Compare commits

...

140 Commits

Author SHA1 Message Date
Bartosz Podrygajlo
8509be01d8 O-RU design document 2025-10-15 10:16:47 +02:00
Robert Schmidt
92bc0aee0e Merge branch 'integration_2025_w41' into 'develop'
Integration `2025.w41`

* !3472 Replace int16 min when obvious
* !3689 Fix OAI UE memory leaks
* !3675 fix RSRP computation at UE
* !3688 Fixes to prevent assertion due to 0 PRB allocation
* !3680 OC PhySim deployment: always undeploy safely
* !3471 SRS noise power
* !3679 CI: Enable Physim threshold check for tests on Caracal and GH
* reduce RFsim F1 throughput after handover

Closes #828

See merge request oai/openairinterface5g!3692
2025-10-09 17:15:02 +00:00
Robert Schmidt
ba8b23772e CI RFsim 5G F1: reduce DL iperf throughput
Reduce throughput requirement, as this fails once two DUs are connected
to a UE, which creates more load on the machine and frequently fails
with low throughput.
2025-10-09 08:48:26 +02:00
Robert Schmidt
dd868fd25e Merge remote-tracking branch 'origin/ci-update-physim-threshold' into integration_2025_w41 (!3679)
CI: Enable Physim threshold check for tests on Caracal and GH

This MR adds support for configurable timing threshold files in PhySim
tests.

- Introduces a new CMake cache variable PHYSIM_CHECK_FILES to specify
  one or more timing threshold files (semicolon-separated).
- Enables optional enforcement of timing thresholds check in PhySim
  tests without changing existing test definitions.
- Defines timing thresholds for LDPC encoding/decoding in nr_ulsim,
  nr_dlsim and ldpctest on Caracal and GH machines.
2025-10-09 08:46:46 +02:00
Robert Schmidt
1ffa012014 Merge remote-tracking branch 'origin/SRS-noise-power' into integration_2025_w41 (!3471)
SRS noise power

This MR implements the calculation of the noise power based on SRS in a
different way, and check whether SNR is more accurate or not. This MR is
built on top of the MR: !3460

A graph was added in T_Tracer to observe UL-SNR calculated using SRS.

See merge request description for measurement results.
2025-10-09 08:45:14 +02:00
Jaroslava Fiedlerova
6843625615 Add separate XML file for PhySim with timing check on GH 2025-10-08 19:45:14 +02:00
Jaroslava Fiedlerova
5ec7bcdcd2 Add timing check for physim tests on GraceHopper
Update Dockerfile to pass -DPHYSIM_CHECK_FILES="ThresholdsGracehopper.cmake".
2025-10-08 19:45:14 +02:00
Jaroslava Fiedlerova
bcc616e654 Increase timeout for physim deployments
Extend the timeout for physim deployments on OC to allow tests to complete
reliably.
2025-10-08 19:45:14 +02:00
Jaroslava Fiedlerova
31af716ccb Update timing thershold for offload tests on Caracal 2025-10-08 19:45:14 +02:00
Jaroslava Fiedlerova
ec8efe1b7e Unify physim test definition
Replace the previous add_timed_physim_test() macro with add_physim_test()
to use a single, unified function for defining physim tests. This simplifies
the test configuration and removes redundant macro definitions while keeping
all existing functionality.

This change follows up on the earlier addition of support for including
custom timing threshold files (PHYSIM_CHECK_FILES).

Update existing tests accordingly.
2025-10-08 19:45:14 +02:00
Jaroslava Fiedlerova
8910406a9e Add support for including custom timing threshold files in physim tests
Introduce a new CMake variable PHYSIM_CHECK_FILES to specify CMake files
(semicolon-separated) containing timing thresholds for timed physim tests.
2025-10-08 19:44:35 +02:00
Jaroslava Fiedlerova
78d91db964 Include timing analysis file in physim.rhel9 image
Add missing timinig analysis scripts to RHEL9 physim docker image. These files
are now copied from the build stage to /oai-ran/openair1/SIMULATION/tests/,
where they are expected by ctest.

Resolves following issue when running ctest in docker container:
CMake Error: Error processing file: /oai-ran/openair1/SIMULATION/tests/RunTimedTest.cmake
2025-10-08 10:57:50 +02:00
Robert Schmidt
a3ac1dbdfe analyze-timing.sh: check only last measurement occurrence
For some physical simulators, we have multiple SNR iterations.

The previous version of the script correctly retained only the last
measurement, but if a previous measurement condition set RC=1, the
script would fail although the final "good" run might fulfil the
measurement condition (IOW, it would show SUCCESS, but still fail on the
check).

Instead, check if all measurement lines finish on SUCCESS, which handles
the above case.
2025-10-08 10:57:50 +02:00
Robert Schmidt
b012700fe4 Fix analyze-timing.sh for mawk compatibility
The awk script in analyze-timing.sh used syntax that works with gawk but fails
on systems where mawk is the default implementation, producing errors such as:

awk: /dev/fd/3: line 6: syntax error at or near ,
-- test command finished with SIGPIPE

Concretely, the match(text, pattern, variable) function does not exist
in mawk, as it cannot capture matches in variables. Work around by
substituing strings, and force a numeric comparison.
2025-10-08 10:57:50 +02:00
Jaroslava Fiedlerova
ddf81a175c Merge remote-tracking branch 'origin/physim-deploy-failsafe' into integration_2025_w41 (!3680)
OC PhySim deployment: always undeploy safely

Always undeploy physim safely. See commits for more details
2025-10-08 08:46:03 +02:00
Jaroslava Fiedlerova
98fea81b39 Merge remote-tracking branch 'origin/fix_0_tbs' into integration_2025_w41 (!3688)
Fixes to prevent assertion due to 0 PRB allocation

Assertion (NPRB>0 && (NPRB + RBstart <= BWPsize)) failed!
In PRBalloc_to_locationandbandwidth0() /home/user/openairinterface5g/common/utils/nr/nr_common.c:506
Illegal NPRB/RBstart Configuration (0,51) for BWPsize 51

Probably caused by missing safeguards to prevent computing TBS with 0 PRB
as input.
2025-10-08 08:43:49 +02:00
Jaroslava Fiedlerova
7459e73277 Merge remote-tracking branch 'origin/fix-ue-mem-leaks' into integration_2025_w41 (!3689)
Fix OAI UE memory leaks

Fix 1: Replaced asn1cFreeStruc with ASN_STRUCT_FREE in MAC layer to properly
       free nested ASN.1 structures in cell group configuration.
Fix 2: Removed premature nullification of dedicatedNAS_Message->buf in
       dlInformationTransfer processing to allow proper ASN.1 cleanup.
Fix 3: Fixed memory ownership in nr_rrc_process_dedicatedNAS_MessageList by
       copying OCTET_STRING data instead of transferring ownership, preventing
       ASN.1 cleanup from losing track of allocated memory

Closes #828
2025-10-07 14:33:15 +02:00
Jaroslava Fiedlerova
2424c182d6 Merge remote-tracking branch 'origin/fix_rsrp_ue' into integration_2025_w41 (!3675)
fix RSRP computation at UE

Conflicts between !3595 (merged) and !3596 (merged) leading to double conversion
of RSRP into index in L1 and L2. With this fix it is only converted in L2.
2025-10-07 14:32:35 +02:00
Jaroslava Fiedlerova
b3007ce55b Merge remote-tracking branch 'origin/replace-INT16_MIN-when-obvious' into integration_2025_w41 (!3472)
Replace int16 min when obvious

INT16_MIN doesn't have a opposite value on 16 bits, so SIMD abs (absolute()), or
simple C operations doesn't make the expected result.

example:
(gdb) p (short)-(short)-32768
$4 = -32768
(gdb)

This MR replaces constants INT16_MIN by -INT16_MAX (so -32767) in places where
it used for mathematical operations. This is not perfect, nevertheless reduces
overflow probability.
We saw in some places a dirty case: code do first calls to _mm_adds_epi16
(or subs), so because of the saturated operations, the probability to reach
32767 and -32768 is higher than the other numbers but, _mm_abs_epi16(), or
negate operations (conjugate) can follow, that is making strong error as
abs(-32768)=-32768
2025-10-07 14:27:30 +02:00
Jaroslava Fiedlerova
bd1dadaa79 OC PhySim deployment: log bash script commands
Also, don't use "set -x" debugging for oc login command:
ci-scripts/cls_cmd.py:242 sets BASH_XTRACEFD=1, which makes that all
"set -x" output is in stdout, leading to a redirect to the file into
which we redirect. This would lead to the following error with
unsuccessfull oc login:

  error: You are not a member of project "****-core-for-ci-ran".
  Error from server (Forbidden): imagestreams.image.openshift.io "oai-physim"
  is forbidden: User "system:anonymous" cannot get resource "imagestreams" in
  API group "image.openshift.io" in the namespace "****-ran"
2025-10-07 08:09:20 +02:00
Robert Schmidt
958fe1ed75 OC PhySim deployment: always undeploy safely
This fixes basically two problems. First, remove "set -e", which leads
to the script exiting on error. For instance, there was the sleep which
should account for the time of the pod being in "ContainerCreating", but
might not be enough. In that case, the script would exit, leaving the
pod deployed.

Second, a fixed time is not good, as it can be too short and unduly
prolong waiting time. Replace with a loop.
2025-10-06 16:16:39 +02:00
francescomani
8411a428db prevent faulty behavior of nr_compute_tbs when null input is not producing TBS = 0 2025-10-06 11:10:38 +02:00
Guido Casati
d6047cd83d Fix memory leak in dlInformationTransfer case
- Remove unnecessary NULL assignment for dedicatedNAS_Message->buf
- The original buffer is copied and transfered to NAS, so it can be properly freed by ASN.1 structure cleanup

Root cause: Code was nullifying dedicatedNAS_Message->buf pointer before ASN.1 cleanup could free the original allocation, causing the leak from OCTET_STRING_decode_uper.

AddressSanitizer leak trace (FIXED):
Direct leak of 119 byte(s) in 3 object(s) allocated from:
    /#0 0x7ec2a42b4c38 in __interceptor_realloc
    /#1 0x555fade852e0 in OCTET_STRING_decode_uper
    /#9 0x555fadb48b11 in nr_rrc_ue_decode_dcch.
2025-10-03 12:39:14 +02:00
Guido Casati
9639cbb436 Fix memory leak in nr_rrc_process_dedicatedNAS_MessageList
The leak was caused by improper memory ownership handling in the
dedicatedNAS_MessageList processing. The function was transferring
buffer ownership to NAS messages and then preventing ASN.1 cleanup
from freeing the original allocations by setting
list.count = 0, causing a memory leak.

Leak trace:
Direct leak of 40 byte(s) in 1 object(s) allocated from:
    /#0 0x7f2ce3ab4a57 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154
    /#1 0x567907083f0f in OCTET_STRING_decode_uper /cmake_targets/ran_build/build/openair2/RRC/LTE/MESSAGES/OCTET_STRING_uper.c:89
    /#2 0x5679070ed5e6 in SET_OF_decode_uper /cmake_targets/ran_build/build/openair2/RRC/NR/MESSAGES/constr_SET_OF_uper.c:70
    /#3 0x56790707b6dc in SEQUENCE_decode_uper /cmake_targets/ran_build/build/openair2/RRC/LTE/MESSAGES/constr_SEQUENCE_uper.c:118
    /#4 0x56790707b6dc in SEQUENCE_decode_uper /cmake_targets/ran_build/build/openair2/RRC/LTE/MESSAGES/constr_SEQUENCE_uper.c:118
    /#5 0x56790709a403 in CHOICE_decode_uper /cmake_targets/ran_build/build/openair2/RRC/LTE/MESSAGES/constr_CHOICE_uper.c:84
    /#6 0x56790707b6dc in SEQUENCE_decode_uper /cmake_targets/ran_build/build/openair2/RRC/LTE/MESSAGES/constr_SEQUENCE_uper.c:118
    /#7 0x56790709a403 in CHOICE_decode_uper /cmake_targets/ran_build/build/openair2/RRC/LTE/MESSAGES/constr_CHOICE_uper.c:84
    /#8 0x56790709a403 in CHOICE_decode_uper /cmake_targets/ran_build/build/openair2/RRC/LTE/MESSAGES/constr_CHOICE_uper.c:84
    /#9 0x56790707b6dc in SEQUENCE_decode_uper /cmake_targets/ran_build/build/openair2/RRC/LTE/MESSAGES/constr_SEQUENCE_uper.c:118
    /#10 0x56790708b5f1 in uper_decode /cmake_targets/ran_build/build/openair2/RRC/LTE/MESSAGES/uper_decoder.c:83
    /#11 0x567906d44b4b in nr_rrc_ue_decode_dcch /openair2/RRC/NR_UE/rrc_UE.c:2212
    /#12 0x567906d520a3 in rrc_nrue /openair2/RRC/NR_UE/rrc_UE.c:2615
    /#13 0x567906d5f77e in rrc_nrue_task /openair2/RRC/NR_UE/rrc_UE.c:2501
    /#14 0x7f2ce2494ac2 in start_thread nptl/pthread_create.c:442

Fix:
- Copy OCTET_STRING data instead of transferring ownership
- Allow ASN.1 cleanup to properly free original allocations

This fixes the leak that occurred during rrcReconfiguration
message processing when dedicatedNAS_MessageList was present.

Closes #828
2025-10-03 12:35:12 +02:00
Guido Casati
9086fb63de Fix memory leak in nr_rrc_ue_process_masterCellGroup
- Replace asn1cFreeStruc with ASN_STRUCT_FREE in MAC layer cleanup
- Fixes improper memory management of NR_CellGroupConfig structures

Root cause: asn1cFreeStruc only calls ASN_STRUCT_RESET + free(), which doesn't properly free nested ASN.1 allocations. ASN_STRUCT_FREE frees all nested structures completely.

AddressSanitizer leak trace:
Direct leak of 288 byte(s) in 1 object(s) allocated from:
    /#0 0x7fb72bab4a57 in __interceptor_calloc
    /#1 0x593752b28d0d in SEQUENCE_decode_uper
    /#2 0x593752b9a546 in SET_OF_decode_uper
    /#3 0x593752b2863c in SEQUENCE_decode_uper
    /#4 0x593752b47363 in CHOICE_decode_uper
    /#5 0x593752b2863c in SEQUENCE_decode_uper
    /#6 0x593752b2863c in SEQUENCE_decode_uper
    /#7 0x593752b2863c in SEQUENCE_decode_uper
    /#8 0x593752b2863c in SEQUENCE_decode_uper
    /#9 0x593752b2863c in SEQUENCE_decode_uper
    /#10 0x593752b38551 in uper_decode
    /#11 0x5937527d859f in nr_rrc_ue_process_masterCellGroup
    /#12 0x5937527d9408 in nr_rrc_process_reconfiguration_v1530
    /#13 0x5937527dd5bb in nr_rrc_ue_process_rrcReconfiguration
    /#14 0x5937527f5e6b in nr_rrc_ue_decode_dcch
    /#15 0x5937527ff003 in rrc_nrue
    /#16 0x59375280c6de in rrc_nrue_task
2025-10-03 10:38:38 +02:00
Laurent THOMAS
7355b55ad1 this MR replaces constants INT16_MIN by -INT16_MAX (so -32767) in places where it used for mathematical operations 2025-10-03 10:02:48 +02:00
francescomani
42b6576d81 fix RSRP computation at UE (let the higher layers compute the index) 2025-10-03 08:42:41 +02:00
rmagueta
8ca05e51ac Added graph in T_Tracer to observe UL-SNR calculated using SRS 2025-10-02 11:43:07 +01:00
rmagueta
799934024e SRS-based noise calculation using holes 2025-10-02 11:43:07 +01:00
Jaroslava Fiedlerova
55a56002de Merge branch 'integration_2025_w40' into 'develop'
Integration: `2025.w40`

* !3672 \[ci\] Fix MissingPropertyException - COTS-UE by binding OAI_Registry globally
* !3609 BWP with no PRACH occasions
* !3657 do not assert for mismatched TBS in phy-test mode
* !3667 CI: Updates for HO and AW2S pipeline
* !3674 NR UE: remove function get_nr_RSRP() and get_nr_rx_total_gain_dB() for cleanup
* !3478 NR UE: add UCI (HARQ-ACK/NACK) on PUSCH support at PHY
* !3664 modulation LUTs size was wrong, and remove inconsistent test of SSE2 enable
* !3665 Make all targets compile
* !3554 Handle failures in RRCReconfiguration encoding gracefully
* !3655 Improvements to N2 handover
* !3678 Add OAIUE longrun pipeline
* !3628 Update documentation

Closes #979, #726, #959, #967, and #930

See merge request oai/openairinterface5g!3676
2025-10-02 08:43:12 +00:00
Robert Schmidt
97185a6921 Merge remote-tracking branch 'origin/update_documentation' into integration_2025_w40 (!3628)
Update documentation
2025-10-01 22:28:38 +02:00
Robert Schmidt
5047bacd6d Merge remote-tracking branch 'origin/oaiue_longrun' into integration_2025_w40 (!3678)
Add OAIUE longrun pipeline

Add a new XML file for OAIUE longrun.

- Test description:
  * 40 MHz BW, n78
  * gNB with USRP N310, UE with USRP N310
  * CN deployed on OC
- Test duration: 1 hour
- Test scenario: 3x DL 10 min test (20 Mbps) + 3x UL 10 min test (5
  Mbps)
2025-10-01 22:21:13 +02:00
Robert Schmidt
7eb33a4003 Workaround: give pod deployment more time
pods deployed through helm occasionally take more time, leading to
errors such as

    Error from server (BadRequest): container "physim" in pod "oai-physims-4g-sczvl" is waiting to start: ContainerCreating

Give a bit more time before checking the logs. We cannot wait too much,
as the container will just end on FINISHED in running state, so the logs
will always be there.
2025-10-01 22:13:50 +02:00
Jaroslava Fiedlerova
3e5681abbd Merge remote-tracking branch 'origin/n2-handover-minor-fixes' into integration_2025_w40 (!3655)
The goal of this MR is to resolve memory leaks, prevent crashes, and improve code quality.

Bug Fixes:
- Fix crash in get_du_for_ue when F1 UE data doesn't exist during N2 handover
- Fix memory leaks in handover preparation and UE context cleanup
- Fix duplicate handover request handling with proper UE context validation

Code Quality Improvements:
- Prevent ASN.1 double-free bug in NGAP memory management (caller ownership
  principle)
- Fix hardcoded instance 0 bug in UE context release command
- Refactor e1_send_bearer_updates into three specialized functions with
  extracted common code
- Replace impossible ID mismatch checks with DevAssert statements
- Fix inconsistent equality checking patterns in E1AP bearer context management
- Improve error message consistency across NGAP handover functions
- Optimize PLMN identity assignment using struct copies

Documentation Enhancements:
- Improve RRC neighbor configuration documentation with actual parameter names
- Add same-machine setup guidance for N2 handover with network configuration
  notes
- Fix grammar errors and standardize naming conventions

Follow up to !3334 (merged)
2025-10-01 18:08:28 +02:00
calvin_peyron
8fcea7c314 Update UL_MIMO documentation 2025-10-01 16:22:46 +02:00
calvin_peyron
23e0f50af0 Change D2D emulator documentation format 2025-10-01 16:22:46 +02:00
calvin_peyron
2dd72d40cb Put documentation images in right folder 2025-10-01 16:22:46 +02:00
calvin_peyron
e7a45a304b Remove unused and outdated documentation 2025-10-01 16:22:46 +02:00
calvin_peyron
2d2f61f253 Fix link in rrc-usage.md 2025-10-01 16:22:46 +02:00
calvin_peyron
aa323b02f2 Fix link in mac-usage.md 2025-10-01 16:22:46 +02:00
calvin_peyron
0721c0fad0 Fix image link inside F1AP-lib.md 2025-10-01 16:22:46 +02:00
calvin_peyron
25918898a7 Update F1-design.md 2025-10-01 16:22:46 +02:00
calvin_peyron
acd3634d27 Update E1-design.md 2025-10-01 16:22:46 +02:00
Laurent THOMAS
a0d8baf323 update and rename TESTING_GNB_W_COTS_UE.md to describe actual content 2025-10-01 16:22:46 +02:00
calvin_peyron
2ea4cbbd93 update env variable usage documentation 2025-10-01 16:22:40 +02:00
Jaroslava Fiedlerova
8348f83a1f Merge remote-tracking branch 'origin/issue-979' into integration_2025_w40 (!3554)
Handle failures in RRCReconfiguration encoding gracefully

Closes #979
2025-10-01 14:51:43 +02:00
Jaroslava Fiedlerova
5adfeb80c3 Merge remote-tracking branch 'origin/make-all-targets-compile' into integration_2025_w40 (!3665)
Make all targets compile

This MR enables us to compile all targets, and does that in one CI test. This
closes #726. Now, this should work:

cd ~/openairinterface5g
mkdir build && cd build
cmake .. -GNinja && ninja

To achieve this, I did the following:
- some targets have been fixed (warnings, errors)
- some targets have been removed when they did not seem to serve a good purpose
  (e.g., an almost empty test)
- some targets have been commented (e.g., LTE simulators, some unitary tests)
  which we maybe want to revive in the future
- some targets built when just building with ninja, but not all. For instance,
  telnetsrv_enb would typically build, but it was missing a dependency. Doing
  cmake .. -GNinja && ninja telnetsrv_enb would show this (in develop)

To help with the last bullet point, there is a script compile_targets.sh that
can compile targets independently (and in parallel, to not wait for ages) to
show that targets compile properly compile-targets.patch.

In almost all cases, the problem is that a specific module uses the logging
module, which depends on T, which needs to dynamically create headers. The way
to do this is to have a dependency, and many targets use generate_T or {T_LIB}
({} intentional: T might be absent, so then it evaluates to nothing). However,
not all do this, and those that depend on T actually don't depend on T, but on
the logging module, which in turn depends on T. So in many places, a simple
dependency onto log_headers fixes this problem, and generate_T or {T_LIB}
simplifies the dependency (but not always). The commits should have more info.

Note that at least the targets in FlexRIC do not all compile, at least in the
configuration that we use in docker/Dockerfile.build.ubuntu. So for the latter,
we cannot build with a simple ninja, but FlexRIC seems to be the only one that
does not compile. Since FlexRIC is a separate repository, that needs to be
addressed in the corresponding repository.
2025-10-01 14:48:45 +02:00
Jaroslava Fiedlerova
2dde472cfd Adjust gNB conf file in OAIUE test
Increase prach_dtx_threshold to avoid fake PRACH detection.
2025-10-01 13:36:53 +02:00
Jaroslava Fiedlerova
7935c19d21 Fix in CreateWorkspace
Previously, the script attempted to directly merge ${merge}, which could f
ail if the branch was not already available locally. This update explicitly
fetches the branch from origin and then merges FETCH_HEAD with --ff, ensuring
the merge works even when the branch is missing locally.
2025-10-01 13:36:53 +02:00
Jaroslava Fiedlerova
6193d7c7f4 Create XML for OAIUE longrun pipeline
Test duration: 1 hour
Test scenario: 3x DL 10 min test (20 Mbps) + 3x UL 10 min test (5 Mbps)
2025-10-01 13:36:49 +02:00
Guido Casati
dcb10ffc94 Handover tutorial: fix minor issues and add same-machine setup guidance
- Update opening statement to reflect both F1 (intra-gNB) and N2 (inter-gNB) handover support
- Fix grammar error: 'either by by decision' -> 'either a decision'
- Standardize naming: 'gNB PCI1' -> 'gNB-PCI1'
- Fix typo: 'neighbor call' -> 'neighbor cell'
- Remove --sa flag from N2 handover target gNB command for consistency
- Add network configuration notes for same-machine setups:
  * IP address assignment instructions to avoid network conflicts
  * Target gNB command options for proper network interface configuration
2025-10-01 11:36:22 +02:00
Guido Casati
dcd7ee711b Improve RRC neighbor configuration documentation
- Move 'What is a gNB neighbor?' explanation from rrc-usage.md to handover-tutorial.md where it belongs
- Replace generic parameter names with actual configuration parameter names and specific descriptions (e.g. gNB_ID, nr_cellid)
- Add example configuration structure showing proper syntax
- Add missing 'band' parameter that was not listed before
- Provide concrete examples and exact constraints for each parameter
- Cross-reference between documents for better organization

This addresses documentation issues where generic parameter descriptions were
not useful for developers configuring neighbor cells.
2025-10-01 11:36:22 +02:00
Guido Casati
4aafd1e369 Simplify N2 handover test to focus on N2 handover only
- Remove extensive traffic testing before HO (iperf tests 030001, 030002)
- Do 1 ping test after attachment
- Reduce ping packet count from 100 to 50 packets for remaining connectivity test

Time savings: ~2-3 minutes by removing traffic validation overhead
2025-10-01 11:36:22 +02:00
Guido Casati
9d9f272e74 Refactor: split e1_send_bearer_updates into specialized functions
Split monolithic e1_send_bearer_updates into three focused functions:
- e1_send_bearer_updates(): DRB setup from F1 UE Context Modification Response
- e1_request_pdcp_status(): Request PDCP status during inter-CU handover
- e1_notify_pdcp_status(): Notify CU-UP with PDCP status during handover

Extract common helpers:
- append_e1_drb_mod_req(): Common DRB-to-mod for bearer request logic
- e1_send_bearer_modification_request(): Common sending step

Bug fixes:
- Fix loop bounds (i < n instead of i == n)
- Fix array access bounds checking
- Fix DRB ID consistency

Memory management:
- Add missing free_e1ap_context_mod_request calls
- Improve error handling with early returns

In the process:
- Simplify cuup_notify_reestablishment with FOR_EACH_SEQ_ARR loop
- Adopted all callers to use new consolidated functions

Improves maintainability and eliminates complex conditional logic.
2025-10-01 11:36:22 +02:00
Guido Casati
205bf7c993 Add NULL check for DU lookup in handover notify
Add early return if get_du_by_cell_id returns NULL to prevent
segmentation fault when accessing DU structure members.
2025-10-01 11:36:22 +02:00
Guido Casati
1fc057cb08 Optimize PLMN identity assignment in handover procedures
Replace field-by-field assignment with struct copy for plmn_identity.
Both source and destination use identical plmn_id_t type, making
this change safe and more maintainable.

- Reduces lines of code
- More readable and less error-prone
- Single memory copy operation instead of multiple field assignments
2025-10-01 11:36:22 +02:00
Guido Casati
c6a06dc81f Improve error message consistency in NGAP handover functions
- ngap_gNB_handover_notify: Fix misleading error message from 'Failed to encode'
  to 'Failed to find UE context' for better clarity
- ngap_gNB_handle_ul_ran_status_transfer: Standardize error message format
  from 'Could not find' to 'Failed to find' for consistency across functions

This ensures consistent and accurate error reporting across all NGAP handover functions.
2025-10-01 11:36:22 +02:00
Guido Casati
0cbed89b03 Replace malloc_or_fail with calloc_or_fail for safer memory allocation
- Update encoder functions in ngap_gNB_mobility_management.c to use calloc_or_fail
- Provides zero-initialized memory and consistent error handling
- Prevents uninitialized fields and improves memory safety

Also:

- Update NG Setup Request to use calloc_or_fail
2025-10-01 11:36:22 +02:00
Guido Casati
3e8354727e Remove redundant NULL checks for handover encoder functions
Handoer encoder functions never return NULL - they either return
a valid pointer or terminate the program. Remove dead code paths.
2025-10-01 11:36:22 +02:00
Guido Casati
c2e8743a7b Optimize create_measgap_config to eliminate unnecessary allocation
- Replace inefficient 'allocate, extract, free' pattern with direct value extraction
- Remove unused functions get_gap_config_from_smtc() and get_gap_config()
- Add extract_gap_config_from_smtc() that extracts values directly without allocation
- Eliminates use-after-free risk and improves performance
- No allocation overhead, no memory leaks
2025-10-01 11:36:22 +02:00
Guido Casati
feea066c3f Fix measurement gap config memory leak in create_measgap_config
- Add missing ASN_STRUCT_FREE for NR_MeasGapConfig in create_measgap_config
- Fix 48-byte measurement gap config leak in get_gap_config_from_smtc

AddressSanitizer backtrace:
Direct leak of 48 byte(s) in 1 object(s) allocated from:
    /#0 0x7d32adab4a57 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154
    /#1 0x5751f99cbb79 in calloc_or_fail /home/guido/repo/openairinterface5g/develop/common/utils/utils.h:74
    /#2 0x5751f99cbb79 in get_gap_config_from_smtc /home/guido/repo/openairinterface5g/develop/openair2/LAYER2/NR_MAC_gNB/nr_radio_config.c:4164
    /#3 0x5751f99cbb79 in create_measgap_config /home/guido/repo/openairinterface5g/develop/openair2/LAYER2/NR_MAC_gNB/nr_radio_config.c:4310
    /#4 0x5751f9964abe in ue_context_setup_request /home/guido/repo/openairinterface5g/develop/openair2/LAYER2/NR_MAC_gNB/mac_rrc_dl_handler.c:709
    /#5 0x5751f979e568 in nr_initiate_handover /home/guido/repo/openairinterface5g/develop/openair2/RRC/NR/rrc_gNB_mobility.c:218
    /#6 0x5751f97a637f in nr_rrc_trigger_n2_ho_target /home/guido/repo/openairinterface5g/develop/openair2/RRC/NR/rrc_gNB_mobility.c:526
    /#7 0x5751f9703608 in rrc_gNB_process_e1_bearer_context_setup_resp /home/guido/repo/openairinterface5g/develop/openair2/RRC/NR/rrc_gNB.c:2641
    /#8 0x5751f9706b7b in rrc_gnb_task /home/guido/repo/openairinterface5g/develop/openair2/RRC/NR/rrc_gNB.c:3020
    /#9 0x7d32ac494ac2 in start_thread nptl/pthread_create.c:442

Root cause: create_measgap_config allocated NR_MeasGapConfig via get_gap_config_from_smtc()
but never freed it after extracting the needed values to populate the measgap_config_t
return structure.
2025-10-01 11:36:22 +02:00
Guido Casati
5e3b4c497c Refactor handover context cleanup and fix memory leak in N2 handover source gNB path
- Add missing handover context cleanup in rrc_CU_process_ue_context_release_complete
- Fix 16-byte handover context leak in N2 handover source gNB trigger path

AddressSanitizer backtrace:
Direct leak of 16 byte(s) in 1 object(s) allocated from:
    /#0 0x7fee67cb4a57 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154
    /#1 0x58059e33454b in calloc_or_fail /home/guido/repo/openairinterface5g/develop/common/utils/utils.h:74
    /#2 0x58059e33454b in alloc_ho_ctx /home/guido/repo/openairinterface5g/develop/openair2/RRC/NR/rrc_gNB_mobility.c:47
    /#3 0x58059e339e4d in nr_rrc_trigger_n2_ho /home/guido/repo/openairinterface5g/develop/openair2/RRC/NR/rrc_gNB_mobility.c:556
    /#4 0x58059e33ae93 in nr_HO_N2_trigger_telnet /home/guido/repo/openairinterface5g/develop/openair2/RRC/NR/rrc_gNB_mobility.c:611

Root cause: Handover context allocated in N2 handover source gNB trigger path (nr_rrc_trigger_n2_ho)
for any successful N2 handover but not properly freed in all handover completion scenarios.
The UE context release complete handler was missing cleanup for handover context.

Solution: refactor handover context cleanup

- Move nr_rrc_finalize_ho() call to rrc_delete_ue_data() for centralized cleanup
- Remove redundant nr_rrc_finalize_ho() calls from handover failure paths:
  * rrc_CU_process_ue_context_release_request() - UE not deleted yet
  * invalidate_du_connections() - UE will be deleted later
- Keep nr_rrc_finalize_ho() calls in handover success paths where UE continues operating
- Ensures handover context is cleaned up exactly once when UE is actually deleted
- Prevents potential double-free and use-after-free issues in handover cleanup

This centralizes all UE data cleanup in rrc_delete_ue_data() and ensures
handover context is properly managed throughout the UE lifecycle and cleaned up
when UE delete happens.
2025-10-01 11:36:22 +02:00
Jaroslava Fiedlerova
7c82312b6d Merge remote-tracking branch 'origin/fix-modulation-luts-size' into integration_2025_w40 (!3664)
modulation LUTs size was wrong, and remove inconsistent test of SSE2 enable
2025-09-30 17:38:09 +02:00
Jaroslava Fiedlerova
3277018fce Merge remote-tracking branch 'origin/uci_on_pusch_phy' into integration_2025_w40 (!3478)
NR UE: add UCI (HARQ-ACK/NACK) on PUSCH support at PHY

Add UCI (HARQ-ACK/NACK) on PUSCH support at nrUE PHY, the multiplexing procedure
can be found in TS 38.212 section 6.2.7.

Verified with 3rd-pary gNB for cases when HARQ payload bits length is 1, 2 or 3.

Closes #959 and #967 .
2025-09-30 17:37:01 +02:00
Jaroslava Fiedlerova
3e79774386 Enable DLSCH performance logging in nr_dlsim 2025-09-30 14:03:20 +02:00
Jaroslava Fiedlerova
ff3245ea90 Enable ULSCH performance logging in nr_ulsim 2025-09-30 14:03:20 +02:00
Guido Casati
915c41c127 Fix MTC sequence memory leak in UE context setup
- Add missing ASN_STRUCT_FREE for NR_MeasurementTimingConfiguration in ue_context_setup_request
- Fix 64-byte MTC sequence leak in get_nr_mtc → SEQUENCE_decode_uper

AddressSanitizer backtrace:
Direct leak of 64 byte(s) in 1 object(s) allocated from:
    /#0 0x7dcfcb8b4a57 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154
    /#1 0x591fcc59b67d in SEQUENCE_decode_uper /home/guido/repo/openairinterface5g/develop/cmake_targets/ran_build/build/openair2/RRC/LTE/MESSAGES/constr_SEQUENCE_uper.c:37
    /#2 0x591fcc57eaa1 in uper_decode /home/guido/repo/openairinterface5g/develop/openair2/RRC/LTE/MESSAGES/uper_decoder.c:83
    /#3 0x591fcbdbedeb in get_nr_mtc /home/guido/repo/openairinterface5g/develop/openair2/LAYER2/NR_MAC_gNB/nr_radio_config.c:4216
    /#4 0x591fcbd58188 in ue_context_setup_request /home/guido/repo/openairinterface5g/develop/openair2/LAYER2/NR_MAC_gNB/mac_rrc_dl_handler.c:635
    /#5 0x591fcbb92568 in nr_initiate_handover /home/guido/repo/openairinterface5g/develop/openair2/RRC/NR/rrc_gNB_mobility.c:218
    /#6 0x591fcbb9a37f in nr_rrc_trigger_n2_ho_target /home/guido/repo/openairinterface5g/develop/openair2/RRC/NR/rrc_gNB_mobility.c:526
    /#7 0x591fcbaf7608 in rrc_gNB_process_e1_bearer_context_setup_resp /home/guido/repo/openairinterface5g/develop/openair2/RRC/NR/rrc_gNB.c:2640
    /#8 0x591fcbafab7b in rrc_gnb_task /home/guido/repo/openairinterface5g/develop/openair2/RRC/NR/rrc_gNB.c:3019
    /#9 0x7dcfca294ac2 in start_thread nptl/pthread_create.c:442

Root cause: ue_context_setup_request allocated NR_MeasurementTimingConfiguration via
get_nr_mtc() but never freed it after creating the measurement gap configuration.
The create_measgap_config function only reads from the structure and doesn't take
ownership, so the caller must free it.
2025-09-30 11:48:53 +02:00
Guido Casati
487de67ff8 Fix measurement configuration memory leak with stack allocation
- Replace heap allocation with stack allocation for seq_arr_t structures
- Use proper seq_arr_free() with free functions for ASN.1 structures
- Remove unnecessary malloc/free calls for sequence containers
- Improve memory safety and performance with automatic cleanup

Fixes 128-byte memory leak:

Direct leak of 128 byte(s) in 2 object(s) allocated from:
   /#0 0x7e7f39ab4a57 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154
   /#1 0x56df8b07312d in SEQUENCE_decode_uper /home/guido/repo/openairinterface5g/develop/cmake_targets/ran_build/build/openair2/RRC/LTE/MESSAGES/constr_SEQUENCE_uper.c:37
   /#2 0x56df8b056551 in uper_decode /home/guido/repo/openairinterface5g/develop/cmake_targets/ran_build/build/openair2/RRC/LTE/MESSAGES/uper_decoder.c:83
   /#3 0x56df8a896b1b in get_nr_mtc /home/guido/repo/openairinterface5g/develop/openair2/LAYER2/NR_MAC_gNB/nr_radio_config.c:4216
   /#4 0x56df8a82feb8 in ue_context_setup_request /home/guido/repo/openairinterface5g/develop/openair2/LAYER2/NR_MAC_gNB/mac_rrc_dl_handler.c:635
   /#5 0x56df8a66a298 in nr_initiate_handover /home/guido/repo/openairinterface5g/develop/openair2/RRC/NR/rrc_gNB_mobility.c:218
   /#6 0x56df8a6720af in nr_rrc_trigger_n2_ho_target /home/guido/repo/openairinterface5g/develop/openair2/RRC/NR/rrc_gNB_mobility.c:526
   /#7 0x56df8a5cf338 in rrc_gNB_process_e1_bearer_context_setup_resp /home/guido/repo/openairinterface5g/develop/openair2/RRC/NR/rrc_gNB.c:2633
   /#8 0x56df8a5d28ab in rrc_gnb_task /home/guido/repo/openairinterface5g/develop/openair2/RRC/NR/rrc_gNB.c:3012
   /#9 0x7e7f38494ac2 in start_thread nptl/pthread_create.c:442
2025-09-30 11:48:53 +02:00
Guido Casati
59803e221f Fix duplicate handover request handling
- Add early check for existing UE context by AMF UE NGAP ID at beginning of rrc_gNB_process_Handover_Request
- Add dedicated function to get UE context by AMF UE NGAP ID: rrc_gNB_get_ue_context_by_amf_ue_ngap_id()
- Send handover failure with appropriate cause if UE context already exists
- Remove redundant ho_context NULL check that could never be true for newly created UE contexts
- Prevents duplicate handover processing and resource leaks
2025-09-30 11:48:53 +02:00
Guido Casati
1357158722 Fix hardcoded instance 0 bug in UE context release command
Use the instance parameter instead of hardcoded 0 to access the correct
RRC instance. Also clean up redundant variable initialization.
2025-09-30 11:48:53 +02:00
Guido Casati
de07668b0b Fix potential memory leak in ngap_gNB_handover_request_acknowledge
Move UE context creation and storage to after successful PDU encoding
to prevent memory leaks if encoding fails. Also add proper PDU cleanup
when AMF fetch fails and use consistent NULL check style.

This ensures UE context is only stored when the operation is guaranteed
to succeed, improving error handling and memory management.
2025-09-30 11:48:53 +02:00
Guido Casati
235493aa07 Fix ASN.1 memory management ownership in NGAP functions
In the current memory management the caller wasn't responsible for freeing
memory they allocate. The ngap_gNB_encode_pdu function was taking ownership
of PDU contents by calling ASN_STRUCT_FREE_CONTENTS_ONLY, while callers
also expected to manage the same memory. This created unclear ownership semantics and
potential double-free bugs.

- Remove ASN_STRUCT_FREE_CONTENTS_ONLY from ngap_gNB_encode_pdu to prevent double-free
- Remove unnecessary ASN_STRUCT_FREE when encode function returns NULL
- Add proper ASN_STRUCT_FREE cleanup for heap-allocated PDUs in ngap_gNB.c functions
- Add ASN_STRUCT_FREE_CONTENTS_ONLY cleanup for stack-allocated PDUs in NAS and context management functions
- Ensure consistent memory cleanup patterns across all NGAP encoder callers
- Fix potential memory leaks in all ngap_gNB_encode_pdu call sites

This prevents double-free bugs and ensures proper cleanup of ASN.1 structures
in both heap and stack allocation scenarios.
2025-09-30 11:48:53 +02:00
Guido Casati
524a3ddf85 Fix xer_fprint parameter in ngap_handover_required
Fix incorrect xer_fprint parameter - should pass pdu instead of &pdu
to properly print ASN.1 structure for debugging.
2025-09-30 11:48:53 +02:00
Robert Schmidt
12d92bc836 Fix crash in get_du_for_ue when F1 UE data does not exist
Add check for cu_exists_f1_ue_data() before calling cu_get_f1_ue_data()
to prevent assertion failure when telnet command 'ci fetch_du_by_ue_id'
is used for UEs that have been handed over via N2 (and no longer have
F1 UE data).

This fixes the crash:
Assertion (ret == HASH_TABLE_OK && data != ((void *)0)) failed!
In get_hashtable_data() /oai-ran/openair2/F1AP/f1ap_ids.c:36
element for ue_id 1 not found

The function now returns NULL gracefully when F1 UE data is not available.

Co-authored-by: Guido Casati <hello@guidocasati.com>
2025-09-30 11:48:53 +02:00
Guido Casati
a38aa1bab8 Fix memory leaks in fill_removal_lists_from_source_measConfig
- Add proper cleanup of allocated ASN.1 structures in all return paths
- Fix early returns that were leaking NR_HandoverPreparationInformation
- Fix early returns that were leaking NR_RRCReconfiguration
- Add cleanup at end of successful function execution

This prevents memory leaks when processing handover preparation information
during N2 handover procedures.
2025-09-30 11:48:53 +02:00
Guido Casati
b4485ecea2 Fix UE context leak in handover failure
- Add UE context cleanup before sending handover failure message
- Prevents memory/resource leak when PDU session establishment fails during handover
- UE context was created but never cleaned up on failure path

This fixes a bug where UE contexts would accumulate over time
when handovers failed after context creation.
2025-09-30 11:48:41 +02:00
Guido Casati
fd50ff43cc Handle gracefully encoding failure in build_RRCReconfiguration_IEs
closes #979
2025-09-30 11:23:45 +02:00
Sakthivel Velumani
59ff9ae04e ulsim: test UCI on PUSCH with matlab
Since there is no UCI on PUSCH implementation in gNB, it is good to test
UE's implementation with matlab.

This commit allows to test with matlab in two ways:
1. generate OFDM waveform from ulsim and decode it in matlab using
uci_on_pusch_decode.m
2. generate codeword in matlab using uci_on_pusch_encode.m read it in
ulsim and compare the bits. ulsim option -o is used
2025-09-30 00:24:39 +08:00
Sakthivel Velumani
83bf140bc3 Add flag for Tx phase pre compensation
Used in ulsim to verify waveform in MATLAB
2025-09-30 00:24:39 +08:00
Sakthivel Velumani
b2174cb8e1 Add processing stats for UCI mapping on PUSCH 2025-09-30 00:24:36 +08:00
Sakthivel Velumani
8de13fab97 Simplify code 2025-09-30 00:23:00 +08:00
alexjiao
ac76c6e27a Add functions to calculate M_bit for PUCCH format 2/3/4
Add functions to calculate PUCCH format 2/3/4 rate matching output sequence length (M_bit),
according to 3GPP TS 38.212 Table 6.3.1.4-1.
2025-09-30 00:23:00 +08:00
alexjiao
b69b65ba66 Handle UCI on PUSCH scrambling
When the codeword has UCI multiplexed with data, we need to handle UCI scrambling according to 38.211 section 6.3.1.1.
Especially when O_ACK <= 2 there are x and y placeholder bits for UCI.
2025-09-30 00:23:00 +08:00
alexjiao
1c5af6065c Handle UCI on PUSCH procedures at PHY
Get beta offset, alpha scaling and other parameters to calculate rate matching information for UCI on PUSCH,
then use the rate matching info to encode UCI and re-encode PUSCH, call nr_uci_on_pusch to get final multiplexed codeword for scrambling.
2025-09-30 00:22:58 +08:00
calvin_peyron
63397ac592 Remove RFSIMULATOR environment variable 2025-09-29 15:14:39 +02:00
Laurent THOMAS
3f9dcee5fa remove a dead function 2025-09-29 15:14:39 +02:00
calvin_peyron
7d70617a01 Fix documentation broken links 2025-09-29 15:14:39 +02:00
Jaroslava Fiedlerova
d6f0b5a9d7 Merge remote-tracking branch 'origin/cleanup-ue-get-nr-rsrp' into integration_2025_w40 (!3674)
NR UE: remove function get_nr_RSRP() and get_nr_rx_total_gain_dB() for cleanup

The function get_nr_RSRP() and get_nr_rx_total_gain_dB() are not used anywhere
in the code, removing for cleanup.
2025-09-29 13:12:36 +02:00
Jaroslava Fiedlerova
afebd033f6 Merge remote-tracking branch 'origin/ci-ho-freq-update' into integration_2025_w40 (!3667)
CI: Updates for HO and AW2S pipeline

This MR introduces several CI updates:

- Change center frequency from 3439 MHz (n78) to 4185 MHz (n77) in HO setup to
  prevent interference with other lab setups.
- Enable attaching multiple AmariUEs simultaneously in the AW2S pipeline - save
  ~25s.
- Update RX gain configuration on AmariUE - improve DL throughput.
2025-09-29 13:11:14 +02:00
Jaroslava Fiedlerova
6e424af56b Merge remote-tracking branch 'origin/issue930' into integration_2025_w40 (!3657)
do not assert for mismatched TBS in phy-test mode

Closes #930
2025-09-29 12:56:24 +02:00
Jaroslava Fiedlerova
1e61c2ccb4 Merge remote-tracking branch 'origin/BWP_with_no_RA' into integration_2025_w40 (!3609)
BWP with no PRACH occasions

This MR includes fixes at gNB and UE in case the current BWP has no PRACH
occasions, i.e. we need to switch to initial BWP.
2025-09-29 12:55:30 +02:00
alexjiao
0fb8a09b86 Remove function get_nr_RSRP() and get_nr_rx_total_gain_dB() for cleanup
The function get_nr_RSRP() and get_nr_rx_total_gain_dB() is not used anywhere in the code.
2025-09-29 17:51:52 +08:00
Robert Schmidt
60ab0a89a2 Build all targets in Cluster PhySim build 2025-09-29 09:04:02 +02:00
Robert Schmidt
2ff949a16f Correct dependencies onto logging module
These libraries depend on the logging module, so add the right
dependency log_headers. Indirectly, this will fulfill the condition of
T. I consider the prior usage of generate_T or {T_LIB} incorrect,
because basically none of these libraries actually, actively use T, but
rather only the logging module, which pulls in T.  The dependency of
log_headers will also take care of generating and including T headers,
which is a dependency of the logging module.

For conf2uedata and related, fulfill the dependency
through conf2uedata_lib (on which the rest depends).
2025-09-29 09:04:02 +02:00
Robert Schmidt
4876533e9c F1AP IDs: Remove unnecessary dependency 2025-09-29 09:04:02 +02:00
Robert Schmidt
cdbfaf835e params_yaml has no dependency on UTIL
These libraries have no dependencies on UTIL, so it's better to omit it.
However, then the test is missing symbols for the config (which likely,
indirectly came through UTIL -> LOG -> CONFIG_LIB, so add it now onto
the test.
2025-09-29 09:04:02 +02:00
Robert Schmidt
1e476735ea xforms uses logging 2025-09-29 09:04:02 +02:00
Robert Schmidt
1b81c4b09c RLC only needs headers for logging 2025-09-29 09:04:02 +02:00
Robert Schmidt
5716d95e97 nr_prachsim: remove unused include 2025-09-29 09:04:02 +02:00
Robert Schmidt
eea7be3977 ldpc_segment: avoid T error, use log_headers for logging
As parent.
2025-09-29 09:04:02 +02:00
Robert Schmidt
19813283fb Avoid T error on radio libraries
These libraries have an (indirect) dependency on T, either by using the
logging module (which in turn depends on T), or through other includes.

The easiest is to depend on the logging module, which will fulfil also
the T dependency.

It would equally be feasible to use the utils target (which in turn
depends on log_headers), but this would necessitate to compile, and does
not seem to be necessary.
2025-09-29 09:04:02 +02:00
Robert Schmidt
2a5ed87589 E2 Agent uses CONFIG_LIB for configuration
Since E2 agent uses the config library, include it directly. This also
makes the dependency on T obsolete, because

- it is the logging headers that are needed, and
- the T dependency is fulfilled through the log_headers.
2025-09-29 09:04:02 +02:00
Robert Schmidt
1ecb03f5f8 Make BladeRF compile
Fix variable name.

See also: 7466297568 ("move command line sample offset [...] at top
  level [...]")
2025-09-29 09:04:02 +02:00
Robert Schmidt
2889e55cd8 Remove redundant target_include_directories() from LOG
The same is achieved by including log_headers.
2025-09-29 09:04:02 +02:00
Robert Schmidt
197705f232 Provide T headers via log.h
It seems that many compilation units include T.h through the config
module (as evidenced when taking out T.h from
config_load_configmodule.h). This is strange, because T.h is only used
in the logging headers. Hence, move it to there, where it is used.
2025-09-29 09:04:02 +02:00
Jaroslava Fiedlerova
fd37fba9b7 Cleanup of libraries/executables from T loop
These libraries/executables are not defined in OAI.
2025-09-29 09:04:02 +02:00
Robert Schmidt
66c3b7d192 Break coding_defs.h dependency on logging module
coding_defs.h included defs_common.h, which pulls in many dependencies,
e.g., the logging module, which pulls in T. However, it does not use
anything of this. So remove, and include stdbool.h instead (because bool
is used in coding_defs.h.

nr_polar_defs.h relied on some includes done in coding_defs. Use
includes for pthreads and SIMD to define types that are used in
nr_polar_defs.h.
2025-09-29 09:04:02 +02:00
Robert Schmidt
eef092c318 Omit JER compilation for NRPPA ASN.1
We don't use JER. This avoids compilation problems, such as:

    /usr/bin/ld: openair3/NRPPA/MESSAGES/libasn1_nrppa.a(INTEGER_jer.c.o): in function `INTEGER_decode_jer':
    tmp.MtrwVDhQqY/openair3/NRPPA/MESSAGES/INTEGER_jer.c:186:(.text+0x5b8): undefined reference to `jer_decode_primitive
2025-09-29 09:04:02 +02:00
Robert Schmidt
72371ba10b Remove unnecessary comment 2025-09-29 09:04:02 +02:00
Robert Schmidt
46ed4ac36d Update comment to reference right target 2025-09-29 09:04:02 +02:00
Robert Schmidt
4177c6d182 Include CMakeLists.txt using add_subdirectory(), simplify 2025-09-29 09:04:02 +02:00
Robert Schmidt
cc094ac737 XNAP asn.1 cmake: ber_decoder.h is not created
XNAP is asn1c compiled with -no-gen-BER. Correspondingly, no
ber_decoder.h file is created. However, when running cmake followed by
ninja, it notices the absence of this file:

    ninja explain: output openair2/XNAP/MESSAGES/ber_decoder.h doesn't exist

which triggers a complete rebuild of XNAP ASN.1. Without this file, the
targets are not marked as dirty.
2025-09-29 09:04:02 +02:00
Robert Schmidt
cede449907 Remove NUMBER_OF_UE_MAX_NB_IoT and make NB_IoT compile
This constant seems to be an analogon to NUMBER_OF_UE_MAX; replace with
the latter, as it does the same. (NBIoT does not work, anyway)

Fix dependencies of the NB_IoT target so it compiles.
2025-09-29 09:04:02 +02:00
Robert Schmidt
a68168805b Remove NB-IoT configuration
Remove, because
1) it does not compile (the asn1c generated code should be prepend with
   LTE_ etc, nobody did that)
2) a shared module makes no sense
3) the configuration is trivial to recreate
2025-09-29 09:04:02 +02:00
Robert Schmidt
1a5e2598a3 Move LTTng check to subdirectory where used 2025-09-29 09:04:02 +02:00
Robert Schmidt
d6c29b2d2c Fix E2_AGENT linking w.r.t. simulators
Link E2_AGENT libraries directly into nr-softmodem/lte-softmodem instead
of L2/L2_NR/F1AP. Doing that ensures that simulators, e.g.,
nr_dlsim/nr_ulsim do still compile. It also simplifies the code.

Prior to this, compiling nr_ulsim with E2_AGENT, for instance, resulted
in the following errors, fixed in this commit:

    FAILED: nr_ulsim
    /usr/bin/ld: openair2/E2AP/RAN_FUNCTION/libe2_ran_func_du_cucp_cuup.a(ran_func_rc.c.o): in function `send_aper_ric_ind':
    /home/oai/robert/cleanup-t-dependency-cmake/openair2/E2AP/RAN_FUNCTION/O-RAN/ran_func_rc.c:643: (.text+0xee6): undefined reference to `async_event_agent_api'
    /usr/bin/ld: /home/oai/robert/cleanup-t-dependency-cmake/openair2/E2AP/RAN_FUNCTION/O-RAN/ran_func_rc.c:643:(.text+0x11ca): undefined reference to `async_event_agent_api'
    /usr/bin/ld: /home/oai/robert/cleanup-t-dependency-cmake/openair2/E2AP/RAN_FUNCTION/O-RAN/ran_func_rc.c:643:(.text+0x1485): undefined reference to `async_event_agent_api'
    /usr/bin/ld: /home/oai/robert/cleanup-t-dependency-cmake/openair2/E2AP/RAN_FUNCTION/O-RAN/ran_func_rc.c:643:(.text+0x159c): undefined reference to `async_event_agent_api'
    /usr/bin/ld: /home/oai/robert/cleanup-t-dependency-cmake/openair2/E2AP/RAN_FUNCTION/O-RAN/ran_func_rc.c:643:(.text+0x16b1): undefined reference to `async_event_agent_api'
    [...]
2025-09-29 09:04:02 +02:00
Robert Schmidt
a31838acd7 CMakeLists.txt: comment out tests that don't compile 2025-09-29 09:04:02 +02:00
Robert Schmidt
ba3a0d2100 CMakeLists.txt: comment out sims that don't compile 2025-09-29 09:04:02 +02:00
Robert Schmidt
124debc2c7 Fix warnings in rftest executable
warning: ‘genericPowerPerAntena’ defined but not used [-Wunused-function]

    warning: ‘graph.text’ is used uninitialized [-Wuninitialized]

    warning: ignoring return value of ‘read’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
2025-09-29 09:04:02 +02:00
Jaroslava Fiedlerova
03d4ce2e1e CI: Attach multiple UEs at once in AW2S test 2025-09-26 15:07:16 +02:00
Jaroslava Fiedlerova
b43dee1499 CI: adjust Amarisoft UE RX gain
Lower the RX gain used by the Amarisoft UE in CI tests to prevent DL signal
saturation. This resolves an issue with low DL throughput observed in CI.
RX/TX signal levels on the Amarisoft UE can be checked with "t spl" command
in lteue; MAX values should not approach 0.
2025-09-26 14:58:47 +02:00
Sakthivel Velumani
5f3a19cb7d Separate segmentation from ULSCH encoding function
Segmentation have to be called before UCI mapping to get number of
segments and sumKr values.
2025-09-26 11:16:54 +08:00
alexjiao
ceda9c1141 Add functions to implement UCI and data multiplexing on PUSCH
Data and control multiplexing procedure is defined in 38.212 section 6.2.7.
Step 3 (CSI1 and CSI2 mapping) is not implemented, only HARQ-ACK.
PUSCH frequency hopping is not supported.
2025-09-26 11:14:12 +08:00
alexjiao
8222fa27e5 Add functions to calculate rate matching information for UCI on PUSCH
Use betaOffset and alpha scaling etc. to get rate matching information of UCI on PUSCH (e.g. max bit capacity of encoded UCI and encoded ULSCH)
according to TS 38.212 section 6.3.2.4 and 6.2.7.
2025-09-26 11:14:12 +08:00
alexjiao
a64038658f Modify nr_uci_encoding for UCI on PUSCH
38.212 section 5.3.3.1 and 5.3.3.2 describe how to encode 1-bit and 2-bit information.
This is needed when typically HARQ-ACK will be transmitted on PUSCH.
38.212 section 5.4.3 also describes how to do rate matching for channel coding of small block lengths.
2025-09-26 11:14:08 +08:00
Jaroslava Fiedlerova
41b33e9124 CI: Update frequency in HO setup
Move center frequency from 3439 MHz to 4185 MHz to avoid interference
with other lab setups.
2025-09-25 15:43:14 +02:00
Guido Casati
e535fbe6a7 Replace impossible ID mismatch checks with DevAssert in NGAP functions
- Replace error handling for impossible ID mismatches with DevAssert statements
- If ngap_get_ue_context() succeeds, returned context must have matching NGAP gNB UE IDs by definition
- This catches potential bugs in the lookup function immediately
- Affects: handover_required, handover_notify, handover_cancel, ul_ran_status_transfer

These checks were logically impossible since we looked up the context using
the same IDs we were then checking for mismatch.
2025-09-25 14:55:03 +02:00
Guido Casati
50760c04a7 Fix log messages in N2 handover: print both PCI and Cell ID when available
- Fixed incorrect log messages that said 'PCI=%lu' when printing nr_cell_id
- Now prints both NR Cell ID and PCI when DU is found
- Provides better debugging information for handover requests
2025-09-25 14:55:03 +02:00
Guido Casati
8dcd253e60 E1 lib: Adopt _E1_EQ_CHECK_OPTIONAL_PTR macro in E1AP bearer context management
- Add _E1_EQ_CHECK_OPTIONAL_PTR checks for pdcp_config, sdap_config, UP_TL_information, and securityIndication
- Fix bug in eq_pdu_session_to_mod_item where a->UP_TL_information was compared with itself instead of b->UP_TL_information
- Fix eq_security_ind call to properly handle return value with early return pattern
- Improve consistency with existing macro usage patterns in the codebase
- Provide better error reporting for optional pointer field mismatches
2025-09-25 14:55:03 +02:00
Guido Casati
a7257eaff1 E1 lib: fix inconsistent equality checking patterns in E1AP bearer context management
Replace result &= pattern with consistent early return pattern:
- Fix mixing of logical (&&) and binary (&) operators
- Use consistent 'if (!eq_()) return false;' pattern throughout
- Fix bug in eq_bearer_context_mod_response where drbModA was compared with itself
- Remove unused 'bool result = true;' variables
- Always return true at the end of equality functions

This makes the code more consistent with the rest of the codebase
and provides better error reporting through the existing _E1_EQ_CHECK macros.
2025-09-25 14:55:03 +02:00
Laurent THOMAS
912463f752 modulation LUTs size was wrong, and remove inconsistent test of SSE2 enable 2025-09-25 09:29:44 +02:00
Robert Schmidt
252b19cddb Make rftest compile
uniqCfg is in minimal_lib, so not necessary. Remove non-existant struct
members.
2025-09-25 08:51:11 +02:00
Robert Schmidt
b2fce659e8 Fix warning for wrong printf format specifier
common/utils/threadPool/measurement_display.c:55:14 warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘long long unsigned int’ [-Wformat=]
2025-09-25 08:51:11 +02:00
Robert Schmidt
ada7eb8b2a Remove unused/non-compiling test stub 2025-09-25 08:51:11 +02:00
Robert Schmidt
acb6f05a6d Remove include_directories() for non-existing directories 2025-09-25 08:51:11 +02:00
Robert Schmidt
d5bf702f10 Remove CMakeLists.txt author information
Author information can be inferred from git blame.
2025-09-25 08:42:35 +02:00
Robert Schmidt
2d70cec6dd Remove autotools definitions
They do not seem to be used anywhere (I grepped).
2025-09-25 08:42:35 +02:00
francescomani
966bab9cca do not assert for mismatched TBS in phy-test mode 2025-09-23 10:39:37 +02:00
francescomani
47554f89ce fix switch to initial UL BWP if no PRACH common configuration in current BWP 2025-09-18 11:57:57 +02:00
francescomani
72bfd1b5c3 switch to initial BWP if current BWP has no PRACH in gNB 2025-09-18 11:57:54 +02:00
172 changed files with 3408 additions and 2530 deletions

View File

@@ -19,8 +19,6 @@
# * contact@openairinterface.org
# */
# Author: laurent THOMAS, Lionel GAUTHIER
cmake_minimum_required (VERSION 3.16)
project (OpenAirInterface LANGUAGES C CXX)
set(CMAKE_CXX_STANDARD 17)
@@ -173,9 +171,6 @@ else ()
set(C_FLAGS_PROCESSOR "${C_FLAGS_PROCESSOR} -march=armv8.2-a")
endif()
# add autotools definitions that were maybe used!
add_definitions(-DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_FCNTL_H=1 -DHAVE_ARPA_INET_H=1 -DHAVE_SYS_TIME_H=1 -DHAVE_SYS_SOCKET_H=1 -DHAVE_STRERROR=1 -DHAVE_SOCKET=1 -DHAVE_MEMSET=1 -DHAVE_GETTIMEOFDAY=1 -DHAVE_STDLIB_H=1 -DHAVE_MALLOC=1 -DHAVE_LIBSCTP)
# we need -rdynamic to incorporate all symbols in shared objects, see man page
set(commonOpts "-pipe -fPIC -Wall -fno-strict-aliasing -rdynamic")
# GNU C/C++ Compiler might throw many warnings without packed-bitfield-compat, see man page
@@ -469,9 +464,6 @@ target_include_directories(f1ap PUBLIC F1AP_DIR)
target_link_libraries(f1ap PUBLIC asn1_f1ap GTPV1U)
target_link_libraries(f1ap PRIVATE ngap nr_rrc HASHTABLE f1ap_lib)
target_include_directories(f1ap PRIVATE ${F1AP_DIR}/lib)
if(E2_AGENT)
target_compile_definitions(f1ap PRIVATE E2_AGENT)
endif()
# LPP
##############
@@ -549,7 +541,6 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories("${OPENAIR_DIR}/executables")
include_directories("${OPENAIR2_DIR}/COMMON")
include_directories("${OPENAIR2_DIR}/UTIL")
include_directories("${OPENAIR2_DIR}/UTIL/LOG")
include_directories("${OPENAIR3_DIR}/COMMON")
include_directories("${OPENAIR3_DIR}/UTILS")
include_directories("${NFAPI_DIR}/nfapi/public_inc")
@@ -590,12 +581,7 @@ include_directories("${OPENAIR3_DIR}/ocp-gtpu")
include_directories("${OPENAIR3_DIR}/M3AP")
include_directories("${OPENAIR3_DIR}/MME_APP")
include_directories("${OPENAIR_DIR}/radio/COMMON")
include_directories("${OPENAIR2_DIR}/UTIL/OSA")
include_directories("${OPENAIR2_DIR}/UTIL/MEM")
include_directories("${OPENAIR2_DIR}/UTIL/LISTS")
include_directories("${OPENAIR2_DIR}/UTIL/FIFO")
include_directories("${OPENAIR2_DIR}/UTIL/MATH")
include_directories("${OPENAIR2_DIR}/UTIL/TIMER")
include_directories("${OPENAIR2_DIR}/UTIL/OTG")
include_directories("${OPENAIR2_DIR}/UTIL/OPT")
include_directories("${OPENAIR_DIR}")
@@ -623,11 +609,6 @@ add_library(UTIL
${OPENAIR_DIR}/common/utils/LOG/vcd_signal_dumper.c
${OPENAIR2_DIR}/UTIL/OPT/probe.c
)
if (ENABLE_LTTNG)
find_package(LTTngUST 2.3.8 EXACT REQUIRED)
else()
message(STATUS "LTTNG support disabled")
endif()
pkg_check_modules(cap libcap)
if (cap_FOUND)
@@ -1318,12 +1299,6 @@ add_library(L2
target_link_libraries(L2 PRIVATE x2ap s1ap lte_rrc m2ap)
target_link_libraries(L2 PRIVATE asn1_lte_rrc_hdrs asn1_nr_rrc_hdrs)
if(E2_AGENT)
target_link_libraries(L2 PUBLIC e2_agent e2_agent_arg e2_ran_func_du_cucp_cuup)
target_compile_definitions(L2 PRIVATE ${E2AP_VERSION} ${KPM_VERSION} E2_AGENT)
endif()
add_library(MAC_UE_NR ${MAC_NR_SRC_UE})
target_link_libraries(MAC_UE_NR PRIVATE asn1_lte_rrc_hdrs asn1_nr_rrc_hdrs PUBLIC nr_ue_power_procedures nr_ue_ra_procedures)
@@ -1350,10 +1325,6 @@ target_link_libraries(L2_NR PRIVATE f1ap x2ap s1ap ngap nr_rrc e1ap nr_rlc nr_co
if(OAI_AERIAL)
target_compile_definitions(L2_NR PRIVATE ENABLE_AERIAL)
endif()
if(E2_AGENT)
target_link_libraries(L2_NR PUBLIC e2_agent e2_agent_arg e2_ran_func_du_cucp_cuup)
target_compile_definitions(L2_NR PRIVATE ${E2AP_VERSION} ${KPM_VERSION} E2_AGENT)
endif()
add_library(L2_LTE_NR
# temporary solution until 4G/5G code completely untangled (as evidenced by deletion of the following file)
@@ -1683,13 +1654,6 @@ include_directories(${NAS_SRC}UE/EMM/SAP)
include_directories(${NAS_SRC}UE/ESM)
include_directories(${NAS_SRC}UE/ESM/SAP)
# nbiot
add_definitions("-DNUMBER_OF_UE_MAX_NB_IoT=16")
set (NBIOT_SOURCES
${OPENAIR2_DIR}/ENB_APP/NB_IoT_config.c
)
add_library(NB_IoT MODULE ${NBIOT_SOURCES} )
# Simulation library
##########################
set (SIMUSRC
@@ -1715,9 +1679,8 @@ include_directories("${NFAPI_DIR}/nfapi/inc")
include_directories("${NFAPI_DIR}/sim_common/inc")
include_directories("${NFAPI_DIR}/pnf_sim/inc")
add_library(oai_iqplayer MODULE
${OPENAIR_DIR}/radio/iqplayer/iqplayer_lib.c
)
add_library(oai_iqplayer MODULE ${OPENAIR_DIR}/radio/iqplayer/iqplayer_lib.c)
target_link_libraries(oai_iqplayer PRIVATE log_headers)
#################################
# add executables for operation
@@ -1727,10 +1690,6 @@ add_library(minimal_lib
)
target_link_libraries(minimal_lib PUBLIC pthread dl ${T_LIB} LOG)
add_executable(nfapi_test
${OPENAIR_DIR}/openair2/NR_PHY_INTERFACE/nfapi_5g_test.c
)
add_executable(measurement_display
${OPENAIR_DIR}/common/utils/threadPool/measurement_display.c)
target_link_libraries (measurement_display minimal_lib)
@@ -1770,6 +1729,7 @@ target_link_libraries(lte-softmodem PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs)
target_link_libraries(lte-softmodem PRIVATE ${blas_LIBRARIES} ${cblas_LIBRARIES} ${lapacke_LIBRARIES} ${lapack_LIBRARIES})
if(E2_AGENT)
target_link_libraries(lte-softmodem PUBLIC e2_agent e2_agent_arg e2_ran_func_du_cucp_cuup)
target_compile_definitions(lte-softmodem PRIVATE ${E2AP_VERSION} ${KPM_VERSION} E2_AGENT)
endif()
@@ -1873,6 +1833,7 @@ if (OAI_AERIAL)
target_link_libraries(nr-softmodem PUBLIC aerial_lib)
endif()
if(E2_AGENT)
target_link_libraries(nr-softmodem PUBLIC e2_agent e2_agent_arg e2_ran_func_du_cucp_cuup)
target_compile_definitions(nr-softmodem PRIVATE ${E2AP_VERSION} ${KPM_VERSION} E2_AGENT)
endif()
@@ -1947,14 +1908,14 @@ target_link_libraries(nr-uesoftmodem PRIVATE
#####################################
#special case for dlim TM4, which uses its own version of phy_scope code
add_executable(dlsim_tm4
${OPENAIR1_DIR}/SIMULATION/LTE_PHY/dlsim_tm4.c
${OPENAIR1_DIR}/PHY/TOOLS/lte_phy_scope_tm4.c
)
target_link_libraries (dlsim_tm4
-Wl,--start-group SIMU UTIL SCHED_LIB SCHED_RU_LIB PHY ITTI -Wl,--end-group
pthread m rt CONFIG_LIB ${T_LIB}
)
#add_executable(dlsim_tm4
# ${OPENAIR1_DIR}/SIMULATION/LTE_PHY/dlsim_tm4.c
# ${OPENAIR1_DIR}/PHY/TOOLS/lte_phy_scope_tm4.c
# )
#target_link_libraries (dlsim_tm4
# -Wl,--start-group SIMU UTIL SCHED_LIB SCHED_RU_LIB PHY ITTI -Wl,--end-group
# pthread m rt CONFIG_LIB ${T_LIB}
# )
add_executable(rftest
${OPENAIR_DIR}/openair1/PHY/TOOLS/calibration_test.c
@@ -2079,7 +2040,9 @@ target_link_libraries(nr_ulsim PRIVATE
)
target_link_libraries(nr_ulsim PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs)
foreach(myExe dlsim dlsim_tm7 ulsim pbchsim scansim mbmssim pdcchsim pucchsim prachsim syncsim)
# these simulators do not compile:
# dlsim_tm7 pbchsim scansim mbmssim pdcchsim pucchsim prachsim syncsim
foreach(myExe dlsim ulsim)
add_executable(${myExe}
${OPENAIR1_DIR}/SIMULATION/LTE_PHY/${myExe}.c
@@ -2099,22 +2062,23 @@ endforeach(myExe)
#unitary tests for Core NEtwork pieces
#################################
foreach(myExe s1ap
secu_knas_encrypt_eia1
secu_kenb
aes128_ctr
secu_knas_encrypt_eea2
secu_knas secu_knas_encrypt_eea1
kdf
aes128_cmac_encrypt
secu_knas_encrypt_eia2)
add_executable(test_${myExe}
${OPENAIR3_DIR}/TEST/test_${myExe}.c
)
target_link_libraries (test_${myExe}
-Wl,--start-group SECURITY UTIL -Wl,--end-group m rt CONFIG_LIB
)
endforeach(myExe)
#foreach(myExe
# s1ap
# secu_knas_encrypt_eia1
# secu_kenb
# aes128_ctr
# secu_knas_encrypt_eea2
# secu_knas secu_knas_encrypt_eea1
# kdf
# aes128_cmac_encrypt
# secu_knas_encrypt_eia2)
# add_executable(test_${myExe}
# ${OPENAIR3_DIR}/TEST/test_${myExe}.c
# )
# target_link_libraries (test_${myExe}
# -Wl,--start-group SECURITY UTIL -Wl,--end-group m rt CONFIG_LIB
# )
#endforeach(myExe)
#ensure that the T header files are generated before targets depending on them
if (${T_TRACER})
@@ -2124,17 +2088,17 @@ if (${T_TRACER})
nr-uesoftmodem dlsim dlsim_tm4 dlsim_tm7
ulsim pbchsim scansim mbmssim pdcchsim pucchsim prachsim
syncsim nr_ulsim nr_dlsim nr_dlschsim nr_pbchsim nr_pucchsim
nr_ulschsim ldpctest polartest smallblocktest cu_test du_test
nr_ulschsim ldpctest polartest smallblocktest
#all "add_library" definitions
ITTI lte_rrc nr_rrc s1ap x2ap m2ap m3ap f1ap
params_libconfig oai_usrpdevif oai_bladerfdevif oai_lmssdrdevif oai_iqplayer
oai_eth_transpro oai_mobipass HASHTABLE UTIL OMG_SUMO
SECURITY SCHED_LIB SCHED_NR_LIB SCHED_RU_LIB SCHED_UE_LIB SCHED_NR_UE_LIB default_sched remote_sched RAL
params_libconfig
oai_eth_transpro HASHTABLE UTIL
SECURITY SCHED_LIB SCHED_NR_LIB SCHED_RU_LIB SCHED_UE_LIB SCHED_NR_UE_LIB
NFAPI_LIB NFAPI_PNF_LIB NFAPI_VNF_LIB NFAPI_USER_LIB
MISC_NFAPI_LTE_LIB MISC_NFAPI_NR_LIB
PHY_COMMON PHY PHY_UE PHY_NR PHY_NR_COMMON PHY_NR_UE PHY_RU
L2 L2_LTE L2_NR L2_LTE_NR L2_UE NR_L2_UE MAC_NR_COMMON MAC_UE_NR ngap
CN_UTILS GTPV1U SCTP_CLIENT MME_APP LIB_NAS_UE NB_IoT SIMU OPENAIR0_LIB
GTPV1U SCTP_CLIENT MME_APP LIB_NAS_UE SIMU
dfts config_internals nr_common crc_byte)
if (TARGET ${i})
add_dependencies(${i} generate_T)
@@ -2142,8 +2106,6 @@ if (${T_TRACER})
endforeach(i)
endif (${T_TRACER})
include(${OPENAIR1_DIR}/PHY/CODING/nrLDPC_decoder/nrLDPC_tools/CMakeLists.txt)
set(ENABLE_TESTS OFF CACHE STRING "Activate build of tests")
set_property(CACHE ENABLE_TESTS PROPERTY TYPE BOOL)
set(ENABLE_PHYSIM_TESTS OFF CACHE STRING "Activate build of physim tests")

View File

@@ -44,4 +44,4 @@ rf_driver: {
#endif
tx_gain: 75.0, /* TX gain (in dB) */
rx_gain: 55.0, /* RX gain (in dB) */
rx_gain: 52.0, /* RX gain (in dB) */

View File

@@ -255,7 +255,7 @@ def Deploy_Physim(ctx, HTML, node, workdir, script, options):
logging.debug(f'Running physims on server {node} workdir {workdir}')
with cls_cmd.getConnection(node) as c:
sys_info = c.exec_script("scripts/sys-info.sh", 5)
ret = c.exec_script(script, 600, options)
ret = c.exec_script(script, 1000, options)
logging.debug(f'"{script}" finished with code {ret.returncode}, output:\n{ret.stdout}')
HTML.CreateHtmlTestRowQueue('Query system info', 'OK', [sys_info.stdout])
with cls_cmd.getConnection(node) as ssh:

View File

@@ -26,11 +26,11 @@ gNBs =
# downlinkConfigCommon
#frequencyInfoDL
# 4.01 GHz
absoluteFrequencySSB = 629376;
dl_frequencyBand = 78;
# 4 GHz
dl_absoluteFrequencyPointA = 628720;
# 4186.56 MHz
absoluteFrequencySSB = 679104;
dl_frequencyBand = 77;
# 4175.82 MHz
dl_absoluteFrequencyPointA = 678388;
#scs-SpecificCarrierList
dl_offstToCarrier = 0;
# subcarrierSpacing
@@ -50,7 +50,7 @@ gNBs =
#uplinkConfigCommon
#frequencyInfoUL
ul_frequencyBand = 78;
ul_frequencyBand = 77;
#scs-SpecificCarrierList
ul_offstToCarrier = 0;
# subcarrierSpacing
@@ -188,7 +188,7 @@ RUs = (
nb_rx = 1
att_tx = 0;
att_rx = 0;
bands = [78];
bands = [77];
max_pdschReferenceSignalPower = -27;
max_rxgain = 114;
eNB_instances = [0];

View File

@@ -26,11 +26,11 @@ gNBs =
# downlinkConfigCommon
#frequencyInfoDL
# 4.01 GHz
absoluteFrequencySSB = 629376;
dl_frequencyBand = 78;
# 4 GHz
dl_absoluteFrequencyPointA = 628720;
# 4186.56 MHz
absoluteFrequencySSB = 679104;
dl_frequencyBand = 77;
# 4175.82 MHz
dl_absoluteFrequencyPointA = 678388;
#scs-SpecificCarrierList
dl_offstToCarrier = 0;
# subcarrierSpacing
@@ -50,7 +50,7 @@ gNBs =
#uplinkConfigCommon
#frequencyInfoUL
ul_frequencyBand = 78;
ul_frequencyBand = 77;
#scs-SpecificCarrierList
ul_offstToCarrier = 0;
# subcarrierSpacing
@@ -188,7 +188,7 @@ RUs = (
nb_rx = 1
att_tx = 0;
att_rx = 0;
bands = [78];
bands = [77];
max_pdschReferenceSignalPower = -27;
max_rxgain = 114;
eNB_instances = [0];

View File

@@ -184,7 +184,7 @@ L1s = (
{
num_cc = 1;
tr_n_preference = "local_mac";
prach_dtx_threshold = 130;
prach_dtx_threshold = 150;
#pucch0_dtx_threshold = 150;
}
);

View File

@@ -6,9 +6,9 @@ neighbour_list = (
gNB_ID = 0xe01;
nr_cellid = 11111111;
physical_cellId = 1;
absoluteFrequencySSB = 629376;
absoluteFrequencySSB = 679104;
subcarrierSpacing = 1; #30 KHz
band = 78;
band = 77;
plmn = { mcc = 001; mnc = 03; mnc_length = 2};
tracking_area_code = 1;
}
@@ -21,9 +21,9 @@ neighbour_list = (
gNB_ID = 0xe00;
nr_cellid = 12345678;
physical_cellId = 0;
absoluteFrequencySSB = 629376;
absoluteFrequencySSB = 679104;
subcarrierSpacing = 1; #30 KHz
band = 78;
band = 77;
plmn = { mcc = 001; mnc = 03; mnc_length = 2};
tracking_area_code = 1;
}

View File

@@ -42,5 +42,6 @@ WORKDIR /oai-ran/build
RUN cmake -GNinja -DENABLE_PHYSIM_TESTS=ON \
-DSANITIZE_UNDEFINED=OFF -DSANITIZE_ADDRESS=OFF \
-DCMAKE_C_FLAGS=-Werror -DCMAKE_CXX_FLAGS=-Werror \
-DPHYSIM_CHECK_FILES="ThresholdsGracehopper.cmake" \
.. && \
ninja ldpctest polartest smallblocktest nr_pbchsim nr_dlschsim nr_ulschsim nr_dlsim nr_ulsim nr_pucchsim nr_prachsim nr_psbchsim

View File

@@ -22,5 +22,5 @@ git config user.name "OAI Jenkins"
git config advice.detachedHead false
mkdir -p cmake_targets/log
git checkout -f ${ref}
[ -n "${merge}" ] && git merge --ff ${merge} -m "Temporary merge for CI"
[ -n "${merge}" ] && git fetch origin ${merge} && git merge --ff FETCH_HEAD -m "Temporary merge for CI"
exit 0

View File

@@ -1,7 +1,5 @@
#!/bin/bash
set -e
function die() { echo $@; exit 1; }
[ $# -eq 4 ] || die "usage: $0 <namespace> <release> <image tag> <oai directory>"
@@ -11,11 +9,17 @@ IMG_TAG=${3}
OAI_DIR=${4}
cat /opt/oc-password | oc login -u oaicicd --server https://api.oai.cs.eurecom.fr:6443 > /dev/null
set -x
oc project ${OC_NS} > /dev/null
oc tag oaicicd-ran/oai-physim:${IMG_TAG} ${OC_NS}/oai-physim:${IMG_TAG}
helm install ${OC_RELEASE} ${OAI_DIR}/charts/${OC_RELEASE} --set global.image.version=${IMG_TAG} --wait --timeout 120s
set +x
POD_ID=$(oc get pods | grep oai-${OC_RELEASE} | awk '{print $1}')
sleep 10
wait_creating=30
while [[ $(oc describe pod "$POD_ID" | grep "ContainerCreating") && ${wait_creating} > 0 ]]; do
sleep 1;
let wait_creating=$wait_creating-1
done
echo "Monitoring logs for 'FINISHED' in pod '$POD_ID'"
oc logs -f -n ${OC_NS} "$POD_ID" | while read -r line; do
if [[ "$line" == *"FINISHED"* ]]; then
@@ -27,6 +31,7 @@ oc logs -f -n ${OC_NS} "$POD_ID" | while read -r line; do
break
fi
done
set -x
oc logs -n ${OC_NS} "$POD_ID" >> ${OAI_DIR}/physim_log.txt
oc describe pod $POD_ID >> ${OAI_DIR}/physim_log.txt
helm uninstall ${OC_RELEASE} --wait

View File

@@ -134,8 +134,8 @@
<testCase id="030021">
<class>Iperf</class>
<desc>Iperf (DL/5Mbps/UDP)(30 sec)</desc>
<iperf_args>-u -b 5M -t 20 -R</iperf_args>
<desc>Iperf (DL/3Mbps/UDP)(30 sec)</desc>
<iperf_args>-u -b 3M -t 20 -R</iperf_args>
<id>rfsim5g_ue</id>
<nodes>acamas</nodes>
<svr_id>rfsim5g_ext_dn</svr_id>

View File

@@ -31,9 +31,6 @@
000002
000003
020001
020002
030001
030002
000004
040001
050001
@@ -110,7 +107,7 @@
<nodes>acamas</nodes>
<svr_id>rfsim5g_ue</svr_id>
<svr_node>acamas</svr_node>
<ping_args>-c 100 -i 0.25</ping_args>
<ping_args>-c 50 -i 0.25</ping_args>
<ping_packetloss_threshold>5</ping_packetloss_threshold>
</testCase>
@@ -121,7 +118,7 @@
<nodes>acamas</nodes>
<svr_id>rfsim5g_ext_dn</svr_id>
<svr_node>acamas</svr_node>
<ping_args>-c 100 -i 0.25</ping_args>
<ping_args>-c 50 -i 0.25</ping_args>
<ping_packetloss_threshold>10</ping_packetloss_threshold>
</testCase>

View File

@@ -36,18 +36,6 @@
102002
302002
102003
102004
102005
102006
102007
102008
102009
102010
102011
102012
102013
102014
102015
100100
100010
100020
@@ -118,80 +106,8 @@
<testCase id="102003">
<class>Attach_UE</class>
<desc>Attach UE 3</desc>
<id>amarisoft_ue_3</id>
</testCase>
<testCase id="102004">
<class>Attach_UE</class>
<desc>Attach UE 4</desc>
<id>amarisoft_ue_4</id>
</testCase>
<testCase id="102005">
<class>Attach_UE</class>
<desc>Attach (RedCap) UE 5</desc>
<id>amarisoft_ue_5</id>
</testCase>
<testCase id="102006">
<class>Attach_UE</class>
<desc>Attach (RedCap) UE 6</desc>
<id>amarisoft_ue_6</id>
</testCase>
<testCase id="102007">
<class>Attach_UE</class>
<desc>Attach UE 7</desc>
<id>amarisoft_ue_7</id>
</testCase>
<testCase id="102008">
<class>Attach_UE</class>
<desc>Attach UE 8</desc>
<id>amarisoft_ue_8</id>
</testCase>
<testCase id="102009">
<class>Attach_UE</class>
<desc>Attach UE 9</desc>
<id>amarisoft_ue_9</id>
</testCase>
<testCase id="102010">
<class>Attach_UE</class>
<desc>Attach (RedCap) UE 10</desc>
<id>amarisoft_ue_10</id>
</testCase>
<testCase id="102011">
<class>Attach_UE</class>
<desc>Attach (RedCap) UE 11</desc>
<id>amarisoft_ue_11</id>
</testCase>
<testCase id="102012">
<class>Attach_UE</class>
<desc>Attach (RedCap) UE 12</desc>
<id>amarisoft_ue_12</id>
</testCase>
<testCase id="102013">
<class>Attach_UE</class>
<desc>Attach UE 13</desc>
<id>amarisoft_ue_13</id>
</testCase>
<testCase id="102014">
<class>Attach_UE</class>
<desc>Attach UE 14</desc>
<id>amarisoft_ue_14</id>
</testCase>
<testCase id="102015">
<class>Attach_UE</class>
<desc>Attach (RedCap) UE 15</desc>
<id>amarisoft_ue_15</id>
<desc>Attach UE 3 - 15</desc>
<id>amarisoft_ue_3 amarisoft_ue_4 amarisoft_ue_5 amarisoft_ue_6 amarisoft_ue_7 amarisoft_ue_8 amarisoft_ue_9 amarisoft_ue_10 amarisoft_ue_11 amarisoft_ue_12 amarisoft_ue_13 amarisoft_ue_14 amarisoft_ue_15</id>
</testCase>
<testCase id="100010">

View File

@@ -0,0 +1,179 @@
<!--
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
-->
<testCaseList>
<htmlTabRef>LONGRUN-5G-NRUE</htmlTabRef>
<htmlTabName>Longrun 40 MHz TDD SA</htmlTabName>
<htmlTabIcon>tasks</htmlTabIcon>
<TestCaseRequestedList>
060000
010000 010001
800813
020000
800814
020001
000001
001000
000100
001000
000100
001000
000100
001000
000200
001000
000200
001000
000200
040001 040000
333333
444444
060001
</TestCaseRequestedList>
<TestCaseExclusionList></TestCaseExclusionList>
<testCase id="060000">
<class>DeployCoreNetwork</class>
<desc>Initialize 5G Core</desc>
<cn_id>oc-cn5g</cn_id>
</testCase>
<testCase id="010000">
<class>Pull_Cluster_Image</class>
<desc>Pull Images from Cluster</desc>
<images>oai-gnb</images>
<node>avra</node>
</testCase>
<testCase id="010001">
<class>Pull_Cluster_Image</class>
<desc>Pull Images from Cluster</desc>
<images>oai-nr-ue</images>
<node>caracal</node>
</testCase>
<testCase id="800813">
<class>Create_Workspace</class>
<desc>Create new Workspace</desc>
<node>avra</node>
</testCase>
<testCase id="020000">
<class>Deploy_Object</class>
<desc>Deploy gNB (TDD/Band78/40MHz/N310) in a container</desc>
<node>avra</node>
<yaml_path>ci-scripts/yaml_files/5g_sa_n310_gnb</yaml_path>
<num_attempts>3</num_attempts>
</testCase>
<testCase id="800814">
<class>Create_Workspace</class>
<desc>Create new Workspace</desc>
<node>caracal</node>
</testCase>
<testCase id="020001">
<class>Deploy_Object</class>
<desc>Deploy nrUE (TDD/Band78/40MHz/N310) in a container</desc>
<yaml_path>ci-scripts/yaml_files/5g_sa_n310_nrue</yaml_path>
<node>caracal</node>
<num_attempts>3</num_attempts>
</testCase>
<testCase id="000001">
<class>Attach_UE</class>
<desc>Attach OAIUE</desc>
<id>oai_ue_caracal</id>
</testCase>
<testCase id="000100">
<class>Iperf</class>
<desc>iperf (DL/10Mbps/UDP)(10 min)</desc>
<iperf_args>-u -b 10M -t 600 -i 1 -R</iperf_args>
<id>oai_ue_caracal</id>
<svr_id>oc-cn5g</svr_id>
<iperf_packetloss_threshold>25</iperf_packetloss_threshold>
<iperf_bitrate_threshold>80</iperf_bitrate_threshold>
</testCase>
<testCase id="000200">
<class>Iperf</class>
<desc>iperf (UL/2Mbps/UDP)(10 min)</desc>
<iperf_args>-u -b 2M -t 600 -i 1 </iperf_args>
<id>oai_ue_caracal</id>
<svr_id>oc-cn5g</svr_id>
<iperf_packetloss_threshold>25</iperf_packetloss_threshold>
<iperf_bitrate_threshold>80</iperf_bitrate_threshold>
</testCase>
<testCase id="001000">
<class>Ping</class>
<desc>Ping: 20pings in 20sec</desc>
<id>oai_ue_caracal</id>
<svr_id>oc-cn5g</svr_id>
<ping_args>-c 20</ping_args>
<ping_packetloss_threshold>1</ping_packetloss_threshold>
<ping_rttavg_threshold>25</ping_rttavg_threshold>
</testCase>
<testCase id="040000">
<class>Undeploy_Object</class>
<always_exec>true</always_exec>
<desc>Undeploy gNB</desc>
<node>avra</node>
<yaml_path>ci-scripts/yaml_files/5g_sa_n310_gnb</yaml_path>
<d_retx_th>20,100,100,100</d_retx_th>
<u_retx_th>20,100,100,100</u_retx_th>
</testCase>
<testCase id="040001">
<class>Undeploy_Object</class>
<always_exec>true</always_exec>
<desc>Undeploy nr UE</desc>
<node>caracal</node>
<yaml_path>ci-scripts/yaml_files/5g_sa_n310_nrue</yaml_path>
</testCase>
<testCase id="333333">
<class>Clean_Test_Server_Images</class>
<always_exec>true</always_exec>
<desc>Clean Test Images on Test Server</desc>
<node>avra</node>
<images>oai-gnb</images>
</testCase>
<testCase id="444444">
<class>Clean_Test_Server_Images</class>
<always_exec>true</always_exec>
<desc>Clean Test Images on Test Server</desc>
<node>caracal</node>
<images>oai-nr-ue</images>
</testCase>
<testCase id="060001">
<class>UndeployCoreNetwork</class>
<desc>Terminate 5G Core</desc>
<always_exec>true</always_exec>
<cn_id>oc-cn5g</cn_id>
</testCase>
</testCaseList>

View File

@@ -42,7 +42,7 @@
<class>Build_eNB</class>
<desc>Build gNB (USRP)</desc>
<node>caracal</node>
<Build_eNB_args>--gNB -w USRP --ninja -c -P --build-lib ldpc_cuda --build-lib ldpc_aal --cmake-opt -DASN1C_EXEC=/opt/asn1c/bin/asn1c</Build_eNB_args>
<Build_eNB_args>--gNB -w USRP --ninja -c -P --build-lib ldpc_cuda --build-lib ldpc_aal --cmake-opt -DASN1C_EXEC=/opt/asn1c/bin/asn1c --cmake-opt -DPHYSIM_CHECK_FILES="ThresholdsOffload.cmake"</Build_eNB_args>
</testCase>
<testCase id="100000">

View File

@@ -21,7 +21,7 @@
-->
<testCaseList>
<htmlTabRef>build-tab</htmlTabRef>
<htmlTabRef>physim-tab</htmlTabRef>
<htmlTabName>PhySim</htmlTabName>
<htmlTabIcon>wrench</htmlTabIcon>
<TestCaseRequestedList>
@@ -38,9 +38,9 @@
<testCase id="010201">
<class>Build_Deploy_Docker_PhySim</class>
<desc>Deploy and Deploy PhySim</desc>
<desc>Build and Deploy PhySim</desc>
<node>localhost</node>
<ctest-opt>-R 5g -E physim.5g.nr_dlsim.mcs.mimo.test9 -j16</ctest-opt> <!-- one nr_dlsim test fails on ARM -->
</testCase>
<ctest-opt>-R 5g -E "nr_dlsim|nr_ulsim|ldpctest" -j32</ctest-opt> <!-- one nr_dlsim test fails on ARM -->
</testCase>
</testCaseList>

View File

@@ -0,0 +1,46 @@
<!--
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
-->
<testCaseList>
<htmlTabRef>physim-timed-tab</htmlTabRef>
<htmlTabName>PhySim with timing check</htmlTabName>
<htmlTabIcon>wrench</htmlTabIcon>
<TestCaseRequestedList>
800813
010202
</TestCaseRequestedList>
<TestCaseExclusionList></TestCaseExclusionList>
<testCase id="800813">
<class>Create_Workspace</class>
<desc>Create new Workspace</desc>
<node>localhost</node>
</testCase>
<testCase id="010202">
<class>Build_Deploy_Docker_PhySim</class>
<desc>Build and Deploy PhySim with timing check</desc>
<node>localhost</node>
<ctest-opt>-R 5g -R "nr_dlsim|nr_ulsim|ldpctest" -E physim.5g.nr_dlsim.mcs.mimo.test9 -j1</ctest-opt> <!-- one nr_dlsim test fails on ARM -->
</testCase>
</testCaseList>

View File

@@ -39,7 +39,6 @@
#include <stdint.h>
#include <stdbool.h>
#include "common/config/config_paramdesc.h"
#include "common/utils/T/T.h"
#define CONFIG_MAX_OOPT_PARAMS 10 // maximum number of parameters in the -O option (-O <cfgmode>:P1:P2...
#define CONFIG_MAX_ALLOCATEDPTRS 32768 // maximum number of parameters that can be dynamicaly allocated in the config module

View File

@@ -8,11 +8,11 @@ else()
endif()
add_library(params_yaml_static config_yaml.cpp)
target_link_libraries(params_yaml_static PUBLIC UTIL yaml-cpp::yaml-cpp)
target_link_libraries(params_yaml_static PUBLIC yaml-cpp::yaml-cpp)
if (ENABLE_TESTS)
add_subdirectory(tests)
endif()
add_library(params_yaml MODULE config_yaml.cpp)
target_link_libraries(params_yaml PUBLIC UTIL yaml-cpp::yaml-cpp)
target_link_libraries(params_yaml PUBLIC yaml-cpp::yaml-cpp)
set_target_properties(params_yaml PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})

View File

@@ -1,5 +1,5 @@
add_executable(test_yaml_config test_yaml_config.cpp)
target_link_libraries(test_yaml_config PRIVATE params_yaml_static GTest::gtest)
target_link_libraries(test_yaml_config PRIVATE params_yaml_static GTest::gtest CONFIG_LIB)
add_dependencies(tests test_yaml_config)
add_test(NAME test_yaml_config
COMMAND ./test_yaml_config)

View File

@@ -4,10 +4,12 @@ target_link_libraries(log_headers INTERFACE T_headers)
set(log_sources log.c)
if (ENABLE_LTTNG)
find_package(LTTngUST 2.3.8 EXACT REQUIRED)
set(log_sources ${log_sources} lttng-tp.c)
else()
message(STATUS "LTTNG support disabled")
endif()
add_library(LOG ${log_sources})
target_include_directories(LOG PUBLIC .)
target_link_libraries(LOG PRIVATE CONFIG_LIB)
target_link_libraries(LOG PUBLIC log_headers)
if (ENABLE_LTTNG)

View File

@@ -52,6 +52,7 @@
#endif
#include <pthread.h>
#include <common/utils/utils.h>
#include "common/utils/T/T.h"
#if ENABLE_LTTNG
#include "lttng-log.h"
#endif

View File

@@ -47,7 +47,7 @@ add_custom_target(generate_T DEPENDS T_IDs.h check_vcd)
# even if T is off, we need the headers as many targets depend on it
# for this, create an INTERFACE (header-only) library T_headers. To ensure the
# headers have really been created, we make this headers library explicitly
# depend on the generated headers.
# depend on the generate_T target.
add_library(T_headers INTERFACE)
add_dependencies(T_headers T_IDs.h generate_T)
target_include_directories(T_headers INTERFACE ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})

View File

@@ -143,6 +143,10 @@ ID = GNB_PHY_UL_TIME_CHANNEL_ESTIMATE
DESC = gNodeB channel estimation in the time domain
GROUP = ALL:PHY:GRAPHIC:HEAVY:GNB
FORMAT = int,gNB_ID : int,rnti : int,frame : int,subframe : int,antenna : buffer,chest_t
ID = GNB_PHY_UL_SNR_ESTIMATE
DESC = gNodeB SNR estimation based on SRS
GROUP = ALL:PHY:GRAPHIC:HEAVY:GNB
FORMAT = int,gNB_ID : int,rnti : int,frame : int,subframe : int,antenna : buffer,snr
ID = GNB_PHY_PRACH_INPUT_SIGNAL
DESC = gNodeB input data in the time domain for slots with PRACH detection
GROUP = ALL:PHY:GRAPHIC:HEAVY:GNB

View File

@@ -19,6 +19,7 @@ typedef struct {
widget *pucch_pusch_iq_plot;
widget *ul_freq_estimate_ue_xy_plot;
widget *ul_time_estimate_ue_xy_plot;
widget *ul_snr_estimate_ue_xy_plot;
widget *current_ue_label;
widget *current_ue_button;
widget *prev_ue_button;
@@ -26,6 +27,7 @@ typedef struct {
logger *pucch_pusch_iq_logger;
logger *ul_freq_estimate_ue_logger;
logger *ul_time_estimate_ue_logger;
logger *ul_snr_ue_logger;
} gnb_gui;
typedef struct {
@@ -98,6 +100,9 @@ static void set_current_ue(gui *g, gnb_data *e, int ue)
sprintf(s, "UL channel estimation in time domain [UE %d]", ue);
xy_plot_set_title(g, e->e->ul_time_estimate_ue_xy_plot, s);
sprintf(s, "UL SNR per RB based on SRS [UE %d]", ue);
xy_plot_set_title(g, e->e->ul_snr_estimate_ue_xy_plot, s);
}
void reset_ue_ids(void)
@@ -146,12 +151,13 @@ static void gnb_main_gui(gnb_gui *e, gui *g, event_handler *h, void *database, g
logger *l;
view *v;
main_window = new_toplevel_window(g, 1500, 230, "gNB tracer");
main_window = new_toplevel_window(g, 1500, 460, "gNB tracer");
top_container = new_container(g, VERTICAL);
widget_add_child(g, main_window, top_container, -1);
line = new_container(g, HORIZONTAL);
widget_add_child(g, top_container, line, -1);
logo = new_image(g, openair_logo_png, openair_logo_png_len);
/* logo + prev/next UE buttons */
@@ -206,6 +212,21 @@ static void gnb_main_gui(gnb_gui *e, gui *g, event_handler *h, void *database, g
logger_add_view(l, v);
e->ul_time_estimate_ue_logger = l;
line = new_container(g, HORIZONTAL);
widget_add_child(g, top_container, line, -1);
/* UL SNR based on SRS */
w = new_xy_plot(g, 1280, 200, "", 190);
e->ul_snr_estimate_ue_xy_plot = w;
widget_add_child(g, line, w, -1);
xy_plot_set_range(g, w, 0, 273, -10, 65);
l = new_framelog(h, database, "GNB_PHY_UL_SNR_ESTIMATE", "subframe", "snr");
framelog_set_update_only_at_sf9(l, 0);
framelog_set_type_buffer_db(l);
v = new_view_xy(273, 10, g, w, new_color(g, "#0c0c72"), XY_LOOP_MODE);
logger_add_view(l, v);
e->ul_snr_ue_logger = l;
set_current_ue(g, ed, ed->ue);
register_notifier(g, "click", e->current_ue_button, click, ed);
register_notifier(g, "click", e->prev_ue_button, click, ed);
@@ -251,6 +272,7 @@ int main(int n, char **v)
on_off(database, "GNB_PHY_PUCCH_PUSCH_IQ", is_on, 1);
on_off(database, "GNB_PHY_UL_FREQ_CHANNEL_ESTIMATE", is_on, 1);
on_off(database, "GNB_PHY_UL_TIME_CHANNEL_ESTIMATE", is_on, 1);
on_off(database, "GNB_PHY_UL_SNR_ESTIMATE", is_on, 1);
gnb_data.ue = 0;
gnb_data.e = &eg;

View File

@@ -8,6 +8,11 @@
#include <stdio.h>
#include <math.h>
typedef enum {
FRAMELOG_BUFFER,
FRAMELOG_BUFFER_dB,
} framelog_buffer_type_t;
struct framelog {
struct logger common;
void *database;
@@ -22,6 +27,7 @@ struct framelog {
int skip_current; /* internal data for the skip mechanism */
int skip_on; /* internal data for the skip mechanism */
int update_only_at_sf9;
framelog_buffer_type_t type;
};
static void _event(void *p, event e)
@@ -52,7 +58,10 @@ static void _event(void *p, event e)
}
if (l->skip_on) return;
nsamples = bsize / (2*sizeof(int16_t));
if (l->type == FRAMELOG_BUFFER)
nsamples = bsize / (2 * sizeof(int16_t));
else
nsamples = bsize / sizeof(int16_t);
if (l->blength != nsamples * 10) {
l->blength = nsamples * 10;
@@ -71,10 +80,15 @@ static void _event(void *p, event e)
}
/* TODO: compute the LOGs in the plotter (too much useless computations) */
for (i = 0; i < nsamples; i++) {
int I = ((int16_t *)buffer)[i*2];
int Q = ((int16_t *)buffer)[i*2+1];
l->buffer[subframe * nsamples + i] = 10*log10(1.0+(float)(I*I+Q*Q));
if (l->type == FRAMELOG_BUFFER_dB) {
for (i = 0; i < nsamples; i++)
l->buffer[subframe * nsamples + i] = ((int16_t *)buffer)[i];
} else {
for (i = 0; i < nsamples; i++) {
int I = ((int16_t *)buffer)[i * 2];
int Q = ((int16_t *)buffer)[i * 2 + 1];
l->buffer[subframe * nsamples + i] = 10 * log10(1.0 + (float)(I * I + Q * Q));
}
}
if (l->update_only_at_sf9 == 0 || subframe == 9)
@@ -132,6 +146,8 @@ logger *new_framelog(event_handler *h, void *database,
abort();
}
ret->type = FRAMELOG_BUFFER;
return ret;
}
@@ -153,3 +169,9 @@ void framelog_set_update_only_at_sf9(logger *_this, int update_only_at_sf9)
struct framelog *l = _this;
l->update_only_at_sf9 = update_only_at_sf9;
}
void framelog_set_type_buffer_db(logger *_this)
{
struct framelog *l = _this;
l->type = FRAMELOG_BUFFER_dB;
}

View File

@@ -30,6 +30,7 @@ logger *new_iqdotlog(void *event_handler, void *database,
void framelog_set_skip(logger *_this, int skip_delay);
void framelog_set_update_only_at_sf9(logger *_this, int update_only_at_sf9);
void framelog_set_type_buffer_db(logger *_this);
void textlog_dump_buffer(logger *_this, int dump_buffer);
void textlog_raw_time(logger *_this, int raw_time);

View File

@@ -25,52 +25,6 @@
#include "common/utils/mem/oai_memory.h"
#include "common/utils/LOG/log.h"
/****************************************************************************
** **
** Name: memory_get_path() **
** **
** Description: Gets the absolute path of the file where non-volatile **
** data are located **
** **
** Inputs: dirname: The directory where data file is located **
** filename: The name of the data file **
** Others: None **
** **
** Outputs: None **
** Return: The absolute path of the non-volatile data **
** file. The returned value is a dynamically **
** allocated octet string that needs to be **
** freed after usage. **
** Others: None **
** **
***************************************************************************/
char* memory_get_path(const char* dirname, const char* filename)
{
/* Get non-volatile data directory */
const char* path = getenv(dirname);
if (path == NULL) {
path = getenv(DEFAULT_NAS_PATH);
}
if (path == NULL) {
path = ".";
}
/* Append non-volatile data file name */
size_t size = strlen(path) + strlen(filename) + 1;
char* data_filename = (char*)malloc(size + 1);
if (data_filename != NULL) {
if (size != sprintf(data_filename, "%s/%s", path, filename)) {
free(data_filename);
return NULL;
}
}
return data_filename;
}
char* memory_get_path_from_ueid(const char* dirname, const char* filename, int ueid)
{
/* Get non-volatile data directory */

View File

@@ -35,8 +35,6 @@ typedef unsigned char uint8_t;
//-----------------------------------------------------------------------------
char* memory_get_path(const char* dirname, const char* filename);
char* memory_get_path_from_ueid(const char* dirname, const char* filename, int ueid);
int memory_read(const char* datafile, void* data, size_t size);

View File

@@ -88,8 +88,6 @@ static inline const char *rnti_types(nr_rnti_type_t rr)
#define NR_NUMBER_OF_SYMBOLS_PER_SLOT_EXTENDED_CP 12
#define NR_MAX_NB_LAYERS 4 // 8
#define BOUNDED_EVAL(a, b, c) (min(c, max(a, b)))
// Since the IQ samples are represented by SQ15 R+I (see https://en.wikipedia.org/wiki/Q_(number_format)) we need to compensate when
// calcualting signal energy. Instead of shifting each sample right by 15, we can normalize the result in dB scale once its
// calcualted. Signal energy is calculated using RMS^2, where each sample is squared before taking the average of the sum, therefore

View File

@@ -44,7 +44,7 @@ add_library(telnetsrv_enb MODULE
telnetsrv_enb_phycmd.c
)
add_dependencies(telnetsrv telnetsrv_enb)
target_link_libraries(telnetsrv_enb PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs)
target_link_libraries(telnetsrv_enb PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs log_headers)
message(STATUS "No specific telnet functions for gnb")

View File

@@ -52,7 +52,7 @@ int main(int argc, char *argv[]) {
while ( 1 ) {
if ( read(fd,&doneRequest, sizeof(doneRequest)) == sizeof(doneRequest)) {
printf("%lu" SEP "%lu" SEP "%lu" SEP "%lu" "\n",
printf("%lu" SEP "%llu" SEP "%llu" SEP "%llu" "\n",
doneRequest.key,
(doneRequest.startProcessingTime-doneRequest.creationTime)/cpuCyclesMicroSec,
(doneRequest.endProcessingTime-doneRequest.startProcessingTime)/cpuCyclesMicroSec,

View File

@@ -7,7 +7,7 @@ add_library(time_management_core OBJECT
time_client.c)
target_link_libraries(time_management PUBLIC time_management_core)
target_link_libraries(time_management_core PRIVATE ${T_LIB})
target_link_libraries(time_management_core PRIVATE log_headers)
if(ENABLE_TESTS)
add_subdirectory(tests)

View File

@@ -51,7 +51,7 @@ PROJECT_BRIEF = "Full experimental OpenSource LTE and NR implementation
# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy
# the logo to the output directory.
PROJECT_LOGO = @CMAKE_SOURCE_DIR@/doc/oai_logo.png
PROJECT_LOGO = @CMAKE_SOURCE_DIR@/doc/images/oai_logo.png
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path
# into which the generated documentation will be written. If a relative path is

View File

@@ -1,6 +1,6 @@
[[_TOC_]]
# 1. Introduction
## 1. Introduction
E1 is the interface that lies between the nodes CU Control Plane (CUCP) and CU User Plane (CUUP). Once the nodes are configured, all user plane traffic flows through CUUP.
@@ -77,11 +77,11 @@ sequenceDiagram
```
More details about the E1AP procedures in OAI are available in this document: [E1 Procedures](./e1ap_procedures.md).
# 2. Running the E1 Split
## 2. Running the E1 Split
The setup is assuming that all modules are running on the same machine. The user can refer to the [F1 design document](./../F1AP/F1-design.md) for local deployment of the DU.
## 2.1 Configuration File
### 2.1 Configuration File
The gNB is started based on the node type that is specified in the configuration file. The following parameters must be configured accordingly.
@@ -130,9 +130,9 @@ The CUUP uses the IP address specified in `gNBs.[0].local_s_address` for F1-U an
Alternatively, you can use the config files `ci-scripts/conf_files/gnb-cucp.sa.f1.conf` and `ci-scripts/conf_files/gnb-cuup.sa.f1.conf`.
## 2.2 Steps to Run the Split in rfsimulator with OAI UE
### 2.2 Steps to Run the Split in rfsimulator with OAI UE
Note: A 5G core must be running at this point. Steps to start the OAI 5G core can be found [in the oai-cn5g-fed repository](https://gitlab.eurecom.fr/oai/cn5g/oai-cn5g-fed/-/blob/master/docs/DEPLOY_HOME.md) or [here](NR_SA_CN5G_gNB_USRP_COTS_UE_Tutorial.md).
Note: A 5G core must be running at this point. Steps to start the OAI 5G core can be found [in the oai-cn5g-fed repository](https://gitlab.eurecom.fr/oai/cn5g/oai-cn5g-fed/-/blob/master/docs/DEPLOY_HOME.md) or [here](../NR_SA_Tutorial_OAI_CN5G.md).
0. Open wireshark to capture the E1AP messages. You might set the capture filter
to `sctp` to limit the number of captured packages.
@@ -165,7 +165,7 @@ OAI UE:
sudo ./nr-uesoftmodem -r 106 --numerology 1 --band 78 -C 3619200000 --rfsim --rfsimulator.serveraddr 127.0.0.1
```
# 3. Configuration file IP addresses of network functions
## 3. Configuration file IP addresses of network functions
You can also run the nodes on different machines. If you do so please change the interface parameters accordingly and make sure the interfaces are reachable. Please refer to the following figure for an overview of all parameters.
@@ -173,7 +173,7 @@ You can also run the nodes on different machines. If you do so please change the
[PDF version](./images/e1-archi.pdf) | [LaTeX/TikZ version](./images/e1-archi.tex) if you want to modify to reflect your setup
# 4. Multiple CU-UP
## 4. Multiple CU-UP
It is possible to connect multiple CU-UP to the same CU-CP. In the handler of
the E1 Setup Request, the CU-CP verifies that the PLMN(s) (MCC, MNC) between
@@ -195,6 +195,6 @@ that you have to restart the CU-CP if you want to connect the CU-UP again
(e.g., after a crash). The CU-CP might also misfunction during attach if a
CU-UP was connected, but disconnected in the meantime.
# 5. Abnormal conditions
## 5. Abnormal conditions
* The CU-UP goes offline during normal operation (e.g. UEs have a valid PDU Session and are exchanging data on the UP): after restarting the CU-UP, the UP is not restored and the user will notice GTP errors. In this case the UEs have to reconnect.

View File

@@ -2,7 +2,7 @@
<tr style="border-collapse: collapse; border: none;">
<td style="border-collapse: collapse; border: none;">
<a href="http://www.openairinterface.org/">
<img src="./images/oai_final_logo.png" alt="" border=3 height=50 width=150>
<img src="../images/oai_final_logo.png" alt="" border=3 height=50 width=150>
</img>
</a>
</td>
@@ -14,7 +14,7 @@
[[_TOC_]]
# Introduction
## Introduction
The F1 interface is the functional split of 3GPP between the CU (centralized
unit: PDCP, RRC, SDAP) and the DU (distributed unit: RLC, MAC, PHY). It is
@@ -33,17 +33,17 @@ F1-U:
No equivalent for 4G exists.
## Control plane (F1-C)
### Control plane (F1-C)
The interface F1-C is designed for the exchange of signalling messages between the
Radio Network Layer (RNL) and the Transport Network Layer (TNL). It
consists of F1 Application Protocol messages (F1-AP) exchanged over SCTP.
## Data plane (F1-U)
### Data plane (F1-U)
F1-U uses GTP-U for information exchange.
# OAI Implementation Status
## OAI Implementation Status
The implementation of F1AP messages is seamlessly integrated into OAI, supporting both Monolithic SA
and CU/DU functional split modes. The F1 code is therefore always compiled with nr-softmodem.
@@ -63,13 +63,13 @@ This is the current status:
- Not supported:
* NSA
## F1-C
### F1-C
### F1AP messages
#### F1AP messages
Refer to [FEATURE_SET.md](FEATURE_SET.md#gNB-F1AP) to learn about the current F1AP implementation status.
Refer to [FEATURE_SET.md](../FEATURE_SET.md#gnb-f1ap) to learn about the current F1AP implementation status.
### High-level F1-C code structure
#### High-level F1-C code structure
The F1 interface is used internally between CU (mostly RRC) and DU (mostly MAC)
to exchange information. In DL, the CU sends messages as defined by the
@@ -170,7 +170,7 @@ sequenceDiagram
TASK_MAC_GNB->>+TASK_RRC_GNB: raw F1AP message (ITTI)
```
## F1-U
### F1-U
Current status:
@@ -178,7 +178,7 @@ Current status:
* Each packet is acknowledged individually
* Support of multiple DUs per CU
# How to run
## How to run
As mentioned earlier, OAI uses F1 internally. It is always compiled in.
To start CU/DU, you use `./nr-softmodem` with the appropriate configuration
@@ -190,7 +190,7 @@ sudo cmake_targets/ran_build/build/nr-softmodem -O ci-scripts/conf_files/gnb-du.
```
These files are tested in the CI, and are configured for use in docker,
see [this `docker-compose` file](../ci-scripts/yaml_files/5g_f1_rfsimulator/docker-compose.yaml).
see [this `docker-compose` file](../../ci-scripts/yaml_files/5g_f1_rfsimulator/docker-compose.yaml).
The rules to decide if a config triggers a start of a DU, CU, or monolithic
gNB, are, in order:
@@ -200,7 +200,7 @@ gNB, are, in order:
(`tr_s_preference`), it is a CU.
3. It is a (monolithic) gNB.
## F1 IP configuration for Local network deployment of F1
### F1 IP configuration for Local network deployment of F1
The following paragraphs explain the IP configuration for F1 in the OAI config
files on the example of a a local deployment. We assume that the CU will bind
@@ -242,7 +242,7 @@ the options `MACRLCs.[0].local_n_address` and
`MACRLCs.[0].local_n_address_f1u`, respectively. Note that this is not foreseen
for the CU; in the case of the CU, please use separate CU-UP and CU-CP.
## Configuration of multiple DUs
### Configuration of multiple DUs
Upon F1 Setup Request of a new DU, the CU cross-checks that
@@ -260,9 +260,9 @@ You have to of course make sure that the local interface of the DU
Assuming you use RFsim, you should make the RFsimulator server side (typically
the gNB) bind on different hosts (`rfsimulator.serverport`).
# Code documentation
## Code documentation
## Common multi-threading architecture
### Common multi-threading architecture
The CU and DU interfaces are based on ITTI threads (see `common/utils/ocp_itti/itti.md`)
adopted by all OAI upper layers to run isolated threads dedicated to one feature.
@@ -301,7 +301,7 @@ All GTP-U tunnels are managed in a Linux Thread, that have partially ITTI design
3. incoming packets are sent to the tunnel creator using a C callback (the callback function is given in tunnel creation order). The callback should not block
## F1-C messages towards the CU
### F1-C messages towards the CU
The CU thread starts when the CU starts. It opens listening socket on the
configuration-specified IP/port by sending the appropriate message to
@@ -332,7 +332,7 @@ You might also want to consult TS 38.401 regarding the message exchange.
| UE Context Release Request | `F1AP_UE_CONTEXT_RELEASE_REQ` | `rrc_CU_process_ue_context_release_request()` | RRC will trigger UE release |
| UE Context Release Complete | `F1AP_UE_CONTEXT_RELEASE_COMPLETE` | `rrc_CU_process_ue_context_release_complete()` | frees UE Context, signals to NGAP |
## F1-C Messages towards the DU
### F1-C Messages towards the DU
The task "gNB app", after reading the configuration file, sends a message
`F1AP_DU_REGISTER_REQ` to the DU task. This message contains network
@@ -371,9 +371,9 @@ You might also want to consult TS 38.401 regarding the message exchange.
a reconfiguration has to be triggered if the CU receives a CellGroupConfig,
originating at the DU. See also flag `expect_reconfiguration`.
## F1-U messages
### F1-U messages
### General
#### General
In the DU in UL, RLC checks in `deliver_sdu()` if we are operating in split
mode, and either (direct) calls `pdcp_data_ind` (DRB) or (f1ap) sends a GTP
@@ -390,7 +390,7 @@ In the DU in DL, assuming the GTP-U tunnel exists, GTP decapsulates the packet
and calls the reception call back `nr_rlc_data_req()`, which enqueues the
packet into the UE's RLC buffer.
## Tunnel Setup
### Tunnel Setup
In GTP-U, TS 29.281 specifies a optional header (NR RAN Container). This
extension header may be transmitted in a G-PDU over the X2-U, Xn-U and F1-U user

View File

@@ -2,7 +2,7 @@
<tr style="border-collapse: collapse; border: none;">
<td style="border-collapse: collapse; border: none;">
<a href="http://www.openairinterface.org/">
<img src="./images/oai_final_logo.png" alt="" border=3 height=50 width=150>
<img src="../images/oai_final_logo.png" alt="" border=3 height=50 width=150>
</img>
</a>
</td>

View File

@@ -11,12 +11,12 @@
- FAPI (IF2) : specified by Small Cell Forum (open-nFAPI implementation)
- IF1 : F1 in 3GPP Release 15
![Functional Split Architecture](./oai_enb_func_split_arch.png)
![Functional Split Architecture](./images/oai_enb_func_split_arch.png)
# OpenAirInterface Block Diagram #
![Block Diagram](./oai_enb_block_diagram.png)
![Block Diagram](./images/oai_enb_block_diagram.png)
# OpenAirInterface 5G-NR Feature Set #
@@ -25,7 +25,7 @@
The following features are valid for the gNB and the 5G-NR UE.
* Static TDD
- Multi TDD pattern supported refer [TDD Configuration](NR_SA_Multi_TDD_Pattern.md)
- Multi TDD pattern supported refer [TDD Configuration](MAC/mac-usage.md)
* Static FDD
* Normal CP
* Subcarrier spacings: 15 and 30kHz (FR1), 120kHz (FR2)

View File

@@ -183,7 +183,7 @@ See [nFAPI documentation](../nfapi.md) or [Aerial
tutorial](../Aerial_FAPI_Split_Tutorial.md) for information about the (n)FAPI
split.
See [F1 documentation](../F1-design.md) for information about the F1 split.
See [F1 documentation](../F1AP/F1-design.md) for information about the F1 split.
## MAC scheduler-related configuration options

View File

@@ -52,7 +52,7 @@ There is some general information in the [OpenAirInterface Gitlab Wiki](https://
* IF setups and arbitrary frequencies
* MIMO
- [How to run OAI with O-RAN 7.2 FHI](./ORAN_FHI7.2_Tutorial.md)
- [How to run a 5G-NSA setup](./TESTING_GNB_W_COTS_UE.md)
- [How to run a 5G-NSA setup](./TESTING_OAI_NSA_COTS_UE.md)
- [How to run a 4G setup using L1 simulator](./L1SIM.md) _Note: we recommend the RFsimulator_
- [How to use the L2 simulator](./L2NFAPI.md)
- [How to use the OAI channel simulator](../openair1/SIMULATION/TOOLS/DOC/channel_simulation.md)
@@ -60,7 +60,7 @@ There is some general information in the [OpenAirInterface Gitlab Wiki](https://
- [How to run OAI-VNF and OAI-PNF](./nfapi.md): how to run the FAPI/nFAPI split,
including some general remarks on FAPI/nFAPI.
- [How to use the positioning reference signal (PRS)](./RUN_NR_PRS.md)
- [How to use device-to-device communication (D2D, 4G)](./d2d_emulator_setup.txt)
- [How to use device-to-device communication (D2D, 4G)](./d2d_emulator_setup.md)
- [How to run with E2 agent](../openair2/E2AP/README.md)
- [How to run the physical simulators](./physical-simulators.md)
- [How to setup OAI with Nvidia Aerial and Foxconn](./Aerial_FAPI_Split_Tutorial.md)
@@ -71,8 +71,6 @@ There is some general information in the [OpenAirInterface Gitlab Wiki](https://
Legacy unmaintained files:
- [`L2NFAPI_NOS1.md`](./L2NFAPI_NOS1.md), [`L2NFAPI_S1.md`](./L2NFAPI_S1.md):
old L2simulator, not valid anymore
- [`SystemX-tutorial-design.md`](./SystemX-tutorial-design.md): old, high-level
documentation
- [`UL_MIMO.txt`](./UL_MIMO.txt): UL-MIMO specific notes
# Designs

View File

@@ -12,7 +12,7 @@ The RRC layer controls the basic connection setup of UEs as well as additional
procedures. It is the fundamental building block of OAI's CU-CP, and interacts
with lower layers (DU, basically MAC and RLC) through F1AP messages, and with
the CU-UP through E1AP messages. More information can be found in the
respective [F1AP page](../F1-design.md) and [E1AP page](../E1AP/E1-design.md).
respective [F1AP page](../F1AP/F1-design.md) and [E1AP page](../E1AP/E1-design.md).
# Periodic output and interpretation
@@ -57,7 +57,7 @@ As of now, it does not print information about connected CU-UPs or AMFs.
## Split-related options (when running in a CU or CU-CP)
See [F1 documentation](../F1-design.md) for information about the F1 split.
See [F1 documentation](../F1AP/F1-design.md) for information about the F1 split.
See [E1 documentation](../E1AP/E1-design.md) for information about the E1 split.
## RRC-specific configuration options
@@ -99,26 +99,43 @@ the [MAC configuration](../MAC/mac-usage.md) as well for SIB configuration.
### Neighbor-gNB configuration
#### What is a gNB neighbor?
Network continuity is a key aspect of 5G. In the 5G architecture, gNB neighbors play a central role in maintaining service continuity through mechanisms such as handover and load balancing. By definition, a gNB neighbor is another gNB that can be measured and linked by the UE. If the current serving gNB is no longer optimal, the UE may connect to a neighbor gNB.
To support this behavior, the network configuration specifies additional frequencies and cells that the UE should measure. The UE reports these measurements to the network, which then decides whether or not to initiate a handover.
Neighbor types include:
- **Intra-gNB neighbors** - cells belonging to the same gNB
- **Inter-gNB neighbors** - cells belonging to different gNBs
- **Inter-RAT neighbors** - cells belonging to another RAT (e.g., LTE)
Refer to the [handover tutorial](../handover-tutorial.md) for detailed information about gNB neighbors and handover procedures.
#### Required configuration parameters
To define a neighbor cell in the configuration file, the following parameters are typically needed:
- **gNB ID** - unique identifier of the gNB
- **Cell ID** - identifier of the cell within the gNB
- **Physical Cell ID** - identifier of the cells synchronization signal (PCI)
- **Absolute Frequency** - frequency used by the SSB (absoluteFrequencySSB)
- **Subcarrier Spacing** - numerology (e.g., 15 kHz, 30 kHz)
- **PLMN configuration** - MCC, MNC, and MNC length
- **Tracking Area Code (TAC)** - identifier of the tracking area
To define a neighbor cell in the configuration file, the following parameters are required:
Refer to the [handover tutorial](../handover-tutorial.md) for more information.
- `gNB_ID` - identifier of the neighbor gNB (e.g., `0xe01`)
- `nr_cellid` - cell identifier of the neighbor cell (e.g., `11111111`)
- `physical_cellId` - physical cell ID for radio identification (e.g., `1`)
- `absoluteFrequencySSB` - SSB frequency in ARFCN notation (e.g., `643296`)
- `subcarrierSpacing` - numerology index: 0=15kHz, 1=30kHz, 2=60kHz, 3=120kHz
- `band` - 3GPP frequency band number (e.g., `78` for 3.5GHz)
- `plmn` - PLMN configuration object with:
- `mcc` - mobile country code (3 digits, e.g., `001`)
- `mnc` - mobile network code (2-3 digits, e.g., `01`)
- `mnc_length` - number of digits in MNC (must be `2` or `3`)
- `tracking_area_code` - tracking area identifier (e.g., `1`)
Example configuration structure:
```
neighbour_list = (
{
nr_cellid = 12345678;
neighbour_cell_configuration = (
{
gNB_ID = 0xe01;
nr_cellid = 11111111;
physical_cellId = 1;
absoluteFrequencySSB = 643296;
subcarrierSpacing = 1; # 30 kHz
band = 78;
plmn = { mcc = 001; mnc = 01; mnc_length = 2 };
tracking_area_code = 1;
}
);
}
);
```
Refer to the [handover tutorial](../handover-tutorial.md) for complete examples and detailed setup instructions.

View File

@@ -1,143 +0,0 @@
# OpenAirInterface for SystemX
# Terminology
****This document use the 5G terminology****
**Central Unit (CU):** It is a logical node that includes the gNB
functions like Transfer of user data, Mobility control, Radio access
network sharing, Positioning, Session Management etc., except those
functions allocated exclusively to the DU. CU controls the operation of
DUs over front-haul (Fs) interface. A central unit (CU) may also be
known as BBU/REC/RCC/C-RAN/V-RAN/VNF
**Distributed Unit (DU):** This logical node includes a subset of the
gNB functions, depending on the functional split option. Its operation
is controlled by the CU. Distributed Unit (DU) also known with other
names like RRH/RRU/RE/RU/PNF.
In OpenAir code, the terminology is often RU and BBU.
# OpenAirUsage
## EPC and general environment
### OAI EPC
Use the stable OAI EPC, that can run in one machine (VM or standalone)
Draft description:
<https://open-cells.com/index.php/2017/08/22/all-in-one-openairinterface-august-22nd/>
## Standalone 4G
EPC+eNB on one machine, the UE can be commercial or OAI UE.
### USRP B210
Main current issue: traffic is good only on coaxial link between UE and
eNB (probably power management issue).
### Simulated RF
Running eNB+UE both OAI can be done over a virtual RF link.
The UE current status is that threads synchronization is implicit in
some cases. As the RF simulator is very quick, a “sleep()” is required
in the UE main loop
(line 1744, targets/RT/USER/lte-ue.c).
Running also the UE in the same machine is possible with simulated RF.
Running in same machine is simpler, offers about infinite speed for
virtual RF samples transmission.
A specific configuration is required because the EPC Sgi interface has
the same IP tunnel end point as the UE.
So, we have to create a network namespace for the UE and to route data
in/out of the namespace.
```bash
ip netns delete aNameSpace 2&gt; /dev/null
ip link delete v-eth1 2&gt; /dev/null
ip netns add aNameSpace
ip link add v-eth1 type veth peer name v-peer1
ip link set v-peer1 netns aNameSpace
ip addr add 10.200.1.1/24 dev v-eth1
ip link set v-eth1 up
iptables -t nat -A POSTROUTING -s 10.200.1.0/255.255.255.0 -o enp0s31f6 \
-j MASQUERADE
iptables -A FORWARD -i enp0s31f6 -o v-eth1 -j ACCEPT
iptables -A FORWARD -o enp0s31f6 -i v-eth1 -j ACCEPT
ip netns exec aNameSpace ip link set dev lo up
ip netns exec aNameSpace ip addr add 10.200.1.2/24 dev v-peer1
ip netns exec aNameSpace ip link set v-peer1 up
ip netns exec aNameSpace bash
```
After the last command, the Linux shell is in the new namespace, ready
to run the UE.
To make user plan traffic, the traffic generator has to run in the same
namespace
```bash
ip netns exec aNameSpace bash
```
The traffic genenrator has to specify the interface:
```bash
route add default oaitun_ue1
```
or specify the outgoing route in the traffic generator (like option “-I”
in ping command).
## 5G and F1
Today 5G achievement is limited to physical layer.
The available modulation is 40MHz, that require one X310 or N300 for the
gNB and a X310 or N300 for the nrUE.
### Usage with X310
Linux configuration:
<https://files.ettus.com/manual/page_usrp_x3x0_config.html>
We included most of this configuration included in OAI source code.
Remain to set the NIC (network interface card) MTU to 9000 (jumbo
frames).
### Running 5G
Usage with RFsimulator:
**gNB**
```bash
sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf
```
**nrUE**
```bash
sudo ./nr-uesoftmodem --numerology 1 -r 106 -C 3510000000 -d --rfsimulator.serveraddr 127.0.0.1
```

View File

@@ -7,12 +7,12 @@ STATUS 2020/10/15 : added External Resources section and links
## External Resources
Additional Resources to this page can be found here (special mention to Walter Maguire <wmaguire@live.com>) :
https://docs.google.com/document/d/1pL8Szm0ocGxdl5ESVp12Ff71a4PbhCb9SpvbLZzwYbo/edit?usp=sharing
[Additional Notes Supporting the OAI COTS NSA](https://docs.google.com/document/d/1pL8Szm0ocGxdl5ESVp12Ff71a4PbhCb9SpvbLZzwYbo/edit?usp=sharing)
At time of writing, the openairinterface5G Commit Tag is 2020.w39
Faraday Cages can be found here :
http://www.saelig.com/MFR00066/ste2300.htm
[Faraday Cage](http://www.saelig.com/MFR00066/ste2300.htm)
## Configuration Overview
@@ -37,32 +37,32 @@ Our code might not work with all 5G phones yet, but we are constantly improving
* Simcom SIMCOM8200EA
* Quectel RM500Q-GL
Note1: In the version we have at Eurecom, you need to set the PLMN to 50501, and you also need to change the firmware to "11.0.0 (RD1A.201105.003.B1, Nov 2020, EU carriers)" (see https://developers.google.com/android/images)
Note1: In the version we have at Eurecom, you need to set the PLMN to 50501, and you also need to change the firmware to "11.0.0 (RD1A.201105.003.B1, Nov 2020, EU carriers)" (see [Factory Images for Nexus and Pixel Devices](https://developers.google.com/android/images))
## Repository
https://gitlab.eurecom.fr/oai/openairinterface5g/tree/develop
[OAI](https://gitlab.eurecom.fr/oai/openairinterface5g/tree/develop)
## Architecture Setup
The scheme below depicts our typical setup:
![image info](./testing_gnb_w_cots_ue_resources/oai_fr1_setup.jpg)
![image info](./images/oai_fr1_setup.jpg)
The photo depicts the FR1 setup part of the scheme above:
![image info](./testing_gnb_w_cots_ue_resources/oai_fr1_lab.jpg)
![image info](./images/oai_fr1_lab.jpg)
## Build and Install
General guidelines to build eNB and gNB :
See https://gitlab.eurecom.fr/oai/openairinterface5g/blob/develop/doc/BUILD.md#building-ues-enodeb-and-gnodeb-executables
See [Building UE, eNB and gNb executables](https://gitlab.eurecom.fr/oai/openairinterface5g/blob/develop/doc/BUILD.md#building-ues-enodeb-and-gnodeb-executables)
- **eNB**
```
```bash
cd <your oai installation directory>/openairinterface5g/
source oaienv
cd cmake_targets/
@@ -72,7 +72,7 @@ cd cmake_targets/
- **gNB**
```
```bash
cd <your oai installation directory>/openairinterface5g/
source oaienv
cd cmake_targets/
@@ -83,8 +83,7 @@ cd cmake_targets/
- **EPC**
for reference:
https://github.com/OPENAIRINTERFACE/openair-epc-fed/blob/master/docs/DEPLOY_HOME.md
[DEPLOY_HOME_MAGMA_MME](https://github.com/OPENAIRINTERFACE/openair-epc-fed/blob/master/docs/DEPLOY_HOME_MAGMA_MME.md)
## Configuration Files
@@ -93,15 +92,17 @@ Each component (EPC, eNB, gNB) has its own configuration file.
These config files are passed as arguments of the run command line, using the option -O \<conf file\>
The **REFERENCE** files for eNB and gNB, **used by the CI**, can be found here:
[enb conf file](../ci-scripts/conf_files/enb.band7.tm1.fr1.25PRB.usrpb210.conf)
[gnb conf file](../ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpb210.conf)
* [enb conf file](../ci-scripts/conf_files/enb.band7.25prb.usrpb200.tm1.conf)
* [gnb conf file](../ci-scripts/conf_files/gnb-du.sa.band78.106prb.usrpb200.conf)
These files have to be updated manually to set the IP addresses and frequency.
**ATTENTION** : an **EXTERNAL** clock is used to sync the eNB and gNB,
whether the clock is internal or external is defined in the configuration files (!! details needed !!)
---
>**⚠️ ATTENTION ⚠️**
>
>An **EXTERNAL** clock is used to sync the eNB and gNB, whether the clock is internal or external is defined in the configuration files (!! details needed !!)
>
---
1- In the **eNB configuration file** :
- look for MME IP address, and update the **ipv4 field** with the IP address of the **EPC** server
@@ -198,14 +199,13 @@ The test takes typically a few seconds, max 10-15 seconds. If it takes more than
- **EPC** (on EPC host):
for reference:
https://github.com/OPENAIRINTERFACE/openair-epc-fed/blob/master/docs/DEPLOY_HOME.md
[DEPLOY_HOME_MAGMA_MME](https://github.com/OPENAIRINTERFACE/openair-epc-fed/blob/master/docs/DEPLOY_HOME_MAGMA_MME.md)
- **eNB** (on the eNB host):
Execute:
```
```bash
~/openairinterface5g/cmake_targets/ran_build/build$ sudo ./lte-softmodem -O **YOUR_ENB_CONF_FILE** | tee **YOUR_LOG_FILE**
```
@@ -213,13 +213,16 @@ Execute:
- **gNB** (on the gNB host)
**ATTENTION** : for the gNB execution,
The **-E** option is required to enable the tri-quarter sampling rate when using a B2xx serie USRP
The **-E** option is **NOT supported** when using a a N300 USRP
---
>**⚠️ ATTENTION ⚠️**
>
> For the gNB execution:
> - The **-E** option is required to enable the tri-quarter sampling rate when using a B2xx serie USRP
> - The **-E** option is **NOT supported** when using a a N300 USRP
---
Execute:
```
```bash
~/openairinterface5g/cmake_targets/ran_build/build$ sudo ./nr-softmodem -O **YOUR_GNB_CONF_FILE** -E --nsa | tee **YOUR_LOG_FILE**
```
@@ -229,9 +232,9 @@ Execute:
The test case corresponds to the UE attachement, that is the UE connection and its initial access in 5G, as depicted below:
**Source** : https://www.sharetechnote.com/html/5G/5G_LTE_Interworking.html
**Source** : [5G/LTE interworking](https://www.sharetechnote.com/html/5G/5G_LTE_Interworking.html )
![image info](./testing_gnb_w_cots_ue_resources/attach_signaling_scheme.jpg)
![image info](./images/attach_signaling_scheme.jpg)
The test reaches step **12. E-RAB modifcation confirmation** , eventhough not all the messages will appear in the log file.
@@ -239,8 +242,8 @@ The test reaches step **12. E-RAB modifcation confirmation** , eventhough not al
From the log file that is generated, we can monitor several important steps, to assess that the test was successful.
Log files examples can be found here:
[enb log file](https://gitlab.eurecom.fr/oai/openairinterface5g/-/blob/rh_doc_update_3/doc/testing_gnb_w_cots_ue_resources/oai_enb.log)
[gnb log file](https://gitlab.eurecom.fr/oai/openairinterface5g/-/blob/rh_doc_update_3/doc/testing_gnb_w_cots_ue_resources/oai_gnb.log)
* [enb log file](./testing_oai_nsa_w_cots_ue_resources/oai_enb.log)
* [gnb log file](./testing_oai_nsa_w_cots_ue_resources/oai_gnb.log)
- eNB receives UE capabilities information, including its NR capabilites, and triggers sGNB Addition Request message:

88
doc/UL_MIMO.md Normal file
View File

@@ -0,0 +1,88 @@
# UpLink Multiple Input Multiple Output (UL MIMO)
## What is UL MIMO ?
UpLink MIMO refers to the use of multiple antennas at both the UE (User Equipment) as transmitter and the base station as receiver. They are used to send multiple data streams simultaneously from the user to the network.
## How to use it ?
## Step 1: build phy sim
```bash
cd cmake_targets/
sudo ./build_oai --phy_simulators -c
cd phy_simulators/build/
```
## Step 2: Use the sim
### Option 1: launch ULSCH sim
On UpLink Shared CHannel(ULSCH), multiple users share the same radio resources (time and frequency slots), the base station schedules and assigns the resources dynamically. The goal here is to simulate the sending of data from an UE to a base station.
Example:
| Parameter | Value | Description |
|--- |:-: |--: |
| R | 106 | R_NB_UL=106|
| m | 9 | MCS=9 |
| s | 13 | Start SNR |
| n | 100 | Will simulate 100 frames |
| y | 4 | 4 antennas used in eNB |
| z | 4 | 4 antennas used in UE |
| W | 4 | Will use 4 layers |
```bash
sudo ./nr_ulschsim -R 106 -m9 -s13 -n100 -y4 -z4 -W4
```
### Option 2: launch UL sim
On UpLink Channel, a single user is dealing with a single base station. The goal is here to simulate the sending of the data from an UE to a base station.
It's focusing on:
- UpLink chain validation
- PUSCH (whole chain) on UE side and gNB side
- No channel model on data domain signal, which means an ideal scenario is used
- No cross-path connection, which means no signal leakage or interference are present
- PMI = 0 is only unitary precoding matrix
The same parameters are used.
```bash
sudo ./nr_ulsim -n100 -m9 -r106 -s13 -W4 -y4 -z4
```
### Option 3: Use RFSIM
#### Build
RF simulator allows to test OAI without an RF board. It replaces an actual RF board driver.
```bash
sudo ./build_oai -c --gNB --nrUE -w SIMU
```
#### Run
##### 4x4 RANK 4
Example:
| Parameter | Value | Description |
|--- |:-: |--: |
| O | [...] | Use a configuration file |
| l | 2 | Set the number of layers for downlink to 2 for PHY test mode |
| L | 4 | Set the number of layers for uplink to 4 for PHY test mode |
| ue-nb-ant-rx | 4 | Set UE number of rx antennas to 4 |
| ue-nb-ant-tx | 4 | Set UE number of tx antennas to 4 |
```bash
sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.4layer.conf --rfsim --phy-test --l 2 --L 4
sudo ./nr-uesoftmodem --rfsim --phy-test --ue-nb-ant-rx 4 --ue-nb-ant-tx 4
```
##### 4x4 RANK 2
The same parameters are used excepted uplink number of layers set to 2.
```bash
sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.4layer.conf --rfsim --phy-test --l 2 --L 2
sudo ./nr-uesoftmodem --rfsim --phy-test --ue-nb-ant-rx 4 --ue-nb-ant-tx 4
```

View File

@@ -1,31 +0,0 @@
# how to build phy sim
cd cmake_targets/
sudo ./build_oai --phy_simulators -c
cd phy_simulators/build/
# ULSCH sim
# bit level validation
# PUSCH encoding and decoding for 4 layers 2 CMD without data
sudo ./nr_ulschsim -R 106 -m9 -s13 -n100 -y4 -z4 -W4
# UL sim
# Uplink chain validation
# PUSCH on UE side and gNB side,whole chain for PUSCH
# No channel model on data domain signal
# No cross-path connection
# PMI = 0 is only unitary prcoding matrix
sudo ./nr_ulsim -n100 -m9 -r106 -s13 -W4 -y4 -z4
# How to build rfsim
sudo ./build_oai -c --gNB --nrUE -w SIMU
# How to run with rfsim
# 4x4 RANK 4
sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.4layer.conf --rfsim --phy-test --l 2 --L 4
sudo ./nr-uesoftmodem --rfsim --phy-test --ue-nb-ant-rx 4 --ue-nb-ant-tx 4
# 4x4 RANK 2
sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.4layer.conf --rfsim --phy-test --l 2 --L 2
sudo ./nr-uesoftmodem --rfsim --phy-test --ue-nb-ant-rx 4 --ue-nb-ant-tx 4

207
doc/d2d_emulator_setup.md Normal file
View File

@@ -0,0 +1,207 @@
# How to use device-to-device communication (D2D, 4G)
---
>**⚠️ ATTENTION ⚠️**
>
>D2D is currently unfinished, the following documentation steps are likely not enough to make it work.
---
## Scenario 1 : **Off-network UE2UE link**
SynchREF UE (UE1)
```mermaid
graph LR
UE1[UE1<br/>eth0: 10.10.10.1] --- UE2[UE2<br/>eno1: 10.10.10.2]
```
### Example of /etc/network/interfaces configuration for UE1
```text
auto eth0
iface eth0 inet static
address 10.10.10.1
netmask 255.255.255.0
gateway 10.10.10.1
```
### Prepare the environment:
```bash
git clone https://gitlab.eurecom.fr/matzakos/LTE-D2D.git
cd LTE-D2D
git checkout master
```
This branch contains all the current development for **DDPS**, including:
- **UE MAC <-> UE MAC** for **Scenario 1** (off-network communication)
- **eNB MAC <-> UE MAC** using **NFAPI Transport** (on-network communication)
- **RRC Extensions** to support on-network cases
### NFAPI configuration (required even for Scenario 1 target)
```bash
git clone https://github.com/cisco/open-nFAPI.git
cd open-nfapi
patch -p1 --dry-run < $OPENAIR_HOME/open-nfapi.oai.patch
```
Validate that there are no errors:
```patch -p1 < $OPENAIR_HOME/open-nfapi.oai.patch```
### OAI build/execute
```bash
export NFAPI_DIR=XXX (place where NFAPI was installed)
cd cmake_targets
./build_oai --UE --ninja #If necessary, use ./build_oai -I --UE to install required packages
cd ran_build/build/
```
### UE1
``` bash
sudo ifconfig oip0 10.0.0.1
sudo iptables -A POSTROUTING -t mangle -o oip0 -d 224.0.0.3 -j MARK --set-mark 3
```
---
>**NOTE**
>
>If necessary, add a default gateway:
>
>```sudo route add default gw 10.10.10.1 eth0```
---
### UE2
```bash
sudo ifconfig oip0 10.0.0.2
sudo iptables -A POSTROUTING -t mangle -o oip0 -d 224.0.0.3 -j MARK --set-mark 3
```
---
>**NOTE**
>
>If necessary, add a default gateway:
>
>```sudo route add default gw 10.10.10.1 eno1```
---
### UE1 and UE2: Get and build `vencore_app` from `d2d-l3-stub` (branch: `l3_stub`)
```bash
gcc -I . vencore_app.c -o vencore_app -lpthread
```
## TEST ONE-TO-MANY
### Run UE1 then UE2, for example:
- UE1:
```bash
sudo ./lte-softmodem-stub -U --emul-iface eth0
```
- UE2:
```bash
sudo ./lte-softmodem-stub -U --emul-iface eno1
```
### Test with Ping
- Sender - UE1:
```bash
ping -I oip0 224.0.0.3
```
- Receiver - UE2: *using wireshark*
### Test with Iperf
- Sender - UE1:
```bash
iperf -c 224.0.0.3 -u -b 0.1M --bind 10.0.0.1 -t 100
```
- Receiver - UE2:
```bash
sudo ./mcreceive 224.0.0.3 5001
```
Filter the incoming packets according to GroupL2Id: receiver (one-to-many) can discard the packets if it doesn't belong to this group.
For the moment, both sender and receiver use the same set of Ids (hardcoded)
- UE1 (sender):
```bash
sudo ./lte-softmodem-stub -U --emul-iface eth0
./vencore_app #send the sourceL2Id, groupL2Id to OAI
ping -I oip0 224.0.0.3
```
- UE2(receiver)
```bash
sudo ./lte-softmodem-stub -U --emul-iface eno1
#we can see the incomming packets from OAI log, however, cannot see from Wireshark -> they are discarded at MAC layer
./vencore_app #we can see the packets appearing in Wireshark
```
## TEST PC5-S (UE1 -sender, UE2 - receiver) and PC5-U for ONE-TO-ONE scenario
### Configure UE1/UE2
Configure ports and routing table for UE1 and UE2
**UE1:**
```bash
sudo ifconfig oip0 10.0.0.1
sudo iptables -A POSTROUTING -t mangle -o oip0 -d 10.0.0.2 -j MARK --set-mark 3
sudo route add default gw 10.10.10.1 eth0
```
**UE2:**
```bash
sudo ifconfig oip0 10.0.0.2
sudo iptables -A POSTROUTING -t mangle -o oip0 -d 10.0.0.1 -j MARK --set-mark 3
sudo route add default gw 10.10.10.1 eno1
```
#### Step 1:
Run the traffic emulated over Ethernet on UE1 using lte-softmodem-stub to test the behaviour without RF board.
**UE1:**
```bash
sudo ./lte-softmodem-stub -U --emul-iface eth0
```
#### Step 2:
Run the traffic emulated over Ethernet on UE2 and set it as listening to incoming messages from PC5-S
**UE2:**
```bash
sudo ./lte-softmodem-stub -U --emul-iface eno1
./vencore_app -r #listen to incomming message from PC5-S
```
#### Step 3:
Send a message from UE1 to UE2
**UE1:**
```bash
./vencore_app -s #send a message via PC5-S (e.g., DirectCommunicationRequest)
```
#### Generate unicast traffic
**UE1:**
```bash
ping -I oip0 10.0.0.2
```
## TEST PC5-D
#### Step 1:
Run the traffic emulated over Ethernet on UE1 and send a discovery message via PC5-D
**UE1:**
```bash
sudo ./lte-softmodem-stub -U --emul-iface eth0
./vencore_app -d #send a PC5-Discovery-Announcement via PC5D
```
#### Step 2:
Run the traffic emulated over Ethernet on UE2 and send a discovery message via PC5-D
**UE2:**
```bash
sudo ./lte-softmodem-stub -U --emul-iface eno1
./vencore_app -d #send a PC5-Discovery-Announcement via PC5D
```

View File

@@ -1,104 +0,0 @@
Scenario 1 : Off-network UE2UE link
SynchREF UE (UE1)
UE1(eth0 - 10.10.10.1)--------UE2(eno1 - 10.10.10.2)
Here's an example of /etc/network/interfaces configuration for UE1
auto eth0
iface eth0 inet static
address 10.10.10.1
netmask 255.255.255.0
gateway 10.10.10.1
Prepare the environment:
- git clone https://gitlab.eurecom.fr/matzakos/LTE-D2D.git #branch: master
This branch contains all the current development for DDPS
- UE MAC<-> UE MAC for Scenario 1
- eNB MAC<->UE MAC (NFAPI Transport)
- RRC Extensions for “on-network” cases
NFAPI configuration (required even for Scenario 1 target)
- git clone https://github.com/cisco/open-nFAPI.git
- cd open-nfapi
- patch -p1 --dry-run < $OPENAIR_HOME/open-nfapi.oai.patch
Validate that there are no errors
- patch -p1 < $OPENAIR_HOME/open-nfapi.oai.patch
OAI build/execute
- export NFAPI_DIR=XXX (place where NFAPI was installed)
- cd cmake_targets
- ./build_oai --UE --ninja
(if necessary, use ./build_oai -I --UE to install required packages)
- cd ran_build/build/
UE1:
- sudo ifconfig oip0 10.0.0.1
- sudo iptables -A POSTROUTING -t mangle -o oip0 -d 224.0.0.3 -j MARK --set-mark 3
- (if necessary) sudo route add default gw 10.10.10.1 eth0
UE2:
- sudo ifconfig oip0 10.0.0.2
- sudo iptables -A POSTROUTING -t mangle -o oip0 -d 224.0.0.3 -j MARK --set-mark 3
- (if necessary) sudo route add default gw 10.10.10.1 eno1
UE1 and UE2: Get and build vencore_app from d2d-l3-stub (branch: l3_stub)
- gcc -I . vencore_app.c -o vencore_app -lpthread
--------------------------------
TEST ONE-TO-MANY
Run UE1 then UE2, for example:
UE1: sudo ./lte-softmodem-stub -U --emul-iface eth0
UE2: sudo ./lte-softmodem-stub -U --emul-iface eno1
Test with Ping
- Sender - UE1: ping -I oip0 224.0.0.3
- Receiver - UE2: using wireshark
Test with Iperf
- Sender - UE1: iperf -c 224.0.0.3 -u -b 0.1M --bind 10.0.0.1 -t 100
- Receiver - UE2: sudo ./mcreceive 224.0.0.3 5001
Filter the incomming packets according to GroupL2Id: receiver (one-to-many) can discard the packets if it doesn't belong to this group.
For the moment, both sender and receiver use the same set of Ids (hardcoded)
UE1 (sender)
- sudo ./lte-softmodem-stub -U --emul-iface eth0
- ./vencore_app #send the sourceL2Id, groupL2Id to OAI
- ping -I oip0 224.0.0.3
UE2(receiver)
- sudo ./lte-softmodem-stub -U --emul-iface eno1
#we can see the incomming packets from OAI log, however, cannot see from Wireshark -> they are discarded at MAC layer
- ./vencore_app #we can see the packets appearing in Wireshark
--------------------------------------
TEST PC5-S (UE1 -sender, UE2 - receiver) and PC5-U for ONE-TO-ONE scenario
Configure UE1/UE2
UE1:
- sudo ifconfig oip0 10.0.0.1
- sudo iptables -A POSTROUTING -t mangle -o oip0 -d 10.0.0.2 -j MARK --set-mark 3
- sudo route add default gw 10.10.10.1 eth0
UE2:
- sudo ifconfig oip0 10.0.0.2
- sudo iptables -A POSTROUTING -t mangle -o oip0 -d 10.0.0.1 -j MARK --set-mark 3
- sudo route add default gw 10.10.10.1 eno1
step 1:
- UE1: sudo ./lte-softmodem-stub -U --emul-iface eth0
step 2:
- UE2: sudo ./lte-softmodem-stub -U --emul-iface eno1
- UE2: ./vencore_app -r #listen to incomming message from PC5-S
step 3:
- UE1: ./vencore_app -s #send a message via PC5-S (e.g., DirectCommunicationRequest)
Generate unicast traffic
UE1: ping -I oip0 10.0.0.2
--------------------------------------
TEST PC5-D
step 1:
- UE1: sudo ./lte-softmodem-stub -U --emul-iface eth0
- UE1: ./vencore_app -d #send a PC5-Discovery-Announcement via PC5D
step 2:
- UE2: sudo ./lte-softmodem-stub -U --emul-iface eno1
- UE2: ./vencore_app -d #send a PC5-Discovery-Announcement via PC5D

View File

@@ -3,14 +3,13 @@
OAI uses/supports a number of environment variables, documented in the following:
- `NFAPI_TRACE_LEVEL`: set the nfapi custom logging framework's log level; can be one of `error`, `warn`, `note`, `info`, `debug`. Default is `warn`.
- `NR_AWGN_RESULTS_DIR`: directory containing BLER curves for L2simulator channel modelling in SISO case
- `NR_MIMO2x2_AWGN_RESULTS_DIR`: directory containing BLER curves for L2simulator channel modelling in 2x2 MIMO case
- `NR_AWGN_RESULTS_DIR`: directory containing BLER curves for NR L2simulator channel modelling in SISO case
- `NR_MIMO2x2_AWGN_RESULTS_DIR`: directory containing BLER curves for NR L2simulator channel modelling in 2x2 MIMO case
- `OPENAIR_DIR`: should point to the root directory of OpenAirInterface; BLER curves for LTE L2sim channel emulation
- `NVRAM_DIR`: directory to read/write NVRAM data in (5G) `nvram` tool; if not defined, will use `PWD` (working directory)
- `OAI_CONFIGMODULE`: can be used to pass the configuration file instead of `-O`
- `OAI_GDBSTACKS`: if defined when hitting an assertion (`DevAssert()`, `AssertFatal()`, ...), OAI will load `gdb` and provide a backtrace for every thread
- `OAI_RNGSEED`: overwrites any seed for random number generators (RNG) in simulators
- `OAI_THREADPOOLMEASUREMENTS`: path to a file to store thread pool debugging information, see the [thread pool documentation](..common/utils/threadPool/thread-pool.md)
- `OPENAIR_DIR`: should point to the root directory of OpenAirInterface; some code relies on this to get a filename, e.g., BLER curves for L2sim channel emulation
- `USIM_DIR`: directory to read/write USIM data in (4G) `usim` tool; if not defined, will use `PWD` (working directory)
Furthermore, these variables appear in code that is not maintained and maybe not even compiled anywhere:
@@ -19,3 +18,5 @@ Furthermore, these variables appear in code that is not maintained and maybe not
- `SSH_CLIENT`: alternative host to connect to, for CLI, if `REMADDR` is not defined
- `USER`: user name in the command-line interface
- `rftestInputFile`: input file for the `calibration_test` tool
- `OPENAIR2_DIR` : OMV and OMG modules, obsolete
- `TITLE`: OTG module, obsolete

View File

@@ -1,5 +1,5 @@
This tutorial explains how to perform handovers. For the moment, only F1
handovers are supported.
This tutorial explains how to perform handovers. It covers both F1 handovers
(intra-gNB, within a single gNB between DUs) and N2 handovers (inter-gNB).
[[_TOC_]]
@@ -13,6 +13,23 @@ same.
![F1 Handover setup](./RRC/ho.png)
# What is a gNB neighbor?
Network continuity is a key aspect of 5G. In the 5G architecture, gNB neighbors
play a central role in maintaining service continuity through mechanisms such
as handover and load balancing. By definition, a gNB neighbor is another gNB
that can be measured and linked by the UE. If the current serving gNB is no
longer optimal, the UE may connect to a neighbor gNB.
To support this behavior, the network configuration specifies additional frequencies
and cells that the UE should measure. The UE reports these measurements to the
network, which then decides whether or not to initiate a handover.
Neighbor types include:
- **Intra-gNB neighbors** - cells belonging to the same gNB
- **Inter-gNB neighbors** - cells belonging to different gNBs
- **Inter-RAT neighbors** - cells belonging to another RAT (e.g., LTE)
# Steps to run F1 handover with OAI UE
Measurement reporting and processing of RRC Reconfiguration for Mobility are
@@ -353,10 +370,16 @@ We assume:
* Two independent gNBs connected to the same 5GC via N2 interface.
* A UE initially connected to gNB-PCI0, which will be handed over to gNB-PCI1.
* Handover is triggered by either by decision based measurement event (e.g. A3) or telnet command.
* Handover is triggered by either a decision based measurement event (e.g. A3) or telnet command.
## Steps to run N2 handover with OAI UE
**Note for same-machine setup:** When running both gNBs on the same machine, you need to assign a unique IP address to the second gNB to avoid network conflicts. For example:
```sh
sudo ip addr add 192.168.71.180/24 dev rfsim5g-public
```
1. Similarly to F1 handover, UE does not support any measurement reporting and handover is triggered by
telnet command. Therefore, ensure that both gNBs and UE are built with telnet support:
@@ -380,10 +403,17 @@ sudo ./nr-uesoftmodem -r 106 --numerology 1 --band 78 -C 3619200000 --rfsim --ui
Ensure the UE successfully registers with the network.
4. Start the target gNB (gNB PCI1) e.g.
4. Start the target gNB (gNB-PCI1) e.g.
```sh
sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.pci1.rfsim.conf --sa --rfsim --telnetsrv --telnetsrv.shrmod ci --gNBs.[0].min_rxtxtime 6 --rfsimulator.serveraddr 127.0.0.1
sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.pci1.rfsim.conf --rfsim --telnetsrv --telnetsrv.shrmod ci --gNBs.[0].min_rxtxtime 6 --rfsimulator.serveraddr 127.0.0.1
```
**Note for same-machine setup:** When running both gNBs on the same machine, add the following network interface options to the target gNB command, e.g.:
```sh
--gNBs.[0].NETWORK_INTERFACES.GNB_IPV4_ADDRESS_FOR_NG_AMF 192.168.71.180
--gNBs.[0].NETWORK_INTERFACES.GNB_IPV4_ADDRESS_FOR_NGU 192.168.71.180
```
5. Trigger the N2 handover, e.g.
@@ -393,7 +423,7 @@ From gNB-PCI0, trigger handover on target gNB with PCI 1 for UE ID 1:
```sh
echo ci trigger_n2_ho 1,1 | nc 127.0.0.1 9090 && echo
```
where the input parameters correspond to the PCI of the neighbor call and the RRC ID of the UE.
where the input parameters correspond to the PCI of the neighbor cell and the RRC ID of the UE.
This will initiate the N2 handover on the source gNB.

View File

Before

Width:  |  Height:  |  Size: 47 KiB

After

Width:  |  Height:  |  Size: 47 KiB

View File

Before

Width:  |  Height:  |  Size: 188 KiB

After

Width:  |  Height:  |  Size: 188 KiB

View File

Before

Width:  |  Height:  |  Size: 361 KiB

After

Width:  |  Height:  |  Size: 361 KiB

View File

Before

Width:  |  Height:  |  Size: 91 KiB

After

Width:  |  Height:  |  Size: 91 KiB

View File

Before

Width:  |  Height:  |  Size: 247 KiB

After

Width:  |  Height:  |  Size: 247 KiB

View File

Before

Width:  |  Height:  |  Size: 9.4 KiB

After

Width:  |  Height:  |  Size: 9.4 KiB

View File

@@ -15,7 +15,7 @@ The UE exits when at any point in operation it gets out of synchronization. When
UE uses actors which are threads dedicated to particular activity. Sync Actor handles initial sync. DL Actors handle DLSCH PHY procedures. UL procedures are are run on the UL Actor
![design](nr-ue-threads.svg)
![design](images/nr-ue-threads.svg)
## Initial Synchronization Block
```mermaid

Binary file not shown.

Before

Width:  |  Height:  |  Size: 271 KiB

130
doc/oru-design.md Normal file
View File

@@ -0,0 +1,130 @@
# O-RU solution design
## Overview
OAI O-RU shall implement a set of O-RU CAT-A and CAT-B on COTS hardware.
## Procedure requirements for CAT-A
The procedures executed by the O-RU are defined in O-RAN.WG4.TS.CUS Section 4.2.1
### DL procedures
For downlink, the O-RU processing chain is as follows:
1. Receive frequency domain IQ data from DU
2. Symbol rotation (if configured)
3. DFT
4. Transmission
### PRACH procedures
TBD
### PUSCH procedures
TBD
### SRS procedures
TBD
## Procedure requirements for CAT-B
TBD
## Architecture
O-RU shall have two main threads are `north_read` and `south_read`. The threads shall read IQ data
from the respective interfaces. The north interface is handled by xran and is a frequency domain
interface The south interface is a split8 time domain device.
There are two processing triggers in the O-RU process:
- `oran_tx_read` - used to indicate to the application that the downlink UP data is available in
xran buffers. Triggers DL FH processing and transmission.
- `trx_read_func` - indicates to the application that samples are available to on the south. Triggers
PRACH, SRS and PUSCH FH processing.
## North interface
The north interface shall be handles by using OAI split 7.2 library, which uses xran library.
### Changes to xran adapter
The OAI xran adapter library has to be modified to adapt ot for usage with the O-RU. The existing
function signatures which are used by the O-DU do not fulfill the processing time requirements of
O-RU.
The proposed solution is to add a new set of sub-slot APIs to OAI xran adapter. This would ensure
on-time transmission and delivery of frequency-domain IQ to xran library buffers.
## Timing requirements
The timing requirements on O-RU processing come from the ORAN specification O-RAN.WG4.TS.CUS
More directly the standard is implemented by the xran library used in OAI split7.2 adapter
(radio/fhi_72) which shall be used by O-RU.
### Timing requirements for DL
The main requirement for DL comes in the form of a timer: T1a_up min, max. The minimum value is
the downlink UP reception window closing time. This value is given in uS before OTA. Therefore
the downlink procedures must complete within this minimum timer value.
An additional requirement comes from the time domain split8 device. This requirement is due to
the device requiring the samples to be provided before transmission.
### Timing requirements for PRACH/PUSCH/SRS
TBD
## Synchronization
xran library provides the main timing callback in the form of downlink UP reception window closing time.
This infromation is received in `north_read` thread and should be communicated to `south_read` thread
in order to determine slot and frame start sample. From there the `south_read` follows this synchronization
information to produce samples for each slot and symbol.
## Thread structure
The O-RU shall use threadPool and/or actors to parallelize the workload. The exact details are up
to the implementation.
Actors are dedicated threads for a single job.
TheadPool is a pool of threads that can be shared for different tasks.
The OAI threadpool implementation disallows usage from another threadPool thread. Therefore if using
threadpool, another form of parallelism is required.
### DL
Each job shall process a subset of symbols in a given slot. The symbols processed by each job depend on
the `sense_of_time_t` struct returned by xran call.
### UL
UL should parallelize each task. This is due to the fact that `south_read` thread needs to poll the south
interface for new IQ samples continuously.
#### PRACH
Each job should process at least 1 PRACH occasion. The job shall be triggered from `south_read` thread
when the samples for the PRACH occasion are received
#### PUSCH
Each job should process a subset of RX antennas. The job shall be triggered from `south_read` thread once
samples for at least one symbol are received.
## Configuration
The O-RU shall use OAIs configuration subsystem and have its own configuration section. The changes to
existing sections shall be kept to a minimum
Configuration elements required:
|name|type|comment|
|---|---|---|
|phase_compensation|bool|Whether to perform symbol rotation.|
|prach_config_index|int|PRACH configuration index.|

View File

@@ -36,9 +36,14 @@ RUN dnf install -y libasan libubsan
#run build_oai to build the target image
RUN /bin/sh oaienv && \
cd cmake_targets && \
mkdir -p log && \
./build_oai --phy_simulators --ninja --sanitize --build-tool-opt -k10 --noavx512 -c --cmake-opt -DCMAKE_C_FLAGS=-Werror --cmake-opt -DCMAKE_CXX_FLAGS=-Werror --cmake-opt -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=/opt/oai-physim/bin
mkdir -p cmake_targets/ran_build/build && \
cd cmake_targets/ran_build/build && \
cmake3 -GNinja ../../.. \
-DAVX512=OFF -DCMAKE_C_FLAGS=-Werror -DCMAKE_CXX_FLAGS=-Werror \
-DENABLE_PHYSIM_TESTS=ON \
-DSANITIZE_ADDRESS=ON -DSANITIZE_UNDEFINED=ON \
-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=/opt/oai-physim/bin && \
ninja -k10 -j36
#start from scratch for target executable
FROM registry.access.redhat.com/ubi9/ubi:latest AS oai-physim
@@ -101,4 +106,11 @@ COPY --from=phy-sim-build \
/oai-ran/cmake_targets/ran_build/build/openair1/SIMULATION/tests/CTestTestfile.cmake \
/opt/oai-physim/
RUN mkdir -p /oai-ran/openair1/SIMULATION/tests
COPY --from=phy-sim-build \
/oai-ran/openair1/SIMULATION/tests/RunTimedTest.cmake \
/oai-ran/openair1/SIMULATION/tests/analyze-timing.sh \
/oai-ran/openair1/SIMULATION/tests/
#CMD ["sleep", "infinity"]

View File

@@ -8,7 +8,6 @@ target_include_directories(nfapi_socket_lib PRIVATE include/)
target_compile_definitions(nfapi_socket_lib PUBLIC ENABLE_SOCKET)
target_link_libraries(nfapi_socket_lib PRIVATE NFAPI_LIB NFAPI_USER_LIB)
target_link_libraries(nfapi_socket_lib PRIVATE LOG)
add_dependencies(nfapi_socket_lib generate_T)
target_link_libraries(nfapi_socket_lib PRIVATE log_headers)
target_link_libraries(nfapi_socket_lib PRIVATE asn1_lte_rrc_hdrs asn1_nr_rrc_hdrs)
target_link_libraries(nfapi_socket_lib PRIVATE nr_fapi_p5 nr_fapi_p7)

View File

@@ -30,6 +30,7 @@
#include <stdint.h>
#include <stdio.h>
#include "PHY/CODING/coding_defs.h"
#include "common/utils/utils.h"
//#define DEBUG_TURBO_ENCODER 1

View File

@@ -123,9 +123,6 @@ typedef char Binary;
typedef short llr_t; // internal decoder data is 16-bit fixed
typedef short channel_t;
#define LLR_MAX 32767
#define LLR_MIN -32768
#define LLRTOT 16
#define MAX 32767//16383
#define FRAME_LENGTH_MAX 6144
#define STATES 8

View File

@@ -7,7 +7,6 @@ add_library(coding MODULE
3gpplte_turbo_decoder.c
)
set_target_properties(coding PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
#ensure that the T header files are generated before targets depending on them
target_link_libraries(coding PRIVATE log_headers)
add_library(ldpc_orig MODULE
@@ -68,3 +67,4 @@ if (ENABLE_LDPC_CUDA)
endif()
add_subdirectory(nrLDPC_coding)
add_subdirectory(nrLDPC_decoder)

View File

@@ -28,7 +28,7 @@
#define __CODING_DEFS__H__
#include <stdint.h>
#include <PHY/defs_common.h>
#include <stdbool.h>
#define CRC24_A 0
#define CRC24_B 1
@@ -455,8 +455,5 @@ int32_t nr_segmentation(unsigned char *input_buffer,
*/
int nr_get_R_ldpc_decoder(int rvidx, int E, int BG, int Z, int *llrLen, int round);
decoder_if_t phy_threegpplte_turbo_decoder;
decoder_if_t phy_threegpplte_turbo_decoder8;
decoder_if_t phy_threegpplte_turbo_decoder16;
/** @} */
#endif

View File

@@ -3,8 +3,4 @@ add_library(ldpc_segment OBJECT
nrLDPC_coding_segment_decoder.c
nrLDPC_coding_segment_encoder.c
)
#ensure that the T header files are generated before targets depending on them
if (${T_TRACER})
add_dependencies(ldpc_segment generate_T)
endif (${T_TRACER})
target_link_libraries(ldpc_segment PUBLIC log_headers)

View File

@@ -16,12 +16,7 @@ if (ENABLE_LDPC_XDMA)
)
target_include_directories(ldpc_xdma PRIVATE ../nrLDPC_coding_segment)
#ensure that the T header files are generated before targets depending on them
if (${T_TRACER})
add_dependencies(ldpc_xdma generate_T)
endif (${T_TRACER})
target_link_libraries(ldpc_xdma PRIVATE ldpc_gen_HEADERS)
target_link_libraries(ldpc_xdma PRIVATE ldpc_gen_HEADERS log_headers)
set_target_properties(ldpc_xdma PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
add_dependencies(nr-softmodem ldpc_xdma)

View File

@@ -0,0 +1 @@
add_subdirectory(nrLDPC_tools)

View File

@@ -1,7 +1,7 @@
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/generator_bnProc ldpc/generator_bnProc)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/generator_bnProc_avx512 ldpc/generator_bnProc_avx512)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/generator_cnProc ldpc/generator_cnProc)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/generator_cnProc_avx512 ldpc/generator_cnProc_avx512)
add_subdirectory(generator_bnProc ldpc/generator_bnProc)
add_subdirectory(generator_bnProc_avx512 ldpc/generator_bnProc_avx512)
add_subdirectory(generator_cnProc ldpc/generator_cnProc)
add_subdirectory(generator_cnProc_avx512 ldpc/generator_cnProc_avx512)
# custom target to build all generators
add_custom_target(ldpc_generators)

View File

@@ -20,6 +20,7 @@
*/
#include "PHY/CODING/nrPolar_tools/nr_polar_defs.h"
#include "common/utils/utils.h"
// ----- Old implementation ----
const uint8_t **crc24c_generator_matrix(uint16_t payloadSizeBits)

View File

@@ -38,11 +38,13 @@
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include "PHY/CODING/nrPolar_tools/nr_polar_dci_defs.h"
#include "PHY/CODING/nrPolar_tools/nr_polar_uci_defs.h"
#include "PHY/CODING/nrPolar_tools/nr_polar_pbch_defs.h"
#include "PHY/CODING/coding_defs.h"
#include "PHY/sse_intrin.h"
// #include "SIMULATION/TOOLS/sim.h"
#define NR_POLAR_DECODER_LISTSIZE 8 // uint8_t

View File

@@ -31,11 +31,14 @@
*/
#include "PHY/CODING/nrSmallBlock/nr_small_block_defs.h"
#include "common/utils/assertions.h"
//input = [0 ... 0 c_K-1 ... c_2 c_1 c_0]
//output = [d_31 d_30 ... d_2 d_1 d_0]
uint32_t encodeSmallBlock(int in, int len)
{
AssertFatal(len >= 3, "encodeSmallBlock only supports input lengths A >= 3, got A=%d", len);
uint32_t out = 0;
for (int i = 0; i < len; i++)
if ((in & (1 << i)) > 0)

View File

@@ -526,11 +526,7 @@ int32_t lte_srs_channel_estimation(LTE_DL_FRAME_PARMS *frame_parms,
//if ((1<<(sub_frame_number%T_SFC))&transmission_offset_tdd[Ssrs]) {
if (generate_srs(frame_parms,
soundingrs_ul_config_dedicated,
&srs_vars->srs[eNB_id],
0x7FFF,
subframe)==-1) {
if (generate_srs(frame_parms, soundingrs_ul_config_dedicated, &srs_vars->srs[eNB_id], INT16_MAX, subframe) == -1) {
LOG_E(PHY,"lte_srs_channel_estimation: Error in generate_srs\n");
return(-1);
}

View File

@@ -764,7 +764,7 @@ uint32_t calc_pucch_1x_interference(PHY_VARS_eNB *eNB,
uint8_t m,l;
uint8_t n_cs,alpha_ind;
int16_t tmp_re,tmp_im,W_re=0,W_im=0;
int16_t W4_nouse[4]={32767,32767,-32768,-32768};
int16_t W4_nouse[4] = {32767, 32767, -32767, -32767};
int32_t n0_IQ[2];
double interference_power;
int16_t *rxptr;

View File

@@ -72,7 +72,7 @@ void init_ncs_cell(LTE_DL_FRAME_PARMS *frame_parms,uint8_t ncs_cell[20][7])
}
}
const int16_t W4[3][4] = {{32767, 32767, 32767, 32767}, {32767, -32768, 32767, -32768}, {32767, -32768, -32768, 32767}};
const int16_t W4[3][4] = {{32767, 32767, 32767, 32767}, {32767, -32767, 32767, -32767}, {32767, -32767, -32767, 32767}};
const int16_t W3_re[3][6] = {{32767, 32767, 32767}, {32767, -16384, -16384}, {32767, -16384, -16384}};
const int16_t W3_im[3][6] = {{0, 0, 0}, {0, 28377, -28378}, {0, -28378, 28377}};
@@ -334,8 +334,8 @@ const uint8_t chcod_tbl[128][48] = {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
{0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0,
0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1}};
const int16_t alpha_re[12] = {32767, 28377, 16383, 0, -16384, -28378, -32768, -28378, -16384, -1, 16383, 28377};
const int16_t alpha_im[12] = {0, 16383, 28377, 32767, 28377, 16383, 0, -16384, -28378, -32768, -28378, -16384};
const int16_t alpha_re[12] = {32767, 28377, 16383, 0, -16384, -28378, -32767, -28378, -16384, -1, 16383, 28377};
const int16_t alpha_im[12] = {0, 16383, 28377, 32767, 28377, 16383, 0, -16384, -28378, -32767, -28378, -16384};
// W5_TBL
const int16_t W5_fmt3_re[5][5] = {{32767, 32767, 32767, 32767, 32767},

View File

@@ -2867,16 +2867,16 @@ void float_to_chan_est(int32_t **dl_ch_estimates_ext,
for (aarx=0; aarx<n_rx; aarx++) {
for (re=0; re<length; re++) {
if (cimag(dl_ch_estimates_ext_f[aatx*n_rx + aarx][re])<-1)
imag = 0x8000;
imag = -INT16_MAX;
else if (cimag(dl_ch_estimates_ext_f[aatx*n_rx + aarx][re])>=1)
imag = 0x7FFF;
imag = INT16_MAX;
else
imag = cimag(dl_ch_estimates_ext_f[aatx*n_rx + aarx][re])*32768;
if (creal(dl_ch_estimates_ext_f[aatx*n_rx + aarx][re])<-1)
real = 0x8000;
real = -INT16_MAX;
else if (creal(dl_ch_estimates_ext_f[aatx*n_rx + aarx][re])>=1)
real = 0x7FFF;
real = INT16_MAX;
else
real = creal(dl_ch_estimates_ext_f[aatx*n_rx + aarx][re])*32768;
@@ -2910,16 +2910,16 @@ void float_to_rxdataF(int32_t **rxdataF_ext,
for (aarx=0; aarx<n_rx; aarx++) {
for (re=0; re<length; re++) {
if (cimag(rxdataF_f[aarx][re])<-1)
imag = 0x8000;
imag = -INT16_MAX;
else if (cimag(rxdataF_f[aarx][re])>=1)
imag = 0x7FFF;
imag = INT16_MAX;
else
imag = cimag(rxdataF_f[aarx][re])*32768;
if (creal(rxdataF_f[aarx][re])<-1)
real = 0x8000;
real = -INT16_MAX;
else if (creal(rxdataF_f[aarx][re])>=1)
real = 0x7FFF;
real = INT16_MAX;
else
real = creal(rxdataF_f[aarx][re])*32768;

View File

@@ -56,8 +56,8 @@ int generate_drs_pusch(PHY_VARS_UE *ue,
//uint32_t phase_shift; // phase shift for cyclic delay in DM RS
//uint8_t alpha_ind;
int16_t alpha_re[12] = {32767, 28377, 16383, 0,-16384, -28378,-32768,-28378,-16384, -1, 16383, 28377};
int16_t alpha_im[12] = {0, 16383, 28377, 32767, 28377, 16383, 0,-16384,-28378,-32768,-28378,-16384};
int16_t alpha_re[12] = {32767, 28377, 16383, 0, -16384, -28378, -32767, -28378, -16384, -1, 16383, 28377};
int16_t alpha_im[12] = {0, 16383, 28377, 32767, 28377, 16383, 0, -16384, -28378, -32767, -28378, -16384};
uint8_t cyclic_shift,cyclic_shift0=0,cyclic_shift1=0;
LTE_DL_FRAME_PARMS *fp = (ue==NULL) ? frame_parms : &ue->frame_parms;

View File

@@ -119,49 +119,33 @@ const char nr_W_4l_4p[5][4][4] = {
void nr_modulation(const uint32_t *in, uint32_t length, uint16_t mod_order, int16_t *out)
{
uint16_t mask = ((1 << mod_order) - 1);
int32_t *nr_mod_table32;
const uint16_t mask = ((1 << mod_order) - 1);
int32_t *out32 = (int32_t *)out;
const uint8_t *in_bytes = (const uint8_t *)in;
const uint64_t *in64 = (const uint64_t *)in;
int64_t *out64 = (int64_t *)out;
uint32_t i = 0;
#if defined(__SSE2__)
simde__m128i *nr_mod_table128;
simde__m128i *out128;
#endif
LOG_D(PHY, "nr_modulation: length %d, mod_order %d\n", length, mod_order);
switch (mod_order) {
#if defined(__SSE2__)
case 2:
nr_mod_table128 = (simde__m128i *)nr_qpsk_byte_mod_table;
out128 = (simde__m128i *)out;
case 2: {
simde__m128i *nr_mod_table128 = (simde__m128i *)nr_qpsk_byte_mod_table;
simde__m128i *out128 = (simde__m128i *)out;
for (i = 0; i < length / 8; i++)
out128[i] = nr_mod_table128[in_bytes[i]];
// the bits that are left out
i = i * 8 / 2;
nr_mod_table32 = (int32_t *)nr_qpsk_mod_table;
int32_t *nr_mod_table32 = (int32_t *)nr_qpsk_mod_table;
while (i < length / 2) {
const int idx = ((in_bytes[(i * 2) / 8] >> ((i * 2) & 0x7)) & mask);
out32[i] = nr_mod_table32[idx];
i++;
}
}
return;
#else
case 2:
nr_mod_table32 = (int32_t *)nr_qpsk_mod_table;
for (i = 0; i < length / mod_order; i++) {
const int idx = ((in[i * 2 / 32] >> ((i * 2) & 0x1f)) & mask);
out32[i] = nr_mod_table32[idx];
}
return;
#endif
case 4:
out64 = (int64_t *)out;
for (i = 0; i < length / 8; i++)
out64[i] = nr_16qam_byte_mod_table[in_bytes[i]];
// the bits that are left out
@@ -234,10 +218,11 @@ void nr_modulation(const uint32_t *in, uint32_t length, uint16_t mod_order, int1
}
return;
case 8:
nr_mod_table32 = (int32_t *)nr_256qam_mod_table;
case 8: {
int32_t *nr_mod_table32 = (int32_t *)nr_256qam_mod_table;
for (i = 0; i < length / 8; i++)
out32[i] = nr_mod_table32[in_bytes[i]];
}
return;
default:

View File

@@ -777,11 +777,12 @@ int nr_srs_channel_estimation(
const nr_srs_info_t *nr_srs_info,
const c16_t **srs_generated_signal,
c16_t srs_received_signal[][gNB->frame_parms.ofdm_symbol_size * (1 << srs_pdu->num_symbols)],
c16_t srs_received_noise[][gNB->frame_parms.ofdm_symbol_size * (1 << srs_pdu->num_symbols)],
c16_t srs_estimated_channel_freq[][1 << srs_pdu->num_ant_ports]
[gNB->frame_parms.ofdm_symbol_size * (1 << srs_pdu->num_symbols)],
c16_t srs_estimated_channel_time[][1 << srs_pdu->num_ant_ports][gNB->frame_parms.ofdm_symbol_size],
c16_t srs_estimated_channel_time_shifted[][1 << srs_pdu->num_ant_ports][gNB->frame_parms.ofdm_symbol_size],
int8_t *snr_per_rb,
int16_t *snr_per_rb,
int8_t *snr)
{
#ifdef SRS_DEBUG
@@ -801,16 +802,6 @@ int nr_srs_channel_estimation(
}
c16_t srs_ls_estimated_channel[frame_parms->ofdm_symbol_size * (1 << srs_pdu->num_symbols)];
uint32_t noise_power_per_rb[srs_pdu->bwp_size];
const uint32_t arr_len = frame_parms->nb_antennas_rx * N_ap * M_sc_b_SRS;
c16_t ch[arr_len];
memset(ch, 0, arr_len * sizeof(c16_t));
c16_t noise[arr_len];
memset(noise, 0, arr_len * sizeof(c16_t));
uint8_t mem_offset = ((16 - ((intptr_t)&srs_estimated_channel_freq[0][0][subcarrier_offset + nr_srs_info->k_0_p[0][0]])) & 0xF)
>> 2; // >> 2 <=> /sizeof(int32_t)
@@ -831,7 +822,7 @@ int nr_srs_channel_estimation(
#endif
uint16_t subcarrier = subcarrier_offset + nr_srs_info->k_0_p[p_index][0];
if (subcarrier > frame_parms->ofdm_symbol_size) {
if (subcarrier >= frame_parms->ofdm_symbol_size) {
subcarrier -= frame_parms->ofdm_symbol_size;
}
@@ -843,19 +834,12 @@ int nr_srs_channel_estimation(
uint16_t subcarrier_cdm = subcarrier;
for (int cdm_idx = 0; cdm_idx < fd_cdm; cdm_idx++) {
int16_t generated_real = srs_generated_signal[p_index][subcarrier_cdm].r;
int16_t generated_imag = srs_generated_signal[p_index][subcarrier_cdm].i;
int16_t received_real = srs_received_signal[ant][subcarrier_cdm].r;
int16_t received_imag = srs_received_signal[ant][subcarrier_cdm].i;
// We know that nr_srs_info->srs_generated_signal_bits bits are enough to represent the generated_real and
// generated_imag. So we only need a nr_srs_info->srs_generated_signal_bits shift to ensure that the result fits into 16
c16_t generated_srs = srs_generated_signal[p_index][subcarrier_cdm];
c16_t received_srs = srs_received_signal[ant][subcarrier_cdm];
// We know that nr_srs_info->srs_generated_signal_bits bits are enough to represent the real and imaginary parts of
// generated_srs. So we only need a nr_srs_info->srs_generated_signal_bits shift to ensure that the result fits into 16
// bits.
ls_estimated.r += (int16_t)(((int32_t)generated_real * received_real + (int32_t)generated_imag * received_imag)
>> nr_srs_info->srs_generated_signal_bits);
ls_estimated.i += (int16_t)(((int32_t)generated_real * received_imag - (int32_t)generated_imag * received_real)
>> nr_srs_info->srs_generated_signal_bits);
ls_estimated = c16maddConjShift(generated_srs, received_srs, ls_estimated, nr_srs_info->srs_generated_signal_bits);
// Subcarrier increment
subcarrier_cdm += K_TC;
@@ -934,7 +918,7 @@ int nr_srs_channel_estimation(
// Subcarrier increment
subcarrier += K_TC;
if (subcarrier >= frame_parms->ofdm_symbol_size) {
subcarrier = subcarrier - frame_parms->ofdm_symbol_size;
subcarrier -= frame_parms->ofdm_symbol_size;
}
} // for (int k = 0; k < M_sc_b_SRS; k++)
@@ -943,25 +927,9 @@ int nr_srs_channel_estimation(
&srs_est[mem_offset],
(frame_parms->ofdm_symbol_size * (1 << srs_pdu->num_symbols)) * sizeof(c16_t));
// Compute noise
subcarrier = subcarrier_offset + nr_srs_info->k_0_p[p_index][0];
if (subcarrier > frame_parms->ofdm_symbol_size) {
subcarrier -= frame_parms->ofdm_symbol_size;
}
uint16_t base_idx = ant * N_ap * M_sc_b_SRS + p_index * M_sc_b_SRS;
for (int k = 0; k < M_sc_b_SRS; k++) {
ch[base_idx + k] = srs_estimated_channel_freq[ant][p_index][subcarrier];
noise[base_idx + k].r = abs(srs_ls_estimated_channel[subcarrier].r - ch[base_idx + k].r);
noise[base_idx + k].i = abs(srs_ls_estimated_channel[subcarrier].i - ch[base_idx + k].i);
subcarrier += K_TC;
if (subcarrier >= frame_parms->ofdm_symbol_size) {
subcarrier = subcarrier - frame_parms->ofdm_symbol_size;
}
}
#ifdef SRS_DEBUG
subcarrier = subcarrier_offset + nr_srs_info->k_0_p[p_index][0];
if (subcarrier > frame_parms->ofdm_symbol_size) {
if (subcarrier >= frame_parms->ofdm_symbol_size) {
subcarrier -= frame_parms->ofdm_symbol_size;
}
@@ -983,13 +951,13 @@ int nr_srs_channel_estimation(
srs_ls_estimated_channel[subcarrier].i,
srs_estimated_channel_freq[ant][p_index][subcarrier].r,
srs_estimated_channel_freq[ant][p_index][subcarrier].i,
noise[base_idx + (k / K_TC)].r,
noise[base_idx + (k / K_TC)].i);
srs_received_noise[ant][subcarrier].r,
srs_received_noise[ant][subcarrier].i);
// Subcarrier increment
subcarrier++;
if (subcarrier >= frame_parms->ofdm_symbol_size) {
subcarrier = subcarrier - frame_parms->ofdm_symbol_size;
subcarrier -= frame_parms->ofdm_symbol_size;
}
}
#endif
@@ -1010,61 +978,71 @@ int nr_srs_channel_estimation(
} // for (int p_index = 0; p_index < N_ap; p_index++)
} // for (int ant = 0; ant < frame_parms->nb_antennas_rx; ant++)
// Compute signal power
uint32_t signal_power = max(signal_energy_nodc(ch, arr_len), 1);
#ifdef SRS_DEBUG
LOG_I(NR_PHY, "signal_power = %u\n", signal_power);
#endif
// Compute wideband SNR
int tot_subcarriers = m_SRS_b * NR_NB_SC_PER_RB;
uint32_t signal_power = 0;
uint32_t noise_power = 0;
for (int ant = 0; ant < frame_parms->nb_antennas_rx; ant++) {
for (int p_index = 0; p_index < N_ap; p_index++) {
uint16_t subcarrier0 = subcarrier_offset + nr_srs_info->k_0_p[p_index][0];
if (subcarrier0 >= frame_parms->ofdm_symbol_size) {
subcarrier0 -= frame_parms->ofdm_symbol_size;
}
if (subcarrier0 + tot_subcarriers < frame_parms->ofdm_symbol_size) {
signal_power += signal_energy_nodc(&srs_estimated_channel_freq[ant][p_index][subcarrier0], tot_subcarriers);
if (p_index == 0)
noise_power += signal_energy_nodc(&srs_received_noise[ant][subcarrier0], tot_subcarriers);
} else {
int size1 = frame_parms->ofdm_symbol_size - subcarrier0;
int size2 = tot_subcarriers - size1;
uint64_t signal_power_p1 = signal_energy_nodc(&srs_estimated_channel_freq[ant][p_index][subcarrier0], size1) * size1;
uint64_t signal_power_p2 = signal_energy_nodc(&srs_estimated_channel_freq[ant][p_index][0], size2) * size2;
signal_power += (signal_power_p1 + signal_power_p2) / tot_subcarriers;
if (p_index == 0) {
uint64_t noise_power_p1 = signal_energy_nodc(&srs_received_noise[ant][subcarrier0], size1) * size1;
uint64_t noise_power_p2 = signal_energy_nodc(&srs_received_noise[ant][0], size2) * size2;
noise_power += (noise_power_p1 + noise_power_p2) / tot_subcarriers;
}
}
}
}
signal_power = max(signal_power / (frame_parms->nb_antennas_rx * N_ap), 1);
noise_power = max(noise_power / (frame_parms->nb_antennas_rx), 1);
if (signal_power == 0) {
LOG_W(NR_PHY, "Received SRS signal power is 0\n");
return -1;
}
// Compute noise power
const uint8_t srs_symbols_per_rb = srs_pdu->comb_size == 0 ? 6 : 3;
const uint8_t n_noise_est = frame_parms->nb_antennas_rx * N_ap * srs_symbols_per_rb;
uint64_t sum_re = 0;
uint64_t sum_re2 = 0;
uint64_t sum_im = 0;
uint64_t sum_im2 = 0;
for (int rb = 0; rb < m_SRS_b; rb++) {
sum_re = 0;
sum_re2 = 0;
sum_im = 0;
sum_im2 = 0;
for (int ant = 0; ant < frame_parms->nb_antennas_rx; ant++) {
for (int p_index = 0; p_index < N_ap; p_index++) {
uint16_t base_idx = ant * N_ap * M_sc_b_SRS + p_index * M_sc_b_SRS + rb * srs_symbols_per_rb;
for (int srs_symb = 0; srs_symb < srs_symbols_per_rb; srs_symb++) {
sum_re = sum_re + noise[base_idx + srs_symb].r;
sum_re2 = sum_re2 + noise[base_idx + srs_symb].r * noise[base_idx + srs_symb].r;
sum_im = sum_im + noise[base_idx + srs_symb].i;
sum_im2 = sum_im2 + noise[base_idx + srs_symb].i * noise[base_idx + srs_symb].i;
} // for (int srs_symb = 0; srs_symb < srs_symbols_per_rb; srs_symb++)
} // for (int p_index = 0; p_index < N_ap; p_index++)
} // for (int ant = 0; ant < frame_parms->nb_antennas_rx; ant++)
noise_power_per_rb[rb] = max(sum_re2 / n_noise_est - (sum_re / n_noise_est) * (sum_re / n_noise_est) + sum_im2 / n_noise_est
- (sum_im / n_noise_est) * (sum_im / n_noise_est),
1);
snr_per_rb[rb] = dB_fixed(signal_power) - dB_fixed(noise_power_per_rb[rb]);
#ifdef SRS_DEBUG
LOG_I(NR_PHY, "noise_power_per_rb[%i] = %i, snr_per_rb[%i] = %i dB\n", rb, noise_power_per_rb[rb], rb, snr_per_rb[rb]);
#endif
} // for (int rb = 0; rb < m_SRS_b; rb++)
const uint32_t noise_power = max(signal_energy_nodc(noise, arr_len), 1);
*snr = dB_fixed(signal_power) - dB_fixed(noise_power);
// Compute SNR per RB
uint16_t subcarrier = subcarrier_offset + nr_srs_info->k_0_p[0][0];
for (int rb = 0; rb < m_SRS_b; rb++) {
if (subcarrier >= frame_parms->ofdm_symbol_size) {
subcarrier -= frame_parms->ofdm_symbol_size;
}
uint32_t noise_power_per_rb = 0;
for (int ant = 0; ant < frame_parms->nb_antennas_rx; ant++) {
if (subcarrier + NR_NB_SC_PER_RB < frame_parms->ofdm_symbol_size) {
noise_power_per_rb += signal_energy_nodc(&srs_received_noise[ant][subcarrier], NR_NB_SC_PER_RB);
} else {
int size1 = frame_parms->ofdm_symbol_size - subcarrier;
int size2 = NR_NB_SC_PER_RB - size1;
uint32_t noise_power_per_rb1 = signal_energy_nodc(&srs_received_noise[ant][subcarrier], size1) * size1;
uint32_t noise_power_per_rb2 = signal_energy_nodc(&srs_received_noise[ant][0], size2) * size2;
noise_power_per_rb += (noise_power_per_rb1 + noise_power_per_rb2) / NR_NB_SC_PER_RB;
}
}
noise_power_per_rb = max(noise_power_per_rb / (frame_parms->nb_antennas_rx), 1);
snr_per_rb[rb] = dB_fixed(signal_power) - dB_fixed(noise_power_per_rb);
subcarrier += NR_NB_SC_PER_RB;
#ifdef SRS_DEBUG
LOG_I(NR_PHY, "noise_power = %u, SNR = %i dB\n", noise_power, *snr);
LOG_I(NR_PHY, "[RB %3i] noise_power_per_rb = %i, snr_per_rb = %i dB\n", rb, noise_power_per_rb, snr_per_rb[rb]);
#endif
}
#ifdef SRS_DEBUG
LOG_I(NR_PHY, "signal_power = %i dB, noise_power = %i dB, SNR = %i dB\n", dB_fixed(signal_power), dB_fixed(noise_power), *snr);
#endif
return 0;

View File

@@ -84,11 +84,12 @@ int nr_srs_channel_estimation(
const nr_srs_info_t *nr_srs_info,
const c16_t **srs_generated_signal,
c16_t srs_received_signal[][gNB->frame_parms.ofdm_symbol_size * (1 << srs_pdu->num_symbols)],
c16_t srs_received_noise[][gNB->frame_parms.ofdm_symbol_size * (1 << srs_pdu->num_symbols)],
c16_t srs_estimated_channel_freq[][1 << srs_pdu->num_ant_ports]
[gNB->frame_parms.ofdm_symbol_size * (1 << srs_pdu->num_symbols)],
c16_t srs_estimated_channel_time[][1 << srs_pdu->num_ant_ports][gNB->frame_parms.ofdm_symbol_size],
c16_t srs_estimated_channel_time_shifted[][1 << srs_pdu->num_ant_ports][gNB->frame_parms.ofdm_symbol_size],
int8_t *snr_per_rb,
int16_t *snr_per_rb,
int8_t *snr);
void nr_freq_equalization(NR_DL_FRAME_PARMS *frame_parms,

View File

@@ -306,6 +306,10 @@ int8_t get_next_dmrs_symbol_in_slot(uint16_t ul_dmrs_symb_pos, uint8_t counter,
return -1;
}
int8_t get_num_dmrs_re_per_rb(const uint8_t dmrs_type, const uint8_t num_cdm_grp_no_data)
{
return (dmrs_type == NFAPI_NR_DMRS_TYPE1 ? 6 * num_cdm_grp_no_data : 4 * num_cdm_grp_no_data);
}
/* return the position of valid dmrs symbol in a slot for channel compensation */
int8_t get_valid_dmrs_idx_for_channel_est(uint16_t dmrs_symb_pos, uint8_t counter)

View File

@@ -71,6 +71,8 @@ void nr_chest_time_domain_avg(NR_DL_FRAME_PARMS *frame_parms,
uint16_t dmrs_bitmap,
uint16_t num_rbs);
int8_t get_num_dmrs_re_per_rb(const uint8_t dmrs_type, const uint8_t num_cdm_grp_no_data);
static inline uint8_t is_dmrs_symbol(uint8_t l, uint16_t dmrsSymbMask)
{
DevAssert(l < 32);

View File

@@ -22,15 +22,11 @@
#include "nr_refsig.h"
#include "nr_mod_table.h"
c16_t nr_qpsk_mod_table[4];
simde__m128i nr_qpsk_byte_mod_table[256];
int32_t nr_16qam_mod_table[16];
simde__m128i nr_qpsk_byte_mod_table[2048];
int64_t nr_16qam_byte_mod_table[1024];
int64_t nr_16qam_byte_mod_table[256];
int64_t nr_64qam_mod_table[4096];
int32_t nr_256qam_mod_table[512];
int32_t nr_256qam_mod_table[256];
void nr_generate_modulation_table() {
float sqrt2 = 0.70711;

View File

@@ -29,15 +29,12 @@
#define NR_MOD_TABLE_QAM256_OFFSET 87
extern c16_t nr_qpsk_mod_table[4];
extern simde__m128i nr_qpsk_byte_mod_table[256];
extern int32_t nr_16qam_mod_table[16];
#if defined(__SSE2__)
extern simde__m128i nr_qpsk_byte_mod_table[2048];
#endif
extern int64_t nr_16qam_byte_mod_table[1024];
extern int64_t nr_16qam_byte_mod_table[256];
extern int64_t nr_64qam_mod_table[4096];
extern int32_t nr_256qam_mod_table[512];
extern int32_t nr_256qam_mod_table[256];
#endif

View File

@@ -242,7 +242,8 @@ int nr_get_srs_signal(PHY_VARS_gNB *gNB,
slot_t slot,
nfapi_nr_srs_pdu_t *srs_pdu,
nr_srs_info_t *nr_srs_info,
c16_t srs_received_signal[][gNB->frame_parms.ofdm_symbol_size * (1 << srs_pdu->num_symbols)]);
c16_t srs_received_signal[][gNB->frame_parms.ofdm_symbol_size * (1 << srs_pdu->num_symbols)],
c16_t srs_received_noise[][gNB->frame_parms.ofdm_symbol_size * (1 << srs_pdu->num_symbols)]);
void init_prach_list(PHY_VARS_gNB *gNB);
void init_prach_ru_list(RU_t *ru);

View File

@@ -79,59 +79,67 @@ int nr_get_srs_signal(PHY_VARS_gNB *gNB,
slot_t slot,
nfapi_nr_srs_pdu_t *srs_pdu,
nr_srs_info_t *nr_srs_info,
c16_t srs_received_signal[][gNB->frame_parms.ofdm_symbol_size * (1 << srs_pdu->num_symbols)])
c16_t srs_received_signal[][gNB->frame_parms.ofdm_symbol_size * (1 << srs_pdu->num_symbols)],
c16_t srs_received_noise[][gNB->frame_parms.ofdm_symbol_size * (1 << srs_pdu->num_symbols)])
{
const NR_DL_FRAME_PARMS *frame_parms = &gNB->frame_parms;
const uint16_t n_symbols = (slot % RU_RX_SLOT_DEPTH) * frame_parms->symbols_per_slot; // number of symbols until this slot
const uint8_t l0 = srs_pdu->time_start_position; // starting symbol in this slot
const uint8_t l0 = srs_pdu->time_start_position; // starting symbol in this slot
const uint64_t symbol_offset = (n_symbols + l0) * frame_parms->ofdm_symbol_size;
const uint64_t subcarrier_offset = frame_parms->first_carrier_offset + srs_pdu->bwp_start*NR_NB_SC_PER_RB;
const uint64_t subcarrier_offset = frame_parms->first_carrier_offset + srs_pdu->bwp_start * NR_NB_SC_PER_RB;
const uint8_t N_ap = 1<<srs_pdu->num_ant_ports;
const uint8_t N_ap = 1 << srs_pdu->num_ant_ports;
const uint8_t N_symb_SRS = 1 << srs_pdu->num_symbols;
const uint8_t K_TC = 2 << srs_pdu->comb_size;
const uint16_t M_sc_b_SRS = get_m_srs(srs_pdu->config_index, srs_pdu->bandwidth_index) * NR_NB_SC_PER_RB / K_TC;
c16_t *rx_signal;
bool no_srs_signal = true;
for (int ant = 0; ant < frame_parms->nb_antennas_rx; ant++) {
memset(srs_received_signal[ant], 0, frame_parms->ofdm_symbol_size * sizeof(c16_t));
rx_signal = &rxdataF[ant][symbol_offset];
memset(srs_received_noise[ant], 0, frame_parms->ofdm_symbol_size * sizeof(c16_t));
c16_t *rx_signal = &rxdataF[ant][symbol_offset];
for (int p_index = 0; p_index < N_ap; p_index++) {
#ifdef SRS_DEBUG
LOG_I(NR_PHY,"===== UE port %d --> gNB Rx antenna %i =====\n", p_index, ant);
LOG_I(NR_PHY, "===== UE port %d --> gNB Rx antenna %i =====\n", p_index, ant);
#endif
for (int l_line = 0; l_line < N_symb_SRS; l_line++) {
#ifdef SRS_DEBUG
LOG_I(NR_PHY,":::::::: OFDM symbol %d ::::::::\n", l0+l_line);
LOG_I(NR_PHY, ":::::::: OFDM symbol %d ::::::::\n", l0 + l_line);
#endif
uint16_t subcarrier = subcarrier_offset + nr_srs_info->k_0_p[p_index][l_line];
if (subcarrier>frame_parms->ofdm_symbol_size) {
if (subcarrier >= frame_parms->ofdm_symbol_size) {
subcarrier -= frame_parms->ofdm_symbol_size;
}
uint16_t l_line_offset = l_line*frame_parms->ofdm_symbol_size;
uint16_t l_line_offset = l_line * frame_parms->ofdm_symbol_size;
for (int k = 0; k < M_sc_b_SRS; k++) {
srs_received_signal[ant][l_line_offset+subcarrier] = rx_signal[l_line_offset+subcarrier];
// Subcarriers with SRS symbols
srs_received_signal[ant][l_line_offset + subcarrier] = rx_signal[l_line_offset + subcarrier];
if (rx_signal[l_line_offset + subcarrier].r || rx_signal[l_line_offset + subcarrier].i) {
no_srs_signal = false;
}
// Subcarriers without SRS symbols and only noise
srs_received_noise[ant][l_line_offset + subcarrier] = rx_signal[l_line_offset + subcarrier + 1];
for (int n = 1; n < K_TC; n++) {
uint16_t subcarrier_n = subcarrier + n;
if (subcarrier_n >= frame_parms->ofdm_symbol_size) {
subcarrier_n -= frame_parms->ofdm_symbol_size;
}
srs_received_noise[ant][l_line_offset + subcarrier_n] = rx_signal[l_line_offset + subcarrier_n];
}
#ifdef SRS_DEBUG
int subcarrier_log = subcarrier-subcarrier_offset;
if(subcarrier_log < 0) {
int subcarrier_log = subcarrier - subcarrier_offset;
if (subcarrier_log < 0) {
subcarrier_log = subcarrier_log + frame_parms->ofdm_symbol_size;
}
if(subcarrier_log%12 == 0) {
LOG_I(NR_PHY,"------------ %d ------------\n", subcarrier_log/12);
if (subcarrier_log % 12 == 0) {
LOG_I(NR_PHY, "------------ %d ------------\n", subcarrier_log / 12);
}
LOG_I(NR_PHY,
"(%i) \t%i\t%i\n",
@@ -143,7 +151,7 @@ int nr_get_srs_signal(PHY_VARS_gNB *gNB,
// Subcarrier increment
subcarrier += K_TC;
if (subcarrier >= frame_parms->ofdm_symbol_size) {
subcarrier=subcarrier-frame_parms->ofdm_symbol_size;
subcarrier -= frame_parms->ofdm_symbol_size;
}
} // for (int k = 0; k < M_sc_b_SRS; k++)

View File

@@ -147,8 +147,6 @@ void nr_pdsch_ptrs_processing(PHY_VARS_NR_UE *ue,
uint16_t rnti,
NR_UE_DLSCH_t dlsch[2]);
float_t get_nr_RSRP(module_id_t Mod_id,uint8_t CC_id,uint8_t gNB_index);
int nr_sl_psbch_rsrp_measurements(sl_nr_ue_phy_params_t *sl_phy_params,
NR_DL_FRAME_PARMS *fp,
c16_t rxdataF[][fp->samples_per_slot_wCP],

View File

@@ -46,34 +46,6 @@
//#define DEBUG_MEAS_UE
//#define DEBUG_RANK_EST
uint32_t get_nr_rx_total_gain_dB (module_id_t Mod_id,uint8_t CC_id)
{
PHY_VARS_NR_UE *ue = PHY_vars_UE_g[Mod_id][CC_id];
if (ue)
return ue->rx_total_gain_dB;
return 0xFFFFFFFF;
}
float_t get_nr_RSRP(module_id_t Mod_id,uint8_t CC_id,uint8_t gNB_index)
{
AssertFatal(PHY_vars_UE_g!=NULL,"PHY_vars_UE_g is null\n");
AssertFatal(PHY_vars_UE_g[Mod_id]!=NULL,"PHY_vars_UE_g[%d] is null\n",Mod_id);
AssertFatal(PHY_vars_UE_g[Mod_id][CC_id]!=NULL,"PHY_vars_UE_g[%d][%d] is null\n",Mod_id,CC_id);
PHY_VARS_NR_UE *ue = PHY_vars_UE_g[Mod_id][CC_id];
if (ue)
return (10*log10(ue->measurements.rsrp[gNB_index])-
get_nr_rx_total_gain_dB(Mod_id,0) -
10*log10(20*12));
return -140.0;
}
void nr_ue_measurements(PHY_VARS_NR_UE *ue,
const UE_nr_rxtx_proc_t *proc,
NR_UE_DLSCH_t *dlsch,
@@ -264,11 +236,10 @@ void nr_ue_ssb_rsrp_measurements(PHY_VARS_NR_UE *ue,
.gNB_index = proc->gNB_id,
.meas_type = NFAPI_NR_SS_MEAS,
.Nid_cell = ue->frame_parms.Nid_cell,
.rsrp_dBm = ue->measurements.ssb_rsrp_dBm[ssb_index],
.ssb_index = ssb_index,
.is_neighboring_cell = false,
};
int ssb_rsrp_dBm = ue->measurements.ssb_rsrp_dBm[ssb_index];
l1_measurements.rsrp_dBm = BOUNDED_EVAL(16, ssb_rsrp_dBm + 157, 113); // TS 38.133 - Table 10.1.6.1-1
nr_downlink_indication_t dl_indication = {0};
fapi_nr_rx_indication_t rx_ind = {0};
nr_fill_dl_indication(&dl_indication, NULL, &rx_ind, proc, ue, NULL);

View File

@@ -987,7 +987,7 @@ void nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue,
.meas_type = NFAPI_NR_CSI_MEAS,
.Nid_cell = frame_parms->Nid_cell,
.is_neighboring_cell = false,
.rsrp_dBm = BOUNDED_EVAL(16, rsrp_dBm + 157, 113), // TS 38.133 - Table 10.1.6.1-1
.rsrp_dBm = rsrp_dBm,
.rank_indicator = rank_indicator,
.i1 = *i1,
.i2 = *i2,

View File

@@ -41,6 +41,15 @@
#define NR_PUSCH_x 2 // UCI placeholder bit TS 38.212 V15.4.0 subclause 5.3.3.1
#define NR_PUSCH_y 3 // UCI placeholder bit
typedef enum {
BIT_TYPE_ULSCH = 0, // Default: UL-SCH data
BIT_TYPE_ACK = 1, // HARQ-ACK bit
BIT_TYPE_ACK_RESERVED = 2, // Reserved for HARQ-ACK (punctured)
BIT_TYPE_ACK_ULSCH = 3,
BIT_TYPE_CSI1 = 4, // CSI Part 1 bit
BIT_TYPE_CSI2 = 5 // CSI Part 2 bit
} uci_on_pusch_bit_type_t;
// Specifies the data that should be copied to the scope during PDSCH RX
typedef struct pdsch_scope_req_s {
bool copy_chanest_to_scope;
@@ -86,6 +95,13 @@ void nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue,
int nb_dlsch,
uint8_t *DLSCH_ids);
int nr_ulsch_pre_encoding(PHY_VARS_NR_UE *ue,
const NR_UE_ULSCH_t *ulsch,
const uint32_t frame,
const uint8_t slot,
const unsigned int *G,
const int nb_ulsch,
const uint8_t *ULSCH_ids);
/** \brief This is the alternative top-level entry point for ULSCH encoding in UE.
It handles all the HARQ processes in only one call. The routine first
computes the segmentation information, followed by LDPC encoding algorithm of the
@@ -121,8 +137,8 @@ void nr_pusch_codeword_scrambling(uint8_t *in,
uint32_t Nid,
uint32_t n_RNTI,
bool uci_on_pusch,
uint32_t* out);
const uci_on_pusch_bit_type_t *template,
uint32_t *out);
/** \brief Alternative entry point to UE uplink shared channels procedures.
It handles all the HARQ processes in only one call.
@@ -154,7 +170,8 @@ uint8_t nr_ue_pusch_common_procedures(PHY_VARS_NR_UE *UE,
c16_t **txdataF,
c16_t **txdata,
uint32_t linktype,
bool was_symbol_used[NR_NUMBER_OF_SYMBOLS_PER_SLOT]);
bool was_symbol_used[NR_NUMBER_OF_SYMBOLS_PER_SLOT],
bool no_phase_pre_comp);
void clean_UE_harq(PHY_VARS_NR_UE *UE);

View File

@@ -55,6 +55,8 @@ typedef struct {
uint32_t C;
/// Number of bits in code segments
uint32_t K;
///
uint32_t Kb;
/// Number of "Filler" bits
uint32_t F;
/// Number of soft channel bits
@@ -135,4 +137,13 @@ typedef struct {
// PTRS symbol index, to be updated every PTRS symbol within a slot.
uint8_t ptrs_symbol_index;
} NR_UE_DLSCH_t;
typedef struct {
uint16_t Q_dash_ACK; // number of coded HARQ-ACK symbols
uint16_t E_uci_ACK; // number of coded HARQ-ACK bits
uint16_t Q_dash_ACK_rvd; // number of coded HARQ-ACK symbols reserved
uint16_t E_uci_ACK_rvd; // number of coded HARQ-ACK bits reserved
uint32_t G_ulsch; // bit capacity of ULSCH
} rate_match_info_uci_t;
#endif

View File

@@ -34,56 +34,27 @@
#include "common/utils/LOG/vcd_signal_dumper.h"
#include "PHY/log_tools.h"
int nr_ulsch_encoding(PHY_VARS_NR_UE *ue,
NR_UE_ULSCH_t *ulsch,
const uint32_t frame,
const uint8_t slot,
unsigned int *G,
int nb_ulsch,
uint8_t *ULSCH_ids,
uint16_t number_dmrs_symbols)
int nr_ulsch_pre_encoding(PHY_VARS_NR_UE *ue,
const NR_UE_ULSCH_t *ulsch,
const uint32_t frame,
const uint8_t slot,
const unsigned int *G,
const int nb_ulsch,
const uint8_t *ULSCH_ids)
{
start_meas_nr_ue_phy(ue, ULSCH_ENCODING_STATS);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_NR_UE_ULSCH_ENCODING, VCD_FUNCTION_IN);
nrLDPC_TB_encoding_parameters_t TBs[nb_ulsch];
memset(TBs, 0, sizeof(TBs));
nrLDPC_slot_encoding_parameters_t slot_parameters = {
.frame = frame,
.slot = slot,
.nb_TBs = nb_ulsch,
.threadPool = &get_nrUE_params()->Tpool,
.tinput = NULL,
.tprep = NULL,
.tparity = NULL,
.toutput = NULL,
.TBs = TBs
};
int max_num_segments = 0;
for (uint8_t pusch_id = 0; pusch_id < nb_ulsch; pusch_id++) {
uint8_t ULSCH_id = ULSCH_ids[pusch_id];
uint8_t harq_pid = ulsch[ULSCH_id].pusch_pdu.pusch_data.harq_process_id;
nrLDPC_TB_encoding_parameters_t *TB_parameters = &TBs[pusch_id];
/* Neither harq_pid nor ULSCH_id are unique in the instance
* but their combination is.
* Since ULSCH_id < 2
* then 2 * harq_pid + ULSCH_id is unique.
*/
TB_parameters->harq_unique_pid = 2 * harq_pid + ULSCH_id;
for (uint_fast8_t pusch_id = 0; pusch_id < nb_ulsch; pusch_id++) {
const uint8_t ULSCH_id = ULSCH_ids[pusch_id];
const uint8_t harq_pid = ulsch[ULSCH_id].pusch_pdu.pusch_data.harq_process_id;
/////////////////////////parameters and variables initialization/////////////////////////
unsigned int crc = 1;
NR_UL_UE_HARQ_t *harq_process = &ue->ul_harq_processes[harq_pid];
const nfapi_nr_ue_pusch_pdu_t *pusch_pdu = &ulsch->pusch_pdu;
uint16_t nb_rb = pusch_pdu->rb_size;
uint32_t A = pusch_pdu->pusch_data.tb_size << 3;
uint8_t Qm = pusch_pdu->qam_mod_order;
const uint16_t nb_rb = pusch_pdu->rb_size;
const uint32_t A = pusch_pdu->pusch_data.tb_size << 3;
const uint8_t Qm = pusch_pdu->qam_mod_order;
// target_code_rate is in 0.1 units
float Coderate = (float)pusch_pdu->target_code_rate / 10240.0f;
const float Coderate = (float)pusch_pdu->target_code_rate / 10240.0f;
LOG_D(NR_PHY, "ulsch coding nb_rb %d, Nl = %d\n", nb_rb, pusch_pdu->nrOfLayers);
LOG_D(NR_PHY, "ulsch coding A %d G %d mod_order %d Coderate %f\n", A, G[pusch_id], Qm, Coderate);
@@ -91,11 +62,11 @@ int nr_ulsch_encoding(PHY_VARS_NR_UE *ue,
///////////////////////// a---->| add CRC |---->b /////////////////////////
int max_payload_bytes = MAX_NUM_NR_ULSCH_SEGMENTS_PER_LAYER * pusch_pdu->nrOfLayers * 1056;
const int max_payload_bytes = MAX_NUM_NR_ULSCH_SEGMENTS_PER_LAYER * pusch_pdu->nrOfLayers * 1056;
int B;
if (A > NR_MAX_PDSCH_TBS) {
// Add 24-bit crc (polynomial A) to payload
crc = crc24a(harq_process->payload_AB, A) >> 8;
const unsigned int crc = crc24a(harq_process->payload_AB, A) >> 8;
harq_process->payload_AB[A >> 3] = ((uint8_t *)&crc)[2];
harq_process->payload_AB[1 + (A >> 3)] = ((uint8_t *)&crc)[1];
harq_process->payload_AB[2 + (A >> 3)] = ((uint8_t *)&crc)[0];
@@ -103,7 +74,7 @@ int nr_ulsch_encoding(PHY_VARS_NR_UE *ue,
AssertFatal((A / 8) + 4 <= max_payload_bytes, "A %d is too big (A/8+4 = %d > %d)\n", A, (A / 8) + 4, max_payload_bytes);
} else {
// Add 16-bit crc (polynomial A) to payload
crc = crc16(harq_process->payload_AB, A) >> 16;
const unsigned int crc = crc16(harq_process->payload_AB, A) >> 16;
harq_process->payload_AB[A >> 3] = ((uint8_t *)&crc)[1];
harq_process->payload_AB[1 + (A >> 3)] = ((uint8_t *)&crc)[0];
B = A + 16;
@@ -151,7 +122,7 @@ int nr_ulsch_encoding(PHY_VARS_NR_UE *ue,
T_INT((int)ulsch->pusch_pdu.transform_precoding), // transformPrecoder_enabled = 0, transformPrecoder_disabled = 1
T_INT((int)ulsch->pusch_pdu.dmrs_config_type), // dmrs_resource_map_config: pusch_dmrs_type1 = 0, pusch_dmrs_type2 = 1
T_INT((int)ulsch->pusch_pdu.ul_dmrs_symb_pos), // used to derive the DMRS symbol positions
T_INT((int)number_dmrs_symbols),
T_INT((int)get_num_dmrs(ulsch->pusch_pdu.ul_dmrs_symb_pos)),
// dmrs_start_ofdm_symbol
// dmrs_duration_num_ofdm_symbols
// dmrs_num_add_positions
@@ -168,36 +139,55 @@ int nr_ulsch_encoding(PHY_VARS_NR_UE *ue,
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_NR_SEGMENTATION, VCD_FUNCTION_IN);
start_meas_nr_ue_phy(ue, ULSCH_SEGMENTATION_STATS);
TB_parameters->Kb = nr_segmentation(harq_process->payload_AB,
harq_process->c,
B,
&harq_process->C,
&harq_process->K,
&harq_process->Z,
&harq_process->F,
harq_process->BG);
TB_parameters->C = harq_process->C;
TB_parameters->K = harq_process->K;
TB_parameters->Z = harq_process->Z;
TB_parameters->F = harq_process->F;
TB_parameters->BG = harq_process->BG;
if (TB_parameters->C > MAX_NUM_NR_DLSCH_SEGMENTS_PER_LAYER * pusch_pdu->nrOfLayers) {
LOG_E(PHY, "nr_segmentation.c: too many segments %d, B %d\n", TB_parameters->C, B);
harq_process->Kb = nr_segmentation(harq_process->payload_AB,
harq_process->c,
B,
&harq_process->C,
&harq_process->K,
&harq_process->Z,
&harq_process->F,
harq_process->BG);
if (harq_process->C > MAX_NUM_NR_DLSCH_SEGMENTS_PER_LAYER * pusch_pdu->nrOfLayers) {
LOG_E(PHY, "nr_segmentation.c: too many segments %d, B %d\n", harq_process->C, B);
return (-1);
}
stop_meas_nr_ue_phy(ue, ULSCH_SEGMENTATION_STATS);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_NR_SEGMENTATION, VCD_FUNCTION_OUT);
max_num_segments = max(max_num_segments, TB_parameters->C);
TB_parameters->nb_rb = nb_rb;
TB_parameters->Qm = Qm;
TB_parameters->mcs = pusch_pdu->mcs_index;
TB_parameters->nb_layers = pusch_pdu->nrOfLayers;
TB_parameters->rv_index = pusch_pdu->pusch_data.rv_index;
TB_parameters->G = G[pusch_id];
TB_parameters->tbslbrm = pusch_pdu->tbslbrm;
TB_parameters->A = A;
} // pusch_id
return 0;
}
int nr_ulsch_encoding(PHY_VARS_NR_UE *ue,
NR_UE_ULSCH_t *ulsch,
const uint32_t frame,
const uint8_t slot,
unsigned int *G,
int nb_ulsch,
uint8_t *ULSCH_ids,
uint16_t number_dmrs_symbols)
{
start_meas_nr_ue_phy(ue, ULSCH_ENCODING_STATS);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_NR_UE_ULSCH_ENCODING, VCD_FUNCTION_IN);
nrLDPC_TB_encoding_parameters_t TBs[nb_ulsch];
memset(TBs, 0, sizeof(TBs));
nrLDPC_slot_encoding_parameters_t slot_parameters = {.frame = frame,
.slot = slot,
.nb_TBs = nb_ulsch,
.threadPool = &get_nrUE_params()->Tpool,
.tinput = NULL,
.tprep = NULL,
.tparity = NULL,
.toutput = NULL,
.TBs = TBs};
int max_num_segments = 0;
for (uint_fast8_t pusch_id = 0; pusch_id < nb_ulsch; pusch_id++) {
const uint8_t ULSCH_id = ULSCH_ids[pusch_id];
const uint8_t harq_pid = ulsch[ULSCH_id].pusch_pdu.pusch_data.harq_process_id;
NR_UL_UE_HARQ_t *harq_process = &ue->ul_harq_processes[harq_pid];
max_num_segments = max(max_num_segments, harq_process->C);
}
nrLDPC_segment_encoding_parameters_t segments[nb_ulsch][max_num_segments];
memset(segments, 0, sizeof(segments));
@@ -208,10 +198,25 @@ int nr_ulsch_encoding(PHY_VARS_NR_UE *ue,
nrLDPC_TB_encoding_parameters_t *TB_parameters = &TBs[pusch_id];
NR_UL_UE_HARQ_t *harq_process = &ue->ul_harq_processes[harq_pid];
const nfapi_nr_ue_pusch_pdu_t *pusch_pdu = &ulsch[ULSCH_id].pusch_pdu;
const uint16_t nb_rb = pusch_pdu->rb_size;
TB_parameters->harq_unique_pid = 2 * harq_pid + ULSCH_id;
TB_parameters->C = harq_process->C;
TB_parameters->K = harq_process->K;
TB_parameters->Z = harq_process->Z;
TB_parameters->F = harq_process->F;
TB_parameters->BG = harq_process->BG;
TB_parameters->Kb = harq_process->Kb;
TB_parameters->nb_rb = nb_rb;
TB_parameters->Qm = pusch_pdu->qam_mod_order;
TB_parameters->mcs = pusch_pdu->mcs_index;
TB_parameters->nb_layers = pusch_pdu->nrOfLayers;
TB_parameters->rv_index = pusch_pdu->pusch_data.rv_index;
TB_parameters->G = G[pusch_id];
TB_parameters->tbslbrm = pusch_pdu->tbslbrm;
TB_parameters->A = pusch_pdu->pusch_data.tb_size / 8;
TB_parameters->segments = segments[pusch_id];
const nfapi_nr_ue_pusch_pdu_t *pusch_pdu = &ulsch->pusch_pdu;
uint16_t nb_rb = pusch_pdu->rb_size;
memset(harq_process->f, 0, 14 * nb_rb * 12 * 16);
TB_parameters->output = harq_process->f;

View File

@@ -49,6 +49,12 @@
#include "PHY/NR_REFSIG/ul_ref_seq_nr.h"
#include <openair2/UTIL/OPT/opt.h>
#include "PHY/log_tools.h"
#include "PHY/NR_UE_TRANSPORT/pucch_nr.h"
#include <math.h>
#define MAX_RE_PER_SYMBOL_IN_ALLOC (275 * 12)
#define MAX_NLQM (4 * 8)
#define MAX_UCI_CODED_BITS 1024
//#define DEBUG_PUSCH_MAPPING
//#define DEBUG_MAC_PDU
@@ -56,33 +62,72 @@
//extern int32_t uplink_counter;
void nr_pusch_codeword_scrambling_uci(uint8_t *in, uint32_t size, uint32_t Nid, uint32_t n_RNTI, uint32_t* out)
static void nr_pusch_codeword_scrambling_uci(uint8_t *in,
uint32_t size,
uint32_t Nid,
uint32_t n_RNTI,
const uci_on_pusch_bit_type_t *template,
uint32_t *out)
{
uint32_t *seq = gold_cache((n_RNTI << 15) + Nid, (size + 31) / 32);
for (int i=0; i<size; i++) {
int idx = i / 32;
int b_idx = i % 32;
if (in[i]==NR_PUSCH_x)
out[idx] ^= 1 << b_idx;
else if (in[i]==NR_PUSCH_y){
if (b_idx)
out[idx] ^= (out[idx] & (1 << (b_idx - 1))) << 1;
else{
uint32_t temp_out = out[idx - 1];
out[idx] ^= temp_out >> 31;
uint32_t num_words = (size + 31) / 32;
// Step 1: Initial general scrambling
// First convert unpacked input to bit-packed words
uint32_t in_words[num_words];
memset(in_words, 0, num_words * sizeof(uint32_t));
for (uint32_t i = 0; i < size; i++) {
uint32_t word_idx = i / 32;
uint32_t bit_idx = i % 32;
if (in[i] & 1) {
in_words[word_idx] |= (1U << bit_idx);
}
}
for (uint32_t i = 0; i < num_words; i++) {
out[i] = in_words[i] ^ seq[i];
}
// According to 38.211 6.3.1.1
for (uint32_t i = 0; i < size; i++) {
if (template[i] == BIT_TYPE_ACK_ULSCH) {
// Step 2: Overwrite/Correct positions for UCI bits including placeholders X, Y when O_ACK <= 2
uint32_t pos = i;
uint32_t idx = pos / 32;
uint32_t b_idx = pos % 32;
if (in[pos] == NR_PUSCH_y) {
// Clear bit
out[idx] &= ~(1U << b_idx);
if (b_idx > 0) {
// Y depends on the final value of the previous bit in the same word.
// This previous bit could be an ACK (already corrected) or ULSCH (from initial scramble).
out[idx] |= ((out[idx] >> (b_idx - 1)) & 1) << b_idx;
} else if (idx > 0) {
// Y depends on the last bit of the previous word.
out[idx] |= ((out[idx - 1] >> 31) & 1);
}
} else if (in[pos] == NR_PUSCH_x) {
out[idx] |= (1U << b_idx);
}
}
else
out[idx] ^= (((in[i]) & 1) ^ ((seq[idx] >> b_idx) & 1)) << b_idx;
//printf("i %d b_idx %d in %d s 0x%08x out 0x%08x\n", i, b_idx, in[i], s, *out);
}
}
void nr_pusch_codeword_scrambling(uint8_t *in, uint32_t size, uint32_t Nid, uint32_t n_RNTI, bool uci_on_pusch, uint32_t* out)
void nr_pusch_codeword_scrambling(uint8_t *in,
uint32_t size,
uint32_t Nid,
uint32_t n_RNTI,
bool uci_on_pusch,
const uci_on_pusch_bit_type_t *template,
uint32_t *out)
{
if (uci_on_pusch)
nr_pusch_codeword_scrambling_uci(in, size, Nid, n_RNTI, out);
// in buffer is in byte-packed format
nr_pusch_codeword_scrambling_uci(in, size, Nid, n_RNTI, template, out);
else
// in buffer is in bit-packed format
nr_codeword_scrambling(in, size, 0, Nid, n_RNTI, out);
}
@@ -472,6 +517,500 @@ static void map_symbols(const nr_phy_pxsch_params_t p,
}
}
// Function to lookup beta offset value from Table 9.3-1 in TS 38.213
static double get_beta_offset_harq_ack(uint8_t beta_offset_index)
{
static const double beta_offset_values[21] = {
1.000, // Index 0
2.000, // Index 1
2.500, // Index 2
3.125, // Index 3
4.000, // Index 4
5.000, // Index 5
6.250, // Index 6
8.000, // Index 7
10.000, // Index 8
12.625, // Index 9
15.875, // Index 10
20.000, // Index 11
31.000, // Index 12
50.000, // Index 13
80.000, // Index 14
126.000, // Index 15
0.6, // Index 16
0.4, // Index 17
0.2, // Index 18
0.1, // Index 19
0.05, // Index 20
};
if (beta_offset_index > 20) {
LOG_E(PHY, "Invalid beta_offset_index %d, using default value\n", beta_offset_index);
return 20.000; // Default value using index 11
}
return beta_offset_values[beta_offset_index];
}
static double get_alpha_scaling_value(uint8_t alpha_scaling)
{
switch (alpha_scaling) {
case 0:
return 0.5;
case 1:
return 0.65;
case 2:
return 0.8;
case 3:
return 1.0;
default:
AssertFatal(false, "Invalid alpha_scaling value %d, valid range is 0-3", alpha_scaling);
return 1.0;
}
}
/*
* This function gets the CRC size of UCI
*/
static int get_crc_uci(const uint16_t ouci)
{
int L = 0;
if (ouci > 19) {
L = 11;
} else if (ouci > 11) {
L = 6;
} else {
L = 0; // no ACK/NACK
}
return L;
}
static uint16_t get_Qd(const uint16_t oack, double beta, double alpha, const uint32_t sumKr, const uint32_t s1, const uint32_t s2)
{
if (oack == 0)
return 0;
uint16_t first_term = ceil(((double)oack + get_crc_uci(oack)) * (double)beta * s1 / sumKr);
uint16_t second_term = ceil(alpha * s2);
return (first_term < second_term) ? first_term : second_term;
}
/*
* This function calculates the rate matching information for UCI multiplexing with PUSCH
*/
static rate_match_info_uci_t calc_rate_match_info_uci(const nfapi_nr_ue_pusch_pdu_t *pusch_pdu,
const NR_UL_UE_HARQ_t *harq_process_ul_ue,
const uint8_t nlqm,
unsigned int *G)
{
// get beta offset
uint8_t beta_offset_index = pusch_pdu->pusch_uci.beta_offset_harq_ack;
double beta = get_beta_offset_harq_ack(beta_offset_index);
// get alpha scaling value
uint8_t alpha_scaling = pusch_pdu->pusch_uci.alpha_scaling;
double alpha = get_alpha_scaling_value(alpha_scaling);
// Calculate sumKr (total bits in all code blocks)
uint32_t sumKr = 0;
if (harq_process_ul_ue->C == 0) {
sumKr = 0;
} else if (harq_process_ul_ue->C == 1) {
sumKr = harq_process_ul_ue->K;
} else {
sumKr = harq_process_ul_ue->K * harq_process_ul_ue->C;
}
// Calculate s1: total number of non-DMRS REs in allocation
uint16_t nb_rb = pusch_pdu->rb_size;
uint8_t start_symbol = pusch_pdu->start_symbol_index;
uint8_t number_of_symbols = pusch_pdu->nr_of_symbols;
uint16_t ul_dmrs_symb_pos = pusch_pdu->ul_dmrs_symb_pos;
uint32_t s1 = 0;
for (int l = start_symbol; l < start_symbol + number_of_symbols; l++) {
if (!((ul_dmrs_symb_pos >> l) & 0x01)) {
s1 += nb_rb * NR_NB_SC_PER_RB;
}
}
// Calculate s2: number of non-DMRS REs after first DMRS symbol
int first_dmrs_symbol = -1;
for (int l = start_symbol; l < start_symbol + number_of_symbols; l++) {
if ((ul_dmrs_symb_pos >> l) & 0x01) {
first_dmrs_symbol = l;
break;
}
}
int l0 = -1;
if (first_dmrs_symbol >= 0 && first_dmrs_symbol < start_symbol + number_of_symbols - 1) {
l0 = first_dmrs_symbol + 1;
}
uint32_t s2 = 0;
for (int l = l0; l < start_symbol + number_of_symbols; l++) {
if (!((ul_dmrs_symb_pos >> l) & 0x01)) {
s2 += nb_rb * NR_NB_SC_PER_RB;
}
}
uint16_t oack = pusch_pdu->pusch_uci.harq_ack_bit_length;
uint16_t oack_rvd = (oack <= 2) ? 2 : 0; // get the reserved bits when oACK <= 2 according to TS 38.212 section 6.2.7, step 1
rate_match_info_uci_t rminfo = {0};
// get the number of coded HARQ-ACK symbols and bits, TS 38.212 section 6.3.2.4.1.1
rminfo.Q_dash_ACK = get_Qd(oack, beta, alpha, sumKr, s1, s2);
rminfo.E_uci_ACK = rminfo.Q_dash_ACK * nlqm;
if (oack_rvd > 0) {
rminfo.Q_dash_ACK_rvd = get_Qd(oack_rvd, beta, alpha, sumKr, s1, s2);
rminfo.E_uci_ACK_rvd = rminfo.Q_dash_ACK_rvd * nlqm;
}
if (oack_rvd == 0) {
rminfo.G_ulsch = *G - rminfo.E_uci_ACK;
} else {
rminfo.G_ulsch = *G;
}
*G = rminfo.G_ulsch;
LOG_D(PHY, "[UCI_RATE_MATCH] sumKr=%u, s1=%u, s2=%u, Final G_ulsch (output G): %u\n", sumKr, s1, s2, *G);
LOG_D(PHY,
"[UCI_RATE_MATCH] rate matching info returned: E_uci_ACK=%u, E_uci_ACK_rvd=%u, G_ulsch=%u\n",
rminfo.E_uci_ACK,
rminfo.E_uci_ACK_rvd,
rminfo.G_ulsch);
return rminfo;
}
static int initialize_mapping_resources(const nfapi_nr_ue_pusch_pdu_t *pusch_pdu,
uint32_t *m_ulsch_initial,
uint32_t *m_uci_current)
{
if (!pusch_pdu || !m_ulsch_initial || !m_uci_current)
return -1;
const uint8_t n_pusch_sym_all = pusch_pdu->nr_of_symbols;
const uint16_t ul_dmrs_symb_pos = pusch_pdu->ul_dmrs_symb_pos;
const uint8_t dmrs_type = pusch_pdu->dmrs_config_type;
const uint8_t cdm_grps_no_data = pusch_pdu->num_dmrs_cdm_grps_no_data;
const uint32_t res_per_symbol_non_dmrs = pusch_pdu->rb_size * NR_NB_SC_PER_RB;
const uint32_t data_re_on_dmrs_sym_per_prb = NR_NB_SC_PER_RB - get_num_dmrs_re_per_rb(dmrs_type, cdm_grps_no_data);
// Initialize resources per symbol for ULSCH and UCI
for (uint8_t i = 0; i < n_pusch_sym_all; i++) {
uint8_t absolute_symbol_idx = pusch_pdu->start_symbol_index + i;
if ((ul_dmrs_symb_pos >> absolute_symbol_idx) & 0x01) {
// Calculate available data REs on DMRS symbols based on DMRS configuration
m_ulsch_initial[i] = pusch_pdu->rb_size * data_re_on_dmrs_sym_per_prb;
m_uci_current[i] = 0; // UCI is not mapped on DMRS symbols
} else { // Not a DMRS symbol
m_ulsch_initial[i] = res_per_symbol_non_dmrs;
m_uci_current[i] = res_per_symbol_non_dmrs;
}
}
return 0;
}
static void get_first_uci_symbol(const uint8_t start_symbol,
const uint8_t num_symbols,
const uint16_t dmrs_map,
uint8_t *first_non_dmrs_sym,
uint8_t *dmrs_p1)
{
// First non-DMRS symbol
const uint16_t last_sym = start_symbol + num_symbols;
for (uint_fast8_t s = start_symbol; s < last_sym; s++) {
if (!is_dmrs_symbol(s, dmrs_map)) {
*first_non_dmrs_sym = s;
break;
}
}
// Symbol after first consequtive DMRS symbol
const uint8_t first_dmrs_sym = get_next_dmrs_symbol_in_slot(dmrs_map, start_symbol, last_sym);
*dmrs_p1 = first_dmrs_sym + 1;
while (is_dmrs_symbol(*dmrs_p1, dmrs_map) && *dmrs_p1 < last_sym) {
(*dmrs_p1)++;
}
// Return relative symbol idx
*first_non_dmrs_sym -= start_symbol;
*dmrs_p1 -= start_symbol;
}
/*
* This function builds the initial template by reserving positions for HARQ-ACK.
*/
static void build_template_reserve_ack(uci_on_pusch_bit_type_t *template,
const nfapi_nr_ue_pusch_pdu_t *pusch_pdu,
uint32_t G_ack_rvd,
uint8_t l1_c,
const uint32_t *m_uci_current,
const uint32_t *m_ulsch_initial,
uint32_t positions_by_sym[][MAX_UCI_CODED_BITS],
uint32_t *count_by_sym)
{
const uint8_t n_symbols = pusch_pdu->nr_of_symbols;
const uint32_t nlqm = pusch_pdu->qam_mod_order * pusch_pdu->nrOfLayers;
memset(count_by_sym, 0, n_symbols * sizeof(uint32_t));
uint32_t symbol_start_bit_idx[14] = {0};
for (uint8_t s = 1; s < n_symbols; s++) {
symbol_start_bit_idx[s] = symbol_start_bit_idx[s - 1] + (m_ulsch_initial[s - 1] * nlqm);
}
// Reserve Positions using RE-level D-Factor Distribution
uint32_t total_reserved = 0;
for (uint8_t sym = l1_c; sym < n_symbols && total_reserved < G_ack_rvd; sym++) {
const uint32_t uci_re_on_sym = m_uci_current[sym];
if (uci_re_on_sym > 0) {
const uint32_t remaining_to_reserve = G_ack_rvd - total_reserved;
uint32_t d_factor_re;
const uint32_t num_re_to_select = ceil((double)remaining_to_reserve / nlqm);
if (num_re_to_select >= uci_re_on_sym) {
d_factor_re = 1;
} else {
d_factor_re = floor((double)uci_re_on_sym / num_re_to_select);
if (d_factor_re == 0) {
d_factor_re = 1;
}
}
for (uint32_t re_offset = 0; re_offset < uci_re_on_sym && total_reserved < G_ack_rvd; re_offset += d_factor_re) {
for (uint32_t bit_in_re = 0; bit_in_re < nlqm; bit_in_re++) {
if (total_reserved >= G_ack_rvd) {
break;
}
uint32_t bit_offset_in_sym = (re_offset * nlqm) + bit_in_re;
uint32_t cw_idx = symbol_start_bit_idx[sym] + bit_offset_in_sym;
template[cw_idx] = BIT_TYPE_ACK_RESERVED;
positions_by_sym[sym][count_by_sym[sym]] = cw_idx;
count_by_sym[sym]++;
total_reserved++;
}
}
}
}
}
/*
* This function maps the HARQ-ACK bits when O_ACK > 2
*/
static void map_non_overlapped_ack(uci_on_pusch_bit_type_t *template,
const nfapi_nr_ue_pusch_pdu_t *pusch_pdu,
uint16_t G_ack,
uint8_t l1_c,
const uint32_t *m_uci_current,
const uint32_t *m_ulsch_initial)
{
const uint8_t n_symbols = pusch_pdu->nr_of_symbols;
const uint32_t nlqm = pusch_pdu->qam_mod_order * pusch_pdu->nrOfLayers;
uint32_t symbol_start_bit_idx[14] = {0};
for (uint8_t s = 1; s < n_symbols; s++) {
symbol_start_bit_idx[s] = symbol_start_bit_idx[s - 1] + (m_ulsch_initial[s - 1] * nlqm);
}
uint32_t total_placed = 0;
for (uint8_t sym = l1_c; sym < n_symbols && total_placed < G_ack; sym++) {
const uint32_t uci_re_on_sym = m_uci_current[sym];
if (uci_re_on_sym > 0) {
const uint32_t remaining_to_place = G_ack - total_placed;
uint32_t d_factor_re;
const uint32_t num_re_to_select = ceil((double)remaining_to_place / nlqm);
if (num_re_to_select >= uci_re_on_sym) {
d_factor_re = 1;
} else {
d_factor_re = floor((double)uci_re_on_sym / num_re_to_select);
if (d_factor_re == 0) {
d_factor_re = 1;
}
}
for (uint32_t re_offset = 0; re_offset < uci_re_on_sym && total_placed < G_ack; re_offset += d_factor_re) {
for (uint32_t bit_in_re = 0; bit_in_re < nlqm; bit_in_re++) {
if (total_placed >= G_ack) {
break;
}
uint32_t bit_offset_in_sym = (re_offset * nlqm) + bit_in_re;
uint32_t cw_idx = symbol_start_bit_idx[sym] + bit_offset_in_sym;
template[cw_idx] = BIT_TYPE_ACK;
total_placed++;
}
}
}
}
}
/*
* This function maps the HARQ-ACK bits when O_ACK <= 2
*/
static void map_overlapped_ack(uci_on_pusch_bit_type_t *template,
uint16_t G_ack,
uint8_t l1_c,
uint8_t n_symbols,
uint32_t positions_by_sym[][MAX_UCI_CODED_BITS],
const uint32_t *count_by_sym)
{
uint32_t ack_bits_marked = 0;
for (uint8_t sym_iter = l1_c; sym_iter < n_symbols && ack_bits_marked < G_ack; sym_iter++) {
const uint32_t num_reserved_bits_on_sym = count_by_sym[sym_iter];
if (num_reserved_bits_on_sym > 0) {
const uint32_t num_ack_remaining = G_ack - ack_bits_marked;
uint32_t d_factor;
// This d-factor is calculated for stepping through the list of *reserved bits*.
if (num_ack_remaining >= num_reserved_bits_on_sym) {
d_factor = 1;
} else {
d_factor = floor((double)num_reserved_bits_on_sym / num_ack_remaining);
if (d_factor == 0) {
d_factor = 1;
}
}
const uint32_t *reserved_indices_on_this_sym = positions_by_sym[sym_iter];
for (uint32_t i = 0; i < num_reserved_bits_on_sym && ack_bits_marked < G_ack; i += d_factor) {
uint32_t pos_to_mark = reserved_indices_on_this_sym[i];
template[pos_to_mark] = BIT_TYPE_ACK_ULSCH;
ack_bits_marked++;
}
}
}
}
/*
* Applies the template to build the final codeword
*/
static void apply_template_to_codeword(uint8_t *codeword,
const uci_on_pusch_bit_type_t *template,
uint32_t codeword_len,
const uint8_t *ulsch_bits,
const uint64_t *cack,
uint16_t G_ack,
uint32_t G_ulsch)
{
uint32_t ulsch_idx = 0;
uint32_t ack_idx = 0;
for (uint32_t i = 0; i < codeword_len; i++) {
switch (template[i]) {
case BIT_TYPE_ACK:
if (G_ack > 0 && ack_idx < G_ack) {
uint32_t word_idx = ack_idx / 64;
uint32_t bit_in_word_idx = ack_idx % 64;
codeword[i] = (cack[word_idx] >> bit_in_word_idx) & 1;
ack_idx++;
}
break;
case BIT_TYPE_ACK_ULSCH:
if (G_ack > 0 && ack_idx < G_ack) {
codeword[i] = ((const uint8_t *)cack)[ack_idx++];
if (G_ulsch > 0 && ulsch_idx < G_ulsch) {
ulsch_idx++;
}
}
break;
case BIT_TYPE_ACK_RESERVED:
case BIT_TYPE_ULSCH:
default:
if (G_ulsch > 0 && ulsch_idx < G_ulsch) {
uint32_t byte_idx = ulsch_idx / 8;
uint32_t bit_in_byte_idx = ulsch_idx % 8;
codeword[i] = (ulsch_bits[byte_idx] >> bit_in_byte_idx) & 1;
ulsch_idx++;
}
break;
}
}
}
/*
* This function implements the UCI multiplexing on PUSCH according to TS 38.212 section 6.2.7.
*/
static uci_on_pusch_bit_type_t *nr_data_control_mapping(const nfapi_nr_ue_pusch_pdu_t *pusch_pdu,
uci_on_pusch_bit_type_t *template,
unsigned int G_ulsch,
uint16_t G_ack,
uint32_t G_ack_rvd,
uint8_t *codeword,
uint32_t codeword_len,
const uint8_t *ulsch_bits,
const uint64_t *cack)
{
if (!pusch_pdu || !codeword || codeword_len == 0 || !template)
return NULL;
const uint8_t n_symbols = pusch_pdu->nr_of_symbols;
if (n_symbols == 0 || n_symbols > NR_NUMBER_OF_SYMBOLS_PER_SLOT)
return NULL;
uint32_t m_ulsch_initial[NR_NUMBER_OF_SYMBOLS_PER_SLOT] = {0};
uint32_t m_uci_current[NR_NUMBER_OF_SYMBOLS_PER_SLOT] = {0}; // This holds RE counts, not bit counts
if (initialize_mapping_resources(pusch_pdu, m_ulsch_initial, m_uci_current) != 0) {
LOG_E(PHY, "Failed to initialize mapping resources\n");
return NULL;
}
uint8_t first_non_dmrs_sym = 0;
uint8_t l1_c = 0;
get_first_uci_symbol(pusch_pdu->start_symbol_index,
pusch_pdu->nr_of_symbols,
pusch_pdu->ul_dmrs_symb_pos,
&first_non_dmrs_sym,
&l1_c);
memset(template, 0, codeword_len * sizeof(uci_on_pusch_bit_type_t));
uint32_t positions_by_sym[NR_NUMBER_OF_SYMBOLS_PER_SLOT][MAX_UCI_CODED_BITS] = {0};
uint32_t count_by_sym[NR_NUMBER_OF_SYMBOLS_PER_SLOT] = {0};
if (G_ack_rvd > 0) {
build_template_reserve_ack(template,
pusch_pdu,
G_ack_rvd,
l1_c,
m_uci_current,
m_ulsch_initial,
positions_by_sym,
count_by_sym);
} else if (G_ack > 0) {
map_non_overlapped_ack(template, pusch_pdu, G_ack, l1_c, m_uci_current, m_ulsch_initial);
}
if (G_ack > 0 && G_ack_rvd > 0) {
map_overlapped_ack(template, G_ack, l1_c, n_symbols, positions_by_sym, count_by_sym);
}
apply_template_to_codeword(codeword, template, codeword_len, ulsch_bits, cack, G_ack, G_ulsch);
return template;
}
void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
const uint32_t frame,
const uint8_t slot,
@@ -494,8 +1033,11 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
LOG_D(PHY, "nr_ue_ulsch_procedures_slot hard_id %d %d.%d prepare for coding\n", harq_pid, frame, slot);
NR_UE_ULSCH_t *ulsch_ue = &phy_data->ulsch;
NR_UE_PUCCH *pucch_ue = &phy_data->pucch_vars;
NR_UL_UE_HARQ_t *harq_process_ul_ue = &UE->ul_harq_processes[harq_pid];
const nfapi_nr_ue_pusch_pdu_t *pusch_pdu = &ulsch_ue->pusch_pdu;
const fapi_nr_ul_config_pucch_pdu *pucch_pdu = &pucch_ue->pucch_pdu[0];
uci_on_pusch_bit_type_t *uci_mapping_template = NULL;
uint16_t number_dmrs_symbols = 0;
@@ -536,6 +1078,11 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
G[pusch_id] = nr_get_G(nb_rb, number_of_symbols, nb_dmrs_re_per_rb, number_dmrs_symbols, unav_res, mod_order, Nl);
// Capture the initial total PUSCH bits. This is the total_codeword_length for mapping.
unsigned int G_initial_total_pusch_bits = G[pusch_id];
uci_on_pusch_bit_type_t template_buffer[G_initial_total_pusch_bits];
ws_trace_t tmp = {.nr = true,
.direction = DIRECTION_UPLINK,
.pdu_buffer = harq_process_ul_ue->payload_AB,
@@ -552,6 +1099,17 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
/////////////////////////ULSCH coding/////////////////////////
rate_match_info_uci_t rm_info = {0};
const uint8_t nl_qm = Nl * mod_order; // product of number of layers and modulation order
if(nr_ulsch_pre_encoding(UE, &phy_data->ulsch, frame, slot, G, 1, ULSCH_ids) != 0) {
LOG_E(PHY, "Error pre-encoding\n");
return;
}
if (pusch_pdu->pusch_uci.harq_ack_bit_length != 0) {
rm_info = calc_rate_match_info_uci(pusch_pdu, harq_process_ul_ue, nl_qm, &G[pusch_id]);
}
if (nr_ulsch_encoding(UE, &phy_data->ulsch, frame, slot, G, 1, ULSCH_ids, number_dmrs_symbols) == -1) {
stop_meas_nr_ue_phy(UE, PUSCH_PROC_STATS);
return;
@@ -565,9 +1123,52 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
int N_PRB_oh = 0; // higher layer (RRC) parameter xOverhead in PUSCH-ServingCellConfig
AssertFatal(pusch_pdu->pusch_uci.harq_ack_bit_length == 0 && pusch_pdu->pusch_uci.csi_part1_bit_length == 0
&& pusch_pdu->pusch_uci.csi_part2_bit_length == 0,
"UCI on PUSCH not supported at PHY\n");
if (pusch_pdu->pusch_uci.harq_ack_bit_length != 0) {
LOG_D(PHY, "[UCI_ON_PUSCH] Original HARQ-ACK bit length: %u\n", pusch_pdu->pusch_uci.harq_ack_bit_length);
LOG_D(PHY, "[UCI_ON_PUSCH] Initial G: %u\n", G_initial_total_pusch_bits);
// b is the block of bits transmitted on the physical channel after payload coding
uint64_t b[16] = {0}; // limit to 1024-bit encoded length
if (pucch_pdu == NULL) {
LOG_E(PHY, "nr_ue_ulsch_procedures: pucch_pdu is NULL but HARQ-ACK is present. Cannot proceed with UCI encoding.\n");
stop_meas_nr_ue_phy(UE, PUSCH_PROC_STATS);
return;
}
nr_uci_encoding(pusch_pdu->pusch_uci.harq_payload,
pusch_pdu->pusch_uci.harq_ack_bit_length,
pucch_pdu->prb_size,
true,
rm_info.E_uci_ACK,
mod_order,
&b[0]);
LOG_D(PHY,
"[UCI_ON_PUSCH] G_ulsch=%u (updated G[pusch_id]), G_ack=%u (M_bit), G_ack_rvd=%u, total_len=%u "
"(G_initial_total_pusch_bits).\n",
G[pusch_id],
rm_info.E_uci_ACK,
rm_info.E_uci_ACK_rvd,
G_initial_total_pusch_bits);
uint8_t temp_codeword[G_initial_total_pusch_bits];
start_meas_nr_ue_phy(UE, UCI_ON_PUSCH_MAPPING);
nr_data_control_mapping(pusch_pdu,
template_buffer,
G[pusch_id],
rm_info.E_uci_ACK,
rm_info.E_uci_ACK_rvd,
temp_codeword,
G_initial_total_pusch_bits,
harq_process_ul_ue->f,
b);
stop_meas_nr_ue_phy(UE, UCI_ON_PUSCH_MAPPING);
memcpy(harq_process_ul_ue->f, temp_codeword, G_initial_total_pusch_bits);
uci_mapping_template = template_buffer;
}
AssertFatal(pusch_pdu->pusch_uci.csi_part1_bit_length == 0 && pusch_pdu->pusch_uci.csi_part2_bit_length == 0,
"UCI (CSI) on PUSCH not supported at PHY\n");
uint16_t start_rb = pusch_pdu->rb_start;
uint16_t start_sc = frame_parms->first_carrier_offset + (start_rb + pusch_pdu->bwp_start) * NR_NB_SC_PER_RB;
@@ -600,17 +1201,32 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
/////////////////////////ULSCH scrambling/////////////////////////
uint32_t available_bits = G[pusch_id];
// +1 because size can be not modulo 4
uint32_t scrambled_output[available_bits / (8 * sizeof(uint32_t)) + 1];
uint32_t available_bits;
bool is_uci_on_pusch = (pusch_pdu->pusch_uci.harq_ack_bit_length != 0);
if (is_uci_on_pusch) {
// UCI on PUSCH is present, so available bits are the total codeword length
available_bits = G_initial_total_pusch_bits;
} else {
// No UCI on PUSCH, so available bits are the initial G value
available_bits = G[pusch_id];
}
// +1 because size can be not modulo 4 for the uint32_t array
uint32_t scrambled_output_len_u32 = (available_bits + 31) / 32; // Round up to nearest uint32_t count
uint32_t scrambled_output[scrambled_output_len_u32];
memset(scrambled_output, 0, sizeof(scrambled_output));
nr_pusch_codeword_scrambling(harq_process_ul_ue->f,
available_bits,
pusch_pdu->data_scrambling_id,
rnti,
false,
is_uci_on_pusch,
uci_mapping_template,
scrambled_output);
if (UE->phy_sim_test_buf) {
memcpy(UE->phy_sim_test_buf, scrambled_output, (available_bits + 7) / 8);
}
#if T_TRACER
if (T_ACTIVE(T_UE_PHY_UL_SCRAMBLED_TX_BITS)) {
// Get Time Stamp for T-tracer messages
@@ -893,19 +1509,21 @@ uint8_t nr_ue_pusch_common_procedures(PHY_VARS_NR_UE *UE,
c16_t **txdataF,
c16_t **txdata,
uint32_t linktype,
bool was_symbol_used[NR_NUMBER_OF_SYMBOLS_PER_SLOT])
bool was_symbol_used[NR_NUMBER_OF_SYMBOLS_PER_SLOT],
bool no_phase_pre_comp)
{
int N_RB = (linktype == link_type_sl) ? frame_parms->N_RB_SL : frame_parms->N_RB_UL;
for (int i = 0; i < NR_NUMBER_OF_SYMBOLS_PER_SLOT; i++) {
if (was_symbol_used[i] == false)
continue;
for (int ap = 0; ap < n_antenna_ports; ap++) {
apply_nr_rotation_TX(frame_parms, txdataF[ap], frame_parms->symbol_rotation[linktype], slot, N_RB, i, 1);
if (!no_phase_pre_comp) {
for (int i = 0; i < NR_NUMBER_OF_SYMBOLS_PER_SLOT; i++) {
if (was_symbol_used[i] == false)
continue;
for (int ap = 0; ap < n_antenna_ports; ap++) {
apply_nr_rotation_TX(frame_parms, txdataF[ap], frame_parms->symbol_rotation[linktype], slot, N_RB, i, 1);
}
}
}
for (int ap = 0; ap < n_antenna_ports; ap++) {
if (frame_parms->Ncp == 1) { // extended cyclic prefix
for (int i = 0; i < NR_NUMBER_OF_SYMBOLS_PER_SLOT_EXTENDED_CP; i++) {

View File

@@ -485,6 +485,45 @@ void nr_generate_pucch1(const PHY_VARS_NR_UE *ue,
}
}
// Calculate number of DMRS symbols for PUCCH formats 3 and 4
static uint8_t nr_pucch_get_dmrs_symbols(uint8_t nrofSymbols, uint8_t add_dmrs)
{
if (nrofSymbols == 4) {
return 1;
} else if (nrofSymbols > 4 && nrofSymbols <= 9) {
return 2;
} else if (nrofSymbols > 9) {
return (add_dmrs == 0) ? 2 : 4;
}
return 0;
}
// Calculate PUCCH format 2/3/4 rate matching output sequence length according to TS 38.212 Table 6.3.1.4-1
static uint16_t nr_pucch_output_sequence_length(uint8_t format_type,
uint8_t nrofSymbols,
uint16_t nrofPRB,
uint8_t n_SF_PUCCH_s,
uint8_t is_pi_over_2_bpsk_enabled,
uint8_t add_dmrs)
{
uint16_t M_bit = 0;
if (format_type == 2) {
M_bit = 16 * nrofSymbols * nrofPRB;
} else if (format_type == 3) {
uint16_t E_init = (is_pi_over_2_bpsk_enabled == 0) ? 24 : 12;
uint8_t num_dmrs_symbols = nr_pucch_get_dmrs_symbols(nrofSymbols, add_dmrs);
M_bit = E_init * (nrofSymbols - num_dmrs_symbols) * nrofPRB / n_SF_PUCCH_s;
} else if (format_type == 4) {
nrofPRB = 1;
uint16_t E_init = (is_pi_over_2_bpsk_enabled == 0) ? 24 : 12;
uint8_t num_dmrs_symbols = nr_pucch_get_dmrs_symbols(nrofSymbols, add_dmrs);
M_bit = E_init * (nrofSymbols - num_dmrs_symbols) * nrofPRB / n_SF_PUCCH_s;
}
return M_bit;
}
static inline void nr_pucch2_3_4_scrambling(uint16_t M_bit, uint16_t rnti, uint16_t n_id, uint64_t *B64, uint8_t *btilde)
{
// c_init=nRNTI*2^15+n_id according to TS 38.211 Subclause 6.3.2.6.1
@@ -520,101 +559,143 @@ static inline void nr_pucch2_3_4_scrambling(uint16_t M_bit, uint16_t rnti, uint1
printf("\t\t [nr_pucch2_3_4_scrambling] scrambling M_bit=%d bits\n", M_bit);
#endif
}
static void nr_uci_encoding(uint64_t payload,
uint8_t nr_bit,
int fmt,
uint8_t is_pi_over_2_bpsk_enabled,
uint8_t nrofSymbols,
uint8_t nrofPRB,
uint8_t n_SF_PUCCH_s,
uint8_t intraSlotFrequencyHopping,
uint8_t add_dmrs,
uint64_t *b,
uint16_t *M_bit) {
void nr_uci_encoding(uint64_t payload, uint8_t nr_bit, uint8_t nrofPRB, bool uci_on_pusch, uint16_t E, uint8_t Qm, uint64_t *b)
{
/*
* Implementing TS 38.212 Subclause 6.3.1.2
* Implementing TS 38.212 Subclause 6.3.1.2 and 6.3.2
*
*/
// A is the payload size, to be provided in function call
uint8_t A = nr_bit;
// L is the CRC size
//uint8_t L;
// uint8_t L;
// E is the rate matching output sequence length as given in TS 38.212 subclause 6.3.1.4.1
uint16_t E=0,E_init;
if (fmt == 2) E = 16*nrofSymbols*nrofPRB;
if (fmt == 3) {
E_init = (is_pi_over_2_bpsk_enabled == 0) ? 24:12;
if (nrofSymbols == 4) {
E = (intraSlotFrequencyHopping == 0)?(E_init*(nrofSymbols-1)*nrofPRB):((E_init*(nrofSymbols-1)*nrofPRB));
// int I_seg;
#ifdef DEBUG_NR_PUCCH_TX
printf("format 3 nrofSymbols =4 and E_init=%d,E=%d\n",E_init,E);
printf("\t\t [nr_uci_encoding] start function with encoding A=%d bits into M_bit=%d (where nrofPRB=%d)\n", A, E, nrofPRB);
#endif
}
if (nrofSymbols > 4) {
E = E_init*(nrofSymbols-2)*nrofPRB;
#ifdef DEBUG_NR_PUCCH_TX
printf("format 3 nrofSymbols >4 and E_init=%d,E = %d\n",E_init,E);
#endif
}
// For A=1 case (single bit UCI)
if (A == 1) {
uint8_t uci_bit_val = payload & 1; // Extract the single UCI bit
uint64_t pattern_word;
uint8_t *b_bytes = (uint8_t *)b; // Access b as bytes to set individual special values
if (nrofSymbols > 9) {
E = (add_dmrs == 0)?(E_init*(nrofSymbols-2)*nrofPRB):((E_init*(nrofSymbols-4)*nrofPRB));
#ifdef DEBUG_NR_PUCCH_TX
printf("format 3 nrofSymbols >9 and E_init=%d,E = %d\n",E_init,E);
#endif
if (Qm == 1) {
// For BPSK, just repeat the input bit
pattern_word = uci_bit_val ? 0xFFFFFFFFFFFFFFFFULL : 0x0000000000000000ULL;
for (int i = 0; i < 8; i++) {
b[i] = pattern_word;
}
} else {
// For higher order modulation (QPSK, etc.), use placeholder values
memset(b, 0, 8 * sizeof(uint64_t));
// Fill the entire output with the pattern
for (int i = 0; i < E; i++) {
switch (i % Qm) {
case 0:
// First bit in each group is actual UCI bit
b_bytes[i] = uci_bit_val;
LOG_D(PHY,
"[UCI_ENCODING_A1_QAM_LOOP] i=%d, i%%Qm=%d (case 0), writing uci_bit_val %d to b_bytes[%d]\n",
i,
i % Qm,
uci_bit_val,
i);
break;
case 1:
b_bytes[i] = NR_PUSCH_y;
LOG_D(PHY,
"[UCI_ENCODING_A1_QAM_LOOP] i=%d, i%%Qm=%d (case 1), writing NR_PUSCH_y (0x%02X) to b_bytes[%d]\n",
i,
i % Qm,
NR_PUSCH_y,
i);
break;
default:
b_bytes[i] = NR_PUSCH_x;
break;
}
}
}
}
// For A=2 case (two bits UCI)
else if (A == 2) {
uint8_t bit0 = (payload >> 0) & 1;
uint8_t bit1 = (payload >> 1) & 1;
uint8_t c2 = bit0 ^ bit1; // Parity bit (XOR of the two bits)
uint8_t *b_bytes = (uint8_t *)b;
if (fmt == 4) {
E_init = (is_pi_over_2_bpsk_enabled == 0) ? 24:12;
if (Qm == 1) {
// For BPSK, output is [bit0, bit1, c2]
uint64_t pattern = (bit0) | (bit1 << 1) | (c2 << 2);
// Repeat this 3-bit pattern to fill the output
pattern |= pattern << 3;
pattern |= pattern << 6;
pattern |= pattern << 12;
pattern |= pattern << 24;
pattern |= pattern << 48;
if (nrofSymbols == 4) {
E = (intraSlotFrequencyHopping == 0)?(E_init*(nrofSymbols-1)/n_SF_PUCCH_s):((E_init*(nrofSymbols-1)/n_SF_PUCCH_s));
#ifdef DEBUG_NR_PUCCH_TX
printf("format 4 nrofSymbols =4 and E_init=%d,E=%d\n",E_init,E);
#endif
for (int i = 0; i < 8; i++) {
b[i] = pattern;
}
} else {
// For higher order modulation (Qm>=2), using patterns from Table 5.3.3.2-1
// Pattern: 3 groups of Qm bits each = 3*Qm total length
memset(b, 0, 8 * sizeof(uint64_t));
for (int i = 0; i < E; i++) {
int pos_in_pattern = i % (3 * Qm);
int group = pos_in_pattern / Qm;
int pos_in_group = pos_in_pattern % Qm;
uint8_t val_to_write;
if (pos_in_group == 0) {
if (group == 0)
val_to_write = bit0;
else if (group == 1)
val_to_write = c2;
else
val_to_write = bit1;
} else if (pos_in_group == 1) {
if (group == 0)
val_to_write = bit1;
else if (group == 1)
val_to_write = bit0;
else
val_to_write = c2;
} else {
// Positions 2 and beyond are x placeholders
val_to_write = NR_PUSCH_x;
}
b_bytes[i] = val_to_write;
}
}
if (nrofSymbols > 4) {
E = E_init*(nrofSymbols-2)/n_SF_PUCCH_s;
#ifdef DEBUG_NR_PUCCH_TX
printf("format 4 nrofSymbols >4 and E_init=%d,E = %d\n",E_init,E);
#endif
}
if (nrofSymbols > 9) {
E = (add_dmrs == 0)?(E_init*(nrofSymbols-2)/n_SF_PUCCH_s):((E_init*(nrofSymbols-4)/n_SF_PUCCH_s));
#ifdef DEBUG_NR_PUCCH_TX
printf("format 4 nrofSymbols >9 and E_init=%d,E = %d\n",E_init,E);
#endif
}
}
*M_bit = E;
//int I_seg;
#ifdef DEBUG_NR_PUCCH_TX
printf("\t\t [nr_uci_encoding] start function with fmt=%d, encoding A=%d bits into M_bit=%d (where nrofSymbols=%d,nrofPRB=%d)\n",fmt,A,*M_bit,nrofSymbols,nrofPRB);
#endif
if (A<=11) {
} else if (A <= 11) {
// procedure in subclause 6.3.1.2.2 (UCI encoded by channel coding of small block lengths -> subclause 6.3.1.3.2)
// CRC bits are not attached, and coding small block lengths (subclause 5.3.3)
uint64_t b0 = encodeSmallBlock(payload, A);
// repetition for rate-matching up to 16 PRB
b[0] = b0 | (b0<<32);
b[1] = b[0];
b[2] = b[0];
b[3] = b[0];
b[4] = b[0];
b[5] = b[0];
b[6] = b[0];
b[7] = b[0];
AssertFatal(nrofPRB<=16,"Number of PRB >16\n");
} else if (A>=12) {
if (uci_on_pusch) {
b[0] = b0;
for (int i = 1; i < 8; i++) {
b[i] = 0;
}
} else {
// repetition for rate-matching up to 16 PRB
b[0] = b0 | (b0<<32);
b[1] = b[0];
b[2] = b[0];
b[3] = b[0];
b[4] = b[0];
b[5] = b[0];
b[6] = b[0];
b[7] = b[0];
AssertFatal(nrofPRB<=16,"Number of PRB >16\n");
}
} else if (A >= 12) {
// Encoder reversal
payload = reverse_bits(payload, A);
@@ -623,7 +704,52 @@ static void nr_uci_encoding(uint64_t payload,
A,
nrofPRB);
}
if (uci_on_pusch) {
// Rate matching for HARQ ACK following 38.212 section 5.4.3
uint64_t output[8] = {0}; // Assuming max 512 bits (8 words of 64 bits)
uint16_t N;
if (nr_bit <= 2) {
// For A=1 (BPSK), N=1. For A=2 (QPSK), N=3
N = (nr_bit == 1) ? 1 : 3;
} else if (nr_bit <= 11) {
// For 3 <= A <= 11, the small block encoder produces a 32-bit codeword
N = 32;
} else {
// For polar-coded UCI, output depends on nrofPRB
N = 16 * nrofPRB;
}
if ((nr_bit == 1 || nr_bit == 2) && Qm > 1) {
LOG_D(PHY,
"[UCI_ENCODING_RM] Bypassing bit-wise rate matching for A=%d, Qm=%d. 'b' (length %d bytes) is assumed to be already "
"final.\n",
nr_bit,
Qm,
E);
} else {
if (N == 0) {
LOG_W(PHY, "HARQ-ACK rate matching with encoded_length=0 but E_uci_ack=%d\n", E);
return;
}
// Rate matching with single loop for both repetition and puncturing
for (int i = 0; i < E; i++) {
int src_bit = i % N; // Modulo for cyclic repetition
int src_word = src_bit / 64;
int src_bit_pos = src_bit % 64;
int dst_word = i / 64;
int dst_bit_pos = i % 64;
if ((b[src_word] >> src_bit_pos) & 1ULL)
output[dst_word] |= (1ULL << dst_bit_pos);
}
for (int i = 0; i < (E + 63) / 64; i++) {
b[i] = output[i];
}
}
}
}
//#if 0
void nr_generate_pucch2(const PHY_VARS_NR_UE *ue,
@@ -639,13 +765,8 @@ void nr_generate_pucch2(const PHY_VARS_NR_UE *ue,
// b is the block of bits transmitted on the physical channel after payload coding
uint64_t b[16] = {0}; // limit to 1024-bit encoded length
// M_bit is the number of bits of block b (payload after encoding)
uint16_t M_bit = 0;
nr_uci_encoding(pucch_pdu->payload,
pucch_pdu->n_bit,
2,0,
pucch_pdu->nr_of_symbols,
pucch_pdu->prb_size,
1,0,0,&b[0],&M_bit);
uint16_t M_bit = nr_pucch_output_sequence_length(pucch_pdu->format_type, pucch_pdu->nr_of_symbols, pucch_pdu->prb_size, 0, 0, 0);
nr_uci_encoding(pucch_pdu->payload, pucch_pdu->n_bit, pucch_pdu->prb_size, false, M_bit, 0, &b[0]);
/*
* Implementing TS 38.211
* Subclauses 6.3.2.5.1 Scrambling (PUCCH format 2)
@@ -829,7 +950,7 @@ void nr_generate_pucch3_4(const PHY_VARS_NR_UE *ue,
// b is the block of bits transmitted on the physical channel after payload coding
uint64_t b[16];
// M_bit is the number of bits of block b (payload after encoding)
uint16_t M_bit;
uint16_t M_bit = 0;
// parameter PUCCH-F4-preDFT-OCC-length set of {2,4} -> to use table -1 or -2
// in format 4, n_SF_PUCCH_s = {2,4}, provided by higher layer parameter PUCCH-F4-preDFT-OCC-length (in format 3 n_SF_PUCCH_s=1)
uint8_t n_SF_PUCCH_s;
@@ -856,17 +977,14 @@ void nr_generate_pucch3_4(const PHY_VARS_NR_UE *ue,
uint16_t startingPRB = pucch_pdu->prb_start + pucch_pdu->bwp_start;
uint8_t add_dmrs = pucch_pdu->add_dmrs_flag;
nr_uci_encoding(pucch_pdu->payload,
pucch_pdu->n_bit,
pucch_pdu->format_type,
is_pi_over_2_bpsk_enabled,
nrofSymbols,
nrofPRB,
n_SF_PUCCH_s,
intraSlotFrequencyHopping,
add_dmrs,
b,
&M_bit);
M_bit = nr_pucch_output_sequence_length(pucch_pdu->format_type,
nrofSymbols,
nrofPRB,
n_SF_PUCCH_s,
is_pi_over_2_bpsk_enabled,
add_dmrs);
nr_uci_encoding(pucch_pdu->payload, pucch_pdu->n_bit, nrofPRB, false, M_bit, 0, b);
/*
* Implementing TS 38.211
* Subclauses 6.3.2.6.1 Scrambling (PUCCH formats 3 and 4)

View File

@@ -72,6 +72,8 @@ void nr_generate_pucch3_4(const PHY_VARS_NR_UE *ue,
const int nr_slot_tx,
const fapi_nr_ul_config_pucch_pdu *pucch_pdu);
void nr_uci_encoding(uint64_t payload, uint8_t nr_bit, uint8_t nrofPRB, bool uci_on_pusch, uint16_t E, uint8_t Qm, uint64_t *b);
static const uint8_t list_of_prime_numbers[46] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29,
31, 37, 41, 43, 47, 53, 59, 61, 67, 71,
73, 79, 83, 89, 97, 101,103,107,109,113,

View File

@@ -45,6 +45,7 @@ if(ENABLE_UESCOPE OR ENABLE_ENBSCOPE OR ENABLE_NRSCOPE)
lte_phy_scope.c
../../../executables/stats.c)
target_link_libraries(xforms_common PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs)
target_link_libraries(xforms_common PRIVATE log_headers)
add_library(enbscope MODULE lte_enb_scope.c $<TARGET_OBJECTS:xforms_common>)
target_link_libraries(enbscope PUBLIC forms PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs UTIL)

Some files were not shown because too many files have changed in this diff Show More