From 0700d5d078297494331c0ee112c658a66e67af8b Mon Sep 17 00:00:00 2001 From: luis_pereira87 Date: Tue, 14 Jun 2022 18:35:40 +0100 Subject: [PATCH 01/13] Add 5G SA end-to-end, step-by-step, tutorials for OAI CN5G, OAI gNB and COTS UE --- doc/NR_SA_CN5G_gNB_B210_COTS_UE_Tutorial.md | 14 ++- doc/NR_SA_CN5G_gNB_N300_COTS_UE_Tutorial.md | 14 ++- .../docker-compose-basic-nrf.yaml | 96 ++++++++++++++----- doc/tutorial_resources/oai_db.sql | 22 ++++- 4 files changed, 107 insertions(+), 39 deletions(-) diff --git a/doc/NR_SA_CN5G_gNB_B210_COTS_UE_Tutorial.md b/doc/NR_SA_CN5G_gNB_B210_COTS_UE_Tutorial.md index 1110a5bc6c..da013515da 100644 --- a/doc/NR_SA_CN5G_gNB_B210_COTS_UE_Tutorial.md +++ b/doc/NR_SA_CN5G_gNB_B210_COTS_UE_Tutorial.md @@ -86,6 +86,7 @@ cd ~/oai-cn5g-fed git checkout master ./scripts/syncComponents.sh --nrf-branch develop --amf-branch develop --smf-branch develop --spgwu-tiny-branch develop --ausf-branch develop --udm-branch develop --udr-branch develop --upf-vpp-branch develop --nssf-branch develop +# Pull docker images docker pull oaisoftwarealliance/oai-amf:develop docker pull oaisoftwarealliance/oai-nrf:develop docker pull oaisoftwarealliance/oai-smf:develop @@ -95,7 +96,9 @@ docker pull oaisoftwarealliance/oai-ausf:develop docker pull oaisoftwarealliance/oai-upf-vpp:develop docker pull oaisoftwarealliance/oai-spgwu-tiny:develop docker pull oaisoftwarealliance/oai-nssf:develop +docker pull oaisoftwarealliance/trf-gen-cn5g:latest +# Tag docker images docker image tag oaisoftwarealliance/oai-amf:develop oai-amf:develop docker image tag oaisoftwarealliance/oai-nrf:develop oai-nrf:develop docker image tag oaisoftwarealliance/oai-smf:develop oai-smf:develop @@ -105,16 +108,17 @@ docker image tag oaisoftwarealliance/oai-ausf:develop oai-ausf:develop docker image tag oaisoftwarealliance/oai-upf-vpp:develop oai-upf-vpp:develop docker image tag oaisoftwarealliance/oai-spgwu-tiny:develop oai-spgwu-tiny:develop docker image tag oaisoftwarealliance/oai-nssf:develop oai-nssf:develop +docker image tag oaisoftwarealliance/trf-gen-cn5g:latest trf-gen-cn5g:latest ``` ## 2.3 OAI CN5G Configuration files -Download and copy the configuration files to ~/oai-cn5g-fed/docker-compose: -- [docker-compose-basic-nrf.yaml](tutorial_resources/docker-compose-basic-nrf.yaml) -- [oai_db.sql](tutorial_resources/oai_db.sql) +Download and copy configuration files: +- Copy [docker-compose-basic-nrf.yaml](tutorial_resources/docker-compose-basic-nrf.yaml) to `~/oai-cn5g-fed/docker-compose` +- Copy [oai_db.sql](tutorial_resources/oai_db.sql) to `~/oai-cn5g-fed/docker-compose/database` Change permissions on oai_db.sql to prevent mysql permission denied error: ```bash -chmod 644 ~/oai-cn5g-fed/docker-compose/oai_db.sql +chmod 644 ~/oai-cn5g-fed/docker-compose/database/oai_db.sql ``` ## 2.4 SIM Card @@ -175,7 +179,7 @@ cd cmake_targets ```bash cd ~/oai-cn5g-fed/docker-compose -python3 core-network.py --type start-basic --fqdn yes --scenario 1 +python3 core-network.py --type start-basic --scenario 1 ``` ## 4.2 Run OAI gNB diff --git a/doc/NR_SA_CN5G_gNB_N300_COTS_UE_Tutorial.md b/doc/NR_SA_CN5G_gNB_N300_COTS_UE_Tutorial.md index ed917e09ea..ac61363af0 100644 --- a/doc/NR_SA_CN5G_gNB_N300_COTS_UE_Tutorial.md +++ b/doc/NR_SA_CN5G_gNB_N300_COTS_UE_Tutorial.md @@ -87,6 +87,7 @@ cd ~/oai-cn5g-fed git checkout master ./scripts/syncComponents.sh --nrf-branch develop --amf-branch develop --smf-branch develop --spgwu-tiny-branch develop --ausf-branch develop --udm-branch develop --udr-branch develop --upf-vpp-branch develop --nssf-branch develop +# Pull docker images docker pull oaisoftwarealliance/oai-amf:develop docker pull oaisoftwarealliance/oai-nrf:develop docker pull oaisoftwarealliance/oai-smf:develop @@ -96,7 +97,9 @@ docker pull oaisoftwarealliance/oai-ausf:develop docker pull oaisoftwarealliance/oai-upf-vpp:develop docker pull oaisoftwarealliance/oai-spgwu-tiny:develop docker pull oaisoftwarealliance/oai-nssf:develop +docker pull oaisoftwarealliance/trf-gen-cn5g:latest +# Tag docker images docker image tag oaisoftwarealliance/oai-amf:develop oai-amf:develop docker image tag oaisoftwarealliance/oai-nrf:develop oai-nrf:develop docker image tag oaisoftwarealliance/oai-smf:develop oai-smf:develop @@ -106,16 +109,17 @@ docker image tag oaisoftwarealliance/oai-ausf:develop oai-ausf:develop docker image tag oaisoftwarealliance/oai-upf-vpp:develop oai-upf-vpp:develop docker image tag oaisoftwarealliance/oai-spgwu-tiny:develop oai-spgwu-tiny:develop docker image tag oaisoftwarealliance/oai-nssf:develop oai-nssf:develop +docker image tag oaisoftwarealliance/trf-gen-cn5g:latest trf-gen-cn5g:latest ``` ## 2.3 OAI CN5G Configuration files -Download and copy the configuration files to ~/oai-cn5g-fed/docker-compose: -- [docker-compose-basic-nrf.yaml](tutorial_resources/docker-compose-basic-nrf.yaml) -- [oai_db.sql](tutorial_resources/oai_db.sql) +Download and copy configuration files: +- Copy [docker-compose-basic-nrf.yaml](tutorial_resources/docker-compose-basic-nrf.yaml) to `~/oai-cn5g-fed/docker-compose` +- Copy [oai_db.sql](tutorial_resources/oai_db.sql) to `~/oai-cn5g-fed/docker-compose/database` Change permissions on oai_db.sql to prevent mysql permission denied error: ```bash -chmod 644 ~/oai-cn5g-fed/docker-compose/oai_db.sql +chmod 644 ~/oai-cn5g-fed/docker-compose/database/oai_db.sql ``` ## 2.4 SIM Card @@ -193,7 +197,7 @@ The following steps are recommended. Please change the network interface(s) as r ```bash cd ~/oai-cn5g-fed/docker-compose -python3 core-network.py --type start-basic --fqdn yes --scenario 1 +python3 core-network.py --type start-basic --scenario 1 ``` ## 4.2 Run OAI gNB diff --git a/doc/tutorial_resources/docker-compose-basic-nrf.yaml b/doc/tutorial_resources/docker-compose-basic-nrf.yaml index 6750cb78be..93c438055e 100644 --- a/doc/tutorial_resources/docker-compose-basic-nrf.yaml +++ b/doc/tutorial_resources/docker-compose-basic-nrf.yaml @@ -4,8 +4,8 @@ services: container_name: "mysql" image: mysql:5.7 volumes: - - ./oai_db.sql:/docker-entrypoint-initdb.d/oai_db.sql - - ./mysql-healthcheck2.sh:/tmp/mysql-healthcheck.sh + - ./database/oai_db.sql:/docker-entrypoint-initdb.d/oai_db.sql + - ./healthscripts/mysql-healthcheck2.sh:/tmp/mysql-healthcheck.sh environment: - TZ=Europe/Paris - MYSQL_DATABASE=oai_db @@ -21,35 +21,45 @@ services: public_net: ipv4_address: 192.168.70.131 oai-udr: - container_name: oai-udr + container_name: "oai-udr" image: oai-udr:develop environment: - TZ=Europe/Paris - INSTANCE=0 - PID_DIRECTORY=/var/run + - UDR_NAME=OAI_UDR - UDR_INTERFACE_NAME_FOR_NUDR=eth0 - UDR_INTERFACE_PORT_FOR_NUDR=80 - UDR_INTERFACE_HTTP2_PORT_FOR_NUDR=8080 + - USE_HTTP2=no - UDR_API_VERSION=v1 - MYSQL_IPV4_ADDRESS=192.168.70.131 - MYSQL_USER=test - MYSQL_PASS=test + - DB_CONNECTION_TIMEOUT=300 # Reset the connection to the DB after expiring the timeout (in second) currently can't be changed - MYSQL_DB=oai_db - WAIT_MYSQL=120 + - USE_FQDN_DNS=yes + - REGISTER_NRF=yes + - NRF_IPV4_ADDRESS=192.168.70.130 + - NRF_PORT=80 + - NRF_API_VERSION=v1 + - NRF_FQDN=oai-nrf depends_on: - mysql + - oai-nrf networks: public_net: ipv4_address: 192.168.70.136 volumes: - - ./udr-healthcheck.sh:/openair-udr/bin/udr-healthcheck.sh + - ./healthscripts/udr-healthcheck.sh:/openair-udr/bin/udr-healthcheck.sh healthcheck: test: /bin/bash -c "/openair-udr/bin/udr-healthcheck.sh" interval: 10s timeout: 5s retries: 5 oai-udm: - container_name: oai-udm + container_name: "oai-udm" image: oai-udm:develop environment: - TZ=Europe/Paris @@ -58,26 +68,33 @@ services: - UDM_NAME=OAI_UDM - SBI_IF_NAME=eth0 - SBI_PORT=80 + - SBI_HTTP2_PORT=8080 + - USE_HTTP2=no - UDM_VERSION_NB=v1 - USE_FQDN_DNS=yes - UDR_IP_ADDRESS=192.168.70.136 - UDR_PORT=80 - UDR_VERSION_NB=v1 - UDR_FQDN=oai-udr + - REGISTER_NRF=yes + - NRF_IPV4_ADDRESS=192.168.70.130 + - NRF_PORT=80 + - NRF_API_VERSION=v1 + - NRF_FQDN=oai-nrf depends_on: - oai-udr networks: public_net: ipv4_address: 192.168.70.137 volumes: - - ./udm-healthcheck.sh:/openair-udm/bin/udm-healthcheck.sh + - ./healthscripts/udm-healthcheck.sh:/openair-udm/bin/udm-healthcheck.sh healthcheck: test: /bin/bash -c "/openair-udm/bin/udm-healthcheck.sh" interval: 10s timeout: 5s retries: 5 oai-ausf: - container_name: oai-ausf + container_name: "oai-ausf" image: oai-ausf:develop environment: - TZ=Europe/Paris @@ -86,18 +103,25 @@ services: - AUSF_NAME=OAI_AUSF - SBI_IF_NAME=eth0 - SBI_PORT=80 + - USE_HTTP2 + - SBI_HTTP2_PORT - USE_FQDN_DNS=yes - UDM_IP_ADDRESS=192.168.70.137 - UDM_PORT=80 - UDM_VERSION_NB=v1 - UDM_FQDN=oai-udm + - REGISTER_NRF=yes + - NRF_IPV4_ADDRESS=192.168.70.130 + - NRF_PORT=80 + - NRF_API_VERSION=v1 + - NRF_FQDN=oai-nrf depends_on: - oai-udm networks: public_net: ipv4_address: 192.168.70.138 volumes: - - ./ausf-healthcheck.sh:/openair-ausf/bin/ausf-healthcheck.sh + - ./healthscripts/ausf-healthcheck.sh:/openair-ausf/bin/ausf-healthcheck.sh healthcheck: test: /bin/bash -c "/openair-ausf/bin/ausf-healthcheck.sh" interval: 10s @@ -107,9 +131,10 @@ services: container_name: "oai-nrf" image: oai-nrf:develop environment: + - TZ=Europe/Paris - NRF_INTERFACE_NAME_FOR_SBI=eth0 - NRF_INTERFACE_PORT_FOR_SBI=80 - - NRF_INTERFACE_HTTP2_PORT_FOR_SBI=9090 + - NRF_INTERFACE_HTTP2_PORT_FOR_SBI=8080 - NRF_API_VERSION=v1 - INSTANCE=0 - PID_DIRECTORY=/var/run @@ -117,7 +142,7 @@ services: public_net: ipv4_address: 192.168.70.130 volumes: - - ./nrf-healthcheck.sh:/openair-nrf/bin/nrf-healthcheck.sh + - ./healthscripts/nrf-healthcheck.sh:/openair-nrf/bin/nrf-healthcheck.sh healthcheck: test: /bin/bash -c "/openair-nrf/bin/nrf-healthcheck.sh" interval: 10s @@ -146,9 +171,7 @@ services: - PLMN_SUPPORT_MNC=99 - PLMN_SUPPORT_TAC=0x0001 - SST_0=1 - - SD_0=1 - - SST_1=1 - - SD_1=12 + - SD_0=0x1 - AMF_INTERFACE_NAME_FOR_NGAP=eth0 - AMF_INTERFACE_NAME_FOR_N11=eth0 - SMF_INSTANCE_ID_0=1 @@ -168,22 +191,30 @@ services: - OPERATOR_KEY=1006020f0a478bf6b699f15c062e42b3 - NRF_IPV4_ADDRESS=192.168.70.130 - NRF_PORT=80 + - EXTERNAL_NRF=no - NF_REGISTRATION=yes - SMF_SELECTION=yes - USE_FQDN_DNS=yes - EXTERNAL_AUSF=yes + - EXTERNAL_UDM=no + - EXTERNAL_NSSF=no + - USE_HTTP2=no - NRF_API_VERSION=v1 - NRF_FQDN=oai-nrf - AUSF_IPV4_ADDRESS=192.168.70.138 - AUSF_PORT=80 - AUSF_API_VERSION=v1 - AUSF_FQDN=oai-ausf + - UDM_IPV4_ADDRESS=192.168.70.137 + - UDM_PORT=80 + - UDM_API_VERSION=v2 + - UDM_FQDN=oai-udm depends_on: - mysql - oai-nrf - oai-ausf volumes: - - ./amf-healthcheck.sh:/openair-amf/bin/amf-healthcheck.sh + - ./healthscripts/amf-healthcheck.sh:/openair-amf/bin/amf-healthcheck.sh healthcheck: test: /bin/bash -c "/openair-amf/bin/amf-healthcheck.sh" interval: 10s @@ -212,26 +243,35 @@ services: - AMF_FQDN=oai-amf - UDM_IPV4_ADDRESS=192.168.70.137 - UDM_PORT=80 - - UDM_API_VERSION=v1 + - UDM_API_VERSION=v2 - UDM_FQDN=oai-udm - UPF_IPV4_ADDRESS=192.168.70.134 - UPF_FQDN_0=oai-spgwu - NRF_IPV4_ADDRESS=192.168.70.130 - NRF_PORT=80 - NRF_API_VERSION=v1 - - USE_LOCAL_SUBSCRIPTION_INFO=yes + - USE_LOCAL_SUBSCRIPTION_INFO=yes #Set to yes if SMF uses local subscription information instead of from an UDM + - USE_NETWORK_INSTANCE=no #Set yes if network instance is to be used for given UPF - NRF_FQDN=oai-nrf - REGISTER_NRF=yes - DISCOVER_UPF=yes - USE_FQDN_DNS=yes - - DNN_RANGE1=12.1.1.2 - 12.1.1.128 - - DNN_RANGE0=12.2.1.2 - 12.2.1.128 - - DNN_NI1=oai + - HTTP_VERSION=1 # Default: 1 + - UE_MTU=1500 + - DNN_NI0=oai + - TYPE0=IPv4 + - DNN_RANGE0=12.1.1.2 - 12.1.1.253 + - NSSAI_SST0=1 + - NSSAI_SD0=0x1 + - SESSION_AMBR_UL0=1000Mbps + - SESSION_AMBR_DL0=1000Mbps + - DEFAULT_CSCF_IPV4_ADDRESS=127.0.0.1 # only needed when ims is being used + - ENABLE_USAGE_REPORTING=no # Set yes if UE USAGE REPORTING is to be done at UPF depends_on: - oai-nrf - oai-amf volumes: - - ./smf-healthcheck.sh:/openair-smf/bin/smf-healthcheck.sh + - ./healthscripts/smf-healthcheck.sh:/openair-smf/bin/smf-healthcheck.sh healthcheck: test: /bin/bash -c "/openair-smf/bin/smf-healthcheck.sh" interval: 10s @@ -258,17 +298,23 @@ services: - MNC03=099 - TAC=1 - GW_ID=1 + - THREAD_S1U_PRIO=80 + - S1U_THREADS=8 + - THREAD_SX_PRIO=81 + - SX_THREADS=1 + - THREAD_SGI_PRIO=80 + - SGI_THREADS=8 - REALM=openairinterface.org - ENABLE_5G_FEATURES=yes - REGISTER_NRF=yes - - USE_FQDN_NRF=no + - USE_FQDN_NRF=yes - UPF_FQDN_5G=oai-spgwu - NRF_IPV4_ADDRESS=192.168.70.130 - NRF_PORT=80 - NRF_API_VERSION=v1 - NRF_FQDN=oai-nrf - NSSAI_SST_0=1 - - NSSAI_SD_0=1 + - NSSAI_SD_0=0x1 - DNN_0=oai depends_on: - oai-nrf @@ -280,7 +326,7 @@ services: - ALL privileged: true volumes: - - ./spgwu-healthcheck.sh:/openair-spgwu-tiny/bin/spgwu-healthcheck.sh + - ./healthscripts/spgwu-healthcheck.sh:/openair-spgwu-tiny/bin/spgwu-healthcheck.sh healthcheck: test: /bin/bash -c "/openair-spgwu-tiny/bin/spgwu-healthcheck.sh" interval: 10s @@ -290,12 +336,10 @@ services: public_net: ipv4_address: 192.168.70.134 oai-ext-dn: - image: ubuntu:bionic + image: trf-gen-cn5g:latest privileged: true container_name: oai-ext-dn entrypoint: /bin/bash -c \ - "apt update; apt install -y iptables iproute2 iperf iperf3 iputils-ping;"\ - "iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE;"\ "ip route add 12.1.1.0/24 via 192.168.70.134 dev eth0; sleep infinity" depends_on: - oai-spgwu diff --git a/doc/tutorial_resources/oai_db.sql b/doc/tutorial_resources/oai_db.sql index e019c60e86..fb8f4b20ed 100644 --- a/doc/tutorial_resources/oai_db.sql +++ b/doc/tutorial_resources/oai_db.sql @@ -151,10 +151,13 @@ CREATE TABLE `AuthenticationSubscription` ( -- INSERT INTO `AuthenticationSubscription` (`ueid`, `authenticationMethod`, `encPermanentKey`, `protectionParameterId`, `sequenceNumber`, `authenticationManagementField`, `algorithmId`, `encOpcKey`, `encTopcKey`, `vectorGenerationInHss`, `n5gcAuthMethod`, `rgAuthenticationInd`, `supi`) VALUES -('208950000000031', '5G_AKA', '0C0A34601D4F07677303652C0462535B', '0C0A34601D4F07677303652C0462535B', '{\"sqn\": \"000000000020\", \"sqnScheme\": \"NON_TIME_BASED\", \"lastIndexes\": {\"ausf\": 0}}', '8000', 'milenage', '63bfa50ee6523365ff14c1f45f88737d', NULL, NULL, NULL, NULL, '208950000000031'); - + ('2089900007487', '5G_AKA', 'fec86ba6eb707ed08905757b1bb44b8f', 'fec86ba6eb707ed08905757b1bb44b8f', '{\"sqn\": \"000000000000\", \"sqnScheme\": \"NON_TIME_BASED\", \"lastIndexes\": {\"ausf\": 0}}', '8000', 'milenage', 'C42449363BBAD02B66D16BC975D77CC1', NULL, NULL, NULL, NULL, '2089900007487'); INSERT INTO `AuthenticationSubscription` (`ueid`, `authenticationMethod`, `encPermanentKey`, `protectionParameterId`, `sequenceNumber`, `authenticationManagementField`, `algorithmId`, `encOpcKey`, `encTopcKey`, `vectorGenerationInHss`, `n5gcAuthMethod`, `rgAuthenticationInd`, `supi`) VALUES -('208990000000001', '5G_AKA', 'fec86ba6eb707ed08905757b1bb44b8f', 'fec86ba6eb707ed08905757b1bb44b8f', '{\"sqn\": \"000000000020\", \"sqnScheme\": \"NON_TIME_BASED\", \"lastIndexes\": {\"ausf\": 0}}', '8000', 'milenage', 'C42449363BBAD02B66D16BC975D77CC1', NULL, NULL, NULL, NULL, '208990000000001'); + ('208990000000001', '5G_AKA', 'fec86ba6eb707ed08905757b1bb44b8f', 'fec86ba6eb707ed08905757b1bb44b8f', '{\"sqn\": \"000000000000\", \"sqnScheme\": \"NON_TIME_BASED\", \"lastIndexes\": {\"ausf\": 0}}', '8000', 'milenage', 'C42449363BBAD02B66D16BC975D77CC1', NULL, NULL, NULL, NULL, '208990000000001'); +INSERT INTO `AuthenticationSubscription` (`ueid`, `authenticationMethod`, `encPermanentKey`, `protectionParameterId`, `sequenceNumber`, `authenticationManagementField`, `algorithmId`, `encOpcKey`, `encTopcKey`, `vectorGenerationInHss`, `n5gcAuthMethod`, `rgAuthenticationInd`, `supi`) VALUES + ('208990000000002', '5G_AKA', 'fec86ba6eb707ed08905757b1bb44b8f', 'fec86ba6eb707ed08905757b1bb44b8f', '{\"sqn\": \"000000000000\", \"sqnScheme\": \"NON_TIME_BASED\", \"lastIndexes\": {\"ausf\": 0}}', '8000', 'milenage', 'C42449363BBAD02B66D16BC975D77CC1', NULL, NULL, NULL, NULL, '208990000000002'); +INSERT INTO `AuthenticationSubscription` (`ueid`, `authenticationMethod`, `encPermanentKey`, `protectionParameterId`, `sequenceNumber`, `authenticationManagementField`, `algorithmId`, `encOpcKey`, `encTopcKey`, `vectorGenerationInHss`, `n5gcAuthMethod`, `rgAuthenticationInd`, `supi`) VALUES + ('208990000000003', '5G_AKA', 'fec86ba6eb707ed08905757b1bb44b8f', 'fec86ba6eb707ed08905757b1bb44b8f', '{\"sqn\": \"000000000000\", \"sqnScheme\": \"NON_TIME_BASED\", \"lastIndexes\": {\"ausf\": 0}}', '8000', 'milenage', 'C42449363BBAD02B66D16BC975D77CC1', NULL, NULL, NULL, NULL, '208990000000003'); -- -------------------------------------------------------- @@ -203,6 +206,19 @@ CREATE TABLE `SessionManagementSubscriptionData` ( `3gppChargingCharacteristics` varchar(50) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +-- +-- Dumping data for table `SessionManagementSubscriptionData` +-- + +INSERT INTO `SessionManagementSubscriptionData` (`ueid`, `servingPlmnid`, `singleNssai`, `dnnConfigurations`) VALUES + ('2089900007487', '20899', '{\"sst\": 1, \"sd\": \"1\"}','{\"oai\":{\"pduSessionTypes\":{ \"defaultSessionType\": \"IPV4\"},\"sscModes\": {\"defaultSscMode\": \"SSC_MODE_1\"},\"5gQosProfile\": {\"5qi\": 6,\"arp\":{\"priorityLevel\": 1,\"preemptCap\": \"NOT_PREEMPT\",\"preemptVuln\":\"NOT_PREEMPTABLE\"},\"priorityLevel\":1},\"sessionAmbr\":{\"uplink\":\"1000Mbps\", \"downlink\":\"1000Mbps\"},\"staticIpAddress\":[{\"ipv4Addr\": \"12.1.1.2\"}]}}'); +INSERT INTO `SessionManagementSubscriptionData` (`ueid`, `servingPlmnid`, `singleNssai`, `dnnConfigurations`) VALUES + ('208990000000001', '20899', '{\"sst\": 1, \"sd\": \"1\"}','{\"oai\":{\"pduSessionTypes\":{ \"defaultSessionType\": \"IPV4\"},\"sscModes\": {\"defaultSscMode\": \"SSC_MODE_1\"},\"5gQosProfile\": {\"5qi\": 6,\"arp\":{\"priorityLevel\": 1,\"preemptCap\": \"NOT_PREEMPT\",\"preemptVuln\":\"NOT_PREEMPTABLE\"},\"priorityLevel\":1},\"sessionAmbr\":{\"uplink\":\"1000Mbps\", \"downlink\":\"1000Mbps\"},\"staticIpAddress\":[{\"ipv4Addr\": \"12.1.1.2\"}]}}'); +INSERT INTO `SessionManagementSubscriptionData` (`ueid`, `servingPlmnid`, `singleNssai`, `dnnConfigurations`) VALUES + ('208990000000002', '20899', '{\"sst\": 1, \"sd\": \"1\"}','{\"oai\":{\"pduSessionTypes\":{ \"defaultSessionType\": \"IPV4\"},\"sscModes\": {\"defaultSscMode\": \"SSC_MODE_1\"},\"5gQosProfile\": {\"5qi\": 6,\"arp\":{\"priorityLevel\": 1,\"preemptCap\": \"NOT_PREEMPT\",\"preemptVuln\":\"NOT_PREEMPTABLE\"},\"priorityLevel\":1},\"sessionAmbr\":{\"uplink\":\"1000Mbps\", \"downlink\":\"1000Mbps\"},\"staticIpAddress\":[{\"ipv4Addr\": \"12.1.1.3\"}]}}'); +INSERT INTO `SessionManagementSubscriptionData` (`ueid`, `servingPlmnid`, `singleNssai`, `dnnConfigurations`) VALUES + ('208990000000003', '20899', '{\"sst\": 1, \"sd\": \"1\"}','{\"oai\":{\"pduSessionTypes\":{ \"defaultSessionType\": \"IPV4\"},\"sscModes\": {\"defaultSscMode\": \"SSC_MODE_1\"},\"5gQosProfile\": {\"5qi\": 6,\"arp\":{\"priorityLevel\": 1,\"preemptCap\": \"NOT_PREEMPT\",\"preemptVuln\":\"NOT_PREEMPTABLE\"},\"priorityLevel\":1},\"sessionAmbr\":{\"uplink\":\"1000Mbps\", \"downlink\":\"1000Mbps\"},\"staticIpAddress\":[{\"ipv4Addr\": \"12.1.1.4\"}]}}'); + -- -------------------------------------------------------- -- From 43298fd02ce8b46636273049a393338117e63aca Mon Sep 17 00:00:00 2001 From: luis_pereira87 Date: Fri, 15 Jul 2022 13:19:37 +0100 Subject: [PATCH 02/13] Address merge request review comments --- doc/NR_SA_CN5G_gNB_B210_COTS_UE_Tutorial.md | 11 ---------- doc/NR_SA_CN5G_gNB_N300_COTS_UE_Tutorial.md | 11 ---------- .../docker-compose-basic-nrf.yaml | 20 +++++++++---------- 3 files changed, 10 insertions(+), 32 deletions(-) diff --git a/doc/NR_SA_CN5G_gNB_B210_COTS_UE_Tutorial.md b/doc/NR_SA_CN5G_gNB_B210_COTS_UE_Tutorial.md index da013515da..fc0700c699 100644 --- a/doc/NR_SA_CN5G_gNB_B210_COTS_UE_Tutorial.md +++ b/doc/NR_SA_CN5G_gNB_B210_COTS_UE_Tutorial.md @@ -71,10 +71,6 @@ reboot # https://docs.docker.com/compose/install/ sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose sudo chmod +x /usr/local/bin/docker-compose - -docker network create --driver=bridge --subnet=192.168.70.128/26 -o "com.docker.network.bridge.name"="demo-oai" demo-oai-public-net -sudo service docker restart - ``` ## 2.2 OAI CN5G Setup @@ -82,9 +78,6 @@ sudo service docker restart ```bash # Git oai-cn5g-fed repository git clone https://gitlab.eurecom.fr/oai/cn5g/oai-cn5g-fed.git ~/oai-cn5g-fed -cd ~/oai-cn5g-fed -git checkout master -./scripts/syncComponents.sh --nrf-branch develop --amf-branch develop --smf-branch develop --spgwu-tiny-branch develop --ausf-branch develop --udm-branch develop --udr-branch develop --upf-vpp-branch develop --nssf-branch develop # Pull docker images docker pull oaisoftwarealliance/oai-amf:develop @@ -93,9 +86,7 @@ docker pull oaisoftwarealliance/oai-smf:develop docker pull oaisoftwarealliance/oai-udr:develop docker pull oaisoftwarealliance/oai-udm:develop docker pull oaisoftwarealliance/oai-ausf:develop -docker pull oaisoftwarealliance/oai-upf-vpp:develop docker pull oaisoftwarealliance/oai-spgwu-tiny:develop -docker pull oaisoftwarealliance/oai-nssf:develop docker pull oaisoftwarealliance/trf-gen-cn5g:latest # Tag docker images @@ -105,9 +96,7 @@ docker image tag oaisoftwarealliance/oai-smf:develop oai-smf:develop docker image tag oaisoftwarealliance/oai-udr:develop oai-udr:develop docker image tag oaisoftwarealliance/oai-udm:develop oai-udm:develop docker image tag oaisoftwarealliance/oai-ausf:develop oai-ausf:develop -docker image tag oaisoftwarealliance/oai-upf-vpp:develop oai-upf-vpp:develop docker image tag oaisoftwarealliance/oai-spgwu-tiny:develop oai-spgwu-tiny:develop -docker image tag oaisoftwarealliance/oai-nssf:develop oai-nssf:develop docker image tag oaisoftwarealliance/trf-gen-cn5g:latest trf-gen-cn5g:latest ``` diff --git a/doc/NR_SA_CN5G_gNB_N300_COTS_UE_Tutorial.md b/doc/NR_SA_CN5G_gNB_N300_COTS_UE_Tutorial.md index ac61363af0..d68057fd08 100644 --- a/doc/NR_SA_CN5G_gNB_N300_COTS_UE_Tutorial.md +++ b/doc/NR_SA_CN5G_gNB_N300_COTS_UE_Tutorial.md @@ -72,10 +72,6 @@ reboot # https://docs.docker.com/compose/install/ sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose sudo chmod +x /usr/local/bin/docker-compose - -docker network create --driver=bridge --subnet=192.168.70.128/26 -o "com.docker.network.bridge.name"="demo-oai" demo-oai-public-net -sudo service docker restart - ``` ## 2.2 OAI CN5G Setup @@ -83,9 +79,6 @@ sudo service docker restart ```bash # Git oai-cn5g-fed repository git clone https://gitlab.eurecom.fr/oai/cn5g/oai-cn5g-fed.git ~/oai-cn5g-fed -cd ~/oai-cn5g-fed -git checkout master -./scripts/syncComponents.sh --nrf-branch develop --amf-branch develop --smf-branch develop --spgwu-tiny-branch develop --ausf-branch develop --udm-branch develop --udr-branch develop --upf-vpp-branch develop --nssf-branch develop # Pull docker images docker pull oaisoftwarealliance/oai-amf:develop @@ -94,9 +87,7 @@ docker pull oaisoftwarealliance/oai-smf:develop docker pull oaisoftwarealliance/oai-udr:develop docker pull oaisoftwarealliance/oai-udm:develop docker pull oaisoftwarealliance/oai-ausf:develop -docker pull oaisoftwarealliance/oai-upf-vpp:develop docker pull oaisoftwarealliance/oai-spgwu-tiny:develop -docker pull oaisoftwarealliance/oai-nssf:develop docker pull oaisoftwarealliance/trf-gen-cn5g:latest # Tag docker images @@ -106,9 +97,7 @@ docker image tag oaisoftwarealliance/oai-smf:develop oai-smf:develop docker image tag oaisoftwarealliance/oai-udr:develop oai-udr:develop docker image tag oaisoftwarealliance/oai-udm:develop oai-udm:develop docker image tag oaisoftwarealliance/oai-ausf:develop oai-ausf:develop -docker image tag oaisoftwarealliance/oai-upf-vpp:develop oai-upf-vpp:develop docker image tag oaisoftwarealliance/oai-spgwu-tiny:develop oai-spgwu-tiny:develop -docker image tag oaisoftwarealliance/oai-nssf:develop oai-nssf:develop docker image tag oaisoftwarealliance/trf-gen-cn5g:latest trf-gen-cn5g:latest ``` diff --git a/doc/tutorial_resources/docker-compose-basic-nrf.yaml b/doc/tutorial_resources/docker-compose-basic-nrf.yaml index 93c438055e..cd1e957ad8 100644 --- a/doc/tutorial_resources/docker-compose-basic-nrf.yaml +++ b/doc/tutorial_resources/docker-compose-basic-nrf.yaml @@ -347,14 +347,14 @@ services: public_net: ipv4_address: 192.168.70.135 networks: + # public_net: + # external: + # name: demo-oai-public-net public_net: - external: - name: demo-oai-public-net -# public_net: -# driver: bridge -# name: demo-oai-public-net -# ipam: -# config: -# - subnet: 192.168.70.128/26 -# driver_opts: -# com.docker.network.bridge.name: "demo-oai" + driver: bridge + name: demo-oai-public-net + ipam: + config: + - subnet: 192.168.70.128/26 + driver_opts: + com.docker.network.bridge.name: "demo-oai" From 24b651b465f002d8814e20492fa0e8baf6766d1f Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Sun, 19 Jun 2022 17:31:57 +0200 Subject: [PATCH 03/13] Provide build_oai option UBSan --- cmake_targets/CMakeLists.txt | 6 ++++++ cmake_targets/build_oai | 12 +++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 25e10931c7..6446ced4bd 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -271,6 +271,12 @@ if (SANITIZE_ADDRESS) # wrong in the pthread library, or something subtly wrong in this CMakeLists.txt. Use Ubuntu 20.04 instead. endif () +add_boolean_option(SANITIZE_UNDEFINED False "enable the undefined behavior sanitizer (UBSan)") +if (SANITIZE_UNDEFINED) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=undefined -fno-sanitize-recover=all") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined -fno-sanitize-recover=all") +endif () + add_definitions("-DASN_DISABLE_OER_SUPPORT") ######################### diff --git a/cmake_targets/build_oai b/cmake_targets/build_oai index 5a201fcfef..16a0d559dd 100755 --- a/cmake_targets/build_oai +++ b/cmake_targets/build_oai @@ -171,8 +171,12 @@ Options: Skip build for shared libraries to reduce compilation time when building frequently for debugging purposes --ninja Tell cmake to use the Ninja build system. Without, will generate make files +--sanitize + Shortcut for usage of --sanitize-address --sanitize-undefined --sanitize-address | -fsanitize=address - Enable the address sanitizer on all targets + Enable the address sanitizer on all targets +--sanitize-undefined | -fsanitize=undefined + Enable the undefined behavior sanitizer on all targets --ittiSIM Makes the itti simulator -h | --help @@ -451,10 +455,16 @@ function main() { CMAKE_CMD="$CMAKE_CMD -GNinja" MAKE_CMD=ninja shift;; + --sanitize) + CMAKE_CMD="$CMAKE_CMD -DSANITIZE_ADDRESS=True -DSANITIZE_UNDEFINED=True" + shift;; --sanitize-address | -fsanitize=address) grep -sq "Ubuntu 18.04" /etc/os-release && echo_error "Bug in OS with this option, see CMakeLists.txt" CMAKE_CMD="$CMAKE_CMD -DSANITIZE_ADDRESS=True" shift;; + --sanitize-undefined | -fundefined=address) + CMAKE_CMD="$CMAKE_CMD -DSANITIZE_UNDEFINED=True" + shift;; --ittiSIM) ittiSIM=1 CMAKE_CMD="$CMAKE_CMD -DITTI_SIM=True" From b07a167370d5a61fcdd2fd083b386be49ea80c2f Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 24 May 2022 14:43:11 +0200 Subject: [PATCH 04/13] Correct indentation in nr_rx_pdsch() --- .../NR_UE_TRANSPORT/nr_dlsch_demodulation.c | 145 +++++++++--------- 1 file changed, 72 insertions(+), 73 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c index eb43d80525..6728f0260c 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c @@ -466,88 +466,87 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, if (cpumeas(CPUMEAS_GETSTATE)) LOG_D(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d: Channel Combine and zero forcing %5.2f \n",frame,nr_slot_rx,slot,symbol,ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0)); - start_meas(&ue->generic_stat_bis[proc->thread_id][slot]); + start_meas(&ue->generic_stat_bis[proc->thread_id][slot]); /* Store the valid DL RE's */ - pdsch_vars[gNB_id]->dl_valid_re[symbol-1] = nb_re_pdsch; + pdsch_vars[gNB_id]->dl_valid_re[symbol-1] = nb_re_pdsch; - if(dlsch0_harq->status == ACTIVE) { - startSymbIdx = dlsch0_harq->start_symbol; - nbSymb = dlsch0_harq->nb_symbols; - pduBitmap = dlsch0_harq->pduBitmap; - } - if(dlsch1_harq) { - startSymbIdx = dlsch1_harq->start_symbol; - nbSymb = dlsch1_harq->nb_symbols; - pduBitmap = dlsch1_harq->pduBitmap; - } + if(dlsch0_harq->status == ACTIVE) { + startSymbIdx = dlsch0_harq->start_symbol; + nbSymb = dlsch0_harq->nb_symbols; + pduBitmap = dlsch0_harq->pduBitmap; + } + if(dlsch1_harq) { + startSymbIdx = dlsch1_harq->start_symbol; + nbSymb = dlsch1_harq->nb_symbols; + pduBitmap = dlsch1_harq->pduBitmap; + } - /* Check for PTRS bitmap and process it respectively */ - if((pduBitmap & 0x1) && (type == PDSCH)) { - nr_pdsch_ptrs_processing(ue, - pdsch_vars, - frame_parms, - dlsch0_harq, - dlsch1_harq, - gNB_id, - nr_slot_rx, - symbol, - (nb_rb_pdsch*12), - dlsch[0]->rnti,rx_type); - pdsch_vars[gNB_id]->dl_valid_re[symbol-1] -= pdsch_vars[gNB_id]->ptrs_re_per_slot[0][symbol]; - } + /* Check for PTRS bitmap and process it respectively */ + if((pduBitmap & 0x1) && (type == PDSCH)) { + nr_pdsch_ptrs_processing(ue, + pdsch_vars, + frame_parms, + dlsch0_harq, + dlsch1_harq, + gNB_id, + nr_slot_rx, + symbol, + (nb_rb_pdsch*12), + dlsch[0]->rnti,rx_type); + pdsch_vars[gNB_id]->dl_valid_re[symbol-1] -= pdsch_vars[gNB_id]->ptrs_re_per_slot[0][symbol]; + } - /* at last symbol in a slot calculate LLR's for whole slot */ - if(symbol == (startSymbIdx + nbSymb -1)) { - for(uint8_t i =startSymbIdx; i < (startSymbIdx+nbSymb);i++) { - /* re evaluating the first symbol flag as LLR's are done in symbol loop */ - if(i == startSymbIdx && i < 3) { - first_symbol_flag =1; - } - else { - first_symbol_flag=0; - } - /* Calculate LLR's for each symbol */ - nr_dlsch_llr(pdsch_vars, frame_parms, - rxdataF_comp_ptr, dl_ch_mag_ptr, - dlsch0_harq, dlsch1_harq, - rx_type, harq_pid, - gNB_id, gNB_id_i, - first_symbol_flag, - i, nb_rb_pdsch, - codeword_TB0, codeword_TB1, - pdsch_vars[gNB_id]->dl_valid_re[i-1], - nr_slot_rx, beamforming_mode); + /* at last symbol in a slot calculate LLR's for whole slot */ + if(symbol == (startSymbIdx + nbSymb -1)) { + for(uint8_t i =startSymbIdx; i < (startSymbIdx+nbSymb);i++) { + /* re evaluating the first symbol flag as LLR's are done in symbol loop */ + if(i == startSymbIdx && i < 3) { + first_symbol_flag =1; } - - int dmrs_type = dlsch[0]->harq_processes[harq_pid]->dmrsConfigType; - uint8_t nb_re_dmrs; - uint16_t dmrs_len = get_num_dmrs(dlsch[0]->harq_processes[harq_pid]->dlDmrsSymbPos); - if (dmrs_type==NFAPI_NR_DMRS_TYPE1) { - nb_re_dmrs = 6*dlsch[0]->harq_processes[harq_pid]->n_dmrs_cdm_groups; - } else { - nb_re_dmrs = 4*dlsch[0]->harq_processes[harq_pid]->n_dmrs_cdm_groups; + else { + first_symbol_flag=0; } - dlsch[0]->harq_processes[harq_pid]->G = nr_get_G(dlsch[0]->harq_processes[harq_pid]->nb_rb, - dlsch[0]->harq_processes[harq_pid]->nb_symbols, - nb_re_dmrs, - dmrs_len, - dlsch[0]->harq_processes[harq_pid]->Qm, - dlsch[0]->harq_processes[harq_pid]->Nl); - nr_dlsch_layer_demapping(pdsch_vars[gNB_id]->llr, - dlsch[0]->harq_processes[harq_pid]->Nl, - dlsch[0]->harq_processes[harq_pid]->Qm, - dlsch[0]->harq_processes[harq_pid]->G, - codeword_TB0, - codeword_TB1, - pdsch_vars[gNB_id]->layer_llr); - + /* Calculate LLR's for each symbol */ + nr_dlsch_llr(pdsch_vars, frame_parms, + rxdataF_comp_ptr, dl_ch_mag_ptr, + dlsch0_harq, dlsch1_harq, + rx_type, harq_pid, + gNB_id, gNB_id_i, + first_symbol_flag, + i, nb_rb_pdsch, + codeword_TB0, codeword_TB1, + pdsch_vars[gNB_id]->dl_valid_re[i-1], + nr_slot_rx, beamforming_mode); } - stop_meas(&ue->generic_stat_bis[proc->thread_id][slot]); - if (cpumeas(CPUMEAS_GETSTATE)) - LOG_D(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d: LLR Computation %5.2f \n",frame,nr_slot_rx,slot,symbol,ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0)); + int dmrs_type = dlsch[0]->harq_processes[harq_pid]->dmrsConfigType; + uint8_t nb_re_dmrs; + uint16_t dmrs_len = get_num_dmrs(dlsch[0]->harq_processes[harq_pid]->dlDmrsSymbPos); + if (dmrs_type==NFAPI_NR_DMRS_TYPE1) { + nb_re_dmrs = 6*dlsch[0]->harq_processes[harq_pid]->n_dmrs_cdm_groups; + } else { + nb_re_dmrs = 4*dlsch[0]->harq_processes[harq_pid]->n_dmrs_cdm_groups; + } + dlsch[0]->harq_processes[harq_pid]->G = nr_get_G(dlsch[0]->harq_processes[harq_pid]->nb_rb, + dlsch[0]->harq_processes[harq_pid]->nb_symbols, + nb_re_dmrs, + dmrs_len, + dlsch[0]->harq_processes[harq_pid]->Qm, + dlsch[0]->harq_processes[harq_pid]->Nl); + nr_dlsch_layer_demapping(pdsch_vars[gNB_id]->llr, + dlsch[0]->harq_processes[harq_pid]->Nl, + dlsch[0]->harq_processes[harq_pid]->Qm, + dlsch[0]->harq_processes[harq_pid]->G, + codeword_TB0, + codeword_TB1, + pdsch_vars[gNB_id]->layer_llr); + } -// Please keep it: useful for debugging + stop_meas(&ue->generic_stat_bis[proc->thread_id][slot]); + if (cpumeas(CPUMEAS_GETSTATE)) + LOG_D(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d: LLR Computation %5.2f \n",frame,nr_slot_rx,slot,symbol,ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0)); + + // Please keep it: useful for debugging #ifdef DEBUG_PDSCH_RX char filename[50]; uint8_t aa = 0; From 6b757c53209bbffa4b3eb58d1d61948969b09037 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 24 May 2022 14:43:49 +0200 Subject: [PATCH 05/13] Correct array sizes in dlsim --- openair1/SIMULATION/LTE_PHY/dlsim.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/openair1/SIMULATION/LTE_PHY/dlsim.c b/openair1/SIMULATION/LTE_PHY/dlsim.c index 231d63cf04..d715423bb1 100644 --- a/openair1/SIMULATION/LTE_PHY/dlsim.c +++ b/openair1/SIMULATION/LTE_PHY/dlsim.c @@ -512,12 +512,12 @@ int main(int argc, char **argv) { int re; int s,Kr,Kr_bytes; LTE_DL_FRAME_PARMS *frame_parms; - double s_re0[30720*2],s_im0[30720*2],r_re0[30720*2],r_im0[30720*2]; - double s_re1[30720*2],s_im1[30720*2],r_re1[30720*2],r_im1[30720*2]; - double *s_re[2]= {s_re0,s_re1}; - double *s_im[2]= {s_im0,s_im1}; - double *r_re[2]= {r_re0,r_re1}; - double *r_im[2]= {r_im0,r_im1}; + double s_re0[30720*NB_ANTENNAS_TX],s_im0[30720*NB_ANTENNAS_TX],r_re0[30720*NB_ANTENNAS_RX],r_im0[30720*NB_ANTENNAS_RX]; + double s_re1[30720*NB_ANTENNAS_TX],s_im1[30720*NB_ANTENNAS_TX],r_re1[30720*NB_ANTENNAS_RX],r_im1[30720*NB_ANTENNAS_RX]; + double *s_re[NB_ANTENNAS_TX]= {s_re0,s_re1}; + double *s_im[NB_ANTENNAS_TX]= {s_im0,s_im1}; + double *r_re[NB_ANTENNAS_RX]= {r_re0,r_re1}; + double *r_im[NB_ANTENNAS_RX]= {r_im0,r_im1}; uint8_t transmission_mode=1,n_tx_port=1,n_tx_phy=1,n_rx=2; int eNB_id = 0; unsigned char round; From db7f39ba19e10ec27d05673ab1f1a6a518327af8 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 24 May 2022 14:47:30 +0200 Subject: [PATCH 06/13] Use correct structure in sctp_eNB_accept_associations() --- openair3/SCTP/sctp_eNB_task.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openair3/SCTP/sctp_eNB_task.c b/openair3/SCTP/sctp_eNB_task.c index 06e606e36b..df6dde0f99 100644 --- a/openair3/SCTP/sctp_eNB_task.c +++ b/openair3/SCTP/sctp_eNB_task.c @@ -859,7 +859,7 @@ sctp_eNB_accept_associations( struct sctp_cnx_list_elm_s *sctp_cnx) { int client_sd; - struct sockaddr saddr; + struct sockaddr_in6 saddr; socklen_t saddr_size; DevAssert(sctp_cnx != NULL); @@ -868,14 +868,14 @@ sctp_eNB_accept_associations( /* There is a new client connecting. Accept it... */ - if ((client_sd = accept(sctp_cnx->sd, &saddr, &saddr_size)) < 0) { + if ((client_sd = accept(sctp_cnx->sd, (struct sockaddr*)&saddr, &saddr_size)) < 0) { SCTP_ERROR("[%d] accept failed: %s:%d\n", sctp_cnx->sd, strerror(errno), errno); } else { struct sctp_cnx_list_elm_s *new_cnx; uint16_t port; /* This is an ipv6 socket */ - port = ((struct sockaddr_in6*)&saddr)->sin6_port; + port = saddr.sin6_port; /* Contrary to BSD, client socket does not inherit O_NONBLOCK option */ if (fcntl(client_sd, F_SETFL, O_NONBLOCK) < 0) { From 017fd225bcd0716b1856be1584438e7b4c64a3b8 Mon Sep 17 00:00:00 2001 From: laurent Date: Sun, 29 May 2022 14:27:51 +0200 Subject: [PATCH 07/13] fix ubsan detected errors --- common/utils/time_meas.h | 4 +- .../nfapi/public_inc/fapi_nr_ue_interface.h | 2 +- .../nfapi/public_inc/nfapi_nr_interface_scf.h | 2 +- .../CODING/3gpplte_turbo_decoder_sse_8bit.c | 6 +- openair1/PHY/CODING/crc_byte.c | 4 +- .../PHY/CODING/nrLDPC_decoder/nrLDPC_cnProc.h | 45 ++++--- openair1/PHY/LTE_TRANSPORT/dci_tools_common.c | 116 +++++++++--------- openair1/PHY/LTE_TRANSPORT/dlsch_coding.c | 2 +- .../PHY/LTE_UE_TRANSPORT/transport_proto_ue.h | 8 -- openair1/PHY/LTE_UE_TRANSPORT/transport_ue.h | 2 +- openair1/PHY/LTE_UE_TRANSPORT/ulsch_coding.c | 47 +++---- openair1/PHY/MODULATION/nr_modulation.c | 7 +- .../PHY/NR_ESTIMATION/nr_measurements_gNB.c | 2 +- openair1/PHY/NR_TRANSPORT/nr_dlsch.c | 5 +- openair1/SCHED_NR/phy_procedures_nr_gNB.c | 2 +- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 3 +- openair1/SIMULATION/LTE_PHY/dlsim.c | 16 ++- openair1/SIMULATION/LTE_PHY/ulsim.c | 14 +-- openair1/SIMULATION/NR_PHY/dlsim.c | 2 +- openair2/LAYER2/NR_MAC_UE/config_ue.c | 4 +- openair2/LAYER2/NR_MAC_UE/mac_proto.h | 7 -- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 22 ++-- openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c | 44 ++++--- openair2/LAYER2/NR_MAC_gNB/config.c | 2 +- .../LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 2 + openair2/RRC/NR_UE/rrc_UE.c | 4 +- 26 files changed, 191 insertions(+), 183 deletions(-) diff --git a/common/utils/time_meas.h b/common/utils/time_meas.h index fded7f1a9c..eb81d09434 100644 --- a/common/utils/time_meas.h +++ b/common/utils/time_meas.h @@ -62,7 +62,7 @@ typedef struct time_stats { oai_cputime_t in; /*!< \brief time at measure starting point */ oai_cputime_t diff; /*!< \brief average difference between time at starting point and time at endpoint*/ oai_cputime_t p_time; /*!< \brief absolute process duration */ - oai_cputime_t diff_square; /*!< \brief process duration square */ + double diff_square; /*!< \brief process duration square */ oai_cputime_t max; /*!< \brief maximum difference between time at starting point and time at endpoint*/ int trials; /*!< \brief number of start point - end point iterations */ int meas_flag; /*!< \brief 1: stop_meas not called (consecutive calls of start_meas) */ @@ -156,7 +156,7 @@ static inline void stop_meas(time_stats_t *ts) { ts->diff += (out-ts->in); /// process duration is the difference between two clock points ts->p_time = (out-ts->in); - ts->diff_square += (out-ts->in)*(out-ts->in); + ts->diff_square += ((double)out-ts->in)*((double)out-ts->in); if ((out-ts->in) > ts->max) ts->max = out-ts->in; 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 fd9af01720..10f881bae6 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 @@ -87,7 +87,7 @@ typedef struct { // N_CCE is L, or number of CCEs for DCI int N_CCE; uint8_t payloadSize; - uint8_t payloadBits[16]; + uint8_t payloadBits[16] __attribute__((aligned(16))); // will be cast as uint64 //fapi_nr_dci_pdu_rel15_t dci; } fapi_nr_dci_indication_pdu_t; diff --git a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface_scf.h b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface_scf.h index 8b564a5e37..0e393066c8 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface_scf.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface_scf.h @@ -738,7 +738,7 @@ typedef struct { // The total DCI length (in bits) including padding bits [TS38.212 sec 7.3.1] Range 0->DCI_PAYLOAD_BYTE_LEN*8 uint16_t PayloadSizeBits; // DCI payload, where the actual size is defined by PayloadSizeBits. The bit order is as following bit0-bit7 are mapped to first byte of MSB - LSB - uint8_t Payload[DCI_PAYLOAD_BYTE_LEN]; + uint8_t Payload[DCI_PAYLOAD_BYTE_LEN] __attribute__((aligned(32))); } nfapi_nr_dl_dci_pdu_t; diff --git a/openair1/PHY/CODING/3gpplte_turbo_decoder_sse_8bit.c b/openair1/PHY/CODING/3gpplte_turbo_decoder_sse_8bit.c index 264b25deca..af02a16054 100644 --- a/openair1/PHY/CODING/3gpplte_turbo_decoder_sse_8bit.c +++ b/openair1/PHY/CODING/3gpplte_turbo_decoder_sse_8bit.c @@ -814,7 +814,7 @@ uint8_t phy_threegpplte_turbo_decoder8(int16_t *y, llr_t *s1,*s2,*yp1,*yp2,*yp; unsigned int i,j,iind;//,pi; unsigned char iteration_cnt=0; - unsigned int crc,oldcrc,crc_len; + unsigned int crc, crc_len; uint8_t temp; #if defined(__x86_64__) || defined(__i386__) __m128i *yp128; @@ -1233,8 +1233,8 @@ uint8_t phy_threegpplte_turbo_decoder8(int16_t *y, } // check the CRC - oldcrc= *((unsigned int *)(&decoded_bytes[(n>>3)-crc_len])); - + uint32_t oldcrc; + memcpy(&oldcrc, &decoded_bytes[(n >> 3) - crc_len], crc_len); switch (crc_type) { case CRC24_A: oldcrc&=0x00ffffff; diff --git a/openair1/PHY/CODING/crc_byte.c b/openair1/PHY/CODING/crc_byte.c index 9ad18cc1a6..471b26fe24 100644 --- a/openair1/PHY/CODING/crc_byte.c +++ b/openair1/PHY/CODING/crc_byte.c @@ -244,11 +244,11 @@ crc16 (unsigned char * inptr, int bitlen) while (octetlen-- > 0) { - crc = (crc << 8) ^ (crc16Table[(*inptr++) ^ (crc >> 24)] << 16); + crc = (crc << 8) ^ (((uint32_t)crc16Table[(*inptr++) ^ (crc >> 24)]) << 16); } if (resbit > 0) - crc = (crc << resbit) ^ (crc16Table[((*inptr) >> (8 - resbit)) ^ (crc >> (32 - resbit))] << 16); + crc = (crc << resbit) ^ (((uint32_t)crc16Table[(*inptr) >> (8 - resbit) ^ (crc >> (32 - resbit))]) << 16); return crc; } diff --git a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_cnProc.h b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_cnProc.h index f4ea4a9434..f792f993e9 100644 --- a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_cnProc.h +++ b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_cnProc.h @@ -961,7 +961,8 @@ static inline uint32_t nrLDPC_cnProcPc_BG1(t_nrLDPC_lut* p_lut, int8_t* cnProcBu // If no error pcRes should be 0 // Only use valid CNs - pcResSum |= (pcRes&(0xFFFFFFFF>>(32-Mrem))); + if (Mrem) + pcResSum |= (pcRes&(0xFFFFFFFF>>(32-Mrem))); // If PC failed we can stop here if (pcResSum > 0) @@ -1028,7 +1029,8 @@ static inline uint32_t nrLDPC_cnProcPc_BG1(t_nrLDPC_lut* p_lut, int8_t* cnProcBu // If no error pcRes should be 0 // Only use valid CNs - pcResSum |= (pcRes&(0xFFFFFFFF>>(32-Mrem))); + if (Mrem) + pcResSum |= (pcRes&(0xFFFFFFFF>>(32-Mrem))); // If PC failed we can stop here if (pcResSum > 0) @@ -1096,7 +1098,8 @@ static inline uint32_t nrLDPC_cnProcPc_BG1(t_nrLDPC_lut* p_lut, int8_t* cnProcBu // If no error pcRes should be 0 // Only use valid CNs - pcResSum |= (pcRes&(0xFFFFFFFF>>(32-Mrem))); + if (Mrem) + pcResSum |= (pcRes&(0xFFFFFFFF>>(32-Mrem))); // If PC failed we can stop here if (pcResSum > 0) @@ -1163,7 +1166,8 @@ static inline uint32_t nrLDPC_cnProcPc_BG1(t_nrLDPC_lut* p_lut, int8_t* cnProcBu // If no error pcRes should be 0 // Only use valid CNs - pcResSum |= (pcRes&(0xFFFFFFFF>>(32-Mrem))); + if (Mrem) + pcResSum |= (pcRes&(0xFFFFFFFF>>(32-Mrem))); // If PC failed we can stop here if (pcResSum > 0) @@ -1230,7 +1234,8 @@ static inline uint32_t nrLDPC_cnProcPc_BG1(t_nrLDPC_lut* p_lut, int8_t* cnProcBu // If no error pcRes should be 0 // Only use valid CNs - pcResSum |= (pcRes&(0xFFFFFFFF>>(32-Mrem))); + if (Mrem) + pcResSum |= (pcRes&(0xFFFFFFFF>>(32-Mrem))); // If PC failed we can stop here if (pcResSum > 0) @@ -1297,7 +1302,8 @@ static inline uint32_t nrLDPC_cnProcPc_BG1(t_nrLDPC_lut* p_lut, int8_t* cnProcBu // If no error pcRes should be 0 // Only use valid CNs - pcResSum |= (pcRes&(0xFFFFFFFF>>(32-Mrem))); + if (Mrem) + pcResSum |= (pcRes&(0xFFFFFFFF>>(32-Mrem))); // If PC failed we can stop here if (pcResSum > 0) @@ -1364,7 +1370,8 @@ static inline uint32_t nrLDPC_cnProcPc_BG1(t_nrLDPC_lut* p_lut, int8_t* cnProcBu // If no error pcRes should be 0 // Only use valid CNs - pcResSum |= (pcRes&(0xFFFFFFFF>>(32-Mrem))); + if (Mrem) + pcResSum |= (pcRes&(0xFFFFFFFF>>(32-Mrem))); // If PC failed we can stop here if (pcResSum > 0) @@ -1431,7 +1438,8 @@ static inline uint32_t nrLDPC_cnProcPc_BG1(t_nrLDPC_lut* p_lut, int8_t* cnProcBu // If no error pcRes should be 0 // Only use valid CNs - pcResSum |= (pcRes&(0xFFFFFFFF>>(32-Mrem))); + if (Mrem) + pcResSum |= (pcRes&(0xFFFFFFFF>>(32-Mrem))); // If PC failed we can stop here if (pcResSum > 0) @@ -1498,7 +1506,8 @@ static inline uint32_t nrLDPC_cnProcPc_BG1(t_nrLDPC_lut* p_lut, int8_t* cnProcBu // If no error pcRes should be 0 // Only use valid CNs - pcResSum |= (pcRes&(0xFFFFFFFF>>(32-Mrem))); + if (Mrem) + pcResSum |= (pcRes&(0xFFFFFFFF>>(32-Mrem))); // If PC failed we can stop here if (pcResSum > 0) @@ -1593,7 +1602,8 @@ static inline uint32_t nrLDPC_cnProcPc_BG2(t_nrLDPC_lut* p_lut, int8_t* cnProcBu // If no error pcRes should be 0 // Only use valid CNs - pcResSum |= (pcRes&(0xFFFFFFFF>>(32-Mrem))); + if (Mrem) + pcResSum |= (pcRes&(0xFFFFFFFF>>(32-Mrem))); // If PC failed we can stop here if (pcResSum > 0) @@ -1660,7 +1670,8 @@ static inline uint32_t nrLDPC_cnProcPc_BG2(t_nrLDPC_lut* p_lut, int8_t* cnProcBu // If no error pcRes should be 0 // Only use valid CNs - pcResSum |= (pcRes&(0xFFFFFFFF>>(32-Mrem))); + if (Mrem) + pcResSum |= (pcRes&(0xFFFFFFFF>>(32-Mrem))); // If PC failed we can stop here if (pcResSum > 0) @@ -1727,7 +1738,8 @@ static inline uint32_t nrLDPC_cnProcPc_BG2(t_nrLDPC_lut* p_lut, int8_t* cnProcBu // If no error pcRes should be 0 // Only use valid CNs - pcResSum |= (pcRes&(0xFFFFFFFF>>(32-Mrem))); + if (Mrem) + pcResSum |= (pcRes&(0xFFFFFFFF>>(32-Mrem))); // If PC failed we can stop here if (pcResSum > 0) @@ -1794,7 +1806,8 @@ static inline uint32_t nrLDPC_cnProcPc_BG2(t_nrLDPC_lut* p_lut, int8_t* cnProcBu // If no error pcRes should be 0 // Only use valid CNs - pcResSum |= (pcRes&(0xFFFFFFFF>>(32-Mrem))); + if (Mrem) + pcResSum |= (pcRes&(0xFFFFFFFF>>(32-Mrem))); // If PC failed we can stop here if (pcResSum > 0) @@ -1861,7 +1874,8 @@ static inline uint32_t nrLDPC_cnProcPc_BG2(t_nrLDPC_lut* p_lut, int8_t* cnProcBu // If no error pcRes should be 0 // Only use valid CNs - pcResSum |= (pcRes&(0xFFFFFFFF>>(32-Mrem))); + if (Mrem) + pcResSum |= (pcRes&(0xFFFFFFFF>>(32-Mrem))); // If PC failed we can stop here if (pcResSum > 0) @@ -1928,7 +1942,8 @@ static inline uint32_t nrLDPC_cnProcPc_BG2(t_nrLDPC_lut* p_lut, int8_t* cnProcBu // If no error pcRes should be 0 // Only use valid CNs - pcResSum |= (pcRes&(0xFFFFFFFF>>(32-Mrem))); + if (Mrem) + pcResSum |= (pcRes&(0xFFFFFFFF>>(32-Mrem))); // If PC failed we can stop here if (pcResSum > 0) diff --git a/openair1/PHY/LTE_TRANSPORT/dci_tools_common.c b/openair1/PHY/LTE_TRANSPORT/dci_tools_common.c index 64e74ebfbf..cb2f190384 100644 --- a/openair1/PHY/LTE_TRANSPORT/dci_tools_common.c +++ b/openair1/PHY/LTE_TRANSPORT/dci_tools_common.c @@ -562,9 +562,9 @@ uint32_t get_prb(int N_RB_DL,int odd_slot,int vrb,int Ngap) { case 15: if (vrb<12) { if ((vrb&3) < 2) // even: 0->0, 1->4, 4->1, 5->5, 8->2, 9->6 odd: 0->7, 1->11 - return(((7*odd_slot) + 4*(vrb&3) + (vrb>>2))%14) + 14*(vrb/14); + return(((7*odd_slot) + 4*(vrb&3) + (vrb>>2))%14) + 14*(vrb/14); else if (vrb < 12) // even: 2->7, 3->11, 6->8, 7->12, 10->9, 11->13 - return (((7*odd_slot) + 4*(vrb&3) + (vrb>>2) +13 )%14) + 14*(vrb/14); + return (((7*odd_slot) + 4*(vrb&3) + (vrb>>2) +13 )%14) + 14*(vrb/14); } if (vrb==12) return (3+(7*odd_slot)) % 14; @@ -573,6 +573,8 @@ uint32_t get_prb(int N_RB_DL,int odd_slot,int vrb,int Ngap) { return 14; break; + // Formula in TS 36.211, chap 6.2.3.2 + // Fix me: returns a PRB number > 24 when vrb is 24 case 25: return (((12*odd_slot) + 6*(vrb&3) + (vrb>>2))%24) + 24*(vrb/24); break; @@ -581,43 +583,44 @@ uint32_t get_prb(int N_RB_DL,int odd_slot,int vrb,int Ngap) { if (Ngap==0) { // Nrow=12,Nnull=2,NVRBDL=46,Ngap1= 27 if (vrb>=23) - offset=4; + offset=4; else - offset=0; + offset=0; if (vrb<44) { - if ((vrb&3)>=2) - return offset+((23*odd_slot) + 12*(vrb&3) + (vrb>>2) + 45)%46; - else - return offset+((23*odd_slot) + 12*(vrb&3) + (vrb>>2))%46; + if ((vrb&3)>=2) + return offset+((23*odd_slot) + 12*(vrb&3) + (vrb>>2) + 45)%46; + else + return offset+((23*odd_slot) + 12*(vrb&3) + (vrb>>2))%46; } if (vrb==44) // even: 44->11, odd: 45->34 - return offset+((23*odd_slot) + 22-12+1); + return offset+((23*odd_slot) + 22-12+1); if (vrb==45) // even: 45->10, odd: 45->33 - return offset+((23*odd_slot) + 22+12); + return offset+((23*odd_slot) + 22+12); if (vrb==46) - return offset+46+((23*odd_slot) + 23-12+1) % 46; + return offset+46+((23*odd_slot) + 23-12+1) % 46; if (vrb==47) - return offset+46+((23*odd_slot) + 23+12) % 46; + return offset+46+((23*odd_slot) + 23+12) % 46; if (vrb==48) - return offset+46+((23*odd_slot) + 23-12+1) % 46; + return offset+46+((23*odd_slot) + 23-12+1) % 46; if (vrb==49) - return offset+46+((23*odd_slot) + 23+12) % 46; + return offset+46+((23*odd_slot) + 23+12) % 46; } else { // Nrow=6,Nnull=6,NVRBDL=18,Ngap1= 27 if (vrb>=9) - offset=18; + offset=18; else - offset=0; + offset=0; if (vrb<12) { - if ((vrb&3)>=2) - return offset+((9*odd_slot) + 6*(vrb&3) + (vrb>>2) + 17)%18; - else - return offset+((9*odd_slot) + 6*(vrb&3) + (vrb>>2))%18; + if ((vrb&3)>=2) + return offset+((9*odd_slot) + 6*(vrb&3) + (vrb>>2) + 17)%18; + else + return offset+((9*odd_slot) + 6*(vrb&3) + (vrb>>2))%18; } else { - return offset+((9*odd_slot) + 12*(vrb&1)+(vrb>>1) )%18 + 18*(vrb/18); + // Same issue as for 25 PRB: returns larger than 0..49 + return ((9*odd_slot) + 12*(vrb&1) + (vrb>>1))%18 + 18*(vrb/18); } } break; @@ -677,7 +680,7 @@ void generate_RIV_tables(void) // printf("RIV %d (%d) : first_rb %d NBRB %d\n",RIV,localRIV2alloc_LUT25[RIV],RBstart,Lcrbs); localRIV2alloc_LUT6[RIV] = alloc0; - distRIV2alloc_even_LUT6[RIV] = allocdist0_0_even; + distRIV2alloc_even_LUT6[RIV] = allocdist0_0_even; distRIV2alloc_odd_LUT6[RIV] = allocdist0_0_odd; RIV2nb_rb_LUT6[RIV] = Lcrbs; RIV2first_rb_LUT6[RIV] = RBstart; @@ -693,15 +696,14 @@ void generate_RIV_tables(void) nVRB = Lcrbs-1+RBstart; //printf("RBstart %d, len %d --> ",RBstart,Lcrbs); alloc0 |= (1<RIV_max25) - RIV_max25 = RIV;; - + RIV_max25 = RIV; localRIV2alloc_LUT25[RIV] = alloc0; distRIV2alloc_even_LUT25[RIV] = allocdist0_0_even; @@ -730,37 +732,37 @@ void generate_RIV_tables(void) if (nVRB<32) - alloc0 |= (1< nVRB_even_dist %d\n",nVRB,nVRB_even_dist); - if (nVRB_even_dist<32) - allocdist0_0_even |= (1<(%08x.%08x.%08x.%08x)\n", allocdist0_0_even, @@ -845,38 +846,37 @@ void generate_RIV_tables(void) // Distributed Gap1, odd slot nVRB_odd_dist = get_prb(100,1,nVRB,0); if (nVRB_odd_dist<32) - allocdist0_0_odd |= (1<dlsch->harq_processes[harq_pid]; if ( rdata-> round == 0) { - uint8_t tmp[96+12+3+3*6144]; + uint8_t tmp[96+12+3+3*6144] __attribute__((aligned(32))); memset(tmp,LTE_NULL, TURBO_SIMD_SOFTBITS); start_meas(rdata->te_stats); encoder(rdata->input, diff --git a/openair1/PHY/LTE_UE_TRANSPORT/transport_proto_ue.h b/openair1/PHY/LTE_UE_TRANSPORT/transport_proto_ue.h index f5b8c6b64a..36da4ccab0 100644 --- a/openair1/PHY/LTE_UE_TRANSPORT/transport_proto_ue.h +++ b/openair1/PHY/LTE_UE_TRANSPORT/transport_proto_ue.h @@ -1272,14 +1272,6 @@ uint32_t get_TBS_DL(uint8_t mcs, uint16_t nb_rb); @return Transport block size */ uint32_t get_TBS_UL(uint8_t mcs, uint16_t nb_rb); -/* \brief Return bit-map of resource allocation for a given DCI rballoc (RIV format) and vrb type - @param N_RB_DL number of PRB on DL - @param indicator for even/odd slot - @param vrb vrb index - @param Ngap Gap indicator -*/ -uint32_t get_prb(int N_RB_DL,int odd_slot,int vrb,int Ngap); - /* \brief Return prb for a given vrb index @param vrb_type VRB type (0=localized,1=distributed) @param rb_alloc_dci rballoc field from DCI diff --git a/openair1/PHY/LTE_UE_TRANSPORT/transport_ue.h b/openair1/PHY/LTE_UE_TRANSPORT/transport_ue.h index b4ae44f6ea..5f8763414e 100644 --- a/openair1/PHY/LTE_UE_TRANSPORT/transport_ue.h +++ b/openair1/PHY/LTE_UE_TRANSPORT/transport_ue.h @@ -90,7 +90,7 @@ typedef struct { /// Redundancy-version of the current sub-frame uint8_t rvidx; /// Turbo-code outputs (36-212 V8.6 2009-03, p.12 - uint8_t d[MAX_NUM_ULSCH_SEGMENTS][(96+3+(3*6144))]; + uint8_t *d[MAX_NUM_ULSCH_SEGMENTS]; /// Sub-block interleaver outputs (36-212 V8.6 2009-03, p.16-17) uint8_t w[MAX_NUM_ULSCH_SEGMENTS][3*6144]; /// Number of code segments (for definition see 36-212 V8.6 2009-03, p.9) diff --git a/openair1/PHY/LTE_UE_TRANSPORT/ulsch_coding.c b/openair1/PHY/LTE_UE_TRANSPORT/ulsch_coding.c index ae3ebbce9d..c04ec160aa 100644 --- a/openair1/PHY/LTE_UE_TRANSPORT/ulsch_coding.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/ulsch_coding.c @@ -71,6 +71,7 @@ void free_ue_ulsch(LTE_UE_ULSCH_t *ulsch) { for (r=0; rharq_processes[i]->c[r]) { free16(ulsch->harq_processes[i]->c[r],((r==0)?8:0) + 3+768); + free16(ulsch->harq_processes[i]->d[r],0); ulsch->harq_processes[i]->c[r] = NULL; } } @@ -86,7 +87,7 @@ void free_ue_ulsch(LTE_UE_ULSCH_t *ulsch) { LTE_UE_ULSCH_t *new_ue_ulsch(unsigned char N_RB_UL, uint8_t abstraction_flag) { LTE_UE_ULSCH_t *ulsch; - unsigned char exit_flag = 0,i,j,r; + unsigned char exit_flag = 0; unsigned char bw_scaling =1; switch (N_RB_UL) { @@ -113,7 +114,7 @@ LTE_UE_ULSCH_t *new_ue_ulsch(unsigned char N_RB_UL, uint8_t abstraction_flag) { memset(ulsch,0,sizeof(LTE_UE_ULSCH_t)); ulsch->Mlimit = 4; - for (i=0; i<8; i++) { + for (int i=0; i<8; i++) { ulsch->harq_processes[i] = (LTE_UL_UE_HARQ_t *)malloc16(sizeof(LTE_UL_UE_HARQ_t)); // printf("ulsch->harq_processes[%d] %p\n",i,ulsch->harq_processes[i]); @@ -129,15 +130,11 @@ LTE_UE_ULSCH_t *new_ue_ulsch(unsigned char N_RB_UL, uint8_t abstraction_flag) { } if (abstraction_flag==0) { - for (r=0; rharq_processes[i]->c[r] = (unsigned char *)malloc16(((r==0)?8:0) + 3+768); // account for filler in first segment and CRCs for multiple segment case - - if (ulsch->harq_processes[i]->c[r]) - memset(ulsch->harq_processes[i]->c[r],0,((r==0)?8:0) + 3+768); - else { - LOG_E(PHY,"Can't get c\n"); - exit_flag=2; - } + for (int r=0; rharq_processes[i]->c[r] = malloc16_clear(((r==0)?8:0) + 3+768); // account for filler in first segment and CRCs for multiple segment case + AssertFatal(ulsch->harq_processes[i]->c[r], ""); + ulsch->harq_processes[i]->d[r] = malloc16_clear(96+3+(3*6144)); + AssertFatal(ulsch->harq_processes[i]->d[r], ""); } } @@ -148,15 +145,7 @@ LTE_UE_ULSCH_t *new_ue_ulsch(unsigned char N_RB_UL, uint8_t abstraction_flag) { exit_flag=3; } } - - if ((abstraction_flag == 0) && (exit_flag==0)) { - for (i=0; i<8; i++) - for (j=0; j<96; j++) - for (r=0; rharq_processes[i]->d[r][j] = LTE_NULL; - - return(ulsch); - } else if (abstraction_flag==1) + if (!exit_flag) return(ulsch); } @@ -191,7 +180,7 @@ uint32_t ulsch_encoding(uint8_t *a, uint32_t Qprime_ACK=0,Qprime_CQI=0,Qprime_RI=0,len_ACK=0,len_RI=0; // uint32_t E; uint8_t ack_parity; - uint32_t i,q,j,iprime,j2; + uint32_t q,j,iprime,j2; uint16_t o_RCC; uint8_t o_flip[8]; uint32_t wACK_idx; @@ -327,6 +316,8 @@ uint32_t ulsch_encoding(uint8_t *a, #endif // offset=0; start_meas(te_stats); + for (int z=0; z<96; z++) + ulsch->harq_processes[harq_pid]->d[r][z] = LTE_NULL; encoder(ulsch->harq_processes[harq_pid]->c[r], Kr>>3, &ulsch->harq_processes[harq_pid]->d[r][96], @@ -539,8 +530,6 @@ uint32_t ulsch_encoding(uint8_t *a, ulsch->q); } - i=0; - // Do RI coding if (ulsch->O_RI == 1) { switch (Q_m) { @@ -691,7 +680,7 @@ uint32_t ulsch_encoding(uint8_t *a, j=0; - for (i=0; i>2); for (q=0; q>2); for (q=0; qh[j++] = *yptr++; @@ -818,7 +807,7 @@ uint32_t ulsch_encoding(uint8_t *a, break; case 4: - for (i=0; ih[j++] = *yptr++; @@ -830,7 +819,7 @@ uint32_t ulsch_encoding(uint8_t *a, break; case 6: - for (i=0; ih[j++] = *yptr++; diff --git a/openair1/PHY/MODULATION/nr_modulation.c b/openair1/PHY/MODULATION/nr_modulation.c index 8ebd70fb92..1b5c4f4af0 100644 --- a/openair1/PHY/MODULATION/nr_modulation.c +++ b/openair1/PHY/MODULATION/nr_modulation.c @@ -226,10 +226,11 @@ void nr_modulation(uint32_t *in, i *= 24; bit_cnt = i * 8; while (bit_cnt < length) { - x = *((uint32_t*)(in_bytes+i)); - x1 = x&4095; + uint32_t xx; + memcpy(&xx, in_bytes+i, sizeof(xx)); + x1 = xx & 4095; out64[j++] = nr_64qam_mod_table[x1]; - x1 = (x>>12)&4095; + x1 = (xx >> 12) & 4095; out64[j++] = nr_64qam_mod_table[x1]; i += 3; bit_cnt += 24; diff --git a/openair1/PHY/NR_ESTIMATION/nr_measurements_gNB.c b/openair1/PHY/NR_ESTIMATION/nr_measurements_gNB.c index fb56322e54..93bd9587a0 100644 --- a/openair1/PHY/NR_ESTIMATION/nr_measurements_gNB.c +++ b/openair1/PHY/NR_ESTIMATION/nr_measurements_gNB.c @@ -119,7 +119,7 @@ void gNB_I0_measurements(PHY_VARS_gNB *gNB,int slot, int first_symb,int num_symb measurements->n0_subband_power[aarx][rb]=0; } int offset0 = (slot&3)*(frame_parms->symbols_per_slot * frame_parms->ofdm_symbol_size) + (frame_parms->first_carrier_offset + (rb*12))%frame_parms->ofdm_symbol_size; - if ((gNB->rb_mask_ul[s][rb>>5]&(1<<(rb&31))) == 0) { // check that rb was not used in this subframe + if ((gNB->rb_mask_ul[s][rb >> 5] & (1U << (rb & 31))) == 0) { // check that rb was not used in this subframe nb_symb[rb]++; for (int aarx=0; aarxnb_antennas_rx; aarx++) { int offset = offset0 + (s*frame_parms->ofdm_symbol_size); diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch.c b/openair1/PHY/NR_TRANSPORT/nr_dlsch.c index d32fd77b03..30dbc39185 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dlsch.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch.c @@ -123,7 +123,6 @@ void nr_generate_pdsch(processingData_L1tx_t *msgTx, rel15->dlDmrsSymbPos); n_ptrs = (rel15->rbSize + rel15->PTRSFreqDensity - 1)/rel15->PTRSFreqDensity; } - int16_t mod_ptrs[n_ptrs<<1] __attribute__ ((aligned(16))); /// CRC, coding, interleaving and rate matching AssertFatal(harq->pdu!=NULL,"harq->pdu is null\n"); @@ -302,12 +301,14 @@ void nr_generate_pdsch(processingData_L1tx_t *msgTx, /* calculate if current symbol is PTRS symbols */ ptrs_idx = 0; - + int16_t *mod_ptrs = NULL; if(rel15->pduBitmap & 0x1) { ptrs_symbol = is_ptrs_symbol(l,dlPtrsSymPos); if(ptrs_symbol) { /* PTRS QPSK Modulation for each OFDM symbol in a slot */ LOG_D(PHY,"Doing ptrs modulation for symbol %d, n_ptrs %d\n",l,n_ptrs); + int16_t mod_ptrsBuf[n_ptrs<<1] __attribute__ ((aligned(16))); + mod_ptrs =mod_ptrsBuf; nr_modulation(pdsch_dmrs[l][rel15->SCID], (n_ptrs<<1), DMRS_MOD_ORDER, mod_ptrs); } } diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index 1428987d40..5c44bde4fe 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -569,7 +569,7 @@ void fill_ul_rb_mask(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) { LOG_D(PHY,"symbol %d Filling rb_mask_ul rb_size %d\n",symbol,ulsch_harq->ulsch_pdu.rb_size); for (rb=0; rbulsch_pdu.rb_size; rb++) { rb2 = rb+ulsch_harq->ulsch_pdu.rb_start+ulsch_harq->ulsch_pdu.bwp_start; - gNB->rb_mask_ul[symbol][rb2>>5] |= (1<<(rb2&31)); + gNB->rb_mask_ul[symbol][rb2 >> 5] |= 1U << (rb2 & 31); } } } diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index d366ae9ec1..38fa3880bb 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -1321,8 +1321,7 @@ int is_ssb_in_slot(fapi_nr_config_request_t *config, int frame, int slot, NR_DL_ //uint8_t half_frame_index = fp->half_frame_bit; //uint8_t i_ssb = fp->ssb_index; uint8_t Lmax = fp->Lmax; - - if (!(frame%(1<<(config->ssb_table.ssb_period-1)))){ + if ((config->ssb_table.ssb_period > 0) && !(frame % (1 << (config->ssb_table.ssb_period - 1)))) { if(Lmax <= 8) { if(slot <=3 && (((config->ssb_table.ssb_mask_list[0].ssb_mask << 2*slot)&0x80000000) == 0x80000000 || ((config->ssb_table.ssb_mask_list[0].ssb_mask << (2*slot +1))&0x80000000) == 0x80000000)) diff --git a/openair1/SIMULATION/LTE_PHY/dlsim.c b/openair1/SIMULATION/LTE_PHY/dlsim.c index d715423bb1..8aff47c86b 100644 --- a/openair1/SIMULATION/LTE_PHY/dlsim.c +++ b/openair1/SIMULATION/LTE_PHY/dlsim.c @@ -512,12 +512,16 @@ int main(int argc, char **argv) { int re; int s,Kr,Kr_bytes; LTE_DL_FRAME_PARMS *frame_parms; - double s_re0[30720*NB_ANTENNAS_TX],s_im0[30720*NB_ANTENNAS_TX],r_re0[30720*NB_ANTENNAS_RX],r_im0[30720*NB_ANTENNAS_RX]; - double s_re1[30720*NB_ANTENNAS_TX],s_im1[30720*NB_ANTENNAS_TX],r_re1[30720*NB_ANTENNAS_RX],r_im1[30720*NB_ANTENNAS_RX]; - double *s_re[NB_ANTENNAS_TX]= {s_re0,s_re1}; - double *s_im[NB_ANTENNAS_TX]= {s_im0,s_im1}; - double *r_re[NB_ANTENNAS_RX]= {r_re0,r_re1}; - double *r_im[NB_ANTENNAS_RX]= {r_im0,r_im1}; + double *tmpTX[4], *tmpRX[4] ; + for (int i = 0; i < 4; i++) { + tmpTX[i] = malloc(30720 * NB_ANTENNAS_TX * sizeof(*tmpTX)); + tmpRX[i] = malloc(30720 * NB_ANTENNAS_RX * sizeof(*tmpRX)); + } + double *s_re[NB_ANTENNAS_TX] = {tmpTX[0], tmpTX[1]}; + double *s_im[NB_ANTENNAS_TX] = {tmpTX[2], tmpTX[3]}; + double *r_re[NB_ANTENNAS_RX] = {tmpRX[0], tmpRX[1]}; + double *r_im[NB_ANTENNAS_RX] = {tmpRX[2], tmpRX[3]}; + uint8_t transmission_mode=1,n_tx_port=1,n_tx_phy=1,n_rx=2; int eNB_id = 0; unsigned char round; diff --git a/openair1/SIMULATION/LTE_PHY/ulsim.c b/openair1/SIMULATION/LTE_PHY/ulsim.c index 0843d00ffd..0f98eb337a 100644 --- a/openair1/SIMULATION/LTE_PHY/ulsim.c +++ b/openair1/SIMULATION/LTE_PHY/ulsim.c @@ -358,7 +358,7 @@ int main(int argc, char **argv) { unsigned short input_buffer_length; unsigned int ret; unsigned int coded_bits_per_codeword,nsymb; - unsigned int tx_lev=0,tx_lev_dB=0,trials,errs[5]= {0,0,0,0,0},round_trials[4]= {0,0,0,0}; + unsigned int tx_lev = 0, tx_lev_dB = 0, trials, errs[6] = {0}, round_trials[4] = {0}; FILE *bler_fd=NULL; char bler_fname[512]; FILE *time_meas_fd=NULL; @@ -387,7 +387,6 @@ int main(int argc, char **argv) { double cpu_freq_GHz; int iter_trials; uint32_t UL_alloc_pdu; - int s,Kr,Kr_bytes; int dump_perf=0; static int dump_table =0; double effective_rate=0.0; @@ -1233,20 +1232,21 @@ int main(int argc, char **argv) { if (n_frames==1) { printf("ULSCH errors found o_ACK[0]= %d\n",eNB->ulsch[0]->harq_processes[harq_pid]->o_ACK[0]); - +#ifdef DUMP_EACH_VALUE + int Kr_bytes; for (s=0; sulsch[0]->harq_processes[harq_pid]->C; s++) { if (sulsch[0]->harq_processes[harq_pid]->Cminus) - Kr = eNB->ulsch[0]->harq_processes[harq_pid]->Kminus; + Kr_bytes = eNB->ulsch[0]->harq_processes[harq_pid]->Kminus; else - Kr = eNB->ulsch[0]->harq_processes[harq_pid]->Kplus; - - Kr_bytes = Kr>>3; + Kr_bytes = eNB->ulsch[0]->harq_processes[harq_pid]->Kplus; + Kr_bytes = Kr_bytes >> 3; printf("Decoded_output (Segment %d):\n",s); for (i=0; iulsch[0]->harq_processes[harq_pid]->c[s][i], eNB->ulsch[0]->harq_processes[harq_pid]->c[s][i]^UE->ulsch[0]->harq_processes[harq_pid]->c[s][i]); } +#endif dump_ulsch(eNB,eNB->proc.frame_rx,subframe,0,round); round=5; diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 78b253ca2a..8500749fe2 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -1142,7 +1142,7 @@ int main(int argc, char **argv) Sched_INFO.frame = frame; Sched_INFO.slot = slot; Sched_INFO.DL_req = &gNB_mac->DL_req[0]; - Sched_INFO.UL_tti_req = gNB_mac->UL_tti_req_ahead[slot]; + Sched_INFO.UL_tti_req = gNB_mac->UL_tti_req_ahead[0]; Sched_INFO.UL_dci_req = NULL; Sched_INFO.TX_req = &gNB_mac->TX_req[0]; pushNotifiedFIFO(gNB->L1_tx_free,msgL1Tx); diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index 072f0e58de..2804a9ec1e 100644 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -190,7 +190,7 @@ void config_common_ue_sa(NR_UE_MAC_INST_t *mac, cfg->ssb_table.ssb_subcarrier_offset = mac->ssb_subcarrier_offset; if (mac->frequency_range == FR1){ - cfg->ssb_table.ssb_mask_list[0].ssb_mask = scc->ssb_PositionsInBurst.inOneGroup.buf[0]<<24; + cfg->ssb_table.ssb_mask_list[0].ssb_mask = ((uint32_t) scc->ssb_PositionsInBurst.inOneGroup.buf[0]) << 24; cfg->ssb_table.ssb_mask_list[1].ssb_mask = 0; } else{ @@ -353,7 +353,7 @@ void config_common_ue(NR_UE_MAC_INST_t *mac, cfg->ssb_table.ssb_mask_list[1].ssb_mask = 0; break; case 2 : - cfg->ssb_table.ssb_mask_list[0].ssb_mask = scc->ssb_PositionsInBurst->choice.mediumBitmap.buf[0]<<24; + cfg->ssb_table.ssb_mask_list[0].ssb_mask = ((uint32_t) scc->ssb_PositionsInBurst->choice.mediumBitmap.buf[0]) << 24; cfg->ssb_table.ssb_mask_list[1].ssb_mask = 0; break; case 3 : diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h index 38f774be76..aa68791466 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -257,13 +257,6 @@ void get_bwp_info(NR_UE_MAC_INST_t *mac, NR_BWP_DownlinkCommon_t *get_bwp_downlink_common(NR_UE_MAC_INST_t *mac, NR_BWP_Id_t dl_bwp_id); -uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, - uint8_t dci_format, - uint8_t dci_length, - uint16_t rnti, - uint64_t *dci_pdu, - dci_pdu_rel15_t *nr_pdci_info_extracted); - NR_PUSCH_TimeDomainResourceAllocationList_t *choose_ul_tda_list(const NR_PUSCH_Config_t *pusch_Config,NR_PUSCH_ConfigCommon_t *pusch_ConfigCommon); NR_PDSCH_TimeDomainResourceAllocationList_t *choose_dl_tda_list(NR_PDSCH_Config_t *pdsch_Config,NR_PDSCH_ConfigCommon_t *pdsch_ConfigCommon); diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 6166fc7038..ccb1b4e72a 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -134,6 +134,13 @@ const initial_pucch_resource_t initial_pucch_resource[16] = { }; +static uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, + uint8_t dci_format, + uint8_t dci_length, + uint16_t rnti, + uint64_t *dci_pdu, + dci_pdu_rel15_t *nr_pdci_info_extracted); + void nr_ue_init_mac(module_id_t module_idP) { int i; @@ -985,7 +992,8 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr if (dci->tpc == 3) dlsch_config_pdu_1_0->accumulated_delta_PUCCH = 3; // Sanity check for pucch_resource_indicator value received to check for false DCI. valid = 0; - if (mac->ULbwp[ul_bwp_id-1] && + if (ul_bwp_id > 0 && + mac->ULbwp[ul_bwp_id-1] && mac->ULbwp[ul_bwp_id-1]->bwp_Dedicated && mac->ULbwp[ul_bwp_id-1]->bwp_Dedicated->pucch_Config && mac->ULbwp[ul_bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup&& @@ -1512,13 +1520,12 @@ void nr_ue_configure_pucch(NR_UE_MAC_INST_t *mac, NR_BWP_UplinkCommon_t *initialUplinkBWP; if (mac->scc) initialUplinkBWP = mac->scc->uplinkConfigCommon->initialUplinkBWP; else initialUplinkBWP = &mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP; - NR_BWP_Uplink_t *ubwp = mac->ULbwp[bwp_id-1]; - if (mac->cg && ubwp && + if (mac->cg && bwp_id > 1 && mac->ULbwp[bwp_id - 1] && mac->cg->spCellConfig && mac->cg->spCellConfig->spCellConfigDedicated && mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig && mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP) { - scs = ubwp->bwp_Common->genericParameters.subcarrierSpacing; + scs = mac->ULbwp[bwp_id - 1]->bwp_Common->genericParameters.subcarrierSpacing; } else scs = initialUplinkBWP->genericParameters.subcarrierSpacing; @@ -2340,17 +2347,16 @@ bool trigger_periodic_scheduling_request(NR_UE_MAC_INST_t *mac, NR_BWP_Id_t bwp_id = mac->UL_BWP_Id; NR_PUCCH_Config_t *pucch_Config = NULL; int scs; - NR_BWP_Uplink_t *ubwp = mac->ULbwp[bwp_id-1]; NR_BWP_UplinkCommon_t *initialUplinkBWP; if (mac->scc) initialUplinkBWP = mac->scc->uplinkConfigCommon->initialUplinkBWP; else initialUplinkBWP = &mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP; - if (mac->cg && ubwp && + if (mac->cg && bwp_id && mac->ULbwp[bwp_id - 1] && mac->cg->spCellConfig && mac->cg->spCellConfig->spCellConfigDedicated && mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig && mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP) { - scs = ubwp->bwp_Common->genericParameters.subcarrierSpacing; + scs = mac->ULbwp[bwp_id - 1]->bwp_Common->genericParameters.subcarrierSpacing; } else scs = initialUplinkBWP->genericParameters.subcarrierSpacing; @@ -2732,7 +2738,7 @@ int get_n_rb(NR_UE_MAC_INST_t *mac, int rnti_type){ } -uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, +static uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, uint8_t dci_format, uint8_t dci_size, uint16_t rnti, diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index f6a42ccaab..49b8e3d05f 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -118,12 +118,13 @@ long get_k2(NR_UE_MAC_INST_t *mac, uint8_t time_domain_ind) { NR_BWP_Id_t ul_bwp_id = mac->UL_BWP_Id; // Get K2 from RRC configuration - NR_PUSCH_Config_t *pusch_config=mac->ULbwp[ul_bwp_id-1] ? mac->ULbwp[ul_bwp_id-1]->bwp_Dedicated->pusch_Config->choice.setup : NULL; + NR_PUSCH_Config_t *pusch_config= ul_bwp_id > 0 && mac->ULbwp[ul_bwp_id-1] ? mac->ULbwp[ul_bwp_id-1]->bwp_Dedicated->pusch_Config->choice.setup : NULL; NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = NULL; if (pusch_config && pusch_config->pusch_TimeDomainAllocationList) { pusch_TimeDomainAllocationList = pusch_config->pusch_TimeDomainAllocationList->choice.setup; } - else if (mac->ULbwp[ul_bwp_id-1] && + else if (ul_bwp_id > 0 && + mac->ULbwp[ul_bwp_id-1] && mac->ULbwp[ul_bwp_id-1]->bwp_Common&& mac->ULbwp[ul_bwp_id-1]->bwp_Common->pusch_ConfigCommon&& mac->ULbwp[ul_bwp_id-1]->bwp_Common->pusch_ConfigCommon->choice.setup && @@ -169,7 +170,7 @@ fapi_nr_ul_config_request_t *get_ul_config_request(NR_UE_MAC_INST_t *mac, int sl // Calculate the index of the UL slot in mac->ul_config_request list. This is // based on the TDD pattern (slot configuration period) and number of UL+mixed // slots in the period. TS 38.213 Sec 11.1 - int mu = mac->ULbwp[ul_bwp_id-1] ? + int mu = ul_bwp_id > 0 && mac->ULbwp[ul_bwp_id-1] ? mac->ULbwp[ul_bwp_id-1]->bwp_Common->genericParameters.subcarrierSpacing : mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.genericParameters.subcarrierSpacing; const int n = nr_slots_per_frame[mu]; @@ -205,7 +206,7 @@ void ul_layers_config(NR_UE_MAC_INST_t * mac, nfapi_nr_ue_pusch_pdu_t *pusch_con srs_config = mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->srs_Config->choice.setup; } - NR_PUSCH_Config_t *pusch_Config = mac->ULbwp[ul_bwp_id-1] ? + NR_PUSCH_Config_t *pusch_Config = ul_bwp_id > 0 && mac->ULbwp[ul_bwp_id-1] ? mac->ULbwp[ul_bwp_id-1]->bwp_Dedicated->pusch_Config->choice.setup : (ubwpd? ubwpd->pusch_Config->choice.setup: @@ -361,7 +362,7 @@ void ul_ports_config(NR_UE_MAC_INST_t *mac, int *n_front_load_symb, nfapi_nr_ue_ mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP) ubwpd = mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP; - NR_PUSCH_Config_t *pusch_Config = mac->ULbwp[ul_bwp_id-1] ? mac->ULbwp[ul_bwp_id-1]->bwp_Dedicated->pusch_Config->choice.setup : (ubwpd?ubwpd->pusch_Config->choice.setup:NULL); + NR_PUSCH_Config_t *pusch_Config = ul_bwp_id > 0 && mac->ULbwp[ul_bwp_id-1] ? mac->ULbwp[ul_bwp_id-1]->bwp_Dedicated->pusch_Config->choice.setup : (ubwpd?ubwpd->pusch_Config->choice.setup:NULL); AssertFatal(pusch_Config!=NULL,"pusch_Config shouldn't be null\n"); long transformPrecoder; @@ -581,7 +582,7 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, if (rar_grant) { // Note: for Msg3 or MsgA PUSCH transmission the N_PRB_oh is always set to 0 - NR_BWP_Uplink_t *ubwp = mac->ULbwp[ul_bwp_id-1]; + NR_BWP_Uplink_t *ubwp = ul_bwp_id > 0 ? mac->ULbwp[ul_bwp_id - 1] : NULL; NR_BWP_UplinkDedicated_t *ibwp; int scs,abwp_start,abwp_size,startSymbolAndLength,mappingtype; NR_PUSCH_Config_t *pusch_Config=NULL; @@ -839,11 +840,15 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, mappingtype, add_pos, dmrslength, pusch_config_pdu->start_symbol_index, mac->scc ? mac->scc->dmrs_TypeA_Position : mac->mib->dmrs_TypeA_Position); - if (mac->ULbwp[ul_bwp_id-1] && pusch_config_pdu->transform_precoding == NR_PUSCH_Config__transformPrecoder_disabled) { - if (*dci_format != NR_UL_DCI_FORMAT_0_1) { - pusch_config_pdu->num_dmrs_cdm_grps_no_data = 1; - } - } else if (*dci_format == NR_UL_DCI_FORMAT_0_0 || (mac->ULbwp[ul_bwp_id-1] && pusch_config_pdu->transform_precoding == NR_PUSCH_Config__transformPrecoder_enabled)) { + if (ul_bwp_id > 0 && + mac->ULbwp[ul_bwp_id - 1] && + pusch_config_pdu->transform_precoding == NR_PUSCH_Config__transformPrecoder_disabled && + *dci_format != NR_UL_DCI_FORMAT_0_1) { + pusch_config_pdu->num_dmrs_cdm_grps_no_data = 1; + } else if (*dci_format == NR_UL_DCI_FORMAT_0_0 || + (ul_bwp_id > 0 && + mac->ULbwp[ul_bwp_id-1] && + pusch_config_pdu->transform_precoding == NR_PUSCH_Config__transformPrecoder_enabled)) { pusch_config_pdu->num_dmrs_cdm_grps_no_data = 2; } @@ -859,7 +864,8 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, else N_PRB_oh = 0; /* PTRS */ - if (mac->ULbwp[ul_bwp_id-1] && + if (ul_bwp_id > 0 && + mac->ULbwp[ul_bwp_id-1] && mac->ULbwp[ul_bwp_id-1]->bwp_Dedicated && mac->ULbwp[ul_bwp_id-1]->bwp_Dedicated->pusch_Config && mac->ULbwp[ul_bwp_id-1]->bwp_Dedicated->pusch_Config->choice.setup && @@ -1086,9 +1092,10 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in dcireq.dl_config_req = mac->dl_config_request; fill_scheduled_response(&scheduled_response, &dcireq.dl_config_req, NULL, NULL, mod_id, cc_id, rx_frame, rx_slot, dl_info->thread_id, dl_info->phy_data); - if(mac->if_module != NULL && mac->if_module->scheduled_response != NULL) + if(mac->if_module != NULL && mac->if_module->scheduled_response != NULL) { LOG_D(NR_MAC,"1# scheduled_response transmitted, %d, %d\n", rx_frame, rx_slot); - mac->if_module->scheduled_response(&scheduled_response); + mac->if_module->scheduled_response(&scheduled_response); + } } else { // this is for Msg2/Msg4 @@ -1557,15 +1564,14 @@ int nr_ue_pusch_scheduler(NR_UE_MAC_INST_t *mac, int delta = 0; NR_BWP_Id_t ul_bwp_id = mac->UL_BWP_Id; - NR_BWP_Uplink_t *ubwp = mac->ULbwp[ul_bwp_id-1]; // Get the numerology to calculate the Tx frame and slot - int mu = ubwp ? - ubwp->bwp_Common->genericParameters.subcarrierSpacing : + int mu = ul_bwp_id > 0 && mac->ULbwp[ul_bwp_id-1] ? + mac->ULbwp[ul_bwp_id-1]->bwp_Common->genericParameters.subcarrierSpacing : mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.genericParameters.subcarrierSpacing; - NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = ubwp ? - ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList: + NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = ul_bwp_id > 0 && mac->ULbwp[ul_bwp_id-1] ? + mac->ULbwp[ul_bwp_id-1]->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList: mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; // k2 as per 3GPP TS 38.214 version 15.9.0 Release 15 ch 6.1.2.1.1 // PUSCH time domain resource allocation is higher layer configured from uschTimeDomainAllocationList in either pusch-ConfigCommon diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c index 218b75b2e8..20ac69ce55 100644 --- a/openair2/LAYER2/NR_MAC_gNB/config.c +++ b/openair2/LAYER2/NR_MAC_gNB/config.c @@ -366,7 +366,7 @@ void config_common(int Mod_idP, int pdsch_AntennaPorts, int pusch_AntennaPorts, cfg->ssb_table.ssb_mask_list[1].ssb_mask.value = 0; break; case 2 : - cfg->ssb_table.ssb_mask_list[0].ssb_mask.value = scc->ssb_PositionsInBurst->choice.mediumBitmap.buf[0]<<24; + cfg->ssb_table.ssb_mask_list[0].ssb_mask.value = ((uint32_t) scc->ssb_PositionsInBurst->choice.mediumBitmap.buf[0]) << 24; cfg->ssb_table.ssb_mask_list[1].ssb_mask.value = 0; break; case 3 : diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index d9a0a50b7e..d32709e731 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -1349,6 +1349,8 @@ void nr_schedule_ue_spec(module_id_t module_id, header->L = htons(bufEnd-buf); dlsch_total_bytes += bufEnd-buf; + for (; ((intptr_t)buf) % 4; buf++) + *buf = lrand48() & 0xff; for (; buf < bufEnd - 3; buf += 4) { uint32_t *buf32 = (uint32_t *)buf; *buf32 = lrand48(); diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index 078f7f51a1..53817af48e 100644 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -1320,11 +1320,11 @@ nr_rrc_ue_process_masterCellGroup( //TODO (perform SCell addition/modification as specified in 5.3.5.5.9) } - if( cellGroupConfig->ext2->bh_RLC_ChannelToReleaseList_r16 != NULL){ + if(cellGroupConfig->ext2 != NULL && cellGroupConfig->ext2->bh_RLC_ChannelToReleaseList_r16 != NULL){ //TODO (perform the BH RLC channel addition/modification as specified in 5.3.5.5.11) } - if( cellGroupConfig->ext2->bh_RLC_ChannelToAddModList_r16 != NULL){ + if(cellGroupConfig->ext2 != NULL && cellGroupConfig->ext2->bh_RLC_ChannelToAddModList_r16 != NULL){ //TODO (perform the BH RLC channel addition/modification as specified in 5.3.5.5.11) } } From ab36474811d591303eb8f7f24db9fe39a0b0bdc8 Mon Sep 17 00:00:00 2001 From: laurent Date: Mon, 4 Jul 2022 19:32:33 +0200 Subject: [PATCH 08/13] dirty workaround in LTE get_prb(): it is not good, but keep safe in memory instead of writing outside the range --- openair1/PHY/LTE_TRANSPORT/dci_tools_common.c | 58 ++++++++++--------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/dci_tools_common.c b/openair1/PHY/LTE_TRANSPORT/dci_tools_common.c index cb2f190384..0addfdf14c 100644 --- a/openair1/PHY/LTE_TRANSPORT/dci_tools_common.c +++ b/openair1/PHY/LTE_TRANSPORT/dci_tools_common.c @@ -532,9 +532,12 @@ uint32_t conv_1C_RIV(int32_t rballoc,uint32_t N_RB_DL) { } +// FIXME: this function is compting PRB outside the range, so I FORCED in the range +// I can't understand the 3GPP spec, see below note uint32_t get_prb(int N_RB_DL,int odd_slot,int vrb,int Ngap) { int offset; + int ret=-1; switch (N_RB_DL) { @@ -545,16 +548,16 @@ uint32_t get_prb(int N_RB_DL,int odd_slot,int vrb,int Ngap) { switch (vrb) { case 0: // even: 0->0, 1->2, odd: 0->3, 1->5 case 1: - return ((3*odd_slot) + 2*(vrb&3))%6; + ret= ((3*odd_slot) + 2*(vrb&3))%6; break; case 2: // even: 2->3, 3->5, odd: 2->0, 3->2 case 3: - return ((3*odd_slot) + 2*(vrb&3) + 5)%6; + ret= ((3*odd_slot) + 2*(vrb&3) + 5)%6; break; case 4: // even: 4->1, odd: 4->4 - return ((3*odd_slot) + 1)%6; + ret= ((3*odd_slot) + 1)%6; case 5: // even: 5->4, odd: 5->1 - return ((3*odd_slot) + 4)%6; + ret= ((3*odd_slot) + 4)%6; break; } break; @@ -562,21 +565,21 @@ uint32_t get_prb(int N_RB_DL,int odd_slot,int vrb,int Ngap) { case 15: if (vrb<12) { if ((vrb&3) < 2) // even: 0->0, 1->4, 4->1, 5->5, 8->2, 9->6 odd: 0->7, 1->11 - return(((7*odd_slot) + 4*(vrb&3) + (vrb>>2))%14) + 14*(vrb/14); + ret= (((7*odd_slot) + 4*(vrb&3) + (vrb>>2))%14) + 14*(vrb/14); else if (vrb < 12) // even: 2->7, 3->11, 6->8, 7->12, 10->9, 11->13 - return (((7*odd_slot) + 4*(vrb&3) + (vrb>>2) +13 )%14) + 14*(vrb/14); + ret= (((7*odd_slot) + 4*(vrb&3) + (vrb>>2) +13 )%14) + 14*(vrb/14); } if (vrb==12) - return (3+(7*odd_slot)) % 14; + ret= (3+(7*odd_slot)) % 14; if (vrb==13) - return (10+(7*odd_slot)) % 14; - return 14; + ret= (10+(7*odd_slot)) % 14; + ret= 14; break; // Formula in TS 36.211, chap 6.2.3.2 // Fix me: returns a PRB number > 24 when vrb is 24 case 25: - return (((12*odd_slot) + 6*(vrb&3) + (vrb>>2))%24) + 24*(vrb/24); + ret= (((12*odd_slot) + 6*(vrb&3) + (vrb>>2))%24) + 24*(vrb/24); break; case 50: // P=3 @@ -588,22 +591,22 @@ uint32_t get_prb(int N_RB_DL,int odd_slot,int vrb,int Ngap) { offset=0; if (vrb<44) { if ((vrb&3)>=2) - return offset+((23*odd_slot) + 12*(vrb&3) + (vrb>>2) + 45)%46; + ret= offset+((23*odd_slot) + 12*(vrb&3) + (vrb>>2) + 45)%46; else - return offset+((23*odd_slot) + 12*(vrb&3) + (vrb>>2))%46; + ret= offset+((23*odd_slot) + 12*(vrb&3) + (vrb>>2))%46; } if (vrb==44) // even: 44->11, odd: 45->34 - return offset+((23*odd_slot) + 22-12+1); + ret= offset+((23*odd_slot) + 22-12+1); if (vrb==45) // even: 45->10, odd: 45->33 - return offset+((23*odd_slot) + 22+12); + ret= offset+((23*odd_slot) + 22+12); if (vrb==46) - return offset+46+((23*odd_slot) + 23-12+1) % 46; + ret= offset+46+((23*odd_slot) + 23-12+1) % 46; if (vrb==47) - return offset+46+((23*odd_slot) + 23+12) % 46; + ret= offset+46+((23*odd_slot) + 23+12) % 46; if (vrb==48) - return offset+46+((23*odd_slot) + 23-12+1) % 46; + ret= offset+46+((23*odd_slot) + 23-12+1) % 46; if (vrb==49) - return offset+46+((23*odd_slot) + 23+12) % 46; + ret= offset+46+((23*odd_slot) + 23+12) % 46; } else { // Nrow=6,Nnull=6,NVRBDL=18,Ngap1= 27 @@ -614,39 +617,38 @@ uint32_t get_prb(int N_RB_DL,int odd_slot,int vrb,int Ngap) { if (vrb<12) { if ((vrb&3)>=2) - return offset+((9*odd_slot) + 6*(vrb&3) + (vrb>>2) + 17)%18; + ret= offset+((9*odd_slot) + 6*(vrb&3) + (vrb>>2) + 17)%18; else - return offset+((9*odd_slot) + 6*(vrb&3) + (vrb>>2))%18; + ret= offset+((9*odd_slot) + 6*(vrb&3) + (vrb>>2))%18; } else { - // Same issue as for 25 PRB: returns larger than 0..49 - return ((9*odd_slot) + 12*(vrb&1) + (vrb>>1))%18 + 18*(vrb/18); + ret= offset+((9*odd_slot) + 12*(vrb&1)+(vrb>>1) )%18 + 18*(vrb/18); } } break; case 75: // Ngap1 = 32, NVRBRL=64, P=4, Nrow= 16, Nnull=0 if (Ngap ==0) { - return ((32*odd_slot) + 16*(vrb&3) + (vrb>>2))%64 + (vrb/64); + ret= ((32*odd_slot) + 16*(vrb&3) + (vrb>>2))%64 + (vrb/64); } else { // Ngap2 = 16, NVRBDL=32, Nrow=8, Nnull=0 - return ((16*odd_slot) + 8*(vrb&3) + (vrb>>2))%32 + (vrb/32); + ret= ((16*odd_slot) + 8*(vrb&3) + (vrb>>2))%32 + (vrb/32); } break; case 100: // Ngap1 = 48, NVRBDL=96, Nrow=24, Nnull=0 if (Ngap ==0) { - return ((48*odd_slot) + 24*(vrb&3) + (vrb>>2))%96 + (vrb/96); + ret= ((48*odd_slot) + 24*(vrb&3) + (vrb>>2))%96 + (vrb/96); } else { // Ngap2 = 16, NVRBDL=32, Nrow=8, Nnull=0 - return ((16*odd_slot) + 8*(vrb&3) + (vrb>>2))%32 + (vrb/32); + ret= ((16*odd_slot) + 8*(vrb&3) + (vrb>>2))%32 + (vrb/32); } break; default: LOG_E(PHY,"Unknown N_RB_DL %d\n",N_RB_DL); - return 0; + ret= 0; } - return 0; + return ret%N_RB_DL; } From 667b8e5eed245e55927a92dc15ed976bef51a089 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Thu, 21 Jul 2022 09:04:29 +0200 Subject: [PATCH 09/13] nr_pdcp: nia1 implementation We reuse existing code from eia1 for actual computation. Maybe not the most efficient. To be revised if needed. Some hacks in CMakeLists.txt were introduced to compile phy simulators. To be removed at some point. --- cmake_targets/CMakeLists.txt | 8 +++ openair2/LAYER2/nr_pdcp/nr_pdcp_entity.c | 20 ++++-- .../LAYER2/nr_pdcp/nr_pdcp_integrity_nia1.c | 66 +++++++++++++++++++ .../LAYER2/nr_pdcp/nr_pdcp_integrity_nia1.h | 34 ++++++++++ 4 files changed, 121 insertions(+), 7 deletions(-) create mode 100644 openair2/LAYER2/nr_pdcp/nr_pdcp_integrity_nia1.c create mode 100644 openair2/LAYER2/nr_pdcp/nr_pdcp_integrity_nia1.h diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 25e10931c7..ef9e22e7ee 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -1804,7 +1804,15 @@ set(NR_PDCP_SRC ${OPENAIR2_DIR}/LAYER2/nr_pdcp/nr_pdcp_timer_thread.c ${OPENAIR2_DIR}/LAYER2/nr_pdcp/nr_pdcp_security_nea2.c ${OPENAIR2_DIR}/LAYER2/nr_pdcp/nr_pdcp_integrity_nia2.c + ${OPENAIR2_DIR}/LAYER2/nr_pdcp/nr_pdcp_integrity_nia1.c ${OPENAIR2_DIR}/LAYER2/nr_pdcp/asn1_utils.c + #hack: include these files to compile the nr phy simulators + #these files should not be here, will be removed at some point when the + #computation is done directly inside nr_pdcp_integrity_nia1.c instead + #of reusing code of osa_stream_eia.c + ${OPENAIR2_DIR}/UTIL/OSA/osa_stream_eia.c + ${OPENAIR2_DIR}/UTIL/OSA/osa_snow3g.c + ${OPENAIR2_DIR}/UTIL/OSA/osa_rijndael.c ) set(NR_SDAP_SRC diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_entity.c b/openair2/LAYER2/nr_pdcp/nr_pdcp_entity.c index 7e1ddb62bd..480b651593 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_entity.c +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_entity.c @@ -27,6 +27,7 @@ #include "nr_pdcp_security_nea2.h" #include "nr_pdcp_integrity_nia2.h" +#include "nr_pdcp_integrity_nia1.h" #include "nr_pdcp_sdu.h" #include "LOG/log.h" @@ -240,16 +241,21 @@ static void nr_pdcp_entity_set_security(nr_pdcp_entity_t *entity, } if (integrity_algorithm != 0 && integrity_algorithm != -1) { - if (integrity_algorithm != 2) { - LOG_E(PDCP, "FATAL: only nia2 supported for the moment\n"); - exit(1); - } entity->has_integrity = 1; if (entity->free_integrity != NULL) entity->free_integrity(entity->integrity_context); - entity->integrity_context = nr_pdcp_integrity_nia2_init(entity->integrity_key); - entity->integrity = nr_pdcp_integrity_nia2_integrity; - entity->free_integrity = nr_pdcp_integrity_nia2_free_integrity; + if (integrity_algorithm == 2) { + entity->integrity_context = nr_pdcp_integrity_nia2_init(entity->integrity_key); + entity->integrity = nr_pdcp_integrity_nia2_integrity; + entity->free_integrity = nr_pdcp_integrity_nia2_free_integrity; + } else if (integrity_algorithm == 1) { + entity->integrity_context = nr_pdcp_integrity_nia1_init(entity->integrity_key); + entity->integrity = nr_pdcp_integrity_nia1_integrity; + entity->free_integrity = nr_pdcp_integrity_nia1_free_integrity; + } else { + LOG_E(PDCP, "FATAL: only nia1 and nia2 supported for the moment\n"); + exit(1); + } } if (ciphering_algorithm == 0) { diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_integrity_nia1.c b/openair2/LAYER2/nr_pdcp/nr_pdcp_integrity_nia1.c new file mode 100644 index 0000000000..08ec959937 --- /dev/null +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_integrity_nia1.c @@ -0,0 +1,66 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +#include "nr_pdcp_integrity_nia1.h" + +#include +#include +#include +#include + +#include "UTIL/OSA/osa_defs.h" + +int stream_compute_integrity_eia1(stream_cipher_t *stream_cipher, uint8_t out[4]); + +void *nr_pdcp_integrity_nia1_init(unsigned char *integrity_key) +{ + stream_cipher_t *ret; + + ret = calloc(1, sizeof(*ret)); if (ret == NULL) abort(); + ret->key = malloc(16); if (ret->key == NULL) abort(); + memcpy(ret->key, integrity_key, 16); + ret->key_length = 16; /* unused */ + + return ret; +} + +void nr_pdcp_integrity_nia1_integrity(void *integrity_context, + unsigned char *out, + unsigned char *buffer, int length, + int bearer, int count, int direction) +{ + stream_cipher_t *ctx = integrity_context; + + ctx->message = buffer; + ctx->count = count; + ctx->bearer = bearer-1; + ctx->direction = direction; + ctx->blength = length * 8; + + stream_compute_integrity_eia1(ctx, out); +} + +void nr_pdcp_integrity_nia1_free_integrity(void *integrity_context) +{ + stream_cipher_t *ctx = integrity_context; + free(ctx->key); + free(ctx); +} diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_integrity_nia1.h b/openair2/LAYER2/nr_pdcp/nr_pdcp_integrity_nia1.h new file mode 100644 index 0000000000..5c44bad4a7 --- /dev/null +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_integrity_nia1.h @@ -0,0 +1,34 @@ +/* + * 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 + */ + +#ifndef _NR_PDCP_INTEGRITY_NIA1_H_ +#define _NR_PDCP_INTEGRITY_NIA1_H_ + +void *nr_pdcp_integrity_nia1_init(unsigned char *integrity_key); + +void nr_pdcp_integrity_nia1_integrity(void *integrity_context, + unsigned char *out, + unsigned char *buffer, int length, + int bearer, int count, int direction); + +void nr_pdcp_integrity_nia1_free_integrity(void *integrity_context); + +#endif /* _NR_PDCP_INTEGRITY_NIA1_H_ */ From 3c2375eadab4a508f85e0fcda7c7524b25b59067 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 21 Jul 2022 17:57:20 +0200 Subject: [PATCH 10/13] CI: do not trigger tests if nothing is tagged NSA The previous version would trigger sub-pipelines (LTE-2x2, ...) if no MR had the NSA tag (without a commit, etc). Of course, this would make all pipelines subsequently fail (as not enough arguments, such as the commit, were given). In this commit, we read the output of `jq` from JSON, which will result in an empty list if no MR is tagged with the NSA label (and the output in the console will be nicer as well). --- ci-scripts/Jenkinsfile-trig-nsa | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/ci-scripts/Jenkinsfile-trig-nsa b/ci-scripts/Jenkinsfile-trig-nsa index 3616b2c404..8e81b75e58 100644 --- a/ci-scripts/Jenkinsfile-trig-nsa +++ b/ci-scripts/Jenkinsfile-trig-nsa @@ -20,6 +20,9 @@ * contact@openairinterface.org */ +// necessary for reading JSON +import groovy.json.JsonSlurper + // Template Jenkins Declarative Pipeline script to run Test w/ RF HW // Location of the python executor node shall be in the same subnet as the others servers @@ -37,12 +40,12 @@ pipeline { stages { stage ("Launcher") { steps { - script { - //retrieve MR that are opened nd with tag NSA - MR_LIST= sh returnStdout: true, script: 'curl --silent "https://gitlab.eurecom.fr/api/v4/projects/oai%2Fopenairinterface5g/merge_requests?state=opened&per_page=100&labels=NSA" | jq ".[].iid" || true ' - echo "List of selected MR:\n${MR_LIST}" - def MR_ARRAY = MR_LIST.split('\n') - //for every selected MR, retrieve the branch name and the latest commit + script { + // retrieve MR that are opened nd with tag NSA + MR_LIST = sh returnStdout: true, script: 'curl --silent "https://gitlab.eurecom.fr/api/v4/projects/oai%2Fopenairinterface5g/merge_requests?state=opened&per_page=100&labels=NSA" | jq -cj "[.[].iid]"' + echo "List of selected MRs: ${MR_LIST.trim()}" + def MR_ARRAY = new JsonSlurper().parseText(MR_LIST.trim()) + // for every selected MR, retrieve the branch name and the latest commit for (MR in MR_ARRAY) { SRC_BRANCH=sh returnStdout: true, script: """curl --silent "https://gitlab.eurecom.fr/api/v4/projects/oai%2Fopenairinterface5g/merge_requests/${MR}" | jq ".source_branch" || true """ SRC_BRANCH=SRC_BRANCH.trim() From 228bd5f16d86d4ebc8d2a6777379455e22346e39 Mon Sep 17 00:00:00 2001 From: francescomani Date: Fri, 22 Jul 2022 17:01:47 +0200 Subject: [PATCH 11/13] fix for ssb subcarrier offset in case of <3GHz --- openair2/LAYER2/NR_MAC_gNB/config.c | 2 +- openair2/RRC/NR/MESSAGES/asn1_msg.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c index 4daddbf03a..a79748238f 100644 --- a/openair2/LAYER2/NR_MAC_gNB/config.c +++ b/openair2/LAYER2/NR_MAC_gNB/config.c @@ -337,7 +337,7 @@ void config_common(int Mod_idP, int pdsch_AntennaPorts, int pusch_AntennaPorts, // SSB Table Configuration uint32_t absolute_diff = (*scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencySSB - scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA); const int scaling_5khz = scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA < 600000 ? 3 : 1; - int sco = (absolute_diff*scaling_5khz) % 24; + int sco = (absolute_diff/scaling_5khz) % 24; if(frequency_range == FR2) sco >>= 1; // this assumes 120kHz SCS for SSB and subCarrierSpacingCommon (only option supported by OAI for const int scs_scaling = frequency_range == FR2 ? 1 << (*scc->ssbSubcarrierSpacing - 2) : 1 << *scc->ssbSubcarrierSpacing; diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index a93d2a8623..ff139c9895 100755 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -230,7 +230,7 @@ uint8_t do_MIB_NR(gNB_RRC_INST *rrc,uint32_t frame) { if (get_softmodem_params()->sa) { uint32_t absolute_diff = (*scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencySSB - scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA); int scs_scaling = scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA < 600000 ? 3 : 1; - ssb_subcarrier_offset = (absolute_diff*scs_scaling)%24; + ssb_subcarrier_offset = (absolute_diff/scs_scaling)%24; if(frequency_range == FR2) ssb_subcarrier_offset >>= 1; // this assumes 120kHz SCS for SSB and subCarrierSpacingCommon (only option supported by OAI for now) } From e1798745ef70265baa7fd8809980e31725fc0dcb Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 19 Jul 2022 18:21:28 +0200 Subject: [PATCH 12/13] Dynamically build L2sim proxy --- ci-scripts/Jenkinsfile-push-registry | 2 +- ci-scripts/Jenkinsfile-tmp-multi-enb | 187 +++++++++++++++++- ci-scripts/cls_containerize.py | 119 +++++++++++ ci-scripts/main.py | 7 +- ci-scripts/xml_class_list.yml | 1 + .../xml_files/container_5g_l2sim_proxy.xml | 42 ++++ 6 files changed, 354 insertions(+), 4 deletions(-) create mode 100644 ci-scripts/xml_files/container_5g_l2sim_proxy.xml diff --git a/ci-scripts/Jenkinsfile-push-registry b/ci-scripts/Jenkinsfile-push-registry index bc1a80ba61..feb1807c91 100644 --- a/ci-scripts/Jenkinsfile-push-registry +++ b/ci-scripts/Jenkinsfile-push-registry @@ -66,7 +66,7 @@ pipeline { withCredentials([ [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.DH_Credentials}", usernameVariable: 'DH_Username', passwordVariable: 'DH_Password'] ]) { - def listOfImages = ["oai-enb", "oai-gnb", "oai-lte-ue", "oai-nr-ue"] + def listOfImages = ["oai-enb", "oai-gnb", "oai-lte-ue", "oai-nr-ue", "proxy"] sh "docker login -u ${DH_Username} -p ${DH_Password} > /dev/null 2>&1" listOfImages.eachWithIndex { item, iindex -> sh "docker image tag ${item}:develop ${DH_Account}/${item}:develop" diff --git a/ci-scripts/Jenkinsfile-tmp-multi-enb b/ci-scripts/Jenkinsfile-tmp-multi-enb index c3b825ec06..fb52316920 100644 --- a/ci-scripts/Jenkinsfile-tmp-multi-enb +++ b/ci-scripts/Jenkinsfile-tmp-multi-enb @@ -36,6 +36,9 @@ def testStageName = params.pipelineTestStageName // Name of the phone resource def ciSmartPhoneResource = params.smartphonesResource +// Name of the phone resource +def ciEpcResource = params.epcResource + // Global Parameters. Normally they should be populated when the master job // triggers the slave job with parameters def eNB_Repository @@ -51,7 +54,7 @@ pipeline { options { disableConcurrentBuilds() ansiColor('xterm') - lock (ciSmartPhoneResource) + lock(extra: [[resource: ciEpcResource]], resource: ciSmartPhoneResource) } stages { stage ("Verify Parameters") { @@ -216,6 +219,76 @@ pipeline { } } } + stage ("Terminate") { + parallel { + stage('Terminate UE') { + // Bypassing this stage if there are no abd server defined + when { + expression { params.ADB_IPAddress != "none" } + } + steps { + echo '\u2705 \u001B[32mTerminate UE\u001B[0m' + withCredentials([ + [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.ADB_Credentials}", usernameVariable: 'ADB_Username', passwordVariable: 'ADB_Password'] + ]) { + sh "python3 ci-scripts/main.py --mode=TerminateUE --ADBIPAddress=${params.ADB_IPAddress} --ADBUserName=${ADB_Username} --ADBPassword=${ADB_Password}" + } + } + } + stage('Terminate eNB') { + steps { + echo '\u2705 \u001B[32mTerminate eNB\u001B[0m' + withCredentials([ + [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.eNB_Credentials}", usernameVariable: 'eNB_Username', passwordVariable: 'eNB_Password'] + ]) { + sh "python3 ci-scripts/main.py --mode=TerminateeNB --eNBIPAddress=${params.eNB_IPAddress} --eNBUserName=${eNB_Username} --eNBPassword=${eNB_Password}" + } + } + } + stage('Terminate SPGW') { + // Bypassing this stage if EPC server is not defined + when { + expression { params.EPC_IPAddress != "none" } + } + steps { + echo '\u2705 \u001B[32mTerminate SPGW\u001B[0m' + withCredentials([ + [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.EPC_Credentials}", usernameVariable: 'EPC_Username', passwordVariable: 'EPC_Password'] + ]) { + sh "python3 ci-scripts/main.py --mode=TerminateSPGW --EPCIPAddress=${params.EPC_IPAddress} --EPCUserName=${EPC_Username} --EPCPassword=${EPC_Password} --EPCType=${params.EPC_Type} --EPCSourceCodePath=${params.EPC_SourceCodePath}" + } + } + } + stage('Terminate MME') { + // Bypassing this stage if EPC server is not defined + when { + expression { params.EPC_IPAddress != "none" } + } + steps { + echo '\u2705 \u001B[32mTerminate MME\u001B[0m' + withCredentials([ + [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.EPC_Credentials}", usernameVariable: 'EPC_Username', passwordVariable: 'EPC_Password'] + ]) { + sh "python3 ci-scripts/main.py --mode=TerminateMME --EPCIPAddress=${params.EPC_IPAddress} --EPCUserName=${EPC_Username} --EPCPassword=${EPC_Password} --EPCType=${params.EPC_Type} --EPCSourceCodePath=${params.EPC_SourceCodePath}" + } + } + } + stage('Terminate HSS') { + // Bypassing this stage if EPC server is not defined + when { + expression { params.EPC_IPAddress != "none" } + } + steps { + echo '\u2705 \u001B[32mTerminate HSS\u001B[0m' + withCredentials([ + [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.EPC_Credentials}", usernameVariable: 'EPC_Username', passwordVariable: 'EPC_Password'] + ]) { + sh "python3 ci-scripts/main.py --mode=TerminateHSS --EPCIPAddress=${params.EPC_IPAddress} --EPCUserName=${EPC_Username} --EPCPassword=${EPC_Password} --EPCType=${params.EPC_Type} --EPCSourceCodePath=${params.EPC_SourceCodePath}" + } + } + } + } + } stage('Log Collection') { parallel { stage('Log Collection (eNB - Build)') { @@ -242,7 +315,7 @@ pipeline { [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.eNB_Credentials}", usernameVariable: 'eNB_Username', passwordVariable: 'eNB_Password'] ]) { echo '\u2705 \u001B[32mLog Collection (eNB - Run)\u001B[0m' - sh "python3 ci-scripts/main.py --mode=LogCollecteNB --eNBIPAddress=${params.eNB_IPAddress} --eNBUserName=${eNB_Username} --eNBPassword=${eNB_Password} --eNBSourceCodePath=${params.eNB_SourceCodePath}" + sh "python3 ci-scripts/main.py --mode=LogCollecteNB --eNBIPAddress=${params.eNB_IPAddress} --eNBUserName=${eNB_Username} --eNBPassword=${eNB_Password} --eNBSourceCodePath=${params.eNB_SourceCodePath} --BuildId=${env.BUILD_ID}" echo '\u2705 \u001B[32mLog Transfer (eNB - Run)\u001B[0m' sh "sshpass -p \'${eNB_Password}\' scp -o 'StrictHostKeyChecking no' -o 'ConnectTimeout 10' ${eNB_Username}@${params.eNB_IPAddress}:${eNB_SourceCodePath}/cmake_targets/enb.log.zip ./enb.log.${env.BUILD_ID}.zip || true" @@ -259,6 +332,116 @@ pipeline { } } } + stage('Log Collection (SPGW)') { + // Bypassing this stage if EPC server is not defined + when { + expression { params.EPC_IPAddress != "none" } + } + steps { + withCredentials([ + [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.EPC_Credentials}", usernameVariable: 'EPC_Username', passwordVariable: 'EPC_Password'] + ]) { + echo '\u2705 \u001B[32mLog Collection (SPGW)\u001B[0m' + sh "python3 ci-scripts/main.py --mode=LogCollectSPGW --EPCIPAddress=${params.EPC_IPAddress} --EPCUserName=${EPC_Username} --EPCPassword=${EPC_Password} --EPCSourceCodePath=${params.EPC_SourceCodePath} --EPCType=${params.EPC_Type}" + + echo '\u2705 \u001B[32mLog Transfer (SPGW)\u001B[0m' + sh "sshpass -p \'${EPC_Password}\' scp -o 'StrictHostKeyChecking no' -o 'ConnectTimeout 10' ${EPC_Username}@${params.EPC_IPAddress}:${EPC_SourceCodePath}/scripts/spgw.log.zip ./spgw.log.${env.BUILD_ID}.zip || true" + } + script { + if(fileExists("spgw.log.${env.BUILD_ID}.zip")) { + archiveArtifacts "spgw.log.${env.BUILD_ID}.zip" + } + } + } + } + stage('Log Collection (MME)') { + // Bypassing this stage if EPC server is not defined + when { + expression { params.EPC_IPAddress != "none" } + } + steps { + withCredentials([ + [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.EPC_Credentials}", usernameVariable: 'EPC_Username', passwordVariable: 'EPC_Password'] + ]) { + echo '\u2705 \u001B[32mLog Collection (MME)\u001B[0m' + sh "python3 ci-scripts/main.py --mode=LogCollectMME --EPCIPAddress=${params.EPC_IPAddress} --EPCUserName=${EPC_Username} --EPCPassword=${EPC_Password} --EPCSourceCodePath=${params.EPC_SourceCodePath} --EPCType=${params.EPC_Type}" + + echo '\u2705 \u001B[32mLog Transfer (MME)\u001B[0m' + sh "sshpass -p \'${EPC_Password}\' scp -o 'StrictHostKeyChecking no' -o 'ConnectTimeout 10' ${EPC_Username}@${params.EPC_IPAddress}:${EPC_SourceCodePath}/scripts/mme.log.zip ./mme.log.${env.BUILD_ID}.zip || true" + } + script { + if(fileExists("mme.log.${env.BUILD_ID}.zip")) { + archiveArtifacts "mme.log.${env.BUILD_ID}.zip" + } + } + } + } + stage('Log Collection (HSS)') { + // Bypassing this stage if EPC server is not defined + when { + expression { params.EPC_IPAddress != "none" } + } + steps { + withCredentials([ + [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.EPC_Credentials}", usernameVariable: 'EPC_Username', passwordVariable: 'EPC_Password'] + ]) { + echo '\u2705 \u001B[32mLog Collection (HSS)\u001B[0m' + sh "python3 ci-scripts/main.py --mode=LogCollectHSS --EPCIPAddress=${params.EPC_IPAddress} --EPCUserName=${EPC_Username} --EPCPassword=${EPC_Password} --EPCSourceCodePath=${params.EPC_SourceCodePath} --EPCType=${params.EPC_Type}" + + echo '\u2705 \u001B[32mLog Transfer (HSS)\u001B[0m' + sh "sshpass -p \'${EPC_Password}\' scp -o 'StrictHostKeyChecking no' -o 'ConnectTimeout 10' ${EPC_Username}@${params.EPC_IPAddress}:${EPC_SourceCodePath}/scripts/hss.log.zip ./hss.log.${env.BUILD_ID}.zip || true" + } + script { + if(fileExists("hss.log.${env.BUILD_ID}.zip")) { + archiveArtifacts "hss.log.${env.BUILD_ID}.zip" + } + } + } + } + stage('Log Collection (Ping)') { + // Bypassing this stage if EPC server is not defined + when { + expression { params.EPC_IPAddress != "none" } + } + steps { + withCredentials([ + [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.EPC_Credentials}", usernameVariable: 'EPC_Username', passwordVariable: 'EPC_Password'] + ]) { + echo '\u2705 \u001B[32mLog Collection (Ping)\u001B[0m' + sh "python3 ci-scripts/main.py --mode=LogCollectPing --EPCIPAddress=${params.EPC_IPAddress} --EPCUserName=${EPC_Username} --EPCPassword=${EPC_Password} --EPCSourceCodePath=${params.EPC_SourceCodePath} --EPCType=${params.EPC_Type}" + + echo '\u2705 \u001B[32mLog Transfer (Ping)\u001B[0m' + sh "sshpass -p \'${EPC_Password}\' scp -o 'StrictHostKeyChecking no' -o 'ConnectTimeout 10' ${EPC_Username}@${params.EPC_IPAddress}:${EPC_SourceCodePath}/scripts/ping.log.zip ./ping.log.${env.BUILD_ID}.zip || true" + } + script { + if(fileExists("ping.log.${env.BUILD_ID}.zip")) { + archiveArtifacts "ping.log.${env.BUILD_ID}.zip" + } + } + } + } + stage('Log Collection (Iperf)') { + // Bypassing this stage if EPC server is not defined + when { + expression { params.EPC_IPAddress != "none" } + } + steps { + withCredentials([ + [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.EPC_Credentials}", usernameVariable: 'EPC_Username', passwordVariable: 'EPC_Password'] + ]) { + echo '\u2705 \u001B[32mLog Collection (Iperf)\u001B[0m' + sh "python3 ci-scripts/main.py --mode=LogCollectIperf --EPCIPAddress=${params.EPC_IPAddress} --EPCUserName=${EPC_Username} --EPCPassword=${EPC_Password} --EPCSourceCodePath=${params.EPC_SourceCodePath} --EPCType=${params.EPC_Type}" + + echo '\u2705 \u001B[32mLog Transfer (Iperf)\u001B[0m' + sh "sshpass -p \'${EPC_Password}\' scp -o 'StrictHostKeyChecking no' -o 'ConnectTimeout 10' ${EPC_Username}@${params.EPC_IPAddress}:${EPC_SourceCodePath}/scripts/iperf.log.zip ./iperf.log.${env.BUILD_ID}.zip || true" + } + script { + if(fileExists("iperf.log.${env.BUILD_ID}.zip")) { + archiveArtifacts "iperf.log.${env.BUILD_ID}.zip" + } + } + } + } } } } diff --git a/ci-scripts/cls_containerize.py b/ci-scripts/cls_containerize.py index 6abf444a0d..8f992689e2 100644 --- a/ci-scripts/cls_containerize.py +++ b/ci-scripts/cls_containerize.py @@ -74,6 +74,7 @@ class Containerize(): self.eNB2SourceCodePath = '' self.forcedWorkspaceCleanup = False self.imageKind = '' + self.proxyCommit = None self.eNB_instance = 0 self.eNB_serverId = ['', '', ''] self.yamlPath = ['', '', ''] @@ -421,6 +422,124 @@ class Containerize(): HTML.CreateHtmlTabFooter(False) sys.exit(1) + def BuildProxy(self, HTML): + if self.ranRepository == '' or self.ranBranch == '' or self.ranCommitID == '': + HELP.GenericHelp(CONST.Version) + sys.exit('Insufficient Parameter') + if self.eNB_serverId[self.eNB_instance] == '0': + lIpAddr = self.eNBIPAddress + lUserName = self.eNBUserName + lPassWord = self.eNBPassword + lSourcePath = self.eNBSourceCodePath + elif self.eNB_serverId[self.eNB_instance] == '1': + lIpAddr = self.eNB1IPAddress + lUserName = self.eNB1UserName + lPassWord = self.eNB1Password + lSourcePath = self.eNB1SourceCodePath + elif self.eNB_serverId[self.eNB_instance] == '2': + lIpAddr = self.eNB2IPAddress + lUserName = self.eNB2UserName + lPassWord = self.eNB2Password + lSourcePath = self.eNB2SourceCodePath + if lIpAddr == '' or lUserName == '' or lPassWord == '' or lSourcePath == '': + HELP.GenericHelp(CONST.Version) + sys.exit('Insufficient Parameter') + if self.proxyCommit is None: + HELP.GenericHelp(CONST.Version) + sys.exit('Insufficient Parameter (need proxyCommit for proxy build)') + logging.debug('Building on server: ' + lIpAddr) + mySSH = SSH.SSHConnection() + mySSH.open(lIpAddr, lUserName, lPassWord) + + # Check that we are on Ubuntu + mySSH.command('hostnamectl', '\$', 5) + result = re.search('Ubuntu', mySSH.getBefore()) + self.host = result.group(0) + if self.host != 'Ubuntu': + logging.error('\u001B[1m Can build proxy only on Ubuntu server\u001B[0m') + mySSH.close() + sys.exit(1) + + self.cli = 'docker' + self.cliBuildOptions = '--no-cache' + + # Workaround for some servers, we need to erase completely the workspace + if self.forcedWorkspaceCleanup: + mySSH.command('echo ' + lPassWord + ' | sudo -S rm -Rf ' + lSourcePath, '\$', 15) + + oldRanCommidID = self.ranCommitID + oldRanRepository = self.ranRepository + oldRanAllowMerge = self.ranAllowMerge + self.ranCommitID = self.proxyCommit + self.ranRepository = 'https://github.com/EpiSci/oai-lte-5g-multi-ue-proxy.git' + self.ranAllowMerge = False + self._createWorkspace(mySSH, lPassWord, lSourcePath) + # to prevent accidentally overwriting data that might be used later + self.ranCommitID = oldRanCommidID + self.ranRepository = oldRanRepository + self.ranAllowMerge = oldRanAllowMerge + + # Let's remove any previous run artifacts if still there + mySSH.command(self.cli + ' image prune --force', '\$', 30) + # Remove any previous proxy image + mySSH.command(self.cli + ' image rm oai-lte-multi-ue-proxy:latest || true', '\$', 30) + + tag = self.proxyCommit + logging.debug('building L2sim proxy image for tag ' + tag) + # check if the corresponding proxy image with tag exists. If not, build it + mySSH.command(self.cli + ' image inspect --format=\'Size = {{.Size}} bytes\' proxy:' + tag, '\$', 5) + buildProxy = mySSH.getBefore().count('o such image') != 0 + if buildProxy: + mySSH.command(self.cli + ' build ' + self.cliBuildOptions + ' --target oai-lte-multi-ue-proxy --tag proxy:' + tag + ' --file docker/Dockerfile.ubuntu18.04 . > cmake_targets/log/proxy-build.log 2>&1', '\$', 180) + # Note: at this point, OAI images are flattened, but we cannot do this + # here, as the flatten script is not in the proxy repo + mySSH.command(self.cli + ' image inspect --format=\'Size = {{.Size}} bytes\' proxy:' + tag, '\$', 5) + if mySSH.getBefore().count('o such image') != 0: + logging.error('\u001B[1m Build of L2sim proxy failed\u001B[0m') + mySSH.close() + HTML.CreateHtmlTestRow('commit ' + tag, 'KO', CONST.ALL_PROCESSES_OK) + HTML.CreateHtmlTabFooter(False) + sys.exit(1) + else: + logging.debug('L2sim proxy image for tag ' + tag + ' already exists, skipping build') + + # retag the build images to that we pick it up later + mySSH.command('docker image tag proxy:' + tag + ' oai-lte-multi-ue-proxy:latest', '\$', 5) + + # no merge: is a push to develop, tag the image so we can push it to the registry + if not self.ranAllowMerge: + mySSH.command('docker image tag proxy:' + tag + ' proxy:develop', '\$', 5) + + # we assume that the host on which this is built will also run the proxy. The proxy + # currently requires the following command, and the docker-compose up mechanism of + # the CI does not allow to run arbitrary commands. Note that the following actually + # belongs to the deployment, not the build of the proxy... + logging.warning('the following command belongs to deployment, but no mechanism exists to exec it there!') + mySSH.command('sudo ifconfig lo: 127.0.0.2 netmask 255.0.0.0 up', '\$', 5) + + # Analyzing the logs + if buildProxy: + self.testCase_id = HTML.testCase_id + mySSH.command('cd ' + lSourcePath + '/cmake_targets', '\$', 5) + mySSH.command('mkdir -p proxy_build_log_' + self.testCase_id, '\$', 5) + mySSH.command('mv log/* ' + 'proxy_build_log_' + self.testCase_id, '\$', 5) + if (os.path.isfile('./proxy_build_log_' + self.testCase_id + '.zip')): + os.remove('./proxy_build_log_' + self.testCase_id + '.zip') + if (os.path.isdir('./proxy_build_log_' + self.testCase_id)): + shutil.rmtree('./proxy_build_log_' + self.testCase_id) + mySSH.command('zip -r -qq proxy_build_log_' + self.testCase_id + '.zip proxy_build_log_' + self.testCase_id, '\$', 5) + mySSH.copyin(lIpAddr, lUserName, lPassWord, lSourcePath + '/cmake_targets/build_log_' + self.testCase_id + '.zip', '.') + # don't delete such that we might recover the zips + #mySSH.command('rm -f build_log_' + self.testCase_id + '.zip','\$', 5) + + # 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(self.collectInfo, self.allImagesSize) + def Copy_Image_to_Test_Server(self, HTML): imageTag = 'develop' if (self.ranAllowMerge): diff --git a/ci-scripts/main.py b/ci-scripts/main.py index 448f2636e3..baed6a6011 100644 --- a/ci-scripts/main.py +++ b/ci-scripts/main.py @@ -102,7 +102,7 @@ def AssignParams(params_dict): def GetParametersFromXML(action): - if action == 'Build_eNB' or action == 'Build_Image': + if action == 'Build_eNB' or action == 'Build_Image' or action == 'Build_Proxy': RAN.Build_eNB_args=test.findtext('Build_eNB_args') CONTAINERS.imageKind=test.findtext('kind') forced_workspace_cleanup = test.findtext('forced_workspace_cleanup') @@ -138,6 +138,9 @@ def GetParametersFromXML(action): RAN.backgroundBuild=True else: RAN.backgroundBuild=False + proxy_commit = test.findtext('proxy_commit') + if proxy_commit is not None: + CONTAINERS.proxyCommit = proxy_commit elif action == 'WaitEndBuild_eNB': RAN.Build_eNB_args=test.findtext('Build_eNB_args') @@ -915,6 +918,8 @@ elif re.match('^TesteNB$', mode, re.IGNORECASE) or re.match('^TestUE$', mode, re HTML=ldpc.Run_PhySim(HTML,CONST,id) elif action == 'Build_Image': CONTAINERS.BuildImage(HTML) + elif action == 'Build_Proxy': + CONTAINERS.BuildProxy(HTML) elif action == 'Copy_Image_to_Test': CONTAINERS.Copy_Image_to_Test_Server(HTML) elif action == 'Deploy_Object': diff --git a/ci-scripts/xml_class_list.yml b/ci-scripts/xml_class_list.yml index b305aff424..2c5f04b11f 100755 --- a/ci-scripts/xml_class_list.yml +++ b/ci-scripts/xml_class_list.yml @@ -1,3 +1,4 @@ + - Build_Proxy - Build_PhySim - Run_PhySim - Build_eNB diff --git a/ci-scripts/xml_files/container_5g_l2sim_proxy.xml b/ci-scripts/xml_files/container_5g_l2sim_proxy.xml new file mode 100644 index 0000000000..af1715d793 --- /dev/null +++ b/ci-scripts/xml_files/container_5g_l2sim_proxy.xml @@ -0,0 +1,42 @@ + + + l2sim-5gnr-proxy-build + Build L2sim proxy image + wrench + 1 + + 000001 + + + + + Build_Proxy + Build L2sim Proxy Image + 1 + 1 + True + 56cfdc0 + + + From b4331bf7f43588fadc90e9504de3894872f14145 Mon Sep 17 00:00:00 2001 From: laurent Date: Thu, 30 Jun 2022 17:57:47 +0200 Subject: [PATCH 13/13] code maintenance: old errors --- executables/nr-softmodem.h | 3 - openair1/PHY/LTE_UE_TRANSPORT/dci_tools_ue.c | 21 ++- openair1/SCHED/ru_procedures.c | 14 +- openair1/SCHED/sched_common_extern.h | 2 + openair1/SIMULATION/LTE_PHY/dlsim.c | 8 +- .../LAYER2/MAC/eNB_scheduler_primitives.c | 16 --- openair2/LAYER2/MAC/eNB_scheduler_ulsch.c | 12 +- openair2/LAYER2/MAC/mac.h | 10 +- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 11 +- openair2/RRC/LTE/rrc_eNB.c | 124 +++++------------- targets/RT/USER/lte-ru.c | 6 +- targets/RT/USER/lte-softmodem.h | 17 ++- targets/RT/USER/lte-uesoftmodem.c | 1 - 13 files changed, 90 insertions(+), 155 deletions(-) diff --git a/executables/nr-softmodem.h b/executables/nr-softmodem.h index 7d2184f01b..98087ea2bb 100644 --- a/executables/nr-softmodem.h +++ b/executables/nr-softmodem.h @@ -59,9 +59,6 @@ extern void set_function_spec_param(RU_t *ru); extern void reset_opp_meas(void); extern void print_opp_meas(void); - -extern void init_fep_thread(PHY_VARS_gNB *); - void init_gNB_afterRU(void); extern int stop_L1L2(module_id_t gnb_id); diff --git a/openair1/PHY/LTE_UE_TRANSPORT/dci_tools_ue.c b/openair1/PHY/LTE_UE_TRANSPORT/dci_tools_ue.c index 088e2c0a5e..b5e5b490a3 100644 --- a/openair1/PHY/LTE_UE_TRANSPORT/dci_tools_ue.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/dci_tools_ue.c @@ -64,6 +64,12 @@ extern uint16_t beta_cqi[16]; extern uint16_t beta_ri[16]; extern uint16_t beta_ack[16]; +static int errorRB(int rb, char * table, int line) { + LOG_E(PHY,"Received %d rb, impossble in table %s, at line %d\n", rb, table, line); + return 0; +} + +#define rbAllocCheck(RBalL, TabLe) (RBalL) > sizeof(TabLe)/sizeof(*TabLe) ? errorRB(RBalL, #TabLe, __LINE__) : TabLe[RBalL] void extract_dci1A_info(uint8_t N_RB_DL, frame_type_t frame_type, void *dci_pdu, DCI_INFO_EXTRACTED_t *pdci_info_extarcted) { uint8_t harq_pid=0; @@ -974,28 +980,28 @@ int check_dci_format1_1a_coherency(DCI_format_t dci_format, { switch (N_RB_DL) { case 6: - NPRB = RIV2nb_rb_LUT6[rballoc];//NPRB; + NPRB = rbAllocCheck(rballoc, RIV2nb_rb_LUT6); if(rah) RIV_max = RIV_max6; else RIV_max = 0x3F; break; case 25: - NPRB = RIV2nb_rb_LUT25[rballoc];//NPRB; + NPRB = rbAllocCheck(rballoc,RIV2nb_rb_LUT25); if(rah) RIV_max = RIV_max25; else RIV_max = 0x1FFF; break; case 50: - NPRB = RIV2nb_rb_LUT50[rballoc];//NPRB; + NPRB = rbAllocCheck(rballoc,RIV2nb_rb_LUT50); if(rah) RIV_max = RIV_max50; else RIV_max = 0x1FFFF; break; case 100: - NPRB = RIV2nb_rb_LUT100[rballoc];//NPRB; + NPRB = rbAllocCheck(rballoc,RIV2nb_rb_LUT100); if(rah) RIV_max = RIV_max100; else @@ -1034,9 +1040,14 @@ int check_dci_format1_1a_coherency(DCI_format_t dci_format, // this is an eNB issue // retransmisison but old and new TBS are different !!! // work around, consider it as a new transmission - LOG_E(PHY,"Format1A Retransmission but TBS are different: consider it as new transmission !!! \n"); + LOG_E(PHY, + "Format1A Retransmission but TBS are different: consider it as new transmission !!!, round %d, mcs 1 %d, NPRB %d \n", + pdlsch0_harq->round, + mcs1, + NPRB); pdlsch0_harq->round = 0; //return(0); // ?? to cross check + return(0); // ?? to cross check } } diff --git a/openair1/SCHED/ru_procedures.c b/openair1/SCHED/ru_procedures.c index dc84279a96..443b1c7989 100644 --- a/openair1/SCHED/ru_procedures.c +++ b/openair1/SCHED/ru_procedures.c @@ -71,9 +71,9 @@ #include "common/utils/system.h" #include - -extern int oai_exit; - +#include "openair1/SCHED/sched_common_extern.h" +#include "targets/RT/USER/lte-softmodem.h" +#include "common/ran_context.h" void feptx0(RU_t *ru, int slot) @@ -616,9 +616,11 @@ void init_fep_thread(RU_t *ru, } -extern void kill_fep_thread(RU_t *ru) +void kill_fep_thread(RU_t *ru) { RU_proc_t *proc = &ru->proc; + if (proc->pthread_fep == 0) + return; pthread_mutex_lock( &proc->mutex_fep ); proc->instance_cnt_fep = 0; pthread_cond_signal(&proc->cond_fep); @@ -630,9 +632,11 @@ extern void kill_fep_thread(RU_t *ru) } -extern void kill_feptx_thread(RU_t *ru) +void kill_feptx_thread(RU_t *ru) { RU_proc_t *proc = &ru->proc; + if (proc->pthread_feptx == 0) + return; pthread_mutex_lock( &proc->mutex_feptx ); proc->instance_cnt_feptx = 0; pthread_cond_signal(&proc->cond_feptx); diff --git a/openair1/SCHED/sched_common_extern.h b/openair1/SCHED/sched_common_extern.h index b5edc6f38e..2236c5f31d 100644 --- a/openair1/SCHED/sched_common_extern.h +++ b/openair1/SCHED/sched_common_extern.h @@ -29,4 +29,6 @@ extern int16_t hundred_times_delta_TF[100]; extern uint16_t hundred_times_log10_NPRB[100]; +void kill_fep_thread(RU_t *ru); + #endif /*__SCHED_EXTERN_H__ */ diff --git a/openair1/SIMULATION/LTE_PHY/dlsim.c b/openair1/SIMULATION/LTE_PHY/dlsim.c index 231d63cf04..e5e97733e5 100644 --- a/openair1/SIMULATION/LTE_PHY/dlsim.c +++ b/openair1/SIMULATION/LTE_PHY/dlsim.c @@ -514,10 +514,10 @@ int main(int argc, char **argv) { LTE_DL_FRAME_PARMS *frame_parms; double s_re0[30720*2],s_im0[30720*2],r_re0[30720*2],r_im0[30720*2]; double s_re1[30720*2],s_im1[30720*2],r_re1[30720*2],r_im1[30720*2]; - double *s_re[2]= {s_re0,s_re1}; - double *s_im[2]= {s_im0,s_im1}; - double *r_re[2]= {r_re0,r_re1}; - double *r_im[2]= {r_im0,r_im1}; + double *s_re[NB_ANTENNAS_TX]= {s_re0,s_re1}; + double *s_im[NB_ANTENNAS_TX]= {s_im0,s_im1}; + double *r_re[NB_ANTENNAS_RX]= {r_re0,r_re1}; + double *r_im[NB_ANTENNAS_RX]= {r_im0,r_im1}; uint8_t transmission_mode=1,n_tx_port=1,n_tx_phy=1,n_rx=2; int eNB_id = 0; unsigned char round; diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c index 4469d0a3f9..58abbd7a47 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c @@ -2366,22 +2366,6 @@ rrc_mac_remove_ue(module_id_t mod_idP, return 0; } -//------------------------------------------------------------------------------ -/* - * Returns the previous UE_id in the scheduling list in UL or DL - */ -inline int prev(UE_list_t *listP, int nodeP) { - if (nodeP == listP->head) - return -1; /* there is no previous of the head */ - - for (int j = listP->head; j >= 0; j = listP->next[j]) - if (listP->next[j] == nodeP) - return j; - - LOG_E(MAC, "%s(): could not find previous to %d in UE_list\n", __func__, nodeP); - dump_ue_list(listP); - return -1; -} // This has to be updated to include BSR information //------------------------------------------------------------------------------ diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index a31b8bdd03..f9218d8511 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -329,17 +329,7 @@ rx_sdu(const module_id_t enb_mod_idP, if (ra->msg3_round >= mac->common_channels[CC_idP].radioResourceConfigCommon->rach_ConfigCommon.maxHARQ_Msg3Tx - 1) { // Release RNTI of LTE PHY when RA does not succeed - UE_free_list_t *free_list = NULL; - pthread_mutex_lock(&lock_ue_freelist); - free_list = &mac->UE_free_list; - free_list->UE_free_ctrl[free_list->tail_freelist].rnti = current_rnti; - free_list->UE_free_ctrl[free_list->tail_freelist].removeContextFlg = 1; - free_list->UE_free_ctrl[free_list->tail_freelist].raFlag = 1; - free_list->num_UEs++; - mac->UE_release_req.ue_release_request_body.ue_release_request_TLVs_list[mac->UE_release_req.ue_release_request_body.number_of_TLVs].rnti = current_rnti; - mac->UE_release_req.ue_release_request_body.number_of_TLVs++; - free_list->tail_freelist = (free_list->tail_freelist + 1) % (NUMBER_OF_UE_MAX+1); - pthread_mutex_unlock(&lock_ue_freelist); + put_UE_in_freelist(enb_mod_idP, current_rnti, true); cancel_ra_proc(enb_mod_idP, CC_idP, frameP, current_rnti); nfapi_hi_dci0_request_t *hi_dci0_req = NULL; diff --git a/openair2/LAYER2/MAC/mac.h b/openair2/LAYER2/MAC/mac.h index 2392c8506b..1fd7182c6f 100644 --- a/openair2/LAYER2/MAC/mac.h +++ b/openair2/LAYER2/MAC/mac.h @@ -1195,14 +1195,6 @@ typedef struct { ///remove RA flag bool raFlag; } UE_free_ctrl_t; -/*! \brief REMOVE UE list used by eNB to order UEs/CC for deleting*/ -typedef struct { - /// deleting control info - UE_free_ctrl_t UE_free_ctrl[NUMBER_OF_UE_MAX+1]; - int num_UEs; - int head_freelist; ///the head position of the delete list - int tail_freelist; ///the tail position of the delete list -} UE_free_list_t; /** * describes contiguous RBs @@ -1443,7 +1435,7 @@ typedef struct eNB_MAC_INST_s { /// processing time of eNB PCH scheduler time_stats_t schedule_pch; - UE_free_list_t UE_free_list; + UE_free_ctrl_t UE_free_ctrl[NUMBER_OF_UE_MAX+1]; /// for scheduling selection SCHEDULER_MODES scheduler_mode; /// Default scheduler: Pre-processor implementation. Algorithms for UL/DL diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 9941437e13..01a574f83c 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -2437,16 +2437,15 @@ NR_UE_info_t *add_new_nr_ue(gNB_MAC_INST *nr_mac, rnti_t rntiP, NR_CellGroupConf sched_ctrl->next_dl_bwp_id = -1; sched_ctrl->next_ul_bwp_id = -1; const struct NR_UplinkConfig__uplinkBWP_ToAddModList *ubwpList = servingCellConfig ? servingCellConfig->uplinkConfig->uplinkBWP_ToAddModList : NULL; - if (ubwpList) - AssertFatal(ubwpList->list.count <= NR_MAX_NUM_BWP, - "uplinkBWP_ToAddModList has %d BWP!\n", - ubwpList->list.count); + AssertFatal(ubwpList == NULL || ubwpList->list.count <= NR_MAX_NUM_BWP, + "uplinkBWP_ToAddModList has %d BWP!\n", + ubwpList->list.count); const int ul_bwp_id = servingCellConfig ? *servingCellConfig->uplinkConfig->firstActiveUplinkBWP_Id : 0; sched_ctrl->active_ubwp = ubwpList && ul_bwp_id > 0 ? ubwpList->list.array[ul_bwp_id - 1] : NULL; /* get Number of HARQ processes for this UE */ - if (servingCellConfig) - AssertFatal(servingCellConfig->pdsch_ServingCellConfig->present == NR_SetupRelease_PDSCH_ServingCellConfig_PR_setup, + AssertFatal(servingCellConfig == NULL + || servingCellConfig->pdsch_ServingCellConfig->present == NR_SetupRelease_PDSCH_ServingCellConfig_PR_setup, "no pdsch-ServingCellConfig found for UE %04x\n", UE->rnti); const NR_PDSCH_ServingCellConfig_t *pdsch = servingCellConfig ? servingCellConfig->pdsch_ServingCellConfig->choice.setup : NULL; diff --git a/openair2/RRC/LTE/rrc_eNB.c b/openair2/RRC/LTE/rrc_eNB.c index a5d938cdf6..8be30175e1 100644 --- a/openair2/RRC/LTE/rrc_eNB.c +++ b/openair2/RRC/LTE/rrc_eNB.c @@ -976,28 +976,24 @@ rrc_eNB_free_UE( put_UE_in_freelist(enb_mod_idP, rnti, 1); } -void remove_UE_from_freelist(module_id_t mod_id, rnti_t rnti) { - eNB_MAC_INST *eNB_MAC = RC.mac[mod_id]; - pthread_mutex_lock(&lock_ue_freelist); - UE_free_list_t *free_list = &eNB_MAC->UE_free_list; - free_list->UE_free_ctrl[free_list->head_freelist].rnti = 0; - free_list->head_freelist = (free_list->head_freelist + 1) % (NUMBER_OF_UE_MAX+1); - free_list->num_UEs--; - pthread_mutex_unlock(&lock_ue_freelist); -} - void put_UE_in_freelist(module_id_t mod_id, rnti_t rnti, bool removeFlag) { - UE_free_list_t *free_list = NULL; eNB_MAC_INST *eNB_MAC = RC.mac[mod_id]; pthread_mutex_lock(&lock_ue_freelist); - free_list = &eNB_MAC->UE_free_list; - free_list->UE_free_ctrl[free_list->tail_freelist].rnti = rnti; - free_list->UE_free_ctrl[free_list->tail_freelist].removeContextFlg = removeFlag; - free_list->UE_free_ctrl[free_list->tail_freelist].raFlag = 0; - free_list->num_UEs++; + LOG_I(PHY,"add ue %d in fre list, context flag: %d\n", rnti, removeFlag); + int i; + for (i=0; i < sizeofArray(eNB_MAC->UE_free_ctrl); i++) + if (eNB_MAC->UE_free_ctrl[i].rnti == 0) + break; + if (i==sizeofArray(eNB_MAC->UE_free_ctrl)) { + LOG_E(PHY,"List of UE to free is full\n"); + pthread_mutex_unlock(&lock_ue_freelist); + return; + } + eNB_MAC->UE_free_ctrl[i].rnti = rnti; + eNB_MAC->UE_free_ctrl[i].removeContextFlg = removeFlag; + eNB_MAC->UE_free_ctrl[i].raFlag = 0; eNB_MAC->UE_release_req.ue_release_request_body.ue_release_request_TLVs_list[eNB_MAC->UE_release_req.ue_release_request_body.number_of_TLVs].rnti = rnti; eNB_MAC->UE_release_req.ue_release_request_body.number_of_TLVs++; - free_list->tail_freelist = (free_list->tail_freelist + 1) % (NUMBER_OF_UE_MAX+1); pthread_mutex_unlock(&lock_ue_freelist); } @@ -1007,104 +1003,47 @@ extern void clean_eNb_ulsch(LTE_eNB_ULSCH_t *ulsch); extern void clean_eNb_dlsch(LTE_eNB_DLSCH_t *dlsch); void release_UE_in_freeList(module_id_t mod_id) { - int i, j, CC_id, pdu_number; - protocol_ctxt_t ctxt; - nfapi_ul_config_request_body_t *ul_req_tmp = NULL; PHY_VARS_eNB *eNB_PHY = NULL; - struct rrc_eNB_ue_context_s *ue_context_pP = NULL; eNB_MAC_INST *eNB_MAC = RC.mac[mod_id]; - bool remove_UEContext; - rnti_t rnti; - int head, tail, ue_num; pthread_mutex_lock(&lock_ue_freelist); - head = eNB_MAC->UE_free_list.head_freelist; - tail = eNB_MAC->UE_free_list.tail_freelist; - if(head == tail) { - pthread_mutex_unlock(&lock_ue_freelist); - return; - } - - if(tail < head) { - tail = head + eNB_MAC->UE_free_list.num_UEs; - } - - pthread_mutex_unlock(&lock_ue_freelist); - - for(ue_num = head; ue_num < tail; ue_num++) { - ue_num = ue_num % (NUMBER_OF_UE_MAX+1); - rnti = eNB_MAC->UE_free_list.UE_free_ctrl[ue_num].rnti; + for(int ue_num = 0; ue_num < sizeofArray(eNB_MAC->UE_free_ctrl) ; ue_num++) { + rnti_t rnti = eNB_MAC->UE_free_ctrl[ue_num].rnti; if(rnti != 0) { - remove_UEContext = eNB_MAC->UE_free_list.UE_free_ctrl[ue_num].removeContextFlg; + protocol_ctxt_t ctxt; PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, mod_id, ENB_FLAG_YES, rnti, 0, 0,mod_id); - for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + for (int CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { eNB_PHY = RC.eNB[mod_id][CC_id]; int id; // clean ULSCH entries for rnti - id = find_ulsch(rnti,eNB_PHY,eNB_MAC->UE_free_list.UE_free_ctrl[ue_num].raFlag ? SEARCH_EXIST_RA : SEARCH_EXIST); + id = find_ulsch(rnti,eNB_PHY,eNB_MAC->UE_free_ctrl[ue_num].raFlag ? SEARCH_EXIST_RA : SEARCH_EXIST); if (id>=0) clean_eNb_ulsch(eNB_PHY->ulsch[id]); // clean DLSCH entries for rnti - id = find_dlsch(rnti,eNB_PHY,eNB_MAC->UE_free_list.UE_free_ctrl[ue_num].raFlag ? SEARCH_EXIST_RA : SEARCH_EXIST); + id = find_dlsch(rnti,eNB_PHY,eNB_MAC->UE_free_ctrl[ue_num].raFlag ? SEARCH_EXIST_RA : SEARCH_EXIST); if (id>=0) clean_eNb_dlsch(eNB_PHY->dlsch[id][0]); // clean UCI entries for rnti - for (i=0; iuci_vars[i].rnti == rnti) { LOG_I(MAC, "clean eNb uci_vars[%d] UE %x \n",i, rnti); memset(&eNB_PHY->uci_vars[i],0,sizeof(LTE_eNB_UCI)); } } - /* - for (i=0; iulsch[i]; - - if((ulsch != NULL) && (ulsch->rnti == rnti)) { - void clean_eNb_ulsch(LTE_eNB_ULSCH_t *ulsch); - LOG_I(RRC, "clean_eNb_ulsch ulsch[%d] UE %x\n", i, rnti); - clean_eNb_ulsch(ulsch); - } - - dlsch = eNB_PHY->dlsch[i][0]; - - if((dlsch != NULL) && (dlsch->rnti == rnti)) { - void clean_eNb_dlsch(LTE_eNB_DLSCH_t *dlsch); - LOG_I(RRC, "clean_eNb_dlsch dlsch[%d] UE %x \n", i, rnti); - clean_eNb_dlsch(dlsch); - } - } - - ulsch = eNB_PHY->ulsch[i]; - - if((ulsch != NULL) && (ulsch->rnti == rnti)) { - void clean_eNb_ulsch(LTE_eNB_ULSCH_t *ulsch); - LOG_I(RRC, "clean_eNb_ulsch ulsch[%d] UE %x\n", i, rnti); - clean_eNb_ulsch(ulsch); - } - - for (i=0; iuci_vars[i].rnti == rnti) { - LOG_I(MAC, "clean eNb uci_vars[%d] UE %x \n",i, rnti); - memset(&eNB_PHY->uci_vars[i],0,sizeof(LTE_eNB_UCI)); - } - } - */ - if (flexran_agent_get_rrc_xface(mod_id)) { - flexran_agent_get_rrc_xface(mod_id)->flexran_agent_notify_ue_state_change( - mod_id, rnti, PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_DEACTIVATED); + flexran_agent_get_rrc_xface(mod_id)->flexran_agent_notify_ue_state_change( mod_id, rnti, PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_DEACTIVATED); } - for(j = 0; j < 10; j++) { - ul_req_tmp = &eNB_MAC->UL_req_tmp[CC_id][j].ul_config_request_body; + for(int j = 0; j < 10; j++) { + nfapi_ul_config_request_body_t *ul_req_tmp = &eNB_MAC->UL_req_tmp[CC_id][j].ul_config_request_body; if(ul_req_tmp) { - pdu_number = ul_req_tmp->number_of_pdus; + int pdu_number = ul_req_tmp->number_of_pdus; for(int pdu_index = pdu_number-1; pdu_index >= 0; pdu_index--) { if((ul_req_tmp->ul_config_pdu_list[pdu_index].ulsch_pdu.ulsch_pdu_rel8.rnti == rnti) || @@ -1126,7 +1065,8 @@ void release_UE_in_freeList(module_id_t mod_id) { } if (!NODE_IS_CU(RC.rrc[mod_id]->node_type)) { - rrc_mac_remove_ue(mod_id,rnti); + if (!eNB_MAC->UE_free_ctrl[ue_num].raFlag) + rrc_mac_remove_ue(mod_id,rnti); rrc_rlc_remove_ue(&ctxt); pdcp_remove_UE(&ctxt); } else { @@ -1139,19 +1079,20 @@ void release_UE_in_freeList(module_id_t mod_id) { itti_send_msg_to_task(TASK_CU_F1, mod_id, m); } - if(remove_UEContext) { - ue_context_pP = rrc_eNB_get_ue_context(RC.rrc[mod_id],rnti); - + if(eNB_MAC->UE_free_ctrl[ue_num].removeContextFlg) { + struct rrc_eNB_ue_context_s *ue_context_pP = rrc_eNB_get_ue_context(RC.rrc[mod_id],rnti); if(ue_context_pP) { + LOG_I(PHY, "remove RNTI %04x\n", rnti); rrc_eNB_remove_ue_context(&ctxt,RC.rrc[mod_id], (struct rrc_eNB_ue_context_s *) ue_context_pP); } } - LOG_I(RRC, "[release_UE_in_freeList] remove UE %x from freeList\n", rnti); - remove_UE_from_freelist(mod_id, rnti); + LOG_I(RRC, "[release_UE_in_freeList] remove UE %x from freeList ra context: %d\n", rnti, eNB_MAC->UE_free_ctrl[ue_num].raFlag); + eNB_MAC->UE_free_ctrl[ue_num].rnti = 0; } } + pthread_mutex_unlock(&lock_ue_freelist); } int rrc_eNB_previous_SRB2(rrc_eNB_ue_context_t *ue_context_pP) { @@ -7246,6 +7187,7 @@ rrc_eNB_decode_ccch( LOG_I(RRC," S-TMSI exists, ue_context_p %p, old rnti %x => %x\n",ue_context_p,ue_context_p->ue_context.rnti,ctxt_pP->rnti); if (!NODE_IS_CU(RC.rrc[ctxt_pP->module_id]->node_type)) { + LOG_I(PHY, "remove RNTI %04x\n", ue_context_p->ue_context.rnti); rrc_mac_remove_ue(ctxt_pP->module_id, ue_context_p->ue_context.rnti); } else { MessageDef *m = itti_alloc_new_message(TASK_RRC_ENB, 0, F1AP_UE_CONTEXT_RELEASE_CMD); diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index a7a0d2de32..1d464cb90c 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -89,7 +89,7 @@ void prach_procedures(PHY_VARS_eNB *eNB,int br_flag); void stop_RU(RU_t **rup,int nb_ru); -void do_ru_synch(RU_t *ru); +static void do_ru_synch(RU_t *ru); void configure_ru(int idx, void *arg); @@ -1059,7 +1059,7 @@ int wakeup_synch(RU_t *ru) { } -void do_ru_synch(RU_t *ru) { +static void do_ru_synch(RU_t *ru) { LTE_DL_FRAME_PARMS *fp = ru->frame_parms; RU_proc_t *proc = &ru->proc; int rxs, ic, ret, i; @@ -1924,7 +1924,7 @@ static void *ru_thread( void *param ) { // This thread run the initial synchronization like a UE -void *ru_thread_synch(void *arg) { +static void *ru_thread_synch(void *arg) { RU_t *ru = (RU_t *)arg; __attribute__((unused)) LTE_DL_FRAME_PARMS *fp = ru->frame_parms; diff --git a/targets/RT/USER/lte-softmodem.h b/targets/RT/USER/lte-softmodem.h index 1c887dd3c8..38b71238b8 100644 --- a/targets/RT/USER/lte-softmodem.h +++ b/targets/RT/USER/lte-softmodem.h @@ -29,6 +29,7 @@ #include "flexran_agent.h" #include "s1ap_eNB.h" #include "SIMULATION/ETH_TRANSPORT/proto.h" +#include "targets/ARCH/COMMON/common_lib.h" #include "executables/softmodem-common.h" @@ -213,5 +214,19 @@ extern void init_UE_standalone_thread(int ue_idx); extern PHY_VARS_UE *init_ue_vars(LTE_DL_FRAME_PARMS *frame_parms, uint8_t UE_id, uint8_t abstraction_flag); extern void init_bler_table(void); - +void feptx_ofdm_2thread(RU_t *ru, + int frame, + int subframe); +void* ru_thread_control( void* param ); +void wait_eNBs(void); +void kill_feptx_thread(RU_t *ru); +void init_fep_thread(RU_t *ru, pthread_attr_t *attr_fep); +void init_feptx_thread(RU_t *ru, pthread_attr_t *attr_feptx); +void fep_full(RU_t *ru, int subframe); +void configure_ru(int, void *arg); +void configure_rru(int, void *arg); +void ru_fep_full_2thread(RU_t *ru,int subframe); +void feptx_ofdm(RU_t*ru, int frame_tx, int tti_tx); +void feptx_prec(struct RU_t_s *ru, int frame_tx, int tti_tx); +void fill_rf_config(RU_t *ru, char *rf_config_file); #endif diff --git a/targets/RT/USER/lte-uesoftmodem.c b/targets/RT/USER/lte-uesoftmodem.c index 678b6e0401..05602b63da 100644 --- a/targets/RT/USER/lte-uesoftmodem.c +++ b/targets/RT/USER/lte-uesoftmodem.c @@ -176,7 +176,6 @@ extern char uecap_xer[1024]; char uecap_xer_in=0; int oaisim_flag=0; -//threads_t threads= {-1,-1,-1,-1,-1,-1,-1,-1}; /* see file openair2/LAYER2/MAC/main.c for why abstraction_flag is needed * this is very hackish - find a proper solution