From 4523ee6087524dabf4d35c39c40015f33498c6c8 Mon Sep 17 00:00:00 2001 From: Codebot Date: Fri, 19 Mar 2021 11:45:56 +0100 Subject: [PATCH 01/48] rename srsLTE to srsRAN --- .gdbinit | 4 +- .github/ISSUE_TEMPLATE.md | 2 +- .github/workflows/ccpp.yml | 6 +- CMakeLists.txt | 24 +- COPYRIGHT | 40 +- CTestConfig.cmake | 6 +- README.md | 36 +- build_trial.sh | 4 +- cmake/modules/CheckFunctionExists.c | 2 +- cmake/modules/FindFFTW3F.cmake | 2 +- cmake/modules/FindLibConfig.cmake | 2 +- cmake/modules/FindLimeSDR.cmake | 2 +- cmake/modules/FindMKL.cmake | 2 +- cmake/modules/FindMbedTLS.cmake | 2 +- cmake/modules/FindPCSCLite.cmake | 2 +- cmake/modules/FindPolarssl.cmake | 2 +- cmake/modules/FindSCTP.cmake | 2 +- cmake/modules/FindSRSGUI.cmake | 2 +- cmake/modules/FindSSE.cmake | 2 +- cmake/modules/FindSoapySDR.cmake | 2 +- cmake/modules/FindUHD.cmake | 4 +- cmake/modules/FindZeroMQ.cmake | 2 +- cmake/modules/FindbladeRF.cmake | 2 +- cmake/modules/SRSLTEVersion.cmake | 13 - ...RSLTEPackage.cmake => SRSRANPackage.cmake} | 12 +- cmake/modules/SRSRANVersion.cmake | 13 + ...igs.sh.in => SRSRAN_install_configs.sh.in} | 22 +- ...info.cmake.in => SRSRANbuildinfo.cmake.in} | 4 +- debian/control | 44 +- debian/copyright | 52 +- debian/man/srsenb.txt | 2 +- debian/man/srsepc.txt | 2 +- debian/man/srsue.txt | 2 +- debian/packager.sh | 18 +- debian/srsenb.service | 2 +- debian/srsepc.service | 2 +- debian/srslte-core.config | 2 +- debian/srslte-core.install | 6 +- debian/srslte-core.postinst | 4 +- debian/srslte-core.templates | 6 +- debian/srslte-dev.install | 2 +- debian/srsue.service | 2 +- lib/CMakeLists.txt | 2 +- lib/examples/CMakeLists.txt | 36 +- lib/examples/cell_search.c | 86 +- lib/examples/cell_search_nbiot.c | 92 +- lib/examples/npdsch_enodeb.c | 286 ++-- lib/examples/npdsch_ue.c | 330 ++--- lib/examples/npdsch_ue_helper.cc | 26 +- lib/examples/npdsch_ue_helper.h | 12 +- lib/examples/pdsch_enodeb.c | 356 ++--- lib/examples/pdsch_ue.c | 304 ++-- lib/examples/pssch_ue.c | 220 +-- lib/examples/synch_file.c | 64 +- lib/examples/test/CMakeLists.txt | 2 +- lib/examples/test/iqtests.cmake | 2 +- lib/examples/usrp_capture.c | 42 +- lib/examples/usrp_capture_sync.c | 84 +- lib/examples/usrp_capture_sync_nbiot.c | 66 +- lib/examples/usrp_txrx.c | 64 +- lib/examples/zmq_remote_rx.c | 38 +- lib/include/CMakeLists.txt | 4 +- lib/include/srslte/config.h | 64 - .../srslte/phy/ch_estimation/chest_dl.h | 164 --- .../srslte/phy/ch_estimation/chest_dl_nbiot.h | 88 -- .../srslte/phy/ch_estimation/chest_sl.h | 107 -- .../srslte/phy/ch_estimation/chest_ul.h | 116 -- lib/include/srslte/phy/ch_estimation/csi_rs.h | 124 -- .../srslte/phy/ch_estimation/refsignal_dl.h | 92 -- .../phy/ch_estimation/refsignal_dl_nbiot.h | 55 - .../srslte/phy/ch_estimation/refsignal_ul.h | 184 --- lib/include/srslte/phy/common/phy_common.h | 524 ------- lib/include/srslte/phy/common/phy_common_sl.h | 167 --- lib/include/srslte/phy/enb/enb_dl.h | 162 --- lib/include/srslte/phy/enb/enb_dl_nr.h | 67 - lib/include/srslte/phy/enb/enb_ul.h | 78 - .../srslte/phy/fec/turbo/turbodecoder.h | 114 -- lib/include/srslte/phy/io/format.h | 26 - lib/include/srslte/phy/phch/dci.h | 243 ---- lib/include/srslte/phy/phch/dci_nbiot.h | 74 - lib/include/srslte/phy/phch/npbch.h | 143 -- lib/include/srslte/phy/phch/npdcch.h | 124 -- lib/include/srslte/phy/phch/npdsch.h | 151 -- lib/include/srslte/phy/phch/pbch.h | 99 -- lib/include/srslte/phy/phch/pcfich.h | 82 -- lib/include/srslte/phy/phch/pdcch.h | 137 -- lib/include/srslte/phy/phch/pdsch.h | 124 -- lib/include/srslte/phy/phch/pdsch_nr.h | 103 -- lib/include/srslte/phy/phch/phich.h | 118 -- lib/include/srslte/phy/phch/pmch.h | 97 -- lib/include/srslte/phy/phch/pscch.h | 90 -- lib/include/srslte/phy/phch/pucch.h | 175 --- lib/include/srslte/phy/phch/pusch.h | 130 -- lib/include/srslte/phy/phch/ra.h | 98 -- lib/include/srslte/phy/phch/ra_dl.h | 65 - lib/include/srslte/phy/phch/ra_ul.h | 60 - lib/include/srslte/phy/phch/sch.h | 133 -- lib/include/srslte/phy/phch/uci_cfg.h | 64 - .../srslte/phy/scrambling/scrambling.h | 49 - lib/include/srslte/phy/sync/cfo.h | 56 - lib/include/srslte/phy/sync/cp.h | 38 - lib/include/srslte/phy/sync/pss.h | 135 -- lib/include/srslte/phy/sync/sss.h | 119 -- lib/include/srslte/phy/sync/ssss.h | 71 - lib/include/srslte/phy/ue/ue_cell_search.h | 102 -- .../srslte/phy/ue/ue_cell_search_nbiot.h | 72 - lib/include/srslte/phy/ue/ue_dl.h | 238 ---- lib/include/srslte/phy/ue/ue_dl_nbiot.h | 182 --- lib/include/srslte/phy/ue/ue_dl_nr.h | 189 --- lib/include/srslte/phy/ue/ue_mib.h | 116 -- lib/include/srslte/phy/ue/ue_sync.h | 276 ---- lib/include/srslte/phy/ue/ue_sync_nbiot.h | 156 -- lib/include/srslte/phy/ue/ue_ul.h | 158 -- lib/include/srslte/phy/ue/ue_ul_nr.h | 98 -- lib/include/srslte/phy/utils/random.h | 48 - lib/include/srslte/phy/utils/vector_simd.h | 141 -- lib/include/srslte/srslte.h | 135 -- lib/include/srslte/version.h.in | 43 - lib/include/{srslte => srsran}/CMakeLists.txt | 4 +- .../{srslte => srsran}/adt/accumulators.h | 12 +- .../{srslte => srsran}/adt/adt_utils.h | 16 +- .../{srslte => srsran}/adt/bounded_bitset.h | 18 +- .../{srslte => srsran}/adt/bounded_vector.h | 12 +- .../{srslte => srsran}/adt/choice_type.h | 14 +- .../{srslte => srsran}/adt/circular_array.h | 12 +- .../{srslte => srsran}/adt/circular_buffer.h | 20 +- .../adt/detail/index_sequence.h | 6 +- .../adt/detail/type_utils.h | 16 +- lib/include/{srslte => srsran}/adt/expected.h | 12 +- lib/include/{srslte => srsran}/adt/interval.h | 18 +- lib/include/{srslte => srsran}/adt/mem_pool.h | 14 +- .../{srslte => srsran}/adt/move_callback.h | 12 +- lib/include/{srslte => srsran}/adt/observer.h | 12 +- .../{srslte => srsran}/adt/scope_exit.h | 12 +- lib/include/{srslte => srsran}/adt/span.h | 12 +- .../{srslte => srsran}/asn1/asn1_utils.h | 4 +- lib/include/{srslte => srsran}/asn1/gtpc.h | 14 +- .../{srslte => srsran}/asn1/gtpc_ies.h | 14 +- .../{srslte => srsran}/asn1/gtpc_msg.h | 14 +- .../{srslte => srsran}/asn1/liblte_common.h | 8 +- .../{srslte => srsran}/asn1/liblte_mme.h | 10 +- lib/include/{srslte => srsran}/asn1/ngap.h | 2 +- lib/include/{srslte => srsran}/asn1/rrc.h | 2 +- .../{srslte => srsran}/asn1/rrc/bcch_msg.h | 2 +- .../{srslte => srsran}/asn1/rrc/common.h | 4 +- .../{srslte => srsran}/asn1/rrc/common_ext.h | 2 +- .../{srslte => srsran}/asn1/rrc/dl_ccch_msg.h | 2 +- .../{srslte => srsran}/asn1/rrc/dl_dcch_msg.h | 2 +- .../{srslte => srsran}/asn1/rrc/ho_cmd.h | 2 +- .../{srslte => srsran}/asn1/rrc/meascfg.h | 2 +- .../{srslte => srsran}/asn1/rrc/paging.h | 2 +- .../{srslte => srsran}/asn1/rrc/phy_ded.h | 2 +- .../{srslte => srsran}/asn1/rrc/rr_common.h | 2 +- .../{srslte => srsran}/asn1/rrc/rr_ded.h | 2 +- .../{srslte => srsran}/asn1/rrc/rrc_asn1.h | 2 +- .../{srslte => srsran}/asn1/rrc/security.h | 2 +- lib/include/{srslte => srsran}/asn1/rrc/si.h | 2 +- .../{srslte => srsran}/asn1/rrc/uecap.h | 2 +- .../{srslte => srsran}/asn1/rrc/ul_ccch_msg.h | 2 +- .../{srslte => srsran}/asn1/rrc/ul_dcch_msg.h | 2 +- .../{srslte => srsran}/asn1/rrc_nbiot.h | 2 +- lib/include/{srslte => srsran}/asn1/rrc_nr.h | 2 +- .../{srslte => srsran}/asn1/rrc_nr_utils.h | 22 +- .../{srslte => srsran}/asn1/rrc_utils.h | 28 +- lib/include/{srslte => srsran}/asn1/s1ap.h | 2 +- .../{srslte => srsran}/asn1/s1ap_utils.h | 8 +- .../{srslte => srsran}/build_info.h.in | 14 +- .../{srslte => srsran}/common/backtrace.h | 12 +- .../{srslte => srsran}/common/backward.hpp | 0 .../{srslte => srsran}/common/band_helper.h | 18 +- .../{srslte => srsran}/common/basic_pnf.h | 48 +- .../{srslte => srsran}/common/basic_vnf.h | 26 +- .../{srslte => srsran}/common/basic_vnf_api.h | 8 +- .../{srslte => srsran}/common/bcd_helpers.h | 12 +- .../{srslte => srsran}/common/block_queue.h | 18 +- .../{srslte => srsran}/common/buffer_pool.h | 28 +- .../{srslte => srsran}/common/byte_buffer.h | 50 +- .../{srslte => srsran}/common/common.h | 38 +- .../{srslte => srsran}/common/common_helper.h | 16 +- .../{srslte => srsran}/common/config_file.h | 16 +- .../{srslte => srsran}/common/crash_handler.h | 12 +- .../{srslte => srsran}/common/enb_events.h | 2 +- .../{srslte => srsran}/common/epoll_helper.h | 26 +- lib/include/{srslte => srsran}/common/fsm.h | 40 +- .../common/gen_mch_tables.h | 2 +- .../{srslte => srsran}/common/int_helpers.h | 12 +- .../common/interfaces_common.h | 30 +- .../common/liblte_security.h | 8 +- .../{srslte => srsran}/common/log_helper.h | 14 +- .../{srslte => srsran}/common/mac_pcap.h | 20 +- .../{srslte => srsran}/common/mac_pcap_base.h | 28 +- .../{srslte => srsran}/common/mac_pcap_net.h | 28 +- .../{srslte => srsran}/common/metrics_hub.h | 14 +- .../{srslte => srsran}/common/multiqueue.h | 14 +- .../{srslte => srsran}/common/nas_pcap.h | 14 +- .../common/netsource_handler.h | 16 +- .../{srslte => srsran}/common/network_utils.h | 20 +- lib/include/{srslte => srsran}/common/pcap.h | 8 +- .../{srslte => srsran}/common/rlc_pcap.h | 10 +- .../{srslte => srsran}/common/rwlock_guard.h | 12 +- .../{srslte => srsran}/common/s1ap_pcap.h | 14 +- lib/include/{srslte => srsran}/common/s3g.h | 8 +- .../{srslte => srsran}/common/security.h | 14 +- .../common/signal_handler.h | 32 +- .../{srslte => srsran}/common/singleton.h | 8 +- lib/include/{srslte => srsran}/common/ssl.h | 8 +- .../common/stack_procedure.h | 16 +- .../common/standard_streams.h | 12 +- .../common/string_helpers.h | 14 +- .../common/task_scheduler.h | 46 +- .../{srslte => srsran}/common/test_common.h | 20 +- .../{srslte => srsran}/common/thread_pool.h | 22 +- .../{srslte => srsran}/common/threads.h | 12 +- .../{srslte => srsran}/common/time_prof.h | 14 +- .../{srslte => srsran}/common/timeout.h | 14 +- .../{srslte => srsran}/common/timers.h | 24 +- lib/include/{srslte => srsran}/common/trace.h | 12 +- .../{srslte => srsran}/common/tti_point.h | 34 +- .../{srslte => srsran}/common/tti_sempahore.h | 12 +- .../{srslte => srsran}/common/tti_sync.h | 12 +- .../{srslte => srsran}/common/tti_sync_cv.h | 14 +- lib/include/{srslte => srsran}/common/zuc.h | 8 +- lib/include/srsran/config.h | 64 + .../interfaces/enb_command_interface.h | 8 +- .../interfaces/enb_gtpu_interfaces.h | 12 +- .../interfaces/enb_interfaces.h | 14 +- .../interfaces/enb_mac_interfaces.h | 44 +- .../interfaces/enb_metrics_interface.h | 28 +- .../interfaces/enb_pdcp_interfaces.h | 32 +- .../interfaces/enb_phy_interfaces.h | 20 +- .../interfaces/enb_rlc_interfaces.h | 18 +- .../interfaces/enb_rrc_interface_types.h | 10 +- .../interfaces/enb_rrc_interfaces.h | 22 +- .../interfaces/enb_s1ap_interfaces.h | 30 +- .../interfaces/epc_interfaces.h | 28 +- .../interfaces/gnb_interfaces.h | 68 +- .../interfaces/mac_interface_types.h | 12 +- .../interfaces/nr_common_interface_types.h | 12 +- .../interfaces/pdcp_interface_types.h | 22 +- .../interfaces/phy_interface_types.h | 18 +- .../interfaces/radio_interfaces.h | 34 +- .../interfaces/rlc_interface_types.h | 33 +- .../interfaces/rrc_interface_types.h | 54 +- .../interfaces/rrc_nr_interface_types.h | 116 +- .../interfaces/sched_interface.h | 56 +- .../interfaces/ue_gw_interfaces.h | 16 +- .../interfaces/ue_interfaces.h | 10 +- .../interfaces/ue_mac_interfaces.h | 24 +- .../interfaces/ue_nas_interfaces.h | 18 +- .../interfaces/ue_nr_interfaces.h | 44 +- .../interfaces/ue_pdcp_interfaces.h | 38 +- .../interfaces/ue_phy_interfaces.h | 36 +- .../interfaces/ue_rlc_interfaces.h | 24 +- .../interfaces/ue_rrc_interfaces.h | 40 +- .../interfaces/ue_usim_interfaces.h | 26 +- .../{srslte => srsran}/mac/mac_rar_pdu_nr.h | 22 +- .../{srslte => srsran}/mac/mac_sch_pdu_nr.h | 22 +- lib/include/{srslte => srsran}/mac/pdu.h | 22 +- .../{srslte => srsran}/mac/pdu_queue.h | 24 +- lib/include/{srslte => srsran}/phy/agc/agc.h | 62 +- .../phy/ch_estimation/chest_common.h | 32 +- .../srsran/phy/ch_estimation/chest_dl.h | 163 +++ .../srsran/phy/ch_estimation/chest_dl_nbiot.h | 88 ++ .../srsran/phy/ch_estimation/chest_sl.h | 106 ++ .../srsran/phy/ch_estimation/chest_ul.h | 116 ++ lib/include/srsran/phy/ch_estimation/csi_rs.h | 124 ++ .../phy/ch_estimation/dmrs_pdcch.h | 96 +- .../phy/ch_estimation/dmrs_pucch.h | 74 +- .../phy/ch_estimation/dmrs_sch.h | 92 +- .../srsran/phy/ch_estimation/refsignal_dl.h | 92 ++ .../phy/ch_estimation/refsignal_dl_nbiot.h | 55 + .../srsran/phy/ch_estimation/refsignal_ul.h | 184 +++ .../phy/ch_estimation/wiener_dl.h | 92 +- .../{srslte => srsran}/phy/channel/ch_awgn.h | 30 +- .../{srslte => srsran}/phy/channel/channel.h | 28 +- .../{srslte => srsran}/phy/channel/delay.h | 28 +- .../{srslte => srsran}/phy/channel/fading.h | 50 +- .../{srslte => srsran}/phy/channel/hst.h | 24 +- .../{srslte => srsran}/phy/channel/rlf.h | 22 +- lib/include/srsran/phy/common/phy_common.h | 524 +++++++ .../phy/common/phy_common_nr.h | 250 ++-- lib/include/srsran/phy/common/phy_common_sl.h | 167 +++ .../{srslte => srsran}/phy/common/sequence.h | 98 +- .../{srslte => srsran}/phy/common/timestamp.h | 34 +- .../phy/common/zc_sequence.h | 42 +- lib/include/{srslte => srsran}/phy/dft/dft.h | 60 +- .../phy/dft/dft_precoding.h | 36 +- lib/include/{srslte => srsran}/phy/dft/ofdm.h | 82 +- lib/include/srsran/phy/enb/enb_dl.h | 162 +++ lib/include/srsran/phy/enb/enb_dl_nr.h | 67 + lib/include/srsran/phy/enb/enb_ul.h | 78 + .../{srslte => srsran}/phy/fec/block/block.h | 30 +- .../{srslte => srsran}/phy/fec/cbsegm.h | 36 +- .../phy/fec/convolutional/convcoder.h | 16 +- .../phy/fec/convolutional/rm_conv.h | 24 +- .../phy/fec/convolutional/viterbi.h | 46 +- lib/include/{srslte => srsran}/phy/fec/crc.h | 32 +- .../phy/fec/ldpc/base_graph.h | 28 +- .../phy/fec/ldpc/ldpc_common.h | 8 +- .../phy/fec/ldpc/ldpc_decoder.h | 64 +- .../phy/fec/ldpc/ldpc_encoder.h | 40 +- .../{srslte => srsran}/phy/fec/ldpc/ldpc_rm.h | 74 +- .../phy/fec/polar/polar_chanalloc.h | 14 +- .../phy/fec/polar/polar_code.h | 20 +- .../phy/fec/polar/polar_decoder.h | 38 +- .../phy/fec/polar/polar_encoder.h | 32 +- .../phy/fec/polar/polar_interleaver.h | 26 +- .../phy/fec/polar/polar_rm.h | 54 +- .../phy/fec/polar/test/polar_sets.h | 16 +- .../fec/polar/test/subchannel_allocation.h | 26 +- .../{srslte => srsran}/phy/fec/softbuffer.h | 46 +- .../phy/fec/turbo/rm_turbo.h | 42 +- .../phy/fec/turbo/tc_interl.h | 22 +- .../phy/fec/turbo/turbocoder.h | 38 +- .../srsran/phy/fec/turbo/turbodecoder.h | 114 ++ .../phy/fec/turbo/turbodecoder_gen.h | 22 +- .../phy/fec/turbo/turbodecoder_impl.h | 36 +- .../phy/fec/turbo/turbodecoder_iter.h | 20 +- .../phy/fec/turbo/turbodecoder_sse.h | 12 +- .../phy/fec/turbo/turbodecoder_win.h | 10 +- .../{srslte => srsran}/phy/io/binsource.h | 28 +- .../{srslte => srsran}/phy/io/filesink.h | 26 +- .../{srslte => srsran}/phy/io/filesource.h | 28 +- lib/include/srsran/phy/io/format.h | 26 + .../{srslte => srsran}/phy/io/netsink.h | 26 +- .../{srslte => srsran}/phy/io/netsource.h | 32 +- .../{srslte => srsran}/phy/mimo/layermap.h | 52 +- .../{srslte => srsran}/phy/mimo/precoding.h | 70 +- .../{srslte => srsran}/phy/modem/demod_hard.h | 22 +- .../{srslte => srsran}/phy/modem/demod_soft.h | 16 +- .../{srslte => srsran}/phy/modem/evm.h | 60 +- .../{srslte => srsran}/phy/modem/mod.h | 16 +- .../phy/modem/modem_table.h | 28 +- lib/include/{srslte => srsran}/phy/phch/cqi.h | 114 +- lib/include/{srslte => srsran}/phy/phch/csi.h | 40 +- .../{srslte => srsran}/phy/phch/csi_cfg.h | 126 +- lib/include/srsran/phy/phch/dci.h | 243 ++++ lib/include/srsran/phy/phch/dci_nbiot.h | 74 + .../{srslte => srsran}/phy/phch/dci_nr.h | 110 +- .../{srslte => srsran}/phy/phch/mib_sl.h | 30 +- lib/include/srsran/phy/phch/npbch.h | 143 ++ lib/include/srsran/phy/phch/npdcch.h | 124 ++ lib/include/srsran/phy/phch/npdsch.h | 151 ++ .../{srslte => srsran}/phy/phch/npdsch_cfg.h | 18 +- lib/include/srsran/phy/phch/pbch.h | 99 ++ lib/include/srsran/phy/phch/pcfich.h | 82 ++ lib/include/srsran/phy/phch/pdcch.h | 137 ++ .../{srslte => srsran}/phy/phch/pdcch_nr.h | 94 +- lib/include/srsran/phy/phch/pdsch.h | 124 ++ .../{srslte => srsran}/phy/phch/pdsch_cfg.h | 40 +- lib/include/srsran/phy/phch/pdsch_nr.h | 103 ++ .../{srslte => srsran}/phy/phch/phch_cfg_nr.h | 114 +- lib/include/srsran/phy/phch/phich.h | 118 ++ lib/include/srsran/phy/phch/pmch.h | 97 ++ .../{srslte => srsran}/phy/phch/prach.h | 108 +- .../{srslte => srsran}/phy/phch/psbch.h | 64 +- lib/include/srsran/phy/phch/pscch.h | 90 ++ .../{srslte => srsran}/phy/phch/pssch.h | 75 +- lib/include/srsran/phy/phch/pucch.h | 175 +++ .../{srslte => srsran}/phy/phch/pucch_cfg.h | 58 +- .../phy/phch/pucch_cfg_nr.h | 138 +- .../{srslte => srsran}/phy/phch/pucch_nr.h | 152 +- .../{srslte => srsran}/phy/phch/pucch_proc.h | 60 +- lib/include/srsran/phy/phch/pusch.h | 130 ++ .../{srslte => srsran}/phy/phch/pusch_cfg.h | 44 +- .../{srslte => srsran}/phy/phch/pusch_nr.h | 110 +- lib/include/srsran/phy/phch/ra.h | 98 ++ lib/include/srsran/phy/phch/ra_dl.h | 65 + .../{srslte => srsran}/phy/phch/ra_dl_nr.h | 46 +- .../{srslte => srsran}/phy/phch/ra_nbiot.h | 198 +-- .../{srslte => srsran}/phy/phch/ra_nr.h | 74 +- .../{srslte => srsran}/phy/phch/ra_sl.h | 62 +- lib/include/srsran/phy/phch/ra_ul.h | 60 + .../{srslte => srsran}/phy/phch/ra_ul_nr.h | 66 +- .../{srslte => srsran}/phy/phch/regs.h | 78 +- lib/include/srsran/phy/phch/sch.h | 133 ++ .../{srslte => srsran}/phy/phch/sch_cfg_nr.h | 28 +- .../{srslte => srsran}/phy/phch/sch_nr.h | 110 +- lib/include/{srslte => srsran}/phy/phch/sci.h | 47 +- lib/include/{srslte => srsran}/phy/phch/uci.h | 108 +- lib/include/srsran/phy/phch/uci_cfg.h | 64 + .../{srslte => srsran}/phy/phch/uci_cfg_nr.h | 52 +- .../{srslte => srsran}/phy/phch/uci_nr.h | 118 +- .../{srslte => srsran}/phy/resampling/decim.h | 14 +- .../phy/resampling/interp.h | 44 +- .../phy/resampling/resample_arb.h | 26 +- .../phy/resampling/resampler.h | 38 +- lib/include/{srslte => srsran}/phy/rf/rf.h | 108 +- .../{srslte => srsran}/phy/rf/rf_utils.h | 30 +- .../srsran/phy/scrambling/scrambling.h | 49 + lib/include/srsran/phy/sync/cfo.h | 56 + lib/include/srsran/phy/sync/cp.h | 38 + .../{srslte => srsran}/phy/sync/npss.h | 80 +- .../{srslte => srsran}/phy/sync/nsss.h | 62 +- lib/include/srsran/phy/sync/pss.h | 135 ++ .../{srslte => srsran}/phy/sync/psss.h | 36 +- .../phy/sync/refsignal_dl_sync.h | 34 +- lib/include/{srslte => srsran}/phy/sync/sfo.h | 14 +- lib/include/srsran/phy/sync/sss.h | 118 ++ lib/include/srsran/phy/sync/ssss.h | 71 + .../{srslte => srsran}/phy/sync/sync.h | 132 +- .../{srslte => srsran}/phy/sync/sync_nbiot.h | 74 +- lib/include/srsran/phy/ue/ue_cell_search.h | 94 ++ .../srsran/phy/ue/ue_cell_search_nbiot.h | 72 + lib/include/srsran/phy/ue/ue_dl.h | 238 ++++ lib/include/srsran/phy/ue/ue_dl_nbiot.h | 182 +++ lib/include/srsran/phy/ue/ue_dl_nr.h | 189 +++ lib/include/srsran/phy/ue/ue_mib.h | 111 ++ .../{srslte => srsran}/phy/ue/ue_mib_nbiot.h | 76 +- .../{srslte => srsran}/phy/ue/ue_mib_sl.h | 22 +- .../{srslte => srsran}/phy/ue/ue_phy.h | 36 +- lib/include/srsran/phy/ue/ue_sync.h | 264 ++++ lib/include/srsran/phy/ue/ue_sync_nbiot.h | 156 ++ lib/include/srsran/phy/ue/ue_ul.h | 158 ++ lib/include/srsran/phy/ue/ue_ul_nr.h | 98 ++ .../{srslte => srsran}/phy/utils/bit.h | 50 +- .../{srslte => srsran}/phy/utils/cexptab.h | 24 +- .../phy/utils/convolution.h | 48 +- .../{srslte => srsran}/phy/utils/debug.h | 48 +- .../{srslte => srsran}/phy/utils/filter.h | 24 +- .../{srslte => srsran}/phy/utils/mat.h | 128 +- .../{srslte => srsran}/phy/utils/phy_logger.h | 12 +- .../{srslte => srsran}/phy/utils/primes.h | 18 +- lib/include/srsran/phy/utils/random.h | 48 + .../{srslte => srsran}/phy/utils/ringbuffer.h | 46 +- .../{srslte => srsran}/phy/utils/simd.h | 316 ++-- .../{srslte => srsran}/phy/utils/vector.h | 236 +-- lib/include/srsran/phy/utils/vector_simd.h | 141 ++ .../radio/channel_mapping.h | 12 +- lib/include/{srslte => srsran}/radio/radio.h | 56 +- .../{srslte => srsran}/radio/radio_base.h | 16 +- .../{srslte => srsran}/radio/radio_metrics.h | 12 +- .../{srslte => srsran}/radio/radio_null.h | 26 +- .../{srslte => srsran}/radio/rf_buffer.h | 34 +- .../{srslte => srsran}/radio/rf_timestamp.h | 34 +- .../{srslte => srsran}/rrc/rrc_cfg_utils.h | 16 +- .../srslog/bundled/fmt/LICENSE.rst | 0 .../srslog/bundled/fmt/chrono.h | 0 .../srslog/bundled/fmt/color.h | 0 .../srslog/bundled/fmt/compile.h | 0 .../srslog/bundled/fmt/core.h | 0 .../srslog/bundled/fmt/format-inl.h | 0 .../srslog/bundled/fmt/format.h | 0 .../srslog/bundled/fmt/locale.h | 0 .../srslog/bundled/fmt/os.h | 0 .../srslog/bundled/fmt/ostream.h | 0 .../srslog/bundled/fmt/posix.h | 0 .../srslog/bundled/fmt/printf.h | 0 .../srslog/bundled/fmt/ranges.h | 0 .../{srslte => srsran}/srslog/context.h | 4 +- .../srslog/detail/log_backend.h | 2 +- .../srslog/detail/log_entry.h | 6 +- .../srslog/detail/log_entry_metadata.h | 4 +- .../srslog/detail/support/any.h | 2 +- .../srslog/detail/support/error_string.h | 2 +- .../srslog/detail/support/memory_buffer.h | 2 +- .../srslog/detail/support/thread_utils.h | 2 +- .../srslog/detail/support/tmp_utils.h | 2 +- .../srslog/detail/support/work_queue.h | 4 +- .../{srslte => srsran}/srslog/event_trace.h | 2 +- .../{srslte => srsran}/srslog/formatter.h | 6 +- .../{srslte => srsran}/srslog/log_channel.h | 8 +- .../{srslte => srsran}/srslog/logger.h | 4 +- .../{srslte => srsran}/srslog/shared_types.h | 2 +- lib/include/{srslte => srsran}/srslog/sink.h | 8 +- .../{srslte => srsran}/srslog/srslog.h | 8 +- .../{srslte => srsran}/srslog/srslog_c.h | 2 +- lib/include/srsran/srsran.h | 135 ++ .../{srslte => srsran}/system/sys_metrics.h | 12 +- .../system/sys_metrics_processor.h | 14 +- .../test/ue_test_interfaces.h | 34 +- .../upper/byte_buffer_queue.h | 20 +- lib/include/{srslte => srsran}/upper/gtpu.h | 20 +- lib/include/{srslte => srsran}/upper/ipv6.h | 8 +- lib/include/{srslte => srsran}/upper/pdcp.h | 36 +- .../upper/pdcp_entity_base.h | 60 +- .../upper/pdcp_entity_lte.h | 54 +- .../{srslte => srsran}/upper/pdcp_entity_nr.h | 34 +- .../{srslte => srsran}/upper/pdcp_metrics.h | 16 +- lib/include/{srslte => srsran}/upper/rlc.h | 38 +- .../{srslte => srsran}/upper/rlc_am_base.h | 20 +- .../{srslte => srsran}/upper/rlc_am_lte.h | 50 +- .../{srslte => srsran}/upper/rlc_am_nr.h | 20 +- .../{srslte => srsran}/upper/rlc_common.h | 18 +- .../{srslte => srsran}/upper/rlc_metrics.h | 18 +- lib/include/{srslte => srsran}/upper/rlc_tm.h | 20 +- .../{srslte => srsran}/upper/rlc_um_base.h | 32 +- .../{srslte => srsran}/upper/rlc_um_lte.h | 24 +- .../{srslte => srsran}/upper/rlc_um_nr.h | 26 +- lib/include/srsran/version.h.in | 43 + lib/src/CMakeLists.txt | 2 +- lib/src/asn1/CMakeLists.txt | 14 +- lib/src/asn1/asn1_utils.cc | 4 +- lib/src/asn1/gtpc.cc | 12 +- lib/src/asn1/liblte_common.cc | 2 +- lib/src/asn1/liblte_mme.cc | 8 +- lib/src/asn1/ngap.cc | 4 +- lib/src/asn1/rrc.cc | 4 +- lib/src/asn1/rrc/bcch_msg.cc | 4 +- lib/src/asn1/rrc/common.cc | 4 +- lib/src/asn1/rrc/common_ext.cc | 4 +- lib/src/asn1/rrc/dl_ccch_msg.cc | 4 +- lib/src/asn1/rrc/dl_dcch_msg.cc | 4 +- lib/src/asn1/rrc/ho_cmd.cc | 4 +- lib/src/asn1/rrc/meascfg.cc | 4 +- lib/src/asn1/rrc/paging.cc | 4 +- lib/src/asn1/rrc/phy_ded.cc | 4 +- lib/src/asn1/rrc/rr_common.cc | 4 +- lib/src/asn1/rrc/rr_ded.cc | 4 +- lib/src/asn1/rrc/security.cc | 4 +- lib/src/asn1/rrc/si.cc | 4 +- lib/src/asn1/rrc/uecap.cc | 4 +- lib/src/asn1/rrc/ul_ccch_msg.cc | 4 +- lib/src/asn1/rrc/ul_dcch_msg.cc | 4 +- lib/src/asn1/rrc_nbiot.cc | 4 +- lib/src/asn1/rrc_nr.cc | 4 +- lib/src/asn1/rrc_nr_utils.cc | 30 +- lib/src/asn1/rrc_utils.cc | 92 +- lib/src/asn1/s1ap.cc | 4 +- lib/src/common/CMakeLists.txt | 16 +- lib/src/common/arch_select.cc | 2 +- lib/src/common/backtrace.c | 4 +- lib/src/common/band_helper.cc | 22 +- lib/src/common/basic_vnf.cc | 70 +- lib/src/common/buffer_pool.cc | 6 +- lib/src/common/byte_buffer.cc | 10 +- lib/src/common/crash_handler.cc | 24 +- lib/src/common/enb_events.cc | 8 +- lib/src/common/gen_mch_tables.c | 4 +- lib/src/common/liblte_security.cc | 8 +- lib/src/common/mac_pcap.cc | 30 +- lib/src/common/mac_pcap_base.cc | 26 +- lib/src/common/mac_pcap_net.cc | 24 +- lib/src/common/nas_pcap.cc | 16 +- lib/src/common/network_utils.cc | 24 +- lib/src/common/pcap.c | 4 +- lib/src/common/rlc_pcap.cc | 12 +- lib/src/common/s1ap_pcap.cc | 12 +- lib/src/common/s3g.cc | 4 +- lib/src/common/security.cc | 16 +- lib/src/common/standard_streams.cc | 10 +- lib/src/common/test/CMakeLists.txt | 8 +- lib/src/common/test/band_helper_test.cc | 16 +- lib/src/common/test/thread_pool_test.cc | 40 +- lib/src/common/test/thread_test.cc | 6 +- lib/src/common/thread_pool.cc | 12 +- lib/src/common/threads.c | 4 +- lib/src/common/time_prof.cc | 10 +- lib/src/common/tti_sync_cv.cc | 8 +- lib/src/common/version.c | 24 +- lib/src/common/zuc.cc | 4 +- lib/src/mac/CMakeLists.txt | 8 +- lib/src/mac/mac_rar_pdu_nr.cc | 20 +- lib/src/mac/mac_sch_pdu_nr.cc | 20 +- lib/src/mac/pdu.cc | 54 +- lib/src/mac/pdu_queue.cc | 10 +- lib/src/phy/CMakeLists.txt | 40 +- lib/src/phy/agc/CMakeLists.txt | 4 +- lib/src/phy/agc/agc.c | 100 +- lib/src/phy/ch_estimation/CMakeLists.txt | 4 +- lib/src/phy/ch_estimation/chest_common.c | 28 +- lib/src/phy/ch_estimation/chest_dl.c | 600 ++++---- lib/src/phy/ch_estimation/chest_dl_nbiot.c | 190 +-- lib/src/phy/ch_estimation/chest_sl.c | 656 ++++----- lib/src/phy/ch_estimation/chest_ul.c | 314 ++-- lib/src/phy/ch_estimation/csi_rs.c | 170 +-- lib/src/phy/ch_estimation/dmrs_pdcch.c | 214 +-- lib/src/phy/ch_estimation/dmrs_pucch.c | 240 ++-- lib/src/phy/ch_estimation/dmrs_sch.c | 354 ++--- lib/src/phy/ch_estimation/refsignal_dl.c | 264 ++-- .../phy/ch_estimation/refsignal_dl_nbiot.c | 166 +-- lib/src/phy/ch_estimation/refsignal_ul.c | 452 +++--- lib/src/phy/ch_estimation/test/CMakeLists.txt | 20 +- .../ch_estimation/test/chest_nbiot_test_dl.c | 104 +- .../phy/ch_estimation/test/chest_test_dl.c | 80 +- .../phy/ch_estimation/test/chest_test_sl.c | 56 +- .../phy/ch_estimation/test/chest_test_srs.c | 98 +- .../phy/ch_estimation/test/chest_test_ul.c | 84 +- lib/src/phy/ch_estimation/test/csi_rs_test.c | 70 +- .../phy/ch_estimation/test/dmrs_pdcch_test.c | 82 +- .../phy/ch_estimation/test/dmrs_pdsch_test.c | 212 +-- .../ch_estimation/test/refsignal_ul_test.c | 42 +- lib/src/phy/ch_estimation/wiener_dl.c | 386 ++--- lib/src/phy/channel/CMakeLists.txt | 4 +- lib/src/phy/channel/ch_awgn.c | 80 +- lib/src/phy/channel/channel.cc | 110 +- lib/src/phy/channel/delay.c | 48 +- lib/src/phy/channel/fading.c | 120 +- lib/src/phy/channel/gauss.c | 2 +- lib/src/phy/channel/gauss.h | 2 +- lib/src/phy/channel/hst.c | 26 +- lib/src/phy/channel/rlf.c | 18 +- lib/src/phy/channel/test/CMakeLists.txt | 10 +- lib/src/phy/channel/test/awgn_channel_test.c | 58 +- lib/src/phy/channel/test/delay_channel_test.c | 42 +- .../phy/channel/test/fading_channel_test.c | 54 +- lib/src/phy/channel/test/hst_channel_test.c | 44 +- lib/src/phy/common/CMakeLists.txt | 4 +- lib/src/phy/common/phy_common.c | 434 +++--- lib/src/phy/common/phy_common_nr.c | 70 +- lib/src/phy/common/phy_common_sl.c | 392 ++--- lib/src/phy/common/sequence.c | 76 +- lib/src/phy/common/test/CMakeLists.txt | 4 +- lib/src/phy/common/test/sequence_test.c | 66 +- lib/src/phy/common/timestamp.c | 44 +- lib/src/phy/common/zc_sequence.c | 104 +- lib/src/phy/dft/CMakeLists.txt | 4 +- lib/src/phy/dft/dft_fftw.c | 108 +- lib/src/phy/dft/dft_precoding.c | 66 +- lib/src/phy/dft/ofdm.c | 280 ++-- lib/src/phy/dft/test/CMakeLists.txt | 4 +- lib/src/phy/dft/test/ofdm_test.c | 56 +- lib/src/phy/enb/CMakeLists.txt | 4 +- lib/src/phy/enb/enb_dl.c | 374 ++--- lib/src/phy/enb/enb_dl_nr.c | 148 +- lib/src/phy/enb/enb_ul.c | 154 +- lib/src/phy/fec/CMakeLists.txt | 4 +- lib/src/phy/fec/block/CMakeLists.txt | 2 +- lib/src/phy/fec/block/block.c | 64 +- lib/src/phy/fec/block/test/CMakeLists.txt | 4 +- lib/src/phy/fec/block/test/block_test.c | 48 +- lib/src/phy/fec/cbsegm.c | 94 +- lib/src/phy/fec/convolutional/CMakeLists.txt | 2 +- lib/src/phy/fec/convolutional/convcoder.c | 8 +- lib/src/phy/fec/convolutional/parity.c | 2 +- lib/src/phy/fec/convolutional/parity.h | 8 +- .../phy/fec/convolutional/test/CMakeLists.txt | 4 +- .../phy/fec/convolutional/test/viterbi_test.c | 80 +- .../phy/fec/convolutional/test/viterbi_test.h | 2 +- lib/src/phy/fec/convolutional/viterbi.c | 116 +- lib/src/phy/fec/convolutional/viterbi37.h | 8 +- lib/src/phy/fec/crc.c | 46 +- lib/src/phy/fec/ldpc/CMakeLists.txt | 2 +- lib/src/phy/fec/ldpc/base_graph.c | 10 +- lib/src/phy/fec/ldpc/ldpc_avx2_consts.h | 8 +- lib/src/phy/fec/ldpc/ldpc_avx512_consts.h | 2 +- lib/src/phy/fec/ldpc/ldpc_dec_all.h | 108 +- lib/src/phy/fec/ldpc/ldpc_dec_c.c | 16 +- lib/src/phy/fec/ldpc/ldpc_dec_c_avx2.c | 24 +- lib/src/phy/fec/ldpc/ldpc_dec_c_avx2_flood.c | 26 +- lib/src/phy/fec/ldpc/ldpc_dec_c_avx2long.c | 54 +- .../phy/fec/ldpc/ldpc_dec_c_avx2long_flood.c | 58 +- lib/src/phy/fec/ldpc/ldpc_dec_c_avx512.c | 38 +- lib/src/phy/fec/ldpc/ldpc_dec_c_avx512long.c | 40 +- .../fec/ldpc/ldpc_dec_c_avx512long_flood.c | 52 +- lib/src/phy/fec/ldpc/ldpc_dec_c_flood.c | 18 +- lib/src/phy/fec/ldpc/ldpc_dec_f.c | 20 +- lib/src/phy/fec/ldpc/ldpc_dec_s.c | 16 +- lib/src/phy/fec/ldpc/ldpc_decoder.c | 120 +- lib/src/phy/fec/ldpc/ldpc_enc_all.h | 144 +- lib/src/phy/fec/ldpc/ldpc_enc_avx2.c | 46 +- lib/src/phy/fec/ldpc/ldpc_enc_avx2long.c | 54 +- lib/src/phy/fec/ldpc/ldpc_enc_avx512.c | 40 +- lib/src/phy/fec/ldpc/ldpc_enc_avx512long.c | 48 +- lib/src/phy/fec/ldpc/ldpc_enc_c.c | 20 +- lib/src/phy/fec/ldpc/ldpc_encoder.c | 68 +- lib/src/phy/fec/ldpc/ldpc_rm.c | 70 +- lib/src/phy/fec/ldpc/test/CMakeLists.txt | 24 +- lib/src/phy/fec/ldpc/test/ldpc_chain_test.c | 138 +- .../phy/fec/ldpc/test/ldpc_dec_avx2_test.c | 32 +- .../phy/fec/ldpc/test/ldpc_dec_avx512_test.c | 22 +- lib/src/phy/fec/ldpc/test/ldpc_dec_c_test.c | 30 +- lib/src/phy/fec/ldpc/test/ldpc_dec_s_test.c | 28 +- lib/src/phy/fec/ldpc/test/ldpc_dec_test.c | 28 +- .../phy/fec/ldpc/test/ldpc_enc_avx2_test.c | 26 +- .../phy/fec/ldpc/test/ldpc_enc_avx512_test.c | 18 +- lib/src/phy/fec/ldpc/test/ldpc_enc_test.c | 26 +- .../phy/fec/ldpc/test/ldpc_rm_chain_test.c | 184 +-- lib/src/phy/fec/ldpc/test/ldpc_rm_test.c | 84 +- lib/src/phy/fec/polar/CMakeLists.txt | 2 +- lib/src/phy/fec/polar/polar_chanalloc.c | 10 +- lib/src/phy/fec/polar/polar_code.c | 22 +- lib/src/phy/fec/polar/polar_decoder.c | 50 +- lib/src/phy/fec/polar/polar_decoder_ssc_all.c | 18 +- lib/src/phy/fec/polar/polar_decoder_ssc_all.h | 2 +- lib/src/phy/fec/polar/polar_decoder_ssc_c.c | 52 +- lib/src/phy/fec/polar/polar_decoder_ssc_c.h | 2 +- .../phy/fec/polar/polar_decoder_ssc_c_avx2.c | 60 +- .../phy/fec/polar/polar_decoder_ssc_c_avx2.h | 2 +- lib/src/phy/fec/polar/polar_decoder_ssc_f.c | 40 +- lib/src/phy/fec/polar/polar_decoder_ssc_f.h | 2 +- lib/src/phy/fec/polar/polar_decoder_ssc_s.c | 48 +- lib/src/phy/fec/polar/polar_decoder_ssc_s.h | 2 +- lib/src/phy/fec/polar/polar_decoder_vector.c | 20 +- lib/src/phy/fec/polar/polar_decoder_vector.h | 24 +- .../phy/fec/polar/polar_decoder_vector_avx2.c | 26 +- .../phy/fec/polar/polar_decoder_vector_avx2.h | 26 +- lib/src/phy/fec/polar/polar_encoder.c | 28 +- lib/src/phy/fec/polar/polar_encoder_avx2.c | 28 +- lib/src/phy/fec/polar/polar_encoder_avx2.h | 4 +- .../phy/fec/polar/polar_encoder_pipelined.c | 12 +- .../phy/fec/polar/polar_encoder_pipelined.h | 4 +- lib/src/phy/fec/polar/polar_interleaver.c | 18 +- lib/src/phy/fec/polar/polar_rm.c | 44 +- lib/src/phy/fec/polar/test/CMakeLists.txt | 6 +- lib/src/phy/fec/polar/test/polar_chain_test.c | 206 ++- .../fec/polar/test/polar_interleaver_gold.h | 2 +- .../fec/polar/test/polar_interleaver_test.c | 16 +- lib/src/phy/fec/polar/test/polar_sets.c | 16 +- lib/src/phy/fec/polar/test/polar_sets.h | 16 +- .../fec/polar/test/subchannel_allocation.c | 8 +- .../fec/polar/test/subchannel_allocation.h | 26 +- lib/src/phy/fec/softbuffer.c | 126 +- lib/src/phy/fec/test/CMakeLists.txt | 4 +- lib/src/phy/fec/test/crc_test.c | 20 +- lib/src/phy/fec/test/crc_test.h | 18 +- lib/src/phy/fec/turbo/CMakeLists.txt | 2 +- lib/src/phy/fec/turbo/rm_conv.c | 32 +- lib/src/phy/fec/turbo/rm_turbo.c | 180 +-- lib/src/phy/fec/turbo/tc_interl_lte.c | 30 +- lib/src/phy/fec/turbo/tc_interl_umts.c | 24 +- lib/src/phy/fec/turbo/test/CMakeLists.txt | 10 +- lib/src/phy/fec/turbo/test/rm_conv_test.c | 16 +- lib/src/phy/fec/turbo/test/rm_turbo_test.c | 40 +- lib/src/phy/fec/turbo/test/turbocoder_test.c | 46 +- .../phy/fec/turbo/test/turbodecoder_test.c | 74 +- .../phy/fec/turbo/test/turbodecoder_test.h | 2 +- lib/src/phy/fec/turbo/turbocoder.c | 84 +- lib/src/phy/fec/turbo/turbodecoder.c | 206 +-- lib/src/phy/fec/turbo/turbodecoder_gen.c | 32 +- lib/src/phy/fec/turbo/turbodecoder_sse.c | 14 +- lib/src/phy/fec/utils_avx2.h | 12 +- lib/src/phy/fec/utils_avx512.h | 12 +- lib/src/phy/io/CMakeLists.txt | 4 +- lib/src/phy/io/binsource.c | 38 +- lib/src/phy/io/filesink.c | 54 +- lib/src/phy/io/filesource.c | 56 +- lib/src/phy/io/netsink.c | 20 +- lib/src/phy/io/netsource.c | 28 +- lib/src/phy/mimo/CMakeLists.txt | 4 +- lib/src/phy/mimo/layermap.c | 126 +- lib/src/phy/mimo/precoding.c | 1256 ++++++++-------- lib/src/phy/mimo/test/CMakeLists.txt | 8 +- lib/src/phy/mimo/test/layermap_test.c | 38 +- lib/src/phy/mimo/test/pmi_select_test.c | 38 +- lib/src/phy/mimo/test/pmi_select_test.h | 4 +- lib/src/phy/mimo/test/precoder_test.c | 104 +- lib/src/phy/modem/CMakeLists.txt | 4 +- lib/src/phy/modem/demod_hard.c | 24 +- lib/src/phy/modem/demod_soft.c | 52 +- lib/src/phy/modem/hard_demod_lte.c | 10 +- lib/src/phy/modem/hard_demod_lte.h | 4 +- lib/src/phy/modem/lte_tables.c | 4 +- lib/src/phy/modem/lte_tables.h | 10 +- lib/src/phy/modem/mod.c | 34 +- lib/src/phy/modem/modem_table.c | 70 +- lib/src/phy/modem/test/CMakeLists.txt | 6 +- lib/src/phy/modem/test/modem_test.c | 52 +- lib/src/phy/modem/test/soft_demod_test.c | 76 +- lib/src/phy/phch/CMakeLists.txt | 4 +- lib/src/phy/phch/cqi.c | 168 +-- lib/src/phy/phch/csi.c | 148 +- lib/src/phy/phch/dci.c | 928 ++++++------ lib/src/phy/phch/dci_nbiot.c | 240 ++-- lib/src/phy/phch/dci_nr.c | 500 +++---- lib/src/phy/phch/mib_sl.c | 60 +- lib/src/phy/phch/npbch.c | 292 ++-- lib/src/phy/phch/npdcch.c | 370 ++--- lib/src/phy/phch/npdsch.c | 372 ++--- lib/src/phy/phch/pbch.c | 264 ++-- lib/src/phy/phch/pcfich.c | 130 +- lib/src/phy/phch/pdcch.c | 268 ++-- lib/src/phy/phch/pdcch_nr.c | 342 ++--- lib/src/phy/phch/pdsch.c | 492 +++---- lib/src/phy/phch/pdsch_nr.c | 416 +++--- lib/src/phy/phch/phich.c | 280 ++-- lib/src/phy/phch/pmch.c | 204 +-- lib/src/phy/phch/prach.c | 286 ++-- lib/src/phy/phch/prach_tables.h | 8 +- lib/src/phy/phch/prb_dl.c | 26 +- lib/src/phy/phch/prb_dl.h | 10 +- lib/src/phy/phch/psbch.c | 250 ++-- lib/src/phy/phch/pscch.c | 254 ++-- lib/src/phy/phch/pssch.c | 406 +++--- lib/src/phy/phch/pucch.c | 780 +++++----- lib/src/phy/phch/pucch_cfg_nr.c | 152 +- lib/src/phy/phch/pucch_nr.c | 502 +++---- lib/src/phy/phch/pucch_proc.c | 182 +-- lib/src/phy/phch/pusch.c | 266 ++-- lib/src/phy/phch/pusch_nr.c | 572 ++++---- lib/src/phy/phch/ra.c | 96 +- lib/src/phy/phch/ra_dl.c | 360 ++--- lib/src/phy/phch/ra_dl_nr.c | 154 +- lib/src/phy/phch/ra_helper.h | 18 +- lib/src/phy/phch/ra_nbiot.c | 194 +-- lib/src/phy/phch/ra_nr.c | 406 +++--- lib/src/phy/phch/ra_sl.c | 86 +- lib/src/phy/phch/ra_ul.c | 128 +- lib/src/phy/phch/ra_ul_nr.c | 294 ++-- lib/src/phy/phch/regs.c | 232 +-- lib/src/phy/phch/sch.c | 284 ++-- lib/src/phy/phch/sch_nr.c | 318 ++--- lib/src/phy/phch/sci.c | 140 +- lib/src/phy/phch/sequences.c | 120 +- lib/src/phy/phch/tbs_tables.h | 10 +- lib/src/phy/phch/tbs_tables_nbiot.h | 8 +- lib/src/phy/phch/test/CMakeLists.txt | 70 +- lib/src/phy/phch/test/dci_nbiot_test.c | 58 +- lib/src/phy/phch/test/npbch_file_test.c | 102 +- lib/src/phy/phch/test/npbch_test.c | 96 +- lib/src/phy/phch/test/npdcch_file_test.c | 114 +- lib/src/phy/phch/test/npdcch_test.c | 116 +- .../phy/phch/test/npdsch_npdcch_file_test.c | 128 +- lib/src/phy/phch/test/npdsch_test.c | 232 +-- lib/src/phy/phch/test/pbch_file_test.c | 86 +- lib/src/phy/phch/test/pbch_test.c | 54 +- lib/src/phy/phch/test/pcfich_file_test.c | 98 +- lib/src/phy/phch/test/pcfich_test.c | 58 +- lib/src/phy/phch/test/pdcch_file_test.c | 112 +- lib/src/phy/phch/test/pdcch_nr_test.c | 124 +- lib/src/phy/phch/test/pdcch_test.c | 128 +- lib/src/phy/phch/test/pdsch_nr_test.c | 146 +- lib/src/phy/phch/test/pdsch_pdcch_file_test.c | 68 +- lib/src/phy/phch/test/pdsch_test.c | 222 +-- lib/src/phy/phch/test/phich_file_test.c | 102 +- lib/src/phy/phch/test/phich_test.c | 86 +- lib/src/phy/phch/test/pmch_file_test.c | 88 +- lib/src/phy/phch/test/pmch_test.c | 182 +-- lib/src/phy/phch/test/prach_test.c | 18 +- lib/src/phy/phch/test/prach_test_multi.c | 58 +- lib/src/phy/phch/test/prach_test_usrp.c | 114 +- lib/src/phy/phch/test/psbch_file_test.c | 136 +- lib/src/phy/phch/test/psbch_test.c | 84 +- lib/src/phy/phch/test/pscch_test.c | 98 +- lib/src/phy/phch/test/pssch_pscch_file_test.c | 224 +-- lib/src/phy/phch/test/pssch_test.c | 74 +- lib/src/phy/phch/test/pucch_nr_test.c | 208 +-- lib/src/phy/phch/test/pucch_test.c | 138 +- lib/src/phy/phch/test/pusch_nr_test.c | 164 +-- lib/src/phy/phch/test/pusch_test.c | 150 +- lib/src/phy/phch/test/ra_nr_test.c | 50 +- lib/src/phy/phch/test/sch_nr_test.c | 122 +- lib/src/phy/phch/uci.c | 286 ++-- lib/src/phy/phch/uci_nr.c | 626 ++++---- lib/src/phy/resampling/CMakeLists.txt | 4 +- lib/src/phy/resampling/decim.c | 10 +- lib/src/phy/resampling/interp.c | 102 +- lib/src/phy/resampling/resample_arb.c | 50 +- lib/src/phy/resampling/resampler.c | 132 +- lib/src/phy/resampling/test/CMakeLists.txt | 8 +- .../phy/resampling/test/resample_arb_bench.c | 16 +- .../phy/resampling/test/resample_arb_test.c | 16 +- lib/src/phy/resampling/test/resampler_test.c | 52 +- lib/src/phy/rf/CMakeLists.txt | 26 +- lib/src/phy/rf/rf_blade_imp.c | 44 +- lib/src/phy/rf/rf_blade_imp.h | 64 +- lib/src/phy/rf/rf_dev.h | 74 +- lib/src/phy/rf/rf_helper.h | 24 +- lib/src/phy/rf/rf_imp.c | 180 +-- lib/src/phy/rf/rf_soapy_imp.c | 120 +- lib/src/phy/rf/rf_soapy_imp.h | 68 +- lib/src/phy/rf/rf_uhd_generic.h | 8 +- lib/src/phy/rf/rf_uhd_imp.cc | 212 +-- lib/src/phy/rf/rf_uhd_imp.h | 70 +- lib/src/phy/rf/rf_uhd_rfnoc.h | 8 +- lib/src/phy/rf/rf_uhd_safe.h | 8 +- lib/src/phy/rf/rf_utils.c | 172 +-- lib/src/phy/rf/rf_zmq_imp.c | 116 +- lib/src/phy/rf/rf_zmq_imp.h | 68 +- lib/src/phy/rf/rf_zmq_imp_rx.c | 42 +- lib/src/phy/rf/rf_zmq_imp_trx.h | 38 +- lib/src/phy/rf/rf_zmq_imp_tx.c | 26 +- lib/src/phy/rf/rf_zmq_test.c | 70 +- lib/src/phy/rf/rfnoc_test.cc | 44 +- lib/src/phy/scrambling/CMakeLists.txt | 4 +- lib/src/phy/scrambling/scrambling.c | 50 +- lib/src/phy/scrambling/test/CMakeLists.txt | 4 +- lib/src/phy/scrambling/test/scrambling_test.c | 64 +- lib/src/phy/sync/CMakeLists.txt | 4 +- lib/src/phy/sync/cfo.c | 98 +- lib/src/phy/sync/cp.c | 34 +- lib/src/phy/sync/find_sss.c | 114 +- lib/src/phy/sync/gen_sss.c | 56 +- lib/src/phy/sync/npss.c | 202 +-- lib/src/phy/sync/nsss.c | 194 +-- lib/src/phy/sync/pss.c | 308 ++-- lib/src/phy/sync/psss.c | 188 +-- lib/src/phy/sync/refsignal_dl_sync.c | 188 +-- lib/src/phy/sync/sfo.c | 10 +- lib/src/phy/sync/sss.c | 80 +- lib/src/phy/sync/ssss.c | 192 +-- lib/src/phy/sync/sync.c | 358 ++--- lib/src/phy/sync/sync_nbiot.c | 156 +- lib/src/phy/sync/test/CMakeLists.txt | 26 +- lib/src/phy/sync/test/cfo_test.c | 18 +- lib/src/phy/sync/test/npss_file.c | 68 +- lib/src/phy/sync/test/npss_test.c | 79 +- lib/src/phy/sync/test/npss_usrp.c | 72 +- lib/src/phy/sync/test/nsss_test.c | 92 +- lib/src/phy/sync/test/nsss_usrp.c | 64 +- lib/src/phy/sync/test/pss_file.c | 120 +- lib/src/phy/sync/test/pss_usrp.c | 122 +- lib/src/phy/sync/test/psss_file_test.c | 58 +- lib/src/phy/sync/test/sync_nbiot_test.c | 100 +- lib/src/phy/sync/test/sync_sl_test.c | 104 +- lib/src/phy/sync/test/sync_test.c | 68 +- lib/src/phy/ue/CMakeLists.txt | 4 +- lib/src/phy/ue/test/CMakeLists.txt | 12 +- lib/src/phy/ue/test/gen_ack_test.c | 28 +- lib/src/phy/ue/test/pucch_resource_test.c | 54 +- lib/src/phy/ue/test/ue_dl_nbiot_test.c | 76 +- .../phy/ue/test/ue_mib_sync_test_nbiot_usrp.c | 72 +- lib/src/phy/ue/test/ue_sync_test_nbiot_usrp.c | 76 +- lib/src/phy/ue/ue_cell_search.c | 148 +- lib/src/phy/ue/ue_cell_search_nbiot.c | 88 +- lib/src/phy/ue/ue_dl.c | 646 ++++----- lib/src/phy/ue/ue_dl_nbiot.c | 468 +++--- lib/src/phy/ue/ue_dl_nr.c | 338 ++--- lib/src/phy/ue/ue_mib.c | 178 +-- lib/src/phy/ue/ue_mib_nbiot.c | 176 +-- lib/src/phy/ue/ue_mib_sl.c | 60 +- lib/src/phy/ue/ue_sync.c | 472 +++--- lib/src/phy/ue/ue_sync_nbiot.c | 336 ++--- lib/src/phy/ue/ue_ul.c | 322 ++--- lib/src/phy/ue/ue_ul_nr.c | 200 +-- lib/src/phy/utils/CMakeLists.txt | 6 +- lib/src/phy/utils/bit.c | 62 +- lib/src/phy/utils/cexptab.c | 28 +- lib/src/phy/utils/convolution.c | 128 +- lib/src/phy/utils/debug.c | 6 +- lib/src/phy/utils/filter.c | 34 +- lib/src/phy/utils/mat.c | 145 +- lib/src/phy/utils/phy_logger.c | 10 +- lib/src/phy/utils/primes.c | 12 +- lib/src/phy/utils/random.cpp | 26 +- lib/src/phy/utils/ringbuffer.c | 118 +- lib/src/phy/utils/test/CMakeLists.txt | 10 +- lib/src/phy/utils/test/dft_test.c | 50 +- lib/src/phy/utils/test/mat_test.c | 114 +- lib/src/phy/utils/test/ring_buffer_test.c | 62 +- lib/src/phy/utils/test/vector_test.c | 479 ++++--- lib/src/phy/utils/vector.c | 362 ++--- lib/src/phy/utils/vector_simd.c | 1269 ++++++++--------- lib/src/radio/CMakeLists.txt | 8 +- lib/src/radio/channel_mapping.cc | 10 +- lib/src/radio/radio.cc | 240 ++-- lib/src/radio/test/CMakeLists.txt | 4 +- lib/src/radio/test/benchmark_radio.cc | 128 +- lib/src/srslog/CMakeLists.txt | 2 +- lib/src/srslog/backend_worker.cpp | 4 +- lib/src/srslog/backend_worker.h | 8 +- lib/src/srslog/bundled/fmt/CMakeLists.txt | 4 +- lib/src/srslog/event_trace.cpp | 6 +- lib/src/srslog/formatters/CMakeLists.txt | 2 +- lib/src/srslog/formatters/json_formatter.cpp | 4 +- lib/src/srslog/formatters/json_formatter.h | 4 +- lib/src/srslog/formatters/text_formatter.cpp | 6 +- lib/src/srslog/formatters/text_formatter.h | 4 +- lib/src/srslog/log_backend_impl.h | 4 +- lib/src/srslog/object_repository.h | 4 +- lib/src/srslog/sinks/buffered_file_sink.h | 4 +- lib/src/srslog/sinks/file_sink.h | 4 +- lib/src/srslog/sinks/file_utils.h | 8 +- lib/src/srslog/sinks/stream_sink.h | 4 +- lib/src/srslog/srslog.cpp | 4 +- lib/src/srslog/srslog_c.cpp | 6 +- lib/src/srslog/srslog_instance.h | 4 +- lib/src/system/sys_metrics_processor.cc | 6 +- lib/src/upper/CMakeLists.txt | 8 +- lib/src/upper/gtpu.cc | 16 +- lib/src/upper/pdcp.cc | 34 +- lib/src/upper/pdcp_entity_base.cc | 22 +- lib/src/upper/pdcp_entity_lte.cc | 54 +- lib/src/upper/pdcp_entity_nr.cc | 20 +- lib/src/upper/rlc.cc | 38 +- lib/src/upper/rlc_am_base.cc | 8 +- lib/src/upper/rlc_am_lte.cc | 120 +- lib/src/upper/rlc_am_nr.cc | 14 +- lib/src/upper/rlc_tm.cc | 16 +- lib/src/upper/rlc_um_base.cc | 20 +- lib/src/upper/rlc_um_lte.cc | 28 +- lib/src/upper/rlc_um_nr.cc | 20 +- lib/test/CMakeLists.txt | 2 +- lib/test/adt/CMakeLists.txt | 20 +- lib/test/adt/bounded_bitset_test.cc | 52 +- lib/test/adt/bounded_vector_test.cc | 28 +- lib/test/adt/circular_buffer_test.cc | 26 +- lib/test/adt/expected_test.cc | 34 +- lib/test/adt/interval_test.cc | 44 +- lib/test/adt/mem_pool_test.cc | 14 +- lib/test/adt/observer_test.cc | 58 +- lib/test/adt/scope_exit_test.cc | 26 +- lib/test/adt/span_test.cc | 46 +- lib/test/asn1/CMakeLists.txt | 56 +- lib/test/asn1/asn1_utils_test.cc | 20 +- lib/test/asn1/nas_decoder.cc | 8 +- lib/test/asn1/ngap_test.cc | 6 +- lib/test/asn1/rrc_asn1_decoder.cc | 6 +- lib/test/asn1/rrc_nr_utils_test.cc | 20 +- lib/test/asn1/rrc_test.cc | 8 +- lib/test/asn1/s1ap_test.cc | 40 +- ...n1_nas_test.cc => srsran_asn1_nas_test.cc} | 18 +- ...est.cc => srsran_asn1_rrc_dl_ccch_test.cc} | 6 +- ...est.cc => srsran_asn1_rrc_dl_dcch_test.cc} | 6 +- ...h_test.cc => srsran_asn1_rrc_mcch_test.cc} | 14 +- ...s_test.cc => srsran_asn1_rrc_meas_test.cc} | 12 +- ..._nr_test.cc => srsran_asn1_rrc_nr_test.cc} | 26 +- ...est.cc => srsran_asn1_rrc_ul_dcch_test.cc} | 10 +- lib/test/common/CMakeLists.txt | 40 +- lib/test/common/bcd_helpers_test.cc | 10 +- lib/test/common/byte_buffer_queue_test.cc | 10 +- lib/test/common/choice_type_test.cc | 70 +- lib/test/common/fsm_test.cc | 84 +- lib/test/common/mac_pcap_net_test.cc | 40 +- lib/test/common/multiqueue_test.cc | 22 +- lib/test/common/network_utils_test.cc | 14 +- lib/test/common/pnf_bridge.cc | 10 +- lib/test/common/pnf_dummy.cc | 8 +- lib/test/common/stack_procedure_test.cc | 46 +- lib/test/common/task_scheduler_test.cc | 22 +- lib/test/common/test_eea1.cc | 42 +- lib/test/common/test_eea2.cc | 40 +- lib/test/common/test_eea3.cc | 28 +- lib/test/common/test_eia1.cc | 28 +- lib/test/common/test_eia3.cc | 32 +- lib/test/common/test_f12345.cc | 20 +- lib/test/common/timeout_test.cc | 8 +- lib/test/common/timer_test.cc | 36 +- lib/test/common/tti_point_test.cc | 12 +- lib/test/mac/CMakeLists.txt | 8 +- lib/test/mac/mac_pcap_test.cc | 36 +- lib/test/mac/mac_pdu_nr_test.cc | 118 +- lib/test/mac/pdu_test.cc | 196 +-- lib/test/phy/CMakeLists.txt | 8 +- lib/test/phy/phy_dl_nr_test.c | 210 +-- lib/test/phy/phy_dl_test.c | 256 ++-- lib/test/phy/pucch_ca_test.c | 98 +- lib/test/srslog/CMakeLists.txt | 2 +- lib/test/srslog/any_test.cpp | 4 +- lib/test/srslog/context_test.cpp | 4 +- lib/test/srslog/event_trace_test.cpp | 6 +- lib/test/srslog/file_sink_test.cpp | 2 +- lib/test/srslog/file_test_utils.h | 2 +- lib/test/srslog/file_utils_test.cpp | 2 +- lib/test/srslog/json_formatter_test.cpp | 4 +- lib/test/srslog/log_backend_test.cpp | 2 +- lib/test/srslog/log_channel_test.cpp | 4 +- lib/test/srslog/logger_test.cpp | 4 +- lib/test/srslog/srslog_test.cpp | 4 +- lib/test/srslog/test_dummies.h | 6 +- lib/test/srslog/testing_helpers.h | 2 +- lib/test/srslog/text_formatter_test.cpp | 4 +- lib/test/upper/CMakeLists.txt | 34 +- lib/test/upper/pdcp_base_test.h | 54 +- lib/test/upper/pdcp_lte_test.h | 62 +- lib/test/upper/pdcp_lte_test_discard_sdu.cc | 58 +- lib/test/upper/pdcp_lte_test_rx.cc | 72 +- lib/test/upper/pdcp_lte_test_status_report.cc | 126 +- lib/test/upper/pdcp_nr_test.h | 54 +- lib/test/upper/pdcp_nr_test_discard_sdu.cc | 30 +- lib/test/upper/pdcp_nr_test_rx.cc | 68 +- lib/test/upper/pdcp_nr_test_tx.cc | 60 +- lib/test/upper/rlc_am_control_test.cc | 32 +- lib/test/upper/rlc_am_data_test.cc | 42 +- lib/test/upper/rlc_am_nr_pdu_test.cc | 100 +- lib/test/upper/rlc_am_test.cc | 214 +-- lib/test/upper/rlc_common_test.cc | 18 +- lib/test/upper/rlc_stress_test.cc | 58 +- lib/test/upper/rlc_test_common.h | 28 +- lib/test/upper/rlc_um_data_test.cc | 16 +- lib/test/upper/rlc_um_nr_pdu_test.cc | 86 +- lib/test/upper/rlc_um_nr_test.cc | 92 +- lib/test/upper/rlc_um_test.cc | 44 +- run-clang-format-diff.sh | 2 +- srsenb/CMakeLists.txt | 2 +- srsenb/hdr/cfg_parser.h | 2 +- srsenb/hdr/enb.h | 32 +- srsenb/hdr/metrics_csv.h | 8 +- srsenb/hdr/metrics_json.h | 8 +- srsenb/hdr/metrics_stdout.h | 6 +- srsenb/hdr/parser.h | 4 +- srsenb/hdr/phy/enb_phy_base.h | 2 +- srsenb/hdr/phy/lte/cc_worker.h | 32 +- srsenb/hdr/phy/lte/sf_worker.h | 14 +- srsenb/hdr/phy/lte/worker_pool.h | 6 +- srsenb/hdr/phy/nr/cc_worker.h | 26 +- srsenb/hdr/phy/nr/sf_worker.h | 12 +- srsenb/hdr/phy/nr/worker_pool.h | 6 +- srsenb/hdr/phy/phy.h | 28 +- srsenb/hdr/phy/phy_common.h | 58 +- srsenb/hdr/phy/phy_interfaces.h | 22 +- srsenb/hdr/phy/phy_metrics.h | 2 +- srsenb/hdr/phy/phy_ue_db.h | 58 +- srsenb/hdr/phy/prach_worker.h | 42 +- srsenb/hdr/phy/txrx.h | 16 +- srsenb/hdr/phy/vnf_phy_nr.h | 12 +- srsenb/hdr/stack/enb_stack_base.h | 14 +- srsenb/hdr/stack/enb_stack_lte.h | 34 +- srsenb/hdr/stack/gnb_stack_nr.h | 20 +- srsenb/hdr/stack/mac/mac.h | 60 +- srsenb/hdr/stack/mac/mac_metrics.h | 2 +- srsenb/hdr/stack/mac/mac_nr.h | 30 +- srsenb/hdr/stack/mac/sched.h | 14 +- srsenb/hdr/stack/mac/sched_carrier.h | 16 +- srsenb/hdr/stack/mac/sched_common.h | 54 +- srsenb/hdr/stack/mac/sched_grid.h | 42 +- srsenb/hdr/stack/mac/sched_helpers.h | 28 +- srsenb/hdr/stack/mac/sched_phy_ch/sched_dci.h | 18 +- .../hdr/stack/mac/sched_phy_ch/sched_result.h | 8 +- .../stack/mac/sched_phy_ch/sf_cch_allocator.h | 18 +- srsenb/hdr/stack/mac/sched_ue.h | 16 +- .../hdr/stack/mac/sched_ue_ctrl/sched_harq.h | 44 +- .../hdr/stack/mac/sched_ue_ctrl/sched_lch.h | 16 +- .../stack/mac/sched_ue_ctrl/sched_ue_cell.h | 12 +- srsenb/hdr/stack/mac/sched_ue_ctrl/tpc.h | 20 +- srsenb/hdr/stack/mac/schedulers/sched_base.h | 8 +- .../hdr/stack/mac/schedulers/sched_time_pf.h | 10 +- .../hdr/stack/mac/schedulers/sched_time_rr.h | 2 +- srsenb/hdr/stack/mac/ta.h | 8 +- srsenb/hdr/stack/mac/ue.h | 78 +- srsenb/hdr/stack/rrc/mac_controller.h | 20 +- srsenb/hdr/stack/rrc/rrc.h | 44 +- srsenb/hdr/stack/rrc/rrc_bearer_cfg.h | 22 +- srsenb/hdr/stack/rrc/rrc_cell_cfg.h | 16 +- srsenb/hdr/stack/rrc/rrc_config.h | 22 +- srsenb/hdr/stack/rrc/rrc_config_common.h | 8 +- srsenb/hdr/stack/rrc/rrc_metrics.h | 2 +- srsenb/hdr/stack/rrc/rrc_mobility.h | 14 +- srsenb/hdr/stack/rrc/rrc_nr.h | 40 +- srsenb/hdr/stack/rrc/rrc_ue.h | 42 +- srsenb/hdr/stack/rrc/ue_meas_cfg.h | 10 +- srsenb/hdr/stack/rrc/ue_rr_cfg.h | 8 +- srsenb/hdr/stack/upper/common_enb.h | 2 +- srsenb/hdr/stack/upper/gtpu.h | 38 +- srsenb/hdr/stack/upper/pdcp.h | 58 +- srsenb/hdr/stack/upper/pdcp_nr.h | 46 +- srsenb/hdr/stack/upper/rlc.h | 36 +- srsenb/hdr/stack/upper/rlc_nr.h | 30 +- srsenb/hdr/stack/upper/s1ap.h | 114 +- srsenb/hdr/stack/upper/s1ap_metrics.h | 2 +- srsenb/hdr/stack/upper/sdap.h | 14 +- srsenb/src/CMakeLists.txt | 8 +- srsenb/src/enb.cc | 78 +- srsenb/src/enb_cfg_parser.cc | 164 +-- srsenb/src/enb_cfg_parser.h | 8 +- srsenb/src/main.cc | 52 +- srsenb/src/metrics_csv.cc | 10 +- srsenb/src/metrics_json.cc | 6 +- srsenb/src/metrics_stdout.cc | 22 +- srsenb/src/parser.cc | 2 +- srsenb/src/phy/CMakeLists.txt | 2 +- srsenb/src/phy/lte/cc_worker.cc | 208 +-- srsenb/src/phy/lte/sf_worker.cc | 74 +- srsenb/src/phy/lte/worker_pool.cc | 2 +- srsenb/src/phy/nr/cc_worker.cc | 52 +- srsenb/src/phy/nr/sf_worker.cc | 28 +- srsenb/src/phy/nr/worker_pool.cc | 4 +- srsenb/src/phy/phy.cc | 32 +- srsenb/src/phy/phy_common.cc | 42 +- srsenb/src/phy/phy_ue_db.cc | 196 +-- srsenb/src/phy/prach_worker.cc | 42 +- srsenb/src/phy/txrx.cc | 30 +- srsenb/src/phy/vnf_phy_nr.cc | 8 +- srsenb/src/stack/CMakeLists.txt | 2 +- srsenb/src/stack/enb_stack_lte.cc | 40 +- srsenb/src/stack/gnb_stack_nr.cc | 16 +- srsenb/src/stack/mac/CMakeLists.txt | 2 +- srsenb/src/stack/mac/mac.cc | 218 +-- srsenb/src/stack/mac/mac_nr.cc | 40 +- srsenb/src/stack/mac/sched.cc | 40 +- srsenb/src/stack/mac/sched_carrier.cc | 30 +- srsenb/src/stack/mac/sched_grid.cc | 58 +- srsenb/src/stack/mac/sched_helpers.cc | 130 +- .../src/stack/mac/sched_phy_ch/sched_dci.cc | 78 +- .../mac/sched_phy_ch/sf_cch_allocator.cc | 12 +- srsenb/src/stack/mac/sched_ue.cc | 130 +- .../src/stack/mac/sched_ue_ctrl/sched_harq.cc | 22 +- .../src/stack/mac/sched_ue_ctrl/sched_lch.cc | 12 +- .../stack/mac/sched_ue_ctrl/sched_ue_cell.cc | 20 +- .../src/stack/mac/schedulers/CMakeLists.txt | 2 +- srsenb/src/stack/mac/schedulers/sched_base.cc | 12 +- .../src/stack/mac/schedulers/sched_time_pf.cc | 8 +- .../src/stack/mac/schedulers/sched_time_rr.cc | 2 +- srsenb/src/stack/mac/ue.cc | 108 +- srsenb/src/stack/rrc/CMakeLists.txt | 2 +- srsenb/src/stack/rrc/mac_controller.cc | 24 +- srsenb/src/stack/rrc/rrc.cc | 104 +- srsenb/src/stack/rrc/rrc_bearer_cfg.cc | 66 +- srsenb/src/stack/rrc/rrc_cell_cfg.cc | 14 +- srsenb/src/stack/rrc/rrc_mobility.cc | 106 +- srsenb/src/stack/rrc/rrc_nr.cc | 66 +- srsenb/src/stack/rrc/rrc_ue.cc | 90 +- srsenb/src/stack/rrc/ue_meas_cfg.cc | 38 +- srsenb/src/stack/rrc/ue_rr_cfg.cc | 36 +- srsenb/src/stack/upper/CMakeLists.txt | 2 +- srsenb/src/stack/upper/gtpu.cc | 82 +- srsenb/src/stack/upper/pdcp.cc | 50 +- srsenb/src/stack/upper/pdcp_nr.cc | 38 +- srsenb/src/stack/upper/rlc.cc | 36 +- srsenb/src/stack/upper/rlc_nr.cc | 38 +- srsenb/src/stack/upper/s1ap.cc | 162 +-- srsenb/src/stack/upper/sdap.cc | 6 +- srsenb/test/CMakeLists.txt | 4 +- srsenb/test/common/dummy_classes.h | 58 +- srsenb/test/common/dummy_nr_classes.h | 24 +- srsenb/test/enb_metrics_test.cc | 10 +- srsenb/test/mac/CMakeLists.txt | 28 +- srsenb/test/mac/sched_benchmark.cc | 70 +- srsenb/test/mac/sched_ca_test.cc | 38 +- srsenb/test/mac/sched_common_test_suite.cc | 114 +- srsenb/test/mac/sched_common_test_suite.h | 30 +- srsenb/test/mac/sched_dci_test.cc | 92 +- srsenb/test/mac/sched_grid_test.cc | 22 +- srsenb/test/mac/sched_lc_ch_test.cc | 32 +- srsenb/test/mac/sched_sim_ue.cc | 50 +- srsenb/test/mac/sched_sim_ue.h | 34 +- srsenb/test/mac/sched_test_common.cc | 36 +- srsenb/test/mac/sched_test_common.h | 14 +- srsenb/test/mac/sched_test_rand.cc | 60 +- srsenb/test/mac/sched_test_utils.h | 28 +- srsenb/test/mac/sched_tpc_test.cc | 8 +- srsenb/test/mac/sched_ue_ded_test_suite.cc | 60 +- srsenb/test/mac/sched_ue_ded_test_suite.h | 8 +- srsenb/test/phy/CMakeLists.txt | 4 +- srsenb/test/phy/enb_phy_test.cc | 380 ++--- srsenb/test/rrc/CMakeLists.txt | 4 +- srsenb/test/rrc/rrc_nr_test.cc | 20 +- srsenb/test/upper/CMakeLists.txt | 10 +- srsenb/test/upper/erab_setup_test.cc | 34 +- srsenb/test/upper/gtpu_test.cc | 70 +- srsenb/test/upper/plmn_test.cc | 52 +- srsenb/test/upper/rrc_meascfg_test.cc | 32 +- srsenb/test/upper/rrc_mobility_test.cc | 90 +- srsenb/test/upper/test_helpers.cc | 20 +- srsenb/test/upper/test_helpers.h | 46 +- srsepc/CMakeLists.txt | 2 +- srsepc/hdr/hss/hss.h | 10 +- srsepc/hdr/mbms-gw/mbms-gw.h | 16 +- srsepc/hdr/mme/mme.h | 10 +- srsepc/hdr/mme/mme_gtpc.h | 26 +- srsepc/hdr/mme/nas.h | 88 +- srsepc/hdr/mme/s1ap.h | 26 +- srsepc/hdr/mme/s1ap_common.h | 14 +- srsepc/hdr/mme/s1ap_ctx_mngmt_proc.h | 8 +- srsepc/hdr/mme/s1ap_erab_mngmt_proc.h | 10 +- srsepc/hdr/mme/s1ap_mngmt_proc.h | 8 +- srsepc/hdr/mme/s1ap_nas_transport.h | 10 +- srsepc/hdr/mme/s1ap_paging.h | 8 +- srsepc/hdr/spgw/gtpc.h | 40 +- srsepc/hdr/spgw/gtpu.h | 26 +- srsepc/hdr/spgw/spgw.h | 24 +- srsepc/src/CMakeLists.txt | 10 +- srsepc/src/hss/CMakeLists.txt | 2 +- srsepc/src/hss/hss.cc | 36 +- srsepc/src/main.cc | 64 +- srsepc/src/mbms-gw/CMakeLists.txt | 2 +- srsepc/src/mbms-gw/main.cc | 10 +- srsepc/src/mbms-gw/mbms-gw.cc | 64 +- srsepc/src/mme/CMakeLists.txt | 2 +- srsepc/src/mme/mme.cc | 12 +- srsepc/src/mme/mme_gtpc.cc | 126 +- srsepc/src/mme/nas.cc | 398 +++--- srsepc/src/mme/s1ap.cc | 58 +- srsepc/src/mme/s1ap_ctx_mngmt_proc.cc | 38 +- srsepc/src/mme/s1ap_erab_mngmt_proc.cc | 12 +- srsepc/src/mme/s1ap_mngmt_proc.cc | 16 +- srsepc/src/mme/s1ap_nas_transport.cc | 54 +- srsepc/src/mme/s1ap_paging.cc | 6 +- srsepc/src/spgw/CMakeLists.txt | 2 +- srsepc/src/spgw/gtpc.cc | 146 +- srsepc/src/spgw/gtpu.cc | 82 +- srsepc/src/spgw/spgw.cc | 30 +- srsepc/srsepc_if_masq.sh | 2 +- srsue/CMakeLists.txt | 2 +- srsue/hdr/metrics_csv.h | 6 +- srsue/hdr/metrics_stdout.h | 6 +- srsue/hdr/phy/lte/cc_worker.h | 66 +- srsue/hdr/phy/lte/sf_worker.h | 24 +- srsue/hdr/phy/lte/worker_pool.h | 6 +- srsue/hdr/phy/nr/cc_worker.h | 24 +- srsue/hdr/phy/nr/sf_worker.h | 8 +- srsue/hdr/phy/nr/state.h | 86 +- srsue/hdr/phy/nr/worker_pool.h | 10 +- srsue/hdr/phy/phy.h | 60 +- srsue/hdr/phy/phy_common.h | 176 +-- srsue/hdr/phy/phy_metrics.h | 14 +- srsue/hdr/phy/prach.h | 20 +- srsue/hdr/phy/scell/intra_measure.h | 18 +- srsue/hdr/phy/scell/scell_recv.h | 10 +- srsue/hdr/phy/scell/scell_state.h | 24 +- srsue/hdr/phy/scell/scell_sync.h | 60 +- srsue/hdr/phy/search.h | 24 +- srsue/hdr/phy/sfn_sync.h | 30 +- srsue/hdr/phy/sync.h | 52 +- srsue/hdr/phy/sync_state.h | 2 +- srsue/hdr/phy/ta_control.h | 16 +- srsue/hdr/phy/ue_lte_phy_base.h | 8 +- srsue/hdr/phy/ue_nr_phy_base.h | 8 +- srsue/hdr/phy/ue_phy_base.h | 4 +- srsue/hdr/phy/vnf_phy_nr.h | 20 +- srsue/hdr/stack/mac/demux.h | 40 +- srsue/hdr/stack/mac/dl_harq.h | 18 +- srsue/hdr/stack/mac/dl_sps.h | 4 +- srsue/hdr/stack/mac/mac.h | 42 +- srsue/hdr/stack/mac/mac_metrics.h | 2 +- srsue/hdr/stack/mac/mux.h | 28 +- srsue/hdr/stack/mac/proc.h | 2 +- srsue/hdr/stack/mac/proc_bsr.h | 22 +- srsue/hdr/stack/mac/proc_phr.h | 22 +- srsue/hdr/stack/mac/proc_ra.h | 36 +- srsue/hdr/stack/mac/proc_sr.h | 10 +- srsue/hdr/stack/mac/ul_harq.h | 22 +- srsue/hdr/stack/mac/ul_sps.h | 4 +- srsue/hdr/stack/mac_nr/mac_nr.h | 56 +- srsue/hdr/stack/mac_nr/mac_nr_interfaces.h | 2 +- srsue/hdr/stack/mac_nr/mux_nr.h | 12 +- srsue/hdr/stack/mac_nr/proc_ra_nr.h | 32 +- srsue/hdr/stack/rrc/phy_controller.h | 50 +- srsue/hdr/stack/rrc/rrc.h | 136 +- srsue/hdr/stack/rrc/rrc_cell.h | 48 +- srsue/hdr/stack/rrc/rrc_common.h | 2 +- srsue/hdr/stack/rrc/rrc_meas.h | 18 +- srsue/hdr/stack/rrc/rrc_metrics.h | 4 +- srsue/hdr/stack/rrc/rrc_nr.h | 70 +- srsue/hdr/stack/rrc/rrc_procedures.h | 162 +-- srsue/hdr/stack/ue_stack_base.h | 2 +- srsue/hdr/stack/ue_stack_lte.h | 52 +- srsue/hdr/stack/ue_stack_nr.h | 34 +- srsue/hdr/stack/upper/gw.h | 22 +- srsue/hdr/stack/upper/gw_metrics.h | 2 +- srsue/hdr/stack/upper/nas.h | 114 +- srsue/hdr/stack/upper/nas_config.h | 2 +- srsue/hdr/stack/upper/nas_emm_state.h | 4 +- srsue/hdr/stack/upper/nas_idle_procedures.h | 12 +- srsue/hdr/stack/upper/nas_metrics.h | 2 +- srsue/hdr/stack/upper/pcsc_usim.h | 6 +- srsue/hdr/stack/upper/tft_packet_filter.h | 22 +- srsue/hdr/stack/upper/usim.h | 6 +- srsue/hdr/stack/upper/usim_base.h | 36 +- srsue/hdr/ue.h | 16 +- srsue/hdr/ue_metrics_interface.h | 20 +- srsue/src/CMakeLists.txt | 8 +- srsue/src/main.cc | 66 +- srsue/src/metrics_csv.cc | 4 +- srsue/src/metrics_stdout.cc | 4 +- srsue/src/phy/CMakeLists.txt | 2 +- srsue/src/phy/lte/cc_worker.cc | 210 +-- srsue/src/phy/lte/sf_worker.cc | 52 +- srsue/src/phy/lte/worker_pool.cc | 4 +- srsue/src/phy/nr/cc_worker.cc | 118 +- srsue/src/phy/nr/sf_worker.cc | 18 +- srsue/src/phy/nr/worker_pool.cc | 30 +- srsue/src/phy/phy.cc | 76 +- srsue/src/phy/phy_common.cc | 204 +-- srsue/src/phy/prach.cc | 58 +- srsue/src/phy/scell/intra_measure.cc | 44 +- srsue/src/phy/scell/scell_recv.cc | 71 +- srsue/src/phy/search.cc | 72 +- srsue/src/phy/sfn_sync.cc | 48 +- srsue/src/phy/sync.cc | 176 ++- srsue/src/phy/vnf_phy_nr.cc | 14 +- srsue/src/set_net_admin_caps.cc | 2 +- srsue/src/stack/CMakeLists.txt | 2 +- srsue/src/stack/mac/CMakeLists.txt | 2 +- srsue/src/stack/mac/demux.cc | 60 +- srsue/src/stack/mac/dl_harq.cc | 46 +- srsue/src/stack/mac/mac.cc | 66 +- srsue/src/stack/mac/mux.cc | 26 +- srsue/src/stack/mac/proc_bsr.cc | 16 +- srsue/src/stack/mac/proc_phr.cc | 8 +- srsue/src/stack/mac/proc_ra.cc | 38 +- srsue/src/stack/mac/proc_sr.cc | 12 +- srsue/src/stack/mac/ul_harq.cc | 32 +- srsue/src/stack/mac_nr/CMakeLists.txt | 4 +- srsue/src/stack/mac_nr/mac_nr.cc | 81 +- srsue/src/stack/mac_nr/mux_nr.cc | 6 +- srsue/src/stack/mac_nr/proc_ra_nr.cc | 56 +- srsue/src/stack/rrc/CMakeLists.txt | 2 +- srsue/src/stack/rrc/phy_controller.cc | 26 +- srsue/src/stack/rrc/rrc.cc | 148 +- srsue/src/stack/rrc/rrc_cell.cc | 24 +- srsue/src/stack/rrc/rrc_meas.cc | 16 +- srsue/src/stack/rrc/rrc_nr.cc | 62 +- srsue/src/stack/rrc/rrc_procedures.cc | 120 +- srsue/src/stack/ue_stack_lte.cc | 44 +- srsue/src/stack/ue_stack_nr.cc | 16 +- srsue/src/stack/upper/CMakeLists.txt | 2 +- srsue/src/stack/upper/gw.cc | 76 +- srsue/src/stack/upper/nas.cc | 124 +- srsue/src/stack/upper/nas_emm_state.cc | 2 +- srsue/src/stack/upper/nas_idle_procedures.cc | 14 +- srsue/src/stack/upper/pcsc_usim.cc | 22 +- srsue/src/stack/upper/tft_packet_filter.cc | 26 +- srsue/src/stack/upper/usim.cc | 20 +- srsue/src/stack/upper/usim_base.cc | 28 +- srsue/src/ue.cc | 136 +- srsue/test/CMakeLists.txt | 6 +- srsue/test/mac_nr/CMakeLists.txt | 2 +- srsue/test/mac_nr/proc_ra_nr_test.cc | 22 +- srsue/test/mac_test.cc | 120 +- srsue/test/metrics_test.cc | 8 +- srsue/test/phy/CMakeLists.txt | 14 +- srsue/test/phy/scell_search_test.cc | 198 +-- srsue/test/phy/ue_phy_test.cc | 102 +- srsue/test/ttcn3/CMakeLists.txt | 2 +- srsue/test/ttcn3/README.md | 2 +- srsue/test/ttcn3/hdr/dut_utils.h | 2 +- srsue/test/ttcn3/hdr/lte_ttcn3_phy.h | 32 +- srsue/test/ttcn3/hdr/swappable_sink.h | 4 +- srsue/test/ttcn3/hdr/ttcn3_common.h | 2 +- srsue/test/ttcn3/hdr/ttcn3_drb_interface.h | 20 +- srsue/test/ttcn3/hdr/ttcn3_helpers.h | 12 +- srsue/test/ttcn3/hdr/ttcn3_interfaces.h | 28 +- .../test/ttcn3/hdr/ttcn3_ip_ctrl_interface.h | 8 +- .../test/ttcn3/hdr/ttcn3_ip_sock_interface.h | 6 +- srsue/test/ttcn3/hdr/ttcn3_port_handler.h | 42 +- srsue/test/ttcn3/hdr/ttcn3_srb_interface.h | 20 +- srsue/test/ttcn3/hdr/ttcn3_sys_interface.h | 42 +- srsue/test/ttcn3/hdr/ttcn3_syssim.h | 44 +- srsue/test/ttcn3/hdr/ttcn3_ue.h | 14 +- srsue/test/ttcn3/hdr/ttcn3_ut_interface.h | 8 +- srsue/test/ttcn3/src/CMakeLists.txt | 16 +- srsue/test/ttcn3/src/lte_ttcn3_phy.cc | 16 +- srsue/test/ttcn3/src/ttcn3_dut.cc | 18 +- srsue/test/ttcn3/src/ttcn3_syssim.cc | 150 +- srsue/test/ttcn3/src/ttcn3_ue.cc | 42 +- srsue/test/ttcn3/test/CMakeLists.txt | 6 +- srsue/test/ttcn3/test/rapidjson_test.cc | 6 +- .../test/ttcn3/test/ttcn3_if_handler_test.cc | 6 +- srsue/test/upper/CMakeLists.txt | 22 +- srsue/test/upper/gw_test.cc | 22 +- srsue/test/upper/nas_test.cc | 74 +- srsue/test/upper/pcsc_usim_test.cc | 10 +- srsue/test/upper/rrc_cell_test.cc | 20 +- srsue/test/upper/rrc_meas_test.cc | 80 +- srsue/test/upper/rrc_phy_ctrl_test.cc | 16 +- srsue/test/upper/rrc_reconfig_test.cc | 10 +- srsue/test/upper/tft_test.cc | 30 +- srsue/test/upper/ue_rrc_nr_test.cc | 16 +- srsue/test/upper/usim_test.cc | 4 +- test/CMakeLists.txt | 2 +- test/README.md | 4 +- test/run_lte.sh | 8 +- 1433 files changed, 44117 insertions(+), 44152 deletions(-) delete mode 100644 cmake/modules/SRSLTEVersion.cmake rename cmake/modules/{SRSLTEPackage.cmake => SRSRANPackage.cmake} (87%) create mode 100644 cmake/modules/SRSRANVersion.cmake rename cmake/modules/{SRSLTE_install_configs.sh.in => SRSRAN_install_configs.sh.in} (83%) rename cmake/modules/{SRSLTEbuildinfo.cmake.in => SRSRANbuildinfo.cmake.in} (78%) delete mode 100644 lib/include/srslte/config.h delete mode 100644 lib/include/srslte/phy/ch_estimation/chest_dl.h delete mode 100644 lib/include/srslte/phy/ch_estimation/chest_dl_nbiot.h delete mode 100644 lib/include/srslte/phy/ch_estimation/chest_sl.h delete mode 100644 lib/include/srslte/phy/ch_estimation/chest_ul.h delete mode 100644 lib/include/srslte/phy/ch_estimation/csi_rs.h delete mode 100644 lib/include/srslte/phy/ch_estimation/refsignal_dl.h delete mode 100644 lib/include/srslte/phy/ch_estimation/refsignal_dl_nbiot.h delete mode 100644 lib/include/srslte/phy/ch_estimation/refsignal_ul.h delete mode 100644 lib/include/srslte/phy/common/phy_common.h delete mode 100644 lib/include/srslte/phy/common/phy_common_sl.h delete mode 100644 lib/include/srslte/phy/enb/enb_dl.h delete mode 100644 lib/include/srslte/phy/enb/enb_dl_nr.h delete mode 100644 lib/include/srslte/phy/enb/enb_ul.h delete mode 100644 lib/include/srslte/phy/fec/turbo/turbodecoder.h delete mode 100644 lib/include/srslte/phy/io/format.h delete mode 100644 lib/include/srslte/phy/phch/dci.h delete mode 100644 lib/include/srslte/phy/phch/dci_nbiot.h delete mode 100644 lib/include/srslte/phy/phch/npbch.h delete mode 100644 lib/include/srslte/phy/phch/npdcch.h delete mode 100644 lib/include/srslte/phy/phch/npdsch.h delete mode 100644 lib/include/srslte/phy/phch/pbch.h delete mode 100644 lib/include/srslte/phy/phch/pcfich.h delete mode 100644 lib/include/srslte/phy/phch/pdcch.h delete mode 100644 lib/include/srslte/phy/phch/pdsch.h delete mode 100644 lib/include/srslte/phy/phch/pdsch_nr.h delete mode 100644 lib/include/srslte/phy/phch/phich.h delete mode 100644 lib/include/srslte/phy/phch/pmch.h delete mode 100644 lib/include/srslte/phy/phch/pscch.h delete mode 100644 lib/include/srslte/phy/phch/pucch.h delete mode 100644 lib/include/srslte/phy/phch/pusch.h delete mode 100644 lib/include/srslte/phy/phch/ra.h delete mode 100644 lib/include/srslte/phy/phch/ra_dl.h delete mode 100644 lib/include/srslte/phy/phch/ra_ul.h delete mode 100644 lib/include/srslte/phy/phch/sch.h delete mode 100644 lib/include/srslte/phy/phch/uci_cfg.h delete mode 100644 lib/include/srslte/phy/scrambling/scrambling.h delete mode 100644 lib/include/srslte/phy/sync/cfo.h delete mode 100644 lib/include/srslte/phy/sync/cp.h delete mode 100644 lib/include/srslte/phy/sync/pss.h delete mode 100644 lib/include/srslte/phy/sync/sss.h delete mode 100644 lib/include/srslte/phy/sync/ssss.h delete mode 100644 lib/include/srslte/phy/ue/ue_cell_search.h delete mode 100644 lib/include/srslte/phy/ue/ue_cell_search_nbiot.h delete mode 100644 lib/include/srslte/phy/ue/ue_dl.h delete mode 100644 lib/include/srslte/phy/ue/ue_dl_nbiot.h delete mode 100644 lib/include/srslte/phy/ue/ue_dl_nr.h delete mode 100644 lib/include/srslte/phy/ue/ue_mib.h delete mode 100644 lib/include/srslte/phy/ue/ue_sync.h delete mode 100644 lib/include/srslte/phy/ue/ue_sync_nbiot.h delete mode 100644 lib/include/srslte/phy/ue/ue_ul.h delete mode 100644 lib/include/srslte/phy/ue/ue_ul_nr.h delete mode 100644 lib/include/srslte/phy/utils/random.h delete mode 100644 lib/include/srslte/phy/utils/vector_simd.h delete mode 100644 lib/include/srslte/srslte.h delete mode 100644 lib/include/srslte/version.h.in rename lib/include/{srslte => srsran}/CMakeLists.txt (76%) rename lib/include/{srslte => srsran}/adt/accumulators.h (95%) rename lib/include/{srslte => srsran}/adt/adt_utils.h (80%) rename lib/include/{srslte => srsran}/adt/bounded_bitset.h (96%) rename lib/include/{srslte => srsran}/adt/bounded_vector.h (97%) rename lib/include/{srslte => srsran}/adt/choice_type.h (96%) rename lib/include/{srslte => srsran}/adt/circular_array.h (84%) rename lib/include/{srslte => srsran}/adt/circular_buffer.h (96%) rename lib/include/{srslte => srsran}/adt/detail/index_sequence.h (88%) rename lib/include/{srslte => srsran}/adt/detail/type_utils.h (97%) rename lib/include/{srslte => srsran}/adt/expected.h (95%) rename lib/include/{srslte => srsran}/adt/interval.h (90%) rename lib/include/{srslte => srsran}/adt/mem_pool.h (97%) rename lib/include/{srslte => srsran}/adt/move_callback.h (97%) rename lib/include/{srslte => srsran}/adt/observer.h (97%) rename lib/include/{srslte => srsran}/adt/scope_exit.h (88%) rename lib/include/{srslte => srsran}/adt/span.h (98%) rename lib/include/{srslte => srsran}/asn1/asn1_utils.h (99%) rename lib/include/{srslte => srsran}/asn1/gtpc.h (93%) rename lib/include/{srslte => srsran}/asn1/gtpc_ies.h (98%) rename lib/include/{srslte => srsran}/asn1/gtpc_msg.h (98%) rename lib/include/{srslte => srsran}/asn1/liblte_common.h (97%) rename lib/include/{srslte => srsran}/asn1/liblte_mme.h (99%) rename lib/include/{srslte => srsran}/asn1/ngap.h (99%) rename lib/include/{srslte => srsran}/asn1/rrc.h (99%) rename lib/include/{srslte => srsran}/asn1/rrc/bcch_msg.h (99%) rename lib/include/{srslte => srsran}/asn1/rrc/common.h (99%) rename lib/include/{srslte => srsran}/asn1/rrc/common_ext.h (99%) rename lib/include/{srslte => srsran}/asn1/rrc/dl_ccch_msg.h (99%) rename lib/include/{srslte => srsran}/asn1/rrc/dl_dcch_msg.h (99%) rename lib/include/{srslte => srsran}/asn1/rrc/ho_cmd.h (99%) rename lib/include/{srslte => srsran}/asn1/rrc/meascfg.h (99%) rename lib/include/{srslte => srsran}/asn1/rrc/paging.h (99%) rename lib/include/{srslte => srsran}/asn1/rrc/phy_ded.h (99%) rename lib/include/{srslte => srsran}/asn1/rrc/rr_common.h (99%) rename lib/include/{srslte => srsran}/asn1/rrc/rr_ded.h (99%) rename lib/include/{srslte => srsran}/asn1/rrc/rrc_asn1.h (99%) rename lib/include/{srslte => srsran}/asn1/rrc/security.h (99%) rename lib/include/{srslte => srsran}/asn1/rrc/si.h (99%) rename lib/include/{srslte => srsran}/asn1/rrc/uecap.h (99%) rename lib/include/{srslte => srsran}/asn1/rrc/ul_ccch_msg.h (99%) rename lib/include/{srslte => srsran}/asn1/rrc/ul_dcch_msg.h (99%) rename lib/include/{srslte => srsran}/asn1/rrc_nbiot.h (99%) rename lib/include/{srslte => srsran}/asn1/rrc_nr.h (99%) rename lib/include/{srslte => srsran}/asn1/rrc_nr_utils.h (76%) rename lib/include/{srslte => srsran}/asn1/rrc_utils.h (91%) rename lib/include/{srslte => srsran}/asn1/s1ap.h (99%) rename lib/include/{srslte => srsran}/asn1/s1ap_utils.h (90%) rename lib/include/{srslte => srsran}/build_info.h.in (73%) rename lib/include/{srslte => srsran}/common/backtrace.h (72%) rename lib/include/{srslte => srsran}/common/backward.hpp (100%) rename lib/include/{srslte => srsran}/common/band_helper.h (91%) rename lib/include/{srslte => srsran}/common/basic_pnf.h (93%) rename lib/include/{srslte => srsran}/common/basic_vnf.h (78%) rename lib/include/{srslte => srsran}/common/basic_vnf_api.h (96%) rename lib/include/{srslte => srsran}/common/bcd_helpers.h (97%) rename lib/include/{srslte => srsran}/common/block_queue.h (93%) rename lib/include/{srslte => srsran}/common/buffer_pool.h (92%) rename lib/include/{srslte => srsran}/common/byte_buffer.h (81%) rename lib/include/{srslte => srsran}/common/common.h (74%) rename lib/include/{srslte => srsran}/common/common_helper.h (84%) rename lib/include/{srslte => srsran}/common/config_file.h (75%) rename lib/include/{srslte => srsran}/common/crash_handler.h (64%) rename lib/include/{srslte => srsran}/common/enb_events.h (97%) rename lib/include/{srslte => srsran}/common/epoll_helper.h (90%) rename lib/include/{srslte => srsran}/common/fsm.h (96%) rename lib/include/{srslte => srsran}/common/gen_mch_tables.h (94%) rename lib/include/{srslte => srsran}/common/int_helpers.h (87%) rename lib/include/{srslte => srsran}/common/interfaces_common.h (67%) rename lib/include/{srslte => srsran}/common/liblte_security.h (99%) rename lib/include/{srslte => srsran}/common/log_helper.h (70%) rename lib/include/{srslte => srsran}/common/mac_pcap.h (59%) rename lib/include/{srslte => srsran}/common/mac_pcap_base.h (89%) rename lib/include/{srslte => srsran}/common/mac_pcap_net.h (53%) rename lib/include/{srslte => srsran}/common/metrics_hub.h (91%) rename lib/include/{srslte => srsran}/common/multiqueue.h (97%) rename lib/include/{srslte => srsran}/common/nas_pcap.h (76%) rename lib/include/{srslte => srsran}/common/netsource_handler.h (78%) rename lib/include/{srslte => srsran}/common/network_utils.h (93%) rename lib/include/{srslte => srsran}/common/pcap.h (98%) rename lib/include/{srslte => srsran}/common/rlc_pcap.h (86%) rename lib/include/{srslte => srsran}/common/rwlock_guard.h (86%) rename lib/include/{srslte => srsran}/common/s1ap_pcap.h (69%) rename lib/include/{srslte => srsran}/common/s3g.h (96%) rename lib/include/{srslte => srsran}/common/security.h (97%) rename lib/include/{srslte => srsran}/common/signal_handler.h (62%) rename lib/include/{srslte => srsran}/common/singleton.h (87%) rename lib/include/{srslte => srsran}/common/ssl.h (94%) rename lib/include/{srslte => srsran}/common/stack_procedure.h (98%) rename lib/include/{srslte => srsran}/common/standard_streams.h (67%) rename lib/include/{srslte => srsran}/common/string_helpers.h (91%) rename lib/include/{srslte => srsran}/common/task_scheduler.h (75%) rename lib/include/{srslte => srsran}/common/test_common.h (94%) rename lib/include/{srslte => srsran}/common/thread_pool.h (90%) rename lib/include/{srslte => srsran}/common/threads.h (96%) rename lib/include/{srslte => srsran}/common/time_prof.h (94%) rename lib/include/{srslte => srsran}/common/timeout.h (92%) rename lib/include/{srslte => srsran}/common/timers.h (94%) rename lib/include/{srslte => srsran}/common/trace.h (91%) rename lib/include/{srslte => srsran}/common/tti_point.h (83%) rename lib/include/{srslte => srsran}/common/tti_sempahore.h (91%) rename lib/include/{srslte => srsran}/common/tti_sync.h (91%) rename lib/include/{srslte => srsran}/common/tti_sync_cv.h (78%) rename lib/include/{srslte => srsran}/common/zuc.h (87%) create mode 100644 lib/include/srsran/config.h rename lib/include/{srslte => srsran}/interfaces/enb_command_interface.h (75%) rename lib/include/{srslte => srsran}/interfaces/enb_gtpu_interfaces.h (79%) rename lib/include/{srslte => srsran}/interfaces/enb_interfaces.h (68%) rename lib/include/{srslte => srsran}/interfaces/enb_mac_interfaces.h (87%) rename lib/include/{srslte => srsran}/interfaces/enb_metrics_interface.h (62%) rename lib/include/{srslte => srsran}/interfaces/enb_pdcp_interfaces.h (70%) rename lib/include/{srslte => srsran}/interfaces/enb_phy_interfaces.h (83%) rename lib/include/{srslte => srsran}/interfaces/enb_rlc_interfaces.h (84%) rename lib/include/{srslte => srsran}/interfaces/enb_rrc_interface_types.h (87%) rename lib/include/{srslte => srsran}/interfaces/enb_rrc_interfaces.h (85%) rename lib/include/{srslte => srsran}/interfaces/enb_s1ap_interfaces.h (83%) rename lib/include/{srslte => srsran}/interfaces/epc_interfaces.h (87%) rename lib/include/{srslte => srsran}/interfaces/gnb_interfaces.h (77%) rename lib/include/{srslte => srsran}/interfaces/mac_interface_types.h (94%) rename lib/include/{srslte => srsran}/interfaces/nr_common_interface_types.h (80%) rename lib/include/{srslte => srsran}/interfaces/pdcp_interface_types.h (90%) rename lib/include/{srslte => srsran}/interfaces/phy_interface_types.h (71%) rename lib/include/{srslte => srsran}/interfaces/radio_interfaces.h (90%) rename lib/include/{srslte => srsran}/interfaces/rlc_interface_types.h (91%) rename lib/include/{srslte => srsran}/interfaces/rrc_interface_types.h (91%) rename lib/include/{srslte => srsran}/interfaces/rrc_nr_interface_types.h (89%) rename lib/include/{srslte => srsran}/interfaces/sched_interface.h (87%) rename lib/include/{srslte => srsran}/interfaces/ue_gw_interfaces.h (82%) rename lib/include/{srslte => srsran}/interfaces/ue_interfaces.h (82%) rename lib/include/{srslte => srsran}/interfaces/ue_mac_interfaces.h (87%) rename lib/include/{srslte => srsran}/interfaces/ue_nas_interfaces.h (76%) rename lib/include/{srslte => srsran}/interfaces/ue_nr_interfaces.h (83%) rename lib/include/{srslte => srsran}/interfaces/ue_pdcp_interfaces.h (63%) rename lib/include/{srslte => srsran}/interfaces/ue_phy_interfaces.h (86%) rename lib/include/{srslte => srsran}/interfaces/ue_rlc_interfaces.h (81%) rename lib/include/{srslte => srsran}/interfaces/ue_rrc_interfaces.h (78%) rename lib/include/{srslte => srsran}/interfaces/ue_usim_interfaces.h (74%) rename lib/include/{srslte => srsran}/mac/mac_rar_pdu_nr.h (87%) rename lib/include/{srslte => srsran}/mac/mac_sch_pdu_nr.h (90%) rename lib/include/{srslte => srsran}/mac/pdu.h (97%) rename lib/include/{srslte => srsran}/mac/pdu_queue.h (76%) rename lib/include/{srslte => srsran}/phy/agc/agc.h (53%) rename lib/include/{srslte => srsran}/phy/ch_estimation/chest_common.h (50%) create mode 100644 lib/include/srsran/phy/ch_estimation/chest_dl.h create mode 100644 lib/include/srsran/phy/ch_estimation/chest_dl_nbiot.h create mode 100644 lib/include/srsran/phy/ch_estimation/chest_sl.h create mode 100644 lib/include/srsran/phy/ch_estimation/chest_ul.h create mode 100644 lib/include/srsran/phy/ch_estimation/csi_rs.h rename lib/include/{srslte => srsran}/phy/ch_estimation/dmrs_pdcch.h (63%) rename lib/include/{srslte => srsran}/phy/ch_estimation/dmrs_pucch.h (58%) rename lib/include/{srslte => srsran}/phy/ch_estimation/dmrs_sch.h (59%) create mode 100644 lib/include/srsran/phy/ch_estimation/refsignal_dl.h create mode 100644 lib/include/srsran/phy/ch_estimation/refsignal_dl_nbiot.h create mode 100644 lib/include/srsran/phy/ch_estimation/refsignal_ul.h rename lib/include/{srslte => srsran}/phy/ch_estimation/wiener_dl.h (52%) rename lib/include/{srslte => srsran}/phy/channel/ch_awgn.h (68%) rename lib/include/{srslte => srsran}/phy/channel/channel.h (72%) rename lib/include/{srslte => srsran}/phy/channel/delay.h (66%) rename lib/include/{srslte => srsran}/phy/channel/fading.h (58%) rename lib/include/{srslte => srsran}/phy/channel/hst.h (58%) rename lib/include/{srslte => srsran}/phy/channel/rlf.h (57%) create mode 100644 lib/include/srsran/phy/common/phy_common.h rename lib/include/{srslte => srsran}/phy/common/phy_common_nr.h (63%) create mode 100644 lib/include/srsran/phy/common/phy_common_sl.h rename lib/include/{srslte => srsran}/phy/common/sequence.h (65%) rename lib/include/{srslte => srsran}/phy/common/timestamp.h (53%) rename lib/include/{srslte => srsran}/phy/common/zc_sequence.h (68%) rename lib/include/{srslte => srsran}/phy/dft/dft.h (64%) rename lib/include/{srslte => srsran}/phy/dft/dft_precoding.h (51%) rename lib/include/{srslte => srsran}/phy/dft/ofdm.h (61%) create mode 100644 lib/include/srsran/phy/enb/enb_dl.h create mode 100644 lib/include/srsran/phy/enb/enb_dl_nr.h create mode 100644 lib/include/srsran/phy/enb/enb_ul.h rename lib/include/{srslte => srsran}/phy/fec/block/block.h (73%) rename lib/include/{srslte => srsran}/phy/fec/cbsegm.h (71%) rename lib/include/{srslte => srsran}/phy/fec/convolutional/convcoder.h (74%) rename lib/include/{srslte => srsran}/phy/fec/convolutional/rm_conv.h (65%) rename lib/include/{srslte => srsran}/phy/fec/convolutional/viterbi.h (62%) rename lib/include/{srslte => srsran}/phy/fec/crc.h (63%) rename lib/include/{srslte => srsran}/phy/fec/ldpc/base_graph.h (83%) rename lib/include/{srslte => srsran}/phy/fec/ldpc/ldpc_common.h (77%) rename lib/include/{srslte => srsran}/phy/fec/ldpc/ldpc_decoder.h (77%) rename lib/include/{srslte => srsran}/phy/fec/ldpc/ldpc_encoder.h (78%) rename lib/include/{srslte => srsran}/phy/fec/ldpc/ldpc_rm.h (79%) rename lib/include/{srslte => srsran}/phy/fec/polar/polar_chanalloc.h (88%) rename lib/include/{srslte => srsran}/phy/fec/polar/polar_code.h (98%) rename lib/include/{srslte => srsran}/phy/fec/polar/polar_decoder.h (86%) rename lib/include/{srslte => srsran}/phy/fec/polar/polar_encoder.h (75%) rename lib/include/{srslte => srsran}/phy/fec/polar/polar_interleaver.h (72%) rename lib/include/{srslte => srsran}/phy/fec/polar/polar_rm.h (79%) rename lib/include/{srslte => srsran}/phy/fec/polar/test/polar_sets.h (89%) rename lib/include/{srslte => srsran}/phy/fec/polar/test/subchannel_allocation.h (79%) rename lib/include/{srslte => srsran}/phy/fec/softbuffer.h (56%) rename lib/include/{srslte => srsran}/phy/fec/turbo/rm_turbo.h (71%) rename lib/include/{srslte => srsran}/phy/fec/turbo/tc_interl.h (60%) rename lib/include/{srslte => srsran}/phy/fec/turbo/turbocoder.h (62%) create mode 100644 lib/include/srsran/phy/fec/turbo/turbodecoder.h rename lib/include/{srslte => srsran}/phy/fec/turbo/turbodecoder_gen.h (78%) rename lib/include/{srslte => srsran}/phy/fec/turbo/turbodecoder_impl.h (59%) rename lib/include/{srslte => srsran}/phy/fec/turbo/turbodecoder_iter.h (86%) rename lib/include/{srslte => srsran}/phy/fec/turbo/turbodecoder_sse.h (79%) rename lib/include/{srslte => srsran}/phy/fec/turbo/turbodecoder_win.h (99%) rename lib/include/{srslte => srsran}/phy/io/binsource.h (52%) rename lib/include/{srslte => srsran}/phy/io/filesink.h (57%) rename lib/include/{srslte => srsran}/phy/io/filesource.h (54%) create mode 100644 lib/include/srsran/phy/io/format.h rename lib/include/{srslte => srsran}/phy/io/netsink.h (57%) rename lib/include/{srslte => srsran}/phy/io/netsource.h (53%) rename lib/include/{srslte => srsran}/phy/mimo/layermap.h (57%) rename lib/include/{srslte => srsran}/phy/mimo/precoding.h (64%) rename lib/include/{srslte => srsran}/phy/modem/demod_hard.h (57%) rename lib/include/{srslte => srsran}/phy/modem/demod_soft.h (68%) rename lib/include/{srslte => srsran}/phy/modem/evm.h (90%) rename lib/include/{srslte => srsran}/phy/modem/mod.h (70%) rename lib/include/{srslte => srsran}/phy/modem/modem_table.h (63%) rename lib/include/{srslte => srsran}/phy/phch/cqi.h (62%) rename lib/include/{srslte => srsran}/phy/phch/csi.h (69%) rename lib/include/{srslte => srsran}/phy/phch/csi_cfg.h (55%) create mode 100644 lib/include/srsran/phy/phch/dci.h create mode 100644 lib/include/srsran/phy/phch/dci_nbiot.h rename lib/include/{srslte => srsran}/phy/phch/dci_nr.h (55%) rename lib/include/{srslte => srsran}/phy/phch/mib_sl.h (65%) create mode 100644 lib/include/srsran/phy/phch/npbch.h create mode 100644 lib/include/srsran/phy/phch/npdcch.h create mode 100644 lib/include/srsran/phy/phch/npdsch.h rename lib/include/{srslte => srsran}/phy/phch/npdsch_cfg.h (70%) create mode 100644 lib/include/srsran/phy/phch/pbch.h create mode 100644 lib/include/srsran/phy/phch/pcfich.h create mode 100644 lib/include/srsran/phy/phch/pdcch.h rename lib/include/{srslte => srsran}/phy/phch/pdcch_nr.h (59%) create mode 100644 lib/include/srsran/phy/phch/pdsch.h rename lib/include/{srslte => srsran}/phy/phch/pdsch_cfg.h (61%) create mode 100644 lib/include/srsran/phy/phch/pdsch_nr.h rename lib/include/{srslte => srsran}/phy/phch/phch_cfg_nr.h (70%) create mode 100644 lib/include/srsran/phy/phch/phich.h create mode 100644 lib/include/srsran/phy/phch/pmch.h rename lib/include/{srslte => srsran}/phy/phch/prach.h (69%) rename lib/include/{srslte => srsran}/phy/phch/psbch.h (51%) create mode 100644 lib/include/srsran/phy/phch/pscch.h rename lib/include/{srslte => srsran}/phy/phch/pssch.h (53%) create mode 100644 lib/include/srsran/phy/phch/pucch.h rename lib/include/{srslte => srsran}/phy/phch/pucch_cfg.h (51%) rename lib/include/{srslte => srsran}/phy/phch/pucch_cfg_nr.h (56%) rename lib/include/{srslte => srsran}/phy/phch/pucch_nr.h (64%) rename lib/include/{srslte => srsran}/phy/phch/pucch_proc.h (63%) create mode 100644 lib/include/srsran/phy/phch/pusch.h rename lib/include/{srslte => srsran}/phy/phch/pusch_cfg.h (59%) rename lib/include/{srslte => srsran}/phy/phch/pusch_nr.h (50%) create mode 100644 lib/include/srsran/phy/phch/ra.h create mode 100644 lib/include/srsran/phy/phch/ra_dl.h rename lib/include/{srslte => srsran}/phy/phch/ra_dl_nr.h (65%) rename lib/include/{srslte => srsran}/phy/phch/ra_nbiot.h (58%) rename lib/include/{srslte => srsran}/phy/phch/ra_nr.h (66%) rename lib/include/{srslte => srsran}/phy/phch/ra_sl.h (85%) create mode 100644 lib/include/srsran/phy/phch/ra_ul.h rename lib/include/{srslte => srsran}/phy/phch/ra_ul_nr.h (61%) rename lib/include/{srslte => srsran}/phy/phch/regs.h (54%) create mode 100644 lib/include/srsran/phy/phch/sch.h rename lib/include/{srslte => srsran}/phy/phch/sch_cfg_nr.h (66%) rename lib/include/{srslte => srsran}/phy/phch/sch_nr.h (60%) rename lib/include/{srslte => srsran}/phy/phch/sci.h (61%) rename lib/include/{srslte => srsran}/phy/phch/uci.h (62%) create mode 100644 lib/include/srsran/phy/phch/uci_cfg.h rename lib/include/{srslte => srsran}/phy/phch/uci_cfg_nr.h (73%) rename lib/include/{srslte => srsran}/phy/phch/uci_nr.h (61%) rename lib/include/{srslte => srsran}/phy/resampling/decim.h (63%) rename lib/include/{srslte => srsran}/phy/resampling/interp.h (70%) rename lib/include/{srslte => srsran}/phy/resampling/resample_arb.h (61%) rename lib/include/{srslte => srsran}/phy/resampling/resampler.h (70%) rename lib/include/{srslte => srsran}/phy/rf/rf.h (51%) rename lib/include/{srslte => srsran}/phy/rf/rf_utils.h (59%) create mode 100644 lib/include/srsran/phy/scrambling/scrambling.h create mode 100644 lib/include/srsran/phy/sync/cfo.h create mode 100644 lib/include/srsran/phy/sync/cp.h rename lib/include/{srslte => srsran}/phy/sync/npss.h (55%) rename lib/include/{srslte => srsran}/phy/sync/nsss.h (72%) create mode 100644 lib/include/srsran/phy/sync/pss.h rename lib/include/{srslte => srsran}/phy/sync/psss.h (51%) rename lib/include/{srslte => srsran}/phy/sync/refsignal_dl_sync.h (54%) rename lib/include/{srslte => srsran}/phy/sync/sfo.h (64%) create mode 100644 lib/include/srsran/phy/sync/sss.h create mode 100644 lib/include/srsran/phy/sync/ssss.h rename lib/include/{srslte => srsran}/phy/sync/sync.h (57%) rename lib/include/{srslte => srsran}/phy/sync/sync_nbiot.h (56%) create mode 100644 lib/include/srsran/phy/ue/ue_cell_search.h create mode 100644 lib/include/srsran/phy/ue/ue_cell_search_nbiot.h create mode 100644 lib/include/srsran/phy/ue/ue_dl.h create mode 100644 lib/include/srsran/phy/ue/ue_dl_nbiot.h create mode 100644 lib/include/srsran/phy/ue/ue_dl_nr.h create mode 100644 lib/include/srsran/phy/ue/ue_mib.h rename lib/include/{srslte => srsran}/phy/ue/ue_mib_nbiot.h (52%) rename lib/include/{srslte => srsran}/phy/ue/ue_mib_sl.h (68%) rename lib/include/{srslte => srsran}/phy/ue/ue_phy.h (86%) create mode 100644 lib/include/srsran/phy/ue/ue_sync.h create mode 100644 lib/include/srsran/phy/ue/ue_sync_nbiot.h create mode 100644 lib/include/srsran/phy/ue/ue_ul.h create mode 100644 lib/include/srsran/phy/ue/ue_ul_nr.h rename lib/include/{srslte => srsran}/phy/utils/bit.h (55%) rename lib/include/{srslte => srsran}/phy/utils/cexptab.h (54%) rename lib/include/{srslte => srsran}/phy/utils/convolution.h (61%) rename lib/include/{srslte => srsran}/phy/utils/debug.h (75%) rename lib/include/{srslte => srsran}/phy/utils/filter.h (60%) rename lib/include/{srslte => srsran}/phy/utils/mat.h (57%) rename lib/include/{srslte => srsran}/phy/utils/phy_logger.h (76%) rename lib/include/{srslte => srsran}/phy/utils/primes.h (55%) create mode 100644 lib/include/srsran/phy/utils/random.h rename lib/include/{srslte => srsran}/phy/utils/ringbuffer.h (55%) rename lib/include/{srslte => srsran}/phy/utils/simd.h (87%) rename lib/include/{srslte => srsran}/phy/utils/vector.h (54%) create mode 100644 lib/include/srsran/phy/utils/vector_simd.h rename lib/include/{srslte => srsran}/radio/channel_mapping.h (95%) rename lib/include/{srslte => srsran}/radio/radio.h (85%) rename lib/include/{srslte => srsran}/radio/radio_base.h (69%) rename lib/include/{srslte => srsran}/radio/radio_metrics.h (61%) rename lib/include/{srslte => srsran}/radio/radio_null.h (86%) rename lib/include/{srslte => srsran}/radio/rf_buffer.h (81%) rename lib/include/{srslte => srsran}/radio/rf_timestamp.h (67%) rename lib/include/{srslte => srsran}/rrc/rrc_cfg_utils.h (97%) rename lib/include/{srslte => srsran}/srslog/bundled/fmt/LICENSE.rst (100%) rename lib/include/{srslte => srsran}/srslog/bundled/fmt/chrono.h (100%) rename lib/include/{srslte => srsran}/srslog/bundled/fmt/color.h (100%) rename lib/include/{srslte => srsran}/srslog/bundled/fmt/compile.h (100%) rename lib/include/{srslte => srsran}/srslog/bundled/fmt/core.h (100%) rename lib/include/{srslte => srsran}/srslog/bundled/fmt/format-inl.h (100%) rename lib/include/{srslte => srsran}/srslog/bundled/fmt/format.h (100%) rename lib/include/{srslte => srsran}/srslog/bundled/fmt/locale.h (100%) rename lib/include/{srslte => srsran}/srslog/bundled/fmt/os.h (100%) rename lib/include/{srslte => srsran}/srslog/bundled/fmt/ostream.h (100%) rename lib/include/{srslte => srsran}/srslog/bundled/fmt/posix.h (100%) rename lib/include/{srslte => srsran}/srslog/bundled/fmt/printf.h (100%) rename lib/include/{srslte => srsran}/srslog/bundled/fmt/ranges.h (100%) rename lib/include/{srslte => srsran}/srslog/context.h (98%) rename lib/include/{srslte => srsran}/srslog/detail/log_backend.h (95%) rename lib/include/{srslte => srsran}/srslog/detail/log_entry.h (85%) rename lib/include/{srslte => srsran}/srslog/detail/log_entry_metadata.h (93%) rename lib/include/{srslte => srsran}/srslog/detail/support/any.h (99%) rename lib/include/{srslte => srsran}/srslog/detail/support/error_string.h (94%) rename lib/include/{srslte => srsran}/srslog/detail/support/memory_buffer.h (95%) rename lib/include/{srslte => srsran}/srslog/detail/support/thread_utils.h (98%) rename lib/include/{srslte => srsran}/srslog/detail/support/tmp_utils.h (96%) rename lib/include/{srslte => srsran}/srslog/detail/support/work_queue.h (96%) rename lib/include/{srslte => srsran}/srslog/event_trace.h (98%) rename lib/include/{srslte => srsran}/srslog/formatter.h (97%) rename lib/include/{srslte => srsran}/srslog/log_channel.h (97%) rename lib/include/{srslte => srsran}/srslog/logger.h (98%) rename lib/include/{srslte => srsran}/srslog/shared_types.h (89%) rename lib/include/{srslte => srsran}/srslog/sink.h (84%) rename lib/include/{srslte => srsran}/srslog/srslog.h (98%) rename lib/include/{srslte => srsran}/srslog/srslog_c.h (98%) create mode 100644 lib/include/srsran/srsran.h rename lib/include/{srslte => srsran}/system/sys_metrics.h (76%) rename lib/include/{srslte => srsran}/system/sys_metrics_processor.h (89%) rename lib/include/{srslte => srsran}/test/ue_test_interfaces.h (66%) rename lib/include/{srslte => srsran}/upper/byte_buffer_queue.h (85%) rename lib/include/{srslte => srsran}/upper/gtpu.h (89%) rename lib/include/{srslte => srsran}/upper/ipv6.h (90%) rename lib/include/{srslte => srsran}/upper/pdcp.h (75%) rename lib/include/{srslte => srsran}/upper/pdcp_entity_base.h (79%) rename lib/include/{srslte => srsran}/upper/pdcp_entity_lte.h (80%) rename lib/include/{srslte => srsran}/upper/pdcp_entity_nr.h (85%) rename lib/include/{srslte => srsran}/upper/pdcp_metrics.h (75%) rename lib/include/{srslte => srsran}/upper/rlc.h (80%) rename lib/include/{srslte => srsran}/upper/rlc_am_base.h (58%) rename lib/include/{srslte => srsran}/upper/rlc_am_lte.h (93%) rename lib/include/{srslte => srsran}/upper/rlc_am_nr.h (85%) rename lib/include/{srslte => srsran}/upper/rlc_common.h (96%) rename lib/include/{srslte => srsran}/upper/rlc_metrics.h (72%) rename lib/include/{srslte => srsran}/upper/rlc_tm.h (83%) rename lib/include/{srslte => srsran}/upper/rlc_um_base.h (86%) rename lib/include/{srslte => srsran}/upper/rlc_um_lte.h (89%) rename lib/include/{srslte => srsran}/upper/rlc_um_nr.h (89%) create mode 100644 lib/include/srsran/version.h.in rename lib/test/asn1/{srslte_asn1_nas_test.cc => srsran_asn1_nas_test.cc} (92%) rename lib/test/asn1/{srslte_asn1_rrc_dl_ccch_test.cc => srsran_asn1_rrc_dl_ccch_test.cc} (96%) rename lib/test/asn1/{srslte_asn1_rrc_dl_dcch_test.cc => srsran_asn1_rrc_dl_dcch_test.cc} (95%) rename lib/test/asn1/{srslte_asn1_rrc_mcch_test.cc => srsran_asn1_rrc_mcch_test.cc} (95%) rename lib/test/asn1/{srslte_asn1_rrc_meas_test.cc => srsran_asn1_rrc_meas_test.cc} (93%) rename lib/test/asn1/{srslte_asn1_rrc_nr_test.cc => srsran_asn1_rrc_nr_test.cc} (96%) rename lib/test/asn1/{srslte_asn1_rrc_ul_dcch_test.cc => srsran_asn1_rrc_ul_dcch_test.cc} (96%) diff --git a/.gdbinit b/.gdbinit index 5ceaea16d..6e3a249dd 100644 --- a/.gdbinit +++ b/.gdbinit @@ -12,7 +12,7 @@ python -###### srslte::bounded_vector ######## +###### srsran::bounded_vector ######## class BoundedVectorPrinter(object): def __init__(self, val): @@ -35,7 +35,7 @@ class BoundedVectorPrinter(object): @staticmethod def make(val): - if str(val.type).startswith('srslte::bounded_vector<'): + if str(val.type).startswith('srsran::bounded_vector<'): return BoundedVectorPrinter(val) gdb.pretty_printers.append(BoundedVectorPrinter.make) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index eb112a4e9..976786810 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1,6 +1,6 @@ ## Issue Description ## diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml index d1a4601fe..9840d5fa5 100644 --- a/.github/workflows/ccpp.yml +++ b/.github/workflows/ccpp.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-18.04 steps: - uses: actions/checkout@v1 - - name: Build srsLTE on x86 Ubuntu 18.04 + - name: Build srsRAN on x86 Ubuntu 18.04 run: | sudo apt update sudo apt install -y build-essential cmake libfftw3-dev libmbedtls-dev libpcsclite-dev libboost-program-options-dev libconfig++-dev libsctp-dev colordiff ninja-build valgrind @@ -22,7 +22,7 @@ jobs: runs-on: ubuntu-16.04 steps: - uses: actions/checkout@v1 - - name: Build srsLTE on x86 Ubuntu 16.04 + - name: Build srsRAN on x86 Ubuntu 16.04 run: | sudo apt update sudo apt install -y build-essential cmake libfftw3-dev libmbedtls-dev libpcsclite-dev libboost-program-options-dev libconfig++-dev libsctp-dev colordiff ninja-build valgrind @@ -36,7 +36,7 @@ jobs: compiler: [gcc, clang] steps: - uses: actions/checkout@v1 - - name: Build srsLTE on aarch64 + - name: Build srsRAN on aarch64 uses: uraimo/run-on-arch-action@master with: architecture: aarch64 diff --git a/CMakeLists.txt b/CMakeLists.txt index f92538684..2f7ff1327 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -19,14 +19,14 @@ endif(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) # Project setup ######################################################################## cmake_minimum_required(VERSION 2.6) -project( SRSLTE ) +project( SRSRAN ) message( STATUS "CMAKE_SYSTEM: " ${CMAKE_SYSTEM} ) message( STATUS "CMAKE_SYSTEM_PROCESSOR: " ${CMAKE_SYSTEM_PROCESSOR} ) message( STATUS "CMAKE_CXX_COMPILER: " ${CMAKE_CXX_COMPILER} ) list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/modules") -include(SRSLTEVersion) #sets version information -include(SRSLTEPackage) #setup cpack +include(SRSRANVersion) #sets version information +include(SRSRANPackage) #setup cpack include(CTest) @@ -43,8 +43,8 @@ set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "") # Generate CMake to include build information configure_file( - ${PROJECT_SOURCE_DIR}/cmake/modules/SRSLTEbuildinfo.cmake.in - ${CMAKE_BINARY_DIR}/SRSLTEbuildinfo.cmake + ${PROJECT_SOURCE_DIR}/cmake/modules/SRSRANbuildinfo.cmake.in + ${CMAKE_BINARY_DIR}/SRSRANbuildinfo.cmake ) ######################################################################## @@ -167,7 +167,7 @@ else(POLARSSL_FOUND) endif(BUILD_STATIC) add_definitions(-DHAVE_MBEDTLS) else(MBEDTLS_FOUND) - message(FATAL_ERROR "Either PolarSSL or mbedTLS are required to build srsLTE") + message(FATAL_ERROR "Either PolarSSL or mbedTLS are required to build srsRAN") endif (MBEDTLS_FOUND) endif(POLARSSL_FOUND) @@ -257,7 +257,7 @@ if(Boost_FOUND) include_directories(${Boost_INCLUDE_DIRS}) link_directories(${Boost_LIBRARY_DIRS}) else(Boost_FOUND) - message(FATAL_ERROR "Boost required to build srsLTE") + message(FATAL_ERROR "Boost required to build srsRAN") endif (Boost_FOUND) # srsGUI @@ -310,10 +310,10 @@ set(DATA_DIR share/${CPACK_PACKAGE_NAME}) # Auto-generate config install helper and mark for installation configure_file( - ${PROJECT_SOURCE_DIR}/cmake/modules/SRSLTE_install_configs.sh.in - ${CMAKE_BINARY_DIR}/srslte_install_configs.sh + ${PROJECT_SOURCE_DIR}/cmake/modules/SRSRAN_install_configs.sh.in + ${CMAKE_BINARY_DIR}/srsran_install_configs.sh ) -install(PROGRAMS ${CMAKE_BINARY_DIR}/srslte_install_configs.sh DESTINATION ${RUNTIME_DIR}) +install(PROGRAMS ${CMAKE_BINARY_DIR}/srsran_install_configs.sh DESTINATION ${RUNTIME_DIR}) # Disables the project to build when calling "make install" set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY TRUE) @@ -588,7 +588,7 @@ foreach(_header ${headers}) list(APPEND HEADERS_ALL ${tmp}) endif(IS_DIRECTORY ${_header}) endforeach() -add_custom_target(add_srslte_headers SOURCES ${HEADERS_ALL}) +add_custom_target(add_srsran_headers SOURCES ${HEADERS_ALL}) ######################################################################## # Add the subdirectories diff --git a/COPYRIGHT b/COPYRIGHT index 54c126fd5..c1643382d 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -1,9 +1,9 @@ Files: * -Copyright: 2013-2020, Software Radio Systems Limited. +Copyright: 2013-2021, Software Radio Systems Limited. License: -The following files are used within srsLTE: +The following files are used within srsRAN: Files: lib/src/phy/fec/viterbi37_port.c lib/src/phy/fec/viterbi37_sse.c @@ -19,34 +19,34 @@ Files: srsue/src/upper/pcsc_usim.cc Copyright: 2002-2014, Jouni Malinen License: BSD-3-clause -Files: lib/include/srslte/asn1/liblte_common.h - lib/include/srslte/asn1/liblte_mme.h - lib/include/srslte/common/liblte_security.h +Files: lib/include/srsran/asn1/liblte_common.h + lib/include/srsran/asn1/liblte_mme.h + lib/include/srsran/common/liblte_security.h lib/src/asn1/liblte_common.cc lib/src/asn1/liblte_mme.cc lib/src/common/liblte_security.cc Copyright: 2012-2014 Ben Wojtowicz License: AGPL-3+ -Files: lib/include/srslte/srslog/bundled/fmt/chrono.h - lib/include/srslte/srslog/bundled/fmt/color.h - lib/include/srslte/srslog/bundled/fmt/compile.h - lib/include/srslte/srslog/bundled/fmt/core.h - lib/include/srslte/srslog/bundled/fmt/format.h - lib/include/srslte/srslog/bundled/fmt/format-inl.h - lib/include/srslte/srslog/bundled/fmt/LICENSE.rst - lib/include/srslte/srslog/bundled/fmt/locale.h - lib/include/srslte/srslog/bundled/fmt/os.h - lib/include/srslte/srslog/bundled/fmt/ostream.h - lib/include/srslte/srslog/bundled/fmt/posix.h - lib/include/srslte/srslog/bundled/fmt/printf.h - lib/include/srslte/srslog/bundled/fmt/ranges.h +Files: lib/include/srsran/srslog/bundled/fmt/chrono.h + lib/include/srsran/srslog/bundled/fmt/color.h + lib/include/srsran/srslog/bundled/fmt/compile.h + lib/include/srsran/srslog/bundled/fmt/core.h + lib/include/srsran/srslog/bundled/fmt/format.h + lib/include/srsran/srslog/bundled/fmt/format-inl.h + lib/include/srsran/srslog/bundled/fmt/LICENSE.rst + lib/include/srsran/srslog/bundled/fmt/locale.h + lib/include/srsran/srslog/bundled/fmt/os.h + lib/include/srsran/srslog/bundled/fmt/ostream.h + lib/include/srsran/srslog/bundled/fmt/posix.h + lib/include/srsran/srslog/bundled/fmt/printf.h + lib/include/srsran/srslog/bundled/fmt/ranges.h lib/src/srslog/bundled/fmt/format.cc lib/src/srslog/bundled/fmt/os.cc Copyright: 2012-2020, Victor Zverovich License: MIT -Files: lib/include/srslte/common/backward.hpp +Files: lib/include/srsran/common/backward.hpp cmake/modules/FindBackward.cmake Copyright: 2013, Google Inc. License: MIT @@ -63,7 +63,7 @@ License: AGPL-3+ GNU Affero General Public License for more details. . On Debian systems, the complete text of the AGPL 3 can be found in - /usr/share/doc/srslte/LICENSE + /usr/share/doc/srsran/LICENSE License: LGPL-2.1 diff --git a/CTestConfig.cmake b/CTestConfig.cmake index cb41621e2..c83d049e0 100644 --- a/CTestConfig.cmake +++ b/CTestConfig.cmake @@ -1,15 +1,15 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of # the distribution. # -set(CTEST_PROJECT_NAME "srsLTE") +set(CTEST_PROJECT_NAME "srsRAN") set(CTEST_NIGHTLY_START_TIME "00:00:00 GMT") set(CTEST_DROP_METHOD "http") set(CTEST_DROP_SITE "my.cdash.org") -set(CTEST_DROP_LOCATION "/submit.php?project=srsLTE") +set(CTEST_DROP_LOCATION "/submit.php?project=srsRAN") set(CTEST_DROP_SITE_CDASH TRUE) set(VALGRIND_COMMAND_OPTIONS "--error-exitcode=1 --trace-children=yes --leak-check=full --show-reachable=yes --vex-guest-max-insns=25") diff --git a/README.md b/README.md index 5da4bd793..da526758c 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ -srsLTE +srsRAN ======== -[![Build Status](https://travis-ci.org/srsLTE/srsLTE.svg?branch=master)](https://travis-ci.org/srsLTE/srsLTE) -[![Language grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/srsLTE/srsLTE.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/srsLTE/srsLTE/context:cpp) -[![Coverity](https://scan.coverity.com/projects/10045/badge.svg)](https://scan.coverity.com/projects/srslte) +[![Build Status](https://travis-ci.org/srsRAN/srsRAN.svg?branch=master)](https://travis-ci.org/srsRAN/srsRAN) +[![Language grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/srsRAN/srsRAN.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/srsRAN/srsRAN/context:cpp) +[![Coverity](https://scan.coverity.com/projects/10045/badge.svg)](https://scan.coverity.com/projects/srsran) -srsLTE is a 4G/5G software radio suite developed by SRS (www.softwareradiosystems.com) -See the srsLTE project pages (www.srslte.com) for documentation, guides and project news. +srsRAN is a 4G/5G software radio suite developed by SRS (www.softwareradiosystems.com) +See the srsRAN project pages (www.srsran.com) for documentation, guides and project news. It includes: * srsUE - a complete SDR LTE UE application featuring all layers from PHY to IP @@ -85,7 +85,7 @@ srsEPC Features Hardware -------- -srsLTE has native support for the Ettus Universal Hardware Driver (UHD) and the bladeRF driver. We also support SoapySDR. +srsRAN has native support for the Ettus Universal Hardware Driver (UHD) and the bladeRF driver. We also support SoapySDR. Thus, any hardware supported by SoapySDR can be used. There is no sampling rate conversion, therefore the hardware should support 30.72 MHz clock in order to work correctly with LTE sampling frequencies and decode signals from live LTE base stations. @@ -130,7 +130,7 @@ For CentOS, use the Fedora packages but replace `libconfig-devel` with just `lib Note that depending on your flavor and version of Linux, the actual package names may be different. * Optional requirements: - * srsgui: https://github.com/srslte/srsgui - for real-time plotting. + * srsgui: https://github.com/srsran/srsgui - for real-time plotting. * libpcsclite-dev: https://pcsclite.apdu.fr/ - for accessing smart card readers * libdw-dev libdw - for truly informative backtraces using backward-cpp @@ -140,10 +140,10 @@ Note that depending on your flavor and version of Linux, the actual package name * BladeRF: https://github.com/Nuand/bladeRF * ZeroMQ: https://github.com/zeromq -Download and build srsLTE: +Download and build srsRAN: ``` -git clone https://github.com/srsLTE/srsLTE.git -cd srsLTE +git clone https://github.com/srsRAN/srsRAN.git +cd srsRAN mkdir build cd build cmake ../ @@ -151,15 +151,15 @@ make make test ``` -Install srsLTE: +Install srsRAN: ``` sudo make install -srslte_install_configs.sh user +srsran_install_configs.sh user ``` -This installs srsLTE and also copies the default srsLTE config files to -the user's home directory (~/.config/srslte). +This installs srsRAN and also copies the default srsRAN config files to +the user's home directory (~/.config/srsran). Execution Instructions @@ -171,7 +171,7 @@ if needed, to meet the system configuration. On many systems they should work out of the box. By default, all applications will search for config files in the user's home -directory (~/.config/srslte) upon startup. +directory (~/.config/srsran) upon startup. Note that you have to execute the applications with root privileges to enable real-time thread priorities and to permit creation of virtual network interfaces. @@ -180,7 +180,7 @@ srsENB and srsEPC can run on the same machine as a network-in-the-box configurat srsUE needs to run on a separate machine. If you have installed the software suite using ```sudo make install``` and -have installed the example config files using ```srslte_install_configs.sh user```, +have installed the example config files using ```srsran_install_configs.sh user```, you may just start all applications with their default parameters. ### srsEPC @@ -224,4 +224,4 @@ ping 172.16.0.1 Support ======== -Mailing list: http://www.softwareradiosystems.com/mailman/listinfo/srslte-users +Mailing list: http://www.softwareradiosystems.com/mailman/listinfo/srsran-users diff --git a/build_trial.sh b/build_trial.sh index 876f1197e..174121420 100755 --- a/build_trial.sh +++ b/build_trial.sh @@ -4,8 +4,8 @@ rm -rf sysroot && mkdir sysroot cmake -DCMAKE_INSTALL_PREFIX="sysroot/" ../ make install this="$(date +%Y-%m-%d_%H_%M_%S)" -trialdir="srslte_trial_${this}" -tar="srslte.build-${this}.tgz" +trialdir="srsran_trial_${this}" +tar="srsran.build-${this}.tgz" mkdir ${trialdir} tar czf "${trialdir}/$tar" -C "sysroot" . md5sum "${trialdir}/$tar" >>${trialdir}/checksums.md5 diff --git a/cmake/modules/CheckFunctionExists.c b/cmake/modules/CheckFunctionExists.c index ea4384a94..7fb79ce91 100644 --- a/cmake/modules/CheckFunctionExists.c +++ b/cmake/modules/CheckFunctionExists.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/cmake/modules/FindFFTW3F.cmake b/cmake/modules/FindFFTW3F.cmake index 6ffbb682e..f498ab57d 100644 --- a/cmake/modules/FindFFTW3F.cmake +++ b/cmake/modules/FindFFTW3F.cmake @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of diff --git a/cmake/modules/FindLibConfig.cmake b/cmake/modules/FindLibConfig.cmake index 7311da1e5..554e74ead 100644 --- a/cmake/modules/FindLibConfig.cmake +++ b/cmake/modules/FindLibConfig.cmake @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of diff --git a/cmake/modules/FindLimeSDR.cmake b/cmake/modules/FindLimeSDR.cmake index b711befcd..6186350e4 100644 --- a/cmake/modules/FindLimeSDR.cmake +++ b/cmake/modules/FindLimeSDR.cmake @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of diff --git a/cmake/modules/FindMKL.cmake b/cmake/modules/FindMKL.cmake index 28f080edc..089c54c15 100644 --- a/cmake/modules/FindMKL.cmake +++ b/cmake/modules/FindMKL.cmake @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of diff --git a/cmake/modules/FindMbedTLS.cmake b/cmake/modules/FindMbedTLS.cmake index b8e3dc951..d8fb3b400 100644 --- a/cmake/modules/FindMbedTLS.cmake +++ b/cmake/modules/FindMbedTLS.cmake @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of diff --git a/cmake/modules/FindPCSCLite.cmake b/cmake/modules/FindPCSCLite.cmake index 756ba35f8..f9257637c 100644 --- a/cmake/modules/FindPCSCLite.cmake +++ b/cmake/modules/FindPCSCLite.cmake @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of diff --git a/cmake/modules/FindPolarssl.cmake b/cmake/modules/FindPolarssl.cmake index 5c4c47de5..91d0e528e 100644 --- a/cmake/modules/FindPolarssl.cmake +++ b/cmake/modules/FindPolarssl.cmake @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of diff --git a/cmake/modules/FindSCTP.cmake b/cmake/modules/FindSCTP.cmake index a3ecab77a..e32d4d6ed 100644 --- a/cmake/modules/FindSCTP.cmake +++ b/cmake/modules/FindSCTP.cmake @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of diff --git a/cmake/modules/FindSRSGUI.cmake b/cmake/modules/FindSRSGUI.cmake index 0115fed17..0faac49ab 100644 --- a/cmake/modules/FindSRSGUI.cmake +++ b/cmake/modules/FindSRSGUI.cmake @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of diff --git a/cmake/modules/FindSSE.cmake b/cmake/modules/FindSSE.cmake index 3cb1397d3..7a3e91b31 100644 --- a/cmake/modules/FindSSE.cmake +++ b/cmake/modules/FindSSE.cmake @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of diff --git a/cmake/modules/FindSoapySDR.cmake b/cmake/modules/FindSoapySDR.cmake index c6daee95d..bdd410fb4 100644 --- a/cmake/modules/FindSoapySDR.cmake +++ b/cmake/modules/FindSoapySDR.cmake @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of diff --git a/cmake/modules/FindUHD.cmake b/cmake/modules/FindUHD.cmake index fcf4fa9e8..9a36b52b5 100644 --- a/cmake/modules/FindUHD.cmake +++ b/cmake/modules/FindUHD.cmake @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -52,7 +52,7 @@ IF(UHD_FOUND) set(CMAKE_REQUIRED_FLAGS "${CMAKE_CXX_FLAGS} -L${UHD_LIBRARY_DIR}") set(CMAKE_REQUIRED_LIBRARIES uhd boost_program_options boost_system) - # Checks whether the UHD driver supports X300 reset from srsLTE. This functionality requires changing the function + # Checks whether the UHD driver supports X300 reset from srsRAN. This functionality requires changing the function # `x300_make_ctrl_iface_enet` visibility in the file `uhd/host/lib/usrp/x300_fw_ctrl.cpp`. This can be accomplished # adding the following line: # `UHD_API wb_iface::sptr x300_make_ctrl_iface_enet(uhd::transport::udp_simple::sptr udp, bool enable_errors);` diff --git a/cmake/modules/FindZeroMQ.cmake b/cmake/modules/FindZeroMQ.cmake index b2e1c9d11..7fe97bf2d 100644 --- a/cmake/modules/FindZeroMQ.cmake +++ b/cmake/modules/FindZeroMQ.cmake @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of diff --git a/cmake/modules/FindbladeRF.cmake b/cmake/modules/FindbladeRF.cmake index a41a77453..265015fbe 100644 --- a/cmake/modules/FindbladeRF.cmake +++ b/cmake/modules/FindbladeRF.cmake @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of diff --git a/cmake/modules/SRSLTEVersion.cmake b/cmake/modules/SRSLTEVersion.cmake deleted file mode 100644 index f3c9a4e2d..000000000 --- a/cmake/modules/SRSLTEVersion.cmake +++ /dev/null @@ -1,13 +0,0 @@ -# -# Copyright 2013-2020 Software Radio Systems Limited -# -# By using this file, you agree to the terms and conditions set -# forth in the LICENSE file which can be found at the top level of -# the distribution. -# - -SET(SRSLTE_VERSION_MAJOR 20) -SET(SRSLTE_VERSION_MINOR 10) -SET(SRSLTE_VERSION_PATCH 1) -SET(SRSLTE_VERSION_STRING "${SRSLTE_VERSION_MAJOR}.${SRSLTE_VERSION_MINOR}.${SRSLTE_VERSION_PATCH}") -SET(SRSLTE_SOVERSION 0) diff --git a/cmake/modules/SRSLTEPackage.cmake b/cmake/modules/SRSRANPackage.cmake similarity index 87% rename from cmake/modules/SRSLTEPackage.cmake rename to cmake/modules/SRSRANPackage.cmake index 3e6d7d416..f7245168a 100644 --- a/cmake/modules/SRSLTEPackage.cmake +++ b/cmake/modules/SRSRANPackage.cmake @@ -1,21 +1,21 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of # the distribution. # -SET(CPACK_PACKAGE_DESCRIPTION "srsLTE") +SET(CPACK_PACKAGE_DESCRIPTION "srsRAN") SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "LTE library for SDR.") -SET(CPACK_PACKAGE_NAME "srslte") +SET(CPACK_PACKAGE_NAME "srsran") SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.3.6), libgcc1 (>= 1:4.1), libboost-dev (>= 1.35)") SET(CPACK_PACKAGE_CONTACT "Ismael Gomez ") SET(CPACK_PACKAGE_VENDOR "Software Radio Systems Limited") -SET(CPACK_PACKAGE_VERSION_MAJOR ${SRSLTE_VERSION_MAJOR}) -SET(CPACK_PACKAGE_VERSION_MINOR ${SRSLTE_VERSION_MINOR}) -SET(CPACK_PACKAGE_VERSION_PATCH ${SRSLTE_VERSION_PATCH}) +SET(CPACK_PACKAGE_VERSION_MAJOR ${SRSRAN_VERSION_MAJOR}) +SET(CPACK_PACKAGE_VERSION_MINOR ${SRSRAN_VERSION_MINOR}) +SET(CPACK_PACKAGE_VERSION_PATCH ${SRSRAN_VERSION_PATCH}) SET(VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") ######################################################################## diff --git a/cmake/modules/SRSRANVersion.cmake b/cmake/modules/SRSRANVersion.cmake new file mode 100644 index 000000000..7843a6dfb --- /dev/null +++ b/cmake/modules/SRSRANVersion.cmake @@ -0,0 +1,13 @@ +# +# Copyright 2013-2021 Software Radio Systems Limited +# +# By using this file, you agree to the terms and conditions set +# forth in the LICENSE file which can be found at the top level of +# the distribution. +# + +SET(SRSRAN_VERSION_MAJOR 20) +SET(SRSRAN_VERSION_MINOR 10) +SET(SRSRAN_VERSION_PATCH 1) +SET(SRSRAN_VERSION_STRING "${SRSRAN_VERSION_MAJOR}.${SRSRAN_VERSION_MINOR}.${SRSRAN_VERSION_PATCH}") +SET(SRSRAN_SOVERSION 0) diff --git a/cmake/modules/SRSLTE_install_configs.sh.in b/cmake/modules/SRSRAN_install_configs.sh.in similarity index 83% rename from cmake/modules/SRSLTE_install_configs.sh.in rename to cmake/modules/SRSRAN_install_configs.sh.in index 894d08e7b..aaa642cad 100755 --- a/cmake/modules/SRSLTE_install_configs.sh.in +++ b/cmake/modules/SRSRAN_install_configs.sh.in @@ -8,27 +8,27 @@ # # Auto-updated by CMake with actual install path -SRSLTE_INSTALL_DIR="${CMAKE_INSTALL_PREFIX}/${DATA_DIR}" +SRSRAN_INSTALL_DIR="${CMAKE_INSTALL_PREFIX}/${DATA_DIR}" # check if install mode has been provided if ([ ! $1 ]) then echo "Please call script with either user or service as first parameter." echo "" - echo "E.g. ./srslte_install_configs.sh user" - echo " .. to install all config files to $HOME/.config/srslte" + echo "E.g. ./srsran_install_configs.sh user" + echo " .. to install all config files to $HOME/.config/srsran" echo "" - echo "E.g. ./srslte_install_configs.sh service" - echo " .. to install all config files to /etc/srslte" + echo "E.g. ./srsran_install_configs.sh service" + echo " .. to install all config files to /etc/srsran" exit fi if [ "$1" == "user" ] then - dest_folder="$HOME/.config/srslte" + dest_folder="$HOME/.config/srsran" elif [ "$1" == "service" ] then - dest_folder="/etc/srslte" + dest_folder="/etc/srsran" else echo "Please call script with either user or service as first parameter." exit @@ -54,7 +54,7 @@ fi install_file(){ - source_path="$SRSLTE_INSTALL_DIR/$1" + source_path="$SRSRAN_INSTALL_DIR/$1" dest_path=$(echo "$dest_folder/$1" | sed 's/\.[^.]*$//') # Strip .example from filename # Check if config file already exists in location @@ -88,12 +88,12 @@ install_file(){ return } -# Install all srsLTE config files -echo "Installing srsLTE configuration files:" +# Install all srsRAN config files +echo "Installing srsRAN configuration files:" # Make sure the target directory exists if [ ! -d "$dest_folder" ]; then - echo " - Creating srsLTE config folder $dest_folder" + echo " - Creating srsRAN config folder $dest_folder" mkdir -p $dest_folder if [ $? -ne 0 ]; then exit diff --git a/cmake/modules/SRSLTEbuildinfo.cmake.in b/cmake/modules/SRSRANbuildinfo.cmake.in similarity index 78% rename from cmake/modules/SRSLTEbuildinfo.cmake.in rename to cmake/modules/SRSRANbuildinfo.cmake.in index 3087e84c9..8cbea7325 100644 --- a/cmake/modules/SRSLTEbuildinfo.cmake.in +++ b/cmake/modules/SRSRANbuildinfo.cmake.in @@ -16,6 +16,6 @@ OUTPUT_STRIP_TRAILING_WHITESPACE message(STATUS "Generating build_info.h") configure_file( - @PROJECT_SOURCE_DIR@/lib/include/srslte/build_info.h.in - @CMAKE_BINARY_DIR@/lib/include/srslte/build_info.h + @PROJECT_SOURCE_DIR@/lib/include/srsran/build_info.h.in + @CMAKE_BINARY_DIR@/lib/include/srsran/build_info.h ) diff --git a/debian/control b/debian/control index 8eb566d53..3126b510d 100644 --- a/debian/control +++ b/debian/control @@ -1,7 +1,7 @@ -Source: srslte +Source: srsran Section: universe/misc Priority: optional -Maintainer: srsLTE Packagers +Maintainer: srsRAN Packagers Build-Depends: debhelper (>= 9), dh-exec, @@ -17,25 +17,25 @@ Build-Depends: txt2man Standards-Version: 4.2.1 Homepage: http://www.softwareradiosystems.com -Vcs-Git: https://github.com/srsLTE/srsLTE.git -Vcs-Browser: https://github.com/srsLTE/srsLTE/ +Vcs-Git: https://github.com/srsRAN/srsRAN.git +Vcs-Browser: https://github.com/srsRAN/srsRAN/ -Package: srslte-dev +Package: srsran-dev Architecture: any Multi-Arch: same Section: libdevel Depends: ${shlibs:Depends}, ${misc:Depends}, - srslte-core:any (= ${binary:Version}) + srsran-core:any (= ${binary:Version}) Breaks: srslte (<= 19.03-0ubuntu1) Replaces: srslte (<= 19.03-0ubuntu1) -Description: Static libraries and headers for srslte - This software allows you to run a full end-to-end, open-source LTE system. +Description: Static libraries and headers for srsran + This software allows you to run a full end-to-end, open-source 4G/5G system. It contains a UE, eNB and EPC implementation. . This package contains the development files - static libraries and headers -Package: srslte +Package: srsran Architecture: all Depends: ${shlibs:Depends}, ${misc:Depends}, @@ -46,13 +46,13 @@ Description: LTE software suite for software defined radios (metapackage) This software allows you to run a full end-to-end, open-source LTE system. It contains a UE, eNB and EPC implementation. . - This package installs all srsLTE components. + This package installs all srsRAN components. Package: srsenb Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends}, - srslte-core (= ${binary:Version}) + srsran-core (= ${binary:Version}) Breaks: srslte (<= 19.03-0ubuntu1) Replaces: srslte (<= 19.03-0ubuntu1) Description: Complete SDR LTE eNodeB application @@ -66,25 +66,25 @@ Package: srsepc Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends}, - srslte-core (= ${binary:Version}) + srsran-core (= ${binary:Version}) Recommends: srsenb -Breaks: srslte (<= 19.03-0ubuntu1) -Replaces: srslte (<= 19.03-0ubuntu1) +Breaks: srsepc (<= 19.03-0ubuntu1) +Replaces: srsepc (<= 19.03-0ubuntu1) Description: Light-weight LTE core network implementation This software allows you to run a full end-to-end, open-source LTE system. It contains a UE, eNB and EPC implementation. . This package contains a light-weight LTE core network implementation with MME, HSS and S/P-GW. -Package: srslte-core +Package: srsran-core Architecture: any Multi-Arch: allowed Depends: ${shlibs:Depends}, ${misc:Depends} -Breaks: srslte (<= 19.03-0ubuntu1) -Replaces: srslte (<= 19.03-0ubuntu1) -Description: Common files for srsLTE - This software allows you to run a full end-to-end, open-source LTE system. +Breaks: srslte-core (<= 19.03-0ubuntu1) +Replaces: srslte-core (<= 19.03-0ubuntu1) +Description: Common files for srsRAN + This software allows you to run a full end-to-end, open-source 4G/5G system. It contains a UE, eNB and EPC implementation. . This package contains the common files for srsenb, srsue and srsepc. @@ -93,9 +93,9 @@ Package: srsue Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends}, - srslte-core (= ${binary:Version}) -Breaks: srslte (<= 19.03-0ubuntu1) -Replaces: srslte (<= 19.03-0ubuntu1) + srsran-core (= ${binary:Version}) +Breaks: srsue (<= 19.03-0ubuntu1) +Replaces: srsue (<= 19.03-0ubuntu1) Description: User Equipment implementation for LTE This software enables using a software defined radio as the user equipment connecting to an LTE network. diff --git a/debian/copyright b/debian/copyright index 9f52b0d58..ad1510717 100644 --- a/debian/copyright +++ b/debian/copyright @@ -1,16 +1,16 @@ Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ -Upstream-Name: srsLTE -Upstream-Contact: srsLTE packaging team +Upstream-Name: srsRAN +Upstream-Contact: srsRAN packaging team License: AGPL-3+ -Copyright: 2013-2020, Software Radio Systems Limited. -Source: https://www.github.com/srsLTE +Copyright: 2013-2021, Software Radio Systems Limited. +Source: https://www.github.com/srsRAN Files: * -Copyright: 2013-2020, Software Radio Systems Limited. +Copyright: 2013-2021, Software Radio Systems Limited. License: AGPL-3+ -The following files are used within srsLTE: +The following files are used within srsRAN: Files: lib/src/phy/fec/viterbi37_port.c lib/src/phy/fec/viterbi37_sse.c @@ -26,34 +26,34 @@ Files: srsue/src/upper/pcsc_usim.cc Copyright: 2002-2014, Jouni Malinen License: BSD-3-clause -Files: lib/include/srslte/asn1/liblte_common.h - lib/include/srslte/asn1/liblte_mme.h - lib/include/srslte/common/liblte_security.h +Files: lib/include/srsran/asn1/liblte_common.h + lib/include/srsran/asn1/liblte_mme.h + lib/include/srsran/common/liblte_security.h lib/src/asn1/liblte_common.cc lib/src/asn1/liblte_mme.cc lib/src/common/liblte_security.cc Copyright: 2012-2014 Ben Wojtowicz License: AGPL-3+ -Files: lib/include/srslte/srslog/bundled/fmt/chrono.h - lib/include/srslte/srslog/bundled/fmt/color.h - lib/include/srslte/srslog/bundled/fmt/compile.h - lib/include/srslte/srslog/bundled/fmt/core.h - lib/include/srslte/srslog/bundled/fmt/format.h - lib/include/srslte/srslog/bundled/fmt/format-inl.h - lib/include/srslte/srslog/bundled/fmt/LICENSE.rst - lib/include/srslte/srslog/bundled/fmt/locale.h - lib/include/srslte/srslog/bundled/fmt/os.h - lib/include/srslte/srslog/bundled/fmt/ostream.h - lib/include/srslte/srslog/bundled/fmt/posix.h - lib/include/srslte/srslog/bundled/fmt/printf.h - lib/include/srslte/srslog/bundled/fmt/ranges.h - lib/src/srslog/bundled/fmt/format.cc - lib/src/srslog/bundled/fmt/os.cc +Files: lib/include/srsran/srslog/bundled/fmt/chrono.h + lib/include/srsran/srslog/bundled/fmt/color.h + lib/include/srsran/srslog/bundled/fmt/compile.h + lib/include/srsran/srslog/bundled/fmt/core.h + lib/include/srsran/srslog/bundled/fmt/format.h + lib/include/srsran/srslog/bundled/fmt/format-inl.h + lib/include/srsran/srslog/bundled/fmt/LICENSE.rst + lib/include/srsran/srslog/bundled/fmt/locale.h + lib/include/srsran/srslog/bundled/fmt/os.h + lib/include/srsran/srslog/bundled/fmt/ostream.h + lib/include/srsran/srslog/bundled/fmt/posix.h + lib/include/srsran/srslog/bundled/fmt/printf.h + lib/include/srsran/srslog/bundled/fmt/ranges.h + lib/src/srsran/bundled/fmt/format.cc + lib/src/srsran/bundled/fmt/os.cc Copyright: 2012-2020, Victor Zverovich License: MIT -Files: lib/include/srslte/common/backward.hpp +Files: lib/include/srsran/common/backward.hpp cmake/modules/FindBackward.cmake Copyright: 2013, Google Inc. License: MIT @@ -71,7 +71,7 @@ License: AGPL-3+ GNU Affero General Public License for more details. . On Debian systems, the complete text of the AGPL 3 can be found in - /usr/share/doc/srslte/LICENSE + /usr/share/doc/srsran/LICENSE License: LGPL-2.1 diff --git a/debian/man/srsenb.txt b/debian/man/srsenb.txt index 7009bf594..42501ebe0 100644 --- a/debian/man/srsenb.txt +++ b/debian/man/srsenb.txt @@ -18,7 +18,7 @@ DESCRIPTION - 75 Mbps DL in SISO configuration with commercial UEs - 50 Mbps UL in 20 MHz with commercial UEs - An example configuration file is available in /usr/share/srslte/enb.conf.example + An example configuration file is available in /usr/share/srsran/enb.conf.example OPTIONS diff --git a/debian/man/srsepc.txt b/debian/man/srsepc.txt index d9af06dd7..68beac902 100644 --- a/debian/man/srsepc.txt +++ b/debian/man/srsepc.txt @@ -13,7 +13,7 @@ DESCRIPTION - S/P-GW with standard SGi exposed as virtual network interface (TUN device) - HSS (Home Subscriber Server) with configurable user database in CSV format - An example configuration file is available in /usr/share/srslte/epc.conf.example + An example configuration file is available in /usr/share/srsran/epc.conf.example OPTIONS diff --git a/debian/man/srsue.txt b/debian/man/srsue.txt index 1c7a813d3..149f9c914 100644 --- a/debian/man/srsue.txt +++ b/debian/man/srsue.txt @@ -18,7 +18,7 @@ DESCRIPTION - 75 Mbps DL in 20 MHz SISO configuration in i7 Quad-Core CPU. - 36 Mbps DL in 10 MHz SISO configuration in i5 Dual-Core CPU. - An example configuration file is available in /usr/share/srslte/ue.conf.example + An example configuration file is available in /usr/share/srsran/ue.conf.example OPTIONS diff --git a/debian/packager.sh b/debian/packager.sh index 8edc344fd..2c9be8251 100755 --- a/debian/packager.sh +++ b/debian/packager.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -12,21 +12,21 @@ DISTRO=disco COMMIT=eda7ca69a09933526e9318bcf553af0dc0b81598 REL_FLAG=releases -echo 'Packaging srsLTE release' $RELEASE 'for Ubuntu' $DISTRO +echo 'Packaging srsRAN release' $RELEASE 'for Ubuntu' $DISTRO # Make build dir for the package -BUILD_DIR=~/build-area/srslte_$RELEASE/$REL_FLAG/$DISTRO +BUILD_DIR=~/build-area/srsran_$RELEASE/$REL_FLAG/$DISTRO mkdir -p $BUILD_DIR # Make tarball of the package source -pushd ~/srsLTE -git archive $COMMIT -o $BUILD_DIR/srslte_$DISTRO.tar.gz +pushd ~/srsRAN +git archive $COMMIT -o $BUILD_DIR/srsran_$DISTRO.tar.gz popd # Copy original tarball -cp ~/build-area/srslte_$RELEASE/$REL_FLAG/srslte_$RELEASE.orig.tar.gz $BUILD_DIR +cp ~/build-area/srsran_$RELEASE/$REL_FLAG/srsran_$RELEASE.orig.tar.gz $BUILD_DIR -mkdir $BUILD_DIR/srsLTE -pushd $BUILD_DIR/srsLTE -tar -vxzf ../srslte_$DISTRO.tar.gz +mkdir $BUILD_DIR/srsRAN +pushd $BUILD_DIR/srsRAN +tar -vxzf ../srsran_$DISTRO.tar.gz popd diff --git a/debian/srsenb.service b/debian/srsenb.service index e4d465258..7682d12fd 100644 --- a/debian/srsenb.service +++ b/debian/srsenb.service @@ -4,7 +4,7 @@ Description=Software Radio System's LTE eNB implementation [Service] Type=simple Restart=always -ExecStart=/usr/bin/srsenb /etc/srslte/enb.conf +ExecStart=/usr/bin/srsenb /etc/srsran/enb.conf RestartSec=2 [Install] diff --git a/debian/srsepc.service b/debian/srsepc.service index de5ec4b7f..a332f553b 100644 --- a/debian/srsepc.service +++ b/debian/srsepc.service @@ -4,7 +4,7 @@ Description=Software Radio System's light-weight EPC implementation [Service] Type=simple Restart=always -ExecStart=/usr/bin/srsepc /etc/srslte/epc.conf +ExecStart=/usr/bin/srsepc /etc/srsran/epc.conf RestartSec=2 [Install] diff --git a/debian/srslte-core.config b/debian/srslte-core.config index 83d7550e1..2ed1714c3 100755 --- a/debian/srslte-core.config +++ b/debian/srslte-core.config @@ -7,7 +7,7 @@ set -e . /usr/share/debconf/confmodule # Ask questions -db_input low srslte/install_configs_question || true +db_input low srsran/install_configs_question || true # Show interface db_go || true diff --git a/debian/srslte-core.install b/debian/srslte-core.install index bb2d39b1d..cc512643f 100644 --- a/debian/srslte-core.install +++ b/debian/srslte-core.install @@ -1,3 +1,3 @@ -usr/lib/*/libsrslte_rf.so* -usr/share/srslte -usr/bin/srslte_install_configs.sh +usr/lib/*/libsrsran_rf.so* +usr/share/srsran +usr/bin/srsran_install_configs.sh diff --git a/debian/srslte-core.postinst b/debian/srslte-core.postinst index 2ffbcfcbe..cd09650b9 100755 --- a/debian/srslte-core.postinst +++ b/debian/srslte-core.postinst @@ -4,11 +4,11 @@ . /usr/share/debconf/confmodule # Fetching configuration from debconf -db_get srslte/install_configs_question +db_get srsran/install_configs_question ANSWER1=$RET if [ $ANSWER1 == "true" ]; then - srslte_install_configs.sh user + srsran_install_configs.sh user fi #DEBHELPER# diff --git a/debian/srslte-core.templates b/debian/srslte-core.templates index 847ac0da3..37f94f7dc 100644 --- a/debian/srslte-core.templates +++ b/debian/srslte-core.templates @@ -1,6 +1,6 @@ -Template: srslte/install_configs_question +Template: srsran/install_configs_question Type: boolean Default: true Description: Install configs? - This installs the default srsLTE configuration files to the user's - home directory (~/.config/srslte) but keeps any existing config files. + This installs the default srsRAN configuration files to the user's + home directory (~/.config/srsran) but keeps any existing config files. diff --git a/debian/srslte-dev.install b/debian/srslte-dev.install index d6ba448a9..6d9efcafb 100644 --- a/debian/srslte-dev.install +++ b/debian/srslte-dev.install @@ -1,2 +1,2 @@ usr/lib/*/*.a -usr/include/srslte +usr/include/srsran diff --git a/debian/srsue.service b/debian/srsue.service index 6bfc19a06..5a3e2bcaf 100644 --- a/debian/srsue.service +++ b/debian/srsue.service @@ -4,7 +4,7 @@ Description=Software Radio Systems's LTE UE implementation [Service] Type=simple Restart=always -ExecStart=/usr/bin/srsue /etc/srslte/ue.conf +ExecStart=/usr/bin/srsue /etc/srsran/ue.conf RestartSec=2 [Install] diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index bb1326899..d187e8100 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of diff --git a/lib/examples/CMakeLists.txt b/lib/examples/CMakeLists.txt index 38ed81164..c6439be03 100644 --- a/lib/examples/CMakeLists.txt +++ b/lib/examples/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -11,7 +11,7 @@ ################################################################# add_executable(synch_file synch_file.c) -target_link_libraries(synch_file srslte_phy) +target_link_libraries(synch_file srsran_phy) ################################################################# # These can be compiled without UHD or graphics support @@ -19,30 +19,30 @@ target_link_libraries(synch_file srslte_phy) if(RF_FOUND) add_executable(pdsch_ue pdsch_ue.c) - target_link_libraries(pdsch_ue srslte_phy srslte_common srslte_rf pthread) + target_link_libraries(pdsch_ue srsran_phy srsran_common srsran_rf pthread) add_executable(pdsch_enodeb pdsch_enodeb.c) - target_link_libraries(pdsch_enodeb srslte_phy srslte_common srslte_rf pthread) + target_link_libraries(pdsch_enodeb srsran_phy srsran_common srsran_rf pthread) add_executable(npdsch_enodeb npdsch_enodeb.c) - target_link_libraries(npdsch_enodeb srslte_phy srslte_rf pthread) + target_link_libraries(npdsch_enodeb srsran_phy srsran_rf pthread) add_executable(npdsch_ue npdsch_ue.c npdsch_ue_helper.cc) - target_link_libraries(npdsch_ue srslte_common srslte_phy srslte_rf pthread rrc_asn1) + target_link_libraries(npdsch_ue srsran_common srsran_phy srsran_rf pthread rrc_asn1) else(RF_FOUND) add_definitions(-DDISABLE_RF) add_executable(pdsch_ue pdsch_ue.c) - target_link_libraries(pdsch_ue srslte_common srslte_phy pthread) + target_link_libraries(pdsch_ue srsran_common srsran_phy pthread) add_executable(pdsch_enodeb pdsch_enodeb.c) - target_link_libraries(pdsch_enodeb srslte_common srslte_phy pthread) + target_link_libraries(pdsch_enodeb srsran_common srsran_phy pthread) add_executable(npdsch_enodeb npdsch_enodeb.c) - target_link_libraries(npdsch_enodeb srslte_phy pthread) + target_link_libraries(npdsch_enodeb srsran_phy pthread) add_executable(npdsch_ue npdsch_ue.c npdsch_ue_helper.cc) - target_link_libraries(npdsch_ue srslte_common srslte_phy pthread rrc_asn1) + target_link_libraries(npdsch_ue srsran_common srsran_phy pthread rrc_asn1) endif(RF_FOUND) if(SRSGUI_FOUND) @@ -54,7 +54,7 @@ endif(SRSGUI_FOUND) if (ZEROMQ_FOUND) add_executable(zmq_remote_rx zmq_remote_rx.c) - target_link_libraries(zmq_remote_rx srslte_phy srslte_rf) + target_link_libraries(zmq_remote_rx srsran_phy srsran_rf) endif (ZEROMQ_FOUND) ################################################################# @@ -64,25 +64,25 @@ endif (ZEROMQ_FOUND) if(RF_FOUND) add_executable(cell_search cell_search.c) - target_link_libraries(cell_search srslte_phy srslte_common srslte_rf) + target_link_libraries(cell_search srsran_phy srsran_common srsran_rf) add_executable(usrp_capture usrp_capture.c) - target_link_libraries(usrp_capture srslte_phy srslte_rf) + target_link_libraries(usrp_capture srsran_phy srsran_rf) add_executable(usrp_capture_sync usrp_capture_sync.c) - target_link_libraries(usrp_capture_sync srslte_phy srslte_rf) + target_link_libraries(usrp_capture_sync srsran_phy srsran_rf) add_executable(usrp_capture_sync_nbiot usrp_capture_sync_nbiot.c) - target_link_libraries(usrp_capture_sync_nbiot srslte_rf srslte_phy) + target_link_libraries(usrp_capture_sync_nbiot srsran_rf srsran_phy) add_executable(cell_search_nbiot cell_search_nbiot.c) - target_link_libraries(cell_search_nbiot srslte_rf srslte_phy) + target_link_libraries(cell_search_nbiot srsran_rf srsran_phy) add_executable(usrp_txrx usrp_txrx.c) - target_link_libraries(usrp_txrx srslte_phy srslte_rf) + target_link_libraries(usrp_txrx srsran_phy srsran_rf) add_executable(pssch_ue pssch_ue.c) - target_link_libraries(pssch_ue srslte_phy srslte_common srslte_rf pthread) + target_link_libraries(pssch_ue srsran_phy srsran_common srsran_rf pthread) if(SRSGUI_FOUND) target_link_libraries(pssch_ue ${SRSGUI_LIBRARIES}) diff --git a/lib/examples/cell_search.c b/lib/examples/cell_search.c index c69c5fa38..12e12a75b 100644 --- a/lib/examples/cell_search.c +++ b/lib/examples/cell_search.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -21,13 +21,13 @@ #include -#include "srslte/srslte.h" +#include "srsran/srsran.h" -#include "srslte/common/crash_handler.h" -#include "srslte/phy/rf/rf_utils.h" +#include "srsran/common/crash_handler.h" +#include "srsran/phy/rf/rf_utils.h" #ifndef DISABLE_RF -#include "srslte/phy/rf/rf.h" +#include "srsran/phy/rf/rf.h" #endif #define MHZ 1000000 @@ -40,14 +40,14 @@ int band = -1; int earfcn_start = -1, earfcn_end = -1; -cell_search_cfg_t cell_detect_config = {.max_frames_pbch = SRSLTE_DEFAULT_MAX_FRAMES_PBCH, - .max_frames_pss = SRSLTE_DEFAULT_MAX_FRAMES_PSS, - .nof_valid_pss_frames = SRSLTE_DEFAULT_NOF_VALID_PSS_FRAMES, +cell_search_cfg_t cell_detect_config = {.max_frames_pbch = SRSRAN_DEFAULT_MAX_FRAMES_PBCH, + .max_frames_pss = SRSRAN_DEFAULT_MAX_FRAMES_PSS, + .nof_valid_pss_frames = SRSRAN_DEFAULT_NOF_VALID_PSS_FRAMES, .init_agc = 0, .force_tdd = false}; struct cells { - srslte_cell_t cell; + srsran_cell_t cell; float freq; int dl_earfcn; float power; @@ -65,7 +65,7 @@ void usage(char* prog) printf("\t-s earfcn_start [Default All]\n"); printf("\t-e earfcn_end [Default All]\n"); printf("\t-n nof_frames_total [Default 100]\n"); - printf("\t-v [set srslte_verbose to debug, default none]\n"); + printf("\t-v [set srsran_verbose to debug, default none]\n"); } void parse_args(int argc, char** argv) @@ -92,7 +92,7 @@ void parse_args(int argc, char** argv) rf_gain = strtof(argv[optind], NULL); break; case 'v': - srslte_verbose++; + srsran_verbose++; break; default: usage(argv[0]); @@ -105,10 +105,10 @@ void parse_args(int argc, char** argv) } } -int srslte_rf_recv_wrapper(void* h, void* data, uint32_t nsamples, srslte_timestamp_t* t) +int srsran_rf_recv_wrapper(void* h, void* data, uint32_t nsamples, srsran_timestamp_t* t) { DEBUG(" ---- Receive %d samples ---- ", nsamples); - return srslte_rf_recv_with_time((srslte_rf_t*)h, data, nsamples, 1, NULL, NULL); + return srsran_rf_recv_with_time((srsran_rf_t*)h, data, nsamples, 1, NULL, NULL); } bool go_exit = false; @@ -121,46 +121,46 @@ void sig_int_handler(int signo) } } -static SRSLTE_AGC_CALLBACK(srslte_rf_set_rx_gain_wrapper) +static SRSRAN_AGC_CALLBACK(srsran_rf_set_rx_gain_wrapper) { - srslte_rf_set_rx_gain((srslte_rf_t*)h, gain_db); + srsran_rf_set_rx_gain((srsran_rf_t*)h, gain_db); } int main(int argc, char** argv) { int n; - srslte_rf_t rf; - srslte_ue_cellsearch_t cs; - srslte_ue_cellsearch_result_t found_cells[3]; + srsran_rf_t rf; + srsran_ue_cellsearch_t cs; + srsran_ue_cellsearch_result_t found_cells[3]; int nof_freqs; - srslte_earfcn_t channels[MAX_EARFCN]; + srsran_earfcn_t channels[MAX_EARFCN]; uint32_t freq; uint32_t n_found_cells = 0; - srslte_debug_handle_crash(argc, argv); + srsran_debug_handle_crash(argc, argv); parse_args(argc, argv); printf("Opening RF device...\n"); - if (srslte_rf_open(&rf, rf_args)) { + if (srsran_rf_open(&rf, rf_args)) { ERROR("Error opening rf"); exit(-1); } if (!cell_detect_config.init_agc) { - srslte_rf_set_rx_gain(&rf, rf_gain); + srsran_rf_set_rx_gain(&rf, rf_gain); } else { printf("Starting AGC thread...\n"); - if (srslte_rf_start_gain_thread(&rf, false)) { + if (srsran_rf_start_gain_thread(&rf, false)) { ERROR("Error opening rf"); exit(-1); } - srslte_rf_set_rx_gain(&rf, 50); + srsran_rf_set_rx_gain(&rf, 50); } // Supress RF messages - srslte_rf_suppress_stdout(&rf); + srsran_rf_suppress_stdout(&rf); - nof_freqs = srslte_band_get_fd_band(band, channels, earfcn_start, earfcn_end, MAX_EARFCN); + nof_freqs = srsran_band_get_fd_band(band, channels, earfcn_start, earfcn_end, MAX_EARFCN); if (nof_freqs < 0) { ERROR("Error getting EARFCN list"); exit(-1); @@ -172,18 +172,18 @@ int main(int argc, char** argv) sigprocmask(SIG_UNBLOCK, &sigset, NULL); signal(SIGINT, sig_int_handler); - if (srslte_ue_cellsearch_init(&cs, cell_detect_config.max_frames_pss, srslte_rf_recv_wrapper, (void*)&rf)) { + if (srsran_ue_cellsearch_init(&cs, cell_detect_config.max_frames_pss, srsran_rf_recv_wrapper, (void*)&rf)) { ERROR("Error initiating UE cell detect"); exit(-1); } if (cell_detect_config.max_frames_pss) { - srslte_ue_cellsearch_set_nof_valid_frames(&cs, cell_detect_config.nof_valid_pss_frames); + srsran_ue_cellsearch_set_nof_valid_frames(&cs, cell_detect_config.nof_valid_pss_frames); } if (cell_detect_config.init_agc) { - srslte_rf_info_t* rf_info = srslte_rf_get_info(&rf); - srslte_ue_sync_start_agc(&cs.ue_sync, - srslte_rf_set_rx_gain_wrapper, + srsran_rf_info_t* rf_info = srsran_rf_get_info(&rf); + srsran_ue_sync_start_agc(&cs.ue_sync, + srsran_rf_set_rx_gain_wrapper, rf_info->min_rx_gain, rf_info->max_rx_gain, cell_detect_config.init_agc); @@ -191,32 +191,32 @@ int main(int argc, char** argv) for (freq = 0; freq < nof_freqs && !go_exit; freq++) { /* set rf_freq */ - srslte_rf_set_rx_freq(&rf, 0, (double)channels[freq].fd * MHZ); + srsran_rf_set_rx_freq(&rf, 0, (double)channels[freq].fd * MHZ); INFO("Set rf_freq to %.3f MHz", (double)channels[freq].fd * MHZ / 1000000); printf( "[%3d/%d]: EARFCN %d Freq. %.2f MHz looking for PSS.\n", freq, nof_freqs, channels[freq].id, channels[freq].fd); fflush(stdout); - if (SRSLTE_VERBOSE_ISINFO()) { + if (SRSRAN_VERBOSE_ISINFO()) { printf("\n"); } - bzero(found_cells, 3 * sizeof(srslte_ue_cellsearch_result_t)); + bzero(found_cells, 3 * sizeof(srsran_ue_cellsearch_result_t)); - INFO("Setting sampling frequency %.2f MHz for PSS search", SRSLTE_CS_SAMP_FREQ / 1000000); - srslte_rf_set_rx_srate(&rf, SRSLTE_CS_SAMP_FREQ); + INFO("Setting sampling frequency %.2f MHz for PSS search", SRSRAN_CS_SAMP_FREQ / 1000000); + srsran_rf_set_rx_srate(&rf, SRSRAN_CS_SAMP_FREQ); INFO("Starting receiver..."); - srslte_rf_start_rx_stream(&rf, false); + srsran_rf_start_rx_stream(&rf, false); - n = srslte_ue_cellsearch_scan(&cs, found_cells, NULL); + n = srsran_ue_cellsearch_scan(&cs, found_cells, NULL); if (n < 0) { ERROR("Error searching cell"); exit(-1); } else if (n > 0) { for (int i = 0; i < 3; i++) { if (found_cells[i].psr > 2.0) { - srslte_cell_t cell; + srsran_cell_t cell; cell.id = found_cells[i].cell_id; cell.cp = found_cells[i].cp; int ret = rf_mib_decoder(&rf, 1, &cell_detect_config, &cell, NULL); @@ -224,7 +224,7 @@ int main(int argc, char** argv) ERROR("Error decoding MIB"); exit(-1); } - if (ret == SRSLTE_UE_MIB_FOUND) { + if (ret == SRSRAN_UE_MIB_FOUND) { printf("Found CELL ID %d. %d PRB, %d ports\n", cell.id, cell.nof_prb, cell.nof_ports); if (cell.nof_ports > 0) { results[n_found_cells].cell = cell; @@ -247,12 +247,12 @@ int main(int argc, char** argv) results[i].cell.id, results[i].cell.nof_prb, results[i].cell.nof_ports, - srslte_convert_power_to_dB(results[i].power)); + srsran_convert_power_to_dB(results[i].power)); } printf("\nBye\n"); - srslte_ue_cellsearch_free(&cs); - srslte_rf_close(&rf); + srsran_ue_cellsearch_free(&cs); + srsran_rf_close(&rf); exit(0); } diff --git a/lib/examples/cell_search_nbiot.c b/lib/examples/cell_search_nbiot.c index f895e4b26..984f6e074 100644 --- a/lib/examples/cell_search_nbiot.c +++ b/lib/examples/cell_search_nbiot.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -19,11 +19,11 @@ #include #include -#include "srslte/phy/rf/rf_utils.h" -#include "srslte/phy/ue/ue_cell_search_nbiot.h" +#include "srsran/phy/rf/rf_utils.h" +#include "srsran/phy/ue/ue_cell_search_nbiot.h" #ifndef DISABLE_RF -#include "srslte/phy/rf/rf.h" +#include "srsran/phy/rf/rf.h" #endif #define MHZ 1000000 @@ -40,14 +40,14 @@ double raster_offset[NUM_RASTER_OFFSET] = {0.0, 2500.0, -2500.0, 7500.0, -7500.0 int band = -1; int earfcn_start = -1, earfcn_end = -1; -cell_search_cfg_t cell_detect_config = {.max_frames_pbch = SRSLTE_DEFAULT_MAX_FRAMES_NPBCH, - .max_frames_pss = SRSLTE_DEFAULT_MAX_FRAMES_NPSS, - .nof_valid_pss_frames = SRSLTE_DEFAULT_NOF_VALID_NPSS_FRAMES, +cell_search_cfg_t cell_detect_config = {.max_frames_pbch = SRSRAN_DEFAULT_MAX_FRAMES_NPBCH, + .max_frames_pss = SRSRAN_DEFAULT_MAX_FRAMES_NPSS, + .nof_valid_pss_frames = SRSRAN_DEFAULT_NOF_VALID_NPSS_FRAMES, .init_agc = 0.0, .force_tdd = false}; struct cells { - srslte_nbiot_cell_t cell; + srsran_nbiot_cell_t cell; float freq; int dl_earfcn; float power; @@ -67,7 +67,7 @@ void usage(char* prog) printf("\t-e earfcn_end [Default All]\n"); printf("\t-r Also scan frequencies with raster offset [Default %s]\n", scan_raster_offset ? "Yes" : "No"); printf("\t-n nof_frames_total [Default 100]\n"); - printf("\t-v [set srslte_verbose to debug, default none]\n"); + printf("\t-v [set srsran_verbose to debug, default none]\n"); } void parse_args(int argc, char** argv) @@ -97,7 +97,7 @@ void parse_args(int argc, char** argv) scan_raster_offset = true; break; case 'v': - srslte_verbose++; + srsran_verbose++; break; default: usage(argv[0]); @@ -110,14 +110,14 @@ void parse_args(int argc, char** argv) } } -int srslte_rf_recv_wrapper(void* h, cf_t* data[SRSLTE_MAX_PORTS], uint32_t nsamples, srslte_timestamp_t* t) +int srsran_rf_recv_wrapper(void* h, cf_t* data[SRSRAN_MAX_PORTS], uint32_t nsamples, srsran_timestamp_t* t) { DEBUG(" ---- Receive %d samples ----", nsamples); - void* ptr[SRSLTE_MAX_PORTS]; - for (int i = 0; i < SRSLTE_MAX_PORTS; i++) { + void* ptr[SRSRAN_MAX_PORTS]; + for (int i = 0; i < SRSRAN_MAX_PORTS; i++) { ptr[i] = data[i]; } - return srslte_rf_recv_with_time_multi(h, ptr, nsamples, true, NULL, NULL); + return srsran_rf_recv_with_time_multi(h, ptr, nsamples, true, NULL, NULL); } bool go_exit = false; @@ -130,44 +130,44 @@ void sig_int_handler(int signo) } } -static SRSLTE_AGC_CALLBACK(srslte_rf_set_rx_gain_wrapper) +static SRSRAN_AGC_CALLBACK(srsran_rf_set_rx_gain_wrapper) { - srslte_rf_set_rx_gain((srslte_rf_t*)h, gain_db); + srsran_rf_set_rx_gain((srsran_rf_t*)h, gain_db); } int main(int argc, char** argv) { int n; - srslte_rf_t rf; - srslte_ue_cellsearch_nbiot_t cs; - srslte_nbiot_ue_cellsearch_result_t found_cells[3]; + srsran_rf_t rf; + srsran_ue_cellsearch_nbiot_t cs; + srsran_nbiot_ue_cellsearch_result_t found_cells[3]; int nof_freqs; - srslte_earfcn_t channels[MAX_EARFCN]; + srsran_earfcn_t channels[MAX_EARFCN]; uint32_t freq; uint32_t n_found_cells = 0; parse_args(argc, argv); printf("Opening RF device...\n"); - if (srslte_rf_open(&rf, rf_args)) { + if (srsran_rf_open(&rf, rf_args)) { fprintf(stderr, "Error opening rf\n"); exit(-1); } if (!cell_detect_config.init_agc) { - srslte_rf_set_rx_gain(&rf, rf_gain); + srsran_rf_set_rx_gain(&rf, rf_gain); } else { printf("Starting AGC thread...\n"); - if (srslte_rf_start_gain_thread(&rf, false)) { + if (srsran_rf_start_gain_thread(&rf, false)) { fprintf(stderr, "Error opening rf\n"); exit(-1); } - srslte_rf_set_rx_gain(&rf, 50); + srsran_rf_set_rx_gain(&rf, 50); } // Supress RF messages - srslte_rf_suppress_stdout(&rf); + srsran_rf_suppress_stdout(&rf); - nof_freqs = srslte_band_get_fd_band(band, channels, earfcn_start, earfcn_end, MAX_EARFCN); + nof_freqs = srsran_band_get_fd_band(band, channels, earfcn_start, earfcn_end, MAX_EARFCN); if (nof_freqs < 0) { fprintf(stderr, "Error getting EARFCN list\n"); exit(-1); @@ -183,47 +183,47 @@ int main(int argc, char** argv) for (int i = 0; i < (scan_raster_offset ? NUM_RASTER_OFFSET : 1); i++) { // set rf_freq double rf_freq = channels[freq].fd * MHZ + raster_offset[i]; - srslte_rf_set_rx_freq(&rf, 0, rf_freq); + srsran_rf_set_rx_freq(&rf, 0, rf_freq); INFO("Set rf_freq to %.3f Hz", rf_freq); printf("[%3d/%d]: EARFCN %d, %.2f MHz looking for NPSS.\n", freq, nof_freqs, channels[freq].id, rf_freq / 1e6); fflush(stdout); - if (SRSLTE_VERBOSE_ISINFO()) { + if (SRSRAN_VERBOSE_ISINFO()) { printf("\n"); } - bzero(found_cells, 3 * sizeof(srslte_nbiot_ue_cellsearch_result_t)); + bzero(found_cells, 3 * sizeof(srsran_nbiot_ue_cellsearch_result_t)); - if (srslte_ue_cellsearch_nbiot_init(&cs, cell_detect_config.max_frames_pss, srslte_rf_recv_wrapper, (void*)&rf)) { + if (srsran_ue_cellsearch_nbiot_init(&cs, cell_detect_config.max_frames_pss, srsran_rf_recv_wrapper, (void*)&rf)) { fprintf(stderr, "Error initiating UE cell detect\n"); exit(-1); } if (cell_detect_config.max_frames_pss) { - srslte_ue_cellsearch_nbiot_set_nof_valid_frames(&cs, cell_detect_config.nof_valid_pss_frames); + srsran_ue_cellsearch_nbiot_set_nof_valid_frames(&cs, cell_detect_config.nof_valid_pss_frames); } if (cell_detect_config.init_agc) { - srslte_ue_sync_nbiot_start_agc(&cs.ue_sync, srslte_rf_set_rx_gain_wrapper, cell_detect_config.init_agc); + srsran_ue_sync_nbiot_start_agc(&cs.ue_sync, srsran_rf_set_rx_gain_wrapper, cell_detect_config.init_agc); } - INFO("Setting sampling frequency %.2f MHz for NPSS search", SRSLTE_CS_SAMP_FREQ / 1000000); - srslte_rf_set_rx_srate(&rf, SRSLTE_CS_SAMP_FREQ); + INFO("Setting sampling frequency %.2f MHz for NPSS search", SRSRAN_CS_SAMP_FREQ / 1000000); + srsran_rf_set_rx_srate(&rf, SRSRAN_CS_SAMP_FREQ); INFO("Starting receiver..."); - srslte_rf_start_rx_stream(&rf, false); - - n = srslte_ue_cellsearch_nbiot_scan(&cs); - if (n == SRSLTE_SUCCESS) { - srslte_rf_stop_rx_stream(&rf); - n = srslte_ue_cellsearch_nbiot_detect(&cs, found_cells); - if (n == SRSLTE_SUCCESS) { - srslte_nbiot_cell_t cell; + srsran_rf_start_rx_stream(&rf, false); + + n = srsran_ue_cellsearch_nbiot_scan(&cs); + if (n == SRSRAN_SUCCESS) { + srsran_rf_stop_rx_stream(&rf); + n = srsran_ue_cellsearch_nbiot_detect(&cs, found_cells); + if (n == SRSRAN_SUCCESS) { + srsran_nbiot_cell_t cell; cell.n_id_ncell = found_cells[0].n_id_ncell; - cell.base.cp = SRSLTE_CP_NORM; + cell.base.cp = SRSRAN_CP_NORM; // TODO: add MIB decoding printf("Found CELL ID %d.\n", cell.n_id_ncell); - memcpy(&results[n_found_cells].cell, &cell, sizeof(srslte_nbiot_cell_t)); + memcpy(&results[n_found_cells].cell, &cell, sizeof(srsran_nbiot_cell_t)); results[n_found_cells].freq = channels[freq].fd; results[n_found_cells].dl_earfcn = channels[freq].id; results[n_found_cells].power = found_cells[0].peak; @@ -232,7 +232,7 @@ int main(int argc, char** argv) printf("Cell found but couldn't detect ID.\n"); } } - srslte_ue_cellsearch_nbiot_free(&cs); + srsran_ue_cellsearch_nbiot_free(&cs); } } @@ -247,6 +247,6 @@ int main(int argc, char** argv) printf("\nBye\n"); - srslte_rf_close(&rf); + srsran_rf_close(&rf); exit(0); } diff --git a/lib/examples/npdsch_enodeb.c b/lib/examples/npdsch_enodeb.c index c3d3c4717..aeae4dddb 100644 --- a/lib/examples/npdsch_enodeb.c +++ b/lib/examples/npdsch_enodeb.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -21,15 +21,15 @@ #include #include -#include "srslte/phy/ch_estimation/chest_dl_nbiot.h" -#include "srslte/phy/channel/ch_awgn.h" -#include "srslte/phy/io/filesink.h" -#include "srslte/phy/io/filesource.h" -#include "srslte/phy/sync/npss.h" -#include "srslte/phy/sync/nsss.h" -#include "srslte/phy/ue/ue_dl_nbiot.h" -#include "srslte/phy/utils/bit.h" -#include "srslte/phy/utils/random.h" +#include "srsran/phy/ch_estimation/chest_dl_nbiot.h" +#include "srsran/phy/channel/ch_awgn.h" +#include "srsran/phy/io/filesink.h" +#include "srsran/phy/io/filesource.h" +#include "srsran/phy/sync/npss.h" +#include "srsran/phy/sync/nsss.h" +#include "srsran/phy/ue/ue_dl_nbiot.h" +#include "srsran/phy/utils/bit.h" +#include "srsran/phy/utils/random.h" #define UE_CRNTI 0x1234 @@ -41,20 +41,20 @@ static const uint8_t dummy_sib1_payload[] = {0x43, 0x4d, 0xd0, 0x92, 0x22, 0x06, 0x02, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; #ifndef DISABLE_RF -#include "srslte/phy/rf/rf.h" -static srslte_rf_t radio; +#include "srsran/phy/rf/rf.h" +static srsran_rf_t radio; #else #pragma message "Compiling npdsch_ue with no RF support" #endif static char* output_file_name = NULL; -static srslte_nbiot_cell_t cell = { - .base = {.nof_ports = 1, .nof_prb = SRSLTE_NBIOT_DEFAULT_NUM_PRB_BASECELL, .cp = SRSLTE_CP_NORM, .id = 0}, - .nbiot_prb = SRSLTE_NBIOT_DEFAULT_PRB_OFFSET, +static srsran_nbiot_cell_t cell = { + .base = {.nof_ports = 1, .nof_prb = SRSRAN_NBIOT_DEFAULT_NUM_PRB_BASECELL, .cp = SRSRAN_CP_NORM, .id = 0}, + .nbiot_prb = SRSRAN_NBIOT_DEFAULT_PRB_OFFSET, .n_id_ncell = 0, .nof_ports = 1, - .mode = SRSLTE_NBIOT_MODE_STANDALONE, + .mode = SRSRAN_NBIOT_MODE_STANDALONE, .is_r14 = true}; static uint32_t i_tbs_val = 1, last_i_tbs_val = 1; @@ -67,22 +67,22 @@ static float rf_amp = 0.8, rf_gain = 70.0, rf_freq = 0; static float file_snr = -100.0; static bool null_file_sink = false; -static srslte_random_t* random_gen; -static srslte_filesink_t fsink; -static srslte_ofdm_t ifft; -static srslte_npss_synch_t npss_sync; -static srslte_nsss_synch_t nsss_sync; -static srslte_npbch_t npbch; -static srslte_npdcch_t npdcch; -static srslte_npdsch_t npdsch; -static srslte_npdsch_cfg_t sib1_npdsch_cfg; -static srslte_npdsch_cfg_t npdsch_cfg; -static srslte_nbiot_ue_dl_t ue_dl; -static srslte_softbuffer_tx_t softbuffer; -static srslte_ra_nbiot_dl_dci_t ra_dl; -static srslte_ra_nbiot_dl_dci_t ra_dl_sib1; -static srslte_chest_dl_nbiot_t ch_est; -static srslte_mib_nb_t mib_nb; +static srsran_random_t* random_gen; +static srsran_filesink_t fsink; +static srsran_ofdm_t ifft; +static srsran_npss_synch_t npss_sync; +static srsran_nsss_synch_t nsss_sync; +static srsran_npbch_t npbch; +static srsran_npdcch_t npdcch; +static srsran_npdsch_t npdsch; +static srsran_npdsch_cfg_t sib1_npdsch_cfg; +static srsran_npdsch_cfg_t npdsch_cfg; +static srsran_nbiot_ue_dl_t ue_dl; +static srsran_softbuffer_tx_t softbuffer; +static srsran_ra_nbiot_dl_dci_t ra_dl; +static srsran_ra_nbiot_dl_dci_t ra_dl_sib1; +static srsran_chest_dl_nbiot_t ch_est; +static srsran_mib_nb_t mib_nb; static uint32_t sched_info_tag = 0; // according to Table 16.4.1.3-3 in 36.213, 0 means 4 NPDSCH repetitions with TBS 208 @@ -110,7 +110,7 @@ void usage(char* prog) printf("\t-l n_id_ncell [Default %d]\n", cell.n_id_ncell); printf("\t-R Is R14 cell [Default %s]\n", cell.is_r14 ? "Yes" : "No"); printf("\t-p NB-IoT PRB id [Default %d]\n", cell.nbiot_prb); - printf("\t-v [set srslte_verbose to debug, default none]\n"); + printf("\t-v [set srsran_verbose to debug, default none]\n"); } void parse_args(int argc, char** argv) @@ -161,7 +161,7 @@ void parse_args(int argc, char** argv) cell.nbiot_prb = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'v': - srslte_verbose++; + srsran_verbose++; break; default: usage(argv[0]); @@ -186,12 +186,12 @@ void parse_args(int argc, char** argv) void base_init() { // init memory - sf_buffer = srslte_vec_cf_malloc(sf_n_re); + sf_buffer = srsran_vec_cf_malloc(sf_n_re); if (!sf_buffer) { perror("malloc"); exit(-1); } - output_buffer = srslte_vec_cf_malloc(sf_n_samples); + output_buffer = srsran_vec_cf_malloc(sf_n_samples); if (!output_buffer) { perror("malloc"); exit(-1); @@ -199,7 +199,7 @@ void base_init() // open file or USRP if (output_file_name) { if (strcmp(output_file_name, "NULL")) { - if (srslte_filesink_init(&fsink, output_file_name, SRSLTE_COMPLEX_FLOAT_BIN)) { + if (srsran_filesink_init(&fsink, output_file_name, SRSRAN_COMPLEX_FLOAT_BIN)) { fprintf(stderr, "Error opening file %s\n", output_file_name); exit(-1); } @@ -210,7 +210,7 @@ void base_init() } else { #ifndef DISABLE_RF printf("Opening RF device...\n"); - if (srslte_rf_open(&radio, rf_args)) { + if (srsran_rf_open(&radio, rf_args)) { fprintf(stderr, "Error opening rf\n"); exit(-1); } @@ -220,72 +220,72 @@ void base_init() #endif } - if (srslte_ofdm_tx_init(&ifft, SRSLTE_CP_NORM, sf_buffer, output_buffer, cell.base.nof_prb)) { + if (srsran_ofdm_tx_init(&ifft, SRSRAN_CP_NORM, sf_buffer, output_buffer, cell.base.nof_prb)) { fprintf(stderr, "Error creating iFFT object\n"); exit(-1); } - srslte_ofdm_set_normalize(&ifft, true); - srslte_ofdm_set_freq_shift(&ifft, -SRSLTE_NBIOT_FREQ_SHIFT_FACTOR); + srsran_ofdm_set_normalize(&ifft, true); + srsran_ofdm_set_freq_shift(&ifft, -SRSRAN_NBIOT_FREQ_SHIFT_FACTOR); - if (srslte_npss_synch_init(&npss_sync, sf_n_samples, srslte_symbol_sz(cell.base.nof_prb))) { + if (srsran_npss_synch_init(&npss_sync, sf_n_samples, srsran_symbol_sz(cell.base.nof_prb))) { fprintf(stderr, "Error initializing NPSS object\n"); exit(-1); } - if (srslte_nsss_synch_init(&nsss_sync, sf_n_samples, srslte_symbol_sz(cell.base.nof_prb))) { + if (srsran_nsss_synch_init(&nsss_sync, sf_n_samples, srsran_symbol_sz(cell.base.nof_prb))) { fprintf(stderr, "Error initializing NSSS object\n"); exit(-1); } - if (srslte_npbch_init(&npbch)) { + if (srsran_npbch_init(&npbch)) { fprintf(stderr, "Error creating NPBCH object\n"); exit(-1); } - if (srslte_npbch_set_cell(&npbch, cell)) { + if (srsran_npbch_set_cell(&npbch, cell)) { fprintf(stderr, "Error setting cell in NPBCH object\n"); exit(-1); } - if (srslte_npdcch_init(&npdcch)) { + if (srsran_npdcch_init(&npdcch)) { fprintf(stderr, "Error creating NPDCCH object\n"); exit(-1); } - if (srslte_npdcch_set_cell(&npdcch, cell)) { + if (srsran_npdcch_set_cell(&npdcch, cell)) { fprintf(stderr, "Configuring cell in NPDCCH\n"); exit(-1); } - if (srslte_npdsch_init(&npdsch)) { + if (srsran_npdsch_init(&npdsch)) { fprintf(stderr, "Error creating NPDSCH object\n"); exit(-1); } - if (srslte_npdsch_set_cell(&npdsch, cell)) { + if (srsran_npdsch_set_cell(&npdsch, cell)) { fprintf(stderr, "Configuring cell in NPDSCH\n"); exit(-1); } - srslte_npdsch_set_rnti(&npdsch, UE_CRNTI); + srsran_npdsch_set_rnti(&npdsch, UE_CRNTI); - if (srslte_softbuffer_tx_init(&softbuffer, cell.base.nof_prb)) { + if (srsran_softbuffer_tx_init(&softbuffer, cell.base.nof_prb)) { fprintf(stderr, "Error initiating soft buffer\n"); exit(-1); } - random_gen = srslte_random_init(time(NULL)); + random_gen = srsran_random_init(time(NULL)); } void base_free() { - srslte_random_free(random_gen); - srslte_softbuffer_tx_free(&softbuffer); - srslte_npdsch_free(&npdsch); - srslte_npdcch_free(&npdcch); - srslte_npbch_free(&npbch); - srslte_chest_dl_nbiot_free(&ch_est); - srslte_npss_synch_free(&npss_sync); - srslte_nsss_synch_free(&nsss_sync); - srslte_ofdm_tx_free(&ifft); + srsran_random_free(random_gen); + srsran_softbuffer_tx_free(&softbuffer); + srsran_npdsch_free(&npdsch); + srsran_npdcch_free(&npdcch); + srsran_npbch_free(&npbch); + srsran_chest_dl_nbiot_free(&ch_est); + srsran_npss_synch_free(&npss_sync); + srsran_nsss_synch_free(&nsss_sync); + srsran_ofdm_tx_free(&ifft); if (sf_buffer) { free(sf_buffer); @@ -295,11 +295,11 @@ void base_free() } if (output_file_name) { if (!null_file_sink) { - srslte_filesink_free(&fsink); + srsran_filesink_free(&fsink); } } else { #ifndef DISABLE_RF - srslte_rf_close(&radio); + srsran_rf_close(&radio); #endif } } @@ -317,14 +317,14 @@ void sig_int_handler(int signo) static int update_radl(void) { - bzero(&ra_dl_sib1, sizeof(srslte_ra_nbiot_dl_dci_t)); + bzero(&ra_dl_sib1, sizeof(srsran_ra_nbiot_dl_dci_t)); // NB-IoT specific fields ra_dl_sib1.alloc.has_sib1 = true; ra_dl_sib1.alloc.sched_info_sib1 = mib_nb.sched_info_sib1; ra_dl_sib1.mcs_idx = 1; - bzero(&ra_dl, sizeof(srslte_ra_nbiot_dl_dci_t)); + bzero(&ra_dl, sizeof(srsran_ra_nbiot_dl_dci_t)); ra_dl.mcs_idx = i_tbs_val; // NB-IoT specific fields @@ -337,19 +337,19 @@ static int update_radl(void) ra_dl.alloc.harq_ack = 1; ra_dl.alloc.i_n_start = 0; - srslte_nbiot_dl_dci_fprint(stdout, &ra_dl); - srslte_ra_nbiot_dl_grant_t dummy_grant; - srslte_ra_nbits_t dummy_nbits; + srsran_nbiot_dl_dci_fprint(stdout, &ra_dl); + srsran_ra_nbiot_dl_grant_t dummy_grant; + srsran_ra_nbits_t dummy_nbits; #define DUMMY_SFIDX 1 #define DUMMY_SFN 0 - srslte_ra_nbiot_dl_dci_to_grant(&ra_dl, &dummy_grant, DUMMY_SFN, DUMMY_SFIDX, DUMMY_R_MAX, false, cell.mode); - srslte_ra_nbiot_dl_grant_to_nbits(&dummy_grant, cell, 0, &dummy_nbits); - srslte_ra_nbiot_dl_grant_fprint(stdout, &dummy_grant); + srsran_ra_nbiot_dl_dci_to_grant(&ra_dl, &dummy_grant, DUMMY_SFN, DUMMY_SFIDX, DUMMY_R_MAX, false, cell.mode); + srsran_ra_nbiot_dl_grant_to_nbits(&dummy_grant, cell, 0, &dummy_nbits); + srsran_ra_nbiot_dl_grant_fprint(stdout, &dummy_grant); printf("Type new MCS index and press Enter: "); fflush(stdout); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } /* Read new MCS from stdin */ @@ -396,14 +396,14 @@ uint8_t data_tmp[DATA_BUFF_SZ] = {}; int main(int argc, char** argv) { int nf = 0, sf_idx = 0; - cf_t npss_signal[SRSLTE_NPSS_TOT_LEN]; - cf_t nsss_signal[SRSLTE_NSSS_LEN * SRSLTE_NSSS_NUM_SEQ]; // for subframe 9 + cf_t npss_signal[SRSRAN_NPSS_TOT_LEN]; + cf_t nsss_signal[SRSRAN_NSSS_LEN * SRSRAN_NSSS_NUM_SEQ]; // for subframe 9 - uint8_t bch_payload[SRSLTE_MIB_NB_LEN]; - uint8_t sib1_nb_payload[SRSLTE_NPDSCH_MAX_TBS]; + uint8_t bch_payload[SRSRAN_MIB_NB_LEN]; + uint8_t sib1_nb_payload[SRSRAN_NPDSCH_MAX_TBS]; - srslte_dci_msg_t dci_msg; - srslte_dci_location_t locations[SRSLTE_NOF_SF_X_FRAME][30]; + srsran_dci_msg_t dci_msg; + srsran_dci_location_t locations[SRSRAN_NOF_SF_X_FRAME][30]; uint32_t sfn = 0; uint32_t hfn = 0; // Hyper frame number is incremented when sfn wraps and is also 10bit wide @@ -423,60 +423,60 @@ int main(int argc, char** argv) printf("Target SNR: %.2fdB\n", file_snr); } - sf_n_re = 2 * SRSLTE_CP_NORM_NSYMB * cell.base.nof_prb * SRSLTE_NRE; - sf_n_samples = 2 * SRSLTE_SLOT_LEN(srslte_symbol_sz(cell.base.nof_prb)); + sf_n_re = 2 * SRSRAN_CP_NORM_NSYMB * cell.base.nof_prb * SRSRAN_NRE; + sf_n_samples = 2 * SRSRAN_SLOT_LEN(srsran_symbol_sz(cell.base.nof_prb)); /* this *must* be called after setting slot_len_* */ base_init(); // buffer for outputting signal in RE representation (using sf_n_re) - cf_t* sf_re_symbols[SRSLTE_MAX_PORTS] = {NULL, NULL, NULL, NULL}; + cf_t* sf_re_symbols[SRSRAN_MAX_PORTS] = {NULL, NULL, NULL, NULL}; sf_re_symbols[0] = sf_buffer; // buffer for outputting actual IQ samples (using sf_n_samples) - cf_t* sf_symbols[SRSLTE_MAX_PORTS] = {NULL, NULL, NULL, NULL}; + cf_t* sf_symbols[SRSRAN_MAX_PORTS] = {NULL, NULL, NULL, NULL}; sf_symbols[0] = output_buffer; // construct MIB-NB mib_nb.sched_info_sib1 = sched_info_tag; mib_nb.sys_info_tag = 0; mib_nb.ac_barring = false; - mib_nb.mode = SRSLTE_NBIOT_MODE_STANDALONE; + mib_nb.mode = SRSRAN_NBIOT_MODE_STANDALONE; // Initialize UE DL - if (srslte_nbiot_ue_dl_init(&ue_dl, sf_symbols, SRSLTE_NBIOT_MAX_PRB, SRSLTE_NBIOT_NUM_RX_ANTENNAS)) { + if (srsran_nbiot_ue_dl_init(&ue_dl, sf_symbols, SRSRAN_NBIOT_MAX_PRB, SRSRAN_NBIOT_NUM_RX_ANTENNAS)) { fprintf(stderr, "Error initiating UE downlink processing module\n"); exit(-1); } - if (srslte_nbiot_ue_dl_set_cell(&ue_dl, cell)) { + if (srsran_nbiot_ue_dl_set_cell(&ue_dl, cell)) { fprintf(stderr, "Setting cell in UE DL\n"); return -1; } - srslte_nbiot_ue_dl_set_mib(&ue_dl, mib_nb); + srsran_nbiot_ue_dl_set_mib(&ue_dl, mib_nb); /* Generate NPSS/NSSS signals */ - srslte_npss_generate(npss_signal); - srslte_nsss_generate(nsss_signal, cell.n_id_ncell); + srsran_npss_generate(npss_signal); + srsran_nsss_generate(nsss_signal, cell.n_id_ncell); #ifdef NPSS_DUMP - srslte_filesink_t debug_fsink; + srsran_filesink_t debug_fsink; char fname[] = "npss.bin"; - if (srslte_filesink_init(&debug_fsink, fname, SRSLTE_COMPLEX_FLOAT_BIN)) { + if (srsran_filesink_init(&debug_fsink, fname, SRSRAN_COMPLEX_FLOAT_BIN)) { fprintf(stderr, "Error opening file %s\n", fname); exit(-1); } - srslte_filesink_write(&debug_fsink, npss_signal, SRSLTE_NPSS_LEN * 11); - srslte_filesink_free(&debug_fsink); + srsran_filesink_write(&debug_fsink, npss_signal, SRSRAN_NPSS_LEN * 11); + srsran_filesink_free(&debug_fsink); #endif /* Generate CRS+NRS signals */ - if (srslte_chest_dl_nbiot_init(&ch_est, SRSLTE_NBIOT_MAX_PRB)) { + if (srsran_chest_dl_nbiot_init(&ch_est, SRSRAN_NBIOT_MAX_PRB)) { fprintf(stderr, "Error initializing equalizer\n"); exit(-1); } - if (srslte_chest_dl_nbiot_set_cell(&ch_est, cell) != SRSLTE_SUCCESS) { + if (srsran_chest_dl_nbiot_set_cell(&ch_est, cell) != SRSRAN_SUCCESS) { fprintf(stderr, "Error setting channel estimator's cell configuration\n"); return -1; } @@ -489,10 +489,10 @@ int main(int argc, char** argv) signal(SIGINT, sig_int_handler); if (!output_file_name) { - int srate = srslte_sampling_freq_hz(cell.base.nof_prb); + int srate = srsran_sampling_freq_hz(cell.base.nof_prb); if (srate != -1) { printf("Setting sampling rate %.2f MHz\n", (float)srate / 1000000); - float srate_rf = srslte_rf_set_tx_srate(&radio, (double)srate); + float srate_rf = srsran_rf_set_tx_srate(&radio, (double)srate); if (srate_rf != srate) { fprintf(stderr, "Could not set sampling rate\n"); exit(-1); @@ -501,9 +501,9 @@ int main(int argc, char** argv) fprintf(stderr, "Invalid number of PRB %d\n", cell.base.nof_prb); exit(-1); } - srslte_rf_set_tx_gain(&radio, rf_gain); - printf("Set TX gain: %.1f dB\n", srslte_rf_get_tx_gain(&radio)); - printf("Set TX freq: %.2f MHz\n", srslte_rf_set_tx_freq(&radio, 0, rf_freq) / 1000000); + srsran_rf_set_tx_gain(&radio, rf_gain); + printf("Set TX gain: %.1f dB\n", srsran_rf_get_tx_gain(&radio)); + printf("Set TX freq: %.2f MHz\n", srsran_rf_set_tx_freq(&radio, 0, rf_freq) / 1000000); } #endif @@ -512,7 +512,7 @@ int main(int argc, char** argv) } /* Initiate valid DCI locations */ - for (int i = 0; i < SRSLTE_NOF_SF_X_FRAME; i++) { + for (int i = 0; i < SRSRAN_NOF_SF_X_FRAME; i++) { locations[i][0].L = 1; // Agg-level 2, i.e. both NCEEs used locations[i][0].ncce = 0; } @@ -521,48 +521,48 @@ int main(int argc, char** argv) bool send_data = false; bool npdsch_active = false; - srslte_softbuffer_tx_reset(&softbuffer); - bzero(&sib1_npdsch_cfg, sizeof(srslte_npdsch_cfg_t)); - bzero(&npdsch_cfg, sizeof(srslte_npdsch_cfg_t)); + srsran_softbuffer_tx_reset(&softbuffer); + bzero(&sib1_npdsch_cfg, sizeof(srsran_npdsch_cfg_t)); + bzero(&npdsch_cfg, sizeof(srsran_npdsch_cfg_t)); #ifndef DISABLE_RF bool start_of_burst = true; #endif while ((nf < nof_frames || nof_frames == -1) && !go_exit) { - for (sf_idx = 0; sf_idx < SRSLTE_NOF_SF_X_FRAME && (nf < nof_frames || nof_frames == -1); sf_idx++) { - srslte_vec_cf_zero(sf_buffer, sf_n_re); + for (sf_idx = 0; sf_idx < SRSRAN_NOF_SF_X_FRAME && (nf < nof_frames || nof_frames == -1); sf_idx++) { + srsran_vec_cf_zero(sf_buffer, sf_n_re); // Transmit NPBCH in subframe 0 if (sf_idx == 0) { - if ((sfn % SRSLTE_NPBCH_NUM_FRAMES) == 0) { - srslte_npbch_mib_pack(hfn, sfn, mib_nb, bch_payload); + if ((sfn % SRSRAN_NPBCH_NUM_FRAMES) == 0) { + srsran_npbch_mib_pack(hfn, sfn, mib_nb, bch_payload); } - srslte_npbch_put_subframe(&npbch, bch_payload, sf_re_symbols, sfn); - if (SRSLTE_VERBOSE_ISDEBUG()) { + srsran_npbch_put_subframe(&npbch, bch_payload, sf_re_symbols, sfn); + if (SRSRAN_VERBOSE_ISDEBUG()) { printf("MIB payload: "); - srslte_vec_fprint_hex(stdout, bch_payload, SRSLTE_MIB_NB_LEN); + srsran_vec_fprint_hex(stdout, bch_payload, SRSRAN_MIB_NB_LEN); } } // Transmit NPSS, NSSS and NRS if (sf_idx == 5) { // NPSS at subframe 5 - srslte_npss_put_subframe(&npss_sync, npss_signal, sf_buffer, cell.base.nof_prb, cell.nbiot_prb); + srsran_npss_put_subframe(&npss_sync, npss_signal, sf_buffer, cell.base.nof_prb, cell.nbiot_prb); } else if ((sfn % 2 == 0) && sf_idx == 9) { // NSSS in every even numbered frame at subframe 9 - srslte_nsss_put_subframe(&nsss_sync, nsss_signal, sf_buffer, sfn, cell.base.nof_prb, cell.nbiot_prb); + srsran_nsss_put_subframe(&nsss_sync, nsss_signal, sf_buffer, sfn, cell.base.nof_prb, cell.nbiot_prb); } else { // NRS in all other subframes (using CSR signal intentionally) - // DEBUG("%d.%d: Putting %d NRS pilots", sfn, sf_idx, SRSLTE_REFSIGNAL_NUM_SF(1, cell.nof_ports)); - srslte_refsignal_nrs_put_sf(cell, 0, ch_est.nrs_signal.pilots[0][sf_idx], sf_buffer); + // DEBUG("%d.%d: Putting %d NRS pilots", sfn, sf_idx, SRSRAN_REFSIGNAL_NUM_SF(1, cell.nof_ports)); + srsran_refsignal_nrs_put_sf(cell, 0, ch_est.nrs_signal.pilots[0][sf_idx], sf_buffer); } #if HAVE_NPDSCH // only transmit in subframes not used for NPBCH, NPSS or NSSS and only use subframe 4 when there is no SIB1 // transmission if (sf_idx != 0 && sf_idx != 5 && (!(sf_idx == 9 && sfn % 2 == 0)) && - !srslte_nbiot_ue_dl_is_sib1_sf(&ue_dl, sfn, sf_idx)) { + !srsran_nbiot_ue_dl_is_sib1_sf(&ue_dl, sfn, sf_idx)) { send_data = true; } else { send_data = false; @@ -575,43 +575,43 @@ int main(int argc, char** argv) // overwrite Hyper Frame Number (HFN), 8 MSB uint8_t unpacked_hfn[4 * 8]; - srslte_bit_unpack_vector(sib1_nb_payload, unpacked_hfn, 4 * 8); + srsran_bit_unpack_vector(sib1_nb_payload, unpacked_hfn, 4 * 8); uint8_t* tmp = unpacked_hfn; tmp += 12; - srslte_bit_unpack(hfn >> 2, &tmp, 8); + srsran_bit_unpack(hfn >> 2, &tmp, 8); uint8_t packed_hfn[4]; - srslte_bit_pack_vector(unpacked_hfn, packed_hfn, 32); + srsran_bit_pack_vector(unpacked_hfn, packed_hfn, 32); memcpy(sib1_nb_payload, packed_hfn, sizeof(packed_hfn)); - if (SRSLTE_VERBOSE_ISDEBUG()) { + if (SRSRAN_VERBOSE_ISDEBUG()) { printf("SIB1-NB payload: "); - srslte_vec_fprint_byte(stdout, sib1_nb_payload, sizeof(dummy_sib1_payload)); + srsran_vec_fprint_byte(stdout, sib1_nb_payload, sizeof(dummy_sib1_payload)); } } - if (srslte_nbiot_ue_dl_is_sib1_sf(&ue_dl, sfn, sf_idx)) { + if (srsran_nbiot_ue_dl_is_sib1_sf(&ue_dl, sfn, sf_idx)) { INFO("%d.%d: Transmitting SIB1-NB.", sfn, sf_idx); assert(send_data == false); // configure DL grant for SIB1-NB transmission if (sib1_npdsch_cfg.sf_idx == 0) { - srslte_ra_nbiot_dl_grant_t grant; - srslte_ra_nbiot_dl_dci_to_grant(&ra_dl_sib1, &grant, sfn, sf_idx, DUMMY_R_MAX, true, cell.mode); - if (srslte_npdsch_cfg(&sib1_npdsch_cfg, cell, &grant, sf_idx)) { + srsran_ra_nbiot_dl_grant_t grant; + srsran_ra_nbiot_dl_dci_to_grant(&ra_dl_sib1, &grant, sfn, sf_idx, DUMMY_R_MAX, true, cell.mode); + if (srsran_npdsch_cfg(&sib1_npdsch_cfg, cell, &grant, sf_idx)) { fprintf(stderr, "Error configuring NPDSCH\n"); exit(-1); } } // Encode SIB1 content - if (srslte_npdsch_encode_rnti( - &npdsch, &sib1_npdsch_cfg, &softbuffer, sib1_nb_payload, SRSLTE_SIRNTI, sf_re_symbols)) { + if (srsran_npdsch_encode_rnti( + &npdsch, &sib1_npdsch_cfg, &softbuffer, sib1_nb_payload, SRSRAN_SIRNTI, sf_re_symbols)) { fprintf(stderr, "Error encoding NPDSCH\n"); exit(-1); } if (sib1_npdsch_cfg.sf_idx == sib1_npdsch_cfg.grant.nof_sf) { - bzero(&sib1_npdsch_cfg, sizeof(srslte_npdsch_cfg_t)); + bzero(&sib1_npdsch_cfg, sizeof(srsran_npdsch_cfg_t)); } } @@ -625,16 +625,16 @@ int main(int argc, char** argv) if (sf_idx == NPDCCH_SF_IDX && !npdsch_active) { // Encode NPDCCH INFO("Putting DCI to location: n=%d, L=%d", locations[sf_idx][0].ncce, locations[sf_idx][0].L); - srslte_dci_msg_pack_npdsch(&ra_dl, SRSLTE_DCI_FORMATN1, &dci_msg, false); - if (srslte_npdcch_encode(&npdcch, &dci_msg, locations[sf_idx][0], UE_CRNTI, sf_re_symbols, sf_idx)) { + srsran_dci_msg_pack_npdsch(&ra_dl, SRSRAN_DCI_FORMATN1, &dci_msg, false); + if (srsran_npdcch_encode(&npdcch, &dci_msg, locations[sf_idx][0], UE_CRNTI, sf_re_symbols, sf_idx)) { fprintf(stderr, "Error encoding DCI message\n"); exit(-1); } // Configure NPDSCH accordingly - srslte_ra_nbiot_dl_grant_t grant; - srslte_ra_nbiot_dl_dci_to_grant(&ra_dl, &grant, sfn, sf_idx, DUMMY_R_MAX, false, cell.mode); - if (srslte_npdsch_cfg(&npdsch_cfg, cell, &grant, sf_idx)) { + srsran_ra_nbiot_dl_grant_t grant; + srsran_ra_nbiot_dl_dci_to_grant(&ra_dl, &grant, sfn, sf_idx, DUMMY_R_MAX, false, cell.mode); + if (srsran_npdsch_cfg(&npdsch_cfg, cell, &grant, sf_idx)) { fprintf(stderr, "Error configuring NPDSCH\n"); exit(-1); } @@ -645,11 +645,11 @@ int main(int argc, char** argv) // generate data only in first sf INFO("%d.%d: Generating %d random bits", sfn, sf_idx, npdsch_cfg.grant.mcs[0].tbs); for (int i = 0; i < npdsch_cfg.grant.mcs[0].tbs / 8; i++) { - data[i] = srslte_random_uniform_int_dist(random_gen, 0, 255); + data[i] = srsran_random_uniform_int_dist(random_gen, 0, 255); } - if (SRSLTE_VERBOSE_ISDEBUG()) { + if (SRSRAN_VERBOSE_ISDEBUG()) { printf("Tx payload: "); - srslte_vec_fprint_b(stdout, data, npdsch_cfg.grant.mcs[0].tbs / 8); + srsran_vec_fprint_b(stdout, data, npdsch_cfg.grant.mcs[0].tbs / 8); } npdsch_active = true; } @@ -661,7 +661,7 @@ int main(int argc, char** argv) npdsch_cfg.grant.start_sfidx, npdsch_cfg.grant.nof_sf); // Encode NPDSCH - if (srslte_npdsch_encode(&npdsch, &npdsch_cfg, &softbuffer, data, sf_re_symbols)) { + if (srsran_npdsch_encode(&npdsch, &npdsch_cfg, &softbuffer, data, sf_re_symbols)) { fprintf(stderr, "Error encoding NPDSCH\n"); exit(-1); } @@ -674,32 +674,32 @@ int main(int argc, char** argv) #endif /* Transform to OFDM symbols */ - srslte_ofdm_tx_sf(&ifft); + srsran_ofdm_tx_sf(&ifft); if (output_file_name && file_snr != -100.0) { // compute average energy per symbol - float abs_avg = srslte_vec_avg_power_cf(output_buffer, sf_n_samples); + float abs_avg = srsran_vec_avg_power_cf(output_buffer, sf_n_samples); // find the noise spectral density - float snr_lin = srslte_convert_dB_to_power(file_snr); + float snr_lin = srsran_convert_dB_to_power(file_snr); float n0 = abs_avg / snr_lin; float nstd = sqrtf(n0 / 2); // add some noise to the signal - srslte_ch_awgn_c(output_buffer, output_buffer, nstd, sf_n_samples); + srsran_ch_awgn_c(output_buffer, output_buffer, nstd, sf_n_samples); } /* send to file or usrp */ if (output_file_name) { // write to file if (!null_file_sink) { - srslte_filesink_write(&fsink, output_buffer, sf_n_samples); + srsran_filesink_write(&fsink, output_buffer, sf_n_samples); } usleep(1000); } else { #ifndef DISABLE_RF // TODO: output scaling needed? - srslte_rf_send2(&radio, output_buffer, sf_n_samples, true, start_of_burst, false); + srsran_rf_send2(&radio, output_buffer, sf_n_samples, true, start_of_burst, false); start_of_burst = false; #endif } @@ -717,5 +717,5 @@ int main(int argc, char** argv) printf("Done\n"); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } diff --git a/lib/examples/npdsch_ue.c b/lib/examples/npdsch_ue.c index 5db732483..1a08e7b26 100644 --- a/lib/examples/npdsch_ue.c +++ b/lib/examples/npdsch_ue.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -23,31 +23,31 @@ #include #include "npdsch_ue_helper.h" -#include "srslte/phy/ch_estimation/chest_dl_nbiot.h" -#include "srslte/phy/channel/ch_awgn.h" -#include "srslte/phy/io/filesink.h" -#include "srslte/phy/io/filesource.h" -#include "srslte/phy/ue/ue_dl_nbiot.h" -#include "srslte/phy/ue/ue_mib_nbiot.h" -#include "srslte/phy/ue/ue_sync_nbiot.h" -#include "srslte/phy/utils/bit.h" +#include "srsran/phy/ch_estimation/chest_dl_nbiot.h" +#include "srsran/phy/channel/ch_awgn.h" +#include "srsran/phy/io/filesink.h" +#include "srsran/phy/io/filesource.h" +#include "srsran/phy/ue/ue_dl_nbiot.h" +#include "srsran/phy/ue/ue_mib_nbiot.h" +#include "srsran/phy/ue/ue_sync_nbiot.h" +#include "srsran/phy/utils/bit.h" #undef ENABLE_AGC_DEFAULT #ifndef DISABLE_RF -#include "srslte/phy/rf/rf.h" -#include "srslte/phy/rf/rf_utils.h" +#include "srsran/phy/rf/rf.h" +#include "srsran/phy/rf/rf_utils.h" #define ENABLE_MANUAL_NSSS_SEARCH 0 #define HAVE_PCAP 1 #if HAVE_PCAP -#include "srslte/common/pcap.h" +#include "srsran/common/pcap.h" #endif -cell_search_cfg_t cell_detect_config = {.max_frames_pbch = SRSLTE_DEFAULT_MAX_FRAMES_NPBCH, - .max_frames_pss = SRSLTE_DEFAULT_MAX_FRAMES_NPSS, - .nof_valid_pss_frames = SRSLTE_DEFAULT_NOF_VALID_NPSS_FRAMES, +cell_search_cfg_t cell_detect_config = {.max_frames_pbch = SRSRAN_DEFAULT_MAX_FRAMES_NPBCH, + .max_frames_pss = SRSRAN_DEFAULT_MAX_FRAMES_NPSS, + .nof_valid_pss_frames = SRSRAN_DEFAULT_NOF_VALID_NPSS_FRAMES, .init_agc = 0, .force_tdd = false}; @@ -69,7 +69,7 @@ bool plot_track = true; #define NPSS_FIND_PLOT_WIDTH 80 //#define CORRECT_SAMPLE_OFFSET -static srslte_nbiot_si_params_t sib2_params; +static srsran_nbiot_si_params_t sib2_params; /********************************************************************** * Program arguments processing @@ -101,8 +101,8 @@ void args_default(prog_args_t* args) args->disable_plots = false; args->disable_plots_except_constellation = false; args->nof_subframes = -1; - args->rnti = SRSLTE_SIRNTI; - args->n_id_ncell = SRSLTE_CELL_ID_UNKNOWN; + args->rnti = SRSRAN_SIRNTI; + args->n_id_ncell = SRSRAN_CELL_ID_UNKNOWN; args->is_r14 = true; args->input_file_name = NULL; args->disable_cfo = false; @@ -155,7 +155,7 @@ void usage(prog_args_t* args, char* prog) printf("\t plots are disabled. Graphics library not available\n"); #endif // ENABLE_GUI printf("\t-n nof_subframes [Default %d]\n", args->nof_subframes); - printf("\t-v [set srslte_verbose to debug, default none]\n"); + printf("\t-v [set srsran_verbose to debug, default none]\n"); } void parse_args(prog_args_t* args, int argc, char** argv) @@ -219,7 +219,7 @@ void parse_args(prog_args_t* args, int argc, char** argv) args->disable_plots_except_constellation = true; break; case 'v': - srslte_verbose++; + srsran_verbose++; break; default: usage(args, argv[0]); @@ -233,7 +233,7 @@ void parse_args(prog_args_t* args, int argc, char** argv) } /**********************************************************************/ -static uint8_t rx_tb[SRSLTE_MAX_DL_BITS_CAT_NB1]; // Byte buffer for rx'ed transport blocks +static uint8_t rx_tb[SRSRAN_MAX_DL_BITS_CAT_NB1]; // Byte buffer for rx'ed transport blocks bool go_exit = false; void sig_int_handler(int signo) @@ -262,8 +262,8 @@ void pcap_pack_and_write(FILE* pcap_file, .ueid = 1, .isRetx = reTX, .crcStatusOK = crc_ok, - .sysFrameNumber = (uint16_t)(tti / SRSLTE_NOF_SF_X_FRAME), - .subFrameNumber = (uint16_t)(tti % SRSLTE_NOF_SF_X_FRAME), + .sysFrameNumber = (uint16_t)(tti / SRSRAN_NOF_SF_X_FRAME), + .subFrameNumber = (uint16_t)(tti % SRSRAN_NOF_SF_X_FRAME), .nbiotMode = 1}; if (pdu) { LTE_PCAP_MAC_WritePDU(pcap_file, &context, pdu, pdu_len_bytes); @@ -272,25 +272,25 @@ void pcap_pack_and_write(FILE* pcap_file, #endif #ifndef DISABLE_RF -int srslte_rf_recv_wrapper(void* h, void* data, uint32_t nsamples, srslte_timestamp_t* t) +int srsran_rf_recv_wrapper(void* h, void* data, uint32_t nsamples, srsran_timestamp_t* t) { DEBUG(" ---- Receive %d samples ----", nsamples); - return srslte_rf_recv_with_time(h, data, nsamples, true, &t->full_secs, &t->frac_secs); + return srsran_rf_recv_with_time(h, data, nsamples, true, &t->full_secs, &t->frac_secs); } -void srslte_rf_set_rx_gain_th_wrapper_(void* h, float f) +void srsran_rf_set_rx_gain_th_wrapper_(void* h, float f) { - srslte_rf_set_rx_gain_th((srslte_rf_t*)h, f); + srsran_rf_set_rx_gain_th((srsran_rf_t*)h, f); } #endif enum receiver_state { DECODE_MIB, DECODE_SIB, DECODE_NPDSCH } state; -static srslte_nbiot_cell_t cell = {}; +static srsran_nbiot_cell_t cell = {}; -srslte_nbiot_ue_dl_t ue_dl; -srslte_nbiot_ue_sync_t ue_sync; +srsran_nbiot_ue_dl_t ue_dl; +srsran_nbiot_ue_sync_t ue_sync; prog_args_t prog_args; bool have_sib1 = false; @@ -317,13 +317,13 @@ int main(int argc, char** argv) { int ret; int64_t sf_cnt; - srslte_ue_mib_nbiot_t ue_mib; + srsran_ue_mib_nbiot_t ue_mib; #ifndef DISABLE_RF - srslte_rf_t rf; + srsran_rf_t rf; #endif uint32_t nof_trials = 0; int n; - uint8_t bch_payload[SRSLTE_MIB_NB_LEN] = {}; + uint8_t bch_payload[SRSRAN_MIB_NB_LEN] = {}; int sfn_offset; float cfo = 0; @@ -339,40 +339,40 @@ int main(int argc, char** argv) sigprocmask(SIG_UNBLOCK, &sigset, NULL); signal(SIGINT, sig_int_handler); - cell.base.nof_prb = SRSLTE_NBIOT_DEFAULT_NUM_PRB_BASECELL; - cell.nbiot_prb = SRSLTE_NBIOT_DEFAULT_PRB_OFFSET; + cell.base.nof_prb = SRSRAN_NBIOT_DEFAULT_NUM_PRB_BASECELL; + cell.nbiot_prb = SRSRAN_NBIOT_DEFAULT_PRB_OFFSET; cell.n_id_ncell = prog_args.n_id_ncell; cell.is_r14 = prog_args.is_r14; #ifndef DISABLE_RF if (!prog_args.input_file_name) { printf("Opening RF device...\n"); - if (srslte_rf_open_devname(&rf, prog_args.rf_dev, prog_args.rf_args, 1)) { + if (srsran_rf_open_devname(&rf, prog_args.rf_dev, prog_args.rf_args, 1)) { fprintf(stderr, "Error opening rf\n"); exit(-1); } /* Set receiver gain */ if (prog_args.rf_gain > 0) { - srslte_rf_set_rx_gain(&rf, prog_args.rf_gain); + srsran_rf_set_rx_gain(&rf, prog_args.rf_gain); printf("Set RX gain: %.1f dB\n", prog_args.rf_gain); } else { printf("Starting AGC thread...\n"); - if (srslte_rf_start_gain_thread(&rf, false)) { + if (srsran_rf_start_gain_thread(&rf, false)) { fprintf(stderr, "Error opening rf\n"); exit(-1); } - srslte_rf_set_rx_gain(&rf, 50); + srsran_rf_set_rx_gain(&rf, 50); cell_detect_config.init_agc = 50; } // set transceiver frequency - printf("Set RX freq: %.6f MHz\n", srslte_rf_set_rx_freq(&rf, 0, prog_args.rf_freq) / 1000000); + printf("Set RX freq: %.6f MHz\n", srsran_rf_set_rx_freq(&rf, 0, prog_args.rf_freq) / 1000000); // set sampling frequency - int srate = srslte_sampling_freq_hz(cell.base.nof_prb); + int srate = srsran_sampling_freq_hz(cell.base.nof_prb); if (srate != -1) { printf("Setting sampling rate %.2f MHz\n", (float)srate / 1e6); - double srate_rf = srslte_rf_set_rx_srate(&rf, srate); + double srate_rf = srsran_rf_set_rx_srate(&rf, srate); printf("Actual sampling rate %.2f MHz\n", srate_rf / 1e6); // We don't check the result rate with requested rate } else { @@ -381,55 +381,55 @@ int main(int argc, char** argv) } INFO("Stopping RF and flushing buffer...\r"); - srslte_rf_stop_rx_stream(&rf); + srsran_rf_stop_rx_stream(&rf); #if ENABLE_MANUAL_NSSS_SEARCH // determine n_id_ncell - if (prog_args.n_id_ncell == SRSLTE_CELL_ID_UNKNOWN) { - srslte_nsss_synch_t nsss; + if (prog_args.n_id_ncell == SRSRAN_CELL_ID_UNKNOWN) { + srsran_nsss_synch_t nsss; float nsss_peak_value; int input_len = srate * 10 / 1000 * 2; // capture two full frames to make sure we have one NSSS - cf_t* buffer = srslte_vec_cf_malloc(input_len * 2); + cf_t* buffer = srsran_vec_cf_malloc(input_len * 2); if (!buffer) { perror("malloc"); exit(-1); } - if (srslte_nsss_synch_init(&nsss, input_len, srate / 15000)) { + if (srsran_nsss_synch_init(&nsss, input_len, srate / 15000)) { fprintf(stderr, "Error initializing NSSS object\n"); exit(-1); } - srslte_rf_start_rx_stream(&rf, false); - n = srslte_rf_recv(&rf, buffer, input_len, 1); + srsran_rf_start_rx_stream(&rf, false); + n = srsran_rf_recv(&rf, buffer, input_len, 1); if (n != input_len) { fprintf(stderr, "Error receiving samples\n"); exit(-1); } - srslte_rf_stop_rx_stream(&rf); + srsran_rf_stop_rx_stream(&rf); // trying to find NSSS printf("Detecting NSSS signal .. "); fflush(stdout); uint32_t sfn_partial; - srslte_nsss_sync_find(&nsss, buffer, &nsss_peak_value, (uint32_t*)&cell.n_id_ncell, &sfn_partial); + srsran_nsss_sync_find(&nsss, buffer, &nsss_peak_value, (uint32_t*)&cell.n_id_ncell, &sfn_partial); printf("done!"); - srslte_nsss_synch_free(&nsss); + srsran_nsss_synch_free(&nsss); free(buffer); } else { cell.n_id_ncell = prog_args.n_id_ncell; } printf("\nSetting n_id_ncell to %d.\n", cell.n_id_ncell); #else - if (cell.n_id_ncell == SRSLTE_CELL_ID_UNKNOWN) { + if (cell.n_id_ncell == SRSRAN_CELL_ID_UNKNOWN) { uint32_t ntrial = 0; do { ret = rf_cell_search_nbiot(&rf, &cell_detect_config, &cell, &cfo); - if (ret != SRSLTE_SUCCESS) { + if (ret != SRSRAN_SUCCESS) { printf("Cell not found after %d trials. Trying again (Press Ctrl+C to exit)\n", ntrial++); } - } while (ret != SRSLTE_SUCCESS && !go_exit); + } while (ret != SRSRAN_SUCCESS && !go_exit); } #endif @@ -445,31 +445,31 @@ int main(int argc, char** argv) cell.base.nof_ports = prog_args.file_nof_ports; cell.nof_ports = prog_args.file_nof_ports; - if (srslte_ue_sync_nbiot_init_file( + if (srsran_ue_sync_nbiot_init_file( &ue_sync, cell, prog_args.input_file_name, prog_args.file_offset_time, prog_args.file_offset_freq)) { fprintf(stderr, "Error initiating ue_sync\n"); exit(-1); } } else { #ifndef DISABLE_RF - if (srslte_ue_sync_nbiot_init(&ue_sync, cell, srslte_rf_recv_wrapper, (void*)&rf)) { + if (srsran_ue_sync_nbiot_init(&ue_sync, cell, srsran_rf_recv_wrapper, (void*)&rf)) { fprintf(stderr, "Error initiating ue_sync\n"); exit(-1); } // reduce AGC period to every 10th frame - srslte_ue_sync_nbiot_set_agc_period(&ue_sync, 10); + srsran_ue_sync_nbiot_set_agc_period(&ue_sync, 10); #endif } // Allocate memory to fit a full frame (needed for time re-alignment) - cf_t* buff_ptrs[SRSLTE_MAX_PORTS] = {NULL}; - buff_ptrs[0] = srslte_vec_cf_malloc(SRSLTE_SF_LEN_PRB_NBIOT * 10); + cf_t* buff_ptrs[SRSRAN_MAX_PORTS] = {NULL}; + buff_ptrs[0] = srsran_vec_cf_malloc(SRSRAN_SF_LEN_PRB_NBIOT * 10); - if (srslte_ue_mib_nbiot_init(&ue_mib, buff_ptrs, SRSLTE_NBIOT_MAX_PRB)) { + if (srsran_ue_mib_nbiot_init(&ue_mib, buff_ptrs, SRSRAN_NBIOT_MAX_PRB)) { fprintf(stderr, "Error initaiting UE MIB decoder\n"); exit(-1); } - if (srslte_ue_mib_nbiot_set_cell(&ue_mib, cell) != SRSLTE_SUCCESS) { + if (srsran_ue_mib_nbiot_set_cell(&ue_mib, cell) != SRSRAN_SUCCESS) { fprintf(stderr, "Error setting cell configuration in UE MIB decoder\n"); exit(-1); } @@ -485,7 +485,7 @@ int main(int argc, char** argv) #ifndef DISABLE_RF if (!prog_args.input_file_name) { - srslte_rf_start_rx_stream(&rf, false); + srsran_rf_start_rx_stream(&rf, false); } #endif @@ -495,48 +495,48 @@ int main(int argc, char** argv) #ifndef DISABLE_RF if (prog_args.rf_gain < 0) { - srslte_ue_sync_nbiot_start_agc(&ue_sync, srslte_rf_set_rx_gain_th_wrapper_, cell_detect_config.init_agc); + srsran_ue_sync_nbiot_start_agc(&ue_sync, srsran_rf_set_rx_gain_th_wrapper_, cell_detect_config.init_agc); } #endif #ifdef PRINT_CHANGE_SCHEDULIGN - srslte_ra_nbiot_dl_dci_t old_dl_dci; - bzero(&old_dl_dci, sizeof(srslte_ra_nbiot_dl_dci_t)); + srsran_ra_nbiot_dl_dci_t old_dl_dci; + bzero(&old_dl_dci, sizeof(srsran_ra_nbiot_dl_dci_t)); #endif ue_sync.correct_cfo = !prog_args.disable_cfo; // Set initial CFO for ue_sync - srslte_ue_sync_nbiot_set_cfo(&ue_sync, cfo); + srsran_ue_sync_nbiot_set_cfo(&ue_sync, cfo); - srslte_npbch_decode_reset(&ue_mib.npbch); + srsran_npbch_decode_reset(&ue_mib.npbch); INFO("\nEntering main loop..."); while (!go_exit && (sf_cnt < prog_args.nof_subframes || prog_args.nof_subframes == -1)) { - ret = srslte_ue_sync_nbiot_zerocopy_multi(&ue_sync, buff_ptrs); + ret = srsran_ue_sync_nbiot_zerocopy_multi(&ue_sync, buff_ptrs); if (ret < 0) { - fprintf(stderr, "Error calling srslte_nbiot_ue_sync_zerocopy_multi()\n"); + fprintf(stderr, "Error calling srsran_nbiot_ue_sync_zerocopy_multi()\n"); break; } #ifdef CORRECT_SAMPLE_OFFSET float sample_offset = - (float)srslte_ue_sync_get_last_sample_offset(&ue_sync) + srslte_ue_sync_get_sfo(&ue_sync) / 1000; - srslte_ue_dl_set_sample_offset(&ue_dl, sample_offset); + (float)srsran_ue_sync_get_last_sample_offset(&ue_sync) + srsran_ue_sync_get_sfo(&ue_sync) / 1000; + srsran_ue_dl_set_sample_offset(&ue_dl, sample_offset); #endif - // srslte_ue_sync_nbiot_zerocopy_multi() returns 1 if successfully read 1 aligned subframe + // srsran_ue_sync_nbiot_zerocopy_multi() returns 1 if successfully read 1 aligned subframe if (ret == 1) { switch (state) { case DECODE_MIB: - if (srslte_ue_sync_nbiot_get_sfidx(&ue_sync) == 0) { - n = srslte_ue_mib_nbiot_decode(&ue_mib, buff_ptrs[0], bch_payload, &cell.nof_ports, &sfn_offset); + if (srsran_ue_sync_nbiot_get_sfidx(&ue_sync) == 0) { + n = srsran_ue_mib_nbiot_decode(&ue_mib, buff_ptrs[0], bch_payload, &cell.nof_ports, &sfn_offset); if (n < 0) { fprintf(stderr, "Error decoding UE MIB\n"); exit(-1); - } else if (n == SRSLTE_UE_MIB_NBIOT_FOUND) { - printf("MIB received (CFO: %+6.2f kHz)\n", srslte_ue_sync_nbiot_get_cfo(&ue_sync) / 1000); - srslte_mib_nb_t mib; - srslte_npbch_mib_unpack(bch_payload, &mib); + } else if (n == SRSRAN_UE_MIB_NBIOT_FOUND) { + printf("MIB received (CFO: %+6.2f kHz)\n", srsran_ue_sync_nbiot_get_cfo(&ue_sync) / 1000); + srsran_mib_nb_t mib; + srsran_npbch_mib_unpack(bch_payload, &mib); // update SFN and set deployment mode system_frame_number = (mib.sfn + sfn_offset) % 1024; @@ -545,34 +545,34 @@ int main(int argc, char** argv) // set number of ports of base cell to that of NB-IoT cell (FIXME: read eutra-NumCRS-Ports-r13) cell.base.nof_ports = cell.nof_ports; - if (cell.mode == SRSLTE_NBIOT_MODE_INBAND_SAME_PCI) { + if (cell.mode == SRSRAN_NBIOT_MODE_INBAND_SAME_PCI) { cell.base.id = cell.n_id_ncell; } - if (SRSLTE_VERBOSE_ISINFO()) { - srslte_mib_nb_printf(stdout, cell, &mib); + if (SRSRAN_VERBOSE_ISINFO()) { + srsran_mib_nb_printf(stdout, cell, &mib); } // Initialize DL - if (srslte_nbiot_ue_dl_init(&ue_dl, buff_ptrs, SRSLTE_NBIOT_MAX_PRB, SRSLTE_NBIOT_NUM_RX_ANTENNAS)) { + if (srsran_nbiot_ue_dl_init(&ue_dl, buff_ptrs, SRSRAN_NBIOT_MAX_PRB, SRSRAN_NBIOT_NUM_RX_ANTENNAS)) { fprintf(stderr, "Error initiating UE downlink processing module\n"); exit(-1); } - if (srslte_nbiot_ue_dl_set_cell(&ue_dl, cell)) { + if (srsran_nbiot_ue_dl_set_cell(&ue_dl, cell)) { fprintf(stderr, "Configuring cell in UE DL\n"); exit(-1); } // Configure downlink receiver with the MIB params and the RNTI we use - srslte_nbiot_ue_dl_set_mib(&ue_dl, mib); - srslte_nbiot_ue_dl_set_rnti(&ue_dl, prog_args.rnti); + srsran_nbiot_ue_dl_set_mib(&ue_dl, mib); + srsran_nbiot_ue_dl_set_rnti(&ue_dl, prog_args.rnti); // Pretty-print MIB - srslte_bit_pack_vector(bch_payload, rx_tb, SRSLTE_MIB_NB_CRC_LEN); + srsran_bit_pack_vector(bch_payload, rx_tb, SRSRAN_MIB_NB_CRC_LEN); #ifdef ENABLE_GUI if (bcch_bch_to_pretty_string( - rx_tb, SRSLTE_MIB_NB_CRC_LEN, mib_buffer_decode, sizeof(mib_buffer_decode))) { + rx_tb, SRSRAN_MIB_NB_CRC_LEN, mib_buffer_decode, sizeof(mib_buffer_decode))) { fprintf(stderr, "Error decoding MIB\n"); } #endif @@ -581,16 +581,16 @@ int main(int argc, char** argv) // write to PCAP pcap_pack_and_write(pcap_file, rx_tb, - SRSLTE_MIB_NB_CRC_LEN, + SRSRAN_MIB_NB_CRC_LEN, 0, true, - system_frame_number * SRSLTE_NOF_SF_X_FRAME, + system_frame_number * SRSRAN_NOF_SF_X_FRAME, 0, DIRECTION_DOWNLINK, NO_RNTI); #endif // activate SIB1 decoding - srslte_nbiot_ue_dl_decode_sib1(&ue_dl, system_frame_number); + srsran_nbiot_ue_dl_decode_sib1(&ue_dl, system_frame_number); state = DECODE_SIB; } } @@ -598,16 +598,16 @@ int main(int argc, char** argv) case DECODE_SIB: if (!have_sib1) { - int dec_ret = srslte_nbiot_ue_dl_decode_npdsch(&ue_dl, + int dec_ret = srsran_nbiot_ue_dl_decode_npdsch(&ue_dl, &buff_ptrs[0][prog_args.time_offset], rx_tb, system_frame_number, - srslte_ue_sync_nbiot_get_sfidx(&ue_sync), - SRSLTE_SIRNTI); - if (dec_ret == SRSLTE_SUCCESS) { + srsran_ue_sync_nbiot_get_sfidx(&ue_sync), + SRSRAN_SIRNTI); + if (dec_ret == SRSRAN_SUCCESS) { printf("SIB1 received\n"); - srslte_sys_info_block_type_1_nb_t sib = {}; - srslte_npdsch_sib1_unpack(rx_tb, &sib); + srsran_sys_info_block_type_1_nb_t sib = {}; + srsran_npdsch_sib1_unpack(rx_tb, &sib); hyper_frame_number = sib.hyper_sfn; have_sib1 = true; @@ -623,37 +623,37 @@ int main(int argc, char** argv) get_sib2_params(rx_tb, ue_dl.npdsch_cfg.grant.mcs[0].tbs / 8, &sib2_params); // Activate SIB2 decoding - srslte_nbiot_ue_dl_decode_sib( - &ue_dl, hyper_frame_number, system_frame_number, SRSLTE_NBIOT_SI_TYPE_SIB2, sib2_params); + srsran_nbiot_ue_dl_decode_sib( + &ue_dl, hyper_frame_number, system_frame_number, SRSRAN_NBIOT_SI_TYPE_SIB2, sib2_params); #if HAVE_PCAP pcap_pack_and_write(pcap_file, rx_tb, ue_dl.npdsch_cfg.grant.mcs[0].tbs / 8, 0, true, - system_frame_number * 10 + srslte_ue_sync_nbiot_get_sfidx(&ue_sync), - SRSLTE_SIRNTI, + system_frame_number * 10 + srsran_ue_sync_nbiot_get_sfidx(&ue_sync), + SRSRAN_SIRNTI, DIRECTION_DOWNLINK, SI_RNTI); #endif // if SIB1 was decoded in this subframe, skip processing it further break; - } else if (dec_ret == SRSLTE_ERROR) { + } else if (dec_ret == SRSRAN_ERROR) { // reactivate SIB1 grant - if (srslte_nbiot_ue_dl_has_grant(&ue_dl) == false) { - srslte_nbiot_ue_dl_decode_sib1(&ue_dl, system_frame_number); + if (srsran_nbiot_ue_dl_has_grant(&ue_dl) == false) { + srsran_nbiot_ue_dl_decode_sib1(&ue_dl, system_frame_number); } } - } else if (!have_sib2 && !srslte_nbiot_ue_dl_is_sib1_sf( - &ue_dl, system_frame_number, srslte_ue_sync_nbiot_get_sfidx(&ue_sync))) { + } else if (!have_sib2 && !srsran_nbiot_ue_dl_is_sib1_sf( + &ue_dl, system_frame_number, srsran_ue_sync_nbiot_get_sfidx(&ue_sync))) { // SIB2 is transmitted over multiple subframes, so this needs to be called more than once .. - int dec_ret = srslte_nbiot_ue_dl_decode_npdsch(&ue_dl, + int dec_ret = srsran_nbiot_ue_dl_decode_npdsch(&ue_dl, &buff_ptrs[0][prog_args.time_offset], rx_tb, system_frame_number, - srslte_ue_sync_nbiot_get_sfidx(&ue_sync), - SRSLTE_SIRNTI); - if (dec_ret == SRSLTE_SUCCESS) { + srsran_ue_sync_nbiot_get_sfidx(&ue_sync), + SRSRAN_SIRNTI); + if (dec_ret == SRSRAN_SUCCESS) { printf("SIB2 received\n"); have_sib2 = true; @@ -670,80 +670,80 @@ int main(int argc, char** argv) ue_dl.npdsch_cfg.grant.mcs[0].tbs / 8, 0, true, - system_frame_number * 10 + srslte_ue_sync_nbiot_get_sfidx(&ue_sync), - SRSLTE_SIRNTI, + system_frame_number * 10 + srsran_ue_sync_nbiot_get_sfidx(&ue_sync), + SRSRAN_SIRNTI, DIRECTION_DOWNLINK, SI_RNTI); #endif } else { // reactivate SIB2 grant - if (srslte_nbiot_ue_dl_has_grant(&ue_dl) == false) { - srslte_nbiot_ue_dl_decode_sib( - &ue_dl, hyper_frame_number, system_frame_number, SRSLTE_NBIOT_SI_TYPE_SIB2, sib2_params); + if (srsran_nbiot_ue_dl_has_grant(&ue_dl) == false) { + srsran_nbiot_ue_dl_decode_sib( + &ue_dl, hyper_frame_number, system_frame_number, SRSRAN_NBIOT_SI_TYPE_SIB2, sib2_params); } } } if (have_sib1 && (have_sib2 || prog_args.skip_sib2)) { - if (prog_args.rnti == SRSLTE_SIRNTI) { - srslte_nbiot_ue_dl_decode_sib1(&ue_dl, system_frame_number); + if (prog_args.rnti == SRSRAN_SIRNTI) { + srsran_nbiot_ue_dl_decode_sib1(&ue_dl, system_frame_number); } state = DECODE_NPDSCH; } break; case DECODE_NPDSCH: - if (prog_args.rnti != SRSLTE_SIRNTI) { - if (srslte_nbiot_ue_dl_has_grant(&ue_dl)) { + if (prog_args.rnti != SRSRAN_SIRNTI) { + if (srsran_nbiot_ue_dl_has_grant(&ue_dl)) { // attempt to decode NPDSCH - n = srslte_nbiot_ue_dl_decode_npdsch(&ue_dl, + n = srsran_nbiot_ue_dl_decode_npdsch(&ue_dl, &buff_ptrs[0][prog_args.time_offset], rx_tb, system_frame_number, - srslte_ue_sync_nbiot_get_sfidx(&ue_sync), + srsran_ue_sync_nbiot_get_sfidx(&ue_sync), prog_args.rnti); - if (n == SRSLTE_SUCCESS) { + if (n == SRSRAN_SUCCESS) { INFO("NPDSCH decoded ok."); } } else { // decode NPDCCH - srslte_dci_msg_t dci_msg; - n = srslte_nbiot_ue_dl_decode_npdcch(&ue_dl, + srsran_dci_msg_t dci_msg; + n = srsran_nbiot_ue_dl_decode_npdcch(&ue_dl, &buff_ptrs[0][prog_args.time_offset], system_frame_number, - srslte_ue_sync_nbiot_get_sfidx(&ue_sync), + srsran_ue_sync_nbiot_get_sfidx(&ue_sync), prog_args.rnti, &dci_msg); - if (n == SRSLTE_NBIOT_UE_DL_FOUND_DCI) { + if (n == SRSRAN_NBIOT_UE_DL_FOUND_DCI) { INFO("DCI found for rnti=%d", prog_args.rnti); // convert DCI to grant - srslte_ra_nbiot_dl_dci_t dci_unpacked; - srslte_ra_nbiot_dl_grant_t grant; - if (srslte_nbiot_dci_msg_to_dl_grant(&dci_msg, + srsran_ra_nbiot_dl_dci_t dci_unpacked; + srsran_ra_nbiot_dl_grant_t grant; + if (srsran_nbiot_dci_msg_to_dl_grant(&dci_msg, prog_args.rnti, &dci_unpacked, &grant, system_frame_number, - srslte_ue_sync_nbiot_get_sfidx(&ue_sync), + srsran_ue_sync_nbiot_get_sfidx(&ue_sync), 64 /* TODO: remove */, cell.mode)) { fprintf(stderr, "Error unpacking DCI\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // activate grant - srslte_nbiot_ue_dl_set_grant(&ue_dl, &grant); + srsran_nbiot_ue_dl_set_grant(&ue_dl, &grant); } } } else { // decode SIB1 over and over again - n = srslte_nbiot_ue_dl_decode_npdsch(&ue_dl, + n = srsran_nbiot_ue_dl_decode_npdsch(&ue_dl, &buff_ptrs[0][prog_args.time_offset], rx_tb, system_frame_number, - srslte_ue_sync_nbiot_get_sfidx(&ue_sync), + srsran_ue_sync_nbiot_get_sfidx(&ue_sync), prog_args.rnti); #ifdef ENABLE_GUI - if (n == SRSLTE_SUCCESS) { + if (n == SRSRAN_SUCCESS) { if (bcch_dl_sch_to_pretty_string( rx_tb, ue_dl.npdsch_cfg.grant.mcs[0].tbs / 8, sib1_buffer_decode, sizeof(sib1_buffer_decode))) { fprintf(stderr, "Error decoding SIB1\n"); @@ -752,16 +752,16 @@ int main(int argc, char** argv) #endif // ENABLE_GUI // reactivate SIB1 grant - if (srslte_nbiot_ue_dl_has_grant(&ue_dl) == false) { - srslte_nbiot_ue_dl_decode_sib1(&ue_dl, system_frame_number); + if (srsran_nbiot_ue_dl_has_grant(&ue_dl) == false) { + srsran_nbiot_ue_dl_decode_sib1(&ue_dl, system_frame_number); } } nof_trials++; - rsrq = SRSLTE_VEC_EMA(srslte_chest_dl_nbiot_get_rsrq(&ue_dl.chest), rsrq, 0.1); - rsrp = SRSLTE_VEC_EMA(srslte_chest_dl_nbiot_get_rsrp(&ue_dl.chest), rsrp, 0.05); - noise = SRSLTE_VEC_EMA(srslte_chest_dl_nbiot_get_noise_estimate(&ue_dl.chest), noise, 0.05); + rsrq = SRSRAN_VEC_EMA(srsran_chest_dl_nbiot_get_rsrq(&ue_dl.chest), rsrq, 0.1); + rsrp = SRSRAN_VEC_EMA(srsran_chest_dl_nbiot_get_rsrp(&ue_dl.chest), rsrp, 0.05); + noise = SRSRAN_VEC_EMA(srsran_chest_dl_nbiot_get_noise_estimate(&ue_dl.chest), noise, 0.05); nframes++; if (isnan(rsrq)) { rsrq = 0; @@ -774,16 +774,16 @@ int main(int argc, char** argv) } // Plot and Printf - if (srslte_ue_sync_nbiot_get_sfidx(&ue_sync) == 5) { + if (srsran_ue_sync_nbiot_get_sfidx(&ue_sync) == 5) { float gain = prog_args.rf_gain; if (gain < 0) { - gain = 10 * log10(srslte_agc_get_gain(&ue_sync.agc)); + gain = 10 * log10(srsran_agc_get_gain(&ue_sync.agc)); } printf( "CFO: %+6.2f kHz, RSRP: %4.1f dBm " "SNR: %4.1f dB, RSRQ: %4.1f dB, " "NPDCCH detected: %d, NPDSCH-BLER: %5.2f%% (%d of total %d), NPDSCH-Rate: %5.2f kbit/s\r", - srslte_ue_sync_nbiot_get_cfo(&ue_sync) / 1000, + srsran_ue_sync_nbiot_get_cfo(&ue_sync) / 1000, 10 * log10(rsrp), 10 * log10(rsrp / noise), 10 * log10(rsrq), @@ -791,12 +791,12 @@ int main(int argc, char** argv) (float)100 * ue_dl.pkt_errors / ue_dl.pkts_total, ue_dl.pkt_errors, ue_dl.pkts_total, - (ue_dl.bits_total / ((system_frame_number * 10 + srslte_ue_sync_nbiot_get_sfidx(&ue_sync)) / 1000.0)) / + (ue_dl.bits_total / ((system_frame_number * 10 + srsran_ue_sync_nbiot_get_sfidx(&ue_sync)) / 1000.0)) / 1000.0); } break; } - if (srslte_ue_sync_nbiot_get_sfidx(&ue_sync) == 9) { + if (srsran_ue_sync_nbiot_get_sfidx(&ue_sync) == 9) { system_frame_number++; if (system_frame_number == 1024) { system_frame_number = 0; @@ -817,7 +817,7 @@ int main(int argc, char** argv) #ifdef ENABLE_GUI if (!prog_args.disable_plots) { if ((system_frame_number % 4) == 0) { - plot_sf_idx = srslte_ue_sync_nbiot_get_sfidx(&ue_sync); + plot_sf_idx = srsran_ue_sync_nbiot_get_sfidx(&ue_sync); plot_track = true; sem_post(&plot_sem); } @@ -826,12 +826,12 @@ int main(int argc, char** argv) } else if (ret == 0) { state = DECODE_MIB; printf("Finding PSS... Peak: %8.1f, FrameCnt: %d, State: %d\r", - srslte_sync_nbiot_get_peak_value(&ue_sync.sfind), + srsran_sync_nbiot_get_peak_value(&ue_sync.sfind), ue_sync.frame_total_cnt, ue_sync.state); #ifdef ENABLE_GUI if (!prog_args.disable_plots) { - plot_sf_idx = srslte_ue_sync_nbiot_get_sfidx(&ue_sync); + plot_sf_idx = srsran_ue_sync_nbiot_get_sfidx(&ue_sync); plot_track = false; sem_post(&plot_sem); } @@ -851,8 +851,8 @@ int main(int argc, char** argv) printf("dci_detected=%d\n", ue_dl.nof_detected); } - srslte_nbiot_ue_dl_free(&ue_dl); - srslte_ue_sync_nbiot_free(&ue_sync); + srsran_nbiot_ue_dl_free(&ue_dl); + srsran_ue_sync_nbiot_free(&ue_sync); #if HAVE_PCAP printf("Saving PCAP file\n"); @@ -861,9 +861,9 @@ int main(int argc, char** argv) #ifndef DISABLE_RF if (!prog_args.input_file_name) { - srslte_ue_mib_nbiot_free(&ue_mib); - srslte_rf_close(&rf); - for (int i = 0; i < SRSLTE_MAX_PORTS; i++) { + srsran_ue_mib_nbiot_free(&ue_mib); + srsran_rf_close(&rf); + for (int i = 0; i < SRSRAN_MAX_PORTS; i++) { if (buff_ptrs[i] != NULL) free(buff_ptrs[i]); } @@ -881,7 +881,7 @@ int main(int argc, char** argv) #endif // ENABLE_GUI printf("\nBye\n"); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } /********************************************************************** @@ -905,7 +905,7 @@ float tmp_plot2[110 * 15 * 2048]; void* plot_thread_run(void* arg) { - uint32_t nof_re = SRSLTE_SF_LEN_RE(ue_dl.cell.base.nof_prb, ue_dl.cell.base.cp); + uint32_t nof_re = SRSRAN_SF_LEN_RE(ue_dl.cell.base.nof_prb, ue_dl.cell.base.cp); #if HAVE_RSRP_PLOT float rsrp_lin = 0; #endif @@ -979,9 +979,9 @@ void* plot_thread_run(void* arg) tmp_plot[i] = -80; } } - int numpoints = SRSLTE_NRE * 2; + int numpoints = SRSRAN_NRE * 2; bzero(tmp_plot2, sizeof(float) * numpoints); - int g = (numpoints - SRSLTE_NRE) / 2; + int g = (numpoints - SRSRAN_NRE) / 2; for (int i = 0; i < 12 * ue_dl.cell.base.nof_prb; i++) { tmp_plot2[g + i] = 20 * log10(cabsf(ue_dl.ce[0][i])); if (isinf(tmp_plot2[g + i])) { @@ -992,17 +992,17 @@ void* plot_thread_run(void* arg) if (!prog_args.input_file_name) { if (plot_track) { - srslte_npss_synch_t* pss_obj = &ue_sync.strack.npss; - int max = srslte_vec_max_fi(pss_obj->conv_output_avg, pss_obj->frame_size + pss_obj->fft_size - 1); - srslte_vec_sc_prod_fff(pss_obj->conv_output_avg, + srsran_npss_synch_t* pss_obj = &ue_sync.strack.npss; + int max = srsran_vec_max_fi(pss_obj->conv_output_avg, pss_obj->frame_size + pss_obj->fft_size - 1); + srsran_vec_sc_prod_fff(pss_obj->conv_output_avg, 1 / pss_obj->conv_output_avg[max], tmp_plot2, pss_obj->frame_size + pss_obj->fft_size - 1); plot_real_setNewData(&p_sync, &tmp_plot2[max - NPSS_FIND_PLOT_WIDTH / 2], NPSS_FIND_PLOT_WIDTH); } else { - int len = SRSLTE_NPSS_CORR_FILTER_LEN + ue_sync.sfind.npss.frame_size - 1; - int max = srslte_vec_max_fi(ue_sync.sfind.npss.conv_output_avg, len); - srslte_vec_sc_prod_fff( + int len = SRSRAN_NPSS_CORR_FILTER_LEN + ue_sync.sfind.npss.frame_size - 1; + int max = srsran_vec_max_fi(ue_sync.sfind.npss.conv_output_avg, len); + srsran_vec_sc_prod_fff( ue_sync.sfind.npss.conv_output_avg, 1 / ue_sync.sfind.npss.conv_output_avg[max], tmp_plot2, len); plot_real_setNewData(&p_sync, tmp_plot2, len); } @@ -1010,7 +1010,7 @@ void* plot_thread_run(void* arg) #if HAVE_RSRP_PLOT // get current RSRP estimate - rsrp_lin = SRSLTE_VEC_EMA(srslte_chest_dl_nbiot_get_rsrp(&ue_dl.chest), rsrp_lin, 0.05); + rsrp_lin = SRSRAN_VEC_EMA(srsran_chest_dl_nbiot_get_rsrp(&ue_dl.chest), rsrp_lin, 0.05); rsrp_table[rsrp_table_index++] = 10 * log10(rsrp_lin); if (rsrp_table_index == rsrp_num_plot) { rsrp_table_index = 0; @@ -1035,7 +1035,7 @@ void* plot_thread_run(void* arg) snprintf(lable_buf, LABLE_MAX_LEN, "%d", cell.n_id_ncell); key_value_setValueText(&id_label, lable_buf); - key_value_setValueText(&mode_label, srslte_nbiot_mode_string(cell.mode)); + key_value_setValueText(&mode_label, srsran_nbiot_mode_string(cell.mode)); snprintf(lable_buf, LABLE_MAX_LEN, "%d / %d", hyper_frame_number, system_frame_number); key_value_setValueText(&hfn_label, lable_buf); diff --git a/lib/examples/npdsch_ue_helper.cc b/lib/examples/npdsch_ue_helper.cc index 529b3b25e..38ca4e561 100644 --- a/lib/examples/npdsch_ue_helper.cc +++ b/lib/examples/npdsch_ue_helper.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,12 +11,12 @@ */ #include "npdsch_ue_helper.h" -#include "srslte/asn1/rrc_nbiot.h" -#include "srslte/phy/utils/vector.h" // for SRSLTE_MIN +#include "srsran/asn1/rrc_nbiot.h" +#include "srsran/phy/utils/vector.h" // for SRSRAN_MIN -int get_sib2_params(const uint8_t* sib1_payload, const uint32_t len, srslte_nbiot_si_params_t* sib2_params) +int get_sib2_params(const uint8_t* sib1_payload, const uint32_t len, srsran_nbiot_si_params_t* sib2_params) { - memset(sib2_params, 0, sizeof(srslte_nbiot_si_params_t)); + memset(sib2_params, 0, sizeof(srsran_nbiot_si_params_t)); // unpack SIB asn1::rrc::bcch_dl_sch_msg_nb_s dlsch_msg; @@ -24,7 +24,7 @@ int get_sib2_params(const uint8_t* sib1_payload, const uint32_t len, srslte_nbio asn1::SRSASN_CODE err = dlsch_msg.unpack(dlsch_bref); if (err != asn1::SRSASN_SUCCESS) { fprintf(stderr, "Error unpacking DL-SCH message\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // set SIB2-NB parameters @@ -38,7 +38,7 @@ int get_sib2_params(const uint8_t* sib1_payload, const uint32_t len, srslte_nbio sib2_params->si_tb = sched_info->si_tb_r13.to_number(); sib2_params->si_window_length = dlsch_msg.msg.c1().sib_type1_r13().si_win_len_r13.to_number(); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } /* @@ -54,16 +54,16 @@ int bcch_bch_to_pretty_string(const uint8_t* bcch_bch_payload, asn1::SRSASN_CODE err = bch_msg.unpack(bch_bref); if (err != asn1::SRSASN_SUCCESS) { fprintf(stderr, "Error unpacking BCCH message\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } asn1::json_writer json_writer; bch_msg.to_json(json_writer); - uint32_t output_len = SRSLTE_MIN(max_output_len, json_writer.to_string().length()); + uint32_t output_len = SRSRAN_MIN(max_output_len, json_writer.to_string().length()); memcpy(output, json_writer.to_string().c_str(), output_len); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } /* @@ -79,14 +79,14 @@ int bcch_dl_sch_to_pretty_string(const uint8_t* bcch_dl_sch_payload, asn1::SRSASN_CODE err = dlsch_msg.unpack(dlsch_bref); if (err != asn1::SRSASN_SUCCESS) { fprintf(stderr, "Error unpacking DL-SCH message\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } asn1::json_writer json_writer; dlsch_msg.to_json(json_writer); - uint32_t output_len = SRSLTE_MIN(max_output_len, json_writer.to_string().length()); + uint32_t output_len = SRSRAN_MIN(max_output_len, json_writer.to_string().length()); memcpy(output, json_writer.to_string().c_str(), output_len); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } \ No newline at end of file diff --git a/lib/examples/npdsch_ue_helper.h b/lib/examples/npdsch_ue_helper.h index bc8d9c8f5..b6a7eeca9 100644 --- a/lib/examples/npdsch_ue_helper.h +++ b/lib/examples/npdsch_ue_helper.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,17 +10,17 @@ * */ -#ifndef SRSLTE_NPDSCH_UE_HELPER_H -#define SRSLTE_NPDSCH_UE_HELPER_H +#ifndef SRSRAN_NPDSCH_UE_HELPER_H +#define SRSRAN_NPDSCH_UE_HELPER_H #ifdef __cplusplus extern "C" { #endif -#include "srslte/phy/phch/ra_nbiot.h" +#include "srsran/phy/phch/ra_nbiot.h" #include -int get_sib2_params(const uint8_t* sib1_payload, const uint32_t len, srslte_nbiot_si_params_t* sib2_params); +int get_sib2_params(const uint8_t* sib1_payload, const uint32_t len, srsran_nbiot_si_params_t* sib2_params); int bcch_bch_to_pretty_string(const uint8_t* bcch_bch_payload, const uint32_t input_len, char* output, @@ -34,4 +34,4 @@ int bcch_dl_sch_to_pretty_string(const uint8_t* bcch_dl_sch_payload, } #endif -#endif // SRSLTE_NPDSCH_UE_HELPER_H +#endif // SRSRAN_NPDSCH_UE_HELPER_H diff --git a/lib/examples/pdsch_enodeb.c b/lib/examples/pdsch_enodeb.c index 8cc065a53..fd6b4ade9 100644 --- a/lib/examples/pdsch_enodeb.c +++ b/lib/examples/pdsch_enodeb.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,9 +10,9 @@ * */ -#include "srslte/common/crash_handler.h" -#include "srslte/common/gen_mch_tables.h" -#include "srslte/srslte.h" +#include "srsran/common/crash_handler.h" +#include "srsran/common/gen_mch_tables.h" +#include "srsran/srsran.h" #include #include #include @@ -27,9 +27,9 @@ #define M_CRNTI 0xFFFD #ifndef DISABLE_RF -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/rf/rf.h" -srslte_rf_t radio; +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/rf/rf.h" +srsran_rf_t radio; #else #pragma message "Compiling pdsch_ue with no RF support" #endif @@ -43,21 +43,21 @@ static char* output_file_name = NULL; #define PAGE_UP 53 #define PAGE_DOWN 54 -static srslte_cell_t cell = { +static srsran_cell_t cell = { 25, // nof_prb 1, // nof_ports 0, // cell_id - SRSLTE_CP_NORM, // cyclic prefix - SRSLTE_PHICH_NORM, // PHICH length - SRSLTE_PHICH_R_1, // PHICH resources - SRSLTE_FDD, + SRSRAN_CP_NORM, // cyclic prefix + SRSRAN_PHICH_NORM, // PHICH length + SRSRAN_PHICH_R_1, // PHICH resources + SRSRAN_FDD, }; static int net_port = -1; // -1 generates random dataThat means there is some problem sending samples to the device static uint32_t cfi = 2; static uint32_t mcs_idx = 1, last_mcs_idx = 1; static int nof_frames = -1; -static srslte_tm_t transmission_mode = SRSLTE_TM1; +static srsran_tm_t transmission_mode = SRSRAN_TM1; static uint32_t nof_tb = 1; static uint32_t multiplex_pmi = 0; static uint32_t multiplex_nof_layers = 1; @@ -71,30 +71,30 @@ static float output_file_snr = +INFINITY; static bool use_standard_lte_rate = false; static bool null_file_sink = false; -static srslte_filesink_t fsink; -static srslte_ofdm_t ifft[SRSLTE_MAX_PORTS]; -static srslte_ofdm_t ifft_mbsfn; -static srslte_pbch_t pbch; -static srslte_pcfich_t pcfich; -static srslte_pdcch_t pdcch; -static srslte_pdsch_t pdsch; -static srslte_pdsch_cfg_t pdsch_cfg; -static srslte_pmch_t pmch; -static srslte_pmch_cfg_t pmch_cfg; -static srslte_softbuffer_tx_t* softbuffers[SRSLTE_MAX_CODEWORDS]; -static srslte_regs_t regs; -static srslte_dci_dl_t dci_dl; -static int rvidx[SRSLTE_MAX_CODEWORDS] = {0, 0}; - -static cf_t * sf_buffer[SRSLTE_MAX_PORTS] = {NULL}, *output_buffer[SRSLTE_MAX_PORTS] = {NULL}; +static srsran_filesink_t fsink; +static srsran_ofdm_t ifft[SRSRAN_MAX_PORTS]; +static srsran_ofdm_t ifft_mbsfn; +static srsran_pbch_t pbch; +static srsran_pcfich_t pcfich; +static srsran_pdcch_t pdcch; +static srsran_pdsch_t pdsch; +static srsran_pdsch_cfg_t pdsch_cfg; +static srsran_pmch_t pmch; +static srsran_pmch_cfg_t pmch_cfg; +static srsran_softbuffer_tx_t* softbuffers[SRSRAN_MAX_CODEWORDS]; +static srsran_regs_t regs; +static srsran_dci_dl_t dci_dl; +static int rvidx[SRSRAN_MAX_CODEWORDS] = {0, 0}; + +static cf_t * sf_buffer[SRSRAN_MAX_PORTS] = {NULL}, *output_buffer[SRSRAN_MAX_PORTS] = {NULL}; static uint32_t sf_n_re, sf_n_samples; static pthread_t net_thread; static void* net_thread_fnc(void* arg); static sem_t net_sem; static bool net_packet_ready = false; -static srslte_netsource_t net_source; -static srslte_netsink_t net_sink; +static srsran_netsource_t net_source; +static srsran_netsink_t net_sink; static int prbset_num = 1, last_prbset_num = 1; static int prbset_orig = 0; @@ -130,7 +130,7 @@ static void usage(char* prog) printf("\t-u listen TCP/UDP port for input data (if mbsfn is active then the stream is over mbsfn only) (-1 is " "random) [Default %d]\n", net_port); - printf("\t-v [set srslte_verbose to debug, default none]\n"); + printf("\t-v [set srsran_verbose to debug, default none]\n"); printf("\t-s output file SNR [Default %f]\n", output_file_snr); printf("\t-q Enable/Disable 256QAM modulation (default %s)\n", enable_256qam ? "enabled" : "disabled"); printf("\t-Q Use standard LTE sample rates (default %s)\n", use_standard_lte_rate ? "enabled" : "disabled"); @@ -177,7 +177,7 @@ static void parse_args(int argc, char** argv) cell.id = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'x': - transmission_mode = (srslte_tm_t)(strtol(argv[optind], NULL, 10) - 1); + transmission_mode = (srsran_tm_t)(strtol(argv[optind], NULL, 10) - 1); break; case 'b': multiplex_pmi = (uint32_t)strtol(argv[optind], NULL, 10); @@ -189,7 +189,7 @@ static void parse_args(int argc, char** argv) mbsfn_area_id = (int)strtol(argv[optind], NULL, 10); break; case 'v': - srslte_verbose++; + srsran_verbose++; break; case 's': output_file_snr = strtof(argv[optind], NULL); @@ -222,12 +222,12 @@ static void base_init() /* Configure cell and PDSCH in function of the transmission mode */ switch (transmission_mode) { - case SRSLTE_TM1: + case SRSRAN_TM1: cell.nof_ports = 1; break; - case SRSLTE_TM2: - case SRSLTE_TM3: - case SRSLTE_TM4: + case SRSRAN_TM2: + case SRSRAN_TM3: + case SRSRAN_TM4: cell.nof_ports = 2; break; default: @@ -236,38 +236,38 @@ static void base_init() } /* Allocate memory */ - for (i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { - data[i] = srslte_vec_u8_malloc(SOFTBUFFER_SIZE); + for (i = 0; i < SRSRAN_MAX_CODEWORDS; i++) { + data[i] = srsran_vec_u8_malloc(SOFTBUFFER_SIZE); if (!data[i]) { perror("malloc"); exit(-1); } bzero(data[i], sizeof(uint8_t) * SOFTBUFFER_SIZE); } - data_mbms = srslte_vec_u8_malloc(SOFTBUFFER_SIZE); + data_mbms = srsran_vec_u8_malloc(SOFTBUFFER_SIZE); /* init memory */ - for (i = 0; i < SRSLTE_MAX_PORTS; i++) { - sf_buffer[i] = srslte_vec_cf_malloc(sf_n_re); + for (i = 0; i < SRSRAN_MAX_PORTS; i++) { + sf_buffer[i] = srsran_vec_cf_malloc(sf_n_re); if (!sf_buffer[i]) { perror("malloc"); exit(-1); } } - for (i = 0; i < SRSLTE_MAX_PORTS; i++) { - output_buffer[i] = srslte_vec_cf_malloc(sf_n_samples); + for (i = 0; i < SRSRAN_MAX_PORTS; i++) { + output_buffer[i] = srsran_vec_cf_malloc(sf_n_samples); if (!output_buffer[i]) { perror("malloc"); exit(-1); } - srslte_vec_cf_zero(output_buffer[i], sf_n_samples); + srsran_vec_cf_zero(output_buffer[i], sf_n_samples); } /* open file or USRP */ if (output_file_name) { if (strcmp(output_file_name, "NULL")) { - if (srslte_filesink_init(&fsink, output_file_name, SRSLTE_COMPLEX_FLOAT_BIN)) { + if (srsran_filesink_init(&fsink, output_file_name, SRSRAN_COMPLEX_FLOAT_BIN)) { ERROR("Error opening file %s", output_file_name); exit(-1); } @@ -278,7 +278,7 @@ static void base_init() } else { #ifndef DISABLE_RF printf("Opening RF device...\n"); - if (srslte_rf_open_devname(&radio, rf_dev, rf_args, cell.nof_ports)) { + if (srsran_rf_open_devname(&radio, rf_dev, rf_args, cell.nof_ports)) { fprintf(stderr, "Error opening rf\n"); exit(-1); } @@ -289,12 +289,12 @@ static void base_init() } if (net_port > 0) { - if (srslte_netsource_init(&net_source, "127.0.0.1", net_port, SRSLTE_NETSOURCE_UDP)) { + if (srsran_netsource_init(&net_source, "127.0.0.1", net_port, SRSRAN_NETSOURCE_UDP)) { ERROR("Error creating input UDP socket at port %d", net_port); exit(-1); } if (null_file_sink) { - if (srslte_netsink_init(&net_sink, "127.0.0.1", net_port + 1, SRSLTE_NETSINK_TCP)) { + if (srsran_netsink_init(&net_sink, "127.0.0.1", net_port + 1, SRSRAN_NETSINK_TCP)) { ERROR("Error sink"); exit(-1); } @@ -307,76 +307,76 @@ static void base_init() /* create ifft object */ for (i = 0; i < cell.nof_ports; i++) { - if (srslte_ofdm_tx_init(&ifft[i], SRSLTE_CP_NORM, sf_buffer[i], output_buffer[i], cell.nof_prb)) { + if (srsran_ofdm_tx_init(&ifft[i], SRSRAN_CP_NORM, sf_buffer[i], output_buffer[i], cell.nof_prb)) { ERROR("Error creating iFFT object"); exit(-1); } - srslte_ofdm_set_normalize(&ifft[i], true); + srsran_ofdm_set_normalize(&ifft[i], true); } - if (srslte_ofdm_tx_init_mbsfn(&ifft_mbsfn, SRSLTE_CP_EXT, sf_buffer[0], output_buffer[0], cell.nof_prb)) { + if (srsran_ofdm_tx_init_mbsfn(&ifft_mbsfn, SRSRAN_CP_EXT, sf_buffer[0], output_buffer[0], cell.nof_prb)) { ERROR("Error creating iFFT object"); exit(-1); } - srslte_ofdm_set_non_mbsfn_region(&ifft_mbsfn, 2); - srslte_ofdm_set_normalize(&ifft_mbsfn, true); + srsran_ofdm_set_non_mbsfn_region(&ifft_mbsfn, 2); + srsran_ofdm_set_normalize(&ifft_mbsfn, true); - if (srslte_pbch_init(&pbch)) { + if (srsran_pbch_init(&pbch)) { ERROR("Error creating PBCH object"); exit(-1); } - if (srslte_pbch_set_cell(&pbch, cell)) { + if (srsran_pbch_set_cell(&pbch, cell)) { ERROR("Error creating PBCH object"); exit(-1); } - if (srslte_regs_init(®s, cell)) { + if (srsran_regs_init(®s, cell)) { ERROR("Error initiating regs"); exit(-1); } - if (srslte_pcfich_init(&pcfich, 1)) { + if (srsran_pcfich_init(&pcfich, 1)) { ERROR("Error creating PBCH object"); exit(-1); } - if (srslte_pcfich_set_cell(&pcfich, ®s, cell)) { + if (srsran_pcfich_set_cell(&pcfich, ®s, cell)) { ERROR("Error creating PBCH object"); exit(-1); } - if (srslte_pdcch_init_enb(&pdcch, cell.nof_prb)) { + if (srsran_pdcch_init_enb(&pdcch, cell.nof_prb)) { ERROR("Error creating PDCCH object"); exit(-1); } - if (srslte_pdcch_set_cell(&pdcch, ®s, cell)) { + if (srsran_pdcch_set_cell(&pdcch, ®s, cell)) { ERROR("Error creating PDCCH object"); exit(-1); } - if (srslte_pdsch_init_enb(&pdsch, cell.nof_prb)) { + if (srsran_pdsch_init_enb(&pdsch, cell.nof_prb)) { ERROR("Error creating PDSCH object"); exit(-1); } - if (srslte_pdsch_set_cell(&pdsch, cell)) { + if (srsran_pdsch_set_cell(&pdsch, cell)) { ERROR("Error creating PDSCH object"); exit(-1); } if (mbsfn_area_id > -1) { - if (srslte_pmch_init(&pmch, cell.nof_prb, 1)) { + if (srsran_pmch_init(&pmch, cell.nof_prb, 1)) { ERROR("Error creating PMCH object"); } - srslte_pmch_set_area_id(&pmch, mbsfn_area_id); + srsran_pmch_set_area_id(&pmch, mbsfn_area_id); } - for (i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { - softbuffers[i] = calloc(sizeof(srslte_softbuffer_tx_t), 1); + for (i = 0; i < SRSRAN_MAX_CODEWORDS; i++) { + softbuffers[i] = calloc(sizeof(srsran_softbuffer_tx_t), 1); if (!softbuffers[i]) { ERROR("Error allocating soft buffer"); exit(-1); } - if (srslte_softbuffer_tx_init(softbuffers[i], cell.nof_prb)) { + if (srsran_softbuffer_tx_init(softbuffers[i], cell.nof_prb)) { ERROR("Error initiating soft buffer"); exit(-1); } @@ -386,31 +386,31 @@ static void base_init() static void base_free() { int i; - for (i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { - srslte_softbuffer_tx_free(softbuffers[i]); + for (i = 0; i < SRSRAN_MAX_CODEWORDS; i++) { + srsran_softbuffer_tx_free(softbuffers[i]); if (softbuffers[i]) { free(softbuffers[i]); } } - srslte_pdsch_free(&pdsch); - srslte_pdcch_free(&pdcch); - srslte_regs_free(®s); - srslte_pbch_free(&pbch); + srsran_pdsch_free(&pdsch); + srsran_pdcch_free(&pdcch); + srsran_regs_free(®s); + srsran_pbch_free(&pbch); if (mbsfn_area_id > -1) { - srslte_pmch_free(&pmch); + srsran_pmch_free(&pmch); } - srslte_ofdm_tx_free(&ifft_mbsfn); + srsran_ofdm_tx_free(&ifft_mbsfn); for (i = 0; i < cell.nof_ports; i++) { - srslte_ofdm_tx_free(&ifft[i]); + srsran_ofdm_tx_free(&ifft[i]); } - for (i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { + for (i = 0; i < SRSRAN_MAX_CODEWORDS; i++) { if (data[i]) { free(data[i]); } } - for (i = 0; i < SRSLTE_MAX_PORTS; i++) { + for (i = 0; i < SRSRAN_MAX_PORTS; i++) { if (sf_buffer[i]) { free(sf_buffer[i]); } @@ -421,16 +421,16 @@ static void base_free() } if (output_file_name) { if (!null_file_sink) { - srslte_filesink_free(&fsink); + srsran_filesink_free(&fsink); } } else { #ifndef DISABLE_RF - srslte_rf_close(&radio); + srsran_rf_close(&radio); #endif } if (net_port > 0) { - srslte_netsource_free(&net_source); + srsran_netsource_free(&net_source); sem_close(&net_sem); } } @@ -458,7 +458,7 @@ static unsigned int reverse(register unsigned int x) static uint32_t prbset_to_bitmask() { uint32_t mask = 0; - int nb = (int)ceilf((float)cell.nof_prb / srslte_ra_type0_P(cell.nof_prb)); + int nb = (int)ceilf((float)cell.nof_prb / srsran_ra_type0_P(cell.nof_prb)); for (int i = 0; i < nb; i++) { if (i >= prbset_orig && i < prbset_orig + prbset_num) { mask = mask | (0x1 << i); @@ -473,17 +473,17 @@ static int update_radl() /* Configure cell and PDSCH in function of the transmission mode */ switch (transmission_mode) { - case SRSLTE_TM1: - case SRSLTE_TM2: + case SRSRAN_TM1: + case SRSRAN_TM2: nof_tb = 1; - dci_dl.format = SRSLTE_DCI_FORMAT1; + dci_dl.format = SRSRAN_DCI_FORMAT1; break; - case SRSLTE_TM3: - dci_dl.format = SRSLTE_DCI_FORMAT2A; + case SRSRAN_TM3: + dci_dl.format = SRSRAN_DCI_FORMAT2A; nof_tb = 2; break; - case SRSLTE_TM4: - dci_dl.format = SRSLTE_DCI_FORMAT2; + case SRSRAN_TM4: + dci_dl.format = SRSRAN_DCI_FORMAT2; nof_tb = multiplex_nof_layers; if (multiplex_nof_layers == 1) { dci_dl.pinfo = (uint8_t)(multiplex_pmi + 1); @@ -502,7 +502,7 @@ static int update_radl() dci_dl.tb[0].ndi = 0; dci_dl.tb[0].rv = rvidx[0]; dci_dl.tb[0].cw_idx = 0; - dci_dl.alloc_type = SRSLTE_RA_ALLOC_TYPE0; + dci_dl.alloc_type = SRSRAN_RA_ALLOC_TYPE0; dci_dl.type0_alloc.rbg_bitmask = prbset_to_bitmask(); if (nof_tb > 1) { @@ -511,11 +511,11 @@ static int update_radl() dci_dl.tb[1].rv = rvidx[1]; dci_dl.tb[1].cw_idx = 1; } else { - SRSLTE_DCI_TB_DISABLE(dci_dl.tb[1]); + SRSRAN_DCI_TB_DISABLE(dci_dl.tb[1]); } - srslte_dci_dl_fprint(stdout, &dci_dl, cell.nof_prb); - if (transmission_mode != SRSLTE_TM1) { + srsran_dci_dl_fprint(stdout, &dci_dl, cell.nof_prb); + if (transmission_mode != SRSRAN_TM1) { printf("\nTransmission mode key table:\n"); printf(" Mode | 1TB | 2TB |\n"); printf("----------+---------+-----+\n"); @@ -552,7 +552,7 @@ static int update_control() if (input[0] == 27) { switch (input[2]) { case RIGHT_KEY: - if (prbset_orig + prbset_num < (int)ceilf((float)cell.nof_prb / srslte_ra_type0_P(cell.nof_prb))) + if (prbset_orig + prbset_num < (int)ceilf((float)cell.nof_prb / srsran_ra_type0_P(cell.nof_prb))) prbset_orig++; break; case LEFT_KEY: @@ -560,7 +560,7 @@ static int update_control() prbset_orig--; break; case UP_KEY: - if (prbset_num < (int)ceilf((float)cell.nof_prb / srslte_ra_type0_P(cell.nof_prb))) + if (prbset_num < (int)ceilf((float)cell.nof_prb / srsran_ra_type0_P(cell.nof_prb))) prbset_num++; break; case DOWN_KEY: @@ -572,15 +572,15 @@ static int update_control() case PAGE_UP: if (!output_file_name) { rf_gain++; - srslte_rf_set_tx_gain(&radio, rf_gain); - printf("Set TX gain: %.1f dB\n", srslte_rf_get_tx_gain(&radio)); + srsran_rf_set_tx_gain(&radio, rf_gain); + printf("Set TX gain: %.1f dB\n", srsran_rf_get_tx_gain(&radio)); } break; case PAGE_DOWN: if (!output_file_name) { rf_gain--; - srslte_rf_set_tx_gain(&radio, rf_gain); - printf("Set TX gain: %.1f dB\n", srslte_rf_get_tx_gain(&radio)); + srsran_rf_set_tx_gain(&radio, rf_gain); + printf("Set TX gain: %.1f dB\n", srsran_rf_get_tx_gain(&radio)); } break; #endif @@ -588,40 +588,40 @@ static int update_control() } else { switch (input[0]) { case 'q': - transmission_mode = SRSLTE_TM4; + transmission_mode = SRSRAN_TM4; multiplex_pmi = 0; multiplex_nof_layers = 1; break; case 'w': - transmission_mode = SRSLTE_TM4; + transmission_mode = SRSRAN_TM4; multiplex_pmi = 1; multiplex_nof_layers = 1; break; case 'e': - transmission_mode = SRSLTE_TM4; + transmission_mode = SRSRAN_TM4; multiplex_pmi = 2; multiplex_nof_layers = 1; break; case 'r': - transmission_mode = SRSLTE_TM4; + transmission_mode = SRSRAN_TM4; multiplex_pmi = 3; multiplex_nof_layers = 1; break; case 'a': - transmission_mode = SRSLTE_TM4; + transmission_mode = SRSRAN_TM4; multiplex_pmi = 0; multiplex_nof_layers = 2; break; case 's': - transmission_mode = SRSLTE_TM4; + transmission_mode = SRSRAN_TM4; multiplex_pmi = 1; multiplex_nof_layers = 2; break; case 'z': - transmission_mode = SRSLTE_TM3; + transmission_mode = SRSRAN_TM3; break; case 'x': - transmission_mode = SRSLTE_TM2; + transmission_mode = SRSRAN_TM2; break; default: last_mcs_idx = mcs_idx; @@ -653,7 +653,7 @@ static void* net_thread_fnc(void* arg) int rpm = 0, wpm = 0; do { - n = srslte_netsource_read(&net_source, &data2[rpm], DATA_BUFF_SZ - rpm); + n = srsran_netsource_read(&net_source, &data2[rpm], DATA_BUFF_SZ - rpm); if (n > 0) { // TODO: I assume that both transport blocks have same size in case of 2 tb are active @@ -694,19 +694,19 @@ static void* net_thread_fnc(void* arg) int main(int argc, char** argv) { int nf = 0, sf_idx = 0, N_id_2 = 0; - cf_t pss_signal[SRSLTE_PSS_LEN]; - float sss_signal0[SRSLTE_SSS_LEN]; // for subframe 0 - float sss_signal5[SRSLTE_SSS_LEN]; // for subframe 5 - uint8_t bch_payload[SRSLTE_BCH_PAYLOAD_LEN]; + cf_t pss_signal[SRSRAN_PSS_LEN]; + float sss_signal0[SRSRAN_SSS_LEN]; // for subframe 0 + float sss_signal5[SRSRAN_SSS_LEN]; // for subframe 5 + uint8_t bch_payload[SRSRAN_BCH_PAYLOAD_LEN]; int i; - cf_t* sf_symbols[SRSLTE_MAX_PORTS]; - srslte_dci_msg_t dci_msg; - srslte_dci_location_t locations[SRSLTE_NOF_SF_X_FRAME][30]; + cf_t* sf_symbols[SRSRAN_MAX_PORTS]; + srsran_dci_msg_t dci_msg; + srsran_dci_location_t locations[SRSRAN_NOF_SF_X_FRAME][30]; uint32_t sfn; - srslte_refsignal_t csr_refs; - srslte_refsignal_t mbsfn_refs; + srsran_refsignal_t csr_refs; + srsran_refsignal_t mbsfn_refs; - srslte_debug_handle_crash(argc, argv); + srsran_debug_handle_crash(argc, argv); #ifdef DISABLE_RF if (argc < 3) { @@ -717,7 +717,7 @@ int main(int argc, char** argv) parse_args(argc, argv); - srslte_use_standard_symbol_size(use_standard_lte_rate); + srsran_use_standard_symbol_size(use_standard_lte_rate); uint8_t mch_table[10]; bzero(&mch_table[0], sizeof(uint8_t) * 10); @@ -725,45 +725,45 @@ int main(int argc, char** argv) generate_mcch_table(mch_table, mbsfn_sf_mask); } N_id_2 = cell.id % 3; - sf_n_re = 2 * SRSLTE_CP_NORM_NSYMB * cell.nof_prb * SRSLTE_NRE; - sf_n_samples = 2 * SRSLTE_SLOT_LEN(srslte_symbol_sz(cell.nof_prb)); + sf_n_re = 2 * SRSRAN_CP_NORM_NSYMB * cell.nof_prb * SRSRAN_NRE; + sf_n_samples = 2 * SRSRAN_SLOT_LEN(srsran_symbol_sz(cell.nof_prb)); - cell.phich_length = SRSLTE_PHICH_NORM; - cell.phich_resources = SRSLTE_PHICH_R_1; + cell.phich_length = SRSRAN_PHICH_NORM; + cell.phich_resources = SRSRAN_PHICH_R_1; sfn = 0; - prbset_num = (int)ceilf((float)cell.nof_prb / srslte_ra_type0_P(cell.nof_prb)); + prbset_num = (int)ceilf((float)cell.nof_prb / srsran_ra_type0_P(cell.nof_prb)); last_prbset_num = prbset_num; /* this *must* be called after setting slot_len_* */ base_init(); /* Generate PSS/SSS signals */ - srslte_pss_generate(pss_signal, N_id_2); - srslte_sss_generate(sss_signal0, sss_signal5, cell.id); + srsran_pss_generate(pss_signal, N_id_2); + srsran_sss_generate(sss_signal0, sss_signal5, cell.id); /* Generate reference signals */ - if (srslte_refsignal_cs_init(&csr_refs, cell.nof_prb)) { + if (srsran_refsignal_cs_init(&csr_refs, cell.nof_prb)) { ERROR("Error initializing equalizer"); exit(-1); } if (mbsfn_area_id > -1) { - if (srslte_refsignal_mbsfn_init(&mbsfn_refs, cell.nof_prb)) { + if (srsran_refsignal_mbsfn_init(&mbsfn_refs, cell.nof_prb)) { ERROR("Error initializing equalizer"); exit(-1); } - if (srslte_refsignal_mbsfn_set_cell(&mbsfn_refs, cell, mbsfn_area_id)) { + if (srsran_refsignal_mbsfn_set_cell(&mbsfn_refs, cell, mbsfn_area_id)) { ERROR("Error initializing MBSFNR signal"); exit(-1); } } - if (srslte_refsignal_cs_set_cell(&csr_refs, cell)) { + if (srsran_refsignal_cs_set_cell(&csr_refs, cell)) { ERROR("Error setting cell"); exit(-1); } - for (i = 0; i < SRSLTE_MAX_PORTS; i++) { + for (i = 0; i < SRSRAN_MAX_PORTS; i++) { sf_symbols[i] = sf_buffer[i % cell.nof_ports]; } @@ -776,10 +776,10 @@ int main(int argc, char** argv) signal(SIGINT, sig_int_handler); if (!output_file_name) { - int srate = srslte_sampling_freq_hz(cell.nof_prb); + int srate = srsran_sampling_freq_hz(cell.nof_prb); if (srate != -1) { printf("Setting sampling rate %.2f MHz\n", (float)srate / 1000000); - float srate_rf = srslte_rf_set_tx_srate(&radio, (double)srate); + float srate_rf = srsran_rf_set_tx_srate(&radio, (double)srate); if (srate_rf != srate) { ERROR("Could not set sampling rate"); exit(-1); @@ -788,9 +788,9 @@ int main(int argc, char** argv) ERROR("Invalid number of PRB %d", cell.nof_prb); exit(-1); } - srslte_rf_set_tx_gain(&radio, rf_gain); - printf("Set TX gain: %.1f dB\n", srslte_rf_get_tx_gain(&radio)); - printf("Set TX freq: %.2f MHz\n", srslte_rf_set_tx_freq(&radio, cell.nof_ports, rf_freq) / 1000000); + srsran_rf_set_tx_gain(&radio, rf_gain); + printf("Set TX gain: %.1f dB\n", srsran_rf_get_tx_gain(&radio)); + printf("Set TX freq: %.2f MHz\n", srsran_rf_set_tx_freq(&radio, cell.nof_ports, rf_freq) / 1000000); } #endif @@ -806,21 +806,21 @@ int main(int argc, char** argv) } pmch_cfg.pdsch_cfg.grant.tb[0].tbs = 1096; - srslte_dl_sf_cfg_t dl_sf; + srsran_dl_sf_cfg_t dl_sf; ZERO_OBJECT(dl_sf); /* Initiate valid DCI locations */ - for (i = 0; i < SRSLTE_NOF_SF_X_FRAME; i++) { + for (i = 0; i < SRSRAN_NOF_SF_X_FRAME; i++) { dl_sf.cfi = cfi; dl_sf.tti = i; - srslte_pdcch_ue_locations(&pdcch, &dl_sf, locations[i], 30, UE_CRNTI); + srsran_pdcch_ue_locations(&pdcch, &dl_sf, locations[i], 30, UE_CRNTI); } nf = 0; bool send_data = false; - for (i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { - srslte_softbuffer_tx_reset(softbuffers[i]); + for (i = 0; i < SRSRAN_MAX_CODEWORDS; i++) { + srsran_softbuffer_tx_reset(softbuffers[i]); } #ifndef DISABLE_RF @@ -828,7 +828,7 @@ int main(int argc, char** argv) #endif ZERO_OBJECT(pdsch_cfg); - for (uint32_t j = 0; j < SRSLTE_MAX_CODEWORDS; j++) { + for (uint32_t j = 0; j < SRSRAN_MAX_CODEWORDS; j++) { pdsch_cfg.softbuffers.tx[j] = softbuffers[j]; } pdsch_cfg.rnti = UE_CRNTI; @@ -836,13 +836,13 @@ int main(int argc, char** argv) pmch_cfg.pdsch_cfg = pdsch_cfg; while ((nf < nof_frames || nof_frames == -1) && !go_exit) { - for (sf_idx = 0; sf_idx < SRSLTE_NOF_SF_X_FRAME && (nf < nof_frames || nof_frames == -1) && !go_exit; sf_idx++) { + for (sf_idx = 0; sf_idx < SRSRAN_NOF_SF_X_FRAME && (nf < nof_frames || nof_frames == -1) && !go_exit; sf_idx++) { /* Set Antenna port resource elements to zero */ - srslte_vec_cf_zero(sf_symbols[0], sf_n_re); + srsran_vec_cf_zero(sf_symbols[0], sf_n_re); if (sf_idx == 0 || sf_idx == 5) { - srslte_pss_put_slot(pss_signal, sf_symbols[0], cell.nof_prb, SRSLTE_CP_NORM); - srslte_sss_put_slot(sf_idx ? sss_signal5 : sss_signal0, sf_symbols[0], cell.nof_prb, SRSLTE_CP_NORM); + srsran_pss_put_slot(pss_signal, sf_symbols[0], cell.nof_prb, SRSRAN_CP_NORM); + srsran_sss_put_slot(sf_idx ? sss_signal5 : sss_signal0, sf_symbols[0], cell.nof_prb, SRSRAN_CP_NORM); } /* Copy zeros, SSS, PSS into the rest of antenna ports */ @@ -851,23 +851,23 @@ int main(int argc, char** argv) } if (mch_table[sf_idx] == 1 && mbsfn_area_id > -1) { - srslte_refsignal_mbsfn_put_sf(cell, 0, csr_refs.pilots[0][sf_idx], mbsfn_refs.pilots[0][sf_idx], sf_symbols[0]); + srsran_refsignal_mbsfn_put_sf(cell, 0, csr_refs.pilots[0][sf_idx], mbsfn_refs.pilots[0][sf_idx], sf_symbols[0]); } else { dl_sf.tti = nf * 10 + sf_idx; for (i = 0; i < cell.nof_ports; i++) { - srslte_refsignal_cs_put_sf(&csr_refs, &dl_sf, (uint32_t)i, sf_symbols[i]); + srsran_refsignal_cs_put_sf(&csr_refs, &dl_sf, (uint32_t)i, sf_symbols[i]); } } - srslte_pbch_mib_pack(&cell, sfn, bch_payload); + srsran_pbch_mib_pack(&cell, sfn, bch_payload); if (sf_idx == 0) { - srslte_pbch_encode(&pbch, bch_payload, sf_symbols, nf % 4); + srsran_pbch_encode(&pbch, bch_payload, sf_symbols, nf % 4); } dl_sf.tti = nf * 10 + sf_idx; dl_sf.cfi = cfi; - srslte_pcfich_encode(&pcfich, &dl_sf, sf_symbols); + srsran_pcfich_encode(&pcfich, &dl_sf, sf_symbols); /* Update DL resource allocation from control port */ if (update_control()) { @@ -882,7 +882,7 @@ int main(int argc, char** argv) } } else { INFO("SF: %d, Generating %d random bits", sf_idx, pdsch_cfg.grant.tb[0].tbs + pdsch_cfg.grant.tb[1].tbs); - for (uint32_t tb = 0; tb < SRSLTE_MAX_CODEWORDS; tb++) { + for (uint32_t tb = 0; tb < SRSRAN_MAX_CODEWORDS; tb++) { if (pdsch_cfg.grant.tb[tb].enabled) { for (i = 0; i < pdsch_cfg.grant.tb[tb].tbs / 8; i++) { data[tb][i] = (uint8_t)rand(); @@ -898,34 +898,34 @@ int main(int argc, char** argv) } if (send_data) { if (mch_table[sf_idx] == 0 || mbsfn_area_id < 0) { // PDCCH + PDSCH - dl_sf.sf_type = SRSLTE_SF_NORM; + dl_sf.sf_type = SRSRAN_SF_NORM; /* Encode PDCCH */ INFO("Putting DCI to location: n=%d, L=%d", locations[sf_idx][0].ncce, locations[sf_idx][0].L); - srslte_dci_msg_pack_pdsch(&cell, &dl_sf, NULL, &dci_dl, &dci_msg); + srsran_dci_msg_pack_pdsch(&cell, &dl_sf, NULL, &dci_dl, &dci_msg); dci_msg.location = locations[sf_idx][0]; - if (srslte_pdcch_encode(&pdcch, &dl_sf, &dci_msg, sf_symbols)) { + if (srsran_pdcch_encode(&pdcch, &dl_sf, &dci_msg, sf_symbols)) { ERROR("Error encoding DCI message"); exit(-1); } /* Configure pdsch_cfg parameters */ - if (srslte_ra_dl_dci_to_grant(&cell, &dl_sf, transmission_mode, enable_256qam, &dci_dl, &pdsch_cfg.grant)) { + if (srsran_ra_dl_dci_to_grant(&cell, &dl_sf, transmission_mode, enable_256qam, &dci_dl, &pdsch_cfg.grant)) { ERROR("Error configuring PDSCH"); exit(-1); } /* Encode PDSCH */ - if (srslte_pdsch_encode(&pdsch, &dl_sf, &pdsch_cfg, data, sf_symbols)) { + if (srsran_pdsch_encode(&pdsch, &dl_sf, &pdsch_cfg, data, sf_symbols)) { ERROR("Error encoding PDSCH"); exit(-1); } if (net_port > 0 && net_packet_ready) { if (null_file_sink) { - for (uint32_t tb = 0; tb < SRSLTE_MAX_CODEWORDS; tb++) { - srslte_bit_pack_vector(data[tb], data_tmp, pdsch_cfg.grant.tb[tb].tbs); - if (srslte_netsink_write(&net_sink, data_tmp, 1 + (pdsch_cfg.grant.tb[tb].tbs - 1) / 8) < 0) { + for (uint32_t tb = 0; tb < SRSRAN_MAX_CODEWORDS; tb++) { + srsran_bit_pack_vector(data[tb], data_tmp, pdsch_cfg.grant.tb[tb].tbs); + if (srsran_netsink_write(&net_sink, data_tmp, 1 + (pdsch_cfg.grant.tb[tb].tbs - 1) / 8) < 0) { ERROR("Error sending data through UDP socket"); } } @@ -936,17 +936,17 @@ int main(int argc, char** argv) } } } else { // We're sending MCH on subframe 1 - PDCCH + PMCH - dl_sf.sf_type = SRSLTE_SF_MBSFN; + dl_sf.sf_type = SRSRAN_SF_MBSFN; /* Force 1 word and MCS 2 */ - dci_dl.rnti = SRSLTE_MRNTI; - dci_dl.alloc_type = SRSLTE_RA_ALLOC_TYPE0; + dci_dl.rnti = SRSRAN_MRNTI; + dci_dl.alloc_type = SRSRAN_RA_ALLOC_TYPE0; dci_dl.type0_alloc.rbg_bitmask = 0xffffffff; dci_dl.tb[0].mcs_idx = 2; - dci_dl.format = SRSLTE_DCI_FORMAT1; + dci_dl.format = SRSRAN_DCI_FORMAT1; /* Configure pdsch_cfg parameters */ - if (srslte_ra_dl_dci_to_grant(&cell, &dl_sf, SRSLTE_TM1, enable_256qam, &dci_dl, &pmch_cfg.pdsch_cfg.grant)) { + if (srsran_ra_dl_dci_to_grant(&cell, &dl_sf, SRSRAN_TM1, enable_256qam, &dci_dl, &pmch_cfg.pdsch_cfg.grant)) { ERROR("Error configuring PDSCH"); exit(-1); } @@ -958,14 +958,14 @@ int main(int argc, char** argv) pmch_cfg.area_id = mbsfn_area_id; /* Encode PMCH */ - if (srslte_pmch_encode(&pmch, &dl_sf, &pmch_cfg, data_mbms, sf_symbols)) { + if (srsran_pmch_encode(&pmch, &dl_sf, &pmch_cfg, data_mbms, sf_symbols)) { ERROR("Error encoding PDSCH"); exit(-1); } if (net_port > 0 && net_packet_ready) { if (null_file_sink) { - srslte_bit_pack_vector(data[0], data_tmp, pmch_cfg.pdsch_cfg.grant.tb[0].tbs); - if (srslte_netsink_write(&net_sink, data_tmp, 1 + (pmch_cfg.pdsch_cfg.grant.tb[0].tbs - 1) / 8) < 0) { + srsran_bit_pack_vector(data[0], data_tmp, pmch_cfg.pdsch_cfg.grant.tb[0].tbs); + if (srsran_netsink_write(&net_sink, data_tmp, 1 + (pmch_cfg.pdsch_cfg.grant.tb[0].tbs - 1) / 8) < 0) { ERROR("Error sending data through UDP socket"); } } @@ -978,10 +978,10 @@ int main(int argc, char** argv) /* Transform to OFDM symbols */ if (mch_table[sf_idx] == 0 || mbsfn_area_id < 0) { for (i = 0; i < cell.nof_ports; i++) { - srslte_ofdm_tx_sf(&ifft[i]); + srsran_ofdm_tx_sf(&ifft[i]); } } else { - srslte_ofdm_tx_sf(&ifft_mbsfn); + srsran_ofdm_tx_sf(&ifft_mbsfn); } /* send to file or usrp */ @@ -989,22 +989,22 @@ int main(int argc, char** argv) if (!null_file_sink) { /* Apply AWGN */ if (output_file_snr != +INFINITY) { - float var = srslte_convert_dB_to_amplitude(-(output_file_snr + 3.0f)); + float var = srsran_convert_dB_to_amplitude(-(output_file_snr + 3.0f)); for (int k = 0; k < cell.nof_ports; k++) { - srslte_ch_awgn_c(output_buffer[k], output_buffer[k], var, sf_n_samples); + srsran_ch_awgn_c(output_buffer[k], output_buffer[k], var, sf_n_samples); } } - srslte_filesink_write_multi(&fsink, (void**)output_buffer, sf_n_samples, cell.nof_ports); + srsran_filesink_write_multi(&fsink, (void**)output_buffer, sf_n_samples, cell.nof_ports); } usleep(1000); } else { #ifndef DISABLE_RF float norm_factor = (float)cell.nof_prb / 15 / sqrtf(pdsch_cfg.grant.nof_prb); for (i = 0; i < cell.nof_ports; i++) { - srslte_vec_sc_prod_cfc( - output_buffer[i], rf_amp * norm_factor, output_buffer[i], SRSLTE_SF_LEN_PRB(cell.nof_prb)); + srsran_vec_sc_prod_cfc( + output_buffer[i], rf_amp * norm_factor, output_buffer[i], SRSRAN_SF_LEN_PRB(cell.nof_prb)); } - srslte_rf_send_multi(&radio, (void**)output_buffer, sf_n_samples, true, start_of_burst, false); + srsran_rf_send_multi(&radio, (void**)output_buffer, sf_n_samples, true, start_of_burst, false); start_of_burst = false; #endif } diff --git a/lib/examples/pdsch_ue.c b/lib/examples/pdsch_ue.c index 1b418dfd7..083546a52 100644 --- a/lib/examples/pdsch_ue.c +++ b/lib/examples/pdsch_ue.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -22,21 +22,21 @@ #include #include -#include "srslte/common/crash_handler.h" -#include "srslte/common/gen_mch_tables.h" -#include "srslte/phy/io/filesink.h" -#include "srslte/srslte.h" +#include "srsran/common/crash_handler.h" +#include "srsran/common/gen_mch_tables.h" +#include "srsran/phy/io/filesink.h" +#include "srsran/srsran.h" #define ENABLE_AGC_DEFAULT #ifndef DISABLE_RF -#include "srslte/phy/rf/rf.h" -#include "srslte/phy/rf/rf_utils.h" +#include "srsran/phy/rf/rf.h" +#include "srsran/phy/rf/rf_utils.h" -cell_search_cfg_t cell_detect_config = {.max_frames_pbch = SRSLTE_DEFAULT_MAX_FRAMES_PBCH, - .max_frames_pss = SRSLTE_DEFAULT_MAX_FRAMES_PSS, - .nof_valid_pss_frames = SRSLTE_DEFAULT_NOF_VALID_PSS_FRAMES, +cell_search_cfg_t cell_detect_config = {.max_frames_pbch = SRSRAN_DEFAULT_MAX_FRAMES_PBCH, + .max_frames_pss = SRSRAN_DEFAULT_MAX_FRAMES_PSS, + .nof_valid_pss_frames = SRSRAN_DEFAULT_NOF_VALID_PSS_FRAMES, .init_agc = 0, .force_tdd = false}; @@ -108,7 +108,7 @@ void args_default(prog_args_t* args) args->disable_plots = false; args->disable_plots_except_constellation = false; args->nof_subframes = -1; - args->rnti = SRSLTE_SIRNTI; + args->rnti = SRSRAN_SIRNTI; args->force_N_id_2 = -1; // Pick the best args->tdd_special_sf = -1; args->sf_config = -1; @@ -188,7 +188,7 @@ void usage(prog_args_t* args, char* prog) printf("\t-N Non-MBSFN region [Default %d]\n", args->non_mbsfn_region); printf("\t-q Enable/Disable 256QAM modulation (default %s)\n", args->enable_256qam ? "enabled" : "disabled"); printf("\t-Q Use standard LTE sample rates (default %s)\n", args->use_standard_lte_rate ? "enabled" : "disabled"); - printf("\t-v [set srslte_verbose to debug, default none]\n"); + printf("\t-v [set srsran_verbose to debug, default none]\n"); } void parse_args(prog_args_t* args, int argc, char** argv) @@ -277,8 +277,8 @@ void parse_args(prog_args_t* args, int argc, char** argv) args->disable_plots_except_constellation = true; break; case 'v': - srslte_verbose++; - args->verbose = srslte_verbose; + srsran_verbose++; + args->verbose = srsran_verbose; break; case 'Z': args->decimate = (int)strtol(argv[optind], NULL, 10); @@ -317,7 +317,7 @@ void parse_args(prog_args_t* args, int argc, char** argv) /**********************************************************************/ -uint8_t* data[SRSLTE_MAX_CODEWORDS]; +uint8_t* data[SRSRAN_MAX_CODEWORDS]; bool go_exit = false; @@ -331,23 +331,23 @@ void sig_int_handler(int signo) } } -cf_t* sf_buffer[SRSLTE_MAX_PORTS] = {NULL}; +cf_t* sf_buffer[SRSRAN_MAX_PORTS] = {NULL}; #ifndef DISABLE_RF -int srslte_rf_recv_wrapper(void* h, cf_t* data_[SRSLTE_MAX_PORTS], uint32_t nsamples, srslte_timestamp_t* t) +int srsran_rf_recv_wrapper(void* h, cf_t* data_[SRSRAN_MAX_PORTS], uint32_t nsamples, srsran_timestamp_t* t) { DEBUG(" ---- Receive %d samples ----", nsamples); - void* ptr[SRSLTE_MAX_PORTS]; - for (int i = 0; i < SRSLTE_MAX_PORTS; i++) { + void* ptr[SRSRAN_MAX_PORTS]; + for (int i = 0; i < SRSRAN_MAX_PORTS; i++) { ptr[i] = data_[i]; } - return srslte_rf_recv_with_time_multi(h, ptr, nsamples, true, NULL, NULL); + return srsran_rf_recv_with_time_multi(h, ptr, nsamples, true, NULL, NULL); } -static SRSLTE_AGC_CALLBACK(srslte_rf_set_rx_gain_th_wrapper_) +static SRSRAN_AGC_CALLBACK(srsran_rf_set_rx_gain_th_wrapper_) { - srslte_rf_set_rx_gain_th((srslte_rf_t*)h, gain_db); + srsran_rf_set_rx_gain_th((srsran_rf_t*)h, gain_db); } #endif @@ -356,18 +356,18 @@ extern float mean_exec_time; enum receiver_state { DECODE_MIB, DECODE_PDSCH } state; -srslte_cell_t cell; -srslte_ue_dl_t ue_dl; -srslte_ue_dl_cfg_t ue_dl_cfg; -srslte_dl_sf_cfg_t dl_sf; -srslte_pdsch_cfg_t pdsch_cfg; -srslte_ue_sync_t ue_sync; +srsran_cell_t cell; +srsran_ue_dl_t ue_dl; +srsran_ue_dl_cfg_t ue_dl_cfg; +srsran_dl_sf_cfg_t dl_sf; +srsran_pdsch_cfg_t pdsch_cfg; +srsran_ue_sync_t ue_sync; prog_args_t prog_args; uint32_t pkt_errors = 0, pkt_total = 0, nof_detected = 0, pmch_pkt_errors = 0, pmch_pkt_total = 0, nof_trials = 0; double evm = 0.0; -srslte_netsink_t net_sink, net_sink_signal; +srsran_netsink_t net_sink, net_sink_signal; /* Useful macros for printing lines which will disappear */ #define PRINT_LINE_INIT() \ @@ -386,14 +386,14 @@ int main(int argc, char** argv) int ret; #ifndef DISABLE_RF - srslte_rf_t rf; + srsran_rf_t rf; #endif - srslte_debug_handle_crash(argc, argv); + srsran_debug_handle_crash(argc, argv); parse_args(&prog_args, argc, argv); - srslte_use_standard_symbol_size(prog_args.use_standard_lte_rate); + srsran_use_standard_symbol_size(prog_args.use_standard_lte_rate); #ifdef ENABLE_GUI if (prog_args.mbsfn_area_id > -1) { @@ -401,8 +401,8 @@ int main(int argc, char** argv) } #endif /* ENABLE_GUI */ - for (int i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { - data[i] = srslte_vec_u8_malloc(2000 * 8); + for (int i = 0; i < SRSRAN_MAX_CODEWORDS; i++) { + data[i] = srsran_vec_u8_malloc(2000 * 8); if (!data[i]) { ERROR("Allocating data"); go_exit = true; @@ -432,19 +432,19 @@ int main(int argc, char** argv) } if (prog_args.net_port > 0) { - if (srslte_netsink_init(&net_sink, prog_args.net_address, prog_args.net_port, SRSLTE_NETSINK_UDP)) { + if (srsran_netsink_init(&net_sink, prog_args.net_address, prog_args.net_port, SRSRAN_NETSINK_UDP)) { ERROR("Error initiating UDP socket to %s:%d", prog_args.net_address, prog_args.net_port); exit(-1); } - srslte_netsink_set_nonblocking(&net_sink); + srsran_netsink_set_nonblocking(&net_sink); } if (prog_args.net_port_signal > 0) { - if (srslte_netsink_init( - &net_sink_signal, prog_args.net_address_signal, prog_args.net_port_signal, SRSLTE_NETSINK_UDP)) { + if (srsran_netsink_init( + &net_sink_signal, prog_args.net_address_signal, prog_args.net_port_signal, SRSRAN_NETSINK_UDP)) { ERROR("Error initiating UDP socket to %s:%d", prog_args.net_address_signal, prog_args.net_port_signal); exit(-1); } - srslte_netsink_set_nonblocking(&net_sink_signal); + srsran_netsink_set_nonblocking(&net_sink_signal); } float search_cell_cfo = 0; @@ -452,21 +452,21 @@ int main(int argc, char** argv) #ifndef DISABLE_RF if (!prog_args.input_file_name) { printf("Opening RF device with %d RX antennas...\n", prog_args.rf_nof_rx_ant); - if (srslte_rf_open_devname(&rf, prog_args.rf_dev, prog_args.rf_args, prog_args.rf_nof_rx_ant)) { + if (srsran_rf_open_devname(&rf, prog_args.rf_dev, prog_args.rf_args, prog_args.rf_nof_rx_ant)) { fprintf(stderr, "Error opening rf\n"); exit(-1); } /* Set receiver gain */ if (prog_args.rf_gain > 0) { - srslte_rf_set_rx_gain(&rf, prog_args.rf_gain); + srsran_rf_set_rx_gain(&rf, prog_args.rf_gain); } else { printf("Starting AGC thread...\n"); - if (srslte_rf_start_gain_thread(&rf, false)) { + if (srsran_rf_start_gain_thread(&rf, false)) { ERROR("Error opening rf"); exit(-1); } - srslte_rf_set_rx_gain(&rf, srslte_rf_get_rx_gain(&rf)); - cell_detect_config.init_agc = srslte_rf_get_rx_gain(&rf); + srsran_rf_set_rx_gain(&rf, srsran_rf_get_rx_gain(&rf)); + cell_detect_config.init_agc = srsran_rf_get_rx_gain(&rf); } sigset_t sigset; @@ -477,7 +477,7 @@ int main(int argc, char** argv) /* set receiver frequency */ printf("Tunning receiver to %.3f MHz\n", (prog_args.rf_freq + prog_args.file_offset_freq) / 1000000); - srslte_rf_set_rx_freq(&rf, prog_args.rf_nof_rx_ant, prog_args.rf_freq + prog_args.file_offset_freq); + srsran_rf_set_rx_freq(&rf, prog_args.rf_nof_rx_ant, prog_args.rf_freq + prog_args.file_offset_freq); uint32_t ntrial = 0; do { @@ -492,15 +492,15 @@ int main(int argc, char** argv) } while (ret == 0 && !go_exit); if (go_exit) { - srslte_rf_close(&rf); + srsran_rf_close(&rf); exit(0); } /* set sampling frequency */ - int srate = srslte_sampling_freq_hz(cell.nof_prb); + int srate = srsran_sampling_freq_hz(cell.nof_prb); if (srate != -1) { printf("Setting sampling rate %.2f MHz\n", (float)srate / 1000000); - float srate_rf = srslte_rf_set_rx_srate(&rf, (double)srate); + float srate_rf = srsran_rf_set_rx_srate(&rf, (double)srate); if (srate_rf != srate) { ERROR("Could not set sampling rate"); exit(-1); @@ -518,13 +518,13 @@ int main(int argc, char** argv) if (prog_args.input_file_name) { /* preset cell configuration */ cell.id = prog_args.file_cell_id; - cell.cp = SRSLTE_CP_NORM; - cell.phich_length = SRSLTE_PHICH_NORM; - cell.phich_resources = SRSLTE_PHICH_R_1; + cell.cp = SRSRAN_CP_NORM; + cell.phich_length = SRSRAN_PHICH_NORM; + cell.phich_resources = SRSRAN_PHICH_R_1; cell.nof_ports = prog_args.file_nof_ports; cell.nof_prb = prog_args.file_nof_prb; - if (srslte_ue_sync_init_file_multi(&ue_sync, + if (srsran_ue_sync_init_file_multi(&ue_sync, prog_args.file_nof_prb, prog_args.input_file_name, prog_args.file_offset_time, @@ -544,42 +544,42 @@ int main(int argc, char** argv) decimate = prog_args.decimate; } } - if (srslte_ue_sync_init_multi_decim(&ue_sync, + if (srsran_ue_sync_init_multi_decim(&ue_sync, cell.nof_prb, cell.id == 1000, - srslte_rf_recv_wrapper, + srsran_rf_recv_wrapper, prog_args.rf_nof_rx_ant, (void*)&rf, decimate)) { ERROR("Error initiating ue_sync"); exit(-1); } - if (srslte_ue_sync_set_cell(&ue_sync, cell)) { + if (srsran_ue_sync_set_cell(&ue_sync, cell)) { ERROR("Error initiating ue_sync"); exit(-1); } #endif } - uint32_t max_num_samples = 3 * SRSLTE_SF_LEN_PRB(cell.nof_prb); /// Length in complex samples + uint32_t max_num_samples = 3 * SRSRAN_SF_LEN_PRB(cell.nof_prb); /// Length in complex samples for (int i = 0; i < prog_args.rf_nof_rx_ant; i++) { - sf_buffer[i] = srslte_vec_cf_malloc(max_num_samples); + sf_buffer[i] = srsran_vec_cf_malloc(max_num_samples); } - srslte_ue_mib_t ue_mib; - if (srslte_ue_mib_init(&ue_mib, sf_buffer[0], cell.nof_prb)) { + srsran_ue_mib_t ue_mib; + if (srsran_ue_mib_init(&ue_mib, sf_buffer[0], cell.nof_prb)) { ERROR("Error initaiting UE MIB decoder"); exit(-1); } - if (srslte_ue_mib_set_cell(&ue_mib, cell)) { + if (srsran_ue_mib_set_cell(&ue_mib, cell)) { ERROR("Error initaiting UE MIB decoder"); exit(-1); } - if (srslte_ue_dl_init(&ue_dl, sf_buffer, cell.nof_prb, prog_args.rf_nof_rx_ant)) { + if (srsran_ue_dl_init(&ue_dl, sf_buffer, cell.nof_prb, prog_args.rf_nof_rx_ant)) { ERROR("Error initiating UE downlink processing module"); exit(-1); } - if (srslte_ue_dl_set_cell(&ue_dl, cell)) { + if (srsran_ue_dl_set_cell(&ue_dl, cell)) { ERROR("Error initiating UE downlink processing module"); exit(-1); } @@ -588,7 +588,7 @@ int main(int argc, char** argv) ue_sync.cfo_current_value = search_cell_cfo / 15000; ue_sync.cfo_is_copied = true; ue_sync.cfo_correct_enable_find = true; - srslte_sync_set_cfo_cp_enable(&ue_sync.sfind, false, 0); + srsran_sync_set_cfo_cp_enable(&ue_sync.sfind, false, 0); ZERO_OBJECT(ue_dl_cfg); ZERO_OBJECT(dl_sf); @@ -596,38 +596,38 @@ int main(int argc, char** argv) pdsch_cfg.meas_evm_en = true; - if (cell.frame_type == SRSLTE_TDD && prog_args.tdd_special_sf >= 0 && prog_args.sf_config >= 0) { + if (cell.frame_type == SRSRAN_TDD && prog_args.tdd_special_sf >= 0 && prog_args.sf_config >= 0) { dl_sf.tdd_config.ss_config = prog_args.tdd_special_sf; dl_sf.tdd_config.sf_config = prog_args.sf_config; dl_sf.tdd_config.configured = true; } - srslte_chest_dl_cfg_t chest_pdsch_cfg = {}; + srsran_chest_dl_cfg_t chest_pdsch_cfg = {}; chest_pdsch_cfg.cfo_estimate_enable = prog_args.enable_cfo_ref; chest_pdsch_cfg.cfo_estimate_sf_mask = 1023; - chest_pdsch_cfg.estimator_alg = srslte_chest_dl_str2estimator_alg(prog_args.estimator_alg); + chest_pdsch_cfg.estimator_alg = srsran_chest_dl_str2estimator_alg(prog_args.estimator_alg); chest_pdsch_cfg.sync_error_enable = true; // Special configuration for MBSFN channel estimation - srslte_chest_dl_cfg_t chest_mbsfn_cfg = {}; - chest_mbsfn_cfg.filter_type = SRSLTE_CHEST_FILTER_TRIANGLE; + srsran_chest_dl_cfg_t chest_mbsfn_cfg = {}; + chest_mbsfn_cfg.filter_type = SRSRAN_CHEST_FILTER_TRIANGLE; chest_mbsfn_cfg.filter_coef[0] = 0.1; - chest_mbsfn_cfg.estimator_alg = SRSLTE_ESTIMATOR_ALG_INTERPOLATE; - chest_mbsfn_cfg.noise_alg = SRSLTE_NOISE_ALG_PSS; + chest_mbsfn_cfg.estimator_alg = SRSRAN_ESTIMATOR_ALG_INTERPOLATE; + chest_mbsfn_cfg.noise_alg = SRSRAN_NOISE_ALG_PSS; // Allocate softbuffer buffers - srslte_softbuffer_rx_t rx_softbuffers[SRSLTE_MAX_CODEWORDS]; - for (uint32_t i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { + srsran_softbuffer_rx_t rx_softbuffers[SRSRAN_MAX_CODEWORDS]; + for (uint32_t i = 0; i < SRSRAN_MAX_CODEWORDS; i++) { pdsch_cfg.softbuffers.rx[i] = &rx_softbuffers[i]; - srslte_softbuffer_rx_init(pdsch_cfg.softbuffers.rx[i], cell.nof_prb); + srsran_softbuffer_rx_init(pdsch_cfg.softbuffers.rx[i], cell.nof_prb); } pdsch_cfg.rnti = prog_args.rnti; /* Configure MBSFN area id and non-MBSFN Region */ if (prog_args.mbsfn_area_id > -1) { - srslte_ue_dl_set_mbsfn_area_id(&ue_dl, prog_args.mbsfn_area_id); - srslte_ue_dl_set_non_mbsfn_region(&ue_dl, prog_args.non_mbsfn_region); + srsran_ue_dl_set_mbsfn_area_id(&ue_dl, prog_args.mbsfn_area_id); + srsran_ue_dl_set_non_mbsfn_region(&ue_dl, prog_args.non_mbsfn_region); } #ifdef ENABLE_GUI @@ -639,39 +639,39 @@ int main(int argc, char** argv) #ifndef DISABLE_RF if (!prog_args.input_file_name) { - srslte_rf_start_rx_stream(&rf, false); + srsran_rf_start_rx_stream(&rf, false); } #endif #ifndef DISABLE_RF if (prog_args.rf_gain < 0 && !prog_args.input_file_name) { - srslte_rf_info_t* rf_info = srslte_rf_get_info(&rf); - srslte_ue_sync_start_agc(&ue_sync, - srslte_rf_set_rx_gain_th_wrapper_, + srsran_rf_info_t* rf_info = srsran_rf_get_info(&rf); + srsran_ue_sync_start_agc(&ue_sync, + srsran_rf_set_rx_gain_th_wrapper_, rf_info->min_rx_gain, rf_info->max_rx_gain, cell_detect_config.init_agc); } #endif #ifdef PRINT_CHANGE_SCHEDULING - srslte_ra_dl_grant_t old_dl_dci; - bzero(&old_dl_dci, sizeof(srslte_ra_dl_grant_t)); + srsran_ra_dl_grant_t old_dl_dci; + bzero(&old_dl_dci, sizeof(srsran_ra_dl_grant_t)); #endif ue_sync.cfo_correct_enable_track = !prog_args.disable_cfo; - srslte_pbch_decode_reset(&ue_mib.pbch); + srsran_pbch_decode_reset(&ue_mib.pbch); INFO("\nEntering main loop..."); // Variables for measurements uint32_t nframes = 0; float rsrp0 = 0.0, rsrp1 = 0.0, rsrq = 0.0, snr = 0.0, enodebrate = 0.0, uerate = 0.0, procrate = 0.0, - sinr[SRSLTE_MAX_LAYERS][SRSLTE_MAX_CODEBOOKS] = {}, sync_err[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS] = {}; + sinr[SRSRAN_MAX_LAYERS][SRSRAN_MAX_CODEBOOKS] = {}, sync_err[SRSRAN_MAX_PORTS][SRSRAN_MAX_PORTS] = {}; bool decode_pdsch = false; - for (int i = 0; i < SRSLTE_MAX_LAYERS; i++) { - srslte_vec_f_zero(sinr[i], SRSLTE_MAX_CODEBOOKS); + for (int i = 0; i < SRSRAN_MAX_LAYERS; i++) { + srsran_vec_f_zero(sinr[i], SRSRAN_MAX_CODEBOOKS); } /* Main loop */ @@ -691,12 +691,12 @@ int main(int argc, char** argv) to.tv_usec = 0; /* Set default verbose level */ - srslte_verbose = prog_args.verbose; + srsran_verbose = prog_args.verbose; int n = select(1, &set, NULL, NULL, &to); if (n == 1) { /* If a new line is detected set verbose level to Debug */ if (fgets(input, sizeof(input), stdin)) { - srslte_verbose = SRSLTE_VERBOSE_DEBUG; + srsran_verbose = SRSRAN_VERBOSE_DEBUG; pkt_errors = 0; pkt_total = 0; nof_detected = 0; @@ -704,40 +704,40 @@ int main(int argc, char** argv) } } - cf_t* buffers[SRSLTE_MAX_CHANNELS] = {}; - for (int p = 0; p < SRSLTE_MAX_PORTS; p++) { + cf_t* buffers[SRSRAN_MAX_CHANNELS] = {}; + for (int p = 0; p < SRSRAN_MAX_PORTS; p++) { buffers[p] = sf_buffer[p]; } - ret = srslte_ue_sync_zerocopy(&ue_sync, buffers, max_num_samples); + ret = srsran_ue_sync_zerocopy(&ue_sync, buffers, max_num_samples); if (ret < 0) { - ERROR("Error calling srslte_ue_sync_work()"); + ERROR("Error calling srsran_ue_sync_work()"); } #ifdef CORRECT_SAMPLE_OFFSET float sample_offset = - (float)srslte_ue_sync_get_last_sample_offset(&ue_sync) + srslte_ue_sync_get_sfo(&ue_sync) / 1000; - srslte_ue_dl_set_sample_offset(&ue_dl, sample_offset); + (float)srsran_ue_sync_get_last_sample_offset(&ue_sync) + srsran_ue_sync_get_sfo(&ue_sync) / 1000; + srsran_ue_dl_set_sample_offset(&ue_dl, sample_offset); #endif - /* srslte_ue_sync_get_buffer returns 1 if successfully read 1 aligned subframe */ + /* srsran_ue_sync_get_buffer returns 1 if successfully read 1 aligned subframe */ if (ret == 1) { - bool acks[SRSLTE_MAX_CODEWORDS] = {false}; + bool acks[SRSRAN_MAX_CODEWORDS] = {false}; struct timeval t[3]; - uint32_t sf_idx = srslte_ue_sync_get_sfidx(&ue_sync); + uint32_t sf_idx = srsran_ue_sync_get_sfidx(&ue_sync); switch (state) { case DECODE_MIB: if (sf_idx == 0) { - uint8_t bch_payload[SRSLTE_BCH_PAYLOAD_LEN]; + uint8_t bch_payload[SRSRAN_BCH_PAYLOAD_LEN]; int sfn_offset; - n = srslte_ue_mib_decode(&ue_mib, bch_payload, NULL, &sfn_offset); + n = srsran_ue_mib_decode(&ue_mib, bch_payload, NULL, &sfn_offset); if (n < 0) { ERROR("Error decoding UE MIB"); exit(-1); - } else if (n == SRSLTE_UE_MIB_FOUND) { - srslte_pbch_mib_unpack(bch_payload, &cell, &sfn); - srslte_cell_fprint(stdout, &cell, sfn); + } else if (n == SRSRAN_UE_MIB_FOUND) { + srsran_pbch_mib_unpack(bch_payload, &cell, &sfn); + srsran_cell_fprint(stdout, &cell, sfn); printf("Decoded MIB. SFN: %d, offset: %d\n", sfn, sfn_offset); sfn = (sfn + sfn_offset) % 1024; state = DECODE_PDSCH; @@ -746,9 +746,9 @@ int main(int argc, char** argv) break; case DECODE_PDSCH: - if (prog_args.rnti != SRSLTE_SIRNTI) { + if (prog_args.rnti != SRSRAN_SIRNTI) { decode_pdsch = true; - if (srslte_sfidx_tdd_type(dl_sf.tdd_config, sf_idx) == SRSLTE_TDD_SF_U) { + if (srsran_sfidx_tdd_type(dl_sf.tdd_config, sf_idx) == SRSRAN_TDD_SF_U) { decode_pdsch = false; } } else { @@ -764,14 +764,14 @@ int main(int argc, char** argv) gettimeofday(&t[1], NULL); if (decode_pdsch) { - srslte_sf_t sf_type; + srsran_sf_t sf_type; if (mch_table[sf_idx] == 0 || prog_args.mbsfn_area_id < 0) { // Not an MBSFN subframe - sf_type = SRSLTE_SF_NORM; + sf_type = SRSRAN_SF_NORM; // Set PDSCH channel estimation ue_dl_cfg.chest_cfg = chest_pdsch_cfg; } else { - sf_type = SRSLTE_SF_MBSFN; + sf_type = SRSRAN_SF_MBSFN; // Set MBSFN channel estimation ue_dl_cfg.chest_cfg = chest_mbsfn_cfg; @@ -781,25 +781,25 @@ int main(int argc, char** argv) for (uint32_t tm = 0; tm < 4 && !n; tm++) { dl_sf.tti = tti; dl_sf.sf_type = sf_type; - ue_dl_cfg.cfg.tm = (srslte_tm_t)tm; + ue_dl_cfg.cfg.tm = (srsran_tm_t)tm; ue_dl_cfg.cfg.pdsch.use_tbs_index_alt = prog_args.enable_256qam; - if ((ue_dl_cfg.cfg.tm == SRSLTE_TM1 && cell.nof_ports == 1) || - (ue_dl_cfg.cfg.tm > SRSLTE_TM1 && cell.nof_ports > 1)) { - n = srslte_ue_dl_find_and_decode(&ue_dl, &dl_sf, &ue_dl_cfg, &pdsch_cfg, data, acks); + if ((ue_dl_cfg.cfg.tm == SRSRAN_TM1 && cell.nof_ports == 1) || + (ue_dl_cfg.cfg.tm > SRSRAN_TM1 && cell.nof_ports > 1)) { + n = srsran_ue_dl_find_and_decode(&ue_dl, &dl_sf, &ue_dl_cfg, &pdsch_cfg, data, acks); if (n > 0) { nof_detected++; last_decoded_tm = tm; - for (uint32_t tb = 0; tb < SRSLTE_MAX_CODEWORDS; tb++) { + for (uint32_t tb = 0; tb < SRSRAN_MAX_CODEWORDS; tb++) { if (pdsch_cfg.grant.tb[tb].enabled) { if (!acks[tb]) { - if (sf_type == SRSLTE_SF_NORM) { + if (sf_type == SRSRAN_SF_NORM) { pkt_errors++; } else { pmch_pkt_errors++; } } - if (sf_type == SRSLTE_SF_NORM) { + if (sf_type == SRSRAN_SF_NORM) { pkt_total++; } else { pmch_pkt_total++; @@ -811,7 +811,7 @@ int main(int argc, char** argv) } // Feed-back ue_sync with chest_dl CFO estimation if (sf_idx == 5 && prog_args.enable_cfo_ref) { - srslte_ue_sync_set_cfo_ref(&ue_sync, ue_dl.chest_res.cfo); + srsran_ue_sync_set_cfo_ref(&ue_sync, ue_dl.chest_res.cfo); } gettimeofday(&t[2], NULL); @@ -821,25 +821,25 @@ int main(int argc, char** argv) /* Send data if socket active */ if (prog_args.net_port > 0) { if (sf_idx == 1) { - srslte_netsink_write(&net_sink, data[0], 1 + (n - 1) / 8); + srsran_netsink_write(&net_sink, data[0], 1 + (n - 1) / 8); } else { // TODO: UDP Data transmission does not work - for (uint32_t tb = 0; tb < SRSLTE_MAX_CODEWORDS; tb++) { + for (uint32_t tb = 0; tb < SRSRAN_MAX_CODEWORDS; tb++) { if (pdsch_cfg.grant.tb[tb].enabled) { - srslte_netsink_write(&net_sink, data[tb], 1 + (pdsch_cfg.grant.tb[tb].tbs - 1) / 8); + srsran_netsink_write(&net_sink, data[tb], 1 + (pdsch_cfg.grant.tb[tb].tbs - 1) / 8); } } } } #ifdef PRINT_CHANGE_SCHEDULING if (pdsch_cfg.dci.cw[0].mcs_idx != old_dl_dci.cw[0].mcs_idx || - memcmp(&pdsch_cfg.dci.type0_alloc, &old_dl_dci.type0_alloc, sizeof(srslte_ra_type0_t)) || - memcmp(&pdsch_cfg.dci.type1_alloc, &old_dl_dci.type1_alloc, sizeof(srslte_ra_type1_t)) || - memcmp(&pdsch_cfg.dci.type2_alloc, &old_dl_dci.type2_alloc, sizeof(srslte_ra_type2_t))) { + memcmp(&pdsch_cfg.dci.type0_alloc, &old_dl_dci.type0_alloc, sizeof(srsran_ra_type0_t)) || + memcmp(&pdsch_cfg.dci.type1_alloc, &old_dl_dci.type1_alloc, sizeof(srsran_ra_type1_t)) || + memcmp(&pdsch_cfg.dci.type2_alloc, &old_dl_dci.type2_alloc, sizeof(srsran_ra_type2_t))) { old_dl_dci = pdsch_cfg.dci; fflush(stdout); - printf("DCI %s\n", srslte_dci_format_string(pdsch_cfg.dci.dci_format)); - srslte_ra_pdsch_fprint(stdout, &old_dl_dci, cell.nof_prb); + printf("DCI %s\n", srsran_dci_format_string(pdsch_cfg.dci.dci_format)); + srsran_ra_pdsch_fprint(stdout, &old_dl_dci, cell.nof_prb); } #endif } @@ -849,16 +849,16 @@ int main(int argc, char** argv) uint32_t enb_bits = ((pdsch_cfg.grant.tb[0].enabled ? pdsch_cfg.grant.tb[0].tbs : 0) + (pdsch_cfg.grant.tb[1].enabled ? pdsch_cfg.grant.tb[1].tbs : 0)); uint32_t ue_bits = ((acks[0] ? pdsch_cfg.grant.tb[0].tbs : 0) + (acks[1] ? pdsch_cfg.grant.tb[1].tbs : 0)); - rsrq = SRSLTE_VEC_EMA(ue_dl.chest_res.rsrp_dbm, rsrq, 0.1f); - rsrp0 = SRSLTE_VEC_EMA(ue_dl.chest_res.rsrp_port_dbm[0], rsrp0, 0.05f); - rsrp1 = SRSLTE_VEC_EMA(ue_dl.chest_res.rsrp_port_dbm[1], rsrp1, 0.05f); - snr = SRSLTE_VEC_EMA(ue_dl.chest_res.snr_db, snr, 0.05f); - enodebrate = SRSLTE_VEC_EMA(enb_bits / 1000.0f, enodebrate, 0.05f); - uerate = SRSLTE_VEC_EMA(ue_bits / 1000.0f, uerate, 0.001f); + rsrq = SRSRAN_VEC_EMA(ue_dl.chest_res.rsrp_dbm, rsrq, 0.1f); + rsrp0 = SRSRAN_VEC_EMA(ue_dl.chest_res.rsrp_port_dbm[0], rsrp0, 0.05f); + rsrp1 = SRSRAN_VEC_EMA(ue_dl.chest_res.rsrp_port_dbm[1], rsrp1, 0.05f); + snr = SRSRAN_VEC_EMA(ue_dl.chest_res.snr_db, snr, 0.05f); + enodebrate = SRSRAN_VEC_EMA(enb_bits / 1000.0f, enodebrate, 0.05f); + uerate = SRSRAN_VEC_EMA(ue_bits / 1000.0f, uerate, 0.001f); if (chest_pdsch_cfg.sync_error_enable) { for (uint32_t i = 0; i < cell.nof_ports; i++) { for (uint32_t j = 0; j < prog_args.rf_nof_rx_ant; j++) { - sync_err[i][j] = SRSLTE_VEC_EMA(ue_dl.chest.sync_err[i][j], sync_err[i][j], 0.001f); + sync_err[i][j] = SRSRAN_VEC_EMA(ue_dl.chest.sync_err[i][j], sync_err[i][j], 0.001f); if (!isnormal(sync_err[i][j])) { sync_err[i][j] = 0.0f; } @@ -867,7 +867,7 @@ int main(int argc, char** argv) } float elapsed = (float)t[0].tv_usec + t[0].tv_sec * 1.0e+6f; if (elapsed != 0.0f) { - procrate = SRSLTE_VEC_EMA(ue_bits / elapsed, procrate, 0.01f); + procrate = SRSRAN_VEC_EMA(ue_bits / elapsed, procrate, 0.01f); } nframes++; @@ -889,13 +889,13 @@ int main(int argc, char** argv) if (sf_idx == 5) { float gain = prog_args.rf_gain; if (gain < 0) { - gain = srslte_convert_power_to_dB(srslte_agc_get_gain(&ue_sync.agc)); + gain = srsran_convert_power_to_dB(srsran_agc_get_gain(&ue_sync.agc)); } /* Print transmission scheme */ /* Print basic Parameters */ - PRINT_LINE(" CFO: %+7.2f Hz", srslte_ue_sync_get_cfo(&ue_sync)); + PRINT_LINE(" CFO: %+7.2f Hz", srsran_ue_sync_get_cfo(&ue_sync)); PRINT_LINE(" RSRP: %+5.1f dBm | %+5.1f dBm", rsrp0, rsrp1); PRINT_LINE(" SNR: %+5.1f dB", snr); PRINT_LINE(" TM: %d", last_decoded_tm + 1); @@ -917,7 +917,7 @@ int main(int argc, char** argv) uint32_t ri = 0; float cn = 0; /* Compute condition number */ - if (srslte_ue_dl_select_ri(&ue_dl, &ri, &cn)) { + if (srsran_ue_dl_select_ri(&ue_dl, &ri, &cn)) { /* Condition number calculation is not supported for the number of tx & rx antennas*/ PRINT_LINE(" κ: NA"); } else { @@ -962,12 +962,12 @@ int main(int argc, char** argv) #endif /* ENABLE_GUI */ } else if (ret == 0) { printf("Finding PSS... Peak: %8.1f, FrameCnt: %d, State: %d\r", - srslte_sync_get_peak_value(&ue_sync.sfind), + srsran_sync_get_peak_value(&ue_sync.sfind), ue_sync.frame_total_cnt, ue_sync.state); #ifdef ENABLE_GUI if (!prog_args.disable_plots) { - plot_sf_idx = srslte_ue_sync_get_sfidx(&ue_sync); + plot_sf_idx = srsran_ue_sync_get_sfidx(&ue_sync); plot_track = false; sem_post(&plot_sem); } @@ -985,9 +985,9 @@ int main(int argc, char** argv) } } #endif - srslte_ue_dl_free(&ue_dl); - srslte_ue_sync_free(&ue_sync); - for (int i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { + srsran_ue_dl_free(&ue_dl); + srsran_ue_sync_free(&ue_sync); + for (int i = 0; i < SRSRAN_MAX_CODEWORDS; i++) { if (data[i]) { free(data[i]); } @@ -1000,8 +1000,8 @@ int main(int argc, char** argv) #ifndef DISABLE_RF if (!prog_args.input_file_name) { - srslte_ue_mib_free(&ue_mib); - srslte_rf_close(&rf); + srsran_ue_mib_free(&ue_mib); + srsran_rf_close(&rf); } #endif @@ -1023,7 +1023,7 @@ static float tmp_plot2[110 * 15 * 2048]; void* plot_thread_run(void* arg) { int i; - uint32_t nof_re = SRSLTE_SF_LEN_RE(ue_dl.cell.nof_prb, ue_dl.cell.cp); + uint32_t nof_re = SRSRAN_SF_LEN_RE(ue_dl.cell.nof_prb, ue_dl.cell.cp); sdrgui_init(); @@ -1068,18 +1068,18 @@ void* plot_thread_run(void* arg) uint32_t nof_symbols = pdsch_cfg.grant.nof_re; if (!prog_args.disable_plots_except_constellation) { for (i = 0; i < nof_re; i++) { - tmp_plot[i] = srslte_convert_amplitude_to_dB(cabsf(ue_dl.sf_symbols[0][i])); + tmp_plot[i] = srsran_convert_amplitude_to_dB(cabsf(ue_dl.sf_symbols[0][i])); if (isinf(tmp_plot[i])) { tmp_plot[i] = -80; } } - int sz = srslte_symbol_sz(ue_dl.cell.nof_prb); + int sz = srsran_symbol_sz(ue_dl.cell.nof_prb); if (sz > 0) { - srslte_vec_f_zero(tmp_plot2, sz); + srsran_vec_f_zero(tmp_plot2, sz); } int g = (sz - 12 * ue_dl.cell.nof_prb) / 2; for (i = 0; i < 12 * ue_dl.cell.nof_prb; i++) { - tmp_plot2[g + i] = srslte_convert_amplitude_to_dB(cabsf(ue_dl.chest_res.ce[0][0][i])); + tmp_plot2[g + i] = srsran_convert_amplitude_to_dB(cabsf(ue_dl.chest_res.ce[0][0][i])); if (isinf(tmp_plot2[g + i])) { tmp_plot2[g + i] = -80; } @@ -1088,17 +1088,17 @@ void* plot_thread_run(void* arg) if (!prog_args.input_file_name) { if (plot_track) { - srslte_pss_t* pss_obj = srslte_sync_get_cur_pss_obj(&ue_sync.strack); - int max = srslte_vec_max_fi(pss_obj->conv_output_avg, pss_obj->frame_size + pss_obj->fft_size - 1); - srslte_vec_sc_prod_fff(pss_obj->conv_output_avg, + srsran_pss_t* pss_obj = srsran_sync_get_cur_pss_obj(&ue_sync.strack); + int max = srsran_vec_max_fi(pss_obj->conv_output_avg, pss_obj->frame_size + pss_obj->fft_size - 1); + srsran_vec_sc_prod_fff(pss_obj->conv_output_avg, 1 / pss_obj->conv_output_avg[max], tmp_plot2, pss_obj->frame_size + pss_obj->fft_size - 1); plot_real_setNewData(&p_sync, tmp_plot2, pss_obj->frame_size); } else { - int max = srslte_vec_max_fi(ue_sync.sfind.pss.conv_output_avg, + int max = srsran_vec_max_fi(ue_sync.sfind.pss.conv_output_avg, ue_sync.sfind.pss.frame_size + ue_sync.sfind.pss.fft_size - 1); - srslte_vec_sc_prod_fff(ue_sync.sfind.pss.conv_output_avg, + srsran_vec_sc_prod_fff(ue_sync.sfind.pss.conv_output_avg, 1 / ue_sync.sfind.pss.conv_output_avg[max], tmp_plot2, ue_sync.sfind.pss.frame_size + ue_sync.sfind.pss.fft_size - 1); @@ -1117,8 +1117,8 @@ void* plot_thread_run(void* arg) if (plot_sf_idx == 1) { if (prog_args.net_port_signal > 0) { - srslte_netsink_write( - &net_sink_signal, &sf_buffer[srslte_ue_sync_sf_len(&ue_sync) / 7], srslte_ue_sync_sf_len(&ue_sync)); + srsran_netsink_write( + &net_sink_signal, &sf_buffer[srsran_ue_sync_sf_len(&ue_sync) / 7], srsran_ue_sync_sf_len(&ue_sync)); } } } diff --git a/lib/examples/pssch_ue.c b/lib/examples/pssch_ue.c index 954c5bfaf..610ae6e87 100644 --- a/lib/examples/pssch_ue.c +++ b/lib/examples/pssch_ue.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -18,25 +18,25 @@ #include #include -#include "srslte/common/pcap.h" -#include "srslte/phy/ch_estimation/chest_sl.h" -#include "srslte/phy/common/phy_common_sl.h" -#include "srslte/phy/dft/ofdm.h" -#include "srslte/phy/phch/pscch.h" -#include "srslte/phy/phch/pssch.h" -#include "srslte/phy/phch/ra_sl.h" -#include "srslte/phy/phch/sci.h" -#include "srslte/phy/rf/rf.h" -#include "srslte/phy/ue/ue_sync.h" -#include "srslte/phy/utils/bit.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/common/pcap.h" +#include "srsran/phy/ch_estimation/chest_sl.h" +#include "srsran/phy/common/phy_common_sl.h" +#include "srsran/phy/dft/ofdm.h" +#include "srsran/phy/phch/pscch.h" +#include "srsran/phy/phch/pssch.h" +#include "srsran/phy/phch/ra_sl.h" +#include "srsran/phy/phch/sci.h" +#include "srsran/phy/rf/rf.h" +#include "srsran/phy/ue/ue_sync.h" +#include "srsran/phy/utils/bit.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" #define PCAP_FILENAME "/tmp/pssch.pcap" static bool keep_running = true; -static srslte_cell_sl_t cell_sl = {.nof_prb = 50, .tm = SRSLTE_SIDELINK_TM4, .cp = SRSLTE_CP_NORM, .N_sl_id = 0}; +static srsran_cell_sl_t cell_sl = {.nof_prb = 50, .tm = SRSRAN_SIDELINK_TM4, .cp = SRSRAN_CP_NORM, .N_sl_id = 0}; typedef struct { bool use_standard_lte_rates; @@ -70,16 +70,16 @@ void args_default(prog_args_t* args) args->num_sub_channel = 5; } -static srslte_pscch_t pscch = {}; // Defined global for plotting thread -static srslte_pssch_t pssch = {}; +static srsran_pscch_t pscch = {}; // Defined global for plotting thread +static srsran_pssch_t pssch = {}; #ifndef DISABLE_RF -static srslte_rf_t radio; +static srsran_rf_t radio; #endif // DISABLE_RF static prog_args_t prog_args; -static srslte_filesource_t fsrc = {}; +static srsran_filesource_t fsrc = {}; #ifdef ENABLE_GUI #include "srsgui/srsgui.h" @@ -115,8 +115,8 @@ void pcap_pack_and_write(FILE* pcap_file, .ueid = 1, .isRetx = reTX, .crcStatusOK = crc_ok, - .sysFrameNumber = (uint16_t)(tti / SRSLTE_NOF_SF_X_FRAME), - .subFrameNumber = (uint16_t)(tti % SRSLTE_NOF_SF_X_FRAME), + .sysFrameNumber = (uint16_t)(tti / SRSRAN_NOF_SF_X_FRAME), + .subFrameNumber = (uint16_t)(tti % SRSRAN_NOF_SF_X_FRAME), .nbiotMode = 0}; if (pdu) { LTE_PCAP_MAC_WritePDU(pcap_file, &context, pdu, pdu_len_bytes); @@ -141,7 +141,7 @@ void usage(prog_args_t* args, char* prog) #ifdef ENABLE_GUI printf("\t-w disable plots [Default enabled]\n"); #endif - printf("\t-v srslte_verbose\n"); + printf("\t-v srsran_verbose\n"); } void parse_args(prog_args_t* args, int argc, char** argv) @@ -179,7 +179,7 @@ void parse_args(prog_args_t* args, int argc, char** argv) args->nof_rx_antennas = (int32_t)strtol(argv[optind], NULL, 10); break; case 'v': - srslte_verbose++; + srsran_verbose++; break; case 'w': args->disable_plots = true; @@ -199,14 +199,14 @@ void parse_args(prog_args_t* args, int argc, char** argv) } #ifndef DISABLE_RF -int srslte_rf_recv_wrapper(void* h, cf_t* data[SRSLTE_MAX_PORTS], uint32_t nsamples, srslte_timestamp_t* t) +int srsran_rf_recv_wrapper(void* h, cf_t* data[SRSRAN_MAX_PORTS], uint32_t nsamples, srsran_timestamp_t* t) { DEBUG(" ---- Receive %d samples ----", nsamples); - void* ptr[SRSLTE_MAX_PORTS]; - for (int i = 0; i < SRSLTE_MAX_PORTS; i++) { + void* ptr[SRSRAN_MAX_PORTS]; + for (int i = 0; i < SRSRAN_MAX_PORTS; i++) { ptr[i] = data[i]; } - return srslte_rf_recv_with_time_multi(h, ptr, nsamples, true, &t->full_secs, &t->frac_secs); + return srsran_rf_recv_with_time_multi(h, ptr, nsamples, true, &t->full_secs, &t->frac_secs); } #endif // DISABLE_RF @@ -225,18 +225,18 @@ int main(int argc, char** argv) FILE* pcap_file = LTE_PCAP_Open(MAC_LTE_DLT, PCAP_FILENAME); - srslte_use_standard_symbol_size(prog_args.use_standard_lte_rates); + srsran_use_standard_symbol_size(prog_args.use_standard_lte_rates); - srslte_sl_comm_resource_pool_t sl_comm_resource_pool; - if (srslte_sl_comm_resource_pool_get_default_config(&sl_comm_resource_pool, cell_sl) != SRSLTE_SUCCESS) { + srsran_sl_comm_resource_pool_t sl_comm_resource_pool; + if (srsran_sl_comm_resource_pool_get_default_config(&sl_comm_resource_pool, cell_sl) != SRSRAN_SUCCESS) { ERROR("Error initializing sl_comm_resource_pool"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (prog_args.input_file_name) { - if (srslte_filesource_init(&fsrc, prog_args.input_file_name, SRSLTE_COMPLEX_FLOAT_BIN)) { + if (srsran_filesource_init(&fsrc, prog_args.input_file_name, SRSRAN_COMPLEX_FLOAT_BIN)) { printf("Error opening file %s\n", prog_args.input_file_name); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } @@ -244,21 +244,21 @@ int main(int argc, char** argv) if (!prog_args.input_file_name) { printf("Opening RF device...\n"); - if (srslte_rf_open_multi(&radio, prog_args.rf_args, prog_args.nof_rx_antennas)) { + if (srsran_rf_open_multi(&radio, prog_args.rf_args, prog_args.nof_rx_antennas)) { ERROR("Error opening rf"); exit(-1); } - srslte_rf_set_rx_gain(&radio, prog_args.rf_gain); + srsran_rf_set_rx_gain(&radio, prog_args.rf_gain); printf("Set RX freq: %.6f MHz\n", - srslte_rf_set_rx_freq(&radio, prog_args.nof_rx_antennas, prog_args.rf_freq) / 1e6); + srsran_rf_set_rx_freq(&radio, prog_args.nof_rx_antennas, prog_args.rf_freq) / 1e6); printf("Set RX gain: %.1f dB\n", prog_args.rf_gain); - int srate = srslte_sampling_freq_hz(cell_sl.nof_prb); + int srate = srsran_sampling_freq_hz(cell_sl.nof_prb); if (srate != -1) { printf("Setting sampling rate %.2f MHz\n", (float)srate / 1000000); - float srate_rf = srslte_rf_set_rx_srate(&radio, (double)srate); + float srate_rf = srsran_rf_set_rx_srate(&radio, (double)srate); if (srate_rf != srate) { ERROR("Could not set sampling rate"); exit(-1); @@ -271,99 +271,99 @@ int main(int argc, char** argv) #endif // DISABLE_RF // allocate Rx buffers for 1ms worth of samples - uint32_t sf_len = SRSLTE_SF_LEN_PRB(cell_sl.nof_prb); + uint32_t sf_len = SRSRAN_SF_LEN_PRB(cell_sl.nof_prb); printf("Using a SF len of %d samples\n", sf_len); - cf_t* rx_buffer[SRSLTE_MAX_CHANNELS] = {}; //< For radio to receive samples - cf_t* sf_buffer[SRSLTE_MAX_PORTS] = {NULL}; ///< For OFDM object to store subframe after FFT + cf_t* rx_buffer[SRSRAN_MAX_CHANNELS] = {}; //< For radio to receive samples + cf_t* sf_buffer[SRSRAN_MAX_PORTS] = {NULL}; ///< For OFDM object to store subframe after FFT for (int i = 0; i < prog_args.nof_rx_antennas; i++) { - rx_buffer[i] = srslte_vec_cf_malloc(sf_len); + rx_buffer[i] = srsran_vec_cf_malloc(sf_len); if (!rx_buffer[i]) { perror("malloc"); exit(-1); } - sf_buffer[i] = srslte_vec_cf_malloc(sf_len); + sf_buffer[i] = srsran_vec_cf_malloc(sf_len); if (!sf_buffer[i]) { perror("malloc"); exit(-1); } } - uint32_t sf_n_re = SRSLTE_CP_NSYMB(SRSLTE_CP_NORM) * SRSLTE_NRE * 2 * cell_sl.nof_prb; - cf_t* equalized_sf_buffer = srslte_vec_malloc(sizeof(cf_t) * sf_n_re); + uint32_t sf_n_re = SRSRAN_CP_NSYMB(SRSRAN_CP_NORM) * SRSRAN_NRE * 2 * cell_sl.nof_prb; + cf_t* equalized_sf_buffer = srsran_vec_malloc(sizeof(cf_t) * sf_n_re); // RX - srslte_ofdm_t fft[SRSLTE_MAX_PORTS]; - srslte_ofdm_cfg_t ofdm_cfg = {}; + srsran_ofdm_t fft[SRSRAN_MAX_PORTS]; + srsran_ofdm_cfg_t ofdm_cfg = {}; ofdm_cfg.nof_prb = cell_sl.nof_prb; - ofdm_cfg.cp = SRSLTE_CP_NORM; + ofdm_cfg.cp = SRSRAN_CP_NORM; ofdm_cfg.rx_window_offset = 0.0f; ofdm_cfg.normalize = true; - ofdm_cfg.sf_type = SRSLTE_SF_NORM; + ofdm_cfg.sf_type = SRSRAN_SF_NORM; ofdm_cfg.freq_shift_f = -0.5; for (int i = 0; i < prog_args.nof_rx_antennas; i++) { ofdm_cfg.in_buffer = rx_buffer[0]; ofdm_cfg.out_buffer = sf_buffer[0]; - if (srslte_ofdm_rx_init_cfg(&fft[i], &ofdm_cfg)) { + if (srsran_ofdm_rx_init_cfg(&fft[i], &ofdm_cfg)) { ERROR("Error initiating FFT"); goto clean_exit; } } // SCI - srslte_sci_t sci; - srslte_sci_init(&sci, cell_sl, sl_comm_resource_pool); - uint8_t sci_rx[SRSLTE_SCI_MAX_LEN] = {}; - char sci_msg[SRSLTE_SCI_MSG_MAX_LEN] = {}; + srsran_sci_t sci; + srsran_sci_init(&sci, cell_sl, sl_comm_resource_pool); + uint8_t sci_rx[SRSRAN_SCI_MAX_LEN] = {}; + char sci_msg[SRSRAN_SCI_MSG_MAX_LEN] = {}; // init PSCCH object - if (srslte_pscch_init(&pscch, SRSLTE_MAX_PRB) != SRSLTE_SUCCESS) { + if (srsran_pscch_init(&pscch, SRSRAN_MAX_PRB) != SRSRAN_SUCCESS) { ERROR("Error in PSCCH init"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_pscch_set_cell(&pscch, cell_sl) != SRSLTE_SUCCESS) { + if (srsran_pscch_set_cell(&pscch, cell_sl) != SRSRAN_SUCCESS) { ERROR("Error in PSCCH set cell"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // PSCCH Channel estimation - srslte_chest_sl_cfg_t pscch_chest_sl_cfg = {}; - srslte_chest_sl_t pscch_chest = {}; - if (srslte_chest_sl_init(&pscch_chest, SRSLTE_SIDELINK_PSCCH, cell_sl, sl_comm_resource_pool) != SRSLTE_SUCCESS) { + srsran_chest_sl_cfg_t pscch_chest_sl_cfg = {}; + srsran_chest_sl_t pscch_chest = {}; + if (srsran_chest_sl_init(&pscch_chest, SRSRAN_SIDELINK_PSCCH, cell_sl, sl_comm_resource_pool) != SRSRAN_SUCCESS) { ERROR("Error in chest PSCCH init"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_pssch_init(&pssch, cell_sl, sl_comm_resource_pool) != SRSLTE_SUCCESS) { + if (srsran_pssch_init(&pssch, cell_sl, sl_comm_resource_pool) != SRSRAN_SUCCESS) { ERROR("Error initializing PSSCH"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - srslte_chest_sl_cfg_t pssch_chest_sl_cfg = {}; - srslte_chest_sl_t pssch_chest = {}; - if (srslte_chest_sl_init(&pssch_chest, SRSLTE_SIDELINK_PSSCH, cell_sl, sl_comm_resource_pool) != SRSLTE_SUCCESS) { + srsran_chest_sl_cfg_t pssch_chest_sl_cfg = {}; + srsran_chest_sl_t pssch_chest = {}; + if (srsran_chest_sl_init(&pssch_chest, SRSRAN_SIDELINK_PSSCH, cell_sl, sl_comm_resource_pool) != SRSRAN_SUCCESS) { ERROR("Error in chest PSSCH init"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - uint8_t tb[SRSLTE_SL_SCH_MAX_TB_LEN] = {}; - uint8_t packed_tb[SRSLTE_SL_SCH_MAX_TB_LEN / 8] = {}; + uint8_t tb[SRSRAN_SL_SCH_MAX_TB_LEN] = {}; + uint8_t packed_tb[SRSRAN_SL_SCH_MAX_TB_LEN / 8] = {}; #ifndef DISABLE_RF - srslte_ue_sync_t ue_sync = {}; + srsran_ue_sync_t ue_sync = {}; if (!prog_args.input_file_name) { - srslte_cell_t cell = {}; + srsran_cell_t cell = {}; cell.nof_prb = cell_sl.nof_prb; - cell.cp = SRSLTE_CP_NORM; + cell.cp = SRSRAN_CP_NORM; cell.nof_ports = 1; - if (srslte_ue_sync_init_multi_decim_mode(&ue_sync, + if (srsran_ue_sync_init_multi_decim_mode(&ue_sync, cell.nof_prb, false, - srslte_rf_recv_wrapper, + srsran_rf_recv_wrapper, prog_args.nof_rx_antennas, (void*)&radio, 1, @@ -372,12 +372,12 @@ int main(int argc, char** argv) exit(-1); } - if (srslte_ue_sync_set_cell(&ue_sync, cell)) { + if (srsran_ue_sync_set_cell(&ue_sync, cell)) { ERROR("Error initiating ue_sync"); exit(-1); } - srslte_rf_start_rx_stream(&radio, false); + srsran_rf_start_rx_stream(&radio, false); } #endif @@ -399,7 +399,7 @@ int main(int argc, char** argv) while (keep_running) { if (prog_args.input_file_name) { // read subframe from file - int nread = srslte_filesource_read(&fsrc, rx_buffer[0], sf_len); + int nread = srsran_filesource_read(&fsrc, rx_buffer[0], sf_len); if (nread < 0) { fprintf(stderr, "Error reading from file\n"); goto clean_exit; @@ -412,18 +412,18 @@ int main(int argc, char** argv) } else { #ifndef DISABLE_RF // receive subframe from radio - int ret = srslte_ue_sync_zerocopy(&ue_sync, rx_buffer, sf_len); + int ret = srsran_ue_sync_zerocopy(&ue_sync, rx_buffer, sf_len); if (ret < 0) { - ERROR("Error calling srslte_ue_sync_work()"); + ERROR("Error calling srsran_ue_sync_work()"); } // update SF index - current_sf_idx = srslte_ue_sync_get_sfidx(&ue_sync); + current_sf_idx = srsran_ue_sync_get_sfidx(&ue_sync); #endif // DISABLE_RF } // do FFT (on first port) - srslte_ofdm_rx_sf(&fft[0]); + srsran_ofdm_rx_sf(&fft[0]); for (int sub_channel_idx = 0; sub_channel_idx < sl_comm_resource_pool.num_sub_channel; sub_channel_idx++) { pscch_prb_start_idx = sub_channel_idx * sl_comm_resource_pool.size_sub_channel; @@ -432,12 +432,12 @@ int main(int argc, char** argv) // PSCCH Channel estimation pscch_chest_sl_cfg.cyclic_shift = cyclic_shift; pscch_chest_sl_cfg.prb_start_idx = pscch_prb_start_idx; - srslte_chest_sl_set_cfg(&pscch_chest, pscch_chest_sl_cfg); - srslte_chest_sl_ls_estimate_equalize(&pscch_chest, sf_buffer[0], equalized_sf_buffer); + srsran_chest_sl_set_cfg(&pscch_chest, pscch_chest_sl_cfg); + srsran_chest_sl_ls_estimate_equalize(&pscch_chest, sf_buffer[0], equalized_sf_buffer); - if (srslte_pscch_decode(&pscch, equalized_sf_buffer, sci_rx, pscch_prb_start_idx) == SRSLTE_SUCCESS) { - if (srslte_sci_format1_unpack(&sci, sci_rx) == SRSLTE_SUCCESS) { - srslte_sci_info(&sci, sci_msg, sizeof(sci_msg)); + if (srsran_pscch_decode(&pscch, equalized_sf_buffer, sci_rx, pscch_prb_start_idx) == SRSRAN_SUCCESS) { + if (srsran_sci_format1_unpack(&sci, sci_rx) == SRSRAN_SUCCESS) { + srsran_sci_info(&sci, sci_msg, sizeof(sci_msg)); fprintf(stdout, "%s", sci_msg); num_decoded_sci++; @@ -452,7 +452,7 @@ int main(int argc, char** argv) // Decode PSSCH uint32_t sub_channel_start_idx = 0; uint32_t L_subCH = 0; - srslte_ra_sl_type0_from_riv( + srsran_ra_sl_type0_from_riv( sci.riv, sl_comm_resource_pool.num_sub_channel, &L_subCH, &sub_channel_start_idx); // 3GPP TS 36.213 Section 14.1.1.4C @@ -462,11 +462,11 @@ int main(int argc, char** argv) pssch_prb_start_idx + sl_comm_resource_pool.start_prb_sub_channel; // make sure PRBs are valid for DFT precoding - nof_prb_pssch = srslte_dft_precoding_get_valid_prb(nof_prb_pssch); + nof_prb_pssch = srsran_dft_precoding_get_valid_prb(nof_prb_pssch); uint32_t N_x_id = 0; - for (int j = 0; j < SRSLTE_SCI_CRC_LEN; j++) { - N_x_id += pscch.sci_crc[j] * exp2(SRSLTE_SCI_CRC_LEN - 1 - j); + for (int j = 0; j < SRSRAN_SCI_CRC_LEN; j++) { + N_x_id += pscch.sci_crc[j] * exp2(SRSRAN_SCI_CRC_LEN - 1 - j); } uint32_t rv_idx = 0; @@ -479,17 +479,17 @@ int main(int argc, char** argv) pssch_chest_sl_cfg.sf_idx = current_sf_idx; pssch_chest_sl_cfg.prb_start_idx = pssch_prb_start_idx; pssch_chest_sl_cfg.nof_prb = nof_prb_pssch; - srslte_chest_sl_set_cfg(&pssch_chest, pssch_chest_sl_cfg); - srslte_chest_sl_ls_estimate_equalize(&pssch_chest, sf_buffer[0], equalized_sf_buffer); + srsran_chest_sl_set_cfg(&pssch_chest, pssch_chest_sl_cfg); + srsran_chest_sl_ls_estimate_equalize(&pssch_chest, sf_buffer[0], equalized_sf_buffer); - srslte_pssch_cfg_t pssch_cfg = { + srsran_pssch_cfg_t pssch_cfg = { pssch_prb_start_idx, nof_prb_pssch, N_x_id, sci.mcs_idx, rv_idx, current_sf_idx}; - if (srslte_pssch_set_cfg(&pssch, pssch_cfg) == SRSLTE_SUCCESS) { - if (srslte_pssch_decode(&pssch, equalized_sf_buffer, tb, SRSLTE_SL_SCH_MAX_TB_LEN) == SRSLTE_SUCCESS) { + if (srsran_pssch_set_cfg(&pssch, pssch_cfg) == SRSRAN_SUCCESS) { + if (srsran_pssch_decode(&pssch, equalized_sf_buffer, tb, SRSRAN_SL_SCH_MAX_TB_LEN) == SRSRAN_SUCCESS) { num_decoded_tb++; // pack bit sand write to PCAP - srslte_bit_pack_vector(tb, packed_tb, pssch.sl_sch_tb_len); + srsran_bit_pack_vector(tb, packed_tb, pssch.sl_sch_tb_len); pcap_pack_and_write(pcap_file, packed_tb, pssch.sl_sch_tb_len / 8, @@ -514,7 +514,7 @@ int main(int argc, char** argv) } } } - if (SRSLTE_VERBOSE_ISDEBUG()) { + if (SRSRAN_VERBOSE_ISDEBUG()) { char filename[64]; snprintf(filename, 64, @@ -522,8 +522,8 @@ int main(int argc, char** argv) subframe_count, cyclic_shift, pscch_prb_start_idx); - printf("Saving PSCCH symbols (%d) to %s\n", pscch.E / SRSLTE_PSCCH_QM, filename); - srslte_vec_save_file(filename, pscch.mod_symbols, pscch.E / SRSLTE_PSCCH_QM * sizeof(cf_t)); + printf("Saving PSCCH symbols (%d) to %s\n", pscch.E / SRSRAN_PSCCH_QM, filename); + srsran_vec_save_file(filename, pscch.mod_symbols, pscch.E / SRSRAN_PSCCH_QM * sizeof(cf_t)); } } } @@ -553,15 +553,15 @@ clean_exit: #endif #ifndef DISABLE_RF - srslte_rf_stop_rx_stream(&radio); - srslte_rf_close(&radio); - srslte_ue_sync_free(&ue_sync); + srsran_rf_stop_rx_stream(&radio); + srsran_rf_close(&radio); + srsran_ue_sync_free(&ue_sync); #endif // DISABLE_RF - srslte_sci_free(&sci); - srslte_pscch_free(&pscch); - srslte_chest_sl_free(&pscch_chest); - srslte_chest_sl_free(&pssch_chest); + srsran_sci_free(&sci); + srsran_pscch_free(&pscch); + srsran_chest_sl_free(&pscch_chest); + srsran_chest_sl_free(&pssch_chest); for (int i = 0; i < prog_args.nof_rx_antennas; i++) { if (rx_buffer[i]) { @@ -570,14 +570,14 @@ clean_exit: if (sf_buffer[i]) { free(sf_buffer[i]); } - srslte_ofdm_rx_free(&fft[i]); + srsran_ofdm_rx_free(&fft[i]); } if (equalized_sf_buffer) { free(equalized_sf_buffer); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } ///< Plotting Functions @@ -605,7 +605,7 @@ void* plot_thread_run(void* arg) while (keep_running) { sem_wait(&plot_sem); - plot_scatter_setNewData(&pscatequal_pscch, pscch.mod_symbols, pscch.E / SRSLTE_PSCCH_QM); + plot_scatter_setNewData(&pscatequal_pscch, pscch.mod_symbols, pscch.E / SRSRAN_PSCCH_QM); if (pssch.G > 0 && pssch.Qm > 0) { plot_scatter_setNewData(&pscatequal_pssch, pssch.symbols, pssch.G / pssch.Qm); } diff --git a/lib/examples/synch_file.c b/lib/examples/synch_file.c index ed61daeaf..04aec21d7 100644 --- a/lib/examples/synch_file.c +++ b/lib/examples/synch_file.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -16,7 +16,7 @@ #include #include -#include "srslte/srslte.h" +#include "srsran/srsran.h" char* input_file_name; char* output_file_name = "abs_corr.txt"; @@ -38,7 +38,7 @@ void usage(char* prog) printf("\t-N out_N_id_2 [Default %d]\n", out_N_id_2); printf("\t-f force_N_id_2 [Default %d]\n", force_N_id_2); printf("\t-c force_cfo [Default disabled]\n"); - printf("\t-v srslte_verbose\n"); + printf("\t-v srsran_verbose\n"); } void parse_args(int argc, char** argv) @@ -74,7 +74,7 @@ void parse_args(int argc, char** argv) force_cfo = strtof(argv[optind], NULL); break; case 'v': - srslte_verbose++; + srsran_verbose++; break; default: usage(argv[0]); @@ -89,11 +89,11 @@ void parse_args(int argc, char** argv) int main(int argc, char** argv) { - srslte_filesource_t fsrc; - srslte_filesink_t fsink; - srslte_pss_t pss[3]; // One for each N_id_2 - srslte_sss_t sss[3]; // One for each N_id_2 - srslte_cfo_t cfocorr; + srsran_filesource_t fsrc; + srsran_filesink_t fsink; + srsran_pss_t pss[3]; // One for each N_id_2 + srsran_sss_t sss[3]; // One for each N_id_2 + srsran_cfo_t cfocorr; int peak_pos[3]; float* cfo; float peak_value[3]; @@ -117,32 +117,32 @@ int main(int argc, char** argv) printf("Initializing..."); fflush(stdout); - if (srslte_filesource_init(&fsrc, input_file_name, SRSLTE_COMPLEX_FLOAT_BIN)) { + if (srsran_filesource_init(&fsrc, input_file_name, SRSRAN_COMPLEX_FLOAT_BIN)) { ERROR("Error opening file %s", input_file_name); exit(-1); } - if (srslte_filesink_init(&fsink, output_file_name, SRSLTE_COMPLEX_FLOAT_BIN)) { + if (srsran_filesink_init(&fsink, output_file_name, SRSRAN_COMPLEX_FLOAT_BIN)) { ERROR("Error opening file %s", output_file_name); exit(-1); } - input = srslte_vec_cf_malloc(frame_length); + input = srsran_vec_cf_malloc(frame_length); if (!input) { perror("malloc"); exit(-1); } - cfo = srslte_vec_f_malloc(nof_frames); + cfo = srsran_vec_f_malloc(nof_frames); if (!cfo) { perror("malloc"); exit(-1); } - exec_time = srslte_vec_i32_malloc(nof_frames); + exec_time = srsran_vec_i32_malloc(nof_frames); if (!exec_time) { perror("malloc"); exit(-1); } - if (srslte_cfo_init(&cfocorr, frame_length)) { + if (srsran_cfo_init(&cfocorr, frame_length)) { ERROR("Error initiating CFO"); return -1; } @@ -153,19 +153,19 @@ int main(int argc, char** argv) * a) requries more memory but has less latency and is paralellizable. */ for (N_id_2 = 0; N_id_2 < 3; N_id_2++) { - if (srslte_pss_init_fft(&pss[N_id_2], frame_length, symbol_sz)) { + if (srsran_pss_init_fft(&pss[N_id_2], frame_length, symbol_sz)) { ERROR("Error initializing PSS object"); exit(-1); } - if (srslte_pss_set_N_id_2(&pss[N_id_2], N_id_2)) { + if (srsran_pss_set_N_id_2(&pss[N_id_2], N_id_2)) { ERROR("Error initializing N_id_2"); exit(-1); } - if (srslte_sss_init(&sss[N_id_2], symbol_sz)) { + if (srsran_sss_init(&sss[N_id_2], symbol_sz)) { ERROR("Error initializing SSS object"); exit(-1); } - if (srslte_sss_set_N_id_2(&sss[N_id_2], N_id_2)) { + if (srsran_sss_set_N_id_2(&sss[N_id_2], N_id_2)) { ERROR("Error initializing N_id_2"); exit(-1); } @@ -179,18 +179,18 @@ int main(int argc, char** argv) /* read all file or nof_frames */ frame_cnt = 0; - while (frame_length == srslte_filesource_read(&fsrc, input, frame_length) && frame_cnt < nof_frames) { + while (frame_length == srsran_filesource_read(&fsrc, input, frame_length) && frame_cnt < nof_frames) { gettimeofday(&tdata[1], NULL); if (force_cfo != CFO_AUTO) { - srslte_cfo_correct(&cfocorr, input, input, force_cfo / 128); + srsran_cfo_correct(&cfocorr, input, input, force_cfo / 128); } if (force_N_id_2 != -1) { N_id_2 = force_N_id_2; - peak_pos[N_id_2] = srslte_pss_find_pss(&pss[N_id_2], input, &peak_value[N_id_2]); + peak_pos[N_id_2] = srsran_pss_find_pss(&pss[N_id_2], input, &peak_value[N_id_2]); } else { for (N_id_2 = 0; N_id_2 < 3; N_id_2++) { - peak_pos[N_id_2] = srslte_pss_find_pss(&pss[N_id_2], input, &peak_value[N_id_2]); + peak_pos[N_id_2] = srsran_pss_find_pss(&pss[N_id_2], input, &peak_value[N_id_2]); } float max_value = -99999; N_id_2 = -1; @@ -205,16 +205,16 @@ int main(int argc, char** argv) /* If peak detected */ if (peak_value[N_id_2] > corr_peak_threshold) { - sss_idx = peak_pos[N_id_2] - 2 * (symbol_sz + SRSLTE_CP_LEN(symbol_sz, SRSLTE_CP_NORM_LEN)); + sss_idx = peak_pos[N_id_2] - 2 * (symbol_sz + SRSRAN_CP_LEN(symbol_sz, SRSRAN_CP_NORM_LEN)); if (sss_idx >= 0) { - srslte_sss_m0m1_diff(&sss[N_id_2], &input[sss_idx], &m0, &m0_value, &m1, &m1_value); + srsran_sss_m0m1_diff(&sss[N_id_2], &input[sss_idx], &m0, &m0_value, &m1, &m1_value); - cfo[frame_cnt] = srslte_pss_cfo_compute(&pss[N_id_2], &input[peak_pos[N_id_2] - 128]); + cfo[frame_cnt] = srsran_pss_cfo_compute(&pss[N_id_2], &input[peak_pos[N_id_2] - 128]); printf("\t%d\t%d\t%d\t%d\t%.3f\t\t%3d\t%d\t%d\t%.3f\n", frame_cnt, N_id_2, - srslte_sss_N_id_1(&sss[N_id_2], m0, m1, m1_value + m0_value), - srslte_sss_subframe(m0, m1), + srsran_sss_N_id_1(&sss[N_id_2], m0, m1, m1_value + m0_value), + srsran_sss_subframe(m0, m1), peak_value[N_id_2], peak_pos[N_id_2], m0, @@ -247,12 +247,12 @@ int main(int argc, char** argv) printf("Average CFO: %.3f\n", cfo_mean); for (N_id_2 = 0; N_id_2 < 3; N_id_2++) { - srslte_pss_free(&pss[N_id_2]); - srslte_sss_free(&sss[N_id_2]); + srsran_pss_free(&pss[N_id_2]); + srsran_sss_free(&sss[N_id_2]); } - srslte_filesource_free(&fsrc); - srslte_filesink_free(&fsink); + srsran_filesource_free(&fsrc); + srsran_filesink_free(&fsink); free(input); free(cfo); diff --git a/lib/examples/test/CMakeLists.txt b/lib/examples/test/CMakeLists.txt index 27da4b664..adc30cc68 100644 --- a/lib/examples/test/CMakeLists.txt +++ b/lib/examples/test/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of diff --git a/lib/examples/test/iqtests.cmake b/lib/examples/test/iqtests.cmake index 7f7dd6d9e..30c703f45 100644 --- a/lib/examples/test/iqtests.cmake +++ b/lib/examples/test/iqtests.cmake @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of diff --git a/lib/examples/usrp_capture.c b/lib/examples/usrp_capture.c index 2a74dc058..740ca7877 100644 --- a/lib/examples/usrp_capture.c +++ b/lib/examples/usrp_capture.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -21,9 +21,9 @@ #include -#include "srslte/phy/io/filesink.h" -#include "srslte/phy/rf/rf.h" -#include "srslte/srslte.h" +#include "srsran/phy/io/filesink.h" +#include "srsran/phy/rf/rf.h" +#include "srsran/srsran.h" static bool keep_running = true; char* output_file_name; @@ -45,7 +45,7 @@ void usage(char* prog) printf("\t-r RF Rate [Default %.6f Hz]\n", rf_rate); printf("\t-n nof_samples [Default %d]\n", nof_samples); printf("\t-A nof_rx_antennas [Default %d]\n", nof_rx_antennas); - printf("\t-v srslte_verbose\n"); + printf("\t-v srsran_verbose\n"); } void parse_args(int argc, char** argv) @@ -75,7 +75,7 @@ void parse_args(int argc, char** argv) nof_rx_antennas = (int)strtol(argv[optind], NULL, 10); break; case 'v': - srslte_verbose++; + srsran_verbose++; break; default: usage(argv[0]); @@ -90,10 +90,10 @@ void parse_args(int argc, char** argv) int main(int argc, char** argv) { - cf_t* buffer[SRSLTE_MAX_PORTS]; + cf_t* buffer[SRSRAN_MAX_PORTS]; int sample_count, n; - srslte_rf_t rf; - srslte_filesink_t sink; + srsran_rf_t rf; + srsran_filesink_t sink; uint32_t buflen; signal(SIGINT, int_handler); @@ -104,17 +104,17 @@ int main(int argc, char** argv) sample_count = 0; for (int i = 0; i < nof_rx_antennas; i++) { - buffer[i] = srslte_vec_cf_malloc(buflen); + buffer[i] = srsran_vec_cf_malloc(buflen); if (!buffer[i]) { perror("malloc"); exit(-1); } } - srslte_filesink_init(&sink, output_file_name, SRSLTE_COMPLEX_FLOAT_BIN); + srsran_filesink_init(&sink, output_file_name, SRSRAN_COMPLEX_FLOAT_BIN); printf("Opening RF device..."); - if (srslte_rf_open_multi(&rf, rf_args, nof_rx_antennas)) { + if (srsran_rf_open_multi(&rf, rf_args, nof_rx_antennas)) { ERROR("Error opening rf"); exit(-1); } @@ -124,13 +124,13 @@ int main(int argc, char** argv) sigaddset(&sigset, SIGINT); sigprocmask(SIG_UNBLOCK, &sigset, NULL); - srslte_rf_set_rx_gain(&rf, rf_gain); - srslte_rf_set_rx_freq(&rf, nof_rx_antennas, rf_freq); + srsran_rf_set_rx_gain(&rf, rf_gain); + srsran_rf_set_rx_freq(&rf, nof_rx_antennas, rf_freq); printf("Set RX freq: %.2f MHz\n", rf_freq / 1000000); printf("Set RX gain: %.2f dB\n", rf_gain); - float srate = srslte_rf_set_rx_srate(&rf, rf_rate); + float srate = srsran_rf_set_rx_srate(&rf, rf_rate); if (srate != rf_rate) { - srate = srslte_rf_set_rx_srate(&rf, rf_rate); + srate = srsran_rf_set_rx_srate(&rf, rf_rate); if (srate != rf_rate) { ERROR("Error setting samplign frequency %.2f MHz", rf_rate * 1e-6); exit(-1); @@ -138,16 +138,16 @@ int main(int argc, char** argv) } printf("Correctly RX rate: %.2f MHz\n", srate * 1e-6); - srslte_rf_start_rx_stream(&rf, false); + srsran_rf_start_rx_stream(&rf, false); while ((sample_count < nof_samples || nof_samples == -1) && keep_running) { - n = srslte_rf_recv_with_time_multi(&rf, (void**)buffer, buflen, true, NULL, NULL); + n = srsran_rf_recv_with_time_multi(&rf, (void**)buffer, buflen, true, NULL, NULL); if (n < 0) { ERROR("Error receiving samples"); exit(-1); } - srslte_filesink_write_multi(&sink, (void**)buffer, buflen, nof_rx_antennas); + srsran_filesink_write_multi(&sink, (void**)buffer, buflen, nof_rx_antennas); sample_count += buflen; } @@ -157,8 +157,8 @@ int main(int argc, char** argv) } } - srslte_filesink_free(&sink); - srslte_rf_close(&rf); + srsran_filesink_free(&sink); + srsran_rf_close(&rf); printf("Ok - wrote %d samples\n", sample_count); exit(0); diff --git a/lib/examples/usrp_capture_sync.c b/lib/examples/usrp_capture_sync.c index 69a52a1b2..27c22feb5 100644 --- a/lib/examples/usrp_capture_sync.c +++ b/lib/examples/usrp_capture_sync.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -21,8 +21,8 @@ #include -#include "srslte/phy/rf/rf.h" -#include "srslte/srslte.h" +#include "srsran/phy/rf/rf.h" +#include "srsran/srsran.h" static bool keep_running = true; char* output_file_name = NULL; @@ -34,7 +34,7 @@ int nof_subframes = -1; int N_id_2 = -1; uint32_t nof_rx_antennas = 1; bool use_standard_lte_rates = false; -srslte_ue_sync_mode_t sync_mode = SYNC_MODE_PSS; +srsran_ue_sync_mode_t sync_mode = SYNC_MODE_PSS; void int_handler(int dummy) { @@ -96,7 +96,7 @@ void parse_args(int argc, char** argv) nof_rx_antennas = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'v': - srslte_verbose++; + srsran_verbose++; break; default: usage(argv[0]); @@ -109,42 +109,42 @@ void parse_args(int argc, char** argv) } } -int srslte_rf_recv_wrapper(void* h, cf_t* data[SRSLTE_MAX_PORTS], uint32_t nsamples, srslte_timestamp_t* t) +int srsran_rf_recv_wrapper(void* h, cf_t* data[SRSRAN_MAX_PORTS], uint32_t nsamples, srsran_timestamp_t* t) { DEBUG(" ---- Receive %d samples ----", nsamples); - void* ptr[SRSLTE_MAX_PORTS]; - for (int i = 0; i < SRSLTE_MAX_PORTS; i++) { + void* ptr[SRSRAN_MAX_PORTS]; + for (int i = 0; i < SRSRAN_MAX_PORTS; i++) { ptr[i] = data[i]; } - return srslte_rf_recv_with_time_multi(h, ptr, nsamples, true, &t->full_secs, &t->frac_secs); + return srsran_rf_recv_with_time_multi(h, ptr, nsamples, true, &t->full_secs, &t->frac_secs); } int main(int argc, char** argv) { - cf_t* buffer[SRSLTE_MAX_CHANNELS] = {NULL}; + cf_t* buffer[SRSRAN_MAX_CHANNELS] = {NULL}; int n = 0; - srslte_rf_t rf = {}; - srslte_filesink_t sink = {}; - srslte_ue_sync_t ue_sync = {}; - srslte_cell_t cell = {}; + srsran_rf_t rf = {}; + srsran_filesink_t sink = {}; + srsran_ue_sync_t ue_sync = {}; + srsran_cell_t cell = {}; signal(SIGINT, int_handler); parse_args(argc, argv); - srslte_use_standard_symbol_size(use_standard_lte_rates); + srsran_use_standard_symbol_size(use_standard_lte_rates); - srslte_filesink_init(&sink, output_file_name, SRSLTE_COMPLEX_FLOAT_BIN); + srsran_filesink_init(&sink, output_file_name, SRSRAN_COMPLEX_FLOAT_BIN); printf("Opening RF device...\n"); - if (srslte_rf_open_multi(&rf, rf_args, nof_rx_antennas)) { + if (srsran_rf_open_multi(&rf, rf_args, nof_rx_antennas)) { ERROR("Error opening rf"); exit(-1); } - uint32_t max_num_samples = 3 * SRSLTE_SF_LEN_MAX; + uint32_t max_num_samples = 3 * SRSRAN_SF_LEN_MAX; for (int i = 0; i < nof_rx_antennas; i++) { - buffer[i] = srslte_vec_cf_malloc(max_num_samples); + buffer[i] = srsran_vec_cf_malloc(max_num_samples); } sigset_t sigset; @@ -152,13 +152,13 @@ int main(int argc, char** argv) sigaddset(&sigset, SIGINT); sigprocmask(SIG_UNBLOCK, &sigset, NULL); - srslte_rf_set_rx_gain(&rf, rf_gain); - printf("Set RX freq: %.6f MHz\n", srslte_rf_set_rx_freq(&rf, nof_rx_antennas, rf_freq) / 1000000); - printf("Set RX gain: %.1f dB\n", srslte_rf_get_rx_gain(&rf)); - int srate = srslte_sampling_freq_hz(nof_prb); + srsran_rf_set_rx_gain(&rf, rf_gain); + printf("Set RX freq: %.6f MHz\n", srsran_rf_set_rx_freq(&rf, nof_rx_antennas, rf_freq) / 1000000); + printf("Set RX gain: %.1f dB\n", srsran_rf_get_rx_gain(&rf)); + int srate = srsran_sampling_freq_hz(nof_prb); if (srate != -1) { printf("Setting sampling rate %.2f MHz\n", (float)srate / 1000000); - float srate_rf = srslte_rf_set_rx_srate(&rf, (double)srate); + float srate_rf = srsran_rf_set_rx_srate(&rf, (double)srate); if (srate_rf != srate) { ERROR("Could not set sampling rate"); exit(-1); @@ -167,19 +167,19 @@ int main(int argc, char** argv) ERROR("Invalid number of PRB %d", nof_prb); exit(-1); } - srslte_rf_start_rx_stream(&rf, false); + srsran_rf_start_rx_stream(&rf, false); - cell.cp = SRSLTE_CP_NORM; + cell.cp = SRSRAN_CP_NORM; cell.id = N_id_2; cell.nof_prb = nof_prb; cell.nof_ports = 1; - if (srslte_ue_sync_init_multi_decim_mode( - &ue_sync, cell.nof_prb, cell.id == 1000, srslte_rf_recv_wrapper, nof_rx_antennas, (void*)&rf, 1, sync_mode)) { + if (srsran_ue_sync_init_multi_decim_mode( + &ue_sync, cell.nof_prb, cell.id == 1000, srsran_rf_recv_wrapper, nof_rx_antennas, (void*)&rf, 1, sync_mode)) { fprintf(stderr, "Error initiating ue_sync\n"); exit(-1); } - if (srslte_ue_sync_set_cell(&ue_sync, cell)) { + if (srsran_ue_sync_set_cell(&ue_sync, cell)) { ERROR("Error initiating ue_sync"); exit(-1); } @@ -187,39 +187,39 @@ int main(int argc, char** argv) uint32_t subframe_count = 0; bool start_capture = false; bool stop_capture = false; - srslte_timestamp_t ts_rx_start = {}; + srsran_timestamp_t ts_rx_start = {}; while ((subframe_count < nof_subframes || nof_subframes == -1) && !stop_capture) { - n = srslte_ue_sync_zerocopy(&ue_sync, buffer, max_num_samples); + n = srsran_ue_sync_zerocopy(&ue_sync, buffer, max_num_samples); if (n < 0) { ERROR("Error receiving samples"); exit(-1); } if (n == 1) { if (!start_capture) { - if (srslte_ue_sync_get_sfidx(&ue_sync) == 9) { + if (srsran_ue_sync_get_sfidx(&ue_sync) == 9) { start_capture = true; } } else { printf("Writing to file %6d subframes...\r", subframe_count); - srslte_filesink_write_multi(&sink, (void**)buffer, SRSLTE_SF_LEN_PRB(nof_prb), nof_rx_antennas); + srsran_filesink_write_multi(&sink, (void**)buffer, SRSRAN_SF_LEN_PRB(nof_prb), nof_rx_antennas); // store time stamp of first subframe if (subframe_count == 0) { - srslte_ue_sync_get_last_timestamp(&ue_sync, &ts_rx_start); + srsran_ue_sync_get_last_timestamp(&ue_sync, &ts_rx_start); } subframe_count++; } } if (!keep_running) { - if (!start_capture || (start_capture && srslte_ue_sync_get_sfidx(&ue_sync) == 9)) { + if (!start_capture || (start_capture && srsran_ue_sync_get_sfidx(&ue_sync) == 9)) { stop_capture = true; } } } - srslte_filesink_free(&sink); - srslte_rf_close(&rf); - srslte_ue_sync_free(&ue_sync); + srsran_filesink_free(&sink); + srsran_rf_close(&rf); + srsran_ue_sync_free(&ue_sync); for (int i = 0; i < nof_rx_antennas; i++) { if (buffer[i]) { @@ -229,12 +229,12 @@ int main(int argc, char** argv) printf("\nOk - wrote %d subframes\n", subframe_count); - srslte_ue_sync_set_tti_from_timestamp(&ue_sync, &ts_rx_start); + srsran_ue_sync_set_tti_from_timestamp(&ue_sync, &ts_rx_start); printf("Start of capture at %ld+%.3f. TTI=%d.%d\n", ts_rx_start.full_secs, ts_rx_start.frac_secs, - srslte_ue_sync_get_sfn(&ue_sync), - srslte_ue_sync_get_sfidx(&ue_sync)); + srsran_ue_sync_get_sfn(&ue_sync), + srsran_ue_sync_get_sfidx(&ue_sync)); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } diff --git a/lib/examples/usrp_capture_sync_nbiot.c b/lib/examples/usrp_capture_sync_nbiot.c index c04048ed9..2c34fd3f1 100644 --- a/lib/examples/usrp_capture_sync_nbiot.c +++ b/lib/examples/usrp_capture_sync_nbiot.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -20,11 +20,11 @@ #include #include -#include "srslte/phy/io/filesink.h" -#include "srslte/phy/rf/rf.h" -#include "srslte/phy/ue/ue_mib_nbiot.h" -#include "srslte/phy/ue/ue_sync_nbiot.h" -#include "srslte/phy/utils/debug.h" +#include "srsran/phy/io/filesink.h" +#include "srsran/phy/rf/rf.h" +#include "srsran/phy/ue/ue_mib_nbiot.h" +#include "srsran/phy/ue/ue_sync_nbiot.h" +#include "srsran/phy/utils/debug.h" static bool keep_running = true; char* output_file_name = NULL; @@ -68,7 +68,7 @@ void parse_args(int argc, char** argv) nof_subframes = (int)strtol(argv[optind], NULL, 10); break; case 'v': - srslte_verbose++; + srsran_verbose++; break; default: usage(argv[0]); @@ -81,10 +81,10 @@ void parse_args(int argc, char** argv) } } -int srslte_rf_recv_wrapper(void* h, void* data, uint32_t nsamples, srslte_timestamp_t* t) +int srsran_rf_recv_wrapper(void* h, void* data, uint32_t nsamples, srsran_timestamp_t* t) { DEBUG(" ---- Receive %d samples ----", nsamples); - return srslte_rf_recv(h, data, nsamples, 1); + return srsran_rf_recv(h, data, nsamples, 1); } int main(int argc, char** argv) @@ -93,12 +93,12 @@ int main(int argc, char** argv) parse_args(argc, argv); - srslte_filesink_t sink; - srslte_filesink_init(&sink, output_file_name, SRSLTE_COMPLEX_FLOAT_BIN); + srsran_filesink_t sink; + srsran_filesink_init(&sink, output_file_name, SRSRAN_COMPLEX_FLOAT_BIN); printf("Opening RF device...\n"); - srslte_rf_t rf; - if (srslte_rf_open(&rf, rf_args)) { + srsran_rf_t rf; + if (srsran_rf_open(&rf, rf_args)) { fprintf(stderr, "Error opening rf\n"); exit(-1); } @@ -108,30 +108,30 @@ int main(int argc, char** argv) sigaddset(&sigset, SIGINT); sigprocmask(SIG_UNBLOCK, &sigset, NULL); - srslte_rf_set_rx_gain(&rf, rf_gain); - printf("Set RX freq: %.6f MHz\n", srslte_rf_set_rx_freq(&rf, 0, rf_freq) / 1000000); - printf("Set RX gain: %.1f dB\n", srslte_rf_get_rx_gain(&rf)); - int srate = srslte_sampling_freq_hz(nof_prb); + srsran_rf_set_rx_gain(&rf, rf_gain); + printf("Set RX freq: %.6f MHz\n", srsran_rf_set_rx_freq(&rf, 0, rf_freq) / 1000000); + printf("Set RX gain: %.1f dB\n", srsran_rf_get_rx_gain(&rf)); + int srate = srsran_sampling_freq_hz(nof_prb); if (srate != -1) { printf("Setting sampling rate %.2f MHz\n", (float)srate / 1e6); - double srate_rf = srslte_rf_set_rx_srate(&rf, srate); + double srate_rf = srsran_rf_set_rx_srate(&rf, srate); printf("Actual sampling rate %.2f MHz\n", srate_rf / 1e6); // We don't check the result rate with requested rate } else { fprintf(stderr, "Invalid number of PRB %d\n", nof_prb); exit(-1); } - srslte_rf_start_rx_stream(&rf, false); + srsran_rf_start_rx_stream(&rf, false); - srslte_nbiot_cell_t cell = {}; + srsran_nbiot_cell_t cell = {}; cell.base.nof_prb = nof_prb; cell.base.nof_ports = 1; - cf_t* buff_ptrs[SRSLTE_MAX_PORTS] = {NULL, NULL, NULL, NULL}; - buff_ptrs[0] = srslte_vec_cf_malloc(SRSLTE_SF_LEN_PRB_NBIOT * 10); + cf_t* buff_ptrs[SRSRAN_MAX_PORTS] = {NULL, NULL, NULL, NULL}; + buff_ptrs[0] = srsran_vec_cf_malloc(SRSRAN_SF_LEN_PRB_NBIOT * 10); - srslte_nbiot_ue_sync_t ue_sync; - if (srslte_ue_sync_nbiot_init(&ue_sync, cell, srslte_rf_recv_wrapper, (void*)&rf)) { + srsran_nbiot_ue_sync_t ue_sync; + if (srsran_ue_sync_nbiot_init(&ue_sync, cell, srsran_rf_recv_wrapper, (void*)&rf)) { fprintf(stderr, "Error initiating ue_sync\n"); exit(-1); } @@ -141,7 +141,7 @@ int main(int argc, char** argv) bool start_capture = false; bool stop_capture = false; while ((subframe_count < nof_subframes || nof_subframes == -1) && !stop_capture) { - int n = srslte_ue_sync_nbiot_zerocopy_multi(&ue_sync, buff_ptrs); + int n = srsran_ue_sync_nbiot_zerocopy_multi(&ue_sync, buff_ptrs); if (n < 0) { fprintf(stderr, "Error receiving samples\n"); exit(-1); @@ -150,7 +150,7 @@ int main(int argc, char** argv) if (n == 1) { if (!start_capture) { if (nof_warmup_subframes <= 0) { - if (srslte_ue_sync_nbiot_get_sfidx(&ue_sync) == 9) { + if (srsran_ue_sync_nbiot_get_sfidx(&ue_sync) == 9) { printf("Starting capture ..\n"); start_capture = true; } @@ -158,25 +158,25 @@ int main(int argc, char** argv) nof_warmup_subframes--; } else { printf("Writing subframe %d (%d/%d) to file (cfo=%6.2f kHz)\n", - srslte_ue_sync_nbiot_get_sfidx(&ue_sync), + srsran_ue_sync_nbiot_get_sfidx(&ue_sync), subframe_count, nof_subframes, - srslte_ue_sync_nbiot_get_cfo(&ue_sync) / 1000); - srslte_filesink_write(&sink, buff_ptrs[0], SRSLTE_SF_LEN_PRB(nof_prb)); + srsran_ue_sync_nbiot_get_cfo(&ue_sync) / 1000); + srsran_filesink_write(&sink, buff_ptrs[0], SRSRAN_SF_LEN_PRB(nof_prb)); subframe_count++; } } if (!keep_running) { - if (!start_capture || (start_capture && srslte_ue_sync_nbiot_get_sfidx(&ue_sync) == 9)) { + if (!start_capture || (start_capture && srsran_ue_sync_nbiot_get_sfidx(&ue_sync) == 9)) { printf("Stopping capture ..\n"); stop_capture = true; } } } - srslte_filesink_free(&sink); - srslte_rf_close(&rf); - srslte_ue_sync_nbiot_free(&ue_sync); + srsran_filesink_free(&sink); + srsran_rf_close(&rf); + srsran_ue_sync_nbiot_free(&ue_sync); printf("Ok - wrote %d subframes\n", subframe_count); exit(0); diff --git a/lib/examples/usrp_txrx.c b/lib/examples/usrp_txrx.c index 69b87cb0a..34548307a 100644 --- a/lib/examples/usrp_txrx.c +++ b/lib/examples/usrp_txrx.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -18,15 +18,15 @@ #include #include -#include "srslte/phy/rf/rf.h" -#include "srslte/srslte.h" +#include "srsran/phy/rf/rf.h" +#include "srsran/srsran.h" uint32_t nof_prb = 25; uint32_t nof_frames = 20; int time_adv_samples = 0; float tone_offset_hz = 1e6; -float rf_rx_gain = 40, srslte_rf_tx_gain = 40, rf_freq = 2.4e9; +float rf_rx_gain = 40, srsran_rf_tx_gain = 40, rf_freq = 2.4e9; char* rf_args = ""; char* output_filename = NULL; char* input_filename = NULL; @@ -37,7 +37,7 @@ void usage(char* prog) printf("\t-a RF args [Default %s]\n", rf_args); printf("\t-f RF TX/RX frequency [Default %.2f MHz]\n", rf_freq / 1e6); printf("\t-g RF RX gain [Default %.1f dB]\n", rf_rx_gain); - printf("\t-G RF TX gain [Default %.1f dB]\n", srslte_rf_tx_gain); + printf("\t-G RF TX gain [Default %.1f dB]\n", srsran_rf_tx_gain); printf("\t-t Single tone offset (Hz) [Default %f]\n", tone_offset_hz); printf("\t-T Time advance samples [Default %d]\n", time_adv_samples); printf("\t-i File name to read signal from [Default single tone]\n"); @@ -71,11 +71,11 @@ void parse_args(int argc, char** argv) rf_rx_gain = strtof(argv[optind], NULL); break; case 'G': - srslte_rf_tx_gain = strtof(argv[optind], NULL); + srsran_rf_tx_gain = strtof(argv[optind], NULL); break; case 'p': nof_prb = (uint32_t)strtol(argv[optind], NULL, 10); - if (!srslte_nofprb_isvalid(nof_prb)) { + if (!srsran_nofprb_isvalid(nof_prb)) { ERROR("Invalid number of UL RB %d", nof_prb); exit(-1); } @@ -100,82 +100,82 @@ int main(int argc, char** argv) { parse_args(argc, argv); - uint32_t flen = srslte_sampling_freq_hz(nof_prb) / 1000; + uint32_t flen = srsran_sampling_freq_hz(nof_prb) / 1000; - cf_t* rx_buffer = srslte_vec_cf_malloc(flen * nof_frames); + cf_t* rx_buffer = srsran_vec_cf_malloc(flen * nof_frames); if (!rx_buffer) { perror("malloc"); exit(-1); } - cf_t* tx_buffer = srslte_vec_cf_malloc((flen + time_adv_samples)); + cf_t* tx_buffer = srsran_vec_cf_malloc((flen + time_adv_samples)); if (!tx_buffer) { perror("malloc"); exit(-1); } - srslte_vec_cf_zero(tx_buffer, flen + time_adv_samples); + srsran_vec_cf_zero(tx_buffer, flen + time_adv_samples); - cf_t* zeros = srslte_vec_cf_malloc(flen); + cf_t* zeros = srsran_vec_cf_malloc(flen); if (!zeros) { perror("calloc"); exit(-1); } - srslte_vec_cf_zero(zeros, flen); + srsran_vec_cf_zero(zeros, flen); - float time_adv_sec = (float)time_adv_samples / srslte_sampling_freq_hz(nof_prb); + float time_adv_sec = (float)time_adv_samples / srsran_sampling_freq_hz(nof_prb); // Send through RF - srslte_rf_t rf; + srsran_rf_t rf; printf("Opening RF device...\n"); - if (srslte_rf_open(&rf, rf_args)) { + if (srsran_rf_open(&rf, rf_args)) { ERROR("Error opening rf"); exit(-1); } - int srate = srslte_sampling_freq_hz(nof_prb); - srslte_rf_set_rx_srate(&rf, (double)srate); - srslte_rf_set_tx_srate(&rf, (double)srate); + int srate = srsran_sampling_freq_hz(nof_prb); + srsran_rf_set_rx_srate(&rf, (double)srate); + srsran_rf_set_tx_srate(&rf, (double)srate); - srslte_rf_set_rx_gain(&rf, rf_rx_gain); - srslte_rf_set_tx_gain(&rf, srslte_rf_tx_gain); - srslte_rf_set_rx_freq(&rf, 0, rf_freq); + srsran_rf_set_rx_gain(&rf, rf_rx_gain); + srsran_rf_set_tx_gain(&rf, srsran_rf_tx_gain); + srsran_rf_set_rx_freq(&rf, 0, rf_freq); printf("Subframe len: %d samples\n", flen); printf("Time advance: %f us\n", time_adv_sec * 1e6); printf("Set TX/RX rate: %.2f MHz\n", (float)srate / 1000000); printf("Set RX gain: %.1f dB\n", rf_rx_gain); - printf("Set TX gain: %.1f dB\n", srslte_rf_tx_gain); + printf("Set TX gain: %.1f dB\n", srsran_rf_tx_gain); printf("Set TX/RX freq: %.2f MHz\n", rf_freq / 1000000); - srslte_rf_set_tx_freq(&rf, 0, rf_freq); + srsran_rf_set_tx_freq(&rf, 0, rf_freq); sleep(1); if (input_filename) { - srslte_vec_load_file(input_filename, &tx_buffer[time_adv_samples], flen * sizeof(cf_t)); + srsran_vec_load_file(input_filename, &tx_buffer[time_adv_samples], flen * sizeof(cf_t)); } else { for (int i = 0; i < flen - time_adv_samples; i++) { tx_buffer[i + time_adv_samples] = 0.3 * cexpf(_Complex_I * 2 * M_PI * tone_offset_hz * ((float)i / (float)srate)); } - srslte_vec_save_file("srslte_rf_txrx_tone", tx_buffer, flen * sizeof(cf_t)); + srsran_vec_save_file("srsran_rf_txrx_tone", tx_buffer, flen * sizeof(cf_t)); } - srslte_timestamp_t tstamp; + srsran_timestamp_t tstamp; - srslte_rf_start_rx_stream(&rf, false); + srsran_rf_start_rx_stream(&rf, false); uint32_t nframe = 0; while (nframe < nof_frames) { printf("Rx subframe %d\n", nframe); - srslte_rf_recv_with_time(&rf, &rx_buffer[flen * nframe], flen, true, &tstamp.full_secs, &tstamp.frac_secs); + srsran_rf_recv_with_time(&rf, &rx_buffer[flen * nframe], flen, true, &tstamp.full_secs, &tstamp.frac_secs); nframe++; if (nframe == 9) { - srslte_timestamp_add(&tstamp, 0, 2e-3 - time_adv_sec); - srslte_rf_send_timed2(&rf, tx_buffer, flen + time_adv_samples, tstamp.full_secs, tstamp.frac_secs, true, true); + srsran_timestamp_add(&tstamp, 0, 2e-3 - time_adv_sec); + srsran_rf_send_timed2(&rf, tx_buffer, flen + time_adv_samples, tstamp.full_secs, tstamp.frac_secs, true, true); printf("Transmitting Signal\n"); } } - srslte_vec_save_file(output_filename, &rx_buffer[10 * flen], flen * sizeof(cf_t)); + srsran_vec_save_file(output_filename, &rx_buffer[10 * flen], flen * sizeof(cf_t)); free(tx_buffer); free(rx_buffer); diff --git a/lib/examples/zmq_remote_rx.c b/lib/examples/zmq_remote_rx.c index f2b133c01..4d6dcfb98 100644 --- a/lib/examples/zmq_remote_rx.c +++ b/lib/examples/zmq_remote_rx.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -22,8 +22,8 @@ #include -#include "srslte/phy/rf/rf.h" -#include "srslte/srslte.h" +#include "srsran/phy/rf/rf.h" +#include "srsran/srsran.h" static bool keep_running = true; static uint32_t nof_rx_antennas = 1; @@ -99,7 +99,7 @@ int main(int argc, char** argv) // Initializes memory for input buffer bzero(buffer, sizeof(void*) * max_rx_antennas); for (int i = 0; i < nof_rx_antennas; i++) { - buffer[i] = srslte_vec_cf_malloc(buflen); + buffer[i] = srsran_vec_cf_malloc(buflen); if (!buffer[i]) { perror("malloc"); exit(-1); @@ -114,7 +114,7 @@ int main(int argc, char** argv) ERROR("Error receiving samples"); exit(-1); } - if (srslte_verbose == SRSLTE_VERBOSE_INFO) { + if (srsran_verbose == SRSRAN_VERBOSE_INFO) { printf("Received %d samples from radio\n", n); } @@ -127,7 +127,7 @@ int main(int argc, char** argv) print_cnt = 0; } } else { - if (srslte_verbose == SRSLTE_VERBOSE_INFO) { + if (srsran_verbose == SRSRAN_VERBOSE_INFO) { printf("Transmitted %d bytes to ZMQ\n", n); } } @@ -145,27 +145,27 @@ int main(int argc, char** argv) exit(0); } -/* Example function to initialize the Radio frontend. In this case, we use srsLTE RF API to open a device, +/* Example function to initialize the Radio frontend. In this case, we use srsRAN RF API to open a device, * which automatically picks UHD, bladeRF, limeSDR, etc. */ -static srslte_rf_t radio = {}; +static srsran_rf_t radio = {}; static char* rf_args = "fastpath"; static float rf_gain = 40.0, rf_freq = -1.0, rf_rate = 11.52e6; static uint32_t rf_recv_frame_size_ms = 1; static int init_radio(uint32_t* buffer_len) { - // Uses srsLTE RF API to open a device, could use other code here + // Uses srsRAN RF API to open a device, could use other code here printf("Opening RF device...\n"); - if (srslte_rf_open_multi(&radio, rf_args, nof_rx_antennas)) { + if (srsran_rf_open_multi(&radio, rf_args, nof_rx_antennas)) { ERROR("Error opening rf"); return -1; } - srslte_rf_set_rx_gain(&radio, rf_gain); - srslte_rf_set_rx_freq(&radio, nof_rx_antennas, rf_freq); + srsran_rf_set_rx_gain(&radio, rf_gain); + srsran_rf_set_rx_freq(&radio, nof_rx_antennas, rf_freq); printf("Set RX freq: %.2f MHz\n", rf_freq / 1000000); printf("Set RX gain: %.2f dB\n", rf_gain); - float srate = srslte_rf_set_rx_srate(&radio, rf_rate); + float srate = srsran_rf_set_rx_srate(&radio, rf_rate); if (srate != rf_rate) { ERROR("Error setting samplign frequency %.2f MHz", rf_rate * 1e-6); return -1; @@ -176,20 +176,20 @@ static int init_radio(uint32_t* buffer_len) } printf("Set RX rate: %.2f MHz\n", srate * 1e-6); - srslte_rf_start_rx_stream(&radio, false); + srsran_rf_start_rx_stream(&radio, false); return 0; } -/* Example implementation to receive from Radio frontend. In this case we use srsLTE +/* Example implementation to receive from Radio frontend. In this case we use srsRAN */ static int rx_radio(void** buffer, uint32_t buf_len) { - return srslte_rf_recv_with_time_multi(&radio, buffer, buf_len, true, NULL, NULL); + return srsran_rf_recv_with_time_multi(&radio, buffer, buf_len, true, NULL, NULL); } static void close_radio() { - srslte_rf_close(&radio); + srsran_rf_close(&radio); } static void int_handler(int dummy) @@ -206,7 +206,7 @@ static void usage(char* prog) printf("\t-m RF receive frame size in ms [Default %d ms]\n", rf_recv_frame_size_ms); printf("\t-A Number of antennas [Max %d, Default %d]\n", max_rx_antennas, nof_rx_antennas); printf("\t-z ZMQ args [Default %s]\n", zmq_args); - printf("\t-v srslte_verbose\n"); + printf("\t-v srsran_verbose\n"); } static void parse_args(int argc, char** argv) @@ -230,7 +230,7 @@ static void parse_args(int argc, char** argv) rf_freq = strtof(argv[optind], NULL); break; case 'v': - srslte_verbose++; + srsran_verbose++; break; case 'z': zmq_args = argv[optind]; diff --git a/lib/include/CMakeLists.txt b/lib/include/CMakeLists.txt index ed0c96c1f..ada599884 100644 --- a/lib/include/CMakeLists.txt +++ b/lib/include/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -9,5 +9,5 @@ ######################################################################## # Add subdirectories ######################################################################## -add_subdirectory(srslte) +add_subdirectory(srsran) diff --git a/lib/include/srslte/config.h b/lib/include/srslte/config.h deleted file mode 100644 index 235fc90af..000000000 --- a/lib/include/srslte/config.h +++ /dev/null @@ -1,64 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2020 Software Radio Systems Limited - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the distribution. - * - */ - -#ifndef SRSLTE_CONFIG_H -#define SRSLTE_CONFIG_H - -// Generic helper definitions for shared library support -#if defined _WIN32 || defined __CYGWIN__ -#define SRSLTE_IMPORT __declspec(dllimport) -#define SRSLTE_EXPORT __declspec(dllexport) -#define SRSLTE_LOCAL -#else -#if __GNUC__ >= 4 -#define SRSLTE_IMPORT __attribute__((visibility("default"))) -#define SRSLTE_EXPORT __attribute__((visibility("default"))) -#else -#define SRSLTE_IMPORT -#define SRSLTE_EXPORT -#define SRSLTE_LOCAL -#endif -#endif - -// Define SRSLTE_API -// SRSLTE_API is used for the public API symbols. -#ifdef SRSLTE_DLL_EXPORTS // defined if we are building the SRSLTE DLL (instead of using it) -#define SRSLTE_API SRSLTE_EXPORT -#else -#define SRSLTE_API SRSLTE_IMPORT -#endif - -// Useful macros for templates -#define CONCAT(a, b) a##b -#define CONCAT2(a, b) CONCAT(a, b) - -#define STRING2(x) #x -#define STRING(x) STRING2(x) - -// Common error codes -#define SRSLTE_SUCCESS 0 -#define SRSLTE_ERROR -1 -#define SRSLTE_ERROR_INVALID_INPUTS -2 -#define SRSLTE_ERROR_TIMEOUT -3 -#define SRSLTE_ERROR_INVALID_COMMAND -4 -#define SRSLTE_ERROR_OUT_OF_BOUNDS -5 -#define SRSLTE_ERROR_CANT_START -6 -#define SRSLTE_ERROR_ALREADY_STARTED -7 - -// cf_t definition -typedef _Complex float cf_t; - -#ifdef ENABLE_C16 -typedef _Complex short int c16_t; -#endif /* ENABLE_C16 */ - -#endif // SRSLTE_CONFIG_H diff --git a/lib/include/srslte/phy/ch_estimation/chest_dl.h b/lib/include/srslte/phy/ch_estimation/chest_dl.h deleted file mode 100644 index 9344f8d9a..000000000 --- a/lib/include/srslte/phy/ch_estimation/chest_dl.h +++ /dev/null @@ -1,164 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2020 Software Radio Systems Limited - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the distribution. - * - */ - -/********************************************************************************************** - * File: chest_dl.h - * - * Description: 3GPP LTE Downlink channel estimator and equalizer. - * Estimates the channel in the resource elements transmitting references and - * interpolates for the rest of the resource grid. - * The equalizer uses the channel estimates to produce an estimation of the - * transmitted symbol. - * This object depends on the srslte_refsignal_t object for creating the LTE - * CSR signal. - * - * Reference: - *********************************************************************************************/ - -#ifndef SRSLTE_CHEST_DL_H -#define SRSLTE_CHEST_DL_H - -#include - -#include "srslte/config.h" - -#include "srslte/phy/ch_estimation/chest_common.h" -#include "srslte/phy/ch_estimation/refsignal_dl.h" -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/resampling/interp.h" -#include "srslte/phy/sync/pss.h" -#include "wiener_dl.h" - -typedef struct SRSLTE_API { - cf_t* ce[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS]; - uint32_t nof_re; - float noise_estimate; - float noise_estimate_dbm; - float snr_db; - float snr_ant_port_db[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS]; - float rsrp; - float rsrp_dbm; - float rsrp_neigh; - float rsrp_port_dbm[SRSLTE_MAX_PORTS]; - float rsrp_ant_port_dbm[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS]; - float rsrq; - float rsrq_db; - float rsrq_ant_port_db[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS]; - float rssi_dbm; - float cfo; - float sync_error; -} srslte_chest_dl_res_t; - -// Noise estimation algorithm -typedef enum SRSLTE_API { - SRSLTE_NOISE_ALG_REFS = 0, - SRSLTE_NOISE_ALG_PSS, - SRSLTE_NOISE_ALG_EMPTY, -} srslte_chest_dl_noise_alg_t; - -// Channel estimator algorithm -typedef enum SRSLTE_API { - SRSLTE_ESTIMATOR_ALG_AVERAGE = 0, - SRSLTE_ESTIMATOR_ALG_INTERPOLATE, - SRSLTE_ESTIMATOR_ALG_WIENER, -} srslte_chest_dl_estimator_alg_t; - -typedef struct SRSLTE_API { - srslte_cell_t cell; - uint32_t nof_rx_antennas; - - srslte_refsignal_t csr_refs; - srslte_refsignal_t** mbsfn_refs; - - srslte_wiener_dl_t* wiener_dl; - - cf_t* pilot_estimates; - cf_t* pilot_estimates_average; - cf_t* pilot_recv_signal; - cf_t* tmp_noise; - cf_t* tmp_cfo_estimate; - -#ifdef FREQ_SEL_SNR - float snr_vector[12000]; - float pilot_power[12000]; -#endif - - srslte_interp_linsrslte_vec_t srslte_interp_linvec; - srslte_interp_lin_t srslte_interp_lin; - srslte_interp_lin_t srslte_interp_lin_3; - srslte_interp_lin_t srslte_interp_lin_mbsfn; - - float rssi[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS]; - float rsrp[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS]; - float rsrp_corr[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS]; - float noise_estimate[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS]; - float sync_err[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS]; - float cfo; - - /* Use PSS for noise estimation in LS linear interpolation mode */ - cf_t pss_signal[SRSLTE_PSS_LEN]; - cf_t tmp_pss[SRSLTE_PSS_LEN]; - cf_t tmp_pss_noisy[SRSLTE_PSS_LEN]; - -} srslte_chest_dl_t; - -typedef struct SRSLTE_API { - - srslte_chest_dl_estimator_alg_t estimator_alg; - srslte_chest_dl_noise_alg_t noise_alg; - - srslte_chest_filter_t filter_type; - float filter_coef[2]; - - uint16_t mbsfn_area_id; - bool rsrp_neighbour; - bool cfo_estimate_enable; - uint32_t cfo_estimate_sf_mask; - bool sync_error_enable; - -} srslte_chest_dl_cfg_t; - -SRSLTE_API int srslte_chest_dl_init(srslte_chest_dl_t* q, uint32_t max_prb, uint32_t nof_rx_antennas); - -SRSLTE_API void srslte_chest_dl_free(srslte_chest_dl_t* q); - -SRSLTE_API int srslte_chest_dl_res_init(srslte_chest_dl_res_t* q, uint32_t max_prb); -SRSLTE_API int srslte_chest_dl_res_init_re(srslte_chest_dl_res_t* q, uint32_t nof_re); - -SRSLTE_API void srslte_chest_dl_res_set_identity(srslte_chest_dl_res_t* q); - -SRSLTE_API void srslte_chest_dl_res_set_ones(srslte_chest_dl_res_t* q); - -SRSLTE_API void srslte_chest_dl_res_free(srslte_chest_dl_res_t* q); - -/* These functions change the internal object state */ - -SRSLTE_API int srslte_chest_dl_set_mbsfn_area_id(srslte_chest_dl_t* q, uint16_t mbsfn_area_id); - -SRSLTE_API int srslte_chest_dl_set_cell(srslte_chest_dl_t* q, srslte_cell_t cell); - -/* These functions do not change the internal state */ - -SRSLTE_API int srslte_chest_dl_estimate(srslte_chest_dl_t* q, - srslte_dl_sf_cfg_t* sf, - cf_t* input[SRSLTE_MAX_PORTS], - srslte_chest_dl_res_t* res); - -SRSLTE_API int srslte_chest_dl_estimate_cfg(srslte_chest_dl_t* q, - srslte_dl_sf_cfg_t* sf, - srslte_chest_dl_cfg_t* cfg, - cf_t* input[SRSLTE_MAX_PORTS], - srslte_chest_dl_res_t* res); - -SRSLTE_API srslte_chest_dl_estimator_alg_t srslte_chest_dl_str2estimator_alg(const char* str); - -#endif // SRSLTE_CHEST_DL_H diff --git a/lib/include/srslte/phy/ch_estimation/chest_dl_nbiot.h b/lib/include/srslte/phy/ch_estimation/chest_dl_nbiot.h deleted file mode 100644 index 27b91cf11..000000000 --- a/lib/include/srslte/phy/ch_estimation/chest_dl_nbiot.h +++ /dev/null @@ -1,88 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2020 Software Radio Systems Limited - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the distribution. - * - */ - -#ifndef SRSLTE_CHEST_DL_NBIOT_H -#define SRSLTE_CHEST_DL_NBIOT_H - -#include - -#include "srslte/config.h" - -#include "srslte/phy/ch_estimation/chest_common.h" -#include "srslte/phy/ch_estimation/chest_dl.h" -#include "srslte/phy/ch_estimation/refsignal_dl_nbiot.h" -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/resampling/interp.h" - -/*! \brief Downlink channel estimation for NB-IoT - * - * Estimates the channel in the resource elements transmitting references and - * interpolates for the rest of the resource grid. - * The equalizer uses the channel estimates to produce an estimation of the - * transmitted symbol. - * This object depends on the srslte_refsignal_t object for creating the LTE CSR signal. - */ -typedef struct { - srslte_nbiot_cell_t cell; - srslte_refsignal_dl_nbiot_t nrs_signal; - - cf_t* pilot_estimates; - cf_t* pilot_estimates_average; - cf_t* pilot_recv_signal; - cf_t* tmp_noise; - - uint32_t smooth_filter_len; - float smooth_filter[SRSLTE_CHEST_MAX_SMOOTH_FIL_LEN]; - - srslte_interp_linsrslte_vec_t srslte_interp_linvec; - srslte_interp_lin_t srslte_interp_lin; - - float rssi[SRSLTE_MAX_PORTS]; - float rsrp[SRSLTE_MAX_PORTS]; - float noise_estimate[SRSLTE_MAX_PORTS]; - - srslte_chest_dl_noise_alg_t noise_alg; - -} srslte_chest_dl_nbiot_t; - -SRSLTE_API int srslte_chest_dl_nbiot_init(srslte_chest_dl_nbiot_t* q, uint32_t max_prb); - -SRSLTE_API void srslte_chest_dl_nbiot_free(srslte_chest_dl_nbiot_t* q); - -SRSLTE_API int srslte_chest_dl_nbiot_set_cell(srslte_chest_dl_nbiot_t* q, srslte_nbiot_cell_t cell); - -SRSLTE_API void srslte_chest_dl_nbiot_set_smooth_filter(srslte_chest_dl_nbiot_t* q, float* filter, uint32_t filter_len); - -SRSLTE_API void srslte_chest_dl_nbiot_set_smooth_filter3_coeff(srslte_chest_dl_nbiot_t* q, float w); - -SRSLTE_API void srslte_chest_dl_nbiot_set_noise_alg(srslte_chest_dl_nbiot_t* q, - srslte_chest_dl_noise_alg_t noise_estimation_alg); - -SRSLTE_API int srslte_chest_dl_nbiot_estimate(srslte_chest_dl_nbiot_t* q, cf_t* input, cf_t** ce, uint32_t sf_idx); - -SRSLTE_API int srslte_chest_dl_nbiot_estimate_port(srslte_chest_dl_nbiot_t* q, - cf_t* input, - cf_t* ce, - uint32_t sf_idx, - uint32_t port_id); - -SRSLTE_API float srslte_chest_dl_nbiot_get_noise_estimate(srslte_chest_dl_nbiot_t* q); - -SRSLTE_API float srslte_chest_dl_nbiot_get_snr(srslte_chest_dl_nbiot_t* q); - -SRSLTE_API float srslte_chest_dl_nbiot_get_rssi(srslte_chest_dl_nbiot_t* q); - -SRSLTE_API float srslte_chest_dl_nbiot_get_rsrq(srslte_chest_dl_nbiot_t* q); - -SRSLTE_API float srslte_chest_dl_nbiot_get_rsrp(srslte_chest_dl_nbiot_t* q); - -#endif // SRSLTE_CHEST_DL_NBIOT_H diff --git a/lib/include/srslte/phy/ch_estimation/chest_sl.h b/lib/include/srslte/phy/ch_estimation/chest_sl.h deleted file mode 100644 index 6411328e1..000000000 --- a/lib/include/srslte/phy/ch_estimation/chest_sl.h +++ /dev/null @@ -1,107 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2020 Software Radio Systems Limited - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the distribution. - * - */ - -#ifndef SRSLTE_CHEST_SL_H -#define SRSLTE_CHEST_SL_H - -#include - -#include "srslte/phy/common/phy_common_sl.h" -#include "srslte/phy/resampling/interp.h" - -#define SRSLTE_SL_N_RU_SEQ (30) -#define SRSLTE_SL_MAX_DMRS_SYMB (4) -#define SRSLTE_SL_DEFAULT_NOF_DMRS_CYCLIC_SHIFTS (1) -#define SRSLTE_SL_MAX_PSCCH_NOF_DMRS_CYCLIC_SHIFTS (4) - -// Base Sequence Number - always 0 for sidelink: 3GPP TS 36.211 version 15.6.0 Release 15 Sec. 5.5.1.4 -#define SRSLTE_SL_BASE_SEQUENCE_NUMBER 0 -#define SRSLTE_SL_MAX_DMRS_PERIOD_LENGTH 320 - -typedef struct SRSLTE_API { - uint32_t prb_start_idx; // PRB start idx to map RE from RIV - uint32_t nof_prb; // PSSCH nof_prb, Length of continuous PRB to map RE (in the pool) from RIV - uint32_t N_x_id; - uint32_t sf_idx; // PSSCH sf_idx - uint32_t cyclic_shift; -} srslte_chest_sl_cfg_t; - -typedef struct SRSLTE_API { - - srslte_sl_channels_t channel; - srslte_cell_sl_t cell; - srslte_sl_comm_resource_pool_t sl_comm_resource_pool; - srslte_chest_sl_cfg_t chest_sl_cfg; - - uint32_t sf_n_re; - - uint32_t M_sc_rs; - int8_t nof_dmrs_symbols; - - // Orthogonal Sequence (W) Transmission Mode 1, 2 and PSBCH - int8_t w[SRSLTE_SL_MAX_DMRS_SYMB]; - - // Cyclic Shift Values - int8_t n_CS[SRSLTE_SL_MAX_DMRS_SYMB]; - - // Reference Signal Cyclic Shift - float alpha[SRSLTE_SL_MAX_DMRS_SYMB]; - - // Group Hopping Flag - uint32_t* f_gh_pattern; - - cf_t* r_sequence[SRSLTE_SL_MAX_DMRS_SYMB][SRSLTE_SL_MAX_PSCCH_NOF_DMRS_CYCLIC_SHIFTS]; - - cf_t* r_sequence_rx[SRSLTE_SL_MAX_DMRS_SYMB]; - - cf_t* ce; - cf_t* ce_average; - cf_t* noise_tmp; - float noise_estimated; - - srslte_interp_linsrslte_vec_t lin_vec_sl; - - bool sync_error_enable; - bool rsrp_enable; - float sync_err; - float rsrp_corr; - -} srslte_chest_sl_t; - -SRSLTE_API int srslte_chest_sl_init(srslte_chest_sl_t* q, - srslte_sl_channels_t channel, - srslte_cell_sl_t cell, - srslte_sl_comm_resource_pool_t sl_comm_resource_pool); - -SRSLTE_API int srslte_chest_sl_set_cell(srslte_chest_sl_t* q, srslte_cell_sl_t cell); - -SRSLTE_API int srslte_chest_sl_set_cfg(srslte_chest_sl_t* q, srslte_chest_sl_cfg_t chest_sl_cfg); - -SRSLTE_API float srslte_chest_sl_get_sync_error(srslte_chest_sl_t* q); - -SRSLTE_API float srslte_chest_sl_estimate_noise(srslte_chest_sl_t* q); - -SRSLTE_API float srslte_chest_sl_get_rsrp(srslte_chest_sl_t* q); - -SRSLTE_API int srslte_chest_sl_put_dmrs(srslte_chest_sl_t* q, cf_t* sf_buffer); - -SRSLTE_API int srslte_chest_sl_get_dmrs(srslte_chest_sl_t* q, cf_t* sf_buffer, cf_t** dmrs_received); - -SRSLTE_API void srslte_chest_sl_ls_estimate(srslte_chest_sl_t* q, cf_t* sf_buffer); - -SRSLTE_API void srslte_chest_sl_ls_equalize(srslte_chest_sl_t* q, cf_t* sf_buffer, cf_t* equalized_sf_buffer); - -SRSLTE_API void srslte_chest_sl_ls_estimate_equalize(srslte_chest_sl_t* q, cf_t* sf_buffer, cf_t* equalized_sf_buffer); - -SRSLTE_API void srslte_chest_sl_free(srslte_chest_sl_t* q); - -#endif \ No newline at end of file diff --git a/lib/include/srslte/phy/ch_estimation/chest_ul.h b/lib/include/srslte/phy/ch_estimation/chest_ul.h deleted file mode 100644 index 04688c250..000000000 --- a/lib/include/srslte/phy/ch_estimation/chest_ul.h +++ /dev/null @@ -1,116 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2020 Software Radio Systems Limited - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the distribution. - * - */ - -/********************************************************************************************** - * File: chest_ul.h - * - * Description: 3GPP LTE Uplink channel estimator and equalizer. - * Estimates the channel in the resource elements transmitting references and - * interpolates for the rest of the resource grid. - * The equalizer uses the channel estimates to produce an estimation of the - * transmitted symbol. - * - * Reference: - *********************************************************************************************/ - -#ifndef SRSLTE_CHEST_UL_H -#define SRSLTE_CHEST_UL_H - -#include - -#include "srslte/config.h" - -#include "srslte/phy/ch_estimation/chest_common.h" -#include "srslte/phy/ch_estimation/refsignal_ul.h" -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/phch/pucch_cfg.h" -#include "srslte/phy/phch/pusch_cfg.h" -#include "srslte/phy/resampling/interp.h" - -typedef struct SRSLTE_API { - cf_t* ce; - uint32_t nof_re; - float noise_estimate; - float noise_estimate_dbm; - float rsrp; - float rsrp_dBfs; - float epre; - float epre_dBfs; - float snr; - float snr_db; - float cfo_hz; - float ta_us; -} srslte_chest_ul_res_t; - -typedef struct { - srslte_cell_t cell; - - srslte_refsignal_ul_t dmrs_signal; - srslte_refsignal_ul_dmrs_pregen_t dmrs_pregen; - bool dmrs_signal_configured; - - srslte_refsignal_srs_pregen_t srs_pregen; - bool srs_signal_configured; - - cf_t* pilot_estimates; - cf_t* pilot_estimates_tmp[4]; - cf_t* pilot_recv_signal; - cf_t* pilot_known_signal; - cf_t* tmp_noise; - -#ifdef FREQ_SEL_SNR - float snr_vector[12000]; - float pilot_power[12000]; -#endif - uint32_t smooth_filter_len; - float smooth_filter[SRSLTE_CHEST_MAX_SMOOTH_FIL_LEN]; - - srslte_interp_linsrslte_vec_t srslte_interp_linvec; - -} srslte_chest_ul_t; - -SRSLTE_API int srslte_chest_ul_init(srslte_chest_ul_t* q, uint32_t max_prb); - -SRSLTE_API void srslte_chest_ul_free(srslte_chest_ul_t* q); - -SRSLTE_API int srslte_chest_ul_res_init(srslte_chest_ul_res_t* q, uint32_t max_prb); - -SRSLTE_API void srslte_chest_ul_res_set_identity(srslte_chest_ul_res_t* q); - -SRSLTE_API void srslte_chest_ul_res_free(srslte_chest_ul_res_t* q); - -SRSLTE_API int srslte_chest_ul_set_cell(srslte_chest_ul_t* q, srslte_cell_t cell); - -SRSLTE_API void srslte_chest_ul_pregen(srslte_chest_ul_t* q, - srslte_refsignal_dmrs_pusch_cfg_t* cfg, - srslte_refsignal_srs_cfg_t* srs_cfg); - -SRSLTE_API int srslte_chest_ul_estimate_pusch(srslte_chest_ul_t* q, - srslte_ul_sf_cfg_t* sf, - srslte_pusch_cfg_t* cfg, - cf_t* input, - srslte_chest_ul_res_t* res); - -SRSLTE_API int srslte_chest_ul_estimate_pucch(srslte_chest_ul_t* q, - srslte_ul_sf_cfg_t* sf, - srslte_pucch_cfg_t* cfg, - cf_t* input, - srslte_chest_ul_res_t* res); - -SRSLTE_API int srslte_chest_ul_estimate_srs(srslte_chest_ul_t* q, - srslte_ul_sf_cfg_t* sf, - srslte_refsignal_srs_cfg_t* cfg, - srslte_refsignal_dmrs_pusch_cfg_t* pusch_cfg, - cf_t* input, - srslte_chest_ul_res_t* res); - -#endif // SRSLTE_CHEST_UL_H diff --git a/lib/include/srslte/phy/ch_estimation/csi_rs.h b/lib/include/srslte/phy/ch_estimation/csi_rs.h deleted file mode 100644 index 76455e145..000000000 --- a/lib/include/srslte/phy/ch_estimation/csi_rs.h +++ /dev/null @@ -1,124 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2020 Software Radio Systems Limited - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the distribution. - * - */ - -#ifndef SRSLTE_CSI_RS_H_ -#define SRSLTE_CSI_RS_H_ - -#include "srslte/config.h" -#include "srslte/phy/common/phy_common_nr.h" -#include -#include -#include - -#define SRSLTE_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_ROW1 4 -#define SRSLTE_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_ROW2 12 -#define SRSLTE_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_ROW4 3 -#define SRSLTE_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_OTHER 6 -#define SRSLTE_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_MAX 12 - -typedef enum SRSLTE_API { - srslte_csi_rs_resource_mapping_row_1 = 0, - srslte_csi_rs_resource_mapping_row_2, - srslte_csi_rs_resource_mapping_row_4, - srslte_csi_rs_resource_mapping_row_other, -} srslte_csi_rs_resource_mapping_row_t; - -typedef enum SRSLTE_API { - srslte_csi_rs_resource_mapping_density_three = 0, - srslte_csi_rs_resource_mapping_density_dot5_even, - srslte_csi_rs_resource_mapping_density_dot5_odd, - srslte_csi_rs_resource_mapping_density_one, - srslte_csi_rs_resource_mapping_density_spare -} srslte_csi_rs_density_t; - -typedef enum SRSLTE_API { - srslte_csi_rs_cdm_nocdm = 0, - srslte_csi_rs_cdm_fd_cdm2, - srslte_csi_rs_cdm_cdm4_fd2_td2, - srslte_csi_rs_cdm_cdm8_fd2_td4 -} srslte_csi_rs_cdm_t; - -/** - * @brief Contains CSI-FrequencyOccupation flattened configuration - */ -typedef struct SRSLTE_API { - uint32_t start_rb; ///< PRB where this CSI resource starts in relation to common resource block #0 (CRB#0) on the - ///< common resource block grid. Only multiples of 4 are allowed (0, 4, ..., 274) - - uint32_t nof_rb; ///< Number of PRBs across which this CSI resource spans. Only multiples of 4 are allowed. The - ///< smallest configurable number is the minimum of 24 and the width of the associated BWP. If the - ///< configured value is larger than the width of the corresponding BWP, the UE shall assume that the - ///< actual CSI-RS bandwidth is equal to the width of the BWP. -} srslte_csi_rs_freq_occupation_t; - -/** - * @brief Contains CSI-ResourcePeriodicityAndOffset flattened configuration - */ -typedef struct SRSLTE_API { - uint32_t period; // 4,5,8,10,16,20,32,40,64,80,160,320,640 - uint32_t offset; // 0..period-1 -} srslte_csi_rs_period_and_offset_t; - -/** - * @brief Contains CSI-RS-ResourceMapping flattened configuration - */ -typedef struct SRSLTE_API { - srslte_csi_rs_resource_mapping_row_t row; - bool frequency_domain_alloc[SRSLTE_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_MAX]; - uint32_t ports; // 1, 2, 4, 8, 12, 16, 24, 32 - uint32_t first_symbol_idx; // 0..13 - uint32_t first_symbol_idx2; // 2..12 (set to 0 for disabled) - srslte_csi_rs_cdm_t cdm; - srslte_csi_rs_density_t density; - srslte_csi_rs_freq_occupation_t freq_band; -} srslte_csi_rs_resource_mapping_t; - -/** - * @brief Contains NZP-CSI-RS-Resource flattened configuration - */ -typedef struct SRSLTE_API { - srslte_csi_rs_resource_mapping_t resource_mapping; - - float power_control_offset; // -8..15 dB - float power_control_offset_ss; // -3, 0, 3, 6 dB - - uint32_t scrambling_id; // 0..1023 - - srslte_csi_rs_period_and_offset_t periodicity; - -} srslte_csi_rs_nzp_resource_t; - -SRSLTE_API int srslte_csi_rs_nzp_put(const srslte_carrier_nr_t* carrier, - const srslte_slot_cfg_t* slot_cfg, - const srslte_csi_rs_nzp_resource_t* resource, - cf_t* grid); - -typedef struct SRSLTE_API { - float rsrp; - float rsrp_dB; - float epre; - float epre_dB; - float n0; - float n0_dB; - float snr_dB; - uint32_t nof_re; -} srslte_csi_rs_measure_t; - -SRSLTE_API int srslte_csi_rs_nzp_measure(const srslte_carrier_nr_t* carrier, - const srslte_slot_cfg_t* slot_cfg, - const srslte_csi_rs_nzp_resource_t* resource, - const cf_t* grid, - srslte_csi_rs_measure_t* measure); - -SRSLTE_API uint32_t srslte_csi_rs_measure_info(const srslte_csi_rs_measure_t* measure, char* str, uint32_t str_len); - -#endif // SRSLTE_CSI_RS_H_ diff --git a/lib/include/srslte/phy/ch_estimation/refsignal_dl.h b/lib/include/srslte/phy/ch_estimation/refsignal_dl.h deleted file mode 100644 index 65f367065..000000000 --- a/lib/include/srslte/phy/ch_estimation/refsignal_dl.h +++ /dev/null @@ -1,92 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2020 Software Radio Systems Limited - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the distribution. - * - */ - -/********************************************************************************************** - * File: refsignal_dl.h - * - * Description: Object to manage downlink reference signals for channel estimation. - * - * Reference: 3GPP TS 36.211 version 10.0.0 Release 10 Sec. 6.10 - *********************************************************************************************/ - -#ifndef SRSLTE_REFSIGNAL_DL_H -#define SRSLTE_REFSIGNAL_DL_H - -#include "srslte/config.h" -#include "srslte/phy/common/phy_common.h" - -// Number of references in a subframe: there are 2 symbols for port_id=0,1 x 2 slots x 2 refs per prb -#define SRSLTE_REFSIGNAL_NUM_SF_MBSFN(nof_prb, port_id) ((2 + 18) * (nof_prb)) - -#define SRSLTE_REFSIGNAL_MAX_NUM_SF(nof_prb) (8 * nof_prb) -#define SRSLTE_REFSIGNAL_MAX_NUM_SF_MBSFN(nof_prb) SRSLTE_REFSIGNAL_NUM_SF_MBSFN(nof_prb, 0) - -#define SRSLTE_REFSIGNAL_PILOT_IDX(i, l, cell) (2 * cell.nof_prb * (l) + (i)) - -#define SRSLTE_REFSIGNAL_PILOT_IDX_MBSFN(i, l, cell) ((6 * cell.nof_prb * (l) + (i))) - -/** Cell-Specific Reference Signal */ -typedef struct SRSLTE_API { - srslte_cell_t cell; - cf_t* pilots[2][SRSLTE_NOF_SF_X_FRAME]; // Saves the reference signal per subframe for ports 0,1 and ports 2,3 - srslte_sf_t type; - uint16_t mbsfn_area_id; -} srslte_refsignal_t; - -SRSLTE_API int srslte_refsignal_cs_init(srslte_refsignal_t* q, uint32_t max_prb); - -SRSLTE_API int srslte_refsignal_cs_set_cell(srslte_refsignal_t* q, srslte_cell_t cell); - -SRSLTE_API void srslte_refsignal_free(srslte_refsignal_t* q); - -SRSLTE_API int -srslte_refsignal_cs_put_sf(srslte_refsignal_t* q, srslte_dl_sf_cfg_t* sf, uint32_t port_id, cf_t* sf_symbols); - -SRSLTE_API int srslte_refsignal_cs_get_sf(srslte_refsignal_t* q, - srslte_dl_sf_cfg_t* sf, - uint32_t port_id, - cf_t* sf_symbols, - cf_t* pilots); - -SRSLTE_API uint32_t srslte_refsignal_cs_fidx(srslte_cell_t cell, uint32_t l, uint32_t port_id, uint32_t m); - -SRSLTE_API uint32_t srslte_refsignal_cs_nsymbol(uint32_t l, srslte_cp_t cp, uint32_t port_id); - -SRSLTE_API uint32_t srslte_refsignal_cs_v(uint32_t port_id, uint32_t ref_symbol_idx); - -SRSLTE_API uint32_t srslte_refsignal_cs_nof_symbols(srslte_refsignal_t* q, srslte_dl_sf_cfg_t* sf, uint32_t port_id); - -SRSLTE_API uint32_t srslte_refsignal_cs_nof_pilots_x_slot(uint32_t nof_ports); - -SRSLTE_API uint32_t srslte_refsignal_cs_nof_re(srslte_refsignal_t* q, srslte_dl_sf_cfg_t* sf, uint32_t port_id); - -SRSLTE_API int srslte_refsignal_mbsfn_init(srslte_refsignal_t* q, uint32_t max_prb); - -SRSLTE_API int srslte_refsignal_mbsfn_set_cell(srslte_refsignal_t* q, srslte_cell_t cell, uint16_t mbsfn_area_id); - -SRSLTE_API int srslte_refsignal_mbsfn_get_sf(srslte_cell_t cell, uint32_t port_id, cf_t* sf_symbols, cf_t* pilots); - -SRSLTE_API uint32_t srslte_refsignal_mbsfn_nsymbol(uint32_t l); - -SRSLTE_API uint32_t srslte_refsignal_mbsfn_fidx(uint32_t l); - -SRSLTE_API uint32_t srslte_refsignal_mbsfn_nof_symbols(); - -SRSLTE_API int srslte_refsignal_mbsfn_put_sf(srslte_cell_t cell, - uint32_t port_id, - cf_t* cs_pilots, - cf_t* mbsfn_pilots, - cf_t* sf_symbols); - -SRSLTE_API int srslte_refsignal_mbsfn_gen_seq(srslte_refsignal_t* q, srslte_cell_t cell, uint32_t N_mbsfn_id); - -#endif // SRSLTE_REFSIGNAL_DL_H diff --git a/lib/include/srslte/phy/ch_estimation/refsignal_dl_nbiot.h b/lib/include/srslte/phy/ch_estimation/refsignal_dl_nbiot.h deleted file mode 100644 index 11fccfed1..000000000 --- a/lib/include/srslte/phy/ch_estimation/refsignal_dl_nbiot.h +++ /dev/null @@ -1,55 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2020 Software Radio Systems Limited - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the distribution. - * - */ - -#ifndef SRSLTE_REFSIGNAL_DL_NBIOT_H -#define SRSLTE_REFSIGNAL_DL_NBIOT_H - -#include "srslte/config.h" -#include "srslte/phy/common/phy_common.h" - -// Number of references in a subframe: there are 2 symbols for port_id=0,1 x 2 slots x 2 refs per prb -#define SRSLTE_NBIOT_NUM_NRS_X_SYM_X_PORT 2 - -// Max number of symbols with RE in one PRB (4 ports LTE plus 2 port NB-IoT) -#define SRSLTE_NBIOT_MAX_NUM_RE_WITH_REFS 40 - -#define SRSLTE_NBIOT_REFSIGNAL_NUM_SF(nof_prb, port_id) (((port_id) < 2 ? 8 : 4) * (nof_prb)) -#define SRSLTE_NBIOT_REFSIGNAL_PILOT_IDX(i, l, nof_prb) (2 * nof_prb * (l) + (i)) - -/** Brief: Narrowband Reference Signal (NRS) - * - * Object to manage downlink reference signals for channel estimation. (3GPP TS 36.211 version 13.3 Sec. 10.2.6) - */ -typedef struct SRSLTE_API { - srslte_nbiot_cell_t cell; - cf_t* pilots[2][SRSLTE_NOF_SF_X_FRAME]; // Saves the reference signal per subframe for ports 0 and 1 -} srslte_refsignal_dl_nbiot_t; - -SRSLTE_API int srslte_refsignal_dl_nbiot_init(srslte_refsignal_dl_nbiot_t* q); - -SRSLTE_API void srslte_refsignal_dl_nbiot_free(srslte_refsignal_dl_nbiot_t* q); - -SRSLTE_API uint32_t srslte_refsignal_dl_nbiot_nof_symbols(uint32_t port_id); - -SRSLTE_API int srslte_refsignal_dl_nbiot_set_cell(srslte_refsignal_dl_nbiot_t* q, srslte_nbiot_cell_t cell); - -SRSLTE_API uint32_t srslte_refsignal_dl_nbiot_fidx(srslte_nbiot_cell_t cell, uint32_t l, uint32_t port_id, uint32_t m); - -SRSLTE_API uint32_t srslte_refsignal_nrs_nsymbol(uint32_t l); - -SRSLTE_API uint32_t srslte_refsignal_nbiot_cs_nof_re(srslte_nbiot_cell_t* cell, uint32_t port_id); - -SRSLTE_API int srslte_refsignal_nrs_put_sf(srslte_nbiot_cell_t cell, uint32_t port_id, cf_t* pilots, cf_t* sf_symbols); - -SRSLTE_API int srslte_refsignal_nrs_get_sf(srslte_nbiot_cell_t cell, uint32_t port_id, cf_t* sf_symbols, cf_t* pilots); - -#endif // SRSLTE_REFSIGNAL_DL_NBIOT_H diff --git a/lib/include/srslte/phy/ch_estimation/refsignal_ul.h b/lib/include/srslte/phy/ch_estimation/refsignal_ul.h deleted file mode 100644 index f5d7dc4d6..000000000 --- a/lib/include/srslte/phy/ch_estimation/refsignal_ul.h +++ /dev/null @@ -1,184 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2020 Software Radio Systems Limited - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the distribution. - * - */ - -/********************************************************************************************** - * File: refsignal_ul.h - * - * Description: Object to manage uplink reference signals for channel estimation. - * - * Reference: 3GPP TS 36.211 version 10.0.0 Release 10 Sec. 5.5 - *********************************************************************************************/ - -#ifndef SRSLTE_REFSIGNAL_UL_H -#define SRSLTE_REFSIGNAL_UL_H - -#include "srslte/config.h" -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/phch/pucch_cfg.h" -#include "srslte/phy/phch/pusch_cfg.h" - -#define SRSLTE_NOF_GROUPS_U 30 -#define SRSLTE_NOF_SEQUENCES_U 2 -#define SRSLTE_NOF_DELTA_SS 30 -#define SRSLTE_NOF_CSHIFT 8 - -#define SRSLTE_REFSIGNAL_UL_L(ns_idx, cp) ((ns_idx + 1) * SRSLTE_CP_NSYMB(cp) - 4) - -/* PUSCH DMRS common configuration (received in SIB2) */ -typedef struct SRSLTE_API { - uint32_t cyclic_shift; - uint32_t delta_ss; - bool group_hopping_en; - bool sequence_hopping_en; -} srslte_refsignal_dmrs_pusch_cfg_t; - -typedef struct SRSLTE_API { - - // Common Configuration - uint32_t subframe_config; - uint32_t bw_cfg; - bool simul_ack; - - // Dedicated configuration - uint32_t B; - uint32_t b_hop; - uint32_t n_srs; - uint32_t I_srs; - uint32_t k_tc; - uint32_t n_rrc; - bool dedicated_enabled; - bool common_enabled; - bool configured; -} srslte_refsignal_srs_cfg_t; - -/** Uplink DeModulation Reference Signal (DMRS) */ -typedef struct SRSLTE_API { - srslte_cell_t cell; - - uint32_t n_cs_cell[SRSLTE_NSLOTS_X_FRAME][SRSLTE_CP_NORM_NSYMB]; - uint32_t n_prs_pusch[SRSLTE_NOF_DELTA_SS][SRSLTE_NSLOTS_X_FRAME]; // We precompute n_prs needed for cyclic shift alpha - // at srslte_refsignal_dl_init() - uint32_t f_gh[SRSLTE_NSLOTS_X_FRAME]; - uint32_t u_pucch[SRSLTE_NSLOTS_X_FRAME]; - uint32_t v_pusch[SRSLTE_NSLOTS_X_FRAME][SRSLTE_NOF_DELTA_SS]; -} srslte_refsignal_ul_t; - -typedef struct { - uint32_t max_prb; - cf_t** r[SRSLTE_NOF_CSHIFT][SRSLTE_NOF_SF_X_FRAME]; -} srslte_refsignal_ul_dmrs_pregen_t; - -typedef struct { - cf_t* r[SRSLTE_NOF_SF_X_FRAME]; -} srslte_refsignal_srs_pregen_t; - -SRSLTE_API int srslte_refsignal_ul_set_cell(srslte_refsignal_ul_t* q, srslte_cell_t cell); - -SRSLTE_API uint32_t srslte_refsignal_dmrs_N_rs(srslte_pucch_format_t format, srslte_cp_t cp); - -SRSLTE_API uint32_t srslte_refsignal_dmrs_pucch_symbol(uint32_t m, srslte_pucch_format_t format, srslte_cp_t cp); - -SRSLTE_API int srslte_refsignal_dmrs_pusch_pregen_init(srslte_refsignal_ul_dmrs_pregen_t* pregen, uint32_t max_prb); - -SRSLTE_API int srslte_refsignal_dmrs_pusch_pregen(srslte_refsignal_ul_t* q, - srslte_refsignal_ul_dmrs_pregen_t* pregen, - srslte_refsignal_dmrs_pusch_cfg_t* cfg); - -SRSLTE_API void srslte_refsignal_dmrs_pusch_pregen_free(srslte_refsignal_ul_t* q, - srslte_refsignal_ul_dmrs_pregen_t* pregen); - -SRSLTE_API int srslte_refsignal_dmrs_pusch_pregen_put(srslte_refsignal_ul_t* q, - srslte_ul_sf_cfg_t* sf_cfg, - srslte_refsignal_ul_dmrs_pregen_t* pregen, - srslte_pusch_cfg_t* pusch_cfg, - cf_t* sf_symbols); - -SRSLTE_API int srslte_refsignal_dmrs_pusch_gen(srslte_refsignal_ul_t* q, - srslte_refsignal_dmrs_pusch_cfg_t* cfg, - uint32_t nof_prb, - uint32_t sf_idx, - uint32_t cyclic_shift_for_dmrs, - cf_t* r_pusch); - -SRSLTE_API void srslte_refsignal_dmrs_pusch_put(srslte_refsignal_ul_t* q, - srslte_pusch_cfg_t* pusch_cfg, - cf_t* r_pusch, - cf_t* sf_symbols); - -SRSLTE_API void srslte_refsignal_dmrs_pusch_get(srslte_refsignal_ul_t* q, - srslte_pusch_cfg_t* pusch_cfg, - cf_t* sf_symbols, - cf_t* r_pusch); - -SRSLTE_API int srslte_refsignal_dmrs_pucch_gen(srslte_refsignal_ul_t* q, - srslte_ul_sf_cfg_t* sf, - srslte_pucch_cfg_t* cfg, - cf_t* r_pucch); - -SRSLTE_API int -srslte_refsignal_dmrs_pucch_put(srslte_refsignal_ul_t* q, srslte_pucch_cfg_t* cfg, cf_t* r_pucch, cf_t* output); - -SRSLTE_API int -srslte_refsignal_dmrs_pucch_get(srslte_refsignal_ul_t* q, srslte_pucch_cfg_t* cfg, cf_t* input, cf_t* r_pucch); - -SRSLTE_API int srslte_refsignal_srs_pregen(srslte_refsignal_ul_t* q, - srslte_refsignal_srs_pregen_t* pregen, - srslte_refsignal_srs_cfg_t* cfg, - srslte_refsignal_dmrs_pusch_cfg_t* dmrs); - -SRSLTE_API int srslte_refsignal_srs_pregen_put(srslte_refsignal_ul_t* q, - srslte_refsignal_srs_pregen_t* pregen, - srslte_refsignal_srs_cfg_t* cfg, - uint32_t tti, - cf_t* sf_symbols); - -SRSLTE_API void srslte_refsignal_srs_pregen_free(srslte_refsignal_ul_t* q, srslte_refsignal_srs_pregen_t* pregen); - -SRSLTE_API int srslte_refsignal_srs_gen(srslte_refsignal_ul_t* q, - srslte_refsignal_srs_cfg_t* cfg, - srslte_refsignal_dmrs_pusch_cfg_t* pusch_cfg, - uint32_t sf_idx, - cf_t* r_srs); - -SRSLTE_API int srslte_refsignal_srs_put(srslte_refsignal_ul_t* q, - srslte_refsignal_srs_cfg_t* cfg, - uint32_t tti, - cf_t* r_srs, - cf_t* sf_symbols); - -SRSLTE_API int srslte_refsignal_srs_get(srslte_refsignal_ul_t* q, - srslte_refsignal_srs_cfg_t* cfg, - uint32_t tti, - cf_t* r_srs, - cf_t* sf_symbols); - -SRSLTE_API void srslte_refsignal_srs_pusch_shortened(srslte_refsignal_ul_t* q, - srslte_ul_sf_cfg_t* sf, - srslte_refsignal_srs_cfg_t* srs_cfg, - srslte_pusch_cfg_t* pusch_cfg); - -SRSLTE_API void srslte_refsignal_srs_pucch_shortened(srslte_refsignal_ul_t* q, - srslte_ul_sf_cfg_t* sf, - srslte_refsignal_srs_cfg_t* srs_cfg, - srslte_pucch_cfg_t* pucch_cfg); - -SRSLTE_API int srslte_refsignal_srs_send_cs(uint32_t subframe_config, uint32_t sf_idx); - -SRSLTE_API int srslte_refsignal_srs_send_ue(uint32_t I_srs, uint32_t tti); - -SRSLTE_API uint32_t srslte_refsignal_srs_rb_start_cs(uint32_t bw_cfg, uint32_t nof_prb); - -SRSLTE_API uint32_t srslte_refsignal_srs_rb_L_cs(uint32_t bw_cfg, uint32_t nof_prb); - -SRSLTE_API uint32_t srslte_refsignal_srs_M_sc(srslte_refsignal_ul_t* q, srslte_refsignal_srs_cfg_t* cfg); - -#endif // SRSLTE_REFSIGNAL_UL_H diff --git a/lib/include/srslte/phy/common/phy_common.h b/lib/include/srslte/phy/common/phy_common.h deleted file mode 100644 index 61ee36065..000000000 --- a/lib/include/srslte/phy/common/phy_common.h +++ /dev/null @@ -1,524 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2020 Software Radio Systems Limited - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the distribution. - * - */ - -/********************************************************************************************** - * File: phy_common.h - * - * Description: Common parameters and lookup functions for PHY - * - * Reference: 3GPP TS 36.211 version 10.0.0 Release 10 - *********************************************************************************************/ - -#ifndef SRSLTE_PHY_COMMON_H -#define SRSLTE_PHY_COMMON_H - -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#include "srslte/config.h" - -#define SRSLTE_NOF_SF_X_FRAME 10 -#define SRSLTE_NOF_SLOTS_PER_SF 2 -#define SRSLTE_NSLOTS_X_FRAME (SRSLTE_NOF_SLOTS_PER_SF * SRSLTE_NOF_SF_X_FRAME) - -#define SRSLTE_NSOFT_BITS 250368 // Soft buffer size for Category 1 UE - -#define SRSLTE_PC_MAX 23 // Maximum TX power for Category 1 UE (in dBm) - -#define SRSLTE_NOF_NID_1 (168) -#define SRSLTE_NOF_NID_2 (3) -#define SRSLTE_NUM_PCI (SRSLTE_NOF_NID_1 * SRSLTE_NOF_NID_2) - -#define SRSLTE_MAX_CARRIERS 5 // Maximum number of supported simultaneous carriers -#define SRSLTE_MAX_PORTS 4 -#define SRSLTE_MAX_CHANNELS (SRSLTE_MAX_CARRIERS * SRSLTE_MAX_PORTS) -#define SRSLTE_MAX_LAYERS 4 -#define SRSLTE_MAX_CODEWORDS 2 -#define SRSLTE_MAX_TB SRSLTE_MAX_CODEWORDS -#define SRSLTE_MAX_QM 8 - -#define SRSLTE_MAX_CODEBLOCKS 32 - -#define SRSLTE_MAX_CODEBOOKS 4 - -#define SRSLTE_NOF_CFI 3 -#define SRSLTE_CFI_ISVALID(x) ((x >= 1 && x <= 3)) -#define SRSLTE_CFI_IDX(x) ((x - 1) % SRSLTE_NOF_CFI) - -#define SRSLTE_LTE_CRC24A 0x1864CFB -#define SRSLTE_LTE_CRC24B 0X1800063 -#define SRSLTE_LTE_CRC24C 0X1B2B117 -#define SRSLTE_LTE_CRC16 0x11021 -#define SRSLTE_LTE_CRC11 0xE21 -#define SRSLTE_LTE_CRC8 0x19B -#define SRSLTE_LTE_CRC6 0x61 - -#define SRSLTE_MAX_MBSFN_AREA_IDS 256 -#define SRSLTE_PMCH_RV 0 - -typedef enum { SRSLTE_CP_NORM = 0, SRSLTE_CP_EXT } srslte_cp_t; -typedef enum { SRSLTE_SF_NORM = 0, SRSLTE_SF_MBSFN } srslte_sf_t; - -#define SRSLTE_INVALID_RNTI 0x0 // TS 36.321 - Table 7.1-1 RNTI 0x0 isn't a valid DL RNTI -#define SRSLTE_CRNTI_START 0x000B -#define SRSLTE_CRNTI_END 0xFFF3 -#define SRSLTE_RARNTI_START 0x0001 -#define SRSLTE_RARNTI_END 0x000A -#define SRSLTE_SIRNTI 0xFFFF -#define SRSLTE_PRNTI 0xFFFE -#define SRSLTE_MRNTI 0xFFFD - -#define SRSLTE_RNTI_ISRAR(rnti) (rnti >= SRSLTE_RARNTI_START && rnti <= SRSLTE_RARNTI_END) -#define SRSLTE_RNTI_ISUSER(rnti) (rnti >= SRSLTE_CRNTI_START && rnti <= SRSLTE_CRNTI_END) -#define SRSLTE_RNTI_ISSI(rnti) (rnti == SRSLTE_SIRNTI) -#define SRSLTE_RNTI_ISPA(rnti) (rnti == SRSLTE_PRNTI) -#define SRSLTE_RNTI_ISMBSFN(rnti) (rnti == SRSLTE_MRNTI) -#define SRSLTE_RNTI_ISSIRAPA(rnti) (SRSLTE_RNTI_ISSI(rnti) || SRSLTE_RNTI_ISRAR(rnti) || SRSLTE_RNTI_ISPA(rnti)) - -#define SRSLTE_CELL_ID_UNKNOWN 1000 - -#define SRSLTE_MAX_NSYMB 7 - -#define SRSLTE_MAX_PRB 110 -#define SRSLTE_NRE 12 - -#define SRSLTE_SYMBOL_SZ_MAX 2048 - -#define SRSLTE_CP_NORM_NSYMB 7 -#define SRSLTE_CP_NORM_SF_NSYMB (2 * SRSLTE_CP_NORM_NSYMB) -#define SRSLTE_CP_NORM_0_LEN 160 -#define SRSLTE_CP_NORM_LEN 144 - -#define SRSLTE_CP_EXT_NSYMB 6 -#define SRSLTE_CP_EXT_SF_NSYMB (2 * SRSLTE_CP_EXT_NSYMB) -#define SRSLTE_CP_EXT_LEN 512 -#define SRSLTE_CP_EXT_7_5_LEN 1024 - -#define SRSLTE_CP_ISNORM(cp) (cp == SRSLTE_CP_NORM) -#define SRSLTE_CP_ISEXT(cp) (cp == SRSLTE_CP_EXT) -#define SRSLTE_CP_NSYMB(cp) (SRSLTE_CP_ISNORM(cp) ? SRSLTE_CP_NORM_NSYMB : SRSLTE_CP_EXT_NSYMB) - -#define SRSLTE_CP_LEN(symbol_sz, c) ((int)ceilf((((float)(c) * (symbol_sz)) / 2048.0f))) -#define SRSLTE_CP_LEN_NORM(symbol, symbol_sz) \ - (((symbol) == 0) ? SRSLTE_CP_LEN((symbol_sz), SRSLTE_CP_NORM_0_LEN) : SRSLTE_CP_LEN((symbol_sz), SRSLTE_CP_NORM_LEN)) -#define SRSLTE_CP_LEN_EXT(symbol_sz) (SRSLTE_CP_LEN((symbol_sz), SRSLTE_CP_EXT_LEN)) - -#define SRSLTE_CP_SZ(symbol_sz, cp) \ - (SRSLTE_CP_LEN(symbol_sz, (SRSLTE_CP_ISNORM(cp) ? SRSLTE_CP_NORM_LEN : SRSLTE_CP_EXT_LEN))) -#define SRSLTE_SYMBOL_SZ(symbol_sz, cp) (symbol_sz + SRSLTE_CP_SZ(symbol_sz, cp)) -#define SRSLTE_SLOT_LEN(symbol_sz) (symbol_sz * 15 / 2) -#define SRSLTE_SF_LEN(symbol_sz) (symbol_sz * 15) -#define SRSLTE_SF_LEN_MAX (SRSLTE_SF_LEN(SRSLTE_SYMBOL_SZ_MAX)) - -#define SRSLTE_SLOT_LEN_PRB(nof_prb) (SRSLTE_SLOT_LEN(srslte_symbol_sz(nof_prb))) -#define SRSLTE_SF_LEN_PRB(nof_prb) ((uint32_t)SRSLTE_SF_LEN(srslte_symbol_sz(nof_prb))) - -#define SRSLTE_SLOT_LEN_RE(nof_prb, cp) (nof_prb * SRSLTE_NRE * SRSLTE_CP_NSYMB(cp)) -#define SRSLTE_SF_LEN_RE(nof_prb, cp) (2 * SRSLTE_SLOT_LEN_RE(nof_prb, cp)) -#define SRSLTE_NOF_RE(cell) (2 * SRSLTE_SLOT_LEN_RE(cell.nof_prb, cell.cp)) - -#define SRSLTE_TA_OFFSET (10e-6) - -#define SRSLTE_LTE_TS (1.0f / (15000.0f * 2048.0f)) - -#define SRSLTE_SLOT_IDX_CPNORM(symbol_idx, symbol_sz) \ - (symbol_idx == 0 ? 0 \ - : (symbol_sz + SRSLTE_CP_LEN(symbol_sz, SRSLTE_CP_NORM_0_LEN) + \ - (symbol_idx - 1) * (symbol_sz + SRSLTE_CP_LEN(symbol_sz, SRSLTE_CP_NORM_LEN)))) -#define SRSLTE_SLOT_IDX_CPEXT(idx, symbol_sz) (idx * (symbol_sz + SRSLTE_CP(symbol_sz, SRSLTE_CP_EXT_LEN))) - -#define SRSLTE_RE_IDX(nof_prb, symbol_idx, sample_idx) ((symbol_idx) * (nof_prb) * (SRSLTE_NRE) + sample_idx) - -#define SRSLTE_RS_VSHIFT(cell_id) (cell_id % 6) - -#define SRSLTE_GUARD_RE(nof_prb) ((srslte_symbol_sz(nof_prb) - nof_prb * SRSLTE_NRE) / 2) - -#define SRSLTE_SYMBOL_HAS_REF(l, cp, nof_ports) ((l == 1 && nof_ports == 4) || l == 0 || l == SRSLTE_CP_NSYMB(cp) - 3) - -#define SRSLTE_NOF_CTRL_SYMBOLS(cell, cfi) (cfi + (cell.nof_prb < 10 ? 1 : 0)) - -#define SRSLTE_SYMBOL_HAS_REF_MBSFN(l, s) ((l == 2 && s == 0) || (l == 0 && s == 1) || (l == 4 && s == 1)) - -#define SRSLTE_NON_MBSFN_REGION_GUARD_LENGTH(non_mbsfn_region, symbol_sz) \ - ((non_mbsfn_region == 1) \ - ? (SRSLTE_CP_LEN_EXT(symbol_sz) - SRSLTE_CP_LEN_NORM(0, symbol_sz)) \ - : (2 * SRSLTE_CP_LEN_EXT(symbol_sz) - SRSLTE_CP_LEN_NORM(0, symbol_sz) - SRSLTE_CP_LEN_NORM(1, symbol_sz))) - -#define SRSLTE_FDD_NOF_HARQ (FDD_HARQ_DELAY_DL_MS + FDD_HARQ_DELAY_UL_MS) -#define SRSLTE_MAX_HARQ_PROC 15 - -#define SRSLTE_NOF_LTE_BANDS 58 - -#define SRSLTE_DEFAULT_MAX_FRAMES_PBCH 500 -#define SRSLTE_DEFAULT_MAX_FRAMES_PSS 10 -#define SRSLTE_DEFAULT_NOF_VALID_PSS_FRAMES 10 - -#define ZERO_OBJECT(x) memset(&(x), 0x0, sizeof((x))) - -typedef enum SRSLTE_API { SRSLTE_PHICH_NORM = 0, SRSLTE_PHICH_EXT } srslte_phich_length_t; - -typedef enum SRSLTE_API { - SRSLTE_PHICH_R_1_6 = 0, - SRSLTE_PHICH_R_1_2, - SRSLTE_PHICH_R_1, - SRSLTE_PHICH_R_2 -} srslte_phich_r_t; - -/// LTE duplex modes. -typedef enum SRSLTE_API { - /// FDD uses frame structure type 1. - SRSLTE_FDD = 0, - /// TDD uses frame structure type 2. - SRSLTE_TDD = 1 -} srslte_frame_type_t; - -/// Maximum number of TDD special subframe configurations. -#define SRSLTE_MAX_TDD_SS_CONFIGS (10u) - -/// Maximum number of TDD uplink-downlink subframe configurations. -#define SRSLTE_MAX_TDD_SF_CONFIGS (7u) - -/// Configuration fields for operating in TDD mode. -typedef struct SRSLTE_API { - /// Uplink-downlink configuration, valid range is [0,SRSLTE_MAX_TDD_SF_CONFIGS[. - /// TS 36.211 v8.9.0 Table 4.2-2. - uint32_t sf_config; - /// Special subframe symbol length configuration, valid range is [0,SRSLTE_MAX_TDD_SS_CONFIGS[. - /// TS 36.211 v13.13.0 Table 4.2-1. - uint32_t ss_config; - /// Set to true when the fields have been configured, otherwise false. - bool configured; -} srslte_tdd_config_t; - -/// TDD uplink-downlink subframe types. -typedef enum SRSLTE_API { - /// Subframe is reserved for downlink transmissions. - SRSLTE_TDD_SF_D = 0, - /// Subframe is reserved for uplink transmissions. - SRSLTE_TDD_SF_U = 1, - /// Special subframe. - SRSLTE_TDD_SF_S = 2, -} srslte_tdd_sf_t; - -typedef struct { - uint8_t mbsfn_area_id; - uint8_t non_mbsfn_region_length; - uint8_t mbsfn_mcs; - bool enable; - bool is_mcch; -} srslte_mbsfn_cfg_t; - -// Common cell constant properties that require object reconfiguration -typedef struct SRSLTE_API { - uint32_t nof_prb; - uint32_t nof_ports; - uint32_t id; - srslte_cp_t cp; - srslte_phich_length_t phich_length; - srslte_phich_r_t phich_resources; - srslte_frame_type_t frame_type; -} srslte_cell_t; - -// Common downlink properties that may change every subframe -typedef struct SRSLTE_API { - srslte_tdd_config_t tdd_config; - uint32_t tti; - uint32_t cfi; - srslte_sf_t sf_type; - uint32_t non_mbsfn_region; -} srslte_dl_sf_cfg_t; - -typedef struct SRSLTE_API { - srslte_tdd_config_t tdd_config; - uint32_t tti; - bool shortened; -} srslte_ul_sf_cfg_t; - -typedef enum SRSLTE_API { - SRSLTE_TM1 = 0, - SRSLTE_TM2, - SRSLTE_TM3, - SRSLTE_TM4, - SRSLTE_TM5, - SRSLTE_TM6, - SRSLTE_TM7, - SRSLTE_TM8, - SRSLTE_TMINV // Invalid Transmission Mode -} srslte_tm_t; - -typedef enum SRSLTE_API { - SRSLTE_TXSCHEME_PORT0, - SRSLTE_TXSCHEME_DIVERSITY, - SRSLTE_TXSCHEME_SPATIALMUX, - SRSLTE_TXSCHEME_CDD -} srslte_tx_scheme_t; - -typedef enum SRSLTE_API { SRSLTE_MIMO_DECODER_ZF, SRSLTE_MIMO_DECODER_MMSE } srslte_mimo_decoder_t; - -/*! - * \brief Types of modulations and associated modulation order. - */ -typedef enum SRSLTE_API { - SRSLTE_MOD_BPSK = 0, /*!< \brief BPSK. */ - SRSLTE_MOD_QPSK, /*!< \brief QPSK. */ - SRSLTE_MOD_16QAM, /*!< \brief QAM16. */ - SRSLTE_MOD_64QAM, /*!< \brief QAM64. */ - SRSLTE_MOD_256QAM, /*!< \brief QAM256. */ - SRSLTE_MOD_NITEMS -} srslte_mod_t; - -typedef enum { - SRSLTE_DCI_FORMAT0 = 0, - SRSLTE_DCI_FORMAT1, - SRSLTE_DCI_FORMAT1A, - SRSLTE_DCI_FORMAT1B, - SRSLTE_DCI_FORMAT1C, - SRSLTE_DCI_FORMAT1D, - SRSLTE_DCI_FORMAT2, - SRSLTE_DCI_FORMAT2A, - SRSLTE_DCI_FORMAT2B, - // SRSLTE_DCI_FORMAT3, - // SRSLTE_DCI_FORMAT3A, - SRSLTE_DCI_FORMATN0, - SRSLTE_DCI_FORMATN1, - SRSLTE_DCI_FORMATN2, - SRSLTE_DCI_FORMAT_RAR, // Not a real LTE format. Used internally to indicate RAR grant - SRSLTE_DCI_NOF_FORMATS -} srslte_dci_format_t; - -typedef enum { - SRSLTE_PUCCH_ACK_NACK_FEEDBACK_MODE_NORMAL = 0, /* No cell selection no pucch3 */ - SRSLTE_PUCCH_ACK_NACK_FEEDBACK_MODE_CS, - SRSLTE_PUCCH_ACK_NACK_FEEDBACK_MODE_PUCCH3, - SRSLTE_PUCCH_ACK_NACK_FEEDBACK_MODE_ERROR, -} srslte_ack_nack_feedback_mode_t; - -typedef struct SRSLTE_API { - int id; - float fd; -} srslte_earfcn_t; - -enum band_geographical_area { - SRSLTE_BAND_GEO_AREA_ALL, - SRSLTE_BAND_GEO_AREA_NAR, - SRSLTE_BAND_GEO_AREA_APAC, - SRSLTE_BAND_GEO_AREA_EMEA, - SRSLTE_BAND_GEO_AREA_JAPAN, - SRSLTE_BAND_GEO_AREA_CALA, - SRSLTE_BAND_GEO_AREA_NA -}; - -///< NB-IoT specific structs -typedef enum { - SRSLTE_NBIOT_MODE_INBAND_SAME_PCI = 0, - SRSLTE_NBIOT_MODE_INBAND_DIFFERENT_PCI, - SRSLTE_NBIOT_MODE_GUARDBAND, - SRSLTE_NBIOT_MODE_STANDALONE, - SRSLTE_NBIOT_MODE_N_ITEMS, -} srslte_nbiot_mode_t; - -typedef struct SRSLTE_API { - srslte_cell_t base; // the umbrella or super cell - uint32_t nbiot_prb; // the index of the NB-IoT PRB within the cell - uint32_t n_id_ncell; - uint32_t nof_ports; // The number of antenna ports for NB-IoT - bool is_r14; // Whether the cell is a R14 cell - srslte_nbiot_mode_t mode; -} srslte_nbiot_cell_t; - -#define SRSLTE_NBIOT_MAX_PORTS 2 -#define SRSLTE_NBIOT_MAX_CODEWORDS SRSLTE_MAX_CODEWORDS - -#define SRSLTE_SF_LEN_PRB_NBIOT (SRSLTE_SF_LEN_PRB(1)) - -#define SRSLTE_SF_LEN_RE_NBIOT (SRSLTE_SF_LEN_RE(1, SRSLTE_CP_NORM)) - -#define SRSLTE_NBIOT_FFT_SIZE 128 -#define SRSLTE_NBIOT_FREQ_SHIFT_FACTOR ((float)-0.5) -#define SRSLTE_NBIOT_NUM_RX_ANTENNAS 1 -#define SRSLTE_NBIOT_MAX_PRB 1 - -#define SRSLTE_NBIOT_DEFAULT_NUM_PRB_BASECELL 1 -#define SRSLTE_NBIOT_DEFAULT_PRB_OFFSET 0 - -#define SRSLTE_DEFAULT_MAX_FRAMES_NPBCH 500 -#define SRSLTE_DEFAULT_MAX_FRAMES_NPSS 20 -#define SRSLTE_DEFAULT_NOF_VALID_NPSS_FRAMES 20 - -#define SRSLTE_NBIOT_NPBCH_NOF_TOTAL_BITS (1600) ///< Number of bits for the entire NPBCH (See 36.211 Sec 10.2.4.1) -#define SRSLTE_NBIOT_NPBCH_NOF_BITS_SF \ - (SRSLTE_NBIOT_NPBCH_NOF_TOTAL_BITS / 8) ///< The NPBCH is transmitted in 8 blocks (See 36.211 Sec 10.2.4.4) - -#define SRSLTE_MAX_DL_BITS_CAT_NB1 (680) ///< TS 36.306 v15.4.0 Table 4.1C-1 - -///< PHY common function declarations - -SRSLTE_API bool srslte_cell_isvalid(srslte_cell_t* cell); - -SRSLTE_API void srslte_cell_fprint(FILE* stream, srslte_cell_t* cell, uint32_t sfn); - -SRSLTE_API bool srslte_cellid_isvalid(uint32_t cell_id); - -SRSLTE_API bool srslte_nofprb_isvalid(uint32_t nof_prb); - -/** - * Returns the subframe type for a given subframe number and a TDD configuration. - * Check TS 36.211 v8.9.0 Table 4.2-2. - * - * @param tdd_config TDD configuration. - * @param sf_idx Subframe number, must be in range [0,SRSLTE_NOF_SF_X_FRAME[. - * @return Returns the subframe type. - */ -SRSLTE_API srslte_tdd_sf_t srslte_sfidx_tdd_type(srslte_tdd_config_t tdd_config, uint32_t sf_idx); - -/** - * Returns the number of UpPTS symbols in a subframe. - * Check TS 36.211 v13.13.0 Table 4.2-1. - * - * @param tdd_config TDD configuration. - * @return Returns the number of UpPTS symbols. - */ -SRSLTE_API uint32_t srslte_sfidx_tdd_nof_up(srslte_tdd_config_t tdd_config); - -/** - * Returns the number of GP symbols in a subframe. - * Check TS 36.211 v13.13.0 Table 4.2-1. - * - * @param tdd_config TDD configuration. - * @return Returns the number of GP symbols. - */ -SRSLTE_API uint32_t srslte_sfidx_tdd_nof_gp(srslte_tdd_config_t tdd_config); - -/** - * Returns the number of DwPTS symbols in a subframe. - * Check TS 36.211 v13.13.0 Table 4.2-1. - * - * @param tdd_config TDD configuration. - * @return Returns the number of DwPTS symbols. - */ -SRSLTE_API uint32_t srslte_sfidx_tdd_nof_dw(srslte_tdd_config_t tdd_config); - -SRSLTE_API uint32_t srslte_tdd_nof_harq(srslte_tdd_config_t tdd_config); - -SRSLTE_API uint32_t srslte_sfidx_tdd_nof_dw_slot(srslte_tdd_config_t tdd_config, uint32_t slot, srslte_cp_t cp); - -SRSLTE_API bool srslte_sfidx_isvalid(uint32_t sf_idx); - -SRSLTE_API bool srslte_portid_isvalid(uint32_t port_id); - -SRSLTE_API bool srslte_N_id_2_isvalid(uint32_t N_id_2); - -SRSLTE_API bool srslte_N_id_1_isvalid(uint32_t N_id_1); - -SRSLTE_API bool srslte_symbol_sz_isvalid(uint32_t symbol_sz); - -SRSLTE_API int srslte_symbol_sz(uint32_t nof_prb); - -SRSLTE_API int srslte_symbol_sz_power2(uint32_t nof_prb); - -SRSLTE_API int srslte_nof_prb(uint32_t symbol_sz); - -SRSLTE_API uint32_t srslte_max_cce(uint32_t nof_prb); - -SRSLTE_API int srslte_sampling_freq_hz(uint32_t nof_prb); - -SRSLTE_API void srslte_use_standard_symbol_size(bool enabled); - -SRSLTE_API bool srslte_symbol_size_is_standard(); - -SRSLTE_API uint32_t srslte_re_x_prb(uint32_t ns, uint32_t symbol, uint32_t nof_ports, uint32_t nof_symbols); - -SRSLTE_API uint32_t srslte_voffset(uint32_t symbol_id, uint32_t cell_id, uint32_t nof_ports); - -SRSLTE_API int srslte_group_hopping_f_gh(uint32_t f_gh[SRSLTE_NSLOTS_X_FRAME], uint32_t cell_id); - -SRSLTE_API uint32_t srslte_N_ta_new_rar(uint32_t ta); - -SRSLTE_API uint32_t srslte_N_ta_new(uint32_t N_ta_old, uint32_t ta); - -SRSLTE_API float srslte_coderate(uint32_t tbs, uint32_t nof_re); - -SRSLTE_API char* srslte_cp_string(srslte_cp_t cp); - -SRSLTE_API srslte_mod_t srslte_str2mod(const char* mod_str); - -SRSLTE_API char* srslte_mod_string(srslte_mod_t mod); - -SRSLTE_API uint32_t srslte_mod_bits_x_symbol(srslte_mod_t mod); - -SRSLTE_API uint8_t srslte_band_get_band(uint32_t dl_earfcn); - -SRSLTE_API bool srslte_band_is_tdd(uint32_t band); - -SRSLTE_API double srslte_band_fd(uint32_t dl_earfcn); - -SRSLTE_API double srslte_band_fu(uint32_t ul_earfcn); - -SRSLTE_API uint32_t srslte_band_ul_earfcn(uint32_t dl_earfcn); - -SRSLTE_API int -srslte_band_get_fd_band(uint32_t band, srslte_earfcn_t* earfcn, int earfcn_start, int earfcn_end, uint32_t max_elems); - -SRSLTE_API int srslte_band_get_fd_band_all(uint32_t band, srslte_earfcn_t* earfcn, uint32_t max_nelems); - -SRSLTE_API int -srslte_band_get_fd_region(enum band_geographical_area region, srslte_earfcn_t* earfcn, uint32_t max_elems); - -SRSLTE_API int srslte_str2mimotype(char* mimo_type_str, srslte_tx_scheme_t* type); - -SRSLTE_API char* srslte_mimotype2str(srslte_tx_scheme_t mimo_type); - -/* Returns the interval tti1-tti2 mod 10240 */ -SRSLTE_API uint32_t srslte_tti_interval(uint32_t tti1, uint32_t tti2); - -SRSLTE_API uint32_t srslte_print_check(char* s, size_t max_len, uint32_t cur_len, const char* format, ...); - -SRSLTE_API bool srslte_nbiot_cell_isvalid(srslte_nbiot_cell_t* cell); -SRSLTE_API bool srslte_nbiot_portid_isvalid(uint32_t port_id); -SRSLTE_API float srslte_band_fu_nbiot(uint32_t ul_earfcn, const float m_ul); - -SRSLTE_API char* srslte_nbiot_mode_string(srslte_nbiot_mode_t mode); - -/** - * Returns a constant string pointer with the ACK/NACK feedback mode - * - * @param ack_nack_feedback_mode Mode - * @return Returns constant pointer with the text of the mode if succesful, `error` otherwise - */ -SRSLTE_API const char* srslte_ack_nack_feedback_mode_string(srslte_ack_nack_feedback_mode_t ack_nack_feedback_mode); - -/** - * Returns a constant string pointer with the ACK/NACK feedback mode - * - * @param ack_nack_feedback_mode Mode - * @return Returns constant pointer with the text of the mode if succesful, `error` otherwise - */ -SRSLTE_API srslte_ack_nack_feedback_mode_t srslte_string_ack_nack_feedback_mode(const char* str); - -/** - * Returns the number of bits for Rank Indicador reporting depending on the cell - * - * @param cell - */ -SRSLTE_API uint32_t srslte_ri_nof_bits(const srslte_cell_t* cell); - -#ifdef __cplusplus -} -#endif - -#endif // SRSLTE_PHY_COMMON_H diff --git a/lib/include/srslte/phy/common/phy_common_sl.h b/lib/include/srslte/phy/common/phy_common_sl.h deleted file mode 100644 index 0c8fc9f85..000000000 --- a/lib/include/srslte/phy/common/phy_common_sl.h +++ /dev/null @@ -1,167 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2020 Software Radio Systems Limited - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the distribution. - * - */ - -/********************************************************************************************** - * File: phy_common_sl.h - * - * Description: Common parameters and lookup functions for Sidelink PHY - * - * Reference: 3GPP TS 36.211 version 15.3.0 Release 15 - *********************************************************************************************/ - -#ifndef SRSLTE_PHY_COMMON_SL_H -#define SRSLTE_PHY_COMMON_SL_H - -/** - * \brief Common parameters and lookup functions for Sidelink PHY - */ - -#include "srslte/phy/common/phy_common.h" - -typedef enum SRSLTE_API { - SRSLTE_SIDELINK_TM1 = 0, - SRSLTE_SIDELINK_TM2, - SRSLTE_SIDELINK_TM3, - SRSLTE_SIDELINK_TM4 -} srslte_sl_tm_t; - -typedef enum SRSLTE_API { - SRSLTE_SIDELINK_PSBCH = 0, // Physical Sidelink Broadcast Channel - SRSLTE_SIDELINK_PSCCH, // Physical Sidelink Control Channel - SRSLTE_SIDELINK_PSSCH, // Physical Sidelink Shared Channel - SRSLTE_SIDELINK_PSDCH // Physical Sidelink Discovery Channel -} srslte_sl_channels_t; - -typedef struct SRSLTE_API { - srslte_sl_tm_t tm; - uint32_t N_sl_id; - uint32_t nof_prb; - srslte_cp_t cp; -} srslte_cell_sl_t; - -#define SRSLTE_SL_MAX_PERIOD_LENGTH 320 // SL-PeriodComm-r12 3GPP TS 36.331 Section 6.3.8 -// SL-CommResourcePool: 3GPP TS 36.331 version 15.6.0 Release 15 Section 6.3.8 -typedef struct SRSLTE_API { - uint32_t period_length; - - uint32_t prb_num; - uint32_t prb_start; - uint32_t prb_end; - - uint8_t pscch_sf_bitmap[SRSLTE_SL_MAX_PERIOD_LENGTH]; - uint8_t pssch_sf_bitmap[SRSLTE_SL_MAX_PERIOD_LENGTH]; - - uint32_t size_sub_channel; // sizeSubchannel-r14 - uint32_t num_sub_channel; // numSubchannel-r14 - uint32_t start_prb_sub_channel; // startRB-Subchannel-r14 offset - bool adjacency_pscch_pssch; // adjacencyPSCCH-PSSCH-r14 - - uint32_t sf_bitmap_tm34_len; - uint8_t sf_bitmap_tm34[SRSLTE_SL_MAX_PERIOD_LENGTH]; // sl_Subframe_r14: 3GPP 36.331 Section 6.3.8 -} srslte_sl_comm_resource_pool_t; - -typedef enum SRSLTE_API { - SRSLTE_SIDELINK_DATA_SYMBOL = 0, - SRSLTE_SIDELINK_SYNC_SYMBOL, - SRSLTE_SIDELINK_DMRS_SYMBOL, - SRSLTE_SIDELINK_GUARD_SYMBOL -} srslte_sl_symbol_t; - -#define SRSLTE_SL_DUPLEX_MODE_FDD (1) -#define SRSLTE_SL_DUPLEX_MODE_TDD (2) - -#define SRSLTE_SLSS_SIDE_PEAK_OFFSET (0.005f) -#define SRSLTE_SLSS_SIDE_PEAK_THRESHOLD_HIGH (0.49f) // square(0.7), max 70% of main peak -#define SRSLTE_SLSS_SIDE_PEAK_THRESHOLD_LOW (0.09f) // square(0.3), min 30% of main peak - -#define SRSLTE_PSBCH_NOF_PRB (6) -#define SRSLTE_PSCCH_TM34_NOF_PRB (2) - -#define SRSLTE_MIB_SL_LEN (40) // TM1/2: 40 bits -#define SRSLTE_MIB_SL_V2X_LEN (48) // TM3/4: 48 bits -#define SRSLTE_MIB_SL_MAX_LEN (SRSLTE_MIB_SL_V2X_LEN) - -#define SRSLTE_SL_TM12_DEFAULT_NUM_DMRS_SYMBOLS (2) -#define SRSLTE_SL_TM34_DEFAULT_NUM_DMRS_SYMBOLS (4) ///< In TM3/4, all channels have 4 DMRS by default - -#define SRSLTE_PSBCH_TM12_NUM_DATA_SYMBOLS (8) // PSBCH is in 8 OFDM symbols (but only 7 are tx'ed) -#define SRSLTE_PSBCH_TM12_NUM_DATA_SYMBOLS_EXT \ - (6) // PSBCH is in 7 OFDM symbols for extended cyclic prefix (but only 6 are tx'ed) -#define SRSLTE_PSBCH_TM12_NUM_DMRS_SYMBOLS (2) ///< PSBCH has 2 DMRS symbols -#define SRSLTE_PSBCH_TM12_NUM_SYNC_SYMBOLS (4) ///< Two symbols PSSS and two SSSS - -#define SRSLTE_PSBCH_TM34_NUM_DATA_SYMBOLS (7) ///< SL-BCH is in 7 OFDM symbols (but only 6 are tx'ed) -#define SRSLTE_PSBCH_TM34_NUM_DMRS_SYMBOLS (3) ///< PSBCH has 3 DMRS symbols in TM3 and TM4 -#define SRSLTE_PSBCH_TM34_NUM_SYNC_SYMBOLS (4) ///< Two symbols PSSS and two SSSS - -#define SRSLTE_SCI_CRC_LEN (16) -#define SRSLTE_SCI_MAX_LEN (45) -#define SRSLTE_SCI_TM34_LEN (32) - -#define SRSLTE_PSCCH_QM 2 -#define SRSLTE_PSCCH_TM12_NOF_PRB (1) -#define SRSLTE_PSCCH_TM34_NOF_PRB (2) -#define SRSLTE_PSCCH_MAX_NOF_PRB (SRSLTE_PSCCH_TM34_NOF_PRB) -#define SRSLTE_PSCCH_SCRAMBLING_SEED (510) ///< Scrambling seed for PSCCH is 510 - -#define SRSLTE_PSCCH_TM12_NUM_DATA_SYMBOLS (12) -#define SRSLTE_PSCCH_TM12_NUM_DMRS_SYMBOLS (2) -#define SRSLTE_PSCCH_TM12_NUM_DATA_SYMBOLS_EXT (10) - -#define SRSLTE_PSCCH_TM34_NUM_DATA_SYMBOLS (10) -#define SRSLTE_PSCCH_TM34_NUM_DMRS_SYMBOLS (4) - -#define SRSLTE_PSCCH_TM12_NOF_CODED_BITS \ - (SRSLTE_NRE * SRSLTE_PSCCH_TM12_NUM_DATA_SYMBOLS * SRSLTE_PSCCH_TM12_NOF_PRB * SRSLTE_PSCCH_QM) -#define SRSLTE_PSCCH_TM34_NOF_CODED_BITS \ - (SRSLTE_NRE * SRSLTE_PSCCH_TM34_NUM_DATA_SYMBOLS * SRSLTE_PSCCH_TM34_NOF_PRB * SRSLTE_PSCCH_QM) -#define SRSLTE_PSCCH_MAX_CODED_BITS SRSLTE_MAX(SRSLTE_PSCCH_TM12_NOF_CODED_BITS, SRSLTE_PSCCH_TM34_NOF_CODED_BITS) - -#define SRSLTE_PSSCH_MAX_QM 6 -#define SRSLTE_PSSCH_CRC_LEN 24 -#define SRSLTE_MAX_CODEWORD_LEN 168000 // 12 subcarriers * 100 PRB * 14 symbols * 10 bits, assuming 1024QAM -#define SRSLTE_SL_SCH_MAX_TB_LEN (48936) // 3GPP 36.306 v15.4.0 Table 4.1B-1 -#define SRSLTE_PSSCH_MAX_CODED_BITS (3 * SRSLTE_TCOD_MAX_LEN_CB + SRSLTE_TCOD_TOTALTAIL) - -#define SRSLTE_PSSCH_TM12_NUM_DATA_SYMBOLS (12) // PSSCH is in 12 OFDM symbols (but only 11 are tx'ed) -#define SRSLTE_PSSCH_TM12_NUM_DMRS_SYMBOLS (2) // PSSCH has 2 DMRS symbols in TM1 and TM2 - -#define SRSLTE_PSSCH_TM12_NUM_DATA_SYMBOLS_CP_EXT \ - (10) // PSSCH is in 10 OFDM symbols for extended cyclic prefix (but only 9 are tx'ed) -#define SRSLTE_PSSCH_TM12_NUM_DMRS_SYMBOLS_CP_EXT \ - (2) // PSSCH has 2 DMRS symbols for extended cyclic prefix in TM1 and TM2 - -#define SRSLTE_PSSCH_TM34_NUM_DATA_SYMBOLS (10) // PSSCH is in 10 OFDM symbols (but only 9 are tx'ed) -#define SRSLTE_PSSCH_TM34_NUM_DMRS_SYMBOLS (4) // PSSCH has 4 DMRS symbols in TM3 and TM4 - -SRSLTE_API int srslte_sl_group_hopping_f_gh(uint32_t f_gh[SRSLTE_NSLOTS_X_FRAME * 2], uint32_t N_x_id); -#define SRSLTE_PSCCH_MAX_NUM_DATA_SYMBOLS (SRSLTE_PSCCH_TM12_NUM_DATA_SYMBOLS) - -SRSLTE_API bool srslte_slss_side_peak_pos_is_valid(uint32_t side_peak_pos, - uint32_t main_peak_pos, - uint32_t side_peak_delta_a, - uint32_t side_peak_delta_b); -SRSLTE_API bool srslte_slss_side_peak_value_is_valid(float side_peak_value, float threshold_low, float threshold_high); - -SRSLTE_API int srslte_sl_tm_to_cell_sl_tm_t(srslte_cell_sl_t* q, uint32_t tm); - -SRSLTE_API uint32_t srslte_sl_get_num_symbols(srslte_sl_tm_t tm, srslte_cp_t cp); -SRSLTE_API bool srslte_psbch_is_symbol(srslte_sl_symbol_t type, srslte_sl_tm_t tm, uint32_t i, srslte_cp_t cp); -SRSLTE_API bool srslte_pscch_is_symbol(srslte_sl_symbol_t type, srslte_sl_tm_t tm, uint32_t i, srslte_cp_t cp); -SRSLTE_API bool srslte_pssch_is_symbol(srslte_sl_symbol_t type, srslte_sl_tm_t tm, uint32_t i, srslte_cp_t cp); - -SRSLTE_API uint32_t srslte_sci_format0_sizeof(uint32_t nof_prb); - -SRSLTE_API int srslte_sl_comm_resource_pool_get_default_config(srslte_sl_comm_resource_pool_t* q, - srslte_cell_sl_t cell); - -#endif // SRSLTE_PHY_COMMON_SL_H \ No newline at end of file diff --git a/lib/include/srslte/phy/enb/enb_dl.h b/lib/include/srslte/phy/enb/enb_dl.h deleted file mode 100644 index 5cfcaddb8..000000000 --- a/lib/include/srslte/phy/enb/enb_dl.h +++ /dev/null @@ -1,162 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2020 Software Radio Systems Limited - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the distribution. - * - */ - -/****************************************************************************** - * File: enb_dl.h - * - * Description: ENB downlink object. - * - * This module is a frontend to all the downlink data and control - * channel processing modules for the ENB transmitter side. - * - * Reference: - *****************************************************************************/ - -#ifndef SRSLTE_ENB_DL_H -#define SRSLTE_ENB_DL_H - -#include - -#include "srslte/phy/ch_estimation/refsignal_dl.h" -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/dft/ofdm.h" -#include "srslte/phy/phch/dci.h" -#include "srslte/phy/phch/pbch.h" -#include "srslte/phy/phch/pcfich.h" -#include "srslte/phy/phch/pdcch.h" -#include "srslte/phy/phch/pdsch.h" -#include "srslte/phy/phch/pdsch_cfg.h" -#include "srslte/phy/phch/phich.h" -#include "srslte/phy/phch/pmch.h" -#include "srslte/phy/phch/ra.h" -#include "srslte/phy/phch/regs.h" -#include "srslte/phy/sync/pss.h" -#include "srslte/phy/sync/sss.h" - -#include "srslte/phy/enb/enb_ul.h" -#include "srslte/phy/ue/ue_dl.h" - -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" - -#include "srslte/config.h" - -typedef struct SRSLTE_API { - srslte_cell_t cell; - - srslte_dl_sf_cfg_t dl_sf; - - cf_t* sf_symbols[SRSLTE_MAX_PORTS]; - - srslte_ofdm_t ifft[SRSLTE_MAX_PORTS]; - srslte_ofdm_t ifft_mbsfn; - - srslte_pbch_t pbch; - srslte_pcfich_t pcfich; - srslte_regs_t regs; - srslte_pdcch_t pdcch; - srslte_pdsch_t pdsch; - srslte_pmch_t pmch; - srslte_phich_t phich; - - srslte_refsignal_t csr_signal; - srslte_refsignal_t mbsfnr_signal; - - cf_t pss_signal[SRSLTE_PSS_LEN]; - float sss_signal0[SRSLTE_SSS_LEN]; - float sss_signal5[SRSLTE_SSS_LEN]; - - uint32_t nof_common_locations[3]; - srslte_dci_location_t common_locations[3][SRSLTE_MAX_CANDIDATES_COM]; - -} srslte_enb_dl_t; - -typedef struct { - uint8_t ack; - uint32_t n_prb_lowest; - uint32_t n_dmrs; -} srslte_enb_dl_phich_t; - -/* This function shall be called just after the initial synchronization */ -SRSLTE_API int srslte_enb_dl_init(srslte_enb_dl_t* q, cf_t* out_buffer[SRSLTE_MAX_PORTS], uint32_t max_prb); - -SRSLTE_API void srslte_enb_dl_free(srslte_enb_dl_t* q); - -SRSLTE_API int srslte_enb_dl_set_cell(srslte_enb_dl_t* q, srslte_cell_t cell); - -SRSLTE_API bool srslte_enb_dl_location_is_common_ncce(srslte_enb_dl_t* q, uint32_t ncce); - -SRSLTE_API void srslte_enb_dl_put_base(srslte_enb_dl_t* q, srslte_dl_sf_cfg_t* dl_sf); - -SRSLTE_API void srslte_enb_dl_put_phich(srslte_enb_dl_t* q, srslte_phich_grant_t* grant, bool ack); - -SRSLTE_API int srslte_enb_dl_put_pdcch_dl(srslte_enb_dl_t* q, srslte_dci_cfg_t* dci_cfg, srslte_dci_dl_t* dci_dl); - -SRSLTE_API int srslte_enb_dl_put_pdcch_ul(srslte_enb_dl_t* q, srslte_dci_cfg_t* dci_cfg, srslte_dci_ul_t* dci_ul); - -SRSLTE_API int -srslte_enb_dl_put_pdsch(srslte_enb_dl_t* q, srslte_pdsch_cfg_t* pdsch, uint8_t* data[SRSLTE_MAX_CODEWORDS]); - -SRSLTE_API int srslte_enb_dl_put_pmch(srslte_enb_dl_t* q, srslte_pmch_cfg_t* pmch_cfg, uint8_t* data); - -SRSLTE_API void srslte_enb_dl_gen_signal(srslte_enb_dl_t* q); - -SRSLTE_API bool srslte_enb_dl_gen_cqi_periodic(const srslte_cell_t* cell, - const srslte_dl_cfg_t* dl_cfg, - uint32_t tti, - uint32_t last_ri, - srslte_cqi_cfg_t* cqi_cfg); - -SRSLTE_API bool srslte_enb_dl_gen_cqi_aperiodic(const srslte_cell_t* cell, - const srslte_dl_cfg_t* dl_cfg, - uint32_t ri, - srslte_cqi_cfg_t* cqi_cfg); - -SRSLTE_API void srslte_enb_dl_save_signal(srslte_enb_dl_t* q); - -/** - * Generates the uplink control information configuration from the cell, subframe and HARQ ACK information. Note that - * it expects the UCI configuration shall have been configured already with scheduling request and channel quality - * information prior to this call. - * - * @param cell points to the physical layer cell parameters - * @param sf points to the subframe configuration - * @param ack_info is the HARQ-ACK information - * @param uci_cfg the UCI configuration destination - */ -SRSLTE_API void srslte_enb_dl_gen_ack(const srslte_cell_t* cell, - const srslte_dl_sf_cfg_t* sf, - const srslte_pdsch_ack_t* ack_info, - srslte_uci_cfg_t* uci_cfg); - -/** - * gets the HARQ-ACK values from the received Uplink Control Information configuration, the cell, and HARQ ACK - * info itself. Note that it expects that the HARQ-ACK info has been set prior the UCI Data decoding. - * - * @param cell points to the physical layer cell parameters - * @param uci_cfg points to the UCI configration - * @param uci_value points to the received UCI values - * @param ack_info is the HARQ-ACK information - */ -SRSLTE_API void srslte_enb_dl_get_ack(const srslte_cell_t* cell, - const srslte_uci_cfg_t* uci_cfg, - const srslte_uci_value_t* uci_value, - srslte_pdsch_ack_t* pdsch_ack); - -/** - * Gets the maximum signal power in decibels full scale. It is equivalent to the transmit power if all resource elements - * were populated. - * @return The maximum power - */ -SRSLTE_API float srslte_enb_dl_get_maximum_signal_power_dBfs(uint32_t nof_prb); - -#endif // SRSLTE_ENB_DL_H diff --git a/lib/include/srslte/phy/enb/enb_dl_nr.h b/lib/include/srslte/phy/enb/enb_dl_nr.h deleted file mode 100644 index 6cc9a5646..000000000 --- a/lib/include/srslte/phy/enb/enb_dl_nr.h +++ /dev/null @@ -1,67 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2020 Software Radio Systems Limited - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the distribution. - * - */ - -#ifndef SRSLTE_ENB_DL_NR_H -#define SRSLTE_ENB_DL_NR_H - -#include "srslte/phy/common/phy_common_nr.h" -#include "srslte/phy/dft/ofdm.h" -#include "srslte/phy/phch/pdcch_nr.h" -#include "srslte/phy/phch/pdsch_nr.h" - -typedef struct SRSLTE_API { - srslte_pdsch_nr_args_t pdsch; - srslte_pdcch_nr_args_t pdcch; - uint32_t nof_tx_antennas; - uint32_t nof_max_prb; -} srslte_enb_dl_nr_args_t; - -typedef struct SRSLTE_API { - uint32_t max_prb; - uint32_t nof_tx_antennas; - srslte_carrier_nr_t carrier; - srslte_coreset_t coreset; - - srslte_ofdm_t fft[SRSLTE_MAX_PORTS]; - - cf_t* sf_symbols[SRSLTE_MAX_PORTS]; - srslte_pdsch_nr_t pdsch; - srslte_dmrs_sch_t dmrs; - - srslte_pdcch_nr_t pdcch; -} srslte_enb_dl_nr_t; - -SRSLTE_API int -srslte_enb_dl_nr_init(srslte_enb_dl_nr_t* q, cf_t* output[SRSLTE_MAX_PORTS], const srslte_enb_dl_nr_args_t* args); - -SRSLTE_API int srslte_enb_dl_nr_set_carrier(srslte_enb_dl_nr_t* q, const srslte_carrier_nr_t* carrier); - -SRSLTE_API int srslte_enb_dl_nr_set_coreset(srslte_enb_dl_nr_t* q, const srslte_coreset_t* coreset); - -SRSLTE_API void srslte_enb_dl_nr_free(srslte_enb_dl_nr_t* q); - -SRSLTE_API int srslte_enb_dl_nr_base_zero(srslte_enb_dl_nr_t* q); - -SRSLTE_API void srslte_enb_dl_nr_gen_signal(srslte_enb_dl_nr_t* q); - -SRSLTE_API int -srslte_enb_dl_nr_pdcch_put(srslte_enb_dl_nr_t* q, const srslte_slot_cfg_t* slot_cfg, const srslte_dci_dl_nr_t* dci_dl); - -SRSLTE_API int srslte_enb_dl_nr_pdsch_put(srslte_enb_dl_nr_t* q, - const srslte_slot_cfg_t* slot, - const srslte_sch_cfg_nr_t* cfg, - uint8_t* data[SRSLTE_MAX_TB]); - -SRSLTE_API int -srslte_enb_dl_nr_pdsch_info(const srslte_enb_dl_nr_t* q, const srslte_sch_cfg_nr_t* cfg, char* str, uint32_t str_len); - -#endif // SRSLTE_ENB_DL_NR_H diff --git a/lib/include/srslte/phy/enb/enb_ul.h b/lib/include/srslte/phy/enb/enb_ul.h deleted file mode 100644 index c365c8a09..000000000 --- a/lib/include/srslte/phy/enb/enb_ul.h +++ /dev/null @@ -1,78 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2020 Software Radio Systems Limited - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the distribution. - * - */ - -/****************************************************************************** - * File: enb_ul.h - * - * Description: ENB uplink object. - * - * This module is a frontend to all the uplink data and control - * channel processing modules for the ENB receiver side. - * - * Reference: - *****************************************************************************/ - -#ifndef SRSLTE_ENB_UL_H -#define SRSLTE_ENB_UL_H - -#include - -#include "srslte/phy/ch_estimation/chest_ul.h" -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/dft/ofdm.h" -#include "srslte/phy/phch/prach.h" -#include "srslte/phy/phch/pucch.h" -#include "srslte/phy/phch/pusch.h" -#include "srslte/phy/phch/pusch_cfg.h" -#include "srslte/phy/phch/ra.h" - -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" - -#include "srslte/config.h" - -typedef struct SRSLTE_API { - srslte_cell_t cell; - - cf_t* sf_symbols; - srslte_chest_ul_res_t chest_res; - - srslte_ofdm_t fft; - srslte_chest_ul_t chest; - srslte_pusch_t pusch; - srslte_pucch_t pucch; - -} srslte_enb_ul_t; - -/* This function shall be called just after the initial synchronization */ -SRSLTE_API int srslte_enb_ul_init(srslte_enb_ul_t* q, cf_t* in_buffer, uint32_t max_prb); - -SRSLTE_API void srslte_enb_ul_free(srslte_enb_ul_t* q); - -SRSLTE_API int srslte_enb_ul_set_cell(srslte_enb_ul_t* q, - srslte_cell_t cell, - srslte_refsignal_dmrs_pusch_cfg_t* pusch_cfg, - srslte_refsignal_srs_cfg_t* srs_cfg); - -SRSLTE_API void srslte_enb_ul_fft(srslte_enb_ul_t* q); - -SRSLTE_API int srslte_enb_ul_get_pucch(srslte_enb_ul_t* q, - srslte_ul_sf_cfg_t* ul_sf, - srslte_pucch_cfg_t* cfg, - srslte_pucch_res_t* res); - -SRSLTE_API int srslte_enb_ul_get_pusch(srslte_enb_ul_t* q, - srslte_ul_sf_cfg_t* ul_sf, - srslte_pusch_cfg_t* cfg, - srslte_pusch_res_t* res); - -#endif // SRSLTE_ENB_UL_H diff --git a/lib/include/srslte/phy/fec/turbo/turbodecoder.h b/lib/include/srslte/phy/fec/turbo/turbodecoder.h deleted file mode 100644 index ca7eb1b9c..000000000 --- a/lib/include/srslte/phy/fec/turbo/turbodecoder.h +++ /dev/null @@ -1,114 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2020 Software Radio Systems Limited - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the distribution. - * - */ - -/********************************************************************************************** - * File: turbodecoder.h - * - * Description: Turbo Decoder. - * Parallel Concatenated Convolutional Code (PCCC) with two 8-state constituent - * encoders and one turbo code internal interleaver. The coding rate of turbo - * encoder is 1/3. - * MAP_GEN is the MAX-LOG-MAP generic implementation of the decoder. - * - * Reference: 3GPP TS 36.212 version 10.0.0 Release 10 Sec. 5.1.3.2 - *********************************************************************************************/ - -#ifndef SRSLTE_TURBODECODER_H -#define SRSLTE_TURBODECODER_H - -#include "srslte/config.h" -#include "srslte/phy/fec/cbsegm.h" -#include "srslte/phy/fec/turbo/tc_interl.h" - -#define SRSLTE_TCOD_RATE 3 -#define SRSLTE_TCOD_TOTALTAIL 12 - -#define SRSLTE_TCOD_MAX_LEN_CB 6144 - -// Expect the input to be aligned for sub-block window processing. -#define SRSLTE_TDEC_EXPECT_INPUT_SB 1 - -// Include interfaces for 8 and 16 bit decoder implementations -#define LLR_IS_8BIT -#include "srslte/phy/fec/turbo/turbodecoder_impl.h" -#undef LLR_IS_8BIT - -#define LLR_IS_16BIT -#include "srslte/phy/fec/turbo/turbodecoder_impl.h" -#undef LLR_IS_16BIT - -#define SRSLTE_TDEC_NOF_AUTO_MODES_8 2 -#define SRSLTE_TDEC_NOF_AUTO_MODES_16 3 - -typedef enum { SRSLTE_TDEC_8, SRSLTE_TDEC_16 } srslte_tdec_llr_type_t; - -typedef struct SRSLTE_API { - uint32_t max_long_cb; - - void* dec8_hdlr[SRSLTE_TDEC_NOF_AUTO_MODES_8]; - void* dec16_hdlr[SRSLTE_TDEC_NOF_AUTO_MODES_16]; - srslte_tdec_8bit_impl_t* dec8[SRSLTE_TDEC_NOF_AUTO_MODES_8]; - srslte_tdec_16bit_impl_t* dec16[SRSLTE_TDEC_NOF_AUTO_MODES_16]; - int nof_blocks8[SRSLTE_TDEC_NOF_AUTO_MODES_8]; - int nof_blocks16[SRSLTE_TDEC_NOF_AUTO_MODES_16]; - - // Declare as void types as can be int8 or int16 - void* app1; - void* app2; - void* ext1; - void* ext2; - void* syst0; - void* parity0; - void* parity1; - - void* input_conv; - - bool force_not_sb; - - srslte_tdec_impl_type_t dec_type; - - srslte_tdec_llr_type_t current_llr_type; - uint32_t current_dec; - uint32_t current_long_cb; - uint32_t current_inter_idx; - int current_cbidx; - srslte_tc_interl_t interleaver[4][SRSLTE_NOF_TC_CB_SIZES]; - int n_iter; -} srslte_tdec_t; - -SRSLTE_API int srslte_tdec_init(srslte_tdec_t* h, uint32_t max_long_cb); - -SRSLTE_API int srslte_tdec_init_manual(srslte_tdec_t* h, uint32_t max_long_cb, srslte_tdec_impl_type_t dec_type); - -SRSLTE_API void srslte_tdec_free(srslte_tdec_t* h); - -SRSLTE_API void srslte_tdec_force_not_sb(srslte_tdec_t* h); - -SRSLTE_API int srslte_tdec_new_cb(srslte_tdec_t* h, uint32_t long_cb); - -SRSLTE_API int srslte_tdec_get_nof_iterations(srslte_tdec_t* h); - -SRSLTE_API uint32_t srslte_tdec_autoimp_get_subblocks(uint32_t long_cb); - -SRSLTE_API uint32_t srslte_tdec_autoimp_get_subblocks_8bit(uint32_t long_cb); - -SRSLTE_API void srslte_tdec_iteration(srslte_tdec_t* h, int16_t* input, uint8_t* output); - -SRSLTE_API int -srslte_tdec_run_all(srslte_tdec_t* h, int16_t* input, uint8_t* output, uint32_t nof_iterations, uint32_t long_cb); - -SRSLTE_API void srslte_tdec_iteration_8bit(srslte_tdec_t* h, int8_t* input, uint8_t* output); - -SRSLTE_API int -srslte_tdec_run_all_8bit(srslte_tdec_t* h, int8_t* input, uint8_t* output, uint32_t nof_iterations, uint32_t long_cb); - -#endif // SRSLTE_TURBODECODER_H diff --git a/lib/include/srslte/phy/io/format.h b/lib/include/srslte/phy/io/format.h deleted file mode 100644 index 290220b03..000000000 --- a/lib/include/srslte/phy/io/format.h +++ /dev/null @@ -1,26 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2020 Software Radio Systems Limited - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the distribution. - * - */ - -#ifndef SRSLTE_FORMAT_H -#define SRSLTE_FORMAT_H - -typedef enum { - SRSLTE_TEXT, - SRSLTE_FLOAT, - SRSLTE_COMPLEX_FLOAT, - SRSLTE_COMPLEX_SHORT, - SRSLTE_FLOAT_BIN, - SRSLTE_COMPLEX_FLOAT_BIN, - SRSLTE_COMPLEX_SHORT_BIN -} srslte_datatype_t; - -#endif // SRSLTE_FORMAT_H diff --git a/lib/include/srslte/phy/phch/dci.h b/lib/include/srslte/phy/phch/dci.h deleted file mode 100644 index a72ec6bb4..000000000 --- a/lib/include/srslte/phy/phch/dci.h +++ /dev/null @@ -1,243 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2020 Software Radio Systems Limited - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the distribution. - * - */ - -/****************************************************************************** - * File: dci.h - * - * Description: Downlink control information (DCI). - * Packing/Unpacking functions to convert between bit streams - * and packed DCI UL/DL grants defined in ra.h - * - * Reference: 3GPP TS 36.212 version 10.0.0 Release 10 Sec. 5.3.3 - *****************************************************************************/ - -#ifndef SRSLTE_DCI_H -#define SRSLTE_DCI_H - -#include - -#include "srslte/config.h" -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/phch/ra.h" - -#define SRSLTE_DCI_MAX_BITS 128 -#define SRSLTE_RAR_GRANT_LEN 20 - -#define SRSLTE_DCI_IS_TB_EN(tb) (!(tb.mcs_idx == 0 && tb.rv == 1)) -#define SRSLTE_DCI_TB_DISABLE(tb) \ - do { \ - tb.mcs_idx = 0; \ - tb.rv = 1; \ - } while (0) -#define SRSLTE_DCI_HEXDEBUG 0 - -typedef struct { - bool multiple_csi_request_enabled; - bool cif_enabled; - bool cif_present; - bool srs_request_enabled; - bool ra_format_enabled; - bool is_not_ue_ss; -} srslte_dci_cfg_t; - -typedef struct SRSLTE_API { - uint32_t L; // Aggregation level (logarithmic) - uint32_t ncce; // Position of first CCE of the dci -} srslte_dci_location_t; - -typedef struct SRSLTE_API { - uint8_t payload[SRSLTE_DCI_MAX_BITS]; - uint32_t nof_bits; - srslte_dci_location_t location; - srslte_dci_format_t format; - uint16_t rnti; -} srslte_dci_msg_t; - -typedef struct SRSLTE_API { - uint32_t mcs_idx; - int rv; - bool ndi; - uint32_t cw_idx; -} srslte_dci_tb_t; - -typedef struct SRSLTE_API { - - uint16_t rnti; - srslte_dci_format_t format; - srslte_dci_location_t location; - uint32_t ue_cc_idx; - - // Resource Allocation - srslte_ra_type_t alloc_type; - union { - srslte_ra_type0_t type0_alloc; - srslte_ra_type1_t type1_alloc; - srslte_ra_type2_t type2_alloc; - }; - - // Codeword information - srslte_dci_tb_t tb[SRSLTE_MAX_CODEWORDS]; - bool tb_cw_swap; - uint32_t pinfo; - - // Power control - bool pconf; - bool power_offset; - uint8_t tpc_pucch; - - // RA order - bool is_ra_order; - uint32_t ra_preamble; - uint32_t ra_mask_idx; - - // Release 10 - uint32_t cif; - bool cif_present; - bool srs_request; - bool srs_request_present; - - // Other parameters - uint32_t pid; - uint32_t dai; - bool is_tdd; - bool is_dwpts; - bool sram_id; - - // For debugging purposes -#if SRSLTE_DCI_HEXDEBUG - uint32_t nof_bits; - char hex_str[SRSLTE_DCI_MAX_BITS]; -#endif -} srslte_dci_dl_t; - -/** Unpacked DCI Format0 message */ -typedef struct SRSLTE_API { - - uint16_t rnti; - srslte_dci_format_t format; - srslte_dci_location_t location; - uint32_t ue_cc_idx; - - srslte_ra_type2_t type2_alloc; - /* 36.213 Table 8.4-2: SRSLTE_RA_PUSCH_HOP_HALF is 0 for < 10 Mhz and 10 for > 10 Mhz. - * SRSLTE_RA_PUSCH_HOP_QUART is 00 for > 10 Mhz and SRSLTE_RA_PUSCH_HOP_QUART_NEG is 01 for > 10 Mhz. - */ - enum { - SRSLTE_RA_PUSCH_HOP_DISABLED = -1, - SRSLTE_RA_PUSCH_HOP_QUART = 0, - SRSLTE_RA_PUSCH_HOP_QUART_NEG = 1, - SRSLTE_RA_PUSCH_HOP_HALF = 2, - SRSLTE_RA_PUSCH_HOP_TYPE2 = 3 - } freq_hop_fl; - - // Codeword information - srslte_dci_tb_t tb; - uint32_t n_dmrs; - bool cqi_request; - - // TDD parametres - uint32_t dai; - uint32_t ul_idx; - bool is_tdd; - - // Power control - uint8_t tpc_pusch; - - // Release 10 - uint32_t cif; - bool cif_present; - uint8_t multiple_csi_request; - bool multiple_csi_request_present; - bool srs_request; - bool srs_request_present; - srslte_ra_type_t ra_type; - bool ra_type_present; - - // For debugging purposes -#if SRSLTE_DCI_HEXDEBUG - uint32_t nof_bits; - char hex_str[SRSLTE_DCI_MAX_BITS]; -#endif /* SRSLTE_DCI_HEXDEBUG */ - -} srslte_dci_ul_t; - -typedef struct SRSLTE_API { - uint32_t rba; - uint32_t trunc_mcs; - uint32_t tpc_pusch; - bool ul_delay; - bool cqi_request; - bool hopping_flag; -} srslte_dci_rar_grant_t; - -SRSLTE_API void srslte_dci_rar_unpack(uint8_t payload[SRSLTE_RAR_GRANT_LEN], srslte_dci_rar_grant_t* rar); - -SRSLTE_API void srslte_dci_rar_pack(srslte_dci_rar_grant_t* rar, uint8_t payload[SRSLTE_RAR_GRANT_LEN]); - -SRSLTE_API int srslte_dci_rar_to_ul_dci(srslte_cell_t* cell, srslte_dci_rar_grant_t* rar, srslte_dci_ul_t* dci_ul); - -SRSLTE_API int srslte_dci_msg_pack_pusch(srslte_cell_t* cell, - srslte_dl_sf_cfg_t* sf, - srslte_dci_cfg_t* cfg, - srslte_dci_ul_t* dci, - srslte_dci_msg_t* msg); - -SRSLTE_API int srslte_dci_msg_unpack_pusch(srslte_cell_t* cell, - srslte_dl_sf_cfg_t* sf, - srslte_dci_cfg_t* cfg, - srslte_dci_msg_t* msg, - srslte_dci_ul_t* dci); - -SRSLTE_API int srslte_dci_msg_pack_pdsch(srslte_cell_t* cell, - srslte_dl_sf_cfg_t* sf, - srslte_dci_cfg_t* cfg, - srslte_dci_dl_t* dci, - srslte_dci_msg_t* msg); - -SRSLTE_API int srslte_dci_msg_unpack_pdsch(srslte_cell_t* cell, - srslte_dl_sf_cfg_t* sf, - srslte_dci_cfg_t* cfg, - srslte_dci_msg_t* msg, - srslte_dci_dl_t* dci); - -SRSLTE_API uint32_t srslte_dci_format_sizeof(const srslte_cell_t* cell, - srslte_dl_sf_cfg_t* sf, - srslte_dci_cfg_t* cfg, - srslte_dci_format_t format); - -SRSLTE_API void srslte_dci_dl_fprint(FILE* f, srslte_dci_dl_t* dci, uint32_t nof_prb); - -SRSLTE_API uint32_t srslte_dci_dl_info(const srslte_dci_dl_t* dci_dl, char* str, uint32_t str_len); - -SRSLTE_API uint32_t srslte_dci_ul_info(srslte_dci_ul_t* dci_ul, char* info_str, uint32_t len); - -SRSLTE_API srslte_dci_format_t srslte_dci_format_from_string(char* str); - -SRSLTE_API char* srslte_dci_format_string(srslte_dci_format_t format); - -SRSLTE_API char* srslte_dci_format_string_short(srslte_dci_format_t format); - -SRSLTE_API bool -srslte_location_find(const srslte_dci_location_t* locations, uint32_t nof_locations, srslte_dci_location_t x); - -SRSLTE_API bool -srslte_location_find_ncce(const srslte_dci_location_t* locations, uint32_t nof_locations, uint32_t ncce); - -SRSLTE_API int srslte_dci_location_set(srslte_dci_location_t* c, uint32_t L, uint32_t nCCE); - -SRSLTE_API bool srslte_dci_location_isvalid(srslte_dci_location_t* c); - -SRSLTE_API void srslte_dci_cfg_set_common_ss(srslte_dci_cfg_t* cfg); - -SRSLTE_API uint32_t srslte_dci_format_max_tb(srslte_dci_format_t format); - -#endif // DCI_ diff --git a/lib/include/srslte/phy/phch/dci_nbiot.h b/lib/include/srslte/phy/phch/dci_nbiot.h deleted file mode 100644 index 7094c8aa4..000000000 --- a/lib/include/srslte/phy/phch/dci_nbiot.h +++ /dev/null @@ -1,74 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2020 Software Radio Systems Limited - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the distribution. - * - */ - -/** - * - * @file dci_nbiot.h - * - * @brief Downlink control information (DCI) for NB-IoT. - * - * Packing/Unpacking functions to convert between bit streams - * and packed DCI UL/DL grants defined in ra_nbiot.h - * - * Reference: 3GPP TS 36.212 version 13.2.0 Release 13 Sec. 6.4.3 - * - */ - -#ifndef SRSLTE_DCI_NBIOT_H -#define SRSLTE_DCI_NBIOT_H - -#include - -#include "srslte/config.h" -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/phch/dci.h" -#include "srslte/phy/phch/ra_nbiot.h" - -#define SRSLTE_DCI_MAX_BITS 128 -#define SRSLTE_NBIOT_RAR_GRANT_LEN 15 - -SRSLTE_API void srslte_nbiot_dci_rar_grant_unpack(srslte_nbiot_dci_rar_grant_t* rar, - const uint8_t grant[SRSLTE_NBIOT_RAR_GRANT_LEN]); - -SRSLTE_API int srslte_nbiot_dci_msg_to_dl_grant(const srslte_dci_msg_t* msg, - const uint16_t msg_rnti, - srslte_ra_nbiot_dl_dci_t* dl_dci, - srslte_ra_nbiot_dl_grant_t* grant, - const uint32_t sfn, - const uint32_t sf_idx, - const uint32_t r_max, - const srslte_nbiot_mode_t mode); - -SRSLTE_API int srslte_nbiot_dci_msg_to_ul_grant(const srslte_dci_msg_t* msg, - srslte_ra_nbiot_ul_dci_t* ul_dci, - srslte_ra_nbiot_ul_grant_t* grant, - const uint32_t rx_tti, - const srslte_npusch_sc_spacing_t spacing); - -SRSLTE_API int -srslte_nbiot_dci_rar_to_ul_grant(srslte_nbiot_dci_rar_grant_t* rar, srslte_ra_nbiot_ul_grant_t* grant, uint32_t rx_tti); - -SRSLTE_API bool srslte_nbiot_dci_location_isvalid(const srslte_dci_location_t* c); - -SRSLTE_API int srslte_dci_msg_pack_npdsch(const srslte_ra_nbiot_dl_dci_t* data, - const srslte_dci_format_t format, - srslte_dci_msg_t* msg, - const bool crc_is_crnti); - -SRSLTE_API int -srslte_dci_msg_unpack_npdsch(const srslte_dci_msg_t* msg, srslte_ra_nbiot_dl_dci_t* data, const bool crc_is_crnti); - -SRSLTE_API int srslte_dci_msg_unpack_npusch(const srslte_dci_msg_t* msg, srslte_ra_nbiot_ul_dci_t* data); - -SRSLTE_API uint32_t srslte_dci_nbiot_format_sizeof(srslte_dci_format_t format); - -#endif // SRSLTE_DCI_NBIOT_H diff --git a/lib/include/srslte/phy/phch/npbch.h b/lib/include/srslte/phy/phch/npbch.h deleted file mode 100644 index e6e220fac..000000000 --- a/lib/include/srslte/phy/phch/npbch.h +++ /dev/null @@ -1,143 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2020 Software Radio Systems Limited - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the distribution. - * - */ - -#ifndef SRSLTE_NPBCH_H -#define SRSLTE_NPBCH_H - -#include "srslte/config.h" -#include "srslte/phy/common/phy_common.h" - -#include "srslte/phy/fec/convolutional/convcoder.h" -#include "srslte/phy/fec/convolutional/rm_conv.h" -#include "srslte/phy/fec/convolutional/viterbi.h" -#include "srslte/phy/fec/crc.h" -#include "srslte/phy/mimo/layermap.h" -#include "srslte/phy/mimo/precoding.h" -#include "srslte/phy/modem/demod_soft.h" -#include "srslte/phy/modem/mod.h" -#include "srslte/phy/scrambling/scrambling.h" - -#define SRSLTE_MIB_NB_LEN 34 -#define SRSLTE_MIB_NB_CRC_LEN (SRSLTE_MIB_NB_LEN + 16) -#define SRSLTE_MIB_NB_ENC_LEN (3 * SRSLTE_MIB_NB_CRC_LEN) - -#define SRSLTE_NPBCH_NUM_RE (12 * 11 - 4 * 8) // 100 RE, entire PRB minus 3 symbols minus 4 times NRS=CRS REs -#define SRSLTE_NPBCH_NUM_BLOCKS 8 // MIB-NB is split across 8 blocks -#define SRSLTE_NPBCH_NUM_REP 8 // number of repetitions per block -#define SRSLTE_NPBCH_NUM_FRAMES (SRSLTE_NPBCH_NUM_BLOCKS * SRSLTE_NPBCH_NUM_REP) - -typedef struct { - uint16_t sfn; - uint16_t hfn; - uint8_t sched_info_sib1; - uint8_t sys_info_tag; - bool ac_barring; - srslte_nbiot_mode_t mode; -} srslte_mib_nb_t; - -/** - * \brief Narrowband Physical broadcast channel (NPBCH) - * - * Reference: 3GPP TS 36.211 version 13.2.0 Release 13 Sec. 10.2.4 - */ -typedef struct SRS_API { - srslte_nbiot_cell_t cell; - - uint32_t frame_idx; - uint32_t nof_symbols; - - // buffers - cf_t* ce[SRSLTE_MAX_PORTS]; - cf_t* symbols[SRSLTE_MAX_PORTS]; - cf_t* x[SRSLTE_MAX_PORTS]; - cf_t* d; - float* llr; - float* temp; - float rm_f[SRSLTE_MIB_NB_ENC_LEN]; - uint8_t* rm_b; - uint8_t data[SRSLTE_MIB_NB_CRC_LEN]; - uint8_t data_enc[SRSLTE_MIB_NB_ENC_LEN]; - - srslte_nbiot_mode_t op_mode; - - // tx & rx objects - srslte_modem_table_t mod; - srslte_sequence_t seq; - srslte_sequence_t seq_r14[SRSLTE_NPBCH_NUM_BLOCKS]; - srslte_viterbi_t decoder; - srslte_crc_t crc; - srslte_convcoder_t encoder; - bool search_all_ports; -} srslte_npbch_t; - -SRSLTE_API int srslte_npbch_init(srslte_npbch_t* q); - -SRSLTE_API void srslte_npbch_free(srslte_npbch_t* q); - -SRSLTE_API int srslte_npbch_set_cell(srslte_npbch_t* q, srslte_nbiot_cell_t cell); - -SRSLTE_API void srslte_npbch_mib_pack(uint32_t sfn, uint32_t hfn, srslte_mib_nb_t mib, uint8_t* msg); - -SRSLTE_API void srslte_npbch_mib_unpack(uint8_t* msg, srslte_mib_nb_t* mib); - -SRSLTE_API void srslte_mib_nb_printf(FILE* stream, srslte_nbiot_cell_t cell, srslte_mib_nb_t* mib); - -SRSLTE_API int srslte_npbch_put_subframe(srslte_npbch_t* q, - uint8_t bch_payload[SRSLTE_MIB_NB_LEN], - cf_t* sf[SRSLTE_MAX_PORTS], - uint32_t frame_idx); - -SRSLTE_API int srslte_npbch_encode(srslte_npbch_t* q, - uint8_t bch_payload[SRSLTE_MIB_NB_LEN], - cf_t* sf[SRSLTE_MAX_PORTS], - uint32_t frame_idx); - -int srslte_npbch_rotate(srslte_npbch_t* q, - uint32_t nf, - cf_t* input_signal, - cf_t* output_signal, - int num_samples, - bool back); - -SRSLTE_API int srslte_npbch_decode(srslte_npbch_t* q, - cf_t* slot1_symbols, - cf_t* ce[SRSLTE_MAX_PORTS], - float noise_estimate, - uint8_t bch_payload[SRSLTE_MIB_NB_LEN], - uint32_t* nof_tx_ports, - int* sfn_offset); - -SRSLTE_API int srslte_npbch_decode_nf(srslte_npbch_t* q, - cf_t* slot1_symbols, - cf_t* ce[SRSLTE_MAX_PORTS], - float noise_estimate, - uint8_t bch_payload[SRSLTE_MIB_NB_LEN], - uint32_t* nof_tx_ports, - int* sfn_offset, - int nf); - -SRSLTE_API void srslte_npbch_decode_reset(srslte_npbch_t* q); - -SRSLTE_API int srslte_npbch_decode_frame(srslte_npbch_t* q, - uint32_t src, - uint32_t dst, - uint32_t n, - uint32_t nof_bits, - uint32_t nof_ports); - -SRSLTE_API uint32_t srslte_npbch_crc_check(srslte_npbch_t* q, uint8_t* bits, uint32_t nof_ports); - -SRSLTE_API void srslte_npbch_crc_set_mask(uint8_t* data, int nof_ports); - -SRSLTE_API int srslte_npbch_cp(cf_t* input, cf_t* output, srslte_nbiot_cell_t cell, bool put); - -#endif // SRSLTE_NPBCH_H diff --git a/lib/include/srslte/phy/phch/npdcch.h b/lib/include/srslte/phy/phch/npdcch.h deleted file mode 100644 index 81e905c0a..000000000 --- a/lib/include/srslte/phy/phch/npdcch.h +++ /dev/null @@ -1,124 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2020 Software Radio Systems Limited - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the distribution. - * - */ - -#ifndef SRSLTE_NPDCCH_H -#define SRSLTE_NPDCCH_H - -#include "srslte/config.h" -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/fec/convolutional/convcoder.h" -#include "srslte/phy/fec/convolutional/rm_conv.h" -#include "srslte/phy/fec/convolutional/viterbi.h" -#include "srslte/phy/fec/crc.h" -#include "srslte/phy/mimo/layermap.h" -#include "srslte/phy/mimo/precoding.h" -#include "srslte/phy/modem/demod_soft.h" -#include "srslte/phy/modem/mod.h" -#include "srslte/phy/phch/dci.h" -#include "srslte/phy/phch/regs.h" -#include "srslte/phy/scrambling/scrambling.h" - -#define SRSLTE_RARNTI_END_NBIOT 0x0100 -#define SRSLTE_NBIOT_NUM_NRS_SYMS 8 -#define SRSLTE_NPDCCH_MAX_RE (SRSLTE_NRE * SRSLTE_CP_NORM_SF_NSYMB - SRSLTE_NBIOT_NUM_NRS_SYMS) - -#define SRSLTE_NBIOT_DCI_MAX_SIZE 23 -#define SRSLTE_AL_REPETITION_USS 64 // Higher layer configured parameter al-Repetition-USS - -typedef enum SRSLTE_API { - SRSLTE_NPDCCH_FORMAT1 = 0, - SRSLTE_NPDCCH_FORMAT0_LOWER_HALF, - SRSLTE_NPDCCH_FORMAT0_UPPER_HALF, - SRSLTE_NPDCCH_FORMAT_NITEMS -} srslte_npdcch_format_t; -static const char srslte_npdcch_format_text[SRSLTE_NPDCCH_FORMAT_NITEMS][30] = {"Format 1", - "Format 0 (Lower Half)", - "Format 0 (Upper Half)"}; - -/** - * @brief Narrowband Physical downlink control channel (NPDCCH) - * - * Reference: 3GPP TS 36.211 version 13.2.0 Release 11 Sec. 6.8 and 10.2.5 - */ -typedef struct SRSLTE_API { - srslte_nbiot_cell_t cell; - uint32_t nof_cce; - uint32_t ncce_bits; - uint32_t max_bits; - uint32_t i_n_start; /// start of the first OFDM symbol (signalled through NB-SIB1) - uint32_t nof_nbiot_refs; /// number of NRS symbols per OFDM symbol - uint32_t nof_lte_refs; /// number of CRS symbols per OFDM symbol - uint32_t num_decoded_symbols; - - /* buffers */ - cf_t* ce[SRSLTE_MAX_PORTS]; - cf_t* symbols[SRSLTE_MAX_PORTS]; - cf_t* x[SRSLTE_MAX_PORTS]; - cf_t* d; - uint8_t* e; - float rm_f[3 * (SRSLTE_DCI_MAX_BITS + 16)]; - float* llr[2]; // Two layers of LLRs for Format0 and Format1 NPDCCH - - /* tx & rx objects */ - srslte_modem_table_t mod; - srslte_sequence_t seq[SRSLTE_NOF_SF_X_FRAME]; - srslte_viterbi_t decoder; - srslte_crc_t crc; - -} srslte_npdcch_t; - -SRSLTE_API int srslte_npdcch_init(srslte_npdcch_t* q); - -SRSLTE_API void srslte_npdcch_free(srslte_npdcch_t* q); - -SRSLTE_API int srslte_npdcch_set_cell(srslte_npdcch_t* q, srslte_nbiot_cell_t cell); - -/// Encoding function -SRSLTE_API int srslte_npdcch_encode(srslte_npdcch_t* q, - srslte_dci_msg_t* msg, - srslte_dci_location_t location, - uint16_t rnti, - cf_t* sf_symbols[SRSLTE_MAX_PORTS], - uint32_t nsubframe); - -/// Decoding functions: Extract the LLRs and save them in the srslte_npdcch_t object -SRSLTE_API int srslte_npdcch_extract_llr(srslte_npdcch_t* q, - cf_t* sf_symbols, - cf_t* ce[SRSLTE_MAX_PORTS], - float noise_estimate, - uint32_t sf_idx); - -/// Decoding functions: Try to decode a DCI message after calling srslte_npdcch_extract_llr -SRSLTE_API int srslte_npdcch_decode_msg(srslte_npdcch_t* q, - srslte_dci_msg_t* msg, - srslte_dci_location_t* location, - srslte_dci_format_t format, - uint16_t* crc_rem); - -SRSLTE_API int -srslte_npdcch_dci_decode(srslte_npdcch_t* q, float* e, uint8_t* data, uint32_t E, uint32_t nof_bits, uint16_t* crc); - -SRSLTE_API int -srslte_npdcch_dci_encode(srslte_npdcch_t* q, uint8_t* data, uint8_t* e, uint32_t nof_bits, uint32_t E, uint16_t rnti); - -SRSLTE_API void -srslte_npdcch_dci_encode_conv(srslte_npdcch_t* q, uint8_t* data, uint32_t nof_bits, uint8_t* coded_data, uint16_t rnti); - -SRSLTE_API uint32_t srslte_npdcch_ue_locations(srslte_dci_location_t* c, uint32_t max_candidates); - -SRSLTE_API uint32_t srslte_npdcch_common_locations(srslte_dci_location_t* c, uint32_t max_candidates); - -int srslte_npdcch_cp(srslte_npdcch_t* q, cf_t* input, cf_t* output, bool put, srslte_npdcch_format_t format); -int srslte_npdcch_put(srslte_npdcch_t* q, cf_t* symbols, cf_t* sf_symbols, srslte_npdcch_format_t format); -int srslte_npdcch_get(srslte_npdcch_t* q, cf_t* symbols, cf_t* sf_symbols, srslte_npdcch_format_t format); - -#endif // SRSLTE_NPDCCH_H diff --git a/lib/include/srslte/phy/phch/npdsch.h b/lib/include/srslte/phy/phch/npdsch.h deleted file mode 100644 index de083d3ed..000000000 --- a/lib/include/srslte/phy/phch/npdsch.h +++ /dev/null @@ -1,151 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2020 Software Radio Systems Limited - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the distribution. - * - */ - -#ifndef SRSLTE_NPDSCH_H -#define SRSLTE_NPDSCH_H - -#include "srslte/config.h" -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/fec/convolutional/convcoder.h" -#include "srslte/phy/fec/crc.h" -#include "srslte/phy/mimo/layermap.h" -#include "srslte/phy/mimo/precoding.h" -#include "srslte/phy/modem/demod_soft.h" -#include "srslte/phy/modem/mod.h" -#include "srslte/phy/phch/dci.h" -#include "srslte/phy/phch/npdsch_cfg.h" -#include "srslte/phy/phch/regs.h" -#include "srslte/phy/phch/sch.h" -#include "srslte/phy/scrambling/scrambling.h" - -#define SRSLTE_NPDSCH_MAX_RE \ - (SRSLTE_CP_NORM_SF_NSYMB * SRSLTE_NRE - 8) ///< Full PRB minus 8 RE for NRS (one antenna port) -#define SRSLTE_NPDSCH_MAX_TBS 680 ///< Max TBS in Rel13 NB-IoT -#define SRSLTE_NPDSCH_CRC_LEN (24) -#define SRSLTE_NPDSCH_MAX_TBS_CRC (SRSLTE_NPDSCH_MAX_TBS + SRSLTE_NPDSCH_CRC_LEN) -#define SRSLTE_NPDSCH_MAX_TBS_ENC (3 * SRSLTE_NPDSCH_MAX_TBS_CRC) -#define SRSLTE_NPDSCH_MAX_NOF_SF 10 -#define SRSLTE_NPDSCH_NUM_SEQ (2 * SRSLTE_NOF_SF_X_FRAME) ///< for even and odd numbered SFNs - -/* @brief Narrowband Physical Downlink shared channel (NPDSCH) - * - * Reference: 3GPP TS 36.211 version 13.2.0 Release 13 Sec. 10.2.3 - */ -typedef struct SRSLTE_API { - srslte_nbiot_cell_t cell; - uint32_t max_re; - bool rnti_is_set; - uint16_t rnti; - - // buffers - uint8_t data[SRSLTE_NPDSCH_MAX_TBS_CRC]; - uint8_t data_enc[SRSLTE_NPDSCH_MAX_TBS_ENC]; - float rm_f[SRSLTE_NPDSCH_MAX_TBS_ENC]; - cf_t* ce[SRSLTE_MAX_PORTS]; - cf_t* symbols[SRSLTE_MAX_PORTS]; - cf_t* sib_symbols[SRSLTE_MAX_PORTS]; // extra buffer for SIB1 symbols as they may be interleaved with other NPDSCH - cf_t* tx_syms[SRSLTE_MAX_PORTS]; // pointer to either symbols or sib1_symbols - cf_t* x[SRSLTE_MAX_PORTS]; - cf_t* d; - - float* llr; - uint8_t* temp; - uint8_t* rm_b; - - // tx & rx objects - srslte_modem_table_t mod; - srslte_viterbi_t decoder; - srslte_sequence_t seq[SRSLTE_NPDSCH_NUM_SEQ]; - srslte_crc_t crc; - srslte_convcoder_t encoder; -} srslte_npdsch_t; - -typedef struct { - uint16_t hyper_sfn; - // TODO: add all other fields -} srslte_sys_info_block_type_1_nb_t; - -SRSLTE_API int srslte_npdsch_init(srslte_npdsch_t* q); - -SRSLTE_API void srslte_npdsch_free(srslte_npdsch_t* q); - -SRSLTE_API int srslte_npdsch_set_cell(srslte_npdsch_t* q, srslte_nbiot_cell_t cell); - -SRSLTE_API int srslte_npdsch_set_rnti(srslte_npdsch_t* q, uint16_t rnti); - -SRSLTE_API int srslte_npdsch_cfg(srslte_npdsch_cfg_t* cfg, - srslte_nbiot_cell_t cell, - srslte_ra_nbiot_dl_grant_t* grant, - uint32_t sf_idx); - -SRSLTE_API int srslte_npdsch_encode(srslte_npdsch_t* q, - srslte_npdsch_cfg_t* cfg, - srslte_softbuffer_tx_t* softbuffer, - uint8_t* data, - cf_t* sf_symbols[SRSLTE_MAX_PORTS]); - -SRSLTE_API int srslte_npdsch_encode_rnti_idx(srslte_npdsch_t* q, - srslte_npdsch_cfg_t* cfg, - srslte_softbuffer_tx_t* softbuffer, - uint8_t* data, - uint32_t rnti_idx, - cf_t* sf_symbols[SRSLTE_MAX_PORTS]); - -SRSLTE_API int srslte_npdsch_encode_rnti(srslte_npdsch_t* q, - srslte_npdsch_cfg_t* cfg, - srslte_softbuffer_tx_t* softbuffer, - uint8_t* data, - uint16_t rnti, - cf_t* sf_symbols[SRSLTE_MAX_PORTS]); - -SRSLTE_API int srslte_npdsch_encode_seq(srslte_npdsch_t* q, - srslte_npdsch_cfg_t* cfg, - srslte_softbuffer_tx_t* softbuffer, - uint8_t* data, - srslte_sequence_t* seq, - cf_t* sf_symbols[SRSLTE_MAX_PORTS]); - -SRSLTE_API int srslte_npdsch_decode(srslte_npdsch_t* q, - srslte_npdsch_cfg_t* cfg, - srslte_softbuffer_rx_t* softbuffer, - cf_t* sf_symbols, - cf_t* ce[SRSLTE_MAX_PORTS], - float noise_estimate, - uint32_t sfn, - uint8_t* data); - -SRSLTE_API int srslte_npdsch_decode_rnti(srslte_npdsch_t* q, - srslte_npdsch_cfg_t* cfg, - srslte_softbuffer_rx_t* softbuffer, - cf_t* sf_symbols, - cf_t* ce[SRSLTE_MAX_PORTS], - float noise_estimate, - uint16_t rnti, - uint32_t sfn, - uint8_t* data, - uint32_t rep_counter); - -SRSLTE_API int -srslte_npdsch_rm_and_decode(srslte_npdsch_t* q, srslte_npdsch_cfg_t* cfg, float* softbits, uint8_t* data); - -SRSLTE_API int -srslte_npdsch_cp(srslte_npdsch_t* q, cf_t* input, cf_t* output, srslte_ra_nbiot_dl_grant_t* grant, bool put); - -SRSLTE_API float srslte_npdsch_average_noi(srslte_npdsch_t* q); - -SRSLTE_API uint32_t srslte_npdsch_last_noi(srslte_npdsch_t* q); - -SRSLTE_API void srslte_npdsch_sib1_pack(srslte_cell_t* cell, srslte_sys_info_block_type_1_nb_t* sib, uint8_t* payload); - -SRSLTE_API void srslte_npdsch_sib1_unpack(uint8_t* const msg, srslte_sys_info_block_type_1_nb_t* sib); - -#endif // SRSLTE_NPDSCH_H diff --git a/lib/include/srslte/phy/phch/pbch.h b/lib/include/srslte/phy/phch/pbch.h deleted file mode 100644 index a5705bc46..000000000 --- a/lib/include/srslte/phy/phch/pbch.h +++ /dev/null @@ -1,99 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2020 Software Radio Systems Limited - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the distribution. - * - */ - -/****************************************************************************** - * File: pbch.h - * - * Description: Physical broadcast channel. If cell.nof_ports = 0, the number - * of ports is blindly determined using the CRC of the received - * codeword for 1, 2 and 4 ports - * - * Reference: 3GPP TS 36.211 version 10.0.0 Release 10 Sec. 6.6 - *****************************************************************************/ - -#ifndef SRSLTE_PBCH_H -#define SRSLTE_PBCH_H - -#include "srslte/config.h" -#include "srslte/phy/ch_estimation/chest_dl.h" -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/fec/convolutional/convcoder.h" -#include "srslte/phy/fec/convolutional/rm_conv.h" -#include "srslte/phy/fec/convolutional/viterbi.h" -#include "srslte/phy/fec/crc.h" -#include "srslte/phy/mimo/layermap.h" -#include "srslte/phy/mimo/precoding.h" -#include "srslte/phy/modem/demod_soft.h" -#include "srslte/phy/modem/mod.h" -#include "srslte/phy/scrambling/scrambling.h" - -#define SRSLTE_BCH_PAYLOAD_LEN 24 -#define SRSLTE_BCH_PAYLOADCRC_LEN (SRSLTE_BCH_PAYLOAD_LEN + 16) -#define SRSLTE_BCH_ENCODED_LEN 3 * (SRSLTE_BCH_PAYLOADCRC_LEN) - -#define SRSLTE_PBCH_MAX_RE 256 // make it avx2-aligned - -/* PBCH object */ -typedef struct SRSLTE_API { - srslte_cell_t cell; - - uint32_t nof_symbols; - - /* buffers */ - cf_t* ce[SRSLTE_MAX_PORTS]; - cf_t* symbols[SRSLTE_MAX_PORTS]; - cf_t* x[SRSLTE_MAX_PORTS]; - cf_t* d; - float* llr; - float* temp; - float rm_f[SRSLTE_BCH_ENCODED_LEN]; - uint8_t* rm_b; - uint8_t data[SRSLTE_BCH_PAYLOADCRC_LEN]; - uint8_t data_enc[SRSLTE_BCH_ENCODED_LEN]; - - uint32_t frame_idx; - - /* tx & rx objects */ - srslte_modem_table_t mod; - srslte_sequence_t seq; - srslte_viterbi_t decoder; - srslte_crc_t crc; - srslte_convcoder_t encoder; - bool search_all_ports; - -} srslte_pbch_t; - -SRSLTE_API int srslte_pbch_init(srslte_pbch_t* q); - -SRSLTE_API void srslte_pbch_free(srslte_pbch_t* q); - -SRSLTE_API int srslte_pbch_set_cell(srslte_pbch_t* q, srslte_cell_t cell); - -SRSLTE_API int srslte_pbch_decode(srslte_pbch_t* q, - srslte_chest_dl_res_t* channel, - cf_t* sf_symbols[SRSLTE_MAX_PORTS], - uint8_t bch_payload[SRSLTE_BCH_PAYLOAD_LEN], - uint32_t* nof_tx_ports, - int* sfn_offset); - -SRSLTE_API int srslte_pbch_encode(srslte_pbch_t* q, - uint8_t bch_payload[SRSLTE_BCH_PAYLOAD_LEN], - cf_t* sf_symbols[SRSLTE_MAX_PORTS], - uint32_t frame_idx); - -SRSLTE_API void srslte_pbch_decode_reset(srslte_pbch_t* q); - -SRSLTE_API void srslte_pbch_mib_unpack(uint8_t* msg, srslte_cell_t* cell, uint32_t* sfn); - -SRSLTE_API void srslte_pbch_mib_pack(srslte_cell_t* cell, uint32_t sfn, uint8_t* msg); - -#endif // SRSLTE_PBCH_H diff --git a/lib/include/srslte/phy/phch/pcfich.h b/lib/include/srslte/phy/phch/pcfich.h deleted file mode 100644 index c482602ba..000000000 --- a/lib/include/srslte/phy/phch/pcfich.h +++ /dev/null @@ -1,82 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2020 Software Radio Systems Limited - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the distribution. - * - */ - -/****************************************************************************** - * File: pcfich.h - * - * Description: Physical control format indicator channel - * - * Reference: 3GPP TS 36.211 version 10.0.0 Release 10 Sec. 6.7 - *****************************************************************************/ - -#ifndef SRSLTE_PCFICH_H -#define SRSLTE_PCFICH_H - -#include "srslte/config.h" -#include "srslte/phy/ch_estimation/chest_dl.h" -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/mimo/layermap.h" -#include "srslte/phy/mimo/precoding.h" -#include "srslte/phy/modem/demod_soft.h" -#include "srslte/phy/modem/mod.h" -#include "srslte/phy/phch/regs.h" -#include "srslte/phy/scrambling/scrambling.h" - -#define PCFICH_CFI_LEN 32 -#define PCFICH_RE PCFICH_CFI_LEN / 2 - -/* PCFICH object */ -typedef struct SRSLTE_API { - srslte_cell_t cell; - int nof_symbols; - - uint32_t nof_rx_antennas; - - /* handler to REGs resource mapper */ - srslte_regs_t* regs; - - /* buffers */ - cf_t ce[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS][PCFICH_RE]; - cf_t symbols[SRSLTE_MAX_PORTS][PCFICH_RE]; - cf_t x[SRSLTE_MAX_PORTS][PCFICH_RE]; - cf_t d[PCFICH_RE]; - - // cfi table in floats - float cfi_table_float[3][PCFICH_CFI_LEN]; - - /* bit message */ - uint8_t data[PCFICH_CFI_LEN]; - - /* received soft bits */ - float data_f[PCFICH_CFI_LEN]; - - /* tx & rx objects */ - srslte_modem_table_t mod; - srslte_sequence_t seq[SRSLTE_NOF_SF_X_FRAME]; - -} srslte_pcfich_t; - -SRSLTE_API int srslte_pcfich_init(srslte_pcfich_t* q, uint32_t nof_rx_antennas); - -SRSLTE_API int srslte_pcfich_set_cell(srslte_pcfich_t* q, srslte_regs_t* regs, srslte_cell_t cell); - -SRSLTE_API void srslte_pcfich_free(srslte_pcfich_t* q); - -SRSLTE_API int srslte_pcfich_decode(srslte_pcfich_t* q, - srslte_dl_sf_cfg_t* sf, - srslte_chest_dl_res_t* channel, - cf_t* sf_symbols[SRSLTE_MAX_PORTS], - float* corr_result); - -SRSLTE_API int srslte_pcfich_encode(srslte_pcfich_t* q, srslte_dl_sf_cfg_t* sf, cf_t* sf_symbols[SRSLTE_MAX_PORTS]); - -#endif // SRSLTE_PCFICH_H diff --git a/lib/include/srslte/phy/phch/pdcch.h b/lib/include/srslte/phy/phch/pdcch.h deleted file mode 100644 index be18b851b..000000000 --- a/lib/include/srslte/phy/phch/pdcch.h +++ /dev/null @@ -1,137 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2020 Software Radio Systems Limited - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the distribution. - * - */ - -/****************************************************************************** - * File: pdcch.h - * - * Description: Physical downlink control channel. - * - * Reference: 3GPP TS 36.211 version 10.0.0 Release 10 Sec. 6.8 - *****************************************************************************/ - -#ifndef SRSLTE_PDCCH_H -#define SRSLTE_PDCCH_H - -#include "srslte/config.h" -#include "srslte/phy/ch_estimation/chest_dl.h" -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/fec/convolutional/convcoder.h" -#include "srslte/phy/fec/convolutional/rm_conv.h" -#include "srslte/phy/fec/convolutional/viterbi.h" -#include "srslte/phy/fec/crc.h" -#include "srslte/phy/mimo/layermap.h" -#include "srslte/phy/mimo/precoding.h" -#include "srslte/phy/modem/demod_soft.h" -#include "srslte/phy/modem/mod.h" -#include "srslte/phy/phch/dci.h" -#include "srslte/phy/phch/regs.h" -#include "srslte/phy/scrambling/scrambling.h" - -typedef enum SRSLTE_API { SEARCH_UE, SEARCH_COMMON } srslte_pdcch_search_mode_t; - -/* PDCCH object */ -typedef struct SRSLTE_API { - srslte_cell_t cell; - uint32_t nof_regs[3]; - uint32_t nof_cce[3]; - uint32_t max_bits; - uint32_t nof_rx_antennas; - bool is_ue; - - srslte_regs_t* regs; - - /* buffers */ - cf_t* ce[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS]; - cf_t* symbols[SRSLTE_MAX_PORTS]; - cf_t* x[SRSLTE_MAX_PORTS]; - cf_t* d; - uint8_t* e; - float rm_f[3 * (SRSLTE_DCI_MAX_BITS + 16)]; - float* llr; - - /* tx & rx objects */ - srslte_modem_table_t mod; - srslte_sequence_t seq[SRSLTE_NOF_SF_X_FRAME]; - srslte_viterbi_t decoder; - srslte_crc_t crc; - -} srslte_pdcch_t; - -SRSLTE_API int srslte_pdcch_init_ue(srslte_pdcch_t* q, uint32_t max_prb, uint32_t nof_rx_antennas); - -SRSLTE_API int srslte_pdcch_init_enb(srslte_pdcch_t* q, uint32_t max_prb); - -SRSLTE_API int srslte_pdcch_set_cell(srslte_pdcch_t* q, srslte_regs_t* regs, srslte_cell_t cell); - -SRSLTE_API void srslte_pdcch_set_regs(srslte_pdcch_t* q, srslte_regs_t* regs); - -SRSLTE_API void srslte_pdcch_free(srslte_pdcch_t* q); - -SRSLTE_API float srslte_pdcch_coderate(uint32_t nof_bits, uint32_t l); - -/* Encoding function */ -SRSLTE_API int srslte_pdcch_encode(srslte_pdcch_t* q, - srslte_dl_sf_cfg_t* sf, - srslte_dci_msg_t* msg, - cf_t* sf_symbols[SRSLTE_MAX_PORTS]); - -/* Decoding functions: Extract the LLRs and save them in the srslte_pdcch_t object */ - -SRSLTE_API int srslte_pdcch_extract_llr(srslte_pdcch_t* q, - srslte_dl_sf_cfg_t* sf, - srslte_chest_dl_res_t* channel, - cf_t* sf_symbols[SRSLTE_MAX_PORTS]); - -/* Decoding functions: Try to decode a DCI message after calling srslte_pdcch_extract_llr */ -SRSLTE_API int -srslte_pdcch_decode_msg(srslte_pdcch_t* q, srslte_dl_sf_cfg_t* sf, srslte_dci_cfg_t* dci_cfg, srslte_dci_msg_t* msg); - -SRSLTE_API int -srslte_pdcch_dci_decode(srslte_pdcch_t* q, float* e, uint8_t* data, uint32_t E, uint32_t nof_bits, uint16_t* crc); - -SRSLTE_API int -srslte_pdcch_dci_encode(srslte_pdcch_t* q, uint8_t* data, uint8_t* e, uint32_t nof_bits, uint32_t E, uint16_t rnti); - -SRSLTE_API void -srslte_pdcch_dci_encode_conv(srslte_pdcch_t* q, uint8_t* data, uint32_t nof_bits, uint8_t* coded_data, uint16_t rnti); - -/* Function for generation of UE-specific search space DCI locations */ -SRSLTE_API uint32_t srslte_pdcch_ue_locations(srslte_pdcch_t* q, - srslte_dl_sf_cfg_t* sf, - srslte_dci_location_t* locations, - uint32_t max_locations, - uint16_t rnti); - -SRSLTE_API uint32_t srslte_pdcch_ue_locations_ncce(uint32_t nof_cce, - srslte_dci_location_t* c, - uint32_t max_candidates, - uint32_t sf_idx, - uint16_t rnti); - -SRSLTE_API uint32_t srslte_pdcch_ue_locations_ncce_L(uint32_t nof_cce, - srslte_dci_location_t* c, - uint32_t max_candidates, - uint32_t sf_idx, - uint16_t rnti, - int L); - -/* Function for generation of common search space DCI locations */ -SRSLTE_API uint32_t srslte_pdcch_common_locations(srslte_pdcch_t* q, - srslte_dci_location_t* locations, - uint32_t max_locations, - uint32_t cfi); - -SRSLTE_API uint32_t srslte_pdcch_common_locations_ncce(uint32_t nof_cce, - srslte_dci_location_t* c, - uint32_t max_candidates); - -#endif // SRSLTE_PDCCH_H diff --git a/lib/include/srslte/phy/phch/pdsch.h b/lib/include/srslte/phy/phch/pdsch.h deleted file mode 100644 index 269ae24c8..000000000 --- a/lib/include/srslte/phy/phch/pdsch.h +++ /dev/null @@ -1,124 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2020 Software Radio Systems Limited - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the distribution. - * - */ - -/****************************************************************************** - * File: pdsch.h - * - * Description: Physical downlink shared channel - * - * Reference: 3GPP TS 36.211 version 10.0.0 Release 10 Sec. 6.4 - *****************************************************************************/ - -#ifndef SRSLTE_PDSCH_H -#define SRSLTE_PDSCH_H - -#include "srslte/config.h" -#include "srslte/phy/ch_estimation/chest_dl.h" -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/mimo/layermap.h" -#include "srslte/phy/mimo/precoding.h" -#include "srslte/phy/modem/demod_soft.h" -#include "srslte/phy/modem/evm.h" -#include "srslte/phy/modem/mod.h" -#include "srslte/phy/phch/dci.h" -#include "srslte/phy/phch/pdsch_cfg.h" -#include "srslte/phy/phch/regs.h" -#include "srslte/phy/phch/sch.h" -#include "srslte/phy/scrambling/scrambling.h" - -/* PDSCH object */ -typedef struct SRSLTE_API { - srslte_cell_t cell; - - uint32_t nof_rx_antennas; - uint32_t max_re; - - bool is_ue; - - bool llr_is_8bit; - - /* buffers */ - // void buffers are shared for tx and rx - cf_t* ce[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS]; /* Channel estimation (Rx only) */ - cf_t* symbols[SRSLTE_MAX_PORTS]; /* PDSCH Encoded/Decoded Symbols */ - cf_t* x[SRSLTE_MAX_LAYERS]; /* Layer mapped */ - cf_t* d[SRSLTE_MAX_CODEWORDS]; /* Modulated/Demodulated codewords */ - void* e[SRSLTE_MAX_CODEWORDS]; - - float* csi[SRSLTE_MAX_CODEWORDS]; /* Channel Strengh Indicator */ - - /* tx & rx objects */ - srslte_modem_table_t mod[SRSLTE_MOD_NITEMS]; - - // EVM buffers, one for each codeword (avoid concurrency issue with coworker) - srslte_evm_buffer_t* evm_buffer[SRSLTE_MAX_CODEWORDS]; - float avg_evm; - - srslte_sch_t dl_sch; - - void* coworker_ptr; - -} srslte_pdsch_t; - -typedef struct { - uint8_t* payload; - bool crc; - float avg_iterations_block; - float evm; -} srslte_pdsch_res_t; - -SRSLTE_API int srslte_pdsch_init_ue(srslte_pdsch_t* q, uint32_t max_prb, uint32_t nof_rx_antennas); - -SRSLTE_API int srslte_pdsch_init_enb(srslte_pdsch_t* q, uint32_t max_prb); - -SRSLTE_API void srslte_pdsch_free(srslte_pdsch_t* q); - -/* These functions modify the state of the object and may take some time */ -SRSLTE_API int srslte_pdsch_enable_coworker(srslte_pdsch_t* q); - -SRSLTE_API int srslte_pdsch_set_cell(srslte_pdsch_t* q, srslte_cell_t cell); - -/* These functions do not modify the state and run in real-time */ -SRSLTE_API int srslte_pdsch_encode(srslte_pdsch_t* q, - srslte_dl_sf_cfg_t* sf, - srslte_pdsch_cfg_t* cfg, - uint8_t* data[SRSLTE_MAX_CODEWORDS], - cf_t* sf_symbols[SRSLTE_MAX_PORTS]); - -SRSLTE_API int srslte_pdsch_decode(srslte_pdsch_t* q, - srslte_dl_sf_cfg_t* sf, - srslte_pdsch_cfg_t* cfg, - srslte_chest_dl_res_t* channel, - cf_t* sf_symbols[SRSLTE_MAX_PORTS], - srslte_pdsch_res_t data[SRSLTE_MAX_CODEWORDS]); - -SRSLTE_API int srslte_pdsch_select_pmi(srslte_pdsch_t* q, - srslte_chest_dl_res_t* channel, - uint32_t nof_layers, - uint32_t* best_pmi, - float sinr[SRSLTE_MAX_CODEBOOKS]); - -SRSLTE_API int srslte_pdsch_compute_cn(srslte_pdsch_t* q, srslte_chest_dl_res_t* channel, float* cn); - -SRSLTE_API uint32_t srslte_pdsch_grant_rx_info(srslte_pdsch_grant_t* grant, - srslte_pdsch_res_t res[SRSLTE_MAX_CODEWORDS], - char* str, - uint32_t str_len); - -SRSLTE_API uint32_t srslte_pdsch_rx_info(srslte_pdsch_cfg_t* cfg, - srslte_pdsch_res_t res[SRSLTE_MAX_CODEWORDS], - char* str, - uint32_t str_len); - -SRSLTE_API uint32_t srslte_pdsch_tx_info(srslte_pdsch_cfg_t* cfg, char* str, uint32_t str_len); - -#endif // SRSLTE_PDSCH_H diff --git a/lib/include/srslte/phy/phch/pdsch_nr.h b/lib/include/srslte/phy/phch/pdsch_nr.h deleted file mode 100644 index e6a96f31d..000000000 --- a/lib/include/srslte/phy/phch/pdsch_nr.h +++ /dev/null @@ -1,103 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2020 Software Radio Systems Limited - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the distribution. - * - */ - -/****************************************************************************** - * File: pdsch_nr.h - * - * Description: Physical downlink shared channel for NR - * - * Reference: 3GPP TS 38.211 V15.8.0 Sec. 7.3.1 - *****************************************************************************/ - -#ifndef SRSLTE_PDSCH_NR_H -#define SRSLTE_PDSCH_NR_H - -#include "srslte/config.h" -#include "srslte/phy/ch_estimation/dmrs_sch.h" -#include "srslte/phy/modem/evm.h" -#include "srslte/phy/modem/modem_table.h" -#include "srslte/phy/phch/phch_cfg_nr.h" -#include "srslte/phy/phch/regs.h" -#include "srslte/phy/phch/sch_nr.h" -#include "srslte/phy/scrambling/scrambling.h" - -/** - * @brief PDSCH encoder and decoder initialization arguments - */ -typedef struct SRSLTE_API { - srslte_sch_nr_args_t sch; - bool measure_evm; - bool measure_time; -} srslte_pdsch_nr_args_t; - -/** - * @brief PDSCH NR object - */ -typedef struct SRSLTE_API { - uint32_t max_prb; ///< Maximum number of allocated prb - uint32_t max_layers; ///< Maximum number of allocated layers - uint32_t max_cw; ///< Maximum number of allocated code words - srslte_carrier_nr_t carrier; ///< NR carrier configuration - srslte_sch_nr_t sch; ///< SCH Encoder/Decoder Object - uint8_t* b[SRSLTE_MAX_CODEWORDS]; ///< SCH Encoded and scrambled data - cf_t* d[SRSLTE_MAX_CODEWORDS]; ///< PDSCH modulated bits - cf_t* x[SRSLTE_MAX_LAYERS_NR]; ///< PDSCH modulated bits - srslte_modem_table_t modem_tables[SRSLTE_MOD_NITEMS]; ///< Modulator tables - srslte_evm_buffer_t* evm_buffer; - bool meas_time_en; - uint32_t meas_time_us; -} srslte_pdsch_nr_t; - -/** - * - */ -typedef struct { - uint8_t* payload; - bool crc; - float evm; -} srslte_pdsch_res_nr_t; - -SRSLTE_API int srslte_pdsch_nr_init_enb(srslte_pdsch_nr_t* q, const srslte_pdsch_nr_args_t* args); - -SRSLTE_API int srslte_pdsch_nr_init_ue(srslte_pdsch_nr_t* q, const srslte_pdsch_nr_args_t* args); - -SRSLTE_API void srslte_pdsch_nr_free(srslte_pdsch_nr_t* q); - -SRSLTE_API int srslte_pdsch_nr_set_carrier(srslte_pdsch_nr_t* q, const srslte_carrier_nr_t* carrier); - -SRSLTE_API int srslte_pdsch_nr_encode(srslte_pdsch_nr_t* q, - const srslte_sch_cfg_nr_t* cfg, - const srslte_sch_grant_nr_t* grant, - uint8_t* data[SRSLTE_MAX_TB], - cf_t* sf_symbols[SRSLTE_MAX_PORTS]); - -SRSLTE_API int srslte_pdsch_nr_decode(srslte_pdsch_nr_t* q, - const srslte_sch_cfg_nr_t* cfg, - const srslte_sch_grant_nr_t* grant, - srslte_chest_dl_res_t* channel, - cf_t* sf_symbols[SRSLTE_MAX_PORTS], - srslte_pdsch_res_nr_t data[SRSLTE_MAX_TB]); - -SRSLTE_API uint32_t srslte_pdsch_nr_rx_info(const srslte_pdsch_nr_t* q, - const srslte_sch_cfg_nr_t* cfg, - const srslte_sch_grant_nr_t* grant, - const srslte_pdsch_res_nr_t* res, - char* str, - uint32_t str_len); - -SRSLTE_API uint32_t srslte_pdsch_nr_tx_info(const srslte_pdsch_nr_t* q, - const srslte_sch_cfg_nr_t* cfg, - const srslte_sch_grant_nr_t* grant, - char* str, - uint32_t str_len); - -#endif // SRSLTE_PDSCH_NR_H diff --git a/lib/include/srslte/phy/phch/phich.h b/lib/include/srslte/phy/phch/phich.h deleted file mode 100644 index b4fffd5a9..000000000 --- a/lib/include/srslte/phy/phch/phich.h +++ /dev/null @@ -1,118 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2020 Software Radio Systems Limited - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the distribution. - * - */ - -/****************************************************************************** - * File: phich.h - * - * Description: Physical Hybrid ARQ indicator channel. - * - * Reference: 3GPP TS 36.211 version 10.0.0 Release 10 Sec. 6.9 - *****************************************************************************/ - -#ifndef SRSLTE_PHICH_H -#define SRSLTE_PHICH_H - -#include "regs.h" -#include "srslte/config.h" -#include "srslte/phy/ch_estimation/chest_dl.h" -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/mimo/layermap.h" -#include "srslte/phy/mimo/precoding.h" -#include "srslte/phy/modem/demod_soft.h" -#include "srslte/phy/modem/mod.h" -#include "srslte/phy/scrambling/scrambling.h" - -#define SRSLTE_PHICH_NORM_NSEQUENCES 8 -#define SRSLTE_PHICH_EXT_NSEQUENCES 4 -#define SRSLTE_PHICH_NBITS 3 - -#define SRSLTE_PHICH_NORM_MSYMB SRSLTE_PHICH_NBITS * 4 -#define SRSLTE_PHICH_EXT_MSYMB SRSLTE_PHICH_NBITS * 2 -#define SRSLTE_PHICH_MAX_NSYMB SRSLTE_PHICH_NORM_MSYMB -#define SRSLTE_PHICH_NORM_C 1 -#define SRSLTE_PHICH_EXT_C 2 -#define SRSLTE_PHICH_NORM_NSF 4 -#define SRSLTE_PHICH_EXT_NSF 2 - -/* phich object */ -typedef struct SRSLTE_API { - srslte_cell_t cell; - - uint32_t nof_rx_antennas; - - /* handler to REGs resource mapper */ - srslte_regs_t* regs; - - /* buffers */ - cf_t ce[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS][SRSLTE_PHICH_MAX_NSYMB]; - cf_t sf_symbols[SRSLTE_MAX_PORTS][SRSLTE_PHICH_MAX_NSYMB]; - cf_t x[SRSLTE_MAX_PORTS][SRSLTE_PHICH_MAX_NSYMB]; - cf_t d[SRSLTE_PHICH_MAX_NSYMB]; - cf_t d0[SRSLTE_PHICH_MAX_NSYMB]; - cf_t z[SRSLTE_PHICH_NBITS]; - - /* bit message */ - uint8_t data[SRSLTE_PHICH_NBITS]; - float data_rx[SRSLTE_PHICH_NBITS]; - - /* tx & rx objects */ - srslte_modem_table_t mod; - srslte_sequence_t seq[SRSLTE_NOF_SF_X_FRAME]; - -} srslte_phich_t; - -typedef struct SRSLTE_API { - uint32_t ngroup; - uint32_t nseq; -} srslte_phich_resource_t; - -typedef struct SRSLTE_API { - uint32_t n_prb_lowest; - uint32_t n_dmrs; - uint32_t I_phich; -} srslte_phich_grant_t; - -typedef struct SRSLTE_API { - bool ack_value; - float distance; -} srslte_phich_res_t; - -SRSLTE_API int srslte_phich_init(srslte_phich_t* q, uint32_t nof_rx_antennas); - -SRSLTE_API void srslte_phich_free(srslte_phich_t* q); - -SRSLTE_API int srslte_phich_set_cell(srslte_phich_t* q, srslte_regs_t* regs, srslte_cell_t cell); - -SRSLTE_API void srslte_phich_set_regs(srslte_phich_t* q, srslte_regs_t* regs); - -SRSLTE_API void srslte_phich_calc(srslte_phich_t* q, srslte_phich_grant_t* grant, srslte_phich_resource_t* n_phich); - -SRSLTE_API int srslte_phich_decode(srslte_phich_t* q, - srslte_dl_sf_cfg_t* sf, - srslte_chest_dl_res_t* channel, - srslte_phich_resource_t n_phich, - cf_t* sf_symbols[SRSLTE_MAX_PORTS], - srslte_phich_res_t* result); - -SRSLTE_API int srslte_phich_encode(srslte_phich_t* q, - srslte_dl_sf_cfg_t* sf, - srslte_phich_resource_t n_phich, - uint8_t ack, - cf_t* sf_symbols[SRSLTE_MAX_PORTS]); - -SRSLTE_API void srslte_phich_reset(srslte_phich_t* q, cf_t* slot_symbols[SRSLTE_MAX_PORTS]); - -SRSLTE_API uint32_t srslte_phich_ngroups(srslte_phich_t* q); - -SRSLTE_API uint32_t srslte_phich_nsf(srslte_phich_t* q); - -#endif // SRSLTE_PHICH_H diff --git a/lib/include/srslte/phy/phch/pmch.h b/lib/include/srslte/phy/phch/pmch.h deleted file mode 100644 index 8345a1e11..000000000 --- a/lib/include/srslte/phy/phch/pmch.h +++ /dev/null @@ -1,97 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2020 Software Radio Systems Limited - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the distribution. - * - */ - -/****************************************************************************** - * File: pmch.h - * - * Description: Physical multicast channel - * - * Reference: 3GPP TS 36.211 version 10.0.0 Release 10 Sec. 6.5 - *****************************************************************************/ - -#ifndef SRSLTE_PMCH_H -#define SRSLTE_PMCH_H - -#include "srslte/config.h" -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/common/sequence.h" -#include "srslte/phy/mimo/layermap.h" -#include "srslte/phy/mimo/precoding.h" -#include "srslte/phy/modem/demod_soft.h" -#include "srslte/phy/modem/mod.h" -#include "srslte/phy/phch/dci.h" -#include "srslte/phy/phch/pdsch.h" -#include "srslte/phy/phch/ra_dl.h" -#include "srslte/phy/phch/regs.h" -#include "srslte/phy/phch/sch.h" -#include "srslte/phy/scrambling/scrambling.h" -typedef struct { - srslte_sequence_t seq[SRSLTE_NOF_SF_X_FRAME]; -} srslte_pmch_seq_t; - -typedef struct SRSLTE_API { - srslte_pdsch_cfg_t pdsch_cfg; - uint16_t area_id; -} srslte_pmch_cfg_t; - -/* PMCH object */ -typedef struct SRSLTE_API { - srslte_cell_t cell; - - uint32_t nof_rx_antennas; - - uint32_t max_re; - - /* buffers */ - // void buffers are shared for tx and rx - cf_t* ce[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS]; - cf_t* symbols[SRSLTE_MAX_PORTS]; - cf_t* x[SRSLTE_MAX_PORTS]; - cf_t* d; - void* e; - - /* tx & rx objects */ - srslte_modem_table_t mod[4]; - - // This is to generate the scrambling seq for multiple MBSFN Area IDs - srslte_pmch_seq_t** seqs; - - srslte_sch_t dl_sch; - -} srslte_pmch_t; - -SRSLTE_API int srslte_pmch_init(srslte_pmch_t* q, uint32_t max_prb, uint32_t nof_rx_antennas); - -SRSLTE_API void srslte_pmch_free(srslte_pmch_t* q); - -SRSLTE_API int srslte_pmch_set_cell(srslte_pmch_t* q, srslte_cell_t cell); - -SRSLTE_API int srslte_pmch_set_area_id(srslte_pmch_t* q, uint16_t area_id); - -SRSLTE_API void srslte_pmch_free_area_id(srslte_pmch_t* q, uint16_t area_id); - -SRSLTE_API void srslte_configure_pmch(srslte_pmch_cfg_t* pmch_cfg, srslte_cell_t* cell, srslte_mbsfn_cfg_t* mbsfn_cfg); - -SRSLTE_API int srslte_pmch_encode(srslte_pmch_t* q, - srslte_dl_sf_cfg_t* sf, - srslte_pmch_cfg_t* cfg, - uint8_t* data, - cf_t* sf_symbols[SRSLTE_MAX_PORTS]); - -SRSLTE_API int srslte_pmch_decode(srslte_pmch_t* q, - srslte_dl_sf_cfg_t* sf, - srslte_pmch_cfg_t* cfg, - srslte_chest_dl_res_t* channel, - cf_t* sf_symbols[SRSLTE_MAX_PORTS], - srslte_pdsch_res_t* data); - -#endif // SRSLTE_PMCH_H diff --git a/lib/include/srslte/phy/phch/pscch.h b/lib/include/srslte/phy/phch/pscch.h deleted file mode 100644 index 6d107113a..000000000 --- a/lib/include/srslte/phy/phch/pscch.h +++ /dev/null @@ -1,90 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2020 Software Radio Systems Limited - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the distribution. - * - */ - -#ifndef SRSLTE_PSCCH_H -#define SRSLTE_PSCCH_H - -#include - -#include "srslte/phy/common/phy_common_sl.h" -#include "srslte/phy/common/sequence.h" -#include "srslte/phy/dft/dft_precoding.h" -#include "srslte/phy/fec/convolutional/convcoder.h" -#include "srslte/phy/fec/convolutional/viterbi.h" -#include "srslte/phy/fec/crc.h" -#include "srslte/phy/modem/modem_table.h" - -/** - * \brief Physical Sidelink control channel. - * - * Reference: 3GPP TS 36.211 version 15.6.0 Release 15 Section 9.4 - */ - -typedef struct SRSLTE_API { - - uint32_t max_prb; - srslte_cell_sl_t cell; - - uint32_t sci_len; - uint32_t nof_tx_re; - - uint32_t pscch_nof_prb; - - // crc - uint8_t* c; - srslte_crc_t crc; - uint8_t* sci_crc; - - // channel coding - srslte_viterbi_t dec; - srslte_convcoder_t encoder; - uint8_t* d; - int16_t* d_16; - - // rate matching - uint32_t E; - uint8_t* e; - int16_t* e_16; - - uint8_t* e_bytes; ///< To pack bits to bytes - uint32_t nof_symbols; - - // interleaving - uint32_t* interleaver_lut; - uint8_t* codeword; - uint8_t* codeword_bytes; - - // scrambling - srslte_sequence_t seq; - - // modulation - srslte_modem_table_t mod; - cf_t* mod_symbols; - int16_t* llr; - - // dft precoding - srslte_dft_precoding_t dft_precoder; - srslte_dft_precoding_t idft_precoder; - - cf_t* scfdma_symbols; - -} srslte_pscch_t; - -SRSLTE_API int srslte_pscch_init(srslte_pscch_t* q, uint32_t max_prb); -SRSLTE_API int srslte_pscch_set_cell(srslte_pscch_t* q, srslte_cell_sl_t cell); -SRSLTE_API int srslte_pscch_encode(srslte_pscch_t* q, uint8_t* sci, cf_t* sf_buffer, uint32_t prb_start_idx); -SRSLTE_API int srslte_pscch_decode(srslte_pscch_t* q, cf_t* equalized_sf_syms, uint8_t* sci, uint32_t prb_start_idx); -SRSLTE_API int srslte_pscch_put(srslte_pscch_t* q, cf_t* sf_buffer, uint32_t prb_start_idx); -SRSLTE_API int srslte_pscch_get(srslte_pscch_t* q, cf_t* sf_buffer, uint32_t prb_start_idx); -SRSLTE_API void srslte_pscch_free(srslte_pscch_t* q); - -#endif // SRSLTE_PSCCH_H diff --git a/lib/include/srslte/phy/phch/pucch.h b/lib/include/srslte/phy/phch/pucch.h deleted file mode 100644 index 1702686e2..000000000 --- a/lib/include/srslte/phy/phch/pucch.h +++ /dev/null @@ -1,175 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2020 Software Radio Systems Limited - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the distribution. - * - */ - -/****************************************************************************** - * File: pucch.h - * - * Description: Physical uplink control channel. - * - * Reference: 3GPP TS 36.211 version 10.0.0 Release 10 Sec. 5.4 - *****************************************************************************/ - -#ifndef SRSLTE_PUCCH_H -#define SRSLTE_PUCCH_H - -#include "srslte/config.h" -#include "srslte/phy/ch_estimation/chest_ul.h" -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/common/sequence.h" -#include "srslte/phy/modem/mod.h" -#include "srslte/phy/phch/cqi.h" -#include "srslte/phy/phch/pucch_cfg.h" -#include "srslte/phy/phch/uci.h" - -#define SRSLTE_PUCCH_N_SEQ SRSLTE_NRE -#define SRSLTE_PUCCH2_NOF_BITS SRSLTE_UCI_CQI_CODED_PUCCH_B -#define SRSLTE_PUCCH2_N_SF (5) -#define SRSLTE_PUCCH_1A_2A_NOF_ACK (1) -#define SRSLTE_PUCCH_1B_2B_NOF_ACK (2) -#define SRSLTE_PUCCH3_NOF_BITS (4 * SRSLTE_NRE) -#define SRSLTE_PUCCH_MAX_SYMBOLS (SRSLTE_PUCCH_N_SEQ * SRSLTE_PUCCH2_N_SF * SRSLTE_NOF_SLOTS_PER_SF) - -// PUCCH Format 1B Channel selection -#define SRSLTE_PUCCH_CS_MAX_ACK 4 -#define SRSLTE_PUCCH_CS_MAX_CARRIERS 2 -#define SRSLTE_PUCCH_FORMAT3_MAX_CARRIERS 5 - -#define SRSLTE_PUCCH_DEFAULT_THRESHOLD_FORMAT1 (0.5f) -#define SRSLTE_PUCCH_DEFAULT_THRESHOLD_FORMAT1A (0.5f) -#define SRSLTE_PUCCH_DEFAULT_THRESHOLD_FORMAT2 (0.5f) -#define SRSLTE_PUCCH_DEFAULT_THRESHOLD_FORMAT3 (0.5f) -#define SRSLTE_PUCCH_DEFAULT_THRESHOLD_DMRS (0.4f) - -/* PUCCH object */ -typedef struct SRSLTE_API { - srslte_cell_t cell; - srslte_modem_table_t mod; - - srslte_uci_cqi_pucch_t cqi; - - srslte_sequence_t seq_f2; - bool is_ue; - - int16_t llr[SRSLTE_PUCCH3_NOF_BITS]; - uint8_t bits_scram[SRSLTE_PUCCH_MAX_BITS]; - cf_t d[SRSLTE_PUCCH_MAX_BITS / 2]; - uint32_t n_cs_cell[SRSLTE_NSLOTS_X_FRAME][SRSLTE_CP_NORM_NSYMB]; - uint32_t f_gh[SRSLTE_NSLOTS_X_FRAME]; - - cf_t* z; - cf_t* z_tmp; - cf_t* ce; - -} srslte_pucch_t; - -typedef struct SRSLTE_API { - srslte_uci_value_t uci_data; - float dmrs_correlation; - float snr_db; - float correlation; - bool detected; - - // PUCCH Measurements - bool ta_valid; - float ta_us; -} srslte_pucch_res_t; - -SRSLTE_API int srslte_pucch_init_ue(srslte_pucch_t* q); - -SRSLTE_API int srslte_pucch_init_enb(srslte_pucch_t* q); - -SRSLTE_API void srslte_pucch_free(srslte_pucch_t* q); - -/* These functions modify the state of the object and may take some time */ -SRSLTE_API int srslte_pucch_set_cell(srslte_pucch_t* q, srslte_cell_t cell); - -/* These functions do not modify the state and run in real-time */ -SRSLTE_API void srslte_pucch_uci_gen_cfg(srslte_pucch_t* q, srslte_pucch_cfg_t* cfg, srslte_uci_data_t* uci_data); - -SRSLTE_API int srslte_pucch_encode(srslte_pucch_t* q, - srslte_ul_sf_cfg_t* sf, - srslte_pucch_cfg_t* cfg, - srslte_uci_value_t* uci_data, - cf_t* sf_symbols); - -SRSLTE_API int srslte_pucch_decode(srslte_pucch_t* q, - srslte_ul_sf_cfg_t* sf, - srslte_pucch_cfg_t* cfg, - srslte_chest_ul_res_t* channel, - cf_t* sf_symbols, - srslte_pucch_res_t* data); - -/* Other utilities. These functions do not modify the state and run in real-time */ -SRSLTE_API float srslte_pucch_alpha_format1(const uint32_t n_cs_cell[SRSLTE_NSLOTS_X_FRAME][SRSLTE_CP_NORM_NSYMB], - const srslte_pucch_cfg_t* cfg, - srslte_cp_t cp, - bool is_dmrs, - uint32_t ns, - uint32_t l, - uint32_t* n_oc, - uint32_t* n_prime_ns); - -SRSLTE_API float srslte_pucch_alpha_format2(const uint32_t n_cs_cell[SRSLTE_NSLOTS_X_FRAME][SRSLTE_CP_NORM_NSYMB], - const srslte_pucch_cfg_t* cfg, - uint32_t ns, - uint32_t l); - -SRSLTE_API int srslte_pucch_format2ab_mod_bits(srslte_pucch_format_t format, uint8_t bits[2], cf_t* d_10); - -SRSLTE_API uint32_t srslte_pucch_m(const srslte_pucch_cfg_t* cfg, srslte_cp_t cp); - -SRSLTE_API uint32_t srslte_pucch_n_prb(const srslte_cell_t* cell, const srslte_pucch_cfg_t* cfg, uint32_t ns); - -SRSLTE_API int srslte_pucch_n_cs_cell(srslte_cell_t cell, - uint32_t n_cs_cell[SRSLTE_NSLOTS_X_FRAME][SRSLTE_CP_NORM_NSYMB]); - -/** - * Checks PUCCH collision from cell and two PUCCH configurations. The provided configurations shall provide format and - * n_pucch resource prior to this call. - * - * @param cell cell parameters - * @param cfg1 First PUCCH configuration - * @param cfg2 Second PUCCH configuration - * @return SRSLTE_SUCCESS if no collision, SRSLTE_ERROR if collision and otherwise SRSLTE_INVALID_INPUTS - */ -SRSLTE_API int -srslte_pucch_collision(const srslte_cell_t* cell, const srslte_pucch_cfg_t* cfg1, const srslte_pucch_cfg_t* cfg2); - -/** - * Checks PUCCH format 1b with channel selection collision configuration from a cell. - * - * @param cell cell parameters - * @param cfg PUCCH configuration - * @return SRSLTE_SUCCESS if no collision, SRSLTE_ERROR if collision and otherwise SRSLTE_INVALID_INPUTS - */ -SRSLTE_API int srslte_pucch_cfg_assert(const srslte_cell_t* cell, const srslte_pucch_cfg_t* cfg); - -SRSLTE_API char* srslte_pucch_format_text(srslte_pucch_format_t format); - -SRSLTE_API char* srslte_pucch_format_text_short(srslte_pucch_format_t format); - -/** - * Returns the number of ACK bits supported by a given PUCCH format - * @param format PUCCH format - * @return Returns the number of bits supported by the format - */ -SRSLTE_API uint32_t srslte_pucch_nof_ack_format(srslte_pucch_format_t format); - -SRSLTE_API void -srslte_pucch_tx_info(srslte_pucch_cfg_t* cfg, srslte_uci_value_t* uci_data, char* str, uint32_t str_len); - -SRSLTE_API void -srslte_pucch_rx_info(srslte_pucch_cfg_t* cfg, srslte_pucch_res_t* pucch_res, char* str, uint32_t str_len); - -SRSLTE_API bool srslte_pucch_cfg_isvalid(srslte_pucch_cfg_t* cfg, uint32_t nof_prb); - -#endif // SRSLTE_PUCCH_H diff --git a/lib/include/srslte/phy/phch/pusch.h b/lib/include/srslte/phy/phch/pusch.h deleted file mode 100644 index 92fd5502a..000000000 --- a/lib/include/srslte/phy/phch/pusch.h +++ /dev/null @@ -1,130 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2020 Software Radio Systems Limited - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the distribution. - * - */ - -/****************************************************************************** - * File: pusch.h - * - * Description: Physical uplink shared channel. - * - * Reference: 3GPP TS 36.211 version 10.0.0 Release 10 Sec. 5.3 - *****************************************************************************/ - -#ifndef SRSLTE_PUSCH_H -#define SRSLTE_PUSCH_H - -#include "srslte/config.h" -#include "srslte/phy/ch_estimation/refsignal_ul.h" -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/dft/dft_precoding.h" -#include "srslte/phy/mimo/layermap.h" -#include "srslte/phy/mimo/precoding.h" -#include "srslte/phy/modem/demod_soft.h" -#include "srslte/phy/modem/evm.h" -#include "srslte/phy/modem/mod.h" -#include "srslte/phy/phch/dci.h" -#include "srslte/phy/phch/pusch_cfg.h" -#include "srslte/phy/phch/regs.h" -#include "srslte/phy/phch/sch.h" -#include "srslte/phy/scrambling/scrambling.h" - -/* PUSCH object */ -typedef struct SRSLTE_API { - srslte_cell_t cell; - - bool is_ue; - uint16_t ue_rnti; - uint32_t max_re; - - bool llr_is_8bit; - - srslte_dft_precoding_t dft_precoding; - - /* buffers */ - // void buffers are shared for tx and rx - cf_t* ce; - cf_t* z; - cf_t* d; - - void* q; - void* g; - - /* tx & rx objects */ - srslte_modem_table_t mod[SRSLTE_MOD_NITEMS]; - srslte_sch_t ul_sch; - - // EVM buffer - srslte_evm_buffer_t* evm_buffer; - -} srslte_pusch_t; - -typedef struct SRSLTE_API { - uint8_t* ptr; - srslte_uci_value_t uci; -} srslte_pusch_data_t; - -typedef struct SRSLTE_API { - uint8_t* data; - srslte_uci_value_t uci; - bool crc; - float avg_iterations_block; - float evm; - float epre_dbfs; -} srslte_pusch_res_t; - -SRSLTE_API int srslte_pusch_init_ue(srslte_pusch_t* q, uint32_t max_prb); - -SRSLTE_API int srslte_pusch_init_enb(srslte_pusch_t* q, uint32_t max_prb); - -SRSLTE_API void srslte_pusch_free(srslte_pusch_t* q); - -/* These functions modify the state of the object and may take some time */ -SRSLTE_API int srslte_pusch_set_cell(srslte_pusch_t* q, srslte_cell_t cell); - -/** - * Asserts PUSCH grant attributes are in range - * @param grant Pointer to PUSCH grant - * @return it returns SRSLTE_SUCCESS if the grant is correct, otherwise it returns a SRSLTE_ERROR code - */ -SRSLTE_API int srslte_pusch_assert_grant(const srslte_pusch_grant_t* grant); - -/* These functions do not modify the state and run in real-time */ -SRSLTE_API int srslte_pusch_encode(srslte_pusch_t* q, - srslte_ul_sf_cfg_t* sf, - srslte_pusch_cfg_t* cfg, - srslte_pusch_data_t* data, - cf_t* sf_symbols); - -SRSLTE_API int srslte_pusch_decode(srslte_pusch_t* q, - srslte_ul_sf_cfg_t* sf, - srslte_pusch_cfg_t* cfg, - srslte_chest_ul_res_t* channel, - cf_t* sf_symbols, - srslte_pusch_res_t* data); - -SRSLTE_API uint32_t srslte_pusch_grant_tx_info(srslte_pusch_grant_t* grant, - srslte_uci_cfg_t* uci_cfg, - srslte_uci_value_t* uci_data, - char* str, - uint32_t str_len); - -SRSLTE_API uint32_t srslte_pusch_tx_info(srslte_pusch_cfg_t* cfg, - srslte_uci_value_t* uci_data, - char* str, - uint32_t str_len); - -SRSLTE_API uint32_t srslte_pusch_rx_info(srslte_pusch_cfg_t* cfg, - srslte_pusch_res_t* res, - srslte_chest_ul_res_t* chest_res, - char* str, - uint32_t str_len); - -#endif // SRSLTE_PUSCH_H diff --git a/lib/include/srslte/phy/phch/ra.h b/lib/include/srslte/phy/phch/ra.h deleted file mode 100644 index d16e1295c..000000000 --- a/lib/include/srslte/phy/phch/ra.h +++ /dev/null @@ -1,98 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2020 Software Radio Systems Limited - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the distribution. - * - */ - -/****************************************************************************** - * File: ra.h - * - * Description: Implements Resource allocation Procedures common in for DL and UL - * - * Reference: 3GPP TS 36.213 version 10.0.1 Release 10 - *****************************************************************************/ - -#ifndef SRSLTE_RA_H -#define SRSLTE_RA_H - -#include -#include - -#include "srslte/config.h" -#include "srslte/phy/common/phy_common.h" - -/************************************************** - * Common structures used for Resource Allocation - **************************************************/ - -typedef struct SRSLTE_API { - srslte_mod_t mod; - int tbs; - int rv; - uint32_t nof_bits; - uint32_t cw_idx; - bool enabled; - - // this is for debugging and metrics purposes - uint32_t mcs_idx; -} srslte_ra_tb_t; - -typedef enum SRSLTE_API { - SRSLTE_RA_ALLOC_TYPE0 = 0, - SRSLTE_RA_ALLOC_TYPE1 = 1, - SRSLTE_RA_ALLOC_TYPE2 = 2 -} srslte_ra_type_t; - -typedef struct SRSLTE_API { - uint32_t rbg_bitmask; -} srslte_ra_type0_t; - -typedef struct SRSLTE_API { - uint32_t vrb_bitmask; - uint32_t rbg_subset; - bool shift; -} srslte_ra_type1_t; - -typedef struct SRSLTE_API { - uint32_t riv; // if L_crb==0, DCI message packer will take this value directly - enum { SRSLTE_RA_TYPE2_NPRB1A_2 = 0, SRSLTE_RA_TYPE2_NPRB1A_3 = 1 } n_prb1a; - enum { SRSLTE_RA_TYPE2_NG1 = 0, SRSLTE_RA_TYPE2_NG2 = 1 } n_gap; - enum { SRSLTE_RA_TYPE2_LOC = 0, SRSLTE_RA_TYPE2_DIST = 1 } mode; -} srslte_ra_type2_t; - -#define SRSLTE_RA_NOF_TBS_IDX 34 - -SRSLTE_API uint32_t srslte_ra_type0_P(uint32_t nof_prb); - -SRSLTE_API uint32_t srslte_ra_type2_n_vrb_dl(uint32_t nof_prb, bool ngap_is_1); - -SRSLTE_API uint32_t srslte_ra_type2_n_rb_step(uint32_t nof_prb); - -SRSLTE_API uint32_t srslte_ra_type2_ngap(uint32_t nof_prb, bool ngap_is_1); - -SRSLTE_API uint32_t srslte_ra_type1_N_rb(uint32_t nof_prb); - -SRSLTE_API uint32_t srslte_ra_type2_to_riv(uint32_t L_crb, uint32_t RB_start, uint32_t nof_prb); - -SRSLTE_API void -srslte_ra_type2_from_riv(uint32_t riv, uint32_t* L_crb, uint32_t* RB_start, uint32_t nof_prb, uint32_t nof_vrb); - -SRSLTE_API int srslte_ra_tbs_idx_from_mcs(uint32_t mcs, bool use_tbs_index_alt, bool is_ul); - -SRSLTE_API srslte_mod_t srslte_ra_dl_mod_from_mcs(uint32_t mcs, bool use_tbs_index_alt); - -SRSLTE_API srslte_mod_t srslte_ra_ul_mod_from_mcs(uint32_t mcs); - -SRSLTE_API int srslte_ra_mcs_from_tbs_idx(uint32_t tbs_idx, bool use_tbs_index_alt, bool is_ul); - -SRSLTE_API int srslte_ra_tbs_from_idx(uint32_t tbs_idx, uint32_t n_prb); - -SRSLTE_API int srslte_ra_tbs_to_table_idx(uint32_t tbs, uint32_t n_prb, uint32_t max_tbs_idx); - -#endif // SRSLTE_RA_H diff --git a/lib/include/srslte/phy/phch/ra_dl.h b/lib/include/srslte/phy/phch/ra_dl.h deleted file mode 100644 index 6968fafc4..000000000 --- a/lib/include/srslte/phy/phch/ra_dl.h +++ /dev/null @@ -1,65 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2020 Software Radio Systems Limited - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the distribution. - * - */ - -/****************************************************************************** - * File: ra_dl.h - * - * Description: Implements Resource allocation Procedures for DL defined in Section 7 - * - * Reference: 3GPP TS 36.213 version 10.0.1 Release 10 - *****************************************************************************/ - -#ifndef SRSLTE_RA_DL_H -#define SRSLTE_RA_DL_H - -#include -#include - -#include "srslte/config.h" -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/phch/dci.h" -#include "srslte/phy/phch/pdsch_cfg.h" -#include "srslte/phy/phch/ra.h" - -/************************************************** - * Structures used for Downlink Resource Allocation - **************************************************/ - -/** Functions to generate a grant from a received DCI */ -SRSLTE_API int srslte_ra_dl_dci_to_grant(const srslte_cell_t* cell, - srslte_dl_sf_cfg_t* sf, - srslte_tm_t tm, - bool pdsch_use_tbs_index_alt, - const srslte_dci_dl_t* dci, - srslte_pdsch_grant_t* grant); - -SRSLTE_API int -srslte_ra_dl_grant_to_grant_prb_allocation(const srslte_dci_dl_t* dci, srslte_pdsch_grant_t* grant, uint32_t nof_prb); - -/** Functions used by the eNodeB scheduler */ -SRSLTE_API uint32_t srslte_ra_dl_approx_nof_re(const srslte_cell_t* cell, uint32_t nof_prb, uint32_t nof_ctrl_symbols); - -SRSLTE_API uint32_t ra_re_x_prb(const srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf, uint32_t slot, uint32_t prb_idx); - -SRSLTE_API uint32_t srslte_ra_dl_grant_nof_re(const srslte_cell_t* cell, - srslte_dl_sf_cfg_t* sf, - srslte_pdsch_grant_t* grant); - -/** Others */ -SRSLTE_API int srslte_dl_fill_ra_mcs(srslte_ra_tb_t* tb, int last_tbs, uint32_t nprb, bool pdsch_use_tbs_index_alt); - -SRSLTE_API void -srslte_ra_dl_compute_nof_re(const srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf, srslte_pdsch_grant_t* grant); - -SRSLTE_API uint32_t srslte_ra_dl_info(srslte_pdsch_grant_t* grant, char* info_str, uint32_t len); - -#endif // SRSLTE_RA_DL_H diff --git a/lib/include/srslte/phy/phch/ra_ul.h b/lib/include/srslte/phy/phch/ra_ul.h deleted file mode 100644 index ca8de1a20..000000000 --- a/lib/include/srslte/phy/phch/ra_ul.h +++ /dev/null @@ -1,60 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2020 Software Radio Systems Limited - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the distribution. - * - */ - -/****************************************************************************** - * File: ra_ul.h - * - * Description: Implements Resource allocation Procedures for UL defined in Sections 8 - * - * Reference: 3GPP TS 36.213 version 10.0.1 Release 10 - *****************************************************************************/ - -#ifndef SRSLTE_RA_UL_H -#define SRSLTE_RA_UL_H - -#include -#include - -#include "srslte/config.h" -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/phch/dci.h" -#include "srslte/phy/phch/pusch_cfg.h" - -// Structure for PUSCH frequency hopping procedure -typedef struct SRSLTE_API { - bool initialized; - srslte_cell_t cell; - srslte_sequence_t seq_type2_fo; -} srslte_ra_ul_pusch_hopping_t; - -SRSLTE_API int srslte_ra_ul_pusch_hopping_init(srslte_ra_ul_pusch_hopping_t* q, srslte_cell_t cell); - -SRSLTE_API void srslte_ra_ul_pusch_hopping_free(srslte_ra_ul_pusch_hopping_t* q); - -SRSLTE_API void srslte_ra_ul_pusch_hopping(srslte_ra_ul_pusch_hopping_t* q, - srslte_ul_sf_cfg_t* sf, - srslte_pusch_hopping_cfg_t* hopping_cfg, - srslte_pusch_grant_t* grant); - -/** Functions to generate a grant from a received DCI */ -SRSLTE_API int srslte_ra_ul_dci_to_grant(srslte_cell_t* cell, - srslte_ul_sf_cfg_t* sf, - srslte_pusch_hopping_cfg_t* hopping_cfg, - srslte_dci_ul_t* dci, - srslte_pusch_grant_t* grant); - -SRSLTE_API void srslte_ra_ul_compute_nof_re(srslte_pusch_grant_t* grant, srslte_cp_t cp, uint32_t N_srs); - -/** Others */ -SRSLTE_API uint32_t srslte_ra_ul_info(const srslte_pusch_grant_t* grant, char* info_str, uint32_t len); - -#endif // SRSLTE_RA_UL_H diff --git a/lib/include/srslte/phy/phch/sch.h b/lib/include/srslte/phy/phch/sch.h deleted file mode 100644 index c2a647a43..000000000 --- a/lib/include/srslte/phy/phch/sch.h +++ /dev/null @@ -1,133 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2020 Software Radio Systems Limited - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the distribution. - * - */ - -/****************************************************************************** - * File: sch.h - * - * Description: Common UL and DL shared channel encode/decode functions. - * - * Reference: 3GPP TS 36.212 version 10.0.0 Release 10 - *****************************************************************************/ - -#ifndef SRSLTE_SCH_H -#define SRSLTE_SCH_H - -#include "srslte/config.h" -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/fec/crc.h" -#include "srslte/phy/fec/turbo/rm_turbo.h" -#include "srslte/phy/fec/turbo/turbocoder.h" -#include "srslte/phy/fec/turbo/turbodecoder.h" -#include "srslte/phy/phch/pdsch_cfg.h" -#include "srslte/phy/phch/pusch_cfg.h" -#include "srslte/phy/phch/uci.h" - -#ifndef SRSLTE_RX_NULL -#define SRSLTE_RX_NULL 10000 -#endif - -#ifndef SRSLTE_TX_NULL -#define SRSLTE_TX_NULL 100 -#endif - -/* DL-SCH AND UL-SCH common functions */ -typedef struct SRSLTE_API { - - uint32_t max_iterations; - float avg_iterations; - - bool llr_is_8bit; - - /* buffers */ - uint8_t* cb_in; - uint8_t* parity_bits; - void* e; - uint8_t* temp_g_bits; - uint32_t* ul_interleaver; - srslte_uci_bit_t ack_ri_bits[57600]; // 4*M_sc*Qm_max for RI and ACK - - srslte_tcod_t encoder; - srslte_tdec_t decoder; - srslte_crc_t crc_tb; - srslte_crc_t crc_cb; - - srslte_uci_cqi_pusch_t uci_cqi; - -} srslte_sch_t; - -SRSLTE_API int srslte_sch_init(srslte_sch_t* q); - -SRSLTE_API void srslte_sch_free(srslte_sch_t* q); - -SRSLTE_API void srslte_sch_set_max_noi(srslte_sch_t* q, uint32_t max_iterations); - -SRSLTE_API float srslte_sch_last_noi(srslte_sch_t* q); - -SRSLTE_API int srslte_dlsch_encode(srslte_sch_t* q, srslte_pdsch_cfg_t* cfg, uint8_t* data, uint8_t* e_bits); - -SRSLTE_API int srslte_dlsch_encode2(srslte_sch_t* q, - srslte_pdsch_cfg_t* cfg, - uint8_t* data, - uint8_t* e_bits, - int codeword_idx, - uint32_t nof_layers); - -SRSLTE_API int srslte_dlsch_decode(srslte_sch_t* q, srslte_pdsch_cfg_t* cfg, int16_t* e_bits, uint8_t* data); - -SRSLTE_API int srslte_dlsch_decode2(srslte_sch_t* q, - srslte_pdsch_cfg_t* cfg, - int16_t* e_bits, - uint8_t* data, - int codeword_idx, - uint32_t nof_layers); - -SRSLTE_API int srslte_ulsch_encode(srslte_sch_t* q, - srslte_pusch_cfg_t* cfg, - uint8_t* data, - srslte_uci_value_t* uci_data, - uint8_t* g_bits, - uint8_t* q_bits); - -SRSLTE_API int srslte_ulsch_decode(srslte_sch_t* q, - srslte_pusch_cfg_t* cfg, - int16_t* q_bits, - int16_t* g_bits, - uint8_t* c_seq, - uint8_t* data, - srslte_uci_value_t* uci_data); - -SRSLTE_API float srslte_sch_beta_cqi(uint32_t I_cqi); - -SRSLTE_API float srslte_sch_beta_ack(uint32_t I_harq); - -SRSLTE_API uint32_t srslte_sch_find_Ioffset_ack(float beta); - -SRSLTE_API uint32_t srslte_sch_find_Ioffset_cqi(float beta); - -SRSLTE_API uint32_t srslte_sch_find_Ioffset_ri(float beta); - -///< Sidelink uses PUSCH Interleaver in all channels -SRSLTE_API void srslte_sl_ulsch_interleave(uint8_t* g_bits, - uint32_t Qm, - uint32_t H_prime_total, - uint32_t N_pusch_symbs, - uint8_t* q_bits); - -///< Sidelink uses PUSCH Deinterleaver in all channels -SRSLTE_API void srslte_sl_ulsch_deinterleave(int16_t* q_bits, - uint32_t Qm, - uint32_t H_prime_total, - uint32_t N_pusch_symbs, - int16_t* g_bits, - uint32_t* inteleaver_lut); - -#endif // SRSLTE_SCH_H \ No newline at end of file diff --git a/lib/include/srslte/phy/phch/uci_cfg.h b/lib/include/srslte/phy/phch/uci_cfg.h deleted file mode 100644 index a87cd252e..000000000 --- a/lib/include/srslte/phy/phch/uci_cfg.h +++ /dev/null @@ -1,64 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2020 Software Radio Systems Limited - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the distribution. - * - */ - -#ifndef SRSLTE_UCI_CFG_H -#define SRSLTE_UCI_CFG_H - -#include "srslte/phy/phch/cqi.h" - -#define SRSLTE_UCI_MAX_ACK_BITS 10 -#define SRSLTE_UCI_MAX_ACK_SR_BITS (SRSLTE_UCI_MAX_ACK_BITS + 1) -#define SRSLTE_UCI_MAX_M 9 - -typedef struct SRSLTE_API { - uint8_t ack_value[SRSLTE_UCI_MAX_ACK_BITS]; - bool valid; -} srslte_uci_value_ack_t; - -typedef struct SRSLTE_API { - bool pending_tb[SRSLTE_MAX_CODEWORDS]; //< Indicates whether there was a grant that requires an ACK/NACK - uint32_t nof_acks; //< Number of transport blocks, deduced from transmission mode - uint32_t ncce[SRSLTE_UCI_MAX_M]; - uint32_t N_bundle; - uint32_t tdd_ack_M; - uint32_t tdd_ack_m; - bool tdd_is_multiplex; - uint32_t tpc_for_pucch; - uint32_t grant_cc_idx; -} srslte_uci_cfg_ack_t; - -typedef struct SRSLTE_API { - srslte_uci_cfg_ack_t ack[SRSLTE_MAX_CARRIERS]; - srslte_cqi_cfg_t cqi; - bool is_scheduling_request_tti; -} srslte_uci_cfg_t; - -typedef struct SRSLTE_API { - bool scheduling_request; - srslte_cqi_value_t cqi; - srslte_uci_value_ack_t ack; - uint8_t ri; // Only 1-bit supported for RI -} srslte_uci_value_t; - -typedef struct SRSLTE_API { - srslte_uci_cfg_t cfg; - srslte_uci_value_t value; -} srslte_uci_data_t; - -typedef enum { UCI_BIT_0 = 0, UCI_BIT_1 = 1, UCI_BIT_REPETITION = 2, UCI_BIT_PLACEHOLDER = 3 } srslte_uci_bit_type_t; - -typedef struct { - uint32_t position; - srslte_uci_bit_type_t type; -} srslte_uci_bit_t; - -#endif // SRSLTE_UCI_CFG_H diff --git a/lib/include/srslte/phy/scrambling/scrambling.h b/lib/include/srslte/phy/scrambling/scrambling.h deleted file mode 100644 index 0e920e504..000000000 --- a/lib/include/srslte/phy/scrambling/scrambling.h +++ /dev/null @@ -1,49 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2020 Software Radio Systems Limited - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the distribution. - * - */ - -/****************************************************************************** - * File: scrambling.h - * - * Description: Generic scrambling functions used by UL and DL channels. - * - * Reference: 3GPP TS 36.211 version 10.0.0 Release 10 Sec. 5.3.1, 6.3.1 - *****************************************************************************/ - -#ifndef SRSLTE_SCRAMBLING_H -#define SRSLTE_SCRAMBLING_H - -#include "srslte/config.h" -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/common/sequence.h" - -/* Scrambling has no state */ -SRSLTE_API void srslte_scrambling_b(srslte_sequence_t* s, uint8_t* data); - -SRSLTE_API void srslte_scrambling_b_offset(srslte_sequence_t* s, uint8_t* data, int offset, int len); - -SRSLTE_API void srslte_scrambling_bytes(srslte_sequence_t* s, uint8_t* data, int len); - -SRSLTE_API void srslte_scrambling_f(srslte_sequence_t* s, float* data); - -SRSLTE_API void srslte_scrambling_f_offset(srslte_sequence_t* s, float* data, int offset, int len); - -SRSLTE_API void srslte_scrambling_s(srslte_sequence_t* s, short* data); - -SRSLTE_API void srslte_scrambling_s_offset(srslte_sequence_t* s, short* data, int offset, int len); - -SRSLTE_API void srslte_scrambling_sb_offset(srslte_sequence_t* s, int8_t* data, int offset, int len); - -SRSLTE_API void srslte_scrambling_c(srslte_sequence_t* s, cf_t* data); - -SRSLTE_API void srslte_scrambling_c_offset(srslte_sequence_t* s, cf_t* data, int offset, int len); - -#endif // SRSLTE_SCRAMBLING_H diff --git a/lib/include/srslte/phy/sync/cfo.h b/lib/include/srslte/phy/sync/cfo.h deleted file mode 100644 index 37c421a7b..000000000 --- a/lib/include/srslte/phy/sync/cfo.h +++ /dev/null @@ -1,56 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2020 Software Radio Systems Limited - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the distribution. - * - */ - -/****************************************************************************** - * File: cfo.h - * - * Description: Carrier frequency offset correction using complex exponentials. - * - * Reference: - *****************************************************************************/ - -#ifndef SRSLTE_CFO_H -#define SRSLTE_CFO_H - -#include - -#include "srslte/config.h" -#include "srslte/phy/utils/cexptab.h" -#include "srslte/phy/common/phy_common.h" - -#define SRSLTE_CFO_CEXPTAB_SIZE 4096 - -typedef struct SRSLTE_API { - float last_freq; - float tol; - int nsamples; - int max_samples; - srslte_cexptab_t tab; - cf_t* cur_cexp; -} srslte_cfo_t; - -SRSLTE_API int srslte_cfo_init(srslte_cfo_t* h, uint32_t nsamples); - -SRSLTE_API void srslte_cfo_free(srslte_cfo_t* h); - -SRSLTE_API int srslte_cfo_resize(srslte_cfo_t* h, uint32_t samples); - -SRSLTE_API void srslte_cfo_set_tol(srslte_cfo_t* h, float tol); - -SRSLTE_API void srslte_cfo_correct(srslte_cfo_t* h, const cf_t* input, cf_t* output, float freq); - -SRSLTE_API void -srslte_cfo_correct_offset(srslte_cfo_t* h, const cf_t* input, cf_t* output, float freq, int cexp_offset, int nsamples); - -SRSLTE_API float srslte_cfo_est_corr_cp(cf_t* input_buffer, uint32_t nof_prb); - -#endif // SRSLTE_CFO_H diff --git a/lib/include/srslte/phy/sync/cp.h b/lib/include/srslte/phy/sync/cp.h deleted file mode 100644 index d3ef5293f..000000000 --- a/lib/include/srslte/phy/sync/cp.h +++ /dev/null @@ -1,38 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2020 Software Radio Systems Limited - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the distribution. - * - */ - -#ifndef SRSLTE_CP_H -#define SRSLTE_CP_H - -#include -#include - -#include "srslte/config.h" - -typedef struct { - cf_t* corr; - uint32_t symbol_sz; - uint32_t max_symbol_sz; -} srslte_cp_synch_t; - -SRSLTE_API int srslte_cp_synch_init(srslte_cp_synch_t* q, uint32_t symbol_sz); - -SRSLTE_API void srslte_cp_synch_free(srslte_cp_synch_t* q); - -SRSLTE_API int srslte_cp_synch_resize(srslte_cp_synch_t* q, uint32_t symbol_sz); - -SRSLTE_API uint32_t - srslte_cp_synch(srslte_cp_synch_t* q, const cf_t* input, uint32_t max_offset, uint32_t nof_symbols, uint32_t cp_len); - -SRSLTE_API cf_t srslte_cp_synch_corr_output(srslte_cp_synch_t* q, uint32_t offset); - -#endif // SRSLTE_CP_H diff --git a/lib/include/srslte/phy/sync/pss.h b/lib/include/srslte/phy/sync/pss.h deleted file mode 100644 index 97d6d52fb..000000000 --- a/lib/include/srslte/phy/sync/pss.h +++ /dev/null @@ -1,135 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2020 Software Radio Systems Limited - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the distribution. - * - */ - -/****************************************************************************** - * File: pss.h - * - * Description: Primary synchronization signal (PSS) generation and detection. - * - * The srslte_pss_t object provides functions for fast - * computation of the crosscorrelation between the PSS and received - * signal and CFO estimation. Also, the function srslte_pss_tperiodic() - * is designed to be called periodically every subframe, taking - * care of the correct data alignment with respect to the PSS sequence. - * - * The object is designed to work with signals sampled at 1.92 Mhz - * centered at the carrier frequency. Thus, downsampling is required - * if the signal is sampled at higher frequencies. - * - * Reference: 3GPP TS 36.211 version 10.0.0 Release 10 Sec. 6.11.1 - *****************************************************************************/ - -#ifndef SRSLTE_PSS_H -#define SRSLTE_PSS_H - -#include -#include - -#include "srslte/config.h" -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/utils/convolution.h" -#include "srslte/phy/utils/filter.h" - -#define CONVOLUTION_FFT - -#define SRSLTE_PSS_LEN 62 -#define SRSLTE_PSS_RE (6 * 12) - -/* PSS processing options */ - -#define SRSLTE_PSS_ACCUMULATE_ABS // If enabled, accumulates the correlation absolute value on consecutive calls to - // srslte_pss_find_pss - -#define SRSLTE_PSS_RETURN_PSR // If enabled returns peak to side-lobe ratio, otherwise returns absolute peak value - -/* Low-level API */ -typedef struct SRSLTE_API { - -#ifdef CONVOLUTION_FFT - srslte_conv_fft_cc_t conv_fft; - srslte_filt_cc_t filter; - -#endif - int decimate; - - uint32_t max_frame_size; - uint32_t max_fft_size; - - uint32_t frame_size; - uint32_t N_id_2; - uint32_t fft_size; - cf_t* pss_signal_freq_full[3]; - - cf_t* pss_signal_time[3]; - cf_t* pss_signal_time_scale[3]; - - cf_t pss_signal_freq[3][SRSLTE_PSS_LEN]; // One sequence for each N_id_2 - cf_t* tmp_input; - cf_t* conv_output; - float* conv_output_abs; - float ema_alpha; - float* conv_output_avg; - float peak_value; - - bool filter_pss_enable; - srslte_dft_plan_t dftp_input; - srslte_dft_plan_t idftp_input; - cf_t tmp_fft[SRSLTE_SYMBOL_SZ_MAX]; - cf_t tmp_fft2[SRSLTE_SYMBOL_SZ_MAX]; - - cf_t tmp_ce[SRSLTE_PSS_LEN]; - - bool chest_on_filter; - -} srslte_pss_t; - -typedef enum { PSS_TX, PSS_RX } pss_direction_t; - -/* Basic functionality */ -SRSLTE_API int srslte_pss_init_fft(srslte_pss_t* q, uint32_t frame_size, uint32_t fft_size); - -SRSLTE_API int srslte_pss_init_fft_offset(srslte_pss_t* q, uint32_t frame_size, uint32_t fft_size, int cfo_i); - -SRSLTE_API int -srslte_pss_init_fft_offset_decim(srslte_pss_t* q, uint32_t frame_size, uint32_t fft_size, int cfo_i, int decimate); - -SRSLTE_API int srslte_pss_resize(srslte_pss_t* q, uint32_t frame_size, uint32_t fft_size, int offset); - -SRSLTE_API int srslte_pss_init(srslte_pss_t* q, uint32_t frame_size); - -SRSLTE_API void srslte_pss_free(srslte_pss_t* q); - -SRSLTE_API void srslte_pss_reset(srslte_pss_t* q); - -SRSLTE_API void srslte_pss_filter_enable(srslte_pss_t* q, bool enable); - -SRSLTE_API void srslte_pss_sic(srslte_pss_t* q, cf_t* input); - -SRSLTE_API void srslte_pss_filter(srslte_pss_t* q, const cf_t* input, cf_t* output); - -SRSLTE_API int srslte_pss_generate(cf_t* signal, uint32_t N_id_2); - -SRSLTE_API void srslte_pss_get_slot(cf_t* slot, cf_t* pss_signal, uint32_t nof_prb, srslte_cp_t cp); - -SRSLTE_API void srslte_pss_put_slot(cf_t* pss_signal, cf_t* slot, uint32_t nof_prb, srslte_cp_t cp); - -SRSLTE_API void srslte_pss_set_ema_alpha(srslte_pss_t* q, float alpha); - -SRSLTE_API int srslte_pss_set_N_id_2(srslte_pss_t* q, uint32_t N_id_2); - -SRSLTE_API int srslte_pss_find_pss(srslte_pss_t* q, const cf_t* input, float* corr_peak_value); - -SRSLTE_API int srslte_pss_chest(srslte_pss_t* q, const cf_t* input, cf_t ce[SRSLTE_PSS_LEN]); - -SRSLTE_API float srslte_pss_cfo_compute(srslte_pss_t* q, const cf_t* pss_recv); - -#endif // SRSLTE_PSS_H diff --git a/lib/include/srslte/phy/sync/sss.h b/lib/include/srslte/phy/sync/sss.h deleted file mode 100644 index 56b27c83d..000000000 --- a/lib/include/srslte/phy/sync/sss.h +++ /dev/null @@ -1,119 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2020 Software Radio Systems Limited - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the distribution. - * - */ - -/****************************************************************************** - * File: sss.h - * - * Description: Secondary synchronization signal (SSS) generation and detection. - * - * - * Reference: 3GPP TS 36.211 version 10.0.0 Release 10 Sec. 6.11.2 - *****************************************************************************/ - -#ifndef SRSLTE_SSS_H -#define SRSLTE_SSS_H - -#include -#include - -#include "srslte/config.h" -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/dft/dft.h" - -#define SRSLTE_SSS_N 31 -#define SRSLTE_SSS_LEN 2 * SRSLTE_SSS_N - -typedef struct SRSLTE_API { - int z1[SRSLTE_SSS_N][SRSLTE_SSS_N]; - int c[2][SRSLTE_SSS_N]; - int s[SRSLTE_SSS_N][SRSLTE_SSS_N]; -} srslte_sss_tables_t; - -/* Allocate 32 complex to make it multiple of 32-byte AVX instructions alignment requirement. - * Should use srslte_vec_malloc() to make it platform agnostic. - */ -typedef struct SRSLTE_API { - float z1[SRSLTE_SSS_N][SRSLTE_SSS_N]; - float c[2][SRSLTE_SSS_N]; - float s[SRSLTE_SSS_N][SRSLTE_SSS_N]; - float sd[SRSLTE_SSS_N][SRSLTE_SSS_N - 1]; -} srslte_sss_fc_tables_t; - -/* Low-level API */ -typedef struct SRSLTE_API { - - srslte_dft_plan_t dftp_input; - - uint32_t fft_size; - uint32_t max_fft_size; - - float corr_peak_threshold; - uint32_t symbol_sz; - uint32_t subframe_sz; - uint32_t N_id_2; - - uint32_t N_id_1_table[30][30]; - srslte_sss_fc_tables_t fc_tables[3]; // one for each N_id_2 - - float corr_output_m0[SRSLTE_SSS_N]; - float corr_output_m1[SRSLTE_SSS_N]; - -} srslte_sss_t; - -/* Basic functionality */ -SRSLTE_API int srslte_sss_init(srslte_sss_t* q, uint32_t fft_size); - -SRSLTE_API int srslte_sss_resize(srslte_sss_t* q, uint32_t fft_size); - -SRSLTE_API void srslte_sss_free(srslte_sss_t* q); - -SRSLTE_API void srslte_sss_generate(float* signal0, float* signal5, uint32_t cell_id); - -SRSLTE_API void srslte_sss_put_slot(float* sss, cf_t* symbol, uint32_t nof_prb, srslte_cp_t cp); - -SRSLTE_API void srslte_sss_put_symbol(float* sss, cf_t* symbol, uint32_t nof_prb); - -SRSLTE_API int srslte_sss_set_N_id_2(srslte_sss_t* q, uint32_t N_id_2); - -SRSLTE_API int srslte_sss_m0m1_partial(srslte_sss_t* q, - const cf_t* input, - uint32_t M, - cf_t ce[2 * SRSLTE_SSS_N], - uint32_t* m0, - float* m0_value, - uint32_t* m1, - float* m1_value); - -SRSLTE_API int srslte_sss_m0m1_diff_coh(srslte_sss_t* q, - const cf_t* input, - cf_t ce[2 * SRSLTE_SSS_N], - uint32_t* m0, - float* m0_value, - uint32_t* m1, - float* m1_value); - -SRSLTE_API int -srslte_sss_m0m1_diff(srslte_sss_t* q, const cf_t* input, uint32_t* m0, float* m0_value, uint32_t* m1, float* m1_value); - -SRSLTE_API uint32_t srslte_sss_subframe(uint32_t m0, uint32_t m1); - -SRSLTE_API int srslte_sss_N_id_1(srslte_sss_t* q, uint32_t m0, uint32_t m1, float corr); - -SRSLTE_API int srslte_sss_frame(srslte_sss_t* q, cf_t* input, uint32_t* subframe_idx, uint32_t* N_id_1); - -SRSLTE_API void srslte_sss_set_threshold(srslte_sss_t* q, float threshold); - -SRSLTE_API void srslte_sss_set_symbol_sz(srslte_sss_t* q, uint32_t symbol_sz); - -SRSLTE_API void srslte_sss_set_subframe_sz(srslte_sss_t* q, uint32_t subframe_sz); - -#endif // SRSLTE_SSS_H diff --git a/lib/include/srslte/phy/sync/ssss.h b/lib/include/srslte/phy/sync/ssss.h deleted file mode 100644 index 91b3686a8..000000000 --- a/lib/include/srslte/phy/sync/ssss.h +++ /dev/null @@ -1,71 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2020 Software Radio Systems Limited - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the distribution. - * - */ - -/****************************************************************************** - * File: ssss.h - * - * Description: Secondary sidelink synchronization signal (SSSS) generation and detection. - * - * - * Reference: 3GPP TS 36.211 version 15.6.0 Release 15 Sec. 9.7.2 - *****************************************************************************/ - -#ifndef SRSLTE_SSSS_H -#define SRSLTE_SSSS_H - -#include -#include - -#include "srslte/phy/common/phy_common_sl.h" -#include "srslte/phy/dft/dft.h" - -#define SRSLTE_SSSS_NOF_SEQ 336 -#define SRSLTE_SSSS_N 31 -#define SRSLTE_SSSS_LEN 2 * SRSLTE_SSSS_N - -typedef struct SRSLTE_API { - - float ssss_signal[SRSLTE_SSSS_NOF_SEQ][SRSLTE_SSSS_LEN]; // One sequence for each N_sl_id - - cf_t** ssss_sf_freq; - - cf_t* input_pad_freq; - cf_t* input_pad_time; - - cf_t* dot_prod_output; - cf_t* dot_prod_output_time; - - cf_t* shifted_output; - - float* shifted_output_abs; - - int32_t corr_peak_pos; - float corr_peak_value; - - uint32_t N_sl_id; - - srslte_dft_plan_t plan_input; - srslte_dft_plan_t plan_out; - -} srslte_ssss_t; - -SRSLTE_API int srslte_ssss_init(srslte_ssss_t* q, uint32_t nof_prb, srslte_cp_t cp, srslte_sl_tm_t tm); - -SRSLTE_API void srslte_ssss_generate(float* ssss_signal, uint32_t N_sl_id, srslte_sl_tm_t tm); - -SRSLTE_API void srslte_ssss_put_sf_buffer(float* ssss_signal, cf_t* sf_buffer, uint32_t nof_prb, srslte_cp_t cp); - -SRSLTE_API int srslte_ssss_find(srslte_ssss_t* q, cf_t* input, uint32_t nof_prb, uint32_t N_id_2, srslte_cp_t cp); - -SRSLTE_API void srslte_ssss_free(srslte_ssss_t* q); - -#endif \ No newline at end of file diff --git a/lib/include/srslte/phy/ue/ue_cell_search.h b/lib/include/srslte/phy/ue/ue_cell_search.h deleted file mode 100644 index 5011c15ae..000000000 --- a/lib/include/srslte/phy/ue/ue_cell_search.h +++ /dev/null @@ -1,102 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2020 Software Radio Systems Limited - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the distribution. - * - */ - -/****************************************************************************** - * File: ue_cell_search.h - * - * Description: Wrapper for the ue_sync object. - * - * This object is a wrapper to the ue_sync object. It receives - * several synchronized frames and obtains the most common cell_id - * and cp length. - * - * The I/O stream device sampling frequency must be set to 1.92 MHz - * (SRSLTE_CS_SAMP_FREQ constant) before calling to - * srslte_ue_cellsearch_scan() functions. - * - * Reference: - *****************************************************************************/ - -#ifndef SRSLTE_UE_CELL_SEARCH_H -#define SRSLTE_UE_CELL_SEARCH_H - -#include - -#include "srslte/config.h" -#include "srslte/phy/ue/ue_sync.h" -#include "srslte/phy/ue/ue_mib.h" -#include "srslte/phy/sync/cfo.h" -#include "srslte/phy/ch_estimation/chest_dl.h" -#include "srslte/phy/phch/pbch.h" -#include "srslte/phy/dft/ofdm.h" - -#define SRSLTE_CS_NOF_PRB 6 -#define SRSLTE_CS_SAMP_FREQ 1920000.0 - -typedef struct SRSLTE_API { - uint32_t cell_id; - srslte_cp_t cp; - srslte_frame_type_t frame_type; - float peak; - float mode; - float psr; - float cfo; -} srslte_ue_cellsearch_result_t; - - -typedef struct SRSLTE_API { - srslte_ue_sync_t ue_sync; - - cf_t* sf_buffer[SRSLTE_MAX_CHANNELS]; - uint32_t nof_rx_antennas; - - uint32_t max_frames; - uint32_t nof_valid_frames; // number of 5 ms frames to scan - - uint32_t *mode_ntimes; - uint8_t *mode_counted; - - srslte_ue_cellsearch_result_t *candidates; -} srslte_ue_cellsearch_t; - -SRSLTE_API int srslte_ue_cellsearch_init(srslte_ue_cellsearch_t *q, - uint32_t max_frames_total, - int (recv_callback)(void*, void*, uint32_t,srslte_timestamp_t*), - void *stream_handler); - -SRSLTE_API int -srslte_ue_cellsearch_init_multi(srslte_ue_cellsearch_t* q, - uint32_t max_frames_total, - int(recv_callback)(void*, cf_t* [SRSLTE_MAX_CHANNELS], uint32_t, srslte_timestamp_t*), - uint32_t nof_rx_antennas, - void* stream_handler); - -SRSLTE_API void srslte_ue_cellsearch_free(srslte_ue_cellsearch_t *q); - -SRSLTE_API int srslte_ue_cellsearch_scan_N_id_2(srslte_ue_cellsearch_t *q, - uint32_t N_id_2, - srslte_ue_cellsearch_result_t *found_cell); - -SRSLTE_API int srslte_ue_cellsearch_scan(srslte_ue_cellsearch_t * q, - srslte_ue_cellsearch_result_t found_cells[3], - uint32_t *max_N_id_2); - -SRSLTE_API int srslte_ue_cellsearch_set_nof_valid_frames(srslte_ue_cellsearch_t *q, - uint32_t nof_frames); - - - - - - -#endif // SRSLTE_UE_CELL_SEARCH_H - diff --git a/lib/include/srslte/phy/ue/ue_cell_search_nbiot.h b/lib/include/srslte/phy/ue/ue_cell_search_nbiot.h deleted file mode 100644 index 5e26b5d70..000000000 --- a/lib/include/srslte/phy/ue/ue_cell_search_nbiot.h +++ /dev/null @@ -1,72 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2020 Software Radio Systems Limited - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the distribution. - * - */ - -#ifndef SRSLTE_UE_CELL_SEARCH_NBIOT_H -#define SRSLTE_UE_CELL_SEARCH_NBIOT_H - -#include "srslte/config.h" -#include "srslte/phy/ch_estimation/chest_dl_nbiot.h" -#include "srslte/phy/dft/ofdm.h" -#include "srslte/phy/phch/npbch.h" -#include "srslte/phy/sync/cfo.h" -#include "srslte/phy/ue/ue_mib_nbiot.h" -#include "srslte/phy/ue/ue_sync_nbiot.h" - -#define SRSLTE_CS_NOF_PRB 6 -#define SRSLTE_CS_SAMP_FREQ 1920000.0 - -typedef struct SRSLTE_API { - uint32_t n_id_ncell; - float peak; - float mode; - float psr; - float cfo; -} srslte_nbiot_ue_cellsearch_result_t; - -/** - * \brief Wrapper for the nbiot_ue_sync object. - * - * This object is a wrapper to the nbiot_ue_sync object. It receives - * several synchronized frames and obtains the most common n_id_ncell. - * - * The I/O stream device sampling frequency must be set to 1.92 MHz - * (SRSLTE_CS_SAMP_FREQ constant) before calling to - * srslte_ue_cellsearch_nbiot_scan() functions. - */ -typedef struct SRSLTE_API { - srslte_nbiot_ue_sync_t ue_sync; - int32_t sf_len; - - cf_t* rx_buffer[SRSLTE_MAX_CHANNELS]; - cf_t* nsss_buffer; - int nsss_sf_counter; - - uint32_t max_frames; - uint32_t nof_valid_frames; // number of frames to scan -} srslte_ue_cellsearch_nbiot_t; - -SRSLTE_API int -srslte_ue_cellsearch_nbiot_init(srslte_ue_cellsearch_nbiot_t* q, - uint32_t max_frames_total, - int(recv_callback)(void*, cf_t* [SRSLTE_MAX_CHANNELS], uint32_t, srslte_timestamp_t*), - void* stream_handler); - -SRSLTE_API void srslte_ue_cellsearch_nbiot_free(srslte_ue_cellsearch_nbiot_t* q); - -SRSLTE_API int srslte_ue_cellsearch_nbiot_scan(srslte_ue_cellsearch_nbiot_t* q); - -SRSLTE_API int srslte_ue_cellsearch_nbiot_detect(srslte_ue_cellsearch_nbiot_t* q, - srslte_nbiot_ue_cellsearch_result_t* found_cells); - -SRSLTE_API int srslte_ue_cellsearch_nbiot_set_nof_valid_frames(srslte_ue_cellsearch_nbiot_t* q, uint32_t nof_frames); - -#endif // SRSLTE_UE_CELL_SEARCH_NBIOT_H diff --git a/lib/include/srslte/phy/ue/ue_dl.h b/lib/include/srslte/phy/ue/ue_dl.h deleted file mode 100644 index 11828fe09..000000000 --- a/lib/include/srslte/phy/ue/ue_dl.h +++ /dev/null @@ -1,238 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2020 Software Radio Systems Limited - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the distribution. - * - */ - -/****************************************************************************** - * File: ue_dl.h - * - * Description: UE downlink object. - * - * This module is a frontend to all the downlink data and control - * channel processing modules. - * - * Reference: - *****************************************************************************/ - -#ifndef SRSLTE_UE_DL_H -#define SRSLTE_UE_DL_H - -#include - -#include "srslte/phy/ch_estimation/chest_dl.h" -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/dft/ofdm.h" - -#include "srslte/phy/phch/dci.h" -#include "srslte/phy/phch/pcfich.h" -#include "srslte/phy/phch/pdcch.h" -#include "srslte/phy/phch/pdsch.h" -#include "srslte/phy/phch/pdsch_cfg.h" -#include "srslte/phy/phch/phich.h" -#include "srslte/phy/phch/pmch.h" -#include "srslte/phy/phch/ra.h" -#include "srslte/phy/phch/regs.h" - -#include "srslte/phy/sync/cfo.h" - -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" - -#include "srslte/config.h" - -#define SRSLTE_MAX_CANDIDATES_UE 16 // From 36.213 Table 9.1.1-1 -#define SRSLTE_MAX_CANDIDATES_COM 6 // From 36.213 Table 9.1.1-1 -#define SRSLTE_MAX_CANDIDATES (SRSLTE_MAX_CANDIDATES_UE + SRSLTE_MAX_CANDIDATES_COM) - -#define SRSLTE_MAX_FORMATS 4 - -#define SRSLTE_MI_NOF_REGS ((q->cell.frame_type == SRSLTE_FDD) ? 1 : 6) -#define SRSLTE_MI_MAX_REGS 6 - -#define SRSLTE_MAX_DCI_MSG SRSLTE_MAX_CARRIERS - -typedef struct SRSLTE_API { - srslte_dci_format_t formats[SRSLTE_MAX_FORMATS]; - srslte_dci_location_t loc[SRSLTE_MAX_CANDIDATES]; - uint32_t nof_locations; - uint32_t nof_formats; -} dci_blind_search_t; - -typedef struct SRSLTE_API { - // Cell configuration - srslte_cell_t cell; - uint32_t nof_rx_antennas; - uint16_t current_mbsfn_area_id; - - // Objects for all DL Physical Channels - srslte_pcfich_t pcfich; - srslte_pdcch_t pdcch; - srslte_pdsch_t pdsch; - srslte_pmch_t pmch; - srslte_phich_t phich; - - // Control region - srslte_regs_t regs[SRSLTE_MI_MAX_REGS]; - uint32_t mi_manual_index; - bool mi_auto; - - // Channel estimation and OFDM demodulation - srslte_chest_dl_t chest; - srslte_chest_dl_res_t chest_res; - srslte_ofdm_t fft[SRSLTE_MAX_PORTS]; - srslte_ofdm_t fft_mbsfn; - - // Buffers to store channel symbols after demodulation - cf_t* sf_symbols[SRSLTE_MAX_PORTS]; - dci_blind_search_t current_ss_common; - - srslte_dci_msg_t pending_ul_dci_msg[SRSLTE_MAX_DCI_MSG]; - uint32_t pending_ul_dci_count; - - srslte_dci_location_t allocated_locations[SRSLTE_MAX_DCI_MSG]; - uint32_t nof_allocated_locations; -} srslte_ue_dl_t; - -// Downlink config (includes common and dedicated variables) -typedef struct SRSLTE_API { - srslte_cqi_report_cfg_t cqi_report; - srslte_pdsch_cfg_t pdsch; - srslte_dci_cfg_t dci; - srslte_tm_t tm; - bool dci_common_ss; -} srslte_dl_cfg_t; - -typedef struct SRSLTE_API { - srslte_dl_cfg_t cfg; - srslte_chest_dl_cfg_t chest_cfg; - uint32_t last_ri; - float snr_to_cqi_offset; -} srslte_ue_dl_cfg_t; - -typedef struct { - uint32_t v_dai_dl; - uint32_t n_cce; - uint32_t grant_cc_idx; - uint32_t tpc_for_pucch; -} srslte_pdsch_ack_resource_t; - -typedef struct { - srslte_pdsch_ack_resource_t resource; - uint32_t k; - uint8_t value[SRSLTE_MAX_CODEWORDS]; // 0/1 or 2 for DTX - bool present; -} srslte_pdsch_ack_m_t; - -typedef struct { - uint32_t M; - srslte_pdsch_ack_m_t m[SRSLTE_UCI_MAX_M]; -} srslte_pdsch_ack_cc_t; - -typedef struct { - srslte_pdsch_ack_cc_t cc[SRSLTE_MAX_CARRIERS]; - uint32_t nof_cc; - uint32_t V_dai_ul; - srslte_tm_t transmission_mode; - srslte_ack_nack_feedback_mode_t ack_nack_feedback_mode; - bool is_grant_available; - bool is_pusch_available; - bool tdd_ack_multiplex; - bool simul_cqi_ack; - bool simul_cqi_ack_pucch3; -} srslte_pdsch_ack_t; - -SRSLTE_API int -srslte_ue_dl_init(srslte_ue_dl_t* q, cf_t* input[SRSLTE_MAX_PORTS], uint32_t max_prb, uint32_t nof_rx_antennas); - -SRSLTE_API void srslte_ue_dl_free(srslte_ue_dl_t* q); - -SRSLTE_API int srslte_ue_dl_set_cell(srslte_ue_dl_t* q, srslte_cell_t cell); - -SRSLTE_API int srslte_ue_dl_set_mbsfn_area_id(srslte_ue_dl_t* q, uint16_t mbsfn_area_id); - -SRSLTE_API void srslte_ue_dl_set_non_mbsfn_region(srslte_ue_dl_t* q, uint8_t non_mbsfn_region_length); - -SRSLTE_API void srslte_ue_dl_set_mi_manual(srslte_ue_dl_t* q, uint32_t mi_idx); - -SRSLTE_API void srslte_ue_dl_set_mi_auto(srslte_ue_dl_t* q); - -/* Perform signal demodulation and channel estimation and store signals in the object */ -SRSLTE_API int srslte_ue_dl_decode_fft_estimate(srslte_ue_dl_t* q, srslte_dl_sf_cfg_t* sf, srslte_ue_dl_cfg_t* cfg); - -SRSLTE_API int srslte_ue_dl_decode_fft_estimate_noguru(srslte_ue_dl_t* q, - srslte_dl_sf_cfg_t* sf, - srslte_ue_dl_cfg_t* cfg, - cf_t* input[SRSLTE_MAX_PORTS]); - -/* Finds UL/DL DCI in the signal processed in a previous call to decode_fft_estimate() */ -SRSLTE_API int srslte_ue_dl_find_ul_dci(srslte_ue_dl_t* q, - srslte_dl_sf_cfg_t* sf, - srslte_ue_dl_cfg_t* dl_cfg, - uint16_t rnti, - srslte_dci_ul_t dci_msg[SRSLTE_MAX_DCI_MSG]); - -SRSLTE_API int srslte_ue_dl_find_dl_dci(srslte_ue_dl_t* q, - srslte_dl_sf_cfg_t* sf, - srslte_ue_dl_cfg_t* dl_cfg, - uint16_t rnti, - srslte_dci_dl_t dci_msg[SRSLTE_MAX_DCI_MSG]); - -SRSLTE_API int srslte_ue_dl_dci_to_pdsch_grant(srslte_ue_dl_t* q, - srslte_dl_sf_cfg_t* sf, - srslte_ue_dl_cfg_t* cfg, - srslte_dci_dl_t* dci, - srslte_pdsch_grant_t* grant); - -/* Decodes PDSCH and PHICH in the signal processed in a previous call to decode_fft_estimate() */ -SRSLTE_API int srslte_ue_dl_decode_pdsch(srslte_ue_dl_t* q, - srslte_dl_sf_cfg_t* sf, - srslte_pdsch_cfg_t* pdsch_cfg, - srslte_pdsch_res_t data[SRSLTE_MAX_CODEWORDS]); - -SRSLTE_API int srslte_ue_dl_decode_pmch(srslte_ue_dl_t* q, - srslte_dl_sf_cfg_t* sf, - srslte_pmch_cfg_t* pmch_cfg, - srslte_pdsch_res_t* data); - -SRSLTE_API int srslte_ue_dl_decode_phich(srslte_ue_dl_t* q, - srslte_dl_sf_cfg_t* sf, - srslte_ue_dl_cfg_t* cfg, - srslte_phich_grant_t* grant, - srslte_phich_res_t* result); - -SRSLTE_API int srslte_ue_dl_select_ri(srslte_ue_dl_t* q, uint32_t* ri, float* cn); - -SRSLTE_API void srslte_ue_dl_gen_cqi_periodic(srslte_ue_dl_t* q, - srslte_ue_dl_cfg_t* cfg, - uint32_t wideband_value, - uint32_t tti, - srslte_uci_data_t* uci_data); - -SRSLTE_API void srslte_ue_dl_gen_cqi_aperiodic(srslte_ue_dl_t* q, - srslte_ue_dl_cfg_t* cfg, - uint32_t wideband_value, - srslte_uci_data_t* uci_data); - -SRSLTE_API void srslte_ue_dl_gen_ack(const srslte_cell_t* cell, - const srslte_dl_sf_cfg_t* sf, - const srslte_pdsch_ack_t* ack_info, - srslte_uci_data_t* uci_data); - -/* Functions used for testing purposes */ -SRSLTE_API int srslte_ue_dl_find_and_decode(srslte_ue_dl_t* q, - srslte_dl_sf_cfg_t* sf, - srslte_ue_dl_cfg_t* cfg, - srslte_pdsch_cfg_t* pdsch_cfg, - uint8_t* data[SRSLTE_MAX_CODEWORDS], - bool acks[SRSLTE_MAX_CODEWORDS]); - -SRSLTE_API void srslte_ue_dl_save_signal(srslte_ue_dl_t* q, srslte_dl_sf_cfg_t* sf, srslte_pdsch_cfg_t* pdsch_cfg); - -#endif // SRSLTE_UE_DL_H diff --git a/lib/include/srslte/phy/ue/ue_dl_nbiot.h b/lib/include/srslte/phy/ue/ue_dl_nbiot.h deleted file mode 100644 index 21ecba8d5..000000000 --- a/lib/include/srslte/phy/ue/ue_dl_nbiot.h +++ /dev/null @@ -1,182 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2020 Software Radio Systems Limited - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the distribution. - * - */ - -#ifndef SRSLTE_UE_DL_NBIOT_H -#define SRSLTE_UE_DL_NBIOT_H - -#include - -#include "srslte/phy/ch_estimation/chest_dl_nbiot.h" -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/dft/ofdm.h" - -#include "srslte/phy/phch/dci_nbiot.h" -#include "srslte/phy/phch/npdcch.h" -#include "srslte/phy/phch/npdsch.h" -#include "srslte/phy/phch/npdsch_cfg.h" -#include "srslte/phy/phch/ra_nbiot.h" - -#include "srslte/phy/sync/cfo.h" - -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" - -#include "srslte/config.h" - -#define SRSLTE_NBIOT_EXPECT_MORE_SF -3 // returned when expecting more subframes for successful decoding -#define SRSLTE_NBIOT_UE_DL_FOUND_DCI -4 // returned when DCI for given RNTI was found -#define SRSLTE_NBIOT_UE_DL_SKIP_SF -5 - -/* - * @brief Narrowband UE downlink object. - * - * This module is a frontend to all the downlink data and control - * channel processing modules. - */ -typedef struct SRSLTE_API { - srslte_npdcch_t npdcch; - srslte_npdsch_t npdsch; - srslte_ofdm_t fft; - srslte_chest_dl_nbiot_t chest; - - srslte_cfo_t sfo_correct; - - srslte_softbuffer_rx_t softbuffer; - srslte_nbiot_cell_t cell; - srslte_mib_nb_t mib; - bool mib_set; - - int nof_re; // Number of RE per subframe - cf_t* sf_symbols; // this buffer holds the symbols of the current subframe - cf_t* sf_buffer; // this buffer holds multiple subframes - cf_t* ce[SRSLTE_MAX_PORTS]; - cf_t* ce_buffer[SRSLTE_MAX_PORTS]; - float* llr; // Buffer to hold soft-bits for later combining repetitions - - uint32_t pkt_errors; - uint32_t pkts_total; - uint32_t pkts_ok; - uint32_t nof_detected; - uint32_t bits_total; - - // DL configuration for "normal" transmissions - bool has_dl_grant; - srslte_npdsch_cfg_t npdsch_cfg; - - // DL configuration for SIB1 transmissions - uint32_t sib1_sfn[4 * SIB1_NB_MAX_REP]; // there are 4 SIB1 TTIs in each hyper frame - srslte_nbiot_si_params_t si_params[SRSLTE_NBIOT_SI_TYPE_NITEMS]; - bool si_tti[10240]; // We trade memory consumption for speed - - uint16_t current_rnti; - uint32_t last_n_cce; - srslte_dci_location_t last_location; - - float sample_offset; -} srslte_nbiot_ue_dl_t; - -// This function shall be called just after the initial synchronization -SRSLTE_API int srslte_nbiot_ue_dl_init(srslte_nbiot_ue_dl_t* q, - cf_t* in_buffer[SRSLTE_MAX_PORTS], - uint32_t max_prb, - uint32_t nof_rx_antennas); - -SRSLTE_API void srslte_nbiot_ue_dl_free(srslte_nbiot_ue_dl_t* q); - -SRSLTE_API int srslte_nbiot_ue_dl_set_cell(srslte_nbiot_ue_dl_t* q, srslte_nbiot_cell_t cell); - -SRSLTE_API int srslte_nbiot_ue_dl_decode_fft_estimate(srslte_nbiot_ue_dl_t* q, uint32_t sf_idx, bool is_dl_sf); - -SRSLTE_API int srslte_nbiot_ue_dl_decode_estimate(srslte_nbiot_ue_dl_t* q, uint32_t sf_idx); - -SRSLTE_API int -srslte_nbiot_ue_dl_cfg_grant(srslte_nbiot_ue_dl_t* q, srslte_ra_nbiot_dl_grant_t* grant, uint32_t sf_idx); - -SRSLTE_API int -srslte_nbiot_ue_dl_find_dl_dci(srslte_nbiot_ue_dl_t* q, uint32_t sf_idx, uint16_t rnti, srslte_dci_msg_t* dci_msg); - -int srslte_nbiot_ue_dl_find_dl_dci_type_siprarnti(srslte_nbiot_ue_dl_t* q, uint16_t rnti, srslte_dci_msg_t* dci_msg); - -int srslte_nbiot_ue_dl_find_dl_dci_type_crnti(srslte_nbiot_ue_dl_t* q, - uint32_t sf_idx, - uint16_t rnti, - srslte_dci_msg_t* dci_msg); - -SRSLTE_API int -srslte_nbiot_ue_dl_find_ul_dci(srslte_nbiot_ue_dl_t* q, uint32_t tti, uint32_t rnti, srslte_dci_msg_t* dci_msg); - -SRSLTE_API uint32_t srslte_nbiot_ue_dl_get_ncce(srslte_nbiot_ue_dl_t* q); - -SRSLTE_API void srslte_nbiot_ue_dl_set_sample_offset(srslte_nbiot_ue_dl_t* q, float sample_offset); - -SRSLTE_API int -srslte_nbiot_ue_dl_decode(srslte_nbiot_ue_dl_t* q, cf_t* input, uint8_t* data, uint32_t sfn, uint32_t sf_idx); - -SRSLTE_API int srslte_nbiot_ue_dl_decode_npdcch(srslte_nbiot_ue_dl_t* q, - cf_t* input, - uint32_t sfn, - uint32_t sf_idx, - uint16_t rnti, - srslte_dci_msg_t* dci_msg); - -SRSLTE_API int srslte_nbiot_ue_dl_decode_npdsch(srslte_nbiot_ue_dl_t* q, - cf_t* input, - uint8_t* data, - uint32_t sfn, - uint32_t sf_idx, - uint16_t rnti); - -int srslte_nbiot_ue_dl_decode_npdsch_bcch(srslte_nbiot_ue_dl_t* q, uint8_t* data, uint32_t tti); - -int srslte_nbiot_ue_dl_decode_npdsch_no_bcch(srslte_nbiot_ue_dl_t* q, uint8_t* data, uint32_t tti, uint16_t rnti); - -void srslte_nbiot_ue_dl_tb_decoded(srslte_nbiot_ue_dl_t* q, uint8_t* data); - -SRSLTE_API void srslte_nbiot_ue_dl_reset(srslte_nbiot_ue_dl_t* q); - -SRSLTE_API void srslte_nbiot_ue_dl_set_rnti(srslte_nbiot_ue_dl_t* q, uint16_t rnti); - -SRSLTE_API void srslte_nbiot_ue_dl_set_mib(srslte_nbiot_ue_dl_t* q, srslte_mib_nb_t mib); - -SRSLTE_API void srslte_nbiot_ue_dl_decode_sib1(srslte_nbiot_ue_dl_t* q, uint32_t current_sfn); - -SRSLTE_API void -srslte_nbiot_ue_dl_get_sib1_grant(srslte_nbiot_ue_dl_t* q, uint32_t sfn, srslte_ra_nbiot_dl_grant_t* grant); - -SRSLTE_API void srslte_nbiot_ue_dl_decode_sib(srslte_nbiot_ue_dl_t* q, - uint32_t hfn, - uint32_t sfn, - srslte_nbiot_si_type_t type, - srslte_nbiot_si_params_t params); - -SRSLTE_API void srslte_nbiot_ue_dl_get_next_si_sfn(uint32_t current_hfn, - uint32_t current_sfn, - srslte_nbiot_si_params_t params, - uint32_t* si_hfn, - uint32_t* si_sfn); - -SRSLTE_API void -srslte_nbiot_ue_dl_set_si_params(srslte_nbiot_ue_dl_t* q, srslte_nbiot_si_type_t type, srslte_nbiot_si_params_t params); - -SRSLTE_API bool srslte_nbiot_ue_dl_is_sib1_sf(srslte_nbiot_ue_dl_t* q, uint32_t sfn, uint32_t sf_idx); - -SRSLTE_API void srslte_nbiot_ue_dl_set_grant(srslte_nbiot_ue_dl_t* q, srslte_ra_nbiot_dl_grant_t* grant); - -SRSLTE_API void srslte_nbiot_ue_dl_flush_grant(srslte_nbiot_ue_dl_t* q); - -SRSLTE_API bool srslte_nbiot_ue_dl_has_grant(srslte_nbiot_ue_dl_t* q); - -SRSLTE_API void srslte_nbiot_ue_dl_check_grant(srslte_nbiot_ue_dl_t* q, srslte_ra_nbiot_dl_grant_t* grant); - -SRSLTE_API void srslte_nbiot_ue_dl_save_signal(srslte_nbiot_ue_dl_t* q, cf_t* input, uint32_t tti, uint32_t sf_idx); - -#endif // SRSLTE_UE_DL_NBIOT_H diff --git a/lib/include/srslte/phy/ue/ue_dl_nr.h b/lib/include/srslte/phy/ue/ue_dl_nr.h deleted file mode 100644 index f56a66a46..000000000 --- a/lib/include/srslte/phy/ue/ue_dl_nr.h +++ /dev/null @@ -1,189 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2020 Software Radio Systems Limited - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the distribution. - * - */ - -#ifndef SRSLTE_UE_DL_NR_H -#define SRSLTE_UE_DL_NR_H - -#include "srslte/phy/ch_estimation/dmrs_pdcch.h" -#include "srslte/phy/common/phy_common_nr.h" -#include "srslte/phy/dft/ofdm.h" -#include "srslte/phy/phch/dci_nr.h" -#include "srslte/phy/phch/pdcch_nr.h" -#include "srslte/phy/phch/pdsch_nr.h" -#include "srslte/phy/phch/uci_cfg_nr.h" - -/** - * Maximum number of CORESET - * @remark Defined in TS 38.331 by maxNrofControlResourceSets-1 - */ -#define SRSLTE_UE_DL_NR_MAX_NOF_CORESET 12 - -/** - * Maximum number of Search spaces - * @remark Defined in TS 38.331 by maxNrofSearchSpaces-1 - */ -#define SRSLTE_UE_DL_NR_MAX_NOF_SEARCH_SPACE 40 - -/** - * Maximum number of DCI messages to receive - */ -#define SRSLTE_MAX_DCI_MSG_NR 4 - -typedef struct SRSLTE_API { - srslte_pdsch_nr_args_t pdsch; - srslte_pdcch_nr_args_t pdcch; - uint32_t nof_rx_antennas; - uint32_t nof_max_prb; - float pdcch_dmrs_corr_thr; - float pdcch_dmrs_epre_thr; -} srslte_ue_dl_nr_args_t; - -typedef struct SRSLTE_API { - srslte_coreset_t coreset[SRSLTE_UE_DL_NR_MAX_NOF_CORESET]; ///< PDCCH Control resource sets (CORESET) collection - bool coreset_present[SRSLTE_UE_DL_NR_MAX_NOF_CORESET]; ///< CORESET present flags - - srslte_search_space_t search_space[SRSLTE_UE_DL_NR_MAX_NOF_SEARCH_SPACE]; - bool search_space_present[SRSLTE_UE_DL_NR_MAX_NOF_SEARCH_SPACE]; - - uint16_t ra_rnti; ///< Needs to be deduced from the PRACH configuration - srslte_search_space_t ra_search_space; - bool ra_search_space_present; -} srslte_ue_dl_nr_pdcch_cfg_t; - -typedef struct { - uint32_t scell_idx; ///< Serving cell index - uint32_t v_dai_dl; ///< Downlink Assigment Index - bool dci_format_1_1; ///< Set to true if the PDSCH transmission is triggered by a PDCCH DCI format 1_1 transmission - uint32_t k1; ///< HARQ feedback timing - uint16_t rnti; - uint32_t pucch_resource_id; -} srslte_pdsch_ack_resource_nr_t; - -typedef struct { - srslte_pdsch_ack_resource_nr_t resource; - uint8_t value[SRSLTE_MAX_CODEWORDS]; // 0/1 or 2 for DTX - bool present; // set to true if there is a PDSCH on serving cell c associated with PDCCH in PDCCH monitoring occasion - // m, or there is a PDCCH indicating SPS PDSCH release on serving cell c - bool dl_bwp_changed; // set to true if PDCCH monitoring occasion m is before an active DL BWP change on serving cell c - bool ul_bwp_changed; // set to true if an active UL BWP change on the PCell and an active DL BWP change is not - // triggered by a DCI format 1_1 in PDCCH monitoring occasion m - bool second_tb_present; // set to true if two TB were detected in the PDCCH monitoring occasion m -} srslte_pdsch_ack_m_nr_t; - -#define SRSLTE_UCI_NR_MAX_M 10 - -typedef struct { - uint32_t M; - srslte_pdsch_ack_m_nr_t m[SRSLTE_UCI_NR_MAX_M]; -} srslte_pdsch_ack_cc_nr_t; - -typedef struct { - srslte_pdsch_ack_cc_nr_t cc[SRSLTE_MAX_CARRIERS]; - uint32_t nof_cc; - bool use_pusch; // Set to true, if UCI bits are carried by PUSCH -} srslte_pdsch_ack_nr_t; - -typedef struct SRSLTE_API { - bool harq_ack_spatial_bundling_pucch; ///< Param harq-ACK-SpatialBundlingPUCCH, set to true if provided - bool harq_ack_spatial_bundling_pusch; ///< Param harq-ACK-SpatialBundlingPUSCH, set to true if provided - srslte_pdsch_harq_ack_codebook_t pdsch_harq_ack_codebook; ///< pdsch-HARQ-ACK-Codebook configuration - bool max_cw_sched_dci_is_2; ///< Param maxNrofCodeWordsScheduledByDCI, set to true if present and equal to 2 - - uint32_t dl_data_to_ul_ack[SRSLTE_MAX_NOF_DL_DATA_TO_UL]; - uint32_t nof_dl_data_to_ul_ack; -} srslte_ue_dl_nr_harq_ack_cfg_t; - -typedef struct SRSLTE_API { - uint32_t coreset_id; - uint32_t ss_id; - srslte_dci_location_t location; - srslte_dmrs_pdcch_measure_t measure; - srslte_pdcch_nr_res_t result; -} srslte_ue_dl_nr_pdcch_info_t; - -typedef struct SRSLTE_API { - uint32_t max_prb; - uint32_t nof_rx_antennas; - float pdcch_dmrs_corr_thr; - float pdcch_dmrs_epre_thr; - - srslte_carrier_nr_t carrier; - srslte_ue_dl_nr_pdcch_cfg_t cfg; - - srslte_ofdm_t fft[SRSLTE_MAX_PORTS]; - - cf_t* sf_symbols[SRSLTE_MAX_PORTS]; - srslte_chest_dl_res_t chest; - srslte_pdsch_nr_t pdsch; - srslte_dmrs_sch_t dmrs_pdsch; - - srslte_dmrs_pdcch_estimator_t dmrs_pdcch[SRSLTE_UE_DL_NR_MAX_NOF_CORESET]; - srslte_pdcch_nr_t pdcch; - srslte_dmrs_pdcch_ce_t* pdcch_ce; - - /// Store Blind-search information from all possible candidate locations for debug purposes - srslte_ue_dl_nr_pdcch_info_t pdcch_info[SRSLTE_MAX_NOF_CANDIDATES_SLOT_NR]; - uint32_t pdcch_info_count; - - /// Temporally stores Found DCI messages from all SS - srslte_dci_msg_nr_t dci_msg[SRSLTE_MAX_DCI_MSG_NR]; - uint32_t dci_msg_count; - - srslte_dci_msg_nr_t pending_ul_dci_msg[SRSLTE_MAX_DCI_MSG_NR]; - uint32_t pending_ul_dci_count; -} srslte_ue_dl_nr_t; - -SRSLTE_API int -srslte_ue_dl_nr_init(srslte_ue_dl_nr_t* q, cf_t* input[SRSLTE_MAX_PORTS], const srslte_ue_dl_nr_args_t* args); - -SRSLTE_API int srslte_ue_dl_nr_set_carrier(srslte_ue_dl_nr_t* q, const srslte_carrier_nr_t* carrier); - -SRSLTE_API int srslte_ue_dl_nr_set_pdcch_config(srslte_ue_dl_nr_t* q, const srslte_ue_dl_nr_pdcch_cfg_t* cfg); - -SRSLTE_API void srslte_ue_dl_nr_free(srslte_ue_dl_nr_t* q); - -SRSLTE_API void srslte_ue_dl_nr_estimate_fft(srslte_ue_dl_nr_t* q, const srslte_slot_cfg_t* slot_cfg); - -SRSLTE_API int srslte_ue_dl_nr_find_dl_dci(srslte_ue_dl_nr_t* q, - const srslte_slot_cfg_t* slot_cfg, - uint16_t rnti, - srslte_rnti_type_t rnti_type, - srslte_dci_dl_nr_t* dci_dl_list, - uint32_t nof_dci_msg); - -SRSLTE_API int srslte_ue_dl_nr_find_ul_dci(srslte_ue_dl_nr_t* q, - const srslte_slot_cfg_t* slot_cfg, - uint16_t rnti, - srslte_rnti_type_t rnti_type, - srslte_dci_ul_nr_t* dci_ul_list, - uint32_t nof_dci_msg); - -SRSLTE_API int srslte_ue_dl_nr_decode_pdsch(srslte_ue_dl_nr_t* q, - const srslte_slot_cfg_t* slot, - const srslte_sch_cfg_nr_t* cfg, - srslte_pdsch_res_nr_t* res); - -SRSLTE_API int srslte_ue_dl_nr_pdsch_info(const srslte_ue_dl_nr_t* q, - const srslte_sch_cfg_nr_t* cfg, - const srslte_pdsch_res_nr_t res[SRSLTE_MAX_CODEWORDS], - char* str, - uint32_t str_len); - -SRSLTE_API int srslte_ue_dl_nr_pdsch_ack_resource(const srslte_ue_dl_nr_harq_ack_cfg_t* cfg, - const srslte_dci_dl_nr_t* dci_dl, - srslte_pdsch_ack_resource_nr_t* pdsch_ack_resource); - -SRSLTE_API int srslte_ue_dl_nr_gen_ack(const srslte_ue_dl_nr_harq_ack_cfg_t* cfg, - const srslte_pdsch_ack_nr_t* ack_info, - srslte_uci_data_nr_t* uci_data); - -#endif // SRSLTE_UE_DL_NR_H diff --git a/lib/include/srslte/phy/ue/ue_mib.h b/lib/include/srslte/phy/ue/ue_mib.h deleted file mode 100644 index 5f7623515..000000000 --- a/lib/include/srslte/phy/ue/ue_mib.h +++ /dev/null @@ -1,116 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2020 Software Radio Systems Limited - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the distribution. - * - */ - -/****************************************************************************** - * File: ue_mib.h - * - * Description: This object decodes the MIB from the PBCH of an LTE signal. - * - * The function srslte_ue_mib_decode() shall be called multiple - * times, each passing a number of samples multiple of 19200, - * sampled at 1.92 MHz (that is, 10 ms of samples). - * - * The function uses the sync_t object to find the PSS sequence and - * decode the PBCH to obtain the MIB. - * - * The function returns 0 until the MIB is decoded. - * - * See ue_cell_detect.c for an example. - * - * Reference: - *****************************************************************************/ - -#ifndef SRSLTE_UE_MIB_H -#define SRSLTE_UE_MIB_H - -#include - -#include "srslte/config.h" -#include "srslte/phy/ue/ue_sync.h" -#include "srslte/phy/sync/cfo.h" -#include "srslte/phy/ch_estimation/chest_dl.h" -#include "srslte/phy/phch/pbch.h" -#include "srslte/phy/dft/ofdm.h" - -#define SRSLTE_UE_MIB_NOF_PRB 6 - -#define SRSLTE_UE_MIB_FOUND 1 -#define SRSLTE_UE_MIB_NOTFOUND 0 - -typedef struct SRSLTE_API { - srslte_sync_t sfind; - - cf_t* sf_symbols; - - srslte_ofdm_t fft; - srslte_pbch_t pbch; - - srslte_chest_dl_t chest; - srslte_chest_dl_res_t chest_res; - - uint8_t bch_payload[SRSLTE_BCH_PAYLOAD_LEN]; - uint32_t nof_tx_ports; - uint32_t sfn_offset; - - uint32_t frame_cnt; -} srslte_ue_mib_t; - -SRSLTE_API int srslte_ue_mib_init(srslte_ue_mib_t* q, cf_t* in_buffer, uint32_t max_prb); - -SRSLTE_API void srslte_ue_mib_free(srslte_ue_mib_t *q); - -SRSLTE_API int srslte_ue_mib_set_cell(srslte_ue_mib_t * q, - srslte_cell_t cell); - -SRSLTE_API void srslte_ue_mib_reset(srslte_ue_mib_t * q); - -SRSLTE_API int srslte_ue_mib_decode(srslte_ue_mib_t * q, - uint8_t bch_payload[SRSLTE_BCH_PAYLOAD_LEN], - uint32_t *nof_tx_ports, - int *sfn_offset); - - -/* This interface uses ue_mib and ue_sync to first get synchronized subframes - * and then decode MIB - * - * This object calls the pbch object with nof_ports=0 for blind nof_ports determination -*/ -typedef struct { - srslte_ue_mib_t ue_mib; - srslte_ue_sync_t ue_sync; - cf_t* sf_buffer[SRSLTE_MAX_CHANNELS]; - uint32_t nof_rx_channels; -} srslte_ue_mib_sync_t; - -SRSLTE_API int -srslte_ue_mib_sync_init_multi(srslte_ue_mib_sync_t* q, - int(recv_callback)(void*, cf_t* [SRSLTE_MAX_CHANNELS], uint32_t, srslte_timestamp_t*), - uint32_t nof_rx_channels, - void* stream_handler); - -SRSLTE_API void srslte_ue_mib_sync_free(srslte_ue_mib_sync_t *q); - -SRSLTE_API int srslte_ue_mib_sync_set_cell(srslte_ue_mib_sync_t* q, srslte_cell_t cell); - -SRSLTE_API void srslte_ue_mib_sync_reset(srslte_ue_mib_sync_t * q); - -SRSLTE_API int srslte_ue_mib_sync_decode(srslte_ue_mib_sync_t * q, - uint32_t max_frames_timeout, - uint8_t bch_payload[SRSLTE_BCH_PAYLOAD_LEN], - uint32_t *nof_tx_ports, - int *sfn_offset); - - - - -#endif // SRSLTE_UE_MIB_H - diff --git a/lib/include/srslte/phy/ue/ue_sync.h b/lib/include/srslte/phy/ue/ue_sync.h deleted file mode 100644 index 787e593aa..000000000 --- a/lib/include/srslte/phy/ue/ue_sync.h +++ /dev/null @@ -1,276 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2020 Software Radio Systems Limited - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the distribution. - * - */ - -/****************************************************************************** - * File: ue_sync.h - * - * Description: This object automatically manages the cell synchronization - * procedure. - * - * The main function is srslte_ue_sync_get_buffer(), which returns - * a pointer to the aligned subframe of samples (before FFT). This - * function should be called regularly, returning every 1 ms. - * It reads from the USRP, aligns the samples to the subframe and - * performs time/freq synch. - * - * It is also possible to read the signal from a file using the - * init function srslte_ue_sync_init_file(). The sampling frequency - * is derived from the number of PRB. - * - * The function returns 1 when the signal is correctly acquired and - * the returned buffer is aligned with the subframe. - * - * Reference: - *****************************************************************************/ - -#ifndef SRSLTE_UE_SYNC_H -#define SRSLTE_UE_SYNC_H - -#include - -#include "srslte/config.h" -#include "srslte/phy/sync/sync.h" -#include "srslte/phy/sync/cfo.h" -#include "srslte/phy/agc/agc.h" -#include "srslte/phy/ch_estimation/chest_dl.h" -#include "srslte/phy/phch/pbch.h" -#include "srslte/phy/dft/ofdm.h" -#include "srslte/phy/common/timestamp.h" -#include "srslte/phy/io/filesource.h" - -#define DEFAULT_SAMPLE_OFFSET_CORRECT_PERIOD 10 -#define DEFAULT_SFO_EMA_COEFF 0.1 - -#define DEFAULT_CFO_BW_PSS 0.05 -#define DEFAULT_CFO_PSS_MIN 400 // typical bias of PSS estimation. -#define DEFAULT_CFO_BW_REF 0.08 -#define DEFAULT_CFO_REF_MIN 0 // typical bias of REF estimation -#define DEFAULT_CFO_REF_MAX DEFAULT_CFO_PSS_MIN // Maximum detection offset of REF based estimation - -#define DEFAULT_PSS_STABLE_TIMEOUT 20 // Time after which the PSS is considered to be stable and we accept REF-CFO - -#define DEFAULT_CFO_EMA_TRACK 0.05 - -typedef enum SRSLTE_API { SYNC_MODE_PSS, SYNC_MODE_GNSS } srslte_ue_sync_mode_t; -typedef enum SRSLTE_API { SF_FIND, SF_TRACK} srslte_ue_sync_state_t; - -//#define MEASURE_EXEC_TIME - -typedef int(ue_sync_recv_callback_t)(void*, cf_t* [SRSLTE_MAX_CHANNELS], uint32_t, srslte_timestamp_t*); - -typedef struct SRSLTE_API { - srslte_ue_sync_mode_t mode; - srslte_sync_t sfind; - srslte_sync_t strack; - - uint32_t max_prb; - - srslte_agc_t agc; - bool do_agc; - uint32_t agc_period; - int decimate; - void *stream; - void *stream_single; - int (*recv_callback)(void*, cf_t* [SRSLTE_MAX_CHANNELS], uint32_t, srslte_timestamp_t*); - int (*recv_callback_single)(void*, void*, uint32_t, srslte_timestamp_t*); - srslte_timestamp_t last_timestamp; - - uint32_t nof_rx_antennas; - - srslte_filesource_t file_source; - bool file_mode; - float file_cfo; - bool file_wrap_enable; - srslte_cfo_t file_cfo_correct; - - srslte_ue_sync_state_t state; - - uint32_t frame_len; - uint32_t fft_size; - uint32_t nof_recv_sf; // Number of subframes received each call to srslte_ue_sync_get_buffer - uint32_t nof_avg_find_frames; - uint32_t frame_find_cnt; - uint32_t sf_len; - - /* These count half frames (5ms) */ - uint64_t frame_ok_cnt; - uint32_t frame_no_cnt; - uint32_t frame_total_cnt; - - /* this is the system frame number (SFN) */ - uint32_t frame_number; - uint32_t sfn_offset; ///< An offset value provided by higher layers - - srslte_cell_t cell; - uint32_t sf_idx; - - bool cfo_is_copied; - bool cfo_correct_enable_track; - bool cfo_correct_enable_find; - float cfo_current_value; - float cfo_loop_bw_pss; - float cfo_loop_bw_ref; - float cfo_pss_min; - float cfo_ref_min; - float cfo_ref_max; - - uint32_t pss_stable_cnt; - uint32_t pss_stable_timeout; - bool pss_is_stable; - - uint32_t peak_idx; - int next_rf_sample_offset; - int last_sample_offset; - float mean_sample_offset; - uint32_t sample_offset_correct_period; - float sfo_ema; - - - #ifdef MEASURE_EXEC_TIME - float mean_exec_time; - #endif -} srslte_ue_sync_t; - -SRSLTE_API int srslte_ue_sync_init(srslte_ue_sync_t *q, - uint32_t max_prb, - bool search_cell, - int (recv_callback)(void*, void*, uint32_t, srslte_timestamp_t*), - void *stream_handler); - -SRSLTE_API int -srslte_ue_sync_init_multi(srslte_ue_sync_t* q, - uint32_t max_prb, - bool search_cell, - int(recv_callback)(void*, cf_t* [SRSLTE_MAX_CHANNELS], uint32_t, srslte_timestamp_t*), - uint32_t nof_rx_antennas, - void* stream_handler); - -SRSLTE_API int -srslte_ue_sync_init_multi_decim(srslte_ue_sync_t* q, - uint32_t max_prb, - bool search_cell, - int(recv_callback)(void*, cf_t* [SRSLTE_MAX_CHANNELS], uint32_t, srslte_timestamp_t*), - uint32_t nof_rx_antennas, - void* stream_handler, - int decimate); - -SRSLTE_API int srslte_ue_sync_init_multi_decim_mode( - srslte_ue_sync_t* q, - uint32_t max_prb, - bool search_cell, - int(recv_callback)(void*, cf_t* [SRSLTE_MAX_CHANNELS], uint32_t, srslte_timestamp_t*), - uint32_t nof_rx_antennas, - void* stream_handler, - int decimate, - srslte_ue_sync_mode_t mode); - -SRSLTE_API int srslte_ue_sync_init_file(srslte_ue_sync_t *q, - uint32_t nof_prb, - char *file_name, - int offset_time, - float offset_freq); - -SRSLTE_API int srslte_ue_sync_init_file_multi(srslte_ue_sync_t *q, - uint32_t nof_prb, - char *file_name, - int offset_time, - float offset_freq, - uint32_t nof_rx_ant); - -SRSLTE_API void srslte_ue_sync_free(srslte_ue_sync_t *q); - -SRSLTE_API void srslte_ue_sync_file_wrap(srslte_ue_sync_t *q, - bool enable); - -SRSLTE_API int srslte_ue_sync_set_cell(srslte_ue_sync_t *q, - srslte_cell_t cell); - -SRSLTE_API void srslte_ue_sync_cfo_reset(srslte_ue_sync_t* q, float init_cfo_hz); - -SRSLTE_API void srslte_ue_sync_reset(srslte_ue_sync_t *q); - -SRSLTE_API void srslte_ue_sync_set_frame_type(srslte_ue_sync_t* q, srslte_frame_type_t frame_type); - -SRSLTE_API void srslte_ue_sync_set_nof_find_frames(srslte_ue_sync_t* q, uint32_t nof_frames); - -SRSLTE_API srslte_frame_type_t srslte_ue_sync_get_frame_type(srslte_ue_sync_t* q); - -SRSLTE_API int srslte_ue_sync_start_agc(srslte_ue_sync_t* q, - SRSLTE_AGC_CALLBACK(set_gain_callback), - float min_gain, - float max_gain, - float init_gain_value); - -SRSLTE_API uint32_t srslte_ue_sync_sf_len(srslte_ue_sync_t* q); - -SRSLTE_API void srslte_ue_sync_set_agc_period(srslte_ue_sync_t* q, uint32_t period); - -SRSLTE_API int -srslte_ue_sync_zerocopy(srslte_ue_sync_t* q, cf_t* input_buffer[SRSLTE_MAX_CHANNELS], const uint32_t max_num_samples); - -SRSLTE_API void srslte_ue_sync_set_cfo_tol(srslte_ue_sync_t* q, float tol); - -SRSLTE_API void srslte_ue_sync_copy_cfo(srslte_ue_sync_t *q, - srslte_ue_sync_t *src_obj); - -SRSLTE_API void srslte_ue_sync_set_cfo_loop_bw(srslte_ue_sync_t *q, - float bw_pss, - float bw_ref, - float pss_tol, - float ref_tol, - float ref_max, - uint32_t pss_stable_timeout); - -SRSLTE_API void srslte_ue_sync_set_cfo_ema(srslte_ue_sync_t *q, - float ema); - -SRSLTE_API void srslte_ue_sync_set_cfo_ref(srslte_ue_sync_t *q, float res_cfo); - -SRSLTE_API void srslte_ue_sync_set_cfo_i_enable(srslte_ue_sync_t *q, - bool enable); - -SRSLTE_API void srslte_ue_sync_set_N_id_2(srslte_ue_sync_t *q, - uint32_t N_id_2); - -SRSLTE_API uint32_t srslte_ue_sync_get_sfn(srslte_ue_sync_t* q); - -SRSLTE_API uint32_t srslte_ue_sync_get_sfidx(srslte_ue_sync_t *q); - -SRSLTE_API float srslte_ue_sync_get_cfo(srslte_ue_sync_t *q); - -SRSLTE_API float srslte_ue_sync_get_sfo(srslte_ue_sync_t *q); - -SRSLTE_API int srslte_ue_sync_get_last_sample_offset(srslte_ue_sync_t *q); - -SRSLTE_API void srslte_ue_sync_set_sfo_correct_period(srslte_ue_sync_t *q, - uint32_t nof_subframes); - -SRSLTE_API void srslte_ue_sync_set_sfo_ema(srslte_ue_sync_t *q, - float ema_coefficient); - -SRSLTE_API void srslte_ue_sync_get_last_timestamp(srslte_ue_sync_t *q, - srslte_timestamp_t *timestamp); - -SRSLTE_API int srslte_ue_sync_run_find_pss_mode(srslte_ue_sync_t* q, cf_t* input_buffer[SRSLTE_MAX_CHANNELS]); - -SRSLTE_API int srslte_ue_sync_run_track_pss_mode(srslte_ue_sync_t* q, cf_t* input_buffer[SRSLTE_MAX_CHANNELS]); - -SRSLTE_API int srslte_ue_sync_run_find_gnss_mode(srslte_ue_sync_t* q, - cf_t* input_buffer[SRSLTE_MAX_CHANNELS], - const uint32_t max_num_samples); - -SRSLTE_API int srslte_ue_sync_run_track_gnss_mode(srslte_ue_sync_t* q, cf_t* input_buffer[SRSLTE_MAX_CHANNELS]); - -SRSLTE_API int srslte_ue_sync_set_tti_from_timestamp(srslte_ue_sync_t* q, srslte_timestamp_t* rx_timestamp); - -#endif // SRSLTE_UE_SYNC_H - diff --git a/lib/include/srslte/phy/ue/ue_sync_nbiot.h b/lib/include/srslte/phy/ue/ue_sync_nbiot.h deleted file mode 100644 index 2fa565828..000000000 --- a/lib/include/srslte/phy/ue/ue_sync_nbiot.h +++ /dev/null @@ -1,156 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2020 Software Radio Systems Limited - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the distribution. - * - */ - -#ifndef SRSLTE_UE_SYNC_NBIOT_H -#define SRSLTE_UE_SYNC_NBIOT_H - -#include - -#include "srslte/config.h" -#include "srslte/phy/agc/agc.h" -#include "srslte/phy/ch_estimation/chest_dl_nbiot.h" -#include "srslte/phy/common/timestamp.h" -#include "srslte/phy/dft/ofdm.h" -#include "srslte/phy/io/filesource.h" -#include "srslte/phy/phch/npbch.h" -#include "srslte/phy/sync/cfo.h" -#include "srslte/phy/sync/sync_nbiot.h" - -typedef srslte_ue_sync_state_t srslte_nbiot_ue_sync_state_t; - -//#define MEASURE_EXEC_TIME - -typedef struct SRSLTE_API { - srslte_sync_nbiot_t sfind; - srslte_sync_nbiot_t strack; - - srslte_agc_t agc; - bool do_agc; - uint32_t agc_period; - - void* stream; - void* stream_single; - int (*recv_callback)(void*, cf_t* [SRSLTE_MAX_PORTS], uint32_t, srslte_timestamp_t*); - int (*recv_callback_single)(void*, void*, uint32_t, srslte_timestamp_t*); - srslte_timestamp_t last_timestamp; - - srslte_filesource_t file_source; - bool file_mode; - float file_cfo; - srslte_cfo_t file_cfo_correct; - - srslte_nbiot_ue_sync_state_t state; - - uint32_t nof_rx_antennas; - uint32_t frame_len; - uint32_t fft_size; - uint32_t nof_recv_sf; // Number of subframes received each call to srslte_ue_sync_get_buffer - uint32_t nof_avg_find_frames; - uint32_t frame_find_cnt; - uint32_t sf_len; - - /* These count half frames (5ms) */ - uint64_t frame_ok_cnt; - uint32_t frame_no_cnt; - uint32_t frame_total_cnt; - - /* this is the system frame number (SFN) */ - uint32_t frame_number; - - srslte_nbiot_cell_t cell; - uint32_t sf_idx; - bool correct_cfo; - - uint32_t peak_idx; - int next_rf_sample_offset; - int last_sample_offset; - float mean_sample_offset; - float mean_sfo; - uint32_t sample_offset_correct_period; - float sfo_ema; - uint32_t max_prb; - -#ifdef MEASURE_EXEC_TIME - float mean_exec_time; -#endif -} srslte_nbiot_ue_sync_t; - -SRSLTE_API int srslte_ue_sync_nbiot_init(srslte_nbiot_ue_sync_t* q, - srslte_nbiot_cell_t cell, - int(recv_callback)(void*, void*, uint32_t, srslte_timestamp_t*), - void* stream_handler); - -SRSLTE_API int -srslte_ue_sync_nbiot_init_multi(srslte_nbiot_ue_sync_t* q, - uint32_t max_prb, - int(recv_callback)(void*, cf_t* [SRSLTE_MAX_PORTS], uint32_t, srslte_timestamp_t*), - uint32_t nof_rx_antennas, - void* stream_handler); - -SRSLTE_API int srslte_ue_sync_nbiot_init_file(srslte_nbiot_ue_sync_t* q, - srslte_nbiot_cell_t cell, - char* file_name, - int offset_time, - float offset_freq); - -SRSLTE_API int srslte_ue_sync_nbiot_init_file_multi(srslte_nbiot_ue_sync_t* q, - srslte_nbiot_cell_t cell, - char* file_name, - int offset_time, - float offset_freq, - uint32_t nof_rx_ant); - -SRSLTE_API void srslte_ue_sync_nbiot_free(srslte_nbiot_ue_sync_t* q); - -SRSLTE_API int srslte_ue_sync_nbiot_set_cell(srslte_nbiot_ue_sync_t* q, srslte_nbiot_cell_t cell); - -SRSLTE_API int srslte_ue_sync_nbiot_start_agc(srslte_nbiot_ue_sync_t* q, - SRSLTE_AGC_CALLBACK(set_gain_callback), - float init_gain_value); - -SRSLTE_API uint32_t srslte_ue_sync_nbiot_sf_len(srslte_nbiot_ue_sync_t* q); - -SRSLTE_API int srslte_nbiot_ue_sync_get_buffer(srslte_nbiot_ue_sync_t* q, cf_t** sf_symbols); - -SRSLTE_API void srslte_ue_sync_nbiot_set_agc_period(srslte_nbiot_ue_sync_t* q, uint32_t period); - -/* CAUTION: input_buffer MUST have space for 2 subframes */ -SRSLTE_API int srslte_ue_sync_nbiot_zerocopy(srslte_nbiot_ue_sync_t* q, cf_t* input_buffer); - -SRSLTE_API int srslte_ue_sync_nbiot_zerocopy_multi(srslte_nbiot_ue_sync_t* q, cf_t** input_buffer); - -SRSLTE_API void srslte_ue_sync_nbiot_set_cfo(srslte_nbiot_ue_sync_t* q, float cfo); - -SRSLTE_API void srslte_ue_sync_nbiot_reset(srslte_nbiot_ue_sync_t* q); - -SRSLTE_API srslte_nbiot_ue_sync_state_t srslte_ue_sync_nbiot_get_state(srslte_nbiot_ue_sync_t* q); - -SRSLTE_API uint32_t srslte_ue_sync_nbiot_get_sfidx(srslte_nbiot_ue_sync_t* q); - -SRSLTE_API void srslte_ue_sync_nbiot_set_cfo_enable(srslte_nbiot_ue_sync_t* q, bool enable); - -SRSLTE_API float srslte_ue_sync_nbiot_get_cfo(srslte_nbiot_ue_sync_t* q); - -SRSLTE_API float srslte_ue_sync_nbiot_get_sfo(srslte_nbiot_ue_sync_t* q); - -SRSLTE_API void srslte_ue_sync_nbiot_set_cfo_ema(srslte_nbiot_ue_sync_t* q, float ema); - -SRSLTE_API void srslte_ue_sync_nbiot_set_cfo_tol(srslte_nbiot_ue_sync_t* q, float cfo_tol); - -SRSLTE_API int srslte_ue_sync_nbiot_get_last_sample_offset(srslte_nbiot_ue_sync_t* q); - -SRSLTE_API void srslte_ue_sync_nbiot_set_sample_offset_correct_period(srslte_nbiot_ue_sync_t* q, - uint32_t nof_subframes); - -SRSLTE_API void srslte_ue_sync_nbiot_get_last_timestamp(srslte_nbiot_ue_sync_t* q, srslte_timestamp_t* timestamp); - -#endif // SRSLTE_UE_SYNC_NBIOT_H \ No newline at end of file diff --git a/lib/include/srslte/phy/ue/ue_ul.h b/lib/include/srslte/phy/ue/ue_ul.h deleted file mode 100644 index d6ed476dd..000000000 --- a/lib/include/srslte/phy/ue/ue_ul.h +++ /dev/null @@ -1,158 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2020 Software Radio Systems Limited - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the distribution. - * - */ - -/****************************************************************************** - * File: ue_ul.h - * - * Description: UE uplink object. - * - * This module is a frontend to all the uplink data and control - * channel processing modules. - * - * Reference: - *****************************************************************************/ - -#ifndef SRSLTE_UE_UL_H -#define SRSLTE_UE_UL_H - -#include "srslte/phy/ch_estimation/chest_dl.h" -#include "srslte/phy/ch_estimation/refsignal_ul.h" -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/dft/ofdm.h" -#include "srslte/phy/phch/dci.h" -#include "srslte/phy/phch/pusch.h" -#include "srslte/phy/phch/ra.h" -#include "srslte/phy/sync/cfo.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" - -#include "srslte/config.h" - -/* UE UL power control */ -typedef struct { - // Common configuration - float p0_nominal_pusch; - float alpha; - float p0_nominal_pucch; - float delta_f_pucch[5]; - float delta_preamble_msg3; - - // Dedicated configuration - float p0_ue_pusch; - bool delta_mcs_based; - bool acc_enabled; - float p0_ue_pucch; - float p_srs_offset; -} srslte_ue_ul_powerctrl_t; - -typedef struct SRSLTE_API { - // Uplink config (includes common and dedicated variables) - srslte_pucch_cfg_t pucch; - srslte_pusch_cfg_t pusch; - srslte_pusch_hopping_cfg_t hopping; - srslte_ue_ul_powerctrl_t power_ctrl; - srslte_refsignal_dmrs_pusch_cfg_t dmrs; - srslte_refsignal_srs_cfg_t srs; -} srslte_ul_cfg_t; - -typedef enum { - SRSLTE_UE_UL_NORMALIZE_MODE_AUTO = 0, - SRSLTE_UE_UL_NORMALIZE_MODE_FORCE_AMPLITUDE -} srslte_ue_ul_normalize_mode_t; - -typedef struct SRSLTE_API { - srslte_ul_cfg_t ul_cfg; - bool grant_available; - uint32_t cc_idx; - - srslte_ue_ul_normalize_mode_t normalize_mode; - float force_peak_amplitude; - bool cfo_en; - float cfo_tol; - float cfo_value; - -} srslte_ue_ul_cfg_t; - -typedef struct SRSLTE_API { - srslte_cell_t cell; - - bool signals_pregenerated; - - srslte_ofdm_t fft; - srslte_cfo_t cfo; - - srslte_refsignal_ul_t signals; - srslte_refsignal_ul_dmrs_pregen_t pregen_dmrs; - srslte_refsignal_srs_pregen_t pregen_srs; - - srslte_pusch_t pusch; - srslte_pucch_t pucch; - - srslte_ra_ul_pusch_hopping_t hopping; - - cf_t* out_buffer; - cf_t* refsignal; - cf_t* srs_signal; - cf_t* sf_symbols; - -} srslte_ue_ul_t; - -SRSLTE_API int srslte_ue_ul_init(srslte_ue_ul_t* q, cf_t* out_buffer, uint32_t max_prb); - -SRSLTE_API void srslte_ue_ul_free(srslte_ue_ul_t* q); - -SRSLTE_API int srslte_ue_ul_set_cell(srslte_ue_ul_t* q, srslte_cell_t cell); - -SRSLTE_API int srslte_ue_ul_pregen_signals(srslte_ue_ul_t* q, srslte_ue_ul_cfg_t* cfg); - -SRSLTE_API int srslte_ue_ul_dci_to_pusch_grant(srslte_ue_ul_t* q, - srslte_ul_sf_cfg_t* sf, - srslte_ue_ul_cfg_t* cfg, - srslte_dci_ul_t* dci, - srslte_pusch_grant_t* grant); - -SRSLTE_API void srslte_ue_ul_pusch_hopping(srslte_ue_ul_t* q, - srslte_ul_sf_cfg_t* sf, - srslte_ue_ul_cfg_t* cfg, - srslte_pusch_grant_t* grant); - -SRSLTE_API int -srslte_ue_ul_encode(srslte_ue_ul_t* q, srslte_ul_sf_cfg_t* sf, srslte_ue_ul_cfg_t* cfg, srslte_pusch_data_t* data); - -SRSLTE_API int srslte_ue_ul_sr_send_tti(const srslte_pucch_cfg_t* cfg, uint32_t current_tti); - -SRSLTE_API bool -srslte_ue_ul_gen_sr(srslte_ue_ul_cfg_t* cfg, srslte_ul_sf_cfg_t* sf, srslte_uci_data_t* uci_data, bool sr_request); - -/** - * Determines the PUCCH resource selection according to 3GPP 36.213 R10 Section 10.1. The PUCCH format and resource are - * saved in cfg->format and cfg->n_pucch. Also, HARQ-ACK - * - * @param cell Cell parameter, non-modifiable - * @param cfg PUCCH configuration and contains function results - * @param uci_cfg UCI configuration - * @param uci_data UCI data - * @param b Modified bits after applying HARQ-ACK feedback mode "encoding" - */ -SRSLTE_API void srslte_ue_ul_pucch_resource_selection(const srslte_cell_t* cell, - srslte_pucch_cfg_t* cfg, - const srslte_uci_cfg_t* uci_cfg, - const srslte_uci_value_t* uci_value, - uint8_t b[SRSLTE_UCI_MAX_ACK_BITS]); - -SRSLTE_API bool srslte_ue_ul_info(srslte_ue_ul_cfg_t* cfg, - srslte_ul_sf_cfg_t* sf, - srslte_uci_value_t* uci_data, - char* str, - uint32_t str_len); - -#endif // SRSLTE_UE_UL_H diff --git a/lib/include/srslte/phy/ue/ue_ul_nr.h b/lib/include/srslte/phy/ue/ue_ul_nr.h deleted file mode 100644 index 6d2575009..000000000 --- a/lib/include/srslte/phy/ue/ue_ul_nr.h +++ /dev/null @@ -1,98 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2020 Software Radio Systems Limited - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the distribution. - * - */ - -/****************************************************************************** - * @file ue_dl_nr.h - * - * Description: NR UE uplink physical layer procedures for data - * - * This module is a frontend to all the uplink data channel processing modules. - * - * Reference: - *****************************************************************************/ - -#ifndef SRSLTE_UE_UL_DATA_H -#define SRSLTE_UE_UL_DATA_H - -#include "srslte/phy/ch_estimation/dmrs_sch.h" -#include "srslte/phy/common/phy_common_nr.h" -#include "srslte/phy/dft/ofdm.h" -#include "srslte/phy/phch/phch_cfg_nr.h" -#include "srslte/phy/phch/pucch_cfg_nr.h" -#include "srslte/phy/phch/pucch_nr.h" -#include "srslte/phy/phch/pusch_nr.h" - -typedef struct SRSLTE_API { - srslte_pusch_nr_args_t pusch; - srslte_pucch_nr_args_t pucch; - uint32_t nof_max_prb; -} srslte_ue_ul_nr_args_t; - -typedef struct SRSLTE_API { - uint32_t max_prb; - - srslte_carrier_nr_t carrier; - - srslte_ofdm_t ifft; - - cf_t* sf_symbols[SRSLTE_MAX_PORTS]; - srslte_pusch_nr_t pusch; - srslte_pucch_nr_t pucch; - srslte_dmrs_sch_t dmrs; -} srslte_ue_ul_nr_t; - -SRSLTE_API int srslte_ue_ul_nr_init(srslte_ue_ul_nr_t* q, cf_t* output, const srslte_ue_ul_nr_args_t* args); - -SRSLTE_API int srslte_ue_ul_nr_set_carrier(srslte_ue_ul_nr_t* q, const srslte_carrier_nr_t* carrier); - -SRSLTE_API int srslte_ue_ul_nr_encode_pusch(srslte_ue_ul_nr_t* q, - const srslte_slot_cfg_t* slot_cfg, - const srslte_sch_cfg_nr_t* pusch_cfg, - const srslte_pusch_data_nr_t* data); - -SRSLTE_API int srslte_ue_ul_nr_encode_pucch(srslte_ue_ul_nr_t* q, - const srslte_slot_cfg_t* slot_cfg, - const srslte_pucch_nr_common_cfg_t* cfg, - const srslte_pucch_nr_resource_t* resource, - const srslte_uci_data_nr_t* uci_data); - -SRSLTE_API void srslte_ue_ul_nr_free(srslte_ue_ul_nr_t* q); - -SRSLTE_API int srslte_ue_ul_nr_pusch_info(const srslte_ue_ul_nr_t* q, - const srslte_sch_cfg_nr_t* cfg, - const srslte_uci_value_nr_t* uci_value, - char* str, - uint32_t str_len); - -SRSLTE_API int srslte_ue_ul_nr_pucch_info(const srslte_pucch_nr_resource_t* resource, - const srslte_uci_data_nr_t* uci_data, - char* str, - uint32_t str_len); - -/** - * @brief Decides whether the provided slot index within the radio frame is a SR transmission opportunity - * - * @remark Implemented according to TS 38.213 9.2.4 UE procedure for reporting SR - * - * @param sr_resources Provides the SR configuration from the upper layers - * @param slot_idx Slot index in the radio frame - * @param[out] sr_resource_id Optional SR resource index (or identifier) - * - * @return the number of SR opportunities if the provided slot index is a SR transmission opportunity, SRSLTE_ERROR code - * if provided parameters are invalid - */ -SRSLTE_API int -srslte_ue_ul_nr_sr_send_slot(const srslte_pucch_nr_sr_resource_t sr_resources[SRSLTE_PUCCH_MAX_NOF_SR_RESOURCES], - uint32_t slot_idx, - uint32_t sr_resource_id[SRSLTE_PUCCH_MAX_NOF_SR_RESOURCES]); - -#endif // SRSLTE_UE_UL_DATA_H diff --git a/lib/include/srslte/phy/utils/random.h b/lib/include/srslte/phy/utils/random.h deleted file mode 100644 index b235871ec..000000000 --- a/lib/include/srslte/phy/utils/random.h +++ /dev/null @@ -1,48 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2020 Software Radio Systems Limited - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the distribution. - * - */ - -#ifndef SRSLTE_RANDOM_H -#define SRSLTE_RANDOM_H - -#include "srslte/config.h" - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef void* srslte_random_t; - -SRSLTE_API srslte_random_t srslte_random_init(uint32_t seed); - -SRSLTE_API int srslte_random_uniform_int_dist(srslte_random_t q, int min, int max); - -SRSLTE_API float srslte_random_uniform_real_dist(srslte_random_t q, float min, float max); - -SRSLTE_API cf_t srslte_random_uniform_complex_dist(srslte_random_t q, float min, float max); - -SRSLTE_API void -srslte_random_uniform_complex_dist_vector(srslte_random_t q, cf_t* vector, uint32_t nsamples, float min, float max); - -SRSLTE_API float srslte_random_gauss_dist(srslte_random_t q, float std_dev); - -SRSLTE_API bool srslte_random_bool(srslte_random_t q, float prob_true); - -SRSLTE_API void srslte_random_free(srslte_random_t q); - -#ifdef __cplusplus -} -#endif - -#endif // SRSLTE_RANDOM_H diff --git a/lib/include/srslte/phy/utils/vector_simd.h b/lib/include/srslte/phy/utils/vector_simd.h deleted file mode 100644 index 0db7b9c11..000000000 --- a/lib/include/srslte/phy/utils/vector_simd.h +++ /dev/null @@ -1,141 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2020 Software Radio Systems Limited - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the distribution. - * - */ - -#ifndef SRSLTE_VECTOR_SIMD_H -#define SRSLTE_VECTOR_SIMD_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include "srslte/config.h" -#include -#include - -/*SIMD Logical operations*/ -SRSLTE_API void srslte_vec_xor_bbb_simd(const uint8_t* x, const uint8_t* y, uint8_t* z, int len); - -/* SIMD Basic vector math */ -SRSLTE_API void srslte_vec_sum_sss_simd(const int16_t* x, const int16_t* y, int16_t* z, int len); - -SRSLTE_API void srslte_vec_sub_sss_simd(const int16_t* x, const int16_t* y, int16_t* z, int len); - -SRSLTE_API void srslte_vec_sub_bbb_simd(const int8_t* x, const int8_t* y, int8_t* z, int len); - -SRSLTE_API float srslte_vec_acc_ff_simd(const float* x, int len); - -SRSLTE_API cf_t srslte_vec_acc_cc_simd(const cf_t* x, int len); - -SRSLTE_API void srslte_vec_add_fff_simd(const float* x, const float* y, float* z, int len); - -SRSLTE_API void srslte_vec_sub_fff_simd(const float* x, const float* y, float* z, int len); - -/* SIMD Vector Scalar Product */ -SRSLTE_API void srslte_vec_sc_prod_cfc_simd(const cf_t* x, const float h, cf_t* y, const int len); - -SRSLTE_API void srslte_vec_sc_prod_fcc_simd(const float* x, const cf_t h, cf_t* y, const int len); - -SRSLTE_API void srslte_vec_sc_prod_fff_simd(const float* x, const float h, float* z, const int len); - -SRSLTE_API void srslte_vec_sc_prod_ccc_simd(const cf_t* x, const cf_t h, cf_t* z, const int len); - -SRSLTE_API int srslte_vec_sc_prod_ccc_simd2(const cf_t* x, const cf_t h, cf_t* z, const int len); - -/* SIMD Vector Product */ -SRSLTE_API void srslte_vec_prod_ccc_split_simd(const float* a_re, - const float* a_im, - const float* b_re, - const float* b_im, - float* r_re, - float* r_im, - const int len); - -SRSLTE_API void srslte_vec_prod_ccc_c16_simd(const int16_t* a_re, - const int16_t* a_im, - const int16_t* b_re, - const int16_t* b_im, - int16_t* r_re, - int16_t* r_im, - const int len); - -SRSLTE_API void srslte_vec_prod_sss_simd(const int16_t* x, const int16_t* y, int16_t* z, const int len); - -SRSLTE_API void srslte_vec_neg_sss_simd(const int16_t* x, const int16_t* y, int16_t* z, const int len); - -SRSLTE_API void srslte_vec_neg_bbb_simd(const int8_t* x, const int8_t* y, int8_t* z, const int len); - -SRSLTE_API void srslte_vec_prod_cfc_simd(const cf_t* x, const float* y, cf_t* z, const int len); - -SRSLTE_API void srslte_vec_prod_fff_simd(const float* x, const float* y, float* z, const int len); - -SRSLTE_API void srslte_vec_prod_ccc_simd(const cf_t* x, const cf_t* y, cf_t* z, const int len); - -SRSLTE_API void srslte_vec_prod_conj_ccc_simd(const cf_t* x, const cf_t* y, cf_t* z, const int len); - -/* SIMD Division */ -SRSLTE_API void srslte_vec_div_ccc_simd(const cf_t* x, const cf_t* y, cf_t* z, const int len); - -SRSLTE_API void srslte_vec_div_cfc_simd(const cf_t* x, const float* y, cf_t* z, const int len); - -SRSLTE_API void srslte_vec_div_fff_simd(const float* x, const float* y, float* z, const int len); - -/* SIMD Dot product */ -SRSLTE_API cf_t srslte_vec_dot_prod_conj_ccc_simd(const cf_t* x, const cf_t* y, const int len); - -SRSLTE_API cf_t srslte_vec_dot_prod_ccc_simd(const cf_t* x, const cf_t* y, const int len); - -#ifdef ENABLE_C16 -SRSLTE_API c16_t srslte_vec_dot_prod_ccc_c16i_simd(const c16_t* x, const c16_t* y, const int len); -#endif /* ENABLE_C16 */ - -SRSLTE_API int srslte_vec_dot_prod_sss_simd(const int16_t* x, const int16_t* y, const int len); - -/* SIMD Modulus functions */ -SRSLTE_API void srslte_vec_abs_cf_simd(const cf_t* x, float* z, const int len); - -SRSLTE_API void srslte_vec_abs_square_cf_simd(const cf_t* x, float* z, const int len); - -/* Other Functions */ -SRSLTE_API void srslte_vec_lut_sss_simd(const short* x, const unsigned short* lut, short* y, const int len); - -SRSLTE_API void srslte_vec_lut_bbb_simd(const int8_t* x, const unsigned short* lut, int8_t* y, const int len); - -SRSLTE_API void srslte_vec_convert_if_simd(const int16_t* x, float* z, const float scale, const int len); - -SRSLTE_API void srslte_vec_convert_fi_simd(const float* x, int16_t* z, const float scale, const int len); - -SRSLTE_API void srslte_vec_convert_conj_cs_simd(const cf_t* x, int16_t* z, const float scale, const int len); - -SRSLTE_API void srslte_vec_convert_fb_simd(const float* x, int8_t* z, const float scale, const int len); - -SRSLTE_API void srslte_vec_interleave_simd(const cf_t* x, const cf_t* y, cf_t* z, const int len); - -SRSLTE_API void srslte_vec_interleave_add_simd(const cf_t* x, const cf_t* y, cf_t* z, const int len); - -SRSLTE_API void srslte_vec_gen_sine_simd(cf_t amplitude, float freq, cf_t* z, int len); - -SRSLTE_API void srslte_vec_apply_cfo_simd(const cf_t* x, float cfo, cf_t* z, int len); - -SRSLTE_API float srslte_vec_estimate_frequency_simd(const cf_t* x, int len); - -/* SIMD Find Max functions */ -SRSLTE_API uint32_t srslte_vec_max_fi_simd(const float* x, const int len); - -SRSLTE_API uint32_t srslte_vec_max_abs_fi_simd(const float* x, const int len); - -SRSLTE_API uint32_t srslte_vec_max_ci_simd(const cf_t* x, const int len); - -#ifdef __cplusplus -} -#endif - -#endif // SRSLTE_VECTOR_SIMD_H diff --git a/lib/include/srslte/srslte.h b/lib/include/srslte/srslte.h deleted file mode 100644 index 8150d6ba6..000000000 --- a/lib/include/srslte/srslte.h +++ /dev/null @@ -1,135 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2020 Software Radio Systems Limited - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the distribution. - * - */ - -#ifndef SRSLTE_SRSLTE_H -#define SRSLTE_SRSLTE_H - -#ifdef __cplusplus -#include -extern "C" { -#else -#include -#endif - -#include - -#include "srslte/config.h" -#include "srslte/version.h" - -#include "srslte/phy/utils/bit.h" -#include "srslte/phy/utils/cexptab.h" -#include "srslte/phy/utils/convolution.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/ringbuffer.h" -#include "srslte/phy/utils/vector.h" - -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/common/sequence.h" -#include "srslte/phy/common/timestamp.h" -#include "srslte/phy/utils/phy_logger.h" - -#include "srslte/phy/ch_estimation/chest_dl.h" -#include "srslte/phy/ch_estimation/chest_ul.h" -#include "srslte/phy/ch_estimation/dmrs_pdcch.h" -#include "srslte/phy/ch_estimation/dmrs_sch.h" -#include "srslte/phy/ch_estimation/refsignal_dl.h" -#include "srslte/phy/ch_estimation/refsignal_ul.h" -#include "srslte/phy/ch_estimation/wiener_dl.h" - -#include "srslte/phy/resampling/decim.h" -#include "srslte/phy/resampling/interp.h" -#include "srslte/phy/resampling/resample_arb.h" - -#include "srslte/phy/channel/ch_awgn.h" - -#include "srslte/phy/dft/dft.h" -#include "srslte/phy/dft/dft_precoding.h" -#include "srslte/phy/dft/ofdm.h" -#include "srslte/phy/fec/cbsegm.h" -#include "srslte/phy/fec/convolutional/convcoder.h" -#include "srslte/phy/fec/convolutional/rm_conv.h" -#include "srslte/phy/fec/convolutional/viterbi.h" -#include "srslte/phy/fec/crc.h" -#include "srslte/phy/fec/turbo/rm_turbo.h" -#include "srslte/phy/fec/turbo/tc_interl.h" -#include "srslte/phy/fec/turbo/turbocoder.h" -#include "srslte/phy/fec/turbo/turbodecoder.h" - -#include "srslte/phy/io/binsource.h" -#include "srslte/phy/io/filesink.h" -#include "srslte/phy/io/filesource.h" -#include "srslte/phy/io/netsink.h" -#include "srslte/phy/io/netsource.h" - -#include "srslte/phy/modem/demod_hard.h" -#include "srslte/phy/modem/demod_soft.h" -#include "srslte/phy/modem/evm.h" -#include "srslte/phy/modem/mod.h" -#include "srslte/phy/modem/modem_table.h" - -#include "srslte/phy/mimo/layermap.h" -#include "srslte/phy/mimo/precoding.h" - -#include "srslte/phy/fec/softbuffer.h" -#include "srslte/phy/phch/cqi.h" -#include "srslte/phy/phch/csi.h" -#include "srslte/phy/phch/dci.h" -#include "srslte/phy/phch/dci_nr.h" -#include "srslte/phy/phch/pbch.h" -#include "srslte/phy/phch/pcfich.h" -#include "srslte/phy/phch/pdcch.h" -#include "srslte/phy/phch/pdcch_nr.h" -#include "srslte/phy/phch/pdsch.h" -#include "srslte/phy/phch/phich.h" -#include "srslte/phy/phch/prach.h" -#include "srslte/phy/phch/pucch.h" -#include "srslte/phy/phch/pucch_proc.h" -#include "srslte/phy/phch/pusch.h" -#include "srslte/phy/phch/ra.h" -#include "srslte/phy/phch/ra_dl.h" -#include "srslte/phy/phch/ra_dl_nr.h" -#include "srslte/phy/phch/ra_nr.h" -#include "srslte/phy/phch/ra_ul.h" -#include "srslte/phy/phch/ra_ul_nr.h" -#include "srslte/phy/phch/regs.h" -#include "srslte/phy/phch/sch.h" -#include "srslte/phy/phch/uci.h" -#include "srslte/phy/phch/uci_nr.h" - -#include "srslte/phy/ue/ue_cell_search.h" -#include "srslte/phy/ue/ue_dl.h" -#include "srslte/phy/ue/ue_dl_nr.h" -#include "srslte/phy/ue/ue_mib.h" -#include "srslte/phy/ue/ue_sync.h" -#include "srslte/phy/ue/ue_ul.h" -#include "srslte/phy/ue/ue_ul_nr.h" - -#include "srslte/phy/enb/enb_dl.h" -#include "srslte/phy/enb/enb_dl_nr.h" -#include "srslte/phy/enb/enb_ul.h" - -#include "srslte/phy/scrambling/scrambling.h" - -#include "srslte/phy/sync/cfo.h" -#include "srslte/phy/sync/cp.h" -#include "srslte/phy/sync/pss.h" -#include "srslte/phy/sync/refsignal_dl_sync.h" -#include "srslte/phy/sync/sfo.h" -#include "srslte/phy/sync/sss.h" -#include "srslte/phy/sync/sync.h" - -#ifdef __cplusplus -} -#undef I // Fix complex.h #define I nastiness when using C++ -#endif - -#endif // SRSLTE_SRSLTE_H diff --git a/lib/include/srslte/version.h.in b/lib/include/srslte/version.h.in deleted file mode 100644 index 7b84613cb..000000000 --- a/lib/include/srslte/version.h.in +++ /dev/null @@ -1,43 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2020 Software Radio Systems Limited - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the distribution. - * - */ - -#ifndef SRSLTE_VERSION_H_IN -#define SRSLTE_VERSION_H_IN - -// the configured options and settings for SRSLTE -#define SRSLTE_VERSION_MAJOR @SRSLTE_VERSION_MAJOR@ -#define SRSLTE_VERSION_MINOR @SRSLTE_VERSION_MINOR@ -#define SRSLTE_VERSION_PATCH @SRSLTE_VERSION_PATCH@ -#define SRSLTE_VERSION_STRING "@SRSLTE_VERSION_STRING@" - -#define SRSLTE_VERSION_ENCODE(major, minor, patch) ( \ - ((major) * 10000) \ - + ((minor) * 100) \ - + ((patch) * 1)) - -#define SRSLTE_VERSION SRSLTE_VERSION_ENCODE( \ - SRSLTE_VERSION_MAJOR, \ - SRSLTE_VERSION_MINOR, \ - SRSLTE_VERSION_PATCH) - -#define SRSLTE_VERSION_CHECK(major,minor,patch) \ - (SRSLTE_VERSION >= SRSLTE_VERSION_ENCODE(major,minor,patch)) - -#include "srslte/config.h" - -SRSLTE_API char* srslte_get_version(); -SRSLTE_API int srslte_get_version_major(); -SRSLTE_API int srslte_get_version_minor(); -SRSLTE_API int srslte_get_version_patch(); -SRSLTE_API int srslte_check_version(int major, int minor, int patch); - -#endif // VERSION_ diff --git a/lib/include/srslte/CMakeLists.txt b/lib/include/srsran/CMakeLists.txt similarity index 76% rename from lib/include/srslte/CMakeLists.txt rename to lib/include/srsran/CMakeLists.txt index 9ec00d537..5ca2e5ecc 100644 --- a/lib/include/srslte/CMakeLists.txt +++ b/lib/include/srsran/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -12,5 +12,5 @@ configure_file( ) INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/version.h - DESTINATION "${INCLUDE_DIR}/srslte" + DESTINATION "${INCLUDE_DIR}/srsran" ) diff --git a/lib/include/srslte/adt/accumulators.h b/lib/include/srsran/adt/accumulators.h similarity index 95% rename from lib/include/srslte/adt/accumulators.h rename to lib/include/srsran/adt/accumulators.h index 778edfeab..29b4ece6b 100644 --- a/lib/include/srslte/adt/accumulators.h +++ b/lib/include/srsran/adt/accumulators.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,8 +10,8 @@ * */ -#ifndef SRSLTE_ACCUMULATORS_H -#define SRSLTE_ACCUMULATORS_H +#ifndef SRSRAN_ACCUMULATORS_H +#define SRSRAN_ACCUMULATORS_H #include #include @@ -19,7 +19,7 @@ #include #include -namespace srslte { +namespace srsran { template struct rolling_average { @@ -152,6 +152,6 @@ private: T coeff; }; -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_ACCUMULATORS_H +#endif // SRSRAN_ACCUMULATORS_H diff --git a/lib/include/srslte/adt/adt_utils.h b/lib/include/srsran/adt/adt_utils.h similarity index 80% rename from lib/include/srslte/adt/adt_utils.h rename to lib/include/srsran/adt/adt_utils.h index f691a8278..98b816d77 100644 --- a/lib/include/srslte/adt/adt_utils.h +++ b/lib/include/srsran/adt/adt_utils.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,8 +10,8 @@ * */ -#ifndef SRSLTE_ADT_UTILS_H -#define SRSLTE_ADT_UTILS_H +#ifndef SRSRAN_ADT_UTILS_H +#define SRSRAN_ADT_UTILS_H #ifdef __EXCEPTIONS @@ -19,7 +19,7 @@ #define EXCEPTIONS_ENABLED 1 -namespace srslte { +namespace srsran { class bad_type_access : public std::runtime_error { @@ -30,7 +30,7 @@ public: #define THROW_BAD_ACCESS(msg) throw bad_type_access(msg) -} // namespace srslte +} // namespace srsran #else @@ -39,14 +39,14 @@ public: #include #include -namespace srslte { +namespace srsran { #define THROW_BAD_ACCESS(msg) \ std::fprintf(stderr, "ERROR: exception thrown with %s", msg); \ std::abort() -} // namespace srslte +} // namespace srsran #endif -#endif // SRSLTE_ADT_UTILS_H +#endif // SRSRAN_ADT_UTILS_H diff --git a/lib/include/srslte/adt/bounded_bitset.h b/lib/include/srsran/adt/bounded_bitset.h similarity index 96% rename from lib/include/srslte/adt/bounded_bitset.h rename to lib/include/srsran/adt/bounded_bitset.h index 1afdd6123..ed86c23d8 100644 --- a/lib/include/srslte/adt/bounded_bitset.h +++ b/lib/include/srsran/adt/bounded_bitset.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,16 +10,16 @@ * */ -#ifndef SRSLTE_DYN_BITSET_H -#define SRSLTE_DYN_BITSET_H +#ifndef SRSRAN_DYN_BITSET_H +#define SRSRAN_DYN_BITSET_H #include "adt_utils.h" -#include "srslte/srslog/bundled/fmt/format.h" +#include "srsran/srslog/bundled/fmt/format.h" #include #include #include -namespace srslte { +namespace srsran { constexpr uint32_t ceil_div(uint32_t x, uint32_t y) { @@ -352,12 +352,12 @@ inline bounded_bitset fliplr(const bounded_bitset& oth return ret; } -} // namespace srslte +} // namespace srsran namespace fmt { /// Custom formatter for bounded_bitset template -struct formatter > { +struct formatter > { enum { hexadecimal, binary } mode = binary; template @@ -375,7 +375,7 @@ struct formatter > { } template - auto format(const srslte::bounded_bitset& s, FormatContext& ctx) + auto format(const srsran::bounded_bitset& s, FormatContext& ctx) -> decltype(std::declval().out()) { if (mode == hexadecimal) { @@ -386,4 +386,4 @@ struct formatter > { }; } // namespace fmt -#endif // SRSLTE_DYN_BITSET_H +#endif // SRSRAN_DYN_BITSET_H diff --git a/lib/include/srslte/adt/bounded_vector.h b/lib/include/srsran/adt/bounded_vector.h similarity index 97% rename from lib/include/srslte/adt/bounded_vector.h rename to lib/include/srsran/adt/bounded_vector.h index f642f4429..e33a4286d 100644 --- a/lib/include/srslte/adt/bounded_vector.h +++ b/lib/include/srsran/adt/bounded_vector.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,15 +10,15 @@ * */ -#ifndef SRSLTE_BOUNDED_VECTOR_H -#define SRSLTE_BOUNDED_VECTOR_H +#ifndef SRSRAN_BOUNDED_VECTOR_H +#define SRSRAN_BOUNDED_VECTOR_H #include #include #include #include -namespace srslte { +namespace srsran { template class bounded_vector @@ -234,6 +234,6 @@ private: std::size_t size_ = 0; typename std::aligned_storage::type buffer[MAX_N]; }; -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_BOUNDED_VECTOR_H +#endif // SRSRAN_BOUNDED_VECTOR_H diff --git a/lib/include/srslte/adt/choice_type.h b/lib/include/srsran/adt/choice_type.h similarity index 96% rename from lib/include/srslte/adt/choice_type.h rename to lib/include/srsran/adt/choice_type.h index 9e21584ce..1fbfd47f0 100644 --- a/lib/include/srslte/adt/choice_type.h +++ b/lib/include/srsran/adt/choice_type.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,12 +10,12 @@ * */ -#include "srslte/adt/detail/type_utils.h" +#include "srsran/adt/detail/type_utils.h" -#ifndef SRSLTE_CHOICE_TYPE_H -#define SRSLTE_CHOICE_TYPE_H +#ifndef SRSRAN_CHOICE_TYPE_H +#define SRSRAN_CHOICE_TYPE_H -namespace srslte { +namespace srsran { //! Compute maximum at compile time template @@ -231,6 +231,6 @@ public: bool holds_same_type(const choice_t& other) noexcept { return base_t::type_id == other.type_id; } }; -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_CHOICE_TYPE_H +#endif // SRSRAN_CHOICE_TYPE_H diff --git a/lib/include/srslte/adt/circular_array.h b/lib/include/srsran/adt/circular_array.h similarity index 84% rename from lib/include/srslte/adt/circular_array.h rename to lib/include/srsran/adt/circular_array.h index 8f435ac06..1311eb272 100644 --- a/lib/include/srslte/adt/circular_array.h +++ b/lib/include/srsran/adt/circular_array.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,8 +10,8 @@ * */ -#ifndef SRSLTE_CIRCULAR_ARRAY_H -#define SRSLTE_CIRCULAR_ARRAY_H +#ifndef SRSRAN_CIRCULAR_ARRAY_H +#define SRSRAN_CIRCULAR_ARRAY_H #include #include @@ -28,7 +28,7 @@ * This is useful for circular data structures, like TTIs or SNs. */ -namespace srslte { +namespace srsran { template class circular_array @@ -51,6 +51,6 @@ public: size_t size() const { return N; } }; -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_CIRCULAR_ARRAY_H +#endif // SRSRAN_CIRCULAR_ARRAY_H diff --git a/lib/include/srslte/adt/circular_buffer.h b/lib/include/srsran/adt/circular_buffer.h similarity index 96% rename from lib/include/srslte/adt/circular_buffer.h rename to lib/include/srsran/adt/circular_buffer.h index 84c3f40d5..3b8da7a44 100644 --- a/lib/include/srslte/adt/circular_buffer.h +++ b/lib/include/srsran/adt/circular_buffer.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,10 +10,10 @@ * */ -#ifndef SRSLTE_CIRCULAR_BUFFER_H -#define SRSLTE_CIRCULAR_BUFFER_H +#ifndef SRSRAN_CIRCULAR_BUFFER_H +#define SRSRAN_CIRCULAR_BUFFER_H -#include "srslte/adt/expected.h" +#include "srsran/adt/expected.h" #include #include @@ -23,7 +23,7 @@ #include #include -namespace srslte { +namespace srsran { namespace detail { @@ -209,9 +209,9 @@ public: } bool try_push(const T& t) { return push_(t, false); } - srslte::error_type try_push(T&& t) { return push_(std::move(t), false); } + srsran::error_type try_push(T&& t) { return push_(std::move(t), false); } bool push_blocking(const T& t) { return push_(t, true); } - srslte::error_type push_blocking(T&& t) { return push_(std::move(t), true); } + srsran::error_type push_blocking(T&& t) { return push_(std::move(t), true); } bool try_pop(T& obj) { return pop_(obj, false); } T pop_blocking() { @@ -300,7 +300,7 @@ protected: cvar_empty.notify_one(); return true; } - srslte::error_type push_(T&& t, bool block_mode) + srsran::error_type push_(T&& t, bool block_mode) { std::unique_lock lock(mutex); if (not active) { @@ -445,6 +445,6 @@ public: void set_size(size_t size) { base_t::circ_buffer.set_size(size); } }; -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_CIRCULAR_BUFFER_H +#endif // SRSRAN_CIRCULAR_BUFFER_H diff --git a/lib/include/srslte/adt/detail/index_sequence.h b/lib/include/srsran/adt/detail/index_sequence.h similarity index 88% rename from lib/include/srslte/adt/detail/index_sequence.h rename to lib/include/srsran/adt/detail/index_sequence.h index 35af029f0..241d4e8c2 100644 --- a/lib/include/srslte/adt/detail/index_sequence.h +++ b/lib/include/srsran/adt/detail/index_sequence.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,7 +13,7 @@ #ifndef CPP_TESTS_INDEX_SEQUENCE_H #define CPP_TESTS_INDEX_SEQUENCE_H -namespace srslte { +namespace srsran { template struct index_sequence {}; @@ -29,6 +29,6 @@ struct index_sequence_helper<0U, Next...> { template using make_index_sequence = typename index_sequence_helper::type; -} // namespace srslte +} // namespace srsran #endif // CPP_TESTS_INDEX_SEQUENCE_H diff --git a/lib/include/srslte/adt/detail/type_utils.h b/lib/include/srsran/adt/detail/type_utils.h similarity index 97% rename from lib/include/srslte/adt/detail/type_utils.h rename to lib/include/srsran/adt/detail/type_utils.h index 3efaa7861..6a42f966a 100644 --- a/lib/include/srslte/adt/detail/type_utils.h +++ b/lib/include/srsran/adt/detail/type_utils.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,17 +10,17 @@ * */ -#ifndef SRSLTE_TYPE_UTILS_H -#define SRSLTE_TYPE_UTILS_H +#ifndef SRSRAN_TYPE_UTILS_H +#define SRSRAN_TYPE_UTILS_H -#include "srslte/adt/expected.h" +#include "srsran/adt/expected.h" #include #include #include #include #include -namespace srslte { +namespace srsran { /************************************ * get_type_name methods @@ -255,7 +255,7 @@ using invoke_result_t = typename std::result_of::type; } // namespace type_utils -//! srslte::get access methods +//! srsran::get access methods template T* get_if(TypeContainer& c) { @@ -332,6 +332,6 @@ void visit(Visitor&& f, const TypeSet& tset) visit_impl, Args...>::apply(tset, std::forward(f)); } -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_TYPE_UTILS_H +#endif // SRSRAN_TYPE_UTILS_H diff --git a/lib/include/srslte/adt/expected.h b/lib/include/srsran/adt/expected.h similarity index 95% rename from lib/include/srslte/adt/expected.h rename to lib/include/srsran/adt/expected.h index 4f8f75967..4842e45e1 100644 --- a/lib/include/srslte/adt/expected.h +++ b/lib/include/srsran/adt/expected.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,14 +10,14 @@ * */ -#ifndef SRSLTE_EXPECTED_H -#define SRSLTE_EXPECTED_H +#ifndef SRSRAN_EXPECTED_H +#define SRSRAN_EXPECTED_H #include "adt_utils.h" #include #include -namespace srslte { +namespace srsran { struct default_error_t {}; @@ -189,6 +189,6 @@ private: template using error_type = expected; -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_EXPECTED_H +#endif // SRSRAN_EXPECTED_H diff --git a/lib/include/srslte/adt/interval.h b/lib/include/srsran/adt/interval.h similarity index 90% rename from lib/include/srslte/adt/interval.h rename to lib/include/srsran/adt/interval.h index b0c4761b4..6724b47f9 100644 --- a/lib/include/srslte/adt/interval.h +++ b/lib/include/srsran/adt/interval.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,16 +10,16 @@ * */ -#ifndef SRSLTE_INTERVAL_H -#define SRSLTE_INTERVAL_H +#ifndef SRSRAN_INTERVAL_H +#define SRSRAN_INTERVAL_H #include "adt_utils.h" -#include "srslte/srslog/bundled/fmt/format.h" +#include "srsran/srslog/bundled/fmt/format.h" #include #include #include -namespace srslte { +namespace srsran { /// Representation of an interval between two numeric-types in the math representation [start, stop) template @@ -132,14 +132,14 @@ interval make_intersection(const interval& lhs, const interval& rhs) return lhs & rhs; } -} // namespace srslte +} // namespace srsran namespace fmt { template -struct formatter > : public formatter { +struct formatter > : public formatter { template - auto format(const srslte::interval& interv, FormatContext& ctx) -> decltype(std::declval().out()) + auto format(const srsran::interval& interv, FormatContext& ctx) -> decltype(std::declval().out()) { return format_to(ctx.out(), "[{}, {})", interv.start(), interv.stop()); } @@ -147,4 +147,4 @@ struct formatter > : public formatter { } // namespace fmt -#endif // SRSLTE_INTERVAL_H +#endif // SRSRAN_INTERVAL_H diff --git a/lib/include/srslte/adt/mem_pool.h b/lib/include/srsran/adt/mem_pool.h similarity index 97% rename from lib/include/srslte/adt/mem_pool.h rename to lib/include/srsran/adt/mem_pool.h index 935e6a733..abe826481 100644 --- a/lib/include/srslte/adt/mem_pool.h +++ b/lib/include/srsran/adt/mem_pool.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,16 +10,16 @@ * */ -#ifndef SRSLTE_MEM_POOL_H -#define SRSLTE_MEM_POOL_H +#ifndef SRSRAN_MEM_POOL_H +#define SRSRAN_MEM_POOL_H -#include "srslte/common/thread_pool.h" +#include "srsran/common/thread_pool.h" #include #include #include #include -namespace srslte { +namespace srsran { /// Stores provided mem blocks in a stack in an non-owning manner. Not thread-safe class memblock_stack @@ -288,6 +288,6 @@ private: std::vector > batches; }; -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_MEM_POOL_H +#endif // SRSRAN_MEM_POOL_H diff --git a/lib/include/srslte/adt/move_callback.h b/lib/include/srsran/adt/move_callback.h similarity index 97% rename from lib/include/srslte/adt/move_callback.h rename to lib/include/srsran/adt/move_callback.h index a1b2f920c..1ea0129b3 100644 --- a/lib/include/srslte/adt/move_callback.h +++ b/lib/include/srsran/adt/move_callback.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,8 +10,8 @@ * */ -#ifndef SRSLTE_MOVE_CALLBACK_H -#define SRSLTE_MOVE_CALLBACK_H +#ifndef SRSRAN_MOVE_CALLBACK_H +#define SRSRAN_MOVE_CALLBACK_H #include #include @@ -29,7 +29,7 @@ std::abort() #endif -namespace srslte { +namespace srsran { // NOTE: gcc 4.8.5 is missing std::max_align_t. Need to create a struct union max_alignment_t { @@ -189,6 +189,6 @@ constexpr task_details::empty_table_t move_callback; -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_MOVE_CALLBACK_H +#endif // SRSRAN_MOVE_CALLBACK_H diff --git a/lib/include/srslte/adt/observer.h b/lib/include/srsran/adt/observer.h similarity index 97% rename from lib/include/srslte/adt/observer.h rename to lib/include/srsran/adt/observer.h index 6ae312f39..a0498557b 100644 --- a/lib/include/srslte/adt/observer.h +++ b/lib/include/srsran/adt/observer.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,15 +10,15 @@ * */ -#ifndef SRSLTE_OBSERVER_H -#define SRSLTE_OBSERVER_H +#ifndef SRSRAN_OBSERVER_H +#define SRSRAN_OBSERVER_H #include #include #include #include -namespace srslte { +namespace srsran { using observer_id = std::size_t; const size_t invalid_observer_id = std::numeric_limits::max(); @@ -229,6 +229,6 @@ private: observer_id id; }; -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_OBSERVER_H +#endif // SRSRAN_OBSERVER_H diff --git a/lib/include/srslte/adt/scope_exit.h b/lib/include/srsran/adt/scope_exit.h similarity index 88% rename from lib/include/srslte/adt/scope_exit.h rename to lib/include/srsran/adt/scope_exit.h index d197c8695..37af5148c 100644 --- a/lib/include/srslte/adt/scope_exit.h +++ b/lib/include/srsran/adt/scope_exit.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,13 +10,13 @@ * */ -#ifndef SRSLTE_SCOPE_EXIT_H -#define SRSLTE_SCOPE_EXIT_H +#ifndef SRSRAN_SCOPE_EXIT_H +#define SRSRAN_SCOPE_EXIT_H #include #include -namespace srslte { +namespace srsran { namespace detail { @@ -62,6 +62,6 @@ detail::scope_exit::type> make_scope_exit(Callable #define DEFER(FUNC) auto on_exit_call = make_scope_exit([&]() { FUNC }) -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_SCOPE_EXIT_H +#endif // SRSRAN_SCOPE_EXIT_H diff --git a/lib/include/srslte/adt/span.h b/lib/include/srsran/adt/span.h similarity index 98% rename from lib/include/srslte/adt/span.h rename to lib/include/srsran/adt/span.h index d76515fa8..bf37a458a 100644 --- a/lib/include/srslte/adt/span.h +++ b/lib/include/srsran/adt/span.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,8 +10,8 @@ * */ -#ifndef SRSLTE_SPAN_H -#define SRSLTE_SPAN_H +#ifndef SRSRAN_SPAN_H +#define SRSRAN_SPAN_H #include #include @@ -20,7 +20,7 @@ #include #include -namespace srslte { +namespace srsran { template class span; @@ -235,6 +235,6 @@ inline bool operator!=(span lhs, span rhs) template using const_span = span; -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_SPAN_H +#endif // SRSRAN_SPAN_H diff --git a/lib/include/srslte/asn1/asn1_utils.h b/lib/include/srsran/asn1/asn1_utils.h similarity index 99% rename from lib/include/srslte/asn1/asn1_utils.h rename to lib/include/srsran/asn1/asn1_utils.h index 1cba3b775..60950b6c8 100644 --- a/lib/include/srslte/asn1/asn1_utils.h +++ b/lib/include/srsran/asn1/asn1_utils.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,7 +13,7 @@ #ifndef SRSASN_COMMON_UTILS_H #define SRSASN_COMMON_UTILS_H -#include "srslte/srslog/srslog.h" +#include "srsran/srslog/srslog.h" #include #include #include diff --git a/lib/include/srslte/asn1/gtpc.h b/lib/include/srsran/asn1/gtpc.h similarity index 93% rename from lib/include/srslte/asn1/gtpc.h rename to lib/include/srsran/asn1/gtpc.h index 37cfc7db9..4d32ea0bc 100644 --- a/lib/include/srslte/asn1/gtpc.h +++ b/lib/include/srsran/asn1/gtpc.h @@ -2,20 +2,20 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of * the distribution. * */ -#ifndef SRSLTE_GTPC_H -#define SRSLTE_GTPC_H +#ifndef SRSRAN_GTPC_H +#define SRSRAN_GTPC_H -#include "srslte/asn1/gtpc_msg.h" +#include "srsran/asn1/gtpc_msg.h" #include -namespace srslte { +namespace srsran { /*GTP-C Version*/ const uint8_t GTPC_V2 = 2; @@ -80,5 +80,5 @@ typedef struct gtpc_pdu { struct gtpc_header header; union gtpc_msg_choice choice; } gtpc_pdu_t; -} // namespace srslte -#endif // SRSLTE_GTPC_H +} // namespace srsran +#endif // SRSRAN_GTPC_H diff --git a/lib/include/srslte/asn1/gtpc_ies.h b/lib/include/srsran/asn1/gtpc_ies.h similarity index 98% rename from lib/include/srslte/asn1/gtpc_ies.h rename to lib/include/srsran/asn1/gtpc_ies.h index 18ba1d1cd..88a845fa2 100644 --- a/lib/include/srslte/asn1/gtpc_ies.h +++ b/lib/include/srsran/asn1/gtpc_ies.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,12 +10,12 @@ * */ -#ifndef SRSLTE_GTPC_IES_H -#define SRSLTE_GTPC_IES_H +#ifndef SRSRAN_GTPC_IES_H +#define SRSRAN_GTPC_IES_H -#include "srslte/phy/io/netsource.h" +#include "srsran/phy/io/netsource.h" -namespace srslte { +namespace srsran { /**************************************************************** * @@ -413,5 +413,5 @@ typedef struct gtpc_f_teid_ie { // As such, each GTP-C message will define it's bearer context structures // locally, according to the rules of TS 29.274 v10.14.0 Section 7. -} // namespace srslte -#endif // SRSLTE_GTPC_IES_H +} // namespace srsran +#endif // SRSRAN_GTPC_IES_H diff --git a/lib/include/srslte/asn1/gtpc_msg.h b/lib/include/srsran/asn1/gtpc_msg.h similarity index 98% rename from lib/include/srslte/asn1/gtpc_msg.h rename to lib/include/srsran/asn1/gtpc_msg.h index 16c756225..14b28691e 100644 --- a/lib/include/srslte/asn1/gtpc_msg.h +++ b/lib/include/srsran/asn1/gtpc_msg.h @@ -2,19 +2,19 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of * the distribution. * */ -#ifndef SRSLTE_GTPC_MSG_H -#define SRSLTE_GTPC_MSG_H +#ifndef SRSRAN_GTPC_MSG_H +#define SRSRAN_GTPC_MSG_H -#include "srslte/asn1/gtpc_ies.h" +#include "srsran/asn1/gtpc_ies.h" -namespace srslte { +namespace srsran { /**************************************************************** * @@ -455,5 +455,5 @@ struct gtpc_release_access_bearers_response { // Private extension }; -} // namespace srslte -#endif // SRSLTE_GTPC_MSG_H +} // namespace srsran +#endif // SRSRAN_GTPC_MSG_H diff --git a/lib/include/srslte/asn1/liblte_common.h b/lib/include/srsran/asn1/liblte_common.h similarity index 97% rename from lib/include/srslte/asn1/liblte_common.h rename to lib/include/srsran/asn1/liblte_common.h index 30cd73bd2..11116adb0 100644 --- a/lib/include/srslte/asn1/liblte_common.h +++ b/lib/include/srsran/asn1/liblte_common.h @@ -10,8 +10,8 @@ * */ -#ifndef SRSLTE_LIBLTE_COMMON_H -#define SRSLTE_LIBLTE_COMMON_H +#ifndef SRSRAN_LIBLTE_COMMON_H +#define SRSRAN_LIBLTE_COMMON_H /******************************************************************************* INCLUDES @@ -29,7 +29,7 @@ // TODO: This was chosen arbitrarily #define LIBLTE_ASN1_OID_MAXSUBIDS 128 -// Caution these values must match SRSLTE_ ones in common.h +// Caution these values must match SRSRAN_ ones in common.h #define LIBLTE_MAX_MSG_SIZE_BITS 102048 #define LIBLTE_MAX_MSG_SIZE_BYTES 12237 #define LIBLTE_MSG_HEADER_OFFSET 1020 @@ -154,4 +154,4 @@ void liblte_align_up(uint8_t** ptr, uint32_t align); *********************************************************************/ void liblte_align_up_zero(uint8_t** ptr, uint32_t align); -#endif // SRSLTE_LIBLTE_COMMON_H +#endif // SRSRAN_LIBLTE_COMMON_H diff --git a/lib/include/srslte/asn1/liblte_mme.h b/lib/include/srsran/asn1/liblte_mme.h similarity index 99% rename from lib/include/srslte/asn1/liblte_mme.h rename to lib/include/srsran/asn1/liblte_mme.h index 9bab6d57f..f8ba5b5e1 100644 --- a/lib/include/srslte/asn1/liblte_mme.h +++ b/lib/include/srsran/asn1/liblte_mme.h @@ -11,8 +11,8 @@ * */ -#ifndef SRSLTE_LIBLTE_MME_H -#define SRSLTE_LIBLTE_MME_H +#ifndef SRSRAN_LIBLTE_MME_H +#define SRSRAN_LIBLTE_MME_H /******************************************************************************* INCLUDES @@ -3672,7 +3672,7 @@ typedef struct { } LIBLTE_MME_ESM_INFORMATION_REQUEST_MSG_STRUCT; // Functions LIBLTE_ERROR_ENUM -srslte_mme_pack_esm_information_request_msg(LIBLTE_MME_ESM_INFORMATION_REQUEST_MSG_STRUCT* esm_info_req, +srsran_mme_pack_esm_information_request_msg(LIBLTE_MME_ESM_INFORMATION_REQUEST_MSG_STRUCT* esm_info_req, uint8 sec_hdr_type, uint32 count, LIBLTE_BYTE_MSG_STRUCT* msg); @@ -3713,7 +3713,7 @@ LIBLTE_ERROR_ENUM liblte_mme_unpack_esm_information_response_msg(LIBLTE_BYTE_MSG_STRUCT* msg, LIBLTE_MME_ESM_INFORMATION_RESPONSE_MSG_STRUCT* esm_info_resp); LIBLTE_ERROR_ENUM -srslte_mme_unpack_esm_information_response_msg(LIBLTE_BYTE_MSG_STRUCT* msg, +srsran_mme_unpack_esm_information_response_msg(LIBLTE_BYTE_MSG_STRUCT* msg, LIBLTE_MME_ESM_INFORMATION_RESPONSE_MSG_STRUCT* esm_info_resp); /********************************************************************* @@ -4013,4 +4013,4 @@ static const char liblte_ue_test_loop_mode_text[LIBLTE_MME_UE_TEST_LOOP_MODE_N_I LIBLTE_ERROR_ENUM liblte_mme_pack_close_ue_test_loop_complete_msg(LIBLTE_BYTE_MSG_STRUCT* msg, uint8 sec_hdr_type, uint32 count); -#endif // SRSLTE_LIBLTE_MME_H +#endif // SRSRAN_LIBLTE_MME_H diff --git a/lib/include/srslte/asn1/ngap.h b/lib/include/srsran/asn1/ngap.h similarity index 99% rename from lib/include/srslte/asn1/ngap.h rename to lib/include/srsran/asn1/ngap.h index 7f9304a91..eb4fe53ff 100644 --- a/lib/include/srslte/asn1/ngap.h +++ b/lib/include/srsran/asn1/ngap.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/lib/include/srslte/asn1/rrc.h b/lib/include/srsran/asn1/rrc.h similarity index 99% rename from lib/include/srslte/asn1/rrc.h rename to lib/include/srsran/asn1/rrc.h index b31e98a42..6d1986da7 100644 --- a/lib/include/srslte/asn1/rrc.h +++ b/lib/include/srsran/asn1/rrc.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/lib/include/srslte/asn1/rrc/bcch_msg.h b/lib/include/srsran/asn1/rrc/bcch_msg.h similarity index 99% rename from lib/include/srslte/asn1/rrc/bcch_msg.h rename to lib/include/srsran/asn1/rrc/bcch_msg.h index 36e7fef1e..ae334258a 100644 --- a/lib/include/srslte/asn1/rrc/bcch_msg.h +++ b/lib/include/srsran/asn1/rrc/bcch_msg.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/lib/include/srslte/asn1/rrc/common.h b/lib/include/srsran/asn1/rrc/common.h similarity index 99% rename from lib/include/srslte/asn1/rrc/common.h rename to lib/include/srsran/asn1/rrc/common.h index 41511dec6..f8e3cc51f 100644 --- a/lib/include/srslte/asn1/rrc/common.h +++ b/lib/include/srsran/asn1/rrc/common.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -19,7 +19,7 @@ #ifndef SRSASN1_RRC_COMMON_H #define SRSASN1_RRC_COMMON_H -#include "srslte/asn1/asn1_utils.h" +#include "srsran/asn1/asn1_utils.h" #include #include diff --git a/lib/include/srslte/asn1/rrc/common_ext.h b/lib/include/srsran/asn1/rrc/common_ext.h similarity index 99% rename from lib/include/srslte/asn1/rrc/common_ext.h rename to lib/include/srsran/asn1/rrc/common_ext.h index 77d0235d1..6c93d14fb 100644 --- a/lib/include/srslte/asn1/rrc/common_ext.h +++ b/lib/include/srsran/asn1/rrc/common_ext.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/lib/include/srslte/asn1/rrc/dl_ccch_msg.h b/lib/include/srsran/asn1/rrc/dl_ccch_msg.h similarity index 99% rename from lib/include/srslte/asn1/rrc/dl_ccch_msg.h rename to lib/include/srsran/asn1/rrc/dl_ccch_msg.h index fc99cfb9b..87e7370ff 100644 --- a/lib/include/srslte/asn1/rrc/dl_ccch_msg.h +++ b/lib/include/srsran/asn1/rrc/dl_ccch_msg.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/lib/include/srslte/asn1/rrc/dl_dcch_msg.h b/lib/include/srsran/asn1/rrc/dl_dcch_msg.h similarity index 99% rename from lib/include/srslte/asn1/rrc/dl_dcch_msg.h rename to lib/include/srsran/asn1/rrc/dl_dcch_msg.h index 9334ea7f0..5f96f322d 100644 --- a/lib/include/srslte/asn1/rrc/dl_dcch_msg.h +++ b/lib/include/srsran/asn1/rrc/dl_dcch_msg.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/lib/include/srslte/asn1/rrc/ho_cmd.h b/lib/include/srsran/asn1/rrc/ho_cmd.h similarity index 99% rename from lib/include/srslte/asn1/rrc/ho_cmd.h rename to lib/include/srsran/asn1/rrc/ho_cmd.h index 263e41de0..e449de138 100644 --- a/lib/include/srslte/asn1/rrc/ho_cmd.h +++ b/lib/include/srsran/asn1/rrc/ho_cmd.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/lib/include/srslte/asn1/rrc/meascfg.h b/lib/include/srsran/asn1/rrc/meascfg.h similarity index 99% rename from lib/include/srslte/asn1/rrc/meascfg.h rename to lib/include/srsran/asn1/rrc/meascfg.h index 7e6d1c50c..7b8284548 100644 --- a/lib/include/srslte/asn1/rrc/meascfg.h +++ b/lib/include/srsran/asn1/rrc/meascfg.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/lib/include/srslte/asn1/rrc/paging.h b/lib/include/srsran/asn1/rrc/paging.h similarity index 99% rename from lib/include/srslte/asn1/rrc/paging.h rename to lib/include/srsran/asn1/rrc/paging.h index 7f521eebc..a753e7ca8 100644 --- a/lib/include/srslte/asn1/rrc/paging.h +++ b/lib/include/srsran/asn1/rrc/paging.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/lib/include/srslte/asn1/rrc/phy_ded.h b/lib/include/srsran/asn1/rrc/phy_ded.h similarity index 99% rename from lib/include/srslte/asn1/rrc/phy_ded.h rename to lib/include/srsran/asn1/rrc/phy_ded.h index faf5b1815..6f70ae838 100644 --- a/lib/include/srslte/asn1/rrc/phy_ded.h +++ b/lib/include/srsran/asn1/rrc/phy_ded.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/lib/include/srslte/asn1/rrc/rr_common.h b/lib/include/srsran/asn1/rrc/rr_common.h similarity index 99% rename from lib/include/srslte/asn1/rrc/rr_common.h rename to lib/include/srsran/asn1/rrc/rr_common.h index 708808ffd..96b46b45c 100644 --- a/lib/include/srslte/asn1/rrc/rr_common.h +++ b/lib/include/srsran/asn1/rrc/rr_common.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/lib/include/srslte/asn1/rrc/rr_ded.h b/lib/include/srsran/asn1/rrc/rr_ded.h similarity index 99% rename from lib/include/srslte/asn1/rrc/rr_ded.h rename to lib/include/srsran/asn1/rrc/rr_ded.h index ca8cd4b06..8fc2f6993 100644 --- a/lib/include/srslte/asn1/rrc/rr_ded.h +++ b/lib/include/srsran/asn1/rrc/rr_ded.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/lib/include/srslte/asn1/rrc/rrc_asn1.h b/lib/include/srsran/asn1/rrc/rrc_asn1.h similarity index 99% rename from lib/include/srslte/asn1/rrc/rrc_asn1.h rename to lib/include/srsran/asn1/rrc/rrc_asn1.h index ed2fa3e56..cefd7f97d 100644 --- a/lib/include/srslte/asn1/rrc/rrc_asn1.h +++ b/lib/include/srsran/asn1/rrc/rrc_asn1.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/lib/include/srslte/asn1/rrc/security.h b/lib/include/srsran/asn1/rrc/security.h similarity index 99% rename from lib/include/srslte/asn1/rrc/security.h rename to lib/include/srsran/asn1/rrc/security.h index a01ab04bb..23bfc3c39 100644 --- a/lib/include/srslte/asn1/rrc/security.h +++ b/lib/include/srsran/asn1/rrc/security.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/lib/include/srslte/asn1/rrc/si.h b/lib/include/srsran/asn1/rrc/si.h similarity index 99% rename from lib/include/srslte/asn1/rrc/si.h rename to lib/include/srsran/asn1/rrc/si.h index 2d223f223..303fec6d6 100644 --- a/lib/include/srslte/asn1/rrc/si.h +++ b/lib/include/srsran/asn1/rrc/si.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/lib/include/srslte/asn1/rrc/uecap.h b/lib/include/srsran/asn1/rrc/uecap.h similarity index 99% rename from lib/include/srslte/asn1/rrc/uecap.h rename to lib/include/srsran/asn1/rrc/uecap.h index fc1cdecf6..405dc5571 100644 --- a/lib/include/srslte/asn1/rrc/uecap.h +++ b/lib/include/srsran/asn1/rrc/uecap.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/lib/include/srslte/asn1/rrc/ul_ccch_msg.h b/lib/include/srsran/asn1/rrc/ul_ccch_msg.h similarity index 99% rename from lib/include/srslte/asn1/rrc/ul_ccch_msg.h rename to lib/include/srsran/asn1/rrc/ul_ccch_msg.h index ceacd0b1a..6d2c00165 100644 --- a/lib/include/srslte/asn1/rrc/ul_ccch_msg.h +++ b/lib/include/srsran/asn1/rrc/ul_ccch_msg.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/lib/include/srslte/asn1/rrc/ul_dcch_msg.h b/lib/include/srsran/asn1/rrc/ul_dcch_msg.h similarity index 99% rename from lib/include/srslte/asn1/rrc/ul_dcch_msg.h rename to lib/include/srsran/asn1/rrc/ul_dcch_msg.h index 1665cc69e..82ae8a64a 100644 --- a/lib/include/srslte/asn1/rrc/ul_dcch_msg.h +++ b/lib/include/srsran/asn1/rrc/ul_dcch_msg.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/lib/include/srslte/asn1/rrc_nbiot.h b/lib/include/srsran/asn1/rrc_nbiot.h similarity index 99% rename from lib/include/srslte/asn1/rrc_nbiot.h rename to lib/include/srsran/asn1/rrc_nbiot.h index de1d82d09..b1503d29a 100644 --- a/lib/include/srslte/asn1/rrc_nbiot.h +++ b/lib/include/srsran/asn1/rrc_nbiot.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/lib/include/srslte/asn1/rrc_nr.h b/lib/include/srsran/asn1/rrc_nr.h similarity index 99% rename from lib/include/srslte/asn1/rrc_nr.h rename to lib/include/srsran/asn1/rrc_nr.h index b80feb725..f20621108 100644 --- a/lib/include/srslte/asn1/rrc_nr.h +++ b/lib/include/srsran/asn1/rrc_nr.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/lib/include/srslte/asn1/rrc_nr_utils.h b/lib/include/srsran/asn1/rrc_nr_utils.h similarity index 76% rename from lib/include/srslte/asn1/rrc_nr_utils.h rename to lib/include/srsran/asn1/rrc_nr_utils.h index b0d0773f1..df4263a48 100644 --- a/lib/include/srslte/asn1/rrc_nr_utils.h +++ b/lib/include/srsran/asn1/rrc_nr_utils.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,14 +10,14 @@ * */ -#ifndef SRSLTE_RRC_NR_UTILS_H -#define SRSLTE_RRC_NR_UTILS_H +#ifndef SRSRAN_RRC_NR_UTILS_H +#define SRSRAN_RRC_NR_UTILS_H -#include "srslte/interfaces/mac_interface_types.h" -#include "srslte/interfaces/pdcp_interface_types.h" -#include "srslte/interfaces/rlc_interface_types.h" -#include "srslte/interfaces/rrc_interface_types.h" -#include "srslte/interfaces/sched_interface.h" +#include "srsran/interfaces/mac_interface_types.h" +#include "srsran/interfaces/pdcp_interface_types.h" +#include "srsran/interfaces/rlc_interface_types.h" +#include "srsran/interfaces/rrc_interface_types.h" +#include "srsran/interfaces/sched_interface.h" /************************ * Forward declarations @@ -38,7 +38,7 @@ struct rach_cfg_common_s; /************************ * Conversion Helpers ***********************/ -namespace srslte { +namespace srsran { plmn_id_t make_plmn_id_t(const asn1::rrc_nr::plmn_id_s& asn1_type); void to_asn1(asn1::rrc_nr::plmn_id_s* asn1_type, const plmn_id_t& cfg); @@ -58,11 +58,11 @@ rlc_config_t make_rlc_config_t(const asn1::rrc_nr::rlc_cfg_c& asn1_type); **************************/ pdcp_config_t make_drb_pdcp_config_t(const uint8_t bearer_id, bool is_ue, const asn1::rrc_nr::pdcp_cfg_s& pdcp_cfg); -} // namespace srslte +} // namespace srsran namespace srsenb { int set_sched_cell_cfg_sib1(srsenb::sched_interface::cell_cfg_t* sched_cfg, const asn1::rrc_nr::sib1_s& sib1); } -#endif // SRSLTE_RRC_NR_UTILS_H +#endif // SRSRAN_RRC_NR_UTILS_H diff --git a/lib/include/srslte/asn1/rrc_utils.h b/lib/include/srsran/asn1/rrc_utils.h similarity index 91% rename from lib/include/srslte/asn1/rrc_utils.h rename to lib/include/srsran/asn1/rrc_utils.h index 261a21d94..18d4a4b4a 100644 --- a/lib/include/srslte/asn1/rrc_utils.h +++ b/lib/include/srsran/asn1/rrc_utils.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,14 +10,14 @@ * */ -#ifndef SRSLTE_RRC_UTILS_H -#define SRSLTE_RRC_UTILS_H +#ifndef SRSRAN_RRC_UTILS_H +#define SRSRAN_RRC_UTILS_H -#include "srslte/interfaces/mac_interface_types.h" -#include "srslte/interfaces/pdcp_interface_types.h" -#include "srslte/interfaces/rlc_interface_types.h" -#include "srslte/interfaces/rrc_interface_types.h" -#include "srslte/interfaces/sched_interface.h" +#include "srsran/interfaces/mac_interface_types.h" +#include "srsran/interfaces/pdcp_interface_types.h" +#include "srsran/interfaces/rlc_interface_types.h" +#include "srsran/interfaces/rrc_interface_types.h" +#include "srsran/interfaces/sched_interface.h" /************************ * Forward declarations @@ -74,7 +74,7 @@ struct ue_eutra_cap_s; /************************ * Conversion Helpers ***********************/ -namespace srslte { +namespace srsran { plmn_id_t make_plmn_id_t(const asn1::rrc::plmn_id_s& asn1_type); void to_asn1(asn1::rrc::plmn_id_s* asn1_type, const plmn_id_t& cfg); plmn_id_t make_plmn_id_t(const asn1::fixed_octstring<3, true>& asn1_type); @@ -93,10 +93,10 @@ void to_asn1(asn1::rrc::rlc_cfg_c* asn1_type, const rlc_config_t& cfg); /*************************** * PDCP Config **************************/ -srslte::pdcp_config_t make_srb_pdcp_config_t(const uint8_t bearer_id, bool is_ue); -srslte::pdcp_config_t make_drb_pdcp_config_t(const uint8_t bearer_id, bool is_ue); +srsran::pdcp_config_t make_srb_pdcp_config_t(const uint8_t bearer_id, bool is_ue); +srsran::pdcp_config_t make_drb_pdcp_config_t(const uint8_t bearer_id, bool is_ue); uint8_t get_pdcp_drb_sn_len(const asn1::rrc::pdcp_cfg_s& pdcp_cfg); -srslte::pdcp_config_t +srsran::pdcp_config_t make_drb_pdcp_config_t(const uint8_t bearer_id, bool is_ue, const asn1::rrc::pdcp_cfg_s& pdcp_cfg); /*************************** @@ -139,7 +139,7 @@ mbsfn_sf_cfg_t make_mbsfn_sf_cfg(const asn1::rrc::mbsfn_sf_cfg_s& sf_cfg); mcch_msg_t make_mcch_msg(const asn1::rrc::mcch_msg_s& asn1_type); sib13_t make_sib13(const asn1::rrc::sib_type13_r9_s& asn1_type); -} // namespace srslte +} // namespace srsran /************************ * ASN1 RRC extensions @@ -174,4 +174,4 @@ void set_rrc_obj_id(scell_to_add_mod_r10_s& obj, uint8_t id); } // namespace rrc } // namespace asn1 -#endif // SRSLTE_RRC_UTILS_H +#endif // SRSRAN_RRC_UTILS_H diff --git a/lib/include/srslte/asn1/s1ap.h b/lib/include/srsran/asn1/s1ap.h similarity index 99% rename from lib/include/srslte/asn1/s1ap.h rename to lib/include/srsran/asn1/s1ap.h index c3f501f1e..3119fdce8 100644 --- a/lib/include/srslte/asn1/s1ap.h +++ b/lib/include/srsran/asn1/s1ap.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/lib/include/srslte/asn1/s1ap_utils.h b/lib/include/srsran/asn1/s1ap_utils.h similarity index 90% rename from lib/include/srslte/asn1/s1ap_utils.h rename to lib/include/srsran/asn1/s1ap_utils.h index e283ac0d0..613ebbf52 100644 --- a/lib/include/srslte/asn1/s1ap_utils.h +++ b/lib/include/srsran/asn1/s1ap_utils.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,8 +10,8 @@ * */ -#ifndef SRSLTE_S1AP_UTILS_H -#define SRSLTE_S1AP_UTILS_H +#ifndef SRSRAN_S1AP_UTILS_H +#define SRSRAN_S1AP_UTILS_H #include "asn1_utils.h" @@ -49,4 +49,4 @@ using cause_radio_network_e = enumerated; } // namespace s1ap } // namespace asn1 -#endif // SRSLTE_S1AP_UTILS_H +#endif // SRSRAN_S1AP_UTILS_H diff --git a/lib/include/srslte/build_info.h.in b/lib/include/srsran/build_info.h.in similarity index 73% rename from lib/include/srslte/build_info.h.in rename to lib/include/srsran/build_info.h.in index 426c6f9e0..2ac75db28 100644 --- a/lib/include/srslte/build_info.h.in +++ b/lib/include/srsran/build_info.h.in @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,10 +10,10 @@ * */ -#ifndef SRSLTE_BUILD_INFO_H_IN -#define SRSLTE_BUILD_INFO_H_IN +#ifndef SRSRAN_BUILD_INFO_H_IN +#define SRSRAN_BUILD_INFO_H_IN -#include "srslte/config.h" +#include "srsran/config.h" # ifdef __cplusplus extern "C" { @@ -33,14 +33,14 @@ extern "C" { #endif #endif -// the configured build options for srsLTE +// the configured build options for srsRAN static char build_info[] = "commit @GIT_COMMIT_HASH@ on branch @GIT_BRANCH@"; -SRSLTE_API char* srslte_get_build_info() { +SRSRAN_API char* srsran_get_build_info() { return build_info; }; -SRSLTE_API char* srslte_get_build_mode() { +SRSRAN_API char* srsran_get_build_mode() { return build_mode; } diff --git a/lib/include/srslte/common/backtrace.h b/lib/include/srsran/common/backtrace.h similarity index 72% rename from lib/include/srslte/common/backtrace.h rename to lib/include/srsran/common/backtrace.h index 8872dd202..dda4edfb1 100644 --- a/lib/include/srslte/common/backtrace.h +++ b/lib/include/srsran/common/backtrace.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -18,19 +18,19 @@ * Reference: *****************************************************************************/ -#ifndef SRSLTE_BACKTRACE_H -#define SRSLTE_BACKTRACE_H +#ifndef SRSRAN_BACKTRACE_H +#define SRSRAN_BACKTRACE_H -#include "srslte/config.h" +#include "srsran/config.h" #include #ifdef __cplusplus extern "C" { #endif // __cplusplus -SRSLTE_API void srslte_backtrace_print(FILE* f); +SRSRAN_API void srsran_backtrace_print(FILE* f); #ifdef __cplusplus } #endif // __cplusplus -#endif // SRSLTE_BACKTRACE_H +#endif // SRSRAN_BACKTRACE_H diff --git a/lib/include/srslte/common/backward.hpp b/lib/include/srsran/common/backward.hpp similarity index 100% rename from lib/include/srslte/common/backward.hpp rename to lib/include/srsran/common/backward.hpp diff --git a/lib/include/srslte/common/band_helper.h b/lib/include/srsran/common/band_helper.h similarity index 91% rename from lib/include/srslte/common/band_helper.h rename to lib/include/srsran/common/band_helper.h index e2521277a..7ca233759 100644 --- a/lib/include/srslte/common/band_helper.h +++ b/lib/include/srsran/common/band_helper.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,22 +10,22 @@ * */ -#ifndef SRSLTE_BAND_HELPER_H -#define SRSLTE_BAND_HELPER_H +#ifndef SRSRAN_BAND_HELPER_H +#define SRSRAN_BAND_HELPER_H #include #include #include -namespace srslte { +namespace srsran { // Helper class to handle frequency bands and ARFCNs // For NR: NR-ARFCN and channel raster as per TS 38.104 -class srslte_band_helper +class srsran_band_helper { public: - srslte_band_helper() = default; - ~srslte_band_helper() = default; + srsran_band_helper() = default; + ~srsran_band_helper() = default; // Return frequency of given NR-ARFCN in Hz double nr_arfcn_to_freq(uint32_t nr_arfcn); @@ -101,6 +101,6 @@ private: }}; }; -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_BAND_HELPER_H \ No newline at end of file +#endif // SRSRAN_BAND_HELPER_H \ No newline at end of file diff --git a/lib/include/srslte/common/basic_pnf.h b/lib/include/srsran/common/basic_pnf.h similarity index 93% rename from lib/include/srslte/common/basic_pnf.h rename to lib/include/srsran/common/basic_pnf.h index 91321a37d..1aef9ee62 100644 --- a/lib/include/srslte/common/basic_pnf.h +++ b/lib/include/srsran/common/basic_pnf.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,15 +10,15 @@ * */ -#ifndef SRSLTE_BASIC_PNF_H -#define SRSLTE_BASIC_PNF_H +#ifndef SRSRAN_BASIC_PNF_H +#define SRSRAN_BASIC_PNF_H #include "basic_vnf_api.h" #include "common.h" -#include "srslte/adt/choice_type.h" -#include "srslte/common/block_queue.h" -#include "srslte/common/buffer_pool.h" -#include "srslte/srslog/srslog.h" +#include "srsran/adt/choice_type.h" +#include "srsran/common/block_queue.h" +#include "srsran/common/buffer_pool.h" +#include "srsran/srslog/srslog.h" #include #include #include @@ -40,7 +40,7 @@ #define PING_REQUEST_PDU 1 -namespace srslte { +namespace srsran { struct pnf_metrics_t { uint32_t avg_rtt_us; @@ -49,15 +49,15 @@ struct pnf_metrics_t { uint32_t tb_size; }; -class srslte_basic_pnf +class srsran_basic_pnf { using msg_header_t = basic_vnf_api::msg_header_t; const static size_t buffer_size = - srslte::static_max::value; + srsran::static_max::value; using msg_buffer_t = std::array; public: - srslte_basic_pnf(const std::string& type_, + srsran_basic_pnf(const std::string& type_, const std::string& vnf_p5_addr, const uint16_t& vnf_p5_port, const uint32_t& sf_interval, @@ -78,7 +78,7 @@ public: logger.set_hex_dump_max_size(-1); } - ~srslte_basic_pnf() { stop(); }; + ~srsran_basic_pnf() { stop(); }; bool start() { @@ -110,10 +110,10 @@ public: running = true; if (type == "gnb") { - rx_thread = std::unique_ptr(new std::thread(&srslte_basic_pnf::dl_handler_thread, this)); - tx_thread = std::unique_ptr(new std::thread(&srslte_basic_pnf::ul_handler_thread, this)); + rx_thread = std::unique_ptr(new std::thread(&srsran_basic_pnf::dl_handler_thread, this)); + tx_thread = std::unique_ptr(new std::thread(&srsran_basic_pnf::ul_handler_thread, this)); } else { - tx_thread = std::unique_ptr(new std::thread(&srslte_basic_pnf::ue_dl_handler_thread, this)); + tx_thread = std::unique_ptr(new std::thread(&srsran_basic_pnf::ue_dl_handler_thread, this)); } return true; @@ -145,12 +145,12 @@ public: return tmp; } - void connect_out_rf_queue(srslte::block_queue* rf_queue_) + void connect_out_rf_queue(srsran::block_queue* rf_queue_) { rf_out_queue = rf_queue_; policy = bridge; } - srslte::block_queue* get_in_rf_queue() + srsran::block_queue* get_in_rf_queue() { policy = bridge; return &rf_in_queue; @@ -273,7 +273,7 @@ private: send_sf_ind(tti); if (policy == bridge) { - srslte::unique_byte_buffer_t tb; + srsran::unique_byte_buffer_t tb; if (rf_in_queue.try_pop(&tb)) { send_dl_ind(tti, std::move(tb)); } @@ -362,7 +362,7 @@ private: if (rf_out_queue != nullptr) { uint32_t len = sizeof(*msg) - sizeof(msg->pdus->data) + msg->pdus->length; - srslte::unique_byte_buffer_t tx = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t tx = srsran::make_byte_buffer(); memcpy(tx->msg, msg, len); rf_out_queue->push(std::move(tx)); } @@ -405,7 +405,7 @@ private: } } - void send_dl_ind(uint32_t tti_, srslte::unique_byte_buffer_t tb = {}) + void send_dl_ind(uint32_t tti_, srsran::unique_byte_buffer_t tb = {}) { #if PING_REQUEST_PDU static uint8_t tv[] = { @@ -536,11 +536,11 @@ private: // two policies possible: dummy packets generated by the PNF class, or bridge between UE and gNB PNFs with TBs // entering/exiting each PNF via the rf_in_queue/rf_out_queue. - srslte::block_queue* rf_out_queue = nullptr; - srslte::block_queue rf_in_queue; + srsran::block_queue* rf_out_queue = nullptr; + srsran::block_queue rf_in_queue; enum data_policy_t { self_gen, bridge } policy = self_gen; }; -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_BASIC_PNF_H +#endif // SRSRAN_BASIC_PNF_H diff --git a/lib/include/srslte/common/basic_vnf.h b/lib/include/srsran/common/basic_vnf.h similarity index 78% rename from lib/include/srslte/common/basic_vnf.h rename to lib/include/srsran/common/basic_vnf.h index 2c98cf15d..b72748a0d 100644 --- a/lib/include/srslte/common/basic_vnf.h +++ b/lib/include/srsran/common/basic_vnf.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,15 +10,15 @@ * */ -#ifndef SRSLTE_BASIC_VNF_H -#define SRSLTE_BASIC_VNF_H +#ifndef SRSRAN_BASIC_VNF_H +#define SRSRAN_BASIC_VNF_H #include "basic_vnf_api.h" #include "common.h" -#include "srslte/common/threads.h" -#include "srslte/interfaces/gnb_interfaces.h" -#include "srslte/interfaces/ue_nr_interfaces.h" -#include "srslte/srslog/srslog.h" +#include "srsran/common/threads.h" +#include "srsran/interfaces/gnb_interfaces.h" +#include "srsran/interfaces/ue_nr_interfaces.h" +#include "srsran/srslog/srslog.h" #include #include #include @@ -30,13 +30,13 @@ #include #include -namespace srslte { +namespace srsran { -class srslte_basic_vnf : public thread +class srsran_basic_vnf : public thread { public: - srslte_basic_vnf(const vnf_args_t& args_, stack_interface_phy_nr* stack_); - ~srslte_basic_vnf(); + srsran_basic_vnf(const vnf_args_t& args_, stack_interface_phy_nr* stack_); + ~srsran_basic_vnf(); bool stop(); @@ -76,6 +76,6 @@ private: uint32_t last_sf_indication_time = 0; }; -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_BASIC_VNF_H +#endif // SRSRAN_BASIC_VNF_H diff --git a/lib/include/srslte/common/basic_vnf_api.h b/lib/include/srsran/common/basic_vnf_api.h similarity index 96% rename from lib/include/srslte/common/basic_vnf_api.h rename to lib/include/srsran/common/basic_vnf_api.h index 6ea0dd26d..9a14a8793 100644 --- a/lib/include/srslte/common/basic_vnf_api.h +++ b/lib/include/srsran/common/basic_vnf_api.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,8 +10,8 @@ * */ -#ifndef SRSLTE_BASIC_VNF_API_H -#define SRSLTE_BASIC_VNF_API_H +#ifndef SRSRAN_BASIC_VNF_API_H +#define SRSRAN_BASIC_VNF_API_H #include @@ -156,4 +156,4 @@ struct ul_ind_msg_t { } // namespace basic_vnf_api -#endif // SRSLTE_BASIC_VNF_API_H +#endif // SRSRAN_BASIC_VNF_API_H diff --git a/lib/include/srslte/common/bcd_helpers.h b/lib/include/srsran/common/bcd_helpers.h similarity index 97% rename from lib/include/srslte/common/bcd_helpers.h rename to lib/include/srsran/common/bcd_helpers.h index ab7e73f37..d7128949f 100644 --- a/lib/include/srslte/common/bcd_helpers.h +++ b/lib/include/srsran/common/bcd_helpers.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,14 +10,14 @@ * */ -#ifndef SRSLTE_BCD_HELPERS_H -#define SRSLTE_BCD_HELPERS_H +#ifndef SRSRAN_BCD_HELPERS_H +#define SRSRAN_BCD_HELPERS_H #include #include #include -namespace srslte { +namespace srsran { /****************************************************************************** * Convert between string and BCD-coded MCC. @@ -275,6 +275,6 @@ inline void s1ap_mccmnc_to_plmn(uint16_t mcc, uint16_t mnc, uint32_t* plmn) *plmn |= nibbles[5]; } -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_BCD_HELPERS_H +#endif // SRSRAN_BCD_HELPERS_H diff --git a/lib/include/srslte/common/block_queue.h b/lib/include/srsran/common/block_queue.h similarity index 93% rename from lib/include/srslte/common/block_queue.h rename to lib/include/srsran/common/block_queue.h index 6689dccbd..7982d191c 100644 --- a/lib/include/srslte/common/block_queue.h +++ b/lib/include/srsran/common/block_queue.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -17,10 +17,10 @@ * operations in both push and pop *****************************************************************************/ -#ifndef SRSLTE_BLOCK_QUEUE_H -#define SRSLTE_BLOCK_QUEUE_H +#ifndef SRSRAN_BLOCK_QUEUE_H +#define SRSRAN_BLOCK_QUEUE_H -#include "srslte/adt/expected.h" +#include "srsran/adt/expected.h" #include #include #include @@ -30,7 +30,7 @@ #include #include -namespace srslte { +namespace srsran { template class block_queue @@ -85,7 +85,7 @@ public: bool try_push(const myobj& value) { return push_(value, false); } - srslte::error_type try_push(myobj&& value) { return push_(std::move(value), false); } + srsran::error_type try_push(myobj&& value) { return push_(std::move(value), false); } bool try_pop(myobj* value) { return pop_(value, false); } @@ -177,7 +177,7 @@ private: return true; } - srslte::error_type push_(myobj&& value, bool block) + srsran::error_type push_(myobj&& value, bool block) { if (!enable) { return std::move(value); @@ -225,6 +225,6 @@ private: uint32_t num_threads; }; -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_BLOCK_QUEUE_H +#endif // SRSRAN_BLOCK_QUEUE_H diff --git a/lib/include/srslte/common/buffer_pool.h b/lib/include/srsran/common/buffer_pool.h similarity index 92% rename from lib/include/srslte/common/buffer_pool.h rename to lib/include/srsran/common/buffer_pool.h index a2e23cb55..8642bb01f 100644 --- a/lib/include/srslte/common/buffer_pool.h +++ b/lib/include/srsran/common/buffer_pool.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,8 +10,8 @@ * */ -#ifndef SRSLTE_BUFFER_POOL_H -#define SRSLTE_BUFFER_POOL_H +#ifndef SRSRAN_BUFFER_POOL_H +#define SRSRAN_BUFFER_POOL_H #include "byte_buffer.h" #include @@ -25,10 +25,10 @@ INCLUDES *******************************************************************************/ -#include "srslte/common/common.h" -#include "srslte/srslog/srslog.h" +#include "srsran/common/common.h" +#include "srsran/srslog/srslog.h" -namespace srslte { +namespace srsran { /****************************************************************************** * Buffer pool @@ -82,7 +82,7 @@ public: void print_all_buffers() { printf("%d buffers in queue\n", (int)used.size()); -#ifdef SRSLTE_BUFFER_POOL_LOG_ENABLED +#ifdef SRSRAN_BUFFER_POOL_LOG_ENABLED std::map buffer_cnt; for (uint32_t i = 0; i < used.size(); i++) { buffer_cnt[strlen(used[i]->debug_name) ? used[i]->debug_name : "Undefined"]++; @@ -111,10 +111,10 @@ public: if (is_almost_empty()) { printf("Warning buffer pool capacity is %f %%\n", (float)100 * available.size() / capacity); } -#ifdef SRSLTE_BUFFER_POOL_LOG_ENABLED +#ifdef SRSRAN_BUFFER_POOL_LOG_ENABLED if (debug_name) { - strncpy(b->debug_name, debug_name, SRSLTE_BUFFER_POOL_LOG_NAME_LEN); - b->debug_name[SRSLTE_BUFFER_POOL_LOG_NAME_LEN - 1] = 0; + strncpy(b->debug_name, debug_name, SRSRAN_BUFFER_POOL_LOG_NAME_LEN); + b->debug_name[SRSRAN_BUFFER_POOL_LOG_NAME_LEN - 1] = 0; } #endif } else if (blocking) { @@ -132,7 +132,7 @@ public: } else { printf("Error - buffer pool is empty\n"); -#ifdef SRSLTE_BUFFER_POOL_LOG_ENABLED +#ifdef SRSRAN_BUFFER_POOL_LOG_ENABLED print_all_buffers(); #endif } @@ -192,7 +192,7 @@ public: return; } if (!pool.deallocate(static_cast(b))) { -#ifdef SRSLTE_BUFFER_POOL_LOG_ENABLED +#ifdef SRSRAN_BUFFER_POOL_LOG_ENABLED print_error("Error deallocating PDU: Addr=0x%p, name=%s not found in pool", (void*)b, b->debug_name); #else print_error("Error deallocating PDU: Addr=0x%p", (void*)b); @@ -237,6 +237,6 @@ inline unique_byte_buffer_t make_byte_buffer(const char* debug_ctxt) noexcept return buffer; } -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_BUFFER_POOL_H +#endif // SRSRAN_BUFFER_POOL_H diff --git a/lib/include/srslte/common/byte_buffer.h b/lib/include/srsran/common/byte_buffer.h similarity index 81% rename from lib/include/srslte/common/byte_buffer.h rename to lib/include/srsran/common/byte_buffer.h index bf6dc1450..47042c724 100644 --- a/lib/include/srslte/common/byte_buffer.h +++ b/lib/include/srsran/common/byte_buffer.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,16 +10,16 @@ * */ -#ifndef SRSLTE_BYTE_BUFFER_H -#define SRSLTE_BYTE_BUFFER_H +#ifndef SRSRAN_BYTE_BUFFER_H +#define SRSRAN_BYTE_BUFFER_H #include "common.h" #include #include -//#define SRSLTE_BUFFER_POOL_LOG_ENABLED +//#define SRSRAN_BUFFER_POOL_LOG_ENABLED -namespace srslte { +namespace srsran { #define ENABLE_TIMESTAMP @@ -82,10 +82,10 @@ public: using const_iterator = const uint8_t*; uint32_t N_bytes = 0; - uint8_t buffer[SRSLTE_MAX_BUFFER_SIZE_BYTES]; + uint8_t buffer[SRSRAN_MAX_BUFFER_SIZE_BYTES]; uint8_t* msg = nullptr; -#ifdef SRSLTE_BUFFER_POOL_LOG_ENABLED - char debug_name[SRSLTE_BUFFER_POOL_LOG_NAME_LEN]; +#ifdef SRSRAN_BUFFER_POOL_LOG_ENABLED + char debug_name[SRSRAN_BUFFER_POOL_LOG_NAME_LEN]; #endif struct buffer_metadata_t { @@ -93,20 +93,20 @@ public: buffer_latency_calc tp; } md; - byte_buffer_t() : msg(&buffer[SRSLTE_BUFFER_HEADER_OFFSET]) + byte_buffer_t() : msg(&buffer[SRSRAN_BUFFER_HEADER_OFFSET]) { -#ifdef SRSLTE_BUFFER_POOL_LOG_ENABLED - bzero(debug_name, SRSLTE_BUFFER_POOL_LOG_NAME_LEN); +#ifdef SRSRAN_BUFFER_POOL_LOG_ENABLED + bzero(debug_name, SRSRAN_BUFFER_POOL_LOG_NAME_LEN); #endif } - explicit byte_buffer_t(uint32_t size) : msg(&buffer[SRSLTE_BUFFER_HEADER_OFFSET]), N_bytes(size) + explicit byte_buffer_t(uint32_t size) : msg(&buffer[SRSRAN_BUFFER_HEADER_OFFSET]), N_bytes(size) { -#ifdef SRSLTE_BUFFER_POOL_LOG_ENABLED - bzero(debug_name, SRSLTE_BUFFER_POOL_LOG_NAME_LEN); +#ifdef SRSRAN_BUFFER_POOL_LOG_ENABLED + bzero(debug_name, SRSRAN_BUFFER_POOL_LOG_NAME_LEN); #endif } byte_buffer_t(uint32_t size, uint8_t val) : byte_buffer_t(size) { std::fill(msg, msg + N_bytes, val); } - byte_buffer_t(const byte_buffer_t& buf) : msg(&buffer[SRSLTE_BUFFER_HEADER_OFFSET]), md(buf.md), N_bytes(buf.N_bytes) + byte_buffer_t(const byte_buffer_t& buf) : msg(&buffer[SRSRAN_BUFFER_HEADER_OFFSET]), md(buf.md), N_bytes(buf.N_bytes) { // copy actual contents memcpy(msg, buf.msg, N_bytes); @@ -117,7 +117,7 @@ public: // avoid self assignment if (&buf == this) return *this; - msg = &buffer[SRSLTE_BUFFER_HEADER_OFFSET]; + msg = &buffer[SRSRAN_BUFFER_HEADER_OFFSET]; N_bytes = buf.N_bytes; md = buf.md; memcpy(msg, buf.msg, N_bytes); @@ -126,7 +126,7 @@ public: void clear() { - msg = &buffer[SRSLTE_BUFFER_HEADER_OFFSET]; + msg = &buffer[SRSRAN_BUFFER_HEADER_OFFSET]; N_bytes = 0; md = {}; } @@ -167,14 +167,14 @@ public: struct bit_buffer_t { uint32_t N_bits = 0; - uint8_t buffer[SRSLTE_MAX_BUFFER_SIZE_BITS]; + uint8_t buffer[SRSRAN_MAX_BUFFER_SIZE_BITS]; uint8_t* msg = nullptr; -#ifdef SRSLTE_BUFFER_POOL_LOG_ENABLED +#ifdef SRSRAN_BUFFER_POOL_LOG_ENABLED char debug_name[128]; #endif - bit_buffer_t() : msg(&buffer[SRSLTE_BUFFER_HEADER_OFFSET]) {} - bit_buffer_t(const bit_buffer_t& buf) : msg(&buffer[SRSLTE_BUFFER_HEADER_OFFSET]), N_bits(buf.N_bits) + bit_buffer_t() : msg(&buffer[SRSRAN_BUFFER_HEADER_OFFSET]) {} + bit_buffer_t(const bit_buffer_t& buf) : msg(&buffer[SRSRAN_BUFFER_HEADER_OFFSET]), N_bits(buf.N_bits) { memcpy(msg, buf.msg, N_bits); } @@ -184,14 +184,14 @@ struct bit_buffer_t { if (&buf == this) { return *this; } - msg = &buffer[SRSLTE_BUFFER_HEADER_OFFSET]; + msg = &buffer[SRSRAN_BUFFER_HEADER_OFFSET]; N_bits = buf.N_bits; memcpy(msg, buf.msg, N_bits); return *this; } void clear() { - msg = &buffer[SRSLTE_BUFFER_HEADER_OFFSET]; + msg = &buffer[SRSRAN_BUFFER_HEADER_OFFSET]; N_bits = 0; } uint32_t get_headroom() { return msg - buffer; } @@ -229,6 +229,6 @@ inline const_byte_span make_span(const unique_byte_buffer_t& b) return const_byte_span{b->msg, b->N_bytes}; } -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_BYTE_BUFFER_H +#endif // SRSRAN_BYTE_BUFFER_H diff --git a/lib/include/srslte/common/common.h b/lib/include/srsran/common/common.h similarity index 74% rename from lib/include/srslte/common/common.h rename to lib/include/srsran/common/common.h index 9937a0f7a..9d690ac4f 100644 --- a/lib/include/srslte/common/common.h +++ b/lib/include/srsran/common/common.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,14 +10,14 @@ * */ -#ifndef SRSLTE_COMMON_H -#define SRSLTE_COMMON_H +#ifndef SRSRAN_COMMON_H +#define SRSRAN_COMMON_H /******************************************************************************* INCLUDES *******************************************************************************/ -#include "srslte/adt/span.h" +#include "srsran/adt/span.h" #include #include #include @@ -28,13 +28,13 @@ DEFINES *******************************************************************************/ -#define SRSLTE_UE_CATEGORY 4 +#define SRSRAN_UE_CATEGORY 4 -#define SRSLTE_N_SRB 3 -#define SRSLTE_N_DRB 8 -#define SRSLTE_N_RADIO_BEARERS 11 +#define SRSRAN_N_SRB 3 +#define SRSRAN_N_DRB 8 +#define SRSRAN_N_RADIO_BEARERS 11 -#define SRSLTE_N_MCH_LCIDS 32 +#define SRSRAN_N_MCH_LCIDS 32 #define FDD_HARQ_DELAY_DL_MS 4 #define FDD_HARQ_DELAY_UL_MS 4 @@ -60,16 +60,16 @@ // Cat 4 UE - Max number of DL-SCH transport block bits received within a TTI // 3GPP 36.306 v15.4.0 Table 4.1.1 for Category 11 with 2 layers and 256QAM -#define SRSLTE_MAX_TBSIZE_BITS 97896 -#define SRSLTE_BUFFER_HEADER_OFFSET 1020 -#define SRSLTE_MAX_BUFFER_SIZE_BITS (SRSLTE_MAX_TBSIZE_BITS + SRSLTE_BUFFER_HEADER_OFFSET) -#define SRSLTE_MAX_BUFFER_SIZE_BYTES (SRSLTE_MAX_TBSIZE_BITS / 8 + SRSLTE_BUFFER_HEADER_OFFSET) +#define SRSRAN_MAX_TBSIZE_BITS 97896 +#define SRSRAN_BUFFER_HEADER_OFFSET 1020 +#define SRSRAN_MAX_BUFFER_SIZE_BITS (SRSRAN_MAX_TBSIZE_BITS + SRSRAN_BUFFER_HEADER_OFFSET) +#define SRSRAN_MAX_BUFFER_SIZE_BYTES (SRSRAN_MAX_TBSIZE_BITS / 8 + SRSRAN_BUFFER_HEADER_OFFSET) /******************************************************************************* TYPEDEFS *******************************************************************************/ -namespace srslte { +namespace srsran { #define ENABLE_TIMESTAMP @@ -85,13 +85,13 @@ ItemType enum_to_number(ItemType* array, uint32_t nof_types, uint32_t enum_val) return enum_val >= nof_types ? -1 : array[enum_val]; } -enum class srslte_rat_t { lte, nr, nulltype }; -inline std::string to_string(const srslte_rat_t& type) +enum class srsran_rat_t { lte, nr, nulltype }; +inline std::string to_string(const srsran_rat_t& type) { constexpr static const char* options[] = {"LTE", "NR"}; - return enum_to_text(options, (uint32_t)srslte_rat_t::nulltype, (uint32_t)type); + return enum_to_text(options, (uint32_t)srsran_rat_t::nulltype, (uint32_t)type); } -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_COMMON_H +#endif // SRSRAN_COMMON_H diff --git a/lib/include/srslte/common/common_helper.h b/lib/include/srsran/common/common_helper.h similarity index 84% rename from lib/include/srslte/common/common_helper.h rename to lib/include/srsran/common/common_helper.h index efd619f1f..81c8c5cc3 100644 --- a/lib/include/srslte/common/common_helper.h +++ b/lib/include/srsran/common/common_helper.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -12,18 +12,18 @@ /** * @file common_helper.h - * @brief Common helper functions shared among srsLTE applications. + * @brief Common helper functions shared among srsRAN applications. */ -#ifndef SRSLTE_COMMON_HELPER_H -#define SRSLTE_COMMON_HELPER_H +#ifndef SRSRAN_COMMON_HELPER_H +#define SRSRAN_COMMON_HELPER_H -#include "srslte/srslog/srslog.h" +#include "srsran/srslog/srslog.h" #include #include #include -namespace srslte { +namespace srsran { inline void log_args(int argc, char* argv[], const std::string& service) { @@ -63,6 +63,6 @@ inline void check_scaling_governor(const std::string& device_name) } } -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_COMMON_HELPER_H +#endif // SRSRAN_COMMON_HELPER_H diff --git a/lib/include/srslte/common/config_file.h b/lib/include/srsran/common/config_file.h similarity index 75% rename from lib/include/srslte/common/config_file.h rename to lib/include/srsran/common/config_file.h index 6882f4f33..264f670d1 100644 --- a/lib/include/srslte/common/config_file.h +++ b/lib/include/srsran/common/config_file.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,11 +10,11 @@ * */ -#ifndef SRSLTE_CONFIG_FILE_H -#define SRSLTE_CONFIG_FILE_H +#ifndef SRSRAN_CONFIG_FILE_H +#define SRSRAN_CONFIG_FILE_H #include "common.h" -#include "srslte/phy/common/phy_common.h" +#include "srsran/phy/common/phy_common.h" #include #include #include @@ -34,15 +34,15 @@ bool config_exists(std::string& filename, std::string default_name) if (!homedir) { homedir = "."; } - snprintf(full_path, sizeof(full_path), "%s/.config/srslte/%s", homedir, default_name.c_str()); + snprintf(full_path, sizeof(full_path), "%s/.config/srsran/%s", homedir, default_name.c_str()); filename = std::string(full_path); // try to open again conf.open(filename.c_str()); if (conf.fail()) { - // Last chance, try to find file in /etc/srslte + // Last chance, try to find file in /etc/srsran ZERO_OBJECT(full_path); - snprintf(full_path, sizeof(full_path), "/etc/srslte/%s", default_name.c_str()); + snprintf(full_path, sizeof(full_path), "/etc/srsran/%s", default_name.c_str()); filename = std::string(full_path); // try to open again @@ -55,4 +55,4 @@ bool config_exists(std::string& filename, std::string default_name) return true; } -#endif // SRSLTE_CONFIG_FILE_H +#endif // SRSRAN_CONFIG_FILE_H diff --git a/lib/include/srslte/common/crash_handler.h b/lib/include/srsran/common/crash_handler.h similarity index 64% rename from lib/include/srslte/common/crash_handler.h rename to lib/include/srsran/common/crash_handler.h index 6916ac69b..b4c29f53a 100644 --- a/lib/include/srslte/common/crash_handler.h +++ b/lib/include/srsran/common/crash_handler.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -15,19 +15,19 @@ * @brief Common handler to catch segfaults and write backtrace to file. */ -#ifndef SRSLTE_CRASH_HANDLER_H -#define SRSLTE_CRASH_HANDLER_H +#ifndef SRSRAN_CRASH_HANDLER_H +#define SRSRAN_CRASH_HANDLER_H -#include "srslte/config.h" +#include "srsran/config.h" #include #ifdef __cplusplus extern "C" { #endif // __cplusplus -void srslte_debug_handle_crash(int argc, char** argv); +void srsran_debug_handle_crash(int argc, char** argv); #ifdef __cplusplus } #endif // __cplusplus -#endif // SRSLTE_CRASH_HANDLER_H +#endif // SRSRAN_CRASH_HANDLER_H diff --git a/lib/include/srslte/common/enb_events.h b/lib/include/srsran/common/enb_events.h similarity index 97% rename from lib/include/srslte/common/enb_events.h rename to lib/include/srsran/common/enb_events.h index 96131a702..32bf39a97 100644 --- a/lib/include/srslte/common/enb_events.h +++ b/lib/include/srsran/common/enb_events.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/lib/include/srslte/common/epoll_helper.h b/lib/include/srsran/common/epoll_helper.h similarity index 90% rename from lib/include/srslte/common/epoll_helper.h rename to lib/include/srsran/common/epoll_helper.h index baec4227d..6382b08a8 100644 --- a/lib/include/srslte/common/epoll_helper.h +++ b/lib/include/srsran/common/epoll_helper.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -14,8 +14,8 @@ * */ -#ifndef SRSLTE_EPOLL_HELPER_H -#define SRSLTE_EPOLL_HELPER_H +#ifndef SRSRAN_EPOLL_HELPER_H +#define SRSRAN_EPOLL_HELPER_H #include #include @@ -65,7 +65,7 @@ public: struct signalfd_siginfo info; if (read(fd, &info, sizeof(info)) != sizeof(info)) { fprintf(stderr, "failed to read signal fd buffer\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } switch (info.ssi_signo) { case SIGTERM: @@ -78,7 +78,7 @@ public: fprintf(stderr, "got signal %d\n", info.ssi_signo); break; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } private: @@ -91,7 +91,7 @@ inline int create_tti_timer() int timer_fd = timerfd_create(CLOCK_MONOTONIC, 0); if (timer_fd == -1) { printf("timerfd_create() failed: errno=%d\n", errno); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } int msec = 1; // our 1ms TTI timer @@ -104,7 +104,7 @@ inline int create_tti_timer() if (timerfd_settime(timer_fd, 0, &ts, NULL) < 0) { printf("timerfd_settime() failed: errno=%d\n", errno); close(timer_fd); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } return timer_fd; } @@ -134,7 +134,7 @@ inline int add_signalfd() int sig_fd = signalfd(-1, &sw, 0); if (sig_fd == -1) { fprintf(stderr, "signalfd: %s\n", strerror(errno)); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } return sig_fd; } @@ -147,9 +147,9 @@ inline int add_epoll(int fd, int epoll_fd) ev.events = EPOLLIN; if (epoll_ctl(epoll_fd, EPOLL_CTL_ADD, fd, &ev) == -1) { fprintf(stderr, "epoll_ctl failed for fd=%d\n", fd); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } ///< Remove fd from epoll @@ -160,9 +160,9 @@ inline int del_epoll(int fd, int epoll_fd) ev.events = EPOLLIN; if (epoll_ctl(epoll_fd, EPOLL_CTL_DEL, fd, &ev) == -1) { fprintf(stderr, "epoll_ctl failed for fd=%d\n", fd); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -#endif // SRSLTE_EPOLL_HELPER_H +#endif // SRSRAN_EPOLL_HELPER_H diff --git a/lib/include/srslte/common/fsm.h b/lib/include/srsran/common/fsm.h similarity index 96% rename from lib/include/srslte/common/fsm.h rename to lib/include/srsran/common/fsm.h index 2915bbf17..760381640 100644 --- a/lib/include/srslte/common/fsm.h +++ b/lib/include/srsran/common/fsm.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,12 +10,12 @@ * */ -#ifndef SRSLTE_FSM_H -#define SRSLTE_FSM_H +#ifndef SRSRAN_FSM_H +#define SRSRAN_FSM_H -#include "srslte/adt/detail/type_utils.h" -#include "srslte/adt/move_callback.h" -#include "srslte/srslog/srslog.h" +#include "srsran/adt/detail/type_utils.h" +#include "srsran/adt/move_callback.h" +#include "srsran/srslog/srslog.h" #include #include #include @@ -34,7 +34,7 @@ #define fsmWarning(fmt, ...) otherfsmWarning(this, fmt, ##__VA_ARGS__) #define fsmError(fmt, ...) otherfsmError(this, fmt, ##__VA_ARGS__) -namespace srslte { +namespace srsran { //! Forward declarations template @@ -162,7 +162,7 @@ template struct state_traits { static_assert(FSM::template can_hold_state(), "FSM type does not hold provided State"); using state_t = State; - using is_subfsm = std::integral_constant::value>; + using is_subfsm = std::integral_constant::value>; //! enter new state. enter is called recursively for subFSMs template @@ -425,7 +425,7 @@ public: template constexpr static bool can_hold_type() { - return srslte::type_list_contains(); + return srsran::type_list_contains(); } template @@ -467,7 +467,7 @@ public: std::string current_state_name() const { fsm_details::state_name_visitor visitor{}; - srslte::visit(visitor, derived()->states); + srsran::visit(visitor, derived()->states); return visitor.name; } @@ -488,7 +488,7 @@ protected: bool process_event(Ev&& e) { fsm_details::trigger_visitor visitor{derived(), std::forward(e)}; - srslte::visit(visitor, derived()->states); + srsran::visit(visitor, derived()->states); return visitor.result; } }; @@ -574,7 +574,7 @@ protected: srslog::basic_logger& logger; srslog::basic_levels log_level = srslog::basic_levels::info; bool trigger_locked = false; - std::deque > pending_events; + std::deque > pending_events; }; template @@ -643,8 +643,8 @@ public: // events template - using launch_ev = srslte::proc_launch_ev; - using complete_ev = srslte::proc_complete_ev; + using launch_ev = srsran::proc_launch_ev; + using complete_ev = srsran::proc_complete_ev; // states struct idle_st { @@ -715,7 +715,7 @@ public: f->get_logger().error("Unable to launch proc1"); f->trigger(typename ProcFSM::complete_ev{false}); } - proc_ptr->trigger(srslte::proc_launch_ev{ev}); + proc_ptr->trigger(srsran::proc_launch_ev{ev}); proc_ptr->await(f); } @@ -739,7 +739,7 @@ struct event_callback { void operator()(const Event& ev) { callback(ev); } void operator()(const Event& ev) const { callback(ev); } - srslte::move_task_t to_move_task(const Event& ev) + srsran::move_task_t to_move_task(const Event& ev) { auto& copied_callback = callback; return [copied_callback, ev]() { copied_callback(ev); }; @@ -749,14 +749,14 @@ struct event_callback { }; template -srslte::move_task_t make_move_task(const event_callback& callback, const Event& ev) +srsran::move_task_t make_move_task(const event_callback& callback, const Event& ev) { auto& copied_callback = callback; return [copied_callback, ev]() { copied_callback(ev); }; } template -srslte::move_task_t make_move_task(std::vector >&& callbacks, const Event& ev) +srsran::move_task_t make_move_task(std::vector >&& callbacks, const Event& ev) { return std::bind( [ev](const std::vector >& callbacks) { @@ -767,6 +767,6 @@ srslte::move_task_t make_move_task(std::vector >&& callbac std::move(callbacks)); } -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_FSM_H +#endif // SRSRAN_FSM_H diff --git a/lib/include/srslte/common/gen_mch_tables.h b/lib/include/srsran/common/gen_mch_tables.h similarity index 94% rename from lib/include/srslte/common/gen_mch_tables.h rename to lib/include/srsran/common/gen_mch_tables.h index 051c9fade..8b22b05bc 100644 --- a/lib/include/srslte/common/gen_mch_tables.h +++ b/lib/include/srsran/common/gen_mch_tables.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/lib/include/srslte/common/int_helpers.h b/lib/include/srsran/common/int_helpers.h similarity index 87% rename from lib/include/srslte/common/int_helpers.h rename to lib/include/srsran/common/int_helpers.h index e316ad154..303813ab2 100644 --- a/lib/include/srslte/common/int_helpers.h +++ b/lib/include/srsran/common/int_helpers.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,10 +10,10 @@ * */ -#ifndef SRSLTE_INT_HELPERS_H -#define SRSLTE_INT_HELPERS_H +#ifndef SRSRAN_INT_HELPERS_H +#define SRSRAN_INT_HELPERS_H -namespace srslte { +namespace srsran { /****************************************************************************** * Safe conversions between byte buffers and integer types. @@ -55,5 +55,5 @@ inline void uint24_to_uint8(uint32_t i, uint8_t* buf) buf[2] = i & 0xFF; } -} // namespace srslte -#endif // SRSLTE_INT_HELPERS_H +} // namespace srsran +#endif // SRSRAN_INT_HELPERS_H diff --git a/lib/include/srslte/common/interfaces_common.h b/lib/include/srsran/common/interfaces_common.h similarity index 67% rename from lib/include/srslte/common/interfaces_common.h rename to lib/include/srsran/common/interfaces_common.h index c502d56b6..5997e63b1 100644 --- a/lib/include/srslte/common/interfaces_common.h +++ b/lib/include/srsran/common/interfaces_common.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,15 +10,15 @@ * */ -#ifndef SRSLTE_INTERFACES_COMMON_H -#define SRSLTE_INTERFACES_COMMON_H +#ifndef SRSRAN_INTERFACES_COMMON_H +#define SRSRAN_INTERFACES_COMMON_H -#include "srslte/common/byte_buffer.h" -#include "srslte/common/security.h" -#include "srslte/phy/common/phy_common.h" +#include "srsran/common/byte_buffer.h" +#include "srsran/common/security.h" +#include "srsran/phy/common/phy_common.h" #include -namespace srslte { +namespace srsran { typedef struct { std::string phy_level = "none"; @@ -40,9 +40,9 @@ typedef struct { float ul_freq; float freq_offset; float rx_gain; - float rx_gain_ch[SRSLTE_MAX_CARRIERS]; + float rx_gain_ch[SRSRAN_MAX_CARRIERS]; float tx_gain; - float tx_gain_ch[SRSLTE_MAX_CARRIERS]; + float tx_gain_ch[SRSRAN_MAX_CARRIERS]; float tx_max_power; float tx_gain_offset; float rx_gain_offset; @@ -53,8 +53,8 @@ typedef struct { std::string time_adv_nsamples; std::string continuous_tx; - std::array ch_rx_bands; - std::array ch_tx_bands; + std::array ch_rx_bands; + std::array ch_tx_bands; } rf_args_t; @@ -66,10 +66,10 @@ struct vnf_args_t { int log_hex_limit; }; -class srslte_gw_config_t +class srsran_gw_config_t { public: - explicit srslte_gw_config_t(uint32_t lcid_ = 0) : lcid(lcid_) {} + explicit srsran_gw_config_t(uint32_t lcid_ = 0) : lcid(lcid_) {} uint32_t lcid; }; @@ -83,6 +83,6 @@ public: class stack_interface_phy_nr {}; -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_INTERFACES_COMMON_H +#endif // SRSRAN_INTERFACES_COMMON_H diff --git a/lib/include/srslte/common/liblte_security.h b/lib/include/srsran/common/liblte_security.h similarity index 99% rename from lib/include/srslte/common/liblte_security.h rename to lib/include/srsran/common/liblte_security.h index 180a66502..95c6a691e 100644 --- a/lib/include/srslte/common/liblte_security.h +++ b/lib/include/srsran/common/liblte_security.h @@ -11,14 +11,14 @@ * */ -#ifndef SRSLTE_LIBLTE_SECURITY_H -#define SRSLTE_LIBLTE_SECURITY_H +#ifndef SRSRAN_LIBLTE_SECURITY_H +#define SRSRAN_LIBLTE_SECURITY_H /******************************************************************************* INCLUDES *******************************************************************************/ -#include "srslte/asn1/liblte_common.h" +#include "srsran/asn1/liblte_common.h" /******************************************************************************* DEFINES @@ -349,4 +349,4 @@ LIBLTE_ERROR_ENUM liblte_security_generate_k_nr_up(uint8* uint8* k_up_enc, uint8* k_up_int); -#endif // SRSLTE_LIBLTE_SECURITY_H +#endif // SRSRAN_LIBLTE_SECURITY_H diff --git a/lib/include/srslte/common/log_helper.h b/lib/include/srsran/common/log_helper.h similarity index 70% rename from lib/include/srslte/common/log_helper.h rename to lib/include/srsran/common/log_helper.h index 4d04affaf..a62fa3656 100644 --- a/lib/include/srslte/common/log_helper.h +++ b/lib/include/srsran/common/log_helper.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,8 +10,8 @@ * */ -#ifndef SRSLTE_LOG_HELPER_H -#define SRSLTE_LOG_HELPER_H +#ifndef SRSRAN_LOG_HELPER_H +#define SRSRAN_LOG_HELPER_H /** * @file log_helper.h @@ -19,14 +19,14 @@ * Convenience macro to log formatted messages. It is checked if the log pointer is still valid before accessing it. */ -namespace srslte { +namespace srsran { #define Error(fmt, ...) logger.error(fmt, ##__VA_ARGS__) #define Warning(fmt, ...) logger.warning(fmt, ##__VA_ARGS__) #define Info(fmt, ...) logger.info(fmt, ##__VA_ARGS__) #define Debug(fmt, ...) logger.debug(fmt, ##__VA_ARGS__) -#define Console(fmt, ...) srslte::console(fmt, ##__VA_ARGS__) +#define Console(fmt, ...) srsran::console(fmt, ##__VA_ARGS__) -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_LOG_HELPER_H +#endif // SRSRAN_LOG_HELPER_H diff --git a/lib/include/srslte/common/mac_pcap.h b/lib/include/srsran/common/mac_pcap.h similarity index 59% rename from lib/include/srslte/common/mac_pcap.h rename to lib/include/srsran/common/mac_pcap.h index 1d84476f4..80b8dec80 100644 --- a/lib/include/srslte/common/mac_pcap.h +++ b/lib/include/srsran/common/mac_pcap.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,14 +10,14 @@ * */ -#ifndef SRSLTE_MAC_PCAP_H -#define SRSLTE_MAC_PCAP_H +#ifndef SRSRAN_MAC_PCAP_H +#define SRSRAN_MAC_PCAP_H -#include "srslte/common/common.h" -#include "srslte/common/mac_pcap_base.h" -#include "srslte/srslte.h" +#include "srsran/common/common.h" +#include "srsran/common/mac_pcap_base.h" +#include "srsran/srsran.h" -namespace srslte { +namespace srsran { class mac_pcap : public mac_pcap_base { public: @@ -27,12 +27,12 @@ public: uint32_t close(); private: - void write_pdu(srslte::mac_pcap_base::pcap_pdu_t& pdu); + void write_pdu(srsran::mac_pcap_base::pcap_pdu_t& pdu); FILE* pcap_file = nullptr; uint32_t dlt = 0; // The DLT used for the PCAP file std::string filename; }; -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_MAC_PCAP_H \ No newline at end of file +#endif // SRSRAN_MAC_PCAP_H \ No newline at end of file diff --git a/lib/include/srslte/common/mac_pcap_base.h b/lib/include/srsran/common/mac_pcap_base.h similarity index 89% rename from lib/include/srslte/common/mac_pcap_base.h rename to lib/include/srsran/common/mac_pcap_base.h index fb321d7df..fe1d41b43 100644 --- a/lib/include/srslte/common/mac_pcap_base.h +++ b/lib/include/srsran/common/mac_pcap_base.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,21 +10,21 @@ * */ -#ifndef SRSLTE_MAC_PCAP_BASE_H -#define SRSLTE_MAC_PCAP_BASE_H +#ifndef SRSRAN_MAC_PCAP_BASE_H +#define SRSRAN_MAC_PCAP_BASE_H -#include "srslte/adt/circular_buffer.h" -#include "srslte/common/buffer_pool.h" -#include "srslte/common/common.h" -#include "srslte/common/pcap.h" -#include "srslte/common/threads.h" -#include "srslte/srslog/srslog.h" +#include "srsran/adt/circular_buffer.h" +#include "srsran/common/buffer_pool.h" +#include "srsran/common/common.h" +#include "srsran/common/pcap.h" +#include "srsran/common/threads.h" +#include "srsran/srslog/srslog.h" #include #include #include -namespace srslte { -class mac_pcap_base : protected srslte::thread +namespace srsran { +class mac_pcap_base : protected srsran::thread { public: mac_pcap_base(); @@ -84,7 +84,7 @@ public: protected: typedef struct { // Different PCAP context for both RATs - srslte::srslte_rat_t rat; + srsran::srsran_rat_t rat; MAC_Context_Info_t context; mac_nr_context_info_t context_nr; unique_byte_buffer_t pdu; @@ -120,6 +120,6 @@ private: uint8_t rnti_type); }; -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_MAC_PCAP_BASE_H +#endif // SRSRAN_MAC_PCAP_BASE_H diff --git a/lib/include/srslte/common/mac_pcap_net.h b/lib/include/srsran/common/mac_pcap_net.h similarity index 53% rename from lib/include/srslte/common/mac_pcap_net.h rename to lib/include/srsran/common/mac_pcap_net.h index a470d373c..47863f176 100644 --- a/lib/include/srslte/common/mac_pcap_net.h +++ b/lib/include/srsran/common/mac_pcap_net.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,15 +10,15 @@ * */ -#ifndef SRSLTE_MAC_PCAP_NET_H -#define SRSLTE_MAC_PCAP_NET_H +#ifndef SRSRAN_MAC_PCAP_NET_H +#define SRSRAN_MAC_PCAP_NET_H -#include "srslte/common/common.h" -#include "srslte/common/mac_pcap_base.h" -#include "srslte/common/network_utils.h" -#include "srslte/srslte.h" +#include "srsran/common/common.h" +#include "srsran/common/mac_pcap_base.h" +#include "srsran/common/network_utils.h" +#include "srsran/srsran.h" -namespace srslte { +namespace srsran { class mac_pcap_net : public mac_pcap_base { public: @@ -32,13 +32,13 @@ public: uint32_t close(); private: - void write_pdu(srslte::mac_pcap_base::pcap_pdu_t& pdu); - void write_mac_lte_pdu_to_net(srslte::mac_pcap_base::pcap_pdu_t& pdu); - void write_mac_nr_pdu_to_net(srslte::mac_pcap_base::pcap_pdu_t& pdu); + void write_pdu(srsran::mac_pcap_base::pcap_pdu_t& pdu); + void write_mac_lte_pdu_to_net(srsran::mac_pcap_base::pcap_pdu_t& pdu); + void write_mac_nr_pdu_to_net(srsran::mac_pcap_base::pcap_pdu_t& pdu); - srslte::socket_handler_t socket; + srsran::socket_handler_t socket; struct sockaddr_in client_addr; }; -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_MAC_PCAP_NET_H +#endif // SRSRAN_MAC_PCAP_NET_H diff --git a/lib/include/srslte/common/metrics_hub.h b/lib/include/srsran/common/metrics_hub.h similarity index 91% rename from lib/include/srslte/common/metrics_hub.h rename to lib/include/srsran/common/metrics_hub.h index e51b903a9..b6417a0a7 100644 --- a/lib/include/srslte/common/metrics_hub.h +++ b/lib/include/srsran/common/metrics_hub.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -16,16 +16,16 @@ * to get metrics *****************************************************************************/ -#ifndef SRSLTE_METRICS_HUB_H -#define SRSLTE_METRICS_HUB_H +#ifndef SRSRAN_METRICS_HUB_H +#define SRSRAN_METRICS_HUB_H -#include "srslte/common/threads.h" +#include "srsran/common/threads.h" #include #include #include #include -namespace srslte { +namespace srsran { template class metrics_interface @@ -96,6 +96,6 @@ private: std::mutex mutex; }; -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_METRICS_HUB_H +#endif // SRSRAN_METRICS_HUB_H diff --git a/lib/include/srslte/common/multiqueue.h b/lib/include/srsran/common/multiqueue.h similarity index 97% rename from lib/include/srslte/common/multiqueue.h rename to lib/include/srsran/common/multiqueue.h index 5a03d3096..5275c4ad1 100644 --- a/lib/include/srslte/common/multiqueue.h +++ b/lib/include/srsran/common/multiqueue.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -16,10 +16,10 @@ * of bounded/unbounded queues. *****************************************************************************/ -#ifndef SRSLTE_MULTIQUEUE_H -#define SRSLTE_MULTIQUEUE_H +#ifndef SRSRAN_MULTIQUEUE_H +#define SRSRAN_MULTIQUEUE_H -#include "srslte/adt/move_callback.h" +#include "srsran/adt/move_callback.h" #include #include #include @@ -27,7 +27,7 @@ #include #include -namespace srslte { +namespace srsran { #define MULTIQUEUE_DEFAULT_CAPACITY (8192) // Default per-queue capacity @@ -319,6 +319,6 @@ private: using task_multiqueue = multiqueue_handler; using task_queue_handle = task_multiqueue::queue_handle; -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_MULTIQUEUE_H +#endif // SRSRAN_MULTIQUEUE_H diff --git a/lib/include/srslte/common/nas_pcap.h b/lib/include/srsran/common/nas_pcap.h similarity index 76% rename from lib/include/srslte/common/nas_pcap.h rename to lib/include/srsran/common/nas_pcap.h index 672f2c291..30b85adbe 100644 --- a/lib/include/srslte/common/nas_pcap.h +++ b/lib/include/srsran/common/nas_pcap.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,13 +10,13 @@ * */ -#ifndef SRSLTE_NAS_PCAP_H -#define SRSLTE_NAS_PCAP_H +#ifndef SRSRAN_NAS_PCAP_H +#define SRSRAN_NAS_PCAP_H -#include "srslte/common/pcap.h" +#include "srsran/common/pcap.h" #include -namespace srslte { +namespace srsran { class nas_pcap { @@ -40,6 +40,6 @@ private: void pack_and_write(uint8_t* pdu, uint32_t pdu_len_bytes); }; -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_NAS_PCAP_H +#endif // SRSRAN_NAS_PCAP_H diff --git a/lib/include/srslte/common/netsource_handler.h b/lib/include/srsran/common/netsource_handler.h similarity index 78% rename from lib/include/srslte/common/netsource_handler.h rename to lib/include/srsran/common/netsource_handler.h index eb6469625..089e0066d 100644 --- a/lib/include/srslte/common/netsource_handler.h +++ b/lib/include/srsran/common/netsource_handler.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -15,16 +15,16 @@ * */ -#ifndef SRSLTE_NETSOURE_HANDLER_H -#define SRSLTE_NETSOURE_HANDLER_H +#ifndef SRSRAN_NETSOURE_HANDLER_H +#define SRSRAN_NETSOURE_HANDLER_H -#include "srslte/common/threads.h" -#include "srslte/phy/io/netsource.h" +#include "srsran/common/threads.h" +#include "srsran/phy/io/netsource.h" #include #include #include -class netsource_handler : public srslte::thread +class netsource_handler : public srsran::thread { public: netsource_handler(const std::string name_) : thread(name_) { rx_buf = unique_byte_array_t(new byte_array_t); } @@ -59,7 +59,7 @@ public: typedef std::unique_ptr unique_byte_array_t; unique_byte_array_t rx_buf; - srslte_netsource_t net_source; + srsran_netsource_t net_source; }; -#endif // SRSLTE_NETSOURE_HANDLER_H +#endif // SRSRAN_NETSOURE_HANDLER_H diff --git a/lib/include/srslte/common/network_utils.h b/lib/include/srsran/common/network_utils.h similarity index 93% rename from lib/include/srslte/common/network_utils.h rename to lib/include/srsran/common/network_utils.h index 08466b592..368cad11a 100644 --- a/lib/include/srslte/common/network_utils.h +++ b/lib/include/srsran/common/network_utils.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,11 +10,11 @@ * */ -#ifndef SRSLTE_RX_SOCKET_HANDLER_H -#define SRSLTE_RX_SOCKET_HANDLER_H +#ifndef SRSRAN_RX_SOCKET_HANDLER_H +#define SRSRAN_RX_SOCKET_HANDLER_H -#include "srslte/common/buffer_pool.h" -#include "srslte/common/threads.h" +#include "srsran/common/buffer_pool.h" +#include "srsran/common/threads.h" #include #include @@ -29,7 +29,7 @@ #include #include // for the pipe -namespace srslte { +namespace srsran { namespace net_utils { @@ -120,9 +120,9 @@ public: virtual bool operator()(int fd) = 0; // returns false, if socket needs to be removed }; using task_callback_t = std::unique_ptr; - using recvfrom_callback_t = std::function; + using recvfrom_callback_t = std::function; using sctp_recv_callback_t = - std::function; + std::function; rx_multisocket_handler(std::string name_, srslog::basic_logger& logger, int thread_prio = 65); rx_multisocket_handler(rx_multisocket_handler&&) = delete; @@ -161,6 +161,6 @@ private: int pipefd[2] = {}; }; -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_RX_SOCKET_HANDLER_H +#endif // SRSRAN_RX_SOCKET_HANDLER_H diff --git a/lib/include/srslte/common/pcap.h b/lib/include/srsran/common/pcap.h similarity index 98% rename from lib/include/srslte/common/pcap.h rename to lib/include/srsran/common/pcap.h index 21b91c929..d3c709d04 100644 --- a/lib/include/srslte/common/pcap.h +++ b/lib/include/srsran/common/pcap.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,8 +10,8 @@ * */ -#ifndef SRSLTE_PCAP_H -#define SRSLTE_PCAP_H +#ifndef SRSRAN_PCAP_H +#define SRSRAN_PCAP_H #include #include @@ -211,4 +211,4 @@ int NR_PCAP_PACK_MAC_CONTEXT_TO_BUFFER(mac_nr_context_info_t* context, uint8_t* } #endif -#endif // SRSLTE_PCAP_H +#endif // SRSRAN_PCAP_H diff --git a/lib/include/srslte/common/rlc_pcap.h b/lib/include/srsran/common/rlc_pcap.h similarity index 86% rename from lib/include/srslte/common/rlc_pcap.h rename to lib/include/srsran/common/rlc_pcap.h index dc4d2e684..d56c489ec 100644 --- a/lib/include/srslte/common/rlc_pcap.h +++ b/lib/include/srsran/common/rlc_pcap.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,11 +13,11 @@ #ifndef RLCPCAP_H #define RLCPCAP_H -#include "srslte/common/pcap.h" -#include "srslte/interfaces/rlc_interface_types.h" +#include "srsran/common/pcap.h" +#include "srsran/interfaces/rlc_interface_types.h" #include -namespace srslte { +namespace srsran { class rlc_pcap { @@ -49,6 +49,6 @@ private: uint16_t channel_id); }; -} // namespace srslte +} // namespace srsran #endif // RLCPCAP_H diff --git a/lib/include/srslte/common/rwlock_guard.h b/lib/include/srsran/common/rwlock_guard.h similarity index 86% rename from lib/include/srslte/common/rwlock_guard.h rename to lib/include/srsran/common/rwlock_guard.h index b0d44b40b..7fe87e763 100644 --- a/lib/include/srslte/common/rwlock_guard.h +++ b/lib/include/srsran/common/rwlock_guard.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,12 +10,12 @@ * */ -#ifndef SRSLTE_RWLOCK_GUARD_H -#define SRSLTE_RWLOCK_GUARD_H +#ifndef SRSRAN_RWLOCK_GUARD_H +#define SRSRAN_RWLOCK_GUARD_H #include -namespace srslte { +namespace srsran { class rwlock_write_guard { @@ -46,6 +46,6 @@ private: pthread_rwlock_t* rwlock; }; -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_RWLOCK_GUARD_H +#endif // SRSRAN_RWLOCK_GUARD_H diff --git a/lib/include/srslte/common/s1ap_pcap.h b/lib/include/srsran/common/s1ap_pcap.h similarity index 69% rename from lib/include/srslte/common/s1ap_pcap.h rename to lib/include/srsran/common/s1ap_pcap.h index 8aa888e3d..819e4845e 100644 --- a/lib/include/srslte/common/s1ap_pcap.h +++ b/lib/include/srsran/common/s1ap_pcap.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,12 +10,12 @@ * */ -#ifndef SRSLTE_S1AP_PCAP_H -#define SRSLTE_S1AP_PCAP_H +#ifndef SRSRAN_S1AP_PCAP_H +#define SRSRAN_S1AP_PCAP_H -#include "srslte/common/pcap.h" +#include "srsran/common/pcap.h" -namespace srslte { +namespace srsran { class s1ap_pcap { @@ -35,6 +35,6 @@ private: FILE* pcap_file; }; -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_NAS_PCAP_H +#endif // SRSRAN_NAS_PCAP_H diff --git a/lib/include/srslte/common/s3g.h b/lib/include/srsran/common/s3g.h similarity index 96% rename from lib/include/srslte/common/s3g.h rename to lib/include/srsran/common/s3g.h index b43eab29b..605b1ecb1 100644 --- a/lib/include/srslte/common/s3g.h +++ b/lib/include/srsran/common/s3g.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -20,8 +20,8 @@ * Document 2: SNOW 3G Specification" */ -#ifndef SRSLTE_S3G_H -#define SRSLTE_S3G_H +#ifndef SRSRAN_S3G_H +#define SRSRAN_S3G_H #include #include @@ -92,4 +92,4 @@ void s3g_generate_keystream(S3G_STATE* state, uint32_t n, uint32_t* ks); uint8_t* s3g_f9(const uint8_t* key, uint32_t count, uint32_t fresh, uint32_t dir, uint8_t* data, uint64_t length); -#endif // SRSLTE_S3G_H \ No newline at end of file +#endif // SRSRAN_S3G_H \ No newline at end of file diff --git a/lib/include/srslte/common/security.h b/lib/include/srsran/common/security.h similarity index 97% rename from lib/include/srslte/common/security.h rename to lib/include/srsran/common/security.h index a8d7257cc..42d7f496b 100644 --- a/lib/include/srslte/common/security.h +++ b/lib/include/srsran/common/security.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,16 +10,16 @@ * */ -#ifndef SRSLTE_SECURITY_H -#define SRSLTE_SECURITY_H +#ifndef SRSRAN_SECURITY_H +#define SRSRAN_SECURITY_H /****************************************************************************** * Common security header - wraps ciphering/integrity check algorithms. *****************************************************************************/ -#include "srslte/common/common.h" +#include "srsran/common/common.h" -namespace srslte { +namespace srsran { typedef enum { CIPHERING_ALGORITHM_ID_EEA0 = 0, @@ -192,5 +192,5 @@ security_milenage_f2345(uint8_t* k, uint8_t* op, uint8_t* rand, uint8_t* res, ui uint8_t security_milenage_f5_star(uint8_t* k, uint8_t* op, uint8_t* rand, uint8_t* ak); -} // namespace srslte -#endif // SRSLTE_SECURITY_H +} // namespace srsran +#endif // SRSRAN_SECURITY_H diff --git a/lib/include/srslte/common/signal_handler.h b/lib/include/srsran/common/signal_handler.h similarity index 62% rename from lib/include/srslte/common/signal_handler.h rename to lib/include/srsran/common/signal_handler.h index e8789bacb..ca700af74 100644 --- a/lib/include/srslte/common/signal_handler.h +++ b/lib/include/srsran/common/signal_handler.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -12,14 +12,14 @@ /** * @file signal_handler.h - * @brief Common signal handling methods for all srsLTE applications. + * @brief Common signal handling methods for all srsRAN applications. */ -#ifndef SRSLTE_SIGNAL_HANDLER_H -#define SRSLTE_SIGNAL_HANDLER_H +#ifndef SRSRAN_SIGNAL_HANDLER_H +#define SRSRAN_SIGNAL_HANDLER_H -#include "srslte/srslog/sink.h" -#include "srslte/srslog/srslog.h" +#include "srsran/srslog/sink.h" +#include "srsran/srslog/srslog.h" #include #include @@ -27,17 +27,17 @@ extern "C" { #endif // __cplusplus -#define SRSLTE_TERM_TIMEOUT_S (5) +#define SRSRAN_TERM_TIMEOUT_S (5) // static vars required by signal handling static srslog::sink* log_sink = nullptr; static bool running = true; -static void srslte_signal_handler(int signal) +static void srsran_signal_handler(int signal) { switch (signal) { case SIGALRM: - fprintf(stderr, "Couldn't stop after %ds. Forcing exit.\n", SRSLTE_TERM_TIMEOUT_S); + fprintf(stderr, "Couldn't stop after %ds. Forcing exit.\n", SRSRAN_TERM_TIMEOUT_S); srslog::flush(); //:TODO: refactor the sighandler, should not depend on log utilities if (log_sink) { @@ -49,7 +49,7 @@ static void srslte_signal_handler(int signal) if (running) { running = false; fprintf(stdout, "Stopping ..\n"); - alarm(SRSLTE_TERM_TIMEOUT_S); + alarm(SRSRAN_TERM_TIMEOUT_S); } else { // already waiting for alarm to go off .. } @@ -57,15 +57,15 @@ static void srslte_signal_handler(int signal) } } -void srslte_register_signal_handler() +void srsran_register_signal_handler() { - signal(SIGINT, srslte_signal_handler); - signal(SIGTERM, srslte_signal_handler); - signal(SIGHUP, srslte_signal_handler); - signal(SIGALRM, srslte_signal_handler); + signal(SIGINT, srsran_signal_handler); + signal(SIGTERM, srsran_signal_handler); + signal(SIGHUP, srsran_signal_handler); + signal(SIGALRM, srsran_signal_handler); } #ifdef __cplusplus } #endif // __cplusplus -#endif // SRSLTE_SIGNAL_HANDLER_H +#endif // SRSRAN_SIGNAL_HANDLER_H diff --git a/lib/include/srslte/common/singleton.h b/lib/include/srsran/common/singleton.h similarity index 87% rename from lib/include/srslte/common/singleton.h rename to lib/include/srsran/common/singleton.h index 8d04e7b83..16ede52e1 100644 --- a/lib/include/srslte/common/singleton.h +++ b/lib/include/srsran/common/singleton.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,8 +10,8 @@ * */ -#ifndef SRSLTE_SINGLETON_H -#define SRSLTE_SINGLETON_H +#ifndef SRSRAN_SINGLETON_H +#define SRSRAN_SINGLETON_H #include @@ -43,4 +43,4 @@ private: }; }; -#endif // SRSLTE_SINGLETON_H +#endif // SRSRAN_SINGLETON_H diff --git a/lib/include/srslte/common/ssl.h b/lib/include/srsran/common/ssl.h similarity index 94% rename from lib/include/srslte/common/ssl.h rename to lib/include/srsran/common/ssl.h index 70f95eaaf..da7f3dc03 100644 --- a/lib/include/srslte/common/ssl.h +++ b/lib/include/srsran/common/ssl.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,8 +10,8 @@ * */ -#ifndef SRSLTE_SSL_H -#define SRSLTE_SSL_H +#ifndef SRSRAN_SSL_H +#define SRSRAN_SSL_H #ifdef HAVE_POLARSSL @@ -73,4 +73,4 @@ void sha256(const unsigned char* key, #endif // HAVE_MBEDTLS -#endif // SRSLTE_SSL_H +#endif // SRSRAN_SSL_H diff --git a/lib/include/srslte/common/stack_procedure.h b/lib/include/srsran/common/stack_procedure.h similarity index 98% rename from lib/include/srslte/common/stack_procedure.h rename to lib/include/srsran/common/stack_procedure.h index 24f8d4897..fd781eb06 100644 --- a/lib/include/srslte/common/stack_procedure.h +++ b/lib/include/srsran/common/stack_procedure.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,17 +10,17 @@ * */ -#include "srslte/adt/move_callback.h" +#include "srsran/adt/move_callback.h" #include #include #include #include #include -#ifndef SRSLTE_RESUMABLE_PROCEDURES_H -#define SRSLTE_RESUMABLE_PROCEDURES_H +#ifndef SRSRAN_RESUMABLE_PROCEDURES_H +#define SRSRAN_RESUMABLE_PROCEDURES_H -namespace srslte { +namespace srsran { enum class proc_outcome_t { yield, success, error }; @@ -65,7 +65,7 @@ class callback_group_t { public: using callback_id_t = uint32_t; - using callback_t = srslte::move_callback; + using callback_t = srsran::move_callback; //! register callback, that gets called once callback_id_t on_next_call(callback_t f_) @@ -475,6 +475,6 @@ private: std::list proc_list; }; -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_RESUMABLE_PROCEDURES_H +#endif // SRSRAN_RESUMABLE_PROCEDURES_H diff --git a/lib/include/srslte/common/standard_streams.h b/lib/include/srsran/common/standard_streams.h similarity index 67% rename from lib/include/srslte/common/standard_streams.h rename to lib/include/srsran/common/standard_streams.h index 2505b031f..8acb4ab97 100644 --- a/lib/include/srslte/common/standard_streams.h +++ b/lib/include/srsran/common/standard_streams.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,10 +10,10 @@ * */ -#ifndef SRSLTE_STANDARD_STREAMS_H -#define SRSLTE_STANDARD_STREAMS_H +#ifndef SRSRAN_STANDARD_STREAMS_H +#define SRSRAN_STANDARD_STREAMS_H -namespace srslte { +namespace srsran { /// Writes the formatted string to the standard output stream. void console(const char* str, ...); @@ -21,6 +21,6 @@ void console(const char* str, ...); /// Writes the formatted string to the standard error stream. void console_stderr(const char* str, ...); -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_STANDARD_STREAMS_H \ No newline at end of file +#endif // SRSRAN_STANDARD_STREAMS_H \ No newline at end of file diff --git a/lib/include/srslte/common/string_helpers.h b/lib/include/srsran/common/string_helpers.h similarity index 91% rename from lib/include/srslte/common/string_helpers.h rename to lib/include/srsran/common/string_helpers.h index ca514380a..d20692568 100644 --- a/lib/include/srslte/common/string_helpers.h +++ b/lib/include/srsran/common/string_helpers.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,16 +10,16 @@ * */ -#ifndef SRSLTE_STRING_HELPERS_H -#define SRSLTE_STRING_HELPERS_H +#ifndef SRSRAN_STRING_HELPERS_H +#define SRSRAN_STRING_HELPERS_H -#include "srslte/srslog/bundled/fmt/format.h" +#include "srsran/srslog/bundled/fmt/format.h" #include #include #include #include -namespace srslte { +namespace srsran { /** * Removes all matching characters from a string @@ -119,6 +119,6 @@ const char* to_c_str(fmt::basic_memory_buffer& mem_buffer) return mem_buffer.data(); } -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_STRING_HELPERS_H +#endif // SRSRAN_STRING_HELPERS_H diff --git a/lib/include/srslte/common/task_scheduler.h b/lib/include/srsran/common/task_scheduler.h similarity index 75% rename from lib/include/srslte/common/task_scheduler.h rename to lib/include/srsran/common/task_scheduler.h index 6036c60af..ea1785ae3 100644 --- a/lib/include/srslte/common/task_scheduler.h +++ b/lib/include/srsran/common/task_scheduler.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,15 +10,15 @@ * */ -#ifndef SRSLTE_TASK_SCHEDULER_H -#define SRSLTE_TASK_SCHEDULER_H +#ifndef SRSRAN_TASK_SCHEDULER_H +#define SRSRAN_TASK_SCHEDULER_H #include "interfaces_common.h" #include "multiqueue.h" #include "thread_pool.h" #include "timers.h" -namespace srslte { +namespace srsran { class task_scheduler { @@ -35,11 +35,11 @@ public: void stop() { external_tasks.reset(); } - srslte::unique_timer get_unique_timer() { return timers.get_unique_timer(); } + srsran::unique_timer get_unique_timer() { return timers.get_unique_timer(); } //! Creates new queue for tasks coming from external thread - srslte::task_queue_handle make_task_queue() { return external_tasks.get_queue_handler(); } - srslte::task_queue_handle make_task_queue(uint32_t qsize) { return external_tasks.get_queue_handler(qsize); } + srsran::task_queue_handle make_task_queue() { return external_tasks.get_queue_handler(); } + srsran::task_queue_handle make_task_queue(uint32_t qsize) { return external_tasks.get_queue_handler(qsize); } //! Delays a task processing by duration_ms template @@ -49,10 +49,10 @@ public: } //! Enqueues internal task to be run in next tic - void defer_task(srslte::move_task_t func) { internal_tasks.push_back(std::move(func)); } + void defer_task(srsran::move_task_t func) { internal_tasks.push_back(std::move(func)); } //! Defer the handling of the result of a background task to next tic - void notify_background_task_result(srslte::move_task_t task) + void notify_background_task_result(srsran::move_task_t task) { // run the notification in next tic external_tasks.push(background_queue_id, std::move(task)); @@ -66,7 +66,7 @@ public: // CAUTION: This is a blocking call bool run_next_task() { - srslte::move_task_t task{}; + srsran::move_task_t task{}; if (external_tasks.wait_pop(&task) >= 0) { task(); run_all_internal_tasks(); @@ -80,14 +80,14 @@ public: void run_pending_tasks() { run_all_internal_tasks(); - srslte::move_task_t task{}; + srsran::move_task_t task{}; while (external_tasks.try_pop(&task) >= 0) { task(); run_all_internal_tasks(); } } - srslte::timer_handler* get_timer_handler() { return &timers; } + srsran::timer_handler* get_timer_handler() { return &timers; } private: void run_all_internal_tasks() @@ -102,9 +102,9 @@ private: } int background_queue_id = -1; ///< Queue for handling the outcomes of tasks run in the background - srslte::task_multiqueue external_tasks; - srslte::timer_handler timers; - std::deque internal_tasks; ///< enqueues stack tasks from within main thread. Avoids locking + srsran::task_multiqueue external_tasks; + srsran::timer_handler timers; + std::deque internal_tasks; ///< enqueues stack tasks from within main thread. Avoids locking }; //! Task scheduler handle given to classes/functions running within the main control thread @@ -113,8 +113,8 @@ class task_sched_handle public: task_sched_handle(task_scheduler* sched_) : sched(sched_) {} - srslte::unique_timer get_unique_timer() { return sched->get_unique_timer(); } - void notify_background_task_result(srslte::move_task_t task) + srsran::unique_timer get_unique_timer() { return sched->get_unique_timer(); } + void notify_background_task_result(srsran::move_task_t task) { sched->notify_background_task_result(std::move(task)); } @@ -123,7 +123,7 @@ public: { sched->defer_callback(duration_ms, std::forward(func)); } - void defer_task(srslte::move_task_t func) { sched->defer_task(std::move(func)); } + void defer_task(srsran::move_task_t func) { sched->defer_task(std::move(func)); } private: task_scheduler* sched; @@ -135,12 +135,12 @@ class ext_task_sched_handle public: ext_task_sched_handle(task_scheduler* sched_) : sched(sched_) {} - srslte::unique_timer get_unique_timer() { return sched->get_unique_timer(); } - void notify_background_task_result(srslte::move_task_t task) + srsran::unique_timer get_unique_timer() { return sched->get_unique_timer(); } + void notify_background_task_result(srsran::move_task_t task) { sched->notify_background_task_result(std::move(task)); } - srslte::task_queue_handle make_task_queue() { return sched->make_task_queue(); } + srsran::task_queue_handle make_task_queue() { return sched->make_task_queue(); } template void defer_callback(uint32_t duration_ms, F&& func) { @@ -151,6 +151,6 @@ private: task_scheduler* sched; }; -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_TASK_SCHEDULER_H +#endif // SRSRAN_TASK_SCHEDULER_H diff --git a/lib/include/srslte/common/test_common.h b/lib/include/srsran/common/test_common.h similarity index 94% rename from lib/include/srslte/common/test_common.h rename to lib/include/srsran/common/test_common.h index 224f2401e..e85632386 100644 --- a/lib/include/srslte/common/test_common.h +++ b/lib/include/srsran/common/test_common.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,19 +10,19 @@ * */ -#ifndef SRSLTE_TEST_COMMON_H -#define SRSLTE_TEST_COMMON_H +#ifndef SRSRAN_TEST_COMMON_H +#define SRSRAN_TEST_COMMON_H -#include "srslte/config.h" +#include "srsran/config.h" #ifdef __cplusplus -#include "srslte/common/standard_streams.h" -#include "srslte/srslog/srslog.h" +#include "srsran/common/standard_streams.h" +#include "srsran/srslog/srslog.h" #include #include -namespace srslte { +namespace srsran { /// This custom sink intercepts log messages to count error and warning log entries. class log_sink_spy : public srslog::sink @@ -128,12 +128,12 @@ private: std::vector entries; }; -} // namespace srslte +} // namespace srsran #define TESTERROR(fmt, ...) \ do { \ srslog::fetch_basic_logger("TEST").error(fmt, ##__VA_ARGS__); \ - return SRSLTE_ERROR; \ + return SRSRAN_ERROR; \ } while (0) #define TESTWARN(fmt, ...) \ @@ -164,4 +164,4 @@ private: #endif // __cplusplus -#endif // SRSLTE_TEST_COMMON_H +#endif // SRSRAN_TEST_COMMON_H diff --git a/lib/include/srslte/common/thread_pool.h b/lib/include/srsran/common/thread_pool.h similarity index 90% rename from lib/include/srslte/common/thread_pool.h rename to lib/include/srsran/common/thread_pool.h index af170a568..7d0d16d32 100644 --- a/lib/include/srslte/common/thread_pool.h +++ b/lib/include/srsran/common/thread_pool.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -17,11 +17,11 @@ * Reference: *****************************************************************************/ -#ifndef SRSLTE_THREAD_POOL_H -#define SRSLTE_THREAD_POOL_H +#ifndef SRSRAN_THREAD_POOL_H +#define SRSRAN_THREAD_POOL_H -#include "srslte/adt/move_callback.h" -#include "srslte/srslog/srslog.h" +#include "srsran/adt/move_callback.h" +#include "srsran/srslog/srslog.h" #include #include #include @@ -32,9 +32,9 @@ #include #include -#include "srslte/common/threads.h" +#include "srsran/common/threads.h" -namespace srslte { +namespace srsran { class thread_pool { @@ -88,7 +88,7 @@ private: class task_thread_pool { - using task_t = srslte::move_callback; + using task_t = srsran::move_callback; public: task_thread_pool(uint32_t nof_workers = 1, bool start_deferred = false, int32_t prio_ = -1, uint32_t mask_ = 255); @@ -136,8 +136,8 @@ private: bool running = false; }; -srslte::task_thread_pool& get_background_workers(); +srsran::task_thread_pool& get_background_workers(); -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_THREAD_POOL_H +#endif // SRSRAN_THREAD_POOL_H diff --git a/lib/include/srslte/common/threads.h b/lib/include/srsran/common/threads.h similarity index 96% rename from lib/include/srslte/common/threads.h rename to lib/include/srsran/common/threads.h index 7e8ba94f2..bbf8972d0 100644 --- a/lib/include/srslte/common/threads.h +++ b/lib/include/srsran/common/threads.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,8 +10,8 @@ * */ -#ifndef SRSLTE_THREADS_H -#define SRSLTE_THREADS_H +#ifndef SRSRAN_THREADS_H +#define SRSRAN_THREADS_H #include #include @@ -37,7 +37,7 @@ void threads_print_self(); #include -namespace srslte { +namespace srsran { class thread { @@ -196,8 +196,8 @@ private: } }; -} // namespace srslte +} // namespace srsran #endif // __cplusplus -#endif // SRSLTE_THREADS_H +#endif // SRSRAN_THREADS_H diff --git a/lib/include/srslte/common/time_prof.h b/lib/include/srsran/common/time_prof.h similarity index 94% rename from lib/include/srslte/common/time_prof.h rename to lib/include/srsran/common/time_prof.h index 775afb0f6..a2090e40f 100644 --- a/lib/include/srslte/common/time_prof.h +++ b/lib/include/srsran/common/time_prof.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,10 +10,10 @@ * */ -#ifndef SRSLTE_TIME_PROF_H -#define SRSLTE_TIME_PROF_H +#ifndef SRSRAN_TIME_PROF_H +#define SRSRAN_TIME_PROF_H -#include "srslte/srslog/srslog.h" +#include "srsran/srslog/srslog.h" #include #include @@ -23,7 +23,7 @@ #define TPROF_ENABLE_DEFAULT false #endif -namespace srslte { +namespace srsran { // individual time interval measure class tprof_measure @@ -153,6 +153,6 @@ public: }; using sliding_window_stats_ms = sliding_window_stats; -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_TIME_PROF_H +#endif // SRSRAN_TIME_PROF_H diff --git a/lib/include/srslte/common/timeout.h b/lib/include/srsran/common/timeout.h similarity index 92% rename from lib/include/srslte/common/timeout.h rename to lib/include/srsran/common/timeout.h index 5de6e5fab..b2a1dd86a 100644 --- a/lib/include/srslte/common/timeout.h +++ b/lib/include/srsran/common/timeout.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -17,16 +17,16 @@ * Reference: *****************************************************************************/ -#ifndef SRSLTE_TIMEOUT_H -#define SRSLTE_TIMEOUT_H +#ifndef SRSRAN_TIMEOUT_H +#define SRSRAN_TIMEOUT_H -#include "srslte/phy/utils/debug.h" +#include "srsran/phy/utils/debug.h" #include #include #include #include -namespace srslte { +namespace srsran { class timeout_callback { @@ -110,6 +110,6 @@ private: int duration_msec; }; -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_TIMEOUT_H +#endif // SRSRAN_TIMEOUT_H diff --git a/lib/include/srslte/common/timers.h b/lib/include/srsran/common/timers.h similarity index 94% rename from lib/include/srslte/common/timers.h rename to lib/include/srsran/common/timers.h index 883604a37..8824ee948 100644 --- a/lib/include/srslte/common/timers.h +++ b/lib/include/srsran/common/timers.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -17,11 +17,11 @@ * Reference: *****************************************************************************/ -#ifndef SRSLTE_TIMERS_H -#define SRSLTE_TIMERS_H +#ifndef SRSRAN_TIMERS_H +#define SRSRAN_TIMERS_H -#include "srslte/adt/move_callback.h" -#include "srslte/phy/utils/debug.h" +#include "srsran/adt/move_callback.h" +#include "srsran/phy/utils/debug.h" #include #include #include @@ -32,7 +32,7 @@ #include #include -namespace srslte { +namespace srsran { class timer_callback { @@ -50,7 +50,7 @@ class timer_handler uint32_t duration = 0, timeout = 0; bool running = false; bool active = false; - srslte::move_callback callback; + srsran::move_callback callback; explicit timer_impl(timer_handler* parent_) : parent(parent_) {} @@ -80,7 +80,7 @@ class timer_handler return true; } - bool set(uint32_t duration_, srslte::move_callback callback_) + bool set(uint32_t duration_, srsran::move_callback callback_) { if (set(duration_)) { callback = std::move(callback_); @@ -114,7 +114,7 @@ class timer_handler stop(); duration = 0; active = false; - callback = srslte::move_callback(); + callback = srsran::move_callback(); // leave run_id unchanged. Since the timeout was changed, we shall not get spurious triggering } @@ -275,7 +275,7 @@ public: void defer_callback(uint32_t duration, const F& func) { uint32_t id = alloc_timer(); - srslte::move_callback c = [func, this, id](uint32_t tid) { + srsran::move_callback c = [func, this, id](uint32_t tid) { func(); // auto-deletes timer timer_list[id].clear(); @@ -324,6 +324,6 @@ private: using unique_timer = timer_handler::unique_timer; -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_TIMERS_H +#endif // SRSRAN_TIMERS_H diff --git a/lib/include/srslte/common/trace.h b/lib/include/srsran/common/trace.h similarity index 91% rename from lib/include/srslte/common/trace.h rename to lib/include/srsran/common/trace.h index b93e53a9d..08194192e 100644 --- a/lib/include/srslte/common/trace.h +++ b/lib/include/srsran/common/trace.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -16,15 +16,15 @@ * Reference: *****************************************************************************/ -#ifndef SRSLTE_TRACE_H -#define SRSLTE_TRACE_H +#ifndef SRSRAN_TRACE_H +#define SRSRAN_TRACE_H #include #include #include #include -namespace srslte { +namespace srsran { template class trace @@ -86,6 +86,6 @@ private: } }; -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_TRACE_H +#endif // SRSRAN_TRACE_H diff --git a/lib/include/srslte/common/tti_point.h b/lib/include/srsran/common/tti_point.h similarity index 83% rename from lib/include/srslte/common/tti_point.h rename to lib/include/srsran/common/tti_point.h index e393337bb..a94adf779 100644 --- a/lib/include/srslte/common/tti_point.h +++ b/lib/include/srsran/common/tti_point.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,16 +10,16 @@ * */ -#ifndef SRSLTE_TTI_POINT_H -#define SRSLTE_TTI_POINT_H +#ifndef SRSRAN_TTI_POINT_H +#define SRSRAN_TTI_POINT_H -#include "srslte/adt/interval.h" -#include "srslte/common/common.h" -#include "srslte/srslog/srslog.h" +#include "srsran/adt/interval.h" +#include "srsran/common/common.h" +#include "srsran/srslog/srslog.h" #include #include -namespace srslte { +namespace srsran { struct tti_point { constexpr tti_point() = default; @@ -110,20 +110,20 @@ inline tti_point min(tti_point tti1, tti_point tti2) return tti1 < tti2 ? tti1 : tti2; } -using tti_interval = srslte::interval; +using tti_interval = srsran::interval; -} // namespace srslte +} // namespace srsran namespace fmt { template <> -struct formatter { +struct formatter { template auto parse(ParseContext& ctx) -> decltype(ctx.begin()) { return ctx.begin(); } template - auto format(srslte::tti_point tti, FormatContext& ctx) -> decltype(std::declval().out()) + auto format(srsran::tti_point tti, FormatContext& ctx) -> decltype(std::declval().out()) { return format_to(ctx.out(), "{}", tti.to_uint()); } @@ -132,25 +132,25 @@ struct formatter { namespace srsenb { -using tti_point = srslte::tti_point; +using tti_point = srsran::tti_point; -inline srslte::tti_point to_tx_dl(srslte::tti_point t) +inline srsran::tti_point to_tx_dl(srsran::tti_point t) { return t + TX_ENB_DELAY; } -inline srslte::tti_point to_tx_ul(srslte::tti_point t) +inline srsran::tti_point to_tx_ul(srsran::tti_point t) { return t + (TX_ENB_DELAY + FDD_HARQ_DELAY_DL_MS); } -inline srslte::tti_point to_tx_dl_ack(srslte::tti_point t) +inline srsran::tti_point to_tx_dl_ack(srsran::tti_point t) { return to_tx_ul(t); } -inline srslte::tti_point to_tx_ul_ack(srslte::tti_point t) +inline srsran::tti_point to_tx_ul_ack(srsran::tti_point t) { return to_tx_ul(t) + TX_ENB_DELAY; } } // namespace srsenb -#endif // SRSLTE_TTI_POINT_H +#endif // SRSRAN_TTI_POINT_H diff --git a/lib/include/srslte/common/tti_sempahore.h b/lib/include/srsran/common/tti_sempahore.h similarity index 91% rename from lib/include/srslte/common/tti_sempahore.h rename to lib/include/srsran/common/tti_sempahore.h index 26d4c67f2..f3a80fe9d 100644 --- a/lib/include/srslte/common/tti_sempahore.h +++ b/lib/include/srsran/common/tti_sempahore.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -16,10 +16,10 @@ #include #include -#ifndef SRSLTE_TTI_SEMPAHORE_H_ -#define SRSLTE_TTI_SEMPAHORE_H_ +#ifndef SRSRAN_TTI_SEMPAHORE_H_ +#define SRSRAN_TTI_SEMPAHORE_H_ -namespace srslte { +namespace srsran { /** * Implements priority semaphore based on a FIFO queue wait . This class enqueues T type element identifiers (method @@ -93,6 +93,6 @@ public: } } }; -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_TTI_SEMPAHORE_H_ +#endif // SRSRAN_TTI_SEMPAHORE_H_ diff --git a/lib/include/srslte/common/tti_sync.h b/lib/include/srsran/common/tti_sync.h similarity index 91% rename from lib/include/srslte/common/tti_sync.h rename to lib/include/srsran/common/tti_sync.h index a25b6d83a..e55f7dc8b 100644 --- a/lib/include/srslte/common/tti_sync.h +++ b/lib/include/srsran/common/tti_sync.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -19,12 +19,12 @@ * Reference: *****************************************************************************/ -#ifndef SRSLTE_TTI_SYNC_H -#define SRSLTE_TTI_SYNC_H +#ifndef SRSRAN_TTI_SYNC_H +#define SRSRAN_TTI_SYNC_H #include -namespace srslte { +namespace srsran { class tti_sync { @@ -60,6 +60,6 @@ protected: uint32_t consumer_cntr; }; -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_TTI_SYNC_H +#endif // SRSRAN_TTI_SYNC_H diff --git a/lib/include/srslte/common/tti_sync_cv.h b/lib/include/srsran/common/tti_sync_cv.h similarity index 78% rename from lib/include/srslte/common/tti_sync_cv.h rename to lib/include/srsran/common/tti_sync_cv.h index 9acbe9f74..a869b3438 100644 --- a/lib/include/srslte/common/tti_sync_cv.h +++ b/lib/include/srsran/common/tti_sync_cv.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -16,13 +16,13 @@ * Reference: *****************************************************************************/ -#ifndef SRSLTE_TTI_SYNC_CV_H -#define SRSLTE_TTI_SYNC_CV_H +#ifndef SRSRAN_TTI_SYNC_CV_H +#define SRSRAN_TTI_SYNC_CV_H -#include "srslte/common/tti_sync.h" +#include "srsran/common/tti_sync.h" #include -namespace srslte { +namespace srsran { class tti_sync_cv : public tti_sync { @@ -40,6 +40,6 @@ private: pthread_mutex_t mutex; }; -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_TTI_SYNC_CV_H +#endif // SRSRAN_TTI_SYNC_CV_H diff --git a/lib/include/srslte/common/zuc.h b/lib/include/srsran/common/zuc.h similarity index 87% rename from lib/include/srslte/common/zuc.h rename to lib/include/srsran/common/zuc.h index 290670519..35a044e9c 100644 --- a/lib/include/srslte/common/zuc.h +++ b/lib/include/srsran/common/zuc.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,8 +10,8 @@ * */ -#ifndef SRSLTE_ZUC_H -#define SRSLTE_ZUC_H +#ifndef SRSRAN_ZUC_H +#define SRSRAN_ZUC_H typedef unsigned char u8; typedef unsigned int u32; @@ -47,4 +47,4 @@ typedef struct { void zuc_initialize(zuc_state_t* state, const u8* k, u8* iv); void zuc_generate_keystream(zuc_state_t* state, int key_stream_len, u32* p_keystream); -#endif // SRSLTE_ZUC_H +#endif // SRSRAN_ZUC_H diff --git a/lib/include/srsran/config.h b/lib/include/srsran/config.h new file mode 100644 index 000000000..4bb98ff57 --- /dev/null +++ b/lib/include/srsran/config.h @@ -0,0 +1,64 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +#ifndef SRSRAN_CONFIG_H +#define SRSRAN_CONFIG_H + +// Generic helper definitions for shared library support +#if defined _WIN32 || defined __CYGWIN__ +#define SRSRAN_IMPORT __declspec(dllimport) +#define SRSRAN_EXPORT __declspec(dllexport) +#define SRSRAN_LOCAL +#else +#if __GNUC__ >= 4 +#define SRSRAN_IMPORT __attribute__((visibility("default"))) +#define SRSRAN_EXPORT __attribute__((visibility("default"))) +#else +#define SRSRAN_IMPORT +#define SRSRAN_EXPORT +#define SRSRAN_LOCAL +#endif +#endif + +// Define SRSRAN_API +// SRSRAN_API is used for the public API symbols. +#ifdef SRSRAN_DLL_EXPORTS // defined if we are building the SRSRAN DLL (instead of using it) +#define SRSRAN_API SRSRAN_EXPORT +#else +#define SRSRAN_API SRSRAN_IMPORT +#endif + +// Useful macros for templates +#define CONCAT(a, b) a##b +#define CONCAT2(a, b) CONCAT(a, b) + +#define STRING2(x) #x +#define STRING(x) STRING2(x) + +// Common error codes +#define SRSRAN_SUCCESS 0 +#define SRSRAN_ERROR -1 +#define SRSRAN_ERROR_INVALID_INPUTS -2 +#define SRSRAN_ERROR_TIMEOUT -3 +#define SRSRAN_ERROR_INVALID_COMMAND -4 +#define SRSRAN_ERROR_OUT_OF_BOUNDS -5 +#define SRSRAN_ERROR_CANT_START -6 +#define SRSRAN_ERROR_ALREADY_STARTED -7 + +// cf_t definition +typedef _Complex float cf_t; + +#ifdef ENABLE_C16 +typedef _Complex short int c16_t; +#endif /* ENABLE_C16 */ + +#endif // SRSRAN_CONFIG_H diff --git a/lib/include/srslte/interfaces/enb_command_interface.h b/lib/include/srsran/interfaces/enb_command_interface.h similarity index 75% rename from lib/include/srslte/interfaces/enb_command_interface.h rename to lib/include/srsran/interfaces/enb_command_interface.h index 4203d733a..3f9325b30 100644 --- a/lib/include/srslte/interfaces/enb_command_interface.h +++ b/lib/include/srsran/interfaces/enb_command_interface.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,8 +10,8 @@ * */ -#ifndef SRSLTE_ENB_COMMAND_INTERFACE_H -#define SRSLTE_ENB_COMMAND_INTERFACE_H +#ifndef SRSRAN_ENB_COMMAND_INTERFACE_H +#define SRSRAN_ENB_COMMAND_INTERFACE_H #include @@ -28,4 +28,4 @@ public: }; } // namespace srsenb -#endif // SRSLTE_ENB_COMMAND_INTERFACE_H +#endif // SRSRAN_ENB_COMMAND_INTERFACE_H diff --git a/lib/include/srslte/interfaces/enb_gtpu_interfaces.h b/lib/include/srsran/interfaces/enb_gtpu_interfaces.h similarity index 79% rename from lib/include/srslte/interfaces/enb_gtpu_interfaces.h rename to lib/include/srsran/interfaces/enb_gtpu_interfaces.h index e99cf8746..8d882065e 100644 --- a/lib/include/srslte/interfaces/enb_gtpu_interfaces.h +++ b/lib/include/srsran/interfaces/enb_gtpu_interfaces.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,10 +10,10 @@ * */ -#ifndef SRSLTE_ENB_GTPU_INTERFACES_H -#define SRSLTE_ENB_GTPU_INTERFACES_H +#ifndef SRSRAN_ENB_GTPU_INTERFACES_H +#define SRSRAN_ENB_GTPU_INTERFACES_H -#include "srslte/common/byte_buffer.h" +#include "srsran/common/byte_buffer.h" namespace srsenb { @@ -21,7 +21,7 @@ namespace srsenb { class gtpu_interface_pdcp { public: - virtual void write_pdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t pdu) = 0; + virtual void write_pdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t pdu) = 0; }; // GTPU interface for RRC @@ -45,4 +45,4 @@ public: } // namespace srsenb -#endif // SRSLTE_ENB_GTPU_INTERFACES_H +#endif // SRSRAN_ENB_GTPU_INTERFACES_H diff --git a/lib/include/srslte/interfaces/enb_interfaces.h b/lib/include/srsran/interfaces/enb_interfaces.h similarity index 68% rename from lib/include/srslte/interfaces/enb_interfaces.h rename to lib/include/srsran/interfaces/enb_interfaces.h index aba3ca9d7..7b42ed9fb 100644 --- a/lib/include/srslte/interfaces/enb_interfaces.h +++ b/lib/include/srsran/interfaces/enb_interfaces.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,12 +10,12 @@ * */ -#include "srslte/common/common.h" -#include "srslte/common/interfaces_common.h" -#include "srslte/srslte.h" +#include "srsran/common/common.h" +#include "srsran/common/interfaces_common.h" +#include "srsran/srsran.h" -#ifndef SRSLTE_ENB_INTERFACES_H -#define SRSLTE_ENB_INTERFACES_H +#ifndef SRSRAN_ENB_INTERFACES_H +#define SRSRAN_ENB_INTERFACES_H namespace srsenb { @@ -36,4 +36,4 @@ public: } // namespace srsenb -#endif // SRSLTE_ENB_INTERFACES_H +#endif // SRSRAN_ENB_INTERFACES_H diff --git a/lib/include/srslte/interfaces/enb_mac_interfaces.h b/lib/include/srsran/interfaces/enb_mac_interfaces.h similarity index 87% rename from lib/include/srslte/interfaces/enb_mac_interfaces.h rename to lib/include/srsran/interfaces/enb_mac_interfaces.h index 0b4d6f3fd..9dc5ff4c2 100644 --- a/lib/include/srslte/interfaces/enb_mac_interfaces.h +++ b/lib/include/srsran/interfaces/enb_mac_interfaces.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,11 +10,11 @@ * */ -#include "srslte/interfaces/rrc_interface_types.h" -#include "srslte/interfaces/sched_interface.h" +#include "srsran/interfaces/rrc_interface_types.h" +#include "srsran/interfaces/sched_interface.h" -#ifndef SRSLTE_ENB_MAC_INTERFACES_H -#define SRSLTE_ENB_MAC_INTERFACES_H +#ifndef SRSRAN_ENB_MAC_INTERFACES_H +#define SRSRAN_ENB_MAC_INTERFACES_H namespace srsenb { @@ -35,9 +35,9 @@ public: * DL grant structure per UE */ struct dl_sched_grant_t { - srslte_dci_dl_t dci = {}; - uint8_t* data[SRSLTE_MAX_TB] = {}; - srslte_softbuffer_tx_t* softbuffer_tx[SRSLTE_MAX_TB] = {}; + srsran_dci_dl_t dci = {}; + uint8_t* data[SRSRAN_MAX_TB] = {}; + srsran_softbuffer_tx_t* softbuffer_tx[SRSRAN_MAX_TB] = {}; }; /** @@ -63,12 +63,12 @@ public: * UL grant information per UE */ typedef struct { - srslte_dci_ul_t dci; + srsran_dci_ul_t dci; uint32_t pid; uint32_t current_tx_nb; uint8_t* data; bool needs_pdcch; - srslte_softbuffer_rx_t* softbuffer_rx; + srsran_softbuffer_rx_t* softbuffer_rx; } ul_sched_grant_t; /** @@ -96,7 +96,7 @@ public: * @param rnti the UE identifier in the eNb * @param cc_idx The eNb Cell/Carrier where the measurement corresponds * @param ri_value the actual Rank Indicator value, 0 for 1 layer, 1 for two layers and so on. - * @return SRSLTE_SUCCESS if no error occurs, SRSLTE_ERROR* if an error occurs + * @return SRSRAN_SUCCESS if no error occurs, SRSRAN_ERROR* if an error occurs */ virtual int ri_info(uint32_t tti, uint16_t rnti, uint32_t cc_idx, uint32_t ri_value) = 0; @@ -107,7 +107,7 @@ public: * @param rnti the UE identifier in the eNb * @param cc_idx The eNb Cell/Carrier where the measurement corresponds * @param pmi_value the actual PMI value - * @return SRSLTE_SUCCESS if no error occurs, SRSLTE_ERROR* if an error occurs + * @return SRSRAN_SUCCESS if no error occurs, SRSRAN_ERROR* if an error occurs */ virtual int pmi_info(uint32_t tti, uint16_t rnti, uint32_t cc_idx, uint32_t pmi_value) = 0; @@ -117,7 +117,7 @@ public: * @param rnti the UE identifier in the eNb * @param cc_idx The eNb Cell/Carrier where the measurement corresponds * @param cqi_value the corresponding Channel Quality Information - * @return SRSLTE_SUCCESS if no error occurs, SRSLTE_ERROR* if an error occurs + * @return SRSRAN_SUCCESS if no error occurs, SRSRAN_ERROR* if an error occurs */ virtual int cqi_info(uint32_t tti, uint16_t rnti, uint32_t cc_idx, uint32_t cqi_value) = 0; @@ -131,7 +131,7 @@ public: * @param cc_idx The eNb Cell/Carrier where the UL transmission was received * @param snr_db The actual SNR of the received signal * @param ch Indicates uplink channel (PUSCH, PUCCH or SRS) - * @return SRSLTE_SUCCESS if no error occurs, SRSLTE_ERROR* if an error occurs + * @return SRSRAN_SUCCESS if no error occurs, SRSRAN_ERROR* if an error occurs */ virtual int snr_info(uint32_t tti, uint16_t rnti, uint32_t cc_idx, float snr_db, ul_channel_t ch) = 0; @@ -141,7 +141,7 @@ public: * @param tti The measurement was made * @param rnti The UE identifier in the eNb * @param ta_us The actual time alignment in microseconds - * @return SRSLTE_SUCCESS if no error occurs, SRSLTE_ERROR* if an error occurs + * @return SRSRAN_SUCCESS if no error occurs, SRSRAN_ERROR* if an error occurs */ virtual int ta_info(uint32_t tti, uint16_t rnti, float ta_us) = 0; @@ -154,7 +154,7 @@ public: * @param cc_idx the eNb Cell/Carrier identifier * @param tb_idx the transport block index * @param ack true for ACK, false for NACK, do not call for DTX - * @return SRSLTE_SUCCESS if no error occurs, SRSLTE_ERROR* if an error occurs + * @return SRSRAN_SUCCESS if no error occurs, SRSRAN_ERROR* if an error occurs */ virtual int ack_info(uint32_t tti, uint16_t rnti, uint32_t cc_idx, uint32_t tb_idx, bool ack) = 0; @@ -169,7 +169,7 @@ public: * @param cc_idx the eNb Cell/Carrier identifier * @param nof_bytes the number of grants carrierd by the PUSCH message * @param crc_res the CRC check, set to true if the message was decoded succesfully - * @return SRSLTE_SUCCESS if no error occurs, SRSLTE_ERROR* if an error occurs + * @return SRSRAN_SUCCESS if no error occurs, SRSRAN_ERROR* if an error occurs */ virtual int crc_info(uint32_t tti, uint16_t rnti, uint32_t cc_idx, uint32_t nof_bytes, bool crc_res) = 0; @@ -181,7 +181,7 @@ public: * @param enb_cc_idx the eNb Cell/Carrier identifier * @param nof_bytes the number of grants carrierd by the PUSCH message * @param crc_res the CRC check, set to true if the message was decoded succesfully - * @return SRSLTE_SUCCESS if no error occurs, SRSLTE_ERROR* if an error occurs + * @return SRSRAN_SUCCESS if no error occurs, SRSRAN_ERROR* if an error occurs */ virtual int push_pdu(uint32_t tti_rx, uint16_t rnti, uint32_t enb_cc_idx, uint32_t nof_bytes, bool crc_res) = 0; @@ -222,9 +222,9 @@ public: virtual int bearer_ue_cfg(uint16_t rnti, uint32_t lc_id, sched_interface::ue_bearer_cfg_t* cfg) = 0; virtual int bearer_ue_rem(uint16_t rnti, uint32_t lc_id) = 0; virtual void phy_config_enabled(uint16_t rnti, bool enabled) = 0; - virtual void write_mcch(const srslte::sib2_mbms_t* sib2_, - const srslte::sib13_t* sib13_, - const srslte::mcch_msg_t* mcch_, + virtual void write_mcch(const srsran::sib2_mbms_t* sib2_, + const srsran::sib13_t* sib13_, + const srsran::mcch_msg_t* mcch_, const uint8_t* mcch_payload, const uint8_t mcch_payload_length) = 0; @@ -244,4 +244,4 @@ public: } // namespace srsenb -#endif // SRSLTE_ENB_MAC_INTERFACES_H +#endif // SRSRAN_ENB_MAC_INTERFACES_H diff --git a/lib/include/srslte/interfaces/enb_metrics_interface.h b/lib/include/srsran/interfaces/enb_metrics_interface.h similarity index 62% rename from lib/include/srslte/interfaces/enb_metrics_interface.h rename to lib/include/srsran/interfaces/enb_metrics_interface.h index 1823ebb66..fd2a51b4d 100644 --- a/lib/include/srslte/interfaces/enb_metrics_interface.h +++ b/lib/include/srsran/interfaces/enb_metrics_interface.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,8 +10,8 @@ * */ -#ifndef SRSLTE_ENB_METRICS_INTERFACE_H -#define SRSLTE_ENB_METRICS_INTERFACE_H +#ifndef SRSRAN_ENB_METRICS_INTERFACE_H +#define SRSRAN_ENB_METRICS_INTERFACE_H #include @@ -20,21 +20,21 @@ #include "srsenb/hdr/stack/rrc/rrc_metrics.h" #include "srsenb/hdr/stack/upper/common_enb.h" #include "srsenb/hdr/stack/upper/s1ap_metrics.h" -#include "srslte/system/sys_metrics.h" -#include "srslte/common/metrics_hub.h" -#include "srslte/radio/radio_metrics.h" -#include "srslte/upper/pdcp_metrics.h" -#include "srslte/upper/rlc_metrics.h" +#include "srsran/common/metrics_hub.h" +#include "srsran/radio/radio_metrics.h" +#include "srsran/system/sys_metrics.h" +#include "srsran/upper/pdcp_metrics.h" +#include "srsran/upper/rlc_metrics.h" #include "srsue/hdr/stack/upper/gw_metrics.h" namespace srsenb { struct rlc_metrics_t { - std::vector ues; + std::vector ues; }; struct pdcp_metrics_t { - std::vector ues; + std::vector ues; }; struct stack_metrics_t { @@ -46,15 +46,15 @@ struct stack_metrics_t { }; struct enb_metrics_t { - srslte::rf_metrics_t rf; + srsran::rf_metrics_t rf; std::vector phy; stack_metrics_t stack; - srslte::sys_metrics_t sys; + srsran::sys_metrics_t sys; bool running; }; // ENB interface -class enb_metrics_interface : public srslte::metrics_interface +class enb_metrics_interface : public srsran::metrics_interface { public: virtual bool get_metrics(enb_metrics_t* m) = 0; @@ -62,4 +62,4 @@ public: } // namespace srsenb -#endif // SRSLTE_ENB_METRICS_INTERFACE_H +#endif // SRSRAN_ENB_METRICS_INTERFACE_H diff --git a/lib/include/srslte/interfaces/enb_pdcp_interfaces.h b/lib/include/srsran/interfaces/enb_pdcp_interfaces.h similarity index 70% rename from lib/include/srslte/interfaces/enb_pdcp_interfaces.h rename to lib/include/srsran/interfaces/enb_pdcp_interfaces.h index 719c46e4f..e49604591 100644 --- a/lib/include/srslte/interfaces/enb_pdcp_interfaces.h +++ b/lib/include/srsran/interfaces/enb_pdcp_interfaces.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,12 +10,12 @@ * */ -#include "srslte/common/byte_buffer.h" -#include "srslte/interfaces/pdcp_interface_types.h" +#include "srsran/common/byte_buffer.h" +#include "srsran/interfaces/pdcp_interface_types.h" #include -#ifndef SRSLTE_ENB_PDCP_INTERFACES_H -#define SRSLTE_ENB_PDCP_INTERFACES_H +#ifndef SRSRAN_ENB_PDCP_INTERFACES_H +#define SRSRAN_ENB_PDCP_INTERFACES_H namespace srsenb { @@ -23,8 +23,8 @@ namespace srsenb { class pdcp_interface_gtpu { public: - virtual void write_sdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t sdu, int pdcp_sn = -1) = 0; - virtual std::map get_buffered_pdus(uint16_t rnti, uint32_t lcid) = 0; + virtual void write_sdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t sdu, int pdcp_sn = -1) = 0; + virtual std::map get_buffered_pdus(uint16_t rnti, uint32_t lcid) = 0; }; // PDCP interface for RRC @@ -34,16 +34,16 @@ public: virtual void reset(uint16_t rnti) = 0; virtual void add_user(uint16_t rnti) = 0; virtual void rem_user(uint16_t rnti) = 0; - virtual void write_sdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t sdu, int pdcp_sn = -1) = 0; - virtual void add_bearer(uint16_t rnti, uint32_t lcid, srslte::pdcp_config_t cnfg) = 0; + virtual void write_sdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t sdu, int pdcp_sn = -1) = 0; + virtual void add_bearer(uint16_t rnti, uint32_t lcid, srsran::pdcp_config_t cnfg) = 0; virtual void del_bearer(uint16_t rnti, uint32_t lcid) = 0; - virtual void config_security(uint16_t rnti, uint32_t lcid, srslte::as_security_config_t sec_cfg) = 0; + virtual void config_security(uint16_t rnti, uint32_t lcid, srsran::as_security_config_t sec_cfg) = 0; virtual void enable_integrity(uint16_t rnti, uint32_t lcid) = 0; virtual void enable_encryption(uint16_t rnti, uint32_t lcid) = 0; virtual void send_status_report(uint16_t rnti) = 0; virtual void send_status_report(uint16_t rnti, uint32_t lcid) = 0; - virtual bool get_bearer_state(uint16_t rnti, uint32_t lcid, srslte::pdcp_lte_state_t* state) = 0; - virtual bool set_bearer_state(uint16_t rnti, uint32_t lcid, const srslte::pdcp_lte_state_t& state) = 0; + virtual bool get_bearer_state(uint16_t rnti, uint32_t lcid, srsran::pdcp_lte_state_t* state) = 0; + virtual bool set_bearer_state(uint16_t rnti, uint32_t lcid, const srsran::pdcp_lte_state_t& state) = 0; virtual void reestablish(uint16_t rnti) = 0; }; @@ -52,11 +52,11 @@ class pdcp_interface_rlc { public: /* RLC calls PDCP to push a PDCP PDU. */ - virtual void write_pdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t pdu) = 0; - virtual void notify_delivery(uint16_t rnti, uint32_t lcid, const srslte::pdcp_sn_vector_t& pdcp_sns) = 0; - virtual void notify_failure(uint16_t rnti, uint32_t lcid, const srslte::pdcp_sn_vector_t& pdcp_sns) = 0; + virtual void write_pdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t pdu) = 0; + virtual void notify_delivery(uint16_t rnti, uint32_t lcid, const srsran::pdcp_sn_vector_t& pdcp_sns) = 0; + virtual void notify_failure(uint16_t rnti, uint32_t lcid, const srsran::pdcp_sn_vector_t& pdcp_sns) = 0; }; } // namespace srsenb -#endif // SRSLTE_ENB_PDCP_INTERFACES_H +#endif // SRSRAN_ENB_PDCP_INTERFACES_H diff --git a/lib/include/srslte/interfaces/enb_phy_interfaces.h b/lib/include/srsran/interfaces/enb_phy_interfaces.h similarity index 83% rename from lib/include/srslte/interfaces/enb_phy_interfaces.h rename to lib/include/srsran/interfaces/enb_phy_interfaces.h index 864f23c51..d31b679cb 100644 --- a/lib/include/srslte/interfaces/enb_phy_interfaces.h +++ b/lib/include/srsran/interfaces/enb_phy_interfaces.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,11 +10,11 @@ * */ -#include "srslte/interfaces/rrc_interface_types.h" -#include "srslte/phy/common/phy_common.h" +#include "srsran/interfaces/rrc_interface_types.h" +#include "srsran/phy/common/phy_common.h" -#ifndef SRSLTE_ENB_PHY_INTERFACES_H -#define SRSLTE_ENB_PHY_INTERFACES_H +#ifndef SRSRAN_ENB_PHY_INTERFACES_H +#define SRSRAN_ENB_PHY_INTERFACES_H namespace srsenb { @@ -43,21 +43,21 @@ public: * @param activation vector with the activate/deactivate. */ virtual void set_activation_deactivation_scell(uint16_t rnti, - const std::array& activation) = 0; + const std::array& activation) = 0; }; /* Interface RRC -> PHY */ class phy_interface_rrc_lte { public: - srslte::phy_cfg_mbsfn_t mbsfn_cfg; + srsran::phy_cfg_mbsfn_t mbsfn_cfg; - virtual void configure_mbsfn(srslte::sib2_mbms_t* sib2, srslte::sib13_t* sib13, const srslte::mcch_msg_t& mcch) = 0; + virtual void configure_mbsfn(srsran::sib2_mbms_t* sib2, srsran::sib13_t* sib13, const srsran::mcch_msg_t& mcch) = 0; struct phy_rrc_cfg_t { bool configured = false; ///< Indicates whether PHY shall consider configuring this cell/carrier uint32_t enb_cc_idx = 0; ///< eNb Cell index - srslte::phy_cfg_t phy_cfg = {}; ///< Dedicated physical layer configuration + srsran::phy_cfg_t phy_cfg = {}; ///< Dedicated physical layer configuration }; typedef std::vector phy_rrc_cfg_list_t; @@ -91,4 +91,4 @@ class phy_interface_stack_lte : public phy_interface_mac_lte, public phy_interfa } // namespace srsenb -#endif // SRSLTE_ENB_PHY_INTERFACES_H +#endif // SRSRAN_ENB_PHY_INTERFACES_H diff --git a/lib/include/srslte/interfaces/enb_rlc_interfaces.h b/lib/include/srsran/interfaces/enb_rlc_interfaces.h similarity index 84% rename from lib/include/srslte/interfaces/enb_rlc_interfaces.h rename to lib/include/srsran/interfaces/enb_rlc_interfaces.h index 02b1057be..5d7be6b3f 100644 --- a/lib/include/srslte/interfaces/enb_rlc_interfaces.h +++ b/lib/include/srsran/interfaces/enb_rlc_interfaces.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,11 +10,11 @@ * */ -#ifndef SRSLTE_ENB_RLC_INTERFACES_H -#define SRSLTE_ENB_RLC_INTERFACES_H +#ifndef SRSRAN_ENB_RLC_INTERFACES_H +#define SRSRAN_ENB_RLC_INTERFACES_H -#include "srslte/common/byte_buffer.h" -#include "srslte/interfaces/rlc_interface_types.h" +#include "srsran/common/byte_buffer.h" +#include "srsran/interfaces/rlc_interface_types.h" namespace srsenb { @@ -39,7 +39,7 @@ class rlc_interface_pdcp public: /* PDCP calls RLC to push an RLC SDU. SDU gets placed into the RLC buffer and MAC pulls * RLC PDUs according to TB size. */ - virtual void write_sdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t sdu) = 0; + virtual void write_sdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t sdu) = 0; virtual void discard_sdu(uint16_t rnti, uint32_t lcid, uint32_t sn) = 0; virtual bool rb_is_um(uint16_t rnti, uint32_t lcid) = 0; virtual bool sdu_queue_is_full(uint16_t rnti, uint32_t lcid) = 0; @@ -52,10 +52,10 @@ public: virtual void clear_buffer(uint16_t rnti) = 0; virtual void add_user(uint16_t rnti) = 0; virtual void rem_user(uint16_t rnti) = 0; - virtual void add_bearer(uint16_t rnti, uint32_t lcid, srslte::rlc_config_t cnfg) = 0; + virtual void add_bearer(uint16_t rnti, uint32_t lcid, srsran::rlc_config_t cnfg) = 0; virtual void add_bearer_mrb(uint16_t rnti, uint32_t lcid) = 0; virtual void del_bearer(uint16_t rnti, uint32_t lcid) = 0; - virtual void write_sdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t sdu) = 0; + virtual void write_sdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t sdu) = 0; virtual bool has_bearer(uint16_t rnti, uint32_t lcid) = 0; virtual bool suspend_bearer(uint16_t rnti, uint32_t lcid) = 0; virtual bool resume_bearer(uint16_t rnti, uint32_t lcid) = 0; @@ -64,4 +64,4 @@ public: } // namespace srsenb -#endif // SRSLTE_ENB_RLC_INTERFACES_H +#endif // SRSRAN_ENB_RLC_INTERFACES_H diff --git a/lib/include/srslte/interfaces/enb_rrc_interface_types.h b/lib/include/srsran/interfaces/enb_rrc_interface_types.h similarity index 87% rename from lib/include/srslte/interfaces/enb_rrc_interface_types.h rename to lib/include/srsran/interfaces/enb_rrc_interface_types.h index 22be4e7a7..9370ddb4e 100644 --- a/lib/include/srslte/interfaces/enb_rrc_interface_types.h +++ b/lib/include/srsran/interfaces/enb_rrc_interface_types.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,10 +10,10 @@ * */ -#ifndef SRSLTE_ENB_RRC_INTERFACE_TYPES_H -#define SRSLTE_ENB_RRC_INTERFACE_TYPES_H +#ifndef SRSRAN_ENB_RRC_INTERFACE_TYPES_H +#define SRSRAN_ENB_RRC_INTERFACE_TYPES_H -#include "srslte/asn1/rrc/meascfg.h" +#include "srsran/asn1/rrc/meascfg.h" #include namespace srsenb { @@ -64,4 +64,4 @@ typedef std::vector cell_list_t; } // namespace srsenb -#endif // SRSLTE_ENB_RRC_INTERFACE_TYPES_H +#endif // SRSRAN_ENB_RRC_INTERFACE_TYPES_H diff --git a/lib/include/srslte/interfaces/enb_rrc_interfaces.h b/lib/include/srsran/interfaces/enb_rrc_interfaces.h similarity index 85% rename from lib/include/srslte/interfaces/enb_rrc_interfaces.h rename to lib/include/srsran/interfaces/enb_rrc_interfaces.h index 6028b4bc2..aadf3d560 100644 --- a/lib/include/srslte/interfaces/enb_rrc_interfaces.h +++ b/lib/include/srsran/interfaces/enb_rrc_interfaces.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,12 +10,12 @@ * */ -#include "srslte/asn1/s1ap_utils.h" -#include "srslte/interfaces/enb_rrc_interface_types.h" -#include "srslte/interfaces/sched_interface.h" +#include "srsran/asn1/s1ap_utils.h" +#include "srsran/interfaces/enb_rrc_interface_types.h" +#include "srsran/interfaces/sched_interface.h" -#ifndef SRSLTE_ENB_RRC_INTERFACES_H -#define SRSLTE_ENB_RRC_INTERFACES_H +#ifndef SRSRAN_ENB_RRC_INTERFACES_H +#define SRSRAN_ENB_RRC_INTERFACES_H namespace srsenb { @@ -23,7 +23,7 @@ namespace srsenb { class rrc_interface_s1ap { public: - virtual void write_dl_info(uint16_t rnti, srslte::unique_byte_buffer_t sdu) = 0; + virtual void write_dl_info(uint16_t rnti, srsran::unique_byte_buffer_t sdu) = 0; virtual void release_complete(uint16_t rnti) = 0; virtual bool setup_ue_ctxt(uint16_t rnti, const asn1::s1ap::init_context_setup_request_s& msg) = 0; virtual bool modify_ue_ctxt(uint16_t rnti, const asn1::s1ap::ue_context_mod_request_s& msg) = 0; @@ -50,7 +50,7 @@ public: virtual void ho_preparation_complete(uint16_t rnti, bool is_success, const asn1::s1ap::ho_cmd_s& msg, - srslte::unique_byte_buffer_t container) = 0; + srsran::unique_byte_buffer_t container) = 0; virtual uint16_t start_ho_ue_resource_alloc(const asn1::s1ap::ho_request_s& msg, const asn1::s1ap::sourceenb_to_targetenb_transparent_container_s& container) = 0; @@ -63,7 +63,7 @@ class rrc_interface_rlc public: virtual void read_pdu_pcch(uint8_t* payload, uint32_t payload_size) = 0; virtual void max_retx_attempted(uint16_t rnti) = 0; - virtual void write_pdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t sdu) = 0; + virtual void write_pdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t sdu) = 0; }; /// RRC interface for MAC @@ -84,9 +84,9 @@ public: class rrc_interface_pdcp { public: - virtual void write_pdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t pdu) = 0; + virtual void write_pdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t pdu) = 0; }; } // namespace srsenb -#endif // SRSLTE_ENB_RRC_INTERFACES_H +#endif // SRSRAN_ENB_RRC_INTERFACES_H diff --git a/lib/include/srslte/interfaces/enb_s1ap_interfaces.h b/lib/include/srsran/interfaces/enb_s1ap_interfaces.h similarity index 83% rename from lib/include/srslte/interfaces/enb_s1ap_interfaces.h rename to lib/include/srsran/interfaces/enb_s1ap_interfaces.h index 90d7cdca4..211d92cb3 100644 --- a/lib/include/srslte/interfaces/enb_s1ap_interfaces.h +++ b/lib/include/srsran/interfaces/enb_s1ap_interfaces.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,11 +10,11 @@ * */ -#include "srslte/asn1/s1ap_utils.h" -#include "srslte/interfaces/rrc_interface_types.h" +#include "srsran/asn1/s1ap_utils.h" +#include "srsran/interfaces/rrc_interface_types.h" -#ifndef SRSLTE_ENB_S1AP_INTERFACES_H -#define SRSLTE_ENB_S1AP_INTERFACES_H +#ifndef SRSRAN_ENB_S1AP_INTERFACES_H +#define SRSRAN_ENB_S1AP_INTERFACES_H namespace srsenb { @@ -43,15 +43,15 @@ public: virtual void initial_ue(uint16_t rnti, uint32_t enb_cc_idx, asn1::s1ap::rrc_establishment_cause_e cause, - srslte::unique_byte_buffer_t pdu) = 0; + srsran::unique_byte_buffer_t pdu) = 0; virtual void initial_ue(uint16_t rnti, uint32_t enb_cc_idx, asn1::s1ap::rrc_establishment_cause_e cause, - srslte::unique_byte_buffer_t pdu, + srsran::unique_byte_buffer_t pdu, uint32_t m_tmsi, uint8_t mmec) = 0; - virtual void write_pdu(uint16_t rnti, srslte::unique_byte_buffer_t pdu) = 0; + virtual void write_pdu(uint16_t rnti, srsran::unique_byte_buffer_t pdu) = 0; virtual bool user_exists(uint16_t rnti) = 0; virtual void user_mod(uint16_t old_rnti, uint16_t new_rnti) = 0; virtual bool user_release(uint16_t rnti, asn1::s1ap::cause_radio_network_e cause_radio) = 0; @@ -72,9 +72,9 @@ public: */ virtual bool send_ho_required(uint16_t rnti, uint32_t target_eci, - srslte::plmn_id_t target_plmn, - srslte::span fwd_erabs, - srslte::unique_byte_buffer_t rrc_container) = 0; + srsran::plmn_id_t target_plmn, + srsran::span fwd_erabs, + srsran::unique_byte_buffer_t rrc_container) = 0; /** * Command the s1ap to transmit eNBStatusTransfer message to MME. This message passes the PDCP context of the UE @@ -91,8 +91,8 @@ public: virtual bool send_ho_req_ack(const asn1::s1ap::ho_request_s& msg, uint16_t rnti, uint32_t enb_cc_idx, - srslte::unique_byte_buffer_t ho_cmd, - srslte::span admitted_bearers) = 0; + srsran::unique_byte_buffer_t ho_cmd, + srsran::span admitted_bearers) = 0; /** * Notify MME that Handover is complete @@ -111,9 +111,9 @@ public: */ virtual bool release_erabs(uint16_t rnti, const std::vector& erabs_successfully_released) = 0; - virtual bool send_ue_cap_info_indication(uint16_t rnti, srslte::unique_byte_buffer_t ue_radio_cap) = 0; + virtual bool send_ue_cap_info_indication(uint16_t rnti, srsran::unique_byte_buffer_t ue_radio_cap) = 0; }; } // namespace srsenb -#endif // SRSLTE_ENB_S1AP_INTERFACES_H +#endif // SRSRAN_ENB_S1AP_INTERFACES_H diff --git a/lib/include/srslte/interfaces/epc_interfaces.h b/lib/include/srsran/interfaces/epc_interfaces.h similarity index 87% rename from lib/include/srslte/interfaces/epc_interfaces.h rename to lib/include/srsran/interfaces/epc_interfaces.h index bf86d6743..7b0fee0b2 100644 --- a/lib/include/srslte/interfaces/epc_interfaces.h +++ b/lib/include/srsran/interfaces/epc_interfaces.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,11 +10,11 @@ * */ -#ifndef SRSLTE_EPC_INTERFACES_H -#define SRSLTE_EPC_INTERFACES_H +#ifndef SRSRAN_EPC_INTERFACES_H +#define SRSRAN_EPC_INTERFACES_H -#include "srslte/asn1/gtpc_ies.h" -#include "srslte/common/common.h" +#include "srsran/asn1/gtpc_ies.h" +#include "srsran/common/common.h" #include #include @@ -33,10 +33,10 @@ class gtpc_interface_nas // NAS -> GTP-C { public: virtual bool send_create_session_request(uint64_t imsi) = 0; - virtual bool send_modify_bearer_request(uint64_t imsi, uint16_t erab_to_modify, srslte::gtp_fteid_t* enb_fteid) = 0; + virtual bool send_modify_bearer_request(uint64_t imsi, uint16_t erab_to_modify, srsran::gtp_fteid_t* enb_fteid) = 0; virtual bool send_delete_session_request(uint64_t imsi) = 0; virtual bool send_downlink_data_notification_failure_indication(uint64_t imsi, - enum srslte::gtpc_cause_value cause) = 0; + enum srsran::gtpc_cause_value cause) = 0; }; class s1ap_interface_gtpc // GTP-C -> S1AP @@ -66,11 +66,11 @@ public: virtual bool send_erab_modify_request(uint32_t enb_ue_s1ap_id, uint32_t mme_ue_s1ap_id, std::map erabs_to_modify, - srslte::byte_buffer_t* nas_msg, + srsran::byte_buffer_t* nas_msg, struct sctp_sndrcvinfo enb_sri) = 0; virtual bool send_downlink_nas_transport(uint32_t enb_ue_s1ap_id, uint32_t mme_ue_s1ap_id, - srslte::byte_buffer_t* nas_msg, + srsran::byte_buffer_t* nas_msg, struct sctp_sndrcvinfo enb_sri) = 0; }; @@ -104,19 +104,19 @@ class gtpu_interface_gtpc // GTP-C -> GTP-U public: virtual in_addr_t get_s1u_addr() = 0; - virtual bool modify_gtpu_tunnel(in_addr_t ue_ipv4, srslte::gtpc_f_teid_ie dw_user_fteid, uint32_t up_ctrl_teid) = 0; + virtual bool modify_gtpu_tunnel(in_addr_t ue_ipv4, srsran::gtpc_f_teid_ie dw_user_fteid, uint32_t up_ctrl_teid) = 0; virtual bool delete_gtpu_tunnel(in_addr_t ue_ipv4) = 0; virtual bool delete_gtpc_tunnel(in_addr_t ue_ipv4) = 0; - virtual void send_all_queued_packets(srslte::gtp_fteid_t dw_user_fteid, - std::queue& pkt_queue) = 0; + virtual void send_all_queued_packets(srsran::gtp_fteid_t dw_user_fteid, + std::queue& pkt_queue) = 0; }; class gtpc_interface_gtpu // GTP-U -> GTP-C { public: - virtual bool queue_downlink_packet(uint32_t spgw_ctr_teid, srslte::unique_byte_buffer_t msg) = 0; + virtual bool queue_downlink_packet(uint32_t spgw_ctr_teid, srsran::unique_byte_buffer_t msg) = 0; virtual bool send_downlink_data_notification(uint32_t spgw_ctr_teid) = 0; }; } // namespace srsepc -#endif // SRSLTE_EPC_INTERFACES_H +#endif // SRSRAN_EPC_INTERFACES_H diff --git a/lib/include/srslte/interfaces/gnb_interfaces.h b/lib/include/srsran/interfaces/gnb_interfaces.h similarity index 77% rename from lib/include/srslte/interfaces/gnb_interfaces.h rename to lib/include/srsran/interfaces/gnb_interfaces.h index dc0a36374..3a3be7e30 100644 --- a/lib/include/srslte/interfaces/gnb_interfaces.h +++ b/lib/include/srsran/interfaces/gnb_interfaces.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,17 +10,17 @@ * */ -#ifndef SRSLTE_GNB_INTERFACES_H -#define SRSLTE_GNB_INTERFACES_H +#ifndef SRSRAN_GNB_INTERFACES_H +#define SRSRAN_GNB_INTERFACES_H -#include "srslte/srslte.h" +#include "srsran/srsran.h" -#include "srslte/common/interfaces_common.h" -#include "srslte/common/security.h" -#include "srslte/interfaces/pdcp_interface_types.h" -#include "srslte/interfaces/rlc_interface_types.h" -#include "srslte/interfaces/rrc_interface_types.h" -#include "srslte/interfaces/sched_interface.h" +#include "srsran/common/interfaces_common.h" +#include "srsran/common/security.h" +#include "srsran/interfaces/pdcp_interface_types.h" +#include "srsran/interfaces/rlc_interface_types.h" +#include "srsran/interfaces/rrc_interface_types.h" +#include "srsran/interfaces/sched_interface.h" namespace srsenb { @@ -60,7 +60,7 @@ class rlc_interface_pdcp_nr public: /* PDCP calls RLC to push an RLC SDU. SDU gets placed into the RLC buffer and MAC pulls * RLC PDUs according to TB size. */ - virtual void write_sdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t sdu) = 0; + virtual void write_sdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t sdu) = 0; virtual bool rb_is_um(uint16_t rnti, uint32_t lcid) = 0; virtual bool sdu_queue_is_full(uint16_t rnti, uint32_t lcid) = 0; }; @@ -70,9 +70,9 @@ public: virtual void clear_buffer(uint16_t rnti) = 0; virtual void add_user(uint16_t rnti) = 0; virtual void rem_user(uint16_t rnti) = 0; - virtual void add_bearer(uint16_t rnti, uint32_t lcid, srslte::rlc_config_t cnfg) = 0; + virtual void add_bearer(uint16_t rnti, uint32_t lcid, srsran::rlc_config_t cnfg) = 0; virtual void add_bearer_mrb(uint16_t rnti, uint32_t lcid) = 0; - virtual void write_sdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t sdu) = 0; + virtual void write_sdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t sdu) = 0; }; /***************************** @@ -82,9 +82,9 @@ class pdcp_interface_rlc_nr { public: /* RLC calls PDCP to push a PDCP PDU. */ - virtual void write_pdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t sdu) = 0; - virtual void notify_delivery(uint16_t rnti, uint32_t lcid, const srslte::pdcp_sn_vector_t& pdcp_sns) = 0; - virtual void notify_failure(uint16_t rnti, uint32_t lcid, const srslte::pdcp_sn_vector_t& pdcp_sns) = 0; + virtual void write_pdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t sdu) = 0; + virtual void notify_delivery(uint16_t rnti, uint32_t lcid, const srsran::pdcp_sn_vector_t& pdcp_sns) = 0; + virtual void notify_failure(uint16_t rnti, uint32_t lcid, const srsran::pdcp_sn_vector_t& pdcp_sns) = 0; }; class pdcp_interface_rrc_nr @@ -93,9 +93,9 @@ public: virtual void reset(uint16_t rnti) = 0; virtual void add_user(uint16_t rnti) = 0; virtual void rem_user(uint16_t rnti) = 0; - virtual void write_sdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t sdu) = 0; - virtual void add_bearer(uint16_t rnti, uint32_t lcid, srslte::pdcp_config_t cnfg) = 0; - virtual void config_security(uint16_t rnti, uint32_t lcid, srslte::as_security_config_t sec_cfg) = 0; + virtual void write_sdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t sdu) = 0; + virtual void add_bearer(uint16_t rnti, uint32_t lcid, srsran::pdcp_config_t cnfg) = 0; + virtual void config_security(uint16_t rnti, uint32_t lcid, srsran::as_security_config_t sec_cfg) = 0; virtual void enable_integrity(uint16_t rnti, uint32_t lcid) = 0; virtual void enable_encryption(uint16_t rnti, uint32_t lcid) = 0; }; @@ -103,7 +103,7 @@ public: class pdcp_interface_sdap_nr { public: - virtual void write_sdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t pdu) = 0; + virtual void write_sdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t pdu) = 0; }; /***************************** @@ -112,12 +112,12 @@ public: class sdap_interface_pdcp_nr { public: - virtual void write_pdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t pdu) = 0; + virtual void write_pdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t pdu) = 0; }; class sdap_interface_gtpu_nr { public: - virtual void write_sdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t pdu) = 0; + virtual void write_sdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t pdu) = 0; }; /***************************** @@ -131,7 +131,7 @@ public: class gtpu_interface_sdap_nr { public: - virtual void write_pdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t pdu) = 0; + virtual void write_pdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t pdu) = 0; }; /***************************** @@ -143,20 +143,20 @@ class rrc_interface_mac_nr { public: // Provides MIB packed message - virtual int read_pdu_bcch_bch(const uint32_t tti, srslte::unique_byte_buffer_t& buffer) = 0; - virtual int read_pdu_bcch_dlsch(uint32_t sib_index, srslte::unique_byte_buffer_t& buffer) = 0; + virtual int read_pdu_bcch_bch(const uint32_t tti, srsran::unique_byte_buffer_t& buffer) = 0; + virtual int read_pdu_bcch_dlsch(uint32_t sib_index, srsran::unique_byte_buffer_t& buffer) = 0; }; class rrc_interface_rlc_nr { public: virtual void read_pdu_pcch(uint8_t* payload, uint32_t payload_size) = 0; virtual void max_retx_attempted(uint16_t rnti) = 0; - virtual void write_pdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t sdu) = 0; + virtual void write_pdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t sdu) = 0; }; class rrc_interface_pdcp_nr { public: - virtual void write_pdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t pdu) = 0; + virtual void write_pdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t pdu) = 0; }; class rrc_interface_ngap_nr { @@ -195,7 +195,7 @@ public: bch_sched_t pbch; uint16_t length; uint16_t index; // index indicated in dl_config - uint8_t* data[SRSLTE_MAX_TB]; // always a pointer in our case + uint8_t* data[SRSRAN_MAX_TB]; // always a pointer in our case } tx_request_pdu_t; typedef struct { @@ -225,9 +225,9 @@ public: * DL grant structure per UE */ struct dl_sched_grant_t { - srslte_dci_dl_nr_t dci = {}; - uint8_t* data[SRSLTE_MAX_TB] = {}; - srslte_softbuffer_tx_t* softbuffer_tx[SRSLTE_MAX_TB] = {}; + srsran_dci_dl_nr_t dci = {}; + uint8_t* data[SRSRAN_MAX_TB] = {}; + srsran_softbuffer_tx_t* softbuffer_tx[SRSRAN_MAX_TB] = {}; }; /** @@ -244,13 +244,13 @@ public: typedef std::vector dl_sched_list_t; }; -class stack_interface_phy_nr : public mac_interface_phy_nr, public srslte::stack_interface_phy_nr +class stack_interface_phy_nr : public mac_interface_phy_nr, public srsran::stack_interface_phy_nr { public: struct rx_data_ind_t { uint32_t tti; uint16_t rnti; - srslte::unique_byte_buffer_t tb; + srsran::unique_byte_buffer_t tb; }; virtual int sf_indication(const uint32_t tti) = 0; @@ -259,4 +259,4 @@ public: } // namespace srsenb -#endif // SRSLTE_GNB_INTERFACES_H +#endif // SRSRAN_GNB_INTERFACES_H diff --git a/lib/include/srslte/interfaces/mac_interface_types.h b/lib/include/srsran/interfaces/mac_interface_types.h similarity index 94% rename from lib/include/srslte/interfaces/mac_interface_types.h rename to lib/include/srsran/interfaces/mac_interface_types.h index bcd4ca546..2cf7940a2 100644 --- a/lib/include/srslte/interfaces/mac_interface_types.h +++ b/lib/include/srsran/interfaces/mac_interface_types.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,12 +10,12 @@ * */ -#ifndef SRSLTE_MAC_INTERFACE_TYPES_H -#define SRSLTE_MAC_INTERFACE_TYPES_H +#ifndef SRSRAN_MAC_INTERFACE_TYPES_H +#define SRSRAN_MAC_INTERFACE_TYPES_H #include "rrc_interface_types.h" -namespace srslte { +namespace srsran { /*************************** * MAC Config @@ -163,6 +163,6 @@ struct mac_cfg_t { int time_alignment_timer = -1; }; -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_MAC_INTERFACE_TYPES_H +#endif // SRSRAN_MAC_INTERFACE_TYPES_H diff --git a/lib/include/srslte/interfaces/nr_common_interface_types.h b/lib/include/srsran/interfaces/nr_common_interface_types.h similarity index 80% rename from lib/include/srslte/interfaces/nr_common_interface_types.h rename to lib/include/srsran/interfaces/nr_common_interface_types.h index 9b4fa0d8a..1e90fe9a1 100644 --- a/lib/include/srslte/interfaces/nr_common_interface_types.h +++ b/lib/include/srsran/interfaces/nr_common_interface_types.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,10 +10,10 @@ * */ -#ifndef SRSLTE_COMMON_NR_H -#define SRSLTE_COMMON_NR_H +#ifndef SRSRAN_COMMON_NR_H +#define SRSRAN_COMMON_NR_H -namespace srslte { +namespace srsran { // NR Radio Bearer Id @@ -36,6 +36,6 @@ inline int get_drb_id(rb_id_nr_t rb_id) return is_drb(rb_id) ? (rb_id - 3) : -1; } -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_NR_COMMON_INTERFACE_TYPES_H +#endif // SRSRAN_NR_COMMON_INTERFACE_TYPES_H diff --git a/lib/include/srslte/interfaces/pdcp_interface_types.h b/lib/include/srsran/interfaces/pdcp_interface_types.h similarity index 90% rename from lib/include/srslte/interfaces/pdcp_interface_types.h rename to lib/include/srsran/interfaces/pdcp_interface_types.h index 5db48df2e..534bb78f9 100644 --- a/lib/include/srslte/interfaces/pdcp_interface_types.h +++ b/lib/include/srsran/interfaces/pdcp_interface_types.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -15,15 +15,15 @@ * Description: Structures used for configuration of the PDCP entities *****************************************************************************/ -#ifndef SRSLTE_PDCP_INTERFACE_TYPES_H -#define SRSLTE_PDCP_INTERFACE_TYPES_H +#ifndef SRSRAN_PDCP_INTERFACE_TYPES_H +#define SRSRAN_PDCP_INTERFACE_TYPES_H -#include "srslte/adt/bounded_vector.h" -#include "srslte/common/security.h" +#include "srsran/adt/bounded_vector.h" +#include "srsran/common/security.h" #include #include -namespace srslte { +namespace srsran { /*************************** * PDCP Config @@ -156,8 +156,8 @@ public: }; // Specifies in which direction security (integrity and ciphering) are enabled for PDCP -enum srslte_direction_t { DIRECTION_NONE = 0, DIRECTION_TX, DIRECTION_RX, DIRECTION_TXRX, DIRECTION_N_ITEMS }; -static const char* srslte_direction_text[DIRECTION_N_ITEMS] = {"none", "tx", "rx", "tx/rx"}; +enum srsran_direction_t { DIRECTION_NONE = 0, DIRECTION_TX, DIRECTION_RX, DIRECTION_TXRX, DIRECTION_N_ITEMS }; +static const char* srsran_direction_text[DIRECTION_N_ITEMS] = {"none", "tx", "rx", "tx/rx"}; // PDCP LTE internal state variables, as defined in TS 36 323, section 7.1 struct pdcp_lte_state_t { @@ -172,8 +172,8 @@ struct pdcp_lte_state_t { // Custom type for interface between PDCP and RLC to convey SDU delivery status #define MAX_SDUS_PER_RLC_PDU (256) // default to RLC SDU queue length #define MAX_SDUS_TO_NOTIFY (MAX_SDUS_PER_RLC_PDU) // Arbitrarily chosen limit -typedef srslte::bounded_vector pdcp_sn_vector_t; +typedef srsran::bounded_vector pdcp_sn_vector_t; -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_PDCP_INTERFACE_TYPES_H +#endif // SRSRAN_PDCP_INTERFACE_TYPES_H diff --git a/lib/include/srslte/interfaces/phy_interface_types.h b/lib/include/srsran/interfaces/phy_interface_types.h similarity index 71% rename from lib/include/srslte/interfaces/phy_interface_types.h rename to lib/include/srsran/interfaces/phy_interface_types.h index 1f3f6d19b..d446eae11 100644 --- a/lib/include/srslte/interfaces/phy_interface_types.h +++ b/lib/include/srsran/interfaces/phy_interface_types.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,24 +10,24 @@ * */ -#ifndef SRSLTE_PHY_INTERFACE_TYPES_H -#define SRSLTE_PHY_INTERFACE_TYPES_H +#ifndef SRSRAN_PHY_INTERFACE_TYPES_H +#define SRSRAN_PHY_INTERFACE_TYPES_H -#include "srslte/srslte.h" +#include "srsran/srsran.h" /// Common types defined by the PHY layer. -inline bool operator==(const srslte_tdd_config_t& a, const srslte_tdd_config_t& b) +inline bool operator==(const srsran_tdd_config_t& a, const srsran_tdd_config_t& b) { return (a.sf_config == b.sf_config && a.ss_config == b.ss_config && a.configured == b.configured); } -inline bool operator!=(const srslte_tdd_config_t& a, const srslte_tdd_config_t& b) +inline bool operator!=(const srsran_tdd_config_t& a, const srsran_tdd_config_t& b) { return !(a == b); } -inline bool operator==(const srslte_prach_cfg_t& a, const srslte_prach_cfg_t& b) +inline bool operator==(const srsran_prach_cfg_t& a, const srsran_prach_cfg_t& b) { return (a.config_idx == b.config_idx && a.root_seq_idx == b.root_seq_idx && a.zero_corr_zone == b.zero_corr_zone && a.freq_offset == b.freq_offset && a.num_ra_preambles == b.num_ra_preambles && a.hs_flag == b.hs_flag && @@ -35,7 +35,7 @@ inline bool operator==(const srslte_prach_cfg_t& a, const srslte_prach_cfg_t& b) a.enable_freq_domain_offset_calc == b.enable_freq_domain_offset_calc); } -inline bool operator!=(const srslte_prach_cfg_t& a, const srslte_prach_cfg_t& b) +inline bool operator!=(const srsran_prach_cfg_t& a, const srsran_prach_cfg_t& b) { return !(a == b); } @@ -67,4 +67,4 @@ struct phy_cell_t { } // namespace srsue -#endif // SRSLTE_PHY_INTERFACE_TYPES_H +#endif // SRSRAN_PHY_INTERFACE_TYPES_H diff --git a/lib/include/srslte/interfaces/radio_interfaces.h b/lib/include/srsran/interfaces/radio_interfaces.h similarity index 90% rename from lib/include/srslte/interfaces/radio_interfaces.h rename to lib/include/srsran/interfaces/radio_interfaces.h index ec4fa5a24..99fed1eff 100644 --- a/lib/include/srslte/interfaces/radio_interfaces.h +++ b/lib/include/srsran/interfaces/radio_interfaces.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -15,16 +15,16 @@ * Description: Common interface for eNB/UE for PHY and radio *****************************************************************************/ -#ifndef SRSLTE_RADIO_INTERFACES_H -#define SRSLTE_RADIO_INTERFACES_H +#ifndef SRSRAN_RADIO_INTERFACES_H +#define SRSRAN_RADIO_INTERFACES_H -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/common/timestamp.h" -#include "srslte/phy/rf/rf.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/common/timestamp.h" +#include "srsran/phy/rf/rf.h" +#include "srsran/phy/utils/vector.h" #include -namespace srslte { +namespace srsran { /** * Class used to pass buffers for all channels and antennas to the radio @@ -59,8 +59,8 @@ public: class rf_timestamp_interface { public: - virtual const srslte_timestamp_t& get(uint32_t idx) const = 0; - virtual srslte_timestamp_t* get_ptr(uint32_t idx) = 0; + virtual const srsran_timestamp_t& get(uint32_t idx) const = 0; + virtual srsran_timestamp_t* get_ptr(uint32_t idx) = 0; virtual void add(double secs) = 0; virtual void sub(double secs) = 0; @@ -72,12 +72,12 @@ public: } // Copy timestamps - for (uint32_t i = 0; i < SRSLTE_MAX_CHANNELS; i++) { + for (uint32_t i = 0; i < SRSRAN_MAX_CHANNELS; i++) { *this->get_ptr(i) = other.get(i); } } - srslte_timestamp_t& operator[](uint32_t idx) { return *this->get_ptr(idx); } + srsran_timestamp_t& operator[](uint32_t idx) { return *this->get_ptr(idx); } }; /** @@ -89,8 +89,8 @@ public: * * The radio interface supports multiple carriers and multiple antennas per carrier. This interface presents an * abstract access to carries and ports to the PHY, regardless of the mapping to RF channels in the underlying radio. - * number of carriers <= SRSLTE_MAX_CARRIERS - * number of ports <= SRSLTE_MAX_PORTS + * number of carriers <= SRSRAN_MAX_CARRIERS + * number of ports <= SRSRAN_MAX_PORTS * * Changing the tx/rx frequency is done on a carrier level and the underlying implementation * will set it for all ports when necessary. @@ -192,7 +192,7 @@ public: virtual bool get_is_start_of_burst() = 0; virtual bool is_init() = 0; virtual void reset() = 0; - virtual srslte_rf_info_t* get_info() = 0; + virtual srsran_rf_info_t* get_info() = 0; }; class phy_interface_radio @@ -202,6 +202,6 @@ public: virtual void radio_failure() = 0; }; -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_RADIO_INTERFACES_H +#endif // SRSRAN_RADIO_INTERFACES_H diff --git a/lib/include/srslte/interfaces/rlc_interface_types.h b/lib/include/srsran/interfaces/rlc_interface_types.h similarity index 91% rename from lib/include/srslte/interfaces/rlc_interface_types.h rename to lib/include/srsran/interfaces/rlc_interface_types.h index 8679f360d..308bfa3cc 100644 --- a/lib/include/srslte/interfaces/rlc_interface_types.h +++ b/lib/include/srsran/interfaces/rlc_interface_types.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,16 +10,16 @@ * */ -#ifndef SRSLTE_RLC_INTERFACE_TYPES_H -#define SRSLTE_RLC_INTERFACE_TYPES_H +#ifndef SRSRAN_RLC_INTERFACE_TYPES_H +#define SRSRAN_RLC_INTERFACE_TYPES_H -#include "srslte/interfaces/rrc_interface_types.h" +#include "srsran/interfaces/rrc_interface_types.h" /*************************** * RLC Config **************************/ -namespace srslte { +namespace srsran { enum class rlc_mode_t { tm, um, am, nulltype }; inline std::string to_string(const rlc_mode_t& mode, bool long_txt = true) @@ -120,7 +120,7 @@ struct rlc_um_nr_config_t { class rlc_config_t { public: - srslte_rat_t rat; + srsran_rat_t rat; rlc_mode_t rlc_mode; rlc_am_config_t am; rlc_um_config_t um; @@ -128,18 +128,13 @@ public: uint32_t tx_queue_length; rlc_config_t() : - rat(srslte_rat_t::lte), - rlc_mode(rlc_mode_t::tm), - am(), - um(), - um_nr(), - tx_queue_length(RLC_TX_QUEUE_LEN){}; + rat(srsran_rat_t::lte), rlc_mode(rlc_mode_t::tm), am(), um(), um_nr(), tx_queue_length(RLC_TX_QUEUE_LEN){}; // Factory for MCH static rlc_config_t mch_config() { rlc_config_t cfg = {}; - cfg.rat = srslte_rat_t::lte; + cfg.rat = srsran_rat_t::lte; cfg.rlc_mode = rlc_mode_t::um; cfg.um.t_reordering = 45; cfg.um.rx_sn_field_length = rlc_umd_sn_size_t::size5bits; @@ -158,7 +153,7 @@ public: } // SRB1 and SRB2 are AM rlc_config_t rlc_cfg = {}; - rlc_cfg.rat = srslte_rat_t::lte; + rlc_cfg.rat = srsran_rat_t::lte; rlc_cfg.rlc_mode = rlc_mode_t::am; rlc_cfg.am.t_poll_retx = 45; rlc_cfg.am.poll_pdu = -1; @@ -171,7 +166,7 @@ public: static rlc_config_t default_rlc_um_config(uint32_t sn_size = 10) { rlc_config_t cnfg = {}; - cnfg.rat = srslte_rat_t::lte; + cnfg.rat = srsran_rat_t::lte; cnfg.rlc_mode = rlc_mode_t::um; cnfg.um.t_reordering = 5; if (sn_size == 10) { @@ -194,7 +189,7 @@ public: static rlc_config_t default_rlc_am_config() { rlc_config_t rlc_cnfg = {}; - rlc_cnfg.rat = srslte_rat_t::lte; + rlc_cnfg.rat = srsran_rat_t::lte; rlc_cnfg.rlc_mode = rlc_mode_t::am; rlc_cnfg.am.t_reordering = 5; rlc_cnfg.am.t_status_prohibit = 5; @@ -207,7 +202,7 @@ public: static rlc_config_t default_rlc_um_nr_config(uint32_t sn_size = 6) { rlc_config_t cnfg = {}; - cnfg.rat = srslte_rat_t::nr; + cnfg.rat = srsran_rat_t::nr; cnfg.rlc_mode = rlc_mode_t::um; if (sn_size == 6) { cnfg.um_nr.sn_field_length = rlc_um_nr_sn_size_t::size6bits; @@ -225,6 +220,6 @@ public: } }; -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_RLC_INTERFACE_TYPES_H +#endif // SRSRAN_RLC_INTERFACE_TYPES_H diff --git a/lib/include/srslte/interfaces/rrc_interface_types.h b/lib/include/srsran/interfaces/rrc_interface_types.h similarity index 91% rename from lib/include/srslte/interfaces/rrc_interface_types.h rename to lib/include/srsran/interfaces/rrc_interface_types.h index 31a94c07b..460d56301 100644 --- a/lib/include/srslte/interfaces/rrc_interface_types.h +++ b/lib/include/srsran/interfaces/rrc_interface_types.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,16 +10,16 @@ * */ -#ifndef SRSLTE_RRC_INTERFACE_TYPES_H -#define SRSLTE_RRC_INTERFACE_TYPES_H +#ifndef SRSRAN_RRC_INTERFACE_TYPES_H +#define SRSRAN_RRC_INTERFACE_TYPES_H -#include "srslte/common/bcd_helpers.h" -#include "srslte/common/common.h" -#include "srslte/config.h" -#include "srslte/srslte.h" +#include "srsran/common/bcd_helpers.h" +#include "srsran/common/common.h" +#include "srsran/config.h" +#include "srsran/srsran.h" #include -namespace srslte { +namespace srsran { /*************************** * PLMN ID @@ -39,25 +39,25 @@ struct plmn_id_t { } int from_number(uint16_t mcc_num, uint16_t mnc_num) { - srslte::mcc_to_bytes(mcc_num, &mcc[0]); - if (not srslte::mnc_to_bytes(mnc_num, &mnc[0], &nof_mnc_digits)) { + srsran::mcc_to_bytes(mcc_num, &mcc[0]); + if (not srsran::mnc_to_bytes(mnc_num, &mnc[0], &nof_mnc_digits)) { reset(); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } std::pair to_number() { uint16_t mcc_num, mnc_num; - srslte::bytes_to_mcc(&mcc[0], &mcc_num); - srslte::bytes_to_mnc(&mnc[0], &mnc_num, nof_mnc_digits); + srsran::bytes_to_mcc(&mcc[0], &mcc_num); + srsran::bytes_to_mnc(&mnc[0], &mnc_num, nof_mnc_digits); return std::make_pair(mcc_num, mnc_num); } uint32_t to_s1ap_plmn() { auto mcc_mnc_pair = to_number(); uint32_t s1ap_plmn; - srslte::s1ap_mccmnc_to_plmn(mcc_mnc_pair.first, mcc_mnc_pair.second, &s1ap_plmn); + srsran::s1ap_mccmnc_to_plmn(mcc_mnc_pair.first, mcc_mnc_pair.second, &s1ap_plmn); return s1ap_plmn; } void to_s1ap_plmn_bytes(uint8_t* plmn_bytes) @@ -71,24 +71,24 @@ struct plmn_id_t { { if (plmn_str.size() < 5 or plmn_str.size() > 6) { reset(); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } uint16_t mnc_num, mcc_num; if (not string_to_mcc(std::string(plmn_str.begin(), plmn_str.begin() + 3), &mcc_num)) { reset(); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (not string_to_mnc(std::string(plmn_str.begin() + 3, plmn_str.end()), &mnc_num)) { reset(); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } return from_number(mcc_num, mnc_num); } int to_number(uint16_t* mcc_num, uint16_t* mnc_num) const { - srslte::bytes_to_mcc(&mcc[0], mcc_num); - srslte::bytes_to_mnc(&mnc[0], mnc_num, nof_mnc_digits); - return SRSLTE_SUCCESS; + srsran::bytes_to_mcc(&mcc[0], mcc_num); + srsran::bytes_to_mnc(&mnc[0], mnc_num, nof_mnc_digits); + return SRSRAN_SUCCESS; } std::string to_string() const { @@ -202,7 +202,7 @@ struct phy_cfg_t { */ void set_defaults_dedicated() { - dl_cfg.tm = SRSLTE_TM1; + dl_cfg.tm = SRSRAN_TM1; dl_cfg.pdsch.use_tbs_index_alt = false; dl_cfg.pdsch.p_a = 0; @@ -222,11 +222,11 @@ struct phy_cfg_t { set_defaults_pucch_sr(); } - srslte_dl_cfg_t dl_cfg = {}; - srslte_ul_cfg_t ul_cfg = {}; + srsran_dl_cfg_t dl_cfg = {}; + srsran_ul_cfg_t ul_cfg = {}; bool prach_cfg_present = false; - srslte_prach_cfg_t prach_cfg = {}; + srsran_prach_cfg_t prach_cfg = {}; }; struct mbsfn_sf_cfg_t { @@ -369,6 +369,6 @@ struct rrc_ue_capabilities_t { bool support_ul_64qam = false; }; -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_RRC_INTERFACE_TYPES_H +#endif // SRSRAN_RRC_INTERFACE_TYPES_H diff --git a/lib/include/srslte/interfaces/rrc_nr_interface_types.h b/lib/include/srsran/interfaces/rrc_nr_interface_types.h similarity index 89% rename from lib/include/srslte/interfaces/rrc_nr_interface_types.h rename to lib/include/srsran/interfaces/rrc_nr_interface_types.h index f7f1e2406..b1964f65e 100644 --- a/lib/include/srslte/interfaces/rrc_nr_interface_types.h +++ b/lib/include/srsran/interfaces/rrc_nr_interface_types.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,28 +10,28 @@ * */ -#ifndef SRSLTE_RRC_NR_INTERFACE_TYPES_H -#define SRSLTE_RRC_NR_INTERFACE_TYPES_H +#ifndef SRSRAN_RRC_NR_INTERFACE_TYPES_H +#define SRSRAN_RRC_NR_INTERFACE_TYPES_H -#include "srslte/config.h" -#include "srslte/srslte.h" +#include "srsran/config.h" +#include "srsran/srsran.h" #include -namespace srslte { +namespace srsran { /*************************** * PHY Config **************************/ struct phy_cfg_nr_t { - srslte_tdd_config_nr_t tdd = {}; - srslte_sch_hl_cfg_nr_t pdsch = {}; - srslte_sch_hl_cfg_nr_t pusch = {}; - srslte_pucch_nr_hl_cfg_t pucch = {}; - srslte_prach_cfg_t prach = {}; - srslte_ue_dl_nr_pdcch_cfg_t pdcch = {}; - srslte_ue_dl_nr_harq_ack_cfg_t harq_ack = {}; - srslte_csi_hl_cfg_t csi = {}; + srsran_tdd_config_nr_t tdd = {}; + srsran_sch_hl_cfg_nr_t pdsch = {}; + srsran_sch_hl_cfg_nr_t pusch = {}; + srsran_pucch_nr_hl_cfg_t pucch = {}; + srsran_prach_cfg_t prach = {}; + srsran_ue_dl_nr_pdcch_cfg_t pdcch = {}; + srsran_ue_dl_nr_harq_ack_cfg_t harq_ack = {}; + srsran_csi_hl_cfg_t csi = {}; phy_cfg_nr_t() { @@ -61,7 +61,7 @@ struct phy_cfg_nr_t { // physicalCellGroupConfig // pdsch-HARQ-ACK-Codebook: dynamic (1) - harq_ack.pdsch_harq_ack_codebook = srslte_pdsch_harq_ack_codebook_dynamic; + harq_ack.pdsch_harq_ack_codebook = srsran_pdsch_harq_ack_codebook_dynamic; // commonControlResourceSet // controlResourceSetId: 1 @@ -71,10 +71,10 @@ struct phy_cfg_nr_t { // nonInterleaved: NULL // precoderGranularity: sameAsREG-bundle (0) pdcch.coreset[1].coreset_id = 1; - pdcch.coreset[1].precoder_granularity = srslte_coreset_precoder_granularity_reg_bundle; + pdcch.coreset[1].precoder_granularity = srsran_coreset_precoder_granularity_reg_bundle; pdcch.coreset[1].duration = 1; - pdcch.coreset[1].mapping_type = srslte_coreset_mapping_type_non_interleaved; - for (uint32_t i = 0; i < SRSLTE_CORESET_FREQ_DOMAIN_RES_SIZE; i++) { + pdcch.coreset[1].mapping_type = srsran_coreset_mapping_type_non_interleaved; + for (uint32_t i = 0; i < SRSRAN_CORESET_FREQ_DOMAIN_RES_SIZE; i++) { pdcch.coreset[1].freq_resources[i] = (i < 8); } pdcch.coreset_present[1] = true; @@ -94,7 +94,7 @@ struct phy_cfg_nr_t { // searchSpaceType: common (0) // common // dci-Format0-0-AndFormat1-0 - srslte_search_space_t search_space1 = {}; + srsran_search_space_t search_space1 = {}; search_space1.id = 1; search_space1.coreset_id = 1; search_space1.nof_candidates[0] = 1; @@ -102,14 +102,14 @@ struct phy_cfg_nr_t { search_space1.nof_candidates[2] = 1; search_space1.nof_candidates[3] = 0; search_space1.nof_candidates[4] = 0; - search_space1.type = srslte_search_space_type_common_3; + search_space1.type = srsran_search_space_type_common_3; pdcch.search_space[1] = search_space1; pdcch.search_space_present[1] = true; // ra-SearchSpace: 1 pdcch.ra_rnti = 0x16; //< Supposed to be deduced from PRACH configuration pdcch.ra_search_space = search_space1; - pdcch.ra_search_space.type = srslte_search_space_type_common_1; + pdcch.ra_search_space.type = srsran_search_space_type_common_1; pdcch.ra_search_space_present = true; // spCellConfigDedicated @@ -127,10 +127,10 @@ struct phy_cfg_nr_t { // nonInterleaved: NULL // precoderGranularity: sameAsREG-bundle (0) pdcch.coreset[2].id = 2; - pdcch.coreset[2].precoder_granularity = srslte_coreset_precoder_granularity_reg_bundle; + pdcch.coreset[2].precoder_granularity = srsran_coreset_precoder_granularity_reg_bundle; pdcch.coreset[2].duration = 1; - pdcch.coreset[2].mapping_type = srslte_coreset_mapping_type_non_interleaved; - for (uint32_t i = 0; i < SRSLTE_CORESET_FREQ_DOMAIN_RES_SIZE; i++) { + pdcch.coreset[2].mapping_type = srsran_coreset_mapping_type_non_interleaved; + for (uint32_t i = 0; i < SRSRAN_CORESET_FREQ_DOMAIN_RES_SIZE; i++) { pdcch.coreset[2].freq_resources[i] = (i < 8); } pdcch.coreset_present[2] = true; @@ -159,7 +159,7 @@ struct phy_cfg_nr_t { pdcch.search_space[2].nof_candidates[2] = 1; pdcch.search_space[2].nof_candidates[3] = 0; pdcch.search_space[2].nof_candidates[4] = 0; - pdcch.search_space[2].type = srslte_search_space_type_ue; + pdcch.search_space[2].type = srsran_search_space_type_ue; pdcch.search_space_present[2] = true; // pdsch-ConfigCommon: setup (1) @@ -173,10 +173,10 @@ struct phy_cfg_nr_t { // PDSCH-TimeDomainResourceAllocation // mappingType: typeA (0) // startSymbolAndLength: 57 - pdsch.common_time_ra[0].mapping_type = srslte_sch_mapping_type_A; + pdsch.common_time_ra[0].mapping_type = srsran_sch_mapping_type_A; pdsch.common_time_ra[0].sliv = 40; pdsch.common_time_ra[0].k = 0; - pdsch.common_time_ra[1].mapping_type = srslte_sch_mapping_type_A; + pdsch.common_time_ra[1].mapping_type = srsran_sch_mapping_type_A; pdsch.common_time_ra[1].sliv = 57; pdsch.common_time_ra[1].k = 0; pdsch.nof_common_time_ra = 2; @@ -195,10 +195,10 @@ struct phy_cfg_nr_t { // mappingType: typeA (0) // startSymbolAndLength: 27 // p0-NominalWithGrant: -90dBm - pusch.common_time_ra[0].mapping_type = srslte_sch_mapping_type_A; + pusch.common_time_ra[0].mapping_type = srsran_sch_mapping_type_A; pusch.common_time_ra[0].sliv = 27; pusch.common_time_ra[0].k = 4; - pusch.common_time_ra[1].mapping_type = srslte_sch_mapping_type_A; + pusch.common_time_ra[1].mapping_type = srsran_sch_mapping_type_A; pusch.common_time_ra[1].sliv = 27; pusch.common_time_ra[1].k = 5; pusch.nof_common_time_ra = 2; @@ -209,7 +209,7 @@ struct phy_cfg_nr_t { // setup // dmrs-AdditionalPosition: pos1 (1) // transformPrecodingDisabled - pusch.dmrs_typeA.additional_pos = srslte_dmrs_sch_add_pos_1; + pusch.dmrs_typeA.additional_pos = srsran_dmrs_sch_add_pos_1; pusch.dmrs_typeA.present = true; // pusch-PowerControl // msg3-Alpha: alpha1 (7) @@ -317,7 +317,7 @@ struct phy_cfg_nr_t { // nrofSymbols: 14 // startingSymbolIndex: 0 // timeDomainOCC: 0 - pucch.sets[0].resources[0].format = SRSLTE_PUCCH_NR_FORMAT_1; + pucch.sets[0].resources[0].format = SRSRAN_PUCCH_NR_FORMAT_1; pucch.sets[0].resources[0].starting_prb = 0; pucch.sets[0].resources[0].initial_cyclic_shift = 0; pucch.sets[0].resources[0].nof_symbols = 14; @@ -334,7 +334,7 @@ struct phy_cfg_nr_t { // nrofSymbols: 14 // startingSymbolIndex: 0 // timeDomainOCC: 0 - pucch.sets[0].resources[1].format = SRSLTE_PUCCH_NR_FORMAT_1; + pucch.sets[0].resources[1].format = SRSRAN_PUCCH_NR_FORMAT_1; pucch.sets[0].resources[1].starting_prb = 0; pucch.sets[0].resources[1].initial_cyclic_shift = 4; pucch.sets[0].resources[1].nof_symbols = 14; @@ -351,7 +351,7 @@ struct phy_cfg_nr_t { // nrofSymbols: 14 // startingSymbolIndex: 0 // timeDomainOCC: 0 - pucch.sets[0].resources[2].format = SRSLTE_PUCCH_NR_FORMAT_1; + pucch.sets[0].resources[2].format = SRSRAN_PUCCH_NR_FORMAT_1; pucch.sets[0].resources[2].starting_prb = 0; pucch.sets[0].resources[2].initial_cyclic_shift = 8; pucch.sets[0].resources[2].nof_symbols = 14; @@ -368,7 +368,7 @@ struct phy_cfg_nr_t { // nrofSymbols: 14 // startingSymbolIndex: 0 // timeDomainOCC: 1 - pucch.sets[0].resources[3].format = SRSLTE_PUCCH_NR_FORMAT_1; + pucch.sets[0].resources[3].format = SRSRAN_PUCCH_NR_FORMAT_1; pucch.sets[0].resources[3].starting_prb = 0; pucch.sets[0].resources[3].initial_cyclic_shift = 0; pucch.sets[0].resources[3].nof_symbols = 14; @@ -385,7 +385,7 @@ struct phy_cfg_nr_t { // nrofSymbols: 14 // startingSymbolIndex: 0 // timeDomainOCC: 1 - pucch.sets[0].resources[4].format = SRSLTE_PUCCH_NR_FORMAT_1; + pucch.sets[0].resources[4].format = SRSRAN_PUCCH_NR_FORMAT_1; pucch.sets[0].resources[4].starting_prb = 0; pucch.sets[0].resources[4].initial_cyclic_shift = 4; pucch.sets[0].resources[4].nof_symbols = 14; @@ -402,7 +402,7 @@ struct phy_cfg_nr_t { // nrofSymbols: 14 // startingSymbolIndex: 0 // timeDomainOCC: 1 - pucch.sets[0].resources[5].format = SRSLTE_PUCCH_NR_FORMAT_1; + pucch.sets[0].resources[5].format = SRSRAN_PUCCH_NR_FORMAT_1; pucch.sets[0].resources[5].starting_prb = 0; pucch.sets[0].resources[5].initial_cyclic_shift = 8; pucch.sets[0].resources[5].nof_symbols = 14; @@ -419,7 +419,7 @@ struct phy_cfg_nr_t { // nrofSymbols: 14 // startingSymbolIndex: 0 // timeDomainOCC: 2 - pucch.sets[0].resources[6].format = SRSLTE_PUCCH_NR_FORMAT_1; + pucch.sets[0].resources[6].format = SRSRAN_PUCCH_NR_FORMAT_1; pucch.sets[0].resources[6].starting_prb = 0; pucch.sets[0].resources[6].initial_cyclic_shift = 0; pucch.sets[0].resources[6].nof_symbols = 14; @@ -436,7 +436,7 @@ struct phy_cfg_nr_t { // nrofSymbols: 14 // startingSymbolIndex: 0 // timeDomainOCC: 2 - pucch.sets[0].resources[7].format = SRSLTE_PUCCH_NR_FORMAT_1; + pucch.sets[0].resources[7].format = SRSRAN_PUCCH_NR_FORMAT_1; pucch.sets[0].resources[7].starting_prb = 0; pucch.sets[0].resources[7].initial_cyclic_shift = 0; pucch.sets[0].resources[7].nof_symbols = 14; @@ -452,7 +452,7 @@ struct phy_cfg_nr_t { // nrofPRBs: 1 // nrofSymbols: 2 // startingSymbolIndex: 0 - pucch.sets[1].resources[0].format = SRSLTE_PUCCH_NR_FORMAT_2; + pucch.sets[1].resources[0].format = SRSRAN_PUCCH_NR_FORMAT_2; pucch.sets[1].resources[0].starting_prb = 51; pucch.sets[1].resources[0].nof_prb = 1; pucch.sets[1].resources[0].nof_symbols = 2; @@ -467,7 +467,7 @@ struct phy_cfg_nr_t { // nrofPRBs: 1 // nrofSymbols: 2 // startingSymbolIndex: 2 - pucch.sets[1].resources[1].format = SRSLTE_PUCCH_NR_FORMAT_2; + pucch.sets[1].resources[1].format = SRSRAN_PUCCH_NR_FORMAT_2; pucch.sets[1].resources[1].starting_prb = 51; pucch.sets[1].resources[1].nof_prb = 1; pucch.sets[1].resources[1].nof_symbols = 2; @@ -482,7 +482,7 @@ struct phy_cfg_nr_t { // nrofPRBs: 1 // nrofSymbols: 2 // startingSymbolIndex: 4 - pucch.sets[1].resources[2].format = SRSLTE_PUCCH_NR_FORMAT_2; + pucch.sets[1].resources[2].format = SRSRAN_PUCCH_NR_FORMAT_2; pucch.sets[1].resources[2].starting_prb = 51; pucch.sets[1].resources[2].nof_prb = 1; pucch.sets[1].resources[2].nof_symbols = 2; @@ -497,7 +497,7 @@ struct phy_cfg_nr_t { // nrofPRBs: 1 // nrofSymbols: 2 // startingSymbolIndex: 6 - pucch.sets[1].resources[3].format = SRSLTE_PUCCH_NR_FORMAT_2; + pucch.sets[1].resources[3].format = SRSRAN_PUCCH_NR_FORMAT_2; pucch.sets[1].resources[3].starting_prb = 51; pucch.sets[1].resources[3].nof_prb = 1; pucch.sets[1].resources[3].nof_symbols = 2; @@ -512,7 +512,7 @@ struct phy_cfg_nr_t { // nrofPRBs: 1 // nrofSymbols: 2 // startingSymbolIndex: 8 - pucch.sets[1].resources[4].format = SRSLTE_PUCCH_NR_FORMAT_2; + pucch.sets[1].resources[4].format = SRSRAN_PUCCH_NR_FORMAT_2; pucch.sets[1].resources[4].starting_prb = 51; pucch.sets[1].resources[4].nof_prb = 1; pucch.sets[1].resources[4].nof_symbols = 2; @@ -527,7 +527,7 @@ struct phy_cfg_nr_t { // nrofPRBs: 1 // nrofSymbols: 2 // startingSymbolIndex: 10 - pucch.sets[1].resources[5].format = SRSLTE_PUCCH_NR_FORMAT_2; + pucch.sets[1].resources[5].format = SRSRAN_PUCCH_NR_FORMAT_2; pucch.sets[1].resources[5].starting_prb = 51; pucch.sets[1].resources[5].nof_prb = 1; pucch.sets[1].resources[5].nof_symbols = 2; @@ -542,7 +542,7 @@ struct phy_cfg_nr_t { // nrofPRBs: 1 // nrofSymbols: 2 // startingSymbolIndex: 12 - pucch.sets[1].resources[6].format = SRSLTE_PUCCH_NR_FORMAT_2; + pucch.sets[1].resources[6].format = SRSRAN_PUCCH_NR_FORMAT_2; pucch.sets[1].resources[6].starting_prb = 51; pucch.sets[1].resources[6].nof_prb = 1; pucch.sets[1].resources[6].nof_symbols = 2; @@ -557,7 +557,7 @@ struct phy_cfg_nr_t { // nrofPRBs: 1 // nrofSymbols: 2 // startingSymbolIndex: 0 - pucch.sets[1].resources[7].format = SRSLTE_PUCCH_NR_FORMAT_2; + pucch.sets[1].resources[7].format = SRSRAN_PUCCH_NR_FORMAT_2; pucch.sets[1].resources[7].starting_prb = 51; pucch.sets[1].resources[7].nof_prb = 1; pucch.sets[1].resources[7].nof_symbols = 2; @@ -573,7 +573,7 @@ struct phy_cfg_nr_t { // nrofSymbols: 14 // startingSymbolIndex: 0 // timeDomainOCC: 2 - pucch.sr_resources[1].resource.format = SRSLTE_PUCCH_NR_FORMAT_1; + pucch.sr_resources[1].resource.format = SRSRAN_PUCCH_NR_FORMAT_1; pucch.sr_resources[1].resource.starting_prb = 0; pucch.sr_resources[1].resource.initial_cyclic_shift = 8; pucch.sr_resources[1].resource.nof_symbols = 14; @@ -589,9 +589,9 @@ struct phy_cfg_nr_t { // nrofPRBs: 1 // nrofSymbols: 2 // startingSymbolIndex: 2 - srslte_pucch_nr_resource_t pucch_res_17 = {}; + srsran_pucch_nr_resource_t pucch_res_17 = {}; pucch_res_17.starting_prb = 1; - pucch_res_17.format = SRSLTE_PUCCH_NR_FORMAT_2; + pucch_res_17.format = SRSRAN_PUCCH_NR_FORMAT_2; pucch_res_17.nof_prb = 1; pucch_res_17.nof_symbols = 2; pucch_res_17.start_symbol_idx = 2; @@ -601,10 +601,10 @@ struct phy_cfg_nr_t { // format2: setup (1) // setup // maxCodeRate: zeroDot25 (2) - for (uint32_t i = 0; i < SRSLTE_PUCCH_NR_MAX_NOF_SETS; i++) { - srslte_pucch_nr_resource_set_t* set = &pucch.sets[i]; + for (uint32_t i = 0; i < SRSRAN_PUCCH_NR_MAX_NOF_SETS; i++) { + srsran_pucch_nr_resource_set_t* set = &pucch.sets[i]; for (uint32_t j = 0; j < set->nof_resources; j++) { - if (set->resources[j].format == SRSLTE_PUCCH_NR_FORMAT_2) { + if (set->resources[j].format == SRSRAN_PUCCH_NR_FORMAT_2) { set->resources[j].max_code_rate = 2; // 0.25 } } @@ -673,18 +673,18 @@ struct phy_cfg_nr_t { // disabled // cqi-Table: table2 (1) // subbandSize: value1 (0) - csi.reports[0].type = SRSLTE_CSI_REPORT_TYPE_PERIODIC; + csi.reports[0].type = SRSRAN_CSI_REPORT_TYPE_PERIODIC; csi.reports[0].channel_meas_id = 0; csi.reports[0].interf_meas_present = true; csi.reports[0].interf_meas_id = 1; csi.reports[0].periodic.period = 80; csi.reports[0].periodic.offset = 9; csi.reports[0].periodic.resource = pucch_res_17; - csi.reports[0].quantity = SRSLTE_CSI_REPORT_QUANTITY_CRI_RI_PMI_CQI; - csi.reports[0].freq_cfg = SRSLTE_CSI_REPORT_FREQ_WIDEBAND; - csi.reports[0].cqi_table = SRSLTE_CSI_CQI_TABLE_2; + csi.reports[0].quantity = SRSRAN_CSI_REPORT_QUANTITY_CRI_RI_PMI_CQI; + csi.reports[0].freq_cfg = SRSRAN_CSI_REPORT_FREQ_WIDEBAND; + csi.reports[0].cqi_table = SRSRAN_CSI_CQI_TABLE_2; } }; -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_RRC_NR_INTERFACE_TYPES_H +#endif // SRSRAN_RRC_NR_INTERFACE_TYPES_H diff --git a/lib/include/srslte/interfaces/sched_interface.h b/lib/include/srsran/interfaces/sched_interface.h similarity index 87% rename from lib/include/srslte/interfaces/sched_interface.h rename to lib/include/srsran/interfaces/sched_interface.h index 375e392f6..3ac0091ae 100644 --- a/lib/include/srslte/interfaces/sched_interface.h +++ b/lib/include/srsran/interfaces/sched_interface.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,13 +10,13 @@ * */ -#include "srslte/adt/bounded_vector.h" -#include "srslte/common/common.h" -#include "srslte/srslte.h" +#include "srsran/adt/bounded_vector.h" +#include "srsran/common/common.h" +#include "srsran/srsran.h" #include -#ifndef SRSLTE_SCHED_INTERFACE_H -#define SRSLTE_SCHED_INTERFACE_H +#ifndef SRSRAN_SCHED_INTERFACE_H +#define SRSRAN_SCHED_INTERFACE_H namespace srsenb { @@ -59,14 +59,14 @@ public: struct cell_cfg_t { // Main cell configuration (used to calculate DCI locations in scheduler) - srslte_cell_t cell; + srsran_cell_t cell; /* SIB configuration */ cell_cfg_sib_t sibs[MAX_SIBS]; uint32_t si_window_ms; /* pusch configuration */ - srslte_pusch_hopping_cfg_t pusch_hopping_cfg; + srsran_pusch_hopping_cfg_t pusch_hopping_cfg; float target_ul_sinr; bool enable_phr_handling; bool enable_64qam; @@ -130,14 +130,14 @@ public: struct cc_cfg_t { bool active = false; uint32_t enb_cc_idx = 0; ///< eNB CC index - srslte_dl_cfg_t dl_cfg = {}; + srsran_dl_cfg_t dl_cfg = {}; uint32_t aperiodic_cqi_period = 0; // if 0 is periodic CQI }; /* ue capabilities, etc */ uint32_t maxharq_tx = 5; bool continuous_pusch = false; - srslte_uci_offset_cfg_t uci_offset = {15, 12, 10}; - srslte_pucch_cfg_t pucch_cfg = {}; + srsran_uci_offset_cfg_t uci_offset = {15, 12, 10}; + srsran_pucch_cfg_t pucch_cfg = {}; std::array ue_bearers = {}; std::vector supported_cc_list; ///< list of UE supported CCs. First index for PCell ant_info_ded_t dl_ant_info; @@ -169,19 +169,19 @@ public: } dl_pdu_mch_t; struct dl_sched_data_t { - srslte_dci_dl_t dci; - uint32_t tbs[SRSLTE_MAX_TB]; + srsran_dci_dl_t dci; + uint32_t tbs[SRSRAN_MAX_TB]; bool mac_ce_ta; bool mac_ce_rnti; - uint32_t nof_pdu_elems[SRSLTE_MAX_TB]; - dl_sched_pdu_t pdu[SRSLTE_MAX_TB][MAX_RLC_PDU_LIST]; + uint32_t nof_pdu_elems[SRSRAN_MAX_TB]; + dl_sched_pdu_t pdu[SRSRAN_MAX_TB][MAX_RLC_PDU_LIST]; }; typedef struct { bool needs_pdcch; uint32_t current_tx_nb; uint32_t tbs; - srslte_dci_ul_t dci; + srsran_dci_ul_t dci; } ul_sched_data_t; struct dl_sched_rar_info_t { @@ -194,17 +194,17 @@ public: typedef struct { dl_sched_rar_info_t data; - srslte_dci_rar_grant_t grant; + srsran_dci_rar_grant_t grant; } dl_sched_rar_grant_t; struct dl_sched_rar_t { uint32_t tbs; - srslte_dci_dl_t dci; - srslte::bounded_vector msg3_grant; + srsran_dci_dl_t dci; + srsran::bounded_vector msg3_grant; }; typedef struct { - srslte_dci_dl_t dci; + srsran_dci_dl_t dci; enum bc_type { BCCH, PCCH } type; @@ -216,9 +216,9 @@ public: struct dl_sched_res_t { uint32_t cfi; - srslte::bounded_vector data; - srslte::bounded_vector rar; - srslte::bounded_vector bc; + srsran::bounded_vector data; + srsran::bounded_vector rar; + srsran::bounded_vector bc; }; typedef struct { @@ -227,8 +227,8 @@ public: } ul_sched_phich_t; struct ul_sched_res_t { - srslte::bounded_vector pusch; - srslte::bounded_vector phich; + srsran::bounded_vector pusch; + srsran::bounded_vector phich; }; /******************* Scheduler Control ****************************/ @@ -292,11 +292,11 @@ public: /* Custom */ virtual void set_dl_tti_mask(uint8_t* tti_mask, uint32_t nof_sfs) = 0; - virtual std::array get_enb_ue_cc_map(uint16_t rnti) = 0; - virtual std::array get_scell_activation_mask(uint16_t rnti) = 0; + virtual std::array get_enb_ue_cc_map(uint16_t rnti) = 0; + virtual std::array get_scell_activation_mask(uint16_t rnti) = 0; virtual int ul_buffer_add(uint16_t rnti, uint32_t lcid, uint32_t bytes) = 0; }; } // namespace srsenb -#endif // SRSLTE_SCHED_INTERFACE_H +#endif // SRSRAN_SCHED_INTERFACE_H diff --git a/lib/include/srslte/interfaces/ue_gw_interfaces.h b/lib/include/srsran/interfaces/ue_gw_interfaces.h similarity index 82% rename from lib/include/srslte/interfaces/ue_gw_interfaces.h rename to lib/include/srsran/interfaces/ue_gw_interfaces.h index f981e273a..e331b52d3 100644 --- a/lib/include/srslte/interfaces/ue_gw_interfaces.h +++ b/lib/include/srsran/interfaces/ue_gw_interfaces.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,11 +10,11 @@ * */ -#ifndef SRSLTE_UE_GW_INTERFACES_H -#define SRSLTE_UE_GW_INTERFACES_H +#ifndef SRSRAN_UE_GW_INTERFACES_H +#define SRSRAN_UE_GW_INTERFACES_H -#include "srslte/asn1/liblte_mme.h" -#include "srslte/common/byte_buffer.h" +#include "srsran/asn1/liblte_mme.h" +#include "srsran/common/byte_buffer.h" namespace srsue { @@ -56,8 +56,8 @@ public: class gw_interface_pdcp { public: - virtual void write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t pdu) = 0; - virtual void write_pdu_mch(uint32_t lcid, srslte::unique_byte_buffer_t pdu) = 0; + virtual void write_pdu(uint32_t lcid, srsran::unique_byte_buffer_t pdu) = 0; + virtual void write_pdu_mch(uint32_t lcid, srsran::unique_byte_buffer_t pdu) = 0; }; class gw_interface_stack : public gw_interface_nas, public gw_interface_rrc, public gw_interface_pdcp @@ -65,4 +65,4 @@ class gw_interface_stack : public gw_interface_nas, public gw_interface_rrc, pub } // namespace srsue -#endif // SRSLTE_UE_GW_INTERFACES_H +#endif // SRSRAN_UE_GW_INTERFACES_H diff --git a/lib/include/srslte/interfaces/ue_interfaces.h b/lib/include/srsran/interfaces/ue_interfaces.h similarity index 82% rename from lib/include/srslte/interfaces/ue_interfaces.h rename to lib/include/srsran/interfaces/ue_interfaces.h index 54155a09a..4027b1458 100644 --- a/lib/include/srslte/interfaces/ue_interfaces.h +++ b/lib/include/srsran/interfaces/ue_interfaces.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -16,8 +16,8 @@ * to other layers. *****************************************************************************/ -#ifndef SRSLTE_UE_INTERFACES_H -#define SRSLTE_UE_INTERFACES_H +#ifndef SRSRAN_UE_INTERFACES_H +#define SRSRAN_UE_INTERFACES_H #include "ue_mac_interfaces.h" #include "ue_rrc_interfaces.h" @@ -28,7 +28,7 @@ namespace srsue { class stack_interface_rrc { public: - virtual srslte::tti_point get_current_tti() = 0; + virtual srsran::tti_point get_current_tti() = 0; }; // Combined interface for PHY to access stack (MAC and RRC) @@ -41,4 +41,4 @@ public: } // namespace srsue -#endif // SRSLTE_UE_INTERFACES_H +#endif // SRSRAN_UE_INTERFACES_H diff --git a/lib/include/srslte/interfaces/ue_mac_interfaces.h b/lib/include/srsran/interfaces/ue_mac_interfaces.h similarity index 87% rename from lib/include/srslte/interfaces/ue_mac_interfaces.h rename to lib/include/srsran/interfaces/ue_mac_interfaces.h index cc6e75fbe..540e5f130 100644 --- a/lib/include/srslte/interfaces/ue_mac_interfaces.h +++ b/lib/include/srsran/interfaces/ue_mac_interfaces.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,8 +10,8 @@ * */ -#ifndef SRSLTE_UE_MAC_INTERFACES_H -#define SRSLTE_UE_MAC_INTERFACES_H +#ifndef SRSRAN_UE_MAC_INTERFACES_H +#define SRSRAN_UE_MAC_INTERFACES_H #include "mac_interface_types.h" @@ -32,7 +32,7 @@ public: } mac_tb_t; typedef struct { - mac_tb_t tb[SRSLTE_MAX_TB]; + mac_tb_t tb[SRSRAN_MAX_TB]; uint32_t pid; uint16_t rnti; bool is_sps_release; @@ -54,13 +54,13 @@ public: uint32_t rv; uint8_t* payload; union { - srslte_softbuffer_rx_t* rx; - srslte_softbuffer_tx_t* tx; + srsran_softbuffer_rx_t* rx; + srsran_softbuffer_tx_t* tx; } softbuffer; } tb_action_t; typedef struct { - tb_action_t tb[SRSLTE_MAX_TB]; + tb_action_t tb[SRSRAN_MAX_TB]; bool generate_ack; } tb_action_dl_t; @@ -85,7 +85,7 @@ public: virtual void new_grant_dl(uint32_t cc_idx, mac_grant_dl_t grant, tb_action_dl_t* action) = 0; /* Indicate successful decoding of PDSCH AND PCH TB. */ - virtual void tb_decoded(uint32_t cc_idx, mac_grant_dl_t grant, bool ack[SRSLTE_MAX_CODEWORDS]) = 0; + virtual void tb_decoded(uint32_t cc_idx, mac_grant_dl_t grant, bool ack[SRSRAN_MAX_CODEWORDS]) = 0; /* Indicate successful decoding of BCH TB through PBCH */ virtual void bch_decoded_ok(uint32_t cc_idx, uint8_t* payload, uint32_t len) = 0; @@ -94,7 +94,7 @@ public: virtual void mch_decoded(uint32_t len, bool crc) = 0; /* Obtain action for a new MCH subframe. */ - virtual void new_mch_dl(const srslte_pdsch_grant_t& phy_grant, tb_action_dl_t* action) = 0; + virtual void new_mch_dl(const srsran_pdsch_grant_t& phy_grant, tb_action_dl_t* action) = 0; /* Communicate the number of mbsfn services available */ virtual void set_mbsfn_config(uint32_t nof_mbsfn_services) = 0; @@ -131,10 +131,10 @@ public: virtual void mch_start_rx(uint32_t lcid) = 0; /* Set entire MAC config */ - virtual void set_config(srslte::mac_cfg_t& mac_cfg) = 0; + virtual void set_config(srsran::mac_cfg_t& mac_cfg) = 0; /* Update SR config only for PUCCH release */ - virtual void set_config(srslte::sr_cfg_t& sr_cfg) = 0; + virtual void set_config(srsran::sr_cfg_t& sr_cfg) = 0; virtual void set_rach_ded_cfg(uint32_t preamble_index, uint32_t prach_mask) = 0; @@ -148,4 +148,4 @@ public: } // namespace srsue -#endif // SRSLTE_UE_MAC_INTERFACES_H +#endif // SRSRAN_UE_MAC_INTERFACES_H diff --git a/lib/include/srslte/interfaces/ue_nas_interfaces.h b/lib/include/srsran/interfaces/ue_nas_interfaces.h similarity index 76% rename from lib/include/srslte/interfaces/ue_nas_interfaces.h rename to lib/include/srsran/interfaces/ue_nas_interfaces.h index b5f30c77c..fa7f0f47d 100644 --- a/lib/include/srslte/interfaces/ue_nas_interfaces.h +++ b/lib/include/srsran/interfaces/ue_nas_interfaces.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,10 +10,10 @@ * */ -#ifndef SRSLTE_UE_NAS_INTERFACES_H -#define SRSLTE_UE_NAS_INTERFACES_H +#ifndef SRSRAN_UE_NAS_INTERFACES_H +#define SRSRAN_UE_NAS_INTERFACES_H -#include "srslte/interfaces/rrc_interface_types.h" +#include "srsran/interfaces/rrc_interface_types.h" namespace srsue { @@ -22,15 +22,15 @@ class nas_interface_rrc public: const static int MAX_FOUND_PLMNS = 16; struct found_plmn_t { - srslte::plmn_id_t plmn_id; + srsran::plmn_id_t plmn_id; uint16_t tac; }; virtual void left_rrc_connected() = 0; - virtual void set_barring(srslte::barring_t barring) = 0; - virtual bool paging(srslte::s_tmsi_t* ue_identity) = 0; + virtual void set_barring(srsran::barring_t barring) = 0; + virtual bool paging(srsran::s_tmsi_t* ue_identity) = 0; virtual bool is_registered() = 0; - virtual void write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t pdu) = 0; + virtual void write_pdu(uint32_t lcid, srsran::unique_byte_buffer_t pdu) = 0; virtual uint32_t get_k_enb_count() = 0; virtual bool get_k_asme(uint8_t* k_asme_, uint32_t n) = 0; virtual uint32_t get_ipv4_addr() = 0; @@ -41,4 +41,4 @@ public: } // namespace srsue -#endif // SRSLTE_UE_NAS_INTERFACES_H +#endif // SRSRAN_UE_NAS_INTERFACES_H diff --git a/lib/include/srslte/interfaces/ue_nr_interfaces.h b/lib/include/srsran/interfaces/ue_nr_interfaces.h similarity index 83% rename from lib/include/srslte/interfaces/ue_nr_interfaces.h rename to lib/include/srsran/interfaces/ue_nr_interfaces.h index 67a66da52..34db1f4ad 100644 --- a/lib/include/srslte/interfaces/ue_nr_interfaces.h +++ b/lib/include/srsran/interfaces/ue_nr_interfaces.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,12 +10,12 @@ * */ -#ifndef SRSLTE_UE_NR_INTERFACES_H -#define SRSLTE_UE_NR_INTERFACES_H +#ifndef SRSRAN_UE_NR_INTERFACES_H +#define SRSRAN_UE_NR_INTERFACES_H -#include "srslte/common/interfaces_common.h" -#include "srslte/interfaces/mac_interface_types.h" -#include "srslte/interfaces/rrc_nr_interface_types.h" +#include "srsran/common/interfaces_common.h" +#include "srsran/interfaces/mac_interface_types.h" +#include "srsran/interfaces/rrc_nr_interface_types.h" #include #include #include @@ -34,7 +34,7 @@ class mac_interface_phy_nr { public: typedef struct { - srslte::unique_byte_buffer_t tb[SRSLTE_MAX_TB]; + srsran::unique_byte_buffer_t tb[SRSRAN_MAX_TB]; uint32_t pid; uint16_t rnti; uint32_t tti; @@ -51,8 +51,8 @@ public: typedef struct { bool enabled; uint32_t rv; - srslte::byte_buffer_t* payload; - srslte_softbuffer_tx_t* softbuffer; + srsran::byte_buffer_t* payload; + srsran_softbuffer_tx_t* softbuffer; } tb_ul_t; /// Struct provided by MAC with all necessary information for PHY @@ -65,7 +65,7 @@ public: // Query the MAC for the current RNTI to look for struct sched_rnti_t { uint16_t id; - srslte_rnti_type_t type; + srsran_rnti_type_t type; }; virtual sched_rnti_t get_dl_sched_rnti_nr(const uint32_t tti) = 0; virtual sched_rnti_t get_ul_sched_rnti_nr(const uint32_t tti) = 0; @@ -98,10 +98,10 @@ public: class mac_interface_rrc_nr { public: - virtual void setup_lcid(const srslte::logical_channel_config_t& config) = 0; - virtual void set_config(const srslte::bsr_cfg_t& bsr_cfg) = 0; - virtual void set_config(const srslte::sr_cfg_t& sr_cfg) = 0; - virtual void set_config(const srslte::rach_nr_cfg_t& rach_cfg) = 0; + virtual void setup_lcid(const srsran::logical_channel_config_t& config) = 0; + virtual void set_config(const srsran::bsr_cfg_t& bsr_cfg) = 0; + virtual void set_config(const srsran::sr_cfg_t& sr_cfg) = 0; + virtual void set_config(const srsran::rach_nr_cfg_t& rach_cfg) = 0; // RRC triggers MAC ra procedure virtual void start_ra_procedure() = 0; @@ -118,9 +118,9 @@ struct phy_args_nr_t { uint32_t nof_prb; uint32_t nof_phy_threads; uint32_t worker_cpu_mask; - srslte::phy_log_args_t log; - srslte_ue_dl_nr_args_t dl; - srslte_ue_ul_nr_args_t ul; + srsran::phy_log_args_t log; + srsran_ue_dl_nr_args_t dl; + srsran_ue_ul_nr_args_t ul; std::set fixed_sr = {1}; uint32_t fix_wideband_cqi = 15; // Set to a non-zero value for fixing the wide-band CQI report @@ -149,9 +149,9 @@ public: } tx_request_t; // MAC informs PHY about UL grant included in RAR PDU - virtual int set_ul_grant(std::array packed_ul_grant, + virtual int set_ul_grant(std::array packed_ul_grant, uint16_t rnti, - srslte_rnti_type_t rnti_type) = 0; + srsran_rnti_type_t rnti_type) = 0; // MAC instructs PHY to transmit MAC TB at the given TTI virtual int tx_request(const tx_request_t& request) = 0; @@ -169,13 +169,13 @@ public: class phy_interface_rrc_nr { public: - virtual bool set_config(const srslte::phy_cfg_nr_t& cfg) = 0; + virtual bool set_config(const srsran::phy_cfg_nr_t& cfg) = 0; }; // Combined interface for PHY to access stack (MAC and RRC) class stack_interface_phy_nr : public mac_interface_phy_nr, public rrc_interface_phy_nr, - public srslte::stack_interface_phy_nr + public srsran::stack_interface_phy_nr {}; // Combined interface for stack (MAC and RRC) to access PHY @@ -184,4 +184,4 @@ class phy_interface_stack_nr : public phy_interface_mac_nr, public phy_interface } // namespace srsue -#endif // SRSLTE_UE_NR_INTERFACES_H +#endif // SRSRAN_UE_NR_INTERFACES_H diff --git a/lib/include/srslte/interfaces/ue_pdcp_interfaces.h b/lib/include/srsran/interfaces/ue_pdcp_interfaces.h similarity index 63% rename from lib/include/srslte/interfaces/ue_pdcp_interfaces.h rename to lib/include/srsran/interfaces/ue_pdcp_interfaces.h index 05874e7ee..fe1f129b4 100644 --- a/lib/include/srslte/interfaces/ue_pdcp_interfaces.h +++ b/lib/include/srsran/interfaces/ue_pdcp_interfaces.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,11 +10,11 @@ * */ -#ifndef SRSLTE_UE_PDCP_INTERFACES_H -#define SRSLTE_UE_PDCP_INTERFACES_H +#ifndef SRSRAN_UE_PDCP_INTERFACES_H +#define SRSRAN_UE_PDCP_INTERFACES_H #include "pdcp_interface_types.h" -#include "srslte/common/byte_buffer.h" +#include "srsran/common/byte_buffer.h" namespace srsue { @@ -24,14 +24,14 @@ public: virtual void reestablish() = 0; virtual void reestablish(uint32_t lcid) = 0; virtual void reset() = 0; - virtual void write_sdu(uint32_t lcid, srslte::unique_byte_buffer_t sdu, int sn = -1) = 0; - virtual void add_bearer(uint32_t lcid, srslte::pdcp_config_t cnfg) = 0; + virtual void write_sdu(uint32_t lcid, srsran::unique_byte_buffer_t sdu, int sn = -1) = 0; + virtual void add_bearer(uint32_t lcid, srsran::pdcp_config_t cnfg) = 0; virtual void change_lcid(uint32_t old_lcid, uint32_t new_lcid) = 0; - virtual void config_security(uint32_t lcid, srslte::as_security_config_t sec_cfg) = 0; - virtual void config_security_all(srslte::as_security_config_t sec_cfg) = 0; - virtual void enable_integrity(uint32_t lcid, srslte::srslte_direction_t direction) = 0; + virtual void config_security(uint32_t lcid, srsran::as_security_config_t sec_cfg) = 0; + virtual void config_security_all(srsran::as_security_config_t sec_cfg) = 0; + virtual void enable_integrity(uint32_t lcid, srsran::srsran_direction_t direction) = 0; virtual void enable_encryption(uint32_t lcid, - srslte::srslte_direction_t direction = srslte::srslte_direction_t::DIRECTION_TXRX) = 0; + srsran::srsran_direction_t direction = srsran::srsran_direction_t::DIRECTION_TXRX) = 0; virtual void send_status_report() = 0; virtual void send_status_report(uint32_t lcid) = 0; }; @@ -40,19 +40,19 @@ class pdcp_interface_rlc { public: /* RLC calls PDCP to push a PDCP PDU. */ - virtual void write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t sdu) = 0; - virtual void write_pdu_bcch_bch(srslte::unique_byte_buffer_t sdu) = 0; - virtual void write_pdu_bcch_dlsch(srslte::unique_byte_buffer_t sdu) = 0; - virtual void write_pdu_pcch(srslte::unique_byte_buffer_t sdu) = 0; - virtual void write_pdu_mch(uint32_t lcid, srslte::unique_byte_buffer_t sdu) = 0; - virtual void notify_delivery(uint32_t lcid, const srslte::pdcp_sn_vector_t& pdcp_sn) = 0; - virtual void notify_failure(uint32_t lcid, const srslte::pdcp_sn_vector_t& pdcp_sn) = 0; + virtual void write_pdu(uint32_t lcid, srsran::unique_byte_buffer_t sdu) = 0; + virtual void write_pdu_bcch_bch(srsran::unique_byte_buffer_t sdu) = 0; + virtual void write_pdu_bcch_dlsch(srsran::unique_byte_buffer_t sdu) = 0; + virtual void write_pdu_pcch(srsran::unique_byte_buffer_t sdu) = 0; + virtual void write_pdu_mch(uint32_t lcid, srsran::unique_byte_buffer_t sdu) = 0; + virtual void notify_delivery(uint32_t lcid, const srsran::pdcp_sn_vector_t& pdcp_sn) = 0; + virtual void notify_failure(uint32_t lcid, const srsran::pdcp_sn_vector_t& pdcp_sn) = 0; }; class pdcp_interface_gw { public: - virtual void write_sdu(uint32_t lcid, srslte::unique_byte_buffer_t sdu) = 0; + virtual void write_sdu(uint32_t lcid, srsran::unique_byte_buffer_t sdu) = 0; virtual bool is_lcid_enabled(uint32_t lcid) = 0; }; @@ -66,4 +66,4 @@ public: } // namespace srsue -#endif // SRSLTE_UE_PDCP_INTERFACES_H +#endif // SRSRAN_UE_PDCP_INTERFACES_H diff --git a/lib/include/srslte/interfaces/ue_phy_interfaces.h b/lib/include/srsran/interfaces/ue_phy_interfaces.h similarity index 86% rename from lib/include/srslte/interfaces/ue_phy_interfaces.h rename to lib/include/srsran/interfaces/ue_phy_interfaces.h index 2290d895e..3ed10ee08 100644 --- a/lib/include/srslte/interfaces/ue_phy_interfaces.h +++ b/lib/include/srsran/interfaces/ue_phy_interfaces.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,15 +10,15 @@ * */ -#ifndef SRSLTE_UE_PHY_INTERFACES_H -#define SRSLTE_UE_PHY_INTERFACES_H +#ifndef SRSRAN_UE_PHY_INTERFACES_H +#define SRSRAN_UE_PHY_INTERFACES_H -#include "srslte/srslte.h" +#include "srsran/srsran.h" #include "phy_interface_types.h" #include "rrc_interface_types.h" -#include "srslte/common/interfaces_common.h" -#include "srslte/phy/channel/channel.h" +#include "srsran/common/interfaces_common.h" +#include "srsran/phy/channel/channel.h" #include #include @@ -28,7 +28,7 @@ namespace srsue { struct phy_args_t { std::string type = "lte"; - srslte::phy_log_args_t log; + srsran::phy_log_args_t log; std::string dl_earfcn = "3400"; // comma-separated list of DL EARFCNs std::string ul_earfcn = ""; // comma-separated list of UL EARFCNs @@ -93,10 +93,10 @@ struct phy_args_t { uint32_t nof_in_sync_events = 10; uint32_t nof_out_of_sync_events = 20; - srslte::channel::args_t dl_channel_args; - srslte::channel::args_t ul_channel_args; + srsran::channel::args_t dl_channel_args; + srsran::channel::args_t ul_channel_args; - srslte::vnf_args_t vnf_args; + srsran::vnf_args_t vnf_args; }; /* RAT agnostic Interface MAC -> PHY */ @@ -111,7 +111,7 @@ public: virtual void set_activation_deactivation_scell(uint32_t cmd, uint32_t tti) = 0; /* Sets RAR dci payload */ - virtual void set_rar_grant(uint8_t grant_payload[SRSLTE_RAR_GRANT_LEN], uint16_t rnti) = 0; + virtual void set_rar_grant(uint8_t grant_payload[SRSRAN_RAR_GRANT_LEN], uint16_t rnti) = 0; virtual uint32_t get_current_tti() = 0; @@ -144,12 +144,12 @@ public: class phy_interface_rrc_lte { public: - virtual bool set_config(srslte::phy_cfg_t config, uint32_t cc_idx = 0) = 0; - virtual bool set_scell(srslte_cell_t cell_info, uint32_t cc_idx, uint32_t earfcn) = 0; - virtual void set_config_tdd(srslte_tdd_config_t& tdd_config) = 0; - virtual void set_config_mbsfn_sib2(srslte::mbsfn_sf_cfg_t* cfg_list, uint32_t nof_cfgs) = 0; - virtual void set_config_mbsfn_sib13(const srslte::sib13_t& sib13) = 0; - virtual void set_config_mbsfn_mcch(const srslte::mcch_msg_t& mcch) = 0; + virtual bool set_config(srsran::phy_cfg_t config, uint32_t cc_idx = 0) = 0; + virtual bool set_scell(srsran_cell_t cell_info, uint32_t cc_idx, uint32_t earfcn) = 0; + virtual void set_config_tdd(srsran_tdd_config_t& tdd_config) = 0; + virtual void set_config_mbsfn_sib2(srsran::mbsfn_sf_cfg_t* cfg_list, uint32_t nof_cfgs) = 0; + virtual void set_config_mbsfn_sib13(const srsran::sib13_t& sib13) = 0; + virtual void set_config_mbsfn_mcch(const srsran::mcch_msg_t& mcch) = 0; virtual void deactivate_scells() = 0; @@ -171,4 +171,4 @@ class phy_interface_stack_lte : public phy_interface_mac_lte, public phy_interfa } // namespace srsue -#endif // SRSLTE_UE_PHY_INTERFACES_H +#endif // SRSRAN_UE_PHY_INTERFACES_H diff --git a/lib/include/srslte/interfaces/ue_rlc_interfaces.h b/lib/include/srsran/interfaces/ue_rlc_interfaces.h similarity index 81% rename from lib/include/srslte/interfaces/ue_rlc_interfaces.h rename to lib/include/srsran/interfaces/ue_rlc_interfaces.h index 004120eac..c7f05dd42 100644 --- a/lib/include/srslte/interfaces/ue_rlc_interfaces.h +++ b/lib/include/srsran/interfaces/ue_rlc_interfaces.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,11 +10,11 @@ * */ -#ifndef SRSLTE_UE_RLC_INTERFACES_H -#define SRSLTE_UE_RLC_INTERFACES_H +#ifndef SRSRAN_UE_RLC_INTERFACES_H +#define SRSRAN_UE_RLC_INTERFACES_H -#include "srslte/common/interfaces_common.h" -#include "srslte/interfaces/rlc_interface_types.h" +#include "srsran/common/interfaces_common.h" +#include "srsran/interfaces/rlc_interface_types.h" namespace srsue { @@ -24,7 +24,7 @@ public: virtual void reset() = 0; virtual void reestablish() = 0; virtual void reestablish(uint32_t lcid) = 0; - virtual void add_bearer(uint32_t lcid, const srslte::rlc_config_t& cnfg) = 0; + virtual void add_bearer(uint32_t lcid, const srsran::rlc_config_t& cnfg) = 0; virtual void add_bearer_mrb(uint32_t lcid) = 0; virtual void del_bearer(uint32_t lcid) = 0; virtual void suspend_bearer(uint32_t lcid) = 0; @@ -33,7 +33,7 @@ public: virtual bool has_bearer(uint32_t lcid) = 0; virtual bool has_data(const uint32_t lcid) = 0; virtual bool is_suspended(const uint32_t lcid) = 0; - virtual void write_sdu(uint32_t lcid, srslte::unique_byte_buffer_t sdu) = 0; + virtual void write_sdu(uint32_t lcid, srsran::unique_byte_buffer_t sdu) = 0; }; class rlc_interface_pdcp @@ -41,7 +41,7 @@ class rlc_interface_pdcp public: ///< PDCP calls RLC to push an RLC SDU. SDU gets placed into the buffer ///< MAC pulls RLC PDUs according to TB size - virtual void write_sdu(uint32_t lcid, srslte::unique_byte_buffer_t sdu) = 0; + virtual void write_sdu(uint32_t lcid, srsran::unique_byte_buffer_t sdu) = 0; ///< Indicate RLC that a certain SN can be discarded virtual void discard_sdu(uint32_t lcid, uint32_t discard_sn) = 0; @@ -53,7 +53,7 @@ public: virtual bool sdu_queue_is_full(uint32_t lcid) = 0; }; -class rlc_interface_mac : public srslte::read_pdu_interface +class rlc_interface_mac : public srsran::read_pdu_interface { public: /* MAC calls has_data() to query whether a logical channel has data to transmit (without @@ -72,12 +72,12 @@ public: /* MAC calls RLC to push an RLC PDU. This function is called from an independent MAC thread. * PDU gets placed into the buffer and higher layer thread gets notified. */ virtual void write_pdu(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes) = 0; - virtual void write_pdu_bcch_bch(srslte::unique_byte_buffer_t payload) = 0; + virtual void write_pdu_bcch_bch(srsran::unique_byte_buffer_t payload) = 0; virtual void write_pdu_bcch_dlsch(uint8_t* payload, uint32_t nof_bytes) = 0; - virtual void write_pdu_pcch(srslte::unique_byte_buffer_t payload) = 0; + virtual void write_pdu_pcch(srsran::unique_byte_buffer_t payload) = 0; virtual void write_pdu_mch(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes) = 0; }; } // namespace srsue -#endif // SRSLTE_UE_RLC_INTERFACES_H +#endif // SRSRAN_UE_RLC_INTERFACES_H diff --git a/lib/include/srslte/interfaces/ue_rrc_interfaces.h b/lib/include/srsran/interfaces/ue_rrc_interfaces.h similarity index 78% rename from lib/include/srslte/interfaces/ue_rrc_interfaces.h rename to lib/include/srsran/interfaces/ue_rrc_interfaces.h index f76525f3d..3cfdd889b 100644 --- a/lib/include/srslte/interfaces/ue_rrc_interfaces.h +++ b/lib/include/srsran/interfaces/ue_rrc_interfaces.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,14 +10,14 @@ * */ -#ifndef SRSLTE_UE_RRC_INTERFACES_H -#define SRSLTE_UE_RRC_INTERFACES_H +#ifndef SRSRAN_UE_RRC_INTERFACES_H +#define SRSRAN_UE_RRC_INTERFACES_H #include "phy_interface_types.h" #include "rrc_interface_types.h" -#include "srslte/asn1/asn1_utils.h" -#include "srslte/common/byte_buffer.h" -#include "srslte/common/tti_point.h" +#include "srsran/asn1/asn1_utils.h" +#include "srsran/common/byte_buffer.h" +#include "srsran/common/tti_point.h" namespace srsue { @@ -63,15 +63,15 @@ class rrc_interface_nas { public: virtual ~rrc_interface_nas() = default; - virtual void write_sdu(srslte::unique_byte_buffer_t sdu) = 0; + virtual void write_sdu(srsran::unique_byte_buffer_t sdu) = 0; virtual uint16_t get_mcc() = 0; virtual uint16_t get_mnc() = 0; virtual void enable_capabilities() = 0; virtual bool plmn_search() = 0; - virtual void plmn_select(srslte::plmn_id_t plmn_id) = 0; - virtual bool connection_request(srslte::establishment_cause_t cause, - srslte::unique_byte_buffer_t dedicatedInfoNAS) = 0; - virtual void set_ue_identity(srslte::s_tmsi_t s_tmsi) = 0; + virtual void plmn_select(srsran::plmn_id_t plmn_id) = 0; + virtual bool connection_request(srsran::establishment_cause_t cause, + srsran::unique_byte_buffer_t dedicatedInfoNAS) = 0; + virtual void set_ue_identity(srsran::s_tmsi_t s_tmsi) = 0; virtual bool is_connected() = 0; virtual void paging_completed(bool outcome) = 0; virtual std::string get_rb_name(uint32_t lcid) = 0; @@ -82,11 +82,11 @@ public: class rrc_interface_pdcp { public: - virtual void write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t pdu) = 0; - virtual void write_pdu_bcch_bch(srslte::unique_byte_buffer_t pdu) = 0; - virtual void write_pdu_bcch_dlsch(srslte::unique_byte_buffer_t pdu) = 0; - virtual void write_pdu_pcch(srslte::unique_byte_buffer_t pdu) = 0; - virtual void write_pdu_mch(uint32_t lcid, srslte::unique_byte_buffer_t pdu) = 0; + virtual void write_pdu(uint32_t lcid, srsran::unique_byte_buffer_t pdu) = 0; + virtual void write_pdu_bcch_bch(srsran::unique_byte_buffer_t pdu) = 0; + virtual void write_pdu_bcch_dlsch(srsran::unique_byte_buffer_t pdu) = 0; + virtual void write_pdu_pcch(srsran::unique_byte_buffer_t pdu) = 0; + virtual void write_pdu_mch(uint32_t lcid, srsran::unique_byte_buffer_t pdu) = 0; virtual std::string get_rb_name(uint32_t lcid) = 0; }; @@ -95,14 +95,14 @@ class rrc_interface_rlc public: virtual void max_retx_attempted() = 0; virtual std::string get_rb_name(uint32_t lcid) = 0; - virtual void write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t pdu) = 0; + virtual void write_pdu(uint32_t lcid, srsran::unique_byte_buffer_t pdu) = 0; }; class rrc_nr_interface_rrc { public: - virtual void get_eutra_nr_capabilities(srslte::byte_buffer_t* eutra_nr_caps) = 0; - virtual void get_nr_capabilities(srslte::byte_buffer_t* nr_cap) = 0; + virtual void get_eutra_nr_capabilities(srsran::byte_buffer_t* eutra_nr_caps) = 0; + virtual void get_nr_capabilities(srsran::byte_buffer_t* nr_cap) = 0; virtual void phy_set_cells_to_meas(uint32_t carrier_freq_r15) = 0; virtual void phy_meas_stop() = 0; virtual bool rrc_reconfiguration(bool endc_release_and_add_r15, @@ -117,4 +117,4 @@ public: } // namespace srsue -#endif // SRSLTE_UE_RRC_INTERFACES_H +#endif // SRSRAN_UE_RRC_INTERFACES_H diff --git a/lib/include/srslte/interfaces/ue_usim_interfaces.h b/lib/include/srsran/interfaces/ue_usim_interfaces.h similarity index 74% rename from lib/include/srslte/interfaces/ue_usim_interfaces.h rename to lib/include/srsran/interfaces/ue_usim_interfaces.h index ecb0a4a84..8ad50cf9f 100644 --- a/lib/include/srslte/interfaces/ue_usim_interfaces.h +++ b/lib/include/srsran/interfaces/ue_usim_interfaces.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,8 +10,8 @@ * */ -#ifndef SRSLTE_UE_USIM_INTERFACES_H -#define SRSLTE_UE_USIM_INTERFACES_H +#ifndef SRSRAN_UE_USIM_INTERFACES_H +#define SRSRAN_UE_USIM_INTERFACES_H #include "rrc_interface_types.h" #include @@ -28,7 +28,7 @@ public: virtual std::string get_imei_str() = 0; virtual bool get_imsi_vec(uint8_t* imsi_, uint32_t n) = 0; virtual bool get_imei_vec(uint8_t* imei_, uint32_t n) = 0; - virtual bool get_home_plmn_id(srslte::plmn_id_t* home_plmn_id) = 0; + virtual bool get_home_plmn_id(srsran::plmn_id_t* home_plmn_id) = 0; virtual auth_result_t generate_authentication_response(uint8_t* rand, uint8_t* autn_enb, uint16_t mcc, @@ -39,27 +39,27 @@ public: virtual void generate_nas_keys(uint8_t* k_asme, uint8_t* k_nas_enc, uint8_t* k_nas_int, - srslte::CIPHERING_ALGORITHM_ID_ENUM cipher_algo, - srslte::INTEGRITY_ALGORITHM_ID_ENUM integ_algo) = 0; + srsran::CIPHERING_ALGORITHM_ID_ENUM cipher_algo, + srsran::INTEGRITY_ALGORITHM_ID_ENUM integ_algo) = 0; }; // USIM interface for RRC class usim_interface_rrc { public: - virtual void generate_as_keys(uint8_t* k_asme, uint32_t count_ul, srslte::as_security_config_t* sec_cfg) = 0; - virtual void generate_as_keys_ho(uint32_t pci, uint32_t earfcn, int ncc, srslte::as_security_config_t* sec_cfg) = 0; - virtual void store_keys_before_ho(const srslte::as_security_config_t& as_cfg) = 0; - virtual void restore_keys_from_failed_ho(srslte::as_security_config_t* as_cfg) = 0; + virtual void generate_as_keys(uint8_t* k_asme, uint32_t count_ul, srsran::as_security_config_t* sec_cfg) = 0; + virtual void generate_as_keys_ho(uint32_t pci, uint32_t earfcn, int ncc, srsran::as_security_config_t* sec_cfg) = 0; + virtual void store_keys_before_ho(const srsran::as_security_config_t& as_cfg) = 0; + virtual void restore_keys_from_failed_ho(srsran::as_security_config_t* as_cfg) = 0; }; class usim_interface_rrc_nr { public: - virtual void generate_nr_context(uint16_t sk_counter, srslte::as_security_config_t* sec_cfg) = 0; - virtual void update_nr_context(srslte::as_security_config_t* sec_cfg) = 0; + virtual void generate_nr_context(uint16_t sk_counter, srsran::as_security_config_t* sec_cfg) = 0; + virtual void update_nr_context(srsran::as_security_config_t* sec_cfg) = 0; }; } // namespace srsue -#endif // SRSLTE_UE_USIM_INTERFACES_H +#endif // SRSRAN_UE_USIM_INTERFACES_H diff --git a/lib/include/srslte/mac/mac_rar_pdu_nr.h b/lib/include/srsran/mac/mac_rar_pdu_nr.h similarity index 87% rename from lib/include/srslte/mac/mac_rar_pdu_nr.h rename to lib/include/srsran/mac/mac_rar_pdu_nr.h index 6ef9857d9..cd7805bde 100644 --- a/lib/include/srslte/mac/mac_rar_pdu_nr.h +++ b/lib/include/srsran/mac/mac_rar_pdu_nr.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,18 +10,18 @@ * */ -#ifndef SRSLTE_MAC_RAR_PDU_NR_H -#define SRSLTE_MAC_RAR_PDU_NR_H +#ifndef SRSRAN_MAC_RAR_PDU_NR_H +#define SRSRAN_MAC_RAR_PDU_NR_H -#include "srslte/common/common.h" -#include "srslte/config.h" -#include "srslte/phy/common/phy_common_nr.h" -#include "srslte/srslog/srslog.h" +#include "srsran/common/common.h" +#include "srsran/config.h" +#include "srsran/phy/common/phy_common_nr.h" +#include "srsran/srslog/srslog.h" #include #include #include -namespace srslte { +namespace srsran { class mac_rar_pdu_nr; @@ -35,7 +35,7 @@ public: mac_rar_subpdu_nr(mac_rar_pdu_nr* parent_); // RAR content length in bits (38.321 Sec 6.2.3) - static const uint32_t UL_GRANT_NBITS = SRSLTE_RAR_UL_GRANT_NBITS; + static const uint32_t UL_GRANT_NBITS = SRSRAN_RAR_UL_GRANT_NBITS; static const uint32_t TA_COMMAND_NBITS = 12; // getter @@ -102,6 +102,6 @@ private: srslog::basic_logger& logger; }; -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_MAC_RAR_PDU_NR_H +#endif // SRSRAN_MAC_RAR_PDU_NR_H diff --git a/lib/include/srslte/mac/mac_sch_pdu_nr.h b/lib/include/srsran/mac/mac_sch_pdu_nr.h similarity index 90% rename from lib/include/srslte/mac/mac_sch_pdu_nr.h rename to lib/include/srsran/mac/mac_sch_pdu_nr.h index f9ffbe59e..bc03bca6b 100644 --- a/lib/include/srslte/mac/mac_sch_pdu_nr.h +++ b/lib/include/srsran/mac/mac_sch_pdu_nr.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,18 +10,18 @@ * */ -#ifndef SRSLTE_MAC_SCH_PDU_NR_H -#define SRSLTE_MAC_SCH_PDU_NR_H +#ifndef SRSRAN_MAC_SCH_PDU_NR_H +#define SRSRAN_MAC_SCH_PDU_NR_H -#include "srslte/common/byte_buffer.h" -#include "srslte/common/common.h" -#include "srslte/config.h" -#include "srslte/srslog/srslog.h" +#include "srsran/common/byte_buffer.h" +#include "srsran/common/common.h" +#include "srsran/config.h" +#include "srsran/srslog/srslog.h" #include #include #include -namespace srslte { +namespace srsran { class mac_sch_pdu_nr; @@ -119,7 +119,7 @@ public: void init_rx(bool ulsch_ = false); // Add SDU or CEs to PDU - // All functions will return SRSLTE_SUCCESS on success, and SRSLE_ERROR otherwise + // All functions will return SRSRAN_SUCCESS on success, and SRSLE_ERROR otherwise uint32_t add_sdu(const uint32_t lcid_, const uint8_t* payload_, const uint32_t len_); uint32_t add_crnti_ce(const uint16_t crnti_); uint32_t add_se_phr_ce(const uint8_t phr_, const uint8_t pcmax_); @@ -141,6 +141,6 @@ private: srslog::basic_logger& logger; }; -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_MAC_SCH_PDU_NR_H +#endif // SRSRAN_MAC_SCH_PDU_NR_H diff --git a/lib/include/srslte/mac/pdu.h b/lib/include/srsran/mac/pdu.h similarity index 97% rename from lib/include/srslte/mac/pdu.h rename to lib/include/srsran/mac/pdu.h index 8a7651a00..0f0a0c49e 100644 --- a/lib/include/srslte/mac/pdu.h +++ b/lib/include/srsran/mac/pdu.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,11 +10,11 @@ * */ -#ifndef SRSLTE_PDU_H -#define SRSLTE_PDU_H +#ifndef SRSRAN_PDU_H +#define SRSRAN_PDU_H -#include "srslte/common/interfaces_common.h" -#include "srslte/srslog/srslog.h" +#include "srsran/common/interfaces_common.h" +#include "srsran/srslog/srslog.h" #include #include #include @@ -23,7 +23,7 @@ /* MAC PDU Packing/Unpacking functions. Section 6 of 36.321 */ class subh; -namespace srslte { +namespace srsran { #define CE_SUBHEADER_LEN (1) @@ -233,7 +233,7 @@ public: // stop processing last subheader indicates another one but all bytes are consumed nof_subheaders = 0; logger.warning(init_ptr, pdu_len, "Corrupted MAC PDU - all bytes have been consumed (pdu_len=%d)", pdu_len); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } while (ret && (nof_subheaders + 1) < (int)max_subheaders && ((int32_t)pdu_len > (ptr - init_ptr))); @@ -244,10 +244,10 @@ public: if ((ptr - init_ptr) > (int32_t)pdu_len) { nof_subheaders = 0; logger.warning(init_ptr, pdu_len, "Corrupted MAC PDU - all bytes have been consumed (pdu_len=%d)", pdu_len); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } protected: @@ -349,7 +349,7 @@ public: void update_bsr(uint32_t buff_size[4], ul_sch_lcid format); bool set_con_res_id(uint64_t con_res_id); bool set_ta_cmd(uint8_t ta_cmd); - bool set_scell_activation_cmd(const std::array& active_scell_idxs); + bool set_scell_activation_cmd(const std::array& active_scell_idxs); bool set_phr(float phr); void set_padding(); void set_padding(uint32_t padding_len); @@ -483,6 +483,6 @@ private: } }; -} // namespace srslte +} // namespace srsran #endif // MACPDU_H diff --git a/lib/include/srslte/mac/pdu_queue.h b/lib/include/srsran/mac/pdu_queue.h similarity index 76% rename from lib/include/srslte/mac/pdu_queue.h rename to lib/include/srsran/mac/pdu_queue.h index 9a6d40639..f107f6c3f 100644 --- a/lib/include/srslte/mac/pdu_queue.h +++ b/lib/include/srsran/mac/pdu_queue.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,18 +10,18 @@ * */ -#ifndef SRSLTE_PDU_QUEUE_H -#define SRSLTE_PDU_QUEUE_H +#ifndef SRSRAN_PDU_QUEUE_H +#define SRSRAN_PDU_QUEUE_H -#include "srslte/adt/circular_buffer.h" -#include "srslte/common/block_queue.h" -#include "srslte/common/buffer_pool.h" -#include "srslte/common/timers.h" -#include "srslte/mac/pdu.h" +#include "srsran/adt/circular_buffer.h" +#include "srsran/common/block_queue.h" +#include "srsran/common/buffer_pool.h" +#include "srsran/common/timers.h" +#include "srsran/mac/pdu.h" /* Logical Channel Demultiplexing and MAC CE dissassemble */ -namespace srslte { +namespace srsran { class pdu_queue { @@ -52,7 +52,7 @@ private: uint8_t ptr[MAX_PDU_LEN]; uint32_t len; channel_t channel; -#ifdef SRSLTE_BUFFER_POOL_LOG_ENABLED +#ifdef SRSRAN_BUFFER_POOL_LOG_ENABLED char debug_name[128]; #endif @@ -65,6 +65,6 @@ private: srslog::basic_logger& logger; }; -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_PDU_QUEUE_H +#endif // SRSRAN_PDU_QUEUE_H diff --git a/lib/include/srslte/phy/agc/agc.h b/lib/include/srsran/phy/agc/agc.h similarity index 53% rename from lib/include/srslte/phy/agc/agc.h rename to lib/include/srsran/phy/agc/agc.h index ba8b70105..a321d6839 100644 --- a/lib/include/srslte/phy/agc/agc.h +++ b/lib/include/srsran/phy/agc/agc.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -19,30 +19,30 @@ * Reference: *********************************************************************************************/ -#ifndef SRSLTE_AGC_H -#define SRSLTE_AGC_H +#ifndef SRSRAN_AGC_H +#define SRSRAN_AGC_H #include #include #include -#include "srslte/config.h" +#include "srsran/config.h" -#define SRSLTE_AGC_CALLBACK(NAME) void(NAME)(void* h, float gain_db) -#define SRSLTE_AGC_DEFAULT_TARGET (0.3f) /* Average RMS target or maximum peak target*/ -#define SRSLTE_AGC_DEFAULT_BW (0.3f) /* Moving average coefficient */ -#define SRSLTE_AGC_HOLD_COUNT (20) /* Number of frames to wait after setting the gain before start measuring */ -#define SRSLTE_AGC_MIN_MEASUREMENTS (10) /* Minimum number of measurements */ -#define SRSLTE_AGC_MIN_GAIN_OFFSET (2.0f) /* Mimum of gain offset to set the radio gain */ +#define SRSRAN_AGC_CALLBACK(NAME) void(NAME)(void* h, float gain_db) +#define SRSRAN_AGC_DEFAULT_TARGET (0.3f) /* Average RMS target or maximum peak target*/ +#define SRSRAN_AGC_DEFAULT_BW (0.3f) /* Moving average coefficient */ +#define SRSRAN_AGC_HOLD_COUNT (20) /* Number of frames to wait after setting the gain before start measuring */ +#define SRSRAN_AGC_MIN_MEASUREMENTS (10) /* Minimum number of measurements */ +#define SRSRAN_AGC_MIN_GAIN_OFFSET (2.0f) /* Mimum of gain offset to set the radio gain */ -typedef enum SRSLTE_API { SRSLTE_AGC_MODE_ENERGY = 0, SRSLTE_AGC_MODE_PEAK_AMPLITUDE } srslte_agc_mode_t; +typedef enum SRSRAN_API { SRSRAN_AGC_MODE_ENERGY = 0, SRSRAN_AGC_MODE_PEAK_AMPLITUDE } srsran_agc_mode_t; /* * The AGC has been implemented using 3 states: * - init: it simply starts the process of measuring - * - measure: performs a minimum of SRSLTE_AGC_MIN_MEASUREMENTS and does not set the gain until it needs - * SRSLTE_AGC_MIN_GAIN_OFFSET dB more of gain. The gain is set in the enter hold transition. - * - hold: waits for SRSLTE_AGC_HOLD_COUNT frames as a Rx gain transition period. After this period, it enters measure + * - measure: performs a minimum of SRSRAN_AGC_MIN_MEASUREMENTS and does not set the gain until it needs + * SRSRAN_AGC_MIN_GAIN_OFFSET dB more of gain. The gain is set in the enter hold transition. + * - hold: waits for SRSRAN_AGC_HOLD_COUNT frames as a Rx gain transition period. After this period, it enters measure * state. * * FSM abstraction: @@ -54,9 +54,9 @@ typedef enum SRSLTE_API { SRSLTE_AGC_MODE_ENERGY = 0, SRSLTE_AGC_MODE_PEAK_AMPLI * +-------------------------+ */ -typedef enum { SRSLTE_AGC_STATE_INIT = 0, SRSLTE_AGC_STATE_MEASURE, SRSLTE_AGC_STATE_HOLD } srslte_agc_state_t; +typedef enum { SRSRAN_AGC_STATE_INIT = 0, SRSRAN_AGC_STATE_MEASURE, SRSRAN_AGC_STATE_HOLD } srsran_agc_state_t; -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { float bandwidth; float gain_db; float gain_offset_db; @@ -66,34 +66,34 @@ typedef struct SRSLTE_API { float y_out; bool isfirst; void* uhd_handler; - SRSLTE_AGC_CALLBACK(*set_gain_callback); - srslte_agc_mode_t mode; + SRSRAN_AGC_CALLBACK(*set_gain_callback); + srsran_agc_mode_t mode; float target; uint32_t nof_frames; uint32_t frame_cnt; uint32_t hold_cnt; float* y_tmp; - srslte_agc_state_t state; -} srslte_agc_t; + srsran_agc_state_t state; +} srsran_agc_t; -SRSLTE_API int srslte_agc_init_acc(srslte_agc_t* q, srslte_agc_mode_t mode, uint32_t nof_frames); +SRSRAN_API int srsran_agc_init_acc(srsran_agc_t* q, srsran_agc_mode_t mode, uint32_t nof_frames); -SRSLTE_API int srslte_agc_init_uhd(srslte_agc_t* q, - srslte_agc_mode_t mode, +SRSRAN_API int srsran_agc_init_uhd(srsran_agc_t* q, + srsran_agc_mode_t mode, uint32_t nof_frames, - SRSLTE_AGC_CALLBACK(set_gain_callback), + SRSRAN_AGC_CALLBACK(set_gain_callback), void* uhd_handler); -SRSLTE_API void srslte_agc_free(srslte_agc_t* q); +SRSRAN_API void srsran_agc_free(srsran_agc_t* q); -SRSLTE_API void srslte_agc_reset(srslte_agc_t* q); +SRSRAN_API void srsran_agc_reset(srsran_agc_t* q); -SRSLTE_API void srslte_agc_set_gain_range(srslte_agc_t* q, float min_gain_db, float max_gain_db); +SRSRAN_API void srsran_agc_set_gain_range(srsran_agc_t* q, float min_gain_db, float max_gain_db); -SRSLTE_API float srslte_agc_get_gain(srslte_agc_t* q); +SRSRAN_API float srsran_agc_get_gain(srsran_agc_t* q); -SRSLTE_API void srslte_agc_set_gain(srslte_agc_t* q, float init_gain_value_db); +SRSRAN_API void srsran_agc_set_gain(srsran_agc_t* q, float init_gain_value_db); -SRSLTE_API void srslte_agc_process(srslte_agc_t* q, cf_t* signal, uint32_t len); +SRSRAN_API void srsran_agc_process(srsran_agc_t* q, cf_t* signal, uint32_t len); -#endif // SRSLTE_AGC_H +#endif // SRSRAN_AGC_H diff --git a/lib/include/srslte/phy/ch_estimation/chest_common.h b/lib/include/srsran/phy/ch_estimation/chest_common.h similarity index 50% rename from lib/include/srslte/phy/ch_estimation/chest_common.h rename to lib/include/srsran/phy/ch_estimation/chest_common.h index 7b1a911e3..6f762ffeb 100644 --- a/lib/include/srslte/phy/ch_estimation/chest_common.h +++ b/lib/include/srsran/phy/ch_estimation/chest_common.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,33 +10,33 @@ * */ -#ifndef SRSLTE_CHEST_COMMON_H -#define SRSLTE_CHEST_COMMON_H +#ifndef SRSRAN_CHEST_COMMON_H +#define SRSRAN_CHEST_COMMON_H -#include "srslte/config.h" +#include "srsran/config.h" #include -#define SRSLTE_CHEST_MAX_SMOOTH_FIL_LEN 64 +#define SRSRAN_CHEST_MAX_SMOOTH_FIL_LEN 64 -typedef enum SRSLTE_API { - SRSLTE_CHEST_FILTER_GAUSS = 0, - SRSLTE_CHEST_FILTER_TRIANGLE, - SRSLTE_CHEST_FILTER_NONE -} srslte_chest_filter_t; +typedef enum SRSRAN_API { + SRSRAN_CHEST_FILTER_GAUSS = 0, + SRSRAN_CHEST_FILTER_TRIANGLE, + SRSRAN_CHEST_FILTER_NONE +} srsran_chest_filter_t; -SRSLTE_API void srslte_chest_average_pilots(cf_t* input, +SRSRAN_API void srsran_chest_average_pilots(cf_t* input, cf_t* output, float* filter, uint32_t nof_ref, uint32_t nof_symbols, uint32_t filter_len); -SRSLTE_API uint32_t srslte_chest_set_smooth_filter3_coeff(float* smooth_filter, float w); +SRSRAN_API uint32_t srsran_chest_set_smooth_filter3_coeff(float* smooth_filter, float w); -SRSLTE_API float srslte_chest_estimate_noise_pilots(cf_t* noisy, cf_t* noiseless, cf_t* noise_vec, uint32_t nof_pilots); +SRSRAN_API float srsran_chest_estimate_noise_pilots(cf_t* noisy, cf_t* noiseless, cf_t* noise_vec, uint32_t nof_pilots); -SRSLTE_API uint32_t srslte_chest_set_triangle_filter(float* fil, int filter_len); +SRSRAN_API uint32_t srsran_chest_set_triangle_filter(float* fil, int filter_len); -SRSLTE_API uint32_t srslte_chest_set_smooth_filter_gauss(float* filter, uint32_t order, float std_dev); +SRSRAN_API uint32_t srsran_chest_set_smooth_filter_gauss(float* filter, uint32_t order, float std_dev); -#endif // SRSLTE_CHEST_COMMON_H +#endif // SRSRAN_CHEST_COMMON_H diff --git a/lib/include/srsran/phy/ch_estimation/chest_dl.h b/lib/include/srsran/phy/ch_estimation/chest_dl.h new file mode 100644 index 000000000..d77e0b824 --- /dev/null +++ b/lib/include/srsran/phy/ch_estimation/chest_dl.h @@ -0,0 +1,163 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +/********************************************************************************************** + * File: chest_dl.h + * + * Description: 3GPP LTE Downlink channel estimator and equalizer. + * Estimates the channel in the resource elements transmitting references and + * interpolates for the rest of the resource grid. + * The equalizer uses the channel estimates to produce an estimation of the + * transmitted symbol. + * This object depends on the srsran_refsignal_t object for creating the LTE + * CSR signal. + * + * Reference: + *********************************************************************************************/ + +#ifndef SRSRAN_CHEST_DL_H +#define SRSRAN_CHEST_DL_H + +#include + +#include "srsran/config.h" + +#include "srsran/phy/ch_estimation/chest_common.h" +#include "srsran/phy/ch_estimation/refsignal_dl.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/resampling/interp.h" +#include "srsran/phy/sync/pss.h" +#include "wiener_dl.h" + +typedef struct SRSRAN_API { + cf_t* ce[SRSRAN_MAX_PORTS][SRSRAN_MAX_PORTS]; + uint32_t nof_re; + float noise_estimate; + float noise_estimate_dbm; + float snr_db; + float snr_ant_port_db[SRSRAN_MAX_PORTS][SRSRAN_MAX_PORTS]; + float rsrp; + float rsrp_dbm; + float rsrp_neigh; + float rsrp_port_dbm[SRSRAN_MAX_PORTS]; + float rsrp_ant_port_dbm[SRSRAN_MAX_PORTS][SRSRAN_MAX_PORTS]; + float rsrq; + float rsrq_db; + float rsrq_ant_port_db[SRSRAN_MAX_PORTS][SRSRAN_MAX_PORTS]; + float rssi_dbm; + float cfo; + float sync_error; +} srsran_chest_dl_res_t; + +// Noise estimation algorithm +typedef enum SRSRAN_API { + SRSRAN_NOISE_ALG_REFS = 0, + SRSRAN_NOISE_ALG_PSS, + SRSRAN_NOISE_ALG_EMPTY, +} srsran_chest_dl_noise_alg_t; + +// Channel estimator algorithm +typedef enum SRSRAN_API { + SRSRAN_ESTIMATOR_ALG_AVERAGE = 0, + SRSRAN_ESTIMATOR_ALG_INTERPOLATE, + SRSRAN_ESTIMATOR_ALG_WIENER, +} srsran_chest_dl_estimator_alg_t; + +typedef struct SRSRAN_API { + srsran_cell_t cell; + uint32_t nof_rx_antennas; + + srsran_refsignal_t csr_refs; + srsran_refsignal_t** mbsfn_refs; + + srsran_wiener_dl_t* wiener_dl; + + cf_t* pilot_estimates; + cf_t* pilot_estimates_average; + cf_t* pilot_recv_signal; + cf_t* tmp_noise; + cf_t* tmp_cfo_estimate; + +#ifdef FREQ_SEL_SNR + float snr_vector[12000]; + float pilot_power[12000]; +#endif + + srsran_interp_linsrsran_vec_t srsran_interp_linvec; + srsran_interp_lin_t srsran_interp_lin; + srsran_interp_lin_t srsran_interp_lin_3; + srsran_interp_lin_t srsran_interp_lin_mbsfn; + + float rssi[SRSRAN_MAX_PORTS][SRSRAN_MAX_PORTS]; + float rsrp[SRSRAN_MAX_PORTS][SRSRAN_MAX_PORTS]; + float rsrp_corr[SRSRAN_MAX_PORTS][SRSRAN_MAX_PORTS]; + float noise_estimate[SRSRAN_MAX_PORTS][SRSRAN_MAX_PORTS]; + float sync_err[SRSRAN_MAX_PORTS][SRSRAN_MAX_PORTS]; + float cfo; + + /* Use PSS for noise estimation in LS linear interpolation mode */ + cf_t pss_signal[SRSRAN_PSS_LEN]; + cf_t tmp_pss[SRSRAN_PSS_LEN]; + cf_t tmp_pss_noisy[SRSRAN_PSS_LEN]; + +} srsran_chest_dl_t; + +typedef struct SRSRAN_API { + srsran_chest_dl_estimator_alg_t estimator_alg; + srsran_chest_dl_noise_alg_t noise_alg; + + srsran_chest_filter_t filter_type; + float filter_coef[2]; + + uint16_t mbsfn_area_id; + bool rsrp_neighbour; + bool cfo_estimate_enable; + uint32_t cfo_estimate_sf_mask; + bool sync_error_enable; + +} srsran_chest_dl_cfg_t; + +SRSRAN_API int srsran_chest_dl_init(srsran_chest_dl_t* q, uint32_t max_prb, uint32_t nof_rx_antennas); + +SRSRAN_API void srsran_chest_dl_free(srsran_chest_dl_t* q); + +SRSRAN_API int srsran_chest_dl_res_init(srsran_chest_dl_res_t* q, uint32_t max_prb); +SRSRAN_API int srsran_chest_dl_res_init_re(srsran_chest_dl_res_t* q, uint32_t nof_re); + +SRSRAN_API void srsran_chest_dl_res_set_identity(srsran_chest_dl_res_t* q); + +SRSRAN_API void srsran_chest_dl_res_set_ones(srsran_chest_dl_res_t* q); + +SRSRAN_API void srsran_chest_dl_res_free(srsran_chest_dl_res_t* q); + +/* These functions change the internal object state */ + +SRSRAN_API int srsran_chest_dl_set_mbsfn_area_id(srsran_chest_dl_t* q, uint16_t mbsfn_area_id); + +SRSRAN_API int srsran_chest_dl_set_cell(srsran_chest_dl_t* q, srsran_cell_t cell); + +/* These functions do not change the internal state */ + +SRSRAN_API int srsran_chest_dl_estimate(srsran_chest_dl_t* q, + srsran_dl_sf_cfg_t* sf, + cf_t* input[SRSRAN_MAX_PORTS], + srsran_chest_dl_res_t* res); + +SRSRAN_API int srsran_chest_dl_estimate_cfg(srsran_chest_dl_t* q, + srsran_dl_sf_cfg_t* sf, + srsran_chest_dl_cfg_t* cfg, + cf_t* input[SRSRAN_MAX_PORTS], + srsran_chest_dl_res_t* res); + +SRSRAN_API srsran_chest_dl_estimator_alg_t srsran_chest_dl_str2estimator_alg(const char* str); + +#endif // SRSRAN_CHEST_DL_H diff --git a/lib/include/srsran/phy/ch_estimation/chest_dl_nbiot.h b/lib/include/srsran/phy/ch_estimation/chest_dl_nbiot.h new file mode 100644 index 000000000..706826e8d --- /dev/null +++ b/lib/include/srsran/phy/ch_estimation/chest_dl_nbiot.h @@ -0,0 +1,88 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +#ifndef SRSRAN_CHEST_DL_NBIOT_H +#define SRSRAN_CHEST_DL_NBIOT_H + +#include + +#include "srsran/config.h" + +#include "srsran/phy/ch_estimation/chest_common.h" +#include "srsran/phy/ch_estimation/chest_dl.h" +#include "srsran/phy/ch_estimation/refsignal_dl_nbiot.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/resampling/interp.h" + +/*! \brief Downlink channel estimation for NB-IoT + * + * Estimates the channel in the resource elements transmitting references and + * interpolates for the rest of the resource grid. + * The equalizer uses the channel estimates to produce an estimation of the + * transmitted symbol. + * This object depends on the srsran_refsignal_t object for creating the LTE CSR signal. + */ +typedef struct { + srsran_nbiot_cell_t cell; + srsran_refsignal_dl_nbiot_t nrs_signal; + + cf_t* pilot_estimates; + cf_t* pilot_estimates_average; + cf_t* pilot_recv_signal; + cf_t* tmp_noise; + + uint32_t smooth_filter_len; + float smooth_filter[SRSRAN_CHEST_MAX_SMOOTH_FIL_LEN]; + + srsran_interp_linsrsran_vec_t srsran_interp_linvec; + srsran_interp_lin_t srsran_interp_lin; + + float rssi[SRSRAN_MAX_PORTS]; + float rsrp[SRSRAN_MAX_PORTS]; + float noise_estimate[SRSRAN_MAX_PORTS]; + + srsran_chest_dl_noise_alg_t noise_alg; + +} srsran_chest_dl_nbiot_t; + +SRSRAN_API int srsran_chest_dl_nbiot_init(srsran_chest_dl_nbiot_t* q, uint32_t max_prb); + +SRSRAN_API void srsran_chest_dl_nbiot_free(srsran_chest_dl_nbiot_t* q); + +SRSRAN_API int srsran_chest_dl_nbiot_set_cell(srsran_chest_dl_nbiot_t* q, srsran_nbiot_cell_t cell); + +SRSRAN_API void srsran_chest_dl_nbiot_set_smooth_filter(srsran_chest_dl_nbiot_t* q, float* filter, uint32_t filter_len); + +SRSRAN_API void srsran_chest_dl_nbiot_set_smooth_filter3_coeff(srsran_chest_dl_nbiot_t* q, float w); + +SRSRAN_API void srsran_chest_dl_nbiot_set_noise_alg(srsran_chest_dl_nbiot_t* q, + srsran_chest_dl_noise_alg_t noise_estimation_alg); + +SRSRAN_API int srsran_chest_dl_nbiot_estimate(srsran_chest_dl_nbiot_t* q, cf_t* input, cf_t** ce, uint32_t sf_idx); + +SRSRAN_API int srsran_chest_dl_nbiot_estimate_port(srsran_chest_dl_nbiot_t* q, + cf_t* input, + cf_t* ce, + uint32_t sf_idx, + uint32_t port_id); + +SRSRAN_API float srsran_chest_dl_nbiot_get_noise_estimate(srsran_chest_dl_nbiot_t* q); + +SRSRAN_API float srsran_chest_dl_nbiot_get_snr(srsran_chest_dl_nbiot_t* q); + +SRSRAN_API float srsran_chest_dl_nbiot_get_rssi(srsran_chest_dl_nbiot_t* q); + +SRSRAN_API float srsran_chest_dl_nbiot_get_rsrq(srsran_chest_dl_nbiot_t* q); + +SRSRAN_API float srsran_chest_dl_nbiot_get_rsrp(srsran_chest_dl_nbiot_t* q); + +#endif // SRSRAN_CHEST_DL_NBIOT_H diff --git a/lib/include/srsran/phy/ch_estimation/chest_sl.h b/lib/include/srsran/phy/ch_estimation/chest_sl.h new file mode 100644 index 000000000..a8c87ac52 --- /dev/null +++ b/lib/include/srsran/phy/ch_estimation/chest_sl.h @@ -0,0 +1,106 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +#ifndef SRSRAN_CHEST_SL_H +#define SRSRAN_CHEST_SL_H + +#include + +#include "srsran/phy/common/phy_common_sl.h" +#include "srsran/phy/resampling/interp.h" + +#define SRSRAN_SL_N_RU_SEQ (30) +#define SRSRAN_SL_MAX_DMRS_SYMB (4) +#define SRSRAN_SL_DEFAULT_NOF_DMRS_CYCLIC_SHIFTS (1) +#define SRSRAN_SL_MAX_PSCCH_NOF_DMRS_CYCLIC_SHIFTS (4) + +// Base Sequence Number - always 0 for sidelink: 3GPP TS 36.211 version 15.6.0 Release 15 Sec. 5.5.1.4 +#define SRSRAN_SL_BASE_SEQUENCE_NUMBER 0 +#define SRSRAN_SL_MAX_DMRS_PERIOD_LENGTH 320 + +typedef struct SRSRAN_API { + uint32_t prb_start_idx; // PRB start idx to map RE from RIV + uint32_t nof_prb; // PSSCH nof_prb, Length of continuous PRB to map RE (in the pool) from RIV + uint32_t N_x_id; + uint32_t sf_idx; // PSSCH sf_idx + uint32_t cyclic_shift; +} srsran_chest_sl_cfg_t; + +typedef struct SRSRAN_API { + srsran_sl_channels_t channel; + srsran_cell_sl_t cell; + srsran_sl_comm_resource_pool_t sl_comm_resource_pool; + srsran_chest_sl_cfg_t chest_sl_cfg; + + uint32_t sf_n_re; + + uint32_t M_sc_rs; + int8_t nof_dmrs_symbols; + + // Orthogonal Sequence (W) Transmission Mode 1, 2 and PSBCH + int8_t w[SRSRAN_SL_MAX_DMRS_SYMB]; + + // Cyclic Shift Values + int8_t n_CS[SRSRAN_SL_MAX_DMRS_SYMB]; + + // Reference Signal Cyclic Shift + float alpha[SRSRAN_SL_MAX_DMRS_SYMB]; + + // Group Hopping Flag + uint32_t* f_gh_pattern; + + cf_t* r_sequence[SRSRAN_SL_MAX_DMRS_SYMB][SRSRAN_SL_MAX_PSCCH_NOF_DMRS_CYCLIC_SHIFTS]; + + cf_t* r_sequence_rx[SRSRAN_SL_MAX_DMRS_SYMB]; + + cf_t* ce; + cf_t* ce_average; + cf_t* noise_tmp; + float noise_estimated; + + srsran_interp_linsrsran_vec_t lin_vec_sl; + + bool sync_error_enable; + bool rsrp_enable; + float sync_err; + float rsrp_corr; + +} srsran_chest_sl_t; + +SRSRAN_API int srsran_chest_sl_init(srsran_chest_sl_t* q, + srsran_sl_channels_t channel, + srsran_cell_sl_t cell, + srsran_sl_comm_resource_pool_t sl_comm_resource_pool); + +SRSRAN_API int srsran_chest_sl_set_cell(srsran_chest_sl_t* q, srsran_cell_sl_t cell); + +SRSRAN_API int srsran_chest_sl_set_cfg(srsran_chest_sl_t* q, srsran_chest_sl_cfg_t chest_sl_cfg); + +SRSRAN_API float srsran_chest_sl_get_sync_error(srsran_chest_sl_t* q); + +SRSRAN_API float srsran_chest_sl_estimate_noise(srsran_chest_sl_t* q); + +SRSRAN_API float srsran_chest_sl_get_rsrp(srsran_chest_sl_t* q); + +SRSRAN_API int srsran_chest_sl_put_dmrs(srsran_chest_sl_t* q, cf_t* sf_buffer); + +SRSRAN_API int srsran_chest_sl_get_dmrs(srsran_chest_sl_t* q, cf_t* sf_buffer, cf_t** dmrs_received); + +SRSRAN_API void srsran_chest_sl_ls_estimate(srsran_chest_sl_t* q, cf_t* sf_buffer); + +SRSRAN_API void srsran_chest_sl_ls_equalize(srsran_chest_sl_t* q, cf_t* sf_buffer, cf_t* equalized_sf_buffer); + +SRSRAN_API void srsran_chest_sl_ls_estimate_equalize(srsran_chest_sl_t* q, cf_t* sf_buffer, cf_t* equalized_sf_buffer); + +SRSRAN_API void srsran_chest_sl_free(srsran_chest_sl_t* q); + +#endif \ No newline at end of file diff --git a/lib/include/srsran/phy/ch_estimation/chest_ul.h b/lib/include/srsran/phy/ch_estimation/chest_ul.h new file mode 100644 index 000000000..ade25ea34 --- /dev/null +++ b/lib/include/srsran/phy/ch_estimation/chest_ul.h @@ -0,0 +1,116 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +/********************************************************************************************** + * File: chest_ul.h + * + * Description: 3GPP LTE Uplink channel estimator and equalizer. + * Estimates the channel in the resource elements transmitting references and + * interpolates for the rest of the resource grid. + * The equalizer uses the channel estimates to produce an estimation of the + * transmitted symbol. + * + * Reference: + *********************************************************************************************/ + +#ifndef SRSRAN_CHEST_UL_H +#define SRSRAN_CHEST_UL_H + +#include + +#include "srsran/config.h" + +#include "srsran/phy/ch_estimation/chest_common.h" +#include "srsran/phy/ch_estimation/refsignal_ul.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/phch/pucch_cfg.h" +#include "srsran/phy/phch/pusch_cfg.h" +#include "srsran/phy/resampling/interp.h" + +typedef struct SRSRAN_API { + cf_t* ce; + uint32_t nof_re; + float noise_estimate; + float noise_estimate_dbm; + float rsrp; + float rsrp_dBfs; + float epre; + float epre_dBfs; + float snr; + float snr_db; + float cfo_hz; + float ta_us; +} srsran_chest_ul_res_t; + +typedef struct { + srsran_cell_t cell; + + srsran_refsignal_ul_t dmrs_signal; + srsran_refsignal_ul_dmrs_pregen_t dmrs_pregen; + bool dmrs_signal_configured; + + srsran_refsignal_srs_pregen_t srs_pregen; + bool srs_signal_configured; + + cf_t* pilot_estimates; + cf_t* pilot_estimates_tmp[4]; + cf_t* pilot_recv_signal; + cf_t* pilot_known_signal; + cf_t* tmp_noise; + +#ifdef FREQ_SEL_SNR + float snr_vector[12000]; + float pilot_power[12000]; +#endif + uint32_t smooth_filter_len; + float smooth_filter[SRSRAN_CHEST_MAX_SMOOTH_FIL_LEN]; + + srsran_interp_linsrsran_vec_t srsran_interp_linvec; + +} srsran_chest_ul_t; + +SRSRAN_API int srsran_chest_ul_init(srsran_chest_ul_t* q, uint32_t max_prb); + +SRSRAN_API void srsran_chest_ul_free(srsran_chest_ul_t* q); + +SRSRAN_API int srsran_chest_ul_res_init(srsran_chest_ul_res_t* q, uint32_t max_prb); + +SRSRAN_API void srsran_chest_ul_res_set_identity(srsran_chest_ul_res_t* q); + +SRSRAN_API void srsran_chest_ul_res_free(srsran_chest_ul_res_t* q); + +SRSRAN_API int srsran_chest_ul_set_cell(srsran_chest_ul_t* q, srsran_cell_t cell); + +SRSRAN_API void srsran_chest_ul_pregen(srsran_chest_ul_t* q, + srsran_refsignal_dmrs_pusch_cfg_t* cfg, + srsran_refsignal_srs_cfg_t* srs_cfg); + +SRSRAN_API int srsran_chest_ul_estimate_pusch(srsran_chest_ul_t* q, + srsran_ul_sf_cfg_t* sf, + srsran_pusch_cfg_t* cfg, + cf_t* input, + srsran_chest_ul_res_t* res); + +SRSRAN_API int srsran_chest_ul_estimate_pucch(srsran_chest_ul_t* q, + srsran_ul_sf_cfg_t* sf, + srsran_pucch_cfg_t* cfg, + cf_t* input, + srsran_chest_ul_res_t* res); + +SRSRAN_API int srsran_chest_ul_estimate_srs(srsran_chest_ul_t* q, + srsran_ul_sf_cfg_t* sf, + srsran_refsignal_srs_cfg_t* cfg, + srsran_refsignal_dmrs_pusch_cfg_t* pusch_cfg, + cf_t* input, + srsran_chest_ul_res_t* res); + +#endif // SRSRAN_CHEST_UL_H diff --git a/lib/include/srsran/phy/ch_estimation/csi_rs.h b/lib/include/srsran/phy/ch_estimation/csi_rs.h new file mode 100644 index 000000000..ab7219dd3 --- /dev/null +++ b/lib/include/srsran/phy/ch_estimation/csi_rs.h @@ -0,0 +1,124 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +#ifndef SRSRAN_CSI_RS_H_ +#define SRSRAN_CSI_RS_H_ + +#include "srsran/config.h" +#include "srsran/phy/common/phy_common_nr.h" +#include +#include +#include + +#define SRSRAN_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_ROW1 4 +#define SRSRAN_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_ROW2 12 +#define SRSRAN_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_ROW4 3 +#define SRSRAN_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_OTHER 6 +#define SRSRAN_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_MAX 12 + +typedef enum SRSRAN_API { + srsran_csi_rs_resource_mapping_row_1 = 0, + srsran_csi_rs_resource_mapping_row_2, + srsran_csi_rs_resource_mapping_row_4, + srsran_csi_rs_resource_mapping_row_other, +} srsran_csi_rs_resource_mapping_row_t; + +typedef enum SRSRAN_API { + srsran_csi_rs_resource_mapping_density_three = 0, + srsran_csi_rs_resource_mapping_density_dot5_even, + srsran_csi_rs_resource_mapping_density_dot5_odd, + srsran_csi_rs_resource_mapping_density_one, + srsran_csi_rs_resource_mapping_density_spare +} srsran_csi_rs_density_t; + +typedef enum SRSRAN_API { + srsran_csi_rs_cdm_nocdm = 0, + srsran_csi_rs_cdm_fd_cdm2, + srsran_csi_rs_cdm_cdm4_fd2_td2, + srsran_csi_rs_cdm_cdm8_fd2_td4 +} srsran_csi_rs_cdm_t; + +/** + * @brief Contains CSI-FrequencyOccupation flattened configuration + */ +typedef struct SRSRAN_API { + uint32_t start_rb; ///< PRB where this CSI resource starts in relation to common resource block #0 (CRB#0) on the + ///< common resource block grid. Only multiples of 4 are allowed (0, 4, ..., 274) + + uint32_t nof_rb; ///< Number of PRBs across which this CSI resource spans. Only multiples of 4 are allowed. The + ///< smallest configurable number is the minimum of 24 and the width of the associated BWP. If the + ///< configured value is larger than the width of the corresponding BWP, the UE shall assume that the + ///< actual CSI-RS bandwidth is equal to the width of the BWP. +} srsran_csi_rs_freq_occupation_t; + +/** + * @brief Contains CSI-ResourcePeriodicityAndOffset flattened configuration + */ +typedef struct SRSRAN_API { + uint32_t period; // 4,5,8,10,16,20,32,40,64,80,160,320,640 + uint32_t offset; // 0..period-1 +} srsran_csi_rs_period_and_offset_t; + +/** + * @brief Contains CSI-RS-ResourceMapping flattened configuration + */ +typedef struct SRSRAN_API { + srsran_csi_rs_resource_mapping_row_t row; + bool frequency_domain_alloc[SRSRAN_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_MAX]; + uint32_t ports; // 1, 2, 4, 8, 12, 16, 24, 32 + uint32_t first_symbol_idx; // 0..13 + uint32_t first_symbol_idx2; // 2..12 (set to 0 for disabled) + srsran_csi_rs_cdm_t cdm; + srsran_csi_rs_density_t density; + srsran_csi_rs_freq_occupation_t freq_band; +} srsran_csi_rs_resource_mapping_t; + +/** + * @brief Contains NZP-CSI-RS-Resource flattened configuration + */ +typedef struct SRSRAN_API { + srsran_csi_rs_resource_mapping_t resource_mapping; + + float power_control_offset; // -8..15 dB + float power_control_offset_ss; // -3, 0, 3, 6 dB + + uint32_t scrambling_id; // 0..1023 + + srsran_csi_rs_period_and_offset_t periodicity; + +} srsran_csi_rs_nzp_resource_t; + +SRSRAN_API int srsran_csi_rs_nzp_put(const srsran_carrier_nr_t* carrier, + const srsran_slot_cfg_t* slot_cfg, + const srsran_csi_rs_nzp_resource_t* resource, + cf_t* grid); + +typedef struct SRSRAN_API { + float rsrp; + float rsrp_dB; + float epre; + float epre_dB; + float n0; + float n0_dB; + float snr_dB; + uint32_t nof_re; +} srsran_csi_rs_measure_t; + +SRSRAN_API int srsran_csi_rs_nzp_measure(const srsran_carrier_nr_t* carrier, + const srsran_slot_cfg_t* slot_cfg, + const srsran_csi_rs_nzp_resource_t* resource, + const cf_t* grid, + srsran_csi_rs_measure_t* measure); + +SRSRAN_API uint32_t srsran_csi_rs_measure_info(const srsran_csi_rs_measure_t* measure, char* str, uint32_t str_len); + +#endif // SRSRAN_CSI_RS_H_ diff --git a/lib/include/srslte/phy/ch_estimation/dmrs_pdcch.h b/lib/include/srsran/phy/ch_estimation/dmrs_pdcch.h similarity index 63% rename from lib/include/srslte/phy/ch_estimation/dmrs_pdcch.h rename to lib/include/srsran/phy/ch_estimation/dmrs_pdcch.h index a45cc98ef..f9cf5b45d 100644 --- a/lib/include/srslte/phy/ch_estimation/dmrs_pdcch.h +++ b/lib/include/srsran/phy/ch_estimation/dmrs_pdcch.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,48 +10,48 @@ * */ -#ifndef SRSLTE_DMRS_PDCCH_H -#define SRSLTE_DMRS_PDCCH_H +#ifndef SRSRAN_DMRS_PDCCH_H +#define SRSRAN_DMRS_PDCCH_H -#include "srslte/phy/common/phy_common_nr.h" -#include "srslte/phy/phch/dci_nr.h" -#include "srslte/phy/resampling/interp.h" -#include "srslte/phy/resampling/resampler.h" +#include "srsran/phy/common/phy_common_nr.h" +#include "srsran/phy/phch/dci_nr.h" +#include "srsran/phy/resampling/interp.h" +#include "srsran/phy/resampling/resampler.h" /** * @brief Puts in the resource grid the DeModulation Reference Signals for decoding PDCCH. * * @remark: Implemented as specified by TS 38.211 V15.8.0 Section 7.1.4.3 * - * @attention it expects sf_symbols to be size SRSLTE_SLOT_LEN_RE_NR(cfg->carrier.nof_prb) + * @attention it expects sf_symbols to be size SRSRAN_SLOT_LEN_RE_NR(cfg->carrier.nof_prb) * * @param[in] carrier Provides carrier configuration * @param[in] coreset Provides higher layer CORSET configuration * @param[in] slot_cfg Provides DL slot configuration * @param[in] dci_location Provides DCI location * @param sf_symbols is the resource grid where the DMRS resource elements will be written - * @return SRSLTE_SUCCESS if the configurations are valid, otherwise it returns an SRSLTE_ERROR code + * @return SRSRAN_SUCCESS if the configurations are valid, otherwise it returns an SRSRAN_ERROR code */ -SRSLTE_API int srslte_dmrs_pdcch_put(const srslte_carrier_nr_t* carrier, - const srslte_coreset_t* coreset, - const srslte_slot_cfg_t* slot_cfg, - const srslte_dci_location_t* dci_location, +SRSRAN_API int srsran_dmrs_pdcch_put(const srsran_carrier_nr_t* carrier, + const srsran_coreset_t* coreset, + const srsran_slot_cfg_t* slot_cfg, + const srsran_dci_location_t* dci_location, cf_t* sf_symbols); /** * @brief PDCCH DMRS channel estimator object * - * @see srslte_dmrs_pdcch_estimator_init - * @see srslte_dmrs_pdcch_estimator_free - * @see srslte_dmrs_pdcch_estimator_estimate - * @see srslte_dmrs_pdcch_estimator_measure + * @see srsran_dmrs_pdcch_estimator_init + * @see srsran_dmrs_pdcch_estimator_free + * @see srsran_dmrs_pdcch_estimator_estimate + * @see srsran_dmrs_pdcch_estimator_measure */ -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { /// Current estimator carrier configuration - srslte_carrier_nr_t carrier; + srsran_carrier_nr_t carrier; /// Current estimator CORESET configuration - srslte_coreset_t coreset; + srsran_coreset_t coreset; /// Stores the current CORESET bandwidth in PRB uint32_t coreset_bw; @@ -60,11 +60,11 @@ typedef struct SRSLTE_API { uint32_t coreset_sz; /// Object for interpolating, it shall be initialised only once - srslte_interp_lin_t interpolator; + srsran_interp_lin_t interpolator; /// Pilots least square estimates, one vector for each possible symbol. Since there are one pilot every 4 sub-carriers /// , each vector is three times the CORESEt band-width - cf_t* lse[SRSLTE_CORESET_DURATION_MAX]; + cf_t* lse[SRSRAN_CORESET_DURATION_MAX]; /// Channel estimates, size coreset_sz cf_t* ce; @@ -72,7 +72,7 @@ typedef struct SRSLTE_API { /// Frequency domain smoothing filter float* filter; uint32_t filter_len; -} srslte_dmrs_pdcch_estimator_t; +} srsran_dmrs_pdcch_estimator_t; /** * @brief Initialises the PDCCH DMRS channel estimator from a given carrier and CORESET configuration @@ -84,17 +84,17 @@ typedef struct SRSLTE_API { * @param[in,out] q provides PDCCH DMRS estimator object * @param[in] carrier Provides carrier configuration * @param[in] coreset Provides higher layer CORSET configuration - * @return SRSLTE_SUCCESS if the configurations are valid, otherwise it returns an SRSLTE_ERROR code + * @return SRSRAN_SUCCESS if the configurations are valid, otherwise it returns an SRSRAN_ERROR code */ -SRSLTE_API int srslte_dmrs_pdcch_estimator_init(srslte_dmrs_pdcch_estimator_t* q, - const srslte_carrier_nr_t* carrier, - const srslte_coreset_t* coreset); +SRSRAN_API int srsran_dmrs_pdcch_estimator_init(srsran_dmrs_pdcch_estimator_t* q, + const srsran_carrier_nr_t* carrier, + const srsran_coreset_t* coreset); /** * @brief Deallocate all memory allocated by a given PDCCH DMRS estimator object * @param q provides PDCCH DMRS estimator object */ -SRSLTE_API void srslte_dmrs_pdcch_estimator_free(srslte_dmrs_pdcch_estimator_t* q); +SRSRAN_API void srsran_dmrs_pdcch_estimator_free(srsran_dmrs_pdcch_estimator_t* q); /** * @brief Estimates the configured CORESET channel from the received PDCCH's DMRS. @@ -103,22 +103,22 @@ SRSLTE_API void srslte_dmrs_pdcch_estimator_free(srslte_dmrs_pdcch_estimator_t* * CORESET in every slot. * * The channel estimate measurements are performed at PDCCH candidate level through the function - * srslte_dmrs_pdcch_estimator_measure. + * srsran_dmrs_pdcch_estimator_measure. * * @param[in,out] cfg Configuration that includes Carrier, CORESET and the Search Space * @param[in] slot_cfg Slot index in the frame * @param[in] sf_symbols Received resource grid. - * @return SRSLTE_SUCCESS if the configurations are valid, otherwise it returns an SRSLTE_ERROR code + * @return SRSRAN_SUCCESS if the configurations are valid, otherwise it returns an SRSRAN_ERROR code */ -SRSLTE_API int -srslte_dmrs_pdcch_estimate(srslte_dmrs_pdcch_estimator_t* q, const srslte_slot_cfg_t* slot_cfg, const cf_t* sf_symbols); +SRSRAN_API int +srsran_dmrs_pdcch_estimate(srsran_dmrs_pdcch_estimator_t* q, const srsran_slot_cfg_t* slot_cfg, const cf_t* sf_symbols); /** * @brief PDSCH DMRS measurement results * - * @see srslte_dmrs_pdcch_estimator_measure + * @see srsran_dmrs_pdcch_estimator_measure */ -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { /// Linear reference signal received power (RSRP). Measure correlation float rsrp; float rsrp_dBfs; @@ -135,19 +135,19 @@ typedef struct SRSLTE_API { /// Measure synchronization error in micro-seconds float sync_error_us; -} srslte_dmrs_pdcch_measure_t; +} srsran_dmrs_pdcch_measure_t; /** * @brief PDSCH DMRS Channel estimates structure * - * @see srslte_dmrs_pdcch_get_ce + * @see srsran_dmrs_pdcch_get_ce */ -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { /// Channel estimates, subtract 1 DMRS for every 4 RE, a maximum of L=16 and 6 PRB per CCE - cf_t ce[SRSLTE_PDCCH_MAX_RE]; + cf_t ce[SRSRAN_PDCCH_MAX_RE]; uint32_t nof_re; float noise_var; -} srslte_dmrs_pdcch_ce_t; +} srsran_dmrs_pdcch_ce_t; /** * @brief Performs PDCCH DMRS measurements of a given DCI location @@ -158,11 +158,11 @@ typedef struct SRSLTE_API { * @param[in] dci_location provides the search space * @param[in] location Provides the aggregation level and CCE resource * @param[out] measure Provides the structure for storing the channel estimate measurements - * @return SRSLTE_SUCCESS if the configurations are valid, otherwise it returns an SRSLTE_ERROR code + * @return SRSRAN_SUCCESS if the configurations are valid, otherwise it returns an SRSRAN_ERROR code */ -SRSLTE_API int srslte_dmrs_pdcch_get_measure(const srslte_dmrs_pdcch_estimator_t* q, - const srslte_dci_location_t* location, - srslte_dmrs_pdcch_measure_t* measure); +SRSRAN_API int srsran_dmrs_pdcch_get_measure(const srsran_dmrs_pdcch_estimator_t* q, + const srsran_dci_location_t* location, + srsran_dmrs_pdcch_measure_t* measure); /** * @brief Extracts PDCCH DMRS channel estimates of a given PDCCH candidate for an aggregation level @@ -172,10 +172,10 @@ SRSLTE_API int srslte_dmrs_pdcch_get_measure(const srslte_dmrs_pdcch_estimator_t * @param[in] q provides PDCCH DMRS estimator object * @param[in] location Provides the aggregation level and CCE resource * @param[out] ce Provides the structure for storing the channel estimates - * @return SRSLTE_SUCCESS if the configurations are valid, otherwise it returns an SRSLTE_ERROR code + * @return SRSRAN_SUCCESS if the configurations are valid, otherwise it returns an SRSRAN_ERROR code */ -SRSLTE_API int srslte_dmrs_pdcch_get_ce(const srslte_dmrs_pdcch_estimator_t* q, - const srslte_dci_location_t* location, - srslte_dmrs_pdcch_ce_t* ce); +SRSRAN_API int srsran_dmrs_pdcch_get_ce(const srsran_dmrs_pdcch_estimator_t* q, + const srsran_dci_location_t* location, + srsran_dmrs_pdcch_ce_t* ce); -#endif // SRSLTE_DMRS_PDCCH_H +#endif // SRSRAN_DMRS_PDCCH_H diff --git a/lib/include/srslte/phy/ch_estimation/dmrs_pucch.h b/lib/include/srsran/phy/ch_estimation/dmrs_pucch.h similarity index 58% rename from lib/include/srslte/phy/ch_estimation/dmrs_pucch.h rename to lib/include/srsran/phy/ch_estimation/dmrs_pucch.h index 629eed535..e8ef7f5d5 100644 --- a/lib/include/srslte/phy/ch_estimation/dmrs_pucch.h +++ b/lib/include/srsran/phy/ch_estimation/dmrs_pucch.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,24 +10,24 @@ * */ -#ifndef SRSLTE_DMRS_PUCCH_H -#define SRSLTE_DMRS_PUCCH_H +#ifndef SRSRAN_DMRS_PUCCH_H +#define SRSRAN_DMRS_PUCCH_H -#include "srslte/config.h" -#include "srslte/phy/ch_estimation/chest_ul.h" -#include "srslte/phy/phch/pucch_nr.h" +#include "srsran/config.h" +#include "srsran/phy/ch_estimation/chest_ul.h" +#include "srsran/phy/phch/pucch_nr.h" -#define SRSLTE_DMRS_PUCCH_FORMAT_3_4_MAX_NSYMB 4 +#define SRSRAN_DMRS_PUCCH_FORMAT_3_4_MAX_NSYMB 4 /** * @brief Computes the symbol indexes carrying DMRS for NR-PUCCH formats 3 and 4 * @remark Implements TS 38.211 Table 6.4.1.3.3.2-1: DM-RS positions for PUCCH format 3 and 4. * @param[in] resource Provides the format 3 or 4 resource * @param[out] idx Destination data for storing the symbol indexes - * @return The number of DMRS symbols if the resource is valid, SRSLTE_ERROR code otherwise + * @return The number of DMRS symbols if the resource is valid, SRSRAN_ERROR code otherwise */ -SRSLTE_API int srslte_dmrs_pucch_format_3_4_get_symbol_idx(const srslte_pucch_nr_resource_t* resource, - uint32_t idx[SRSLTE_DMRS_PUCCH_FORMAT_3_4_MAX_NSYMB]); +SRSRAN_API int srsran_dmrs_pucch_format_3_4_get_symbol_idx(const srsran_pucch_nr_resource_t* resource, + uint32_t idx[SRSRAN_DMRS_PUCCH_FORMAT_3_4_MAX_NSYMB]); /** * @brief Puts NR-PUCCH format 1 DMRS in the provided resource grid @@ -37,13 +37,13 @@ SRSLTE_API int srslte_dmrs_pucch_format_3_4_get_symbol_idx(const srslte_pucch_nr * @param[in] slot slot configuration * @param[in] resource PUCCH format 1 resource * @param[out] slot_symbols Resource grid of the given slot - * @return SRSLTE_SUCCESS if successful, SRSLTE_ERROR code otherwise + * @return SRSRAN_SUCCESS if successful, SRSRAN_ERROR code otherwise */ -SRSLTE_API int srslte_dmrs_pucch_format1_put(const srslte_pucch_nr_t* q, - const srslte_carrier_nr_t* carrier, - const srslte_pucch_nr_common_cfg_t* cfg, - const srslte_slot_cfg_t* slot, - const srslte_pucch_nr_resource_t* resource, +SRSRAN_API int srsran_dmrs_pucch_format1_put(const srsran_pucch_nr_t* q, + const srsran_carrier_nr_t* carrier, + const srsran_pucch_nr_common_cfg_t* cfg, + const srsran_slot_cfg_t* slot, + const srsran_pucch_nr_resource_t* resource, cf_t* slot_symbols); /** @@ -55,15 +55,15 @@ SRSLTE_API int srslte_dmrs_pucch_format1_put(const srslte_pucch_nr_t* * @param[in] resource PUCCH format 1 resource * @param[in] slot_symbols Resource grid of the given slot * @param[out] res UL Channel estimator result - * @return SRSLTE_SUCCESS if successful, SRSLTE_ERROR code otherwise + * @return SRSRAN_SUCCESS if successful, SRSRAN_ERROR code otherwise */ -SRSLTE_API int srslte_dmrs_pucch_format1_estimate(const srslte_pucch_nr_t* q, - const srslte_carrier_nr_t* carrier, - const srslte_pucch_nr_common_cfg_t* cfg, - const srslte_slot_cfg_t* slot, - const srslte_pucch_nr_resource_t* resource, +SRSRAN_API int srsran_dmrs_pucch_format1_estimate(const srsran_pucch_nr_t* q, + const srsran_carrier_nr_t* carrier, + const srsran_pucch_nr_common_cfg_t* cfg, + const srsran_slot_cfg_t* slot, + const srsran_pucch_nr_resource_t* resource, const cf_t* slot_symbols, - srslte_chest_ul_res_t* res); + srsran_chest_ul_res_t* res); /** * @brief Puts NR-PUCCH format 2 DMRS in the provided resource grid @@ -73,13 +73,13 @@ SRSLTE_API int srslte_dmrs_pucch_format1_estimate(const srslte_pucch_nr_t* * @param[in] slot slot configuration * @param[in] resource PUCCH format 2 resource * @param[out] slot_symbols Resource grid of the given slot - * @return SRSLTE_SUCCESS if successful, SRSLTE_ERROR code otherwise + * @return SRSRAN_SUCCESS if successful, SRSRAN_ERROR code otherwise */ -int srslte_dmrs_pucch_format2_put(const srslte_pucch_nr_t* q, - const srslte_carrier_nr_t* carrier, - const srslte_pucch_nr_common_cfg_t* cfg, - const srslte_slot_cfg_t* slot, - const srslte_pucch_nr_resource_t* resource, +int srsran_dmrs_pucch_format2_put(const srsran_pucch_nr_t* q, + const srsran_carrier_nr_t* carrier, + const srsran_pucch_nr_common_cfg_t* cfg, + const srsran_slot_cfg_t* slot, + const srsran_pucch_nr_resource_t* resource, cf_t* slot_symbols); /** @@ -91,14 +91,14 @@ int srslte_dmrs_pucch_format2_put(const srslte_pucch_nr_t* q, * @param[in] resource PUCCH format 2 resource * @param[in] slot_symbols Resource grid of the given slot * @param[out] res UL Channel estimator result - * @return SRSLTE_SUCCESS if successful, SRSLTE_ERROR code otherwise + * @return SRSRAN_SUCCESS if successful, SRSRAN_ERROR code otherwise */ -int srslte_dmrs_pucch_format2_estimate(const srslte_pucch_nr_t* q, - const srslte_carrier_nr_t* carrier, - const srslte_pucch_nr_common_cfg_t* cfg, - const srslte_slot_cfg_t* slot, - const srslte_pucch_nr_resource_t* resource, +int srsran_dmrs_pucch_format2_estimate(const srsran_pucch_nr_t* q, + const srsran_carrier_nr_t* carrier, + const srsran_pucch_nr_common_cfg_t* cfg, + const srsran_slot_cfg_t* slot, + const srsran_pucch_nr_resource_t* resource, const cf_t* slot_symbols, - srslte_chest_ul_res_t* res); + srsran_chest_ul_res_t* res); -#endif // SRSLTE_DMRS_PUCCH_H +#endif // SRSRAN_DMRS_PUCCH_H diff --git a/lib/include/srslte/phy/ch_estimation/dmrs_sch.h b/lib/include/srsran/phy/ch_estimation/dmrs_sch.h similarity index 59% rename from lib/include/srslte/phy/ch_estimation/dmrs_sch.h rename to lib/include/srsran/phy/ch_estimation/dmrs_sch.h index 3db0fc834..a5aed07fe 100644 --- a/lib/include/srslte/phy/ch_estimation/dmrs_sch.h +++ b/lib/include/srsran/phy/ch_estimation/dmrs_sch.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,57 +10,57 @@ * */ -#ifndef SRSLTE_DMRS_SCH_H -#define SRSLTE_DMRS_SCH_H +#ifndef SRSRAN_DMRS_SCH_H +#define SRSRAN_DMRS_SCH_H -#include "srslte/phy/ch_estimation/chest_dl.h" -#include "srslte/phy/common/phy_common_nr.h" -#include "srslte/phy/phch/phch_cfg_nr.h" +#include "srsran/phy/ch_estimation/chest_dl.h" +#include "srsran/phy/common/phy_common_nr.h" +#include "srsran/phy/phch/phch_cfg_nr.h" #include -#define SRSLTE_DMRS_SCH_MAX_SYMBOLS 4 +#define SRSRAN_DMRS_SCH_MAX_SYMBOLS 4 /** * @brief Helper macro for counting the number of subcarriers taken by DMRS in a PRB. */ -#define SRSLTE_DMRS_SCH_SC(CDM_GROUPS, DMRS_TYPE) \ - (SRSLTE_MIN(SRSLTE_NRE, (CDM_GROUPS) * ((DMRS_TYPE) == srslte_dmrs_sch_type_1 ? 6 : 4))) +#define SRSRAN_DMRS_SCH_SC(CDM_GROUPS, DMRS_TYPE) \ + (SRSRAN_MIN(SRSRAN_NRE, (CDM_GROUPS) * ((DMRS_TYPE) == srsran_dmrs_sch_type_1 ? 6 : 4))) /** * @brief PDSCH DMRS estimator object * * @note The DMRS PDSCH object has to be initialised and the carrier parameters needs to be set. * - * @see srslte_dmrs_sch_init - * @see srslte_dmrs_sch_set_carrier - * @see srslte_dmrs_sch_free - * @see srslte_dmrs_sch_put_sf - * @see srslte_dmrs_sch_estimate + * @see srsran_dmrs_sch_init + * @see srsran_dmrs_sch_set_carrier + * @see srsran_dmrs_sch_free + * @see srsran_dmrs_sch_put_sf + * @see srsran_dmrs_sch_estimate */ typedef struct { bool is_rx; - srslte_carrier_nr_t carrier; + srsran_carrier_nr_t carrier; - srslte_interp_lin_t interpolator_type1; /// Type 1 DMRS: 1 pilot every 2 RE - srslte_interp_lin_t interpolator_type2; /// Type 2 DMRS: 2 consecutive pilots every 6 RE + srsran_interp_lin_t interpolator_type1; /// Type 1 DMRS: 1 pilot every 2 RE + srsran_interp_lin_t interpolator_type2; /// Type 2 DMRS: 2 consecutive pilots every 6 RE uint32_t max_nof_prb; cf_t* pilot_estimates; /// Pilots least squares estimates - cf_t* temp; /// Temporal data vector of size SRSLTE_NRE * carrier.nof_prb + cf_t* temp; /// Temporal data vector of size SRSRAN_NRE * carrier.nof_prb -} srslte_dmrs_sch_t; +} srsran_dmrs_sch_t; /** * @brief Computes the symbol indexes carrying DMRS and stores them in symbols_idx * @param dmrs_cfg DMRS configuration * @param grant PDSCH information provided by a DCI * @param symbols_idx is the destination pointer where the symbols indexes are stored - * @return It returns the number of symbols if inputs are valid, otherwise, it returns SRSLTE_ERROR code. + * @return It returns the number of symbols if inputs are valid, otherwise, it returns SRSRAN_ERROR code. */ -SRSLTE_API int srslte_dmrs_sch_get_symbols_idx(const srslte_dmrs_sch_cfg_t* dmrs_cfg, - const srslte_sch_grant_nr_t* grant, - uint32_t symbols_idx[SRSLTE_DMRS_SCH_MAX_SYMBOLS]); +SRSRAN_API int srsran_dmrs_sch_get_symbols_idx(const srsran_dmrs_sch_cfg_t* dmrs_cfg, + const srsran_sch_grant_nr_t* grant, + uint32_t symbols_idx[SRSRAN_DMRS_SCH_MAX_SYMBOLS]); /** * @brief Computes the sub-carrier indexes carrying DMRS @@ -69,17 +69,17 @@ SRSLTE_API int srslte_dmrs_sch_get_symbols_idx(const srslte_dmrs_sch_cfg_t* dmrs * @param max_count is the number of sub-carriers to generate * @param sc_idx is the destination pointer where the sub-carrier indexes are stored * - * @return It returns the number of sub-carriers if inputs are valid, otherwise, it returns SRSLTE_ERROR code. + * @return It returns the number of sub-carriers if inputs are valid, otherwise, it returns SRSRAN_ERROR code. */ -SRSLTE_API int srslte_dmrs_sch_get_sc_idx(const srslte_dmrs_sch_cfg_t* cfg, uint32_t max_count, uint32_t* sc_idx); +SRSRAN_API int srsran_dmrs_sch_get_sc_idx(const srsran_dmrs_sch_cfg_t* cfg, uint32_t max_count, uint32_t* sc_idx); /** * @brief Calculates the number of resource elements taken by a PDSCH-DMRS for a given PDSCH transmission * @param dmrs_cfg PDSCH-DMRS configuration * @param grant PDSCH information provided by a DCI - * @return it returns the number of resource elements if the configuration is valid, otherwise it returns SRSLTE_ERROR + * @return it returns the number of resource elements if the configuration is valid, otherwise it returns SRSRAN_ERROR */ -SRSLTE_API int srslte_dmrs_sch_get_N_prb(const srslte_dmrs_sch_cfg_t* dmrs_cfg, const srslte_sch_grant_nr_t* grant); +SRSRAN_API int srsran_dmrs_sch_get_N_prb(const srsran_dmrs_sch_cfg_t* dmrs_cfg, const srsran_sch_grant_nr_t* grant); /** * @brief Stringifies the PDSCH DMRS configuration @@ -89,25 +89,25 @@ SRSLTE_API int srslte_dmrs_sch_get_N_prb(const srslte_dmrs_sch_cfg_t* dmrs_cfg, * @param max_len Maximum number of characters to write * * @return It returns the number of characters written in the vector if no error occurs, otherwise it returns - * SRSLTE_ERROR code + * SRSRAN_ERROR code */ -SRSLTE_API int srslte_dmrs_sch_cfg_to_str(const srslte_dmrs_sch_cfg_t* cfg, char* msg, uint32_t max_len); +SRSRAN_API int srsran_dmrs_sch_cfg_to_str(const srsran_dmrs_sch_cfg_t* cfg, char* msg, uint32_t max_len); /** * @brief Initialises DMRS PDSCH object * * @param q DMRS PDSCH object * @param is_rx indicates whether the object is used as receiver (in this case, it shall initialise as an estimator) - * @return it returns SRSLTE_ERROR code if an error occurs, otherwise it returns SRSLTE_SUCCESS + * @return it returns SRSRAN_ERROR code if an error occurs, otherwise it returns SRSRAN_SUCCESS */ -SRSLTE_API int srslte_dmrs_sch_init(srslte_dmrs_sch_t* q, bool is_rx); +SRSRAN_API int srsran_dmrs_sch_init(srsran_dmrs_sch_t* q, bool is_rx); /** * @brief Frees DMRS PDSCH object * * @param q DMRS PDSCH object */ -SRSLTE_API void srslte_dmrs_sch_free(srslte_dmrs_sch_t* q); +SRSRAN_API void srsran_dmrs_sch_free(srsran_dmrs_sch_t* q); /** * @brief Sets the carrier configuration. if the PDSCH DMRS object is configured as UE, it will resize internal buffers @@ -116,9 +116,9 @@ SRSLTE_API void srslte_dmrs_sch_free(srslte_dmrs_sch_t* q); * @param q DMRS PDSCH object * @param carrier Carrier configuration * - * @return it returns SRSLTE_ERROR code if an error occurs, otherwise it returns SRSLTE_SUCCESS + * @return it returns SRSRAN_ERROR code if an error occurs, otherwise it returns SRSRAN_SUCCESS */ -SRSLTE_API int srslte_dmrs_sch_set_carrier(srslte_dmrs_sch_t* q, const srslte_carrier_nr_t* carrier); +SRSRAN_API int srsran_dmrs_sch_set_carrier(srsran_dmrs_sch_t* q, const srsran_carrier_nr_t* carrier); /** * @brief Puts PDSCH DMRS into a given resource grid @@ -129,12 +129,12 @@ SRSLTE_API int srslte_dmrs_sch_set_carrier(srslte_dmrs_sch_t* q, const srslte_ca * @param grant PDSCH information provided by a DCI * @param sf_symbols Resource grid * - * @return it returns SRSLTE_ERROR code if an error occurs, otherwise it returns SRSLTE_SUCCESS + * @return it returns SRSRAN_ERROR code if an error occurs, otherwise it returns SRSRAN_SUCCESS */ -SRSLTE_API int srslte_dmrs_sch_put_sf(srslte_dmrs_sch_t* q, - const srslte_slot_cfg_t* slot_cfg, - const srslte_sch_cfg_nr_t* pdsch_cfg, - const srslte_sch_grant_nr_t* grant, +SRSRAN_API int srsran_dmrs_sch_put_sf(srsran_dmrs_sch_t* q, + const srsran_slot_cfg_t* slot_cfg, + const srsran_sch_cfg_nr_t* pdsch_cfg, + const srsran_sch_grant_nr_t* grant, cf_t* sf_symbols); /** @@ -149,13 +149,13 @@ SRSLTE_API int srslte_dmrs_sch_put_sf(srslte_dmrs_sch_t* q, * @param sf_symbols Received resource grid * @param[out] ce Channel estimates * - * @return it returns SRSLTE_ERROR code if an error occurs, otherwise it returns SRSLTE_SUCCESS + * @return it returns SRSRAN_ERROR code if an error occurs, otherwise it returns SRSRAN_SUCCESS */ -SRSLTE_API int srslte_dmrs_sch_estimate(srslte_dmrs_sch_t* q, - const srslte_slot_cfg_t* slot_cfg, - const srslte_sch_cfg_nr_t* pdsch_cfg, - const srslte_sch_grant_nr_t* grant, +SRSRAN_API int srsran_dmrs_sch_estimate(srsran_dmrs_sch_t* q, + const srsran_slot_cfg_t* slot_cfg, + const srsran_sch_cfg_nr_t* pdsch_cfg, + const srsran_sch_grant_nr_t* grant, const cf_t* sf_symbols, - srslte_chest_dl_res_t* chest_res); + srsran_chest_dl_res_t* chest_res); -#endif // SRSLTE_DMRS_SCH_H +#endif // SRSRAN_DMRS_SCH_H diff --git a/lib/include/srsran/phy/ch_estimation/refsignal_dl.h b/lib/include/srsran/phy/ch_estimation/refsignal_dl.h new file mode 100644 index 000000000..251a4b9a0 --- /dev/null +++ b/lib/include/srsran/phy/ch_estimation/refsignal_dl.h @@ -0,0 +1,92 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +/********************************************************************************************** + * File: refsignal_dl.h + * + * Description: Object to manage downlink reference signals for channel estimation. + * + * Reference: 3GPP TS 36.211 version 10.0.0 Release 10 Sec. 6.10 + *********************************************************************************************/ + +#ifndef SRSRAN_REFSIGNAL_DL_H +#define SRSRAN_REFSIGNAL_DL_H + +#include "srsran/config.h" +#include "srsran/phy/common/phy_common.h" + +// Number of references in a subframe: there are 2 symbols for port_id=0,1 x 2 slots x 2 refs per prb +#define SRSRAN_REFSIGNAL_NUM_SF_MBSFN(nof_prb, port_id) ((2 + 18) * (nof_prb)) + +#define SRSRAN_REFSIGNAL_MAX_NUM_SF(nof_prb) (8 * nof_prb) +#define SRSRAN_REFSIGNAL_MAX_NUM_SF_MBSFN(nof_prb) SRSRAN_REFSIGNAL_NUM_SF_MBSFN(nof_prb, 0) + +#define SRSRAN_REFSIGNAL_PILOT_IDX(i, l, cell) (2 * cell.nof_prb * (l) + (i)) + +#define SRSRAN_REFSIGNAL_PILOT_IDX_MBSFN(i, l, cell) ((6 * cell.nof_prb * (l) + (i))) + +/** Cell-Specific Reference Signal */ +typedef struct SRSRAN_API { + srsran_cell_t cell; + cf_t* pilots[2][SRSRAN_NOF_SF_X_FRAME]; // Saves the reference signal per subframe for ports 0,1 and ports 2,3 + srsran_sf_t type; + uint16_t mbsfn_area_id; +} srsran_refsignal_t; + +SRSRAN_API int srsran_refsignal_cs_init(srsran_refsignal_t* q, uint32_t max_prb); + +SRSRAN_API int srsran_refsignal_cs_set_cell(srsran_refsignal_t* q, srsran_cell_t cell); + +SRSRAN_API void srsran_refsignal_free(srsran_refsignal_t* q); + +SRSRAN_API int +srsran_refsignal_cs_put_sf(srsran_refsignal_t* q, srsran_dl_sf_cfg_t* sf, uint32_t port_id, cf_t* sf_symbols); + +SRSRAN_API int srsran_refsignal_cs_get_sf(srsran_refsignal_t* q, + srsran_dl_sf_cfg_t* sf, + uint32_t port_id, + cf_t* sf_symbols, + cf_t* pilots); + +SRSRAN_API uint32_t srsran_refsignal_cs_fidx(srsran_cell_t cell, uint32_t l, uint32_t port_id, uint32_t m); + +SRSRAN_API uint32_t srsran_refsignal_cs_nsymbol(uint32_t l, srsran_cp_t cp, uint32_t port_id); + +SRSRAN_API uint32_t srsran_refsignal_cs_v(uint32_t port_id, uint32_t ref_symbol_idx); + +SRSRAN_API uint32_t srsran_refsignal_cs_nof_symbols(srsran_refsignal_t* q, srsran_dl_sf_cfg_t* sf, uint32_t port_id); + +SRSRAN_API uint32_t srsran_refsignal_cs_nof_pilots_x_slot(uint32_t nof_ports); + +SRSRAN_API uint32_t srsran_refsignal_cs_nof_re(srsran_refsignal_t* q, srsran_dl_sf_cfg_t* sf, uint32_t port_id); + +SRSRAN_API int srsran_refsignal_mbsfn_init(srsran_refsignal_t* q, uint32_t max_prb); + +SRSRAN_API int srsran_refsignal_mbsfn_set_cell(srsran_refsignal_t* q, srsran_cell_t cell, uint16_t mbsfn_area_id); + +SRSRAN_API int srsran_refsignal_mbsfn_get_sf(srsran_cell_t cell, uint32_t port_id, cf_t* sf_symbols, cf_t* pilots); + +SRSRAN_API uint32_t srsran_refsignal_mbsfn_nsymbol(uint32_t l); + +SRSRAN_API uint32_t srsran_refsignal_mbsfn_fidx(uint32_t l); + +SRSRAN_API uint32_t srsran_refsignal_mbsfn_nof_symbols(); + +SRSRAN_API int srsran_refsignal_mbsfn_put_sf(srsran_cell_t cell, + uint32_t port_id, + cf_t* cs_pilots, + cf_t* mbsfn_pilots, + cf_t* sf_symbols); + +SRSRAN_API int srsran_refsignal_mbsfn_gen_seq(srsran_refsignal_t* q, srsran_cell_t cell, uint32_t N_mbsfn_id); + +#endif // SRSRAN_REFSIGNAL_DL_H diff --git a/lib/include/srsran/phy/ch_estimation/refsignal_dl_nbiot.h b/lib/include/srsran/phy/ch_estimation/refsignal_dl_nbiot.h new file mode 100644 index 000000000..d5c0234cf --- /dev/null +++ b/lib/include/srsran/phy/ch_estimation/refsignal_dl_nbiot.h @@ -0,0 +1,55 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +#ifndef SRSRAN_REFSIGNAL_DL_NBIOT_H +#define SRSRAN_REFSIGNAL_DL_NBIOT_H + +#include "srsran/config.h" +#include "srsran/phy/common/phy_common.h" + +// Number of references in a subframe: there are 2 symbols for port_id=0,1 x 2 slots x 2 refs per prb +#define SRSRAN_NBIOT_NUM_NRS_X_SYM_X_PORT 2 + +// Max number of symbols with RE in one PRB (4 ports LTE plus 2 port NB-IoT) +#define SRSRAN_NBIOT_MAX_NUM_RE_WITH_REFS 40 + +#define SRSRAN_NBIOT_REFSIGNAL_NUM_SF(nof_prb, port_id) (((port_id) < 2 ? 8 : 4) * (nof_prb)) +#define SRSRAN_NBIOT_REFSIGNAL_PILOT_IDX(i, l, nof_prb) (2 * nof_prb * (l) + (i)) + +/** Brief: Narrowband Reference Signal (NRS) + * + * Object to manage downlink reference signals for channel estimation. (3GPP TS 36.211 version 13.3 Sec. 10.2.6) + */ +typedef struct SRSRAN_API { + srsran_nbiot_cell_t cell; + cf_t* pilots[2][SRSRAN_NOF_SF_X_FRAME]; // Saves the reference signal per subframe for ports 0 and 1 +} srsran_refsignal_dl_nbiot_t; + +SRSRAN_API int srsran_refsignal_dl_nbiot_init(srsran_refsignal_dl_nbiot_t* q); + +SRSRAN_API void srsran_refsignal_dl_nbiot_free(srsran_refsignal_dl_nbiot_t* q); + +SRSRAN_API uint32_t srsran_refsignal_dl_nbiot_nof_symbols(uint32_t port_id); + +SRSRAN_API int srsran_refsignal_dl_nbiot_set_cell(srsran_refsignal_dl_nbiot_t* q, srsran_nbiot_cell_t cell); + +SRSRAN_API uint32_t srsran_refsignal_dl_nbiot_fidx(srsran_nbiot_cell_t cell, uint32_t l, uint32_t port_id, uint32_t m); + +SRSRAN_API uint32_t srsran_refsignal_nrs_nsymbol(uint32_t l); + +SRSRAN_API uint32_t srsran_refsignal_nbiot_cs_nof_re(srsran_nbiot_cell_t* cell, uint32_t port_id); + +SRSRAN_API int srsran_refsignal_nrs_put_sf(srsran_nbiot_cell_t cell, uint32_t port_id, cf_t* pilots, cf_t* sf_symbols); + +SRSRAN_API int srsran_refsignal_nrs_get_sf(srsran_nbiot_cell_t cell, uint32_t port_id, cf_t* sf_symbols, cf_t* pilots); + +#endif // SRSRAN_REFSIGNAL_DL_NBIOT_H diff --git a/lib/include/srsran/phy/ch_estimation/refsignal_ul.h b/lib/include/srsran/phy/ch_estimation/refsignal_ul.h new file mode 100644 index 000000000..2e55f820a --- /dev/null +++ b/lib/include/srsran/phy/ch_estimation/refsignal_ul.h @@ -0,0 +1,184 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +/********************************************************************************************** + * File: refsignal_ul.h + * + * Description: Object to manage uplink reference signals for channel estimation. + * + * Reference: 3GPP TS 36.211 version 10.0.0 Release 10 Sec. 5.5 + *********************************************************************************************/ + +#ifndef SRSRAN_REFSIGNAL_UL_H +#define SRSRAN_REFSIGNAL_UL_H + +#include "srsran/config.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/phch/pucch_cfg.h" +#include "srsran/phy/phch/pusch_cfg.h" + +#define SRSRAN_NOF_GROUPS_U 30 +#define SRSRAN_NOF_SEQUENCES_U 2 +#define SRSRAN_NOF_DELTA_SS 30 +#define SRSRAN_NOF_CSHIFT 8 + +#define SRSRAN_REFSIGNAL_UL_L(ns_idx, cp) ((ns_idx + 1) * SRSRAN_CP_NSYMB(cp) - 4) + +/* PUSCH DMRS common configuration (received in SIB2) */ +typedef struct SRSRAN_API { + uint32_t cyclic_shift; + uint32_t delta_ss; + bool group_hopping_en; + bool sequence_hopping_en; +} srsran_refsignal_dmrs_pusch_cfg_t; + +typedef struct SRSRAN_API { + + // Common Configuration + uint32_t subframe_config; + uint32_t bw_cfg; + bool simul_ack; + + // Dedicated configuration + uint32_t B; + uint32_t b_hop; + uint32_t n_srs; + uint32_t I_srs; + uint32_t k_tc; + uint32_t n_rrc; + bool dedicated_enabled; + bool common_enabled; + bool configured; +} srsran_refsignal_srs_cfg_t; + +/** Uplink DeModulation Reference Signal (DMRS) */ +typedef struct SRSRAN_API { + srsran_cell_t cell; + + uint32_t n_cs_cell[SRSRAN_NSLOTS_X_FRAME][SRSRAN_CP_NORM_NSYMB]; + uint32_t n_prs_pusch[SRSRAN_NOF_DELTA_SS][SRSRAN_NSLOTS_X_FRAME]; // We precompute n_prs needed for cyclic shift alpha + // at srsran_refsignal_dl_init() + uint32_t f_gh[SRSRAN_NSLOTS_X_FRAME]; + uint32_t u_pucch[SRSRAN_NSLOTS_X_FRAME]; + uint32_t v_pusch[SRSRAN_NSLOTS_X_FRAME][SRSRAN_NOF_DELTA_SS]; +} srsran_refsignal_ul_t; + +typedef struct { + uint32_t max_prb; + cf_t** r[SRSRAN_NOF_CSHIFT][SRSRAN_NOF_SF_X_FRAME]; +} srsran_refsignal_ul_dmrs_pregen_t; + +typedef struct { + cf_t* r[SRSRAN_NOF_SF_X_FRAME]; +} srsran_refsignal_srs_pregen_t; + +SRSRAN_API int srsran_refsignal_ul_set_cell(srsran_refsignal_ul_t* q, srsran_cell_t cell); + +SRSRAN_API uint32_t srsran_refsignal_dmrs_N_rs(srsran_pucch_format_t format, srsran_cp_t cp); + +SRSRAN_API uint32_t srsran_refsignal_dmrs_pucch_symbol(uint32_t m, srsran_pucch_format_t format, srsran_cp_t cp); + +SRSRAN_API int srsran_refsignal_dmrs_pusch_pregen_init(srsran_refsignal_ul_dmrs_pregen_t* pregen, uint32_t max_prb); + +SRSRAN_API int srsran_refsignal_dmrs_pusch_pregen(srsran_refsignal_ul_t* q, + srsran_refsignal_ul_dmrs_pregen_t* pregen, + srsran_refsignal_dmrs_pusch_cfg_t* cfg); + +SRSRAN_API void srsran_refsignal_dmrs_pusch_pregen_free(srsran_refsignal_ul_t* q, + srsran_refsignal_ul_dmrs_pregen_t* pregen); + +SRSRAN_API int srsran_refsignal_dmrs_pusch_pregen_put(srsran_refsignal_ul_t* q, + srsran_ul_sf_cfg_t* sf_cfg, + srsran_refsignal_ul_dmrs_pregen_t* pregen, + srsran_pusch_cfg_t* pusch_cfg, + cf_t* sf_symbols); + +SRSRAN_API int srsran_refsignal_dmrs_pusch_gen(srsran_refsignal_ul_t* q, + srsran_refsignal_dmrs_pusch_cfg_t* cfg, + uint32_t nof_prb, + uint32_t sf_idx, + uint32_t cyclic_shift_for_dmrs, + cf_t* r_pusch); + +SRSRAN_API void srsran_refsignal_dmrs_pusch_put(srsran_refsignal_ul_t* q, + srsran_pusch_cfg_t* pusch_cfg, + cf_t* r_pusch, + cf_t* sf_symbols); + +SRSRAN_API void srsran_refsignal_dmrs_pusch_get(srsran_refsignal_ul_t* q, + srsran_pusch_cfg_t* pusch_cfg, + cf_t* sf_symbols, + cf_t* r_pusch); + +SRSRAN_API int srsran_refsignal_dmrs_pucch_gen(srsran_refsignal_ul_t* q, + srsran_ul_sf_cfg_t* sf, + srsran_pucch_cfg_t* cfg, + cf_t* r_pucch); + +SRSRAN_API int +srsran_refsignal_dmrs_pucch_put(srsran_refsignal_ul_t* q, srsran_pucch_cfg_t* cfg, cf_t* r_pucch, cf_t* output); + +SRSRAN_API int +srsran_refsignal_dmrs_pucch_get(srsran_refsignal_ul_t* q, srsran_pucch_cfg_t* cfg, cf_t* input, cf_t* r_pucch); + +SRSRAN_API int srsran_refsignal_srs_pregen(srsran_refsignal_ul_t* q, + srsran_refsignal_srs_pregen_t* pregen, + srsran_refsignal_srs_cfg_t* cfg, + srsran_refsignal_dmrs_pusch_cfg_t* dmrs); + +SRSRAN_API int srsran_refsignal_srs_pregen_put(srsran_refsignal_ul_t* q, + srsran_refsignal_srs_pregen_t* pregen, + srsran_refsignal_srs_cfg_t* cfg, + uint32_t tti, + cf_t* sf_symbols); + +SRSRAN_API void srsran_refsignal_srs_pregen_free(srsran_refsignal_ul_t* q, srsran_refsignal_srs_pregen_t* pregen); + +SRSRAN_API int srsran_refsignal_srs_gen(srsran_refsignal_ul_t* q, + srsran_refsignal_srs_cfg_t* cfg, + srsran_refsignal_dmrs_pusch_cfg_t* pusch_cfg, + uint32_t sf_idx, + cf_t* r_srs); + +SRSRAN_API int srsran_refsignal_srs_put(srsran_refsignal_ul_t* q, + srsran_refsignal_srs_cfg_t* cfg, + uint32_t tti, + cf_t* r_srs, + cf_t* sf_symbols); + +SRSRAN_API int srsran_refsignal_srs_get(srsran_refsignal_ul_t* q, + srsran_refsignal_srs_cfg_t* cfg, + uint32_t tti, + cf_t* r_srs, + cf_t* sf_symbols); + +SRSRAN_API void srsran_refsignal_srs_pusch_shortened(srsran_refsignal_ul_t* q, + srsran_ul_sf_cfg_t* sf, + srsran_refsignal_srs_cfg_t* srs_cfg, + srsran_pusch_cfg_t* pusch_cfg); + +SRSRAN_API void srsran_refsignal_srs_pucch_shortened(srsran_refsignal_ul_t* q, + srsran_ul_sf_cfg_t* sf, + srsran_refsignal_srs_cfg_t* srs_cfg, + srsran_pucch_cfg_t* pucch_cfg); + +SRSRAN_API int srsran_refsignal_srs_send_cs(uint32_t subframe_config, uint32_t sf_idx); + +SRSRAN_API int srsran_refsignal_srs_send_ue(uint32_t I_srs, uint32_t tti); + +SRSRAN_API uint32_t srsran_refsignal_srs_rb_start_cs(uint32_t bw_cfg, uint32_t nof_prb); + +SRSRAN_API uint32_t srsran_refsignal_srs_rb_L_cs(uint32_t bw_cfg, uint32_t nof_prb); + +SRSRAN_API uint32_t srsran_refsignal_srs_M_sc(srsran_refsignal_ul_t* q, srsran_refsignal_srs_cfg_t* cfg); + +#endif // SRSRAN_REFSIGNAL_UL_H diff --git a/lib/include/srslte/phy/ch_estimation/wiener_dl.h b/lib/include/srsran/phy/ch_estimation/wiener_dl.h similarity index 52% rename from lib/include/srslte/phy/ch_estimation/wiener_dl.h rename to lib/include/srsran/phy/ch_estimation/wiener_dl.h index 75d5d934f..83ca59c2a 100644 --- a/lib/include/srslte/phy/ch_estimation/wiener_dl.h +++ b/lib/include/srsran/phy/ch_estimation/wiener_dl.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,39 +10,39 @@ * */ -#ifndef SRSLTE_WIENER_DL_H_ -#define SRSLTE_WIENER_DL_H_ +#ifndef SRSRAN_WIENER_DL_H_ +#define SRSRAN_WIENER_DL_H_ -#include -#include -#include -#include +#include +#include +#include +#include // Constant static parameters -#define SRSLTE_WIENER_DL_HLS_FIFO_SIZE (8U) -#define SRSLTE_WIENER_DL_MIN_PRB (4U) -#define SRSLTE_WIENER_DL_MIN_RE (SRSLTE_WIENER_DL_MIN_PRB * SRSLTE_NRE) -#define SRSLTE_WIENER_DL_MIN_REF (SRSLTE_WIENER_DL_MIN_PRB * 2U) -#define SRSLTE_WIENER_DL_TFIFO_SIZE (2U) -#define SRSLTE_WIENER_DL_XFIFO_SIZE (400U) -#define SRSLTE_WIENER_DL_TIMEFIFO_SIZE (32U) -#define SRSLTE_WIENER_DL_CXFIFO_SIZE (400U) +#define SRSRAN_WIENER_DL_HLS_FIFO_SIZE (8U) +#define SRSRAN_WIENER_DL_MIN_PRB (4U) +#define SRSRAN_WIENER_DL_MIN_RE (SRSRAN_WIENER_DL_MIN_PRB * SRSRAN_NRE) +#define SRSRAN_WIENER_DL_MIN_REF (SRSRAN_WIENER_DL_MIN_PRB * 2U) +#define SRSRAN_WIENER_DL_TFIFO_SIZE (2U) +#define SRSRAN_WIENER_DL_XFIFO_SIZE (400U) +#define SRSRAN_WIENER_DL_TIMEFIFO_SIZE (32U) +#define SRSRAN_WIENER_DL_CXFIFO_SIZE (400U) typedef struct { - cf_t* hls_fifo_1[SRSLTE_WIENER_DL_HLS_FIFO_SIZE]; // Least square channel estimates on odd pilots - cf_t* hls_fifo_2[SRSLTE_WIENER_DL_HLS_FIFO_SIZE]; // Least square channel estimates on even pilots - cf_t* tfifo[SRSLTE_WIENER_DL_TFIFO_SIZE]; // memory for time domain channel linear interpolation - cf_t* xfifo[SRSLTE_WIENER_DL_XFIFO_SIZE]; // fifo for averaging the frequency correlation vectors - cf_t cV[SRSLTE_WIENER_DL_MIN_RE]; // frequency correlation vector among all subcarriers + cf_t* hls_fifo_1[SRSRAN_WIENER_DL_HLS_FIFO_SIZE]; // Least square channel estimates on odd pilots + cf_t* hls_fifo_2[SRSRAN_WIENER_DL_HLS_FIFO_SIZE]; // Least square channel estimates on even pilots + cf_t* tfifo[SRSRAN_WIENER_DL_TFIFO_SIZE]; // memory for time domain channel linear interpolation + cf_t* xfifo[SRSRAN_WIENER_DL_XFIFO_SIZE]; // fifo for averaging the frequency correlation vectors + cf_t cV[SRSRAN_WIENER_DL_MIN_RE]; // frequency correlation vector among all subcarriers float deltan; // step within time domain linear interpolation uint32_t nfifosamps; // number of samples inside the fifo for averaging the correlation vectors float invtpilotoff; // step for time domain linear interpolation cf_t* timefifo; // fifo for storing single frequency channel time domain evolution - cf_t* cxfifo[SRSLTE_WIENER_DL_CXFIFO_SIZE]; // fifo for averaging time domain channel correlation vector + cf_t* cxfifo[SRSRAN_WIENER_DL_CXFIFO_SIZE]; // fifo for averaging time domain channel correlation vector uint32_t sumlen; // length of dynamic average window for time domain channel correlation vector uint32_t skip; // pilot OFDM symbols to skip when training Wiener matrices (skip = 1,..,4) uint32_t cnt; // counter for skipping pilot OFDM symbols -} srslte_wiener_dl_state_t; +} srsran_wiener_dl_state_t; typedef struct { // Maximum allocated number of... @@ -60,53 +60,53 @@ typedef struct { uint32_t nof_rx_ant; // Rx Antennas // One state per possible channel (allocated in init) - srslte_wiener_dl_state_t* state[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS]; + srsran_wiener_dl_state_t* state[SRSRAN_MAX_PORTS][SRSRAN_MAX_PORTS]; // Wiener matrices - cf_t wm1[SRSLTE_WIENER_DL_MIN_RE][SRSLTE_WIENER_DL_MIN_REF]; - cf_t wm2[SRSLTE_WIENER_DL_MIN_RE][SRSLTE_WIENER_DL_MIN_REF]; + cf_t wm1[SRSRAN_WIENER_DL_MIN_RE][SRSRAN_WIENER_DL_MIN_REF]; + cf_t wm2[SRSRAN_WIENER_DL_MIN_RE][SRSRAN_WIENER_DL_MIN_REF]; bool wm_computed; bool ready; // Calculation support - cf_t hlsv[SRSLTE_WIENER_DL_MIN_RE]; - cf_t hlsv_sum[SRSLTE_WIENER_DL_MIN_RE]; - cf_t acV[SRSLTE_WIENER_DL_MIN_RE]; + cf_t hlsv[SRSRAN_WIENER_DL_MIN_RE]; + cf_t hlsv_sum[SRSRAN_WIENER_DL_MIN_RE]; + cf_t acV[SRSRAN_WIENER_DL_MIN_RE]; union { - cf_t m[SRSLTE_WIENER_DL_MIN_REF][SRSLTE_WIENER_DL_MIN_REF]; - cf_t v[SRSLTE_WIENER_DL_MIN_REF * SRSLTE_WIENER_DL_MIN_REF]; + cf_t m[SRSRAN_WIENER_DL_MIN_REF][SRSRAN_WIENER_DL_MIN_REF]; + cf_t v[SRSRAN_WIENER_DL_MIN_REF * SRSRAN_WIENER_DL_MIN_REF]; } RH; union { - cf_t m[SRSLTE_WIENER_DL_MIN_REF][SRSLTE_WIENER_DL_MIN_REF]; - cf_t v[SRSLTE_WIENER_DL_MIN_REF * SRSLTE_WIENER_DL_MIN_REF]; + cf_t m[SRSRAN_WIENER_DL_MIN_REF][SRSRAN_WIENER_DL_MIN_REF]; + cf_t v[SRSRAN_WIENER_DL_MIN_REF * SRSRAN_WIENER_DL_MIN_REF]; } invRH; - cf_t hH1[SRSLTE_WIENER_DL_MIN_RE][SRSLTE_WIENER_DL_MIN_REF]; - cf_t hH2[SRSLTE_WIENER_DL_MIN_RE][SRSLTE_WIENER_DL_MIN_REF]; + cf_t hH1[SRSRAN_WIENER_DL_MIN_RE][SRSRAN_WIENER_DL_MIN_REF]; + cf_t hH2[SRSRAN_WIENER_DL_MIN_RE][SRSRAN_WIENER_DL_MIN_REF]; // Temporal vector cf_t* tmp; // Random generator - srslte_random_t random; + srsran_random_t random; // FFT/iFFT - srslte_dft_plan_t fft; - srslte_dft_plan_t ifft; - cf_t filter[SRSLTE_WIENER_DL_MIN_RE]; + srsran_dft_plan_t fft; + srsran_dft_plan_t ifft; + cf_t filter[SRSRAN_WIENER_DL_MIN_RE]; // Matrix inverter void* matrix_inverter; -} srslte_wiener_dl_t; +} srsran_wiener_dl_t; -SRSLTE_API int -srslte_wiener_dl_init(srslte_wiener_dl_t* q, uint32_t max_prb, uint32_t max_tx_ports, uint32_t max_rx_ant); +SRSRAN_API int +srsran_wiener_dl_init(srsran_wiener_dl_t* q, uint32_t max_prb, uint32_t max_tx_ports, uint32_t max_rx_ant); -SRSLTE_API int srslte_wiener_dl_set_cell(srslte_wiener_dl_t* q, srslte_cell_t cell); +SRSRAN_API int srsran_wiener_dl_set_cell(srsran_wiener_dl_t* q, srsran_cell_t cell); -SRSLTE_API void srslte_wiener_dl_reset(srslte_wiener_dl_t* q); +SRSRAN_API void srsran_wiener_dl_reset(srsran_wiener_dl_t* q); -SRSLTE_API int srslte_wiener_dl_run(srslte_wiener_dl_t* q, +SRSRAN_API int srsran_wiener_dl_run(srsran_wiener_dl_t* q, uint32_t tx, uint32_t rx, uint32_t m, @@ -115,6 +115,6 @@ SRSLTE_API int srslte_wiener_dl_run(srslte_wiener_dl_t* q, cf_t* estimated, float snr_lin); -SRSLTE_API void srslte_wiener_dl_free(srslte_wiener_dl_t* q); +SRSRAN_API void srsran_wiener_dl_free(srsran_wiener_dl_t* q); -#endif // SRSLTE_WIENER_DL_H_ +#endif // SRSRAN_WIENER_DL_H_ diff --git a/lib/include/srslte/phy/channel/ch_awgn.h b/lib/include/srsran/phy/channel/ch_awgn.h similarity index 68% rename from lib/include/srslte/phy/channel/ch_awgn.h rename to lib/include/srsran/phy/channel/ch_awgn.h index 34d4ef752..b5cb25b58 100644 --- a/lib/include/srslte/phy/channel/ch_awgn.h +++ b/lib/include/srsran/phy/channel/ch_awgn.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -18,25 +18,25 @@ * Reference: *********************************************************************************************/ +#include "srsran/config.h" #include -#include "srslte/config.h" -#ifndef SRSLTE_CH_AWGN_H -#define SRSLTE_CH_AWGN_H +#ifndef SRSRAN_CH_AWGN_H +#define SRSRAN_CH_AWGN_H #ifdef __cplusplus extern "C" { #endif /** - * The srsLTE channel AWGN implements an efficient Box-Muller Method accelerated with SIMD. + * The srsRAN channel AWGN implements an efficient Box-Muller Method accelerated with SIMD. */ typedef struct { float* table_cos; float* table_log; uint32_t rand_state; float std_dev; -} srslte_channel_awgn_t; +} srsran_channel_awgn_t; /** * Initialization function of the channel AWGN object @@ -44,7 +44,7 @@ typedef struct { * @param q AWGN channel object * @param seed random generator seed */ -SRSLTE_API int srslte_channel_awgn_init(srslte_channel_awgn_t* q, uint32_t seed); +SRSRAN_API int srsran_channel_awgn_init(srsran_channel_awgn_t* q, uint32_t seed); /** * Sets the noise level N0 in decibels full scale (dBfs) @@ -52,7 +52,7 @@ SRSLTE_API int srslte_channel_awgn_init(srslte_channel_awgn_t* q, uint32_t seed) * @param q AWGN channel object * @param n0_dBfs noise level */ -SRSLTE_API int srslte_channel_awgn_set_n0(srslte_channel_awgn_t* q, float n0_dBfs); +SRSRAN_API int srsran_channel_awgn_set_n0(srsran_channel_awgn_t* q, float n0_dBfs); /** * Runs the complex AWGN channel @@ -62,7 +62,7 @@ SRSLTE_API int srslte_channel_awgn_set_n0(srslte_channel_awgn_t* q, float n0_dBf * @param out complex output array * @param length number of samples */ -SRSLTE_API void srslte_channel_awgn_run_c(srslte_channel_awgn_t* q, const cf_t* in, cf_t* out, uint32_t length); +SRSRAN_API void srsran_channel_awgn_run_c(srsran_channel_awgn_t* q, const cf_t* in, cf_t* out, uint32_t length); /** * Runs the real AWGN channel @@ -72,23 +72,23 @@ SRSLTE_API void srslte_channel_awgn_run_c(srslte_channel_awgn_t* q, const cf_t* * @param out real output array * @param length number of samples */ -SRSLTE_API void srslte_channel_awgn_run_f(srslte_channel_awgn_t* q, const float* in, float* out, uint32_t length); +SRSRAN_API void srsran_channel_awgn_run_f(srsran_channel_awgn_t* q, const float* in, float* out, uint32_t length); /** * Free AWGN channel generator data * * @param q AWGN channel object */ -SRSLTE_API void srslte_channel_awgn_free(srslte_channel_awgn_t* q); +SRSRAN_API void srsran_channel_awgn_free(srsran_channel_awgn_t* q); -SRSLTE_API void srslte_ch_awgn_c(const cf_t* input, cf_t* output, float variance, uint32_t len); +SRSRAN_API void srsran_ch_awgn_c(const cf_t* input, cf_t* output, float variance, uint32_t len); -SRSLTE_API void srslte_ch_awgn_f(const float* x, float* y, float variance, uint32_t len); +SRSRAN_API void srsran_ch_awgn_f(const float* x, float* y, float variance, uint32_t len); -SRSLTE_API float srslte_ch_awgn_get_variance(float ebno_db, float rate); +SRSRAN_API float srsran_ch_awgn_get_variance(float ebno_db, float rate); #ifdef __cplusplus } #endif -#endif // SRSLTE_CH_AWGN_H +#endif // SRSRAN_CH_AWGN_H diff --git a/lib/include/srslte/phy/channel/channel.h b/lib/include/srsran/phy/channel/channel.h similarity index 72% rename from lib/include/srslte/phy/channel/channel.h rename to lib/include/srsran/phy/channel/channel.h index e8f5e76e2..2b73789b8 100644 --- a/lib/include/srslte/phy/channel/channel.h +++ b/lib/include/srsran/phy/channel/channel.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,20 +10,20 @@ * */ -#ifndef SRSLTE_CHANNEL_H -#define SRSLTE_CHANNEL_H +#ifndef SRSRAN_CHANNEL_H +#define SRSRAN_CHANNEL_H #include "ch_awgn.h" #include "delay.h" #include "fading.h" #include "hst.h" #include "rlf.h" -#include "srslte/phy/common/phy_common.h" -#include "srslte/srslog/srslog.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/srslog/srslog.h" #include #include -namespace srslte { +namespace srsran { class channel { @@ -64,16 +64,16 @@ public: ~channel(); void set_srate(uint32_t srate); void set_signal_power_dBfs(float power_dBfs); - void run(cf_t* in[SRSLTE_MAX_CHANNELS], cf_t* out[SRSLTE_MAX_CHANNELS], uint32_t len, const srslte_timestamp_t& t); + void run(cf_t* in[SRSRAN_MAX_CHANNELS], cf_t* out[SRSRAN_MAX_CHANNELS], uint32_t len, const srsran_timestamp_t& t); private: srslog::basic_logger& logger; float hst_init_phase = 0.0f; - srslte_channel_fading_t* fading[SRSLTE_MAX_CHANNELS] = {}; - srslte_channel_delay_t* delay[SRSLTE_MAX_CHANNELS] = {}; - srslte_channel_awgn_t* awgn = nullptr; - srslte_channel_hst_t* hst = nullptr; - srslte_channel_rlf_t* rlf = nullptr; + srsran_channel_fading_t* fading[SRSRAN_MAX_CHANNELS] = {}; + srsran_channel_delay_t* delay[SRSRAN_MAX_CHANNELS] = {}; + srsran_channel_awgn_t* awgn = nullptr; + srsran_channel_hst_t* hst = nullptr; + srsran_channel_rlf_t* rlf = nullptr; cf_t* buffer_in = nullptr; cf_t* buffer_out = nullptr; uint32_t nof_channels = 0; @@ -83,6 +83,6 @@ private: typedef std::unique_ptr channel_ptr; -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_CHANNEL_H +#endif // SRSRAN_CHANNEL_H diff --git a/lib/include/srslte/phy/channel/delay.h b/lib/include/srsran/phy/channel/delay.h similarity index 66% rename from lib/include/srslte/phy/channel/delay.h rename to lib/include/srsran/phy/channel/delay.h index 88b9371ab..b206f3e3b 100644 --- a/lib/include/srslte/phy/channel/delay.h +++ b/lib/include/srsran/phy/channel/delay.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,12 +10,12 @@ * */ -#ifndef SRSLTE_DELAY_H -#define SRSLTE_DELAY_H +#ifndef SRSRAN_DELAY_H +#define SRSRAN_DELAY_H -#include "srslte/config.h" -#include "srslte/phy/common/timestamp.h" -#include "srslte/phy/utils/ringbuffer.h" +#include "srsran/config.h" +#include "srsran/phy/common/timestamp.h" +#include "srsran/phy/utils/ringbuffer.h" #include typedef struct { @@ -28,33 +28,33 @@ typedef struct { float delay_us; uint32_t delay_nsamples; - srslte_ringbuffer_t rb; + srsran_ringbuffer_t rb; cf_t* zero_buffer; -} srslte_channel_delay_t; +} srsran_channel_delay_t; #ifdef __cplusplus extern "C" { #endif -SRSLTE_API int srslte_channel_delay_init(srslte_channel_delay_t* q, +SRSRAN_API int srsran_channel_delay_init(srsran_channel_delay_t* q, float delay_min_us, float delay_max_us, float period_s, float init_time_s, uint32_t srate_max_hz); -SRSLTE_API void srslte_channel_delay_update_srate(srslte_channel_delay_t* q, uint32_t srate_hz); +SRSRAN_API void srsran_channel_delay_update_srate(srsran_channel_delay_t* q, uint32_t srate_hz); -SRSLTE_API void srslte_channel_delay_free(srslte_channel_delay_t* q); +SRSRAN_API void srsran_channel_delay_free(srsran_channel_delay_t* q); -SRSLTE_API void srslte_channel_delay_execute(srslte_channel_delay_t* q, +SRSRAN_API void srsran_channel_delay_execute(srsran_channel_delay_t* q, const cf_t* in, cf_t* out, uint32_t len, - const srslte_timestamp_t* ts); + const srsran_timestamp_t* ts); #ifdef __cplusplus } #endif -#endif // SRSLTE_DELAY_H +#endif // SRSRAN_DELAY_H diff --git a/lib/include/srslte/phy/channel/fading.h b/lib/include/srsran/phy/channel/fading.h similarity index 58% rename from lib/include/srslte/phy/channel/fading.h rename to lib/include/srsran/phy/channel/fading.h index 42fb32f25..1de352ba5 100644 --- a/lib/include/srslte/phy/channel/fading.h +++ b/lib/include/srsran/phy/channel/fading.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,29 +10,29 @@ * */ -#ifndef SRSLTE_FADING_H -#define SRSLTE_FADING_H +#ifndef SRSRAN_FADING_H +#define SRSRAN_FADING_H -#include "srslte/config.h" -#include "srslte/phy/common/timestamp.h" -#include "srslte/phy/dft/dft.h" +#include "srsran/config.h" +#include "srsran/phy/common/timestamp.h" +#include "srsran/phy/dft/dft.h" #include #include -#define SRSLTE_CHANNEL_FADING_MAXTAPS 9 -#define SRSLTE_CHANNEL_FADING_NTERMS 16 +#define SRSRAN_CHANNEL_FADING_MAXTAPS 9 +#define SRSRAN_CHANNEL_FADING_NTERMS 16 typedef enum { - srslte_channel_fading_model_none = 0, - srslte_channel_fading_model_epa, - srslte_channel_fading_model_eva, - srslte_channel_fading_model_etu, -} srslte_channel_fading_model_t; + srsran_channel_fading_model_none = 0, + srsran_channel_fading_model_epa, + srsran_channel_fading_model_eva, + srsran_channel_fading_model_etu, +} srsran_channel_fading_model_t; typedef struct { // Configuration parameters float srate; // Sampling rate: 1.92e6, 3.84e6, ..., 23.04e6, 30.72e6 - srslte_channel_fading_model_t model; // None, EPA, EVA, ETU + srsran_channel_fading_model_t model; // None, EPA, EVA, ETU float doppler; // Maximum doppler: 5, 70, 300 // Internal tap parametrisation @@ -40,14 +40,14 @@ typedef struct { uint32_t path_delay; // Path delay uint32_t state_len; // Length of the impulse response saved in the state - float coeff_alpha[SRSLTE_CHANNEL_FADING_MAXTAPS][SRSLTE_CHANNEL_FADING_NTERMS]; // Angle of arrival - float coeff_a[SRSLTE_CHANNEL_FADING_MAXTAPS][SRSLTE_CHANNEL_FADING_NTERMS]; // Random phase - float coeff_b[SRSLTE_CHANNEL_FADING_MAXTAPS][SRSLTE_CHANNEL_FADING_NTERMS]; // Random phase - cf_t* h_tap[SRSLTE_CHANNEL_FADING_MAXTAPS]; // Static tap signal in frequency domain + float coeff_alpha[SRSRAN_CHANNEL_FADING_MAXTAPS][SRSRAN_CHANNEL_FADING_NTERMS]; // Angle of arrival + float coeff_a[SRSRAN_CHANNEL_FADING_MAXTAPS][SRSRAN_CHANNEL_FADING_NTERMS]; // Random phase + float coeff_b[SRSRAN_CHANNEL_FADING_MAXTAPS][SRSRAN_CHANNEL_FADING_NTERMS]; // Random phase + cf_t* h_tap[SRSRAN_CHANNEL_FADING_MAXTAPS]; // Static tap signal in frequency domain // Utils - srslte_dft_plan_t fft; // DFT to frequency domain - srslte_dft_plan_t ifft; // DFT to time domain + srsran_dft_plan_t fft; // DFT to frequency domain + srsran_dft_plan_t ifft; // DFT to time domain cf_t* temp; // Temporal buffer, length fft_size cf_t* h_freq; // Channel frequency response, length fft_size cf_t* y_freq; // Intermediate frequency domain buffer @@ -55,17 +55,17 @@ typedef struct { // State variables cf_t* state; // To save impulse response of the filter -} srslte_channel_fading_t; +} srsran_channel_fading_t; #ifdef __cplusplus extern "C" { #endif -SRSLTE_API int srslte_channel_fading_init(srslte_channel_fading_t* q, double srate, const char* model, uint32_t seed); +SRSRAN_API int srsran_channel_fading_init(srsran_channel_fading_t* q, double srate, const char* model, uint32_t seed); -SRSLTE_API void srslte_channel_fading_free(srslte_channel_fading_t* q); +SRSRAN_API void srsran_channel_fading_free(srsran_channel_fading_t* q); -SRSLTE_API double srslte_channel_fading_execute(srslte_channel_fading_t* q, +SRSRAN_API double srsran_channel_fading_execute(srsran_channel_fading_t* q, const cf_t* in, cf_t* out, uint32_t nof_samples, @@ -75,4 +75,4 @@ SRSLTE_API double srslte_channel_fading_execute(srslte_channel_fading_t* q, } #endif -#endif // SRSLTE_FADING_H +#endif // SRSRAN_FADING_H diff --git a/lib/include/srslte/phy/channel/hst.h b/lib/include/srsran/phy/channel/hst.h similarity index 58% rename from lib/include/srslte/phy/channel/hst.h rename to lib/include/srsran/phy/channel/hst.h index 9b50741dc..8a4b8cfac 100644 --- a/lib/include/srslte/phy/channel/hst.h +++ b/lib/include/srsran/phy/channel/hst.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,11 +10,11 @@ * */ -#ifndef SRSLTE_HST_H_ -#define SRSLTE_HST_H_ +#ifndef SRSRAN_HST_H_ +#define SRSRAN_HST_H_ -#include "srslte/config.h" -#include "srslte/phy/common/timestamp.h" +#include "srsran/config.h" +#include "srsran/phy/common/timestamp.h" #include typedef struct { @@ -30,23 +30,23 @@ typedef struct { // State float fs_hz; // Last doppler dispersion [Hz] -} srslte_channel_hst_t; +} srsran_channel_hst_t; #ifdef __cplusplus extern "C" { #endif -SRSLTE_API int srslte_channel_hst_init(srslte_channel_hst_t* q, float fd_hz, float period_d, float init_time_s); +SRSRAN_API int srsran_channel_hst_init(srsran_channel_hst_t* q, float fd_hz, float period_d, float init_time_s); -SRSLTE_API void srslte_channel_hst_update_srate(srslte_channel_hst_t* q, uint32_t srate); +SRSRAN_API void srsran_channel_hst_update_srate(srsran_channel_hst_t* q, uint32_t srate); -SRSLTE_API void -srslte_channel_hst_execute(srslte_channel_hst_t* q, cf_t* in, cf_t* out, uint32_t len, const srslte_timestamp_t* ts); +SRSRAN_API void +srsran_channel_hst_execute(srsran_channel_hst_t* q, cf_t* in, cf_t* out, uint32_t len, const srsran_timestamp_t* ts); -SRSLTE_API void srslte_channel_hst_free(srslte_channel_hst_t* q); +SRSRAN_API void srsran_channel_hst_free(srsran_channel_hst_t* q); #ifdef __cplusplus } #endif -#endif // SRSLTE_HST_H_ +#endif // SRSRAN_HST_H_ diff --git a/lib/include/srslte/phy/channel/rlf.h b/lib/include/srsran/phy/channel/rlf.h similarity index 57% rename from lib/include/srslte/phy/channel/rlf.h rename to lib/include/srsran/phy/channel/rlf.h index 142e310b8..e106841b0 100644 --- a/lib/include/srslte/phy/channel/rlf.h +++ b/lib/include/srsran/phy/channel/rlf.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,34 +10,34 @@ * */ -#ifndef SRSLTE_RLF_H -#define SRSLTE_RLF_H +#ifndef SRSRAN_RLF_H +#define SRSRAN_RLF_H -#include "srslte/config.h" -#include "srslte/phy/common/timestamp.h" +#include "srsran/config.h" +#include "srsran/phy/common/timestamp.h" #include typedef struct { uint32_t t_on_ms; uint32_t t_off_ms; -} srslte_channel_rlf_t; +} srsran_channel_rlf_t; #ifdef __cplusplus extern "C" { #endif -SRSLTE_API void srslte_channel_rlf_init(srslte_channel_rlf_t* q, uint32_t t_on_ms, uint32_t t_off_ms); +SRSRAN_API void srsran_channel_rlf_init(srsran_channel_rlf_t* q, uint32_t t_on_ms, uint32_t t_off_ms); -SRSLTE_API void srslte_channel_rlf_execute(srslte_channel_rlf_t* q, +SRSRAN_API void srsran_channel_rlf_execute(srsran_channel_rlf_t* q, const cf_t* in, cf_t* out, uint32_t nsamples, - const srslte_timestamp_t* ts); + const srsran_timestamp_t* ts); -SRSLTE_API void srslte_channel_rlf_free(srslte_channel_rlf_t* q); +SRSRAN_API void srsran_channel_rlf_free(srsran_channel_rlf_t* q); #ifdef __cplusplus } #endif -#endif // SRSLTE_RLF_H +#endif // SRSRAN_RLF_H diff --git a/lib/include/srsran/phy/common/phy_common.h b/lib/include/srsran/phy/common/phy_common.h new file mode 100644 index 000000000..c3c5b8f41 --- /dev/null +++ b/lib/include/srsran/phy/common/phy_common.h @@ -0,0 +1,524 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +/********************************************************************************************** + * File: phy_common.h + * + * Description: Common parameters and lookup functions for PHY + * + * Reference: 3GPP TS 36.211 version 10.0.0 Release 10 + *********************************************************************************************/ + +#ifndef SRSRAN_PHY_COMMON_H +#define SRSRAN_PHY_COMMON_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#include "srsran/config.h" + +#define SRSRAN_NOF_SF_X_FRAME 10 +#define SRSRAN_NOF_SLOTS_PER_SF 2 +#define SRSRAN_NSLOTS_X_FRAME (SRSRAN_NOF_SLOTS_PER_SF * SRSRAN_NOF_SF_X_FRAME) + +#define SRSRAN_NSOFT_BITS 250368 // Soft buffer size for Category 1 UE + +#define SRSRAN_PC_MAX 23 // Maximum TX power for Category 1 UE (in dBm) + +#define SRSRAN_NOF_NID_1 (168) +#define SRSRAN_NOF_NID_2 (3) +#define SRSRAN_NUM_PCI (SRSRAN_NOF_NID_1 * SRSRAN_NOF_NID_2) + +#define SRSRAN_MAX_CARRIERS 5 // Maximum number of supported simultaneous carriers +#define SRSRAN_MAX_PORTS 4 +#define SRSRAN_MAX_CHANNELS (SRSRAN_MAX_CARRIERS * SRSRAN_MAX_PORTS) +#define SRSRAN_MAX_LAYERS 4 +#define SRSRAN_MAX_CODEWORDS 2 +#define SRSRAN_MAX_TB SRSRAN_MAX_CODEWORDS +#define SRSRAN_MAX_QM 8 + +#define SRSRAN_MAX_CODEBLOCKS 32 + +#define SRSRAN_MAX_CODEBOOKS 4 + +#define SRSRAN_NOF_CFI 3 +#define SRSRAN_CFI_ISVALID(x) ((x >= 1 && x <= 3)) +#define SRSRAN_CFI_IDX(x) ((x - 1) % SRSRAN_NOF_CFI) + +#define SRSRAN_LTE_CRC24A 0x1864CFB +#define SRSRAN_LTE_CRC24B 0X1800063 +#define SRSRAN_LTE_CRC24C 0X1B2B117 +#define SRSRAN_LTE_CRC16 0x11021 +#define SRSRAN_LTE_CRC11 0xE21 +#define SRSRAN_LTE_CRC8 0x19B +#define SRSRAN_LTE_CRC6 0x61 + +#define SRSRAN_MAX_MBSFN_AREA_IDS 256 +#define SRSRAN_PMCH_RV 0 + +typedef enum { SRSRAN_CP_NORM = 0, SRSRAN_CP_EXT } srsran_cp_t; +typedef enum { SRSRAN_SF_NORM = 0, SRSRAN_SF_MBSFN } srsran_sf_t; + +#define SRSRAN_INVALID_RNTI 0x0 // TS 36.321 - Table 7.1-1 RNTI 0x0 isn't a valid DL RNTI +#define SRSRAN_CRNTI_START 0x000B +#define SRSRAN_CRNTI_END 0xFFF3 +#define SRSRAN_RARNTI_START 0x0001 +#define SRSRAN_RARNTI_END 0x000A +#define SRSRAN_SIRNTI 0xFFFF +#define SRSRAN_PRNTI 0xFFFE +#define SRSRAN_MRNTI 0xFFFD + +#define SRSRAN_RNTI_ISRAR(rnti) (rnti >= SRSRAN_RARNTI_START && rnti <= SRSRAN_RARNTI_END) +#define SRSRAN_RNTI_ISUSER(rnti) (rnti >= SRSRAN_CRNTI_START && rnti <= SRSRAN_CRNTI_END) +#define SRSRAN_RNTI_ISSI(rnti) (rnti == SRSRAN_SIRNTI) +#define SRSRAN_RNTI_ISPA(rnti) (rnti == SRSRAN_PRNTI) +#define SRSRAN_RNTI_ISMBSFN(rnti) (rnti == SRSRAN_MRNTI) +#define SRSRAN_RNTI_ISSIRAPA(rnti) (SRSRAN_RNTI_ISSI(rnti) || SRSRAN_RNTI_ISRAR(rnti) || SRSRAN_RNTI_ISPA(rnti)) + +#define SRSRAN_CELL_ID_UNKNOWN 1000 + +#define SRSRAN_MAX_NSYMB 7 + +#define SRSRAN_MAX_PRB 110 +#define SRSRAN_NRE 12 + +#define SRSRAN_SYMBOL_SZ_MAX 2048 + +#define SRSRAN_CP_NORM_NSYMB 7 +#define SRSRAN_CP_NORM_SF_NSYMB (2 * SRSRAN_CP_NORM_NSYMB) +#define SRSRAN_CP_NORM_0_LEN 160 +#define SRSRAN_CP_NORM_LEN 144 + +#define SRSRAN_CP_EXT_NSYMB 6 +#define SRSRAN_CP_EXT_SF_NSYMB (2 * SRSRAN_CP_EXT_NSYMB) +#define SRSRAN_CP_EXT_LEN 512 +#define SRSRAN_CP_EXT_7_5_LEN 1024 + +#define SRSRAN_CP_ISNORM(cp) (cp == SRSRAN_CP_NORM) +#define SRSRAN_CP_ISEXT(cp) (cp == SRSRAN_CP_EXT) +#define SRSRAN_CP_NSYMB(cp) (SRSRAN_CP_ISNORM(cp) ? SRSRAN_CP_NORM_NSYMB : SRSRAN_CP_EXT_NSYMB) + +#define SRSRAN_CP_LEN(symbol_sz, c) ((int)ceilf((((float)(c) * (symbol_sz)) / 2048.0f))) +#define SRSRAN_CP_LEN_NORM(symbol, symbol_sz) \ + (((symbol) == 0) ? SRSRAN_CP_LEN((symbol_sz), SRSRAN_CP_NORM_0_LEN) : SRSRAN_CP_LEN((symbol_sz), SRSRAN_CP_NORM_LEN)) +#define SRSRAN_CP_LEN_EXT(symbol_sz) (SRSRAN_CP_LEN((symbol_sz), SRSRAN_CP_EXT_LEN)) + +#define SRSRAN_CP_SZ(symbol_sz, cp) \ + (SRSRAN_CP_LEN(symbol_sz, (SRSRAN_CP_ISNORM(cp) ? SRSRAN_CP_NORM_LEN : SRSRAN_CP_EXT_LEN))) +#define SRSRAN_SYMBOL_SZ(symbol_sz, cp) (symbol_sz + SRSRAN_CP_SZ(symbol_sz, cp)) +#define SRSRAN_SLOT_LEN(symbol_sz) (symbol_sz * 15 / 2) +#define SRSRAN_SF_LEN(symbol_sz) (symbol_sz * 15) +#define SRSRAN_SF_LEN_MAX (SRSRAN_SF_LEN(SRSRAN_SYMBOL_SZ_MAX)) + +#define SRSRAN_SLOT_LEN_PRB(nof_prb) (SRSRAN_SLOT_LEN(srsran_symbol_sz(nof_prb))) +#define SRSRAN_SF_LEN_PRB(nof_prb) ((uint32_t)SRSRAN_SF_LEN(srsran_symbol_sz(nof_prb))) + +#define SRSRAN_SLOT_LEN_RE(nof_prb, cp) (nof_prb * SRSRAN_NRE * SRSRAN_CP_NSYMB(cp)) +#define SRSRAN_SF_LEN_RE(nof_prb, cp) (2 * SRSRAN_SLOT_LEN_RE(nof_prb, cp)) +#define SRSRAN_NOF_RE(cell) (2 * SRSRAN_SLOT_LEN_RE(cell.nof_prb, cell.cp)) + +#define SRSRAN_TA_OFFSET (10e-6) + +#define SRSRAN_LTE_TS (1.0f / (15000.0f * 2048.0f)) + +#define SRSRAN_SLOT_IDX_CPNORM(symbol_idx, symbol_sz) \ + (symbol_idx == 0 ? 0 \ + : (symbol_sz + SRSRAN_CP_LEN(symbol_sz, SRSRAN_CP_NORM_0_LEN) + \ + (symbol_idx - 1) * (symbol_sz + SRSRAN_CP_LEN(symbol_sz, SRSRAN_CP_NORM_LEN)))) +#define SRSRAN_SLOT_IDX_CPEXT(idx, symbol_sz) (idx * (symbol_sz + SRSRAN_CP(symbol_sz, SRSRAN_CP_EXT_LEN))) + +#define SRSRAN_RE_IDX(nof_prb, symbol_idx, sample_idx) ((symbol_idx) * (nof_prb) * (SRSRAN_NRE) + sample_idx) + +#define SRSRAN_RS_VSHIFT(cell_id) (cell_id % 6) + +#define SRSRAN_GUARD_RE(nof_prb) ((srsran_symbol_sz(nof_prb) - nof_prb * SRSRAN_NRE) / 2) + +#define SRSRAN_SYMBOL_HAS_REF(l, cp, nof_ports) ((l == 1 && nof_ports == 4) || l == 0 || l == SRSRAN_CP_NSYMB(cp) - 3) + +#define SRSRAN_NOF_CTRL_SYMBOLS(cell, cfi) (cfi + (cell.nof_prb < 10 ? 1 : 0)) + +#define SRSRAN_SYMBOL_HAS_REF_MBSFN(l, s) ((l == 2 && s == 0) || (l == 0 && s == 1) || (l == 4 && s == 1)) + +#define SRSRAN_NON_MBSFN_REGION_GUARD_LENGTH(non_mbsfn_region, symbol_sz) \ + ((non_mbsfn_region == 1) \ + ? (SRSRAN_CP_LEN_EXT(symbol_sz) - SRSRAN_CP_LEN_NORM(0, symbol_sz)) \ + : (2 * SRSRAN_CP_LEN_EXT(symbol_sz) - SRSRAN_CP_LEN_NORM(0, symbol_sz) - SRSRAN_CP_LEN_NORM(1, symbol_sz))) + +#define SRSRAN_FDD_NOF_HARQ (FDD_HARQ_DELAY_DL_MS + FDD_HARQ_DELAY_UL_MS) +#define SRSRAN_MAX_HARQ_PROC 15 + +#define SRSRAN_NOF_LTE_BANDS 58 + +#define SRSRAN_DEFAULT_MAX_FRAMES_PBCH 500 +#define SRSRAN_DEFAULT_MAX_FRAMES_PSS 10 +#define SRSRAN_DEFAULT_NOF_VALID_PSS_FRAMES 10 + +#define ZERO_OBJECT(x) memset(&(x), 0x0, sizeof((x))) + +typedef enum SRSRAN_API { SRSRAN_PHICH_NORM = 0, SRSRAN_PHICH_EXT } srsran_phich_length_t; + +typedef enum SRSRAN_API { + SRSRAN_PHICH_R_1_6 = 0, + SRSRAN_PHICH_R_1_2, + SRSRAN_PHICH_R_1, + SRSRAN_PHICH_R_2 +} srsran_phich_r_t; + +/// LTE duplex modes. +typedef enum SRSRAN_API { + /// FDD uses frame structure type 1. + SRSRAN_FDD = 0, + /// TDD uses frame structure type 2. + SRSRAN_TDD = 1 +} srsran_frame_type_t; + +/// Maximum number of TDD special subframe configurations. +#define SRSRAN_MAX_TDD_SS_CONFIGS (10u) + +/// Maximum number of TDD uplink-downlink subframe configurations. +#define SRSRAN_MAX_TDD_SF_CONFIGS (7u) + +/// Configuration fields for operating in TDD mode. +typedef struct SRSRAN_API { + /// Uplink-downlink configuration, valid range is [0,SRSRAN_MAX_TDD_SF_CONFIGS[. + /// TS 36.211 v8.9.0 Table 4.2-2. + uint32_t sf_config; + /// Special subframe symbol length configuration, valid range is [0,SRSRAN_MAX_TDD_SS_CONFIGS[. + /// TS 36.211 v13.13.0 Table 4.2-1. + uint32_t ss_config; + /// Set to true when the fields have been configured, otherwise false. + bool configured; +} srsran_tdd_config_t; + +/// TDD uplink-downlink subframe types. +typedef enum SRSRAN_API { + /// Subframe is reserved for downlink transmissions. + SRSRAN_TDD_SF_D = 0, + /// Subframe is reserved for uplink transmissions. + SRSRAN_TDD_SF_U = 1, + /// Special subframe. + SRSRAN_TDD_SF_S = 2, +} srsran_tdd_sf_t; + +typedef struct { + uint8_t mbsfn_area_id; + uint8_t non_mbsfn_region_length; + uint8_t mbsfn_mcs; + bool enable; + bool is_mcch; +} srsran_mbsfn_cfg_t; + +// Common cell constant properties that require object reconfiguration +typedef struct SRSRAN_API { + uint32_t nof_prb; + uint32_t nof_ports; + uint32_t id; + srsran_cp_t cp; + srsran_phich_length_t phich_length; + srsran_phich_r_t phich_resources; + srsran_frame_type_t frame_type; +} srsran_cell_t; + +// Common downlink properties that may change every subframe +typedef struct SRSRAN_API { + srsran_tdd_config_t tdd_config; + uint32_t tti; + uint32_t cfi; + srsran_sf_t sf_type; + uint32_t non_mbsfn_region; +} srsran_dl_sf_cfg_t; + +typedef struct SRSRAN_API { + srsran_tdd_config_t tdd_config; + uint32_t tti; + bool shortened; +} srsran_ul_sf_cfg_t; + +typedef enum SRSRAN_API { + SRSRAN_TM1 = 0, + SRSRAN_TM2, + SRSRAN_TM3, + SRSRAN_TM4, + SRSRAN_TM5, + SRSRAN_TM6, + SRSRAN_TM7, + SRSRAN_TM8, + SRSRAN_TMINV // Invalid Transmission Mode +} srsran_tm_t; + +typedef enum SRSRAN_API { + SRSRAN_TXSCHEME_PORT0, + SRSRAN_TXSCHEME_DIVERSITY, + SRSRAN_TXSCHEME_SPATIALMUX, + SRSRAN_TXSCHEME_CDD +} srsran_tx_scheme_t; + +typedef enum SRSRAN_API { SRSRAN_MIMO_DECODER_ZF, SRSRAN_MIMO_DECODER_MMSE } srsran_mimo_decoder_t; + +/*! + * \brief Types of modulations and associated modulation order. + */ +typedef enum SRSRAN_API { + SRSRAN_MOD_BPSK = 0, /*!< \brief BPSK. */ + SRSRAN_MOD_QPSK, /*!< \brief QPSK. */ + SRSRAN_MOD_16QAM, /*!< \brief QAM16. */ + SRSRAN_MOD_64QAM, /*!< \brief QAM64. */ + SRSRAN_MOD_256QAM, /*!< \brief QAM256. */ + SRSRAN_MOD_NITEMS +} srsran_mod_t; + +typedef enum { + SRSRAN_DCI_FORMAT0 = 0, + SRSRAN_DCI_FORMAT1, + SRSRAN_DCI_FORMAT1A, + SRSRAN_DCI_FORMAT1B, + SRSRAN_DCI_FORMAT1C, + SRSRAN_DCI_FORMAT1D, + SRSRAN_DCI_FORMAT2, + SRSRAN_DCI_FORMAT2A, + SRSRAN_DCI_FORMAT2B, + // SRSRAN_DCI_FORMAT3, + // SRSRAN_DCI_FORMAT3A, + SRSRAN_DCI_FORMATN0, + SRSRAN_DCI_FORMATN1, + SRSRAN_DCI_FORMATN2, + SRSRAN_DCI_FORMAT_RAR, // Not a real LTE format. Used internally to indicate RAR grant + SRSRAN_DCI_NOF_FORMATS +} srsran_dci_format_t; + +typedef enum { + SRSRAN_PUCCH_ACK_NACK_FEEDBACK_MODE_NORMAL = 0, /* No cell selection no pucch3 */ + SRSRAN_PUCCH_ACK_NACK_FEEDBACK_MODE_CS, + SRSRAN_PUCCH_ACK_NACK_FEEDBACK_MODE_PUCCH3, + SRSRAN_PUCCH_ACK_NACK_FEEDBACK_MODE_ERROR, +} srsran_ack_nack_feedback_mode_t; + +typedef struct SRSRAN_API { + int id; + float fd; +} srsran_earfcn_t; + +enum band_geographical_area { + SRSRAN_BAND_GEO_AREA_ALL, + SRSRAN_BAND_GEO_AREA_NAR, + SRSRAN_BAND_GEO_AREA_APAC, + SRSRAN_BAND_GEO_AREA_EMEA, + SRSRAN_BAND_GEO_AREA_JAPAN, + SRSRAN_BAND_GEO_AREA_CALA, + SRSRAN_BAND_GEO_AREA_NA +}; + +///< NB-IoT specific structs +typedef enum { + SRSRAN_NBIOT_MODE_INBAND_SAME_PCI = 0, + SRSRAN_NBIOT_MODE_INBAND_DIFFERENT_PCI, + SRSRAN_NBIOT_MODE_GUARDBAND, + SRSRAN_NBIOT_MODE_STANDALONE, + SRSRAN_NBIOT_MODE_N_ITEMS, +} srsran_nbiot_mode_t; + +typedef struct SRSRAN_API { + srsran_cell_t base; // the umbrella or super cell + uint32_t nbiot_prb; // the index of the NB-IoT PRB within the cell + uint32_t n_id_ncell; + uint32_t nof_ports; // The number of antenna ports for NB-IoT + bool is_r14; // Whether the cell is a R14 cell + srsran_nbiot_mode_t mode; +} srsran_nbiot_cell_t; + +#define SRSRAN_NBIOT_MAX_PORTS 2 +#define SRSRAN_NBIOT_MAX_CODEWORDS SRSRAN_MAX_CODEWORDS + +#define SRSRAN_SF_LEN_PRB_NBIOT (SRSRAN_SF_LEN_PRB(1)) + +#define SRSRAN_SF_LEN_RE_NBIOT (SRSRAN_SF_LEN_RE(1, SRSRAN_CP_NORM)) + +#define SRSRAN_NBIOT_FFT_SIZE 128 +#define SRSRAN_NBIOT_FREQ_SHIFT_FACTOR ((float)-0.5) +#define SRSRAN_NBIOT_NUM_RX_ANTENNAS 1 +#define SRSRAN_NBIOT_MAX_PRB 1 + +#define SRSRAN_NBIOT_DEFAULT_NUM_PRB_BASECELL 1 +#define SRSRAN_NBIOT_DEFAULT_PRB_OFFSET 0 + +#define SRSRAN_DEFAULT_MAX_FRAMES_NPBCH 500 +#define SRSRAN_DEFAULT_MAX_FRAMES_NPSS 20 +#define SRSRAN_DEFAULT_NOF_VALID_NPSS_FRAMES 20 + +#define SRSRAN_NBIOT_NPBCH_NOF_TOTAL_BITS (1600) ///< Number of bits for the entire NPBCH (See 36.211 Sec 10.2.4.1) +#define SRSRAN_NBIOT_NPBCH_NOF_BITS_SF \ + (SRSRAN_NBIOT_NPBCH_NOF_TOTAL_BITS / 8) ///< The NPBCH is transmitted in 8 blocks (See 36.211 Sec 10.2.4.4) + +#define SRSRAN_MAX_DL_BITS_CAT_NB1 (680) ///< TS 36.306 v15.4.0 Table 4.1C-1 + +///< PHY common function declarations + +SRSRAN_API bool srsran_cell_isvalid(srsran_cell_t* cell); + +SRSRAN_API void srsran_cell_fprint(FILE* stream, srsran_cell_t* cell, uint32_t sfn); + +SRSRAN_API bool srsran_cellid_isvalid(uint32_t cell_id); + +SRSRAN_API bool srsran_nofprb_isvalid(uint32_t nof_prb); + +/** + * Returns the subframe type for a given subframe number and a TDD configuration. + * Check TS 36.211 v8.9.0 Table 4.2-2. + * + * @param tdd_config TDD configuration. + * @param sf_idx Subframe number, must be in range [0,SRSRAN_NOF_SF_X_FRAME[. + * @return Returns the subframe type. + */ +SRSRAN_API srsran_tdd_sf_t srsran_sfidx_tdd_type(srsran_tdd_config_t tdd_config, uint32_t sf_idx); + +/** + * Returns the number of UpPTS symbols in a subframe. + * Check TS 36.211 v13.13.0 Table 4.2-1. + * + * @param tdd_config TDD configuration. + * @return Returns the number of UpPTS symbols. + */ +SRSRAN_API uint32_t srsran_sfidx_tdd_nof_up(srsran_tdd_config_t tdd_config); + +/** + * Returns the number of GP symbols in a subframe. + * Check TS 36.211 v13.13.0 Table 4.2-1. + * + * @param tdd_config TDD configuration. + * @return Returns the number of GP symbols. + */ +SRSRAN_API uint32_t srsran_sfidx_tdd_nof_gp(srsran_tdd_config_t tdd_config); + +/** + * Returns the number of DwPTS symbols in a subframe. + * Check TS 36.211 v13.13.0 Table 4.2-1. + * + * @param tdd_config TDD configuration. + * @return Returns the number of DwPTS symbols. + */ +SRSRAN_API uint32_t srsran_sfidx_tdd_nof_dw(srsran_tdd_config_t tdd_config); + +SRSRAN_API uint32_t srsran_tdd_nof_harq(srsran_tdd_config_t tdd_config); + +SRSRAN_API uint32_t srsran_sfidx_tdd_nof_dw_slot(srsran_tdd_config_t tdd_config, uint32_t slot, srsran_cp_t cp); + +SRSRAN_API bool srsran_sfidx_isvalid(uint32_t sf_idx); + +SRSRAN_API bool srsran_portid_isvalid(uint32_t port_id); + +SRSRAN_API bool srsran_N_id_2_isvalid(uint32_t N_id_2); + +SRSRAN_API bool srsran_N_id_1_isvalid(uint32_t N_id_1); + +SRSRAN_API bool srsran_symbol_sz_isvalid(uint32_t symbol_sz); + +SRSRAN_API int srsran_symbol_sz(uint32_t nof_prb); + +SRSRAN_API int srsran_symbol_sz_power2(uint32_t nof_prb); + +SRSRAN_API int srsran_nof_prb(uint32_t symbol_sz); + +SRSRAN_API uint32_t srsran_max_cce(uint32_t nof_prb); + +SRSRAN_API int srsran_sampling_freq_hz(uint32_t nof_prb); + +SRSRAN_API void srsran_use_standard_symbol_size(bool enabled); + +SRSRAN_API bool srsran_symbol_size_is_standard(); + +SRSRAN_API uint32_t srsran_re_x_prb(uint32_t ns, uint32_t symbol, uint32_t nof_ports, uint32_t nof_symbols); + +SRSRAN_API uint32_t srsran_voffset(uint32_t symbol_id, uint32_t cell_id, uint32_t nof_ports); + +SRSRAN_API int srsran_group_hopping_f_gh(uint32_t f_gh[SRSRAN_NSLOTS_X_FRAME], uint32_t cell_id); + +SRSRAN_API uint32_t srsran_N_ta_new_rar(uint32_t ta); + +SRSRAN_API uint32_t srsran_N_ta_new(uint32_t N_ta_old, uint32_t ta); + +SRSRAN_API float srsran_coderate(uint32_t tbs, uint32_t nof_re); + +SRSRAN_API char* srsran_cp_string(srsran_cp_t cp); + +SRSRAN_API srsran_mod_t srsran_str2mod(const char* mod_str); + +SRSRAN_API char* srsran_mod_string(srsran_mod_t mod); + +SRSRAN_API uint32_t srsran_mod_bits_x_symbol(srsran_mod_t mod); + +SRSRAN_API uint8_t srsran_band_get_band(uint32_t dl_earfcn); + +SRSRAN_API bool srsran_band_is_tdd(uint32_t band); + +SRSRAN_API double srsran_band_fd(uint32_t dl_earfcn); + +SRSRAN_API double srsran_band_fu(uint32_t ul_earfcn); + +SRSRAN_API uint32_t srsran_band_ul_earfcn(uint32_t dl_earfcn); + +SRSRAN_API int +srsran_band_get_fd_band(uint32_t band, srsran_earfcn_t* earfcn, int earfcn_start, int earfcn_end, uint32_t max_elems); + +SRSRAN_API int srsran_band_get_fd_band_all(uint32_t band, srsran_earfcn_t* earfcn, uint32_t max_nelems); + +SRSRAN_API int +srsran_band_get_fd_region(enum band_geographical_area region, srsran_earfcn_t* earfcn, uint32_t max_elems); + +SRSRAN_API int srsran_str2mimotype(char* mimo_type_str, srsran_tx_scheme_t* type); + +SRSRAN_API char* srsran_mimotype2str(srsran_tx_scheme_t mimo_type); + +/* Returns the interval tti1-tti2 mod 10240 */ +SRSRAN_API uint32_t srsran_tti_interval(uint32_t tti1, uint32_t tti2); + +SRSRAN_API uint32_t srsran_print_check(char* s, size_t max_len, uint32_t cur_len, const char* format, ...); + +SRSRAN_API bool srsran_nbiot_cell_isvalid(srsran_nbiot_cell_t* cell); +SRSRAN_API bool srsran_nbiot_portid_isvalid(uint32_t port_id); +SRSRAN_API float srsran_band_fu_nbiot(uint32_t ul_earfcn, const float m_ul); + +SRSRAN_API char* srsran_nbiot_mode_string(srsran_nbiot_mode_t mode); + +/** + * Returns a constant string pointer with the ACK/NACK feedback mode + * + * @param ack_nack_feedback_mode Mode + * @return Returns constant pointer with the text of the mode if succesful, `error` otherwise + */ +SRSRAN_API const char* srsran_ack_nack_feedback_mode_string(srsran_ack_nack_feedback_mode_t ack_nack_feedback_mode); + +/** + * Returns a constant string pointer with the ACK/NACK feedback mode + * + * @param ack_nack_feedback_mode Mode + * @return Returns constant pointer with the text of the mode if succesful, `error` otherwise + */ +SRSRAN_API srsran_ack_nack_feedback_mode_t srsran_string_ack_nack_feedback_mode(const char* str); + +/** + * Returns the number of bits for Rank Indicador reporting depending on the cell + * + * @param cell + */ +SRSRAN_API uint32_t srsran_ri_nof_bits(const srsran_cell_t* cell); + +#ifdef __cplusplus +} +#endif + +#endif // SRSRAN_PHY_COMMON_H diff --git a/lib/include/srslte/phy/common/phy_common_nr.h b/lib/include/srsran/phy/common/phy_common_nr.h similarity index 63% rename from lib/include/srslte/phy/common/phy_common_nr.h rename to lib/include/srsran/phy/common/phy_common_nr.h index c358adbeb..a3d8ee7c8 100644 --- a/lib/include/srslte/phy/common/phy_common_nr.h +++ b/lib/include/srsran/phy/common/phy_common_nr.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,8 +10,8 @@ * */ -#ifndef SRSLTE_PHY_COMMON_NR_H -#define SRSLTE_PHY_COMMON_NR_H +#ifndef SRSRAN_PHY_COMMON_NR_H +#define SRSRAN_PHY_COMMON_NR_H #include "phy_common.h" #include @@ -23,220 +23,220 @@ extern "C" { /** * @brief Defines the number of symbols per slot. Defined by TS 38.211 v15.8.0 Table 4.3.2-1. */ -#define SRSLTE_NSYMB_PER_SLOT_NR 14U +#define SRSRAN_NSYMB_PER_SLOT_NR 14U /** * @brief Defines the resource grid size in physical resource elements (frequency and time domain) */ -#define SRSLTE_SLOT_LEN_RE_NR(nof_prb) (nof_prb * SRSLTE_NRE * SRSLTE_NSYMB_PER_SLOT_NR) +#define SRSRAN_SLOT_LEN_RE_NR(nof_prb) (nof_prb * SRSRAN_NRE * SRSRAN_NSYMB_PER_SLOT_NR) -#define SRSLTE_SLOT_MAX_LEN_RE_NR (SRSLTE_SLOT_LEN_RE_NR(SRSLTE_MAX_PRB_NR)) -#define SRSLTE_SLOT_MAX_NOF_BITS_NR (SRSLTE_SLOT_MAX_LEN_RE_NR * SRSLTE_MAX_QM) -#define SRSLTE_MAX_LAYERS_NR 8 +#define SRSRAN_SLOT_MAX_LEN_RE_NR (SRSRAN_SLOT_LEN_RE_NR(SRSRAN_MAX_PRB_NR)) +#define SRSRAN_SLOT_MAX_NOF_BITS_NR (SRSRAN_SLOT_MAX_LEN_RE_NR * SRSRAN_MAX_QM) +#define SRSRAN_MAX_LAYERS_NR 8 /** * @brief Defines the maximum numerology supported. Defined by TS 38.211 v15.8.0 Table 4.3.2-1. */ -#define SRSLTE_NR_MAX_NUMEROLOGY 4U +#define SRSRAN_NR_MAX_NUMEROLOGY 4U /** * @brief Defines the symbol duration, including cyclic prefix */ -#define SRSLTE_SUBC_SPACING_NR(NUM) (15000U << (NUM)) +#define SRSRAN_SUBC_SPACING_NR(NUM) (15000U << (NUM)) /** * @brief Defines the number of slots per SF. Defined by TS 38.211 v15.8.0 Table 4.3.2-1. */ -#define SRSLTE_NSLOTS_PER_SF_NR(NUM) (1U << (NUM)) +#define SRSRAN_NSLOTS_PER_SF_NR(NUM) (1U << (NUM)) /** * @brief Defines the number of slots per frame. Defined by TS 38.211 v15.8.0 Table 4.3.2-1. */ -#define SRSLTE_NSLOTS_PER_FRAME_NR(NUM) (SRSLTE_NSLOTS_PER_SF_NR(NUM) * SRSLTE_NOF_SF_X_FRAME) +#define SRSRAN_NSLOTS_PER_FRAME_NR(NUM) (SRSRAN_NSLOTS_PER_SF_NR(NUM) * SRSRAN_NOF_SF_X_FRAME) /** * @brief Bounds slot index into the frame */ -#define SRSLTE_SLOT_NR_MOD(NUM, N) ((N) % SRSLTE_NSLOTS_PER_FRAME_NR(NUM)) +#define SRSRAN_SLOT_NR_MOD(NUM, N) ((N) % SRSRAN_NSLOTS_PER_FRAME_NR(NUM)) /** * @brief Maximum Carrier identification value. Defined by TS 38.331 v15.10.0 as PhysCellId from 0 to 1007. */ -#define SRSLTE_MAX_ID_NR 1007 +#define SRSRAN_MAX_ID_NR 1007 /** * @brief Maximum number of physical resource blocks (PRB) that a 5G NR can have. This is defined by TS 38.331 v15.10.0 * as maxNrofPhysicalResourceBlocks */ -#define SRSLTE_MAX_PRB_NR 275 +#define SRSRAN_MAX_PRB_NR 275 /** * @brief Maximum start sub-carrier index for the carrier relative point */ -#define SRSLTE_MAX_START_NR 2199 +#define SRSRAN_MAX_START_NR 2199 /** * @brief defines the maximum number of Aggregation levels: 1, 2, 4, 8 and 16 */ -#define SRSLTE_SEARCH_SPACE_NOF_AGGREGATION_LEVELS_NR 5 +#define SRSRAN_SEARCH_SPACE_NOF_AGGREGATION_LEVELS_NR 5 /** * @brief defines the maximum number of RE */ -#define SRSLTE_PDCCH_MAX_RE ((SRSLTE_NRE - 3U) * (1U << (SRSLTE_SEARCH_SPACE_NOF_AGGREGATION_LEVELS_NR - 1U)) * 6U) +#define SRSRAN_PDCCH_MAX_RE ((SRSRAN_NRE - 3U) * (1U << (SRSRAN_SEARCH_SPACE_NOF_AGGREGATION_LEVELS_NR - 1U)) * 6U) /** * @brief defines the maximum number of candidates for a given search-space and aggregation level according to TS 38.331 * SearchSpace sequence */ -#define SRSLTE_SEARCH_SPACE_MAX_NOF_CANDIDATES_NR 8 +#define SRSRAN_SEARCH_SPACE_MAX_NOF_CANDIDATES_NR 8 /** * @brief defines the maximum number of monitored PDCCH candidates per slot and per serving cell according to TS 38.213 * Table 10.1-2 */ -#define SRSLTE_MAX_NOF_CANDIDATES_SLOT_NR 44 +#define SRSRAN_MAX_NOF_CANDIDATES_SLOT_NR 44 /** * @brief defines the maximum number of resource elements per PRB * @remark Defined in TS 38.214 V15.10.0 5.1.3.2 Transport block size determination, point 1, second bullet */ -#define SRSLTE_MAX_NRE_NR 156 +#define SRSRAN_MAX_NRE_NR 156 /** * @brief defines the maximum number of resource elements in a PDSCH transmission * @remark deduced from in TS 36.214 V15.10.0 5.1.3.2 Transport block size determination */ -#define SRSLTE_PDSCH_MAX_RE_NR (SRSLTE_MAX_NRE_NR * SRSLTE_MAX_PRB_NR) +#define SRSRAN_PDSCH_MAX_RE_NR (SRSRAN_MAX_NRE_NR * SRSRAN_MAX_PRB_NR) /** * @brief Maximum number of PDSCH time domain resource allocations. This is defined by TS 38.331 v15.10.0 * as maxNrofDL-Allocations */ -#define SRSLTE_MAX_NOF_DL_ALLOCATION 16 +#define SRSRAN_MAX_NOF_DL_ALLOCATION 16 /** * @brief Maximum dl-DataToUL-ACK value. This is defined by TS 38.331 v15.10.1 in PUCCH-Config */ -#define SRSLTE_MAX_NOF_DL_DATA_TO_UL 8 +#define SRSRAN_MAX_NOF_DL_DATA_TO_UL 8 -typedef enum SRSLTE_API { - srslte_coreset_mapping_type_non_interleaved = 0, - srslte_coreset_mapping_type_interleaved, -} srslte_coreset_mapping_type_t; +typedef enum SRSRAN_API { + srsran_coreset_mapping_type_non_interleaved = 0, + srsran_coreset_mapping_type_interleaved, +} srsran_coreset_mapping_type_t; -typedef enum SRSLTE_API { - srslte_coreset_bundle_size_n2 = 0, - srslte_coreset_bundle_size_n3, - srslte_coreset_bundle_size_n6, -} srslte_coreset_bundle_size_t; +typedef enum SRSRAN_API { + srsran_coreset_bundle_size_n2 = 0, + srsran_coreset_bundle_size_n3, + srsran_coreset_bundle_size_n6, +} srsran_coreset_bundle_size_t; -typedef enum SRSLTE_API { - srslte_coreset_precoder_granularity_contiguous = 0, - srslte_coreset_precoder_granularity_reg_bundle -} srslte_coreset_precoder_granularity_t; +typedef enum SRSRAN_API { + srsran_coreset_precoder_granularity_contiguous = 0, + srsran_coreset_precoder_granularity_reg_bundle +} srsran_coreset_precoder_granularity_t; /** * @brief PDSCH mapping type * @remark Described in TS 38.331 V15.10.0 Section PDSCH-TimeDomainResourceAllocationList */ -typedef enum SRSLTE_API { srslte_sch_mapping_type_A = 0, srslte_sch_mapping_type_B } srslte_sch_mapping_type_t; +typedef enum SRSRAN_API { srsran_sch_mapping_type_A = 0, srsran_sch_mapping_type_B } srsran_sch_mapping_type_t; /** * @brief Search spaces * @remark Described in TS 38.213 V15.10.0 Section 10.1 UE procedure for determining physical downlink control channel * assignment */ -typedef enum SRSLTE_API { - srslte_search_space_type_common_0 = 0, ///< configured by pdcch-ConfigSIB1 in MIB or by searchSpaceSIB1 in +typedef enum SRSRAN_API { + srsran_search_space_type_common_0 = 0, ///< configured by pdcch-ConfigSIB1 in MIB or by searchSpaceSIB1 in ///< PDCCH-ConfigCommon or by searchSpaceZero in PDCCH-ConfigCommon - srslte_search_space_type_common_0A, ///< configured by searchSpaceOtherSystemInformation in PDCCH-ConfigCommon - srslte_search_space_type_common_1, ///< configured by ra-SearchSpace in PDCCH-ConfigCommon - srslte_search_space_type_common_2, ///< configured by pagingSearchSpace in PDCCH-ConfigCommon - srslte_search_space_type_common_3, ///< configured by SearchSpace in PDCCH-Config with searchSpaceType = common - srslte_search_space_type_ue, ///< configured by SearchSpace in PDCCH-Config with searchSpaceType = ue-Specific - srslte_search_space_type_rar, ///< Indicates that a grant was given by MAC RAR as described in TS 38.213 clause 8.2 - srslte_search_space_type_cg ///< Indicates that a grant was given by Configured Grant from the upper layers -} srslte_search_space_type_t; + srsran_search_space_type_common_0A, ///< configured by searchSpaceOtherSystemInformation in PDCCH-ConfigCommon + srsran_search_space_type_common_1, ///< configured by ra-SearchSpace in PDCCH-ConfigCommon + srsran_search_space_type_common_2, ///< configured by pagingSearchSpace in PDCCH-ConfigCommon + srsran_search_space_type_common_3, ///< configured by SearchSpace in PDCCH-Config with searchSpaceType = common + srsran_search_space_type_ue, ///< configured by SearchSpace in PDCCH-Config with searchSpaceType = ue-Specific + srsran_search_space_type_rar, ///< Indicates that a grant was given by MAC RAR as described in TS 38.213 clause 8.2 + srsran_search_space_type_cg ///< Indicates that a grant was given by Configured Grant from the upper layers +} srsran_search_space_type_t; /** * @brief Helper macro to get if a search space type is common or not */ -#define SRSLTE_SEARCH_SPACE_IS_COMMON(SS_TYPE) ((SS_TYPE) < srslte_search_space_type_ue) +#define SRSRAN_SEARCH_SPACE_IS_COMMON(SS_TYPE) ((SS_TYPE) < srsran_search_space_type_ue) /** * @brief RAR content length in bits (see TS 38.321 Sec 6.2.3) */ -#define SRSLTE_RAR_UL_GRANT_NBITS (27) +#define SRSRAN_RAR_UL_GRANT_NBITS (27) /** * @brief Indicates the MCS table the UE shall use for PDSCH and/or PUSCH without transform precoding */ -typedef enum SRSLTE_API { - srslte_mcs_table_64qam = 0, - srslte_mcs_table_256qam, - srslte_mcs_table_qam64LowSE, - srslte_mcs_table_N -} srslte_mcs_table_t; +typedef enum SRSRAN_API { + srsran_mcs_table_64qam = 0, + srsran_mcs_table_256qam, + srsran_mcs_table_qam64LowSE, + srsran_mcs_table_N +} srsran_mcs_table_t; /** * @brief RNTI types * @remark Usage described in TS 38.321 Table 7.1-2: RNTI usage. */ -typedef enum SRSLTE_API { - srslte_rnti_type_c = 0, - srslte_rnti_type_p, ///< @brief Paging and System Information change notification (PCH) - srslte_rnti_type_si, ///< @brief Broadcast of System Information (DL-SCH) - srslte_rnti_type_ra, ///< @brief Random Access Response (DL-SCH) - srslte_rnti_type_tc, ///< @brief Contention Resolution (when no valid C-RNTI is available) (DL-SCH) - srslte_rnti_type_cs, ///< @brief Configured scheduled unicast transmission (DL-SCH, UL-SCH) - srslte_rnti_type_sp_csi, ///< @brief Activation of Semi-persistent CSI reporting on PUSCH - srslte_rnti_type_mcs_c, ///< @brief Dynamically scheduled unicast transmission (DL-SCH) -} srslte_rnti_type_t; +typedef enum SRSRAN_API { + srsran_rnti_type_c = 0, + srsran_rnti_type_p, ///< @brief Paging and System Information change notification (PCH) + srsran_rnti_type_si, ///< @brief Broadcast of System Information (DL-SCH) + srsran_rnti_type_ra, ///< @brief Random Access Response (DL-SCH) + srsran_rnti_type_tc, ///< @brief Contention Resolution (when no valid C-RNTI is available) (DL-SCH) + srsran_rnti_type_cs, ///< @brief Configured scheduled unicast transmission (DL-SCH, UL-SCH) + srsran_rnti_type_sp_csi, ///< @brief Activation of Semi-persistent CSI reporting on PUSCH + srsran_rnti_type_mcs_c, ///< @brief Dynamically scheduled unicast transmission (DL-SCH) +} srsran_rnti_type_t; /** * @brief DCI formats * @remark Described in TS 38.212 V15.9.0 Section 7.3.1 DCI formats */ -typedef enum SRSLTE_API { - srslte_dci_format_nr_0_0 = 0, ///< @brief Scheduling of PUSCH in one cell - srslte_dci_format_nr_0_1, ///< @brief Scheduling of PUSCH in one cell - srslte_dci_format_nr_1_0, ///< @brief Scheduling of PDSCH in one cell - srslte_dci_format_nr_1_1, ///< @brief Scheduling of PDSCH in one cell - srslte_dci_format_nr_2_0, ///< @brief Notifying a group of UEs of the slot format - srslte_dci_format_nr_2_1, ///< @brief Notifying a group of UEs of the PRB(s) and OFDM symbol(s) where UE may assume no +typedef enum SRSRAN_API { + srsran_dci_format_nr_0_0 = 0, ///< @brief Scheduling of PUSCH in one cell + srsran_dci_format_nr_0_1, ///< @brief Scheduling of PUSCH in one cell + srsran_dci_format_nr_1_0, ///< @brief Scheduling of PDSCH in one cell + srsran_dci_format_nr_1_1, ///< @brief Scheduling of PDSCH in one cell + srsran_dci_format_nr_2_0, ///< @brief Notifying a group of UEs of the slot format + srsran_dci_format_nr_2_1, ///< @brief Notifying a group of UEs of the PRB(s) and OFDM symbol(s) where UE may assume no ///< transmission is intended for the UE - srslte_dci_format_nr_2_2, ///< @brief Transmission of TPC commands for PUCCH and PUSCH - srslte_dci_format_nr_2_3, ///< @brief Transmission of a group of TPC commands for SRS transmissions by one or more UEs - srslte_dci_format_nr_rar, ///< @brief Scheduling a transmission of PUSCH from RAR - srslte_dci_format_nr_cg ///< @brief Scheduling of PUSCH using a configured grant -} srslte_dci_format_nr_t; + srsran_dci_format_nr_2_2, ///< @brief Transmission of TPC commands for PUCCH and PUSCH + srsran_dci_format_nr_2_3, ///< @brief Transmission of a group of TPC commands for SRS transmissions by one or more UEs + srsran_dci_format_nr_rar, ///< @brief Scheduling a transmission of PUSCH from RAR + srsran_dci_format_nr_cg ///< @brief Scheduling of PUSCH using a configured grant +} srsran_dci_format_nr_t; /** * @brief Overhead configuration provided by higher layers * @remark Described in TS 38.331 V15.10.0 PDSCH-ServingCellConfig * @remark Described in TS 38.331 V15.10.0 PUSCH-ServingCellConfig */ -typedef enum SRSLTE_API { - srslte_xoverhead_0 = 0, - srslte_xoverhead_6, - srslte_xoverhead_12, - srslte_xoverhead_18 -} srslte_xoverhead_t; +typedef enum SRSRAN_API { + srsran_xoverhead_0 = 0, + srsran_xoverhead_6, + srsran_xoverhead_12, + srsran_xoverhead_18 +} srsran_xoverhead_t; /** * @brief PDSCH HARQ ACK codebook configuration * @remark Described in TS 38.331 V15.10.0 PhysicalCellGroupConfig */ -typedef enum SRSLTE_API { - srslte_pdsch_harq_ack_codebook_none = 0, - srslte_pdsch_harq_ack_codebook_semi_static, - srslte_pdsch_harq_ack_codebook_dynamic, -} srslte_pdsch_harq_ack_codebook_t; +typedef enum SRSRAN_API { + srsran_pdsch_harq_ack_codebook_none = 0, + srsran_pdsch_harq_ack_codebook_semi_static, + srsran_pdsch_harq_ack_codebook_dynamic, +} srsran_pdsch_harq_ack_codebook_t; /** * @brief NR carrier parameters. It is a combination of fixed cell and bandwidth-part (BWP) */ -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { uint32_t id; uint32_t numerology; uint32_t nof_prb; @@ -245,94 +245,94 @@ typedef struct SRSLTE_API { ///< of this serving cell. (see TS 38.212 [17], clause 5.4.2.1). UL: Indicates the maximum ///< MIMO layer to be used for PUSCH in all BWPs of the normal UL of this serving cell (see ///< TS 38.212 [17], clause 5.4.2.1) -} srslte_carrier_nr_t; +} srsran_carrier_nr_t; /** * @brief NR Slot parameters. It contains parameters that change in a slot basis. */ -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { /// Slot index in the radio frame uint32_t idx; /// Left for future parameters /// ... -} srslte_slot_cfg_t; +} srsran_slot_cfg_t; /** * @brief Min number of OFDM symbols in a control resource set. */ -#define SRSLTE_CORESET_DURATION_MIN 1 +#define SRSRAN_CORESET_DURATION_MIN 1 /** * @brief Max number of OFDM symbols in a control resource set. Specified in TS 38.331 V15.10.0 as maxCoReSetDuration */ -#define SRSLTE_CORESET_DURATION_MAX 3 +#define SRSRAN_CORESET_DURATION_MAX 3 /** * @brief Number of possible CORESET frequency resources. */ -#define SRSLTE_CORESET_FREQ_DOMAIN_RES_SIZE 45 +#define SRSRAN_CORESET_FREQ_DOMAIN_RES_SIZE 45 /** * @brief Max value for shift index */ -#define SRSLTE_CORESET_SHIFT_INDEX_MAX (SRSLTE_CORESET_NOF_PRB_MAX - 1) +#define SRSRAN_CORESET_SHIFT_INDEX_MAX (SRSRAN_CORESET_NOF_PRB_MAX - 1) /** * @brief CORESET parameters as defined in TS 38.331 V15.10.0 - ControlResourceSet */ -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { uint32_t id; uint32_t coreset_id; - srslte_coreset_mapping_type_t mapping_type; + srsran_coreset_mapping_type_t mapping_type; uint32_t duration; - bool freq_resources[SRSLTE_CORESET_FREQ_DOMAIN_RES_SIZE]; - srslte_coreset_bundle_size_t interleaver_size; + bool freq_resources[SRSRAN_CORESET_FREQ_DOMAIN_RES_SIZE]; + srsran_coreset_bundle_size_t interleaver_size; bool dmrs_scrambling_id_present; uint32_t dmrs_scrambling_id; - srslte_coreset_precoder_granularity_t precoder_granularity; - srslte_coreset_bundle_size_t reg_bundle_size; + srsran_coreset_precoder_granularity_t precoder_granularity; + srsran_coreset_bundle_size_t reg_bundle_size; uint32_t shift_index; /** Missing TCI parameters */ -} srslte_coreset_t; +} srsran_coreset_t; /** * @brief SearchSpace parameters as defined in TS 38.331 v15.10.0 SearchSpace sequence */ -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { uint32_t id; uint32_t coreset_id; uint32_t duration; // in slots - srslte_search_space_type_t type; - uint32_t nof_candidates[SRSLTE_SEARCH_SPACE_NOF_AGGREGATION_LEVELS_NR]; -} srslte_search_space_t; + srsran_search_space_type_t type; + uint32_t nof_candidates[SRSRAN_SEARCH_SPACE_NOF_AGGREGATION_LEVELS_NR]; +} srsran_search_space_t; /** * @brief TDD pattern configuration */ -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { uint32_t period_ms; ///< Period in milliseconds, set to 0 if not present uint32_t nof_dl_slots; ///< Number of consecutive full DL slots at the beginning of each DL-UL pattern uint32_t nof_dl_symbols; ///< Number of consecutive DL symbols in the beginning of the slot following the last DL slot uint32_t nof_ul_slots; ///< Number of consecutive full UL slots at the end of each DL-UL pattern uint32_t nof_ul_symbols; ///< Number of consecutive UL symbols in the end of the slot preceding the first full UL slot -} srslte_tdd_pattern_t; +} srsran_tdd_pattern_t; /** * @brief TDD configuration as described in TS 38.331 v15.10.0 TDD-UL-DL-ConfigCommon */ -typedef struct SRSLTE_API { - srslte_tdd_pattern_t pattern1; - srslte_tdd_pattern_t pattern2; -} srslte_tdd_config_nr_t; +typedef struct SRSRAN_API { + srsran_tdd_pattern_t pattern1; + srsran_tdd_pattern_t pattern2; +} srsran_tdd_config_nr_t; /** * @brief Get the RNTI type name for NR * @param rnti_type RNTI type name * @return Constant string with the RNTI type name */ -SRSLTE_API const char* srslte_rnti_type_str(srslte_rnti_type_t rnti_type); +SRSRAN_API const char* srsran_rnti_type_str(srsran_rnti_type_t rnti_type); /** * @brief Calculates the bandwidth of a given CORESET in physical resource blocks (PRB) . This function uses the @@ -344,7 +344,7 @@ SRSLTE_API const char* srslte_rnti_type_str(srslte_rnti_type_t rnti_type); * @param coreset provides the given CORESET configuration * @return The number of PRB that the CORESET takes in frequency domain */ -SRSLTE_API uint32_t srslte_coreset_get_bw(const srslte_coreset_t* coreset); +SRSRAN_API uint32_t srsran_coreset_get_bw(const srsran_coreset_t* coreset); /** * @brief Calculates the number of Physical Resource Elements (time and frequency domain) that a given CORESET uses. @@ -356,28 +356,28 @@ SRSLTE_API uint32_t srslte_coreset_get_bw(const srslte_coreset_t* coreset); * @param coreset provides the given CORESET configuration * @return The number of resource elements that compose the coreset */ -SRSLTE_API uint32_t srslte_coreset_get_sz(const srslte_coreset_t* coreset); +SRSRAN_API uint32_t srsran_coreset_get_sz(const srsran_coreset_t* coreset); /** * @brief Get the NR PDSCH mapping type in string * @param mapping_type Mapping type * @return Constant string with PDSCH mapping type */ -SRSLTE_API const char* srslte_sch_mapping_type_to_str(srslte_sch_mapping_type_t mapping_type); +SRSRAN_API const char* srsran_sch_mapping_type_to_str(srsran_sch_mapping_type_t mapping_type); /** * @brief Get the MCS table string * @param mcs_table MCS table value * @return Constant string with the MCS table name */ -SRSLTE_API const char* srslte_mcs_table_to_str(srslte_mcs_table_t mcs_table); +SRSRAN_API const char* srsran_mcs_table_to_str(srsran_mcs_table_t mcs_table); /** * @brief Get the MCS table value from a string * @param str Points to a given string * @return The MCS table value */ -SRSLTE_API srslte_mcs_table_t srslte_mcs_table_from_str(const char* str); +SRSRAN_API srsran_mcs_table_t srsran_mcs_table_from_str(const char* str); /** * @brief Computes the minimum valid symbol size for a given amount of PRB @@ -385,7 +385,7 @@ SRSLTE_API srslte_mcs_table_t srslte_mcs_table_from_str(const char* str); * @param nof_prb Number of PRB * @return The minimum valid FFT size if the number of PRB is in range, 0 otherwise */ -SRSLTE_API uint32_t srslte_min_symbol_sz_rb(uint32_t nof_prb); +SRSRAN_API uint32_t srsran_min_symbol_sz_rb(uint32_t nof_prb); /** * @brief Computes the time in seconds between two symbols in a slot @@ -396,7 +396,7 @@ SRSLTE_API uint32_t srslte_min_symbol_sz_rb(uint32_t nof_prb); * @param numerology NR Carrier numerology * @return Returns the time in seconds between the two symbols if the condition above is satisfied, 0 seconds otherwise */ -SRSLTE_API float srslte_symbol_distance_s(uint32_t l0, uint32_t l1, uint32_t numerology); +SRSRAN_API float srsran_symbol_distance_s(uint32_t l0, uint32_t l1, uint32_t numerology); /** * @brief Decides whether a given slot is configured as Downlink @@ -405,7 +405,7 @@ SRSLTE_API float srslte_symbol_distance_s(uint32_t l0, uint32_t l1, uint32_t num * @param slot_idx Slot index in the frame for the given numerology * @return true if the provided slot index is configured for Downlink */ -SRSLTE_API bool srslte_tdd_nr_is_dl(const srslte_tdd_config_nr_t* cfg, uint32_t numerology, uint32_t slot_idx); +SRSRAN_API bool srsran_tdd_nr_is_dl(const srsran_tdd_config_nr_t* cfg, uint32_t numerology, uint32_t slot_idx); /** * @brief Decides whether a given slot is configured as Uplink @@ -414,10 +414,10 @@ SRSLTE_API bool srslte_tdd_nr_is_dl(const srslte_tdd_config_nr_t* cfg, uint32_t * @param slot_idx Slot index in the frame for the given numerology * @return true if the provided slot index is configured for Uplink */ -SRSLTE_API bool srslte_tdd_nr_is_ul(const srslte_tdd_config_nr_t* cfg, uint32_t numerology, uint32_t slot_idx); +SRSRAN_API bool srsran_tdd_nr_is_ul(const srsran_tdd_config_nr_t* cfg, uint32_t numerology, uint32_t slot_idx); #ifdef __cplusplus } #endif -#endif // SRSLTE_PHY_COMMON_NR_H +#endif // SRSRAN_PHY_COMMON_NR_H diff --git a/lib/include/srsran/phy/common/phy_common_sl.h b/lib/include/srsran/phy/common/phy_common_sl.h new file mode 100644 index 000000000..db30dd7a4 --- /dev/null +++ b/lib/include/srsran/phy/common/phy_common_sl.h @@ -0,0 +1,167 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +/********************************************************************************************** + * File: phy_common_sl.h + * + * Description: Common parameters and lookup functions for Sidelink PHY + * + * Reference: 3GPP TS 36.211 version 15.3.0 Release 15 + *********************************************************************************************/ + +#ifndef SRSRAN_PHY_COMMON_SL_H +#define SRSRAN_PHY_COMMON_SL_H + +/** + * \brief Common parameters and lookup functions for Sidelink PHY + */ + +#include "srsran/phy/common/phy_common.h" + +typedef enum SRSRAN_API { + SRSRAN_SIDELINK_TM1 = 0, + SRSRAN_SIDELINK_TM2, + SRSRAN_SIDELINK_TM3, + SRSRAN_SIDELINK_TM4 +} srsran_sl_tm_t; + +typedef enum SRSRAN_API { + SRSRAN_SIDELINK_PSBCH = 0, // Physical Sidelink Broadcast Channel + SRSRAN_SIDELINK_PSCCH, // Physical Sidelink Control Channel + SRSRAN_SIDELINK_PSSCH, // Physical Sidelink Shared Channel + SRSRAN_SIDELINK_PSDCH // Physical Sidelink Discovery Channel +} srsran_sl_channels_t; + +typedef struct SRSRAN_API { + srsran_sl_tm_t tm; + uint32_t N_sl_id; + uint32_t nof_prb; + srsran_cp_t cp; +} srsran_cell_sl_t; + +#define SRSRAN_SL_MAX_PERIOD_LENGTH 320 // SL-PeriodComm-r12 3GPP TS 36.331 Section 6.3.8 +// SL-CommResourcePool: 3GPP TS 36.331 version 15.6.0 Release 15 Section 6.3.8 +typedef struct SRSRAN_API { + uint32_t period_length; + + uint32_t prb_num; + uint32_t prb_start; + uint32_t prb_end; + + uint8_t pscch_sf_bitmap[SRSRAN_SL_MAX_PERIOD_LENGTH]; + uint8_t pssch_sf_bitmap[SRSRAN_SL_MAX_PERIOD_LENGTH]; + + uint32_t size_sub_channel; // sizeSubchannel-r14 + uint32_t num_sub_channel; // numSubchannel-r14 + uint32_t start_prb_sub_channel; // startRB-Subchannel-r14 offset + bool adjacency_pscch_pssch; // adjacencyPSCCH-PSSCH-r14 + + uint32_t sf_bitmap_tm34_len; + uint8_t sf_bitmap_tm34[SRSRAN_SL_MAX_PERIOD_LENGTH]; // sl_Subframe_r14: 3GPP 36.331 Section 6.3.8 +} srsran_sl_comm_resource_pool_t; + +typedef enum SRSRAN_API { + SRSRAN_SIDELINK_DATA_SYMBOL = 0, + SRSRAN_SIDELINK_SYNC_SYMBOL, + SRSRAN_SIDELINK_DMRS_SYMBOL, + SRSRAN_SIDELINK_GUARD_SYMBOL +} srsran_sl_symbol_t; + +#define SRSRAN_SL_DUPLEX_MODE_FDD (1) +#define SRSRAN_SL_DUPLEX_MODE_TDD (2) + +#define SRSRAN_SLSS_SIDE_PEAK_OFFSET (0.005f) +#define SRSRAN_SLSS_SIDE_PEAK_THRESHOLD_HIGH (0.49f) // square(0.7), max 70% of main peak +#define SRSRAN_SLSS_SIDE_PEAK_THRESHOLD_LOW (0.09f) // square(0.3), min 30% of main peak + +#define SRSRAN_PSBCH_NOF_PRB (6) +#define SRSRAN_PSCCH_TM34_NOF_PRB (2) + +#define SRSRAN_MIB_SL_LEN (40) // TM1/2: 40 bits +#define SRSRAN_MIB_SL_V2X_LEN (48) // TM3/4: 48 bits +#define SRSRAN_MIB_SL_MAX_LEN (SRSRAN_MIB_SL_V2X_LEN) + +#define SRSRAN_SL_TM12_DEFAULT_NUM_DMRS_SYMBOLS (2) +#define SRSRAN_SL_TM34_DEFAULT_NUM_DMRS_SYMBOLS (4) ///< In TM3/4, all channels have 4 DMRS by default + +#define SRSRAN_PSBCH_TM12_NUM_DATA_SYMBOLS (8) // PSBCH is in 8 OFDM symbols (but only 7 are tx'ed) +#define SRSRAN_PSBCH_TM12_NUM_DATA_SYMBOLS_EXT \ + (6) // PSBCH is in 7 OFDM symbols for extended cyclic prefix (but only 6 are tx'ed) +#define SRSRAN_PSBCH_TM12_NUM_DMRS_SYMBOLS (2) ///< PSBCH has 2 DMRS symbols +#define SRSRAN_PSBCH_TM12_NUM_SYNC_SYMBOLS (4) ///< Two symbols PSSS and two SSSS + +#define SRSRAN_PSBCH_TM34_NUM_DATA_SYMBOLS (7) ///< SL-BCH is in 7 OFDM symbols (but only 6 are tx'ed) +#define SRSRAN_PSBCH_TM34_NUM_DMRS_SYMBOLS (3) ///< PSBCH has 3 DMRS symbols in TM3 and TM4 +#define SRSRAN_PSBCH_TM34_NUM_SYNC_SYMBOLS (4) ///< Two symbols PSSS and two SSSS + +#define SRSRAN_SCI_CRC_LEN (16) +#define SRSRAN_SCI_MAX_LEN (45) +#define SRSRAN_SCI_TM34_LEN (32) + +#define SRSRAN_PSCCH_QM 2 +#define SRSRAN_PSCCH_TM12_NOF_PRB (1) +#define SRSRAN_PSCCH_TM34_NOF_PRB (2) +#define SRSRAN_PSCCH_MAX_NOF_PRB (SRSRAN_PSCCH_TM34_NOF_PRB) +#define SRSRAN_PSCCH_SCRAMBLING_SEED (510) ///< Scrambling seed for PSCCH is 510 + +#define SRSRAN_PSCCH_TM12_NUM_DATA_SYMBOLS (12) +#define SRSRAN_PSCCH_TM12_NUM_DMRS_SYMBOLS (2) +#define SRSRAN_PSCCH_TM12_NUM_DATA_SYMBOLS_EXT (10) + +#define SRSRAN_PSCCH_TM34_NUM_DATA_SYMBOLS (10) +#define SRSRAN_PSCCH_TM34_NUM_DMRS_SYMBOLS (4) + +#define SRSRAN_PSCCH_TM12_NOF_CODED_BITS \ + (SRSRAN_NRE * SRSRAN_PSCCH_TM12_NUM_DATA_SYMBOLS * SRSRAN_PSCCH_TM12_NOF_PRB * SRSRAN_PSCCH_QM) +#define SRSRAN_PSCCH_TM34_NOF_CODED_BITS \ + (SRSRAN_NRE * SRSRAN_PSCCH_TM34_NUM_DATA_SYMBOLS * SRSRAN_PSCCH_TM34_NOF_PRB * SRSRAN_PSCCH_QM) +#define SRSRAN_PSCCH_MAX_CODED_BITS SRSRAN_MAX(SRSRAN_PSCCH_TM12_NOF_CODED_BITS, SRSRAN_PSCCH_TM34_NOF_CODED_BITS) + +#define SRSRAN_PSSCH_MAX_QM 6 +#define SRSRAN_PSSCH_CRC_LEN 24 +#define SRSRAN_MAX_CODEWORD_LEN 168000 // 12 subcarriers * 100 PRB * 14 symbols * 10 bits, assuming 1024QAM +#define SRSRAN_SL_SCH_MAX_TB_LEN (48936) // 3GPP 36.306 v15.4.0 Table 4.1B-1 +#define SRSRAN_PSSCH_MAX_CODED_BITS (3 * SRSRAN_TCOD_MAX_LEN_CB + SRSRAN_TCOD_TOTALTAIL) + +#define SRSRAN_PSSCH_TM12_NUM_DATA_SYMBOLS (12) // PSSCH is in 12 OFDM symbols (but only 11 are tx'ed) +#define SRSRAN_PSSCH_TM12_NUM_DMRS_SYMBOLS (2) // PSSCH has 2 DMRS symbols in TM1 and TM2 + +#define SRSRAN_PSSCH_TM12_NUM_DATA_SYMBOLS_CP_EXT \ + (10) // PSSCH is in 10 OFDM symbols for extended cyclic prefix (but only 9 are tx'ed) +#define SRSRAN_PSSCH_TM12_NUM_DMRS_SYMBOLS_CP_EXT \ + (2) // PSSCH has 2 DMRS symbols for extended cyclic prefix in TM1 and TM2 + +#define SRSRAN_PSSCH_TM34_NUM_DATA_SYMBOLS (10) // PSSCH is in 10 OFDM symbols (but only 9 are tx'ed) +#define SRSRAN_PSSCH_TM34_NUM_DMRS_SYMBOLS (4) // PSSCH has 4 DMRS symbols in TM3 and TM4 + +SRSRAN_API int srsran_sl_group_hopping_f_gh(uint32_t f_gh[SRSRAN_NSLOTS_X_FRAME * 2], uint32_t N_x_id); +#define SRSRAN_PSCCH_MAX_NUM_DATA_SYMBOLS (SRSRAN_PSCCH_TM12_NUM_DATA_SYMBOLS) + +SRSRAN_API bool srsran_slss_side_peak_pos_is_valid(uint32_t side_peak_pos, + uint32_t main_peak_pos, + uint32_t side_peak_delta_a, + uint32_t side_peak_delta_b); +SRSRAN_API bool srsran_slss_side_peak_value_is_valid(float side_peak_value, float threshold_low, float threshold_high); + +SRSRAN_API int srsran_sl_tm_to_cell_sl_tm_t(srsran_cell_sl_t* q, uint32_t tm); + +SRSRAN_API uint32_t srsran_sl_get_num_symbols(srsran_sl_tm_t tm, srsran_cp_t cp); +SRSRAN_API bool srsran_psbch_is_symbol(srsran_sl_symbol_t type, srsran_sl_tm_t tm, uint32_t i, srsran_cp_t cp); +SRSRAN_API bool srsran_pscch_is_symbol(srsran_sl_symbol_t type, srsran_sl_tm_t tm, uint32_t i, srsran_cp_t cp); +SRSRAN_API bool srsran_pssch_is_symbol(srsran_sl_symbol_t type, srsran_sl_tm_t tm, uint32_t i, srsran_cp_t cp); + +SRSRAN_API uint32_t srsran_sci_format0_sizeof(uint32_t nof_prb); + +SRSRAN_API int srsran_sl_comm_resource_pool_get_default_config(srsran_sl_comm_resource_pool_t* q, + srsran_cell_sl_t cell); + +#endif // SRSRAN_PHY_COMMON_SL_H \ No newline at end of file diff --git a/lib/include/srslte/phy/common/sequence.h b/lib/include/srsran/phy/common/sequence.h similarity index 65% rename from lib/include/srslte/phy/common/sequence.h rename to lib/include/srsran/phy/common/sequence.h index 7a0ed0074..ee01f446d 100644 --- a/lib/include/srslte/phy/common/sequence.h +++ b/lib/include/srsran/phy/common/sequence.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -19,26 +19,26 @@ * Reference: 3GPP TS 36.211 version 10.0.0 Release 10 Sec. 7.2 *********************************************************************************************/ -#ifndef SRSLTE_SEQUENCE_H -#define SRSLTE_SEQUENCE_H +#ifndef SRSRAN_SEQUENCE_H +#define SRSRAN_SEQUENCE_H -#include "srslte/config.h" -#include "srslte/phy/common/phy_common.h" +#include "srsran/config.h" +#include "srsran/phy/common/phy_common.h" -#define SRSLTE_SEQUENCE_MOD(X) ((uint32_t)((X) & (uint64_t)INT32_MAX)) +#define SRSRAN_SEQUENCE_MOD(X) ((uint32_t)((X) & (uint64_t)INT32_MAX)) -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { uint32_t x1; uint32_t x2; -} srslte_sequence_state_t; +} srsran_sequence_state_t; -SRSLTE_API void srslte_sequence_state_init(srslte_sequence_state_t* s, uint32_t seed); +SRSRAN_API void srsran_sequence_state_init(srsran_sequence_state_t* s, uint32_t seed); -SRSLTE_API void srslte_sequence_state_gen_f(srslte_sequence_state_t* s, float value, float* out, uint32_t length); +SRSRAN_API void srsran_sequence_state_gen_f(srsran_sequence_state_t* s, float value, float* out, uint32_t length); -SRSLTE_API void srslte_sequence_state_advance(srslte_sequence_state_t* s, uint32_t length); +SRSRAN_API void srsran_sequence_state_advance(srsran_sequence_state_t* s, uint32_t length); -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { uint8_t* c; uint8_t* c_bytes; float* c_float; @@ -46,38 +46,38 @@ typedef struct SRSLTE_API { int8_t* c_char; uint32_t cur_len; uint32_t max_len; -} srslte_sequence_t; +} srsran_sequence_t; -SRSLTE_API int srslte_sequence_init(srslte_sequence_t* q, uint32_t len); +SRSRAN_API int srsran_sequence_init(srsran_sequence_t* q, uint32_t len); -SRSLTE_API void srslte_sequence_free(srslte_sequence_t* q); +SRSRAN_API void srsran_sequence_free(srsran_sequence_t* q); -SRSLTE_API int srslte_sequence_LTE_pr(srslte_sequence_t* q, uint32_t len, uint32_t seed); +SRSRAN_API int srsran_sequence_LTE_pr(srsran_sequence_t* q, uint32_t len, uint32_t seed); -SRSLTE_API int srslte_sequence_set_LTE_pr(srslte_sequence_t* q, uint32_t len, uint32_t seed); +SRSRAN_API int srsran_sequence_set_LTE_pr(srsran_sequence_t* q, uint32_t len, uint32_t seed); -SRSLTE_API void srslte_sequence_apply_f(const float* in, float* out, uint32_t length, uint32_t seed); +SRSRAN_API void srsran_sequence_apply_f(const float* in, float* out, uint32_t length, uint32_t seed); -SRSLTE_API void srslte_sequence_apply_s(const int16_t* in, int16_t* out, uint32_t length, uint32_t seed); +SRSRAN_API void srsran_sequence_apply_s(const int16_t* in, int16_t* out, uint32_t length, uint32_t seed); -SRSLTE_API void srslte_sequence_apply_c(const int8_t* in, int8_t* out, uint32_t length, uint32_t seed); +SRSRAN_API void srsran_sequence_apply_c(const int8_t* in, int8_t* out, uint32_t length, uint32_t seed); -SRSLTE_API void srslte_sequence_apply_packed(const uint8_t* in, uint8_t* out, uint32_t length, uint32_t seed); +SRSRAN_API void srsran_sequence_apply_packed(const uint8_t* in, uint8_t* out, uint32_t length, uint32_t seed); -SRSLTE_API void srslte_sequence_apply_bit(const uint8_t* in, uint8_t* out, uint32_t length, uint32_t seed); +SRSRAN_API void srsran_sequence_apply_bit(const uint8_t* in, uint8_t* out, uint32_t length, uint32_t seed); -SRSLTE_API int srslte_sequence_pbch(srslte_sequence_t* seq, srslte_cp_t cp, uint32_t cell_id); +SRSRAN_API int srsran_sequence_pbch(srsran_sequence_t* seq, srsran_cp_t cp, uint32_t cell_id); -SRSLTE_API int srslte_sequence_pcfich(srslte_sequence_t* seq, uint32_t nslot, uint32_t cell_id); +SRSRAN_API int srsran_sequence_pcfich(srsran_sequence_t* seq, uint32_t nslot, uint32_t cell_id); -SRSLTE_API int srslte_sequence_phich(srslte_sequence_t* seq, uint32_t nslot, uint32_t cell_id); +SRSRAN_API int srsran_sequence_phich(srsran_sequence_t* seq, uint32_t nslot, uint32_t cell_id); -SRSLTE_API int srslte_sequence_pdcch(srslte_sequence_t* seq, uint32_t nslot, uint32_t cell_id, uint32_t len); +SRSRAN_API int srsran_sequence_pdcch(srsran_sequence_t* seq, uint32_t nslot, uint32_t cell_id, uint32_t len); -SRSLTE_API int -srslte_sequence_pdsch(srslte_sequence_t* seq, uint16_t rnti, int q, uint32_t nslot, uint32_t cell_id, uint32_t len); +SRSRAN_API int +srsran_sequence_pdsch(srsran_sequence_t* seq, uint16_t rnti, int q, uint32_t nslot, uint32_t cell_id, uint32_t len); -SRSLTE_API void srslte_sequence_pdsch_apply_pack(const uint8_t* in, +SRSRAN_API void srsran_sequence_pdsch_apply_pack(const uint8_t* in, uint8_t* out, uint16_t rnti, int q, @@ -85,7 +85,7 @@ SRSLTE_API void srslte_sequence_pdsch_apply_pack(const uint8_t* in, uint32_t cell_id, uint32_t len); -SRSLTE_API void srslte_sequence_pdsch_apply_f(const float* in, +SRSRAN_API void srsran_sequence_pdsch_apply_f(const float* in, float* out, uint16_t rnti, int q, @@ -93,7 +93,7 @@ SRSLTE_API void srslte_sequence_pdsch_apply_f(const float* in, uint32_t cell_id, uint32_t len); -SRSLTE_API void srslte_sequence_pdsch_apply_s(const int16_t* in, +SRSRAN_API void srsran_sequence_pdsch_apply_s(const int16_t* in, int16_t* out, uint16_t rnti, int q, @@ -101,7 +101,7 @@ SRSLTE_API void srslte_sequence_pdsch_apply_s(const int16_t* in, uint32_t cell_id, uint32_t len); -SRSLTE_API void srslte_sequence_pdsch_apply_c(const int8_t* in, +SRSRAN_API void srsran_sequence_pdsch_apply_c(const int8_t* in, int8_t* out, uint16_t rnti, int q, @@ -109,42 +109,42 @@ SRSLTE_API void srslte_sequence_pdsch_apply_c(const int8_t* in, uint32_t cell_id, uint32_t len); -SRSLTE_API int -srslte_sequence_pusch(srslte_sequence_t* seq, uint16_t rnti, uint32_t nslot, uint32_t cell_id, uint32_t len); +SRSRAN_API int +srsran_sequence_pusch(srsran_sequence_t* seq, uint16_t rnti, uint32_t nslot, uint32_t cell_id, uint32_t len); -SRSLTE_API void srslte_sequence_pusch_apply_pack(const uint8_t* in, +SRSRAN_API void srsran_sequence_pusch_apply_pack(const uint8_t* in, uint8_t* out, uint16_t rnti, uint32_t nslot, uint32_t cell_id, uint32_t len); -SRSLTE_API void srslte_sequence_pusch_apply_c(const int8_t* in, +SRSRAN_API void srsran_sequence_pusch_apply_c(const int8_t* in, int8_t* out, uint16_t rnti, uint32_t nslot, uint32_t cell_id, uint32_t len); -SRSLTE_API void srslte_sequence_pusch_apply_s(const int16_t* in, +SRSRAN_API void srsran_sequence_pusch_apply_s(const int16_t* in, int16_t* out, uint16_t rnti, uint32_t nslot, uint32_t cell_id, uint32_t len); -SRSLTE_API void -srslte_sequence_pusch_gen_unpack(uint8_t* out, uint16_t rnti, uint32_t nslot, uint32_t cell_id, uint32_t len); +SRSRAN_API void +srsran_sequence_pusch_gen_unpack(uint8_t* out, uint16_t rnti, uint32_t nslot, uint32_t cell_id, uint32_t len); -SRSLTE_API int srslte_sequence_pucch(srslte_sequence_t* seq, uint16_t rnti, uint32_t nslot, uint32_t cell_id); +SRSRAN_API int srsran_sequence_pucch(srsran_sequence_t* seq, uint16_t rnti, uint32_t nslot, uint32_t cell_id); -SRSLTE_API int srslte_sequence_pmch(srslte_sequence_t* seq, uint32_t nslot, uint32_t mbsfn_id, uint32_t len); +SRSRAN_API int srsran_sequence_pmch(srsran_sequence_t* seq, uint32_t nslot, uint32_t mbsfn_id, uint32_t len); -SRSLTE_API int srslte_sequence_npbch(srslte_sequence_t* seq, srslte_cp_t cp, uint32_t cell_id); +SRSRAN_API int srsran_sequence_npbch(srsran_sequence_t* seq, srsran_cp_t cp, uint32_t cell_id); -SRSLTE_API int srslte_sequence_npbch_r14(srslte_sequence_t* seq, uint32_t n_id_ncell, uint32_t nf); +SRSRAN_API int srsran_sequence_npbch_r14(srsran_sequence_t* seq, uint32_t n_id_ncell, uint32_t nf); -SRSLTE_API int srslte_sequence_npdsch(srslte_sequence_t* seq, +SRSRAN_API int srsran_sequence_npdsch(srsran_sequence_t* seq, uint16_t rnti, int q, uint32_t nf, @@ -152,17 +152,17 @@ SRSLTE_API int srslte_sequence_npdsch(srslte_sequence_t* seq, uint32_t cell_id, uint32_t len); -SRSLTE_API int srslte_sequence_npdsch_bcch_r14(srslte_sequence_t* seq, uint32_t nf, uint32_t n_id_ncell, uint32_t len); +SRSRAN_API int srsran_sequence_npdsch_bcch_r14(srsran_sequence_t* seq, uint32_t nf, uint32_t n_id_ncell, uint32_t len); -SRSLTE_API int srslte_sequence_npdcch(srslte_sequence_t* seq, uint32_t nslot, uint32_t cell_id, uint32_t len); +SRSRAN_API int srsran_sequence_npdcch(srsran_sequence_t* seq, uint32_t nslot, uint32_t cell_id, uint32_t len); -SRSLTE_API int srslte_sequence_npusch(srslte_sequence_t* seq, +SRSRAN_API int srsran_sequence_npusch(srsran_sequence_t* seq, uint16_t rnti, uint32_t nf, uint32_t nslot, uint32_t cell_id, uint32_t len); -SRSLTE_API int srslte_sequence_nprach(srslte_sequence_t* seq, uint32_t cell_id); +SRSRAN_API int srsran_sequence_nprach(srsran_sequence_t* seq, uint32_t cell_id); -#endif // SRSLTE_SEQUENCE_H +#endif // SRSRAN_SEQUENCE_H diff --git a/lib/include/srslte/phy/common/timestamp.h b/lib/include/srsran/phy/common/timestamp.h similarity index 53% rename from lib/include/srslte/phy/common/timestamp.h rename to lib/include/srsran/phy/common/timestamp.h index 524b2bece..5a089a76a 100644 --- a/lib/include/srslte/phy/common/timestamp.h +++ b/lib/include/srsran/phy/common/timestamp.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -20,45 +20,45 @@ * Reference: *********************************************************************************************/ -#ifndef SRSLTE_TIMESTAMP_H -#define SRSLTE_TIMESTAMP_H +#ifndef SRSRAN_TIMESTAMP_H +#define SRSRAN_TIMESTAMP_H -#include "srslte/config.h" +#include "srsran/config.h" #include #include #include -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { time_t full_secs; double frac_secs; -} srslte_timestamp_t; +} srsran_timestamp_t; #ifdef __cplusplus extern "C" { #endif -SRSLTE_API int srslte_timestamp_init(srslte_timestamp_t* t, time_t full_secs, double frac_secs); +SRSRAN_API int srsran_timestamp_init(srsran_timestamp_t* t, time_t full_secs, double frac_secs); -SRSLTE_API void srslte_timestamp_init_uint64(srslte_timestamp_t* ts_time, uint64_t ts_count, double base_srate); +SRSRAN_API void srsran_timestamp_init_uint64(srsran_timestamp_t* ts_time, uint64_t ts_count, double base_srate); -SRSLTE_API int srslte_timestamp_copy(srslte_timestamp_t* dest, srslte_timestamp_t* src); +SRSRAN_API int srsran_timestamp_copy(srsran_timestamp_t* dest, srsran_timestamp_t* src); -SRSLTE_API int srslte_timestamp_compare(const srslte_timestamp_t* a, const srslte_timestamp_t* b); +SRSRAN_API int srsran_timestamp_compare(const srsran_timestamp_t* a, const srsran_timestamp_t* b); -SRSLTE_API int srslte_timestamp_add(srslte_timestamp_t* t, time_t full_secs, double frac_secs); +SRSRAN_API int srsran_timestamp_add(srsran_timestamp_t* t, time_t full_secs, double frac_secs); -SRSLTE_API int srslte_timestamp_sub(srslte_timestamp_t* t, time_t full_secs, double frac_secs); +SRSRAN_API int srsran_timestamp_sub(srsran_timestamp_t* t, time_t full_secs, double frac_secs); -SRSLTE_API double srslte_timestamp_real(const srslte_timestamp_t* t); +SRSRAN_API double srsran_timestamp_real(const srsran_timestamp_t* t); -SRSLTE_API bool srslte_timestamp_iszero(const srslte_timestamp_t* t); +SRSRAN_API bool srsran_timestamp_iszero(const srsran_timestamp_t* t); -SRSLTE_API uint32_t srslte_timestamp_uint32(srslte_timestamp_t* t); +SRSRAN_API uint32_t srsran_timestamp_uint32(srsran_timestamp_t* t); -SRSLTE_API uint64_t srslte_timestamp_uint64(const srslte_timestamp_t* t, double srate); +SRSRAN_API uint64_t srsran_timestamp_uint64(const srsran_timestamp_t* t, double srate); #ifdef __cplusplus } #endif -#endif // SRSLTE_TIMESTAMP_H +#endif // SRSRAN_TIMESTAMP_H diff --git a/lib/include/srslte/phy/common/zc_sequence.h b/lib/include/srsran/phy/common/zc_sequence.h similarity index 68% rename from lib/include/srslte/phy/common/zc_sequence.h rename to lib/include/srsran/phy/common/zc_sequence.h index 66c71ef89..87a58ffb4 100644 --- a/lib/include/srslte/phy/common/zc_sequence.h +++ b/lib/include/srsran/phy/common/zc_sequence.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,22 +10,22 @@ * */ -#ifndef SRSLTE_ZC_SEQUENCE_H -#define SRSLTE_ZC_SEQUENCE_H +#ifndef SRSRAN_ZC_SEQUENCE_H +#define SRSRAN_ZC_SEQUENCE_H -#include "srslte/config.h" +#include "srsran/config.h" #include #include /** * @brief Defines the maximum number of ZC sequence groups (u) */ -#define SRSLTE_ZC_SEQUENCE_NOF_GROUPS 30 +#define SRSRAN_ZC_SEQUENCE_NOF_GROUPS 30 /** * @brief Defines the maximum number of base sequences (v) */ -#define SRSLTE_ZC_SEQUENCE_NOF_BASE 2 +#define SRSRAN_ZC_SEQUENCE_NOF_BASE 2 /** * @brief Generates ZC sequences given the required parameters used in the TS 36 series (LTE) @@ -37,9 +37,9 @@ * @param[in] alpha Phase shift * @param[in] nof_prb Number of PRB * @param[out] sequence Output sequence - * @return SRSLTE_SUCCESS if the generation is successful, SRSLTE_ERROR code otherwise + * @return SRSRAN_SUCCESS if the generation is successful, SRSRAN_ERROR code otherwise */ -SRSLTE_API int srslte_zc_sequence_generate_lte(uint32_t u, uint32_t v, float alpha, uint32_t nof_prb, cf_t* sequence); +SRSRAN_API int srsran_zc_sequence_generate_lte(uint32_t u, uint32_t v, float alpha, uint32_t nof_prb, cf_t* sequence); /** * @brief Generates ZC sequences given the required parameters used in the TS 38 series (NR) @@ -52,19 +52,19 @@ SRSLTE_API int srslte_zc_sequence_generate_lte(uint32_t u, uint32_t v, float alp * @param m Number of PRB * @param delta Delta parameter described in specification * @param sequence Output sequence - * @return SRSLTE_SUCCESS if the generation is successful, SRSLTE_ERROR code otherwise + * @return SRSRAN_SUCCESS if the generation is successful, SRSRAN_ERROR code otherwise */ -SRSLTE_API int -srslte_zc_sequence_generate_nr(uint32_t u, uint32_t v, float alpha, uint32_t m, uint32_t delta, cf_t* sequence); +SRSRAN_API int +srsran_zc_sequence_generate_nr(uint32_t u, uint32_t v, float alpha, uint32_t m, uint32_t delta, cf_t* sequence); /** * @brief Low-PAPR ZC sequence look-up-table */ -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { uint32_t M_zc; uint32_t nof_alphas; - cf_t* sequence[SRSLTE_ZC_SEQUENCE_NOF_GROUPS][SRSLTE_ZC_SEQUENCE_NOF_BASE]; -} srslte_zc_sequence_lut_t; + cf_t* sequence[SRSRAN_ZC_SEQUENCE_NOF_GROUPS][SRSRAN_ZC_SEQUENCE_NOF_BASE]; +} srsran_zc_sequence_lut_t; /** * @brief Initialises a Low-PAPR sequence look-up-table object using NR tables @@ -74,9 +74,9 @@ typedef struct SRSLTE_API { * @param delta Delta parameter described in specification * @param alphas Vector with the alpha shift parameters * @param nof_alphas Number alpha shifts to generate - * @return SRSLTE_SUCCESS if the initialization is successful, SRSLTE_ERROR code otherwise + * @return SRSRAN_SUCCESS if the initialization is successful, SRSRAN_ERROR code otherwise */ -SRSLTE_API int srslte_zc_sequence_lut_init_nr(srslte_zc_sequence_lut_t* q, +SRSRAN_API int srsran_zc_sequence_lut_init_nr(srsran_zc_sequence_lut_t* q, uint32_t m, uint32_t delta, float* alphas, @@ -86,7 +86,7 @@ SRSLTE_API int srslte_zc_sequence_lut_init_nr(srslte_zc_sequence_lut_t* q, * @brief Deallocates a Low-PAPR sequence look-up-table object * @param q Object pointer */ -SRSLTE_API void srslte_zc_sequence_lut_free(srslte_zc_sequence_lut_t* q); +SRSRAN_API void srsran_zc_sequence_lut_free(srsran_zc_sequence_lut_t* q); /** * @brief Get a Low-PAPR sequence from the LUT @@ -94,9 +94,9 @@ SRSLTE_API void srslte_zc_sequence_lut_free(srslte_zc_sequence_lut_t* q); * @param u Group number {0,1,...29} * @param v base sequence * @param alpha_idx Phase shift index - * @return SRSLTE_SUCCESS if the generation is successful, SRSLTE_ERROR code otherwise + * @return SRSRAN_SUCCESS if the generation is successful, SRSRAN_ERROR code otherwise */ -SRSLTE_API const cf_t* - srslte_zc_sequence_lut_get(const srslte_zc_sequence_lut_t* q, uint32_t u, uint32_t v, uint32_t alpha_idx); +SRSRAN_API const cf_t* + srsran_zc_sequence_lut_get(const srsran_zc_sequence_lut_t* q, uint32_t u, uint32_t v, uint32_t alpha_idx); -#endif // SRSLTE_ZC_SEQUENCE_H +#endif // SRSRAN_ZC_SEQUENCE_H diff --git a/lib/include/srslte/phy/dft/dft.h b/lib/include/srsran/phy/dft/dft.h similarity index 64% rename from lib/include/srslte/phy/dft/dft.h rename to lib/include/srsran/phy/dft/dft.h index e06d105fa..ccf609d78 100644 --- a/lib/include/srslte/phy/dft/dft.h +++ b/lib/include/srsran/phy/dft/dft.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,10 +10,10 @@ * */ -#ifndef SRSLTE_DFT_H -#define SRSLTE_DFT_H +#ifndef SRSRAN_DFT_H +#define SRSRAN_DFT_H -#include "srslte/config.h" +#include "srsran/config.h" #include /********************************************************************************************** @@ -38,11 +38,11 @@ extern "C" { #endif -typedef enum { SRSLTE_DFT_COMPLEX, SRSLTE_REAL } srslte_dft_mode_t; +typedef enum { SRSRAN_DFT_COMPLEX, SRSRAN_REAL } srsran_dft_mode_t; -typedef enum { SRSLTE_DFT_FORWARD, SRSLTE_DFT_BACKWARD } srslte_dft_dir_t; +typedef enum { SRSRAN_DFT_FORWARD, SRSRAN_DFT_BACKWARD } srsran_dft_dir_t; -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { int init_size; // DFT length used in the first initialization int size; // DFT length void* in; // Input buffer @@ -54,17 +54,17 @@ typedef struct SRSLTE_API { bool db; // Provide output in dB? bool norm; // Normalize output? bool dc; // Handle insertion/removal of null DC carrier internally? - srslte_dft_dir_t dir; // Forward/Backward - srslte_dft_mode_t mode; // Complex/Real -} srslte_dft_plan_t; + srsran_dft_dir_t dir; // Forward/Backward + srsran_dft_mode_t mode; // Complex/Real +} srsran_dft_plan_t; -SRSLTE_API int srslte_dft_plan(srslte_dft_plan_t* plan, int dft_points, srslte_dft_dir_t dir, srslte_dft_mode_t type); +SRSRAN_API int srsran_dft_plan(srsran_dft_plan_t* plan, int dft_points, srsran_dft_dir_t dir, srsran_dft_mode_t type); -SRSLTE_API int srslte_dft_plan_c(srslte_dft_plan_t* plan, int dft_points, srslte_dft_dir_t dir); +SRSRAN_API int srsran_dft_plan_c(srsran_dft_plan_t* plan, int dft_points, srsran_dft_dir_t dir); -SRSLTE_API int srslte_dft_plan_guru_c(srslte_dft_plan_t* plan, +SRSRAN_API int srsran_dft_plan_guru_c(srsran_dft_plan_t* plan, int dft_points, - srslte_dft_dir_t dir, + srsran_dft_dir_t dir, cf_t* in_buffer, cf_t* out_buffer, int istride, @@ -73,11 +73,11 @@ SRSLTE_API int srslte_dft_plan_guru_c(srslte_dft_plan_t* plan, int idist, int odist); -SRSLTE_API int srslte_dft_plan_r(srslte_dft_plan_t* plan, int dft_points, srslte_dft_dir_t dir); +SRSRAN_API int srsran_dft_plan_r(srsran_dft_plan_t* plan, int dft_points, srsran_dft_dir_t dir); -SRSLTE_API int srslte_dft_replan(srslte_dft_plan_t* plan, const int new_dft_points); +SRSRAN_API int srsran_dft_replan(srsran_dft_plan_t* plan, const int new_dft_points); -SRSLTE_API int srslte_dft_replan_guru_c(srslte_dft_plan_t* plan, +SRSRAN_API int srsran_dft_replan_guru_c(srsran_dft_plan_t* plan, const int new_dft_points, cf_t* in_buffer, cf_t* out_buffer, @@ -87,36 +87,36 @@ SRSLTE_API int srslte_dft_replan_guru_c(srslte_dft_plan_t* plan, int idist, int odist); -SRSLTE_API int srslte_dft_replan_c(srslte_dft_plan_t* plan, int new_dft_points); +SRSRAN_API int srsran_dft_replan_c(srsran_dft_plan_t* plan, int new_dft_points); -SRSLTE_API int srslte_dft_replan_r(srslte_dft_plan_t* plan, int new_dft_points); +SRSRAN_API int srsran_dft_replan_r(srsran_dft_plan_t* plan, int new_dft_points); -SRSLTE_API void srslte_dft_plan_free(srslte_dft_plan_t* plan); +SRSRAN_API void srsran_dft_plan_free(srsran_dft_plan_t* plan); /* Set options */ -SRSLTE_API void srslte_dft_plan_set_mirror(srslte_dft_plan_t* plan, bool val); +SRSRAN_API void srsran_dft_plan_set_mirror(srsran_dft_plan_t* plan, bool val); -SRSLTE_API void srslte_dft_plan_set_db(srslte_dft_plan_t* plan, bool val); +SRSRAN_API void srsran_dft_plan_set_db(srsran_dft_plan_t* plan, bool val); -SRSLTE_API void srslte_dft_plan_set_norm(srslte_dft_plan_t* plan, bool val); +SRSRAN_API void srsran_dft_plan_set_norm(srsran_dft_plan_t* plan, bool val); -SRSLTE_API void srslte_dft_plan_set_dc(srslte_dft_plan_t* plan, bool val); +SRSRAN_API void srsran_dft_plan_set_dc(srsran_dft_plan_t* plan, bool val); /* Compute DFT */ -SRSLTE_API void srslte_dft_run(srslte_dft_plan_t* plan, const void* in, void* out); +SRSRAN_API void srsran_dft_run(srsran_dft_plan_t* plan, const void* in, void* out); -SRSLTE_API void srslte_dft_run_c_zerocopy(srslte_dft_plan_t* plan, const cf_t* in, cf_t* out); +SRSRAN_API void srsran_dft_run_c_zerocopy(srsran_dft_plan_t* plan, const cf_t* in, cf_t* out); -SRSLTE_API void srslte_dft_run_c(srslte_dft_plan_t* plan, const cf_t* in, cf_t* out); +SRSRAN_API void srsran_dft_run_c(srsran_dft_plan_t* plan, const cf_t* in, cf_t* out); -SRSLTE_API void srslte_dft_run_guru_c(srslte_dft_plan_t* plan); +SRSRAN_API void srsran_dft_run_guru_c(srsran_dft_plan_t* plan); -SRSLTE_API void srslte_dft_run_r(srslte_dft_plan_t* plan, const float* in, float* out); +SRSRAN_API void srsran_dft_run_r(srsran_dft_plan_t* plan, const float* in, float* out); #ifdef __cplusplus } #endif -#endif // SRSLTE_DFT_H +#endif // SRSRAN_DFT_H diff --git a/lib/include/srslte/phy/dft/dft_precoding.h b/lib/include/srsran/phy/dft/dft_precoding.h similarity index 51% rename from lib/include/srslte/phy/dft/dft_precoding.h rename to lib/include/srsran/phy/dft/dft_precoding.h index a7a1879c4..96a40edcd 100644 --- a/lib/include/srslte/phy/dft/dft_precoding.h +++ b/lib/include/srsran/phy/dft/dft_precoding.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -19,34 +19,34 @@ * Reference: 3GPP TS 36.211 version 10.0.0 Release 10 Sec. 5.3.3 *********************************************************************************************/ -#ifndef SRSLTE_DFT_PRECODING_H -#define SRSLTE_DFT_PRECODING_H +#ifndef SRSRAN_DFT_PRECODING_H +#define SRSRAN_DFT_PRECODING_H -#include "srslte/config.h" -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/dft/dft.h" +#include "srsran/config.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/dft/dft.h" /* DFT-based Transform Precoding object */ -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { uint32_t max_prb; - srslte_dft_plan_t dft_plan[SRSLTE_MAX_PRB + 1]; + srsran_dft_plan_t dft_plan[SRSRAN_MAX_PRB + 1]; -} srslte_dft_precoding_t; +} srsran_dft_precoding_t; -SRSLTE_API int srslte_dft_precoding_init(srslte_dft_precoding_t* q, uint32_t max_prb, bool is_tx); +SRSRAN_API int srsran_dft_precoding_init(srsran_dft_precoding_t* q, uint32_t max_prb, bool is_tx); -SRSLTE_API int srslte_dft_precoding_init_tx(srslte_dft_precoding_t* q, uint32_t max_prb); +SRSRAN_API int srsran_dft_precoding_init_tx(srsran_dft_precoding_t* q, uint32_t max_prb); -SRSLTE_API int srslte_dft_precoding_init_rx(srslte_dft_precoding_t* q, uint32_t max_prb); +SRSRAN_API int srsran_dft_precoding_init_rx(srsran_dft_precoding_t* q, uint32_t max_prb); -SRSLTE_API void srslte_dft_precoding_free(srslte_dft_precoding_t* q); +SRSRAN_API void srsran_dft_precoding_free(srsran_dft_precoding_t* q); -SRSLTE_API bool srslte_dft_precoding_valid_prb(uint32_t nof_prb); +SRSRAN_API bool srsran_dft_precoding_valid_prb(uint32_t nof_prb); -SRSLTE_API uint32_t srslte_dft_precoding_get_valid_prb(uint32_t nof_prb); +SRSRAN_API uint32_t srsran_dft_precoding_get_valid_prb(uint32_t nof_prb); -SRSLTE_API int -srslte_dft_precoding(srslte_dft_precoding_t* q, cf_t* input, cf_t* output, uint32_t nof_prb, uint32_t nof_symbols); +SRSRAN_API int +srsran_dft_precoding(srsran_dft_precoding_t* q, cf_t* input, cf_t* output, uint32_t nof_prb, uint32_t nof_symbols); -#endif // SRSLTE_DFT_PRECODING_H +#endif // SRSRAN_DFT_PRECODING_H diff --git a/lib/include/srslte/phy/dft/ofdm.h b/lib/include/srsran/phy/dft/ofdm.h similarity index 61% rename from lib/include/srslte/phy/dft/ofdm.h rename to lib/include/srsran/phy/dft/ofdm.h index 9494e6fbd..81702934a 100644 --- a/lib/include/srslte/phy/dft/ofdm.h +++ b/lib/include/srsran/phy/dft/ofdm.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,8 +10,8 @@ * */ -#ifndef SRSLTE_OFDM_H -#define SRSLTE_OFDM_H +#ifndef SRSRAN_OFDM_H +#define SRSRAN_OFDM_H /********************************************************************************************** * File: ofdm.h @@ -24,42 +24,42 @@ #include -#include "srslte/config.h" -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/dft/dft.h" +#include "srsran/config.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/dft/dft.h" /** - * @struct srslte_ofdm_cfg_t + * @struct srsran_ofdm_cfg_t * Contains the generic OFDM modulator configuration. The structure must be initialised to all zeros before being * filled. Only compulsory parameters need to be filled prior initialization. * - * This structure must be used with init functions srslte_ofdm_rx_init_cfg and srslte_ofdm_tx_init_cfg. These provide + * This structure must be used with init functions srsran_ofdm_rx_init_cfg and srsran_ofdm_tx_init_cfg. These provide * more flexible options. */ -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { // Compulsory parameters uint32_t nof_prb; ///< Number of Resource Block cf_t* in_buffer; ///< Input bnuffer pointer cf_t* out_buffer; ///< Output buffer pointer - srslte_cp_t cp; ///< Cyclic prefix type + srsran_cp_t cp; ///< Cyclic prefix type // Optional parameters - srslte_sf_t sf_type; ///< Subframe type, normal or MBSFN + srsran_sf_t sf_type; ///< Subframe type, normal or MBSFN bool normalize; ///< Normalization flag, it divides the output by square root of the symbol size float freq_shift_f; ///< Frequency shift, normalised by sampling rate (used in UL) float rx_window_offset; ///< DFT Window offset in CP portion (0-1), RX only uint32_t symbol_sz; ///< Symbol size, forces a given symbol size for the number of PRB bool keep_dc; ///< If true, it does not remove the DC -} srslte_ofdm_cfg_t; +} srsran_ofdm_cfg_t; /** - * @struct srslte_ofdm_t + * @struct srsran_ofdm_t * OFDM object, common for Tx and Rx */ -typedef struct SRSLTE_API { - srslte_ofdm_cfg_t cfg; - srslte_dft_plan_t fft_plan; - srslte_dft_plan_t fft_plan_sf[2]; +typedef struct SRSRAN_API { + srsran_ofdm_cfg_t cfg; + srsran_dft_plan_t fft_plan; + srsran_dft_plan_t fft_plan_sf[2]; uint32_t max_prb; uint32_t nof_symbols; uint32_t nof_guards; @@ -74,7 +74,7 @@ typedef struct SRSLTE_API { uint32_t window_offset_n; cf_t* shift_buffer; cf_t* window_offset_buffer; -} srslte_ofdm_t; +} srsran_ofdm_t; /** * @brief Initialises or reconfigures OFDM receiver @@ -84,9 +84,9 @@ typedef struct SRSLTE_API { * * @param q OFDM object * @param cfg OFDM configuration - * @return SRSLTE_SUCCESS if the initialization/reconfiguration is successful, SRSLTE_ERROR code otherwise + * @return SRSRAN_SUCCESS if the initialization/reconfiguration is successful, SRSRAN_ERROR code otherwise */ -SRSLTE_API int srslte_ofdm_rx_init_cfg(srslte_ofdm_t* q, srslte_ofdm_cfg_t* cfg); +SRSRAN_API int srsran_ofdm_rx_init_cfg(srsran_ofdm_t* q, srsran_ofdm_cfg_t* cfg); /** * @brief Initialises or reconfigures OFDM transmitter @@ -96,40 +96,40 @@ SRSLTE_API int srslte_ofdm_rx_init_cfg(srslte_ofdm_t* q, srslte_ofdm_cfg_t* cfg) * * @param q OFDM object * @param cfg OFDM configuration - * @return SRSLTE_SUCCESS if the initialization/reconfiguration is successful, SRSLTE_ERROR code otherwise + * @return SRSRAN_SUCCESS if the initialization/reconfiguration is successful, SRSRAN_ERROR code otherwise */ -SRSLTE_API int srslte_ofdm_tx_init_cfg(srslte_ofdm_t* q, srslte_ofdm_cfg_t* cfg); +SRSRAN_API int srsran_ofdm_tx_init_cfg(srsran_ofdm_t* q, srsran_ofdm_cfg_t* cfg); -SRSLTE_API int -srslte_ofdm_rx_init_mbsfn(srslte_ofdm_t* q, srslte_cp_t cp_type, cf_t* in_buffer, cf_t* out_buffer, uint32_t max_prb); +SRSRAN_API int +srsran_ofdm_rx_init_mbsfn(srsran_ofdm_t* q, srsran_cp_t cp_type, cf_t* in_buffer, cf_t* out_buffer, uint32_t max_prb); -SRSLTE_API int -srslte_ofdm_rx_init(srslte_ofdm_t* q, srslte_cp_t cp_type, cf_t* in_buffer, cf_t* out_buffer, uint32_t max_prb); +SRSRAN_API int +srsran_ofdm_rx_init(srsran_ofdm_t* q, srsran_cp_t cp_type, cf_t* in_buffer, cf_t* out_buffer, uint32_t max_prb); -SRSLTE_API int srslte_ofdm_tx_set_prb(srslte_ofdm_t* q, srslte_cp_t cp, uint32_t nof_prb); +SRSRAN_API int srsran_ofdm_tx_set_prb(srsran_ofdm_t* q, srsran_cp_t cp, uint32_t nof_prb); -SRSLTE_API int srslte_ofdm_rx_set_prb(srslte_ofdm_t* q, srslte_cp_t cp, uint32_t nof_prb); +SRSRAN_API int srsran_ofdm_rx_set_prb(srsran_ofdm_t* q, srsran_cp_t cp, uint32_t nof_prb); -SRSLTE_API void srslte_ofdm_rx_free(srslte_ofdm_t* q); +SRSRAN_API void srsran_ofdm_rx_free(srsran_ofdm_t* q); -SRSLTE_API void srslte_ofdm_rx_sf(srslte_ofdm_t* q); +SRSRAN_API void srsran_ofdm_rx_sf(srsran_ofdm_t* q); -SRSLTE_API void srslte_ofdm_rx_sf_ng(srslte_ofdm_t* q, cf_t* input, cf_t* output); +SRSRAN_API void srsran_ofdm_rx_sf_ng(srsran_ofdm_t* q, cf_t* input, cf_t* output); -SRSLTE_API int -srslte_ofdm_tx_init(srslte_ofdm_t* q, srslte_cp_t cp_type, cf_t* in_buffer, cf_t* out_buffer, uint32_t nof_prb); +SRSRAN_API int +srsran_ofdm_tx_init(srsran_ofdm_t* q, srsran_cp_t cp_type, cf_t* in_buffer, cf_t* out_buffer, uint32_t nof_prb); -SRSLTE_API int -srslte_ofdm_tx_init_mbsfn(srslte_ofdm_t* q, srslte_cp_t cp, cf_t* in_buffer, cf_t* out_buffer, uint32_t nof_prb); +SRSRAN_API int +srsran_ofdm_tx_init_mbsfn(srsran_ofdm_t* q, srsran_cp_t cp, cf_t* in_buffer, cf_t* out_buffer, uint32_t nof_prb); -SRSLTE_API void srslte_ofdm_tx_free(srslte_ofdm_t* q); +SRSRAN_API void srsran_ofdm_tx_free(srsran_ofdm_t* q); -SRSLTE_API void srslte_ofdm_tx_sf(srslte_ofdm_t* q); +SRSRAN_API void srsran_ofdm_tx_sf(srsran_ofdm_t* q); -SRSLTE_API int srslte_ofdm_set_freq_shift(srslte_ofdm_t* q, float freq_shift); +SRSRAN_API int srsran_ofdm_set_freq_shift(srsran_ofdm_t* q, float freq_shift); -SRSLTE_API void srslte_ofdm_set_normalize(srslte_ofdm_t* q, bool normalize_enable); +SRSRAN_API void srsran_ofdm_set_normalize(srsran_ofdm_t* q, bool normalize_enable); -SRSLTE_API void srslte_ofdm_set_non_mbsfn_region(srslte_ofdm_t* q, uint8_t non_mbsfn_region); +SRSRAN_API void srsran_ofdm_set_non_mbsfn_region(srsran_ofdm_t* q, uint8_t non_mbsfn_region); -#endif // SRSLTE_OFDM_H +#endif // SRSRAN_OFDM_H diff --git a/lib/include/srsran/phy/enb/enb_dl.h b/lib/include/srsran/phy/enb/enb_dl.h new file mode 100644 index 000000000..0acd6fc54 --- /dev/null +++ b/lib/include/srsran/phy/enb/enb_dl.h @@ -0,0 +1,162 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +/****************************************************************************** + * File: enb_dl.h + * + * Description: ENB downlink object. + * + * This module is a frontend to all the downlink data and control + * channel processing modules for the ENB transmitter side. + * + * Reference: + *****************************************************************************/ + +#ifndef SRSRAN_ENB_DL_H +#define SRSRAN_ENB_DL_H + +#include + +#include "srsran/phy/ch_estimation/refsignal_dl.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/dft/ofdm.h" +#include "srsran/phy/phch/dci.h" +#include "srsran/phy/phch/pbch.h" +#include "srsran/phy/phch/pcfich.h" +#include "srsran/phy/phch/pdcch.h" +#include "srsran/phy/phch/pdsch.h" +#include "srsran/phy/phch/pdsch_cfg.h" +#include "srsran/phy/phch/phich.h" +#include "srsran/phy/phch/pmch.h" +#include "srsran/phy/phch/ra.h" +#include "srsran/phy/phch/regs.h" +#include "srsran/phy/sync/pss.h" +#include "srsran/phy/sync/sss.h" + +#include "srsran/phy/enb/enb_ul.h" +#include "srsran/phy/ue/ue_dl.h" + +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" + +#include "srsran/config.h" + +typedef struct SRSRAN_API { + srsran_cell_t cell; + + srsran_dl_sf_cfg_t dl_sf; + + cf_t* sf_symbols[SRSRAN_MAX_PORTS]; + + srsran_ofdm_t ifft[SRSRAN_MAX_PORTS]; + srsran_ofdm_t ifft_mbsfn; + + srsran_pbch_t pbch; + srsran_pcfich_t pcfich; + srsran_regs_t regs; + srsran_pdcch_t pdcch; + srsran_pdsch_t pdsch; + srsran_pmch_t pmch; + srsran_phich_t phich; + + srsran_refsignal_t csr_signal; + srsran_refsignal_t mbsfnr_signal; + + cf_t pss_signal[SRSRAN_PSS_LEN]; + float sss_signal0[SRSRAN_SSS_LEN]; + float sss_signal5[SRSRAN_SSS_LEN]; + + uint32_t nof_common_locations[3]; + srsran_dci_location_t common_locations[3][SRSRAN_MAX_CANDIDATES_COM]; + +} srsran_enb_dl_t; + +typedef struct { + uint8_t ack; + uint32_t n_prb_lowest; + uint32_t n_dmrs; +} srsran_enb_dl_phich_t; + +/* This function shall be called just after the initial synchronization */ +SRSRAN_API int srsran_enb_dl_init(srsran_enb_dl_t* q, cf_t* out_buffer[SRSRAN_MAX_PORTS], uint32_t max_prb); + +SRSRAN_API void srsran_enb_dl_free(srsran_enb_dl_t* q); + +SRSRAN_API int srsran_enb_dl_set_cell(srsran_enb_dl_t* q, srsran_cell_t cell); + +SRSRAN_API bool srsran_enb_dl_location_is_common_ncce(srsran_enb_dl_t* q, uint32_t ncce); + +SRSRAN_API void srsran_enb_dl_put_base(srsran_enb_dl_t* q, srsran_dl_sf_cfg_t* dl_sf); + +SRSRAN_API void srsran_enb_dl_put_phich(srsran_enb_dl_t* q, srsran_phich_grant_t* grant, bool ack); + +SRSRAN_API int srsran_enb_dl_put_pdcch_dl(srsran_enb_dl_t* q, srsran_dci_cfg_t* dci_cfg, srsran_dci_dl_t* dci_dl); + +SRSRAN_API int srsran_enb_dl_put_pdcch_ul(srsran_enb_dl_t* q, srsran_dci_cfg_t* dci_cfg, srsran_dci_ul_t* dci_ul); + +SRSRAN_API int +srsran_enb_dl_put_pdsch(srsran_enb_dl_t* q, srsran_pdsch_cfg_t* pdsch, uint8_t* data[SRSRAN_MAX_CODEWORDS]); + +SRSRAN_API int srsran_enb_dl_put_pmch(srsran_enb_dl_t* q, srsran_pmch_cfg_t* pmch_cfg, uint8_t* data); + +SRSRAN_API void srsran_enb_dl_gen_signal(srsran_enb_dl_t* q); + +SRSRAN_API bool srsran_enb_dl_gen_cqi_periodic(const srsran_cell_t* cell, + const srsran_dl_cfg_t* dl_cfg, + uint32_t tti, + uint32_t last_ri, + srsran_cqi_cfg_t* cqi_cfg); + +SRSRAN_API bool srsran_enb_dl_gen_cqi_aperiodic(const srsran_cell_t* cell, + const srsran_dl_cfg_t* dl_cfg, + uint32_t ri, + srsran_cqi_cfg_t* cqi_cfg); + +SRSRAN_API void srsran_enb_dl_save_signal(srsran_enb_dl_t* q); + +/** + * Generates the uplink control information configuration from the cell, subframe and HARQ ACK information. Note that + * it expects the UCI configuration shall have been configured already with scheduling request and channel quality + * information prior to this call. + * + * @param cell points to the physical layer cell parameters + * @param sf points to the subframe configuration + * @param ack_info is the HARQ-ACK information + * @param uci_cfg the UCI configuration destination + */ +SRSRAN_API void srsran_enb_dl_gen_ack(const srsran_cell_t* cell, + const srsran_dl_sf_cfg_t* sf, + const srsran_pdsch_ack_t* ack_info, + srsran_uci_cfg_t* uci_cfg); + +/** + * gets the HARQ-ACK values from the received Uplink Control Information configuration, the cell, and HARQ ACK + * info itself. Note that it expects that the HARQ-ACK info has been set prior the UCI Data decoding. + * + * @param cell points to the physical layer cell parameters + * @param uci_cfg points to the UCI configration + * @param uci_value points to the received UCI values + * @param ack_info is the HARQ-ACK information + */ +SRSRAN_API void srsran_enb_dl_get_ack(const srsran_cell_t* cell, + const srsran_uci_cfg_t* uci_cfg, + const srsran_uci_value_t* uci_value, + srsran_pdsch_ack_t* pdsch_ack); + +/** + * Gets the maximum signal power in decibels full scale. It is equivalent to the transmit power if all resource elements + * were populated. + * @return The maximum power + */ +SRSRAN_API float srsran_enb_dl_get_maximum_signal_power_dBfs(uint32_t nof_prb); + +#endif // SRSRAN_ENB_DL_H diff --git a/lib/include/srsran/phy/enb/enb_dl_nr.h b/lib/include/srsran/phy/enb/enb_dl_nr.h new file mode 100644 index 000000000..61d05c45b --- /dev/null +++ b/lib/include/srsran/phy/enb/enb_dl_nr.h @@ -0,0 +1,67 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +#ifndef SRSRAN_ENB_DL_NR_H +#define SRSRAN_ENB_DL_NR_H + +#include "srsran/phy/common/phy_common_nr.h" +#include "srsran/phy/dft/ofdm.h" +#include "srsran/phy/phch/pdcch_nr.h" +#include "srsran/phy/phch/pdsch_nr.h" + +typedef struct SRSRAN_API { + srsran_pdsch_nr_args_t pdsch; + srsran_pdcch_nr_args_t pdcch; + uint32_t nof_tx_antennas; + uint32_t nof_max_prb; +} srsran_enb_dl_nr_args_t; + +typedef struct SRSRAN_API { + uint32_t max_prb; + uint32_t nof_tx_antennas; + srsran_carrier_nr_t carrier; + srsran_coreset_t coreset; + + srsran_ofdm_t fft[SRSRAN_MAX_PORTS]; + + cf_t* sf_symbols[SRSRAN_MAX_PORTS]; + srsran_pdsch_nr_t pdsch; + srsran_dmrs_sch_t dmrs; + + srsran_pdcch_nr_t pdcch; +} srsran_enb_dl_nr_t; + +SRSRAN_API int +srsran_enb_dl_nr_init(srsran_enb_dl_nr_t* q, cf_t* output[SRSRAN_MAX_PORTS], const srsran_enb_dl_nr_args_t* args); + +SRSRAN_API int srsran_enb_dl_nr_set_carrier(srsran_enb_dl_nr_t* q, const srsran_carrier_nr_t* carrier); + +SRSRAN_API int srsran_enb_dl_nr_set_coreset(srsran_enb_dl_nr_t* q, const srsran_coreset_t* coreset); + +SRSRAN_API void srsran_enb_dl_nr_free(srsran_enb_dl_nr_t* q); + +SRSRAN_API int srsran_enb_dl_nr_base_zero(srsran_enb_dl_nr_t* q); + +SRSRAN_API void srsran_enb_dl_nr_gen_signal(srsran_enb_dl_nr_t* q); + +SRSRAN_API int +srsran_enb_dl_nr_pdcch_put(srsran_enb_dl_nr_t* q, const srsran_slot_cfg_t* slot_cfg, const srsran_dci_dl_nr_t* dci_dl); + +SRSRAN_API int srsran_enb_dl_nr_pdsch_put(srsran_enb_dl_nr_t* q, + const srsran_slot_cfg_t* slot, + const srsran_sch_cfg_nr_t* cfg, + uint8_t* data[SRSRAN_MAX_TB]); + +SRSRAN_API int +srsran_enb_dl_nr_pdsch_info(const srsran_enb_dl_nr_t* q, const srsran_sch_cfg_nr_t* cfg, char* str, uint32_t str_len); + +#endif // SRSRAN_ENB_DL_NR_H diff --git a/lib/include/srsran/phy/enb/enb_ul.h b/lib/include/srsran/phy/enb/enb_ul.h new file mode 100644 index 000000000..86b823356 --- /dev/null +++ b/lib/include/srsran/phy/enb/enb_ul.h @@ -0,0 +1,78 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +/****************************************************************************** + * File: enb_ul.h + * + * Description: ENB uplink object. + * + * This module is a frontend to all the uplink data and control + * channel processing modules for the ENB receiver side. + * + * Reference: + *****************************************************************************/ + +#ifndef SRSRAN_ENB_UL_H +#define SRSRAN_ENB_UL_H + +#include + +#include "srsran/phy/ch_estimation/chest_ul.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/dft/ofdm.h" +#include "srsran/phy/phch/prach.h" +#include "srsran/phy/phch/pucch.h" +#include "srsran/phy/phch/pusch.h" +#include "srsran/phy/phch/pusch_cfg.h" +#include "srsran/phy/phch/ra.h" + +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" + +#include "srsran/config.h" + +typedef struct SRSRAN_API { + srsran_cell_t cell; + + cf_t* sf_symbols; + srsran_chest_ul_res_t chest_res; + + srsran_ofdm_t fft; + srsran_chest_ul_t chest; + srsran_pusch_t pusch; + srsran_pucch_t pucch; + +} srsran_enb_ul_t; + +/* This function shall be called just after the initial synchronization */ +SRSRAN_API int srsran_enb_ul_init(srsran_enb_ul_t* q, cf_t* in_buffer, uint32_t max_prb); + +SRSRAN_API void srsran_enb_ul_free(srsran_enb_ul_t* q); + +SRSRAN_API int srsran_enb_ul_set_cell(srsran_enb_ul_t* q, + srsran_cell_t cell, + srsran_refsignal_dmrs_pusch_cfg_t* pusch_cfg, + srsran_refsignal_srs_cfg_t* srs_cfg); + +SRSRAN_API void srsran_enb_ul_fft(srsran_enb_ul_t* q); + +SRSRAN_API int srsran_enb_ul_get_pucch(srsran_enb_ul_t* q, + srsran_ul_sf_cfg_t* ul_sf, + srsran_pucch_cfg_t* cfg, + srsran_pucch_res_t* res); + +SRSRAN_API int srsran_enb_ul_get_pusch(srsran_enb_ul_t* q, + srsran_ul_sf_cfg_t* ul_sf, + srsran_pusch_cfg_t* cfg, + srsran_pusch_res_t* res); + +#endif // SRSRAN_ENB_UL_H diff --git a/lib/include/srslte/phy/fec/block/block.h b/lib/include/srsran/phy/fec/block/block.h similarity index 73% rename from lib/include/srslte/phy/fec/block/block.h rename to lib/include/srsran/phy/fec/block/block.h index 8221f73d0..aeddb7b9d 100644 --- a/lib/include/srslte/phy/fec/block/block.h +++ b/lib/include/srsran/phy/fec/block/block.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,22 +10,22 @@ * */ -#ifndef SRSLTE_BLOCK_H -#define SRSLTE_BLOCK_H +#ifndef SRSRAN_BLOCK_H +#define SRSRAN_BLOCK_H -#include "srslte/config.h" +#include "srsran/config.h" #include #include /** * @brief Maximum number of bits that can be encoded */ -#define SRSLTE_FEC_BLOCK_MAX_NOF_BITS 11U +#define SRSRAN_FEC_BLOCK_MAX_NOF_BITS 11U /** * @brief Block coding output complete length */ -#define SRSLTE_FEC_BLOCK_SIZE 32U +#define SRSRAN_FEC_BLOCK_SIZE 32U /** * @brief Encodes unpacked data using Reed–Muller code block channel coding. @@ -34,11 +34,11 @@ * @remark Described by 3GPP 38.212 section 5.3.3.3 for 5G/NR * * @param[in] input provides unpacked bits to encode - * @param[in] input_len number of bits to encode, the maximum number of bits is SRSLTE_FEC_BLOCK_MAX_NOF_BITS + * @param[in] input_len number of bits to encode, the maximum number of bits is SRSRAN_FEC_BLOCK_MAX_NOF_BITS * @param[out] output points to the unpacked encoded data * @param[in] output_len number of bits of encoded bits */ -SRSLTE_API void srslte_block_encode(const uint8_t* input, uint32_t input_len, uint8_t* output, uint32_t output_len); +SRSRAN_API void srsran_block_encode(const uint8_t* input, uint32_t input_len, uint8_t* output, uint32_t output_len); /** * @brief Decodes 16-bit signed data using Reed–Muller code block channel coding. @@ -46,10 +46,10 @@ SRSLTE_API void srslte_block_encode(const uint8_t* input, uint32_t input_len, ui * @param[in] llr Provides received LLRs * @param[in] nof_llr number of available LLRs * @param[out] data Data destination to store unpacked received bits - * @param[in] data_len number of bits to decode, the maximum number of bits is SRSLTE_FEC_BLOCK_MAX_NOF_BITS - * @return Decoded bits correlation if provided arguments are valid, otherwise SRSLTE_ERROR code + * @param[in] data_len number of bits to decode, the maximum number of bits is SRSRAN_FEC_BLOCK_MAX_NOF_BITS + * @return Decoded bits correlation if provided arguments are valid, otherwise SRSRAN_ERROR code */ -SRSLTE_API int32_t srslte_block_decode_i16(const int16_t* llr, uint32_t nof_llr, uint8_t* data, uint32_t data_len); +SRSRAN_API int32_t srsran_block_decode_i16(const int16_t* llr, uint32_t nof_llr, uint8_t* data, uint32_t data_len); /** * @brief Decodes 8-bit signed data using Reed–Muller code block channel coding. @@ -57,9 +57,9 @@ SRSLTE_API int32_t srslte_block_decode_i16(const int16_t* llr, uint32_t nof_llr, * @param[in] llr Provides received LLRs * @param[in] nof_llr number of available LLRs * @param[out] data Data destination to store unpacked received bits - * @param[in] data_len number of bits to decode, the maximum number of bits is SRSLTE_FEC_BLOCK_MAX_NOF_BITS - * @return Decoded bits correlation if provided arguments are valid, otherwise SRSLTE_ERROR code + * @param[in] data_len number of bits to decode, the maximum number of bits is SRSRAN_FEC_BLOCK_MAX_NOF_BITS + * @return Decoded bits correlation if provided arguments are valid, otherwise SRSRAN_ERROR code */ -SRSLTE_API int32_t srslte_block_decode_i8(const int8_t* llr, uint32_t nof_llr, uint8_t* data, uint32_t data_len); +SRSRAN_API int32_t srsran_block_decode_i8(const int8_t* llr, uint32_t nof_llr, uint8_t* data, uint32_t data_len); -#endif // SRSLTE_BLOCK_H +#endif // SRSRAN_BLOCK_H diff --git a/lib/include/srslte/phy/fec/cbsegm.h b/lib/include/srsran/phy/fec/cbsegm.h similarity index 71% rename from lib/include/srslte/phy/fec/cbsegm.h rename to lib/include/srsran/phy/fec/cbsegm.h index a7cc4396a..407afd351 100644 --- a/lib/include/srslte/phy/fec/cbsegm.h +++ b/lib/include/srsran/phy/fec/cbsegm.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,17 +10,17 @@ * */ -#ifndef SRSLTE_CBSEGM_H -#define SRSLTE_CBSEGM_H +#ifndef SRSRAN_CBSEGM_H +#define SRSRAN_CBSEGM_H #include #include -#include "srslte/config.h" +#include "srsran/config.h" -#define SRSLTE_NOF_TC_CB_SIZES 188 +#define SRSRAN_NOF_TC_CB_SIZES 188 -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { uint32_t F; ///< \brief Total number of the transport block bit uint32_t C; ///< \brief Total number of code blocks uint32_t K1; ///< \brief Code block size 1 @@ -33,7 +33,7 @@ typedef struct SRSLTE_API { uint32_t L_tb; ///< \brief Transport block CRC length uint32_t L_cb; ///< \brief Code block CRC length uint32_t Z; ///< \brief Lifting size, LDPC only -} srslte_cbsegm_t; +} srsran_cbsegm_t; /** * @brief Calculate code block Segmentation for LTE @@ -42,9 +42,9 @@ typedef struct SRSLTE_API { * * @param[out] s Output of code block segmentation calculation * @param[in] tbs Input Transport Block Size in bits. CRC's will be added to this - * @return It returns SRSLTE_SUCCESS if the provided arguments are valid, otherwise it returns SRSLTE_ERROR code + * @return It returns SRSRAN_SUCCESS if the provided arguments are valid, otherwise it returns SRSRAN_ERROR code */ -SRSLTE_API int srslte_cbsegm(srslte_cbsegm_t* s, uint32_t tbs); +SRSRAN_API int srsran_cbsegm(srsran_cbsegm_t* s, uint32_t tbs); /** * @brief provides interleaver size Table 5.1.3-3 (36.212) index @@ -52,9 +52,9 @@ SRSLTE_API int srslte_cbsegm(srslte_cbsegm_t* s, uint32_t tbs); * @remark Defined as in TS 36.212 V8.8.0 Table 5.1.3-3 Turbo code internal interleaver parameters * * @return It returns Turbo coder interleaver size if the provided arguments are valid, otherwise it returns - * SRSLTE_ERROR code + * SRSRAN_ERROR code */ -SRSLTE_API int srslte_cbsegm_cbsize(uint32_t index); +SRSRAN_API int srsran_cbsegm_cbsize(uint32_t index); /** * @brief Check is code block size is valid for LTE Turbo Code @@ -62,14 +62,14 @@ SRSLTE_API int srslte_cbsegm_cbsize(uint32_t index); * @param[in] size Size of code block in bits * @return true if Code Block size is allowed */ -SRSLTE_API bool srslte_cbsegm_cbsize_isvalid(uint32_t size); +SRSRAN_API bool srsran_cbsegm_cbsize_isvalid(uint32_t size); /** * @brief Finds index of minimum K>=long_cb in Table 5.1.3-3 of 36.212 * * @return I_TBS or error code */ -SRSLTE_API int srslte_cbsegm_cbindex(uint32_t long_cb); +SRSRAN_API int srsran_cbsegm_cbindex(uint32_t long_cb); /** * @brief Calculate code block Segmentation for NR LDPC base graph 1 @@ -78,9 +78,9 @@ SRSLTE_API int srslte_cbsegm_cbindex(uint32_t long_cb); * * @param[out] s Output of code block segmentation calculation * @param[in] tbs Input Transport Block Size in bits. CRC's will be added to this - * @return It returns SRSLTE_SUCCESS if the provided arguments are valid, otherwise it returns SRSLTE_ERROR code + * @return It returns SRSRAN_SUCCESS if the provided arguments are valid, otherwise it returns SRSRAN_ERROR code */ -SRSLTE_API int srslte_cbsegm_ldpc_bg1(srslte_cbsegm_t* s, uint32_t tbs); +SRSRAN_API int srsran_cbsegm_ldpc_bg1(srsran_cbsegm_t* s, uint32_t tbs); /** * @brief Calculate code block Segmentation for NR LDPC base graph 2 @@ -89,8 +89,8 @@ SRSLTE_API int srslte_cbsegm_ldpc_bg1(srslte_cbsegm_t* s, uint32_t tbs); * * @param[out] s Output of code block segmentation calculation * @param[in] tbs Input Transport Block Size in bits. CRC's will be added to this - * @return It returns SRSLTE_SUCCESS if the provided arguments are valid, otherwise it returns SRSLTE_ERROR code + * @return It returns SRSRAN_SUCCESS if the provided arguments are valid, otherwise it returns SRSRAN_ERROR code */ -SRSLTE_API int srslte_cbsegm_ldpc_bg2(srslte_cbsegm_t* s, uint32_t tbs); +SRSRAN_API int srsran_cbsegm_ldpc_bg2(srsran_cbsegm_t* s, uint32_t tbs); -#endif // SRSLTE_CBSEGM_H +#endif // SRSRAN_CBSEGM_H diff --git a/lib/include/srslte/phy/fec/convolutional/convcoder.h b/lib/include/srsran/phy/fec/convolutional/convcoder.h similarity index 74% rename from lib/include/srslte/phy/fec/convolutional/convcoder.h rename to lib/include/srsran/phy/fec/convolutional/convcoder.h index 05a380ddd..b2ba3cf5d 100644 --- a/lib/include/srslte/phy/fec/convolutional/convcoder.h +++ b/lib/include/srsran/phy/fec/convolutional/convcoder.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -20,19 +20,19 @@ * Reference: 3GPP TS 36.212 version 10.0.0 Release 10 Sec. 5.1.3.1 *********************************************************************************************/ -#ifndef SRSLTE_CONVCODER_H -#define SRSLTE_CONVCODER_H +#ifndef SRSRAN_CONVCODER_H +#define SRSRAN_CONVCODER_H -#include "srslte/config.h" +#include "srsran/config.h" #include -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { uint32_t R; uint32_t K; int poly[3]; bool tail_biting; -} srslte_convcoder_t; +} srsran_convcoder_t; -SRSLTE_API int srslte_convcoder_encode(srslte_convcoder_t* q, uint8_t* input, uint8_t* output, uint32_t frame_length); +SRSRAN_API int srsran_convcoder_encode(srsran_convcoder_t* q, uint8_t* input, uint8_t* output, uint32_t frame_length); -#endif // SRSLTE_CONVCODER_H +#endif // SRSRAN_CONVCODER_H diff --git a/lib/include/srslte/phy/fec/convolutional/rm_conv.h b/lib/include/srsran/phy/fec/convolutional/rm_conv.h similarity index 65% rename from lib/include/srslte/phy/fec/convolutional/rm_conv.h rename to lib/include/srsran/phy/fec/convolutional/rm_conv.h index cecb3cdc3..ee9d3eea0 100644 --- a/lib/include/srslte/phy/fec/convolutional/rm_conv.h +++ b/lib/include/srsran/phy/fec/convolutional/rm_conv.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -19,24 +19,24 @@ * Reference: 3GPP TS 36.212 version 10.0.0 Release 10 Sec. 5.1.4.2 *********************************************************************************************/ -#ifndef SRSLTE_RM_CONV_H -#define SRSLTE_RM_CONV_H +#ifndef SRSRAN_RM_CONV_H +#define SRSRAN_RM_CONV_H -#include "srslte/config.h" +#include "srsran/config.h" -#ifndef SRSLTE_RX_NULL -#define SRSLTE_RX_NULL 10000 +#ifndef SRSRAN_RX_NULL +#define SRSRAN_RX_NULL 10000 #endif -#ifndef SRSLTE_TX_NULL -#define SRSLTE_TX_NULL 100 +#ifndef SRSRAN_TX_NULL +#define SRSRAN_TX_NULL 100 #endif -SRSLTE_API int srslte_rm_conv_tx(uint8_t* input, uint32_t in_len, uint8_t* output, uint32_t out_len); +SRSRAN_API int srsran_rm_conv_tx(uint8_t* input, uint32_t in_len, uint8_t* output, uint32_t out_len); -SRSLTE_API int srslte_rm_conv_rx(float* input, uint32_t in_len, float* output, uint32_t out_len); +SRSRAN_API int srsran_rm_conv_rx(float* input, uint32_t in_len, float* output, uint32_t out_len); /************* FIX THIS. MOVE ALL PROCESSING TO INT16 AND HAVE ONLY 1 IMPLEMENTATION ******/ -SRSLTE_API int srslte_rm_conv_rx_s(int16_t* input, uint32_t in_len, int16_t* output, uint32_t out_len); +SRSRAN_API int srsran_rm_conv_rx_s(int16_t* input, uint32_t in_len, int16_t* output, uint32_t out_len); -#endif // SRSLTE_RM_CONV_H +#endif // SRSRAN_RM_CONV_H diff --git a/lib/include/srslte/phy/fec/convolutional/viterbi.h b/lib/include/srsran/phy/fec/convolutional/viterbi.h similarity index 62% rename from lib/include/srslte/phy/fec/convolutional/viterbi.h rename to lib/include/srsran/phy/fec/convolutional/viterbi.h index 1322fe4a8..d7a21f421 100644 --- a/lib/include/srslte/phy/fec/convolutional/viterbi.h +++ b/lib/include/srsran/phy/fec/convolutional/viterbi.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -19,15 +19,15 @@ * Reference: *****************************************************************************/ -#ifndef SRSLTE_VITERBI_H -#define SRSLTE_VITERBI_H +#ifndef SRSRAN_VITERBI_H +#define SRSRAN_VITERBI_H -#include "srslte/config.h" +#include "srsran/config.h" #include -typedef enum { SRSLTE_VITERBI_27 = 0, SRSLTE_VITERBI_29, SRSLTE_VITERBI_37, SRSLTE_VITERBI_39 } srslte_viterbi_type_t; +typedef enum { SRSRAN_VITERBI_27 = 0, SRSRAN_VITERBI_29, SRSRAN_VITERBI_37, SRSRAN_VITERBI_39 } srsran_viterbi_type_t; -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { void* ptr; uint32_t R; uint32_t K; @@ -43,44 +43,44 @@ typedef struct SRSLTE_API { uint16_t* tmp_s; uint8_t* symbols_uc; uint16_t* symbols_us; -} srslte_viterbi_t; +} srsran_viterbi_t; -SRSLTE_API int srslte_viterbi_init(srslte_viterbi_t* q, - srslte_viterbi_type_t type, +SRSRAN_API int srsran_viterbi_init(srsran_viterbi_t* q, + srsran_viterbi_type_t type, int poly[3], uint32_t max_frame_length, bool tail_bitting); -SRSLTE_API void srslte_viterbi_set_gain_quant(srslte_viterbi_t* q, float gain_quant); +SRSRAN_API void srsran_viterbi_set_gain_quant(srsran_viterbi_t* q, float gain_quant); -SRSLTE_API void srslte_viterbi_set_gain_quant_s(srslte_viterbi_t* q, int16_t gain_quant); +SRSRAN_API void srsran_viterbi_set_gain_quant_s(srsran_viterbi_t* q, int16_t gain_quant); -SRSLTE_API void srslte_viterbi_free(srslte_viterbi_t* q); +SRSRAN_API void srsran_viterbi_free(srsran_viterbi_t* q); -SRSLTE_API int srslte_viterbi_decode_f(srslte_viterbi_t* q, float* symbols, uint8_t* data, uint32_t frame_length); +SRSRAN_API int srsran_viterbi_decode_f(srsran_viterbi_t* q, float* symbols, uint8_t* data, uint32_t frame_length); -SRSLTE_API int srslte_viterbi_decode_s(srslte_viterbi_t* q, int16_t* symbols, uint8_t* data, uint32_t frame_length); +SRSRAN_API int srsran_viterbi_decode_s(srsran_viterbi_t* q, int16_t* symbols, uint8_t* data, uint32_t frame_length); -SRSLTE_API int srslte_viterbi_decode_us(srslte_viterbi_t* q, uint16_t* symbols, uint8_t* data, uint32_t frame_length); +SRSRAN_API int srsran_viterbi_decode_us(srsran_viterbi_t* q, uint16_t* symbols, uint8_t* data, uint32_t frame_length); -SRSLTE_API int srslte_viterbi_decode_uc(srslte_viterbi_t* q, uint8_t* symbols, uint8_t* data, uint32_t frame_length); +SRSRAN_API int srsran_viterbi_decode_uc(srsran_viterbi_t* q, uint8_t* symbols, uint8_t* data, uint32_t frame_length); -SRSLTE_API int srslte_viterbi_init_sse(srslte_viterbi_t* q, - srslte_viterbi_type_t type, +SRSRAN_API int srsran_viterbi_init_sse(srsran_viterbi_t* q, + srsran_viterbi_type_t type, int poly[3], uint32_t max_frame_length, bool tail_bitting); -SRSLTE_API int srslte_viterbi_init_neon(srslte_viterbi_t* q, - srslte_viterbi_type_t type, +SRSRAN_API int srsran_viterbi_init_neon(srsran_viterbi_t* q, + srsran_viterbi_type_t type, int poly[3], uint32_t max_frame_length, bool tail_bitting); -SRSLTE_API int srslte_viterbi_init_avx2(srslte_viterbi_t* q, - srslte_viterbi_type_t type, +SRSRAN_API int srsran_viterbi_init_avx2(srsran_viterbi_t* q, + srsran_viterbi_type_t type, int poly[3], uint32_t max_frame_length, bool tail_bitting); -#endif // SRSLTE_VITERBI_H +#endif // SRSRAN_VITERBI_H diff --git a/lib/include/srslte/phy/fec/crc.h b/lib/include/srsran/phy/fec/crc.h similarity index 63% rename from lib/include/srslte/phy/fec/crc.h rename to lib/include/srsran/phy/fec/crc.h index d03e1a441..11ee824a5 100644 --- a/lib/include/srslte/phy/fec/crc.h +++ b/lib/include/srsran/phy/fec/crc.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -20,31 +20,31 @@ * Reference: 3GPP TS 36.212 version 10.0.0 Release 10 Sec. 5.1.1 *********************************************************************************************/ -#ifndef SRSLTE_CRC_H -#define SRSLTE_CRC_H +#ifndef SRSRAN_CRC_H +#define SRSRAN_CRC_H -#include "srslte/config.h" +#include "srsran/config.h" #include -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { uint64_t table[256]; int polynom; int order; uint64_t crcinit; uint64_t crcmask; uint64_t crchighbit; - uint32_t srslte_crc_out; -} srslte_crc_t; + uint32_t srsran_crc_out; +} srsran_crc_t; -SRSLTE_API int srslte_crc_init(srslte_crc_t* h, uint32_t srslte_crc_poly, int srslte_crc_order); +SRSRAN_API int srsran_crc_init(srsran_crc_t* h, uint32_t srsran_crc_poly, int srsran_crc_order); -SRSLTE_API int srslte_crc_set_init(srslte_crc_t* h, uint64_t init_value); +SRSRAN_API int srsran_crc_set_init(srsran_crc_t* h, uint64_t init_value); -SRSLTE_API uint32_t srslte_crc_attach(srslte_crc_t* h, uint8_t* data, int len); +SRSRAN_API uint32_t srsran_crc_attach(srsran_crc_t* h, uint8_t* data, int len); -SRSLTE_API uint32_t srslte_crc_attach_byte(srslte_crc_t* h, uint8_t* data, int len); +SRSRAN_API uint32_t srsran_crc_attach_byte(srsran_crc_t* h, uint8_t* data, int len); -static inline void srslte_crc_checksum_put_byte(srslte_crc_t* h, uint8_t byte) +static inline void srsran_crc_checksum_put_byte(srsran_crc_t* h, uint8_t byte) { uint64_t crc = h->crcinit; @@ -64,13 +64,13 @@ static inline void srslte_crc_checksum_put_byte(srslte_crc_t* h, uint8_t byte) h->crcinit = crc; } -static inline uint64_t srslte_crc_checksum_get(srslte_crc_t* h) +static inline uint64_t srsran_crc_checksum_get(srsran_crc_t* h) { return (h->crcinit & h->crcmask); } -SRSLTE_API uint32_t srslte_crc_checksum_byte(srslte_crc_t* h, const uint8_t* data, int len); +SRSRAN_API uint32_t srsran_crc_checksum_byte(srsran_crc_t* h, const uint8_t* data, int len); -SRSLTE_API uint32_t srslte_crc_checksum(srslte_crc_t* h, uint8_t* data, int len); +SRSRAN_API uint32_t srsran_crc_checksum(srsran_crc_t* h, uint8_t* data, int len); -#endif // SRSLTE_CRC_H +#endif // SRSRAN_CRC_H diff --git a/lib/include/srslte/phy/fec/ldpc/base_graph.h b/lib/include/srsran/phy/fec/ldpc/base_graph.h similarity index 83% rename from lib/include/srslte/phy/fec/ldpc/base_graph.h rename to lib/include/srsran/phy/fec/ldpc/base_graph.h index 2ccc61bc9..3c8699b97 100644 --- a/lib/include/srslte/phy/fec/ldpc/base_graph.h +++ b/lib/include/srsran/phy/fec/ldpc/base_graph.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -25,18 +25,18 @@ * */ -#ifndef SRSLTE_BASEGRAPH_H -#define SRSLTE_BASEGRAPH_H +#ifndef SRSRAN_BASEGRAPH_H +#define SRSRAN_BASEGRAPH_H -#include "srslte/config.h" +#include "srsran/config.h" #include -#define SRSLTE_LDPC_BG1_MAX_LEN_CB 8448 /*!< \brief Maximum code block size for LDPC BG1 */ -#define SRSLTE_LDPC_BG2_MAX_LEN_CB 3840 /*!< \brief Maximum code block size for LDPC BG2 */ -#define SRSLTE_LDPC_MAX_LEN_CB \ - SRSLTE_MAX(SRSLTE_LDPC_BG1_MAX_LEN_CB, \ - SRSLTE_LDPC_BG2_MAX_LEN_CB) /*!< \brief Maximum code block size for LDPC BG1 or BG2 */ +#define SRSRAN_LDPC_BG1_MAX_LEN_CB 8448 /*!< \brief Maximum code block size for LDPC BG1 */ +#define SRSRAN_LDPC_BG2_MAX_LEN_CB 3840 /*!< \brief Maximum code block size for LDPC BG2 */ +#define SRSRAN_LDPC_MAX_LEN_CB \ + SRSRAN_MAX(SRSRAN_LDPC_BG1_MAX_LEN_CB, \ + SRSRAN_LDPC_BG2_MAX_LEN_CB) /*!< \brief Maximum code block size for LDPC BG1 or BG2 */ #define BG1Nfull 68 /*!< \brief Number of variable nodes in BG1. */ #define BG1N 66 /*!< \brief Number of variable nodes in BG1 after puncturing. */ @@ -54,7 +54,7 @@ #define MAX_LIFTSIZE 384 /*!< \brief Maximum lifting size. */ -#define SRSLTE_LDPC_MAX_LEN_ENCODED_CB (MAX_LIFTSIZE * SRSLTE_MAX(BG1N, BG2N)) +#define SRSRAN_LDPC_MAX_LEN_ENCODED_CB (MAX_LIFTSIZE * SRSRAN_MAX(BG1N, BG2N)) #define VOID_LIFTSIZE 255 /*!< \brief Identifies an invalid lifting size in the lookup table. */ /*! @@ -63,10 +63,10 @@ #define NO_CNCT 0xFFFF /*! \brief Possible base graphs, BG1 or BG2. */ -typedef enum SRSLTE_API { +typedef enum SRSRAN_API { BG1 = 0, /*!< \brief Base Graph 1 */ BG2, /*!< \brief Base Graph 2 */ -} srslte_basegraph_t; +} srsran_basegraph_t; /*! * Creates the parity-check matrix for the given base graph and lifting size @@ -88,7 +88,7 @@ typedef enum SRSLTE_API { * \param[in] ls The desired lifting size. * \return An integer: 0 if the function executes correctly, -1 otherwise. */ -SRSLTE_API int create_compact_pcm(uint16_t* pcm, int8_t (*positions)[MAX_CNCT], srslte_basegraph_t bg, uint16_t ls); +SRSRAN_API int create_compact_pcm(uint16_t* pcm, int8_t (*positions)[MAX_CNCT], srsran_basegraph_t bg, uint16_t ls); /*! * Reads the lookup table and returns the set index corresponding to the given @@ -103,4 +103,4 @@ static inline uint8_t get_ls_index(uint16_t ls) return (ls <= MAX_LIFTSIZE ? LSindex[ls] : VOID_LIFTSIZE); } -#endif // SRSLTE_BASEGRAPH_H +#endif // SRSRAN_BASEGRAPH_H diff --git a/lib/include/srslte/phy/fec/ldpc/ldpc_common.h b/lib/include/srsran/phy/fec/ldpc/ldpc_common.h similarity index 77% rename from lib/include/srslte/phy/fec/ldpc/ldpc_common.h rename to lib/include/srsran/phy/fec/ldpc/ldpc_common.h index 27b90f848..08ebb13bc 100644 --- a/lib/include/srslte/phy/fec/ldpc/ldpc_common.h +++ b/lib/include/srsran/phy/fec/ldpc/ldpc_common.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -20,9 +20,9 @@ * */ -#ifndef SRSLTE_LDPCCOMMON_H -#define SRSLTE_LDPCCOMMON_H +#ifndef SRSRAN_LDPCCOMMON_H +#define SRSRAN_LDPCCOMMON_H #define FILLER_BIT 254 /*!< \brief Identifies a filler bit. */ -#endif // SRSLTE_LDPCCOMMON_H +#endif // SRSRAN_LDPCCOMMON_H diff --git a/lib/include/srslte/phy/fec/ldpc/ldpc_decoder.h b/lib/include/srsran/phy/fec/ldpc/ldpc_decoder.h similarity index 77% rename from lib/include/srslte/phy/fec/ldpc/ldpc_decoder.h rename to lib/include/srsran/phy/fec/ldpc/ldpc_decoder.h index c24a9814b..4875d6797 100644 --- a/lib/include/srslte/phy/fec/ldpc/ldpc_decoder.h +++ b/lib/include/srsran/phy/fec/ldpc/ldpc_decoder.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -20,33 +20,33 @@ * */ -#ifndef SRSLTE_LDPCDECODER_H -#define SRSLTE_LDPCDECODER_H +#ifndef SRSRAN_LDPCDECODER_H +#define SRSRAN_LDPCDECODER_H -#include "srslte/phy/fec/ldpc/base_graph.h" +#include "srsran/phy/fec/ldpc/base_graph.h" /*! * \brief Types of LDPC decoder. */ typedef enum { - SRSLTE_LDPC_DECODER_F, /*!< \brief %Decoder working with real-valued LLRs. */ - SRSLTE_LDPC_DECODER_S, /*!< \brief %Decoder working with 16-bit integer-valued LLRs. */ - SRSLTE_LDPC_DECODER_C, /*!< \brief %Decoder working with 8-bit integer-valued LLRs. */ - SRSLTE_LDPC_DECODER_C_FLOOD, /*!< \brief %Decoder working with 8-bit integer-valued LLRs, flooded scheduling. */ - SRSLTE_LDPC_DECODER_C_AVX2, /*!< \brief %Decoder working with 8-bit integer-valued LLRs (AVX2 version). */ - SRSLTE_LDPC_DECODER_C_AVX2_FLOOD, /*!< \brief %Decoder working with 8-bit integer-valued LLRs, flooded scheduling + SRSRAN_LDPC_DECODER_F, /*!< \brief %Decoder working with real-valued LLRs. */ + SRSRAN_LDPC_DECODER_S, /*!< \brief %Decoder working with 16-bit integer-valued LLRs. */ + SRSRAN_LDPC_DECODER_C, /*!< \brief %Decoder working with 8-bit integer-valued LLRs. */ + SRSRAN_LDPC_DECODER_C_FLOOD, /*!< \brief %Decoder working with 8-bit integer-valued LLRs, flooded scheduling. */ + SRSRAN_LDPC_DECODER_C_AVX2, /*!< \brief %Decoder working with 8-bit integer-valued LLRs (AVX2 version). */ + SRSRAN_LDPC_DECODER_C_AVX2_FLOOD, /*!< \brief %Decoder working with 8-bit integer-valued LLRs, flooded scheduling (AVX2 version). */ - SRSLTE_LDPC_DECODER_C_AVX512, /*!< \brief %Decoder working with 8-bit integer-valued LLRs (AVX512 version). */ - SRSLTE_LDPC_DECODER_C_AVX512_FLOOD, /*!< \brief %Decoder working with 8-bit integer-valued LLRs, flooded scheduling + SRSRAN_LDPC_DECODER_C_AVX512, /*!< \brief %Decoder working with 8-bit integer-valued LLRs (AVX512 version). */ + SRSRAN_LDPC_DECODER_C_AVX512_FLOOD, /*!< \brief %Decoder working with 8-bit integer-valued LLRs, flooded scheduling (AVX512 version). */ -} srslte_ldpc_decoder_type_t; +} srsran_ldpc_decoder_type_t; /*! * \brief Describes an LDPC decoder. */ -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { void* ptr; /*!< \brief Registers used by the decoder. */ - srslte_basegraph_t bg; /*!< \brief Current base graph. */ + srsran_basegraph_t bg; /*!< \brief Current base graph. */ uint16_t ls; /*!< \brief Current lifting size. */ uint8_t bgN; /*!< \brief Number of variable nodes in the BG. */ uint16_t liftN; /*!< \brief Number of variable nodes in the lifted graph. */ @@ -74,21 +74,21 @@ typedef struct SRSLTE_API { const int8_t*, uint8_t*, uint32_t); /*!< \brief Pointer to the decoding function (16-bit version). */ -} srslte_ldpc_decoder_t; +} srsran_ldpc_decoder_t; /*! * Initializes all the LDPC decoder variables according to the given base graph * and lifting size. - * \param[out] q A pointer to a srslte_ldpc_decoder_t structure. + * \param[out] q A pointer to a srsran_ldpc_decoder_t structure. * \param[in] type Type of LDPC decoder. * \param[in] bg The desired base graph (BG1 or BG2). * \param[in] ls The desired lifting size. * \param[in] scaling_fctr Scaling factor of the normalized min-sum algorithm. * \return An integer: 0 if the function executes correctly, -1 otherwise. */ -SRSLTE_API int srslte_ldpc_decoder_init(srslte_ldpc_decoder_t* q, - srslte_ldpc_decoder_type_t type, - srslte_basegraph_t bg, +SRSRAN_API int srsran_ldpc_decoder_init(srsran_ldpc_decoder_t* q, + srsran_ldpc_decoder_type_t type, + srsran_basegraph_t bg, uint16_t ls, float scaling_fctr); @@ -96,11 +96,11 @@ SRSLTE_API int srslte_ldpc_decoder_init(srslte_ldpc_decoder_t* q, * The LDPC decoder "destructor": it frees all the resources allocated to the decoder. * \param[in] q A pointer to the dismantled decoder. */ -SRSLTE_API void srslte_ldpc_decoder_free(srslte_ldpc_decoder_t* q); +SRSRAN_API void srsran_ldpc_decoder_free(srsran_ldpc_decoder_t* q); /*! * Carries out the actual decoding with real-valued LLRs. - * \param[in] q A pointer to the LDPC decoder (a srslte_ldpc_decoder_t structure + * \param[in] q A pointer to the LDPC decoder (a srsran_ldpc_decoder_t structure * instance) that carries out the decoding. * \param[in] llrs The LLRs obtained from the channel samples that correspond to * the codeword to be decoded. @@ -108,14 +108,14 @@ SRSLTE_API void srslte_ldpc_decoder_free(srslte_ldpc_decoder_t* q); * operation. * \param[in] cdwd_rm_length The number of bits forming the codeword (after rate matching). */ -SRSLTE_API int -srslte_ldpc_decoder_decode_f(srslte_ldpc_decoder_t* q, const float* llrs, uint8_t* message, uint32_t cdwd_rm_length); +SRSRAN_API int +srsran_ldpc_decoder_decode_f(srsran_ldpc_decoder_t* q, const float* llrs, uint8_t* message, uint32_t cdwd_rm_length); /*! * Carries out the actual decoding with 16-bit integer-valued LLRs. It is * recommended to use a 15-bit representation for the LLRs, given that all * values exceeding \f$ 2^{15}-1 \f$ (in magnitude) will be considered as infinity. - * \param[in] q A pointer to the LDPC decoder (a srslte_ldpc_decoder_t structure + * \param[in] q A pointer to the LDPC decoder (a srsran_ldpc_decoder_t structure * instance) that carries out the decoding. * \param[in] llrs The LLRs obtained from the channel samples that correspond to * the codeword to be decoded. @@ -123,27 +123,27 @@ srslte_ldpc_decoder_decode_f(srslte_ldpc_decoder_t* q, const float* llrs, uint8_ * operation. * \param[in] cdwd_rm_length The number of bits forming the codeword (after rate matching). */ -SRSLTE_API int -srslte_ldpc_decoder_decode_s(srslte_ldpc_decoder_t* q, const int16_t* llrs, uint8_t* message, uint32_t cdwd_rm_length); +SRSRAN_API int +srsran_ldpc_decoder_decode_s(srsran_ldpc_decoder_t* q, const int16_t* llrs, uint8_t* message, uint32_t cdwd_rm_length); /*! * Carries out the actual decoding with 8-bit integer-valued LLRs. It is * recommended to use a 7-bit representation for the LLRs, given that all * values exceeding \f$ 2^{7}-1 \f$ (in magnitude) will be considered as infinity. - * \param[in] q A pointer to the LDPC decoder (a srslte_ldpc_decoder_t structure + * \param[in] q A pointer to the LDPC decoder (a srsran_ldpc_decoder_t structure * instance) that carries out the decoding. * \param[in] llrs The LLRs obtained from the channel samples that correspond to * the codeword to be decoded. * \param[out] message The message (uncoded bits) resulting from the decoding * operation. */ -SRSLTE_API int srslte_ldpc_decoder_decode_c(srslte_ldpc_decoder_t* q, const int8_t* llrs, uint8_t* message); +SRSRAN_API int srsran_ldpc_decoder_decode_c(srsran_ldpc_decoder_t* q, const int8_t* llrs, uint8_t* message); /*! * Carries out the actual decoding with 8-bit integer-valued LLRs. It is * recommended to use a 7-bit representation for the LLRs, given that all * values exceeding \f$ 2^{7}-1 \f$ (in magnitude) will be considered as infinity. - * \param[in] q A pointer to the LDPC decoder (a srslte_ldpc_decoder_t structure + * \param[in] q A pointer to the LDPC decoder (a srsran_ldpc_decoder_t structure * instance) that carries out the decoding. * \param[in] llrs The LLRs obtained from the channel samples that correspond to * the codeword to be decoded. @@ -151,9 +151,9 @@ SRSLTE_API int srslte_ldpc_decoder_decode_c(srslte_ldpc_decoder_t* q, const int8 * operation. * \param[in] cdwd_rm_length The number of bits forming the codeword (after rate matching). */ -SRSLTE_API int srslte_ldpc_decoder_decode_rm_c(srslte_ldpc_decoder_t* q, +SRSRAN_API int srsran_ldpc_decoder_decode_rm_c(srsran_ldpc_decoder_t* q, const int8_t* llrs, uint8_t* message, uint32_t cdwd_rm_length); -#endif // SRSLTE_LDPCDECODER_H +#endif // SRSRAN_LDPCDECODER_H diff --git a/lib/include/srslte/phy/fec/ldpc/ldpc_encoder.h b/lib/include/srsran/phy/fec/ldpc/ldpc_encoder.h similarity index 78% rename from lib/include/srslte/phy/fec/ldpc/ldpc_encoder.h rename to lib/include/srsran/phy/fec/ldpc/ldpc_encoder.h index 9f53332b3..5f894afd2 100644 --- a/lib/include/srslte/phy/fec/ldpc/ldpc_encoder.h +++ b/lib/include/srsran/phy/fec/ldpc/ldpc_encoder.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -20,30 +20,30 @@ * */ -#ifndef SRSLTE_LDPCENCODER_H -#define SRSLTE_LDPCENCODER_H +#ifndef SRSRAN_LDPCENCODER_H +#define SRSRAN_LDPCENCODER_H -#include "srslte/phy/fec/ldpc/base_graph.h" +#include "srsran/phy/fec/ldpc/base_graph.h" /*! * \brief Types of LDPC encoder. */ -typedef enum SRSLTE_API { - SRSLTE_LDPC_ENCODER_C = 0, /*!< \brief Non-optimized encoder. */ +typedef enum SRSRAN_API { + SRSRAN_LDPC_ENCODER_C = 0, /*!< \brief Non-optimized encoder. */ #if LV_HAVE_AVX2 - SRSLTE_LDPC_ENCODER_AVX2, /*!< \brief SIMD-optimized encoder. */ + SRSRAN_LDPC_ENCODER_AVX2, /*!< \brief SIMD-optimized encoder. */ #endif // LV_HAVE_AVX2 #if LV_HAVE_AVX512 - SRSLTE_LDPC_ENCODER_AVX512, /*!< \brief SIMD-optimized encoder. */ + SRSRAN_LDPC_ENCODER_AVX512, /*!< \brief SIMD-optimized encoder. */ #endif // LV_HAVE_AVX512 -} srslte_ldpc_encoder_type_t; +} srsran_ldpc_encoder_type_t; /*! * \brief Describes an LDPC encoder. */ -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { void* ptr; /*!< \brief %Encoder auxiliary registers. */ - srslte_basegraph_t bg; /*!< \brief Current base graph. */ + srsran_basegraph_t bg; /*!< \brief Current base graph. */ uint16_t ls; /*!< \brief Current lifting size. */ uint8_t bgN; /*!< \brief Number of variable nodes in the BG. */ uint16_t liftN; /*!< \brief Number of variable nodes in the lifted graph. */ @@ -62,25 +62,25 @@ typedef struct SRSLTE_API { /*! \brief Pointer to the encoder for the high-rate region (SIMD-AVX512-optimized version). */ void (*encode_high_rate_avx512)(void*); -} srslte_ldpc_encoder_t; +} srsran_ldpc_encoder_t; /*! * Initializes all the LDPC encoder variables according to the given base graph * and lifting size. - * \param[out] q A pointer to a srslte_ldpc_encoder_t structure. + * \param[out] q A pointer to a srsran_ldpc_encoder_t structure. * \param[in] type The encoder type. * \param[in] bg The desired base graph (BG1 or BG2). * \param[in] ls The desired lifting size. * \return An integer: 0 if the function executes correctly, -1 otherwise. */ -SRSLTE_API int -srslte_ldpc_encoder_init(srslte_ldpc_encoder_t* q, srslte_ldpc_encoder_type_t type, srslte_basegraph_t bg, uint16_t ls); +SRSRAN_API int +srsran_ldpc_encoder_init(srsran_ldpc_encoder_t* q, srsran_ldpc_encoder_type_t type, srsran_basegraph_t bg, uint16_t ls); /*! * The LDPC encoder "destructor": it frees all the resources allocated to the encoder. * \param[in] q A pointer to the dismantled encoder. */ -SRSLTE_API void srslte_ldpc_encoder_free(srslte_ldpc_encoder_t* q); +SRSRAN_API void srsran_ldpc_encoder_free(srsran_ldpc_encoder_t* q); /*! * Encodes a message into a codeword with the specified encoder. @@ -90,8 +90,8 @@ SRSLTE_API void srslte_ldpc_encoder_free(srslte_ldpc_encoder_t* q); * \param[in] input_length The number of uncoded bits in the input message. * \return An integer: 0 if the function executes correctly, -1 otherwise. */ -SRSLTE_API int -srslte_ldpc_encoder_encode(srslte_ldpc_encoder_t* q, const uint8_t* input, uint8_t* output, uint32_t input_length); +SRSRAN_API int +srsran_ldpc_encoder_encode(srsran_ldpc_encoder_t* q, const uint8_t* input, uint8_t* output, uint32_t input_length); /*! * Encodes a message into a codeword with the specified encoder. @@ -102,10 +102,10 @@ srslte_ldpc_encoder_encode(srslte_ldpc_encoder_t* q, const uint8_t* input, uint8 * \param[in] cdwd_rm_length The codeword length after rate matching. * \return An integer: 0 if the function executes correctly, -1 otherwise. */ -SRSLTE_API int srslte_ldpc_encoder_encode_rm(srslte_ldpc_encoder_t* q, +SRSRAN_API int srsran_ldpc_encoder_encode_rm(srsran_ldpc_encoder_t* q, const uint8_t* input, uint8_t* output, uint32_t input_length, uint32_t cdwd_rm_length); -#endif // SRSLTE_LDPCENCODER_H +#endif // SRSRAN_LDPCENCODER_H diff --git a/lib/include/srslte/phy/fec/ldpc/ldpc_rm.h b/lib/include/srsran/phy/fec/ldpc/ldpc_rm.h similarity index 79% rename from lib/include/srslte/phy/fec/ldpc/ldpc_rm.h rename to lib/include/srsran/phy/fec/ldpc/ldpc_rm.h index cf5b87c9e..c9c5a2f66 100644 --- a/lib/include/srslte/phy/fec/ldpc/ldpc_rm.h +++ b/lib/include/srsran/phy/fec/ldpc/ldpc_rm.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -20,18 +20,18 @@ * */ -#ifndef SRSLTE_LDPCRM_H -#define SRSLTE_LDPCRM_H +#ifndef SRSRAN_LDPCRM_H +#define SRSRAN_LDPCRM_H -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/fec/ldpc/base_graph.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/fec/ldpc/base_graph.h" /*! * \brief Describes a rate matcher or rate dematcher (K, F are ignored at rate matcher) */ -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { void* ptr; /*!< \brief %Rate Matcher auxiliary registers. */ - srslte_basegraph_t bg; /*!< \brief Current base graph. */ + srsran_basegraph_t bg; /*!< \brief Current base graph. */ uint16_t ls; /*!< \brief Current lifting size. */ uint32_t N; /*!< \brief Codeword size. */ uint32_t E; /*!< \brief Rate-Matched codeword size. */ @@ -40,18 +40,18 @@ typedef struct SRSLTE_API { uint32_t k0; /*!< \brief Starting position in the circular buffer. */ uint32_t mod_order; /*!< \brief Modulation order. */ uint32_t Ncb; /*!< \brief Limit to the number of bits in the circular buffer. */ -} srslte_ldpc_rm_t; +} srsran_ldpc_rm_t; /*! * Initializes the Rate Matcher for the maximum rate-matched codeword length - * \param[out] q A pointer to a srslte_ldpc_rm_t structure. + * \param[out] q A pointer to a srsran_ldpc_rm_t structure. * \return An integer: 0 if the function executes correctly, -1 otherwise. */ -SRSLTE_API int srslte_ldpc_rm_tx_init(srslte_ldpc_rm_t* q); +SRSRAN_API int srsran_ldpc_rm_tx_init(srsran_ldpc_rm_t* q); /*! * Carries out the actual rate-matching. - * \param[in] q A pointer to the Rate-Matcher (a srslte_ldpc_rm_t structure + * \param[in] q A pointer to the Rate-Matcher (a srsran_ldpc_rm_t structure * instance) that carries out the rate matching. * \param[in] input The codeword obtained from the ldpc encoder. * \param[out] output The rate-matched codeword resulting from the rate-matching @@ -64,26 +64,26 @@ SRSLTE_API int srslte_ldpc_rm_tx_init(srslte_ldpc_rm_t* q); * \param[in] Nref Size of limited buffer. * \return An integer: 0 if the function executes correctly, -1 otherwise. */ -SRSLTE_API int srslte_ldpc_rm_tx(srslte_ldpc_rm_t* q, +SRSRAN_API int srsran_ldpc_rm_tx(srsran_ldpc_rm_t* q, const uint8_t* input, uint8_t* output, const uint32_t E, - const srslte_basegraph_t bg, + const srsran_basegraph_t bg, const uint32_t ls, const uint8_t rv, - const srslte_mod_t mod_type, + const srsran_mod_t mod_type, const uint32_t Nref); /*! * Initializes all the Rate DeMatcher variables. - * \param[out] q A pointer to a srslte_ldpc_rm_t structure. + * \param[out] q A pointer to a srsran_ldpc_rm_t structure. * \return An integer: 0 if the function executes correctly, -1 otherwise. */ -SRSLTE_API int srslte_ldpc_rm_rx_init_f(srslte_ldpc_rm_t* q); +SRSRAN_API int srsran_ldpc_rm_rx_init_f(srsran_ldpc_rm_t* q); /*! * Carries out the actual rate-dematching. - * \param[in] q A pointer to the Rate-DeMatcher (a srslte_ldpc_rm_t structure + * \param[in] q A pointer to the Rate-DeMatcher (a srsran_ldpc_rm_t structure * instance) that carries out the rate matching. * \param[in] input The LLRs obtained from the channel samples that correspond to * the codeword to be first, rate-dematched and then decoded. @@ -99,27 +99,27 @@ SRSLTE_API int srslte_ldpc_rm_rx_init_f(srslte_ldpc_rm_t* q); * \param[in] Nref Size of limited buffer. * \return An integer: 0 if the function executes correctly, -1 otherwise. */ -SRSLTE_API int srslte_ldpc_rm_rx_f(srslte_ldpc_rm_t* q, +SRSRAN_API int srsran_ldpc_rm_rx_f(srsran_ldpc_rm_t* q, const float* input, float* output, const uint32_t E, const uint32_t F, - const srslte_basegraph_t bg, + const srsran_basegraph_t bg, const uint32_t ls, const uint8_t rv, - const srslte_mod_t mod_type, + const srsran_mod_t mod_type, const uint32_t Nref); /*! * Initializes all the Rate DeMatcher variables (short inputs). - * \param[out] q A pointer to a srslte_ldpc_rm_t structure. + * \param[out] q A pointer to a srsran_ldpc_rm_t structure. * \return An integer: 0 if the function executes correctly, -1 otherwise. */ -SRSLTE_API int srslte_ldpc_rm_rx_init_s(srslte_ldpc_rm_t* q); +SRSRAN_API int srsran_ldpc_rm_rx_init_s(srsran_ldpc_rm_t* q); /*! * Carries out the actual rate-dematching (short symbols). - * \param[in] q A pointer to the Rate-DeMatcher (a srslte_ldpc_rm_t structure + * \param[in] q A pointer to the Rate-DeMatcher (a srsran_ldpc_rm_t structure * instance) that carries out the rate matching. * \param[in] input The LLRs obtained from the channel samples that correspond to * the codeword to be first, rate-dematched and then decoded. @@ -135,27 +135,27 @@ SRSLTE_API int srslte_ldpc_rm_rx_init_s(srslte_ldpc_rm_t* q); * \param[in] Nref Size of limited buffer. * \return An integer: 0 if the function executes correctly, -1 otherwise. */ -SRSLTE_API int srslte_ldpc_rm_rx_s(srslte_ldpc_rm_t* q, +SRSRAN_API int srsran_ldpc_rm_rx_s(srsran_ldpc_rm_t* q, const int16_t* input, int16_t* output, const uint32_t E, const uint32_t F, - const srslte_basegraph_t bg, + const srsran_basegraph_t bg, const uint32_t ls, const uint8_t rv, - const srslte_mod_t mod_type, + const srsran_mod_t mod_type, const uint32_t Nref); /*! * Initializes all the Rate DeMatcher variables (char inputs). - * \param[out] q A pointer to a srslte_ldpc_rm_t structure. + * \param[out] q A pointer to a srsran_ldpc_rm_t structure. * \return An integer: 0 if the function executes correctly, -1 otherwise. */ -SRSLTE_API int srslte_ldpc_rm_rx_init_c(srslte_ldpc_rm_t* q); +SRSRAN_API int srsran_ldpc_rm_rx_init_c(srsran_ldpc_rm_t* q); /*! * Carries out the actual rate-dematching (int8_t symbols). - * \param[in] q A pointer to the Rate-DeMatcher (a srslte_ldpc_rm_t structure + * \param[in] q A pointer to the Rate-DeMatcher (a srsran_ldpc_rm_t structure * instance) that carries out the rate matching. * \param[in] input The LLRs obtained from the channel samples that correspond to * the codeword to be first, rate-dematched and then decoded. @@ -171,39 +171,39 @@ SRSLTE_API int srslte_ldpc_rm_rx_init_c(srslte_ldpc_rm_t* q); * \param[in] Nref Size of limited buffer. * \return An integer: 0 if the function executes correctly, -1 otherwise. */ -SRSLTE_API int srslte_ldpc_rm_rx_c(srslte_ldpc_rm_t* q, +SRSRAN_API int srsran_ldpc_rm_rx_c(srsran_ldpc_rm_t* q, const int8_t* input, int8_t* output, const uint32_t E, const uint32_t F, - const srslte_basegraph_t bg, + const srsran_basegraph_t bg, const uint32_t ls, const uint8_t rv, - const srslte_mod_t mod_type, + const srsran_mod_t mod_type, const uint32_t Nref); /*! * The Rate Matcher "destructor": it frees all the resources allocated to the rate-matcher. * \param[in] q A pointer to the dismantled rate-matcher. */ -SRSLTE_API void srslte_ldpc_rm_tx_free(srslte_ldpc_rm_t* q); +SRSRAN_API void srsran_ldpc_rm_tx_free(srsran_ldpc_rm_t* q); /*! * The Rate Matcher "destructor": it frees all the resources allocated to the rate-dematcher. * \param[in] q A pointer to the dismantled rate-dematcher. */ -SRSLTE_API void srslte_ldpc_rm_rx_free_f(srslte_ldpc_rm_t* q); +SRSRAN_API void srsran_ldpc_rm_rx_free_f(srsran_ldpc_rm_t* q); /*! * The Rate Matcher "destructor" for short symbols: it frees all the resources allocated to the rate-dematcher. * \param[in] q A pointer to the dismantled rate-dematcher. */ -SRSLTE_API void srslte_ldpc_rm_rx_free_s(srslte_ldpc_rm_t* q); +SRSRAN_API void srsran_ldpc_rm_rx_free_s(srsran_ldpc_rm_t* q); /*! * The Rate Matcher "destructor" for int8_t symbols: it frees all the resources allocated to the rate-dematcher. * \param[in] q A pointer to the dismantled rate-dematcher. */ -SRSLTE_API void srslte_ldpc_rm_rx_free_c(srslte_ldpc_rm_t* q); +SRSRAN_API void srsran_ldpc_rm_rx_free_c(srsran_ldpc_rm_t* q); -#endif // SRSLTE_LDPCENCODER_H +#endif // SRSRAN_LDPCENCODER_H diff --git a/lib/include/srslte/phy/fec/polar/polar_chanalloc.h b/lib/include/srsran/phy/fec/polar/polar_chanalloc.h similarity index 88% rename from lib/include/srslte/phy/fec/polar/polar_chanalloc.h rename to lib/include/srsran/phy/fec/polar/polar_chanalloc.h index 2d8a3dd95..bf6b7c0c8 100644 --- a/lib/include/srslte/phy/fec/polar/polar_chanalloc.h +++ b/lib/include/srsran/phy/fec/polar/polar_chanalloc.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -21,10 +21,10 @@ * */ -#ifndef SRSLTE_CHANALLOC_H -#define SRSLTE_CHANALLOC_H +#ifndef SRSRAN_CHANALLOC_H +#define SRSRAN_CHANALLOC_H -#include "srslte/config.h" +#include "srsran/config.h" #include "stdint.h" /*! @@ -39,7 +39,7 @@ * \param[in] K_set Pointer to the indices of the encoder input vector containing. * \param[in] PC_set Pointer to the indices of the parity check bits. */ -void srslte_polar_chanalloc_tx(const uint8_t* message, +void srsran_polar_chanalloc_tx(const uint8_t* message, uint8_t* input_encoder, const uint16_t N, const uint16_t K, @@ -57,11 +57,11 @@ void srslte_polar_chanalloc_tx(const uint8_t* message, * \param[in] K_set Pointer to the indices of the encoder input vector containing. * \param[in] PC_set Pointer to the indices of the parity check bits. */ -void srslte_polar_chanalloc_rx(const uint8_t* output_decoder, +void srsran_polar_chanalloc_rx(const uint8_t* output_decoder, uint8_t* message, const uint16_t K, const uint8_t nPC, const uint16_t* K_set, const uint16_t* PC_set); -#endif // SRSLTE_CHANALLOC_H +#endif // SRSRAN_CHANALLOC_H diff --git a/lib/include/srslte/phy/fec/polar/polar_code.h b/lib/include/srsran/phy/fec/polar/polar_code.h similarity index 98% rename from lib/include/srslte/phy/fec/polar/polar_code.h rename to lib/include/srsran/phy/fec/polar/polar_code.h index cab6c14eb..a20d44394 100644 --- a/lib/include/srslte/phy/fec/polar/polar_code.h +++ b/lib/include/srsran/phy/fec/polar/polar_code.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -25,11 +25,11 @@ * */ -#ifndef SRSLTE_POLAR_CODE_H -#define SRSLTE_POLAR_CODE_H +#ifndef SRSRAN_POLAR_CODE_H +#define SRSRAN_POLAR_CODE_H -#include "srslte/config.h" -#include "srslte/phy/utils/debug.h" +#include "srsran/config.h" +#include "srsran/phy/utils/debug.h" #include //#define debug @@ -324,7 +324,7 @@ typedef struct { uint16_t* tmp_K_set; /*!< \brief Temporal Pointer. */ uint16_t PC_set[4]; /*!< \brief Pointer to the indices of the encoder input vector containing the parity bits.*/ uint16_t* F_set; /*!< \brief Pointer to the indices of the encoder input vector containing frozen bits.*/ -} srslte_polar_code_t; +} srsran_polar_code_t; /*! * Returns a pointer to the desired mother code. @@ -391,7 +391,7 @@ static inline const uint16_t* get_blk_interleaver(uint8_t n) * \param[out] c A pointer to the initialized polar code. * \return An integer: 0 if the function executes correctly, -1 otherwise. */ -int srslte_polar_code_init(srslte_polar_code_t* c); +int srsran_polar_code_init(srsran_polar_code_t* c); /*! * Initializes the different index sets as needed by the subchannel allocation block and/or by the polar decoder. @@ -402,12 +402,12 @@ int srslte_polar_code_init(srslte_polar_code_t* c); * uplink. * \return An integer: 0 if the function executes correctly, -1 otherwise. */ -int srslte_polar_code_get(srslte_polar_code_t* c, const uint16_t K, const uint16_t E, const uint8_t nMax); +int srsran_polar_code_get(srsran_polar_code_t* c, const uint16_t K, const uint16_t E, const uint8_t nMax); /*! * The polar code "destructor": it frees all the resources. * \param[in] c A pointer to the dismantled polar code. */ -void srslte_polar_code_free(srslte_polar_code_t* c); +void srsran_polar_code_free(srsran_polar_code_t* c); -#endif // SRSLTE_POLAR_CODE_H +#endif // SRSRAN_POLAR_CODE_H diff --git a/lib/include/srslte/phy/fec/polar/polar_decoder.h b/lib/include/srsran/phy/fec/polar/polar_decoder.h similarity index 86% rename from lib/include/srslte/phy/fec/polar/polar_decoder.h rename to lib/include/srsran/phy/fec/polar/polar_decoder.h index 7daf6584e..7b7810bbc 100644 --- a/lib/include/srslte/phy/fec/polar/polar_decoder.h +++ b/lib/include/srsran/phy/fec/polar/polar_decoder.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -22,27 +22,27 @@ * */ -#ifndef SRSLTE_POLARDECODER_H -#define SRSLTE_POLARDECODER_H -#include "srslte/config.h" +#ifndef SRSRAN_POLARDECODER_H +#define SRSRAN_POLARDECODER_H +#include "srsran/config.h" #include #include /*! * Lists the different types of polar decoder. */ -typedef enum SRSLTE_API { - SRSLTE_POLAR_DECODER_SSC_F = 0, /*!< \brief Floating-point Simplified Successive Cancellation (SSC) decoder. */ - SRSLTE_POLAR_DECODER_SSC_S = 1, /*!< \brief Fixed-point (16 bit) Simplified Successive Cancellation (SSC) decoder. */ - SRSLTE_POLAR_DECODER_SSC_C = 2, /*!< \brief Fixed-point (8 bit) Simplified Successive Cancellation (SSC) decoder. */ - SRSLTE_POLAR_DECODER_SSC_C_AVX2 = +typedef enum SRSRAN_API { + SRSRAN_POLAR_DECODER_SSC_F = 0, /*!< \brief Floating-point Simplified Successive Cancellation (SSC) decoder. */ + SRSRAN_POLAR_DECODER_SSC_S = 1, /*!< \brief Fixed-point (16 bit) Simplified Successive Cancellation (SSC) decoder. */ + SRSRAN_POLAR_DECODER_SSC_C = 2, /*!< \brief Fixed-point (8 bit) Simplified Successive Cancellation (SSC) decoder. */ + SRSRAN_POLAR_DECODER_SSC_C_AVX2 = 3 /*!< \brief Fixed-point (8 bit, avx2) Simplified Successive Cancellation (SSC) decoder. */ -} srslte_polar_decoder_type_t; +} srsran_polar_decoder_type_t; /*! * \brief Describes a polar decoder. */ -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { void* ptr; /*!< \brief Pointer to the actual polar decoder structure. */ uint8_t nMax; /*!< \brief Maximum \f$log_2(code_size)\f$. */ int (*decode_f)(void* ptr, @@ -64,7 +64,7 @@ typedef struct SRSLTE_API { const uint16_t* frozen_set, const uint16_t frozen_set_size); /*!< \brief Pointer to the decoder function (8-bit version). */ void (*free)(void*); /*!< \brief Pointer to a "destructor". */ -} srslte_polar_decoder_t; +} srsran_polar_decoder_t; /*! * Initializes all the polar decoder variables according to the selected decoding @@ -74,15 +74,15 @@ typedef struct SRSLTE_API { * \param[in] code_size_log The \f$ log_2\f$ of the number of bits of the decoder input/output vector. * \return An integer: 0 if the function executes correctly, -1 otherwise. */ -SRSLTE_API int srslte_polar_decoder_init(srslte_polar_decoder_t* q, - srslte_polar_decoder_type_t polar_decoder_type, +SRSRAN_API int srsran_polar_decoder_init(srsran_polar_decoder_t* q, + srsran_polar_decoder_type_t polar_decoder_type, const uint8_t code_size_log); /*! * The polar decoder "destructor": it frees all the resources. * \param[in, out] q A pointer to the dismantled decoder. */ -SRSLTE_API void srslte_polar_decoder_free(srslte_polar_decoder_t* q); +SRSRAN_API void srsran_polar_decoder_free(srsran_polar_decoder_t* q); /*! * Decodes the input (float) codeword with the specified polar decoder. @@ -94,7 +94,7 @@ SRSLTE_API void srslte_polar_decoder_free(srslte_polar_decoder_t* q); * \param[in] frozen_set_size The size of the frozen_set. * \return An integer: 0 if the function executes correctly, -1 otherwise. */ -SRSLTE_API int srslte_polar_decoder_decode_f(srslte_polar_decoder_t* q, +SRSRAN_API int srsran_polar_decoder_decode_f(srsran_polar_decoder_t* q, const float* input_llr, uint8_t* data_decoded, const uint8_t code_size_log, @@ -112,7 +112,7 @@ SRSLTE_API int srslte_polar_decoder_decode_f(srslte_polar_decoder_t* q, * \return An integer: 0 if the function executes correctly, -1 otherwise. */ -SRSLTE_API int srslte_polar_decoder_decode_s(srslte_polar_decoder_t* q, +SRSRAN_API int srsran_polar_decoder_decode_s(srsran_polar_decoder_t* q, const int16_t* input_llr, uint8_t* data_decoded, const uint8_t code_size_log, @@ -129,11 +129,11 @@ SRSLTE_API int srslte_polar_decoder_decode_s(srslte_polar_decoder_t* q, * \param[in] frozen_set_size The size of the frozen_set. * \return An integer: 0 if the function executes correctly, -1 otherwise. */ -SRSLTE_API int srslte_polar_decoder_decode_c(srslte_polar_decoder_t* q, +SRSRAN_API int srsran_polar_decoder_decode_c(srsran_polar_decoder_t* q, const int8_t* input_llr, uint8_t* data_decoded, const uint8_t code_size_log, const uint16_t* frozen_set, const uint16_t frozen_set_size); -#endif // SRSLTE_POLARDECODER_H +#endif // SRSRAN_POLARDECODER_H diff --git a/lib/include/srslte/phy/fec/polar/polar_encoder.h b/lib/include/srsran/phy/fec/polar/polar_encoder.h similarity index 75% rename from lib/include/srslte/phy/fec/polar/polar_encoder.h rename to lib/include/srsran/phy/fec/polar/polar_encoder.h index 7a66ce0ab..c3647d778 100644 --- a/lib/include/srslte/phy/fec/polar/polar_encoder.h +++ b/lib/include/srsran/phy/fec/polar/polar_encoder.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -22,31 +22,31 @@ * */ -#ifndef SRSLTE_POLAR_ENCODER_H -#define SRSLTE_POLAR_ENCODER_H +#ifndef SRSRAN_POLAR_ENCODER_H +#define SRSRAN_POLAR_ENCODER_H -#include "srslte/config.h" +#include "srsran/config.h" #include /*! * Lists the different types of polar decoder. */ typedef enum { - SRSLTE_POLAR_ENCODER_PIPELINED = 0, /*!< \brief Non-optimized version of the pipelined polar encoder*/ - SRSLTE_POLAR_ENCODER_AVX2 = 1, /*!< \brief SIMD implementation of the polar encoder */ -} srslte_polar_encoder_type_t; + SRSRAN_POLAR_ENCODER_PIPELINED = 0, /*!< \brief Non-optimized version of the pipelined polar encoder*/ + SRSRAN_POLAR_ENCODER_AVX2 = 1, /*!< \brief SIMD implementation of the polar encoder */ +} srsran_polar_encoder_type_t; /*! * \brief Describes a polar encoder. */ -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { void* ptr; /*!< \brief Pointer to the actual polar encoder structure. */ int (*encode)(void* ptr, const uint8_t* input, uint8_t* output, const uint8_t code_size_log); /*!< \brief Pointer to the encoder function. */ void (*free)(void*); /*!< \brief Pointer to a "destructor". */ -} srslte_polar_encoder_t; +} srsran_polar_encoder_t; /*! * Initializes all the polar encoder variables according to the given code size. @@ -55,15 +55,15 @@ typedef struct SRSLTE_API { * \param[in] code_size_log The \f$ log_2\f$ of the number of bits of the encoder input/output vector. * \return An integer: 0 if the function executes correctly, -1 otherwise. */ -SRSLTE_API int srslte_polar_encoder_init(srslte_polar_encoder_t* q, - srslte_polar_encoder_type_t polar_encoder_type, +SRSRAN_API int srsran_polar_encoder_init(srsran_polar_encoder_t* q, + srsran_polar_encoder_type_t polar_encoder_type, uint8_t code_size_log); /*! * The polar encoder "destructor": it frees all the resources. * \param[in, out] q A pointer to the dismantled encoder. */ -SRSLTE_API void srslte_polar_encoder_free(srslte_polar_encoder_t* q); +SRSRAN_API void srsran_polar_encoder_free(srsran_polar_encoder_t* q); /*! * Encodes the input vector into a codeword with the specified polar encoder. @@ -71,11 +71,11 @@ SRSLTE_API void srslte_polar_encoder_free(srslte_polar_encoder_t* q); * \param[in] input The encoder input vector. * \param[in] code_size_log The \f$ log_2\f$ of the number of bits of the encoder input/output vector. * It cannot be larger than the maximum code_size_log specified in q.code_size_log of - * the srslte_polar_encoder_t structure. + * the srsran_polar_encoder_t structure. * \param[out] output The encoder output vector. * \return An integer: 0 if the function executes correctly, -1 otherwise. */ -SRSLTE_API int -srslte_polar_encoder_encode(srslte_polar_encoder_t* q, const uint8_t* input, uint8_t* output, uint8_t code_size_log); +SRSRAN_API int +srsran_polar_encoder_encode(srsran_polar_encoder_t* q, const uint8_t* input, uint8_t* output, uint8_t code_size_log); -#endif // SRSLTE_POLAR_ENCODER_H +#endif // SRSRAN_POLAR_ENCODER_H diff --git a/lib/include/srslte/phy/fec/polar/polar_interleaver.h b/lib/include/srsran/phy/fec/polar/polar_interleaver.h similarity index 72% rename from lib/include/srslte/phy/fec/polar/polar_interleaver.h rename to lib/include/srsran/phy/fec/polar/polar_interleaver.h index 9638d45a0..8e7c47e20 100644 --- a/lib/include/srslte/phy/fec/polar/polar_interleaver.h +++ b/lib/include/srsran/phy/fec/polar/polar_interleaver.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,14 +10,14 @@ * */ -#ifndef SRSLTE_POLAR_INTERLEAVER_H -#define SRSLTE_POLAR_INTERLEAVER_H +#ifndef SRSRAN_POLAR_INTERLEAVER_H +#define SRSRAN_POLAR_INTERLEAVER_H -#include "srslte/config.h" +#include "srsran/config.h" #include #include -#define SRSLTE_POLAR_INTERLEAVER_K_MAX_IL 164 +#define SRSRAN_POLAR_INTERLEAVER_K_MAX_IL 164 /** * * @brief Implements generic Polar code interleaver as described in TS 38.212 V15.9.0 Section 5.3.1.1 @@ -30,12 +30,12 @@ * @param K Number of elements * @param dir Set to true for encoder and false for decoder */ -SRSLTE_API void srslte_polar_interleaver_run(const void* in, void* out, uint32_t S, uint32_t K, bool dir); +SRSRAN_API void srsran_polar_interleaver_run(const void* in, void* out, uint32_t S, uint32_t K, bool dir); -#define SRSLTE_POLAR_INTERLEAVE_GEN(NAME, TYPE) \ - static inline void srslte_polar_interleaver_run_##NAME(const TYPE* in, void* out, uint32_t K, bool dir) \ +#define SRSRAN_POLAR_INTERLEAVE_GEN(NAME, TYPE) \ + static inline void srsran_polar_interleaver_run_##NAME(const TYPE* in, void* out, uint32_t K, bool dir) \ { \ - srslte_polar_interleaver_run(in, out, (uint32_t)sizeof(TYPE), K, dir); \ + srsran_polar_interleaver_run(in, out, (uint32_t)sizeof(TYPE), K, dir); \ } /** @@ -48,7 +48,7 @@ SRSLTE_API void srslte_polar_interleaver_run(const void* in, void* out, uint32_t * @param K Number of elements * @param dir Set to true for encoder and false for decoder */ -SRSLTE_POLAR_INTERLEAVE_GEN(u16, uint16_t) +SRSRAN_POLAR_INTERLEAVE_GEN(u16, uint16_t) /** * @brief Implements Polar code interleaver as described in TS 38.212 V15.9.0 Section 5.3.1.1 @@ -60,8 +60,8 @@ SRSLTE_POLAR_INTERLEAVE_GEN(u16, uint16_t) * @param K Number of elements * @param dir Set to true for encoder and false for decoder */ -SRSLTE_POLAR_INTERLEAVE_GEN(u8, uint8_t) +SRSRAN_POLAR_INTERLEAVE_GEN(u8, uint8_t) -#undef SRSLTE_POLAR_INTERLEAVE_GEN +#undef SRSRAN_POLAR_INTERLEAVE_GEN -#endif // SRSLTE_POLAR_INTERLEAVER_H +#endif // SRSRAN_POLAR_INTERLEAVER_H diff --git a/lib/include/srslte/phy/fec/polar/polar_rm.h b/lib/include/srsran/phy/fec/polar/polar_rm.h similarity index 79% rename from lib/include/srslte/phy/fec/polar/polar_rm.h rename to lib/include/srsran/phy/fec/polar/polar_rm.h index 5eecb5403..a16c13086 100644 --- a/lib/include/srslte/phy/fec/polar/polar_rm.h +++ b/lib/include/srsran/phy/fec/polar/polar_rm.h @@ -1,8 +1,8 @@ /** * - * section COPYRIGHT + * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -20,26 +20,26 @@ * */ -#ifndef SRSLTE_POLARRM_H -#define SRSLTE_POLARRM_H +#ifndef SRSRAN_POLARRM_H +#define SRSRAN_POLARRM_H /*! * \brief Describes a polar rate matcher or rate dematcher */ -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { void* ptr; /*!< \brief Rate Matcher auxiliary registers. */ -} srslte_polar_rm_t; +} srsran_polar_rm_t; /*! * Initializes the Rate Matcher for the maximum rate-matched codeword length - * \param[out] q A pointer to a srslte_polar_rm_t structure. + * \param[out] q A pointer to a srsran_polar_rm_t structure. * \return An integer: 0 if the function executes correctly, -1 otherwise. */ -SRSLTE_API int srslte_polar_rm_tx_init(srslte_polar_rm_t* q); +SRSRAN_API int srsran_polar_rm_tx_init(srsran_polar_rm_t* q); /*! * Carries out the actual rate-matching. - * \param[in] q A pointer to the Rate-Matcher (a srslte_polar_rm_t structure + * \param[in] q A pointer to the Rate-Matcher (a srsran_polar_rm_t structure * instance) that carries out the rate matching. * \param[in] input The codeword obtained from the polar encoder. * \param[out] output The rate-matched codeword resulting from the rate-matching @@ -50,7 +50,7 @@ SRSLTE_API int srslte_polar_rm_tx_init(srslte_polar_rm_t* q); * \param[in] ibil Indicator of bit interliaver (set to 0 to disable). * \return An integer: 0 if the function executes correctly, -1 otherwise. */ -SRSLTE_API int srslte_polar_rm_tx(srslte_polar_rm_t* q, +SRSRAN_API int srsran_polar_rm_tx(srsran_polar_rm_t* q, const uint8_t* input, uint8_t* output, const uint8_t n, @@ -60,14 +60,14 @@ SRSLTE_API int srslte_polar_rm_tx(srslte_polar_rm_t* q, /*! * Initializes all the Rate DeMatcher variables. - * \param[out] q A pointer to a srslte_polar_rm_t structure. + * \param[out] q A pointer to a srsran_polar_rm_t structure. * \return An integer: 0 if the function executes correctly, -1 otherwise. */ -SRSLTE_API int srslte_polar_rm_rx_init_f(srslte_polar_rm_t* q); +SRSRAN_API int srsran_polar_rm_rx_init_f(srsran_polar_rm_t* q); /*! * Carries out the actual rate-dematching. - * \param[in] q A pointer to the Rate-DeMatcher (a srslte_polar_rm_t structure + * \param[in] q A pointer to the Rate-DeMatcher (a srsran_polar_rm_t structure * instance) that carries out the rate matching. * \param[in] input The LLRs obtained from the channel samples that correspond to * the codeword to be first, rate-dematched and then decoded. @@ -79,7 +79,7 @@ SRSLTE_API int srslte_polar_rm_rx_init_f(srslte_polar_rm_t* q); * \param[in] ibil Indicator of bit interliaver (set to 0 to disable). * \return An integer: 0 if the function executes correctly, -1 otherwise. */ -SRSLTE_API int srslte_polar_rm_rx_f(srslte_polar_rm_t* q, +SRSRAN_API int srsran_polar_rm_rx_f(srsran_polar_rm_t* q, const float* input, float* output, const uint32_t E, @@ -89,14 +89,14 @@ SRSLTE_API int srslte_polar_rm_rx_f(srslte_polar_rm_t* q, /*! * Initializes all the Rate DeMatcher variables (int16_t inputs). - * \param[out] q A pointer to a srslte_polar_rm_t structure. + * \param[out] q A pointer to a srsran_polar_rm_t structure. * \return An integer: 0 if the function executes correctly, -1 otherwise. */ -SRSLTE_API int srslte_polar_rm_rx_init_s(srslte_polar_rm_t* q); +SRSRAN_API int srsran_polar_rm_rx_init_s(srsran_polar_rm_t* q); /*! * Carries out the actual rate-dematching (in16_t inputs) - * \param[in] q A pointer to the Rate-DeMatcher (a srslte_polar_rm_t structure + * \param[in] q A pointer to the Rate-DeMatcher (a srsran_polar_rm_t structure * instance) that carries out the rate matching. * \param[in] input The LLRs obtained from the channel samples that correspond to * the codeword to be first, rate-dematched and then decoded. @@ -108,7 +108,7 @@ SRSLTE_API int srslte_polar_rm_rx_init_s(srslte_polar_rm_t* q); * \param[in] ibil Indicator of bit interliaver (set to 0 to disable). * \return An integer: 0 if the function executes correctly, -1 otherwise. */ -SRSLTE_API int srslte_polar_rm_rx_s(srslte_polar_rm_t* q, +SRSRAN_API int srsran_polar_rm_rx_s(srsran_polar_rm_t* q, const int16_t* input, int16_t* output, const uint32_t E, @@ -118,14 +118,14 @@ SRSLTE_API int srslte_polar_rm_rx_s(srslte_polar_rm_t* q, /*! * Initializes all the Rate DeMatcher variables (int8_t inputs). - * \param[out] q A pointer to a srslte_polar_rm_t structure. + * \param[out] q A pointer to a srsran_polar_rm_t structure. * \return An integer: 0 if the function executes correctly, -1 otherwise. */ -SRSLTE_API int srslte_polar_rm_rx_init_c(srslte_polar_rm_t* q); +SRSRAN_API int srsran_polar_rm_rx_init_c(srsran_polar_rm_t* q); /*! * Carries out the actual rate-dematching (int8_t inputs). - * \param[in] q A pointer to the Rate-DeMatcher (a srslte_polar_rm_t structure + * \param[in] q A pointer to the Rate-DeMatcher (a srsran_polar_rm_t structure * instance) that carries out the rate matching. * \param[in] input The LLRs obtained from the channel samples that correspond to * the codeword to be first, rate-dematched and then decoded. @@ -137,7 +137,7 @@ SRSLTE_API int srslte_polar_rm_rx_init_c(srslte_polar_rm_t* q); * \param[in] ibil Indicator of bit interliaver (set to 0 to disable). * \return An integer: 0 if the function executes correctly, -1 otherwise. */ -SRSLTE_API int srslte_polar_rm_rx_c(srslte_polar_rm_t* q, +SRSRAN_API int srsran_polar_rm_rx_c(srsran_polar_rm_t* q, const int8_t* input, int8_t* output, const uint32_t E, @@ -149,24 +149,24 @@ SRSLTE_API int srslte_polar_rm_rx_c(srslte_polar_rm_t* q, * The Rate Matcher "destructor": it frees all the resources allocated to the rate-matcher. * \param[in] q A pointer to the dismantled rate-matcher. */ -SRSLTE_API void srslte_polar_rm_tx_free(srslte_polar_rm_t* q); +SRSRAN_API void srsran_polar_rm_tx_free(srsran_polar_rm_t* q); /*! * The Rate Matcher "destructor": it frees all the resources allocated to the rate-dematcher. * \param[in] q A pointer to the dismantled rate-dematcher. */ -SRSLTE_API void srslte_polar_rm_rx_free_f(srslte_polar_rm_t* q); +SRSRAN_API void srsran_polar_rm_rx_free_f(srsran_polar_rm_t* q); /*! * The Rate Matcher "destructor" for short symbols: it frees all the resources allocated to the rate-dematcher. * \param[in] q A pointer to the dismantled rate-dematcher. */ -SRSLTE_API void srslte_polar_rm_rx_free_s(srslte_polar_rm_t* q); +SRSRAN_API void srsran_polar_rm_rx_free_s(srsran_polar_rm_t* q); /*! * The Rate Matcher "destructor" for int8_t symbols: it frees all the resources allocated to the rate-dematcher. * \param[in] q A pointer to the dismantled rate-dematcher. */ -SRSLTE_API void srslte_polar_rm_rx_free_c(srslte_polar_rm_t* q); +SRSRAN_API void srsran_polar_rm_rx_free_c(srsran_polar_rm_t* q); -#endif // SRSLTE_POLARRM_H +#endif // SRSRAN_POLARRM_H diff --git a/lib/include/srslte/phy/fec/polar/test/polar_sets.h b/lib/include/srsran/phy/fec/polar/test/polar_sets.h similarity index 89% rename from lib/include/srslte/phy/fec/polar/test/polar_sets.h rename to lib/include/srsran/phy/fec/polar/test/polar_sets.h index cf8ac4805..8fb58afd9 100644 --- a/lib/include/srslte/phy/fec/polar/test/polar_sets.h +++ b/lib/include/srsran/phy/fec/polar/test/polar_sets.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -24,10 +24,10 @@ * */ -#ifndef SRSLTE_POLAR_SETS_H -#define SRSLTE_POLAR_SETS_H +#ifndef SRSRAN_POLAR_SETS_H +#define SRSRAN_POLAR_SETS_H -#include "srslte/config.h" +#include "srsran/config.h" #include /*! @@ -43,7 +43,7 @@ typedef struct { parity check bits.*/ uint16_t* parity_set; /*!< \brief Pointer to the indices of the encoder input vector containing the parity bits.*/ uint16_t* frozen_set; /*!< \brief Pointer to the indices of the encoder input vector containing frozen bits.*/ -} srslte_polar_sets_t; +} srsran_polar_sets_t; /*! * Initializes the different index sets as needed by the subchannel allocation block and/or by the polar decoder. @@ -55,7 +55,7 @@ typedef struct { * \param[in] nWmPC Number of parity bits of minimum weight type. * \return An integer: 0 if the function executes correctly, -1 otherwise. */ -int srslte_polar_code_sets_read(srslte_polar_sets_t* c, +int srsran_polar_code_sets_read(srsran_polar_sets_t* c, uint16_t message_size, uint8_t code_size_log, uint16_t rate_matching_size, @@ -66,6 +66,6 @@ int srslte_polar_code_sets_read(srslte_polar_sets_t* c, * The polar set "destructor": it frees all the resources. * \param[in] c A pointer to the dismantled polar set. */ -void srslte_polar_code_sets_free(srslte_polar_sets_t* c); +void srsran_polar_code_sets_free(srsran_polar_sets_t* c); -#endif // SRSLTE_POLAR_SETS_H +#endif // SRSRAN_POLAR_SETS_H diff --git a/lib/include/srslte/phy/fec/polar/test/subchannel_allocation.h b/lib/include/srsran/phy/fec/polar/test/subchannel_allocation.h similarity index 79% rename from lib/include/srslte/phy/fec/polar/test/subchannel_allocation.h rename to lib/include/srsran/phy/fec/polar/test/subchannel_allocation.h index c7f57269e..7c57efbf5 100644 --- a/lib/include/srslte/phy/fec/polar/test/subchannel_allocation.h +++ b/lib/include/srsran/phy/fec/polar/test/subchannel_allocation.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -23,31 +23,31 @@ * */ -#ifndef SRSLTE_SUB_CHANNEL_ALLOC_H -#define SRSLTE_SUB_CHANNEL_ALLOC_H +#ifndef SRSRAN_SUB_CHANNEL_ALLOC_H +#define SRSRAN_SUB_CHANNEL_ALLOC_H -#include "srslte/config.h" +#include "srsran/config.h" #include "stdint.h" /*! * \brief Describes a subchannel allocation. */ -typedef struct SRSLTE_API srslte_subchn_alloc_t { +typedef struct SRSRAN_API srsran_subchn_alloc_t { uint16_t code_size; /*!< \brief Number of bits, \f$N\f$, of the encoder input/output vector. */ uint16_t message_size; /*!< \brief Number of bits, \f$K\f$, of data + CRC. */ uint16_t* message_set; /*!< \brief Pointer to the indices of the encoder input vector containing data and CRC bits. */ -} srslte_subchn_alloc_t; +} srsran_subchn_alloc_t; /*! * Initializes a subchannel allocation instance. - * \param[out] c A pointer to the srslte_subchn_alloc_t structure + * \param[out] c A pointer to the srsran_subchn_alloc_t structure * containing the parameters needed by the subchannel allocation function. * \param[in] code_size_log The \f$ log_2\f$ of the number of bits of the decoder input/output vector. * \param[in] message_set_size Number of data + CRC bits. * \param[in] message_set Pointer to the indices of the encoder input vector containing * data and CRC bits. */ -void srslte_subchannel_allocation_init(srslte_subchn_alloc_t* c, +void srsran_subchannel_allocation_init(srsran_subchn_alloc_t* c, uint8_t code_size_log, uint16_t message_set_size, uint16_t* message_set); @@ -57,21 +57,21 @@ void srslte_subchannel_allocation_init(srslte_subchn_alloc_t* c, * positions specified in \a c->message_set and zeros to the remaining * positions. This function is not fully 5G compliant as parity bits positions * are set to 0. - * \param[in] c A pointer to the srslte_subchn_alloc_t structure containing + * \param[in] c A pointer to the srsran_subchn_alloc_t structure containing * the parameters needed by the subchannel allocation function. * \param[in] message A pointer to the vector with the message bits (data and CRC). * \param[out] input_encoder A pointer to the encoder input bit vector. */ -void srslte_subchannel_allocation(const srslte_subchn_alloc_t* c, const uint8_t* message, uint8_t* input_encoder); +void srsran_subchannel_allocation(const srsran_subchn_alloc_t* c, const uint8_t* message, uint8_t* input_encoder); /*! * Extracts message bits (data + CRC) from the decoder output vector * according to the positions specified in \a c->message_set. - * \param[in] c A pointer to the srslte_subchn_alloc_t structure containing the + * \param[in] c A pointer to the srsran_subchn_alloc_t structure containing the * parameters needed by the subchannel allocation function. * \param[in] output_decoder A pointer to the decoder output bit vector. * \param[out] message A pointer to the vector with the message bits (data and CRC). */ -void srslte_subchannel_deallocation(const srslte_subchn_alloc_t* c, const uint8_t* output_decoder, uint8_t* message); +void srsran_subchannel_deallocation(const srsran_subchn_alloc_t* c, const uint8_t* output_decoder, uint8_t* message); -#endif // SRSLTE_SUB_CHANNEL_ALLOC_H +#endif // SRSRAN_SUB_CHANNEL_ALLOC_H diff --git a/lib/include/srslte/phy/fec/softbuffer.h b/lib/include/srsran/phy/fec/softbuffer.h similarity index 56% rename from lib/include/srslte/phy/fec/softbuffer.h rename to lib/include/srsran/phy/fec/softbuffer.h index c43b90ff7..1e6dbf149 100644 --- a/lib/include/srslte/phy/fec/softbuffer.h +++ b/lib/include/srsran/phy/fec/softbuffer.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -19,73 +19,73 @@ * Reference: *****************************************************************************/ -#ifndef SRSLTE_SOFTBUFFER_H -#define SRSLTE_SOFTBUFFER_H +#ifndef SRSRAN_SOFTBUFFER_H +#define SRSRAN_SOFTBUFFER_H -#include "srslte/config.h" +#include "srsran/config.h" #include #ifdef __cplusplus extern "C" { #endif -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { uint32_t max_cb; uint32_t max_cb_size; int16_t** buffer_f; uint8_t** data; bool* cb_crc; bool tb_crc; -} srslte_softbuffer_rx_t; +} srsran_softbuffer_rx_t; -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { uint32_t max_cb; uint32_t max_cb_size; uint8_t** buffer_b; -} srslte_softbuffer_tx_t; +} srsran_softbuffer_tx_t; #define SOFTBUFFER_SIZE 18600 -SRSLTE_API int srslte_softbuffer_rx_init(srslte_softbuffer_rx_t* q, uint32_t nof_prb); +SRSRAN_API int srsran_softbuffer_rx_init(srsran_softbuffer_rx_t* q, uint32_t nof_prb); /** * @brief Initialises Rx soft-buffer for a number of code blocks and their size * @param q The Rx soft-buffer pointer * @param max_cb The maximum number of code blocks to allocate * @param max_cb_size The code block size to allocate - * @return It returns SRSLTE_SUCCESS if it allocates the soft-buffer succesfully, otherwise it returns SRSLTE_ERROR code + * @return It returns SRSRAN_SUCCESS if it allocates the soft-buffer succesfully, otherwise it returns SRSRAN_ERROR code */ -SRSLTE_API int srslte_softbuffer_rx_init_guru(srslte_softbuffer_rx_t* q, uint32_t max_cb, uint32_t max_cb_size); +SRSRAN_API int srsran_softbuffer_rx_init_guru(srsran_softbuffer_rx_t* q, uint32_t max_cb, uint32_t max_cb_size); -SRSLTE_API void srslte_softbuffer_rx_reset(srslte_softbuffer_rx_t* p); +SRSRAN_API void srsran_softbuffer_rx_reset(srsran_softbuffer_rx_t* p); -SRSLTE_API void srslte_softbuffer_rx_reset_tbs(srslte_softbuffer_rx_t* q, uint32_t tbs); +SRSRAN_API void srsran_softbuffer_rx_reset_tbs(srsran_softbuffer_rx_t* q, uint32_t tbs); -SRSLTE_API void srslte_softbuffer_rx_reset_cb(srslte_softbuffer_rx_t* q, uint32_t nof_cb); +SRSRAN_API void srsran_softbuffer_rx_reset_cb(srsran_softbuffer_rx_t* q, uint32_t nof_cb); -SRSLTE_API void srslte_softbuffer_rx_free(srslte_softbuffer_rx_t* p); +SRSRAN_API void srsran_softbuffer_rx_free(srsran_softbuffer_rx_t* p); -SRSLTE_API int srslte_softbuffer_tx_init(srslte_softbuffer_tx_t* q, uint32_t nof_prb); +SRSRAN_API int srsran_softbuffer_tx_init(srsran_softbuffer_tx_t* q, uint32_t nof_prb); /** * @brief Initialises Tx soft-buffer for a number of code blocks and their size * @param q The Tx soft-buffer pointer * @param max_cb The maximum number of code blocks to allocate * @param max_cb_size The code block size to allocate - * @return It returns SRSLTE_SUCCESS if it allocates the soft-buffer succesfully, otherwise it returns SRSLTE_ERROR code + * @return It returns SRSRAN_SUCCESS if it allocates the soft-buffer succesfully, otherwise it returns SRSRAN_ERROR code */ -SRSLTE_API int srslte_softbuffer_tx_init_guru(srslte_softbuffer_tx_t* q, uint32_t max_cb, uint32_t max_cb_size); +SRSRAN_API int srsran_softbuffer_tx_init_guru(srsran_softbuffer_tx_t* q, uint32_t max_cb, uint32_t max_cb_size); -SRSLTE_API void srslte_softbuffer_tx_reset(srslte_softbuffer_tx_t* p); +SRSRAN_API void srsran_softbuffer_tx_reset(srsran_softbuffer_tx_t* p); -SRSLTE_API void srslte_softbuffer_tx_reset_tbs(srslte_softbuffer_tx_t* q, uint32_t tbs); +SRSRAN_API void srsran_softbuffer_tx_reset_tbs(srsran_softbuffer_tx_t* q, uint32_t tbs); -SRSLTE_API void srslte_softbuffer_tx_reset_cb(srslte_softbuffer_tx_t* q, uint32_t nof_cb); +SRSRAN_API void srsran_softbuffer_tx_reset_cb(srsran_softbuffer_tx_t* q, uint32_t nof_cb); -SRSLTE_API void srslte_softbuffer_tx_free(srslte_softbuffer_tx_t* p); +SRSRAN_API void srsran_softbuffer_tx_free(srsran_softbuffer_tx_t* p); #ifdef __cplusplus } #endif -#endif // SRSLTE_SOFTBUFFER_H +#endif // SRSRAN_SOFTBUFFER_H diff --git a/lib/include/srslte/phy/fec/turbo/rm_turbo.h b/lib/include/srsran/phy/fec/turbo/rm_turbo.h similarity index 71% rename from lib/include/srslte/phy/fec/turbo/rm_turbo.h rename to lib/include/srsran/phy/fec/turbo/rm_turbo.h index d825ce120..479ed5561 100644 --- a/lib/include/srslte/phy/fec/turbo/rm_turbo.h +++ b/lib/include/srsran/phy/fec/turbo/rm_turbo.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -18,23 +18,23 @@ * Reference: 3GPP TS 36.212 version 10.0.0 Release 10 Sec. 5.1.4.1 *********************************************************************************************/ -#ifndef SRSLTE_RM_TURBO_H -#define SRSLTE_RM_TURBO_H +#ifndef SRSRAN_RM_TURBO_H +#define SRSRAN_RM_TURBO_H -#include "srslte/config.h" -#include "srslte/phy/fec/turbo/turbodecoder.h" +#include "srsran/config.h" +#include "srsran/phy/fec/turbo/turbodecoder.h" -#ifndef SRSLTE_RX_NULL -#define SRSLTE_RX_NULL 10000 +#ifndef SRSRAN_RX_NULL +#define SRSRAN_RX_NULL 10000 #endif -#ifndef SRSLTE_TX_NULL -#define SRSLTE_TX_NULL 100 +#ifndef SRSRAN_TX_NULL +#define SRSRAN_TX_NULL 100 #endif -#include "srslte/config.h" +#include "srsran/config.h" -SRSLTE_API int srslte_rm_turbo_tx(uint8_t* w_buff, +SRSRAN_API int srsran_rm_turbo_tx(uint8_t* w_buff, uint32_t buff_len, uint8_t* input, uint32_t in_len, @@ -42,11 +42,11 @@ SRSLTE_API int srslte_rm_turbo_tx(uint8_t* w_buff, uint32_t out_len, uint32_t rv_idx); -SRSLTE_API void srslte_rm_turbo_gentables(); +SRSRAN_API void srsran_rm_turbo_gentables(); -SRSLTE_API void srslte_rm_turbo_free_tables(); +SRSRAN_API void srsran_rm_turbo_free_tables(); -SRSLTE_API int srslte_rm_turbo_tx_lut(uint8_t* w_buff, +SRSRAN_API int srsran_rm_turbo_tx_lut(uint8_t* w_buff, uint8_t* systematic, uint8_t* parity, uint8_t* output, @@ -55,7 +55,7 @@ SRSLTE_API int srslte_rm_turbo_tx_lut(uint8_t* w_buff, uint32_t w_offset, uint32_t rv_idx); -SRSLTE_API int srslte_rm_turbo_rx(float* w_buff, +SRSRAN_API int srsran_rm_turbo_rx(float* w_buff, uint32_t buff_len, float* input, uint32_t in_len, @@ -64,17 +64,17 @@ SRSLTE_API int srslte_rm_turbo_rx(float* w_buff, uint32_t rv_idx, uint32_t nof_filler_bits); -SRSLTE_API int -srslte_rm_turbo_rx_lut(int16_t* input, int16_t* output, uint32_t in_len, uint32_t cb_idx, uint32_t rv_idx); +SRSRAN_API int +srsran_rm_turbo_rx_lut(int16_t* input, int16_t* output, uint32_t in_len, uint32_t cb_idx, uint32_t rv_idx); -SRSLTE_API int srslte_rm_turbo_rx_lut_(int16_t* input, +SRSRAN_API int srsran_rm_turbo_rx_lut_(int16_t* input, int16_t* output, uint32_t in_len, uint32_t cb_idx, uint32_t rv_idx, bool enable_input_tdec); -SRSLTE_API int -srslte_rm_turbo_rx_lut_8bit(int8_t* input, int8_t* output, uint32_t in_len, uint32_t cb_idx, uint32_t rv_idx); +SRSRAN_API int +srsran_rm_turbo_rx_lut_8bit(int8_t* input, int8_t* output, uint32_t in_len, uint32_t cb_idx, uint32_t rv_idx); -#endif // SRSLTE_RM_TURBO_H +#endif // SRSRAN_RM_TURBO_H diff --git a/lib/include/srslte/phy/fec/turbo/tc_interl.h b/lib/include/srsran/phy/fec/turbo/tc_interl.h similarity index 60% rename from lib/include/srslte/phy/fec/turbo/tc_interl.h rename to lib/include/srsran/phy/fec/turbo/tc_interl.h index ded295d63..34fc508b7 100644 --- a/lib/include/srslte/phy/fec/turbo/tc_interl.h +++ b/lib/include/srsran/phy/fec/turbo/tc_interl.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -18,24 +18,24 @@ * Reference: 3GPP TS 36.212 version 10.0.0 Release 10 Sec. 5.1.3.2.3 *********************************************************************************************/ -#ifndef SRSLTE_TC_INTERL_H -#define SRSLTE_TC_INTERL_H +#ifndef SRSRAN_TC_INTERL_H +#define SRSRAN_TC_INTERL_H -#include "srslte/config.h" +#include "srsran/config.h" #include -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { uint16_t* forward; uint16_t* reverse; uint32_t max_long_cb; -} srslte_tc_interl_t; +} srsran_tc_interl_t; -SRSLTE_API int srslte_tc_interl_LTE_gen(srslte_tc_interl_t* h, uint32_t long_cb); +SRSRAN_API int srsran_tc_interl_LTE_gen(srsran_tc_interl_t* h, uint32_t long_cb); -SRSLTE_API int srslte_tc_interl_LTE_gen_interl(srslte_tc_interl_t* h, uint32_t long_cb, uint32_t interl_win); +SRSRAN_API int srsran_tc_interl_LTE_gen_interl(srsran_tc_interl_t* h, uint32_t long_cb, uint32_t interl_win); -SRSLTE_API int srslte_tc_interl_init(srslte_tc_interl_t* h, uint32_t max_long_cb); +SRSRAN_API int srsran_tc_interl_init(srsran_tc_interl_t* h, uint32_t max_long_cb); -SRSLTE_API void srslte_tc_interl_free(srslte_tc_interl_t* h); +SRSRAN_API void srsran_tc_interl_free(srsran_tc_interl_t* h); -#endif // SRSLTE_TC_INTERL_H +#endif // SRSRAN_TC_INTERL_H diff --git a/lib/include/srslte/phy/fec/turbo/turbocoder.h b/lib/include/srsran/phy/fec/turbo/turbocoder.h similarity index 62% rename from lib/include/srslte/phy/fec/turbo/turbocoder.h rename to lib/include/srsran/phy/fec/turbo/turbocoder.h index 465ad91c8..bdc747f02 100644 --- a/lib/include/srslte/phy/fec/turbo/turbocoder.h +++ b/lib/include/srsran/phy/fec/turbo/turbocoder.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -21,42 +21,42 @@ * Reference: 3GPP TS 36.212 version 10.0.0 Release 10 Sec. 5.1.3.2 *********************************************************************************************/ -#ifndef SRSLTE_TURBOCODER_H -#define SRSLTE_TURBOCODER_H +#ifndef SRSRAN_TURBOCODER_H +#define SRSRAN_TURBOCODER_H -#include "srslte/config.h" -#include "srslte/phy/fec/crc.h" -#include "srslte/phy/fec/turbo/tc_interl.h" -#define SRSLTE_TCOD_MAX_LEN_CB_BYTES (6144 / 8) +#include "srsran/config.h" +#include "srsran/phy/fec/crc.h" +#include "srsran/phy/fec/turbo/tc_interl.h" +#define SRSRAN_TCOD_MAX_LEN_CB_BYTES (6144 / 8) -#ifndef SRSLTE_TX_NULL -#define SRSLTE_TX_NULL 100 +#ifndef SRSRAN_TX_NULL +#define SRSRAN_TX_NULL 100 #endif -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { uint32_t max_long_cb; uint8_t* temp; -} srslte_tcod_t; +} srsran_tcod_t; /* This structure is used as an output for the LUT version of the encoder. * The encoder produces parity bits only and rate matching will interleave them * with the systematic bits */ -SRSLTE_API int srslte_tcod_init(srslte_tcod_t* h, uint32_t max_long_cb); +SRSRAN_API int srsran_tcod_init(srsran_tcod_t* h, uint32_t max_long_cb); -SRSLTE_API void srslte_tcod_free(srslte_tcod_t* h); +SRSRAN_API void srsran_tcod_free(srsran_tcod_t* h); -SRSLTE_API int srslte_tcod_encode(srslte_tcod_t* h, uint8_t* input, uint8_t* output, uint32_t long_cb); +SRSRAN_API int srsran_tcod_encode(srsran_tcod_t* h, uint8_t* input, uint8_t* output, uint32_t long_cb); -SRSLTE_API int srslte_tcod_encode_lut(srslte_tcod_t* h, - srslte_crc_t* crc_tb, - srslte_crc_t* crc_cb, +SRSRAN_API int srsran_tcod_encode_lut(srsran_tcod_t* h, + srsran_crc_t* crc_tb, + srsran_crc_t* crc_cb, uint8_t* input, uint8_t* parity, uint32_t cblen_idx, bool last_cb); -SRSLTE_API void srslte_tcod_gentable(); +SRSRAN_API void srsran_tcod_gentable(); -#endif // SRSLTE_TURBOCODER_H +#endif // SRSRAN_TURBOCODER_H diff --git a/lib/include/srsran/phy/fec/turbo/turbodecoder.h b/lib/include/srsran/phy/fec/turbo/turbodecoder.h new file mode 100644 index 000000000..4dc278583 --- /dev/null +++ b/lib/include/srsran/phy/fec/turbo/turbodecoder.h @@ -0,0 +1,114 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +/********************************************************************************************** + * File: turbodecoder.h + * + * Description: Turbo Decoder. + * Parallel Concatenated Convolutional Code (PCCC) with two 8-state constituent + * encoders and one turbo code internal interleaver. The coding rate of turbo + * encoder is 1/3. + * MAP_GEN is the MAX-LOG-MAP generic implementation of the decoder. + * + * Reference: 3GPP TS 36.212 version 10.0.0 Release 10 Sec. 5.1.3.2 + *********************************************************************************************/ + +#ifndef SRSRAN_TURBODECODER_H +#define SRSRAN_TURBODECODER_H + +#include "srsran/config.h" +#include "srsran/phy/fec/cbsegm.h" +#include "srsran/phy/fec/turbo/tc_interl.h" + +#define SRSRAN_TCOD_RATE 3 +#define SRSRAN_TCOD_TOTALTAIL 12 + +#define SRSRAN_TCOD_MAX_LEN_CB 6144 + +// Expect the input to be aligned for sub-block window processing. +#define SRSRAN_TDEC_EXPECT_INPUT_SB 1 + +// Include interfaces for 8 and 16 bit decoder implementations +#define LLR_IS_8BIT +#include "srsran/phy/fec/turbo/turbodecoder_impl.h" +#undef LLR_IS_8BIT + +#define LLR_IS_16BIT +#include "srsran/phy/fec/turbo/turbodecoder_impl.h" +#undef LLR_IS_16BIT + +#define SRSRAN_TDEC_NOF_AUTO_MODES_8 2 +#define SRSRAN_TDEC_NOF_AUTO_MODES_16 3 + +typedef enum { SRSRAN_TDEC_8, SRSRAN_TDEC_16 } srsran_tdec_llr_type_t; + +typedef struct SRSRAN_API { + uint32_t max_long_cb; + + void* dec8_hdlr[SRSRAN_TDEC_NOF_AUTO_MODES_8]; + void* dec16_hdlr[SRSRAN_TDEC_NOF_AUTO_MODES_16]; + srsran_tdec_8bit_impl_t* dec8[SRSRAN_TDEC_NOF_AUTO_MODES_8]; + srsran_tdec_16bit_impl_t* dec16[SRSRAN_TDEC_NOF_AUTO_MODES_16]; + int nof_blocks8[SRSRAN_TDEC_NOF_AUTO_MODES_8]; + int nof_blocks16[SRSRAN_TDEC_NOF_AUTO_MODES_16]; + + // Declare as void types as can be int8 or int16 + void* app1; + void* app2; + void* ext1; + void* ext2; + void* syst0; + void* parity0; + void* parity1; + + void* input_conv; + + bool force_not_sb; + + srsran_tdec_impl_type_t dec_type; + + srsran_tdec_llr_type_t current_llr_type; + uint32_t current_dec; + uint32_t current_long_cb; + uint32_t current_inter_idx; + int current_cbidx; + srsran_tc_interl_t interleaver[4][SRSRAN_NOF_TC_CB_SIZES]; + int n_iter; +} srsran_tdec_t; + +SRSRAN_API int srsran_tdec_init(srsran_tdec_t* h, uint32_t max_long_cb); + +SRSRAN_API int srsran_tdec_init_manual(srsran_tdec_t* h, uint32_t max_long_cb, srsran_tdec_impl_type_t dec_type); + +SRSRAN_API void srsran_tdec_free(srsran_tdec_t* h); + +SRSRAN_API void srsran_tdec_force_not_sb(srsran_tdec_t* h); + +SRSRAN_API int srsran_tdec_new_cb(srsran_tdec_t* h, uint32_t long_cb); + +SRSRAN_API int srsran_tdec_get_nof_iterations(srsran_tdec_t* h); + +SRSRAN_API uint32_t srsran_tdec_autoimp_get_subblocks(uint32_t long_cb); + +SRSRAN_API uint32_t srsran_tdec_autoimp_get_subblocks_8bit(uint32_t long_cb); + +SRSRAN_API void srsran_tdec_iteration(srsran_tdec_t* h, int16_t* input, uint8_t* output); + +SRSRAN_API int +srsran_tdec_run_all(srsran_tdec_t* h, int16_t* input, uint8_t* output, uint32_t nof_iterations, uint32_t long_cb); + +SRSRAN_API void srsran_tdec_iteration_8bit(srsran_tdec_t* h, int8_t* input, uint8_t* output); + +SRSRAN_API int +srsran_tdec_run_all_8bit(srsran_tdec_t* h, int8_t* input, uint8_t* output, uint32_t nof_iterations, uint32_t long_cb); + +#endif // SRSRAN_TURBODECODER_H diff --git a/lib/include/srslte/phy/fec/turbo/turbodecoder_gen.h b/lib/include/srsran/phy/fec/turbo/turbodecoder_gen.h similarity index 78% rename from lib/include/srslte/phy/fec/turbo/turbodecoder_gen.h rename to lib/include/srsran/phy/fec/turbo/turbodecoder_gen.h index ac3dc93a1..ab7dcdad8 100644 --- a/lib/include/srslte/phy/fec/turbo/turbodecoder_gen.h +++ b/lib/include/srsran/phy/fec/turbo/turbodecoder_gen.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -22,18 +22,18 @@ * Reference: 3GPP TS 36.212 version 10.0.0 Release 10 Sec. 5.1.3.2 *********************************************************************************************/ -#ifndef SRSLTE_TURBODECODER_GEN_H -#define SRSLTE_TURBODECODER_GEN_H +#ifndef SRSRAN_TURBODECODER_GEN_H +#define SRSRAN_TURBODECODER_GEN_H -#include "srslte/config.h" -#include "srslte/phy/fec/cbsegm.h" -#include "srslte/phy/fec/turbo/tc_interl.h" -#define SRSLTE_TCOD_RATE 3 -#define SRSLTE_TCOD_TOTALTAIL 12 +#include "srsran/config.h" +#include "srsran/phy/fec/cbsegm.h" +#include "srsran/phy/fec/turbo/tc_interl.h" +#define SRSRAN_TCOD_RATE 3 +#define SRSRAN_TCOD_TOTALTAIL 12 -#define SRSLTE_TCOD_MAX_LEN_CB 6144 +#define SRSRAN_TCOD_MAX_LEN_CB 6144 -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { uint32_t max_long_cb; int16_t* beta; } tdec_gen_t; @@ -49,4 +49,4 @@ void tdec_gen_extract_input(int16_t* input, uint32_t long_cb); void tdec_gen_decision_byte(int16_t* app1, uint8_t* output, uint32_t long_cb); -#endif // SRSLTE_TURBODECODER_GEN_H +#endif // SRSRAN_TURBODECODER_GEN_H diff --git a/lib/include/srslte/phy/fec/turbo/turbodecoder_impl.h b/lib/include/srsran/phy/fec/turbo/turbodecoder_impl.h similarity index 59% rename from lib/include/srslte/phy/fec/turbo/turbodecoder_impl.h rename to lib/include/srsran/phy/fec/turbo/turbodecoder_impl.h index fda53a1db..2ca1f5638 100644 --- a/lib/include/srslte/phy/fec/turbo/turbodecoder_impl.h +++ b/lib/include/srsran/phy/fec/turbo/turbodecoder_impl.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,39 +10,39 @@ * */ -#ifndef SRSLTE_TURBODECODER_IMPL_H -#define SRSLTE_TURBODECODER_IMPL_H +#ifndef SRSRAN_TURBODECODER_IMPL_H +#define SRSRAN_TURBODECODER_IMPL_H -#include "srslte/config.h" +#include "srsran/config.h" /* Interface for internal decoder implementation */ -typedef enum SRSLTE_API { - SRSLTE_TDEC_AUTO = 0, - SRSLTE_TDEC_GENERIC, - SRSLTE_TDEC_SSE, - SRSLTE_TDEC_SSE_WINDOW, - SRSLTE_TDEC_NEON_WINDOW, - SRSLTE_TDEC_AVX_WINDOW, - SRSLTE_TDEC_SSE8_WINDOW, - SRSLTE_TDEC_AVX8_WINDOW, - SRSLTE_TDEC_NOF_IMP -} srslte_tdec_impl_type_t; +typedef enum SRSRAN_API { + SRSRAN_TDEC_AUTO = 0, + SRSRAN_TDEC_GENERIC, + SRSRAN_TDEC_SSE, + SRSRAN_TDEC_SSE_WINDOW, + SRSRAN_TDEC_NEON_WINDOW, + SRSRAN_TDEC_AVX_WINDOW, + SRSRAN_TDEC_SSE8_WINDOW, + SRSRAN_TDEC_AVX8_WINDOW, + SRSRAN_TDEC_NOF_IMP +} srsran_tdec_impl_type_t; #endif #ifdef LLR_IS_8BIT #define llr_t int8_t -#define type_name srslte_tdec_8bit_impl_t +#define type_name srsran_tdec_8bit_impl_t #else #ifdef LLR_IS_16BIT #define llr_t int16_t -#define type_name srslte_tdec_16bit_impl_t +#define type_name srsran_tdec_16bit_impl_t #else #error "Unsupported LLR mode" #endif #endif -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { int (*tdec_init)(void** h, uint32_t max_long_cb); void (*tdec_free)(void* h); void (*tdec_dec)(void* h, llr_t* input, llr_t* app, llr_t* parity, llr_t* output, uint32_t long_cb); diff --git a/lib/include/srslte/phy/fec/turbo/turbodecoder_iter.h b/lib/include/srsran/phy/fec/turbo/turbodecoder_iter.h similarity index 86% rename from lib/include/srslte/phy/fec/turbo/turbodecoder_iter.h rename to lib/include/srsran/phy/fec/turbo/turbodecoder_iter.h index 87e2bc517..f83b4ef83 100644 --- a/lib/include/srslte/phy/fec/turbo/turbodecoder_iter.h +++ b/lib/include/srsran/phy/fec/turbo/turbodecoder_iter.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,11 +10,11 @@ * */ -#include "srslte/config.h" +#include "srsran/config.h" #define MAKE_CALL(a) CONCAT2(a, type_name) #define MAKE_VEC(a) CONCAT2(a, vec_suffix) -#define PRINT CONCAT2(srslte_vec_fprint, print_suffix) +#define PRINT CONCAT2(srsran_vec_fprint, print_suffix) #ifdef LLR_IS_8BIT #define llr_t int8_t @@ -60,7 +60,7 @@ static void MAKE_CALL( } /* Runs 1 turbo decoder iteration */ -void MAKE_CALL(run_tdec_iteration)(srslte_tdec_t* h, llr_t* input) +void MAKE_CALL(run_tdec_iteration)(srsran_tdec_t* h, llr_t* input) { if (h->current_cbidx >= 0) { @@ -78,7 +78,7 @@ void MAKE_CALL(run_tdec_iteration)(srslte_tdec_t* h, llr_t* input) uint32_t long_cb = h->current_long_cb; uint32_t n_iter = h->n_iter; - if (SRSLTE_TDEC_EXPECT_INPUT_SB && !h->force_not_sb && input_is_interleaved) { + if (SRSRAN_TDEC_EXPECT_INPUT_SB && !h->force_not_sb && input_is_interleaved) { syst = input; // align to 32 bytes (warning: must be same alignment as in rm_turbo.c) parity0 = &input[long_cb + 32]; @@ -96,7 +96,7 @@ void MAKE_CALL(run_tdec_iteration)(srslte_tdec_t* h, llr_t* input) // Add apriori information to decoder 1 if (n_iter) { - MAKE_VEC(srslte_vec_sub)(app1, ext1, app1, long_cb); + MAKE_VEC(srsran_vec_sub)(app1, ext1, app1, long_cb); } // Run MAP DEC #1 @@ -106,16 +106,16 @@ void MAKE_CALL(run_tdec_iteration)(srslte_tdec_t* h, llr_t* input) if (n_iter % 2) { // Convert aposteriori information into extrinsic information if (n_iter > 1) { - MAKE_VEC(srslte_vec_sub)(ext1, app1, ext1, long_cb); + MAKE_VEC(srsran_vec_sub)(ext1, app1, ext1, long_cb); } - MAKE_VEC(srslte_vec_lut)(ext1, deinter, app2, long_cb); + MAKE_VEC(srsran_vec_lut)(ext1, deinter, app2, long_cb); // Run MAP DEC #2. 2nd decoder uses apriori information as systematic bits decptr->tdec_dec(dechdlr, app2, NULL, parity1, ext2, long_cb); // Deinterleaved extrinsic bits become apriori info for decoder 1 - MAKE_VEC(srslte_vec_lut)(ext2, inter, app1, long_cb); + MAKE_VEC(srsran_vec_lut)(ext2, inter, app1, long_cb); } if (h->n_iter == 0) { @@ -130,7 +130,7 @@ void MAKE_CALL(run_tdec_iteration)(srslte_tdec_t* h, llr_t* input) h->n_iter++; } else { - ERROR("Error CB index not set (call srslte_tdec_new_cb() first"); + ERROR("Error CB index not set (call srsran_tdec_new_cb() first"); } } diff --git a/lib/include/srslte/phy/fec/turbo/turbodecoder_sse.h b/lib/include/srsran/phy/fec/turbo/turbodecoder_sse.h similarity index 79% rename from lib/include/srslte/phy/fec/turbo/turbodecoder_sse.h rename to lib/include/srsran/phy/fec/turbo/turbodecoder_sse.h index e6a2ee519..2a7a074b5 100644 --- a/lib/include/srslte/phy/fec/turbo/turbodecoder_sse.h +++ b/lib/include/srsran/phy/fec/turbo/turbodecoder_sse.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,12 +10,12 @@ * */ -#ifndef SRSLTE_TURBODECODER_SSE_H -#define SRSLTE_TURBODECODER_SSE_H +#ifndef SRSRAN_TURBODECODER_SSE_H +#define SRSRAN_TURBODECODER_SSE_H -#include "srslte/config.h" +#include "srsran/config.h" -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { uint32_t max_long_cb; int16_t* alpha; int16_t* branch; @@ -32,4 +32,4 @@ void tdec_sse_extract_input(int16_t* input, uint32_t long_cb); void tdec_sse_decision_byte(int16_t* app1, uint8_t* output, uint32_t long_cb); -#endif // SRSLTE_TURBODECODER_SSE_H +#endif // SRSRAN_TURBODECODER_SSE_H diff --git a/lib/include/srslte/phy/fec/turbo/turbodecoder_win.h b/lib/include/srsran/phy/fec/turbo/turbodecoder_win.h similarity index 99% rename from lib/include/srslte/phy/fec/turbo/turbodecoder_win.h rename to lib/include/srsran/phy/fec/turbo/turbodecoder_win.h index 0435d53c8..7d4a2448f 100644 --- a/lib/include/srslte/phy/fec/turbo/turbodecoder_win.h +++ b/lib/include/srsran/phy/fec/turbo/turbodecoder_win.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,7 +10,7 @@ * */ -#include "srslte/config.h" +#include "srsran/config.h" #define MAKE_FUNC(a) CONCAT2(CONCAT2(tdec_win, WINIMP), CONCAT2(_, a)) #define MAKE_TYPE CONCAT2(CONCAT2(tdec_win_, WINIMP), _t) @@ -399,7 +399,7 @@ inline static uint8x16_t v_load_s8(int i15, #endif #endif -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { uint32_t max_long_cb; llr_t* beta; } MAKE_TYPE; @@ -828,9 +828,9 @@ int MAKE_FUNC(init)(void** hh, uint32_t max_long_cb) MAKE_TYPE* h = (MAKE_TYPE*)*hh; - h->beta = srslte_vec_malloc(sizeof(llr_t) * 8 * max_long_cb * nof_blocks); + h->beta = srsran_vec_malloc(sizeof(llr_t) * 8 * max_long_cb * nof_blocks); if (!h->beta) { - perror("srslte_vec_malloc"); + perror("srsran_vec_malloc"); return -1; } h->max_long_cb = max_long_cb; diff --git a/lib/include/srslte/phy/io/binsource.h b/lib/include/srsran/phy/io/binsource.h similarity index 52% rename from lib/include/srslte/phy/io/binsource.h rename to lib/include/srsran/phy/io/binsource.h index 05682bab8..6c22888e4 100644 --- a/lib/include/srslte/phy/io/binsource.h +++ b/lib/include/srsran/phy/io/binsource.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -18,33 +18,33 @@ * Reference: *****************************************************************************/ -#ifndef SRSLTE_BINSOURCE_H -#define SRSLTE_BINSOURCE_H +#ifndef SRSRAN_BINSOURCE_H +#define SRSRAN_BINSOURCE_H -#include "srslte/config.h" +#include "srsran/config.h" #include /* Low-level API */ -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { uint32_t seed; uint32_t* seq_buff; int seq_buff_nwords; int seq_cache_nbits; int seq_cache_rp; -} srslte_binsource_t; +} srsran_binsource_t; -SRSLTE_API void srslte_binsource_init(srslte_binsource_t* q); +SRSRAN_API void srsran_binsource_init(srsran_binsource_t* q); -SRSLTE_API void srslte_binsource_free(srslte_binsource_t* q); +SRSRAN_API void srsran_binsource_free(srsran_binsource_t* q); -SRSLTE_API void srslte_binsource_seed_set(srslte_binsource_t* q, uint32_t seed); +SRSRAN_API void srsran_binsource_seed_set(srsran_binsource_t* q, uint32_t seed); -SRSLTE_API void srslte_binsource_seed_time(srslte_binsource_t* q); +SRSRAN_API void srsran_binsource_seed_time(srsran_binsource_t* q); -SRSLTE_API int srslte_binsource_cache_gen(srslte_binsource_t* q, int nbits); +SRSRAN_API int srsran_binsource_cache_gen(srsran_binsource_t* q, int nbits); -SRSLTE_API void srslte_binsource_cache_cpy(srslte_binsource_t* q, uint8_t* bits, int nbits); +SRSRAN_API void srsran_binsource_cache_cpy(srsran_binsource_t* q, uint8_t* bits, int nbits); -SRSLTE_API int srslte_binsource_generate(srslte_binsource_t* q, uint8_t* bits, int nbits); +SRSRAN_API int srsran_binsource_generate(srsran_binsource_t* q, uint8_t* bits, int nbits); -#endif // SRSLTE_BINSOURCE_H +#endif // SRSRAN_BINSOURCE_H diff --git a/lib/include/srslte/phy/io/filesink.h b/lib/include/srsran/phy/io/filesink.h similarity index 57% rename from lib/include/srslte/phy/io/filesink.h rename to lib/include/srsran/phy/io/filesink.h index 616339c2c..6d3226f10 100644 --- a/lib/include/srslte/phy/io/filesink.h +++ b/lib/include/srsran/phy/io/filesink.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -20,28 +20,28 @@ * Reference: *****************************************************************************/ -#ifndef SRSLTE_FILESINK_H -#define SRSLTE_FILESINK_H +#ifndef SRSRAN_FILESINK_H +#define SRSRAN_FILESINK_H #include #include #include -#include "srslte/config.h" -#include "srslte/phy/io/format.h" +#include "srsran/config.h" +#include "srsran/phy/io/format.h" /* Low-level API */ -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { FILE* f; - srslte_datatype_t type; -} srslte_filesink_t; + srsran_datatype_t type; +} srsran_filesink_t; -SRSLTE_API int srslte_filesink_init(srslte_filesink_t* q, char* filename, srslte_datatype_t type); +SRSRAN_API int srsran_filesink_init(srsran_filesink_t* q, char* filename, srsran_datatype_t type); -SRSLTE_API void srslte_filesink_free(srslte_filesink_t* q); +SRSRAN_API void srsran_filesink_free(srsran_filesink_t* q); -SRSLTE_API int srslte_filesink_write(srslte_filesink_t* q, void* buffer, int nsamples); +SRSRAN_API int srsran_filesink_write(srsran_filesink_t* q, void* buffer, int nsamples); -SRSLTE_API int srslte_filesink_write_multi(srslte_filesink_t* q, void** buffer, int nsamples, int nchannels); +SRSRAN_API int srsran_filesink_write_multi(srsran_filesink_t* q, void** buffer, int nsamples, int nchannels); -#endif // SRSLTE_FILESINK_H +#endif // SRSRAN_FILESINK_H diff --git a/lib/include/srslte/phy/io/filesource.h b/lib/include/srsran/phy/io/filesource.h similarity index 54% rename from lib/include/srslte/phy/io/filesource.h rename to lib/include/srsran/phy/io/filesource.h index c76ed0031..c33e6564e 100644 --- a/lib/include/srslte/phy/io/filesource.h +++ b/lib/include/srsran/phy/io/filesource.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -20,29 +20,29 @@ * Reference: *****************************************************************************/ -#ifndef SRSLTE_FILESOURCE_H -#define SRSLTE_FILESOURCE_H +#ifndef SRSRAN_FILESOURCE_H +#define SRSRAN_FILESOURCE_H #include #include -#include "srslte/config.h" -#include "srslte/phy/io/format.h" +#include "srsran/config.h" +#include "srsran/phy/io/format.h" /* Low-level API */ -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { FILE* f; - srslte_datatype_t type; -} srslte_filesource_t; + srsran_datatype_t type; +} srsran_filesource_t; -SRSLTE_API int srslte_filesource_init(srslte_filesource_t* q, char* filename, srslte_datatype_t type); +SRSRAN_API int srsran_filesource_init(srsran_filesource_t* q, char* filename, srsran_datatype_t type); -SRSLTE_API void srslte_filesource_free(srslte_filesource_t* q); +SRSRAN_API void srsran_filesource_free(srsran_filesource_t* q); -SRSLTE_API void srslte_filesource_seek(srslte_filesource_t* q, int pos); +SRSRAN_API void srsran_filesource_seek(srsran_filesource_t* q, int pos); -SRSLTE_API int srslte_filesource_read(srslte_filesource_t* q, void* buffer, int nsamples); +SRSRAN_API int srsran_filesource_read(srsran_filesource_t* q, void* buffer, int nsamples); -SRSLTE_API int srslte_filesource_read_multi(srslte_filesource_t* q, void** buffer, int nsamples, int nof_channels); +SRSRAN_API int srsran_filesource_read_multi(srsran_filesource_t* q, void** buffer, int nsamples, int nof_channels); -#endif // SRSLTE_FILESOURCE_H +#endif // SRSRAN_FILESOURCE_H diff --git a/lib/include/srsran/phy/io/format.h b/lib/include/srsran/phy/io/format.h new file mode 100644 index 000000000..d6cc15870 --- /dev/null +++ b/lib/include/srsran/phy/io/format.h @@ -0,0 +1,26 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +#ifndef SRSRAN_FORMAT_H +#define SRSRAN_FORMAT_H + +typedef enum { + SRSRAN_TEXT, + SRSRAN_FLOAT, + SRSRAN_COMPLEX_FLOAT, + SRSRAN_COMPLEX_SHORT, + SRSRAN_FLOAT_BIN, + SRSRAN_COMPLEX_FLOAT_BIN, + SRSRAN_COMPLEX_SHORT_BIN +} srsran_datatype_t; + +#endif // SRSRAN_FORMAT_H diff --git a/lib/include/srslte/phy/io/netsink.h b/lib/include/srsran/phy/io/netsink.h similarity index 57% rename from lib/include/srslte/phy/io/netsink.h rename to lib/include/srsran/phy/io/netsink.h index 51db45398..770479f14 100644 --- a/lib/include/srslte/phy/io/netsink.h +++ b/lib/include/srsran/phy/io/netsink.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -19,8 +19,8 @@ * Reference: *****************************************************************************/ -#ifndef SRSLTE_NETSINK_H -#define SRSLTE_NETSINK_H +#ifndef SRSRAN_NETSINK_H +#define SRSRAN_NETSINK_H #include #include @@ -29,24 +29,24 @@ #include #include -#include "srslte/config.h" +#include "srsran/config.h" -typedef enum { SRSLTE_NETSINK_UDP, SRSLTE_NETSINK_TCP } srslte_netsink_type_t; +typedef enum { SRSRAN_NETSINK_UDP, SRSRAN_NETSINK_TCP } srsran_netsink_type_t; /* Low-level API */ -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { int sockfd; bool connected; - srslte_netsink_type_t type; + srsran_netsink_type_t type; struct sockaddr_in servaddr; -} srslte_netsink_t; +} srsran_netsink_t; -SRSLTE_API int srslte_netsink_init(srslte_netsink_t* q, const char* address, uint16_t port, srslte_netsink_type_t type); +SRSRAN_API int srsran_netsink_init(srsran_netsink_t* q, const char* address, uint16_t port, srsran_netsink_type_t type); -SRSLTE_API void srslte_netsink_free(srslte_netsink_t* q); +SRSRAN_API void srsran_netsink_free(srsran_netsink_t* q); -SRSLTE_API int srslte_netsink_write(srslte_netsink_t* q, void* buffer, int nof_bytes); +SRSRAN_API int srsran_netsink_write(srsran_netsink_t* q, void* buffer, int nof_bytes); -SRSLTE_API int srslte_netsink_set_nonblocking(srslte_netsink_t* q); +SRSRAN_API int srsran_netsink_set_nonblocking(srsran_netsink_t* q); -#endif // SRSLTE_NETSINK_H +#endif // SRSRAN_NETSINK_H diff --git a/lib/include/srslte/phy/io/netsource.h b/lib/include/srsran/phy/io/netsource.h similarity index 53% rename from lib/include/srslte/phy/io/netsource.h rename to lib/include/srsran/phy/io/netsource.h index f1f3d9c2e..cdae5be28 100644 --- a/lib/include/srslte/phy/io/netsource.h +++ b/lib/include/srsran/phy/io/netsource.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -19,8 +19,8 @@ * Reference: *****************************************************************************/ -#ifndef SRSLTE_NETSOURCE_H -#define SRSLTE_NETSOURCE_H +#ifndef SRSRAN_NETSOURCE_H +#define SRSRAN_NETSOURCE_H #include #include @@ -29,30 +29,30 @@ #include #include -#include "srslte/config.h" +#include "srsran/config.h" -typedef enum { SRSLTE_NETSOURCE_UDP, SRSLTE_NETSOURCE_TCP } srslte_netsource_type_t; +typedef enum { SRSRAN_NETSOURCE_UDP, SRSRAN_NETSOURCE_TCP } srsran_netsource_type_t; /* Low-level API */ -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { int sockfd; int connfd; struct sockaddr_in servaddr; - srslte_netsource_type_t type; + srsran_netsource_type_t type; struct sockaddr_in cliaddr; -} srslte_netsource_t; +} srsran_netsource_t; -SRSLTE_API int -srslte_netsource_init(srslte_netsource_t* q, const char* address, uint16_t port, srslte_netsource_type_t type); +SRSRAN_API int +srsran_netsource_init(srsran_netsource_t* q, const char* address, uint16_t port, srsran_netsource_type_t type); -SRSLTE_API void srslte_netsource_free(srslte_netsource_t* q); +SRSRAN_API void srsran_netsource_free(srsran_netsource_t* q); -SRSLTE_API int srslte_netsource_set_nonblocking(srslte_netsource_t* q); +SRSRAN_API int srsran_netsource_set_nonblocking(srsran_netsource_t* q); -SRSLTE_API int srslte_netsource_read(srslte_netsource_t* q, void* buffer, int nof_bytes); +SRSRAN_API int srsran_netsource_read(srsran_netsource_t* q, void* buffer, int nof_bytes); -SRSLTE_API int srslte_netsource_write(srslte_netsource_t* q, void* buffer, int nbytes); +SRSRAN_API int srsran_netsource_write(srsran_netsource_t* q, void* buffer, int nbytes); -SRSLTE_API int srslte_netsource_set_timeout(srslte_netsource_t* q, uint32_t microseconds); +SRSRAN_API int srsran_netsource_set_timeout(srsran_netsource_t* q, uint32_t microseconds); -#endif // SRSLTE_NETSOURCE_H +#endif // SRSRAN_NETSOURCE_H diff --git a/lib/include/srslte/phy/mimo/layermap.h b/lib/include/srsran/phy/mimo/layermap.h similarity index 57% rename from lib/include/srslte/phy/mimo/layermap.h rename to lib/include/srsran/phy/mimo/layermap.h index 25d802de2..b573dce96 100644 --- a/lib/include/srslte/phy/mimo/layermap.h +++ b/lib/include/srsran/phy/mimo/layermap.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -20,54 +20,54 @@ * Reference: 3GPP TS 36.211 version 10.0.0 Release 10 Sec. 6.3.3 *****************************************************************************/ -#ifndef SRSLTE_LAYERMAP_H -#define SRSLTE_LAYERMAP_H +#ifndef SRSRAN_LAYERMAP_H +#define SRSRAN_LAYERMAP_H -#include "srslte/config.h" -#include "srslte/phy/common/phy_common.h" +#include "srsran/config.h" +#include "srsran/phy/common/phy_common.h" /* Generates the vector of layer-mapped symbols "x" based on the vector of data symbols "d" */ -SRSLTE_API int srslte_layermap_single(cf_t* d, cf_t* x, int nof_symbols); +SRSRAN_API int srsran_layermap_single(cf_t* d, cf_t* x, int nof_symbols); -SRSLTE_API int srslte_layermap_diversity(cf_t* d, cf_t* x[SRSLTE_MAX_LAYERS], int nof_layers, int nof_symbols); +SRSRAN_API int srsran_layermap_diversity(cf_t* d, cf_t* x[SRSRAN_MAX_LAYERS], int nof_layers, int nof_symbols); -SRSLTE_API int srslte_layermap_multiplex(cf_t* d[SRSLTE_MAX_CODEWORDS], - cf_t* x[SRSLTE_MAX_LAYERS], +SRSRAN_API int srsran_layermap_multiplex(cf_t* d[SRSRAN_MAX_CODEWORDS], + cf_t* x[SRSRAN_MAX_LAYERS], int nof_cw, int nof_layers, - int nof_symbols[SRSLTE_MAX_CODEWORDS]); + int nof_symbols[SRSRAN_MAX_CODEWORDS]); -SRSLTE_API int srslte_layermap_type(cf_t* d[SRSLTE_MAX_CODEWORDS], - cf_t* x[SRSLTE_MAX_LAYERS], +SRSRAN_API int srsran_layermap_type(cf_t* d[SRSRAN_MAX_CODEWORDS], + cf_t* x[SRSRAN_MAX_LAYERS], int nof_cw, int nof_layers, - int nof_symbols[SRSLTE_MAX_CODEWORDS], - srslte_tx_scheme_t type); + int nof_symbols[SRSRAN_MAX_CODEWORDS], + srsran_tx_scheme_t type); /* Generates the vector of data symbols "d" based on the vector of layer-mapped symbols "x" */ -SRSLTE_API int srslte_layerdemap_single(cf_t* x, cf_t* d, int nof_symbols); +SRSRAN_API int srsran_layerdemap_single(cf_t* x, cf_t* d, int nof_symbols); -SRSLTE_API int srslte_layerdemap_diversity(cf_t* x[SRSLTE_MAX_LAYERS], cf_t* d, int nof_layers, int nof_layer_symbols); +SRSRAN_API int srsran_layerdemap_diversity(cf_t* x[SRSRAN_MAX_LAYERS], cf_t* d, int nof_layers, int nof_layer_symbols); -SRSLTE_API int srslte_layerdemap_multiplex(cf_t* x[SRSLTE_MAX_LAYERS], - cf_t* d[SRSLTE_MAX_CODEWORDS], +SRSRAN_API int srsran_layerdemap_multiplex(cf_t* x[SRSRAN_MAX_LAYERS], + cf_t* d[SRSRAN_MAX_CODEWORDS], int nof_layers, int nof_cw, int nof_layer_symbols, - int nof_symbols[SRSLTE_MAX_CODEWORDS]); + int nof_symbols[SRSRAN_MAX_CODEWORDS]); -SRSLTE_API int srslte_layerdemap_type(cf_t* x[SRSLTE_MAX_LAYERS], - cf_t* d[SRSLTE_MAX_CODEWORDS], +SRSRAN_API int srsran_layerdemap_type(cf_t* x[SRSRAN_MAX_LAYERS], + cf_t* d[SRSRAN_MAX_CODEWORDS], int nof_layers, int nof_cw, int nof_layer_symbols, - int nof_symbols[SRSLTE_MAX_CODEWORDS], - srslte_tx_scheme_t type); + int nof_symbols[SRSRAN_MAX_CODEWORDS], + srsran_tx_scheme_t type); -SRSLTE_API int srslte_layermap_nr(cf_t** d, int nof_cw, cf_t** x, int nof_layers, uint32_t nof_re); +SRSRAN_API int srsran_layermap_nr(cf_t** d, int nof_cw, cf_t** x, int nof_layers, uint32_t nof_re); -SRSLTE_API int srslte_layerdemap_nr(cf_t** d, int nof_cw, cf_t** x, int nof_layers, uint32_t nof_re); +SRSRAN_API int srsran_layerdemap_nr(cf_t** d, int nof_cw, cf_t** x, int nof_layers, uint32_t nof_re); -#endif // SRSLTE_LAYERMAP_H +#endif // SRSRAN_LAYERMAP_H diff --git a/lib/include/srslte/phy/mimo/precoding.h b/lib/include/srsran/phy/mimo/precoding.h similarity index 64% rename from lib/include/srslte/phy/mimo/precoding.h rename to lib/include/srsran/phy/mimo/precoding.h index 635256163..3a29172c1 100644 --- a/lib/include/srslte/phy/mimo/precoding.h +++ b/lib/include/srsran/phy/mimo/precoding.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -19,11 +19,11 @@ * Reference: 3GPP TS 36.211 version 10.0.0 Release 10 Sec. 6.3.4 *****************************************************************************/ -#ifndef SRSLTE_PRECODING_H -#define SRSLTE_PRECODING_H +#ifndef SRSRAN_PRECODING_H +#define SRSRAN_PRECODING_H -#include "srslte/config.h" -#include "srslte/phy/common/phy_common.h" +#include "srsran/config.h" +#include "srsran/phy/common/phy_common.h" /** The precoder takes as input nlayers vectors "x" from the * layer mapping and generates nports vectors "y" to be mapped onto @@ -32,86 +32,86 @@ /* Generates the vector "y" from the input vector "x" */ -SRSLTE_API int srslte_precoding_single(cf_t* x, cf_t* y, int nof_symbols, float scaling); +SRSRAN_API int srsran_precoding_single(cf_t* x, cf_t* y, int nof_symbols, float scaling); -SRSLTE_API int srslte_precoding_diversity(cf_t* x[SRSLTE_MAX_LAYERS], - cf_t* y[SRSLTE_MAX_PORTS], +SRSRAN_API int srsran_precoding_diversity(cf_t* x[SRSRAN_MAX_LAYERS], + cf_t* y[SRSRAN_MAX_PORTS], int nof_ports, int nof_symbols, float scaling); -SRSLTE_API int srslte_precoding_cdd(cf_t* x[SRSLTE_MAX_LAYERS], - cf_t* y[SRSLTE_MAX_PORTS], +SRSRAN_API int srsran_precoding_cdd(cf_t* x[SRSRAN_MAX_LAYERS], + cf_t* y[SRSRAN_MAX_PORTS], int nof_layers, int nof_ports, int nof_symbols, float scaling); -SRSLTE_API int srslte_precoding_type(cf_t* x[SRSLTE_MAX_LAYERS], - cf_t* y[SRSLTE_MAX_PORTS], +SRSRAN_API int srsran_precoding_type(cf_t* x[SRSRAN_MAX_LAYERS], + cf_t* y[SRSRAN_MAX_PORTS], int nof_layers, int nof_ports, int codebook_idx, int nof_symbols, float scaling, - srslte_tx_scheme_t type); + srsran_tx_scheme_t type); /* Estimates the vector "x" based on the received signal "y" and the channel estimates "h" */ -SRSLTE_API int -srslte_predecoding_single(cf_t* y, cf_t* h, cf_t* x, float* csi, int nof_symbols, float scaling, float noise_estimate); +SRSRAN_API int +srsran_predecoding_single(cf_t* y, cf_t* h, cf_t* x, float* csi, int nof_symbols, float scaling, float noise_estimate); -SRSLTE_API int srslte_predecoding_single_multi(cf_t* y[SRSLTE_MAX_PORTS], - cf_t* h[SRSLTE_MAX_PORTS], +SRSRAN_API int srsran_predecoding_single_multi(cf_t* y[SRSRAN_MAX_PORTS], + cf_t* h[SRSRAN_MAX_PORTS], cf_t* x, - float* csi[SRSLTE_MAX_CODEWORDS], + float* csi[SRSRAN_MAX_CODEWORDS], int nof_rxant, int nof_symbols, float scaling, float noise_estimate); -SRSLTE_API int srslte_predecoding_diversity(cf_t* y, - cf_t* h[SRSLTE_MAX_PORTS], - cf_t* x[SRSLTE_MAX_LAYERS], +SRSRAN_API int srsran_predecoding_diversity(cf_t* y, + cf_t* h[SRSRAN_MAX_PORTS], + cf_t* x[SRSRAN_MAX_LAYERS], int nof_ports, int nof_symbols, float scaling); -SRSLTE_API int srslte_predecoding_diversity_multi(cf_t* y[SRSLTE_MAX_PORTS], - cf_t* h[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS], - cf_t* x[SRSLTE_MAX_LAYERS], - float* csi[SRSLTE_MAX_LAYERS], +SRSRAN_API int srsran_predecoding_diversity_multi(cf_t* y[SRSRAN_MAX_PORTS], + cf_t* h[SRSRAN_MAX_PORTS][SRSRAN_MAX_PORTS], + cf_t* x[SRSRAN_MAX_LAYERS], + float* csi[SRSRAN_MAX_LAYERS], int nof_rxant, int nof_ports, int nof_symbols, float scaling); -SRSLTE_API void srslte_predecoding_set_mimo_decoder(srslte_mimo_decoder_t _mimo_decoder); +SRSRAN_API void srsran_predecoding_set_mimo_decoder(srsran_mimo_decoder_t _mimo_decoder); -SRSLTE_API int srslte_predecoding_type(cf_t* y[SRSLTE_MAX_PORTS], - cf_t* h[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS], - cf_t* x[SRSLTE_MAX_LAYERS], - float* csi[SRSLTE_MAX_CODEWORDS], +SRSRAN_API int srsran_predecoding_type(cf_t* y[SRSRAN_MAX_PORTS], + cf_t* h[SRSRAN_MAX_PORTS][SRSRAN_MAX_PORTS], + cf_t* x[SRSRAN_MAX_LAYERS], + float* csi[SRSRAN_MAX_CODEWORDS], int nof_rxant, int nof_ports, int nof_layers, int codebook_idx, int nof_symbols, - srslte_tx_scheme_t type, + srsran_tx_scheme_t type, float scaling, float noise_estimate); -SRSLTE_API int srslte_precoding_pmi_select(cf_t* h[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS], +SRSRAN_API int srsran_precoding_pmi_select(cf_t* h[SRSRAN_MAX_PORTS][SRSRAN_MAX_PORTS], uint32_t nof_symbols, float noise_estimate, int nof_layers, uint32_t* pmi, - float sinr[SRSLTE_MAX_CODEBOOKS]); + float sinr[SRSRAN_MAX_CODEBOOKS]); -SRSLTE_API int srslte_precoding_cn(cf_t* h[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS], +SRSRAN_API int srsran_precoding_cn(cf_t* h[SRSRAN_MAX_PORTS][SRSRAN_MAX_PORTS], uint32_t nof_tx_antennas, uint32_t nof_rx_antennas, uint32_t nof_symbols, float* cn); -#endif // SRSLTE_PRECODING_H +#endif // SRSRAN_PRECODING_H diff --git a/lib/include/srslte/phy/modem/demod_hard.h b/lib/include/srsran/phy/modem/demod_hard.h similarity index 57% rename from lib/include/srslte/phy/modem/demod_hard.h rename to lib/include/srsran/phy/modem/demod_hard.h index dc4d75017..1917a36a9 100644 --- a/lib/include/srslte/phy/modem/demod_hard.h +++ b/lib/include/srsran/phy/modem/demod_hard.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -19,22 +19,22 @@ * Reference: 3GPP TS 36.211 version 10.0.0 Release 10 Sec. 7.1 *****************************************************************************/ -#ifndef SRSLTE_DEMOD_HARD_H -#define SRSLTE_DEMOD_HARD_H +#ifndef SRSRAN_DEMOD_HARD_H +#define SRSRAN_DEMOD_HARD_H #include #include "modem_table.h" -#include "srslte/config.h" +#include "srsran/config.h" -typedef struct SRSLTE_API { - srslte_mod_t mod; /* In this implementation, mapping table is hard-coded */ -} srslte_demod_hard_t; +typedef struct SRSRAN_API { + srsran_mod_t mod; /* In this implementation, mapping table is hard-coded */ +} srsran_demod_hard_t; -SRSLTE_API void srslte_demod_hard_init(srslte_demod_hard_t* q); +SRSRAN_API void srsran_demod_hard_init(srsran_demod_hard_t* q); -SRSLTE_API void srslte_demod_hard_table_set(srslte_demod_hard_t* q, srslte_mod_t mod); +SRSRAN_API void srsran_demod_hard_table_set(srsran_demod_hard_t* q, srsran_mod_t mod); -SRSLTE_API int srslte_demod_hard_demodulate(srslte_demod_hard_t* q, cf_t* symbols, uint8_t* bits, uint32_t nsymbols); +SRSRAN_API int srsran_demod_hard_demodulate(srsran_demod_hard_t* q, cf_t* symbols, uint8_t* bits, uint32_t nsymbols); -#endif // SRSLTE_DEMOD_HARD_H +#endif // SRSRAN_DEMOD_HARD_H diff --git a/lib/include/srslte/phy/modem/demod_soft.h b/lib/include/srsran/phy/modem/demod_soft.h similarity index 68% rename from lib/include/srslte/phy/modem/demod_soft.h rename to lib/include/srsran/phy/modem/demod_soft.h index bc1eb79df..ea3337942 100644 --- a/lib/include/srslte/phy/modem/demod_soft.h +++ b/lib/include/srsran/phy/modem/demod_soft.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -19,18 +19,18 @@ * Reference: 3GPP TS 36.211 version 10.0.0 Release 10 Sec. 7.1 *****************************************************************************/ -#ifndef SRSLTE_DEMOD_SOFT_H -#define SRSLTE_DEMOD_SOFT_H +#ifndef SRSRAN_DEMOD_SOFT_H +#define SRSRAN_DEMOD_SOFT_H #include #include "modem_table.h" -#include "srslte/config.h" +#include "srsran/config.h" -SRSLTE_API int srslte_demod_soft_demodulate(srslte_mod_t modulation, const cf_t* symbols, float* llr, int nsymbols); +SRSRAN_API int srsran_demod_soft_demodulate(srsran_mod_t modulation, const cf_t* symbols, float* llr, int nsymbols); -SRSLTE_API int srslte_demod_soft_demodulate_s(srslte_mod_t modulation, const cf_t* symbols, short* llr, int nsymbols); +SRSRAN_API int srsran_demod_soft_demodulate_s(srsran_mod_t modulation, const cf_t* symbols, short* llr, int nsymbols); -SRSLTE_API int srslte_demod_soft_demodulate_b(srslte_mod_t modulation, const cf_t* symbols, int8_t* llr, int nsymbols); +SRSRAN_API int srsran_demod_soft_demodulate_b(srsran_mod_t modulation, const cf_t* symbols, int8_t* llr, int nsymbols); -#endif // SRSLTE_DEMOD_SOFT_H +#endif // SRSRAN_DEMOD_SOFT_H diff --git a/lib/include/srslte/phy/modem/evm.h b/lib/include/srsran/phy/modem/evm.h similarity index 90% rename from lib/include/srslte/phy/modem/evm.h rename to lib/include/srsran/phy/modem/evm.h index fa1a64b99..ff030443c 100644 --- a/lib/include/srslte/phy/modem/evm.h +++ b/lib/include/srsran/phy/modem/evm.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,16 +10,16 @@ * */ -#ifndef SRSLTE_EVM_H_ -#define SRSLTE_EVM_H_ +#ifndef SRSRAN_EVM_H_ +#define SRSRAN_EVM_H_ -#include "srslte/phy/modem/mod.h" -#include "srslte/phy/modem/modem_table.h" -#include "srslte/phy/phch/ra.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/modem/mod.h" +#include "srsran/phy/modem/modem_table.h" +#include "srsran/phy/phch/ra.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" -/** @struct srslte_evm_buffer_t +/** @struct srsran_evm_buffer_t * This structure carries the necessary temporary data required for calculating the EVM. * * @var max_bits maximum of bits which can support @@ -30,16 +30,16 @@ typedef struct { uint32_t max_bits; uint8_t* hard_bits; cf_t* symbols; -} srslte_evm_buffer_t; +} srsran_evm_buffer_t; /** * Allocates the EVM calculation buffer * @param nof_prb that provides the maximum number of bits * @return EVM buffer pointer */ -static inline srslte_evm_buffer_t* srslte_evm_buffer_alloc(uint32_t nof_bits) +static inline srsran_evm_buffer_t* srsran_evm_buffer_alloc(uint32_t nof_bits) { - srslte_evm_buffer_t* q = SRSLTE_MEM_ALLOC(srslte_evm_buffer_t, 1); + srsran_evm_buffer_t* q = SRSRAN_MEM_ALLOC(srsran_evm_buffer_t, 1); // Check allocation result and number of PRB if (!q || !nof_bits) { @@ -48,20 +48,20 @@ static inline srslte_evm_buffer_t* srslte_evm_buffer_alloc(uint32_t nof_bits) } // Zero memory the buffer fields - SRSLTE_MEM_ZERO(q, srslte_evm_buffer_t, 1); + SRSRAN_MEM_ZERO(q, srsran_evm_buffer_t, 1); // Set max number of bits q->max_bits = nof_bits; // Allocate hard bits - q->hard_bits = srslte_vec_u8_malloc(q->max_bits); + q->hard_bits = srsran_vec_u8_malloc(q->max_bits); if (!q->hard_bits) { ERROR("Malloc"); return q; } // Allocate symbols assuming BPSK - q->symbols = srslte_vec_cf_malloc(q->max_bits); + q->symbols = srsran_vec_cf_malloc(q->max_bits); if (!q->symbols) { ERROR("Malloc"); return q; @@ -75,7 +75,7 @@ static inline srslte_evm_buffer_t* srslte_evm_buffer_alloc(uint32_t nof_bits) * @param nof_prb that provides the maximum number of bits * @return EVM buffer pointer */ -static inline void srslte_evm_buffer_resize(srslte_evm_buffer_t* q, uint32_t new_max_bits) +static inline void srsran_evm_buffer_resize(srsran_evm_buffer_t* q, uint32_t new_max_bits) { // Assert pointer and number of PRB if (!q || !new_max_bits) { @@ -97,7 +97,7 @@ static inline void srslte_evm_buffer_resize(srslte_evm_buffer_t* q, uint32_t new } // Allocate hard bits again - q->hard_bits = srslte_vec_u8_malloc(q->max_bits); + q->hard_bits = srsran_vec_u8_malloc(q->max_bits); if (!q->hard_bits) { ERROR("Malloc"); return; @@ -109,7 +109,7 @@ static inline void srslte_evm_buffer_resize(srslte_evm_buffer_t* q, uint32_t new } // Allocate symbols again - q->symbols = srslte_vec_cf_malloc(q->max_bits); + q->symbols = srsran_vec_cf_malloc(q->max_bits); if (!q->symbols) { ERROR("Malloc"); return; @@ -164,8 +164,8 @@ static inline void srslte_evm_buffer_resize(srslte_evm_buffer_t* q, uint32_t new * Template RMS EVM calculation for different LLR */ #define EVM_RUN_TEMPLATE(LLR_T, SUFFIX) \ - static inline float srslte_evm_run_##SUFFIX(srslte_evm_buffer_t* q, \ - const srslte_modem_table_t* modem_table, \ + static inline float srsran_evm_run_##SUFFIX(srsran_evm_buffer_t* q, \ + const srsran_modem_table_t* modem_table, \ const cf_t* symbols, \ const LLR_T* llr, \ uint32_t nof_bits) \ @@ -174,12 +174,12 @@ static inline void srslte_evm_buffer_resize(srslte_evm_buffer_t* q, uint32_t new \ /* Return NAN if EVM buffers, modem table, LLR, symbols or bits missing*/ \ if (!q || !modem_table || !modem_table->nbits_x_symbol || !llr || !symbols || !nof_bits) { \ - ERROR("Invalid inputs %p %p %p %p %d", q, modem_table, llr, symbols, nof_bits); \ + ERROR("Invalid inputs %p %p %p %p %d", q, modem_table, llr, symbols, nof_bits); \ return evm_rms; \ } \ \ /* Limit number of bits to the one supported by the buffer */ \ - nof_bits = SRSLTE_MIN(q->max_bits, nof_bits); \ + nof_bits = SRSRAN_MIN(q->max_bits, nof_bits); \ \ /* Calculate number of symbols */ \ uint32_t nsymbols = nof_bits / modem_table->nbits_x_symbol; \ @@ -188,13 +188,13 @@ static inline void srslte_evm_buffer_resize(srslte_evm_buffer_t* q, uint32_t new HARD_DECISION(LLR_T, llr, q->hard_bits, nof_bits); \ \ /* Modulate */ \ - srslte_mod_modulate_bytes(modem_table, q->hard_bits, q->symbols, nof_bits); \ + srsran_mod_modulate_bytes(modem_table, q->hard_bits, q->symbols, nof_bits); \ \ /* Compute symbol difference */ \ - srslte_vec_sub_ccc(symbols, q->symbols, q->symbols, nsymbols); \ + srsran_vec_sub_ccc(symbols, q->symbols, q->symbols, nsymbols); \ \ /* Average squares */ \ - float evm_pow = srslte_vec_avg_power_cf(q->symbols, nsymbols); \ + float evm_pow = srsran_vec_avg_power_cf(q->symbols, nsymbols); \ \ /* Convert measure to RMS */ \ evm_rms = sqrtf(evm_pow); \ @@ -202,7 +202,7 @@ static inline void srslte_evm_buffer_resize(srslte_evm_buffer_t* q, uint32_t new return evm_rms; \ } -/** @function srslte_evm_run_f +/** @function srsran_evm_run_f * Calculates the Root Mean Squared EVM given a modulation table, complex symbols, floating point LLR (soft bits) and * the number of bits. * @@ -215,7 +215,7 @@ static inline void srslte_evm_buffer_resize(srslte_evm_buffer_t* q, uint32_t new */ EVM_RUN_TEMPLATE(float, f) -/** @function srslte_evm_run_s +/** @function srsran_evm_run_s * Calculates the Root Mean Squared EVM given a modulation table, complex symbols, fixed integer 16 bit LLR (soft bits) * and the number of bits. * @@ -228,7 +228,7 @@ EVM_RUN_TEMPLATE(float, f) */ EVM_RUN_TEMPLATE(int16_t, s) -/** @function srslte_evm_run_b +/** @function srsran_evm_run_b * Calculates the Root Mean Squared EVM given a modulation table, complex symbols, fixed integer 8 bit LLR (soft bits) * and the number of bits. * @@ -244,7 +244,7 @@ EVM_RUN_TEMPLATE(int8_t, b) #undef EVM_RUN_TEMPLATE #undef HARD_DECISION -static inline void srslte_evm_free(srslte_evm_buffer_t* q) +static inline void srsran_evm_free(srsran_evm_buffer_t* q) { // Check EVM buffer object exist if (q) { @@ -263,4 +263,4 @@ static inline void srslte_evm_free(srslte_evm_buffer_t* q) } } -#endif // SRSLTE_EVM_H_ +#endif // SRSRAN_EVM_H_ diff --git a/lib/include/srslte/phy/modem/mod.h b/lib/include/srsran/phy/modem/mod.h similarity index 70% rename from lib/include/srslte/phy/modem/mod.h rename to lib/include/srsran/phy/modem/mod.h index d8f343da1..30c18cd59 100644 --- a/lib/include/srslte/phy/modem/mod.h +++ b/lib/include/srsran/phy/modem/mod.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -19,17 +19,17 @@ * Reference: 3GPP TS 36.211 version 10.0.0 Release 10 Sec. 7.1 *****************************************************************************/ -#ifndef SRSLTE_MOD_H -#define SRSLTE_MOD_H +#ifndef SRSRAN_MOD_H +#define SRSRAN_MOD_H #include #include "modem_table.h" -#include "srslte/config.h" +#include "srsran/config.h" -SRSLTE_API int srslte_mod_modulate(const srslte_modem_table_t* table, uint8_t* bits, cf_t* symbols, uint32_t nbits); +SRSRAN_API int srsran_mod_modulate(const srsran_modem_table_t* table, uint8_t* bits, cf_t* symbols, uint32_t nbits); -SRSLTE_API int -srslte_mod_modulate_bytes(const srslte_modem_table_t* q, const uint8_t* bits, cf_t* symbols, uint32_t nbits); +SRSRAN_API int +srsran_mod_modulate_bytes(const srsran_modem_table_t* q, const uint8_t* bits, cf_t* symbols, uint32_t nbits); -#endif // SRSLTE_MOD_H +#endif // SRSRAN_MOD_H diff --git a/lib/include/srslte/phy/modem/modem_table.h b/lib/include/srsran/phy/modem/modem_table.h similarity index 63% rename from lib/include/srslte/phy/modem/modem_table.h rename to lib/include/srsran/phy/modem/modem_table.h index fbd63ab36..46207aff8 100644 --- a/lib/include/srslte/phy/modem/modem_table.h +++ b/lib/include/srsran/phy/modem/modem_table.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -19,14 +19,14 @@ * Reference: 3GPP TS 36.211 version 10.0.0 Release 10 Sec. 7.1 *****************************************************************************/ -#ifndef SRSLTE_MODEM_TABLE_H -#define SRSLTE_MODEM_TABLE_H +#ifndef SRSRAN_MODEM_TABLE_H +#define SRSRAN_MODEM_TABLE_H #include #include -#include "srslte/config.h" -#include "srslte/phy/common/phy_common.h" +#include "srsran/config.h" +#include "srsran/phy/common/phy_common.h" typedef struct { cf_t symbol[8]; @@ -40,7 +40,7 @@ typedef struct { cf_t symbol[2]; } qam16_packed_t; -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { cf_t* symbol_table; // bit-to-symbol mapping uint32_t nsymbols; // number of modulation symbols uint32_t nbits_x_symbol; // number of bits per symbol @@ -49,18 +49,18 @@ typedef struct SRSLTE_API { bpsk_packed_t* symbol_table_bpsk; qpsk_packed_t* symbol_table_qpsk; qam16_packed_t* symbol_table_16qam; -} srslte_modem_table_t; +} srsran_modem_table_t; -SRSLTE_API void srslte_modem_table_init(srslte_modem_table_t* q); +SRSRAN_API void srsran_modem_table_init(srsran_modem_table_t* q); -SRSLTE_API void srslte_modem_table_free(srslte_modem_table_t* q); +SRSRAN_API void srsran_modem_table_free(srsran_modem_table_t* q); -SRSLTE_API void srslte_modem_table_reset(srslte_modem_table_t* q); +SRSRAN_API void srsran_modem_table_reset(srsran_modem_table_t* q); -SRSLTE_API int srslte_modem_table_set(srslte_modem_table_t* q, cf_t* table, uint32_t nsymbols, uint32_t nbits_x_symbol); +SRSRAN_API int srsran_modem_table_set(srsran_modem_table_t* q, cf_t* table, uint32_t nsymbols, uint32_t nbits_x_symbol); -SRSLTE_API int srslte_modem_table_lte(srslte_modem_table_t* q, srslte_mod_t modulation); +SRSRAN_API int srsran_modem_table_lte(srsran_modem_table_t* q, srsran_mod_t modulation); -SRSLTE_API void srslte_modem_table_bytes(srslte_modem_table_t* q); +SRSRAN_API void srsran_modem_table_bytes(srsran_modem_table_t* q); -#endif // SRSLTE_MODEM_TABLE_H +#endif // SRSRAN_MODEM_TABLE_H diff --git a/lib/include/srslte/phy/phch/cqi.h b/lib/include/srsran/phy/phch/cqi.h similarity index 62% rename from lib/include/srslte/phy/phch/cqi.h rename to lib/include/srsran/phy/phch/cqi.h index dbda4cf34..68e942db9 100644 --- a/lib/include/srslte/phy/phch/cqi.h +++ b/lib/include/srsran/phy/phch/cqi.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -18,30 +18,30 @@ * Reference: 3GPP TS 36.212 version 10.0.0 Release 10 Sec. 5.2.2.6, 5.2.3.3 *****************************************************************************/ -#ifndef SRSLTE_CQI_H -#define SRSLTE_CQI_H +#ifndef SRSRAN_CQI_H +#define SRSRAN_CQI_H #include -#include "srslte/config.h" -#include "srslte/phy/common/phy_common.h" +#include "srsran/config.h" +#include "srsran/phy/common/phy_common.h" -#define SRSLTE_CQI_MAX_BITS 64 -#define SRSLTE_DIF_CQI_MAX_BITS 3 -#define SRSLTE_PMI_MAX_BITS 4 -#define SRSLTE_CQI_STR_MAX_CHAR 64 +#define SRSRAN_CQI_MAX_BITS 64 +#define SRSRAN_DIF_CQI_MAX_BITS 3 +#define SRSRAN_PMI_MAX_BITS 4 +#define SRSRAN_CQI_STR_MAX_CHAR 64 typedef enum { - SRSLTE_CQI_MODE_10, - SRSLTE_CQI_MODE_11, - SRSLTE_CQI_MODE_12, - SRSLTE_CQI_MODE_20, - SRSLTE_CQI_MODE_21, - SRSLTE_CQI_MODE_22, - SRSLTE_CQI_MODE_30, - SRSLTE_CQI_MODE_31, - SRSLTE_CQI_MODE_NA, -} srslte_cqi_report_mode_t; + SRSRAN_CQI_MODE_10, + SRSRAN_CQI_MODE_11, + SRSRAN_CQI_MODE_12, + SRSRAN_CQI_MODE_20, + SRSRAN_CQI_MODE_21, + SRSRAN_CQI_MODE_22, + SRSRAN_CQI_MODE_30, + SRSRAN_CQI_MODE_31, + SRSRAN_CQI_MODE_NA, +} srsran_cqi_report_mode_t; typedef struct { bool periodic_configured; @@ -51,9 +51,9 @@ typedef struct { bool ri_idx_present; bool format_is_subband; uint32_t subband_size; - srslte_cqi_report_mode_t periodic_mode; - srslte_cqi_report_mode_t aperiodic_mode; -} srslte_cqi_report_cfg_t; + srsran_cqi_report_mode_t periodic_mode; + srsran_cqi_report_mode_t aperiodic_mode; +} srsran_cqi_report_cfg_t; /* Table 5.2.2.6.2-1: Fields for channel quality information feedback for higher layer configured subband CQI reports (transmission mode 1, transmission mode 2, transmission mode 3, transmission mode 7 and @@ -62,23 +62,23 @@ typedef struct { /* Table 5.2.2.6.2-2: Fields for channel quality information (CQI) feedback for higher layer configured subband CQI reports (transmission mode 4, transmission mode 5 and transmission mode 6). */ -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { uint8_t wideband_cqi_cw0; // 4-bit width uint32_t subband_diff_cqi_cw0; // 2N-bit width uint8_t wideband_cqi_cw1; // if RI > 1 then 4-bit width otherwise 0-bit width uint32_t subband_diff_cqi_cw1; // if RI > 1 then 2N-bit width otherwise 0-bit width uint32_t pmi; // if RI > 1 then 2-bit width otherwise 1-bit width -} srslte_cqi_hl_subband_t; +} srsran_cqi_hl_subband_t; /* Table 5.2.2.6.3-1: Fields for channel quality information feedback for UE selected subband CQI reports (transmission mode 1, transmission mode 2, transmission mode 3, transmission mode 7 and transmission mode 8 configured without PMI/RI reporting). */ -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { uint8_t wideband_cqi; // 4-bit width uint8_t subband_diff_cqi; // 2-bit width uint32_t position_subband; // L-bit width -} srslte_cqi_ue_subband_t; +} srsran_cqi_ue_subband_t; /* Table 5.2.3.3.1-1: Fields for channel quality information feedback for wideband CQI reports (transmission mode 1, transmission mode 2, transmission mode 3, transmission mode 7 and @@ -91,25 +91,25 @@ wideband reports (transmission mode 4, transmission mode 5 and transmission mode This is for PUCCH Format 2 reports */ -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { uint8_t wideband_cqi; // 4-bit width uint8_t spatial_diff_cqi; // If Rank==1 then it is 0-bit width otherwise it is 3-bit width uint8_t pmi; -} srslte_cqi_format2_wideband_t; +} srsran_cqi_format2_wideband_t; -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { uint8_t subband_cqi; // 4-bit width uint8_t subband_label; // 1- or 2-bit width -} srslte_cqi_format2_subband_t; +} srsran_cqi_format2_subband_t; typedef enum { - SRSLTE_CQI_TYPE_WIDEBAND = 0, - SRSLTE_CQI_TYPE_SUBBAND, - SRSLTE_CQI_TYPE_SUBBAND_UE, - SRSLTE_CQI_TYPE_SUBBAND_HL -} srslte_cqi_type_t; + SRSRAN_CQI_TYPE_WIDEBAND = 0, + SRSRAN_CQI_TYPE_SUBBAND, + SRSRAN_CQI_TYPE_SUBBAND_UE, + SRSRAN_CQI_TYPE_SUBBAND_HL +} srsran_cqi_type_t; -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { bool data_enable; bool pmi_present; bool four_antenna_ports; ///< If cell has 4 antenna ports then true otherwise false @@ -118,40 +118,40 @@ typedef struct SRSLTE_API { uint32_t scell_index; ///< Indicates the cell/carrier the measurement belongs, use 0 for PCell uint32_t L; uint32_t N; - srslte_cqi_type_t type; + srsran_cqi_type_t type; uint32_t ri_len; -} srslte_cqi_cfg_t; +} srsran_cqi_cfg_t; typedef struct { union { - srslte_cqi_format2_wideband_t wideband; - srslte_cqi_format2_subband_t subband; - srslte_cqi_ue_subband_t subband_ue; - srslte_cqi_hl_subband_t subband_hl; + srsran_cqi_format2_wideband_t wideband; + srsran_cqi_format2_subband_t subband; + srsran_cqi_ue_subband_t subband_ue; + srsran_cqi_hl_subband_t subband_hl; }; bool data_crc; -} srslte_cqi_value_t; +} srsran_cqi_value_t; -SRSLTE_API int srslte_cqi_size(srslte_cqi_cfg_t* cfg); +SRSRAN_API int srsran_cqi_size(srsran_cqi_cfg_t* cfg); -SRSLTE_API int srslte_cqi_value_pack(srslte_cqi_cfg_t* cfg, srslte_cqi_value_t* value, uint8_t* buff); +SRSRAN_API int srsran_cqi_value_pack(srsran_cqi_cfg_t* cfg, srsran_cqi_value_t* value, uint8_t* buff); -SRSLTE_API int -srslte_cqi_value_unpack(srslte_cqi_cfg_t* cfg, uint8_t buff[SRSLTE_CQI_MAX_BITS], srslte_cqi_value_t* value); +SRSRAN_API int +srsran_cqi_value_unpack(srsran_cqi_cfg_t* cfg, uint8_t buff[SRSRAN_CQI_MAX_BITS], srsran_cqi_value_t* value); -SRSLTE_API int -srslte_cqi_value_tostring(srslte_cqi_cfg_t* cfg, srslte_cqi_value_t* value, char* buff, uint32_t buff_len); +SRSRAN_API int +srsran_cqi_value_tostring(srsran_cqi_cfg_t* cfg, srsran_cqi_value_t* value, char* buff, uint32_t buff_len); -SRSLTE_API bool -srslte_cqi_periodic_send(const srslte_cqi_report_cfg_t* periodic_cfg, uint32_t tti, srslte_frame_type_t frame_type); +SRSRAN_API bool +srsran_cqi_periodic_send(const srsran_cqi_report_cfg_t* periodic_cfg, uint32_t tti, srsran_frame_type_t frame_type); -SRSLTE_API bool -srslte_cqi_periodic_ri_send(const srslte_cqi_report_cfg_t* periodic_cfg, uint32_t tti, srslte_frame_type_t frame_type); +SRSRAN_API bool +srsran_cqi_periodic_ri_send(const srsran_cqi_report_cfg_t* periodic_cfg, uint32_t tti, srsran_frame_type_t frame_type); -SRSLTE_API int srslte_cqi_hl_get_no_subbands(int nof_prb); +SRSRAN_API int srsran_cqi_hl_get_no_subbands(int nof_prb); -SRSLTE_API uint8_t srslte_cqi_from_snr(float snr); +SRSRAN_API uint8_t srsran_cqi_from_snr(float snr); -SRSLTE_API float srslte_cqi_to_coderate(uint32_t cqi, bool use_alt_table); +SRSRAN_API float srsran_cqi_to_coderate(uint32_t cqi, bool use_alt_table); -#endif // SRSLTE_CQI_H +#endif // SRSRAN_CQI_H diff --git a/lib/include/srslte/phy/phch/csi.h b/lib/include/srsran/phy/phch/csi.h similarity index 69% rename from lib/include/srslte/phy/phch/csi.h rename to lib/include/srsran/phy/phch/csi.h index 30f2c773b..2d55f220f 100644 --- a/lib/include/srslte/phy/phch/csi.h +++ b/lib/include/srsran/phy/phch/csi.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,8 +10,8 @@ * */ -#ifndef SRSLTE_CSI_NR_H -#define SRSLTE_CSI_NR_H +#ifndef SRSRAN_CSI_NR_H +#define SRSRAN_CSI_NR_H #include "uci_cfg_nr.h" @@ -21,21 +21,21 @@ * @param slot_idx Slot index within the radio frame * @param measurements CSI measurements * @param[out] uci_data Uplink Control Information data - * @return The number CSI reports for transmission if the provided data is valid, SRSLTE_ERROR code otherwise + * @return The number CSI reports for transmission if the provided data is valid, SRSRAN_ERROR code otherwise */ -SRSLTE_API int srslte_csi_generate_reports(const srslte_csi_hl_cfg_t* cfg, +SRSRAN_API int srsran_csi_generate_reports(const srsran_csi_hl_cfg_t* cfg, uint32_t slot_idx, - const srslte_csi_measurements_t measurements[SRSLTE_CSI_MAX_NOF_RESOURCES], - srslte_csi_report_cfg_t report_cfg[SRSLTE_CSI_MAX_NOF_REPORT], - srslte_csi_report_value_t report_value[SRSLTE_CSI_MAX_NOF_REPORT]); + const srsran_csi_measurements_t measurements[SRSRAN_CSI_MAX_NOF_RESOURCES], + srsran_csi_report_cfg_t report_cfg[SRSRAN_CSI_MAX_NOF_REPORT], + srsran_csi_report_value_t report_value[SRSRAN_CSI_MAX_NOF_REPORT]); /** * @brief Compute number of CSI bits necessary to transmit all the CSI reports for a PUCCH transmission * @param report_list Provides the CSI report list * @param nof_reports Number of CSI reports in the list - * @return The number of bits if the provided list is valid, SRSLTE_ERROR code otherwise + * @return The number of bits if the provided list is valid, SRSRAN_ERROR code otherwise */ -SRSLTE_API int srslte_csi_part1_nof_bits(const srslte_csi_report_cfg_t* report_list, uint32_t nof_reports); +SRSRAN_API int srsran_csi_part1_nof_bits(const srsran_csi_report_cfg_t* report_list, uint32_t nof_reports); /** * @brief Checks if the report list contains part 2 CSI report @@ -43,7 +43,7 @@ SRSLTE_API int srslte_csi_part1_nof_bits(const srslte_csi_report_cfg_t* report_l * @param nof_reports Number of reports in the list * @return True if at least one report contains part 2, false otherwise */ -SRSLTE_API bool srslte_csi_has_part2(const srslte_csi_report_cfg_t* report_list, uint32_t nof_reports); +SRSRAN_API bool srsran_csi_has_part2(const srsran_csi_report_cfg_t* report_list, uint32_t nof_reports); /** * @brief Pack CSI part 1 bits for a PUCCH or PUSCH transmission @@ -51,10 +51,10 @@ SRSLTE_API bool srslte_csi_has_part2(const srslte_csi_report_cfg_t* report_list, * @param nof_reports Number of CSI reports in the list * @param o_csi1 CSI bits * @param max_o_csi1 Maximum number of CSI bits - * @return number of packed bits if provided data is valid, SRSLTE_ERROR code otherwise + * @return number of packed bits if provided data is valid, SRSRAN_ERROR code otherwise */ -SRSLTE_API int srslte_csi_part1_pack(const srslte_csi_report_cfg_t* report_cfg, - const srslte_csi_report_value_t* report_value, +SRSRAN_API int srsran_csi_part1_pack(const srsran_csi_report_cfg_t* report_cfg, + const srsran_csi_report_value_t* report_value, uint32_t nof_reports, uint8_t* o_csi1, uint32_t max_o_csi1); @@ -66,13 +66,13 @@ SRSLTE_API int srslte_csi_part1_pack(const srslte_csi_report_cfg_t* report_cfg * @param o_csi1 CSI bits * @param max_o_csi1 Maximum number of CSI bits * @param report_value - * @return SRSLTE_SUCCESS if provided data is valid, SRSLTE_ERROR code otherwise + * @return SRSRAN_SUCCESS if provided data is valid, SRSRAN_ERROR code otherwise */ -SRSLTE_API int srslte_csi_part1_unpack(const srslte_csi_report_cfg_t* report_cfg, +SRSRAN_API int srsran_csi_part1_unpack(const srsran_csi_report_cfg_t* report_cfg, uint32_t nof_reports, uint8_t* o_csi1, uint32_t max_o_csi1, - srslte_csi_report_value_t* report_value); + srsran_csi_report_value_t* report_value); /** * @brief Converts to string a given list of CSI reports @@ -83,10 +83,10 @@ SRSLTE_API int srslte_csi_part1_unpack(const srslte_csi_report_cfg_t* report_cfg * @param str_len Maximum string length * @return Number of used characters */ -SRSLTE_API uint32_t srslte_csi_str(const srslte_csi_report_cfg_t* report_cfg, - const srslte_csi_report_value_t* report_value, +SRSRAN_API uint32_t srsran_csi_str(const srsran_csi_report_cfg_t* report_cfg, + const srsran_csi_report_value_t* report_value, uint32_t nof_reports, char* str, uint32_t str_len); -#endif // SRSLTE_CSI_NR_H +#endif // SRSRAN_CSI_NR_H diff --git a/lib/include/srslte/phy/phch/csi_cfg.h b/lib/include/srsran/phy/phch/csi_cfg.h similarity index 55% rename from lib/include/srslte/phy/phch/csi_cfg.h rename to lib/include/srsran/phy/phch/csi_cfg.h index f6c578525..81cf88f88 100644 --- a/lib/include/srslte/phy/phch/csi_cfg.h +++ b/lib/include/srsran/phy/phch/csi_cfg.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,104 +10,104 @@ * */ -#ifndef SRSLTE_CSI_CFG_H -#define SRSLTE_CSI_CFG_H +#ifndef SRSRAN_CSI_CFG_H +#define SRSRAN_CSI_CFG_H #include "pucch_cfg_nr.h" -#include "srslte/config.h" +#include "srsran/config.h" #include /** * @brief Maximum number of CSI report configurations defined in TS 38.331 maxNrofCSI-ReportConfigurations */ -#define SRSLTE_CSI_MAX_NOF_REPORT 48 +#define SRSRAN_CSI_MAX_NOF_REPORT 48 /** * @brief Maximum number of CSI-RS resources defined in TS 38.331 maxNrofCSI-ResourceConfigurations */ -#define SRSLTE_CSI_MAX_NOF_RESOURCES 112 +#define SRSRAN_CSI_MAX_NOF_RESOURCES 112 /** * @brief CSI report types defined in TS 38.331 CSI-ReportConfig */ -typedef enum SRSLTE_API { - SRSLTE_CSI_REPORT_TYPE_NONE = 0, - SRSLTE_CSI_REPORT_TYPE_PERIODIC, - SRSLTE_CSI_REPORT_TYPE_SEMI_PERSISTENT_ON_PUCCH, - SRSLTE_CSI_REPORT_TYPE_SEMI_PERSISTENT_ON_PUSCH, - SRSLTE_CSI_REPORT_TYPE_APERIODIC, -} srslte_csi_report_type_t; +typedef enum SRSRAN_API { + SRSRAN_CSI_REPORT_TYPE_NONE = 0, + SRSRAN_CSI_REPORT_TYPE_PERIODIC, + SRSRAN_CSI_REPORT_TYPE_SEMI_PERSISTENT_ON_PUCCH, + SRSRAN_CSI_REPORT_TYPE_SEMI_PERSISTENT_ON_PUSCH, + SRSRAN_CSI_REPORT_TYPE_APERIODIC, +} srsran_csi_report_type_t; /** * @brief CSI report quantities defined in TS 38.331 CSI-ReportConfig */ -typedef enum SRSLTE_API { - SRSLTE_CSI_REPORT_QUANTITY_NONE = 0, - SRSLTE_CSI_REPORT_QUANTITY_CRI_RI_PMI_CQI, - SRSLTE_CSI_REPORT_QUANTITY_CRI_RI_I1, - SRSLTE_CSI_REPORT_QUANTITY_CRI_RI_I1_CQI, - SRSLTE_CSI_REPORT_QUANTITY_CRI_RI_CQI, - SRSLTE_CSI_REPORT_QUANTITY_CRI_RSRP, - SRSLTE_CSI_REPORT_QUANTITY_SSB_INDEX_RSRP, - SRSLTE_CSI_REPORT_QUANTITY_CRI_RI_LI_PMI_CQI -} srslte_csi_report_quantity_t; +typedef enum SRSRAN_API { + SRSRAN_CSI_REPORT_QUANTITY_NONE = 0, + SRSRAN_CSI_REPORT_QUANTITY_CRI_RI_PMI_CQI, + SRSRAN_CSI_REPORT_QUANTITY_CRI_RI_I1, + SRSRAN_CSI_REPORT_QUANTITY_CRI_RI_I1_CQI, + SRSRAN_CSI_REPORT_QUANTITY_CRI_RI_CQI, + SRSRAN_CSI_REPORT_QUANTITY_CRI_RSRP, + SRSRAN_CSI_REPORT_QUANTITY_SSB_INDEX_RSRP, + SRSRAN_CSI_REPORT_QUANTITY_CRI_RI_LI_PMI_CQI +} srsran_csi_report_quantity_t; /** * @brief CSI report frequency configuration defined in TS 38.331 CSI-ReportConfig */ -typedef enum SRSLTE_API { - SRSLTE_CSI_REPORT_FREQ_WIDEBAND = 0, - SRSLTE_CSI_REPORT_FREQ_SUBBAND -} srslte_csi_report_freq_t; +typedef enum SRSRAN_API { + SRSRAN_CSI_REPORT_FREQ_WIDEBAND = 0, + SRSRAN_CSI_REPORT_FREQ_SUBBAND +} srsran_csi_report_freq_t; /** * @brief CQI table selection */ -typedef enum SRSLTE_API { - SRSLTE_CSI_CQI_TABLE_1 = 0, - SRSLTE_CSI_CQI_TABLE_2, - SRSLTE_CSI_CQI_TABLE_3, -} srslte_csi_cqi_table_t; +typedef enum SRSRAN_API { + SRSRAN_CSI_CQI_TABLE_1 = 0, + SRSRAN_CSI_CQI_TABLE_2, + SRSRAN_CSI_CQI_TABLE_3, +} srsran_csi_cqi_table_t; /** * @brief CSI periodic report configuration from upper layers * @remark Described in TS 38.331 CSI-ReportConfig */ -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { uint32_t period; ///< Period in slots uint32_t offset; ///< Offset from beginning of the period in slots - srslte_pucch_nr_resource_t resource; ///< PUCCH resource to use for reporting -} srslte_csi_periodic_report_cfg_t; + srsran_pucch_nr_resource_t resource; ///< PUCCH resource to use for reporting +} srsran_csi_periodic_report_cfg_t; /** * @brief CSI report configuration from higher layers */ -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { uint32_t channel_meas_id; ///< Channel measurement resource identifier uint32_t interf_meas_id; ///< Interference measurement resource identifier bool interf_meas_present; ///< Indicates if interference measurement identifier is present - srslte_csi_report_type_t type; ///< CSI report type (none, periodic, semiPersistentOnPUCCH, ...) + srsran_csi_report_type_t type; ///< CSI report type (none, periodic, semiPersistentOnPUCCH, ...) union { void* none; ///< Reserved, no configured - srslte_csi_periodic_report_cfg_t periodic; ///< Used for periodic reporting + srsran_csi_periodic_report_cfg_t periodic; ///< Used for periodic reporting // ... add here other types }; - srslte_csi_report_quantity_t quantity; ///< Report quantity - srslte_csi_cqi_table_t cqi_table; ///< CQI table selection - srslte_csi_report_freq_t freq_cfg; ///< Determine whether it is wideband or subband -} srslte_csi_hl_report_cfg_t; + srsran_csi_report_quantity_t quantity; ///< Report quantity + srsran_csi_cqi_table_t cqi_table; ///< CQI table selection + srsran_csi_report_freq_t freq_cfg; ///< Determine whether it is wideband or subband +} srsran_csi_hl_report_cfg_t; /** * @brief General CSI configuration provided by higher layers */ -typedef struct SRSLTE_API { - srslte_csi_hl_report_cfg_t reports[SRSLTE_CSI_MAX_NOF_REPORT]; ///< CSI report configuration +typedef struct SRSRAN_API { + srsran_csi_hl_report_cfg_t reports[SRSRAN_CSI_MAX_NOF_REPORT]; ///< CSI report configuration // ... add here physical CSI measurement sets -} srslte_csi_hl_cfg_t; +} srsran_csi_hl_cfg_t; /** * @brief Generic measurement structure */ -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { uint32_t cri; ///< CSI-RS Resource Indicator float wideband_rsrp_dBm; ///< Measured NZP-CSI-RS RSRP (Ignore for IM-CSI-RS) float wideband_epre_dBm; ///< Measured EPRE @@ -116,51 +116,51 @@ typedef struct SRSLTE_API { // Resource set context uint32_t nof_ports; ///< Number of antenna ports uint32_t K_csi_rs; ///< Number of CSI-RS in the corresponding resource set -} srslte_csi_measurements_t; +} srsran_csi_measurements_t; /** * @brief CSI report configuration */ -typedef struct SRSLTE_API { - srslte_csi_report_type_t type; ///< CSI report type (none, periodic, semiPersistentOnPUCCH, ...) - srslte_csi_report_quantity_t quantity; ///< Report quantity - srslte_pucch_nr_resource_t pucch_resource; ///< PUCCH resource to use for periodic reporting - srslte_csi_report_freq_t freq_cfg; ///< Determine whether it is wideband or subband +typedef struct SRSRAN_API { + srsran_csi_report_type_t type; ///< CSI report type (none, periodic, semiPersistentOnPUCCH, ...) + srsran_csi_report_quantity_t quantity; ///< Report quantity + srsran_pucch_nr_resource_t pucch_resource; ///< PUCCH resource to use for periodic reporting + srsran_csi_report_freq_t freq_cfg; ///< Determine whether it is wideband or subband // Resource set context uint32_t nof_ports; ///< Number of antenna ports uint32_t K_csi_rs; ///< Number of CSI-RS in the corresponding resource set bool has_part2; ///< Set to true if the report has part 2 -} srslte_csi_report_cfg_t; +} srsran_csi_report_cfg_t; /** * @brief Wideband CSI report values */ -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { uint32_t ri; uint32_t pmi; uint32_t cqi; -} srslte_csi_report_wideband_cri_ri_pmi_cqi_t; +} srsran_csi_report_wideband_cri_ri_pmi_cqi_t; /** * @brief Unified CSI report values */ -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { uint32_t cri; ///< CSI-RS Resource Indicator union { void* none; - srslte_csi_report_wideband_cri_ri_pmi_cqi_t wideband_cri_ri_pmi_cqi; + srsran_csi_report_wideband_cri_ri_pmi_cqi_t wideband_cri_ri_pmi_cqi; }; bool valid; ///< Used by receiver only -} srslte_csi_report_value_t; +} srsran_csi_report_value_t; /** * @brief Complete report configuration and value */ -typedef struct SRSLTE_API { - srslte_csi_report_cfg_t cfg[SRSLTE_CSI_MAX_NOF_REPORT]; ///< Configuration ready for encoding - srslte_csi_report_value_t value[SRSLTE_CSI_MAX_NOF_REPORT]; ///< Quantified values +typedef struct SRSRAN_API { + srsran_csi_report_cfg_t cfg[SRSRAN_CSI_MAX_NOF_REPORT]; ///< Configuration ready for encoding + srsran_csi_report_value_t value[SRSRAN_CSI_MAX_NOF_REPORT]; ///< Quantified values uint32_t nof_reports; ///< Total number of reports to transmit -} srslte_csi_reports_t; +} srsran_csi_reports_t; -#endif // SRSLTE_CSI_CFG_H +#endif // SRSRAN_CSI_CFG_H diff --git a/lib/include/srsran/phy/phch/dci.h b/lib/include/srsran/phy/phch/dci.h new file mode 100644 index 000000000..96f86a6ea --- /dev/null +++ b/lib/include/srsran/phy/phch/dci.h @@ -0,0 +1,243 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +/****************************************************************************** + * File: dci.h + * + * Description: Downlink control information (DCI). + * Packing/Unpacking functions to convert between bit streams + * and packed DCI UL/DL grants defined in ra.h + * + * Reference: 3GPP TS 36.212 version 10.0.0 Release 10 Sec. 5.3.3 + *****************************************************************************/ + +#ifndef SRSRAN_DCI_H +#define SRSRAN_DCI_H + +#include + +#include "srsran/config.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/phch/ra.h" + +#define SRSRAN_DCI_MAX_BITS 128 +#define SRSRAN_RAR_GRANT_LEN 20 + +#define SRSRAN_DCI_IS_TB_EN(tb) (!(tb.mcs_idx == 0 && tb.rv == 1)) +#define SRSRAN_DCI_TB_DISABLE(tb) \ + do { \ + tb.mcs_idx = 0; \ + tb.rv = 1; \ + } while (0) +#define SRSRAN_DCI_HEXDEBUG 0 + +typedef struct { + bool multiple_csi_request_enabled; + bool cif_enabled; + bool cif_present; + bool srs_request_enabled; + bool ra_format_enabled; + bool is_not_ue_ss; +} srsran_dci_cfg_t; + +typedef struct SRSRAN_API { + uint32_t L; // Aggregation level (logarithmic) + uint32_t ncce; // Position of first CCE of the dci +} srsran_dci_location_t; + +typedef struct SRSRAN_API { + uint8_t payload[SRSRAN_DCI_MAX_BITS]; + uint32_t nof_bits; + srsran_dci_location_t location; + srsran_dci_format_t format; + uint16_t rnti; +} srsran_dci_msg_t; + +typedef struct SRSRAN_API { + uint32_t mcs_idx; + int rv; + bool ndi; + uint32_t cw_idx; +} srsran_dci_tb_t; + +typedef struct SRSRAN_API { + + uint16_t rnti; + srsran_dci_format_t format; + srsran_dci_location_t location; + uint32_t ue_cc_idx; + + // Resource Allocation + srsran_ra_type_t alloc_type; + union { + srsran_ra_type0_t type0_alloc; + srsran_ra_type1_t type1_alloc; + srsran_ra_type2_t type2_alloc; + }; + + // Codeword information + srsran_dci_tb_t tb[SRSRAN_MAX_CODEWORDS]; + bool tb_cw_swap; + uint32_t pinfo; + + // Power control + bool pconf; + bool power_offset; + uint8_t tpc_pucch; + + // RA order + bool is_ra_order; + uint32_t ra_preamble; + uint32_t ra_mask_idx; + + // Release 10 + uint32_t cif; + bool cif_present; + bool srs_request; + bool srs_request_present; + + // Other parameters + uint32_t pid; + uint32_t dai; + bool is_tdd; + bool is_dwpts; + bool sram_id; + + // For debugging purposes +#if SRSRAN_DCI_HEXDEBUG + uint32_t nof_bits; + char hex_str[SRSRAN_DCI_MAX_BITS]; +#endif +} srsran_dci_dl_t; + +/** Unpacked DCI Format0 message */ +typedef struct SRSRAN_API { + + uint16_t rnti; + srsran_dci_format_t format; + srsran_dci_location_t location; + uint32_t ue_cc_idx; + + srsran_ra_type2_t type2_alloc; + /* 36.213 Table 8.4-2: SRSRAN_RA_PUSCH_HOP_HALF is 0 for < 10 Mhz and 10 for > 10 Mhz. + * SRSRAN_RA_PUSCH_HOP_QUART is 00 for > 10 Mhz and SRSRAN_RA_PUSCH_HOP_QUART_NEG is 01 for > 10 Mhz. + */ + enum { + SRSRAN_RA_PUSCH_HOP_DISABLED = -1, + SRSRAN_RA_PUSCH_HOP_QUART = 0, + SRSRAN_RA_PUSCH_HOP_QUART_NEG = 1, + SRSRAN_RA_PUSCH_HOP_HALF = 2, + SRSRAN_RA_PUSCH_HOP_TYPE2 = 3 + } freq_hop_fl; + + // Codeword information + srsran_dci_tb_t tb; + uint32_t n_dmrs; + bool cqi_request; + + // TDD parametres + uint32_t dai; + uint32_t ul_idx; + bool is_tdd; + + // Power control + uint8_t tpc_pusch; + + // Release 10 + uint32_t cif; + bool cif_present; + uint8_t multiple_csi_request; + bool multiple_csi_request_present; + bool srs_request; + bool srs_request_present; + srsran_ra_type_t ra_type; + bool ra_type_present; + + // For debugging purposes +#if SRSRAN_DCI_HEXDEBUG + uint32_t nof_bits; + char hex_str[SRSRAN_DCI_MAX_BITS]; +#endif /* SRSRAN_DCI_HEXDEBUG */ + +} srsran_dci_ul_t; + +typedef struct SRSRAN_API { + uint32_t rba; + uint32_t trunc_mcs; + uint32_t tpc_pusch; + bool ul_delay; + bool cqi_request; + bool hopping_flag; +} srsran_dci_rar_grant_t; + +SRSRAN_API void srsran_dci_rar_unpack(uint8_t payload[SRSRAN_RAR_GRANT_LEN], srsran_dci_rar_grant_t* rar); + +SRSRAN_API void srsran_dci_rar_pack(srsran_dci_rar_grant_t* rar, uint8_t payload[SRSRAN_RAR_GRANT_LEN]); + +SRSRAN_API int srsran_dci_rar_to_ul_dci(srsran_cell_t* cell, srsran_dci_rar_grant_t* rar, srsran_dci_ul_t* dci_ul); + +SRSRAN_API int srsran_dci_msg_pack_pusch(srsran_cell_t* cell, + srsran_dl_sf_cfg_t* sf, + srsran_dci_cfg_t* cfg, + srsran_dci_ul_t* dci, + srsran_dci_msg_t* msg); + +SRSRAN_API int srsran_dci_msg_unpack_pusch(srsran_cell_t* cell, + srsran_dl_sf_cfg_t* sf, + srsran_dci_cfg_t* cfg, + srsran_dci_msg_t* msg, + srsran_dci_ul_t* dci); + +SRSRAN_API int srsran_dci_msg_pack_pdsch(srsran_cell_t* cell, + srsran_dl_sf_cfg_t* sf, + srsran_dci_cfg_t* cfg, + srsran_dci_dl_t* dci, + srsran_dci_msg_t* msg); + +SRSRAN_API int srsran_dci_msg_unpack_pdsch(srsran_cell_t* cell, + srsran_dl_sf_cfg_t* sf, + srsran_dci_cfg_t* cfg, + srsran_dci_msg_t* msg, + srsran_dci_dl_t* dci); + +SRSRAN_API uint32_t srsran_dci_format_sizeof(const srsran_cell_t* cell, + srsran_dl_sf_cfg_t* sf, + srsran_dci_cfg_t* cfg, + srsran_dci_format_t format); + +SRSRAN_API void srsran_dci_dl_fprint(FILE* f, srsran_dci_dl_t* dci, uint32_t nof_prb); + +SRSRAN_API uint32_t srsran_dci_dl_info(const srsran_dci_dl_t* dci_dl, char* str, uint32_t str_len); + +SRSRAN_API uint32_t srsran_dci_ul_info(srsran_dci_ul_t* dci_ul, char* info_str, uint32_t len); + +SRSRAN_API srsran_dci_format_t srsran_dci_format_from_string(char* str); + +SRSRAN_API char* srsran_dci_format_string(srsran_dci_format_t format); + +SRSRAN_API char* srsran_dci_format_string_short(srsran_dci_format_t format); + +SRSRAN_API bool +srsran_location_find(const srsran_dci_location_t* locations, uint32_t nof_locations, srsran_dci_location_t x); + +SRSRAN_API bool +srsran_location_find_ncce(const srsran_dci_location_t* locations, uint32_t nof_locations, uint32_t ncce); + +SRSRAN_API int srsran_dci_location_set(srsran_dci_location_t* c, uint32_t L, uint32_t nCCE); + +SRSRAN_API bool srsran_dci_location_isvalid(srsran_dci_location_t* c); + +SRSRAN_API void srsran_dci_cfg_set_common_ss(srsran_dci_cfg_t* cfg); + +SRSRAN_API uint32_t srsran_dci_format_max_tb(srsran_dci_format_t format); + +#endif // DCI_ diff --git a/lib/include/srsran/phy/phch/dci_nbiot.h b/lib/include/srsran/phy/phch/dci_nbiot.h new file mode 100644 index 000000000..874831a0e --- /dev/null +++ b/lib/include/srsran/phy/phch/dci_nbiot.h @@ -0,0 +1,74 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +/** + * + * @file dci_nbiot.h + * + * @brief Downlink control information (DCI) for NB-IoT. + * + * Packing/Unpacking functions to convert between bit streams + * and packed DCI UL/DL grants defined in ra_nbiot.h + * + * Reference: 3GPP TS 36.212 version 13.2.0 Release 13 Sec. 6.4.3 + * + */ + +#ifndef SRSRAN_DCI_NBIOT_H +#define SRSRAN_DCI_NBIOT_H + +#include + +#include "srsran/config.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/phch/dci.h" +#include "srsran/phy/phch/ra_nbiot.h" + +#define SRSRAN_DCI_MAX_BITS 128 +#define SRSRAN_NBIOT_RAR_GRANT_LEN 15 + +SRSRAN_API void srsran_nbiot_dci_rar_grant_unpack(srsran_nbiot_dci_rar_grant_t* rar, + const uint8_t grant[SRSRAN_NBIOT_RAR_GRANT_LEN]); + +SRSRAN_API int srsran_nbiot_dci_msg_to_dl_grant(const srsran_dci_msg_t* msg, + const uint16_t msg_rnti, + srsran_ra_nbiot_dl_dci_t* dl_dci, + srsran_ra_nbiot_dl_grant_t* grant, + const uint32_t sfn, + const uint32_t sf_idx, + const uint32_t r_max, + const srsran_nbiot_mode_t mode); + +SRSRAN_API int srsran_nbiot_dci_msg_to_ul_grant(const srsran_dci_msg_t* msg, + srsran_ra_nbiot_ul_dci_t* ul_dci, + srsran_ra_nbiot_ul_grant_t* grant, + const uint32_t rx_tti, + const srsran_npusch_sc_spacing_t spacing); + +SRSRAN_API int +srsran_nbiot_dci_rar_to_ul_grant(srsran_nbiot_dci_rar_grant_t* rar, srsran_ra_nbiot_ul_grant_t* grant, uint32_t rx_tti); + +SRSRAN_API bool srsran_nbiot_dci_location_isvalid(const srsran_dci_location_t* c); + +SRSRAN_API int srsran_dci_msg_pack_npdsch(const srsran_ra_nbiot_dl_dci_t* data, + const srsran_dci_format_t format, + srsran_dci_msg_t* msg, + const bool crc_is_crnti); + +SRSRAN_API int +srsran_dci_msg_unpack_npdsch(const srsran_dci_msg_t* msg, srsran_ra_nbiot_dl_dci_t* data, const bool crc_is_crnti); + +SRSRAN_API int srsran_dci_msg_unpack_npusch(const srsran_dci_msg_t* msg, srsran_ra_nbiot_ul_dci_t* data); + +SRSRAN_API uint32_t srsran_dci_nbiot_format_sizeof(srsran_dci_format_t format); + +#endif // SRSRAN_DCI_NBIOT_H diff --git a/lib/include/srslte/phy/phch/dci_nr.h b/lib/include/srsran/phy/phch/dci_nr.h similarity index 55% rename from lib/include/srslte/phy/phch/dci_nr.h rename to lib/include/srsran/phy/phch/dci_nr.h index 3e906008b..342d4e68a 100644 --- a/lib/include/srslte/phy/phch/dci_nr.h +++ b/lib/include/srsran/phy/phch/dci_nr.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,30 +10,30 @@ * */ -#ifndef SRSLTE_DCI_NR_H -#define SRSLTE_DCI_NR_H +#ifndef SRSRAN_DCI_NR_H +#define SRSRAN_DCI_NR_H #include "dci.h" -#include "srslte/phy/common/phy_common_nr.h" -#include "srslte/phy/phch/phch_cfg_nr.h" +#include "srsran/phy/common/phy_common_nr.h" +#include "srsran/phy/phch/phch_cfg_nr.h" -typedef struct SRSLTE_API { - srslte_dci_location_t location; - srslte_search_space_type_t search_space; +typedef struct SRSRAN_API { + srsran_dci_location_t location; + srsran_search_space_type_t search_space; uint32_t coreset_id; uint8_t payload[50]; - srslte_rnti_type_t rnti_type; + srsran_rnti_type_t rnti_type; uint32_t nof_bits; - srslte_dci_format_nr_t format; + srsran_dci_format_nr_t format; uint16_t rnti; -} srslte_dci_msg_nr_t; +} srsran_dci_msg_nr_t; -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { uint16_t rnti; - srslte_rnti_type_t rnti_type; - srslte_dci_format_nr_t format; - srslte_dci_location_t location; - srslte_search_space_type_t search_space; + srsran_rnti_type_t rnti_type; + srsran_dci_format_nr_t format; + srsran_dci_location_t location; + srsran_search_space_type_t search_space; uint32_t coreset_id; // Common fields @@ -60,15 +60,15 @@ typedef struct SRSLTE_API { // SI-RNTI specific fields uint32_t sii; ///< System information indicator -} srslte_dci_dl_nr_t; +} srsran_dci_dl_nr_t; -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { // Context information uint16_t rnti; - srslte_rnti_type_t rnti_type; - srslte_dci_format_nr_t format; - srslte_dci_location_t location; - srslte_search_space_type_t search_space; + srsran_rnti_type_t rnti_type; + srsran_dci_format_nr_t format; + srsran_dci_location_t location; + srsran_search_space_type_t search_space; uint32_t coreset_id; // Common fields @@ -91,7 +91,7 @@ typedef struct SRSLTE_API { // Random Access Response Grant uint32_t csi_request; -} srslte_dci_ul_nr_t; +} srsran_dci_ul_nr_t; /** * @brief Indicates whether the provided DCI message format bit indicator belongs to DCI format 1_0 according according @@ -99,52 +99,52 @@ typedef struct SRSLTE_API { * @param dci_msg Provides DCI format 1_0 message * @return true if the DCI message is format 1_0, false otherwise */ -SRSLTE_API bool srslte_dci_nr_format_1_0_valid(const srslte_dci_msg_nr_t* dci_msg); +SRSRAN_API bool srsran_dci_nr_format_1_0_valid(const srsran_dci_msg_nr_t* dci_msg); -SRSLTE_API int srslte_dci_nr_pack(const srslte_carrier_nr_t* carrier, - const srslte_coreset_t* coreset, - const srslte_dci_dl_nr_t* dci, - srslte_dci_msg_nr_t* msg); +SRSRAN_API int srsran_dci_nr_pack(const srsran_carrier_nr_t* carrier, + const srsran_coreset_t* coreset, + const srsran_dci_dl_nr_t* dci, + srsran_dci_msg_nr_t* msg); -SRSLTE_API int srslte_dci_nr_format_0_0_sizeof(const srslte_carrier_nr_t* carrier, - const srslte_coreset_t* coreset, - srslte_rnti_type_t rnti_type); +SRSRAN_API int srsran_dci_nr_format_0_0_sizeof(const srsran_carrier_nr_t* carrier, + const srsran_coreset_t* coreset, + srsran_rnti_type_t rnti_type); -SRSLTE_API int srslte_dci_nr_format_0_0_pack(const srslte_carrier_nr_t* carrier, - const srslte_coreset_t* coreset0, - const srslte_dci_ul_nr_t* dci, - srslte_dci_msg_nr_t* msg); +SRSRAN_API int srsran_dci_nr_format_0_0_pack(const srsran_carrier_nr_t* carrier, + const srsran_coreset_t* coreset0, + const srsran_dci_ul_nr_t* dci, + srsran_dci_msg_nr_t* msg); -SRSLTE_API int srslte_dci_nr_format_0_0_unpack(const srslte_carrier_nr_t* carrier, - const srslte_coreset_t* coreset, - srslte_dci_msg_nr_t* msg, - srslte_dci_ul_nr_t* dci); +SRSRAN_API int srsran_dci_nr_format_0_0_unpack(const srsran_carrier_nr_t* carrier, + const srsran_coreset_t* coreset, + srsran_dci_msg_nr_t* msg, + srsran_dci_ul_nr_t* dci); /** * @brief Unpacks DCI from Random Access Response Grant * @remark Described in TS 38.213 Table 8.2-1: Random Access Response Grant Content field size * @param msg * @param dci - * @return SRSLTE_SUCCESS if unpacked correctly, SRSLTE_ERROR code otherwise + * @return SRSRAN_SUCCESS if unpacked correctly, SRSRAN_ERROR code otherwise */ -SRSLTE_API int srslte_dci_nr_rar_unpack(srslte_dci_msg_nr_t* msg, srslte_dci_ul_nr_t* dci); +SRSRAN_API int srsran_dci_nr_rar_unpack(srsran_dci_msg_nr_t* msg, srsran_dci_ul_nr_t* dci); -SRSLTE_API int srslte_dci_nr_format_1_0_sizeof(const srslte_carrier_nr_t* carrier, - const srslte_coreset_t* coreset, - srslte_rnti_type_t rnti_type); +SRSRAN_API int srsran_dci_nr_format_1_0_sizeof(const srsran_carrier_nr_t* carrier, + const srsran_coreset_t* coreset, + srsran_rnti_type_t rnti_type); -SRSLTE_API int srslte_dci_nr_format_1_0_pack(const srslte_carrier_nr_t* carrier, - const srslte_coreset_t* coreset, - const srslte_dci_dl_nr_t* dci, - srslte_dci_msg_nr_t* msg); +SRSRAN_API int srsran_dci_nr_format_1_0_pack(const srsran_carrier_nr_t* carrier, + const srsran_coreset_t* coreset, + const srsran_dci_dl_nr_t* dci, + srsran_dci_msg_nr_t* msg); -SRSLTE_API int srslte_dci_nr_format_1_0_unpack(const srslte_carrier_nr_t* carrier, - const srslte_coreset_t* coreset, - srslte_dci_msg_nr_t* msg, - srslte_dci_dl_nr_t* dci); +SRSRAN_API int srsran_dci_nr_format_1_0_unpack(const srsran_carrier_nr_t* carrier, + const srsran_coreset_t* coreset, + srsran_dci_msg_nr_t* msg, + srsran_dci_dl_nr_t* dci); -SRSLTE_API int srslte_dci_ul_nr_to_str(const srslte_dci_ul_nr_t* dci, char* str, uint32_t str_len); +SRSRAN_API int srsran_dci_ul_nr_to_str(const srsran_dci_ul_nr_t* dci, char* str, uint32_t str_len); -SRSLTE_API int srslte_dci_dl_nr_to_str(const srslte_dci_dl_nr_t* dci, char* str, uint32_t str_len); +SRSRAN_API int srsran_dci_dl_nr_to_str(const srsran_dci_dl_nr_t* dci, char* str, uint32_t str_len); -#endif // SRSLTE_DCI_NR_H +#endif // SRSRAN_DCI_NR_H diff --git a/lib/include/srslte/phy/phch/mib_sl.h b/lib/include/srsran/phy/phch/mib_sl.h similarity index 65% rename from lib/include/srslte/phy/phch/mib_sl.h rename to lib/include/srsran/phy/phch/mib_sl.h index af2048af3..df29b9ee2 100644 --- a/lib/include/srslte/phy/phch/mib_sl.h +++ b/lib/include/srsran/phy/phch/mib_sl.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,14 +10,14 @@ * */ -#ifndef SRSLTE_MIB_SL_H -#define SRSLTE_MIB_SL_H +#ifndef SRSRAN_MIB_SL_H +#define SRSRAN_MIB_SL_H #include #include -#include "srslte/config.h" -#include "srslte/phy/common/phy_common_sl.h" +#include "srsran/config.h" +#include "srsran/phy/common/phy_common_sl.h" /** * Master information block - Sidelink (MIB-SL and MIB-SL-V2X). @@ -26,7 +26,7 @@ * * Reference: 3GPP TS 36.331 version 15.6.0 Release 15 Sec. 6.5 */ -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { uint32_t mib_sl_len; @@ -49,25 +49,25 @@ typedef struct SRSLTE_API { // TM2: (19 bits) // TM4: (27 bits) -} srslte_mib_sl_t; +} srsran_mib_sl_t; -static const int srslte_mib_sl_bandwith_to_prb[6] = {6, 15, 25, 50, 75, 100}; +static const int srsran_mib_sl_bandwith_to_prb[6] = {6, 15, 25, 50, 75, 100}; -SRSLTE_API int srslte_mib_sl_init(srslte_mib_sl_t* q, srslte_sl_tm_t tm); +SRSRAN_API int srsran_mib_sl_init(srsran_mib_sl_t* q, srsran_sl_tm_t tm); -SRSLTE_API int srslte_mib_sl_set(srslte_mib_sl_t* q, +SRSRAN_API int srsran_mib_sl_set(srsran_mib_sl_t* q, uint32_t nof_prb, uint32_t tdd_config, uint32_t direct_frame_number, uint32_t direct_subframe_number, bool in_coverage); -SRSLTE_API void srslte_mib_sl_pack(srslte_mib_sl_t* q, uint8_t* msg); +SRSRAN_API void srsran_mib_sl_pack(srsran_mib_sl_t* q, uint8_t* msg); -SRSLTE_API void srslte_mib_sl_unpack(srslte_mib_sl_t* q, uint8_t* msg); +SRSRAN_API void srsran_mib_sl_unpack(srsran_mib_sl_t* q, uint8_t* msg); -SRSLTE_API void srslte_mib_sl_free(srslte_mib_sl_t* q); +SRSRAN_API void srsran_mib_sl_free(srsran_mib_sl_t* q); -SRSLTE_API void srslte_mib_sl_printf(FILE* f, srslte_mib_sl_t* q); +SRSRAN_API void srsran_mib_sl_printf(FILE* f, srsran_mib_sl_t* q); -#endif // SRSLTE_MIB_SL_H +#endif // SRSRAN_MIB_SL_H diff --git a/lib/include/srsran/phy/phch/npbch.h b/lib/include/srsran/phy/phch/npbch.h new file mode 100644 index 000000000..11117d0d1 --- /dev/null +++ b/lib/include/srsran/phy/phch/npbch.h @@ -0,0 +1,143 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +#ifndef SRSRAN_NPBCH_H +#define SRSRAN_NPBCH_H + +#include "srsran/config.h" +#include "srsran/phy/common/phy_common.h" + +#include "srsran/phy/fec/convolutional/convcoder.h" +#include "srsran/phy/fec/convolutional/rm_conv.h" +#include "srsran/phy/fec/convolutional/viterbi.h" +#include "srsran/phy/fec/crc.h" +#include "srsran/phy/mimo/layermap.h" +#include "srsran/phy/mimo/precoding.h" +#include "srsran/phy/modem/demod_soft.h" +#include "srsran/phy/modem/mod.h" +#include "srsran/phy/scrambling/scrambling.h" + +#define SRSRAN_MIB_NB_LEN 34 +#define SRSRAN_MIB_NB_CRC_LEN (SRSRAN_MIB_NB_LEN + 16) +#define SRSRAN_MIB_NB_ENC_LEN (3 * SRSRAN_MIB_NB_CRC_LEN) + +#define SRSRAN_NPBCH_NUM_RE (12 * 11 - 4 * 8) // 100 RE, entire PRB minus 3 symbols minus 4 times NRS=CRS REs +#define SRSRAN_NPBCH_NUM_BLOCKS 8 // MIB-NB is split across 8 blocks +#define SRSRAN_NPBCH_NUM_REP 8 // number of repetitions per block +#define SRSRAN_NPBCH_NUM_FRAMES (SRSRAN_NPBCH_NUM_BLOCKS * SRSRAN_NPBCH_NUM_REP) + +typedef struct { + uint16_t sfn; + uint16_t hfn; + uint8_t sched_info_sib1; + uint8_t sys_info_tag; + bool ac_barring; + srsran_nbiot_mode_t mode; +} srsran_mib_nb_t; + +/** + * \brief Narrowband Physical broadcast channel (NPBCH) + * + * Reference: 3GPP TS 36.211 version 13.2.0 Release 13 Sec. 10.2.4 + */ +typedef struct SRS_API { + srsran_nbiot_cell_t cell; + + uint32_t frame_idx; + uint32_t nof_symbols; + + // buffers + cf_t* ce[SRSRAN_MAX_PORTS]; + cf_t* symbols[SRSRAN_MAX_PORTS]; + cf_t* x[SRSRAN_MAX_PORTS]; + cf_t* d; + float* llr; + float* temp; + float rm_f[SRSRAN_MIB_NB_ENC_LEN]; + uint8_t* rm_b; + uint8_t data[SRSRAN_MIB_NB_CRC_LEN]; + uint8_t data_enc[SRSRAN_MIB_NB_ENC_LEN]; + + srsran_nbiot_mode_t op_mode; + + // tx & rx objects + srsran_modem_table_t mod; + srsran_sequence_t seq; + srsran_sequence_t seq_r14[SRSRAN_NPBCH_NUM_BLOCKS]; + srsran_viterbi_t decoder; + srsran_crc_t crc; + srsran_convcoder_t encoder; + bool search_all_ports; +} srsran_npbch_t; + +SRSRAN_API int srsran_npbch_init(srsran_npbch_t* q); + +SRSRAN_API void srsran_npbch_free(srsran_npbch_t* q); + +SRSRAN_API int srsran_npbch_set_cell(srsran_npbch_t* q, srsran_nbiot_cell_t cell); + +SRSRAN_API void srsran_npbch_mib_pack(uint32_t sfn, uint32_t hfn, srsran_mib_nb_t mib, uint8_t* msg); + +SRSRAN_API void srsran_npbch_mib_unpack(uint8_t* msg, srsran_mib_nb_t* mib); + +SRSRAN_API void srsran_mib_nb_printf(FILE* stream, srsran_nbiot_cell_t cell, srsran_mib_nb_t* mib); + +SRSRAN_API int srsran_npbch_put_subframe(srsran_npbch_t* q, + uint8_t bch_payload[SRSRAN_MIB_NB_LEN], + cf_t* sf[SRSRAN_MAX_PORTS], + uint32_t frame_idx); + +SRSRAN_API int srsran_npbch_encode(srsran_npbch_t* q, + uint8_t bch_payload[SRSRAN_MIB_NB_LEN], + cf_t* sf[SRSRAN_MAX_PORTS], + uint32_t frame_idx); + +int srsran_npbch_rotate(srsran_npbch_t* q, + uint32_t nf, + cf_t* input_signal, + cf_t* output_signal, + int num_samples, + bool back); + +SRSRAN_API int srsran_npbch_decode(srsran_npbch_t* q, + cf_t* slot1_symbols, + cf_t* ce[SRSRAN_MAX_PORTS], + float noise_estimate, + uint8_t bch_payload[SRSRAN_MIB_NB_LEN], + uint32_t* nof_tx_ports, + int* sfn_offset); + +SRSRAN_API int srsran_npbch_decode_nf(srsran_npbch_t* q, + cf_t* slot1_symbols, + cf_t* ce[SRSRAN_MAX_PORTS], + float noise_estimate, + uint8_t bch_payload[SRSRAN_MIB_NB_LEN], + uint32_t* nof_tx_ports, + int* sfn_offset, + int nf); + +SRSRAN_API void srsran_npbch_decode_reset(srsran_npbch_t* q); + +SRSRAN_API int srsran_npbch_decode_frame(srsran_npbch_t* q, + uint32_t src, + uint32_t dst, + uint32_t n, + uint32_t nof_bits, + uint32_t nof_ports); + +SRSRAN_API uint32_t srsran_npbch_crc_check(srsran_npbch_t* q, uint8_t* bits, uint32_t nof_ports); + +SRSRAN_API void srsran_npbch_crc_set_mask(uint8_t* data, int nof_ports); + +SRSRAN_API int srsran_npbch_cp(cf_t* input, cf_t* output, srsran_nbiot_cell_t cell, bool put); + +#endif // SRSRAN_NPBCH_H diff --git a/lib/include/srsran/phy/phch/npdcch.h b/lib/include/srsran/phy/phch/npdcch.h new file mode 100644 index 000000000..6b920a696 --- /dev/null +++ b/lib/include/srsran/phy/phch/npdcch.h @@ -0,0 +1,124 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +#ifndef SRSRAN_NPDCCH_H +#define SRSRAN_NPDCCH_H + +#include "srsran/config.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/fec/convolutional/convcoder.h" +#include "srsran/phy/fec/convolutional/rm_conv.h" +#include "srsran/phy/fec/convolutional/viterbi.h" +#include "srsran/phy/fec/crc.h" +#include "srsran/phy/mimo/layermap.h" +#include "srsran/phy/mimo/precoding.h" +#include "srsran/phy/modem/demod_soft.h" +#include "srsran/phy/modem/mod.h" +#include "srsran/phy/phch/dci.h" +#include "srsran/phy/phch/regs.h" +#include "srsran/phy/scrambling/scrambling.h" + +#define SRSRAN_RARNTI_END_NBIOT 0x0100 +#define SRSRAN_NBIOT_NUM_NRS_SYMS 8 +#define SRSRAN_NPDCCH_MAX_RE (SRSRAN_NRE * SRSRAN_CP_NORM_SF_NSYMB - SRSRAN_NBIOT_NUM_NRS_SYMS) + +#define SRSRAN_NBIOT_DCI_MAX_SIZE 23 +#define SRSRAN_AL_REPETITION_USS 64 // Higher layer configured parameter al-Repetition-USS + +typedef enum SRSRAN_API { + SRSRAN_NPDCCH_FORMAT1 = 0, + SRSRAN_NPDCCH_FORMAT0_LOWER_HALF, + SRSRAN_NPDCCH_FORMAT0_UPPER_HALF, + SRSRAN_NPDCCH_FORMAT_NITEMS +} srsran_npdcch_format_t; +static const char srsran_npdcch_format_text[SRSRAN_NPDCCH_FORMAT_NITEMS][30] = {"Format 1", + "Format 0 (Lower Half)", + "Format 0 (Upper Half)"}; + +/** + * @brief Narrowband Physical downlink control channel (NPDCCH) + * + * Reference: 3GPP TS 36.211 version 13.2.0 Release 11 Sec. 6.8 and 10.2.5 + */ +typedef struct SRSRAN_API { + srsran_nbiot_cell_t cell; + uint32_t nof_cce; + uint32_t ncce_bits; + uint32_t max_bits; + uint32_t i_n_start; /// start of the first OFDM symbol (signalled through NB-SIB1) + uint32_t nof_nbiot_refs; /// number of NRS symbols per OFDM symbol + uint32_t nof_lte_refs; /// number of CRS symbols per OFDM symbol + uint32_t num_decoded_symbols; + + /* buffers */ + cf_t* ce[SRSRAN_MAX_PORTS]; + cf_t* symbols[SRSRAN_MAX_PORTS]; + cf_t* x[SRSRAN_MAX_PORTS]; + cf_t* d; + uint8_t* e; + float rm_f[3 * (SRSRAN_DCI_MAX_BITS + 16)]; + float* llr[2]; // Two layers of LLRs for Format0 and Format1 NPDCCH + + /* tx & rx objects */ + srsran_modem_table_t mod; + srsran_sequence_t seq[SRSRAN_NOF_SF_X_FRAME]; + srsran_viterbi_t decoder; + srsran_crc_t crc; + +} srsran_npdcch_t; + +SRSRAN_API int srsran_npdcch_init(srsran_npdcch_t* q); + +SRSRAN_API void srsran_npdcch_free(srsran_npdcch_t* q); + +SRSRAN_API int srsran_npdcch_set_cell(srsran_npdcch_t* q, srsran_nbiot_cell_t cell); + +/// Encoding function +SRSRAN_API int srsran_npdcch_encode(srsran_npdcch_t* q, + srsran_dci_msg_t* msg, + srsran_dci_location_t location, + uint16_t rnti, + cf_t* sf_symbols[SRSRAN_MAX_PORTS], + uint32_t nsubframe); + +/// Decoding functions: Extract the LLRs and save them in the srsran_npdcch_t object +SRSRAN_API int srsran_npdcch_extract_llr(srsran_npdcch_t* q, + cf_t* sf_symbols, + cf_t* ce[SRSRAN_MAX_PORTS], + float noise_estimate, + uint32_t sf_idx); + +/// Decoding functions: Try to decode a DCI message after calling srsran_npdcch_extract_llr +SRSRAN_API int srsran_npdcch_decode_msg(srsran_npdcch_t* q, + srsran_dci_msg_t* msg, + srsran_dci_location_t* location, + srsran_dci_format_t format, + uint16_t* crc_rem); + +SRSRAN_API int +srsran_npdcch_dci_decode(srsran_npdcch_t* q, float* e, uint8_t* data, uint32_t E, uint32_t nof_bits, uint16_t* crc); + +SRSRAN_API int +srsran_npdcch_dci_encode(srsran_npdcch_t* q, uint8_t* data, uint8_t* e, uint32_t nof_bits, uint32_t E, uint16_t rnti); + +SRSRAN_API void +srsran_npdcch_dci_encode_conv(srsran_npdcch_t* q, uint8_t* data, uint32_t nof_bits, uint8_t* coded_data, uint16_t rnti); + +SRSRAN_API uint32_t srsran_npdcch_ue_locations(srsran_dci_location_t* c, uint32_t max_candidates); + +SRSRAN_API uint32_t srsran_npdcch_common_locations(srsran_dci_location_t* c, uint32_t max_candidates); + +int srsran_npdcch_cp(srsran_npdcch_t* q, cf_t* input, cf_t* output, bool put, srsran_npdcch_format_t format); +int srsran_npdcch_put(srsran_npdcch_t* q, cf_t* symbols, cf_t* sf_symbols, srsran_npdcch_format_t format); +int srsran_npdcch_get(srsran_npdcch_t* q, cf_t* symbols, cf_t* sf_symbols, srsran_npdcch_format_t format); + +#endif // SRSRAN_NPDCCH_H diff --git a/lib/include/srsran/phy/phch/npdsch.h b/lib/include/srsran/phy/phch/npdsch.h new file mode 100644 index 000000000..ff7e710e0 --- /dev/null +++ b/lib/include/srsran/phy/phch/npdsch.h @@ -0,0 +1,151 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +#ifndef SRSRAN_NPDSCH_H +#define SRSRAN_NPDSCH_H + +#include "srsran/config.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/fec/convolutional/convcoder.h" +#include "srsran/phy/fec/crc.h" +#include "srsran/phy/mimo/layermap.h" +#include "srsran/phy/mimo/precoding.h" +#include "srsran/phy/modem/demod_soft.h" +#include "srsran/phy/modem/mod.h" +#include "srsran/phy/phch/dci.h" +#include "srsran/phy/phch/npdsch_cfg.h" +#include "srsran/phy/phch/regs.h" +#include "srsran/phy/phch/sch.h" +#include "srsran/phy/scrambling/scrambling.h" + +#define SRSRAN_NPDSCH_MAX_RE \ + (SRSRAN_CP_NORM_SF_NSYMB * SRSRAN_NRE - 8) ///< Full PRB minus 8 RE for NRS (one antenna port) +#define SRSRAN_NPDSCH_MAX_TBS 680 ///< Max TBS in Rel13 NB-IoT +#define SRSRAN_NPDSCH_CRC_LEN (24) +#define SRSRAN_NPDSCH_MAX_TBS_CRC (SRSRAN_NPDSCH_MAX_TBS + SRSRAN_NPDSCH_CRC_LEN) +#define SRSRAN_NPDSCH_MAX_TBS_ENC (3 * SRSRAN_NPDSCH_MAX_TBS_CRC) +#define SRSRAN_NPDSCH_MAX_NOF_SF 10 +#define SRSRAN_NPDSCH_NUM_SEQ (2 * SRSRAN_NOF_SF_X_FRAME) ///< for even and odd numbered SFNs + +/* @brief Narrowband Physical Downlink shared channel (NPDSCH) + * + * Reference: 3GPP TS 36.211 version 13.2.0 Release 13 Sec. 10.2.3 + */ +typedef struct SRSRAN_API { + srsran_nbiot_cell_t cell; + uint32_t max_re; + bool rnti_is_set; + uint16_t rnti; + + // buffers + uint8_t data[SRSRAN_NPDSCH_MAX_TBS_CRC]; + uint8_t data_enc[SRSRAN_NPDSCH_MAX_TBS_ENC]; + float rm_f[SRSRAN_NPDSCH_MAX_TBS_ENC]; + cf_t* ce[SRSRAN_MAX_PORTS]; + cf_t* symbols[SRSRAN_MAX_PORTS]; + cf_t* sib_symbols[SRSRAN_MAX_PORTS]; // extra buffer for SIB1 symbols as they may be interleaved with other NPDSCH + cf_t* tx_syms[SRSRAN_MAX_PORTS]; // pointer to either symbols or sib1_symbols + cf_t* x[SRSRAN_MAX_PORTS]; + cf_t* d; + + float* llr; + uint8_t* temp; + uint8_t* rm_b; + + // tx & rx objects + srsran_modem_table_t mod; + srsran_viterbi_t decoder; + srsran_sequence_t seq[SRSRAN_NPDSCH_NUM_SEQ]; + srsran_crc_t crc; + srsran_convcoder_t encoder; +} srsran_npdsch_t; + +typedef struct { + uint16_t hyper_sfn; + // TODO: add all other fields +} srsran_sys_info_block_type_1_nb_t; + +SRSRAN_API int srsran_npdsch_init(srsran_npdsch_t* q); + +SRSRAN_API void srsran_npdsch_free(srsran_npdsch_t* q); + +SRSRAN_API int srsran_npdsch_set_cell(srsran_npdsch_t* q, srsran_nbiot_cell_t cell); + +SRSRAN_API int srsran_npdsch_set_rnti(srsran_npdsch_t* q, uint16_t rnti); + +SRSRAN_API int srsran_npdsch_cfg(srsran_npdsch_cfg_t* cfg, + srsran_nbiot_cell_t cell, + srsran_ra_nbiot_dl_grant_t* grant, + uint32_t sf_idx); + +SRSRAN_API int srsran_npdsch_encode(srsran_npdsch_t* q, + srsran_npdsch_cfg_t* cfg, + srsran_softbuffer_tx_t* softbuffer, + uint8_t* data, + cf_t* sf_symbols[SRSRAN_MAX_PORTS]); + +SRSRAN_API int srsran_npdsch_encode_rnti_idx(srsran_npdsch_t* q, + srsran_npdsch_cfg_t* cfg, + srsran_softbuffer_tx_t* softbuffer, + uint8_t* data, + uint32_t rnti_idx, + cf_t* sf_symbols[SRSRAN_MAX_PORTS]); + +SRSRAN_API int srsran_npdsch_encode_rnti(srsran_npdsch_t* q, + srsran_npdsch_cfg_t* cfg, + srsran_softbuffer_tx_t* softbuffer, + uint8_t* data, + uint16_t rnti, + cf_t* sf_symbols[SRSRAN_MAX_PORTS]); + +SRSRAN_API int srsran_npdsch_encode_seq(srsran_npdsch_t* q, + srsran_npdsch_cfg_t* cfg, + srsran_softbuffer_tx_t* softbuffer, + uint8_t* data, + srsran_sequence_t* seq, + cf_t* sf_symbols[SRSRAN_MAX_PORTS]); + +SRSRAN_API int srsran_npdsch_decode(srsran_npdsch_t* q, + srsran_npdsch_cfg_t* cfg, + srsran_softbuffer_rx_t* softbuffer, + cf_t* sf_symbols, + cf_t* ce[SRSRAN_MAX_PORTS], + float noise_estimate, + uint32_t sfn, + uint8_t* data); + +SRSRAN_API int srsran_npdsch_decode_rnti(srsran_npdsch_t* q, + srsran_npdsch_cfg_t* cfg, + srsran_softbuffer_rx_t* softbuffer, + cf_t* sf_symbols, + cf_t* ce[SRSRAN_MAX_PORTS], + float noise_estimate, + uint16_t rnti, + uint32_t sfn, + uint8_t* data, + uint32_t rep_counter); + +SRSRAN_API int +srsran_npdsch_rm_and_decode(srsran_npdsch_t* q, srsran_npdsch_cfg_t* cfg, float* softbits, uint8_t* data); + +SRSRAN_API int +srsran_npdsch_cp(srsran_npdsch_t* q, cf_t* input, cf_t* output, srsran_ra_nbiot_dl_grant_t* grant, bool put); + +SRSRAN_API float srsran_npdsch_average_noi(srsran_npdsch_t* q); + +SRSRAN_API uint32_t srsran_npdsch_last_noi(srsran_npdsch_t* q); + +SRSRAN_API void srsran_npdsch_sib1_pack(srsran_cell_t* cell, srsran_sys_info_block_type_1_nb_t* sib, uint8_t* payload); + +SRSRAN_API void srsran_npdsch_sib1_unpack(uint8_t* const msg, srsran_sys_info_block_type_1_nb_t* sib); + +#endif // SRSRAN_NPDSCH_H diff --git a/lib/include/srslte/phy/phch/npdsch_cfg.h b/lib/include/srsran/phy/phch/npdsch_cfg.h similarity index 70% rename from lib/include/srslte/phy/phch/npdsch_cfg.h rename to lib/include/srsran/phy/phch/npdsch_cfg.h index 7b7309ad3..73f2895b5 100644 --- a/lib/include/srslte/phy/phch/npdsch_cfg.h +++ b/lib/include/srsran/phy/phch/npdsch_cfg.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,24 +10,24 @@ * */ -#ifndef SRSLTE_NPDSCH_CFG_H -#define SRSLTE_NPDSCH_CFG_H +#ifndef SRSRAN_NPDSCH_CFG_H +#define SRSRAN_NPDSCH_CFG_H -#include "srslte/phy/phch/ra_nbiot.h" +#include "srsran/phy/phch/ra_nbiot.h" /* * @brief Narrowband Physical downlink shared channel configuration * * Reference: 3GPP TS 36.211 version 13.2.0 Release 13 Sec. 10.2.3 */ -typedef struct SRSLTE_API { - srslte_ra_nbiot_dl_grant_t grant; - srslte_ra_nbits_t nbits; +typedef struct SRSRAN_API { + srsran_ra_nbiot_dl_grant_t grant; + srsran_ra_nbits_t nbits; bool is_encoded; bool has_bcch; // Whether this NPDSCH is carrying the BCCH uint32_t sf_idx; // The current idx within the entire NPDSCH uint32_t rep_idx; // The current repetion within this NPDSCH uint32_t num_sf; // Total number of subframes tx'ed in this NPDSCH -} srslte_npdsch_cfg_t; +} srsran_npdsch_cfg_t; -#endif // SRSLTE_NPDSCH_CFG_H +#endif // SRSRAN_NPDSCH_CFG_H diff --git a/lib/include/srsran/phy/phch/pbch.h b/lib/include/srsran/phy/phch/pbch.h new file mode 100644 index 000000000..39457258f --- /dev/null +++ b/lib/include/srsran/phy/phch/pbch.h @@ -0,0 +1,99 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +/****************************************************************************** + * File: pbch.h + * + * Description: Physical broadcast channel. If cell.nof_ports = 0, the number + * of ports is blindly determined using the CRC of the received + * codeword for 1, 2 and 4 ports + * + * Reference: 3GPP TS 36.211 version 10.0.0 Release 10 Sec. 6.6 + *****************************************************************************/ + +#ifndef SRSRAN_PBCH_H +#define SRSRAN_PBCH_H + +#include "srsran/config.h" +#include "srsran/phy/ch_estimation/chest_dl.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/fec/convolutional/convcoder.h" +#include "srsran/phy/fec/convolutional/rm_conv.h" +#include "srsran/phy/fec/convolutional/viterbi.h" +#include "srsran/phy/fec/crc.h" +#include "srsran/phy/mimo/layermap.h" +#include "srsran/phy/mimo/precoding.h" +#include "srsran/phy/modem/demod_soft.h" +#include "srsran/phy/modem/mod.h" +#include "srsran/phy/scrambling/scrambling.h" + +#define SRSRAN_BCH_PAYLOAD_LEN 24 +#define SRSRAN_BCH_PAYLOADCRC_LEN (SRSRAN_BCH_PAYLOAD_LEN + 16) +#define SRSRAN_BCH_ENCODED_LEN 3 * (SRSRAN_BCH_PAYLOADCRC_LEN) + +#define SRSRAN_PBCH_MAX_RE 256 // make it avx2-aligned + +/* PBCH object */ +typedef struct SRSRAN_API { + srsran_cell_t cell; + + uint32_t nof_symbols; + + /* buffers */ + cf_t* ce[SRSRAN_MAX_PORTS]; + cf_t* symbols[SRSRAN_MAX_PORTS]; + cf_t* x[SRSRAN_MAX_PORTS]; + cf_t* d; + float* llr; + float* temp; + float rm_f[SRSRAN_BCH_ENCODED_LEN]; + uint8_t* rm_b; + uint8_t data[SRSRAN_BCH_PAYLOADCRC_LEN]; + uint8_t data_enc[SRSRAN_BCH_ENCODED_LEN]; + + uint32_t frame_idx; + + /* tx & rx objects */ + srsran_modem_table_t mod; + srsran_sequence_t seq; + srsran_viterbi_t decoder; + srsran_crc_t crc; + srsran_convcoder_t encoder; + bool search_all_ports; + +} srsran_pbch_t; + +SRSRAN_API int srsran_pbch_init(srsran_pbch_t* q); + +SRSRAN_API void srsran_pbch_free(srsran_pbch_t* q); + +SRSRAN_API int srsran_pbch_set_cell(srsran_pbch_t* q, srsran_cell_t cell); + +SRSRAN_API int srsran_pbch_decode(srsran_pbch_t* q, + srsran_chest_dl_res_t* channel, + cf_t* sf_symbols[SRSRAN_MAX_PORTS], + uint8_t bch_payload[SRSRAN_BCH_PAYLOAD_LEN], + uint32_t* nof_tx_ports, + int* sfn_offset); + +SRSRAN_API int srsran_pbch_encode(srsran_pbch_t* q, + uint8_t bch_payload[SRSRAN_BCH_PAYLOAD_LEN], + cf_t* sf_symbols[SRSRAN_MAX_PORTS], + uint32_t frame_idx); + +SRSRAN_API void srsran_pbch_decode_reset(srsran_pbch_t* q); + +SRSRAN_API void srsran_pbch_mib_unpack(uint8_t* msg, srsran_cell_t* cell, uint32_t* sfn); + +SRSRAN_API void srsran_pbch_mib_pack(srsran_cell_t* cell, uint32_t sfn, uint8_t* msg); + +#endif // SRSRAN_PBCH_H diff --git a/lib/include/srsran/phy/phch/pcfich.h b/lib/include/srsran/phy/phch/pcfich.h new file mode 100644 index 000000000..066c16243 --- /dev/null +++ b/lib/include/srsran/phy/phch/pcfich.h @@ -0,0 +1,82 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +/****************************************************************************** + * File: pcfich.h + * + * Description: Physical control format indicator channel + * + * Reference: 3GPP TS 36.211 version 10.0.0 Release 10 Sec. 6.7 + *****************************************************************************/ + +#ifndef SRSRAN_PCFICH_H +#define SRSRAN_PCFICH_H + +#include "srsran/config.h" +#include "srsran/phy/ch_estimation/chest_dl.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/mimo/layermap.h" +#include "srsran/phy/mimo/precoding.h" +#include "srsran/phy/modem/demod_soft.h" +#include "srsran/phy/modem/mod.h" +#include "srsran/phy/phch/regs.h" +#include "srsran/phy/scrambling/scrambling.h" + +#define PCFICH_CFI_LEN 32 +#define PCFICH_RE PCFICH_CFI_LEN / 2 + +/* PCFICH object */ +typedef struct SRSRAN_API { + srsran_cell_t cell; + int nof_symbols; + + uint32_t nof_rx_antennas; + + /* handler to REGs resource mapper */ + srsran_regs_t* regs; + + /* buffers */ + cf_t ce[SRSRAN_MAX_PORTS][SRSRAN_MAX_PORTS][PCFICH_RE]; + cf_t symbols[SRSRAN_MAX_PORTS][PCFICH_RE]; + cf_t x[SRSRAN_MAX_PORTS][PCFICH_RE]; + cf_t d[PCFICH_RE]; + + // cfi table in floats + float cfi_table_float[3][PCFICH_CFI_LEN]; + + /* bit message */ + uint8_t data[PCFICH_CFI_LEN]; + + /* received soft bits */ + float data_f[PCFICH_CFI_LEN]; + + /* tx & rx objects */ + srsran_modem_table_t mod; + srsran_sequence_t seq[SRSRAN_NOF_SF_X_FRAME]; + +} srsran_pcfich_t; + +SRSRAN_API int srsran_pcfich_init(srsran_pcfich_t* q, uint32_t nof_rx_antennas); + +SRSRAN_API int srsran_pcfich_set_cell(srsran_pcfich_t* q, srsran_regs_t* regs, srsran_cell_t cell); + +SRSRAN_API void srsran_pcfich_free(srsran_pcfich_t* q); + +SRSRAN_API int srsran_pcfich_decode(srsran_pcfich_t* q, + srsran_dl_sf_cfg_t* sf, + srsran_chest_dl_res_t* channel, + cf_t* sf_symbols[SRSRAN_MAX_PORTS], + float* corr_result); + +SRSRAN_API int srsran_pcfich_encode(srsran_pcfich_t* q, srsran_dl_sf_cfg_t* sf, cf_t* sf_symbols[SRSRAN_MAX_PORTS]); + +#endif // SRSRAN_PCFICH_H diff --git a/lib/include/srsran/phy/phch/pdcch.h b/lib/include/srsran/phy/phch/pdcch.h new file mode 100644 index 000000000..281c2ba9f --- /dev/null +++ b/lib/include/srsran/phy/phch/pdcch.h @@ -0,0 +1,137 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +/****************************************************************************** + * File: pdcch.h + * + * Description: Physical downlink control channel. + * + * Reference: 3GPP TS 36.211 version 10.0.0 Release 10 Sec. 6.8 + *****************************************************************************/ + +#ifndef SRSRAN_PDCCH_H +#define SRSRAN_PDCCH_H + +#include "srsran/config.h" +#include "srsran/phy/ch_estimation/chest_dl.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/fec/convolutional/convcoder.h" +#include "srsran/phy/fec/convolutional/rm_conv.h" +#include "srsran/phy/fec/convolutional/viterbi.h" +#include "srsran/phy/fec/crc.h" +#include "srsran/phy/mimo/layermap.h" +#include "srsran/phy/mimo/precoding.h" +#include "srsran/phy/modem/demod_soft.h" +#include "srsran/phy/modem/mod.h" +#include "srsran/phy/phch/dci.h" +#include "srsran/phy/phch/regs.h" +#include "srsran/phy/scrambling/scrambling.h" + +typedef enum SRSRAN_API { SEARCH_UE, SEARCH_COMMON } srsran_pdcch_search_mode_t; + +/* PDCCH object */ +typedef struct SRSRAN_API { + srsran_cell_t cell; + uint32_t nof_regs[3]; + uint32_t nof_cce[3]; + uint32_t max_bits; + uint32_t nof_rx_antennas; + bool is_ue; + + srsran_regs_t* regs; + + /* buffers */ + cf_t* ce[SRSRAN_MAX_PORTS][SRSRAN_MAX_PORTS]; + cf_t* symbols[SRSRAN_MAX_PORTS]; + cf_t* x[SRSRAN_MAX_PORTS]; + cf_t* d; + uint8_t* e; + float rm_f[3 * (SRSRAN_DCI_MAX_BITS + 16)]; + float* llr; + + /* tx & rx objects */ + srsran_modem_table_t mod; + srsran_sequence_t seq[SRSRAN_NOF_SF_X_FRAME]; + srsran_viterbi_t decoder; + srsran_crc_t crc; + +} srsran_pdcch_t; + +SRSRAN_API int srsran_pdcch_init_ue(srsran_pdcch_t* q, uint32_t max_prb, uint32_t nof_rx_antennas); + +SRSRAN_API int srsran_pdcch_init_enb(srsran_pdcch_t* q, uint32_t max_prb); + +SRSRAN_API int srsran_pdcch_set_cell(srsran_pdcch_t* q, srsran_regs_t* regs, srsran_cell_t cell); + +SRSRAN_API void srsran_pdcch_set_regs(srsran_pdcch_t* q, srsran_regs_t* regs); + +SRSRAN_API void srsran_pdcch_free(srsran_pdcch_t* q); + +SRSRAN_API float srsran_pdcch_coderate(uint32_t nof_bits, uint32_t l); + +/* Encoding function */ +SRSRAN_API int srsran_pdcch_encode(srsran_pdcch_t* q, + srsran_dl_sf_cfg_t* sf, + srsran_dci_msg_t* msg, + cf_t* sf_symbols[SRSRAN_MAX_PORTS]); + +/* Decoding functions: Extract the LLRs and save them in the srsran_pdcch_t object */ + +SRSRAN_API int srsran_pdcch_extract_llr(srsran_pdcch_t* q, + srsran_dl_sf_cfg_t* sf, + srsran_chest_dl_res_t* channel, + cf_t* sf_symbols[SRSRAN_MAX_PORTS]); + +/* Decoding functions: Try to decode a DCI message after calling srsran_pdcch_extract_llr */ +SRSRAN_API int +srsran_pdcch_decode_msg(srsran_pdcch_t* q, srsran_dl_sf_cfg_t* sf, srsran_dci_cfg_t* dci_cfg, srsran_dci_msg_t* msg); + +SRSRAN_API int +srsran_pdcch_dci_decode(srsran_pdcch_t* q, float* e, uint8_t* data, uint32_t E, uint32_t nof_bits, uint16_t* crc); + +SRSRAN_API int +srsran_pdcch_dci_encode(srsran_pdcch_t* q, uint8_t* data, uint8_t* e, uint32_t nof_bits, uint32_t E, uint16_t rnti); + +SRSRAN_API void +srsran_pdcch_dci_encode_conv(srsran_pdcch_t* q, uint8_t* data, uint32_t nof_bits, uint8_t* coded_data, uint16_t rnti); + +/* Function for generation of UE-specific search space DCI locations */ +SRSRAN_API uint32_t srsran_pdcch_ue_locations(srsran_pdcch_t* q, + srsran_dl_sf_cfg_t* sf, + srsran_dci_location_t* locations, + uint32_t max_locations, + uint16_t rnti); + +SRSRAN_API uint32_t srsran_pdcch_ue_locations_ncce(uint32_t nof_cce, + srsran_dci_location_t* c, + uint32_t max_candidates, + uint32_t sf_idx, + uint16_t rnti); + +SRSRAN_API uint32_t srsran_pdcch_ue_locations_ncce_L(uint32_t nof_cce, + srsran_dci_location_t* c, + uint32_t max_candidates, + uint32_t sf_idx, + uint16_t rnti, + int L); + +/* Function for generation of common search space DCI locations */ +SRSRAN_API uint32_t srsran_pdcch_common_locations(srsran_pdcch_t* q, + srsran_dci_location_t* locations, + uint32_t max_locations, + uint32_t cfi); + +SRSRAN_API uint32_t srsran_pdcch_common_locations_ncce(uint32_t nof_cce, + srsran_dci_location_t* c, + uint32_t max_candidates); + +#endif // SRSRAN_PDCCH_H diff --git a/lib/include/srslte/phy/phch/pdcch_nr.h b/lib/include/srsran/phy/phch/pdcch_nr.h similarity index 59% rename from lib/include/srslte/phy/phch/pdcch_nr.h rename to lib/include/srsran/phy/phch/pdcch_nr.h index 2038a2f5e..a0b6e9a46 100644 --- a/lib/include/srslte/phy/phch/pdcch_nr.h +++ b/lib/include/srsran/phy/phch/pdcch_nr.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -18,19 +18,19 @@ * Reference: 3GPP TS 38.211 version 15.10.0 *****************************************************************************/ -#ifndef SRSLTE_PDCCH_NR_H -#define SRSLTE_PDCCH_NR_H +#ifndef SRSRAN_PDCCH_NR_H +#define SRSRAN_PDCCH_NR_H #include "dci_nr.h" -#include "srslte/phy/ch_estimation/dmrs_pdcch.h" -#include "srslte/phy/common/phy_common_nr.h" -#include "srslte/phy/fec/crc.h" -#include "srslte/phy/fec/polar/polar_code.h" -#include "srslte/phy/fec/polar/polar_decoder.h" -#include "srslte/phy/fec/polar/polar_encoder.h" -#include "srslte/phy/fec/polar/polar_rm.h" -#include "srslte/phy/modem/evm.h" -#include "srslte/phy/modem/modem_table.h" +#include "srsran/phy/ch_estimation/dmrs_pdcch.h" +#include "srsran/phy/common/phy_common_nr.h" +#include "srsran/phy/fec/crc.h" +#include "srsran/phy/fec/polar/polar_code.h" +#include "srsran/phy/fec/polar/polar_decoder.h" +#include "srsran/phy/fec/polar/polar_encoder.h" +#include "srsran/phy/fec/polar/polar_rm.h" +#include "srsran/phy/modem/evm.h" +#include "srsran/phy/modem/modem_table.h" /** * @brief PDCCH configuration initialization arguments @@ -39,48 +39,48 @@ typedef struct { bool disable_simd; bool measure_evm; bool measure_time; -} srslte_pdcch_nr_args_t; +} srsran_pdcch_nr_args_t; /** * @brief PDCCH Attributes and objects required to encode/decode NR PDCCH */ -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { bool is_tx; - srslte_polar_code_t code; - srslte_polar_encoder_t encoder; - srslte_polar_decoder_t decoder; - srslte_polar_rm_t rm; - srslte_carrier_nr_t carrier; - srslte_coreset_t coreset; - srslte_crc_t crc24c; + srsran_polar_code_t code; + srsran_polar_encoder_t encoder; + srsran_polar_decoder_t decoder; + srsran_polar_rm_t rm; + srsran_carrier_nr_t carrier; + srsran_coreset_t coreset; + srsran_crc_t crc24c; uint8_t* c; // Message bits with attached CRC uint8_t* d; // encoded bits uint8_t* f; // bits at the Rate matching output uint8_t* allocated; // Allocated polar bit buffer, encoder input, decoder output cf_t* symbols; - srslte_modem_table_t modem_table; - srslte_evm_buffer_t* evm_buffer; + srsran_modem_table_t modem_table; + srsran_evm_buffer_t* evm_buffer; bool meas_time_en; uint32_t meas_time_us; uint32_t K; uint32_t M; uint32_t E; -} srslte_pdcch_nr_t; +} srsran_pdcch_nr_t; /** * @brief NR PDCCH decoder result */ -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { float evm; bool crc; -} srslte_pdcch_nr_res_t; +} srsran_pdcch_nr_res_t; /** * @brief Function for generating NR PDCCH candidate locations n_cce for a given CORESET, search space, aggregation * level and slot. * - * @see srslte_pdcch_ue_locations_ncce - * @see srslte_pdcch_common_locations_ncce + * @see srsran_pdcch_ue_locations_ncce + * @see srsran_pdcch_common_locations_ncce * * @param coreset is the coreset configuration provided from higher layers * @param search_space is the Search Space configuration provided from higher layers @@ -89,20 +89,20 @@ typedef struct SRSLTE_API { * @param slot_idx Slot index within the radio frame * @param locations is the destination array with the possible candidate locations n_cce */ -int srslte_pdcch_nr_locations_coreset(const srslte_coreset_t* coreset, - const srslte_search_space_t* search_space, +int srsran_pdcch_nr_locations_coreset(const srsran_coreset_t* coreset, + const srsran_search_space_t* search_space, uint16_t rnti, uint32_t aggregation_level, uint32_t slot_idx, - uint32_t locations[SRSLTE_SEARCH_SPACE_MAX_NOF_CANDIDATES_NR]); + uint32_t locations[SRSRAN_SEARCH_SPACE_MAX_NOF_CANDIDATES_NR]); -SRSLTE_API int srslte_pdcch_nr_max_candidates_coreset(const srslte_coreset_t* coreset, uint32_t aggregation_level); +SRSRAN_API int srsran_pdcch_nr_max_candidates_coreset(const srsran_coreset_t* coreset, uint32_t aggregation_level); -SRSLTE_API int srslte_pdcch_nr_init_tx(srslte_pdcch_nr_t* q, const srslte_pdcch_nr_args_t* args); +SRSRAN_API int srsran_pdcch_nr_init_tx(srsran_pdcch_nr_t* q, const srsran_pdcch_nr_args_t* args); -SRSLTE_API int srslte_pdcch_nr_init_rx(srslte_pdcch_nr_t* q, const srslte_pdcch_nr_args_t* args); +SRSRAN_API int srsran_pdcch_nr_init_rx(srsran_pdcch_nr_t* q, const srsran_pdcch_nr_args_t* args); -SRSLTE_API void srslte_pdcch_nr_free(srslte_pdcch_nr_t* q); +SRSRAN_API void srsran_pdcch_nr_free(srsran_pdcch_nr_t* q); /** * @brief Sets carrier and CORESET configuration for a given PDCCH object @@ -110,12 +110,12 @@ SRSLTE_API void srslte_pdcch_nr_free(srslte_pdcch_nr_t* q); * @param[in,out] q PDCCH encoder/decoder object * @param[in] carrier New carrier configuration * @param[in] coreset New CORESET configuration - * @return SRSLTE_SUCCESS if the configurations are valid, otherwise it returns an SRSLTE_ERROR code + * @return SRSRAN_SUCCESS if the configurations are valid, otherwise it returns an SRSRAN_ERROR code */ -SRSLTE_API int -srslte_pdcch_nr_set_carrier(srslte_pdcch_nr_t* q, const srslte_carrier_nr_t* carrier, const srslte_coreset_t* coreset); +SRSRAN_API int +srsran_pdcch_nr_set_carrier(srsran_pdcch_nr_t* q, const srsran_carrier_nr_t* carrier, const srsran_coreset_t* coreset); -SRSLTE_API int srslte_pdcch_nr_encode(srslte_pdcch_nr_t* q, const srslte_dci_msg_nr_t* dci_msg, cf_t* slot_symbols); +SRSRAN_API int srsran_pdcch_nr_encode(srsran_pdcch_nr_t* q, const srsran_dci_msg_nr_t* dci_msg, cf_t* slot_symbols); /** * @brief Decodes a DCI @@ -126,13 +126,13 @@ SRSLTE_API int srslte_pdcch_nr_encode(srslte_pdcch_nr_t* q, const srslte_dci_msg * @param[in,out] dci_msg Provides with the DCI message location, RNTI, RNTI type and so on. Also, the message data * buffer * @param[out] res Provides the PDCCH result information - * @return SRSLTE_SUCCESS if the configurations are valid, otherwise it returns an SRSLTE_ERROR code + * @return SRSRAN_SUCCESS if the configurations are valid, otherwise it returns an SRSRAN_ERROR code */ -SRSLTE_API int srslte_pdcch_nr_decode(srslte_pdcch_nr_t* q, +SRSRAN_API int srsran_pdcch_nr_decode(srsran_pdcch_nr_t* q, cf_t* slot_symbols, - srslte_dmrs_pdcch_ce_t* ce, - srslte_dci_msg_nr_t* dci_msg, - srslte_pdcch_nr_res_t* res); + srsran_dmrs_pdcch_ce_t* ce, + srsran_dci_msg_nr_t* dci_msg, + srsran_pdcch_nr_res_t* res); /** * @brief Stringifies NR PDCCH decoding information from the latest encoded/decoded transmission @@ -143,9 +143,9 @@ SRSLTE_API int srslte_pdcch_nr_decode(srslte_pdcch_nr_t* q, * @param[out] str_len Maximum destination string length * @return The number of characters written in the string */ -SRSLTE_API uint32_t srslte_pdcch_nr_info(const srslte_pdcch_nr_t* q, - const srslte_pdcch_nr_res_t* res, +SRSRAN_API uint32_t srsran_pdcch_nr_info(const srsran_pdcch_nr_t* q, + const srsran_pdcch_nr_res_t* res, char* str, uint32_t str_len); -#endif // SRSLTE_PDCCH_NR_H +#endif // SRSRAN_PDCCH_NR_H diff --git a/lib/include/srsran/phy/phch/pdsch.h b/lib/include/srsran/phy/phch/pdsch.h new file mode 100644 index 000000000..614fc18f1 --- /dev/null +++ b/lib/include/srsran/phy/phch/pdsch.h @@ -0,0 +1,124 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +/****************************************************************************** + * File: pdsch.h + * + * Description: Physical downlink shared channel + * + * Reference: 3GPP TS 36.211 version 10.0.0 Release 10 Sec. 6.4 + *****************************************************************************/ + +#ifndef SRSRAN_PDSCH_H +#define SRSRAN_PDSCH_H + +#include "srsran/config.h" +#include "srsran/phy/ch_estimation/chest_dl.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/mimo/layermap.h" +#include "srsran/phy/mimo/precoding.h" +#include "srsran/phy/modem/demod_soft.h" +#include "srsran/phy/modem/evm.h" +#include "srsran/phy/modem/mod.h" +#include "srsran/phy/phch/dci.h" +#include "srsran/phy/phch/pdsch_cfg.h" +#include "srsran/phy/phch/regs.h" +#include "srsran/phy/phch/sch.h" +#include "srsran/phy/scrambling/scrambling.h" + +/* PDSCH object */ +typedef struct SRSRAN_API { + srsran_cell_t cell; + + uint32_t nof_rx_antennas; + uint32_t max_re; + + bool is_ue; + + bool llr_is_8bit; + + /* buffers */ + // void buffers are shared for tx and rx + cf_t* ce[SRSRAN_MAX_PORTS][SRSRAN_MAX_PORTS]; /* Channel estimation (Rx only) */ + cf_t* symbols[SRSRAN_MAX_PORTS]; /* PDSCH Encoded/Decoded Symbols */ + cf_t* x[SRSRAN_MAX_LAYERS]; /* Layer mapped */ + cf_t* d[SRSRAN_MAX_CODEWORDS]; /* Modulated/Demodulated codewords */ + void* e[SRSRAN_MAX_CODEWORDS]; + + float* csi[SRSRAN_MAX_CODEWORDS]; /* Channel Strengh Indicator */ + + /* tx & rx objects */ + srsran_modem_table_t mod[SRSRAN_MOD_NITEMS]; + + // EVM buffers, one for each codeword (avoid concurrency issue with coworker) + srsran_evm_buffer_t* evm_buffer[SRSRAN_MAX_CODEWORDS]; + float avg_evm; + + srsran_sch_t dl_sch; + + void* coworker_ptr; + +} srsran_pdsch_t; + +typedef struct { + uint8_t* payload; + bool crc; + float avg_iterations_block; + float evm; +} srsran_pdsch_res_t; + +SRSRAN_API int srsran_pdsch_init_ue(srsran_pdsch_t* q, uint32_t max_prb, uint32_t nof_rx_antennas); + +SRSRAN_API int srsran_pdsch_init_enb(srsran_pdsch_t* q, uint32_t max_prb); + +SRSRAN_API void srsran_pdsch_free(srsran_pdsch_t* q); + +/* These functions modify the state of the object and may take some time */ +SRSRAN_API int srsran_pdsch_enable_coworker(srsran_pdsch_t* q); + +SRSRAN_API int srsran_pdsch_set_cell(srsran_pdsch_t* q, srsran_cell_t cell); + +/* These functions do not modify the state and run in real-time */ +SRSRAN_API int srsran_pdsch_encode(srsran_pdsch_t* q, + srsran_dl_sf_cfg_t* sf, + srsran_pdsch_cfg_t* cfg, + uint8_t* data[SRSRAN_MAX_CODEWORDS], + cf_t* sf_symbols[SRSRAN_MAX_PORTS]); + +SRSRAN_API int srsran_pdsch_decode(srsran_pdsch_t* q, + srsran_dl_sf_cfg_t* sf, + srsran_pdsch_cfg_t* cfg, + srsran_chest_dl_res_t* channel, + cf_t* sf_symbols[SRSRAN_MAX_PORTS], + srsran_pdsch_res_t data[SRSRAN_MAX_CODEWORDS]); + +SRSRAN_API int srsran_pdsch_select_pmi(srsran_pdsch_t* q, + srsran_chest_dl_res_t* channel, + uint32_t nof_layers, + uint32_t* best_pmi, + float sinr[SRSRAN_MAX_CODEBOOKS]); + +SRSRAN_API int srsran_pdsch_compute_cn(srsran_pdsch_t* q, srsran_chest_dl_res_t* channel, float* cn); + +SRSRAN_API uint32_t srsran_pdsch_grant_rx_info(srsran_pdsch_grant_t* grant, + srsran_pdsch_res_t res[SRSRAN_MAX_CODEWORDS], + char* str, + uint32_t str_len); + +SRSRAN_API uint32_t srsran_pdsch_rx_info(srsran_pdsch_cfg_t* cfg, + srsran_pdsch_res_t res[SRSRAN_MAX_CODEWORDS], + char* str, + uint32_t str_len); + +SRSRAN_API uint32_t srsran_pdsch_tx_info(srsran_pdsch_cfg_t* cfg, char* str, uint32_t str_len); + +#endif // SRSRAN_PDSCH_H diff --git a/lib/include/srslte/phy/phch/pdsch_cfg.h b/lib/include/srsran/phy/phch/pdsch_cfg.h similarity index 61% rename from lib/include/srslte/phy/phch/pdsch_cfg.h rename to lib/include/srsran/phy/phch/pdsch_cfg.h index 42650147b..e92853e6a 100644 --- a/lib/include/srslte/phy/phch/pdsch_cfg.h +++ b/lib/include/srsran/phy/phch/pdsch_cfg.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -18,34 +18,32 @@ * Reference: 3GPP TS 36.211 version 10.0.0 Release 10 Sec. 6.4 *****************************************************************************/ -#ifndef SRSLTE_PDSCH_CFG_H -#define SRSLTE_PDSCH_CFG_H +#ifndef SRSRAN_PDSCH_CFG_H +#define SRSRAN_PDSCH_CFG_H -#include "srslte/phy/fec/cbsegm.h" -#include "srslte/phy/fec/softbuffer.h" -#include "srslte/phy/phch/ra.h" +#include "srsran/phy/fec/cbsegm.h" +#include "srsran/phy/fec/softbuffer.h" +#include "srsran/phy/phch/ra.h" -typedef struct SRSLTE_API { - - srslte_tx_scheme_t tx_scheme; +typedef struct SRSRAN_API { + srsran_tx_scheme_t tx_scheme; uint32_t pmi; - bool prb_idx[2][SRSLTE_MAX_PRB]; + bool prb_idx[2][SRSRAN_MAX_PRB]; uint32_t nof_prb; uint32_t nof_re; uint32_t nof_symb_slot[2]; - srslte_ra_tb_t tb[SRSLTE_MAX_CODEWORDS]; - int last_tbs[SRSLTE_MAX_CODEWORDS]; + srsran_ra_tb_t tb[SRSRAN_MAX_CODEWORDS]; + int last_tbs[SRSRAN_MAX_CODEWORDS]; uint32_t nof_tb; uint32_t nof_layers; -} srslte_pdsch_grant_t; - -typedef struct SRSLTE_API { +} srsran_pdsch_grant_t; - srslte_pdsch_grant_t grant; +typedef struct SRSRAN_API { + srsran_pdsch_grant_t grant; uint16_t rnti; uint32_t max_nof_iterations; - srslte_mimo_decoder_t decoder_type; + srsran_mimo_decoder_t decoder_type; float p_a; uint32_t p_b; float rs_power; @@ -54,13 +52,13 @@ typedef struct SRSLTE_API { bool use_tbs_index_alt; union { - srslte_softbuffer_tx_t* tx[SRSLTE_MAX_CODEWORDS]; - srslte_softbuffer_rx_t* rx[SRSLTE_MAX_CODEWORDS]; + srsran_softbuffer_tx_t* tx[SRSRAN_MAX_CODEWORDS]; + srsran_softbuffer_rx_t* rx[SRSRAN_MAX_CODEWORDS]; } softbuffers; bool meas_evm_en; bool meas_time_en; uint32_t meas_time_value; -} srslte_pdsch_cfg_t; +} srsran_pdsch_cfg_t; -#endif // SRSLTE_PDSCH_CFG_H +#endif // SRSRAN_PDSCH_CFG_H diff --git a/lib/include/srsran/phy/phch/pdsch_nr.h b/lib/include/srsran/phy/phch/pdsch_nr.h new file mode 100644 index 000000000..0cd163afc --- /dev/null +++ b/lib/include/srsran/phy/phch/pdsch_nr.h @@ -0,0 +1,103 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +/****************************************************************************** + * File: pdsch_nr.h + * + * Description: Physical downlink shared channel for NR + * + * Reference: 3GPP TS 38.211 V15.8.0 Sec. 7.3.1 + *****************************************************************************/ + +#ifndef SRSRAN_PDSCH_NR_H +#define SRSRAN_PDSCH_NR_H + +#include "srsran/config.h" +#include "srsran/phy/ch_estimation/dmrs_sch.h" +#include "srsran/phy/modem/evm.h" +#include "srsran/phy/modem/modem_table.h" +#include "srsran/phy/phch/phch_cfg_nr.h" +#include "srsran/phy/phch/regs.h" +#include "srsran/phy/phch/sch_nr.h" +#include "srsran/phy/scrambling/scrambling.h" + +/** + * @brief PDSCH encoder and decoder initialization arguments + */ +typedef struct SRSRAN_API { + srsran_sch_nr_args_t sch; + bool measure_evm; + bool measure_time; +} srsran_pdsch_nr_args_t; + +/** + * @brief PDSCH NR object + */ +typedef struct SRSRAN_API { + uint32_t max_prb; ///< Maximum number of allocated prb + uint32_t max_layers; ///< Maximum number of allocated layers + uint32_t max_cw; ///< Maximum number of allocated code words + srsran_carrier_nr_t carrier; ///< NR carrier configuration + srsran_sch_nr_t sch; ///< SCH Encoder/Decoder Object + uint8_t* b[SRSRAN_MAX_CODEWORDS]; ///< SCH Encoded and scrambled data + cf_t* d[SRSRAN_MAX_CODEWORDS]; ///< PDSCH modulated bits + cf_t* x[SRSRAN_MAX_LAYERS_NR]; ///< PDSCH modulated bits + srsran_modem_table_t modem_tables[SRSRAN_MOD_NITEMS]; ///< Modulator tables + srsran_evm_buffer_t* evm_buffer; + bool meas_time_en; + uint32_t meas_time_us; +} srsran_pdsch_nr_t; + +/** + * + */ +typedef struct { + uint8_t* payload; + bool crc; + float evm; +} srsran_pdsch_res_nr_t; + +SRSRAN_API int srsran_pdsch_nr_init_enb(srsran_pdsch_nr_t* q, const srsran_pdsch_nr_args_t* args); + +SRSRAN_API int srsran_pdsch_nr_init_ue(srsran_pdsch_nr_t* q, const srsran_pdsch_nr_args_t* args); + +SRSRAN_API void srsran_pdsch_nr_free(srsran_pdsch_nr_t* q); + +SRSRAN_API int srsran_pdsch_nr_set_carrier(srsran_pdsch_nr_t* q, const srsran_carrier_nr_t* carrier); + +SRSRAN_API int srsran_pdsch_nr_encode(srsran_pdsch_nr_t* q, + const srsran_sch_cfg_nr_t* cfg, + const srsran_sch_grant_nr_t* grant, + uint8_t* data[SRSRAN_MAX_TB], + cf_t* sf_symbols[SRSRAN_MAX_PORTS]); + +SRSRAN_API int srsran_pdsch_nr_decode(srsran_pdsch_nr_t* q, + const srsran_sch_cfg_nr_t* cfg, + const srsran_sch_grant_nr_t* grant, + srsran_chest_dl_res_t* channel, + cf_t* sf_symbols[SRSRAN_MAX_PORTS], + srsran_pdsch_res_nr_t data[SRSRAN_MAX_TB]); + +SRSRAN_API uint32_t srsran_pdsch_nr_rx_info(const srsran_pdsch_nr_t* q, + const srsran_sch_cfg_nr_t* cfg, + const srsran_sch_grant_nr_t* grant, + const srsran_pdsch_res_nr_t* res, + char* str, + uint32_t str_len); + +SRSRAN_API uint32_t srsran_pdsch_nr_tx_info(const srsran_pdsch_nr_t* q, + const srsran_sch_cfg_nr_t* cfg, + const srsran_sch_grant_nr_t* grant, + char* str, + uint32_t str_len); + +#endif // SRSRAN_PDSCH_NR_H diff --git a/lib/include/srslte/phy/phch/phch_cfg_nr.h b/lib/include/srsran/phy/phch/phch_cfg_nr.h similarity index 70% rename from lib/include/srslte/phy/phch/phch_cfg_nr.h rename to lib/include/srsran/phy/phch/phch_cfg_nr.h index b6fc8a46e..b464907d9 100644 --- a/lib/include/srslte/phy/phch/phch_cfg_nr.h +++ b/lib/include/srsran/phy/phch/phch_cfg_nr.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -18,46 +18,46 @@ * Reference: *****************************************************************************/ -#ifndef SRSLTE_PHCH_CFG_NR_H -#define SRSLTE_PHCH_CFG_NR_H +#ifndef SRSRAN_PHCH_CFG_NR_H +#define SRSRAN_PHCH_CFG_NR_H -#include "srslte/phy/common/phy_common_nr.h" -#include "srslte/phy/phch/sch_cfg_nr.h" -#include "srslte/phy/phch/uci_cfg_nr.h" +#include "srsran/phy/common/phy_common_nr.h" +#include "srsran/phy/phch/sch_cfg_nr.h" +#include "srsran/phy/phch/uci_cfg_nr.h" /** * @brief PDSCH DMRS type */ typedef enum { - srslte_dmrs_sch_type_1 = 0, // 1 pilot every 2 sub-carriers (default) - srslte_dmrs_sch_type_2 // 2 consecutive pilots every 6 sub-carriers -} srslte_dmrs_sch_type_t; + srsran_dmrs_sch_type_1 = 0, // 1 pilot every 2 sub-carriers (default) + srsran_dmrs_sch_type_2 // 2 consecutive pilots every 6 sub-carriers +} srsran_dmrs_sch_type_t; /** * @brief PDSCH DMRS length in symbols */ typedef enum { - srslte_dmrs_sch_len_1 = 0, // single, 1 symbol long (default) - srslte_dmrs_sch_len_2 // double, 2 symbol long -} srslte_dmrs_sch_len_t; + srsran_dmrs_sch_len_1 = 0, // single, 1 symbol long (default) + srsran_dmrs_sch_len_2 // double, 2 symbol long +} srsran_dmrs_sch_len_t; /** * @brief Determines whether the first pilot goes into symbol index 2 or 3 */ typedef enum { - srslte_dmrs_sch_typeA_pos_2 = 0, // Start in slot symbol index 2 (default) - srslte_dmrs_sch_typeA_pos_3 // Start in slot symbol index 3 -} srslte_dmrs_sch_typeA_pos_t; + srsran_dmrs_sch_typeA_pos_2 = 0, // Start in slot symbol index 2 (default) + srsran_dmrs_sch_typeA_pos_3 // Start in slot symbol index 3 +} srsran_dmrs_sch_typeA_pos_t; /** * @brief Determines additional symbols if possible to be added */ typedef enum { - srslte_dmrs_sch_add_pos_2 = 0, - srslte_dmrs_sch_add_pos_0, - srslte_dmrs_sch_add_pos_1, - srslte_dmrs_sch_add_pos_3 -} srslte_dmrs_sch_add_pos_t; + srsran_dmrs_sch_add_pos_2 = 0, + srsran_dmrs_sch_add_pos_0, + srsran_dmrs_sch_add_pos_1, + srsran_dmrs_sch_add_pos_3 +} srsran_dmrs_sch_add_pos_t; /** * @brief Provides PDSCH DMRS configuration @@ -65,58 +65,58 @@ typedef enum { */ typedef struct { /// Parameters provided by IE DMRS-DownlinkConfig - srslte_dmrs_sch_type_t type; - srslte_dmrs_sch_add_pos_t additional_pos; - srslte_dmrs_sch_len_t length; + srsran_dmrs_sch_type_t type; + srsran_dmrs_sch_add_pos_t additional_pos; + srsran_dmrs_sch_len_t length; bool scrambling_id0_present; uint32_t scrambling_id0; bool scrambling_id1_present; uint32_t scrambling_id1; /// Parameters provided by ServingCellConfigCommon - srslte_dmrs_sch_typeA_pos_t typeA_pos; + srsran_dmrs_sch_typeA_pos_t typeA_pos; bool lte_CRS_to_match_around; /// Parameters provided by FeatureSetDownlink-v1540 bool additional_DMRS_DL_Alt; -} srslte_dmrs_sch_cfg_t; +} srsran_dmrs_sch_cfg_t; /** * @brief Common flatten PDSCH and PUSCH time domain allocation parameters * @remark Described in TS 38.331 V15.10.0 Section PDSCH-TimeDomainResourceAllocationList * @remark Described in TS 38.331 V15.10.0 Section PUSCH-TimeDomainResourceAllocationList */ -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { /// For PDSCH Slot offset between DCI and its scheduled PDSCH /// For PUSCH parameter K2 uint32_t k; /// SCH mapping type - srslte_sch_mapping_type_t mapping_type; + srsran_sch_mapping_type_t mapping_type; /// An index giving valid combinations of start symbol and length (jointly encoded) as start and length indicator /// (SLIV). The network configures the field so that the allocation does not cross the slot boundary uint32_t sliv; -} srslte_sch_time_ra_t; +} srsran_sch_time_ra_t; /** * @brief PDSCH grant information provided by the Downlink Control Information (DCI) */ -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { /// UE identifier uint16_t rnti; - srslte_rnti_type_t rnti_type; + srsran_rnti_type_t rnti_type; /// Time domain resources uint32_t k; // k0 for PDSCH, k2 for PUSCH uint32_t S; uint32_t L; - srslte_sch_mapping_type_t mapping; + srsran_sch_mapping_type_t mapping; /// Frequency domain resources - bool prb_idx[SRSLTE_MAX_PRB_NR]; + bool prb_idx[SRSRAN_MAX_PRB_NR]; uint32_t nof_prb; /// Number of DMRS groups without data @@ -134,15 +134,15 @@ typedef struct SRSLTE_API { bool n_scid; /// DCI information - srslte_dci_format_nr_t dci_format; - srslte_search_space_type_t dci_search_space; + srsran_dci_format_nr_t dci_format; + srsran_search_space_type_t dci_search_space; /// Transport block uint32_t tb_scaling_field; /// .... - srslte_sch_tb_t tb[SRSLTE_MAX_TB]; -} srslte_sch_grant_nr_t; + srsran_sch_tb_t tb[SRSRAN_MAX_TB]; +} srsran_sch_grant_nr_t; /** * @brief Beta offset configuration provided from upper layers @@ -156,25 +156,25 @@ typedef struct { uint32_t csi1_index2; ///< Use for more than 11 CSI bits. Set to 13 if absent. uint32_t csi2_index1; ///< Use for up to 11 CSI bits. Set to 13 if absent. uint32_t csi2_index2; ///< Use for more than 11 CSI bits. Set to 13 if absent. -} srslte_beta_offsets_t; +} srsran_beta_offsets_t; /** * @brief flatten SCH configuration parameters provided by higher layers * @remark Described in TS 38.331 V15.10.0 Section PDSCH-Config * @remark Described in TS 38.331 V15.10.0 Section PUSCH-Config */ -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { // Serving cell parameters uint32_t scs_cfg; // Subcarrier spacing configuration - srslte_dmrs_sch_typeA_pos_t typeA_pos; + srsran_dmrs_sch_typeA_pos_t typeA_pos; bool scrambling_id_present; uint32_t scambling_id; // Identifier used to initialize data scrambling (0-1023) struct { - srslte_dmrs_sch_type_t type; - srslte_dmrs_sch_add_pos_t additional_pos; - srslte_dmrs_sch_len_t length; + srsran_dmrs_sch_type_t type; + srsran_dmrs_sch_add_pos_t additional_pos; + srsran_dmrs_sch_len_t length; bool scrambling_id0_present; uint32_t scrambling_id0; bool scrambling_id1_present; @@ -183,9 +183,9 @@ typedef struct SRSLTE_API { } dmrs_typeA; struct { - srslte_dmrs_sch_type_t type; - srslte_dmrs_sch_add_pos_t additional_pos; - srslte_dmrs_sch_len_t length; + srsran_dmrs_sch_type_t type; + srsran_dmrs_sch_add_pos_t additional_pos; + srsran_dmrs_sch_len_t length; bool scrambling_id0_present; uint32_t scrambling_id0; bool scrambling_id1_present; @@ -193,41 +193,41 @@ typedef struct SRSLTE_API { bool present; } dmrs_typeB; - srslte_sch_time_ra_t common_time_ra[SRSLTE_MAX_NOF_DL_ALLOCATION]; + srsran_sch_time_ra_t common_time_ra[SRSRAN_MAX_NOF_DL_ALLOCATION]; uint32_t nof_common_time_ra; - srslte_sch_time_ra_t dedicated_time_ra[SRSLTE_MAX_NOF_DL_ALLOCATION]; + srsran_sch_time_ra_t dedicated_time_ra[SRSRAN_MAX_NOF_DL_ALLOCATION]; uint32_t nof_dedicated_time_ra; bool rbg_size_cfg_1; ///< RBG size configuration (1 or 2) - srslte_sch_cfg_t sch_cfg; ///< Common shared channel parameters + srsran_sch_cfg_t sch_cfg; ///< Common shared channel parameters /// PUSCH only - srslte_beta_offsets_t beta_offsets; /// Semi-static only. + srsran_beta_offsets_t beta_offsets; /// Semi-static only. float scaling; /// Indicates a scaling factor to limit the number of resource elements assigned to UCI on PUSCH. -} srslte_sch_hl_cfg_nr_t; +} srsran_sch_hl_cfg_nr_t; /** * @brief Common NR-SCH (PDSCH and PUSCH for NR) configuration */ -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { bool scrambling_id_present; uint32_t scambling_id; // Identifier used to initialize data scrambling (0-1023) - srslte_dmrs_sch_cfg_t dmrs; - srslte_sch_grant_nr_t grant; + srsran_dmrs_sch_cfg_t dmrs; + srsran_sch_grant_nr_t grant; - srslte_sch_cfg_t sch_cfg; ///< Common shared channel parameters + srsran_sch_cfg_t sch_cfg; ///< Common shared channel parameters /// PUSCH only parameters - srslte_uci_cfg_nr_t uci; ///< Uplink Control Information configuration + srsran_uci_cfg_nr_t uci; ///< Uplink Control Information configuration bool enable_transform_precoder; float beta_harq_ack_offset; float beta_csi_part1_offset; float beta_csi_part2_offset; float scaling; bool freq_hopping_enabled; -} srslte_sch_cfg_nr_t; +} srsran_sch_cfg_nr_t; -#endif // SRSLTE_PHCH_CFG_NR_H +#endif // SRSRAN_PHCH_CFG_NR_H diff --git a/lib/include/srsran/phy/phch/phich.h b/lib/include/srsran/phy/phch/phich.h new file mode 100644 index 000000000..0f7d5c83c --- /dev/null +++ b/lib/include/srsran/phy/phch/phich.h @@ -0,0 +1,118 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +/****************************************************************************** + * File: phich.h + * + * Description: Physical Hybrid ARQ indicator channel. + * + * Reference: 3GPP TS 36.211 version 10.0.0 Release 10 Sec. 6.9 + *****************************************************************************/ + +#ifndef SRSRAN_PHICH_H +#define SRSRAN_PHICH_H + +#include "regs.h" +#include "srsran/config.h" +#include "srsran/phy/ch_estimation/chest_dl.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/mimo/layermap.h" +#include "srsran/phy/mimo/precoding.h" +#include "srsran/phy/modem/demod_soft.h" +#include "srsran/phy/modem/mod.h" +#include "srsran/phy/scrambling/scrambling.h" + +#define SRSRAN_PHICH_NORM_NSEQUENCES 8 +#define SRSRAN_PHICH_EXT_NSEQUENCES 4 +#define SRSRAN_PHICH_NBITS 3 + +#define SRSRAN_PHICH_NORM_MSYMB SRSRAN_PHICH_NBITS * 4 +#define SRSRAN_PHICH_EXT_MSYMB SRSRAN_PHICH_NBITS * 2 +#define SRSRAN_PHICH_MAX_NSYMB SRSRAN_PHICH_NORM_MSYMB +#define SRSRAN_PHICH_NORM_C 1 +#define SRSRAN_PHICH_EXT_C 2 +#define SRSRAN_PHICH_NORM_NSF 4 +#define SRSRAN_PHICH_EXT_NSF 2 + +/* phich object */ +typedef struct SRSRAN_API { + srsran_cell_t cell; + + uint32_t nof_rx_antennas; + + /* handler to REGs resource mapper */ + srsran_regs_t* regs; + + /* buffers */ + cf_t ce[SRSRAN_MAX_PORTS][SRSRAN_MAX_PORTS][SRSRAN_PHICH_MAX_NSYMB]; + cf_t sf_symbols[SRSRAN_MAX_PORTS][SRSRAN_PHICH_MAX_NSYMB]; + cf_t x[SRSRAN_MAX_PORTS][SRSRAN_PHICH_MAX_NSYMB]; + cf_t d[SRSRAN_PHICH_MAX_NSYMB]; + cf_t d0[SRSRAN_PHICH_MAX_NSYMB]; + cf_t z[SRSRAN_PHICH_NBITS]; + + /* bit message */ + uint8_t data[SRSRAN_PHICH_NBITS]; + float data_rx[SRSRAN_PHICH_NBITS]; + + /* tx & rx objects */ + srsran_modem_table_t mod; + srsran_sequence_t seq[SRSRAN_NOF_SF_X_FRAME]; + +} srsran_phich_t; + +typedef struct SRSRAN_API { + uint32_t ngroup; + uint32_t nseq; +} srsran_phich_resource_t; + +typedef struct SRSRAN_API { + uint32_t n_prb_lowest; + uint32_t n_dmrs; + uint32_t I_phich; +} srsran_phich_grant_t; + +typedef struct SRSRAN_API { + bool ack_value; + float distance; +} srsran_phich_res_t; + +SRSRAN_API int srsran_phich_init(srsran_phich_t* q, uint32_t nof_rx_antennas); + +SRSRAN_API void srsran_phich_free(srsran_phich_t* q); + +SRSRAN_API int srsran_phich_set_cell(srsran_phich_t* q, srsran_regs_t* regs, srsran_cell_t cell); + +SRSRAN_API void srsran_phich_set_regs(srsran_phich_t* q, srsran_regs_t* regs); + +SRSRAN_API void srsran_phich_calc(srsran_phich_t* q, srsran_phich_grant_t* grant, srsran_phich_resource_t* n_phich); + +SRSRAN_API int srsran_phich_decode(srsran_phich_t* q, + srsran_dl_sf_cfg_t* sf, + srsran_chest_dl_res_t* channel, + srsran_phich_resource_t n_phich, + cf_t* sf_symbols[SRSRAN_MAX_PORTS], + srsran_phich_res_t* result); + +SRSRAN_API int srsran_phich_encode(srsran_phich_t* q, + srsran_dl_sf_cfg_t* sf, + srsran_phich_resource_t n_phich, + uint8_t ack, + cf_t* sf_symbols[SRSRAN_MAX_PORTS]); + +SRSRAN_API void srsran_phich_reset(srsran_phich_t* q, cf_t* slot_symbols[SRSRAN_MAX_PORTS]); + +SRSRAN_API uint32_t srsran_phich_ngroups(srsran_phich_t* q); + +SRSRAN_API uint32_t srsran_phich_nsf(srsran_phich_t* q); + +#endif // SRSRAN_PHICH_H diff --git a/lib/include/srsran/phy/phch/pmch.h b/lib/include/srsran/phy/phch/pmch.h new file mode 100644 index 000000000..804902b6f --- /dev/null +++ b/lib/include/srsran/phy/phch/pmch.h @@ -0,0 +1,97 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +/****************************************************************************** + * File: pmch.h + * + * Description: Physical multicast channel + * + * Reference: 3GPP TS 36.211 version 10.0.0 Release 10 Sec. 6.5 + *****************************************************************************/ + +#ifndef SRSRAN_PMCH_H +#define SRSRAN_PMCH_H + +#include "srsran/config.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/common/sequence.h" +#include "srsran/phy/mimo/layermap.h" +#include "srsran/phy/mimo/precoding.h" +#include "srsran/phy/modem/demod_soft.h" +#include "srsran/phy/modem/mod.h" +#include "srsran/phy/phch/dci.h" +#include "srsran/phy/phch/pdsch.h" +#include "srsran/phy/phch/ra_dl.h" +#include "srsran/phy/phch/regs.h" +#include "srsran/phy/phch/sch.h" +#include "srsran/phy/scrambling/scrambling.h" +typedef struct { + srsran_sequence_t seq[SRSRAN_NOF_SF_X_FRAME]; +} srsran_pmch_seq_t; + +typedef struct SRSRAN_API { + srsran_pdsch_cfg_t pdsch_cfg; + uint16_t area_id; +} srsran_pmch_cfg_t; + +/* PMCH object */ +typedef struct SRSRAN_API { + srsran_cell_t cell; + + uint32_t nof_rx_antennas; + + uint32_t max_re; + + /* buffers */ + // void buffers are shared for tx and rx + cf_t* ce[SRSRAN_MAX_PORTS][SRSRAN_MAX_PORTS]; + cf_t* symbols[SRSRAN_MAX_PORTS]; + cf_t* x[SRSRAN_MAX_PORTS]; + cf_t* d; + void* e; + + /* tx & rx objects */ + srsran_modem_table_t mod[4]; + + // This is to generate the scrambling seq for multiple MBSFN Area IDs + srsran_pmch_seq_t** seqs; + + srsran_sch_t dl_sch; + +} srsran_pmch_t; + +SRSRAN_API int srsran_pmch_init(srsran_pmch_t* q, uint32_t max_prb, uint32_t nof_rx_antennas); + +SRSRAN_API void srsran_pmch_free(srsran_pmch_t* q); + +SRSRAN_API int srsran_pmch_set_cell(srsran_pmch_t* q, srsran_cell_t cell); + +SRSRAN_API int srsran_pmch_set_area_id(srsran_pmch_t* q, uint16_t area_id); + +SRSRAN_API void srsran_pmch_free_area_id(srsran_pmch_t* q, uint16_t area_id); + +SRSRAN_API void srsran_configure_pmch(srsran_pmch_cfg_t* pmch_cfg, srsran_cell_t* cell, srsran_mbsfn_cfg_t* mbsfn_cfg); + +SRSRAN_API int srsran_pmch_encode(srsran_pmch_t* q, + srsran_dl_sf_cfg_t* sf, + srsran_pmch_cfg_t* cfg, + uint8_t* data, + cf_t* sf_symbols[SRSRAN_MAX_PORTS]); + +SRSRAN_API int srsran_pmch_decode(srsran_pmch_t* q, + srsran_dl_sf_cfg_t* sf, + srsran_pmch_cfg_t* cfg, + srsran_chest_dl_res_t* channel, + cf_t* sf_symbols[SRSRAN_MAX_PORTS], + srsran_pdsch_res_t* data); + +#endif // SRSRAN_PMCH_H diff --git a/lib/include/srslte/phy/phch/prach.h b/lib/include/srsran/phy/phch/prach.h similarity index 69% rename from lib/include/srslte/phy/phch/prach.h rename to lib/include/srsran/phy/phch/prach.h index 2e83db3d0..a0755f835 100644 --- a/lib/include/srslte/phy/phch/prach.h +++ b/lib/include/srsran/phy/phch/prach.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -18,24 +18,24 @@ * Reference: 3GPP TS 36.211 version 10.0.0 Release 10 Sec. 5.7 *****************************************************************************/ -#ifndef SRSLTE_PRACH_H -#define SRSLTE_PRACH_H +#ifndef SRSRAN_PRACH_H +#define SRSRAN_PRACH_H -#include "srslte/config.h" -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/dft/dft.h" +#include "srsran/config.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/dft/dft.h" #include #include #include #include -#define SRSLTE_PRACH_MAX_LEN (2 * 24576 + 21024) // Maximum Tcp + Tseq +#define SRSRAN_PRACH_MAX_LEN (2 * 24576 + 21024) // Maximum Tcp + Tseq // Long PRACH ZC sequence sequence length -#define SRSLTE_PRACH_N_ZC_LONG 839 +#define SRSRAN_PRACH_N_ZC_LONG 839 // Short PRACH ZC sequence sequence length -#define SRSLTE_PRACH_N_ZC_SHORT 139 +#define SRSRAN_PRACH_N_ZC_SHORT 139 /** Generation and detection of RACH signals for uplink. * Currently only supports preamble formats 0-3. @@ -46,10 +46,10 @@ typedef struct { int idx; float factor; - cf_t phase_array[2 * SRSLTE_PRACH_N_ZC_LONG]; -} srslte_prach_cancellation_t; + cf_t phase_array[2 * SRSRAN_PRACH_N_ZC_LONG]; +} srsran_prach_cancellation_t; -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { // Parameters from higher layers (extracted from SIB2) bool is_nr; uint32_t config_idx; @@ -71,8 +71,8 @@ typedef struct SRSLTE_API { uint32_t N_cp; // Cyclic prefix length // Generated tables - cf_t seqs[64][SRSLTE_PRACH_N_ZC_LONG]; // Our set of 64 preamble sequences - cf_t dft_seqs[64][SRSLTE_PRACH_N_ZC_LONG]; // DFT-precoded seqs + cf_t seqs[64][SRSRAN_PRACH_N_ZC_LONG]; // Our set of 64 preamble sequences + cf_t dft_seqs[64][SRSRAN_PRACH_N_ZC_LONG]; // DFT-precoded seqs uint64_t dft_gen_bitmap; // Bitmap where each bit Indicates if the dft has been generated for sequence i. uint32_t root_seqs_idx[64]; // Indices of root seqs in seqs table uint32_t N_roots; // Number of root sequences used in this configuration @@ -85,12 +85,12 @@ typedef struct SRSLTE_API { float* corr; // PRACH IFFT - srslte_dft_plan_t fft; - srslte_dft_plan_t ifft; + srsran_dft_plan_t fft; + srsran_dft_plan_t ifft; // ZC-sequence FFT and IFFT - srslte_dft_plan_t zc_fft; - srslte_dft_plan_t zc_ifft; + srsran_dft_plan_t zc_fft; + srsran_dft_plan_t zc_ifft; cf_t* signal_fft; float detect_factor; @@ -101,25 +101,25 @@ typedef struct SRSLTE_API { uint32_t num_ra_preambles; bool successive_cancellation; bool freq_domain_offset_calc; - srslte_tdd_config_t tdd_config; + srsran_tdd_config_t tdd_config; uint32_t current_prach_idx; cf_t* cross; cf_t* corr_freq; - srslte_prach_cancellation_t prach_cancel; + srsran_prach_cancellation_t prach_cancel; cf_t sub[839 * 2]; float phase[839]; -} srslte_prach_t; +} srsran_prach_t; -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { int nof_sf; uint32_t sf[5]; -} srslte_prach_sf_config_t; +} srsran_prach_sf_config_t; -typedef enum SRSLTE_API { - SRSLTE_PRACH_SFN_EVEN = 0, - SRSLTE_PRACH_SFN_ANY, -} srslte_prach_sfn_t; +typedef enum SRSRAN_API { + SRSRAN_PRACH_SFN_EVEN = 0, + SRSRAN_PRACH_SFN_ANY, +} srsran_prach_sfn_t; typedef struct { bool is_nr; // Set to true if NR @@ -129,64 +129,64 @@ typedef struct { uint32_t freq_offset; uint32_t num_ra_preambles; bool hs_flag; - srslte_tdd_config_t tdd_config; + srsran_tdd_config_t tdd_config; bool enable_successive_cancellation; bool enable_freq_domain_offset_calc; -} srslte_prach_cfg_t; +} srsran_prach_cfg_t; -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { uint32_t f; uint32_t t0; uint32_t t1; uint32_t t2; -} srslte_prach_tdd_loc_t; +} srsran_prach_tdd_loc_t; -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { uint32_t nof_elems; - srslte_prach_tdd_loc_t elems[6]; -} srslte_prach_tdd_loc_table_t; + srsran_prach_tdd_loc_t elems[6]; +} srsran_prach_tdd_loc_table_t; -SRSLTE_API uint32_t srslte_prach_get_preamble_format(uint32_t config_idx); +SRSRAN_API uint32_t srsran_prach_get_preamble_format(uint32_t config_idx); -SRSLTE_API srslte_prach_sfn_t srslte_prach_get_sfn(uint32_t config_idx); +SRSRAN_API srsran_prach_sfn_t srsran_prach_get_sfn(uint32_t config_idx); -SRSLTE_API bool srslte_prach_tti_opportunity(srslte_prach_t* p, uint32_t current_tti, int allowed_subframe); +SRSRAN_API bool srsran_prach_tti_opportunity(srsran_prach_t* p, uint32_t current_tti, int allowed_subframe); -SRSLTE_API bool -srslte_prach_tti_opportunity_config_fdd(uint32_t config_idx, uint32_t current_tti, int allowed_subframe); +SRSRAN_API bool +srsran_prach_tti_opportunity_config_fdd(uint32_t config_idx, uint32_t current_tti, int allowed_subframe); -SRSLTE_API bool srslte_prach_tti_opportunity_config_tdd(uint32_t config_idx, +SRSRAN_API bool srsran_prach_tti_opportunity_config_tdd(uint32_t config_idx, uint32_t tdd_ul_dl_config, uint32_t current_tti, uint32_t* prach_idx); -SRSLTE_API uint32_t srslte_prach_f_ra_tdd(uint32_t config_idx, +SRSRAN_API uint32_t srsran_prach_f_ra_tdd(uint32_t config_idx, uint32_t tdd_ul_dl_config, uint32_t current_tti, uint32_t prach_idx, uint32_t prach_offset, uint32_t n_rb_ul); -SRSLTE_API uint32_t srslte_prach_f_id_tdd(uint32_t config_idx, uint32_t tdd_ul_dl_config, uint32_t prach_idx); +SRSRAN_API uint32_t srsran_prach_f_id_tdd(uint32_t config_idx, uint32_t tdd_ul_dl_config, uint32_t prach_idx); -SRSLTE_API uint32_t srslte_prach_nof_f_idx_tdd(uint32_t config_idx, uint32_t tdd_ul_dl_config); +SRSRAN_API uint32_t srsran_prach_nof_f_idx_tdd(uint32_t config_idx, uint32_t tdd_ul_dl_config); -SRSLTE_API void srslte_prach_sf_config(uint32_t config_idx, srslte_prach_sf_config_t* sf_config); +SRSRAN_API void srsran_prach_sf_config(uint32_t config_idx, srsran_prach_sf_config_t* sf_config); -SRSLTE_API int srslte_prach_init(srslte_prach_t* p, uint32_t max_N_ifft_ul); +SRSRAN_API int srsran_prach_init(srsran_prach_t* p, uint32_t max_N_ifft_ul); -SRSLTE_API int srslte_prach_set_cfg(srslte_prach_t* p, srslte_prach_cfg_t* cfg, uint32_t nof_prb); +SRSRAN_API int srsran_prach_set_cfg(srsran_prach_t* p, srsran_prach_cfg_t* cfg, uint32_t nof_prb); -SRSLTE_API int srslte_prach_gen(srslte_prach_t* p, uint32_t seq_index, uint32_t freq_offset, cf_t* signal); +SRSRAN_API int srsran_prach_gen(srsran_prach_t* p, uint32_t seq_index, uint32_t freq_offset, cf_t* signal); -SRSLTE_API int srslte_prach_detect(srslte_prach_t* p, +SRSRAN_API int srsran_prach_detect(srsran_prach_t* p, uint32_t freq_offset, cf_t* signal, uint32_t sig_len, uint32_t* indices, uint32_t* ind_len); -SRSLTE_API int srslte_prach_detect_offset(srslte_prach_t* p, +SRSRAN_API int srsran_prach_detect_offset(srsran_prach_t* p, uint32_t freq_offset, cf_t* signal, uint32_t sig_len, @@ -195,13 +195,13 @@ SRSLTE_API int srslte_prach_detect_offset(srslte_prach_t* p, float* peak_to_avg, uint32_t* ind_len); -SRSLTE_API void srslte_prach_set_detect_factor(srslte_prach_t* p, float factor); +SRSRAN_API void srsran_prach_set_detect_factor(srsran_prach_t* p, float factor); -SRSLTE_API int srslte_prach_free(srslte_prach_t* p); +SRSRAN_API int srsran_prach_free(srsran_prach_t* p); -SRSLTE_API int srslte_prach_print_seqs(srslte_prach_t* p); +SRSRAN_API int srsran_prach_print_seqs(srsran_prach_t* p); -SRSLTE_API int srslte_prach_process(srslte_prach_t* p, +SRSRAN_API int srsran_prach_process(srsran_prach_t* p, cf_t* signal, uint32_t* indices, float* t_offsets, @@ -211,4 +211,4 @@ SRSLTE_API int srslte_prach_process(srslte_prach_t* p, uint32_t begin, uint32_t sig_len); -#endif // SRSLTE_PRACH_H +#endif // SRSRAN_PRACH_H diff --git a/lib/include/srslte/phy/phch/psbch.h b/lib/include/srsran/phy/phch/psbch.h similarity index 51% rename from lib/include/srslte/phy/phch/psbch.h rename to lib/include/srsran/phy/phch/psbch.h index a242dd3f0..e7c05f015 100644 --- a/lib/include/srslte/phy/phch/psbch.h +++ b/lib/include/srsran/phy/phch/psbch.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,29 +10,29 @@ * */ -#ifndef SRSLTE_PSBCH_H -#define SRSLTE_PSBCH_H +#ifndef SRSRAN_PSBCH_H +#define SRSRAN_PSBCH_H -#include "srslte/phy/common/phy_common_sl.h" -#include "srslte/phy/dft/dft_precoding.h" -#include "srslte/phy/fec/convolutional/convcoder.h" -#include "srslte/phy/fec/convolutional/viterbi.h" -#include "srslte/phy/fec/crc.h" -#include "srslte/phy/modem/demod_soft.h" -#include "srslte/phy/modem/modem_table.h" -#include "srslte/phy/scrambling/scrambling.h" +#include "srsran/phy/common/phy_common_sl.h" +#include "srsran/phy/dft/dft_precoding.h" +#include "srsran/phy/fec/convolutional/convcoder.h" +#include "srsran/phy/fec/convolutional/viterbi.h" +#include "srsran/phy/fec/crc.h" +#include "srsran/phy/modem/demod_soft.h" +#include "srsran/phy/modem/modem_table.h" +#include "srsran/phy/scrambling/scrambling.h" -#define SRSLTE_SL_BCH_CRC_LEN 16 +#define SRSRAN_SL_BCH_CRC_LEN 16 /** * \brief Physical Sidelink broadcast channel. * * Reference: 3GPP TS 36.211 version 15.6.0 Release 15 Sec. 9.6 */ -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { uint32_t N_sl_id; - srslte_sl_tm_t tm; - srslte_cp_t cp; + srsran_sl_tm_t tm; + srsran_cp_t cp; uint32_t nof_data_re; ///< Number of RE considered during the channel mapping uint32_t nof_tx_re; ///< Number of RE actually transmitted over the air (without last OFDM symbol) @@ -50,12 +50,12 @@ typedef struct SRSLTE_API { uint8_t* c; // crc - srslte_crc_t crc_mib_sl; + srsran_crc_t crc_mib_sl; uint8_t* crc_temp; // channel coding - srslte_viterbi_t dec; - srslte_convcoder_t encoder; + srsran_viterbi_t dec; + srsran_convcoder_t encoder; uint8_t* d; int16_t* d_16; @@ -72,32 +72,32 @@ typedef struct SRSLTE_API { uint32_t* interleaver_lut; // scrambling - srslte_sequence_t seq; + srsran_sequence_t seq; // modulation - srslte_modem_table_t mod; + srsran_modem_table_t mod; cf_t* mod_symbols; // dft precoding - srslte_dft_precoding_t dft_precoder; - srslte_dft_precoding_t idft_precoder; + srsran_dft_precoding_t dft_precoder; + srsran_dft_precoding_t idft_precoder; cf_t* scfdma_symbols; -} srslte_psbch_t; +} srsran_psbch_t; -SRSLTE_API int -srslte_psbch_init(srslte_psbch_t* q, uint32_t nof_prb, uint32_t N_sl_id, srslte_sl_tm_t tm, srslte_cp_t cp); +SRSRAN_API int +srsran_psbch_init(srsran_psbch_t* q, uint32_t nof_prb, uint32_t N_sl_id, srsran_sl_tm_t tm, srsran_cp_t cp); -SRSLTE_API void srslte_psbch_free(srslte_psbch_t* q); +SRSRAN_API void srsran_psbch_free(srsran_psbch_t* q); -SRSLTE_API int srslte_psbch_encode(srslte_psbch_t* q, uint8_t* input, uint32_t input_len, cf_t* sf_buffer); +SRSRAN_API int srsran_psbch_encode(srsran_psbch_t* q, uint8_t* input, uint32_t input_len, cf_t* sf_buffer); -SRSLTE_API int srslte_psbch_decode(srslte_psbch_t* q, cf_t* scfdma_symbols, uint8_t* output, uint32_t max_output_len); +SRSRAN_API int srsran_psbch_decode(srsran_psbch_t* q, cf_t* scfdma_symbols, uint8_t* output, uint32_t max_output_len); -SRSLTE_API int srslte_psbch_reset(srslte_psbch_t* q, uint32_t N_sl_id); +SRSRAN_API int srsran_psbch_reset(srsran_psbch_t* q, uint32_t N_sl_id); -SRSLTE_API int srslte_psbch_put(srslte_psbch_t* q, cf_t* symbols, cf_t* sf_buffer); +SRSRAN_API int srsran_psbch_put(srsran_psbch_t* q, cf_t* symbols, cf_t* sf_buffer); -SRSLTE_API int srslte_psbch_get(srslte_psbch_t* q, cf_t* sf_buffer, cf_t* symbols); +SRSRAN_API int srsran_psbch_get(srsran_psbch_t* q, cf_t* sf_buffer, cf_t* symbols); -#endif // SRSLTE_PSBCH_H +#endif // SRSRAN_PSBCH_H diff --git a/lib/include/srsran/phy/phch/pscch.h b/lib/include/srsran/phy/phch/pscch.h new file mode 100644 index 000000000..c2257ca03 --- /dev/null +++ b/lib/include/srsran/phy/phch/pscch.h @@ -0,0 +1,90 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +#ifndef SRSRAN_PSCCH_H +#define SRSRAN_PSCCH_H + +#include + +#include "srsran/phy/common/phy_common_sl.h" +#include "srsran/phy/common/sequence.h" +#include "srsran/phy/dft/dft_precoding.h" +#include "srsran/phy/fec/convolutional/convcoder.h" +#include "srsran/phy/fec/convolutional/viterbi.h" +#include "srsran/phy/fec/crc.h" +#include "srsran/phy/modem/modem_table.h" + +/** + * \brief Physical Sidelink control channel. + * + * Reference: 3GPP TS 36.211 version 15.6.0 Release 15 Section 9.4 + */ + +typedef struct SRSRAN_API { + + uint32_t max_prb; + srsran_cell_sl_t cell; + + uint32_t sci_len; + uint32_t nof_tx_re; + + uint32_t pscch_nof_prb; + + // crc + uint8_t* c; + srsran_crc_t crc; + uint8_t* sci_crc; + + // channel coding + srsran_viterbi_t dec; + srsran_convcoder_t encoder; + uint8_t* d; + int16_t* d_16; + + // rate matching + uint32_t E; + uint8_t* e; + int16_t* e_16; + + uint8_t* e_bytes; ///< To pack bits to bytes + uint32_t nof_symbols; + + // interleaving + uint32_t* interleaver_lut; + uint8_t* codeword; + uint8_t* codeword_bytes; + + // scrambling + srsran_sequence_t seq; + + // modulation + srsran_modem_table_t mod; + cf_t* mod_symbols; + int16_t* llr; + + // dft precoding + srsran_dft_precoding_t dft_precoder; + srsran_dft_precoding_t idft_precoder; + + cf_t* scfdma_symbols; + +} srsran_pscch_t; + +SRSRAN_API int srsran_pscch_init(srsran_pscch_t* q, uint32_t max_prb); +SRSRAN_API int srsran_pscch_set_cell(srsran_pscch_t* q, srsran_cell_sl_t cell); +SRSRAN_API int srsran_pscch_encode(srsran_pscch_t* q, uint8_t* sci, cf_t* sf_buffer, uint32_t prb_start_idx); +SRSRAN_API int srsran_pscch_decode(srsran_pscch_t* q, cf_t* equalized_sf_syms, uint8_t* sci, uint32_t prb_start_idx); +SRSRAN_API int srsran_pscch_put(srsran_pscch_t* q, cf_t* sf_buffer, uint32_t prb_start_idx); +SRSRAN_API int srsran_pscch_get(srsran_pscch_t* q, cf_t* sf_buffer, uint32_t prb_start_idx); +SRSRAN_API void srsran_pscch_free(srsran_pscch_t* q); + +#endif // SRSRAN_PSCCH_H diff --git a/lib/include/srslte/phy/phch/pssch.h b/lib/include/srsran/phy/phch/pssch.h similarity index 53% rename from lib/include/srslte/phy/phch/pssch.h rename to lib/include/srsran/phy/phch/pssch.h index 8f703ea5a..21427cde8 100644 --- a/lib/include/srslte/phy/phch/pssch.h +++ b/lib/include/srsran/phy/phch/pssch.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,16 +10,16 @@ * */ -#ifndef SRSLTE_PSSCH_H -#define SRSLTE_PSSCH_H +#ifndef SRSRAN_PSSCH_H +#define SRSRAN_PSSCH_H -#include "srslte/phy/common/phy_common_sl.h" -#include "srslte/phy/dft/dft_precoding.h" -#include "srslte/phy/fec/crc.h" -#include "srslte/phy/fec/turbo/turbocoder.h" -#include "srslte/phy/fec/turbo/turbodecoder.h" -#include "srslte/phy/modem/mod.h" -#include "srslte/phy/scrambling/scrambling.h" +#include "srsran/phy/common/phy_common_sl.h" +#include "srsran/phy/dft/dft_precoding.h" +#include "srsran/phy/fec/crc.h" +#include "srsran/phy/fec/turbo/turbocoder.h" +#include "srsran/phy/fec/turbo/turbodecoder.h" +#include "srsran/phy/modem/mod.h" +#include "srsran/phy/scrambling/scrambling.h" /** * \brief Physical Sidelink shared channel. @@ -28,24 +28,23 @@ */ // Redundancy version -static const uint8_t srslte_pssch_rv[4] = {0, 2, 3, 1}; +static const uint8_t srsran_pssch_rv[4] = {0, 2, 3, 1}; -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { uint32_t prb_start_idx; // PRB start idx to map RE from RIV uint32_t nof_prb; // PSSCH nof_prbs, Length of continuous PRB to map RE (in the pool) from RIV uint32_t N_x_id; uint32_t mcs_idx; uint32_t rv_idx; uint32_t sf_idx; // PSSCH sf_idx -} srslte_pssch_cfg_t; +} srsran_pssch_cfg_t; -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { + srsran_cell_sl_t cell; + srsran_sl_comm_resource_pool_t sl_comm_resource_pool; + srsran_pssch_cfg_t pssch_cfg; - srslte_cell_sl_t cell; - srslte_sl_comm_resource_pool_t sl_comm_resource_pool; - srslte_pssch_cfg_t pssch_cfg; - - srslte_cbsegm_t cb_segm; + srsran_cbsegm_t cb_segm; uint32_t G; uint32_t E; @@ -65,15 +64,15 @@ typedef struct SRSLTE_API { uint8_t* c_r; uint8_t* c_r_bytes; uint8_t* tb_crc_temp; - srslte_crc_t tb_crc; + srsran_crc_t tb_crc; uint8_t* cb_crc_temp; - srslte_crc_t cb_crc; + srsran_crc_t cb_crc; // channel coding uint8_t* d_r; int16_t* d_r_16; - srslte_tcod_t tcod; - srslte_tdec_t tdec; + srsran_tcod_t tcod; + srsran_tdec_t tdec; // rate matching uint8_t* e_r; @@ -91,29 +90,29 @@ typedef struct SRSLTE_API { uint32_t* interleaver_lut; // scrambling - srslte_sequence_t scrambling_seq; + srsran_sequence_t scrambling_seq; // modulation - srslte_mod_t mod_idx; - srslte_modem_table_t mod[SRSLTE_MOD_NITEMS]; + srsran_mod_t mod_idx; + srsran_modem_table_t mod[SRSRAN_MOD_NITEMS]; cf_t* symbols; uint8_t* bits_after_demod; uint8_t* bytes_after_demod; // dft precoding - srslte_dft_precoding_t dft_precoder; + srsran_dft_precoding_t dft_precoder; cf_t* scfdma_symbols; - srslte_dft_precoding_t idft_precoder; + srsran_dft_precoding_t idft_precoder; -} srslte_pssch_t; +} srsran_pssch_t; -SRSLTE_API int - srslte_pssch_init(srslte_pssch_t* q, srslte_cell_sl_t cell, srslte_sl_comm_resource_pool_t sl_comm_resource_pool); -SRSLTE_API int srslte_pssch_set_cfg(srslte_pssch_t* q, srslte_pssch_cfg_t pssch_cfg); -SRSLTE_API int srslte_pssch_encode(srslte_pssch_t* q, uint8_t* input, uint32_t input_len, cf_t* sf_buffer); -SRSLTE_API int srslte_pssch_decode(srslte_pssch_t* q, cf_t* equalized_sf_syms, uint8_t* output, uint32_t output_len); -SRSLTE_API int srslte_pssch_put(srslte_pssch_t* q, cf_t* sf_buffer, cf_t* symbols); -SRSLTE_API int srslte_pssch_get(srslte_pssch_t* q, cf_t* sf_buffer, cf_t* symbols); -SRSLTE_API void srslte_pssch_free(srslte_pssch_t* q); +SRSRAN_API int + srsran_pssch_init(srsran_pssch_t* q, srsran_cell_sl_t cell, srsran_sl_comm_resource_pool_t sl_comm_resource_pool); +SRSRAN_API int srsran_pssch_set_cfg(srsran_pssch_t* q, srsran_pssch_cfg_t pssch_cfg); +SRSRAN_API int srsran_pssch_encode(srsran_pssch_t* q, uint8_t* input, uint32_t input_len, cf_t* sf_buffer); +SRSRAN_API int srsran_pssch_decode(srsran_pssch_t* q, cf_t* equalized_sf_syms, uint8_t* output, uint32_t output_len); +SRSRAN_API int srsran_pssch_put(srsran_pssch_t* q, cf_t* sf_buffer, cf_t* symbols); +SRSRAN_API int srsran_pssch_get(srsran_pssch_t* q, cf_t* sf_buffer, cf_t* symbols); +SRSRAN_API void srsran_pssch_free(srsran_pssch_t* q); -#endif // SRSLTE_PSSCH_H \ No newline at end of file +#endif // SRSRAN_PSSCH_H \ No newline at end of file diff --git a/lib/include/srsran/phy/phch/pucch.h b/lib/include/srsran/phy/phch/pucch.h new file mode 100644 index 000000000..73c7ec6a1 --- /dev/null +++ b/lib/include/srsran/phy/phch/pucch.h @@ -0,0 +1,175 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +/****************************************************************************** + * File: pucch.h + * + * Description: Physical uplink control channel. + * + * Reference: 3GPP TS 36.211 version 10.0.0 Release 10 Sec. 5.4 + *****************************************************************************/ + +#ifndef SRSRAN_PUCCH_H +#define SRSRAN_PUCCH_H + +#include "srsran/config.h" +#include "srsran/phy/ch_estimation/chest_ul.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/common/sequence.h" +#include "srsran/phy/modem/mod.h" +#include "srsran/phy/phch/cqi.h" +#include "srsran/phy/phch/pucch_cfg.h" +#include "srsran/phy/phch/uci.h" + +#define SRSRAN_PUCCH_N_SEQ SRSRAN_NRE +#define SRSRAN_PUCCH2_NOF_BITS SRSRAN_UCI_CQI_CODED_PUCCH_B +#define SRSRAN_PUCCH2_N_SF (5) +#define SRSRAN_PUCCH_1A_2A_NOF_ACK (1) +#define SRSRAN_PUCCH_1B_2B_NOF_ACK (2) +#define SRSRAN_PUCCH3_NOF_BITS (4 * SRSRAN_NRE) +#define SRSRAN_PUCCH_MAX_SYMBOLS (SRSRAN_PUCCH_N_SEQ * SRSRAN_PUCCH2_N_SF * SRSRAN_NOF_SLOTS_PER_SF) + +// PUCCH Format 1B Channel selection +#define SRSRAN_PUCCH_CS_MAX_ACK 4 +#define SRSRAN_PUCCH_CS_MAX_CARRIERS 2 +#define SRSRAN_PUCCH_FORMAT3_MAX_CARRIERS 5 + +#define SRSRAN_PUCCH_DEFAULT_THRESHOLD_FORMAT1 (0.5f) +#define SRSRAN_PUCCH_DEFAULT_THRESHOLD_FORMAT1A (0.5f) +#define SRSRAN_PUCCH_DEFAULT_THRESHOLD_FORMAT2 (0.5f) +#define SRSRAN_PUCCH_DEFAULT_THRESHOLD_FORMAT3 (0.5f) +#define SRSRAN_PUCCH_DEFAULT_THRESHOLD_DMRS (0.4f) + +/* PUCCH object */ +typedef struct SRSRAN_API { + srsran_cell_t cell; + srsran_modem_table_t mod; + + srsran_uci_cqi_pucch_t cqi; + + srsran_sequence_t seq_f2; + bool is_ue; + + int16_t llr[SRSRAN_PUCCH3_NOF_BITS]; + uint8_t bits_scram[SRSRAN_PUCCH_MAX_BITS]; + cf_t d[SRSRAN_PUCCH_MAX_BITS / 2]; + uint32_t n_cs_cell[SRSRAN_NSLOTS_X_FRAME][SRSRAN_CP_NORM_NSYMB]; + uint32_t f_gh[SRSRAN_NSLOTS_X_FRAME]; + + cf_t* z; + cf_t* z_tmp; + cf_t* ce; + +} srsran_pucch_t; + +typedef struct SRSRAN_API { + srsran_uci_value_t uci_data; + float dmrs_correlation; + float snr_db; + float correlation; + bool detected; + + // PUCCH Measurements + bool ta_valid; + float ta_us; +} srsran_pucch_res_t; + +SRSRAN_API int srsran_pucch_init_ue(srsran_pucch_t* q); + +SRSRAN_API int srsran_pucch_init_enb(srsran_pucch_t* q); + +SRSRAN_API void srsran_pucch_free(srsran_pucch_t* q); + +/* These functions modify the state of the object and may take some time */ +SRSRAN_API int srsran_pucch_set_cell(srsran_pucch_t* q, srsran_cell_t cell); + +/* These functions do not modify the state and run in real-time */ +SRSRAN_API void srsran_pucch_uci_gen_cfg(srsran_pucch_t* q, srsran_pucch_cfg_t* cfg, srsran_uci_data_t* uci_data); + +SRSRAN_API int srsran_pucch_encode(srsran_pucch_t* q, + srsran_ul_sf_cfg_t* sf, + srsran_pucch_cfg_t* cfg, + srsran_uci_value_t* uci_data, + cf_t* sf_symbols); + +SRSRAN_API int srsran_pucch_decode(srsran_pucch_t* q, + srsran_ul_sf_cfg_t* sf, + srsran_pucch_cfg_t* cfg, + srsran_chest_ul_res_t* channel, + cf_t* sf_symbols, + srsran_pucch_res_t* data); + +/* Other utilities. These functions do not modify the state and run in real-time */ +SRSRAN_API float srsran_pucch_alpha_format1(const uint32_t n_cs_cell[SRSRAN_NSLOTS_X_FRAME][SRSRAN_CP_NORM_NSYMB], + const srsran_pucch_cfg_t* cfg, + srsran_cp_t cp, + bool is_dmrs, + uint32_t ns, + uint32_t l, + uint32_t* n_oc, + uint32_t* n_prime_ns); + +SRSRAN_API float srsran_pucch_alpha_format2(const uint32_t n_cs_cell[SRSRAN_NSLOTS_X_FRAME][SRSRAN_CP_NORM_NSYMB], + const srsran_pucch_cfg_t* cfg, + uint32_t ns, + uint32_t l); + +SRSRAN_API int srsran_pucch_format2ab_mod_bits(srsran_pucch_format_t format, uint8_t bits[2], cf_t* d_10); + +SRSRAN_API uint32_t srsran_pucch_m(const srsran_pucch_cfg_t* cfg, srsran_cp_t cp); + +SRSRAN_API uint32_t srsran_pucch_n_prb(const srsran_cell_t* cell, const srsran_pucch_cfg_t* cfg, uint32_t ns); + +SRSRAN_API int srsran_pucch_n_cs_cell(srsran_cell_t cell, + uint32_t n_cs_cell[SRSRAN_NSLOTS_X_FRAME][SRSRAN_CP_NORM_NSYMB]); + +/** + * Checks PUCCH collision from cell and two PUCCH configurations. The provided configurations shall provide format and + * n_pucch resource prior to this call. + * + * @param cell cell parameters + * @param cfg1 First PUCCH configuration + * @param cfg2 Second PUCCH configuration + * @return SRSRAN_SUCCESS if no collision, SRSRAN_ERROR if collision and otherwise SRSRAN_INVALID_INPUTS + */ +SRSRAN_API int +srsran_pucch_collision(const srsran_cell_t* cell, const srsran_pucch_cfg_t* cfg1, const srsran_pucch_cfg_t* cfg2); + +/** + * Checks PUCCH format 1b with channel selection collision configuration from a cell. + * + * @param cell cell parameters + * @param cfg PUCCH configuration + * @return SRSRAN_SUCCESS if no collision, SRSRAN_ERROR if collision and otherwise SRSRAN_INVALID_INPUTS + */ +SRSRAN_API int srsran_pucch_cfg_assert(const srsran_cell_t* cell, const srsran_pucch_cfg_t* cfg); + +SRSRAN_API char* srsran_pucch_format_text(srsran_pucch_format_t format); + +SRSRAN_API char* srsran_pucch_format_text_short(srsran_pucch_format_t format); + +/** + * Returns the number of ACK bits supported by a given PUCCH format + * @param format PUCCH format + * @return Returns the number of bits supported by the format + */ +SRSRAN_API uint32_t srsran_pucch_nof_ack_format(srsran_pucch_format_t format); + +SRSRAN_API void +srsran_pucch_tx_info(srsran_pucch_cfg_t* cfg, srsran_uci_value_t* uci_data, char* str, uint32_t str_len); + +SRSRAN_API void +srsran_pucch_rx_info(srsran_pucch_cfg_t* cfg, srsran_pucch_res_t* pucch_res, char* str, uint32_t str_len); + +SRSRAN_API bool srsran_pucch_cfg_isvalid(srsran_pucch_cfg_t* cfg, uint32_t nof_prb); + +#endif // SRSRAN_PUCCH_H diff --git a/lib/include/srslte/phy/phch/pucch_cfg.h b/lib/include/srsran/phy/phch/pucch_cfg.h similarity index 51% rename from lib/include/srslte/phy/phch/pucch_cfg.h rename to lib/include/srsran/phy/phch/pucch_cfg.h index 4cebeeba3..dfb4df382 100644 --- a/lib/include/srslte/phy/phch/pucch_cfg.h +++ b/lib/include/srsran/phy/phch/pucch_cfg.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,35 +10,35 @@ * */ -#ifndef SRSLTE_PUCCH_CFG_H -#define SRSLTE_PUCCH_CFG_H +#ifndef SRSRAN_PUCCH_CFG_H +#define SRSRAN_PUCCH_CFG_H -#include "srslte/phy/phch/cqi.h" -#include "srslte/phy/phch/ra.h" -#include "srslte/phy/phch/uci_cfg.h" +#include "srsran/phy/phch/cqi.h" +#include "srsran/phy/phch/ra.h" +#include "srsran/phy/phch/uci_cfg.h" -#define SRSLTE_PUCCH_SIZE_AN_CS 4 -#define SRSLTE_PUCCH_SIZE_AN_N3 4 -#define SRSLTE_PUCCH_NOF_AN_CS 2 -#define SRSLTE_PUCCH_MAX_BITS SRSLTE_CQI_MAX_BITS +#define SRSRAN_PUCCH_SIZE_AN_CS 4 +#define SRSRAN_PUCCH_SIZE_AN_N3 4 +#define SRSRAN_PUCCH_NOF_AN_CS 2 +#define SRSRAN_PUCCH_MAX_BITS SRSRAN_CQI_MAX_BITS -typedef enum SRSLTE_API { - SRSLTE_PUCCH_FORMAT_1 = 0, - SRSLTE_PUCCH_FORMAT_1A, - SRSLTE_PUCCH_FORMAT_1B, - SRSLTE_PUCCH_FORMAT_2, - SRSLTE_PUCCH_FORMAT_2A, - SRSLTE_PUCCH_FORMAT_2B, - SRSLTE_PUCCH_FORMAT_3, - SRSLTE_PUCCH_FORMAT_ERROR, -} srslte_pucch_format_t; +typedef enum SRSRAN_API { + SRSRAN_PUCCH_FORMAT_1 = 0, + SRSRAN_PUCCH_FORMAT_1A, + SRSRAN_PUCCH_FORMAT_1B, + SRSRAN_PUCCH_FORMAT_2, + SRSRAN_PUCCH_FORMAT_2A, + SRSRAN_PUCCH_FORMAT_2B, + SRSRAN_PUCCH_FORMAT_3, + SRSRAN_PUCCH_FORMAT_ERROR, +} srsran_pucch_format_t; -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { // Input configuration for this subframe uint16_t rnti; // UCI configuration - srslte_uci_cfg_t uci_cfg; + srsran_uci_cfg_t uci_cfg; // Common configuration uint32_t delta_pucch_shift; @@ -58,9 +58,9 @@ typedef struct SRSLTE_API { bool sps_enabled; // Release 10 CA specific - srslte_ack_nack_feedback_mode_t ack_nack_feedback_mode; - uint32_t n1_pucch_an_cs[SRSLTE_PUCCH_SIZE_AN_CS][SRSLTE_PUCCH_NOF_AN_CS]; - uint32_t n3_pucch_an_list[SRSLTE_PUCCH_SIZE_AN_N3]; + srsran_ack_nack_feedback_mode_t ack_nack_feedback_mode; + uint32_t n1_pucch_an_cs[SRSRAN_PUCCH_SIZE_AN_CS][SRSRAN_PUCCH_NOF_AN_CS]; + uint32_t n3_pucch_an_list[SRSRAN_PUCCH_SIZE_AN_N3]; // Other configuration float threshold_format1; @@ -71,10 +71,10 @@ typedef struct SRSLTE_API { bool meas_ta_en; // PUCCH configuration generated during a call to encode/decode - srslte_pucch_format_t format; + srsran_pucch_format_t format; uint16_t n_pucch; - uint8_t pucch2_drs_bits[SRSLTE_PUCCH_MAX_BITS]; + uint8_t pucch2_drs_bits[SRSRAN_PUCCH_MAX_BITS]; -} srslte_pucch_cfg_t; +} srsran_pucch_cfg_t; -#endif // SRSLTE_PUCCH_CFG_H +#endif // SRSRAN_PUCCH_CFG_H diff --git a/lib/include/srslte/phy/phch/pucch_cfg_nr.h b/lib/include/srsran/phy/phch/pucch_cfg_nr.h similarity index 56% rename from lib/include/srslte/phy/phch/pucch_cfg_nr.h rename to lib/include/srsran/phy/phch/pucch_cfg_nr.h index 7ce80551e..826567d52 100644 --- a/lib/include/srslte/phy/phch/pucch_cfg_nr.h +++ b/lib/include/srsran/phy/phch/pucch_cfg_nr.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,100 +10,100 @@ * */ -#ifndef SRSLTE_PUCCH_CFG_NR_H -#define SRSLTE_PUCCH_CFG_NR_H +#ifndef SRSRAN_PUCCH_CFG_NR_H +#define SRSRAN_PUCCH_CFG_NR_H -#include "srslte/config.h" +#include "srsran/config.h" #include #include /** * NR-PUCCH Format 0 ranges */ -#define SRSLTE_PUCCH_NR_FORMAT0_MAX_CS 11 -#define SRSLTE_PUCCH_NR_FORMAT0_MIN_NSYMB 1 -#define SRSLTE_PUCCH_NR_FORMAT0_MAX_NSYMB 2 -#define SRSLTE_PUCCH_NR_FORMAT0_MAX_STARTSYMB 13 +#define SRSRAN_PUCCH_NR_FORMAT0_MAX_CS 11 +#define SRSRAN_PUCCH_NR_FORMAT0_MIN_NSYMB 1 +#define SRSRAN_PUCCH_NR_FORMAT0_MAX_NSYMB 2 +#define SRSRAN_PUCCH_NR_FORMAT0_MAX_STARTSYMB 13 /** * NR-PUCCH Format 1 ranges */ -#define SRSLTE_PUCCH_NR_FORMAT1_MAX_CS 11 -#define SRSLTE_PUCCH_NR_FORMAT1_MAX_TOCC 6 -#define SRSLTE_PUCCH_NR_FORMAT1_MIN_NSYMB 4 -#define SRSLTE_PUCCH_NR_FORMAT1_MAX_NSYMB 14 -#define SRSLTE_PUCCH_NR_FORMAT1_MAX_STARTSYMB 10 -#define SRSLTE_PUCCH_NR_FORMAT1_MAX_NOF_BITS 2 +#define SRSRAN_PUCCH_NR_FORMAT1_MAX_CS 11 +#define SRSRAN_PUCCH_NR_FORMAT1_MAX_TOCC 6 +#define SRSRAN_PUCCH_NR_FORMAT1_MIN_NSYMB 4 +#define SRSRAN_PUCCH_NR_FORMAT1_MAX_NSYMB 14 +#define SRSRAN_PUCCH_NR_FORMAT1_MAX_STARTSYMB 10 +#define SRSRAN_PUCCH_NR_FORMAT1_MAX_NOF_BITS 2 /** * NR-PUCCH Format 2 ranges */ -#define SRSLTE_PUCCH_NR_FORMAT2_MIN_NPRB 1 -#define SRSLTE_PUCCH_NR_FORMAT2_MAX_NPRB 16 -#define SRSLTE_PUCCH_NR_FORMAT2_MIN_NSYMB 1 -#define SRSLTE_PUCCH_NR_FORMAT2_MAX_NSYMB 2 -#define SRSLTE_PUCCH_NR_FORMAT2_MAX_STARTSYMB 13 -#define SRSLTE_PUCCH_NR_FORMAT2_MIN_NOF_BITS 3 +#define SRSRAN_PUCCH_NR_FORMAT2_MIN_NPRB 1 +#define SRSRAN_PUCCH_NR_FORMAT2_MAX_NPRB 16 +#define SRSRAN_PUCCH_NR_FORMAT2_MIN_NSYMB 1 +#define SRSRAN_PUCCH_NR_FORMAT2_MAX_NSYMB 2 +#define SRSRAN_PUCCH_NR_FORMAT2_MAX_STARTSYMB 13 +#define SRSRAN_PUCCH_NR_FORMAT2_MIN_NOF_BITS 3 /** * NR-PUCCH Format 3 ranges */ -#define SRSLTE_PUCCH_NR_FORMAT3_MIN_NPRB 1 -#define SRSLTE_PUCCH_NR_FORMAT3_MAX_NPRB 16 -#define SRSLTE_PUCCH_NR_FORMAT3_MIN_NSYMB 4 -#define SRSLTE_PUCCH_NR_FORMAT3_MAX_NSYMB 14 -#define SRSLTE_PUCCH_NR_FORMAT3_MAX_STARTSYMB 10 +#define SRSRAN_PUCCH_NR_FORMAT3_MIN_NPRB 1 +#define SRSRAN_PUCCH_NR_FORMAT3_MAX_NPRB 16 +#define SRSRAN_PUCCH_NR_FORMAT3_MIN_NSYMB 4 +#define SRSRAN_PUCCH_NR_FORMAT3_MAX_NSYMB 14 +#define SRSRAN_PUCCH_NR_FORMAT3_MAX_STARTSYMB 10 /** * NR-PUCCH Format 4 ranges */ -#define SRSLTE_PUCCH_NR_FORMAT4_NPRB 1 -#define SRSLTE_PUCCH_NR_FORMAT4_MIN_NSYMB 4 -#define SRSLTE_PUCCH_NR_FORMAT4_MAX_NSYMB 14 -#define SRSLTE_PUCCH_NR_FORMAT4_MAX_STARTSYMB 10 +#define SRSRAN_PUCCH_NR_FORMAT4_NPRB 1 +#define SRSRAN_PUCCH_NR_FORMAT4_MIN_NSYMB 4 +#define SRSRAN_PUCCH_NR_FORMAT4_MAX_NSYMB 14 +#define SRSRAN_PUCCH_NR_FORMAT4_MAX_STARTSYMB 10 /** * NR-PUCCH Formats 2, 3 and 4 code rate range */ -#define SRSLTE_PUCCH_NR_MAX_CODE_RATE 7 +#define SRSRAN_PUCCH_NR_MAX_CODE_RATE 7 /** * Maximum number of NR-PUCCH resources per set (TS 38.331 maxNrofPUCCH-ResourcesPerSet) */ -#define SRSLTE_PUCCH_NR_MAX_NOF_RESOURCES_PER_SET 32 +#define SRSRAN_PUCCH_NR_MAX_NOF_RESOURCES_PER_SET 32 /** * Maximum number NR-PUCCH resource sets (TS 38.331 maxNrofPUCCH-ResourceSets) */ -#define SRSLTE_PUCCH_NR_MAX_NOF_SETS 4 +#define SRSRAN_PUCCH_NR_MAX_NOF_SETS 4 /** * Maximum number of SR resources (TS 38.331 maxNrofSR-Resources) */ -#define SRSLTE_PUCCH_MAX_NOF_SR_RESOURCES 8 - -typedef enum SRSLTE_API { - SRSLTE_PUCCH_NR_FORMAT_0 = 0, - SRSLTE_PUCCH_NR_FORMAT_1, - SRSLTE_PUCCH_NR_FORMAT_2, - SRSLTE_PUCCH_NR_FORMAT_3, - SRSLTE_PUCCH_NR_FORMAT_4, - SRSLTE_PUCCH_NR_FORMAT_ERROR, -} srslte_pucch_nr_format_t; - -typedef enum SRSLTE_API { - SRSLTE_PUCCH_NR_GROUP_HOPPING_NEITHER = 0, - SRSLTE_PUCCH_NR_GROUP_HOPPING_ENABLE, - SRSLTE_PUCCH_NR_GROUP_HOPPING_DISABLE -} srslte_pucch_nr_group_hopping_t; +#define SRSRAN_PUCCH_MAX_NOF_SR_RESOURCES 8 + +typedef enum SRSRAN_API { + SRSRAN_PUCCH_NR_FORMAT_0 = 0, + SRSRAN_PUCCH_NR_FORMAT_1, + SRSRAN_PUCCH_NR_FORMAT_2, + SRSRAN_PUCCH_NR_FORMAT_3, + SRSRAN_PUCCH_NR_FORMAT_4, + SRSRAN_PUCCH_NR_FORMAT_ERROR, +} srsran_pucch_nr_format_t; + +typedef enum SRSRAN_API { + SRSRAN_PUCCH_NR_GROUP_HOPPING_NEITHER = 0, + SRSRAN_PUCCH_NR_GROUP_HOPPING_ENABLE, + SRSRAN_PUCCH_NR_GROUP_HOPPING_DISABLE +} srsran_pucch_nr_group_hopping_t; /** * @brief PUCCH Common configuration * @remark Defined in TS 38.331 PUCCH-ConfigCommon */ -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { uint32_t resource_common; ///< Configures a set of cell-specific PUCCH resources/parameters - srslte_pucch_nr_group_hopping_t group_hopping; ///< Configuration of group and sequence hopping + srsran_pucch_nr_group_hopping_t group_hopping; ///< Configuration of group and sequence hopping uint32_t hopping_id; ///< Cell-specific scrambling ID for group hopping and sequence hopping if enabled bool hopping_id_present; float p0_nominal; ///< Power control parameter P0 for PUCCH transmissions. Value in dBm. (-202..24) @@ -111,20 +111,20 @@ typedef struct SRSLTE_API { // From PUSCH-config bool scrambling_id_present; uint32_t scambling_id; // Identifier used to initialize data scrambling (dataScramblingIdentityPUSCH, 0-1023) -} srslte_pucch_nr_common_cfg_t; +} srsran_pucch_nr_common_cfg_t; /** * @brief Generic PUCCH Resource configuration * @remark Defined in TS 38.331 PUCCH-Config */ -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { // Common PUCCH-Resource parameter uint32_t starting_prb; bool intra_slot_hopping; uint32_t second_hop_prb; // Common PUCCH-Resource parameters among all formats - srslte_pucch_nr_format_t format; ///< PUCCH format this configuration belongs + srsran_pucch_nr_format_t format; ///< PUCCH format this configuration belongs uint32_t nof_symbols; ///< Number of symbols uint32_t start_symbol_idx; ///< Starting symbol index @@ -139,39 +139,39 @@ typedef struct SRSLTE_API { bool enable_pi_bpsk; ///< Enables PI-BPSK uint32_t max_code_rate; ///< Maximum code rate r (0..7) bool additional_dmrs; ///< UE enables 2 DMRS symbols per hop of a PUCCH Format 3 or 4 -} srslte_pucch_nr_resource_t; +} srsran_pucch_nr_resource_t; -typedef struct SRSLTE_API { - srslte_pucch_nr_resource_t resources[SRSLTE_PUCCH_NR_MAX_NOF_RESOURCES_PER_SET]; +typedef struct SRSRAN_API { + srsran_pucch_nr_resource_t resources[SRSRAN_PUCCH_NR_MAX_NOF_RESOURCES_PER_SET]; uint32_t nof_resources; ///< Set to 0 if it is NOT provided by higher layers uint32_t max_payload_size; ///< Maximum payload size, set to 0 if not present -} srslte_pucch_nr_resource_set_t; +} srsran_pucch_nr_resource_set_t; /** * @brief Scheduling Request resource described in TS 38.331 SchedulingRequestResourceConfig * @note Every SR configuration corresponds to one or more logical channels (resources) */ -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { uint32_t sr_id; ///< Scheduling Request identifier uint32_t period; ///< Period in slots uint32_t offset; ///< Offset from beginning of the period in slots - srslte_pucch_nr_resource_t resource; ///< PUCCH resource + srsran_pucch_nr_resource_t resource; ///< PUCCH resource bool configured; ///< Set to true if higher layers added this value, otherwise set to false -} srslte_pucch_nr_sr_resource_t; +} srsran_pucch_nr_sr_resource_t; -typedef struct SRSLTE_API { - srslte_pucch_nr_common_cfg_t common; ///< NR-PUCCH configuration common for all formats and resources - srslte_pucch_nr_resource_set_t sets[SRSLTE_PUCCH_NR_MAX_NOF_SETS]; ///< Resource sets, indexed by pucch-ResourceSetId +typedef struct SRSRAN_API { + srsran_pucch_nr_common_cfg_t common; ///< NR-PUCCH configuration common for all formats and resources + srsran_pucch_nr_resource_set_t sets[SRSRAN_PUCCH_NR_MAX_NOF_SETS]; ///< Resource sets, indexed by pucch-ResourceSetId bool enabled; ///< Set to true if any set is enabled - srslte_pucch_nr_sr_resource_t - sr_resources[SRSLTE_PUCCH_MAX_NOF_SR_RESOURCES]; ///< SR resources, indexed by identifier -} srslte_pucch_nr_hl_cfg_t; + srsran_pucch_nr_sr_resource_t + sr_resources[SRSRAN_PUCCH_MAX_NOF_SR_RESOURCES]; ///< SR resources, indexed by identifier +} srsran_pucch_nr_hl_cfg_t; /** * @brief Validates an NR-PUCCH resource configuration provided by upper layers * @param resource Resource configuration to validate - * @return SRSLTE_SUCCESS if valid, SRSLTE_ERROR code otherwise + * @return SRSRAN_SUCCESS if valid, SRSRAN_ERROR code otherwise */ -SRSLTE_API int srslte_pucch_nr_cfg_resource_valid(const srslte_pucch_nr_resource_t* resource); +SRSRAN_API int srsran_pucch_nr_cfg_resource_valid(const srsran_pucch_nr_resource_t* resource); -#endif // SRSLTE_PUCCH_CFG_NR_H +#endif // SRSRAN_PUCCH_CFG_NR_H diff --git a/lib/include/srslte/phy/phch/pucch_nr.h b/lib/include/srsran/phy/phch/pucch_nr.h similarity index 64% rename from lib/include/srslte/phy/phch/pucch_nr.h rename to lib/include/srsran/phy/phch/pucch_nr.h index cdaf5ed57..cb532fbe1 100644 --- a/lib/include/srslte/phy/phch/pucch_nr.h +++ b/lib/include/srsran/phy/phch/pucch_nr.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,70 +10,70 @@ * */ -#ifndef SRSLTE_PUCCH_NR_H -#define SRSLTE_PUCCH_NR_H +#ifndef SRSRAN_PUCCH_NR_H +#define SRSRAN_PUCCH_NR_H -#include "srslte/phy/ch_estimation/chest_ul.h" -#include "srslte/phy/common/phy_common_nr.h" -#include "srslte/phy/common/zc_sequence.h" -#include "srslte/phy/modem/modem_table.h" -#include "srslte/phy/phch/uci_nr.h" +#include "srsran/phy/ch_estimation/chest_ul.h" +#include "srsran/phy/common/phy_common_nr.h" +#include "srsran/phy/common/zc_sequence.h" +#include "srsran/phy/modem/modem_table.h" +#include "srsran/phy/phch/uci_nr.h" /** * @brief Maximum number of symbols (without DMRS) that NR-PUCCH format 1 can transmit */ -#define SRSLTE_PUCCH_NR_FORMAT1_N_MAX 7 +#define SRSRAN_PUCCH_NR_FORMAT1_N_MAX 7 -typedef struct SRSLTE_API { - srslte_uci_nr_args_t uci; +typedef struct SRSRAN_API { + srsran_uci_nr_args_t uci; uint32_t max_nof_prb; -} srslte_pucch_nr_args_t; +} srsran_pucch_nr_args_t; -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { float rsrp; float rsrp_dBfs; float epre; float epre_dBfs; float norm_corr; -} srslte_pucch_nr_measure_t; +} srsran_pucch_nr_measure_t; /** * @brief NR-PUCCH encoder/decoder object */ -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { uint32_t max_prb; - srslte_carrier_nr_t carrier; - srslte_zc_sequence_lut_t r_uv_1prb; - cf_t format1_w_i_m[SRSLTE_PUCCH_NR_FORMAT1_N_MAX][SRSLTE_PUCCH_NR_FORMAT1_N_MAX][SRSLTE_PUCCH_NR_FORMAT1_N_MAX]; - srslte_modem_table_t bpsk; - srslte_modem_table_t qpsk; - srslte_uci_nr_t uci; + srsran_carrier_nr_t carrier; + srsran_zc_sequence_lut_t r_uv_1prb; + cf_t format1_w_i_m[SRSRAN_PUCCH_NR_FORMAT1_N_MAX][SRSRAN_PUCCH_NR_FORMAT1_N_MAX][SRSRAN_PUCCH_NR_FORMAT1_N_MAX]; + srsran_modem_table_t bpsk; + srsran_modem_table_t qpsk; + srsran_uci_nr_t uci; uint8_t* b; cf_t* d; cf_t* ce; -} srslte_pucch_nr_t; +} srsran_pucch_nr_t; /** * @brief Initialises an NR-PUCCH encoder/decoder object * @param q Object * @param args PUCCH configuration arguments - * @return SRSLTE_SUCCESS if successful, SRSLTE_ERROR code otherwise + * @return SRSRAN_SUCCESS if successful, SRSRAN_ERROR code otherwise */ -SRSLTE_API int srslte_pucch_nr_init(srslte_pucch_nr_t* q, const srslte_pucch_nr_args_t* args); +SRSRAN_API int srsran_pucch_nr_init(srsran_pucch_nr_t* q, const srsran_pucch_nr_args_t* args); /** * @brief Initialises an NR-PUCCH encoder/decoder object * @param q Object * @param carrier - * @return SRSLTE_SUCCESS if successful, SRSLTE_ERROR code otherwise + * @return SRSRAN_SUCCESS if successful, SRSRAN_ERROR code otherwise */ -SRSLTE_API int srslte_pucch_nr_set_carrier(srslte_pucch_nr_t* q, const srslte_carrier_nr_t* carrier); +SRSRAN_API int srsran_pucch_nr_set_carrier(srsran_pucch_nr_t* q, const srsran_carrier_nr_t* carrier); /** * @brief Deallocates an NR-PUCCH encoder/decoder object * @param q Object */ -SRSLTE_API void srslte_pucch_nr_free(srslte_pucch_nr_t* q); +SRSRAN_API void srsran_pucch_nr_free(srsran_pucch_nr_t* q); /** * @brief Computes the NR-PUCCH group sequence @@ -82,10 +82,10 @@ SRSLTE_API void srslte_pucch_nr_free(srslte_pucch_nr_t* q); * @param[in] cfg PUCCH common configuration * @param[out] u_ Group sequence (u) * @param[out] v_ Base sequence (v) - * @return SRSLTE_SUCCESS if provide arguments are right, SRSLTE_ERROR code otherwise + * @return SRSRAN_SUCCESS if provide arguments are right, SRSRAN_ERROR code otherwise */ -SRSLTE_API int srslte_pucch_nr_group_sequence(const srslte_carrier_nr_t* carrier, - const srslte_pucch_nr_common_cfg_t* cfg, +SRSRAN_API int srsran_pucch_nr_group_sequence(const srsran_carrier_nr_t* carrier, + const srsran_pucch_nr_common_cfg_t* cfg, uint32_t* u_, uint32_t* v_); @@ -99,11 +99,11 @@ SRSLTE_API int srslte_pucch_nr_group_sequence(const srslte_carrier_nr_t* * @param[in] m0 Initial cyclic shift * @param[in] m_cs Set to zero expect for format 0 * @param[out] alpha_idx Computed alpha index - * @return SRSLTE_SUCCESS if provide arguments are right, SRSLTE_ERROR code otherwise + * @return SRSRAN_SUCCESS if provide arguments are right, SRSRAN_ERROR code otherwise */ -SRSLTE_API int srslte_pucch_nr_alpha_idx(const srslte_carrier_nr_t* carrier, - const srslte_pucch_nr_common_cfg_t* cfg, - const srslte_slot_cfg_t* slot, +SRSRAN_API int srsran_pucch_nr_alpha_idx(const srsran_carrier_nr_t* carrier, + const srsran_pucch_nr_common_cfg_t* cfg, + const srsran_slot_cfg_t* slot, uint32_t l, uint32_t l_prime, uint32_t m0, @@ -119,12 +119,12 @@ SRSLTE_API int srslte_pucch_nr_alpha_idx(const srslte_carrier_nr_t* car * @param[in] resource PUCCH format 0 resource * @param[in] m_cs Cyclic shift according to TS 38.213 clause 5 * @param[out] slot_symbols Resource grid of the given slot - * @return SRSLTE_SUCCESS if successful, SRSLTE_ERROR code otherwise + * @return SRSRAN_SUCCESS if successful, SRSRAN_ERROR code otherwise */ -SRSLTE_API int srslte_pucch_nr_format0_encode(const srslte_pucch_nr_t* q, - const srslte_pucch_nr_common_cfg_t* cfg, - const srslte_slot_cfg_t* slot, - srslte_pucch_nr_resource_t* resource, +SRSRAN_API int srsran_pucch_nr_format0_encode(const srsran_pucch_nr_t* q, + const srsran_pucch_nr_common_cfg_t* cfg, + const srsran_slot_cfg_t* slot, + srsran_pucch_nr_resource_t* resource, uint32_t m_cs, cf_t* slot_symbols); @@ -137,15 +137,15 @@ SRSLTE_API int srslte_pucch_nr_format0_encode(const srslte_pucch_nr_t* * @param[in] m_cs Cyclic shift according to TS 38.213 clause 5 * @param[in] slot_symbols Resource grid of the given slot * @param[out] measure Measurement structure - * @return SRSLTE_SUCCESS if successful, SRSLTE_ERROR code otherwise + * @return SRSRAN_SUCCESS if successful, SRSRAN_ERROR code otherwise */ -SRSLTE_API int srslte_pucch_nr_format0_measure(const srslte_pucch_nr_t* q, - const srslte_pucch_nr_common_cfg_t* cfg, - const srslte_slot_cfg_t* slot, - srslte_pucch_nr_resource_t* resource, +SRSRAN_API int srsran_pucch_nr_format0_measure(const srsran_pucch_nr_t* q, + const srsran_pucch_nr_common_cfg_t* cfg, + const srsran_slot_cfg_t* slot, + srsran_pucch_nr_resource_t* resource, uint32_t m_cs, const cf_t* slot_symbols, - srslte_pucch_nr_measure_t* measure); + srsran_pucch_nr_measure_t* measure); /** * @brief Get NR-PUCCH orthogonal sequence w @@ -156,7 +156,7 @@ SRSLTE_API int srslte_pucch_nr_format0_measure(const srslte_pucch_nr_t* * @param m OFDM symbol index * @return Orthogonal sequence complex number if valid, NAN otherwise */ -SRSLTE_API cf_t srslte_pucch_nr_format1_w(const srslte_pucch_nr_t* q, uint32_t n_pucch, uint32_t i, uint32_t m); +SRSRAN_API cf_t srsran_pucch_nr_format1_w(const srsran_pucch_nr_t* q, uint32_t n_pucch, uint32_t i, uint32_t m); /** * @brief Encodes and puts NR-PUCCH format 1 in the resource grid @@ -168,12 +168,12 @@ SRSLTE_API cf_t srslte_pucch_nr_format1_w(const srslte_pucch_nr_t* q, uint32_t n * @param[in] b Bits to encode in the message * @param[in] nof_bits Number of bits to encode in the message * @param[out] slot_symbols Resource grid of the given slot - * @return SRSLTE_SUCCESS if successful, SRSLTE_ERROR code otherwise + * @return SRSRAN_SUCCESS if successful, SRSRAN_ERROR code otherwise */ -SRSLTE_API int srslte_pucch_nr_format1_encode(const srslte_pucch_nr_t* q, - const srslte_pucch_nr_common_cfg_t* cfg, - const srslte_slot_cfg_t* slot, - const srslte_pucch_nr_resource_t* resource, +SRSRAN_API int srsran_pucch_nr_format1_encode(const srsran_pucch_nr_t* q, + const srsran_pucch_nr_common_cfg_t* cfg, + const srsran_slot_cfg_t* slot, + const srsran_pucch_nr_resource_t* resource, uint8_t* b, uint32_t nof_bits, cf_t* slot_symbols); @@ -188,15 +188,15 @@ SRSLTE_API int srslte_pucch_nr_format1_encode(const srslte_pucch_nr_t* * @param[in] slot_symbols Resource grid of the given slot * @param[out] b Bits to decode * @param[in] nof_bits Number of bits to decode in the message - * @return SRSLTE_SUCCESS if successful, SRSLTE_ERROR code otherwise + * @return SRSRAN_SUCCESS if successful, SRSRAN_ERROR code otherwise */ -SRSLTE_API int srslte_pucch_nr_format1_decode(srslte_pucch_nr_t* q, - const srslte_pucch_nr_common_cfg_t* cfg, - const srslte_slot_cfg_t* slot, - const srslte_pucch_nr_resource_t* resource, - srslte_chest_ul_res_t* chest_res, +SRSRAN_API int srsran_pucch_nr_format1_decode(srsran_pucch_nr_t* q, + const srsran_pucch_nr_common_cfg_t* cfg, + const srsran_slot_cfg_t* slot, + const srsran_pucch_nr_resource_t* resource, + srsran_chest_ul_res_t* chest_res, cf_t* slot_symbols, - uint8_t b[SRSLTE_PUCCH_NR_FORMAT1_MAX_NOF_BITS], + uint8_t b[SRSRAN_PUCCH_NR_FORMAT1_MAX_NOF_BITS], uint32_t nof_bits); /** @@ -208,14 +208,14 @@ SRSLTE_API int srslte_pucch_nr_format1_decode(srslte_pucch_nr_t* * @param[in] uci_cfg Uplink Control Information configuration * @param[in] uci_value Uplink Control Information data * @param[out] slot_symbols Resource grid of the given slot - * @return SRSLTE_SUCCESS if successful, SRSLTE_ERROR code otherwise + * @return SRSRAN_SUCCESS if successful, SRSRAN_ERROR code otherwise */ -SRSLTE_API int srslte_pucch_nr_format_2_3_4_encode(srslte_pucch_nr_t* q, - const srslte_pucch_nr_common_cfg_t* cfg, - const srslte_slot_cfg_t* slot, - const srslte_pucch_nr_resource_t* resource, - const srslte_uci_cfg_nr_t* uci_cfg, - const srslte_uci_value_nr_t* uci_value, +SRSRAN_API int srsran_pucch_nr_format_2_3_4_encode(srsran_pucch_nr_t* q, + const srsran_pucch_nr_common_cfg_t* cfg, + const srsran_slot_cfg_t* slot, + const srsran_pucch_nr_resource_t* resource, + const srsran_uci_cfg_nr_t* uci_cfg, + const srsran_uci_value_nr_t* uci_value, cf_t* slot_symbols); /** @@ -228,20 +228,20 @@ SRSLTE_API int srslte_pucch_nr_format_2_3_4_encode(srslte_pucch_nr_t* * @param[in] chest_res Channel estimator result * @param[in] slot_symbols Resource grid of the given slot * @param[out] uci_value Uplink Control Information data - * @return SRSLTE_SUCCESS if successful, SRSLTE_ERROR code otherwise + * @return SRSRAN_SUCCESS if successful, SRSRAN_ERROR code otherwise */ -SRSLTE_API int srslte_pucch_nr_format_2_3_4_decode(srslte_pucch_nr_t* q, - const srslte_pucch_nr_common_cfg_t* cfg, - const srslte_slot_cfg_t* slot, - const srslte_pucch_nr_resource_t* resource, - const srslte_uci_cfg_nr_t* uci_cfg, - srslte_chest_ul_res_t* chest_res, +SRSRAN_API int srsran_pucch_nr_format_2_3_4_decode(srsran_pucch_nr_t* q, + const srsran_pucch_nr_common_cfg_t* cfg, + const srsran_slot_cfg_t* slot, + const srsran_pucch_nr_resource_t* resource, + const srsran_uci_cfg_nr_t* uci_cfg, + srsran_chest_ul_res_t* chest_res, cf_t* slot_symbols, - srslte_uci_value_nr_t* uci_value); + srsran_uci_value_nr_t* uci_value); -SRSLTE_API uint32_t srslte_pucch_nr_tx_info(const srslte_pucch_nr_resource_t* resource, - const srslte_uci_data_nr_t* uci_data, +SRSRAN_API uint32_t srsran_pucch_nr_tx_info(const srsran_pucch_nr_resource_t* resource, + const srsran_uci_data_nr_t* uci_data, char* str, uint32_t str_len); -#endif // SRSLTE_PUCCH_NR_H +#endif // SRSRAN_PUCCH_NR_H diff --git a/lib/include/srslte/phy/phch/pucch_proc.h b/lib/include/srsran/phy/phch/pucch_proc.h similarity index 63% rename from lib/include/srslte/phy/phch/pucch_proc.h rename to lib/include/srsran/phy/phch/pucch_proc.h index 57f44cfe2..f203241a1 100644 --- a/lib/include/srslte/phy/phch/pucch_proc.h +++ b/lib/include/srsran/phy/phch/pucch_proc.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,18 +10,18 @@ * */ -#ifndef SRSLTE_PUCCH_PROC_H_ -#define SRSLTE_PUCCH_PROC_H_ +#ifndef SRSRAN_PUCCH_PROC_H_ +#define SRSRAN_PUCCH_PROC_H_ -#include "srslte/config.h" -#include "srslte/phy/ch_estimation/chest_ul.h" -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/common/sequence.h" -#include "srslte/phy/modem/mod.h" -#include "srslte/phy/phch/pucch.h" -#include "srslte/phy/phch/uci.h" +#include "srsran/config.h" +#include "srsran/phy/ch_estimation/chest_ul.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/common/sequence.h" +#include "srsran/phy/modem/mod.h" +#include "srsran/phy/phch/pucch.h" +#include "srsran/phy/phch/uci.h" -#define SRSLTE_PUCCH_MAX_ALLOC 4 +#define SRSRAN_PUCCH_MAX_ALLOC 4 /** * Implements 3GPP 36.213 R10 10.1 PUCCH format selection @@ -31,10 +31,10 @@ * @param uci_value uplink control information data, use NULL if unavailable * @return */ -SRSLTE_API srslte_pucch_format_t srslte_pucch_proc_select_format(const srslte_cell_t* cell, - const srslte_pucch_cfg_t* cfg, - const srslte_uci_cfg_t* uci_cfg, - const srslte_uci_value_t* uci_value); +SRSRAN_API srsran_pucch_format_t srsran_pucch_proc_select_format(const srsran_cell_t* cell, + const srsran_pucch_cfg_t* cfg, + const srsran_uci_cfg_t* uci_cfg, + const srsran_uci_value_t* uci_value); /** * Determines the possible n_pucch_i resources/locations for PUCCH. It follows 3GPP 36.213 R10 10.1 UE procedure for @@ -47,10 +47,10 @@ SRSLTE_API srslte_pucch_format_t srslte_pucch_proc_select_format(const srslte_ce * @param n_pucch_i table with the PUCCH format 1b possible resources * @return Returns the number of entries in the table or negative value indicating error */ -SRSLTE_API int srslte_pucch_proc_get_resources(const srslte_cell_t* cell, - const srslte_pucch_cfg_t* cfg, - const srslte_uci_cfg_t* uci_cfg, - const srslte_uci_value_t* uci_value, +SRSRAN_API int srsran_pucch_proc_get_resources(const srsran_cell_t* cell, + const srsran_pucch_cfg_t* cfg, + const srsran_uci_cfg_t* uci_cfg, + const srsran_uci_value_t* uci_value, uint32_t* n_pucch_i); /** * Determines the n_pucch resource for PUCCH. @@ -61,11 +61,11 @@ SRSLTE_API int srslte_pucch_proc_get_resources(const srslte_cell_t* cell, * @param b Selected ACK-NACK bits after HARQ-ACK feedback mode "encoding" * @return the selected resource */ -SRSLTE_API uint32_t srslte_pucch_proc_get_npucch(const srslte_cell_t* cell, - const srslte_pucch_cfg_t* cfg, - const srslte_uci_cfg_t* uci_cfg, - const srslte_uci_value_t* uci_value, - uint8_t b[SRSLTE_UCI_MAX_ACK_BITS]); +SRSRAN_API uint32_t srsran_pucch_proc_get_npucch(const srsran_cell_t* cell, + const srsran_pucch_cfg_t* cfg, + const srsran_uci_cfg_t* uci_cfg, + const srsran_uci_value_t* uci_value, + uint8_t b[SRSRAN_UCI_MAX_ACK_BITS]); /** * Decodes the HARQ ACK bits from a selected resource (j) and received bits (b) @@ -78,12 +78,12 @@ SRSLTE_API uint32_t srslte_pucch_proc_get_npucch(const srslte_cell_t* cell, * @param uci_cfg uplink control information configuration * @param j selected channel * @param b received bits - * @return Returns SRSLTE_SUCCESS if it can decode it succesfully, SRSLTE_ERROR code otherwise + * @return Returns SRSRAN_SUCCESS if it can decode it succesfully, SRSRAN_ERROR code otherwise */ -SRSLTE_API int srslte_pucch_cs_get_ack(const srslte_pucch_cfg_t* cfg, - const srslte_uci_cfg_t* uci_cfg, +SRSRAN_API int srsran_pucch_cs_get_ack(const srsran_pucch_cfg_t* cfg, + const srsran_uci_cfg_t* uci_cfg, uint32_t j, - const uint8_t b[SRSLTE_PUCCH_1B_2B_NOF_ACK], - srslte_uci_value_t* uci_value); + const uint8_t b[SRSRAN_PUCCH_1B_2B_NOF_ACK], + srsran_uci_value_t* uci_value); -#endif // SRSLTE_PUCCH_PROC_H_ +#endif // SRSRAN_PUCCH_PROC_H_ diff --git a/lib/include/srsran/phy/phch/pusch.h b/lib/include/srsran/phy/phch/pusch.h new file mode 100644 index 000000000..64a295962 --- /dev/null +++ b/lib/include/srsran/phy/phch/pusch.h @@ -0,0 +1,130 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +/****************************************************************************** + * File: pusch.h + * + * Description: Physical uplink shared channel. + * + * Reference: 3GPP TS 36.211 version 10.0.0 Release 10 Sec. 5.3 + *****************************************************************************/ + +#ifndef SRSRAN_PUSCH_H +#define SRSRAN_PUSCH_H + +#include "srsran/config.h" +#include "srsran/phy/ch_estimation/refsignal_ul.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/dft/dft_precoding.h" +#include "srsran/phy/mimo/layermap.h" +#include "srsran/phy/mimo/precoding.h" +#include "srsran/phy/modem/demod_soft.h" +#include "srsran/phy/modem/evm.h" +#include "srsran/phy/modem/mod.h" +#include "srsran/phy/phch/dci.h" +#include "srsran/phy/phch/pusch_cfg.h" +#include "srsran/phy/phch/regs.h" +#include "srsran/phy/phch/sch.h" +#include "srsran/phy/scrambling/scrambling.h" + +/* PUSCH object */ +typedef struct SRSRAN_API { + srsran_cell_t cell; + + bool is_ue; + uint16_t ue_rnti; + uint32_t max_re; + + bool llr_is_8bit; + + srsran_dft_precoding_t dft_precoding; + + /* buffers */ + // void buffers are shared for tx and rx + cf_t* ce; + cf_t* z; + cf_t* d; + + void* q; + void* g; + + /* tx & rx objects */ + srsran_modem_table_t mod[SRSRAN_MOD_NITEMS]; + srsran_sch_t ul_sch; + + // EVM buffer + srsran_evm_buffer_t* evm_buffer; + +} srsran_pusch_t; + +typedef struct SRSRAN_API { + uint8_t* ptr; + srsran_uci_value_t uci; +} srsran_pusch_data_t; + +typedef struct SRSRAN_API { + uint8_t* data; + srsran_uci_value_t uci; + bool crc; + float avg_iterations_block; + float evm; + float epre_dbfs; +} srsran_pusch_res_t; + +SRSRAN_API int srsran_pusch_init_ue(srsran_pusch_t* q, uint32_t max_prb); + +SRSRAN_API int srsran_pusch_init_enb(srsran_pusch_t* q, uint32_t max_prb); + +SRSRAN_API void srsran_pusch_free(srsran_pusch_t* q); + +/* These functions modify the state of the object and may take some time */ +SRSRAN_API int srsran_pusch_set_cell(srsran_pusch_t* q, srsran_cell_t cell); + +/** + * Asserts PUSCH grant attributes are in range + * @param grant Pointer to PUSCH grant + * @return it returns SRSRAN_SUCCESS if the grant is correct, otherwise it returns a SRSRAN_ERROR code + */ +SRSRAN_API int srsran_pusch_assert_grant(const srsran_pusch_grant_t* grant); + +/* These functions do not modify the state and run in real-time */ +SRSRAN_API int srsran_pusch_encode(srsran_pusch_t* q, + srsran_ul_sf_cfg_t* sf, + srsran_pusch_cfg_t* cfg, + srsran_pusch_data_t* data, + cf_t* sf_symbols); + +SRSRAN_API int srsran_pusch_decode(srsran_pusch_t* q, + srsran_ul_sf_cfg_t* sf, + srsran_pusch_cfg_t* cfg, + srsran_chest_ul_res_t* channel, + cf_t* sf_symbols, + srsran_pusch_res_t* data); + +SRSRAN_API uint32_t srsran_pusch_grant_tx_info(srsran_pusch_grant_t* grant, + srsran_uci_cfg_t* uci_cfg, + srsran_uci_value_t* uci_data, + char* str, + uint32_t str_len); + +SRSRAN_API uint32_t srsran_pusch_tx_info(srsran_pusch_cfg_t* cfg, + srsran_uci_value_t* uci_data, + char* str, + uint32_t str_len); + +SRSRAN_API uint32_t srsran_pusch_rx_info(srsran_pusch_cfg_t* cfg, + srsran_pusch_res_t* res, + srsran_chest_ul_res_t* chest_res, + char* str, + uint32_t str_len); + +#endif // SRSRAN_PUSCH_H diff --git a/lib/include/srslte/phy/phch/pusch_cfg.h b/lib/include/srsran/phy/phch/pusch_cfg.h similarity index 59% rename from lib/include/srslte/phy/phch/pusch_cfg.h rename to lib/include/srsran/phy/phch/pusch_cfg.h index 3cb687e95..908c14d71 100644 --- a/lib/include/srslte/phy/phch/pusch_cfg.h +++ b/lib/include/srsran/phy/phch/pusch_cfg.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,29 +10,29 @@ * */ -#ifndef SRSLTE_PUSCH_CFG_H -#define SRSLTE_PUSCH_CFG_H +#ifndef SRSRAN_PUSCH_CFG_H +#define SRSRAN_PUSCH_CFG_H -#include "srslte/phy/fec/softbuffer.h" -#include "srslte/phy/phch/ra.h" -#include "srslte/phy/phch/uci_cfg.h" +#include "srsran/phy/fec/softbuffer.h" +#include "srsran/phy/phch/ra.h" +#include "srsran/phy/phch/uci_cfg.h" -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { uint32_t I_offset_cqi; uint32_t I_offset_ri; uint32_t I_offset_ack; -} srslte_uci_offset_cfg_t; +} srsran_uci_offset_cfg_t; typedef struct { - enum { SRSLTE_PUSCH_HOP_MODE_INTER_SF = 1, SRSLTE_PUSCH_HOP_MODE_INTRA_SF = 0 } hop_mode; + enum { SRSRAN_PUSCH_HOP_MODE_INTER_SF = 1, SRSRAN_PUSCH_HOP_MODE_INTRA_SF = 0 } hop_mode; uint32_t hopping_offset; uint32_t n_sb; uint32_t n_rb_ho; uint32_t current_tx_nb; bool hopping_enabled; -} srslte_pusch_hopping_cfg_t; +} srsran_pusch_hopping_cfg_t; -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { uint32_t L_prb; uint32_t n_prb[2]; // rb_start after frequency hopping @@ -40,20 +40,20 @@ typedef struct SRSLTE_API { uint32_t freq_hopping; uint32_t nof_re; uint32_t nof_symb; - srslte_ra_tb_t tb; - srslte_ra_tb_t last_tb; + srsran_ra_tb_t tb; + srsran_ra_tb_t last_tb; uint32_t n_dmrs; bool is_rar; -} srslte_pusch_grant_t; +} srsran_pusch_grant_t; -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { uint16_t rnti; - srslte_uci_cfg_t uci_cfg; - srslte_uci_offset_cfg_t uci_offset; - srslte_pusch_grant_t grant; + srsran_uci_cfg_t uci_cfg; + srsran_uci_offset_cfg_t uci_offset; + srsran_pusch_grant_t grant; uint32_t max_nof_iterations; uint32_t last_O_cqi; @@ -63,8 +63,8 @@ typedef struct SRSLTE_API { bool enable_64qam; union { - srslte_softbuffer_tx_t* tx; - srslte_softbuffer_rx_t* rx; + srsran_softbuffer_tx_t* tx; + srsran_softbuffer_rx_t* rx; } softbuffers; bool meas_time_en; @@ -74,6 +74,6 @@ typedef struct SRSLTE_API { bool meas_ta_en; bool meas_evm_en; -} srslte_pusch_cfg_t; +} srsran_pusch_cfg_t; -#endif // SRSLTE_PUSCH_CFG_H +#endif // SRSRAN_PUSCH_CFG_H diff --git a/lib/include/srslte/phy/phch/pusch_nr.h b/lib/include/srsran/phy/phch/pusch_nr.h similarity index 50% rename from lib/include/srslte/phy/phch/pusch_nr.h rename to lib/include/srsran/phy/phch/pusch_nr.h index ffac74c42..6eb894c92 100644 --- a/lib/include/srslte/phy/phch/pusch_nr.h +++ b/lib/include/srsran/phy/phch/pusch_nr.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,47 +10,47 @@ * */ -#ifndef SRSLTE_PUSCH_NR_H -#define SRSLTE_PUSCH_NR_H +#ifndef SRSRAN_PUSCH_NR_H +#define SRSRAN_PUSCH_NR_H -#include "srslte/config.h" -#include "srslte/phy/ch_estimation/dmrs_sch.h" -#include "srslte/phy/modem/evm.h" -#include "srslte/phy/modem/modem_table.h" -#include "srslte/phy/phch/phch_cfg_nr.h" -#include "srslte/phy/phch/regs.h" -#include "srslte/phy/phch/sch_nr.h" -#include "srslte/phy/phch/uci_nr.h" -#include "srslte/phy/scrambling/scrambling.h" +#include "srsran/config.h" +#include "srsran/phy/ch_estimation/dmrs_sch.h" +#include "srsran/phy/modem/evm.h" +#include "srsran/phy/modem/modem_table.h" +#include "srsran/phy/phch/phch_cfg_nr.h" +#include "srsran/phy/phch/regs.h" +#include "srsran/phy/phch/sch_nr.h" +#include "srsran/phy/phch/uci_nr.h" +#include "srsran/phy/scrambling/scrambling.h" /** * @brief PUSCH encoder and decoder initialization arguments */ -typedef struct SRSLTE_API { - srslte_sch_nr_args_t sch; - srslte_uci_nr_args_t uci; +typedef struct SRSRAN_API { + srsran_sch_nr_args_t sch; + srsran_uci_nr_args_t uci; bool measure_evm; bool measure_time; -} srslte_pusch_nr_args_t; +} srsran_pusch_nr_args_t; /** * @brief PDSCH NR object */ -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { uint32_t max_prb; ///< Maximum number of allocated prb uint32_t max_layers; ///< Maximum number of allocated layers uint32_t max_cw; ///< Maximum number of allocated code words - srslte_carrier_nr_t carrier; ///< NR carrier configuration - srslte_sch_nr_t sch; ///< SCH Encoder/Decoder Object - srslte_uci_nr_t uci; ///< UCI Encoder/Decoder Object - uint8_t* b[SRSLTE_MAX_CODEWORDS]; ///< SCH Encoded and scrambled data - cf_t* d[SRSLTE_MAX_CODEWORDS]; ///< PDSCH modulated bits - cf_t* x[SRSLTE_MAX_LAYERS_NR]; ///< PDSCH modulated bits - srslte_modem_table_t modem_tables[SRSLTE_MOD_NITEMS]; ///< Modulator tables - srslte_evm_buffer_t* evm_buffer; + srsran_carrier_nr_t carrier; ///< NR carrier configuration + srsran_sch_nr_t sch; ///< SCH Encoder/Decoder Object + srsran_uci_nr_t uci; ///< UCI Encoder/Decoder Object + uint8_t* b[SRSRAN_MAX_CODEWORDS]; ///< SCH Encoded and scrambled data + cf_t* d[SRSRAN_MAX_CODEWORDS]; ///< PDSCH modulated bits + cf_t* x[SRSRAN_MAX_LAYERS_NR]; ///< PDSCH modulated bits + srsran_modem_table_t modem_tables[SRSRAN_MOD_NITEMS]; ///< Modulator tables + srsran_evm_buffer_t* evm_buffer; bool meas_time_en; uint32_t meas_time_us; - srslte_uci_cfg_nr_t uci_cfg; ///< Internal UCI bits configuration + srsran_uci_cfg_nr_t uci_cfg; ///< Internal UCI bits configuration uint8_t* g_ulsch; ///< Temporal Encoded UL-SCH data uint8_t* g_ack; ///< Temporal Encoded HARQ-ACK bits uint8_t* g_csi1; ///< Temporal Encoded CSI part 1 bits @@ -64,59 +64,59 @@ typedef struct SRSLTE_API { uint32_t G_csi1; ///< Number of encoded CSI part 1 bits uint32_t G_csi2; ///< Number of encoded CSI part 2 bits uint32_t G_ulsch; ///< Number of encoded shared channel -} srslte_pusch_nr_t; +} srsran_pusch_nr_t; /** * @brief Groups NR-PUSCH data for transmission */ typedef struct { uint8_t* payload; ///< SCH payload - srslte_uci_value_nr_t uci; ///< UCI payload -} srslte_pusch_data_nr_t; + srsran_uci_value_nr_t uci; ///< UCI payload +} srsran_pusch_data_nr_t; /** * @brief Groups NR-PUSCH data for reception */ typedef struct { uint8_t* payload; ///< SCH payload - srslte_uci_value_nr_t uci; ///< UCI payload + srsran_uci_value_nr_t uci; ///< UCI payload bool crc; ///< CRC match float evm; ///< EVM measurement if configured through arguments -} srslte_pusch_res_nr_t; +} srsran_pusch_res_nr_t; -SRSLTE_API int srslte_pusch_nr_init_gnb(srslte_pusch_nr_t* q, const srslte_pusch_nr_args_t* args); +SRSRAN_API int srsran_pusch_nr_init_gnb(srsran_pusch_nr_t* q, const srsran_pusch_nr_args_t* args); -SRSLTE_API int srslte_pusch_nr_init_ue(srslte_pusch_nr_t* q, const srslte_pusch_nr_args_t* args); +SRSRAN_API int srsran_pusch_nr_init_ue(srsran_pusch_nr_t* q, const srsran_pusch_nr_args_t* args); -SRSLTE_API void srslte_pusch_nr_free(srslte_pusch_nr_t* q); +SRSRAN_API void srsran_pusch_nr_free(srsran_pusch_nr_t* q); -SRSLTE_API int srslte_pusch_nr_set_carrier(srslte_pusch_nr_t* q, const srslte_carrier_nr_t* carrier); +SRSRAN_API int srsran_pusch_nr_set_carrier(srsran_pusch_nr_t* q, const srsran_carrier_nr_t* carrier); -SRSLTE_API int srslte_pusch_nr_encode(srslte_pusch_nr_t* q, - const srslte_sch_cfg_nr_t* cfg, - const srslte_sch_grant_nr_t* grant, - const srslte_pusch_data_nr_t* data, - cf_t* sf_symbols[SRSLTE_MAX_PORTS]); +SRSRAN_API int srsran_pusch_nr_encode(srsran_pusch_nr_t* q, + const srsran_sch_cfg_nr_t* cfg, + const srsran_sch_grant_nr_t* grant, + const srsran_pusch_data_nr_t* data, + cf_t* sf_symbols[SRSRAN_MAX_PORTS]); -SRSLTE_API int srslte_pusch_nr_decode(srslte_pusch_nr_t* q, - const srslte_sch_cfg_nr_t* cfg, - const srslte_sch_grant_nr_t* grant, - srslte_chest_dl_res_t* channel, - cf_t* sf_symbols[SRSLTE_MAX_PORTS], - srslte_pusch_res_nr_t data[SRSLTE_MAX_TB]); +SRSRAN_API int srsran_pusch_nr_decode(srsran_pusch_nr_t* q, + const srsran_sch_cfg_nr_t* cfg, + const srsran_sch_grant_nr_t* grant, + srsran_chest_dl_res_t* channel, + cf_t* sf_symbols[SRSRAN_MAX_PORTS], + srsran_pusch_res_nr_t data[SRSRAN_MAX_TB]); -SRSLTE_API uint32_t srslte_pusch_nr_rx_info(const srslte_pusch_nr_t* q, - const srslte_sch_cfg_nr_t* cfg, - const srslte_sch_grant_nr_t* grant, - const srslte_pusch_res_nr_t* res, +SRSRAN_API uint32_t srsran_pusch_nr_rx_info(const srsran_pusch_nr_t* q, + const srsran_sch_cfg_nr_t* cfg, + const srsran_sch_grant_nr_t* grant, + const srsran_pusch_res_nr_t* res, char* str, uint32_t str_len); -SRSLTE_API uint32_t srslte_pusch_nr_tx_info(const srslte_pusch_nr_t* q, - const srslte_sch_cfg_nr_t* cfg, - const srslte_sch_grant_nr_t* grant, - const srslte_uci_value_nr_t* uci_value, +SRSRAN_API uint32_t srsran_pusch_nr_tx_info(const srsran_pusch_nr_t* q, + const srsran_sch_cfg_nr_t* cfg, + const srsran_sch_grant_nr_t* grant, + const srsran_uci_value_nr_t* uci_value, char* str, uint32_t str_len); -#endif // SRSLTE_PUSCH_NR_H +#endif // SRSRAN_PUSCH_NR_H diff --git a/lib/include/srsran/phy/phch/ra.h b/lib/include/srsran/phy/phch/ra.h new file mode 100644 index 000000000..09cec9a19 --- /dev/null +++ b/lib/include/srsran/phy/phch/ra.h @@ -0,0 +1,98 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +/****************************************************************************** + * File: ra.h + * + * Description: Implements Resource allocation Procedures common in for DL and UL + * + * Reference: 3GPP TS 36.213 version 10.0.1 Release 10 + *****************************************************************************/ + +#ifndef SRSRAN_RA_H +#define SRSRAN_RA_H + +#include +#include + +#include "srsran/config.h" +#include "srsran/phy/common/phy_common.h" + +/************************************************** + * Common structures used for Resource Allocation + **************************************************/ + +typedef struct SRSRAN_API { + srsran_mod_t mod; + int tbs; + int rv; + uint32_t nof_bits; + uint32_t cw_idx; + bool enabled; + + // this is for debugging and metrics purposes + uint32_t mcs_idx; +} srsran_ra_tb_t; + +typedef enum SRSRAN_API { + SRSRAN_RA_ALLOC_TYPE0 = 0, + SRSRAN_RA_ALLOC_TYPE1 = 1, + SRSRAN_RA_ALLOC_TYPE2 = 2 +} srsran_ra_type_t; + +typedef struct SRSRAN_API { + uint32_t rbg_bitmask; +} srsran_ra_type0_t; + +typedef struct SRSRAN_API { + uint32_t vrb_bitmask; + uint32_t rbg_subset; + bool shift; +} srsran_ra_type1_t; + +typedef struct SRSRAN_API { + uint32_t riv; // if L_crb==0, DCI message packer will take this value directly + enum { SRSRAN_RA_TYPE2_NPRB1A_2 = 0, SRSRAN_RA_TYPE2_NPRB1A_3 = 1 } n_prb1a; + enum { SRSRAN_RA_TYPE2_NG1 = 0, SRSRAN_RA_TYPE2_NG2 = 1 } n_gap; + enum { SRSRAN_RA_TYPE2_LOC = 0, SRSRAN_RA_TYPE2_DIST = 1 } mode; +} srsran_ra_type2_t; + +#define SRSRAN_RA_NOF_TBS_IDX 34 + +SRSRAN_API uint32_t srsran_ra_type0_P(uint32_t nof_prb); + +SRSRAN_API uint32_t srsran_ra_type2_n_vrb_dl(uint32_t nof_prb, bool ngap_is_1); + +SRSRAN_API uint32_t srsran_ra_type2_n_rb_step(uint32_t nof_prb); + +SRSRAN_API uint32_t srsran_ra_type2_ngap(uint32_t nof_prb, bool ngap_is_1); + +SRSRAN_API uint32_t srsran_ra_type1_N_rb(uint32_t nof_prb); + +SRSRAN_API uint32_t srsran_ra_type2_to_riv(uint32_t L_crb, uint32_t RB_start, uint32_t nof_prb); + +SRSRAN_API void +srsran_ra_type2_from_riv(uint32_t riv, uint32_t* L_crb, uint32_t* RB_start, uint32_t nof_prb, uint32_t nof_vrb); + +SRSRAN_API int srsran_ra_tbs_idx_from_mcs(uint32_t mcs, bool use_tbs_index_alt, bool is_ul); + +SRSRAN_API srsran_mod_t srsran_ra_dl_mod_from_mcs(uint32_t mcs, bool use_tbs_index_alt); + +SRSRAN_API srsran_mod_t srsran_ra_ul_mod_from_mcs(uint32_t mcs); + +SRSRAN_API int srsran_ra_mcs_from_tbs_idx(uint32_t tbs_idx, bool use_tbs_index_alt, bool is_ul); + +SRSRAN_API int srsran_ra_tbs_from_idx(uint32_t tbs_idx, uint32_t n_prb); + +SRSRAN_API int srsran_ra_tbs_to_table_idx(uint32_t tbs, uint32_t n_prb, uint32_t max_tbs_idx); + +#endif // SRSRAN_RA_H diff --git a/lib/include/srsran/phy/phch/ra_dl.h b/lib/include/srsran/phy/phch/ra_dl.h new file mode 100644 index 000000000..9627e1760 --- /dev/null +++ b/lib/include/srsran/phy/phch/ra_dl.h @@ -0,0 +1,65 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +/****************************************************************************** + * File: ra_dl.h + * + * Description: Implements Resource allocation Procedures for DL defined in Section 7 + * + * Reference: 3GPP TS 36.213 version 10.0.1 Release 10 + *****************************************************************************/ + +#ifndef SRSRAN_RA_DL_H +#define SRSRAN_RA_DL_H + +#include +#include + +#include "srsran/config.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/phch/dci.h" +#include "srsran/phy/phch/pdsch_cfg.h" +#include "srsran/phy/phch/ra.h" + +/************************************************** + * Structures used for Downlink Resource Allocation + **************************************************/ + +/** Functions to generate a grant from a received DCI */ +SRSRAN_API int srsran_ra_dl_dci_to_grant(const srsran_cell_t* cell, + srsran_dl_sf_cfg_t* sf, + srsran_tm_t tm, + bool pdsch_use_tbs_index_alt, + const srsran_dci_dl_t* dci, + srsran_pdsch_grant_t* grant); + +SRSRAN_API int +srsran_ra_dl_grant_to_grant_prb_allocation(const srsran_dci_dl_t* dci, srsran_pdsch_grant_t* grant, uint32_t nof_prb); + +/** Functions used by the eNodeB scheduler */ +SRSRAN_API uint32_t srsran_ra_dl_approx_nof_re(const srsran_cell_t* cell, uint32_t nof_prb, uint32_t nof_ctrl_symbols); + +SRSRAN_API uint32_t ra_re_x_prb(const srsran_cell_t* cell, srsran_dl_sf_cfg_t* sf, uint32_t slot, uint32_t prb_idx); + +SRSRAN_API uint32_t srsran_ra_dl_grant_nof_re(const srsran_cell_t* cell, + srsran_dl_sf_cfg_t* sf, + srsran_pdsch_grant_t* grant); + +/** Others */ +SRSRAN_API int srsran_dl_fill_ra_mcs(srsran_ra_tb_t* tb, int last_tbs, uint32_t nprb, bool pdsch_use_tbs_index_alt); + +SRSRAN_API void +srsran_ra_dl_compute_nof_re(const srsran_cell_t* cell, srsran_dl_sf_cfg_t* sf, srsran_pdsch_grant_t* grant); + +SRSRAN_API uint32_t srsran_ra_dl_info(srsran_pdsch_grant_t* grant, char* info_str, uint32_t len); + +#endif // SRSRAN_RA_DL_H diff --git a/lib/include/srslte/phy/phch/ra_dl_nr.h b/lib/include/srsran/phy/phch/ra_dl_nr.h similarity index 65% rename from lib/include/srslte/phy/phch/ra_dl_nr.h rename to lib/include/srsran/phy/phch/ra_dl_nr.h index 346cf796e..ecc628f9d 100644 --- a/lib/include/srslte/phy/phch/ra_dl_nr.h +++ b/lib/include/srsran/phy/phch/ra_dl_nr.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -20,12 +20,12 @@ * Reference: *****************************************************************************/ -#ifndef SRSLTE_RA_DL_NR_H -#define SRSLTE_RA_DL_NR_H +#ifndef SRSRAN_RA_DL_NR_H +#define SRSRAN_RA_DL_NR_H -#include "srslte/phy/common/phy_common_nr.h" -#include "srslte/phy/phch/dci_nr.h" -#include "srslte/phy/phch/phch_cfg_nr.h" +#include "srsran/phy/common/phy_common_nr.h" +#include "srsran/phy/phch/dci_nr.h" +#include "srsran/phy/phch/phch_cfg_nr.h" /** * @brief Calculates the PDSCH time resource allocation and stores it in the provided PDSCH NR grant. @@ -39,14 +39,14 @@ * @param coreset_id CORESET identifier associated with the PDCCH transmission * @param m Time domain resource assignment field value m provided in DCI * @param[out] Provides grant pointer to fill - * @return Returns SRSLTE_SUCCESS if the provided allocation is valid, otherwise it returns SRSLTE_ERROR code + * @return Returns SRSRAN_SUCCESS if the provided allocation is valid, otherwise it returns SRSRAN_ERROR code */ -SRSLTE_API int srslte_ra_dl_nr_time(const srslte_sch_hl_cfg_nr_t* cfg, - const srslte_rnti_type_t rnti_type, - const srslte_search_space_type_t ss_type, +SRSRAN_API int srsran_ra_dl_nr_time(const srsran_sch_hl_cfg_nr_t* cfg, + const srsran_rnti_type_t rnti_type, + const srsran_search_space_type_t ss_type, const uint32_t coreset_id, const uint8_t m, - srslte_sch_grant_nr_t* grant); + srsran_sch_grant_nr_t* grant); /** * @brief Calculates the PDSCH time resource default A and stores it in the provided PDSCH NR grant. This can be used by @@ -58,10 +58,10 @@ SRSLTE_API int srslte_ra_dl_nr_time(const srslte_sch_hl_cfg_nr_t* cfg, * @param m Time domain resource assignment field value m of the DCI * @param dmrs_typeA_pos DMRS TypeA position provided by higher layers * @param[out] grant PDSCH mapping type - * @return Returns SRSLTE_SUCCESS if the provided allocation is valid, otherwise it returns SRSLTE_ERROR code + * @return Returns SRSRAN_SUCCESS if the provided allocation is valid, otherwise it returns SRSRAN_ERROR code */ -SRSLTE_API int -srslte_ra_dl_nr_time_default_A(uint32_t m, srslte_dmrs_sch_typeA_pos_t dmrs_typeA_pos, srslte_sch_grant_nr_t* grant); +SRSRAN_API int +srsran_ra_dl_nr_time_default_A(uint32_t m, srsran_dmrs_sch_typeA_pos_t dmrs_typeA_pos, srsran_sch_grant_nr_t* grant); /** * @brief Calculates the number of PDSCH-DMRS CDM groups without data for DCI format 1_0 * @@ -69,10 +69,10 @@ srslte_ra_dl_nr_time_default_A(uint32_t m, srslte_dmrs_sch_typeA_pos_t dmrs_type * * @param cfg PDSCH-DMRS NR configuration by upper layers * @param[out] grant Provides grant pointer to fill - * @return Returns SRSLTE_SUCCESS if the provided data is valid, otherwise it returns SRSLTE_ERROR code + * @return Returns SRSRAN_SUCCESS if the provided data is valid, otherwise it returns SRSRAN_ERROR code */ -SRSLTE_API int srslte_ra_dl_nr_nof_dmrs_cdm_groups_without_data_format_1_0(const srslte_dmrs_sch_cfg_t* cfg, - srslte_sch_grant_nr_t* grant); +SRSRAN_API int srsran_ra_dl_nr_nof_dmrs_cdm_groups_without_data_format_1_0(const srsran_dmrs_sch_cfg_t* cfg, + srsran_sch_grant_nr_t* grant); /** * @brief Calculates the PDSCH frequency resource allocation and stores it in the provided PDSCH NR grant. @@ -82,11 +82,11 @@ SRSLTE_API int srslte_ra_dl_nr_nof_dmrs_cdm_groups_without_data_format_1_0(const * @param cfg PDSCH NR configuration by upper layers * @param dci_dl Unpacked DCI used to schedule the PDSCH grant * @param[out] grant Provides grant pointer to fill - * @return SRSLTE_SUCCESS if the provided data is valid, SRSLTE_ERROR code otherwise + * @return SRSRAN_SUCCESS if the provided data is valid, SRSRAN_ERROR code otherwise */ -SRSLTE_API int srslte_ra_dl_nr_freq(const srslte_carrier_nr_t* carrier, - const srslte_sch_hl_cfg_nr_t* cfg, - const srslte_dci_dl_nr_t* dci_dl, - srslte_sch_grant_nr_t* grant); +SRSRAN_API int srsran_ra_dl_nr_freq(const srsran_carrier_nr_t* carrier, + const srsran_sch_hl_cfg_nr_t* cfg, + const srsran_dci_dl_nr_t* dci_dl, + srsran_sch_grant_nr_t* grant); -#endif // SRSLTE_RA_DL_NR_H +#endif // SRSRAN_RA_DL_NR_H diff --git a/lib/include/srslte/phy/phch/ra_nbiot.h b/lib/include/srsran/phy/phch/ra_nbiot.h similarity index 58% rename from lib/include/srslte/phy/phch/ra_nbiot.h rename to lib/include/srsran/phy/phch/ra_nbiot.h index c2724747e..c68d698c2 100644 --- a/lib/include/srslte/phy/phch/ra_nbiot.h +++ b/lib/include/srsran/phy/phch/ra_nbiot.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -16,43 +16,43 @@ * Reference: 3GPP TS 36.213 version 13.2.0 Release 13 */ -#ifndef SRSLTE_RA_NBIOT_H -#define SRSLTE_RA_NBIOT_H +#ifndef SRSRAN_RA_NBIOT_H +#define SRSRAN_RA_NBIOT_H #include #include -#include "srslte/config.h" -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/phch/npbch.h" -#include "srslte/phy/phch/ra.h" +#include "srsran/config.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/phch/npbch.h" +#include "srsran/phy/phch/ra.h" -#define SRSLTE_NPUSCH_MAX_SC 12 -#define SRSLTE_NPUSCH_MAX_SLOTS (16 * SRSLTE_NPUSCH_N_RU_MAX) -#define SRSLTE_NPUSCH_MAX_SF (SRSLTE_NPUSCH_MAX_SLOTS / 2) -#define SRSLTE_NPUSCH_N_REP_MAX 128 -#define SRSLTE_NPUSCH_N_RU_MAX 10 -#define SRSLTE_NPUSCH_MAX_NOF_RU_SLOTS_PROD 24 -#define SRSLTE_NPUSCH_FORMAT2_MAX_SLOTS 4 +#define SRSRAN_NPUSCH_MAX_SC 12 +#define SRSRAN_NPUSCH_MAX_SLOTS (16 * SRSRAN_NPUSCH_N_RU_MAX) +#define SRSRAN_NPUSCH_MAX_SF (SRSRAN_NPUSCH_MAX_SLOTS / 2) +#define SRSRAN_NPUSCH_N_REP_MAX 128 +#define SRSRAN_NPUSCH_N_RU_MAX 10 +#define SRSRAN_NPUSCH_MAX_NOF_RU_SLOTS_PROD 24 +#define SRSRAN_NPUSCH_FORMAT2_MAX_SLOTS 4 #define DUMMY_R_MAX 64 #define SIB1_NB_TTI 256 #define SIB1_NB_MAX_REP 16 /// All System Information types defined for NB-IoT -typedef enum SRSLTE_API { - SRSLTE_NBIOT_SI_TYPE_MIB = 0, ///< Essential information required to receive further sys information - SRSLTE_NBIOT_SI_TYPE_SIB1, ///< Cell access and selection, other SIB scheduling - SRSLTE_NBIOT_SI_TYPE_SIB2, ///< Radio resource configuration information - SRSLTE_NBIOT_SI_TYPE_SIB3, ///< Cell re-selection information for intra-frequency, inter-frequency - SRSLTE_NBIOT_SI_TYPE_SIB4, ///< Neighboring cell related information relevant for intra-frequency cell re-selection - SRSLTE_NBIOT_SI_TYPE_SIB5, ///< Neighboring cell related information relevant for inter-frequency cell re-selection - SRSLTE_NBIOT_SI_TYPE_SIB14, ///< Access Barring parameters - SRSLTE_NBIOT_SI_TYPE_SIB16, ///< Information related to GPS time and Coordinated Universal Time (UTC) - SRSLTE_NBIOT_SI_TYPE_NITEMS -} srslte_nbiot_si_type_t; - -typedef struct SRSLTE_API { +typedef enum SRSRAN_API { + SRSRAN_NBIOT_SI_TYPE_MIB = 0, ///< Essential information required to receive further sys information + SRSRAN_NBIOT_SI_TYPE_SIB1, ///< Cell access and selection, other SIB scheduling + SRSRAN_NBIOT_SI_TYPE_SIB2, ///< Radio resource configuration information + SRSRAN_NBIOT_SI_TYPE_SIB3, ///< Cell re-selection information for intra-frequency, inter-frequency + SRSRAN_NBIOT_SI_TYPE_SIB4, ///< Neighboring cell related information relevant for intra-frequency cell re-selection + SRSRAN_NBIOT_SI_TYPE_SIB5, ///< Neighboring cell related information relevant for inter-frequency cell re-selection + SRSRAN_NBIOT_SI_TYPE_SIB14, ///< Access Barring parameters + SRSRAN_NBIOT_SI_TYPE_SIB16, ///< Information related to GPS time and Coordinated Universal Time (UTC) + SRSRAN_NBIOT_SI_TYPE_NITEMS +} srsran_nbiot_si_type_t; + +typedef struct SRSRAN_API { bool has_sib1; ///< Whether this NPDSCH carries SystemInformationBlockType1-NB bool is_ra; ///< Order is set to 1 for random access procedure uint32_t nprach_start; ///< Starting number for NPRACH repetitions @@ -64,39 +64,39 @@ typedef struct SRSLTE_API { uint32_t harq_ack; ///< HARQ-ACK resource uint32_t dci_sf_rep_num; ///< DCI subframe repetition number uint32_t sched_info_sib1; ///< broadcasted through MIB-NB for TBS calculation -} srslte_ra_nbiot_t; +} srsran_ra_nbiot_t; /// This shall be replaced/moved by proper structures and packing/unpacking based on ASN1 -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { uint32_t n; ///< Index of entry in schedulingInfoList uint32_t si_periodicity; uint32_t si_radio_frame_offset; uint32_t si_repetition_pattern; uint32_t si_tb; uint32_t si_window_length; -} srslte_nbiot_si_params_t; - -typedef enum SRSLTE_API { - SRSLTE_NPUSCH_FORMAT1 = 0, - SRSLTE_NPUSCH_FORMAT2, - SRSLTE_NPUSCH_FORMAT_NITEMS -} srslte_npusch_format_t; -static const char srslte_npusch_format_text[SRSLTE_NPUSCH_FORMAT_NITEMS][20] = {"Format 1 (UL-SCH)", "Format 2 (UCI)"}; - -typedef enum SRSLTE_API { - SRSLTE_NPUSCH_SC_SPACING_15000 = 0, - SRSLTE_NPUSCH_SC_SPACING_3750 = 1, - SRSLTE_NPUSCH_SC_SPACING_NITEMS -} srslte_npusch_sc_spacing_t; -static const char srslte_npusch_sc_spacing_text[SRSLTE_NPUSCH_SC_SPACING_NITEMS][20] = {"15kHz", "3.75kHz"}; +} srsran_nbiot_si_params_t; + +typedef enum SRSRAN_API { + SRSRAN_NPUSCH_FORMAT1 = 0, + SRSRAN_NPUSCH_FORMAT2, + SRSRAN_NPUSCH_FORMAT_NITEMS +} srsran_npusch_format_t; +static const char srsran_npusch_format_text[SRSRAN_NPUSCH_FORMAT_NITEMS][20] = {"Format 1 (UL-SCH)", "Format 2 (UCI)"}; + +typedef enum SRSRAN_API { + SRSRAN_NPUSCH_SC_SPACING_15000 = 0, + SRSRAN_NPUSCH_SC_SPACING_3750 = 1, + SRSRAN_NPUSCH_SC_SPACING_NITEMS +} srsran_npusch_sc_spacing_t; +static const char srsran_npusch_sc_spacing_text[SRSRAN_NPUSCH_SC_SPACING_NITEMS][20] = {"15kHz", "3.75kHz"}; /************************************************** * Structures used for Downlink Resource Allocation **************************************************/ -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { uint32_t Qm; - srslte_ra_tb_t mcs[SRSLTE_MAX_TB]; + srsran_ra_tb_t mcs[SRSRAN_MAX_TB]; uint32_t start_hfn; uint32_t start_sfn; uint32_t start_sfidx; @@ -106,14 +106,14 @@ typedef struct SRSLTE_API { uint32_t l_start; uint32_t ack_nack_resource; - srslte_nbiot_mode_t mode; ///< needed to compute starting symbol for NPDSCH + srsran_nbiot_mode_t mode; ///< needed to compute starting symbol for NPDSCH bool has_sib1; -} srslte_ra_nbiot_dl_grant_t; +} srsran_ra_nbiot_dl_grant_t; /// Unpacked DCI message for DL grant -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { uint32_t format; ///< Flag for format N0/format N1 differentiation – 1 bit, 0 for format N0 and value 1 for format N1 - srslte_ra_nbiot_t alloc; + srsran_ra_nbiot_t alloc; uint32_t mcs_idx; int rv_idx; @@ -122,13 +122,13 @@ typedef struct SRSLTE_API { // Format N2 specifics bool dci_is_n2; uint8_t dir_indication_info; -} srslte_ra_nbiot_dl_dci_t; +} srsran_ra_nbiot_dl_dci_t; /// Structures used for Uplink Resource Allocation /// Unpacked DCI message -typedef struct SRSLTE_API { - srslte_npusch_sc_spacing_t sc_spacing; +typedef struct SRSRAN_API { + srsran_npusch_sc_spacing_t sc_spacing; uint32_t format; ///< Flag for format N0/format N1 differentiation – 1 bit, 0 for format N0 and value 1 for format N1 uint32_t i_sc; ///< Subcarrier indication field uint32_t i_delay; ///< Scheduling delay @@ -138,29 +138,29 @@ typedef struct SRSLTE_API { uint32_t i_rep; ///< Repetition number bool ndi; ///< New data indicator uint32_t dci_sf_rep_num; ///< DCI subframe repetition number -} srslte_ra_nbiot_ul_dci_t; +} srsran_ra_nbiot_ul_dci_t; -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { uint32_t Qm; - srslte_ra_tb_t mcs; + srsran_ra_tb_t mcs; uint32_t k0; ///< TODO: consider removing k0 and compute tx_tti directly uint32_t nof_rep; ///< number of repetitions uint32_t nof_ru; ///< Number of resource units uint32_t nof_slots; uint32_t nof_sc; ///< The total number of Subcarriers (N_sc_RU) - uint32_t sc_alloc_set[SRSLTE_NPUSCH_MAX_SC]; ///< The set of subcarriers + uint32_t sc_alloc_set[SRSRAN_NPUSCH_MAX_SC]; ///< The set of subcarriers uint32_t rv_idx; uint32_t tx_tti; - srslte_npusch_sc_spacing_t sc_spacing; - srslte_npusch_format_t format; -} srslte_ra_nbiot_ul_grant_t; + srsran_npusch_sc_spacing_t sc_spacing; + srsran_npusch_format_t format; +} srsran_ra_nbiot_ul_grant_t; typedef union { - srslte_ra_nbiot_ul_grant_t ul; - srslte_ra_nbiot_dl_grant_t dl; -} srslte_nbiot_phy_grant_t; + srsran_ra_nbiot_ul_grant_t ul; + srsran_ra_nbiot_dl_grant_t dl; +} srsran_nbiot_phy_grant_t; -#define SRSLTE_NBIOT_PHY_GRANT_LEN sizeof(srslte_nbiot_phy_grant_t) +#define SRSRAN_NBIOT_PHY_GRANT_LEN sizeof(srsran_nbiot_phy_grant_t) /// Structure that gives the number of encoded bits and RE for a UL/DL grant typedef struct { @@ -168,49 +168,49 @@ typedef struct { uint32_t nof_symb; uint32_t nof_bits; uint32_t nof_re; -} srslte_ra_nbits_t; +} srsran_ra_nbits_t; /// According to Section 16.3.3 in TS 36.213 v13.3 -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { uint32_t sc_spacing; ///< SC spacing (1bit) uint32_t i_sc; ///< Subcarrier indication field (6bits) uint32_t i_delay; ///< Scheduling delay (2bits) uint32_t n_rep; ///< Repetition number (3bits) (Is this i_rep or N_rep?) uint32_t i_mcs; ///< MCS field (3bits), according to 16.3.3-1 -} srslte_nbiot_dci_rar_grant_t; +} srsran_nbiot_dci_rar_grant_t; /// Functions -SRSLTE_API int srslte_ra_nbiot_dl_dci_to_grant(srslte_ra_nbiot_dl_dci_t* dci, - srslte_ra_nbiot_dl_grant_t* grant, +SRSRAN_API int srsran_ra_nbiot_dl_dci_to_grant(srsran_ra_nbiot_dl_dci_t* dci, + srsran_ra_nbiot_dl_grant_t* grant, uint32_t sfn, uint32_t sf_idx, uint32_t r_max, bool is_prescheduled, - srslte_nbiot_mode_t mode); + srsran_nbiot_mode_t mode); -SRSLTE_API void srslte_ra_nbiot_dl_grant_to_nbits(srslte_ra_nbiot_dl_grant_t* grant, - srslte_nbiot_cell_t cell, +SRSRAN_API void srsran_ra_nbiot_dl_grant_to_nbits(srsran_ra_nbiot_dl_grant_t* grant, + srsran_nbiot_cell_t cell, uint32_t sf_idx, - srslte_ra_nbits_t* nbits); + srsran_ra_nbits_t* nbits); -SRSLTE_API void -srslte_ra_nbiot_ul_get_uci_grant(srslte_ra_nbiot_ul_grant_t* grant, const uint8_t resource_field, const uint32_t tti); +SRSRAN_API void +srsran_ra_nbiot_ul_get_uci_grant(srsran_ra_nbiot_ul_grant_t* grant, const uint8_t resource_field, const uint32_t tti); -SRSLTE_API int srslte_ra_nbiot_ul_dci_to_grant(srslte_ra_nbiot_ul_dci_t* dci, - srslte_ra_nbiot_ul_grant_t* grant, +SRSRAN_API int srsran_ra_nbiot_ul_dci_to_grant(srsran_ra_nbiot_ul_dci_t* dci, + srsran_ra_nbiot_ul_grant_t* grant, uint32_t rx_tti, - srslte_npusch_sc_spacing_t spacing); + srsran_npusch_sc_spacing_t spacing); -SRSLTE_API void srslte_ra_nbiot_ul_grant_to_nbits(srslte_ra_nbiot_ul_grant_t* grant, srslte_ra_nbits_t* nbits); +SRSRAN_API void srsran_ra_nbiot_ul_grant_to_nbits(srsran_ra_nbiot_ul_grant_t* grant, srsran_ra_nbits_t* nbits); -SRSLTE_API int -srslte_ra_nbiot_ul_rar_dci_to_grant(srslte_ra_nbiot_ul_dci_t* dci, srslte_ra_nbiot_ul_grant_t* grant, uint32_t rx_tti); +SRSRAN_API int +srsran_ra_nbiot_ul_rar_dci_to_grant(srsran_ra_nbiot_ul_dci_t* dci, srsran_ra_nbiot_ul_grant_t* grant, uint32_t rx_tti); -SRSLTE_API void srslte_ra_npdsch_fprint(FILE* f, srslte_ra_nbiot_dl_dci_t* ra, uint32_t nof_prb); +SRSRAN_API void srsran_ra_npdsch_fprint(FILE* f, srsran_ra_nbiot_dl_dci_t* ra, uint32_t nof_prb); -SRSLTE_API void srslte_ra_npusch_fprint(FILE* f, srslte_ra_nbiot_ul_dci_t* dci); +SRSRAN_API void srsran_ra_npusch_fprint(FILE* f, srsran_ra_nbiot_ul_dci_t* dci); -SRSLTE_API void srslte_nbiot_dl_dci_fprint(FILE* f, srslte_ra_nbiot_dl_dci_t* dci); +SRSRAN_API void srsran_nbiot_dl_dci_fprint(FILE* f, srsran_ra_nbiot_dl_dci_t* dci); /*! * Checks if TTI contains reference signal @@ -220,7 +220,7 @@ SRSLTE_API void srslte_nbiot_dl_dci_fprint(FILE* f, srslte_ra_nbiot_dl_dci_t* dc * \param tti the TTI in question * \return true if TTI contains DL ref signal */ -SRSLTE_API bool srslte_ra_nbiot_dl_has_ref_signal(uint32_t tti); +SRSRAN_API bool srsran_ra_nbiot_dl_has_ref_signal(uint32_t tti); /*! * Checks if TTI contains reference signal for standalone deployment @@ -228,7 +228,7 @@ SRSLTE_API bool srslte_ra_nbiot_dl_has_ref_signal(uint32_t tti); * \param tti the TTI in question * \return true if TTI contains DL ref signal */ -SRSLTE_API bool srslte_ra_nbiot_dl_has_ref_signal_standalone(uint32_t tti); +SRSRAN_API bool srsran_ra_nbiot_dl_has_ref_signal_standalone(uint32_t tti); /*! * Checks if TTI contains reference signal for inband deployments @@ -236,7 +236,7 @@ SRSLTE_API bool srslte_ra_nbiot_dl_has_ref_signal_standalone(uint32_t tti); * \param tti the TTI in question * \return true if TTI contains DL ref signal */ -SRSLTE_API bool srslte_ra_nbiot_dl_has_ref_signal_inband(uint32_t tti); +SRSRAN_API bool srsran_ra_nbiot_dl_has_ref_signal_inband(uint32_t tti); /*! * Checks if TTI is a valid downlink TTI, i.e., can carry either a NPDCCH or NPDSCH @@ -244,7 +244,7 @@ SRSLTE_API bool srslte_ra_nbiot_dl_has_ref_signal_inband(uint32_t tti); * \param tti the TTI in question * \return true if TTI is valid DL TTI */ -SRSLTE_API bool srslte_ra_nbiot_is_valid_dl_sf(uint32_t tti); +SRSRAN_API bool srsran_ra_nbiot_is_valid_dl_sf(uint32_t tti); /*! * Calculate the number of resource elements per subframe that carry data @@ -253,24 +253,24 @@ SRSLTE_API bool srslte_ra_nbiot_is_valid_dl_sf(uint32_t tti); * \param l_start the starting OFDM symbols that carries data * \return the number of resource elements */ -SRSLTE_API uint32_t srslte_ra_nbiot_dl_grant_nof_re(srslte_nbiot_cell_t cell, uint32_t l_start); +SRSRAN_API uint32_t srsran_ra_nbiot_dl_grant_nof_re(srsran_nbiot_cell_t cell, uint32_t l_start); -SRSLTE_API void srslte_ra_nbiot_dl_grant_fprint(FILE* f, srslte_ra_nbiot_dl_grant_t* grant); +SRSRAN_API void srsran_ra_nbiot_dl_grant_fprint(FILE* f, srsran_ra_nbiot_dl_grant_t* grant); -SRSLTE_API void srslte_ra_nbiot_ul_grant_fprint(FILE* f, srslte_ra_nbiot_ul_grant_t* grant); +SRSRAN_API void srsran_ra_nbiot_ul_grant_fprint(FILE* f, srsran_ra_nbiot_ul_grant_t* grant); -SRSLTE_API int srslte_ra_n_rep_sib1_nb(srslte_mib_nb_t* mib); +SRSRAN_API int srsran_ra_n_rep_sib1_nb(srsran_mib_nb_t* mib); -SRSLTE_API int srslte_ra_nbiot_get_sib1_tbs(srslte_mib_nb_t* mib); +SRSRAN_API int srsran_ra_nbiot_get_sib1_tbs(srsran_mib_nb_t* mib); -SRSLTE_API int srslte_ra_nbiot_get_npdsch_tbs(uint32_t i_tbs, uint32_t i_sf); +SRSRAN_API int srsran_ra_nbiot_get_npdsch_tbs(uint32_t i_tbs, uint32_t i_sf); -SRSLTE_API int srslte_ra_nbiot_get_npusch_tbs(uint32_t i_tbs, uint32_t i_ru); +SRSRAN_API int srsran_ra_nbiot_get_npusch_tbs(uint32_t i_tbs, uint32_t i_ru); -SRSLTE_API int srslte_ra_nbiot_get_starting_sib1_frame(uint32_t cell_id, srslte_mib_nb_t* mib); +SRSRAN_API int srsran_ra_nbiot_get_starting_sib1_frame(uint32_t cell_id, srsran_mib_nb_t* mib); -SRSLTE_API int srslte_ra_nbiot_sib1_start(uint32_t n_id_ncell, srslte_mib_nb_t* mib); +SRSRAN_API int srsran_ra_nbiot_sib1_start(uint32_t n_id_ncell, srsran_mib_nb_t* mib); -SRSLTE_API float srslte_ra_nbiot_get_delta_f(srslte_npusch_sc_spacing_t spacing); +SRSRAN_API float srsran_ra_nbiot_get_delta_f(srsran_npusch_sc_spacing_t spacing); -#endif // SRSLTE_RA_NBIOT_H +#endif // SRSRAN_RA_NBIOT_H diff --git a/lib/include/srslte/phy/phch/ra_nr.h b/lib/include/srsran/phy/phch/ra_nr.h similarity index 66% rename from lib/include/srslte/phy/phch/ra_nr.h rename to lib/include/srsran/phy/phch/ra_nr.h index ba272f4f1..546d20eca 100644 --- a/lib/include/srslte/phy/phch/ra_nr.h +++ b/lib/include/srsran/phy/phch/ra_nr.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -18,16 +18,16 @@ * Reference: 3GPP TS 38.214 version 15.10.0 *****************************************************************************/ -#ifndef SRSLTE_RA_NR_H -#define SRSLTE_RA_NR_H +#ifndef SRSRAN_RA_NR_H +#define SRSRAN_RA_NR_H #include #include -#include "srslte/config.h" -#include "srslte/phy/common/phy_common_nr.h" -#include "srslte/phy/phch/dci_nr.h" -#include "srslte/phy/phch/phch_cfg_nr.h" +#include "srsran/config.h" +#include "srsran/phy/common/phy_common_nr.h" +#include "srsran/phy/phch/dci_nr.h" +#include "srsran/phy/phch/phch_cfg_nr.h" /** * @brief Determines target rate @@ -38,10 +38,10 @@ * @param mcs_idx Desired Modulation Coding Scheme (MCS) index * @return The target rate if provided information is valid. Otherwise, it returns NAN */ -SRSLTE_API double srslte_ra_nr_R_from_mcs(srslte_mcs_table_t mcs_table, - srslte_dci_format_nr_t dci_format, - srslte_search_space_type_t search_space_type, - srslte_rnti_type_t rnti_type, +SRSRAN_API double srsran_ra_nr_R_from_mcs(srsran_mcs_table_t mcs_table, + srsran_dci_format_nr_t dci_format, + srsran_search_space_type_t search_space_type, + srsran_rnti_type_t rnti_type, uint32_t mcs_idx); /** @@ -51,21 +51,21 @@ SRSLTE_API double srslte_ra_nr_R_from_mcs(srslte_mcs_table_t mcs_table, * @param search_space_type Search space type * @param rnti_type RNTI type * @param mcs_idx Desired Modulation Coding Scheme (MCS) index - * @return The selected modulation if provided information is valid. Otherwise, it returns SRSLTE_MOD_NITEMS + * @return The selected modulation if provided information is valid. Otherwise, it returns SRSRAN_MOD_NITEMS */ -SRSLTE_API srslte_mod_t srslte_ra_nr_mod_from_mcs(srslte_mcs_table_t mcs_table, - srslte_dci_format_nr_t dci_format, - srslte_search_space_type_t search_space_type, - srslte_rnti_type_t rnti_type, +SRSRAN_API srsran_mod_t srsran_ra_nr_mod_from_mcs(srsran_mcs_table_t mcs_table, + srsran_dci_format_nr_t dci_format, + srsran_search_space_type_t search_space_type, + srsran_rnti_type_t rnti_type, uint32_t mcs_idx); /** * @brief Determines the number of resource elements available for a given PDSCH transmission * @param pdsch_cfg PDSCH configuration provided by higher layers * @param grant The given PDSCH transmission grant - * @return The number of resource elements if the provided configuration is valid, otherwise SRSLTE_ERROR code + * @return The number of resource elements if the provided configuration is valid, otherwise SRSRAN_ERROR code */ -SRSLTE_API int srslte_ra_dl_nr_slot_nof_re(const srslte_sch_cfg_nr_t* pdsch_cfg, const srslte_sch_grant_nr_t* grant); +SRSRAN_API int srsran_ra_dl_nr_slot_nof_re(const srsran_sch_cfg_nr_t* pdsch_cfg, const srsran_sch_grant_nr_t* grant); /** * @brief Calculates shared channel TBS @@ -76,12 +76,12 @@ SRSLTE_API int srslte_ra_dl_nr_slot_nof_re(const srslte_sch_cfg_nr_t* pdsch_cfg, * @param nof_layers Number of layers * @return The transport block size */ -SRSLTE_API uint32_t srslte_ra_nr_tbs(uint32_t N_re, double S, double R, uint32_t Qm, uint32_t nof_layers); +SRSRAN_API uint32_t srsran_ra_nr_tbs(uint32_t N_re, double S, double R, uint32_t Qm, uint32_t nof_layers); -SRSLTE_API int srslte_ra_nr_fill_tb(const srslte_sch_cfg_nr_t* pdsch_cfg, - const srslte_sch_grant_nr_t* grant, +SRSRAN_API int srsran_ra_nr_fill_tb(const srsran_sch_cfg_nr_t* pdsch_cfg, + const srsran_sch_grant_nr_t* grant, uint32_t mcs_idx, - srslte_sch_tb_t* tb); + srsran_sch_tb_t* tb); /** * @brief Converts an unpacked DL DCI message to a PDSCH grant structure. * Implements the procedures defined in Section 5 of 38.214 to compute the resource allocation (5.1.2) @@ -95,11 +95,11 @@ SRSLTE_API int srslte_ra_nr_fill_tb(const srslte_sch_cfg_nr_t* pdsch_cfg, * @param pdsch_grant Generated PDSCH grant * @return 0 on success, -1 on error */ -SRSLTE_API int srslte_ra_dl_dci_to_grant_nr(const srslte_carrier_nr_t* carrier, - const srslte_sch_hl_cfg_nr_t* pdsch_cfg, - const srslte_dci_dl_nr_t* dci_dl, - srslte_sch_cfg_nr_t* cfg, - srslte_sch_grant_nr_t* pdsch_grant); +SRSRAN_API int srsran_ra_dl_dci_to_grant_nr(const srsran_carrier_nr_t* carrier, + const srsran_sch_hl_cfg_nr_t* pdsch_cfg, + const srsran_dci_dl_nr_t* dci_dl, + srsran_sch_cfg_nr_t* cfg, + srsran_sch_grant_nr_t* pdsch_grant); /** * @brief Converts an unpacked UL DCI message to a PUSCH grant structure. @@ -115,11 +115,11 @@ SRSLTE_API int srslte_ra_dl_dci_to_grant_nr(const srslte_carrier_nr_t* carrie * @param pusch_grant Generated PUSCH grant * @return 0 on success, -1 on error */ -SRSLTE_API int srslte_ra_ul_dci_to_grant_nr(const srslte_carrier_nr_t* carrier, - const srslte_sch_hl_cfg_nr_t* pusch_hl_cfg, - const srslte_dci_ul_nr_t* dci_ul, - srslte_sch_cfg_nr_t* pusch_cfg, - srslte_sch_grant_nr_t* pusch_grant); +SRSRAN_API int srsran_ra_ul_dci_to_grant_nr(const srsran_carrier_nr_t* carrier, + const srsran_sch_hl_cfg_nr_t* pusch_hl_cfg, + const srsran_dci_ul_nr_t* dci_ul, + srsran_sch_cfg_nr_t* pusch_cfg, + srsran_sch_grant_nr_t* pusch_grant); /** * @brief Set up the Uplink Control Information configuration for a PUSCH transmission @@ -129,10 +129,10 @@ SRSLTE_API int srslte_ra_ul_dci_to_grant_nr(const srslte_carrier_nr_t* carrie * @param pusch_hl_cfg PUSCH configuration provided by higher layers * @param uci_cfg Uplink Control Information configuration for this PUSCH transmission * @param pusch_cfg PUSCH configuration after applying the procedure - * @return SRSLTE_SUCCESS if the procedure is successful, SRSLTE_ERROR code otherwise + * @return SRSRAN_SUCCESS if the procedure is successful, SRSRAN_ERROR code otherwise */ -SRSLTE_API int srslte_ra_ul_set_grant_uci_nr(const srslte_sch_hl_cfg_nr_t* pusch_hl_cfg, - const srslte_uci_cfg_nr_t* uci_cfg, - srslte_sch_cfg_nr_t* pusch_cfg); +SRSRAN_API int srsran_ra_ul_set_grant_uci_nr(const srsran_sch_hl_cfg_nr_t* pusch_hl_cfg, + const srsran_uci_cfg_nr_t* uci_cfg, + srsran_sch_cfg_nr_t* pusch_cfg); -#endif // SRSLTE_RA_NR_H +#endif // SRSRAN_RA_NR_H diff --git a/lib/include/srslte/phy/phch/ra_sl.h b/lib/include/srsran/phy/phch/ra_sl.h similarity index 85% rename from lib/include/srslte/phy/phch/ra_sl.h rename to lib/include/srsran/phy/phch/ra_sl.h index 55e379ef6..ec779a1de 100644 --- a/lib/include/srslte/phy/phch/ra_sl.h +++ b/lib/include/srsran/phy/phch/ra_sl.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,12 +10,12 @@ * */ -#ifndef SRSLTE_RA_SL_H -#define SRSLTE_RA_SL_H +#ifndef SRSRAN_RA_SL_H +#define SRSRAN_RA_SL_H -SRSLTE_API int srslte_sl_get_available_pool_prb(uint32_t prb_num, uint32_t prb_start, uint32_t prb_end); +SRSRAN_API int srsran_sl_get_available_pool_prb(uint32_t prb_num, uint32_t prb_start, uint32_t prb_end); -SRSLTE_API int srslte_pscch_resources(uint32_t prb_num, +SRSRAN_API int srsran_pscch_resources(uint32_t prb_num, uint32_t prb_start, uint32_t prb_end, uint8_t* pscch_sf_bitmap, @@ -24,21 +24,21 @@ SRSLTE_API int srslte_pscch_resources(uint32_t prb_num, uint32_t* m_a, uint32_t* l_b); -SRSLTE_API uint32_t srslte_ra_sl_type0_to_riv(uint32_t nof_prb, uint32_t prb_start, uint32_t L_crb); -SRSLTE_API void srslte_ra_sl_type0_from_riv(uint32_t riv, uint32_t nof_prb, uint32_t* L_crb, uint32_t* prb_start); -SRSLTE_API int - srslte_ra_sl_pssch_allowed_sf(uint32_t pssch_sf_idx, uint32_t trp_idx, uint32_t duplex_mode, uint32_t tdd_config); -SRSLTE_API int srslte_sci_generate_trp_idx(uint32_t duplex_mode, uint32_t tdd_config, uint32_t k_TRP); +SRSRAN_API uint32_t srsran_ra_sl_type0_to_riv(uint32_t nof_prb, uint32_t prb_start, uint32_t L_crb); +SRSRAN_API void srsran_ra_sl_type0_from_riv(uint32_t riv, uint32_t nof_prb, uint32_t* L_crb, uint32_t* prb_start); +SRSRAN_API int + srsran_ra_sl_pssch_allowed_sf(uint32_t pssch_sf_idx, uint32_t trp_idx, uint32_t duplex_mode, uint32_t tdd_config); +SRSRAN_API int srsran_sci_generate_trp_idx(uint32_t duplex_mode, uint32_t tdd_config, uint32_t k_TRP); // TS 36.213 table 14.1.1.1.1-3: Time Resource pattern Index mapping for N_TRP = 6 -static const uint8_t srslte_sl_N_TRP_6_k_1[] = {1, 2, 4, 8, 16, 32}; -static const uint8_t srslte_sl_N_TRP_6_k_2[] = {3, 5, 6, 9, 10, 12, 17, 18, 20, 24, 33, 34, 36, 40, 48}; -static const uint8_t srslte_sl_N_TRP_6_k_3[] = {7, 11, 13, 14, 19, 21, 22, 25, 26, 28, +static const uint8_t srsran_sl_N_TRP_6_k_1[] = {1, 2, 4, 8, 16, 32}; +static const uint8_t srsran_sl_N_TRP_6_k_2[] = {3, 5, 6, 9, 10, 12, 17, 18, 20, 24, 33, 34, 36, 40, 48}; +static const uint8_t srsran_sl_N_TRP_6_k_3[] = {7, 11, 13, 14, 19, 21, 22, 25, 26, 28, 35, 37, 38, 41, 42, 44, 49, 50, 52, 56}; -static const uint8_t srslte_sl_N_TRP_6_k_4[] = {15, 23, 27, 29, 30, 39, 43, 45, 46, 51, 53, 54, 57, 58, 60}; -static const uint8_t srslte_sl_N_TRP_6_k_5[] = {31, 47, 55, 59, 61, 62}; -static const uint8_t srslte_sl_N_TRP_6_k_6[] = {63}; -static const uint8_t srslte_sl_N_TRP_6[][6] = { +static const uint8_t srsran_sl_N_TRP_6_k_4[] = {15, 23, 27, 29, 30, 39, 43, 45, 46, 51, 53, 54, 57, 58, 60}; +static const uint8_t srsran_sl_N_TRP_6_k_5[] = {31, 47, 55, 59, 61, 62}; +static const uint8_t srsran_sl_N_TRP_6_k_6[] = {63}; +static const uint8_t srsran_sl_N_TRP_6[][6] = { {0, 0, 0, 0, 0, 0}, {1, 0, 0, 0, 0, 0}, {0, 1, 0, 0, 0, 0}, {1, 1, 0, 0, 0, 0}, {0, 0, 1, 0, 0, 0}, {1, 0, 1, 0, 0, 0}, {0, 1, 1, 0, 0, 0}, {1, 1, 1, 0, 0, 0}, {0, 0, 0, 1, 0, 0}, {1, 0, 0, 1, 0, 0}, {0, 1, 0, 1, 0, 0}, {1, 1, 0, 1, 0, 0}, {0, 0, 1, 1, 0, 0}, {1, 0, 1, 1, 0, 0}, {0, 1, 1, 1, 0, 0}, @@ -54,20 +54,20 @@ static const uint8_t srslte_sl_N_TRP_6[][6] = { {0, 0, 1, 1, 1, 1}, {1, 0, 1, 1, 1, 1}, {0, 1, 1, 1, 1, 1}, {1, 1, 1, 1, 1, 1}}; // TS 36.213 table 14.1.1.1.1-2: Time Resource pattern Index mapping for N_TRP = 7 -static const uint8_t srslte_sl_N_TRP_7_k_1[] = {1, 2, 4, 8, 16, 32, 64}; -static const uint8_t srslte_sl_N_TRP_7_k_2[] = {3, 5, 6, 9, 10, 12, 17, 18, 20, 24, 33, +static const uint8_t srsran_sl_N_TRP_7_k_1[] = {1, 2, 4, 8, 16, 32, 64}; +static const uint8_t srsran_sl_N_TRP_7_k_2[] = {3, 5, 6, 9, 10, 12, 17, 18, 20, 24, 33, 34, 36, 40, 48, 65, 66, 68, 72, 80, 96}; -static const uint8_t srslte_sl_N_TRP_7_k_3[] = {7, 11, 13, 14, 19, 21, 22, 25, 26, 28, 35, 37, +static const uint8_t srsran_sl_N_TRP_7_k_3[] = {7, 11, 13, 14, 19, 21, 22, 25, 26, 28, 35, 37, 38, 41, 42, 44, 49, 50, 52, 56, 67, 69, 70, 73, 74, 76, 81, 82, 84, 88, 97, 98, 100, 104, 112}; -static const uint8_t srslte_sl_N_TRP_7_k_4[] = {15, 23, 27, 29, 30, 39, 43, 45, 46, 51, 53, 54, +static const uint8_t srsran_sl_N_TRP_7_k_4[] = {15, 23, 27, 29, 30, 39, 43, 45, 46, 51, 53, 54, 57, 58, 60, 71, 75, 77, 78, 83, 85, 86, 89, 90, 92, 99, 101, 102, 105, 106, 108, 113, 114, 116, 120}; -static const uint8_t srslte_sl_N_TRP_7_k_5[] = {31, 47, 55, 59, 61, 62, 79, 87, 91, 93, 94, +static const uint8_t srsran_sl_N_TRP_7_k_5[] = {31, 47, 55, 59, 61, 62, 79, 87, 91, 93, 94, 103, 107, 109, 110, 115, 117, 118, 121, 122, 124}; -static const uint8_t srslte_sl_N_TRP_7_k_6[] = {63, 95, 111, 119, 123, 125, 126}; -static const uint8_t srslte_sl_N_TRP_7_k_7[] = {127}; -static const uint8_t srslte_sl_N_TRP_7[][7] = { +static const uint8_t srsran_sl_N_TRP_7_k_6[] = {63, 95, 111, 119, 123, 125, 126}; +static const uint8_t srsran_sl_N_TRP_7_k_7[] = {127}; +static const uint8_t srsran_sl_N_TRP_7[][7] = { {0, 0, 0, 0, 0, 0, 0}, {1, 0, 0, 0, 0, 0, 0}, {0, 1, 0, 0, 0, 0, 0}, {1, 1, 0, 0, 0, 0, 0}, {0, 0, 1, 0, 0, 0, 0}, {1, 0, 1, 0, 0, 0, 0}, {0, 1, 1, 0, 0, 0, 0}, {1, 1, 1, 0, 0, 0, 0}, {0, 0, 0, 1, 0, 0, 0}, {1, 0, 0, 1, 0, 0, 0}, {0, 1, 0, 1, 0, 0, 0}, {1, 1, 0, 1, 0, 0, 0}, {0, 0, 1, 1, 0, 0, 0}, {1, 0, 1, 1, 0, 0, 0}, {0, 1, 1, 1, 0, 0, 0}, @@ -96,15 +96,15 @@ static const uint8_t srslte_sl_N_TRP_7[][7] = { {1, 0, 1, 1, 1, 1, 1}, {0, 1, 1, 1, 1, 1, 1}, {1, 1, 1, 1, 1, 1, 1}}; // TS 36.213 table 14.1.1.1.1-1: Time Resource pattern Index mapping for N_TRP = 8 -static const uint8_t srslte_sl_N_TRP_8_k_1[] = {0, 1, 2, 3, 4, 5, 6, 7}; -static const uint8_t srslte_sl_N_TRP_8_k_2[] = {8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, +static const uint8_t srsran_sl_N_TRP_8_k_1[] = {0, 1, 2, 3, 4, 5, 6, 7}; +static const uint8_t srsran_sl_N_TRP_8_k_2[] = {8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35}; -static const uint8_t srslte_sl_N_TRP_8_k_4[] = { +static const uint8_t srsran_sl_N_TRP_8_k_4[] = { 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105}; -static const uint8_t srslte_sl_N_TRP_8_k_8[] = {106}; -static const uint8_t srslte_sl_N_TRP_8[][8] = { +static const uint8_t srsran_sl_N_TRP_8_k_8[] = {106}; +static const uint8_t srsran_sl_N_TRP_8[][8] = { {1, 0, 0, 0, 0, 0, 0, 0}, {0, 1, 0, 0, 0, 0, 0, 0}, {0, 0, 1, 0, 0, 0, 0, 0}, {0, 0, 0, 1, 0, 0, 0, 0}, {0, 0, 0, 0, 1, 0, 0, 0}, {0, 0, 0, 0, 0, 1, 0, 0}, {0, 0, 0, 0, 0, 0, 1, 0}, {0, 0, 0, 0, 0, 0, 0, 1}, {1, 1, 0, 0, 0, 0, 0, 0}, {1, 0, 1, 0, 0, 0, 0, 0}, {0, 1, 1, 0, 0, 0, 0, 0}, {1, 0, 0, 1, 0, 0, 0, 0}, @@ -133,4 +133,4 @@ static const uint8_t srslte_sl_N_TRP_8[][8] = { {0, 0, 0, 1, 1, 0, 1, 1}, {1, 0, 0, 0, 0, 1, 1, 1}, {0, 1, 0, 0, 0, 1, 1, 1}, {0, 0, 1, 0, 0, 1, 1, 1}, {0, 0, 0, 1, 0, 1, 1, 1}, {0, 0, 0, 0, 1, 1, 1, 1}, {1, 1, 1, 1, 1, 1, 1, 1}}; -#endif // SRSLTE_RA_SL_H +#endif // SRSRAN_RA_SL_H diff --git a/lib/include/srsran/phy/phch/ra_ul.h b/lib/include/srsran/phy/phch/ra_ul.h new file mode 100644 index 000000000..53390db6c --- /dev/null +++ b/lib/include/srsran/phy/phch/ra_ul.h @@ -0,0 +1,60 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +/****************************************************************************** + * File: ra_ul.h + * + * Description: Implements Resource allocation Procedures for UL defined in Sections 8 + * + * Reference: 3GPP TS 36.213 version 10.0.1 Release 10 + *****************************************************************************/ + +#ifndef SRSRAN_RA_UL_H +#define SRSRAN_RA_UL_H + +#include +#include + +#include "srsran/config.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/phch/dci.h" +#include "srsran/phy/phch/pusch_cfg.h" + +// Structure for PUSCH frequency hopping procedure +typedef struct SRSRAN_API { + bool initialized; + srsran_cell_t cell; + srsran_sequence_t seq_type2_fo; +} srsran_ra_ul_pusch_hopping_t; + +SRSRAN_API int srsran_ra_ul_pusch_hopping_init(srsran_ra_ul_pusch_hopping_t* q, srsran_cell_t cell); + +SRSRAN_API void srsran_ra_ul_pusch_hopping_free(srsran_ra_ul_pusch_hopping_t* q); + +SRSRAN_API void srsran_ra_ul_pusch_hopping(srsran_ra_ul_pusch_hopping_t* q, + srsran_ul_sf_cfg_t* sf, + srsran_pusch_hopping_cfg_t* hopping_cfg, + srsran_pusch_grant_t* grant); + +/** Functions to generate a grant from a received DCI */ +SRSRAN_API int srsran_ra_ul_dci_to_grant(srsran_cell_t* cell, + srsran_ul_sf_cfg_t* sf, + srsran_pusch_hopping_cfg_t* hopping_cfg, + srsran_dci_ul_t* dci, + srsran_pusch_grant_t* grant); + +SRSRAN_API void srsran_ra_ul_compute_nof_re(srsran_pusch_grant_t* grant, srsran_cp_t cp, uint32_t N_srs); + +/** Others */ +SRSRAN_API uint32_t srsran_ra_ul_info(const srsran_pusch_grant_t* grant, char* info_str, uint32_t len); + +#endif // SRSRAN_RA_UL_H diff --git a/lib/include/srslte/phy/phch/ra_ul_nr.h b/lib/include/srsran/phy/phch/ra_ul_nr.h similarity index 61% rename from lib/include/srslte/phy/phch/ra_ul_nr.h rename to lib/include/srsran/phy/phch/ra_ul_nr.h index 346ca91ed..4fb80dce7 100644 --- a/lib/include/srslte/phy/phch/ra_ul_nr.h +++ b/lib/include/srsran/phy/phch/ra_ul_nr.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,13 +10,13 @@ * */ -#ifndef SRSLTE_RA_UL_NR_H -#define SRSLTE_RA_UL_NR_H +#ifndef SRSRAN_RA_UL_NR_H +#define SRSRAN_RA_UL_NR_H #include "dci_nr.h" -#include "srslte/config.h" -#include "srslte/phy/phch/phch_cfg_nr.h" -#include "srslte/phy/phch/pucch_cfg_nr.h" +#include "srsran/config.h" +#include "srsran/phy/phch/phch_cfg_nr.h" +#include "srsran/phy/phch/pucch_cfg_nr.h" #include "uci_cfg_nr.h" /** @@ -31,14 +31,14 @@ * @param coreset_id CORESET identifier associated with the PDCCH transmission * @param m Time domain resource assignment field value m provided in DCI * @param[out] Provides grant pointer to fill - * @return Returns SRSLTE_SUCCESS if the provided allocation is valid, otherwise it returns SRSLTE_ERROR code + * @return Returns SRSRAN_SUCCESS if the provided allocation is valid, otherwise it returns SRSRAN_ERROR code */ -SRSLTE_API int srslte_ra_ul_nr_time(const srslte_sch_hl_cfg_nr_t* cfg, - const srslte_rnti_type_t rnti_type, - const srslte_search_space_type_t ss_type, +SRSRAN_API int srsran_ra_ul_nr_time(const srsran_sch_hl_cfg_nr_t* cfg, + const srsran_rnti_type_t rnti_type, + const srsran_search_space_type_t ss_type, const uint32_t coreset_id, const uint8_t m, - srslte_sch_grant_nr_t* grant); + srsran_sch_grant_nr_t* grant); /** * @brief Calculates the PUSCH time resource default A and stores it in the provided PUSCH NR grant. @@ -49,10 +49,10 @@ SRSLTE_API int srslte_ra_ul_nr_time(const srslte_sch_hl_cfg_nr_t* cfg, * @param scs_cfg Sub-carrier spacing configuration for PUSCH (μ) * @param m Time domain resource assignment field value m of the DCI * @param[out] grant PUSCH grant - * @return Returns SRSLTE_SUCCESS if the provided allocation is valid, otherwise it returns SRSLTE_ERROR code + * @return Returns SRSRAN_SUCCESS if the provided allocation is valid, otherwise it returns SRSRAN_ERROR code */ -SRSLTE_API int -srslte_ra_ul_nr_pusch_time_resource_default_A(uint32_t scs_cfg, uint32_t m, srslte_sch_grant_nr_t* grant); +SRSRAN_API int +srsran_ra_ul_nr_pusch_time_resource_default_A(uint32_t scs_cfg, uint32_t m, srsran_sch_grant_nr_t* grant); /** * @brief Calculates the number of PUSCH-DMRS CDM groups without data for DCI format 0_0 @@ -61,10 +61,10 @@ srslte_ra_ul_nr_pusch_time_resource_default_A(uint32_t scs_cfg, uint32_t m, srsl * * @param cfg PUSCH NR configuration by upper layers * @param[out] grant Provides grant pointer to fill - * @return Returns SRSLTE_SUCCESS if the provided data is valid, otherwise it returns SRSLTE_ERROR code + * @return Returns SRSRAN_SUCCESS if the provided data is valid, otherwise it returns SRSRAN_ERROR code */ -SRSLTE_API int srslte_ra_ul_nr_nof_dmrs_cdm_groups_without_data_format_0_0(const srslte_sch_cfg_nr_t* cfg, - srslte_sch_grant_nr_t* grant); +SRSRAN_API int srsran_ra_ul_nr_nof_dmrs_cdm_groups_without_data_format_0_0(const srsran_sch_cfg_nr_t* cfg, + srsran_sch_grant_nr_t* grant); /** * @brief Calculates the ratio of PUSCH EPRE to DM-RS EPRE @@ -72,17 +72,17 @@ SRSLTE_API int srslte_ra_ul_nr_nof_dmrs_cdm_groups_without_data_format_0_0(const * @remark Defined by TS 38.214 V15.10.0 Table 6.2.2-1: The ratio of PUSCH EPRE to DM-RS EPRE * * @param[out] grant Provides grant pointer to fill - * @return Returns SRSLTE_SUCCESS if the provided data is valid, otherwise it returns SRSLTE_ERROR code + * @return Returns SRSRAN_SUCCESS if the provided data is valid, otherwise it returns SRSRAN_ERROR code */ -SRSLTE_API int srslte_ra_ul_nr_dmrs_power_offset(srslte_sch_grant_nr_t* grant); +SRSRAN_API int srsran_ra_ul_nr_dmrs_power_offset(srsran_sch_grant_nr_t* grant); /** * @brief Calculates the minimum number of PRB required for transmitting NR-PUCCH Format 2, 3 or 4 * @remark Based in TS 38.213 9.2.5.1 UE procedure for multiplexing HARQ-ACK or CSI and SR in a PUCCH - * @return The number of PRB if the provided configuration is valid, SRSLTE_ERROR code otherwise + * @return The number of PRB if the provided configuration is valid, SRSRAN_ERROR code otherwise */ -SRSLTE_API int srslte_ra_ul_nr_pucch_format_2_3_min_prb(const srslte_pucch_nr_resource_t* resource, - const srslte_uci_cfg_nr_t* uci_cfg); +SRSRAN_API int srsran_ra_ul_nr_pucch_format_2_3_min_prb(const srsran_pucch_nr_resource_t* resource, + const srsran_uci_cfg_nr_t* uci_cfg); /** * @brief Calculates the PUSCH frequency resource allocation and stores it in the provided PUSCH NR grant. @@ -92,29 +92,29 @@ SRSLTE_API int srslte_ra_ul_nr_pucch_format_2_3_min_prb(const srslte_pucch_nr_re * @param cfg PDSCH NR configuration by upper layers * @param dci_dl Unpacked DCI used to schedule the PDSCH grant * @param[out] grant Provides grant pointer to fill - * @return SRSLTE_SUCCESS if the provided data is valid, SRSLTE_ERROR code otherwise + * @return SRSRAN_SUCCESS if the provided data is valid, SRSRAN_ERROR code otherwise */ -SRSLTE_API int srslte_ra_ul_nr_freq(const srslte_carrier_nr_t* carrier, - const srslte_sch_hl_cfg_nr_t* cfg, - const srslte_dci_ul_nr_t* dci_ul, - srslte_sch_grant_nr_t* grant); +SRSRAN_API int srsran_ra_ul_nr_freq(const srsran_carrier_nr_t* carrier, + const srsran_sch_hl_cfg_nr_t* cfg, + const srsran_dci_ul_nr_t* dci_ul, + srsran_sch_grant_nr_t* grant); /** * @brief Selects a valid PUCCH resource for transmission * @param pucch_cfg PUCCH configuration from upper layers * @param uci_cfg Uplink Control information configuration (and PDCCH context) * @param[out] resource Selected resource for transmitting PUCCH - * @return SRSLTE_SUCCESS if provided configuration is valid, SRSLTE_ERROR code otherwise + * @return SRSRAN_SUCCESS if provided configuration is valid, SRSRAN_ERROR code otherwise */ -SRSLTE_API int srslte_ra_ul_nr_pucch_resource(const srslte_pucch_nr_hl_cfg_t* pucch_cfg, - const srslte_uci_cfg_nr_t* uci_cfg, - srslte_pucch_nr_resource_t* resource); +SRSRAN_API int srsran_ra_ul_nr_pucch_resource(const srsran_pucch_nr_hl_cfg_t* pucch_cfg, + const srsran_uci_cfg_nr_t* uci_cfg, + srsran_pucch_nr_resource_t* resource); /** * @brief Computes the number of SR bits * @param K Number of SR transmission opportunities, including negative * @return The number of bits according to the number of SRs */ -SRSLTE_API uint32_t srslte_ra_ul_nr_nof_sr_bits(uint32_t K); +SRSRAN_API uint32_t srsran_ra_ul_nr_nof_sr_bits(uint32_t K); -#endif // SRSLTE_RA_UL_NR_H +#endif // SRSRAN_RA_UL_NR_H diff --git a/lib/include/srslte/phy/phch/regs.h b/lib/include/srsran/phy/phch/regs.h similarity index 54% rename from lib/include/srslte/phy/phch/regs.h rename to lib/include/srsran/phy/phch/regs.h index 74fc349f3..316c56c34 100644 --- a/lib/include/srslte/phy/phch/regs.h +++ b/lib/include/srsran/phy/phch/regs.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -18,11 +18,11 @@ * Reference: 3GPP TS 36.211 version 10.0.0 Release 10 *****************************************************************************/ -#ifndef SRSLTE_REGS_H -#define SRSLTE_REGS_H +#ifndef SRSRAN_REGS_H +#define SRSRAN_REGS_H -#include "srslte/config.h" -#include "srslte/phy/common/phy_common.h" +#include "srsran/config.h" +#include "srsran/phy/common/phy_common.h" #include #define REGS_PHICH_NSYM 12 @@ -33,81 +33,81 @@ #define REGS_RE_X_REG 4 -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { uint32_t k[4]; uint32_t k0; uint32_t l; bool assigned; -} srslte_regs_reg_t; +} srsran_regs_reg_t; -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { uint32_t nof_regs; - srslte_regs_reg_t** regs; -} srslte_regs_ch_t; + srsran_regs_reg_t** regs; +} srsran_regs_ch_t; -typedef struct SRSLTE_API { - srslte_cell_t cell; +typedef struct SRSRAN_API { + srsran_cell_t cell; uint32_t max_ctrl_symbols; uint32_t ngroups_phich; uint32_t ngroups_phich_m1; - srslte_phich_r_t phich_res; - srslte_phich_length_t phich_len; + srsran_phich_r_t phich_res; + srsran_phich_length_t phich_len; - srslte_regs_ch_t pcfich; - srslte_regs_ch_t* phich; // there are several phich - srslte_regs_ch_t pdcch[3]; /* PDCCH indexing, permutation and interleaving is computed for + srsran_regs_ch_t pcfich; + srsran_regs_ch_t* phich; // there are several phich + srsran_regs_ch_t pdcch[3]; /* PDCCH indexing, permutation and interleaving is computed for the three possible CFI value */ uint32_t phich_mi; uint32_t nof_regs; - srslte_regs_reg_t* regs; -} srslte_regs_t; + srsran_regs_reg_t* regs; +} srsran_regs_t; -SRSLTE_API int srslte_regs_init(srslte_regs_t* h, srslte_cell_t cell); +SRSRAN_API int srsran_regs_init(srsran_regs_t* h, srsran_cell_t cell); -SRSLTE_API int srslte_regs_init_opts(srslte_regs_t* h, srslte_cell_t cell, uint32_t phich_mi, bool mbsfn_or_sf1_6_tdd); +SRSRAN_API int srsran_regs_init_opts(srsran_regs_t* h, srsran_cell_t cell, uint32_t phich_mi, bool mbsfn_or_sf1_6_tdd); -SRSLTE_API void srslte_regs_free(srslte_regs_t* h); +SRSRAN_API void srsran_regs_free(srsran_regs_t* h); -SRSLTE_API int srslte_regs_pdcch_nregs(srslte_regs_t* h, uint32_t cfi); +SRSRAN_API int srsran_regs_pdcch_nregs(srsran_regs_t* h, uint32_t cfi); -SRSLTE_API int srslte_regs_pdcch_ncce(srslte_regs_t* h, uint32_t cfi); +SRSRAN_API int srsran_regs_pdcch_ncce(srsran_regs_t* h, uint32_t cfi); -SRSLTE_API int srslte_regs_pcfich_put(srslte_regs_t* h, cf_t symbols[REGS_PCFICH_NSYM], cf_t* slot_symbols); +SRSRAN_API int srsran_regs_pcfich_put(srsran_regs_t* h, cf_t symbols[REGS_PCFICH_NSYM], cf_t* slot_symbols); -SRSLTE_API int srslte_regs_pcfich_get(srslte_regs_t* h, cf_t* slot_symbols, cf_t symbols[REGS_PCFICH_NSYM]); +SRSRAN_API int srsran_regs_pcfich_get(srsran_regs_t* h, cf_t* slot_symbols, cf_t symbols[REGS_PCFICH_NSYM]); -SRSLTE_API uint32_t srslte_regs_phich_nregs(srslte_regs_t* h); +SRSRAN_API uint32_t srsran_regs_phich_nregs(srsran_regs_t* h); -SRSLTE_API int -srslte_regs_phich_add(srslte_regs_t* h, cf_t symbols[REGS_PHICH_NSYM], uint32_t ngroup, cf_t* slot_symbols); +SRSRAN_API int +srsran_regs_phich_add(srsran_regs_t* h, cf_t symbols[REGS_PHICH_NSYM], uint32_t ngroup, cf_t* slot_symbols); -SRSLTE_API int -srslte_regs_phich_get(srslte_regs_t* h, cf_t* slot_symbols, cf_t symbols[REGS_PHICH_NSYM], uint32_t ngroup); +SRSRAN_API int +srsran_regs_phich_get(srsran_regs_t* h, cf_t* slot_symbols, cf_t symbols[REGS_PHICH_NSYM], uint32_t ngroup); -SRSLTE_API uint32_t srslte_regs_phich_ngroups(srslte_regs_t* h); +SRSRAN_API uint32_t srsran_regs_phich_ngroups(srsran_regs_t* h); -SRSLTE_API uint32_t srslte_regs_phich_ngroups_m1(srslte_regs_t* h); +SRSRAN_API uint32_t srsran_regs_phich_ngroups_m1(srsran_regs_t* h); -SRSLTE_API int srslte_regs_phich_reset(srslte_regs_t* h, cf_t* slot_symbols); +SRSRAN_API int srsran_regs_phich_reset(srsran_regs_t* h, cf_t* slot_symbols); -SRSLTE_API int srslte_regs_pdcch_put(srslte_regs_t* h, uint32_t cfi, cf_t* d, cf_t* slot_symbols); +SRSRAN_API int srsran_regs_pdcch_put(srsran_regs_t* h, uint32_t cfi, cf_t* d, cf_t* slot_symbols); -SRSLTE_API int srslte_regs_pdcch_put_offset(srslte_regs_t* h, +SRSRAN_API int srsran_regs_pdcch_put_offset(srsran_regs_t* h, uint32_t cfi, cf_t* d, cf_t* slot_symbols, uint32_t start_reg, uint32_t nof_regs); -SRSLTE_API int srslte_regs_pdcch_get(srslte_regs_t* h, uint32_t cfi, cf_t* slot_symbols, cf_t* d); +SRSRAN_API int srsran_regs_pdcch_get(srsran_regs_t* h, uint32_t cfi, cf_t* slot_symbols, cf_t* d); -SRSLTE_API int srslte_regs_pdcch_get_offset(srslte_regs_t* h, +SRSRAN_API int srsran_regs_pdcch_get_offset(srsran_regs_t* h, uint32_t cfi, cf_t* slot_symbols, cf_t* d, uint32_t start_reg, uint32_t nof_regs); -#endif // SRSLTE_REGS_H +#endif // SRSRAN_REGS_H diff --git a/lib/include/srsran/phy/phch/sch.h b/lib/include/srsran/phy/phch/sch.h new file mode 100644 index 000000000..ed8540c8b --- /dev/null +++ b/lib/include/srsran/phy/phch/sch.h @@ -0,0 +1,133 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +/****************************************************************************** + * File: sch.h + * + * Description: Common UL and DL shared channel encode/decode functions. + * + * Reference: 3GPP TS 36.212 version 10.0.0 Release 10 + *****************************************************************************/ + +#ifndef SRSRAN_SCH_H +#define SRSRAN_SCH_H + +#include "srsran/config.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/fec/crc.h" +#include "srsran/phy/fec/turbo/rm_turbo.h" +#include "srsran/phy/fec/turbo/turbocoder.h" +#include "srsran/phy/fec/turbo/turbodecoder.h" +#include "srsran/phy/phch/pdsch_cfg.h" +#include "srsran/phy/phch/pusch_cfg.h" +#include "srsran/phy/phch/uci.h" + +#ifndef SRSRAN_RX_NULL +#define SRSRAN_RX_NULL 10000 +#endif + +#ifndef SRSRAN_TX_NULL +#define SRSRAN_TX_NULL 100 +#endif + +/* DL-SCH AND UL-SCH common functions */ +typedef struct SRSRAN_API { + + uint32_t max_iterations; + float avg_iterations; + + bool llr_is_8bit; + + /* buffers */ + uint8_t* cb_in; + uint8_t* parity_bits; + void* e; + uint8_t* temp_g_bits; + uint32_t* ul_interleaver; + srsran_uci_bit_t ack_ri_bits[57600]; // 4*M_sc*Qm_max for RI and ACK + + srsran_tcod_t encoder; + srsran_tdec_t decoder; + srsran_crc_t crc_tb; + srsran_crc_t crc_cb; + + srsran_uci_cqi_pusch_t uci_cqi; + +} srsran_sch_t; + +SRSRAN_API int srsran_sch_init(srsran_sch_t* q); + +SRSRAN_API void srsran_sch_free(srsran_sch_t* q); + +SRSRAN_API void srsran_sch_set_max_noi(srsran_sch_t* q, uint32_t max_iterations); + +SRSRAN_API float srsran_sch_last_noi(srsran_sch_t* q); + +SRSRAN_API int srsran_dlsch_encode(srsran_sch_t* q, srsran_pdsch_cfg_t* cfg, uint8_t* data, uint8_t* e_bits); + +SRSRAN_API int srsran_dlsch_encode2(srsran_sch_t* q, + srsran_pdsch_cfg_t* cfg, + uint8_t* data, + uint8_t* e_bits, + int codeword_idx, + uint32_t nof_layers); + +SRSRAN_API int srsran_dlsch_decode(srsran_sch_t* q, srsran_pdsch_cfg_t* cfg, int16_t* e_bits, uint8_t* data); + +SRSRAN_API int srsran_dlsch_decode2(srsran_sch_t* q, + srsran_pdsch_cfg_t* cfg, + int16_t* e_bits, + uint8_t* data, + int codeword_idx, + uint32_t nof_layers); + +SRSRAN_API int srsran_ulsch_encode(srsran_sch_t* q, + srsran_pusch_cfg_t* cfg, + uint8_t* data, + srsran_uci_value_t* uci_data, + uint8_t* g_bits, + uint8_t* q_bits); + +SRSRAN_API int srsran_ulsch_decode(srsran_sch_t* q, + srsran_pusch_cfg_t* cfg, + int16_t* q_bits, + int16_t* g_bits, + uint8_t* c_seq, + uint8_t* data, + srsran_uci_value_t* uci_data); + +SRSRAN_API float srsran_sch_beta_cqi(uint32_t I_cqi); + +SRSRAN_API float srsran_sch_beta_ack(uint32_t I_harq); + +SRSRAN_API uint32_t srsran_sch_find_Ioffset_ack(float beta); + +SRSRAN_API uint32_t srsran_sch_find_Ioffset_cqi(float beta); + +SRSRAN_API uint32_t srsran_sch_find_Ioffset_ri(float beta); + +///< Sidelink uses PUSCH Interleaver in all channels +SRSRAN_API void srsran_sl_ulsch_interleave(uint8_t* g_bits, + uint32_t Qm, + uint32_t H_prime_total, + uint32_t N_pusch_symbs, + uint8_t* q_bits); + +///< Sidelink uses PUSCH Deinterleaver in all channels +SRSRAN_API void srsran_sl_ulsch_deinterleave(int16_t* q_bits, + uint32_t Qm, + uint32_t H_prime_total, + uint32_t N_pusch_symbs, + int16_t* g_bits, + uint32_t* inteleaver_lut); + +#endif // SRSRAN_SCH_H \ No newline at end of file diff --git a/lib/include/srslte/phy/phch/sch_cfg_nr.h b/lib/include/srsran/phy/phch/sch_cfg_nr.h similarity index 66% rename from lib/include/srslte/phy/phch/sch_cfg_nr.h rename to lib/include/srsran/phy/phch/sch_cfg_nr.h index 4d93dd78f..2c7d548f6 100644 --- a/lib/include/srslte/phy/phch/sch_cfg_nr.h +++ b/lib/include/srsran/phy/phch/sch_cfg_nr.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,21 +10,21 @@ * */ -#ifndef SRSLTE_SCH_CFG_NR_H -#define SRSLTE_SCH_CFG_NR_H +#ifndef SRSRAN_SCH_CFG_NR_H +#define SRSRAN_SCH_CFG_NR_H -#include "srslte/phy/fec/softbuffer.h" +#include "srsran/phy/fec/softbuffer.h" -typedef struct SRSLTE_API { - srslte_mcs_table_t mcs_table; ///< @brief Indicates the MCS table the UE shall use for PDSCH and/or PUSCH without +typedef struct SRSRAN_API { + srsran_mcs_table_t mcs_table; ///< @brief Indicates the MCS table the UE shall use for PDSCH and/or PUSCH without ///< transform precoding - srslte_xoverhead_t xoverhead; ///< Accounts for overhead from CSI-RS, CORESET, etc. If the field is absent, the UE + srsran_xoverhead_t xoverhead; ///< Accounts for overhead from CSI-RS, CORESET, etc. If the field is absent, the UE ///< applies value xOh0 (see TS 38.214 [19], clause 5.1.3.2). -} srslte_sch_cfg_t; +} srsran_sch_cfg_t; -typedef struct SRSLTE_API { - srslte_mod_t mod; +typedef struct SRSRAN_API { + srsran_mod_t mod; uint32_t N_L; ///< the number of transmission layers that the transport block is mapped onto int tbs; ///< Payload size, TS 38.212 refers to it as A double R; ///< Target LDPC rate @@ -36,9 +36,9 @@ typedef struct SRSLTE_API { /// Soft-buffers pointers union { - srslte_softbuffer_tx_t* tx; - srslte_softbuffer_rx_t* rx; + srsran_softbuffer_tx_t* tx; + srsran_softbuffer_rx_t* rx; } softbuffer; -} srslte_sch_tb_t; +} srsran_sch_tb_t; -#endif // SRSLTE_SCH_CFG_NR_H +#endif // SRSRAN_SCH_CFG_NR_H diff --git a/lib/include/srslte/phy/phch/sch_nr.h b/lib/include/srsran/phy/phch/sch_nr.h similarity index 60% rename from lib/include/srslte/phy/phch/sch_nr.h rename to lib/include/srsran/phy/phch/sch_nr.h index 649e4de9f..3a730c10c 100644 --- a/lib/include/srslte/phy/phch/sch_nr.h +++ b/lib/include/srsran/phy/phch/sch_nr.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -18,58 +18,58 @@ * Reference: 3GPP TS 38.212 V15.9.0 *****************************************************************************/ -#ifndef SRSLTE_SCH_NR_H -#define SRSLTE_SCH_NR_H +#ifndef SRSRAN_SCH_NR_H +#define SRSRAN_SCH_NR_H -#include "srslte/config.h" -#include "srslte/phy/common/phy_common_nr.h" -#include "srslte/phy/fec/crc.h" -#include "srslte/phy/fec/ldpc/ldpc_decoder.h" -#include "srslte/phy/fec/ldpc/ldpc_encoder.h" -#include "srslte/phy/fec/ldpc/ldpc_rm.h" -#include "srslte/phy/phch/phch_cfg_nr.h" +#include "srsran/config.h" +#include "srsran/phy/common/phy_common_nr.h" +#include "srsran/phy/fec/crc.h" +#include "srsran/phy/fec/ldpc/ldpc_decoder.h" +#include "srsran/phy/fec/ldpc/ldpc_encoder.h" +#include "srsran/phy/fec/ldpc/ldpc_rm.h" +#include "srsran/phy/phch/phch_cfg_nr.h" -#define SRSLTE_SCH_NR_MAX_NOF_CB_LDPC \ - ((SRSLTE_SLOT_MAX_NOF_BITS_NR + (SRSLTE_LDPC_BG2_MAX_LEN_CB - 1)) / SRSLTE_LDPC_BG2_MAX_LEN_CB) +#define SRSRAN_SCH_NR_MAX_NOF_CB_LDPC \ + ((SRSRAN_SLOT_MAX_NOF_BITS_NR + (SRSRAN_LDPC_BG2_MAX_LEN_CB - 1)) / SRSRAN_LDPC_BG2_MAX_LEN_CB) -typedef struct SRSLTE_API { - srslte_carrier_nr_t carrier; +typedef struct SRSRAN_API { + srsran_carrier_nr_t carrier; /// Temporal data buffers uint8_t* temp_cb; /// CRC generators - srslte_crc_t crc_tb_24; - srslte_crc_t crc_tb_16; - srslte_crc_t crc_cb; + srsran_crc_t crc_tb_24; + srsran_crc_t crc_tb_16; + srsran_crc_t crc_cb; /// LDPC encoders - srslte_ldpc_encoder_t* encoder_bg1[MAX_LIFTSIZE + 1]; - srslte_ldpc_encoder_t* encoder_bg2[MAX_LIFTSIZE + 1]; + srsran_ldpc_encoder_t* encoder_bg1[MAX_LIFTSIZE + 1]; + srsran_ldpc_encoder_t* encoder_bg2[MAX_LIFTSIZE + 1]; /// LDPC decoders - srslte_ldpc_decoder_t* decoder_bg1[MAX_LIFTSIZE + 1]; - srslte_ldpc_decoder_t* decoder_bg2[MAX_LIFTSIZE + 1]; + srsran_ldpc_decoder_t* decoder_bg1[MAX_LIFTSIZE + 1]; + srsran_ldpc_decoder_t* decoder_bg2[MAX_LIFTSIZE + 1]; /// LDPC Rate matcher - srslte_ldpc_rm_t tx_rm; - srslte_ldpc_rm_t rx_rm; -} srslte_sch_nr_t; + srsran_ldpc_rm_t tx_rm; + srsran_ldpc_rm_t rx_rm; +} srsran_sch_nr_t; /** * @brief SCH encoder and decoder initialization arguments */ -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { bool disable_simd; bool decoder_use_flooded; float decoder_scaling_factor; -} srslte_sch_nr_args_t; +} srsran_sch_nr_args_t; /** * @brief Common SCH configuration */ typedef struct { - srslte_basegraph_t bg; ///< @brief Base graph + srsran_basegraph_t bg; ///< @brief Base graph uint32_t Qm; ///< @brief Modulation order uint32_t G; ///< Number of available bits uint32_t A; ///< @brief Payload size, TBS @@ -83,10 +83,10 @@ typedef struct { uint32_t Nref; ///< @brief N_ref parameter described in TS 38.212 V15.9.0 5.4.2.1 uint32_t Z; ///< @brief LDPC lifting size uint32_t Nl; ///< @brief Number of transmission layers that the transport block is mapped onto - bool mask[SRSLTE_SCH_NR_MAX_NOF_CB_LDPC]; ///< Indicates what codeblocks shall be encoded/decoded + bool mask[SRSRAN_SCH_NR_MAX_NOF_CB_LDPC]; ///< Indicates what codeblocks shall be encoded/decoded uint32_t C; ///< Number of codeblocks uint32_t Cp; ///< Number of codeblocks that are actually transmitted -} srslte_sch_nr_tb_info_t; +} srsran_sch_nr_tb_info_t; /** * @brief Base graph selection from a provided transport block size and target rate @@ -98,7 +98,7 @@ typedef struct { * @param R Target rate * @return it returns the selected base graph */ -SRSLTE_API srslte_basegraph_t srslte_sch_nr_select_basegraph(uint32_t tbs, double R); +SRSRAN_API srsran_basegraph_t srsran_sch_nr_select_basegraph(uint32_t tbs, double R); /** * @brief Calculates all the parameters required for performing TS 38.212 V15.9.0 5.4 General procedures for LDPC @@ -107,67 +107,67 @@ SRSLTE_API srslte_basegraph_t srslte_sch_nr_select_basegraph(uint32_t tbs, doubl * @param cfg SCH object * @return */ -SRSLTE_API int srslte_sch_nr_fill_tb_info(const srslte_carrier_nr_t* carrier, - const srslte_sch_cfg_t* sch_cfg, - const srslte_sch_tb_t* tb, - srslte_sch_nr_tb_info_t* cfg); +SRSRAN_API int srsran_sch_nr_fill_tb_info(const srsran_carrier_nr_t* carrier, + const srsran_sch_cfg_t* sch_cfg, + const srsran_sch_tb_t* tb, + srsran_sch_nr_tb_info_t* cfg); /** * @brief Initialises an SCH object as transmitter * @param q Points ats the SCH object * @param args Provides static configuration arguments - * @return SRSLTE_SUCCESS if the initialization is successful, SRSLTE_ERROR otherwise + * @return SRSRAN_SUCCESS if the initialization is successful, SRSRAN_ERROR otherwise */ -SRSLTE_API int srslte_sch_nr_init_tx(srslte_sch_nr_t* q, const srslte_sch_nr_args_t* args); +SRSRAN_API int srsran_sch_nr_init_tx(srsran_sch_nr_t* q, const srsran_sch_nr_args_t* args); /** * @brief Initialises an SCH object as receiver * @param q Points ats the SCH object * @param args Provides static configuration arguments - * @return SRSLTE_SUCCESS if the initialization is successful, SRSLTE_ERROR otherwise + * @return SRSRAN_SUCCESS if the initialization is successful, SRSRAN_ERROR otherwise */ -SRSLTE_API int srslte_sch_nr_init_rx(srslte_sch_nr_t* q, const srslte_sch_nr_args_t* args); +SRSRAN_API int srsran_sch_nr_init_rx(srsran_sch_nr_t* q, const srsran_sch_nr_args_t* args); /** * @brief Sets SCH object carrier attribute * @param q Points ats the SCH object * @param carrier Provides the NR carrier object - * @return SRSLTE_SUCCESS if the setting is successful, SRSLTE_ERROR otherwise + * @return SRSRAN_SUCCESS if the setting is successful, SRSRAN_ERROR otherwise */ -SRSLTE_API int srslte_sch_nr_set_carrier(srslte_sch_nr_t* q, const srslte_carrier_nr_t* carrier); +SRSRAN_API int srsran_sch_nr_set_carrier(srsran_sch_nr_t* q, const srsran_carrier_nr_t* carrier); /** * @brief Free allocated resources used by an SCH intance * @param q Points ats the SCH object */ -SRSLTE_API void srslte_sch_nr_free(srslte_sch_nr_t* q); +SRSRAN_API void srsran_sch_nr_free(srsran_sch_nr_t* q); -SRSLTE_API int srslte_dlsch_nr_encode(srslte_sch_nr_t* q, - const srslte_sch_cfg_t* cfg, - const srslte_sch_tb_t* tb, +SRSRAN_API int srsran_dlsch_nr_encode(srsran_sch_nr_t* q, + const srsran_sch_cfg_t* cfg, + const srsran_sch_tb_t* tb, const uint8_t* data, uint8_t* e_bits); -SRSLTE_API int srslte_dlsch_nr_decode(srslte_sch_nr_t* q, - const srslte_sch_cfg_t* sch_cfg, - const srslte_sch_tb_t* tb, +SRSRAN_API int srsran_dlsch_nr_decode(srsran_sch_nr_t* q, + const srsran_sch_cfg_t* sch_cfg, + const srsran_sch_tb_t* tb, int8_t* e_bits, uint8_t* data, bool* crc_ok); -SRSLTE_API int srslte_ulsch_nr_encode(srslte_sch_nr_t* q, - const srslte_sch_cfg_t* cfg, - const srslte_sch_tb_t* tb, +SRSRAN_API int srsran_ulsch_nr_encode(srsran_sch_nr_t* q, + const srsran_sch_cfg_t* cfg, + const srsran_sch_tb_t* tb, const uint8_t* data, uint8_t* e_bits); -SRSLTE_API int srslte_ulsch_nr_decode(srslte_sch_nr_t* q, - const srslte_sch_cfg_t* sch_cfg, - const srslte_sch_tb_t* tb, +SRSRAN_API int srsran_ulsch_nr_decode(srsran_sch_nr_t* q, + const srsran_sch_cfg_t* sch_cfg, + const srsran_sch_tb_t* tb, int8_t* e_bits, uint8_t* data, bool* crc_ok); -SRSLTE_API int srslte_sch_nr_tb_info(const srslte_sch_tb_t* tb, char* str, uint32_t str_len); +SRSRAN_API int srsran_sch_nr_tb_info(const srsran_sch_tb_t* tb, char* str, uint32_t str_len); -#endif // SRSLTE_SCH_NR_H \ No newline at end of file +#endif // SRSRAN_SCH_NR_H \ No newline at end of file diff --git a/lib/include/srslte/phy/phch/sci.h b/lib/include/srsran/phy/phch/sci.h similarity index 61% rename from lib/include/srslte/phy/phch/sci.h rename to lib/include/srsran/phy/phch/sci.h index 5666aad09..b883d81e1 100644 --- a/lib/include/srslte/phy/phch/sci.h +++ b/lib/include/srsran/phy/phch/sci.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,22 +10,22 @@ * */ -#ifndef SRSLTE_SCI_H -#define SRSLTE_SCI_H +#ifndef SRSRAN_SCI_H +#define SRSRAN_SCI_H #include #include -#include "srslte/config.h" -#include "srslte/phy/common/phy_common_sl.h" +#include "srsran/config.h" +#include "srsran/phy/common/phy_common_sl.h" -#define SRSLTE_SCI_MSG_MAX_LEN 80 +#define SRSRAN_SCI_MSG_MAX_LEN 80 -#define SRSLTE_SCI_CRC_LEN (16) -#define SRSLTE_SCI_MAX_LEN (45) -#define SRSLTE_SCI_TM34_LEN (32) +#define SRSRAN_SCI_CRC_LEN (16) +#define SRSRAN_SCI_MAX_LEN (45) +#define SRSRAN_SCI_TM34_LEN (32) -typedef enum { SRSLTE_SCI_FORMAT0 = 0, SRSLTE_SCI_FORMAT1 } srslte_sci_format_t; +typedef enum { SRSRAN_SCI_FORMAT0 = 0, SRSRAN_SCI_FORMAT1 } srsran_sci_format_t; /** * Sidelink Control Information - Sidelink (SCI0 and SCI1). @@ -34,13 +34,12 @@ typedef enum { SRSLTE_SCI_FORMAT0 = 0, SRSLTE_SCI_FORMAT1 } srslte_sci_format_t; * * Reference: 3GPP TS 36.212 version 15.6.0 Release 15 Section 5.4.3 */ -typedef struct SRSLTE_API { - - srslte_sl_tm_t tm; +typedef struct SRSRAN_API { + srsran_sl_tm_t tm; uint32_t sci_len; uint32_t nof_prb; - srslte_sci_format_t format; + srsran_sci_format_t format; // sizeSubChannel uint32_t size_sub_channel; @@ -88,15 +87,15 @@ typedef struct SRSLTE_API { // 0 means transmission format including puncturing and no TBS-scaling uint32_t transmission_format; -} srslte_sci_t; +} srsran_sci_t; -SRSLTE_API int - srslte_sci_init(srslte_sci_t* q, srslte_cell_sl_t cell, srslte_sl_comm_resource_pool_t sl_comm_resource_pool); -SRSLTE_API int srslte_sci_format0_pack(srslte_sci_t* q, uint8_t* output); -SRSLTE_API int srslte_sci_format1_pack(srslte_sci_t* q, uint8_t* output); -SRSLTE_API int srslte_sci_format0_unpack(srslte_sci_t* q, uint8_t* input); -SRSLTE_API int srslte_sci_format1_unpack(srslte_sci_t* q, uint8_t* input); -SRSLTE_API void srslte_sci_info(const srslte_sci_t* sci, char* str, uint32_t len); -SRSLTE_API void srslte_sci_free(srslte_sci_t* q); +SRSRAN_API int + srsran_sci_init(srsran_sci_t* q, srsran_cell_sl_t cell, srsran_sl_comm_resource_pool_t sl_comm_resource_pool); +SRSRAN_API int srsran_sci_format0_pack(srsran_sci_t* q, uint8_t* output); +SRSRAN_API int srsran_sci_format1_pack(srsran_sci_t* q, uint8_t* output); +SRSRAN_API int srsran_sci_format0_unpack(srsran_sci_t* q, uint8_t* input); +SRSRAN_API int srsran_sci_format1_unpack(srsran_sci_t* q, uint8_t* input); +SRSRAN_API void srsran_sci_info(const srsran_sci_t* sci, char* str, uint32_t len); +SRSRAN_API void srsran_sci_free(srsran_sci_t* q); -#endif // SRSLTE_SCI_H +#endif // SRSRAN_SCI_H diff --git a/lib/include/srslte/phy/phch/uci.h b/lib/include/srsran/phy/phch/uci.h similarity index 62% rename from lib/include/srslte/phy/phch/uci.h rename to lib/include/srsran/phy/phch/uci.h index 2fe03d433..4e5f1557c 100644 --- a/lib/include/srslte/phy/phch/uci.h +++ b/lib/include/srsran/phy/phch/uci.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -18,65 +18,65 @@ * Reference: 3GPP TS 36.212 version 10.0.0 Release 10 Sec. 5.2.3, 5.2.4 *****************************************************************************/ -#ifndef SRSLTE_UCI_H -#define SRSLTE_UCI_H - -#include "srslte/config.h" -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/fec/convolutional/viterbi.h" -#include "srslte/phy/fec/crc.h" -#include "srslte/phy/phch/pusch_cfg.h" -#include "srslte/phy/phch/uci_cfg.h" - -#define SRSLTE_UCI_MAX_CQI_LEN_PUSCH 512 -#define SRSLTE_UCI_MAX_CQI_LEN_PUCCH 13 -#define SRSLTE_UCI_CQI_CODED_PUCCH_B 20 -#define SRSLTE_UCI_STR_MAX_CHAR 32 - -typedef struct SRSLTE_API { - srslte_crc_t crc; - srslte_viterbi_t viterbi; - uint8_t tmp_cqi[SRSLTE_UCI_MAX_CQI_LEN_PUSCH]; - uint8_t encoded_cqi[3 * SRSLTE_UCI_MAX_CQI_LEN_PUSCH]; - int16_t encoded_cqi_s[3 * SRSLTE_UCI_MAX_CQI_LEN_PUSCH]; -} srslte_uci_cqi_pusch_t; - -typedef struct SRSLTE_API { +#ifndef SRSRAN_UCI_H +#define SRSRAN_UCI_H + +#include "srsran/config.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/fec/convolutional/viterbi.h" +#include "srsran/phy/fec/crc.h" +#include "srsran/phy/phch/pusch_cfg.h" +#include "srsran/phy/phch/uci_cfg.h" + +#define SRSRAN_UCI_MAX_CQI_LEN_PUSCH 512 +#define SRSRAN_UCI_MAX_CQI_LEN_PUCCH 13 +#define SRSRAN_UCI_CQI_CODED_PUCCH_B 20 +#define SRSRAN_UCI_STR_MAX_CHAR 32 + +typedef struct SRSRAN_API { + srsran_crc_t crc; + srsran_viterbi_t viterbi; + uint8_t tmp_cqi[SRSRAN_UCI_MAX_CQI_LEN_PUSCH]; + uint8_t encoded_cqi[3 * SRSRAN_UCI_MAX_CQI_LEN_PUSCH]; + int16_t encoded_cqi_s[3 * SRSRAN_UCI_MAX_CQI_LEN_PUSCH]; +} srsran_uci_cqi_pusch_t; + +typedef struct SRSRAN_API { uint8_t** cqi_table; int16_t** cqi_table_s; -} srslte_uci_cqi_pucch_t; +} srsran_uci_cqi_pucch_t; -SRSLTE_API void srslte_uci_cqi_pucch_init(srslte_uci_cqi_pucch_t* q); +SRSRAN_API void srsran_uci_cqi_pucch_init(srsran_uci_cqi_pucch_t* q); -SRSLTE_API void srslte_uci_cqi_pucch_free(srslte_uci_cqi_pucch_t* q); +SRSRAN_API void srsran_uci_cqi_pucch_free(srsran_uci_cqi_pucch_t* q); -SRSLTE_API int -srslte_uci_encode_cqi_pucch(uint8_t* cqi_data, uint32_t cqi_len, uint8_t b_bits[SRSLTE_UCI_CQI_CODED_PUCCH_B]); +SRSRAN_API int +srsran_uci_encode_cqi_pucch(uint8_t* cqi_data, uint32_t cqi_len, uint8_t b_bits[SRSRAN_UCI_CQI_CODED_PUCCH_B]); -SRSLTE_API int srslte_uci_encode_cqi_pucch_from_table(srslte_uci_cqi_pucch_t* q, +SRSRAN_API int srsran_uci_encode_cqi_pucch_from_table(srsran_uci_cqi_pucch_t* q, uint8_t* cqi_data, uint32_t cqi_len, - uint8_t b_bits[SRSLTE_UCI_CQI_CODED_PUCCH_B]); + uint8_t b_bits[SRSRAN_UCI_CQI_CODED_PUCCH_B]); -SRSLTE_API int16_t srslte_uci_decode_cqi_pucch(srslte_uci_cqi_pucch_t* q, - int16_t b_bits[SRSLTE_CQI_MAX_BITS], // aligned for simd +SRSRAN_API int16_t srsran_uci_decode_cqi_pucch(srsran_uci_cqi_pucch_t* q, + int16_t b_bits[SRSRAN_CQI_MAX_BITS], // aligned for simd uint8_t* cqi_data, uint32_t cqi_len); -SRSLTE_API int srslte_uci_cqi_init(srslte_uci_cqi_pusch_t* q); +SRSRAN_API int srsran_uci_cqi_init(srsran_uci_cqi_pusch_t* q); -SRSLTE_API void srslte_uci_cqi_free(srslte_uci_cqi_pusch_t* q); +SRSRAN_API void srsran_uci_cqi_free(srsran_uci_cqi_pusch_t* q); -SRSLTE_API int srslte_uci_encode_cqi_pusch(srslte_uci_cqi_pusch_t* q, - srslte_pusch_cfg_t* cfg, +SRSRAN_API int srsran_uci_encode_cqi_pusch(srsran_uci_cqi_pusch_t* q, + srsran_pusch_cfg_t* cfg, uint8_t* cqi_data, uint32_t cqi_len, float beta, uint32_t Q_prime_ri, uint8_t* q_bits); -SRSLTE_API int srslte_uci_decode_cqi_pusch(srslte_uci_cqi_pusch_t* q, - srslte_pusch_cfg_t* cfg, +SRSRAN_API int srsran_uci_decode_cqi_pusch(srsran_uci_cqi_pusch_t* q, + srsran_pusch_cfg_t* cfg, int16_t* q_bits, float beta, uint32_t Q_prime_ri, @@ -84,15 +84,15 @@ SRSLTE_API int srslte_uci_decode_cqi_pusch(srslte_uci_cqi_pusch_t* q, uint8_t* cqi_data, bool* cqi_ack); -SRSLTE_API int srslte_uci_encode_ack(srslte_pusch_cfg_t* cfg, +SRSRAN_API int srsran_uci_encode_ack(srsran_pusch_cfg_t* cfg, uint8_t acks[2], uint32_t nof_acks, uint32_t O_cqi, float beta, uint32_t H_prime_total, - srslte_uci_bit_t* ri_bits); + srsran_uci_bit_t* ri_bits); -SRSLTE_API int srslte_uci_encode_ack_ri(srslte_pusch_cfg_t* cfg, +SRSRAN_API int srsran_uci_encode_ack_ri(srsran_pusch_cfg_t* cfg, uint8_t* data, uint32_t O_ack, uint32_t O_cqi, @@ -100,15 +100,15 @@ SRSLTE_API int srslte_uci_encode_ack_ri(srslte_pusch_cfg_t* cfg, uint32_t H_prime_total, bool input_is_ri, uint32_t N_bundle, - srslte_uci_bit_t* ri_bits); + srsran_uci_bit_t* ri_bits); -SRSLTE_API int srslte_uci_decode_ack_ri(srslte_pusch_cfg_t* cfg, +SRSRAN_API int srsran_uci_decode_ack_ri(srsran_pusch_cfg_t* cfg, int16_t* q_bits, uint8_t* c_seq, float beta, uint32_t H_prime_total, uint32_t O_cqi, - srslte_uci_bit_t* ack_ri_bits, + srsran_uci_bit_t* ack_ri_bits, uint8_t* data, bool* valid, uint32_t nof_bits, @@ -117,13 +117,13 @@ SRSLTE_API int srslte_uci_decode_ack_ri(srslte_pusch_cfg_t* cfg, /** * Calculates the maximum number of coded symbols used by CQI-UCI over PUSCH */ -SRSLTE_API uint32_t srslte_qprime_cqi_ext(uint32_t L_prb, uint32_t nof_symbols, uint32_t tbs, float beta); +SRSRAN_API uint32_t srsran_qprime_cqi_ext(uint32_t L_prb, uint32_t nof_symbols, uint32_t tbs, float beta); /** * Calculates the maximum number of coded symbols used by ACK/RI over PUSCH */ -SRSLTE_API uint32_t -srslte_qprime_ack_ext(uint32_t L_prb, uint32_t nof_symbols, uint32_t tbs, uint32_t nof_ack, float beta); +SRSRAN_API uint32_t +srsran_qprime_ack_ext(uint32_t L_prb, uint32_t nof_symbols, uint32_t tbs, uint32_t nof_ack, float beta); /** * Calculates the number of acknowledgements carried by the Uplink Control Information (UCI) deduced from the number of @@ -132,11 +132,11 @@ srslte_qprime_ack_ext(uint32_t L_prb, uint32_t nof_symbols, uint32_t tbs, uint32 * @param uci_cfg is the UCI configuration * @return the number of acknowledgements */ -SRSLTE_API uint32_t srslte_uci_cfg_total_ack(const srslte_uci_cfg_t* uci_cfg); +SRSRAN_API uint32_t srsran_uci_cfg_total_ack(const srsran_uci_cfg_t* uci_cfg); -SRSLTE_API void srslte_uci_data_reset(srslte_uci_data_t* uci_data); +SRSRAN_API void srsran_uci_data_reset(srsran_uci_data_t* uci_data); -SRSLTE_API int -srslte_uci_data_info(srslte_uci_cfg_t* uci_cfg, srslte_uci_value_t* uci_data, char* str, uint32_t maxlen); +SRSRAN_API int +srsran_uci_data_info(srsran_uci_cfg_t* uci_cfg, srsran_uci_value_t* uci_data, char* str, uint32_t maxlen); -#endif // SRSLTE_UCI_H +#endif // SRSRAN_UCI_H diff --git a/lib/include/srsran/phy/phch/uci_cfg.h b/lib/include/srsran/phy/phch/uci_cfg.h new file mode 100644 index 000000000..6bac5c50e --- /dev/null +++ b/lib/include/srsran/phy/phch/uci_cfg.h @@ -0,0 +1,64 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +#ifndef SRSRAN_UCI_CFG_H +#define SRSRAN_UCI_CFG_H + +#include "srsran/phy/phch/cqi.h" + +#define SRSRAN_UCI_MAX_ACK_BITS 10 +#define SRSRAN_UCI_MAX_ACK_SR_BITS (SRSRAN_UCI_MAX_ACK_BITS + 1) +#define SRSRAN_UCI_MAX_M 9 + +typedef struct SRSRAN_API { + uint8_t ack_value[SRSRAN_UCI_MAX_ACK_BITS]; + bool valid; +} srsran_uci_value_ack_t; + +typedef struct SRSRAN_API { + bool pending_tb[SRSRAN_MAX_CODEWORDS]; //< Indicates whether there was a grant that requires an ACK/NACK + uint32_t nof_acks; //< Number of transport blocks, deduced from transmission mode + uint32_t ncce[SRSRAN_UCI_MAX_M]; + uint32_t N_bundle; + uint32_t tdd_ack_M; + uint32_t tdd_ack_m; + bool tdd_is_multiplex; + uint32_t tpc_for_pucch; + uint32_t grant_cc_idx; +} srsran_uci_cfg_ack_t; + +typedef struct SRSRAN_API { + srsran_uci_cfg_ack_t ack[SRSRAN_MAX_CARRIERS]; + srsran_cqi_cfg_t cqi; + bool is_scheduling_request_tti; +} srsran_uci_cfg_t; + +typedef struct SRSRAN_API { + bool scheduling_request; + srsran_cqi_value_t cqi; + srsran_uci_value_ack_t ack; + uint8_t ri; // Only 1-bit supported for RI +} srsran_uci_value_t; + +typedef struct SRSRAN_API { + srsran_uci_cfg_t cfg; + srsran_uci_value_t value; +} srsran_uci_data_t; + +typedef enum { UCI_BIT_0 = 0, UCI_BIT_1 = 1, UCI_BIT_REPETITION = 2, UCI_BIT_PLACEHOLDER = 3 } srsran_uci_bit_type_t; + +typedef struct { + uint32_t position; + srsran_uci_bit_type_t type; +} srsran_uci_bit_t; + +#endif // SRSRAN_UCI_CFG_H diff --git a/lib/include/srslte/phy/phch/uci_cfg_nr.h b/lib/include/srsran/phy/phch/uci_cfg_nr.h similarity index 73% rename from lib/include/srslte/phy/phch/uci_cfg_nr.h rename to lib/include/srsran/phy/phch/uci_cfg_nr.h index a61b3377e..b47e65507 100644 --- a/lib/include/srslte/phy/phch/uci_cfg_nr.h +++ b/lib/include/srsran/phy/phch/uci_cfg_nr.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,11 +10,11 @@ * */ -#ifndef SRSLTE_UCI_CFG_NR_H -#define SRSLTE_UCI_CFG_NR_H +#ifndef SRSRAN_UCI_CFG_NR_H +#define SRSRAN_UCI_CFG_NR_H #include "csi_cfg.h" -#include "srslte/phy/common/phy_common_nr.h" +#include "srsran/phy/common/phy_common_nr.h" #include #include @@ -22,18 +22,18 @@ * @brief Maximum number of Uplink Control Bits * @remark TS 38.212 section 5.2.1 Polar coding: The value of A is no larger than 1706. */ -#define SRSLTE_UCI_NR_MAX_NOF_BITS 1706U +#define SRSRAN_UCI_NR_MAX_NOF_BITS 1706U /** * @brief Maximum number of HARQ ACK feedback bits that can be carried in Uplink Control Information (UCI) message */ -#define SRSLTE_UCI_NR_MAX_ACK_BITS 360 +#define SRSRAN_UCI_NR_MAX_ACK_BITS 360 /** * @brief Maximum number of Channel State Information part 1 (CSI1) bits that can be carried in Uplink Control * Information (UCI) message */ -#define SRSLTE_UCI_NR_MAX_CSI1_BITS 360 +#define SRSRAN_UCI_NR_MAX_CSI1_BITS 360 /** * @brief Uplink Control Information bits configuration for PUCCH transmission @@ -45,7 +45,7 @@ typedef struct { uint32_t N_cce; ///< number of CCEs in a CORESET of a PDCCH reception with DCI format 1_0 or 1_1 uint32_t sr_resource_id; ///< Scheduling request resource identifier, only valid if positive SR bool sr_positive_present; ///< Set to true if there is at least one positive SR -} srslte_uci_nr_pucch_cfg_t; +} srsran_uci_nr_pucch_cfg_t; /** * @brief Uplink Control Information bits configuration for PUSCH transmission @@ -53,10 +53,10 @@ typedef struct { typedef struct { uint32_t l0; ///< First OFDM symbol that does not carry DMRS of the PUSCH, after the first DMRS symbol(s) uint32_t l1; ///< OFDM symbol index of the first OFDM symbol that does not carry DMRS - uint32_t M_pusch_sc[SRSLTE_NSYMB_PER_SLOT_NR]; ///< Number of potential RE for PUSCH transmission - uint32_t M_uci_sc[SRSLTE_NSYMB_PER_SLOT_NR]; ///< Number of potential RE for UCI transmission + uint32_t M_pusch_sc[SRSRAN_NSYMB_PER_SLOT_NR]; ///< Number of potential RE for PUSCH transmission + uint32_t M_uci_sc[SRSRAN_NSYMB_PER_SLOT_NR]; ///< Number of potential RE for UCI transmission uint32_t K_sum; ///< Sum of UL-SCH code block sizes, set to zero if no UL-SCH - srslte_mod_t modulation; ///< Modulation for the PUSCH + srsran_mod_t modulation; ///< Modulation for the PUSCH uint32_t nof_layers; ///< Number of layers for PUSCH float R; ///< Code rate of the PUSCH float alpha; ///< Higher layer parameter scaling @@ -64,39 +64,39 @@ typedef struct { float beta_csi1_offset; uint32_t nof_re; bool csi_part2_present; -} srslte_uci_nr_pusch_cfg_t; +} srsran_uci_nr_pusch_cfg_t; /** * @brief Uplink Control Information (UCI) message configuration */ -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { /// Common Parameters uint32_t o_ack; ///< Number of HARQ-ACK bits uint32_t o_sr; ///< Number of SR bits - srslte_csi_report_cfg_t csi[SRSLTE_CSI_MAX_NOF_REPORT]; ///< CSI report configuration + srsran_csi_report_cfg_t csi[SRSRAN_CSI_MAX_NOF_REPORT]; ///< CSI report configuration uint32_t nof_csi; ///< Number of CSI reports union { - srslte_uci_nr_pucch_cfg_t pucch; ///< Configuration for transmission in PUCCH - srslte_uci_nr_pusch_cfg_t pusch; ///< Configuration for transmission in PUSCH + srsran_uci_nr_pucch_cfg_t pucch; ///< Configuration for transmission in PUCCH + srsran_uci_nr_pusch_cfg_t pusch; ///< Configuration for transmission in PUSCH }; -} srslte_uci_cfg_nr_t; +} srsran_uci_cfg_nr_t; /** * @brief Uplink Control Information (UCI) message packed information */ -typedef struct SRSLTE_API { - uint8_t ack[SRSLTE_UCI_NR_MAX_ACK_BITS]; ///< HARQ ACK feedback bits +typedef struct SRSRAN_API { + uint8_t ack[SRSRAN_UCI_NR_MAX_ACK_BITS]; ///< HARQ ACK feedback bits uint32_t sr; ///< Number of positive SR - srslte_csi_report_value_t csi[SRSLTE_CSI_MAX_NOF_REPORT]; ///< Packed CSI report values + srsran_csi_report_value_t csi[SRSRAN_CSI_MAX_NOF_REPORT]; ///< Packed CSI report values bool valid; ///< Indicates whether the message has been decoded successfully, ignored in the transmitter -} srslte_uci_value_nr_t; +} srsran_uci_value_nr_t; /** * @brief Uplink Control Information (UCI) data (configuration + values) */ -typedef struct SRSLTE_API { - srslte_uci_cfg_nr_t cfg; - srslte_uci_value_nr_t value; -} srslte_uci_data_nr_t; +typedef struct SRSRAN_API { + srsran_uci_cfg_nr_t cfg; + srsran_uci_value_nr_t value; +} srsran_uci_data_nr_t; -#endif // SRSLTE_UCI_CFG_NR_H +#endif // SRSRAN_UCI_CFG_NR_H diff --git a/lib/include/srslte/phy/phch/uci_nr.h b/lib/include/srsran/phy/phch/uci_nr.h similarity index 61% rename from lib/include/srslte/phy/phch/uci_nr.h rename to lib/include/srsran/phy/phch/uci_nr.h index 913d769f0..94b2899fc 100644 --- a/lib/include/srslte/phy/phch/uci_nr.h +++ b/lib/include/srsran/phy/phch/uci_nr.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,17 +10,17 @@ * */ -#ifndef SRSLTE_UCI_NR_H -#define SRSLTE_UCI_NR_H +#ifndef SRSRAN_UCI_NR_H +#define SRSRAN_UCI_NR_H -#include "srslte/phy/common/phy_common_nr.h" -#include "srslte/phy/fec/crc.h" -#include "srslte/phy/fec/polar/polar_code.h" -#include "srslte/phy/fec/polar/polar_decoder.h" -#include "srslte/phy/fec/polar/polar_encoder.h" -#include "srslte/phy/fec/polar/polar_rm.h" -#include "srslte/phy/phch/phch_cfg_nr.h" -#include "srslte/phy/phch/pucch_cfg_nr.h" +#include "srsran/phy/common/phy_common_nr.h" +#include "srsran/phy/fec/crc.h" +#include "srsran/phy/fec/polar/polar_code.h" +#include "srsran/phy/fec/polar/polar_decoder.h" +#include "srsran/phy/fec/polar/polar_encoder.h" +#include "srsran/phy/fec/polar/polar_rm.h" +#include "srsran/phy/phch/phch_cfg_nr.h" +#include "srsran/phy/phch/pucch_cfg_nr.h" #include "uci_cfg_nr.h" #include #include @@ -32,52 +32,52 @@ typedef struct { bool disable_simd; ///< Disable Polar code SIMD float block_code_threshold; ///< Set normalised block code threshold (receiver only) float one_bit_threshold; ///< Decode threshold for 1 bit (receiver only) -} srslte_uci_nr_args_t; +} srsran_uci_nr_args_t; typedef struct { - srslte_polar_rm_t rm_tx; - srslte_polar_rm_t rm_rx; - srslte_polar_encoder_t encoder; - srslte_polar_decoder_t decoder; - srslte_crc_t crc6; - srslte_crc_t crc11; - srslte_polar_code_t code; + srsran_polar_rm_t rm_tx; + srsran_polar_rm_t rm_rx; + srsran_polar_encoder_t encoder; + srsran_polar_decoder_t decoder; + srsran_crc_t crc6; + srsran_crc_t crc11; + srsran_polar_code_t code; uint8_t* bit_sequence; ///< UCI bit sequence uint8_t* c; ///< UCI code-block prior encoding or after decoding uint8_t* allocated; ///< Polar code intermediate uint8_t* d; ///< Polar code encoded intermediate float block_code_threshold; ///< Decode threshold for block code (3-11 bits) float one_bit_threshold; ///< Decode threshold for 1 bit -} srslte_uci_nr_t; +} srsran_uci_nr_t; /** * @brief Calculates the number of bits carried by PUCCH formats 2, 3 and 4 from the PUCCH resource * @remark Defined in TS 38.212 Table 6.3.1.4-1: Total rate matching output sequence length Etot * @param resource PUCCH format 2, 3 or 4 Resource provided by upper layers - * @return The number of bits if the provided resource is valid, SRSLTE_ERROR code otherwise + * @return The number of bits if the provided resource is valid, SRSRAN_ERROR code otherwise */ -SRSLTE_API int srslte_uci_nr_pucch_format_2_3_4_E(const srslte_pucch_nr_resource_t* resource); +SRSRAN_API int srsran_uci_nr_pucch_format_2_3_4_E(const srsran_pucch_nr_resource_t* resource); /** * @brief Calculates in advance how many CRC bits will be appended for a given amount of UCI bits (A) * @remark Defined in TS 38.212 section 6.3.1.2 Code block segmentation and CRC attachment * @param A Number of UCI bits to transmit */ -SRSLTE_API uint32_t srslte_uci_nr_crc_len(uint32_t A); +SRSRAN_API uint32_t srsran_uci_nr_crc_len(uint32_t A); /** * @brief Initialises NR-UCI encoder/decoder object * @param[in,out] q NR-UCI object * @param[in] args Configuration arguments - * @return SRSLTE_SUCCESS if initialization is successful, SRSLTE_ERROR code otherwise + * @return SRSRAN_SUCCESS if initialization is successful, SRSRAN_ERROR code otherwise */ -SRSLTE_API int srslte_uci_nr_init(srslte_uci_nr_t* q, const srslte_uci_nr_args_t* args); +SRSRAN_API int srsran_uci_nr_init(srsran_uci_nr_t* q, const srsran_uci_nr_args_t* args); /** * @brief Deallocates NR-UCI encoder/decoder object * @param[in,out] q NR-UCI object */ -SRSLTE_API void srslte_uci_nr_free(srslte_uci_nr_t* q); +SRSRAN_API void srsran_uci_nr_free(srsran_uci_nr_t* q); /** * @brief Encodes UCI bits @@ -91,12 +91,12 @@ SRSLTE_API void srslte_uci_nr_free(srslte_uci_nr_t* q); * @param[in] uci_cfg UCI configuration * @param[in] uci_value UCI values * @param[out] o Output encoded bits - * @return Number of encoded bits if encoding is successful, SRSLTE_ERROR code otherwise + * @return Number of encoded bits if encoding is successful, SRSRAN_ERROR code otherwise */ -SRSLTE_API int srslte_uci_nr_encode_pucch(srslte_uci_nr_t* q, - const srslte_pucch_nr_resource_t* pucch_resource, - const srslte_uci_cfg_nr_t* uci_cfg, - const srslte_uci_value_nr_t* value, +SRSRAN_API int srsran_uci_nr_encode_pucch(srsran_uci_nr_t* q, + const srsran_pucch_nr_resource_t* pucch_resource, + const srsran_uci_cfg_nr_t* uci_cfg, + const srsran_uci_value_nr_t* value, uint8_t* o); /** @@ -109,20 +109,20 @@ SRSLTE_API int srslte_uci_nr_encode_pucch(srslte_uci_nr_t* q, * @param[in] uci_cfg * @param[in] llr * @param[out] value - * @return SRSLTE_SUCCESSFUL if it is successful, SRSLTE_ERROR code otherwise + * @return SRSRAN_SUCCESSFUL if it is successful, SRSRAN_ERROR code otherwise */ -SRSLTE_API int srslte_uci_nr_decode_pucch(srslte_uci_nr_t* q, - const srslte_pucch_nr_resource_t* pucch_resource_cfg, - const srslte_uci_cfg_nr_t* uci_cfg, +SRSRAN_API int srsran_uci_nr_decode_pucch(srsran_uci_nr_t* q, + const srsran_pucch_nr_resource_t* pucch_resource_cfg, + const srsran_uci_cfg_nr_t* uci_cfg, int8_t* llr, - srslte_uci_value_nr_t* value); + srsran_uci_value_nr_t* value); /** * @brief Calculates total number of encoded bits for HARQ-ACK multiplexing in PUSCH * @param[in] cfg PUSCH transmission configuration - * @return The number of encoded bits if successful, SRSLTE_ERROR code otherwise + * @return The number of encoded bits if successful, SRSRAN_ERROR code otherwise */ -SRSLTE_API int srslte_uci_nr_pusch_ack_nof_bits(const srslte_uci_nr_pusch_cfg_t* cfg, uint32_t O_ack); +SRSRAN_API int srsran_uci_nr_pusch_ack_nof_bits(const srsran_uci_nr_pusch_cfg_t* cfg, uint32_t O_ack); /** * @brief Encodes HARQ-ACK bits for PUSCH transmission @@ -130,11 +130,11 @@ SRSLTE_API int srslte_uci_nr_pusch_ack_nof_bits(const srslte_uci_nr_pusch_cfg_t* * @param[in] cfg UCI configuration * @param[in] value UCI value * @param[out] o_ack Encoded ack bits - * @return The number of encoded bits if successful, SRSLTE_ERROR code otherwise + * @return The number of encoded bits if successful, SRSRAN_ERROR code otherwise */ -SRSLTE_API int srslte_uci_nr_encode_pusch_ack(srslte_uci_nr_t* q, - const srslte_uci_cfg_nr_t* cfg, - const srslte_uci_value_nr_t* value, +SRSRAN_API int srsran_uci_nr_encode_pusch_ack(srsran_uci_nr_t* q, + const srsran_uci_cfg_nr_t* cfg, + const srsran_uci_value_nr_t* value, uint8_t* o_ack); /** @@ -143,19 +143,19 @@ SRSLTE_API int srslte_uci_nr_encode_pusch_ack(srslte_uci_nr_t* q, * @param[in] cfg UCI configuration * @param[in] llr Provides softbits LLR * @param[out] value UCI value - * @return SRSLTE_SUCCESS if the decoding process was successful, SRSLTE_ERROR code otherwise + * @return SRSRAN_SUCCESS if the decoding process was successful, SRSRAN_ERROR code otherwise */ -SRSLTE_API int srslte_uci_nr_decode_pusch_ack(srslte_uci_nr_t* q, - const srslte_uci_cfg_nr_t* cfg, +SRSRAN_API int srsran_uci_nr_decode_pusch_ack(srsran_uci_nr_t* q, + const srsran_uci_cfg_nr_t* cfg, int8_t* llr, - srslte_uci_value_nr_t* value); + srsran_uci_value_nr_t* value); /** * @brief Calculates total number of encoded bits for CSI part 1 multiplexing in PUSCH * @param[in] cfg UCI configuration - * @return The number of encoded bits if valid, SRSLTE_ERROR code otherwise + * @return The number of encoded bits if valid, SRSRAN_ERROR code otherwise */ -SRSLTE_API int srslte_uci_nr_pusch_csi1_nof_bits(const srslte_uci_cfg_nr_t* cfg); +SRSRAN_API int srsran_uci_nr_pusch_csi1_nof_bits(const srsran_uci_cfg_nr_t* cfg); /** * @brief Encodes CSI part 1 bits for PUSCH transmission @@ -163,11 +163,11 @@ SRSLTE_API int srslte_uci_nr_pusch_csi1_nof_bits(const srslte_uci_cfg_nr_t* cfg) * @param[in] cfg UCI configuration * @param[in] value UCI value * @param[out] o_ack Encoded CSI part 1 bits - * @return The number of encoded bits if successful, SRSLTE_ERROR code otherwise + * @return The number of encoded bits if successful, SRSRAN_ERROR code otherwise */ -SRSLTE_API int srslte_uci_nr_encode_pusch_csi1(srslte_uci_nr_t* q, - const srslte_uci_cfg_nr_t* cfg, - const srslte_uci_value_nr_t* value, +SRSRAN_API int srsran_uci_nr_encode_pusch_csi1(srsran_uci_nr_t* q, + const srsran_uci_cfg_nr_t* cfg, + const srsran_uci_value_nr_t* value, uint8_t* o); /** @@ -176,19 +176,19 @@ SRSLTE_API int srslte_uci_nr_encode_pusch_csi1(srslte_uci_nr_t* q, * @param[in] cfg UCI configuration * @param[in] llr Provides softbits LLR * @param[out] value UCI value - * @return SRSLTE_SUCCESS if the decoding process was successful, SRSLTE_ERROR code otherwise + * @return SRSRAN_SUCCESS if the decoding process was successful, SRSRAN_ERROR code otherwise */ -SRSLTE_API int srslte_uci_nr_decode_pusch_csi1(srslte_uci_nr_t* q, - const srslte_uci_cfg_nr_t* cfg, +SRSRAN_API int srsran_uci_nr_decode_pusch_csi1(srsran_uci_nr_t* q, + const srsran_uci_cfg_nr_t* cfg, int8_t* llr, - srslte_uci_value_nr_t* value); + srsran_uci_value_nr_t* value); /** * @brief Calculates the total number of UCI bits * @param uci_cfg UCI configuration * @return The number of total bits carrying HARQ ACK, CSI reports and SR bits */ -SRSLTE_API uint32_t srslte_uci_nr_total_bits(const srslte_uci_cfg_nr_t* uci_cfg); +SRSRAN_API uint32_t srsran_uci_nr_total_bits(const srsran_uci_cfg_nr_t* uci_cfg); /** * @brief Converts to string an UCI data structure @@ -197,6 +197,6 @@ SRSLTE_API uint32_t srslte_uci_nr_total_bits(const srslte_uci_cfg_nr_t* uci_cfg) * @param str_len String length * @return Resultant string length */ -SRSLTE_API uint32_t srslte_uci_nr_info(const srslte_uci_data_nr_t* uci_data, char* str, uint32_t str_len); +SRSRAN_API uint32_t srsran_uci_nr_info(const srsran_uci_data_nr_t* uci_data, char* str, uint32_t str_len); -#endif // SRSLTE_UCI_NR_H +#endif // SRSRAN_UCI_NR_H diff --git a/lib/include/srslte/phy/resampling/decim.h b/lib/include/srsran/phy/resampling/decim.h similarity index 63% rename from lib/include/srslte/phy/resampling/decim.h rename to lib/include/srsran/phy/resampling/decim.h index 2e3b6208b..1ea7192d6 100644 --- a/lib/include/srslte/phy/resampling/decim.h +++ b/lib/include/srsran/phy/resampling/decim.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -18,13 +18,13 @@ * Reference: *****************************************************************************/ -#ifndef SRSLTE_DECIM_H -#define SRSLTE_DECIM_H +#ifndef SRSRAN_DECIM_H +#define SRSRAN_DECIM_H -#include "srslte/config.h" +#include "srsran/config.h" -SRSLTE_API void srslte_decim_c(cf_t* input, cf_t* output, int M, int len); +SRSRAN_API void srsran_decim_c(cf_t* input, cf_t* output, int M, int len); -SRSLTE_API void srslte_decim_f(float* input, float* output, int M, int len); +SRSRAN_API void srsran_decim_f(float* input, float* output, int M, int len); -#endif // SRSLTE_DECIM_H +#endif // SRSRAN_DECIM_H diff --git a/lib/include/srslte/phy/resampling/interp.h b/lib/include/srsran/phy/resampling/interp.h similarity index 70% rename from lib/include/srslte/phy/resampling/interp.h rename to lib/include/srsran/phy/resampling/interp.h index 603d7e2e8..a8a265926 100644 --- a/lib/include/srslte/phy/resampling/interp.h +++ b/lib/include/srsran/phy/resampling/interp.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -18,28 +18,28 @@ * Reference: *****************************************************************************/ -#ifndef SRSLTE_INTERP_H -#define SRSLTE_INTERP_H +#ifndef SRSRAN_INTERP_H +#define SRSRAN_INTERP_H #include #include -#include "srslte/config.h" +#include "srsran/config.h" /************* STATIC LINEAR INTERPOLATION FUNCTIONS */ -SRSLTE_API cf_t srslte_interp_linear_onesample(cf_t input0, cf_t input1); +SRSRAN_API cf_t srsran_interp_linear_onesample(cf_t input0, cf_t input1); -SRSLTE_API cf_t srslte_interp_linear_onesample_cabs(cf_t input0, cf_t input1); +SRSRAN_API cf_t srsran_interp_linear_onesample_cabs(cf_t input0, cf_t input1); -SRSLTE_API void srslte_interp_linear_offset_cabs(cf_t* input, +SRSRAN_API void srsran_interp_linear_offset_cabs(cf_t* input, cf_t* output, uint32_t M, uint32_t len, uint32_t off_st, uint32_t off_end); -SRSLTE_API void srslte_interp_linear_f(float* input, float* output, uint32_t M, uint32_t len); +SRSRAN_API void srsran_interp_linear_f(float* input, float* output, uint32_t M, uint32_t len); /* Interpolation between vectors */ @@ -47,22 +47,22 @@ typedef struct { cf_t* diff_vec; uint32_t vector_len; uint32_t max_vector_len; -} srslte_interp_linsrslte_vec_t; +} srsran_interp_linsrsran_vec_t; -SRSLTE_API int srslte_interp_linear_vector_init(srslte_interp_linsrslte_vec_t* q, uint32_t vector_len); +SRSRAN_API int srsran_interp_linear_vector_init(srsran_interp_linsrsran_vec_t* q, uint32_t vector_len); -SRSLTE_API void srslte_interp_linear_vector_free(srslte_interp_linsrslte_vec_t* q); +SRSRAN_API void srsran_interp_linear_vector_free(srsran_interp_linsrsran_vec_t* q); -SRSLTE_API int srslte_interp_linear_vector_resize(srslte_interp_linsrslte_vec_t* q, uint32_t vector_len); +SRSRAN_API int srsran_interp_linear_vector_resize(srsran_interp_linsrsran_vec_t* q, uint32_t vector_len); -SRSLTE_API void srslte_interp_linear_vector(srslte_interp_linsrslte_vec_t* q, +SRSRAN_API void srsran_interp_linear_vector(srsran_interp_linsrsran_vec_t* q, cf_t* in0, cf_t* in1, cf_t* between, uint32_t in1_in0_d, uint32_t M); -SRSLTE_API void srslte_interp_linear_vector2(srslte_interp_linsrslte_vec_t* q, +SRSRAN_API void srsran_interp_linear_vector2(srsran_interp_linsrsran_vec_t* q, cf_t* in0, cf_t* in1, cf_t* start, @@ -70,7 +70,7 @@ SRSLTE_API void srslte_interp_linear_vector2(srslte_interp_linsrslte_vec_t* q, uint32_t in1_in0_d, uint32_t M); -SRSLTE_API void srslte_interp_linear_vector3(srslte_interp_linsrslte_vec_t* q, +SRSRAN_API void srsran_interp_linear_vector3(srsran_interp_linsrsran_vec_t* q, cf_t* in0, cf_t* in1, cf_t* start, @@ -90,15 +90,15 @@ typedef struct { uint32_t M; uint32_t max_vector_len; uint32_t max_M; -} srslte_interp_lin_t; +} srsran_interp_lin_t; -SRSLTE_API int srslte_interp_linear_init(srslte_interp_lin_t* q, uint32_t vector_len, uint32_t M); +SRSRAN_API int srsran_interp_linear_init(srsran_interp_lin_t* q, uint32_t vector_len, uint32_t M); -SRSLTE_API void srslte_interp_linear_free(srslte_interp_lin_t* q); +SRSRAN_API void srsran_interp_linear_free(srsran_interp_lin_t* q); -SRSLTE_API int srslte_interp_linear_resize(srslte_interp_lin_t* q, uint32_t vector_len, uint32_t M); +SRSRAN_API int srsran_interp_linear_resize(srsran_interp_lin_t* q, uint32_t vector_len, uint32_t M); -SRSLTE_API void -srslte_interp_linear_offset(srslte_interp_lin_t* q, cf_t* input, cf_t* output, uint32_t off_st, uint32_t off_end); +SRSRAN_API void +srsran_interp_linear_offset(srsran_interp_lin_t* q, cf_t* input, cf_t* output, uint32_t off_st, uint32_t off_end); -#endif // SRSLTE_INTERP_H +#endif // SRSRAN_INTERP_H diff --git a/lib/include/srslte/phy/resampling/resample_arb.h b/lib/include/srsran/phy/resampling/resample_arb.h similarity index 61% rename from lib/include/srslte/phy/resampling/resample_arb.h rename to lib/include/srsran/phy/resampling/resample_arb.h index 80978acb2..093bff172 100644 --- a/lib/include/srslte/phy/resampling/resample_arb.h +++ b/lib/include/srsran/phy/resampling/resample_arb.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -20,30 +20,30 @@ * fredric j. harris *****************************************************************************/ -#ifndef SRSLTE_RESAMPLE_ARB_H -#define SRSLTE_RESAMPLE_ARB_H +#ifndef SRSRAN_RESAMPLE_ARB_H +#define SRSRAN_RESAMPLE_ARB_H #include #include #include -#include "srslte/config.h" +#include "srsran/config.h" -#define SRSLTE_RESAMPLE_ARB_N_35 35 -#define SRSLTE_RESAMPLE_ARB_N 32 // Polyphase filter rows -#define SRSLTE_RESAMPLE_ARB_M 8 // Polyphase filter columns +#define SRSRAN_RESAMPLE_ARB_N_35 35 +#define SRSRAN_RESAMPLE_ARB_N 32 // Polyphase filter rows +#define SRSRAN_RESAMPLE_ARB_M 8 // Polyphase filter columns -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { float rate; // Resample rate float step; // Step increment through filter float acc; // Index into filter bool interpolate; - cf_t reg[SRSLTE_RESAMPLE_ARB_M]; // Our window of samples + cf_t reg[SRSRAN_RESAMPLE_ARB_M]; // Our window of samples -} srslte_resample_arb_t; +} srsran_resample_arb_t; -SRSLTE_API void srslte_resample_arb_init(srslte_resample_arb_t* q, float rate, bool interpolate); +SRSRAN_API void srsran_resample_arb_init(srsran_resample_arb_t* q, float rate, bool interpolate); -SRSLTE_API int srslte_resample_arb_compute(srslte_resample_arb_t* q, cf_t* input, cf_t* output, int n_in); +SRSRAN_API int srsran_resample_arb_compute(srsran_resample_arb_t* q, cf_t* input, cf_t* output, int n_in); -#endif // SRSLTE_RESAMPLE_ARB_ +#endif // SRSRAN_RESAMPLE_ARB_ diff --git a/lib/include/srslte/phy/resampling/resampler.h b/lib/include/srsran/phy/resampling/resampler.h similarity index 70% rename from lib/include/srslte/phy/resampling/resampler.h rename to lib/include/srsran/phy/resampling/resampler.h index b0d4d6b8c..7a79cbb80 100644 --- a/lib/include/srslte/phy/resampling/resampler.h +++ b/lib/include/srsran/phy/resampling/resampler.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -18,14 +18,14 @@ * Reference: *****************************************************************************/ -#ifndef SRSLTE_RESAMPLER_H -#define SRSLTE_RESAMPLER_H +#ifndef SRSRAN_RESAMPLER_H +#define SRSRAN_RESAMPLER_H #include #include -#include "srslte/config.h" -#include "srslte/phy/dft/dft.h" +#include "srsran/config.h" +#include "srsran/phy/dft/dft.h" #ifdef __cplusplus extern "C" { @@ -35,47 +35,47 @@ extern "C" { * Resampler operating modes */ typedef enum { - SRSLTE_RESAMPLER_MODE_INTERPOLATE = 0, - SRSLTE_RESAMPLER_MODE_DECIMATE, -} srslte_resampler_mode_t; + SRSRAN_RESAMPLER_MODE_INTERPOLATE = 0, + SRSRAN_RESAMPLER_MODE_DECIMATE, +} srsran_resampler_mode_t; /** * Resampler internal buffers and subcomponents */ typedef struct { - srslte_resampler_mode_t mode; + srsran_resampler_mode_t mode; uint32_t ratio; uint32_t window_sz; - srslte_dft_plan_t fft; - srslte_dft_plan_t ifft; + srsran_dft_plan_t fft; + srsran_dft_plan_t ifft; uint32_t state_len; cf_t* in_buffer; cf_t* out_buffer; cf_t* state; cf_t* filter; -} srslte_resampler_fft_t; +} srsran_resampler_fft_t; /** * Initialise an FFT based resampler which can be configured as decimator or interpolator. * @param q Object pointer * @param mode Determines whether the operation mode is decimation or interpolation * @param ratio Operational ratio - * @return SRSLTE_SUCCES if no error, otherwise an SRSLTE error code + * @return SRSRAN_SUCCES if no error, otherwise an SRSRAN error code */ -SRSLTE_API int srslte_resampler_fft_init(srslte_resampler_fft_t* q, srslte_resampler_mode_t mode, uint32_t ratio); +SRSRAN_API int srsran_resampler_fft_init(srsran_resampler_fft_t* q, srsran_resampler_mode_t mode, uint32_t ratio); /** * @brief resets internal re-sampler state * @param q Object pointer */ -SRSLTE_API void srslte_resampler_fft_reset_state(srslte_resampler_fft_t* q); +SRSRAN_API void srsran_resampler_fft_reset_state(srsran_resampler_fft_t* q); /** * Get delay from the FFT based resampler. * @param q Object pointer * @return the delay in number of samples */ -SRSLTE_API uint32_t srslte_resampler_fft_get_delay(srslte_resampler_fft_t* q); +SRSRAN_API uint32_t srsran_resampler_fft_get_delay(srsran_resampler_fft_t* q); /** * @brief Run FFT based resampler in the initiated mode. @@ -88,16 +88,16 @@ SRSLTE_API uint32_t srslte_resampler_fft_get_delay(srslte_resampler_fft_t* q); * @param output Points at the output complex buffer * @param nsamples Number of samples to apply the processing */ -SRSLTE_API void srslte_resampler_fft_run(srslte_resampler_fft_t* q, const cf_t* input, cf_t* output, uint32_t nsamples); +SRSRAN_API void srsran_resampler_fft_run(srsran_resampler_fft_t* q, const cf_t* input, cf_t* output, uint32_t nsamples); /** * Free FFT based resampler buffers and subcomponents * @param q Object pointer */ -SRSLTE_API void srslte_resampler_fft_free(srslte_resampler_fft_t* q); +SRSRAN_API void srsran_resampler_fft_free(srsran_resampler_fft_t* q); #ifdef __cplusplus } #endif -#endif // SRSLTE_RESAMPLER_H +#endif // SRSRAN_RESAMPLER_H diff --git a/lib/include/srslte/phy/rf/rf.h b/lib/include/srsran/phy/rf/rf.h similarity index 51% rename from lib/include/srslte/phy/rf/rf.h rename to lib/include/srsran/phy/rf/rf.h index 1ff44decd..7782c2f4f 100644 --- a/lib/include/srslte/phy/rf/rf.h +++ b/lib/include/srsran/phy/rf/rf.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,15 +10,15 @@ * */ -#ifndef SRSLTE_RF_H -#define SRSLTE_RF_H +#ifndef SRSRAN_RF_H +#define SRSRAN_RF_H #include #include #include #include -#include "srslte/config.h" +#include "srsran/config.h" #ifdef __cplusplus extern "C" { @@ -39,107 +39,107 @@ typedef struct { double new_rx_gain; bool tx_gain_same_rx; float tx_rx_gain_offset; -} srslte_rf_t; +} srsran_rf_t; typedef struct { double min_tx_gain; double max_tx_gain; double min_rx_gain; double max_rx_gain; -} srslte_rf_info_t; +} srsran_rf_info_t; typedef struct { enum { - SRSLTE_RF_ERROR_LATE, - SRSLTE_RF_ERROR_UNDERFLOW, - SRSLTE_RF_ERROR_OVERFLOW, - SRSLTE_RF_ERROR_RX, - SRSLTE_RF_ERROR_OTHER + SRSRAN_RF_ERROR_LATE, + SRSRAN_RF_ERROR_UNDERFLOW, + SRSRAN_RF_ERROR_OVERFLOW, + SRSRAN_RF_ERROR_RX, + SRSRAN_RF_ERROR_OTHER } type; int opt; const char* msg; -} srslte_rf_error_t; +} srsran_rf_error_t; -typedef void (*srslte_rf_error_handler_t)(void* arg, srslte_rf_error_t error); +typedef void (*srsran_rf_error_handler_t)(void* arg, srsran_rf_error_t error); -SRSLTE_API int srslte_rf_open(srslte_rf_t* h, char* args); +SRSRAN_API int srsran_rf_open(srsran_rf_t* h, char* args); -SRSLTE_API int srslte_rf_open_multi(srslte_rf_t* h, char* args, uint32_t nof_channels); +SRSRAN_API int srsran_rf_open_multi(srsran_rf_t* h, char* args, uint32_t nof_channels); -SRSLTE_API int srslte_rf_open_devname(srslte_rf_t* h, const char* devname, char* args, uint32_t nof_channels); +SRSRAN_API int srsran_rf_open_devname(srsran_rf_t* h, const char* devname, char* args, uint32_t nof_channels); -SRSLTE_API const char* srslte_rf_name(srslte_rf_t* h); +SRSRAN_API const char* srsran_rf_name(srsran_rf_t* h); -SRSLTE_API int srslte_rf_start_gain_thread(srslte_rf_t* rf, bool tx_gain_same_rx); +SRSRAN_API int srsran_rf_start_gain_thread(srsran_rf_t* rf, bool tx_gain_same_rx); -SRSLTE_API int srslte_rf_close(srslte_rf_t* h); +SRSRAN_API int srsran_rf_close(srsran_rf_t* h); -SRSLTE_API int srslte_rf_start_rx_stream(srslte_rf_t* h, bool now); +SRSRAN_API int srsran_rf_start_rx_stream(srsran_rf_t* h, bool now); -SRSLTE_API int srslte_rf_stop_rx_stream(srslte_rf_t* h); +SRSRAN_API int srsran_rf_stop_rx_stream(srsran_rf_t* h); -SRSLTE_API void srslte_rf_flush_buffer(srslte_rf_t* h); +SRSRAN_API void srsran_rf_flush_buffer(srsran_rf_t* h); -SRSLTE_API bool srslte_rf_has_rssi(srslte_rf_t* h); +SRSRAN_API bool srsran_rf_has_rssi(srsran_rf_t* h); -SRSLTE_API float srslte_rf_get_rssi(srslte_rf_t* h); +SRSRAN_API float srsran_rf_get_rssi(srsran_rf_t* h); -SRSLTE_API double srslte_rf_set_rx_srate(srslte_rf_t* h, double freq); +SRSRAN_API double srsran_rf_set_rx_srate(srsran_rf_t* h, double freq); -SRSLTE_API int srslte_rf_set_rx_gain(srslte_rf_t* h, double gain); +SRSRAN_API int srsran_rf_set_rx_gain(srsran_rf_t* h, double gain); -SRSLTE_API int srslte_rf_set_rx_gain_ch(srslte_rf_t* h, uint32_t ch, double gain); +SRSRAN_API int srsran_rf_set_rx_gain_ch(srsran_rf_t* h, uint32_t ch, double gain); -SRSLTE_API void srslte_rf_set_tx_rx_gain_offset(srslte_rf_t* h, double offset); +SRSRAN_API void srsran_rf_set_tx_rx_gain_offset(srsran_rf_t* h, double offset); -SRSLTE_API int srslte_rf_set_rx_gain_th(srslte_rf_t* h, double gain); +SRSRAN_API int srsran_rf_set_rx_gain_th(srsran_rf_t* h, double gain); -SRSLTE_API double srslte_rf_get_rx_gain(srslte_rf_t* h); +SRSRAN_API double srsran_rf_get_rx_gain(srsran_rf_t* h); -SRSLTE_API double srslte_rf_get_tx_gain(srslte_rf_t* h); +SRSRAN_API double srsran_rf_get_tx_gain(srsran_rf_t* h); -SRSLTE_API srslte_rf_info_t* srslte_rf_get_info(srslte_rf_t* h); +SRSRAN_API srsran_rf_info_t* srsran_rf_get_info(srsran_rf_t* h); -SRSLTE_API void srslte_rf_suppress_stdout(srslte_rf_t* h); +SRSRAN_API void srsran_rf_suppress_stdout(srsran_rf_t* h); -SRSLTE_API void srslte_rf_register_error_handler(srslte_rf_t* h, srslte_rf_error_handler_t error_handler, void* arg); +SRSRAN_API void srsran_rf_register_error_handler(srsran_rf_t* h, srsran_rf_error_handler_t error_handler, void* arg); -SRSLTE_API double srslte_rf_set_rx_freq(srslte_rf_t* h, uint32_t ch, double freq); +SRSRAN_API double srsran_rf_set_rx_freq(srsran_rf_t* h, uint32_t ch, double freq); -SRSLTE_API int srslte_rf_recv(srslte_rf_t* h, void* data, uint32_t nsamples, bool blocking); +SRSRAN_API int srsran_rf_recv(srsran_rf_t* h, void* data, uint32_t nsamples, bool blocking); -SRSLTE_API int -srslte_rf_recv_with_time(srslte_rf_t* h, void* data, uint32_t nsamples, bool blocking, time_t* secs, double* frac_secs); +SRSRAN_API int +srsran_rf_recv_with_time(srsran_rf_t* h, void* data, uint32_t nsamples, bool blocking, time_t* secs, double* frac_secs); -SRSLTE_API int srslte_rf_recv_with_time_multi(srslte_rf_t* h, +SRSRAN_API int srsran_rf_recv_with_time_multi(srsran_rf_t* h, void** data, uint32_t nsamples, bool blocking, time_t* secs, double* frac_secs); -SRSLTE_API double srslte_rf_set_tx_srate(srslte_rf_t* h, double freq); +SRSRAN_API double srsran_rf_set_tx_srate(srsran_rf_t* h, double freq); -SRSLTE_API int srslte_rf_set_tx_gain(srslte_rf_t* h, double gain); +SRSRAN_API int srsran_rf_set_tx_gain(srsran_rf_t* h, double gain); -SRSLTE_API int srslte_rf_set_tx_gain_ch(srslte_rf_t* h, uint32_t ch, double gain); +SRSRAN_API int srsran_rf_set_tx_gain_ch(srsran_rf_t* h, uint32_t ch, double gain); -SRSLTE_API double srslte_rf_set_tx_freq(srslte_rf_t* h, uint32_t ch, double freq); +SRSRAN_API double srsran_rf_set_tx_freq(srsran_rf_t* h, uint32_t ch, double freq); -SRSLTE_API void srslte_rf_get_time(srslte_rf_t* h, time_t* secs, double* frac_secs); +SRSRAN_API void srsran_rf_get_time(srsran_rf_t* h, time_t* secs, double* frac_secs); -SRSLTE_API int srslte_rf_sync(srslte_rf_t* rf); +SRSRAN_API int srsran_rf_sync(srsran_rf_t* rf); -SRSLTE_API int srslte_rf_send(srslte_rf_t* h, void* data, uint32_t nsamples, bool blocking); +SRSRAN_API int srsran_rf_send(srsran_rf_t* h, void* data, uint32_t nsamples, bool blocking); -SRSLTE_API int -srslte_rf_send2(srslte_rf_t* h, void* data, uint32_t nsamples, bool blocking, bool start_of_burst, bool end_of_burst); +SRSRAN_API int +srsran_rf_send2(srsran_rf_t* h, void* data, uint32_t nsamples, bool blocking, bool start_of_burst, bool end_of_burst); -SRSLTE_API int srslte_rf_send(srslte_rf_t* h, void* data, uint32_t nsamples, bool blocking); +SRSRAN_API int srsran_rf_send(srsran_rf_t* h, void* data, uint32_t nsamples, bool blocking); -SRSLTE_API int srslte_rf_send_timed(srslte_rf_t* h, void* data, int nsamples, time_t secs, double frac_secs); +SRSRAN_API int srsran_rf_send_timed(srsran_rf_t* h, void* data, int nsamples, time_t secs, double frac_secs); -SRSLTE_API int srslte_rf_send_timed2(srslte_rf_t* h, +SRSRAN_API int srsran_rf_send_timed2(srsran_rf_t* h, void* data, int nsamples, time_t secs, @@ -147,7 +147,7 @@ SRSLTE_API int srslte_rf_send_timed2(srslte_rf_t* h, bool is_start_of_burst, bool is_end_of_burst); -SRSLTE_API int srslte_rf_send_timed_multi(srslte_rf_t* rf, +SRSRAN_API int srsran_rf_send_timed_multi(srsran_rf_t* rf, void** data, int nsamples, time_t secs, @@ -156,7 +156,7 @@ SRSLTE_API int srslte_rf_send_timed_multi(srslte_rf_t* rf, bool is_start_of_burst, bool is_end_of_burst); -SRSLTE_API int srslte_rf_send_multi(srslte_rf_t* rf, +SRSRAN_API int srsran_rf_send_multi(srsran_rf_t* rf, void** data, int nsamples, bool blocking, @@ -167,4 +167,4 @@ SRSLTE_API int srslte_rf_send_multi(srslte_rf_t* rf, } #endif -#endif // SRSLTE_RF_H +#endif // SRSRAN_RF_H diff --git a/lib/include/srslte/phy/rf/rf_utils.h b/lib/include/srsran/phy/rf/rf_utils.h similarity index 59% rename from lib/include/srslte/phy/rf/rf_utils.h rename to lib/include/srsran/phy/rf/rf_utils.h index d86ae8717..75e9d3197 100644 --- a/lib/include/srslte/phy/rf/rf_utils.h +++ b/lib/include/srsran/phy/rf/rf_utils.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,13 +10,13 @@ * */ -#ifndef SRSLTE_RF_UTILS_H -#define SRSLTE_RF_UTILS_H +#ifndef SRSRAN_RF_UTILS_H +#define SRSRAN_RF_UTILS_H -#include "srslte/phy/rf/rf.h" -#include "srslte/srslte.h" +#include "srsran/phy/rf/rf.h" +#include "srsran/srsran.h" -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { uint32_t max_frames_pbch; // timeout in number of 5ms frames for MIB decoding uint32_t max_frames_pss; // timeout in number of 5ms frames for synchronization uint32_t nof_valid_pss_frames; // number of required synchronized frames @@ -24,25 +24,25 @@ typedef struct SRSLTE_API { bool force_tdd; } cell_search_cfg_t; -SRSLTE_API int rf_rssi_scan(srslte_rf_t* rf, float* freqs, float* rssi, int nof_bands, double fs, int nsamp); +SRSRAN_API int rf_rssi_scan(srsran_rf_t* rf, float* freqs, float* rssi, int nof_bands, double fs, int nsamp); -SRSLTE_API int -rf_mib_decoder(srslte_rf_t* rf, uint32_t nof_rf_channels, cell_search_cfg_t* config, srslte_cell_t* cell, float* cfo); +SRSRAN_API int +rf_mib_decoder(srsran_rf_t* rf, uint32_t nof_rf_channels, cell_search_cfg_t* config, srsran_cell_t* cell, float* cfo); -SRSLTE_API int rf_cell_search(srslte_rf_t* rf, +SRSRAN_API int rf_cell_search(srsran_rf_t* rf, uint32_t nof_rf_channels, cell_search_cfg_t* config, int force_N_id_2, - srslte_cell_t* cell, + srsran_cell_t* cell, float* cfo); -SRSLTE_API int rf_search_and_decode_mib(srslte_rf_t* rf, +SRSRAN_API int rf_search_and_decode_mib(srsran_rf_t* rf, uint32_t nof_rf_channels, cell_search_cfg_t* config, int force_N_id_2, - srslte_cell_t* cell, + srsran_cell_t* cell, float* cfo); -SRSLTE_API int rf_cell_search_nbiot(srslte_rf_t* rf, cell_search_cfg_t* config, srslte_nbiot_cell_t* cell, float* cfo); +SRSRAN_API int rf_cell_search_nbiot(srsran_rf_t* rf, cell_search_cfg_t* config, srsran_nbiot_cell_t* cell, float* cfo); -#endif // SRSLTE_RF_UTILS_H +#endif // SRSRAN_RF_UTILS_H diff --git a/lib/include/srsran/phy/scrambling/scrambling.h b/lib/include/srsran/phy/scrambling/scrambling.h new file mode 100644 index 000000000..e6ee4b426 --- /dev/null +++ b/lib/include/srsran/phy/scrambling/scrambling.h @@ -0,0 +1,49 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +/****************************************************************************** + * File: scrambling.h + * + * Description: Generic scrambling functions used by UL and DL channels. + * + * Reference: 3GPP TS 36.211 version 10.0.0 Release 10 Sec. 5.3.1, 6.3.1 + *****************************************************************************/ + +#ifndef SRSRAN_SCRAMBLING_H +#define SRSRAN_SCRAMBLING_H + +#include "srsran/config.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/common/sequence.h" + +/* Scrambling has no state */ +SRSRAN_API void srsran_scrambling_b(srsran_sequence_t* s, uint8_t* data); + +SRSRAN_API void srsran_scrambling_b_offset(srsran_sequence_t* s, uint8_t* data, int offset, int len); + +SRSRAN_API void srsran_scrambling_bytes(srsran_sequence_t* s, uint8_t* data, int len); + +SRSRAN_API void srsran_scrambling_f(srsran_sequence_t* s, float* data); + +SRSRAN_API void srsran_scrambling_f_offset(srsran_sequence_t* s, float* data, int offset, int len); + +SRSRAN_API void srsran_scrambling_s(srsran_sequence_t* s, short* data); + +SRSRAN_API void srsran_scrambling_s_offset(srsran_sequence_t* s, short* data, int offset, int len); + +SRSRAN_API void srsran_scrambling_sb_offset(srsran_sequence_t* s, int8_t* data, int offset, int len); + +SRSRAN_API void srsran_scrambling_c(srsran_sequence_t* s, cf_t* data); + +SRSRAN_API void srsran_scrambling_c_offset(srsran_sequence_t* s, cf_t* data, int offset, int len); + +#endif // SRSRAN_SCRAMBLING_H diff --git a/lib/include/srsran/phy/sync/cfo.h b/lib/include/srsran/phy/sync/cfo.h new file mode 100644 index 000000000..03aba13f3 --- /dev/null +++ b/lib/include/srsran/phy/sync/cfo.h @@ -0,0 +1,56 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +/****************************************************************************** + * File: cfo.h + * + * Description: Carrier frequency offset correction using complex exponentials. + * + * Reference: + *****************************************************************************/ + +#ifndef SRSRAN_CFO_H +#define SRSRAN_CFO_H + +#include + +#include "srsran/config.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/utils/cexptab.h" + +#define SRSRAN_CFO_CEXPTAB_SIZE 4096 + +typedef struct SRSRAN_API { + float last_freq; + float tol; + int nsamples; + int max_samples; + srsran_cexptab_t tab; + cf_t* cur_cexp; +} srsran_cfo_t; + +SRSRAN_API int srsran_cfo_init(srsran_cfo_t* h, uint32_t nsamples); + +SRSRAN_API void srsran_cfo_free(srsran_cfo_t* h); + +SRSRAN_API int srsran_cfo_resize(srsran_cfo_t* h, uint32_t samples); + +SRSRAN_API void srsran_cfo_set_tol(srsran_cfo_t* h, float tol); + +SRSRAN_API void srsran_cfo_correct(srsran_cfo_t* h, const cf_t* input, cf_t* output, float freq); + +SRSRAN_API void +srsran_cfo_correct_offset(srsran_cfo_t* h, const cf_t* input, cf_t* output, float freq, int cexp_offset, int nsamples); + +SRSRAN_API float srsran_cfo_est_corr_cp(cf_t* input_buffer, uint32_t nof_prb); + +#endif // SRSRAN_CFO_H diff --git a/lib/include/srsran/phy/sync/cp.h b/lib/include/srsran/phy/sync/cp.h new file mode 100644 index 000000000..fe84b09c0 --- /dev/null +++ b/lib/include/srsran/phy/sync/cp.h @@ -0,0 +1,38 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +#ifndef SRSRAN_CP_H +#define SRSRAN_CP_H + +#include +#include + +#include "srsran/config.h" + +typedef struct { + cf_t* corr; + uint32_t symbol_sz; + uint32_t max_symbol_sz; +} srsran_cp_synch_t; + +SRSRAN_API int srsran_cp_synch_init(srsran_cp_synch_t* q, uint32_t symbol_sz); + +SRSRAN_API void srsran_cp_synch_free(srsran_cp_synch_t* q); + +SRSRAN_API int srsran_cp_synch_resize(srsran_cp_synch_t* q, uint32_t symbol_sz); + +SRSRAN_API uint32_t +srsran_cp_synch(srsran_cp_synch_t* q, const cf_t* input, uint32_t max_offset, uint32_t nof_symbols, uint32_t cp_len); + +SRSRAN_API cf_t srsran_cp_synch_corr_output(srsran_cp_synch_t* q, uint32_t offset); + +#endif // SRSRAN_CP_H diff --git a/lib/include/srslte/phy/sync/npss.h b/lib/include/srsran/phy/sync/npss.h similarity index 55% rename from lib/include/srslte/phy/sync/npss.h rename to lib/include/srsran/phy/sync/npss.h index a55ebd20d..d8ab0ba4a 100644 --- a/lib/include/srslte/phy/sync/npss.h +++ b/lib/include/srsran/phy/sync/npss.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -15,9 +15,9 @@ * * Description: Narrowband Primary synchronization signal (NPSS) generation and detection. * - * The srslte_npss_synch_t object provides functions for fast + * The srsran_npss_synch_t object provides functions for fast * computation of the crosscorrelation between the NPSS and received - * signal and CFO estimation. Also, the function srslte_npss_synch_tperiodic() + * signal and CFO estimation. Also, the function srsran_npss_synch_tperiodic() * is designed to be called periodically every subframe, taking * care of the correct data alignment with respect to the NPSS sequence. * @@ -28,54 +28,54 @@ * Reference: 3GPP TS 36.211 version 13.2.0 Release 13 Sec. 10.x.x *****************************************************************************/ -#ifndef SRSLTE_NPSS_H -#define SRSLTE_NPSS_H +#ifndef SRSRAN_NPSS_H +#define SRSRAN_NPSS_H #include #include -#include "srslte/config.h" -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/utils/convolution.h" +#include "srsran/config.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/utils/convolution.h" #define CONVOLUTION_FFT -#define SRSLTE_NPSS_RETURN_PSR +#define SRSRAN_NPSS_RETURN_PSR -#define SRSLTE_NPSS_LEN 11 -#define SRSLTE_NPSS_NUM_OFDM_SYMS 11 -#define SRSLTE_NPSS_TOT_LEN (SRSLTE_NPSS_LEN * SRSLTE_NPSS_NUM_OFDM_SYMS) +#define SRSRAN_NPSS_LEN 11 +#define SRSRAN_NPSS_NUM_OFDM_SYMS 11 +#define SRSRAN_NPSS_TOT_LEN (SRSRAN_NPSS_LEN * SRSRAN_NPSS_NUM_OFDM_SYMS) -#define SRSLTE_NPSS_CORR_FILTER_LEN \ - ((SRSLTE_NPSS_NUM_OFDM_SYMS * SRSLTE_NBIOT_FFT_SIZE) + \ - (SRSLTE_NPSS_NUM_OFDM_SYMS - 1) * SRSLTE_CP_LEN_NORM(1, SRSLTE_NBIOT_FFT_SIZE) + \ - SRSLTE_CP_LEN_NORM(0, SRSLTE_NBIOT_FFT_SIZE)) +#define SRSRAN_NPSS_CORR_FILTER_LEN \ + ((SRSRAN_NPSS_NUM_OFDM_SYMS * SRSRAN_NBIOT_FFT_SIZE) + \ + (SRSRAN_NPSS_NUM_OFDM_SYMS - 1) * SRSRAN_CP_LEN_NORM(1, SRSRAN_NBIOT_FFT_SIZE) + \ + SRSRAN_CP_LEN_NORM(0, SRSRAN_NBIOT_FFT_SIZE)) // The below value corresponds to the time-domain representation of the first // three OFDM-symbols plus cyclic prefix that are not transmitted in the sub-frame // carrying the NPSS -#define SRSLTE_NPSS_CORR_OFFSET (SRSLTE_SF_LEN(SRSLTE_NBIOT_FFT_SIZE) - SRSLTE_NPSS_CORR_FILTER_LEN) +#define SRSRAN_NPSS_CORR_OFFSET (SRSRAN_SF_LEN(SRSRAN_NBIOT_FFT_SIZE) - SRSRAN_NPSS_CORR_FILTER_LEN) // CFO estimation based on the NPSS is done using the second slot of the sub-frame -#define SRSLTE_NPSS_CFO_OFFSET (SRSLTE_SF_LEN(SRSLTE_NBIOT_FFT_SIZE) / 2 - SRSLTE_NPSS_CORR_OFFSET) -#define SRSLTE_NPSS_CFO_NUM_SYMS 6 // number of symbols for CFO estimation -#define SRSLTE_NPSS_CFO_NUM_SAMPS \ - ((SRSLTE_NPSS_CFO_NUM_SYMS * SRSLTE_NBIOT_FFT_SIZE) + \ - (SRSLTE_NPSS_CFO_NUM_SYMS - 1) * SRSLTE_CP_LEN_NORM(1, SRSLTE_NBIOT_FFT_SIZE) + \ - SRSLTE_CP_LEN_NORM(0, SRSLTE_NBIOT_FFT_SIZE)) // resulting number of samples +#define SRSRAN_NPSS_CFO_OFFSET (SRSRAN_SF_LEN(SRSRAN_NBIOT_FFT_SIZE) / 2 - SRSRAN_NPSS_CORR_OFFSET) +#define SRSRAN_NPSS_CFO_NUM_SYMS 6 // number of symbols for CFO estimation +#define SRSRAN_NPSS_CFO_NUM_SAMPS \ + ((SRSRAN_NPSS_CFO_NUM_SYMS * SRSRAN_NBIOT_FFT_SIZE) + \ + (SRSRAN_NPSS_CFO_NUM_SYMS - 1) * SRSRAN_CP_LEN_NORM(1, SRSRAN_NBIOT_FFT_SIZE) + \ + SRSRAN_CP_LEN_NORM(0, SRSRAN_NBIOT_FFT_SIZE)) // resulting number of samples // NPSS processing options -#define SRSLTE_NPSS_ACCUMULATE_ABS // If enabled, accumulates the correlation absolute value on consecutive calls to - // srslte_pss_synch_find_pss +#define SRSRAN_NPSS_ACCUMULATE_ABS // If enabled, accumulates the correlation absolute value on consecutive calls to + // srsran_pss_synch_find_pss -#define SRSLTE_NPSS_ABS_SQUARE // If enabled, compute abs square, otherwise computes absolute value only +#define SRSRAN_NPSS_ABS_SQUARE // If enabled, compute abs square, otherwise computes absolute value only -#define SRSLTE_NPSS_RETURN_PSR // If enabled returns peak to side-lobe ratio, otherwise returns absolute peak value +#define SRSRAN_NPSS_RETURN_PSR // If enabled returns peak to side-lobe ratio, otherwise returns absolute peak value /* Low-level API */ -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { #ifdef CONVOLUTION_FFT - srslte_conv_fft_cc_t conv_fft; + srsran_conv_fft_cc_t conv_fft; #endif uint32_t frame_size, max_frame_size; @@ -88,30 +88,30 @@ typedef struct SRSLTE_API { float ema_alpha; float* conv_output_avg; float peak_value; -} srslte_npss_synch_t; +} srsran_npss_synch_t; // Basic functionality -SRSLTE_API int srslte_npss_synch_init(srslte_npss_synch_t* q, uint32_t frame_size, uint32_t fft_size); +SRSRAN_API int srsran_npss_synch_init(srsran_npss_synch_t* q, uint32_t frame_size, uint32_t fft_size); -SRSLTE_API void srslte_npss_synch_reset(srslte_npss_synch_t* q); +SRSRAN_API void srsran_npss_synch_reset(srsran_npss_synch_t* q); -SRSLTE_API int srslte_npss_synch_resize(srslte_npss_synch_t* q, uint32_t frame_size, uint32_t fft_size); +SRSRAN_API int srsran_npss_synch_resize(srsran_npss_synch_t* q, uint32_t frame_size, uint32_t fft_size); -SRSLTE_API void srslte_npss_synch_set_ema_alpha(srslte_npss_synch_t* q, float alpha); +SRSRAN_API void srsran_npss_synch_set_ema_alpha(srsran_npss_synch_t* q, float alpha); -SRSLTE_API void srslte_npss_synch_free(srslte_npss_synch_t* q); +SRSRAN_API void srsran_npss_synch_free(srsran_npss_synch_t* q); -SRSLTE_API int srslte_npss_sync_find(srslte_npss_synch_t* q, cf_t* input, float* corr_peak_value); +SRSRAN_API int srsran_npss_sync_find(srsran_npss_synch_t* q, cf_t* input, float* corr_peak_value); // Internal functions -SRSLTE_API int srslte_npss_corr_init(cf_t* npss_signal_time, uint32_t fft_size, uint32_t frame_size); +SRSRAN_API int srsran_npss_corr_init(cf_t* npss_signal_time, uint32_t fft_size, uint32_t frame_size); -SRSLTE_API int srslte_npss_generate(cf_t* signal); +SRSRAN_API int srsran_npss_generate(cf_t* signal); -SRSLTE_API void srslte_npss_put_subframe(srslte_npss_synch_t* q, +SRSRAN_API void srsran_npss_put_subframe(srsran_npss_synch_t* q, cf_t* npss_signal, cf_t* sf, const uint32_t nof_prb, const uint32_t nbiot_prb_offset); -#endif // SRSLTE_NPSS_H +#endif // SRSRAN_NPSS_H diff --git a/lib/include/srslte/phy/sync/nsss.h b/lib/include/srsran/phy/sync/nsss.h similarity index 72% rename from lib/include/srslte/phy/sync/nsss.h rename to lib/include/srsran/phy/sync/nsss.h index 80130d6fb..670aa88cd 100644 --- a/lib/include/srslte/phy/sync/nsss.h +++ b/lib/include/srsran/phy/sync/nsss.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -20,32 +20,32 @@ * Reference: 3GPP TS 36.211 version 13.2.0 Release 13 Sec. 10.2.7.2 *****************************************************************************/ -#ifndef SRSLTE_NSSS_H -#define SRSLTE_NSSS_H +#ifndef SRSRAN_NSSS_H +#define SRSRAN_NSSS_H #include #include #include -#include "srslte/config.h" -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/dft/dft.h" -#include "srslte/phy/utils/convolution.h" +#include "srsran/config.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/dft/dft.h" +#include "srsran/phy/utils/convolution.h" -#define SRSLTE_NSSS_NSYMB 11 -#define SRSLTE_NSSS_NSC 12 -#define SRSLTE_NSSS_LEN (SRSLTE_NSSS_NSYMB * SRSLTE_NSSS_NSC) -#define SRSLTE_NSSS_NUM_SEQ 4 -#define SRSLTE_NSSS_TOT_LEN (SRSLTE_NSSS_NUM_SEQ * SRSLTE_NSSS_LEN) +#define SRSRAN_NSSS_NSYMB 11 +#define SRSRAN_NSSS_NSC 12 +#define SRSRAN_NSSS_LEN (SRSRAN_NSSS_NSYMB * SRSRAN_NSSS_NSC) +#define SRSRAN_NSSS_NUM_SEQ 4 +#define SRSRAN_NSSS_TOT_LEN (SRSRAN_NSSS_NUM_SEQ * SRSRAN_NSSS_LEN) -#define SRSLTE_NSSS_CORR_FILTER_LEN 1508 -#define SRSLTE_NSSS_CORR_OFFSET 412 +#define SRSRAN_NSSS_CORR_FILTER_LEN 1508 +#define SRSRAN_NSSS_CORR_OFFSET 412 -#define SRSLTE_NSSS_PERIOD 2 -#define SRSLTE_NSSS_NUM_SF_DETECT (SRSLTE_NSSS_PERIOD) +#define SRSRAN_NSSS_PERIOD 2 +#define SRSRAN_NSSS_NUM_SF_DETECT (SRSRAN_NSSS_PERIOD) // b_q_m table from 3GPP TS 36.211 v13.2.0 table 10.2.7.2.1-1 -static const int b_q_m[SRSLTE_NSSS_NUM_SEQ][128] = { +static const int b_q_m[SRSRAN_NSSS_NUM_SEQ][128] = { {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -66,43 +66,43 @@ static const int b_q_m[SRSLTE_NSSS_NUM_SEQ][128] = { -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, -1}}; /* Low-level API */ -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { uint32_t input_size; uint32_t subframe_sz; uint32_t fft_size, max_fft_size; - srslte_conv_fft_cc_t conv_fft; + srsran_conv_fft_cc_t conv_fft; - cf_t* nsss_signal_time[SRSLTE_NUM_PCI]; + cf_t* nsss_signal_time[SRSRAN_NUM_PCI]; cf_t* tmp_input; cf_t* conv_output; float* conv_output_abs; - float peak_values[SRSLTE_NUM_PCI]; + float peak_values[SRSRAN_NUM_PCI]; float corr_peak_threshold; -} srslte_nsss_synch_t; +} srsran_nsss_synch_t; -SRSLTE_API int srslte_nsss_synch_init(srslte_nsss_synch_t* q, uint32_t input_size, uint32_t fft_size); +SRSRAN_API int srsran_nsss_synch_init(srsran_nsss_synch_t* q, uint32_t input_size, uint32_t fft_size); -SRSLTE_API void srslte_nsss_synch_free(srslte_nsss_synch_t* q); +SRSRAN_API void srsran_nsss_synch_free(srsran_nsss_synch_t* q); -SRSLTE_API int srslte_nsss_synch_resize(srslte_nsss_synch_t* q, uint32_t fft_size); +SRSRAN_API int srsran_nsss_synch_resize(srsran_nsss_synch_t* q, uint32_t fft_size); -SRSLTE_API int srslte_nsss_sync_find(srslte_nsss_synch_t* q, +SRSRAN_API int srsran_nsss_sync_find(srsran_nsss_synch_t* q, cf_t* input, float* corr_peak_value, uint32_t* cell_id, uint32_t* sfn_partial); -void srslte_nsss_sync_find_pci(srslte_nsss_synch_t* q, cf_t* input, uint32_t cell_id); +void srsran_nsss_sync_find_pci(srsran_nsss_synch_t* q, cf_t* input, uint32_t cell_id); -SRSLTE_API int srslte_nsss_corr_init(srslte_nsss_synch_t* q); +SRSRAN_API int srsran_nsss_corr_init(srsran_nsss_synch_t* q); -SRSLTE_API void srslte_nsss_generate(cf_t* signal, uint32_t cell_id); +SRSRAN_API void srsran_nsss_generate(cf_t* signal, uint32_t cell_id); -SRSLTE_API void srslte_nsss_put_subframe(srslte_nsss_synch_t* q, +SRSRAN_API void srsran_nsss_put_subframe(srsran_nsss_synch_t* q, cf_t* nsss, cf_t* subframe, const int nf, const uint32_t nof_prb, const uint32_t nbiot_prb_offset); -#endif // SRSLTE_NSSS_H \ No newline at end of file +#endif // SRSRAN_NSSS_H \ No newline at end of file diff --git a/lib/include/srsran/phy/sync/pss.h b/lib/include/srsran/phy/sync/pss.h new file mode 100644 index 000000000..fc2bf3faa --- /dev/null +++ b/lib/include/srsran/phy/sync/pss.h @@ -0,0 +1,135 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +/****************************************************************************** + * File: pss.h + * + * Description: Primary synchronization signal (PSS) generation and detection. + * + * The srsran_pss_t object provides functions for fast + * computation of the crosscorrelation between the PSS and received + * signal and CFO estimation. Also, the function srsran_pss_tperiodic() + * is designed to be called periodically every subframe, taking + * care of the correct data alignment with respect to the PSS sequence. + * + * The object is designed to work with signals sampled at 1.92 Mhz + * centered at the carrier frequency. Thus, downsampling is required + * if the signal is sampled at higher frequencies. + * + * Reference: 3GPP TS 36.211 version 10.0.0 Release 10 Sec. 6.11.1 + *****************************************************************************/ + +#ifndef SRSRAN_PSS_H +#define SRSRAN_PSS_H + +#include +#include + +#include "srsran/config.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/utils/convolution.h" +#include "srsran/phy/utils/filter.h" + +#define CONVOLUTION_FFT + +#define SRSRAN_PSS_LEN 62 +#define SRSRAN_PSS_RE (6 * 12) + +/* PSS processing options */ + +#define SRSRAN_PSS_ACCUMULATE_ABS // If enabled, accumulates the correlation absolute value on consecutive calls to + // srsran_pss_find_pss + +#define SRSRAN_PSS_RETURN_PSR // If enabled returns peak to side-lobe ratio, otherwise returns absolute peak value + +/* Low-level API */ +typedef struct SRSRAN_API { + +#ifdef CONVOLUTION_FFT + srsran_conv_fft_cc_t conv_fft; + srsran_filt_cc_t filter; + +#endif + int decimate; + + uint32_t max_frame_size; + uint32_t max_fft_size; + + uint32_t frame_size; + uint32_t N_id_2; + uint32_t fft_size; + cf_t* pss_signal_freq_full[3]; + + cf_t* pss_signal_time[3]; + cf_t* pss_signal_time_scale[3]; + + cf_t pss_signal_freq[3][SRSRAN_PSS_LEN]; // One sequence for each N_id_2 + cf_t* tmp_input; + cf_t* conv_output; + float* conv_output_abs; + float ema_alpha; + float* conv_output_avg; + float peak_value; + + bool filter_pss_enable; + srsran_dft_plan_t dftp_input; + srsran_dft_plan_t idftp_input; + cf_t tmp_fft[SRSRAN_SYMBOL_SZ_MAX]; + cf_t tmp_fft2[SRSRAN_SYMBOL_SZ_MAX]; + + cf_t tmp_ce[SRSRAN_PSS_LEN]; + + bool chest_on_filter; + +} srsran_pss_t; + +typedef enum { PSS_TX, PSS_RX } pss_direction_t; + +/* Basic functionality */ +SRSRAN_API int srsran_pss_init_fft(srsran_pss_t* q, uint32_t frame_size, uint32_t fft_size); + +SRSRAN_API int srsran_pss_init_fft_offset(srsran_pss_t* q, uint32_t frame_size, uint32_t fft_size, int cfo_i); + +SRSRAN_API int +srsran_pss_init_fft_offset_decim(srsran_pss_t* q, uint32_t frame_size, uint32_t fft_size, int cfo_i, int decimate); + +SRSRAN_API int srsran_pss_resize(srsran_pss_t* q, uint32_t frame_size, uint32_t fft_size, int offset); + +SRSRAN_API int srsran_pss_init(srsran_pss_t* q, uint32_t frame_size); + +SRSRAN_API void srsran_pss_free(srsran_pss_t* q); + +SRSRAN_API void srsran_pss_reset(srsran_pss_t* q); + +SRSRAN_API void srsran_pss_filter_enable(srsran_pss_t* q, bool enable); + +SRSRAN_API void srsran_pss_sic(srsran_pss_t* q, cf_t* input); + +SRSRAN_API void srsran_pss_filter(srsran_pss_t* q, const cf_t* input, cf_t* output); + +SRSRAN_API int srsran_pss_generate(cf_t* signal, uint32_t N_id_2); + +SRSRAN_API void srsran_pss_get_slot(cf_t* slot, cf_t* pss_signal, uint32_t nof_prb, srsran_cp_t cp); + +SRSRAN_API void srsran_pss_put_slot(cf_t* pss_signal, cf_t* slot, uint32_t nof_prb, srsran_cp_t cp); + +SRSRAN_API void srsran_pss_set_ema_alpha(srsran_pss_t* q, float alpha); + +SRSRAN_API int srsran_pss_set_N_id_2(srsran_pss_t* q, uint32_t N_id_2); + +SRSRAN_API int srsran_pss_find_pss(srsran_pss_t* q, const cf_t* input, float* corr_peak_value); + +SRSRAN_API int srsran_pss_chest(srsran_pss_t* q, const cf_t* input, cf_t ce[SRSRAN_PSS_LEN]); + +SRSRAN_API float srsran_pss_cfo_compute(srsran_pss_t* q, const cf_t* pss_recv); + +#endif // SRSRAN_PSS_H diff --git a/lib/include/srslte/phy/sync/psss.h b/lib/include/srsran/phy/sync/psss.h similarity index 51% rename from lib/include/srslte/phy/sync/psss.h rename to lib/include/srsran/phy/sync/psss.h index 07f0a7b79..01cbdf5e1 100644 --- a/lib/include/srslte/phy/sync/psss.h +++ b/lib/include/srsran/phy/sync/psss.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -19,21 +19,21 @@ * Reference: 3GPP TS 36.211 version 15.6.0 Release 15 Sec. 9.7.1 *****************************************************************************/ -#ifndef SRSLTE_PSSS_H -#define SRSLTE_PSSS_H +#ifndef SRSRAN_PSSS_H +#define SRSRAN_PSSS_H #include #include -#include "srslte/config.h" -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/dft/dft.h" +#include "srsran/config.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/dft/dft.h" -#define SRSLTE_PSSS_LEN 62 +#define SRSRAN_PSSS_LEN 62 -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { - cf_t psss_signal[2][SRSLTE_PSSS_LEN]; // One sequence for each N_id_2 + cf_t psss_signal[2][SRSRAN_PSSS_LEN]; // One sequence for each N_id_2 cf_t** psss_sf_freq; @@ -52,19 +52,19 @@ typedef struct SRSLTE_API { uint32_t N_id_2; - srslte_dft_plan_t plan_input; - srslte_dft_plan_t plan_out; + srsran_dft_plan_t plan_input; + srsran_dft_plan_t plan_out; -} srslte_psss_t; +} srsran_psss_t; -SRSLTE_API int srslte_psss_init(srslte_psss_t* q, uint32_t nof_prb, srslte_cp_t cp); +SRSRAN_API int srsran_psss_init(srsran_psss_t* q, uint32_t nof_prb, srsran_cp_t cp); -SRSLTE_API int srslte_psss_generate(cf_t* psss_signal, uint32_t N_id_2); +SRSRAN_API int srsran_psss_generate(cf_t* psss_signal, uint32_t N_id_2); -SRSLTE_API void srslte_psss_put_sf_buffer(cf_t* psss_signal, cf_t* sf_buffer, uint32_t nof_prb, srslte_cp_t cp); +SRSRAN_API void srsran_psss_put_sf_buffer(cf_t* psss_signal, cf_t* sf_buffer, uint32_t nof_prb, srsran_cp_t cp); -SRSLTE_API int srslte_psss_find(srslte_psss_t* q, cf_t* input, uint32_t nof_prb, srslte_cp_t cp); +SRSRAN_API int srsran_psss_find(srsran_psss_t* q, cf_t* input, uint32_t nof_prb, srsran_cp_t cp); -SRSLTE_API void srslte_psss_free(srslte_psss_t* q); +SRSRAN_API void srsran_psss_free(srsran_psss_t* q); -#endif // SRSLTE_PSSS_H +#endif // SRSRAN_PSSS_H diff --git a/lib/include/srslte/phy/sync/refsignal_dl_sync.h b/lib/include/srsran/phy/sync/refsignal_dl_sync.h similarity index 54% rename from lib/include/srslte/phy/sync/refsignal_dl_sync.h rename to lib/include/srsran/phy/sync/refsignal_dl_sync.h index cbe2c6104..afcafd70d 100644 --- a/lib/include/srslte/phy/sync/refsignal_dl_sync.h +++ b/lib/include/srsran/phy/sync/refsignal_dl_sync.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,21 +10,21 @@ * */ -#ifndef SRSLTE_REFSIGNAL_DL_SYNC_H_ -#define SRSLTE_REFSIGNAL_DL_SYNC_H_ +#ifndef SRSRAN_REFSIGNAL_DL_SYNC_H_ +#define SRSRAN_REFSIGNAL_DL_SYNC_H_ -#include -#include -#include +#include +#include +#include typedef struct { - srslte_refsignal_t refsignal; - srslte_ofdm_t ifft; + srsran_refsignal_t refsignal; + srsran_ofdm_t ifft; cf_t* ifft_buffer_in; cf_t* ifft_buffer_out; - cf_t* sequences[SRSLTE_NOF_SF_X_FRAME]; + cf_t* sequences[SRSRAN_NOF_SF_X_FRAME]; cf_t* correlation; - srslte_conv_fft_cc_t conv_fft_cc; + srsran_conv_fft_cc_t conv_fft_cc; // Results bool found; @@ -33,21 +33,21 @@ typedef struct { float rsrq_dB; float cfo_Hz; uint32_t peak_index; -} srslte_refsignal_dl_sync_t; +} srsran_refsignal_dl_sync_t; -SRSLTE_API int srslte_refsignal_dl_sync_init(srslte_refsignal_dl_sync_t* q); +SRSRAN_API int srsran_refsignal_dl_sync_init(srsran_refsignal_dl_sync_t* q); -SRSLTE_API int srslte_refsignal_dl_sync_set_cell(srslte_refsignal_dl_sync_t* q, srslte_cell_t cell); +SRSRAN_API int srsran_refsignal_dl_sync_set_cell(srsran_refsignal_dl_sync_t* q, srsran_cell_t cell); -SRSLTE_API void srslte_refsignal_dl_sync_free(srslte_refsignal_dl_sync_t* q); +SRSRAN_API void srsran_refsignal_dl_sync_free(srsran_refsignal_dl_sync_t* q); -SRSLTE_API void srslte_refsignal_dl_sync_run(srslte_refsignal_dl_sync_t* q, cf_t* buffer, uint32_t nsamples); +SRSRAN_API void srsran_refsignal_dl_sync_run(srsran_refsignal_dl_sync_t* q, cf_t* buffer, uint32_t nsamples); -SRSLTE_API void srslte_refsignal_dl_sync_measure_sf(srslte_refsignal_dl_sync_t* q, +SRSRAN_API void srsran_refsignal_dl_sync_measure_sf(srsran_refsignal_dl_sync_t* q, cf_t* buffer, uint32_t sf_idx, float* rsrp, float* rssi, float* cfo); -#endif // SRSLTE_REFSIGNAL_DL_SYNC_H_ +#endif // SRSRAN_REFSIGNAL_DL_SYNC_H_ diff --git a/lib/include/srslte/phy/sync/sfo.h b/lib/include/srsran/phy/sync/sfo.h similarity index 64% rename from lib/include/srslte/phy/sync/sfo.h rename to lib/include/srsran/phy/sync/sfo.h index 4d852ab75..c3b0df22b 100644 --- a/lib/include/srslte/phy/sync/sfo.h +++ b/lib/include/srsran/phy/sync/sfo.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -18,13 +18,13 @@ * Reference: *****************************************************************************/ -#ifndef SRSLTE_SFO_H -#define SRSLTE_SFO_H +#ifndef SRSRAN_SFO_H +#define SRSRAN_SFO_H -#include "srslte/config.h" +#include "srsran/config.h" -SRSLTE_API float srslte_sfo_estimate(int* t0, int len, float period); +SRSRAN_API float srsran_sfo_estimate(int* t0, int len, float period); -SRSLTE_API float srslte_sfo_estimate_period(int* t0, int* t, int len, float period); +SRSRAN_API float srsran_sfo_estimate_period(int* t0, int* t, int len, float period); -#endif // SRSLTE_SFO_H +#endif // SRSRAN_SFO_H diff --git a/lib/include/srsran/phy/sync/sss.h b/lib/include/srsran/phy/sync/sss.h new file mode 100644 index 000000000..8046af18d --- /dev/null +++ b/lib/include/srsran/phy/sync/sss.h @@ -0,0 +1,118 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +/****************************************************************************** + * File: sss.h + * + * Description: Secondary synchronization signal (SSS) generation and detection. + * + * + * Reference: 3GPP TS 36.211 version 10.0.0 Release 10 Sec. 6.11.2 + *****************************************************************************/ + +#ifndef SRSRAN_SSS_H +#define SRSRAN_SSS_H + +#include +#include + +#include "srsran/config.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/dft/dft.h" + +#define SRSRAN_SSS_N 31 +#define SRSRAN_SSS_LEN 2 * SRSRAN_SSS_N + +typedef struct SRSRAN_API { + int z1[SRSRAN_SSS_N][SRSRAN_SSS_N]; + int c[2][SRSRAN_SSS_N]; + int s[SRSRAN_SSS_N][SRSRAN_SSS_N]; +} srsran_sss_tables_t; + +/* Allocate 32 complex to make it multiple of 32-byte AVX instructions alignment requirement. + * Should use srsran_vec_malloc() to make it platform agnostic. + */ +typedef struct SRSRAN_API { + float z1[SRSRAN_SSS_N][SRSRAN_SSS_N]; + float c[2][SRSRAN_SSS_N]; + float s[SRSRAN_SSS_N][SRSRAN_SSS_N]; + float sd[SRSRAN_SSS_N][SRSRAN_SSS_N - 1]; +} srsran_sss_fc_tables_t; + +/* Low-level API */ +typedef struct SRSRAN_API { + srsran_dft_plan_t dftp_input; + + uint32_t fft_size; + uint32_t max_fft_size; + + float corr_peak_threshold; + uint32_t symbol_sz; + uint32_t subframe_sz; + uint32_t N_id_2; + + uint32_t N_id_1_table[30][30]; + srsran_sss_fc_tables_t fc_tables[3]; // one for each N_id_2 + + float corr_output_m0[SRSRAN_SSS_N]; + float corr_output_m1[SRSRAN_SSS_N]; + +} srsran_sss_t; + +/* Basic functionality */ +SRSRAN_API int srsran_sss_init(srsran_sss_t* q, uint32_t fft_size); + +SRSRAN_API int srsran_sss_resize(srsran_sss_t* q, uint32_t fft_size); + +SRSRAN_API void srsran_sss_free(srsran_sss_t* q); + +SRSRAN_API void srsran_sss_generate(float* signal0, float* signal5, uint32_t cell_id); + +SRSRAN_API void srsran_sss_put_slot(float* sss, cf_t* symbol, uint32_t nof_prb, srsran_cp_t cp); + +SRSRAN_API void srsran_sss_put_symbol(float* sss, cf_t* symbol, uint32_t nof_prb); + +SRSRAN_API int srsran_sss_set_N_id_2(srsran_sss_t* q, uint32_t N_id_2); + +SRSRAN_API int srsran_sss_m0m1_partial(srsran_sss_t* q, + const cf_t* input, + uint32_t M, + cf_t ce[2 * SRSRAN_SSS_N], + uint32_t* m0, + float* m0_value, + uint32_t* m1, + float* m1_value); + +SRSRAN_API int srsran_sss_m0m1_diff_coh(srsran_sss_t* q, + const cf_t* input, + cf_t ce[2 * SRSRAN_SSS_N], + uint32_t* m0, + float* m0_value, + uint32_t* m1, + float* m1_value); + +SRSRAN_API int +srsran_sss_m0m1_diff(srsran_sss_t* q, const cf_t* input, uint32_t* m0, float* m0_value, uint32_t* m1, float* m1_value); + +SRSRAN_API uint32_t srsran_sss_subframe(uint32_t m0, uint32_t m1); + +SRSRAN_API int srsran_sss_N_id_1(srsran_sss_t* q, uint32_t m0, uint32_t m1, float corr); + +SRSRAN_API int srsran_sss_frame(srsran_sss_t* q, cf_t* input, uint32_t* subframe_idx, uint32_t* N_id_1); + +SRSRAN_API void srsran_sss_set_threshold(srsran_sss_t* q, float threshold); + +SRSRAN_API void srsran_sss_set_symbol_sz(srsran_sss_t* q, uint32_t symbol_sz); + +SRSRAN_API void srsran_sss_set_subframe_sz(srsran_sss_t* q, uint32_t subframe_sz); + +#endif // SRSRAN_SSS_H diff --git a/lib/include/srsran/phy/sync/ssss.h b/lib/include/srsran/phy/sync/ssss.h new file mode 100644 index 000000000..1ab9593fd --- /dev/null +++ b/lib/include/srsran/phy/sync/ssss.h @@ -0,0 +1,71 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +/****************************************************************************** + * File: ssss.h + * + * Description: Secondary sidelink synchronization signal (SSSS) generation and detection. + * + * + * Reference: 3GPP TS 36.211 version 15.6.0 Release 15 Sec. 9.7.2 + *****************************************************************************/ + +#ifndef SRSRAN_SSSS_H +#define SRSRAN_SSSS_H + +#include +#include + +#include "srsran/phy/common/phy_common_sl.h" +#include "srsran/phy/dft/dft.h" + +#define SRSRAN_SSSS_NOF_SEQ 336 +#define SRSRAN_SSSS_N 31 +#define SRSRAN_SSSS_LEN 2 * SRSRAN_SSSS_N + +typedef struct SRSRAN_API { + + float ssss_signal[SRSRAN_SSSS_NOF_SEQ][SRSRAN_SSSS_LEN]; // One sequence for each N_sl_id + + cf_t** ssss_sf_freq; + + cf_t* input_pad_freq; + cf_t* input_pad_time; + + cf_t* dot_prod_output; + cf_t* dot_prod_output_time; + + cf_t* shifted_output; + + float* shifted_output_abs; + + int32_t corr_peak_pos; + float corr_peak_value; + + uint32_t N_sl_id; + + srsran_dft_plan_t plan_input; + srsran_dft_plan_t plan_out; + +} srsran_ssss_t; + +SRSRAN_API int srsran_ssss_init(srsran_ssss_t* q, uint32_t nof_prb, srsran_cp_t cp, srsran_sl_tm_t tm); + +SRSRAN_API void srsran_ssss_generate(float* ssss_signal, uint32_t N_sl_id, srsran_sl_tm_t tm); + +SRSRAN_API void srsran_ssss_put_sf_buffer(float* ssss_signal, cf_t* sf_buffer, uint32_t nof_prb, srsran_cp_t cp); + +SRSRAN_API int srsran_ssss_find(srsran_ssss_t* q, cf_t* input, uint32_t nof_prb, uint32_t N_id_2, srsran_cp_t cp); + +SRSRAN_API void srsran_ssss_free(srsran_ssss_t* q); + +#endif \ No newline at end of file diff --git a/lib/include/srslte/phy/sync/sync.h b/lib/include/srsran/phy/sync/sync.h similarity index 57% rename from lib/include/srslte/phy/sync/sync.h rename to lib/include/srsran/phy/sync/sync.h index 4e92aa769..7d638c9b3 100644 --- a/lib/include/srslte/phy/sync/sync.h +++ b/lib/include/srsran/phy/sync/sync.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -28,28 +28,28 @@ * Reference: 3GPP TS 36.211 version 10.0.0 Release 10 Sec. 6.11.1, 6.11.2 *****************************************************************************/ -#ifndef SRSLTE_SYNC_H -#define SRSLTE_SYNC_H +#ifndef SRSRAN_SYNC_H +#define SRSRAN_SYNC_H #include #include -#include "srslte/config.h" -#include "srslte/phy/sync/cfo.h" -#include "srslte/phy/sync/cp.h" -#include "srslte/phy/sync/pss.h" -#include "srslte/phy/sync/sss.h" +#include "srsran/config.h" +#include "srsran/phy/sync/cfo.h" +#include "srsran/phy/sync/cp.h" +#include "srsran/phy/sync/pss.h" +#include "srsran/phy/sync/sss.h" -#define SRSLTE_SYNC_FFT_SZ_MIN 64 -#define SRSLTE_SYNC_FFT_SZ_MAX 2048 +#define SRSRAN_SYNC_FFT_SZ_MIN 64 +#define SRSRAN_SYNC_FFT_SZ_MAX 2048 typedef enum { SSS_DIFF = 0, SSS_PARTIAL_3 = 2, SSS_FULL = 1 } sss_alg_t; -typedef struct SRSLTE_API { - srslte_pss_t pss; - srslte_pss_t pss_i[2]; - srslte_sss_t sss; - srslte_cp_synch_t cp_synch; +typedef struct SRSRAN_API { + srsran_pss_t pss; + srsran_pss_t pss_i[2]; + srsran_sss_t sss; + srsran_cp_synch_t cp_synch; cf_t* cfo_i_corr[2]; int decimate; float threshold; @@ -66,7 +66,7 @@ typedef struct SRSLTE_API { sss_alg_t sss_alg; bool detect_cp; bool sss_en; - srslte_cp_t cp; + srsran_cp_t cp; uint32_t m0; uint32_t m1; float m0_value; @@ -77,7 +77,7 @@ typedef struct SRSLTE_API { uint32_t max_frame_size; - srslte_frame_type_t frame_type; + srsran_frame_type_t frame_type; bool detect_frame_type; // variables for various CFO estimation methods @@ -98,120 +98,120 @@ typedef struct SRSLTE_API { uint32_t cfo_cp_nsymbols; - srslte_cfo_t cfo_corr_frame; - srslte_cfo_t cfo_corr_symbol; + srsran_cfo_t cfo_corr_frame; + srsran_cfo_t cfo_corr_symbol; bool sss_channel_equalize; bool pss_filtering_enabled; - cf_t sss_filt[SRSLTE_SYMBOL_SZ_MAX]; - cf_t pss_filt[SRSLTE_SYMBOL_SZ_MAX]; + cf_t sss_filt[SRSRAN_SYMBOL_SZ_MAX]; + cf_t pss_filt[SRSRAN_SYMBOL_SZ_MAX]; bool sss_generated; bool sss_detected; bool sss_available; float sss_corr; - srslte_dft_plan_t idftp_sss; - cf_t sss_recv[SRSLTE_SYMBOL_SZ_MAX]; - cf_t sss_signal[2][SRSLTE_SYMBOL_SZ_MAX]; + srsran_dft_plan_t idftp_sss; + cf_t sss_recv[SRSRAN_SYMBOL_SZ_MAX]; + cf_t sss_signal[2][SRSRAN_SYMBOL_SZ_MAX]; -} srslte_sync_t; +} srsran_sync_t; typedef enum { - SRSLTE_SYNC_FOUND = 1, - SRSLTE_SYNC_FOUND_NOSPACE = 2, - SRSLTE_SYNC_NOFOUND = 0, - SRSLTE_SYNC_ERROR = -1 -} srslte_sync_find_ret_t; + SRSRAN_SYNC_FOUND = 1, + SRSRAN_SYNC_FOUND_NOSPACE = 2, + SRSRAN_SYNC_NOFOUND = 0, + SRSRAN_SYNC_ERROR = -1 +} srsran_sync_find_ret_t; -SRSLTE_API int srslte_sync_init(srslte_sync_t* q, uint32_t frame_size, uint32_t max_offset, uint32_t fft_size); +SRSRAN_API int srsran_sync_init(srsran_sync_t* q, uint32_t frame_size, uint32_t max_offset, uint32_t fft_size); -SRSLTE_API int -srslte_sync_init_decim(srslte_sync_t* q, uint32_t frame_size, uint32_t max_offset, uint32_t fft_size, int decimate); +SRSRAN_API int +srsran_sync_init_decim(srsran_sync_t* q, uint32_t frame_size, uint32_t max_offset, uint32_t fft_size, int decimate); -SRSLTE_API void srslte_sync_free(srslte_sync_t* q); +SRSRAN_API void srsran_sync_free(srsran_sync_t* q); -SRSLTE_API int srslte_sync_resize(srslte_sync_t* q, uint32_t frame_size, uint32_t max_offset, uint32_t fft_size); +SRSRAN_API int srsran_sync_resize(srsran_sync_t* q, uint32_t frame_size, uint32_t max_offset, uint32_t fft_size); -SRSLTE_API void srslte_sync_reset(srslte_sync_t* q); +SRSRAN_API void srsran_sync_reset(srsran_sync_t* q); /* Finds a correlation peak in the input signal around position find_offset */ -SRSLTE_API srslte_sync_find_ret_t srslte_sync_find(srslte_sync_t* q, +SRSRAN_API srsran_sync_find_ret_t srsran_sync_find(srsran_sync_t* q, const cf_t* input, uint32_t find_offset, uint32_t* peak_position); /* Estimates the CP length */ -SRSLTE_API srslte_cp_t srslte_sync_detect_cp(srslte_sync_t* q, const cf_t* input, uint32_t peak_pos); +SRSRAN_API srsran_cp_t srsran_sync_detect_cp(srsran_sync_t* q, const cf_t* input, uint32_t peak_pos); /* Sets the threshold for peak comparison */ -SRSLTE_API void srslte_sync_set_threshold(srslte_sync_t* q, float threshold); +SRSRAN_API void srsran_sync_set_threshold(srsran_sync_t* q, float threshold); /* Gets the subframe idx (0 or 5) */ -SRSLTE_API uint32_t srslte_sync_get_sf_idx(srslte_sync_t* q); +SRSRAN_API uint32_t srsran_sync_get_sf_idx(srsran_sync_t* q); /* Gets the peak value */ -SRSLTE_API float srslte_sync_get_peak_value(srslte_sync_t* q); +SRSRAN_API float srsran_sync_get_peak_value(srsran_sync_t* q); /* Choose SSS detection algorithm */ -SRSLTE_API void srslte_sync_set_sss_algorithm(srslte_sync_t* q, sss_alg_t alg); +SRSRAN_API void srsran_sync_set_sss_algorithm(srsran_sync_t* q, sss_alg_t alg); /* Sets PSS exponential averaging alpha weight */ -SRSLTE_API void srslte_sync_set_em_alpha(srslte_sync_t* q, float alpha); +SRSRAN_API void srsran_sync_set_em_alpha(srsran_sync_t* q, float alpha); /* Sets the N_id_2 to search for */ -SRSLTE_API int srslte_sync_set_N_id_2(srslte_sync_t* q, uint32_t N_id_2); +SRSRAN_API int srsran_sync_set_N_id_2(srsran_sync_t* q, uint32_t N_id_2); -SRSLTE_API int srslte_sync_set_N_id_1(srslte_sync_t* q, uint32_t N_id_1); +SRSRAN_API int srsran_sync_set_N_id_1(srsran_sync_t* q, uint32_t N_id_1); /* Gets the Physical CellId from the last call to synch_run() */ -SRSLTE_API int srslte_sync_get_cell_id(srslte_sync_t* q); +SRSRAN_API int srsran_sync_get_cell_id(srsran_sync_t* q); /* Enables/disables filtering of the central PRBs before PSS CFO estimation or SSS correlation*/ -SRSLTE_API void srslte_sync_set_pss_filt_enable(srslte_sync_t* q, bool enable); +SRSRAN_API void srsran_sync_set_pss_filt_enable(srsran_sync_t* q, bool enable); -SRSLTE_API void srslte_sync_set_sss_eq_enable(srslte_sync_t* q, bool enable); +SRSRAN_API void srsran_sync_set_sss_eq_enable(srsran_sync_t* q, bool enable); /* Gets the CFO estimation from the last call to synch_run() */ -SRSLTE_API float srslte_sync_get_cfo(srslte_sync_t* q); +SRSRAN_API float srsran_sync_get_cfo(srsran_sync_t* q); /* Resets internal CFO state */ -SRSLTE_API void srslte_sync_cfo_reset(srslte_sync_t* q, float cfo_Hz); +SRSRAN_API void srsran_sync_cfo_reset(srsran_sync_t* q, float cfo_Hz); /* Copies CFO internal state from another object to avoid long transients */ -SRSLTE_API void srslte_sync_copy_cfo(srslte_sync_t* q, srslte_sync_t* src_obj); +SRSRAN_API void srsran_sync_copy_cfo(srsran_sync_t* q, srsran_sync_t* src_obj); /* Enable different CFO estimation stages */ -SRSLTE_API void srslte_sync_set_cfo_i_enable(srslte_sync_t* q, bool enable); -SRSLTE_API void srslte_sync_set_cfo_cp_enable(srslte_sync_t* q, bool enable, uint32_t nof_symbols); +SRSRAN_API void srsran_sync_set_cfo_i_enable(srsran_sync_t* q, bool enable); +SRSRAN_API void srsran_sync_set_cfo_cp_enable(srsran_sync_t* q, bool enable, uint32_t nof_symbols); -SRSLTE_API void srslte_sync_set_cfo_pss_enable(srslte_sync_t* q, bool enable); +SRSRAN_API void srsran_sync_set_cfo_pss_enable(srsran_sync_t* q, bool enable); /* Sets CFO correctors tolerance (in Hz) */ -SRSLTE_API void srslte_sync_set_cfo_tol(srslte_sync_t* q, float tol); +SRSRAN_API void srsran_sync_set_cfo_tol(srsran_sync_t* q, float tol); -SRSLTE_API void srslte_sync_set_frame_type(srslte_sync_t* q, srslte_frame_type_t frame_type); +SRSRAN_API void srsran_sync_set_frame_type(srsran_sync_t* q, srsran_frame_type_t frame_type); /* Sets the exponential moving average coefficient for CFO averaging */ -SRSLTE_API void srslte_sync_set_cfo_ema_alpha(srslte_sync_t* q, float alpha); +SRSRAN_API void srsran_sync_set_cfo_ema_alpha(srsran_sync_t* q, float alpha); /* Gets the CP length estimation from the last call to synch_run() */ -SRSLTE_API srslte_cp_t srslte_sync_get_cp(srslte_sync_t* q); +SRSRAN_API srsran_cp_t srsran_sync_get_cp(srsran_sync_t* q); /* Sets the CP length estimation (must do it if disabled) */ -SRSLTE_API void srslte_sync_set_cp(srslte_sync_t* q, srslte_cp_t cp); +SRSRAN_API void srsran_sync_set_cp(srsran_sync_t* q, srsran_cp_t cp); /* Enables/Disables SSS detection */ -SRSLTE_API void srslte_sync_sss_en(srslte_sync_t* q, bool enabled); +SRSRAN_API void srsran_sync_sss_en(srsran_sync_t* q, bool enabled); -SRSLTE_API srslte_pss_t* srslte_sync_get_cur_pss_obj(srslte_sync_t* q); +SRSRAN_API srsran_pss_t* srsran_sync_get_cur_pss_obj(srsran_sync_t* q); -SRSLTE_API bool srslte_sync_sss_detected(srslte_sync_t* q); +SRSRAN_API bool srsran_sync_sss_detected(srsran_sync_t* q); -SRSLTE_API float srslte_sync_sss_correlation_peak(srslte_sync_t* q); +SRSRAN_API float srsran_sync_sss_correlation_peak(srsran_sync_t* q); -SRSLTE_API bool srslte_sync_sss_available(srslte_sync_t* q); +SRSRAN_API bool srsran_sync_sss_available(srsran_sync_t* q); /* Enables/Disables CP detection */ -SRSLTE_API void srslte_sync_cp_en(srslte_sync_t* q, bool enabled); +SRSRAN_API void srsran_sync_cp_en(srsran_sync_t* q, bool enabled); -#endif // SRSLTE_SYNC_H +#endif // SRSRAN_SYNC_H diff --git a/lib/include/srslte/phy/sync/sync_nbiot.h b/lib/include/srsran/phy/sync/sync_nbiot.h similarity index 56% rename from lib/include/srslte/phy/sync/sync_nbiot.h rename to lib/include/srsran/phy/sync/sync_nbiot.h index 42bf74c09..f37ee3a99 100644 --- a/lib/include/srslte/phy/sync/sync_nbiot.h +++ b/lib/include/srsran/phy/sync/sync_nbiot.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -25,24 +25,24 @@ * Reference: 3GPP TS 36.211 version 13.2.0 Release 13 *****************************************************************************/ -#ifndef SRSLTE_SYNC_NBIOT_H -#define SRSLTE_SYNC_NBIOT_H +#ifndef SRSRAN_SYNC_NBIOT_H +#define SRSRAN_SYNC_NBIOT_H #include #include -#include "srslte/config.h" -#include "srslte/phy/sync/npss.h" -#include "srslte/phy/sync/nsss.h" -#include "srslte/phy/sync/sync.h" -#include "srslte/phy/ue/ue_sync.h" +#include "srsran/config.h" +#include "srsran/phy/sync/npss.h" +#include "srsran/phy/sync/nsss.h" +#include "srsran/phy/sync/sync.h" +#include "srsran/phy/ue/ue_sync.h" #define MAX_NUM_CFO_CANDITATES 50 -typedef struct SRSLTE_API { - srslte_npss_synch_t npss; - srslte_nsss_synch_t nsss; - srslte_cp_synch_t cp_synch; +typedef struct SRSRAN_API { + srsran_npss_synch_t npss; + srsran_nsss_synch_t nsss; + srsran_cp_synch_t cp_synch; uint32_t n_id_ncell; float threshold; @@ -66,51 +66,51 @@ typedef struct SRSLTE_API { float cfo_ema_alpha; uint32_t nof_symbols; uint32_t cp_len; - srslte_cfo_t cfocorr; - srslte_cp_t cp; -} srslte_sync_nbiot_t; + srsran_cfo_t cfocorr; + srsran_cp_t cp; +} srsran_sync_nbiot_t; -SRSLTE_API int -srslte_sync_nbiot_init(srslte_sync_nbiot_t* q, uint32_t frame_size, uint32_t max_offset, uint32_t fft_size); +SRSRAN_API int +srsran_sync_nbiot_init(srsran_sync_nbiot_t* q, uint32_t frame_size, uint32_t max_offset, uint32_t fft_size); -SRSLTE_API void srslte_sync_nbiot_free(srslte_sync_nbiot_t* q); +SRSRAN_API void srsran_sync_nbiot_free(srsran_sync_nbiot_t* q); -SRSLTE_API int -srslte_sync_nbiot_resize(srslte_sync_nbiot_t* q, uint32_t frame_size, uint32_t max_offset, uint32_t fft_size); +SRSRAN_API int +srsran_sync_nbiot_resize(srsran_sync_nbiot_t* q, uint32_t frame_size, uint32_t max_offset, uint32_t fft_size); -SRSLTE_API srslte_sync_find_ret_t srslte_sync_nbiot_find(srslte_sync_nbiot_t* q, +SRSRAN_API srsran_sync_find_ret_t srsran_sync_nbiot_find(srsran_sync_nbiot_t* q, cf_t* input, uint32_t find_offset, uint32_t* peak_position); -SRSLTE_API float cfo_estimate_nbiot(srslte_sync_nbiot_t* q, cf_t* input); +SRSRAN_API float cfo_estimate_nbiot(srsran_sync_nbiot_t* q, cf_t* input); -SRSLTE_API void srslte_sync_nbiot_set_threshold(srslte_sync_nbiot_t* q, float threshold); +SRSRAN_API void srsran_sync_nbiot_set_threshold(srsran_sync_nbiot_t* q, float threshold); -SRSLTE_API void srslte_sync_nbiot_set_cfo_enable(srslte_sync_nbiot_t* q, bool enable); +SRSRAN_API void srsran_sync_nbiot_set_cfo_enable(srsran_sync_nbiot_t* q, bool enable); -SRSLTE_API void srslte_sync_nbiot_set_cfo_cand_test_enable(srslte_sync_nbiot_t* q, bool enable); +SRSRAN_API void srsran_sync_nbiot_set_cfo_cand_test_enable(srsran_sync_nbiot_t* q, bool enable); -SRSLTE_API int srslte_sync_nbiot_set_cfo_cand(srslte_sync_nbiot_t* q, const float* cand, const int num); +SRSRAN_API int srsran_sync_nbiot_set_cfo_cand(srsran_sync_nbiot_t* q, const float* cand, const int num); -SRSLTE_API void srslte_sync_nbiot_set_cfo_tol(srslte_sync_nbiot_t* q, float tol); +SRSRAN_API void srsran_sync_nbiot_set_cfo_tol(srsran_sync_nbiot_t* q, float tol); -SRSLTE_API void srslte_sync_nbiot_set_cfo_ema_alpha(srslte_sync_nbiot_t* q, float alpha); +SRSRAN_API void srsran_sync_nbiot_set_cfo_ema_alpha(srsran_sync_nbiot_t* q, float alpha); -SRSLTE_API void srslte_sync_nbiot_set_npss_ema_alpha(srslte_sync_nbiot_t* q, float alpha); +SRSRAN_API void srsran_sync_nbiot_set_npss_ema_alpha(srsran_sync_nbiot_t* q, float alpha); -SRSLTE_API int srslte_sync_nbiot_find_cell_id(srslte_sync_nbiot_t* q, cf_t* input); +SRSRAN_API int srsran_sync_nbiot_find_cell_id(srsran_sync_nbiot_t* q, cf_t* input); -SRSLTE_API int srslte_sync_nbiot_get_cell_id(srslte_sync_nbiot_t* q); +SRSRAN_API int srsran_sync_nbiot_get_cell_id(srsran_sync_nbiot_t* q); -SRSLTE_API float srslte_sync_nbiot_get_cfo(srslte_sync_nbiot_t* q); +SRSRAN_API float srsran_sync_nbiot_get_cfo(srsran_sync_nbiot_t* q); -SRSLTE_API void srslte_sync_nbiot_set_cfo(srslte_sync_nbiot_t* q, float cfo); +SRSRAN_API void srsran_sync_nbiot_set_cfo(srsran_sync_nbiot_t* q, float cfo); -SRSLTE_API bool srslte_sync_nbiot_nsss_detected(srslte_sync_nbiot_t* q); +SRSRAN_API bool srsran_sync_nbiot_nsss_detected(srsran_sync_nbiot_t* q); -SRSLTE_API float srslte_sync_nbiot_get_peak_value(srslte_sync_nbiot_t* q); +SRSRAN_API float srsran_sync_nbiot_get_peak_value(srsran_sync_nbiot_t* q); -SRSLTE_API void srslte_sync_nbiot_reset(srslte_sync_nbiot_t* q); +SRSRAN_API void srsran_sync_nbiot_reset(srsran_sync_nbiot_t* q); -#endif // SRSLTE_SYNC_NBIOT_H +#endif // SRSRAN_SYNC_NBIOT_H diff --git a/lib/include/srsran/phy/ue/ue_cell_search.h b/lib/include/srsran/phy/ue/ue_cell_search.h new file mode 100644 index 000000000..98da33300 --- /dev/null +++ b/lib/include/srsran/phy/ue/ue_cell_search.h @@ -0,0 +1,94 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +/****************************************************************************** + * File: ue_cell_search.h + * + * Description: Wrapper for the ue_sync object. + * + * This object is a wrapper to the ue_sync object. It receives + * several synchronized frames and obtains the most common cell_id + * and cp length. + * + * The I/O stream device sampling frequency must be set to 1.92 MHz + * (SRSRAN_CS_SAMP_FREQ constant) before calling to + * srsran_ue_cellsearch_scan() functions. + * + * Reference: + *****************************************************************************/ + +#ifndef SRSRAN_UE_CELL_SEARCH_H +#define SRSRAN_UE_CELL_SEARCH_H + +#include + +#include "srsran/config.h" +#include "srsran/phy/ch_estimation/chest_dl.h" +#include "srsran/phy/dft/ofdm.h" +#include "srsran/phy/phch/pbch.h" +#include "srsran/phy/sync/cfo.h" +#include "srsran/phy/ue/ue_mib.h" +#include "srsran/phy/ue/ue_sync.h" + +#define SRSRAN_CS_NOF_PRB 6 +#define SRSRAN_CS_SAMP_FREQ 1920000.0 + +typedef struct SRSRAN_API { + uint32_t cell_id; + srsran_cp_t cp; + srsran_frame_type_t frame_type; + float peak; + float mode; + float psr; + float cfo; +} srsran_ue_cellsearch_result_t; + +typedef struct SRSRAN_API { + srsran_ue_sync_t ue_sync; + + cf_t* sf_buffer[SRSRAN_MAX_CHANNELS]; + uint32_t nof_rx_antennas; + + uint32_t max_frames; + uint32_t nof_valid_frames; // number of 5 ms frames to scan + + uint32_t *mode_ntimes; + uint8_t* mode_counted; + + srsran_ue_cellsearch_result_t* candidates; +} srsran_ue_cellsearch_t; + +SRSRAN_API int srsran_ue_cellsearch_init(srsran_ue_cellsearch_t* q, + uint32_t max_frames_total, + int(recv_callback)(void*, void*, uint32_t, srsran_timestamp_t*), + void* stream_handler); + +SRSRAN_API int +srsran_ue_cellsearch_init_multi(srsran_ue_cellsearch_t* q, + uint32_t max_frames_total, + int(recv_callback)(void*, cf_t* [SRSRAN_MAX_CHANNELS], uint32_t, srsran_timestamp_t*), + uint32_t nof_rx_antennas, + void* stream_handler); + +SRSRAN_API void srsran_ue_cellsearch_free(srsran_ue_cellsearch_t* q); + +SRSRAN_API int +srsran_ue_cellsearch_scan_N_id_2(srsran_ue_cellsearch_t* q, uint32_t N_id_2, srsran_ue_cellsearch_result_t* found_cell); + +SRSRAN_API int srsran_ue_cellsearch_scan(srsran_ue_cellsearch_t* q, + srsran_ue_cellsearch_result_t found_cells[3], + uint32_t* max_N_id_2); + +SRSRAN_API int srsran_ue_cellsearch_set_nof_valid_frames(srsran_ue_cellsearch_t* q, uint32_t nof_frames); + +#endif // SRSRAN_UE_CELL_SEARCH_H + diff --git a/lib/include/srsran/phy/ue/ue_cell_search_nbiot.h b/lib/include/srsran/phy/ue/ue_cell_search_nbiot.h new file mode 100644 index 000000000..dc8d2e483 --- /dev/null +++ b/lib/include/srsran/phy/ue/ue_cell_search_nbiot.h @@ -0,0 +1,72 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +#ifndef SRSRAN_UE_CELL_SEARCH_NBIOT_H +#define SRSRAN_UE_CELL_SEARCH_NBIOT_H + +#include "srsran/config.h" +#include "srsran/phy/ch_estimation/chest_dl_nbiot.h" +#include "srsran/phy/dft/ofdm.h" +#include "srsran/phy/phch/npbch.h" +#include "srsran/phy/sync/cfo.h" +#include "srsran/phy/ue/ue_mib_nbiot.h" +#include "srsran/phy/ue/ue_sync_nbiot.h" + +#define SRSRAN_CS_NOF_PRB 6 +#define SRSRAN_CS_SAMP_FREQ 1920000.0 + +typedef struct SRSRAN_API { + uint32_t n_id_ncell; + float peak; + float mode; + float psr; + float cfo; +} srsran_nbiot_ue_cellsearch_result_t; + +/** + * \brief Wrapper for the nbiot_ue_sync object. + * + * This object is a wrapper to the nbiot_ue_sync object. It receives + * several synchronized frames and obtains the most common n_id_ncell. + * + * The I/O stream device sampling frequency must be set to 1.92 MHz + * (SRSRAN_CS_SAMP_FREQ constant) before calling to + * srsran_ue_cellsearch_nbiot_scan() functions. + */ +typedef struct SRSRAN_API { + srsran_nbiot_ue_sync_t ue_sync; + int32_t sf_len; + + cf_t* rx_buffer[SRSRAN_MAX_CHANNELS]; + cf_t* nsss_buffer; + int nsss_sf_counter; + + uint32_t max_frames; + uint32_t nof_valid_frames; // number of frames to scan +} srsran_ue_cellsearch_nbiot_t; + +SRSRAN_API int +srsran_ue_cellsearch_nbiot_init(srsran_ue_cellsearch_nbiot_t* q, + uint32_t max_frames_total, + int(recv_callback)(void*, cf_t* [SRSRAN_MAX_CHANNELS], uint32_t, srsran_timestamp_t*), + void* stream_handler); + +SRSRAN_API void srsran_ue_cellsearch_nbiot_free(srsran_ue_cellsearch_nbiot_t* q); + +SRSRAN_API int srsran_ue_cellsearch_nbiot_scan(srsran_ue_cellsearch_nbiot_t* q); + +SRSRAN_API int srsran_ue_cellsearch_nbiot_detect(srsran_ue_cellsearch_nbiot_t* q, + srsran_nbiot_ue_cellsearch_result_t* found_cells); + +SRSRAN_API int srsran_ue_cellsearch_nbiot_set_nof_valid_frames(srsran_ue_cellsearch_nbiot_t* q, uint32_t nof_frames); + +#endif // SRSRAN_UE_CELL_SEARCH_NBIOT_H diff --git a/lib/include/srsran/phy/ue/ue_dl.h b/lib/include/srsran/phy/ue/ue_dl.h new file mode 100644 index 000000000..366b062dc --- /dev/null +++ b/lib/include/srsran/phy/ue/ue_dl.h @@ -0,0 +1,238 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +/****************************************************************************** + * File: ue_dl.h + * + * Description: UE downlink object. + * + * This module is a frontend to all the downlink data and control + * channel processing modules. + * + * Reference: + *****************************************************************************/ + +#ifndef SRSRAN_UE_DL_H +#define SRSRAN_UE_DL_H + +#include + +#include "srsran/phy/ch_estimation/chest_dl.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/dft/ofdm.h" + +#include "srsran/phy/phch/dci.h" +#include "srsran/phy/phch/pcfich.h" +#include "srsran/phy/phch/pdcch.h" +#include "srsran/phy/phch/pdsch.h" +#include "srsran/phy/phch/pdsch_cfg.h" +#include "srsran/phy/phch/phich.h" +#include "srsran/phy/phch/pmch.h" +#include "srsran/phy/phch/ra.h" +#include "srsran/phy/phch/regs.h" + +#include "srsran/phy/sync/cfo.h" + +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" + +#include "srsran/config.h" + +#define SRSRAN_MAX_CANDIDATES_UE 16 // From 36.213 Table 9.1.1-1 +#define SRSRAN_MAX_CANDIDATES_COM 6 // From 36.213 Table 9.1.1-1 +#define SRSRAN_MAX_CANDIDATES (SRSRAN_MAX_CANDIDATES_UE + SRSRAN_MAX_CANDIDATES_COM) + +#define SRSRAN_MAX_FORMATS 4 + +#define SRSRAN_MI_NOF_REGS ((q->cell.frame_type == SRSRAN_FDD) ? 1 : 6) +#define SRSRAN_MI_MAX_REGS 6 + +#define SRSRAN_MAX_DCI_MSG SRSRAN_MAX_CARRIERS + +typedef struct SRSRAN_API { + srsran_dci_format_t formats[SRSRAN_MAX_FORMATS]; + srsran_dci_location_t loc[SRSRAN_MAX_CANDIDATES]; + uint32_t nof_locations; + uint32_t nof_formats; +} dci_blind_search_t; + +typedef struct SRSRAN_API { + // Cell configuration + srsran_cell_t cell; + uint32_t nof_rx_antennas; + uint16_t current_mbsfn_area_id; + + // Objects for all DL Physical Channels + srsran_pcfich_t pcfich; + srsran_pdcch_t pdcch; + srsran_pdsch_t pdsch; + srsran_pmch_t pmch; + srsran_phich_t phich; + + // Control region + srsran_regs_t regs[SRSRAN_MI_MAX_REGS]; + uint32_t mi_manual_index; + bool mi_auto; + + // Channel estimation and OFDM demodulation + srsran_chest_dl_t chest; + srsran_chest_dl_res_t chest_res; + srsran_ofdm_t fft[SRSRAN_MAX_PORTS]; + srsran_ofdm_t fft_mbsfn; + + // Buffers to store channel symbols after demodulation + cf_t* sf_symbols[SRSRAN_MAX_PORTS]; + dci_blind_search_t current_ss_common; + + srsran_dci_msg_t pending_ul_dci_msg[SRSRAN_MAX_DCI_MSG]; + uint32_t pending_ul_dci_count; + + srsran_dci_location_t allocated_locations[SRSRAN_MAX_DCI_MSG]; + uint32_t nof_allocated_locations; +} srsran_ue_dl_t; + +// Downlink config (includes common and dedicated variables) +typedef struct SRSRAN_API { + srsran_cqi_report_cfg_t cqi_report; + srsran_pdsch_cfg_t pdsch; + srsran_dci_cfg_t dci; + srsran_tm_t tm; + bool dci_common_ss; +} srsran_dl_cfg_t; + +typedef struct SRSRAN_API { + srsran_dl_cfg_t cfg; + srsran_chest_dl_cfg_t chest_cfg; + uint32_t last_ri; + float snr_to_cqi_offset; +} srsran_ue_dl_cfg_t; + +typedef struct { + uint32_t v_dai_dl; + uint32_t n_cce; + uint32_t grant_cc_idx; + uint32_t tpc_for_pucch; +} srsran_pdsch_ack_resource_t; + +typedef struct { + srsran_pdsch_ack_resource_t resource; + uint32_t k; + uint8_t value[SRSRAN_MAX_CODEWORDS]; // 0/1 or 2 for DTX + bool present; +} srsran_pdsch_ack_m_t; + +typedef struct { + uint32_t M; + srsran_pdsch_ack_m_t m[SRSRAN_UCI_MAX_M]; +} srsran_pdsch_ack_cc_t; + +typedef struct { + srsran_pdsch_ack_cc_t cc[SRSRAN_MAX_CARRIERS]; + uint32_t nof_cc; + uint32_t V_dai_ul; + srsran_tm_t transmission_mode; + srsran_ack_nack_feedback_mode_t ack_nack_feedback_mode; + bool is_grant_available; + bool is_pusch_available; + bool tdd_ack_multiplex; + bool simul_cqi_ack; + bool simul_cqi_ack_pucch3; +} srsran_pdsch_ack_t; + +SRSRAN_API int +srsran_ue_dl_init(srsran_ue_dl_t* q, cf_t* input[SRSRAN_MAX_PORTS], uint32_t max_prb, uint32_t nof_rx_antennas); + +SRSRAN_API void srsran_ue_dl_free(srsran_ue_dl_t* q); + +SRSRAN_API int srsran_ue_dl_set_cell(srsran_ue_dl_t* q, srsran_cell_t cell); + +SRSRAN_API int srsran_ue_dl_set_mbsfn_area_id(srsran_ue_dl_t* q, uint16_t mbsfn_area_id); + +SRSRAN_API void srsran_ue_dl_set_non_mbsfn_region(srsran_ue_dl_t* q, uint8_t non_mbsfn_region_length); + +SRSRAN_API void srsran_ue_dl_set_mi_manual(srsran_ue_dl_t* q, uint32_t mi_idx); + +SRSRAN_API void srsran_ue_dl_set_mi_auto(srsran_ue_dl_t* q); + +/* Perform signal demodulation and channel estimation and store signals in the object */ +SRSRAN_API int srsran_ue_dl_decode_fft_estimate(srsran_ue_dl_t* q, srsran_dl_sf_cfg_t* sf, srsran_ue_dl_cfg_t* cfg); + +SRSRAN_API int srsran_ue_dl_decode_fft_estimate_noguru(srsran_ue_dl_t* q, + srsran_dl_sf_cfg_t* sf, + srsran_ue_dl_cfg_t* cfg, + cf_t* input[SRSRAN_MAX_PORTS]); + +/* Finds UL/DL DCI in the signal processed in a previous call to decode_fft_estimate() */ +SRSRAN_API int srsran_ue_dl_find_ul_dci(srsran_ue_dl_t* q, + srsran_dl_sf_cfg_t* sf, + srsran_ue_dl_cfg_t* dl_cfg, + uint16_t rnti, + srsran_dci_ul_t dci_msg[SRSRAN_MAX_DCI_MSG]); + +SRSRAN_API int srsran_ue_dl_find_dl_dci(srsran_ue_dl_t* q, + srsran_dl_sf_cfg_t* sf, + srsran_ue_dl_cfg_t* dl_cfg, + uint16_t rnti, + srsran_dci_dl_t dci_msg[SRSRAN_MAX_DCI_MSG]); + +SRSRAN_API int srsran_ue_dl_dci_to_pdsch_grant(srsran_ue_dl_t* q, + srsran_dl_sf_cfg_t* sf, + srsran_ue_dl_cfg_t* cfg, + srsran_dci_dl_t* dci, + srsran_pdsch_grant_t* grant); + +/* Decodes PDSCH and PHICH in the signal processed in a previous call to decode_fft_estimate() */ +SRSRAN_API int srsran_ue_dl_decode_pdsch(srsran_ue_dl_t* q, + srsran_dl_sf_cfg_t* sf, + srsran_pdsch_cfg_t* pdsch_cfg, + srsran_pdsch_res_t data[SRSRAN_MAX_CODEWORDS]); + +SRSRAN_API int srsran_ue_dl_decode_pmch(srsran_ue_dl_t* q, + srsran_dl_sf_cfg_t* sf, + srsran_pmch_cfg_t* pmch_cfg, + srsran_pdsch_res_t* data); + +SRSRAN_API int srsran_ue_dl_decode_phich(srsran_ue_dl_t* q, + srsran_dl_sf_cfg_t* sf, + srsran_ue_dl_cfg_t* cfg, + srsran_phich_grant_t* grant, + srsran_phich_res_t* result); + +SRSRAN_API int srsran_ue_dl_select_ri(srsran_ue_dl_t* q, uint32_t* ri, float* cn); + +SRSRAN_API void srsran_ue_dl_gen_cqi_periodic(srsran_ue_dl_t* q, + srsran_ue_dl_cfg_t* cfg, + uint32_t wideband_value, + uint32_t tti, + srsran_uci_data_t* uci_data); + +SRSRAN_API void srsran_ue_dl_gen_cqi_aperiodic(srsran_ue_dl_t* q, + srsran_ue_dl_cfg_t* cfg, + uint32_t wideband_value, + srsran_uci_data_t* uci_data); + +SRSRAN_API void srsran_ue_dl_gen_ack(const srsran_cell_t* cell, + const srsran_dl_sf_cfg_t* sf, + const srsran_pdsch_ack_t* ack_info, + srsran_uci_data_t* uci_data); + +/* Functions used for testing purposes */ +SRSRAN_API int srsran_ue_dl_find_and_decode(srsran_ue_dl_t* q, + srsran_dl_sf_cfg_t* sf, + srsran_ue_dl_cfg_t* cfg, + srsran_pdsch_cfg_t* pdsch_cfg, + uint8_t* data[SRSRAN_MAX_CODEWORDS], + bool acks[SRSRAN_MAX_CODEWORDS]); + +SRSRAN_API void srsran_ue_dl_save_signal(srsran_ue_dl_t* q, srsran_dl_sf_cfg_t* sf, srsran_pdsch_cfg_t* pdsch_cfg); + +#endif // SRSRAN_UE_DL_H diff --git a/lib/include/srsran/phy/ue/ue_dl_nbiot.h b/lib/include/srsran/phy/ue/ue_dl_nbiot.h new file mode 100644 index 000000000..e290dc92e --- /dev/null +++ b/lib/include/srsran/phy/ue/ue_dl_nbiot.h @@ -0,0 +1,182 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +#ifndef SRSRAN_UE_DL_NBIOT_H +#define SRSRAN_UE_DL_NBIOT_H + +#include + +#include "srsran/phy/ch_estimation/chest_dl_nbiot.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/dft/ofdm.h" + +#include "srsran/phy/phch/dci_nbiot.h" +#include "srsran/phy/phch/npdcch.h" +#include "srsran/phy/phch/npdsch.h" +#include "srsran/phy/phch/npdsch_cfg.h" +#include "srsran/phy/phch/ra_nbiot.h" + +#include "srsran/phy/sync/cfo.h" + +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" + +#include "srsran/config.h" + +#define SRSRAN_NBIOT_EXPECT_MORE_SF -3 // returned when expecting more subframes for successful decoding +#define SRSRAN_NBIOT_UE_DL_FOUND_DCI -4 // returned when DCI for given RNTI was found +#define SRSRAN_NBIOT_UE_DL_SKIP_SF -5 + +/* + * @brief Narrowband UE downlink object. + * + * This module is a frontend to all the downlink data and control + * channel processing modules. + */ +typedef struct SRSRAN_API { + srsran_npdcch_t npdcch; + srsran_npdsch_t npdsch; + srsran_ofdm_t fft; + srsran_chest_dl_nbiot_t chest; + + srsran_cfo_t sfo_correct; + + srsran_softbuffer_rx_t softbuffer; + srsran_nbiot_cell_t cell; + srsran_mib_nb_t mib; + bool mib_set; + + int nof_re; // Number of RE per subframe + cf_t* sf_symbols; // this buffer holds the symbols of the current subframe + cf_t* sf_buffer; // this buffer holds multiple subframes + cf_t* ce[SRSRAN_MAX_PORTS]; + cf_t* ce_buffer[SRSRAN_MAX_PORTS]; + float* llr; // Buffer to hold soft-bits for later combining repetitions + + uint32_t pkt_errors; + uint32_t pkts_total; + uint32_t pkts_ok; + uint32_t nof_detected; + uint32_t bits_total; + + // DL configuration for "normal" transmissions + bool has_dl_grant; + srsran_npdsch_cfg_t npdsch_cfg; + + // DL configuration for SIB1 transmissions + uint32_t sib1_sfn[4 * SIB1_NB_MAX_REP]; // there are 4 SIB1 TTIs in each hyper frame + srsran_nbiot_si_params_t si_params[SRSRAN_NBIOT_SI_TYPE_NITEMS]; + bool si_tti[10240]; // We trade memory consumption for speed + + uint16_t current_rnti; + uint32_t last_n_cce; + srsran_dci_location_t last_location; + + float sample_offset; +} srsran_nbiot_ue_dl_t; + +// This function shall be called just after the initial synchronization +SRSRAN_API int srsran_nbiot_ue_dl_init(srsran_nbiot_ue_dl_t* q, + cf_t* in_buffer[SRSRAN_MAX_PORTS], + uint32_t max_prb, + uint32_t nof_rx_antennas); + +SRSRAN_API void srsran_nbiot_ue_dl_free(srsran_nbiot_ue_dl_t* q); + +SRSRAN_API int srsran_nbiot_ue_dl_set_cell(srsran_nbiot_ue_dl_t* q, srsran_nbiot_cell_t cell); + +SRSRAN_API int srsran_nbiot_ue_dl_decode_fft_estimate(srsran_nbiot_ue_dl_t* q, uint32_t sf_idx, bool is_dl_sf); + +SRSRAN_API int srsran_nbiot_ue_dl_decode_estimate(srsran_nbiot_ue_dl_t* q, uint32_t sf_idx); + +SRSRAN_API int +srsran_nbiot_ue_dl_cfg_grant(srsran_nbiot_ue_dl_t* q, srsran_ra_nbiot_dl_grant_t* grant, uint32_t sf_idx); + +SRSRAN_API int +srsran_nbiot_ue_dl_find_dl_dci(srsran_nbiot_ue_dl_t* q, uint32_t sf_idx, uint16_t rnti, srsran_dci_msg_t* dci_msg); + +int srsran_nbiot_ue_dl_find_dl_dci_type_siprarnti(srsran_nbiot_ue_dl_t* q, uint16_t rnti, srsran_dci_msg_t* dci_msg); + +int srsran_nbiot_ue_dl_find_dl_dci_type_crnti(srsran_nbiot_ue_dl_t* q, + uint32_t sf_idx, + uint16_t rnti, + srsran_dci_msg_t* dci_msg); + +SRSRAN_API int +srsran_nbiot_ue_dl_find_ul_dci(srsran_nbiot_ue_dl_t* q, uint32_t tti, uint32_t rnti, srsran_dci_msg_t* dci_msg); + +SRSRAN_API uint32_t srsran_nbiot_ue_dl_get_ncce(srsran_nbiot_ue_dl_t* q); + +SRSRAN_API void srsran_nbiot_ue_dl_set_sample_offset(srsran_nbiot_ue_dl_t* q, float sample_offset); + +SRSRAN_API int +srsran_nbiot_ue_dl_decode(srsran_nbiot_ue_dl_t* q, cf_t* input, uint8_t* data, uint32_t sfn, uint32_t sf_idx); + +SRSRAN_API int srsran_nbiot_ue_dl_decode_npdcch(srsran_nbiot_ue_dl_t* q, + cf_t* input, + uint32_t sfn, + uint32_t sf_idx, + uint16_t rnti, + srsran_dci_msg_t* dci_msg); + +SRSRAN_API int srsran_nbiot_ue_dl_decode_npdsch(srsran_nbiot_ue_dl_t* q, + cf_t* input, + uint8_t* data, + uint32_t sfn, + uint32_t sf_idx, + uint16_t rnti); + +int srsran_nbiot_ue_dl_decode_npdsch_bcch(srsran_nbiot_ue_dl_t* q, uint8_t* data, uint32_t tti); + +int srsran_nbiot_ue_dl_decode_npdsch_no_bcch(srsran_nbiot_ue_dl_t* q, uint8_t* data, uint32_t tti, uint16_t rnti); + +void srsran_nbiot_ue_dl_tb_decoded(srsran_nbiot_ue_dl_t* q, uint8_t* data); + +SRSRAN_API void srsran_nbiot_ue_dl_reset(srsran_nbiot_ue_dl_t* q); + +SRSRAN_API void srsran_nbiot_ue_dl_set_rnti(srsran_nbiot_ue_dl_t* q, uint16_t rnti); + +SRSRAN_API void srsran_nbiot_ue_dl_set_mib(srsran_nbiot_ue_dl_t* q, srsran_mib_nb_t mib); + +SRSRAN_API void srsran_nbiot_ue_dl_decode_sib1(srsran_nbiot_ue_dl_t* q, uint32_t current_sfn); + +SRSRAN_API void +srsran_nbiot_ue_dl_get_sib1_grant(srsran_nbiot_ue_dl_t* q, uint32_t sfn, srsran_ra_nbiot_dl_grant_t* grant); + +SRSRAN_API void srsran_nbiot_ue_dl_decode_sib(srsran_nbiot_ue_dl_t* q, + uint32_t hfn, + uint32_t sfn, + srsran_nbiot_si_type_t type, + srsran_nbiot_si_params_t params); + +SRSRAN_API void srsran_nbiot_ue_dl_get_next_si_sfn(uint32_t current_hfn, + uint32_t current_sfn, + srsran_nbiot_si_params_t params, + uint32_t* si_hfn, + uint32_t* si_sfn); + +SRSRAN_API void +srsran_nbiot_ue_dl_set_si_params(srsran_nbiot_ue_dl_t* q, srsran_nbiot_si_type_t type, srsran_nbiot_si_params_t params); + +SRSRAN_API bool srsran_nbiot_ue_dl_is_sib1_sf(srsran_nbiot_ue_dl_t* q, uint32_t sfn, uint32_t sf_idx); + +SRSRAN_API void srsran_nbiot_ue_dl_set_grant(srsran_nbiot_ue_dl_t* q, srsran_ra_nbiot_dl_grant_t* grant); + +SRSRAN_API void srsran_nbiot_ue_dl_flush_grant(srsran_nbiot_ue_dl_t* q); + +SRSRAN_API bool srsran_nbiot_ue_dl_has_grant(srsran_nbiot_ue_dl_t* q); + +SRSRAN_API void srsran_nbiot_ue_dl_check_grant(srsran_nbiot_ue_dl_t* q, srsran_ra_nbiot_dl_grant_t* grant); + +SRSRAN_API void srsran_nbiot_ue_dl_save_signal(srsran_nbiot_ue_dl_t* q, cf_t* input, uint32_t tti, uint32_t sf_idx); + +#endif // SRSRAN_UE_DL_NBIOT_H diff --git a/lib/include/srsran/phy/ue/ue_dl_nr.h b/lib/include/srsran/phy/ue/ue_dl_nr.h new file mode 100644 index 000000000..c95744430 --- /dev/null +++ b/lib/include/srsran/phy/ue/ue_dl_nr.h @@ -0,0 +1,189 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +#ifndef SRSRAN_UE_DL_NR_H +#define SRSRAN_UE_DL_NR_H + +#include "srsran/phy/ch_estimation/dmrs_pdcch.h" +#include "srsran/phy/common/phy_common_nr.h" +#include "srsran/phy/dft/ofdm.h" +#include "srsran/phy/phch/dci_nr.h" +#include "srsran/phy/phch/pdcch_nr.h" +#include "srsran/phy/phch/pdsch_nr.h" +#include "srsran/phy/phch/uci_cfg_nr.h" + +/** + * Maximum number of CORESET + * @remark Defined in TS 38.331 by maxNrofControlResourceSets-1 + */ +#define SRSRAN_UE_DL_NR_MAX_NOF_CORESET 12 + +/** + * Maximum number of Search spaces + * @remark Defined in TS 38.331 by maxNrofSearchSpaces-1 + */ +#define SRSRAN_UE_DL_NR_MAX_NOF_SEARCH_SPACE 40 + +/** + * Maximum number of DCI messages to receive + */ +#define SRSRAN_MAX_DCI_MSG_NR 4 + +typedef struct SRSRAN_API { + srsran_pdsch_nr_args_t pdsch; + srsran_pdcch_nr_args_t pdcch; + uint32_t nof_rx_antennas; + uint32_t nof_max_prb; + float pdcch_dmrs_corr_thr; + float pdcch_dmrs_epre_thr; +} srsran_ue_dl_nr_args_t; + +typedef struct SRSRAN_API { + srsran_coreset_t coreset[SRSRAN_UE_DL_NR_MAX_NOF_CORESET]; ///< PDCCH Control resource sets (CORESET) collection + bool coreset_present[SRSRAN_UE_DL_NR_MAX_NOF_CORESET]; ///< CORESET present flags + + srsran_search_space_t search_space[SRSRAN_UE_DL_NR_MAX_NOF_SEARCH_SPACE]; + bool search_space_present[SRSRAN_UE_DL_NR_MAX_NOF_SEARCH_SPACE]; + + uint16_t ra_rnti; ///< Needs to be deduced from the PRACH configuration + srsran_search_space_t ra_search_space; + bool ra_search_space_present; +} srsran_ue_dl_nr_pdcch_cfg_t; + +typedef struct { + uint32_t scell_idx; ///< Serving cell index + uint32_t v_dai_dl; ///< Downlink Assigment Index + bool dci_format_1_1; ///< Set to true if the PDSCH transmission is triggered by a PDCCH DCI format 1_1 transmission + uint32_t k1; ///< HARQ feedback timing + uint16_t rnti; + uint32_t pucch_resource_id; +} srsran_pdsch_ack_resource_nr_t; + +typedef struct { + srsran_pdsch_ack_resource_nr_t resource; + uint8_t value[SRSRAN_MAX_CODEWORDS]; // 0/1 or 2 for DTX + bool present; // set to true if there is a PDSCH on serving cell c associated with PDCCH in PDCCH monitoring occasion + // m, or there is a PDCCH indicating SPS PDSCH release on serving cell c + bool dl_bwp_changed; // set to true if PDCCH monitoring occasion m is before an active DL BWP change on serving cell c + bool ul_bwp_changed; // set to true if an active UL BWP change on the PCell and an active DL BWP change is not + // triggered by a DCI format 1_1 in PDCCH monitoring occasion m + bool second_tb_present; // set to true if two TB were detected in the PDCCH monitoring occasion m +} srsran_pdsch_ack_m_nr_t; + +#define SRSRAN_UCI_NR_MAX_M 10 + +typedef struct { + uint32_t M; + srsran_pdsch_ack_m_nr_t m[SRSRAN_UCI_NR_MAX_M]; +} srsran_pdsch_ack_cc_nr_t; + +typedef struct { + srsran_pdsch_ack_cc_nr_t cc[SRSRAN_MAX_CARRIERS]; + uint32_t nof_cc; + bool use_pusch; // Set to true, if UCI bits are carried by PUSCH +} srsran_pdsch_ack_nr_t; + +typedef struct SRSRAN_API { + bool harq_ack_spatial_bundling_pucch; ///< Param harq-ACK-SpatialBundlingPUCCH, set to true if provided + bool harq_ack_spatial_bundling_pusch; ///< Param harq-ACK-SpatialBundlingPUSCH, set to true if provided + srsran_pdsch_harq_ack_codebook_t pdsch_harq_ack_codebook; ///< pdsch-HARQ-ACK-Codebook configuration + bool max_cw_sched_dci_is_2; ///< Param maxNrofCodeWordsScheduledByDCI, set to true if present and equal to 2 + + uint32_t dl_data_to_ul_ack[SRSRAN_MAX_NOF_DL_DATA_TO_UL]; + uint32_t nof_dl_data_to_ul_ack; +} srsran_ue_dl_nr_harq_ack_cfg_t; + +typedef struct SRSRAN_API { + uint32_t coreset_id; + uint32_t ss_id; + srsran_dci_location_t location; + srsran_dmrs_pdcch_measure_t measure; + srsran_pdcch_nr_res_t result; +} srsran_ue_dl_nr_pdcch_info_t; + +typedef struct SRSRAN_API { + uint32_t max_prb; + uint32_t nof_rx_antennas; + float pdcch_dmrs_corr_thr; + float pdcch_dmrs_epre_thr; + + srsran_carrier_nr_t carrier; + srsran_ue_dl_nr_pdcch_cfg_t cfg; + + srsran_ofdm_t fft[SRSRAN_MAX_PORTS]; + + cf_t* sf_symbols[SRSRAN_MAX_PORTS]; + srsran_chest_dl_res_t chest; + srsran_pdsch_nr_t pdsch; + srsran_dmrs_sch_t dmrs_pdsch; + + srsran_dmrs_pdcch_estimator_t dmrs_pdcch[SRSRAN_UE_DL_NR_MAX_NOF_CORESET]; + srsran_pdcch_nr_t pdcch; + srsran_dmrs_pdcch_ce_t* pdcch_ce; + + /// Store Blind-search information from all possible candidate locations for debug purposes + srsran_ue_dl_nr_pdcch_info_t pdcch_info[SRSRAN_MAX_NOF_CANDIDATES_SLOT_NR]; + uint32_t pdcch_info_count; + + /// Temporally stores Found DCI messages from all SS + srsran_dci_msg_nr_t dci_msg[SRSRAN_MAX_DCI_MSG_NR]; + uint32_t dci_msg_count; + + srsran_dci_msg_nr_t pending_ul_dci_msg[SRSRAN_MAX_DCI_MSG_NR]; + uint32_t pending_ul_dci_count; +} srsran_ue_dl_nr_t; + +SRSRAN_API int +srsran_ue_dl_nr_init(srsran_ue_dl_nr_t* q, cf_t* input[SRSRAN_MAX_PORTS], const srsran_ue_dl_nr_args_t* args); + +SRSRAN_API int srsran_ue_dl_nr_set_carrier(srsran_ue_dl_nr_t* q, const srsran_carrier_nr_t* carrier); + +SRSRAN_API int srsran_ue_dl_nr_set_pdcch_config(srsran_ue_dl_nr_t* q, const srsran_ue_dl_nr_pdcch_cfg_t* cfg); + +SRSRAN_API void srsran_ue_dl_nr_free(srsran_ue_dl_nr_t* q); + +SRSRAN_API void srsran_ue_dl_nr_estimate_fft(srsran_ue_dl_nr_t* q, const srsran_slot_cfg_t* slot_cfg); + +SRSRAN_API int srsran_ue_dl_nr_find_dl_dci(srsran_ue_dl_nr_t* q, + const srsran_slot_cfg_t* slot_cfg, + uint16_t rnti, + srsran_rnti_type_t rnti_type, + srsran_dci_dl_nr_t* dci_dl_list, + uint32_t nof_dci_msg); + +SRSRAN_API int srsran_ue_dl_nr_find_ul_dci(srsran_ue_dl_nr_t* q, + const srsran_slot_cfg_t* slot_cfg, + uint16_t rnti, + srsran_rnti_type_t rnti_type, + srsran_dci_ul_nr_t* dci_ul_list, + uint32_t nof_dci_msg); + +SRSRAN_API int srsran_ue_dl_nr_decode_pdsch(srsran_ue_dl_nr_t* q, + const srsran_slot_cfg_t* slot, + const srsran_sch_cfg_nr_t* cfg, + srsran_pdsch_res_nr_t* res); + +SRSRAN_API int srsran_ue_dl_nr_pdsch_info(const srsran_ue_dl_nr_t* q, + const srsran_sch_cfg_nr_t* cfg, + const srsran_pdsch_res_nr_t res[SRSRAN_MAX_CODEWORDS], + char* str, + uint32_t str_len); + +SRSRAN_API int srsran_ue_dl_nr_pdsch_ack_resource(const srsran_ue_dl_nr_harq_ack_cfg_t* cfg, + const srsran_dci_dl_nr_t* dci_dl, + srsran_pdsch_ack_resource_nr_t* pdsch_ack_resource); + +SRSRAN_API int srsran_ue_dl_nr_gen_ack(const srsran_ue_dl_nr_harq_ack_cfg_t* cfg, + const srsran_pdsch_ack_nr_t* ack_info, + srsran_uci_data_nr_t* uci_data); + +#endif // SRSRAN_UE_DL_NR_H diff --git a/lib/include/srsran/phy/ue/ue_mib.h b/lib/include/srsran/phy/ue/ue_mib.h new file mode 100644 index 000000000..83e1c4191 --- /dev/null +++ b/lib/include/srsran/phy/ue/ue_mib.h @@ -0,0 +1,111 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +/****************************************************************************** + * File: ue_mib.h + * + * Description: This object decodes the MIB from the PBCH of an LTE signal. + * + * The function srsran_ue_mib_decode() shall be called multiple + * times, each passing a number of samples multiple of 19200, + * sampled at 1.92 MHz (that is, 10 ms of samples). + * + * The function uses the sync_t object to find the PSS sequence and + * decode the PBCH to obtain the MIB. + * + * The function returns 0 until the MIB is decoded. + * + * See ue_cell_detect.c for an example. + * + * Reference: + *****************************************************************************/ + +#ifndef SRSRAN_UE_MIB_H +#define SRSRAN_UE_MIB_H + +#include + +#include "srsran/config.h" +#include "srsran/phy/ch_estimation/chest_dl.h" +#include "srsran/phy/dft/ofdm.h" +#include "srsran/phy/phch/pbch.h" +#include "srsran/phy/sync/cfo.h" +#include "srsran/phy/ue/ue_sync.h" + +#define SRSRAN_UE_MIB_NOF_PRB 6 + +#define SRSRAN_UE_MIB_FOUND 1 +#define SRSRAN_UE_MIB_NOTFOUND 0 + +typedef struct SRSRAN_API { + srsran_sync_t sfind; + + cf_t* sf_symbols; + + srsran_ofdm_t fft; + srsran_pbch_t pbch; + + srsran_chest_dl_t chest; + srsran_chest_dl_res_t chest_res; + + uint8_t bch_payload[SRSRAN_BCH_PAYLOAD_LEN]; + uint32_t nof_tx_ports; + uint32_t sfn_offset; + + uint32_t frame_cnt; +} srsran_ue_mib_t; + +SRSRAN_API int srsran_ue_mib_init(srsran_ue_mib_t* q, cf_t* in_buffer, uint32_t max_prb); + +SRSRAN_API void srsran_ue_mib_free(srsran_ue_mib_t* q); + +SRSRAN_API int srsran_ue_mib_set_cell(srsran_ue_mib_t* q, srsran_cell_t cell); + +SRSRAN_API void srsran_ue_mib_reset(srsran_ue_mib_t* q); + +SRSRAN_API int srsran_ue_mib_decode(srsran_ue_mib_t* q, + uint8_t bch_payload[SRSRAN_BCH_PAYLOAD_LEN], + uint32_t* nof_tx_ports, + int* sfn_offset); + +/* This interface uses ue_mib and ue_sync to first get synchronized subframes + * and then decode MIB + * + * This object calls the pbch object with nof_ports=0 for blind nof_ports determination +*/ +typedef struct { + srsran_ue_mib_t ue_mib; + srsran_ue_sync_t ue_sync; + cf_t* sf_buffer[SRSRAN_MAX_CHANNELS]; + uint32_t nof_rx_channels; +} srsran_ue_mib_sync_t; + +SRSRAN_API int +srsran_ue_mib_sync_init_multi(srsran_ue_mib_sync_t* q, + int(recv_callback)(void*, cf_t* [SRSRAN_MAX_CHANNELS], uint32_t, srsran_timestamp_t*), + uint32_t nof_rx_channels, + void* stream_handler); + +SRSRAN_API void srsran_ue_mib_sync_free(srsran_ue_mib_sync_t* q); + +SRSRAN_API int srsran_ue_mib_sync_set_cell(srsran_ue_mib_sync_t* q, srsran_cell_t cell); + +SRSRAN_API void srsran_ue_mib_sync_reset(srsran_ue_mib_sync_t* q); + +SRSRAN_API int srsran_ue_mib_sync_decode(srsran_ue_mib_sync_t* q, + uint32_t max_frames_timeout, + uint8_t bch_payload[SRSRAN_BCH_PAYLOAD_LEN], + uint32_t* nof_tx_ports, + int* sfn_offset); + +#endif // SRSRAN_UE_MIB_H + diff --git a/lib/include/srslte/phy/ue/ue_mib_nbiot.h b/lib/include/srsran/phy/ue/ue_mib_nbiot.h similarity index 52% rename from lib/include/srslte/phy/ue/ue_mib_nbiot.h rename to lib/include/srsran/phy/ue/ue_mib_nbiot.h index c68900f46..5e07bb76d 100644 --- a/lib/include/srslte/phy/ue/ue_mib_nbiot.h +++ b/lib/include/srsran/phy/ue/ue_mib_nbiot.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,24 +10,24 @@ * */ -#ifndef SRSLTE_UE_MIB_NBIOT_H -#define SRSLTE_UE_MIB_NBIOT_H +#ifndef SRSRAN_UE_MIB_NBIOT_H +#define SRSRAN_UE_MIB_NBIOT_H -#include "srslte/config.h" -#include "srslte/phy/ch_estimation/chest_dl_nbiot.h" -#include "srslte/phy/dft/ofdm.h" -#include "srslte/phy/phch/npbch.h" -#include "srslte/phy/sync/cfo.h" -#include "srslte/phy/ue/ue_sync_nbiot.h" +#include "srsran/config.h" +#include "srsran/phy/ch_estimation/chest_dl_nbiot.h" +#include "srsran/phy/dft/ofdm.h" +#include "srsran/phy/phch/npbch.h" +#include "srsran/phy/sync/cfo.h" +#include "srsran/phy/ue/ue_sync_nbiot.h" -#define SRSLTE_UE_MIB_NBIOT_NOF_PRB 6 -#define SRSLTE_UE_MIB_NBIOT_FOUND 1 -#define SRSLTE_UE_MIB_NBIOT_NOTFOUND 0 +#define SRSRAN_UE_MIB_NBIOT_NOF_PRB 6 +#define SRSRAN_UE_MIB_NBIOT_FOUND 1 +#define SRSRAN_UE_MIB_NBIOT_NOTFOUND 0 /** * \brief This object decodes the MIB-NB from the NPBCH of an NB-IoT LTE signal. * - * The function srslte_ue_mib_nbiot_decode() shall be called multiple + * The function srsran_ue_mib_nbiot_decode() shall be called multiple * times, each passing a number of samples multiple of 19200, * sampled at 1.92 MHz (that is, 10 ms of samples). * @@ -37,33 +37,33 @@ * The function returns 0 until the MIB is decoded. */ -typedef struct SRSLTE_API { - srslte_sync_nbiot_t sfind; +typedef struct SRSRAN_API { + srsran_sync_nbiot_t sfind; cf_t* sf_symbols; - cf_t* ce[SRSLTE_MAX_PORTS]; + cf_t* ce[SRSRAN_MAX_PORTS]; - srslte_ofdm_t fft; - srslte_chest_dl_nbiot_t chest; - srslte_npbch_t npbch; + srsran_ofdm_t fft; + srsran_chest_dl_nbiot_t chest; + srsran_npbch_t npbch; - uint8_t last_bch_payload[SRSLTE_MIB_NB_LEN]; + uint8_t last_bch_payload[SRSRAN_MIB_NB_LEN]; uint32_t nof_tx_ports; uint32_t nof_rx_antennas; uint32_t sfn_offset; uint32_t frame_cnt; -} srslte_ue_mib_nbiot_t; +} srsran_ue_mib_nbiot_t; -SRSLTE_API int srslte_ue_mib_nbiot_init(srslte_ue_mib_nbiot_t* q, cf_t** in_buffer, uint32_t max_prb); +SRSRAN_API int srsran_ue_mib_nbiot_init(srsran_ue_mib_nbiot_t* q, cf_t** in_buffer, uint32_t max_prb); -SRSLTE_API int srslte_ue_mib_nbiot_set_cell(srslte_ue_mib_nbiot_t* q, srslte_nbiot_cell_t cell); +SRSRAN_API int srsran_ue_mib_nbiot_set_cell(srsran_ue_mib_nbiot_t* q, srsran_nbiot_cell_t cell); -SRSLTE_API void srslte_ue_mib_nbiot_free(srslte_ue_mib_nbiot_t* q); +SRSRAN_API void srsran_ue_mib_nbiot_free(srsran_ue_mib_nbiot_t* q); -SRSLTE_API void srslte_ue_mib_nbiot_reset(srslte_ue_mib_nbiot_t* q); +SRSRAN_API void srsran_ue_mib_nbiot_reset(srsran_ue_mib_nbiot_t* q); -SRSLTE_API int srslte_ue_mib_nbiot_decode(srslte_ue_mib_nbiot_t* q, +SRSRAN_API int srsran_ue_mib_nbiot_decode(srsran_ue_mib_nbiot_t* q, cf_t* input, uint8_t* bch_payload, uint32_t* nof_tx_ports, @@ -75,28 +75,28 @@ SRSLTE_API int srslte_ue_mib_nbiot_decode(srslte_ue_mib_nbiot_t* q, * This object calls the pbch object with nof_ports=0 for blind nof_ports determination */ typedef struct { - srslte_ue_mib_nbiot_t ue_mib; - srslte_nbiot_ue_sync_t ue_sync; - cf_t* sf_buffer[SRSLTE_MAX_PORTS]; + srsran_ue_mib_nbiot_t ue_mib; + srsran_nbiot_ue_sync_t ue_sync; + cf_t* sf_buffer[SRSRAN_MAX_PORTS]; uint32_t nof_rx_antennas; -} srslte_ue_mib_sync_nbiot_t; +} srsran_ue_mib_sync_nbiot_t; -SRSLTE_API int -srslte_ue_mib_sync_nbiot_init_multi(srslte_ue_mib_sync_nbiot_t* q, - int(recv_callback)(void*, cf_t* [SRSLTE_MAX_PORTS], uint32_t, srslte_timestamp_t*), +SRSRAN_API int +srsran_ue_mib_sync_nbiot_init_multi(srsran_ue_mib_sync_nbiot_t* q, + int(recv_callback)(void*, cf_t* [SRSRAN_MAX_PORTS], uint32_t, srsran_timestamp_t*), uint32_t nof_rx_antennas, void* stream_handler); -SRSLTE_API void srslte_ue_mib_sync_nbiot_free(srslte_ue_mib_sync_nbiot_t* q); +SRSRAN_API void srsran_ue_mib_sync_nbiot_free(srsran_ue_mib_sync_nbiot_t* q); -SRSLTE_API int srslte_ue_mib_sync_nbiot_set_cell(srslte_ue_mib_sync_nbiot_t* q, srslte_nbiot_cell_t cell); +SRSRAN_API int srsran_ue_mib_sync_nbiot_set_cell(srsran_ue_mib_sync_nbiot_t* q, srsran_nbiot_cell_t cell); -SRSLTE_API void srslte_ue_mib_sync_nbiot_reset(srslte_ue_mib_sync_nbiot_t* q); +SRSRAN_API void srsran_ue_mib_sync_nbiot_reset(srsran_ue_mib_sync_nbiot_t* q); -SRSLTE_API int srslte_ue_mib_sync_nbiot_decode(srslte_ue_mib_sync_nbiot_t* q, +SRSRAN_API int srsran_ue_mib_sync_nbiot_decode(srsran_ue_mib_sync_nbiot_t* q, uint32_t max_frames_timeout, uint8_t* bch_payload, uint32_t* nof_tx_ports, int* sfn_offset); -#endif // SRSLTE_UE_MIB_NBIOT_H +#endif // SRSRAN_UE_MIB_NBIOT_H diff --git a/lib/include/srslte/phy/ue/ue_mib_sl.h b/lib/include/srsran/phy/ue/ue_mib_sl.h similarity index 68% rename from lib/include/srslte/phy/ue/ue_mib_sl.h rename to lib/include/srsran/phy/ue/ue_mib_sl.h index 5d98fafb0..7f63368e9 100644 --- a/lib/include/srslte/phy/ue/ue_mib_sl.h +++ b/lib/include/srsran/phy/ue/ue_mib_sl.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,16 +10,16 @@ * */ -#ifndef SRSLTE_UE_SL_MIB_H -#define SRSLTE_UE_SL_MIB_H +#ifndef SRSRAN_UE_SL_MIB_H +#define SRSRAN_UE_SL_MIB_H #include #include -#define SRSLTE_MIB_SL_MAX_LEN 40 +#define SRSRAN_MIB_SL_MAX_LEN 40 // 3GPP TS 36.331 Sec. 6.5.2 -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { // sl-Bandwidth-r12 enum {6, 15, 25, 50, 75, 100} (3 bits) uint32_t sl_bandwidth_r12; @@ -38,18 +38,18 @@ typedef struct SRSLTE_API { // reserved-r12 (19 bits) -} srslte_ue_mib_sl_t; +} srsran_ue_mib_sl_t; -int srslte_ue_mib_sl_set(srslte_ue_mib_sl_t* q, +int srsran_ue_mib_sl_set(srsran_ue_mib_sl_t* q, uint32_t nof_prb, uint32_t tdd_config, uint32_t direct_frame_number, uint32_t direct_subframe_number, bool in_coverage); -void srslte_ue_mib_sl_pack(srslte_ue_mib_sl_t* q, uint8_t* msg); -void srlste_ue_mib_sl_unpack(srslte_ue_mib_sl_t* q, uint8_t* msg); +void srsran_ue_mib_sl_pack(srsran_ue_mib_sl_t* q, uint8_t* msg); +void srlste_ue_mib_sl_unpack(srsran_ue_mib_sl_t* q, uint8_t* msg); -void srslte_ue_mib_sl_free(srslte_ue_mib_sl_t* q); +void srsran_ue_mib_sl_free(srsran_ue_mib_sl_t* q); -#endif // SRSLTE_UE_SL_MIB_H \ No newline at end of file +#endif // SRSRAN_UE_SL_MIB_H \ No newline at end of file diff --git a/lib/include/srslte/phy/ue/ue_phy.h b/lib/include/srsran/phy/ue/ue_phy.h similarity index 86% rename from lib/include/srslte/phy/ue/ue_phy.h rename to lib/include/srsran/phy/ue/ue_phy.h index 09793aeab..161dbd5af 100644 --- a/lib/include/srslte/phy/ue/ue_phy.h +++ b/lib/include/srsran/phy/ue/ue_phy.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -18,17 +18,17 @@ * Reference: *****************************************************************************/ -#include "srslte/phy/utils/queue.h" -#include "srslte/srslte.h" +#include "srsran/phy/utils/queue.h" +#include "srsran/srsran.h" -#ifndef SRSLTE_UE_PHY_H -#define SRSLTE_UE_PHY_H +#ifndef SRSRAN_UE_PHY_H +#define SRSRAN_UE_PHY_H #define SYNC_MODE_CV 0 #define SYNC_MODE_CALLBACK 1 #define SYNC_MODE SYNC_MODE_CV -namespace srslte { +namespace srsran { typedef _Complex float cf_t; @@ -68,8 +68,8 @@ public: private: union { - srslte_ra_ul_grant_t ul_grant; - srslte_ra_dl_grant_t dl_grant; + srsran_ra_ul_grant_t ul_grant; + srsran_ra_dl_grant_t dl_grant; }; direction_t dir; }; @@ -80,12 +80,12 @@ public: class ul_buffer : public queue::element { public: - ul_buffer(srslte_cell_t cell); - void generate_pusch(sched_grant pusch_grant, uint8_t* payload, srslte_uci_data_t uci_data); - void generate_pucch(srslte_uci_data_t uci_data); + ul_buffer(srsran_cell_t cell); + void generate_pusch(sched_grant pusch_grant, uint8_t* payload, srsran_uci_data_t uci_data); + void generate_pucch(srsran_uci_data_t uci_data); private: - srslte_ue_ul_t ue_ul; + srsran_ue_ul_t ue_ul; bool signal_generated = false; cf_t* signal_buffer = NULL; uint32_t tti = 0; @@ -97,14 +97,14 @@ public: class dl_buffer : public queue::element { public: - dl_buffer(srslte_cell_t cell); + dl_buffer(srsran_cell_t cell); sched_grant get_ul_grant(pdcch_ul_search_t mode, uint32_t rnti); sched_grant get_dl_grant(pdcch_dl_search_t mode, uint32_t rnti); bool decode_phich(sched_grant pusch_grant); bool decode_pdsch(sched_grant pdsch_grant, uint8_t* payload); // returns true or false for CRC OK/KO private: - srslte_ue_dl_t ue_dl; - srslte_phich_t phich; + srsran_ue_dl_t ue_dl; + srsran_phich_t phich; cf_t* signal_buffer = NULL; bool sf_symbols_and_ce_done = false; bool pdcch_llr_extracted = false; @@ -141,7 +141,7 @@ private: bool prach_initiated = false; bool prach_ready_to_send = false; - srslte_prach_t prach; + srsran_prach_t prach; queue ul_buffer_queue; queue dl_buffer_queue; @@ -150,5 +150,5 @@ private: void* radio_handler; }; -} // namespace srslte -#endif // SRSLTE_UE_PHY_H +} // namespace srsran +#endif // SRSRAN_UE_PHY_H diff --git a/lib/include/srsran/phy/ue/ue_sync.h b/lib/include/srsran/phy/ue/ue_sync.h new file mode 100644 index 000000000..c6a33e192 --- /dev/null +++ b/lib/include/srsran/phy/ue/ue_sync.h @@ -0,0 +1,264 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +/****************************************************************************** + * File: ue_sync.h + * + * Description: This object automatically manages the cell synchronization + * procedure. + * + * The main function is srsran_ue_sync_get_buffer(), which returns + * a pointer to the aligned subframe of samples (before FFT). This + * function should be called regularly, returning every 1 ms. + * It reads from the USRP, aligns the samples to the subframe and + * performs time/freq synch. + * + * It is also possible to read the signal from a file using the + * init function srsran_ue_sync_init_file(). The sampling frequency + * is derived from the number of PRB. + * + * The function returns 1 when the signal is correctly acquired and + * the returned buffer is aligned with the subframe. + * + * Reference: + *****************************************************************************/ + +#ifndef SRSRAN_UE_SYNC_H +#define SRSRAN_UE_SYNC_H + +#include + +#include "srsran/config.h" +#include "srsran/phy/agc/agc.h" +#include "srsran/phy/ch_estimation/chest_dl.h" +#include "srsran/phy/common/timestamp.h" +#include "srsran/phy/dft/ofdm.h" +#include "srsran/phy/io/filesource.h" +#include "srsran/phy/phch/pbch.h" +#include "srsran/phy/sync/cfo.h" +#include "srsran/phy/sync/sync.h" + +#define DEFAULT_SAMPLE_OFFSET_CORRECT_PERIOD 10 +#define DEFAULT_SFO_EMA_COEFF 0.1 + +#define DEFAULT_CFO_BW_PSS 0.05 +#define DEFAULT_CFO_PSS_MIN 400 // typical bias of PSS estimation. +#define DEFAULT_CFO_BW_REF 0.08 +#define DEFAULT_CFO_REF_MIN 0 // typical bias of REF estimation +#define DEFAULT_CFO_REF_MAX DEFAULT_CFO_PSS_MIN // Maximum detection offset of REF based estimation + +#define DEFAULT_PSS_STABLE_TIMEOUT 20 // Time after which the PSS is considered to be stable and we accept REF-CFO + +#define DEFAULT_CFO_EMA_TRACK 0.05 + +typedef enum SRSRAN_API { SYNC_MODE_PSS, SYNC_MODE_GNSS } srsran_ue_sync_mode_t; +typedef enum SRSRAN_API { SF_FIND, SF_TRACK } srsran_ue_sync_state_t; + +//#define MEASURE_EXEC_TIME + +typedef int(ue_sync_recv_callback_t)(void*, cf_t* [SRSRAN_MAX_CHANNELS], uint32_t, srsran_timestamp_t*); + +typedef struct SRSRAN_API { + srsran_ue_sync_mode_t mode; + srsran_sync_t sfind; + srsran_sync_t strack; + + uint32_t max_prb; + + srsran_agc_t agc; + bool do_agc; + uint32_t agc_period; + int decimate; + void *stream; + void *stream_single; + int (*recv_callback)(void*, cf_t* [SRSRAN_MAX_CHANNELS], uint32_t, srsran_timestamp_t*); + int (*recv_callback_single)(void*, void*, uint32_t, srsran_timestamp_t*); + srsran_timestamp_t last_timestamp; + + uint32_t nof_rx_antennas; + + srsran_filesource_t file_source; + bool file_mode; + float file_cfo; + bool file_wrap_enable; + srsran_cfo_t file_cfo_correct; + + srsran_ue_sync_state_t state; + + uint32_t frame_len; + uint32_t fft_size; + uint32_t nof_recv_sf; // Number of subframes received each call to srsran_ue_sync_get_buffer + uint32_t nof_avg_find_frames; + uint32_t frame_find_cnt; + uint32_t sf_len; + + /* These count half frames (5ms) */ + uint64_t frame_ok_cnt; + uint32_t frame_no_cnt; + uint32_t frame_total_cnt; + + /* this is the system frame number (SFN) */ + uint32_t frame_number; + uint32_t sfn_offset; ///< An offset value provided by higher layers + + srsran_cell_t cell; + uint32_t sf_idx; + + bool cfo_is_copied; + bool cfo_correct_enable_track; + bool cfo_correct_enable_find; + float cfo_current_value; + float cfo_loop_bw_pss; + float cfo_loop_bw_ref; + float cfo_pss_min; + float cfo_ref_min; + float cfo_ref_max; + + uint32_t pss_stable_cnt; + uint32_t pss_stable_timeout; + bool pss_is_stable; + + uint32_t peak_idx; + int next_rf_sample_offset; + int last_sample_offset; + float mean_sample_offset; + uint32_t sample_offset_correct_period; + float sfo_ema; + + + #ifdef MEASURE_EXEC_TIME + float mean_exec_time; + #endif +} srsran_ue_sync_t; + +SRSRAN_API int srsran_ue_sync_init(srsran_ue_sync_t* q, + uint32_t max_prb, + bool search_cell, + int(recv_callback)(void*, void*, uint32_t, srsran_timestamp_t*), + void* stream_handler); + +SRSRAN_API int +srsran_ue_sync_init_multi(srsran_ue_sync_t* q, + uint32_t max_prb, + bool search_cell, + int(recv_callback)(void*, cf_t* [SRSRAN_MAX_CHANNELS], uint32_t, srsran_timestamp_t*), + uint32_t nof_rx_antennas, + void* stream_handler); + +SRSRAN_API int +srsran_ue_sync_init_multi_decim(srsran_ue_sync_t* q, + uint32_t max_prb, + bool search_cell, + int(recv_callback)(void*, cf_t* [SRSRAN_MAX_CHANNELS], uint32_t, srsran_timestamp_t*), + uint32_t nof_rx_antennas, + void* stream_handler, + int decimate); + +SRSRAN_API int srsran_ue_sync_init_multi_decim_mode( + srsran_ue_sync_t* q, + uint32_t max_prb, + bool search_cell, + int(recv_callback)(void*, cf_t* [SRSRAN_MAX_CHANNELS], uint32_t, srsran_timestamp_t*), + uint32_t nof_rx_antennas, + void* stream_handler, + int decimate, + srsran_ue_sync_mode_t mode); + +SRSRAN_API int +srsran_ue_sync_init_file(srsran_ue_sync_t* q, uint32_t nof_prb, char* file_name, int offset_time, float offset_freq); + +SRSRAN_API int srsran_ue_sync_init_file_multi(srsran_ue_sync_t* q, + uint32_t nof_prb, + char* file_name, + int offset_time, + float offset_freq, + uint32_t nof_rx_ant); + +SRSRAN_API void srsran_ue_sync_free(srsran_ue_sync_t* q); + +SRSRAN_API void srsran_ue_sync_file_wrap(srsran_ue_sync_t* q, bool enable); + +SRSRAN_API int srsran_ue_sync_set_cell(srsran_ue_sync_t* q, srsran_cell_t cell); + +SRSRAN_API void srsran_ue_sync_cfo_reset(srsran_ue_sync_t* q, float init_cfo_hz); + +SRSRAN_API void srsran_ue_sync_reset(srsran_ue_sync_t* q); + +SRSRAN_API void srsran_ue_sync_set_frame_type(srsran_ue_sync_t* q, srsran_frame_type_t frame_type); + +SRSRAN_API void srsran_ue_sync_set_nof_find_frames(srsran_ue_sync_t* q, uint32_t nof_frames); + +SRSRAN_API srsran_frame_type_t srsran_ue_sync_get_frame_type(srsran_ue_sync_t* q); + +SRSRAN_API int srsran_ue_sync_start_agc(srsran_ue_sync_t* q, + SRSRAN_AGC_CALLBACK(set_gain_callback), + float min_gain, + float max_gain, + float init_gain_value); + +SRSRAN_API uint32_t srsran_ue_sync_sf_len(srsran_ue_sync_t* q); + +SRSRAN_API void srsran_ue_sync_set_agc_period(srsran_ue_sync_t* q, uint32_t period); + +SRSRAN_API int +srsran_ue_sync_zerocopy(srsran_ue_sync_t* q, cf_t* input_buffer[SRSRAN_MAX_CHANNELS], const uint32_t max_num_samples); + +SRSRAN_API void srsran_ue_sync_set_cfo_tol(srsran_ue_sync_t* q, float tol); + +SRSRAN_API void srsran_ue_sync_copy_cfo(srsran_ue_sync_t* q, srsran_ue_sync_t* src_obj); + +SRSRAN_API void srsran_ue_sync_set_cfo_loop_bw(srsran_ue_sync_t* q, + float bw_pss, + float bw_ref, + float pss_tol, + float ref_tol, + float ref_max, + uint32_t pss_stable_timeout); + +SRSRAN_API void srsran_ue_sync_set_cfo_ema(srsran_ue_sync_t* q, float ema); + +SRSRAN_API void srsran_ue_sync_set_cfo_ref(srsran_ue_sync_t* q, float res_cfo); + +SRSRAN_API void srsran_ue_sync_set_cfo_i_enable(srsran_ue_sync_t* q, bool enable); + +SRSRAN_API void srsran_ue_sync_set_N_id_2(srsran_ue_sync_t* q, uint32_t N_id_2); + +SRSRAN_API uint32_t srsran_ue_sync_get_sfn(srsran_ue_sync_t* q); + +SRSRAN_API uint32_t srsran_ue_sync_get_sfidx(srsran_ue_sync_t* q); + +SRSRAN_API float srsran_ue_sync_get_cfo(srsran_ue_sync_t* q); + +SRSRAN_API float srsran_ue_sync_get_sfo(srsran_ue_sync_t* q); + +SRSRAN_API int srsran_ue_sync_get_last_sample_offset(srsran_ue_sync_t* q); + +SRSRAN_API void srsran_ue_sync_set_sfo_correct_period(srsran_ue_sync_t* q, uint32_t nof_subframes); + +SRSRAN_API void srsran_ue_sync_set_sfo_ema(srsran_ue_sync_t* q, float ema_coefficient); + +SRSRAN_API void srsran_ue_sync_get_last_timestamp(srsran_ue_sync_t* q, srsran_timestamp_t* timestamp); + +SRSRAN_API int srsran_ue_sync_run_find_pss_mode(srsran_ue_sync_t* q, cf_t* input_buffer[SRSRAN_MAX_CHANNELS]); + +SRSRAN_API int srsran_ue_sync_run_track_pss_mode(srsran_ue_sync_t* q, cf_t* input_buffer[SRSRAN_MAX_CHANNELS]); + +SRSRAN_API int srsran_ue_sync_run_find_gnss_mode(srsran_ue_sync_t* q, + cf_t* input_buffer[SRSRAN_MAX_CHANNELS], + const uint32_t max_num_samples); + +SRSRAN_API int srsran_ue_sync_run_track_gnss_mode(srsran_ue_sync_t* q, cf_t* input_buffer[SRSRAN_MAX_CHANNELS]); + +SRSRAN_API int srsran_ue_sync_set_tti_from_timestamp(srsran_ue_sync_t* q, srsran_timestamp_t* rx_timestamp); + +#endif // SRSRAN_UE_SYNC_H + diff --git a/lib/include/srsran/phy/ue/ue_sync_nbiot.h b/lib/include/srsran/phy/ue/ue_sync_nbiot.h new file mode 100644 index 000000000..055e097f6 --- /dev/null +++ b/lib/include/srsran/phy/ue/ue_sync_nbiot.h @@ -0,0 +1,156 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +#ifndef SRSRAN_UE_SYNC_NBIOT_H +#define SRSRAN_UE_SYNC_NBIOT_H + +#include + +#include "srsran/config.h" +#include "srsran/phy/agc/agc.h" +#include "srsran/phy/ch_estimation/chest_dl_nbiot.h" +#include "srsran/phy/common/timestamp.h" +#include "srsran/phy/dft/ofdm.h" +#include "srsran/phy/io/filesource.h" +#include "srsran/phy/phch/npbch.h" +#include "srsran/phy/sync/cfo.h" +#include "srsran/phy/sync/sync_nbiot.h" + +typedef srsran_ue_sync_state_t srsran_nbiot_ue_sync_state_t; + +//#define MEASURE_EXEC_TIME + +typedef struct SRSRAN_API { + srsran_sync_nbiot_t sfind; + srsran_sync_nbiot_t strack; + + srsran_agc_t agc; + bool do_agc; + uint32_t agc_period; + + void* stream; + void* stream_single; + int (*recv_callback)(void*, cf_t* [SRSRAN_MAX_PORTS], uint32_t, srsran_timestamp_t*); + int (*recv_callback_single)(void*, void*, uint32_t, srsran_timestamp_t*); + srsran_timestamp_t last_timestamp; + + srsran_filesource_t file_source; + bool file_mode; + float file_cfo; + srsran_cfo_t file_cfo_correct; + + srsran_nbiot_ue_sync_state_t state; + + uint32_t nof_rx_antennas; + uint32_t frame_len; + uint32_t fft_size; + uint32_t nof_recv_sf; // Number of subframes received each call to srsran_ue_sync_get_buffer + uint32_t nof_avg_find_frames; + uint32_t frame_find_cnt; + uint32_t sf_len; + + /* These count half frames (5ms) */ + uint64_t frame_ok_cnt; + uint32_t frame_no_cnt; + uint32_t frame_total_cnt; + + /* this is the system frame number (SFN) */ + uint32_t frame_number; + + srsran_nbiot_cell_t cell; + uint32_t sf_idx; + bool correct_cfo; + + uint32_t peak_idx; + int next_rf_sample_offset; + int last_sample_offset; + float mean_sample_offset; + float mean_sfo; + uint32_t sample_offset_correct_period; + float sfo_ema; + uint32_t max_prb; + +#ifdef MEASURE_EXEC_TIME + float mean_exec_time; +#endif +} srsran_nbiot_ue_sync_t; + +SRSRAN_API int srsran_ue_sync_nbiot_init(srsran_nbiot_ue_sync_t* q, + srsran_nbiot_cell_t cell, + int(recv_callback)(void*, void*, uint32_t, srsran_timestamp_t*), + void* stream_handler); + +SRSRAN_API int +srsran_ue_sync_nbiot_init_multi(srsran_nbiot_ue_sync_t* q, + uint32_t max_prb, + int(recv_callback)(void*, cf_t* [SRSRAN_MAX_PORTS], uint32_t, srsran_timestamp_t*), + uint32_t nof_rx_antennas, + void* stream_handler); + +SRSRAN_API int srsran_ue_sync_nbiot_init_file(srsran_nbiot_ue_sync_t* q, + srsran_nbiot_cell_t cell, + char* file_name, + int offset_time, + float offset_freq); + +SRSRAN_API int srsran_ue_sync_nbiot_init_file_multi(srsran_nbiot_ue_sync_t* q, + srsran_nbiot_cell_t cell, + char* file_name, + int offset_time, + float offset_freq, + uint32_t nof_rx_ant); + +SRSRAN_API void srsran_ue_sync_nbiot_free(srsran_nbiot_ue_sync_t* q); + +SRSRAN_API int srsran_ue_sync_nbiot_set_cell(srsran_nbiot_ue_sync_t* q, srsran_nbiot_cell_t cell); + +SRSRAN_API int srsran_ue_sync_nbiot_start_agc(srsran_nbiot_ue_sync_t* q, + SRSRAN_AGC_CALLBACK(set_gain_callback), + float init_gain_value); + +SRSRAN_API uint32_t srsran_ue_sync_nbiot_sf_len(srsran_nbiot_ue_sync_t* q); + +SRSRAN_API int srsran_nbiot_ue_sync_get_buffer(srsran_nbiot_ue_sync_t* q, cf_t** sf_symbols); + +SRSRAN_API void srsran_ue_sync_nbiot_set_agc_period(srsran_nbiot_ue_sync_t* q, uint32_t period); + +/* CAUTION: input_buffer MUST have space for 2 subframes */ +SRSRAN_API int srsran_ue_sync_nbiot_zerocopy(srsran_nbiot_ue_sync_t* q, cf_t* input_buffer); + +SRSRAN_API int srsran_ue_sync_nbiot_zerocopy_multi(srsran_nbiot_ue_sync_t* q, cf_t** input_buffer); + +SRSRAN_API void srsran_ue_sync_nbiot_set_cfo(srsran_nbiot_ue_sync_t* q, float cfo); + +SRSRAN_API void srsran_ue_sync_nbiot_reset(srsran_nbiot_ue_sync_t* q); + +SRSRAN_API srsran_nbiot_ue_sync_state_t srsran_ue_sync_nbiot_get_state(srsran_nbiot_ue_sync_t* q); + +SRSRAN_API uint32_t srsran_ue_sync_nbiot_get_sfidx(srsran_nbiot_ue_sync_t* q); + +SRSRAN_API void srsran_ue_sync_nbiot_set_cfo_enable(srsran_nbiot_ue_sync_t* q, bool enable); + +SRSRAN_API float srsran_ue_sync_nbiot_get_cfo(srsran_nbiot_ue_sync_t* q); + +SRSRAN_API float srsran_ue_sync_nbiot_get_sfo(srsran_nbiot_ue_sync_t* q); + +SRSRAN_API void srsran_ue_sync_nbiot_set_cfo_ema(srsran_nbiot_ue_sync_t* q, float ema); + +SRSRAN_API void srsran_ue_sync_nbiot_set_cfo_tol(srsran_nbiot_ue_sync_t* q, float cfo_tol); + +SRSRAN_API int srsran_ue_sync_nbiot_get_last_sample_offset(srsran_nbiot_ue_sync_t* q); + +SRSRAN_API void srsran_ue_sync_nbiot_set_sample_offset_correct_period(srsran_nbiot_ue_sync_t* q, + uint32_t nof_subframes); + +SRSRAN_API void srsran_ue_sync_nbiot_get_last_timestamp(srsran_nbiot_ue_sync_t* q, srsran_timestamp_t* timestamp); + +#endif // SRSRAN_UE_SYNC_NBIOT_H \ No newline at end of file diff --git a/lib/include/srsran/phy/ue/ue_ul.h b/lib/include/srsran/phy/ue/ue_ul.h new file mode 100644 index 000000000..bc8567af1 --- /dev/null +++ b/lib/include/srsran/phy/ue/ue_ul.h @@ -0,0 +1,158 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +/****************************************************************************** + * File: ue_ul.h + * + * Description: UE uplink object. + * + * This module is a frontend to all the uplink data and control + * channel processing modules. + * + * Reference: + *****************************************************************************/ + +#ifndef SRSRAN_UE_UL_H +#define SRSRAN_UE_UL_H + +#include "srsran/phy/ch_estimation/chest_dl.h" +#include "srsran/phy/ch_estimation/refsignal_ul.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/dft/ofdm.h" +#include "srsran/phy/phch/dci.h" +#include "srsran/phy/phch/pusch.h" +#include "srsran/phy/phch/ra.h" +#include "srsran/phy/sync/cfo.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" + +#include "srsran/config.h" + +/* UE UL power control */ +typedef struct { + // Common configuration + float p0_nominal_pusch; + float alpha; + float p0_nominal_pucch; + float delta_f_pucch[5]; + float delta_preamble_msg3; + + // Dedicated configuration + float p0_ue_pusch; + bool delta_mcs_based; + bool acc_enabled; + float p0_ue_pucch; + float p_srs_offset; +} srsran_ue_ul_powerctrl_t; + +typedef struct SRSRAN_API { + // Uplink config (includes common and dedicated variables) + srsran_pucch_cfg_t pucch; + srsran_pusch_cfg_t pusch; + srsran_pusch_hopping_cfg_t hopping; + srsran_ue_ul_powerctrl_t power_ctrl; + srsran_refsignal_dmrs_pusch_cfg_t dmrs; + srsran_refsignal_srs_cfg_t srs; +} srsran_ul_cfg_t; + +typedef enum { + SRSRAN_UE_UL_NORMALIZE_MODE_AUTO = 0, + SRSRAN_UE_UL_NORMALIZE_MODE_FORCE_AMPLITUDE +} srsran_ue_ul_normalize_mode_t; + +typedef struct SRSRAN_API { + srsran_ul_cfg_t ul_cfg; + bool grant_available; + uint32_t cc_idx; + + srsran_ue_ul_normalize_mode_t normalize_mode; + float force_peak_amplitude; + bool cfo_en; + float cfo_tol; + float cfo_value; + +} srsran_ue_ul_cfg_t; + +typedef struct SRSRAN_API { + srsran_cell_t cell; + + bool signals_pregenerated; + + srsran_ofdm_t fft; + srsran_cfo_t cfo; + + srsran_refsignal_ul_t signals; + srsran_refsignal_ul_dmrs_pregen_t pregen_dmrs; + srsran_refsignal_srs_pregen_t pregen_srs; + + srsran_pusch_t pusch; + srsran_pucch_t pucch; + + srsran_ra_ul_pusch_hopping_t hopping; + + cf_t* out_buffer; + cf_t* refsignal; + cf_t* srs_signal; + cf_t* sf_symbols; + +} srsran_ue_ul_t; + +SRSRAN_API int srsran_ue_ul_init(srsran_ue_ul_t* q, cf_t* out_buffer, uint32_t max_prb); + +SRSRAN_API void srsran_ue_ul_free(srsran_ue_ul_t* q); + +SRSRAN_API int srsran_ue_ul_set_cell(srsran_ue_ul_t* q, srsran_cell_t cell); + +SRSRAN_API int srsran_ue_ul_pregen_signals(srsran_ue_ul_t* q, srsran_ue_ul_cfg_t* cfg); + +SRSRAN_API int srsran_ue_ul_dci_to_pusch_grant(srsran_ue_ul_t* q, + srsran_ul_sf_cfg_t* sf, + srsran_ue_ul_cfg_t* cfg, + srsran_dci_ul_t* dci, + srsran_pusch_grant_t* grant); + +SRSRAN_API void srsran_ue_ul_pusch_hopping(srsran_ue_ul_t* q, + srsran_ul_sf_cfg_t* sf, + srsran_ue_ul_cfg_t* cfg, + srsran_pusch_grant_t* grant); + +SRSRAN_API int +srsran_ue_ul_encode(srsran_ue_ul_t* q, srsran_ul_sf_cfg_t* sf, srsran_ue_ul_cfg_t* cfg, srsran_pusch_data_t* data); + +SRSRAN_API int srsran_ue_ul_sr_send_tti(const srsran_pucch_cfg_t* cfg, uint32_t current_tti); + +SRSRAN_API bool +srsran_ue_ul_gen_sr(srsran_ue_ul_cfg_t* cfg, srsran_ul_sf_cfg_t* sf, srsran_uci_data_t* uci_data, bool sr_request); + +/** + * Determines the PUCCH resource selection according to 3GPP 36.213 R10 Section 10.1. The PUCCH format and resource are + * saved in cfg->format and cfg->n_pucch. Also, HARQ-ACK + * + * @param cell Cell parameter, non-modifiable + * @param cfg PUCCH configuration and contains function results + * @param uci_cfg UCI configuration + * @param uci_data UCI data + * @param b Modified bits after applying HARQ-ACK feedback mode "encoding" + */ +SRSRAN_API void srsran_ue_ul_pucch_resource_selection(const srsran_cell_t* cell, + srsran_pucch_cfg_t* cfg, + const srsran_uci_cfg_t* uci_cfg, + const srsran_uci_value_t* uci_value, + uint8_t b[SRSRAN_UCI_MAX_ACK_BITS]); + +SRSRAN_API bool srsran_ue_ul_info(srsran_ue_ul_cfg_t* cfg, + srsran_ul_sf_cfg_t* sf, + srsran_uci_value_t* uci_data, + char* str, + uint32_t str_len); + +#endif // SRSRAN_UE_UL_H diff --git a/lib/include/srsran/phy/ue/ue_ul_nr.h b/lib/include/srsran/phy/ue/ue_ul_nr.h new file mode 100644 index 000000000..904bdb749 --- /dev/null +++ b/lib/include/srsran/phy/ue/ue_ul_nr.h @@ -0,0 +1,98 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +/****************************************************************************** + * @file ue_dl_nr.h + * + * Description: NR UE uplink physical layer procedures for data + * + * This module is a frontend to all the uplink data channel processing modules. + * + * Reference: + *****************************************************************************/ + +#ifndef SRSRAN_UE_UL_DATA_H +#define SRSRAN_UE_UL_DATA_H + +#include "srsran/phy/ch_estimation/dmrs_sch.h" +#include "srsran/phy/common/phy_common_nr.h" +#include "srsran/phy/dft/ofdm.h" +#include "srsran/phy/phch/phch_cfg_nr.h" +#include "srsran/phy/phch/pucch_cfg_nr.h" +#include "srsran/phy/phch/pucch_nr.h" +#include "srsran/phy/phch/pusch_nr.h" + +typedef struct SRSRAN_API { + srsran_pusch_nr_args_t pusch; + srsran_pucch_nr_args_t pucch; + uint32_t nof_max_prb; +} srsran_ue_ul_nr_args_t; + +typedef struct SRSRAN_API { + uint32_t max_prb; + + srsran_carrier_nr_t carrier; + + srsran_ofdm_t ifft; + + cf_t* sf_symbols[SRSRAN_MAX_PORTS]; + srsran_pusch_nr_t pusch; + srsran_pucch_nr_t pucch; + srsran_dmrs_sch_t dmrs; +} srsran_ue_ul_nr_t; + +SRSRAN_API int srsran_ue_ul_nr_init(srsran_ue_ul_nr_t* q, cf_t* output, const srsran_ue_ul_nr_args_t* args); + +SRSRAN_API int srsran_ue_ul_nr_set_carrier(srsran_ue_ul_nr_t* q, const srsran_carrier_nr_t* carrier); + +SRSRAN_API int srsran_ue_ul_nr_encode_pusch(srsran_ue_ul_nr_t* q, + const srsran_slot_cfg_t* slot_cfg, + const srsran_sch_cfg_nr_t* pusch_cfg, + const srsran_pusch_data_nr_t* data); + +SRSRAN_API int srsran_ue_ul_nr_encode_pucch(srsran_ue_ul_nr_t* q, + const srsran_slot_cfg_t* slot_cfg, + const srsran_pucch_nr_common_cfg_t* cfg, + const srsran_pucch_nr_resource_t* resource, + const srsran_uci_data_nr_t* uci_data); + +SRSRAN_API void srsran_ue_ul_nr_free(srsran_ue_ul_nr_t* q); + +SRSRAN_API int srsran_ue_ul_nr_pusch_info(const srsran_ue_ul_nr_t* q, + const srsran_sch_cfg_nr_t* cfg, + const srsran_uci_value_nr_t* uci_value, + char* str, + uint32_t str_len); + +SRSRAN_API int srsran_ue_ul_nr_pucch_info(const srsran_pucch_nr_resource_t* resource, + const srsran_uci_data_nr_t* uci_data, + char* str, + uint32_t str_len); + +/** + * @brief Decides whether the provided slot index within the radio frame is a SR transmission opportunity + * + * @remark Implemented according to TS 38.213 9.2.4 UE procedure for reporting SR + * + * @param sr_resources Provides the SR configuration from the upper layers + * @param slot_idx Slot index in the radio frame + * @param[out] sr_resource_id Optional SR resource index (or identifier) + * + * @return the number of SR opportunities if the provided slot index is a SR transmission opportunity, SRSRAN_ERROR code + * if provided parameters are invalid + */ +SRSRAN_API int +srsran_ue_ul_nr_sr_send_slot(const srsran_pucch_nr_sr_resource_t sr_resources[SRSRAN_PUCCH_MAX_NOF_SR_RESOURCES], + uint32_t slot_idx, + uint32_t sr_resource_id[SRSRAN_PUCCH_MAX_NOF_SR_RESOURCES]); + +#endif // SRSRAN_UE_UL_DATA_H diff --git a/lib/include/srslte/phy/utils/bit.h b/lib/include/srsran/phy/utils/bit.h similarity index 55% rename from lib/include/srslte/phy/utils/bit.h rename to lib/include/srsran/phy/utils/bit.h index 6373bf3f5..c9267a441 100644 --- a/lib/include/srslte/phy/utils/bit.h +++ b/lib/include/srsran/phy/utils/bit.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -18,13 +18,13 @@ * Reference: *****************************************************************************/ -#ifndef SRSLTE_BIT_H -#define SRSLTE_BIT_H +#ifndef SRSRAN_BIT_H +#define SRSRAN_BIT_H #include #include -#include "srslte/config.h" +#include "srsran/config.h" typedef struct { uint32_t nof_bits; @@ -32,50 +32,50 @@ typedef struct { uint16_t* byte_idx; uint8_t* bit_mask; uint8_t n_128; -} srslte_bit_interleaver_t; +} srsran_bit_interleaver_t; -SRSLTE_API void srslte_bit_interleaver_init(srslte_bit_interleaver_t* q, uint16_t* interleaver, uint32_t nof_bits); +SRSRAN_API void srsran_bit_interleaver_init(srsran_bit_interleaver_t* q, uint16_t* interleaver, uint32_t nof_bits); -SRSLTE_API void srslte_bit_interleaver_free(srslte_bit_interleaver_t* q); +SRSRAN_API void srsran_bit_interleaver_free(srsran_bit_interleaver_t* q); -SRSLTE_API void -srslte_bit_interleaver_run(srslte_bit_interleaver_t* q, uint8_t* input, uint8_t* output, uint16_t w_offset); +SRSRAN_API void +srsran_bit_interleaver_run(srsran_bit_interleaver_t* q, uint8_t* input, uint8_t* output, uint16_t w_offset); -SRSLTE_API void srslte_bit_interleave(uint8_t* input, uint8_t* output, uint16_t* interleaver, uint32_t nof_bits); +SRSRAN_API void srsran_bit_interleave(uint8_t* input, uint8_t* output, uint16_t* interleaver, uint32_t nof_bits); -SRSLTE_API void -srslte_bit_copy(uint8_t* dst, uint32_t dst_offset, uint8_t* src, uint32_t src_offset, uint32_t nof_bits); +SRSRAN_API void +srsran_bit_copy(uint8_t* dst, uint32_t dst_offset, uint8_t* src, uint32_t src_offset, uint32_t nof_bits); -SRSLTE_API void srslte_bit_interleave_i(uint8_t* input, uint8_t* output, uint32_t* interleaver, uint32_t nof_bits); +SRSRAN_API void srsran_bit_interleave_i(uint8_t* input, uint8_t* output, uint32_t* interleaver, uint32_t nof_bits); -SRSLTE_API void srslte_bit_interleave_i_w_offset(uint8_t* input, +SRSRAN_API void srsran_bit_interleave_i_w_offset(uint8_t* input, uint8_t* output, uint32_t* interleaver, uint32_t nof_bits, uint32_t w_offset); -SRSLTE_API void srslte_bit_interleave_w_offset(uint8_t* input, +SRSRAN_API void srsran_bit_interleave_w_offset(uint8_t* input, uint8_t* output, uint16_t* interleaver, uint32_t nof_bits, uint32_t w_offset); -SRSLTE_API void srslte_bit_unpack_vector(const uint8_t* packed, uint8_t* unpacked, int nof_bits); +SRSRAN_API void srsran_bit_unpack_vector(const uint8_t* packed, uint8_t* unpacked, int nof_bits); -SRSLTE_API void srslte_bit_pack_vector(uint8_t* unpacked, uint8_t* packed, int nof_bits); +SRSRAN_API void srsran_bit_pack_vector(uint8_t* unpacked, uint8_t* packed, int nof_bits); -SRSLTE_API uint32_t srslte_bit_pack(uint8_t** bits, int nof_bits); +SRSRAN_API uint32_t srsran_bit_pack(uint8_t** bits, int nof_bits); -SRSLTE_API uint64_t srslte_bit_pack_l(uint8_t** bits, int nof_bits); +SRSRAN_API uint64_t srsran_bit_pack_l(uint8_t** bits, int nof_bits); -SRSLTE_API void srslte_bit_unpack_l(uint64_t value, uint8_t** bits, int nof_bits); +SRSRAN_API void srsran_bit_unpack_l(uint64_t value, uint8_t** bits, int nof_bits); -SRSLTE_API void srslte_bit_unpack(uint32_t value, uint8_t** bits, int nof_bits); +SRSRAN_API void srsran_bit_unpack(uint32_t value, uint8_t** bits, int nof_bits); -SRSLTE_API void srslte_bit_fprint(FILE* stream, uint8_t* bits, int nof_bits); +SRSRAN_API void srsran_bit_fprint(FILE* stream, uint8_t* bits, int nof_bits); -SRSLTE_API uint32_t srslte_bit_diff(const uint8_t* x, const uint8_t* y, int nbits); +SRSRAN_API uint32_t srsran_bit_diff(const uint8_t* x, const uint8_t* y, int nbits); -SRSLTE_API uint32_t srslte_bit_count(uint32_t n); +SRSRAN_API uint32_t srsran_bit_count(uint32_t n); -#endif // SRSLTE_BIT_H +#endif // SRSRAN_BIT_H diff --git a/lib/include/srslte/phy/utils/cexptab.h b/lib/include/srsran/phy/utils/cexptab.h similarity index 54% rename from lib/include/srslte/phy/utils/cexptab.h rename to lib/include/srsran/phy/utils/cexptab.h index 37d0147cc..ec7b2f08d 100644 --- a/lib/include/srslte/phy/utils/cexptab.h +++ b/lib/include/srsran/phy/utils/cexptab.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -18,26 +18,26 @@ * Reference: *****************************************************************************/ -#ifndef SRSLTE_CEXPTAB_H -#define SRSLTE_CEXPTAB_H +#ifndef SRSRAN_CEXPTAB_H +#define SRSRAN_CEXPTAB_H -#include "srslte/config.h" +#include "srsran/config.h" #include #include -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { uint32_t size; cf_t* tab; -} srslte_cexptab_t; +} srsran_cexptab_t; -SRSLTE_API int srslte_cexptab_init(srslte_cexptab_t* nco, uint32_t size); +SRSRAN_API int srsran_cexptab_init(srsran_cexptab_t* nco, uint32_t size); -SRSLTE_API void srslte_cexptab_free(srslte_cexptab_t* nco); +SRSRAN_API void srsran_cexptab_free(srsran_cexptab_t* nco); -SRSLTE_API void srslte_cexptab_gen(srslte_cexptab_t* nco, cf_t* x, float freq, uint32_t len); +SRSRAN_API void srsran_cexptab_gen(srsran_cexptab_t* nco, cf_t* x, float freq, uint32_t len); -SRSLTE_API void srslte_cexptab_gen_direct(cf_t* x, float freq, uint32_t len); +SRSRAN_API void srsran_cexptab_gen_direct(cf_t* x, float freq, uint32_t len); -SRSLTE_API void srslte_cexptab_gen_sf(cf_t* x, float freq, uint32_t fft_size); +SRSRAN_API void srsran_cexptab_gen_sf(cf_t* x, float freq, uint32_t fft_size); -#endif // SRSLTE_CEXPTAB_H +#endif // SRSRAN_CEXPTAB_H diff --git a/lib/include/srslte/phy/utils/convolution.h b/lib/include/srsran/phy/utils/convolution.h similarity index 61% rename from lib/include/srslte/phy/utils/convolution.h rename to lib/include/srsran/phy/utils/convolution.h index 58c6cc65d..1057f8349 100644 --- a/lib/include/srslte/phy/utils/convolution.h +++ b/lib/include/srsran/phy/utils/convolution.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -18,14 +18,14 @@ * Reference: *****************************************************************************/ -#ifndef SRSLTE_CONVOLUTION_H -#define SRSLTE_CONVOLUTION_H +#ifndef SRSRAN_CONVOLUTION_H +#define SRSRAN_CONVOLUTION_H -#include "srslte/config.h" -#include "srslte/phy/dft/dft.h" +#include "srsran/config.h" +#include "srsran/phy/dft/dft.h" #include -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { cf_t* input_fft; cf_t* filter_fft; cf_t* output_fft; @@ -35,41 +35,41 @@ typedef struct SRSLTE_API { uint32_t output_len; uint32_t max_input_len; uint32_t max_filter_len; - srslte_dft_plan_t input_plan; - srslte_dft_plan_t filter_plan; - srslte_dft_plan_t output_plan; + srsran_dft_plan_t input_plan; + srsran_dft_plan_t filter_plan; + srsran_dft_plan_t output_plan; // cf_t *pss_signal_time_fft[3]; // One sequence for each N_id_2 // cf_t *pss_signal_time[3]; -} srslte_conv_fft_cc_t; +} srsran_conv_fft_cc_t; -SRSLTE_API int srslte_conv_fft_cc_init(srslte_conv_fft_cc_t* q, uint32_t input_len, uint32_t filter_len); +SRSRAN_API int srsran_conv_fft_cc_init(srsran_conv_fft_cc_t* q, uint32_t input_len, uint32_t filter_len); -SRSLTE_API int srslte_conv_fft_cc_replan(srslte_conv_fft_cc_t* q, uint32_t input_len, uint32_t filter_len); +SRSRAN_API int srsran_conv_fft_cc_replan(srsran_conv_fft_cc_t* q, uint32_t input_len, uint32_t filter_len); -SRSLTE_API void srslte_conv_fft_cc_free(srslte_conv_fft_cc_t* q); +SRSRAN_API void srsran_conv_fft_cc_free(srsran_conv_fft_cc_t* q); -SRSLTE_API uint32_t srslte_corr_fft_cc_run(srslte_conv_fft_cc_t* q, cf_t* input, cf_t* filter, cf_t* output); +SRSRAN_API uint32_t srsran_corr_fft_cc_run(srsran_conv_fft_cc_t* q, cf_t* input, cf_t* filter, cf_t* output); -SRSLTE_API uint32_t srslte_corr_fft_cc_run_opt(srslte_conv_fft_cc_t* q, cf_t* input, cf_t* filter, cf_t* output); +SRSRAN_API uint32_t srsran_corr_fft_cc_run_opt(srsran_conv_fft_cc_t* q, cf_t* input, cf_t* filter, cf_t* output); -SRSLTE_API uint32_t srslte_conv_fft_cc_run(srslte_conv_fft_cc_t* q, +SRSRAN_API uint32_t srsran_conv_fft_cc_run(srsran_conv_fft_cc_t* q, const cf_t* input, const cf_t* filter, cf_t* output); -SRSLTE_API uint32_t srslte_conv_fft_cc_run_opt(srslte_conv_fft_cc_t* q, +SRSRAN_API uint32_t srsran_conv_fft_cc_run_opt(srsran_conv_fft_cc_t* q, const cf_t* input, const cf_t* filter_freq, cf_t* output); -SRSLTE_API uint32_t -srslte_conv_cc(const cf_t* input, const cf_t* filter, cf_t* output, uint32_t input_len, uint32_t filter_len); +SRSRAN_API uint32_t +srsran_conv_cc(const cf_t* input, const cf_t* filter, cf_t* output, uint32_t input_len, uint32_t filter_len); -SRSLTE_API uint32_t -srslte_conv_same_cf(cf_t* input, float* filter, cf_t* output, uint32_t input_len, uint32_t filter_len); +SRSRAN_API uint32_t +srsran_conv_same_cf(cf_t* input, float* filter, cf_t* output, uint32_t input_len, uint32_t filter_len); -SRSLTE_API uint32_t -srslte_conv_same_cc(cf_t* input, cf_t* filter, cf_t* output, uint32_t input_len, uint32_t filter_len); +SRSRAN_API uint32_t +srsran_conv_same_cc(cf_t* input, cf_t* filter, cf_t* output, uint32_t input_len, uint32_t filter_len); -#endif // SRSLTE_CONVOLUTION_H +#endif // SRSRAN_CONVOLUTION_H diff --git a/lib/include/srslte/phy/utils/debug.h b/lib/include/srsran/phy/utils/debug.h similarity index 75% rename from lib/include/srslte/phy/utils/debug.h rename to lib/include/srsran/phy/utils/debug.h index 970bcc31b..c1b4d556f 100644 --- a/lib/include/srslte/phy/utils/debug.h +++ b/lib/include/srsran/phy/utils/debug.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -18,48 +18,48 @@ * Reference: *****************************************************************************/ -#ifndef SRSLTE_DEBUG_H -#define SRSLTE_DEBUG_H +#ifndef SRSRAN_DEBUG_H +#define SRSRAN_DEBUG_H #include "phy_logger.h" -#include "srslte/config.h" +#include "srsran/config.h" #include -#define SRSLTE_VERBOSE_DEBUG 2 -#define SRSLTE_VERBOSE_INFO 1 -#define SRSLTE_VERBOSE_NONE 0 +#define SRSRAN_VERBOSE_DEBUG 2 +#define SRSRAN_VERBOSE_INFO 1 +#define SRSRAN_VERBOSE_NONE 0 #include -SRSLTE_API void get_time_interval(struct timeval* tdata); +SRSRAN_API void get_time_interval(struct timeval* tdata); -#define SRSLTE_DEBUG_ENABLED 1 +#define SRSRAN_DEBUG_ENABLED 1 -SRSLTE_API extern int srslte_verbose; -SRSLTE_API extern int handler_registered; +SRSRAN_API extern int srsran_verbose; +SRSRAN_API extern int handler_registered; -#define SRSLTE_VERBOSE_ISINFO() (srslte_verbose >= SRSLTE_VERBOSE_INFO) -#define SRSLTE_VERBOSE_ISDEBUG() (srslte_verbose >= SRSLTE_VERBOSE_DEBUG) -#define SRSLTE_VERBOSE_ISNONE() (srslte_verbose == SRSLTE_VERBOSE_NONE) +#define SRSRAN_VERBOSE_ISINFO() (srsran_verbose >= SRSRAN_VERBOSE_INFO) +#define SRSRAN_VERBOSE_ISDEBUG() (srsran_verbose >= SRSRAN_VERBOSE_DEBUG) +#define SRSRAN_VERBOSE_ISNONE() (srsran_verbose == SRSRAN_VERBOSE_NONE) -#define PRINT_DEBUG srslte_verbose = SRSLTE_VERBOSE_DEBUG -#define PRINT_INFO srslte_verbose = SRSLTE_VERBOSE_INFO -#define PRINT_NONE srslte_verbose = SRSLTE_VERBOSE_NONE +#define PRINT_DEBUG srsran_verbose = SRSRAN_VERBOSE_DEBUG +#define PRINT_INFO srsran_verbose = SRSRAN_VERBOSE_INFO +#define PRINT_NONE srsran_verbose = SRSRAN_VERBOSE_NONE #define DEBUG(_fmt, ...) \ do { \ - if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_DEBUG && !handler_registered) { \ + if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_DEBUG && !handler_registered) { \ fprintf(stdout, "[DEBUG]: " _fmt "\n", ##__VA_ARGS__); \ } else { \ - srslte_phy_log_print(LOG_LEVEL_DEBUG_S, _fmt, ##__VA_ARGS__); \ + srsran_phy_log_print(LOG_LEVEL_DEBUG_S, _fmt, ##__VA_ARGS__); \ } \ } while (0) #define INFO(_fmt, ...) \ do { \ - if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_INFO && !handler_registered) { \ + if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_INFO && !handler_registered) { \ fprintf(stdout, "[INFO]: " _fmt "\n", ##__VA_ARGS__); \ } else { \ - srslte_phy_log_print(LOG_LEVEL_INFO_S, _fmt, ##__VA_ARGS__); \ + srsran_phy_log_print(LOG_LEVEL_INFO_S, _fmt, ##__VA_ARGS__); \ } \ } while (0) @@ -70,7 +70,7 @@ SRSLTE_API extern int handler_registered; if (!handler_registered) { \ fprintf(stderr, "\e[31m%s.%d: " _fmt "\e[0m\n", __FILE__, __LINE__, ##__VA_ARGS__); \ } else { \ - srslte_phy_log_print(LOG_LEVEL_ERROR_S, _fmt, ##__VA_ARGS__); \ + srsran_phy_log_print(LOG_LEVEL_ERROR_S, _fmt, ##__VA_ARGS__); \ } \ } while (0) #else @@ -78,8 +78,8 @@ SRSLTE_API extern int handler_registered; if (!handler_registered) { \ fprintf(stderr, "[ERROR in %s]:" _fmt "\n", __FUNCTION__, ##__VA_ARGS__); \ } else { \ - srslte_phy_log_print(LOG_LEVEL_ERROR, _fmt, ##__VA_ARGS__); \ + srsran_phy_log_print(LOG_LEVEL_ERROR, _fmt, ##__VA_ARGS__); \ } // #endif /* CMAKE_BUILD_TYPE==Debug */ -#endif // SRSLTE_DEBUG_H +#endif // SRSRAN_DEBUG_H diff --git a/lib/include/srslte/phy/utils/filter.h b/lib/include/srsran/phy/utils/filter.h similarity index 60% rename from lib/include/srslte/phy/utils/filter.h rename to lib/include/srsran/phy/utils/filter.h index 3ce29aa9e..f41e04c46 100644 --- a/lib/include/srslte/phy/utils/filter.h +++ b/lib/include/srsran/phy/utils/filter.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -18,15 +18,15 @@ * Reference: *****************************************************************************/ -#ifndef SRSLTE_FILTER_H -#define SRSLTE_FILTER_H +#ifndef SRSRAN_FILTER_H +#define SRSRAN_FILTER_H -#include "srslte/config.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/config.h" +#include "srsran/phy/utils/vector.h" #include #include #include -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { cf_t* filter_input; cf_t* downsampled_input; cf_t* filter_output; @@ -35,13 +35,13 @@ typedef struct SRSLTE_API { int num_taps; float* taps; -} srslte_filt_cc_t; +} srsran_filt_cc_t; -void srslte_filt_decim_cc_init(srslte_filt_cc_t* q, int factor, int order); +void srsran_filt_decim_cc_init(srsran_filt_cc_t* q, int factor, int order); -void srslte_filt_decim_cc_free(srslte_filt_cc_t* q); +void srsran_filt_decim_cc_free(srsran_filt_cc_t* q); -void srslte_filt_decim_cc_execute(srslte_filt_cc_t* q, cf_t* input, cf_t* downsampled_input, cf_t* output, int size); +void srsran_filt_decim_cc_execute(srsran_filt_cc_t* q, cf_t* input, cf_t* downsampled_input, cf_t* output, int size); -void srslte_downsample_cc(cf_t* input, cf_t* output, int M, int size); -#endif // SRSLTE_FILTER_H \ No newline at end of file +void srsran_downsample_cc(cf_t* input, cf_t* output, int M, int size); +#endif // SRSRAN_FILTER_H \ No newline at end of file diff --git a/lib/include/srslte/phy/utils/mat.h b/lib/include/srsran/phy/utils/mat.h similarity index 57% rename from lib/include/srslte/phy/utils/mat.h rename to lib/include/srsran/phy/utils/mat.h index 8fc847842..23ba1ebe1 100644 --- a/lib/include/srslte/phy/utils/mat.h +++ b/lib/include/srsran/phy/utils/mat.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,29 +10,29 @@ * */ -#ifndef SRSLTE_MAT_H -#define SRSLTE_MAT_H +#ifndef SRSRAN_MAT_H +#define SRSRAN_MAT_H -#include "srslte/config.h" -#include "srslte/phy/utils/simd.h" +#include "srsran/config.h" +#include "srsran/phy/utils/simd.h" #include /* Generic implementation for complex reciprocal */ -SRSLTE_API cf_t srslte_mat_cf_recip_gen(cf_t a); +SRSRAN_API cf_t srsran_mat_cf_recip_gen(cf_t a); /* Generic implementation for 2x2 determinant */ -SRSLTE_API cf_t srslte_mat_2x2_det_gen(cf_t a00, cf_t a01, cf_t a10, cf_t a11); +SRSRAN_API cf_t srsran_mat_2x2_det_gen(cf_t a00, cf_t a01, cf_t a10, cf_t a11); /* Generic implementation for 2x2 Matrix Inversion */ -SRSLTE_API void -srslte_mat_2x2_inv_gen(cf_t a00, cf_t a01, cf_t a10, cf_t a11, cf_t* r00, cf_t* r01, cf_t* r10, cf_t* r11); +SRSRAN_API void +srsran_mat_2x2_inv_gen(cf_t a00, cf_t a01, cf_t a10, cf_t a11, cf_t* r00, cf_t* r01, cf_t* r10, cf_t* r11); /* Generic implementation for Zero Forcing (ZF) solver */ -SRSLTE_API void -srslte_mat_2x2_zf_gen(cf_t y0, cf_t y1, cf_t h00, cf_t h01, cf_t h10, cf_t h11, cf_t* x0, cf_t* x1, float norm); +SRSRAN_API void +srsran_mat_2x2_zf_gen(cf_t y0, cf_t y1, cf_t h00, cf_t h01, cf_t h10, cf_t h11, cf_t* x0, cf_t* x1, float norm); /* Generic implementation for Minimum Mean Squared Error (MMSE) solver */ -SRSLTE_API void srslte_mat_2x2_mmse_gen(cf_t y0, +SRSRAN_API void srsran_mat_2x2_mmse_gen(cf_t y0, cf_t y1, cf_t h00, cf_t h01, @@ -43,7 +43,7 @@ SRSLTE_API void srslte_mat_2x2_mmse_gen(cf_t y0, float noise_estimate, float norm); -SRSLTE_API void srslte_mat_2x2_mmse_csi_gen(cf_t y0, +SRSRAN_API void srsran_mat_2x2_mmse_csi_gen(cf_t y0, cf_t y1, cf_t h00, cf_t h01, @@ -56,38 +56,38 @@ SRSLTE_API void srslte_mat_2x2_mmse_csi_gen(cf_t y0, float noise_estimate, float norm); -SRSLTE_API int srslte_mat_2x2_cn(cf_t h00, cf_t h01, cf_t h10, cf_t h11, float* cn); +SRSRAN_API int srsran_mat_2x2_cn(cf_t h00, cf_t h01, cf_t h10, cf_t h11, float* cn); #ifdef LV_HAVE_SSE /* SSE implementation for complex reciprocal */ -SRSLTE_API __m128 srslte_mat_cf_recip_sse(__m128 a); +SRSRAN_API __m128 srsran_mat_cf_recip_sse(__m128 a); /* SSE implementation for 2x2 determinant */ -SRSLTE_API __m128 srslte_mat_2x2_det_sse(__m128 a00, __m128 a01, __m128 a10, __m128 a11); +SRSRAN_API __m128 srsran_mat_2x2_det_sse(__m128 a00, __m128 a01, __m128 a10, __m128 a11); #endif /* LV_HAVE_SSE */ #ifdef LV_HAVE_AVX /* AVX implementation for complex reciprocal */ -SRSLTE_API __m256 srslte_mat_cf_recip_avx(__m256 a); +SRSRAN_API __m256 srsran_mat_cf_recip_avx(__m256 a); /* AVX implementation for 2x2 determinant */ -SRSLTE_API __m256 srslte_mat_2x2_det_avx(__m256 a00, __m256 a01, __m256 a10, __m256 a11); +SRSRAN_API __m256 srsran_mat_2x2_det_avx(__m256 a00, __m256 a01, __m256 a10, __m256 a11); #endif /* LV_HAVE_AVX */ -#if SRSLTE_SIMD_CF_SIZE != 0 +#if SRSRAN_SIMD_CF_SIZE != 0 /* Generic SIMD implementation for 2x2 determinant */ -static inline simd_cf_t srslte_mat_2x2_det_simd(simd_cf_t a00, simd_cf_t a01, simd_cf_t a10, simd_cf_t a11) +static inline simd_cf_t srsran_mat_2x2_det_simd(simd_cf_t a00, simd_cf_t a01, simd_cf_t a10, simd_cf_t a11) { - return srslte_simd_cf_sub(srslte_simd_cf_prod(a00, a11), srslte_simd_cf_prod(a01, a10)); + return srsran_simd_cf_sub(srsran_simd_cf_prod(a00, a11), srsran_simd_cf_prod(a01, a10)); } /* Generic SIMD implementation for Zero Forcing (ZF) solver */ -static inline void srslte_mat_2x2_zf_csi_simd(simd_cf_t y0, +static inline void srsran_mat_2x2_zf_csi_simd(simd_cf_t y0, simd_cf_t y1, simd_cf_t h00, simd_cf_t h01, @@ -99,17 +99,17 @@ static inline void srslte_mat_2x2_zf_csi_simd(simd_cf_t y0, simd_f_t* csi1, float norm) { - simd_cf_t det = srslte_mat_2x2_det_simd(h00, h01, h10, h11); - simd_cf_t detrec = srslte_simd_cf_mul(srslte_simd_cf_rcp(det), srslte_simd_f_set1(norm)); + simd_cf_t det = srsran_mat_2x2_det_simd(h00, h01, h10, h11); + simd_cf_t detrec = srsran_simd_cf_mul(srsran_simd_cf_rcp(det), srsran_simd_f_set1(norm)); - *x0 = srslte_simd_cf_prod(srslte_simd_cf_sub(srslte_simd_cf_prod(h11, y0), srslte_simd_cf_prod(h01, y1)), detrec); - *x1 = srslte_simd_cf_prod(srslte_simd_cf_sub(srslte_simd_cf_prod(h00, y1), srslte_simd_cf_prod(h10, y0)), detrec); + *x0 = srsran_simd_cf_prod(srsran_simd_cf_sub(srsran_simd_cf_prod(h11, y0), srsran_simd_cf_prod(h01, y1)), detrec); + *x1 = srsran_simd_cf_prod(srsran_simd_cf_sub(srsran_simd_cf_prod(h00, y1), srsran_simd_cf_prod(h10, y0)), detrec); - *csi0 = srslte_simd_f_set1(1.0f); - *csi1 = srslte_simd_f_set1(1.0f); + *csi0 = srsran_simd_f_set1(1.0f); + *csi1 = srsran_simd_f_set1(1.0f); } -static inline void srslte_mat_2x2_zf_simd(simd_cf_t y0, +static inline void srsran_mat_2x2_zf_simd(simd_cf_t y0, simd_cf_t y1, simd_cf_t h00, simd_cf_t h01, @@ -120,11 +120,11 @@ static inline void srslte_mat_2x2_zf_simd(simd_cf_t y0, float norm) { simd_f_t csi1, csi2; - srslte_mat_2x2_zf_csi_simd(y0, y1, h00, h01, h10, h11, x0, x1, &csi1, &csi2, norm); + srsran_mat_2x2_zf_csi_simd(y0, y1, h00, h01, h10, h11, x0, x1, &csi1, &csi2, norm); } /* Generic SIMD implementation for Minimum Mean Squared Error (MMSE) solver */ -static inline void srslte_mat_2x2_mmse_csi_simd(simd_cf_t y0, +static inline void srsran_mat_2x2_mmse_csi_simd(simd_cf_t y0, simd_cf_t y1, simd_cf_t h00, simd_cf_t h01, @@ -138,48 +138,48 @@ static inline void srslte_mat_2x2_mmse_csi_simd(simd_cf_t y0, float norm) { simd_cf_t _noise_estimate; - simd_f_t _norm = srslte_simd_f_set1(norm); + simd_f_t _norm = srsran_simd_f_set1(norm); #if HAVE_NEON - _noise_estimate.val[0] = srslte_simd_f_set1(noise_estimate); - _noise_estimate.val[1] = srslte_simd_f_zero(); + _noise_estimate.val[0] = srsran_simd_f_set1(noise_estimate); + _noise_estimate.val[1] = srsran_simd_f_zero(); #else /* HAVE_NEON */ - _noise_estimate.re = srslte_simd_f_set1(noise_estimate); - _noise_estimate.im = srslte_simd_f_zero(); + _noise_estimate.re = srsran_simd_f_set1(noise_estimate); + _noise_estimate.im = srsran_simd_f_zero(); #endif /* HAVE_NEON */ /* 1. A = H' x H + No*/ - simd_cf_t a00 = srslte_simd_cf_add( - srslte_simd_cf_add(srslte_simd_cf_conjprod(h00, h00), srslte_simd_cf_conjprod(h10, h10)), _noise_estimate); - simd_cf_t a01 = srslte_simd_cf_add(srslte_simd_cf_conjprod(h01, h00), srslte_simd_cf_conjprod(h11, h10)); - simd_cf_t a10 = srslte_simd_cf_add(srslte_simd_cf_conjprod(h00, h01), srslte_simd_cf_conjprod(h10, h11)); - simd_cf_t a11 = srslte_simd_cf_add( - srslte_simd_cf_add(srslte_simd_cf_conjprod(h01, h01), srslte_simd_cf_conjprod(h11, h11)), _noise_estimate); - simd_cf_t a_det_rcp = srslte_simd_cf_rcp(srslte_mat_2x2_det_simd(a00, a01, a10, a11)); + simd_cf_t a00 = srsran_simd_cf_add( + srsran_simd_cf_add(srsran_simd_cf_conjprod(h00, h00), srsran_simd_cf_conjprod(h10, h10)), _noise_estimate); + simd_cf_t a01 = srsran_simd_cf_add(srsran_simd_cf_conjprod(h01, h00), srsran_simd_cf_conjprod(h11, h10)); + simd_cf_t a10 = srsran_simd_cf_add(srsran_simd_cf_conjprod(h00, h01), srsran_simd_cf_conjprod(h10, h11)); + simd_cf_t a11 = srsran_simd_cf_add( + srsran_simd_cf_add(srsran_simd_cf_conjprod(h01, h01), srsran_simd_cf_conjprod(h11, h11)), _noise_estimate); + simd_cf_t a_det_rcp = srsran_simd_cf_rcp(srsran_mat_2x2_det_simd(a00, a01, a10, a11)); /* 2. B = inv(H' x H + No) = inv(A) */ - simd_cf_t _norm2 = srslte_simd_cf_mul(a_det_rcp, _norm); - simd_cf_t b00 = srslte_simd_cf_prod(a11, _norm2); - simd_cf_t b01 = srslte_simd_cf_prod(srslte_simd_cf_neg(a01), _norm2); - simd_cf_t b10 = srslte_simd_cf_prod(srslte_simd_cf_neg(a10), _norm2); - simd_cf_t b11 = srslte_simd_cf_prod(a00, _norm2); + simd_cf_t _norm2 = srsran_simd_cf_mul(a_det_rcp, _norm); + simd_cf_t b00 = srsran_simd_cf_prod(a11, _norm2); + simd_cf_t b01 = srsran_simd_cf_prod(srsran_simd_cf_neg(a01), _norm2); + simd_cf_t b10 = srsran_simd_cf_prod(srsran_simd_cf_neg(a10), _norm2); + simd_cf_t b11 = srsran_simd_cf_prod(a00, _norm2); /* 3. W = inv(H' x H + No) x H' = B x H' */ - simd_cf_t w00 = srslte_simd_cf_add(srslte_simd_cf_conjprod(b00, h00), srslte_simd_cf_conjprod(b01, h01)); - simd_cf_t w01 = srslte_simd_cf_add(srslte_simd_cf_conjprod(b00, h10), srslte_simd_cf_conjprod(b01, h11)); - simd_cf_t w10 = srslte_simd_cf_add(srslte_simd_cf_conjprod(b10, h00), srslte_simd_cf_conjprod(b11, h01)); - simd_cf_t w11 = srslte_simd_cf_add(srslte_simd_cf_conjprod(b10, h10), srslte_simd_cf_conjprod(b11, h11)); + simd_cf_t w00 = srsran_simd_cf_add(srsran_simd_cf_conjprod(b00, h00), srsran_simd_cf_conjprod(b01, h01)); + simd_cf_t w01 = srsran_simd_cf_add(srsran_simd_cf_conjprod(b00, h10), srsran_simd_cf_conjprod(b01, h11)); + simd_cf_t w10 = srsran_simd_cf_add(srsran_simd_cf_conjprod(b10, h00), srsran_simd_cf_conjprod(b11, h01)); + simd_cf_t w11 = srsran_simd_cf_add(srsran_simd_cf_conjprod(b10, h10), srsran_simd_cf_conjprod(b11, h11)); /* 4. X = W x Y */ - *x0 = srslte_simd_cf_add(srslte_simd_cf_prod(y0, w00), srslte_simd_cf_prod(y1, w01)); - *x1 = srslte_simd_cf_add(srslte_simd_cf_prod(y0, w10), srslte_simd_cf_prod(y1, w11)); + *x0 = srsran_simd_cf_add(srsran_simd_cf_prod(y0, w00), srsran_simd_cf_prod(y1, w01)); + *x1 = srsran_simd_cf_add(srsran_simd_cf_prod(y0, w10), srsran_simd_cf_prod(y1, w11)); /* 5. Extract CSI */ - *csi0 = srslte_simd_f_rcp(srslte_simd_cf_re(b00)); - *csi1 = srslte_simd_f_rcp(srslte_simd_cf_re(b11)); + *csi0 = srsran_simd_f_rcp(srsran_simd_cf_re(b00)); + *csi1 = srsran_simd_f_rcp(srsran_simd_cf_re(b11)); } -static inline void srslte_mat_2x2_mmse_simd(simd_cf_t y0, +static inline void srsran_mat_2x2_mmse_simd(simd_cf_t y0, simd_cf_t y1, simd_cf_t h00, simd_cf_t h01, @@ -191,21 +191,21 @@ static inline void srslte_mat_2x2_mmse_simd(simd_cf_t y0, float norm) { simd_f_t csi0, csi1; - srslte_mat_2x2_mmse_csi_simd(y0, y1, h00, h01, h10, h11, x0, x1, &csi0, &csi1, noise_estimate, norm); + srsran_mat_2x2_mmse_csi_simd(y0, y1, h00, h01, h10, h11, x0, x1, &csi0, &csi1, noise_estimate, norm); } -#endif /* SRSLTE_SIMD_CF_SIZE != 0 */ +#endif /* SRSRAN_SIMD_CF_SIZE != 0 */ typedef struct { uint32_t N; cf_t* row_buffer; cf_t* matrix; -} srslte_matrix_NxN_inv_t; +} srsran_matrix_NxN_inv_t; -SRSLTE_API int srslte_matrix_NxN_inv_init(srslte_matrix_NxN_inv_t* q, uint32_t N); +SRSRAN_API int srsran_matrix_NxN_inv_init(srsran_matrix_NxN_inv_t* q, uint32_t N); -SRSLTE_API void srslte_matrix_NxN_inv_run(srslte_matrix_NxN_inv_t* q, cf_t* in, cf_t* out); +SRSRAN_API void srsran_matrix_NxN_inv_run(srsran_matrix_NxN_inv_t* q, cf_t* in, cf_t* out); -SRSLTE_API void srslte_matrix_NxN_inv_free(srslte_matrix_NxN_inv_t* q); +SRSRAN_API void srsran_matrix_NxN_inv_free(srsran_matrix_NxN_inv_t* q); -#endif /* SRSLTE_MAT_H */ +#endif /* SRSRAN_MAT_H */ diff --git a/lib/include/srslte/phy/utils/phy_logger.h b/lib/include/srsran/phy/utils/phy_logger.h similarity index 76% rename from lib/include/srslte/phy/utils/phy_logger.h rename to lib/include/srsran/phy/utils/phy_logger.h index e5c73a57e..f1a931c34 100644 --- a/lib/include/srslte/phy/utils/phy_logger.h +++ b/lib/include/srsran/phy/utils/phy_logger.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -15,8 +15,8 @@ * Description: Interface for logging output *****************************************************************************/ -#ifndef SRSLTE_PHY_LOGGER_H -#define SRSLTE_PHY_LOGGER_H +#ifndef SRSRAN_PHY_LOGGER_H +#define SRSRAN_PHY_LOGGER_H #include #include @@ -32,12 +32,12 @@ typedef enum { LOG_LEVEL_INFO_S, LOG_LEVEL_DEBUG_S, LOG_LEVEL_ERROR_S } phy_logg typedef void (*phy_log_handler_t)(phy_logger_level_t log_level, void* ctx, char* str); -void srslte_phy_log_register_handler(void* ctx, phy_log_handler_t handler); +void srsran_phy_log_register_handler(void* ctx, phy_log_handler_t handler); -void srslte_phy_log_print(phy_logger_level_t log_level, const char* format, ...); +void srsran_phy_log_print(phy_logger_level_t log_level, const char* format, ...); #ifdef __cplusplus } #endif // C++ -#endif // SRSLTE_PHY_LOGGER_H +#endif // SRSRAN_PHY_LOGGER_H diff --git a/lib/include/srslte/phy/utils/primes.h b/lib/include/srsran/phy/utils/primes.h similarity index 55% rename from lib/include/srslte/phy/utils/primes.h rename to lib/include/srsran/phy/utils/primes.h index 96600810f..33c5ac2fb 100644 --- a/lib/include/srslte/phy/utils/primes.h +++ b/lib/include/srsran/phy/utils/primes.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,25 +10,25 @@ * */ -#ifndef SRSLTE_PRIMES_H -#define SRSLTE_PRIMES_H +#ifndef SRSRAN_PRIMES_H +#define SRSRAN_PRIMES_H -#include "srslte/config.h" +#include "srsran/config.h" #include /** * @brief Finds the smallest prime number greater than n * @param[in] n Provide the number - * @return A prime number below 1193, SRSLTE_ERROR code otherwise + * @return A prime number below 1193, SRSRAN_ERROR code otherwise */ -SRSLTE_API int srslte_prime_greater_than(uint32_t n); +SRSRAN_API int srsran_prime_greater_than(uint32_t n); /** * @brief Finds the biggest prime number lesser than n * @attention the maximum prime number it can return is 1193 * @param[in] n Provide the number - * @return A prime number below 1193, SRSLTE_ERROR code otherwise + * @return A prime number below 1193, SRSRAN_ERROR code otherwise */ -SRSLTE_API int srslte_prime_lower_than(uint32_t n); +SRSRAN_API int srsran_prime_lower_than(uint32_t n); -#endif // SRSLTE_PRIMES_H +#endif // SRSRAN_PRIMES_H diff --git a/lib/include/srsran/phy/utils/random.h b/lib/include/srsran/phy/utils/random.h new file mode 100644 index 000000000..1cf42196a --- /dev/null +++ b/lib/include/srsran/phy/utils/random.h @@ -0,0 +1,48 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +#ifndef SRSRAN_RANDOM_H +#define SRSRAN_RANDOM_H + +#include "srsran/config.h" + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void* srsran_random_t; + +SRSRAN_API srsran_random_t srsran_random_init(uint32_t seed); + +SRSRAN_API int srsran_random_uniform_int_dist(srsran_random_t q, int min, int max); + +SRSRAN_API float srsran_random_uniform_real_dist(srsran_random_t q, float min, float max); + +SRSRAN_API cf_t srsran_random_uniform_complex_dist(srsran_random_t q, float min, float max); + +SRSRAN_API void +srsran_random_uniform_complex_dist_vector(srsran_random_t q, cf_t* vector, uint32_t nsamples, float min, float max); + +SRSRAN_API float srsran_random_gauss_dist(srsran_random_t q, float std_dev); + +SRSRAN_API bool srsran_random_bool(srsran_random_t q, float prob_true); + +SRSRAN_API void srsran_random_free(srsran_random_t q); + +#ifdef __cplusplus +} +#endif + +#endif // SRSRAN_RANDOM_H diff --git a/lib/include/srslte/phy/utils/ringbuffer.h b/lib/include/srsran/phy/utils/ringbuffer.h similarity index 55% rename from lib/include/srslte/phy/utils/ringbuffer.h rename to lib/include/srsran/phy/utils/ringbuffer.h index 548a7267b..a516a780c 100644 --- a/lib/include/srslte/phy/utils/ringbuffer.h +++ b/lib/include/srsran/phy/utils/ringbuffer.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,10 +10,10 @@ * */ -#ifndef SRSLTE_RINGBUFFER_H -#define SRSLTE_RINGBUFFER_H +#ifndef SRSRAN_RINGBUFFER_H +#define SRSRAN_RINGBUFFER_H -#include "srslte/config.h" +#include "srsran/config.h" #include #include #include @@ -28,53 +28,53 @@ typedef struct { pthread_mutex_t mutex; pthread_cond_t write_cvar; pthread_cond_t read_cvar; -} srslte_ringbuffer_t; +} srsran_ringbuffer_t; #ifdef __cplusplus extern "C" { #endif -SRSLTE_API int srslte_ringbuffer_init(srslte_ringbuffer_t* q, int capacity); +SRSRAN_API int srsran_ringbuffer_init(srsran_ringbuffer_t* q, int capacity); -SRSLTE_API void srslte_ringbuffer_free(srslte_ringbuffer_t* q); +SRSRAN_API void srsran_ringbuffer_free(srsran_ringbuffer_t* q); -SRSLTE_API void srslte_ringbuffer_reset(srslte_ringbuffer_t* q); +SRSRAN_API void srsran_ringbuffer_reset(srsran_ringbuffer_t* q); -SRSLTE_API int srslte_ringbuffer_status(srslte_ringbuffer_t* q); +SRSRAN_API int srsran_ringbuffer_status(srsran_ringbuffer_t* q); -SRSLTE_API int srslte_ringbuffer_space(srslte_ringbuffer_t* q); +SRSRAN_API int srsran_ringbuffer_space(srsran_ringbuffer_t* q); -SRSLTE_API int srslte_ringbuffer_resize(srslte_ringbuffer_t* q, int capacity); +SRSRAN_API int srsran_ringbuffer_resize(srsran_ringbuffer_t* q, int capacity); // write to the buffer immediately, if there isnt enough space it will overflow -SRSLTE_API int srslte_ringbuffer_write(srslte_ringbuffer_t* q, void* ptr, int nof_bytes); +SRSRAN_API int srsran_ringbuffer_write(srsran_ringbuffer_t* q, void* ptr, int nof_bytes); // block forever until there is enough space then write to buffer -SRSLTE_API int srslte_ringbuffer_write_block(srslte_ringbuffer_t* q, void* ptr, int nof_bytes); +SRSRAN_API int srsran_ringbuffer_write_block(srsran_ringbuffer_t* q, void* ptr, int nof_bytes); // block for timeout_ms milliseconds, then either write to buffer if there is space or return an error without writing -SRSLTE_API int srslte_ringbuffer_write_timed(srslte_ringbuffer_t* q, void* ptr, int nof_bytes, int32_t timeout_ms); +SRSRAN_API int srsran_ringbuffer_write_timed(srsran_ringbuffer_t* q, void* ptr, int nof_bytes, int32_t timeout_ms); -SRSLTE_API int -srslte_ringbuffer_write_timed_block(srslte_ringbuffer_t* q, void* ptr, int nof_bytes, int32_t timeout_ms); +SRSRAN_API int +srsran_ringbuffer_write_timed_block(srsran_ringbuffer_t* q, void* ptr, int nof_bytes, int32_t timeout_ms); // read from buffer, blocking until there is enough samples -SRSLTE_API int srslte_ringbuffer_read(srslte_ringbuffer_t* q, void* ptr, int nof_bytes); +SRSRAN_API int srsran_ringbuffer_read(srsran_ringbuffer_t* q, void* ptr, int nof_bytes); // read from buffer, blocking for timeout_ms milliseconds until there is enough samples or return an error -SRSLTE_API int srslte_ringbuffer_read_timed(srslte_ringbuffer_t* q, void* p, int nof_bytes, int32_t timeout_ms); +SRSRAN_API int srsran_ringbuffer_read_timed(srsran_ringbuffer_t* q, void* p, int nof_bytes, int32_t timeout_ms); -SRSLTE_API int srslte_ringbuffer_read_timed_block(srslte_ringbuffer_t* q, void* p, int nof_bytes, int32_t timeout_ms); +SRSRAN_API int srsran_ringbuffer_read_timed_block(srsran_ringbuffer_t* q, void* p, int nof_bytes, int32_t timeout_ms); // read samples from the buffer, convert them from uint16_t to cplx float and get the conjugate -SRSLTE_API int srslte_ringbuffer_read_convert_conj(srslte_ringbuffer_t* q, cf_t* dst_ptr, float norm, int nof_samples); +SRSRAN_API int srsran_ringbuffer_read_convert_conj(srsran_ringbuffer_t* q, cf_t* dst_ptr, float norm, int nof_samples); -SRSLTE_API int srslte_ringbuffer_read_block(srslte_ringbuffer_t* q, void** p, int nof_bytes, int32_t timeout_ms); +SRSRAN_API int srsran_ringbuffer_read_block(srsran_ringbuffer_t* q, void** p, int nof_bytes, int32_t timeout_ms); -SRSLTE_API void srslte_ringbuffer_stop(srslte_ringbuffer_t* q); +SRSRAN_API void srsran_ringbuffer_stop(srsran_ringbuffer_t* q); #ifdef __cplusplus } #endif -#endif // SRSLTE_RINGBUFFER_H +#endif // SRSRAN_RINGBUFFER_H diff --git a/lib/include/srslte/phy/utils/simd.h b/lib/include/srsran/phy/utils/simd.h similarity index 87% rename from lib/include/srslte/phy/utils/simd.h rename to lib/include/srsran/phy/utils/simd.h index 7111d1961..cddb5a1f6 100644 --- a/lib/include/srslte/phy/utils/simd.h +++ b/lib/include/srsran/phy/utils/simd.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,8 +10,8 @@ * */ -#ifndef SRSLTE_SIMD_H -#define SRSLTE_SIMD_H +#ifndef SRSRAN_SIMD_H +#define SRSRAN_SIMD_H #ifdef LV_HAVE_SSE /* AVX, AVX2, FMA, AVX512 are in this group */ #ifndef __OPTIMIZE__ @@ -20,7 +20,7 @@ #include #endif /* LV_HAVE_SSE */ -#include "srslte/config.h" +#include "srsran/config.h" #include #ifdef HAVE_NEON @@ -90,80 +90,80 @@ * SIMD Vector bit alignment */ #ifdef LV_HAVE_AVX512 -#define SRSLTE_SIMD_BIT_ALIGN 512 -#define SRSLTE_IS_ALIGNED(PTR) (((size_t)(PTR)&0x3F) == 0) +#define SRSRAN_SIMD_BIT_ALIGN 512 +#define SRSRAN_IS_ALIGNED(PTR) (((size_t)(PTR)&0x3F) == 0) #else /* LV_HAVE_AVX512 */ #ifdef LV_HAVE_AVX -#define SRSLTE_SIMD_BIT_ALIGN 256 -#define SRSLTE_IS_ALIGNED(PTR) (((size_t)(PTR)&0x1F) == 0) +#define SRSRAN_SIMD_BIT_ALIGN 256 +#define SRSRAN_IS_ALIGNED(PTR) (((size_t)(PTR)&0x1F) == 0) #else /* LV_HAVE_AVX */ #ifdef LV_HAVE_SSE -#define SRSLTE_SIMD_BIT_ALIGN 128 -#define SRSLTE_IS_ALIGNED(PTR) (((size_t)(PTR)&0x0F) == 0) +#define SRSRAN_SIMD_BIT_ALIGN 128 +#define SRSRAN_IS_ALIGNED(PTR) (((size_t)(PTR)&0x0F) == 0) #else /* LV_HAVE_SSE */ -#define SRSLTE_SIMD_BIT_ALIGN 64 -#define SRSLTE_IS_ALIGNED(PTR) (1) +#define SRSRAN_SIMD_BIT_ALIGN 64 +#define SRSRAN_IS_ALIGNED(PTR) (1) #endif /* LV_HAVE_SSE */ #endif /* LV_HAVE_AVX */ #endif /* LV_HAVE_AVX512 */ -#define srslte_simd_aligned __attribute__((aligned(SRSLTE_SIMD_BIT_ALIGN / 8))) +#define srsran_simd_aligned __attribute__((aligned(SRSRAN_SIMD_BIT_ALIGN / 8))) /* Memory Sizes for Single Floating Point and fixed point */ #ifdef LV_HAVE_AVX512 -#define SRSLTE_SIMD_F_SIZE 16 -#define SRSLTE_SIMD_CF_SIZE 16 +#define SRSRAN_SIMD_F_SIZE 16 +#define SRSRAN_SIMD_CF_SIZE 16 -#define SRSLTE_SIMD_I_SIZE 16 +#define SRSRAN_SIMD_I_SIZE 16 -#define SRSLTE_SIMD_B_SIZE 64 -#define SRSLTE_SIMD_S_SIZE 32 -#define SRSLTE_SIMD_C16_SIZE 0 +#define SRSRAN_SIMD_B_SIZE 64 +#define SRSRAN_SIMD_S_SIZE 32 +#define SRSRAN_SIMD_C16_SIZE 0 #else #ifdef LV_HAVE_AVX2 -#define SRSLTE_SIMD_F_SIZE 8 -#define SRSLTE_SIMD_CF_SIZE 8 +#define SRSRAN_SIMD_F_SIZE 8 +#define SRSRAN_SIMD_CF_SIZE 8 -#define SRSLTE_SIMD_I_SIZE 8 +#define SRSRAN_SIMD_I_SIZE 8 -#define SRSLTE_SIMD_B_SIZE 32 -#define SRSLTE_SIMD_S_SIZE 16 -#define SRSLTE_SIMD_C16_SIZE 16 +#define SRSRAN_SIMD_B_SIZE 32 +#define SRSRAN_SIMD_S_SIZE 16 +#define SRSRAN_SIMD_C16_SIZE 16 #else /* LV_HAVE_AVX2 */ #ifdef LV_HAVE_SSE -#define SRSLTE_SIMD_F_SIZE 4 -#define SRSLTE_SIMD_CF_SIZE 4 +#define SRSRAN_SIMD_F_SIZE 4 +#define SRSRAN_SIMD_CF_SIZE 4 -#define SRSLTE_SIMD_I_SIZE 4 +#define SRSRAN_SIMD_I_SIZE 4 -#define SRSLTE_SIMD_B_SIZE 16 -#define SRSLTE_SIMD_S_SIZE 8 -#define SRSLTE_SIMD_C16_SIZE 8 +#define SRSRAN_SIMD_B_SIZE 16 +#define SRSRAN_SIMD_S_SIZE 8 +#define SRSRAN_SIMD_C16_SIZE 8 #else /* LV_HAVE_SSE */ #ifdef HAVE_NEON -#define SRSLTE_SIMD_F_SIZE 4 -#define SRSLTE_SIMD_CF_SIZE 4 +#define SRSRAN_SIMD_F_SIZE 4 +#define SRSRAN_SIMD_CF_SIZE 4 -#define SRSLTE_SIMD_I_SIZE 4 -#define SRSLTE_SIMD_B_SIZE 16 -#define SRSLTE_SIMD_S_SIZE 8 -#define SRSLTE_SIMD_C16_SIZE 8 +#define SRSRAN_SIMD_I_SIZE 4 +#define SRSRAN_SIMD_B_SIZE 16 +#define SRSRAN_SIMD_S_SIZE 8 +#define SRSRAN_SIMD_C16_SIZE 8 #else /* HAVE_NEON */ -#define SRSLTE_SIMD_F_SIZE 0 -#define SRSLTE_SIMD_CF_SIZE 0 +#define SRSRAN_SIMD_F_SIZE 0 +#define SRSRAN_SIMD_CF_SIZE 0 -#define SRSLTE_SIMD_I_SIZE 0 -#define SRSLTE_SIMD_B_SIZE 0 -#define SRSLTE_SIMD_S_SIZE 0 -#define SRSLTE_SIMD_C16_SIZE 0 +#define SRSRAN_SIMD_I_SIZE 0 +#define SRSRAN_SIMD_B_SIZE 0 +#define SRSRAN_SIMD_S_SIZE 0 +#define SRSRAN_SIMD_C16_SIZE 0 #endif /* HAVE_NEON */ #endif /* LV_HAVE_SSE */ @@ -171,11 +171,11 @@ #endif /* LV_HAVE_AVX512 */ #ifndef ENABLE_C16 -#undef SRSLTE_SIMD_C16_SIZE -#define SRSLTE_SIMD_C16_SIZE 0 +#undef SRSRAN_SIMD_C16_SIZE +#define SRSRAN_SIMD_C16_SIZE 0 #endif /* ENABLE_C16 */ -#if SRSLTE_SIMD_F_SIZE +#if SRSRAN_SIMD_F_SIZE /* Data types */ #ifdef LV_HAVE_AVX512 @@ -195,7 +195,7 @@ typedef float32x4_t simd_f_t; #endif /* LV_HAVE_AVX512 */ /* Single precision Floating point functions */ -static inline simd_f_t srslte_simd_f_load(const float* ptr) +static inline simd_f_t srsran_simd_f_load(const float* ptr) { #ifdef LV_HAVE_AVX512 return _mm512_load_ps(ptr); @@ -214,7 +214,7 @@ static inline simd_f_t srslte_simd_f_load(const float* ptr) #endif /* LV_HAVE_AVX512 */ } -static inline simd_f_t srslte_simd_f_loadu(const float* ptr) +static inline simd_f_t srsran_simd_f_loadu(const float* ptr) { #ifdef LV_HAVE_AVX512 return _mm512_loadu_ps(ptr); @@ -233,7 +233,7 @@ static inline simd_f_t srslte_simd_f_loadu(const float* ptr) #endif /* LV_HAVE_AVX512 */ } -static inline void srslte_simd_f_store(float* ptr, simd_f_t simdreg) +static inline void srsran_simd_f_store(float* ptr, simd_f_t simdreg) { #ifdef LV_HAVE_AVX512 _mm512_store_ps(ptr, simdreg); @@ -252,7 +252,7 @@ static inline void srslte_simd_f_store(float* ptr, simd_f_t simdreg) #endif /* LV_HAVE_AVX512 */ } -static inline void srslte_simd_f_storeu(float* ptr, simd_f_t simdreg) +static inline void srsran_simd_f_storeu(float* ptr, simd_f_t simdreg) { #ifdef LV_HAVE_AVX512 _mm512_storeu_ps(ptr, simdreg); @@ -271,7 +271,7 @@ static inline void srslte_simd_f_storeu(float* ptr, simd_f_t simdreg) #endif /* LV_HAVE_AVX512 */ } -static inline simd_f_t srslte_simd_f_set1(float x) +static inline simd_f_t srsran_simd_f_set1(float x) { #ifdef LV_HAVE_AVX512 return _mm512_set1_ps(x); @@ -290,7 +290,7 @@ static inline simd_f_t srslte_simd_f_set1(float x) #endif /* LV_HAVE_AVX512 */ } -static inline simd_f_t srslte_simd_f_mul(simd_f_t a, simd_f_t b) +static inline simd_f_t srsran_simd_f_mul(simd_f_t a, simd_f_t b) { #ifdef LV_HAVE_AVX512 return _mm512_mul_ps(a, b); @@ -309,7 +309,7 @@ static inline simd_f_t srslte_simd_f_mul(simd_f_t a, simd_f_t b) #endif /* LV_HAVE_AVX512 */ } -static inline simd_f_t srslte_simd_f_rcp(simd_f_t a) +static inline simd_f_t srsran_simd_f_rcp(simd_f_t a) { #ifdef LV_HAVE_AVX512 return _mm512_rcp14_ps(a); @@ -328,7 +328,7 @@ static inline simd_f_t srslte_simd_f_rcp(simd_f_t a) #endif /* LV_HAVE_AVX512 */ } -static inline simd_f_t srslte_simd_f_addsub(simd_f_t a, simd_f_t b) +static inline simd_f_t srsran_simd_f_addsub(simd_f_t a, simd_f_t b) { #ifdef LV_HAVE_AVX512 __m512 r = _mm512_add_ps(a, b); @@ -360,7 +360,7 @@ static inline simd_f_t srslte_simd_f_addsub(simd_f_t a, simd_f_t b) #endif /* LV_HAVE_AVX512 */ } -static inline simd_f_t srslte_simd_f_sub(simd_f_t a, simd_f_t b) +static inline simd_f_t srsran_simd_f_sub(simd_f_t a, simd_f_t b) { #ifdef LV_HAVE_AVX512 return _mm512_sub_ps(a, b); @@ -379,7 +379,7 @@ static inline simd_f_t srslte_simd_f_sub(simd_f_t a, simd_f_t b) #endif /* LV_HAVE_AVX512 */ } -static inline simd_f_t srslte_simd_f_add(simd_f_t a, simd_f_t b) +static inline simd_f_t srsran_simd_f_add(simd_f_t a, simd_f_t b) { #ifdef LV_HAVE_AVX512 return _mm512_add_ps(a, b); @@ -398,7 +398,7 @@ static inline simd_f_t srslte_simd_f_add(simd_f_t a, simd_f_t b) #endif /* LV_HAVE_AVX512 */ } -static inline simd_f_t srslte_simd_f_zero(void) +static inline simd_f_t srsran_simd_f_zero(void) { #ifdef LV_HAVE_AVX512 return _mm512_setzero_ps(); @@ -417,7 +417,7 @@ static inline simd_f_t srslte_simd_f_zero(void) #endif /* LV_HAVE_AVX512 */ } -static inline simd_f_t srslte_simd_f_swap(simd_f_t a) +static inline simd_f_t srsran_simd_f_swap(simd_f_t a) { #ifdef LV_HAVE_AVX512 return _mm512_permute_ps(a, 0b10110001); @@ -436,7 +436,7 @@ static inline simd_f_t srslte_simd_f_swap(simd_f_t a) #endif /* LV_HAVE_AVX512 */ } -static inline simd_f_t srslte_simd_f_hadd(simd_f_t a, simd_f_t b) +static inline simd_f_t srsran_simd_f_hadd(simd_f_t a, simd_f_t b) { #ifdef LV_HAVE_AVX512 const __m512i idx1 = _mm512_setr_epi32((0b00000), @@ -477,7 +477,7 @@ static inline simd_f_t srslte_simd_f_hadd(simd_f_t a, simd_f_t b) #endif /* LV_HAVE_AVX512 */ } -static inline simd_f_t srslte_simd_f_sqrt(simd_f_t a) +static inline simd_f_t srsran_simd_f_sqrt(simd_f_t a) { #ifdef LV_HAVE_AVX512 return _mm512_sqrt_ps(a); @@ -503,7 +503,7 @@ static inline simd_f_t srslte_simd_f_sqrt(simd_f_t a) #endif /* LV_HAVE_AVX512 */ } -static inline simd_f_t srslte_simd_f_neg(simd_f_t a) +static inline simd_f_t srsran_simd_f_neg(simd_f_t a) { #ifdef LV_HAVE_AVX512 return _mm512_xor_ps(_mm512_set1_ps(-0.0f), a); @@ -522,7 +522,7 @@ static inline simd_f_t srslte_simd_f_neg(simd_f_t a) #endif /* LV_HAVE_AVX512 */ } -static inline simd_f_t srslte_simd_f_neg_mask(simd_f_t a, simd_f_t mask) +static inline simd_f_t srsran_simd_f_neg_mask(simd_f_t a, simd_f_t mask) { #ifdef LV_HAVE_AVX512 return _mm512_xor_ps(mask, a); @@ -541,7 +541,7 @@ static inline simd_f_t srslte_simd_f_neg_mask(simd_f_t a, simd_f_t mask) #endif /* LV_HAVE_AVX512 */ } -static inline simd_f_t srslte_simd_f_abs(simd_f_t a) +static inline simd_f_t srsran_simd_f_abs(simd_f_t a) { #ifdef LV_HAVE_AVX512 return _mm512_andnot_ps(_mm512_set1_ps(-0.0f), a); @@ -560,22 +560,22 @@ static inline simd_f_t srslte_simd_f_abs(simd_f_t a) #endif /* LV_HAVE_AVX512 */ } -static inline void srslte_simd_f_fprintf(FILE* stream, simd_f_t a) +static inline void srsran_simd_f_fprintf(FILE* stream, simd_f_t a) { - float x[SRSLTE_SIMD_F_SIZE]; + float x[SRSRAN_SIMD_F_SIZE]; - srslte_simd_f_storeu(x, a); + srsran_simd_f_storeu(x, a); fprintf(stream, "["); - for (int i = 0; i < SRSLTE_SIMD_F_SIZE; i++) { + for (int i = 0; i < SRSRAN_SIMD_F_SIZE; i++) { fprintf(stream, "%+2.5f, ", x[i]); } fprintf(stream, "];\n"); } -#endif /* SRSLTE_SIMD_F_SIZE */ +#endif /* SRSRAN_SIMD_F_SIZE */ -#if SRSLTE_SIMD_CF_SIZE +#if SRSRAN_SIMD_CF_SIZE #ifdef HAVE_NEON typedef float32x4x2_t simd_cf_t; @@ -587,12 +587,12 @@ typedef struct { #endif /* Complex Single precission Floating point functions */ -static inline simd_cf_t srslte_simd_cfi_load(const cf_t* ptr) +static inline simd_cf_t srsran_simd_cfi_load(const cf_t* ptr) { simd_cf_t ret; #ifdef LV_HAVE_AVX512 __m512 in1 = _mm512_load_ps((float*)(ptr)); - __m512 in2 = _mm512_load_ps((float*)(ptr + SRSLTE_SIMD_CF_SIZE / 2)); + __m512 in2 = _mm512_load_ps((float*)(ptr + SRSRAN_SIMD_CF_SIZE / 2)); ret.re = _mm512_permutex2var_ps( in1, _mm512_setr_epi32(0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x0E, 0x10, 0x12, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x1E), @@ -624,12 +624,12 @@ static inline simd_cf_t srslte_simd_cfi_load(const cf_t* ptr) } /* Complex Single precission Floating point functions */ -static inline simd_cf_t srslte_simd_cfi_loadu(const cf_t* ptr) +static inline simd_cf_t srsran_simd_cfi_loadu(const cf_t* ptr) { simd_cf_t ret; #ifdef LV_HAVE_AVX512 __m512 in1 = _mm512_loadu_ps((float*)(ptr)); - __m512 in2 = _mm512_loadu_ps((float*)(ptr + SRSLTE_SIMD_CF_SIZE / 2)); + __m512 in2 = _mm512_loadu_ps((float*)(ptr + SRSRAN_SIMD_CF_SIZE / 2)); ret.re = _mm512_permutex2var_ps( in1, _mm512_setr_epi32(0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x0E, 0x10, 0x12, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x1E), @@ -660,7 +660,7 @@ static inline simd_cf_t srslte_simd_cfi_loadu(const cf_t* ptr) return ret; } -static inline simd_cf_t srslte_simd_cf_load(const float* re, const float* im) +static inline simd_cf_t srsran_simd_cf_load(const float* re, const float* im) { simd_cf_t ret; #ifdef LV_HAVE_AVX512 @@ -685,7 +685,7 @@ static inline simd_cf_t srslte_simd_cf_load(const float* re, const float* im) return ret; } -static inline simd_cf_t srslte_simd_cf_loadu(const float* re, const float* im) +static inline simd_cf_t srsran_simd_cf_loadu(const float* re, const float* im) { simd_cf_t ret; #ifdef LV_HAVE_AVX512 @@ -710,7 +710,7 @@ static inline simd_cf_t srslte_simd_cf_loadu(const float* re, const float* im) return ret; } -static inline void srslte_simd_cfi_store(cf_t* ptr, simd_cf_t simdreg) +static inline void srsran_simd_cfi_store(cf_t* ptr, simd_cf_t simdreg) { #ifdef LV_HAVE_AVX512 __m512 s1 = _mm512_permutex2var_ps( @@ -742,7 +742,7 @@ static inline void srslte_simd_cfi_store(cf_t* ptr, simd_cf_t simdreg) #endif /* LV_HAVE_AVX512 */ } -static inline void srslte_simd_cfi_storeu(cf_t* ptr, simd_cf_t simdreg) +static inline void srsran_simd_cfi_storeu(cf_t* ptr, simd_cf_t simdreg) { #ifdef LV_HAVE_AVX512 __m512 s1 = _mm512_permutex2var_ps( @@ -774,7 +774,7 @@ static inline void srslte_simd_cfi_storeu(cf_t* ptr, simd_cf_t simdreg) #endif /* LV_HAVE_AVX512 */ } -static inline void srslte_simd_cf_store(float* re, float* im, simd_cf_t simdreg) +static inline void srsran_simd_cf_store(float* re, float* im, simd_cf_t simdreg) { #ifdef LV_HAVE_AVX512 _mm512_store_ps(re, simdreg.re); @@ -797,7 +797,7 @@ static inline void srslte_simd_cf_store(float* re, float* im, simd_cf_t simdreg) #endif /* LV_HAVE_AVX512 */ } -static inline void srslte_simd_cf_storeu(float* re, float* im, simd_cf_t simdreg) +static inline void srsran_simd_cf_storeu(float* re, float* im, simd_cf_t simdreg) { #ifdef LV_HAVE_AVX512 _mm512_storeu_ps(re, simdreg.re); @@ -820,7 +820,7 @@ static inline void srslte_simd_cf_storeu(float* re, float* im, simd_cf_t simdreg #endif /* LV_HAVE_AVX512 */ } -static inline simd_f_t srslte_simd_cf_re(simd_cf_t in) +static inline simd_f_t srsran_simd_cf_re(simd_cf_t in) { #ifdef HAVE_NEON simd_f_t out = in.val[0]; @@ -837,7 +837,7 @@ static inline simd_f_t srslte_simd_cf_re(simd_cf_t in) return out; } -static inline simd_f_t srslte_simd_cf_im(simd_cf_t in) +static inline simd_f_t srsran_simd_cf_im(simd_cf_t in) { #ifdef HAVE_NEON simd_f_t out = in.val[1]; @@ -854,7 +854,7 @@ static inline simd_f_t srslte_simd_cf_im(simd_cf_t in) return out; } -static inline simd_cf_t srslte_simd_cf_set1(cf_t x) +static inline simd_cf_t srsran_simd_cf_set1(cf_t x) { simd_cf_t ret; #ifdef LV_HAVE_AVX512 @@ -879,7 +879,7 @@ static inline simd_cf_t srslte_simd_cf_set1(cf_t x) return ret; } -static inline simd_cf_t srslte_simd_cf_prod(simd_cf_t a, simd_cf_t b) +static inline simd_cf_t srsran_simd_cf_prod(simd_cf_t a, simd_cf_t b) { simd_cf_t ret; #ifdef LV_HAVE_AVX512 @@ -909,7 +909,7 @@ static inline simd_cf_t srslte_simd_cf_prod(simd_cf_t a, simd_cf_t b) return ret; } -static inline simd_cf_t srslte_simd_cf_conjprod(simd_cf_t a, simd_cf_t b) +static inline simd_cf_t srsran_simd_cf_conjprod(simd_cf_t a, simd_cf_t b) { simd_cf_t ret; #ifdef LV_HAVE_AVX512 @@ -934,7 +934,7 @@ static inline simd_cf_t srslte_simd_cf_conjprod(simd_cf_t a, simd_cf_t b) return ret; } -static inline simd_cf_t srslte_simd_cf_add(simd_cf_t a, simd_cf_t b) +static inline simd_cf_t srsran_simd_cf_add(simd_cf_t a, simd_cf_t b) { simd_cf_t ret; #ifdef LV_HAVE_AVX512 @@ -959,7 +959,7 @@ static inline simd_cf_t srslte_simd_cf_add(simd_cf_t a, simd_cf_t b) return ret; } -static inline simd_cf_t srslte_simd_cf_sub(simd_cf_t a, simd_cf_t b) +static inline simd_cf_t srsran_simd_cf_sub(simd_cf_t a, simd_cf_t b) { simd_cf_t ret; #ifdef LV_HAVE_AVX512 @@ -984,7 +984,7 @@ static inline simd_cf_t srslte_simd_cf_sub(simd_cf_t a, simd_cf_t b) return ret; } -static inline simd_cf_t srslte_simd_cf_mul(simd_cf_t a, simd_f_t b) +static inline simd_cf_t srsran_simd_cf_mul(simd_cf_t a, simd_f_t b) { simd_cf_t ret; #ifdef LV_HAVE_AVX512 @@ -1010,7 +1010,7 @@ static inline simd_cf_t srslte_simd_cf_mul(simd_cf_t a, simd_f_t b) return ret; } -static inline simd_cf_t srslte_simd_cf_rcp(simd_cf_t a) +static inline simd_cf_t srsran_simd_cf_rcp(simd_cf_t a) { simd_cf_t ret; #ifdef LV_HAVE_AVX512 @@ -1055,20 +1055,20 @@ static inline simd_cf_t srslte_simd_cf_rcp(simd_cf_t a) return ret; } -static inline simd_cf_t srslte_simd_cf_neg(simd_cf_t a) +static inline simd_cf_t srsran_simd_cf_neg(simd_cf_t a) { simd_cf_t ret; #if HAVE_NEON - ret.val[0] = srslte_simd_f_neg(a.val[0]); - ret.val[1] = srslte_simd_f_neg(a.val[1]); + ret.val[0] = srsran_simd_f_neg(a.val[0]); + ret.val[1] = srsran_simd_f_neg(a.val[1]); #else /* HAVE_NEON */ - ret.re = srslte_simd_f_neg(a.re); - ret.im = srslte_simd_f_neg(a.im); + ret.re = srsran_simd_f_neg(a.re); + ret.im = srsran_simd_f_neg(a.im); #endif /* HAVE_NEON */ return ret; } -static inline simd_cf_t srslte_simd_cf_neg_mask(simd_cf_t a, simd_f_t mask) +static inline simd_cf_t srsran_simd_cf_neg_mask(simd_cf_t a, simd_f_t mask) { simd_cf_t ret; #ifndef LV_HAVE_AVX512 @@ -1077,42 +1077,42 @@ static inline simd_cf_t srslte_simd_cf_neg_mask(simd_cf_t a, simd_f_t mask) #endif /* LV_HAVE_AVX2 */ #endif /* LV_HAVE_AVX512 */ #if HAVE_NEON - ret.val[0] = srslte_simd_f_neg_mask(a.val[0], mask); - ret.val[1] = srslte_simd_f_neg_mask(a.val[1], mask); + ret.val[0] = srsran_simd_f_neg_mask(a.val[0], mask); + ret.val[1] = srsran_simd_f_neg_mask(a.val[1], mask); #else /* HAVE_NEON */ - ret.re = srslte_simd_f_neg_mask(a.re, mask); - ret.im = srslte_simd_f_neg_mask(a.im, mask); + ret.re = srsran_simd_f_neg_mask(a.re, mask); + ret.im = srsran_simd_f_neg_mask(a.im, mask); #endif /* HAVE_NEON */ return ret; } -static inline simd_cf_t srslte_simd_cf_conj(simd_cf_t a) +static inline simd_cf_t srsran_simd_cf_conj(simd_cf_t a) { simd_cf_t ret; #if HAVE_NEON ret.val[0] = a.val[0]; - ret.val[1] = srslte_simd_f_neg(a.val[1]); + ret.val[1] = srsran_simd_f_neg(a.val[1]); #else /* HAVE_NEON */ ret.re = a.re; - ret.im = srslte_simd_f_neg(a.im); + ret.im = srsran_simd_f_neg(a.im); #endif /* HAVE_NEON */ return ret; } -static inline simd_cf_t srslte_simd_cf_mulj(simd_cf_t a) +static inline simd_cf_t srsran_simd_cf_mulj(simd_cf_t a) { simd_cf_t ret; #if HAVE_NEON - ret.val[0] = srslte_simd_f_neg(a.val[1]); + ret.val[0] = srsran_simd_f_neg(a.val[1]); ret.val[1] = a.val[0]; #else /* HAVE_NEON */ - ret.re = srslte_simd_f_neg(a.im); + ret.re = srsran_simd_f_neg(a.im); ret.im = a.re; #endif /* HAVE_NEON */ return ret; } -static inline simd_cf_t srslte_simd_cf_zero(void) +static inline simd_cf_t srsran_simd_cf_zero(void) { simd_cf_t ret; #ifdef LV_HAVE_AVX512 @@ -1137,22 +1137,22 @@ static inline simd_cf_t srslte_simd_cf_zero(void) return ret; } -static inline void srslte_simd_cf_fprintf(FILE* stream, simd_cf_t a) +static inline void srsran_simd_cf_fprintf(FILE* stream, simd_cf_t a) { - cf_t x[SRSLTE_SIMD_CF_SIZE]; + cf_t x[SRSRAN_SIMD_CF_SIZE]; - srslte_simd_cfi_storeu(x, a); + srsran_simd_cfi_storeu(x, a); fprintf(stream, "["); - for (int i = 0; i < SRSLTE_SIMD_CF_SIZE; i++) { + for (int i = 0; i < SRSRAN_SIMD_CF_SIZE; i++) { fprintf(stream, "%+2.5f%+2.5fi, ", __real__ x[i], __imag__ x[i]); } fprintf(stream, "];\n"); } -#endif /* SRSLTE_SIMD_CF_SIZE */ +#endif /* SRSRAN_SIMD_CF_SIZE */ -#if SRSLTE_SIMD_I_SIZE +#if SRSRAN_SIMD_I_SIZE #ifdef LV_HAVE_AVX512 typedef __m512i simd_i_t; @@ -1174,7 +1174,7 @@ typedef int32x4_t simd_sel_t; #endif /* LV_HAVE_AVX2 */ #endif /* LV_HAVE_AVX512 */ -static inline simd_i_t srslte_simd_i_load(int* x) +static inline simd_i_t srsran_simd_i_load(int* x) { #ifdef LV_HAVE_AVX512 return _mm512_load_epi32((__m512i*)x); @@ -1193,7 +1193,7 @@ static inline simd_i_t srslte_simd_i_load(int* x) #endif /* LV_HAVE_AVX512 */ } -static inline void srslte_simd_i_store(int* x, simd_i_t reg) +static inline void srsran_simd_i_store(int* x, simd_i_t reg) { #ifdef LV_HAVE_AVX512 _mm512_store_epi32((__m512i*)x, reg); @@ -1212,7 +1212,7 @@ static inline void srslte_simd_i_store(int* x, simd_i_t reg) #endif /* LV_HAVE_AVX512 */ } -static inline simd_i_t srslte_simd_i_set1(int x) +static inline simd_i_t srsran_simd_i_set1(int x) { #ifdef LV_HAVE_AVX512 return _mm512_set1_epi32(x); @@ -1231,7 +1231,7 @@ static inline simd_i_t srslte_simd_i_set1(int x) #endif /* LV_HAVE_AVX512 */ } -static inline simd_i_t srslte_simd_i_add(simd_i_t a, simd_i_t b) +static inline simd_i_t srsran_simd_i_add(simd_i_t a, simd_i_t b) { #ifdef LV_HAVE_AVX512 return _mm512_add_epi32(a, b); @@ -1250,7 +1250,7 @@ static inline simd_i_t srslte_simd_i_add(simd_i_t a, simd_i_t b) #endif /* LV_HAVE_AVX512 */ } -static inline simd_i_t srslte_simd_i_mul(simd_i_t a, simd_i_t b) +static inline simd_i_t srsran_simd_i_mul(simd_i_t a, simd_i_t b) { #ifdef LV_HAVE_AVX512 return _mm512_mullo_epi32(a, b); @@ -1269,7 +1269,7 @@ static inline simd_i_t srslte_simd_i_mul(simd_i_t a, simd_i_t b) #endif /* LV_HAVE_AVX512 */ } -static inline simd_i_t srslte_simd_i_and(simd_i_t a, simd_i_t b) +static inline simd_i_t srsran_simd_i_and(simd_i_t a, simd_i_t b) { #ifdef LV_HAVE_AVX512 return _mm512_and_si512(a, b); @@ -1288,7 +1288,7 @@ static inline simd_i_t srslte_simd_i_and(simd_i_t a, simd_i_t b) #endif /* LV_HAVE_AVX512 */ } -static inline simd_sel_t srslte_simd_f_max(simd_f_t a, simd_f_t b) +static inline simd_sel_t srsran_simd_f_max(simd_f_t a, simd_f_t b) { #ifdef LV_HAVE_AVX512 return _mm512_cmp_ps_mask(a, b, _CMP_GT_OS); @@ -1307,7 +1307,7 @@ static inline simd_sel_t srslte_simd_f_max(simd_f_t a, simd_f_t b) #endif /* LV_HAVE_AVX512 */ } -static inline simd_sel_t srslte_simd_f_min(simd_f_t a, simd_f_t b) +static inline simd_sel_t srsran_simd_f_min(simd_f_t a, simd_f_t b) { #ifdef LV_HAVE_AVX512 return _mm512_cmp_ps_mask(a, b, _CMP_LT_OS); @@ -1326,7 +1326,7 @@ static inline simd_sel_t srslte_simd_f_min(simd_f_t a, simd_f_t b) #endif /* LV_HAVE_AVX512 */ } -static inline simd_f_t srslte_simd_f_select(simd_f_t a, simd_f_t b, simd_sel_t selector) +static inline simd_f_t srsran_simd_f_select(simd_f_t a, simd_f_t b, simd_sel_t selector) { #ifdef LV_HAVE_AVX512 return _mm512_mask_blend_ps(selector, (__m512)a, (__m512)b); @@ -1357,7 +1357,7 @@ static inline simd_f_t srslte_simd_f_select(simd_f_t a, simd_f_t b, simd_sel_t s #endif /* LV_HAVE_AVX512 */ } -static inline simd_i_t srslte_simd_i_select(simd_i_t a, simd_i_t b, simd_sel_t selector) +static inline simd_i_t srsran_simd_i_select(simd_i_t a, simd_i_t b, simd_sel_t selector) { #ifdef LV_HAVE_AVX512 return (__m512i)_mm512_mask_blend_ps(selector, (__m512)a, (__m512)b); @@ -1388,9 +1388,9 @@ static inline simd_i_t srslte_simd_i_select(simd_i_t a, simd_i_t b, simd_sel_t s #endif /* LV_HAVE_AVX512 */ } -#endif /* SRSLTE_SIMD_I_SIZE*/ +#endif /* SRSRAN_SIMD_I_SIZE*/ -#if SRSLTE_SIMD_S_SIZE +#if SRSRAN_SIMD_S_SIZE #ifdef LV_HAVE_AVX512 typedef __m512i simd_s_t; @@ -1408,7 +1408,7 @@ typedef int16x8_t simd_s_t; #endif /* LV_HAVE_AVX2 */ #endif /* LV_HAVE_AVX512 */ -static inline simd_s_t srslte_simd_s_load(const int16_t* ptr) +static inline simd_s_t srsran_simd_s_load(const int16_t* ptr) { #ifdef LV_HAVE_AVX512 return _mm512_load_si512(ptr); @@ -1427,7 +1427,7 @@ static inline simd_s_t srslte_simd_s_load(const int16_t* ptr) #endif /* LV_HAVE_AVX512 */ } -static inline simd_s_t srslte_simd_s_loadu(const int16_t* ptr) +static inline simd_s_t srsran_simd_s_loadu(const int16_t* ptr) { #ifdef LV_HAVE_AVX512 return _mm512_loadu_si512(ptr); @@ -1446,7 +1446,7 @@ static inline simd_s_t srslte_simd_s_loadu(const int16_t* ptr) #endif /* LV_HAVE_AVX512 */ } -static inline void srslte_simd_s_store(int16_t* ptr, simd_s_t simdreg) +static inline void srsran_simd_s_store(int16_t* ptr, simd_s_t simdreg) { #ifdef LV_HAVE_AVX512 _mm512_store_si512(ptr, simdreg); @@ -1465,7 +1465,7 @@ static inline void srslte_simd_s_store(int16_t* ptr, simd_s_t simdreg) #endif /* LV_HAVE_AVX512 */ } -static inline void srslte_simd_s_storeu(int16_t* ptr, simd_s_t simdreg) +static inline void srsran_simd_s_storeu(int16_t* ptr, simd_s_t simdreg) { #ifdef LV_HAVE_AVX512 _mm512_storeu_si512(ptr, simdreg); @@ -1483,7 +1483,7 @@ static inline void srslte_simd_s_storeu(int16_t* ptr, simd_s_t simdreg) #endif /* LV_HAVE_AVX2 */ #endif /* LV_HAVE_AVX512 */ } -static inline simd_s_t srslte_simd_s_zero(void) +static inline simd_s_t srsran_simd_s_zero(void) { #ifdef LV_HAVE_AVX512 return _mm512_setzero_si512(); @@ -1502,7 +1502,7 @@ static inline simd_s_t srslte_simd_s_zero(void) #endif /* LV_HAVE_AVX512 */ } -static inline simd_s_t srslte_simd_s_mul(simd_s_t a, simd_s_t b) +static inline simd_s_t srsran_simd_s_mul(simd_s_t a, simd_s_t b) { #ifdef LV_HAVE_AVX512 return _mm512_mullo_epi16(a, b); @@ -1521,7 +1521,7 @@ static inline simd_s_t srslte_simd_s_mul(simd_s_t a, simd_s_t b) #endif /* LV_HAVE_AVX512 */ } -static inline simd_s_t srslte_simd_s_neg(simd_s_t a, simd_s_t b) +static inline simd_s_t srsran_simd_s_neg(simd_s_t a, simd_s_t b) { #ifdef LV_HAVE_AVX512 __m256i a0 = _mm512_extracti64x4_epi64(a, 0); @@ -1561,7 +1561,7 @@ static inline simd_s_t srslte_simd_s_neg(simd_s_t a, simd_s_t b) #endif /* LV_HAVE_AVX512 */ } -static inline simd_s_t srslte_simd_s_add(simd_s_t a, simd_s_t b) +static inline simd_s_t srsran_simd_s_add(simd_s_t a, simd_s_t b) { #ifdef LV_HAVE_AVX512 return _mm512_add_epi16(a, b); @@ -1580,7 +1580,7 @@ static inline simd_s_t srslte_simd_s_add(simd_s_t a, simd_s_t b) #endif /* LV_HAVE_AVX512 */ } -static inline simd_s_t srslte_simd_s_sub(simd_s_t a, simd_s_t b) +static inline simd_s_t srsran_simd_s_sub(simd_s_t a, simd_s_t b) { #ifdef LV_HAVE_AVX512 return _mm512_sub_epi16(a, b); @@ -1599,9 +1599,9 @@ static inline simd_s_t srslte_simd_s_sub(simd_s_t a, simd_s_t b) #endif /* LV_HAVE_AVX512 */ } -#endif /* SRSLTE_SIMD_S_SIZE */ +#endif /* SRSRAN_SIMD_S_SIZE */ -#if SRSLTE_SIMD_C16_SIZE +#if SRSRAN_SIMD_C16_SIZE typedef #ifdef LV_HAVE_AVX512 @@ -1648,7 +1648,7 @@ typedef } simd_c16_t; /* Fixed point precision (16-bit) functions */ -static inline simd_c16_t srslte_simd_c16i_load(const c16_t* ptr) +static inline simd_c16_t srsran_simd_c16i_load(const c16_t* ptr) { simd_c16_t ret; #ifdef LV_HAVE_AVX512 @@ -1682,7 +1682,7 @@ static inline simd_c16_t srslte_simd_c16i_load(const c16_t* ptr) return ret; } -static inline simd_c16_t srslte_simd_c16_load(const int16_t* re, const int16_t* im) +static inline simd_c16_t srsran_simd_c16_load(const int16_t* re, const int16_t* im) { simd_c16_t ret; #ifdef LV_HAVE_AVX2 @@ -1702,7 +1702,7 @@ static inline simd_c16_t srslte_simd_c16_load(const int16_t* re, const int16_t* return ret; } -static inline simd_c16_t srslte_simd_c16_loadu(const int16_t* re, const int16_t* im) +static inline simd_c16_t srsran_simd_c16_loadu(const int16_t* re, const int16_t* im) { simd_c16_t ret; #ifdef LV_HAVE_AVX2 @@ -1722,7 +1722,7 @@ static inline simd_c16_t srslte_simd_c16_loadu(const int16_t* re, const int16_t* return ret; } -static inline void srslte_simd_c16i_store(c16_t* ptr, simd_c16_t simdreg) +static inline void srsran_simd_c16i_store(c16_t* ptr, simd_c16_t simdreg) { #ifdef LV_HAVE_AVX2 __m256i re_sw = _mm256_shufflelo_epi16(_mm256_shufflehi_epi16(simdreg.re.m256, 0b10110001), 0b10110001); @@ -1743,7 +1743,7 @@ static inline void srslte_simd_c16i_store(c16_t* ptr, simd_c16_t simdreg) #endif /* LV_HAVE_AVX2 */ } -static inline void srslte_simd_c16i_storeu(c16_t* ptr, simd_c16_t simdreg) +static inline void srsran_simd_c16i_storeu(c16_t* ptr, simd_c16_t simdreg) { #ifdef LV_HAVE_AVX2 __m256i re_sw = _mm256_shufflelo_epi16(_mm256_shufflehi_epi16(simdreg.re.m256, 0b10110001), 0b10110001); @@ -1764,7 +1764,7 @@ static inline void srslte_simd_c16i_storeu(c16_t* ptr, simd_c16_t simdreg) #endif /* LV_HAVE_AVX2 */ } -static inline void srslte_simd_c16_store(int16_t* re, int16_t* im, simd_c16_t simdreg) +static inline void srsran_simd_c16_store(int16_t* re, int16_t* im, simd_c16_t simdreg) { #ifdef LV_HAVE_AVX2 _mm256_store_si256((__m256i*)re, simdreg.re.m256); @@ -1782,7 +1782,7 @@ static inline void srslte_simd_c16_store(int16_t* re, int16_t* im, simd_c16_t si #endif /* LV_HAVE_AVX2 */ } -static inline void srslte_simd_c16_storeu(int16_t* re, int16_t* im, simd_c16_t simdreg) +static inline void srsran_simd_c16_storeu(int16_t* re, int16_t* im, simd_c16_t simdreg) { #ifdef LV_HAVE_AVX2 _mm256_storeu_si256((__m256i*)re, simdreg.re.m256); @@ -1800,7 +1800,7 @@ static inline void srslte_simd_c16_storeu(int16_t* re, int16_t* im, simd_c16_t s #endif /* LV_HAVE_AVX2 */ } -static inline simd_c16_t srslte_simd_c16_prod(simd_c16_t a, simd_c16_t b) +static inline simd_c16_t srsran_simd_c16_prod(simd_c16_t a, simd_c16_t b) { simd_c16_t ret; #ifdef LV_HAVE_AVX2 @@ -1819,7 +1819,7 @@ static inline simd_c16_t srslte_simd_c16_prod(simd_c16_t a, simd_c16_t b) return ret; } -static inline simd_c16_t srslte_simd_c16_add(simd_c16_t a, simd_c16_t b) +static inline simd_c16_t srsran_simd_c16_add(simd_c16_t a, simd_c16_t b) { simd_c16_t ret; #ifdef LV_HAVE_AVX2 @@ -1839,7 +1839,7 @@ static inline simd_c16_t srslte_simd_c16_add(simd_c16_t a, simd_c16_t b) return ret; } -static inline simd_c16_t srslte_simd_c16_zero(void) +static inline simd_c16_t srsran_simd_c16_zero(void) { simd_c16_t ret; #ifdef LV_HAVE_AVX2 @@ -1859,11 +1859,11 @@ static inline simd_c16_t srslte_simd_c16_zero(void) return ret; } -#endif /* SRSLTE_SIMD_C16_SIZE */ +#endif /* SRSRAN_SIMD_C16_SIZE */ -#if SRSLTE_SIMD_F_SIZE && SRSLTE_SIMD_S_SIZE +#if SRSRAN_SIMD_F_SIZE && SRSRAN_SIMD_S_SIZE -static inline simd_s_t srslte_simd_convert_2f_s(simd_f_t a, simd_f_t b) +static inline simd_s_t srsran_simd_convert_2f_s(simd_f_t a, simd_f_t b) { #ifdef LV_HAVE_AVX512 __m512 aa = _mm512_permutex2var_ps( @@ -1900,9 +1900,9 @@ static inline simd_s_t srslte_simd_convert_2f_s(simd_f_t a, simd_f_t b) #endif /* LV_HAVE_AVX512 */ } -#endif /* SRSLTE_SIMD_F_SIZE && SRSLTE_SIMD_C16_SIZE */ +#endif /* SRSRAN_SIMD_F_SIZE && SRSRAN_SIMD_C16_SIZE */ -#if SRSLTE_SIMD_B_SIZE +#if SRSRAN_SIMD_B_SIZE /* Data types */ #ifdef LV_HAVE_AVX512 typedef __m512i simd_b_t; @@ -1920,7 +1920,7 @@ typedef int8x16_t simd_b_t; #endif /* LV_HAVE_AVX2 */ #endif /* LV_HAVE_AVX512 */ -static inline simd_b_t srslte_simd_b_load(const int8_t* ptr) +static inline simd_b_t srsran_simd_b_load(const int8_t* ptr) { #ifdef LV_HAVE_AVX512 return _mm512_load_si512(ptr); @@ -1939,7 +1939,7 @@ static inline simd_b_t srslte_simd_b_load(const int8_t* ptr) #endif /* LV_HAVE_AVX512 */ } -static inline simd_b_t srslte_simd_b_loadu(const int8_t* ptr) +static inline simd_b_t srsran_simd_b_loadu(const int8_t* ptr) { #ifdef LV_HAVE_AVX512 return _mm512_loadu_si512(ptr); @@ -1958,7 +1958,7 @@ static inline simd_b_t srslte_simd_b_loadu(const int8_t* ptr) #endif /* LV_HAVE_AVX512 */ } -static inline void srslte_simd_b_store(int8_t* ptr, simd_b_t simdreg) +static inline void srsran_simd_b_store(int8_t* ptr, simd_b_t simdreg) { #ifdef LV_HAVE_AVX512 _mm512_store_si512(ptr, simdreg); @@ -1977,7 +1977,7 @@ static inline void srslte_simd_b_store(int8_t* ptr, simd_b_t simdreg) #endif /* LV_HAVE_AVX512 */ } -static inline void srslte_simd_b_storeu(int8_t* ptr, simd_b_t simdreg) +static inline void srsran_simd_b_storeu(int8_t* ptr, simd_b_t simdreg) { #ifdef LV_HAVE_AVX512 _mm512_storeu_si512(ptr, simdreg); @@ -1996,7 +1996,7 @@ static inline void srslte_simd_b_storeu(int8_t* ptr, simd_b_t simdreg) #endif /* LV_HAVE_AVX512 */ } -static inline simd_b_t srslte_simd_b_xor(simd_b_t a, simd_b_t b) +static inline simd_b_t srsran_simd_b_xor(simd_b_t a, simd_b_t b) { #ifdef LV_HAVE_AVX512 @@ -2016,7 +2016,7 @@ static inline simd_b_t srslte_simd_b_xor(simd_b_t a, simd_b_t b) #endif /* LV_HAVE_AVX512 */ } -static inline simd_b_t srslte_simd_b_sub(simd_b_t a, simd_b_t b) +static inline simd_b_t srsran_simd_b_sub(simd_b_t a, simd_b_t b) { #ifdef LV_HAVE_AVX512 return _mm512_subs_epi8(a, b); @@ -2035,7 +2035,7 @@ static inline simd_b_t srslte_simd_b_sub(simd_b_t a, simd_b_t b) #endif /* LV_HAVE_AVX512 */ } -static inline simd_b_t srslte_simd_b_neg(simd_b_t a, simd_b_t b) +static inline simd_b_t srsran_simd_b_neg(simd_b_t a, simd_b_t b) { #ifdef LV_HAVE_AVX512 __m256i a0 = _mm512_extracti64x4_epi64(a, 0); @@ -2075,6 +2075,6 @@ static inline simd_b_t srslte_simd_b_neg(simd_b_t a, simd_b_t b) #endif /* LV_HAVE_AVX512 */ } -#endif /*SRSLTE_SIMD_B_SIZE */ +#endif /*SRSRAN_SIMD_B_SIZE */ -#endif // SRSLTE_SIMD_H +#endif // SRSRAN_SIMD_H diff --git a/lib/include/srslte/phy/utils/vector.h b/lib/include/srsran/phy/utils/vector.h similarity index 54% rename from lib/include/srslte/phy/utils/vector.h rename to lib/include/srsran/phy/utils/vector.h index bf5276b09..5ea401301 100644 --- a/lib/include/srslte/phy/utils/vector.h +++ b/lib/include/srsran/phy/utils/vector.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -18,58 +18,58 @@ * Reference: *****************************************************************************/ -#ifndef SRSLTE_VECTOR_H -#define SRSLTE_VECTOR_H +#ifndef SRSRAN_VECTOR_H +#define SRSRAN_VECTOR_H #ifdef __cplusplus extern "C" { #endif -#include "srslte/config.h" +#include "srsran/config.h" #include #include #include #include -#define SRSLTE_MEM_ALLOC(T, N) ((T*)srslte_vec_malloc((uint32_t)sizeof(T) * (N))) -#define SRSLTE_MEM_ZERO(Q, T, N) \ +#define SRSRAN_MEM_ALLOC(T, N) ((T*)srsran_vec_malloc((uint32_t)sizeof(T) * (N))) +#define SRSRAN_MEM_ZERO(Q, T, N) \ do { \ T* ptr_ = (Q); \ - srslte_vec_zero((void*)ptr_, (uint32_t)sizeof(T) * (N)); \ + srsran_vec_zero((void*)ptr_, (uint32_t)sizeof(T) * (N)); \ } while (false) -#define SRSLTE_MAX(a, b) ((a) > (b) ? (a) : (b)) -#define SRSLTE_MIN(a, b) ((a) < (b) ? (a) : (b)) -#define SRSLTE_CEIL(NUM, DEN) (((NUM) + ((DEN)-1)) / (DEN)) -#define SRSLTE_FLOOR(NUM, DEN) ((NUM) / (DEN)) -#define SRSLTE_ROUND(NUM, DEN) ((uint32_t)round((double)(NUM) / (double)(DEN))) +#define SRSRAN_MAX(a, b) ((a) > (b) ? (a) : (b)) +#define SRSRAN_MIN(a, b) ((a) < (b) ? (a) : (b)) +#define SRSRAN_CEIL(NUM, DEN) (((NUM) + ((DEN)-1)) / (DEN)) +#define SRSRAN_FLOOR(NUM, DEN) ((NUM) / (DEN)) +#define SRSRAN_ROUND(NUM, DEN) ((uint32_t)round((double)(NUM) / (double)(DEN))) // Cumulative moving average -#define SRSLTE_VEC_CMA(data, average, n) ((average) + ((data) - (average)) / ((n) + 1)) +#define SRSRAN_VEC_CMA(data, average, n) ((average) + ((data) - (average)) / ((n) + 1)) // Proportional moving average -#define SRSLTE_VEC_PMA(average1, n1, average2, n2) (((average1) * (n1) + (average2) * (n2)) / ((n1) + (n2))) +#define SRSRAN_VEC_PMA(average1, n1, average2, n2) (((average1) * (n1) + (average2) * (n2)) / ((n1) + (n2))) // Exponential moving average -#define SRSLTE_VEC_EMA(data, average, alpha) ((alpha) * (data) + (1 - alpha) * (average)) +#define SRSRAN_VEC_EMA(data, average, alpha) ((alpha) * (data) + (1 - alpha) * (average)) -static inline float srslte_convert_amplitude_to_dB(float v) +static inline float srsran_convert_amplitude_to_dB(float v) { return 20.0f * log10f(v); } -static inline float srslte_convert_power_to_dB(float v) +static inline float srsran_convert_power_to_dB(float v) { return 10.0f * log10f(v); } -static inline float srslte_convert_power_to_dBm(float v) +static inline float srsran_convert_power_to_dBm(float v) { - return srslte_convert_power_to_dB(v) + 30.0f; + return srsran_convert_power_to_dB(v) + 30.0f; } -static inline float srslte_convert_dB_to_amplitude(float v) +static inline float srsran_convert_dB_to_amplitude(float v) { return powf(10.0f, v / 20.0f); } -static inline float srslte_convert_dB_to_power(float v) +static inline float srsran_convert_dB_to_power(float v) { return powf(10.0f, v / 10.0f); } @@ -81,86 +81,86 @@ static inline float srslte_convert_dB_to_power(float v) * \param[out] z A pointer to a vector of uint8_t with 0's and 1's. * \param[in] len Length of vectors x, y and z. */ -SRSLTE_API void srslte_vec_xor_bbb(const uint8_t* x, const uint8_t* y, uint8_t* z, const uint32_t len); +SRSRAN_API void srsran_vec_xor_bbb(const uint8_t* x, const uint8_t* y, uint8_t* z, const uint32_t len); /** Return the sum of all the elements */ -SRSLTE_API float srslte_vec_acc_ff(const float* x, const uint32_t len); -SRSLTE_API cf_t srslte_vec_acc_cc(const cf_t* x, const uint32_t len); +SRSRAN_API float srsran_vec_acc_ff(const float* x, const uint32_t len); +SRSRAN_API cf_t srsran_vec_acc_cc(const cf_t* x, const uint32_t len); -SRSLTE_API void* srslte_vec_malloc(uint32_t size); -SRSLTE_API cf_t* srslte_vec_cf_malloc(uint32_t size); -SRSLTE_API float* srslte_vec_f_malloc(uint32_t size); -SRSLTE_API int32_t* srslte_vec_i32_malloc(uint32_t nsamples); -SRSLTE_API uint32_t* srslte_vec_u32_malloc(uint32_t nsamples); -SRSLTE_API int16_t* srslte_vec_i16_malloc(uint32_t nsamples); -SRSLTE_API uint16_t* srslte_vec_u16_malloc(uint32_t nsamples); -SRSLTE_API int8_t* srslte_vec_i8_malloc(uint32_t nsamples); -SRSLTE_API uint8_t* srslte_vec_u8_malloc(uint32_t nsamples); +SRSRAN_API void* srsran_vec_malloc(uint32_t size); +SRSRAN_API cf_t* srsran_vec_cf_malloc(uint32_t size); +SRSRAN_API float* srsran_vec_f_malloc(uint32_t size); +SRSRAN_API int32_t* srsran_vec_i32_malloc(uint32_t nsamples); +SRSRAN_API uint32_t* srsran_vec_u32_malloc(uint32_t nsamples); +SRSRAN_API int16_t* srsran_vec_i16_malloc(uint32_t nsamples); +SRSRAN_API uint16_t* srsran_vec_u16_malloc(uint32_t nsamples); +SRSRAN_API int8_t* srsran_vec_i8_malloc(uint32_t nsamples); +SRSRAN_API uint8_t* srsran_vec_u8_malloc(uint32_t nsamples); -SRSLTE_API void* srslte_vec_realloc(void* ptr, uint32_t old_size, uint32_t new_size); +SRSRAN_API void* srsran_vec_realloc(void* ptr, uint32_t old_size, uint32_t new_size); /* Zero memory */ -SRSLTE_API void srslte_vec_zero(void* ptr, uint32_t nsamples); -SRSLTE_API void srslte_vec_cf_zero(cf_t* ptr, uint32_t nsamples); -SRSLTE_API void srslte_vec_f_zero(float* ptr, uint32_t nsamples); -SRSLTE_API void srslte_vec_i8_zero(int8_t* ptr, uint32_t nsamples); -SRSLTE_API void srslte_vec_u8_zero(uint8_t* ptr, uint32_t nsamples); -SRSLTE_API void srslte_vec_i16_zero(int16_t* ptr, uint32_t nsamples); -SRSLTE_API void srslte_vec_u32_zero(uint32_t* ptr, uint32_t nsamples); +SRSRAN_API void srsran_vec_zero(void* ptr, uint32_t nsamples); +SRSRAN_API void srsran_vec_cf_zero(cf_t* ptr, uint32_t nsamples); +SRSRAN_API void srsran_vec_f_zero(float* ptr, uint32_t nsamples); +SRSRAN_API void srsran_vec_i8_zero(int8_t* ptr, uint32_t nsamples); +SRSRAN_API void srsran_vec_u8_zero(uint8_t* ptr, uint32_t nsamples); +SRSRAN_API void srsran_vec_i16_zero(int16_t* ptr, uint32_t nsamples); +SRSRAN_API void srsran_vec_u32_zero(uint32_t* ptr, uint32_t nsamples); /* Copy memory */ -SRSLTE_API void srslte_vec_cf_copy(cf_t* dst, const cf_t* src, uint32_t len); -SRSLTE_API void srslte_vec_f_copy(float* dst, const float* src, uint32_t len); -SRSLTE_API void srslte_vec_u8_copy(uint8_t* dst, const uint8_t* src, uint32_t len); -SRSLTE_API void srslte_vec_i8_copy(int8_t* dst, const int8_t* src, uint32_t len); -SRSLTE_API void srslte_vec_u16_copy(uint16_t* dst, const uint16_t* src, uint32_t len); -SRSLTE_API void srslte_vec_i16_copy(int16_t* dst, const int16_t* src, uint32_t len); +SRSRAN_API void srsran_vec_cf_copy(cf_t* dst, const cf_t* src, uint32_t len); +SRSRAN_API void srsran_vec_f_copy(float* dst, const float* src, uint32_t len); +SRSRAN_API void srsran_vec_u8_copy(uint8_t* dst, const uint8_t* src, uint32_t len); +SRSRAN_API void srsran_vec_i8_copy(int8_t* dst, const int8_t* src, uint32_t len); +SRSRAN_API void srsran_vec_u16_copy(uint16_t* dst, const uint16_t* src, uint32_t len); +SRSRAN_API void srsran_vec_i16_copy(int16_t* dst, const int16_t* src, uint32_t len); /* print vectors */ -SRSLTE_API void srslte_vec_fprint_c(FILE* stream, const cf_t* x, const uint32_t len); -SRSLTE_API void srslte_vec_fprint_f(FILE* stream, const float* x, const uint32_t len); -SRSLTE_API void srslte_vec_fprint_b(FILE* stream, const uint8_t* x, const uint32_t len); -SRSLTE_API void srslte_vec_fprint_bs(FILE* stream, const int8_t* x, const uint32_t len); -SRSLTE_API void srslte_vec_fprint_byte(FILE* stream, const uint8_t* x, const uint32_t len); -SRSLTE_API void srslte_vec_fprint_i(FILE* stream, const int* x, const uint32_t len); -SRSLTE_API void srslte_vec_fprint_s(FILE* stream, const int16_t* x, const uint32_t len); -SRSLTE_API void srslte_vec_fprint_hex(FILE* stream, uint8_t* x, const uint32_t len); -SRSLTE_API void srslte_vec_sprint_hex(char* str, const uint32_t max_str_len, uint8_t* x, const uint32_t len); -SRSLTE_API void srslte_vec_sprint_bin(char* str, const uint32_t max_str_len, const uint8_t* x, const uint32_t len); +SRSRAN_API void srsran_vec_fprint_c(FILE* stream, const cf_t* x, const uint32_t len); +SRSRAN_API void srsran_vec_fprint_f(FILE* stream, const float* x, const uint32_t len); +SRSRAN_API void srsran_vec_fprint_b(FILE* stream, const uint8_t* x, const uint32_t len); +SRSRAN_API void srsran_vec_fprint_bs(FILE* stream, const int8_t* x, const uint32_t len); +SRSRAN_API void srsran_vec_fprint_byte(FILE* stream, const uint8_t* x, const uint32_t len); +SRSRAN_API void srsran_vec_fprint_i(FILE* stream, const int* x, const uint32_t len); +SRSRAN_API void srsran_vec_fprint_s(FILE* stream, const int16_t* x, const uint32_t len); +SRSRAN_API void srsran_vec_fprint_hex(FILE* stream, uint8_t* x, const uint32_t len); +SRSRAN_API void srsran_vec_sprint_hex(char* str, const uint32_t max_str_len, uint8_t* x, const uint32_t len); +SRSRAN_API void srsran_vec_sprint_bin(char* str, const uint32_t max_str_len, const uint8_t* x, const uint32_t len); /* Saves/loads a vector to a file */ -SRSLTE_API void srslte_vec_save_file(char* filename, const void* buffer, const uint32_t len); -SRSLTE_API void srslte_vec_load_file(char* filename, void* buffer, const uint32_t len); +SRSRAN_API void srsran_vec_save_file(char* filename, const void* buffer, const uint32_t len); +SRSRAN_API void srsran_vec_load_file(char* filename, void* buffer, const uint32_t len); /* sum two vectors */ -SRSLTE_API void srslte_vec_sum_fff(const float* x, const float* y, float* z, const uint32_t len); -SRSLTE_API void srslte_vec_sum_ccc(const cf_t* x, const cf_t* y, cf_t* z, const uint32_t len); -SRSLTE_API void srslte_vec_sum_sss(const int16_t* x, const int16_t* y, int16_t* z, const uint32_t len); +SRSRAN_API void srsran_vec_sum_fff(const float* x, const float* y, float* z, const uint32_t len); +SRSRAN_API void srsran_vec_sum_ccc(const cf_t* x, const cf_t* y, cf_t* z, const uint32_t len); +SRSRAN_API void srsran_vec_sum_sss(const int16_t* x, const int16_t* y, int16_t* z, const uint32_t len); /* substract two vectors z=x-y */ -SRSLTE_API void srslte_vec_sub_fff(const float* x, const float* y, float* z, const uint32_t len); -SRSLTE_API void srslte_vec_sub_ccc(const cf_t* x, const cf_t* y, cf_t* z, const uint32_t len); -SRSLTE_API void srslte_vec_sub_sss(const int16_t* x, const int16_t* y, int16_t* z, const uint32_t len); -SRSLTE_API void srslte_vec_sub_bbb(const int8_t* x, const int8_t* y, int8_t* z, const uint32_t len); +SRSRAN_API void srsran_vec_sub_fff(const float* x, const float* y, float* z, const uint32_t len); +SRSRAN_API void srsran_vec_sub_ccc(const cf_t* x, const cf_t* y, cf_t* z, const uint32_t len); +SRSRAN_API void srsran_vec_sub_sss(const int16_t* x, const int16_t* y, int16_t* z, const uint32_t len); +SRSRAN_API void srsran_vec_sub_bbb(const int8_t* x, const int8_t* y, int8_t* z, const uint32_t len); /* scalar product */ -SRSLTE_API void srslte_vec_sc_prod_cfc(const cf_t* x, const float h, cf_t* z, const uint32_t len); -SRSLTE_API void srslte_vec_sc_prod_fcc(const float* x, const cf_t h, cf_t* z, const uint32_t len); -SRSLTE_API void srslte_vec_sc_prod_ccc(const cf_t* x, const cf_t h, cf_t* z, const uint32_t len); -SRSLTE_API void srslte_vec_sc_prod_fff(const float* x, const float h, float* z, const uint32_t len); +SRSRAN_API void srsran_vec_sc_prod_cfc(const cf_t* x, const float h, cf_t* z, const uint32_t len); +SRSRAN_API void srsran_vec_sc_prod_fcc(const float* x, const cf_t h, cf_t* z, const uint32_t len); +SRSRAN_API void srsran_vec_sc_prod_ccc(const cf_t* x, const cf_t h, cf_t* z, const uint32_t len); +SRSRAN_API void srsran_vec_sc_prod_fff(const float* x, const float h, float* z, const uint32_t len); -SRSLTE_API void srslte_vec_convert_fi(const float* x, const float scale, int16_t* z, const uint32_t len); -SRSLTE_API void srslte_vec_convert_conj_cs(const cf_t* x, const float scale, int16_t* z, const uint32_t len); -SRSLTE_API void srslte_vec_convert_if(const int16_t* x, const float scale, float* z, const uint32_t len); -SRSLTE_API void srslte_vec_convert_fb(const float* x, const float scale, int8_t* z, const uint32_t len); +SRSRAN_API void srsran_vec_convert_fi(const float* x, const float scale, int16_t* z, const uint32_t len); +SRSRAN_API void srsran_vec_convert_conj_cs(const cf_t* x, const float scale, int16_t* z, const uint32_t len); +SRSRAN_API void srsran_vec_convert_if(const int16_t* x, const float scale, float* z, const uint32_t len); +SRSRAN_API void srsran_vec_convert_fb(const float* x, const float scale, int8_t* z, const uint32_t len); -SRSLTE_API void srslte_vec_lut_sss(const short* x, const unsigned short* lut, short* y, const uint32_t len); -SRSLTE_API void srslte_vec_lut_bbb(const int8_t* x, const unsigned short* lut, int8_t* y, const uint32_t len); -SRSLTE_API void srslte_vec_lut_sis(const short* x, const unsigned int* lut, short* y, const uint32_t len); +SRSRAN_API void srsran_vec_lut_sss(const short* x, const unsigned short* lut, short* y, const uint32_t len); +SRSRAN_API void srsran_vec_lut_bbb(const int8_t* x, const unsigned short* lut, int8_t* y, const uint32_t len); +SRSRAN_API void srsran_vec_lut_sis(const short* x, const unsigned int* lut, short* y, const uint32_t len); /* vector product (element-wise) */ -SRSLTE_API void srslte_vec_prod_ccc(const cf_t* x, const cf_t* y, cf_t* z, const uint32_t len); -SRSLTE_API void srslte_vec_prod_ccc_split(const float* x_re, +SRSRAN_API void srsran_vec_prod_ccc(const cf_t* x, const cf_t* y, cf_t* z, const uint32_t len); +SRSRAN_API void srsran_vec_prod_ccc_split(const float* x_re, const float* x_im, const float* y_re, const float* y_im, @@ -169,46 +169,46 @@ SRSLTE_API void srslte_vec_prod_ccc_split(const float* x_re, const uint32_t len); /* vector product (element-wise) */ -SRSLTE_API void srslte_vec_prod_cfc(const cf_t* x, const float* y, cf_t* z, const uint32_t len); +SRSRAN_API void srsran_vec_prod_cfc(const cf_t* x, const float* y, cf_t* z, const uint32_t len); /* conjugate vector product (element-wise) */ -SRSLTE_API void srslte_vec_prod_conj_ccc(const cf_t* x, const cf_t* y, cf_t* z, const uint32_t len); +SRSRAN_API void srsran_vec_prod_conj_ccc(const cf_t* x, const cf_t* y, cf_t* z, const uint32_t len); /* real vector product (element-wise) */ -SRSLTE_API void srslte_vec_prod_fff(const float* x, const float* y, float* z, const uint32_t len); -SRSLTE_API void srslte_vec_prod_sss(const int16_t* x, const int16_t* y, int16_t* z, const uint32_t len); +SRSRAN_API void srsran_vec_prod_fff(const float* x, const float* y, float* z, const uint32_t len); +SRSRAN_API void srsran_vec_prod_sss(const int16_t* x, const int16_t* y, int16_t* z, const uint32_t len); // Negate sign (scrambling) -SRSLTE_API void srslte_vec_neg_sss(const int16_t* x, const int16_t* y, int16_t* z, const uint32_t len); -SRSLTE_API void srslte_vec_neg_bbb(const int8_t* x, const int8_t* y, int8_t* z, const uint32_t len); +SRSRAN_API void srsran_vec_neg_sss(const int16_t* x, const int16_t* y, int16_t* z, const uint32_t len); +SRSRAN_API void srsran_vec_neg_bbb(const int8_t* x, const int8_t* y, int8_t* z, const uint32_t len); /* Dot-product */ -SRSLTE_API cf_t srslte_vec_dot_prod_cfc(const cf_t* x, const float* y, const uint32_t len); -SRSLTE_API cf_t srslte_vec_dot_prod_ccc(const cf_t* x, const cf_t* y, const uint32_t len); -SRSLTE_API cf_t srslte_vec_dot_prod_conj_ccc(const cf_t* x, const cf_t* y, const uint32_t len); -SRSLTE_API float srslte_vec_dot_prod_fff(const float* x, const float* y, const uint32_t len); -SRSLTE_API int32_t srslte_vec_dot_prod_sss(const int16_t* x, const int16_t* y, const uint32_t len); +SRSRAN_API cf_t srsran_vec_dot_prod_cfc(const cf_t* x, const float* y, const uint32_t len); +SRSRAN_API cf_t srsran_vec_dot_prod_ccc(const cf_t* x, const cf_t* y, const uint32_t len); +SRSRAN_API cf_t srsran_vec_dot_prod_conj_ccc(const cf_t* x, const cf_t* y, const uint32_t len); +SRSRAN_API float srsran_vec_dot_prod_fff(const float* x, const float* y, const uint32_t len); +SRSRAN_API int32_t srsran_vec_dot_prod_sss(const int16_t* x, const int16_t* y, const uint32_t len); /* z=x/y vector division (element-wise) */ -SRSLTE_API void srslte_vec_div_ccc(const cf_t* x, const cf_t* y, cf_t* z, const uint32_t len); -SRSLTE_API void srslte_vec_div_cfc(const cf_t* x, const float* y, cf_t* z, const uint32_t len); -SRSLTE_API void srslte_vec_div_fff(const float* x, const float* y, float* z, const uint32_t len); +SRSRAN_API void srsran_vec_div_ccc(const cf_t* x, const cf_t* y, cf_t* z, const uint32_t len); +SRSRAN_API void srsran_vec_div_cfc(const cf_t* x, const float* y, cf_t* z, const uint32_t len); +SRSRAN_API void srsran_vec_div_fff(const float* x, const float* y, float* z, const uint32_t len); /* conjugate */ -SRSLTE_API void srslte_vec_conj_cc(const cf_t* x, cf_t* y, const uint32_t len); +SRSRAN_API void srsran_vec_conj_cc(const cf_t* x, cf_t* y, const uint32_t len); /* average vector power */ -SRSLTE_API float srslte_vec_avg_power_cf(const cf_t* x, const uint32_t len); -SRSLTE_API float srslte_vec_avg_power_sf(const int16_t* x, const uint32_t len); -SRSLTE_API float srslte_vec_avg_power_bf(const int8_t* x, const uint32_t len); +SRSRAN_API float srsran_vec_avg_power_cf(const cf_t* x, const uint32_t len); +SRSRAN_API float srsran_vec_avg_power_sf(const int16_t* x, const uint32_t len); +SRSRAN_API float srsran_vec_avg_power_bf(const int8_t* x, const uint32_t len); /* Correlation between complex vectors x and y */ -SRSLTE_API float srslte_vec_corr_ccc(const cf_t* x, cf_t* y, const uint32_t len); +SRSRAN_API float srsran_vec_corr_ccc(const cf_t* x, cf_t* y, const uint32_t len); /* return the index of the maximum value in the vector */ -SRSLTE_API uint32_t srslte_vec_max_fi(const float* x, const uint32_t len); -SRSLTE_API uint32_t srslte_vec_max_abs_fi(const float* x, const uint32_t len); -SRSLTE_API uint32_t srslte_vec_max_abs_ci(const cf_t* x, const uint32_t len); +SRSRAN_API uint32_t srsran_vec_max_fi(const float* x, const uint32_t len); +SRSRAN_API uint32_t srsran_vec_max_abs_fi(const float* x, const uint32_t len); +SRSRAN_API uint32_t srsran_vec_max_abs_ci(const cf_t* x, const uint32_t len); /*! * Quantizes an array of floats into an array of 16-bit signed integers. It is @@ -221,7 +221,7 @@ SRSLTE_API uint32_t srslte_vec_max_abs_ci(const cf_t* x, const uint32_t len); * \param[in] clip Saturation value. * \param[in] len Number of values to be quantized. */ -SRSLTE_API void srslte_vec_quant_fs(const float* in, int16_t* out, float gain, float offset, float clip, uint32_t len); +SRSRAN_API void srsran_vec_quant_fs(const float* in, int16_t* out, float gain, float offset, float clip, uint32_t len); /*! * Quantizes an array of floats into an array of 8-bit signed integers. It is @@ -234,37 +234,37 @@ SRSLTE_API void srslte_vec_quant_fs(const float* in, int16_t* out, float gain, f * \param[in] clip Saturation value. * \param[in] len Number of values to be quantized. */ -SRSLTE_API void srslte_vec_quant_fc(const float* in, int8_t* out, float gain, float offset, float clip, uint32_t len); +SRSRAN_API void srsran_vec_quant_fc(const float* in, int8_t* out, float gain, float offset, float clip, uint32_t len); /* quantify vector of floats or int16 and convert to uint8_t */ -SRSLTE_API void srslte_vec_quant_fuc(const float* in, +SRSRAN_API void srsran_vec_quant_fuc(const float* in, uint8_t* out, const float gain, const float offset, const uint8_t clip, const uint32_t len); -SRSLTE_API void srslte_vec_quant_fus(const float* in, +SRSRAN_API void srsran_vec_quant_fus(const float* in, uint16_t* out, const float gain, const float offset, const uint16_t clip, const uint32_t len); -SRSLTE_API void srslte_vec_quant_suc(const int16_t* in, +SRSRAN_API void srsran_vec_quant_suc(const int16_t* in, uint8_t* out, const float gain, const float offset, const uint8_t clip, const uint32_t len); -SRSLTE_API void srslte_vec_quant_sus(const int16_t* in, +SRSRAN_API void srsran_vec_quant_sus(const int16_t* in, uint16_t* out, const float gain, const float offset, const uint16_t clip, const uint32_t len); /* magnitude of each vector element */ -SRSLTE_API void srslte_vec_abs_cf(const cf_t* x, float* abs, const uint32_t len); -SRSLTE_API void srslte_vec_abs_square_cf(const cf_t* x, float* abs_square, const uint32_t len); +SRSRAN_API void srsran_vec_abs_cf(const cf_t* x, float* abs, const uint32_t len); +SRSRAN_API void srsran_vec_abs_square_cf(const cf_t* x, float* abs_square, const uint32_t len); /** * @brief Extracts module in decibels of a complex vector @@ -292,7 +292,7 @@ SRSLTE_API void srslte_vec_abs_square_cf(const cf_t* x, float* abs_square, const * @param len is the input and output number of samples * */ -SRSLTE_API void srslte_vec_abs_dB_cf(const cf_t* x, float default_value, float* abs, const uint32_t len); +SRSRAN_API void srsran_vec_abs_dB_cf(const cf_t* x, float default_value, float* abs, const uint32_t len); /** * @brief Extracts argument in degrees from a complex vector @@ -315,22 +315,22 @@ SRSLTE_API void srslte_vec_abs_dB_cf(const cf_t* x, float default_value, float* * @param len is the input and output number of samples * */ -SRSLTE_API void srslte_vec_arg_deg_cf(const cf_t* x, float default_value, float* arg, const uint32_t len); +SRSRAN_API void srsran_vec_arg_deg_cf(const cf_t* x, float default_value, float* arg, const uint32_t len); -SRSLTE_API float srslte_mean_arg_cf(const cf_t* x, uint32_t len); +SRSRAN_API float srsran_mean_arg_cf(const cf_t* x, uint32_t len); -SRSLTE_API void srslte_vec_interleave(const cf_t* x, const cf_t* y, cf_t* z, const int len); +SRSRAN_API void srsran_vec_interleave(const cf_t* x, const cf_t* y, cf_t* z, const int len); -SRSLTE_API void srslte_vec_interleave_add(const cf_t* x, const cf_t* y, cf_t* z, const int len); +SRSRAN_API void srsran_vec_interleave_add(const cf_t* x, const cf_t* y, cf_t* z, const int len); -SRSLTE_API void srslte_vec_gen_sine(cf_t amplitude, float freq, cf_t* z, int len); +SRSRAN_API void srsran_vec_gen_sine(cf_t amplitude, float freq, cf_t* z, int len); -SRSLTE_API void srslte_vec_apply_cfo(const cf_t* x, float cfo, cf_t* z, int len); +SRSRAN_API void srsran_vec_apply_cfo(const cf_t* x, float cfo, cf_t* z, int len); -SRSLTE_API float srslte_vec_estimate_frequency(const cf_t* x, int len); +SRSRAN_API float srsran_vec_estimate_frequency(const cf_t* x, int len); #ifdef __cplusplus } #endif -#endif // SRSLTE_VECTOR_H +#endif // SRSRAN_VECTOR_H diff --git a/lib/include/srsran/phy/utils/vector_simd.h b/lib/include/srsran/phy/utils/vector_simd.h new file mode 100644 index 000000000..318a819e6 --- /dev/null +++ b/lib/include/srsran/phy/utils/vector_simd.h @@ -0,0 +1,141 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +#ifndef SRSRAN_VECTOR_SIMD_H +#define SRSRAN_VECTOR_SIMD_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "srsran/config.h" +#include +#include + +/*SIMD Logical operations*/ +SRSRAN_API void srsran_vec_xor_bbb_simd(const uint8_t* x, const uint8_t* y, uint8_t* z, int len); + +/* SIMD Basic vector math */ +SRSRAN_API void srsran_vec_sum_sss_simd(const int16_t* x, const int16_t* y, int16_t* z, int len); + +SRSRAN_API void srsran_vec_sub_sss_simd(const int16_t* x, const int16_t* y, int16_t* z, int len); + +SRSRAN_API void srsran_vec_sub_bbb_simd(const int8_t* x, const int8_t* y, int8_t* z, int len); + +SRSRAN_API float srsran_vec_acc_ff_simd(const float* x, int len); + +SRSRAN_API cf_t srsran_vec_acc_cc_simd(const cf_t* x, int len); + +SRSRAN_API void srsran_vec_add_fff_simd(const float* x, const float* y, float* z, int len); + +SRSRAN_API void srsran_vec_sub_fff_simd(const float* x, const float* y, float* z, int len); + +/* SIMD Vector Scalar Product */ +SRSRAN_API void srsran_vec_sc_prod_cfc_simd(const cf_t* x, const float h, cf_t* y, const int len); + +SRSRAN_API void srsran_vec_sc_prod_fcc_simd(const float* x, const cf_t h, cf_t* y, const int len); + +SRSRAN_API void srsran_vec_sc_prod_fff_simd(const float* x, const float h, float* z, const int len); + +SRSRAN_API void srsran_vec_sc_prod_ccc_simd(const cf_t* x, const cf_t h, cf_t* z, const int len); + +SRSRAN_API int srsran_vec_sc_prod_ccc_simd2(const cf_t* x, const cf_t h, cf_t* z, const int len); + +/* SIMD Vector Product */ +SRSRAN_API void srsran_vec_prod_ccc_split_simd(const float* a_re, + const float* a_im, + const float* b_re, + const float* b_im, + float* r_re, + float* r_im, + const int len); + +SRSRAN_API void srsran_vec_prod_ccc_c16_simd(const int16_t* a_re, + const int16_t* a_im, + const int16_t* b_re, + const int16_t* b_im, + int16_t* r_re, + int16_t* r_im, + const int len); + +SRSRAN_API void srsran_vec_prod_sss_simd(const int16_t* x, const int16_t* y, int16_t* z, const int len); + +SRSRAN_API void srsran_vec_neg_sss_simd(const int16_t* x, const int16_t* y, int16_t* z, const int len); + +SRSRAN_API void srsran_vec_neg_bbb_simd(const int8_t* x, const int8_t* y, int8_t* z, const int len); + +SRSRAN_API void srsran_vec_prod_cfc_simd(const cf_t* x, const float* y, cf_t* z, const int len); + +SRSRAN_API void srsran_vec_prod_fff_simd(const float* x, const float* y, float* z, const int len); + +SRSRAN_API void srsran_vec_prod_ccc_simd(const cf_t* x, const cf_t* y, cf_t* z, const int len); + +SRSRAN_API void srsran_vec_prod_conj_ccc_simd(const cf_t* x, const cf_t* y, cf_t* z, const int len); + +/* SIMD Division */ +SRSRAN_API void srsran_vec_div_ccc_simd(const cf_t* x, const cf_t* y, cf_t* z, const int len); + +SRSRAN_API void srsran_vec_div_cfc_simd(const cf_t* x, const float* y, cf_t* z, const int len); + +SRSRAN_API void srsran_vec_div_fff_simd(const float* x, const float* y, float* z, const int len); + +/* SIMD Dot product */ +SRSRAN_API cf_t srsran_vec_dot_prod_conj_ccc_simd(const cf_t* x, const cf_t* y, const int len); + +SRSRAN_API cf_t srsran_vec_dot_prod_ccc_simd(const cf_t* x, const cf_t* y, const int len); + +#ifdef ENABLE_C16 +SRSRAN_API c16_t srsran_vec_dot_prod_ccc_c16i_simd(const c16_t* x, const c16_t* y, const int len); +#endif /* ENABLE_C16 */ + +SRSRAN_API int srsran_vec_dot_prod_sss_simd(const int16_t* x, const int16_t* y, const int len); + +/* SIMD Modulus functions */ +SRSRAN_API void srsran_vec_abs_cf_simd(const cf_t* x, float* z, const int len); + +SRSRAN_API void srsran_vec_abs_square_cf_simd(const cf_t* x, float* z, const int len); + +/* Other Functions */ +SRSRAN_API void srsran_vec_lut_sss_simd(const short* x, const unsigned short* lut, short* y, const int len); + +SRSRAN_API void srsran_vec_lut_bbb_simd(const int8_t* x, const unsigned short* lut, int8_t* y, const int len); + +SRSRAN_API void srsran_vec_convert_if_simd(const int16_t* x, float* z, const float scale, const int len); + +SRSRAN_API void srsran_vec_convert_fi_simd(const float* x, int16_t* z, const float scale, const int len); + +SRSRAN_API void srsran_vec_convert_conj_cs_simd(const cf_t* x, int16_t* z, const float scale, const int len); + +SRSRAN_API void srsran_vec_convert_fb_simd(const float* x, int8_t* z, const float scale, const int len); + +SRSRAN_API void srsran_vec_interleave_simd(const cf_t* x, const cf_t* y, cf_t* z, const int len); + +SRSRAN_API void srsran_vec_interleave_add_simd(const cf_t* x, const cf_t* y, cf_t* z, const int len); + +SRSRAN_API void srsran_vec_gen_sine_simd(cf_t amplitude, float freq, cf_t* z, int len); + +SRSRAN_API void srsran_vec_apply_cfo_simd(const cf_t* x, float cfo, cf_t* z, int len); + +SRSRAN_API float srsran_vec_estimate_frequency_simd(const cf_t* x, int len); + +/* SIMD Find Max functions */ +SRSRAN_API uint32_t srsran_vec_max_fi_simd(const float* x, const int len); + +SRSRAN_API uint32_t srsran_vec_max_abs_fi_simd(const float* x, const int len); + +SRSRAN_API uint32_t srsran_vec_max_ci_simd(const cf_t* x, const int len); + +#ifdef __cplusplus +} +#endif + +#endif // SRSRAN_VECTOR_SIMD_H diff --git a/lib/include/srslte/radio/channel_mapping.h b/lib/include/srsran/radio/channel_mapping.h similarity index 95% rename from lib/include/srslte/radio/channel_mapping.h rename to lib/include/srsran/radio/channel_mapping.h index 35748c3e0..5e8f9f79e 100644 --- a/lib/include/srslte/radio/channel_mapping.h +++ b/lib/include/srsran/radio/channel_mapping.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,15 +10,15 @@ * */ -#ifndef SRSLTE_CHANNEL_MAPPING_H -#define SRSLTE_CHANNEL_MAPPING_H +#ifndef SRSRAN_CHANNEL_MAPPING_H +#define SRSRAN_CHANNEL_MAPPING_H #include #include #include #include -namespace srslte { +namespace srsran { /** * This class manages the mapping between logical and physical channels. @@ -140,6 +140,6 @@ private: uint32_t nof_channels_x_dev = 1; }; -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_CHANNEL_MAPPING_H +#endif // SRSRAN_CHANNEL_MAPPING_H diff --git a/lib/include/srslte/radio/radio.h b/lib/include/srsran/radio/radio.h similarity index 85% rename from lib/include/srslte/radio/radio.h rename to lib/include/srsran/radio/radio.h index 9c242ca06..0b9f7e07c 100644 --- a/lib/include/srslte/radio/radio.h +++ b/lib/include/srsran/radio/radio.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -14,34 +14,34 @@ #include "radio_metrics.h" #include "rf_buffer.h" #include "rf_timestamp.h" -#include "srslte/common/interfaces_common.h" -#include "srslte/interfaces/radio_interfaces.h" -#include "srslte/phy/resampling/resampler.h" -#include "srslte/phy/rf/rf.h" -#include "srslte/radio/radio_base.h" -#include "srslte/srslog/srslog.h" -#include "srslte/srslte.h" +#include "srsran/common/interfaces_common.h" +#include "srsran/interfaces/radio_interfaces.h" +#include "srsran/phy/resampling/resampler.h" +#include "srsran/phy/rf/rf.h" +#include "srsran/radio/radio_base.h" +#include "srsran/srslog/srslog.h" +#include "srsran/srsran.h" #include #include -#ifndef SRSLTE_RADIO_H -#define SRSLTE_RADIO_H +#ifndef SRSRAN_RADIO_H +#define SRSRAN_RADIO_H -namespace srslte { +namespace srsran { /** * Implementation of the radio interface for the PHY * * It uses the rf C library object to access the underlying radio. This implementation uses a flat array to * transmit/receive samples for all RF channels. The N carriers and P antennas are mapped into M=NP RF channels (M <= - * SRSLTE_MAX_CHANNELS). Note that all carriers must have the same number of antennas. + * SRSRAN_MAX_CHANNELS). Note that all carriers must have the same number of antennas. * * The underlying radio receives and transmits M RF channels synchronously from possibly multiple radios using the same * rf driver object. In the current implementation, the mapping between N carriers and P antennas is sequentially, eg: * [carrier_0_port_0, carrier_0_port_1, carrier_1_port_0, carrier_1_port_1, ..., carrier_N_port_N] */ -class radio : public radio_interface_phy, public srslte::radio_base +class radio : public radio_interface_phy, public srsran::radio_base { public: radio(); @@ -77,29 +77,29 @@ public: bool get_is_start_of_burst() override; bool is_init() override; void reset() override; - srslte_rf_info_t* get_info() override; + srsran_rf_info_t* get_info() override; // Other functions bool get_metrics(rf_metrics_t* metrics) final; - void handle_rf_msg(srslte_rf_error_t error); - static void rf_msg_callback(void* arg, srslte_rf_error_t error); + void handle_rf_msg(srsran_rf_error_t error); + static void rf_msg_callback(void* arg, srsran_rf_error_t error); private: - std::vector rf_devices = {}; - std::vector rf_info = {}; + std::vector rf_devices = {}; + std::vector rf_info = {}; std::vector rx_offset_n = {}; rf_metrics_t rf_metrics = {}; srslog::basic_logger& logger = srslog::fetch_basic_logger("RF", false); phy_interface_radio* phy = nullptr; cf_t* zeros = nullptr; - std::array dummy_buffers; + std::array dummy_buffers; std::mutex tx_mutex; std::mutex rx_mutex; - std::array, SRSLTE_MAX_CHANNELS> tx_buffer; - std::array, SRSLTE_MAX_CHANNELS> rx_buffer; - std::array interpolators = {}; - std::array decimators = {}; + std::array, SRSRAN_MAX_CHANNELS> tx_buffer; + std::array, SRSRAN_MAX_CHANNELS> rx_buffer; + std::array interpolators = {}; + std::array decimators = {}; bool decimator_busy = false; ///< Indicates the decimator is changing the rate rf_timestamp_t end_of_burst_time = {}; @@ -170,7 +170,7 @@ private: * @param tx_time_ Timestamp to transmit (read only) * @return it returns true if the transmission was successful, otherwise it returns false */ - bool tx_dev(const uint32_t& device_idx, rf_buffer_interface& buffer, const srslte_timestamp_t& tx_time_); + bool tx_dev(const uint32_t& device_idx, rf_buffer_interface& buffer, const srsran_timestamp_t& tx_time_); /** * Helper method for receiving over a single RF device. This function maps automatically the logical receive buffers @@ -181,7 +181,7 @@ private: * @param rxd_time Points at the receive time (write only) * @return it returns true if the reception was successful, otherwise it returns false */ - bool rx_dev(const uint32_t& device_idx, const rf_buffer_interface& buffer, srslte_timestamp_t* rxd_time); + bool rx_dev(const uint32_t& device_idx, const rf_buffer_interface& buffer, srsran_timestamp_t* rxd_time); /** * Helper method for mapping logical channels into physical radio buffers. @@ -197,13 +197,13 @@ private: uint32_t device_idx, uint32_t sample_offset, const rf_buffer_interface& buffer, - void* radio_buffers[SRSLTE_MAX_CHANNELS]); + void* radio_buffers[SRSRAN_MAX_CHANNELS]); bool start_agc(bool tx_gain_same_rx = false); void set_tx_adv(int nsamples); void set_tx_adv_neg(bool tx_adv_is_neg); bool config_rf_channels(const rf_args_t& args); }; -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_RADIO_H +#endif // SRSRAN_RADIO_H diff --git a/lib/include/srslte/radio/radio_base.h b/lib/include/srsran/radio/radio_base.h similarity index 69% rename from lib/include/srslte/radio/radio_base.h rename to lib/include/srsran/radio/radio_base.h index 52c5b2db9..03e666644 100644 --- a/lib/include/srslte/radio/radio_base.h +++ b/lib/include/srsran/radio/radio_base.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -15,13 +15,13 @@ * @brief Base class for all eNB/UE radios. */ -#ifndef SRSLTE_RADIO_BASE_H -#define SRSLTE_RADIO_BASE_H +#ifndef SRSRAN_RADIO_BASE_H +#define SRSRAN_RADIO_BASE_H -#include "srslte/common/interfaces_common.h" -#include "srslte/radio/radio_metrics.h" +#include "srsran/common/interfaces_common.h" +#include "srsran/radio/radio_metrics.h" -namespace srslte { +namespace srsran { class phy_interface_radio; @@ -38,6 +38,6 @@ public: virtual bool get_metrics(rf_metrics_t* metrics) = 0; }; -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_RADIO_BASE_H +#endif // SRSRAN_RADIO_BASE_H diff --git a/lib/include/srslte/radio/radio_metrics.h b/lib/include/srsran/radio/radio_metrics.h similarity index 61% rename from lib/include/srslte/radio/radio_metrics.h rename to lib/include/srsran/radio/radio_metrics.h index 9395f38c6..3ae9bf750 100644 --- a/lib/include/srslte/radio/radio_metrics.h +++ b/lib/include/srsran/radio/radio_metrics.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,10 +10,10 @@ * */ -#ifndef SRSLTE_RADIO_METRICS_H -#define SRSLTE_RADIO_METRICS_H +#ifndef SRSRAN_RADIO_METRICS_H +#define SRSRAN_RADIO_METRICS_H -namespace srslte { +namespace srsran { typedef struct { uint32_t rf_o; @@ -22,6 +22,6 @@ typedef struct { bool rf_error; } rf_metrics_t; -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_RADIO_METRICS_H +#endif // SRSRAN_RADIO_METRICS_H diff --git a/lib/include/srslte/radio/radio_null.h b/lib/include/srsran/radio/radio_null.h similarity index 86% rename from lib/include/srslte/radio/radio_null.h rename to lib/include/srsran/radio/radio_null.h index b438aff72..2ec62e048 100644 --- a/lib/include/srslte/radio/radio_null.h +++ b/lib/include/srsran/radio/radio_null.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -15,16 +15,16 @@ * @brief Dummy radio class */ -#ifndef SRSLTE_RADIO_NULL_H -#define SRSLTE_RADIO_NULL_H +#ifndef SRSRAN_RADIO_NULL_H +#define SRSRAN_RADIO_NULL_H #include "radio_base.h" -#include "srslte/interfaces/radio_interfaces.h" -#include "srslte/phy/rf/rf.h" -#include "srslte/radio/radio.h" -#include "srslte/radio/radio_metrics.h" +#include "srsran/interfaces/radio_interfaces.h" +#include "srsran/phy/rf/rf.h" +#include "srsran/radio/radio.h" +#include "srsran/radio/radio_metrics.h" -namespace srslte { +namespace srsran { class radio_null final : public radio_base, public radio_interface_phy { @@ -38,7 +38,7 @@ public: logger.set_level(srslog::str_to_basic_level(args.log_level)); running = true; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } void stop() override { running = false; } @@ -95,7 +95,7 @@ public: void set_channel_rx_offset(uint32_t ch, int32_t offset_samples) override { logger.info("%s", __PRETTY_FUNCTION__); } - srslte_rf_info_t* get_info() override + srsran_rf_info_t* get_info() override { logger.info("%s", __PRETTY_FUNCTION__); return nullptr; @@ -111,9 +111,9 @@ protected: srslog::basic_logger& logger = srslog::fetch_basic_logger("RF", false); bool running = false; - srslte::rf_metrics_t rf_metrics = {}; + srsran::rf_metrics_t rf_metrics = {}; phy_interface_radio* phy = nullptr; }; -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_RADIO_NULL_H +#endif // SRSRAN_RADIO_NULL_H diff --git a/lib/include/srslte/radio/rf_buffer.h b/lib/include/srsran/radio/rf_buffer.h similarity index 81% rename from lib/include/srslte/radio/rf_buffer.h rename to lib/include/srsran/radio/rf_buffer.h index e6a708b11..859362c9c 100644 --- a/lib/include/srslte/radio/rf_buffer.h +++ b/lib/include/srsran/radio/rf_buffer.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,12 +10,12 @@ * */ -#ifndef SRSLTE_RF_BUFFER_H -#define SRSLTE_RF_BUFFER_H +#ifndef SRSRAN_RF_BUFFER_H +#define SRSRAN_RF_BUFFER_H -#include "srslte/interfaces/radio_interfaces.h" +#include "srsran/interfaces/radio_interfaces.h" -namespace srslte { +namespace srsran { /** * Implemenation of the rf_buffer_interface for the current radio implementation which uses flat arrays. @@ -35,9 +35,9 @@ public: { if (nof_subframes_ > 0) { // Allocate buffers for an integer number of subframes - for (uint32_t i = 0; i < SRSLTE_MAX_CHANNELS; i++) { - sample_buffer[i] = srslte_vec_cf_malloc(nof_subframes_ * SRSLTE_SF_LEN_MAX); - srslte_vec_cf_zero(sample_buffer[i], SRSLTE_SF_LEN_MAX); + for (uint32_t i = 0; i < SRSRAN_MAX_CHANNELS; i++) { + sample_buffer[i] = srsran_vec_cf_malloc(nof_subframes_ * SRSRAN_SF_LEN_MAX); + srsran_vec_cf_zero(sample_buffer[i], SRSRAN_SF_LEN_MAX); } allocated = true; nof_subframes = nof_subframes_; @@ -45,12 +45,12 @@ public: } /** * Creates an object and sets the buffers to the flat array pointed by data. Note that data must - * contain up to SRSLTE_MAX_CHANNELS pointers + * contain up to SRSRAN_MAX_CHANNELS pointers * @param data Flat array to use as initializer for the internal buffer pointers */ - explicit rf_buffer_t(cf_t* data[SRSLTE_MAX_CHANNELS], uint32_t nof_samples_) + explicit rf_buffer_t(cf_t* data[SRSRAN_MAX_CHANNELS], uint32_t nof_samples_) { - for (uint32_t i = 0; i < SRSLTE_MAX_CHANNELS; i++) { + for (uint32_t i = 0; i < SRSRAN_MAX_CHANNELS; i++) { sample_buffer[i] = data[i]; } nof_samples = nof_samples_; @@ -95,7 +95,7 @@ public: free_all(); this->allocated = false; } - for (int i = 0; i < SRSLTE_MAX_CHANNELS; i++) { + for (int i = 0; i < SRSRAN_MAX_CHANNELS; i++) { this->sample_buffer[i] = other.sample_buffer[i]; } return *this; @@ -114,18 +114,18 @@ public: } void** to_void() override { return (void**)sample_buffer.data(); } cf_t** to_cf_t() override { return sample_buffer.data(); } - uint32_t size() override { return nof_subframes * SRSLTE_SF_LEN_MAX; } + uint32_t size() override { return nof_subframes * SRSRAN_SF_LEN_MAX; } void set_nof_samples(uint32_t n) override { nof_samples = n; } uint32_t get_nof_samples() const override { return nof_samples; } private: - std::array sample_buffer = {}; + std::array sample_buffer = {}; bool allocated = false; uint32_t nof_subframes = 0; uint32_t nof_samples = 0; void free_all() { - for (uint32_t i = 0; i < SRSLTE_MAX_CHANNELS; i++) { + for (uint32_t i = 0; i < SRSRAN_MAX_CHANNELS; i++) { if (sample_buffer[i]) { free(sample_buffer[i]); } @@ -133,6 +133,6 @@ private: } }; -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_RF_BUFFER_H +#endif // SRSRAN_RF_BUFFER_H diff --git a/lib/include/srslte/radio/rf_timestamp.h b/lib/include/srsran/radio/rf_timestamp.h similarity index 67% rename from lib/include/srslte/radio/rf_timestamp.h rename to lib/include/srsran/radio/rf_timestamp.h index 91a8d9a23..ce54d011d 100644 --- a/lib/include/srslte/radio/rf_timestamp.h +++ b/lib/include/srsran/radio/rf_timestamp.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,12 +10,12 @@ * */ -#ifndef SRSLTE_RF_TIMESTAMP_H -#define SRSLTE_RF_TIMESTAMP_H +#ifndef SRSRAN_RF_TIMESTAMP_H +#define SRSRAN_RF_TIMESTAMP_H -#include "srslte/interfaces/radio_interfaces.h" +#include "srsran/interfaces/radio_interfaces.h" -namespace srslte { +namespace srsran { /** * Implemenation of the rf_buffer_interface for the current radio implementation which uses flat arrays. @@ -46,9 +46,9 @@ public: * Gets a timestamp by reference * @return Given timestamp of the indicated device if the index is bounded, otherwise it returns the default timestamp */ - const srslte_timestamp_t& get(uint32_t idx) const override + const srsran_timestamp_t& get(uint32_t idx) const override { - if (idx >= SRSLTE_MAX_CHANNELS) { + if (idx >= SRSRAN_MAX_CHANNELS) { return default_ts; } @@ -59,9 +59,9 @@ public: * Get the timestamp array pointer * @return timestamp pointer with the value if the channel index is bounded. Otherwise, returns nullptr */ - srslte_timestamp_t* get_ptr(uint32_t idx) override + srsran_timestamp_t* get_ptr(uint32_t idx) override { - if (idx >= SRSLTE_MAX_CHANNELS) { + if (idx >= SRSRAN_MAX_CHANNELS) { return nullptr; } return ×tamps[idx]; @@ -73,8 +73,8 @@ public: */ void add(double secs) override { - for (srslte_timestamp_t& ts : timestamps) { - srslte_timestamp_add(&ts, 0, secs); + for (srsran_timestamp_t& ts : timestamps) { + srsran_timestamp_add(&ts, 0, secs); } } @@ -84,15 +84,15 @@ public: */ void sub(double secs) override { - for (srslte_timestamp_t& ts : timestamps) { - srslte_timestamp_sub(&ts, 0, secs); + for (srsran_timestamp_t& ts : timestamps) { + srsran_timestamp_sub(&ts, 0, secs); } } private: - const srslte_timestamp_t default_ts = {}; - std::array timestamps = {}; + const srsran_timestamp_t default_ts = {}; + std::array timestamps = {}; }; -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_RF_TIMESTAMP_H +#endif // SRSRAN_RF_TIMESTAMP_H diff --git a/lib/include/srslte/rrc/rrc_cfg_utils.h b/lib/include/srsran/rrc/rrc_cfg_utils.h similarity index 97% rename from lib/include/srslte/rrc/rrc_cfg_utils.h rename to lib/include/srsran/rrc/rrc_cfg_utils.h index cb7c6ee8a..695750a2b 100644 --- a/lib/include/srslte/rrc/rrc_cfg_utils.h +++ b/lib/include/srsran/rrc/rrc_cfg_utils.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,15 +10,15 @@ * */ -#ifndef SRSLTE_RRC_CFG_UTILS_H -#define SRSLTE_RRC_CFG_UTILS_H +#ifndef SRSRAN_RRC_CFG_UTILS_H +#define SRSRAN_RRC_CFG_UTILS_H -#include "srslte/asn1/rrc_utils.h" -#include "srslte/common/common.h" +#include "srsran/asn1/rrc_utils.h" +#include "srsran/common/common.h" #include #include -namespace srslte { +namespace srsran { template using rrc_obj_id_t = decltype(asn1::rrc::get_rrc_obj_id(std::declval())); @@ -317,6 +317,6 @@ void compute_cfg_diff(const toAddModList& src_list, compute_cfg_diff(src_list, target_list, rem_func, add_func, mod_func); } -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_RRC_CFG_UTILS_H +#endif // SRSRAN_RRC_CFG_UTILS_H diff --git a/lib/include/srslte/srslog/bundled/fmt/LICENSE.rst b/lib/include/srsran/srslog/bundled/fmt/LICENSE.rst similarity index 100% rename from lib/include/srslte/srslog/bundled/fmt/LICENSE.rst rename to lib/include/srsran/srslog/bundled/fmt/LICENSE.rst diff --git a/lib/include/srslte/srslog/bundled/fmt/chrono.h b/lib/include/srsran/srslog/bundled/fmt/chrono.h similarity index 100% rename from lib/include/srslte/srslog/bundled/fmt/chrono.h rename to lib/include/srsran/srslog/bundled/fmt/chrono.h diff --git a/lib/include/srslte/srslog/bundled/fmt/color.h b/lib/include/srsran/srslog/bundled/fmt/color.h similarity index 100% rename from lib/include/srslte/srslog/bundled/fmt/color.h rename to lib/include/srsran/srslog/bundled/fmt/color.h diff --git a/lib/include/srslte/srslog/bundled/fmt/compile.h b/lib/include/srsran/srslog/bundled/fmt/compile.h similarity index 100% rename from lib/include/srslte/srslog/bundled/fmt/compile.h rename to lib/include/srsran/srslog/bundled/fmt/compile.h diff --git a/lib/include/srslte/srslog/bundled/fmt/core.h b/lib/include/srsran/srslog/bundled/fmt/core.h similarity index 100% rename from lib/include/srslte/srslog/bundled/fmt/core.h rename to lib/include/srsran/srslog/bundled/fmt/core.h diff --git a/lib/include/srslte/srslog/bundled/fmt/format-inl.h b/lib/include/srsran/srslog/bundled/fmt/format-inl.h similarity index 100% rename from lib/include/srslte/srslog/bundled/fmt/format-inl.h rename to lib/include/srsran/srslog/bundled/fmt/format-inl.h diff --git a/lib/include/srslte/srslog/bundled/fmt/format.h b/lib/include/srsran/srslog/bundled/fmt/format.h similarity index 100% rename from lib/include/srslte/srslog/bundled/fmt/format.h rename to lib/include/srsran/srslog/bundled/fmt/format.h diff --git a/lib/include/srslte/srslog/bundled/fmt/locale.h b/lib/include/srsran/srslog/bundled/fmt/locale.h similarity index 100% rename from lib/include/srslte/srslog/bundled/fmt/locale.h rename to lib/include/srsran/srslog/bundled/fmt/locale.h diff --git a/lib/include/srslte/srslog/bundled/fmt/os.h b/lib/include/srsran/srslog/bundled/fmt/os.h similarity index 100% rename from lib/include/srslte/srslog/bundled/fmt/os.h rename to lib/include/srsran/srslog/bundled/fmt/os.h diff --git a/lib/include/srslte/srslog/bundled/fmt/ostream.h b/lib/include/srsran/srslog/bundled/fmt/ostream.h similarity index 100% rename from lib/include/srslte/srslog/bundled/fmt/ostream.h rename to lib/include/srsran/srslog/bundled/fmt/ostream.h diff --git a/lib/include/srslte/srslog/bundled/fmt/posix.h b/lib/include/srsran/srslog/bundled/fmt/posix.h similarity index 100% rename from lib/include/srslte/srslog/bundled/fmt/posix.h rename to lib/include/srsran/srslog/bundled/fmt/posix.h diff --git a/lib/include/srslte/srslog/bundled/fmt/printf.h b/lib/include/srsran/srslog/bundled/fmt/printf.h similarity index 100% rename from lib/include/srslte/srslog/bundled/fmt/printf.h rename to lib/include/srsran/srslog/bundled/fmt/printf.h diff --git a/lib/include/srslte/srslog/bundled/fmt/ranges.h b/lib/include/srsran/srslog/bundled/fmt/ranges.h similarity index 100% rename from lib/include/srslte/srslog/bundled/fmt/ranges.h rename to lib/include/srsran/srslog/bundled/fmt/ranges.h diff --git a/lib/include/srslte/srslog/context.h b/lib/include/srsran/srslog/context.h similarity index 98% rename from lib/include/srslte/srslog/context.h rename to lib/include/srsran/srslog/context.h index 02df5d49a..c16536b89 100644 --- a/lib/include/srslte/srslog/context.h +++ b/lib/include/srsran/srslog/context.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,7 +13,7 @@ #ifndef SRSLOG_CONTEXT_H #define SRSLOG_CONTEXT_H -#include "srslte/srslog/detail/support/tmp_utils.h" +#include "srsran/srslog/detail/support/tmp_utils.h" #include #include diff --git a/lib/include/srslte/srslog/detail/log_backend.h b/lib/include/srsran/srslog/detail/log_backend.h similarity index 95% rename from lib/include/srslte/srslog/detail/log_backend.h rename to lib/include/srsran/srslog/detail/log_backend.h index adb71e68c..b4332d49f 100644 --- a/lib/include/srslte/srslog/detail/log_backend.h +++ b/lib/include/srsran/srslog/detail/log_backend.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/lib/include/srslte/srslog/detail/log_entry.h b/lib/include/srsran/srslog/detail/log_entry.h similarity index 85% rename from lib/include/srslte/srslog/detail/log_entry.h rename to lib/include/srsran/srslog/detail/log_entry.h index 64e30cba8..37fb7644e 100644 --- a/lib/include/srslte/srslog/detail/log_entry.h +++ b/lib/include/srsran/srslog/detail/log_entry.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,8 +13,8 @@ #ifndef SRSLOG_DETAIL_LOG_ENTRY_H #define SRSLOG_DETAIL_LOG_ENTRY_H -#include "srslte/srslog/detail/log_entry_metadata.h" -#include "srslte/srslog/detail/support/thread_utils.h" +#include "srsran/srslog/detail/log_entry_metadata.h" +#include "srsran/srslog/detail/support/thread_utils.h" namespace srslog { diff --git a/lib/include/srslte/srslog/detail/log_entry_metadata.h b/lib/include/srsran/srslog/detail/log_entry_metadata.h similarity index 93% rename from lib/include/srslte/srslog/detail/log_entry_metadata.h rename to lib/include/srsran/srslog/detail/log_entry_metadata.h index e69850c52..a2d50df3a 100644 --- a/lib/include/srslte/srslog/detail/log_entry_metadata.h +++ b/lib/include/srsran/srslog/detail/log_entry_metadata.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,7 +13,7 @@ #ifndef SRSLOG_DETAIL_LOG_ENTRY_METADATA_H #define SRSLOG_DETAIL_LOG_ENTRY_METADATA_H -#include "srslte/srslog/bundled/fmt/printf.h" +#include "srsran/srslog/bundled/fmt/printf.h" #include namespace srslog { diff --git a/lib/include/srslte/srslog/detail/support/any.h b/lib/include/srsran/srslog/detail/support/any.h similarity index 99% rename from lib/include/srslte/srslog/detail/support/any.h rename to lib/include/srsran/srslog/detail/support/any.h index ac7c2b42c..5e0acec92 100644 --- a/lib/include/srslte/srslog/detail/support/any.h +++ b/lib/include/srsran/srslog/detail/support/any.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/lib/include/srslte/srslog/detail/support/error_string.h b/lib/include/srsran/srslog/detail/support/error_string.h similarity index 94% rename from lib/include/srslte/srslog/detail/support/error_string.h rename to lib/include/srsran/srslog/detail/support/error_string.h index 436c3a535..086079bdb 100644 --- a/lib/include/srslte/srslog/detail/support/error_string.h +++ b/lib/include/srsran/srslog/detail/support/error_string.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/lib/include/srslte/srslog/detail/support/memory_buffer.h b/lib/include/srsran/srslog/detail/support/memory_buffer.h similarity index 95% rename from lib/include/srslte/srslog/detail/support/memory_buffer.h rename to lib/include/srsran/srslog/detail/support/memory_buffer.h index 30e27bdfe..cbba6b088 100644 --- a/lib/include/srslte/srslog/detail/support/memory_buffer.h +++ b/lib/include/srsran/srslog/detail/support/memory_buffer.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/lib/include/srslte/srslog/detail/support/thread_utils.h b/lib/include/srsran/srslog/detail/support/thread_utils.h similarity index 98% rename from lib/include/srslte/srslog/detail/support/thread_utils.h rename to lib/include/srsran/srslog/detail/support/thread_utils.h index 537e21912..a1b2e511f 100644 --- a/lib/include/srslte/srslog/detail/support/thread_utils.h +++ b/lib/include/srsran/srslog/detail/support/thread_utils.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/lib/include/srslte/srslog/detail/support/tmp_utils.h b/lib/include/srsran/srslog/detail/support/tmp_utils.h similarity index 96% rename from lib/include/srslte/srslog/detail/support/tmp_utils.h rename to lib/include/srsran/srslog/detail/support/tmp_utils.h index c21518942..0212bdfed 100644 --- a/lib/include/srslte/srslog/detail/support/tmp_utils.h +++ b/lib/include/srsran/srslog/detail/support/tmp_utils.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/lib/include/srslte/srslog/detail/support/work_queue.h b/lib/include/srsran/srslog/detail/support/work_queue.h similarity index 96% rename from lib/include/srslte/srslog/detail/support/work_queue.h rename to lib/include/srsran/srslog/detail/support/work_queue.h index 29d0dd888..b20a360bd 100644 --- a/lib/include/srslte/srslog/detail/support/work_queue.h +++ b/lib/include/srsran/srslog/detail/support/work_queue.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,7 +13,7 @@ #ifndef SRSLOG_DETAIL_SUPPORT_WORK_QUEUE_H #define SRSLOG_DETAIL_SUPPORT_WORK_QUEUE_H -#include "srslte/srslog/detail/support/thread_utils.h" +#include "srsran/srslog/detail/support/thread_utils.h" #include #ifndef SRSLOG_QUEUE_CAPACITY diff --git a/lib/include/srslte/srslog/event_trace.h b/lib/include/srsran/srslog/event_trace.h similarity index 98% rename from lib/include/srslte/srslog/event_trace.h rename to lib/include/srsran/srslog/event_trace.h index 8b894508a..f08fe86c7 100644 --- a/lib/include/srslte/srslog/event_trace.h +++ b/lib/include/srsran/srslog/event_trace.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/lib/include/srslte/srslog/formatter.h b/lib/include/srsran/srslog/formatter.h similarity index 97% rename from lib/include/srslte/srslog/formatter.h rename to lib/include/srsran/srslog/formatter.h index 551f6f426..be69c1730 100644 --- a/lib/include/srslte/srslog/formatter.h +++ b/lib/include/srsran/srslog/formatter.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,8 +13,8 @@ #ifndef SRSLOG_FORMATTER_H #define SRSLOG_FORMATTER_H -#include "srslte/srslog/bundled/fmt/format.h" -#include "srslte/srslog/context.h" +#include "srsran/srslog/bundled/fmt/format.h" +#include "srsran/srslog/context.h" namespace srslog { diff --git a/lib/include/srslte/srslog/log_channel.h b/lib/include/srsran/srslog/log_channel.h similarity index 97% rename from lib/include/srslte/srslog/log_channel.h rename to lib/include/srsran/srslog/log_channel.h index 75b67f330..8fa0387d9 100644 --- a/lib/include/srslte/srslog/log_channel.h +++ b/lib/include/srsran/srslog/log_channel.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,9 +13,9 @@ #ifndef SRSLOG_LOG_CHANNEL_H #define SRSLOG_LOG_CHANNEL_H -#include "srslte/srslog/detail/log_backend.h" -#include "srslte/srslog/detail/log_entry.h" -#include "srslte/srslog/sink.h" +#include "srsran/srslog/detail/log_backend.h" +#include "srsran/srslog/detail/log_entry.h" +#include "srsran/srslog/sink.h" namespace srslog { diff --git a/lib/include/srslte/srslog/logger.h b/lib/include/srsran/srslog/logger.h similarity index 98% rename from lib/include/srslte/srslog/logger.h rename to lib/include/srsran/srslog/logger.h index c0444c9f7..e215ddb58 100644 --- a/lib/include/srslte/srslog/logger.h +++ b/lib/include/srsran/srslog/logger.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,7 +13,7 @@ #ifndef SRSLOG_LOGGER_H #define SRSLOG_LOGGER_H -#include "srslte/srslog/log_channel.h" +#include "srsran/srslog/log_channel.h" namespace srslog { diff --git a/lib/include/srslte/srslog/shared_types.h b/lib/include/srsran/srslog/shared_types.h similarity index 89% rename from lib/include/srslte/srslog/shared_types.h rename to lib/include/srsran/srslog/shared_types.h index 2f116b8d9..0598c59dd 100644 --- a/lib/include/srslte/srslog/shared_types.h +++ b/lib/include/srsran/srslog/shared_types.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/lib/include/srslte/srslog/sink.h b/lib/include/srsran/srslog/sink.h similarity index 84% rename from lib/include/srslte/srslog/sink.h rename to lib/include/srsran/srslog/sink.h index e0f704394..1c67a2371 100644 --- a/lib/include/srslte/srslog/sink.h +++ b/lib/include/srsran/srslog/sink.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,9 +13,9 @@ #ifndef SRSLOG_SINK_H #define SRSLOG_SINK_H -#include "srslte/srslog/detail/support/error_string.h" -#include "srslte/srslog/detail/support/memory_buffer.h" -#include "srslte/srslog/formatter.h" +#include "srsran/srslog/detail/support/error_string.h" +#include "srsran/srslog/detail/support/memory_buffer.h" +#include "srsran/srslog/formatter.h" #include namespace srslog { diff --git a/lib/include/srslte/srslog/srslog.h b/lib/include/srsran/srslog/srslog.h similarity index 98% rename from lib/include/srslte/srslog/srslog.h rename to lib/include/srsran/srslog/srslog.h index 968a7f514..6dd9ec077 100644 --- a/lib/include/srslte/srslog/srslog.h +++ b/lib/include/srsran/srslog/srslog.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,9 +13,9 @@ #ifndef SRSLOG_SRSLOG_H #define SRSLOG_SRSLOG_H -#include "srslte/srslog/detail/support/any.h" -#include "srslte/srslog/logger.h" -#include "srslte/srslog/shared_types.h" +#include "srsran/srslog/detail/support/any.h" +#include "srsran/srslog/logger.h" +#include "srsran/srslog/shared_types.h" namespace srslog { diff --git a/lib/include/srslte/srslog/srslog_c.h b/lib/include/srsran/srslog/srslog_c.h similarity index 98% rename from lib/include/srslte/srslog/srslog_c.h rename to lib/include/srsran/srslog/srslog_c.h index 3520fcdf6..90d733720 100644 --- a/lib/include/srslte/srslog/srslog_c.h +++ b/lib/include/srsran/srslog/srslog_c.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/lib/include/srsran/srsran.h b/lib/include/srsran/srsran.h new file mode 100644 index 000000000..6bcf7ceeb --- /dev/null +++ b/lib/include/srsran/srsran.h @@ -0,0 +1,135 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +#ifndef SRSRAN_SRSRAN_H +#define SRSRAN_SRSRAN_H + +#ifdef __cplusplus +#include +extern "C" { +#else +#include +#endif + +#include + +#include "srsran/config.h" +#include "srsran/version.h" + +#include "srsran/phy/utils/bit.h" +#include "srsran/phy/utils/cexptab.h" +#include "srsran/phy/utils/convolution.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/ringbuffer.h" +#include "srsran/phy/utils/vector.h" + +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/common/sequence.h" +#include "srsran/phy/common/timestamp.h" +#include "srsran/phy/utils/phy_logger.h" + +#include "srsran/phy/ch_estimation/chest_dl.h" +#include "srsran/phy/ch_estimation/chest_ul.h" +#include "srsran/phy/ch_estimation/dmrs_pdcch.h" +#include "srsran/phy/ch_estimation/dmrs_sch.h" +#include "srsran/phy/ch_estimation/refsignal_dl.h" +#include "srsran/phy/ch_estimation/refsignal_ul.h" +#include "srsran/phy/ch_estimation/wiener_dl.h" + +#include "srsran/phy/resampling/decim.h" +#include "srsran/phy/resampling/interp.h" +#include "srsran/phy/resampling/resample_arb.h" + +#include "srsran/phy/channel/ch_awgn.h" + +#include "srsran/phy/dft/dft.h" +#include "srsran/phy/dft/dft_precoding.h" +#include "srsran/phy/dft/ofdm.h" +#include "srsran/phy/fec/cbsegm.h" +#include "srsran/phy/fec/convolutional/convcoder.h" +#include "srsran/phy/fec/convolutional/rm_conv.h" +#include "srsran/phy/fec/convolutional/viterbi.h" +#include "srsran/phy/fec/crc.h" +#include "srsran/phy/fec/turbo/rm_turbo.h" +#include "srsran/phy/fec/turbo/tc_interl.h" +#include "srsran/phy/fec/turbo/turbocoder.h" +#include "srsran/phy/fec/turbo/turbodecoder.h" + +#include "srsran/phy/io/binsource.h" +#include "srsran/phy/io/filesink.h" +#include "srsran/phy/io/filesource.h" +#include "srsran/phy/io/netsink.h" +#include "srsran/phy/io/netsource.h" + +#include "srsran/phy/modem/demod_hard.h" +#include "srsran/phy/modem/demod_soft.h" +#include "srsran/phy/modem/evm.h" +#include "srsran/phy/modem/mod.h" +#include "srsran/phy/modem/modem_table.h" + +#include "srsran/phy/mimo/layermap.h" +#include "srsran/phy/mimo/precoding.h" + +#include "srsran/phy/fec/softbuffer.h" +#include "srsran/phy/phch/cqi.h" +#include "srsran/phy/phch/csi.h" +#include "srsran/phy/phch/dci.h" +#include "srsran/phy/phch/dci_nr.h" +#include "srsran/phy/phch/pbch.h" +#include "srsran/phy/phch/pcfich.h" +#include "srsran/phy/phch/pdcch.h" +#include "srsran/phy/phch/pdcch_nr.h" +#include "srsran/phy/phch/pdsch.h" +#include "srsran/phy/phch/phich.h" +#include "srsran/phy/phch/prach.h" +#include "srsran/phy/phch/pucch.h" +#include "srsran/phy/phch/pucch_proc.h" +#include "srsran/phy/phch/pusch.h" +#include "srsran/phy/phch/ra.h" +#include "srsran/phy/phch/ra_dl.h" +#include "srsran/phy/phch/ra_dl_nr.h" +#include "srsran/phy/phch/ra_nr.h" +#include "srsran/phy/phch/ra_ul.h" +#include "srsran/phy/phch/ra_ul_nr.h" +#include "srsran/phy/phch/regs.h" +#include "srsran/phy/phch/sch.h" +#include "srsran/phy/phch/uci.h" +#include "srsran/phy/phch/uci_nr.h" + +#include "srsran/phy/ue/ue_cell_search.h" +#include "srsran/phy/ue/ue_dl.h" +#include "srsran/phy/ue/ue_dl_nr.h" +#include "srsran/phy/ue/ue_mib.h" +#include "srsran/phy/ue/ue_sync.h" +#include "srsran/phy/ue/ue_ul.h" +#include "srsran/phy/ue/ue_ul_nr.h" + +#include "srsran/phy/enb/enb_dl.h" +#include "srsran/phy/enb/enb_dl_nr.h" +#include "srsran/phy/enb/enb_ul.h" + +#include "srsran/phy/scrambling/scrambling.h" + +#include "srsran/phy/sync/cfo.h" +#include "srsran/phy/sync/cp.h" +#include "srsran/phy/sync/pss.h" +#include "srsran/phy/sync/refsignal_dl_sync.h" +#include "srsran/phy/sync/sfo.h" +#include "srsran/phy/sync/sss.h" +#include "srsran/phy/sync/sync.h" + +#ifdef __cplusplus +} +#undef I // Fix complex.h #define I nastiness when using C++ +#endif + +#endif // SRSRAN_SRSRAN_H diff --git a/lib/include/srslte/system/sys_metrics.h b/lib/include/srsran/system/sys_metrics.h similarity index 76% rename from lib/include/srslte/system/sys_metrics.h rename to lib/include/srsran/system/sys_metrics.h index ff7cca5c5..150e9f36f 100644 --- a/lib/include/srslte/system/sys_metrics.h +++ b/lib/include/srsran/system/sys_metrics.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,12 +10,12 @@ * */ -#ifndef SRSLTE_SYS_METRICS_H -#define SRSLTE_SYS_METRICS_H +#ifndef SRSRAN_SYS_METRICS_H +#define SRSRAN_SYS_METRICS_H #include -namespace srslte { +namespace srsran { /// Metrics of cpu usage, memory consumption and number of thread used by the process. struct sys_metrics_t { @@ -28,6 +28,6 @@ struct sys_metrics_t { float system_mem = -1.f; }; -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_SYS_METRICS_H +#endif // SRSRAN_SYS_METRICS_H diff --git a/lib/include/srslte/system/sys_metrics_processor.h b/lib/include/srsran/system/sys_metrics_processor.h similarity index 89% rename from lib/include/srslte/system/sys_metrics_processor.h rename to lib/include/srsran/system/sys_metrics_processor.h index 88326f1e3..4c1d6309b 100644 --- a/lib/include/srslte/system/sys_metrics_processor.h +++ b/lib/include/srsran/system/sys_metrics_processor.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,14 +10,14 @@ * */ -#ifndef SRSLTE_SYS_METRICS_PROCESSOR_H -#define SRSLTE_SYS_METRICS_PROCESSOR_H +#ifndef SRSRAN_SYS_METRICS_PROCESSOR_H +#define SRSRAN_SYS_METRICS_PROCESSOR_H -#include "srslte/system/sys_metrics.h" +#include "srsran/system/sys_metrics.h" #include #include -namespace srslte { +namespace srsran { /// Process information from the system to create sys_metrics_t. The information is processed from the /proc/ system. class sys_metrics_processor @@ -61,6 +61,6 @@ private: std::chrono::time_point last_query_time = std::chrono::steady_clock::now(); }; -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_SYS_METRICS_PROCESSOR_H +#endif // SRSRAN_SYS_METRICS_PROCESSOR_H diff --git a/lib/include/srslte/test/ue_test_interfaces.h b/lib/include/srsran/test/ue_test_interfaces.h similarity index 66% rename from lib/include/srslte/test/ue_test_interfaces.h rename to lib/include/srsran/test/ue_test_interfaces.h index 4499fb429..0ec3bcffc 100644 --- a/lib/include/srslte/test/ue_test_interfaces.h +++ b/lib/include/srsran/test/ue_test_interfaces.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,11 +13,11 @@ #ifndef SRSUE_DUMMY_CLASSES_H #define SRSUE_DUMMY_CLASSES_H -#include "srslte/common/task_scheduler.h" -#include "srslte/interfaces/phy_interface_types.h" -#include "srslte/interfaces/ue_interfaces.h" -#include "srslte/interfaces/ue_phy_interfaces.h" -#include "srslte/interfaces/ue_rlc_interfaces.h" +#include "srsran/common/task_scheduler.h" +#include "srsran/interfaces/phy_interface_types.h" +#include "srsran/interfaces/ue_interfaces.h" +#include "srsran/interfaces/ue_phy_interfaces.h" +#include "srsran/interfaces/ue_rlc_interfaces.h" namespace srsue { @@ -26,9 +26,9 @@ class stack_test_dummy : public stack_interface_rrc public: stack_test_dummy() {} - srslte::tti_point get_current_tti() override + srsran::tti_point get_current_tti() override { - return srslte::tti_point{task_sched.get_timer_handler()->get_cur_time() % 10240}; + return srsran::tti_point{task_sched.get_timer_handler()->get_cur_time() % 10240}; } // Testing utility functions @@ -43,7 +43,7 @@ public: // run pending tasks without updating timers void run_pending_tasks() { task_sched.run_pending_tasks(); } - srslte::task_scheduler task_sched{512, 100}; + srsran::task_scheduler task_sched{512, 100}; }; class rlc_dummy_interface : public rlc_interface_mac @@ -53,20 +53,20 @@ public: uint32_t get_buffer_state(const uint32_t lcid) override { return 0; } int read_pdu(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes) override { return 0; } void write_pdu(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes) override {} - void write_pdu_bcch_bch(srslte::unique_byte_buffer_t payload) override {} + void write_pdu_bcch_bch(srsran::unique_byte_buffer_t payload) override {} void write_pdu_bcch_dlsch(uint8_t* payload, uint32_t nof_bytes) override {} - void write_pdu_pcch(srslte::unique_byte_buffer_t payload) override {} + void write_pdu_pcch(srsran::unique_byte_buffer_t payload) override {} void write_pdu_mch(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes) override {} }; class phy_dummy_interface : public phy_interface_rrc_lte { - bool set_config(srslte::phy_cfg_t config, uint32_t cc_idx) override { return true; } - bool set_scell(srslte_cell_t cell_info, uint32_t cc_idx, uint32_t earfcn) override { return true; } - void set_config_tdd(srslte_tdd_config_t& tdd_config) override {} - void set_config_mbsfn_sib2(srslte::mbsfn_sf_cfg_t* cfg_list, uint32_t nof_cfgs) override {} - void set_config_mbsfn_sib13(const srslte::sib13_t& sib13) override {} - void set_config_mbsfn_mcch(const srslte::mcch_msg_t& mcch) override {} + bool set_config(srsran::phy_cfg_t config, uint32_t cc_idx) override { return true; } + bool set_scell(srsran_cell_t cell_info, uint32_t cc_idx, uint32_t earfcn) override { return true; } + void set_config_tdd(srsran_tdd_config_t& tdd_config) override {} + void set_config_mbsfn_sib2(srsran::mbsfn_sf_cfg_t* cfg_list, uint32_t nof_cfgs) override {} + void set_config_mbsfn_sib13(const srsran::sib13_t& sib13) override {} + void set_config_mbsfn_mcch(const srsran::mcch_msg_t& mcch) override {} void deactivate_scells() override {} /* Measurements interface */ diff --git a/lib/include/srslte/upper/byte_buffer_queue.h b/lib/include/srsran/upper/byte_buffer_queue.h similarity index 85% rename from lib/include/srslte/upper/byte_buffer_queue.h rename to lib/include/srsran/upper/byte_buffer_queue.h index f061f2c31..5451ea68d 100644 --- a/lib/include/srslte/upper/byte_buffer_queue.h +++ b/lib/include/srsran/upper/byte_buffer_queue.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -18,15 +18,15 @@ * when pushing uplink traffic */ -#ifndef SRSLTE_BYTE_BUFFERQUEUE_H -#define SRSLTE_BYTE_BUFFERQUEUE_H +#ifndef SRSRAN_BYTE_BUFFERQUEUE_H +#define SRSRAN_BYTE_BUFFERQUEUE_H -#include "srslte/adt/circular_buffer.h" -#include "srslte/common/block_queue.h" -#include "srslte/common/common.h" +#include "srsran/adt/circular_buffer.h" +#include "srsran/common/block_queue.h" +#include "srsran/common/common.h" #include -namespace srslte { +namespace srsran { class byte_buffer_queue { @@ -35,7 +35,7 @@ public: void write(unique_byte_buffer_t msg) { queue.push_blocking(std::move(msg)); } - srslte::error_type try_write(unique_byte_buffer_t&& msg) + srsran::error_type try_write(unique_byte_buffer_t&& msg) { return queue.try_push(std::move(msg)); } @@ -83,6 +83,6 @@ private: uint32_t unread_bytes = 0; }; -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_BYTE_BUFFERQUEUE_H +#endif // SRSRAN_BYTE_BUFFERQUEUE_H diff --git a/lib/include/srslte/upper/gtpu.h b/lib/include/srsran/upper/gtpu.h similarity index 89% rename from lib/include/srslte/upper/gtpu.h rename to lib/include/srsran/upper/gtpu.h index c6fa3270e..f78ac17b2 100644 --- a/lib/include/srslte/upper/gtpu.h +++ b/lib/include/srsran/upper/gtpu.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,15 +10,15 @@ * */ -#ifndef SRSLTE_GTPU_H -#define SRSLTE_GTPU_H +#ifndef SRSRAN_GTPU_H +#define SRSRAN_GTPU_H -#include "srslte/common/byte_buffer.h" -#include "srslte/common/common.h" -#include "srslte/srslog/srslog.h" +#include "srsran/common/byte_buffer.h" +#include "srsran/common/common.h" +#include "srsran/srslog/srslog.h" #include -namespace srslte { +namespace srsran { /**************************************************************************** * GTPU Header @@ -71,8 +71,8 @@ struct gtpu_header_t { std::vector ext_buffer; }; -bool gtpu_read_header(srslte::byte_buffer_t* pdu, gtpu_header_t* header, srslog::basic_logger& logger); -bool gtpu_write_header(gtpu_header_t* header, srslte::byte_buffer_t* pdu, srslog::basic_logger& logger); +bool gtpu_read_header(srsran::byte_buffer_t* pdu, gtpu_header_t* header, srslog::basic_logger& logger); +bool gtpu_write_header(gtpu_header_t* header, srsran::byte_buffer_t* pdu, srslog::basic_logger& logger); void gtpu_ntoa(fmt::memory_buffer& buffer, uint32_t addr); inline bool gtpu_supported_flags_check(gtpu_header_t* header, srslog::basic_logger& logger) @@ -105,6 +105,6 @@ inline bool gtpu_supported_msg_type_check(gtpu_header_t* header, srslog::basic_l return true; } -} // namespace srslte +} // namespace srsran #endif diff --git a/lib/include/srslte/upper/ipv6.h b/lib/include/srsran/upper/ipv6.h similarity index 90% rename from lib/include/srslte/upper/ipv6.h rename to lib/include/srsran/upper/ipv6.h index 21fdda835..621a9d357 100644 --- a/lib/include/srslte/upper/ipv6.h +++ b/lib/include/srsran/upper/ipv6.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,8 +10,8 @@ * */ -#ifndef SRSLTE_IPV6_H -#define SRSLTE_IPV6_H +#ifndef SRSRAN_IPV6_H +#define SRSRAN_IPV6_H #include @@ -51,4 +51,4 @@ struct in6_ifreq { }; #endif -#endif // SRSLTE_IPV6_H +#endif // SRSRAN_IPV6_H diff --git a/lib/include/srslte/upper/pdcp.h b/lib/include/srsran/upper/pdcp.h similarity index 75% rename from lib/include/srslte/upper/pdcp.h rename to lib/include/srsran/upper/pdcp.h index c54fd4834..962fdb828 100644 --- a/lib/include/srslte/upper/pdcp.h +++ b/lib/include/srsran/upper/pdcp.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,21 +10,21 @@ * */ -#ifndef SRSLTE_PDCP_H -#define SRSLTE_PDCP_H +#ifndef SRSRAN_PDCP_H +#define SRSRAN_PDCP_H -#include "srslte/common/common.h" -#include "srslte/common/task_scheduler.h" -#include "srslte/interfaces/ue_pdcp_interfaces.h" -#include "srslte/upper/pdcp_entity_lte.h" +#include "srsran/common/common.h" +#include "srsran/common/task_scheduler.h" +#include "srsran/interfaces/ue_pdcp_interfaces.h" +#include "srsran/upper/pdcp_entity_lte.h" #include -namespace srslte { +namespace srsran { class pdcp : public srsue::pdcp_interface_rlc, public srsue::pdcp_interface_rrc { public: - pdcp(srslte::task_sched_handle task_sched_, const char* logname); + pdcp(srsran::task_sched_handle task_sched_, const char* logname); virtual ~pdcp(); void init(srsue::rlc_interface_pdcp* rlc_, srsue::rrc_interface_pdcp* rrc_, srsue::gw_interface_pdcp* gw_); void stop(); @@ -44,11 +44,11 @@ public: void change_lcid(uint32_t old_lcid, uint32_t new_lcid) override; void config_security(uint32_t lcid, as_security_config_t sec_cfg) override; void config_security_all(as_security_config_t sec_cfg) override; - void enable_integrity(uint32_t lcid, srslte_direction_t direction) override; - void enable_encryption(uint32_t lcid, srslte_direction_t direction) override; - void enable_security_timed(uint32_t lcid, srslte_direction_t direction, uint32_t sn); - bool get_bearer_state(uint32_t lcid, srslte::pdcp_lte_state_t* state); - bool set_bearer_state(uint32_t lcid, const srslte::pdcp_lte_state_t& state); + void enable_integrity(uint32_t lcid, srsran_direction_t direction) override; + void enable_encryption(uint32_t lcid, srsran_direction_t direction) override; + void enable_security_timed(uint32_t lcid, srsran_direction_t direction, uint32_t sn); + bool get_bearer_state(uint32_t lcid, srsran::pdcp_lte_state_t* state); + bool set_bearer_state(uint32_t lcid, const srsran::pdcp_lte_state_t& state); void send_status_report() override; void send_status_report(uint32_t lcid) override; @@ -62,7 +62,7 @@ public: void notify_failure(uint32_t lcid, const pdcp_sn_vector_t& pdcp_sns) override; // eNB-only methods - std::map get_buffered_pdus(uint32_t lcid); + std::map get_buffered_pdus(uint32_t lcid); // Metrics void get_metrics(pdcp_metrics_t& m, const uint32_t nof_tti); @@ -72,7 +72,7 @@ private: srsue::rlc_interface_pdcp* rlc = nullptr; srsue::rrc_interface_pdcp* rrc = nullptr; srsue::gw_interface_pdcp* gw = nullptr; - srslte::task_sched_handle task_sched; + srsran::task_sched_handle task_sched; srslog::basic_logger& logger; using pdcp_map_t = std::map >; @@ -89,5 +89,5 @@ private: std::chrono::high_resolution_clock::time_point metrics_tp; }; -} // namespace srslte -#endif // SRSLTE_PDCP_H +} // namespace srsran +#endif // SRSRAN_PDCP_H diff --git a/lib/include/srslte/upper/pdcp_entity_base.h b/lib/include/srsran/upper/pdcp_entity_base.h similarity index 79% rename from lib/include/srslte/upper/pdcp_entity_base.h rename to lib/include/srsran/upper/pdcp_entity_base.h index 632aa2505..5a7c1e38b 100644 --- a/lib/include/srslte/upper/pdcp_entity_base.h +++ b/lib/include/srsran/upper/pdcp_entity_base.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,22 +10,22 @@ * */ -#ifndef SRSLTE_PDCP_ENTITY_BASE_H -#define SRSLTE_PDCP_ENTITY_BASE_H +#ifndef SRSRAN_PDCP_ENTITY_BASE_H +#define SRSRAN_PDCP_ENTITY_BASE_H -#include "srslte/adt/accumulators.h" -#include "srslte/common/buffer_pool.h" -#include "srslte/common/common.h" -#include "srslte/common/interfaces_common.h" -#include "srslte/common/security.h" -#include "srslte/common/task_scheduler.h" -#include "srslte/common/threads.h" -#include "srslte/common/timers.h" -#include "srslte/interfaces/pdcp_interface_types.h" -#include "srslte/upper/byte_buffer_queue.h" -#include "srslte/upper/pdcp_metrics.h" +#include "srsran/adt/accumulators.h" +#include "srsran/common/buffer_pool.h" +#include "srsran/common/common.h" +#include "srsran/common/interfaces_common.h" +#include "srsran/common/security.h" +#include "srsran/common/task_scheduler.h" +#include "srsran/common/threads.h" +#include "srsran/common/timers.h" +#include "srsran/interfaces/pdcp_interface_types.h" +#include "srsran/upper/byte_buffer_queue.h" +#include "srsran/upper/pdcp_metrics.h" -namespace srslte { +namespace srsran { /**************************************************************************** * Structs and Defines common to both LTE and NR @@ -64,7 +64,7 @@ public: bool is_drb() { return cfg.rb_type == PDCP_RB_IS_DRB; } // RRC interface - void enable_integrity(srslte_direction_t direction = DIRECTION_TXRX) + void enable_integrity(srsran_direction_t direction = DIRECTION_TXRX) { // if either DL or UL is already enabled, both are enabled if (integrity_direction == DIRECTION_TX && direction == DIRECTION_RX) { @@ -74,10 +74,10 @@ public: } else { integrity_direction = direction; } - logger.debug("LCID=%d, integrity=%s", lcid, srslte_direction_text[integrity_direction]); + logger.debug("LCID=%d, integrity=%s", lcid, srsran_direction_text[integrity_direction]); } - void enable_encryption(srslte_direction_t direction = DIRECTION_TXRX) + void enable_encryption(srsran_direction_t direction = DIRECTION_TXRX) { // if either DL or UL is already enabled, both are enabled if (encryption_direction == DIRECTION_TX && direction == DIRECTION_RX) { @@ -87,10 +87,10 @@ public: } else { encryption_direction = direction; } - logger.debug("LCID=%d encryption=%s", lcid, srslte_direction_text[integrity_direction]); + logger.debug("LCID=%d encryption=%s", lcid, srsran_direction_text[integrity_direction]); } - void enable_security_timed(srslte_direction_t direction, uint32_t sn) + void enable_security_timed(srsran_direction_t direction, uint32_t sn) { switch (direction) { case DIRECTION_TX: @@ -100,7 +100,7 @@ public: enable_security_rx_sn = sn; break; default: - logger.error("Timed security activation for direction %s not supported.", srslte_direction_text[direction]); + logger.error("Timed security activation for direction %s not supported.", srsran_direction_text[direction]); break; } } @@ -118,7 +118,7 @@ public: virtual void get_bearer_state(pdcp_lte_state_t* state) = 0; virtual void set_bearer_state(const pdcp_lte_state_t& state, bool set_fmc) = 0; - virtual std::map get_buffered_pdus() = 0; + virtual std::map get_buffered_pdus() = 0; virtual void send_status_report() = 0; @@ -133,12 +133,12 @@ public: protected: srslog::basic_logger& logger; - srslte::task_sched_handle task_sched; + srsran::task_sched_handle task_sched; bool active = false; uint32_t lcid = 0; - srslte_direction_t integrity_direction = DIRECTION_NONE; - srslte_direction_t encryption_direction = DIRECTION_NONE; + srsran_direction_t integrity_direction = DIRECTION_NONE; + srsran_direction_t encryption_direction = DIRECTION_NONE; int32_t enable_security_tx_sn = -1; // TX SN at which security will be enabled int32_t enable_security_rx_sn = -1; // RX SN at which security will be enabled @@ -152,7 +152,7 @@ protected: pdcp_discard_timer_t::infinity, false}; - srslte::as_security_config_t sec_cfg = {}; + srsran::as_security_config_t sec_cfg = {}; // Security functions void integrity_generate(uint8_t* msg, uint32_t msg_len, uint32_t count, uint8_t* mac); @@ -165,13 +165,13 @@ protected: pdcp_pdu_type_t get_control_pdu_type(const unique_byte_buffer_t& pdu); uint32_t read_data_header(const unique_byte_buffer_t& pdu); void discard_data_header(const unique_byte_buffer_t& pdu); - void write_data_header(const srslte::unique_byte_buffer_t& sdu, uint32_t count); + void write_data_header(const srsran::unique_byte_buffer_t& sdu, uint32_t count); void extract_mac(const unique_byte_buffer_t& pdu, uint8_t* mac); void append_mac(const unique_byte_buffer_t& sdu, uint8_t* mac); // Metrics helpers pdcp_bearer_metrics_t metrics = {}; - srslte::rolling_average tx_pdu_ack_latency_ms; + srsran::rolling_average tx_pdu_ack_latency_ms; }; inline uint32_t pdcp_entity_base::HFN(uint32_t count) @@ -189,6 +189,6 @@ inline uint32_t pdcp_entity_base::COUNT(uint32_t hfn, uint32_t sn) return (hfn << cfg.sn_len) | sn; } -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_PDCP_ENTITY_BASE_H +#endif // SRSRAN_PDCP_ENTITY_BASE_H diff --git a/lib/include/srslte/upper/pdcp_entity_lte.h b/lib/include/srsran/upper/pdcp_entity_lte.h similarity index 80% rename from lib/include/srslte/upper/pdcp_entity_lte.h rename to lib/include/srsran/upper/pdcp_entity_lte.h index 6ab00d07e..6a6929aca 100644 --- a/lib/include/srslte/upper/pdcp_entity_lte.h +++ b/lib/include/srsran/upper/pdcp_entity_lte.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,16 +10,16 @@ * */ -#ifndef SRSLTE_PDCP_ENTITY_LTE_H -#define SRSLTE_PDCP_ENTITY_LTE_H +#ifndef SRSRAN_PDCP_ENTITY_LTE_H +#define SRSRAN_PDCP_ENTITY_LTE_H -#include "srslte/adt/circular_array.h" -#include "srslte/common/buffer_pool.h" -#include "srslte/common/common.h" -#include "srslte/common/security.h" -#include "srslte/common/threads.h" -#include "srslte/interfaces/ue_rrc_interfaces.h" -#include "srslte/upper/pdcp_entity_base.h" +#include "srsran/adt/circular_array.h" +#include "srsran/common/buffer_pool.h" +#include "srsran/common/common.h" +#include "srsran/common/security.h" +#include "srsran/common/threads.h" +#include "srsran/interfaces/ue_rrc_interfaces.h" +#include "srsran/upper/pdcp_entity_base.h" namespace srsue { @@ -28,12 +28,12 @@ class rlc_interface_pdcp; } // namespace srsue -namespace srslte { +namespace srsran { class undelivered_sdus_queue { public: - explicit undelivered_sdus_queue(srslte::task_sched_handle task_sched); + explicit undelivered_sdus_queue(srsran::task_sched_handle task_sched); bool empty() const { return count == 0; } bool is_full() const { return count >= capacity; } @@ -48,9 +48,9 @@ public: size_t nof_discard_timers() const; bool add_sdu(uint32_t sn, - const srslte::unique_byte_buffer_t& sdu, + const srsran::unique_byte_buffer_t& sdu, uint32_t discard_timeout, - srslte::move_callback callback); + srsran::move_callback callback); unique_byte_buffer_t& operator[](uint32_t sn) { @@ -68,7 +68,7 @@ public: uint32_t get_lms() const { return lms; } - std::map get_buffered_sdus(); + std::map get_buffered_sdus(); private: const static uint32_t capacity = 4096; @@ -77,15 +77,15 @@ private: static uint32_t increment_sn(uint32_t sn) { return (sn + 1) % capacity; } struct sdu_data { - srslte::unique_byte_buffer_t sdu; - srslte::unique_timer discard_timer; + srsran::unique_byte_buffer_t sdu; + srsran::unique_timer discard_timer; }; uint32_t count = 0; uint32_t bytes = 0; uint32_t fms = 0; uint32_t lms = 0; - srslte::circular_array sdus; + srsran::circular_array sdus; }; /**************************************************************************** @@ -106,7 +106,7 @@ public: pdcp_entity_lte(srsue::rlc_interface_pdcp* rlc_, srsue::rrc_interface_pdcp* rrc_, srsue::gw_interface_pdcp* gw_, - srslte::task_sched_handle task_sched_, + srsran::task_sched_handle task_sched_, srslog::basic_logger& logger, uint32_t lcid_, pdcp_config_t cfg_); @@ -129,11 +129,11 @@ public: bool store_sdu(uint32_t tx_count, const unique_byte_buffer_t& pdu); // Getter for unacknowledged PDUs. Used for handover - std::map get_buffered_pdus() override; + std::map get_buffered_pdus() override; // Status report helper(s) void send_status_report() override; - void handle_status_report_pdu(srslte::unique_byte_buffer_t pdu); + void handle_status_report_pdu(srsran::unique_byte_buffer_t pdu); // Internal state getters/setters void get_bearer_state(pdcp_lte_state_t* state) override; @@ -157,10 +157,10 @@ private: uint32_t maximum_pdcp_sn = 0; // PDU handlers - void handle_control_pdu(srslte::unique_byte_buffer_t pdu); - void handle_srb_pdu(srslte::unique_byte_buffer_t pdu); - void handle_um_drb_pdu(srslte::unique_byte_buffer_t pdu); - void handle_am_drb_pdu(srslte::unique_byte_buffer_t pdu); + void handle_control_pdu(srsran::unique_byte_buffer_t pdu); + void handle_srb_pdu(srsran::unique_byte_buffer_t pdu); + void handle_um_drb_pdu(srsran::unique_byte_buffer_t pdu); + void handle_am_drb_pdu(srsran::unique_byte_buffer_t pdu); // Discard callback (discardTimer) class discard_callback; @@ -208,5 +208,5 @@ private: uint32_t discard_sn; }; -} // namespace srslte -#endif // SRSLTE_PDCP_ENTITY_LTE_H +} // namespace srsran +#endif // SRSRAN_PDCP_ENTITY_LTE_H diff --git a/lib/include/srslte/upper/pdcp_entity_nr.h b/lib/include/srsran/upper/pdcp_entity_nr.h similarity index 85% rename from lib/include/srslte/upper/pdcp_entity_nr.h rename to lib/include/srsran/upper/pdcp_entity_nr.h index 893772f61..f6bfb09b8 100644 --- a/lib/include/srslte/upper/pdcp_entity_nr.h +++ b/lib/include/srsran/upper/pdcp_entity_nr.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,22 +10,22 @@ * */ -#ifndef SRSLTE_PDCP_ENTITY_NR_H -#define SRSLTE_PDCP_ENTITY_NR_H +#ifndef SRSRAN_PDCP_ENTITY_NR_H +#define SRSRAN_PDCP_ENTITY_NR_H #include "pdcp_entity_base.h" -#include "srslte/common/buffer_pool.h" -#include "srslte/common/common.h" -#include "srslte/common/interfaces_common.h" -#include "srslte/common/security.h" -#include "srslte/common/task_scheduler.h" -#include "srslte/common/threads.h" -#include "srslte/interfaces/ue_gw_interfaces.h" -#include "srslte/interfaces/ue_interfaces.h" -#include "srslte/interfaces/ue_rlc_interfaces.h" +#include "srsran/common/buffer_pool.h" +#include "srsran/common/common.h" +#include "srsran/common/interfaces_common.h" +#include "srsran/common/security.h" +#include "srsran/common/task_scheduler.h" +#include "srsran/common/threads.h" +#include "srsran/interfaces/ue_gw_interfaces.h" +#include "srsran/interfaces/ue_interfaces.h" +#include "srsran/interfaces/ue_rlc_interfaces.h" #include -namespace srslte { +namespace srsran { /**************************************************************************** * NR PDCP Entity @@ -37,7 +37,7 @@ public: pdcp_entity_nr(srsue::rlc_interface_pdcp* rlc_, srsue::rrc_interface_pdcp* rrc_, srsue::gw_interface_pdcp* gw_, - srslte::task_sched_handle task_sched_, + srsran::task_sched_handle task_sched_, srslog::basic_logger& logger, uint32_t lcid, pdcp_config_t cfg_); @@ -66,7 +66,7 @@ public: pdcp_bearer_metrics_t get_metrics() override; void reset_metrics() override; - std::map get_buffered_pdus() override { return {}; } + std::map get_buffered_pdus() override { return {}; } // State variable getters (useful for testing) uint32_t nof_discard_timers() { return discard_timers_map.size(); } @@ -148,5 +148,5 @@ inline void pdcp_entity_nr::pass_to_upper_layers(unique_byte_buffer_t sdu) } } -} // namespace srslte -#endif // SRSLTE_PDCP_ENTITY_NR_H +} // namespace srsran +#endif // SRSRAN_PDCP_ENTITY_NR_H diff --git a/lib/include/srslte/upper/pdcp_metrics.h b/lib/include/srsran/upper/pdcp_metrics.h similarity index 75% rename from lib/include/srslte/upper/pdcp_metrics.h rename to lib/include/srsran/upper/pdcp_metrics.h index 4af834283..572e43c5e 100644 --- a/lib/include/srslte/upper/pdcp_metrics.h +++ b/lib/include/srsran/upper/pdcp_metrics.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,13 +10,13 @@ * */ -#ifndef SRSLTE_PDCP_METRICS_H -#define SRSLTE_PDCP_METRICS_H +#ifndef SRSRAN_PDCP_METRICS_H +#define SRSRAN_PDCP_METRICS_H -#include "srslte/common/common.h" +#include "srsran/common/common.h" #include -namespace srslte { +namespace srsran { typedef struct { // PDU metrics @@ -33,9 +33,9 @@ typedef struct { } pdcp_bearer_metrics_t; typedef struct { - pdcp_bearer_metrics_t bearer[SRSLTE_N_RADIO_BEARERS]; + pdcp_bearer_metrics_t bearer[SRSRAN_N_RADIO_BEARERS]; } pdcp_metrics_t; -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_RLC_METRICS_H +#endif // SRSRAN_RLC_METRICS_H diff --git a/lib/include/srslte/upper/rlc.h b/lib/include/srsran/upper/rlc.h similarity index 80% rename from lib/include/srslte/upper/rlc.h rename to lib/include/srsran/upper/rlc.h index 27864ef17..533cd7a11 100644 --- a/lib/include/srslte/upper/rlc.h +++ b/lib/include/srsran/upper/rlc.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,19 +10,19 @@ * */ -#ifndef SRSLTE_RLC_H -#define SRSLTE_RLC_H +#ifndef SRSRAN_RLC_H +#define SRSRAN_RLC_H -#include "srslte/common/buffer_pool.h" -#include "srslte/common/common.h" -#include "srslte/common/task_scheduler.h" -#include "srslte/interfaces/ue_pdcp_interfaces.h" -#include "srslte/interfaces/ue_rlc_interfaces.h" -#include "srslte/interfaces/ue_rrc_interfaces.h" -#include "srslte/upper/rlc_common.h" -#include "srslte/upper/rlc_metrics.h" +#include "srsran/common/buffer_pool.h" +#include "srsran/common/common.h" +#include "srsran/common/task_scheduler.h" +#include "srsran/interfaces/ue_pdcp_interfaces.h" +#include "srsran/interfaces/ue_rlc_interfaces.h" +#include "srsran/interfaces/ue_rrc_interfaces.h" +#include "srsran/upper/rlc_common.h" +#include "srsran/upper/rlc_metrics.h" -namespace srslte { +namespace srsran { /**************************************************************************** * RLC Layer @@ -37,11 +37,11 @@ public: virtual ~rlc(); void init(srsue::pdcp_interface_rlc* pdcp_, srsue::rrc_interface_rlc* rrc_, - srslte::timer_handler* timers_, + srsran::timer_handler* timers_, uint32_t lcid_); void init(srsue::pdcp_interface_rlc* pdcp_, srsue::rrc_interface_rlc* rrc_, - srslte::timer_handler* timers_, + srsran::timer_handler* timers_, uint32_t lcid_, bsr_callback_t bsr_callback_); void stop(); @@ -63,9 +63,9 @@ public: int read_pdu_mch(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes); int get_increment_sequence_num(); void write_pdu(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes); - void write_pdu_bcch_bch(srslte::unique_byte_buffer_t pdu); + void write_pdu_bcch_bch(srsran::unique_byte_buffer_t pdu); void write_pdu_bcch_dlsch(uint8_t* payload, uint32_t nof_bytes); - void write_pdu_pcch(srslte::unique_byte_buffer_t pdu); + void write_pdu_pcch(srsran::unique_byte_buffer_t pdu); void write_pdu_mch(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes); // RRC interface @@ -91,7 +91,7 @@ private: srslog::basic_logger& logger; srsue::pdcp_interface_rlc* pdcp = nullptr; srsue::rrc_interface_rlc* rrc = nullptr; - srslte::timer_handler* timers = nullptr; + srsran::timer_handler* timers = nullptr; typedef std::map rlc_map_t; typedef std::pair rlc_map_pair_t; @@ -115,6 +115,6 @@ private: void rlc_bearer_metrics_print(const rlc_bearer_metrics_t& metrics); -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_RLC_H +#endif // SRSRAN_RLC_H diff --git a/lib/include/srslte/upper/rlc_am_base.h b/lib/include/srsran/upper/rlc_am_base.h similarity index 58% rename from lib/include/srslte/upper/rlc_am_base.h rename to lib/include/srsran/upper/rlc_am_base.h index b4ac1cf18..9aa7020c8 100644 --- a/lib/include/srslte/upper/rlc_am_base.h +++ b/lib/include/srsran/upper/rlc_am_base.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,26 +10,26 @@ * */ -#ifndef SRSLTE_RLC_AM_BASE_H -#define SRSLTE_RLC_AM_BASE_H +#ifndef SRSRAN_RLC_AM_BASE_H +#define SRSRAN_RLC_AM_BASE_H -#include "srslte/common/buffer_pool.h" -#include "srslte/common/common.h" -#include "srslte/upper/byte_buffer_queue.h" -#include "srslte/upper/rlc_common.h" +#include "srsran/common/buffer_pool.h" +#include "srsran/common/common.h" +#include "srsran/upper/byte_buffer_queue.h" +#include "srsran/upper/rlc_common.h" #include #include #include #include -namespace srslte { +namespace srsran { ///< Add rlc_am_base here bool rlc_am_is_control_pdu(uint8_t* payload); bool rlc_am_is_control_pdu(byte_buffer_t* pdu); -} // namespace srslte +} // namespace srsran namespace srsue { @@ -38,4 +38,4 @@ class rrc_interface_rlc; } // namespace srsue -#endif // SRSLTE_RLC_AM_BASE_H +#endif // SRSRAN_RLC_AM_BASE_H diff --git a/lib/include/srslte/upper/rlc_am_lte.h b/lib/include/srsran/upper/rlc_am_lte.h similarity index 93% rename from lib/include/srslte/upper/rlc_am_lte.h rename to lib/include/srsran/upper/rlc_am_lte.h index 27f1f29cf..202240138 100644 --- a/lib/include/srslte/upper/rlc_am_lte.h +++ b/lib/include/srsran/upper/rlc_am_lte.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,24 +10,24 @@ * */ -#ifndef SRSLTE_RLC_AM_LTE_H -#define SRSLTE_RLC_AM_LTE_H - -#include "srslte/adt/accumulators.h" -#include "srslte/adt/circular_array.h" -#include "srslte/common/buffer_pool.h" -#include "srslte/common/common.h" -#include "srslte/common/task_scheduler.h" -#include "srslte/common/timeout.h" -#include "srslte/interfaces/pdcp_interface_types.h" -#include "srslte/upper/byte_buffer_queue.h" -#include "srslte/upper/rlc_am_base.h" -#include "srslte/upper/rlc_common.h" +#ifndef SRSRAN_RLC_AM_LTE_H +#define SRSRAN_RLC_AM_LTE_H + +#include "srsran/adt/accumulators.h" +#include "srsran/adt/circular_array.h" +#include "srsran/common/buffer_pool.h" +#include "srsran/common/common.h" +#include "srsran/common/task_scheduler.h" +#include "srsran/common/timeout.h" +#include "srsran/interfaces/pdcp_interface_types.h" +#include "srsran/upper/byte_buffer_queue.h" +#include "srsran/upper/rlc_am_base.h" +#include "srsran/upper/rlc_common.h" #include #include #include -namespace srslte { +namespace srsran { #undef RLC_AM_BUFFER_DEBUG @@ -117,8 +117,8 @@ struct rlc_ringbuffer_t { private: size_t count = 0; - srslte::circular_array active_flag = {}; - srslte::circular_array window; + srsran::circular_array active_flag = {}; + srsran::circular_array window; }; struct buffered_pdcp_pdu_list { @@ -222,7 +222,7 @@ public: uint32_t lcid_, srsue::pdcp_interface_rlc* pdcp_, srsue::rrc_interface_rlc* rrc_, - srslte::timer_handler* timers_); + srsran::timer_handler* timers_); bool configure(const rlc_config_t& cfg_); void reestablish(); void stop(); @@ -334,8 +334,8 @@ private: * Ref: 3GPP TS 36.322 v10.0.0 Section 7 ***************************************************************************/ - srslte::timer_handler::unique_timer poll_retx_timer; - srslte::timer_handler::unique_timer status_prohibit_timer; + srsran::timer_handler::unique_timer poll_retx_timer; + srsran::timer_handler::unique_timer status_prohibit_timer; // SDU info for PDCP notifications buffered_pdcp_pdu_list undelivered_sdu_info_queue; @@ -426,16 +426,16 @@ private: * Ref: 3GPP TS 36.322 v10.0.0 Section 7 ***************************************************************************/ - srslte::timer_handler::unique_timer reordering_timer; + srsran::timer_handler::unique_timer reordering_timer; - srslte::rolling_average sdu_rx_latency_ms; + srsran::rolling_average sdu_rx_latency_ms; }; // Common variables needed/provided by parent class srsue::rrc_interface_rlc* rrc = nullptr; srslog::basic_logger& logger; srsue::pdcp_interface_rlc* pdcp = nullptr; - srslte::timer_handler* timers = nullptr; + srsran::timer_handler* timers = nullptr; uint32_t lcid = 0; rlc_config_t cfg = {}; std::string rb_name; @@ -474,6 +474,6 @@ bool rlc_am_end_aligned(const uint8_t fi); bool rlc_am_is_unaligned(const uint8_t fi); bool rlc_am_not_start_aligned(const uint8_t fi); -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_RLC_AM_LTE_H +#endif // SRSRAN_RLC_AM_LTE_H diff --git a/lib/include/srslte/upper/rlc_am_nr.h b/lib/include/srsran/upper/rlc_am_nr.h similarity index 85% rename from lib/include/srslte/upper/rlc_am_nr.h rename to lib/include/srsran/upper/rlc_am_nr.h index aa9813b58..a825938a2 100644 --- a/lib/include/srslte/upper/rlc_am_nr.h +++ b/lib/include/srsran/upper/rlc_am_nr.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,19 +10,19 @@ * */ -#ifndef SRSLTE_RLC_AM_NR_H -#define SRSLTE_RLC_AM_NR_H +#ifndef SRSRAN_RLC_AM_NR_H +#define SRSRAN_RLC_AM_NR_H -#include "srslte/common/buffer_pool.h" -#include "srslte/common/common.h" -#include "srslte/upper/byte_buffer_queue.h" -#include "srslte/upper/rlc_am_base.h" +#include "srsran/common/buffer_pool.h" +#include "srsran/common/common.h" +#include "srsran/upper/byte_buffer_queue.h" +#include "srsran/upper/rlc_am_base.h" #include #include #include #include -namespace srslte { +namespace srsran { typedef struct { rlc_am_nr_pdu_header_t header; @@ -60,6 +60,6 @@ int32_t rlc_am_nr_write_status_pdu(const rlc_am_nr_status_pdu_t& status_pdu, const rlc_am_nr_sn_size_t sn_size, byte_buffer_t* pdu); -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_RLC_AM_NR_H +#endif // SRSRAN_RLC_AM_NR_H diff --git a/lib/include/srslte/upper/rlc_common.h b/lib/include/srsran/upper/rlc_common.h similarity index 96% rename from lib/include/srslte/upper/rlc_common.h rename to lib/include/srsran/upper/rlc_common.h index 8df58b8be..ab76e4c5a 100644 --- a/lib/include/srslte/upper/rlc_common.h +++ b/lib/include/srsran/upper/rlc_common.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,15 +10,15 @@ * */ -#ifndef SRSLTE_RLC_COMMON_H -#define SRSLTE_RLC_COMMON_H +#ifndef SRSRAN_RLC_COMMON_H +#define SRSRAN_RLC_COMMON_H -#include "srslte/adt/circular_buffer.h" -#include "srslte/interfaces/rlc_interface_types.h" -#include "srslte/upper/rlc_metrics.h" +#include "srsran/adt/circular_buffer.h" +#include "srsran/interfaces/rlc_interface_types.h" +#include "srsran/upper/rlc_metrics.h" #include -namespace srslte { +namespace srsran { /**************************************************************************** * Structs and Defines @@ -307,5 +307,5 @@ private: static_blocking_queue tx_sdu_resume_queue; }; -} // namespace srslte -#endif // SRSLTE_RLC_COMMON_H +} // namespace srsran +#endif // SRSRAN_RLC_COMMON_H diff --git a/lib/include/srslte/upper/rlc_metrics.h b/lib/include/srsran/upper/rlc_metrics.h similarity index 72% rename from lib/include/srslte/upper/rlc_metrics.h rename to lib/include/srsran/upper/rlc_metrics.h index b204974d0..ac099660b 100644 --- a/lib/include/srslte/upper/rlc_metrics.h +++ b/lib/include/srsran/upper/rlc_metrics.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,13 +10,13 @@ * */ -#ifndef SRSLTE_RLC_METRICS_H -#define SRSLTE_RLC_METRICS_H +#ifndef SRSRAN_RLC_METRICS_H +#define SRSRAN_RLC_METRICS_H -#include "srslte/common/common.h" +#include "srsran/common/common.h" #include -namespace srslte { +namespace srsran { typedef struct { // SDU metrics @@ -39,10 +39,10 @@ typedef struct { } rlc_bearer_metrics_t; typedef struct { - rlc_bearer_metrics_t bearer[SRSLTE_N_RADIO_BEARERS]; - rlc_bearer_metrics_t mrb_bearer[SRSLTE_N_MCH_LCIDS]; + rlc_bearer_metrics_t bearer[SRSRAN_N_RADIO_BEARERS]; + rlc_bearer_metrics_t mrb_bearer[SRSRAN_N_MCH_LCIDS]; } rlc_metrics_t; -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_RLC_METRICS_H +#endif // SRSRAN_RLC_METRICS_H diff --git a/lib/include/srslte/upper/rlc_tm.h b/lib/include/srsran/upper/rlc_tm.h similarity index 83% rename from lib/include/srslte/upper/rlc_tm.h rename to lib/include/srsran/upper/rlc_tm.h index 6fac7fc3c..d4890db70 100644 --- a/lib/include/srslte/upper/rlc_tm.h +++ b/lib/include/srsran/upper/rlc_tm.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,13 +10,13 @@ * */ -#ifndef SRSLTE_RLC_TM_H -#define SRSLTE_RLC_TM_H +#ifndef SRSRAN_RLC_TM_H +#define SRSRAN_RLC_TM_H -#include "srslte/common/buffer_pool.h" -#include "srslte/common/common.h" -#include "srslte/upper/byte_buffer_queue.h" -#include "srslte/upper/rlc_common.h" +#include "srsran/common/buffer_pool.h" +#include "srsran/common/common.h" +#include "srsran/upper/byte_buffer_queue.h" +#include "srsran/upper/rlc_common.h" namespace srsue { @@ -25,7 +25,7 @@ class rrc_interface_rlc; } // namespace srsue -namespace srslte { +namespace srsran { class rlc_tm final : public rlc_common { @@ -74,6 +74,6 @@ private: byte_buffer_queue ul_queue; }; -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_RLC_TM_H +#endif // SRSRAN_RLC_TM_H diff --git a/lib/include/srslte/upper/rlc_um_base.h b/lib/include/srsran/upper/rlc_um_base.h similarity index 86% rename from lib/include/srslte/upper/rlc_um_base.h rename to lib/include/srsran/upper/rlc_um_base.h index 111f3bf39..1094b7cff 100644 --- a/lib/include/srslte/upper/rlc_um_base.h +++ b/lib/include/srsran/upper/rlc_um_base.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,15 +10,15 @@ * */ -#ifndef SRSLTE_RLC_UM_BASE_H -#define SRSLTE_RLC_UM_BASE_H +#ifndef SRSRAN_RLC_UM_BASE_H +#define SRSRAN_RLC_UM_BASE_H -#include "srslte/adt/accumulators.h" -#include "srslte/common/buffer_pool.h" -#include "srslte/common/common.h" -#include "srslte/common/task_scheduler.h" -#include "srslte/upper/byte_buffer_queue.h" -#include "srslte/upper/rlc_common.h" +#include "srsran/adt/accumulators.h" +#include "srsran/common/buffer_pool.h" +#include "srsran/common/common.h" +#include "srsran/common/task_scheduler.h" +#include "srsran/upper/byte_buffer_queue.h" +#include "srsran/upper/rlc_common.h" #include #include #include @@ -31,7 +31,7 @@ class rrc_interface_rlc; } // namespace srsue -namespace srslte { +namespace srsran { class rlc_um_base : public rlc_common { @@ -40,7 +40,7 @@ public: uint32_t lcid_, srsue::pdcp_interface_rlc* pdcp_, srsue::rrc_interface_rlc* rrc_, - srslte::timer_handler* timers_); + srsran::timer_handler* timers_); virtual ~rlc_um_base(); void reestablish(); void stop(); @@ -104,7 +104,7 @@ protected: // Metrics #ifdef ENABLE_TIMESTAMP - srslte::rolling_average mean_pdu_latency_us; + srsran::rolling_average mean_pdu_latency_us; #endif virtual int build_data_pdu(unique_byte_buffer_t pdu, uint8_t* payload, uint32_t nof_bytes) = 0; @@ -130,7 +130,7 @@ protected: protected: byte_buffer_pool* pool = nullptr; srslog::basic_logger& logger; - srslte::timer_handler* timers = nullptr; + srsran::timer_handler* timers = nullptr; srsue::pdcp_interface_rlc* pdcp = nullptr; srsue::rrc_interface_rlc* rrc = nullptr; @@ -151,7 +151,7 @@ protected: srsue::rrc_interface_rlc* rrc = nullptr; srsue::pdcp_interface_rlc* pdcp = nullptr; srslog::basic_logger& logger; - srslte::timer_handler* timers = nullptr; + srsran::timer_handler* timers = nullptr; uint32_t lcid = 0; rlc_config_t cfg = {}; std::string rb_name; @@ -168,6 +168,6 @@ protected: rlc_bearer_metrics_t metrics = {}; }; -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_RLC_UM_BASE_H +#endif // SRSRAN_RLC_UM_BASE_H diff --git a/lib/include/srslte/upper/rlc_um_lte.h b/lib/include/srsran/upper/rlc_um_lte.h similarity index 89% rename from lib/include/srslte/upper/rlc_um_lte.h rename to lib/include/srsran/upper/rlc_um_lte.h index 73028087f..f544c582e 100644 --- a/lib/include/srslte/upper/rlc_um_lte.h +++ b/lib/include/srsran/upper/rlc_um_lte.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,19 +10,19 @@ * */ -#ifndef SRSLTE_RLC_UM_LTE_H -#define SRSLTE_RLC_UM_LTE_H +#ifndef SRSRAN_RLC_UM_LTE_H +#define SRSRAN_RLC_UM_LTE_H -#include "srslte/common/buffer_pool.h" -#include "srslte/common/common.h" -#include "srslte/upper/byte_buffer_queue.h" -#include "srslte/upper/rlc_um_base.h" +#include "srsran/common/buffer_pool.h" +#include "srsran/common/common.h" +#include "srsran/upper/byte_buffer_queue.h" +#include "srsran/upper/rlc_um_base.h" #include #include #include #include -namespace srslte { +namespace srsran { typedef struct { rlc_umd_pdu_header_t header; @@ -36,7 +36,7 @@ public: uint32_t lcid_, srsue::pdcp_interface_rlc* pdcp_, srsue::rrc_interface_rlc* rrc_, - srslte::timer_handler* timers_); + srsran::timer_handler* timers_); ~rlc_um_lte(); bool configure(const rlc_config_t& cnfg); @@ -101,7 +101,7 @@ private: * Timers * Ref: 3GPP TS 36.322 v10.0.0 Section 7 ***************************************************************************/ - srslte::timer_handler::unique_timer reordering_timer; + srsran::timer_handler::unique_timer reordering_timer; // helper functions void debug_state(); @@ -123,6 +123,6 @@ uint32_t rlc_um_packed_length(rlc_umd_pdu_header_t* header); bool rlc_um_start_aligned(uint8_t fi); bool rlc_um_end_aligned(uint8_t fi); -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_RLC_UM_LTE_H +#endif // SRSRAN_RLC_UM_LTE_H diff --git a/lib/include/srslte/upper/rlc_um_nr.h b/lib/include/srsran/upper/rlc_um_nr.h similarity index 89% rename from lib/include/srslte/upper/rlc_um_nr.h rename to lib/include/srsran/upper/rlc_um_nr.h index 36aafa7a4..2421f90e7 100644 --- a/lib/include/srslte/upper/rlc_um_nr.h +++ b/lib/include/srsran/upper/rlc_um_nr.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,20 +10,20 @@ * */ -#ifndef SRSLTE_RLC_UM_NR_H -#define SRSLTE_RLC_UM_NR_H +#ifndef SRSRAN_RLC_UM_NR_H +#define SRSRAN_RLC_UM_NR_H -#include "srslte/common/buffer_pool.h" -#include "srslte/common/common.h" -#include "srslte/interfaces/ue_interfaces.h" -#include "srslte/upper/byte_buffer_queue.h" -#include "srslte/upper/rlc_um_base.h" +#include "srsran/common/buffer_pool.h" +#include "srsran/common/common.h" +#include "srsran/interfaces/ue_interfaces.h" +#include "srsran/upper/byte_buffer_queue.h" +#include "srsran/upper/rlc_um_base.h" #include #include #include #include -namespace srslte { +namespace srsran { typedef struct { rlc_um_nr_pdu_header_t header; @@ -37,7 +37,7 @@ public: uint32_t lcid_, srsue::pdcp_interface_rlc* pdcp_, srsue::rrc_interface_rlc* rrc_, - srslte::timer_handler* timers_); + srsran::timer_handler* timers_); ~rlc_um_nr(); bool configure(const rlc_config_t& cnfg); @@ -105,7 +105,7 @@ private: void update_total_sdu_length(rlc_umd_pdu_segments_nr_t& pdu_segments, const rlc_umd_pdu_nr_t& rx_pdu); // TS 38.322 Sec. 7.3 - srslte::timer_handler::unique_timer reassembly_timer; // to detect loss of RLC PDUs at lower layers + srsran::timer_handler::unique_timer reassembly_timer; // to detect loss of RLC PDUs at lower layers // helper functions void reset(); @@ -132,6 +132,6 @@ uint32_t rlc_um_nr_write_data_pdu_header(const rlc_um_nr_pdu_header_t& header, b uint32_t rlc_um_nr_packed_length(const rlc_um_nr_pdu_header_t& header); -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_RLC_UM_NR_H +#endif // SRSRAN_RLC_UM_NR_H diff --git a/lib/include/srsran/version.h.in b/lib/include/srsran/version.h.in new file mode 100644 index 000000000..029e78ebf --- /dev/null +++ b/lib/include/srsran/version.h.in @@ -0,0 +1,43 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +#ifndef SRSRAN_VERSION_H_IN +#define SRSRAN_VERSION_H_IN + +// the configured options and settings for SRSRAN +#define SRSRAN_VERSION_MAJOR @SRSRAN_VERSION_MAJOR@ +#define SRSRAN_VERSION_MINOR @SRSRAN_VERSION_MINOR@ +#define SRSRAN_VERSION_PATCH @SRSRAN_VERSION_PATCH@ +#define SRSRAN_VERSION_STRING "@SRSRAN_VERSION_STRING@" + +#define SRSRAN_VERSION_ENCODE(major, minor, patch) ( \ + ((major) * 10000) \ + + ((minor) * 100) \ + + ((patch) * 1)) + +#define SRSRAN_VERSION SRSRAN_VERSION_ENCODE( \ + SRSRAN_VERSION_MAJOR, \ + SRSRAN_VERSION_MINOR, \ + SRSRAN_VERSION_PATCH) + +#define SRSRAN_VERSION_CHECK(major,minor,patch) \ + (SRSRAN_VERSION >= SRSRAN_VERSION_ENCODE(major,minor,patch)) + +#include "srsran/config.h" + +SRSRAN_API char* srsran_get_version(); +SRSRAN_API int srsran_get_version_major(); +SRSRAN_API int srsran_get_version_minor(); +SRSRAN_API int srsran_get_version_patch(); +SRSRAN_API int srsran_check_version(int major, int minor, int patch); + +#endif // VERSION_ diff --git a/lib/src/CMakeLists.txt b/lib/src/CMakeLists.txt index 1f47129c9..1d0da18d6 100644 --- a/lib/src/CMakeLists.txt +++ b/lib/src/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of diff --git a/lib/src/asn1/CMakeLists.txt b/lib/src/asn1/CMakeLists.txt index f9c6a69d3..95c602e7d 100644 --- a/lib/src/asn1/CMakeLists.txt +++ b/lib/src/asn1/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -7,7 +7,7 @@ # set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-switch -Wno-unused-variable -Wno-return-type -Wno-sign-compare -Wno-reorder -Wno-parentheses -fno-exceptions") -add_library(srslte_asn1 STATIC +add_library(srsran_asn1 STATIC liblte_common.cc liblte_mme.cc gtpc.cc @@ -15,7 +15,7 @@ add_library(srslte_asn1 STATIC # ASN1 utils add_library(asn1_utils STATIC asn1_utils.cc) -target_link_libraries(asn1_utils srslte_common) +target_link_libraries(asn1_utils srsran_common) INSTALL(TARGETS asn1_utils DESTINATION ${LIBRARY_DIR}) # RRC ASN1 lib @@ -41,25 +41,25 @@ add_library(rrc_asn1 STATIC rrc_utils.cc) # Compile RRC ASN1 optimized for size target_compile_options(rrc_asn1 PRIVATE "-Os") -target_link_libraries(rrc_asn1 asn1_utils srslte_common) +target_link_libraries(rrc_asn1 asn1_utils srsran_common) INSTALL(TARGETS rrc_asn1 DESTINATION ${LIBRARY_DIR}) # S1AP ASN1 lib add_library(s1ap_asn1 STATIC s1ap.cc) target_compile_options(s1ap_asn1 PRIVATE "-Os") -target_link_libraries(s1ap_asn1 asn1_utils srslte_common) +target_link_libraries(s1ap_asn1 asn1_utils srsran_common) INSTALL(TARGETS s1ap_asn1 DESTINATION ${LIBRARY_DIR}) # RRC NR ASN1 add_library(rrc_nr_asn1 STATIC rrc_nr.cc rrc_nr_utils.cc) target_compile_options(rrc_nr_asn1 PRIVATE "-Os") -target_link_libraries(rrc_nr_asn1 asn1_utils srslte_common) +target_link_libraries(rrc_nr_asn1 asn1_utils srsran_common) INSTALL(TARGETS rrc_nr_asn1 DESTINATION ${LIBRARY_DIR}) # NGAP ASN1 add_library(ngap_nr_asn1 STATIC ngap.cc) target_compile_options(ngap_nr_asn1 PRIVATE "-Os") -target_link_libraries(ngap_nr_asn1 asn1_utils srslte_common) +target_link_libraries(ngap_nr_asn1 asn1_utils srsran_common) INSTALL(TARGETS ngap_nr_asn1 DESTINATION ${LIBRARY_DIR}) diff --git a/lib/src/asn1/asn1_utils.cc b/lib/src/asn1/asn1_utils.cc index 957720f8d..6d8f1ee36 100644 --- a/lib/src/asn1/asn1_utils.cc +++ b/lib/src/asn1/asn1_utils.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,7 +10,7 @@ * */ -#include "srslte/asn1/asn1_utils.h" +#include "srsran/asn1/asn1_utils.h" namespace asn1 { diff --git a/lib/src/asn1/gtpc.cc b/lib/src/asn1/gtpc.cc index 031d34bc9..a3d114575 100644 --- a/lib/src/asn1/gtpc.cc +++ b/lib/src/asn1/gtpc.cc @@ -2,18 +2,18 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of * the distribution. * */ -#include "srslte/asn1/gtpc.h" -#include "srslte/common/byte_buffer.h" +#include "srsran/asn1/gtpc.h" +#include "srsran/common/byte_buffer.h" #include -namespace srslte { +namespace srsran { const char* gtpc_msg_type_to_str(uint8_t type) { @@ -178,9 +178,9 @@ const char* gtpc_msg_type_to_str(uint8_t type) return "GTPC_MSG_TYPE_INVALID"; } -int gtpc_pack_create_session_request(struct gtpc_create_session_request* cs_req, srslte::byte_buffer_t) +int gtpc_pack_create_session_request(struct gtpc_create_session_request* cs_req, srsran::byte_buffer_t) { // TODO return 0; } -} // namespace srslte +} // namespace srsran diff --git a/lib/src/asn1/liblte_common.cc b/lib/src/asn1/liblte_common.cc index 744ecf808..d4e41ab2e 100644 --- a/lib/src/asn1/liblte_common.cc +++ b/lib/src/asn1/liblte_common.cc @@ -14,7 +14,7 @@ INCLUDES *******************************************************************************/ -#include "srslte/asn1/liblte_common.h" +#include "srsran/asn1/liblte_common.h" /******************************************************************************* DEFINES diff --git a/lib/src/asn1/liblte_mme.cc b/lib/src/asn1/liblte_mme.cc index 85ecd7173..6fb1e41eb 100644 --- a/lib/src/asn1/liblte_mme.cc +++ b/lib/src/asn1/liblte_mme.cc @@ -15,8 +15,8 @@ INCLUDES *******************************************************************************/ -#include "srslte/asn1/liblte_mme.h" -#include "srslte/common/liblte_security.h" +#include "srsran/asn1/liblte_mme.h" +#include "srsran/common/liblte_security.h" /******************************************************************************* DEFINES @@ -9116,7 +9116,7 @@ LIBLTE_ERROR_ENUM liblte_mme_unpack_deactivate_eps_bearer_context_request_msg( Document Reference: 24.301 v10.2.0 Section 8.3.13 *********************************************************************/ LIBLTE_ERROR_ENUM -srslte_mme_pack_esm_information_request_msg(LIBLTE_MME_ESM_INFORMATION_REQUEST_MSG_STRUCT* esm_info_req, +srsran_mme_pack_esm_information_request_msg(LIBLTE_MME_ESM_INFORMATION_REQUEST_MSG_STRUCT* esm_info_req, uint8 sec_hdr_type, uint32 count, LIBLTE_BYTE_MSG_STRUCT* msg) @@ -9301,7 +9301,7 @@ liblte_mme_pack_esm_information_response_msg(LIBLTE_MME_ESM_INFORMATION_RESPONSE } LIBLTE_ERROR_ENUM -srslte_mme_unpack_esm_information_response_msg(LIBLTE_BYTE_MSG_STRUCT* msg, +srsran_mme_unpack_esm_information_response_msg(LIBLTE_BYTE_MSG_STRUCT* msg, LIBLTE_MME_ESM_INFORMATION_RESPONSE_MSG_STRUCT* esm_info_resp) { LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS; diff --git a/lib/src/asn1/ngap.cc b/lib/src/asn1/ngap.cc index de52bb429..cc7ce78b7 100644 --- a/lib/src/asn1/ngap.cc +++ b/lib/src/asn1/ngap.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,7 +10,7 @@ * */ -#include "srslte/asn1/ngap.h" +#include "srsran/asn1/ngap.h" #include using namespace asn1; diff --git a/lib/src/asn1/rrc.cc b/lib/src/asn1/rrc.cc index 9b3596d36..11525d8ce 100644 --- a/lib/src/asn1/rrc.cc +++ b/lib/src/asn1/rrc.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,7 +10,7 @@ * */ -#include "srslte/asn1/rrc.h" +#include "srsran/asn1/rrc.h" #include using namespace asn1; diff --git a/lib/src/asn1/rrc/bcch_msg.cc b/lib/src/asn1/rrc/bcch_msg.cc index 9bfdf2575..41ddecdd8 100644 --- a/lib/src/asn1/rrc/bcch_msg.cc +++ b/lib/src/asn1/rrc/bcch_msg.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,7 +10,7 @@ * */ -#include "srslte/asn1/rrc/bcch_msg.h" +#include "srsran/asn1/rrc/bcch_msg.h" #include using namespace asn1; diff --git a/lib/src/asn1/rrc/common.cc b/lib/src/asn1/rrc/common.cc index de766f76e..804772eb1 100644 --- a/lib/src/asn1/rrc/common.cc +++ b/lib/src/asn1/rrc/common.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,7 +10,7 @@ * */ -#include "srslte/asn1/rrc/common.h" +#include "srsran/asn1/rrc/common.h" #include using namespace asn1; diff --git a/lib/src/asn1/rrc/common_ext.cc b/lib/src/asn1/rrc/common_ext.cc index 8e54023d9..f20e943b3 100644 --- a/lib/src/asn1/rrc/common_ext.cc +++ b/lib/src/asn1/rrc/common_ext.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,7 +10,7 @@ * */ -#include "srslte/asn1/rrc/common_ext.h" +#include "srsran/asn1/rrc/common_ext.h" #include using namespace asn1; diff --git a/lib/src/asn1/rrc/dl_ccch_msg.cc b/lib/src/asn1/rrc/dl_ccch_msg.cc index c39159781..4a10ce7e7 100644 --- a/lib/src/asn1/rrc/dl_ccch_msg.cc +++ b/lib/src/asn1/rrc/dl_ccch_msg.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,7 +10,7 @@ * */ -#include "srslte/asn1/rrc/dl_ccch_msg.h" +#include "srsran/asn1/rrc/dl_ccch_msg.h" #include using namespace asn1; diff --git a/lib/src/asn1/rrc/dl_dcch_msg.cc b/lib/src/asn1/rrc/dl_dcch_msg.cc index 8592dbdac..caeab714f 100644 --- a/lib/src/asn1/rrc/dl_dcch_msg.cc +++ b/lib/src/asn1/rrc/dl_dcch_msg.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,7 +10,7 @@ * */ -#include "srslte/asn1/rrc/dl_dcch_msg.h" +#include "srsran/asn1/rrc/dl_dcch_msg.h" #include using namespace asn1; diff --git a/lib/src/asn1/rrc/ho_cmd.cc b/lib/src/asn1/rrc/ho_cmd.cc index 67ece2006..98254704e 100644 --- a/lib/src/asn1/rrc/ho_cmd.cc +++ b/lib/src/asn1/rrc/ho_cmd.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,7 +10,7 @@ * */ -#include "srslte/asn1/rrc/ho_cmd.h" +#include "srsran/asn1/rrc/ho_cmd.h" #include using namespace asn1; diff --git a/lib/src/asn1/rrc/meascfg.cc b/lib/src/asn1/rrc/meascfg.cc index 4e62da7f7..3f8922d7c 100644 --- a/lib/src/asn1/rrc/meascfg.cc +++ b/lib/src/asn1/rrc/meascfg.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,7 +10,7 @@ * */ -#include "srslte/asn1/rrc/meascfg.h" +#include "srsran/asn1/rrc/meascfg.h" #include using namespace asn1; diff --git a/lib/src/asn1/rrc/paging.cc b/lib/src/asn1/rrc/paging.cc index cadc233ce..4329b44f0 100644 --- a/lib/src/asn1/rrc/paging.cc +++ b/lib/src/asn1/rrc/paging.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,7 +10,7 @@ * */ -#include "srslte/asn1/rrc/paging.h" +#include "srsran/asn1/rrc/paging.h" #include using namespace asn1; diff --git a/lib/src/asn1/rrc/phy_ded.cc b/lib/src/asn1/rrc/phy_ded.cc index 70abc65a5..853e2fd2a 100644 --- a/lib/src/asn1/rrc/phy_ded.cc +++ b/lib/src/asn1/rrc/phy_ded.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,7 +10,7 @@ * */ -#include "srslte/asn1/rrc/phy_ded.h" +#include "srsran/asn1/rrc/phy_ded.h" #include using namespace asn1; diff --git a/lib/src/asn1/rrc/rr_common.cc b/lib/src/asn1/rrc/rr_common.cc index 8d6e4cb7e..efe43a48c 100644 --- a/lib/src/asn1/rrc/rr_common.cc +++ b/lib/src/asn1/rrc/rr_common.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,7 +10,7 @@ * */ -#include "srslte/asn1/rrc/rr_common.h" +#include "srsran/asn1/rrc/rr_common.h" #include using namespace asn1; diff --git a/lib/src/asn1/rrc/rr_ded.cc b/lib/src/asn1/rrc/rr_ded.cc index b256bd612..1436f8488 100644 --- a/lib/src/asn1/rrc/rr_ded.cc +++ b/lib/src/asn1/rrc/rr_ded.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,7 +10,7 @@ * */ -#include "srslte/asn1/rrc/rr_ded.h" +#include "srsran/asn1/rrc/rr_ded.h" #include using namespace asn1; diff --git a/lib/src/asn1/rrc/security.cc b/lib/src/asn1/rrc/security.cc index dd54d3761..0ffb48290 100644 --- a/lib/src/asn1/rrc/security.cc +++ b/lib/src/asn1/rrc/security.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,7 +10,7 @@ * */ -#include "srslte/asn1/rrc/security.h" +#include "srsran/asn1/rrc/security.h" #include using namespace asn1; diff --git a/lib/src/asn1/rrc/si.cc b/lib/src/asn1/rrc/si.cc index 2011d358b..db6d4de3d 100644 --- a/lib/src/asn1/rrc/si.cc +++ b/lib/src/asn1/rrc/si.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,7 +10,7 @@ * */ -#include "srslte/asn1/rrc/si.h" +#include "srsran/asn1/rrc/si.h" #include using namespace asn1; diff --git a/lib/src/asn1/rrc/uecap.cc b/lib/src/asn1/rrc/uecap.cc index e180b131d..5900dfe2d 100644 --- a/lib/src/asn1/rrc/uecap.cc +++ b/lib/src/asn1/rrc/uecap.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,7 +10,7 @@ * */ -#include "srslte/asn1/rrc/uecap.h" +#include "srsran/asn1/rrc/uecap.h" #include using namespace asn1; diff --git a/lib/src/asn1/rrc/ul_ccch_msg.cc b/lib/src/asn1/rrc/ul_ccch_msg.cc index da391ce0f..a7bbe1a90 100644 --- a/lib/src/asn1/rrc/ul_ccch_msg.cc +++ b/lib/src/asn1/rrc/ul_ccch_msg.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,7 +10,7 @@ * */ -#include "srslte/asn1/rrc/ul_ccch_msg.h" +#include "srsran/asn1/rrc/ul_ccch_msg.h" #include using namespace asn1; diff --git a/lib/src/asn1/rrc/ul_dcch_msg.cc b/lib/src/asn1/rrc/ul_dcch_msg.cc index e2726795a..8a6ec722f 100644 --- a/lib/src/asn1/rrc/ul_dcch_msg.cc +++ b/lib/src/asn1/rrc/ul_dcch_msg.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,7 +10,7 @@ * */ -#include "srslte/asn1/rrc/ul_dcch_msg.h" +#include "srsran/asn1/rrc/ul_dcch_msg.h" #include using namespace asn1; diff --git a/lib/src/asn1/rrc_nbiot.cc b/lib/src/asn1/rrc_nbiot.cc index 3f1716054..e544d1455 100644 --- a/lib/src/asn1/rrc_nbiot.cc +++ b/lib/src/asn1/rrc_nbiot.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,7 +10,7 @@ * */ -#include "srslte/asn1/rrc_nbiot.h" +#include "srsran/asn1/rrc_nbiot.h" #include using namespace asn1; diff --git a/lib/src/asn1/rrc_nr.cc b/lib/src/asn1/rrc_nr.cc index 802709763..ff5832ddc 100644 --- a/lib/src/asn1/rrc_nr.cc +++ b/lib/src/asn1/rrc_nr.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,7 +10,7 @@ * */ -#include "srslte/asn1/rrc_nr.h" +#include "srsran/asn1/rrc_nr.h" #include using namespace asn1; diff --git a/lib/src/asn1/rrc_nr_utils.cc b/lib/src/asn1/rrc_nr_utils.cc index 455ea2b3b..0ba2c5eac 100644 --- a/lib/src/asn1/rrc_nr_utils.cc +++ b/lib/src/asn1/rrc_nr_utils.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,14 +10,14 @@ * */ -#include "srslte/asn1/rrc_nr_utils.h" -#include "srslte/asn1/rrc_nr.h" -#include "srslte/config.h" -#include "srslte/interfaces/pdcp_interface_types.h" -#include "srslte/interfaces/rlc_interface_types.h" +#include "srsran/asn1/rrc_nr_utils.h" +#include "srsran/asn1/rrc_nr.h" +#include "srsran/config.h" +#include "srsran/interfaces/pdcp_interface_types.h" +#include "srsran/interfaces/rlc_interface_types.h" #include -namespace srslte { +namespace srsran { using namespace asn1::rrc_nr; /*************************** @@ -81,7 +81,7 @@ rach_nr_cfg_t make_mac_rach_cfg(const rach_cfg_common_s& asn1_type) rlc_config_t make_rlc_config_t(const rlc_cfg_c& asn1_type) { rlc_config_t rlc_cfg = rlc_config_t::default_rlc_um_nr_config(); - rlc_cfg.rat = srslte_rat_t::nr; + rlc_cfg.rat = srsran_rat_t::nr; switch (asn1_type.type().value) { case rlc_cfg_c::types_opts::am: break; @@ -100,7 +100,7 @@ rlc_config_t make_rlc_config_t(const rlc_cfg_c& asn1_type) return rlc_cfg; } -srslte::pdcp_config_t make_drb_pdcp_config_t(const uint8_t bearer_id, bool is_ue, const pdcp_cfg_s& pdcp_cfg) +srsran::pdcp_config_t make_drb_pdcp_config_t(const uint8_t bearer_id, bool is_ue, const pdcp_cfg_s& pdcp_cfg) { // TODO: complete config processing // TODO: check if is drb_cfg.pdcp_cfg.drb_present if not return Error @@ -170,14 +170,14 @@ srslte::pdcp_config_t make_drb_pdcp_config_t(const uint8_t bearer_id, bool is_ue } } - uint8_t sn_len = srslte::PDCP_SN_LEN_12; + uint8_t sn_len = srsran::PDCP_SN_LEN_12; if (pdcp_cfg.drb.pdcp_sn_size_dl_present) { switch (pdcp_cfg.drb.pdcp_sn_size_dl.value) { case pdcp_cfg_s::drb_s_::pdcp_sn_size_dl_opts::options::len12bits: - sn_len = srslte::PDCP_SN_LEN_12; + sn_len = srsran::PDCP_SN_LEN_12; break; case pdcp_cfg_s::drb_s_::pdcp_sn_size_dl_opts::options::len18bits: - sn_len = srslte::PDCP_SN_LEN_18; + sn_len = srsran::PDCP_SN_LEN_18; default: break; } @@ -194,7 +194,7 @@ srslte::pdcp_config_t make_drb_pdcp_config_t(const uint8_t bearer_id, bool is_ue return cfg; } -} // namespace srslte +} // namespace srsran namespace srsenb { @@ -214,13 +214,13 @@ int set_sched_cell_cfg_sib1(srsenb::sched_interface::cell_cfg_t* sched_cfg, cons // setup PRACH if (not sib1.si_sched_info.si_request_cfg.rach_occasions_si_present) { asn1::log_error("Expected RA Resp Win present\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } sched_cfg->prach_rar_window = sib1.si_sched_info.si_request_cfg.rach_occasions_si.rach_cfg_si.ra_resp_win.to_number(); sched_cfg->prach_freq_offset = sib1.si_sched_info.si_request_cfg.rach_occasions_si.rach_cfg_si.msg1_freq_start; sched_cfg->maxharq_msg3tx = sib1.si_sched_info.si_request_cfg.rach_occasions_si.rach_cfg_si.preamb_trans_max; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } } // namespace srsenb diff --git a/lib/src/asn1/rrc_utils.cc b/lib/src/asn1/rrc_utils.cc index b59cf3b17..e48abfd51 100644 --- a/lib/src/asn1/rrc_utils.cc +++ b/lib/src/asn1/rrc_utils.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,13 +10,13 @@ * */ -#include "srslte/asn1/rrc_utils.h" -#include "srslte/asn1/rrc.h" -#include "srslte/config.h" +#include "srsran/asn1/rrc_utils.h" +#include "srsran/asn1/rrc.h" +#include "srsran/config.h" #include -#include +#include -namespace srslte { +namespace srsran { using namespace asn1::rrc; @@ -91,25 +91,25 @@ void to_asn1(asn1::rrc::s_tmsi_s* asn1_type, const s_tmsi_t& cfg) * CQI Report Aperiodic **************************/ -srslte_cqi_report_mode_t make_aperiodic_mode(const asn1::rrc::cqi_report_mode_aperiodic_e asn_mode) +srsran_cqi_report_mode_t make_aperiodic_mode(const asn1::rrc::cqi_report_mode_aperiodic_e asn_mode) { switch (asn_mode) { case asn1::rrc::cqi_report_mode_aperiodic_e::rm12: - return SRSLTE_CQI_MODE_12; + return SRSRAN_CQI_MODE_12; case asn1::rrc::cqi_report_mode_aperiodic_e::rm20: - return SRSLTE_CQI_MODE_20; + return SRSRAN_CQI_MODE_20; case asn1::rrc::cqi_report_mode_aperiodic_e::rm22: - return SRSLTE_CQI_MODE_22; + return SRSRAN_CQI_MODE_22; case asn1::rrc::cqi_report_mode_aperiodic_e::rm30: - return SRSLTE_CQI_MODE_30; + return SRSRAN_CQI_MODE_30; case asn1::rrc::cqi_report_mode_aperiodic_e::rm31: - return SRSLTE_CQI_MODE_31; + return SRSRAN_CQI_MODE_31; case asn1::rrc::cqi_report_mode_aperiodic_e::rm10_v1310: case asn1::rrc::cqi_report_mode_aperiodic_e::rm11_v1310: case asn1::rrc::cqi_report_mode_aperiodic_e::rm32_v1250: fprintf(stderr, "Aperiodic mode %s not handled\n", asn_mode.to_string().c_str()); default: - return SRSLTE_CQI_MODE_NA; + return SRSRAN_CQI_MODE_NA; } } @@ -124,9 +124,9 @@ static_assert((int)establishment_cause_t::nulltype == (int)asn1::rrc::establishm * RLC Config **************************/ -srslte::rlc_config_t make_rlc_config_t(const asn1::rrc::rlc_cfg_c& asn1_type) +srsran::rlc_config_t make_rlc_config_t(const asn1::rrc::rlc_cfg_c& asn1_type) { - srslte::rlc_config_t rlc_cfg; + srsran::rlc_config_t rlc_cfg; switch (asn1_type.type().value) { case asn1::rrc::rlc_cfg_c::types_opts::am: rlc_cfg.rlc_mode = rlc_mode_t::am; @@ -154,7 +154,7 @@ srslte::rlc_config_t make_rlc_config_t(const asn1::rrc::rlc_cfg_c& asn1_type) return rlc_cfg; } -srslte::rlc_config_t make_rlc_config_t(const asn1::rrc::srb_to_add_mod_s& asn1_type) +srsran::rlc_config_t make_rlc_config_t(const asn1::rrc::srb_to_add_mod_s& asn1_type) { if (asn1_type.rlc_cfg.type().value == asn1::rrc::srb_to_add_mod_s::rlc_cfg_c_::types_opts::explicit_value) { return make_rlc_config_t(asn1_type.rlc_cfg.explicit_value()); @@ -167,7 +167,7 @@ srslte::rlc_config_t make_rlc_config_t(const asn1::rrc::srb_to_add_mod_s& asn1_t } } -void to_asn1(asn1::rrc::rlc_cfg_c* asn1_type, const srslte::rlc_config_t& cfg) +void to_asn1(asn1::rrc::rlc_cfg_c* asn1_type, const srsran::rlc_config_t& cfg) { *asn1_type = asn1::rrc::rlc_cfg_c(); switch (cfg.rlc_mode) { @@ -198,7 +198,7 @@ void to_asn1(asn1::rrc::rlc_cfg_c* asn1_type, const srslte::rlc_config_t& cfg) * PDCP Config */ -srslte::pdcp_config_t make_srb_pdcp_config_t(const uint8_t bearer_id, bool is_ue) +srsran::pdcp_config_t make_srb_pdcp_config_t(const uint8_t bearer_id, bool is_ue) { pdcp_config_t cfg(bearer_id, PDCP_RB_IS_SRB, @@ -211,7 +211,7 @@ srslte::pdcp_config_t make_srb_pdcp_config_t(const uint8_t bearer_id, bool is_ue return cfg; } -srslte::pdcp_config_t make_drb_pdcp_config_t(const uint8_t bearer_id, bool is_ue) +srsran::pdcp_config_t make_drb_pdcp_config_t(const uint8_t bearer_id, bool is_ue) { pdcp_config_t cfg(bearer_id, PDCP_RB_IS_DRB, @@ -226,24 +226,24 @@ srslte::pdcp_config_t make_drb_pdcp_config_t(const uint8_t bearer_id, bool is_ue uint8_t get_pdcp_drb_sn_len(const pdcp_cfg_s& pdcp_cfg) { - uint8_t sn_len = srslte::PDCP_SN_LEN_12; + uint8_t sn_len = srsran::PDCP_SN_LEN_12; if (pdcp_cfg.rlc_um_present) { if (pdcp_cfg.rlc_um.pdcp_sn_size.value == pdcp_cfg_s::rlc_um_s_::pdcp_sn_size_e_::len7bits) { - sn_len = srslte::PDCP_SN_LEN_7; + sn_len = srsran::PDCP_SN_LEN_7; } } if (pdcp_cfg.ext) { if (pdcp_cfg.pdcp_sn_size_v1130_present) { - sn_len = srslte::PDCP_SN_LEN_15; + sn_len = srsran::PDCP_SN_LEN_15; } if (pdcp_cfg.pdcp_sn_size_v1310_present) { - sn_len = srslte::PDCP_SN_LEN_18; + sn_len = srsran::PDCP_SN_LEN_18; } } return sn_len; } -srslte::pdcp_config_t make_drb_pdcp_config_t(const uint8_t bearer_id, bool is_ue, const asn1::rrc::pdcp_cfg_s& pdcp_cfg) +srsran::pdcp_config_t make_drb_pdcp_config_t(const uint8_t bearer_id, bool is_ue, const asn1::rrc::pdcp_cfg_s& pdcp_cfg) { // TODO: complete config processing pdcp_discard_timer_t discard_timer = pdcp_discard_timer_t::infinity; @@ -468,10 +468,10 @@ void set_phy_cfg_t_dedicated_cfg(phy_cfg_t* cfg, const asn1::rrc::phys_cfg_ded_s if (pucch_format_r10->type() == pucch_format_r10_t::types::format3_r10) { // Select feedback mode - cfg->ul_cfg.pucch.ack_nack_feedback_mode = SRSLTE_PUCCH_ACK_NACK_FEEDBACK_MODE_PUCCH3; + cfg->ul_cfg.pucch.ack_nack_feedback_mode = SRSRAN_PUCCH_ACK_NACK_FEEDBACK_MODE_PUCCH3; auto* format3_r13 = &pucch_format_r10->format3_r10(); - for (uint32_t n = 0; n < SRSLTE_MIN(format3_r13->n3_pucch_an_list_r13.size(), SRSLTE_PUCCH_SIZE_AN_CS); n++) { + for (uint32_t n = 0; n < SRSRAN_MIN(format3_r13->n3_pucch_an_list_r13.size(), SRSRAN_PUCCH_SIZE_AN_CS); n++) { cfg->ul_cfg.pucch.n3_pucch_an_list[n] = format3_r13->n3_pucch_an_list_r13[n]; } if (format3_r13->two_ant_port_activ_pucch_format3_r13_present) { @@ -491,19 +491,19 @@ void set_phy_cfg_t_dedicated_cfg(phy_cfg_t* cfg, const asn1::rrc::phys_cfg_ded_s if (n1_pucch_an_cs_r10->type() == asn1::rrc::setup_e::setup) { // Select feedback mode - cfg->ul_cfg.pucch.ack_nack_feedback_mode = SRSLTE_PUCCH_ACK_NACK_FEEDBACK_MODE_CS; + cfg->ul_cfg.pucch.ack_nack_feedback_mode = SRSRAN_PUCCH_ACK_NACK_FEEDBACK_MODE_CS; typedef n1_pucch_an_cs_r10_t::setup_s_::n1_pucch_an_cs_list_r10_l_ n1_pucch_an_cs_list_r10_t; n1_pucch_an_cs_list_r10_t n1_pucch_an_cs_list = ch_sel_r10->n1_pucch_an_cs_r10.setup().n1_pucch_an_cs_list_r10; - for (uint32_t i = 0; i < SRSLTE_MIN(n1_pucch_an_cs_list.size(), SRSLTE_PUCCH_NOF_AN_CS); i++) { + for (uint32_t i = 0; i < SRSRAN_MIN(n1_pucch_an_cs_list.size(), SRSRAN_PUCCH_NOF_AN_CS); i++) { asn1::rrc::n1_pucch_an_cs_r10_l n1_pucch_an_cs = n1_pucch_an_cs_list[i]; - for (uint32_t j = 0; j < SRSLTE_PUCCH_SIZE_AN_CS; j++) { + for (uint32_t j = 0; j < SRSRAN_PUCCH_SIZE_AN_CS; j++) { cfg->ul_cfg.pucch.n1_pucch_an_cs[j][i] = n1_pucch_an_cs[j]; } } } else { - cfg->ul_cfg.pucch.ack_nack_feedback_mode = SRSLTE_PUCCH_ACK_NACK_FEEDBACK_MODE_NORMAL; + cfg->ul_cfg.pucch.ack_nack_feedback_mode = SRSRAN_PUCCH_ACK_NACK_FEEDBACK_MODE_NORMAL; } } } else { @@ -600,8 +600,8 @@ void set_phy_cfg_t_dedicated_cfg(phy_cfg_t* cfg, const asn1::rrc::phys_cfg_ded_s // Parse Release 10 asn1::rrc::ant_info_ded_r10_s::tx_mode_r10_e_::options tx_mode = asn1_type.ant_info_r10->explicit_value_r10().tx_mode_r10.value; - if ((srslte_tm_t)tx_mode < SRSLTE_TMINV) { - cfg->dl_cfg.tm = (srslte_tm_t)tx_mode; + if ((srsran_tm_t)tx_mode < SRSRAN_TMINV) { + cfg->dl_cfg.tm = (srsran_tm_t)tx_mode; } else { fprintf(stderr, "Transmission mode (R10) %s is not supported\n", @@ -611,8 +611,8 @@ void set_phy_cfg_t_dedicated_cfg(phy_cfg_t* cfg, const asn1::rrc::phys_cfg_ded_s asn1_type.ant_info.type() == asn1::rrc::phys_cfg_ded_s::ant_info_c_::types::explicit_value) { // Parse Release 8 asn1::rrc::ant_info_ded_s::tx_mode_e_::options tx_mode = asn1_type.ant_info.explicit_value().tx_mode.value; - if ((srslte_tm_t)tx_mode < SRSLTE_TMINV) { - cfg->dl_cfg.tm = (srslte_tm_t)tx_mode; + if ((srsran_tm_t)tx_mode < SRSRAN_TMINV) { + cfg->dl_cfg.tm = (srsran_tm_t)tx_mode; } else { fprintf(stderr, "Transmission mode (R8) %s is not supported\n", @@ -668,21 +668,21 @@ void set_phy_cfg_t_enable_64qam(phy_cfg_t* cfg, const bool enabled) void set_phy_cfg_t_common_pusch(phy_cfg_t* cfg, const asn1::rrc::pusch_cfg_common_s& asn1_type) { /* PUSCH DMRS signal configuration */ - bzero(&cfg->ul_cfg.dmrs, sizeof(srslte_refsignal_dmrs_pusch_cfg_t)); + bzero(&cfg->ul_cfg.dmrs, sizeof(srsran_refsignal_dmrs_pusch_cfg_t)); cfg->ul_cfg.dmrs.group_hopping_en = asn1_type.ul_ref_sigs_pusch.group_hop_enabled; cfg->ul_cfg.dmrs.sequence_hopping_en = asn1_type.ul_ref_sigs_pusch.seq_hop_enabled; cfg->ul_cfg.dmrs.cyclic_shift = asn1_type.ul_ref_sigs_pusch.cyclic_shift; cfg->ul_cfg.dmrs.delta_ss = asn1_type.ul_ref_sigs_pusch.group_assign_pusch; /* PUSCH Hopping configuration */ - bzero(&cfg->ul_cfg.hopping, sizeof(srslte_pusch_hopping_cfg_t)); + bzero(&cfg->ul_cfg.hopping, sizeof(srsran_pusch_hopping_cfg_t)); cfg->ul_cfg.hopping.n_sb = asn1_type.pusch_cfg_basic.n_sb; cfg->ul_cfg.hopping.hopping_offset = asn1_type.pusch_cfg_basic.pusch_hop_offset; cfg->ul_cfg.hopping.hop_mode = asn1_type.pusch_cfg_basic.hop_mode.value == asn1::rrc::pusch_cfg_common_s::pusch_cfg_basic_s_::hop_mode_e_::intra_and_inter_sub_frame - ? cfg->ul_cfg.hopping.SRSLTE_PUSCH_HOP_MODE_INTRA_SF - : cfg->ul_cfg.hopping.SRSLTE_PUSCH_HOP_MODE_INTER_SF; + ? cfg->ul_cfg.hopping.SRSRAN_PUSCH_HOP_MODE_INTRA_SF + : cfg->ul_cfg.hopping.SRSRAN_PUSCH_HOP_MODE_INTER_SF; } void set_phy_cfg_t_common_pucch(phy_cfg_t* cfg, const asn1::rrc::pucch_cfg_common_s& asn1_type) @@ -731,7 +731,7 @@ void set_phy_cfg_t_scell_config(phy_cfg_t* cfg, const asn1::rrc::scell_to_add_mo // Parse Power control auto* ul_pwr_ctrl_common_scell_r10 = &ul_cfg_r10->ul_pwr_ctrl_common_scell_r10; - bzero(&cfg->ul_cfg.power_ctrl, sizeof(srslte_ue_ul_powerctrl_t)); + bzero(&cfg->ul_cfg.power_ctrl, sizeof(srsran_ue_ul_powerctrl_t)); cfg->ul_cfg.power_ctrl.p0_nominal_pusch = ul_pwr_ctrl_common_scell_r10->p0_nominal_pusch_r10; cfg->ul_cfg.power_ctrl.alpha = ul_pwr_ctrl_common_scell_r10->alpha_r10.to_number(); @@ -746,13 +746,13 @@ void set_phy_cfg_t_scell_config(phy_cfg_t* cfg, const asn1::rrc::scell_to_add_mo // Parse PUSCH auto* pusch_cfg_common = &ul_cfg_r10->pusch_cfg_common_r10; - bzero(&cfg->ul_cfg.hopping, sizeof(srslte_pusch_hopping_cfg_t)); + bzero(&cfg->ul_cfg.hopping, sizeof(srsran_pusch_hopping_cfg_t)); cfg->ul_cfg.hopping.n_sb = pusch_cfg_common->pusch_cfg_basic.n_sb; cfg->ul_cfg.hopping.hop_mode = pusch_cfg_common->pusch_cfg_basic.hop_mode.value == asn1::rrc::pusch_cfg_common_s::pusch_cfg_basic_s_::hop_mode_e_::intra_and_inter_sub_frame - ? cfg->ul_cfg.hopping.SRSLTE_PUSCH_HOP_MODE_INTRA_SF - : cfg->ul_cfg.hopping.SRSLTE_PUSCH_HOP_MODE_INTER_SF; + ? cfg->ul_cfg.hopping.SRSRAN_PUSCH_HOP_MODE_INTRA_SF + : cfg->ul_cfg.hopping.SRSRAN_PUSCH_HOP_MODE_INTER_SF; cfg->ul_cfg.hopping.hopping_offset = pusch_cfg_common->pusch_cfg_basic.pusch_hop_offset; cfg->ul_cfg.pusch.enable_64qam = pusch_cfg_common->pusch_cfg_basic.enable64_qam; } @@ -769,8 +769,8 @@ void set_phy_cfg_t_scell_config(phy_cfg_t* cfg, const asn1::rrc::scell_to_add_mo // Parse Transmission mode if (non_ul_cfg->ant_info_r10_present) { - if (non_ul_cfg->ant_info_r10.tx_mode_r10.to_number() < (uint8_t)SRSLTE_TMINV) { - cfg->dl_cfg.tm = (srslte_tm_t)non_ul_cfg->ant_info_r10.tx_mode_r10.to_number(); + if (non_ul_cfg->ant_info_r10.tx_mode_r10.to_number() < (uint8_t)SRSRAN_TMINV) { + cfg->dl_cfg.tm = (srsran_tm_t)non_ul_cfg->ant_info_r10.tx_mode_r10.to_number(); } else { fprintf(stderr, "Transmission mode (R10) %s is not supported\n", @@ -1039,7 +1039,7 @@ mcch_msg_t make_mcch_msg(const asn1::rrc::mcch_msg_s& asn1_type) } return msg; } -static_assert(ASN1_RRC_MAX_SESSION_PER_PMCH == pmch_info_t::max_session_per_pmch, "ASN1 to srsLTE interface mismatch"); +static_assert(ASN1_RRC_MAX_SESSION_PER_PMCH == pmch_info_t::max_session_per_pmch, "ASN1 to srsRAN interface mismatch"); sib13_t make_sib13(const asn1::rrc::sib_type13_r9_s& asn1_type) { @@ -1052,7 +1052,7 @@ sib13_t make_sib13(const asn1::rrc::sib_type13_r9_s& asn1_type) return sib13; } -} // namespace srslte +} // namespace srsran namespace asn1 { namespace rrc { diff --git a/lib/src/asn1/s1ap.cc b/lib/src/asn1/s1ap.cc index 9cfa6f92a..fc0275c19 100644 --- a/lib/src/asn1/s1ap.cc +++ b/lib/src/asn1/s1ap.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,7 +10,7 @@ * */ -#include "srslte/asn1/s1ap.h" +#include "srsran/asn1/s1ap.h" #include using namespace asn1; diff --git a/lib/src/common/CMakeLists.txt b/lib/src/common/CMakeLists.txt index d02aa23f3..3c6bf3104 100644 --- a/lib/src/common/CMakeLists.txt +++ b/lib/src/common/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -38,16 +38,16 @@ set(SOURCES arch_select.cc # Avoid warnings caused by libmbedtls about deprecated functions set_source_files_properties(security.cc PROPERTIES COMPILE_FLAGS -Wno-deprecated-declarations) -add_library(srslte_common STATIC ${SOURCES}) -add_custom_target(gen_build_info COMMAND cmake -P ${CMAKE_BINARY_DIR}/SRSLTEbuildinfo.cmake) -add_dependencies(srslte_common gen_build_info) +add_library(srsran_common STATIC ${SOURCES}) +add_custom_target(gen_build_info COMMAND cmake -P ${CMAKE_BINARY_DIR}/SRSRANbuildinfo.cmake) +add_dependencies(srsran_common gen_build_info) add_executable(arch_select arch_select.cc) -target_include_directories(srslte_common PUBLIC ${SEC_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR} ${BACKWARD_INCLUDE_DIRS}) -target_link_libraries(srslte_common srslte_phy srslog ${SEC_LIBRARIES} ${BACKWARD_LIBRARIES} ${SCTP_LIBRARIES}) -target_compile_definitions(srslte_common PRIVATE ${BACKWARD_DEFINITIONS}) +target_include_directories(srsran_common PUBLIC ${SEC_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR} ${BACKWARD_INCLUDE_DIRS}) +target_link_libraries(srsran_common srsran_phy srslog ${SEC_LIBRARIES} ${BACKWARD_LIBRARIES} ${SCTP_LIBRARIES}) +target_compile_definitions(srsran_common PRIVATE ${BACKWARD_DEFINITIONS}) -INSTALL(TARGETS srslte_common DESTINATION ${LIBRARY_DIR}) +INSTALL(TARGETS srsran_common DESTINATION ${LIBRARY_DIR}) add_subdirectory(test) diff --git a/lib/src/common/arch_select.cc b/lib/src/common/arch_select.cc index 0f45a1612..ab46de079 100644 --- a/lib/src/common/arch_select.cc +++ b/lib/src/common/arch_select.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/lib/src/common/backtrace.c b/lib/src/common/backtrace.c index 3064b108f..4713f83fe 100644 --- a/lib/src/common/backtrace.c +++ b/lib/src/common/backtrace.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,7 +13,7 @@ #include #include -void srslte_backtrace_print(FILE* f) +void srsran_backtrace_print(FILE* f) { void* array[128] = {}; int size = 0; diff --git a/lib/src/common/band_helper.cc b/lib/src/common/band_helper.cc index 3e04fbb0b..820b8fcb7 100644 --- a/lib/src/common/band_helper.cc +++ b/lib/src/common/band_helper.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,26 +10,26 @@ * */ -#include "srslte/common/band_helper.h" +#include "srsran/common/band_helper.h" #include -namespace srslte { +namespace srsran { // definition of static members -constexpr std::array - srslte_band_helper::nr_band_table_fr1; -constexpr std::array srslte_band_helper::nr_fr_params; +constexpr std::array + srsran_band_helper::nr_band_table_fr1; +constexpr std::array srsran_band_helper::nr_fr_params; // Formula in 5.4.2.1 -double srslte_band_helper::nr_arfcn_to_freq(uint32_t nr_arfcn) +double srsran_band_helper::nr_arfcn_to_freq(uint32_t nr_arfcn) { nr_raster_params params = get_raster_params(nr_arfcn); return (params.F_REF_Offs_MHz * 1e6 + params.delta_F_global_kHz * (nr_arfcn - params.N_REF_Offs) * 1e3); } // Implements 5.4.2.1 in TS 38.401 -std::vector srslte_band_helper::get_bands_nr(uint32_t nr_arfcn, - srslte_band_helper::delta_f_raster_t delta_f_raster) +std::vector srsran_band_helper::get_bands_nr(uint32_t nr_arfcn, + srsran_band_helper::delta_f_raster_t delta_f_raster) { std::vector bands; for (const auto& nr_band : nr_band_table_fr1) { @@ -51,7 +51,7 @@ std::vector srslte_band_helper::get_bands_nr(uint32_t return bands; } -srslte_band_helper::nr_raster_params srslte_band_helper::get_raster_params(uint32_t nr_arfcn) +srsran_band_helper::nr_raster_params srsran_band_helper::get_raster_params(uint32_t nr_arfcn) { for (auto& fr : nr_fr_params) { if (nr_arfcn >= fr.N_REF_min && nr_arfcn <= fr.N_REF_max) { @@ -61,4 +61,4 @@ srslte_band_helper::nr_raster_params srslte_band_helper::get_raster_params(uint3 return {}; // return empty params } -} // namespace srslte \ No newline at end of file +} // namespace srsran \ No newline at end of file diff --git a/lib/src/common/basic_vnf.cc b/lib/src/common/basic_vnf.cc index 5e80788af..d3ad5819b 100644 --- a/lib/src/common/basic_vnf.cc +++ b/lib/src/common/basic_vnf.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,9 +10,9 @@ * */ -#include "srslte/common/basic_vnf.h" -#include "srslte/common/buffer_pool.h" -#include "srslte/interfaces/ue_nr_interfaces.h" +#include "srsran/common/basic_vnf.h" +#include "srsran/common/buffer_pool.h" +#include "srsran/interfaces/ue_nr_interfaces.h" #include #include #include @@ -20,15 +20,15 @@ #define RAND_SEED (12314) #define RX_TIMEOUT_MS (1000) -namespace srslte { +namespace srsran { -struct srslte_pnf_info_t { +struct srsran_pnf_info_t { // TODO: fill when needed }; -struct srslte_vnf_info_t {}; +struct srsran_vnf_info_t {}; -srslte_basic_vnf::srslte_basic_vnf(const vnf_args_t& args_, stack_interface_phy_nr* stack_) : +srsran_basic_vnf::srsran_basic_vnf(const vnf_args_t& args_, stack_interface_phy_nr* stack_) : m_args(args_), thread("BASIC_VNF_P7"), m_tx_req_msg(new basic_vnf_api::tx_request_msg_t) { logger.set_level(srslog::str_to_basic_level(m_args.log_level)); @@ -48,12 +48,12 @@ srslte_basic_vnf::srslte_basic_vnf(const vnf_args_t& args_, stack_interface_phy_ } } -srslte_basic_vnf::~srslte_basic_vnf() +srsran_basic_vnf::~srsran_basic_vnf() { stop(); } -void srslte_basic_vnf::run_thread() +void srsran_basic_vnf::run_thread() { // Bind to UDP socket sockfd = socket(AF_INET, SOCK_DGRAM, 0); @@ -117,7 +117,7 @@ void srslte_basic_vnf::run_thread() logger.info("VNF thread stopped"); } -int srslte_basic_vnf::handle_msg(const uint8_t* buffer, const uint32_t len) +int srsran_basic_vnf::handle_msg(const uint8_t* buffer, const uint32_t len) { basic_vnf_api::msg_header_t* header = (basic_vnf_api::msg_header_t*)buffer; @@ -146,9 +146,9 @@ int srslte_basic_vnf::handle_msg(const uint8_t* buffer, const uint32_t len) return 0; } -int srslte_basic_vnf::handle_sf_ind(basic_vnf_api::sf_ind_msg_t* msg) +int srsran_basic_vnf::handle_sf_ind(basic_vnf_api::sf_ind_msg_t* msg) { - int ret = SRSLTE_SUCCESS; + int ret = SRSRAN_SUCCESS; logger.info("Received %s for TTI=%d", basic_vnf_api::msg_type_text[msg->header.type], msg->tti); // store Rx timestamp @@ -159,15 +159,15 @@ int srslte_basic_vnf::handle_sf_ind(basic_vnf_api::sf_ind_msg_t* msg) } else if (m_ue_stack != nullptr) { m_ue_stack->sf_indication(msg->tti); } else { - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } return ret; } -int srslte_basic_vnf::handle_dl_ind(basic_vnf_api::dl_ind_msg_t* msg) +int srsran_basic_vnf::handle_dl_ind(basic_vnf_api::dl_ind_msg_t* msg) { - int ret = SRSLTE_ERROR; + int ret = SRSRAN_ERROR; logger.info("Received %s for TTI=%d", basic_vnf_api::msg_type_text[msg->header.type], msg->tti); uint32_t cc_idx = 0; @@ -176,13 +176,13 @@ int srslte_basic_vnf::handle_dl_ind(basic_vnf_api::dl_ind_msg_t* msg) srsue::stack_interface_phy_nr::mac_nr_grant_dl_t dl_grant = {}; dl_grant.tti = msg->tti; - if (msg->nof_pdus > SRSLTE_MAX_TB) { - logger.error("Too many TBs (%d > %d)", msg->nof_pdus, SRSLTE_MAX_TB); + if (msg->nof_pdus > SRSRAN_MAX_TB) { + logger.error("Too many TBs (%d > %d)", msg->nof_pdus, SRSRAN_MAX_TB); goto exit; } for (uint32_t i = 0; i < msg->nof_pdus; ++i) { - dl_grant.tb[i] = srslte::make_byte_buffer(); + dl_grant.tb[i] = srsran::make_byte_buffer(); if (dl_grant.tb[i]->get_tailroom() >= msg->pdus[i].length) { memcpy(dl_grant.tb[i]->msg, msg->pdus[i].data, msg->pdus[i].length); dl_grant.tb[i]->N_bytes = msg->pdus[i].length; @@ -194,20 +194,20 @@ int srslte_basic_vnf::handle_dl_ind(basic_vnf_api::dl_ind_msg_t* msg) } } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; exit: return ret; } -int srslte_basic_vnf::handle_ul_ind(basic_vnf_api::ul_ind_msg_t* msg) +int srsran_basic_vnf::handle_ul_ind(basic_vnf_api::ul_ind_msg_t* msg) { logger.info("Received %s for TTI=%d", basic_vnf_api::msg_type_text[msg->header.type], msg->tti); if (msg->pdus.type != basic_vnf_api::PUSCH) { logger.error("Received UL indication for wrong PDU type"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } uint32_t cc_idx = 0; @@ -221,22 +221,22 @@ int srslte_basic_vnf::handle_ul_ind(basic_vnf_api::ul_ind_msg_t* msg) srsue::stack_interface_phy_nr::tb_action_ul_t ul_action = {}; m_ue_stack->new_grant_ul(cc_idx, ul_grant, &ul_action); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_basic_vnf::handle_rx_data_ind(basic_vnf_api::rx_data_ind_msg_t* msg) +int srsran_basic_vnf::handle_rx_data_ind(basic_vnf_api::rx_data_ind_msg_t* msg) { logger.info("Received %s for TTI=%d", basic_vnf_api::msg_type_text[msg->header.type], msg->sfn); if (msg->nof_pdus != 1 || msg->pdus[0].type != basic_vnf_api::PUSCH) { logger.error("Received UL indication for wrong PDU type"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // fill struct srsenb::stack_interface_phy_nr::rx_data_ind_t rx_data = {}; rx_data.tti = msg->sfn; - rx_data.tb = srslte::make_byte_buffer(); + rx_data.tb = srsran::make_byte_buffer(); if (rx_data.tb->get_tailroom() >= msg->pdus[0].length) { // copy actual data memcpy(rx_data.tb->msg, msg->pdus[0].data, msg->pdus[0].length); @@ -246,10 +246,10 @@ int srslte_basic_vnf::handle_rx_data_ind(basic_vnf_api::rx_data_ind_msg_t* msg) } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_basic_vnf::dl_config_request(const srsenb::phy_interface_stack_nr::dl_config_request_t& request) +int srsran_basic_vnf::dl_config_request(const srsenb::phy_interface_stack_nr::dl_config_request_t& request) { // Generate DL Config basic_vnf_api::dl_conf_msg_t dl_conf = {}; @@ -275,7 +275,7 @@ int srslte_basic_vnf::dl_config_request(const srsenb::phy_interface_stack_nr::dl } /// Tx request from UE, i.e. UL transmission -int srslte_basic_vnf::tx_request(const srsue::phy_interface_stack_nr::tx_request_t& request) +int srsran_basic_vnf::tx_request(const srsue::phy_interface_stack_nr::tx_request_t& request) { // Generate Tx request m_tx_req_msg->header.type = basic_vnf_api::TX_REQUEST; @@ -312,14 +312,14 @@ int srslte_basic_vnf::tx_request(const srsue::phy_interface_stack_nr::tx_request return 0; } -int srslte_basic_vnf::tx_request(const srsenb::phy_interface_stack_nr::tx_request_t& request) +int srsran_basic_vnf::tx_request(const srsenb::phy_interface_stack_nr::tx_request_t& request) { if (request.nof_pdus > MAX_NUM_PDUS) { logger.error("Trying to send %d PDUs but only %d supported", request.nof_pdus, MAX_NUM_PDUS); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (request.nof_pdus == 0) { - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Generate Tx request @@ -368,7 +368,7 @@ int srslte_basic_vnf::tx_request(const srsenb::phy_interface_stack_nr::tx_reques return 0; } -uint32_t srslte_basic_vnf::calc_full_msg_len(const basic_vnf_api::tx_request_msg_t& msg) +uint32_t srsran_basic_vnf::calc_full_msg_len(const basic_vnf_api::tx_request_msg_t& msg) { // start with mandatory part uint32_t len = sizeof(basic_vnf_api::msg_header_t) + 3 * sizeof(uint32_t); @@ -381,7 +381,7 @@ uint32_t srslte_basic_vnf::calc_full_msg_len(const basic_vnf_api::tx_request_msg return len; } -bool srslte_basic_vnf::stop() +bool srsran_basic_vnf::stop() { if (running) { running = false; @@ -391,4 +391,4 @@ bool srslte_basic_vnf::stop() return true; } -} // namespace srslte +} // namespace srsran diff --git a/lib/src/common/buffer_pool.cc b/lib/src/common/buffer_pool.cc index d22a28fb5..74c043da6 100644 --- a/lib/src/common/buffer_pool.cc +++ b/lib/src/common/buffer_pool.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,9 +10,9 @@ * */ -#include "srslte/common/buffer_pool.h" +#include "srsran/common/buffer_pool.h" #include #include #include -namespace srslte {} // namespace srslte +namespace srsran {} // namespace srsran diff --git a/lib/src/common/byte_buffer.cc b/lib/src/common/byte_buffer.cc index 7a46c0008..991a06036 100644 --- a/lib/src/common/byte_buffer.cc +++ b/lib/src/common/byte_buffer.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,10 +10,10 @@ * */ -#include "srslte/common/byte_buffer.h" -#include "srslte/common/buffer_pool.h" +#include "srsran/common/byte_buffer.h" +#include "srsran/common/buffer_pool.h" -namespace srslte { +namespace srsran { void* byte_buffer_t::operator new(size_t sz, const std::nothrow_t& nothrow_value) noexcept { @@ -36,4 +36,4 @@ void byte_buffer_t::operator delete(void* ptr) byte_buffer_pool::get_instance()->deallocate(ptr); } -} // namespace srslte +} // namespace srsran diff --git a/lib/src/common/crash_handler.cc b/lib/src/common/crash_handler.cc index 548081763..93b6f6466 100644 --- a/lib/src/common/crash_handler.cc +++ b/lib/src/common/crash_handler.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -15,20 +15,20 @@ #include #include -#include "srslte/common/crash_handler.h" +#include "srsran/common/crash_handler.h" #if HAVE_BACKWARD -#include "srslte/common/backward.hpp" +#include "srsran/common/backward.hpp" using namespace backward; -void srslte_debug_handle_crash(int argc, char** argv) +void srsran_debug_handle_crash(int argc, char** argv) { backward::SignalHandling sh; } #else // HAVE_BACKWARD -#include "srslte/common/backtrace.h" -#include "srslte/version.h" +#include "srsran/common/backtrace.h" +#include "srsran/version.h" -const static char crash_file_name[] = "./srsLTE.backtrace.crash"; +const static char crash_file_name[] = "./srsRAN.backtrace.crash"; static int bt_argc; static char** bt_argv; @@ -36,7 +36,7 @@ static void crash_handler(int sig) { FILE* f = fopen(crash_file_name, "a"); if (!f) { - printf("srsLTE crashed... we could not save backtrace in '%s'...\n", crash_file_name); + printf("srsRAN crashed... we could not save backtrace in '%s'...\n", crash_file_name); } else { time_t lnTime; struct tm stTime; @@ -51,19 +51,19 @@ static void crash_handler(int sig) for (int i = 0; i < bt_argc; i++) { fprintf(f, "%s%s", (i == 0) ? "" : " ", bt_argv[i]); } - fprintf(f, "' version=%s signal=%d date='%s' ---\n", SRSLTE_VERSION_STRING, sig, strdate); + fprintf(f, "' version=%s signal=%d date='%s' ---\n", SRSRAN_VERSION_STRING, sig, strdate); - srslte_backtrace_print(f); + srsran_backtrace_print(f); fprintf(f, "\n"); - printf("srsLTE crashed... backtrace saved in '%s'...\n", crash_file_name); + printf("srsRAN crashed... backtrace saved in '%s'...\n", crash_file_name); fclose(f); } printf("--- exiting ---\n"); exit(1); } -void srslte_debug_handle_crash(int argc, char** argv) +void srsran_debug_handle_crash(int argc, char** argv) { bt_argc = argc; bt_argv = argv; diff --git a/lib/src/common/enb_events.cc b/lib/src/common/enb_events.cc index 472848721..cc45fc7ce 100644 --- a/lib/src/common/enb_events.cc +++ b/lib/src/common/enb_events.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,9 +10,9 @@ * */ -#include "srslte/common/enb_events.h" -#include "srslte/srslog/context.h" -#include "srslte/srslog/log_channel.h" +#include "srsran/common/enb_events.h" +#include "srsran/srslog/context.h" +#include "srsran/srslog/log_channel.h" using namespace srsenb; diff --git a/lib/src/common/gen_mch_tables.c b/lib/src/common/gen_mch_tables.c index 1e301f6f2..25333fc81 100644 --- a/lib/src/common/gen_mch_tables.c +++ b/lib/src/common/gen_mch_tables.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,7 +10,7 @@ * */ -#include "srslte/common/gen_mch_tables.h" +#include "srsran/common/gen_mch_tables.h" /****************************************************************************** * Key Generation diff --git a/lib/src/common/liblte_security.cc b/lib/src/common/liblte_security.cc index a1ca336fc..0687b0b3b 100644 --- a/lib/src/common/liblte_security.cc +++ b/lib/src/common/liblte_security.cc @@ -15,11 +15,11 @@ INCLUDES *******************************************************************************/ -#include "srslte/common/liblte_security.h" +#include "srsran/common/liblte_security.h" #include "math.h" -#include "srslte/common/ssl.h" -#include "srslte/common/s3g.h" -#include "srslte/common/zuc.h" +#include "srsran/common/s3g.h" +#include "srsran/common/ssl.h" +#include "srsran/common/zuc.h" /******************************************************************************* LOCAL FUNCTION PROTOTYPES diff --git a/lib/src/common/mac_pcap.cc b/lib/src/common/mac_pcap.cc index 4f573d273..a258f1059 100644 --- a/lib/src/common/mac_pcap.cc +++ b/lib/src/common/mac_pcap.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,11 +10,11 @@ * */ -#include "srslte/common/mac_pcap.h" -#include "srslte/common/standard_streams.h" -#include "srslte/common/threads.h" +#include "srsran/common/mac_pcap.h" +#include "srsran/common/standard_streams.h" +#include "srsran/common/threads.h" -namespace srslte { +namespace srsran { mac_pcap::mac_pcap() : mac_pcap_base() {} mac_pcap::~mac_pcap() @@ -27,7 +27,7 @@ uint32_t mac_pcap::open(std::string filename_, uint32_t ue_id_) std::lock_guard lock(mutex); if (pcap_file != nullptr) { logger.error("PCAP writer for %s already running. Close first.", filename_.c_str()); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // set DLT for selected RAT @@ -35,7 +35,7 @@ uint32_t mac_pcap::open(std::string filename_, uint32_t ue_id_) pcap_file = LTE_PCAP_Open(dlt, filename_.c_str()); if (pcap_file == nullptr) { logger.error("Couldn't open %s to write PCAP", filename_.c_str()); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } filename = filename_; @@ -45,7 +45,7 @@ uint32_t mac_pcap::open(std::string filename_, uint32_t ue_id_) // start writer thread start(); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } uint32_t mac_pcap::close() @@ -53,7 +53,7 @@ uint32_t mac_pcap::close() { std::lock_guard lock(mutex); if (running == false || pcap_file == nullptr) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // tell writer thread to stop @@ -67,22 +67,22 @@ uint32_t mac_pcap::close() // close file handle { std::lock_guard lock(mutex); - srslte::console("Saving MAC PCAP (DLT=%d) to %s\n", dlt, filename.c_str()); + srsran::console("Saving MAC PCAP (DLT=%d) to %s\n", dlt, filename.c_str()); LTE_PCAP_Close(pcap_file); pcap_file = nullptr; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -void mac_pcap::write_pdu(srslte::mac_pcap_base::pcap_pdu_t& pdu) +void mac_pcap::write_pdu(srsran::mac_pcap_base::pcap_pdu_t& pdu) { if (pdu.pdu != nullptr) { switch (pdu.rat) { - case srslte_rat_t::lte: + case srsran_rat_t::lte: LTE_PCAP_MAC_UDP_WritePDU(pcap_file, &pdu.context, pdu.pdu->msg, pdu.pdu->N_bytes); break; - case srslte_rat_t::nr: + case srsran_rat_t::nr: NR_PCAP_MAC_UDP_WritePDU(pcap_file, &pdu.context_nr, pdu.pdu->msg, pdu.pdu->N_bytes); break; default: @@ -91,4 +91,4 @@ void mac_pcap::write_pdu(srslte::mac_pcap_base::pcap_pdu_t& pdu) } } -} // namespace srslte \ No newline at end of file +} // namespace srsran \ No newline at end of file diff --git a/lib/src/common/mac_pcap_base.cc b/lib/src/common/mac_pcap_base.cc index f89705e8d..03426e0e1 100644 --- a/lib/src/common/mac_pcap_base.cc +++ b/lib/src/common/mac_pcap_base.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,12 +10,12 @@ * */ -#include "srslte/common/mac_pcap_base.h" -#include "srslte/config.h" -#include "srslte/phy/common/phy_common.h" +#include "srsran/common/mac_pcap_base.h" +#include "srsran/config.h" +#include "srsran/phy/common/phy_common.h" #include -namespace srslte { +namespace srsran { mac_pcap_base::mac_pcap_base() : logger(srslog::fetch_basic_logger("MAC")), thread("PCAP_WRITER_MAC") {} @@ -66,7 +66,7 @@ void mac_pcap_base::pack_and_queue(uint8_t* payload, { if (running && payload != nullptr) { pcap_pdu_t pdu = {}; - pdu.rat = srslte::srslte_rat_t::lte; + pdu.rat = srsran::srsran_rat_t::lte; pdu.context.radioType = FDD_RADIO; pdu.context.direction = direction; pdu.context.rntiType = rnti_type; @@ -79,7 +79,7 @@ void mac_pcap_base::pack_and_queue(uint8_t* payload, pdu.context.subFrameNumber = (uint16_t)(tti % 10); // try to allocate PDU buffer - pdu.pdu = srslte::make_byte_buffer(); + pdu.pdu = srsran::make_byte_buffer(); if (pdu.pdu != nullptr && pdu.pdu->get_tailroom() >= payload_len) { // copy payload into PDU buffer memcpy(pdu.pdu->msg, payload, payload_len); @@ -105,7 +105,7 @@ void mac_pcap_base::pack_and_queue_nr(uint8_t* payload, { if (running && payload != nullptr) { pcap_pdu_t pdu = {}; - pdu.rat = srslte_rat_t::nr; + pdu.rat = srsran_rat_t::nr; pdu.context_nr.radioType = FDD_RADIO; pdu.context_nr.direction = direction; pdu.context_nr.rntiType = rnti_type; @@ -116,7 +116,7 @@ void mac_pcap_base::pack_and_queue_nr(uint8_t* payload, pdu.context_nr.sub_frame_number = tti % 10; // try to allocate PDU buffer - pdu.pdu = srslte::make_byte_buffer(); + pdu.pdu = srsran::make_byte_buffer(); if (pdu.pdu != nullptr && pdu.pdu->get_tailroom() >= payload_len) { // copy payload into PDU buffer memcpy(pdu.pdu->msg, payload, payload_len); @@ -196,15 +196,15 @@ void mac_pcap_base::write_dl_bch(uint8_t* pdu, uint32_t pdu_len_bytes, bool crc_ } void mac_pcap_base::write_dl_pch(uint8_t* pdu, uint32_t pdu_len_bytes, bool crc_ok, uint32_t tti, uint8_t cc_idx) { - pack_and_queue(pdu, pdu_len_bytes, ue_id, 0, crc_ok, cc_idx, tti, SRSLTE_PRNTI, DIRECTION_DOWNLINK, P_RNTI); + pack_and_queue(pdu, pdu_len_bytes, ue_id, 0, crc_ok, cc_idx, tti, SRSRAN_PRNTI, DIRECTION_DOWNLINK, P_RNTI); } void mac_pcap_base::write_dl_mch(uint8_t* pdu, uint32_t pdu_len_bytes, bool crc_ok, uint32_t tti, uint8_t cc_idx) { - pack_and_queue(pdu, pdu_len_bytes, ue_id, 0, crc_ok, cc_idx, tti, SRSLTE_MRNTI, DIRECTION_DOWNLINK, M_RNTI); + pack_and_queue(pdu, pdu_len_bytes, ue_id, 0, crc_ok, cc_idx, tti, SRSRAN_MRNTI, DIRECTION_DOWNLINK, M_RNTI); } void mac_pcap_base::write_dl_sirnti(uint8_t* pdu, uint32_t pdu_len_bytes, bool crc_ok, uint32_t tti, uint8_t cc_idx) { - pack_and_queue(pdu, pdu_len_bytes, ue_id, 0, crc_ok, cc_idx, tti, SRSLTE_SIRNTI, DIRECTION_DOWNLINK, SI_RNTI); + pack_and_queue(pdu, pdu_len_bytes, ue_id, 0, crc_ok, cc_idx, tti, SRSRAN_SIRNTI, DIRECTION_DOWNLINK, SI_RNTI); } void mac_pcap_base::write_dl_crnti_nr(uint8_t* pdu, uint32_t pdu_len_bytes, uint16_t rnti, uint8_t harqid, uint32_t tti) @@ -337,4 +337,4 @@ void mac_pcap_base::write_ul_rrc_pdu(const uint8_t* input, const int32_t input_l write_ul_crnti(pdu, pdu_ptr - pdu, 14931, true, 0, 0); } -} // namespace srslte +} // namespace srsran diff --git a/lib/src/common/mac_pcap_net.cc b/lib/src/common/mac_pcap_net.cc index 08352e25d..e651b9b39 100644 --- a/lib/src/common/mac_pcap_net.cc +++ b/lib/src/common/mac_pcap_net.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,9 +10,9 @@ * */ -#include "srslte/common/mac_pcap_net.h" +#include "srsran/common/mac_pcap_net.h" -namespace srslte { +namespace srsran { mac_pcap_net::mac_pcap_net() : mac_pcap_base() {} @@ -30,18 +30,18 @@ uint32_t mac_pcap_net::open(std::string client_ip_addr_, if (socket.is_init()) { logger.error("PCAP socket writer for %s already running. Close first.", bind_addr_str.c_str()); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (not socket.open_socket( net_utils::addr_family::ipv4, net_utils::socket_type::datagram, net_utils::protocol_type::UDP)) { logger.error("Couldn't open socket %s to write PCAP", bind_addr_str.c_str()); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (not socket.bind_addr(bind_addr_str.c_str(), bind_udp_port_)) { socket.reset(); logger.error("Couldn't bind socket %s to write PCAP", bind_addr_str.c_str()); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } logger.info("Sending MAC PCAP frames to %s:%d (from %s:%d)", @@ -57,7 +57,7 @@ uint32_t mac_pcap_net::open(std::string client_ip_addr_, // start writer thread start(); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } uint32_t mac_pcap_net::close() @@ -65,7 +65,7 @@ uint32_t mac_pcap_net::close() { std::lock_guard lock(mutex); if (running == false || socket.is_init() == false) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // tell writer thread to stop @@ -81,17 +81,17 @@ uint32_t mac_pcap_net::close() socket.close(); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } void mac_pcap_net::write_pdu(pcap_pdu_t& pdu) { if (pdu.pdu != nullptr && socket.is_init()) { switch (pdu.rat) { - case srslte_rat_t::lte: + case srsran_rat_t::lte: write_mac_lte_pdu_to_net(pdu); break; - case srslte_rat_t::nr: + case srsran_rat_t::nr: write_mac_nr_pdu_to_net(pdu); break; default: @@ -167,4 +167,4 @@ void mac_pcap_net::write_mac_nr_pdu_to_net(pcap_pdu_t& pdu) "Sending UDP packet mismatches %d != %d (err %s)", pdu.pdu.get()->N_bytes, bytes_sent, strerror(errno)); } } -} // namespace srslte \ No newline at end of file +} // namespace srsran \ No newline at end of file diff --git a/lib/src/common/nas_pcap.cc b/lib/src/common/nas_pcap.cc index 47c987125..05ff76ca5 100644 --- a/lib/src/common/nas_pcap.cc +++ b/lib/src/common/nas_pcap.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,12 +10,12 @@ * */ -#include "srslte/common/nas_pcap.h" -#include "srslte/common/pcap.h" -#include "srslte/srslte.h" +#include "srsran/common/nas_pcap.h" +#include "srsran/common/pcap.h" +#include "srsran/srsran.h" #include -namespace srslte { +namespace srsran { void nas_pcap::enable() { @@ -27,11 +27,11 @@ uint32_t nas_pcap::open(std::string filename_, uint32_t ue_id_) filename = filename_; pcap_file = LTE_PCAP_Open(NAS_LTE_DLT, filename.c_str()); if (pcap_file == nullptr) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } ue_id = ue_id_; enable_write = true; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } void nas_pcap::close() @@ -50,4 +50,4 @@ void nas_pcap::write_nas(uint8_t* pdu, uint32_t pdu_len_bytes) } } -} // namespace srslte +} // namespace srsran diff --git a/lib/src/common/network_utils.cc b/lib/src/common/network_utils.cc index 3356af1f9..47a1a4558 100644 --- a/lib/src/common/network_utils.cc +++ b/lib/src/common/network_utils.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,7 +10,7 @@ * */ -#include "srslte/common/network_utils.h" +#include "srsran/common/network_utils.h" #include #include @@ -21,7 +21,7 @@ #define rxSockInfo(fmt, ...) logger.info("%s: " fmt, name.c_str(), ##__VA_ARGS__) #define rxSockDebug(fmt, ...) logger.debug("%s: " fmt, name.c_str(), ##__VA_ARGS__) -namespace srslte { +namespace srsran { const char* LOGSERVICE = "COMN"; @@ -408,12 +408,12 @@ int tcp_send(int remotefd, const void* buf, size_t nbytes) class recvfrom_pdu_task final : public rx_multisocket_handler::recv_task { public: - using callback_t = std::function; + using callback_t = std::function; explicit recvfrom_pdu_task(srslog::basic_logger& logger, callback_t func_) : logger(logger), func(std::move(func_)) {} bool operator()(int fd) override { - srslte::unique_byte_buffer_t pdu = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t pdu = srsran::make_byte_buffer(); if (pdu == nullptr) { logger.error("Unable to allocate byte buffer"); return true; @@ -445,7 +445,7 @@ class sctp_recvmsg_pdu_task final : public rx_multisocket_handler::recv_task { public: using callback_t = std::function< - void(srslte::unique_byte_buffer_t pdu, const sockaddr_in& from, const sctp_sndrcvinfo& sri, int flags)>; + void(srsran::unique_byte_buffer_t pdu, const sockaddr_in& from, const sctp_sndrcvinfo& sri, int flags)>; explicit sctp_recvmsg_pdu_task(srslog::basic_logger& logger, callback_t func_) : logger(logger), func(std::move(func_)) {} @@ -453,7 +453,7 @@ public: bool operator()(int fd) override { // inside rx_sockets thread. Read socket - srslte::unique_byte_buffer_t pdu = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t pdu = srsran::make_byte_buffer(); if (pdu == nullptr) { logger.error("Unable to allocate byte buffer"); return true; @@ -534,8 +534,8 @@ void rx_multisocket_handler::stop() */ bool rx_multisocket_handler::add_socket_pdu_handler(int fd, recvfrom_callback_t pdu_task) { - std::unique_ptr task; - task.reset(new srslte::recvfrom_pdu_task(logger, std::move(pdu_task))); + std::unique_ptr task; + task.reset(new srsran::recvfrom_pdu_task(logger, std::move(pdu_task))); return add_socket_handler(fd, std::move(task)); } @@ -544,8 +544,8 @@ bool rx_multisocket_handler::add_socket_pdu_handler(int fd, recvfrom_callback_t */ bool rx_multisocket_handler::add_socket_sctp_pdu_handler(int fd, sctp_recv_callback_t pdu_task) { - srslte::rx_multisocket_handler::task_callback_t task; - task.reset(new srslte::sctp_recvmsg_pdu_task(logger, std::move(pdu_task))); + srsran::rx_multisocket_handler::task_callback_t task; + task.reset(new srsran::sctp_recvmsg_pdu_task(logger, std::move(pdu_task))); return add_socket_handler(fd, std::move(task)); } @@ -686,4 +686,4 @@ void rx_multisocket_handler::run_thread() } } -} // namespace srslte +} // namespace srsran diff --git a/lib/src/common/pcap.c b/lib/src/common/pcap.c index 0db6d10d5..d51727551 100644 --- a/lib/src/common/pcap.c +++ b/lib/src/common/pcap.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,7 +10,7 @@ * */ -#include "srslte/common/pcap.h" +#include "srsran/common/pcap.h" #include #include #include diff --git a/lib/src/common/rlc_pcap.cc b/lib/src/common/rlc_pcap.cc index 26d8d6959..a0878bb76 100644 --- a/lib/src/common/rlc_pcap.cc +++ b/lib/src/common/rlc_pcap.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,12 +10,12 @@ * */ -#include "srslte/common/rlc_pcap.h" -#include "srslte/common/pcap.h" -#include "srslte/srslte.h" +#include "srsran/common/rlc_pcap.h" +#include "srsran/common/pcap.h" +#include "srsran/srsran.h" #include -namespace srslte { +namespace srsran { void rlc_pcap::enable(bool en) { @@ -94,4 +94,4 @@ void rlc_pcap::write_ul_ccch(uint8_t* pdu, uint32_t pdu_len_bytes) pack_and_write(pdu, pdu_len_bytes, mode, DIRECTION_UPLINK, priority, sn_length, ue_id, CHANNEL_TYPE_CCCH, channel_id); } -} // namespace srslte +} // namespace srsran diff --git a/lib/src/common/s1ap_pcap.cc b/lib/src/common/s1ap_pcap.cc index b6260e523..fd192344b 100644 --- a/lib/src/common/s1ap_pcap.cc +++ b/lib/src/common/s1ap_pcap.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,12 +10,12 @@ * */ -#include "srslte/common/s1ap_pcap.h" -#include "srslte/common/pcap.h" -#include "srslte/srslte.h" +#include "srsran/common/s1ap_pcap.h" +#include "srsran/common/pcap.h" +#include "srsran/srsran.h" #include -namespace srslte { +namespace srsran { void s1ap_pcap::enable() { @@ -42,4 +42,4 @@ void s1ap_pcap::write_s1ap(uint8_t* pdu, uint32_t pdu_len_bytes) } } -} // namespace srslte +} // namespace srsran diff --git a/lib/src/common/s3g.cc b/lib/src/common/s3g.cc index 0e0c76a69..4964dd419 100644 --- a/lib/src/common/s3g.cc +++ b/lib/src/common/s3g.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,7 +10,7 @@ * */ -#include "srslte/common/s3g.h" +#include "srsran/common/s3g.h" /* S-box SQ */ static const uint8_t SQ[256] = { diff --git a/lib/src/common/security.cc b/lib/src/common/security.cc index 16ce13669..7252c0385 100644 --- a/lib/src/common/security.cc +++ b/lib/src/common/security.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,10 +10,10 @@ * */ -#include "srslte/common/security.h" -#include "srslte/common/liblte_security.h" -#include "srslte/common/s3g.h" -#include "srslte/config.h" +#include "srsran/common/security.h" +#include "srsran/common/liblte_security.h" +#include "srsran/common/s3g.h" +#include "srsran/config.h" #ifdef HAVE_MBEDTLS #include "mbedtls/md5.h" @@ -22,7 +22,7 @@ #include "polarssl/md5.h" #endif -namespace srslte { +namespace srsran { /****************************************************************************** * Key Generation @@ -170,7 +170,7 @@ uint8_t security_md5(const uint8_t* input, size_t len, uint8_t* output) #ifdef HAVE_POLARSSL md5(input, len, output); #endif - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } /****************************************************************************** @@ -242,4 +242,4 @@ uint8_t security_milenage_f5_star(uint8_t* k, uint8_t* op, uint8_t* rand, uint8_ return liblte_security_milenage_f5_star(k, op, rand, ak); } -} // namespace srslte +} // namespace srsran diff --git a/lib/src/common/standard_streams.cc b/lib/src/common/standard_streams.cc index 0b61e6066..c29beddc4 100644 --- a/lib/src/common/standard_streams.cc +++ b/lib/src/common/standard_streams.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,13 +10,13 @@ * */ -#include "srslte/common/standard_streams.h" +#include "srsran/common/standard_streams.h" #include #include -using namespace srslte; +using namespace srsran; -void srslte::console(const char* str, ...) +void srsran::console(const char* str, ...) { std::va_list args; va_start(args, str); @@ -27,7 +27,7 @@ void srslte::console(const char* str, ...) va_end(args); } -void srslte::console_stderr(const char* str, ...) +void srsran::console_stderr(const char* str, ...) { std::va_list args; va_start(args, str); diff --git a/lib/src/common/test/CMakeLists.txt b/lib/src/common/test/CMakeLists.txt index cec9f2306..53acc0465 100644 --- a/lib/src/common/test/CMakeLists.txt +++ b/lib/src/common/test/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -8,14 +8,14 @@ add_executable(thread_pool_test thread_pool_test.cc) target_link_libraries(thread_pool_test - srslte_common) + srsran_common) add_test(thread_pool_test thread_pool_test) add_executable(thread_test thread_test.cc) target_link_libraries(thread_test - srslte_common) + srsran_common) add_test(thread_test thread_test) add_executable(band_helper_test band_helper_test.cc) -target_link_libraries(band_helper_test srslte_common) +target_link_libraries(band_helper_test srsran_common) add_test(band_helper_test band_helper_test) \ No newline at end of file diff --git a/lib/src/common/test/band_helper_test.cc b/lib/src/common/test/band_helper_test.cc index fb8064479..ac7e3310a 100644 --- a/lib/src/common/test/band_helper_test.cc +++ b/lib/src/common/test/band_helper_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,12 +10,12 @@ * */ -#include "srslte/common/band_helper.h" -#include "srslte/common/test_common.h" +#include "srsran/common/band_helper.h" +#include "srsran/common/test_common.h" int bands_test_nr() { - srslte::srslte_band_helper bands; + srsran::srsran_band_helper bands; TESTASSERT(bands.nr_arfcn_to_freq(632628) == 3489.42e6); @@ -34,15 +34,15 @@ int bands_test_nr() // Invalid configs // For 30 kHz, 620001 is not a valid ARFCN, only every 2nd - band_vector = bands.get_bands_nr(620001, srslte::srslte_band_helper::KHZ_30); + band_vector = bands.get_bands_nr(620001, srsran::srsran_band_helper::KHZ_30); TESTASSERT(band_vector.empty()); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int main(int argc, char** argv) { - TESTASSERT(bands_test_nr() == SRSLTE_SUCCESS); + TESTASSERT(bands_test_nr() == SRSRAN_SUCCESS); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } \ No newline at end of file diff --git a/lib/src/common/test/thread_pool_test.cc b/lib/src/common/test/thread_pool_test.cc index fb4d8b05d..f5967ccf8 100644 --- a/lib/src/common/test/thread_pool_test.cc +++ b/lib/src/common/test/thread_pool_test.cc @@ -2,18 +2,18 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of * the distribution. * */ -#include "srslte/common/common.h" -#include "srslte/common/thread_pool.h" -#include "srslte/common/tti_sempahore.h" -#include "srslte/phy/utils/random.h" -#include "srslte/srslog/srslog.h" +#include "srsran/common/common.h" +#include "srsran/common/thread_pool.h" +#include "srsran/common/tti_sempahore.h" +#include "srsran/phy/utils/random.h" +#include "srsran/srslog/srslog.h" class dummy_radio { @@ -52,32 +52,32 @@ public: bool is_late() { return late; } }; -class dummy_worker : public srslte::thread_pool::worker +class dummy_worker : public srsran::thread_pool::worker { private: static const int sleep_time_min_us = 50; static const int sleep_time_max_us = 2000; srslog::basic_logger& logger; - srslte::tti_semaphore* tti_semaphore = nullptr; + srsran::tti_semaphore* tti_semaphore = nullptr; dummy_radio* radio = nullptr; - srslte_random_t random_gen = nullptr; + srsran_random_t random_gen = nullptr; uint32_t tti = 0; public: dummy_worker(uint32_t id, - srslte::tti_semaphore* tti_semaphore_, + srsran::tti_semaphore* tti_semaphore_, srslog::basic_logger& logger, dummy_radio* radio_) : logger(logger) { tti_semaphore = tti_semaphore_; radio = radio_; - random_gen = srslte_random_init(id); + random_gen = srsran_random_init(id); logger.info("Dummy worker created"); } - ~dummy_worker() { srslte_random_free(random_gen); } + ~dummy_worker() { srsran_random_free(random_gen); } void set_tti(uint32_t tti_) { tti = tti_; } @@ -85,7 +85,7 @@ protected: void work_imp() override { // Choose a random time to work - int sleep_time_us = srslte_random_uniform_int_dist(random_gen, sleep_time_min_us, sleep_time_max_us); + int sleep_time_us = srsran_random_uniform_int_dist(random_gen, sleep_time_min_us, sleep_time_max_us); // Inform @@ -107,18 +107,18 @@ protected: int main(int argc, char** argv) { - int ret = SRSLTE_SUCCESS; + int ret = SRSRAN_SUCCESS; // Simulation Constants const uint32_t nof_workers = FDD_HARQ_DELAY_UL_MS; const uint32_t nof_tti = 10240; const float enable_probability = 0.9f; - srslte_random_t random_gen = srslte_random_init(1234); + srsran_random_t random_gen = srsran_random_init(1234); // Pools and workers - srslte::thread_pool pool(nof_workers); + srsran::thread_pool pool(nof_workers); std::vector > workers; - srslte::tti_semaphore tti_semaphore; + srsran::tti_semaphore tti_semaphore; // Loggers. auto& radio_logger = srslog::fetch_basic_logger("radio", false); @@ -150,7 +150,7 @@ int main(int argc, char** argv) } for (uint32_t tti = 0; tti < nof_tti && !radio.is_late(); tti++) { - if (enable_probability > srslte_random_uniform_real_dist(random_gen, 0.0f, 1.0f)) { + if (enable_probability > srsran_random_uniform_real_dist(random_gen, 0.0f, 1.0f)) { // Wait worker auto worker = (dummy_worker*)pool.wait_worker(tti); @@ -164,12 +164,12 @@ int main(int argc, char** argv) } if (radio.is_late()) { - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } tti_semaphore.wait_all(); pool.stop(); - srslte_random_free(random_gen); + srsran_random_free(random_gen); return ret; } diff --git a/lib/src/common/test/thread_test.cc b/lib/src/common/test/thread_test.cc index 5137f5720..c575e5f48 100644 --- a/lib/src/common/test/thread_test.cc +++ b/lib/src/common/test/thread_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,9 +11,9 @@ */ #include -#include +#include -class thread_test : public srslte::thread +class thread_test : public srsran::thread { public: thread_test() : thread("Thread Test") {} diff --git a/lib/src/common/thread_pool.cc b/lib/src/common/thread_pool.cc index ee47d1264..7aa8ab9d9 100644 --- a/lib/src/common/thread_pool.cc +++ b/lib/src/common/thread_pool.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,8 +10,8 @@ * */ -#include "srslte/common/thread_pool.h" -#include "srslte/srslog/srslog.h" +#include "srsran/common/thread_pool.h" +#include "srsran/srslog/srslog.h" #include #include #include @@ -23,7 +23,7 @@ printf(fmt, __VA_ARGS__); \ } while (0) -namespace srslte { +namespace srsran { thread_pool::worker::worker() : thread("THREAD_POOL_WORKER") {} @@ -326,7 +326,7 @@ uint32_t task_thread_pool::nof_pending_tasks() const return pending_tasks.size(); } -task_thread_pool::worker_t::worker_t(srslte::task_thread_pool* parent_, uint32_t my_id) : +task_thread_pool::worker_t::worker_t(srsran::task_thread_pool* parent_, uint32_t my_id) : parent(parent_), thread(std::string("TASKWORKER") + std::to_string(my_id)), id_(my_id), running(true) { if (parent->mask == 255) { @@ -377,4 +377,4 @@ task_thread_pool& get_background_workers() return background_workers; } -} // namespace srslte +} // namespace srsran diff --git a/lib/src/common/threads.c b/lib/src/common/threads.c index 8c4951a53..a53aebfa8 100644 --- a/lib/src/common/threads.c +++ b/lib/src/common/threads.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -17,7 +17,7 @@ #include #include -#include "srslte/common/threads.h" +#include "srsran/common/threads.h" bool threads_new_rt(pthread_t* thread, void* (*start_routine)(void*), void* arg) { diff --git a/lib/src/common/time_prof.cc b/lib/src/common/time_prof.cc index 12b495273..29bc5e3f4 100644 --- a/lib/src/common/time_prof.cc +++ b/lib/src/common/time_prof.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,12 +10,12 @@ * */ -#include "srslte/common/time_prof.h" +#include "srsran/common/time_prof.h" #include #include #include -using namespace srslte; +using namespace srsran; using std::chrono::nanoseconds; // log utils @@ -104,5 +104,5 @@ void sliding_window_stats::operator()(nanoseconds duration) } } -template class srslte::sliding_window_stats; -template class srslte::sliding_window_stats; +template class srsran::sliding_window_stats; +template class srsran::sliding_window_stats; diff --git a/lib/src/common/tti_sync_cv.cc b/lib/src/common/tti_sync_cv.cc index a147b94b0..ef0521139 100644 --- a/lib/src/common/tti_sync_cv.cc +++ b/lib/src/common/tti_sync_cv.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -12,9 +12,9 @@ #include -#include "srslte/common/tti_sync_cv.h" +#include "srsran/common/tti_sync_cv.h" -namespace srslte { +namespace srsran { tti_sync_cv::tti_sync_cv(uint32_t modulus) : tti_sync(modulus) { @@ -71,4 +71,4 @@ void tti_sync_cv::increase(uint32_t tti) pthread_cond_signal(&cond); pthread_mutex_unlock(&mutex); } -} // namespace srslte +} // namespace srsran diff --git a/lib/src/common/version.c b/lib/src/common/version.c index 5605b51a7..3fe3985aa 100644 --- a/lib/src/common/version.c +++ b/lib/src/common/version.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,27 +10,27 @@ * */ -#include "srslte/version.h" +#include "srsran/version.h" -char* srslte_get_version() +char* srsran_get_version() { - return SRSLTE_VERSION_STRING; + return SRSRAN_VERSION_STRING; } -int srslte_get_version_major() +int srsran_get_version_major() { - return SRSLTE_VERSION_MAJOR; + return SRSRAN_VERSION_MAJOR; } -int srslte_get_version_minor() +int srsran_get_version_minor() { - return SRSLTE_VERSION_MINOR; + return SRSRAN_VERSION_MINOR; } -int srslte_get_version_patch() +int srsran_get_version_patch() { - return SRSLTE_VERSION_PATCH; + return SRSRAN_VERSION_PATCH; } -int srslte_check_version(int major, int minor, int patch) +int srsran_check_version(int major, int minor, int patch) { - return (SRSLTE_VERSION >= SRSLTE_VERSION_ENCODE(major, minor, patch)); + return (SRSRAN_VERSION >= SRSRAN_VERSION_ENCODE(major, minor, patch)); } diff --git a/lib/src/common/zuc.cc b/lib/src/common/zuc.cc index 1385eee0d..7569bab7c 100644 --- a/lib/src/common/zuc.cc +++ b/lib/src/common/zuc.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -20,7 +20,7 @@ ---------------------------------------------------------*/ -#include "srslte/common/zuc.h" +#include "srsran/common/zuc.h" #define MAKEU32(a, b, c, d) (((u32)(a) << 24) | ((u32)(b) << 16) | ((u32)(c) << 8) | ((u32)(d))) #define MulByPow2(x, k) ((((x) << k) | ((x) >> (31 - k))) & 0x7FFFFFFF) diff --git a/lib/src/mac/CMakeLists.txt b/lib/src/mac/CMakeLists.txt index 4d73f3327..0a14d0143 100644 --- a/lib/src/mac/CMakeLists.txt +++ b/lib/src/mac/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -8,6 +8,6 @@ SET(SOURCES pdu.cc pdu_queue.cc mac_sch_pdu_nr.cc mac_rar_pdu_nr.cc) -add_library(srslte_mac STATIC ${SOURCES}) -target_link_libraries(srslte_mac srslte_common) -INSTALL(TARGETS srslte_mac DESTINATION ${LIBRARY_DIR}) \ No newline at end of file +add_library(srsran_mac STATIC ${SOURCES}) +target_link_libraries(srsran_mac srsran_common) +INSTALL(TARGETS srsran_mac DESTINATION ${LIBRARY_DIR}) \ No newline at end of file diff --git a/lib/src/mac/mac_rar_pdu_nr.cc b/lib/src/mac/mac_rar_pdu_nr.cc index f456101e8..4ede54530 100644 --- a/lib/src/mac/mac_rar_pdu_nr.cc +++ b/lib/src/mac/mac_rar_pdu_nr.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,16 +10,16 @@ * */ -#include "srslte/mac/mac_rar_pdu_nr.h" +#include "srsran/mac/mac_rar_pdu_nr.h" #include #ifdef __cplusplus extern "C" { -#include "srslte/phy/utils/bit.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/utils/bit.h" +#include "srsran/phy/utils/vector.h" } #endif -namespace srslte { +namespace srsran { mac_rar_subpdu_nr::mac_rar_subpdu_nr(mac_rar_pdu_nr* parent_) : parent(parent_), logger(srslog::fetch_basic_logger("MAC")) @@ -50,9 +50,9 @@ bool mac_rar_subpdu_nr::read_subpdu(const uint8_t* ptr) ul_grant.at(2) = *(rar + 1) & 0x1 ? 1 : 0; // And now the remaining 3 full octets uint8_t* x = &ul_grant.at(3); - srslte_bit_unpack(*(rar + 2), &x, 8); - srslte_bit_unpack(*(rar + 3), &x, 8); - srslte_bit_unpack(*(rar + 4), &x, 8); + srsran_bit_unpack(*(rar + 2), &x, 8); + srsran_bit_unpack(*(rar + 3), &x, 8); + srsran_bit_unpack(*(rar + 4), &x, 8); // Temp CRNTI is octet 6 + 7 temp_crnti = ((uint16_t) * (rar + 5)) << 8 | *(rar + 6); payload_length = MAC_RAR_NBYTES; @@ -136,7 +136,7 @@ std::string mac_rar_subpdu_nr::to_string() } char tmp[16] = {}; - srslte_vec_sprint_hex(tmp, sizeof(tmp), ul_grant.data(), UL_GRANT_NBITS); + srsran_vec_sprint_hex(tmp, sizeof(tmp), ul_grant.data(), UL_GRANT_NBITS); ss << tmp; return ss.str(); @@ -216,4 +216,4 @@ std::string mac_rar_pdu_nr::to_string() return ss.str(); } -} // namespace srslte +} // namespace srsran diff --git a/lib/src/mac/mac_sch_pdu_nr.cc b/lib/src/mac/mac_sch_pdu_nr.cc index 070b8ef23..6abefe968 100644 --- a/lib/src/mac/mac_sch_pdu_nr.cc +++ b/lib/src/mac/mac_sch_pdu_nr.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,9 +10,9 @@ * */ -#include "srslte/mac/mac_sch_pdu_nr.h" +#include "srsran/mac/mac_sch_pdu_nr.h" -namespace srslte { +namespace srsran { mac_sch_subpdu_nr::mac_sch_subpdu_nr(mac_sch_pdu_nr* parent_) : parent(parent_) {} @@ -42,7 +42,7 @@ bool mac_sch_subpdu_nr::is_var_len_ce() return false; } -// return length of PDU (or SRSLTE_ERROR otherwise) +// return length of PDU (or SRSRAN_ERROR otherwise) int32_t mac_sch_subpdu_nr::read_subheader(const uint8_t* ptr) { // Skip R, read F bit and LCID @@ -70,7 +70,7 @@ int32_t mac_sch_subpdu_nr::read_subheader(const uint8_t* ptr) sdu = (uint8_t*)ptr; } else { srslog::fetch_basic_logger("MAC").warning("Invalid LCID (%d) in MAC PDU", lcid); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } return header_length; } @@ -287,7 +287,7 @@ void mac_sch_pdu_nr::unpack(const uint8_t* payload, const uint32_t& len) uint32_t offset = 0; while (offset < len) { mac_sch_subpdu_nr sch_pdu(this); - if (sch_pdu.read_subheader(payload + offset) == SRSLTE_ERROR) { + if (sch_pdu.read_subheader(payload + offset) == SRSRAN_ERROR) { fprintf(stderr, "Error parsing NR MAC PDU (len=%d, offset=%d)\n", len, offset); return; } @@ -361,7 +361,7 @@ uint32_t mac_sch_pdu_nr::add_sdu(const uint32_t lcid_, const uint8_t* payload_, int header_size = size_header_sdu(lcid_, len_); if (header_size + len_ > remaining_len) { printf("Header and SDU exceed space in PDU (%d > %d).\n", header_size + len_, remaining_len); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } mac_sch_subpdu_nr sch_pdu(this); @@ -395,7 +395,7 @@ uint32_t mac_sch_pdu_nr::add_sudpdu(mac_sch_subpdu_nr& subpdu) uint32_t subpdu_len = subpdu.get_total_length(); if (subpdu_len > remaining_len) { logger.warning("Not enough space to add subPDU to PDU (%d > %d)", subpdu_len, remaining_len); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Write subPDU straigt into provided buffer @@ -406,7 +406,7 @@ uint32_t mac_sch_pdu_nr::add_sudpdu(mac_sch_subpdu_nr& subpdu) remaining_len -= subpdu_len; subpdus.push_back(subpdu); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -} // namespace srslte +} // namespace srsran diff --git a/lib/src/mac/pdu.cc b/lib/src/mac/pdu.cc index ca8c9658e..844a32a5b 100644 --- a/lib/src/mac/pdu.cc +++ b/lib/src/mac/pdu.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -15,12 +15,12 @@ #include #include -#include "srslte/common/standard_streams.h" -#include "srslte/mac/pdu.h" +#include "srsran/common/standard_streams.h" +#include "srsran/mac/pdu.h" extern "C" { -#include "srslte/phy/utils/bit.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/utils/bit.h" +#include "srsran/phy/utils/vector.h" } // Table 6.1.3.1-1 Buffer size levels for BSR @@ -30,7 +30,7 @@ static uint32_t btable[64] = { 1132, 1326, 1552, 1817, 2127, 2490, 2915, 3413, 3995, 4667, 5476, 6411, 7505, 8787, 10287, 12043, 14099, 16507, 19325, 22624, 26487, 31009, 36304, 42502, 49759, 58255, 68201, 79846, 93479, 109439, 128125, 150000}; -namespace srslte { +namespace srsran { /************************* * DL-SCH LCID @@ -172,11 +172,11 @@ const char* lcid_t::to_string() const { switch (type) { case ch_type::dl_sch: - return srslte::to_string(dl_sch); + return srsran::to_string(dl_sch); case ch_type::ul_sch: - return srslte::to_string(ul_sch); + return srsran::to_string(ul_sch); case ch_type::mch: - return srslte::to_string(mch); + return srsran::to_string(mch); default: return "unrecognized lcid type\n"; } @@ -186,11 +186,11 @@ bool lcid_t::is_sdu() const { switch (type) { case ch_type::dl_sch: - return srslte::is_sdu(dl_sch); + return srsran::is_sdu(dl_sch); case ch_type::ul_sch: - return srslte::is_sdu(ul_sch); + return srsran::is_sdu(ul_sch); case ch_type::mch: - return srslte::is_sdu(mch); + return srsran::is_sdu(mch); default: return false; } @@ -353,8 +353,8 @@ uint8_t* sch_pdu::write_packet(srslog::basic_logger& log) num_padding); if (buffer_tx->N_bytes != pdu_len) { - srslte::console("------------------------------\n"); - srslte::console("Wrote PDU: pdu_len=%d, expected_pdu_len=%d, header_and_ce=%d (%d+%d), nof_subh=%d, last_sdu=%d, " + srsran::console("------------------------------\n"); + srsran::console("Wrote PDU: pdu_len=%d, expected_pdu_len=%d, header_and_ce=%d (%d+%d), nof_subh=%d, last_sdu=%d, " "onepad=%d, multi=%d\n", buffer_tx->N_bytes, pdu_len, @@ -365,7 +365,7 @@ uint8_t* sch_pdu::write_packet(srslog::basic_logger& log) last_sdu_idx, onetwo_padding, num_padding); - srslte::console("------------------------------\n"); + srsran::console("------------------------------\n"); log.error( "Wrote PDU: pdu_len=%d, expected_pdu_len=%d, header_and_ce=%d (%d+%d), nof_subh=%d, last_sdu=%d, onepad=%d, " @@ -476,7 +476,7 @@ int sch_pdu::get_sdu_space() void sch_subh::init() { - srslte_vec_u8_zero(w_payload_ce, 64); + srsran_vec_u8_zero(w_payload_ce, 64); payload = w_payload_ce; lcid = 0; nof_bytes = 0; @@ -752,7 +752,7 @@ bool sch_subh::set_ta_cmd(uint8_t ta_cmd) } } -bool sch_subh::set_scell_activation_cmd(const std::array& active_scell_idxs) +bool sch_subh::set_scell_activation_cmd(const std::array& active_scell_idxs) { const uint32_t nof_octets = 1; if (not((sch_pdu*)parent)->has_space_ce(nof_octets)) { @@ -760,7 +760,7 @@ bool sch_subh::set_scell_activation_cmd(const std::array(active_scell_idxs[i]) << i); } lcid = (uint32_t)dl_sch_lcid::SCELL_ACTIVATION; @@ -794,7 +794,7 @@ int sch_subh::set_sdu(uint32_t lcid_, uint32_t requested_bytes_, read_pdu_interf int sdu_sz = sdu_itf_->read_pdu(lcid, payload, requested_bytes_); if (sdu_sz < 0) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (sdu_sz == 0) { return 0; @@ -803,7 +803,7 @@ int sch_subh::set_sdu(uint32_t lcid_, uint32_t requested_bytes_, read_pdu_interf nof_bytes = sdu_sz; if (nof_bytes > (int32_t)requested_bytes_) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } @@ -812,7 +812,7 @@ int sch_subh::set_sdu(uint32_t lcid_, uint32_t requested_bytes_, read_pdu_interf return nof_bytes; } else { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } @@ -1072,7 +1072,7 @@ void rar_subh::to_string(fmt::memory_buffer& buffer) } char tmp[16]; - srslte_vec_sprint_hex(tmp, sizeof(tmp), grant, RAR_GRANT_LEN); + srsran_vec_sprint_hex(tmp, sizeof(tmp), grant, RAR_GRANT_LEN); fmt::format_to(buffer, "{}", tmp); } @@ -1140,8 +1140,8 @@ void rar_subh::write_payload(uint8_t** ptr) *(*ptr + 0) = (uint8_t)((ta & 0x7f0) >> 4); *(*ptr + 1) = (uint8_t)((ta & 0xf) << 4) | (grant[0] << 3) | (grant[1] << 2) | (grant[2] << 1) | grant[3]; uint8_t* x = &grant[4]; - *(*ptr + 2) = (uint8_t)srslte_bit_pack(&x, 8); - *(*ptr + 3) = (uint8_t)srslte_bit_pack(&x, 8); + *(*ptr + 2) = (uint8_t)srsran_bit_pack(&x, 8); + *(*ptr + 3) = (uint8_t)srsran_bit_pack(&x, 8); *(*ptr + 4) = (uint8_t)((temp_rnti & 0xff00) >> 8); *(*ptr + 5) = (uint8_t)(temp_rnti & 0x00ff); *ptr += 6; @@ -1156,8 +1156,8 @@ void rar_subh::read_payload(uint8_t** ptr) grant[2] = *(*ptr + 1) & 0x2 ? 1 : 0; grant[3] = *(*ptr + 1) & 0x1 ? 1 : 0; uint8_t* x = &grant[4]; - srslte_bit_unpack(*(*ptr + 2), &x, 8); - srslte_bit_unpack(*(*ptr + 3), &x, 8); + srsran_bit_unpack(*(*ptr + 2), &x, 8); + srsran_bit_unpack(*(*ptr + 3), &x, 8); temp_rnti = ((uint16_t) * (*ptr + 4)) << 8 | *(*ptr + 5); *ptr += 6; } @@ -1176,4 +1176,4 @@ bool rar_subh::read_subheader(uint8_t** ptr) return e_bit; } -} // namespace srslte +} // namespace srsran diff --git a/lib/src/mac/pdu_queue.cc b/lib/src/mac/pdu_queue.cc index 3cb39415e..035d47669 100644 --- a/lib/src/mac/pdu_queue.cc +++ b/lib/src/mac/pdu_queue.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,10 +10,10 @@ * */ -#include "srslte/mac/pdu_queue.h" -#include "srslte/common/log_helper.h" +#include "srsran/mac/pdu_queue.h" +#include "srsran/common/log_helper.h" -namespace srslte { +namespace srsran { void pdu_queue::init(process_callback* callback_) { @@ -93,4 +93,4 @@ void pdu_queue::reset() } } -} // namespace srslte +} // namespace srsran diff --git a/lib/src/phy/CMakeLists.txt b/lib/src/phy/CMakeLists.txt index d3cdd43c3..8c166ba89 100644 --- a/lib/src/phy/CMakeLists.txt +++ b/lib/src/phy/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -23,24 +23,24 @@ add_subdirectory(resampling) add_subdirectory(scrambling) add_subdirectory(ue) add_subdirectory(enb) -set(srslte_srcs $ - $ - $ - $ - $ - $ - $ - $ - $ - $ - $ - $ - $ - $ - $ - $ +set(srsran_srcs $ + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ ) -add_library(srslte_phy STATIC ${srslte_srcs} ) -target_link_libraries(srslte_phy pthread m ${FFT_LIBRARIES}) -INSTALL(TARGETS srslte_phy DESTINATION ${LIBRARY_DIR}) +add_library(srsran_phy STATIC ${srsran_srcs} ) +target_link_libraries(srsran_phy pthread m ${FFT_LIBRARIES}) +INSTALL(TARGETS srsran_phy DESTINATION ${LIBRARY_DIR}) diff --git a/lib/src/phy/agc/CMakeLists.txt b/lib/src/phy/agc/CMakeLists.txt index 4392ab549..71fb0f313 100644 --- a/lib/src/phy/agc/CMakeLists.txt +++ b/lib/src/phy/agc/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -7,4 +7,4 @@ # file(GLOB SOURCES "*.c") -add_library(srslte_agc OBJECT ${SOURCES}) +add_library(srsran_agc OBJECT ${SOURCES}) diff --git a/lib/src/phy/agc/agc.c b/lib/src/phy/agc/agc.c index 1fd4cee3b..51c07f50a 100644 --- a/lib/src/phy/agc/agc.c +++ b/lib/src/phy/agc/agc.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -12,64 +12,64 @@ #include -#include "srslte/phy/agc/agc.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/agc/agc.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" -int srslte_agc_init_acc(srslte_agc_t* q, srslte_agc_mode_t mode, uint32_t nof_frames) +int srsran_agc_init_acc(srsran_agc_t* q, srsran_agc_mode_t mode, uint32_t nof_frames) { - bzero(q, sizeof(srslte_agc_t)); + bzero(q, sizeof(srsran_agc_t)); q->mode = mode; q->nof_frames = nof_frames; q->max_gain_db = 90.0; q->min_gain_db = 0.0; if (nof_frames > 0) { - q->y_tmp = srslte_vec_f_malloc(nof_frames); + q->y_tmp = srsran_vec_f_malloc(nof_frames); if (!q->y_tmp) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } else { q->y_tmp = NULL; } - q->target = SRSLTE_AGC_DEFAULT_TARGET; - srslte_agc_reset(q); - return SRSLTE_SUCCESS; + q->target = SRSRAN_AGC_DEFAULT_TARGET; + srsran_agc_reset(q); + return SRSRAN_SUCCESS; } -int srslte_agc_init_uhd(srslte_agc_t* q, - srslte_agc_mode_t mode, +int srsran_agc_init_uhd(srsran_agc_t* q, + srsran_agc_mode_t mode, uint32_t nof_frames, - SRSLTE_AGC_CALLBACK(set_gain_callback), + SRSRAN_AGC_CALLBACK(set_gain_callback), void* uhd_handler) { - if (!srslte_agc_init_acc(q, mode, nof_frames)) { + if (!srsran_agc_init_acc(q, mode, nof_frames)) { q->set_gain_callback = set_gain_callback; q->uhd_handler = uhd_handler; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } else { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } -void srslte_agc_free(srslte_agc_t* q) +void srsran_agc_free(srsran_agc_t* q) { if (q->y_tmp) { free(q->y_tmp); } - bzero(q, sizeof(srslte_agc_t)); + bzero(q, sizeof(srsran_agc_t)); } -void srslte_agc_reset(srslte_agc_t* q) +void srsran_agc_reset(srsran_agc_t* q) { - q->state = SRSLTE_AGC_STATE_INIT; - q->bandwidth = SRSLTE_AGC_DEFAULT_BW; + q->state = SRSRAN_AGC_STATE_INIT; + q->bandwidth = SRSRAN_AGC_DEFAULT_BW; q->gain_db = q->default_gain_db; if (q->set_gain_callback && q->uhd_handler) { q->set_gain_callback(q->uhd_handler, q->default_gain_db); } } -void srslte_agc_set_gain_range(srslte_agc_t* q, float min_gain_db, float max_gain_db) +void srsran_agc_set_gain_range(srsran_agc_t* q, float min_gain_db, float max_gain_db) { if (q) { q->min_gain_db = min_gain_db; @@ -78,12 +78,12 @@ void srslte_agc_set_gain_range(srslte_agc_t* q, float min_gain_db, float max_gai } } -float srslte_agc_get_gain(srslte_agc_t* q) +float srsran_agc_get_gain(srsran_agc_t* q) { return q->gain_db; } -void srslte_agc_set_gain(srslte_agc_t* q, float init_gain_value_db) +void srsran_agc_set_gain(srsran_agc_t* q, float init_gain_value_db) { q->gain_db = init_gain_value_db; } @@ -91,7 +91,7 @@ void srslte_agc_set_gain(srslte_agc_t* q, float init_gain_value_db) /* * Transition functions */ -static inline void agc_enter_state_hold(srslte_agc_t* q) +static inline void agc_enter_state_hold(srsran_agc_t* q) { // Bound gain in dB float gain_db = q->gain_db + q->gain_offset_db; @@ -112,36 +112,36 @@ static inline void agc_enter_state_hold(srslte_agc_t* q) // Set holding period q->hold_cnt = 0; - q->state = SRSLTE_AGC_STATE_HOLD; + q->state = SRSRAN_AGC_STATE_HOLD; } -static inline void agc_enter_state_measure(srslte_agc_t* q) +static inline void agc_enter_state_measure(srsran_agc_t* q) { q->hold_cnt = 0; q->isfirst = true; - q->state = SRSLTE_AGC_STATE_MEASURE; + q->state = SRSRAN_AGC_STATE_MEASURE; } /* * Running state functions */ -static inline void agc_run_state_init(srslte_agc_t* q) +static inline void agc_run_state_init(srsran_agc_t* q) { agc_enter_state_measure(q); } -static inline void agc_run_state_measure(srslte_agc_t* q, cf_t* signal, uint32_t len) +static inline void agc_run_state_measure(srsran_agc_t* q, cf_t* signal, uint32_t len) { // Perform measurement of the frame float y = 0; float* t; switch (q->mode) { - case SRSLTE_AGC_MODE_ENERGY: - y = sqrtf(crealf(srslte_vec_dot_prod_conj_ccc(signal, signal, len)) / len); + case SRSRAN_AGC_MODE_ENERGY: + y = sqrtf(crealf(srsran_vec_dot_prod_conj_ccc(signal, signal, len)) / len); break; - case SRSLTE_AGC_MODE_PEAK_AMPLITUDE: + case SRSRAN_AGC_MODE_PEAK_AMPLITUDE: t = (float*)signal; - y = t[srslte_vec_max_fi(t, 2 * len)]; // take only positive max to avoid abs() (should be similar) + y = t[srsran_vec_max_fi(t, 2 * len)]; // take only positive max to avoid abs() (should be similar) break; default: ERROR("Unsupported AGC mode"); @@ -154,11 +154,11 @@ static inline void agc_run_state_measure(srslte_agc_t* q, cf_t* signal, uint32_t if (q->frame_cnt == q->nof_frames) { q->frame_cnt = 0; switch (q->mode) { - case SRSLTE_AGC_MODE_ENERGY: - y = srslte_vec_acc_ff(q->y_tmp, q->nof_frames) / q->nof_frames; + case SRSRAN_AGC_MODE_ENERGY: + y = srsran_vec_acc_ff(q->y_tmp, q->nof_frames) / q->nof_frames; break; - case SRSLTE_AGC_MODE_PEAK_AMPLITUDE: - y = q->y_tmp[srslte_vec_max_fi(q->y_tmp, q->nof_frames)]; + case SRSRAN_AGC_MODE_PEAK_AMPLITUDE: + y = q->y_tmp[srsran_vec_max_fi(q->y_tmp, q->nof_frames)]; break; default: ERROR("Unsupported AGC mode"); @@ -174,29 +174,29 @@ static inline void agc_run_state_measure(srslte_agc_t* q, cf_t* signal, uint32_t q->gain_offset_db = 0.0f; } else { if (q->frame_cnt == 0) { - q->y_out = SRSLTE_VEC_EMA(y, q->y_out, q->bandwidth); - q->gain_offset_db = srslte_convert_amplitude_to_dB(q->target) - srslte_convert_amplitude_to_dB(q->y_out); + q->y_out = SRSRAN_VEC_EMA(y, q->y_out, q->bandwidth); + q->gain_offset_db = srsran_convert_amplitude_to_dB(q->target) - srsran_convert_amplitude_to_dB(q->y_out); INFO("AGC gain offset: %.2f y_out=%.3f, y=%.3f target=%.1f", q->gain_offset_db, q->y_out, y, q->target); } } // Check minimum of frame measurements count - if (q->hold_cnt < SRSLTE_AGC_MIN_MEASUREMENTS) { + if (q->hold_cnt < SRSRAN_AGC_MIN_MEASUREMENTS) { // Increment hold counter q->hold_cnt++; - } else if (fabsf(q->gain_offset_db) > SRSLTE_AGC_MIN_GAIN_OFFSET) { + } else if (fabsf(q->gain_offset_db) > SRSRAN_AGC_MIN_GAIN_OFFSET) { // Wait for a minimum of measurements and a minimum gain offset before setting gain agc_enter_state_hold(q); } } -static inline void agc_run_state_hold(srslte_agc_t* q) +static inline void agc_run_state_hold(srsran_agc_t* q) { // Increment holding counter q->hold_cnt++; // Check holding counter - if (q->hold_cnt >= SRSLTE_AGC_HOLD_COUNT) { + if (q->hold_cnt >= SRSRAN_AGC_HOLD_COUNT) { // Enter state measure agc_enter_state_measure(q); } @@ -205,22 +205,22 @@ static inline void agc_run_state_hold(srslte_agc_t* q) /* * AGC FSM entry function */ -void srslte_agc_process(srslte_agc_t* q, cf_t* signal, uint32_t len) +void srsran_agc_process(srsran_agc_t* q, cf_t* signal, uint32_t len) { // Apply current gain to input signal if (!q->uhd_handler) { - srslte_vec_sc_prod_cfc(signal, srslte_convert_dB_to_amplitude(q->gain_db), signal, len); + srsran_vec_sc_prod_cfc(signal, srsran_convert_dB_to_amplitude(q->gain_db), signal, len); } // Run FSM state switch (q->state) { - case SRSLTE_AGC_STATE_HOLD: + case SRSRAN_AGC_STATE_HOLD: agc_run_state_hold(q); break; - case SRSLTE_AGC_STATE_MEASURE: + case SRSRAN_AGC_STATE_MEASURE: agc_run_state_measure(q, signal, len); break; - case SRSLTE_AGC_STATE_INIT: + case SRSRAN_AGC_STATE_INIT: default: agc_run_state_init(q); } diff --git a/lib/src/phy/ch_estimation/CMakeLists.txt b/lib/src/phy/ch_estimation/CMakeLists.txt index c989c4822..e5084fef1 100644 --- a/lib/src/phy/ch_estimation/CMakeLists.txt +++ b/lib/src/phy/ch_estimation/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -7,5 +7,5 @@ # file(GLOB SOURCES "*.c") -add_library(srslte_ch_estimation OBJECT ${SOURCES}) +add_library(srsran_ch_estimation OBJECT ${SOURCES}) add_subdirectory(test) diff --git a/lib/src/phy/ch_estimation/chest_common.c b/lib/src/phy/ch_estimation/chest_common.c index ea2d32557..d529f4fbe 100644 --- a/lib/src/phy/ch_estimation/chest_common.c +++ b/lib/src/phy/ch_estimation/chest_common.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -17,11 +17,11 @@ #include #include -#include "srslte/phy/ch_estimation/chest_common.h" -#include "srslte/phy/utils/convolution.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/ch_estimation/chest_common.h" +#include "srsran/phy/utils/convolution.h" +#include "srsran/phy/utils/vector.h" -uint32_t srslte_chest_set_triangle_filter(float* fil, int filter_len) +uint32_t srsran_chest_set_triangle_filter(float* fil, int filter_len) { for (int i = 0; i < filter_len / 2; i++) { fil[i] = i + 1; @@ -40,17 +40,17 @@ uint32_t srslte_chest_set_triangle_filter(float* fil, int filter_len) } /* Uses the difference between the averaged and non-averaged pilot estimates */ -float srslte_chest_estimate_noise_pilots(cf_t* noisy, cf_t* noiseless, cf_t* noise_vec, uint32_t nof_pilots) +float srsran_chest_estimate_noise_pilots(cf_t* noisy, cf_t* noiseless, cf_t* noise_vec, uint32_t nof_pilots) { /* Substract noisy pilot estimates */ - srslte_vec_sub_ccc(noiseless, noisy, noise_vec, nof_pilots); + srsran_vec_sub_ccc(noiseless, noisy, noise_vec, nof_pilots); /* Compute average power */ - float power = srslte_vec_avg_power_cf(noise_vec, nof_pilots); + float power = srsran_vec_avg_power_cf(noise_vec, nof_pilots); return power; } -uint32_t srslte_chest_set_smooth_filter3_coeff(float* smooth_filter, float w) +uint32_t srsran_chest_set_smooth_filter3_coeff(float* smooth_filter, float w) { smooth_filter[0] = w; smooth_filter[2] = w; @@ -58,7 +58,7 @@ uint32_t srslte_chest_set_smooth_filter3_coeff(float* smooth_filter, float w) return 3; } -uint32_t srslte_chest_set_smooth_filter_gauss(float* filter, uint32_t order, float std_dev) +uint32_t srsran_chest_set_smooth_filter_gauss(float* filter, uint32_t order, float std_dev) { const uint32_t filterlen = order + 1; const int center = (filterlen - 1) / 2; @@ -72,7 +72,7 @@ uint32_t srslte_chest_set_smooth_filter_gauss(float* filter, uint32_t order, flo } // Calculate average for normalization - const float norm = srslte_vec_acc_ff(filter, filterlen); + const float norm = srsran_vec_acc_ff(filter, filterlen); // Avoids NAN, INF or ZERO division if (!isnormal(norm)) { @@ -80,12 +80,12 @@ uint32_t srslte_chest_set_smooth_filter_gauss(float* filter, uint32_t order, flo } // Normalize filter - srslte_vec_sc_prod_fff(filter, 1.0f / norm, filter, filterlen); + srsran_vec_sc_prod_fff(filter, 1.0f / norm, filter, filterlen); return filterlen; } -void srslte_chest_average_pilots(cf_t* input, +void srsran_chest_average_pilots(cf_t* input, cf_t* output, float* filter, uint32_t nof_ref, @@ -93,6 +93,6 @@ void srslte_chest_average_pilots(cf_t* input, uint32_t filter_len) { for (int l = 0; l < nof_symbols; l++) { - srslte_conv_same_cf(&input[l * nof_ref], filter, &output[l * nof_ref], nof_ref, filter_len); + srsran_conv_same_cf(&input[l * nof_ref], filter, &output[l * nof_ref], nof_ref, filter_len); } } diff --git a/lib/src/phy/ch_estimation/chest_dl.c b/lib/src/phy/ch_estimation/chest_dl.c index bafd3196b..37eabbb2e 100644 --- a/lib/src/phy/ch_estimation/chest_dl.c +++ b/lib/src/phy/ch_estimation/chest_dl.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,7 +10,7 @@ * */ -#include "srslte/srslte.h" +#include "srsran/srsran.h" #include #include #include @@ -18,18 +18,18 @@ #include #include -#include "srslte/config.h" +#include "srsran/config.h" -#include "srslte/phy/ch_estimation/chest_dl.h" -#include "srslte/phy/utils/convolution.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/ch_estimation/chest_dl.h" +#include "srsran/phy/utils/convolution.h" +#include "srsran/phy/utils/vector.h" //#define DEFAULT_FILTER_LEN 3 #ifdef DEFAULT_FILTER_LEN -static void set_default_filter(srslte_chest_dl_t* q, int filter_len) +static void set_default_filter(srsran_chest_dl_t* q, int filter_len) { - float fil[SRSLTE_CHEST_DL_MAX_SMOOTH_FIL_LEN]; + float fil[SRSRAN_CHEST_DL_MAX_SMOOTH_FIL_LEN]; for (int i = 0; i < filter_len / 2; i++) { fil[i] = i + 1; @@ -45,7 +45,7 @@ static void set_default_filter(srslte_chest_dl_t* q, int filter_len) fil[i] /= s; } - srslte_chest_dl_set_smooth_filter(q, fil, filter_len); + srsran_chest_dl_set_smooth_filter(q, fil, filter_len); } #endif @@ -55,86 +55,86 @@ static void set_default_filter(srslte_chest_dl_t* q, int filter_len) * * The equalizer uses the channel estimates to produce an estimation of the transmitted symbol. * - * This object depends on the srslte_refsignal_t object for creating the LTE CSR signal. + * This object depends on the srsran_refsignal_t object for creating the LTE CSR signal. */ -int srslte_chest_dl_init(srslte_chest_dl_t* q, uint32_t max_prb, uint32_t nof_rx_antennas) +int srsran_chest_dl_init(srsran_chest_dl_t* q, uint32_t max_prb, uint32_t nof_rx_antennas) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL) { - bzero(q, sizeof(srslte_chest_dl_t)); + bzero(q, sizeof(srsran_chest_dl_t)); - ret = srslte_refsignal_cs_init(&q->csr_refs, max_prb); - if (ret != SRSLTE_SUCCESS) { + ret = srsran_refsignal_cs_init(&q->csr_refs, max_prb); + if (ret != SRSRAN_SUCCESS) { ERROR("Error initializing CSR signal (%d)", ret); goto clean_exit; } - q->mbsfn_refs = calloc(SRSLTE_MAX_MBSFN_AREA_IDS, sizeof(srslte_refsignal_t*)); + q->mbsfn_refs = calloc(SRSRAN_MAX_MBSFN_AREA_IDS, sizeof(srsran_refsignal_t*)); if (!q->mbsfn_refs) { ERROR("Calloc error initializing mbsfn_refs (%d)", ret); goto clean_exit; } int pilot_vec_size; - if (SRSLTE_REFSIGNAL_MAX_NUM_SF_MBSFN(max_prb) > SRSLTE_REFSIGNAL_MAX_NUM_SF(max_prb)) { - pilot_vec_size = SRSLTE_REFSIGNAL_MAX_NUM_SF_MBSFN(max_prb); + if (SRSRAN_REFSIGNAL_MAX_NUM_SF_MBSFN(max_prb) > SRSRAN_REFSIGNAL_MAX_NUM_SF(max_prb)) { + pilot_vec_size = SRSRAN_REFSIGNAL_MAX_NUM_SF_MBSFN(max_prb); } else { - pilot_vec_size = SRSLTE_REFSIGNAL_MAX_NUM_SF(max_prb); + pilot_vec_size = SRSRAN_REFSIGNAL_MAX_NUM_SF(max_prb); } - q->tmp_noise = srslte_vec_cf_malloc(pilot_vec_size); + q->tmp_noise = srsran_vec_cf_malloc(pilot_vec_size); if (!q->tmp_noise) { perror("malloc"); goto clean_exit; } - q->tmp_cfo_estimate = srslte_vec_cf_malloc(pilot_vec_size); + q->tmp_cfo_estimate = srsran_vec_cf_malloc(pilot_vec_size); if (!q->tmp_cfo_estimate) { perror("malloc"); goto clean_exit; } - q->pilot_estimates = srslte_vec_cf_malloc(pilot_vec_size); + q->pilot_estimates = srsran_vec_cf_malloc(pilot_vec_size); if (!q->pilot_estimates) { perror("malloc"); goto clean_exit; } - q->pilot_estimates_average = srslte_vec_cf_malloc(pilot_vec_size); + q->pilot_estimates_average = srsran_vec_cf_malloc(pilot_vec_size); if (!q->pilot_estimates_average) { perror("malloc"); goto clean_exit; } - q->pilot_recv_signal = srslte_vec_cf_malloc(pilot_vec_size); + q->pilot_recv_signal = srsran_vec_cf_malloc(pilot_vec_size); if (!q->pilot_recv_signal) { perror("malloc"); goto clean_exit; } - if (srslte_interp_linear_vector_init(&q->srslte_interp_linvec, SRSLTE_NRE * max_prb)) { + if (srsran_interp_linear_vector_init(&q->srsran_interp_linvec, SRSRAN_NRE * max_prb)) { ERROR("Error initializing vector interpolator"); goto clean_exit; } - if (srslte_interp_linear_init(&q->srslte_interp_lin, 2 * max_prb, SRSLTE_NRE / 2)) { + if (srsran_interp_linear_init(&q->srsran_interp_lin, 2 * max_prb, SRSRAN_NRE / 2)) { ERROR("Error initializing interpolator"); goto clean_exit; } - if (srslte_interp_linear_init(&q->srslte_interp_lin_3, 4 * max_prb, SRSLTE_NRE / 4)) { + if (srsran_interp_linear_init(&q->srsran_interp_lin_3, 4 * max_prb, SRSRAN_NRE / 4)) { ERROR("Error initializing interpolator"); goto clean_exit; } - if (srslte_interp_linear_init(&q->srslte_interp_lin_mbsfn, 6 * max_prb, SRSLTE_NRE / 6)) { + if (srsran_interp_linear_init(&q->srsran_interp_lin_mbsfn, 6 * max_prb, SRSRAN_NRE / 6)) { ERROR("Error initializing interpolator"); goto clean_exit; } - q->wiener_dl = calloc(sizeof(srslte_wiener_dl_t), 1); + q->wiener_dl = calloc(sizeof(srsran_wiener_dl_t), 1); if (q->wiener_dl) { - srslte_wiener_dl_init(q->wiener_dl, max_prb, 2, nof_rx_antennas); + srsran_wiener_dl_init(q->wiener_dl, max_prb, 2, nof_rx_antennas); } else { ERROR("Error allocating wiener filter"); goto clean_exit; @@ -143,27 +143,27 @@ int srslte_chest_dl_init(srslte_chest_dl_t* q, uint32_t max_prb, uint32_t nof_rx q->nof_rx_antennas = nof_rx_antennas; } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; clean_exit: - if (ret != SRSLTE_SUCCESS) { - srslte_chest_dl_free(q); + if (ret != SRSRAN_SUCCESS) { + srsran_chest_dl_free(q); } return ret; } -void srslte_chest_dl_free(srslte_chest_dl_t* q) +void srsran_chest_dl_free(srsran_chest_dl_t* q) { if (!q) { return; } - srslte_refsignal_free(&q->csr_refs); + srsran_refsignal_free(&q->csr_refs); if (q->mbsfn_refs) { - for (int i = 0; i < SRSLTE_MAX_MBSFN_AREA_IDS; i++) { + for (int i = 0; i < SRSRAN_MAX_MBSFN_AREA_IDS; i++) { if (q->mbsfn_refs[i]) { - srslte_refsignal_free(q->mbsfn_refs[i]); + srsran_refsignal_free(q->mbsfn_refs[i]); free(q->mbsfn_refs[i]); } } @@ -176,10 +176,10 @@ void srslte_chest_dl_free(srslte_chest_dl_t* q) if (q->tmp_cfo_estimate) { free(q->tmp_cfo_estimate); } - srslte_interp_linear_vector_free(&q->srslte_interp_linvec); - srslte_interp_linear_free(&q->srslte_interp_lin); - srslte_interp_linear_free(&q->srslte_interp_lin_3); - srslte_interp_linear_free(&q->srslte_interp_lin_mbsfn); + srsran_interp_linear_vector_free(&q->srsran_interp_linvec); + srsran_interp_linear_free(&q->srsran_interp_lin); + srsran_interp_linear_free(&q->srsran_interp_lin_3); + srsran_interp_linear_free(&q->srsran_interp_lin_mbsfn); if (q->pilot_estimates) { free(q->pilot_estimates); } @@ -190,38 +190,38 @@ void srslte_chest_dl_free(srslte_chest_dl_t* q) free(q->pilot_recv_signal); } if (q->wiener_dl) { - srslte_wiener_dl_free(q->wiener_dl); + srsran_wiener_dl_free(q->wiener_dl); free(q->wiener_dl); } - bzero(q, sizeof(srslte_chest_dl_t)); + bzero(q, sizeof(srsran_chest_dl_t)); } -int srslte_chest_dl_res_init(srslte_chest_dl_res_t* q, uint32_t max_prb) +int srsran_chest_dl_res_init(srsran_chest_dl_res_t* q, uint32_t max_prb) { - return srslte_chest_dl_res_init_re(q, SRSLTE_SF_LEN_RE(max_prb, SRSLTE_CP_NORM)); + return srsran_chest_dl_res_init_re(q, SRSRAN_SF_LEN_RE(max_prb, SRSRAN_CP_NORM)); } -int srslte_chest_dl_res_init_re(srslte_chest_dl_res_t* q, uint32_t nof_re) +int srsran_chest_dl_res_init_re(srsran_chest_dl_res_t* q, uint32_t nof_re) { - bzero(q, sizeof(srslte_chest_dl_res_t)); + bzero(q, sizeof(srsran_chest_dl_res_t)); q->nof_re = nof_re; - for (uint32_t i = 0; i < SRSLTE_MAX_PORTS; i++) { - for (uint32_t j = 0; j < SRSLTE_MAX_PORTS; j++) { - q->ce[i][j] = srslte_vec_cf_malloc(q->nof_re); + for (uint32_t i = 0; i < SRSRAN_MAX_PORTS; i++) { + for (uint32_t j = 0; j < SRSRAN_MAX_PORTS; j++) { + q->ce[i][j] = srsran_vec_cf_malloc(q->nof_re); if (!q->ce[i][j]) { perror("malloc"); return -1; } - srslte_vec_cf_zero(q->ce[i][j], nof_re); + srsran_vec_cf_zero(q->ce[i][j], nof_re); } } return 0; } -void srslte_chest_dl_res_set_identity(srslte_chest_dl_res_t* q) +void srsran_chest_dl_res_set_identity(srsran_chest_dl_res_t* q) { - for (uint32_t i = 0; i < SRSLTE_MAX_PORTS; i++) { - for (uint32_t j = 0; j < SRSLTE_MAX_PORTS; j++) { + for (uint32_t i = 0; i < SRSRAN_MAX_PORTS; i++) { + for (uint32_t j = 0; j < SRSRAN_MAX_PORTS; j++) { for (uint32_t k = 0; k < q->nof_re; k++) { q->ce[i][j][k] = (i == j) ? 1.0f : 0.0f; } @@ -229,10 +229,10 @@ void srslte_chest_dl_res_set_identity(srslte_chest_dl_res_t* q) } } -void srslte_chest_dl_res_set_ones(srslte_chest_dl_res_t* q) +void srsran_chest_dl_res_set_ones(srsran_chest_dl_res_t* q) { - for (uint32_t i = 0; i < SRSLTE_MAX_PORTS; i++) { - for (uint32_t j = 0; j < SRSLTE_MAX_PORTS; j++) { + for (uint32_t i = 0; i < SRSRAN_MAX_PORTS; i++) { + for (uint32_t j = 0; j < SRSRAN_MAX_PORTS; j++) { for (uint32_t k = 0; k < q->nof_re; k++) { q->ce[i][j][k] = 1.0f; } @@ -240,10 +240,10 @@ void srslte_chest_dl_res_set_ones(srslte_chest_dl_res_t* q) } } -void srslte_chest_dl_res_free(srslte_chest_dl_res_t* q) +void srsran_chest_dl_res_free(srsran_chest_dl_res_t* q) { - for (uint32_t i = 0; i < SRSLTE_MAX_PORTS; i++) { - for (uint32_t j = 0; j < SRSLTE_MAX_PORTS; j++) { + for (uint32_t i = 0; i < SRSRAN_MAX_PORTS; i++) { + for (uint32_t j = 0; j < SRSRAN_MAX_PORTS; j++) { if (q->ce[i][j]) { free(q->ce[i][j]); } @@ -251,93 +251,93 @@ void srslte_chest_dl_res_free(srslte_chest_dl_res_t* q) } } -int srslte_chest_dl_set_mbsfn_area_id(srslte_chest_dl_t* q, uint16_t mbsfn_area_id) +int srsran_chest_dl_set_mbsfn_area_id(srsran_chest_dl_t* q, uint16_t mbsfn_area_id) { - if (mbsfn_area_id < SRSLTE_MAX_MBSFN_AREA_IDS) { + if (mbsfn_area_id < SRSRAN_MAX_MBSFN_AREA_IDS) { if (!q->mbsfn_refs[mbsfn_area_id]) { - q->mbsfn_refs[mbsfn_area_id] = calloc(1, sizeof(srslte_refsignal_t)); - if (srslte_refsignal_mbsfn_init(q->mbsfn_refs[mbsfn_area_id], q->cell.nof_prb)) { - return SRSLTE_ERROR; + q->mbsfn_refs[mbsfn_area_id] = calloc(1, sizeof(srsran_refsignal_t)); + if (srsran_refsignal_mbsfn_init(q->mbsfn_refs[mbsfn_area_id], q->cell.nof_prb)) { + return SRSRAN_ERROR; } - if (srslte_refsignal_mbsfn_set_cell(q->mbsfn_refs[mbsfn_area_id], q->cell, mbsfn_area_id)) { - return SRSLTE_ERROR; + if (srsran_refsignal_mbsfn_set_cell(q->mbsfn_refs[mbsfn_area_id], q->cell, mbsfn_area_id)) { + return SRSRAN_ERROR; } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } - return SRSLTE_ERROR; + return SRSRAN_ERROR; } -int srslte_chest_dl_set_cell(srslte_chest_dl_t* q, srslte_cell_t cell) +int srsran_chest_dl_set_cell(srsran_chest_dl_t* q, srsran_cell_t cell) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; - if (q != NULL && srslte_cell_isvalid(&cell)) { + int ret = SRSRAN_ERROR_INVALID_INPUTS; + if (q != NULL && srsran_cell_isvalid(&cell)) { if (q->cell.id != cell.id || q->cell.nof_prb == 0) { q->cell = cell; - ret = srslte_refsignal_cs_set_cell(&q->csr_refs, cell); - if (ret != SRSLTE_SUCCESS) { + ret = srsran_refsignal_cs_set_cell(&q->csr_refs, cell); + if (ret != SRSRAN_SUCCESS) { ERROR("Error initializing CSR signal (%d)", ret); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_pss_generate(q->pss_signal, cell.id % 3)) { + if (srsran_pss_generate(q->pss_signal, cell.id % 3)) { ERROR("Error initializing PSS signal for noise estimation"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_interp_linear_vector_resize(&q->srslte_interp_linvec, SRSLTE_NRE * q->cell.nof_prb)) { + if (srsran_interp_linear_vector_resize(&q->srsran_interp_linvec, SRSRAN_NRE * q->cell.nof_prb)) { ERROR("Error initializing vector interpolator"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_interp_linear_resize(&q->srslte_interp_lin, 2 * q->cell.nof_prb, SRSLTE_NRE / 2)) { + if (srsran_interp_linear_resize(&q->srsran_interp_lin, 2 * q->cell.nof_prb, SRSRAN_NRE / 2)) { ERROR("Error initializing interpolator"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_interp_linear_resize(&q->srslte_interp_lin_3, 4 * q->cell.nof_prb, SRSLTE_NRE / 4)) { + if (srsran_interp_linear_resize(&q->srsran_interp_lin_3, 4 * q->cell.nof_prb, SRSRAN_NRE / 4)) { ERROR("Error initializing interpolator"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_interp_linear_resize(&q->srslte_interp_lin_mbsfn, 6 * q->cell.nof_prb, SRSLTE_NRE / 6)) { + if (srsran_interp_linear_resize(&q->srsran_interp_lin_mbsfn, 6 * q->cell.nof_prb, SRSRAN_NRE / 6)) { fprintf(stderr, "Error initializing interpolator\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_wiener_dl_set_cell(q->wiener_dl, cell)) { + if (srsran_wiener_dl_set_cell(q->wiener_dl, cell)) { fprintf(stderr, "Error initializing interpolator\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } /* Uses the difference between the averaged and non-averaged pilot estimates */ -static float estimate_noise_pilots(srslte_chest_dl_t* q, srslte_dl_sf_cfg_t* sf, uint32_t port_id) +static float estimate_noise_pilots(srsran_chest_dl_t* q, srsran_dl_sf_cfg_t* sf, uint32_t port_id) { - srslte_sf_t ch_mode = sf->sf_type; + srsran_sf_t ch_mode = sf->sf_type; const float weight = 1.0f; float sum_power = 0.0f; uint32_t count = 0; - uint32_t npilots = (ch_mode == SRSLTE_SF_MBSFN) ? SRSLTE_REFSIGNAL_NUM_SF_MBSFN(q->cell.nof_prb, port_id) - : srslte_refsignal_cs_nof_re(&q->csr_refs, sf, port_id); - uint32_t nsymbols = (ch_mode == SRSLTE_SF_MBSFN) ? srslte_refsignal_mbsfn_nof_symbols() - : srslte_refsignal_cs_nof_symbols(&q->csr_refs, sf, port_id); + uint32_t npilots = (ch_mode == SRSRAN_SF_MBSFN) ? SRSRAN_REFSIGNAL_NUM_SF_MBSFN(q->cell.nof_prb, port_id) + : srsran_refsignal_cs_nof_re(&q->csr_refs, sf, port_id); + uint32_t nsymbols = (ch_mode == SRSRAN_SF_MBSFN) ? srsran_refsignal_mbsfn_nof_symbols() + : srsran_refsignal_cs_nof_symbols(&q->csr_refs, sf, port_id); uint32_t nref = npilots / nsymbols; uint32_t fidx = - (ch_mode == SRSLTE_SF_MBSFN) ? srslte_refsignal_mbsfn_fidx(1) : srslte_refsignal_cs_fidx(q->cell, 0, port_id, 0); + (ch_mode == SRSRAN_SF_MBSFN) ? srsran_refsignal_mbsfn_fidx(1) : srsran_refsignal_cs_fidx(q->cell, 0, port_id, 0); cf_t* input2d[nsymbols + 2]; cf_t* tmp_noise = q->tmp_noise; // Special case for 1 symbol if (nsymbols == 1) { - srslte_vec_sc_prod_cfc(q->pilot_estimates + 1, weight, tmp_noise, nref - 2); - srslte_vec_sum_ccc(q->pilot_estimates + 0, tmp_noise, tmp_noise, nref - 2); - srslte_vec_sum_ccc(q->pilot_estimates + 2, tmp_noise, tmp_noise, nref - 2); - srslte_vec_sc_prod_cfc(tmp_noise, 1.0f / (weight + 2.0f), tmp_noise, nref - 2); - srslte_vec_sub_ccc(q->pilot_estimates + 1, tmp_noise, tmp_noise, nref - 2); - sum_power = srslte_vec_avg_power_cf(tmp_noise, nref - 2); + srsran_vec_sc_prod_cfc(q->pilot_estimates + 1, weight, tmp_noise, nref - 2); + srsran_vec_sum_ccc(q->pilot_estimates + 0, tmp_noise, tmp_noise, nref - 2); + srsran_vec_sum_ccc(q->pilot_estimates + 2, tmp_noise, tmp_noise, nref - 2); + srsran_vec_sc_prod_cfc(tmp_noise, 1.0f / (weight + 2.0f), tmp_noise, nref - 2); + srsran_vec_sub_ccc(q->pilot_estimates + 1, tmp_noise, tmp_noise, nref - 2); + sum_power = srsran_vec_avg_power_cf(tmp_noise, nref - 2); return sum_power; } @@ -347,319 +347,319 @@ static float estimate_noise_pilots(srslte_chest_dl_t* q, srslte_dl_sf_cfg_t* sf, input2d[0] = &q->tmp_noise[nref]; if (nsymbols > 3) { - srslte_vec_sc_prod_cfc(input2d[2], 2.0f, input2d[0], nref); - srslte_vec_sub_ccc(input2d[0], input2d[4], input2d[0], nref); + srsran_vec_sc_prod_cfc(input2d[2], 2.0f, input2d[0], nref); + srsran_vec_sub_ccc(input2d[0], input2d[4], input2d[0], nref); } else { - srslte_vec_sc_prod_cfc(input2d[2], 1.0f, input2d[0], nref); + srsran_vec_sc_prod_cfc(input2d[2], 1.0f, input2d[0], nref); } input2d[nsymbols + 1] = &q->tmp_noise[nref * 2]; if (nsymbols > 3) { - srslte_vec_sc_prod_cfc(input2d[nsymbols - 1], 2.0f, input2d[nsymbols + 1], nref); - srslte_vec_sub_ccc(input2d[nsymbols + 1], input2d[nsymbols - 3], input2d[nsymbols + 1], nref); + srsran_vec_sc_prod_cfc(input2d[nsymbols - 1], 2.0f, input2d[nsymbols + 1], nref); + srsran_vec_sub_ccc(input2d[nsymbols + 1], input2d[nsymbols - 3], input2d[nsymbols + 1], nref); } else { - srslte_vec_sc_prod_cfc(input2d[nsymbols - 1], 1.0f, input2d[nsymbols + 1], nref); + srsran_vec_sc_prod_cfc(input2d[nsymbols - 1], 1.0f, input2d[nsymbols + 1], nref); } for (int i = 1; i < nsymbols + 1; i++) { uint32_t offset = ((fidx < 3) ^ (i & 1)) ? 0 : 1; - srslte_vec_sc_prod_cfc(input2d[i], weight, tmp_noise, nref); + srsran_vec_sc_prod_cfc(input2d[i], weight, tmp_noise, nref); - srslte_vec_sum_ccc(&input2d[i - 1][0], &tmp_noise[offset], &tmp_noise[offset], nref - offset); - srslte_vec_sum_ccc(&input2d[i - 1][1 - offset], &tmp_noise[0], &tmp_noise[0], nref + offset - 1); + srsran_vec_sum_ccc(&input2d[i - 1][0], &tmp_noise[offset], &tmp_noise[offset], nref - offset); + srsran_vec_sum_ccc(&input2d[i - 1][1 - offset], &tmp_noise[0], &tmp_noise[0], nref + offset - 1); if (offset) { tmp_noise[0] += 2.0f * input2d[i - 1][0] - input2d[i - 1][1]; } else { tmp_noise[nref - 1] += 2.0f * input2d[i - 1][nref - 2] - input2d[i - 1][nref - 1]; } - srslte_vec_sum_ccc(&input2d[i + 1][0], &tmp_noise[offset], &tmp_noise[offset], nref - offset); - srslte_vec_sum_ccc(&input2d[i + 1][1 - offset], &tmp_noise[0], &tmp_noise[0], nref + offset - 1); + srsran_vec_sum_ccc(&input2d[i + 1][0], &tmp_noise[offset], &tmp_noise[offset], nref - offset); + srsran_vec_sum_ccc(&input2d[i + 1][1 - offset], &tmp_noise[0], &tmp_noise[0], nref + offset - 1); if (offset) { tmp_noise[0] += 2.0f * input2d[i + 1][0] - input2d[i + 1][1]; } else { tmp_noise[nref - 1] += 2.0f * input2d[i + 1][nref - 2] - input2d[i + 1][nref - 1]; } - srslte_vec_sc_prod_cfc(tmp_noise, 1.0f / (weight + 4.0f), tmp_noise, nref); + srsran_vec_sc_prod_cfc(tmp_noise, 1.0f / (weight + 4.0f), tmp_noise, nref); - srslte_vec_sub_ccc(input2d[i], tmp_noise, tmp_noise, nref); - sum_power = srslte_vec_avg_power_cf(tmp_noise, nref); + srsran_vec_sub_ccc(input2d[i], tmp_noise, tmp_noise, nref); + sum_power = srsran_vec_avg_power_cf(tmp_noise, nref); count++; } return sum_power / (float)count * sqrtf(weight + 4.0f); } -static float estimate_noise_pss(srslte_chest_dl_t* q, cf_t* input, cf_t* ce) +static float estimate_noise_pss(srsran_chest_dl_t* q, cf_t* input, cf_t* ce) { /* Get PSS from received signal */ - srslte_pss_get_slot(input, q->tmp_pss, q->cell.nof_prb, q->cell.cp); + srsran_pss_get_slot(input, q->tmp_pss, q->cell.nof_prb, q->cell.cp); /* Get channel estimates for PSS position */ - srslte_pss_get_slot(ce, q->tmp_pss_noisy, q->cell.nof_prb, q->cell.cp); + srsran_pss_get_slot(ce, q->tmp_pss_noisy, q->cell.nof_prb, q->cell.cp); /* Multiply known PSS by channel estimates */ - srslte_vec_prod_ccc(q->tmp_pss_noisy, q->pss_signal, q->tmp_pss_noisy, SRSLTE_PSS_LEN); + srsran_vec_prod_ccc(q->tmp_pss_noisy, q->pss_signal, q->tmp_pss_noisy, SRSRAN_PSS_LEN); /* Substract received signal */ - srslte_vec_sub_ccc(q->tmp_pss_noisy, q->tmp_pss, q->tmp_pss_noisy, SRSLTE_PSS_LEN); + srsran_vec_sub_ccc(q->tmp_pss_noisy, q->tmp_pss, q->tmp_pss_noisy, SRSRAN_PSS_LEN); /* Compute average power */ - float power = q->cell.nof_ports * srslte_vec_avg_power_cf(q->tmp_pss_noisy, SRSLTE_PSS_LEN) * M_SQRT1_2; + float power = q->cell.nof_ports * srsran_vec_avg_power_cf(q->tmp_pss_noisy, SRSRAN_PSS_LEN) * M_SQRT1_2; return power; } /* Uses the 5 empty transmitted SC before and after the SSS and PSS sequences for noise estimation */ -static float estimate_noise_empty_sc(srslte_chest_dl_t* q, cf_t* input) +static float estimate_noise_empty_sc(srsran_chest_dl_t* q, cf_t* input) { - int k_sss = (SRSLTE_CP_NSYMB(q->cell.cp) - 2) * q->cell.nof_prb * SRSLTE_NRE + q->cell.nof_prb * SRSLTE_NRE / 2 - 31; + int k_sss = (SRSRAN_CP_NSYMB(q->cell.cp) - 2) * q->cell.nof_prb * SRSRAN_NRE + q->cell.nof_prb * SRSRAN_NRE / 2 - 31; float noise_power = 0; - noise_power += srslte_vec_avg_power_cf(&input[k_sss - 5], 5); // 5 empty SC before SSS - noise_power += srslte_vec_avg_power_cf(&input[k_sss + 62], 5); // 5 empty SC after SSS - int k_pss = (SRSLTE_CP_NSYMB(q->cell.cp) - 1) * q->cell.nof_prb * SRSLTE_NRE + q->cell.nof_prb * SRSLTE_NRE / 2 - 31; - noise_power += srslte_vec_avg_power_cf(&input[k_pss - 5], 5); // 5 empty SC before PSS - noise_power += srslte_vec_avg_power_cf(&input[k_pss + 62], 5); // 5 empty SC after PSS + noise_power += srsran_vec_avg_power_cf(&input[k_sss - 5], 5); // 5 empty SC before SSS + noise_power += srsran_vec_avg_power_cf(&input[k_sss + 62], 5); // 5 empty SC after SSS + int k_pss = (SRSRAN_CP_NSYMB(q->cell.cp) - 1) * q->cell.nof_prb * SRSRAN_NRE + q->cell.nof_prb * SRSRAN_NRE / 2 - 31; + noise_power += srsran_vec_avg_power_cf(&input[k_pss - 5], 5); // 5 empty SC before PSS + noise_power += srsran_vec_avg_power_cf(&input[k_pss + 62], 5); // 5 empty SC after PSS return noise_power; } -#define cesymb(i) ce[SRSLTE_RE_IDX(q->cell.nof_prb, i, 0)] +#define cesymb(i) ce[SRSRAN_RE_IDX(q->cell.nof_prb, i, 0)] -static void interpolate_pilots(srslte_chest_dl_t* q, - srslte_dl_sf_cfg_t* sf, - srslte_chest_dl_cfg_t* cfg, +static void interpolate_pilots(srsran_chest_dl_t* q, + srsran_dl_sf_cfg_t* sf, + srsran_chest_dl_cfg_t* cfg, cf_t* pilot_estimates, cf_t* ce, uint32_t port_id) { /* interpolate the symbols with references in the freq domain */ - uint32_t nsymbols = (sf->sf_type == SRSLTE_SF_MBSFN) ? srslte_refsignal_mbsfn_nof_symbols() + 1 - : srslte_refsignal_cs_nof_symbols(&q->csr_refs, sf, port_id); + uint32_t nsymbols = (sf->sf_type == SRSRAN_SF_MBSFN) ? srsran_refsignal_mbsfn_nof_symbols() + 1 + : srsran_refsignal_cs_nof_symbols(&q->csr_refs, sf, port_id); uint32_t fidx_offset = 0; /* Interpolate in the frequency domain */ uint32_t freq_nsymbols = nsymbols; - if (cfg->estimator_alg == SRSLTE_ESTIMATOR_ALG_AVERAGE) { + if (cfg->estimator_alg == SRSRAN_ESTIMATOR_ALG_AVERAGE) { freq_nsymbols = 1; } // we add one to nsymbols to allow for inclusion of the non-mbms references in the channel estimation for (uint32_t l = 0; l < freq_nsymbols; l++) { - if (sf->sf_type == SRSLTE_SF_MBSFN) { + if (sf->sf_type == SRSRAN_SF_MBSFN) { if (l == 0) { - fidx_offset = srslte_refsignal_cs_fidx(q->cell, l, port_id, 0); - srslte_interp_linear_offset( - &q->srslte_interp_lin, + fidx_offset = srsran_refsignal_cs_fidx(q->cell, l, port_id, 0); + srsran_interp_linear_offset( + &q->srsran_interp_lin, &pilot_estimates[2 * q->cell.nof_prb * l], - &ce[srslte_refsignal_cs_nsymbol(l, q->cell.cp, port_id) * q->cell.nof_prb * SRSLTE_NRE], + &ce[srsran_refsignal_cs_nsymbol(l, q->cell.cp, port_id) * q->cell.nof_prb * SRSRAN_NRE], fidx_offset, - SRSLTE_NRE / 2 - fidx_offset); + SRSRAN_NRE / 2 - fidx_offset); } else { - fidx_offset = srslte_refsignal_mbsfn_fidx(l - 1); - srslte_interp_linear_offset(&q->srslte_interp_lin_mbsfn, + fidx_offset = srsran_refsignal_mbsfn_fidx(l - 1); + srsran_interp_linear_offset(&q->srsran_interp_lin_mbsfn, &pilot_estimates[(2 * q->cell.nof_prb) + 6 * q->cell.nof_prb * (l - 1)], - &ce[srslte_refsignal_mbsfn_nsymbol(l - 1) * q->cell.nof_prb * SRSLTE_NRE], + &ce[srsran_refsignal_mbsfn_nsymbol(l - 1) * q->cell.nof_prb * SRSRAN_NRE], fidx_offset, (fidx_offset) ? 1 : 2); } } else { - if (cfg->estimator_alg == SRSLTE_ESTIMATOR_ALG_AVERAGE && nsymbols > 1) { + if (cfg->estimator_alg == SRSRAN_ESTIMATOR_ALG_AVERAGE && nsymbols > 1) { fidx_offset = q->cell.id % 3; - srslte_interp_linear_offset( - &q->srslte_interp_lin_3, pilot_estimates, ce, fidx_offset, SRSLTE_NRE / 4 - fidx_offset); + srsran_interp_linear_offset( + &q->srsran_interp_lin_3, pilot_estimates, ce, fidx_offset, SRSRAN_NRE / 4 - fidx_offset); } else { - fidx_offset = srslte_refsignal_cs_fidx(q->cell, l, port_id, 0); - srslte_interp_linear_offset( - &q->srslte_interp_lin, + fidx_offset = srsran_refsignal_cs_fidx(q->cell, l, port_id, 0); + srsran_interp_linear_offset( + &q->srsran_interp_lin, &pilot_estimates[2 * q->cell.nof_prb * l], - &ce[srslte_refsignal_cs_nsymbol(l, q->cell.cp, port_id) * q->cell.nof_prb * SRSLTE_NRE], + &ce[srsran_refsignal_cs_nsymbol(l, q->cell.cp, port_id) * q->cell.nof_prb * SRSRAN_NRE], fidx_offset, - SRSLTE_NRE / 2 - fidx_offset); + SRSRAN_NRE / 2 - fidx_offset); } } } /* Now interpolate in the time domain between symbols */ - if (sf->sf_type == SRSLTE_SF_NORM && (cfg->estimator_alg == SRSLTE_ESTIMATOR_ALG_AVERAGE || nsymbols < 3)) { + if (sf->sf_type == SRSRAN_SF_NORM && (cfg->estimator_alg == SRSRAN_ESTIMATOR_ALG_AVERAGE || nsymbols < 3)) { // If we average per subframe, just copy the estimates in the time domain - for (uint32_t l = 1; l < 2 * SRSLTE_CP_NSYMB(q->cell.cp); l++) { - memcpy(&ce[l * SRSLTE_NRE * q->cell.nof_prb], ce, sizeof(cf_t) * SRSLTE_NRE * q->cell.nof_prb); + for (uint32_t l = 1; l < 2 * SRSRAN_CP_NSYMB(q->cell.cp); l++) { + memcpy(&ce[l * SRSRAN_NRE * q->cell.nof_prb], ce, sizeof(cf_t) * SRSRAN_NRE * q->cell.nof_prb); } } else { - if (sf->sf_type == SRSLTE_SF_MBSFN) { - srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(0), &cesymb(2), &cesymb(1), 2, 1); - srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(2), &cesymb(6), &cesymb(3), 4, 3); - srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(6), &cesymb(10), &cesymb(7), 4, 3); - srslte_interp_linear_vector2(&q->srslte_interp_linvec, &cesymb(6), &cesymb(10), &cesymb(10), &cesymb(11), 4, 1); + if (sf->sf_type == SRSRAN_SF_MBSFN) { + srsran_interp_linear_vector(&q->srsran_interp_linvec, &cesymb(0), &cesymb(2), &cesymb(1), 2, 1); + srsran_interp_linear_vector(&q->srsran_interp_linvec, &cesymb(2), &cesymb(6), &cesymb(3), 4, 3); + srsran_interp_linear_vector(&q->srsran_interp_linvec, &cesymb(6), &cesymb(10), &cesymb(7), 4, 3); + srsran_interp_linear_vector2(&q->srsran_interp_linvec, &cesymb(6), &cesymb(10), &cesymb(10), &cesymb(11), 4, 1); } else { - if (SRSLTE_CP_ISNORM(q->cell.cp)) { + if (SRSRAN_CP_ISNORM(q->cell.cp)) { if (port_id <= 2) { - srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(0), &cesymb(4), &cesymb(1), 4, 3); - srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(4), &cesymb(7), &cesymb(5), 3, 2); + srsran_interp_linear_vector(&q->srsran_interp_linvec, &cesymb(0), &cesymb(4), &cesymb(1), 4, 3); + srsran_interp_linear_vector(&q->srsran_interp_linvec, &cesymb(4), &cesymb(7), &cesymb(5), 3, 2); if (nsymbols == 4) { - srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(7), &cesymb(11), &cesymb(8), 4, 3); - srslte_interp_linear_vector2( - &q->srslte_interp_linvec, &cesymb(7), &cesymb(11), &cesymb(11), &cesymb(12), 4, 2); + srsran_interp_linear_vector(&q->srsran_interp_linvec, &cesymb(7), &cesymb(11), &cesymb(8), 4, 3); + srsran_interp_linear_vector2( + &q->srsran_interp_linvec, &cesymb(7), &cesymb(11), &cesymb(11), &cesymb(12), 4, 2); } else { - srslte_interp_linear_vector2( - &q->srslte_interp_linvec, &cesymb(4), &cesymb(7), &cesymb(7), &cesymb(8), 3, 6); + srsran_interp_linear_vector2( + &q->srsran_interp_linvec, &cesymb(4), &cesymb(7), &cesymb(7), &cesymb(8), 3, 6); } } else { - srslte_interp_linear_vector2(&q->srslte_interp_linvec, &cesymb(8), &cesymb(1), &cesymb(1), &cesymb(0), 7, 1); - srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(1), &cesymb(8), &cesymb(2), 7, 6); - srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(1), &cesymb(8), &cesymb(9), 7, 5); + srsran_interp_linear_vector2(&q->srsran_interp_linvec, &cesymb(8), &cesymb(1), &cesymb(1), &cesymb(0), 7, 1); + srsran_interp_linear_vector(&q->srsran_interp_linvec, &cesymb(1), &cesymb(8), &cesymb(2), 7, 6); + srsran_interp_linear_vector(&q->srsran_interp_linvec, &cesymb(1), &cesymb(8), &cesymb(9), 7, 5); } } else { if (port_id <= 2) { // TODO: TDD and extended cyclic prefix - srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(0), &cesymb(3), &cesymb(1), 3, 2); - srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(3), &cesymb(6), &cesymb(4), 3, 2); - srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(6), &cesymb(9), &cesymb(7), 3, 2); - srslte_interp_linear_vector2(&q->srslte_interp_linvec, &cesymb(6), &cesymb(9), &cesymb(9), &cesymb(10), 3, 2); + srsran_interp_linear_vector(&q->srsran_interp_linvec, &cesymb(0), &cesymb(3), &cesymb(1), 3, 2); + srsran_interp_linear_vector(&q->srsran_interp_linvec, &cesymb(3), &cesymb(6), &cesymb(4), 3, 2); + srsran_interp_linear_vector(&q->srsran_interp_linvec, &cesymb(6), &cesymb(9), &cesymb(7), 3, 2); + srsran_interp_linear_vector2(&q->srsran_interp_linvec, &cesymb(6), &cesymb(9), &cesymb(9), &cesymb(10), 3, 2); } else { - srslte_interp_linear_vector2(&q->srslte_interp_linvec, &cesymb(7), &cesymb(1), &cesymb(1), &cesymb(0), 6, 1); - srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(1), &cesymb(7), &cesymb(2), 6, 5); - srslte_interp_linear_vector(&q->srslte_interp_linvec, &cesymb(1), &cesymb(7), &cesymb(8), 6, 4); + srsran_interp_linear_vector2(&q->srsran_interp_linvec, &cesymb(7), &cesymb(1), &cesymb(1), &cesymb(0), 6, 1); + srsran_interp_linear_vector(&q->srsran_interp_linvec, &cesymb(1), &cesymb(7), &cesymb(2), 6, 5); + srsran_interp_linear_vector(&q->srsran_interp_linvec, &cesymb(1), &cesymb(7), &cesymb(8), 6, 4); } } } } } -static void average_pilots(srslte_chest_dl_t* q, - srslte_dl_sf_cfg_t* sf, - srslte_chest_dl_cfg_t* cfg, +static void average_pilots(srsran_chest_dl_t* q, + srsran_dl_sf_cfg_t* sf, + srsran_chest_dl_cfg_t* cfg, cf_t* input, cf_t* output, uint32_t port_id, float* filter, uint32_t filter_len) { - uint32_t nsymbols = (sf->sf_type == SRSLTE_SF_MBSFN) ? srslte_refsignal_mbsfn_nof_symbols() - : srslte_refsignal_cs_nof_symbols(&q->csr_refs, sf, port_id); - uint32_t nref = (sf->sf_type == SRSLTE_SF_MBSFN) ? 6 * q->cell.nof_prb : 2 * q->cell.nof_prb; + uint32_t nsymbols = (sf->sf_type == SRSRAN_SF_MBSFN) ? srsran_refsignal_mbsfn_nof_symbols() + : srsran_refsignal_cs_nof_symbols(&q->csr_refs, sf, port_id); + uint32_t nref = (sf->sf_type == SRSRAN_SF_MBSFN) ? 6 * q->cell.nof_prb : 2 * q->cell.nof_prb; // Average in the time domain if enabled - if (cfg->estimator_alg == SRSLTE_ESTIMATOR_ALG_AVERAGE && nsymbols > 1) { + if (cfg->estimator_alg == SRSRAN_ESTIMATOR_ALG_AVERAGE && nsymbols > 1) { cf_t* temp = output; // Use output as temporal buffer - if (srslte_refsignal_cs_fidx(q->cell, 0, port_id, 0) < 3) { - srslte_vec_interleave(input, &input[nref], temp, nref); + if (srsran_refsignal_cs_fidx(q->cell, 0, port_id, 0) < 3) { + srsran_vec_interleave(input, &input[nref], temp, nref); for (int l = 2; l < nsymbols - 1; l += 2) { - srslte_vec_interleave_add(&input[l * nref], &input[(l + 1) * nref], temp, nref); + srsran_vec_interleave_add(&input[l * nref], &input[(l + 1) * nref], temp, nref); } } else { - srslte_vec_interleave(&input[nref], input, temp, nref); + srsran_vec_interleave(&input[nref], input, temp, nref); for (int l = 2; l < nsymbols - 1; l += 2) { - srslte_vec_interleave_add(&input[(l + 1) * nref], &input[l * nref], temp, nref); + srsran_vec_interleave_add(&input[(l + 1) * nref], &input[l * nref], temp, nref); } } nref *= 2; - srslte_vec_sc_prod_cfc(temp, 2.0f / (float)nsymbols, input, nref); + srsran_vec_sc_prod_cfc(temp, 2.0f / (float)nsymbols, input, nref); nsymbols = 1; } - uint32_t skip = (sf->sf_type == SRSLTE_SF_MBSFN) ? 2 * q->cell.nof_prb : 0; - if (sf->sf_type == SRSLTE_SF_MBSFN) { + uint32_t skip = (sf->sf_type == SRSRAN_SF_MBSFN) ? 2 * q->cell.nof_prb : 0; + if (sf->sf_type == SRSRAN_SF_MBSFN) { memcpy(&output[0], &input[0], skip * sizeof(cf_t)); } // Average in the frequency domain for (int l = 0; l < nsymbols; l++) { - srslte_conv_same_cf(&input[l * nref + skip], filter, &output[l * nref + skip], nref, filter_len); + srsran_conv_same_cf(&input[l * nref + skip], filter, &output[l * nref + skip], nref, filter_len); } } -static float chest_dl_rssi(srslte_chest_dl_t* q, srslte_dl_sf_cfg_t* sf, cf_t* input, uint32_t port_id) +static float chest_dl_rssi(srsran_chest_dl_t* q, srsran_dl_sf_cfg_t* sf, cf_t* input, uint32_t port_id) { uint32_t l; float rssi = 0; - uint32_t nsymbols = srslte_refsignal_cs_nof_symbols(&q->csr_refs, sf, port_id); + uint32_t nsymbols = srsran_refsignal_cs_nof_symbols(&q->csr_refs, sf, port_id); for (l = 0; l < nsymbols; l++) { - cf_t* tmp = &input[srslte_refsignal_cs_nsymbol(l, q->cell.cp, port_id) * q->cell.nof_prb * SRSLTE_NRE]; - rssi += srslte_vec_dot_prod_conj_ccc(tmp, tmp, q->cell.nof_prb * SRSLTE_NRE); + cf_t* tmp = &input[srsran_refsignal_cs_nsymbol(l, q->cell.cp, port_id) * q->cell.nof_prb * SRSRAN_NRE]; + rssi += srsran_vec_dot_prod_conj_ccc(tmp, tmp, q->cell.nof_prb * SRSRAN_NRE); } return rssi / nsymbols; } // CFO estimation algorithm taken from "Carrier Frequency Synchronization in the // Downlink of 3GPP LTE", Qi Wang, C. Mehlfuhrer, M. Rupp -static float chest_estimate_cfo(srslte_chest_dl_t* q) +static float chest_estimate_cfo(srsran_chest_dl_t* q) { - float n = (float)srslte_symbol_sz(q->cell.nof_prb); - float ns = (float)SRSLTE_CP_NSYMB(q->cell.cp); - float ng = (float)SRSLTE_CP_LEN_NORM(1, n); + float n = (float)srsran_symbol_sz(q->cell.nof_prb); + float ns = (float)SRSRAN_CP_NSYMB(q->cell.cp); + float ng = (float)SRSRAN_CP_LEN_NORM(1, n); - srslte_dl_sf_cfg_t sf_cfg; + srsran_dl_sf_cfg_t sf_cfg; ZERO_OBJECT(sf_cfg); - uint32_t npilots = srslte_refsignal_cs_nof_re(&q->csr_refs, &sf_cfg, 0); + uint32_t npilots = srsran_refsignal_cs_nof_re(&q->csr_refs, &sf_cfg, 0); // Compute angles between slots for (int i = 0; i < 2; i++) { - srslte_vec_prod_conj_ccc(&q->pilot_estimates[i * npilots / 4], + srsran_vec_prod_conj_ccc(&q->pilot_estimates[i * npilots / 4], &q->pilot_estimates[(i + 2) * npilots / 4], &q->tmp_cfo_estimate[i * npilots / 4], npilots / 4); } // Average all angles - cf_t sum = srslte_vec_acc_cc(q->tmp_cfo_estimate, npilots / 2); + cf_t sum = srsran_vec_acc_cc(q->tmp_cfo_estimate, npilots / 2); // Compute CFO return -cargf(sum) * n / (ns * (n + ng)) / 2 / M_PI; } -static void chest_interpolate_noise_est(srslte_chest_dl_t* q, - srslte_dl_sf_cfg_t* sf, - srslte_chest_dl_cfg_t* cfg, +static void chest_interpolate_noise_est(srsran_chest_dl_t* q, + srsran_dl_sf_cfg_t* sf, + srsran_chest_dl_cfg_t* cfg, cf_t* input, cf_t* ce, uint32_t port_id, uint32_t rxant_id) { - float filter[SRSLTE_CHEST_MAX_SMOOTH_FIL_LEN]; + float filter[SRSRAN_CHEST_MAX_SMOOTH_FIL_LEN]; uint32_t filter_len = 0; uint32_t sf_idx = sf->tti % 10; - srslte_sf_t ch_mode = sf->sf_type; + srsran_sf_t ch_mode = sf->sf_type; - if (cfg->cfo_estimate_enable && ((1 << sf_idx) & cfg->cfo_estimate_sf_mask) && ch_mode != SRSLTE_SF_MBSFN) { + if (cfg->cfo_estimate_enable && ((1 << sf_idx) & cfg->cfo_estimate_sf_mask) && ch_mode != SRSRAN_SF_MBSFN) { q->cfo = chest_estimate_cfo(q); } /* Estimate noise */ - if (cfg->noise_alg == SRSLTE_NOISE_ALG_REFS) { - if (ch_mode == SRSLTE_SF_MBSFN) { + if (cfg->noise_alg == SRSRAN_NOISE_ALG_REFS) { + if (ch_mode == SRSRAN_SF_MBSFN) { ERROR("Warning: REFS noise estimation algorithm not supported in MBSFN subframes"); } q->noise_estimate[rxant_id][port_id] = estimate_noise_pilots(q, sf, port_id); } - if (q->wiener_dl && ch_mode == SRSLTE_SF_NORM && cfg->estimator_alg == SRSLTE_ESTIMATOR_ALG_WIENER) { + if (q->wiener_dl && ch_mode == SRSRAN_SF_NORM && cfg->estimator_alg == SRSRAN_ESTIMATOR_ALG_WIENER) { bool ready = q->wiener_dl->ready; - uint32_t nre = q->cell.nof_prb * SRSLTE_NRE; + uint32_t nre = q->cell.nof_prb * SRSRAN_NRE; uint32_t nref = q->cell.nof_prb * 2; - uint32_t shift = srslte_refsignal_cs_fidx(q->cell, 0, port_id, 0); - uint32_t nsymb = srslte_refsignal_cs_nof_symbols(&q->csr_refs, sf, port_id); + uint32_t shift = srsran_refsignal_cs_fidx(q->cell, 0, port_id, 0); + uint32_t nsymb = srsran_refsignal_cs_nof_symbols(&q->csr_refs, sf, port_id); float snr_lin = +INFINITY; if (isnormal(q->noise_estimate[rxant_id][port_id]) && isnormal(q->rsrp[rxant_id][port_id])) { snr_lin = q->rsrp[rxant_id][port_id] / q->noise_estimate[rxant_id][port_id] / 2; } - for (uint32_t m = 0, l = 0; m < 2 * SRSLTE_CP_NORM_NSYMB + 4; m++) { + for (uint32_t m = 0, l = 0; m < 2 * SRSRAN_CP_NORM_NSYMB + 4; m++) { uint32_t ce_idx = 0; if (m >= 4) { ce_idx = (m - 4) * nre; } - uint32_t k = srslte_refsignal_cs_nsymbol(l, q->cell.cp, port_id); - srslte_wiener_dl_run( + uint32_t k = srsran_refsignal_cs_nsymbol(l, q->cell.cp, port_id); + srsran_wiener_dl_run( q->wiener_dl, port_id, rxant_id, m, shift, &q->pilot_estimates[nref * l], &ce[ce_idx], snr_lin); if (m == k) { @@ -673,29 +673,29 @@ static void chest_interpolate_noise_est(srslte_chest_dl_t* q, if (ce != NULL) { switch (cfg->filter_type) { - case SRSLTE_CHEST_FILTER_GAUSS: - if (ch_mode == SRSLTE_SF_MBSFN) { + case SRSRAN_CHEST_FILTER_GAUSS: + if (ch_mode == SRSRAN_SF_MBSFN) { ERROR("Warning: Gauss filter not supported in MBSFN subframes"); } if (cfg->filter_coef[0] <= 0) { - filter_len = srslte_chest_set_smooth_filter_gauss(filter, 4, q->noise_estimate[rxant_id][port_id] * 200.0f); + filter_len = srsran_chest_set_smooth_filter_gauss(filter, 4, q->noise_estimate[rxant_id][port_id] * 200.0f); } else { - filter_len = srslte_chest_set_smooth_filter_gauss(filter, (uint32_t)cfg->filter_coef[0], cfg->filter_coef[1]); + filter_len = srsran_chest_set_smooth_filter_gauss(filter, (uint32_t)cfg->filter_coef[0], cfg->filter_coef[1]); } break; - case SRSLTE_CHEST_FILTER_TRIANGLE: - filter_len = srslte_chest_set_smooth_filter3_coeff(filter, cfg->filter_coef[0]); + case SRSRAN_CHEST_FILTER_TRIANGLE: + filter_len = srsran_chest_set_smooth_filter3_coeff(filter, cfg->filter_coef[0]); break; default: break; } - if (cfg->estimator_alg != SRSLTE_ESTIMATOR_ALG_INTERPOLATE && ch_mode == SRSLTE_SF_MBSFN) { + if (cfg->estimator_alg != SRSRAN_ESTIMATOR_ALG_INTERPOLATE && ch_mode == SRSRAN_SF_MBSFN) { ERROR("Warning: Subframe interpolation must be enabled in MBSFN subframes"); } /* Smooth estimates (if applicable) and interpolate */ - if (cfg->filter_type == SRSLTE_CHEST_FILTER_NONE) { + if (cfg->filter_type == SRSRAN_CHEST_FILTER_NONE) { interpolate_pilots(q, sf, cfg, q->pilot_estimates, ce, port_id); } else { average_pilots(q, sf, cfg, q->pilot_estimates, q->pilot_estimates_average, port_id, filter, filter_len); @@ -704,12 +704,12 @@ static void chest_interpolate_noise_est(srslte_chest_dl_t* q, /* Estimate noise for PSS and EMPTY algorithms */ switch (cfg->noise_alg) { - case SRSLTE_NOISE_ALG_PSS: + case SRSRAN_NOISE_ALG_PSS: if (sf_idx == 0 || sf_idx == 5) { q->noise_estimate[rxant_id][port_id] = estimate_noise_pss(q, input, ce); } break; - case SRSLTE_NOISE_ALG_EMPTY: + case SRSRAN_NOISE_ALG_EMPTY: if (sf_idx == 0 || sf_idx == 5) { q->noise_estimate[rxant_id][port_id] = estimate_noise_empty_sc(q, input); } @@ -721,30 +721,30 @@ static void chest_interpolate_noise_est(srslte_chest_dl_t* q, } static void -chest_dl_estimate_correct_sync_error(srslte_chest_dl_t* q, srslte_dl_sf_cfg_t* sf, cf_t* input, uint32_t rxant_id) +chest_dl_estimate_correct_sync_error(srsran_chest_dl_t* q, srsran_dl_sf_cfg_t* sf, cf_t* input, uint32_t rxant_id) { float pwr_sum = 0.0f; float sync_err = 0.0f; // For each cell port... for (uint32_t cell_port_id = 0; cell_port_id < q->cell.nof_ports; cell_port_id++) { - uint32_t npilots = srslte_refsignal_cs_nof_re(&q->csr_refs, sf, cell_port_id); - uint32_t nsymb = srslte_refsignal_cs_nof_symbols(&q->csr_refs, sf, cell_port_id); + uint32_t npilots = srsran_refsignal_cs_nof_re(&q->csr_refs, sf, cell_port_id); + uint32_t nsymb = srsran_refsignal_cs_nof_symbols(&q->csr_refs, sf, cell_port_id); // Get references from the input signal - srslte_refsignal_cs_get_sf(&q->csr_refs, sf, cell_port_id, input, q->pilot_recv_signal); + srsran_refsignal_cs_get_sf(&q->csr_refs, sf, cell_port_id, input, q->pilot_recv_signal); // Use the known CSR signal to compute Least-squares estimates - srslte_vec_prod_conj_ccc( + srsran_vec_prod_conj_ccc( q->pilot_recv_signal, q->csr_refs.pilots[cell_port_id / 2][sf->tti % 10], q->pilot_estimates, npilots); // Estimate synchronization error from the phase shift - float k = (float)srslte_symbol_sz(q->cell.nof_prb) / 6.0f; + float k = (float)srsran_symbol_sz(q->cell.nof_prb) / 6.0f; float sum = 0.0f; for (uint32_t i = 0; i < nsymb; i++) { - sum += srslte_vec_estimate_frequency(q->pilot_estimates + i * npilots / nsymb, npilots / nsymb) * k; + sum += srsran_vec_estimate_frequency(q->pilot_estimates + i * npilots / nsymb, npilots / nsymb) * k; } - float pwr = srslte_vec_avg_power_cf(q->pilot_estimates, npilots); + float pwr = srsran_vec_avg_power_cf(q->pilot_estimates, npilots); // Average symbol sum q->sync_err[rxant_id][cell_port_id] = sum / nsymb; @@ -764,42 +764,42 @@ chest_dl_estimate_correct_sync_error(srslte_chest_dl_t* q, srslte_dl_sf_cfg_t* s // Correct time synchronization error if estimated is not NAN, not INF and greater than 0.05 samples if (isnormal(sync_err) && fabsf(sync_err) > 0.05f) { // Compute required frequency shift, convert from sample error to normalised sine - float cfo = sync_err / (float)srslte_symbol_sz(q->cell.nof_prb); - uint32_t nre = SRSLTE_NRE * q->cell.nof_prb; - uint32_t nsymb = SRSLTE_CP_NSYMB(q->cell.cp) * SRSLTE_NOF_SLOTS_PER_SF; + float cfo = sync_err / (float)srsran_symbol_sz(q->cell.nof_prb); + uint32_t nre = SRSRAN_NRE * q->cell.nof_prb; + uint32_t nsymb = SRSRAN_CP_NSYMB(q->cell.cp) * SRSRAN_NOF_SLOTS_PER_SF; // For each symbol... for (uint32_t i = 0; i < nsymb; i++) { // Do a frequency shift cf_t* ptr = &input[i * nre]; - srslte_vec_apply_cfo(ptr, cfo, ptr, nre); + srsran_vec_apply_cfo(ptr, cfo, ptr, nre); } } } -static int estimate_port(srslte_chest_dl_t* q, - srslte_dl_sf_cfg_t* sf, - srslte_chest_dl_cfg_t* cfg, +static int estimate_port(srsran_chest_dl_t* q, + srsran_dl_sf_cfg_t* sf, + srsran_chest_dl_cfg_t* cfg, cf_t* input, cf_t* ce, uint32_t port_id, uint32_t rxant_id) { - uint32_t npilots = srslte_refsignal_cs_nof_re(&q->csr_refs, sf, port_id); + uint32_t npilots = srsran_refsignal_cs_nof_re(&q->csr_refs, sf, port_id); /* Get references from the input signal */ - srslte_refsignal_cs_get_sf(&q->csr_refs, sf, port_id, input, q->pilot_recv_signal); + srsran_refsignal_cs_get_sf(&q->csr_refs, sf, port_id, input, q->pilot_recv_signal); /* Use the known CSR signal to compute Least-squares estimates */ - srslte_vec_prod_conj_ccc( + srsran_vec_prod_conj_ccc( q->pilot_recv_signal, q->csr_refs.pilots[port_id / 2][sf->tti % 10], q->pilot_estimates, npilots); /* Compute RSRP for the channel estimates in this port */ if (cfg->rsrp_neighbour) { - double energy = cabsf(srslte_vec_acc_cc(q->pilot_estimates, npilots) / npilots); + double energy = cabsf(srsran_vec_acc_cc(q->pilot_estimates, npilots) / npilots); q->rsrp_corr[rxant_id][port_id] = energy * energy; } - q->rsrp[rxant_id][port_id] = srslte_vec_avg_power_cf(q->pilot_recv_signal, npilots); + q->rsrp[rxant_id][port_id] = srsran_vec_avg_power_cf(q->pilot_recv_signal, npilots); q->rssi[rxant_id][port_id] = chest_dl_rssi(q, sf, input, port_id); chest_interpolate_noise_est(q, sf, cfg, input, ce, port_id, rxant_id); @@ -807,9 +807,9 @@ static int estimate_port(srslte_chest_dl_t* q, return 0; } -static int estimate_port_mbsfn(srslte_chest_dl_t* q, - srslte_dl_sf_cfg_t* sf, - srslte_chest_dl_cfg_t* cfg, +static int estimate_port_mbsfn(srsran_chest_dl_t* q, + srsran_dl_sf_cfg_t* sf, + srsran_chest_dl_cfg_t* cfg, cf_t* input, cf_t* ce, uint32_t port_id, @@ -823,26 +823,26 @@ static int estimate_port_mbsfn(srslte_chest_dl_t* q, } /* Use the known CSR signal to compute Least-squares estimates */ - srslte_refsignal_mbsfn_get_sf(q->cell, port_id, input, q->pilot_recv_signal); + srsran_refsignal_mbsfn_get_sf(q->cell, port_id, input, q->pilot_recv_signal); // estimate for non-mbsfn section of subframe - srslte_vec_prod_conj_ccc( + srsran_vec_prod_conj_ccc( q->pilot_recv_signal, q->csr_refs.pilots[port_id / 2][sf_idx], q->pilot_estimates, (2 * q->cell.nof_prb)); - srslte_vec_prod_conj_ccc(&q->pilot_recv_signal[(2 * q->cell.nof_prb)], + srsran_vec_prod_conj_ccc(&q->pilot_recv_signal[(2 * q->cell.nof_prb)], q->mbsfn_refs[mbsfn_area_id]->pilots[port_id / 2][sf_idx], &q->pilot_estimates[(2 * q->cell.nof_prb)], - SRSLTE_REFSIGNAL_NUM_SF_MBSFN(q->cell.nof_prb, port_id) - (2 * q->cell.nof_prb)); + SRSRAN_REFSIGNAL_NUM_SF_MBSFN(q->cell.nof_prb, port_id) - (2 * q->cell.nof_prb)); chest_interpolate_noise_est(q, sf, cfg, input, ce, port_id, rxant_id); return 0; } -static float get_noise(srslte_chest_dl_t* q) +static float get_noise(srsran_chest_dl_t* q) { float n = 0; for (int i = 0; i < q->nof_rx_antennas; i++) { - n += srslte_vec_acc_ff(q->noise_estimate[i], q->cell.nof_ports) / q->cell.nof_ports; + n += srsran_vec_acc_ff(q->noise_estimate[i], q->cell.nof_ports) / q->cell.nof_ports; } if (q->nof_rx_antennas) { n /= q->nof_rx_antennas; @@ -850,11 +850,11 @@ static float get_noise(srslte_chest_dl_t* q) return n; } -static float get_rssi(srslte_chest_dl_t* q) +static float get_rssi(srsran_chest_dl_t* q) { float n = 0; for (int i = 0; i < q->nof_rx_antennas; i++) { - n += 4 * q->rssi[i][0] / q->cell.nof_prb / SRSLTE_NRE; + n += 4 * q->rssi[i][0] / q->cell.nof_prb / SRSRAN_NRE; } return n / q->nof_rx_antennas; } @@ -862,7 +862,7 @@ static float get_rssi(srslte_chest_dl_t* q) /* q->rssi[0] is the average power in all RE in all symbol containing references for port 0 . q->rssi[0]/q->cell.nof_prb * is the average power per PRB q->rsrp[0] is the average power of RE containing references only (for port 0). */ -static float get_rsrq(srslte_chest_dl_t* q) +static float get_rsrq(srsran_chest_dl_t* q) { float n = 0; for (int i = 0; i < q->nof_rx_antennas; i++) { @@ -871,7 +871,7 @@ static float get_rsrq(srslte_chest_dl_t* q) return n / q->nof_rx_antennas; } -static float get_rsrp_port(srslte_chest_dl_t* q, uint32_t port) +static float get_rsrp_port(srsran_chest_dl_t* q, uint32_t port) { float sum = 0.0f; for (int j = 0; j < q->nof_rx_antennas; ++j) { @@ -885,7 +885,7 @@ static float get_rsrp_port(srslte_chest_dl_t* q, uint32_t port) return sum; } -static float get_rsrp_neighbour_port(srslte_chest_dl_t* q, uint32_t port) +static float get_rsrp_neighbour_port(srsran_chest_dl_t* q, uint32_t port) { float sum = 0.0f; for (int j = 0; j < q->cell.nof_ports; ++j) { @@ -899,7 +899,7 @@ static float get_rsrp_neighbour_port(srslte_chest_dl_t* q, uint32_t port) return sum; } -static float get_rsrp(srslte_chest_dl_t* q) +static float get_rsrp(srsran_chest_dl_t* q) { float max = -1e9; for (int i = 0; i < q->nof_rx_antennas; ++i) { @@ -911,17 +911,17 @@ static float get_rsrp(srslte_chest_dl_t* q) return max; } -static float get_snr(srslte_chest_dl_t* q) +static float get_snr(srsran_chest_dl_t* q) { #ifdef FREQ_SEL_SNR - int nref = SRSLTE_REFSIGNAL_NUM_SF(q->cell.nof_prb, 0); - return srslte_vec_acc_ff(q->snr_vector, nref) / nref; + int nref = SRSRAN_REFSIGNAL_NUM_SF(q->cell.nof_prb, 0); + return srsran_vec_acc_ff(q->snr_vector, nref) / nref; #else return get_rsrp(q) / get_noise(q); #endif } -static float get_rsrp_neighbour(srslte_chest_dl_t* q) +static float get_rsrp_neighbour(srsran_chest_dl_t* q) { float max = -1e9; for (int i = 0; i < q->nof_rx_antennas; ++i) { @@ -933,52 +933,52 @@ static float get_rsrp_neighbour(srslte_chest_dl_t* q) return max; } -static void fill_res(srslte_chest_dl_t* q, srslte_chest_dl_res_t* res) +static void fill_res(srsran_chest_dl_t* q, srsran_chest_dl_res_t* res) { res->noise_estimate = get_noise(q); - res->noise_estimate_dbm = srslte_convert_power_to_dBm(res->noise_estimate); + res->noise_estimate_dbm = srsran_convert_power_to_dBm(res->noise_estimate); res->cfo = q->cfo; res->rsrp = get_rsrp(q); - res->rsrp_dbm = srslte_convert_power_to_dBm(res->rsrp); + res->rsrp_dbm = srsran_convert_power_to_dBm(res->rsrp); res->rsrp_neigh = get_rsrp_neighbour(q); res->rsrq = get_rsrq(q); - res->rsrq_db = srslte_convert_power_to_dB(res->rsrq); - res->snr_db = srslte_convert_power_to_dB(get_snr(q)); - res->rssi_dbm = srslte_convert_power_to_dBm(get_rssi(q)); + res->rsrq_db = srsran_convert_power_to_dB(res->rsrq); + res->snr_db = srsran_convert_power_to_dB(get_snr(q)); + res->rssi_dbm = srsran_convert_power_to_dBm(get_rssi(q)); res->sync_error = q->sync_err[0][0]; // Take only the channel used for synch for (uint32_t port_id = 0; port_id < q->cell.nof_ports; port_id++) { - res->rsrp_port_dbm[port_id] = srslte_convert_power_to_dBm(get_rsrp_port(q, port_id)); + res->rsrp_port_dbm[port_id] = srsran_convert_power_to_dBm(get_rsrp_port(q, port_id)); for (uint32_t a = 0; a < q->nof_rx_antennas; a++) { if (q->noise_estimate[a]) { res->snr_ant_port_db[a][port_id] = - srslte_convert_power_to_dB(q->rsrp[a][port_id] / q->noise_estimate[a][port_id]); + srsran_convert_power_to_dB(q->rsrp[a][port_id] / q->noise_estimate[a][port_id]); } else { res->snr_ant_port_db[a][port_id] = 0.0f; } - res->rsrp_ant_port_dbm[a][port_id] = srslte_convert_power_to_dBm(q->rsrp[a][port_id]); + res->rsrp_ant_port_dbm[a][port_id] = srsran_convert_power_to_dBm(q->rsrp[a][port_id]); res->rsrq_ant_port_db[a][port_id] = - srslte_convert_power_to_dB(q->cell.nof_prb * q->rsrp[a][port_id] / q->rssi[a][port_id]); + srsran_convert_power_to_dB(q->cell.nof_prb * q->rsrp[a][port_id] / q->rssi[a][port_id]); } } } -int srslte_chest_dl_estimate(srslte_chest_dl_t* q, - srslte_dl_sf_cfg_t* sf, - cf_t* input[SRSLTE_MAX_PORTS], - srslte_chest_dl_res_t* res) +int srsran_chest_dl_estimate(srsran_chest_dl_t* q, + srsran_dl_sf_cfg_t* sf, + cf_t* input[SRSRAN_MAX_PORTS], + srsran_chest_dl_res_t* res) { - srslte_chest_dl_cfg_t cfg; + srsran_chest_dl_cfg_t cfg; ZERO_OBJECT(cfg); - return srslte_chest_dl_estimate_cfg(q, sf, &cfg, input, res); + return srsran_chest_dl_estimate_cfg(q, sf, &cfg, input, res); } -int srslte_chest_dl_estimate_cfg(srslte_chest_dl_t* q, - srslte_dl_sf_cfg_t* sf, - srslte_chest_dl_cfg_t* cfg, - cf_t* input[SRSLTE_MAX_PORTS], - srslte_chest_dl_res_t* res) +int srsran_chest_dl_estimate_cfg(srsran_chest_dl_t* q, + srsran_dl_sf_cfg_t* sf, + srsran_chest_dl_cfg_t* cfg, + cf_t* input[SRSRAN_MAX_PORTS], + srsran_chest_dl_res_t* res) { for (uint32_t rxant_id = 0; rxant_id < q->nof_rx_antennas; rxant_id++) { // Estimate and correct synchronization error if enabled @@ -987,13 +987,13 @@ int srslte_chest_dl_estimate_cfg(srslte_chest_dl_t* q, } for (uint32_t port_id = 0; port_id < q->cell.nof_ports; port_id++) { - if (sf->sf_type == SRSLTE_SF_MBSFN) { + if (sf->sf_type == SRSRAN_SF_MBSFN) { if (estimate_port_mbsfn(q, sf, cfg, input[rxant_id], res->ce[port_id][rxant_id], port_id, rxant_id)) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } else { if (estimate_port(q, sf, cfg, input[rxant_id], res->ce[port_id][rxant_id], port_id, rxant_id)) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } } @@ -1001,20 +1001,20 @@ int srslte_chest_dl_estimate_cfg(srslte_chest_dl_t* q, fill_res(q, res); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -srslte_chest_dl_estimator_alg_t srslte_chest_dl_str2estimator_alg(const char* str) +srsran_chest_dl_estimator_alg_t srsran_chest_dl_str2estimator_alg(const char* str) { - srslte_chest_dl_estimator_alg_t ret = SRSLTE_ESTIMATOR_ALG_AVERAGE; + srsran_chest_dl_estimator_alg_t ret = SRSRAN_ESTIMATOR_ALG_AVERAGE; if (str) { if (strcmp(str, "interpolate") == 0) { - ret = SRSLTE_ESTIMATOR_ALG_INTERPOLATE; + ret = SRSRAN_ESTIMATOR_ALG_INTERPOLATE; } else if (strcmp(str, "average") == 0) { - ret = SRSLTE_ESTIMATOR_ALG_AVERAGE; + ret = SRSRAN_ESTIMATOR_ALG_AVERAGE; } else if (strcmp(str, "wiener") == 0) { - ret = SRSLTE_ESTIMATOR_ALG_WIENER; + ret = SRSRAN_ESTIMATOR_ALG_WIENER; } } diff --git a/lib/src/phy/ch_estimation/chest_dl_nbiot.c b/lib/src/phy/ch_estimation/chest_dl_nbiot.c index eb2378cce..87337f5b5 100644 --- a/lib/src/phy/ch_estimation/chest_dl_nbiot.c +++ b/lib/src/phy/ch_estimation/chest_dl_nbiot.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -18,83 +18,83 @@ #include #include -#include "srslte/config.h" -#include "srslte/phy/utils/debug.h" +#include "srsran/config.h" +#include "srsran/phy/utils/debug.h" -#include "srslte/phy/ch_estimation/chest_dl_nbiot.h" -#include "srslte/phy/utils/convolution.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/ch_estimation/chest_dl_nbiot.h" +#include "srsran/phy/utils/convolution.h" +#include "srsran/phy/utils/vector.h" -int srslte_chest_dl_nbiot_init(srslte_chest_dl_nbiot_t* q, uint32_t max_prb) +int srsran_chest_dl_nbiot_init(srsran_chest_dl_nbiot_t* q, uint32_t max_prb) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL) { - bzero(q, sizeof(srslte_chest_dl_nbiot_t)); + bzero(q, sizeof(srsran_chest_dl_nbiot_t)); - ret = srslte_refsignal_dl_nbiot_init(&q->nrs_signal); - if (ret != SRSLTE_SUCCESS) { + ret = srsran_refsignal_dl_nbiot_init(&q->nrs_signal); + if (ret != SRSRAN_SUCCESS) { fprintf(stderr, "Error initializing CSR signal (%d)\n", ret); goto clean_exit; } - q->tmp_noise = srslte_vec_cf_malloc(SRSLTE_REFSIGNAL_MAX_NUM_SF(max_prb)); + q->tmp_noise = srsran_vec_cf_malloc(SRSRAN_REFSIGNAL_MAX_NUM_SF(max_prb)); if (!q->tmp_noise) { perror("malloc"); goto clean_exit; } - q->pilot_estimates = srslte_vec_cf_malloc(SRSLTE_REFSIGNAL_MAX_NUM_SF(max_prb) + SRSLTE_CHEST_MAX_SMOOTH_FIL_LEN); + q->pilot_estimates = srsran_vec_cf_malloc(SRSRAN_REFSIGNAL_MAX_NUM_SF(max_prb) + SRSRAN_CHEST_MAX_SMOOTH_FIL_LEN); if (!q->pilot_estimates) { perror("malloc"); goto clean_exit; } q->pilot_estimates_average = - srslte_vec_cf_malloc(SRSLTE_REFSIGNAL_MAX_NUM_SF(max_prb) + SRSLTE_CHEST_MAX_SMOOTH_FIL_LEN); + srsran_vec_cf_malloc(SRSRAN_REFSIGNAL_MAX_NUM_SF(max_prb) + SRSRAN_CHEST_MAX_SMOOTH_FIL_LEN); if (!q->pilot_estimates_average) { perror("malloc"); goto clean_exit; } - for (int i = 0; i < SRSLTE_REFSIGNAL_MAX_NUM_SF(max_prb); i++) { + for (int i = 0; i < SRSRAN_REFSIGNAL_MAX_NUM_SF(max_prb); i++) { q->pilot_estimates_average[i] = 1; } - q->pilot_recv_signal = srslte_vec_cf_malloc(SRSLTE_REFSIGNAL_MAX_NUM_SF(max_prb)); + q->pilot_recv_signal = srsran_vec_cf_malloc(SRSRAN_REFSIGNAL_MAX_NUM_SF(max_prb)); if (!q->pilot_recv_signal) { perror("malloc"); goto clean_exit; } - if (srslte_interp_linear_vector_init(&q->srslte_interp_linvec, SRSLTE_NRE * max_prb)) { + if (srsran_interp_linear_vector_init(&q->srsran_interp_linvec, SRSRAN_NRE * max_prb)) { fprintf(stderr, "Error initializing vector interpolator\n"); goto clean_exit; } - if (srslte_interp_linear_init(&q->srslte_interp_lin, 2 * max_prb, SRSLTE_NRE / 2)) { + if (srsran_interp_linear_init(&q->srsran_interp_lin, 2 * max_prb, SRSRAN_NRE / 2)) { fprintf(stderr, "Error initializing interpolator\n"); goto clean_exit; } - q->noise_alg = SRSLTE_NOISE_ALG_REFS; - srslte_chest_dl_nbiot_set_smooth_filter3_coeff(q, 0.1); + q->noise_alg = SRSRAN_NOISE_ALG_REFS; + srsran_chest_dl_nbiot_set_smooth_filter3_coeff(q, 0.1); - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } clean_exit: - if (ret != SRSLTE_SUCCESS) { - srslte_chest_dl_nbiot_free(q); + if (ret != SRSRAN_SUCCESS) { + srsran_chest_dl_nbiot_free(q); } return ret; } -void srslte_chest_dl_nbiot_free(srslte_chest_dl_nbiot_t* q) +void srsran_chest_dl_nbiot_free(srsran_chest_dl_nbiot_t* q) { - srslte_refsignal_dl_nbiot_free(&q->nrs_signal); + srsran_refsignal_dl_nbiot_free(&q->nrs_signal); if (q->tmp_noise) { free(q->tmp_noise); } - srslte_interp_linear_vector_free(&q->srslte_interp_linvec); - srslte_interp_linear_free(&q->srslte_interp_lin); + srsran_interp_linear_vector_free(&q->srsran_interp_linvec); + srsran_interp_linear_free(&q->srsran_interp_lin); if (q->pilot_estimates) { free(q->pilot_estimates); @@ -107,47 +107,47 @@ void srslte_chest_dl_nbiot_free(srslte_chest_dl_nbiot_t* q) } } -int srslte_chest_dl_nbiot_set_cell(srslte_chest_dl_nbiot_t* q, srslte_nbiot_cell_t cell) +int srsran_chest_dl_nbiot_set_cell(srsran_chest_dl_nbiot_t* q, srsran_nbiot_cell_t cell) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; // set ports configuration if (cell.nof_ports == 0) { - cell.nof_ports = SRSLTE_NBIOT_MAX_PORTS; + cell.nof_ports = SRSRAN_NBIOT_MAX_PORTS; } - if (q != NULL && srslte_nbiot_cell_isvalid(&cell)) { + if (q != NULL && srsran_nbiot_cell_isvalid(&cell)) { if (q->cell.n_id_ncell != cell.n_id_ncell || q->cell.base.nof_prb == 0) { q->cell = cell; - ret = srslte_refsignal_dl_nbiot_set_cell(&q->nrs_signal, cell); - if (ret != SRSLTE_SUCCESS) { + ret = srsran_refsignal_dl_nbiot_set_cell(&q->nrs_signal, cell); + if (ret != SRSRAN_SUCCESS) { fprintf(stderr, "Error initializing NRS signal (%d)\n", ret); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_interp_linear_vector_resize(&q->srslte_interp_linvec, SRSLTE_NRE * cell.base.nof_prb)) { + if (srsran_interp_linear_vector_resize(&q->srsran_interp_linvec, SRSRAN_NRE * cell.base.nof_prb)) { fprintf(stderr, "Error initializing vector interpolator\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_interp_linear_resize(&q->srslte_interp_lin, 2 * cell.base.nof_prb, SRSLTE_NRE / 2)) { + if (srsran_interp_linear_resize(&q->srsran_interp_lin, 2 * cell.base.nof_prb, SRSRAN_NRE / 2)) { fprintf(stderr, "Error initializing interpolator\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } /* Uses the difference between the averaged and non-averaged pilot estimates */ -static float estimate_noise_pilots(srslte_chest_dl_nbiot_t* q, uint32_t port_id) +static float estimate_noise_pilots(srsran_chest_dl_nbiot_t* q, uint32_t port_id) { - int nref = srslte_refsignal_cs_nof_re(NULL, NULL, port_id); + int nref = srsran_refsignal_cs_nof_re(NULL, NULL, port_id); // Substract noisy pilot estimates - srslte_vec_sub_ccc(q->pilot_estimates_average, q->pilot_estimates, q->tmp_noise, nref); + srsran_vec_sub_ccc(q->pilot_estimates_average, q->pilot_estimates, q->tmp_noise, nref); // Compute average power. Normalized for filter len 3 using ML float norm = 1; @@ -156,34 +156,34 @@ static float estimate_noise_pilots(srslte_chest_dl_nbiot_t* q, uint32_t port_id) float norm3 = 6.143 * a * a + 0.04859 * a - 0.002774; norm /= norm3; } - float power = norm * q->cell.nof_ports * srslte_vec_avg_power_cf(q->tmp_noise, nref); + float power = norm * q->cell.nof_ports * srsran_vec_avg_power_cf(q->tmp_noise, nref); return power; } -#define cesymb(i) ce[SRSLTE_RE_IDX(q->cell.base.nof_prb, (i), 0)] +#define cesymb(i) ce[SRSRAN_RE_IDX(q->cell.base.nof_prb, (i), 0)] -static void interpolate_pilots(srslte_chest_dl_nbiot_t* q, cf_t* pilot_estimates, cf_t* ce, uint32_t port_id) +static void interpolate_pilots(srsran_chest_dl_nbiot_t* q, cf_t* pilot_estimates, cf_t* ce, uint32_t port_id) { - uint32_t nsymbols = srslte_refsignal_cs_nof_symbols(NULL, NULL, port_id); - int num_ces = q->cell.base.nof_prb * SRSLTE_NRE; + uint32_t nsymbols = srsran_refsignal_cs_nof_symbols(NULL, NULL, port_id); + int num_ces = q->cell.base.nof_prb * SRSRAN_NRE; cf_t ce_avg[2][num_ces]; // interpolate the symbols with references in the freq domain DEBUG("Interpolating %d pilots in %d symbols at port %d.", nsymbols * 2, nsymbols, port_id); for (int l = 0; l < nsymbols; l++) { - uint32_t fidx_offset = srslte_refsignal_dl_nbiot_fidx(q->cell, l, port_id, 0); + uint32_t fidx_offset = srsran_refsignal_dl_nbiot_fidx(q->cell, l, port_id, 0); // points to the RE of the beginning of the l'th symbol containing a ref - uint32_t ce_idx = srslte_refsignal_nrs_nsymbol(l) * q->cell.base.nof_prb * SRSLTE_NRE; - ce_idx += q->cell.nbiot_prb * SRSLTE_NRE; - DEBUG(" - freq.-dmn interp. in sym %d at RE %d", srslte_refsignal_nrs_nsymbol(l), ce_idx + fidx_offset); - srslte_interp_linear_offset( - &q->srslte_interp_lin, &pilot_estimates[2 * l], &ce[ce_idx], fidx_offset, SRSLTE_NRE / 2 - fidx_offset); + uint32_t ce_idx = srsran_refsignal_nrs_nsymbol(l) * q->cell.base.nof_prb * SRSRAN_NRE; + ce_idx += q->cell.nbiot_prb * SRSRAN_NRE; + DEBUG(" - freq.-dmn interp. in sym %d at RE %d", srsran_refsignal_nrs_nsymbol(l), ce_idx + fidx_offset); + srsran_interp_linear_offset( + &q->srsran_interp_lin, &pilot_estimates[2 * l], &ce[ce_idx], fidx_offset, SRSRAN_NRE / 2 - fidx_offset); } // average the two neighbor subcarriers containing pilots for (int l = 0; l < nsymbols / 2; l++) { - int sym_idx = srslte_refsignal_nrs_nsymbol(l * 2); - srslte_vec_sum_ccc(&cesymb(sym_idx), &cesymb(sym_idx + 1), ce_avg[l], num_ces); + int sym_idx = srsran_refsignal_nrs_nsymbol(l * 2); + srsran_vec_sum_ccc(&cesymb(sym_idx), &cesymb(sym_idx + 1), ce_avg[l], num_ces); // TODO: use vector operation for this for (int k = 0; k < num_ces; k++) { ce_avg[l][k] /= 2; @@ -194,13 +194,13 @@ static void interpolate_pilots(srslte_chest_dl_nbiot_t* q, cf_t* pilot_estimates } // now interpolate in the time domain between symbols - srslte_interp_linear_vector(&q->srslte_interp_linvec, ce_avg[0], ce_avg[1], &cesymb(0), 5, 5); - srslte_interp_linear_vector(&q->srslte_interp_linvec, ce_avg[0], ce_avg[1], &cesymb(7), 5, 5); + srsran_interp_linear_vector(&q->srsran_interp_linvec, ce_avg[0], ce_avg[1], &cesymb(0), 5, 5); + srsran_interp_linear_vector(&q->srsran_interp_linvec, ce_avg[0], ce_avg[1], &cesymb(7), 5, 5); } -void srslte_chest_dl_nbiot_set_smooth_filter(srslte_chest_dl_nbiot_t* q, float* filter, uint32_t filter_len) +void srsran_chest_dl_nbiot_set_smooth_filter(srsran_chest_dl_nbiot_t* q, float* filter, uint32_t filter_len) { - if (filter_len < SRSLTE_CHEST_MAX_SMOOTH_FIL_LEN) { + if (filter_len < SRSRAN_CHEST_MAX_SMOOTH_FIL_LEN) { if (filter) { memcpy(q->smooth_filter, filter, filter_len * sizeof(float)); q->smooth_filter_len = filter_len; @@ -211,16 +211,16 @@ void srslte_chest_dl_nbiot_set_smooth_filter(srslte_chest_dl_nbiot_t* q, float* fprintf(stderr, "Error setting smoothing filter: filter len exceeds maximum (%d>%d)\n", filter_len, - SRSLTE_CHEST_MAX_SMOOTH_FIL_LEN); + SRSRAN_CHEST_MAX_SMOOTH_FIL_LEN); } } -void srslte_chest_dl_nbiot_set_noise_alg(srslte_chest_dl_nbiot_t* q, srslte_chest_dl_noise_alg_t noise_estimation_alg) +void srsran_chest_dl_nbiot_set_noise_alg(srsran_chest_dl_nbiot_t* q, srsran_chest_dl_noise_alg_t noise_estimation_alg) { q->noise_alg = noise_estimation_alg; } -void srslte_chest_dl_nbiot_set_smooth_filter3_coeff(srslte_chest_dl_nbiot_t* q, float w) +void srsran_chest_dl_nbiot_set_smooth_filter3_coeff(srsran_chest_dl_nbiot_t* q, float w) { q->smooth_filter_len = 3; q->smooth_filter[0] = w; @@ -228,52 +228,52 @@ void srslte_chest_dl_nbiot_set_smooth_filter3_coeff(srslte_chest_dl_nbiot_t* q, q->smooth_filter[1] = 1 - 2 * w; } -static void average_pilots(srslte_chest_dl_nbiot_t* q, cf_t* input, cf_t* output, uint32_t port_id) +static void average_pilots(srsran_chest_dl_nbiot_t* q, cf_t* input, cf_t* output, uint32_t port_id) { - uint32_t nsymbols = srslte_refsignal_cs_nof_symbols(NULL, NULL, port_id); + uint32_t nsymbols = srsran_refsignal_cs_nof_symbols(NULL, NULL, port_id); uint32_t nref = 2; // Average in the frequency domain for (int l = 0; l < nsymbols; l++) { - srslte_conv_same_cf(&input[l * nref], q->smooth_filter, &output[l * nref], nref, q->smooth_filter_len); + srsran_conv_same_cf(&input[l * nref], q->smooth_filter, &output[l * nref], nref, q->smooth_filter_len); } } -float srslte_chest_nbiot_dl_rssi(srslte_chest_dl_nbiot_t* q, cf_t* input, uint32_t port_id) +float srsran_chest_nbiot_dl_rssi(srsran_chest_dl_nbiot_t* q, cf_t* input, uint32_t port_id) { float rssi = 0; - uint32_t nsymbols = srslte_refsignal_cs_nof_symbols(NULL, NULL, port_id); + uint32_t nsymbols = srsran_refsignal_cs_nof_symbols(NULL, NULL, port_id); for (uint32_t l = 0; l < nsymbols; l++) { - cf_t* tmp = &input[srslte_refsignal_nrs_nsymbol(l) * SRSLTE_NRE]; - rssi += srslte_vec_dot_prod_conj_ccc(tmp, tmp, SRSLTE_NRE); + cf_t* tmp = &input[srsran_refsignal_nrs_nsymbol(l) * SRSRAN_NRE]; + rssi += srsran_vec_dot_prod_conj_ccc(tmp, tmp, SRSRAN_NRE); } return rssi / nsymbols; } -int srslte_chest_dl_nbiot_estimate_port(srslte_chest_dl_nbiot_t* q, +int srsran_chest_dl_nbiot_estimate_port(srsran_chest_dl_nbiot_t* q, cf_t* input, cf_t* ce, uint32_t sf_idx, uint32_t port_id) { DEBUG("x.%d: Estimating DL channel on port %d.", sf_idx, port_id); - int nref = srslte_refsignal_nbiot_cs_nof_re(&q->cell, port_id); + int nref = srsran_refsignal_nbiot_cs_nof_re(&q->cell, port_id); // Get references from the input signal - srslte_refsignal_nrs_get_sf(q->cell, port_id, input, q->pilot_recv_signal); + srsran_refsignal_nrs_get_sf(q->cell, port_id, input, q->pilot_recv_signal); // Use the known NRS signal to compute Least-squares estimates - srslte_vec_prod_conj_ccc(q->pilot_recv_signal, q->nrs_signal.pilots[port_id][sf_idx], q->pilot_estimates, nref); + srsran_vec_prod_conj_ccc(q->pilot_recv_signal, q->nrs_signal.pilots[port_id][sf_idx], q->pilot_estimates, nref); - if (SRSLTE_VERBOSE_ISDEBUG()) { + if (SRSRAN_VERBOSE_ISDEBUG()) { printf("Rx pilots:\n"); - srslte_vec_fprint_c(stdout, q->pilot_recv_signal, nref); + srsran_vec_fprint_c(stdout, q->pilot_recv_signal, nref); printf("Tx pilots on port=%d for sf_idx=%d:\n", port_id, sf_idx); - srslte_vec_fprint_c(stdout, q->nrs_signal.pilots[port_id][sf_idx], nref); + srsran_vec_fprint_c(stdout, q->nrs_signal.pilots[port_id][sf_idx], nref); printf("Estimates:\n"); - srslte_vec_fprint_c(stdout, q->pilot_estimates, nref); + srsran_vec_fprint_c(stdout, q->pilot_estimates, nref); printf("Average estimates:\n"); - srslte_vec_fprint_c(stdout, q->pilot_estimates_average, nref); + srsran_vec_fprint_c(stdout, q->pilot_estimates_average, nref); } if (ce != NULL) { @@ -286,60 +286,60 @@ int srslte_chest_dl_nbiot_estimate_port(srslte_chest_dl_nbiot_t* q, } // Estimate noise power - if (q->noise_alg == SRSLTE_NOISE_ALG_REFS && q->smooth_filter_len > 0) { + if (q->noise_alg == SRSRAN_NOISE_ALG_REFS && q->smooth_filter_len > 0) { q->noise_estimate[port_id] = estimate_noise_pilots(q, port_id); } } - if (SRSLTE_VERBOSE_ISDEBUG()) { + if (SRSRAN_VERBOSE_ISDEBUG()) { printf("Updated Average estimates:\n"); - srslte_vec_fprint_c(stdout, q->pilot_estimates_average, nref); + srsran_vec_fprint_c(stdout, q->pilot_estimates_average, nref); } // Compute RSRP for the channel estimates in this port - q->rsrp[port_id] = srslte_vec_avg_power_cf(q->pilot_recv_signal, nref); + q->rsrp[port_id] = srsran_vec_avg_power_cf(q->pilot_recv_signal, nref); if (port_id == 0) { // compute rssi only for port 0 - q->rssi[port_id] = srslte_chest_nbiot_dl_rssi(q, input, port_id); + q->rssi[port_id] = srsran_chest_nbiot_dl_rssi(q, input, port_id); } return 0; } -int srslte_chest_dl_nbiot_estimate(srslte_chest_dl_nbiot_t* q, cf_t* input, cf_t** ce, uint32_t sf_idx) +int srsran_chest_dl_nbiot_estimate(srsran_chest_dl_nbiot_t* q, cf_t* input, cf_t** ce, uint32_t sf_idx) { for (uint32_t port_id = 0; port_id < q->cell.nof_ports; port_id++) { - srslte_chest_dl_nbiot_estimate_port(q, input, ce[port_id], sf_idx, port_id); + srsran_chest_dl_nbiot_estimate_port(q, input, ce[port_id], sf_idx, port_id); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -float srslte_chest_dl_nbiot_get_noise_estimate(srslte_chest_dl_nbiot_t* q) +float srsran_chest_dl_nbiot_get_noise_estimate(srsran_chest_dl_nbiot_t* q) { - return srslte_vec_acc_ff(q->noise_estimate, q->cell.nof_ports) / q->cell.nof_ports; + return srsran_vec_acc_ff(q->noise_estimate, q->cell.nof_ports) / q->cell.nof_ports; } -float srslte_chest_dl_nbiot_get_snr(srslte_chest_dl_nbiot_t* q) +float srsran_chest_dl_nbiot_get_snr(srsran_chest_dl_nbiot_t* q) { - return srslte_chest_dl_nbiot_get_rsrp(q) / srslte_chest_dl_nbiot_get_noise_estimate(q); + return srsran_chest_dl_nbiot_get_rsrp(q) / srsran_chest_dl_nbiot_get_noise_estimate(q); } -float srslte_chest_dl_nbiot_get_rssi(srslte_chest_dl_nbiot_t* q) +float srsran_chest_dl_nbiot_get_rssi(srsran_chest_dl_nbiot_t* q) { - return 4 * q->rssi[0] / SRSLTE_NRE; + return 4 * q->rssi[0] / SRSRAN_NRE; } /* q->rssi[0] is the average power in all RE in all symbol containing references for port 0. * q->rssi[0]/q->cell.nof_prb is the average power per PRB * q->rsrp[0] is the average power of RE containing references only (for port 0). */ -float srslte_chest_dl_nbiot_get_rsrq(srslte_chest_dl_nbiot_t* q) +float srsran_chest_dl_nbiot_get_rsrq(srsran_chest_dl_nbiot_t* q) { return q->rsrp[0] / q->rssi[0]; } -float srslte_chest_dl_nbiot_get_rsrp(srslte_chest_dl_nbiot_t* q) +float srsran_chest_dl_nbiot_get_rsrp(srsran_chest_dl_nbiot_t* q) { // return sum of power received from all tx ports - return srslte_vec_acc_ff(q->rsrp, q->cell.nof_ports); + return srsran_vec_acc_ff(q->rsrp, q->cell.nof_ports); } \ No newline at end of file diff --git a/lib/src/phy/ch_estimation/chest_sl.c b/lib/src/phy/ch_estimation/chest_sl.c index 8ccf356e5..fb409e738 100644 --- a/lib/src/phy/ch_estimation/chest_sl.c +++ b/lib/src/phy/ch_estimation/chest_sl.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -16,74 +16,74 @@ #include #include -#include "srslte/phy/ch_estimation/chest_sl.h" -#include "srslte/phy/common/zc_sequence.h" -#include "srslte/phy/mimo/precoding.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/ch_estimation/chest_sl.h" +#include "srsran/phy/common/zc_sequence.h" +#include "srsran/phy/mimo/precoding.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" -static int chest_sl_init(srslte_chest_sl_t* q, uint32_t nof_cyclic_shift_seq) +static int chest_sl_init(srsran_chest_sl_t* q, uint32_t nof_cyclic_shift_seq) { - q->sf_n_re = SRSLTE_CP_NSYMB(q->cell.cp) * SRSLTE_NRE * q->cell.nof_prb * 2; + q->sf_n_re = SRSRAN_CP_NSYMB(q->cell.cp) * SRSRAN_NRE * q->cell.nof_prb * 2; - srslte_interp_linear_vector_init(&q->lin_vec_sl, SRSLTE_MAX_PRB * SRSLTE_NRE); + srsran_interp_linear_vector_init(&q->lin_vec_sl, SRSRAN_MAX_PRB * SRSRAN_NRE); - for (int i = 0; i < SRSLTE_SL_MAX_DMRS_SYMB; i++) { + for (int i = 0; i < SRSRAN_SL_MAX_DMRS_SYMB; i++) { for (int j = 0; j < nof_cyclic_shift_seq; j++) { - q->r_sequence[i][j] = srslte_vec_cf_malloc(SRSLTE_MAX_PRB * SRSLTE_NRE); + q->r_sequence[i][j] = srsran_vec_cf_malloc(SRSRAN_MAX_PRB * SRSRAN_NRE); if (!q->r_sequence[i][j]) { ERROR("Error allocating memory"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } - q->r_sequence_rx[i] = srslte_vec_cf_malloc(SRSLTE_MAX_PRB * SRSLTE_NRE); + q->r_sequence_rx[i] = srsran_vec_cf_malloc(SRSRAN_MAX_PRB * SRSRAN_NRE); if (!q->r_sequence_rx[i]) { ERROR("Error allocating memory"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } - q->f_gh_pattern = srslte_vec_u32_malloc(SRSLTE_SL_MAX_DMRS_PERIOD_LENGTH); // MAX PERIOD LENGTH 320 + q->f_gh_pattern = srsran_vec_u32_malloc(SRSRAN_SL_MAX_DMRS_PERIOD_LENGTH); // MAX PERIOD LENGTH 320 if (!q->f_gh_pattern) { ERROR("Error allocating memory"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - q->ce = srslte_vec_cf_malloc(2 * SRSLTE_CP_NSYMB(SRSLTE_CP_NORM) * SRSLTE_NRE * SRSLTE_MAX_PRB); + q->ce = srsran_vec_cf_malloc(2 * SRSRAN_CP_NSYMB(SRSRAN_CP_NORM) * SRSRAN_NRE * SRSRAN_MAX_PRB); if (!q->ce) { ERROR("Error allocating memory"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - q->ce_average = srslte_vec_cf_malloc(2 * SRSLTE_CP_NSYMB(SRSLTE_CP_NORM) * SRSLTE_NRE * SRSLTE_MAX_PRB); + q->ce_average = srsran_vec_cf_malloc(2 * SRSRAN_CP_NSYMB(SRSRAN_CP_NORM) * SRSRAN_NRE * SRSRAN_MAX_PRB); if (!q->ce_average) { ERROR("Error allocating memory"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - q->noise_tmp = srslte_vec_cf_malloc(2 * SRSLTE_CP_NSYMB(SRSLTE_CP_NORM) * SRSLTE_NRE * SRSLTE_MAX_PRB); + q->noise_tmp = srsran_vec_cf_malloc(2 * SRSRAN_CP_NSYMB(SRSRAN_CP_NORM) * SRSRAN_NRE * SRSRAN_MAX_PRB); if (!q->noise_tmp) { ERROR("Error allocating memory"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } q->sync_error_enable = true; q->rsrp_enable = true; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -static int chest_sl_psbch_gen(srslte_chest_sl_t* q) +static int chest_sl_psbch_gen(srsran_chest_sl_t* q) { // M_sc_rs - Reference Signal Length - q->M_sc_rs = SRSLTE_PSBCH_NOF_PRB * SRSLTE_NRE; + q->M_sc_rs = SRSRAN_PSBCH_NOF_PRB * SRSRAN_NRE; // Number of DMRS symbols - if (q->cell.tm <= SRSLTE_SIDELINK_TM2) { - q->nof_dmrs_symbols = SRSLTE_SL_TM12_DEFAULT_NUM_DMRS_SYMBOLS; + if (q->cell.tm <= SRSRAN_SIDELINK_TM2) { + q->nof_dmrs_symbols = SRSRAN_SL_TM12_DEFAULT_NUM_DMRS_SYMBOLS; } else { - q->nof_dmrs_symbols = SRSLTE_PSBCH_TM34_NUM_DMRS_SYMBOLS; + q->nof_dmrs_symbols = SRSRAN_PSBCH_TM34_NUM_DMRS_SYMBOLS; } // Cyclic Shift follows 36.211, Section 9.8 @@ -99,17 +99,17 @@ static int chest_sl_psbch_gen(srslte_chest_sl_t* q) // Group Hopping uint32_t f_gh = 0; // Group Hopping Flag uint32_t f_ss = 0; - uint32_t u[SRSLTE_SL_MAX_DMRS_SYMB] = {}; // Sequence Group Number + uint32_t u[SRSRAN_SL_MAX_DMRS_SYMB] = {}; // Sequence Group Number // 36.211, Section 10.1.4.1.3 Base Sequence Number - always 0 for sidelink f_gh = 0; - f_ss = (q->cell.N_sl_id / 16) % SRSLTE_SL_N_RU_SEQ; + f_ss = (q->cell.N_sl_id / 16) % SRSRAN_SL_N_RU_SEQ; for (int ns = 0; ns < q->nof_dmrs_symbols; ns++) { - u[ns] = (f_gh + f_ss) % SRSLTE_SL_N_RU_SEQ; + u[ns] = (f_gh + f_ss) % SRSRAN_SL_N_RU_SEQ; } // w - Orthogonal Sequence, 36.211 Section 9.8 - if (q->cell.tm <= SRSLTE_SIDELINK_TM2) { + if (q->cell.tm <= SRSRAN_SIDELINK_TM2) { if (q->cell.N_sl_id % 2) { q->w[0] = 1; q->w[1] = -1; @@ -134,60 +134,60 @@ static int chest_sl_psbch_gen(srslte_chest_sl_t* q) cf_t* seq = q->r_sequence[j][0]; // Generate R_uv sequences - srslte_zc_sequence_generate_lte(u[j], SRSLTE_SL_BASE_SEQUENCE_NUMBER, q->alpha[0], q->M_sc_rs / SRSLTE_NRE, seq); + srsran_zc_sequence_generate_lte(u[j], SRSRAN_SL_BASE_SEQUENCE_NUMBER, q->alpha[0], q->M_sc_rs / SRSRAN_NRE, seq); // Apply w - srslte_vec_sc_prod_ccc(seq, q->w[j], seq, q->M_sc_rs); + srsran_vec_sc_prod_ccc(seq, q->w[j], seq, q->M_sc_rs); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -static int chest_sl_psbch_put_dmrs(srslte_chest_sl_t* q, cf_t* sf_buffer) +static int chest_sl_psbch_put_dmrs(srsran_chest_sl_t* q, cf_t* sf_buffer) { uint32_t dmrs_idx = 0; - uint32_t k = q->cell.nof_prb * SRSLTE_NRE / 2 - 36; + uint32_t k = q->cell.nof_prb * SRSRAN_NRE / 2 - 36; // Mapping to physical resources - for (uint32_t i = 0; i < srslte_sl_get_num_symbols(q->cell.tm, q->cell.cp); i++) { - if (srslte_psbch_is_symbol(SRSLTE_SIDELINK_DMRS_SYMBOL, q->cell.tm, i, q->cell.cp)) { - memcpy(&sf_buffer[k + i * q->cell.nof_prb * SRSLTE_NRE], q->r_sequence[dmrs_idx][0], q->M_sc_rs * sizeof(cf_t)); + for (uint32_t i = 0; i < srsran_sl_get_num_symbols(q->cell.tm, q->cell.cp); i++) { + if (srsran_psbch_is_symbol(SRSRAN_SIDELINK_DMRS_SYMBOL, q->cell.tm, i, q->cell.cp)) { + memcpy(&sf_buffer[k + i * q->cell.nof_prb * SRSRAN_NRE], q->r_sequence[dmrs_idx][0], q->M_sc_rs * sizeof(cf_t)); dmrs_idx++; } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -static int chest_sl_psbch_get_dmrs(srslte_chest_sl_t* q, cf_t* sf_buffer, cf_t** dmrs_received) +static int chest_sl_psbch_get_dmrs(srsran_chest_sl_t* q, cf_t* sf_buffer, cf_t** dmrs_received) { uint32_t dmrs_idx = 0; - uint32_t k = q->cell.nof_prb * SRSLTE_NRE / 2 - 36; + uint32_t k = q->cell.nof_prb * SRSRAN_NRE / 2 - 36; // Get PSBCH DMRS symbols - for (uint32_t i = 0; i < srslte_sl_get_num_symbols(q->cell.tm, q->cell.cp); i++) { - if (srslte_psbch_is_symbol(SRSLTE_SIDELINK_DMRS_SYMBOL, q->cell.tm, i, q->cell.cp)) { - memcpy(dmrs_received[dmrs_idx], &sf_buffer[k + i * q->cell.nof_prb * SRSLTE_NRE], q->M_sc_rs * sizeof(cf_t)); + for (uint32_t i = 0; i < srsran_sl_get_num_symbols(q->cell.tm, q->cell.cp); i++) { + if (srsran_psbch_is_symbol(SRSRAN_SIDELINK_DMRS_SYMBOL, q->cell.tm, i, q->cell.cp)) { + memcpy(dmrs_received[dmrs_idx], &sf_buffer[k + i * q->cell.nof_prb * SRSRAN_NRE], q->M_sc_rs * sizeof(cf_t)); dmrs_idx++; } } return dmrs_idx; } -static void interpolate_pilots_sl_psbch(srslte_chest_sl_t* q) +static void interpolate_pilots_sl_psbch(srsran_chest_sl_t* q) { - uint32_t NL = srslte_sl_get_num_symbols(q->cell.tm, q->cell.cp); - uint32_t ce_l[SRSLTE_SL_MAX_DMRS_SYMB] = {}; - uint32_t n_re = q->cell.nof_prb * SRSLTE_NRE; + uint32_t NL = srsran_sl_get_num_symbols(q->cell.tm, q->cell.cp); + uint32_t ce_l[SRSRAN_SL_MAX_DMRS_SYMB] = {}; + uint32_t n_re = q->cell.nof_prb * SRSRAN_NRE; uint32_t l_idx = 0; - uint32_t L[SRSLTE_SL_MAX_DMRS_SYMB] = {}; + uint32_t L[SRSRAN_SL_MAX_DMRS_SYMB] = {}; uint32_t k = 0; - srslte_interp_linear_vector_resize(&q->lin_vec_sl, n_re); + srsran_interp_linear_vector_resize(&q->lin_vec_sl, n_re); for (int i = 0; i < NL; i++) { - if (srslte_psbch_is_symbol(SRSLTE_SIDELINK_DMRS_SYMBOL, q->cell.tm, i, q->cell.cp)) { + if (srsran_psbch_is_symbol(SRSRAN_SIDELINK_DMRS_SYMBOL, q->cell.tm, i, q->cell.cp)) { L[l_idx] = i; l_idx++; } @@ -200,12 +200,12 @@ static void interpolate_pilots_sl_psbch(srslte_chest_sl_t* q) } for (uint32_t n = 0; n < l_idx; n++) { - ce_l[n] = SRSLTE_RE_IDX(q->cell.nof_prb, L[n], 0 * SRSLTE_NRE); + ce_l[n] = SRSRAN_RE_IDX(q->cell.nof_prb, L[n], 0 * SRSRAN_NRE); } - k = q->cell.nof_prb * SRSLTE_NRE / 2 - 36; + k = q->cell.nof_prb * SRSRAN_NRE / 2 - 36; - srslte_interp_linear_vector3(&q->lin_vec_sl, + srsran_interp_linear_vector3(&q->lin_vec_sl, &q->ce[ce_l[1] + k], &q->ce[ce_l[0] + k], &q->ce[ce_l[0] + k], @@ -216,7 +216,7 @@ static void interpolate_pilots_sl_psbch(srslte_chest_sl_t* q) q->M_sc_rs); for (uint32_t n = 1; n < l_idx; n++) { - srslte_interp_linear_vector3(&q->lin_vec_sl, + srsran_interp_linear_vector3(&q->lin_vec_sl, &q->ce[ce_l[n - 1] + k], &q->ce[ce_l[n] + k], NULL, @@ -227,7 +227,7 @@ static void interpolate_pilots_sl_psbch(srslte_chest_sl_t* q) q->M_sc_rs); } - srslte_interp_linear_vector3(&q->lin_vec_sl, + srsran_interp_linear_vector3(&q->lin_vec_sl, &q->ce[ce_l[l_idx - 2] + k], &q->ce[ce_l[l_idx - 1] + k], &q->ce[ce_l[l_idx - 1] + k], @@ -238,21 +238,21 @@ static void interpolate_pilots_sl_psbch(srslte_chest_sl_t* q) q->M_sc_rs); } -static void chest_sl_psbch_ls_estimate(srslte_chest_sl_t* q, cf_t* sf_buffer) +static void chest_sl_psbch_ls_estimate(srsran_chest_sl_t* q, cf_t* sf_buffer) { uint32_t dmrs_index = 0; - uint32_t k = q->cell.nof_prb * SRSLTE_NRE / 2 - 36; - uint32_t sf_nsymbols = srslte_sl_get_num_symbols(q->cell.tm, q->cell.cp); - uint32_t sf_n_re = SRSLTE_SF_LEN_RE(q->cell.nof_prb, q->cell.cp); + uint32_t k = q->cell.nof_prb * SRSRAN_NRE / 2 - 36; + uint32_t sf_nsymbols = srsran_sl_get_num_symbols(q->cell.tm, q->cell.cp); + uint32_t sf_n_re = SRSRAN_SF_LEN_RE(q->cell.nof_prb, q->cell.cp); // Get Pilot Estimates // Use the known DMRS signal to compute least-squares estimates - srslte_vec_cf_zero(q->ce, sf_n_re); + srsran_vec_cf_zero(q->ce, sf_n_re); for (uint32_t i = 0; i < sf_nsymbols; i++) { - if (srslte_psbch_is_symbol(SRSLTE_SIDELINK_DMRS_SYMBOL, q->cell.tm, i, q->cell.cp)) { - srslte_vec_prod_conj_ccc(&sf_buffer[i * q->cell.nof_prb * SRSLTE_NRE + k], + if (srsran_psbch_is_symbol(SRSRAN_SIDELINK_DMRS_SYMBOL, q->cell.tm, i, q->cell.cp)) { + srsran_vec_prod_conj_ccc(&sf_buffer[i * q->cell.nof_prb * SRSRAN_NRE + k], &q->r_sequence[dmrs_index][0][0], - &q->ce[i * q->cell.nof_prb * SRSLTE_NRE + k], + &q->ce[i * q->cell.nof_prb * SRSRAN_NRE + k], q->M_sc_rs); dmrs_index++; } @@ -261,24 +261,24 @@ static void chest_sl_psbch_ls_estimate(srslte_chest_sl_t* q, cf_t* sf_buffer) interpolate_pilots_sl_psbch(q); } -static int chest_sl_pscch_gen(srslte_chest_sl_t* q, uint32_t cyclic_shift) +static int chest_sl_pscch_gen(srsran_chest_sl_t* q, uint32_t cyclic_shift) { // M_sc_rs - Reference Signal Length - if (q->cell.tm <= SRSLTE_SIDELINK_TM2) { - q->M_sc_rs = SRSLTE_NRE; + if (q->cell.tm <= SRSRAN_SIDELINK_TM2) { + q->M_sc_rs = SRSRAN_NRE; } else { - q->M_sc_rs = SRSLTE_PSCCH_TM34_NOF_PRB * SRSLTE_NRE; + q->M_sc_rs = SRSRAN_PSCCH_TM34_NOF_PRB * SRSRAN_NRE; } // Number of DMRS symbols - if (q->cell.tm <= SRSLTE_SIDELINK_TM2) { - q->nof_dmrs_symbols = SRSLTE_SL_TM12_DEFAULT_NUM_DMRS_SYMBOLS; + if (q->cell.tm <= SRSRAN_SIDELINK_TM2) { + q->nof_dmrs_symbols = SRSRAN_SL_TM12_DEFAULT_NUM_DMRS_SYMBOLS; } else { - q->nof_dmrs_symbols = SRSLTE_SL_TM34_DEFAULT_NUM_DMRS_SYMBOLS; + q->nof_dmrs_symbols = SRSRAN_SL_TM34_DEFAULT_NUM_DMRS_SYMBOLS; } // Cyclic Shift follows 36.211, Section 9.8 - if (q->cell.tm <= SRSLTE_SIDELINK_TM2) { + if (q->cell.tm <= SRSRAN_SIDELINK_TM2) { for (int i = 0; i < q->nof_dmrs_symbols; i++) { q->n_CS[i] = 0; } @@ -296,21 +296,21 @@ static int chest_sl_pscch_gen(srslte_chest_sl_t* q, uint32_t cyclic_shift) // Group Hopping uint32_t f_gh = 0; // Group Hopping Flag uint32_t f_ss = 0; - uint32_t u[SRSLTE_SL_MAX_DMRS_SYMB] = {}; // Sequence Group Number + uint32_t u[SRSRAN_SL_MAX_DMRS_SYMB] = {}; // Sequence Group Number // 36.211, Section 10.1.4.1.3 Base Sequence Number - always 0 for sidelink f_gh = 0; - if (q->cell.tm <= SRSLTE_SIDELINK_TM2) { + if (q->cell.tm <= SRSRAN_SIDELINK_TM2) { f_ss = 0; } else { f_ss = 8; } for (int ns = 0; ns < q->nof_dmrs_symbols; ns++) { - u[ns] = (f_gh + f_ss) % SRSLTE_SL_N_RU_SEQ; + u[ns] = (f_gh + f_ss) % SRSRAN_SL_N_RU_SEQ; } // w - Orthogonal Sequence, 36.211 Section 9.8 - if (q->cell.tm <= SRSLTE_SIDELINK_TM2) { + if (q->cell.tm <= SRSRAN_SIDELINK_TM2) { q->w[0] = 1; q->w[1] = 1; } else { @@ -324,61 +324,61 @@ static int chest_sl_pscch_gen(srslte_chest_sl_t* q, uint32_t cyclic_shift) cf_t* seq = q->r_sequence[j][cyclic_shift / 3]; // Generate R_uv sequences - srslte_zc_sequence_generate_lte(u[j], SRSLTE_SL_BASE_SEQUENCE_NUMBER, q->alpha[0], q->M_sc_rs / SRSLTE_NRE, seq); + srsran_zc_sequence_generate_lte(u[j], SRSRAN_SL_BASE_SEQUENCE_NUMBER, q->alpha[0], q->M_sc_rs / SRSRAN_NRE, seq); // Apply w - srslte_vec_sc_prod_ccc(seq, q->w[j], seq, q->M_sc_rs); + srsran_vec_sc_prod_ccc(seq, q->w[j], seq, q->M_sc_rs); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -static int chest_sl_pscch_put_dmrs(srslte_chest_sl_t* q, cf_t* sf_buffer) +static int chest_sl_pscch_put_dmrs(srsran_chest_sl_t* q, cf_t* sf_buffer) { uint32_t dmrs_idx = 0; - uint32_t k = q->chest_sl_cfg.prb_start_idx * SRSLTE_NRE; + uint32_t k = q->chest_sl_cfg.prb_start_idx * SRSRAN_NRE; // Mapping to physical resources - for (uint32_t i = 0; i < srslte_sl_get_num_symbols(q->cell.tm, q->cell.cp); i++) { - if (srslte_pscch_is_symbol(SRSLTE_SIDELINK_DMRS_SYMBOL, q->cell.tm, i, q->cell.cp)) { - memcpy(&sf_buffer[k + i * q->cell.nof_prb * SRSLTE_NRE], + for (uint32_t i = 0; i < srsran_sl_get_num_symbols(q->cell.tm, q->cell.cp); i++) { + if (srsran_pscch_is_symbol(SRSRAN_SIDELINK_DMRS_SYMBOL, q->cell.tm, i, q->cell.cp)) { + memcpy(&sf_buffer[k + i * q->cell.nof_prb * SRSRAN_NRE], q->r_sequence[dmrs_idx][q->chest_sl_cfg.cyclic_shift / 3], q->M_sc_rs * sizeof(cf_t)); dmrs_idx++; } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -static int chest_sl_pscch_get_dmrs(srslte_chest_sl_t* q, cf_t* sf_buffer, cf_t** dmrs_received) +static int chest_sl_pscch_get_dmrs(srsran_chest_sl_t* q, cf_t* sf_buffer, cf_t** dmrs_received) { uint32_t dmrs_idx = 0; - uint32_t k = q->chest_sl_cfg.prb_start_idx * SRSLTE_NRE; + uint32_t k = q->chest_sl_cfg.prb_start_idx * SRSRAN_NRE; // Get DMRSs - for (uint32_t i = 0; i < srslte_sl_get_num_symbols(q->cell.tm, q->cell.cp); i++) { - if (srslte_pscch_is_symbol(SRSLTE_SIDELINK_DMRS_SYMBOL, q->cell.tm, i, q->cell.cp)) { - memcpy(dmrs_received[dmrs_idx], &sf_buffer[k + i * q->cell.nof_prb * SRSLTE_NRE], q->M_sc_rs * sizeof(cf_t)); + for (uint32_t i = 0; i < srsran_sl_get_num_symbols(q->cell.tm, q->cell.cp); i++) { + if (srsran_pscch_is_symbol(SRSRAN_SIDELINK_DMRS_SYMBOL, q->cell.tm, i, q->cell.cp)) { + memcpy(dmrs_received[dmrs_idx], &sf_buffer[k + i * q->cell.nof_prb * SRSRAN_NRE], q->M_sc_rs * sizeof(cf_t)); dmrs_idx++; } } return dmrs_idx; } -static void interpolate_pilots_sl_pscch(srslte_chest_sl_t* q) +static void interpolate_pilots_sl_pscch(srsran_chest_sl_t* q) { - uint32_t NL = srslte_sl_get_num_symbols(q->cell.tm, q->cell.cp); - uint32_t n_re = q->cell.nof_prb * SRSLTE_NRE; - uint32_t ce_l[SRSLTE_SL_MAX_DMRS_SYMB] = {}; + uint32_t NL = srsran_sl_get_num_symbols(q->cell.tm, q->cell.cp); + uint32_t n_re = q->cell.nof_prb * SRSRAN_NRE; + uint32_t ce_l[SRSRAN_SL_MAX_DMRS_SYMB] = {}; uint32_t l_idx = 0; - uint32_t L[SRSLTE_SL_MAX_DMRS_SYMB] = {}; + uint32_t L[SRSRAN_SL_MAX_DMRS_SYMB] = {}; uint32_t k = 0; - srslte_interp_linear_vector_resize(&q->lin_vec_sl, n_re); + srsran_interp_linear_vector_resize(&q->lin_vec_sl, n_re); for (int i = 0; i < NL; i++) { - if (srslte_pscch_is_symbol(SRSLTE_SIDELINK_DMRS_SYMBOL, q->cell.tm, i, q->cell.cp)) { + if (srsran_pscch_is_symbol(SRSRAN_SIDELINK_DMRS_SYMBOL, q->cell.tm, i, q->cell.cp)) { L[l_idx] = i; l_idx++; } @@ -391,12 +391,12 @@ static void interpolate_pilots_sl_pscch(srslte_chest_sl_t* q) } for (uint32_t n = 0; n < l_idx; n++) { - ce_l[n] = SRSLTE_RE_IDX(q->cell.nof_prb, L[n], 0 * SRSLTE_NRE); + ce_l[n] = SRSRAN_RE_IDX(q->cell.nof_prb, L[n], 0 * SRSRAN_NRE); } - k = q->chest_sl_cfg.prb_start_idx * SRSLTE_NRE; + k = q->chest_sl_cfg.prb_start_idx * SRSRAN_NRE; - srslte_interp_linear_vector3(&q->lin_vec_sl, + srsran_interp_linear_vector3(&q->lin_vec_sl, &q->ce[ce_l[1] + k], &q->ce[ce_l[0] + k], &q->ce[ce_l[0] + k], @@ -407,7 +407,7 @@ static void interpolate_pilots_sl_pscch(srslte_chest_sl_t* q) q->M_sc_rs); for (uint32_t n = 1; n < l_idx; n++) { - srslte_interp_linear_vector3(&q->lin_vec_sl, + srsran_interp_linear_vector3(&q->lin_vec_sl, &q->ce[ce_l[n - 1] + k], &q->ce[ce_l[n] + k], NULL, @@ -418,7 +418,7 @@ static void interpolate_pilots_sl_pscch(srslte_chest_sl_t* q) q->M_sc_rs); } - srslte_interp_linear_vector3(&q->lin_vec_sl, + srsran_interp_linear_vector3(&q->lin_vec_sl, &q->ce[ce_l[l_idx - 2] + k], &q->ce[ce_l[l_idx - 1] + k], &q->ce[ce_l[l_idx - 1] + k], @@ -429,19 +429,19 @@ static void interpolate_pilots_sl_pscch(srslte_chest_sl_t* q) q->M_sc_rs); } -static void chest_sl_pscch_ls_estimate(srslte_chest_sl_t* q, cf_t* sf_buffer) +static void chest_sl_pscch_ls_estimate(srsran_chest_sl_t* q, cf_t* sf_buffer) { // Get Pilot Estimates // Use the known DMRS signal to compute least-squares estimates - srslte_vec_cf_zero(q->ce, q->sf_n_re); + srsran_vec_cf_zero(q->ce, q->sf_n_re); uint32_t dmrs_idx = 0; - for (uint32_t i = 0; i < srslte_sl_get_num_symbols(q->cell.tm, q->cell.cp); i++) { - if (srslte_pscch_is_symbol(SRSLTE_SIDELINK_DMRS_SYMBOL, q->cell.tm, i, q->cell.cp)) { - srslte_vec_prod_conj_ccc( - &sf_buffer[i * q->cell.nof_prb * SRSLTE_NRE + q->chest_sl_cfg.prb_start_idx * SRSLTE_NRE], + for (uint32_t i = 0; i < srsran_sl_get_num_symbols(q->cell.tm, q->cell.cp); i++) { + if (srsran_pscch_is_symbol(SRSRAN_SIDELINK_DMRS_SYMBOL, q->cell.tm, i, q->cell.cp)) { + srsran_vec_prod_conj_ccc( + &sf_buffer[i * q->cell.nof_prb * SRSRAN_NRE + q->chest_sl_cfg.prb_start_idx * SRSRAN_NRE], &q->r_sequence[dmrs_idx][q->chest_sl_cfg.cyclic_shift / 3][0], - &q->ce[i * q->cell.nof_prb * SRSLTE_NRE + q->chest_sl_cfg.prb_start_idx * SRSLTE_NRE], + &q->ce[i * q->cell.nof_prb * SRSRAN_NRE + q->chest_sl_cfg.prb_start_idx * SRSRAN_NRE], q->M_sc_rs); dmrs_idx++; } @@ -450,16 +450,16 @@ static void chest_sl_pscch_ls_estimate(srslte_chest_sl_t* q, cf_t* sf_buffer) interpolate_pilots_sl_pscch(q); } -static int chest_sl_pssch_gen(srslte_chest_sl_t* q) +static int chest_sl_pssch_gen(srsran_chest_sl_t* q) { // M_sc_rs - Reference Signal Length - q->M_sc_rs = q->chest_sl_cfg.nof_prb * SRSLTE_NRE; + q->M_sc_rs = q->chest_sl_cfg.nof_prb * SRSRAN_NRE; // Number of DMRS symbols - if (q->cell.tm <= SRSLTE_SIDELINK_TM2) { - q->nof_dmrs_symbols = SRSLTE_SL_TM12_DEFAULT_NUM_DMRS_SYMBOLS; + if (q->cell.tm <= SRSRAN_SIDELINK_TM2) { + q->nof_dmrs_symbols = SRSRAN_SL_TM12_DEFAULT_NUM_DMRS_SYMBOLS; } else { - q->nof_dmrs_symbols = SRSLTE_SL_TM34_DEFAULT_NUM_DMRS_SYMBOLS; + q->nof_dmrs_symbols = SRSRAN_SL_TM34_DEFAULT_NUM_DMRS_SYMBOLS; } // Cyclic Shift follows 36.211, Section 9.8 @@ -475,32 +475,32 @@ static int chest_sl_pssch_gen(srslte_chest_sl_t* q) // Group Hopping uint32_t f_gh = 0; // Group Hopping Flag uint32_t f_ss = 0; - uint32_t u[SRSLTE_SL_MAX_DMRS_SYMB] = {}; // Sequence Group Number + uint32_t u[SRSRAN_SL_MAX_DMRS_SYMB] = {}; // Sequence Group Number // 36.211, Section 10.1.4.1.3 Base Sequence Number - always 0 for sidelink - srslte_sl_group_hopping_f_gh(q->f_gh_pattern, q->chest_sl_cfg.N_x_id); + srsran_sl_group_hopping_f_gh(q->f_gh_pattern, q->chest_sl_cfg.N_x_id); - if (q->cell.tm <= SRSLTE_SIDELINK_TM2) { - f_ss = q->chest_sl_cfg.N_x_id % SRSLTE_SL_N_RU_SEQ; + if (q->cell.tm <= SRSRAN_SIDELINK_TM2) { + f_ss = q->chest_sl_cfg.N_x_id % SRSRAN_SL_N_RU_SEQ; uint32_t delta_ss = 0; for (uint32_t ns = 0; ns < q->nof_dmrs_symbols; ns++) { f_gh = q->f_gh_pattern[ns]; - u[ns] = (f_gh + f_ss + delta_ss) % SRSLTE_SL_N_RU_SEQ; + u[ns] = (f_gh + f_ss + delta_ss) % SRSRAN_SL_N_RU_SEQ; } } else { // TM3/4 - f_ss = (q->chest_sl_cfg.N_x_id / 16) % SRSLTE_SL_N_RU_SEQ; + f_ss = (q->chest_sl_cfg.N_x_id / 16) % SRSRAN_SL_N_RU_SEQ; uint32_t delta_ss = 0; for (uint32_t ns = 0; ns < q->nof_dmrs_symbols; ns++) { f_gh = q->f_gh_pattern[(2 * 2 * (q->chest_sl_cfg.sf_idx % 10)) + ns]; - u[ns] = (f_gh + f_ss + delta_ss) % SRSLTE_SL_N_RU_SEQ; + u[ns] = (f_gh + f_ss + delta_ss) % SRSRAN_SL_N_RU_SEQ; } } // w - Orthogonal Sequence, 36.211 Section 9.8 - if (q->cell.tm <= SRSLTE_SIDELINK_TM2) { + if (q->cell.tm <= SRSRAN_SIDELINK_TM2) { if (q->chest_sl_cfg.N_x_id % 2 == 0) { q->w[0] = 1; q->w[1] = 1; @@ -527,112 +527,112 @@ static int chest_sl_pssch_gen(srslte_chest_sl_t* q) cf_t* seq = q->r_sequence[j][0]; // Generate R_uv sequences - srslte_zc_sequence_generate_lte(u[j], SRSLTE_SL_BASE_SEQUENCE_NUMBER, q->alpha[0], q->M_sc_rs / SRSLTE_NRE, seq); + srsran_zc_sequence_generate_lte(u[j], SRSRAN_SL_BASE_SEQUENCE_NUMBER, q->alpha[0], q->M_sc_rs / SRSRAN_NRE, seq); // Apply w - srslte_vec_sc_prod_ccc(seq, q->w[j], seq, q->M_sc_rs); + srsran_vec_sc_prod_ccc(seq, q->w[j], seq, q->M_sc_rs); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -static int chest_sl_pssch_put_dmrs(srslte_chest_sl_t* q, cf_t* sf_buffer) +static int chest_sl_pssch_put_dmrs(srsran_chest_sl_t* q, cf_t* sf_buffer) { int dmrs_idx = 0; - uint32_t k = q->chest_sl_cfg.prb_start_idx * SRSLTE_NRE; + uint32_t k = q->chest_sl_cfg.prb_start_idx * SRSRAN_NRE; // Mapping to physical resources - for (int i = 0; i < srslte_sl_get_num_symbols(q->cell.tm, q->cell.cp); i++) { - if (srslte_pssch_is_symbol(SRSLTE_SIDELINK_DMRS_SYMBOL, q->cell.tm, i, q->cell.cp)) { - if (q->cell.tm == SRSLTE_SIDELINK_TM1 || q->cell.tm == SRSLTE_SIDELINK_TM2) { + for (int i = 0; i < srsran_sl_get_num_symbols(q->cell.tm, q->cell.cp); i++) { + if (srsran_pssch_is_symbol(SRSRAN_SIDELINK_DMRS_SYMBOL, q->cell.tm, i, q->cell.cp)) { + if (q->cell.tm == SRSRAN_SIDELINK_TM1 || q->cell.tm == SRSRAN_SIDELINK_TM2) { if (q->chest_sl_cfg.nof_prb <= q->sl_comm_resource_pool.prb_num) { - memcpy(&sf_buffer[k + i * q->cell.nof_prb * SRSLTE_NRE], + memcpy(&sf_buffer[k + i * q->cell.nof_prb * SRSRAN_NRE], q->r_sequence[dmrs_idx][0], - sizeof(cf_t) * (SRSLTE_NRE * q->chest_sl_cfg.nof_prb)); + sizeof(cf_t) * (SRSRAN_NRE * q->chest_sl_cfg.nof_prb)); } else { // First band - k = q->chest_sl_cfg.prb_start_idx * SRSLTE_NRE; - memcpy(&sf_buffer[k + i * q->cell.nof_prb * SRSLTE_NRE], + k = q->chest_sl_cfg.prb_start_idx * SRSRAN_NRE; + memcpy(&sf_buffer[k + i * q->cell.nof_prb * SRSRAN_NRE], q->r_sequence[dmrs_idx][0], - sizeof(cf_t) * (SRSLTE_NRE * q->sl_comm_resource_pool.prb_num)); + sizeof(cf_t) * (SRSRAN_NRE * q->sl_comm_resource_pool.prb_num)); // Second band if ((q->sl_comm_resource_pool.prb_num * 2) > (q->sl_comm_resource_pool.prb_end - q->sl_comm_resource_pool.prb_start + 1)) { - k = (q->sl_comm_resource_pool.prb_end + 1 - q->sl_comm_resource_pool.prb_num + 1) * SRSLTE_NRE; + k = (q->sl_comm_resource_pool.prb_end + 1 - q->sl_comm_resource_pool.prb_num + 1) * SRSRAN_NRE; } else { - k = (q->sl_comm_resource_pool.prb_end + 1 - q->sl_comm_resource_pool.prb_num) * SRSLTE_NRE; + k = (q->sl_comm_resource_pool.prb_end + 1 - q->sl_comm_resource_pool.prb_num) * SRSRAN_NRE; } - memcpy(&sf_buffer[k + i * q->cell.nof_prb * SRSLTE_NRE], - &q->r_sequence[dmrs_idx][0][SRSLTE_NRE * q->sl_comm_resource_pool.prb_num], - sizeof(cf_t) * (SRSLTE_NRE * (q->chest_sl_cfg.nof_prb - q->sl_comm_resource_pool.prb_num))); + memcpy(&sf_buffer[k + i * q->cell.nof_prb * SRSRAN_NRE], + &q->r_sequence[dmrs_idx][0][SRSRAN_NRE * q->sl_comm_resource_pool.prb_num], + sizeof(cf_t) * (SRSRAN_NRE * (q->chest_sl_cfg.nof_prb - q->sl_comm_resource_pool.prb_num))); } - } else if (q->cell.tm == SRSLTE_SIDELINK_TM3 || q->cell.tm == SRSLTE_SIDELINK_TM4) { - memcpy(&sf_buffer[k + i * q->cell.nof_prb * SRSLTE_NRE], + } else if (q->cell.tm == SRSRAN_SIDELINK_TM3 || q->cell.tm == SRSRAN_SIDELINK_TM4) { + memcpy(&sf_buffer[k + i * q->cell.nof_prb * SRSRAN_NRE], q->r_sequence[dmrs_idx][0], - sizeof(cf_t) * (SRSLTE_NRE * q->chest_sl_cfg.nof_prb)); + sizeof(cf_t) * (SRSRAN_NRE * q->chest_sl_cfg.nof_prb)); } dmrs_idx++; } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -static int chest_sl_pssch_get_dmrs(srslte_chest_sl_t* q, cf_t* sf_buffer, cf_t** dmrs_received) +static int chest_sl_pssch_get_dmrs(srsran_chest_sl_t* q, cf_t* sf_buffer, cf_t** dmrs_received) { int dmrs_idx = 0; - uint32_t k = q->chest_sl_cfg.prb_start_idx * SRSLTE_NRE; + uint32_t k = q->chest_sl_cfg.prb_start_idx * SRSRAN_NRE; // Mapping to physical resources - for (int i = 0; i < srslte_sl_get_num_symbols(q->cell.tm, q->cell.cp); i++) { - if (srslte_pssch_is_symbol(SRSLTE_SIDELINK_DMRS_SYMBOL, q->cell.tm, i, q->cell.cp)) { - if (q->cell.tm == SRSLTE_SIDELINK_TM1 || q->cell.tm == SRSLTE_SIDELINK_TM2) { + for (int i = 0; i < srsran_sl_get_num_symbols(q->cell.tm, q->cell.cp); i++) { + if (srsran_pssch_is_symbol(SRSRAN_SIDELINK_DMRS_SYMBOL, q->cell.tm, i, q->cell.cp)) { + if (q->cell.tm == SRSRAN_SIDELINK_TM1 || q->cell.tm == SRSRAN_SIDELINK_TM2) { if (q->chest_sl_cfg.nof_prb <= q->sl_comm_resource_pool.prb_num) { memcpy(dmrs_received[dmrs_idx], - &sf_buffer[k + i * q->cell.nof_prb * SRSLTE_NRE], - sizeof(cf_t) * (SRSLTE_NRE * q->chest_sl_cfg.nof_prb)); + &sf_buffer[k + i * q->cell.nof_prb * SRSRAN_NRE], + sizeof(cf_t) * (SRSRAN_NRE * q->chest_sl_cfg.nof_prb)); } else { // First band - k = q->chest_sl_cfg.prb_start_idx * SRSLTE_NRE; + k = q->chest_sl_cfg.prb_start_idx * SRSRAN_NRE; memcpy(dmrs_received[dmrs_idx], - &sf_buffer[k + i * q->cell.nof_prb * SRSLTE_NRE], - sizeof(cf_t) * (SRSLTE_NRE * q->sl_comm_resource_pool.prb_num)); + &sf_buffer[k + i * q->cell.nof_prb * SRSRAN_NRE], + sizeof(cf_t) * (SRSRAN_NRE * q->sl_comm_resource_pool.prb_num)); // Second band if ((q->sl_comm_resource_pool.prb_num * 2) > (q->sl_comm_resource_pool.prb_end - q->sl_comm_resource_pool.prb_start + 1)) { - k = (q->sl_comm_resource_pool.prb_end + 1 - q->sl_comm_resource_pool.prb_num + 1) * SRSLTE_NRE; + k = (q->sl_comm_resource_pool.prb_end + 1 - q->sl_comm_resource_pool.prb_num + 1) * SRSRAN_NRE; } else { - k = (q->sl_comm_resource_pool.prb_end + 1 - q->sl_comm_resource_pool.prb_num) * SRSLTE_NRE; + k = (q->sl_comm_resource_pool.prb_end + 1 - q->sl_comm_resource_pool.prb_num) * SRSRAN_NRE; } - memcpy(&dmrs_received[dmrs_idx][SRSLTE_NRE * q->sl_comm_resource_pool.prb_num], - &sf_buffer[k + i * q->cell.nof_prb * SRSLTE_NRE], - sizeof(cf_t) * (SRSLTE_NRE * (q->chest_sl_cfg.nof_prb - q->sl_comm_resource_pool.prb_num))); + memcpy(&dmrs_received[dmrs_idx][SRSRAN_NRE * q->sl_comm_resource_pool.prb_num], + &sf_buffer[k + i * q->cell.nof_prb * SRSRAN_NRE], + sizeof(cf_t) * (SRSRAN_NRE * (q->chest_sl_cfg.nof_prb - q->sl_comm_resource_pool.prb_num))); } - } else if (q->cell.tm == SRSLTE_SIDELINK_TM3 || q->cell.tm == SRSLTE_SIDELINK_TM4) { + } else if (q->cell.tm == SRSRAN_SIDELINK_TM3 || q->cell.tm == SRSRAN_SIDELINK_TM4) { memcpy(dmrs_received[dmrs_idx], - &sf_buffer[k + i * q->cell.nof_prb * SRSLTE_NRE], - sizeof(cf_t) * (SRSLTE_NRE * q->chest_sl_cfg.nof_prb)); + &sf_buffer[k + i * q->cell.nof_prb * SRSRAN_NRE], + sizeof(cf_t) * (SRSRAN_NRE * q->chest_sl_cfg.nof_prb)); } dmrs_idx++; } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -static void interpolate_pilots_sl_pssch(srslte_chest_sl_t* q) +static void interpolate_pilots_sl_pssch(srsran_chest_sl_t* q) { - uint32_t NL = srslte_sl_get_num_symbols(q->cell.tm, q->cell.cp); - uint32_t n_re = q->cell.nof_prb * SRSLTE_NRE; - uint32_t ce_l[SRSLTE_SL_MAX_DMRS_SYMB] = {}; + uint32_t NL = srsran_sl_get_num_symbols(q->cell.tm, q->cell.cp); + uint32_t n_re = q->cell.nof_prb * SRSRAN_NRE; + uint32_t ce_l[SRSRAN_SL_MAX_DMRS_SYMB] = {}; uint32_t l_idx = 0; - uint32_t L[SRSLTE_SL_MAX_DMRS_SYMB] = {}; + uint32_t L[SRSRAN_SL_MAX_DMRS_SYMB] = {}; uint32_t k = 0; - srslte_interp_linear_vector_resize(&q->lin_vec_sl, n_re); + srsran_interp_linear_vector_resize(&q->lin_vec_sl, n_re); for (int i = 0; i < NL; i++) { - if (srslte_pssch_is_symbol(SRSLTE_SIDELINK_DMRS_SYMBOL, q->cell.tm, i, q->cell.cp)) { + if (srsran_pssch_is_symbol(SRSRAN_SIDELINK_DMRS_SYMBOL, q->cell.tm, i, q->cell.cp)) { L[l_idx] = i; l_idx++; } @@ -645,14 +645,14 @@ static void interpolate_pilots_sl_pssch(srslte_chest_sl_t* q) } for (uint32_t n = 0; n < l_idx; n++) { - ce_l[n] = SRSLTE_RE_IDX(q->cell.nof_prb, L[n], 0 * SRSLTE_NRE); + ce_l[n] = SRSRAN_RE_IDX(q->cell.nof_prb, L[n], 0 * SRSRAN_NRE); } - if (q->cell.tm == SRSLTE_SIDELINK_TM1 || q->cell.tm == SRSLTE_SIDELINK_TM2) { + if (q->cell.tm == SRSRAN_SIDELINK_TM1 || q->cell.tm == SRSRAN_SIDELINK_TM2) { if (q->chest_sl_cfg.nof_prb <= q->sl_comm_resource_pool.prb_num) { - k = q->chest_sl_cfg.prb_start_idx * SRSLTE_NRE; + k = q->chest_sl_cfg.prb_start_idx * SRSRAN_NRE; - srslte_interp_linear_vector3(&q->lin_vec_sl, + srsran_interp_linear_vector3(&q->lin_vec_sl, &q->ce[ce_l[1] + k], &q->ce[ce_l[0] + k], &q->ce[ce_l[0] + k], @@ -660,10 +660,10 @@ static void interpolate_pilots_sl_pssch(srslte_chest_sl_t* q) (L[1] - L[0]), L[0], false, - q->chest_sl_cfg.nof_prb * SRSLTE_NRE); + q->chest_sl_cfg.nof_prb * SRSRAN_NRE); for (uint32_t n = 1; n < l_idx; n++) { - srslte_interp_linear_vector3(&q->lin_vec_sl, + srsran_interp_linear_vector3(&q->lin_vec_sl, &q->ce[ce_l[n - 1] + k], &q->ce[ce_l[n] + k], NULL, @@ -671,10 +671,10 @@ static void interpolate_pilots_sl_pssch(srslte_chest_sl_t* q) (L[n] - L[n - 1]), (L[n] - L[n - 1]) - 1, true, - q->chest_sl_cfg.nof_prb * SRSLTE_NRE); + q->chest_sl_cfg.nof_prb * SRSRAN_NRE); } - srslte_interp_linear_vector3(&q->lin_vec_sl, + srsran_interp_linear_vector3(&q->lin_vec_sl, &q->ce[ce_l[l_idx - 2] + k], &q->ce[ce_l[l_idx - 1] + k], &q->ce[ce_l[l_idx - 1] + k], @@ -682,13 +682,13 @@ static void interpolate_pilots_sl_pssch(srslte_chest_sl_t* q) (L[l_idx - 1] - L[l_idx - 2]), (NL - L[l_idx - 1]) - 1, true, - q->chest_sl_cfg.nof_prb * SRSLTE_NRE); + q->chest_sl_cfg.nof_prb * SRSRAN_NRE); } else { // First band - k = q->chest_sl_cfg.prb_start_idx * SRSLTE_NRE; + k = q->chest_sl_cfg.prb_start_idx * SRSRAN_NRE; - srslte_interp_linear_vector3(&q->lin_vec_sl, + srsran_interp_linear_vector3(&q->lin_vec_sl, &q->ce[ce_l[1] + k], &q->ce[ce_l[0] + k], &q->ce[ce_l[0] + k], @@ -696,10 +696,10 @@ static void interpolate_pilots_sl_pssch(srslte_chest_sl_t* q) (L[1] - L[0]), L[0], false, - q->sl_comm_resource_pool.prb_num * SRSLTE_NRE); + q->sl_comm_resource_pool.prb_num * SRSRAN_NRE); for (uint32_t n = 1; n < l_idx; n++) { - srslte_interp_linear_vector3(&q->lin_vec_sl, + srsran_interp_linear_vector3(&q->lin_vec_sl, &q->ce[ce_l[n - 1] + k], &q->ce[ce_l[n] + k], NULL, @@ -707,10 +707,10 @@ static void interpolate_pilots_sl_pssch(srslte_chest_sl_t* q) (L[n] - L[n - 1]), (L[n] - L[n - 1]) - 1, true, - q->sl_comm_resource_pool.prb_num * SRSLTE_NRE); + q->sl_comm_resource_pool.prb_num * SRSRAN_NRE); } - srslte_interp_linear_vector3(&q->lin_vec_sl, + srsran_interp_linear_vector3(&q->lin_vec_sl, &q->ce[ce_l[l_idx - 2] + k], &q->ce[ce_l[l_idx - 1] + k], &q->ce[ce_l[l_idx - 1] + k], @@ -718,17 +718,17 @@ static void interpolate_pilots_sl_pssch(srslte_chest_sl_t* q) (L[l_idx - 1] - L[l_idx - 2]), (NL - L[l_idx - 1]) - 1, true, - q->sl_comm_resource_pool.prb_num * SRSLTE_NRE); + q->sl_comm_resource_pool.prb_num * SRSRAN_NRE); // Second band if ((q->sl_comm_resource_pool.prb_num * 2) > (q->sl_comm_resource_pool.prb_end - q->sl_comm_resource_pool.prb_start + 1)) { - k = (q->sl_comm_resource_pool.prb_end + 1 - q->sl_comm_resource_pool.prb_num + 1) * SRSLTE_NRE; + k = (q->sl_comm_resource_pool.prb_end + 1 - q->sl_comm_resource_pool.prb_num + 1) * SRSRAN_NRE; } else { - k = (q->sl_comm_resource_pool.prb_end + 1 - q->sl_comm_resource_pool.prb_num) * SRSLTE_NRE; + k = (q->sl_comm_resource_pool.prb_end + 1 - q->sl_comm_resource_pool.prb_num) * SRSRAN_NRE; } - srslte_interp_linear_vector3(&q->lin_vec_sl, + srsran_interp_linear_vector3(&q->lin_vec_sl, &q->ce[ce_l[1] + k], &q->ce[ce_l[0] + k], &q->ce[ce_l[0] + k], @@ -736,10 +736,10 @@ static void interpolate_pilots_sl_pssch(srslte_chest_sl_t* q) (L[1] - L[0]), L[0], false, - (q->chest_sl_cfg.nof_prb - q->sl_comm_resource_pool.prb_num) * SRSLTE_NRE); + (q->chest_sl_cfg.nof_prb - q->sl_comm_resource_pool.prb_num) * SRSRAN_NRE); for (uint32_t n = 1; n < l_idx; n++) { - srslte_interp_linear_vector3(&q->lin_vec_sl, + srsran_interp_linear_vector3(&q->lin_vec_sl, &q->ce[ce_l[n - 1] + k], &q->ce[ce_l[n] + k], NULL, @@ -747,10 +747,10 @@ static void interpolate_pilots_sl_pssch(srslte_chest_sl_t* q) (L[n] - L[n - 1]), (L[n] - L[n - 1]) - 1, true, - (q->chest_sl_cfg.nof_prb - q->sl_comm_resource_pool.prb_num) * SRSLTE_NRE); + (q->chest_sl_cfg.nof_prb - q->sl_comm_resource_pool.prb_num) * SRSRAN_NRE); } - srslte_interp_linear_vector3(&q->lin_vec_sl, + srsran_interp_linear_vector3(&q->lin_vec_sl, &q->ce[ce_l[l_idx - 2] + k], &q->ce[ce_l[l_idx - 1] + k], &q->ce[ce_l[l_idx - 1] + k], @@ -758,13 +758,13 @@ static void interpolate_pilots_sl_pssch(srslte_chest_sl_t* q) (L[l_idx - 1] - L[l_idx - 2]), (NL - L[l_idx - 1]) - 1, true, - (q->chest_sl_cfg.nof_prb - q->sl_comm_resource_pool.prb_num) * SRSLTE_NRE); + (q->chest_sl_cfg.nof_prb - q->sl_comm_resource_pool.prb_num) * SRSRAN_NRE); } - } else if (q->cell.tm == SRSLTE_SIDELINK_TM3 || q->cell.tm == SRSLTE_SIDELINK_TM4) { - k = q->chest_sl_cfg.prb_start_idx * SRSLTE_NRE; + } else if (q->cell.tm == SRSRAN_SIDELINK_TM3 || q->cell.tm == SRSRAN_SIDELINK_TM4) { + k = q->chest_sl_cfg.prb_start_idx * SRSRAN_NRE; - srslte_interp_linear_vector3(&q->lin_vec_sl, + srsran_interp_linear_vector3(&q->lin_vec_sl, &q->ce[ce_l[1] + k], &q->ce[ce_l[0] + k], &q->ce[ce_l[0] + k], @@ -772,10 +772,10 @@ static void interpolate_pilots_sl_pssch(srslte_chest_sl_t* q) (L[1] - L[0]), L[0], false, - q->chest_sl_cfg.nof_prb * SRSLTE_NRE); + q->chest_sl_cfg.nof_prb * SRSRAN_NRE); for (uint32_t n = 1; n < l_idx; n++) { - srslte_interp_linear_vector3(&q->lin_vec_sl, + srsran_interp_linear_vector3(&q->lin_vec_sl, &q->ce[ce_l[n - 1] + k], &q->ce[ce_l[n] + k], NULL, @@ -783,10 +783,10 @@ static void interpolate_pilots_sl_pssch(srslte_chest_sl_t* q) (L[n] - L[n - 1]), (L[n] - L[n - 1]) - 1, true, - q->chest_sl_cfg.nof_prb * SRSLTE_NRE); + q->chest_sl_cfg.nof_prb * SRSRAN_NRE); } - srslte_interp_linear_vector3(&q->lin_vec_sl, + srsran_interp_linear_vector3(&q->lin_vec_sl, &q->ce[ce_l[l_idx - 2] + k], &q->ce[ce_l[l_idx - 1] + k], &q->ce[ce_l[l_idx - 1] + k], @@ -794,49 +794,49 @@ static void interpolate_pilots_sl_pssch(srslte_chest_sl_t* q) (L[l_idx - 1] - L[l_idx - 2]), (NL - L[l_idx - 1]) - 1, true, - q->chest_sl_cfg.nof_prb * SRSLTE_NRE); + q->chest_sl_cfg.nof_prb * SRSRAN_NRE); } } -static void chest_sl_pssch_ls_estimate(srslte_chest_sl_t* q, cf_t* sf_buffer) +static void chest_sl_pssch_ls_estimate(srsran_chest_sl_t* q, cf_t* sf_buffer) { int dmrs_idx = 0; - uint32_t k = q->chest_sl_cfg.prb_start_idx * SRSLTE_NRE; + uint32_t k = q->chest_sl_cfg.prb_start_idx * SRSRAN_NRE; - srslte_vec_cf_zero(q->ce, q->sf_n_re); - for (int i = 0; i < srslte_sl_get_num_symbols(q->cell.tm, q->cell.cp); i++) { - if (srslte_pssch_is_symbol(SRSLTE_SIDELINK_DMRS_SYMBOL, q->cell.tm, i, q->cell.cp)) { - if (q->cell.tm == SRSLTE_SIDELINK_TM1 || q->cell.tm == SRSLTE_SIDELINK_TM2) { + srsran_vec_cf_zero(q->ce, q->sf_n_re); + for (int i = 0; i < srsran_sl_get_num_symbols(q->cell.tm, q->cell.cp); i++) { + if (srsran_pssch_is_symbol(SRSRAN_SIDELINK_DMRS_SYMBOL, q->cell.tm, i, q->cell.cp)) { + if (q->cell.tm == SRSRAN_SIDELINK_TM1 || q->cell.tm == SRSRAN_SIDELINK_TM2) { if (q->chest_sl_cfg.nof_prb <= q->sl_comm_resource_pool.prb_num) { - srslte_vec_prod_conj_ccc(&sf_buffer[k + i * q->cell.nof_prb * SRSLTE_NRE], + srsran_vec_prod_conj_ccc(&sf_buffer[k + i * q->cell.nof_prb * SRSRAN_NRE], &q->r_sequence[dmrs_idx][0][0], - &q->ce[k + i * q->cell.nof_prb * SRSLTE_NRE], - (SRSLTE_NRE * q->chest_sl_cfg.nof_prb)); + &q->ce[k + i * q->cell.nof_prb * SRSRAN_NRE], + (SRSRAN_NRE * q->chest_sl_cfg.nof_prb)); } else { // First band - k = q->chest_sl_cfg.prb_start_idx * SRSLTE_NRE; - srslte_vec_prod_conj_ccc(&sf_buffer[k + i * q->cell.nof_prb * SRSLTE_NRE], + k = q->chest_sl_cfg.prb_start_idx * SRSRAN_NRE; + srsran_vec_prod_conj_ccc(&sf_buffer[k + i * q->cell.nof_prb * SRSRAN_NRE], &q->r_sequence[dmrs_idx][0][0], - &q->ce[k + i * q->cell.nof_prb * SRSLTE_NRE], - (SRSLTE_NRE * q->sl_comm_resource_pool.prb_num)); + &q->ce[k + i * q->cell.nof_prb * SRSRAN_NRE], + (SRSRAN_NRE * q->sl_comm_resource_pool.prb_num)); // Second band if ((q->sl_comm_resource_pool.prb_num * 2) > (q->sl_comm_resource_pool.prb_end - q->sl_comm_resource_pool.prb_start + 1)) { - k = (q->sl_comm_resource_pool.prb_end + 1 - q->sl_comm_resource_pool.prb_num + 1) * SRSLTE_NRE; + k = (q->sl_comm_resource_pool.prb_end + 1 - q->sl_comm_resource_pool.prb_num + 1) * SRSRAN_NRE; } else { - k = (q->sl_comm_resource_pool.prb_end + 1 - q->sl_comm_resource_pool.prb_num) * SRSLTE_NRE; + k = (q->sl_comm_resource_pool.prb_end + 1 - q->sl_comm_resource_pool.prb_num) * SRSRAN_NRE; } - srslte_vec_prod_conj_ccc(&sf_buffer[k + i * q->cell.nof_prb * SRSLTE_NRE], - &q->r_sequence[dmrs_idx][0][SRSLTE_NRE * q->sl_comm_resource_pool.prb_num], - &q->ce[k + i * q->cell.nof_prb * SRSLTE_NRE], - (SRSLTE_NRE * (q->chest_sl_cfg.nof_prb - q->sl_comm_resource_pool.prb_num))); + srsran_vec_prod_conj_ccc(&sf_buffer[k + i * q->cell.nof_prb * SRSRAN_NRE], + &q->r_sequence[dmrs_idx][0][SRSRAN_NRE * q->sl_comm_resource_pool.prb_num], + &q->ce[k + i * q->cell.nof_prb * SRSRAN_NRE], + (SRSRAN_NRE * (q->chest_sl_cfg.nof_prb - q->sl_comm_resource_pool.prb_num))); } - } else if (q->cell.tm == SRSLTE_SIDELINK_TM3 || q->cell.tm == SRSLTE_SIDELINK_TM4) { - srslte_vec_prod_conj_ccc(&sf_buffer[k + i * q->cell.nof_prb * SRSLTE_NRE], + } else if (q->cell.tm == SRSRAN_SIDELINK_TM3 || q->cell.tm == SRSRAN_SIDELINK_TM4) { + srsran_vec_prod_conj_ccc(&sf_buffer[k + i * q->cell.nof_prb * SRSRAN_NRE], &q->r_sequence[dmrs_idx][0][0], - &q->ce[k + i * q->cell.nof_prb * SRSLTE_NRE], - (SRSLTE_NRE * q->chest_sl_cfg.nof_prb)); + &q->ce[k + i * q->cell.nof_prb * SRSRAN_NRE], + (SRSRAN_NRE * q->chest_sl_cfg.nof_prb)); } dmrs_idx++; } @@ -844,170 +844,170 @@ static void chest_sl_pssch_ls_estimate(srslte_chest_sl_t* q, cf_t* sf_buffer) interpolate_pilots_sl_pssch(q); } -static void get_subband_noise(srslte_chest_sl_t* q, uint32_t k_start, uint32_t k_end, uint32_t sf_nsymbols) +static void get_subband_noise(srsran_chest_sl_t* q, uint32_t k_start, uint32_t k_end, uint32_t sf_nsymbols) { for (int k = k_start; k < k_end; k++) { cf_t aux = 0.0; for (int l = 0; l < sf_nsymbols / 2; l++) { - aux = aux + q->ce[k + l * q->cell.nof_prb * SRSLTE_NRE]; + aux = aux + q->ce[k + l * q->cell.nof_prb * SRSRAN_NRE]; } for (int l = 0; l < sf_nsymbols / 2; l++) { - q->ce_average[k + l * q->cell.nof_prb * SRSLTE_NRE] = aux / (float)sf_nsymbols * 2; + q->ce_average[k + l * q->cell.nof_prb * SRSRAN_NRE] = aux / (float)sf_nsymbols * 2; } aux = 0.0; for (int l = sf_nsymbols / 2; l < sf_nsymbols; l++) { - aux = aux + q->ce[k + l * q->cell.nof_prb * SRSLTE_NRE]; + aux = aux + q->ce[k + l * q->cell.nof_prb * SRSRAN_NRE]; } for (int l = sf_nsymbols / 2; l < sf_nsymbols; l++) { - q->ce_average[k + l * q->cell.nof_prb * SRSLTE_NRE] = aux / (float)sf_nsymbols * 2; + q->ce_average[k + l * q->cell.nof_prb * SRSRAN_NRE] = aux / (float)sf_nsymbols * 2; } } for (int l = 0; l < sf_nsymbols; l++) { - srslte_vec_sub_ccc(&q->ce_average[k_start + l * q->cell.nof_prb * SRSLTE_NRE], - &q->ce[k_start + l * q->cell.nof_prb * SRSLTE_NRE], - &q->noise_tmp[k_start + l * q->cell.nof_prb * SRSLTE_NRE], + srsran_vec_sub_ccc(&q->ce_average[k_start + l * q->cell.nof_prb * SRSRAN_NRE], + &q->ce[k_start + l * q->cell.nof_prb * SRSRAN_NRE], + &q->noise_tmp[k_start + l * q->cell.nof_prb * SRSRAN_NRE], k_end - k_start); q->noise_estimated += - srslte_vec_avg_power_cf(&q->noise_tmp[k_start + l * q->cell.nof_prb * SRSLTE_NRE], k_end - k_start); + srsran_vec_avg_power_cf(&q->noise_tmp[k_start + l * q->cell.nof_prb * SRSRAN_NRE], k_end - k_start); } } -float srslte_chest_sl_estimate_noise(srslte_chest_sl_t* q) +float srsran_chest_sl_estimate_noise(srsran_chest_sl_t* q) { - uint32_t sf_nsymbols = srslte_sl_get_num_symbols(q->cell.tm, q->cell.cp); + uint32_t sf_nsymbols = srsran_sl_get_num_symbols(q->cell.tm, q->cell.cp); if (sf_nsymbols == 0) { ERROR("Error estimating channel noise. Invalid number of OFDM symbols."); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - srslte_vec_cf_zero(q->ce_average, q->sf_n_re); + srsran_vec_cf_zero(q->ce_average, q->sf_n_re); q->noise_estimated = 0.0; uint32_t k_start = 0; uint32_t k_end = 0; switch (q->channel) { - case SRSLTE_SIDELINK_PSBCH: - k_start = q->cell.nof_prb * SRSLTE_NRE / 2 - 36; + case SRSRAN_SIDELINK_PSBCH: + k_start = q->cell.nof_prb * SRSRAN_NRE / 2 - 36; k_end = k_start + q->M_sc_rs; get_subband_noise(q, k_start, k_end, sf_nsymbols); break; - case SRSLTE_SIDELINK_PSCCH: - k_start = q->chest_sl_cfg.prb_start_idx * SRSLTE_NRE; + case SRSRAN_SIDELINK_PSCCH: + k_start = q->chest_sl_cfg.prb_start_idx * SRSRAN_NRE; k_end = k_start + q->M_sc_rs; get_subband_noise(q, k_start, k_end, sf_nsymbols); break; - case SRSLTE_SIDELINK_PSSCH: - if (q->cell.tm == SRSLTE_SIDELINK_TM1 || q->cell.tm == SRSLTE_SIDELINK_TM2) { + case SRSRAN_SIDELINK_PSSCH: + if (q->cell.tm == SRSRAN_SIDELINK_TM1 || q->cell.tm == SRSRAN_SIDELINK_TM2) { if (q->chest_sl_cfg.nof_prb <= q->sl_comm_resource_pool.prb_num) { - k_start = q->chest_sl_cfg.prb_start_idx * SRSLTE_NRE; - k_end = (q->chest_sl_cfg.nof_prb + q->chest_sl_cfg.prb_start_idx) * SRSLTE_NRE; + k_start = q->chest_sl_cfg.prb_start_idx * SRSRAN_NRE; + k_end = (q->chest_sl_cfg.nof_prb + q->chest_sl_cfg.prb_start_idx) * SRSRAN_NRE; get_subband_noise(q, k_start, k_end, sf_nsymbols); } else { // First band - k_start = q->chest_sl_cfg.prb_start_idx * SRSLTE_NRE; - k_end = k_start + q->sl_comm_resource_pool.prb_num * SRSLTE_NRE; + k_start = q->chest_sl_cfg.prb_start_idx * SRSRAN_NRE; + k_end = k_start + q->sl_comm_resource_pool.prb_num * SRSRAN_NRE; get_subband_noise(q, k_start, k_end, sf_nsymbols); // Second band if ((q->sl_comm_resource_pool.prb_num * 2) > (q->sl_comm_resource_pool.prb_end - q->sl_comm_resource_pool.prb_start + 1)) { - k_start = (q->sl_comm_resource_pool.prb_end + 1 - q->sl_comm_resource_pool.prb_num + 1) * SRSLTE_NRE; + k_start = (q->sl_comm_resource_pool.prb_end + 1 - q->sl_comm_resource_pool.prb_num + 1) * SRSRAN_NRE; } else { - k_start = (q->sl_comm_resource_pool.prb_end + 1 - q->sl_comm_resource_pool.prb_num) * SRSLTE_NRE; + k_start = (q->sl_comm_resource_pool.prb_end + 1 - q->sl_comm_resource_pool.prb_num) * SRSRAN_NRE; } - k_end = k_start + (q->chest_sl_cfg.nof_prb - q->sl_comm_resource_pool.prb_num) * SRSLTE_NRE; + k_end = k_start + (q->chest_sl_cfg.nof_prb - q->sl_comm_resource_pool.prb_num) * SRSRAN_NRE; get_subband_noise(q, k_start, k_end, sf_nsymbols); } - } else if (q->cell.tm == SRSLTE_SIDELINK_TM3 || q->cell.tm == SRSLTE_SIDELINK_TM4) { - k_start = q->chest_sl_cfg.prb_start_idx * SRSLTE_NRE; - k_end = (q->chest_sl_cfg.nof_prb + q->chest_sl_cfg.prb_start_idx) * SRSLTE_NRE; + } else if (q->cell.tm == SRSRAN_SIDELINK_TM3 || q->cell.tm == SRSRAN_SIDELINK_TM4) { + k_start = q->chest_sl_cfg.prb_start_idx * SRSRAN_NRE; + k_end = (q->chest_sl_cfg.nof_prb + q->chest_sl_cfg.prb_start_idx) * SRSRAN_NRE; get_subband_noise(q, k_start, k_end, sf_nsymbols); } break; default: ERROR("Invalid Sidelink channel"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } q->noise_estimated = q->noise_estimated / (float)sf_nsymbols; return q->noise_estimated; } -int srslte_chest_sl_init(srslte_chest_sl_t* q, - srslte_sl_channels_t channel, - srslte_cell_sl_t cell, - srslte_sl_comm_resource_pool_t sl_comm_resource_pool) +int srsran_chest_sl_init(srsran_chest_sl_t* q, + srsran_sl_channels_t channel, + srsran_cell_sl_t cell, + srsran_sl_comm_resource_pool_t sl_comm_resource_pool) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL) { - bzero(q, sizeof(srslte_chest_sl_t)); + bzero(q, sizeof(srsran_chest_sl_t)); q->channel = channel; q->cell = cell; q->sl_comm_resource_pool = sl_comm_resource_pool; switch (channel) { - case SRSLTE_SIDELINK_PSBCH: - if (chest_sl_init(q, SRSLTE_SL_DEFAULT_NOF_DMRS_CYCLIC_SHIFTS) != SRSLTE_SUCCESS) { + case SRSRAN_SIDELINK_PSBCH: + if (chest_sl_init(q, SRSRAN_SL_DEFAULT_NOF_DMRS_CYCLIC_SHIFTS) != SRSRAN_SUCCESS) { ERROR("Error initializing sl dmrs"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (chest_sl_psbch_gen(q) != SRSLTE_SUCCESS) { + if (chest_sl_psbch_gen(q) != SRSRAN_SUCCESS) { ERROR("Error in chest PSBCH gen"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } break; - case SRSLTE_SIDELINK_PSCCH: - if (q->cell.tm <= SRSLTE_SIDELINK_TM2) { - if (chest_sl_init(q, SRSLTE_SL_DEFAULT_NOF_DMRS_CYCLIC_SHIFTS) != SRSLTE_SUCCESS) { + case SRSRAN_SIDELINK_PSCCH: + if (q->cell.tm <= SRSRAN_SIDELINK_TM2) { + if (chest_sl_init(q, SRSRAN_SL_DEFAULT_NOF_DMRS_CYCLIC_SHIFTS) != SRSRAN_SUCCESS) { ERROR("Error initializing sl dmrs"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Generate DMRS sequence for PSCCH cyclic shift: {0} - if (chest_sl_pscch_gen(q, 0) != SRSLTE_SUCCESS) { + if (chest_sl_pscch_gen(q, 0) != SRSRAN_SUCCESS) { ERROR("Error in chest PSCCH gen"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } else { - if (chest_sl_init(q, SRSLTE_SL_MAX_PSCCH_NOF_DMRS_CYCLIC_SHIFTS) != SRSLTE_SUCCESS) { + if (chest_sl_init(q, SRSRAN_SL_MAX_PSCCH_NOF_DMRS_CYCLIC_SHIFTS) != SRSRAN_SUCCESS) { ERROR("Error initializing sl dmrs"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Generate DMRS sequences for all PSCCH cyclic shifts: {0,3,6,9} for (int i = 0; i <= 9; i += 3) { - if (chest_sl_pscch_gen(q, i) != SRSLTE_SUCCESS) { + if (chest_sl_pscch_gen(q, i) != SRSRAN_SUCCESS) { ERROR("Error in chest PSCCH gen"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } } break; - case SRSLTE_SIDELINK_PSSCH: - if (chest_sl_init(q, SRSLTE_SL_DEFAULT_NOF_DMRS_CYCLIC_SHIFTS) != SRSLTE_SUCCESS) { + case SRSRAN_SIDELINK_PSSCH: + if (chest_sl_init(q, SRSRAN_SL_DEFAULT_NOF_DMRS_CYCLIC_SHIFTS) != SRSRAN_SUCCESS) { ERROR("Error initializing sl dmrs"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } break; default: ERROR("Invalid Sidelink channel"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } -float srslte_chest_sl_get_sync_error(srslte_chest_sl_t* q) +float srsran_chest_sl_get_sync_error(srsran_chest_sl_t* q) { // Estimate synchronization error if (q->sync_error_enable) { - float k = (float)srslte_symbol_sz(q->cell.nof_prb); + float k = (float)srsran_symbol_sz(q->cell.nof_prb); float sum = 0.0f; - srslte_chest_sl_get_dmrs(q, q->ce, q->r_sequence_rx); + srsran_chest_sl_get_dmrs(q, q->ce, q->r_sequence_rx); for (int i = 0; i < q->nof_dmrs_symbols; i++) { - sum += srslte_vec_estimate_frequency(q->r_sequence_rx[i], q->M_sc_rs) * k; + sum += srsran_vec_estimate_frequency(q->r_sequence_rx[i], q->M_sc_rs) * k; } q->sync_err = sum / q->nof_dmrs_symbols; } else { @@ -1016,13 +1016,13 @@ float srslte_chest_sl_get_sync_error(srslte_chest_sl_t* q) return q->sync_err; } -float srslte_chest_sl_get_rsrp(srslte_chest_sl_t* q) +float srsran_chest_sl_get_rsrp(srsran_chest_sl_t* q) { // Compute RSRP for the channel estimates in this port if (q->rsrp_enable) { - srslte_chest_sl_get_dmrs(q, q->ce, q->r_sequence_rx); + srsran_chest_sl_get_dmrs(q, q->ce, q->r_sequence_rx); for (int i = 0; i < q->nof_dmrs_symbols; i++) { - cf_t corr = srslte_vec_acc_cc(q->r_sequence_rx[i], q->M_sc_rs) / q->M_sc_rs; + cf_t corr = srsran_vec_acc_cc(q->r_sequence_rx[i], q->M_sc_rs) / q->M_sc_rs; float energy = __real__(corr * conjf(corr)); q->rsrp_corr = energy; } @@ -1033,110 +1033,110 @@ float srslte_chest_sl_get_rsrp(srslte_chest_sl_t* q) return q->rsrp_corr; } -int srslte_chest_sl_set_cell(srslte_chest_sl_t* q, srslte_cell_sl_t cell) +int srsran_chest_sl_set_cell(srsran_chest_sl_t* q, srsran_cell_sl_t cell) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL) { q->cell = cell; - if (q->channel == SRSLTE_SIDELINK_PSBCH) { - if (chest_sl_psbch_gen(q) != SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (q->channel == SRSRAN_SIDELINK_PSBCH) { + if (chest_sl_psbch_gen(q) != SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } -int srslte_chest_sl_set_cfg(srslte_chest_sl_t* q, srslte_chest_sl_cfg_t chest_sl_cfg) +int srsran_chest_sl_set_cfg(srsran_chest_sl_t* q, srsran_chest_sl_cfg_t chest_sl_cfg) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL) { q->chest_sl_cfg = chest_sl_cfg; - if (q->channel == SRSLTE_SIDELINK_PSSCH) { - if (chest_sl_pssch_gen(q) != SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (q->channel == SRSRAN_SIDELINK_PSSCH) { + if (chest_sl_pssch_gen(q) != SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } -int srslte_chest_sl_put_dmrs(srslte_chest_sl_t* q, cf_t* sf_buffer) +int srsran_chest_sl_put_dmrs(srsran_chest_sl_t* q, cf_t* sf_buffer) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL) { switch (q->channel) { - case SRSLTE_SIDELINK_PSBCH: + case SRSRAN_SIDELINK_PSBCH: return chest_sl_psbch_put_dmrs(q, sf_buffer); - case SRSLTE_SIDELINK_PSCCH: + case SRSRAN_SIDELINK_PSCCH: return chest_sl_pscch_put_dmrs(q, sf_buffer); - case SRSLTE_SIDELINK_PSSCH: + case SRSRAN_SIDELINK_PSSCH: return chest_sl_pssch_put_dmrs(q, sf_buffer); default: - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; break; } } return ret; } -int srslte_chest_sl_get_dmrs(srslte_chest_sl_t* q, cf_t* sf_buffer, cf_t** dmrs_received) +int srsran_chest_sl_get_dmrs(srsran_chest_sl_t* q, cf_t* sf_buffer, cf_t** dmrs_received) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL) { switch (q->channel) { - case SRSLTE_SIDELINK_PSBCH: + case SRSRAN_SIDELINK_PSBCH: return chest_sl_psbch_get_dmrs(q, sf_buffer, dmrs_received); - case SRSLTE_SIDELINK_PSCCH: + case SRSRAN_SIDELINK_PSCCH: return chest_sl_pscch_get_dmrs(q, sf_buffer, dmrs_received); - case SRSLTE_SIDELINK_PSSCH: + case SRSRAN_SIDELINK_PSSCH: return chest_sl_pssch_get_dmrs(q, sf_buffer, dmrs_received); default: - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; break; } } return ret; } -void srslte_chest_sl_ls_estimate(srslte_chest_sl_t* q, cf_t* sf_buffer) +void srsran_chest_sl_ls_estimate(srsran_chest_sl_t* q, cf_t* sf_buffer) { switch (q->channel) { - case SRSLTE_SIDELINK_PSBCH: + case SRSRAN_SIDELINK_PSBCH: return chest_sl_psbch_ls_estimate(q, sf_buffer); - case SRSLTE_SIDELINK_PSCCH: + case SRSRAN_SIDELINK_PSCCH: return chest_sl_pscch_ls_estimate(q, sf_buffer); - case SRSLTE_SIDELINK_PSSCH: + case SRSRAN_SIDELINK_PSSCH: return chest_sl_pssch_ls_estimate(q, sf_buffer); default: return; } } -void srslte_chest_sl_ls_equalize(srslte_chest_sl_t* q, cf_t* sf_buffer, cf_t* equalized_sf_buffer) +void srsran_chest_sl_ls_equalize(srsran_chest_sl_t* q, cf_t* sf_buffer, cf_t* equalized_sf_buffer) { - srslte_chest_sl_estimate_noise(q); + srsran_chest_sl_estimate_noise(q); // Perform channel equalization - srslte_predecoding_single(sf_buffer, q->ce_average, equalized_sf_buffer, NULL, q->sf_n_re, 1.0, q->noise_estimated); + srsran_predecoding_single(sf_buffer, q->ce_average, equalized_sf_buffer, NULL, q->sf_n_re, 1.0, q->noise_estimated); } -void srslte_chest_sl_ls_estimate_equalize(srslte_chest_sl_t* q, cf_t* sf_buffer, cf_t* equalized_sf_buffer) +void srsran_chest_sl_ls_estimate_equalize(srsran_chest_sl_t* q, cf_t* sf_buffer, cf_t* equalized_sf_buffer) { - srslte_chest_sl_ls_estimate(q, sf_buffer); - srslte_chest_sl_ls_equalize(q, sf_buffer, equalized_sf_buffer); + srsran_chest_sl_ls_estimate(q, sf_buffer); + srsran_chest_sl_ls_equalize(q, sf_buffer, equalized_sf_buffer); } -void srslte_chest_sl_free(srslte_chest_sl_t* q) +void srsran_chest_sl_free(srsran_chest_sl_t* q) { if (q != NULL) { - srslte_interp_linear_vector_free(&q->lin_vec_sl); + srsran_interp_linear_vector_free(&q->lin_vec_sl); - for (int i = 0; i < SRSLTE_SL_MAX_DMRS_SYMB; i++) { - for (int j = 0; j < SRSLTE_SL_MAX_PSCCH_NOF_DMRS_CYCLIC_SHIFTS; j++) { + for (int i = 0; i < SRSRAN_SL_MAX_DMRS_SYMB; i++) { + for (int j = 0; j < SRSRAN_SL_MAX_PSCCH_NOF_DMRS_CYCLIC_SHIFTS; j++) { if (q->r_sequence[i][j]) { free(q->r_sequence[i][j]); } diff --git a/lib/src/phy/ch_estimation/chest_ul.c b/lib/src/phy/ch_estimation/chest_ul.c index e7fe3fcb2..00873f077 100644 --- a/lib/src/phy/ch_estimation/chest_ul.c +++ b/lib/src/phy/ch_estimation/chest_ul.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -18,18 +18,18 @@ #include #include -#include "srslte/config.h" -#include "srslte/phy/ch_estimation/chest_ul.h" -#include "srslte/phy/dft/dft_precoding.h" -#include "srslte/phy/utils/convolution.h" -#include "srslte/phy/utils/vector.h" -#include "srslte/srslte.h" +#include "srsran/config.h" +#include "srsran/phy/ch_estimation/chest_ul.h" +#include "srsran/phy/dft/dft_precoding.h" +#include "srsran/phy/utils/convolution.h" +#include "srsran/phy/utils/vector.h" +#include "srsran/srsran.h" -#define NOF_REFS_SYM (q->cell.nof_prb * SRSLTE_NRE) +#define NOF_REFS_SYM (q->cell.nof_prb * SRSRAN_NRE) #define NOF_REFS_SF (NOF_REFS_SYM * 2) // 2 reference symbols per subframe -#define MAX_REFS_SYM (max_prb * SRSLTE_NRE) -#define MAX_REFS_SF (max_prb * SRSLTE_NRE * 2) // 2 reference symbols per subframe +#define MAX_REFS_SYM (max_prb * SRSRAN_NRE) +#define MAX_REFS_SF (max_prb * SRSRAN_NRE * 2) // 2 reference symbols per subframe /** 3GPP LTE Downlink channel estimator and equalizer. * Estimates the channel in the resource elements transmitting references and interpolates for the rest @@ -37,77 +37,77 @@ * * The equalizer uses the channel estimates to produce an estimation of the transmitted symbol. * - * This object depends on the srslte_refsignal_t object for creating the LTE CSR signal. + * This object depends on the srsran_refsignal_t object for creating the LTE CSR signal. */ -int srslte_chest_ul_init(srslte_chest_ul_t* q, uint32_t max_prb) +int srsran_chest_ul_init(srsran_chest_ul_t* q, uint32_t max_prb) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL) { - bzero(q, sizeof(srslte_chest_ul_t)); + bzero(q, sizeof(srsran_chest_ul_t)); - q->tmp_noise = srslte_vec_cf_malloc(MAX_REFS_SF); + q->tmp_noise = srsran_vec_cf_malloc(MAX_REFS_SF); if (!q->tmp_noise) { perror("malloc"); goto clean_exit; } - q->pilot_estimates = srslte_vec_cf_malloc(MAX_REFS_SF); + q->pilot_estimates = srsran_vec_cf_malloc(MAX_REFS_SF); if (!q->pilot_estimates) { perror("malloc"); goto clean_exit; } for (int i = 0; i < 4; i++) { - q->pilot_estimates_tmp[i] = srslte_vec_cf_malloc(MAX_REFS_SF); + q->pilot_estimates_tmp[i] = srsran_vec_cf_malloc(MAX_REFS_SF); if (!q->pilot_estimates_tmp[i]) { perror("malloc"); goto clean_exit; } } - q->pilot_recv_signal = srslte_vec_cf_malloc(MAX_REFS_SF + 1); + q->pilot_recv_signal = srsran_vec_cf_malloc(MAX_REFS_SF + 1); if (!q->pilot_recv_signal) { perror("malloc"); goto clean_exit; } - q->pilot_known_signal = srslte_vec_cf_malloc(MAX_REFS_SF + 1); + q->pilot_known_signal = srsran_vec_cf_malloc(MAX_REFS_SF + 1); if (!q->pilot_known_signal) { perror("malloc"); goto clean_exit; } - if (srslte_interp_linear_vector_init(&q->srslte_interp_linvec, MAX_REFS_SYM)) { + if (srsran_interp_linear_vector_init(&q->srsran_interp_linvec, MAX_REFS_SYM)) { ERROR("Error initializing vector interpolator"); goto clean_exit; } q->smooth_filter_len = 3; - srslte_chest_set_smooth_filter3_coeff(q->smooth_filter, 0.3333); + srsran_chest_set_smooth_filter3_coeff(q->smooth_filter, 0.3333); q->dmrs_signal_configured = false; - if (srslte_refsignal_dmrs_pusch_pregen_init(&q->dmrs_pregen, max_prb)) { + if (srsran_refsignal_dmrs_pusch_pregen_init(&q->dmrs_pregen, max_prb)) { ERROR("Error allocating memory for pregenerated signals"); goto clean_exit; } } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; clean_exit: - if (ret != SRSLTE_SUCCESS) { - srslte_chest_ul_free(q); + if (ret != SRSRAN_SUCCESS) { + srsran_chest_ul_free(q); } return ret; } -void srslte_chest_ul_free(srslte_chest_ul_t* q) +void srsran_chest_ul_free(srsran_chest_ul_t* q) { - srslte_refsignal_dmrs_pusch_pregen_free(&q->dmrs_signal, &q->dmrs_pregen); + srsran_refsignal_dmrs_pusch_pregen_free(&q->dmrs_signal, &q->dmrs_pregen); if (q->tmp_noise) { free(q->tmp_noise); } - srslte_interp_linear_vector_free(&q->srslte_interp_linvec); + srsran_interp_linear_vector_free(&q->srsran_interp_linvec); if (q->pilot_estimates) { free(q->pilot_estimates); @@ -123,14 +123,14 @@ void srslte_chest_ul_free(srslte_chest_ul_t* q) if (q->pilot_known_signal) { free(q->pilot_known_signal); } - bzero(q, sizeof(srslte_chest_ul_t)); + bzero(q, sizeof(srsran_chest_ul_t)); } -int srslte_chest_ul_res_init(srslte_chest_ul_res_t* q, uint32_t max_prb) +int srsran_chest_ul_res_init(srsran_chest_ul_res_t* q, uint32_t max_prb) { - bzero(q, sizeof(srslte_chest_ul_res_t)); - q->nof_re = SRSLTE_SF_LEN_RE(max_prb, SRSLTE_CP_NORM); - q->ce = srslte_vec_cf_malloc(q->nof_re); + bzero(q, sizeof(srsran_chest_ul_res_t)); + q->nof_re = SRSRAN_SF_LEN_RE(max_prb, SRSRAN_CP_NORM); + q->ce = srsran_vec_cf_malloc(q->nof_re); if (!q->ce) { perror("malloc"); return -1; @@ -138,63 +138,63 @@ int srslte_chest_ul_res_init(srslte_chest_ul_res_t* q, uint32_t max_prb) return 0; } -void srslte_chest_ul_res_set_identity(srslte_chest_ul_res_t* q) +void srsran_chest_ul_res_set_identity(srsran_chest_ul_res_t* q) { for (uint32_t i = 0; i < q->nof_re; i++) { q->ce[i] = 1.0; } } -void srslte_chest_ul_res_free(srslte_chest_ul_res_t* q) +void srsran_chest_ul_res_free(srsran_chest_ul_res_t* q) { if (q->ce) { free(q->ce); } } -int srslte_chest_ul_set_cell(srslte_chest_ul_t* q, srslte_cell_t cell) +int srsran_chest_ul_set_cell(srsran_chest_ul_t* q, srsran_cell_t cell) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; - if (q != NULL && srslte_cell_isvalid(&cell)) { + int ret = SRSRAN_ERROR_INVALID_INPUTS; + if (q != NULL && srsran_cell_isvalid(&cell)) { if (cell.id != q->cell.id || q->cell.nof_prb == 0) { q->cell = cell; - ret = srslte_refsignal_ul_set_cell(&q->dmrs_signal, cell); - if (ret != SRSLTE_SUCCESS) { + ret = srsran_refsignal_ul_set_cell(&q->dmrs_signal, cell); + if (ret != SRSRAN_SUCCESS) { ERROR("Error initializing CSR signal (%d)", ret); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_interp_linear_vector_resize(&q->srslte_interp_linvec, NOF_REFS_SYM)) { + if (srsran_interp_linear_vector_resize(&q->srsran_interp_linvec, NOF_REFS_SYM)) { ERROR("Error initializing vector interpolator"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } -void srslte_chest_ul_pregen(srslte_chest_ul_t* q, - srslte_refsignal_dmrs_pusch_cfg_t* cfg, - srslte_refsignal_srs_cfg_t* srs_cfg) +void srsran_chest_ul_pregen(srsran_chest_ul_t* q, + srsran_refsignal_dmrs_pusch_cfg_t* cfg, + srsran_refsignal_srs_cfg_t* srs_cfg) { - srslte_refsignal_dmrs_pusch_pregen(&q->dmrs_signal, &q->dmrs_pregen, cfg); + srsran_refsignal_dmrs_pusch_pregen(&q->dmrs_signal, &q->dmrs_pregen, cfg); q->dmrs_signal_configured = true; if (srs_cfg) { - srslte_refsignal_srs_pregen(&q->dmrs_signal, &q->srs_pregen, srs_cfg, cfg); + srsran_refsignal_srs_pregen(&q->dmrs_signal, &q->srs_pregen, srs_cfg, cfg); q->srs_signal_configured = true; } } /* Uses the difference between the averaged and non-averaged pilot estimates */ -static float estimate_noise_pilots(srslte_chest_ul_t* q, cf_t* ce, uint32_t nslots, uint32_t nrefs, uint32_t n_prb[2]) +static float estimate_noise_pilots(srsran_chest_ul_t* q, cf_t* ce, uint32_t nslots, uint32_t nrefs, uint32_t n_prb[2]) { float power = 0; for (int i = 0; i < nslots; i++) { - power += srslte_chest_estimate_noise_pilots( + power += srsran_chest_estimate_noise_pilots( &q->pilot_estimates[i * nrefs], - &ce[SRSLTE_REFSIGNAL_UL_L(i, q->cell.cp) * q->cell.nof_prb * SRSLTE_NRE + n_prb[i] * SRSLTE_NRE], + &ce[SRSRAN_REFSIGNAL_UL_L(i, q->cell.cp) * q->cell.nof_prb * SRSRAN_NRE + n_prb[i] * SRSRAN_NRE], q->tmp_noise, nrefs); } @@ -212,20 +212,20 @@ static float estimate_noise_pilots(srslte_chest_ul_t* q, cf_t* ce, uint32_t nslo } // The interpolator currently only supports same frequency allocation for each subframe -#define cesymb(i) ce[SRSLTE_RE_IDX(q->cell.nof_prb, i, n_prb[0] * SRSLTE_NRE)] -static void interpolate_pilots(srslte_chest_ul_t* q, cf_t* ce, uint32_t nslots, uint32_t nrefs, uint32_t n_prb[2]) +#define cesymb(i) ce[SRSRAN_RE_IDX(q->cell.nof_prb, i, n_prb[0] * SRSRAN_NRE)] +static void interpolate_pilots(srsran_chest_ul_t* q, cf_t* ce, uint32_t nslots, uint32_t nrefs, uint32_t n_prb[2]) { #ifdef DO_LINEAR_INTERPOLATION - uint32_t L1 = SRSLTE_REFSIGNAL_UL_L(0, q->cell.cp); - uint32_t L2 = SRSLTE_REFSIGNAL_UL_L(1, q->cell.cp); - uint32_t NL = 2 * SRSLTE_CP_NSYMB(q->cell.cp); + uint32_t L1 = SRSRAN_REFSIGNAL_UL_L(0, q->cell.cp); + uint32_t L2 = SRSRAN_REFSIGNAL_UL_L(1, q->cell.cp); + uint32_t NL = 2 * SRSRAN_CP_NSYMB(q->cell.cp); /* Interpolate in the time domain between symbols */ - srslte_interp_linear_vector3( - &q->srslte_interp_linvec, &cesymb(L2), &cesymb(L1), &cesymb(L1), &cesymb(L1 - 1), (L2 - L1), L1, false, nrefs); - srslte_interp_linear_vector3( - &q->srslte_interp_linvec, &cesymb(L1), &cesymb(L2), NULL, &cesymb(L1 + 1), (L2 - L1), (L2 - L1) - 1, true, nrefs); - srslte_interp_linear_vector3(&q->srslte_interp_linvec, + srsran_interp_linear_vector3( + &q->srsran_interp_linvec, &cesymb(L2), &cesymb(L1), &cesymb(L1), &cesymb(L1 - 1), (L2 - L1), L1, false, nrefs); + srsran_interp_linear_vector3( + &q->srsran_interp_linvec, &cesymb(L1), &cesymb(L2), NULL, &cesymb(L1 + 1), (L2 - L1), (L2 - L1) - 1, true, nrefs); + srsran_interp_linear_vector3(&q->srsran_interp_linvec, &cesymb(L1), &cesymb(L2), &cesymb(L2), @@ -237,14 +237,14 @@ static void interpolate_pilots(srslte_chest_ul_t* q, cf_t* ce, uint32_t nslots, #else // Instead of a linear interpolation, we just copy the estimates to all symbols in that subframe for (int s = 0; s < nslots; s++) { - for (int i = 0; i < SRSLTE_CP_NSYMB(q->cell.cp); i++) { - int src_symb = SRSLTE_REFSIGNAL_UL_L(s, q->cell.cp); - int dst_symb = i + s * SRSLTE_CP_NSYMB(q->cell.cp); + for (int i = 0; i < SRSRAN_CP_NSYMB(q->cell.cp); i++) { + int src_symb = SRSRAN_REFSIGNAL_UL_L(s, q->cell.cp); + int dst_symb = i + s * SRSRAN_CP_NSYMB(q->cell.cp); // skip the symbol with the estimates if (dst_symb != src_symb) { - srslte_vec_cf_copy(&ce[(dst_symb * q->cell.nof_prb + n_prb[s]) * SRSLTE_NRE], - &ce[(src_symb * q->cell.nof_prb + n_prb[s]) * SRSLTE_NRE], + srsran_vec_cf_copy(&ce[(dst_symb * q->cell.nof_prb + n_prb[s]) * SRSRAN_NRE], + &ce[(src_symb * q->cell.nof_prb + n_prb[s]) * SRSRAN_NRE], nrefs); } } @@ -253,12 +253,12 @@ static void interpolate_pilots(srslte_chest_ul_t* q, cf_t* ce, uint32_t nslots, } static void -average_pilots(srslte_chest_ul_t* q, cf_t* input, cf_t* ce, uint32_t nslots, uint32_t nrefs, uint32_t n_prb[2]) +average_pilots(srsran_chest_ul_t* q, cf_t* input, cf_t* ce, uint32_t nslots, uint32_t nrefs, uint32_t n_prb[2]) { for (uint32_t i = 0; i < nslots; i++) { - srslte_chest_average_pilots( + srsran_chest_average_pilots( &input[i * nrefs], - &ce[SRSLTE_REFSIGNAL_UL_L(i, q->cell.cp) * q->cell.nof_prb * SRSLTE_NRE + n_prb[i] * SRSLTE_NRE], + &ce[SRSRAN_REFSIGNAL_UL_L(i, q->cell.cp) * q->cell.nof_prb * SRSRAN_NRE + n_prb[i] * SRSRAN_NRE], q->smooth_filter, nrefs, 1, @@ -279,18 +279,18 @@ average_pilots(srslte_chest_ul_t* q, cf_t* input, cf_t* ce, uint32_t nslots, uin * @param n_prb Resource block start for the grant, set to zero for Sounding Reference Signals * @param res UL channel estimation result */ -static void chest_ul_estimate(srslte_chest_ul_t* q, +static void chest_ul_estimate(srsran_chest_ul_t* q, uint32_t nslots, uint32_t nrefs_sym, uint32_t stride, bool meas_ta_en, bool write_estimates, - uint32_t n_prb[SRSLTE_NOF_SLOTS_PER_SF], - srslte_chest_ul_res_t* res) + uint32_t n_prb[SRSRAN_NOF_SLOTS_PER_SF], + srsran_chest_ul_res_t* res) { // Calculate CFO if (nslots == 2) { - float phase = cargf(srslte_vec_dot_prod_conj_ccc( + float phase = cargf(srsran_vec_dot_prod_conj_ccc( &q->pilot_estimates[0 * nrefs_sym], &q->pilot_estimates[1 * nrefs_sym], nrefs_sym)); res->cfo_hz = phase / (2.0f * (float)M_PI * 0.0005f); } else { @@ -301,7 +301,7 @@ static void chest_ul_estimate(srslte_chest_ul_t* q, float ta_err = 0.0f; if (meas_ta_en) { for (int i = 0; i < nslots; i++) { - ta_err += srslte_vec_estimate_frequency(&q->pilot_estimates[i * nrefs_sym], nrefs_sym) / nslots; + ta_err += srsran_vec_estimate_frequency(&q->pilot_estimates[i * nrefs_sym], nrefs_sym) / nslots; } } @@ -334,8 +334,8 @@ static void chest_ul_estimate(srslte_chest_ul_t* q, } else { // Copy estimates to CE vector without averaging for (int i = 0; i < nslots; i++) { - srslte_vec_cf_copy( - &res->ce[SRSLTE_REFSIGNAL_UL_L(i, q->cell.cp) * q->cell.nof_prb * SRSLTE_NRE + n_prb[i] * SRSLTE_NRE], + srsran_vec_cf_copy( + &res->ce[SRSRAN_REFSIGNAL_UL_L(i, q->cell.cp) * q->cell.nof_prb * SRSRAN_NRE + n_prb[i] * SRSRAN_NRE], &q->pilot_estimates[i * nrefs_sym], nrefs_sym); } @@ -348,68 +348,68 @@ static void chest_ul_estimate(srslte_chest_ul_t* q, // Estimate received pilot power if (isnormal(res->noise_estimate)) { - res->snr = srslte_vec_avg_power_cf(q->pilot_recv_signal, nslots * nrefs_sym) / res->noise_estimate; + res->snr = srsran_vec_avg_power_cf(q->pilot_recv_signal, nslots * nrefs_sym) / res->noise_estimate; } else { res->snr = NAN; } // Convert measurements in logarithm scale - res->snr_db = srslte_convert_power_to_dB(res->snr); - res->noise_estimate_dbm = srslte_convert_power_to_dBm(res->noise_estimate); + res->snr_db = srsran_convert_power_to_dB(res->snr); + res->noise_estimate_dbm = srsran_convert_power_to_dBm(res->noise_estimate); } -int srslte_chest_ul_estimate_pusch(srslte_chest_ul_t* q, - srslte_ul_sf_cfg_t* sf, - srslte_pusch_cfg_t* cfg, +int srsran_chest_ul_estimate_pusch(srsran_chest_ul_t* q, + srsran_ul_sf_cfg_t* sf, + srsran_pusch_cfg_t* cfg, cf_t* input, - srslte_chest_ul_res_t* res) + srsran_chest_ul_res_t* res) { if (!q->dmrs_signal_configured) { - ERROR("Error must call srslte_chest_ul_set_cfg() before using the UL estimator"); - return SRSLTE_ERROR; + ERROR("Error must call srsran_chest_ul_set_cfg() before using the UL estimator"); + return SRSRAN_ERROR; } uint32_t nof_prb = cfg->grant.L_prb; - if (!srslte_dft_precoding_valid_prb(nof_prb)) { + if (!srsran_dft_precoding_valid_prb(nof_prb)) { ERROR("Error invalid nof_prb=%d", nof_prb); - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } - int nrefs_sym = nof_prb * SRSLTE_NRE; - int nrefs_sf = nrefs_sym * SRSLTE_NOF_SLOTS_PER_SF; + int nrefs_sym = nof_prb * SRSRAN_NRE; + int nrefs_sf = nrefs_sym * SRSRAN_NOF_SLOTS_PER_SF; /* Get references from the input signal */ - srslte_refsignal_dmrs_pusch_get(&q->dmrs_signal, cfg, input, q->pilot_recv_signal); + srsran_refsignal_dmrs_pusch_get(&q->dmrs_signal, cfg, input, q->pilot_recv_signal); // Use the known DMRS signal to compute Least-squares estimates - srslte_vec_prod_conj_ccc(q->pilot_recv_signal, - q->dmrs_pregen.r[cfg->grant.n_dmrs][sf->tti % SRSLTE_NOF_SF_X_FRAME][nof_prb], + srsran_vec_prod_conj_ccc(q->pilot_recv_signal, + q->dmrs_pregen.r[cfg->grant.n_dmrs][sf->tti % SRSRAN_NOF_SF_X_FRAME][nof_prb], q->pilot_estimates, nrefs_sf); // Estimate - chest_ul_estimate(q, SRSLTE_NOF_SLOTS_PER_SF, nrefs_sym, 1, cfg->meas_ta_en, true, cfg->grant.n_prb, res); + chest_ul_estimate(q, SRSRAN_NOF_SLOTS_PER_SF, nrefs_sym, 1, cfg->meas_ta_en, true, cfg->grant.n_prb, res); return 0; } static float -estimate_noise_pilots_pucch(srslte_chest_ul_t* q, cf_t* ce, uint32_t n_rs, uint32_t n_prb[SRSLTE_NOF_SLOTS_PER_SF]) +estimate_noise_pilots_pucch(srsran_chest_ul_t* q, cf_t* ce, uint32_t n_rs, uint32_t n_prb[SRSRAN_NOF_SLOTS_PER_SF]) { float power = 0; - for (int ns = 0; ns < SRSLTE_NOF_SLOTS_PER_SF; ns++) { + for (int ns = 0; ns < SRSRAN_NOF_SLOTS_PER_SF; ns++) { for (int i = 0; i < n_rs; i++) { // All CE are the same, so pick the first symbol of the first slot always and compare with the noisy estimates - power += srslte_chest_estimate_noise_pilots( - &q->pilot_estimates[(i + ns * n_rs) * SRSLTE_NRE], - &ce[SRSLTE_RE_IDX(q->cell.nof_prb, ns * SRSLTE_CP_NSYMB(q->cell.cp), n_prb[ns] * SRSLTE_NRE)], + power += srsran_chest_estimate_noise_pilots( + &q->pilot_estimates[(i + ns * n_rs) * SRSRAN_NRE], + &ce[SRSRAN_RE_IDX(q->cell.nof_prb, ns * SRSRAN_CP_NSYMB(q->cell.cp), n_prb[ns] * SRSRAN_NRE)], q->tmp_noise, - SRSLTE_NRE); + SRSRAN_NRE); } } - power /= (SRSLTE_NOF_SLOTS_PER_SF * n_rs); + power /= (SRSRAN_NOF_SLOTS_PER_SF * n_rs); if (q->smooth_filter_len == 3) { // Calibrated for filter length 3 @@ -421,29 +421,29 @@ estimate_noise_pilots_pucch(srslte_chest_ul_t* q, cf_t* ce, uint32_t n_rs, uint3 } } -int srslte_chest_ul_estimate_pucch(srslte_chest_ul_t* q, - srslte_ul_sf_cfg_t* sf, - srslte_pucch_cfg_t* cfg, +int srsran_chest_ul_estimate_pucch(srsran_chest_ul_t* q, + srsran_ul_sf_cfg_t* sf, + srsran_pucch_cfg_t* cfg, cf_t* input, - srslte_chest_ul_res_t* res) + srsran_chest_ul_res_t* res) { - int n_rs = srslte_refsignal_dmrs_N_rs(cfg->format, q->cell.cp); + int n_rs = srsran_refsignal_dmrs_N_rs(cfg->format, q->cell.cp); if (!n_rs) { ERROR("Error computing N_rs"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - int nrefs_sf = SRSLTE_NRE * n_rs * SRSLTE_NOF_SLOTS_PER_SF; + int nrefs_sf = SRSRAN_NRE * n_rs * SRSRAN_NOF_SLOTS_PER_SF; /* Get references from the input signal */ - srslte_refsignal_dmrs_pucch_get(&q->dmrs_signal, cfg, input, q->pilot_recv_signal); + srsran_refsignal_dmrs_pucch_get(&q->dmrs_signal, cfg, input, q->pilot_recv_signal); /* Generate known pilots */ - if (cfg->format == SRSLTE_PUCCH_FORMAT_2A || cfg->format == SRSLTE_PUCCH_FORMAT_2B) { + if (cfg->format == SRSRAN_PUCCH_FORMAT_2A || cfg->format == SRSRAN_PUCCH_FORMAT_2B) { float max = -1e9; int i_max = 0; int m = 0; - if (cfg->format == SRSLTE_PUCCH_FORMAT_2A) { + if (cfg->format == SRSRAN_PUCCH_FORMAT_2A) { m = 2; } else { m = 4; @@ -452,9 +452,9 @@ int srslte_chest_ul_estimate_pucch(srslte_chest_ul_t* q, for (int i = 0; i < m; i++) { cfg->pucch2_drs_bits[0] = i % 2; cfg->pucch2_drs_bits[1] = i / 2; - srslte_refsignal_dmrs_pucch_gen(&q->dmrs_signal, sf, cfg, q->pilot_known_signal); - srslte_vec_prod_conj_ccc(q->pilot_recv_signal, q->pilot_known_signal, q->pilot_estimates_tmp[i], nrefs_sf); - float x = cabsf(srslte_vec_acc_cc(q->pilot_estimates_tmp[i], nrefs_sf)); + srsran_refsignal_dmrs_pucch_gen(&q->dmrs_signal, sf, cfg, q->pilot_known_signal); + srsran_vec_prod_conj_ccc(q->pilot_recv_signal, q->pilot_known_signal, q->pilot_estimates_tmp[i], nrefs_sf); + float x = cabsf(srsran_vec_acc_cc(q->pilot_estimates_tmp[i], nrefs_sf)); if (x >= max) { max = x; i_max = i; @@ -465,38 +465,38 @@ int srslte_chest_ul_estimate_pucch(srslte_chest_ul_t* q, cfg->pucch2_drs_bits[1] = i_max / 2; } else { - srslte_refsignal_dmrs_pucch_gen(&q->dmrs_signal, sf, cfg, q->pilot_known_signal); + srsran_refsignal_dmrs_pucch_gen(&q->dmrs_signal, sf, cfg, q->pilot_known_signal); /* Use the known DMRS signal to compute Least-squares estimates */ - srslte_vec_prod_conj_ccc(q->pilot_recv_signal, q->pilot_known_signal, q->pilot_estimates, nrefs_sf); + srsran_vec_prod_conj_ccc(q->pilot_recv_signal, q->pilot_known_signal, q->pilot_estimates, nrefs_sf); } // Measure power float rsrp_avg = 0.0f; - for (int ns = 0; ns < SRSLTE_NOF_SLOTS_PER_SF; ns++) { + for (int ns = 0; ns < SRSRAN_NOF_SLOTS_PER_SF; ns++) { for (int i = 0; i < n_rs; i++) { - cf_t corr = srslte_vec_acc_cc(q->pilot_estimates, SRSLTE_NOF_SLOTS_PER_SF * SRSLTE_NRE * n_rs) / (SRSLTE_NRE); + cf_t corr = srsran_vec_acc_cc(q->pilot_estimates, SRSRAN_NOF_SLOTS_PER_SF * SRSRAN_NRE * n_rs) / (SRSRAN_NRE); rsrp_avg += __real__ corr * __real__ corr + __imag__ corr * __imag__ corr; } } - rsrp_avg /= SRSLTE_NOF_SLOTS_PER_SF * n_rs; - float epre = srslte_vec_avg_power_cf(q->pilot_estimates, SRSLTE_NOF_SLOTS_PER_SF * SRSLTE_NRE * n_rs); + rsrp_avg /= SRSRAN_NOF_SLOTS_PER_SF * n_rs; + float epre = srsran_vec_avg_power_cf(q->pilot_estimates, SRSRAN_NOF_SLOTS_PER_SF * SRSRAN_NRE * n_rs); // RSRP shall not be greater than EPRE - rsrp_avg = SRSLTE_MIN(rsrp_avg, epre); + rsrp_avg = SRSRAN_MIN(rsrp_avg, epre); // Set EPRE and RSRP res->epre = epre; - res->epre_dBfs = srslte_convert_power_to_dB(res->epre); + res->epre_dBfs = srsran_convert_power_to_dB(res->epre); res->rsrp = rsrp_avg; - res->rsrp_dBfs = srslte_convert_power_to_dB(res->rsrp); + res->rsrp_dBfs = srsran_convert_power_to_dB(res->rsrp); // Estimate time alignment if (cfg->meas_ta_en) { float ta_err = 0.0f; - for (int ns = 0; ns < SRSLTE_NOF_SLOTS_PER_SF; ns++) { + for (int ns = 0; ns < SRSRAN_NOF_SLOTS_PER_SF; ns++) { for (int i = 0; i < n_rs; i++) { - ta_err += srslte_vec_estimate_frequency(&q->pilot_estimates[(i + ns * n_rs) * SRSLTE_NRE], SRSLTE_NRE) / - (float)(SRSLTE_NOF_SLOTS_PER_SF * n_rs); + ta_err += srsran_vec_estimate_frequency(&q->pilot_estimates[(i + ns * n_rs) * SRSRAN_NRE], SRSRAN_NRE) / + (float)(SRSRAN_NOF_SLOTS_PER_SF * n_rs); } } @@ -518,33 +518,33 @@ int srslte_chest_ul_estimate_pucch(srslte_chest_ul_t* q, for (int ns = 0; ns < 2; ns++) { // Average all slot for (int i = 1; i < n_rs; i++) { - srslte_vec_sum_ccc(&q->pilot_estimates[ns * n_rs * SRSLTE_NRE], - &q->pilot_estimates[(i + ns * n_rs) * SRSLTE_NRE], - &q->pilot_estimates[ns * n_rs * SRSLTE_NRE], - SRSLTE_NRE); + srsran_vec_sum_ccc(&q->pilot_estimates[ns * n_rs * SRSRAN_NRE], + &q->pilot_estimates[(i + ns * n_rs) * SRSRAN_NRE], + &q->pilot_estimates[ns * n_rs * SRSRAN_NRE], + SRSRAN_NRE); } - srslte_vec_sc_prod_ccc(&q->pilot_estimates[ns * n_rs * SRSLTE_NRE], + srsran_vec_sc_prod_ccc(&q->pilot_estimates[ns * n_rs * SRSRAN_NRE], (float)1.0 / n_rs, - &q->pilot_estimates[ns * n_rs * SRSLTE_NRE], - SRSLTE_NRE); + &q->pilot_estimates[ns * n_rs * SRSRAN_NRE], + SRSRAN_NRE); // Average in freq domain - srslte_chest_average_pilots(&q->pilot_estimates[ns * n_rs * SRSLTE_NRE], - &q->pilot_recv_signal[ns * n_rs * SRSLTE_NRE], + srsran_chest_average_pilots(&q->pilot_estimates[ns * n_rs * SRSRAN_NRE], + &q->pilot_recv_signal[ns * n_rs * SRSRAN_NRE], q->smooth_filter, - SRSLTE_NRE, + SRSRAN_NRE, 1, q->smooth_filter_len); // Determine n_prb - n_prb[ns] = srslte_pucch_n_prb(&q->cell, cfg, ns); + n_prb[ns] = srsran_pucch_n_prb(&q->cell, cfg, ns); // copy estimates to slot - for (int i = 0; i < SRSLTE_CP_NSYMB(q->cell.cp); i++) { - srslte_vec_cf_copy( - &res->ce[SRSLTE_RE_IDX(q->cell.nof_prb, i + ns * SRSLTE_CP_NSYMB(q->cell.cp), n_prb[ns] * SRSLTE_NRE)], - &q->pilot_recv_signal[ns * n_rs * SRSLTE_NRE], - SRSLTE_NRE); + for (int i = 0; i < SRSRAN_CP_NSYMB(q->cell.cp); i++) { + srsran_vec_cf_copy( + &res->ce[SRSRAN_RE_IDX(q->cell.nof_prb, i + ns * SRSRAN_CP_NSYMB(q->cell.cp), n_prb[ns] * SRSRAN_NRE)], + &q->pilot_recv_signal[ns * n_rs * SRSRAN_NRE], + SRSRAN_NRE); } } @@ -553,12 +553,12 @@ int srslte_chest_ul_estimate_pucch(srslte_chest_ul_t* q, if (fpclassify(res->noise_estimate) == FP_ZERO) { res->noise_estimate = FLT_MIN; } - res->noise_estimate_dbm = srslte_convert_power_to_dBm(res->noise_estimate); + res->noise_estimate_dbm = srsran_convert_power_to_dBm(res->noise_estimate); // Estimate SINR if (isnormal(res->noise_estimate)) { res->snr = res->rsrp / res->noise_estimate; - res->snr_db = srslte_convert_power_to_dB(res->snr); + res->snr_db = srsran_convert_power_to_dB(res->snr); } else { res->snr = NAN; res->snr_db = NAN; @@ -568,39 +568,39 @@ int srslte_chest_ul_estimate_pucch(srslte_chest_ul_t* q, return 0; } -int srslte_chest_ul_estimate_srs(srslte_chest_ul_t* q, - srslte_ul_sf_cfg_t* sf, - srslte_refsignal_srs_cfg_t* cfg, - srslte_refsignal_dmrs_pusch_cfg_t* pusch_cfg, +int srsran_chest_ul_estimate_srs(srsran_chest_ul_t* q, + srsran_ul_sf_cfg_t* sf, + srsran_refsignal_srs_cfg_t* cfg, + srsran_refsignal_dmrs_pusch_cfg_t* pusch_cfg, cf_t* input, - srslte_chest_ul_res_t* res) + srsran_chest_ul_res_t* res) { if (q == NULL || sf == NULL || cfg == NULL || pusch_cfg == NULL || input == NULL || res == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } // Extract parameters - uint32_t n_srs_re = srslte_refsignal_srs_M_sc(&q->dmrs_signal, cfg); + uint32_t n_srs_re = srsran_refsignal_srs_M_sc(&q->dmrs_signal, cfg); // Extract Sounding Reference Signal - if (srslte_refsignal_srs_get(&q->dmrs_signal, cfg, sf->tti, q->pilot_recv_signal, input) != SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (srsran_refsignal_srs_get(&q->dmrs_signal, cfg, sf->tti, q->pilot_recv_signal, input) != SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } // Get Known pilots cf_t* known_pilots = q->pilot_known_signal; if (q->srs_signal_configured) { - known_pilots = q->srs_pregen.r[sf->tti % SRSLTE_NOF_SF_X_FRAME]; + known_pilots = q->srs_pregen.r[sf->tti % SRSRAN_NOF_SF_X_FRAME]; } else { - srslte_refsignal_srs_gen(&q->dmrs_signal, cfg, pusch_cfg, sf->tti % SRSLTE_NOF_SF_X_FRAME, known_pilots); + srsran_refsignal_srs_gen(&q->dmrs_signal, cfg, pusch_cfg, sf->tti % SRSRAN_NOF_SF_X_FRAME, known_pilots); } // Compute least squares estimates - srslte_vec_prod_conj_ccc(q->pilot_recv_signal, known_pilots, q->pilot_estimates, n_srs_re); + srsran_vec_prod_conj_ccc(q->pilot_recv_signal, known_pilots, q->pilot_estimates, n_srs_re); // Estimate uint32_t n_prb[2] = {}; chest_ul_estimate(q, 1, n_srs_re, 1, true, false, n_prb, res); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } diff --git a/lib/src/phy/ch_estimation/csi_rs.c b/lib/src/phy/ch_estimation/csi_rs.c index f13627d63..c035ebec3 100644 --- a/lib/src/phy/ch_estimation/csi_rs.c +++ b/lib/src/phy/ch_estimation/csi_rs.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,37 +10,37 @@ * */ -#include "srslte/phy/ch_estimation/csi_rs.h" -#include "srslte/phy/common/sequence.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/ch_estimation/csi_rs.h" +#include "srsran/phy/common/sequence.h" +#include "srsran/phy/utils/vector.h" #include #include #include -#define SRSLTE_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_ROW1 4 -#define SRSLTE_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_ROW2 12 -#define SRSLTE_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_ROW4 3 -#define SRSLTE_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_OTHER 6 -#define SRSLTE_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_MAX 12 +#define SRSRAN_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_ROW1 4 +#define SRSRAN_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_ROW2 12 +#define SRSRAN_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_ROW4 3 +#define SRSRAN_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_OTHER 6 +#define SRSRAN_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_MAX 12 #define CSI_RS_MAX_CDM_GROUP 16 -static int csi_rs_location_f(const srslte_csi_rs_resource_mapping_t* resource, uint32_t i) +static int csi_rs_location_f(const srsran_csi_rs_resource_mapping_t* resource, uint32_t i) { uint32_t count = 0; uint32_t nof_freq_domain = 0; switch (resource->row) { - case srslte_csi_rs_resource_mapping_row_1: - nof_freq_domain = SRSLTE_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_ROW1; + case srsran_csi_rs_resource_mapping_row_1: + nof_freq_domain = SRSRAN_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_ROW1; break; - case srslte_csi_rs_resource_mapping_row_2: - nof_freq_domain = SRSLTE_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_ROW2; + case srsran_csi_rs_resource_mapping_row_2: + nof_freq_domain = SRSRAN_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_ROW2; break; - case srslte_csi_rs_resource_mapping_row_4: - nof_freq_domain = SRSLTE_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_ROW4; + case srsran_csi_rs_resource_mapping_row_4: + nof_freq_domain = SRSRAN_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_ROW4; break; - case srslte_csi_rs_resource_mapping_row_other: - nof_freq_domain = SRSLTE_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_OTHER; + case srsran_csi_rs_resource_mapping_row_other: + nof_freq_domain = SRSRAN_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_OTHER; break; } @@ -54,11 +54,11 @@ static int csi_rs_location_f(const srslte_csi_rs_resource_mapping_t* resource, u } } - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Table 7.4.1.5.3-1: CSI-RS locations within a slot -static int csi_rs_location_get_k_list(const srslte_csi_rs_resource_mapping_t* resource, +static int csi_rs_location_get_k_list(const srsran_csi_rs_resource_mapping_t* resource, uint32_t k_list[CSI_RS_MAX_CDM_GROUP]) { int k0 = csi_rs_location_f(resource, 1); @@ -66,59 +66,59 @@ static int csi_rs_location_get_k_list(const srslte_csi_rs_resource_mapping_t* re // int k2 = csi_rs_location_f(resource, 3); // int k3 = csi_rs_location_f(resource, 4); - if (k0 < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (k0 < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } // Row 1 - if (resource->row == srslte_csi_rs_resource_mapping_row_1 && resource->ports == 1 && - resource->density == srslte_csi_rs_resource_mapping_density_three && resource->cdm == srslte_csi_rs_cdm_nocdm) { + if (resource->row == srsran_csi_rs_resource_mapping_row_1 && resource->ports == 1 && + resource->density == srsran_csi_rs_resource_mapping_density_three && resource->cdm == srsran_csi_rs_cdm_nocdm) { k_list[0] = k0; k_list[1] = k0 + 4; k_list[2] = k0 + 8; return 3; } - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Table 7.4.1.5.3-1: CSI-RS locations within a slot -static int csi_rs_location_get_l_list(const srslte_csi_rs_resource_mapping_t* resource, +static int csi_rs_location_get_l_list(const srsran_csi_rs_resource_mapping_t* resource, uint32_t l_list[CSI_RS_MAX_CDM_GROUP]) { uint32_t l0 = resource->first_symbol_idx; if (l0 > 13) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // uint32_t l1 = resource->first_symbol_idx2; // if (l1 < 2 || l1 > 12) { - // return SRSLTE_ERROR; + // return SRSRAN_ERROR; // } // Row 1 - if (resource->row == srslte_csi_rs_resource_mapping_row_1 && resource->ports == 1 && - resource->density == srslte_csi_rs_resource_mapping_density_three && resource->cdm == srslte_csi_rs_cdm_nocdm) { + if (resource->row == srsran_csi_rs_resource_mapping_row_1 && resource->ports == 1 && + resource->density == srsran_csi_rs_resource_mapping_density_three && resource->cdm == srsran_csi_rs_cdm_nocdm) { l_list[0] = l0; return 1; } - return SRSLTE_ERROR; + return SRSRAN_ERROR; } -uint32_t csi_rs_cinit(const srslte_carrier_nr_t* carrier, - const srslte_slot_cfg_t* slot_cfg, - const srslte_csi_rs_nzp_resource_t* resource, +uint32_t csi_rs_cinit(const srsran_carrier_nr_t* carrier, + const srsran_slot_cfg_t* slot_cfg, + const srsran_csi_rs_nzp_resource_t* resource, uint32_t l) { - uint32_t n = SRSLTE_SLOT_NR_MOD(carrier->numerology, slot_cfg->idx); + uint32_t n = SRSRAN_SLOT_NR_MOD(carrier->numerology, slot_cfg->idx); uint32_t n_id = resource->scrambling_id; - return ((SRSLTE_NSYMB_PER_SLOT_NR * n + l + 1UL) * (2UL * n_id) << 10UL) + n_id; + return ((SRSRAN_NSYMB_PER_SLOT_NR * n + l + 1UL) * (2UL * n_id) << 10UL) + n_id; } -bool srslte_csi_send(const srslte_csi_rs_period_and_offset_t* periodicity, const srslte_slot_cfg_t* slot_cfg) +bool srsran_csi_send(const srsran_csi_rs_period_and_offset_t* periodicity, const srsran_slot_cfg_t* slot_cfg) { if (periodicity == NULL || slot_cfg == NULL) { return false; @@ -133,47 +133,47 @@ bool srslte_csi_send(const srslte_csi_rs_period_and_offset_t* periodicity, const return n == 0; } -uint32_t csi_rs_count(srslte_csi_rs_density_t density, uint32_t nprb) +uint32_t csi_rs_count(srsran_csi_rs_density_t density, uint32_t nprb) { switch (density) { - case srslte_csi_rs_resource_mapping_density_three: + case srsran_csi_rs_resource_mapping_density_three: return nprb * 3; - case srslte_csi_rs_resource_mapping_density_dot5_even: + case srsran_csi_rs_resource_mapping_density_dot5_even: return nprb / 2; - case srslte_csi_rs_resource_mapping_density_dot5_odd: + case srsran_csi_rs_resource_mapping_density_dot5_odd: return nprb / 2; - case srslte_csi_rs_resource_mapping_density_one: + case srsran_csi_rs_resource_mapping_density_one: return nprb; - case srslte_csi_rs_resource_mapping_density_spare: + case srsran_csi_rs_resource_mapping_density_spare: default:; // Do nothing } return 0; } -uint32_t csi_rs_rb_begin(const srslte_carrier_nr_t* carrier, const srslte_csi_rs_resource_mapping_t* m) +uint32_t csi_rs_rb_begin(const srsran_carrier_nr_t* carrier, const srsran_csi_rs_resource_mapping_t* m) { - uint32_t ret = SRSLTE_MAX(carrier->start, m->freq_band.start_rb); + uint32_t ret = SRSRAN_MAX(carrier->start, m->freq_band.start_rb); - if ((m->density == srslte_csi_rs_resource_mapping_density_dot5_even && ret % 2 == 1) || - (m->density == srslte_csi_rs_resource_mapping_density_dot5_odd && ret % 2 == 0)) { + if ((m->density == srsran_csi_rs_resource_mapping_density_dot5_even && ret % 2 == 1) || + (m->density == srsran_csi_rs_resource_mapping_density_dot5_odd && ret % 2 == 0)) { ret++; } return ret; } -uint32_t csi_rs_rb_end(const srslte_carrier_nr_t* carrier, const srslte_csi_rs_resource_mapping_t* m) +uint32_t csi_rs_rb_end(const srsran_carrier_nr_t* carrier, const srsran_csi_rs_resource_mapping_t* m) { - return SRSLTE_MIN(carrier->start + carrier->nof_prb, m->freq_band.start_rb + m->freq_band.nof_rb); + return SRSRAN_MIN(carrier->start + carrier->nof_prb, m->freq_band.start_rb + m->freq_band.nof_rb); } -uint32_t csi_rs_rb_stride(const srslte_csi_rs_resource_mapping_t* m) +uint32_t csi_rs_rb_stride(const srsran_csi_rs_resource_mapping_t* m) { uint32_t ret = 1; // Special .5 density cases - if (m->density == srslte_csi_rs_resource_mapping_density_dot5_even || - m->density == srslte_csi_rs_resource_mapping_density_dot5_odd) { + if (m->density == srsran_csi_rs_resource_mapping_density_dot5_even || + m->density == srsran_csi_rs_resource_mapping_density_dot5_odd) { // Skip one RB ret = 2; } @@ -181,25 +181,25 @@ uint32_t csi_rs_rb_stride(const srslte_csi_rs_resource_mapping_t* m) return ret; } -int srslte_csi_rs_nzp_put(const srslte_carrier_nr_t* carrier, - const srslte_slot_cfg_t* slot_cfg, - const srslte_csi_rs_nzp_resource_t* resource, +int srsran_csi_rs_nzp_put(const srsran_carrier_nr_t* carrier, + const srsran_slot_cfg_t* slot_cfg, + const srsran_csi_rs_nzp_resource_t* resource, cf_t* grid) { if (carrier == NULL || resource == NULL || grid == NULL) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } uint32_t k_list[CSI_RS_MAX_CDM_GROUP]; int nof_k = csi_rs_location_get_k_list(&resource->resource_mapping, k_list); if (nof_k <= 0) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } uint32_t l_list[CSI_RS_MAX_CDM_GROUP]; int nof_l = csi_rs_location_get_l_list(&resource->resource_mapping, l_list); if (nof_l <= 0) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Calculate Resource Block boundaries @@ -208,7 +208,7 @@ int srslte_csi_rs_nzp_put(const srslte_carrier_nr_t* carrier, uint32_t rb_stride = csi_rs_rb_stride(&resource->resource_mapping); // Calculate power allocation - float beta = srslte_convert_dB_to_amplitude((float)resource->power_control_offset); + float beta = srsran_convert_dB_to_amplitude((float)resource->power_control_offset); if (!isnormal(beta)) { beta = 1.0f; } @@ -219,11 +219,11 @@ int srslte_csi_rs_nzp_put(const srslte_carrier_nr_t* carrier, // Initialise sequence for this OFDM symbol uint32_t cinit = csi_rs_cinit(carrier, slot_cfg, resource, l); - srslte_sequence_state_t sequence_state = {}; - srslte_sequence_state_init(&sequence_state, cinit); + srsran_sequence_state_t sequence_state = {}; + srsran_sequence_state_init(&sequence_state, cinit); // Skip unallocated RB - srslte_sequence_state_advance(&sequence_state, 2 * csi_rs_count(resource->resource_mapping.density, rb_begin)); + srsran_sequence_state_advance(&sequence_state, 2 * csi_rs_count(resource->resource_mapping.density, rb_begin)); // Temporal R sequence cf_t r[64]; @@ -233,44 +233,44 @@ int srslte_csi_rs_nzp_put(const srslte_carrier_nr_t* carrier, for (uint32_t n = rb_begin; n < rb_end; n += rb_stride) { for (uint32_t k_idx = 0; k_idx < nof_k; k_idx++) { // Calculate sub-carrier index k - uint32_t k = SRSLTE_NRE * n + k_list[k_idx]; + uint32_t k = SRSRAN_NRE * n + k_list[k_idx]; // Do we need more r? if (r_idx >= 64) { // ... Generate a bunch of it! - srslte_sequence_state_gen_f(&sequence_state, M_SQRT1_2 * beta, (float*)r, 64 * 2); + srsran_sequence_state_gen_f(&sequence_state, M_SQRT1_2 * beta, (float*)r, 64 * 2); r_idx = 0; } // Put CSI in grid - grid[l * SRSLTE_NRE * carrier->nof_prb + k] = r[r_idx++]; + grid[l * SRSRAN_NRE * carrier->nof_prb + k] = r[r_idx++]; } } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_csi_rs_nzp_measure(const srslte_carrier_nr_t* carrier, - const srslte_slot_cfg_t* slot_cfg, - const srslte_csi_rs_nzp_resource_t* resource, +int srsran_csi_rs_nzp_measure(const srsran_carrier_nr_t* carrier, + const srsran_slot_cfg_t* slot_cfg, + const srsran_csi_rs_nzp_resource_t* resource, const cf_t* grid, - srslte_csi_rs_measure_t* measure) + srsran_csi_rs_measure_t* measure) { if (carrier == NULL || resource == NULL || grid == NULL) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } uint32_t k_list[CSI_RS_MAX_CDM_GROUP]; int nof_k = csi_rs_location_get_k_list(&resource->resource_mapping, k_list); if (nof_k <= 0) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } uint32_t l_list[CSI_RS_MAX_CDM_GROUP]; int nof_l = csi_rs_location_get_l_list(&resource->resource_mapping, l_list); if (nof_l <= 0) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Calculate Resource Block boundaries @@ -289,11 +289,11 @@ int srslte_csi_rs_nzp_measure(const srslte_carrier_nr_t* carrier, // Initialise sequence for this OFDM symbol uint32_t cinit = csi_rs_cinit(carrier, slot_cfg, resource, l); - srslte_sequence_state_t sequence_state = {}; - srslte_sequence_state_init(&sequence_state, cinit); + srsran_sequence_state_t sequence_state = {}; + srsran_sequence_state_init(&sequence_state, cinit); // Skip unallocated RB - srslte_sequence_state_advance(&sequence_state, 2 * csi_rs_count(resource->resource_mapping.density, rb_begin)); + srsran_sequence_state_advance(&sequence_state, 2 * csi_rs_count(resource->resource_mapping.density, rb_begin)); // Temporal R sequence cf_t r[64]; @@ -303,17 +303,17 @@ int srslte_csi_rs_nzp_measure(const srslte_carrier_nr_t* carrier, for (uint32_t n = rb_begin; n < rb_end; n += rb_stride) { for (uint32_t k_idx = 0; k_idx < nof_k; k_idx++) { // Calculate sub-carrier index k - uint32_t k = SRSLTE_NRE * n + k_list[k_idx]; + uint32_t k = SRSRAN_NRE * n + k_list[k_idx]; // Do we need more r? if (r_idx >= 64) { // ... Generate a bunch of it! - srslte_sequence_state_gen_f(&sequence_state, M_SQRT1_2, (float*)r, 64 * 2); + srsran_sequence_state_gen_f(&sequence_state, M_SQRT1_2, (float*)r, 64 * 2); r_idx = 0; } // Take CSI-RS from grid and measure - cf_t tmp = grid[l * SRSLTE_NRE * carrier->nof_prb + k] * conjf(r[r_idx++]); + cf_t tmp = grid[l * SRSRAN_NRE * carrier->nof_prb + k] * conjf(r[r_idx++]); rsrp_acc += tmp; epre_acc += __real__ tmp * __real__ tmp + __imag__ tmp * __imag__ tmp; count++; @@ -332,18 +332,18 @@ int srslte_csi_rs_nzp_measure(const srslte_carrier_nr_t* carrier, } } - measure->rsrp_dB = srslte_convert_power_to_dB(measure->rsrp); - measure->epre_dB = srslte_convert_power_to_dB(measure->epre); - measure->n0_dB = srslte_convert_power_to_dB(measure->n0); + measure->rsrp_dB = srsran_convert_power_to_dB(measure->rsrp); + measure->epre_dB = srsran_convert_power_to_dB(measure->epre); + measure->n0_dB = srsran_convert_power_to_dB(measure->n0); measure->snr_dB = measure->rsrp_dB - measure->n0_dB; measure->nof_re = count; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -uint32_t srslte_csi_rs_measure_info(const srslte_csi_rs_measure_t* measure, char* str, uint32_t str_len) +uint32_t srsran_csi_rs_measure_info(const srsran_csi_rs_measure_t* measure, char* str, uint32_t str_len) { - return srslte_print_check(str, + return srsran_print_check(str, str_len, 0, "rsrp=%+.1f, epre=%+.1f, n0=%+.1f, snr=%+.1f, nof_re=%d", diff --git a/lib/src/phy/ch_estimation/dmrs_pdcch.c b/lib/src/phy/ch_estimation/dmrs_pdcch.c index f30e6b091..161da0e86 100644 --- a/lib/src/phy/ch_estimation/dmrs_pdcch.c +++ b/lib/src/phy/ch_estimation/dmrs_pdcch.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,12 +10,12 @@ * */ -#include "srslte/phy/ch_estimation/dmrs_pdcch.h" -#include "srslte/phy/ch_estimation/chest_common.h" -#include "srslte/phy/common/sequence.h" -#include "srslte/phy/utils/convolution.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/ch_estimation/dmrs_pdcch.h" +#include "srsran/phy/ch_estimation/chest_common.h" +#include "srsran/phy/common/sequence.h" +#include "srsran/phy/utils/convolution.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" #include #include @@ -31,22 +31,22 @@ static uint32_t dmrs_pdcch_get_cinit(uint32_t slot_idx, uint32_t symbol_idx, uint32_t n_id) { - return SRSLTE_SEQUENCE_MOD((((SRSLTE_NSYMB_PER_SLOT_NR * slot_idx + symbol_idx + 1UL) * (2UL * n_id + 1UL)) << 17U) + + return SRSRAN_SEQUENCE_MOD((((SRSRAN_NSYMB_PER_SLOT_NR * slot_idx + symbol_idx + 1UL) * (2UL * n_id + 1UL)) << 17U) + 2UL * n_id); } -static void dmrs_pdcch_put_symbol_noninterleaved(const srslte_carrier_nr_t* carrier, - const srslte_coreset_t* coreset, - const srslte_dci_location_t* dci_location, +static void dmrs_pdcch_put_symbol_noninterleaved(const srsran_carrier_nr_t* carrier, + const srsran_coreset_t* coreset, + const srsran_dci_location_t* dci_location, uint32_t cinit, cf_t* sf_symbol) { uint32_t L = 1U << dci_location->L; - uint32_t nof_freq_res = SRSLTE_MIN(carrier->nof_prb / 6, SRSLTE_CORESET_FREQ_DOMAIN_RES_SIZE); + uint32_t nof_freq_res = SRSRAN_MIN(carrier->nof_prb / 6, SRSRAN_CORESET_FREQ_DOMAIN_RES_SIZE); // Initialise sequence for this symbol - srslte_sequence_state_t sequence_state = {}; - srslte_sequence_state_init(&sequence_state, cinit); + srsran_sequence_state_t sequence_state = {}; + srsran_sequence_state_init(&sequence_state, cinit); uint32_t sequence_skip = 0; // Accumulates pilot locations to skip // Calculate Resource block indexes range, every CCE is 6 REG, 1 REG is 6 RE in resource blocks @@ -79,12 +79,12 @@ static void dmrs_pdcch_put_symbol_noninterleaved(const srslte_carrier_nr_t* ca } // Skip all discarded possible pilot locations - srslte_sequence_state_advance(&sequence_state, 2 * sequence_skip); + srsran_sequence_state_advance(&sequence_state, 2 * sequence_skip); sequence_skip = 0; // Generate pilots cf_t rl[NOF_PILOTS_X_FREQ_RES]; - srslte_sequence_state_gen_f(&sequence_state, M_SQRT1_2, (float*)rl, NOF_PILOTS_X_FREQ_RES * 2); + srsran_sequence_state_gen_f(&sequence_state, M_SQRT1_2, (float*)rl, NOF_PILOTS_X_FREQ_RES * 2); // For each RB in the frequency resource for (uint32_t j = 0; j < 6; j++) { @@ -105,7 +105,7 @@ static void dmrs_pdcch_put_symbol_noninterleaved(const srslte_carrier_nr_t* ca // Write pilots in the symbol for (uint32_t k_prime = 0; k_prime < 3; k_prime++) { // Calculate sub-carrier index - uint32_t k = n * SRSLTE_NRE + 4 * k_prime + 1; + uint32_t k = n * SRSRAN_NRE + 4 * k_prime + 1; sf_symbol[k] = rl[3 * j + k_prime]; } @@ -114,27 +114,27 @@ static void dmrs_pdcch_put_symbol_noninterleaved(const srslte_carrier_nr_t* ca } } -int srslte_dmrs_pdcch_put(const srslte_carrier_nr_t* carrier, - const srslte_coreset_t* coreset, - const srslte_slot_cfg_t* slot_cfg, - const srslte_dci_location_t* dci_location, +int srsran_dmrs_pdcch_put(const srsran_carrier_nr_t* carrier, + const srsran_coreset_t* coreset, + const srsran_slot_cfg_t* slot_cfg, + const srsran_dci_location_t* dci_location, cf_t* sf_symbols) { if (carrier == NULL || coreset == NULL || slot_cfg == NULL || dci_location == NULL || sf_symbols == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } - if (coreset->mapping_type == srslte_coreset_mapping_type_interleaved) { + if (coreset->mapping_type == srsran_coreset_mapping_type_interleaved) { ERROR("Error interleaved CORESET mapping is not currently implemented"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (coreset->duration < SRSLTE_CORESET_DURATION_MIN || coreset->duration > SRSLTE_CORESET_DURATION_MAX) { + if (coreset->duration < SRSRAN_CORESET_DURATION_MIN || coreset->duration > SRSRAN_CORESET_DURATION_MAX) { ERROR("Error CORESET duration %d is out-of-bounds (%d,%d)", coreset->duration, - SRSLTE_CORESET_DURATION_MIN, - SRSLTE_CORESET_DURATION_MAX); - return SRSLTE_ERROR; + SRSRAN_CORESET_DURATION_MIN, + SRSRAN_CORESET_DURATION_MAX); + return SRSRAN_ERROR; } // Use cell id if the DMR scrambling id is not provided by higher layers @@ -144,7 +144,7 @@ int srslte_dmrs_pdcch_put(const srslte_carrier_nr_t* carrier, } // Bound slot index - uint32_t slot_idx = SRSLTE_SLOT_NR_MOD(carrier->numerology, slot_cfg->idx); + uint32_t slot_idx = SRSRAN_SLOT_NR_MOD(carrier->numerology, slot_cfg->idx); for (uint32_t l = 0; l < coreset->duration; l++) { // Get Cin @@ -154,34 +154,34 @@ int srslte_dmrs_pdcch_put(const srslte_carrier_nr_t* carrier, // Put data dmrs_pdcch_put_symbol_noninterleaved( - carrier, coreset, dci_location, cinit, &sf_symbols[carrier->nof_prb * SRSLTE_NRE * l]); + carrier, coreset, dci_location, cinit, &sf_symbols[carrier->nof_prb * SRSRAN_NRE * l]); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_dmrs_pdcch_estimator_init(srslte_dmrs_pdcch_estimator_t* q, - const srslte_carrier_nr_t* carrier, - const srslte_coreset_t* coreset) +int srsran_dmrs_pdcch_estimator_init(srsran_dmrs_pdcch_estimator_t* q, + const srsran_carrier_nr_t* carrier, + const srsran_coreset_t* coreset) { if (q == NULL || carrier == NULL || coreset == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } - if (coreset->duration < SRSLTE_CORESET_DURATION_MIN || coreset->duration > SRSLTE_CORESET_DURATION_MAX) { + if (coreset->duration < SRSRAN_CORESET_DURATION_MIN || coreset->duration > SRSRAN_CORESET_DURATION_MAX) { ERROR("Error CORESET duration %d is out-of-bounds (%d,%d)", coreset->duration, - SRSLTE_CORESET_DURATION_MIN, - SRSLTE_CORESET_DURATION_MAX); - return SRSLTE_ERROR; + SRSRAN_CORESET_DURATION_MIN, + SRSRAN_CORESET_DURATION_MAX); + return SRSRAN_ERROR; } // The carrier configuration is not used for initialization, so copy it always q->carrier = *carrier; // Detect change in CORESET, if none, return early - if (memcmp(&q->coreset, coreset, sizeof(srslte_coreset_t)) == 0) { - return SRSLTE_SUCCESS; + if (memcmp(&q->coreset, coreset, sizeof(srsran_coreset_t)) == 0) { + return SRSRAN_SUCCESS; } // Save new CORESET @@ -189,26 +189,26 @@ int srslte_dmrs_pdcch_estimator_init(srslte_dmrs_pdcch_estimator_t* q, // The interpolator may return without reconfiguring after the first call if (q->interpolator.M != 0) { - srslte_interp_linear_free(&q->interpolator); + srsran_interp_linear_free(&q->interpolator); } // Calculate new bandwidth and size - uint32_t coreset_bw = srslte_coreset_get_bw(coreset); - uint32_t coreset_sz = srslte_coreset_get_sz(coreset); + uint32_t coreset_bw = srsran_coreset_get_bw(coreset); + uint32_t coreset_sz = srsran_coreset_get_sz(coreset); #if DMRS_PDCCH_INTERPOLATE_GROUP - if (srslte_interp_linear_init(&q->interpolator, NOF_PILOTS_X_FREQ_RES / q->coreset.duration, 4)) { + if (srsran_interp_linear_init(&q->interpolator, NOF_PILOTS_X_FREQ_RES / q->coreset.duration, 4)) { #else - if (srslte_interp_linear_init(&q->interpolator, coreset_bw * 3, 4)) { + if (srsran_interp_linear_init(&q->interpolator, coreset_bw * 3, 4)) { #endif ERROR("Initiating interpolator"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Reallocate only if the CORESET size or bandwidth changed if (q->coreset_bw != coreset_bw || q->coreset_sz != coreset_sz) { // Iterate all possible symbols - for (uint32_t l = 0; l < SRSLTE_CORESET_DURATION_MAX; l++) { + for (uint32_t l = 0; l < SRSRAN_CORESET_DURATION_MAX; l++) { // Free if allocated if (q->lse[l] != NULL) { free(q->lse[l]); @@ -218,35 +218,35 @@ int srslte_dmrs_pdcch_estimator_init(srslte_dmrs_pdcch_estimator_t* q, // Allocate if (l < coreset->duration) { // Allocate for 3 pilots per physical resource block - q->lse[l] = srslte_vec_cf_malloc(coreset_bw * 3); + q->lse[l] = srsran_vec_cf_malloc(coreset_bw * 3); } } if (q->ce) { free(q->ce); } - q->ce = srslte_vec_cf_malloc(coreset_sz); + q->ce = srsran_vec_cf_malloc(coreset_sz); } if (q->filter == NULL) { q->filter_len = 5U; - q->filter = srslte_vec_f_malloc(q->filter_len); + q->filter = srsran_vec_f_malloc(q->filter_len); if (q->filter == NULL) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - srslte_chest_set_smooth_filter_gauss(q->filter, q->filter_len - 1, 2); + srsran_chest_set_smooth_filter_gauss(q->filter, q->filter_len - 1, 2); } // Save new calculated values q->coreset_bw = coreset_bw; q->coreset_sz = coreset_sz; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -void srslte_dmrs_pdcch_estimator_free(srslte_dmrs_pdcch_estimator_t* q) +void srsran_dmrs_pdcch_estimator_free(srsran_dmrs_pdcch_estimator_t* q) { if (q == NULL) { return; @@ -256,7 +256,7 @@ void srslte_dmrs_pdcch_estimator_free(srslte_dmrs_pdcch_estimator_t* q) free(q->ce); } - for (uint32_t i = 0; i < SRSLTE_CORESET_DURATION_MAX; i++) { + for (uint32_t i = 0; i < SRSRAN_CORESET_DURATION_MAX; i++) { if (q->lse[i]) { free(q->lse[i]); } @@ -266,17 +266,17 @@ void srslte_dmrs_pdcch_estimator_free(srslte_dmrs_pdcch_estimator_t* q) free(q->filter); } - srslte_interp_linear_free(&q->interpolator); + srsran_interp_linear_free(&q->interpolator); - SRSLTE_MEM_ZERO(q, srslte_dmrs_pdcch_estimator_t, 1); + SRSRAN_MEM_ZERO(q, srsran_dmrs_pdcch_estimator_t, 1); } static void -srslte_dmrs_pdcch_extract(srslte_dmrs_pdcch_estimator_t* q, uint32_t cinit, const cf_t* sf_symbol, cf_t* lse) +srsran_dmrs_pdcch_extract(srsran_dmrs_pdcch_estimator_t* q, uint32_t cinit, const cf_t* sf_symbol, cf_t* lse) { // Initialise pseudo-random sequence - srslte_sequence_state_t sequence_state = {}; - srslte_sequence_state_init(&sequence_state, cinit); + srsran_sequence_state_t sequence_state = {}; + srsran_sequence_state_init(&sequence_state, cinit); // Counter for skipping unused pilot locations uint32_t sequence_skip = 0; @@ -285,7 +285,7 @@ srslte_dmrs_pdcch_extract(srslte_dmrs_pdcch_estimator_t* q, uint32_t cinit, cons uint32_t rb_coreset_idx = 0; // Iterate over all possible frequency resources - uint32_t freq_domain_res_size = SRSLTE_MIN(q->carrier.nof_prb / 6, SRSLTE_CORESET_FREQ_DOMAIN_RES_SIZE); + uint32_t freq_domain_res_size = SRSRAN_MIN(q->carrier.nof_prb / 6, SRSRAN_CORESET_FREQ_DOMAIN_RES_SIZE); for (uint32_t i = 0; i < freq_domain_res_size; i++) { // Skip disabled frequency resources if (!q->coreset.freq_resources[i]) { @@ -294,12 +294,12 @@ srslte_dmrs_pdcch_extract(srslte_dmrs_pdcch_estimator_t* q, uint32_t cinit, cons } // Skip unused pilots - srslte_sequence_state_advance(&sequence_state, 2 * sequence_skip); + srsran_sequence_state_advance(&sequence_state, 2 * sequence_skip); sequence_skip = 0; // Generate sequence cf_t rl[NOF_PILOTS_X_FREQ_RES]; - srslte_sequence_state_gen_f(&sequence_state, M_SQRT1_2, (float*)rl, NOF_PILOTS_X_FREQ_RES * 2); + srsran_sequence_state_gen_f(&sequence_state, M_SQRT1_2, (float*)rl, NOF_PILOTS_X_FREQ_RES * 2); // Iterate all PRBs in the enabled frequency domain resource for (uint32_t j = 0, idx = rb_coreset_idx * NOF_PILOTS_X_FREQ_RES; j < 6; j++) { @@ -309,7 +309,7 @@ srslte_dmrs_pdcch_extract(srslte_dmrs_pdcch_estimator_t* q, uint32_t cinit, cons // For each pilot in the PRB for (uint32_t k_prime = 0; k_prime < 3; k_prime++, idx++) { // Calculate sub-carrier index - uint32_t k = n * SRSLTE_NRE + 4 * k_prime + 1; + uint32_t k = n * SRSRAN_NRE + 4 * k_prime + 1; // Extract symbol lse[idx] = sf_symbol[k]; @@ -318,19 +318,19 @@ srslte_dmrs_pdcch_extract(srslte_dmrs_pdcch_estimator_t* q, uint32_t cinit, cons // Calculate least squared estimates cf_t* lse_ptr = &lse[rb_coreset_idx * NOF_PILOTS_X_FREQ_RES]; - srslte_vec_prod_conj_ccc(lse_ptr, rl, lse_ptr, NOF_PILOTS_X_FREQ_RES); + srsran_vec_prod_conj_ccc(lse_ptr, rl, lse_ptr, NOF_PILOTS_X_FREQ_RES); // Increment frequency domain resource counter rb_coreset_idx++; } } -int srslte_dmrs_pdcch_estimate(srslte_dmrs_pdcch_estimator_t* q, - const srslte_slot_cfg_t* slot_cfg, +int srsran_dmrs_pdcch_estimate(srsran_dmrs_pdcch_estimator_t* q, + const srsran_slot_cfg_t* slot_cfg, const cf_t* sf_symbols) { if (q == NULL || sf_symbols == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } // Use cell id if the DMR scrambling id is not provided by higher layers @@ -340,7 +340,7 @@ int srslte_dmrs_pdcch_estimate(srslte_dmrs_pdcch_estimator_t* q, } // Bound slot index - uint32_t slot_idx = SRSLTE_SLOT_NR_MOD(q->carrier.numerology, slot_cfg->idx); + uint32_t slot_idx = SRSRAN_SLOT_NR_MOD(q->carrier.numerology, slot_cfg->idx); // Extract pilots for (uint32_t l = 0; l < q->coreset.duration; l++) { @@ -350,7 +350,7 @@ int srslte_dmrs_pdcch_estimate(srslte_dmrs_pdcch_estimator_t* q, DMRS_PDCCH_INFO_RX("n=%d; l=%d; cinit=%08x", slot_idx, l, cinit); // Extract pilots least square estimates - srslte_dmrs_pdcch_extract(q, cinit, &sf_symbols[l * q->carrier.nof_prb * SRSLTE_NRE], q->lse[l]); + srsran_dmrs_pdcch_extract(q, cinit, &sf_symbols[l * q->carrier.nof_prb * SRSRAN_NRE], q->lse[l]); } // Time averaging and smoothing should be implemented here @@ -365,39 +365,39 @@ int srslte_dmrs_pdcch_estimate(srslte_dmrs_pdcch_estimator_t* q, cf_t tmp[NOF_PILOTS_X_FREQ_RES]; // Smoothing filter group - srslte_conv_same_cf(&q->lse[l][j * group_size], q->filter, tmp, group_size, q->filter_len); + srsran_conv_same_cf(&q->lse[l][j * group_size], q->filter, tmp, group_size, q->filter_len); - srslte_interp_linear_offset( - &q->interpolator, tmp, &q->ce[SRSLTE_NRE * q->coreset_bw * l + j * group_size * 4], 1, 3); + srsran_interp_linear_offset( + &q->interpolator, tmp, &q->ce[SRSRAN_NRE * q->coreset_bw * l + j * group_size * 4], 1, 3); } } #else for (uint32_t l = 0; l < q->coreset.duration; l++) { - srslte_interp_linear_offset(&q->interpolator, q->lse[l], &q->ce[SRSLTE_NRE * q->coreset_bw * l], 1, 3); + srsran_interp_linear_offset(&q->interpolator, q->lse[l], &q->ce[SRSRAN_NRE * q->coreset_bw * l], 1, 3); } #endif - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_dmrs_pdcch_get_measure(const srslte_dmrs_pdcch_estimator_t* q, - const srslte_dci_location_t* dci_location, - srslte_dmrs_pdcch_measure_t* measure) +int srsran_dmrs_pdcch_get_measure(const srsran_dmrs_pdcch_estimator_t* q, + const srsran_dci_location_t* dci_location, + srsran_dmrs_pdcch_measure_t* measure) { if (q == NULL || dci_location == NULL || measure == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } uint32_t L = 1U << dci_location->L; - if (q->coreset.mapping_type == srslte_coreset_mapping_type_interleaved) { + if (q->coreset.mapping_type == srsran_coreset_mapping_type_interleaved) { ERROR("Error interleaved mapping not implemented"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Check that CORESET duration is not less than minimum - if (q->coreset.duration < SRSLTE_CORESET_DURATION_MIN) { + if (q->coreset.duration < SRSRAN_CORESET_DURATION_MIN) { ERROR("Invalid CORESET duration"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Get base pilot; @@ -408,21 +408,21 @@ int srslte_dmrs_pdcch_get_measure(const srslte_dmrs_pdcch_estimator_t* q, float epre = 0.0f; float cfo = 0.0f; float sync_err = 0.0f; - cf_t corr[SRSLTE_CORESET_DURATION_MAX] = {}; + cf_t corr[SRSRAN_CORESET_DURATION_MAX] = {}; for (uint32_t l = 0; l < q->coreset.duration; l++) { - if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_INFO && !handler_registered) { + if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_INFO && !handler_registered) { DMRS_PDCCH_INFO_RX("Measuring PDCCH l=%d; lse=", l); - srslte_vec_fprint_c(stdout, &q->lse[l][pilot_idx], nof_pilots); + srsran_vec_fprint_c(stdout, &q->lse[l][pilot_idx], nof_pilots); } // Correlate DMRS - corr[l] = srslte_vec_acc_cc(&q->lse[l][pilot_idx], nof_pilots) / (float)nof_pilots; + corr[l] = srsran_vec_acc_cc(&q->lse[l][pilot_idx], nof_pilots) / (float)nof_pilots; // Measure symbol RSRP rsrp += __real__ corr[l] * __real__ corr[l] + __imag__ corr[l] * __imag__ corr[l]; // Measure symbol EPRE - epre += srslte_vec_avg_power_cf(&q->lse[l][pilot_idx], nof_pilots); + epre += srsran_vec_avg_power_cf(&q->lse[l][pilot_idx], nof_pilots); // Measure CFO only from the second and third symbols if (l != 0) { @@ -430,7 +430,7 @@ int srslte_dmrs_pdcch_get_measure(const srslte_dmrs_pdcch_estimator_t* q, } // Measure synchronization error - sync_err += srslte_vec_estimate_frequency(&q->lse[l][pilot_idx], nof_pilots); + sync_err += srsran_vec_estimate_frequency(&q->lse[l][pilot_idx], nof_pilots); } if (q->coreset.duration > 1) { @@ -444,10 +444,10 @@ int srslte_dmrs_pdcch_get_measure(const srslte_dmrs_pdcch_estimator_t* q, measure->epre = epre / (float)q->coreset.duration; measure->cfo_hz = cfo / (2.0f * (float)M_PI * Ts); measure->sync_error_us = - sync_err / (4.0e-6f * (float)q->coreset.duration * SRSLTE_SUBC_SPACING_NR(q->carrier.numerology)); + sync_err / (4.0e-6f * (float)q->coreset.duration * SRSRAN_SUBC_SPACING_NR(q->carrier.numerology)); - measure->rsrp_dBfs = srslte_convert_power_to_dB(measure->rsrp); - measure->epre_dBfs = srslte_convert_power_to_dB(measure->epre); + measure->rsrp_dBfs = srsran_convert_power_to_dB(measure->rsrp); + measure->epre_dBfs = srsran_convert_power_to_dB(measure->epre); if (isnormal(measure->rsrp) && isnormal(measure->epre)) { measure->norm_corr = measure->rsrp / measure->epre; @@ -462,45 +462,45 @@ int srslte_dmrs_pdcch_get_measure(const srslte_dmrs_pdcch_estimator_t* q, measure->epre_dBfs, measure->norm_corr); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_dmrs_pdcch_get_ce(const srslte_dmrs_pdcch_estimator_t* q, - const srslte_dci_location_t* dci_location, - srslte_dmrs_pdcch_ce_t* ce) +int srsran_dmrs_pdcch_get_ce(const srsran_dmrs_pdcch_estimator_t* q, + const srsran_dci_location_t* dci_location, + srsran_dmrs_pdcch_ce_t* ce) { if (q == NULL || dci_location == NULL || ce == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } uint32_t L = 1U << dci_location->L; - if (q->coreset.mapping_type == srslte_coreset_mapping_type_interleaved) { + if (q->coreset.mapping_type == srsran_coreset_mapping_type_interleaved) { ERROR("Error interleaved mapping not implemented"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Check that CORESET duration is not less than minimum - if (q->coreset.duration < SRSLTE_CORESET_DURATION_MIN) { + if (q->coreset.duration < SRSRAN_CORESET_DURATION_MIN) { ERROR("Invalid CORESET duration"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Calculate begin and end sub-carrier index for the selected candidate - uint32_t k_begin = (dci_location->ncce * SRSLTE_NRE * 6) / q->coreset.duration; - uint32_t k_end = k_begin + (L * 6 * SRSLTE_NRE) / q->coreset.duration; + uint32_t k_begin = (dci_location->ncce * SRSRAN_NRE * 6) / q->coreset.duration; + uint32_t k_end = k_begin + (L * 6 * SRSRAN_NRE) / q->coreset.duration; // Extract CE for PDCCH uint32_t count = 0; for (uint32_t l = 0; l < q->coreset.duration; l++) { for (uint32_t k = k_begin; k < k_end; k++) { if (k % 4 != 1) { - ce->ce[count++] = q->ce[q->coreset_bw * SRSLTE_NRE * l + k]; + ce->ce[count++] = q->ce[q->coreset_bw * SRSRAN_NRE * l + k]; } } } // Double check extracted RE match ideal count - ce->nof_re = (SRSLTE_NRE - 3) * 6 * L; + ce->nof_re = (SRSRAN_NRE - 3) * 6 * L; if (count != ce->nof_re) { ERROR("Incorrect number of extracted resources (%d != %d)", count, ce->nof_re); } @@ -508,5 +508,5 @@ int srslte_dmrs_pdcch_get_ce(const srslte_dmrs_pdcch_estimator_t* q, // At the moment Noise is not calculated ce->noise_var = 0.0f; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } diff --git a/lib/src/phy/ch_estimation/dmrs_pucch.c b/lib/src/phy/ch_estimation/dmrs_pucch.c index b53bee7a1..fd76e7a44 100644 --- a/lib/src/phy/ch_estimation/dmrs_pucch.c +++ b/lib/src/phy/ch_estimation/dmrs_pucch.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,13 +10,13 @@ * */ -#include "srslte/phy/ch_estimation/dmrs_pucch.h" -#include "srslte/phy/common/sequence.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/ch_estimation/dmrs_pucch.h" +#include "srsran/phy/common/sequence.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" // Implements TS 38.211 table 6.4.1.3.1.1-1: Number of DM-RS symbols and the corresponding N_PUCCH... -static uint32_t dmrs_pucch_format1_n_pucch(const srslte_pucch_nr_resource_t* resource, uint32_t m_prime) +static uint32_t dmrs_pucch_format1_n_pucch(const srsran_pucch_nr_resource_t* resource, uint32_t m_prime) { if (resource->intra_slot_hopping) { if (m_prime == 0) { @@ -85,34 +85,34 @@ static uint32_t dmrs_pucch_format1_n_pucch(const srslte_pucch_nr_resource_t* res return 0; } -int srslte_dmrs_pucch_format1_put(const srslte_pucch_nr_t* q, - const srslte_carrier_nr_t* carrier, - const srslte_pucch_nr_common_cfg_t* cfg, - const srslte_slot_cfg_t* slot, - const srslte_pucch_nr_resource_t* resource, +int srsran_dmrs_pucch_format1_put(const srsran_pucch_nr_t* q, + const srsran_carrier_nr_t* carrier, + const srsran_pucch_nr_common_cfg_t* cfg, + const srsran_slot_cfg_t* slot, + const srsran_pucch_nr_resource_t* resource, cf_t* slot_symbols) { if (q == NULL || carrier == NULL || cfg == NULL || slot == NULL || resource == NULL || slot_symbols == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } - if (srslte_pucch_nr_cfg_resource_valid(resource) < SRSLTE_SUCCESS) { + if (srsran_pucch_nr_cfg_resource_valid(resource) < SRSRAN_SUCCESS) { ERROR("Invalid PUCCH format 1 resource"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Get group sequence uint32_t u = 0; uint32_t v = 0; - if (srslte_pucch_nr_group_sequence(carrier, cfg, &u, &v) < SRSLTE_SUCCESS) { + if (srsran_pucch_nr_group_sequence(carrier, cfg, &u, &v) < SRSRAN_SUCCESS) { ERROR("Error getting group sequence"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } uint32_t n_pucch = dmrs_pucch_format1_n_pucch(resource, 0); if (n_pucch == 0) { ERROR("Error getting number of symbols"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } uint32_t l_prime = resource->start_symbol_idx; @@ -121,69 +121,69 @@ int srslte_dmrs_pucch_format1_put(const srslte_pucch_nr_t* q, uint32_t l = m * 2; // Get start of the sequence in resource grid - cf_t* slot_symbols_ptr = &slot_symbols[(carrier->nof_prb * (l + l_prime) + resource->starting_prb) * SRSLTE_NRE]; + cf_t* slot_symbols_ptr = &slot_symbols[(carrier->nof_prb * (l + l_prime) + resource->starting_prb) * SRSRAN_NRE]; // Get Alpha index uint32_t alpha_idx = 0; - if (srslte_pucch_nr_alpha_idx(carrier, cfg, slot, l, l_prime, resource->initial_cyclic_shift, 0, &alpha_idx) < - SRSLTE_SUCCESS) { + if (srsran_pucch_nr_alpha_idx(carrier, cfg, slot, l, l_prime, resource->initial_cyclic_shift, 0, &alpha_idx) < + SRSRAN_SUCCESS) { ERROR("Calculating alpha"); } // get r_uv sequence from LUT object - const cf_t* r_uv = srslte_zc_sequence_lut_get(&q->r_uv_1prb, u, v, alpha_idx); + const cf_t* r_uv = srsran_zc_sequence_lut_get(&q->r_uv_1prb, u, v, alpha_idx); if (r_uv == NULL) { ERROR("Getting r_uv sequence"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Get w_i_m - cf_t w_i_m = srslte_pucch_nr_format1_w(q, n_pucch, resource->time_domain_occ, m); + cf_t w_i_m = srsran_pucch_nr_format1_w(q, n_pucch, resource->time_domain_occ, m); // Compute z(n) = w(i) * r_uv(n) - cf_t z[SRSLTE_NRE]; - srslte_vec_sc_prod_ccc(r_uv, w_i_m, z, SRSLTE_NRE); + cf_t z[SRSRAN_NRE]; + srsran_vec_sc_prod_ccc(r_uv, w_i_m, z, SRSRAN_NRE); // Put z in the grid - srslte_vec_cf_copy(slot_symbols_ptr, z, SRSLTE_NRE); + srsran_vec_cf_copy(slot_symbols_ptr, z, SRSRAN_NRE); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_dmrs_pucch_format1_estimate(const srslte_pucch_nr_t* q, - const srslte_carrier_nr_t* carrier, - const srslte_pucch_nr_common_cfg_t* cfg, - const srslte_slot_cfg_t* slot, - const srslte_pucch_nr_resource_t* resource, +int srsran_dmrs_pucch_format1_estimate(const srsran_pucch_nr_t* q, + const srsran_carrier_nr_t* carrier, + const srsran_pucch_nr_common_cfg_t* cfg, + const srsran_slot_cfg_t* slot, + const srsran_pucch_nr_resource_t* resource, const cf_t* slot_symbols, - srslte_chest_ul_res_t* res) + srsran_chest_ul_res_t* res) { if (q == NULL || carrier == NULL || cfg == NULL || slot == NULL || resource == NULL || slot_symbols == NULL || res == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } - if (srslte_pucch_nr_cfg_resource_valid(resource) < SRSLTE_SUCCESS) { + if (srsran_pucch_nr_cfg_resource_valid(resource) < SRSRAN_SUCCESS) { ERROR("Invalid PUCCH format 1 resource"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Get group sequence uint32_t u = 0; uint32_t v = 0; - if (srslte_pucch_nr_group_sequence(carrier, cfg, &u, &v) < SRSLTE_SUCCESS) { + if (srsran_pucch_nr_group_sequence(carrier, cfg, &u, &v) < SRSRAN_SUCCESS) { ERROR("Error getting group sequence"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } uint32_t n_pucch = dmrs_pucch_format1_n_pucch(resource, 0); if (n_pucch == 0) { ERROR("Error getting number of symbols"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - cf_t ce[SRSLTE_PUCCH_NR_FORMAT1_N_MAX][SRSLTE_NRE]; + cf_t ce[SRSRAN_PUCCH_NR_FORMAT1_N_MAX][SRSRAN_NRE]; uint32_t l_prime = resource->start_symbol_idx; for (uint32_t m = 0; m < n_pucch; m++) { // Clause 6.4.1.3.1.2 specifies l=0,2,4... @@ -191,31 +191,31 @@ int srslte_dmrs_pucch_format1_estimate(const srslte_pucch_nr_t* q, // Get start of the sequence in resource grid const cf_t* slot_symbols_ptr = - &slot_symbols[(carrier->nof_prb * (l + l_prime) + resource->starting_prb) * SRSLTE_NRE]; + &slot_symbols[(carrier->nof_prb * (l + l_prime) + resource->starting_prb) * SRSRAN_NRE]; // Get Alpha index uint32_t alpha_idx = 0; - if (srslte_pucch_nr_alpha_idx(carrier, cfg, slot, l, l_prime, resource->initial_cyclic_shift, 0, &alpha_idx) < - SRSLTE_SUCCESS) { + if (srsran_pucch_nr_alpha_idx(carrier, cfg, slot, l, l_prime, resource->initial_cyclic_shift, 0, &alpha_idx) < + SRSRAN_SUCCESS) { ERROR("Calculating alpha"); } // get r_uv sequence from LUT object - const cf_t* r_uv = srslte_zc_sequence_lut_get(&q->r_uv_1prb, u, v, alpha_idx); + const cf_t* r_uv = srsran_zc_sequence_lut_get(&q->r_uv_1prb, u, v, alpha_idx); if (r_uv == NULL) { ERROR("Getting r_uv sequence"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Get w_i_m - cf_t w_i_m = srslte_pucch_nr_format1_w(q, n_pucch, resource->time_domain_occ, m); + cf_t w_i_m = srsran_pucch_nr_format1_w(q, n_pucch, resource->time_domain_occ, m); // Compute z(n) = w(i) * r_uv(n) - cf_t z[SRSLTE_NRE]; - srslte_vec_sc_prod_ccc(r_uv, w_i_m, z, SRSLTE_NRE); + cf_t z[SRSRAN_NRE]; + srsran_vec_sc_prod_ccc(r_uv, w_i_m, z, SRSRAN_NRE); // Calculate least square estimates for this symbol - srslte_vec_prod_conj_ccc(slot_symbols_ptr, z, ce[m], SRSLTE_NRE); + srsran_vec_prod_conj_ccc(slot_symbols_ptr, z, ce[m], SRSRAN_NRE); } // Perform measurements @@ -223,10 +223,10 @@ int srslte_dmrs_pucch_format1_estimate(const srslte_pucch_nr_t* q, float epre = 0.0f; float ta_err = 0.0f; for (uint32_t m = 0; m < n_pucch; m++) { - cf_t corr = srslte_vec_acc_cc(ce[m], SRSLTE_NRE) / SRSLTE_NRE; + cf_t corr = srsran_vec_acc_cc(ce[m], SRSRAN_NRE) / SRSRAN_NRE; rsrp += __real__ corr * __real__ corr + __imag__ corr * __imag__ corr; - epre += srslte_vec_avg_power_cf(ce[m], SRSLTE_NRE); - ta_err += srslte_vec_estimate_frequency(ce[m], SRSLTE_NRE); + epre += srsran_vec_avg_power_cf(ce[m], SRSRAN_NRE); + ta_err += srsran_vec_estimate_frequency(ce[m], SRSRAN_NRE); } // Average measurements @@ -235,15 +235,15 @@ int srslte_dmrs_pucch_format1_estimate(const srslte_pucch_nr_t* q, ta_err /= n_pucch; // Set power measures - rsrp = SRSLTE_MIN(rsrp, epre); + rsrp = SRSRAN_MIN(rsrp, epre); res->rsrp = rsrp; - res->rsrp_dBfs = srslte_convert_power_to_dB(rsrp); + res->rsrp_dBfs = srsran_convert_power_to_dB(rsrp); res->epre = epre; - res->epre_dBfs = srslte_convert_power_to_dB(epre); + res->epre_dBfs = srsran_convert_power_to_dB(epre); res->noise_estimate = epre - rsrp; - res->noise_estimate_dbm = srslte_convert_power_to_dB(res->noise_estimate); + res->noise_estimate_dbm = srsran_convert_power_to_dB(res->noise_estimate); res->snr = rsrp / res->noise_estimate; - res->snr_db = srslte_convert_power_to_dB(res->snr); + res->snr_db = srsran_convert_power_to_dB(res->snr); // Compute Time Aligment error in microseconds if (isnormal(ta_err)) { @@ -264,122 +264,122 @@ int srslte_dmrs_pucch_format1_estimate(const srslte_pucch_nr_t* q, // Interpolates between DMRS symbols for (uint32_t m = 0; m < n_pucch; m++) { uint32_t l = m * 2 + 1; - cf_t* ce_ptr = &res->ce[(carrier->nof_prb * (l + l_prime) + resource->starting_prb) * SRSLTE_NRE]; + cf_t* ce_ptr = &res->ce[(carrier->nof_prb * (l + l_prime) + resource->starting_prb) * SRSRAN_NRE]; if (m != n_pucch - 1) { // If it is not the last symbol with DMRS, average between - srslte_vec_sum_ccc(ce[m], ce[m + 1], ce_ptr, SRSLTE_NRE); - srslte_vec_sc_prod_cfc(ce_ptr, 0.5f, ce_ptr, SRSLTE_NRE); + srsran_vec_sum_ccc(ce[m], ce[m + 1], ce_ptr, SRSRAN_NRE); + srsran_vec_sc_prod_cfc(ce_ptr, 0.5f, ce_ptr, SRSRAN_NRE); } else if (m != 0) { // Extrapolate for the last if more than 1 are provided - srslte_vec_sc_prod_cfc(ce[m], 3.0f, ce_ptr, SRSLTE_NRE); - srslte_vec_sub_ccc(ce_ptr, ce[m - 1], ce_ptr, SRSLTE_NRE); - srslte_vec_sc_prod_cfc(ce_ptr, 0.5f, ce_ptr, SRSLTE_NRE); + srsran_vec_sc_prod_cfc(ce[m], 3.0f, ce_ptr, SRSRAN_NRE); + srsran_vec_sub_ccc(ce_ptr, ce[m - 1], ce_ptr, SRSRAN_NRE); + srsran_vec_sc_prod_cfc(ce_ptr, 0.5f, ce_ptr, SRSRAN_NRE); } else { // Simply copy the - srslte_vec_cf_copy(ce_ptr, ce[m], SRSLTE_NRE); + srsran_vec_cf_copy(ce_ptr, ce[m], SRSRAN_NRE); } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -static uint32_t dmrs_pucch_format2_cinit(const srslte_carrier_nr_t* carrier, - const srslte_pucch_nr_common_cfg_t* cfg, - const srslte_slot_cfg_t* slot, +static uint32_t dmrs_pucch_format2_cinit(const srsran_carrier_nr_t* carrier, + const srsran_pucch_nr_common_cfg_t* cfg, + const srsran_slot_cfg_t* slot, uint32_t l) { - uint64_t n = SRSLTE_SLOT_NR_MOD(carrier->numerology, slot->idx); + uint64_t n = SRSRAN_SLOT_NR_MOD(carrier->numerology, slot->idx); uint64_t n_id = (cfg->scrambling_id_present) ? cfg->scambling_id : carrier->id; - return SRSLTE_SEQUENCE_MOD((((SRSLTE_NSYMB_PER_SLOT_NR * n + l + 1UL) * (2UL * n_id + 1UL)) << 17UL) + 2UL * n_id); + return SRSRAN_SEQUENCE_MOD((((SRSRAN_NSYMB_PER_SLOT_NR * n + l + 1UL) * (2UL * n_id + 1UL)) << 17UL) + 2UL * n_id); } -int srslte_dmrs_pucch_format2_put(const srslte_pucch_nr_t* q, - const srslte_carrier_nr_t* carrier, - const srslte_pucch_nr_common_cfg_t* cfg, - const srslte_slot_cfg_t* slot, - const srslte_pucch_nr_resource_t* resource, +int srsran_dmrs_pucch_format2_put(const srsran_pucch_nr_t* q, + const srsran_carrier_nr_t* carrier, + const srsran_pucch_nr_common_cfg_t* cfg, + const srsran_slot_cfg_t* slot, + const srsran_pucch_nr_resource_t* resource, cf_t* slot_symbols) { if (q == NULL || carrier == NULL || cfg == NULL || slot == NULL || resource == NULL || slot_symbols == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } - if (srslte_pucch_nr_cfg_resource_valid(resource) < SRSLTE_SUCCESS) { + if (srsran_pucch_nr_cfg_resource_valid(resource) < SRSRAN_SUCCESS) { ERROR("Invalid PUCCH format 1 resource"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } uint32_t l_start = resource->start_symbol_idx; uint32_t l_end = resource->start_symbol_idx + resource->nof_symbols; - uint32_t k_start = SRSLTE_MIN(carrier->nof_prb - 1, resource->starting_prb) * SRSLTE_NRE + 1; - uint32_t k_end = SRSLTE_MIN(carrier->nof_prb, resource->starting_prb + resource->nof_prb) * SRSLTE_NRE; + uint32_t k_start = SRSRAN_MIN(carrier->nof_prb - 1, resource->starting_prb) * SRSRAN_NRE + 1; + uint32_t k_end = SRSRAN_MIN(carrier->nof_prb, resource->starting_prb + resource->nof_prb) * SRSRAN_NRE; for (uint32_t l = l_start; l < l_end; l++) { // Compute sequence initial state uint32_t cinit = dmrs_pucch_format2_cinit(carrier, cfg, slot, l); - srslte_sequence_state_t sequence = {}; - srslte_sequence_state_init(&sequence, cinit); + srsran_sequence_state_t sequence = {}; + srsran_sequence_state_init(&sequence, cinit); // Skip PRBs to start - srslte_sequence_state_advance(&sequence, 2 * 4 * resource->starting_prb); + srsran_sequence_state_advance(&sequence, 2 * 4 * resource->starting_prb); // Generate sequence - cf_t r_l[SRSLTE_PUCCH_NR_FORMAT2_MAX_NPRB * 4]; - srslte_sequence_state_gen_f(&sequence, M_SQRT1_2, (float*)r_l, 2 * 4 * resource->nof_prb); + cf_t r_l[SRSRAN_PUCCH_NR_FORMAT2_MAX_NPRB * 4]; + srsran_sequence_state_gen_f(&sequence, M_SQRT1_2, (float*)r_l, 2 * 4 * resource->nof_prb); // Put sequence in k = 3 * m + 1 for (uint32_t k = k_start, i = 0; k < k_end; k += 3, i++) { - slot_symbols[l * carrier->nof_prb * SRSLTE_NRE + k] = r_l[i]; + slot_symbols[l * carrier->nof_prb * SRSRAN_NRE + k] = r_l[i]; } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_dmrs_pucch_format2_estimate(const srslte_pucch_nr_t* q, - const srslte_carrier_nr_t* carrier, - const srslte_pucch_nr_common_cfg_t* cfg, - const srslte_slot_cfg_t* slot, - const srslte_pucch_nr_resource_t* resource, +int srsran_dmrs_pucch_format2_estimate(const srsran_pucch_nr_t* q, + const srsran_carrier_nr_t* carrier, + const srsran_pucch_nr_common_cfg_t* cfg, + const srsran_slot_cfg_t* slot, + const srsran_pucch_nr_resource_t* resource, const cf_t* slot_symbols, - srslte_chest_ul_res_t* res) + srsran_chest_ul_res_t* res) { if (q == NULL || carrier == NULL || cfg == NULL || slot == NULL || resource == NULL || slot_symbols == NULL || res == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } - if (srslte_pucch_nr_cfg_resource_valid(resource) < SRSLTE_SUCCESS) { + if (srsran_pucch_nr_cfg_resource_valid(resource) < SRSRAN_SUCCESS) { ERROR("Invalid PUCCH format 1 resource"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - cf_t ce[SRSLTE_PUCCH_NR_FORMAT2_MAX_NSYMB][SRSLTE_PUCCH_NR_FORMAT2_MAX_NPRB * 4]; + cf_t ce[SRSRAN_PUCCH_NR_FORMAT2_MAX_NSYMB][SRSRAN_PUCCH_NR_FORMAT2_MAX_NPRB * 4]; uint32_t l_start = resource->start_symbol_idx; uint32_t l_end = resource->start_symbol_idx + resource->nof_symbols; - uint32_t k_start = SRSLTE_MIN(carrier->nof_prb - 1, resource->starting_prb) * SRSLTE_NRE + 1; - uint32_t k_end = SRSLTE_MIN(carrier->nof_prb, resource->starting_prb + resource->nof_prb) * SRSLTE_NRE; + uint32_t k_start = SRSRAN_MIN(carrier->nof_prb - 1, resource->starting_prb) * SRSRAN_NRE + 1; + uint32_t k_end = SRSRAN_MIN(carrier->nof_prb, resource->starting_prb + resource->nof_prb) * SRSRAN_NRE; uint32_t nof_ref = 4 * resource->nof_prb; for (uint32_t l = l_start, j = 0; l < l_end; l++, j++) { // Compute sequence initial state uint32_t cinit = dmrs_pucch_format2_cinit(carrier, cfg, slot, l); - srslte_sequence_state_t sequence = {}; - srslte_sequence_state_init(&sequence, cinit); + srsran_sequence_state_t sequence = {}; + srsran_sequence_state_init(&sequence, cinit); // Skip PRBs to start - srslte_sequence_state_advance(&sequence, 2 * 4 * resource->starting_prb); + srsran_sequence_state_advance(&sequence, 2 * 4 * resource->starting_prb); // Generate sequence - cf_t r_l[SRSLTE_PUCCH_NR_FORMAT2_MAX_NPRB * 4]; - srslte_sequence_state_gen_f(&sequence, M_SQRT1_2, (float*)r_l, 2 * nof_ref); + cf_t r_l[SRSRAN_PUCCH_NR_FORMAT2_MAX_NPRB * 4]; + srsran_sequence_state_gen_f(&sequence, M_SQRT1_2, (float*)r_l, 2 * nof_ref); // Put sequence in k = 3 * m + 1 for (uint32_t k = k_start, i = 0; k < k_end; k += 3, i++) { - ce[j][i] = slot_symbols[l * carrier->nof_prb * SRSLTE_NRE + k]; + ce[j][i] = slot_symbols[l * carrier->nof_prb * SRSRAN_NRE + k]; } - srslte_vec_prod_conj_ccc(ce[j], r_l, ce[j], nof_ref); + srsran_vec_prod_conj_ccc(ce[j], r_l, ce[j], nof_ref); } // Perform measurements @@ -387,25 +387,25 @@ int srslte_dmrs_pucch_format2_estimate(const srslte_pucch_nr_t* q, float rsrp = 0.0f; float ta_err = 0.0f; for (uint32_t i = 0; i < resource->nof_symbols; i++) { - cf_t corr = srslte_vec_acc_cc(ce[i], nof_ref) / nof_ref; + cf_t corr = srsran_vec_acc_cc(ce[i], nof_ref) / nof_ref; rsrp += __real__ corr * __real__ corr + __imag__ corr * __imag__ corr; - epre += srslte_vec_avg_power_cf(ce[i], nof_ref); - ta_err += srslte_vec_estimate_frequency(ce[i], nof_ref); + epre += srsran_vec_avg_power_cf(ce[i], nof_ref); + ta_err += srsran_vec_estimate_frequency(ce[i], nof_ref); } epre /= resource->nof_symbols; rsrp /= resource->nof_symbols; ta_err /= resource->nof_symbols; // Set power measures - rsrp = SRSLTE_MIN(rsrp, epre); + rsrp = SRSRAN_MIN(rsrp, epre); res->rsrp = rsrp; - res->rsrp_dBfs = srslte_convert_power_to_dB(rsrp); + res->rsrp_dBfs = srsran_convert_power_to_dB(rsrp); res->epre = epre; - res->epre_dBfs = srslte_convert_power_to_dB(epre); + res->epre_dBfs = srsran_convert_power_to_dB(epre); res->noise_estimate = epre - rsrp; - res->noise_estimate_dbm = srslte_convert_power_to_dB(res->noise_estimate); + res->noise_estimate_dbm = srsran_convert_power_to_dB(res->noise_estimate); res->snr = rsrp / res->noise_estimate; - res->snr_db = srslte_convert_power_to_dB(res->snr); + res->snr_db = srsran_convert_power_to_dB(res->snr); // Compute Time Aligment error in microseconds if (isnormal(ta_err)) { @@ -423,18 +423,18 @@ int srslte_dmrs_pucch_format2_estimate(const srslte_pucch_nr_t* q, // Zero order hold for (uint32_t l = l_start, j = 0; l < l_end; l++, j++) { for (uint32_t k = k_start - 1, i = 0; k < k_end; k++, i++) { - res->ce[l * carrier->nof_prb * SRSLTE_NRE + k] = ce[j][i / 3]; + res->ce[l * carrier->nof_prb * SRSRAN_NRE + k] = ce[j][i / 3]; } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_dmrs_pucch_format_3_4_get_symbol_idx(const srslte_pucch_nr_resource_t* resource, - uint32_t idx[SRSLTE_DMRS_PUCCH_FORMAT_3_4_MAX_NSYMB]) +int srsran_dmrs_pucch_format_3_4_get_symbol_idx(const srsran_pucch_nr_resource_t* resource, + uint32_t idx[SRSRAN_DMRS_PUCCH_FORMAT_3_4_MAX_NSYMB]) { if (resource == NULL || idx == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } int count = 0; @@ -522,7 +522,7 @@ int srslte_dmrs_pucch_format_3_4_get_symbol_idx(const srslte_pucch_nr_resource_t break; default: ERROR("Invalid case (%d)", resource->nof_symbols); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } return count; diff --git a/lib/src/phy/ch_estimation/dmrs_sch.c b/lib/src/phy/ch_estimation/dmrs_sch.c index f30b273cc..5114b14c3 100644 --- a/lib/src/phy/ch_estimation/dmrs_sch.c +++ b/lib/src/phy/ch_estimation/dmrs_sch.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,31 +10,31 @@ * */ -#include "srslte/phy/ch_estimation/dmrs_sch.h" -#include "srslte/phy/common/sequence.h" +#include "srsran/phy/ch_estimation/dmrs_sch.h" +#include "srsran/phy/common/sequence.h" #include -#include +#include -#define SRSLTE_DMRS_SCH_TYPEA_SINGLE_DURATION_MIN 3 -#define SRSLTE_DMRS_SCH_TYPEA_DOUBLE_DURATION_MIN 4 +#define SRSRAN_DMRS_SCH_TYPEA_SINGLE_DURATION_MIN 3 +#define SRSRAN_DMRS_SCH_TYPEA_DOUBLE_DURATION_MIN 4 -int srslte_dmrs_sch_cfg_to_str(const srslte_dmrs_sch_cfg_t* cfg, char* msg, uint32_t max_len) +int srsran_dmrs_sch_cfg_to_str(const srsran_dmrs_sch_cfg_t* cfg, char* msg, uint32_t max_len) { int type = (int)cfg->type + 1; int typeA_pos = (int)cfg->typeA_pos + 2; - int additional_pos = cfg->additional_pos == srslte_dmrs_sch_add_pos_0 + int additional_pos = cfg->additional_pos == srsran_dmrs_sch_add_pos_0 ? 0 - : cfg->additional_pos == srslte_dmrs_sch_add_pos_1 + : cfg->additional_pos == srsran_dmrs_sch_add_pos_1 ? 1 - : cfg->additional_pos == srslte_dmrs_sch_add_pos_2 ? 2 : 3; - const char* len = cfg->length == srslte_dmrs_sch_len_1 ? "single" : "double"; + : cfg->additional_pos == srsran_dmrs_sch_add_pos_2 ? 2 : 3; + const char* len = cfg->length == srsran_dmrs_sch_len_1 ? "single" : "double"; - return srslte_print_check( + return srsran_print_check( msg, max_len, 0, "type=%d, typeA_pos=%d, add_pos=%d, len=%s", type, typeA_pos, additional_pos, len); } static uint32_t -srslte_dmrs_get_pilots_type1(uint32_t start_prb, uint32_t nof_prb, uint32_t delta, const cf_t* symbols, cf_t* pilots) +srsran_dmrs_get_pilots_type1(uint32_t start_prb, uint32_t nof_prb, uint32_t delta, const cf_t* symbols, cf_t* pilots) { uint32_t count = 0; uint32_t n_begin = start_prb * 3; @@ -50,7 +50,7 @@ srslte_dmrs_get_pilots_type1(uint32_t start_prb, uint32_t nof_prb, uint32_t delt } static uint32_t -srslte_dmrs_get_pilots_type2(uint32_t start_prb, uint32_t nof_prb, uint32_t delta, const cf_t* symbols, cf_t* pilots) +srsran_dmrs_get_pilots_type2(uint32_t start_prb, uint32_t nof_prb, uint32_t delta, const cf_t* symbols, cf_t* pilots) { uint32_t count = 0; uint32_t n_begin = start_prb * 2; @@ -65,9 +65,9 @@ srslte_dmrs_get_pilots_type2(uint32_t start_prb, uint32_t nof_prb, uint32_t delt return count; } -static uint32_t srslte_dmrs_get_lse(srslte_dmrs_sch_t* q, - srslte_sequence_state_t* sequence_state, - srslte_dmrs_sch_type_t dmrs_type, +static uint32_t srsran_dmrs_get_lse(srsran_dmrs_sch_t* q, + srsran_sequence_state_t* sequence_state, + srsran_dmrs_sch_type_t dmrs_type, uint32_t start_prb, uint32_t nof_prb, uint32_t delta, @@ -78,27 +78,27 @@ static uint32_t srslte_dmrs_get_lse(srslte_dmrs_sch_t* q, uint32_t count = 0; switch (dmrs_type) { - case srslte_dmrs_sch_type_1: - count = srslte_dmrs_get_pilots_type1(start_prb, nof_prb, delta, symbols, least_square_estimates); + case srsran_dmrs_sch_type_1: + count = srsran_dmrs_get_pilots_type1(start_prb, nof_prb, delta, symbols, least_square_estimates); break; - case srslte_dmrs_sch_type_2: - count = srslte_dmrs_get_pilots_type2(start_prb, nof_prb, delta, symbols, least_square_estimates); + case srsran_dmrs_sch_type_2: + count = srsran_dmrs_get_pilots_type2(start_prb, nof_prb, delta, symbols, least_square_estimates); break; default: ERROR("Unknown DMRS type."); } // Generate sequence for the given pilots - srslte_sequence_state_gen_f(sequence_state, amplitude, (float*)q->temp, count * 2); + srsran_sequence_state_gen_f(sequence_state, amplitude, (float*)q->temp, count * 2); // Calculate least square estimates - srslte_vec_prod_conj_ccc(least_square_estimates, q->temp, least_square_estimates, count); + srsran_vec_prod_conj_ccc(least_square_estimates, q->temp, least_square_estimates, count); return count; } static uint32_t -srslte_dmrs_put_pilots_type1(uint32_t start_prb, uint32_t nof_prb, uint32_t delta, cf_t* symbols, const cf_t* pilots) +srsran_dmrs_put_pilots_type1(uint32_t start_prb, uint32_t nof_prb, uint32_t delta, cf_t* symbols, const cf_t* pilots) { uint32_t count = 0; uint32_t n_begin = start_prb * 3; @@ -114,7 +114,7 @@ srslte_dmrs_put_pilots_type1(uint32_t start_prb, uint32_t nof_prb, uint32_t delt } static uint32_t -srslte_dmrs_put_pilots_type2(uint32_t start_prb, uint32_t nof_prb, uint32_t delta, cf_t* symbols, const cf_t* pilots) +srsran_dmrs_put_pilots_type2(uint32_t start_prb, uint32_t nof_prb, uint32_t delta, cf_t* symbols, const cf_t* pilots) { uint32_t count = 0; uint32_t n_begin = start_prb * 2; @@ -129,26 +129,26 @@ srslte_dmrs_put_pilots_type2(uint32_t start_prb, uint32_t nof_prb, uint32_t delt return count; } -static uint32_t srslte_dmrs_put_pilots(srslte_dmrs_sch_t* q, - srslte_sequence_state_t* sequence_state, - srslte_dmrs_sch_type_t dmrs_type, +static uint32_t srsran_dmrs_put_pilots(srsran_dmrs_sch_t* q, + srsran_sequence_state_t* sequence_state, + srsran_dmrs_sch_type_t dmrs_type, uint32_t start_prb, uint32_t nof_prb, uint32_t delta, float amplitude, cf_t* symbols) { - uint32_t count = (dmrs_type == srslte_dmrs_sch_type_1) ? nof_prb * 6 : nof_prb * 4; + uint32_t count = (dmrs_type == srsran_dmrs_sch_type_1) ? nof_prb * 6 : nof_prb * 4; // Generate sequence for the given pilots - srslte_sequence_state_gen_f(sequence_state, amplitude, (float*)q->temp, count * 2); + srsran_sequence_state_gen_f(sequence_state, amplitude, (float*)q->temp, count * 2); switch (dmrs_type) { - case srslte_dmrs_sch_type_1: - count = srslte_dmrs_put_pilots_type1(start_prb, nof_prb, delta, symbols, q->temp); + case srsran_dmrs_sch_type_1: + count = srsran_dmrs_put_pilots_type1(start_prb, nof_prb, delta, symbols, q->temp); break; - case srslte_dmrs_sch_type_2: - count = srslte_dmrs_put_pilots_type2(start_prb, nof_prb, delta, symbols, q->temp); + case srsran_dmrs_sch_type_2: + count = srsran_dmrs_put_pilots_type2(start_prb, nof_prb, delta, symbols, q->temp); break; default: ERROR("Unknown DMRS type."); @@ -157,9 +157,9 @@ static uint32_t srslte_dmrs_put_pilots(srslte_dmrs_sch_t* q, return count; } -static int srslte_dmrs_sch_put_symbol(srslte_dmrs_sch_t* q, - const srslte_sch_cfg_nr_t* pdsch_cfg, - const srslte_sch_grant_nr_t* grant, +static int srsran_dmrs_sch_put_symbol(srsran_dmrs_sch_t* q, + const srsran_sch_cfg_nr_t* pdsch_cfg, + const srsran_sch_grant_nr_t* grant, uint32_t cinit, uint32_t delta, cf_t* symbols) @@ -170,16 +170,16 @@ static int srslte_dmrs_sch_put_symbol(srslte_dmrs_sch_t* q, amplitude *= grant->beta_dmrs; } - const srslte_dmrs_sch_cfg_t* dmrs_cfg = &pdsch_cfg->dmrs; + const srsran_dmrs_sch_cfg_t* dmrs_cfg = &pdsch_cfg->dmrs; uint32_t prb_count = 0; // Counts consecutive used PRB uint32_t prb_start = 0; // Start consecutive used PRB uint32_t prb_skip = 0; // Number of PRB to skip - uint32_t nof_pilots_x_prb = dmrs_cfg->type == srslte_dmrs_sch_type_1 ? 6 : 4; + uint32_t nof_pilots_x_prb = dmrs_cfg->type == srsran_dmrs_sch_type_1 ? 6 : 4; uint32_t pilot_count = 0; // Initialise sequence - srslte_sequence_state_t sequence_state = {}; - srslte_sequence_state_init(&sequence_state, cinit); + srsran_sequence_state_t sequence_state = {}; + srsran_sequence_state_init(&sequence_state, cinit); // Iterate over PRBs for (uint32_t prb_idx = 0; prb_idx < q->carrier.nof_prb; prb_idx++) { @@ -191,7 +191,7 @@ static int srslte_dmrs_sch_put_symbol(srslte_dmrs_sch_t* q, prb_start = prb_idx; // ... discard unused pilots and reset counter - srslte_sequence_state_advance(&sequence_state, prb_skip * nof_pilots_x_prb * 2); + srsran_sequence_state_advance(&sequence_state, prb_skip * nof_pilots_x_prb * 2); prb_skip = 0; } prb_count++; @@ -209,7 +209,7 @@ static int srslte_dmrs_sch_put_symbol(srslte_dmrs_sch_t* q, // Get contiguous pilots pilot_count += - srslte_dmrs_put_pilots(q, &sequence_state, dmrs_cfg->type, prb_start, prb_count, delta, amplitude, symbols); + srsran_dmrs_put_pilots(q, &sequence_state, dmrs_cfg->type, prb_start, prb_count, delta, amplitude, symbols); // Reset counter prb_count = 0; @@ -217,26 +217,26 @@ static int srslte_dmrs_sch_put_symbol(srslte_dmrs_sch_t* q, if (prb_count > 0) { pilot_count += - srslte_dmrs_put_pilots(q, &sequence_state, dmrs_cfg->type, prb_start, prb_count, delta, amplitude, symbols); + srsran_dmrs_put_pilots(q, &sequence_state, dmrs_cfg->type, prb_start, prb_count, delta, amplitude, symbols); } return pilot_count; } // Implements 3GPP 38.211 R.15 Table 7.4.1.1.2-3 PDSCH mapping type A Single -static int srslte_dmrs_sch_get_symbols_idx_mapping_type_A_single(const srslte_dmrs_sch_cfg_t* dmrs_cfg, +static int srsran_dmrs_sch_get_symbols_idx_mapping_type_A_single(const srsran_dmrs_sch_cfg_t* dmrs_cfg, uint32_t ld, - uint32_t symbols[SRSLTE_DMRS_SCH_MAX_SYMBOLS]) + uint32_t symbols[SRSRAN_DMRS_SCH_MAX_SYMBOLS]) { int count = 0; - if (ld < SRSLTE_DMRS_SCH_TYPEA_SINGLE_DURATION_MIN) { + if (ld < SRSRAN_DMRS_SCH_TYPEA_SINGLE_DURATION_MIN) { ERROR("Duration is below the minimum"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // l0 = 3 if the higher-layer parameter dmrs-TypeA-Position is equal to 'pos3' and l0 = 2 otherwise - int l0 = (dmrs_cfg->typeA_pos == srslte_dmrs_sch_typeA_pos_3) ? 3 : 2; + int l0 = (dmrs_cfg->typeA_pos == srsran_dmrs_sch_typeA_pos_3) ? 3 : 2; // For PDSCH mapping Type A single-symbol DM-RS, l1 = 11 except if all of the following conditions are fulfilled in // which case l1 = 12: @@ -244,15 +244,15 @@ static int srslte_dmrs_sch_get_symbols_idx_mapping_type_A_single(const srslte_dm // - the higher-layer parameters dmrs-AdditionalPosition is equal to 'pos1' and l0 = 3; and // - the UE has indicated it is capable of additionalDMRS-DL-Alt int l1 = 11; - if (dmrs_cfg->lte_CRS_to_match_around && dmrs_cfg->additional_pos == srslte_dmrs_sch_add_pos_1 && - dmrs_cfg->typeA_pos == srslte_dmrs_sch_typeA_pos_3 && dmrs_cfg->additional_DMRS_DL_Alt) { + if (dmrs_cfg->lte_CRS_to_match_around && dmrs_cfg->additional_pos == srsran_dmrs_sch_add_pos_1 && + dmrs_cfg->typeA_pos == srsran_dmrs_sch_typeA_pos_3 && dmrs_cfg->additional_DMRS_DL_Alt) { l1 = 12; } symbols[count] = l0; count++; - if (ld < 8 || dmrs_cfg->additional_pos == srslte_dmrs_sch_add_pos_0) { + if (ld < 8 || dmrs_cfg->additional_pos == srsran_dmrs_sch_add_pos_0) { return count; } @@ -260,7 +260,7 @@ static int srslte_dmrs_sch_get_symbols_idx_mapping_type_A_single(const srslte_dm symbols[count] = 7; count++; } else if (ld < 12) { - if (dmrs_cfg->additional_pos > srslte_dmrs_sch_add_pos_2) { + if (dmrs_cfg->additional_pos > srsran_dmrs_sch_add_pos_2) { symbols[count] = 6; count++; } @@ -270,11 +270,11 @@ static int srslte_dmrs_sch_get_symbols_idx_mapping_type_A_single(const srslte_dm } else if (ld == 12) { switch (dmrs_cfg->additional_pos) { - case srslte_dmrs_sch_add_pos_1: + case srsran_dmrs_sch_add_pos_1: symbols[count] = 9; count++; break; - case srslte_dmrs_sch_add_pos_2: + case srsran_dmrs_sch_add_pos_2: symbols[count] = 6; count++; symbols[count] = 9; @@ -290,11 +290,11 @@ static int srslte_dmrs_sch_get_symbols_idx_mapping_type_A_single(const srslte_dm } } else { switch (dmrs_cfg->additional_pos) { - case srslte_dmrs_sch_add_pos_1: + case srsran_dmrs_sch_add_pos_1: symbols[count] = l1; count++; break; - case srslte_dmrs_sch_add_pos_2: + case srsran_dmrs_sch_add_pos_2: symbols[count] = 7; count++; symbols[count] = 11; @@ -314,31 +314,31 @@ static int srslte_dmrs_sch_get_symbols_idx_mapping_type_A_single(const srslte_dm } // Implements 3GPP 38.211 R.15 Table 7.4.1.1.2-4 PDSCH mapping type A Double -static int srslte_dmrs_sch_get_symbols_idx_mapping_type_A_double(const srslte_dmrs_sch_cfg_t* dmrs_cfg, +static int srsran_dmrs_sch_get_symbols_idx_mapping_type_A_double(const srsran_dmrs_sch_cfg_t* dmrs_cfg, uint32_t ld, - uint32_t symbols[SRSLTE_DMRS_SCH_MAX_SYMBOLS]) + uint32_t symbols[SRSRAN_DMRS_SCH_MAX_SYMBOLS]) { int count = 0; - if (ld < SRSLTE_DMRS_SCH_TYPEA_DOUBLE_DURATION_MIN) { - return SRSLTE_ERROR; + if (ld < SRSRAN_DMRS_SCH_TYPEA_DOUBLE_DURATION_MIN) { + return SRSRAN_ERROR; } // According to Table 7.4.1.1.2-4, the additional position 3 is invalid. - if (dmrs_cfg->additional_pos == srslte_dmrs_sch_add_pos_3) { + if (dmrs_cfg->additional_pos == srsran_dmrs_sch_add_pos_3) { ERROR("Invalid additional DMRS (%d)", dmrs_cfg->additional_pos); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // l0 = 3 if the higher-layer parameter dmrs-TypeA-Position is equal to 'pos3' and l0 = 2 otherwise - int l0 = (dmrs_cfg->typeA_pos == srslte_dmrs_sch_typeA_pos_3) ? 3 : 2; + int l0 = (dmrs_cfg->typeA_pos == srsran_dmrs_sch_typeA_pos_3) ? 3 : 2; symbols[count] = l0; count++; symbols[count] = symbols[count - 1] + 1; count++; - if (ld < 10 || dmrs_cfg->additional_pos == srslte_dmrs_sch_add_pos_0) { + if (ld < 10 || dmrs_cfg->additional_pos == srsran_dmrs_sch_add_pos_0) { return count; } @@ -357,54 +357,54 @@ static int srslte_dmrs_sch_get_symbols_idx_mapping_type_A_double(const srslte_dm return count; } -int srslte_dmrs_sch_get_symbols_idx(const srslte_dmrs_sch_cfg_t* dmrs_cfg, - const srslte_sch_grant_nr_t* grant, - uint32_t symbols[SRSLTE_DMRS_SCH_MAX_SYMBOLS]) +int srsran_dmrs_sch_get_symbols_idx(const srsran_dmrs_sch_cfg_t* dmrs_cfg, + const srsran_sch_grant_nr_t* grant, + uint32_t symbols[SRSRAN_DMRS_SCH_MAX_SYMBOLS]) { // The position(s) of the DM-RS symbols is given by l and duration ld where // - for PDSCH mapping type A, ld is the duration between the first OFDM symbol of the slot and the last OFDM symbol // of the scheduled PDSCH resources in the slot // - for PDSCH mapping type B, ld is the duration of the scheduled PDSCH resources uint32_t ld = grant->L; - if (grant->mapping == srslte_sch_mapping_type_A) { + if (grant->mapping == srsran_sch_mapping_type_A) { ld = grant->S + grant->L; } switch (grant->mapping) { - case srslte_sch_mapping_type_A: + case srsran_sch_mapping_type_A: // The case dmrs-AdditionalPosition equals to 'pos3' is only supported when dmrs-TypeA-Position is equal to 'pos2' - if (dmrs_cfg->typeA_pos != srslte_dmrs_sch_typeA_pos_2 && dmrs_cfg->additional_pos == srslte_dmrs_sch_add_pos_3) { + if (dmrs_cfg->typeA_pos != srsran_dmrs_sch_typeA_pos_2 && dmrs_cfg->additional_pos == srsran_dmrs_sch_add_pos_3) { ERROR("The case dmrs-AdditionalPosition equals to 'pos3' is only supported when dmrs-TypeA-Position is equal " "to 'pos2'"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // For PDSCH mapping type A, ld = 3 and ld = 4 symbols in Tables 7.4.1.1.2-3 and 7.4.1.1.2-4 respectively is only // applicable when dmrs-TypeA-Position is equal to 'pos2 - if ((ld == 3 || ld == 4) && dmrs_cfg->typeA_pos != srslte_dmrs_sch_typeA_pos_2) { + if ((ld == 3 || ld == 4) && dmrs_cfg->typeA_pos != srsran_dmrs_sch_typeA_pos_2) { ERROR("For PDSCH mapping type A, ld = 3 and ld = 4 symbols in Tables 7.4.1.1.2-3 and 7.4.1.1.2-4 respectively " "is only applicable when dmrs-TypeA-Position is equal to 'pos2"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (dmrs_cfg->length == srslte_dmrs_sch_len_1) { - return srslte_dmrs_sch_get_symbols_idx_mapping_type_A_single(dmrs_cfg, ld, symbols); + if (dmrs_cfg->length == srsran_dmrs_sch_len_1) { + return srsran_dmrs_sch_get_symbols_idx_mapping_type_A_single(dmrs_cfg, ld, symbols); } - return srslte_dmrs_sch_get_symbols_idx_mapping_type_A_double(dmrs_cfg, ld, symbols); - case srslte_sch_mapping_type_B: + return srsran_dmrs_sch_get_symbols_idx_mapping_type_A_double(dmrs_cfg, ld, symbols); + case srsran_sch_mapping_type_B: ERROR("Error PDSCH mapping type B not supported"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_ERROR; + return SRSRAN_ERROR; } -int srslte_dmrs_sch_get_sc_idx(const srslte_dmrs_sch_cfg_t* cfg, uint32_t max_count, uint32_t* sc_idx) +int srsran_dmrs_sch_get_sc_idx(const srsran_dmrs_sch_cfg_t* cfg, uint32_t max_count, uint32_t* sc_idx) { int count = 0; uint32_t delta = 0; - if (cfg->type == srslte_dmrs_sch_type_1) { + if (cfg->type == srsran_dmrs_sch_type_1) { for (uint32_t n = 0; count < max_count; n += 4) { for (uint32_t k_prime = 0; k_prime < 2 && count < max_count; k_prime++) { sc_idx[count++] = n + 2 * k_prime + delta; @@ -421,35 +421,35 @@ int srslte_dmrs_sch_get_sc_idx(const srslte_dmrs_sch_cfg_t* cfg, uint32_t max_co return count; } -int srslte_dmrs_sch_get_N_prb(const srslte_dmrs_sch_cfg_t* dmrs_cfg, const srslte_sch_grant_nr_t* grant) +int srsran_dmrs_sch_get_N_prb(const srsran_dmrs_sch_cfg_t* dmrs_cfg, const srsran_sch_grant_nr_t* grant) { if (grant->nof_dmrs_cdm_groups_without_data < 1 || grant->nof_dmrs_cdm_groups_without_data > 3) { ERROR("Invalid number if DMRS CDM groups without data (%d). Valid values: 1, 2 , 3", grant->nof_dmrs_cdm_groups_without_data); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Get number of frequency domain resource elements used for DMRS - int nof_sc = SRSLTE_DMRS_SCH_SC(grant->nof_dmrs_cdm_groups_without_data, dmrs_cfg->type); + int nof_sc = SRSRAN_DMRS_SCH_SC(grant->nof_dmrs_cdm_groups_without_data, dmrs_cfg->type); // Get number of symbols used for DMRS - uint32_t symbols[SRSLTE_DMRS_SCH_MAX_SYMBOLS] = {}; - int ret = srslte_dmrs_sch_get_symbols_idx(dmrs_cfg, grant, symbols); - if (ret < SRSLTE_SUCCESS) { + uint32_t symbols[SRSRAN_DMRS_SCH_MAX_SYMBOLS] = {}; + int ret = srsran_dmrs_sch_get_symbols_idx(dmrs_cfg, grant, symbols); + if (ret < SRSRAN_SUCCESS) { ERROR("Error getting PDSCH DMRS symbol indexes"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } return nof_sc * ret; } -static uint32_t srslte_dmrs_sch_seed(const srslte_carrier_nr_t* carrier, - const srslte_sch_cfg_nr_t* cfg, - const srslte_sch_grant_nr_t* grant, +static uint32_t srsran_dmrs_sch_seed(const srsran_carrier_nr_t* carrier, + const srsran_sch_cfg_nr_t* cfg, + const srsran_sch_grant_nr_t* grant, uint32_t slot_idx, uint32_t symbol_idx) { - const srslte_dmrs_sch_cfg_t* dmrs_cfg = &cfg->dmrs; + const srsran_dmrs_sch_cfg_t* dmrs_cfg = &cfg->dmrs; // Calculate scrambling IDs uint32_t n_id = carrier->id; @@ -462,31 +462,31 @@ static uint32_t srslte_dmrs_sch_seed(const srslte_carrier_nr_t* carrier, n_id = dmrs_cfg->scrambling_id1; } - return SRSLTE_SEQUENCE_MOD((((SRSLTE_NSYMB_PER_SLOT_NR * slot_idx + symbol_idx + 1UL) * (2UL * n_id + 1UL)) << 17UL) + + return SRSRAN_SEQUENCE_MOD((((SRSRAN_NSYMB_PER_SLOT_NR * slot_idx + symbol_idx + 1UL) * (2UL * n_id + 1UL)) << 17UL) + (2UL * n_id + n_scid)); } -int srslte_dmrs_sch_init(srslte_dmrs_sch_t* q, bool is_rx) +int srsran_dmrs_sch_init(srsran_dmrs_sch_t* q, bool is_rx) { if (q == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } if (is_rx) { q->is_rx = true; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -void srslte_dmrs_sch_free(srslte_dmrs_sch_t* q) +void srsran_dmrs_sch_free(srsran_dmrs_sch_t* q) { if (q == NULL) { return; } - srslte_interp_linear_free(&q->interpolator_type1); - srslte_interp_linear_free(&q->interpolator_type2); + srsran_interp_linear_free(&q->interpolator_type1); + srsran_interp_linear_free(&q->interpolator_type2); if (q->pilot_estimates) { free(q->pilot_estimates); } @@ -494,16 +494,16 @@ void srslte_dmrs_sch_free(srslte_dmrs_sch_t* q) free(q->temp); } - SRSLTE_MEM_ZERO(q, srslte_dmrs_sch_t, 1); + SRSRAN_MEM_ZERO(q, srsran_dmrs_sch_t, 1); } -int srslte_dmrs_sch_set_carrier(srslte_dmrs_sch_t* q, const srslte_carrier_nr_t* carrier) +int srsran_dmrs_sch_set_carrier(srsran_dmrs_sch_t* q, const srsran_carrier_nr_t* carrier) { bool max_nof_prb_changed = q->max_nof_prb < carrier->nof_prb; // Set carrier and update maximum number of PRB q->carrier = *carrier; - q->max_nof_prb = SRSLTE_MAX(q->max_nof_prb, carrier->nof_prb); + q->max_nof_prb = SRSRAN_MAX(q->max_nof_prb, carrier->nof_prb); // Resize/allocate temp for gNb and UE if (max_nof_prb_changed) { @@ -511,28 +511,28 @@ int srslte_dmrs_sch_set_carrier(srslte_dmrs_sch_t* q, const srslte_carrier_nr_t* free(q->temp); } - q->temp = srslte_vec_cf_malloc(q->max_nof_prb * SRSLTE_NRE); + q->temp = srsran_vec_cf_malloc(q->max_nof_prb * SRSRAN_NRE); if (!q->temp) { ERROR("malloc"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } // If it is not UE, quit now if (!q->is_rx) { - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } if (max_nof_prb_changed) { // Resize interpolator only if the number of PRB has increased - srslte_interp_linear_free(&q->interpolator_type1); - srslte_interp_linear_free(&q->interpolator_type2); + srsran_interp_linear_free(&q->interpolator_type1); + srsran_interp_linear_free(&q->interpolator_type2); - if (srslte_interp_linear_init(&q->interpolator_type1, carrier->nof_prb * SRSLTE_NRE / 2, 2) != SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (srsran_interp_linear_init(&q->interpolator_type1, carrier->nof_prb * SRSRAN_NRE / 2, 2) != SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } - if (srslte_interp_linear_init(&q->interpolator_type2, carrier->nof_prb * SRSLTE_NRE / 3, 6) != SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (srsran_interp_linear_init(&q->interpolator_type2, carrier->nof_prb * SRSRAN_NRE / 3, 6) != SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } if (q->pilot_estimates) { @@ -540,52 +540,52 @@ int srslte_dmrs_sch_set_carrier(srslte_dmrs_sch_t* q, const srslte_carrier_nr_t* } // The maximum number of pilots is for Type 1 - q->pilot_estimates = srslte_vec_cf_malloc(SRSLTE_DMRS_SCH_MAX_SYMBOLS * q->max_nof_prb * SRSLTE_NRE / 2); + q->pilot_estimates = srsran_vec_cf_malloc(SRSRAN_DMRS_SCH_MAX_SYMBOLS * q->max_nof_prb * SRSRAN_NRE / 2); if (!q->pilot_estimates) { ERROR("malloc"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_dmrs_sch_put_sf(srslte_dmrs_sch_t* q, - const srslte_slot_cfg_t* slot_cfg, - const srslte_sch_cfg_nr_t* pdsch_cfg, - const srslte_sch_grant_nr_t* grant, +int srsran_dmrs_sch_put_sf(srsran_dmrs_sch_t* q, + const srsran_slot_cfg_t* slot_cfg, + const srsran_sch_cfg_nr_t* pdsch_cfg, + const srsran_sch_grant_nr_t* grant, cf_t* sf_symbols) { uint32_t delta = 0; if (q == NULL || slot_cfg == NULL || pdsch_cfg == NULL || sf_symbols == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } - uint32_t symbol_sz = q->carrier.nof_prb * SRSLTE_NRE; // Symbol size in resource elements + uint32_t symbol_sz = q->carrier.nof_prb * SRSRAN_NRE; // Symbol size in resource elements // Get symbols indexes - uint32_t symbols[SRSLTE_DMRS_SCH_MAX_SYMBOLS] = {}; - int nof_symbols = srslte_dmrs_sch_get_symbols_idx(&pdsch_cfg->dmrs, grant, symbols); - if (nof_symbols < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + uint32_t symbols[SRSRAN_DMRS_SCH_MAX_SYMBOLS] = {}; + int nof_symbols = srsran_dmrs_sch_get_symbols_idx(&pdsch_cfg->dmrs, grant, symbols); + if (nof_symbols < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } // Iterate symbols for (uint32_t i = 0; i < nof_symbols; i++) { uint32_t l = symbols[i]; // Symbol index inside the slot - uint32_t slot_idx = SRSLTE_SLOT_NR_MOD(q->carrier.numerology, slot_cfg->idx); // Slot index in the frame - uint32_t cinit = srslte_dmrs_sch_seed(&q->carrier, pdsch_cfg, grant, slot_idx, l); + uint32_t slot_idx = SRSRAN_SLOT_NR_MOD(q->carrier.numerology, slot_cfg->idx); // Slot index in the frame + uint32_t cinit = srsran_dmrs_sch_seed(&q->carrier, pdsch_cfg, grant, slot_idx, l); - srslte_dmrs_sch_put_symbol(q, pdsch_cfg, grant, cinit, delta, &sf_symbols[symbol_sz * l]); + srsran_dmrs_sch_put_symbol(q, pdsch_cfg, grant, cinit, delta, &sf_symbols[symbol_sz * l]); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -static int srslte_dmrs_sch_get_symbol(srslte_dmrs_sch_t* q, - const srslte_sch_cfg_nr_t* pdsch_cfg, - const srslte_sch_grant_nr_t* grant, +static int srsran_dmrs_sch_get_symbol(srsran_dmrs_sch_t* q, + const srsran_sch_cfg_nr_t* pdsch_cfg, + const srsran_sch_grant_nr_t* grant, uint32_t cinit, uint32_t delta, const cf_t* symbols, @@ -597,17 +597,17 @@ static int srslte_dmrs_sch_get_symbol(srslte_dmrs_sch_t* q, amplitude /= grant->beta_dmrs; } - const srslte_dmrs_sch_cfg_t* dmrs_cfg = &pdsch_cfg->dmrs; + const srsran_dmrs_sch_cfg_t* dmrs_cfg = &pdsch_cfg->dmrs; uint32_t prb_count = 0; // Counts consecutive used PRB uint32_t prb_start = 0; // Start consecutive used PRB uint32_t prb_skip = 0; // Number of PRB to skip - uint32_t nof_pilots_x_prb = dmrs_cfg->type == srslte_dmrs_sch_type_1 ? 6 : 4; + uint32_t nof_pilots_x_prb = dmrs_cfg->type == srsran_dmrs_sch_type_1 ? 6 : 4; uint32_t pilot_count = 0; // Initialise sequence - srslte_sequence_state_t sequence_state = {}; - srslte_sequence_state_init(&sequence_state, cinit); + srsran_sequence_state_t sequence_state = {}; + srsran_sequence_state_init(&sequence_state, cinit); // Iterate over PRBs for (uint32_t prb_idx = 0; prb_idx < q->carrier.nof_prb; prb_idx++) { @@ -619,7 +619,7 @@ static int srslte_dmrs_sch_get_symbol(srslte_dmrs_sch_t* q, prb_start = prb_idx; // ... discard unused pilots and reset counter - srslte_sequence_state_advance(&sequence_state, prb_skip * nof_pilots_x_prb * 2); + srsran_sequence_state_advance(&sequence_state, prb_skip * nof_pilots_x_prb * 2); prb_skip = 0; } prb_count++; @@ -636,7 +636,7 @@ static int srslte_dmrs_sch_get_symbol(srslte_dmrs_sch_t* q, } // Get contiguous pilots - pilot_count += srslte_dmrs_get_lse(q, + pilot_count += srsran_dmrs_get_lse(q, &sequence_state, dmrs_cfg->type, prb_start, @@ -651,7 +651,7 @@ static int srslte_dmrs_sch_get_symbol(srslte_dmrs_sch_t* q, } if (prb_count > 0) { - pilot_count += srslte_dmrs_get_lse(q, + pilot_count += srsran_dmrs_get_lse(q, &sequence_state, dmrs_cfg->type, prb_start, @@ -665,30 +665,30 @@ static int srslte_dmrs_sch_get_symbol(srslte_dmrs_sch_t* q, return pilot_count; } -int srslte_dmrs_sch_estimate(srslte_dmrs_sch_t* q, - const srslte_slot_cfg_t* slot_cfg, - const srslte_sch_cfg_nr_t* pdsch_cfg, - const srslte_sch_grant_nr_t* grant, +int srsran_dmrs_sch_estimate(srsran_dmrs_sch_t* q, + const srsran_slot_cfg_t* slot_cfg, + const srsran_sch_cfg_nr_t* pdsch_cfg, + const srsran_sch_grant_nr_t* grant, const cf_t* sf_symbols, - srslte_chest_dl_res_t* chest_res) + srsran_chest_dl_res_t* chest_res) { const uint32_t delta = 0; if (q == NULL || slot_cfg == NULL || sf_symbols == NULL || chest_res == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } - const srslte_dmrs_sch_cfg_t* dmrs_cfg = &pdsch_cfg->dmrs; + const srsran_dmrs_sch_cfg_t* dmrs_cfg = &pdsch_cfg->dmrs; cf_t* ce = q->temp; - uint32_t symbol_sz = q->carrier.nof_prb * SRSLTE_NRE; // Symbol size in resource elements + uint32_t symbol_sz = q->carrier.nof_prb * SRSRAN_NRE; // Symbol size in resource elements // Get symbols indexes - uint32_t symbols[SRSLTE_DMRS_SCH_MAX_SYMBOLS] = {}; - int nof_symbols = srslte_dmrs_sch_get_symbols_idx(&pdsch_cfg->dmrs, grant, symbols); - if (nof_symbols <= SRSLTE_SUCCESS) { + uint32_t symbols[SRSRAN_DMRS_SCH_MAX_SYMBOLS] = {}; + int nof_symbols = srsran_dmrs_sch_get_symbols_idx(&pdsch_cfg->dmrs, grant, symbols); + if (nof_symbols <= SRSRAN_SUCCESS) { ERROR("Error getting symbol indexes"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } uint32_t nof_pilots_x_symbol = 0; @@ -697,44 +697,44 @@ int srslte_dmrs_sch_estimate(srslte_dmrs_sch_t* q, for (uint32_t i = 0; i < nof_symbols; i++) { uint32_t l = symbols[i]; // Symbol index inside the slot - uint32_t cinit = srslte_dmrs_sch_seed( - &q->carrier, pdsch_cfg, grant, SRSLTE_SLOT_NR_MOD(q->carrier.numerology, slot_cfg->idx), l); + uint32_t cinit = srsran_dmrs_sch_seed( + &q->carrier, pdsch_cfg, grant, SRSRAN_SLOT_NR_MOD(q->carrier.numerology, slot_cfg->idx), l); - nof_pilots_x_symbol = srslte_dmrs_sch_get_symbol( + nof_pilots_x_symbol = srsran_dmrs_sch_get_symbol( q, pdsch_cfg, grant, cinit, delta, &sf_symbols[symbol_sz * l], &q->pilot_estimates[nof_pilots_x_symbol * i]); if (nof_pilots_x_symbol == 0) { ERROR("Error, no pilots extracted (i=%d, l=%d)", i, l); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } // Perform Power measurements float rsrp = 0.0f; float epre = 0.0f; - cf_t corr[SRSLTE_DMRS_SCH_MAX_SYMBOLS] = {}; + cf_t corr[SRSRAN_DMRS_SCH_MAX_SYMBOLS] = {}; for (uint32_t i = 0; i < nof_symbols; i++) { corr[i] = - srslte_vec_acc_cc(&q->pilot_estimates[nof_pilots_x_symbol * i], nof_pilots_x_symbol) / nof_pilots_x_symbol; + srsran_vec_acc_cc(&q->pilot_estimates[nof_pilots_x_symbol * i], nof_pilots_x_symbol) / nof_pilots_x_symbol; rsrp += __real__ corr[i] * __real__ corr[i] + __imag__ corr[i] * __imag__ corr[i]; - epre += srslte_vec_avg_power_cf(&q->pilot_estimates[nof_pilots_x_symbol * i], nof_pilots_x_symbol); + epre += srsran_vec_avg_power_cf(&q->pilot_estimates[nof_pilots_x_symbol * i], nof_pilots_x_symbol); } rsrp /= nof_symbols; epre /= nof_symbols; - rsrp = SRSLTE_MIN(rsrp, epre - epre * 1e-7); + rsrp = SRSRAN_MIN(rsrp, epre - epre * 1e-7); chest_res->rsrp = rsrp; - chest_res->rsrp_dbm = srslte_convert_power_to_dB(chest_res->rsrp); + chest_res->rsrp_dbm = srsran_convert_power_to_dB(chest_res->rsrp); chest_res->noise_estimate = epre - rsrp; - chest_res->noise_estimate_dbm = srslte_convert_power_to_dB(chest_res->noise_estimate); + chest_res->noise_estimate_dbm = srsran_convert_power_to_dB(chest_res->noise_estimate); chest_res->snr_db = chest_res->rsrp_dbm - chest_res->noise_estimate_dbm; // Measure CFO if more than one symbol is used float cfo_avg = 0.0; for (uint32_t i = 0; i < nof_symbols - 1; i++) { - float time_diff = srslte_symbol_distance_s(symbols[i], symbols[i + 1], q->carrier.numerology); + float time_diff = srsran_symbol_distance_s(symbols[i], symbols[i + 1], q->carrier.numerology); float phase_diff = cargf(corr[i + 1] * conjf(corr[i])); if (isnormal(time_diff)) { @@ -745,35 +745,35 @@ int srslte_dmrs_sch_estimate(srslte_dmrs_sch_t* q, // Average over time, only if more than one DMRS symbol for (uint32_t i = 1; i < nof_symbols; i++) { - srslte_vec_sum_ccc( + srsran_vec_sum_ccc( q->pilot_estimates, &q->pilot_estimates[nof_pilots_x_symbol * i], q->pilot_estimates, nof_pilots_x_symbol); } if (nof_symbols > 0) { - srslte_vec_sc_prod_cfc(q->pilot_estimates, 1.0f / (float)nof_symbols, q->pilot_estimates, nof_pilots_x_symbol); + srsran_vec_sc_prod_cfc(q->pilot_estimates, 1.0f / (float)nof_symbols, q->pilot_estimates, nof_pilots_x_symbol); } // Frequency domain interpolate uint32_t nof_re_x_symbol = - (dmrs_cfg->type == srslte_dmrs_sch_type_1) ? nof_pilots_x_symbol * 2 : nof_pilots_x_symbol * 3; - if (dmrs_cfg->type == srslte_dmrs_sch_type_1) { + (dmrs_cfg->type == srsran_dmrs_sch_type_1) ? nof_pilots_x_symbol * 2 : nof_pilots_x_symbol * 3; + if (dmrs_cfg->type == srsran_dmrs_sch_type_1) { // Prepare interpolator - if (srslte_interp_linear_resize(&q->interpolator_type1, nof_pilots_x_symbol, 2) < SRSLTE_SUCCESS) { + if (srsran_interp_linear_resize(&q->interpolator_type1, nof_pilots_x_symbol, 2) < SRSRAN_SUCCESS) { ERROR("Resizing interpolator nof_pilots_x_symbol=%d; M=%d;", nof_pilots_x_symbol, 2); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Interpolate - srslte_interp_linear_offset(&q->interpolator_type1, q->pilot_estimates, ce, delta, 2 - delta); + srsran_interp_linear_offset(&q->interpolator_type1, q->pilot_estimates, ce, delta, 2 - delta); } else { // Prepare interpolator - if (srslte_interp_linear_resize(&q->interpolator_type2, nof_pilots_x_symbol, 3) < SRSLTE_SUCCESS) { + if (srsran_interp_linear_resize(&q->interpolator_type2, nof_pilots_x_symbol, 3) < SRSRAN_SUCCESS) { ERROR("Resizing interpolator nof_pilots_x_symbol=%d; M=%d;", nof_pilots_x_symbol, 3); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Interpolate - srslte_interp_linear_offset(&q->interpolator_type2, q->pilot_estimates, ce, delta, 3 - delta); + srsran_interp_linear_offset(&q->interpolator_type2, q->pilot_estimates, ce, delta, 3 - delta); } // Time domain hold, extract resource elements estimates for PDSCH @@ -786,7 +786,7 @@ int srslte_dmrs_sch_estimate(srslte_dmrs_sch_t* q, if (symbols[symbol_idx] == l) { switch (dmrs_cfg->type) { - case srslte_dmrs_sch_type_1: + case srsran_dmrs_sch_type_1: // Skip if there is no data to read if (grant->nof_dmrs_cdm_groups_without_data != 1) { continue; @@ -796,25 +796,25 @@ int srslte_dmrs_sch_estimate(srslte_dmrs_sch_t* q, count++; } break; - case srslte_dmrs_sch_type_2: + case srsran_dmrs_sch_type_2: // Skip if there is no data to read if (grant->nof_dmrs_cdm_groups_without_data != 1 && grant->nof_dmrs_cdm_groups_without_data != 2) { continue; } for (uint32_t i = grant->nof_dmrs_cdm_groups_without_data * 2; i < nof_re_x_symbol; i += 6) { uint32_t nof_re = (3 - grant->nof_dmrs_cdm_groups_without_data) * 2; - srslte_vec_cf_copy(&chest_res->ce[0][0][count], &ce[i], nof_re); + srsran_vec_cf_copy(&chest_res->ce[0][0][count], &ce[i], nof_re); count += nof_re; } break; } } else { - srslte_vec_cf_copy(&chest_res->ce[0][0][count], ce, nof_re_x_symbol); + srsran_vec_cf_copy(&chest_res->ce[0][0][count], ce, nof_re_x_symbol); count += nof_re_x_symbol; } } // Set other values in the estimation result chest_res->nof_re = count; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } diff --git a/lib/src/phy/ch_estimation/refsignal_dl.c b/lib/src/phy/ch_estimation/refsignal_dl.c index 124a8e9e7..559cfe7bd 100644 --- a/lib/src/phy/ch_estimation/refsignal_dl.c +++ b/lib/src/phy/ch_estimation/refsignal_dl.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,43 +10,43 @@ * */ -#include "srslte/srslte.h" +#include "srsran/srsran.h" #include #include #include #include #include -#include "srslte/phy/ch_estimation/refsignal_dl.h" -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/common/sequence.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/ch_estimation/refsignal_dl.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/common/sequence.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" /** Allocates memory for the 20 slots in a subframe */ -int srslte_refsignal_cs_init(srslte_refsignal_t* q, uint32_t max_prb) +int srsran_refsignal_cs_init(srsran_refsignal_t* q, uint32_t max_prb) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL) { - ret = SRSLTE_ERROR; - bzero(q, sizeof(srslte_refsignal_t)); + ret = SRSRAN_ERROR; + bzero(q, sizeof(srsran_refsignal_t)); for (int p = 0; p < 2; p++) { - for (int i = 0; i < SRSLTE_NOF_SF_X_FRAME; i++) { - q->pilots[p][i] = srslte_vec_cf_malloc(SRSLTE_REFSIGNAL_MAX_NUM_SF(max_prb)); + for (int i = 0; i < SRSRAN_NOF_SF_X_FRAME; i++) { + q->pilots[p][i] = srsran_vec_cf_malloc(SRSRAN_REFSIGNAL_MAX_NUM_SF(max_prb)); if (!q->pilots[p][i]) { perror("malloc"); goto free_and_exit; } } } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } free_and_exit: - if (ret == SRSLTE_ERROR) { - srslte_refsignal_free(q); + if (ret == SRSRAN_ERROR) { + srsran_refsignal_free(q); } return ret; } @@ -54,48 +54,48 @@ free_and_exit: /** Allocates and precomputes the Cell-Specific Reference (CSR) signal for * the 20 slots in a subframe */ -int srslte_refsignal_cs_set_cell(srslte_refsignal_t* q, srslte_cell_t cell) +int srsran_refsignal_cs_set_cell(srsran_refsignal_t* q, srsran_cell_t cell) { uint32_t c_init; uint32_t N_cp, mp; - srslte_sequence_t seq; - int ret = SRSLTE_ERROR_INVALID_INPUTS; + srsran_sequence_t seq; + int ret = SRSRAN_ERROR_INVALID_INPUTS; - if (q != NULL && srslte_cell_isvalid(&cell)) { + if (q != NULL && srsran_cell_isvalid(&cell)) { if (cell.id != q->cell.id || q->cell.nof_prb == 0) { q->cell = cell; - bzero(&seq, sizeof(srslte_sequence_t)); - if (srslte_sequence_init(&seq, 2 * 2 * SRSLTE_MAX_PRB)) { - return SRSLTE_ERROR; + bzero(&seq, sizeof(srsran_sequence_t)); + if (srsran_sequence_init(&seq, 2 * 2 * SRSRAN_MAX_PRB)) { + return SRSRAN_ERROR; } - if (SRSLTE_CP_ISNORM(cell.cp)) { + if (SRSRAN_CP_ISNORM(cell.cp)) { N_cp = 1; } else { N_cp = 0; } - srslte_dl_sf_cfg_t sf_cfg; + srsran_dl_sf_cfg_t sf_cfg; ZERO_OBJECT(sf_cfg); - for (uint32_t ns = 0; ns < SRSLTE_NSLOTS_X_FRAME; ns++) { + for (uint32_t ns = 0; ns < SRSRAN_NSLOTS_X_FRAME; ns++) { for (uint32_t p = 0; p < 2; p++) { sf_cfg.tti = ns / 2; - uint32_t nsymbols = srslte_refsignal_cs_nof_symbols(q, &sf_cfg, 2 * p) / 2; + uint32_t nsymbols = srsran_refsignal_cs_nof_symbols(q, &sf_cfg, 2 * p) / 2; for (uint32_t l = 0; l < nsymbols; l++) { /* Compute sequence init value */ - uint32_t lp = srslte_refsignal_cs_nsymbol(l, cell.cp, 2 * p); + uint32_t lp = srsran_refsignal_cs_nsymbol(l, cell.cp, 2 * p); c_init = 1024 * (7 * (ns + 1) + lp + 1) * (2 * cell.id + 1) + 2 * cell.id + N_cp; /* generate sequence for this symbol and slot */ - srslte_sequence_set_LTE_pr(&seq, 2 * 2 * SRSLTE_MAX_PRB, c_init); + srsran_sequence_set_LTE_pr(&seq, 2 * 2 * SRSRAN_MAX_PRB, c_init); /* Compute signal */ for (uint32_t i = 0; i < 2 * q->cell.nof_prb; i++) { - uint32_t idx = SRSLTE_REFSIGNAL_PILOT_IDX(i, (ns % 2) * nsymbols + l, q->cell); - mp = i + SRSLTE_MAX_PRB - cell.nof_prb; + uint32_t idx = SRSRAN_REFSIGNAL_PILOT_IDX(i, (ns % 2) * nsymbols + l, q->cell); + mp = i + SRSRAN_MAX_PRB - cell.nof_prb; /* save signal */ __real__ q->pilots[p][ns / 2][idx] = (1 - 2 * (float)seq.c[2 * mp + 0]) * M_SQRT1_2; __imag__ q->pilots[p][ns / 2][idx] = (1 - 2 * (float)seq.c[2 * mp + 1]) * M_SQRT1_2; @@ -103,27 +103,27 @@ int srslte_refsignal_cs_set_cell(srslte_refsignal_t* q, srslte_cell_t cell) } } } - srslte_sequence_free(&seq); + srsran_sequence_free(&seq); } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } -/** Deallocates a srslte_refsignal_cs_t object allocated with srslte_refsignal_cs_init */ -void srslte_refsignal_free(srslte_refsignal_t* q) +/** Deallocates a srsran_refsignal_cs_t object allocated with srsran_refsignal_cs_init */ +void srsran_refsignal_free(srsran_refsignal_t* q) { for (int p = 0; p < 2; p++) { - for (int i = 0; i < SRSLTE_NOF_SF_X_FRAME; i++) { + for (int i = 0; i < SRSRAN_NOF_SF_X_FRAME; i++) { if (q->pilots[p][i]) { free(q->pilots[p][i]); } } } - bzero(q, sizeof(srslte_refsignal_t)); + bzero(q, sizeof(srsran_refsignal_t)); } -uint32_t srslte_refsignal_cs_v(uint32_t port_id, uint32_t ref_symbol_idx) +uint32_t srsran_refsignal_cs_v(uint32_t port_id, uint32_t ref_symbol_idx) { uint32_t v = 0; switch (port_id) { @@ -159,18 +159,18 @@ uint32_t srslte_refsignal_cs_v(uint32_t port_id, uint32_t ref_symbol_idx) return v; } -inline uint32_t srslte_refsignal_cs_nof_symbols(srslte_refsignal_t* q, srslte_dl_sf_cfg_t* sf, uint32_t port_id) +inline uint32_t srsran_refsignal_cs_nof_symbols(srsran_refsignal_t* q, srsran_dl_sf_cfg_t* sf, uint32_t port_id) { - if (q == NULL || sf == NULL || q->cell.frame_type == SRSLTE_FDD || !sf->tdd_config.configured || - srslte_sfidx_tdd_type(sf->tdd_config, sf->tti % 10) == SRSLTE_TDD_SF_D) { + if (q == NULL || sf == NULL || q->cell.frame_type == SRSRAN_FDD || !sf->tdd_config.configured || + srsran_sfidx_tdd_type(sf->tdd_config, sf->tti % 10) == SRSRAN_TDD_SF_D) { if (port_id < 2) { return 4; } else { return 2; } } else { - uint32_t nof_dw_symbols = srslte_sfidx_tdd_nof_dw(sf->tdd_config); - if (q->cell.cp == SRSLTE_CP_NORM) { + uint32_t nof_dw_symbols = srsran_sfidx_tdd_nof_dw(sf->tdd_config); + if (q->cell.cp == SRSRAN_CP_NORM) { if (nof_dw_symbols >= 12) { if (port_id < 2) { return 4; @@ -218,7 +218,7 @@ inline uint32_t srslte_refsignal_cs_nof_symbols(srslte_refsignal_t* q, srslte_dl } } -inline uint32_t srslte_refsignal_cs_nof_pilots_x_slot(uint32_t nof_ports) +inline uint32_t srsran_refsignal_cs_nof_pilots_x_slot(uint32_t nof_ports) { switch (nof_ports) { case 2: @@ -230,59 +230,59 @@ inline uint32_t srslte_refsignal_cs_nof_pilots_x_slot(uint32_t nof_ports) } } -inline uint32_t srslte_refsignal_cs_nof_re(srslte_refsignal_t* q, srslte_dl_sf_cfg_t* sf, uint32_t port_id) +inline uint32_t srsran_refsignal_cs_nof_re(srsran_refsignal_t* q, srsran_dl_sf_cfg_t* sf, uint32_t port_id) { - uint32_t nof_re = srslte_refsignal_cs_nof_symbols(q, sf, port_id); + uint32_t nof_re = srsran_refsignal_cs_nof_symbols(q, sf, port_id); if (q != NULL) { nof_re *= q->cell.nof_prb * 2; // 2 RE per PRB } return nof_re; } -inline uint32_t srslte_refsignal_cs_fidx(srslte_cell_t cell, uint32_t l, uint32_t port_id, uint32_t m) +inline uint32_t srsran_refsignal_cs_fidx(srsran_cell_t cell, uint32_t l, uint32_t port_id, uint32_t m) { - return 6 * m + ((srslte_refsignal_cs_v(port_id, l) + (cell.id % 6)) % 6); + return 6 * m + ((srsran_refsignal_cs_v(port_id, l) + (cell.id % 6)) % 6); } -inline uint32_t srslte_refsignal_cs_nsymbol(uint32_t l, srslte_cp_t cp, uint32_t port_id) +inline uint32_t srsran_refsignal_cs_nsymbol(uint32_t l, srsran_cp_t cp, uint32_t port_id) { if (port_id < 2) { if (l % 2) { - return (l / 2 + 1) * SRSLTE_CP_NSYMB(cp) - 3; + return (l / 2 + 1) * SRSRAN_CP_NSYMB(cp) - 3; } else { - return (l / 2) * SRSLTE_CP_NSYMB(cp); + return (l / 2) * SRSRAN_CP_NSYMB(cp); } } else { - return 1 + l * SRSLTE_CP_NSYMB(cp); + return 1 + l * SRSRAN_CP_NSYMB(cp); } } -/* Maps a reference signal initialized with srslte_refsignal_cs_init() into an array of subframe symbols */ -int srslte_refsignal_cs_put_sf(srslte_refsignal_t* q, srslte_dl_sf_cfg_t* sf, uint32_t port_id, cf_t* sf_symbols) +/* Maps a reference signal initialized with srsran_refsignal_cs_init() into an array of subframe symbols */ +int srsran_refsignal_cs_put_sf(srsran_refsignal_t* q, srsran_dl_sf_cfg_t* sf, uint32_t port_id, cf_t* sf_symbols) { uint32_t i, l; uint32_t fidx; - if (q != NULL && port_id < SRSLTE_MAX_PORTS && sf_symbols != NULL) { + if (q != NULL && port_id < SRSRAN_MAX_PORTS && sf_symbols != NULL) { cf_t* pilots = q->pilots[port_id / 2][sf->tti % 10]; - for (l = 0; l < srslte_refsignal_cs_nof_symbols(q, sf, port_id); l++) { - uint32_t nsymbol = srslte_refsignal_cs_nsymbol(l, q->cell.cp, port_id); + for (l = 0; l < srsran_refsignal_cs_nof_symbols(q, sf, port_id); l++) { + uint32_t nsymbol = srsran_refsignal_cs_nsymbol(l, q->cell.cp, port_id); /* Compute offset frequency index */ - fidx = ((srslte_refsignal_cs_v(port_id, l) + (q->cell.id % 6)) % 6); + fidx = ((srsran_refsignal_cs_v(port_id, l) + (q->cell.id % 6)) % 6); for (i = 0; i < 2 * q->cell.nof_prb; i++) { - sf_symbols[SRSLTE_RE_IDX(q->cell.nof_prb, nsymbol, fidx)] = pilots[SRSLTE_REFSIGNAL_PILOT_IDX(i, l, q->cell)]; - fidx += SRSLTE_NRE / 2; // 1 reference every 6 RE + sf_symbols[SRSRAN_RE_IDX(q->cell.nof_prb, nsymbol, fidx)] = pilots[SRSRAN_REFSIGNAL_PILOT_IDX(i, l, q->cell)]; + fidx += SRSRAN_NRE / 2; // 1 reference every 6 RE } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } else { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } } /** Copies the RE containing references from an array of subframe symbols to the pilots array. */ -int srslte_refsignal_cs_get_sf(srslte_refsignal_t* q, - srslte_dl_sf_cfg_t* sf, +int srsran_refsignal_cs_get_sf(srsran_refsignal_t* q, + srsran_dl_sf_cfg_t* sf, uint32_t port_id, cf_t* sf_symbols, cf_t* pilots) @@ -291,22 +291,22 @@ int srslte_refsignal_cs_get_sf(srslte_refsignal_t* q, uint32_t fidx; if (q != NULL && pilots != NULL && sf_symbols != NULL) { - for (l = 0; l < srslte_refsignal_cs_nof_symbols(q, sf, port_id); l++) { - uint32_t nsymbol = srslte_refsignal_cs_nsymbol(l, q->cell.cp, port_id); + for (l = 0; l < srsran_refsignal_cs_nof_symbols(q, sf, port_id); l++) { + uint32_t nsymbol = srsran_refsignal_cs_nsymbol(l, q->cell.cp, port_id); /* Compute offset frequency index */ - fidx = srslte_refsignal_cs_fidx(q->cell, l, port_id, 0); + fidx = srsran_refsignal_cs_fidx(q->cell, l, port_id, 0); for (i = 0; i < 2 * q->cell.nof_prb; i++) { - pilots[SRSLTE_REFSIGNAL_PILOT_IDX(i, l, q->cell)] = sf_symbols[SRSLTE_RE_IDX(q->cell.nof_prb, nsymbol, fidx)]; - fidx += SRSLTE_NRE / 2; // 2 references per PRB + pilots[SRSRAN_REFSIGNAL_PILOT_IDX(i, l, q->cell)] = sf_symbols[SRSRAN_RE_IDX(q->cell.nof_prb, nsymbol, fidx)]; + fidx += SRSRAN_NRE / 2; // 2 references per PRB } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } else { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } } -SRSLTE_API int srslte_refsignal_mbsfn_put_sf(srslte_cell_t cell, +SRSRAN_API int srsran_refsignal_mbsfn_put_sf(srsran_cell_t cell, uint32_t port_id, cf_t* cs_pilots, cf_t* mbsfn_pilots, @@ -315,37 +315,37 @@ SRSLTE_API int srslte_refsignal_mbsfn_put_sf(srslte_cell_t cell, uint32_t i, l; uint32_t fidx; - if (srslte_cell_isvalid(&cell) && srslte_portid_isvalid(port_id) && cs_pilots != NULL && mbsfn_pilots != NULL && + if (srsran_cell_isvalid(&cell) && srsran_portid_isvalid(port_id) && cs_pilots != NULL && mbsfn_pilots != NULL && sf_symbols != NULL) { // adding CS refs for the non-mbsfn section of the sub-frame - fidx = ((srslte_refsignal_cs_v(port_id, 0) + (cell.id % 6)) % 6); + fidx = ((srsran_refsignal_cs_v(port_id, 0) + (cell.id % 6)) % 6); for (i = 0; i < 2 * cell.nof_prb; i++) { - sf_symbols[SRSLTE_RE_IDX(cell.nof_prb, 0, fidx)] = cs_pilots[SRSLTE_REFSIGNAL_PILOT_IDX(i, 0, cell)]; - fidx += SRSLTE_NRE / 2; // 1 reference every 6 RE + sf_symbols[SRSRAN_RE_IDX(cell.nof_prb, 0, fidx)] = cs_pilots[SRSRAN_REFSIGNAL_PILOT_IDX(i, 0, cell)]; + fidx += SRSRAN_NRE / 2; // 1 reference every 6 RE } - for (l = 0; l < srslte_refsignal_mbsfn_nof_symbols(); l++) { - uint32_t nsymbol = srslte_refsignal_mbsfn_nsymbol(l); - fidx = srslte_refsignal_mbsfn_fidx(l); + for (l = 0; l < srsran_refsignal_mbsfn_nof_symbols(); l++) { + uint32_t nsymbol = srsran_refsignal_mbsfn_nsymbol(l); + fidx = srsran_refsignal_mbsfn_fidx(l); for (i = 0; i < 6 * cell.nof_prb; i++) { - sf_symbols[SRSLTE_RE_IDX(cell.nof_prb, nsymbol, fidx)] = - mbsfn_pilots[SRSLTE_REFSIGNAL_PILOT_IDX_MBSFN(i, l, cell)]; - fidx += SRSLTE_NRE / 6; + sf_symbols[SRSRAN_RE_IDX(cell.nof_prb, nsymbol, fidx)] = + mbsfn_pilots[SRSRAN_REFSIGNAL_PILOT_IDX_MBSFN(i, l, cell)]; + fidx += SRSRAN_NRE / 6; } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } else { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } } -uint32_t srslte_refsignal_mbsfn_nof_symbols() +uint32_t srsran_refsignal_mbsfn_nof_symbols() { return 3; } -inline uint32_t srslte_refsignal_mbsfn_fidx(uint32_t l) +inline uint32_t srsran_refsignal_mbsfn_fidx(uint32_t l) { uint32_t ret = 0; @@ -359,7 +359,7 @@ inline uint32_t srslte_refsignal_mbsfn_fidx(uint32_t l) return ret; } -inline uint32_t srslte_refsignal_mbsfn_nsymbol(uint32_t l) +inline uint32_t srsran_refsignal_mbsfn_nsymbol(uint32_t l) { uint32_t ret = 0; if (l == 0) { @@ -373,30 +373,30 @@ inline uint32_t srslte_refsignal_mbsfn_nsymbol(uint32_t l) return ret; } -int srslte_refsignal_mbsfn_gen_seq(srslte_refsignal_t* q, srslte_cell_t cell, uint32_t N_mbsfn_id) +int srsran_refsignal_mbsfn_gen_seq(srsran_refsignal_t* q, srsran_cell_t cell, uint32_t N_mbsfn_id) { uint32_t c_init; uint32_t i, ns, l, p; uint32_t mp; - int ret = SRSLTE_ERROR; + int ret = SRSRAN_ERROR; - srslte_sequence_t seq_mbsfn; - bzero(&seq_mbsfn, sizeof(srslte_sequence_t)); - if (srslte_sequence_init(&seq_mbsfn, 20 * SRSLTE_MAX_PRB)) { + srsran_sequence_t seq_mbsfn; + bzero(&seq_mbsfn, sizeof(srsran_sequence_t)); + if (srsran_sequence_init(&seq_mbsfn, 20 * SRSRAN_MAX_PRB)) { goto free_and_exit; } - for (ns = 0; ns < SRSLTE_NOF_SF_X_FRAME; ns++) { + for (ns = 0; ns < SRSRAN_NOF_SF_X_FRAME; ns++) { for (p = 0; p < 2; p++) { uint32_t nsymbols = 3; // replace with function for (l = 0; l < nsymbols; l++) { - uint32_t lp = (srslte_refsignal_mbsfn_nsymbol(l)) % 6; + uint32_t lp = (srsran_refsignal_mbsfn_nsymbol(l)) % 6; uint32_t slot = (l) ? (ns * 2 + 1) : (ns * 2); c_init = 512 * (7 * (slot + 1) + lp + 1) * (2 * N_mbsfn_id + 1) + N_mbsfn_id; - srslte_sequence_set_LTE_pr(&seq_mbsfn, SRSLTE_MAX_PRB * 20, c_init); + srsran_sequence_set_LTE_pr(&seq_mbsfn, SRSRAN_MAX_PRB * 20, c_init); for (i = 0; i < 6 * q->cell.nof_prb; i++) { - uint32_t idx = SRSLTE_REFSIGNAL_PILOT_IDX_MBSFN(i, l, q->cell); - mp = i + 3 * (SRSLTE_MAX_PRB - cell.nof_prb); + uint32_t idx = SRSRAN_REFSIGNAL_PILOT_IDX_MBSFN(i, l, q->cell); + mp = i + 3 * (SRSRAN_MAX_PRB - cell.nof_prb); __real__ q->pilots[p][ns][idx] = (1 - 2 * (float)seq_mbsfn.c[2 * mp + 0]) * M_SQRT1_2; __imag__ q->pilots[p][ns][idx] = (1 - 2 * (float)seq_mbsfn.c[2 * mp + 1]) * M_SQRT1_2; } @@ -404,30 +404,30 @@ int srslte_refsignal_mbsfn_gen_seq(srslte_refsignal_t* q, srslte_cell_t cell, ui } } - srslte_sequence_free(&seq_mbsfn); - ret = SRSLTE_SUCCESS; + srsran_sequence_free(&seq_mbsfn); + ret = SRSRAN_SUCCESS; free_and_exit: - if (ret == SRSLTE_ERROR) { - srslte_sequence_free(&seq_mbsfn); - srslte_refsignal_free(q); + if (ret == SRSRAN_ERROR) { + srsran_sequence_free(&seq_mbsfn); + srsran_refsignal_free(q); } return ret; } -int srslte_refsignal_mbsfn_init(srslte_refsignal_t* q, uint32_t max_prb) +int srsran_refsignal_mbsfn_init(srsran_refsignal_t* q, uint32_t max_prb) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; uint32_t i, p; if (q != NULL) { - ret = SRSLTE_ERROR; - bzero(q, sizeof(srslte_refsignal_t)); + ret = SRSRAN_ERROR; + bzero(q, sizeof(srsran_refsignal_t)); - q->type = SRSLTE_SF_MBSFN; + q->type = SRSRAN_SF_MBSFN; for (p = 0; p < 2; p++) { - for (i = 0; i < SRSLTE_NOF_SF_X_FRAME; i++) { - q->pilots[p][i] = srslte_vec_cf_malloc(max_prb * 18); + for (i = 0; i < SRSRAN_NOF_SF_X_FRAME; i++) { + q->pilots[p][i] = srsran_vec_cf_malloc(max_prb * 18); if (!q->pilots[p][i]) { perror("malloc"); goto free_and_exit; @@ -435,62 +435,62 @@ int srslte_refsignal_mbsfn_init(srslte_refsignal_t* q, uint32_t max_prb) } } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } free_and_exit: - if (ret == SRSLTE_ERROR) { - srslte_refsignal_free(q); + if (ret == SRSRAN_ERROR) { + srsran_refsignal_free(q); } return ret; } -int srslte_refsignal_mbsfn_set_cell(srslte_refsignal_t* q, srslte_cell_t cell, uint16_t mbsfn_area_id) +int srsran_refsignal_mbsfn_set_cell(srsran_refsignal_t* q, srsran_cell_t cell, uint16_t mbsfn_area_id) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; q->cell = cell; q->mbsfn_area_id = mbsfn_area_id; - if (srslte_refsignal_mbsfn_gen_seq(q, q->cell, q->mbsfn_area_id)) { + if (srsran_refsignal_mbsfn_gen_seq(q, q->cell, q->mbsfn_area_id)) { goto free_and_exit; } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; free_and_exit: - if (ret == SRSLTE_ERROR) { - srslte_refsignal_free(q); + if (ret == SRSRAN_ERROR) { + srsran_refsignal_free(q); } return ret; } -int srslte_refsignal_mbsfn_get_sf(srslte_cell_t cell, uint32_t port_id, cf_t* sf_symbols, cf_t* pilots) +int srsran_refsignal_mbsfn_get_sf(srsran_cell_t cell, uint32_t port_id, cf_t* sf_symbols, cf_t* pilots) { uint32_t i, l; uint32_t fidx; uint32_t nsymbol; - if (srslte_cell_isvalid(&cell) && srslte_portid_isvalid(port_id) && pilots != NULL && sf_symbols != NULL) { + if (srsran_cell_isvalid(&cell) && srsran_portid_isvalid(port_id) && pilots != NULL && sf_symbols != NULL) { // getting refs from non mbsfn section of subframe - nsymbol = srslte_refsignal_cs_nsymbol(0, cell.cp, port_id); - fidx = ((srslte_refsignal_cs_v(port_id, 0) + (cell.id % 6)) % 6); + nsymbol = srsran_refsignal_cs_nsymbol(0, cell.cp, port_id); + fidx = ((srsran_refsignal_cs_v(port_id, 0) + (cell.id % 6)) % 6); for (i = 0; i < 2 * cell.nof_prb; i++) { - pilots[SRSLTE_REFSIGNAL_PILOT_IDX(i, 0, cell)] = sf_symbols[SRSLTE_RE_IDX(cell.nof_prb, nsymbol, fidx)]; - fidx += SRSLTE_NRE / 2; // 2 references per PRB + pilots[SRSRAN_REFSIGNAL_PILOT_IDX(i, 0, cell)] = sf_symbols[SRSRAN_RE_IDX(cell.nof_prb, nsymbol, fidx)]; + fidx += SRSRAN_NRE / 2; // 2 references per PRB } - for (l = 0; l < srslte_refsignal_mbsfn_nof_symbols(); l++) { - nsymbol = srslte_refsignal_mbsfn_nsymbol(l); - fidx = srslte_refsignal_mbsfn_fidx(l); + for (l = 0; l < srsran_refsignal_mbsfn_nof_symbols(); l++) { + nsymbol = srsran_refsignal_mbsfn_nsymbol(l); + fidx = srsran_refsignal_mbsfn_fidx(l); for (i = 0; i < 6 * cell.nof_prb; i++) { - pilots[SRSLTE_REFSIGNAL_PILOT_IDX_MBSFN(i, l, cell) + (2 * cell.nof_prb)] = - sf_symbols[SRSLTE_RE_IDX(cell.nof_prb, nsymbol, fidx)]; - fidx += SRSLTE_NRE / 6; + pilots[SRSRAN_REFSIGNAL_PILOT_IDX_MBSFN(i, l, cell) + (2 * cell.nof_prb)] = + sf_symbols[SRSRAN_RE_IDX(cell.nof_prb, nsymbol, fidx)]; + fidx += SRSRAN_NRE / 6; } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } else { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } } diff --git a/lib/src/phy/ch_estimation/refsignal_dl_nbiot.c b/lib/src/phy/ch_estimation/refsignal_dl_nbiot.c index e9711275f..9071a8dfb 100644 --- a/lib/src/phy/ch_estimation/refsignal_dl_nbiot.c +++ b/lib/src/phy/ch_estimation/refsignal_dl_nbiot.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -12,20 +12,20 @@ #include #include -#include +#include #include #include #include -#include "srslte/phy/ch_estimation/refsignal_dl_nbiot.h" -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/common/sequence.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/ch_estimation/refsignal_dl_nbiot.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/common/sequence.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" #define EXTRA_DEBUG 0 -uint32_t srslte_nbiot_refsignal_dl_v(uint32_t port_id, uint32_t ref_symbol_idx) +uint32_t srsran_nbiot_refsignal_dl_v(uint32_t port_id, uint32_t ref_symbol_idx) { uint32_t v = 0; switch (port_id) { @@ -47,7 +47,7 @@ uint32_t srslte_nbiot_refsignal_dl_v(uint32_t port_id, uint32_t ref_symbol_idx) return v; } -uint32_t srslte_refsignal_dl_nbiot_nof_symbols(uint32_t port_id) +uint32_t srsran_refsignal_dl_nbiot_nof_symbols(uint32_t port_id) { if (port_id < 2) { return 4; @@ -56,44 +56,44 @@ uint32_t srslte_refsignal_dl_nbiot_nof_symbols(uint32_t port_id) } } -uint32_t srslte_refsignal_dl_nbiot_fidx(srslte_nbiot_cell_t cell, uint32_t l, uint32_t port_id, uint32_t m) +uint32_t srsran_refsignal_dl_nbiot_fidx(srsran_nbiot_cell_t cell, uint32_t l, uint32_t port_id, uint32_t m) { - return (6 * m + ((srslte_nbiot_refsignal_dl_v(port_id, l) + (cell.n_id_ncell % 6)) % 6)); + return (6 * m + ((srsran_nbiot_refsignal_dl_v(port_id, l) + (cell.n_id_ncell % 6)) % 6)); } -inline uint32_t srslte_nbiot_refsignal_dl_nsymbol(uint32_t l, srslte_cp_t cp, uint32_t port_id) +inline uint32_t srsran_nbiot_refsignal_dl_nsymbol(uint32_t l, srsran_cp_t cp, uint32_t port_id) { if (port_id < 2) { if (l % 2) { - return (l / 2 + 1) * SRSLTE_CP_NSYMB(cp) - 3; + return (l / 2 + 1) * SRSRAN_CP_NSYMB(cp) - 3; } else { - return (l / 2) * SRSLTE_CP_NSYMB(cp); + return (l / 2) * SRSRAN_CP_NSYMB(cp); } } else { - return 1 + l * SRSLTE_CP_NSYMB(cp); + return 1 + l * SRSRAN_CP_NSYMB(cp); } } -inline uint32_t srslte_refsignal_nbiot_cs_nof_re(srslte_nbiot_cell_t* cell, uint32_t port_id) +inline uint32_t srsran_refsignal_nbiot_cs_nof_re(srsran_nbiot_cell_t* cell, uint32_t port_id) { - return srslte_refsignal_cs_nof_symbols(NULL, NULL, port_id) * cell->base.nof_prb * 2; // 2 RE per PRB + return srsran_refsignal_cs_nof_symbols(NULL, NULL, port_id) * cell->base.nof_prb * 2; // 2 RE per PRB } /** Allocates and precomputes the Narrowband Reference Signal (NRS) signal for * the 20 slots in a subframe */ -int srslte_refsignal_dl_nbiot_init(srslte_refsignal_dl_nbiot_t* q) +int srsran_refsignal_dl_nbiot_init(srsran_refsignal_dl_nbiot_t* q) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL) { - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; - bzero(q, sizeof(srslte_refsignal_dl_nbiot_t)); + bzero(q, sizeof(srsran_refsignal_dl_nbiot_t)); for (uint32_t p = 0; p < 2; p++) { - for (uint32_t i = 0; i < SRSLTE_NOF_SF_X_FRAME; i++) { - q->pilots[p][i] = srslte_vec_cf_malloc(SRSLTE_NBIOT_REFSIGNAL_NUM_SF(SRSLTE_NBIOT_MAX_PRB, p)); + for (uint32_t i = 0; i < SRSRAN_NOF_SF_X_FRAME; i++) { + q->pilots[p][i] = srsran_vec_cf_malloc(SRSRAN_NBIOT_REFSIGNAL_NUM_SF(SRSRAN_NBIOT_MAX_PRB, p)); if (!q->pilots[p][i]) { perror("malloc"); goto free_and_exit; @@ -101,49 +101,49 @@ int srslte_refsignal_dl_nbiot_init(srslte_refsignal_dl_nbiot_t* q) } } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } free_and_exit: - if (ret == SRSLTE_ERROR) { - srslte_refsignal_dl_nbiot_free(q); + if (ret == SRSRAN_ERROR) { + srsran_refsignal_dl_nbiot_free(q); } return ret; } -int srslte_refsignal_dl_nbiot_set_cell(srslte_refsignal_dl_nbiot_t* q, srslte_nbiot_cell_t cell) +int srsran_refsignal_dl_nbiot_set_cell(srsran_refsignal_dl_nbiot_t* q, srsran_nbiot_cell_t cell) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; INFO("Generating NRS for n_id_ncell=%d", cell.n_id_ncell); - if (q != NULL && srslte_nbiot_cell_isvalid(&cell)) { - ret = SRSLTE_ERROR; + if (q != NULL && srsran_nbiot_cell_isvalid(&cell)) { + ret = SRSRAN_ERROR; q->cell = cell; - srslte_sequence_t seq; - bzero(&seq, sizeof(srslte_sequence_t)); - if (srslte_sequence_init(&seq, SRSLTE_NOF_SLOTS_PER_SF * SRSLTE_NBIOT_MAX_PORTS * SRSLTE_MAX_PRB)) { + srsran_sequence_t seq; + bzero(&seq, sizeof(srsran_sequence_t)); + if (srsran_sequence_init(&seq, SRSRAN_NOF_SLOTS_PER_SF * SRSRAN_NBIOT_MAX_PORTS * SRSRAN_MAX_PRB)) { goto free_and_exit; } - for (uint32_t ns = 0; ns < SRSLTE_NSLOTS_X_FRAME; ns++) { + for (uint32_t ns = 0; ns < SRSRAN_NSLOTS_X_FRAME; ns++) { for (uint32_t p = 0; p < 2; p++) { - uint32_t nsymbols = srslte_refsignal_dl_nbiot_nof_symbols(p) / 2; + uint32_t nsymbols = srsran_refsignal_dl_nbiot_nof_symbols(p) / 2; for (uint32_t l = 0; l < nsymbols; l++) { /* Compute sequence init value */ - uint32_t lp = srslte_refsignal_nrs_nsymbol(l); + uint32_t lp = srsran_refsignal_nrs_nsymbol(l); uint32_t N_cp = 1; uint32_t c_init = 1024 * (7 * (ns + 1) + lp + 1) * (2 * cell.n_id_ncell + 1) + 2 * cell.n_id_ncell + N_cp; /* generate sequence for this symbol and slot */ - srslte_sequence_set_LTE_pr(&seq, SRSLTE_NOF_SLOTS_PER_SF + SRSLTE_NBIOT_MAX_PORTS * SRSLTE_MAX_PRB, c_init); + srsran_sequence_set_LTE_pr(&seq, SRSRAN_NOF_SLOTS_PER_SF + SRSRAN_NBIOT_MAX_PORTS * SRSRAN_MAX_PRB, c_init); /* Compute signal */ for (uint32_t i = 0; i < 2; i++) { - uint32_t mp = i + SRSLTE_MAX_PRB - 1; + uint32_t mp = i + SRSRAN_MAX_PRB - 1; /* save signal */ int idx = - SRSLTE_NBIOT_REFSIGNAL_PILOT_IDX(i, (ns % 2) * nsymbols + l, SRSLTE_NBIOT_DEFAULT_NUM_PRB_BASECELL); + SRSRAN_NBIOT_REFSIGNAL_PILOT_IDX(i, (ns % 2) * nsymbols + l, SRSRAN_NBIOT_DEFAULT_NUM_PRB_BASECELL); DEBUG("Ref port=%d, lp=%d, ns=%d, ns/2=%d, idx=%d, i=%d, nsymbols=%d, l=%d", p, lp, @@ -159,107 +159,107 @@ int srslte_refsignal_dl_nbiot_set_cell(srslte_refsignal_dl_nbiot_t* q, srslte_nb } } } - srslte_sequence_free(&seq); - ret = SRSLTE_SUCCESS; + srsran_sequence_free(&seq); + ret = SRSRAN_SUCCESS; } free_and_exit: - if (ret == SRSLTE_ERROR) { - srslte_refsignal_dl_nbiot_free(q); + if (ret == SRSRAN_ERROR) { + srsran_refsignal_dl_nbiot_free(q); } return ret; } -// Deallocates a srslte_refsignal_cs_t object allocated with srslte_refsignal_cs_init -void srslte_refsignal_dl_nbiot_free(srslte_refsignal_dl_nbiot_t* q) +// Deallocates a srsran_refsignal_cs_t object allocated with srsran_refsignal_cs_init +void srsran_refsignal_dl_nbiot_free(srsran_refsignal_dl_nbiot_t* q) { for (int p = 0; p < 2; p++) { - for (int i = 0; i < SRSLTE_NOF_SF_X_FRAME; i++) { + for (int i = 0; i < SRSRAN_NOF_SF_X_FRAME; i++) { if (q->pilots[p][i]) { free(q->pilots[p][i]); } } } - bzero(q, sizeof(srslte_refsignal_dl_nbiot_t)); + bzero(q, sizeof(srsran_refsignal_dl_nbiot_t)); } /** Regardless of the number of antenna ports, NRS are always transmitted * in the last two symbols of each slot */ -inline uint32_t srslte_refsignal_nrs_nsymbol(uint32_t l) +inline uint32_t srsran_refsignal_nrs_nsymbol(uint32_t l) { if (l % 2 == 0) { - return ((l / 2) * SRSLTE_CP_NORM_NSYMB + 5); + return ((l / 2) * SRSRAN_CP_NORM_NSYMB + 5); } else { - return ((l / 2) * SRSLTE_CP_NORM_NSYMB + 6); + return ((l / 2) * SRSRAN_CP_NORM_NSYMB + 6); } } -/** Maps the NRS reference signal initialized with srslte_refsignal_cs_init() into an array of subframe symbols +/** Maps the NRS reference signal initialized with srsran_refsignal_cs_init() into an array of subframe symbols Note that the NRS signal is identical to the CRS, but is initalized with NCellID */ -int srslte_refsignal_nrs_put_sf(srslte_nbiot_cell_t cell, uint32_t port_id, cf_t* pilots, cf_t* sf_symbols) +int srsran_refsignal_nrs_put_sf(srsran_nbiot_cell_t cell, uint32_t port_id, cf_t* pilots, cf_t* sf_symbols) { - if (srslte_nbiot_cell_isvalid(&cell) && srslte_portid_isvalid(port_id) && pilots != NULL && sf_symbols != NULL) { - for (int l = 0; l < srslte_refsignal_dl_nbiot_nof_symbols(port_id); l++) { - uint32_t nsymbol = srslte_refsignal_nrs_nsymbol(l); + if (srsran_nbiot_cell_isvalid(&cell) && srsran_portid_isvalid(port_id) && pilots != NULL && sf_symbols != NULL) { + for (int l = 0; l < srsran_refsignal_dl_nbiot_nof_symbols(port_id); l++) { + uint32_t nsymbol = srsran_refsignal_nrs_nsymbol(l); // Two reference symbols per OFDM symbol - for (int m = 0; m < SRSLTE_NBIOT_NUM_NRS_X_SYM_X_PORT; m++) { - uint32_t fidx = srslte_refsignal_dl_nbiot_fidx(cell, l, port_id, m) + cell.nbiot_prb * SRSLTE_NRE; - sf_symbols[SRSLTE_RE_IDX(cell.base.nof_prb, nsymbol, fidx)] = pilots[SRSLTE_NBIOT_REFSIGNAL_PILOT_IDX(m, l, 1)]; + for (int m = 0; m < SRSRAN_NBIOT_NUM_NRS_X_SYM_X_PORT; m++) { + uint32_t fidx = srsran_refsignal_dl_nbiot_fidx(cell, l, port_id, m) + cell.nbiot_prb * SRSRAN_NRE; + sf_symbols[SRSRAN_RE_IDX(cell.base.nof_prb, nsymbol, fidx)] = pilots[SRSRAN_NBIOT_REFSIGNAL_PILOT_IDX(m, l, 1)]; #if EXTRA_DEBUG DEBUG("port: %d, re_idx: %d, pilot_idx: %d, %+2.2f%+2.2fi", port_id, - SRSLTE_RE_IDX(cell.base.nof_prb, nsymbol, fidx), - SRSLTE_NBIOT_REFSIGNAL_PILOT_IDX(i, l, 1), - __real__ sf_symbols[SRSLTE_RE_IDX(cell.base.nof_prb, nsymbol, fidx)], - __imag__ sf_symbols[SRSLTE_RE_IDX(cell.base.nof_prb, nsymbol, fidx)]); + SRSRAN_RE_IDX(cell.base.nof_prb, nsymbol, fidx), + SRSRAN_NBIOT_REFSIGNAL_PILOT_IDX(i, l, 1), + __real__ sf_symbols[SRSRAN_RE_IDX(cell.base.nof_prb, nsymbol, fidx)], + __imag__ sf_symbols[SRSRAN_RE_IDX(cell.base.nof_prb, nsymbol, fidx)]); #endif } } #if EXTRA_DEBUG - if (SRSLTE_VERBOSE_ISDEBUG()) { + if (SRSRAN_VERBOSE_ISDEBUG()) { DEBUG("SAVED FILE chest_nbiot_tx_after_mapping.bin: NRS after mapping", 0); - srslte_vec_save_file( - "chest_nbiot_tx_after_mapping.bin", pilots, SRSLTE_REFSIGNAL_NUM_SF(1, port_id) * sizeof(cf_t)); + srsran_vec_save_file( + "chest_nbiot_tx_after_mapping.bin", pilots, SRSRAN_REFSIGNAL_NUM_SF(1, port_id) * sizeof(cf_t)); } #endif - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } else { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } } /** Copies the RE containing references from an array of subframe symbols to the pilots array. */ -int srslte_refsignal_nrs_get_sf(srslte_nbiot_cell_t cell, uint32_t port_id, cf_t* sf_symbols, cf_t* pilots) +int srsran_refsignal_nrs_get_sf(srsran_nbiot_cell_t cell, uint32_t port_id, cf_t* sf_symbols, cf_t* pilots) { - if (srslte_nbiot_cell_isvalid(&cell) && srslte_portid_isvalid(port_id) && pilots != NULL && sf_symbols != NULL) { - for (int l = 0; l < srslte_refsignal_dl_nbiot_nof_symbols(port_id); l++) { - uint32_t nsymbol = srslte_refsignal_nrs_nsymbol(l); + if (srsran_nbiot_cell_isvalid(&cell) && srsran_portid_isvalid(port_id) && pilots != NULL && sf_symbols != NULL) { + for (int l = 0; l < srsran_refsignal_dl_nbiot_nof_symbols(port_id); l++) { + uint32_t nsymbol = srsran_refsignal_nrs_nsymbol(l); // read both pilots of this symbol - for (int m = 0; m < SRSLTE_NBIOT_NUM_NRS_X_SYM_X_PORT; m++) { - uint32_t fidx = srslte_refsignal_dl_nbiot_fidx(cell, l, port_id, m) + cell.nbiot_prb * SRSLTE_NRE; - pilots[SRSLTE_NBIOT_REFSIGNAL_PILOT_IDX(m, l, 1)] = sf_symbols[SRSLTE_RE_IDX(cell.base.nof_prb, nsymbol, fidx)]; + for (int m = 0; m < SRSRAN_NBIOT_NUM_NRS_X_SYM_X_PORT; m++) { + uint32_t fidx = srsran_refsignal_dl_nbiot_fidx(cell, l, port_id, m) + cell.nbiot_prb * SRSRAN_NRE; + pilots[SRSRAN_NBIOT_REFSIGNAL_PILOT_IDX(m, l, 1)] = sf_symbols[SRSRAN_RE_IDX(cell.base.nof_prb, nsymbol, fidx)]; #if EXTRA_DEBUG DEBUG("port: %d, pilot_idx: %d, re_idx: %d, %+2.2f%+2.2fi", port_id, - SRSLTE_NBIOT_REFSIGNAL_PILOT_IDX(m, l, 1), - SRSLTE_RE_IDX(cell.base.nof_prb, nsymbol, fidx), - __real__ pilots[SRSLTE_NBIOT_REFSIGNAL_PILOT_IDX(m, l, 1)], - __imag__ pilots[SRSLTE_NBIOT_REFSIGNAL_PILOT_IDX(m, l, 1)]); + SRSRAN_NBIOT_REFSIGNAL_PILOT_IDX(m, l, 1), + SRSRAN_RE_IDX(cell.base.nof_prb, nsymbol, fidx), + __real__ pilots[SRSRAN_NBIOT_REFSIGNAL_PILOT_IDX(m, l, 1)], + __imag__ pilots[SRSRAN_NBIOT_REFSIGNAL_PILOT_IDX(m, l, 1)]); #endif } } #if EXTRA_DEBUG - if (SRSLTE_VERBOSE_ISDEBUG()) { + if (SRSRAN_VERBOSE_ISDEBUG()) { DEBUG("SAVED FILE chest_nbiot_rx_after_demapping.bin: NRS after demapping", 0); - srslte_vec_save_file( - "chest_nbiot_rx_after_demapping.bin", pilots, SRSLTE_REFSIGNAL_NUM_SF(1, port_id) * sizeof(cf_t)); + srsran_vec_save_file( + "chest_nbiot_rx_after_demapping.bin", pilots, SRSRAN_REFSIGNAL_NUM_SF(1, port_id) * sizeof(cf_t)); } #endif - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } else { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } } diff --git a/lib/src/phy/ch_estimation/refsignal_ul.c b/lib/src/phy/ch_estimation/refsignal_ul.c index 2d428d363..6abcae8cc 100644 --- a/lib/src/phy/ch_estimation/refsignal_ul.c +++ b/lib/src/phy/ch_estimation/refsignal_ul.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -16,15 +16,15 @@ #include #include -#include "srslte/phy/ch_estimation/refsignal_ul.h" -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/common/sequence.h" -#include "srslte/phy/common/zc_sequence.h" -#include "srslte/phy/dft/dft_precoding.h" -#include "srslte/phy/phch/pucch.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/primes.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/ch_estimation/refsignal_ul.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/common/sequence.h" +#include "srsran/phy/common/zc_sequence.h" +#include "srsran/phy/dft/dft_precoding.h" +#include "srsran/phy/phch/pucch.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/primes.h" +#include "srsran/phy/utils/vector.h" // n_dmrs_2 table 5.5.2.1.1-1 from 36.211 uint32_t n_dmrs_2[8] = {0, 6, 3, 4, 2, 8, 10, 9}; @@ -81,87 +81,87 @@ uint32_t Nb[4][4][8] = { {{1, 1, 1, 1, 1, 1, 1, 1}, {2, 3, 2, 3, 2, 3, 2, 3}, {2, 2, 2, 2, 2, 5, 2, 2}, {6, 4, 5, 3, 4, 1, 3, 2}}}; /** Computes n_prs values used to compute alpha as defined in 5.5.2.1.1 of 36.211 */ -static int generate_n_prs(srslte_refsignal_ul_t* q) +static int generate_n_prs(srsran_refsignal_ul_t* q) { /* Calculate n_prs */ uint32_t c_init; - srslte_sequence_t seq; - bzero(&seq, sizeof(srslte_sequence_t)); + srsran_sequence_t seq; + bzero(&seq, sizeof(srsran_sequence_t)); - for (uint32_t delta_ss = 0; delta_ss < SRSLTE_NOF_DELTA_SS; delta_ss++) { + for (uint32_t delta_ss = 0; delta_ss < SRSRAN_NOF_DELTA_SS; delta_ss++) { c_init = ((q->cell.id / 30) << 5) + (((q->cell.id % 30) + delta_ss) % 30); - if (srslte_sequence_LTE_pr(&seq, 8 * SRSLTE_CP_NSYMB(q->cell.cp) * 20, c_init)) { - return SRSLTE_ERROR; + if (srsran_sequence_LTE_pr(&seq, 8 * SRSRAN_CP_NSYMB(q->cell.cp) * 20, c_init)) { + return SRSRAN_ERROR; } - for (uint32_t ns = 0; ns < SRSLTE_NSLOTS_X_FRAME; ns++) { + for (uint32_t ns = 0; ns < SRSRAN_NSLOTS_X_FRAME; ns++) { uint32_t n_prs = 0; for (int i = 0; i < 8; i++) { - n_prs += (seq.c[8 * SRSLTE_CP_NSYMB(q->cell.cp) * ns + i] << i); + n_prs += (seq.c[8 * SRSRAN_CP_NSYMB(q->cell.cp) * ns + i] << i); } q->n_prs_pusch[delta_ss][ns] = n_prs; } } - srslte_sequence_free(&seq); + srsran_sequence_free(&seq); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -static int generate_srslte_sequence_hopping_v(srslte_refsignal_ul_t* q) +static int generate_srsran_sequence_hopping_v(srsran_refsignal_ul_t* q) { - srslte_sequence_t seq; - bzero(&seq, sizeof(srslte_sequence_t)); + srsran_sequence_t seq; + bzero(&seq, sizeof(srsran_sequence_t)); - for (uint32_t ns = 0; ns < SRSLTE_NSLOTS_X_FRAME; ns++) { - for (uint32_t delta_ss = 0; delta_ss < SRSLTE_NOF_DELTA_SS; delta_ss++) { - if (srslte_sequence_LTE_pr(&seq, 20, ((q->cell.id / 30) << 5) + ((q->cell.id % 30) + delta_ss) % 30)) { - return SRSLTE_ERROR; + for (uint32_t ns = 0; ns < SRSRAN_NSLOTS_X_FRAME; ns++) { + for (uint32_t delta_ss = 0; delta_ss < SRSRAN_NOF_DELTA_SS; delta_ss++) { + if (srsran_sequence_LTE_pr(&seq, 20, ((q->cell.id / 30) << 5) + ((q->cell.id % 30) + delta_ss) % 30)) { + return SRSRAN_ERROR; } q->v_pusch[ns][delta_ss] = seq.c[ns]; } } - srslte_sequence_free(&seq); - return SRSLTE_SUCCESS; + srsran_sequence_free(&seq); + return SRSRAN_SUCCESS; } -/** Initializes srslte_refsignal_ul_t object according to 3GPP 36.211 5.5 +/** Initializes srsran_refsignal_ul_t object according to 3GPP 36.211 5.5 * */ -int srslte_refsignal_ul_set_cell(srslte_refsignal_ul_t* q, srslte_cell_t cell) +int srsran_refsignal_ul_set_cell(srsran_refsignal_ul_t* q, srsran_cell_t cell) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; - if (q != NULL && srslte_cell_isvalid(&cell)) { + if (q != NULL && srsran_cell_isvalid(&cell)) { if (cell.id != q->cell.id || q->cell.nof_prb == 0) { q->cell = cell; // Precompute n_prs if (generate_n_prs(q)) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Precompute group hopping values u. - if (srslte_group_hopping_f_gh(q->f_gh, q->cell.id)) { - return SRSLTE_ERROR; + if (srsran_group_hopping_f_gh(q->f_gh, q->cell.id)) { + return SRSRAN_ERROR; } // Precompute sequence hopping values v. Uses f_ss_pusch - if (generate_srslte_sequence_hopping_v(q)) { - return SRSLTE_ERROR; + if (generate_srsran_sequence_hopping_v(q)) { + return SRSRAN_ERROR; } - if (srslte_pucch_n_cs_cell(q->cell, q->n_cs_cell)) { - return SRSLTE_ERROR; + if (srsran_pucch_n_cs_cell(q->cell, q->n_cs_cell)) { + return SRSRAN_ERROR; } } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } /* Calculates alpha according to 5.5.2.1.1 of 36.211 */ -static float pusch_alpha(srslte_refsignal_ul_t* q, - srslte_refsignal_dmrs_pusch_cfg_t* cfg, +static float pusch_alpha(srsran_refsignal_ul_t* q, + srsran_refsignal_dmrs_pusch_cfg_t* cfg, uint32_t cyclic_shift_for_dmrs, uint32_t ns) { @@ -171,17 +171,17 @@ static float pusch_alpha(srslte_refsignal_ul_t* q, return 2 * M_PI * (n_cs) / 12; } -static bool pusch_cfg_isvalid(srslte_refsignal_ul_t* q, srslte_refsignal_dmrs_pusch_cfg_t* cfg, uint32_t nof_prb) +static bool pusch_cfg_isvalid(srsran_refsignal_ul_t* q, srsran_refsignal_dmrs_pusch_cfg_t* cfg, uint32_t nof_prb) { - if (cfg->cyclic_shift < SRSLTE_NOF_CSHIFT && cfg->delta_ss < SRSLTE_NOF_DELTA_SS && nof_prb <= q->cell.nof_prb) { + if (cfg->cyclic_shift < SRSRAN_NOF_CSHIFT && cfg->delta_ss < SRSRAN_NOF_DELTA_SS && nof_prb <= q->cell.nof_prb) { return true; } else { return false; } } -void srslte_refsignal_dmrs_pusch_put(srslte_refsignal_ul_t* q, - srslte_pusch_cfg_t* pusch_cfg, +void srsran_refsignal_dmrs_pusch_put(srsran_refsignal_ul_t* q, + srsran_pusch_cfg_t* pusch_cfg, cf_t* r_pusch, cf_t* sf_symbols) { @@ -190,15 +190,15 @@ void srslte_refsignal_dmrs_pusch_put(srslte_refsignal_ul_t* q, pusch_cfg->grant.n_prb_tilde[ns_idx], pusch_cfg->grant.L_prb, ns_idx); - uint32_t L = SRSLTE_REFSIGNAL_UL_L(ns_idx, q->cell.cp); - memcpy(&sf_symbols[SRSLTE_RE_IDX(q->cell.nof_prb, L, pusch_cfg->grant.n_prb_tilde[ns_idx] * SRSLTE_NRE)], - &r_pusch[ns_idx * SRSLTE_NRE * pusch_cfg->grant.L_prb], - pusch_cfg->grant.L_prb * SRSLTE_NRE * sizeof(cf_t)); + uint32_t L = SRSRAN_REFSIGNAL_UL_L(ns_idx, q->cell.cp); + memcpy(&sf_symbols[SRSRAN_RE_IDX(q->cell.nof_prb, L, pusch_cfg->grant.n_prb_tilde[ns_idx] * SRSRAN_NRE)], + &r_pusch[ns_idx * SRSRAN_NRE * pusch_cfg->grant.L_prb], + pusch_cfg->grant.L_prb * SRSRAN_NRE * sizeof(cf_t)); } } -void srslte_refsignal_dmrs_pusch_get(srslte_refsignal_ul_t* q, - srslte_pusch_cfg_t* pusch_cfg, +void srsran_refsignal_dmrs_pusch_get(srsran_refsignal_ul_t* q, + srsran_pusch_cfg_t* pusch_cfg, cf_t* sf_symbols, cf_t* r_pusch) { @@ -207,16 +207,16 @@ void srslte_refsignal_dmrs_pusch_get(srslte_refsignal_ul_t* q, pusch_cfg->grant.n_prb_tilde[ns_idx], pusch_cfg->grant.L_prb, ns_idx); - uint32_t L = SRSLTE_REFSIGNAL_UL_L(ns_idx, q->cell.cp); - memcpy(&r_pusch[ns_idx * SRSLTE_NRE * pusch_cfg->grant.L_prb], - &sf_symbols[SRSLTE_RE_IDX(q->cell.nof_prb, L, pusch_cfg->grant.n_prb_tilde[ns_idx] * SRSLTE_NRE)], - pusch_cfg->grant.L_prb * SRSLTE_NRE * sizeof(cf_t)); + uint32_t L = SRSRAN_REFSIGNAL_UL_L(ns_idx, q->cell.cp); + memcpy(&r_pusch[ns_idx * SRSRAN_NRE * pusch_cfg->grant.L_prb], + &sf_symbols[SRSRAN_RE_IDX(q->cell.nof_prb, L, pusch_cfg->grant.n_prb_tilde[ns_idx] * SRSRAN_NRE)], + pusch_cfg->grant.L_prb * SRSRAN_NRE * sizeof(cf_t)); } } /* Computes r sequence */ -static void compute_r(srslte_refsignal_ul_t* q, - srslte_refsignal_dmrs_pusch_cfg_t* cfg, +static void compute_r(srsran_refsignal_ul_t* q, + srsran_refsignal_dmrs_pusch_cfg_t* cfg, uint32_t nof_prb, uint32_t ns, uint32_t delta_ss, @@ -237,63 +237,63 @@ static void compute_r(srslte_refsignal_ul_t* q, } // Compute signal argument - srslte_zc_sequence_generate_lte(u, v, alpha, nof_prb, sequence); + srsran_zc_sequence_generate_lte(u, v, alpha, nof_prb, sequence); } -int srslte_refsignal_dmrs_pusch_pregen_init(srslte_refsignal_ul_dmrs_pregen_t* pregen, uint32_t max_prb) +int srsran_refsignal_dmrs_pusch_pregen_init(srsran_refsignal_ul_dmrs_pregen_t* pregen, uint32_t max_prb) { pregen->max_prb = max_prb; - for (uint32_t sf_idx = 0; sf_idx < SRSLTE_NOF_SF_X_FRAME; sf_idx++) { - for (uint32_t cs = 0; cs < SRSLTE_NOF_CSHIFT; cs++) { + for (uint32_t sf_idx = 0; sf_idx < SRSRAN_NOF_SF_X_FRAME; sf_idx++) { + for (uint32_t cs = 0; cs < SRSRAN_NOF_CSHIFT; cs++) { pregen->r[cs][sf_idx] = (cf_t**)calloc(sizeof(cf_t*), max_prb + 1); if (pregen->r[cs][sf_idx]) { for (uint32_t n = 0; n <= max_prb; n++) { - if (srslte_dft_precoding_valid_prb(n)) { - pregen->r[cs][sf_idx][n] = srslte_vec_cf_malloc(n * 2 * SRSLTE_NRE); + if (srsran_dft_precoding_valid_prb(n)) { + pregen->r[cs][sf_idx][n] = srsran_vec_cf_malloc(n * 2 * SRSRAN_NRE); if (!pregen->r[cs][sf_idx][n]) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } } } else { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_refsignal_dmrs_pusch_pregen(srslte_refsignal_ul_t* q, - srslte_refsignal_ul_dmrs_pregen_t* pregen, - srslte_refsignal_dmrs_pusch_cfg_t* cfg) +int srsran_refsignal_dmrs_pusch_pregen(srsran_refsignal_ul_t* q, + srsran_refsignal_ul_dmrs_pregen_t* pregen, + srsran_refsignal_dmrs_pusch_cfg_t* cfg) { - for (uint32_t sf_idx = 0; sf_idx < SRSLTE_NOF_SF_X_FRAME; sf_idx++) { - for (uint32_t cs = 0; cs < SRSLTE_NOF_CSHIFT; cs++) { + for (uint32_t sf_idx = 0; sf_idx < SRSRAN_NOF_SF_X_FRAME; sf_idx++) { + for (uint32_t cs = 0; cs < SRSRAN_NOF_CSHIFT; cs++) { if (pregen->r[cs][sf_idx]) { for (uint32_t n = 1; n <= q->cell.nof_prb; n++) { - if (srslte_dft_precoding_valid_prb(n)) { + if (srsran_dft_precoding_valid_prb(n)) { if (pregen->r[cs][sf_idx][n]) { - if (srslte_refsignal_dmrs_pusch_gen(q, cfg, n, sf_idx, cs, pregen->r[cs][sf_idx][n])) { - return SRSLTE_ERROR; + if (srsran_refsignal_dmrs_pusch_gen(q, cfg, n, sf_idx, cs, pregen->r[cs][sf_idx][n])) { + return SRSRAN_ERROR; } } else { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } } } else { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -void srslte_refsignal_dmrs_pusch_pregen_free(srslte_refsignal_ul_t* q, srslte_refsignal_ul_dmrs_pregen_t* pregen) +void srsran_refsignal_dmrs_pusch_pregen_free(srsran_refsignal_ul_t* q, srsran_refsignal_ul_dmrs_pregen_t* pregen) { - for (uint32_t sf_idx = 0; sf_idx < SRSLTE_NOF_SF_X_FRAME; sf_idx++) { - for (uint32_t cs = 0; cs < SRSLTE_NOF_CSHIFT; cs++) { + for (uint32_t sf_idx = 0; sf_idx < SRSRAN_NOF_SF_X_FRAME; sf_idx++) { + for (uint32_t cs = 0; cs < SRSRAN_NOF_CSHIFT; cs++) { if (pregen->r[cs][sf_idx]) { for (uint32_t n = 0; n <= pregen->max_prb; n++) { if (pregen->r[cs][sf_idx][n]) { @@ -306,41 +306,41 @@ void srslte_refsignal_dmrs_pusch_pregen_free(srslte_refsignal_ul_t* q, srslte_re } } -int srslte_refsignal_dmrs_pusch_pregen_put(srslte_refsignal_ul_t* q, - srslte_ul_sf_cfg_t* sf_cfg, - srslte_refsignal_ul_dmrs_pregen_t* pregen, - srslte_pusch_cfg_t* pusch_cfg, +int srsran_refsignal_dmrs_pusch_pregen_put(srsran_refsignal_ul_t* q, + srsran_ul_sf_cfg_t* sf_cfg, + srsran_refsignal_ul_dmrs_pregen_t* pregen, + srsran_pusch_cfg_t* pusch_cfg, cf_t* sf_symbols) { uint32_t sf_idx = sf_cfg->tti % 10; - if (srslte_dft_precoding_valid_prb(pusch_cfg->grant.L_prb) && sf_idx < SRSLTE_NOF_SF_X_FRAME && - pusch_cfg->grant.n_dmrs < SRSLTE_NOF_CSHIFT) { - srslte_refsignal_dmrs_pusch_put( + if (srsran_dft_precoding_valid_prb(pusch_cfg->grant.L_prb) && sf_idx < SRSRAN_NOF_SF_X_FRAME && + pusch_cfg->grant.n_dmrs < SRSRAN_NOF_CSHIFT) { + srsran_refsignal_dmrs_pusch_put( q, pusch_cfg, pregen->r[pusch_cfg->grant.n_dmrs][sf_idx][pusch_cfg->grant.L_prb], sf_symbols); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } else { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } } /* Generate DMRS for PUSCH signal according to 5.5.2.1 of 36.211 */ -int srslte_refsignal_dmrs_pusch_gen(srslte_refsignal_ul_t* q, - srslte_refsignal_dmrs_pusch_cfg_t* cfg, +int srsran_refsignal_dmrs_pusch_gen(srsran_refsignal_ul_t* q, + srsran_refsignal_dmrs_pusch_cfg_t* cfg, uint32_t nof_prb, uint32_t sf_idx, uint32_t cyclic_shift_for_dmrs, cf_t* r_pusch) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (pusch_cfg_isvalid(q, cfg, nof_prb)) { - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; for (uint32_t ns = 2 * sf_idx; ns < 2 * (sf_idx + 1); ns++) { // Add cyclic prefix alpha float alpha = pusch_alpha(q, cfg, cyclic_shift_for_dmrs, ns); - compute_r(q, cfg, nof_prb, ns, cfg->delta_ss, alpha, &r_pusch[(ns % 2) * SRSLTE_NRE * nof_prb]); + compute_r(q, cfg, nof_prb, ns, cfg->delta_ss, alpha, &r_pusch[(ns % 2) * SRSRAN_NRE * nof_prb]); } ret = 0; } @@ -348,26 +348,26 @@ int srslte_refsignal_dmrs_pusch_gen(srslte_refsignal_ul_t* q, } /* Number of PUCCH demodulation reference symbols per slot N_rs_pucch tABLE 5.5.2.2.1-1 36.211 */ -uint32_t srslte_refsignal_dmrs_N_rs(srslte_pucch_format_t format, srslte_cp_t cp) +uint32_t srsran_refsignal_dmrs_N_rs(srsran_pucch_format_t format, srsran_cp_t cp) { switch (format) { - case SRSLTE_PUCCH_FORMAT_1: - case SRSLTE_PUCCH_FORMAT_1A: - case SRSLTE_PUCCH_FORMAT_1B: - if (SRSLTE_CP_ISNORM(cp)) { + case SRSRAN_PUCCH_FORMAT_1: + case SRSRAN_PUCCH_FORMAT_1A: + case SRSRAN_PUCCH_FORMAT_1B: + if (SRSRAN_CP_ISNORM(cp)) { return 3; } else { return 2; } - case SRSLTE_PUCCH_FORMAT_2: - case SRSLTE_PUCCH_FORMAT_3: - if (SRSLTE_CP_ISNORM(cp)) { + case SRSRAN_PUCCH_FORMAT_2: + case SRSRAN_PUCCH_FORMAT_3: + if (SRSRAN_CP_ISNORM(cp)) { return 2; } else { return 1; } - case SRSLTE_PUCCH_FORMAT_2A: - case SRSLTE_PUCCH_FORMAT_2B: + case SRSRAN_PUCCH_FORMAT_2A: + case SRSRAN_PUCCH_FORMAT_2B: return 2; default: ERROR("DMRS Nof RS: Unsupported format %d", format); @@ -377,13 +377,13 @@ uint32_t srslte_refsignal_dmrs_N_rs(srslte_pucch_format_t format, srslte_cp_t cp } /* Table 5.5.2.2.2-1: Demodulation reference signal location for different PUCCH formats. 36.211 */ -uint32_t srslte_refsignal_dmrs_pucch_symbol(uint32_t m, srslte_pucch_format_t format, srslte_cp_t cp) +uint32_t srsran_refsignal_dmrs_pucch_symbol(uint32_t m, srsran_pucch_format_t format, srsran_cp_t cp) { switch (format) { - case SRSLTE_PUCCH_FORMAT_1: - case SRSLTE_PUCCH_FORMAT_1A: - case SRSLTE_PUCCH_FORMAT_1B: - if (SRSLTE_CP_ISNORM(cp)) { + case SRSRAN_PUCCH_FORMAT_1: + case SRSRAN_PUCCH_FORMAT_1A: + case SRSRAN_PUCCH_FORMAT_1B: + if (SRSRAN_CP_ISNORM(cp)) { if (m < 3) { return pucch_dmrs_symbol_format1_cpnorm[m]; } @@ -393,9 +393,9 @@ uint32_t srslte_refsignal_dmrs_pucch_symbol(uint32_t m, srslte_pucch_format_t fo } } break; - case SRSLTE_PUCCH_FORMAT_2: - case SRSLTE_PUCCH_FORMAT_3: - if (SRSLTE_CP_ISNORM(cp)) { + case SRSRAN_PUCCH_FORMAT_2: + case SRSRAN_PUCCH_FORMAT_3: + if (SRSRAN_CP_ISNORM(cp)) { if (m < 2) { return pucch_dmrs_symbol_format2_cpnorm[m]; } @@ -405,8 +405,8 @@ uint32_t srslte_refsignal_dmrs_pucch_symbol(uint32_t m, srslte_pucch_format_t fo } } break; - case SRSLTE_PUCCH_FORMAT_2A: - case SRSLTE_PUCCH_FORMAT_2B: + case SRSRAN_PUCCH_FORMAT_2A: + case SRSRAN_PUCCH_FORMAT_2B: if (m < 2) { return pucch_dmrs_symbol_format2_cpnorm[m]; } @@ -419,22 +419,22 @@ uint32_t srslte_refsignal_dmrs_pucch_symbol(uint32_t m, srslte_pucch_format_t fo } /* Generates DMRS for PUCCH according to 5.5.2.2 in 36.211 */ -int srslte_refsignal_dmrs_pucch_gen(srslte_refsignal_ul_t* q, - srslte_ul_sf_cfg_t* sf, - srslte_pucch_cfg_t* cfg, +int srsran_refsignal_dmrs_pucch_gen(srsran_refsignal_ul_t* q, + srsran_ul_sf_cfg_t* sf, + srsran_pucch_cfg_t* cfg, cf_t* r_pucch) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q && r_pucch) { - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; - uint32_t N_rs = srslte_refsignal_dmrs_N_rs(cfg->format, q->cell.cp); + uint32_t N_rs = srsran_refsignal_dmrs_N_rs(cfg->format, q->cell.cp); uint32_t sf_idx = sf->tti % 10; cf_t z_m_1 = 1.0; - if (cfg->format == SRSLTE_PUCCH_FORMAT_2A || cfg->format == SRSLTE_PUCCH_FORMAT_2B) { - srslte_pucch_format2ab_mod_bits(cfg->format, cfg->pucch2_drs_bits, &z_m_1); + if (cfg->format == SRSRAN_PUCCH_FORMAT_2A || cfg->format == SRSRAN_PUCCH_FORMAT_2B) { + srsran_pucch_format2ab_mod_bits(cfg->format, cfg->pucch2_drs_bits, &z_m_1); } for (uint32_t ns = 2 * sf_idx; ns < 2 * (sf_idx + 1); ns++) { @@ -448,103 +448,103 @@ int srslte_refsignal_dmrs_pucch_gen(srslte_refsignal_ul_t* q, for (uint32_t m = 0; m < N_rs; m++) { uint32_t n_oc = 0; - uint32_t l = srslte_refsignal_dmrs_pucch_symbol(m, cfg->format, q->cell.cp); + uint32_t l = srsran_refsignal_dmrs_pucch_symbol(m, cfg->format, q->cell.cp); // Add cyclic prefix alpha float alpha = 0.0; - if (cfg->format < SRSLTE_PUCCH_FORMAT_2) { - alpha = srslte_pucch_alpha_format1(q->n_cs_cell, cfg, q->cell.cp, true, ns, l, &n_oc, NULL); + if (cfg->format < SRSRAN_PUCCH_FORMAT_2) { + alpha = srsran_pucch_alpha_format1(q->n_cs_cell, cfg, q->cell.cp, true, ns, l, &n_oc, NULL); } else { - alpha = srslte_pucch_alpha_format2(q->n_cs_cell, cfg, ns, l); + alpha = srsran_pucch_alpha_format2(q->n_cs_cell, cfg, ns, l); } // Choose number of symbols and orthogonal sequence from Tables 5.5.2.2.1-1 to -3 float* w = NULL; switch (cfg->format) { - case SRSLTE_PUCCH_FORMAT_1: - case SRSLTE_PUCCH_FORMAT_1A: - case SRSLTE_PUCCH_FORMAT_1B: - if (SRSLTE_CP_ISNORM(q->cell.cp)) { + case SRSRAN_PUCCH_FORMAT_1: + case SRSRAN_PUCCH_FORMAT_1A: + case SRSRAN_PUCCH_FORMAT_1B: + if (SRSRAN_CP_ISNORM(q->cell.cp)) { w = w_arg_pucch_format1_cpnorm[n_oc]; } else { w = w_arg_pucch_format1_cpext[n_oc]; } break; - case SRSLTE_PUCCH_FORMAT_2: - case SRSLTE_PUCCH_FORMAT_3: - if (SRSLTE_CP_ISNORM(q->cell.cp)) { + case SRSRAN_PUCCH_FORMAT_2: + case SRSRAN_PUCCH_FORMAT_3: + if (SRSRAN_CP_ISNORM(q->cell.cp)) { w = w_arg_pucch_format2_cpnorm; } else { w = w_arg_pucch_format2_cpext; } break; - case SRSLTE_PUCCH_FORMAT_2A: - case SRSLTE_PUCCH_FORMAT_2B: + case SRSRAN_PUCCH_FORMAT_2A: + case SRSRAN_PUCCH_FORMAT_2B: w = w_arg_pucch_format2_cpnorm; break; default: ERROR("DMRS Generator: Unsupported format %d", cfg->format); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - cf_t* r_sequence = &r_pucch[(ns % 2) * SRSLTE_NRE * N_rs + m * SRSLTE_NRE]; - srslte_zc_sequence_generate_lte(u, 0, alpha, 1, r_sequence); + cf_t* r_sequence = &r_pucch[(ns % 2) * SRSRAN_NRE * N_rs + m * SRSRAN_NRE]; + srsran_zc_sequence_generate_lte(u, 0, alpha, 1, r_sequence); cf_t z_m = cexpf(I * w[m]); if (m == 1) { z_m *= z_m_1; } - srslte_vec_sc_prod_ccc(r_sequence, z_m, r_sequence, SRSLTE_NRE); + srsran_vec_sc_prod_ccc(r_sequence, z_m, r_sequence, SRSRAN_NRE); } } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } -int srslte_refsignal_dmrs_pucch_cp(srslte_refsignal_ul_t* q, - srslte_pucch_cfg_t* cfg, +int srsran_refsignal_dmrs_pucch_cp(srsran_refsignal_ul_t* q, + srsran_pucch_cfg_t* cfg, cf_t* source, cf_t* dest, bool source_is_grid) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q && source && dest) { - uint32_t nsymbols = SRSLTE_CP_ISNORM(q->cell.cp) ? SRSLTE_CP_NORM_NSYMB : SRSLTE_CP_EXT_NSYMB; + uint32_t nsymbols = SRSRAN_CP_ISNORM(q->cell.cp) ? SRSRAN_CP_NORM_NSYMB : SRSRAN_CP_EXT_NSYMB; - uint32_t N_rs = srslte_refsignal_dmrs_N_rs(cfg->format, q->cell.cp); + uint32_t N_rs = srsran_refsignal_dmrs_N_rs(cfg->format, q->cell.cp); for (uint32_t ns = 0; ns < 2; ns++) { // Determine n_prb - uint32_t n_prb = srslte_pucch_n_prb(&q->cell, cfg, ns); + uint32_t n_prb = srsran_pucch_n_prb(&q->cell, cfg, ns); for (uint32_t i = 0; i < N_rs; i++) { - uint32_t l = srslte_refsignal_dmrs_pucch_symbol(i, cfg->format, q->cell.cp); + uint32_t l = srsran_refsignal_dmrs_pucch_symbol(i, cfg->format, q->cell.cp); if (!source_is_grid) { - memcpy(&dest[SRSLTE_RE_IDX(q->cell.nof_prb, l + ns * nsymbols, n_prb * SRSLTE_NRE)], - &source[ns * N_rs * SRSLTE_NRE + i * SRSLTE_NRE], - SRSLTE_NRE * sizeof(cf_t)); + memcpy(&dest[SRSRAN_RE_IDX(q->cell.nof_prb, l + ns * nsymbols, n_prb * SRSRAN_NRE)], + &source[ns * N_rs * SRSRAN_NRE + i * SRSRAN_NRE], + SRSRAN_NRE * sizeof(cf_t)); } else { - memcpy(&dest[ns * N_rs * SRSLTE_NRE + i * SRSLTE_NRE], - &source[SRSLTE_RE_IDX(q->cell.nof_prb, l + ns * nsymbols, n_prb * SRSLTE_NRE)], - SRSLTE_NRE * sizeof(cf_t)); + memcpy(&dest[ns * N_rs * SRSRAN_NRE + i * SRSRAN_NRE], + &source[SRSRAN_RE_IDX(q->cell.nof_prb, l + ns * nsymbols, n_prb * SRSRAN_NRE)], + SRSRAN_NRE * sizeof(cf_t)); } } } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } /* Maps PUCCH DMRS to the physical resources as defined in 5.5.2.2.2 in 36.211 */ -int srslte_refsignal_dmrs_pucch_put(srslte_refsignal_ul_t* q, srslte_pucch_cfg_t* cfg, cf_t* r_pucch, cf_t* output) +int srsran_refsignal_dmrs_pucch_put(srsran_refsignal_ul_t* q, srsran_pucch_cfg_t* cfg, cf_t* r_pucch, cf_t* output) { - return srslte_refsignal_dmrs_pucch_cp(q, cfg, r_pucch, output, false); + return srsran_refsignal_dmrs_pucch_cp(q, cfg, r_pucch, output, false); } /* Gets PUCCH DMRS from the physical resources as defined in 5.5.2.2.2 in 36.211 */ -int srslte_refsignal_dmrs_pucch_get(srslte_refsignal_ul_t* q, srslte_pucch_cfg_t* cfg, cf_t* input, cf_t* r_pucch) +int srsran_refsignal_dmrs_pucch_get(srsran_refsignal_ul_t* q, srsran_pucch_cfg_t* cfg, cf_t* input, cf_t* r_pucch) { - return srslte_refsignal_dmrs_pucch_cp(q, cfg, input, r_pucch, true); + return srsran_refsignal_dmrs_pucch_cp(q, cfg, input, r_pucch, true); } static uint32_t T_srs_table(uint32_t I_srs) @@ -577,7 +577,7 @@ static uint32_t T_srs_table(uint32_t I_srs) * configuration index), as defined in Section 8.1 of 36.213. * Returns 0 if no SRS shall be transmitted or a negative number if error. */ -int srslte_refsignal_srs_send_ue(uint32_t I_srs, uint32_t tti) +int srsran_refsignal_srs_send_ue(uint32_t I_srs, uint32_t tti) { if (I_srs < 1024 && tti < 10240) { uint32_t Toffset = 0; @@ -607,23 +607,23 @@ int srslte_refsignal_srs_send_ue(uint32_t I_srs, uint32_t tti) return 0; } } else { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } } // Shortened PUCCH happen in every cell-specific SRS subframes for Format 1/1a/1b -void srslte_refsignal_srs_pucch_shortened(srslte_refsignal_ul_t* q, - srslte_ul_sf_cfg_t* sf, - srslte_refsignal_srs_cfg_t* srs_cfg, - srslte_pucch_cfg_t* pucch_cfg) +void srsran_refsignal_srs_pucch_shortened(srsran_refsignal_ul_t* q, + srsran_ul_sf_cfg_t* sf, + srsran_refsignal_srs_cfg_t* srs_cfg, + srsran_pucch_cfg_t* pucch_cfg) { bool shortened = false; - if (srs_cfg->configured && pucch_cfg->format < SRSLTE_PUCCH_FORMAT_2) { + if (srs_cfg->configured && pucch_cfg->format < SRSRAN_PUCCH_FORMAT_2) { shortened = false; // If CQI is not transmitted, PUCCH will be normal unless ACK/NACK and SRS simultaneous transmission is enabled if (srs_cfg->simul_ack) { // If simultaneous ACK and SRS is enabled, PUCCH is shortened in cell-specific SRS subframes - if (srslte_refsignal_srs_send_cs(srs_cfg->subframe_config, sf->tti % 10) == 1) { + if (srsran_refsignal_srs_send_cs(srs_cfg->subframe_config, sf->tti % 10) == 1) { shortened = true; } } @@ -631,10 +631,10 @@ void srslte_refsignal_srs_pucch_shortened(srslte_refsignal_ul_t* q, sf->shortened = shortened; } -void srslte_refsignal_srs_pusch_shortened(srslte_refsignal_ul_t* q, - srslte_ul_sf_cfg_t* sf, - srslte_refsignal_srs_cfg_t* srs_cfg, - srslte_pusch_cfg_t* pusch_cfg) +void srsran_refsignal_srs_pusch_shortened(srsran_refsignal_ul_t* q, + srsran_ul_sf_cfg_t* sf, + srsran_refsignal_srs_cfg_t* srs_cfg, + srsran_pusch_cfg_t* pusch_cfg) { bool shortened = false; @@ -649,12 +649,12 @@ void srslte_refsignal_srs_pusch_shortened(srslte_refsignal_ul_t* q, if (srs_cfg->configured) { // If UE-specific SRS is configured, PUSCH is shortened every time UE transmits SRS even if overlaping in the same // RB or not - if (srslte_refsignal_srs_send_cs(srs_cfg->subframe_config, sf->tti % 10) == 1 && - srslte_refsignal_srs_send_ue(srs_cfg->I_srs, sf->tti) == 1) { + if (srsran_refsignal_srs_send_cs(srs_cfg->subframe_config, sf->tti % 10) == 1 && + srsran_refsignal_srs_send_ue(srs_cfg->I_srs, sf->tti) == 1) { shortened = true; /* If RBs are contiguous, PUSCH is not shortened */ - uint32_t k0_srs = srslte_refsignal_srs_rb_start_cs(srs_cfg->bw_cfg, q->cell.nof_prb); - uint32_t nrb_srs = srslte_refsignal_srs_rb_L_cs(srs_cfg->bw_cfg, q->cell.nof_prb); + uint32_t k0_srs = srsran_refsignal_srs_rb_start_cs(srs_cfg->bw_cfg, q->cell.nof_prb); + uint32_t nrb_srs = srsran_refsignal_srs_rb_L_cs(srs_cfg->bw_cfg, q->cell.nof_prb); for (uint32_t ns = 0; ns < 2 && shortened; ns++) { if (pusch_cfg->grant.n_prb_tilde[ns] == k0_srs + nrb_srs || // If PUSCH is contiguous on the right-hand side of SRS @@ -668,9 +668,9 @@ void srslte_refsignal_srs_pusch_shortened(srslte_refsignal_ul_t* q, // If not coincides with UE transmission. PUSCH shall be shortened if cell-specific SRS transmission RB // coincides with PUSCH allocated RB if (!shortened) { - if (srslte_refsignal_srs_send_cs(srs_cfg->subframe_config, sf->tti % 10) == 1) { - uint32_t k0_srs = srslte_refsignal_srs_rb_start_cs(srs_cfg->bw_cfg, q->cell.nof_prb); - uint32_t nrb_srs = srslte_refsignal_srs_rb_L_cs(srs_cfg->bw_cfg, q->cell.nof_prb); + if (srsran_refsignal_srs_send_cs(srs_cfg->subframe_config, sf->tti % 10) == 1) { + uint32_t k0_srs = srsran_refsignal_srs_rb_start_cs(srs_cfg->bw_cfg, q->cell.nof_prb); + uint32_t nrb_srs = srsran_refsignal_srs_rb_L_cs(srs_cfg->bw_cfg, q->cell.nof_prb); for (uint32_t ns = 0; ns < 2 && !shortened; ns++) { if ((pusch_cfg->grant.n_prb_tilde[ns] >= k0_srs && pusch_cfg->grant.n_prb_tilde[ns] < k0_srs + nrb_srs) || (pusch_cfg->grant.n_prb_tilde[ns] + pusch_cfg->grant.L_prb > k0_srs && @@ -690,7 +690,7 @@ void srslte_refsignal_srs_pusch_shortened(srslte_refsignal_ul_t* q, * as defined in Section 5.5.3.3 of 36.211. Returns 0 if no SRS shall be transmitted or a negative * number if error. */ -int srslte_refsignal_srs_send_cs(uint32_t subframe_config, uint32_t sf_idx) +int srsran_refsignal_srs_send_cs(uint32_t subframe_config, uint32_t sf_idx) { if (subframe_config < 15 && sf_idx < 10) { uint32_t tsfc = T_sfc[subframe_config]; @@ -734,7 +734,7 @@ int srslte_refsignal_srs_send_cs(uint32_t subframe_config, uint32_t sf_idx) return 0; } } else { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } } @@ -752,7 +752,7 @@ static uint32_t srsbwtable_idx(uint32_t nof_prb) } /* Returns start of common SRS BW region */ -uint32_t srslte_refsignal_srs_rb_start_cs(uint32_t bw_cfg, uint32_t nof_prb) +uint32_t srsran_refsignal_srs_rb_start_cs(uint32_t bw_cfg, uint32_t nof_prb) { if (bw_cfg < 8) { return nof_prb / 2 - m_srs_b[srsbwtable_idx(nof_prb)][0][bw_cfg] / 2; @@ -761,7 +761,7 @@ uint32_t srslte_refsignal_srs_rb_start_cs(uint32_t bw_cfg, uint32_t nof_prb) } /* Returns number of RB defined for the cell-specific SRS */ -uint32_t srslte_refsignal_srs_rb_L_cs(uint32_t bw_cfg, uint32_t nof_prb) +uint32_t srsran_refsignal_srs_rb_L_cs(uint32_t bw_cfg, uint32_t nof_prb) { if (bw_cfg < 8) { return m_srs_b[srsbwtable_idx(nof_prb)][0][bw_cfg]; @@ -769,7 +769,7 @@ uint32_t srslte_refsignal_srs_rb_L_cs(uint32_t bw_cfg, uint32_t nof_prb) return 0; } -static uint32_t srs_Fb(srslte_refsignal_srs_cfg_t* cfg, uint32_t b, uint32_t nof_prb, uint32_t tti) +static uint32_t srs_Fb(srsran_refsignal_srs_cfg_t* cfg, uint32_t b, uint32_t nof_prb, uint32_t tti) { uint32_t Fb = 0; uint32_t T = T_srs_table(cfg->I_srs); @@ -792,15 +792,15 @@ static uint32_t srs_Fb(srslte_refsignal_srs_cfg_t* cfg, uint32_t b, uint32_t nof } /* Returns k0: frequency-domain starting position for ue-specific SRS */ -static uint32_t srs_k0_ue(srslte_refsignal_srs_cfg_t* cfg, uint32_t nof_prb, uint32_t tti) +static uint32_t srs_k0_ue(srsran_refsignal_srs_cfg_t* cfg, uint32_t nof_prb, uint32_t tti) { if (cfg->bw_cfg < 8 && cfg->B < 4 && cfg->k_tc < 2) { - uint32_t k0p = srslte_refsignal_srs_rb_start_cs(cfg->bw_cfg, nof_prb) * SRSLTE_NRE + cfg->k_tc; + uint32_t k0p = srsran_refsignal_srs_rb_start_cs(cfg->bw_cfg, nof_prb) * SRSRAN_NRE + cfg->k_tc; uint32_t k0 = k0p; uint32_t nb = 0; for (int b = 0; b <= cfg->B; b++) { uint32_t m_srs = m_srs_b[srsbwtable_idx(nof_prb)][b][cfg->bw_cfg]; - uint32_t m_sc = m_srs * SRSLTE_NRE / 2; + uint32_t m_sc = m_srs * SRSRAN_NRE / 2; if (b <= cfg->b_hop) { nb = (4 * cfg->n_rrc / m_srs) % Nb[srsbwtable_idx(nof_prb)][b][cfg->bw_cfg]; } else { @@ -814,101 +814,101 @@ static uint32_t srs_k0_ue(srslte_refsignal_srs_cfg_t* cfg, uint32_t nof_prb, uin return 0; } -uint32_t srslte_refsignal_srs_M_sc(srslte_refsignal_ul_t* q, srslte_refsignal_srs_cfg_t* cfg) +uint32_t srsran_refsignal_srs_M_sc(srsran_refsignal_ul_t* q, srsran_refsignal_srs_cfg_t* cfg) { - return m_srs_b[srsbwtable_idx(q->cell.nof_prb)][cfg->B][cfg->bw_cfg] * SRSLTE_NRE / 2; + return m_srs_b[srsbwtable_idx(q->cell.nof_prb)][cfg->B][cfg->bw_cfg] * SRSRAN_NRE / 2; } -int srslte_refsignal_srs_pregen(srslte_refsignal_ul_t* q, - srslte_refsignal_srs_pregen_t* pregen, - srslte_refsignal_srs_cfg_t* cfg, - srslte_refsignal_dmrs_pusch_cfg_t* dmrs) +int srsran_refsignal_srs_pregen(srsran_refsignal_ul_t* q, + srsran_refsignal_srs_pregen_t* pregen, + srsran_refsignal_srs_cfg_t* cfg, + srsran_refsignal_dmrs_pusch_cfg_t* dmrs) { - uint32_t M_sc = srslte_refsignal_srs_M_sc(q, cfg); - for (uint32_t sf_idx = 0; sf_idx < SRSLTE_NOF_SF_X_FRAME; sf_idx++) { - pregen->r[sf_idx] = srslte_vec_cf_malloc(2 * M_sc); + uint32_t M_sc = srsran_refsignal_srs_M_sc(q, cfg); + for (uint32_t sf_idx = 0; sf_idx < SRSRAN_NOF_SF_X_FRAME; sf_idx++) { + pregen->r[sf_idx] = srsran_vec_cf_malloc(2 * M_sc); if (pregen->r[sf_idx]) { - if (srslte_refsignal_srs_gen(q, cfg, dmrs, sf_idx, pregen->r[sf_idx])) { - return SRSLTE_ERROR; + if (srsran_refsignal_srs_gen(q, cfg, dmrs, sf_idx, pregen->r[sf_idx])) { + return SRSRAN_ERROR; } } else { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -void srslte_refsignal_srs_pregen_free(srslte_refsignal_ul_t* q, srslte_refsignal_srs_pregen_t* pregen) +void srsran_refsignal_srs_pregen_free(srsran_refsignal_ul_t* q, srsran_refsignal_srs_pregen_t* pregen) { - for (uint32_t sf_idx = 0; sf_idx < SRSLTE_NOF_SF_X_FRAME; sf_idx++) { + for (uint32_t sf_idx = 0; sf_idx < SRSRAN_NOF_SF_X_FRAME; sf_idx++) { if (pregen->r[sf_idx]) { free(pregen->r[sf_idx]); } } } -int srslte_refsignal_srs_pregen_put(srslte_refsignal_ul_t* q, - srslte_refsignal_srs_pregen_t* pregen, - srslte_refsignal_srs_cfg_t* cfg, +int srsran_refsignal_srs_pregen_put(srsran_refsignal_ul_t* q, + srsran_refsignal_srs_pregen_t* pregen, + srsran_refsignal_srs_cfg_t* cfg, uint32_t tti, cf_t* sf_symbols) { - return srslte_refsignal_srs_put(q, cfg, tti, pregen->r[tti % SRSLTE_NOF_SF_X_FRAME], sf_symbols); + return srsran_refsignal_srs_put(q, cfg, tti, pregen->r[tti % SRSRAN_NOF_SF_X_FRAME], sf_symbols); } /* Genearte SRS signal as defined in Section 5.5.3.1 */ -int srslte_refsignal_srs_gen(srslte_refsignal_ul_t* q, - srslte_refsignal_srs_cfg_t* cfg, - srslte_refsignal_dmrs_pusch_cfg_t* pusch_cfg, +int srsran_refsignal_srs_gen(srsran_refsignal_ul_t* q, + srsran_refsignal_srs_cfg_t* cfg, + srsran_refsignal_dmrs_pusch_cfg_t* pusch_cfg, uint32_t sf_idx, cf_t* r_srs) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (r_srs && q && cfg && pusch_cfg) { - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; - uint32_t M_sc = srslte_refsignal_srs_M_sc(q, cfg); + uint32_t M_sc = srsran_refsignal_srs_M_sc(q, cfg); for (uint32_t ns = 2 * sf_idx; ns < 2 * (sf_idx + 1); ns++) { float alpha = 2 * M_PI * cfg->n_srs / 8; - compute_r(q, pusch_cfg, M_sc / SRSLTE_NRE, ns, 0, alpha, &r_srs[(ns % 2) * M_sc]); + compute_r(q, pusch_cfg, M_sc / SRSRAN_NRE, ns, 0, alpha, &r_srs[(ns % 2) * M_sc]); } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } -int srslte_refsignal_srs_put(srslte_refsignal_ul_t* q, - srslte_refsignal_srs_cfg_t* cfg, +int srsran_refsignal_srs_put(srsran_refsignal_ul_t* q, + srsran_refsignal_srs_cfg_t* cfg, uint32_t tti, cf_t* r_srs, cf_t* sf_symbols) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (r_srs && q && sf_symbols && cfg) { - uint32_t M_sc = srslte_refsignal_srs_M_sc(q, cfg); + uint32_t M_sc = srsran_refsignal_srs_M_sc(q, cfg); uint32_t k0 = srs_k0_ue(cfg, q->cell.nof_prb, tti); for (int i = 0; i < M_sc; i++) { - sf_symbols[SRSLTE_RE_IDX(q->cell.nof_prb, 2 * SRSLTE_CP_NSYMB(q->cell.cp) - 1, k0 + 2 * i)] = r_srs[i]; + sf_symbols[SRSRAN_RE_IDX(q->cell.nof_prb, 2 * SRSRAN_CP_NSYMB(q->cell.cp) - 1, k0 + 2 * i)] = r_srs[i]; } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } -int srslte_refsignal_srs_get(srslte_refsignal_ul_t* q, - srslte_refsignal_srs_cfg_t* cfg, +int srsran_refsignal_srs_get(srsran_refsignal_ul_t* q, + srsran_refsignal_srs_cfg_t* cfg, uint32_t tti, cf_t* r_srs, cf_t* sf_symbols) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (r_srs && q && sf_symbols && cfg) { - uint32_t M_sc = srslte_refsignal_srs_M_sc(q, cfg); + uint32_t M_sc = srsran_refsignal_srs_M_sc(q, cfg); uint32_t k0 = srs_k0_ue(cfg, q->cell.nof_prb, tti); for (int i = 0; i < M_sc; i++) { - r_srs[i] = sf_symbols[SRSLTE_RE_IDX(q->cell.nof_prb, 2 * SRSLTE_CP_NSYMB(q->cell.cp) - 1, k0 + 2 * i)]; + r_srs[i] = sf_symbols[SRSRAN_RE_IDX(q->cell.nof_prb, 2 * SRSRAN_CP_NSYMB(q->cell.cp) - 1, k0 + 2 * i)]; } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } diff --git a/lib/src/phy/ch_estimation/test/CMakeLists.txt b/lib/src/phy/ch_estimation/test/CMakeLists.txt index 5ef9996ef..8e2fcca68 100644 --- a/lib/src/phy/ch_estimation/test/CMakeLists.txt +++ b/lib/src/phy/ch_estimation/test/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -13,7 +13,7 @@ set(CTEST_LABELS "lib;phy;chest") ######################################################################## add_executable(chest_test_dl chest_test_dl.c) -target_link_libraries(chest_test_dl srslte_phy) +target_link_libraries(chest_test_dl srsran_phy) add_lte_test(chest_test_dl_cellid0 chest_test_dl -c 0) add_lte_test(chest_test_dl_cellid1 chest_test_dl -c 1) @@ -29,10 +29,10 @@ add_lte_test(chest_test_dl_cellid2_50prb chest_test_dl -c 2 -r 50) ######################################################################## add_executable(chest_test_ul chest_test_ul.c) -target_link_libraries(chest_test_ul srslte_phy srslte_common) +target_link_libraries(chest_test_ul srsran_phy srsran_common) add_executable(refsignal_ul_test_all refsignal_ul_test.c) -target_link_libraries(refsignal_ul_test_all srslte_phy srslte_common) +target_link_libraries(refsignal_ul_test_all srsran_phy srsran_common) add_lte_test(chest_test_ul_cellid0 chest_test_ul -c 0 -r 50) add_lte_test(chest_test_ul_cellid1 chest_test_ul -c 1 -r 50) @@ -43,7 +43,7 @@ add_lte_test(chest_test_ul_cellid2 chest_test_ul -c 2 -r 50) ######################################################################## add_executable(chest_test_srs chest_test_srs.c) -target_link_libraries(chest_test_srs srslte_phy srslte_common) +target_link_libraries(chest_test_srs srsran_phy srsran_common) foreach (cell_n_prb 6 15 25 50 75 100) add_lte_test(chest_test_srs_${cell_n_prb} chest_test_srs -c 2 -r ${cell_n_prb}) @@ -55,7 +55,7 @@ endforeach(cell_n_prb 6 15 25 50 75 100) ######################################################################## add_executable(chest_nbiot_test_dl chest_nbiot_test_dl.c) -target_link_libraries(chest_nbiot_test_dl srslte_phy) +target_link_libraries(chest_nbiot_test_dl srsran_phy) add_lte_test(chest_nbiot_test_dl chest_nbiot_test_dl) @@ -65,7 +65,7 @@ add_lte_test(chest_nbiot_test_dl chest_nbiot_test_dl) ######################################################################## add_executable(chest_test_sl chest_test_sl.c) -target_link_libraries(chest_test_sl srslte_phy) +target_link_libraries(chest_test_sl srsran_phy) add_lte_test(chest_test_sl_psbch chest_test_sl) @@ -75,7 +75,7 @@ add_lte_test(chest_test_sl_psbch chest_test_sl) ######################################################################## add_executable(dmrs_pdsch_test dmrs_pdsch_test.c) -target_link_libraries(dmrs_pdsch_test srslte_phy) +target_link_libraries(dmrs_pdsch_test srsran_phy) add_lte_test(dmrs_pdsch_test dmrs_pdsch_test) @@ -85,7 +85,7 @@ add_lte_test(dmrs_pdsch_test dmrs_pdsch_test) ######################################################################## add_executable(dmrs_pdcch_test dmrs_pdcch_test.c) -target_link_libraries(dmrs_pdcch_test srslte_phy) +target_link_libraries(dmrs_pdcch_test srsran_phy) add_lte_test(dmrs_pdcch_test dmrs_pdcch_test) @@ -95,7 +95,7 @@ add_lte_test(dmrs_pdcch_test dmrs_pdcch_test) ######################################################################## add_executable(csi_rs_test csi_rs_test.c) -target_link_libraries(csi_rs_test srslte_phy) +target_link_libraries(csi_rs_test srsran_phy) add_lte_test(csi_rs_test csi_rs_test -o 3 -S 0 -L 150 -f 3 -p 15) diff --git a/lib/src/phy/ch_estimation/test/chest_nbiot_test_dl.c b/lib/src/phy/ch_estimation/test/chest_nbiot_test_dl.c index ea3b5f493..07cc93110 100644 --- a/lib/src/phy/ch_estimation/test/chest_nbiot_test_dl.c +++ b/lib/src/phy/ch_estimation/test/chest_nbiot_test_dl.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -16,12 +16,12 @@ #include #include -#include "srslte/phy/ch_estimation/chest_dl_nbiot.h" -#include "srslte/phy/channel/ch_awgn.h" -#include "srslte/phy/dft/ofdm.h" -#include "srslte/phy/mimo/precoding.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/ch_estimation/chest_dl_nbiot.h" +#include "srsran/phy/channel/ch_awgn.h" +#include "srsran/phy/dft/ofdm.h" +#include "srsran/phy/mimo/precoding.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" #define TESTASSERT(cond) \ { \ @@ -31,7 +31,7 @@ } \ } -srslte_nbiot_cell_t cell = {.base = {.nof_prb = 1, .cp = SRSLTE_CP_NORM, .id = 0}, +srsran_nbiot_cell_t cell = {.base = {.nof_prb = 1, .cp = SRSRAN_CP_NORM, .id = 0}, .base.nof_ports = 1, .nbiot_prb = 0, .n_id_ncell = 0}; @@ -79,7 +79,7 @@ void parse_args(int argc, char** argv) snr_db = strtof(argv[optind], NULL); break; case 'v': - srslte_verbose++; + srsran_verbose++; break; default: usage(argv[0]); @@ -90,114 +90,114 @@ void parse_args(int argc, char** argv) int main(int argc, char** argv) { - srslte_chest_dl_nbiot_t est = {}; - int ret = SRSLTE_ERROR; + srsran_chest_dl_nbiot_t est = {}; + int ret = SRSRAN_ERROR; cf_t * input = NULL, *ce = NULL, *h = NULL, *output = NULL, *sf_buffer = NULL; parse_args(argc, argv); - uint32_t num_re = 2 * cell.base.nof_prb * SRSLTE_NRE * SRSLTE_CP_NSYMB(cell.base.cp); + uint32_t num_re = 2 * cell.base.nof_prb * SRSRAN_NRE * SRSRAN_CP_NSYMB(cell.base.cp); - input = srslte_vec_cf_malloc(num_re); + input = srsran_vec_cf_malloc(num_re); if (!input) { - perror("srslte_vec_malloc"); + perror("srsran_vec_malloc"); goto do_exit; } - output = srslte_vec_cf_malloc(num_re); + output = srsran_vec_cf_malloc(num_re); if (!output) { - perror("srslte_vec_malloc"); + perror("srsran_vec_malloc"); goto do_exit; } - sf_buffer = srslte_vec_cf_malloc(2U * SRSLTE_SLOT_LEN(srslte_symbol_sz(cell.base.nof_prb))); + sf_buffer = srsran_vec_cf_malloc(2U * SRSRAN_SLOT_LEN(srsran_symbol_sz(cell.base.nof_prb))); if (!sf_buffer) { perror("malloc"); return -1; } - h = srslte_vec_cf_malloc(num_re); + h = srsran_vec_cf_malloc(num_re); if (!h) { - perror("srslte_vec_malloc"); + perror("srsran_vec_malloc"); goto do_exit; } - ce = srslte_vec_cf_malloc(num_re); + ce = srsran_vec_cf_malloc(num_re); if (!ce) { - perror("srslte_vec_malloc"); + perror("srsran_vec_malloc"); goto do_exit; } for (int j = 0; j < num_re; j++) { ce[j] = 1; } - if (SRSLTE_VERBOSE_ISDEBUG()) { + if (SRSRAN_VERBOSE_ISDEBUG()) { DEBUG("SAVED FILE chest_start.bin: channel estimates start"); - srslte_vec_save_file("chest_start.bin", ce, num_re * sizeof(cf_t)); + srsran_vec_save_file("chest_start.bin", ce, num_re * sizeof(cf_t)); } - if (srslte_chest_dl_nbiot_init(&est, SRSLTE_NBIOT_MAX_PRB)) { + if (srsran_chest_dl_nbiot_init(&est, SRSRAN_NBIOT_MAX_PRB)) { fprintf(stderr, "Error initializing equalizer\n"); goto do_exit; } - if (srslte_chest_dl_nbiot_set_cell(&est, cell) != SRSLTE_SUCCESS) { + if (srsran_chest_dl_nbiot_set_cell(&est, cell) != SRSRAN_SUCCESS) { fprintf(stderr, "Error setting channel estimator's cell configuration\n"); return -1; } for (int sf_idx = 0; sf_idx < 1; sf_idx++) { for (int n_port = 0; n_port < cell.base.nof_ports; n_port++) { - srslte_vec_cf_zero(input, num_re); + srsran_vec_cf_zero(input, num_re); for (int i = 0; i < num_re; i++) { input[i] = 0.5 - rand() / RAND_MAX + I * (0.5 - rand() / RAND_MAX); } - srslte_vec_cf_zero(ce, num_re); - srslte_vec_cf_zero(h, num_re); + srsran_vec_cf_zero(ce, num_re); + srsran_vec_cf_zero(h, num_re); - srslte_ofdm_t ifft, fft; + srsran_ofdm_t ifft, fft; if (have_ofdm) { - if (srslte_ofdm_tx_init(&ifft, cell.base.cp, input, sf_buffer, cell.base.nof_prb)) { + if (srsran_ofdm_tx_init(&ifft, cell.base.cp, input, sf_buffer, cell.base.nof_prb)) { fprintf(stderr, "Error initializing IFFT\n"); return -1; } - if (srslte_ofdm_rx_init(&fft, cell.base.cp, sf_buffer, input, cell.base.nof_prb)) { + if (srsran_ofdm_rx_init(&fft, cell.base.cp, sf_buffer, input, cell.base.nof_prb)) { fprintf(stderr, "Error initializing FFT\n"); return -1; } - srslte_ofdm_set_normalize(&ifft, true); - srslte_ofdm_set_normalize(&fft, true); + srsran_ofdm_set_normalize(&ifft, true); + srsran_ofdm_set_normalize(&fft, true); } - srslte_refsignal_nrs_put_sf(cell, n_port, est.nrs_signal.pilots[0][0], input); + srsran_refsignal_nrs_put_sf(cell, n_port, est.nrs_signal.pilots[0][0], input); if (have_channel) { // Add noise - float std_dev = srslte_convert_dB_to_amplitude(-(snr_db + 3.0f)) * 0.1f; - srslte_ch_awgn_c(est.pilot_recv_signal, est.pilot_recv_signal, std_dev, SRSLTE_REFSIGNAL_MAX_NUM_SF(1)); + float std_dev = srsran_convert_dB_to_amplitude(-(snr_db + 3.0f)) * 0.1f; + srsran_ch_awgn_c(est.pilot_recv_signal, est.pilot_recv_signal, std_dev, SRSRAN_REFSIGNAL_MAX_NUM_SF(1)); } if (have_ofdm) { - srslte_ofdm_tx_sf(&ifft); - srslte_ofdm_rx_sf(&fft); + srsran_ofdm_tx_sf(&ifft); + srsran_ofdm_rx_sf(&fft); } // check length of LTE CSR signal - for (int i = 0; i < SRSLTE_NBIOT_MAX_PORTS; i++) { - TESTASSERT(srslte_refsignal_nbiot_cs_nof_re(&cell, i) == 8); + for (int i = 0; i < SRSRAN_NBIOT_MAX_PORTS; i++) { + TESTASSERT(srsran_refsignal_nbiot_cs_nof_re(&cell, i) == 8); } - srslte_chest_dl_nbiot_estimate_port(&est, input, ce, sf_idx, n_port); + srsran_chest_dl_nbiot_estimate_port(&est, input, ce, sf_idx, n_port); - float rsrq = srslte_chest_dl_nbiot_get_rsrq(&est); - float rsrp = srslte_chest_dl_nbiot_get_rsrp(&est); - float noise = srslte_chest_dl_nbiot_get_noise_estimate(&est); - float snr = srslte_chest_dl_nbiot_get_snr(&est); + float rsrq = srsran_chest_dl_nbiot_get_rsrq(&est); + float rsrp = srsran_chest_dl_nbiot_get_rsrp(&est); + float noise = srsran_chest_dl_nbiot_get_noise_estimate(&est); + float snr = srsran_chest_dl_nbiot_get_snr(&est); DEBUG("rsrq=%4.2f, rsrp=%4.2f, noise=%4.2f, snr=%4.2f", rsrq, rsrp, noise, snr); - if (SRSLTE_VERBOSE_ISDEBUG()) { + if (SRSRAN_VERBOSE_ISDEBUG()) { DEBUG("SAVED FILE chest_final.bin: channel after estimation"); - srslte_vec_save_file("chest_final.bin", ce, num_re * sizeof(cf_t)); + srsran_vec_save_file("chest_final.bin", ce, num_re * sizeof(cf_t)); } // use ZF equalizer - srslte_predecoding_single(input, ce, output, NULL, num_re, 1.0, 0); + srsran_predecoding_single(input, ce, output, NULL, num_re, 1.0, 0); if (!have_channel) { if (memcmp(est.nrs_signal.pilots[0][0], est.pilot_recv_signal, 8) == 0) { @@ -209,15 +209,15 @@ int main(int argc, char** argv) } if (have_ofdm) { - srslte_ofdm_tx_free(&ifft); - srslte_ofdm_rx_free(&fft); + srsran_ofdm_tx_free(&ifft); + srsran_ofdm_rx_free(&fft); } } } - srslte_chest_dl_nbiot_free(&est); + srsran_chest_dl_nbiot_free(&est); - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; do_exit: diff --git a/lib/src/phy/ch_estimation/test/chest_test_dl.c b/lib/src/phy/ch_estimation/test/chest_test_dl.c index c7f2ff203..10b0ed269 100644 --- a/lib/src/phy/ch_estimation/test/chest_test_dl.c +++ b/lib/src/phy/ch_estimation/test/chest_test_dl.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -16,15 +16,15 @@ #include #include -#include "srslte/srslte.h" +#include "srsran/srsran.h" -srslte_cell_t cell = {6, // nof_prb +srsran_cell_t cell = {6, // nof_prb 1, // nof_ports 1000, // cell_id - SRSLTE_CP_NORM, // cyclic prefix - SRSLTE_PHICH_NORM, - SRSLTE_PHICH_R_1_6, - SRSLTE_FDD}; + SRSRAN_CP_NORM, // cyclic prefix + SRSRAN_PHICH_NORM, + SRSRAN_PHICH_R_1_6, + SRSRAN_FDD}; char* output_matlab = NULL; @@ -50,7 +50,7 @@ void parse_args(int argc, char** argv) cell.nof_prb = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'e': - cell.cp = SRSLTE_CP_EXT; + cell.cp = SRSRAN_CP_EXT; break; case 'c': cell.id = (uint32_t)strtol(argv[optind], NULL, 10); @@ -59,7 +59,7 @@ void parse_args(int argc, char** argv) output_matlab = argv[optind]; break; case 'v': - srslte_verbose++; + srsran_verbose++; break; default: usage(argv[0]); @@ -70,7 +70,7 @@ void parse_args(int argc, char** argv) int main(int argc, char** argv) { - srslte_chest_dl_t est; + srsran_chest_dl_t est; cf_t * input = NULL, *ce = NULL, *h = NULL, *output = NULL; int i, j; int ret = -1; @@ -88,26 +88,26 @@ int main(int argc, char** argv) } } - uint32_t num_re = 2 * cell.nof_prb * SRSLTE_NRE * SRSLTE_CP_NSYMB(cell.cp); + uint32_t num_re = 2 * cell.nof_prb * SRSRAN_NRE * SRSRAN_CP_NSYMB(cell.cp); - input = srslte_vec_cf_malloc(num_re); + input = srsran_vec_cf_malloc(num_re); if (!input) { - perror("srslte_vec_malloc"); + perror("srsran_vec_malloc"); goto do_exit; } - output = srslte_vec_cf_malloc(num_re); + output = srsran_vec_cf_malloc(num_re); if (!output) { - perror("srslte_vec_malloc"); + perror("srsran_vec_malloc"); goto do_exit; } - h = srslte_vec_cf_malloc(num_re); + h = srsran_vec_cf_malloc(num_re); if (!h) { - perror("srslte_vec_malloc"); + perror("srsran_vec_malloc"); goto do_exit; } - ce = srslte_vec_cf_malloc(num_re); + ce = srsran_vec_cf_malloc(num_re); if (!ce) { - perror("srslte_vec_malloc"); + perror("srsran_vec_malloc"); goto do_exit; } @@ -118,53 +118,53 @@ int main(int argc, char** argv) cid = cell.id; max_cid = cell.id; } - if (srslte_chest_dl_init(&est, cell.nof_prb, 1)) { + if (srsran_chest_dl_init(&est, cell.nof_prb, 1)) { ERROR("Error initializing equalizer"); goto do_exit; } while (cid <= max_cid) { cell.id = cid; - if (srslte_chest_dl_set_cell(&est, cell)) { + if (srsran_chest_dl_set_cell(&est, cell)) { ERROR("Error initializing equalizer"); goto do_exit; } for (uint32_t sf_idx = 0; sf_idx < 1; sf_idx++) { - srslte_dl_sf_cfg_t sf_cfg; + srsran_dl_sf_cfg_t sf_cfg; ZERO_OBJECT(sf_cfg); sf_cfg.tti = sf_idx; for (uint32_t n_port = 0; n_port < cell.nof_ports; n_port++) { - srslte_vec_cf_zero(input, num_re); + srsran_vec_cf_zero(input, num_re); for (i = 0; i < num_re; i++) { input[i] = 0.5 - rand() / RAND_MAX + I * (0.5 - rand() / RAND_MAX); } - srslte_vec_cf_zero(ce, num_re); - srslte_vec_cf_zero(h, num_re); + srsran_vec_cf_zero(ce, num_re); + srsran_vec_cf_zero(h, num_re); - srslte_refsignal_cs_put_sf(&est.csr_refs, &sf_cfg, n_port, input); + srsran_refsignal_cs_put_sf(&est.csr_refs, &sf_cfg, n_port, input); - for (i = 0; i < 2 * SRSLTE_CP_NSYMB(cell.cp); i++) { - for (j = 0; j < cell.nof_prb * SRSLTE_NRE; j++) { - float x = -1 + (float)i / SRSLTE_CP_NSYMB(cell.cp) + cosf(2 * M_PI * (float)j / cell.nof_prb / SRSLTE_NRE); - h[i * cell.nof_prb * SRSLTE_NRE + j] = (3 + x) * cexpf(I * x); - input[i * cell.nof_prb * SRSLTE_NRE + j] *= h[i * cell.nof_prb * SRSLTE_NRE + j]; + for (i = 0; i < 2 * SRSRAN_CP_NSYMB(cell.cp); i++) { + for (j = 0; j < cell.nof_prb * SRSRAN_NRE; j++) { + float x = -1 + (float)i / SRSRAN_CP_NSYMB(cell.cp) + cosf(2 * M_PI * (float)j / cell.nof_prb / SRSRAN_NRE); + h[i * cell.nof_prb * SRSRAN_NRE + j] = (3 + x) * cexpf(I * x); + input[i * cell.nof_prb * SRSRAN_NRE + j] *= h[i * cell.nof_prb * SRSRAN_NRE + j]; } } } - srslte_chest_dl_res_t res; + srsran_chest_dl_res_t res; res.ce[0][0] = ce; - cf_t* input_m[SRSLTE_MAX_PORTS]; + cf_t* input_m[SRSRAN_MAX_PORTS]; input_m[0] = input; struct timeval t[3]; gettimeofday(&t[1], NULL); for (int j = 0; j < 100; j++) { - srslte_chest_dl_estimate(&est, &sf_cfg, input_m, &res); + srsran_chest_dl_estimate(&est, &sf_cfg, input_m, &res); } gettimeofday(&t[2], NULL); get_time_interval(t); @@ -172,7 +172,7 @@ int main(int argc, char** argv) gettimeofday(&t[1], NULL); for (int j = 0; j < 100; j++) { - srslte_predecoding_single(input, ce, output, NULL, num_re, 1.0f, 0); + srsran_predecoding_single(input, ce, output, NULL, num_re, 1.0f, 0); } gettimeofday(&t[2], NULL); get_time_interval(t); @@ -187,7 +187,7 @@ int main(int argc, char** argv) gettimeofday(&t[1], NULL); for (int j = 0; j < 100; j++) { - srslte_predecoding_single(input, ce, output, NULL, num_re, 1.0f, res.noise_estimate); + srsran_predecoding_single(input, ce, output, NULL, num_re, 1.0f, res.noise_estimate); } gettimeofday(&t[2], NULL); get_time_interval(t); @@ -206,20 +206,20 @@ int main(int argc, char** argv) if (fmatlab) { fprintf(fmatlab, "input="); - srslte_vec_fprint_c(fmatlab, input, num_re); + srsran_vec_fprint_c(fmatlab, input, num_re); fprintf(fmatlab, ";\n"); fprintf(fmatlab, "h="); - srslte_vec_fprint_c(fmatlab, h, num_re); + srsran_vec_fprint_c(fmatlab, h, num_re); fprintf(fmatlab, ";\n"); fprintf(fmatlab, "ce="); - srslte_vec_fprint_c(fmatlab, ce, num_re); + srsran_vec_fprint_c(fmatlab, ce, num_re); fprintf(fmatlab, ";\n"); } } cid += 10; INFO("cid=%d", cid); } - srslte_chest_dl_free(&est); + srsran_chest_dl_free(&est); ret = 0; do_exit: diff --git a/lib/src/phy/ch_estimation/test/chest_test_sl.c b/lib/src/phy/ch_estimation/test/chest_test_sl.c index 253eea85c..3d68135e0 100644 --- a/lib/src/phy/ch_estimation/test/chest_test_sl.c +++ b/lib/src/phy/ch_estimation/test/chest_test_sl.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -15,12 +15,12 @@ #include #include -#include "srslte/phy/ch_estimation/chest_sl.h" -#include "srslte/phy/common/phy_common_sl.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/ch_estimation/chest_sl.h" +#include "srsran/phy/common/phy_common_sl.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" -srslte_cell_sl_t cell = {.nof_prb = 6, .N_sl_id = 168, .tm = SRSLTE_SIDELINK_TM2, .cp = SRSLTE_CP_NORM}; +srsran_cell_sl_t cell = {.nof_prb = 6, .N_sl_id = 168, .tm = SRSRAN_SIDELINK_TM2, .cp = SRSRAN_CP_NORM}; bool run_psbch_test = true; void usage(char* prog) @@ -42,7 +42,7 @@ void parse_args(int argc, char** argv) cell.nof_prb = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'e': - cell.cp = SRSLTE_CP_EXT; + cell.cp = SRSRAN_CP_EXT; break; case 'c': cell.N_sl_id = (uint32_t)strtol(argv[optind], NULL, 10); @@ -50,16 +50,16 @@ void parse_args(int argc, char** argv) case 't': switch (strtol(argv[optind], NULL, 10)) { case 1: - cell.tm = SRSLTE_SIDELINK_TM1; + cell.tm = SRSRAN_SIDELINK_TM1; break; case 2: - cell.tm = SRSLTE_SIDELINK_TM2; + cell.tm = SRSRAN_SIDELINK_TM2; break; case 3: - cell.tm = SRSLTE_SIDELINK_TM3; + cell.tm = SRSRAN_SIDELINK_TM3; break; case 4: - cell.tm = SRSLTE_SIDELINK_TM4; + cell.tm = SRSRAN_SIDELINK_TM4; break; default: usage(argv[0]); @@ -67,14 +67,14 @@ void parse_args(int argc, char** argv) } break; case 'v': - srslte_verbose++; + srsran_verbose++; break; default: usage(argv[0]); exit(-1); } } - if (cell.cp == SRSLTE_CP_EXT && cell.tm >= SRSLTE_SIDELINK_TM3) { + if (cell.cp == SRSRAN_CP_EXT && cell.tm >= SRSRAN_SIDELINK_TM3) { ERROR("Selected TM does not support extended CP"); usage(argv[0]); exit(-1); @@ -85,33 +85,33 @@ int main(int argc, char** argv) { parse_args(argc, argv); - int sf_n_re = SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp); - cf_t* sf_buffer = srslte_vec_cf_malloc(sf_n_re); + int sf_n_re = SRSRAN_SF_LEN_RE(cell.nof_prb, cell.cp); + cf_t* sf_buffer = srsran_vec_cf_malloc(sf_n_re); bzero(sf_buffer, sizeof(cf_t) * sf_n_re); // Variables init Rx - cf_t* equalized_sf_buffer = srslte_vec_cf_malloc(sf_n_re); + cf_t* equalized_sf_buffer = srsran_vec_cf_malloc(sf_n_re); bzero(equalized_sf_buffer, sizeof(cf_t) * sf_n_re); - cf_t* dmrs_received[SRSLTE_SL_MAX_DMRS_SYMB] = {NULL}; - for (int i = 0; i < SRSLTE_SL_MAX_DMRS_SYMB; i++) { - dmrs_received[i] = srslte_vec_cf_malloc(SRSLTE_NRE * cell.nof_prb); + cf_t* dmrs_received[SRSRAN_SL_MAX_DMRS_SYMB] = {NULL}; + for (int i = 0; i < SRSRAN_SL_MAX_DMRS_SYMB; i++) { + dmrs_received[i] = srsran_vec_cf_malloc(SRSRAN_NRE * cell.nof_prb); } - srslte_sl_comm_resource_pool_t sl_comm_resource_pool = {}; + srsran_sl_comm_resource_pool_t sl_comm_resource_pool = {}; // Variables init Tx - srslte_chest_sl_t q = {}; + srsran_chest_sl_t q = {}; if (run_psbch_test) { // Tx - srslte_chest_sl_init(&q, SRSLTE_SIDELINK_PSBCH, cell, sl_comm_resource_pool); - srslte_chest_sl_put_dmrs(&q, sf_buffer); + srsran_chest_sl_init(&q, SRSRAN_SIDELINK_PSBCH, cell, sl_comm_resource_pool); + srsran_chest_sl_put_dmrs(&q, sf_buffer); // Rx - srslte_chest_sl_ls_estimate_equalize(&q, sf_buffer, equalized_sf_buffer); - srslte_chest_sl_get_dmrs(&q, equalized_sf_buffer, dmrs_received); + srsran_chest_sl_ls_estimate_equalize(&q, sf_buffer, equalized_sf_buffer); + srsran_chest_sl_get_dmrs(&q, equalized_sf_buffer, dmrs_received); // Test // TODO: add proper test @@ -127,7 +127,7 @@ int main(int argc, char** argv) printf("\n"); } - srslte_chest_sl_free(&q); + srsran_chest_sl_free(&q); if (sf_buffer) { free(sf_buffer); @@ -135,11 +135,11 @@ int main(int argc, char** argv) if (equalized_sf_buffer) { free(equalized_sf_buffer); } - for (int i = 0; i < SRSLTE_SL_MAX_DMRS_SYMB; i++) { + for (int i = 0; i < SRSRAN_SL_MAX_DMRS_SYMB; i++) { if (dmrs_received[i]) { free(dmrs_received[i]); } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } \ No newline at end of file diff --git a/lib/src/phy/ch_estimation/test/chest_test_srs.c b/lib/src/phy/ch_estimation/test/chest_test_srs.c index a14d74bc9..8867cb484 100644 --- a/lib/src/phy/ch_estimation/test/chest_test_srs.c +++ b/lib/src/phy/ch_estimation/test/chest_test_srs.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,30 +10,30 @@ * */ -#include "srslte/common/test_common.h" -#include "srslte/srslte.h" +#include "srsran/common/test_common.h" +#include "srsran/srsran.h" #include #include #include #include #include -static srslte_cell_t cell = {6, // nof_prb +static srsran_cell_t cell = {6, // nof_prb 1, // nof_ports 1, // cell_id - SRSLTE_CP_NORM, // cyclic prefix - SRSLTE_PHICH_NORM, - SRSLTE_PHICH_R_1, // PHICH length - SRSLTE_FDD}; + SRSRAN_CP_NORM, // cyclic prefix + SRSRAN_PHICH_NORM, + SRSRAN_PHICH_R_1, // PHICH length + SRSRAN_FDD}; -static srslte_refsignal_dmrs_pusch_cfg_t dmrs_pusch_cfg = {}; -static srslte_refsignal_srs_cfg_t srs_cfg = {}; +static srsran_refsignal_dmrs_pusch_cfg_t dmrs_pusch_cfg = {}; +static srsran_refsignal_srs_cfg_t srs_cfg = {}; static uint32_t test_counter = 0; static float snr_db = 20.0f; static float n0_dbm = 30.0f - 20.0f; -static srslte_channel_awgn_t channel = {}; +static srsran_channel_awgn_t channel = {}; #define CHEST_TEST_SRS_SNR_DB_TOLERANCE 10.0f #define CHEST_TEST_SRS_TA_US_TOLERANCE 0.5f @@ -59,63 +59,63 @@ void usage(char* prog) typedef struct { uint32_t sf_size; - srslte_refsignal_ul_t refsignal_ul; - srslte_refsignal_srs_pregen_t srs_pregen; - srslte_chest_ul_t chest_ul; + srsran_refsignal_ul_t refsignal_ul; + srsran_refsignal_srs_pregen_t srs_pregen; + srsran_chest_ul_t chest_ul; cf_t* sf_symbols; - srslte_chest_ul_res_t chest_ul_res; + srsran_chest_ul_res_t chest_ul_res; } srs_test_context_t; int srs_test_context_init(srs_test_context_t* q) { - q->sf_size = SRSLTE_SF_LEN_RE(SRSLTE_MAX_PRB, cell.cp); + q->sf_size = SRSRAN_SF_LEN_RE(SRSRAN_MAX_PRB, cell.cp); // Set cell - if (srslte_refsignal_ul_set_cell(&q->refsignal_ul, cell) != SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (srsran_refsignal_ul_set_cell(&q->refsignal_ul, cell) != SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } // Pregenerate signals - if (srslte_refsignal_srs_pregen(&q->refsignal_ul, &q->srs_pregen, &srs_cfg, &dmrs_pusch_cfg) != SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (srsran_refsignal_srs_pregen(&q->refsignal_ul, &q->srs_pregen, &srs_cfg, &dmrs_pusch_cfg) != SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } // Allocate buffer - q->sf_symbols = srslte_vec_cf_malloc(q->sf_size); + q->sf_symbols = srsran_vec_cf_malloc(q->sf_size); if (q->sf_symbols == NULL) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Create UL channel estimator - if (srslte_chest_ul_init(&q->chest_ul, SRSLTE_MAX_PRB) != SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (srsran_chest_ul_init(&q->chest_ul, SRSRAN_MAX_PRB) != SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } // Set cell in UL channel estimator - if (srslte_chest_ul_set_cell(&q->chest_ul, cell) != SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (srsran_chest_ul_set_cell(&q->chest_ul, cell) != SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } // Initialise UL channel estimator result - if (srslte_chest_ul_res_init(&q->chest_ul_res, SRSLTE_MAX_PRB) != SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (srsran_chest_ul_res_init(&q->chest_ul_res, SRSRAN_MAX_PRB) != SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } void srs_test_context_free(srs_test_context_t* q) { - srslte_refsignal_srs_pregen_free(&q->refsignal_ul, &q->srs_pregen); - srslte_chest_ul_free(&q->chest_ul); - srslte_chest_ul_res_free(&q->chest_ul_res); + srsran_refsignal_srs_pregen_free(&q->refsignal_ul, &q->srs_pregen); + srsran_chest_ul_free(&q->chest_ul); + srsran_chest_ul_res_free(&q->chest_ul_res); if (q->sf_symbols) { free(q->sf_symbols); } } int srs_test_context_run(srs_test_context_t* q) { - srslte_ul_sf_cfg_t ul_sf_cfg = {}; + srsran_ul_sf_cfg_t ul_sf_cfg = {}; INFO(" TEST: bw_cfg=%d; sf_cfg=%d; B=%d; b_hops=%d; n_srs=%d; I_srs=%d;", srs_cfg.bw_cfg, @@ -126,26 +126,26 @@ int srs_test_context_run(srs_test_context_t* q) srs_cfg.I_srs); // Assert SRS transmission SF - TESTASSERT(srslte_refsignal_srs_send_cs(srs_cfg.subframe_config, ul_sf_cfg.tti) == 1); - TESTASSERT(srslte_refsignal_srs_send_cs(srs_cfg.subframe_config, ul_sf_cfg.tti) == 1); + TESTASSERT(srsran_refsignal_srs_send_cs(srs_cfg.subframe_config, ul_sf_cfg.tti) == 1); + TESTASSERT(srsran_refsignal_srs_send_cs(srs_cfg.subframe_config, ul_sf_cfg.tti) == 1); // Set resource grid to zero - srslte_vec_cf_zero(q->sf_symbols, q->sf_size); + srsran_vec_cf_zero(q->sf_symbols, q->sf_size); // Put sounding reference signals - TESTASSERT(srslte_refsignal_srs_put( + TESTASSERT(srsran_refsignal_srs_put( &q->refsignal_ul, &srs_cfg, ul_sf_cfg.tti, q->srs_pregen.r[ul_sf_cfg.tti], q->sf_symbols) == - SRSLTE_SUCCESS); + SRSRAN_SUCCESS); // Apply AWGN channel if (!isnan(snr_db) && !isinf(snr_db)) { - srslte_channel_awgn_run_c(&channel, q->sf_symbols, q->sf_symbols, q->sf_size); + srsran_channel_awgn_run_c(&channel, q->sf_symbols, q->sf_symbols, q->sf_size); } // Estimate - TESTASSERT(srslte_chest_ul_estimate_srs( + TESTASSERT(srsran_chest_ul_estimate_srs( &q->chest_ul, &ul_sf_cfg, &srs_cfg, &dmrs_pusch_cfg, q->sf_symbols, &q->chest_ul_res) == - SRSLTE_SUCCESS); + SRSRAN_SUCCESS); INFO("RESULTS: tti=%d; snr_db=%+.1f; noise_estimate_dbm=%+.1f; ta_us=%+.1f;", ul_sf_cfg.tti, @@ -158,7 +158,7 @@ int srs_test_context_run(srs_test_context_t* q) TESTASSERT(fabsf(q->chest_ul_res.noise_estimate_dbm - n0_dbm) < CHEST_TEST_SRS_SNR_DB_TOLERANCE); TESTASSERT(fabsf(q->chest_ul_res.ta_us) < CHEST_TEST_SRS_TA_US_TOLERANCE); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } void parse_args(int argc, char** argv) @@ -170,13 +170,13 @@ void parse_args(int argc, char** argv) cell.nof_prb = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'e': - cell.cp = SRSLTE_CP_EXT; + cell.cp = SRSRAN_CP_EXT; break; case 'c': cell.id = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'v': - srslte_verbose++; + srsran_verbose++; break; default: usage(argv[0]); @@ -188,17 +188,17 @@ void parse_args(int argc, char** argv) int main(int argc, char** argv) { srs_test_context_t context = {}; - int ret = SRSLTE_SUCCESS; + int ret = SRSRAN_SUCCESS; parse_args(argc, argv); - if (srslte_channel_awgn_init(&channel, 123456789) != SRSLTE_SUCCESS) { - ret = SRSLTE_ERROR; + if (srsran_channel_awgn_init(&channel, 123456789) != SRSRAN_SUCCESS) { + ret = SRSRAN_ERROR; } if (!isnan(snr_db) && !isinf(snr_db)) { n0_dbm = 30.0f - snr_db; - srslte_channel_awgn_set_n0(&channel, n0_dbm - 33.0f); + srsran_channel_awgn_set_n0(&channel, n0_dbm - 33.0f); } for (srs_cfg.bw_cfg = 0; srs_cfg.bw_cfg < 8 && !ret; srs_cfg.bw_cfg++) { @@ -232,7 +232,7 @@ int main(int argc, char** argv) } } - srslte_channel_awgn_free(&channel); + srsran_channel_awgn_free(&channel); if (!ret) { printf("OK, %d test passed successfully.\n", test_counter); diff --git a/lib/src/phy/ch_estimation/test/chest_test_ul.c b/lib/src/phy/ch_estimation/test/chest_test_ul.c index 343aae3a1..c9a5b1568 100644 --- a/lib/src/phy/ch_estimation/test/chest_test_ul.c +++ b/lib/src/phy/ch_estimation/test/chest_test_ul.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -16,16 +16,16 @@ #include #include -#include "srslte/srslte.h" +#include "srsran/srsran.h" -srslte_cell_t cell = { +srsran_cell_t cell = { 6, // nof_prb 1, // nof_ports 1000, // cell_id - SRSLTE_CP_NORM, // cyclic prefix - SRSLTE_PHICH_NORM, - SRSLTE_PHICH_R_1, // PHICH length - SRSLTE_FDD, + SRSRAN_CP_NORM, // cyclic prefix + SRSRAN_PHICH_NORM, + SRSRAN_PHICH_R_1, // PHICH length + SRSRAN_FDD, }; @@ -53,7 +53,7 @@ void parse_args(int argc, char** argv) cell.nof_prb = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'e': - cell.cp = SRSLTE_CP_EXT; + cell.cp = SRSRAN_CP_EXT; break; case 'c': cell.id = (uint32_t)strtol(argv[optind], NULL, 10); @@ -62,7 +62,7 @@ void parse_args(int argc, char** argv) output_matlab = argv[optind]; break; case 'v': - srslte_verbose++; + srsran_verbose++; break; default: usage(argv[0]); @@ -73,7 +73,7 @@ void parse_args(int argc, char** argv) int main(int argc, char** argv) { - srslte_chest_ul_t est; + srsran_chest_ul_t est; cf_t * input = NULL, *ce = NULL, *h = NULL; int i, j, n_port = 0, sf_idx = 0, cid = 0; int ret = -1; @@ -90,24 +90,24 @@ int main(int argc, char** argv) } } - uint32_t num_re = 2U * cell.nof_prb * SRSLTE_NRE * SRSLTE_CP_NSYMB(cell.cp); + uint32_t num_re = 2U * cell.nof_prb * SRSRAN_NRE * SRSRAN_CP_NSYMB(cell.cp); - input = srslte_vec_cf_malloc(num_re); + input = srsran_vec_cf_malloc(num_re); if (!input) { - perror("srslte_vec_malloc"); + perror("srsran_vec_malloc"); goto do_exit; } - h = srslte_vec_cf_malloc(num_re); + h = srsran_vec_cf_malloc(num_re); if (!h) { - perror("srslte_vec_malloc"); + perror("srsran_vec_malloc"); goto do_exit; } - ce = srslte_vec_cf_malloc(num_re); + ce = srsran_vec_cf_malloc(num_re); if (!ce) { - perror("srslte_vec_malloc"); + perror("srsran_vec_malloc"); goto do_exit; } - srslte_vec_cf_zero(ce, num_re); + srsran_vec_cf_zero(ce, num_re); if (cell.id == 1000) { cid = 0; @@ -117,24 +117,24 @@ int main(int argc, char** argv) max_cid = cell.id; } printf("max_cid=%d, cid=%d, cell.id=%d\n", max_cid, cid, cell.id); - if (srslte_chest_ul_init(&est, cell.nof_prb)) { + if (srsran_chest_ul_init(&est, cell.nof_prb)) { ERROR("Error initializing equalizer"); goto do_exit; } while (cid <= max_cid) { cell.id = cid; - if (srslte_chest_ul_set_cell(&est, cell)) { + if (srsran_chest_ul_set_cell(&est, cell)) { ERROR("Error initializing equalizer"); goto do_exit; } for (int n = 6; n <= cell.nof_prb; n += 5) { - if (srslte_dft_precoding_valid_prb(n)) { - for (int delta_ss = 29; delta_ss < SRSLTE_NOF_DELTA_SS; delta_ss++) { - for (int cshift = 7; cshift < SRSLTE_NOF_CSHIFT; cshift++) { + if (srsran_dft_precoding_valid_prb(n)) { + for (int delta_ss = 29; delta_ss < SRSRAN_NOF_DELTA_SS; delta_ss++) { + for (int cshift = 7; cshift < SRSRAN_NOF_CSHIFT; cshift++) { for (int t = 2; t < 3; t++) { /* Setup and pregen DMRS reference signals */ - srslte_refsignal_dmrs_pusch_cfg_t pusch_cfg; + srsran_refsignal_dmrs_pusch_cfg_t pusch_cfg; uint32_t nof_prb = n; pusch_cfg.cyclic_shift = cshift; @@ -154,13 +154,13 @@ int main(int argc, char** argv) } pusch_cfg.group_hopping_en = group_hopping_en; pusch_cfg.sequence_hopping_en = sequence_hopping_en; - srslte_chest_ul_pregen(&est, &pusch_cfg, NULL); + srsran_chest_ul_pregen(&est, &pusch_cfg, NULL); // Loop through subframe idx and cyclic shifts for (int sf_idx = 0; sf_idx < 10; sf_idx += 3) { - for (int cshift_dmrs = 0; cshift_dmrs < SRSLTE_NOF_CSHIFT; cshift_dmrs += 5) { - if (SRSLTE_VERBOSE_ISINFO()) { + for (int cshift_dmrs = 0; cshift_dmrs < SRSRAN_NOF_CSHIFT; cshift_dmrs += 5) { + if (SRSRAN_VERBOSE_ISINFO()) { printf("nof_prb: %d, ", nof_prb); printf("cyclic_shift: %d, ", pusch_cfg.cyclic_shift); printf("cyclic_shift_for_dmrs: %d, ", cshift_dmrs); @@ -169,24 +169,24 @@ int main(int argc, char** argv) } /* Generate random input */ - srslte_vec_cf_zero(input, num_re); + srsran_vec_cf_zero(input, num_re); for (i = 0; i < num_re; i++) { input[i] = 0.5 - rand() / (float)RAND_MAX + I * (0.5 - rand() / (float)RAND_MAX); } /* Generate channel and pass input through channel */ - for (i = 0; i < 2 * SRSLTE_CP_NSYMB(cell.cp); i++) { - for (j = 0; j < cell.nof_prb * SRSLTE_NRE; j++) { - float x = -1 + (float)i / SRSLTE_CP_NSYMB(cell.cp) + - cosf(2 * M_PI * (float)j / cell.nof_prb / SRSLTE_NRE); - h[i * cell.nof_prb * SRSLTE_NRE + j] = (3 + x) * cexpf(I * x); - input[i * cell.nof_prb * SRSLTE_NRE + j] *= h[i * cell.nof_prb * SRSLTE_NRE + j]; + for (i = 0; i < 2 * SRSRAN_CP_NSYMB(cell.cp); i++) { + for (j = 0; j < cell.nof_prb * SRSRAN_NRE; j++) { + float x = -1 + (float)i / SRSRAN_CP_NSYMB(cell.cp) + + cosf(2 * M_PI * (float)j / cell.nof_prb / SRSRAN_NRE); + h[i * cell.nof_prb * SRSRAN_NRE + j] = (3 + x) * cexpf(I * x); + input[i * cell.nof_prb * SRSRAN_NRE + j] *= h[i * cell.nof_prb * SRSRAN_NRE + j]; } } // Configure estimator - srslte_chest_ul_res_t res; - srslte_pusch_cfg_t cfg; + srsran_chest_ul_res_t res; + srsran_pusch_cfg_t cfg; ZERO_OBJECT(cfg); res.ce = ce; @@ -195,12 +195,12 @@ int main(int argc, char** argv) cfg.grant.n_prb_tilde[1] = 0; cfg.grant.n_dmrs = cshift_dmrs; - srslte_ul_sf_cfg_t ul_sf; + srsran_ul_sf_cfg_t ul_sf; ZERO_OBJECT(ul_sf); ul_sf.tti = sf_idx; // Estimate channel - srslte_chest_ul_estimate_pusch(&est, &ul_sf, &cfg, input, &res); + srsran_chest_ul_estimate_pusch(&est, &ul_sf, &cfg, input, &res); // Compute MSE float mse = 0; @@ -223,17 +223,17 @@ int main(int argc, char** argv) printf("cid=%d\n", cid); } - srslte_chest_ul_free(&est); + srsran_chest_ul_free(&est); if (fmatlab) { fprintf(fmatlab, "input="); - srslte_vec_fprint_c(fmatlab, input, num_re); + srsran_vec_fprint_c(fmatlab, input, num_re); fprintf(fmatlab, ";\n"); fprintf(fmatlab, "h="); - srslte_vec_fprint_c(fmatlab, h, num_re); + srsran_vec_fprint_c(fmatlab, h, num_re); fprintf(fmatlab, ";\n"); fprintf(fmatlab, "ce="); - srslte_vec_fprint_c(fmatlab, ce, num_re); + srsran_vec_fprint_c(fmatlab, ce, num_re); fprintf(fmatlab, ";\n"); } diff --git a/lib/src/phy/ch_estimation/test/csi_rs_test.c b/lib/src/phy/ch_estimation/test/csi_rs_test.c index e526c01a4..c3cacb175 100644 --- a/lib/src/phy/ch_estimation/test/csi_rs_test.c +++ b/lib/src/phy/ch_estimation/test/csi_rs_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,14 +10,14 @@ * */ -#include "srslte/common/test_common.h" -#include "srslte/phy/ch_estimation/csi_rs.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/common/test_common.h" +#include "srsran/phy/ch_estimation/csi_rs.h" +#include "srsran/phy/utils/vector.h" #include -#include +#include #include -static srslte_carrier_nr_t carrier = { +static srsran_carrier_nr_t carrier = { 0, // cell_id 0, // numerology 50, // nof_prb @@ -31,30 +31,30 @@ static uint32_t start_rb = UINT32_MAX; static uint32_t nof_rb = UINT32_MAX; static uint32_t first_symbol = UINT32_MAX; -static int test(const srslte_slot_cfg_t* slot_cfg, - const srslte_csi_rs_nzp_resource_t* resource, - srslte_channel_awgn_t* awgn, +static int test(const srsran_slot_cfg_t* slot_cfg, + const srsran_csi_rs_nzp_resource_t* resource, + srsran_channel_awgn_t* awgn, cf_t* grid) { - srslte_csi_rs_measure_t measure = {}; + srsran_csi_rs_measure_t measure = {}; // Put NZP-CSI-RS - TESTASSERT(srslte_csi_rs_nzp_put(&carrier, slot_cfg, resource, grid) == SRSLTE_SUCCESS); + TESTASSERT(srsran_csi_rs_nzp_put(&carrier, slot_cfg, resource, grid) == SRSRAN_SUCCESS); // Configure N0 and add Noise - TESTASSERT(srslte_channel_awgn_set_n0(awgn, (float)resource->power_control_offset - snr_dB) == SRSLTE_SUCCESS); - srslte_channel_awgn_run_c(awgn, grid, grid, SRSLTE_SLOT_LEN_RE_NR(carrier.nof_prb)); + TESTASSERT(srsran_channel_awgn_set_n0(awgn, (float)resource->power_control_offset - snr_dB) == SRSRAN_SUCCESS); + srsran_channel_awgn_run_c(awgn, grid, grid, SRSRAN_SLOT_LEN_RE_NR(carrier.nof_prb)); - TESTASSERT(srslte_csi_rs_nzp_measure(&carrier, slot_cfg, resource, grid, &measure) == SRSLTE_SUCCESS); + TESTASSERT(srsran_csi_rs_nzp_measure(&carrier, slot_cfg, resource, grid, &measure) == SRSRAN_SUCCESS); const float rsrp_dB_gold = (float)resource->power_control_offset; const float epre_dB_gold = - srslte_convert_power_to_dB(srslte_convert_dB_to_power(rsrp_dB_gold) + awgn->std_dev * awgn->std_dev); - const float n0_dB_gold = srslte_convert_amplitude_to_dB(awgn->std_dev); + srsran_convert_power_to_dB(srsran_convert_dB_to_power(rsrp_dB_gold) + awgn->std_dev * awgn->std_dev); + const float n0_dB_gold = srsran_convert_amplitude_to_dB(awgn->std_dev); - if (srslte_verbose >= SRSLTE_VERBOSE_INFO) { + if (srsran_verbose >= SRSRAN_VERBOSE_INFO) { char str[128] = {}; - srslte_csi_rs_measure_info(&measure, str, sizeof(str)); + srsran_csi_rs_measure_info(&measure, str, sizeof(str)); INFO("Measure: %s", str); } @@ -63,7 +63,7 @@ static int test(const srslte_slot_cfg_t* slot_cfg, TESTASSERT(fabsf(measure.n0_dB - n0_dB_gold) < 2.0f); TESTASSERT(fabsf(measure.snr_dB - snr_dB) < 2.0f); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } static void usage(char* prog) @@ -106,7 +106,7 @@ static void parse_args(int argc, char** argv) first_symbol = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'v': - srslte_verbose++; + srsran_verbose++; break; default: usage(argv[0]); @@ -117,32 +117,32 @@ static void parse_args(int argc, char** argv) int main(int argc, char** argv) { - int ret = SRSLTE_ERROR; - srslte_slot_cfg_t slot_cfg = {}; - srslte_csi_rs_nzp_resource_t resource = {}; - srslte_channel_awgn_t awgn = {}; + int ret = SRSRAN_ERROR; + srsran_slot_cfg_t slot_cfg = {}; + srsran_csi_rs_nzp_resource_t resource = {}; + srsran_channel_awgn_t awgn = {}; parse_args(argc, argv); - cf_t* grid = srslte_vec_cf_malloc(SRSLTE_SLOT_LEN_RE_NR(carrier.nof_prb)); + cf_t* grid = srsran_vec_cf_malloc(SRSRAN_SLOT_LEN_RE_NR(carrier.nof_prb)); if (grid == NULL) { ERROR("Alloc"); goto clean_exit; } - if (srslte_channel_awgn_init(&awgn, 1234) < SRSLTE_SUCCESS) { + if (srsran_channel_awgn_init(&awgn, 1234) < SRSRAN_SUCCESS) { ERROR("AWGN Init"); goto clean_exit; } // Fixed parameters, other params are not implemented - resource.resource_mapping.cdm = srslte_csi_rs_cdm_nocdm; - resource.resource_mapping.density = srslte_csi_rs_resource_mapping_density_three; - resource.resource_mapping.row = srslte_csi_rs_resource_mapping_row_1; + resource.resource_mapping.cdm = srsran_csi_rs_cdm_nocdm; + resource.resource_mapping.density = srsran_csi_rs_resource_mapping_density_three; + resource.resource_mapping.row = srsran_csi_rs_resource_mapping_row_1; resource.resource_mapping.ports = 1; // Row 1 supported only! - uint32_t nof_freq_dom_alloc = SRSLTE_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_ROW1; + uint32_t nof_freq_dom_alloc = SRSRAN_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_ROW1; uint32_t first_symbol_begin = (first_symbol != UINT32_MAX) ? first_symbol : 0; uint32_t first_symbol_end = (first_symbol != UINT32_MAX) ? first_symbol : 13; @@ -169,7 +169,7 @@ int main(int argc, char** argv) resource.resource_mapping.freq_band.nof_rb <= nof_rb_end; resource.resource_mapping.freq_band.nof_rb += 4) { // Iterate for all slot numbers - for (slot_cfg.idx = 0; slot_cfg.idx < SRSLTE_NSLOTS_PER_FRAME_NR(carrier.numerology); slot_cfg.idx++) { + for (slot_cfg.idx = 0; slot_cfg.idx < SRSRAN_NSLOTS_PER_FRAME_NR(carrier.numerology); slot_cfg.idx++) { // Steer Frequency allocation for (uint32_t freq_dom_alloc = 0; freq_dom_alloc < nof_freq_dom_alloc; freq_dom_alloc++) { for (uint32_t i = 0; i < nof_freq_dom_alloc; i++) { @@ -177,7 +177,7 @@ int main(int argc, char** argv) } // Call actual test - if (test(&slot_cfg, &resource, &awgn, grid) < SRSLTE_SUCCESS) { + if (test(&slot_cfg, &resource, &awgn, grid) < SRSRAN_SUCCESS) { goto clean_exit; } } @@ -187,16 +187,16 @@ int main(int argc, char** argv) } } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; clean_exit: if (grid) { free(grid); } - srslte_channel_awgn_free(&awgn); + srsran_channel_awgn_free(&awgn); - if (ret == SRSLTE_SUCCESS) { + if (ret == SRSRAN_SUCCESS) { printf("Passed!\n"); } else { printf("Failed!\n"); diff --git a/lib/src/phy/ch_estimation/test/dmrs_pdcch_test.c b/lib/src/phy/ch_estimation/test/dmrs_pdcch_test.c index 55d0bc4f8..a8d12b90d 100644 --- a/lib/src/phy/ch_estimation/test/dmrs_pdcch_test.c +++ b/lib/src/phy/ch_estimation/test/dmrs_pdcch_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,17 +10,17 @@ * */ -#include "srslte/common/test_common.h" -#include "srslte/phy/ch_estimation/dmrs_pdcch.h" -#include "srslte/phy/phch/pdcch_nr.h" +#include "srsran/common/test_common.h" +#include "srsran/phy/ch_estimation/dmrs_pdcch.h" +#include "srsran/phy/phch/pdcch_nr.h" #include #include #include #include #include -static srslte_carrier_nr_t carrier = {}; -static srslte_dmrs_pdcch_ce_t pdcch_ce = {}; +static srsran_carrier_nr_t carrier = {}; +static srsran_dmrs_pdcch_ce_t pdcch_ce = {}; static uint16_t rnti = 0x1234; void usage(char* prog) @@ -47,7 +47,7 @@ static void parse_args(int argc, char** argv) carrier.id = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'v': - srslte_verbose++; + srsran_verbose++; break; default: usage(argv[0]); @@ -56,38 +56,38 @@ static void parse_args(int argc, char** argv) } } -static int run_test(srslte_dmrs_pdcch_estimator_t* estimator, - const srslte_coreset_t* coreset, - const srslte_search_space_t* search_space, +static int run_test(srsran_dmrs_pdcch_estimator_t* estimator, + const srsran_coreset_t* coreset, + const srsran_search_space_t* search_space, uint32_t aggregation_level, cf_t* sf_symbols, - srslte_dmrs_pdcch_ce_t* ce) + srsran_dmrs_pdcch_ce_t* ce) { - srslte_slot_cfg_t slot_cfg = {}; + srsran_slot_cfg_t slot_cfg = {}; - srslte_dci_location_t dci_location = {}; + srsran_dci_location_t dci_location = {}; dci_location.L = aggregation_level; - for (slot_cfg.idx = 0; slot_cfg.idx < SRSLTE_NSLOTS_PER_FRAME_NR(carrier.numerology); slot_cfg.idx++) { - uint32_t locations[SRSLTE_SEARCH_SPACE_MAX_NOF_CANDIDATES_NR] = {}; + for (slot_cfg.idx = 0; slot_cfg.idx < SRSRAN_NSLOTS_PER_FRAME_NR(carrier.numerology); slot_cfg.idx++) { + uint32_t locations[SRSRAN_SEARCH_SPACE_MAX_NOF_CANDIDATES_NR] = {}; int nof_locations = - srslte_pdcch_nr_locations_coreset(coreset, search_space, rnti, aggregation_level, slot_cfg.idx, locations); + srsran_pdcch_nr_locations_coreset(coreset, search_space, rnti, aggregation_level, slot_cfg.idx, locations); TESTASSERT(nof_locations == search_space->nof_candidates[aggregation_level]); for (uint32_t candidate = 0; candidate < nof_locations; candidate++) { dci_location.ncce = locations[candidate]; - uint32_t nof_re = carrier.nof_prb * SRSLTE_NRE * SRSLTE_NSYMB_PER_SLOT_NR; - srslte_vec_cf_zero(sf_symbols, nof_re); + uint32_t nof_re = carrier.nof_prb * SRSRAN_NRE * SRSRAN_NSYMB_PER_SLOT_NR; + srsran_vec_cf_zero(sf_symbols, nof_re); - TESTASSERT(srslte_dmrs_pdcch_put(&carrier, coreset, &slot_cfg, &dci_location, sf_symbols) == SRSLTE_SUCCESS); + TESTASSERT(srsran_dmrs_pdcch_put(&carrier, coreset, &slot_cfg, &dci_location, sf_symbols) == SRSRAN_SUCCESS); - TESTASSERT(srslte_dmrs_pdcch_estimate(estimator, &slot_cfg, sf_symbols) == SRSLTE_SUCCESS); + TESTASSERT(srsran_dmrs_pdcch_estimate(estimator, &slot_cfg, sf_symbols) == SRSRAN_SUCCESS); - srslte_dmrs_pdcch_measure_t measure = {}; - TESTASSERT(srslte_dmrs_pdcch_get_measure(estimator, &dci_location, &measure) == SRSLTE_SUCCESS); + srsran_dmrs_pdcch_measure_t measure = {}; + TESTASSERT(srsran_dmrs_pdcch_get_measure(estimator, &dci_location, &measure) == SRSRAN_SUCCESS); if (fabsf(measure.rsrp - 1.0f) > 1e-2) { printf("EPRE=%f; RSRP=%f; CFO=%f; SYNC_ERR=%f;\n", @@ -101,38 +101,38 @@ static int run_test(srslte_dmrs_pdcch_estimator_t* estimator, TESTASSERT(fabsf(measure.cfo_hz) < 1e-3f); TESTASSERT(fabsf(measure.sync_error_us) < 1e-3f); - TESTASSERT(srslte_dmrs_pdcch_get_ce(estimator, &dci_location, ce) == SRSLTE_SUCCESS); - float avg_pow = srslte_vec_avg_power_cf(ce->ce, ce->nof_re); + TESTASSERT(srsran_dmrs_pdcch_get_ce(estimator, &dci_location, ce) == SRSRAN_SUCCESS); + float avg_pow = srsran_vec_avg_power_cf(ce->ce, ce->nof_re); float avg_pow_err = fabsf(avg_pow - 1.0f); - TESTASSERT(ce->nof_re == ((SRSLTE_NRE - 3) * (1U << aggregation_level) * 6U)); + TESTASSERT(ce->nof_re == ((SRSRAN_NRE - 3) * (1U << aggregation_level) * 6U)); TESTASSERT(avg_pow_err < 0.1f); } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int main(int argc, char** argv) { - int ret = SRSLTE_ERROR; + int ret = SRSRAN_ERROR; carrier.nof_prb = 50; parse_args(argc, argv); - srslte_coreset_t coreset = {}; - srslte_search_space_t search_space = {}; - srslte_dmrs_pdcch_estimator_t estimator = {}; + srsran_coreset_t coreset = {}; + srsran_search_space_t search_space = {}; + srsran_dmrs_pdcch_estimator_t estimator = {}; - uint32_t nof_re = carrier.nof_prb * SRSLTE_NRE * SRSLTE_NSYMB_PER_SLOT_NR; - cf_t* sf_symbols = srslte_vec_cf_malloc(nof_re); + uint32_t nof_re = carrier.nof_prb * SRSRAN_NRE * SRSRAN_NSYMB_PER_SLOT_NR; + cf_t* sf_symbols = srsran_vec_cf_malloc(nof_re); uint32_t test_counter = 0; uint32_t test_passed = 0; - coreset.mapping_type = srslte_coreset_mapping_type_non_interleaved; + coreset.mapping_type = srsran_coreset_mapping_type_non_interleaved; - uint32_t nof_frequency_resource = SRSLTE_MIN(SRSLTE_CORESET_FREQ_DOMAIN_RES_SIZE, carrier.nof_prb / 6); + uint32_t nof_frequency_resource = SRSRAN_MIN(SRSRAN_CORESET_FREQ_DOMAIN_RES_SIZE, carrier.nof_prb / 6); for (uint32_t frequency_resources = 1; frequency_resources < (1U << nof_frequency_resource); frequency_resources++) { uint32_t nof_freq_resources = 0; for (uint32_t i = 0; i < nof_frequency_resource; i++) { @@ -142,18 +142,18 @@ int main(int argc, char** argv) } for (coreset.duration = 1; coreset.duration <= 3; coreset.duration++) { - for (search_space.type = srslte_search_space_type_common_0; search_space.type <= srslte_search_space_type_ue; + for (search_space.type = srsran_search_space_type_common_0; search_space.type <= srsran_search_space_type_ue; search_space.type++) { - for (uint32_t i = 0; i < SRSLTE_SEARCH_SPACE_NOF_AGGREGATION_LEVELS_NR; i++) { + for (uint32_t i = 0; i < SRSRAN_SEARCH_SPACE_NOF_AGGREGATION_LEVELS_NR; i++) { uint32_t L = 1U << i; uint32_t nof_reg = coreset.duration * nof_freq_resources * 6; uint32_t nof_cce = nof_reg / 6; - search_space.nof_candidates[i] = SRSLTE_MIN(nof_cce / L, SRSLTE_SEARCH_SPACE_MAX_NOF_CANDIDATES_NR); + search_space.nof_candidates[i] = SRSRAN_MIN(nof_cce / L, SRSRAN_SEARCH_SPACE_MAX_NOF_CANDIDATES_NR); } - for (uint32_t aggregation_level = 0; aggregation_level < SRSLTE_SEARCH_SPACE_NOF_AGGREGATION_LEVELS_NR; + for (uint32_t aggregation_level = 0; aggregation_level < SRSRAN_SEARCH_SPACE_NOF_AGGREGATION_LEVELS_NR; aggregation_level++) { - srslte_dmrs_pdcch_estimator_init(&estimator, &carrier, &coreset); + srsran_dmrs_pdcch_estimator_init(&estimator, &carrier, &coreset); if (run_test(&estimator, &coreset, &search_space, aggregation_level, sf_symbols, &pdcch_ce)) { ERROR("Test %d failed", test_counter); @@ -166,13 +166,13 @@ int main(int argc, char** argv) } } - srslte_dmrs_pdcch_estimator_free(&estimator); + srsran_dmrs_pdcch_estimator_free(&estimator); if (sf_symbols) { free(sf_symbols); } - ret = test_passed == test_counter ? SRSLTE_SUCCESS : SRSLTE_ERROR; + ret = test_passed == test_counter ? SRSRAN_SUCCESS : SRSRAN_ERROR; printf("%s, %d of %d test passed successfully.\n", ret ? "Failed" : "Passed", test_passed, test_counter); return ret; diff --git a/lib/src/phy/ch_estimation/test/dmrs_pdsch_test.c b/lib/src/phy/ch_estimation/test/dmrs_pdsch_test.c index 206ff4d4a..1da99b177 100644 --- a/lib/src/phy/ch_estimation/test/dmrs_pdsch_test.c +++ b/lib/src/phy/ch_estimation/test/dmrs_pdsch_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,17 +10,17 @@ * */ -#include "srslte/common/test_common.h" -#include "srslte/phy/ch_estimation/dmrs_sch.h" -#include "srslte/phy/phch/ra_dl_nr.h" -#include "srslte/srslte.h" +#include "srsran/common/test_common.h" +#include "srsran/phy/ch_estimation/dmrs_sch.h" +#include "srsran/phy/phch/ra_dl_nr.h" +#include "srsran/srsran.h" #include #include #include #include #include -static srslte_carrier_nr_t carrier = { +static srsran_carrier_nr_t carrier = { 0, // cell_id 0, // numerology 50, // nof_prb @@ -29,95 +29,95 @@ static srslte_carrier_nr_t carrier = { }; typedef struct { - srslte_sch_mapping_type_t mapping_type; - srslte_dmrs_sch_typeA_pos_t typeA_pos; - srslte_dmrs_sch_len_t max_length; - srslte_dmrs_sch_add_pos_t additional_pos; - srslte_dmrs_sch_type_t type; - uint32_t symbol_idx[SRSLTE_DMRS_SCH_MAX_SYMBOLS]; + srsran_sch_mapping_type_t mapping_type; + srsran_dmrs_sch_typeA_pos_t typeA_pos; + srsran_dmrs_sch_len_t max_length; + srsran_dmrs_sch_add_pos_t additional_pos; + srsran_dmrs_sch_type_t type; + uint32_t symbol_idx[SRSRAN_DMRS_SCH_MAX_SYMBOLS]; uint32_t nof_symbols; - uint32_t sc_idx[SRSLTE_NRE]; + uint32_t sc_idx[SRSRAN_NRE]; uint32_t nof_sc; } golden_t; // Golden values extracted from https://www.sharetechnote.com/html/5G/5G_PDSCH_DMRS.html -static const golden_t gold[] = {{.mapping_type = srslte_sch_mapping_type_A, - .typeA_pos = srslte_dmrs_sch_typeA_pos_2, - .max_length = srslte_dmrs_sch_len_1, - .additional_pos = srslte_dmrs_sch_add_pos_0, - .type = srslte_dmrs_sch_type_2, +static const golden_t gold[] = {{.mapping_type = srsran_sch_mapping_type_A, + .typeA_pos = srsran_dmrs_sch_typeA_pos_2, + .max_length = srsran_dmrs_sch_len_1, + .additional_pos = srsran_dmrs_sch_add_pos_0, + .type = srsran_dmrs_sch_type_2, .nof_symbols = 1, .symbol_idx = {2}, .nof_sc = 4, .sc_idx = {0, 1, 6, 7}}, - {.mapping_type = srslte_sch_mapping_type_A, - .typeA_pos = srslte_dmrs_sch_typeA_pos_3, - .max_length = srslte_dmrs_sch_len_1, - .additional_pos = srslte_dmrs_sch_add_pos_0, - .type = srslte_dmrs_sch_type_2, + {.mapping_type = srsran_sch_mapping_type_A, + .typeA_pos = srsran_dmrs_sch_typeA_pos_3, + .max_length = srsran_dmrs_sch_len_1, + .additional_pos = srsran_dmrs_sch_add_pos_0, + .type = srsran_dmrs_sch_type_2, .nof_symbols = 1, .symbol_idx = {3}, .nof_sc = 4, .sc_idx = {0, 1, 6, 7}}, - {.mapping_type = srslte_sch_mapping_type_A, - .typeA_pos = srslte_dmrs_sch_typeA_pos_2, - .max_length = srslte_dmrs_sch_len_2, - .additional_pos = srslte_dmrs_sch_add_pos_0, - .type = srslte_dmrs_sch_type_2, + {.mapping_type = srsran_sch_mapping_type_A, + .typeA_pos = srsran_dmrs_sch_typeA_pos_2, + .max_length = srsran_dmrs_sch_len_2, + .additional_pos = srsran_dmrs_sch_add_pos_0, + .type = srsran_dmrs_sch_type_2, .nof_symbols = 2, .symbol_idx = {2, 3}, .nof_sc = 4, .sc_idx = {0, 1, 6, 7}}, - {.mapping_type = srslte_sch_mapping_type_A, - .typeA_pos = srslte_dmrs_sch_typeA_pos_2, - .max_length = srslte_dmrs_sch_len_1, - .additional_pos = srslte_dmrs_sch_add_pos_1, - .type = srslte_dmrs_sch_type_2, + {.mapping_type = srsran_sch_mapping_type_A, + .typeA_pos = srsran_dmrs_sch_typeA_pos_2, + .max_length = srsran_dmrs_sch_len_1, + .additional_pos = srsran_dmrs_sch_add_pos_1, + .type = srsran_dmrs_sch_type_2, .nof_symbols = 2, .symbol_idx = {2, 11}, .nof_sc = 4, .sc_idx = {0, 1, 6, 7}}, - {.mapping_type = srslte_sch_mapping_type_A, - .typeA_pos = srslte_dmrs_sch_typeA_pos_2, - .max_length = srslte_dmrs_sch_len_1, - .additional_pos = srslte_dmrs_sch_add_pos_2, - .type = srslte_dmrs_sch_type_2, + {.mapping_type = srsran_sch_mapping_type_A, + .typeA_pos = srsran_dmrs_sch_typeA_pos_2, + .max_length = srsran_dmrs_sch_len_1, + .additional_pos = srsran_dmrs_sch_add_pos_2, + .type = srsran_dmrs_sch_type_2, .nof_symbols = 3, .symbol_idx = {2, 7, 11}, .nof_sc = 4, .sc_idx = {0, 1, 6, 7}}, - {.mapping_type = srslte_sch_mapping_type_A, - .typeA_pos = srslte_dmrs_sch_typeA_pos_2, - .max_length = srslte_dmrs_sch_len_1, - .additional_pos = srslte_dmrs_sch_add_pos_3, - .type = srslte_dmrs_sch_type_2, + {.mapping_type = srsran_sch_mapping_type_A, + .typeA_pos = srsran_dmrs_sch_typeA_pos_2, + .max_length = srsran_dmrs_sch_len_1, + .additional_pos = srsran_dmrs_sch_add_pos_3, + .type = srsran_dmrs_sch_type_2, .nof_symbols = 4, .symbol_idx = {2, 5, 8, 11}, .nof_sc = 4, .sc_idx = {0, 1, 6, 7}}, - {.mapping_type = srslte_sch_mapping_type_A, - .typeA_pos = srslte_dmrs_sch_typeA_pos_2, - .max_length = srslte_dmrs_sch_len_1, - .additional_pos = srslte_dmrs_sch_add_pos_0, - .type = srslte_dmrs_sch_type_1, + {.mapping_type = srsran_sch_mapping_type_A, + .typeA_pos = srsran_dmrs_sch_typeA_pos_2, + .max_length = srsran_dmrs_sch_len_1, + .additional_pos = srsran_dmrs_sch_add_pos_0, + .type = srsran_dmrs_sch_type_1, .nof_symbols = 1, .symbol_idx = {2}, .nof_sc = 6, .sc_idx = {0, 2, 4, 6, 8, 10}}, - {.mapping_type = srslte_sch_mapping_type_A, - .typeA_pos = srslte_dmrs_sch_typeA_pos_2, - .max_length = srslte_dmrs_sch_len_2, - .additional_pos = srslte_dmrs_sch_add_pos_0, - .type = srslte_dmrs_sch_type_1, + {.mapping_type = srsran_sch_mapping_type_A, + .typeA_pos = srsran_dmrs_sch_typeA_pos_2, + .max_length = srsran_dmrs_sch_len_2, + .additional_pos = srsran_dmrs_sch_add_pos_0, + .type = srsran_dmrs_sch_type_1, .nof_symbols = 2, .symbol_idx = {2, 3}, .nof_sc = 6, .sc_idx = {0, 2, 4, 6, 8, 10}}, - {.mapping_type = srslte_sch_mapping_type_A, - .typeA_pos = srslte_dmrs_sch_typeA_pos_2, - .max_length = srslte_dmrs_sch_len_1, - .additional_pos = srslte_dmrs_sch_add_pos_3, - .type = srslte_dmrs_sch_type_1, + {.mapping_type = srsran_sch_mapping_type_A, + .typeA_pos = srsran_dmrs_sch_typeA_pos_2, + .max_length = srsran_dmrs_sch_len_1, + .additional_pos = srsran_dmrs_sch_add_pos_3, + .type = srsran_dmrs_sch_type_1, .nof_symbols = 4, .symbol_idx = {2, 5, 8, 11}, .nof_sc = 6, @@ -147,7 +147,7 @@ static void parse_args(int argc, char** argv) carrier.id = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'v': - srslte_verbose++; + srsran_verbose++; break; default: usage(argv[0]); @@ -156,7 +156,7 @@ static void parse_args(int argc, char** argv) } } -static int assert_cfg(const srslte_sch_cfg_nr_t* pdsch_cfg, const srslte_sch_grant_nr_t* grant) +static int assert_cfg(const srsran_sch_cfg_nr_t* pdsch_cfg, const srsran_sch_grant_nr_t* grant) { for (uint32_t i = 0; gold[i].nof_sc != 0; i++) { // Gold examples are done for more than 12 symbols @@ -184,8 +184,8 @@ static int assert_cfg(const srslte_sch_cfg_nr_t* pdsch_cfg, const srslte_sch_gra continue; } - uint32_t symbols[SRSLTE_DMRS_SCH_MAX_SYMBOLS] = {}; - int nof_symbols = srslte_dmrs_sch_get_symbols_idx(&pdsch_cfg->dmrs, grant, symbols); + uint32_t symbols[SRSRAN_DMRS_SCH_MAX_SYMBOLS] = {}; + int nof_symbols = srsran_dmrs_sch_get_symbols_idx(&pdsch_cfg->dmrs, grant, symbols); TESTASSERT(nof_symbols == gold[i].nof_symbols); @@ -193,33 +193,33 @@ static int assert_cfg(const srslte_sch_cfg_nr_t* pdsch_cfg, const srslte_sch_gra TESTASSERT(symbols[j] == gold[i].symbol_idx[j]); } - uint32_t sc[SRSLTE_NRE] = {}; - srslte_dmrs_sch_get_sc_idx(&pdsch_cfg->dmrs, SRSLTE_NRE, sc); + uint32_t sc[SRSRAN_NRE] = {}; + srsran_dmrs_sch_get_sc_idx(&pdsch_cfg->dmrs, SRSRAN_NRE, sc); for (uint32_t j = 0; j < gold[i].nof_sc; j++) { TESTASSERT(sc[j] == gold[i].sc_idx[j]); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -static int run_test(srslte_dmrs_sch_t* dmrs_pdsch, - const srslte_sch_cfg_nr_t* pdsch_cfg, - const srslte_sch_grant_nr_t* grant, +static int run_test(srsran_dmrs_sch_t* dmrs_pdsch, + const srsran_sch_cfg_nr_t* pdsch_cfg, + const srsran_sch_grant_nr_t* grant, cf_t* sf_symbols, - srslte_chest_dl_res_t* chest_res) + srsran_chest_dl_res_t* chest_res) { - TESTASSERT(assert_cfg(pdsch_cfg, grant) == SRSLTE_SUCCESS); + TESTASSERT(assert_cfg(pdsch_cfg, grant) == SRSRAN_SUCCESS); - srslte_slot_cfg_t slot_cfg = {}; - for (slot_cfg.idx = 0; slot_cfg.idx < SRSLTE_NSLOTS_PER_FRAME_NR(dmrs_pdsch->carrier.numerology); slot_cfg.idx++) { - TESTASSERT(srslte_dmrs_sch_put_sf(dmrs_pdsch, &slot_cfg, pdsch_cfg, grant, sf_symbols) == SRSLTE_SUCCESS); + srsran_slot_cfg_t slot_cfg = {}; + for (slot_cfg.idx = 0; slot_cfg.idx < SRSRAN_NSLOTS_PER_FRAME_NR(dmrs_pdsch->carrier.numerology); slot_cfg.idx++) { + TESTASSERT(srsran_dmrs_sch_put_sf(dmrs_pdsch, &slot_cfg, pdsch_cfg, grant, sf_symbols) == SRSRAN_SUCCESS); - TESTASSERT(srslte_dmrs_sch_estimate(dmrs_pdsch, &slot_cfg, pdsch_cfg, grant, sf_symbols, chest_res) == - SRSLTE_SUCCESS); + TESTASSERT(srsran_dmrs_sch_estimate(dmrs_pdsch, &slot_cfg, pdsch_cfg, grant, sf_symbols, chest_res) == + SRSRAN_SUCCESS); float mse = 0.0f; for (uint32_t i = 0; i < chest_res->nof_re; i++) { @@ -232,70 +232,70 @@ static int run_test(srslte_dmrs_sch_t* dmrs_pdsch, TESTASSERT(mse < 1e-6f); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int main(int argc, char** argv) { - int ret = SRSLTE_ERROR; + int ret = SRSRAN_ERROR; parse_args(argc, argv); - srslte_dmrs_sch_t dmrs_pdsch = {}; - srslte_sch_cfg_nr_t pdsch_cfg = {}; - srslte_sch_grant_nr_t grant = {}; - srslte_chest_dl_res_t chest_dl_res = {}; + srsran_dmrs_sch_t dmrs_pdsch = {}; + srsran_sch_cfg_nr_t pdsch_cfg = {}; + srsran_sch_grant_nr_t grant = {}; + srsran_chest_dl_res_t chest_dl_res = {}; - uint32_t nof_re = carrier.nof_prb * SRSLTE_NRE * SRSLTE_NOF_SLOTS_PER_SF * SRSLTE_MAX_NSYMB; - cf_t* sf_symbols = srslte_vec_cf_malloc(nof_re); + uint32_t nof_re = carrier.nof_prb * SRSRAN_NRE * SRSRAN_NOF_SLOTS_PER_SF * SRSRAN_MAX_NSYMB; + cf_t* sf_symbols = srsran_vec_cf_malloc(nof_re); uint32_t test_counter = 0; uint32_t test_passed = 0; // Initialise object DMRS for PDSCH - if (srslte_dmrs_sch_init(&dmrs_pdsch, true) != SRSLTE_SUCCESS) { + if (srsran_dmrs_sch_init(&dmrs_pdsch, true) != SRSRAN_SUCCESS) { ERROR("Init"); goto clean_exit; } // Set carrier configuration - if (srslte_dmrs_sch_set_carrier(&dmrs_pdsch, &carrier) != SRSLTE_SUCCESS) { + if (srsran_dmrs_sch_set_carrier(&dmrs_pdsch, &carrier) != SRSRAN_SUCCESS) { ERROR("Setting carrier"); goto clean_exit; } - if (srslte_chest_dl_res_init(&chest_dl_res, carrier.nof_prb) != SRSLTE_SUCCESS) { + if (srsran_chest_dl_res_init(&chest_dl_res, carrier.nof_prb) != SRSRAN_SUCCESS) { ERROR("Initiating channel estimation result"); goto clean_exit; } // For each DCI m param for (uint32_t m = 0; m < 16; m++) { - srslte_dmrs_sch_type_t type_begin = srslte_dmrs_sch_type_1; - srslte_dmrs_sch_type_t type_end = srslte_dmrs_sch_type_2; + srsran_dmrs_sch_type_t type_begin = srsran_dmrs_sch_type_1; + srsran_dmrs_sch_type_t type_end = srsran_dmrs_sch_type_2; for (pdsch_cfg.dmrs.type = type_begin; pdsch_cfg.dmrs.type <= type_end; pdsch_cfg.dmrs.type++) { - srslte_dmrs_sch_typeA_pos_t typeA_pos_begin = srslte_dmrs_sch_typeA_pos_2; - srslte_dmrs_sch_typeA_pos_t typeA_pos_end = srslte_dmrs_sch_typeA_pos_3; + srsran_dmrs_sch_typeA_pos_t typeA_pos_begin = srsran_dmrs_sch_typeA_pos_2; + srsran_dmrs_sch_typeA_pos_t typeA_pos_end = srsran_dmrs_sch_typeA_pos_3; for (pdsch_cfg.dmrs.typeA_pos = typeA_pos_begin; pdsch_cfg.dmrs.typeA_pos <= typeA_pos_end; pdsch_cfg.dmrs.typeA_pos++) { - srslte_dmrs_sch_add_pos_t add_pos_begin = srslte_dmrs_sch_add_pos_2; - srslte_dmrs_sch_add_pos_t add_pos_end = srslte_dmrs_sch_add_pos_3; + srsran_dmrs_sch_add_pos_t add_pos_begin = srsran_dmrs_sch_add_pos_2; + srsran_dmrs_sch_add_pos_t add_pos_end = srsran_dmrs_sch_add_pos_3; - if (pdsch_cfg.dmrs.typeA_pos == srslte_dmrs_sch_typeA_pos_3) { - add_pos_end = srslte_dmrs_sch_add_pos_1; + if (pdsch_cfg.dmrs.typeA_pos == srsran_dmrs_sch_typeA_pos_3) { + add_pos_end = srsran_dmrs_sch_add_pos_1; } for (pdsch_cfg.dmrs.additional_pos = add_pos_begin; pdsch_cfg.dmrs.additional_pos <= add_pos_end; pdsch_cfg.dmrs.additional_pos++) { - srslte_dmrs_sch_len_t max_len_begin = srslte_dmrs_sch_len_1; - srslte_dmrs_sch_len_t max_len_end = srslte_dmrs_sch_len_2; + srsran_dmrs_sch_len_t max_len_begin = srsran_dmrs_sch_len_1; + srsran_dmrs_sch_len_t max_len_end = srsran_dmrs_sch_len_2; // Only single DMRS symbols can have additional positions 2 and 3 - if (pdsch_cfg.dmrs.additional_pos == srslte_dmrs_sch_add_pos_2 || - pdsch_cfg.dmrs.additional_pos == srslte_dmrs_sch_add_pos_3) { - max_len_end = srslte_dmrs_sch_len_1; + if (pdsch_cfg.dmrs.additional_pos == srsran_dmrs_sch_add_pos_2 || + pdsch_cfg.dmrs.additional_pos == srsran_dmrs_sch_add_pos_3) { + max_len_end = srsran_dmrs_sch_len_1; } for (pdsch_cfg.dmrs.length = max_len_begin; pdsch_cfg.dmrs.length <= max_len_end; pdsch_cfg.dmrs.length++) { @@ -307,15 +307,15 @@ int main(int argc, char** argv) for (grant.nof_dmrs_cdm_groups_without_data = 1; grant.nof_dmrs_cdm_groups_without_data <= 3; grant.nof_dmrs_cdm_groups_without_data++) { // Load default type A grant - srslte_ra_dl_nr_time_default_A(0, pdsch_cfg.dmrs.typeA_pos, &grant); + srsran_ra_dl_nr_time_default_A(0, pdsch_cfg.dmrs.typeA_pos, &grant); int n = run_test(&dmrs_pdsch, &pdsch_cfg, &grant, sf_symbols, &chest_dl_res); - if (n == SRSLTE_SUCCESS) { + if (n == SRSRAN_SUCCESS) { test_passed++; } else { char str[64] = {}; - srslte_dmrs_sch_cfg_to_str(&pdsch_cfg.dmrs, str, 64); + srsran_dmrs_sch_cfg_to_str(&pdsch_cfg.dmrs, str, 64); ERROR("Test %d failed. %s.", test_counter, str); } @@ -334,10 +334,10 @@ clean_exit: if (sf_symbols) { free(sf_symbols); } - srslte_chest_dl_res_free(&chest_dl_res); - srslte_dmrs_sch_free(&dmrs_pdsch); + srsran_chest_dl_res_free(&chest_dl_res); + srsran_dmrs_sch_free(&dmrs_pdsch); - ret = test_passed == test_counter ? SRSLTE_SUCCESS : SRSLTE_ERROR; + ret = test_passed == test_counter ? SRSRAN_SUCCESS : SRSRAN_ERROR; printf("%s, %d of %d test passed successfully.\n", ret ? "Failed" : "Passed", test_passed, test_counter); return ret; diff --git a/lib/src/phy/ch_estimation/test/refsignal_ul_test.c b/lib/src/phy/ch_estimation/test/refsignal_ul_test.c index 0d48f4467..1a8098ee3 100644 --- a/lib/src/phy/ch_estimation/test/refsignal_ul_test.c +++ b/lib/src/phy/ch_estimation/test/refsignal_ul_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,23 +10,23 @@ * */ -#include "srslte/srslte.h" +#include "srsran/srsran.h" #include #include #include #include #include -#include "srslte/srslte.h" +#include "srsran/srsran.h" -srslte_cell_t cell = { +srsran_cell_t cell = { 100, // nof_prb - SRSLTE_MAX_PORTS, // nof_ports + SRSRAN_MAX_PORTS, // nof_ports 1, // cell_id - SRSLTE_CP_NORM, // cyclic prefix - SRSLTE_PHICH_NORM, - SRSLTE_PHICH_R_1_6, // PHICH length - SRSLTE_FDD, + SRSRAN_CP_NORM, // cyclic prefix + SRSRAN_PHICH_NORM, + SRSRAN_PHICH_R_1_6, // PHICH length + SRSRAN_FDD, }; @@ -51,13 +51,13 @@ void parse_args(int argc, char** argv) cell.nof_prb = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'e': - cell.cp = SRSLTE_CP_EXT; + cell.cp = SRSRAN_CP_EXT; break; case 'c': cell.id = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'v': - srslte_verbose++; + srsran_verbose++; break; default: usage(argv[0]); @@ -68,19 +68,19 @@ void parse_args(int argc, char** argv) int main(int argc, char** argv) { - srslte_refsignal_ul_t refs = {}; - srslte_refsignal_dmrs_pusch_cfg_t pusch_cfg = {}; + srsran_refsignal_ul_t refs = {}; + srsran_refsignal_dmrs_pusch_cfg_t pusch_cfg = {}; cf_t* signal = NULL; int ret = -1; parse_args(argc, argv); - if (srslte_refsignal_ul_set_cell(&refs, cell)) { + if (srsran_refsignal_ul_set_cell(&refs, cell)) { ERROR("Error initializing UL reference signal"); goto do_exit; } - signal = srslte_vec_cf_malloc(2 * SRSLTE_NRE * cell.nof_prb); + signal = srsran_vec_cf_malloc(2 * SRSRAN_NRE * cell.nof_prb); if (!signal) { perror("malloc"); goto do_exit; @@ -88,11 +88,11 @@ int main(int argc, char** argv) printf("Running tests for %d PRB\n", cell.nof_prb); for (int n = 6; n < cell.nof_prb; n++) { - for (int delta_ss = 29; delta_ss < SRSLTE_NOF_DELTA_SS; delta_ss++) { - for (int cshift = 0; cshift < SRSLTE_NOF_CSHIFT; cshift++) { + for (int delta_ss = 29; delta_ss < SRSRAN_NOF_DELTA_SS; delta_ss++) { + for (int cshift = 0; cshift < SRSRAN_NOF_CSHIFT; cshift++) { for (int h = 0; h < 3; h++) { for (int sf_idx = 0; sf_idx < 10; sf_idx++) { - for (int cshift_dmrs = 0; cshift_dmrs < SRSLTE_NOF_CSHIFT; cshift_dmrs++) { + for (int cshift_dmrs = 0; cshift_dmrs < SRSRAN_NOF_CSHIFT; cshift_dmrs++) { uint32_t nof_prb = n; pusch_cfg.cyclic_shift = cshift; pusch_cfg.delta_ss = delta_ss; @@ -121,16 +121,16 @@ int main(int argc, char** argv) pusch_cfg.group_hopping_en = group_hopping_en; pusch_cfg.sequence_hopping_en = sequence_hopping_en; - srslte_refsignal_dmrs_pusch_gen(&refs, &pusch_cfg, nof_prb, sf_idx, cshift_dmrs, signal); + srsran_refsignal_dmrs_pusch_gen(&refs, &pusch_cfg, nof_prb, sf_idx, cshift_dmrs, signal); gettimeofday(&t[2], NULL); get_time_interval(t); printf("DMRS ExecTime: %ld us\n", t[0].tv_usec); - srslte_refsignal_srs_cfg_t srs_cfg; + srsran_refsignal_srs_cfg_t srs_cfg; ZERO_OBJECT(srs_cfg); gettimeofday(&t[1], NULL); - srslte_refsignal_srs_gen(&refs, &srs_cfg, &pusch_cfg, sf_idx, signal); + srsran_refsignal_srs_gen(&refs, &srs_cfg, &pusch_cfg, sf_idx, signal); gettimeofday(&t[2], NULL); get_time_interval(t); printf("SRS ExecTime: %ld us\n", t[0].tv_usec); diff --git a/lib/src/phy/ch_estimation/wiener_dl.c b/lib/src/phy/ch_estimation/wiener_dl.c index ea6b20ef7..ae3606ef6 100644 --- a/lib/src/phy/ch_estimation/wiener_dl.c +++ b/lib/src/phy/ch_estimation/wiener_dl.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,9 +11,9 @@ */ #include -#include -#include -#include +#include +#include +#include // Useful macros #define NSAMPLES2NBYTES(N) (sizeof(cf_t) * (N)) @@ -23,10 +23,10 @@ #define M_4_7 0.571428571f /* 4 / 7 */ #define M_4_3 1.33333333333333333333f /* 4 / 3 */ #define M_5_3 1.66666666666666666666f /* 5 / 3 */ -#define SRSLTE_WIENER_HALFREF_IDX (q->nof_ref / 2 - 1) +#define SRSRAN_WIENER_HALFREF_IDX (q->nof_ref / 2 - 1) // Constants -const float hlsv_sum_norm[SRSLTE_WIENER_DL_MIN_RE] = {0.0625f, +const float hlsv_sum_norm[SRSRAN_WIENER_DL_MIN_RE] = {0.0625f, 0.0638297872326845f, 0.0652173913015123f, 0.0666666666622222f, @@ -76,16 +76,16 @@ const float hlsv_sum_norm[SRSLTE_WIENER_DL_MIN_RE] = {0.0625f, 2.99999985900001}; // Local state function prototypes -static srslte_wiener_dl_state_t* srslte_wiener_dl_state_malloc(srslte_wiener_dl_t* q); -static void srslte_wiener_dl_state_free(srslte_wiener_dl_state_t* q); -static void srslte_wiener_dl_state_reset(srslte_wiener_dl_t* q, srslte_wiener_dl_state_t* state); +static srsran_wiener_dl_state_t* srsran_wiener_dl_state_malloc(srsran_wiener_dl_t* q); +static void srsran_wiener_dl_state_free(srsran_wiener_dl_state_t* q); +static void srsran_wiener_dl_state_reset(srsran_wiener_dl_t* q, srsran_wiener_dl_state_t* state); // Local run function prototypes static void - srslte_wiener_dl_run_symbol_1_8(srslte_wiener_dl_t* q, srslte_wiener_dl_state_t* state, cf_t* pilots, float snr_lin); -static void srslte_wiener_dl_run_symbol_2_9(srslte_wiener_dl_t* q, srslte_wiener_dl_state_t* state); -static void srslte_wiener_dl_run_symbol_5_12(srslte_wiener_dl_t* q, - srslte_wiener_dl_state_t* state, + srsran_wiener_dl_run_symbol_1_8(srsran_wiener_dl_t* q, srsran_wiener_dl_state_t* state, cf_t* pilots, float snr_lin); +static void srsran_wiener_dl_run_symbol_2_9(srsran_wiener_dl_t* q, srsran_wiener_dl_state_t* state); +static void srsran_wiener_dl_run_symbol_5_12(srsran_wiener_dl_t* q, + srsran_wiener_dl_state_t* state, cf_t* pilots, uint32_t tx, uint32_t rx, @@ -93,63 +93,63 @@ static void srslte_wiener_dl_run_symbol_5_12(srslte_wiener_dl_t* q, float snr_lin); // Local state related functions -static srslte_wiener_dl_state_t* srslte_wiener_dl_state_malloc(srslte_wiener_dl_t* q) +static srsran_wiener_dl_state_t* srsran_wiener_dl_state_malloc(srsran_wiener_dl_t* q) { // Allocate Channel state - srslte_wiener_dl_state_t* state = calloc(sizeof(srslte_wiener_dl_state_t), 1); + srsran_wiener_dl_state_t* state = calloc(sizeof(srsran_wiener_dl_state_t), 1); // Check allocation if (!state) { perror("malloc"); } else { - int ret = SRSLTE_SUCCESS; + int ret = SRSRAN_SUCCESS; // Allocate state variables - for (int i = 0; i < SRSLTE_WIENER_DL_HLS_FIFO_SIZE && !ret; i++) { - state->hls_fifo_1[i] = srslte_vec_malloc(NSAMPLES2NBYTES(q->max_ref)); + for (int i = 0; i < SRSRAN_WIENER_DL_HLS_FIFO_SIZE && !ret; i++) { + state->hls_fifo_1[i] = srsran_vec_malloc(NSAMPLES2NBYTES(q->max_ref)); if (!state->hls_fifo_1[i]) { perror("malloc"); - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } if (!ret) { - state->hls_fifo_2[i] = srslte_vec_malloc(NSAMPLES2NBYTES(q->max_ref)); + state->hls_fifo_2[i] = srsran_vec_malloc(NSAMPLES2NBYTES(q->max_ref)); if (!state->hls_fifo_2[i]) { perror("malloc"); - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } } } - for (uint32_t i = 0; i < SRSLTE_WIENER_DL_TFIFO_SIZE && !ret; i++) { - state->tfifo[i] = srslte_vec_malloc(NSAMPLES2NBYTES(q->max_re)); + for (uint32_t i = 0; i < SRSRAN_WIENER_DL_TFIFO_SIZE && !ret; i++) { + state->tfifo[i] = srsran_vec_malloc(NSAMPLES2NBYTES(q->max_re)); if (!state->tfifo[i]) { perror("malloc"); - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } } - for (uint32_t i = 0; i < SRSLTE_WIENER_DL_XFIFO_SIZE && !ret; i++) { - state->xfifo[i] = srslte_vec_malloc(NSAMPLES2NBYTES(SRSLTE_WIENER_DL_MIN_RE)); + for (uint32_t i = 0; i < SRSRAN_WIENER_DL_XFIFO_SIZE && !ret; i++) { + state->xfifo[i] = srsran_vec_malloc(NSAMPLES2NBYTES(SRSRAN_WIENER_DL_MIN_RE)); if (!state->xfifo[i]) { perror("malloc"); - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } } if (!ret) { - state->timefifo = srslte_vec_malloc(NSAMPLES2NBYTES(SRSLTE_WIENER_DL_TIMEFIFO_SIZE)); + state->timefifo = srsran_vec_malloc(NSAMPLES2NBYTES(SRSRAN_WIENER_DL_TIMEFIFO_SIZE)); if (!state->timefifo) { perror("malloc"); - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } } - for (uint32_t i = 0; i < SRSLTE_WIENER_DL_CXFIFO_SIZE && !ret; i++) { - state->cxfifo[i] = srslte_vec_malloc(NSAMPLES2NBYTES(SRSLTE_WIENER_DL_TIMEFIFO_SIZE)); + for (uint32_t i = 0; i < SRSRAN_WIENER_DL_CXFIFO_SIZE && !ret; i++) { + state->cxfifo[i] = srsran_vec_malloc(NSAMPLES2NBYTES(SRSRAN_WIENER_DL_TIMEFIFO_SIZE)); if (!state->cxfifo[i]) { perror("malloc"); - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } } @@ -163,7 +163,7 @@ static srslte_wiener_dl_state_t* srslte_wiener_dl_state_malloc(srslte_wiener_dl_ if (ret) { // Free all allocated memory - srslte_wiener_dl_state_free(state); + srsran_wiener_dl_state_free(state); // Return NULL if error state = NULL; @@ -173,25 +173,25 @@ static srslte_wiener_dl_state_t* srslte_wiener_dl_state_malloc(srslte_wiener_dl_ return state; } -static void srslte_wiener_dl_state_reset(srslte_wiener_dl_t* q, srslte_wiener_dl_state_t* state) +static void srsran_wiener_dl_state_reset(srsran_wiener_dl_t* q, srsran_wiener_dl_state_t* state) { if (q && state) { // Initialise memory - for (uint32_t i = 0; i < SRSLTE_WIENER_DL_HLS_FIFO_SIZE; i++) { + for (uint32_t i = 0; i < SRSRAN_WIENER_DL_HLS_FIFO_SIZE; i++) { bzero(state->hls_fifo_1[i], NSAMPLES2NBYTES(q->nof_ref)); bzero(state->hls_fifo_2[i], NSAMPLES2NBYTES(q->nof_ref)); } - for (uint32_t i = 0; i < SRSLTE_WIENER_DL_TFIFO_SIZE; i++) { + for (uint32_t i = 0; i < SRSRAN_WIENER_DL_TFIFO_SIZE; i++) { bzero(state->tfifo[i], NSAMPLES2NBYTES(q->nof_re)); } - for (uint32_t i = 0; i < SRSLTE_WIENER_DL_XFIFO_SIZE; i++) { - bzero(state->xfifo[i], NSAMPLES2NBYTES(SRSLTE_WIENER_DL_MIN_RE)); + for (uint32_t i = 0; i < SRSRAN_WIENER_DL_XFIFO_SIZE; i++) { + bzero(state->xfifo[i], NSAMPLES2NBYTES(SRSRAN_WIENER_DL_MIN_RE)); } - bzero(state->cV, NSAMPLES2NBYTES(SRSLTE_WIENER_DL_MIN_RE)); - bzero(state->timefifo, NSAMPLES2NBYTES(SRSLTE_WIENER_DL_TIMEFIFO_SIZE)); + bzero(state->cV, NSAMPLES2NBYTES(SRSRAN_WIENER_DL_MIN_RE)); + bzero(state->timefifo, NSAMPLES2NBYTES(SRSRAN_WIENER_DL_TIMEFIFO_SIZE)); - for (uint32_t i = 0; i < SRSLTE_WIENER_DL_CXFIFO_SIZE; i++) { - bzero(state->cxfifo[i], NSAMPLES2NBYTES(SRSLTE_WIENER_DL_TIMEFIFO_SIZE)); + for (uint32_t i = 0; i < SRSRAN_WIENER_DL_CXFIFO_SIZE; i++) { + bzero(state->cxfifo[i], NSAMPLES2NBYTES(SRSRAN_WIENER_DL_TIMEFIFO_SIZE)); } // Initialise counters and variables @@ -204,11 +204,11 @@ static void srslte_wiener_dl_state_reset(srslte_wiener_dl_t* q, srslte_wiener_dl } } -static void srslte_wiener_dl_state_free(srslte_wiener_dl_state_t* q) +static void srsran_wiener_dl_state_free(srsran_wiener_dl_state_t* q) { if (q) { - for (int i = 0; i < SRSLTE_WIENER_DL_HLS_FIFO_SIZE; i++) { + for (int i = 0; i < SRSRAN_WIENER_DL_HLS_FIFO_SIZE; i++) { if (q->hls_fifo_1[i]) { free(q->hls_fifo_1[i]); } @@ -216,17 +216,17 @@ static void srslte_wiener_dl_state_free(srslte_wiener_dl_state_t* q) free(q->hls_fifo_2[i]); } } - for (uint32_t i = 0; i < SRSLTE_WIENER_DL_TFIFO_SIZE; i++) { + for (uint32_t i = 0; i < SRSRAN_WIENER_DL_TFIFO_SIZE; i++) { if (q->tfifo[i]) { free(q->tfifo[i]); } } - for (uint32_t i = 0; i < SRSLTE_WIENER_DL_XFIFO_SIZE; i++) { + for (uint32_t i = 0; i < SRSRAN_WIENER_DL_XFIFO_SIZE; i++) { if (q->xfifo[i]) { free(q->xfifo[i]); } } - for (uint32_t i = 0; i < SRSLTE_WIENER_DL_CXFIFO_SIZE; i++) { + for (uint32_t i = 0; i < SRSRAN_WIENER_DL_CXFIFO_SIZE; i++) { if (q->cxfifo[i]) { free(q->cxfifo[i]); } @@ -240,28 +240,28 @@ static void srslte_wiener_dl_state_free(srslte_wiener_dl_state_t* q) } } -int srslte_wiener_dl_init(srslte_wiener_dl_t* q, uint32_t max_prb, uint32_t max_tx_ports, uint32_t max_rx_ant) +int srsran_wiener_dl_init(srsran_wiener_dl_t* q, uint32_t max_prb, uint32_t max_tx_ports, uint32_t max_rx_ant) { - int ret = SRSLTE_SUCCESS; + int ret = SRSRAN_SUCCESS; - if (q && max_prb <= SRSLTE_MAX_PRB && max_tx_ports <= SRSLTE_MAX_PORTS && max_rx_ant <= SRSLTE_MAX_PORTS) { + if (q && max_prb <= SRSRAN_MAX_PRB && max_tx_ports <= SRSRAN_MAX_PORTS && max_rx_ant <= SRSRAN_MAX_PORTS) { // Bzero structure - bzero(q, sizeof(srslte_wiener_dl_t)); + bzero(q, sizeof(srsran_wiener_dl_t)); // Set maximum parameters q->max_prb = max_prb; q->max_ref = max_prb * 2; - q->max_re = max_prb * SRSLTE_NRE; + q->max_re = max_prb * SRSRAN_NRE; q->max_tx_ports = max_tx_ports; q->max_rx_ant = max_rx_ant; // Allocate state for (uint32_t tx = 0; tx < q->max_tx_ports && !ret; tx++) { for (uint32_t rx = 0; rx < q->max_rx_ant && !ret; rx++) { - srslte_wiener_dl_state_t* state = srslte_wiener_dl_state_malloc(q); + srsran_wiener_dl_state_t* state = srsran_wiener_dl_state_malloc(q); if (!state) { - perror("srslte_wiener_dl_state_malloc"); - ret = SRSLTE_ERROR; + perror("srsran_wiener_dl_state_malloc"); + ret = SRSRAN_ERROR; } else { q->state[tx][rx] = state; } @@ -270,49 +270,49 @@ int srslte_wiener_dl_init(srslte_wiener_dl_t* q, uint32_t max_prb, uint32_t max_ // Allocate temporal buffers, maximum SF size if (!ret) { - q->tmp = srslte_vec_malloc(NSAMPLES2NBYTES(SRSLTE_SF_LEN_MAX)); + q->tmp = srsran_vec_malloc(NSAMPLES2NBYTES(SRSRAN_SF_LEN_MAX)); if (!q->tmp) { perror("malloc"); - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } } if (!ret) { - q->random = srslte_random_init(0xdead); + q->random = srsran_random_init(0xdead); if (!q->random) { - perror("srslte_random_init"); - ret = SRSLTE_ERROR; + perror("srsran_random_init"); + ret = SRSRAN_ERROR; } } // Create filter FFT/iFFT plans if (!ret) { - ret = srslte_dft_plan_c(&q->fft, SRSLTE_WIENER_DL_MIN_RE, SRSLTE_DFT_FORWARD); + ret = srsran_dft_plan_c(&q->fft, SRSRAN_WIENER_DL_MIN_RE, SRSRAN_DFT_FORWARD); } if (!ret) { - ret = srslte_dft_plan_c(&q->ifft, SRSLTE_WIENER_DL_MIN_RE, SRSLTE_DFT_BACKWARD); + ret = srsran_dft_plan_c(&q->ifft, SRSRAN_WIENER_DL_MIN_RE, SRSRAN_DFT_BACKWARD); } // Initialise interpolation filter if (!ret) { - bzero(q->filter, NSAMPLES2NBYTES(SRSLTE_WIENER_DL_MIN_RE)); - q->filter[0] = 1.0f / SRSLTE_WIENER_DL_MIN_RE; - q->filter[1] = M_2_3 / SRSLTE_WIENER_DL_MIN_RE; - q->filter[2] = M_1_3 / SRSLTE_WIENER_DL_MIN_RE; - q->filter[SRSLTE_WIENER_DL_MIN_RE - 2] = M_1_3 / SRSLTE_WIENER_DL_MIN_RE; - q->filter[SRSLTE_WIENER_DL_MIN_RE - 1] = M_2_3 / SRSLTE_WIENER_DL_MIN_RE; - srslte_dft_run_c(&q->fft, q->filter, q->filter); + bzero(q->filter, NSAMPLES2NBYTES(SRSRAN_WIENER_DL_MIN_RE)); + q->filter[0] = 1.0f / SRSRAN_WIENER_DL_MIN_RE; + q->filter[1] = M_2_3 / SRSRAN_WIENER_DL_MIN_RE; + q->filter[2] = M_1_3 / SRSRAN_WIENER_DL_MIN_RE; + q->filter[SRSRAN_WIENER_DL_MIN_RE - 2] = M_1_3 / SRSRAN_WIENER_DL_MIN_RE; + q->filter[SRSRAN_WIENER_DL_MIN_RE - 1] = M_2_3 / SRSRAN_WIENER_DL_MIN_RE; + srsran_dft_run_c(&q->fft, q->filter, q->filter); } // Initialise matrix inverter if (!ret) { - q->matrix_inverter = calloc(sizeof(srslte_matrix_NxN_inv_t), 1); + q->matrix_inverter = calloc(sizeof(srsran_matrix_NxN_inv_t), 1); if (q->matrix_inverter) { - ret = srslte_matrix_NxN_inv_init(q->matrix_inverter, SRSLTE_WIENER_DL_MIN_REF); + ret = srsran_matrix_NxN_inv_init(q->matrix_inverter, SRSRAN_WIENER_DL_MIN_REF); } else { perror("calloc"); - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } } } @@ -320,45 +320,45 @@ int srslte_wiener_dl_init(srslte_wiener_dl_t* q, uint32_t max_prb, uint32_t max_ return ret; } -int srslte_wiener_dl_set_cell(srslte_wiener_dl_t* q, srslte_cell_t cell) +int srsran_wiener_dl_set_cell(srsran_wiener_dl_t* q, srsran_cell_t cell) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q) { // No invalid inputs - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; // Set new values q->nof_prb = cell.nof_prb; q->nof_ref = cell.nof_prb * 2; - q->nof_re = cell.nof_prb * SRSLTE_NRE; + q->nof_re = cell.nof_prb * SRSRAN_NRE; q->nof_tx_ports = cell.nof_ports; q->nof_rx_ant = q->max_rx_ant; q->ready = false; q->wm_computed = false; // Reset states - srslte_wiener_dl_reset(q); + srsran_wiener_dl_reset(q); } return ret; } -void srslte_wiener_dl_reset(srslte_wiener_dl_t* q) +void srsran_wiener_dl_reset(srsran_wiener_dl_t* q) { if (q) { // Reset states - for (uint32_t tx = 0; tx < SRSLTE_MAX_PORTS; tx++) { - for (uint32_t rx = 0; rx < SRSLTE_MAX_PORTS; rx++) { + for (uint32_t tx = 0; tx < SRSRAN_MAX_PORTS; tx++) { + for (uint32_t rx = 0; rx < SRSRAN_MAX_PORTS; rx++) { if (q->state[tx][rx]) { - srslte_wiener_dl_state_reset(q, q->state[tx][rx]); + srsran_wiener_dl_state_reset(q, q->state[tx][rx]); } } } // Reset wiener - bzero(q->wm1, NSAMPLES2NBYTES(SRSLTE_WIENER_DL_MIN_REF * SRSLTE_WIENER_DL_MIN_RE)); - bzero(q->wm2, NSAMPLES2NBYTES(SRSLTE_WIENER_DL_MIN_REF * SRSLTE_WIENER_DL_MIN_RE)); + bzero(q->wm1, NSAMPLES2NBYTES(SRSRAN_WIENER_DL_MIN_REF * SRSRAN_WIENER_DL_MIN_RE)); + bzero(q->wm2, NSAMPLES2NBYTES(SRSRAN_WIENER_DL_MIN_REF * SRSRAN_WIENER_DL_MIN_RE)); } } @@ -413,14 +413,14 @@ static void matrix_acc_dim1_cc(cf_t** matrix, cf_t* res, uint32_t ndim1, uint32_ { int dim2 = 0; -#if SRSLTE_SIMD_CF_SIZE - for (; dim2 < ndim2 - SRSLTE_SIMD_CF_SIZE / 2 + 1; dim2 += SRSLTE_SIMD_CF_SIZE / 2) { - simd_f_t acc = srslte_simd_f_zero(); +#if SRSRAN_SIMD_CF_SIZE + for (; dim2 < ndim2 - SRSRAN_SIMD_CF_SIZE / 2 + 1; dim2 += SRSRAN_SIMD_CF_SIZE / 2) { + simd_f_t acc = srsran_simd_f_zero(); for (uint32_t dim1 = 0; dim1 < ndim1; dim1++) { - simd_f_t reg = srslte_simd_f_loadu((float*)&matrix[dim1][dim2]); - acc = srslte_simd_f_add(acc, reg); + simd_f_t reg = srsran_simd_f_loadu((float*)&matrix[dim1][dim2]); + acc = srsran_simd_f_add(acc, reg); } - srslte_simd_f_storeu((float*)&res[dim2], acc); + srsran_simd_f_storeu((float*)&res[dim2], acc); } #endif @@ -438,7 +438,7 @@ static void matrix_acc_dim1_cc(cf_t** matrix, cf_t* res, uint32_t ndim1, uint32_ { // Accumulate each row for (uint32_t dim1 = 0; dim1 < ndim1; dim1++) { - res[dim1] = srslte_vec_acc_cc(matrix[dim1], ndim2); + res[dim1] = srsran_vec_acc_cc(matrix[dim1], ndim2); } }*/ @@ -455,30 +455,30 @@ static inline uint32_t vec_find_first_smaller_than_cf(cf_t* x, float y, uint32_t return ret; } -static inline cf_t _srslte_vec_dot_prod_ccc_simd(const cf_t* x, const cf_t* y, const int len) +static inline cf_t _srsran_vec_dot_prod_ccc_simd(const cf_t* x, const cf_t* y, const int len) { int i = 0; cf_t result = 0; -#if SRSLTE_SIMD_CF_SIZE - if (len >= SRSLTE_SIMD_CF_SIZE) { - simd_cf_t avx_result = srslte_simd_cf_zero(); - for (; i < len - SRSLTE_SIMD_CF_SIZE + 1; i += SRSLTE_SIMD_CF_SIZE) { - simd_cf_t xVal = srslte_simd_cfi_loadu(&x[i]); - simd_cf_t yVal = srslte_simd_cfi_loadu(&y[i]); +#if SRSRAN_SIMD_CF_SIZE + if (len >= SRSRAN_SIMD_CF_SIZE) { + simd_cf_t avx_result = srsran_simd_cf_zero(); + for (; i < len - SRSRAN_SIMD_CF_SIZE + 1; i += SRSRAN_SIMD_CF_SIZE) { + simd_cf_t xVal = srsran_simd_cfi_loadu(&x[i]); + simd_cf_t yVal = srsran_simd_cfi_loadu(&y[i]); - avx_result = srslte_simd_cf_add(srslte_simd_cf_prod(xVal, yVal), avx_result); + avx_result = srsran_simd_cf_add(srsran_simd_cf_prod(xVal, yVal), avx_result); } - __attribute__((aligned(64))) float simd_dotProdVector[SRSLTE_SIMD_CF_SIZE]; - simd_f_t acc_re = srslte_simd_cf_re(avx_result); - simd_f_t acc_im = srslte_simd_cf_im(avx_result); + __attribute__((aligned(64))) float simd_dotProdVector[SRSRAN_SIMD_CF_SIZE]; + simd_f_t acc_re = srsran_simd_cf_re(avx_result); + simd_f_t acc_im = srsran_simd_cf_im(avx_result); - simd_f_t acc = srslte_simd_f_hadd(acc_re, acc_im); - for (int j = 2; j < SRSLTE_SIMD_F_SIZE; j *= 2) { - acc = srslte_simd_f_hadd(acc, acc); + simd_f_t acc = srsran_simd_f_hadd(acc_re, acc_im); + for (int j = 2; j < SRSRAN_SIMD_F_SIZE; j *= 2) { + acc = srsran_simd_f_hadd(acc, acc); } - srslte_simd_f_store(simd_dotProdVector, acc); + srsran_simd_f_store(simd_dotProdVector, acc); __real__ result = simd_dotProdVector[0]; __imag__ result = simd_dotProdVector[1]; } @@ -491,8 +491,8 @@ static inline cf_t _srslte_vec_dot_prod_ccc_simd(const cf_t* x, const cf_t* y, c return result; } -static void estimate_wiener(srslte_wiener_dl_t* q, - const cf_t wm[SRSLTE_WIENER_DL_MIN_RE][SRSLTE_WIENER_DL_MIN_REF], +static void estimate_wiener(srsran_wiener_dl_t* q, + const cf_t wm[SRSRAN_WIENER_DL_MIN_RE][SRSRAN_WIENER_DL_MIN_REF], cf_t* ref, cf_t* h) { @@ -500,24 +500,24 @@ static void estimate_wiener(srslte_wiener_dl_t* q, uint32_t p_offset = 0; // Pilot indexing offset // Estimate lower band - for (uint32_t i = 0; i < SRSLTE_WIENER_DL_MIN_RE; i++) { - h[r_offset + i] = _srslte_vec_dot_prod_ccc_simd(&ref[p_offset], wm[i], SRSLTE_WIENER_DL_MIN_REF); + for (uint32_t i = 0; i < SRSRAN_WIENER_DL_MIN_RE; i++) { + h[r_offset + i] = _srsran_vec_dot_prod_ccc_simd(&ref[p_offset], wm[i], SRSRAN_WIENER_DL_MIN_REF); } // Estimate Upper band (it might overlap in 6PRB cells with the lower band) - r_offset = q->nof_re - SRSLTE_WIENER_DL_MIN_RE; - p_offset = q->nof_ref - SRSLTE_WIENER_DL_MIN_REF; - for (uint32_t i = 0; i < SRSLTE_WIENER_DL_MIN_RE; i++) { - h[r_offset + i] = _srslte_vec_dot_prod_ccc_simd(&ref[p_offset], wm[i], SRSLTE_WIENER_DL_MIN_REF); + r_offset = q->nof_re - SRSRAN_WIENER_DL_MIN_RE; + p_offset = q->nof_ref - SRSRAN_WIENER_DL_MIN_REF; + for (uint32_t i = 0; i < SRSRAN_WIENER_DL_MIN_RE; i++) { + h[r_offset + i] = _srsran_vec_dot_prod_ccc_simd(&ref[p_offset], wm[i], SRSRAN_WIENER_DL_MIN_REF); } // Estimate center Resource elements - if (q->nof_re > 2 * SRSLTE_WIENER_DL_MIN_RE) { + if (q->nof_re > 2 * SRSRAN_WIENER_DL_MIN_RE) { for (uint32_t prb = 2; prb < q->nof_prb - 2; prb += 2) { p_offset = (prb - 1) * 2; - r_offset = prb * SRSLTE_NRE; - for (uint32_t i = 0; i < SRSLTE_NRE * 2; i++) { - h[r_offset + i] = _srslte_vec_dot_prod_ccc_simd(&ref[p_offset], wm[i + SRSLTE_NRE], SRSLTE_WIENER_DL_MIN_REF); + r_offset = prb * SRSRAN_NRE; + for (uint32_t i = 0; i < SRSRAN_NRE * 2; i++) { + h[r_offset + i] = _srsran_vec_dot_prod_ccc_simd(&ref[p_offset], wm[i + SRSRAN_NRE], SRSRAN_WIENER_DL_MIN_REF); } } } @@ -534,42 +534,42 @@ inline static cf_t _cmul(cf_t a, cf_t b) } static void -srslte_wiener_dl_run_symbol_1_8(srslte_wiener_dl_t* q, srslte_wiener_dl_state_t* state, cf_t* pilots, float snr_lin) +srsran_wiener_dl_run_symbol_1_8(srsran_wiener_dl_t* q, srsran_wiener_dl_state_t* state, cf_t* pilots, float snr_lin) { // there are pilot symbols (even) in this OFDM period (first symbol of the slot) - circshift_dim1(state->hls_fifo_2, SRSLTE_WIENER_DL_HLS_FIFO_SIZE, 1); // shift matrix rows down one position + circshift_dim1(state->hls_fifo_2, SRSRAN_WIENER_DL_HLS_FIFO_SIZE, 1); // shift matrix rows down one position memcpy(state->hls_fifo_2[0], pilots, NSAMPLES2NBYTES(q->nof_ref)); // Online training for pilot filtering - circshift_dim2(&state->timefifo, 1, SRSLTE_WIENER_DL_TIMEFIFO_SIZE, 1); // shift columns right one position - state->timefifo[0] = conjf(pilots[SRSLTE_WIENER_HALFREF_IDX]); // train with center of subband frequency + circshift_dim2(&state->timefifo, 1, SRSRAN_WIENER_DL_TIMEFIFO_SIZE, 1); // shift columns right one position + state->timefifo[0] = conjf(pilots[SRSRAN_WIENER_HALFREF_IDX]); // train with center of subband frequency - circshift_dim1(state->cxfifo, SRSLTE_WIENER_DL_CXFIFO_SIZE, 1); // shift rows down one position - srslte_vec_sc_prod_ccc( - state->timefifo, pilots[SRSLTE_WIENER_HALFREF_IDX], state->cxfifo[0], SRSLTE_WIENER_DL_TIMEFIFO_SIZE); + circshift_dim1(state->cxfifo, SRSRAN_WIENER_DL_CXFIFO_SIZE, 1); // shift rows down one position + srsran_vec_sc_prod_ccc( + state->timefifo, pilots[SRSRAN_WIENER_HALFREF_IDX], state->cxfifo[0], SRSRAN_WIENER_DL_TIMEFIFO_SIZE); // Calculate auto-correlation and normalize - matrix_acc_dim1_cc(state->cxfifo, q->tmp, SRSLTE_WIENER_DL_CXFIFO_SIZE, SRSLTE_WIENER_DL_TIMEFIFO_SIZE); - srslte_vec_sc_prod_cfc(q->tmp, 1.0f / SRSLTE_WIENER_DL_CXFIFO_SIZE, q->tmp, SRSLTE_WIENER_DL_TIMEFIFO_SIZE); + matrix_acc_dim1_cc(state->cxfifo, q->tmp, SRSRAN_WIENER_DL_CXFIFO_SIZE, SRSRAN_WIENER_DL_TIMEFIFO_SIZE); + srsran_vec_sc_prod_cfc(q->tmp, 1.0f / SRSRAN_WIENER_DL_CXFIFO_SIZE, q->tmp, SRSRAN_WIENER_DL_TIMEFIFO_SIZE); // Find index of half amplitude - uint32_t halfcx = vec_find_first_smaller_than_cf(q->tmp, cabsf(q->tmp[1]) * 0.5f, SRSLTE_WIENER_DL_TIMEFIFO_SIZE, 2); + uint32_t halfcx = vec_find_first_smaller_than_cf(q->tmp, cabsf(q->tmp[1]) * 0.5f, SRSRAN_WIENER_DL_TIMEFIFO_SIZE, 2); // Update internal states - state->sumlen = SRSLTE_MAX(1, floorf(halfcx / 8.0f * SRSLTE_MIN(2.0f, 1.0f + 1.0f / snr_lin))); - state->skip = SRSLTE_MAX(1, floorf(halfcx / 4.0f * SRSLTE_MIN(1, snr_lin / 16.0f))); + state->sumlen = SRSRAN_MAX(1, floorf(halfcx / 8.0f * SRSRAN_MIN(2.0f, 1.0f + 1.0f / snr_lin))); + state->skip = SRSRAN_MAX(1, floorf(halfcx / 4.0f * SRSRAN_MIN(1, snr_lin / 16.0f))); } -static void srslte_wiener_dl_run_symbol_2_9(srslte_wiener_dl_t* q, srslte_wiener_dl_state_t* state) +static void srsran_wiener_dl_run_symbol_2_9(srsran_wiener_dl_t* q, srsran_wiener_dl_state_t* state) { // here we only shift and feed TD interpolation fifo - circshift_dim1(state->tfifo, SRSLTE_WIENER_DL_TFIFO_SIZE, 1); // shift matrix columns right by one position + circshift_dim1(state->tfifo, SRSRAN_WIENER_DL_TFIFO_SIZE, 1); // shift matrix columns right by one position // Average Reference Signals matrix_acc_dim1_cc(state->hls_fifo_2, q->tmp, state->sumlen, q->nof_ref); // Sum values - srslte_vec_sc_prod_cfc(q->tmp, 1.0f / state->sumlen, q->tmp, q->nof_ref); // Scale sum + srsran_vec_sc_prod_cfc(q->tmp, 1.0f / state->sumlen, q->tmp, q->nof_ref); // Scale sum // Estimate channel based on the wiener matrix 2 estimate_wiener(q, q->wm2, q->tmp, state->tfifo[0]); @@ -579,8 +579,8 @@ static void srslte_wiener_dl_run_symbol_2_9(srslte_wiener_dl_t* q, srslte_wiener state->invtpilotoff = M_1_3; } -static void srslte_wiener_dl_run_symbol_5_12(srslte_wiener_dl_t* q, - srslte_wiener_dl_state_t* state, +static void srsran_wiener_dl_run_symbol_5_12(srsran_wiener_dl_t* q, + srsran_wiener_dl_state_t* state, cf_t* pilots, uint32_t tx, uint32_t rx, @@ -588,14 +588,14 @@ static void srslte_wiener_dl_run_symbol_5_12(srslte_wiener_dl_t* q, float snr_lin) { // there are pilot symbols (odd) in this OFDM period (fifth symbol of the slot) - circshift_dim1(state->hls_fifo_1, SRSLTE_WIENER_DL_HLS_FIFO_SIZE, 1); // shift matrix rows down one position + circshift_dim1(state->hls_fifo_1, SRSRAN_WIENER_DL_HLS_FIFO_SIZE, 1); // shift matrix rows down one position memcpy(state->hls_fifo_1[0], pilots, NSAMPLES2NBYTES(q->nof_ref)); - circshift_dim1(state->tfifo, SRSLTE_WIENER_DL_TFIFO_SIZE, 1); // shift matrix columns right by one position + circshift_dim1(state->tfifo, SRSRAN_WIENER_DL_TFIFO_SIZE, 1); // shift matrix columns right by one position // Average Reference Signals matrix_acc_dim1_cc(state->hls_fifo_1, q->tmp, state->sumlen, q->nof_ref); // Sum values - srslte_vec_sc_prod_cfc(q->tmp, 1.0f / state->sumlen, q->tmp, q->nof_ref); // Scale sum + srsran_vec_sc_prod_cfc(q->tmp, 1.0f / state->sumlen, q->tmp, q->nof_ref); // Scale sum // Estimate channel based on the wiener matrix 1 estimate_wiener(q, q->wm1, q->tmp, state->tfifo[0]); @@ -614,56 +614,56 @@ static void srslte_wiener_dl_run_symbol_5_12(srslte_wiener_dl_t* q, pos1 = (pos2 + 3) % 6; // Choose randomly a pair of PRB and calculate the start reference signal - nsbb = srslte_random_uniform_int_dist(q->random, 0, q->nof_prb / 2); + nsbb = srsran_random_uniform_int_dist(q->random, 0, q->nof_prb / 2); if (nsbb == 0) { pstart = 0; } else if (nsbb >= (q->nof_prb / 2) - 1) { - pstart = q->nof_ref - SRSLTE_WIENER_DL_MIN_REF; + pstart = q->nof_ref - SRSRAN_WIENER_DL_MIN_REF; } else { - pstart = (SRSLTE_WIENER_DL_MIN_REF / 2) * nsbb - 2; + pstart = (SRSRAN_WIENER_DL_MIN_REF / 2) * nsbb - 2; } - bzero(q->hlsv, NSAMPLES2NBYTES(SRSLTE_WIENER_DL_MIN_RE)); - for (uint32_t i = pos2, k = pstart; i < SRSLTE_WIENER_DL_MIN_RE; i += 6, k++) { + bzero(q->hlsv, NSAMPLES2NBYTES(SRSRAN_WIENER_DL_MIN_RE)); + for (uint32_t i = pos2, k = pstart; i < SRSRAN_WIENER_DL_MIN_RE; i += 6, k++) { q->hlsv[i] = conjf(state->hls_fifo_2[1][k] + (state->hls_fifo_2[0][k] - state->hls_fifo_2[1][k]) * M_4_7); } - for (uint32_t i = pos1, k = pstart; i < SRSLTE_WIENER_DL_MIN_RE; i += 6, k++) { + for (uint32_t i = pos1, k = pstart; i < SRSRAN_WIENER_DL_MIN_RE; i += 6, k++) { q->hlsv[i] = conjf(state->hls_fifo_1[1][k]); } // Correlate Least Squares estimation - bzero(q->hlsv_sum, NSAMPLES2NBYTES(SRSLTE_WIENER_DL_MIN_RE)); // Zero correlation vector - for (uint32_t i = 0; i < SRSLTE_WIENER_DL_MIN_REF * 2; i++) { + bzero(q->hlsv_sum, NSAMPLES2NBYTES(SRSRAN_WIENER_DL_MIN_RE)); // Zero correlation vector + for (uint32_t i = 0; i < SRSRAN_WIENER_DL_MIN_REF * 2; i++) { uint32_t offset = i * 3; - uint32_t sum_len = SRSLTE_WIENER_DL_MIN_RE - offset; - srslte_vec_sc_prod_ccc(&q->hlsv[offset], conjf(q->hlsv[offset]), q->tmp, sum_len); - srslte_vec_sum_ccc(q->tmp, q->hlsv_sum, q->hlsv_sum, sum_len); + uint32_t sum_len = SRSRAN_WIENER_DL_MIN_RE - offset; + srsran_vec_sc_prod_ccc(&q->hlsv[offset], conjf(q->hlsv[offset]), q->tmp, sum_len); + srsran_vec_sum_ccc(q->tmp, q->hlsv_sum, q->hlsv_sum, sum_len); } - srslte_vec_prod_cfc(q->hlsv_sum, hlsv_sum_norm, q->hlsv_sum, SRSLTE_WIENER_DL_MIN_RE); // Normalize correlation + srsran_vec_prod_cfc(q->hlsv_sum, hlsv_sum_norm, q->hlsv_sum, SRSRAN_WIENER_DL_MIN_RE); // Normalize correlation // Put correlation in FIFO - state->nfifosamps = SRSLTE_MIN(state->nfifosamps + 1, SRSLTE_WIENER_DL_XFIFO_SIZE); + state->nfifosamps = SRSRAN_MIN(state->nfifosamps + 1, SRSRAN_WIENER_DL_XFIFO_SIZE); circshift_dim1(state->xfifo, state->nfifosamps, 1); - memcpy(state->xfifo[0], q->hlsv_sum, NSAMPLES2NBYTES(SRSLTE_WIENER_DL_MIN_RE)); + memcpy(state->xfifo[0], q->hlsv_sum, NSAMPLES2NBYTES(SRSRAN_WIENER_DL_MIN_RE)); // Average samples in FIFO - matrix_acc_dim1_cc(state->xfifo, state->cV, SRSLTE_WIENER_DL_XFIFO_SIZE, SRSLTE_WIENER_DL_MIN_RE); + matrix_acc_dim1_cc(state->xfifo, state->cV, SRSRAN_WIENER_DL_XFIFO_SIZE, SRSRAN_WIENER_DL_MIN_RE); if (state->nfifosamps) { - srslte_vec_sc_prod_cfc(state->cV, 1.0f / state->nfifosamps, state->cV, SRSLTE_WIENER_DL_MIN_RE); + srsran_vec_sc_prod_cfc(state->cV, 1.0f / state->nfifosamps, state->cV, SRSRAN_WIENER_DL_MIN_RE); } // Interpolate - srslte_dft_run_c(&q->fft, state->cV, q->tmp); - srslte_vec_prod_ccc(q->tmp, q->filter, q->tmp, SRSLTE_WIENER_DL_MIN_RE); - srslte_dft_run_c(&q->ifft, q->tmp, state->cV); + srsran_dft_run_c(&q->fft, state->cV, q->tmp); + srsran_vec_prod_ccc(q->tmp, q->filter, q->tmp, SRSRAN_WIENER_DL_MIN_RE); + srsran_dft_run_c(&q->ifft, q->tmp, state->cV); // Interpolate last edge - state->cV[SRSLTE_WIENER_DL_MIN_RE - 2] = - state->cV[SRSLTE_WIENER_DL_MIN_RE - 6] + - (state->cV[SRSLTE_WIENER_DL_MIN_RE - 3] - state->cV[SRSLTE_WIENER_DL_MIN_RE - 6]) * M_4_3; - state->cV[SRSLTE_WIENER_DL_MIN_RE - 1] = - state->cV[SRSLTE_WIENER_DL_MIN_RE - 6] + - (state->cV[SRSLTE_WIENER_DL_MIN_RE - 3] - state->cV[SRSLTE_WIENER_DL_MIN_RE - 6]) * M_5_3; + state->cV[SRSRAN_WIENER_DL_MIN_RE - 2] = + state->cV[SRSRAN_WIENER_DL_MIN_RE - 6] + + (state->cV[SRSRAN_WIENER_DL_MIN_RE - 3] - state->cV[SRSRAN_WIENER_DL_MIN_RE - 6]) * M_4_3; + state->cV[SRSRAN_WIENER_DL_MIN_RE - 1] = + state->cV[SRSRAN_WIENER_DL_MIN_RE - 6] + + (state->cV[SRSRAN_WIENER_DL_MIN_RE - 3] - state->cV[SRSRAN_WIENER_DL_MIN_RE - 6]) * M_5_3; if (tx == q->nof_tx_ports - 1 && rx == q->nof_rx_ant - 1) { // Average correlation vectors @@ -671,21 +671,21 @@ static void srslte_wiener_dl_run_symbol_5_12(srslte_wiener_dl_t* q, for (uint32_t j = 0; j < q->nof_rx_ant; j++) { if (i == 0 && j == 0) { // Copy if first one - memcpy(q->acV, q->state[i][j]->cV, NSAMPLES2NBYTES(SRSLTE_WIENER_DL_MIN_RE)); + memcpy(q->acV, q->state[i][j]->cV, NSAMPLES2NBYTES(SRSRAN_WIENER_DL_MIN_RE)); } else { // Accumulate otherwise - srslte_vec_sum_ccc(q->state[i][j]->cV, q->acV, q->acV, SRSLTE_WIENER_DL_MIN_RE); + srsran_vec_sum_ccc(q->state[i][j]->cV, q->acV, q->acV, SRSRAN_WIENER_DL_MIN_RE); } } } // Apply averaging scale - srslte_vec_sc_prod_cfc(q->acV, 1.0f / (q->nof_tx_ports * q->nof_rx_ant), q->acV, SRSLTE_WIENER_DL_MIN_RE); + srsran_vec_sc_prod_cfc(q->acV, 1.0f / (q->nof_tx_ports * q->nof_rx_ant), q->acV, SRSRAN_WIENER_DL_MIN_RE); // Compute square wiener correlation matrix - for (uint32_t i = 0; i < SRSLTE_WIENER_DL_MIN_REF; i++) { - for (uint32_t k = i; k < SRSLTE_WIENER_DL_MIN_REF; k++) { + for (uint32_t i = 0; i < SRSRAN_WIENER_DL_MIN_REF; i++) { + for (uint32_t k = i; k < SRSRAN_WIENER_DL_MIN_REF; k++) { q->RH.m[i][k] = q->acV[6 * (k - i)]; q->RH.m[k][i] = conjf(q->RH.m[i][k]); } @@ -695,19 +695,19 @@ static void srslte_wiener_dl_run_symbol_5_12(srslte_wiener_dl_t* q, float N = 0.0f; if (isnormal(__real__ q->acV[0]) && isnormal(snr_lin) && state->sumlen > 0) { - N = (__real__ q->acV[0] / SRSLTE_MIN(15, snr_lin * state->sumlen)); + N = (__real__ q->acV[0] / SRSRAN_MIN(15, snr_lin * state->sumlen)); } - for (uint32_t i = 0; i < SRSLTE_WIENER_DL_MIN_REF; i++) { + for (uint32_t i = 0; i < SRSRAN_WIENER_DL_MIN_REF; i++) { q->RH.m[i][i] += N; } // Compute wiener correlation inverse matrix - srslte_matrix_NxN_inv_run(q->matrix_inverter, q->RH.v, q->invRH.v); + srsran_matrix_NxN_inv_run(q->matrix_inverter, q->RH.v, q->invRH.v); // Generate Rectangular Wiener - for (uint32_t i = 0; i < SRSLTE_WIENER_DL_MIN_RE; i++) { - for (uint32_t k = 0; k < SRSLTE_WIENER_DL_MIN_REF; k++) { + for (uint32_t i = 0; i < SRSRAN_WIENER_DL_MIN_RE; i++) { + for (uint32_t k = 0; k < SRSRAN_WIENER_DL_MIN_REF; k++) { int m1 = ((shift + 3) % 6) + 6 * k - i; int m2 = shift + 6 * k - i; @@ -726,11 +726,11 @@ static void srslte_wiener_dl_run_symbol_5_12(srslte_wiener_dl_t* q, } // Compute Wiener matrices - for (uint32_t dim1 = 0; dim1 < SRSLTE_WIENER_DL_MIN_RE; dim1++) { - for (uint32_t dim2 = 0; dim2 < SRSLTE_WIENER_DL_MIN_REF; dim2++) { + for (uint32_t dim1 = 0; dim1 < SRSRAN_WIENER_DL_MIN_RE; dim1++) { + for (uint32_t dim2 = 0; dim2 < SRSRAN_WIENER_DL_MIN_REF; dim2++) { q->wm1[dim1][dim2] = 0; q->wm2[dim1][dim2] = 0; - for (int i = 0; i < SRSLTE_WIENER_DL_MIN_REF; i++) { + for (int i = 0; i < SRSRAN_WIENER_DL_MIN_REF; i++) { q->wm1[dim1][dim2] += _cmul(q->hH1[dim1][i], q->invRH.m[i][dim2]); q->wm2[dim1][dim2] += _cmul(q->hH2[dim1][i], q->invRH.m[i][dim2]); } @@ -741,7 +741,7 @@ static void srslte_wiener_dl_run_symbol_5_12(srslte_wiener_dl_t* q, } } -int srslte_wiener_dl_run(srslte_wiener_dl_t* q, +int srsran_wiener_dl_run(srsran_wiener_dl_t* q, uint32_t tx, uint32_t rx, uint32_t m, @@ -750,53 +750,53 @@ int srslte_wiener_dl_run(srslte_wiener_dl_t* q, cf_t* estimated, float snr_lin) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q) { // m is based on 0, increase one; m++; // Get estimator state - srslte_wiener_dl_state_t* state = q->state[tx][rx]; + srsran_wiener_dl_state_t* state = q->state[tx][rx]; // Process symbol switch (m) { case 1: q->ready = q->wm_computed; case 8: - srslte_wiener_dl_run_symbol_1_8(q, state, pilots, snr_lin); + srsran_wiener_dl_run_symbol_1_8(q, state, pilots, snr_lin); break; case 2: case 9: - srslte_wiener_dl_run_symbol_2_9(q, state); + srsran_wiener_dl_run_symbol_2_9(q, state); break; case 5: case 12: - srslte_wiener_dl_run_symbol_5_12(q, state, pilots, tx, rx, shift, snr_lin); + srsran_wiener_dl_run_symbol_5_12(q, state, pilots, tx, rx, shift, snr_lin); break; default: /* Do nothing */; } // Estimate - srslte_vec_sub_ccc(state->tfifo[0], state->tfifo[1], q->tmp, q->nof_re); - srslte_vec_sc_prod_cfc(q->tmp, state->deltan * state->invtpilotoff, q->tmp, q->nof_re); - srslte_vec_sum_ccc(state->tfifo[1], q->tmp, estimated, q->nof_re); + srsran_vec_sub_ccc(state->tfifo[0], state->tfifo[1], q->tmp, q->nof_re); + srsran_vec_sc_prod_cfc(q->tmp, state->deltan * state->invtpilotoff, q->tmp, q->nof_re); + srsran_vec_sum_ccc(state->tfifo[1], q->tmp, estimated, q->nof_re); state->deltan += 1.0f; - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } -void srslte_wiener_dl_free(srslte_wiener_dl_t* q) +void srsran_wiener_dl_free(srsran_wiener_dl_t* q) { if (q) { - for (uint32_t tx = 0; tx < SRSLTE_MAX_PORTS; tx++) { - for (uint32_t rx = 0; rx < SRSLTE_MAX_PORTS; rx++) { + for (uint32_t tx = 0; tx < SRSRAN_MAX_PORTS; tx++) { + for (uint32_t rx = 0; rx < SRSRAN_MAX_PORTS; rx++) { if (q->state[tx][rx]) { - srslte_wiener_dl_state_free(q->state[tx][rx]); + srsran_wiener_dl_state_free(q->state[tx][rx]); q->state[tx][rx] = NULL; } } @@ -807,14 +807,14 @@ void srslte_wiener_dl_free(srslte_wiener_dl_t* q) } if (q->random) { - srslte_random_free(q->random); + srsran_random_free(q->random); } - srslte_dft_plan_free(&q->fft); - srslte_dft_plan_free(&q->ifft); + srsran_dft_plan_free(&q->fft); + srsran_dft_plan_free(&q->ifft); if (q->matrix_inverter) { - srslte_matrix_NxN_inv_free(q->matrix_inverter); + srsran_matrix_NxN_inv_free(q->matrix_inverter); free(q->matrix_inverter); } } diff --git a/lib/src/phy/channel/CMakeLists.txt b/lib/src/phy/channel/CMakeLists.txt index a1547db25..1df958716 100644 --- a/lib/src/phy/channel/CMakeLists.txt +++ b/lib/src/phy/channel/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -7,6 +7,6 @@ # file(GLOB SOURCES "*.c" "*.cc") -add_library(srslte_channel OBJECT ${SOURCES}) +add_library(srsran_channel OBJECT ${SOURCES}) add_subdirectory(test) \ No newline at end of file diff --git a/lib/src/phy/channel/ch_awgn.c b/lib/src/phy/channel/ch_awgn.c index d2b18a6af..9ca580932 100644 --- a/lib/src/phy/channel/ch_awgn.c +++ b/lib/src/phy/channel/ch_awgn.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -15,27 +15,27 @@ #include #include "gauss.h" -#include -#include -#include -#include +#include +#include +#include +#include #define AWGN_TABLE_READ_BURST 32U #define AWGN_TABLE_SIZE_POW 10U #define AWGN_TABLE_SIZE (1U << AWGN_TABLE_SIZE_POW) -#define AWGN_TABLE_ALLOC_SIZE (AWGN_TABLE_SIZE + SRSLTE_MAX(SRSLTE_SIMD_F_SIZE, AWGN_TABLE_READ_BURST)) +#define AWGN_TABLE_ALLOC_SIZE (AWGN_TABLE_SIZE + SRSRAN_MAX(SRSRAN_SIMD_F_SIZE, AWGN_TABLE_READ_BURST)) // Linear congruential Generator parameters #define AWGN_LCG_A 12345U #define AWGN_LCG_C 1103515245U -static inline int32_t channel_awgn_rand(srslte_channel_awgn_t* q) +static inline int32_t channel_awgn_rand(srsran_channel_awgn_t* q) { q->rand_state = (AWGN_LCG_A + AWGN_LCG_C * q->rand_state); return q->rand_state % AWGN_TABLE_SIZE; } -static inline void channel_awgn_shuffle_tables(srslte_channel_awgn_t* q) +static inline void channel_awgn_shuffle_tables(srsran_channel_awgn_t* q) { for (uint32_t i = 0; i < AWGN_TABLE_SIZE; i++) { int32_t idx; @@ -56,18 +56,18 @@ static inline void channel_awgn_shuffle_tables(srslte_channel_awgn_t* q) } } -int srslte_channel_awgn_init(srslte_channel_awgn_t* q, uint32_t seed) +int srsran_channel_awgn_init(srsran_channel_awgn_t* q, uint32_t seed) { if (!q) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } // Initialise random generator q->rand_state = seed; // Allocate complex exponential and logarithmic tables - q->table_cos = srslte_vec_f_malloc(AWGN_TABLE_ALLOC_SIZE); - q->table_log = srslte_vec_f_malloc(AWGN_TABLE_ALLOC_SIZE); + q->table_cos = srsran_vec_f_malloc(AWGN_TABLE_ALLOC_SIZE); + q->table_log = srsran_vec_f_malloc(AWGN_TABLE_ALLOC_SIZE); if (!q->table_cos || !q->table_log) { ERROR("Malloc"); } @@ -84,29 +84,29 @@ int srslte_channel_awgn_init(srslte_channel_awgn_t* q, uint32_t seed) // Shuffle values in tables to break correlation in SIMD registers channel_awgn_shuffle_tables(q); -#if SRSLTE_SIMD_F_SIZE != 0 +#if SRSRAN_SIMD_F_SIZE != 0 // Copy head in tail for keeping continuity in SIMD registers - for (uint32_t i = 0; i < SRSLTE_SIMD_F_SIZE; i++) { + for (uint32_t i = 0; i < SRSRAN_SIMD_F_SIZE; i++) { q->table_log[i + AWGN_TABLE_SIZE] = q->table_log[i]; q->table_cos[i + AWGN_TABLE_SIZE] = q->table_cos[i]; } #endif - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_channel_awgn_set_n0(srslte_channel_awgn_t* q, float n0_dBfs) +int srsran_channel_awgn_set_n0(srsran_channel_awgn_t* q, float n0_dBfs) { if (!q) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } q->std_dev = powf(10.0f, n0_dBfs / 20.0f); - return isnormal(q->std_dev) ? SRSLTE_SUCCESS : SRSLTE_ERROR; + return isnormal(q->std_dev) ? SRSRAN_SUCCESS : SRSRAN_ERROR; } -static inline void channel_awgn_run(srslte_channel_awgn_t* q, const float* in, float* out, uint32_t size, float std_dev) +static inline void channel_awgn_run(srsran_channel_awgn_t* q, const float* in, float* out, uint32_t size, float std_dev) { if (!q) { return; @@ -116,32 +116,32 @@ static inline void channel_awgn_run(srslte_channel_awgn_t* q, const float* in, f int32_t idx1 = 0; int32_t idx2 = 0; -#if SRSLTE_SIMD_F_SIZE - for (; i < (int)size - SRSLTE_SIMD_F_SIZE + 1; i += SRSLTE_SIMD_F_SIZE) { +#if SRSRAN_SIMD_F_SIZE + for (; i < (int)size - SRSRAN_SIMD_F_SIZE + 1; i += SRSRAN_SIMD_F_SIZE) { if (i % AWGN_TABLE_READ_BURST == 0) { idx1 = channel_awgn_rand(q); idx2 = channel_awgn_rand(q); } else { - idx1 = (idx1 + SRSLTE_SIMD_F_SIZE) % AWGN_TABLE_SIZE; - idx2 = (idx2 + SRSLTE_SIMD_F_SIZE) % AWGN_TABLE_SIZE; + idx1 = (idx1 + SRSRAN_SIMD_F_SIZE) % AWGN_TABLE_SIZE; + idx2 = (idx2 + SRSRAN_SIMD_F_SIZE) % AWGN_TABLE_SIZE; } // Load SIMD registers - simd_f_t t1 = srslte_simd_f_loadu(&q->table_cos[idx1]); - simd_f_t t2 = srslte_simd_f_loadu(&q->table_log[idx2]); - simd_f_t in_ = srslte_simd_f_loadu(&in[i]); - simd_f_t out_ = srslte_simd_f_set1(std_dev); + simd_f_t t1 = srsran_simd_f_loadu(&q->table_cos[idx1]); + simd_f_t t2 = srsran_simd_f_loadu(&q->table_log[idx2]); + simd_f_t in_ = srsran_simd_f_loadu(&in[i]); + simd_f_t out_ = srsran_simd_f_set1(std_dev); // Compute random number - out_ = srslte_simd_f_mul(t1, out_); - out_ = srslte_simd_f_mul(t2, out_); - out_ = srslte_simd_f_add(in_, out_); + out_ = srsran_simd_f_mul(t1, out_); + out_ = srsran_simd_f_mul(t2, out_); + out_ = srsran_simd_f_add(in_, out_); // Store random number - srslte_simd_f_storeu(&out[i], out_); + srsran_simd_f_storeu(&out[i], out_); } -#endif /* SRSLTE_SIMD_F_SIZE */ +#endif /* SRSRAN_SIMD_F_SIZE */ for (; i < size; i++) { @@ -161,17 +161,17 @@ static inline void channel_awgn_run(srslte_channel_awgn_t* q, const float* in, f } } -void srslte_channel_awgn_run_c(srslte_channel_awgn_t* q, const cf_t* in, cf_t* out, uint32_t size) +void srsran_channel_awgn_run_c(srsran_channel_awgn_t* q, const cf_t* in, cf_t* out, uint32_t size) { channel_awgn_run(q, (float*)in, (float*)out, 2 * size, q->std_dev * (float)M_SQRT1_2); } -void srslte_channel_awgn_run_f(srslte_channel_awgn_t* q, const float* in, float* out, uint32_t size) +void srsran_channel_awgn_run_f(srsran_channel_awgn_t* q, const float* in, float* out, uint32_t size) { channel_awgn_run(q, in, out, size, q->std_dev); } -void srslte_channel_awgn_free(srslte_channel_awgn_t* q) +void srsran_channel_awgn_free(srsran_channel_awgn_t* q) { if (!q) { return; @@ -186,13 +186,13 @@ void srslte_channel_awgn_free(srslte_channel_awgn_t* q) } } -float srslte_ch_awgn_get_variance(float ebno_db, float rate) +float srsran_ch_awgn_get_variance(float ebno_db, float rate) { - float esno_db = ebno_db + srslte_convert_power_to_dB(rate); - return srslte_convert_dB_to_amplitude(-esno_db); + float esno_db = ebno_db + srsran_convert_power_to_dB(rate); + return srsran_convert_dB_to_amplitude(-esno_db); } -void srslte_ch_awgn_c(const cf_t* x, cf_t* y, float variance, uint32_t len) +void srsran_ch_awgn_c(const cf_t* x, cf_t* y, float variance, uint32_t len) { cf_t tmp; uint32_t i; @@ -204,7 +204,7 @@ void srslte_ch_awgn_c(const cf_t* x, cf_t* y, float variance, uint32_t len) y[i] = tmp + x[i]; } } -void srslte_ch_awgn_f(const float* x, float* y, float variance, uint32_t len) +void srsran_ch_awgn_f(const float* x, float* y, float variance, uint32_t len) { uint32_t i; diff --git a/lib/src/phy/channel/channel.cc b/lib/src/phy/channel/channel.cc index 877c2a3ed..aa020c210 100644 --- a/lib/src/phy/channel/channel.cc +++ b/lib/src/phy/channel/channel.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,23 +11,23 @@ */ #include -#include -#include +#include +#include -using namespace srslte; +using namespace srsran; channel::channel(const channel::args_t& channel_args, uint32_t _nof_channels, srslog::basic_logger& logger) : logger(logger) { - int ret = SRSLTE_SUCCESS; - uint32_t srate_max = (uint32_t)srslte_symbol_sz(SRSLTE_MAX_PRB) * 15000; - uint32_t buffer_size = (uint32_t)SRSLTE_SF_LEN_PRB(SRSLTE_MAX_PRB) * 5; // be safe, 5 Subframes + int ret = SRSRAN_SUCCESS; + uint32_t srate_max = (uint32_t)srsran_symbol_sz(SRSRAN_MAX_PRB) * 15000; + uint32_t buffer_size = (uint32_t)SRSRAN_SF_LEN_PRB(SRSRAN_MAX_PRB) * 5; // be safe, 5 Subframes - if (_nof_channels > SRSLTE_MAX_CHANNELS) { + if (_nof_channels > SRSRAN_MAX_CHANNELS) { fprintf(stderr, "Error creating channel object: maximum number of channels exceeded (%d > %d)\n", _nof_channels, - SRSLTE_MAX_CHANNELS); + SRSRAN_MAX_CHANNELS); return; } @@ -35,27 +35,27 @@ channel::channel(const channel::args_t& channel_args, uint32_t _nof_channels, sr args = channel_args; // Allocate internal buffers - buffer_in = srslte_vec_cf_malloc(buffer_size); - buffer_out = srslte_vec_cf_malloc(buffer_size); + buffer_in = srsran_vec_cf_malloc(buffer_size); + buffer_out = srsran_vec_cf_malloc(buffer_size); if (!buffer_out || !buffer_in) { - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } nof_channels = _nof_channels; for (uint32_t i = 0; i < nof_channels; i++) { // Create fading channel if (channel_args.fading_enable && !channel_args.fading_model.empty() && channel_args.fading_model != "none" && - ret == SRSLTE_SUCCESS) { - fading[i] = (srslte_channel_fading_t*)calloc(sizeof(srslte_channel_fading_t), 1); - ret = srslte_channel_fading_init(fading[i], srate_max, channel_args.fading_model.c_str(), 0x1234 * i); + ret == SRSRAN_SUCCESS) { + fading[i] = (srsran_channel_fading_t*)calloc(sizeof(srsran_channel_fading_t), 1); + ret = srsran_channel_fading_init(fading[i], srate_max, channel_args.fading_model.c_str(), 0x1234 * i); } else { fading[i] = nullptr; } // Create delay - if (channel_args.delay_enable && ret == SRSLTE_SUCCESS) { - delay[i] = (srslte_channel_delay_t*)calloc(sizeof(srslte_channel_delay_t), 1); - ret = srslte_channel_delay_init(delay[i], + if (channel_args.delay_enable && ret == SRSRAN_SUCCESS) { + delay[i] = (srsran_channel_delay_t*)calloc(sizeof(srsran_channel_delay_t), 1); + ret = srsran_channel_delay_init(delay[i], channel_args.delay_min_us, channel_args.delay_max_us, channel_args.delay_period_s, @@ -67,25 +67,25 @@ channel::channel(const channel::args_t& channel_args, uint32_t _nof_channels, sr } // Create AWGN channnel - if (channel_args.awgn_enable && ret == SRSLTE_SUCCESS) { - awgn = (srslte_channel_awgn_t*)calloc(sizeof(srslte_channel_awgn_t), 1); - ret = srslte_channel_awgn_init(awgn, 1234); - srslte_channel_awgn_set_n0(awgn, args.awgn_signal_power_dBfs - args.awgn_snr_dB); + if (channel_args.awgn_enable && ret == SRSRAN_SUCCESS) { + awgn = (srsran_channel_awgn_t*)calloc(sizeof(srsran_channel_awgn_t), 1); + ret = srsran_channel_awgn_init(awgn, 1234); + srsran_channel_awgn_set_n0(awgn, args.awgn_signal_power_dBfs - args.awgn_snr_dB); } // Create high speed train - if (channel_args.hst_enable && ret == SRSLTE_SUCCESS) { - hst = (srslte_channel_hst_t*)calloc(sizeof(srslte_channel_hst_t), 1); - srslte_channel_hst_init(hst, channel_args.hst_fd_hz, channel_args.hst_period_s, channel_args.hst_init_time_s); + if (channel_args.hst_enable && ret == SRSRAN_SUCCESS) { + hst = (srsran_channel_hst_t*)calloc(sizeof(srsran_channel_hst_t), 1); + srsran_channel_hst_init(hst, channel_args.hst_fd_hz, channel_args.hst_period_s, channel_args.hst_init_time_s); } // Create Radio Link Failure simulator - if (channel_args.rlf_enable && ret == SRSLTE_SUCCESS) { - rlf = (srslte_channel_rlf_t*)calloc(sizeof(srslte_channel_rlf_t), 1); - srslte_channel_rlf_init(rlf, channel_args.rlf_t_on_ms, channel_args.rlf_t_off_ms); + if (channel_args.rlf_enable && ret == SRSRAN_SUCCESS) { + rlf = (srsran_channel_rlf_t*)calloc(sizeof(srsran_channel_rlf_t), 1); + srsran_channel_rlf_init(rlf, channel_args.rlf_t_on_ms, channel_args.rlf_t_off_ms); } - if (ret != SRSLTE_SUCCESS) { + if (ret != SRSRAN_SUCCESS) { fprintf(stderr, "Error: Creating channel\n\n"); } } @@ -101,28 +101,28 @@ channel::~channel() } if (awgn) { - srslte_channel_awgn_free(awgn); + srsran_channel_awgn_free(awgn); free(awgn); } if (hst) { - srslte_channel_hst_free(hst); + srsran_channel_hst_free(hst); free(hst); } if (rlf) { - srslte_channel_rlf_free(rlf); + srsran_channel_rlf_free(rlf); free(rlf); } for (uint32_t i = 0; i < nof_channels; i++) { if (fading[i]) { - srslte_channel_fading_free(fading[i]); + srsran_channel_fading_free(fading[i]); free(fading[i]); } if (delay[i]) { - srslte_channel_delay_free(delay[i]); + srsran_channel_delay_free(delay[i]); free(delay[i]); } } @@ -138,10 +138,10 @@ static inline cf_t local_cexpf(float phase) } } -void channel::run(cf_t* in[SRSLTE_MAX_CHANNELS], - cf_t* out[SRSLTE_MAX_CHANNELS], +void channel::run(cf_t* in[SRSRAN_MAX_CHANNELS], + cf_t* out[SRSRAN_MAX_CHANNELS], uint32_t len, - const srslte_timestamp_t& t) + const srsran_timestamp_t& t) { // Early return if pointers are not enabled if (in == nullptr || out == nullptr) { @@ -158,41 +158,41 @@ void channel::run(cf_t* in[SRSLTE_MAX_CHANNELS], // If sampling rate is not set, copy input and skip rest of channel if (current_srate == 0) { if (in[i] != out[i]) { - srslte_vec_cf_copy(out[i], in[i], len); + srsran_vec_cf_copy(out[i], in[i], len); } continue; } // Copy input buffer - srslte_vec_cf_copy(buffer_in, in[i], len); + srsran_vec_cf_copy(buffer_in, in[i], len); if (hst) { - srslte_channel_hst_execute(hst, buffer_in, buffer_out, len, &t); - srslte_vec_sc_prod_ccc(buffer_out, local_cexpf(hst_init_phase), buffer_in, len); + srsran_channel_hst_execute(hst, buffer_in, buffer_out, len, &t); + srsran_vec_sc_prod_ccc(buffer_out, local_cexpf(hst_init_phase), buffer_in, len); } if (awgn) { - srslte_channel_awgn_run_c(awgn, buffer_in, buffer_out, len); - srslte_vec_cf_copy(buffer_in, buffer_out, len); + srsran_channel_awgn_run_c(awgn, buffer_in, buffer_out, len); + srsran_vec_cf_copy(buffer_in, buffer_out, len); } if (fading[i]) { - srslte_channel_fading_execute(fading[i], buffer_in, buffer_out, len, t.full_secs + t.frac_secs); - srslte_vec_cf_copy(buffer_in, buffer_out, len); + srsran_channel_fading_execute(fading[i], buffer_in, buffer_out, len, t.full_secs + t.frac_secs); + srsran_vec_cf_copy(buffer_in, buffer_out, len); } if (delay[i]) { - srslte_channel_delay_execute(delay[i], buffer_in, buffer_out, len, &t); - srslte_vec_cf_copy(buffer_in, buffer_out, len); + srsran_channel_delay_execute(delay[i], buffer_in, buffer_out, len, &t); + srsran_vec_cf_copy(buffer_in, buffer_out, len); } if (rlf) { - srslte_channel_rlf_execute(rlf, buffer_in, buffer_out, len, &t); - srslte_vec_cf_copy(buffer_in, buffer_out, len); + srsran_channel_rlf_execute(rlf, buffer_in, buffer_out, len, &t); + srsran_vec_cf_copy(buffer_in, buffer_out, len); } // Copy output buffer - srslte_vec_cf_copy(out[i], buffer_in, len); + srsran_vec_cf_copy(out[i], buffer_in, len); } if (hst) { @@ -227,18 +227,18 @@ void channel::set_srate(uint32_t srate) if (current_srate != srate) { for (uint32_t i = 0; i < nof_channels; i++) { if (fading[i]) { - srslte_channel_fading_free(fading[i]); + srsran_channel_fading_free(fading[i]); - srslte_channel_fading_init(fading[i], srate, args.fading_model.c_str(), 0x1234 * i); + srsran_channel_fading_init(fading[i], srate, args.fading_model.c_str(), 0x1234 * i); } if (delay[i]) { - srslte_channel_delay_update_srate(delay[i], srate); + srsran_channel_delay_update_srate(delay[i], srate); } } if (hst) { - srslte_channel_hst_update_srate(hst, srate); + srsran_channel_hst_update_srate(hst, srate); } // Update sampling rate @@ -249,6 +249,6 @@ void channel::set_srate(uint32_t srate) void channel::set_signal_power_dBfs(float power_dBfs) { if (awgn != nullptr) { - srslte_channel_awgn_set_n0(awgn, power_dBfs - args.awgn_snr_dB); + srsran_channel_awgn_set_n0(awgn, power_dBfs - args.awgn_snr_dB); } } diff --git a/lib/src/phy/channel/delay.c b/lib/src/phy/channel/delay.c index 9619dc176..deedc3c64 100644 --- a/lib/src/phy/channel/delay.c +++ b/lib/src/phy/channel/delay.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,17 +11,17 @@ */ #include -#include -#include +#include +#include -static inline double calculate_delay_us(srslte_channel_delay_t* q, const srslte_timestamp_t* ts) +static inline double calculate_delay_us(srsran_channel_delay_t* q, const srsran_timestamp_t* ts) { if (q->period_s) { // Convert period from seconds to samples uint64_t period_nsamples = (uint64_t)roundf(q->period_s * q->srate_hz); // Convert timestamp to samples - uint64_t ts_nsamples = srslte_timestamp_uint64(ts, q->srate_hz) + (uint64_t)q->init_time_s * q->srate_hz; + uint64_t ts_nsamples = srsran_timestamp_uint64(ts, q->srate_hz) + (uint64_t)q->init_time_s * q->srate_hz; // Calculate time modulus in period uint64_t mod_t_nsamples = ts_nsamples - period_nsamples * (ts_nsamples / period_nsamples); @@ -36,17 +36,17 @@ static inline double calculate_delay_us(srslte_channel_delay_t* q, const srslte_ } } -static inline uint32_t calculate_delay_nsamples(srslte_channel_delay_t* q) +static inline uint32_t calculate_delay_nsamples(srsran_channel_delay_t* q) { return (uint32_t)round(q->delay_us * (double)q->srate_hz / 1e6); } -static inline uint32_t ringbuffer_available_nsamples(srslte_channel_delay_t* q) +static inline uint32_t ringbuffer_available_nsamples(srsran_channel_delay_t* q) { - return srslte_ringbuffer_status(&q->rb) / sizeof(cf_t); + return srsran_ringbuffer_status(&q->rb) / sizeof(cf_t); } -int srslte_channel_delay_init(srslte_channel_delay_t* q, +int srsran_channel_delay_init(srsran_channel_delay_t* q, float delay_min_us, float delay_max_us, float period_s, @@ -57,12 +57,12 @@ int srslte_channel_delay_init(srslte_channel_delay_t* q, uint32_t buff_size = (uint32_t)ceilf(delay_max_us * (float)srate_max_hz / 1e6f); // Create ring buffer - int ret = srslte_ringbuffer_init(&q->rb, sizeof(cf_t) * buff_size); + int ret = srsran_ringbuffer_init(&q->rb, sizeof(cf_t) * buff_size); // Create zero buffer - q->zero_buffer = srslte_vec_cf_malloc(buff_size); + q->zero_buffer = srsran_vec_cf_malloc(buff_size); if (!q->zero_buffer) { - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } // Load initial parameters @@ -76,43 +76,43 @@ int srslte_channel_delay_init(srslte_channel_delay_t* q, return ret; } -void srslte_channel_delay_update_srate(srslte_channel_delay_t* q, uint32_t srate_hz) +void srsran_channel_delay_update_srate(srsran_channel_delay_t* q, uint32_t srate_hz) { - srslte_ringbuffer_reset(&q->rb); + srsran_ringbuffer_reset(&q->rb); q->srate_hz = srate_hz; } -void srslte_channel_delay_free(srslte_channel_delay_t* q) +void srsran_channel_delay_free(srsran_channel_delay_t* q) { - srslte_ringbuffer_free(&q->rb); + srsran_ringbuffer_free(&q->rb); if (q->zero_buffer) { free(q->zero_buffer); } } -void srslte_channel_delay_execute(srslte_channel_delay_t* q, +void srsran_channel_delay_execute(srsran_channel_delay_t* q, const cf_t* in, cf_t* out, uint32_t len, - const srslte_timestamp_t* ts) + const srsran_timestamp_t* ts) { q->delay_us = calculate_delay_us(q, ts); q->delay_nsamples = calculate_delay_nsamples(q); uint32_t available_nsamples = ringbuffer_available_nsamples(q); - uint32_t read_nsamples = SRSLTE_MIN(q->delay_nsamples, len); + uint32_t read_nsamples = SRSRAN_MIN(q->delay_nsamples, len); uint32_t copy_nsamples = (len > read_nsamples) ? (len - read_nsamples) : 0; if (available_nsamples < q->delay_nsamples) { uint32_t nzeros = q->delay_nsamples - available_nsamples; - srslte_vec_cf_zero(q->zero_buffer, nzeros); - srslte_ringbuffer_write(&q->rb, q->zero_buffer, sizeof(cf_t) * nzeros); + srsran_vec_cf_zero(q->zero_buffer, nzeros); + srsran_ringbuffer_write(&q->rb, q->zero_buffer, sizeof(cf_t) * nzeros); } else if (available_nsamples > q->delay_nsamples) { - srslte_ringbuffer_read(&q->rb, q->zero_buffer, sizeof(cf_t) * (available_nsamples - q->delay_nsamples)); + srsran_ringbuffer_read(&q->rb, q->zero_buffer, sizeof(cf_t) * (available_nsamples - q->delay_nsamples)); } // Read buffered samples - srslte_ringbuffer_read(&q->rb, out, sizeof(cf_t) * read_nsamples); + srsran_ringbuffer_read(&q->rb, out, sizeof(cf_t) * read_nsamples); // Read other samples if (copy_nsamples) { @@ -120,5 +120,5 @@ void srslte_channel_delay_execute(srslte_channel_delay_t* q, } // Write new sampels - srslte_ringbuffer_write(&q->rb, (void*)&in[copy_nsamples], sizeof(cf_t) * read_nsamples); + srsran_ringbuffer_write(&q->rb, (void*)&in[copy_nsamples], sizeof(cf_t) * read_nsamples); } diff --git a/lib/src/phy/channel/fading.c b/lib/src/phy/channel/fading.c index a4aca2dfc..6973f0e60 100644 --- a/lib/src/phy/channel/fading.c +++ b/lib/src/phy/channel/fading.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,9 +10,9 @@ * */ -#include "srslte/phy/channel/fading.h" -#include "srslte/phy/utils/random.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/channel/fading.h" +#include "srsran/phy/utils/random.h" +#include "srsran/phy/utils/vector.h" #include #include #include @@ -23,45 +23,45 @@ */ const static uint32_t nof_taps[4] = {1, 7, 9, 9}; -const static float excess_tap_delay_ns[4][SRSLTE_CHANNEL_FADING_MAXTAPS] = { +const static float excess_tap_delay_ns[4][SRSRAN_CHANNEL_FADING_MAXTAPS] = { /* None */ {0, NAN, NAN, NAN, NAN, NAN, NAN, NAN, NAN}, /* EPA */ {0, 30, 70, 90, 110, 190, 410, NAN, NAN}, /* EVA */ {0, 30, 150, 310, 370, 710, 1090, 1730, 2510}, /* ETU */ {0, 50, 120, 200, 230, 500, 1600, 2300, 5000}}; -const static float relative_power_db[4][SRSLTE_CHANNEL_FADING_MAXTAPS] = { +const static float relative_power_db[4][SRSRAN_CHANNEL_FADING_MAXTAPS] = { /* None */ {+0.0f, NAN, NAN, NAN, NAN, NAN, NAN, NAN, NAN}, /* EPA */ {+0.0f, -1.0f, -2.0f, -3.0f, -8.0f, -17.2f, -20.8f, NAN, NAN}, /* EVA */ {+0.0f, -1.5f, -1.4f, -3.6f, -0.6f, -9.1f, -7.0f, -12.0f, -16.9f}, /* ETU */ {-1.0f, -1.0f, -1.0f, +0.0f, +0.0f, +0.0f, -3.0f, -5.0f, -7.0f}, }; -static inline int parse_model(srslte_channel_fading_t* q, const char* str) +static inline int parse_model(srsran_channel_fading_t* q, const char* str) { - int ret = SRSLTE_SUCCESS; + int ret = SRSRAN_SUCCESS; uint32_t offset = 3; if (strncmp("none", str, 4) == 0) { - q->model = srslte_channel_fading_model_none; + q->model = srsran_channel_fading_model_none; offset = 4; } else if (strncmp("epa", str, 3) == 0) { - q->model = srslte_channel_fading_model_epa; + q->model = srsran_channel_fading_model_epa; } else if (strncmp("eva", str, 3) == 0) { - q->model = srslte_channel_fading_model_eva; + q->model = srsran_channel_fading_model_eva; } else if (strncmp("etu", str, 3) == 0) { - q->model = srslte_channel_fading_model_etu; + q->model = srsran_channel_fading_model_etu; } else { - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } - if (ret == SRSLTE_SUCCESS) { + if (ret == SRSRAN_SUCCESS) { if (strlen(str) > offset) { q->doppler = (float)strtod(&str[offset], NULL); if (isnan(q->doppler) || isinf(q->doppler)) { q->doppler = 0.0f; } } else { - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } } @@ -99,10 +99,10 @@ static inline __m128 _cosine(float* table, __m128 arg) #endif /*LV_HAVE_SSE*/ static inline cf_t -get_doppler_dispersion(srslte_channel_fading_t* q, float t, float F_d, float* alpha, float* a, float* b) +get_doppler_dispersion(srsran_channel_fading_t* q, float t, float F_d, float* alpha, float* a, float* b) { #ifdef LV_HAVE_SSE - const float recN = 1.0f / sqrtf(SRSLTE_CHANNEL_FADING_NTERMS); + const float recN = 1.0f / sqrtf(SRSRAN_CHANNEL_FADING_NTERMS); cf_t ret = 0; __m128 _reacc = _mm_setzero_ps(); __m128 _imacc = _mm_setzero_ps(); @@ -110,7 +110,7 @@ get_doppler_dispersion(srslte_channel_fading_t* q, float t, float F_d, float* al __m128 _t = _mm_set1_ps(t); __m128 _arg_ = (_mm_mul_ps(_arg, _t)); - for (int i = 0; i < SRSLTE_CHANNEL_FADING_NTERMS; i += 4) { + for (int i = 0; i < SRSRAN_CHANNEL_FADING_NTERMS; i += 4) { __m128 _alpha = _mm_loadu_ps(&alpha[i]); __m128 _a = _mm_loadu_ps(&a[i]); __m128 _b = _mm_loadu_ps(&b[i]); @@ -131,10 +131,10 @@ get_doppler_dispersion(srslte_channel_fading_t* q, float t, float F_d, float* al return ret * recN; #else - const float recN = 1.0f / sqrtf(SRSLTE_CHANNEL_FADING_NTERMS); + const float recN = 1.0f / sqrtf(SRSRAN_CHANNEL_FADING_NTERMS); cf_t r = 0; - for (uint32_t i = 0; i < SRSLTE_CHANNEL_FADING_NTERMS; i++) { + for (uint32_t i = 0; i < SRSRAN_CHANNEL_FADING_NTERMS; i++) { float arg = (float)M_PI * F_d * cosf(alpha[i]) * t; __real__ r += cosf(arg + a[i]); __imag__ r += sinf(arg + b[i]); @@ -146,14 +146,14 @@ get_doppler_dispersion(srslte_channel_fading_t* q, float t, float F_d, float* al static inline void generate_tap(float delay_ns, float power_db, float srate, cf_t* buf, uint32_t N, uint32_t path_delay) { - float amplitude = srslte_convert_dB_to_power(power_db); + float amplitude = srsran_convert_dB_to_power(power_db); float O = (delay_ns * 1e-9f * srate + path_delay) / (float)N; cf_t a0 = amplitude / N; - srslte_vec_gen_sine(a0, -O, buf, N); + srsran_vec_gen_sine(a0, -O, buf, N); } -static inline void generate_taps(srslte_channel_fading_t* q, float time) +static inline void generate_taps(srsran_channel_fading_t* q, float time) { // Generate taps for (int i = 0; i < nof_taps[q->model]; i++) { @@ -162,53 +162,53 @@ static inline void generate_taps(srslte_channel_fading_t* q, float time) if (i) { // Copy tap frequency response - srslte_vec_sc_prod_ccc(q->h_tap[i], a, q->temp, q->N); + srsran_vec_sc_prod_ccc(q->h_tap[i], a, q->temp, q->N); // Add to frequency response, shifts FFT at same time - srslte_vec_sum_ccc(q->h_freq, &q->temp[q->N / 2], q->h_freq, q->N / 2); - srslte_vec_sum_ccc(&q->h_freq[q->N / 2], q->temp, &q->h_freq[q->N / 2], q->N / 2); + srsran_vec_sum_ccc(q->h_freq, &q->temp[q->N / 2], q->h_freq, q->N / 2); + srsran_vec_sum_ccc(&q->h_freq[q->N / 2], q->temp, &q->h_freq[q->N / 2], q->N / 2); } else { // Copy tap frequency response - srslte_vec_sc_prod_ccc(&q->h_tap[i][q->N / 2], a, q->h_freq, q->N / 2); - srslte_vec_sc_prod_ccc(&q->h_tap[i][0], a, &q->h_freq[q->N / 2], q->N / 2); + srsran_vec_sc_prod_ccc(&q->h_tap[i][q->N / 2], a, q->h_freq, q->N / 2); + srsran_vec_sc_prod_ccc(&q->h_tap[i][0], a, &q->h_freq[q->N / 2], q->N / 2); } } // at this stage, q->h_freq should contain the frequency response } -static inline void filter_segment(srslte_channel_fading_t* q, const cf_t* input, cf_t* output, uint32_t nsamples) +static inline void filter_segment(srsran_channel_fading_t* q, const cf_t* input, cf_t* output, uint32_t nsamples) { // Fill Input vector - srslte_vec_cf_copy(q->temp, input, nsamples); - srslte_vec_cf_zero(&q->temp[nsamples], q->N - nsamples); + srsran_vec_cf_copy(q->temp, input, nsamples); + srsran_vec_cf_zero(&q->temp[nsamples], q->N - nsamples); // Do FFT - srslte_dft_run_c_zerocopy(&q->fft, q->temp, q->y_freq); + srsran_dft_run_c_zerocopy(&q->fft, q->temp, q->y_freq); // Apply channel - srslte_vec_prod_ccc(q->y_freq, q->h_freq, q->y_freq, q->N); + srsran_vec_prod_ccc(q->y_freq, q->h_freq, q->y_freq, q->N); // Do iFFT - srslte_dft_run_c_zerocopy(&q->ifft, q->y_freq, q->temp); + srsran_dft_run_c_zerocopy(&q->ifft, q->y_freq, q->temp); // Add state - srslte_vec_sum_ccc(q->temp, q->state, q->temp, q->state_len); + srsran_vec_sum_ccc(q->temp, q->state, q->temp, q->state_len); // Copy the first nsamples into the output - srslte_vec_cf_copy(output, q->temp, nsamples); + srsran_vec_cf_copy(output, q->temp, nsamples); // Copy the rest of the samples into the state q->state_len = q->N - nsamples; - srslte_vec_cf_copy(q->state, &q->temp[nsamples], q->state_len); + srsran_vec_cf_copy(q->state, &q->temp[nsamples], q->state_len); } -int srslte_channel_fading_init(srslte_channel_fading_t* q, double srate, const char* model, uint32_t seed) +int srsran_channel_fading_init(srsran_channel_fading_t* q, double srate, const char* model, uint32_t seed) { - int ret = SRSLTE_ERROR; + int ret = SRSRAN_ERROR; if (q) { // Parse model - if (parse_model(q, model) != SRSLTE_SUCCESS) { + if (parse_model(q, model) != SRSRAN_SUCCESS) { fprintf(stderr, "Error: invalid channel model '%s'\n", model); goto clean_exit; } @@ -219,24 +219,24 @@ int srslte_channel_fading_init(srslte_channel_fading_t* q, double srate, const c // Populate internal parameters uint32_t fft_min_pow = (uint32_t)round(log2(excess_tap_delay_ns[q->model][nof_taps[q->model] - 1] * 1e-9 * srate)) + 3; - q->N = SRSLTE_MAX(1U << fft_min_pow, (uint32_t)(srate / (15e3f * 4.0f))); + q->N = SRSRAN_MAX(1U << fft_min_pow, (uint32_t)(srate / (15e3f * 4.0f))); q->path_delay = q->N / 4; q->state_len = 0; // Initialise random number - srslte_random_t* random = srslte_random_init(seed); + srsran_random_t* random = srsran_random_init(seed); // Initialise values for each tap for (uint32_t i = 0; i < nof_taps[q->model]; i++) { // Random Jakes model Coeffients - for (uint32_t j = 0; (float)j < SRSLTE_CHANNEL_FADING_NTERMS; j++) { - q->coeff_a[i][j] = srslte_random_uniform_real_dist(random, 0, 2.0f * (float)M_PI); - q->coeff_b[i][j] = srslte_random_uniform_real_dist(random, 0, 2.0f * (float)M_PI); + for (uint32_t j = 0; (float)j < SRSRAN_CHANNEL_FADING_NTERMS; j++) { + q->coeff_a[i][j] = srsran_random_uniform_real_dist(random, 0, 2.0f * (float)M_PI); + q->coeff_b[i][j] = srsran_random_uniform_real_dist(random, 0, 2.0f * (float)M_PI); q->coeff_alpha[i][j] = ((float)M_PI * ((float)i - (float)0.5f)) / (2.0f * nof_taps[q->model]); } // Allocate tap frequency response - q->h_tap[i] = srslte_vec_cf_malloc(q->N); + q->h_tap[i] = srsran_vec_cf_malloc(q->N); // Generate tap frequency response generate_tap( @@ -249,58 +249,58 @@ int srslte_channel_fading_init(srslte_channel_fading_t* q, double srate, const c } // Free random - srslte_random_free(random); + srsran_random_free(random); // Plan FFT - if (srslte_dft_plan_c(&q->fft, q->N, SRSLTE_DFT_FORWARD) != SRSLTE_SUCCESS) { + if (srsran_dft_plan_c(&q->fft, q->N, SRSRAN_DFT_FORWARD) != SRSRAN_SUCCESS) { fprintf(stderr, "Error: planning fft\n"); goto clean_exit; } // Plan iFFT - if (srslte_dft_plan_c(&q->ifft, q->N, SRSLTE_DFT_BACKWARD) != SRSLTE_SUCCESS) { + if (srsran_dft_plan_c(&q->ifft, q->N, SRSRAN_DFT_BACKWARD) != SRSRAN_SUCCESS) { fprintf(stderr, "Error: planning ifft\n"); goto clean_exit; } // Allocate memory - q->temp = srslte_vec_cf_malloc(q->N); + q->temp = srsran_vec_cf_malloc(q->N); if (!q->temp) { fprintf(stderr, "Error: allocating h_freq\n"); goto clean_exit; } - q->h_freq = srslte_vec_cf_malloc(q->N); + q->h_freq = srsran_vec_cf_malloc(q->N); if (!q->h_freq) { fprintf(stderr, "Error: allocating h_freq\n"); goto clean_exit; } - q->y_freq = srslte_vec_cf_malloc(q->N); + q->y_freq = srsran_vec_cf_malloc(q->N); if (!q->y_freq) { fprintf(stderr, "Error: allocating y_freq\n"); goto clean_exit; } - q->state = srslte_vec_cf_malloc(q->N); + q->state = srsran_vec_cf_malloc(q->N); if (!q->state) { fprintf(stderr, "Error: allocating y_freq\n"); goto clean_exit; } - srslte_vec_cf_zero(q->state, q->N); + srsran_vec_cf_zero(q->state, q->N); } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; clean_exit: return ret; } -void srslte_channel_fading_free(srslte_channel_fading_t* q) +void srsran_channel_fading_free(srsran_channel_fading_t* q) { if (q) { - srslte_dft_plan_free(&q->fft); - srslte_dft_plan_free(&q->ifft); + srsran_dft_plan_free(&q->fft); + srsran_dft_plan_free(&q->ifft); if (q->temp) { free(q->temp); @@ -326,7 +326,7 @@ void srslte_channel_fading_free(srslte_channel_fading_t* q) } } -double srslte_channel_fading_execute(srslte_channel_fading_t* q, +double srsran_channel_fading_execute(srsran_channel_fading_t* q, const cf_t* in, cf_t* out, uint32_t nsamples, @@ -340,7 +340,7 @@ double srslte_channel_fading_execute(srslte_channel_fading_t* q, generate_taps(q, (float)init_time); // Do not process more than N/2 samples - uint32_t n = SRSLTE_MIN(q->N / 2, nsamples - counter); + uint32_t n = SRSRAN_MIN(q->N / 2, nsamples - counter); // Execute filter_segment(q, &in[counter], &out[counter], n); diff --git a/lib/src/phy/channel/gauss.c b/lib/src/phy/channel/gauss.c index 91e2bc890..97333f2fa 100644 --- a/lib/src/phy/channel/gauss.c +++ b/lib/src/phy/channel/gauss.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/lib/src/phy/channel/gauss.h b/lib/src/phy/channel/gauss.h index 711beb752..faf3c1133 100644 --- a/lib/src/phy/channel/gauss.h +++ b/lib/src/phy/channel/gauss.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/lib/src/phy/channel/hst.c b/lib/src/phy/channel/hst.c index bb788c74b..715793ca8 100644 --- a/lib/src/phy/channel/hst.c +++ b/lib/src/phy/channel/hst.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,14 +10,14 @@ * */ -#include "srslte/phy/channel/hst.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/channel/hst.h" +#include "srsran/phy/utils/vector.h" #include #include -int srslte_channel_hst_init(srslte_channel_hst_t* q, float fd_hz, float period_d, float init_time_s) +int srsran_channel_hst_init(srsran_channel_hst_t* q, float fd_hz, float period_d, float init_time_s) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q) { q->fd_hz = fd_hz; // Hz @@ -26,31 +26,31 @@ int srslte_channel_hst_init(srslte_channel_hst_t* q, float fd_hz, float period_d q->period_s = period_d; // s q->init_time_s = init_time_s; // s q->fs_hz = NAN; - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } -void srslte_channel_hst_update_srate(srslte_channel_hst_t* q, uint32_t srate) +void srsran_channel_hst_update_srate(srsran_channel_hst_t* q, uint32_t srate) { if (q) { q->srate_hz = srate; } } -void srslte_channel_hst_execute(srslte_channel_hst_t* q, +void srsran_channel_hst_execute(srsran_channel_hst_t* q, cf_t* in, cf_t* out, uint32_t len, - const srslte_timestamp_t* ts) + const srsran_timestamp_t* ts) { if (q && q->srate_hz) { // Convert period from seconds to samples uint64_t period_nsamples = (uint64_t)roundf(q->period_s * q->srate_hz); // Convert timestamp to samples - uint64_t ts_nsamples = srslte_timestamp_uint64(ts, q->srate_hz) + (uint64_t)q->init_time_s * q->srate_hz; + uint64_t ts_nsamples = srsran_timestamp_uint64(ts, q->srate_hz) + (uint64_t)q->init_time_s * q->srate_hz; // Calculate time modulus in period uint64_t mod_t_nsamples = ts_nsamples - period_nsamples * (ts_nsamples / period_nsamples); @@ -72,13 +72,13 @@ void srslte_channel_hst_execute(srslte_channel_hst_t* q, q->fs_hz = q->fd_hz * costheta; // Apply doppler shift, assume the doppler does not vary in a sub-frame - srslte_vec_apply_cfo(in, -q->fs_hz / q->srate_hz, out, len); + srsran_vec_apply_cfo(in, -q->fs_hz / q->srate_hz, out, len); } } -void srslte_channel_hst_free(srslte_channel_hst_t* q) +void srsran_channel_hst_free(srsran_channel_hst_t* q) { if (q) { - bzero(q, sizeof(srslte_channel_hst_t)); + bzero(q, sizeof(srsran_channel_hst_t)); } } diff --git a/lib/src/phy/channel/rlf.c b/lib/src/phy/channel/rlf.c index f3485c77d..92be5d780 100644 --- a/lib/src/phy/channel/rlf.c +++ b/lib/src/phy/channel/rlf.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,20 +10,20 @@ * */ -#include -#include +#include +#include -void srslte_channel_rlf_init(srslte_channel_rlf_t* q, uint32_t t_on_ms, uint32_t t_off_ms) +void srsran_channel_rlf_init(srsran_channel_rlf_t* q, uint32_t t_on_ms, uint32_t t_off_ms) { q->t_on_ms = t_on_ms; q->t_off_ms = t_off_ms; } -void srslte_channel_rlf_execute(srslte_channel_rlf_t* q, +void srsran_channel_rlf_execute(srsran_channel_rlf_t* q, const cf_t* in, cf_t* out, uint32_t nsamples, - const srslte_timestamp_t* ts) + const srsran_timestamp_t* ts) { // Caulculate full period in MS uint64_t period_ms = q->t_on_ms + q->t_off_ms; @@ -39,13 +39,13 @@ void srslte_channel_rlf_execute(srslte_channel_rlf_t* q, // Decide whether enables or disables channel if (time_ms < q->t_on_ms) { - srslte_vec_sc_prod_cfc(in, 1.0f, out, nsamples); + srsran_vec_sc_prod_cfc(in, 1.0f, out, nsamples); } else { - srslte_vec_sc_prod_cfc(in, 0.0f, out, nsamples); + srsran_vec_sc_prod_cfc(in, 0.0f, out, nsamples); } } -void srslte_channel_rlf_free(srslte_channel_rlf_t* q) +void srsran_channel_rlf_free(srsran_channel_rlf_t* q) { // Do nothing } diff --git a/lib/src/phy/channel/test/CMakeLists.txt b/lib/src/phy/channel/test/CMakeLists.txt index b16882860..07c0c8083 100644 --- a/lib/src/phy/channel/test/CMakeLists.txt +++ b/lib/src/phy/channel/test/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -12,23 +12,23 @@ if(SRSGUI_FOUND) target_link_libraries(fading_channel_test ${SRSGUI_LIBRARIES}) endif(SRSGUI_FOUND) -target_link_libraries(fading_channel_test srslte_phy srslte_common srslte_phy ${SEC_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) +target_link_libraries(fading_channel_test srsran_phy srsran_common srsran_phy ${SEC_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) add_test(fading_channel_test_epa5 fading_channel_test -m epa5 -s 26.04e6 -t 100) add_test(fading_channel_test_eva70 fading_channel_test -m eva70 -s 23.04e6 -t 100) add_test(fading_channel_test_etu300 fading_channel_test -m etu70 -s 23.04e6 -t 100) add_executable(delay_channel_test delay_channel_test.c) -target_link_libraries(delay_channel_test srslte_phy srslte_common srslte_phy ${SEC_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) +target_link_libraries(delay_channel_test srsran_phy srsran_common srsran_phy ${SEC_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) add_test(delay_channel_test delay_channel_test -m 10 -M 100 -t 1000 -T 1 -s 1.92e6) add_executable(hst_channel_test hst_channel_test.c) -target_link_libraries(hst_channel_test srslte_phy srslte_common srslte_phy ${SEC_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) +target_link_libraries(hst_channel_test srsran_phy srsran_common srsran_phy ${SEC_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) add_test(hst_channel_test hst_channel_test -f 750 -t 7.2 -i 0 -T 1 -s 1.92e6) add_executable(awgn_channel_test awgn_channel_test.c) if(SRSGUI_FOUND) target_link_libraries(awgn_channel_test ${SRSGUI_LIBRARIES}) endif(SRSGUI_FOUND) -target_link_libraries(awgn_channel_test srslte_phy srslte_common srslte_phy ${SEC_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) +target_link_libraries(awgn_channel_test srsran_phy srsran_common srsran_phy ${SEC_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) add_test(awgn_channel_test awgn_channel_test) diff --git a/lib/src/phy/channel/test/awgn_channel_test.c b/lib/src/phy/channel/test/awgn_channel_test.c index 86bccda6a..9ebd10c0c 100644 --- a/lib/src/phy/channel/test/awgn_channel_test.c +++ b/lib/src/phy/channel/test/awgn_channel_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,11 +10,11 @@ * */ -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/utils/vector.h" #include -#include -#include -#include +#include +#include +#include #include #undef ENABLE_GUI @@ -22,7 +22,7 @@ #include "srsgui/srsgui.h" #endif /* ENABLE_GUI */ -static srslte_channel_awgn_t awgn = {}; +static srsran_channel_awgn_t awgn = {}; static uint32_t nof_samples = 1920 * 8; static float n0_min = 0.0f; @@ -69,7 +69,7 @@ static void parse_args(int argc, char** argv) int main(int argc, char** argv) { - int ret = SRSLTE_SUCCESS; + int ret = SRSRAN_SUCCESS; cf_t* input_buffer = NULL; cf_t* output_buffer = NULL; uint64_t count_samples = 0; @@ -79,16 +79,16 @@ int main(int argc, char** argv) parse_args(argc, argv); // Initialise buffers - input_buffer = srslte_vec_cf_malloc(nof_samples); - output_buffer = srslte_vec_cf_malloc(nof_samples); + input_buffer = srsran_vec_cf_malloc(nof_samples); + output_buffer = srsran_vec_cf_malloc(nof_samples); if (!input_buffer || !output_buffer) { ERROR("Error: Allocating memory"); - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } // Initialise input - srslte_vec_cf_zero(input_buffer, nof_samples); + srsran_vec_cf_zero(input_buffer, nof_samples); #ifdef ENABLE_GUI sdrgui_init(); @@ -104,52 +104,52 @@ int main(int argc, char** argv) plot_scatter_setTitle(&plot_fft, "IQ"); plot_scatter_addToWindowGrid(&plot_fft, (char*)"IQ", 1, 0); - cf_t* fft_out = srslte_vec_cf_malloc(nof_samples); - srslte_dft_plan_t fft = {}; - if (srslte_dft_plan_c(&fft, nof_samples, SRSLTE_DFT_FORWARD)) { + cf_t* fft_out = srsran_vec_cf_malloc(nof_samples); + srsran_dft_plan_t fft = {}; + if (srsran_dft_plan_c(&fft, nof_samples, SRSRAN_DFT_FORWARD)) { ERROR("Error: init DFT"); - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } #endif /* ENABLE_GUI */ // Initialise AWGN channel - if (ret == SRSLTE_SUCCESS) { - ret = srslte_channel_awgn_init(&awgn, 0); + if (ret == SRSRAN_SUCCESS) { + ret = srsran_channel_awgn_init(&awgn, 0); } float n0 = n0_min; while (!isnan(n0) && !isinf(n0) && n0 < n0_max) { struct timeval t[3] = {}; - srslte_channel_awgn_set_n0(&awgn, n0); + srsran_channel_awgn_set_n0(&awgn, n0); // Run actual test gettimeofday(&t[1], NULL); - srslte_channel_awgn_run_c(&awgn, input_buffer, output_buffer, nof_samples); + srsran_channel_awgn_run_c(&awgn, input_buffer, output_buffer, nof_samples); gettimeofday(&t[2], NULL); get_time_interval(t); - float power = srslte_vec_avg_power_cf(output_buffer, nof_samples); - float power_dB = srslte_convert_power_to_dB(power); + float power = srsran_vec_avg_power_cf(output_buffer, nof_samples); + float power_dB = srsran_convert_power_to_dB(power); if ((n0 + tolerance) < power_dB || (n0 - tolerance) > power_dB) { printf("-- failed: %.3f<%.3f<%.3f\n", n0 - tolerance, power_dB, n0 + tolerance); - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } #ifdef ENABLE_GUI plot_scatter_setNewData(&plot_scatter, output_buffer, nof_samples); - srslte_dft_run_c(&fft, output_buffer, fft_out); + srsran_dft_run_c(&fft, output_buffer, fft_out); float min = +INFINITY; float max = -INFINITY; float* fft_mag = (float*)fft_out; for (uint32_t i = 0; i < nof_samples; i++) { - float mag = srslte_convert_amplitude_to_dB(cabsf(fft_out[i])); + float mag = srsran_convert_amplitude_to_dB(cabsf(fft_out[i])); - min = SRSLTE_MIN(min, mag); - max = SRSLTE_MAX(max, mag); + min = SRSRAN_MIN(min, mag); + max = SRSRAN_MAX(max, mag); fft_mag[i] = mag; } @@ -167,7 +167,7 @@ int main(int argc, char** argv) } // Free - srslte_channel_awgn_free(&awgn); + srsran_channel_awgn_free(&awgn); if (input_buffer) { free(input_buffer); @@ -181,7 +181,7 @@ int main(int argc, char** argv) if (fft_out) { free(fft_out); } - srslte_dft_plan_free(&fft); + srsran_dft_plan_free(&fft); #endif /* ENABLE_GUI */ // Print result and exit @@ -190,7 +190,7 @@ int main(int argc, char** argv) n0_max, n0_step, nof_samples, - (ret == SRSLTE_SUCCESS) ? "Passed" : "Failed", + (ret == SRSRAN_SUCCESS) ? "Passed" : "Failed", (double)nof_samples / (double)count_us); return ret; } diff --git a/lib/src/phy/channel/test/delay_channel_test.c b/lib/src/phy/channel/test/delay_channel_test.c index 561ca6762..0920951a2 100644 --- a/lib/src/phy/channel/test/delay_channel_test.c +++ b/lib/src/phy/channel/test/delay_channel_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,13 +10,13 @@ * */ -#include "srslte/phy/utils/vector.h" -#include -#include -#include +#include "srsran/phy/utils/vector.h" +#include +#include +#include #include -static srslte_channel_delay_t delay = {}; +static srsran_channel_delay_t delay = {}; static uint32_t delay_min_us = 10; static uint32_t delay_max_us = 3333; @@ -66,11 +66,11 @@ static void parse_args(int argc, char** argv) int main(int argc, char** argv) { - int ret = SRSLTE_SUCCESS; + int ret = SRSRAN_SUCCESS; cf_t* input_buffer = NULL; cf_t* output_buffer = NULL; - srslte_timestamp_t ts = {}; // Initialised to zero - srslte_random_t random_gen = srslte_random_init(0x1234); + srsran_timestamp_t ts = {}; // Initialised to zero + srsran_random_t random_gen = srsran_random_init(0x1234); struct timeval t[3] = {}; // Parse arguments @@ -78,38 +78,38 @@ int main(int argc, char** argv) // Initialise buffers uint32_t size = srate_hz / 1000; - input_buffer = srslte_vec_cf_malloc(size); - output_buffer = srslte_vec_cf_malloc(size); + input_buffer = srsran_vec_cf_malloc(size); + output_buffer = srsran_vec_cf_malloc(size); if (!input_buffer || !output_buffer) { fprintf(stderr, "Error: Allocating memory\n"); - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } // Generate random samples - srslte_random_uniform_complex_dist_vector(random_gen, input_buffer, size, -1.0f, +1.0f); + srsran_random_uniform_complex_dist_vector(random_gen, input_buffer, size, -1.0f, +1.0f); // Initialise delay channel - if (ret == SRSLTE_SUCCESS) { - ret = srslte_channel_delay_init(&delay, delay_min_us, delay_max_us, delay_period_s, delay_init_time_s, srate_hz); + if (ret == SRSRAN_SUCCESS) { + ret = srsran_channel_delay_init(&delay, delay_min_us, delay_max_us, delay_period_s, delay_init_time_s, srate_hz); } // Run actual test gettimeofday(&t[1], NULL); - for (int i = 0; i < sim_time_periods && ret == SRSLTE_SUCCESS; i++) { + for (int i = 0; i < sim_time_periods && ret == SRSRAN_SUCCESS; i++) { for (int j = 0; j < 1000 * delay_period_s; j++) { // Run delay channel - srslte_channel_delay_execute(&delay, input_buffer, output_buffer, size, &ts); + srsran_channel_delay_execute(&delay, input_buffer, output_buffer, size, &ts); // Increment timestamp 1ms - srslte_timestamp_add(&ts, 0, 0.001); + srsran_timestamp_add(&ts, 0, 0.001); } } gettimeofday(&t[2], NULL); get_time_interval(t); // Free - srslte_random_free(random_gen); - srslte_channel_delay_free(&delay); + srsran_random_free(random_gen); + srsran_channel_delay_free(&delay); if (input_buffer) { free(input_buffer); @@ -129,7 +129,7 @@ int main(int argc, char** argv) delay_period_s, srate_hz, sim_time_periods, - (ret == SRSLTE_SUCCESS) ? "Passed" : "Failed", + (ret == SRSRAN_SUCCESS) ? "Passed" : "Failed", (double)nof_samples / elapsed_us); exit(ret); } diff --git a/lib/src/phy/channel/test/fading_channel_test.c b/lib/src/phy/channel/test/fading_channel_test.c index cd41bdc39..afc0566e6 100644 --- a/lib/src/phy/channel/test/fading_channel_test.c +++ b/lib/src/phy/channel/test/fading_channel_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,12 +10,12 @@ * */ -#include "srslte/phy/channel/fading.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/channel/fading.h" +#include "srsran/phy/utils/vector.h" #include #include #include -#include +#include #include #include #include @@ -27,7 +27,7 @@ static bool enable_gui = false; #endif /* ENABLE_GUI */ -static srslte_channel_fading_t channel_fading; +static srsran_channel_fading_t channel_fading; static char default_model[] = "epa5"; static uint32_t duration_ms = 1000; @@ -80,7 +80,7 @@ static void parse_args(int argc, char** argv) int main(int argc, char** argv) { - int ret = SRSLTE_ERROR; + int ret = SRSRAN_ERROR; cf_t* input_buffer = NULL; cf_t* output_buffer = NULL; struct timeval t[3] = {}; @@ -88,15 +88,15 @@ int main(int argc, char** argv) parse_args(argc, argv); - srslte_dft_plan_t ifft; - srslte_dft_plan_c(&ifft, srate / 1000, SRSLTE_DFT_BACKWARD); + srsran_dft_plan_t ifft; + srsran_dft_plan_c(&ifft, srate / 1000, SRSRAN_DFT_BACKWARD); #ifdef ENABLE_GUI plot_real_t plot_fft = NULL; plot_real_t plot_h = NULL; plot_real_t plot_imp = NULL; - srslte_dft_plan_t fft = {}; + srsran_dft_plan_t fft = {}; cf_t* fft_buffer = NULL; float* fft_mag = NULL; float* imp = NULL; @@ -120,21 +120,21 @@ int main(int argc, char** argv) plot_real_setYAxisScale(&plot_imp, 0, 5); plot_real_addToWindowGrid(&plot_imp, (char*)"fading", 0, 2); - srslte_dft_plan_c(&fft, srate / 1000, SRSLTE_DFT_FORWARD); + srsran_dft_plan_c(&fft, srate / 1000, SRSRAN_DFT_FORWARD); - fft_buffer = srslte_vec_cf_malloc(srate / 1000); + fft_buffer = srsran_vec_cf_malloc(srate / 1000); if (!fft_buffer) { fprintf(stderr, "Error: malloc\n"); goto clean_exit; } - fft_mag = srslte_vec_f_malloc(srate / 1000); + fft_mag = srsran_vec_f_malloc(srate / 1000); if (!fft_mag) { fprintf(stderr, "Error: malloc\n"); goto clean_exit; } - imp = srslte_vec_f_malloc(srate / 1000); + imp = srsran_vec_f_malloc(srate / 1000); if (!imp) { fprintf(stderr, "Error: malloc\n"); goto clean_exit; @@ -143,29 +143,29 @@ int main(int argc, char** argv) #endif /* ENABLE_GUI */ // Initialise channel - if (srslte_channel_fading_init(&channel_fading, srate, model, 0x12345678)) { + if (srsran_channel_fading_init(&channel_fading, srate, model, 0x12345678)) { fprintf(stderr, "Error: initialising fading channel. model=%s, srate=%d\n", model, srate); goto clean_exit; } // Allocate buffers - input_buffer = srslte_vec_cf_malloc(srate / 1000); + input_buffer = srsran_vec_cf_malloc(srate / 1000); if (!input_buffer) { fprintf(stderr, "Error: allocating input buffer\n"); goto clean_exit; } #if INPUT_TYPE == 0 - srslte_vec_cf_zero(input_buffer, srate / 1000); + srsran_vec_cf_zero(input_buffer, srate / 1000); input_buffer[0] = 1; #else for (int i = 0; i < srate / 1000; i++) { input_buffer[i] = cexpf(_Complex_I * ((double)rand() / (double)RAND_MAX) * M_PI / 2.0) / ((double)srate / 1000.0); } - srslte_dft_run_c(&ifft, input_buffer, input_buffer); + srsran_dft_run_c(&ifft, input_buffer, input_buffer); #endif - output_buffer = srslte_vec_cf_malloc(srate / 1000); + output_buffer = srsran_vec_cf_malloc(srate / 1000); if (!output_buffer) { fprintf(stderr, "Error: allocating output buffer\n"); goto clean_exit; @@ -178,22 +178,22 @@ int main(int argc, char** argv) for (int i = 0; i < duration_ms; i++) { gettimeofday(&t[1], NULL); - srslte_channel_fading_execute(&channel_fading, input_buffer, output_buffer, srate / 1000, (double)i / 1000.0); + srsran_channel_fading_execute(&channel_fading, input_buffer, output_buffer, srate / 1000, (double)i / 1000.0); gettimeofday(&t[2], NULL); get_time_interval(t); time_usec += (uint64_t)(t->tv_sec * 1e6 + t->tv_usec); #ifdef ENABLE_GUI if (enable_gui) { - srslte_dft_run_c_zerocopy(&fft, output_buffer, fft_buffer); - srslte_vec_prod_conj_ccc(fft_buffer, fft_buffer, fft_buffer, srate / 1000); + srsran_dft_run_c_zerocopy(&fft, output_buffer, fft_buffer); + srsran_vec_prod_conj_ccc(fft_buffer, fft_buffer, fft_buffer, srate / 1000); for (int j = 0; j < srate / 1000; j++) { - fft_mag[j] = srslte_convert_power_to_dB(__real__ fft_buffer[j]); + fft_mag[j] = srsran_convert_power_to_dB(__real__ fft_buffer[j]); } plot_real_setNewData(&plot_fft, fft_mag, srate / 1000); for (int j = 0; j < channel_fading.N; j++) { - fft_mag[j] = srslte_convert_amplitude_to_dB(cabsf(channel_fading.h_freq[j])); + fft_mag[j] = srsran_convert_amplitude_to_dB(cabsf(channel_fading.h_freq[j])); } plot_real_setNewData(&plot_h, fft_mag, channel_fading.N); @@ -207,7 +207,7 @@ int main(int argc, char** argv) #endif /* ENABLE_GUI */ } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; clean_exit: if (ret) { @@ -216,7 +216,7 @@ clean_exit: printf("Ok ... %.1f MSps\n", duration_ms * (srate / 1000.0) / (double)time_usec); } - srslte_dft_plan_free(&ifft); + srsran_dft_plan_free(&ifft); #ifdef ENABLE_GUI if (enable_gui) { @@ -230,7 +230,7 @@ clean_exit: if (fft_buffer) { free(fft_buffer); } - srslte_dft_plan_free(&fft); + srsran_dft_plan_free(&fft); } #endif /* ENABLE_GUI */ if (input_buffer) { @@ -239,6 +239,6 @@ clean_exit: if (output_buffer) { free(output_buffer); } - srslte_channel_fading_free(&channel_fading); + srsran_channel_fading_free(&channel_fading); return ret; } diff --git a/lib/src/phy/channel/test/hst_channel_test.c b/lib/src/phy/channel/test/hst_channel_test.c index a5aaba850..e30de050e 100644 --- a/lib/src/phy/channel/test/hst_channel_test.c +++ b/lib/src/phy/channel/test/hst_channel_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,12 +10,12 @@ * */ -#include "srslte/phy/utils/vector.h" -#include -#include +#include "srsran/phy/utils/vector.h" +#include +#include #include -static srslte_channel_hst_t hst = {}; +static srsran_channel_hst_t hst = {}; static float fd_hz = 750; static float period_s = 7.2; @@ -64,10 +64,10 @@ static void parse_args(int argc, char** argv) int main(int argc, char** argv) { - int ret = SRSLTE_SUCCESS; + int ret = SRSRAN_SUCCESS; cf_t* input_buffer = NULL; cf_t* output_buffer = NULL; - srslte_timestamp_t ts = {}; // Initialised to zero + srsran_timestamp_t ts = {}; // Initialised to zero struct timeval t[3] = {}; // Parse arguments @@ -75,40 +75,40 @@ int main(int argc, char** argv) // Initialise buffers uint32_t size = srate_hz / 1000; // 1 ms samples - input_buffer = srslte_vec_cf_malloc(size); - output_buffer = srslte_vec_cf_malloc(size); + input_buffer = srsran_vec_cf_malloc(size); + output_buffer = srsran_vec_cf_malloc(size); if (!input_buffer || !output_buffer) { fprintf(stderr, "Error: Allocating memory\n"); - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } // Generate random samples - if (ret == SRSLTE_SUCCESS) { - srslte_vec_gen_sine(1.0f, 0.0f, input_buffer, size); + if (ret == SRSRAN_SUCCESS) { + srsran_vec_gen_sine(1.0f, 0.0f, input_buffer, size); } // Initialise delay channel - if (ret == SRSLTE_SUCCESS) { - ret = srslte_channel_hst_init(&hst, fd_hz, period_s, init_time_s); - srslte_channel_hst_update_srate(&hst, srate_hz); + if (ret == SRSRAN_SUCCESS) { + ret = srsran_channel_hst_init(&hst, fd_hz, period_s, init_time_s); + srsran_channel_hst_update_srate(&hst, srate_hz); } // Run actual test gettimeofday(&t[1], NULL); - for (int i = 0; i < sim_time_periods && ret == SRSLTE_SUCCESS; i++) { + for (int i = 0; i < sim_time_periods && ret == SRSRAN_SUCCESS; i++) { for (int j = 0; j < 1000 * period_s; j++) { // Run delay channel - srslte_channel_hst_execute(&hst, input_buffer, output_buffer, size, &ts); + srsran_channel_hst_execute(&hst, input_buffer, output_buffer, size, &ts); // Increment timestamp 1ms - srslte_timestamp_add(&ts, 0, 0.001); + srsran_timestamp_add(&ts, 0, 0.001); float ideal_freq = hst.fs_hz; - float meas_freq = srslte_vec_estimate_frequency(output_buffer, size) * srate_hz; + float meas_freq = srsran_vec_estimate_frequency(output_buffer, size) * srate_hz; // printf("[%03d.%03d] fs = [%6.1f | %6.1f] Hz\n", i, j, ideal_freq, meas_freq); if (fabsf(ideal_freq - meas_freq) > 0.5f) { printf("Error [%03d.%03d] fs = [%6.1f | %6.1f] Hz\n", i, j, ideal_freq, meas_freq); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } } @@ -116,7 +116,7 @@ int main(int argc, char** argv) get_time_interval(t); // Free - srslte_channel_hst_free(&hst); + srsran_channel_hst_free(&hst); if (input_buffer) { free(input_buffer); @@ -136,7 +136,7 @@ int main(int argc, char** argv) init_time_s, srate_hz, sim_time_periods, - (ret == SRSLTE_SUCCESS) ? "Passed" : "Failed", + (ret == SRSRAN_SUCCESS) ? "Passed" : "Failed", (double)nof_samples / elapsed_us); exit(ret); } diff --git a/lib/src/phy/common/CMakeLists.txt b/lib/src/phy/common/CMakeLists.txt index 6d69c462e..9493d6836 100644 --- a/lib/src/phy/common/CMakeLists.txt +++ b/lib/src/phy/common/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -7,6 +7,6 @@ # set(SOURCES phy_common.c phy_common_sl.c phy_common_nr.c sequence.c timestamp.c zc_sequence.c) -add_library(srslte_phy_common OBJECT ${SOURCES}) +add_library(srsran_phy_common OBJECT ${SOURCES}) add_subdirectory(test) \ No newline at end of file diff --git a/lib/src/phy/common/phy_common.c b/lib/src/phy/common/phy_common.c index 97e3ca2ff..d96a49310 100644 --- a/lib/src/phy/common/phy_common.c +++ b/lib/src/phy/common/phy_common.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -15,9 +15,9 @@ #include #include -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/common/sequence.h" -#include "srslte/phy/utils/debug.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/common/sequence.h" +#include "srsran/phy/utils/debug.h" #ifdef FORCE_STANDARD_RATE static bool use_standard_rates = true; @@ -28,7 +28,7 @@ static bool use_standard_rates = false; /* Returns true if the structure pointed by cell has valid parameters */ -bool srslte_cellid_isvalid(uint32_t cell_id) +bool srsran_cellid_isvalid(uint32_t cell_id) { if (cell_id < 504) { return true; @@ -37,41 +37,41 @@ bool srslte_cellid_isvalid(uint32_t cell_id) } } -bool srslte_nofprb_isvalid(uint32_t nof_prb) +bool srsran_nofprb_isvalid(uint32_t nof_prb) { - if (nof_prb == 1 || (nof_prb >= 6 && nof_prb <= SRSLTE_MAX_PRB)) { + if (nof_prb == 1 || (nof_prb >= 6 && nof_prb <= SRSRAN_MAX_PRB)) { return true; } else { return false; } } -bool srslte_cell_isvalid(srslte_cell_t* cell) +bool srsran_cell_isvalid(srsran_cell_t* cell) { - return srslte_cellid_isvalid(cell->id) && srslte_portid_isvalid(cell->nof_ports) && - srslte_nofprb_isvalid(cell->nof_prb); + return srsran_cellid_isvalid(cell->id) && srsran_portid_isvalid(cell->nof_ports) && + srsran_nofprb_isvalid(cell->nof_prb); } -void srslte_cell_fprint(FILE* stream, srslte_cell_t* cell, uint32_t sfn) +void srsran_cell_fprint(FILE* stream, srsran_cell_t* cell, uint32_t sfn) { - fprintf(stream, " - Type: %s\n", cell->frame_type == SRSLTE_FDD ? "FDD" : "TDD"); + fprintf(stream, " - Type: %s\n", cell->frame_type == SRSRAN_FDD ? "FDD" : "TDD"); fprintf(stream, " - PCI: %d\n", cell->id); fprintf(stream, " - Nof ports: %d\n", cell->nof_ports); - fprintf(stream, " - CP: %s\n", srslte_cp_string(cell->cp)); + fprintf(stream, " - CP: %s\n", srsran_cp_string(cell->cp)); fprintf(stream, " - PRB: %d\n", cell->nof_prb); - fprintf(stream, " - PHICH Length: %s\n", cell->phich_length == SRSLTE_PHICH_EXT ? "Extended" : "Normal"); + fprintf(stream, " - PHICH Length: %s\n", cell->phich_length == SRSRAN_PHICH_EXT ? "Extended" : "Normal"); fprintf(stream, " - PHICH Resources: "); switch (cell->phich_resources) { - case SRSLTE_PHICH_R_1_6: + case SRSRAN_PHICH_R_1_6: fprintf(stream, "1/6"); break; - case SRSLTE_PHICH_R_1_2: + case SRSRAN_PHICH_R_1_2: fprintf(stream, "1/2"); break; - case SRSLTE_PHICH_R_1: + case SRSRAN_PHICH_R_1: fprintf(stream, "1"); break; - case SRSLTE_PHICH_R_2: + case SRSRAN_PHICH_R_2: fprintf(stream, "2"); break; } @@ -80,13 +80,13 @@ void srslte_cell_fprint(FILE* stream, srslte_cell_t* cell, uint32_t sfn) } // Initialize the matrix below with shorter symbols to improve readability. -#define D SRSLTE_TDD_SF_D -#define U SRSLTE_TDD_SF_U -#define S SRSLTE_TDD_SF_S +#define D SRSRAN_TDD_SF_D +#define U SRSRAN_TDD_SF_U +#define S SRSRAN_TDD_SF_S // TDD uplink-downlink configurations. // TS 36.211 v8.9.0 Table 4.2-2. -static const srslte_tdd_sf_t tdd_sf[SRSLTE_MAX_TDD_SF_CONFIGS][SRSLTE_NOF_SF_X_FRAME] = { +static const srsran_tdd_sf_t tdd_sf[SRSRAN_MAX_TDD_SF_CONFIGS][SRSRAN_NOF_SF_X_FRAME] = { {D, S, U, U, U, D, S, U, U, U}, {D, S, U, U, D, D, S, U, U, D}, {D, S, U, D, D, D, S, U, D, D}, @@ -99,19 +99,19 @@ static const srslte_tdd_sf_t tdd_sf[SRSLTE_MAX_TDD_SF_CONFIGS][SRSLTE_NOF_SF_X_F #undef U #undef S -srslte_tdd_sf_t srslte_sfidx_tdd_type(srslte_tdd_config_t tdd_config, uint32_t sf_idx) +srsran_tdd_sf_t srsran_sfidx_tdd_type(srsran_tdd_config_t tdd_config, uint32_t sf_idx) { - if (tdd_config.sf_config < SRSLTE_MAX_TDD_SF_CONFIGS && sf_idx < SRSLTE_NOF_SF_X_FRAME && tdd_config.configured) { + if (tdd_config.sf_config < SRSRAN_MAX_TDD_SF_CONFIGS && sf_idx < SRSRAN_NOF_SF_X_FRAME && tdd_config.configured) { return tdd_sf[tdd_config.sf_config][sf_idx]; } - return SRSLTE_TDD_SF_D; + return SRSRAN_TDD_SF_D; } -uint32_t srslte_sfidx_tdd_nof_dw_slot(srslte_tdd_config_t tdd_config, uint32_t slot, srslte_cp_t cp) +uint32_t srsran_sfidx_tdd_nof_dw_slot(srsran_tdd_config_t tdd_config, uint32_t slot, srsran_cp_t cp) { - uint32_t n = srslte_sfidx_tdd_nof_dw(tdd_config); - if (n < SRSLTE_CP_NSYMB(cp)) { + uint32_t n = srsran_sfidx_tdd_nof_dw(tdd_config); + if (n < SRSRAN_CP_NSYMB(cp)) { if (slot == 1) { return 0; } else { @@ -119,16 +119,16 @@ uint32_t srslte_sfidx_tdd_nof_dw_slot(srslte_tdd_config_t tdd_config, uint32_t s } } else { if (slot == 1) { - return n - SRSLTE_CP_NSYMB(cp); + return n - SRSRAN_CP_NSYMB(cp); } else { - return SRSLTE_CP_NSYMB(cp); + return SRSRAN_CP_NSYMB(cp); } } } // Number of DwPTS / GP / UpPTS symbols per subframe. // TS 36.211 v13.13.0 Table 4.2-2. -static const uint32_t tdd_nof_sf_symbols[SRSLTE_MAX_TDD_SS_CONFIGS][3] = {{3, 10, 1}, +static const uint32_t tdd_nof_sf_symbols[SRSRAN_MAX_TDD_SS_CONFIGS][3] = {{3, 10, 1}, {9, 4, 1}, {10, 3, 1}, {11, 2, 1}, @@ -139,58 +139,58 @@ static const uint32_t tdd_nof_sf_symbols[SRSLTE_MAX_TDD_SS_CONFIGS][3] = {{3, 10 {11, 1, 1}, {6, 6, 2}}; -uint32_t srslte_sfidx_tdd_nof_dw(srslte_tdd_config_t tdd_config) +uint32_t srsran_sfidx_tdd_nof_dw(srsran_tdd_config_t tdd_config) { - if (tdd_config.ss_config < SRSLTE_MAX_TDD_SS_CONFIGS) { + if (tdd_config.ss_config < SRSRAN_MAX_TDD_SS_CONFIGS) { return tdd_nof_sf_symbols[tdd_config.ss_config][0]; } return 0; } -uint32_t srslte_sfidx_tdd_nof_gp(srslte_tdd_config_t tdd_config) +uint32_t srsran_sfidx_tdd_nof_gp(srsran_tdd_config_t tdd_config) { - if (tdd_config.ss_config < SRSLTE_MAX_TDD_SS_CONFIGS) { + if (tdd_config.ss_config < SRSRAN_MAX_TDD_SS_CONFIGS) { return tdd_nof_sf_symbols[tdd_config.ss_config][1]; } return 0; } -uint32_t srslte_sfidx_tdd_nof_up(srslte_tdd_config_t tdd_config) +uint32_t srsran_sfidx_tdd_nof_up(srsran_tdd_config_t tdd_config) { - if (tdd_config.ss_config < SRSLTE_MAX_TDD_SS_CONFIGS) { + if (tdd_config.ss_config < SRSRAN_MAX_TDD_SS_CONFIGS) { return tdd_nof_sf_symbols[tdd_config.ss_config][2]; } return 0; } -uint32_t srslte_tdd_nof_harq(srslte_tdd_config_t tdd_config) +uint32_t srsran_tdd_nof_harq(srsran_tdd_config_t tdd_config) { static const uint32_t tdd_nof_harq[7] = {7, 4, 2, 3, 2, 1, 6}; return tdd_nof_harq[tdd_config.sf_config]; } -bool srslte_sfidx_isvalid(uint32_t sf_idx) +bool srsran_sfidx_isvalid(uint32_t sf_idx) { - if (sf_idx <= SRSLTE_NOF_SF_X_FRAME) { + if (sf_idx <= SRSRAN_NOF_SF_X_FRAME) { return true; } else { return false; } } -bool srslte_portid_isvalid(uint32_t port_id) +bool srsran_portid_isvalid(uint32_t port_id) { - if (port_id <= SRSLTE_MAX_PORTS) { + if (port_id <= SRSRAN_MAX_PORTS) { return true; } else { return false; } } -bool srslte_N_id_2_isvalid(uint32_t N_id_2) +bool srsran_N_id_2_isvalid(uint32_t N_id_2) { if (N_id_2 < 3) { return true; @@ -199,7 +199,7 @@ bool srslte_N_id_2_isvalid(uint32_t N_id_2) } } -bool srslte_N_id_1_isvalid(uint32_t N_id_1) +bool srsran_N_id_1_isvalid(uint32_t N_id_1) { if (N_id_1 < 168) { return true; @@ -208,7 +208,7 @@ bool srslte_N_id_1_isvalid(uint32_t N_id_1) } } -srslte_mod_t srslte_str2mod(const char* str) +srsran_mod_t srsran_str2mod(const char* str) { char mod_str[7] = {}; @@ -222,57 +222,57 @@ srslte_mod_t srslte_str2mod(const char* str) } if (!strcmp(mod_str, "QPSK")) { - return SRSLTE_MOD_QPSK; + return SRSRAN_MOD_QPSK; } else if (!strcmp(mod_str, "16QAM")) { - return SRSLTE_MOD_16QAM; + return SRSRAN_MOD_16QAM; } else if (!strcmp(mod_str, "64QAM")) { - return SRSLTE_MOD_64QAM; + return SRSRAN_MOD_64QAM; } else if (!strcmp(mod_str, "256QAM")) { - return SRSLTE_MOD_256QAM; + return SRSRAN_MOD_256QAM; } else { - return (srslte_mod_t)SRSLTE_ERROR_INVALID_INPUTS; + return (srsran_mod_t)SRSRAN_ERROR_INVALID_INPUTS; } }; -char* srslte_mod_string(srslte_mod_t mod) +char* srsran_mod_string(srsran_mod_t mod) { switch (mod) { - case SRSLTE_MOD_BPSK: + case SRSRAN_MOD_BPSK: return "BPSK"; - case SRSLTE_MOD_QPSK: + case SRSRAN_MOD_QPSK: return "QPSK"; - case SRSLTE_MOD_16QAM: + case SRSRAN_MOD_16QAM: return "16QAM"; - case SRSLTE_MOD_64QAM: + case SRSRAN_MOD_64QAM: return "64QAM"; - case SRSLTE_MOD_256QAM: + case SRSRAN_MOD_256QAM: return "256QAM"; default: return "N/A"; } } -uint32_t srslte_mod_bits_x_symbol(srslte_mod_t mod) +uint32_t srsran_mod_bits_x_symbol(srsran_mod_t mod) { switch (mod) { - case SRSLTE_MOD_BPSK: + case SRSRAN_MOD_BPSK: return 1; - case SRSLTE_MOD_QPSK: + case SRSRAN_MOD_QPSK: return 2; - case SRSLTE_MOD_16QAM: + case SRSRAN_MOD_16QAM: return 4; - case SRSLTE_MOD_64QAM: + case SRSRAN_MOD_64QAM: return 6; - case SRSLTE_MOD_256QAM: + case SRSRAN_MOD_256QAM: return 8; default: return 0; } } -char* srslte_cp_string(srslte_cp_t cp) +char* srsran_cp_string(srsran_cp_t cp) { - if (cp == SRSLTE_CP_NORM) { + if (cp == SRSRAN_CP_NORM) { return "Normal "; } else { return "Extended"; @@ -280,7 +280,7 @@ char* srslte_cp_string(srslte_cp_t cp) } /* Returns the new time advance N_ta_new as specified in Section 4.2.3 of 36.213 */ -uint32_t srslte_N_ta_new(uint32_t N_ta_old, uint32_t ta) +uint32_t srsran_N_ta_new(uint32_t N_ta_old, uint32_t ta) { ta &= 63; int n_ta_new = N_ta_old + ((float)ta - 31) * 16; @@ -295,14 +295,14 @@ uint32_t srslte_N_ta_new(uint32_t N_ta_old, uint32_t ta) } } -float srslte_coderate(uint32_t tbs, uint32_t nof_re) +float srsran_coderate(uint32_t tbs, uint32_t nof_re) { return (float)(24 + tbs) / nof_re; } /* Returns the new time advance as indicated by the random access response * as specified in Section 4.2.3 of 36.213 */ -uint32_t srslte_N_ta_new_rar(uint32_t ta) +uint32_t srsran_N_ta_new_rar(uint32_t ta) { if (ta > 1282) { ta = 1282; @@ -310,27 +310,27 @@ uint32_t srslte_N_ta_new_rar(uint32_t ta) return ta * 16; } -void srslte_use_standard_symbol_size(bool enabled) +void srsran_use_standard_symbol_size(bool enabled) { use_standard_rates = enabled; } -bool srslte_symbol_size_is_standard() +bool srsran_symbol_size_is_standard() { return use_standard_rates; } -int srslte_sampling_freq_hz(uint32_t nof_prb) +int srsran_sampling_freq_hz(uint32_t nof_prb) { - int n = srslte_symbol_sz(nof_prb); + int n = srsran_symbol_sz(nof_prb); if (n == -1) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } else { return 15000 * n; } } -int srslte_symbol_sz_power2(uint32_t nof_prb) +int srsran_symbol_sz_power2(uint32_t nof_prb) { if (nof_prb <= 6) { return 128; @@ -349,10 +349,10 @@ int srslte_symbol_sz_power2(uint32_t nof_prb) } } -int srslte_symbol_sz(uint32_t nof_prb) +int srsran_symbol_sz(uint32_t nof_prb) { if (nof_prb <= 0) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (!use_standard_rates) { if (nof_prb <= 6) { @@ -368,14 +368,14 @@ int srslte_symbol_sz(uint32_t nof_prb) } else if (nof_prb <= 110) { return 1536; } else { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } else { - return srslte_symbol_sz_power2(nof_prb); + return srsran_symbol_sz_power2(nof_prb); } } -int srslte_nof_prb(uint32_t symbol_sz) +int srsran_nof_prb(uint32_t symbol_sz) { if (!use_standard_rates) { switch (symbol_sz) { @@ -408,10 +408,10 @@ int srslte_nof_prb(uint32_t symbol_sz) return 100; } } - return SRSLTE_ERROR; + return SRSRAN_ERROR; } -bool srslte_symbol_sz_isvalid(uint32_t symbol_sz) +bool srsran_symbol_sz_isvalid(uint32_t symbol_sz) { if (!use_standard_rates) { if (symbol_sz == 128 || symbol_sz == 256 || symbol_sz == 384 || symbol_sz == 768 || symbol_sz == 1024 || @@ -431,7 +431,7 @@ bool srslte_symbol_sz_isvalid(uint32_t symbol_sz) } // Returns maximum number of CCE assuming CFI 3 and PHICH 1/6 -uint32_t srslte_max_cce(uint32_t nof_prb) +uint32_t srsran_max_cce(uint32_t nof_prb) { switch (nof_prb) { case 6: @@ -449,7 +449,7 @@ uint32_t srslte_max_cce(uint32_t nof_prb) } } -uint32_t srslte_voffset(uint32_t symbol_id, uint32_t cell_id, uint32_t nof_ports) +uint32_t srsran_voffset(uint32_t symbol_id, uint32_t cell_id, uint32_t nof_ports) { if (nof_ports == 1 && symbol_id == 0) { return (cell_id + 3) % 6; @@ -459,55 +459,55 @@ uint32_t srslte_voffset(uint32_t symbol_id, uint32_t cell_id, uint32_t nof_ports } /** Computes sequence-group pattern f_gh according to 5.5.1.3 of 36.211 */ -int srslte_group_hopping_f_gh(uint32_t f_gh[SRSLTE_NSLOTS_X_FRAME], uint32_t cell_id) +int srsran_group_hopping_f_gh(uint32_t f_gh[SRSRAN_NSLOTS_X_FRAME], uint32_t cell_id) { - srslte_sequence_t seq; - bzero(&seq, sizeof(srslte_sequence_t)); + srsran_sequence_t seq; + bzero(&seq, sizeof(srsran_sequence_t)); - if (srslte_sequence_LTE_pr(&seq, 160, cell_id / 30)) { - return SRSLTE_ERROR; + if (srsran_sequence_LTE_pr(&seq, 160, cell_id / 30)) { + return SRSRAN_ERROR; } - for (uint32_t ns = 0; ns < SRSLTE_NSLOTS_X_FRAME; ns++) { + for (uint32_t ns = 0; ns < SRSRAN_NSLOTS_X_FRAME; ns++) { f_gh[ns] = 0; for (int i = 0; i < 8; i++) { f_gh[ns] += (((uint32_t)seq.c[8 * ns + i]) << i); } } - srslte_sequence_free(&seq); - return SRSLTE_SUCCESS; + srsran_sequence_free(&seq); + return SRSRAN_SUCCESS; } /* Returns the number of available RE per PRB */ -uint32_t srslte_re_x_prb(uint32_t ns, uint32_t symbol, uint32_t nof_ports, uint32_t nof_symbols) +uint32_t srsran_re_x_prb(uint32_t ns, uint32_t symbol, uint32_t nof_ports, uint32_t nof_symbols) { if (symbol == 0) { if (((ns % 2) == 0) || (ns == 1)) { - return SRSLTE_NRE - 4; + return SRSRAN_NRE - 4; } else { if (nof_ports == 1) { - return SRSLTE_NRE - 2; + return SRSRAN_NRE - 2; } else { - return SRSLTE_NRE - 4; + return SRSRAN_NRE - 4; } } } else if (symbol == 1) { if (ns == 1) { - return SRSLTE_NRE - 4; + return SRSRAN_NRE - 4; } else if (nof_ports == 4) { - return SRSLTE_NRE - 4; + return SRSRAN_NRE - 4; } else { - return SRSLTE_NRE; + return SRSRAN_NRE; } } else if (symbol == nof_symbols - 3) { if (nof_ports == 1) { - return SRSLTE_NRE - 2; + return SRSRAN_NRE - 2; } else { - return SRSLTE_NRE - 4; + return SRSRAN_NRE - 4; } } else { - return SRSLTE_NRE; + return SRSRAN_NRE; } } @@ -520,68 +520,68 @@ struct lte_band { enum band_geographical_area area; }; -struct lte_band lte_bands[SRSLTE_NOF_LTE_BANDS] = { - {1, 2110, 0, 18000, 190, SRSLTE_BAND_GEO_AREA_ALL}, - {2, 1930, 600, 18600, 80, SRSLTE_BAND_GEO_AREA_NAR}, - {3, 1805, 1200, 19200, 95, SRSLTE_BAND_GEO_AREA_ALL}, - {4, 2110, 1950, 19950, 400, SRSLTE_BAND_GEO_AREA_NAR}, - {5, 869, 2400, 20400, 45, SRSLTE_BAND_GEO_AREA_NAR}, - {6, 875, 2650, 20650, 45, SRSLTE_BAND_GEO_AREA_APAC}, - {7, 2620, 2750, 20750, 120, SRSLTE_BAND_GEO_AREA_EMEA}, - {8, 925, 3450, 21450, 45, SRSLTE_BAND_GEO_AREA_ALL}, - {9, 1844.9, 3800, 21800, 95, SRSLTE_BAND_GEO_AREA_APAC}, - {10, 2110, 4150, 22150, 400, SRSLTE_BAND_GEO_AREA_NAR}, - {11, 1475.9, 4750, 22750, 48, SRSLTE_BAND_GEO_AREA_JAPAN}, - {12, 729, 5010, 23010, 30, SRSLTE_BAND_GEO_AREA_NAR}, - {13, 746, 5180, 23180, -31, SRSLTE_BAND_GEO_AREA_NAR}, - {14, 758, 5280, 23280, -30, SRSLTE_BAND_GEO_AREA_NAR}, - {17, 734, 5730, 23730, 30, SRSLTE_BAND_GEO_AREA_NAR}, - {18, 860, 5850, 23850, 45, SRSLTE_BAND_GEO_AREA_JAPAN}, - {19, 875, 6000, 24000, 45, SRSLTE_BAND_GEO_AREA_JAPAN}, - {20, 791, 6150, 24150, -41, SRSLTE_BAND_GEO_AREA_EMEA}, - {21, 1495.9, 6450, 24450, 48, SRSLTE_BAND_GEO_AREA_JAPAN}, - {22, 3500, 6600, 24600, 100, SRSLTE_BAND_GEO_AREA_NA}, - {23, 2180, 7500, 25500, 180, SRSLTE_BAND_GEO_AREA_NAR}, - {24, 1525, 7700, 25700, -101.5, SRSLTE_BAND_GEO_AREA_NAR}, - {25, 1930, 8040, 26040, 80, SRSLTE_BAND_GEO_AREA_NAR}, - {26, 859, 8690, 26690, 45, SRSLTE_BAND_GEO_AREA_NAR}, - {27, 852, 9040, 27040, 45, SRSLTE_BAND_GEO_AREA_NAR}, - {28, 758, 9210, 27210, 55, SRSLTE_BAND_GEO_AREA_APAC}, - {29, 717, 9660, 0, 0, SRSLTE_BAND_GEO_AREA_NAR}, - {30, 2350, 9770, 27660, 45, SRSLTE_BAND_GEO_AREA_NAR}, - {31, 462.5, 9870, 27760, 10, SRSLTE_BAND_GEO_AREA_CALA}, - {32, 1452, 9920, 0, 0, SRSLTE_BAND_GEO_AREA_EMEA}, - {33, 1900, 36000, 0, 0, SRSLTE_BAND_GEO_AREA_EMEA}, - {34, 2010, 36200, 0, 0, SRSLTE_BAND_GEO_AREA_EMEA}, - {35, 1850, 36350, 0, 0, SRSLTE_BAND_GEO_AREA_NAR}, - {36, 1930, 36950, 0, 0, SRSLTE_BAND_GEO_AREA_NAR}, - {37, 1910, 37550, 0, 0, SRSLTE_BAND_GEO_AREA_NAR}, - {38, 2570, 37750, 0, 0, SRSLTE_BAND_GEO_AREA_EMEA}, - {39, 1880, 38250, 0, 0, SRSLTE_BAND_GEO_AREA_APAC}, - {40, 2300, 38650, 0, 0, SRSLTE_BAND_GEO_AREA_APAC}, - {41, 2496, 39650, 0, 0, SRSLTE_BAND_GEO_AREA_ALL}, - {42, 3400, 41590, 0, 0, SRSLTE_BAND_GEO_AREA_ALL}, - {43, 3600, 43590, 0, 0, SRSLTE_BAND_GEO_AREA_ALL}, - {44, 703, 45590, 0, 0, SRSLTE_BAND_GEO_AREA_APAC}, - {45, 1447, 46590, 0, 0, SRSLTE_BAND_GEO_AREA_APAC}, - {46, 5150, 46790, 0, 0, SRSLTE_BAND_GEO_AREA_ALL}, - {47, 5855, 54540, 0, 0, SRSLTE_BAND_GEO_AREA_ALL}, - {48, 3550, 55240, 0, 0, SRSLTE_BAND_GEO_AREA_ALL}, - {49, 3550, 56740, 0, 0, SRSLTE_BAND_GEO_AREA_ALL}, - {50, 1432, 58240, 0, 0, SRSLTE_BAND_GEO_AREA_ALL}, - {51, 1427, 59090, 0, 0, SRSLTE_BAND_GEO_AREA_ALL}, - {52, 3300, 59140, 0, 0, SRSLTE_BAND_GEO_AREA_ALL}, - {64, 0, 60140, 27810, 0, SRSLTE_BAND_GEO_AREA_ALL}, // <- Placeholder band, not defined by 3GPP - {65, 2110, 65536, 131072, 190, SRSLTE_BAND_GEO_AREA_ALL}, - {66, 2110, 66436, 131972, 400, SRSLTE_BAND_GEO_AREA_NAR}, - {67, 738, 67336, 0, 0, SRSLTE_BAND_GEO_AREA_EMEA}, - {68, 753, 67536, 132672, 55, SRSLTE_BAND_GEO_AREA_EMEA}, - {69, 2570, 67836, 0, 0, SRSLTE_BAND_GEO_AREA_EMEA}, - {70, 1995, 68336, 132972, 300, SRSLTE_BAND_GEO_AREA_NAR}, - {71, 0, 68586, 133122, 0, SRSLTE_BAND_GEO_AREA_NAR} // dummy band to bound band 70 earfcn +struct lte_band lte_bands[SRSRAN_NOF_LTE_BANDS] = { + {1, 2110, 0, 18000, 190, SRSRAN_BAND_GEO_AREA_ALL}, + {2, 1930, 600, 18600, 80, SRSRAN_BAND_GEO_AREA_NAR}, + {3, 1805, 1200, 19200, 95, SRSRAN_BAND_GEO_AREA_ALL}, + {4, 2110, 1950, 19950, 400, SRSRAN_BAND_GEO_AREA_NAR}, + {5, 869, 2400, 20400, 45, SRSRAN_BAND_GEO_AREA_NAR}, + {6, 875, 2650, 20650, 45, SRSRAN_BAND_GEO_AREA_APAC}, + {7, 2620, 2750, 20750, 120, SRSRAN_BAND_GEO_AREA_EMEA}, + {8, 925, 3450, 21450, 45, SRSRAN_BAND_GEO_AREA_ALL}, + {9, 1844.9, 3800, 21800, 95, SRSRAN_BAND_GEO_AREA_APAC}, + {10, 2110, 4150, 22150, 400, SRSRAN_BAND_GEO_AREA_NAR}, + {11, 1475.9, 4750, 22750, 48, SRSRAN_BAND_GEO_AREA_JAPAN}, + {12, 729, 5010, 23010, 30, SRSRAN_BAND_GEO_AREA_NAR}, + {13, 746, 5180, 23180, -31, SRSRAN_BAND_GEO_AREA_NAR}, + {14, 758, 5280, 23280, -30, SRSRAN_BAND_GEO_AREA_NAR}, + {17, 734, 5730, 23730, 30, SRSRAN_BAND_GEO_AREA_NAR}, + {18, 860, 5850, 23850, 45, SRSRAN_BAND_GEO_AREA_JAPAN}, + {19, 875, 6000, 24000, 45, SRSRAN_BAND_GEO_AREA_JAPAN}, + {20, 791, 6150, 24150, -41, SRSRAN_BAND_GEO_AREA_EMEA}, + {21, 1495.9, 6450, 24450, 48, SRSRAN_BAND_GEO_AREA_JAPAN}, + {22, 3500, 6600, 24600, 100, SRSRAN_BAND_GEO_AREA_NA}, + {23, 2180, 7500, 25500, 180, SRSRAN_BAND_GEO_AREA_NAR}, + {24, 1525, 7700, 25700, -101.5, SRSRAN_BAND_GEO_AREA_NAR}, + {25, 1930, 8040, 26040, 80, SRSRAN_BAND_GEO_AREA_NAR}, + {26, 859, 8690, 26690, 45, SRSRAN_BAND_GEO_AREA_NAR}, + {27, 852, 9040, 27040, 45, SRSRAN_BAND_GEO_AREA_NAR}, + {28, 758, 9210, 27210, 55, SRSRAN_BAND_GEO_AREA_APAC}, + {29, 717, 9660, 0, 0, SRSRAN_BAND_GEO_AREA_NAR}, + {30, 2350, 9770, 27660, 45, SRSRAN_BAND_GEO_AREA_NAR}, + {31, 462.5, 9870, 27760, 10, SRSRAN_BAND_GEO_AREA_CALA}, + {32, 1452, 9920, 0, 0, SRSRAN_BAND_GEO_AREA_EMEA}, + {33, 1900, 36000, 0, 0, SRSRAN_BAND_GEO_AREA_EMEA}, + {34, 2010, 36200, 0, 0, SRSRAN_BAND_GEO_AREA_EMEA}, + {35, 1850, 36350, 0, 0, SRSRAN_BAND_GEO_AREA_NAR}, + {36, 1930, 36950, 0, 0, SRSRAN_BAND_GEO_AREA_NAR}, + {37, 1910, 37550, 0, 0, SRSRAN_BAND_GEO_AREA_NAR}, + {38, 2570, 37750, 0, 0, SRSRAN_BAND_GEO_AREA_EMEA}, + {39, 1880, 38250, 0, 0, SRSRAN_BAND_GEO_AREA_APAC}, + {40, 2300, 38650, 0, 0, SRSRAN_BAND_GEO_AREA_APAC}, + {41, 2496, 39650, 0, 0, SRSRAN_BAND_GEO_AREA_ALL}, + {42, 3400, 41590, 0, 0, SRSRAN_BAND_GEO_AREA_ALL}, + {43, 3600, 43590, 0, 0, SRSRAN_BAND_GEO_AREA_ALL}, + {44, 703, 45590, 0, 0, SRSRAN_BAND_GEO_AREA_APAC}, + {45, 1447, 46590, 0, 0, SRSRAN_BAND_GEO_AREA_APAC}, + {46, 5150, 46790, 0, 0, SRSRAN_BAND_GEO_AREA_ALL}, + {47, 5855, 54540, 0, 0, SRSRAN_BAND_GEO_AREA_ALL}, + {48, 3550, 55240, 0, 0, SRSRAN_BAND_GEO_AREA_ALL}, + {49, 3550, 56740, 0, 0, SRSRAN_BAND_GEO_AREA_ALL}, + {50, 1432, 58240, 0, 0, SRSRAN_BAND_GEO_AREA_ALL}, + {51, 1427, 59090, 0, 0, SRSRAN_BAND_GEO_AREA_ALL}, + {52, 3300, 59140, 0, 0, SRSRAN_BAND_GEO_AREA_ALL}, + {64, 0, 60140, 27810, 0, SRSRAN_BAND_GEO_AREA_ALL}, // <- Placeholder band, not defined by 3GPP + {65, 2110, 65536, 131072, 190, SRSRAN_BAND_GEO_AREA_ALL}, + {66, 2110, 66436, 131972, 400, SRSRAN_BAND_GEO_AREA_NAR}, + {67, 738, 67336, 0, 0, SRSRAN_BAND_GEO_AREA_EMEA}, + {68, 753, 67536, 132672, 55, SRSRAN_BAND_GEO_AREA_EMEA}, + {69, 2570, 67836, 0, 0, SRSRAN_BAND_GEO_AREA_EMEA}, + {70, 1995, 68336, 132972, 300, SRSRAN_BAND_GEO_AREA_NAR}, + {71, 0, 68586, 133122, 0, SRSRAN_BAND_GEO_AREA_NAR} // dummy band to bound band 70 earfcn }; -int srslte_str2mimotype(char* mimo_type_str, srslte_tx_scheme_t* type) +int srsran_str2mimotype(char* mimo_type_str, srsran_tx_scheme_t* type) { int i = 0; @@ -589,28 +589,28 @@ int srslte_str2mimotype(char* mimo_type_str, srslte_tx_scheme_t* type) while (mimo_type_str[i] |= ' ', mimo_type_str[++i]) ; - srslte_tx_scheme_t t = SRSLTE_TXSCHEME_PORT0; + srsran_tx_scheme_t t = SRSRAN_TXSCHEME_PORT0; do { - if (!strcmp(mimo_type_str, srslte_mimotype2str(t))) { + if (!strcmp(mimo_type_str, srsran_mimotype2str(t))) { *type = t; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } t++; - } while (t <= SRSLTE_TXSCHEME_CDD); + } while (t <= SRSRAN_TXSCHEME_CDD); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } -char* srslte_mimotype2str(srslte_tx_scheme_t mimo_type) +char* srsran_mimotype2str(srsran_tx_scheme_t mimo_type) { switch (mimo_type) { - case SRSLTE_TXSCHEME_PORT0: + case SRSRAN_TXSCHEME_PORT0: return "p0"; - case SRSLTE_TXSCHEME_DIVERSITY: + case SRSRAN_TXSCHEME_DIVERSITY: return "div"; - case SRSLTE_TXSCHEME_SPATIALMUX: + case SRSRAN_TXSCHEME_SPATIALMUX: return "mux"; - case SRSLTE_TXSCHEME_CDD: + case SRSRAN_TXSCHEME_CDD: return "cdd"; default: return "N/A"; @@ -635,22 +635,22 @@ static double get_fu(struct lte_band* band, uint32_t ul_earfcn) } } -bool srslte_band_is_tdd(uint32_t band) +bool srsran_band_is_tdd(uint32_t band) { uint32_t i = 0; - while (i < SRSLTE_NOF_LTE_BANDS && lte_bands[i].band != band) { + while (i < SRSRAN_NOF_LTE_BANDS && lte_bands[i].band != band) { i++; } - if (i == SRSLTE_NOF_LTE_BANDS) { + if (i == SRSRAN_NOF_LTE_BANDS) { ERROR("Invalid Band %d", band); return false; } return lte_bands[i].ul_earfcn_offset == 0; } -uint8_t srslte_band_get_band(uint32_t dl_earfcn) +uint8_t srsran_band_get_band(uint32_t dl_earfcn) { - uint32_t i = SRSLTE_NOF_LTE_BANDS - 1; + uint32_t i = SRSRAN_NOF_LTE_BANDS - 1; if (dl_earfcn > lte_bands[i].dl_earfcn_offset) { ERROR("Invalid DL_EARFCN=%d", dl_earfcn); } @@ -661,9 +661,9 @@ uint8_t srslte_band_get_band(uint32_t dl_earfcn) return lte_bands[i].band; } -double srslte_band_fd(uint32_t dl_earfcn) +double srsran_band_fd(uint32_t dl_earfcn) { - uint32_t i = SRSLTE_NOF_LTE_BANDS - 1; + uint32_t i = SRSRAN_NOF_LTE_BANDS - 1; if (dl_earfcn > lte_bands[i].dl_earfcn_offset) { ERROR("Invalid DL_EARFCN=%d", dl_earfcn); } @@ -674,9 +674,9 @@ double srslte_band_fd(uint32_t dl_earfcn) return get_fd(<e_bands[i], dl_earfcn); } -double srslte_band_fu(uint32_t ul_earfcn) +double srsran_band_fu(uint32_t ul_earfcn) { - uint32_t i = SRSLTE_NOF_LTE_BANDS - 1; + uint32_t i = SRSRAN_NOF_LTE_BANDS - 1; if (ul_earfcn > lte_bands[i].ul_earfcn_offset) { ERROR("Invalid UL_EARFCN=%d", ul_earfcn); } @@ -687,9 +687,9 @@ double srslte_band_fu(uint32_t ul_earfcn) return get_fu(<e_bands[i], ul_earfcn); } -uint32_t srslte_band_ul_earfcn(uint32_t dl_earfcn) +uint32_t srsran_band_ul_earfcn(uint32_t dl_earfcn) { - uint32_t i = SRSLTE_NOF_LTE_BANDS - 1; + uint32_t i = SRSRAN_NOF_LTE_BANDS - 1; if (dl_earfcn > lte_bands[i].dl_earfcn_offset) { ERROR("Invalid DL_EARFCN=%d", dl_earfcn); } @@ -700,13 +700,13 @@ uint32_t srslte_band_ul_earfcn(uint32_t dl_earfcn) return lte_bands[i].ul_earfcn_offset + (dl_earfcn - lte_bands[i].dl_earfcn_offset); } -int srslte_band_get_fd_band_all(uint32_t band, srslte_earfcn_t* earfcn, uint32_t max_elems) +int srsran_band_get_fd_band_all(uint32_t band, srsran_earfcn_t* earfcn, uint32_t max_elems) { - return srslte_band_get_fd_band(band, earfcn, -1, -1, max_elems); + return srsran_band_get_fd_band(band, earfcn, -1, -1, max_elems); } -int srslte_band_get_fd_band(uint32_t band, - srslte_earfcn_t* earfcn, +int srsran_band_get_fd_band(uint32_t band, + srsran_earfcn_t* earfcn, int start_earfcn, int end_earfcn, uint32_t max_elems) @@ -714,19 +714,19 @@ int srslte_band_get_fd_band(uint32_t band, uint32_t i, j; uint32_t nof_earfcn; i = 0; - while (i < SRSLTE_NOF_LTE_BANDS && lte_bands[i].band != band) { + while (i < SRSRAN_NOF_LTE_BANDS && lte_bands[i].band != band) { i++; } - if (i >= SRSLTE_NOF_LTE_BANDS - 1) { + if (i >= SRSRAN_NOF_LTE_BANDS - 1) { ERROR("Error: Invalid band %d", band); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (end_earfcn == -1) { end_earfcn = lte_bands[i + 1].dl_earfcn_offset - 1; } else { if (end_earfcn > lte_bands[i + 1].dl_earfcn_offset - 1) { ERROR("Error: Invalid end earfcn %d. Max is %d", end_earfcn, lte_bands[i + 1].dl_earfcn_offset - 1); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } if (start_earfcn == -1) { @@ -734,7 +734,7 @@ int srslte_band_get_fd_band(uint32_t band, } else { if (start_earfcn < lte_bands[i].dl_earfcn_offset) { ERROR("Error: Invalid start earfcn %d. Min is %d", start_earfcn, lte_bands[i].dl_earfcn_offset); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } nof_earfcn = end_earfcn - start_earfcn; @@ -749,19 +749,19 @@ int srslte_band_get_fd_band(uint32_t band, return (int)j; } -int srslte_band_get_fd_region(enum band_geographical_area region, srslte_earfcn_t* earfcn, uint32_t max_elems) +int srsran_band_get_fd_region(enum band_geographical_area region, srsran_earfcn_t* earfcn, uint32_t max_elems) { uint32_t i; int n; int nof_fd = 0; - for (i = 0; i < SRSLTE_NOF_LTE_BANDS && max_elems > 0; i++) { + for (i = 0; i < SRSRAN_NOF_LTE_BANDS && max_elems > 0; i++) { if (lte_bands[i].area == region) { - n = srslte_band_get_fd_band(i, &earfcn[nof_fd], -1, -1, max_elems); + n = srsran_band_get_fd_band(i, &earfcn[nof_fd], -1, -1, max_elems); if (n != -1) { nof_fd += n; max_elems -= n; } else { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } } @@ -769,7 +769,7 @@ int srslte_band_get_fd_region(enum band_geographical_area region, srslte_earfcn_ } /* Returns the interval tti1-tti2 mod 10240 */ -uint32_t srslte_tti_interval(uint32_t tti1, uint32_t tti2) +uint32_t srsran_tti_interval(uint32_t tti1, uint32_t tti2) { if (tti1 >= tti2) { return tti1 - tti2; @@ -778,7 +778,7 @@ uint32_t srslte_tti_interval(uint32_t tti1, uint32_t tti2) } } -uint32_t srslte_print_check(char* s, size_t max_len, uint32_t cur_len, const char* format, ...) +uint32_t srsran_print_check(char* s, size_t max_len, uint32_t cur_len, const char* format, ...) { if (cur_len < max_len - 1) { va_list args; @@ -803,7 +803,7 @@ uint32_t srslte_print_check(char* s, size_t max_len, uint32_t cur_len, const cha return cur_len; } -bool srslte_nbiot_prb_isvalid(srslte_nbiot_cell_t* cell) +bool srsran_nbiot_prb_isvalid(srsran_nbiot_cell_t* cell) { if (cell->nbiot_prb <= cell->base.nof_prb) { return true; @@ -811,53 +811,53 @@ bool srslte_nbiot_prb_isvalid(srslte_nbiot_cell_t* cell) return false; } -bool srslte_nbiot_cell_isvalid(srslte_nbiot_cell_t* cell) +bool srsran_nbiot_cell_isvalid(srsran_nbiot_cell_t* cell) { - return (srslte_cell_isvalid(&cell->base) && srslte_nbiot_portid_isvalid(cell->nof_ports) && - srslte_nbiot_prb_isvalid(cell) && srslte_cellid_isvalid(cell->n_id_ncell)); + return (srsran_cell_isvalid(&cell->base) && srsran_nbiot_portid_isvalid(cell->nof_ports) && + srsran_nbiot_prb_isvalid(cell) && srsran_cellid_isvalid(cell->n_id_ncell)); } -bool srslte_nbiot_portid_isvalid(uint32_t port_id) +bool srsran_nbiot_portid_isvalid(uint32_t port_id) { - if (port_id <= SRSLTE_NBIOT_MAX_PORTS) { + if (port_id <= SRSRAN_NBIOT_MAX_PORTS) { return true; } else { return false; } } -char* srslte_nbiot_mode_string(srslte_nbiot_mode_t mode) +char* srsran_nbiot_mode_string(srsran_nbiot_mode_t mode) { switch (mode) { - case SRSLTE_NBIOT_MODE_INBAND_SAME_PCI: + case SRSRAN_NBIOT_MODE_INBAND_SAME_PCI: return "Inband (Same PCI)"; - case SRSLTE_NBIOT_MODE_INBAND_DIFFERENT_PCI: + case SRSRAN_NBIOT_MODE_INBAND_DIFFERENT_PCI: return "Inband (Different PCI)"; - case SRSLTE_NBIOT_MODE_GUARDBAND: + case SRSRAN_NBIOT_MODE_GUARDBAND: return "Guardband"; - case SRSLTE_NBIOT_MODE_STANDALONE: + case SRSRAN_NBIOT_MODE_STANDALONE: return "Standalone"; default: return "N/A"; } } -const char* srslte_ack_nack_feedback_mode_string(srslte_ack_nack_feedback_mode_t ack_nack_feedback_mode) +const char* srsran_ack_nack_feedback_mode_string(srsran_ack_nack_feedback_mode_t ack_nack_feedback_mode) { switch (ack_nack_feedback_mode) { - case SRSLTE_PUCCH_ACK_NACK_FEEDBACK_MODE_NORMAL: + case SRSRAN_PUCCH_ACK_NACK_FEEDBACK_MODE_NORMAL: return "normal"; - case SRSLTE_PUCCH_ACK_NACK_FEEDBACK_MODE_CS: + case SRSRAN_PUCCH_ACK_NACK_FEEDBACK_MODE_CS: return "cs"; - case SRSLTE_PUCCH_ACK_NACK_FEEDBACK_MODE_PUCCH3: + case SRSRAN_PUCCH_ACK_NACK_FEEDBACK_MODE_PUCCH3: return "pucch3"; - case SRSLTE_PUCCH_ACK_NACK_FEEDBACK_MODE_ERROR: + case SRSRAN_PUCCH_ACK_NACK_FEEDBACK_MODE_ERROR: default: return "error"; } } -srslte_ack_nack_feedback_mode_t srslte_string_ack_nack_feedback_mode(const char* str) +srsran_ack_nack_feedback_mode_t srsran_string_ack_nack_feedback_mode(const char* str) { #define MAX_STR_LEN (8) int i = 0; @@ -873,19 +873,19 @@ srslte_ack_nack_feedback_mode_t srslte_string_ack_nack_feedback_mode(const char* // Format 1b with channel selection if (strcmp(str2, "cs") == 0) { - return SRSLTE_PUCCH_ACK_NACK_FEEDBACK_MODE_CS; + return SRSRAN_PUCCH_ACK_NACK_FEEDBACK_MODE_CS; } // Detect PUCCH3 if (strcmp(str2, "pucch3") == 0) { - return SRSLTE_PUCCH_ACK_NACK_FEEDBACK_MODE_PUCCH3; + return SRSRAN_PUCCH_ACK_NACK_FEEDBACK_MODE_PUCCH3; } // Otherwise Normal - return SRSLTE_PUCCH_ACK_NACK_FEEDBACK_MODE_NORMAL; + return SRSRAN_PUCCH_ACK_NACK_FEEDBACK_MODE_NORMAL; } -uint32_t srslte_ri_nof_bits(const srslte_cell_t* cell) +uint32_t srsran_ri_nof_bits(const srsran_cell_t* cell) { uint32_t ret = 0; diff --git a/lib/src/phy/common/phy_common_nr.c b/lib/src/phy/common/phy_common_nr.c index b4f36d4b5..6f9e49337 100644 --- a/lib/src/phy/common/phy_common_nr.c +++ b/lib/src/phy/common/phy_common_nr.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,39 +10,39 @@ * */ -#include "srslte/phy/common/phy_common_nr.h" +#include "srsran/phy/common/phy_common_nr.h" #include -const char* srslte_rnti_type_str(srslte_rnti_type_t rnti_type) +const char* srsran_rnti_type_str(srsran_rnti_type_t rnti_type) { switch (rnti_type) { - case srslte_rnti_type_c: + case srsran_rnti_type_c: return "C-RNTI"; - case srslte_rnti_type_p: + case srsran_rnti_type_p: return "P-RNTI"; - case srslte_rnti_type_si: + case srsran_rnti_type_si: return "SI-RNTI"; - case srslte_rnti_type_ra: + case srsran_rnti_type_ra: return "RA-RNTI"; - case srslte_rnti_type_tc: + case srsran_rnti_type_tc: return "TC-RNTI"; - case srslte_rnti_type_cs: + case srsran_rnti_type_cs: return "CS-RNTI"; - case srslte_rnti_type_sp_csi: + case srsran_rnti_type_sp_csi: return "SP-CSI-RNTI"; - case srslte_rnti_type_mcs_c: + case srsran_rnti_type_mcs_c: return "MCS-C-RNTI"; default:; // Do nothing } return "unknown"; } -uint32_t srslte_coreset_get_bw(const srslte_coreset_t* coreset) +uint32_t srsran_coreset_get_bw(const srsran_coreset_t* coreset) { uint32_t prb_count = 0; // Iterate all the frequency domain resources bit-map... - for (uint32_t i = 0; i < SRSLTE_CORESET_FREQ_DOMAIN_RES_SIZE; i++) { + for (uint32_t i = 0; i < SRSRAN_CORESET_FREQ_DOMAIN_RES_SIZE; i++) { // ... and count 6 PRB for every frequency domain resource that it is enabled if (coreset->freq_resources[i]) { prb_count += 6; @@ -53,50 +53,50 @@ uint32_t srslte_coreset_get_bw(const srslte_coreset_t* coreset) return prb_count; } -uint32_t srslte_coreset_get_sz(const srslte_coreset_t* coreset) +uint32_t srsran_coreset_get_sz(const srsran_coreset_t* coreset) { // Returns the number of resource elements in time and frequency domains - return srslte_coreset_get_bw(coreset) * SRSLTE_NRE * coreset->duration; + return srsran_coreset_get_bw(coreset) * SRSRAN_NRE * coreset->duration; } -const char* srslte_sch_mapping_type_to_str(srslte_sch_mapping_type_t mapping_type) +const char* srsran_sch_mapping_type_to_str(srsran_sch_mapping_type_t mapping_type) { switch (mapping_type) { - case srslte_sch_mapping_type_A: + case srsran_sch_mapping_type_A: return "A"; - case srslte_sch_mapping_type_B: + case srsran_sch_mapping_type_B: return "B"; default: return "undefined"; } } -const char* srslte_mcs_table_to_str(srslte_mcs_table_t mcs_table) +const char* srsran_mcs_table_to_str(srsran_mcs_table_t mcs_table) { switch (mcs_table) { - case srslte_mcs_table_64qam: + case srsran_mcs_table_64qam: return "64qam"; - case srslte_mcs_table_256qam: + case srsran_mcs_table_256qam: return "256qam"; - case srslte_mcs_table_qam64LowSE: + case srsran_mcs_table_qam64LowSE: return "qam64LowSE"; default: return "undefined"; } } -srslte_mcs_table_t srslte_mcs_table_from_str(const char* str) +srsran_mcs_table_t srsran_mcs_table_from_str(const char* str) { if (strcmp(str, "64qam") == 0) { - return srslte_mcs_table_64qam; + return srsran_mcs_table_64qam; } if (strcmp(str, "256qam") == 0) { - return srslte_mcs_table_256qam; + return srsran_mcs_table_256qam; } if (strcmp(str, "qam64LowSE") == 0) { - return srslte_mcs_table_qam64LowSE; + return srsran_mcs_table_qam64LowSE; } - return srslte_mcs_table_N; + return srsran_mcs_table_N; } #define PHY_COMMON_NR_NOF_VALID_SYMB_SZ 10U @@ -104,9 +104,9 @@ srslte_mcs_table_t srslte_mcs_table_from_str(const char* str) static const uint32_t phy_common_nr_valid_symbol_sz[PHY_COMMON_NR_NOF_VALID_SYMB_SZ] = {128, 256, 384, 512, 768, 1024, 1536, 2048, 3072, 4096}; -uint32_t srslte_min_symbol_sz_rb(uint32_t nof_prb) +uint32_t srsran_min_symbol_sz_rb(uint32_t nof_prb) { - uint32_t nof_re = nof_prb * SRSLTE_NRE; + uint32_t nof_re = nof_prb * SRSRAN_NRE; if (nof_re == 0) { return 0; @@ -121,7 +121,7 @@ uint32_t srslte_min_symbol_sz_rb(uint32_t nof_prb) return 0; } -float srslte_symbol_distance_s(uint32_t l0, uint32_t l1, uint32_t numerology) +float srsran_symbol_distance_s(uint32_t l0, uint32_t l1, uint32_t numerology) { // l0 must be smaller than l1 if (l0 >= l1) { @@ -144,10 +144,10 @@ float srslte_symbol_distance_s(uint32_t l0, uint32_t l1, uint32_t numerology) uint32_t N = (2048 + 144) * count + extra_cp; // Return symbol distance in microseconds - return (N << numerology) * SRSLTE_LTE_TS; + return (N << numerology) * SRSRAN_LTE_TS; } -bool srslte_tdd_nr_is_dl(const srslte_tdd_config_nr_t* cfg, uint32_t numerology, uint32_t slot_idx) +bool srsran_tdd_nr_is_dl(const srsran_tdd_config_nr_t* cfg, uint32_t numerology, uint32_t slot_idx) { if (cfg == NULL) { return false; @@ -159,7 +159,7 @@ bool srslte_tdd_nr_is_dl(const srslte_tdd_config_nr_t* cfg, uint32_t numerology, uint32_t slot_idx_period = slot_idx % period_sum; // Slot index within the period // Select pattern - const srslte_tdd_pattern_t* pattern = &cfg->pattern1; + const srsran_tdd_pattern_t* pattern = &cfg->pattern1; if ((slot_idx_period >= cfg->pattern1.period_ms * slot_x_ms)) { pattern = &cfg->pattern2; slot_idx_period -= cfg->pattern1.period_ms * slot_x_ms; // Remove pattern 1 offset @@ -169,7 +169,7 @@ bool srslte_tdd_nr_is_dl(const srslte_tdd_config_nr_t* cfg, uint32_t numerology, (slot_idx_period == pattern->nof_dl_slots && pattern->nof_dl_symbols != 0)); } -bool srslte_tdd_nr_is_ul(const srslte_tdd_config_nr_t* cfg, uint32_t numerology, uint32_t slot_idx) +bool srsran_tdd_nr_is_ul(const srsran_tdd_config_nr_t* cfg, uint32_t numerology, uint32_t slot_idx) { if (cfg == NULL) { return false; @@ -181,7 +181,7 @@ bool srslte_tdd_nr_is_ul(const srslte_tdd_config_nr_t* cfg, uint32_t numerology, uint32_t slot_idx_period = slot_idx % period_sum; // Slot index within the period // Select pattern - const srslte_tdd_pattern_t* pattern = &cfg->pattern1; + const srsran_tdd_pattern_t* pattern = &cfg->pattern1; if ((slot_idx_period >= cfg->pattern1.period_ms * slot_x_ms)) { pattern = &cfg->pattern2; slot_idx_period -= cfg->pattern1.period_ms * slot_x_ms; // Remove pattern 1 offset diff --git a/lib/src/phy/common/phy_common_sl.c b/lib/src/phy/common/phy_common_sl.c index e45252fee..ad3da8fa6 100644 --- a/lib/src/phy/common/phy_common_sl.c +++ b/lib/src/phy/common/phy_common_sl.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -12,32 +12,32 @@ #include -#include "srslte/phy/common/phy_common_sl.h" -#include "srslte/phy/common/sequence.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/common/phy_common_sl.h" +#include "srsran/phy/common/sequence.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" -int srslte_sl_group_hopping_f_gh(uint32_t f_gh[SRSLTE_NSLOTS_X_FRAME * 2], uint32_t N_x_id) +int srsran_sl_group_hopping_f_gh(uint32_t f_gh[SRSRAN_NSLOTS_X_FRAME * 2], uint32_t N_x_id) { - srslte_sequence_t seq; - bzero(&seq, sizeof(srslte_sequence_t)); + srsran_sequence_t seq; + bzero(&seq, sizeof(srsran_sequence_t)); - if (srslte_sequence_LTE_pr(&seq, 160 * 2, N_x_id / 30)) { - return SRSLTE_ERROR; + if (srsran_sequence_LTE_pr(&seq, 160 * 2, N_x_id / 30)) { + return SRSRAN_ERROR; } - for (uint32_t ns = 0; ns < SRSLTE_NSLOTS_X_FRAME * 2; ns++) { + for (uint32_t ns = 0; ns < SRSRAN_NSLOTS_X_FRAME * 2; ns++) { f_gh[ns] = 0; for (int i = 0; i < 8; i++) { f_gh[ns] += (((uint32_t)seq.c[8 * ns + i]) << i); } } - srslte_sequence_free(&seq); - return SRSLTE_SUCCESS; + srsran_sequence_free(&seq); + return SRSRAN_SUCCESS; } -bool srslte_slss_side_peak_pos_is_valid(uint32_t side_peak_pos, +bool srsran_slss_side_peak_pos_is_valid(uint32_t side_peak_pos, uint32_t main_peak_pos, uint32_t side_peak_delta_a, uint32_t side_peak_delta_b) @@ -52,7 +52,7 @@ bool srslte_slss_side_peak_pos_is_valid(uint32_t side_peak_pos, return false; } -bool srslte_slss_side_peak_value_is_valid(float side_peak_value, float threshold_low, float threshold_high) +bool srsran_slss_side_peak_value_is_valid(float side_peak_value, float threshold_low, float threshold_high) { if ((side_peak_value >= threshold_low) && (side_peak_value <= threshold_high)) { return true; @@ -60,25 +60,25 @@ bool srslte_slss_side_peak_value_is_valid(float side_peak_value, float threshold return false; } -int srslte_sl_tm_to_cell_sl_tm_t(srslte_cell_sl_t* q, uint32_t tm) +int srsran_sl_tm_to_cell_sl_tm_t(srsran_cell_sl_t* q, uint32_t tm) { switch (tm) { case 1: - q->tm = SRSLTE_SIDELINK_TM1; + q->tm = SRSRAN_SIDELINK_TM1; break; case 2: - q->tm = SRSLTE_SIDELINK_TM2; + q->tm = SRSRAN_SIDELINK_TM2; break; case 3: - q->tm = SRSLTE_SIDELINK_TM3; + q->tm = SRSRAN_SIDELINK_TM3; break; case 4: - q->tm = SRSLTE_SIDELINK_TM4; + q->tm = SRSRAN_SIDELINK_TM4; break; default: - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } /* Returns the number of OFDM symbols depending on the Sidelink transmission mode and the CP @@ -87,17 +87,17 @@ int srslte_sl_tm_to_cell_sl_tm_t(srslte_cell_sl_t* q, uint32_t tm) * @cp Cyclic prefix * @return Number of symbols (0 if invalid params where given) */ -uint32_t srslte_sl_get_num_symbols(srslte_sl_tm_t tm, srslte_cp_t cp) +uint32_t srsran_sl_get_num_symbols(srsran_sl_tm_t tm, srsran_cp_t cp) { - if (tm == SRSLTE_SIDELINK_TM1 || tm == SRSLTE_SIDELINK_TM2) { - if (cp == SRSLTE_CP_NORM) { - return SRSLTE_CP_NORM_SF_NSYMB; + if (tm == SRSRAN_SIDELINK_TM1 || tm == SRSRAN_SIDELINK_TM2) { + if (cp == SRSRAN_CP_NORM) { + return SRSRAN_CP_NORM_SF_NSYMB; } else { - return SRSLTE_CP_EXT_SF_NSYMB; + return SRSRAN_CP_EXT_SF_NSYMB; } - } else if (tm == SRSLTE_SIDELINK_TM3 || tm == SRSLTE_SIDELINK_TM4) { - if (cp == SRSLTE_CP_NORM) { - return SRSLTE_CP_NORM_SF_NSYMB; + } else if (tm == SRSRAN_SIDELINK_TM3 || tm == SRSRAN_SIDELINK_TM4) { + if (cp == SRSRAN_CP_NORM) { + return SRSRAN_CP_NORM_SF_NSYMB; } else { ERROR("Invalid CP"); } @@ -108,181 +108,181 @@ uint32_t srslte_sl_get_num_symbols(srslte_sl_tm_t tm, srslte_cp_t cp) } // Look-up tables for Sidelink channel symbols -static const srslte_sl_symbol_t srslte_psbch_symbol_map_tm12[SRSLTE_CP_NORM_SF_NSYMB] = {SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_SYNC_SYMBOL, - SRSLTE_SIDELINK_SYNC_SYMBOL, - SRSLTE_SIDELINK_DMRS_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DMRS_SYMBOL, - SRSLTE_SIDELINK_SYNC_SYMBOL, - SRSLTE_SIDELINK_SYNC_SYMBOL, - SRSLTE_SIDELINK_GUARD_SYMBOL}; - -static const srslte_sl_symbol_t srslte_psbch_symbol_map_tm12_ext[SRSLTE_CP_EXT_SF_NSYMB] = { - SRSLTE_SIDELINK_SYNC_SYMBOL, - SRSLTE_SIDELINK_SYNC_SYMBOL, - SRSLTE_SIDELINK_DMRS_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DMRS_SYMBOL, - SRSLTE_SIDELINK_SYNC_SYMBOL, - SRSLTE_SIDELINK_SYNC_SYMBOL, - SRSLTE_SIDELINK_GUARD_SYMBOL}; - -static const srslte_sl_symbol_t srslte_psbch_symbol_map_tm34[SRSLTE_CP_NORM_SF_NSYMB] = {SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_SYNC_SYMBOL, - SRSLTE_SIDELINK_SYNC_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DMRS_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DMRS_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DMRS_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_SYNC_SYMBOL, - SRSLTE_SIDELINK_SYNC_SYMBOL, - SRSLTE_SIDELINK_GUARD_SYMBOL}; - -bool srslte_psbch_is_symbol(srslte_sl_symbol_t type, srslte_sl_tm_t tm, uint32_t i, srslte_cp_t cp) +static const srsran_sl_symbol_t srsran_psbch_symbol_map_tm12[SRSRAN_CP_NORM_SF_NSYMB] = {SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_SYNC_SYMBOL, + SRSRAN_SIDELINK_SYNC_SYMBOL, + SRSRAN_SIDELINK_DMRS_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DMRS_SYMBOL, + SRSRAN_SIDELINK_SYNC_SYMBOL, + SRSRAN_SIDELINK_SYNC_SYMBOL, + SRSRAN_SIDELINK_GUARD_SYMBOL}; + +static const srsran_sl_symbol_t srsran_psbch_symbol_map_tm12_ext[SRSRAN_CP_EXT_SF_NSYMB] = { + SRSRAN_SIDELINK_SYNC_SYMBOL, + SRSRAN_SIDELINK_SYNC_SYMBOL, + SRSRAN_SIDELINK_DMRS_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DMRS_SYMBOL, + SRSRAN_SIDELINK_SYNC_SYMBOL, + SRSRAN_SIDELINK_SYNC_SYMBOL, + SRSRAN_SIDELINK_GUARD_SYMBOL}; + +static const srsran_sl_symbol_t srsran_psbch_symbol_map_tm34[SRSRAN_CP_NORM_SF_NSYMB] = {SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_SYNC_SYMBOL, + SRSRAN_SIDELINK_SYNC_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DMRS_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DMRS_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DMRS_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_SYNC_SYMBOL, + SRSRAN_SIDELINK_SYNC_SYMBOL, + SRSRAN_SIDELINK_GUARD_SYMBOL}; + +bool srsran_psbch_is_symbol(srsran_sl_symbol_t type, srsran_sl_tm_t tm, uint32_t i, srsran_cp_t cp) { - if (tm == SRSLTE_SIDELINK_TM1 || tm == SRSLTE_SIDELINK_TM2) { - if (cp == SRSLTE_CP_EXT && i < SRSLTE_CP_EXT_SF_NSYMB) { - return srslte_psbch_symbol_map_tm12_ext[i] == type; - } else if (i < SRSLTE_CP_NORM_SF_NSYMB) { - return srslte_psbch_symbol_map_tm12[i] == type; + if (tm == SRSRAN_SIDELINK_TM1 || tm == SRSRAN_SIDELINK_TM2) { + if (cp == SRSRAN_CP_EXT && i < SRSRAN_CP_EXT_SF_NSYMB) { + return srsran_psbch_symbol_map_tm12_ext[i] == type; + } else if (i < SRSRAN_CP_NORM_SF_NSYMB) { + return srsran_psbch_symbol_map_tm12[i] == type; } - } else if ((tm == SRSLTE_SIDELINK_TM3 || tm == SRSLTE_SIDELINK_TM4) && i < SRSLTE_CP_NORM_SF_NSYMB) { - return srslte_psbch_symbol_map_tm34[i] == type; + } else if ((tm == SRSRAN_SIDELINK_TM3 || tm == SRSRAN_SIDELINK_TM4) && i < SRSRAN_CP_NORM_SF_NSYMB) { + return srsran_psbch_symbol_map_tm34[i] == type; } return false; } -static const srslte_sl_symbol_t srslte_pscch_symbol_map_tm12[SRSLTE_CP_NORM_SF_NSYMB] = {SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DMRS_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DMRS_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_GUARD_SYMBOL}; - -static const srslte_sl_symbol_t srslte_pscch_symbol_map_tm12_ext[SRSLTE_CP_EXT_SF_NSYMB] = { - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DMRS_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DMRS_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_GUARD_SYMBOL}; - -static const srslte_sl_symbol_t srslte_pscch_symbol_map_tm34[SRSLTE_CP_NORM_SF_NSYMB] = {SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DMRS_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DMRS_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DMRS_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DMRS_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_GUARD_SYMBOL}; - -bool srslte_pscch_is_symbol(srslte_sl_symbol_t type, srslte_sl_tm_t tm, uint32_t i, srslte_cp_t cp) +static const srsran_sl_symbol_t srsran_pscch_symbol_map_tm12[SRSRAN_CP_NORM_SF_NSYMB] = {SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DMRS_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DMRS_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_GUARD_SYMBOL}; + +static const srsran_sl_symbol_t srsran_pscch_symbol_map_tm12_ext[SRSRAN_CP_EXT_SF_NSYMB] = { + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DMRS_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DMRS_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_GUARD_SYMBOL}; + +static const srsran_sl_symbol_t srsran_pscch_symbol_map_tm34[SRSRAN_CP_NORM_SF_NSYMB] = {SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DMRS_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DMRS_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DMRS_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DMRS_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_GUARD_SYMBOL}; + +bool srsran_pscch_is_symbol(srsran_sl_symbol_t type, srsran_sl_tm_t tm, uint32_t i, srsran_cp_t cp) { - if (tm == SRSLTE_SIDELINK_TM1 || tm == SRSLTE_SIDELINK_TM2) { - if (cp == SRSLTE_CP_EXT && i < SRSLTE_CP_EXT_SF_NSYMB) { - return srslte_pscch_symbol_map_tm12_ext[i] == type; - } else if (i < SRSLTE_CP_NORM_SF_NSYMB) { - return srslte_pscch_symbol_map_tm12[i] == type; + if (tm == SRSRAN_SIDELINK_TM1 || tm == SRSRAN_SIDELINK_TM2) { + if (cp == SRSRAN_CP_EXT && i < SRSRAN_CP_EXT_SF_NSYMB) { + return srsran_pscch_symbol_map_tm12_ext[i] == type; + } else if (i < SRSRAN_CP_NORM_SF_NSYMB) { + return srsran_pscch_symbol_map_tm12[i] == type; } - } else if ((tm == SRSLTE_SIDELINK_TM3 || tm == SRSLTE_SIDELINK_TM4) && i < SRSLTE_CP_NORM_SF_NSYMB) { - return srslte_pscch_symbol_map_tm34[i] == type; + } else if ((tm == SRSRAN_SIDELINK_TM3 || tm == SRSRAN_SIDELINK_TM4) && i < SRSRAN_CP_NORM_SF_NSYMB) { + return srsran_pscch_symbol_map_tm34[i] == type; } return false; } -static const srslte_sl_symbol_t srslte_pssch_symbol_map_tm12[SRSLTE_CP_NORM_SF_NSYMB] = {SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DMRS_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DMRS_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_GUARD_SYMBOL}; - -static const srslte_sl_symbol_t srslte_pssch_symbol_map_tm12_ext[SRSLTE_CP_EXT_SF_NSYMB] = { - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DMRS_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DMRS_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_GUARD_SYMBOL}; - -static const srslte_sl_symbol_t srslte_pssch_symbol_map_tm34[SRSLTE_CP_NORM_SF_NSYMB] = {SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DMRS_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DMRS_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DMRS_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_DMRS_SYMBOL, - SRSLTE_SIDELINK_DATA_SYMBOL, - SRSLTE_SIDELINK_GUARD_SYMBOL}; - -bool srslte_pssch_is_symbol(srslte_sl_symbol_t type, srslte_sl_tm_t tm, uint32_t i, srslte_cp_t cp) +static const srsran_sl_symbol_t srsran_pssch_symbol_map_tm12[SRSRAN_CP_NORM_SF_NSYMB] = {SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DMRS_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DMRS_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_GUARD_SYMBOL}; + +static const srsran_sl_symbol_t srsran_pssch_symbol_map_tm12_ext[SRSRAN_CP_EXT_SF_NSYMB] = { + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DMRS_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DMRS_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_GUARD_SYMBOL}; + +static const srsran_sl_symbol_t srsran_pssch_symbol_map_tm34[SRSRAN_CP_NORM_SF_NSYMB] = {SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DMRS_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DMRS_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DMRS_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_DMRS_SYMBOL, + SRSRAN_SIDELINK_DATA_SYMBOL, + SRSRAN_SIDELINK_GUARD_SYMBOL}; + +bool srsran_pssch_is_symbol(srsran_sl_symbol_t type, srsran_sl_tm_t tm, uint32_t i, srsran_cp_t cp) { - if (tm == SRSLTE_SIDELINK_TM1 || tm == SRSLTE_SIDELINK_TM2) { - if (cp == SRSLTE_CP_EXT && i < SRSLTE_CP_EXT_SF_NSYMB) { - return srslte_pssch_symbol_map_tm12_ext[i] == type; - } else if (i < SRSLTE_CP_NORM_SF_NSYMB) { - return srslte_pssch_symbol_map_tm12[i] == type; + if (tm == SRSRAN_SIDELINK_TM1 || tm == SRSRAN_SIDELINK_TM2) { + if (cp == SRSRAN_CP_EXT && i < SRSRAN_CP_EXT_SF_NSYMB) { + return srsran_pssch_symbol_map_tm12_ext[i] == type; + } else if (i < SRSRAN_CP_NORM_SF_NSYMB) { + return srsran_pssch_symbol_map_tm12[i] == type; } - } else if ((tm == SRSLTE_SIDELINK_TM3 || tm == SRSLTE_SIDELINK_TM4) && i < SRSLTE_CP_NORM_SF_NSYMB) { - return srslte_pssch_symbol_map_tm34[i] == type; + } else if ((tm == SRSRAN_SIDELINK_TM3 || tm == SRSRAN_SIDELINK_TM4) && i < SRSRAN_CP_NORM_SF_NSYMB) { + return srsran_pssch_symbol_map_tm34[i] == type; } return false; } -uint32_t srslte_sci_format0_sizeof(uint32_t nof_prb) +uint32_t srsran_sci_format0_sizeof(uint32_t nof_prb) { // 3GPP TS 36.212 5.4.3.1 uint32_t n = 0; @@ -309,12 +309,12 @@ uint32_t srslte_sci_format0_sizeof(uint32_t nof_prb) } // Example pool configurations based on 3GPP TS 36.101 Version 15.6 Sections A.7 and A.9 -int srslte_sl_comm_resource_pool_get_default_config(srslte_sl_comm_resource_pool_t* q, srslte_cell_sl_t cell) +int srsran_sl_comm_resource_pool_get_default_config(srsran_sl_comm_resource_pool_t* q, srsran_cell_sl_t cell) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL) { q->period_length = 40; - if (cell.tm == SRSLTE_SIDELINK_TM3 || cell.tm == SRSLTE_SIDELINK_TM4) { + if (cell.tm == SRSRAN_SIDELINK_TM3 || cell.tm == SRSRAN_SIDELINK_TM4) { q->period_length = 160; } @@ -324,11 +324,11 @@ int srslte_sl_comm_resource_pool_get_default_config(srslte_sl_comm_resource_pool q->prb_end = cell.nof_prb - 1; // 0110000000000000000000000000000000000000 - bzero(q->pscch_sf_bitmap, SRSLTE_SL_MAX_PERIOD_LENGTH); + bzero(q->pscch_sf_bitmap, SRSRAN_SL_MAX_PERIOD_LENGTH); memset(&q->pscch_sf_bitmap[1], 1, 2); // 0001111111111111111111111111111111111111 - bzero(q->pssch_sf_bitmap, SRSLTE_SL_MAX_PERIOD_LENGTH); + bzero(q->pssch_sf_bitmap, SRSRAN_SL_MAX_PERIOD_LENGTH); memset(&q->pssch_sf_bitmap[3], 1, 37); q->size_sub_channel = 10; @@ -337,10 +337,10 @@ int srslte_sl_comm_resource_pool_get_default_config(srslte_sl_comm_resource_pool q->adjacency_pscch_pssch = true; q->sf_bitmap_tm34_len = 10; - bzero(q->sf_bitmap_tm34, SRSLTE_SL_MAX_PERIOD_LENGTH); + bzero(q->sf_bitmap_tm34, SRSRAN_SL_MAX_PERIOD_LENGTH); memset(q->sf_bitmap_tm34, 1, q->sf_bitmap_tm34_len); - if (cell.tm == SRSLTE_SIDELINK_TM4) { + if (cell.tm == SRSRAN_SIDELINK_TM4) { switch (cell.nof_prb) { case 6: q->size_sub_channel = 6; @@ -359,11 +359,11 @@ int srslte_sl_comm_resource_pool_get_default_config(srslte_sl_comm_resource_pool break; default: ERROR("Invalid nof_prb"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } diff --git a/lib/src/phy/common/sequence.c b/lib/src/phy/common/sequence.c index 418a913de..1216564e0 100644 --- a/lib/src/phy/common/sequence.c +++ b/lib/src/phy/common/sequence.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,10 +10,10 @@ * */ -#include "srslte/phy/common/sequence.h" -#include "srslte/phy/utils/bit.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/common/sequence.h" +#include "srsran/phy/utils/bit.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" #ifdef LV_HAVE_SSE #include @@ -140,7 +140,7 @@ static uint32_t sequence_x2_init[SEQUENCE_SEED_LEN] = {}; /** * C constructor, pre-computes X1 and X2 initial states */ -__attribute__((constructor)) __attribute__((unused)) static void srslte_lte_pr_pregen() +__attribute__((constructor)) __attribute__((unused)) static void srsran_lte_pr_pregen() { // Compute transition step sequence_x1_init = 1; @@ -205,13 +205,13 @@ static void sequence_gen_LTE_pr(uint8_t* pr, uint32_t len, uint32_t seed) } } -void srslte_sequence_state_init(srslte_sequence_state_t* s, uint32_t seed) +void srsran_sequence_state_init(srsran_sequence_state_t* s, uint32_t seed) { s->x1 = sequence_x1_init; s->x2 = sequence_get_x2_init(seed); } -void srslte_sequence_state_gen_f(srslte_sequence_state_t* s, float value, float* out, uint32_t length) +void srsran_sequence_state_gen_f(srsran_sequence_state_t* s, float value, float* out, uint32_t length) { uint32_t i = 0; const float xor [2] = {+0.0F, -0.0F}; @@ -264,7 +264,7 @@ void srslte_sequence_state_gen_f(srslte_sequence_state_t* s, float value, float* } } -void srslte_sequence_state_advance(srslte_sequence_state_t* s, uint32_t length) +void srsran_sequence_state_advance(srsran_sequence_state_t* s, uint32_t length) { uint32_t i = 0; if (length >= SEQUENCE_PAR_BITS) { @@ -283,16 +283,16 @@ void srslte_sequence_state_advance(srslte_sequence_state_t* s, uint32_t length) } // static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; -int srslte_sequence_set_LTE_pr(srslte_sequence_t* q, uint32_t len, uint32_t seed) +int srsran_sequence_set_LTE_pr(srsran_sequence_t* q, uint32_t len, uint32_t seed) { if (len > q->max_len) { ERROR("Error generating pseudo-random sequence: len %d is greater than allocated len %d", len, q->max_len); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } sequence_gen_LTE_pr(q->c, len, seed); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } static inline void @@ -358,57 +358,57 @@ sequence_generate_signed(const uint8_t* c_unpacked, int8_t* c_char, int16_t* c_s } } -int srslte_sequence_LTE_pr(srslte_sequence_t* q, uint32_t len, uint32_t seed) +int srsran_sequence_LTE_pr(srsran_sequence_t* q, uint32_t len, uint32_t seed) { - if (srslte_sequence_init(q, len)) { - return SRSLTE_ERROR; + if (srsran_sequence_init(q, len)) { + return SRSRAN_ERROR; } q->cur_len = len; // Generate sequence - srslte_sequence_set_LTE_pr(q, len, seed); + srsran_sequence_set_LTE_pr(q, len, seed); // Pack PR sequence - srslte_bit_pack_vector(q->c, q->c_bytes, len); + srsran_bit_pack_vector(q->c, q->c_bytes, len); // Generate signed type values sequence_generate_signed(q->c, q->c_char, q->c_short, q->c_float, len); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_sequence_init(srslte_sequence_t* q, uint32_t len) +int srsran_sequence_init(srsran_sequence_t* q, uint32_t len) { if (q->c && len > q->max_len) { - srslte_sequence_free(q); + srsran_sequence_free(q); } if (!q->c) { - q->c = srslte_vec_u8_malloc(len); + q->c = srsran_vec_u8_malloc(len); if (!q->c) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - q->c_bytes = srslte_vec_u8_malloc(len / 8 + 8); + q->c_bytes = srsran_vec_u8_malloc(len / 8 + 8); if (!q->c_bytes) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - q->c_float = srslte_vec_f_malloc(len); + q->c_float = srsran_vec_f_malloc(len); if (!q->c_float) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - q->c_short = srslte_vec_i16_malloc(len); + q->c_short = srsran_vec_i16_malloc(len); if (!q->c_short) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - q->c_char = srslte_vec_i8_malloc(len); + q->c_char = srsran_vec_i8_malloc(len); if (!q->c_char) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } q->max_len = len; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -void srslte_sequence_free(srslte_sequence_t* q) +void srsran_sequence_free(srsran_sequence_t* q) { if (q->c) { free(q->c); @@ -425,10 +425,10 @@ void srslte_sequence_free(srslte_sequence_t* q) if (q->c_char) { free(q->c_char); } - bzero(q, sizeof(srslte_sequence_t)); + bzero(q, sizeof(srsran_sequence_t)); } -void srslte_sequence_apply_f(const float* in, float* out, uint32_t length, uint32_t seed) +void srsran_sequence_apply_f(const float* in, float* out, uint32_t length, uint32_t seed) { uint32_t x1 = sequence_x1_init; // X1 initial state is fix uint32_t x2 = sequence_get_x2_init(seed); // loads x2 initial state @@ -482,7 +482,7 @@ void srslte_sequence_apply_f(const float* in, float* out, uint32_t length, uint3 } } -void srslte_sequence_apply_s(const int16_t* in, int16_t* out, uint32_t length, uint32_t seed) +void srsran_sequence_apply_s(const int16_t* in, int16_t* out, uint32_t length, uint32_t seed) { const int16_t s[2] = {+1, -1}; uint32_t x1 = sequence_x1_init; // X1 initial state is fix @@ -538,7 +538,7 @@ void srslte_sequence_apply_s(const int16_t* in, int16_t* out, uint32_t length, u } } -void srslte_sequence_apply_c(const int8_t* in, int8_t* out, uint32_t length, uint32_t seed) +void srsran_sequence_apply_c(const int8_t* in, int8_t* out, uint32_t length, uint32_t seed) { uint32_t x1 = sequence_x1_init; // X1 initial state is fix uint32_t x2 = sequence_get_x2_init(seed); // loads x2 initial state @@ -598,7 +598,7 @@ void srslte_sequence_apply_c(const int8_t* in, int8_t* out, uint32_t length, uin } } -void srslte_sequence_apply_bit(const uint8_t* in, uint8_t* out, uint32_t length, uint32_t seed) +void srsran_sequence_apply_bit(const uint8_t* in, uint8_t* out, uint32_t length, uint32_t seed) { uint32_t x1 = sequence_x1_init; // X1 initial state is fix uint32_t x2 = sequence_get_x2_init(seed); // loads x2 initial state @@ -657,7 +657,7 @@ void srslte_sequence_apply_bit(const uint8_t* in, uint8_t* out, uint32_t length, } } -void srslte_sequence_apply_packed(const uint8_t* in, uint8_t* out, uint32_t length, uint32_t seed) +void srsran_sequence_apply_packed(const uint8_t* in, uint8_t* out, uint32_t length, uint32_t seed) { uint32_t x1 = sequence_x1_init; // X1 initial state is fix uint32_t x2 = sequence_get_x2_init(seed); // loads x2 initial state diff --git a/lib/src/phy/common/test/CMakeLists.txt b/lib/src/phy/common/test/CMakeLists.txt index 75dbb7319..c933a3c23 100644 --- a/lib/src/phy/common/test/CMakeLists.txt +++ b/lib/src/phy/common/test/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -11,6 +11,6 @@ ######################################################################## add_executable(sequence_test sequence_test.c) -target_link_libraries(sequence_test srslte_phy) +target_link_libraries(sequence_test srsran_phy) add_test(sequence_test sequence_test) diff --git a/lib/src/phy/common/test/sequence_test.c b/lib/src/phy/common/test/sequence_test.c index c9ebbf501..1685c31b1 100644 --- a/lib/src/phy/common/test/sequence_test.c +++ b/lib/src/phy/common/test/sequence_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,10 +10,10 @@ * */ -#include "srslte/phy/common/sequence.h" -#include "srslte/phy/utils/bit.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/random.h" +#include "srsran/phy/common/sequence.h" +#include "srsran/phy/utils/bit.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/random.h" #define Nc 1600 #define MAX_SEQ_LEN (256 * 1024) @@ -34,9 +34,9 @@ static int8_t ones_char[Nc + MAX_SEQ_LEN + 31]; static uint8_t ones_packed[(MAX_SEQ_LEN * 7) / 8]; static uint8_t ones_unpacked[MAX_SEQ_LEN]; -static int test_sequence(srslte_sequence_t* sequence, uint32_t seed, uint32_t length, uint32_t repetitions) +static int test_sequence(srsran_sequence_t* sequence, uint32_t seed, uint32_t length, uint32_t repetitions) { - int ret = SRSLTE_SUCCESS; + int ret = SRSRAN_SUCCESS; struct timeval t[3] = {}; uint64_t interval_gen_us = 0; uint64_t interval_xor_float_us = 0; @@ -49,7 +49,7 @@ static int test_sequence(srslte_sequence_t* sequence, uint32_t seed, uint32_t le // Generate sequence for (uint32_t r = 0; r < repetitions; r++) { - srslte_sequence_LTE_pr(sequence, length, seed); + srsran_sequence_LTE_pr(sequence, length, seed); } gettimeofday(&t[2], NULL); @@ -74,23 +74,23 @@ static int test_sequence(srslte_sequence_t* sequence, uint32_t seed, uint32_t le c_char[n] = c[n] ? -1 : +1; } - srslte_bit_pack_vector(c, c_packed_gold, length); + srsran_bit_pack_vector(c, c_packed_gold, length); if (memcmp(c, sequence->c, length) != 0) { ERROR("Unmatched c"); - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } // Check Float sequence if (memcmp(c_float, sequence->c_float, length * sizeof(float)) != 0) { ERROR("Unmatched c_float"); - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } // Test in-place Float XOR gettimeofday(&t[1], NULL); for (uint32_t r = 0; r < repetitions; r++) { - srslte_sequence_apply_f(ones_float, sequence->c_float, length, seed); + srsran_sequence_apply_f(ones_float, sequence->c_float, length, seed); } gettimeofday(&t[2], NULL); get_time_interval(t); @@ -99,13 +99,13 @@ static int test_sequence(srslte_sequence_t* sequence, uint32_t seed, uint32_t le // Check Short Sequence if (memcmp(c_short, sequence->c_short, length * sizeof(int16_t)) != 0) { ERROR("Unmatched XOR c_short"); - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } // Test in-place Short XOR gettimeofday(&t[1], NULL); for (uint32_t r = 0; r < repetitions; r++) { - srslte_sequence_apply_s(ones_short, sequence->c_short, length, seed); + srsran_sequence_apply_s(ones_short, sequence->c_short, length, seed); } gettimeofday(&t[2], NULL); get_time_interval(t); @@ -113,19 +113,19 @@ static int test_sequence(srslte_sequence_t* sequence, uint32_t seed, uint32_t le if (memcmp(c_short, sequence->c_short, length * sizeof(int16_t)) != 0) { ERROR("Unmatched XOR c_short"); - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } // Check Char Sequence if (memcmp(c_char, sequence->c_char, length * sizeof(int8_t)) != 0) { ERROR("Unmatched c_char"); - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } // Test in-place Char XOR gettimeofday(&t[1], NULL); for (uint32_t r = 0; r < repetitions; r++) { - srslte_sequence_apply_c(ones_char, sequence->c_char, length, seed); + srsran_sequence_apply_c(ones_char, sequence->c_char, length, seed); } gettimeofday(&t[2], NULL); get_time_interval(t); @@ -134,7 +134,7 @@ static int test_sequence(srslte_sequence_t* sequence, uint32_t seed, uint32_t le // Test in-place unpacked XOR gettimeofday(&t[1], NULL); for (uint32_t r = 0; r < repetitions; r++) { - srslte_sequence_apply_bit(ones_unpacked, c_unpacked, length, seed); + srsran_sequence_apply_bit(ones_unpacked, c_unpacked, length, seed); } gettimeofday(&t[2], NULL); get_time_interval(t); @@ -143,7 +143,7 @@ static int test_sequence(srslte_sequence_t* sequence, uint32_t seed, uint32_t le // Test in-place packed XOR gettimeofday(&t[1], NULL); for (uint32_t r = 0; r < repetitions; r++) { - srslte_sequence_apply_packed(ones_packed, c_packed, length, seed); + srsran_sequence_apply_packed(ones_packed, c_packed, length, seed); } gettimeofday(&t[2], NULL); get_time_interval(t); @@ -151,22 +151,22 @@ static int test_sequence(srslte_sequence_t* sequence, uint32_t seed, uint32_t le if (memcmp(c_char, sequence->c_char, length * sizeof(int8_t)) != 0) { ERROR("Unmatched XOR c_char"); - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } if (memcmp(c_packed_gold, sequence->c_bytes, (length + 7) / 8) != 0) { ERROR("Unmatched c_packed"); - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } if (memcmp(c_packed_gold, c_packed, (length + 7) / 8) != 0) { ERROR("Unmatched c_packed"); - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } if (memcmp(c, c_unpacked, length) != 0) { ERROR("Unmatched c_unpacked"); - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } printf("%08x; %8d; %8.1f; %8.1f; %8.1f; %8.1f; %8.1f; %8.1f; %8c\n", @@ -178,9 +178,9 @@ static int test_sequence(srslte_sequence_t* sequence, uint32_t seed, uint32_t le (double)(length * repetitions) / (double)interval_xor_char_us, (double)(length * repetitions) / (double)interval_xor_unpacked_us, (double)(length * repetitions) / (double)interval_xor_packed_us, - ret == SRSLTE_SUCCESS ? 'y' : 'n'); + ret == SRSRAN_SUCCESS ? 'y' : 'n'); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int main(int argc, char** argv) @@ -189,8 +189,8 @@ int main(int argc, char** argv) uint32_t min_length = 16; uint32_t max_length = MAX_SEQ_LEN; - srslte_sequence_t sequence = {}; - srslte_random_t random_gen = srslte_random_init(0); + srsran_sequence_t sequence = {}; + srsran_random_t random_gen = srsran_random_init(0); // Initialise vectors with ones for (uint32_t i = 0; i < MAX_SEQ_LEN; i++) { @@ -204,9 +204,9 @@ int main(int argc, char** argv) } // Initialise sequence object - if (srslte_sequence_init(&sequence, max_length) != SRSLTE_SUCCESS) { + if (srsran_sequence_init(&sequence, max_length) != SRSRAN_SUCCESS) { fprintf(stderr, "Error initializing sequence object\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } printf("%8s; %8s; %8s; %8s; %8s; %8s; %8s; %8s; %8s;\n", @@ -221,12 +221,12 @@ int main(int argc, char** argv) "Passed"); for (uint32_t length = min_length; length <= max_length; length = (length * 5) / 4) { - test_sequence(&sequence, (uint32_t)srslte_random_uniform_int_dist(random_gen, 1, INT32_MAX), length, repetitions); + test_sequence(&sequence, (uint32_t)srsran_random_uniform_int_dist(random_gen, 1, INT32_MAX), length, repetitions); } // Free sequence object - srslte_sequence_free(&sequence); - srslte_random_free(random_gen); + srsran_sequence_free(&sequence); + srsran_random_free(random_gen); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } diff --git a/lib/src/phy/common/timestamp.c b/lib/src/phy/common/timestamp.c index fb423282b..5ec6ea1da 100644 --- a/lib/src/phy/common/timestamp.c +++ b/lib/src/phy/common/timestamp.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,43 +10,43 @@ * */ -#include "srslte/phy/common/timestamp.h" +#include "srsran/phy/common/timestamp.h" #include "math.h" -int srslte_timestamp_init(srslte_timestamp_t* t, time_t full_secs, double frac_secs) +int srsran_timestamp_init(srsran_timestamp_t* t, time_t full_secs, double frac_secs) { - int ret = SRSLTE_ERROR; + int ret = SRSRAN_ERROR; if (t != NULL && frac_secs >= 0.0) { t->full_secs = full_secs; t->frac_secs = frac_secs; - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } -void srslte_timestamp_init_uint64(srslte_timestamp_t* ts_time, uint64_t ts_count, double base_srate) +void srsran_timestamp_init_uint64(srsran_timestamp_t* ts_time, uint64_t ts_count, double base_srate) { uint64_t seconds = ts_count / (uint64_t)base_srate; uint64_t frac_samples = (uint64_t)(seconds * (uint64_t)base_srate); double frac_seconds = (double)(ts_count - frac_samples) / base_srate; if (ts_time) { - srslte_timestamp_init(ts_time, seconds, frac_seconds); + srsran_timestamp_init(ts_time, seconds, frac_seconds); } } -int srslte_timestamp_copy(srslte_timestamp_t* dest, srslte_timestamp_t* src) +int srsran_timestamp_copy(srsran_timestamp_t* dest, srsran_timestamp_t* src) { - int ret = SRSLTE_ERROR; + int ret = SRSRAN_ERROR; if (dest != NULL && src != NULL) { dest->full_secs = src->full_secs; dest->frac_secs = src->frac_secs; - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } -int srslte_timestamp_compare(const srslte_timestamp_t* a, const srslte_timestamp_t* b) +int srsran_timestamp_compare(const srsran_timestamp_t* a, const srsran_timestamp_t* b) { int ret = 0; @@ -63,23 +63,23 @@ int srslte_timestamp_compare(const srslte_timestamp_t* a, const srslte_timestamp return ret; } -int srslte_timestamp_add(srslte_timestamp_t* t, time_t full_secs, double frac_secs) +int srsran_timestamp_add(srsran_timestamp_t* t, time_t full_secs, double frac_secs) { - int ret = SRSLTE_ERROR; + int ret = SRSRAN_ERROR; if (t != NULL && frac_secs >= 0.0) { t->frac_secs += frac_secs; t->full_secs += full_secs; double r = floor(t->frac_secs); t->full_secs += r; t->frac_secs -= r; - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } -int srslte_timestamp_sub(srslte_timestamp_t* t, time_t full_secs, double frac_secs) +int srsran_timestamp_sub(srsran_timestamp_t* t, time_t full_secs, double frac_secs) { - int ret = SRSLTE_ERROR; + int ret = SRSRAN_ERROR; if (t != NULL && frac_secs >= 0.0) { t->frac_secs -= frac_secs; t->full_secs -= full_secs; @@ -88,29 +88,29 @@ int srslte_timestamp_sub(srslte_timestamp_t* t, time_t full_secs, double frac_se t->full_secs--; } if (t->full_secs < 0) - return SRSLTE_ERROR; - ret = SRSLTE_SUCCESS; + return SRSRAN_ERROR; + ret = SRSRAN_SUCCESS; } return ret; } -double srslte_timestamp_real(const srslte_timestamp_t* t) +double srsran_timestamp_real(const srsran_timestamp_t* t) { return t->frac_secs + t->full_secs; } -bool srslte_timestamp_iszero(const srslte_timestamp_t* t) +bool srsran_timestamp_iszero(const srsran_timestamp_t* t) { return ((t->full_secs == 0) && (t->frac_secs == 0)); } -uint32_t srslte_timestamp_uint32(srslte_timestamp_t* t) +uint32_t srsran_timestamp_uint32(srsran_timestamp_t* t) { uint32_t x = t->full_secs * 1e6 + (uint32_t)(t->frac_secs * 1e6); return x; } -uint64_t srslte_timestamp_uint64(const srslte_timestamp_t* t, double srate) +uint64_t srsran_timestamp_uint64(const srsran_timestamp_t* t, double srate) { return (uint64_t)(t->full_secs * (uint64_t)srate) + (uint64_t)round(t->frac_secs * srate); } diff --git a/lib/src/phy/common/zc_sequence.c b/lib/src/phy/common/zc_sequence.c index 250f02cf2..b860b9da2 100644 --- a/lib/src/phy/common/zc_sequence.c +++ b/lib/src/phy/common/zc_sequence.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,11 +10,11 @@ * */ -#include "srslte/phy/common/zc_sequence.h" -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/primes.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/common/zc_sequence.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/primes.h" +#include "srsran/phy/utils/vector.h" #include // Phi values for M_sc=12 Table 5.5.1.2-1 in TS 36.211 @@ -165,32 +165,32 @@ static const float zc_sequence_nr_phi_M_sc_24[30][24] = { static void zc_sequence_lte_r_uv_arg_1prb(uint32_t u, cf_t* tmp_arg) { - srslte_vec_sc_prod_fcc(zc_sequence_lte_phi_M_sc_12[u], M_PI_4, tmp_arg, SRSLTE_NRE); + srsran_vec_sc_prod_fcc(zc_sequence_lte_phi_M_sc_12[u], M_PI_4, tmp_arg, SRSRAN_NRE); } static void zc_sequence_lte_r_uv_arg_2prb(uint32_t u, cf_t* tmp_arg) { - srslte_vec_sc_prod_fcc(zc_sequence_lte_phi_M_sc_24[u], M_PI_4, tmp_arg, 2 * SRSLTE_NRE); + srsran_vec_sc_prod_fcc(zc_sequence_lte_phi_M_sc_24[u], M_PI_4, tmp_arg, 2 * SRSRAN_NRE); } static void zc_sequence_nr_r_uv_arg_0dot5prb(uint32_t u, cf_t* tmp_arg) { - srslte_vec_sc_prod_fcc(zc_sequence_nr_phi_M_sc_6[u], M_PI_4, tmp_arg, SRSLTE_NRE / 2); + srsran_vec_sc_prod_fcc(zc_sequence_nr_phi_M_sc_6[u], M_PI_4, tmp_arg, SRSRAN_NRE / 2); } static void zc_sequence_nr_r_uv_arg_1prb(uint32_t u, cf_t* tmp_arg) { - srslte_vec_sc_prod_fcc(zc_sequence_nr_phi_M_sc_12[u], M_PI_4, tmp_arg, SRSLTE_NRE); + srsran_vec_sc_prod_fcc(zc_sequence_nr_phi_M_sc_12[u], M_PI_4, tmp_arg, SRSRAN_NRE); } static void zc_sequence_nr_r_uv_arg_1dot5prb(uint32_t u, cf_t* tmp_arg) { - srslte_vec_sc_prod_fcc(zc_sequence_nr_phi_M_sc_18[u], M_PI_4, tmp_arg, (3 * SRSLTE_NRE) / 2); + srsran_vec_sc_prod_fcc(zc_sequence_nr_phi_M_sc_18[u], M_PI_4, tmp_arg, (3 * SRSRAN_NRE) / 2); } static void zc_sequence_nr_r_uv_arg_2prb(uint32_t u, cf_t* tmp_arg) { - srslte_vec_sc_prod_fcc(zc_sequence_nr_phi_M_sc_24[u], M_PI_4, tmp_arg, 2 * SRSLTE_NRE); + srsran_vec_sc_prod_fcc(zc_sequence_nr_phi_M_sc_24[u], M_PI_4, tmp_arg, 2 * SRSRAN_NRE); } static uint32_t zc_sequence_q(uint32_t u, uint32_t v, uint32_t N_sz) @@ -211,7 +211,7 @@ static uint32_t zc_sequence_q(uint32_t u, uint32_t v, uint32_t N_sz) // Common for LTE and NR static void zc_sequence_r_uv_arg_mprb(uint32_t M_zc, uint32_t u, uint32_t v, cf_t* tmp_arg) { - int32_t N_sz = srslte_prime_lower_than(M_zc); // N_zc - Zadoff Chu Sequence Length + int32_t N_sz = srsran_prime_lower_than(M_zc); // N_zc - Zadoff Chu Sequence Length if (N_sz > 0) { float q = zc_sequence_q(u, v, N_sz); float n_sz = (float)N_sz; @@ -232,10 +232,10 @@ static int zc_sequence_lte_r_uv_arg(uint32_t M_zc, uint32_t u, uint32_t v, cf_t* zc_sequence_r_uv_arg_mprb(M_zc, u, v, tmp_arg); } else { ERROR("Invalid M_zc (%d)", M_zc); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } static int zc_sequence_nr_r_uv_arg(uint32_t M_zc, uint32_t u, uint32_t v, cf_t* tmp_arg) @@ -252,10 +252,10 @@ static int zc_sequence_nr_r_uv_arg(uint32_t M_zc, uint32_t u, uint32_t v, cf_t* zc_sequence_r_uv_arg_mprb(M_zc, u, v, tmp_arg); } else { ERROR("Invalid M_zc (%d)", M_zc); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } static void zc_sequence_generate(uint32_t M_zc, float alpha, const cf_t* tmp_arg, cf_t* sequence) @@ -265,123 +265,123 @@ static void zc_sequence_generate(uint32_t M_zc, float alpha, const cf_t* tmp_arg } } -int srslte_zc_sequence_generate_lte(uint32_t u, uint32_t v, float alpha, uint32_t nof_prb, cf_t* sequence) +int srsran_zc_sequence_generate_lte(uint32_t u, uint32_t v, float alpha, uint32_t nof_prb, cf_t* sequence) { // Check inputs if (sequence == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } // Check U and V - if (u >= SRSLTE_ZC_SEQUENCE_NOF_GROUPS || v >= SRSLTE_ZC_SEQUENCE_NOF_BASE) { + if (u >= SRSRAN_ZC_SEQUENCE_NOF_GROUPS || v >= SRSRAN_ZC_SEQUENCE_NOF_BASE) { ERROR("Invalid u (%d) or v (%d)", u, v); - return SRSLTE_ERROR_OUT_OF_BOUNDS; + return SRSRAN_ERROR_OUT_OF_BOUNDS; } // Calculate number of samples - uint32_t M_zc = nof_prb * SRSLTE_NRE; + uint32_t M_zc = nof_prb * SRSRAN_NRE; // Calculate argument - if (zc_sequence_lte_r_uv_arg(M_zc, u, v, sequence) < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (zc_sequence_lte_r_uv_arg(M_zc, u, v, sequence) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } // Do complex exponential and adjust amplitude zc_sequence_generate(M_zc, alpha, sequence, sequence); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_zc_sequence_generate_nr(uint32_t u, uint32_t v, float alpha, uint32_t m, uint32_t delta, cf_t* sequence) +int srsran_zc_sequence_generate_nr(uint32_t u, uint32_t v, float alpha, uint32_t m, uint32_t delta, cf_t* sequence) { // Check inputs if (sequence == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } // Check U and V - if (u >= SRSLTE_ZC_SEQUENCE_NOF_GROUPS || v >= SRSLTE_ZC_SEQUENCE_NOF_BASE) { + if (u >= SRSRAN_ZC_SEQUENCE_NOF_GROUPS || v >= SRSRAN_ZC_SEQUENCE_NOF_BASE) { ERROR("Invalid u (%d) or v (%d)", u, v); - return SRSLTE_ERROR_OUT_OF_BOUNDS; + return SRSRAN_ERROR_OUT_OF_BOUNDS; } // Calculate number of samples - uint32_t M_zc = (m * SRSLTE_NRE) >> delta; + uint32_t M_zc = (m * SRSRAN_NRE) >> delta; // Calculate argument - if (zc_sequence_nr_r_uv_arg(M_zc, u, v, sequence) < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (zc_sequence_nr_r_uv_arg(M_zc, u, v, sequence) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } // Do complex exponential and adjust amplitude zc_sequence_generate(M_zc, alpha, sequence, sequence); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_zc_sequence_lut_init_nr(srslte_zc_sequence_lut_t* q, +int srsran_zc_sequence_lut_init_nr(srsran_zc_sequence_lut_t* q, uint32_t m, uint32_t delta, float* alphas, uint32_t nof_alphas) { if (q == NULL || alphas == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } // Set all structure to zero - SRSLTE_MEM_ZERO(q, srslte_zc_sequence_lut_t, 1); + SRSRAN_MEM_ZERO(q, srsran_zc_sequence_lut_t, 1); // Calculate number of samples - q->M_zc = (m * SRSLTE_NRE) >> delta; + q->M_zc = (m * SRSRAN_NRE) >> delta; q->nof_alphas = nof_alphas; - for (uint32_t u = 0; u < SRSLTE_ZC_SEQUENCE_NOF_GROUPS; u++) { - for (uint32_t v = 0; v < SRSLTE_ZC_SEQUENCE_NOF_BASE; v++) { + for (uint32_t u = 0; u < SRSRAN_ZC_SEQUENCE_NOF_GROUPS; u++) { + for (uint32_t v = 0; v < SRSRAN_ZC_SEQUENCE_NOF_BASE; v++) { // Allocate sequence - q->sequence[u][v] = srslte_vec_cf_malloc(nof_alphas * q->M_zc); + q->sequence[u][v] = srsran_vec_cf_malloc(nof_alphas * q->M_zc); if (q->sequence[u][v] == NULL) { ERROR("Malloc"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Generate a sequence for each alpha for (uint32_t alpha_idx = 0; alpha_idx < nof_alphas; alpha_idx++) { - if (srslte_zc_sequence_generate_nr(u, v, alphas[alpha_idx], m, delta, &q->sequence[u][v][alpha_idx * q->M_zc]) < - SRSLTE_SUCCESS) { + if (srsran_zc_sequence_generate_nr(u, v, alphas[alpha_idx], m, delta, &q->sequence[u][v][alpha_idx * q->M_zc]) < + SRSRAN_SUCCESS) { ERROR("Generating sequence"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -void srslte_zc_sequence_lut_free(srslte_zc_sequence_lut_t* q) +void srsran_zc_sequence_lut_free(srsran_zc_sequence_lut_t* q) { - for (uint32_t u = 0; u < SRSLTE_ZC_SEQUENCE_NOF_GROUPS; u++) { - for (uint32_t v = 0; v < SRSLTE_ZC_SEQUENCE_NOF_BASE; v++) { + for (uint32_t u = 0; u < SRSRAN_ZC_SEQUENCE_NOF_GROUPS; u++) { + for (uint32_t v = 0; v < SRSRAN_ZC_SEQUENCE_NOF_BASE; v++) { if (q->sequence[u][v] != NULL) { free(q->sequence[u][v]); } } } - SRSLTE_MEM_ZERO(q, srslte_zc_sequence_lut_t, 1); + SRSRAN_MEM_ZERO(q, srsran_zc_sequence_lut_t, 1); } -const cf_t* srslte_zc_sequence_lut_get(const srslte_zc_sequence_lut_t* q, uint32_t u, uint32_t v, uint32_t alpha_idx) +const cf_t* srsran_zc_sequence_lut_get(const srsran_zc_sequence_lut_t* q, uint32_t u, uint32_t v, uint32_t alpha_idx) { if (q == NULL) { return NULL; } - if (u >= SRSLTE_ZC_SEQUENCE_NOF_GROUPS) { + if (u >= SRSRAN_ZC_SEQUENCE_NOF_GROUPS) { return NULL; } - if (v >= SRSLTE_ZC_SEQUENCE_NOF_BASE) { + if (v >= SRSRAN_ZC_SEQUENCE_NOF_BASE) { return NULL; } diff --git a/lib/src/phy/dft/CMakeLists.txt b/lib/src/phy/dft/CMakeLists.txt index d39cc0fbc..7776f5919 100644 --- a/lib/src/phy/dft/CMakeLists.txt +++ b/lib/src/phy/dft/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -7,5 +7,5 @@ # set(SRCS dft_fftw.c dft_precoding.c ofdm.c) -add_library(srslte_dft OBJECT ${SRCS}) +add_library(srsran_dft OBJECT ${SRCS}) add_subdirectory(test) diff --git a/lib/src/phy/dft/dft_fftw.c b/lib/src/phy/dft/dft_fftw.c index df703a918..0f5599612 100644 --- a/lib/src/phy/dft/dft_fftw.c +++ b/lib/src/phy/dft/dft_fftw.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,7 +10,7 @@ * */ -#include "srslte/srslte.h" +#include "srsran/srsran.h" #include #include #include @@ -18,13 +18,13 @@ #include #include -#include "srslte/phy/dft/dft.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/dft/dft.h" +#include "srsran/phy/utils/vector.h" #define dft_ceil(a, b) ((a - 1) / b + 1) #define dft_floor(a, b) (a / b) -#define FFTW_WISDOM_FILE "%s/.srslte_fftwisdom" +#define FFTW_WISDOM_FILE "%s/.srsran_fftwisdom" static int get_fftw_wisdom_file(char* full_path, uint32_t n) { @@ -45,7 +45,7 @@ static int get_fftw_wisdom_file(char* full_path, uint32_t n) static pthread_mutex_t fft_mutex = PTHREAD_MUTEX_INITIALIZER; // This function is called in the beggining of any executable where it is linked -__attribute__((constructor)) static void srslte_dft_load() +__attribute__((constructor)) static void srsran_dft_load() { #ifdef FFTW_WISDOM_FILE char full_path[256]; @@ -57,7 +57,7 @@ __attribute__((constructor)) static void srslte_dft_load() } // This function is called in the ending of any executable where it is linked -__attribute__((destructor)) static void srslte_dft_exit() +__attribute__((destructor)) static void srsran_dft_exit() { #ifdef FFTW_WISDOM_FILE char full_path[256]; @@ -67,24 +67,24 @@ __attribute__((destructor)) static void srslte_dft_exit() fftwf_cleanup(); } -int srslte_dft_plan(srslte_dft_plan_t* plan, const int dft_points, srslte_dft_dir_t dir, srslte_dft_mode_t mode) +int srsran_dft_plan(srsran_dft_plan_t* plan, const int dft_points, srsran_dft_dir_t dir, srsran_dft_mode_t mode) { - bzero(plan, sizeof(srslte_dft_plan_t)); - if (mode == SRSLTE_DFT_COMPLEX) { - return srslte_dft_plan_c(plan, dft_points, dir); + bzero(plan, sizeof(srsran_dft_plan_t)); + if (mode == SRSRAN_DFT_COMPLEX) { + return srsran_dft_plan_c(plan, dft_points, dir); } else { - return srslte_dft_plan_r(plan, dft_points, dir); + return srsran_dft_plan_r(plan, dft_points, dir); } return 0; } -int srslte_dft_replan(srslte_dft_plan_t* plan, const int new_dft_points) +int srsran_dft_replan(srsran_dft_plan_t* plan, const int new_dft_points) { if (new_dft_points <= plan->init_size) { - if (plan->mode == SRSLTE_DFT_COMPLEX) { - return srslte_dft_replan_c(plan, new_dft_points); + if (plan->mode == SRSRAN_DFT_COMPLEX) { + return srsran_dft_replan_c(plan, new_dft_points); } else { - return srslte_dft_replan_r(plan, new_dft_points); + return srsran_dft_replan_r(plan, new_dft_points); } } else { ERROR("DFT: Error calling replan: new_dft_points (%d) must be lower or equal " @@ -95,13 +95,13 @@ int srslte_dft_replan(srslte_dft_plan_t* plan, const int new_dft_points) } } -static void allocate(srslte_dft_plan_t* plan, int size_in, int size_out, int len) +static void allocate(srsran_dft_plan_t* plan, int size_in, int size_out, int len) { plan->in = fftwf_malloc((size_t)size_in * len); plan->out = fftwf_malloc((size_t)size_out * len); } -int srslte_dft_replan_guru_c(srslte_dft_plan_t* plan, +int srsran_dft_replan_guru_c(srsran_dft_plan_t* plan, const int new_dft_points, cf_t* in_buffer, cf_t* out_buffer, @@ -134,9 +134,9 @@ int srslte_dft_replan_guru_c(srslte_dft_plan_t* plan, return 0; } -int srslte_dft_replan_c(srslte_dft_plan_t* plan, const int new_dft_points) +int srsran_dft_replan_c(srsran_dft_plan_t* plan, const int new_dft_points) { - int sign = (plan->dir == SRSLTE_DFT_FORWARD) ? FFTW_FORWARD : FFTW_BACKWARD; + int sign = (plan->dir == SRSRAN_DFT_FORWARD) ? FFTW_FORWARD : FFTW_BACKWARD; // No change in size, skip re-planning if (plan->size == new_dft_points) { @@ -158,9 +158,9 @@ int srslte_dft_replan_c(srslte_dft_plan_t* plan, const int new_dft_points) return 0; } -int srslte_dft_plan_guru_c(srslte_dft_plan_t* plan, +int srsran_dft_plan_guru_c(srsran_dft_plan_t* plan, const int dft_points, - srslte_dft_dir_t dir, + srsran_dft_dir_t dir, cf_t* in_buffer, cf_t* out_buffer, int istride, @@ -169,7 +169,7 @@ int srslte_dft_plan_guru_c(srslte_dft_plan_t* plan, int idist, int odist) { - int sign = (dir == SRSLTE_DFT_FORWARD) ? FFTW_FORWARD : FFTW_BACKWARD; + int sign = (dir == SRSRAN_DFT_FORWARD) ? FFTW_FORWARD : FFTW_BACKWARD; const fftwf_iodim iodim = {dft_points, istride, ostride}; const fftwf_iodim howmany_dims = {how_many, idist, odist}; @@ -184,9 +184,9 @@ int srslte_dft_plan_guru_c(srslte_dft_plan_t* plan, plan->size = dft_points; plan->init_size = plan->size; - plan->mode = SRSLTE_DFT_COMPLEX; + plan->mode = SRSRAN_DFT_COMPLEX; plan->dir = dir; - plan->forward = (dir == SRSLTE_DFT_FORWARD) ? true : false; + plan->forward = (dir == SRSRAN_DFT_FORWARD) ? true : false; plan->mirror = false; plan->db = false; plan->norm = false; @@ -196,13 +196,13 @@ int srslte_dft_plan_guru_c(srslte_dft_plan_t* plan, return 0; } -int srslte_dft_plan_c(srslte_dft_plan_t* plan, const int dft_points, srslte_dft_dir_t dir) +int srsran_dft_plan_c(srsran_dft_plan_t* plan, const int dft_points, srsran_dft_dir_t dir) { allocate(plan, sizeof(fftwf_complex), sizeof(fftwf_complex), dft_points); pthread_mutex_lock(&fft_mutex); - int sign = (dir == SRSLTE_DFT_FORWARD) ? FFTW_FORWARD : FFTW_BACKWARD; + int sign = (dir == SRSRAN_DFT_FORWARD) ? FFTW_FORWARD : FFTW_BACKWARD; plan->p = fftwf_plan_dft_1d(dft_points, plan->in, plan->out, sign, FFTW_TYPE); pthread_mutex_unlock(&fft_mutex); @@ -212,9 +212,9 @@ int srslte_dft_plan_c(srslte_dft_plan_t* plan, const int dft_points, srslte_dft_ } plan->size = dft_points; plan->init_size = plan->size; - plan->mode = SRSLTE_DFT_COMPLEX; + plan->mode = SRSRAN_DFT_COMPLEX; plan->dir = dir; - plan->forward = (dir == SRSLTE_DFT_FORWARD) ? true : false; + plan->forward = (dir == SRSRAN_DFT_FORWARD) ? true : false; plan->mirror = false; plan->db = false; plan->norm = false; @@ -224,9 +224,9 @@ int srslte_dft_plan_c(srslte_dft_plan_t* plan, const int dft_points, srslte_dft_ return 0; } -int srslte_dft_replan_r(srslte_dft_plan_t* plan, const int new_dft_points) +int srsran_dft_replan_r(srsran_dft_plan_t* plan, const int new_dft_points) { - int sign = (plan->dir == SRSLTE_DFT_FORWARD) ? FFTW_R2HC : FFTW_HC2R; + int sign = (plan->dir == SRSRAN_DFT_FORWARD) ? FFTW_R2HC : FFTW_HC2R; pthread_mutex_lock(&fft_mutex); if (plan->p) { @@ -243,10 +243,10 @@ int srslte_dft_replan_r(srslte_dft_plan_t* plan, const int new_dft_points) return 0; } -int srslte_dft_plan_r(srslte_dft_plan_t* plan, const int dft_points, srslte_dft_dir_t dir) +int srsran_dft_plan_r(srsran_dft_plan_t* plan, const int dft_points, srsran_dft_dir_t dir) { allocate(plan, sizeof(float), sizeof(float), dft_points); - int sign = (dir == SRSLTE_DFT_FORWARD) ? FFTW_R2HC : FFTW_HC2R; + int sign = (dir == SRSRAN_DFT_FORWARD) ? FFTW_R2HC : FFTW_HC2R; pthread_mutex_lock(&fft_mutex); plan->p = fftwf_plan_r2r_1d(dft_points, plan->in, plan->out, sign, FFTW_TYPE); @@ -257,9 +257,9 @@ int srslte_dft_plan_r(srslte_dft_plan_t* plan, const int dft_points, srslte_dft_ } plan->size = dft_points; plan->init_size = plan->size; - plan->mode = SRSLTE_REAL; + plan->mode = SRSRAN_REAL; plan->dir = dir; - plan->forward = (dir == SRSLTE_DFT_FORWARD) ? true : false; + plan->forward = (dir == SRSRAN_DFT_FORWARD) ? true : false; plan->mirror = false; plan->db = false; plan->norm = false; @@ -268,19 +268,19 @@ int srslte_dft_plan_r(srslte_dft_plan_t* plan, const int dft_points, srslte_dft_ return 0; } -void srslte_dft_plan_set_mirror(srslte_dft_plan_t* plan, bool val) +void srsran_dft_plan_set_mirror(srsran_dft_plan_t* plan, bool val) { plan->mirror = val; } -void srslte_dft_plan_set_db(srslte_dft_plan_t* plan, bool val) +void srsran_dft_plan_set_db(srsran_dft_plan_t* plan, bool val) { plan->db = val; } -void srslte_dft_plan_set_norm(srslte_dft_plan_t* plan, bool val) +void srsran_dft_plan_set_norm(srsran_dft_plan_t* plan, bool val) { plan->norm = val; } -void srslte_dft_plan_set_dc(srslte_dft_plan_t* plan, bool val) +void srsran_dft_plan_set_dc(srsran_dft_plan_t* plan, bool val) { plan->dc = val; } @@ -310,21 +310,21 @@ static void copy_post(uint8_t* dst, uint8_t* src, int size_d, int len, bool forw } } -void srslte_dft_run(srslte_dft_plan_t* plan, const void* in, void* out) +void srsran_dft_run(srsran_dft_plan_t* plan, const void* in, void* out) { - if (plan->mode == SRSLTE_DFT_COMPLEX) { - srslte_dft_run_c(plan, in, out); + if (plan->mode == SRSRAN_DFT_COMPLEX) { + srsran_dft_run_c(plan, in, out); } else { - srslte_dft_run_r(plan, in, out); + srsran_dft_run_r(plan, in, out); } } -void srslte_dft_run_c_zerocopy(srslte_dft_plan_t* plan, const cf_t* in, cf_t* out) +void srsran_dft_run_c_zerocopy(srsran_dft_plan_t* plan, const cf_t* in, cf_t* out) { fftwf_execute_dft(plan->p, (cf_t*)in, out); } -void srslte_dft_run_c(srslte_dft_plan_t* plan, const cf_t* in, cf_t* out) +void srsran_dft_run_c(srsran_dft_plan_t* plan, const cf_t* in, cf_t* out) { float norm; int i; @@ -334,26 +334,26 @@ void srslte_dft_run_c(srslte_dft_plan_t* plan, const cf_t* in, cf_t* out) fftwf_execute(plan->p); if (plan->norm) { norm = 1.0 / sqrtf(plan->size); - srslte_vec_sc_prod_cfc(f_out, norm, f_out, plan->size); + srsran_vec_sc_prod_cfc(f_out, norm, f_out, plan->size); } if (plan->db) { for (i = 0; i < plan->size; i++) { - f_out[i] = srslte_convert_power_to_dB(f_out[i]); + f_out[i] = srsran_convert_power_to_dB(f_out[i]); } } copy_post((uint8_t*)out, (uint8_t*)plan->out, sizeof(cf_t), plan->size, plan->forward, plan->mirror, plan->dc); } -void srslte_dft_run_guru_c(srslte_dft_plan_t* plan) +void srsran_dft_run_guru_c(srsran_dft_plan_t* plan) { if (plan->is_guru == true) { fftwf_execute(plan->p); } else { - ERROR("srslte_dft_run_guru_c: the selected plan is not guru!"); + ERROR("srsran_dft_run_guru_c: the selected plan is not guru!"); } } -void srslte_dft_run_r(srslte_dft_plan_t* plan, const float* in, float* out) +void srsran_dft_run_r(srsran_dft_plan_t* plan, const float* in, float* out) { float norm; int i; @@ -364,17 +364,17 @@ void srslte_dft_run_r(srslte_dft_plan_t* plan, const float* in, float* out) fftwf_execute(plan->p); if (plan->norm) { norm = 1.0 / plan->size; - srslte_vec_sc_prod_fff(f_out, norm, f_out, plan->size); + srsran_vec_sc_prod_fff(f_out, norm, f_out, plan->size); } if (plan->db) { for (i = 0; i < len; i++) { - f_out[i] = srslte_convert_power_to_dB(f_out[i]); + f_out[i] = srsran_convert_power_to_dB(f_out[i]); } } memcpy(out, plan->out, sizeof(float) * plan->size); } -void srslte_dft_plan_free(srslte_dft_plan_t* plan) +void srsran_dft_plan_free(srsran_dft_plan_t* plan) { if (!plan) return; @@ -391,5 +391,5 @@ void srslte_dft_plan_free(srslte_dft_plan_t* plan) if (plan->p) fftwf_destroy_plan(plan->p); pthread_mutex_unlock(&fft_mutex); - bzero(plan, sizeof(srslte_dft_plan_t)); + bzero(plan, sizeof(srsran_dft_plan_t)); } diff --git a/lib/src/phy/dft/dft_precoding.c b/lib/src/phy/dft/dft_precoding.c index 619bb2929..cfc00c90f 100644 --- a/lib/src/phy/dft/dft_precoding.c +++ b/lib/src/phy/dft/dft_precoding.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -19,61 +19,61 @@ #include #include -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/dft/dft.h" -#include "srslte/phy/dft/dft_precoding.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/dft/dft.h" +#include "srsran/phy/dft/dft_precoding.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" /* Create DFT plans for transform precoding */ -int srslte_dft_precoding_init(srslte_dft_precoding_t* q, uint32_t max_prb, bool is_tx) +int srsran_dft_precoding_init(srsran_dft_precoding_t* q, uint32_t max_prb, bool is_tx) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; - bzero(q, sizeof(srslte_dft_precoding_t)); + int ret = SRSRAN_ERROR_INVALID_INPUTS; + bzero(q, sizeof(srsran_dft_precoding_t)); - if (max_prb <= SRSLTE_MAX_PRB) { - ret = SRSLTE_ERROR; + if (max_prb <= SRSRAN_MAX_PRB) { + ret = SRSRAN_ERROR; for (uint32_t i = 1; i <= max_prb; i++) { - if (srslte_dft_precoding_valid_prb(i)) { + if (srsran_dft_precoding_valid_prb(i)) { DEBUG("Initiating DFT precoding plan for %d PRBs", i); - if (srslte_dft_plan_c(&q->dft_plan[i], i * SRSLTE_NRE, is_tx ? SRSLTE_DFT_FORWARD : SRSLTE_DFT_BACKWARD)) { + if (srsran_dft_plan_c(&q->dft_plan[i], i * SRSRAN_NRE, is_tx ? SRSRAN_DFT_FORWARD : SRSRAN_DFT_BACKWARD)) { ERROR("Error: Creating DFT plan %d", i); goto clean_exit; } - srslte_dft_plan_set_norm(&q->dft_plan[i], true); + srsran_dft_plan_set_norm(&q->dft_plan[i], true); } } q->max_prb = max_prb; - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } clean_exit: - if (ret == SRSLTE_ERROR) { - srslte_dft_precoding_free(q); + if (ret == SRSRAN_ERROR) { + srsran_dft_precoding_free(q); } return ret; } -int srslte_dft_precoding_init_rx(srslte_dft_precoding_t* q, uint32_t max_prb) +int srsran_dft_precoding_init_rx(srsran_dft_precoding_t* q, uint32_t max_prb) { - return srslte_dft_precoding_init(q, max_prb, false); + return srsran_dft_precoding_init(q, max_prb, false); } -int srslte_dft_precoding_init_tx(srslte_dft_precoding_t* q, uint32_t max_prb) +int srsran_dft_precoding_init_tx(srsran_dft_precoding_t* q, uint32_t max_prb) { - return srslte_dft_precoding_init(q, max_prb, true); + return srsran_dft_precoding_init(q, max_prb, true); } /* Free DFT plans for transform precoding */ -void srslte_dft_precoding_free(srslte_dft_precoding_t* q) +void srsran_dft_precoding_free(srsran_dft_precoding_t* q) { for (uint32_t i = 1; i <= q->max_prb; i++) { - if (srslte_dft_precoding_valid_prb(i)) { - srslte_dft_plan_free(&q->dft_plan[i]); + if (srsran_dft_precoding_valid_prb(i)) { + srsran_dft_plan_free(&q->dft_plan[i]); } } - bzero(q, sizeof(srslte_dft_precoding_t)); + bzero(q, sizeof(srsran_dft_precoding_t)); } static bool valid_prb[101] = {true, true, true, true, true, true, true, false, true, true, true, false, true, @@ -85,7 +85,7 @@ static bool valid_prb[101] = {true, true, true, true, true, true, true, f false, false, true, true, false, false, false, false, false, false, false, false, true, false, false, false, false, false, true, false, false, false, true}; -bool srslte_dft_precoding_valid_prb(uint32_t nof_prb) +bool srsran_dft_precoding_valid_prb(uint32_t nof_prb) { if (nof_prb <= 100) { return valid_prb[nof_prb]; @@ -94,24 +94,24 @@ bool srslte_dft_precoding_valid_prb(uint32_t nof_prb) } /* Return largest integer that fulfills the DFT precoding PRB criterion (TS 36.213 Section 14.1.1.4C) */ -uint32_t srslte_dft_precoding_get_valid_prb(uint32_t nof_prb) +uint32_t srsran_dft_precoding_get_valid_prb(uint32_t nof_prb) { - while (srslte_dft_precoding_valid_prb(nof_prb) == false) { + while (srsran_dft_precoding_valid_prb(nof_prb) == false) { nof_prb--; } return nof_prb; } -int srslte_dft_precoding(srslte_dft_precoding_t* q, cf_t* input, cf_t* output, uint32_t nof_prb, uint32_t nof_symbols) +int srsran_dft_precoding(srsran_dft_precoding_t* q, cf_t* input, cf_t* output, uint32_t nof_prb, uint32_t nof_symbols) { - if (!srslte_dft_precoding_valid_prb(nof_prb) && nof_prb <= q->max_prb) { + if (!srsran_dft_precoding_valid_prb(nof_prb) && nof_prb <= q->max_prb) { ERROR("Error invalid number of PRB (%d)", nof_prb); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } for (uint32_t i = 0; i < nof_symbols; i++) { - srslte_dft_run_c(&q->dft_plan[nof_prb], &input[i * SRSLTE_NRE * nof_prb], &output[i * SRSLTE_NRE * nof_prb]); + srsran_dft_run_c(&q->dft_plan[nof_prb], &input[i * SRSRAN_NRE * nof_prb], &output[i * SRSRAN_NRE * nof_prb]); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } diff --git a/lib/src/phy/dft/ofdm.c b/lib/src/phy/dft/ofdm.c index e729d8b9d..4e48cc6a7 100644 --- a/lib/src/phy/dft/ofdm.c +++ b/lib/src/phy/dft/ofdm.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,30 +10,30 @@ * */ -#include "srslte/srslte.h" +#include "srsran/srsran.h" #include #include #include #include #include -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/dft/dft.h" -#include "srslte/phy/dft/ofdm.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/dft/dft.h" +#include "srsran/phy/dft/ofdm.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" /* Uncomment next line for avoiding Guru DFT call */ //#define AVOID_GURU -static int ofdm_init_mbsfn_(srslte_ofdm_t* q, srslte_ofdm_cfg_t* cfg, srslte_dft_dir_t dir) +static int ofdm_init_mbsfn_(srsran_ofdm_t* q, srsran_ofdm_cfg_t* cfg, srsran_dft_dir_t dir) { // If the symbol size is not given, calculate in function of the number of resource blocks if (cfg->symbol_sz == 0) { - int symbol_sz_err = srslte_symbol_sz(cfg->nof_prb); - if (symbol_sz_err <= SRSLTE_SUCCESS) { + int symbol_sz_err = srsran_symbol_sz(cfg->nof_prb); + if (symbol_sz_err <= SRSRAN_SUCCESS) { ERROR("Invalid number of PRB %d", cfg->nof_prb); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } cfg->symbol_sz = (uint32_t)symbol_sz_err; } @@ -49,29 +49,29 @@ static int ofdm_init_mbsfn_(srslte_ofdm_t* q, srslte_ofdm_cfg_t* cfg, srslte_dft } uint32_t symbol_sz = q->cfg.symbol_sz; - srslte_cp_t cp = q->cfg.cp; - srslte_sf_t sf_type = q->cfg.sf_type; + srsran_cp_t cp = q->cfg.cp; + srsran_sf_t sf_type = q->cfg.sf_type; // Set OFDM object attributes - q->nof_symbols = SRSLTE_CP_NSYMB(cp); - q->nof_symbols_mbsfn = SRSLTE_CP_NSYMB(SRSLTE_CP_EXT); - q->nof_re = cfg->nof_prb * SRSLTE_NRE; + q->nof_symbols = SRSRAN_CP_NSYMB(cp); + q->nof_symbols_mbsfn = SRSRAN_CP_NSYMB(SRSRAN_CP_EXT); + q->nof_re = cfg->nof_prb * SRSRAN_NRE; q->nof_guards = (q->cfg.symbol_sz - q->nof_re) / 2U; - q->slot_sz = (uint32_t)SRSLTE_SLOT_LEN(q->cfg.symbol_sz); - q->sf_sz = (uint32_t)SRSLTE_SF_LEN(q->cfg.symbol_sz); + q->slot_sz = (uint32_t)SRSRAN_SLOT_LEN(q->cfg.symbol_sz); + q->sf_sz = (uint32_t)SRSRAN_SF_LEN(q->cfg.symbol_sz); // Plan MBSFN if (q->fft_plan.size) { // Replan if it was initialised previously - if (srslte_dft_replan(&q->fft_plan, q->cfg.symbol_sz)) { + if (srsran_dft_replan(&q->fft_plan, q->cfg.symbol_sz)) { ERROR("Reeplaning DFT plan"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } else { // Create plan from zero otherwise - if (srslte_dft_plan_c(&q->fft_plan, symbol_sz, dir)) { + if (srsran_dft_plan_c(&q->fft_plan, symbol_sz, dir)) { ERROR("Creating DFT plan"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } @@ -84,43 +84,43 @@ static int ofdm_init_mbsfn_(srslte_ofdm_t* q, srslte_ofdm_cfg_t* cfg, srslte_dft } #ifdef AVOID_GURU - q->tmp = srslte_vec_cf_malloc(symbol_sz); + q->tmp = srsran_vec_cf_malloc(symbol_sz); #else - q->tmp = srslte_vec_cf_malloc(q->sf_sz); + q->tmp = srsran_vec_cf_malloc(q->sf_sz); #endif /* AVOID_GURU */ if (!q->tmp) { perror("malloc"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - q->shift_buffer = srslte_vec_cf_malloc(q->sf_sz); + q->shift_buffer = srsran_vec_cf_malloc(q->sf_sz); if (!q->shift_buffer) { perror("malloc"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - q->window_offset_buffer = srslte_vec_cf_malloc(q->sf_sz); + q->window_offset_buffer = srsran_vec_cf_malloc(q->sf_sz); if (!q->window_offset_buffer) { perror("malloc"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } q->max_prb = cfg->nof_prb; } #ifdef AVOID_GURU - srslte_vec_cf_zero(q->tmp, symbol_sz); + srsran_vec_cf_zero(q->tmp, symbol_sz); #else uint32_t nof_prb = q->cfg.nof_prb; cf_t* in_buffer = q->cfg.in_buffer; cf_t* out_buffer = q->cfg.out_buffer; - int cp1 = SRSLTE_CP_ISNORM(cp) ? SRSLTE_CP_LEN_NORM(0, symbol_sz) : SRSLTE_CP_LEN_EXT(symbol_sz); - int cp2 = SRSLTE_CP_ISNORM(cp) ? SRSLTE_CP_LEN_NORM(1, symbol_sz) : SRSLTE_CP_LEN_EXT(symbol_sz); + int cp1 = SRSRAN_CP_ISNORM(cp) ? SRSRAN_CP_LEN_NORM(0, symbol_sz) : SRSRAN_CP_LEN_EXT(symbol_sz); + int cp2 = SRSRAN_CP_ISNORM(cp) ? SRSRAN_CP_LEN_NORM(1, symbol_sz) : SRSRAN_CP_LEN_EXT(symbol_sz); // Slides DFT window a fraction of cyclic prefix, it does not apply for the inverse-DFT if (isnormal(cfg->rx_window_offset)) { - cfg->rx_window_offset = SRSLTE_MAX(0, cfg->rx_window_offset); // Needs to be positive - cfg->rx_window_offset = SRSLTE_MIN(100, cfg->rx_window_offset); // Needs to be below 100 + cfg->rx_window_offset = SRSRAN_MAX(0, cfg->rx_window_offset); // Needs to be positive + cfg->rx_window_offset = SRSRAN_MIN(100, cfg->rx_window_offset); // Needs to be below 100 q->window_offset_n = (uint32_t)roundf((float)cp2 * cfg->rx_window_offset); for (uint32_t i = 0; i < symbol_sz; i++) { @@ -129,65 +129,65 @@ static int ofdm_init_mbsfn_(srslte_ofdm_t* q, srslte_ofdm_cfg_t* cfg, srslte_dft } // Zero temporal and input buffers always - srslte_vec_cf_zero(q->tmp, q->sf_sz); + srsran_vec_cf_zero(q->tmp, q->sf_sz); - if (dir == SRSLTE_DFT_BACKWARD) { - srslte_vec_cf_zero(in_buffer, SRSLTE_SF_LEN_RE(nof_prb, cp)); + if (dir == SRSRAN_DFT_BACKWARD) { + srsran_vec_cf_zero(in_buffer, SRSRAN_SF_LEN_RE(nof_prb, cp)); } else { - srslte_vec_cf_zero(in_buffer, q->sf_sz); + srsran_vec_cf_zero(in_buffer, q->sf_sz); } for (int slot = 0; slot < 2; slot++) { // If Guru DFT was allocated, free if (q->fft_plan_sf[slot].size) { - srslte_dft_plan_free(&q->fft_plan_sf[slot]); + srsran_dft_plan_free(&q->fft_plan_sf[slot]); } // Create Tx/Rx plans - if (dir == SRSLTE_DFT_FORWARD) { - if (srslte_dft_plan_guru_c(&q->fft_plan_sf[slot], + if (dir == SRSRAN_DFT_FORWARD) { + if (srsran_dft_plan_guru_c(&q->fft_plan_sf[slot], symbol_sz, dir, in_buffer + cp1 + q->slot_sz * slot - q->window_offset_n, q->tmp, 1, 1, - SRSLTE_CP_NSYMB(cp), + SRSRAN_CP_NSYMB(cp), symbol_sz + cp2, symbol_sz)) { ERROR("Creating Guru DFT plan (%d)", slot); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } else { - if (srslte_dft_plan_guru_c(&q->fft_plan_sf[slot], + if (srsran_dft_plan_guru_c(&q->fft_plan_sf[slot], symbol_sz, dir, q->tmp, out_buffer + cp1 + q->slot_sz * slot, 1, 1, - SRSLTE_CP_NSYMB(cp), + SRSRAN_CP_NSYMB(cp), symbol_sz, symbol_sz + cp2)) { ERROR("Creating Guru inverse-DFT plan (%d)", slot); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } } #endif - srslte_dft_plan_set_mirror(&q->fft_plan, true); + srsran_dft_plan_set_mirror(&q->fft_plan, true); DEBUG("Init %s symbol_sz=%d, nof_symbols=%d, cp=%s, nof_re=%d, nof_guards=%d", - dir == SRSLTE_DFT_FORWARD ? "FFT" : "iFFT", + dir == SRSRAN_DFT_FORWARD ? "FFT" : "iFFT", q->cfg.symbol_sz, q->nof_symbols, - q->cfg.cp == SRSLTE_CP_NORM ? "Normal" : "Extended", + q->cfg.cp == SRSRAN_CP_NORM ? "Normal" : "Extended", q->nof_re, q->nof_guards); // MBSFN logic - if (sf_type == SRSLTE_SF_MBSFN) { + if (sf_type == SRSRAN_SF_MBSFN) { q->mbsfn_subframe = true; q->non_mbsfn_region = 2; // default set to 2 } else { @@ -195,26 +195,26 @@ static int ofdm_init_mbsfn_(srslte_ofdm_t* q, srslte_ofdm_cfg_t* cfg, srslte_dft } // Set other parameters - srslte_ofdm_set_freq_shift(q, q->cfg.freq_shift_f); - srslte_dft_plan_set_norm(&q->fft_plan, q->cfg.normalize); - srslte_dft_plan_set_dc(&q->fft_plan, (!cfg->keep_dc) && (!isnormal(q->cfg.freq_shift_f))); + srsran_ofdm_set_freq_shift(q, q->cfg.freq_shift_f); + srsran_dft_plan_set_norm(&q->fft_plan, q->cfg.normalize); + srsran_dft_plan_set_dc(&q->fft_plan, (!cfg->keep_dc) && (!isnormal(q->cfg.freq_shift_f))); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -void srslte_ofdm_set_non_mbsfn_region(srslte_ofdm_t* q, uint8_t non_mbsfn_region) +void srsran_ofdm_set_non_mbsfn_region(srsran_ofdm_t* q, uint8_t non_mbsfn_region) { q->non_mbsfn_region = non_mbsfn_region; } -void srslte_ofdm_free_(srslte_ofdm_t* q) +void srsran_ofdm_free_(srsran_ofdm_t* q) { - srslte_dft_plan_free(&q->fft_plan); + srsran_dft_plan_free(&q->fft_plan); #ifndef AVOID_GURU for (int slot = 0; slot < 2; slot++) { if (q->fft_plan_sf[slot].init_size) { - srslte_dft_plan_free(&q->fft_plan_sf[slot]); + srsran_dft_plan_free(&q->fft_plan_sf[slot]); } } #endif @@ -228,117 +228,117 @@ void srslte_ofdm_free_(srslte_ofdm_t* q) if (q->window_offset_buffer) { free(q->window_offset_buffer); } - SRSLTE_MEM_ZERO(q, srslte_ofdm_t, 1); + SRSRAN_MEM_ZERO(q, srsran_ofdm_t, 1); } -int srslte_ofdm_rx_init(srslte_ofdm_t* q, srslte_cp_t cp, cf_t* in_buffer, cf_t* out_buffer, uint32_t max_prb) +int srsran_ofdm_rx_init(srsran_ofdm_t* q, srsran_cp_t cp, cf_t* in_buffer, cf_t* out_buffer, uint32_t max_prb) { - bzero(q, sizeof(srslte_ofdm_t)); + bzero(q, sizeof(srsran_ofdm_t)); - srslte_ofdm_cfg_t cfg = {}; + srsran_ofdm_cfg_t cfg = {}; cfg.cp = cp; cfg.in_buffer = in_buffer; cfg.out_buffer = out_buffer; cfg.nof_prb = max_prb; - cfg.sf_type = SRSLTE_SF_NORM; + cfg.sf_type = SRSRAN_SF_NORM; - return ofdm_init_mbsfn_(q, &cfg, SRSLTE_DFT_FORWARD); + return ofdm_init_mbsfn_(q, &cfg, SRSRAN_DFT_FORWARD); } -int srslte_ofdm_rx_init_mbsfn(srslte_ofdm_t* q, srslte_cp_t cp, cf_t* in_buffer, cf_t* out_buffer, uint32_t max_prb) +int srsran_ofdm_rx_init_mbsfn(srsran_ofdm_t* q, srsran_cp_t cp, cf_t* in_buffer, cf_t* out_buffer, uint32_t max_prb) { - bzero(q, sizeof(srslte_ofdm_t)); + bzero(q, sizeof(srsran_ofdm_t)); - srslte_ofdm_cfg_t cfg = {}; + srsran_ofdm_cfg_t cfg = {}; cfg.cp = cp; cfg.in_buffer = in_buffer; cfg.out_buffer = out_buffer; cfg.nof_prb = max_prb; - cfg.sf_type = SRSLTE_SF_MBSFN; + cfg.sf_type = SRSRAN_SF_MBSFN; - return ofdm_init_mbsfn_(q, &cfg, SRSLTE_DFT_FORWARD); + return ofdm_init_mbsfn_(q, &cfg, SRSRAN_DFT_FORWARD); } -int srslte_ofdm_tx_init(srslte_ofdm_t* q, srslte_cp_t cp, cf_t* in_buffer, cf_t* out_buffer, uint32_t max_prb) +int srsran_ofdm_tx_init(srsran_ofdm_t* q, srsran_cp_t cp, cf_t* in_buffer, cf_t* out_buffer, uint32_t max_prb) { - bzero(q, sizeof(srslte_ofdm_t)); + bzero(q, sizeof(srsran_ofdm_t)); - srslte_ofdm_cfg_t cfg = {}; + srsran_ofdm_cfg_t cfg = {}; cfg.cp = cp; cfg.in_buffer = in_buffer; cfg.out_buffer = out_buffer; cfg.nof_prb = max_prb; - cfg.sf_type = SRSLTE_SF_NORM; + cfg.sf_type = SRSRAN_SF_NORM; - return ofdm_init_mbsfn_(q, &cfg, SRSLTE_DFT_BACKWARD); + return ofdm_init_mbsfn_(q, &cfg, SRSRAN_DFT_BACKWARD); } -int srslte_ofdm_tx_init_cfg(srslte_ofdm_t* q, srslte_ofdm_cfg_t* cfg) +int srsran_ofdm_tx_init_cfg(srsran_ofdm_t* q, srsran_ofdm_cfg_t* cfg) { - return ofdm_init_mbsfn_(q, cfg, SRSLTE_DFT_BACKWARD); + return ofdm_init_mbsfn_(q, cfg, SRSRAN_DFT_BACKWARD); } -int srslte_ofdm_rx_init_cfg(srslte_ofdm_t* q, srslte_ofdm_cfg_t* cfg) +int srsran_ofdm_rx_init_cfg(srsran_ofdm_t* q, srsran_ofdm_cfg_t* cfg) { - return ofdm_init_mbsfn_(q, cfg, SRSLTE_DFT_FORWARD); + return ofdm_init_mbsfn_(q, cfg, SRSRAN_DFT_FORWARD); } -int srslte_ofdm_tx_init_mbsfn(srslte_ofdm_t* q, srslte_cp_t cp, cf_t* in_buffer, cf_t* out_buffer, uint32_t nof_prb) +int srsran_ofdm_tx_init_mbsfn(srsran_ofdm_t* q, srsran_cp_t cp, cf_t* in_buffer, cf_t* out_buffer, uint32_t nof_prb) { - bzero(q, sizeof(srslte_ofdm_t)); + bzero(q, sizeof(srsran_ofdm_t)); - srslte_ofdm_cfg_t cfg = {}; + srsran_ofdm_cfg_t cfg = {}; cfg.cp = cp; cfg.in_buffer = in_buffer; cfg.out_buffer = out_buffer; cfg.nof_prb = nof_prb; - cfg.sf_type = SRSLTE_SF_MBSFN; + cfg.sf_type = SRSRAN_SF_MBSFN; - return ofdm_init_mbsfn_(q, &cfg, SRSLTE_DFT_BACKWARD); + return ofdm_init_mbsfn_(q, &cfg, SRSRAN_DFT_BACKWARD); } -int srslte_ofdm_rx_set_prb(srslte_ofdm_t* q, srslte_cp_t cp, uint32_t nof_prb) +int srsran_ofdm_rx_set_prb(srsran_ofdm_t* q, srsran_cp_t cp, uint32_t nof_prb) { - srslte_ofdm_cfg_t cfg = {}; + srsran_ofdm_cfg_t cfg = {}; cfg.cp = cp; cfg.nof_prb = nof_prb; - return ofdm_init_mbsfn_(q, &cfg, SRSLTE_DFT_FORWARD); + return ofdm_init_mbsfn_(q, &cfg, SRSRAN_DFT_FORWARD); } -int srslte_ofdm_tx_set_prb(srslte_ofdm_t* q, srslte_cp_t cp, uint32_t nof_prb) +int srsran_ofdm_tx_set_prb(srsran_ofdm_t* q, srsran_cp_t cp, uint32_t nof_prb) { - srslte_ofdm_cfg_t cfg = {}; + srsran_ofdm_cfg_t cfg = {}; cfg.cp = cp; cfg.nof_prb = nof_prb; - return ofdm_init_mbsfn_(q, &cfg, SRSLTE_DFT_BACKWARD); + return ofdm_init_mbsfn_(q, &cfg, SRSRAN_DFT_BACKWARD); } -void srslte_ofdm_rx_free(srslte_ofdm_t* q) +void srsran_ofdm_rx_free(srsran_ofdm_t* q) { - srslte_ofdm_free_(q); + srsran_ofdm_free_(q); } /* Shifts the signal after the iFFT or before the FFT. * Freq_shift is relative to inter-carrier spacing. * Caution: This function shall not be called during run-time */ -int srslte_ofdm_set_freq_shift(srslte_ofdm_t* q, float freq_shift) +int srsran_ofdm_set_freq_shift(srsran_ofdm_t* q, float freq_shift) { q->cfg.freq_shift_f = freq_shift; // Check if fft shift is required if (!isnormal(q->cfg.freq_shift_f)) { - srslte_dft_plan_set_dc(&q->fft_plan, true); - return SRSLTE_SUCCESS; + srsran_dft_plan_set_dc(&q->fft_plan, true); + return SRSRAN_SUCCESS; } uint32_t symbol_sz = q->cfg.symbol_sz; - srslte_cp_t cp = q->cfg.cp; + srsran_cp_t cp = q->cfg.cp; cf_t* ptr = q->shift_buffer; - for (uint32_t n = 0; n < SRSLTE_NOF_SLOTS_PER_SF; n++) { + for (uint32_t n = 0; n < SRSRAN_NOF_SLOTS_PER_SF; n++) { for (uint32_t i = 0; i < q->nof_symbols; i++) { - uint32_t cplen = SRSLTE_CP_ISNORM(cp) ? SRSLTE_CP_LEN_NORM(i, symbol_sz) : SRSLTE_CP_LEN_EXT(symbol_sz); + uint32_t cplen = SRSRAN_CP_ISNORM(cp) ? SRSRAN_CP_LEN_NORM(i, symbol_sz) : SRSRAN_CP_LEN_EXT(symbol_sz); for (uint32_t t = 0; t < symbol_sz + cplen; t++) { ptr[t] = cexpf(I * 2 * M_PI * ((float)t - (float)cplen) * freq_shift / symbol_sz); } @@ -347,25 +347,25 @@ int srslte_ofdm_set_freq_shift(srslte_ofdm_t* q, float freq_shift) } /* Disable DC carrier addition */ - srslte_dft_plan_set_dc(&q->fft_plan, false); + srsran_dft_plan_set_dc(&q->fft_plan, false); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -void srslte_ofdm_tx_free(srslte_ofdm_t* q) +void srsran_ofdm_tx_free(srsran_ofdm_t* q) { - srslte_ofdm_free_(q); + srsran_ofdm_free_(q); } -void srslte_ofdm_rx_slot_ng(srslte_ofdm_t* q, cf_t* input, cf_t* output) +void srsran_ofdm_rx_slot_ng(srsran_ofdm_t* q, cf_t* input, cf_t* output) { uint32_t symbol_sz = q->cfg.symbol_sz; - srslte_cp_t cp = q->cfg.cp; + srsran_cp_t cp = q->cfg.cp; for (uint32_t i = 0; i < q->nof_symbols; i++) { - input += SRSLTE_CP_ISNORM(cp) ? SRSLTE_CP_LEN_NORM(i, symbol_sz) : SRSLTE_CP_LEN_EXT(symbol_sz); + input += SRSRAN_CP_ISNORM(cp) ? SRSRAN_CP_LEN_NORM(i, symbol_sz) : SRSRAN_CP_LEN_EXT(symbol_sz); input -= q->window_offset_n; - srslte_dft_run_c(&q->fft_plan, input, q->tmp); + srsran_dft_run_c(&q->fft_plan, input, q->tmp); memcpy(output, &q->tmp[q->nof_guards], q->nof_re * sizeof(cf_t)); input += symbol_sz; output += q->nof_re; @@ -375,10 +375,10 @@ void srslte_ofdm_rx_slot_ng(srslte_ofdm_t* q, cf_t* input, cf_t* output) /* Transforms input samples into output OFDM symbols. * Performs FFT on a each symbol and removes CP. */ -static void ofdm_rx_slot(srslte_ofdm_t* q, int slot_in_sf) +static void ofdm_rx_slot(srsran_ofdm_t* q, int slot_in_sf) { #ifdef AVOID_GURU - srslte_ofdm_rx_slot_ng( + srsran_ofdm_rx_slot_ng( q, q->cfg.in_buffer + slot_in_sf * q->slot_sz, q->cfg.out_buffer + slot_in_sf * q->nof_re * q->nof_symbols); #else uint32_t nof_symbols = q->nof_symbols; @@ -389,12 +389,12 @@ static void ofdm_rx_slot(srslte_ofdm_t* q, int slot_in_sf) cf_t* tmp = q->tmp; uint32_t dc = (q->fft_plan.dc) ? 1 : 0; - srslte_dft_run_guru_c(&q->fft_plan_sf[slot_in_sf]); + srsran_dft_run_guru_c(&q->fft_plan_sf[slot_in_sf]); for (int i = 0; i < q->nof_symbols; i++) { // Apply frequency domain window offset if (q->window_offset_n) { - srslte_vec_prod_ccc(tmp, q->window_offset_buffer, tmp, symbol_sz); + srsran_vec_prod_ccc(tmp, q->window_offset_buffer, tmp, symbol_sz); } // Perform FFT shift @@ -403,7 +403,7 @@ static void ofdm_rx_slot(srslte_ofdm_t* q, int slot_in_sf) // Normalize output if (q->fft_plan.norm) { - srslte_vec_sc_prod_cfc(output, norm, output, nof_re); + srsran_vec_sc_prod_cfc(output, norm, output, nof_re); } tmp += symbol_sz; @@ -412,28 +412,28 @@ static void ofdm_rx_slot(srslte_ofdm_t* q, int slot_in_sf) #endif } -static void ofdm_rx_slot_mbsfn(srslte_ofdm_t* q, cf_t* input, cf_t* output) +static void ofdm_rx_slot_mbsfn(srsran_ofdm_t* q, cf_t* input, cf_t* output) { uint32_t i; for (i = 0; i < q->nof_symbols_mbsfn; i++) { if (i == q->non_mbsfn_region) { - input += SRSLTE_NON_MBSFN_REGION_GUARD_LENGTH(q->non_mbsfn_region, q->cfg.symbol_sz); + input += SRSRAN_NON_MBSFN_REGION_GUARD_LENGTH(q->non_mbsfn_region, q->cfg.symbol_sz); } - input += (i >= q->non_mbsfn_region) ? SRSLTE_CP_LEN_EXT(q->cfg.symbol_sz) : SRSLTE_CP_LEN_NORM(i, q->cfg.symbol_sz); - srslte_dft_run_c(&q->fft_plan, input, q->tmp); + input += (i >= q->non_mbsfn_region) ? SRSRAN_CP_LEN_EXT(q->cfg.symbol_sz) : SRSRAN_CP_LEN_NORM(i, q->cfg.symbol_sz); + srsran_dft_run_c(&q->fft_plan, input, q->tmp); memcpy(output, &q->tmp[q->nof_guards], q->nof_re * sizeof(cf_t)); input += q->cfg.symbol_sz; output += q->nof_re; } } -void srslte_ofdm_rx_slot_zerocopy(srslte_ofdm_t* q, cf_t* input, cf_t* output) +void srsran_ofdm_rx_slot_zerocopy(srsran_ofdm_t* q, cf_t* input, cf_t* output) { uint32_t i; for (i = 0; i < q->nof_symbols; i++) { input += - SRSLTE_CP_ISNORM(q->cfg.cp) ? SRSLTE_CP_LEN_NORM(i, q->cfg.symbol_sz) : SRSLTE_CP_LEN_EXT(q->cfg.symbol_sz); - srslte_dft_run_c_zerocopy(&q->fft_plan, input, q->tmp); + SRSRAN_CP_ISNORM(q->cfg.cp) ? SRSRAN_CP_LEN_NORM(i, q->cfg.symbol_sz) : SRSRAN_CP_LEN_EXT(q->cfg.symbol_sz); + srsran_dft_run_c_zerocopy(&q->fft_plan, input, q->tmp); memcpy(output, &q->tmp[q->cfg.symbol_sz / 2 + q->nof_guards], sizeof(cf_t) * q->nof_re / 2); memcpy(&output[q->nof_re / 2], &q->tmp[1], sizeof(cf_t) * q->nof_re / 2); input += q->cfg.symbol_sz; @@ -441,13 +441,13 @@ void srslte_ofdm_rx_slot_zerocopy(srslte_ofdm_t* q, cf_t* input, cf_t* output) } } -void srslte_ofdm_rx_sf(srslte_ofdm_t* q) +void srsran_ofdm_rx_sf(srsran_ofdm_t* q) { if (isnormal(q->cfg.freq_shift_f)) { - srslte_vec_prod_ccc(q->cfg.in_buffer, q->shift_buffer, q->cfg.in_buffer, q->sf_sz); + srsran_vec_prod_ccc(q->cfg.in_buffer, q->shift_buffer, q->cfg.in_buffer, q->sf_sz); } if (!q->mbsfn_subframe) { - for (uint32_t n = 0; n < SRSLTE_NOF_SLOTS_PER_SF; n++) { + for (uint32_t n = 0; n < SRSRAN_NOF_SLOTS_PER_SF; n++) { ofdm_rx_slot(q, n); } } else { @@ -456,15 +456,15 @@ void srslte_ofdm_rx_sf(srslte_ofdm_t* q) } } -void srslte_ofdm_rx_sf_ng(srslte_ofdm_t* q, cf_t* input, cf_t* output) +void srsran_ofdm_rx_sf_ng(srsran_ofdm_t* q, cf_t* input, cf_t* output) { uint32_t n; if (isnormal(q->cfg.freq_shift_f)) { - srslte_vec_prod_ccc(input, q->shift_buffer, input, q->sf_sz); + srsran_vec_prod_ccc(input, q->shift_buffer, input, q->sf_sz); } if (!q->mbsfn_subframe) { - for (n = 0; n < SRSLTE_NOF_SLOTS_PER_SF; n++) { - srslte_ofdm_rx_slot_ng(q, &input[n * q->slot_sz], &output[n * q->nof_re * q->nof_symbols]); + for (n = 0; n < SRSRAN_NOF_SLOTS_PER_SF; n++) { + srsran_ofdm_rx_slot_ng(q, &input[n * q->slot_sz], &output[n * q->nof_re * q->nof_symbols]); } } else { ofdm_rx_slot_mbsfn(q, q->cfg.in_buffer, q->cfg.out_buffer); @@ -475,19 +475,19 @@ void srslte_ofdm_rx_sf_ng(srslte_ofdm_t* q, cf_t* input, cf_t* output) /* Transforms input OFDM symbols into output samples. * Performs FFT on a each symbol and adds CP. */ -static void ofdm_tx_slot(srslte_ofdm_t* q, int slot_in_sf) +static void ofdm_tx_slot(srsran_ofdm_t* q, int slot_in_sf) { uint32_t symbol_sz = q->cfg.symbol_sz; - srslte_cp_t cp = q->cfg.cp; + srsran_cp_t cp = q->cfg.cp; cf_t* input = q->cfg.in_buffer + slot_in_sf * q->nof_re * q->nof_symbols; cf_t* output = q->cfg.out_buffer + slot_in_sf * q->slot_sz; #ifdef AVOID_GURU for (int i = 0; i < q->nof_symbols; i++) { - int cp_len = SRSLTE_CP_ISNORM(cp) ? SRSLTE_CP_LEN_NORM(i, symbol_sz) : SRSLTE_CP_LEN_EXT(symbol_sz); + int cp_len = SRSRAN_CP_ISNORM(cp) ? SRSRAN_CP_LEN_NORM(i, symbol_sz) : SRSRAN_CP_LEN_EXT(symbol_sz); memcpy(&q->tmp[q->nof_guards], input, q->nof_re * sizeof(cf_t)); - srslte_dft_run_c(&q->fft_plan, q->tmp, &output[cp_len]); + srsran_dft_run_c(&q->fft_plan, q->tmp, &output[cp_len]); input += q->nof_re; /* add CP */ memcpy(output, &output[symbol_sz], cp_len * sizeof(cf_t)); @@ -510,13 +510,13 @@ static void ofdm_tx_slot(srslte_ofdm_t* q, int slot_in_sf) tmp += symbol_sz; } - srslte_dft_run_guru_c(&q->fft_plan_sf[slot_in_sf]); + srsran_dft_run_guru_c(&q->fft_plan_sf[slot_in_sf]); for (int i = 0; i < nof_symbols; i++) { - int cp_len = SRSLTE_CP_ISNORM(cp) ? SRSLTE_CP_LEN_NORM(i, symbol_sz) : SRSLTE_CP_LEN_EXT(symbol_sz); + int cp_len = SRSRAN_CP_ISNORM(cp) ? SRSRAN_CP_LEN_NORM(i, symbol_sz) : SRSRAN_CP_LEN_EXT(symbol_sz); if (q->fft_plan.norm) { - srslte_vec_sc_prod_cfc(&output[cp_len], norm, &output[cp_len], symbol_sz); + srsran_vec_sc_prod_cfc(&output[cp_len], norm, &output[cp_len], symbol_sz); } /* add CP */ @@ -526,14 +526,14 @@ static void ofdm_tx_slot(srslte_ofdm_t* q, int slot_in_sf) #endif } -void ofdm_tx_slot_mbsfn(srslte_ofdm_t* q, cf_t* input, cf_t* output) +void ofdm_tx_slot_mbsfn(srsran_ofdm_t* q, cf_t* input, cf_t* output) { uint32_t symbol_sz = q->cfg.symbol_sz; for (uint32_t i = 0; i < q->nof_symbols_mbsfn; i++) { - int cp_len = (i > (q->non_mbsfn_region - 1)) ? SRSLTE_CP_LEN_EXT(symbol_sz) : SRSLTE_CP_LEN_NORM(i, symbol_sz); + int cp_len = (i > (q->non_mbsfn_region - 1)) ? SRSRAN_CP_LEN_EXT(symbol_sz) : SRSRAN_CP_LEN_NORM(i, symbol_sz); memcpy(&q->tmp[q->nof_guards], input, q->nof_re * sizeof(cf_t)); - srslte_dft_run_c(&q->fft_plan, q->tmp, &output[cp_len]); + srsran_dft_run_c(&q->fft_plan, q->tmp, &output[cp_len]); input += q->nof_re; /* add CP */ memcpy(output, &output[symbol_sz], cp_len * sizeof(cf_t)); @@ -541,20 +541,20 @@ void ofdm_tx_slot_mbsfn(srslte_ofdm_t* q, cf_t* input, cf_t* output) /*skip the small section between the non mbms region and the mbms region*/ if (i == (q->non_mbsfn_region - 1)) - output += SRSLTE_NON_MBSFN_REGION_GUARD_LENGTH(q->non_mbsfn_region, symbol_sz); + output += SRSRAN_NON_MBSFN_REGION_GUARD_LENGTH(q->non_mbsfn_region, symbol_sz); } } -void srslte_ofdm_set_normalize(srslte_ofdm_t* q, bool normalize_enable) +void srsran_ofdm_set_normalize(srsran_ofdm_t* q, bool normalize_enable) { - srslte_dft_plan_set_norm(&q->fft_plan, normalize_enable); + srsran_dft_plan_set_norm(&q->fft_plan, normalize_enable); } -void srslte_ofdm_tx_sf(srslte_ofdm_t* q) +void srsran_ofdm_tx_sf(srsran_ofdm_t* q) { uint32_t n; if (!q->mbsfn_subframe) { - for (n = 0; n < SRSLTE_NOF_SLOTS_PER_SF; n++) { + for (n = 0; n < SRSRAN_NOF_SLOTS_PER_SF; n++) { ofdm_tx_slot(q, n); } } else { @@ -562,6 +562,6 @@ void srslte_ofdm_tx_sf(srslte_ofdm_t* q) ofdm_tx_slot(q, 1); } if (isnormal(q->cfg.freq_shift_f)) { - srslte_vec_prod_ccc(q->cfg.out_buffer, q->shift_buffer, q->cfg.out_buffer, q->sf_sz); + srsran_vec_prod_ccc(q->cfg.out_buffer, q->shift_buffer, q->cfg.out_buffer, q->sf_sz); } } diff --git a/lib/src/phy/dft/test/CMakeLists.txt b/lib/src/phy/dft/test/CMakeLists.txt index f8f67d872..9ac8b2d57 100644 --- a/lib/src/phy/dft/test/CMakeLists.txt +++ b/lib/src/phy/dft/test/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -11,7 +11,7 @@ ######################################################################## add_executable(ofdm_test ofdm_test.c) -target_link_libraries(ofdm_test srslte_phy) +target_link_libraries(ofdm_test srsran_phy) add_test(ofdm_normal ofdm_test -r 1) add_test(ofdm_extended ofdm_test -e -r 1) diff --git a/lib/src/phy/dft/test/ofdm_test.c b/lib/src/phy/dft/test/ofdm_test.c index f80ef75e0..2e993008f 100644 --- a/lib/src/phy/dft/test/ofdm_test.c +++ b/lib/src/phy/dft/test/ofdm_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -17,11 +17,11 @@ #include #include -#include "srslte/phy/utils/random.h" -#include "srslte/srslte.h" +#include "srsran/phy/utils/random.h" +#include "srsran/srsran.h" static int nof_prb = -1; -static srslte_cp_t cp = SRSLTE_CP_NORM; +static srsran_cp_t cp = SRSRAN_CP_NORM; static int nof_repetitions = 1; static float rx_window_offset = 0.5f; static float freq_shift_f = 0.0f; @@ -60,16 +60,16 @@ static void parse_args(int argc, char** argv) force_symbol_sz = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'e': - cp = SRSLTE_CP_EXT; + cp = SRSRAN_CP_EXT; break; case 'r': nof_repetitions = (int)strtol(argv[optind], NULL, 10); break; case 'o': - rx_window_offset = SRSLTE_MIN(1.0f, SRSLTE_MAX(0.0f, strtof(argv[optind], NULL))); + rx_window_offset = SRSRAN_MIN(1.0f, SRSRAN_MAX(0.0f, strtof(argv[optind], NULL))); break; case 's': - freq_shift_f = SRSLTE_MIN(1.0f, SRSLTE_MAX(0.0f, strtof(argv[optind], NULL))); + freq_shift_f = SRSRAN_MIN(1.0f, SRSRAN_MAX(0.0f, strtof(argv[optind], NULL))); break; default: usage(argv[0]); @@ -80,9 +80,9 @@ static void parse_args(int argc, char** argv) int main(int argc, char** argv) { - srslte_random_t random_gen = srslte_random_init(0); + srsran_random_t random_gen = srsran_random_init(0); struct timeval start, end; - srslte_ofdm_t fft = {}, ifft = {}; + srsran_ofdm_t fft = {}, ifft = {}; cf_t * input, *outfft, *outifft; float mse; uint32_t n_prb, max_prb; @@ -91,29 +91,29 @@ int main(int argc, char** argv) if (nof_prb == -1) { n_prb = 6; - max_prb = SRSLTE_MAX_PRB; + max_prb = SRSRAN_MAX_PRB; } else { n_prb = (uint32_t)nof_prb; max_prb = (uint32_t)nof_prb; } while (n_prb <= max_prb) { - uint32_t symbol_sz = (force_symbol_sz) ? force_symbol_sz : (uint32_t)srslte_symbol_sz(n_prb); - uint32_t n_re = SRSLTE_CP_NSYMB(cp) * n_prb * SRSLTE_NRE * SRSLTE_NOF_SLOTS_PER_SF; - uint32_t sf_len = SRSLTE_SF_LEN(symbol_sz); + uint32_t symbol_sz = (force_symbol_sz) ? force_symbol_sz : (uint32_t)srsran_symbol_sz(n_prb); + uint32_t n_re = SRSRAN_CP_NSYMB(cp) * n_prb * SRSRAN_NRE * SRSRAN_NOF_SLOTS_PER_SF; + uint32_t sf_len = SRSRAN_SF_LEN(symbol_sz); printf("Running test for %d PRB, %d RE... ", n_prb, n_re); fflush(stdout); - input = srslte_vec_cf_malloc(n_re); - outfft = srslte_vec_cf_malloc(n_re); - outifft = srslte_vec_cf_malloc(sf_len); + input = srsran_vec_cf_malloc(n_re); + outfft = srsran_vec_cf_malloc(n_re); + outifft = srsran_vec_cf_malloc(sf_len); if (!input || !outfft || !outifft) { perror("malloc"); exit(-1); } - srslte_vec_cf_zero(outifft, sf_len); + srsran_vec_cf_zero(outifft, sf_len); - srslte_ofdm_cfg_t ofdm_cfg = {}; + srsran_ofdm_cfg_t ofdm_cfg = {}; ofdm_cfg.cp = cp; ofdm_cfg.in_buffer = input; ofdm_cfg.out_buffer = outifft; @@ -121,7 +121,7 @@ int main(int argc, char** argv) ofdm_cfg.symbol_sz = symbol_sz; ofdm_cfg.freq_shift_f = freq_shift_f; ofdm_cfg.normalize = true; - if (srslte_ofdm_tx_init_cfg(&ifft, &ofdm_cfg)) { + if (srsran_ofdm_tx_init_cfg(&ifft, &ofdm_cfg)) { ERROR("Error initializing iFFT"); exit(-1); } @@ -130,7 +130,7 @@ int main(int argc, char** argv) ofdm_cfg.out_buffer = outfft; ofdm_cfg.rx_window_offset = rx_window_offset; ofdm_cfg.freq_shift_f = -freq_shift_f; - if (srslte_ofdm_rx_init_cfg(&fft, &ofdm_cfg)) { + if (srsran_ofdm_rx_init_cfg(&fft, &ofdm_cfg)) { ERROR("Error initializing FFT"); exit(-1); } @@ -140,12 +140,12 @@ int main(int argc, char** argv) } // Generate Random data - srslte_random_uniform_complex_dist_vector(random_gen, input, n_re, -1.0f, +1.0f); + srsran_random_uniform_complex_dist_vector(random_gen, input, n_re, -1.0f, +1.0f); // Execute Tx gettimeofday(&start, NULL); for (uint32_t i = 0; i < nof_repetitions; i++) { - srslte_ofdm_tx_sf(&ifft); + srsran_ofdm_tx_sf(&ifft); } gettimeofday(&end, NULL); printf(" Tx@%.1fMsps", (float)(sf_len * nof_repetitions) / elapsed_us(&start, &end)); @@ -153,14 +153,14 @@ int main(int argc, char** argv) // Execute Rx gettimeofday(&start, NULL); for (uint32_t i = 0; i < nof_repetitions; i++) { - srslte_ofdm_rx_sf(&fft); + srsran_ofdm_rx_sf(&fft); } gettimeofday(&end, NULL); printf(" Rx@%.1fMsps", (double)(sf_len * nof_repetitions) / elapsed_us(&start, &end)); // compute Mean Square Error - srslte_vec_sub_ccc(input, outfft, outfft, n_re); - mse = sqrtf(srslte_vec_avg_power_cf(outfft, n_re)); + srsran_vec_sub_ccc(input, outfft, outfft, n_re); + mse = sqrtf(srsran_vec_avg_power_cf(outfft, n_re)); printf(" MSE=%.6f\n", mse); @@ -169,8 +169,8 @@ int main(int argc, char** argv) exit(-1); } - srslte_ofdm_rx_free(&fft); - srslte_ofdm_tx_free(&ifft); + srsran_ofdm_rx_free(&fft); + srsran_ofdm_tx_free(&ifft); free(input); free(outfft); @@ -179,7 +179,7 @@ int main(int argc, char** argv) n_prb++; } - srslte_random_free(random_gen); + srsran_random_free(random_gen); exit(0); } diff --git a/lib/src/phy/enb/CMakeLists.txt b/lib/src/phy/enb/CMakeLists.txt index c9548dae3..c33967548 100644 --- a/lib/src/phy/enb/CMakeLists.txt +++ b/lib/src/phy/enb/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -7,4 +7,4 @@ # file(GLOB SOURCES "*.c") -add_library(srslte_enb OBJECT ${SOURCES}) +add_library(srsran_enb OBJECT ${SOURCES}) diff --git a/lib/src/phy/enb/enb_dl.c b/lib/src/phy/enb/enb_dl.c index d89799f6b..a6bb4160f 100644 --- a/lib/src/phy/enb/enb_dl.c +++ b/lib/src/phy/enb/enb_dl.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,47 +10,47 @@ * */ -#include "srslte/phy/enb/enb_dl.h" +#include "srsran/phy/enb/enb_dl.h" -#include "srslte/srslte.h" +#include "srsran/srsran.h" #include #include #include -#define CURRENT_FFTSIZE srslte_symbol_sz(q->cell.nof_prb) -#define CURRENT_SFLEN_RE SRSLTE_NOF_RE(q->cell) +#define CURRENT_FFTSIZE srsran_symbol_sz(q->cell.nof_prb) +#define CURRENT_SFLEN_RE SRSRAN_NOF_RE(q->cell) static float enb_dl_get_norm_factor(uint32_t nof_prb) { return 0.05f / sqrtf(nof_prb); } -int srslte_enb_dl_init(srslte_enb_dl_t* q, cf_t* out_buffer[SRSLTE_MAX_PORTS], uint32_t max_prb) +int srsran_enb_dl_init(srsran_enb_dl_t* q, cf_t* out_buffer[SRSRAN_MAX_PORTS], uint32_t max_prb) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL) { - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; - bzero(q, sizeof(srslte_enb_dl_t)); + bzero(q, sizeof(srsran_enb_dl_t)); - for (int i = 0; i < SRSLTE_MAX_PORTS; i++) { - q->sf_symbols[i] = srslte_vec_cf_malloc(SRSLTE_SF_LEN_RE(max_prb, SRSLTE_CP_NORM)); + for (int i = 0; i < SRSRAN_MAX_PORTS; i++) { + q->sf_symbols[i] = srsran_vec_cf_malloc(SRSRAN_SF_LEN_RE(max_prb, SRSRAN_CP_NORM)); if (!q->sf_symbols[i]) { perror("malloc"); goto clean_exit; } } - srslte_ofdm_cfg_t ofdm_cfg = {}; + srsran_ofdm_cfg_t ofdm_cfg = {}; ofdm_cfg.nof_prb = max_prb; - ofdm_cfg.cp = SRSLTE_CP_NORM; + ofdm_cfg.cp = SRSRAN_CP_NORM; ofdm_cfg.normalize = false; - for (int i = 0; i < SRSLTE_MAX_PORTS; i++) { + for (int i = 0; i < SRSRAN_MAX_PORTS; i++) { ofdm_cfg.in_buffer = q->sf_symbols[i]; ofdm_cfg.out_buffer = out_buffer[i]; - ofdm_cfg.sf_type = SRSLTE_SF_NORM; - if (srslte_ofdm_tx_init_cfg(&q->ifft[i], &ofdm_cfg)) { + ofdm_cfg.sf_type = SRSRAN_SF_NORM; + if (srsran_ofdm_tx_init_cfg(&q->ifft[i], &ofdm_cfg)) { ERROR("Error initiating FFT (%d)", i); goto clean_exit; } @@ -58,164 +58,164 @@ int srslte_enb_dl_init(srslte_enb_dl_t* q, cf_t* out_buffer[SRSLTE_MAX_PORTS], u ofdm_cfg.in_buffer = q->sf_symbols[0]; ofdm_cfg.out_buffer = out_buffer[0]; - ofdm_cfg.sf_type = SRSLTE_SF_MBSFN; - if (srslte_ofdm_tx_init_cfg(&q->ifft_mbsfn, &ofdm_cfg)) { + ofdm_cfg.sf_type = SRSRAN_SF_MBSFN; + if (srsran_ofdm_tx_init_cfg(&q->ifft_mbsfn, &ofdm_cfg)) { ERROR("Error initiating FFT"); goto clean_exit; } - if (srslte_pbch_init(&q->pbch)) { + if (srsran_pbch_init(&q->pbch)) { ERROR("Error creating PBCH object"); goto clean_exit; } - if (srslte_pcfich_init(&q->pcfich, 0)) { + if (srsran_pcfich_init(&q->pcfich, 0)) { ERROR("Error creating PCFICH object"); goto clean_exit; } - if (srslte_phich_init(&q->phich, 0)) { + if (srsran_phich_init(&q->phich, 0)) { ERROR("Error creating PHICH object"); goto clean_exit; } int mbsfn_area_id = 1; - if (srslte_pmch_init(&q->pmch, max_prb, 1)) { + if (srsran_pmch_init(&q->pmch, max_prb, 1)) { ERROR("Error creating PMCH object"); } - srslte_pmch_set_area_id(&q->pmch, mbsfn_area_id); + srsran_pmch_set_area_id(&q->pmch, mbsfn_area_id); - if (srslte_pdcch_init_enb(&q->pdcch, max_prb)) { + if (srsran_pdcch_init_enb(&q->pdcch, max_prb)) { ERROR("Error creating PDCCH object"); goto clean_exit; } - if (srslte_pdsch_init_enb(&q->pdsch, max_prb)) { + if (srsran_pdsch_init_enb(&q->pdsch, max_prb)) { ERROR("Error creating PDSCH object"); goto clean_exit; } - if (srslte_refsignal_cs_init(&q->csr_signal, max_prb)) { + if (srsran_refsignal_cs_init(&q->csr_signal, max_prb)) { ERROR("Error initializing CSR signal (%d)", ret); goto clean_exit; } - if (srslte_refsignal_mbsfn_init(&q->mbsfnr_signal, max_prb)) { + if (srsran_refsignal_mbsfn_init(&q->mbsfnr_signal, max_prb)) { ERROR("Error initializing CSR signal (%d)", ret); goto clean_exit; } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } else { ERROR("Invalid parameters"); } clean_exit: - if (ret == SRSLTE_ERROR) { - srslte_enb_dl_free(q); + if (ret == SRSRAN_ERROR) { + srsran_enb_dl_free(q); } return ret; } -void srslte_enb_dl_free(srslte_enb_dl_t* q) +void srsran_enb_dl_free(srsran_enb_dl_t* q) { if (q) { - for (int i = 0; i < SRSLTE_MAX_PORTS; i++) { - srslte_ofdm_tx_free(&q->ifft[i]); + for (int i = 0; i < SRSRAN_MAX_PORTS; i++) { + srsran_ofdm_tx_free(&q->ifft[i]); } - srslte_ofdm_tx_free(&q->ifft_mbsfn); - srslte_regs_free(&q->regs); - srslte_pbch_free(&q->pbch); - srslte_pcfich_free(&q->pcfich); - srslte_phich_free(&q->phich); - srslte_pdcch_free(&q->pdcch); - srslte_pdsch_free(&q->pdsch); - srslte_pmch_free(&q->pmch); - srslte_refsignal_free(&q->csr_signal); - srslte_refsignal_free(&q->mbsfnr_signal); - for (int i = 0; i < SRSLTE_MAX_PORTS; i++) { + srsran_ofdm_tx_free(&q->ifft_mbsfn); + srsran_regs_free(&q->regs); + srsran_pbch_free(&q->pbch); + srsran_pcfich_free(&q->pcfich); + srsran_phich_free(&q->phich); + srsran_pdcch_free(&q->pdcch); + srsran_pdsch_free(&q->pdsch); + srsran_pmch_free(&q->pmch); + srsran_refsignal_free(&q->csr_signal); + srsran_refsignal_free(&q->mbsfnr_signal); + for (int i = 0; i < SRSRAN_MAX_PORTS; i++) { if (q->sf_symbols[i]) { free(q->sf_symbols[i]); } } - bzero(q, sizeof(srslte_enb_dl_t)); + bzero(q, sizeof(srsran_enb_dl_t)); } } -int srslte_enb_dl_set_cell(srslte_enb_dl_t* q, srslte_cell_t cell) +int srsran_enb_dl_set_cell(srsran_enb_dl_t* q, srsran_cell_t cell) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; - if (q != NULL && srslte_cell_isvalid(&cell)) { + if (q != NULL && srsran_cell_isvalid(&cell)) { if (q->cell.id != cell.id || q->cell.nof_prb == 0) { if (q->cell.nof_prb != 0) { - srslte_regs_free(&q->regs); + srsran_regs_free(&q->regs); } q->cell = cell; - if (srslte_regs_init(&q->regs, q->cell)) { + if (srsran_regs_init(&q->regs, q->cell)) { ERROR("Error resizing REGs"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } for (int i = 0; i < q->cell.nof_ports; i++) { - if (srslte_ofdm_tx_set_prb(&q->ifft[i], q->cell.cp, q->cell.nof_prb)) { + if (srsran_ofdm_tx_set_prb(&q->ifft[i], q->cell.cp, q->cell.nof_prb)) { ERROR("Error re-planning iFFT (%d)", i); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } - if (srslte_ofdm_tx_set_prb(&q->ifft_mbsfn, SRSLTE_CP_EXT, q->cell.nof_prb)) { + if (srsran_ofdm_tx_set_prb(&q->ifft_mbsfn, SRSRAN_CP_EXT, q->cell.nof_prb)) { ERROR("Error re-planning ifft_mbsfn"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - srslte_ofdm_set_non_mbsfn_region(&q->ifft_mbsfn, 2); + srsran_ofdm_set_non_mbsfn_region(&q->ifft_mbsfn, 2); - if (srslte_pbch_set_cell(&q->pbch, q->cell)) { + if (srsran_pbch_set_cell(&q->pbch, q->cell)) { ERROR("Error creating PBCH object"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_pcfich_set_cell(&q->pcfich, &q->regs, q->cell)) { + if (srsran_pcfich_set_cell(&q->pcfich, &q->regs, q->cell)) { ERROR("Error creating PCFICH object"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_phich_set_cell(&q->phich, &q->regs, q->cell)) { + if (srsran_phich_set_cell(&q->phich, &q->regs, q->cell)) { ERROR("Error creating PHICH object"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_pdcch_set_cell(&q->pdcch, &q->regs, q->cell)) { + if (srsran_pdcch_set_cell(&q->pdcch, &q->regs, q->cell)) { ERROR("Error creating PDCCH object"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_pdsch_set_cell(&q->pdsch, q->cell)) { + if (srsran_pdsch_set_cell(&q->pdsch, q->cell)) { ERROR("Error creating PDSCH object"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_pmch_set_cell(&q->pmch, q->cell)) { + if (srsran_pmch_set_cell(&q->pmch, q->cell)) { ERROR("Error creating PMCH object"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_refsignal_cs_set_cell(&q->csr_signal, q->cell)) { + if (srsran_refsignal_cs_set_cell(&q->csr_signal, q->cell)) { ERROR("Error initializing CSR signal (%d)", ret); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } int mbsfn_area_id = 1; - if (srslte_refsignal_mbsfn_set_cell(&q->mbsfnr_signal, q->cell, mbsfn_area_id)) { + if (srsran_refsignal_mbsfn_set_cell(&q->mbsfnr_signal, q->cell, mbsfn_area_id)) { ERROR("Error initializing MBSFNR signal (%d)", ret); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } /* Generate PSS/SSS signals */ - srslte_pss_generate(q->pss_signal, cell.id % 3); - srslte_sss_generate(q->sss_signal0, q->sss_signal5, cell.id); + srsran_pss_generate(q->pss_signal, cell.id % 3); + srsran_sss_generate(q->sss_signal0, q->sss_signal5, cell.id); // Calculate common DCI locations for (int32_t cfi = 1; cfi <= 3; cfi++) { - q->nof_common_locations[SRSLTE_CFI_IDX(cfi)] = srslte_pdcch_common_locations( - &q->pdcch, q->common_locations[SRSLTE_CFI_IDX(cfi)], SRSLTE_MAX_CANDIDATES_COM, cfi); + q->nof_common_locations[SRSRAN_CFI_IDX(cfi)] = srsran_pdcch_common_locations( + &q->pdcch, q->common_locations[SRSRAN_CFI_IDX(cfi)], SRSRAN_MAX_CANDIDATES_COM, cfi); } } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } else { ERROR("Invalid cell properties: Id=%d, Ports=%d, PRBs=%d", cell.id, cell.nof_ports, cell.nof_prb); @@ -224,10 +224,10 @@ int srslte_enb_dl_set_cell(srslte_enb_dl_t* q, srslte_cell_t cell) } #ifdef resolve -void srslte_enb_dl_apply_power_allocation(srslte_enb_dl_t* q) +void srsran_enb_dl_apply_power_allocation(srsran_enb_dl_t* q) { - uint32_t nof_symbols_slot = SRSLTE_CP_NSYMB(q->cell.cp); - uint32_t nof_re_symbol = SRSLTE_NRE * q->cell.nof_prb; + uint32_t nof_symbols_slot = SRSRAN_CP_NSYMB(q->cell.cp); + uint32_t nof_re_symbol = SRSRAN_NRE * q->cell.nof_prb; if (q->rho_b != 0.0f && q->rho_b != 1.0f) { float scaling = q->rho_b; @@ -235,27 +235,27 @@ void srslte_enb_dl_apply_power_allocation(srslte_enb_dl_t* q) for (uint32_t j = 0; j < 2; j++) { cf_t* ptr; ptr = q->sf_symbols[i] + nof_re_symbol * (j * nof_symbols_slot + 0); - srslte_vec_sc_prod_cfc(ptr, scaling, ptr, nof_re_symbol); - if (q->cell.cp == SRSLTE_CP_NORM) { + srsran_vec_sc_prod_cfc(ptr, scaling, ptr, nof_re_symbol); + if (q->cell.cp == SRSRAN_CP_NORM) { ptr = q->sf_symbols[i] + nof_re_symbol * (j * nof_symbols_slot + 4); - srslte_vec_sc_prod_cfc(ptr, scaling, ptr, nof_re_symbol); + srsran_vec_sc_prod_cfc(ptr, scaling, ptr, nof_re_symbol); } else { ptr = q->sf_symbols[i] + nof_re_symbol * (j * nof_symbols_slot + 3); - srslte_vec_sc_prod_cfc(ptr, scaling, ptr, nof_re_symbol); + srsran_vec_sc_prod_cfc(ptr, scaling, ptr, nof_re_symbol); } if (q->cell.nof_ports == 4) { ptr = q->sf_symbols[i] + nof_re_symbol * (j * nof_symbols_slot + 1); - srslte_vec_sc_prod_cfc(ptr, scaling, ptr, nof_re_symbol); + srsran_vec_sc_prod_cfc(ptr, scaling, ptr, nof_re_symbol); } } } } } -void srslte_enb_dl_prepare_power_allocation(srslte_enb_dl_t* q) +void srsran_enb_dl_prepare_power_allocation(srsran_enb_dl_t* q) { - uint32_t nof_symbols_slot = SRSLTE_CP_NSYMB(q->cell.cp); - uint32_t nof_re_symbol = SRSLTE_NRE * q->cell.nof_prb; + uint32_t nof_symbols_slot = SRSRAN_CP_NSYMB(q->cell.cp); + uint32_t nof_re_symbol = SRSRAN_NRE * q->cell.nof_prb; if (q->rho_b != 0.0f && q->rho_b != 1.0f) { float scaling = 1.0f / q->rho_b; @@ -263,17 +263,17 @@ void srslte_enb_dl_prepare_power_allocation(srslte_enb_dl_t* q) for (uint32_t j = 0; j < 2; j++) { cf_t* ptr; ptr = q->sf_symbols[i] + nof_re_symbol * (j * nof_symbols_slot + 0); - srslte_vec_sc_prod_cfc(ptr, scaling, ptr, nof_re_symbol); - if (q->cell.cp == SRSLTE_CP_NORM) { + srsran_vec_sc_prod_cfc(ptr, scaling, ptr, nof_re_symbol); + if (q->cell.cp == SRSRAN_CP_NORM) { ptr = q->sf_symbols[i] + nof_re_symbol * (j * nof_symbols_slot + 4); - srslte_vec_sc_prod_cfc(ptr, scaling, ptr, nof_re_symbol); + srsran_vec_sc_prod_cfc(ptr, scaling, ptr, nof_re_symbol); } else { ptr = q->sf_symbols[i] + nof_re_symbol * (j * nof_symbols_slot + 3); - srslte_vec_sc_prod_cfc(ptr, scaling, ptr, nof_re_symbol); + srsran_vec_sc_prod_cfc(ptr, scaling, ptr, nof_re_symbol); } if (q->cell.nof_ports == 4) { ptr = q->sf_symbols[i] + nof_re_symbol * (j * nof_symbols_slot + 1); - srslte_vec_sc_prod_cfc(ptr, scaling, ptr, nof_re_symbol); + srsran_vec_sc_prod_cfc(ptr, scaling, ptr, nof_re_symbol); } } } @@ -282,59 +282,59 @@ void srslte_enb_dl_prepare_power_allocation(srslte_enb_dl_t* q) #endif -static void clear_sf(srslte_enb_dl_t* q) +static void clear_sf(srsran_enb_dl_t* q) { for (int i = 0; i < q->cell.nof_ports; i++) { - srslte_vec_cf_zero(q->sf_symbols[i], CURRENT_SFLEN_RE); + srsran_vec_cf_zero(q->sf_symbols[i], CURRENT_SFLEN_RE); } } -static void put_sync(srslte_enb_dl_t* q) +static void put_sync(srsran_enb_dl_t* q) { uint32_t sf_idx = q->dl_sf.tti % 10; if (sf_idx == 0 || sf_idx == 5) { for (int p = 0; p < q->cell.nof_ports; p++) { - srslte_pss_put_slot(q->pss_signal, q->sf_symbols[p], q->cell.nof_prb, q->cell.cp); - srslte_sss_put_slot(sf_idx ? q->sss_signal5 : q->sss_signal0, q->sf_symbols[p], q->cell.nof_prb, q->cell.cp); + srsran_pss_put_slot(q->pss_signal, q->sf_symbols[p], q->cell.nof_prb, q->cell.cp); + srsran_sss_put_slot(sf_idx ? q->sss_signal5 : q->sss_signal0, q->sf_symbols[p], q->cell.nof_prb, q->cell.cp); } } } -static void put_refs(srslte_enb_dl_t* q) +static void put_refs(srsran_enb_dl_t* q) { uint32_t sf_idx = q->dl_sf.tti % 10; - if (q->dl_sf.sf_type == SRSLTE_SF_MBSFN) { - srslte_refsignal_mbsfn_put_sf( + if (q->dl_sf.sf_type == SRSRAN_SF_MBSFN) { + srsran_refsignal_mbsfn_put_sf( q->cell, 0, q->csr_signal.pilots[0][sf_idx], q->mbsfnr_signal.pilots[0][sf_idx], q->sf_symbols[0]); } else { for (int p = 0; p < q->cell.nof_ports; p++) { - srslte_refsignal_cs_put_sf(&q->csr_signal, &q->dl_sf, (uint32_t)p, q->sf_symbols[p]); + srsran_refsignal_cs_put_sf(&q->csr_signal, &q->dl_sf, (uint32_t)p, q->sf_symbols[p]); } } } -static void put_mib(srslte_enb_dl_t* q) +static void put_mib(srsran_enb_dl_t* q) { - uint8_t bch_payload[SRSLTE_BCH_PAYLOAD_LEN]; + uint8_t bch_payload[SRSRAN_BCH_PAYLOAD_LEN]; uint32_t sf_idx = q->dl_sf.tti % 10; uint32_t sfn = q->dl_sf.tti / 10; if (sf_idx == 0) { - srslte_pbch_mib_pack(&q->cell, sfn, bch_payload); - srslte_pbch_encode(&q->pbch, bch_payload, q->sf_symbols, sfn % 4); + srsran_pbch_mib_pack(&q->cell, sfn, bch_payload); + srsran_pbch_encode(&q->pbch, bch_payload, q->sf_symbols, sfn % 4); } } -static void put_pcfich(srslte_enb_dl_t* q) +static void put_pcfich(srsran_enb_dl_t* q) { - srslte_pcfich_encode(&q->pcfich, &q->dl_sf, q->sf_symbols); + srsran_pcfich_encode(&q->pcfich, &q->dl_sf, q->sf_symbols); } -void srslte_enb_dl_put_base(srslte_enb_dl_t* q, srslte_dl_sf_cfg_t* dl_sf) +void srsran_enb_dl_put_base(srsran_enb_dl_t* q, srsran_dl_sf_cfg_t* dl_sf) { - srslte_ofdm_set_non_mbsfn_region(&q->ifft_mbsfn, dl_sf->non_mbsfn_region); + srsran_ofdm_set_non_mbsfn_region(&q->ifft_mbsfn, dl_sf->non_mbsfn_region); q->dl_sf = *dl_sf; clear_sf(q); put_sync(q); @@ -343,100 +343,100 @@ void srslte_enb_dl_put_base(srslte_enb_dl_t* q, srslte_dl_sf_cfg_t* dl_sf) put_pcfich(q); } -void srslte_enb_dl_put_phich(srslte_enb_dl_t* q, srslte_phich_grant_t* grant, bool ack) +void srsran_enb_dl_put_phich(srsran_enb_dl_t* q, srsran_phich_grant_t* grant, bool ack) { - srslte_phich_resource_t resource; - srslte_phich_calc(&q->phich, grant, &resource); - srslte_phich_encode(&q->phich, &q->dl_sf, resource, ack, q->sf_symbols); + srsran_phich_resource_t resource; + srsran_phich_calc(&q->phich, grant, &resource); + srsran_phich_encode(&q->phich, &q->dl_sf, resource, ack, q->sf_symbols); } -bool srslte_enb_dl_location_is_common_ncce(srslte_enb_dl_t* q, uint32_t ncce) +bool srsran_enb_dl_location_is_common_ncce(srsran_enb_dl_t* q, uint32_t ncce) { - if (SRSLTE_CFI_ISVALID(q->dl_sf.cfi)) { - return srslte_location_find_ncce( - q->common_locations[SRSLTE_CFI_IDX(q->dl_sf.cfi)], q->nof_common_locations[SRSLTE_CFI_IDX(q->dl_sf.cfi)], ncce); + if (SRSRAN_CFI_ISVALID(q->dl_sf.cfi)) { + return srsran_location_find_ncce( + q->common_locations[SRSRAN_CFI_IDX(q->dl_sf.cfi)], q->nof_common_locations[SRSRAN_CFI_IDX(q->dl_sf.cfi)], ncce); } else { return false; } } -int srslte_enb_dl_put_pdcch_dl(srslte_enb_dl_t* q, srslte_dci_cfg_t* dci_cfg, srslte_dci_dl_t* dci_dl) +int srsran_enb_dl_put_pdcch_dl(srsran_enb_dl_t* q, srsran_dci_cfg_t* dci_cfg, srsran_dci_dl_t* dci_dl) { - srslte_dci_msg_t dci_msg; + srsran_dci_msg_t dci_msg; ZERO_OBJECT(dci_msg); - if (srslte_dci_msg_pack_pdsch(&q->cell, &q->dl_sf, dci_cfg, dci_dl, &dci_msg)) { + if (srsran_dci_msg_pack_pdsch(&q->cell, &q->dl_sf, dci_cfg, dci_dl, &dci_msg)) { ERROR("Error packing DL DCI"); } - if (srslte_pdcch_encode(&q->pdcch, &q->dl_sf, &dci_msg, q->sf_symbols)) { + if (srsran_pdcch_encode(&q->pdcch, &q->dl_sf, &dci_msg, q->sf_symbols)) { ERROR("Error encoding DL DCI message"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_enb_dl_put_pdcch_ul(srslte_enb_dl_t* q, srslte_dci_cfg_t* dci_cfg, srslte_dci_ul_t* dci_ul) +int srsran_enb_dl_put_pdcch_ul(srsran_enb_dl_t* q, srsran_dci_cfg_t* dci_cfg, srsran_dci_ul_t* dci_ul) { - srslte_dci_msg_t dci_msg; + srsran_dci_msg_t dci_msg; ZERO_OBJECT(dci_msg); - if (srslte_dci_msg_pack_pusch(&q->cell, &q->dl_sf, dci_cfg, dci_ul, &dci_msg)) { + if (srsran_dci_msg_pack_pusch(&q->cell, &q->dl_sf, dci_cfg, dci_ul, &dci_msg)) { ERROR("Error packing UL DCI"); } - if (srslte_pdcch_encode(&q->pdcch, &q->dl_sf, &dci_msg, q->sf_symbols)) { + if (srsran_pdcch_encode(&q->pdcch, &q->dl_sf, &dci_msg, q->sf_symbols)) { ERROR("Error encoding UL DCI message"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_enb_dl_put_pdsch(srslte_enb_dl_t* q, srslte_pdsch_cfg_t* pdsch, uint8_t* data[SRSLTE_MAX_CODEWORDS]) +int srsran_enb_dl_put_pdsch(srsran_enb_dl_t* q, srsran_pdsch_cfg_t* pdsch, uint8_t* data[SRSRAN_MAX_CODEWORDS]) { - return srslte_pdsch_encode(&q->pdsch, &q->dl_sf, pdsch, data, q->sf_symbols); + return srsran_pdsch_encode(&q->pdsch, &q->dl_sf, pdsch, data, q->sf_symbols); } -int srslte_enb_dl_put_pmch(srslte_enb_dl_t* q, srslte_pmch_cfg_t* pmch_cfg, uint8_t* data) +int srsran_enb_dl_put_pmch(srsran_enb_dl_t* q, srsran_pmch_cfg_t* pmch_cfg, uint8_t* data) { - return srslte_pmch_encode(&q->pmch, &q->dl_sf, pmch_cfg, data, q->sf_symbols); + return srsran_pmch_encode(&q->pmch, &q->dl_sf, pmch_cfg, data, q->sf_symbols); } -void srslte_enb_dl_gen_signal(srslte_enb_dl_t* q) +void srsran_enb_dl_gen_signal(srsran_enb_dl_t* q) { // TODO: PAPR control float norm_factor = enb_dl_get_norm_factor(q->cell.nof_prb); - if (q->dl_sf.sf_type == SRSLTE_SF_MBSFN) { - srslte_ofdm_tx_sf(&q->ifft_mbsfn); - srslte_vec_sc_prod_cfc(q->ifft_mbsfn.cfg.out_buffer, + if (q->dl_sf.sf_type == SRSRAN_SF_MBSFN) { + srsran_ofdm_tx_sf(&q->ifft_mbsfn); + srsran_vec_sc_prod_cfc(q->ifft_mbsfn.cfg.out_buffer, norm_factor, q->ifft_mbsfn.cfg.out_buffer, - (uint32_t)SRSLTE_SF_LEN_PRB(q->cell.nof_prb)); + (uint32_t)SRSRAN_SF_LEN_PRB(q->cell.nof_prb)); } else { for (int i = 0; i < q->cell.nof_ports; i++) { - srslte_ofdm_tx_sf(&q->ifft[i]); - srslte_vec_sc_prod_cfc(q->ifft[i].cfg.out_buffer, + srsran_ofdm_tx_sf(&q->ifft[i]); + srsran_vec_sc_prod_cfc(q->ifft[i].cfg.out_buffer, norm_factor, q->ifft[i].cfg.out_buffer, - (uint32_t)SRSLTE_SF_LEN_PRB(q->cell.nof_prb)); + (uint32_t)SRSRAN_SF_LEN_PRB(q->cell.nof_prb)); } } } -bool srslte_enb_dl_gen_cqi_periodic(const srslte_cell_t* cell, - const srslte_dl_cfg_t* dl_cfg, +bool srsran_enb_dl_gen_cqi_periodic(const srsran_cell_t* cell, + const srsran_dl_cfg_t* dl_cfg, uint32_t tti, uint32_t last_ri, - srslte_cqi_cfg_t* cqi_cfg) + srsran_cqi_cfg_t* cqi_cfg) { bool cqi_enabled = false; - if (srslte_cqi_periodic_ri_send(&dl_cfg->cqi_report, tti, cell->frame_type)) { - cqi_cfg->ri_len = srslte_ri_nof_bits(cell); + if (srsran_cqi_periodic_ri_send(&dl_cfg->cqi_report, tti, cell->frame_type)) { + cqi_cfg->ri_len = srsran_ri_nof_bits(cell); cqi_enabled = true; - } else if (srslte_cqi_periodic_send(&dl_cfg->cqi_report, tti, cell->frame_type)) { - cqi_cfg->type = SRSLTE_CQI_TYPE_WIDEBAND; - if (dl_cfg->tm == SRSLTE_TM4) { + } else if (srsran_cqi_periodic_send(&dl_cfg->cqi_report, tti, cell->frame_type)) { + cqi_cfg->type = SRSRAN_CQI_TYPE_WIDEBAND; + if (dl_cfg->tm == SRSRAN_TM4) { cqi_cfg->pmi_present = true; cqi_cfg->rank_is_not_one = last_ri > 0; } @@ -446,19 +446,19 @@ bool srslte_enb_dl_gen_cqi_periodic(const srslte_cell_t* cell, return cqi_enabled; } -bool srslte_enb_dl_gen_cqi_aperiodic(const srslte_cell_t* cell, - const srslte_dl_cfg_t* dl_cfg, +bool srsran_enb_dl_gen_cqi_aperiodic(const srsran_cell_t* cell, + const srsran_dl_cfg_t* dl_cfg, uint32_t ri, - srslte_cqi_cfg_t* cqi_cfg) + srsran_cqi_cfg_t* cqi_cfg) { bool cqi_enabled = false; - const srslte_cqi_report_cfg_t* cqi_report_cfg = &dl_cfg->cqi_report; + const srsran_cqi_report_cfg_t* cqi_report_cfg = &dl_cfg->cqi_report; - cqi_cfg->type = SRSLTE_CQI_TYPE_SUBBAND_HL; - if (dl_cfg->tm == SRSLTE_TM3 || dl_cfg->tm == SRSLTE_TM4) { - cqi_cfg->ri_len = srslte_ri_nof_bits(cell); + cqi_cfg->type = SRSRAN_CQI_TYPE_SUBBAND_HL; + if (dl_cfg->tm == SRSRAN_TM3 || dl_cfg->tm == SRSRAN_TM4) { + cqi_cfg->ri_len = srsran_ri_nof_bits(cell); } - cqi_cfg->N = (cell->nof_prb > 7) ? srslte_cqi_hl_get_no_subbands(cell->nof_prb) : 0; + cqi_cfg->N = (cell->nof_prb > 7) ? srsran_cqi_hl_get_no_subbands(cell->nof_prb) : 0; cqi_cfg->four_antenna_ports = (cell->nof_ports == 4); cqi_cfg->pmi_present = (cqi_report_cfg->pmi_idx != 0); cqi_cfg->rank_is_not_one = ri > 0; @@ -467,45 +467,45 @@ bool srslte_enb_dl_gen_cqi_aperiodic(const srslte_cell_t* cell, return cqi_enabled; } -void srslte_enb_dl_save_signal(srslte_enb_dl_t* q) +void srsran_enb_dl_save_signal(srsran_enb_dl_t* q) { char tmpstr[64]; uint32_t tti = q->dl_sf.tti; snprintf(tmpstr, 64, "sf_symbols_%d", tti); - srslte_vec_save_file(tmpstr, q->sf_symbols[0], SRSLTE_NOF_RE(q->cell) * sizeof(cf_t)); + srsran_vec_save_file(tmpstr, q->sf_symbols[0], SRSRAN_NOF_RE(q->cell) * sizeof(cf_t)); /* int cb_len = q->pdsch_cfg.cb_segm[0].K1; for (int i=0;ipdsch_cfg.cb_segm[0].C;i++) { snprintf(tmpstr,64,"output/rmout_%d_%d",i,tti); - srslte_bit_unpack_vector(softbuffer->buffer_b[i], q->tmp, (3*cb_len+12)); - srslte_vec_save_file(tmpstr, q->tmp, (3*cb_len+12)*sizeof(uint8_t)); + srsran_bit_unpack_vector(softbuffer->buffer_b[i], q->tmp, (3*cb_len+12)); + srsran_vec_save_file(tmpstr, q->tmp, (3*cb_len+12)*sizeof(uint8_t)); }*/ // printf("Saved files for tti=%d, sf=%d, cfi=%d, mcs=%d, tbs=%d, rv=%d, rnti=0x%x\n", tti, tti%10, cfi, // q->dci.mcs[0].idx, q->dci.mcs[0].tbs, rv_idx, rnti); } -void srslte_enb_dl_gen_ack(const srslte_cell_t* cell, - const srslte_dl_sf_cfg_t* sf, - const srslte_pdsch_ack_t* ack_info, - srslte_uci_cfg_t* uci_cfg) +void srsran_enb_dl_gen_ack(const srsran_cell_t* cell, + const srsran_dl_sf_cfg_t* sf, + const srsran_pdsch_ack_t* ack_info, + srsran_uci_cfg_t* uci_cfg) { - srslte_uci_data_t uci_data = {}; + srsran_uci_data_t uci_data = {}; // Copy UCI configuration uci_data.cfg = *uci_cfg; - srslte_ue_dl_gen_ack(cell, sf, ack_info, &uci_data); + srsran_ue_dl_gen_ack(cell, sf, ack_info, &uci_data); // Copy back the result of uci configuration *uci_cfg = uci_data.cfg; } -static void enb_dl_get_ack_fdd_all_spatial_bundling(const srslte_uci_value_t* uci_value, - srslte_pdsch_ack_t* pdsch_ack, +static void enb_dl_get_ack_fdd_all_spatial_bundling(const srsran_uci_value_t* uci_value, + srsran_pdsch_ack_t* pdsch_ack, uint32_t nof_tb) { for (uint32_t cc_idx = 0; cc_idx < pdsch_ack->nof_cc; cc_idx++) { @@ -521,7 +521,7 @@ static void enb_dl_get_ack_fdd_all_spatial_bundling(const srslte_uci_value_t* uc } static void -enb_dl_get_ack_fdd_pcell_skip_drx(const srslte_uci_value_t* uci_value, srslte_pdsch_ack_t* pdsch_ack, uint32_t nof_tb) +enb_dl_get_ack_fdd_pcell_skip_drx(const srsran_uci_value_t* uci_value, srsran_pdsch_ack_t* pdsch_ack, uint32_t nof_tb) { uint32_t ack_idx = 0; if (pdsch_ack->cc[0].m[0].present) { @@ -539,7 +539,7 @@ enb_dl_get_ack_fdd_pcell_skip_drx(const srslte_uci_value_t* uci_value, srslte_pd } static void -enb_dl_get_ack_fdd_all_keep_drx(const srslte_uci_value_t* uci_value, srslte_pdsch_ack_t* pdsch_ack, uint32_t nof_tb) +enb_dl_get_ack_fdd_all_keep_drx(const srsran_uci_value_t* uci_value, srsran_pdsch_ack_t* pdsch_ack, uint32_t nof_tb) { for (uint32_t cc_idx = 0; cc_idx < pdsch_ack->nof_cc; cc_idx++) { if (pdsch_ack->cc[cc_idx].m[0].present) { @@ -558,12 +558,12 @@ enb_dl_get_ack_fdd_all_keep_drx(const srslte_uci_value_t* uci_value, srslte_pdsc } static void -get_ack_fdd(const srslte_uci_cfg_t* uci_cfg, const srslte_uci_value_t* uci_value, srslte_pdsch_ack_t* pdsch_ack) +get_ack_fdd(const srsran_uci_cfg_t* uci_cfg, const srsran_uci_value_t* uci_value, srsran_pdsch_ack_t* pdsch_ack) { // Number of transport blocks for the current Transmission Mode uint32_t nof_tb = 1; - if (pdsch_ack->transmission_mode > SRSLTE_TM2) { - nof_tb = SRSLTE_MAX_CODEWORDS; + if (pdsch_ack->transmission_mode > SRSRAN_TM2) { + nof_tb = SRSRAN_MAX_CODEWORDS; } // Count number of transmissions @@ -586,11 +586,11 @@ get_ack_fdd(const srslte_uci_cfg_t* uci_cfg, const srslte_uci_value_t* uci_value bool csi_report = uci_cfg->cqi.data_enable || uci_cfg->cqi.ri_len; switch (pdsch_ack->ack_nack_feedback_mode) { - case SRSLTE_PUCCH_ACK_NACK_FEEDBACK_MODE_NORMAL: + case SRSRAN_PUCCH_ACK_NACK_FEEDBACK_MODE_NORMAL: // Get ACK from PCell only, skipping DRX enb_dl_get_ack_fdd_pcell_skip_drx(uci_value, pdsch_ack, nof_tb); break; - case SRSLTE_PUCCH_ACK_NACK_FEEDBACK_MODE_CS: + case SRSRAN_PUCCH_ACK_NACK_FEEDBACK_MODE_CS: if (pdsch_ack->nof_cc == 1) { enb_dl_get_ack_fdd_pcell_skip_drx(uci_value, pdsch_ack, nof_tb); } else if (pdsch_ack->is_pusch_available) { @@ -614,33 +614,33 @@ get_ack_fdd(const srslte_uci_cfg_t* uci_cfg, const srslte_uci_value_t* uci_value enb_dl_get_ack_fdd_all_keep_drx(uci_value, pdsch_ack, nof_tb); } break; - case SRSLTE_PUCCH_ACK_NACK_FEEDBACK_MODE_PUCCH3: + case SRSRAN_PUCCH_ACK_NACK_FEEDBACK_MODE_PUCCH3: if (tb_count == tb_count_cc0) { enb_dl_get_ack_fdd_pcell_skip_drx(uci_value, pdsch_ack, nof_tb); } else { enb_dl_get_ack_fdd_all_keep_drx(uci_value, pdsch_ack, nof_tb); } break; - case SRSLTE_PUCCH_ACK_NACK_FEEDBACK_MODE_ERROR: + case SRSRAN_PUCCH_ACK_NACK_FEEDBACK_MODE_ERROR: default:; // Do nothing break; } } -void srslte_enb_dl_get_ack(const srslte_cell_t* cell, - const srslte_uci_cfg_t* uci_cfg, - const srslte_uci_value_t* uci_value, - srslte_pdsch_ack_t* pdsch_ack) +void srsran_enb_dl_get_ack(const srsran_cell_t* cell, + const srsran_uci_cfg_t* uci_cfg, + const srsran_uci_value_t* uci_value, + srsran_pdsch_ack_t* pdsch_ack) { - if (cell->frame_type == SRSLTE_FDD) { + if (cell->frame_type == SRSRAN_FDD) { get_ack_fdd(uci_cfg, uci_value, pdsch_ack); } else { ERROR("Not implemented for TDD"); } } -float srslte_enb_dl_get_maximum_signal_power_dBfs(uint32_t nof_prb) +float srsran_enb_dl_get_maximum_signal_power_dBfs(uint32_t nof_prb) { - return srslte_convert_amplitude_to_dB(enb_dl_get_norm_factor(nof_prb)) + - srslte_convert_power_to_dB((float)nof_prb * SRSLTE_NRE) + 3.0f; + return srsran_convert_amplitude_to_dB(enb_dl_get_norm_factor(nof_prb)) + + srsran_convert_power_to_dB((float)nof_prb * SRSRAN_NRE) + 3.0f; } diff --git a/lib/src/phy/enb/enb_dl_nr.c b/lib/src/phy/enb/enb_dl_nr.c index 9760a1cdf..09188dd39 100644 --- a/lib/src/phy/enb/enb_dl_nr.c +++ b/lib/src/phy/enb/enb_dl_nr.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,10 +10,10 @@ * */ -#include "srslte/phy/enb/enb_dl_nr.h" +#include "srsran/phy/enb/enb_dl_nr.h" #include -static int enb_dl_alloc_prb(srslte_enb_dl_nr_t* q, uint32_t new_nof_prb) +static int enb_dl_alloc_prb(srsran_enb_dl_nr_t* q, uint32_t new_nof_prb) { if (q->max_prb < new_nof_prb) { q->max_prb = new_nof_prb; @@ -23,214 +23,214 @@ static int enb_dl_alloc_prb(srslte_enb_dl_nr_t* q, uint32_t new_nof_prb) free(q->sf_symbols[i]); } - q->sf_symbols[i] = srslte_vec_cf_malloc(SRSLTE_SLOT_LEN_RE_NR(q->max_prb)); + q->sf_symbols[i] = srsran_vec_cf_malloc(SRSRAN_SLOT_LEN_RE_NR(q->max_prb)); if (q->sf_symbols[i] == NULL) { ERROR("Malloc"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_enb_dl_nr_init(srslte_enb_dl_nr_t* q, cf_t* output[SRSLTE_MAX_PORTS], const srslte_enb_dl_nr_args_t* args) +int srsran_enb_dl_nr_init(srsran_enb_dl_nr_t* q, cf_t* output[SRSRAN_MAX_PORTS], const srsran_enb_dl_nr_args_t* args) { if (!q || !output || !args) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } if (args->nof_tx_antennas == 0) { ERROR("Error invalid number of antennas (%d)", args->nof_tx_antennas); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } q->nof_tx_antennas = args->nof_tx_antennas; - if (srslte_pdsch_nr_init_enb(&q->pdsch, &args->pdsch) < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (srsran_pdsch_nr_init_enb(&q->pdsch, &args->pdsch) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } - if (enb_dl_alloc_prb(q, args->nof_max_prb) < SRSLTE_SUCCESS) { + if (enb_dl_alloc_prb(q, args->nof_max_prb) < SRSRAN_SUCCESS) { ERROR("Error allocating"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - srslte_ofdm_cfg_t fft_cfg = {}; + srsran_ofdm_cfg_t fft_cfg = {}; fft_cfg.nof_prb = args->nof_max_prb; - fft_cfg.symbol_sz = srslte_min_symbol_sz_rb(args->nof_max_prb); + fft_cfg.symbol_sz = srsran_min_symbol_sz_rb(args->nof_max_prb); fft_cfg.keep_dc = true; for (uint32_t i = 0; i < q->nof_tx_antennas; i++) { fft_cfg.in_buffer = q->sf_symbols[i]; fft_cfg.out_buffer = output[i]; - srslte_ofdm_tx_init_cfg(&q->fft[i], &fft_cfg); + srsran_ofdm_tx_init_cfg(&q->fft[i], &fft_cfg); } - if (srslte_dmrs_sch_init(&q->dmrs, false) < SRSLTE_SUCCESS) { + if (srsran_dmrs_sch_init(&q->dmrs, false) < SRSRAN_SUCCESS) { ERROR("Error DMRS"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_pdcch_nr_init_tx(&q->pdcch, &args->pdcch) < SRSLTE_SUCCESS) { + if (srsran_pdcch_nr_init_tx(&q->pdcch, &args->pdcch) < SRSRAN_SUCCESS) { ERROR("Error PDCCH"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -void srslte_enb_dl_nr_free(srslte_enb_dl_nr_t* q) +void srsran_enb_dl_nr_free(srsran_enb_dl_nr_t* q) { if (q == NULL) { return; } - for (uint32_t i = 0; i < SRSLTE_MAX_PORTS; i++) { - srslte_ofdm_rx_free(&q->fft[i]); + for (uint32_t i = 0; i < SRSRAN_MAX_PORTS; i++) { + srsran_ofdm_rx_free(&q->fft[i]); if (q->sf_symbols[i] != NULL) { free(q->sf_symbols[i]); } } - srslte_pdsch_nr_free(&q->pdsch); - srslte_dmrs_sch_free(&q->dmrs); + srsran_pdsch_nr_free(&q->pdsch); + srsran_dmrs_sch_free(&q->dmrs); - srslte_pdcch_nr_free(&q->pdcch); + srsran_pdcch_nr_free(&q->pdcch); - SRSLTE_MEM_ZERO(q, srslte_enb_dl_nr_t, 1); + SRSRAN_MEM_ZERO(q, srsran_enb_dl_nr_t, 1); } -int srslte_enb_dl_nr_set_carrier(srslte_enb_dl_nr_t* q, const srslte_carrier_nr_t* carrier) +int srsran_enb_dl_nr_set_carrier(srsran_enb_dl_nr_t* q, const srsran_carrier_nr_t* carrier) { - if (srslte_pdsch_nr_set_carrier(&q->pdsch, carrier) < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (srsran_pdsch_nr_set_carrier(&q->pdsch, carrier) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } - if (srslte_dmrs_sch_set_carrier(&q->dmrs, carrier) < SRSLTE_SUCCESS) { + if (srsran_dmrs_sch_set_carrier(&q->dmrs, carrier) < SRSRAN_SUCCESS) { ERROR("Error DMRS"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (enb_dl_alloc_prb(q, carrier->nof_prb) < SRSLTE_SUCCESS) { + if (enb_dl_alloc_prb(q, carrier->nof_prb) < SRSRAN_SUCCESS) { ERROR("Error allocating"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (carrier->nof_prb != q->carrier.nof_prb) { - srslte_ofdm_cfg_t fft_cfg = {}; + srsran_ofdm_cfg_t fft_cfg = {}; fft_cfg.nof_prb = carrier->nof_prb; - fft_cfg.symbol_sz = srslte_min_symbol_sz_rb(carrier->nof_prb); + fft_cfg.symbol_sz = srsran_min_symbol_sz_rb(carrier->nof_prb); fft_cfg.keep_dc = true; for (uint32_t i = 0; i < q->nof_tx_antennas; i++) { fft_cfg.in_buffer = q->sf_symbols[i]; - srslte_ofdm_tx_init_cfg(&q->fft[i], &fft_cfg); + srsran_ofdm_tx_init_cfg(&q->fft[i], &fft_cfg); } } q->carrier = *carrier; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_enb_dl_nr_set_coreset(srslte_enb_dl_nr_t* q, const srslte_coreset_t* coreset) +int srsran_enb_dl_nr_set_coreset(srsran_enb_dl_nr_t* q, const srsran_coreset_t* coreset) { if (q == NULL || coreset == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } q->coreset = *coreset; - if (srslte_pdcch_nr_set_carrier(&q->pdcch, &q->carrier, &q->coreset) < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (srsran_pdcch_nr_set_carrier(&q->pdcch, &q->carrier, &q->coreset) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -void srslte_enb_dl_nr_gen_signal(srslte_enb_dl_nr_t* q) +void srsran_enb_dl_nr_gen_signal(srsran_enb_dl_nr_t* q) { if (q == NULL) { return; } for (uint32_t i = 0; i < q->nof_tx_antennas; i++) { - srslte_ofdm_tx_sf(&q->fft[i]); + srsran_ofdm_tx_sf(&q->fft[i]); } } -int srslte_enb_dl_nr_base_zero(srslte_enb_dl_nr_t* q) +int srsran_enb_dl_nr_base_zero(srsran_enb_dl_nr_t* q) { if (q == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } for (uint32_t i = 0; i < q->nof_tx_antennas; i++) { - srslte_vec_cf_zero(q->sf_symbols[i], SRSLTE_SLOT_LEN_RE_NR(q->carrier.nof_prb)); + srsran_vec_cf_zero(q->sf_symbols[i], SRSRAN_SLOT_LEN_RE_NR(q->carrier.nof_prb)); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_enb_dl_nr_pdcch_put(srslte_enb_dl_nr_t* q, - const srslte_slot_cfg_t* slot_cfg, - const srslte_dci_dl_nr_t* dci_dl) +int srsran_enb_dl_nr_pdcch_put(srsran_enb_dl_nr_t* q, + const srsran_slot_cfg_t* slot_cfg, + const srsran_dci_dl_nr_t* dci_dl) { if (q == NULL || slot_cfg == NULL || dci_dl == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } // Put DMRS - if (srslte_dmrs_pdcch_put(&q->carrier, &q->coreset, slot_cfg, &dci_dl->location, q->sf_symbols[0]) < SRSLTE_SUCCESS) { + if (srsran_dmrs_pdcch_put(&q->carrier, &q->coreset, slot_cfg, &dci_dl->location, q->sf_symbols[0]) < SRSRAN_SUCCESS) { ERROR("Error putting PDCCH DMRS"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Pack DCI - srslte_dci_msg_nr_t dci_msg = {}; - if (srslte_dci_nr_pack(&q->carrier, &q->coreset, dci_dl, &dci_msg) < SRSLTE_SUCCESS) { + srsran_dci_msg_nr_t dci_msg = {}; + if (srsran_dci_nr_pack(&q->carrier, &q->coreset, dci_dl, &dci_msg) < SRSRAN_SUCCESS) { ERROR("Error packing DL DCI"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // PDCCH Encode - if (srslte_pdcch_nr_encode(&q->pdcch, &dci_msg, q->sf_symbols[0]) < SRSLTE_SUCCESS) { + if (srsran_pdcch_nr_encode(&q->pdcch, &dci_msg, q->sf_symbols[0]) < SRSRAN_SUCCESS) { ERROR("Error encoding PDCCH"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } INFO("DCI DL NR: L=%d; ncce=%d;", dci_dl->location.L, dci_dl->location.ncce); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_enb_dl_nr_pdsch_put(srslte_enb_dl_nr_t* q, - const srslte_slot_cfg_t* slot, - const srslte_sch_cfg_nr_t* cfg, - uint8_t* data[SRSLTE_MAX_TB]) +int srsran_enb_dl_nr_pdsch_put(srsran_enb_dl_nr_t* q, + const srsran_slot_cfg_t* slot, + const srsran_sch_cfg_nr_t* cfg, + uint8_t* data[SRSRAN_MAX_TB]) { - if (srslte_dmrs_sch_put_sf(&q->dmrs, slot, cfg, &cfg->grant, q->sf_symbols[0]) < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (srsran_dmrs_sch_put_sf(&q->dmrs, slot, cfg, &cfg->grant, q->sf_symbols[0]) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } - if (srslte_pdsch_nr_encode(&q->pdsch, cfg, &cfg->grant, data, q->sf_symbols) < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (srsran_pdsch_nr_encode(&q->pdsch, cfg, &cfg->grant, data, q->sf_symbols) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_enb_dl_nr_pdsch_info(const srslte_enb_dl_nr_t* q, - const srslte_sch_cfg_nr_t* cfg, +int srsran_enb_dl_nr_pdsch_info(const srsran_enb_dl_nr_t* q, + const srsran_sch_cfg_nr_t* cfg, char* str, uint32_t str_len) { int len = 0; // Append PDSCH info - len += srslte_pdsch_nr_tx_info(&q->pdsch, cfg, &cfg->grant, &str[len], str_len - len); + len += srsran_pdsch_nr_tx_info(&q->pdsch, cfg, &cfg->grant, &str[len], str_len - len); return len; } diff --git a/lib/src/phy/enb/enb_ul.c b/lib/src/phy/enb/enb_ul.c index 496d1db32..03d1195d6 100644 --- a/lib/src/phy/enb/enb_ul.c +++ b/lib/src/phy/enb/enb_ul.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,82 +10,82 @@ * */ -#include "srslte/phy/enb/enb_ul.h" +#include "srsran/phy/enb/enb_ul.h" -#include "srslte/srslte.h" +#include "srsran/srsran.h" #include #include #include -int srslte_enb_ul_init(srslte_enb_ul_t* q, cf_t* in_buffer, uint32_t max_prb) +int srsran_enb_ul_init(srsran_enb_ul_t* q, cf_t* in_buffer, uint32_t max_prb) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL) { - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; - bzero(q, sizeof(srslte_enb_ul_t)); + bzero(q, sizeof(srsran_enb_ul_t)); - q->sf_symbols = srslte_vec_cf_malloc(SRSLTE_SF_LEN_RE(max_prb, SRSLTE_CP_NORM)); + q->sf_symbols = srsran_vec_cf_malloc(SRSRAN_SF_LEN_RE(max_prb, SRSRAN_CP_NORM)); if (!q->sf_symbols) { perror("malloc"); goto clean_exit; } - q->chest_res.ce = srslte_vec_cf_malloc(SRSLTE_SF_LEN_RE(max_prb, SRSLTE_CP_NORM)); + q->chest_res.ce = srsran_vec_cf_malloc(SRSRAN_SF_LEN_RE(max_prb, SRSRAN_CP_NORM)); if (!q->chest_res.ce) { perror("malloc"); goto clean_exit; } - srslte_ofdm_cfg_t ofdm_cfg = {}; + srsran_ofdm_cfg_t ofdm_cfg = {}; ofdm_cfg.nof_prb = max_prb; ofdm_cfg.in_buffer = in_buffer; ofdm_cfg.out_buffer = q->sf_symbols; - ofdm_cfg.cp = SRSLTE_CP_NORM; + ofdm_cfg.cp = SRSRAN_CP_NORM; ofdm_cfg.freq_shift_f = -0.5f; ofdm_cfg.normalize = false; ofdm_cfg.rx_window_offset = 0.5f; - if (srslte_ofdm_rx_init_cfg(&q->fft, &ofdm_cfg)) { + if (srsran_ofdm_rx_init_cfg(&q->fft, &ofdm_cfg)) { ERROR("Error initiating FFT"); goto clean_exit; } - if (srslte_pucch_init_enb(&q->pucch)) { + if (srsran_pucch_init_enb(&q->pucch)) { ERROR("Error creating PUCCH object"); goto clean_exit; } - if (srslte_pusch_init_enb(&q->pusch, max_prb)) { + if (srsran_pusch_init_enb(&q->pusch, max_prb)) { ERROR("Error creating PUSCH object"); goto clean_exit; } - if (srslte_chest_ul_init(&q->chest, max_prb)) { + if (srsran_chest_ul_init(&q->chest, max_prb)) { ERROR("Error initiating channel estimator"); goto clean_exit; } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } else { ERROR("Invalid parameters"); } clean_exit: - if (ret == SRSLTE_ERROR) { - srslte_enb_ul_free(q); + if (ret == SRSRAN_ERROR) { + srsran_enb_ul_free(q); } return ret; } -void srslte_enb_ul_free(srslte_enb_ul_t* q) +void srsran_enb_ul_free(srsran_enb_ul_t* q) { if (q) { - srslte_ofdm_rx_free(&q->fft); - srslte_pucch_free(&q->pucch); - srslte_pusch_free(&q->pusch); - srslte_chest_ul_free(&q->chest); + srsran_ofdm_rx_free(&q->fft); + srsran_pucch_free(&q->pucch); + srsran_pusch_free(&q->pusch); + srsran_chest_ul_free(&q->chest); if (q->sf_symbols) { free(q->sf_symbols); @@ -93,45 +93,45 @@ void srslte_enb_ul_free(srslte_enb_ul_t* q) if (q->chest_res.ce) { free(q->chest_res.ce); } - bzero(q, sizeof(srslte_enb_ul_t)); + bzero(q, sizeof(srsran_enb_ul_t)); } } -int srslte_enb_ul_set_cell(srslte_enb_ul_t* q, - srslte_cell_t cell, - srslte_refsignal_dmrs_pusch_cfg_t* pusch_cfg, - srslte_refsignal_srs_cfg_t* srs_cfg) +int srsran_enb_ul_set_cell(srsran_enb_ul_t* q, + srsran_cell_t cell, + srsran_refsignal_dmrs_pusch_cfg_t* pusch_cfg, + srsran_refsignal_srs_cfg_t* srs_cfg) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; - if (q != NULL && srslte_cell_isvalid(&cell)) { + if (q != NULL && srsran_cell_isvalid(&cell)) { if (cell.id != q->cell.id || q->cell.nof_prb == 0) { q->cell = cell; - if (srslte_ofdm_rx_set_prb(&q->fft, q->cell.cp, q->cell.nof_prb)) { + if (srsran_ofdm_rx_set_prb(&q->fft, q->cell.cp, q->cell.nof_prb)) { ERROR("Error initiating FFT"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_pucch_set_cell(&q->pucch, q->cell)) { + if (srsran_pucch_set_cell(&q->pucch, q->cell)) { ERROR("Error creating PUCCH object"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_pusch_set_cell(&q->pusch, q->cell)) { + if (srsran_pusch_set_cell(&q->pusch, q->cell)) { ERROR("Error creating PUSCH object"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_chest_ul_set_cell(&q->chest, cell)) { + if (srsran_chest_ul_set_cell(&q->chest, cell)) { ERROR("Error initiating channel estimator"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // SRS is a dedicated configuration - srslte_chest_ul_pregen(&q->chest, pusch_cfg, srs_cfg); + srsran_chest_ul_pregen(&q->chest, pusch_cfg, srs_cfg); - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } } else { ERROR("Invalid cell properties: Id=%d, Ports=%d, PRBs=%d", cell.id, cell.nof_ports, cell.nof_prb); @@ -139,16 +139,16 @@ int srslte_enb_ul_set_cell(srslte_enb_ul_t* q, return ret; } -void srslte_enb_ul_fft(srslte_enb_ul_t* q) +void srsran_enb_ul_fft(srsran_enb_ul_t* q) { - srslte_ofdm_rx_sf(&q->fft); + srsran_ofdm_rx_sf(&q->fft); } -static int get_pucch(srslte_enb_ul_t* q, srslte_ul_sf_cfg_t* ul_sf, srslte_pucch_cfg_t* cfg, srslte_pucch_res_t* res) +static int get_pucch(srsran_enb_ul_t* q, srsran_ul_sf_cfg_t* ul_sf, srsran_pucch_cfg_t* cfg, srsran_pucch_res_t* res) { - int ret = SRSLTE_SUCCESS; - uint32_t n_pucch_i[SRSLTE_PUCCH_MAX_ALLOC] = {}; - uint32_t uci_cfg_total_ack = srslte_uci_cfg_total_ack(&cfg->uci_cfg); + int ret = SRSRAN_SUCCESS; + uint32_t n_pucch_i[SRSRAN_PUCCH_MAX_ALLOC] = {}; + uint32_t uci_cfg_total_ack = srsran_uci_cfg_total_ack(&cfg->uci_cfg); // Drop CQI if there is collision with ACK if (!cfg->simul_cqi_ack && uci_cfg_total_ack > 0 && cfg->uci_cfg.cqi.data_enable) { @@ -156,38 +156,38 @@ static int get_pucch(srslte_enb_ul_t* q, srslte_ul_sf_cfg_t* ul_sf, srslte_pucch } // Select format - cfg->format = srslte_pucch_proc_select_format(&q->cell, cfg, &cfg->uci_cfg, NULL); - if (cfg->format == SRSLTE_PUCCH_FORMAT_ERROR) { + cfg->format = srsran_pucch_proc_select_format(&q->cell, cfg, &cfg->uci_cfg, NULL); + if (cfg->format == SRSRAN_PUCCH_FORMAT_ERROR) { ERROR("Returned Error while selecting PUCCH format"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Get possible resources - int nof_resources = srslte_pucch_proc_get_resources(&q->cell, cfg, &cfg->uci_cfg, NULL, n_pucch_i); - if (nof_resources < 1 || nof_resources > SRSLTE_PUCCH_CS_MAX_ACK) { + int nof_resources = srsran_pucch_proc_get_resources(&q->cell, cfg, &cfg->uci_cfg, NULL, n_pucch_i); + if (nof_resources < 1 || nof_resources > SRSRAN_PUCCH_CS_MAX_ACK) { ERROR("No PUCCH resource could be calculated (%d)", nof_resources); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Initialise minimum correlation res->correlation = 0.0f; // Iterate possible resources and select the one with higher correlation - for (int i = 0; i < nof_resources && ret == SRSLTE_SUCCESS; i++) { - srslte_pucch_res_t pucch_res = {}; + for (int i = 0; i < nof_resources && ret == SRSRAN_SUCCESS; i++) { + srsran_pucch_res_t pucch_res = {}; // Configure resource cfg->n_pucch = n_pucch_i[i]; // Prepare configuration - if (srslte_chest_ul_estimate_pucch(&q->chest, ul_sf, cfg, q->sf_symbols, &q->chest_res)) { + if (srsran_chest_ul_estimate_pucch(&q->chest, ul_sf, cfg, q->sf_symbols, &q->chest_res)) { ERROR("Error estimating PUCCH DMRS"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } pucch_res.snr_db = q->chest_res.snr_db; - ret = srslte_pucch_decode(&q->pucch, ul_sf, cfg, &q->chest_res, q->sf_symbols, &pucch_res); - if (ret < SRSLTE_SUCCESS) { + ret = srsran_pucch_decode(&q->pucch, ul_sf, cfg, &q->chest_res, q->sf_symbols, &pucch_res); + if (ret < SRSRAN_SUCCESS) { ERROR("Error decoding PUCCH"); } else { // Get PUCCH Format 1b with channel selection if: @@ -196,11 +196,11 @@ static int get_pucch(srslte_enb_ul_t* q, srslte_ul_sf_cfg_t* ul_sf, srslte_pucch // - HARQ feedback mode is set to PUCCH Format1b with Channel Selection (CS); and // - No scheduling request is expected; and // - Data is valid (invalid data does not make sense to decode). - if (uci_cfg_total_ack > 0 && cfg->format == SRSLTE_PUCCH_FORMAT_1B && - cfg->ack_nack_feedback_mode == SRSLTE_PUCCH_ACK_NACK_FEEDBACK_MODE_CS && + if (uci_cfg_total_ack > 0 && cfg->format == SRSRAN_PUCCH_FORMAT_1B && + cfg->ack_nack_feedback_mode == SRSRAN_PUCCH_ACK_NACK_FEEDBACK_MODE_CS && !cfg->uci_cfg.is_scheduling_request_tti && pucch_res.uci_data.ack.valid) { uint8_t b[2] = {pucch_res.uci_data.ack.ack_value[0], pucch_res.uci_data.ack.ack_value[1]}; - srslte_pucch_cs_get_ack(cfg, &cfg->uci_cfg, i, b, &pucch_res.uci_data); + srsran_pucch_cs_get_ack(cfg, &cfg->uci_cfg, i, b, &pucch_res.uci_data); } // Compares correlation value, it stores the PUCCH result with the greatest correlation @@ -219,38 +219,38 @@ static int get_pucch(srslte_enb_ul_t* q, srslte_ul_sf_cfg_t* ul_sf, srslte_pucch return ret; } -int srslte_enb_ul_get_pucch(srslte_enb_ul_t* q, - srslte_ul_sf_cfg_t* ul_sf, - srslte_pucch_cfg_t* cfg, - srslte_pucch_res_t* res) +int srsran_enb_ul_get_pucch(srsran_enb_ul_t* q, + srsran_ul_sf_cfg_t* ul_sf, + srsran_pucch_cfg_t* cfg, + srsran_pucch_res_t* res) { - if (!srslte_pucch_cfg_isvalid(cfg, q->cell.nof_prb)) { + if (!srsran_pucch_cfg_isvalid(cfg, q->cell.nof_prb)) { ERROR("Invalid PUCCH configuration"); - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } if (get_pucch(q, ul_sf, cfg, res)) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // If we are looking for SR and ACK at the same time and ret=0, means there is no SR. // try again to decode ACK only - if (cfg->uci_cfg.is_scheduling_request_tti && srslte_uci_cfg_total_ack(&cfg->uci_cfg) && !res->detected) { + if (cfg->uci_cfg.is_scheduling_request_tti && srsran_uci_cfg_total_ack(&cfg->uci_cfg) && !res->detected) { cfg->uci_cfg.is_scheduling_request_tti = false; if (get_pucch(q, ul_sf, cfg, res)) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_enb_ul_get_pusch(srslte_enb_ul_t* q, - srslte_ul_sf_cfg_t* ul_sf, - srslte_pusch_cfg_t* cfg, - srslte_pusch_res_t* res) +int srsran_enb_ul_get_pusch(srsran_enb_ul_t* q, + srsran_ul_sf_cfg_t* ul_sf, + srsran_pusch_cfg_t* cfg, + srsran_pusch_res_t* res) { - srslte_chest_ul_estimate_pusch(&q->chest, ul_sf, cfg, q->sf_symbols, &q->chest_res); + srsran_chest_ul_estimate_pusch(&q->chest, ul_sf, cfg, q->sf_symbols, &q->chest_res); - return srslte_pusch_decode(&q->pusch, ul_sf, cfg, &q->chest_res, q->sf_symbols, res); + return srsran_pusch_decode(&q->pusch, ul_sf, cfg, &q->chest_res, q->sf_symbols, res); } diff --git a/lib/src/phy/fec/CMakeLists.txt b/lib/src/phy/fec/CMakeLists.txt index 8c6ced9a9..13f293d25 100644 --- a/lib/src/phy/fec/CMakeLists.txt +++ b/lib/src/phy/fec/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -18,4 +18,4 @@ add_subdirectory(polar) add_subdirectory(test) add_subdirectory(turbo) -add_library(srslte_fec OBJECT ${FEC_SOURCES}) +add_library(srsran_fec OBJECT ${FEC_SOURCES}) diff --git a/lib/src/phy/fec/block/CMakeLists.txt b/lib/src/phy/fec/block/CMakeLists.txt index be0d876d9..00cba5262 100644 --- a/lib/src/phy/fec/block/CMakeLists.txt +++ b/lib/src/phy/fec/block/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of diff --git a/lib/src/phy/fec/block/block.c b/lib/src/phy/fec/block/block.c index 2ed378484..e69f5775b 100644 --- a/lib/src/phy/fec/block/block.c +++ b/lib/src/phy/fec/block/block.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,9 +10,9 @@ * */ -#include "srslte/phy/fec/block/block.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/fec/block/block.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" // The following MACRO enables/disables LUT for the decoder #define USE_LUT 1 @@ -21,7 +21,7 @@ typedef int16_t block_llr_t; /// Table 5.2.2.6.4-1: Basis sequence for (32, O) code compressed in uint16_t types -static const uint64_t M_basis_seq_b[SRSLTE_FEC_BLOCK_SIZE] = { +static const uint64_t M_basis_seq_b[SRSRAN_FEC_BLOCK_SIZE] = { 0b10000000011, 0b11000000111, 0b11101001001, 0b10100001101, 0b10010001111, 0b10111010011, 0b11101010101, 0b10110011001, 0b11010011011, 0b11001011101, 0b11011100101, 0b10101100111, 0b11110101001, 0b11010101011, 0b10010110001, 0b11011110011, 0b01001110111, 0b00100111001, 0b00011111011, 0b00001100001, 0b10001000101, @@ -32,7 +32,7 @@ static const uint64_t M_basis_seq_b[SRSLTE_FEC_BLOCK_SIZE] = { static inline uint8_t encode_M_basis_seq_u16(uint16_t w, uint32_t bit_idx) { // Apply mask - uint64_t d = w & M_basis_seq_b[bit_idx % SRSLTE_FEC_BLOCK_SIZE]; + uint64_t d = w & M_basis_seq_b[bit_idx % SRSRAN_FEC_BLOCK_SIZE]; // Compute parity using Bit Twiddling d ^= d >> 8UL; @@ -45,16 +45,16 @@ static inline uint8_t encode_M_basis_seq_u16(uint16_t w, uint32_t bit_idx) #if USE_LUT // Encoded unpacked table -static uint8_t block_unpacked_lut[1U << SRSLTE_FEC_BLOCK_MAX_NOF_BITS][SRSLTE_FEC_BLOCK_SIZE]; +static uint8_t block_unpacked_lut[1U << SRSRAN_FEC_BLOCK_MAX_NOF_BITS][SRSRAN_FEC_BLOCK_SIZE]; // LLR signed table -static block_llr_t block_llr_lut[1U << SRSLTE_FEC_BLOCK_MAX_NOF_BITS][SRSLTE_FEC_BLOCK_SIZE]; +static block_llr_t block_llr_lut[1U << SRSRAN_FEC_BLOCK_MAX_NOF_BITS][SRSRAN_FEC_BLOCK_SIZE]; // Initialization function, as the table is read-only after initialization, it can be initialised from constructor -__attribute__((constructor)) static void srslte_block_init() +__attribute__((constructor)) static void srsran_block_init() { - for (uint32_t word = 0; word < (1U << SRSLTE_FEC_BLOCK_MAX_NOF_BITS); word++) { - for (uint32_t i = 0; i < SRSLTE_FEC_BLOCK_SIZE; i++) { + for (uint32_t word = 0; word < (1U << SRSRAN_FEC_BLOCK_MAX_NOF_BITS); word++) { + for (uint32_t i = 0; i < SRSRAN_FEC_BLOCK_SIZE; i++) { uint8_t e = encode_M_basis_seq_u16(word, i); // Encoded unpacked byte block_unpacked_lut[word][i] = e; @@ -66,7 +66,7 @@ __attribute__((constructor)) static void srslte_block_init() } #endif -void srslte_block_encode(const uint8_t* input, uint32_t input_len, uint8_t* output, uint32_t output_len) +void srsran_block_encode(const uint8_t* input, uint32_t input_len, uint8_t* output, uint32_t output_len) { if (!input || !output) { ERROR("Invalid inputs"); @@ -74,7 +74,7 @@ void srslte_block_encode(const uint8_t* input, uint32_t input_len, uint8_t* outp } // Limit number of input bits - input_len = SRSLTE_MIN(input_len, SRSLTE_FEC_BLOCK_MAX_NOF_BITS); + input_len = SRSRAN_MIN(input_len, SRSRAN_FEC_BLOCK_MAX_NOF_BITS); // Pack input bits (reversed) uint16_t w = 0; @@ -85,18 +85,18 @@ void srslte_block_encode(const uint8_t* input, uint32_t input_len, uint8_t* outp // Encode bits #if USE_LUT uint32_t i = 0; - for (; i < output_len / SRSLTE_FEC_BLOCK_SIZE; i++) { - srslte_vec_u8_copy(&output[i * SRSLTE_FEC_BLOCK_SIZE], block_unpacked_lut[w], SRSLTE_FEC_BLOCK_SIZE); + for (; i < output_len / SRSRAN_FEC_BLOCK_SIZE; i++) { + srsran_vec_u8_copy(&output[i * SRSRAN_FEC_BLOCK_SIZE], block_unpacked_lut[w], SRSRAN_FEC_BLOCK_SIZE); } - srslte_vec_u8_copy(&output[i * SRSLTE_FEC_BLOCK_SIZE], block_unpacked_lut[w], output_len % SRSLTE_FEC_BLOCK_SIZE); + srsran_vec_u8_copy(&output[i * SRSRAN_FEC_BLOCK_SIZE], block_unpacked_lut[w], output_len % SRSRAN_FEC_BLOCK_SIZE); #else // USE_LUT - for (uint32_t i = 0; i < SRSLTE_MIN(output_len, SRSLTE_FEC_BLOCK_SIZE); i++) { + for (uint32_t i = 0; i < SRSRAN_MIN(output_len, SRSRAN_FEC_BLOCK_SIZE); i++) { output[i] = encode_M_basis_seq_u16(w, i); } // Avoid repeating operation by copying repeated sequence - for (uint32_t i = SRSLTE_FEC_BLOCK_SIZE; i < output_len; i++) { - output[i] = output[i % SRSLTE_FEC_BLOCK_SIZE]; + for (uint32_t i = SRSRAN_FEC_BLOCK_SIZE; i < output_len; i++) { + output[i] = output[i % SRSRAN_FEC_BLOCK_SIZE]; } #endif // USE_LUT } @@ -107,7 +107,7 @@ static int32_t block_decode(const block_llr_t* llr, uint8_t* data, uint32_t data uint32_t max_data = 0; //< Stores the word for maximum correlation // Limit data to maximum - data_len = SRSLTE_MIN(data_len, SRSLTE_FEC_BLOCK_MAX_NOF_BITS); + data_len = SRSRAN_MIN(data_len, SRSRAN_FEC_BLOCK_MAX_NOF_BITS); // Brute force all possible sequences uint16_t max_guess = (1U << data_len); //< Maximum guess bit combination (excluded) @@ -116,11 +116,11 @@ static int32_t block_decode(const block_llr_t* llr, uint8_t* data, uint32_t data #if USE_LUT // Load sequence from LUT // Dot product - for (uint32_t i = 0; i < SRSLTE_FEC_BLOCK_SIZE; i++) { + for (uint32_t i = 0; i < SRSRAN_FEC_BLOCK_SIZE; i++) { corr += llr[i] * block_llr_lut[guess][i]; } #else - for (uint32_t i = 0; i < SRSLTE_FEC_BLOCK_SIZE; i++) { + for (uint32_t i = 0; i < SRSRAN_FEC_BLOCK_SIZE; i++) { // On-the-fly sequence generation and product corr += llr[i] * (encode_M_basis_seq_u16(guess, i) * 2 - 1); } @@ -142,40 +142,40 @@ static int32_t block_decode(const block_llr_t* llr, uint8_t* data, uint32_t data return max_corr; } -int32_t srslte_block_decode_i8(const int8_t* llr, uint32_t nof_llr, uint8_t* data, uint32_t data_len) +int32_t srsran_block_decode_i8(const int8_t* llr, uint32_t nof_llr, uint8_t* data, uint32_t data_len) { - block_llr_t llr_[SRSLTE_FEC_BLOCK_SIZE] = {}; + block_llr_t llr_[SRSRAN_FEC_BLOCK_SIZE] = {}; // Return invalid inputs if data is not provided if (!llr || !data) { ERROR("Invalid inputs"); - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } // Accumulate all copies of the 32-length sequence for (uint32_t i = 0; i < nof_llr; i++) { - llr_[i % SRSLTE_FEC_BLOCK_SIZE] += (block_llr_t)llr[i]; + llr_[i % SRSRAN_FEC_BLOCK_SIZE] += (block_llr_t)llr[i]; } return block_decode(llr_, data, data_len); } -int32_t srslte_block_decode_i16(const int16_t* llr, uint32_t nof_llr, uint8_t* data, uint32_t data_len) +int32_t srsran_block_decode_i16(const int16_t* llr, uint32_t nof_llr, uint8_t* data, uint32_t data_len) { - block_llr_t llr_[SRSLTE_FEC_BLOCK_SIZE] = {}; + block_llr_t llr_[SRSRAN_FEC_BLOCK_SIZE] = {}; // Return invalid inputs if data is not provided if (!llr || !data) { ERROR("Invalid inputs"); - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } // Accumulate all copies of the 32-length sequence uint32_t i = 0; - for (; i < nof_llr / SRSLTE_FEC_BLOCK_SIZE; i++) { - srslte_vec_sum_sss(&llr[i * SRSLTE_FEC_BLOCK_SIZE], llr_, llr_, SRSLTE_FEC_BLOCK_SIZE); + for (; i < nof_llr / SRSRAN_FEC_BLOCK_SIZE; i++) { + srsran_vec_sum_sss(&llr[i * SRSRAN_FEC_BLOCK_SIZE], llr_, llr_, SRSRAN_FEC_BLOCK_SIZE); } - srslte_vec_sum_sss(&llr[i * SRSLTE_FEC_BLOCK_SIZE], llr_, llr_, nof_llr % SRSLTE_FEC_BLOCK_SIZE); + srsran_vec_sum_sss(&llr[i * SRSRAN_FEC_BLOCK_SIZE], llr_, llr_, nof_llr % SRSRAN_FEC_BLOCK_SIZE); return block_decode(llr_, data, data_len); } diff --git a/lib/src/phy/fec/block/test/CMakeLists.txt b/lib/src/phy/fec/block/test/CMakeLists.txt index 89098f865..c76cfec10 100644 --- a/lib/src/phy/fec/block/test/CMakeLists.txt +++ b/lib/src/phy/fec/block/test/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -11,7 +11,7 @@ ######################################################################## add_executable(block_test block_test.c) -target_link_libraries(block_test srslte_phy) +target_link_libraries(block_test srsran_phy) add_test(block_test_20 block_test -E 20) add_test(block_test_32 block_test -E 32) diff --git a/lib/src/phy/fec/block/test/block_test.c b/lib/src/phy/fec/block/test/block_test.c index 36a730fbf..470095536 100644 --- a/lib/src/phy/fec/block/test/block_test.c +++ b/lib/src/phy/fec/block/test/block_test.c @@ -2,19 +2,19 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of * the distribution. * */ -#include "srslte/common/test_common.h" -#include "srslte/phy/fec/block/block.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/random.h" +#include "srsran/common/test_common.h" +#include "srsran/phy/fec/block/block.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/random.h" #include -#include +#include #include #include #include @@ -23,16 +23,16 @@ static uint32_t seed = 0x1234; static uint32_t nof_repetitions = 1; -static uint32_t E = SRSLTE_FEC_BLOCK_SIZE; +static uint32_t E = SRSRAN_FEC_BLOCK_SIZE; static uint32_t A = 100; -static srslte_random_t random_gen = NULL; +static srsran_random_t random_gen = NULL; void usage(char* prog) { printf("Usage: %s [Rv]\n", prog); printf("\t-R Number of repetitions [Default %d]\n", nof_repetitions); printf("\t-E Number of encoded bits [Default %d]\n", E); - printf("\t-v increase verbose [Default %d]\n", srslte_verbose); + printf("\t-v increase verbose [Default %d]\n", srsran_verbose); } void parse_args(int argc, char** argv) @@ -47,7 +47,7 @@ void parse_args(int argc, char** argv) E = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'v': - srslte_verbose++; + srsran_verbose++; break; default: usage(argv[0]); @@ -59,20 +59,20 @@ void parse_args(int argc, char** argv) int test(uint32_t block_size) { struct timeval t[3] = {}; - uint8_t tx[SRSLTE_FEC_BLOCK_MAX_NOF_BITS] = {}; - uint8_t rx[SRSLTE_FEC_BLOCK_MAX_NOF_BITS] = {}; - uint8_t encoded[4 * SRSLTE_FEC_BLOCK_SIZE] = {}; - int16_t llr_i16[4 * SRSLTE_FEC_BLOCK_SIZE] = {}; - int8_t llr_i8[4 * SRSLTE_FEC_BLOCK_SIZE] = {}; + uint8_t tx[SRSRAN_FEC_BLOCK_MAX_NOF_BITS] = {}; + uint8_t rx[SRSRAN_FEC_BLOCK_MAX_NOF_BITS] = {}; + uint8_t encoded[4 * SRSRAN_FEC_BLOCK_SIZE] = {}; + int16_t llr_i16[4 * SRSRAN_FEC_BLOCK_SIZE] = {}; + int8_t llr_i8[4 * SRSRAN_FEC_BLOCK_SIZE] = {}; // Generate random data for (uint32_t i = 0; i < block_size; i++) { - tx[i] = (uint8_t)srslte_random_uniform_int_dist(random_gen, 0, 1); + tx[i] = (uint8_t)srsran_random_uniform_int_dist(random_gen, 0, 1); } gettimeofday(&t[1], NULL); for (uint32_t r = 0; r < nof_repetitions; r++) { - srslte_block_encode(tx, block_size, encoded, E); + srsran_block_encode(tx, block_size, encoded, E); } gettimeofday(&t[2], NULL); get_time_interval(t); @@ -88,7 +88,7 @@ int test(uint32_t block_size) gettimeofday(&t[1], NULL); for (uint32_t r = 0; r < nof_repetitions; r++) { - corr_i16 = srslte_block_decode_i16(llr_i16, E, rx, block_size); + corr_i16 = srsran_block_decode_i16(llr_i16, E, rx, block_size); } gettimeofday(&t[2], NULL); get_time_interval(t); @@ -99,7 +99,7 @@ int test(uint32_t block_size) gettimeofday(&t[1], NULL); int32_t corr_i8 = 0; for (uint32_t r = 0; r < nof_repetitions; r++) { - corr_i8 = srslte_block_decode_i8(llr_i8, E, rx, block_size); + corr_i8 = srsran_block_decode_i8(llr_i8, E, rx, block_size); } gettimeofday(&t[2], NULL); get_time_interval(t); @@ -118,19 +118,19 @@ int test(uint32_t block_size) t_decode_i8_us / (double)nof_repetitions, total_bits / (double)t_decode_i8_us); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int main(int argc, char** argv) { parse_args(argc, argv); - random_gen = srslte_random_init(seed); + random_gen = srsran_random_init(seed); - for (uint32_t block_size = 3; block_size <= SRSLTE_FEC_BLOCK_MAX_NOF_BITS; block_size++) { - if (test(block_size) < SRSLTE_SUCCESS) { + for (uint32_t block_size = 3; block_size <= SRSRAN_FEC_BLOCK_MAX_NOF_BITS; block_size++) { + if (test(block_size) < SRSRAN_SUCCESS) { break; } } - srslte_random_free(random_gen); + srsran_random_free(random_gen); } diff --git a/lib/src/phy/fec/cbsegm.c b/lib/src/phy/fec/cbsegm.c index 71740f5c0..58cb5e943 100644 --- a/lib/src/phy/fec/cbsegm.c +++ b/lib/src/phy/fec/cbsegm.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,17 +10,17 @@ * */ -#include "srslte/phy/fec/cbsegm.h" -#include "srslte/phy/fec/ldpc/base_graph.h" -#include "srslte/phy/fec/turbo/turbodecoder_gen.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/fec/cbsegm.h" +#include "srsran/phy/fec/ldpc/base_graph.h" +#include "srsran/phy/fec/turbo/turbodecoder_gen.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" #include /** * TS 36.212 V8.8.0 Table 5.1.3-3: Turbo code internal interleaver parameters */ -const uint32_t tc_cb_sizes[SRSLTE_NOF_TC_CB_SIZES] = { +const uint32_t tc_cb_sizes[SRSRAN_NOF_TC_CB_SIZES] = { 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 136, 144, 152, 160, 168, 176, 184, 192, 200, 208, 216, 224, 232, 240, 248, 256, 264, 272, 280, 288, 296, 304, 312, 320, 328, 336, 344, 352, 360, 368, 376, 384, 392, 400, 408, 416, 424, 432, 440, 448, 456, 464, 472, 480, 488, @@ -45,37 +45,37 @@ static void cbsegm_cb_size(uint32_t B, uint32_t Z, uint32_t* C, uint32_t* B_prim *C = 1; *B_prime = B; } else { - *C = SRSLTE_CEIL(B, (Z - 24U)); + *C = SRSRAN_CEIL(B, (Z - 24U)); *B_prime = B + 24U * (*C); } } -int srslte_cbsegm(srslte_cbsegm_t* s, uint32_t tbs) +int srsran_cbsegm(srsran_cbsegm_t* s, uint32_t tbs) { uint32_t Bp, B, idx1; int ret; if (tbs == 0) { - bzero(s, sizeof(srslte_cbsegm_t)); - ret = SRSLTE_SUCCESS; + bzero(s, sizeof(srsran_cbsegm_t)); + ret = SRSRAN_SUCCESS; } else { B = tbs + 24; s->tbs = tbs; // Calculate CB sizes - cbsegm_cb_size(B, SRSLTE_TCOD_MAX_LEN_CB, &s->C, &Bp); + cbsegm_cb_size(B, SRSRAN_TCOD_MAX_LEN_CB, &s->C, &Bp); - ret = srslte_cbsegm_cbindex((Bp - 1) / s->C + 1); - if (ret != SRSLTE_ERROR) { + ret = srsran_cbsegm_cbindex((Bp - 1) / s->C + 1); + if (ret != SRSRAN_ERROR) { idx1 = (uint32_t)ret; - ret = srslte_cbsegm_cbsize(idx1); - if (ret != SRSLTE_ERROR) { + ret = srsran_cbsegm_cbsize(idx1); + if (ret != SRSRAN_ERROR) { s->K1 = (uint32_t)ret; s->K1_idx = idx1; if (idx1 > 0) { - ret = srslte_cbsegm_cbsize(idx1 - 1); + ret = srsran_cbsegm_cbsize(idx1 - 1); } - if (ret != SRSLTE_ERROR) { + if (ret != SRSRAN_ERROR) { if (s->C == 1) { s->K2 = 0; s->K2_idx = 0; @@ -99,7 +99,7 @@ int srslte_cbsegm(srslte_cbsegm_t* s, uint32_t tbs) s->K2, s->F, Bp); - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } } } @@ -107,32 +107,32 @@ int srslte_cbsegm(srslte_cbsegm_t* s, uint32_t tbs) return ret; } -int srslte_cbsegm_cbindex(uint32_t long_cb) +int srsran_cbsegm_cbindex(uint32_t long_cb) { int j = 0; - while (j < SRSLTE_NOF_TC_CB_SIZES && tc_cb_sizes[j] < long_cb) { + while (j < SRSRAN_NOF_TC_CB_SIZES && tc_cb_sizes[j] < long_cb) { j++; } - if (j == SRSLTE_NOF_TC_CB_SIZES) { - return SRSLTE_ERROR; + if (j == SRSRAN_NOF_TC_CB_SIZES) { + return SRSRAN_ERROR; } else { return j; } } -int srslte_cbsegm_cbsize(uint32_t index) +int srsran_cbsegm_cbsize(uint32_t index) { - if (index < SRSLTE_NOF_TC_CB_SIZES) { + if (index < SRSRAN_NOF_TC_CB_SIZES) { return (int)tc_cb_sizes[index]; } else { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } -bool srslte_cbsegm_cbsize_isvalid(uint32_t size) +bool srsran_cbsegm_cbsize_isvalid(uint32_t size) { - for (int i = 0; i < SRSLTE_NOF_TC_CB_SIZES; i++) { + for (int i = 0; i < SRSRAN_NOF_TC_CB_SIZES; i++) { if (tc_cb_sizes[i] == size) { return true; } @@ -150,12 +150,12 @@ bool srslte_cbsegm_cbsize_isvalid(uint32_t size) static int cbsegm_ldpc_select_ls(uint32_t Kp, uint32_t K_b, uint32_t* Z_c, uint8_t* i_ls) { // Early return if the minimum required lift size is too high - if (SRSLTE_CEIL(Kp, K_b) > MAX_LIFTSIZE) { - return SRSLTE_ERROR; + if (SRSRAN_CEIL(Kp, K_b) > MAX_LIFTSIZE) { + return SRSRAN_ERROR; } // Iterate from the minimum required lift size to the maximum value - for (uint16_t Z = SRSLTE_CEIL(Kp, K_b); Z <= MAX_LIFTSIZE; Z++) { + for (uint16_t Z = SRSRAN_CEIL(Kp, K_b); Z <= MAX_LIFTSIZE; Z++) { // Get index for a selected lifting size uint8_t i = get_ls_index(Z); @@ -169,13 +169,13 @@ static int cbsegm_ldpc_select_ls(uint32_t Kp, uint32_t K_b, uint32_t* Z_c, uint8 *Z_c = Z; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Otherwise continue... } - return SRSLTE_ERROR; + return SRSRAN_ERROR; } /** @@ -186,7 +186,7 @@ static int cbsegm_ldpc_select_ls(uint32_t Kp, uint32_t K_b, uint32_t* Z_c, uint8 * @param tbs Transport block size * @return The TB CRC length L */ -static uint32_t srslte_cbsegm_ldpc_L(uint32_t tbs) +static uint32_t srsran_cbsegm_ldpc_L(uint32_t tbs) { if (tbs <= 3824) { return 16; @@ -195,24 +195,24 @@ static uint32_t srslte_cbsegm_ldpc_L(uint32_t tbs) return 24; } -static int srslte_cbsegm_ldpc(srslte_cbsegm_t* s, srslte_basegraph_t bg, uint32_t tbs) +static int srsran_cbsegm_ldpc(srsran_cbsegm_t* s, srsran_basegraph_t bg, uint32_t tbs) { // Check input pointer if (s == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } // Early return if no TBS is provided if (tbs == 0) { - bzero(s, sizeof(srslte_cbsegm_t)); - return SRSLTE_SUCCESS; + bzero(s, sizeof(srsran_cbsegm_t)); + return SRSRAN_SUCCESS; } // Calculate TB CRC length - uint32_t L = srslte_cbsegm_ldpc_L(tbs); + uint32_t L = srsran_cbsegm_ldpc_L(tbs); // Select maximum code block size - uint32_t K_cb = (bg == BG1) ? SRSLTE_LDPC_BG1_MAX_LEN_CB : SRSLTE_LDPC_BG2_MAX_LEN_CB; + uint32_t K_cb = (bg == BG1) ? SRSRAN_LDPC_BG1_MAX_LEN_CB : SRSRAN_LDPC_BG2_MAX_LEN_CB; // Calculate CB sizes uint32_t B = tbs + L; @@ -239,8 +239,8 @@ static int srslte_cbsegm_ldpc(srslte_cbsegm_t* s, srslte_basegraph_t bg, uint32_ uint8_t i_ls = 0; uint32_t Z_c = 0; int ret = cbsegm_ldpc_select_ls(Kp, K_b, &Z_c, &i_ls); - if (ret < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (ret < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } uint32_t K = Z_c * ((bg == BG1) ? 22U : 10U); @@ -262,15 +262,15 @@ static int srslte_cbsegm_ldpc(srslte_cbsegm_t* s, srslte_basegraph_t bg, uint32_ INFO("LDPC CB Segmentation: TBS: %d, C=%d, K=%d, F=%d, Bp=%d", tbs, s->C, s->K1, s->F, Bp); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_cbsegm_ldpc_bg1(srslte_cbsegm_t* s, uint32_t tbs) +int srsran_cbsegm_ldpc_bg1(srsran_cbsegm_t* s, uint32_t tbs) { - return srslte_cbsegm_ldpc(s, BG1, tbs); + return srsran_cbsegm_ldpc(s, BG1, tbs); } -int srslte_cbsegm_ldpc_bg2(srslte_cbsegm_t* s, uint32_t tbs) +int srsran_cbsegm_ldpc_bg2(srsran_cbsegm_t* s, uint32_t tbs) { - return srslte_cbsegm_ldpc(s, BG2, tbs); + return srsran_cbsegm_ldpc(s, BG2, tbs); } \ No newline at end of file diff --git a/lib/src/phy/fec/convolutional/CMakeLists.txt b/lib/src/phy/fec/convolutional/CMakeLists.txt index 2e12a3de0..59752d341 100644 --- a/lib/src/phy/fec/convolutional/CMakeLists.txt +++ b/lib/src/phy/fec/convolutional/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of diff --git a/lib/src/phy/fec/convolutional/convcoder.c b/lib/src/phy/fec/convolutional/convcoder.c index e4f20bc6a..234c757f0 100644 --- a/lib/src/phy/fec/convolutional/convcoder.c +++ b/lib/src/phy/fec/convolutional/convcoder.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -16,7 +16,7 @@ #include #include "parity.h" -#include "srslte/phy/fec/convolutional/convcoder.h" +#include "srsran/phy/fec/convolutional/convcoder.h" /** * Convolution encodes according to given parameters. @@ -31,7 +31,7 @@ * @param[in] frame_length Number of bits in input_array * @return Number of bits in output */ -int srslte_convcoder_encode(srslte_convcoder_t* q, uint8_t* input, uint8_t* output, uint32_t frame_length) +int srsran_convcoder_encode(srsran_convcoder_t* q, uint8_t* input, uint8_t* output, uint32_t frame_length) { uint32_t sr; uint32_t i, j; @@ -55,6 +55,6 @@ int srslte_convcoder_encode(srslte_convcoder_t* q, uint8_t* input, uint8_t* outp } return q->R * len; } else { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } } diff --git a/lib/src/phy/fec/convolutional/parity.c b/lib/src/phy/fec/convolutional/parity.c index 2ea7fff7b..75680b04f 100644 --- a/lib/src/phy/fec/convolutional/parity.c +++ b/lib/src/phy/fec/convolutional/parity.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/lib/src/phy/fec/convolutional/parity.h b/lib/src/phy/fec/convolutional/parity.h index a9cbc9569..40ebf86ee 100644 --- a/lib/src/phy/fec/convolutional/parity.h +++ b/lib/src/phy/fec/convolutional/parity.h @@ -2,15 +2,15 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of * the distribution. * */ -#ifndef SRSLTE_PARITY_H_ -#define SRSLTE_PARITY_H_ +#ifndef SRSRAN_PARITY_H_ +#define SRSRAN_PARITY_H_ #include @@ -47,4 +47,4 @@ static inline uint32_t parity(int x) return parityb(x); } -#endif /* SRSLTE_PARITY_H_ */ +#endif /* SRSRAN_PARITY_H_ */ diff --git a/lib/src/phy/fec/convolutional/test/CMakeLists.txt b/lib/src/phy/fec/convolutional/test/CMakeLists.txt index 56bc1b111..23607bc78 100644 --- a/lib/src/phy/fec/convolutional/test/CMakeLists.txt +++ b/lib/src/phy/fec/convolutional/test/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -11,7 +11,7 @@ ######################################################################## add_executable(viterbi_test viterbi_test.c) -target_link_libraries(viterbi_test srslte_phy) +target_link_libraries(viterbi_test srsran_phy) add_test(viterbi_40_0 viterbi_test -n 1000 -s 1 -l 40 -t -e 0.0) add_test(viterbi_40_2 viterbi_test -n 1000 -s 1 -l 40 -t -e 2.0) diff --git a/lib/src/phy/fec/convolutional/test/viterbi_test.c b/lib/src/phy/fec/convolutional/test/viterbi_test.c index 55cef2a53..990f0e9c3 100644 --- a/lib/src/phy/fec/convolutional/test/viterbi_test.c +++ b/lib/src/phy/fec/convolutional/test/viterbi_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,7 +11,7 @@ */ #include -#include +#include #include #include #include @@ -19,7 +19,7 @@ #include #include -#include "srslte/srslte.h" +#include "srsran/srsran.h" #include "viterbi_test.h" @@ -76,7 +76,7 @@ void parse_args(int argc, char** argv) gettimeofday(&t[1], NULL); \ for (uint32_t m = 0; m < M && NOF_ERRORS >= 0; m++) { \ int ret = FUNC(&DEC, LLR, data_rx, frame_length); \ - if (ret < SRSLTE_SUCCESS) { \ + if (ret < SRSRAN_SUCCESS) { \ NOF_ERRORS = ret; \ } \ } \ @@ -84,7 +84,7 @@ void parse_args(int argc, char** argv) get_time_interval(t); \ /*printf("-- "#FUNC" took\t\t%.1f us\n", (float) t[0].tv_sec * 1e6f + (float) t[0].tv_usec/M);*/ \ if (NOF_ERRORS >= 0) { \ - NOF_ERRORS += srslte_bit_diff(data_tx, data_rx, frame_length); \ + NOF_ERRORS += srsran_bit_diff(data_tx, data_rx, frame_length); \ } \ } while (0) @@ -106,10 +106,10 @@ int main(int argc, char** argv) int errors_f = 0; int errors_sse = 0; #ifdef TEST_SSE - srslte_viterbi_t dec_sse; + srsran_viterbi_t dec_sse; #endif - srslte_viterbi_t dec; - srslte_convcoder_t cod; + srsran_viterbi_t dec; + srsran_convcoder_t cod; int coded_length; parse_args(argc, argv); @@ -127,11 +127,11 @@ int main(int argc, char** argv) cod.R = 3; coded_length = cod.R * (frame_length + ((cod.tail_biting) ? 0 : cod.K - 1)); - srslte_viterbi_init(&dec, SRSLTE_VITERBI_37, cod.poly, frame_length, cod.tail_biting); + srsran_viterbi_init(&dec, SRSRAN_VITERBI_37, cod.poly, frame_length, cod.tail_biting); printf("Convolutional Code 1/3 K=%d Tail bitting: %s\n", cod.K, cod.tail_biting ? "yes" : "no"); #ifdef TEST_SSE - srslte_viterbi_init_sse(&dec_sse, SRSLTE_VITERBI_37, cod.poly, frame_length, cod.tail_biting); + srsran_viterbi_init_sse(&dec_sse, SRSRAN_VITERBI_37, cod.poly, frame_length, cod.tail_biting); #endif printf(" Frame length: %d\n", frame_length); @@ -139,39 +139,39 @@ int main(int argc, char** argv) printf(" EbNo: %.2f\n", ebno_db); } - data_tx = srslte_vec_u8_malloc(frame_length); + data_tx = srsran_vec_u8_malloc(frame_length); if (!data_tx) { perror("malloc"); exit(-1); } - data_rx = srslte_vec_u8_malloc(frame_length); + data_rx = srsran_vec_u8_malloc(frame_length); if (!data_rx) { perror("malloc"); exit(-1); } - symbols = srslte_vec_u8_malloc(coded_length); + symbols = srsran_vec_u8_malloc(coded_length); if (!symbols) { perror("malloc"); exit(-1); } - llr = srslte_vec_f_malloc(coded_length); + llr = srsran_vec_f_malloc(coded_length); if (!llr) { perror("malloc"); exit(-1); } - llr_s = srslte_vec_i16_malloc(2 * coded_length); + llr_s = srsran_vec_i16_malloc(2 * coded_length); if (!llr_s) { perror("malloc"); exit(-1); } - llr_us = srslte_vec_u16_malloc(2 * coded_length); + llr_us = srsran_vec_u16_malloc(2 * coded_length); if (!llr_us) { perror("malloc"); exit(-1); } - llr_c = srslte_vec_u8_malloc(2 * coded_length); + llr_c = srsran_vec_u8_malloc(2 * coded_length); if (!llr_c) { perror("malloc"); exit(-1); @@ -183,14 +183,14 @@ int main(int argc, char** argv) snr_points = SNR_POINTS; for (uint32_t i = 0; i < snr_points; i++) { ebno_db = SNR_MIN + i * ebno_inc; - esno_db = ebno_db + srslte_convert_power_to_dB(1.0f / 3.0f); - var[i] = srslte_convert_dB_to_amplitude(esno_db); - varunc[i] = srslte_convert_dB_to_amplitude(ebno_db); + esno_db = ebno_db + srsran_convert_power_to_dB(1.0f / 3.0f); + var[i] = srsran_convert_dB_to_amplitude(esno_db); + varunc[i] = srsran_convert_dB_to_amplitude(ebno_db); } } else { - esno_db = ebno_db + srslte_convert_power_to_dB(1.0f / 3.0f); - var[0] = srslte_convert_dB_to_amplitude(esno_db); - varunc[0] = srslte_convert_dB_to_amplitude(ebno_db); + esno_db = ebno_db + srsran_convert_power_to_dB(1.0f / 3.0f); + var[0] = srsran_convert_dB_to_amplitude(esno_db); + varunc[0] = srsran_convert_dB_to_amplitude(ebno_db); snr_points = 1; } @@ -202,38 +202,38 @@ int main(int argc, char** argv) errors_sse = 0; while (frame_cnt < nof_frames) { /* generate data_tx */ - srslte_random_t random_gen = srslte_random_init(0); + srsran_random_t random_gen = srsran_random_init(0); for (int j = 0; j < frame_length; j++) { - data_tx[j] = srslte_random_uniform_int_dist(random_gen, 0, 1); + data_tx[j] = srsran_random_uniform_int_dist(random_gen, 0, 1); } - srslte_random_free(random_gen); + srsran_random_free(random_gen); /* uncoded BER */ for (int j = 0; j < frame_length; j++) { llr[j] = data_tx[j] ? M_SQRT2 : -M_SQRT2; } - srslte_ch_awgn_f(llr, llr, varunc[i], frame_length); + srsran_ch_awgn_f(llr, llr, varunc[i], frame_length); /* coded BER */ - srslte_convcoder_encode(&cod, data_tx, symbols, frame_length); + srsran_convcoder_encode(&cod, data_tx, symbols, frame_length); for (int j = 0; j < coded_length; j++) { llr[j] = symbols[j] ? M_SQRT2 : -M_SQRT2; } - srslte_ch_awgn_f(llr, llr, var[i], coded_length); - // srslte_vec_fprint_f(stdout, llr, 100); + srsran_ch_awgn_f(llr, llr, var[i], coded_length); + // srsran_vec_fprint_f(stdout, llr, 100); - srslte_vec_convert_fi(llr, 1000, llr_s, coded_length); - srslte_vec_quant_fuc(llr, llr_c, 32, INT8_MAX, UINT8_MAX, coded_length); - srslte_vec_quant_fus(llr, llr_us, 8192, INT16_MAX, UINT16_MAX, coded_length); + srsran_vec_convert_fi(llr, 1000, llr_s, coded_length); + srsran_vec_quant_fuc(llr, llr_c, 32, INT8_MAX, UINT8_MAX, coded_length); + srsran_vec_quant_fus(llr, llr_us, 8192, INT16_MAX, UINT16_MAX, coded_length); - VITERBI_TEST(srslte_viterbi_decode_s, dec, llr_s, errors_s); - VITERBI_TEST(srslte_viterbi_decode_us, dec, llr_us, errors_us); - VITERBI_TEST(srslte_viterbi_decode_uc, dec, llr_c, errors_c); - VITERBI_TEST(srslte_viterbi_decode_f, dec, llr, errors_f); + VITERBI_TEST(srsran_viterbi_decode_s, dec, llr_s, errors_s); + VITERBI_TEST(srsran_viterbi_decode_us, dec, llr_us, errors_us); + VITERBI_TEST(srsran_viterbi_decode_uc, dec, llr_c, errors_c); + VITERBI_TEST(srsran_viterbi_decode_f, dec, llr, errors_f); #ifdef TEST_SSE - VITERBI_TEST(srslte_viterbi_decode_uc, dec_sse, llr_c, errors_sse); + VITERBI_TEST(srsran_viterbi_decode_uc, dec_sse, llr_c, errors_sse); #endif frame_cnt++; printf(" Eb/No: %3.2f %10d/%d ", SNR_MIN + i * ebno_inc, frame_cnt, nof_frames); @@ -266,9 +266,9 @@ int main(int argc, char** argv) #endif } } - srslte_viterbi_free(&dec); + srsran_viterbi_free(&dec); #ifdef TEST_SSE - srslte_viterbi_free(&dec_sse); + srsran_viterbi_free(&dec_sse); #endif free(data_tx); diff --git a/lib/src/phy/fec/convolutional/test/viterbi_test.h b/lib/src/phy/fec/convolutional/test/viterbi_test.h index f25d42e36..db8da02fd 100644 --- a/lib/src/phy/fec/convolutional/test/viterbi_test.h +++ b/lib/src/phy/fec/convolutional/test/viterbi_test.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/lib/src/phy/fec/convolutional/viterbi.c b/lib/src/phy/fec/convolutional/viterbi.c index 323d09863..a346ebc7e 100644 --- a/lib/src/phy/fec/convolutional/viterbi.c +++ b/lib/src/phy/fec/convolutional/viterbi.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -18,9 +18,9 @@ #include #include "parity.h" -#include "srslte/phy/fec/convolutional/viterbi.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/fec/convolutional/viterbi.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" #include "viterbi37.h" #define DEB 0 @@ -40,7 +40,7 @@ int decode37(void* o, uint8_t* symbols, uint8_t* data, uint32_t frame_length) { - srslte_viterbi_t* q = o; + srsran_viterbi_t* q = o; uint32_t best_state; @@ -71,7 +71,7 @@ int decode37(void* o, uint8_t* symbols, uint8_t* data, uint32_t frame_length) #ifdef LV_HAVE_SSE int decode37_sse(void* o, uint8_t* symbols, uint8_t* data, uint32_t frame_length) { - srslte_viterbi_t* q = o; + srsran_viterbi_t* q = o; uint32_t best_state; @@ -101,7 +101,7 @@ int decode37_sse(void* o, uint8_t* symbols, uint8_t* data, uint32_t frame_length void free37_sse(void* o) { - srslte_viterbi_t* q = o; + srsran_viterbi_t* q = o; if (q->symbols_uc) { free(q->symbols_uc); } @@ -119,7 +119,7 @@ void free37_sse(void* o) #ifdef LV_HAVE_AVX2 int decode37_avx2_16bit(void* o, uint16_t* symbols, uint8_t* data, uint32_t frame_length) { - srslte_viterbi_t* q = o; + srsran_viterbi_t* q = o; uint32_t best_state; @@ -149,7 +149,7 @@ int decode37_avx2_16bit(void* o, uint16_t* symbols, uint8_t* data, uint32_t fram void free37_avx2_16bit(void* o) { - srslte_viterbi_t* q = o; + srsran_viterbi_t* q = o; if (q->symbols_uc) { free(q->symbols_uc); @@ -168,7 +168,7 @@ void free37_avx2_16bit(void* o) int decode37_avx2(void* o, uint8_t* symbols, uint8_t* data, uint32_t frame_length) { - srslte_viterbi_t* q = o; + srsran_viterbi_t* q = o; uint32_t best_state; @@ -196,7 +196,7 @@ int decode37_avx2(void* o, uint8_t* symbols, uint8_t* data, uint32_t frame_lengt void free37_avx2(void* o) { - srslte_viterbi_t* q = o; + srsran_viterbi_t* q = o; if (q->symbols_uc) { free(q->symbols_uc); } @@ -211,7 +211,7 @@ void free37_avx2(void* o) #ifdef HAVE_NEON int decode37_neon(void* o, uint8_t* symbols, uint8_t* data, uint32_t frame_length) { - srslte_viterbi_t* q = o; + srsran_viterbi_t* q = o; uint32_t best_state; @@ -241,7 +241,7 @@ int decode37_neon(void* o, uint8_t* symbols, uint8_t* data, uint32_t frame_lengt void free37_neon(void* o) { - srslte_viterbi_t* q = o; + srsran_viterbi_t* q = o; if (q->symbols_uc) { free(q->symbols_uc); } @@ -255,7 +255,7 @@ void free37_neon(void* o) void free37(void* o) { - srslte_viterbi_t* q = o; + srsran_viterbi_t* q = o; if (q->symbols_uc) { free(q->symbols_uc); } @@ -265,7 +265,7 @@ void free37(void* o) delete_viterbi37_port(q->ptr); } -int init37(srslte_viterbi_t* q, int poly[3], uint32_t framebits, bool tail_biting) +int init37(srsran_viterbi_t* q, int poly[3], uint32_t framebits, bool tail_biting) { q->K = 7; q->R = 3; @@ -276,13 +276,13 @@ int init37(srslte_viterbi_t* q, int poly[3], uint32_t framebits, bool tail_bitin q->decode = decode37; q->free = free37; q->decode_f = NULL; - q->symbols_uc = srslte_vec_u8_malloc(3 * (q->framebits + q->K - 1)); + q->symbols_uc = srsran_vec_u8_malloc(3 * (q->framebits + q->K - 1)); if (!q->symbols_uc) { perror("malloc"); return -1; } if (q->tail_biting) { - q->tmp = srslte_vec_u8_malloc(TB_ITER * 3 * (q->framebits + q->K - 1)); + q->tmp = srsran_vec_u8_malloc(TB_ITER * 3 * (q->framebits + q->K - 1)); bzero(q->tmp, 3 * (q->framebits + q->K - 1) * sizeof(uint8_t)); if (!q->tmp) { perror("malloc"); @@ -303,7 +303,7 @@ int init37(srslte_viterbi_t* q, int poly[3], uint32_t framebits, bool tail_bitin } #ifdef LV_HAVE_SSE -int init37_sse(srslte_viterbi_t* q, int poly[3], uint32_t framebits, bool tail_biting) +int init37_sse(srsran_viterbi_t* q, int poly[3], uint32_t framebits, bool tail_biting) { q->K = 7; q->R = 3; @@ -314,20 +314,20 @@ int init37_sse(srslte_viterbi_t* q, int poly[3], uint32_t framebits, bool tail_b q->decode = decode37_sse; q->free = free37_sse; q->decode_f = NULL; - q->symbols_uc = srslte_vec_u8_malloc(3 * (q->framebits + q->K - 1)); + q->symbols_uc = srsran_vec_u8_malloc(3 * (q->framebits + q->K - 1)); if (!q->symbols_uc) { perror("malloc"); return -1; } #ifdef VITERBI_16 - q->symbols_us = srslte_vec_u16_malloc(3 * (q->framebits + q->K - 1)); + q->symbols_us = srsran_vec_u16_malloc(3 * (q->framebits + q->K - 1)); if (!q->symbols_us) { perror("malloc"); return -1; } #endif if (q->tail_biting) { - q->tmp = srslte_vec_u8_malloc(TB_ITER * 3 * (q->framebits + q->K - 1)); + q->tmp = srsran_vec_u8_malloc(TB_ITER * 3 * (q->framebits + q->K - 1)); if (!q->tmp) { perror("malloc"); free37(q); @@ -348,7 +348,7 @@ int init37_sse(srslte_viterbi_t* q, int poly[3], uint32_t framebits, bool tail_b #endif #ifdef HAVE_NEON -int init37_neon(srslte_viterbi_t* q, int poly[3], uint32_t framebits, bool tail_biting) +int init37_neon(srsran_viterbi_t* q, int poly[3], uint32_t framebits, bool tail_biting) { q->K = 7; q->R = 3; @@ -359,13 +359,13 @@ int init37_neon(srslte_viterbi_t* q, int poly[3], uint32_t framebits, bool tail_ q->decode = decode37_neon; q->free = free37_neon; q->decode_f = NULL; - q->symbols_uc = srslte_vec_u8_malloc(3 * (q->framebits + q->K - 1)); + q->symbols_uc = srsran_vec_u8_malloc(3 * (q->framebits + q->K - 1)); if (!q->symbols_uc) { perror("malloc"); return -1; } if (q->tail_biting) { - q->tmp = srslte_vec_u8_malloc(TB_ITER * 3 * (q->framebits + q->K - 1)); + q->tmp = srsran_vec_u8_malloc(TB_ITER * 3 * (q->framebits + q->K - 1)); if (!q->tmp) { perror("malloc"); free37(q); @@ -386,7 +386,7 @@ int init37_neon(srslte_viterbi_t* q, int poly[3], uint32_t framebits, bool tail_ #endif #ifdef LV_HAVE_AVX2 -int init37_avx2(srslte_viterbi_t* q, int poly[3], uint32_t framebits, bool tail_biting) +int init37_avx2(srsran_viterbi_t* q, int poly[3], uint32_t framebits, bool tail_biting) { q->K = 7; q->R = 3; @@ -397,13 +397,13 @@ int init37_avx2(srslte_viterbi_t* q, int poly[3], uint32_t framebits, bool tail_ q->decode = decode37_avx2; q->free = free37_avx2; q->decode_f = NULL; - q->symbols_uc = srslte_vec_u8_malloc(3 * (q->framebits + q->K - 1)); + q->symbols_uc = srsran_vec_u8_malloc(3 * (q->framebits + q->K - 1)); if (!q->symbols_uc) { perror("malloc"); return -1; } if (q->tail_biting) { - q->tmp = srslte_vec_u8_malloc(TB_ITER * 3 * (q->framebits + q->K - 1)); + q->tmp = srsran_vec_u8_malloc(TB_ITER * 3 * (q->framebits + q->K - 1)); if (!q->tmp) { perror("malloc"); free37(q); @@ -422,7 +422,7 @@ int init37_avx2(srslte_viterbi_t* q, int poly[3], uint32_t framebits, bool tail_ } } -int init37_avx2_16bit(srslte_viterbi_t* q, int poly[3], uint32_t framebits, bool tail_biting) +int init37_avx2_16bit(srsran_viterbi_t* q, int poly[3], uint32_t framebits, bool tail_biting) { q->K = 7; q->R = 3; @@ -433,15 +433,15 @@ int init37_avx2_16bit(srslte_viterbi_t* q, int poly[3], uint32_t framebits, bool q->decode_s = decode37_avx2_16bit; q->free = free37_avx2_16bit; q->decode_f = NULL; - q->symbols_uc = srslte_vec_u8_malloc(3 * (q->framebits + q->K - 1)); - q->symbols_us = srslte_vec_u16_malloc(3 * (q->framebits + q->K - 1)); + q->symbols_uc = srsran_vec_u8_malloc(3 * (q->framebits + q->K - 1)); + q->symbols_us = srsran_vec_u16_malloc(3 * (q->framebits + q->K - 1)); if (!q->symbols_uc || !q->symbols_us) { perror("malloc"); return -1; } if (q->tail_biting) { - q->tmp = srslte_vec_u8_malloc(TB_ITER * 3 * (q->framebits + q->K - 1)); - q->tmp_s = srslte_vec_u16_malloc(TB_ITER * 3 * (q->framebits + q->K - 1)); + q->tmp = srsran_vec_u8_malloc(TB_ITER * 3 * (q->framebits + q->K - 1)); + q->tmp_s = srsran_vec_u16_malloc(TB_ITER * 3 * (q->framebits + q->K - 1)); if (!q->tmp) { perror("malloc"); free37(q); @@ -462,25 +462,25 @@ int init37_avx2_16bit(srslte_viterbi_t* q, int poly[3], uint32_t framebits, bool #endif -void srslte_viterbi_set_gain_quant(srslte_viterbi_t* q, float gain_quant) +void srsran_viterbi_set_gain_quant(srsran_viterbi_t* q, float gain_quant) { q->gain_quant = gain_quant; } -void srslte_viterbi_set_gain_quant_s(srslte_viterbi_t* q, int16_t gain_quant) +void srsran_viterbi_set_gain_quant_s(srsran_viterbi_t* q, int16_t gain_quant) { q->gain_quant_s = gain_quant; } -int srslte_viterbi_init(srslte_viterbi_t* q, - srslte_viterbi_type_t type, +int srsran_viterbi_init(srsran_viterbi_t* q, + srsran_viterbi_type_t type, int poly[3], uint32_t max_frame_length, bool tail_bitting) { - bzero(q, sizeof(srslte_viterbi_t)); + bzero(q, sizeof(srsran_viterbi_t)); switch (type) { - case SRSLTE_VITERBI_37: + case SRSRAN_VITERBI_37: #ifdef LV_HAVE_SSE #ifdef LV_HAVE_AVX2 @@ -506,8 +506,8 @@ int srslte_viterbi_init(srslte_viterbi_t* q, } #ifdef LV_HAVE_SSE -int srslte_viterbi_init_sse(srslte_viterbi_t* q, - srslte_viterbi_type_t type, +int srsran_viterbi_init_sse(srsran_viterbi_t* q, + srsran_viterbi_type_t type, int poly[3], uint32_t max_frame_length, bool tail_bitting) @@ -517,8 +517,8 @@ int srslte_viterbi_init_sse(srslte_viterbi_t* q, #endif #ifdef LV_HAVE_AVX2 -int srslte_viterbi_init_avx2(srslte_viterbi_t* q, - srslte_viterbi_type_t type, +int srsran_viterbi_init_avx2(srsran_viterbi_t* q, + srsran_viterbi_type_t type, int poly[3], uint32_t max_frame_length, bool tail_bitting) @@ -527,16 +527,16 @@ int srslte_viterbi_init_avx2(srslte_viterbi_t* q, } #endif -void srslte_viterbi_free(srslte_viterbi_t* q) +void srsran_viterbi_free(srsran_viterbi_t* q) { if (q->free) { q->free(q); } - bzero(q, sizeof(srslte_viterbi_t)); + bzero(q, sizeof(srsran_viterbi_t)); } /* symbols are real-valued */ -int srslte_viterbi_decode_f(srslte_viterbi_t* q, float* symbols, uint8_t* data, uint32_t frame_length) +int srsran_viterbi_decode_f(srsran_viterbi_t* q, float* symbols, uint8_t* data, uint32_t frame_length) { uint32_t len; if (frame_length > q->framebits) { @@ -556,11 +556,11 @@ int srslte_viterbi_decode_f(srslte_viterbi_t* q, float* symbols, uint8_t* data, } } #ifdef VITERBI_16 - srslte_vec_quant_fus(symbols, q->symbols_us, q->gain_quant / max, 32767.5, 65535, len); - return srslte_viterbi_decode_us(q, q->symbols_us, data, frame_length); + srsran_vec_quant_fus(symbols, q->symbols_us, q->gain_quant / max, 32767.5, 65535, len); + return srsran_viterbi_decode_us(q, q->symbols_us, data, frame_length); #else - srslte_vec_quant_fuc(symbols, q->symbols_uc, q->gain_quant / max, 127.5, 255, len); - return srslte_viterbi_decode_uc(q, q->symbols_uc, data, frame_length); + srsran_vec_quant_fuc(symbols, q->symbols_uc, q->gain_quant / max, 127.5, 255, len); + return srsran_viterbi_decode_uc(q, q->symbols_uc, data, frame_length); #endif } else { return q->decode_f(q, symbols, data, frame_length); @@ -568,7 +568,7 @@ int srslte_viterbi_decode_f(srslte_viterbi_t* q, float* symbols, uint8_t* data, } /* symbols are int16 */ -int srslte_viterbi_decode_s(srslte_viterbi_t* q, int16_t* symbols, uint8_t* data, uint32_t frame_length) +int srsran_viterbi_decode_s(srsran_viterbi_t* q, int16_t* symbols, uint8_t* data, uint32_t frame_length) { uint32_t len; if (frame_length > q->framebits) { @@ -588,17 +588,17 @@ int srslte_viterbi_decode_s(srslte_viterbi_t* q, int16_t* symbols, uint8_t* data } } #ifdef VITERBI_16 - srslte_vec_quant_sus(symbols, q->symbols_us, 1, (float)INT16_MAX, UINT16_MAX, len); - return srslte_viterbi_decode_us(q, q->symbols_us, data, frame_length); + srsran_vec_quant_sus(symbols, q->symbols_us, 1, (float)INT16_MAX, UINT16_MAX, len); + return srsran_viterbi_decode_us(q, q->symbols_us, data, frame_length); #else - srslte_vec_quant_suc(symbols, q->symbols_uc, (float)q->gain_quant / max, 127, 255, len); - return srslte_viterbi_decode_uc(q, q->symbols_uc, data, frame_length); + srsran_vec_quant_suc(symbols, q->symbols_uc, (float)q->gain_quant / max, 127, 255, len); + return srsran_viterbi_decode_uc(q, q->symbols_uc, data, frame_length); #endif } -int srslte_viterbi_decode_us(srslte_viterbi_t* q, uint16_t* symbols, uint8_t* data, uint32_t frame_length) +int srsran_viterbi_decode_us(srsran_viterbi_t* q, uint16_t* symbols, uint8_t* data, uint32_t frame_length) { - int ret = SRSLTE_ERROR; + int ret = SRSRAN_ERROR; if (q && q->decode_s) { ret = q->decode_s(q, symbols, data, frame_length); @@ -607,9 +607,9 @@ int srslte_viterbi_decode_us(srslte_viterbi_t* q, uint16_t* symbols, uint8_t* da return ret; } -int srslte_viterbi_decode_uc(srslte_viterbi_t* q, uint8_t* symbols, uint8_t* data, uint32_t frame_length) +int srsran_viterbi_decode_uc(srsran_viterbi_t* q, uint8_t* symbols, uint8_t* data, uint32_t frame_length) { - int ret = SRSLTE_ERROR; + int ret = SRSRAN_ERROR; if (q && q->decode) { ret = q->decode(q, symbols, data, frame_length); diff --git a/lib/src/phy/fec/convolutional/viterbi37.h b/lib/src/phy/fec/convolutional/viterbi37.h index 37d2d51cc..20a5152c3 100644 --- a/lib/src/phy/fec/convolutional/viterbi37.h +++ b/lib/src/phy/fec/convolutional/viterbi37.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,8 +10,8 @@ * */ -#ifndef SRSLTE_VITERBI37_H_ -#define SRSLTE_VITERBI37_H_ +#ifndef SRSRAN_VITERBI37_H_ +#define SRSRAN_VITERBI37_H_ #include @@ -73,4 +73,4 @@ void delete_viterbi37_avx2_16bit(void* p); int update_viterbi37_blk_avx2_16bit(void* p, uint16_t* syms, uint32_t nbits, uint32_t* best_state); -#endif /* SRSLTE_VITERBI37_H_ */ +#endif /* SRSRAN_VITERBI37_H_ */ diff --git a/lib/src/phy/fec/crc.c b/lib/src/phy/fec/crc.c index 0a9b68930..6c4da1d8e 100644 --- a/lib/src/phy/fec/crc.c +++ b/lib/src/phy/fec/crc.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,11 +10,11 @@ * */ -#include "srslte/phy/fec/crc.h" -#include "srslte/phy/utils/bit.h" -#include "srslte/phy/utils/debug.h" +#include "srsran/phy/fec/crc.h" +#include "srsran/phy/utils/bit.h" +#include "srsran/phy/utils/debug.h" -static void gen_crc_table(srslte_crc_t* h) +static void gen_crc_table(srsran_crc_t* h) { uint32_t pad = (h->order < 8) ? (8 - h->order) : 0; uint32_t ord = h->order + pad - 8; @@ -34,7 +34,7 @@ static void gen_crc_table(srslte_crc_t* h) } } -uint64_t reversecrcbit(uint32_t crc, int nbits, srslte_crc_t* h) +uint64_t reversecrcbit(uint32_t crc, int nbits, srsran_crc_t* h) { uint64_t m, rmask = 0x1; @@ -47,7 +47,7 @@ uint64_t reversecrcbit(uint32_t crc, int nbits, srslte_crc_t* h) return (crc & h->crcmask); } -int srslte_crc_set_init(srslte_crc_t* crc_par, uint64_t crc_init_value) +int srsran_crc_set_init(srsran_crc_t* crc_par, uint64_t crc_init_value) { crc_par->crcinit = crc_init_value; if (crc_par->crcinit != (crc_par->crcinit & crc_par->crcmask)) { @@ -57,7 +57,7 @@ int srslte_crc_set_init(srslte_crc_t* crc_par, uint64_t crc_init_value) return 0; } -int srslte_crc_init(srslte_crc_t* h, uint32_t crc_poly, int crc_order) +int srsran_crc_init(srsran_crc_t* h, uint32_t crc_poly, int crc_order) { // Set crc working default parameters h->polynom = crc_poly; @@ -68,7 +68,7 @@ int srslte_crc_init(srslte_crc_t* h, uint32_t crc_poly, int crc_order) h->crcmask = ((((uint64_t)1 << (h->order - 1)) - 1) << 1) | 1; h->crchighbit = (uint64_t)1 << (h->order - 1); - if (srslte_crc_set_init(h, h->crcinit)) { + if (srsran_crc_set_init(h, h->crcinit)) { ERROR("Error setting CRC init word"); return -1; } @@ -79,13 +79,13 @@ int srslte_crc_init(srslte_crc_t* h, uint32_t crc_poly, int crc_order) return 0; } -uint32_t srslte_crc_checksum(srslte_crc_t* h, uint8_t* data, int len) +uint32_t srsran_crc_checksum(srsran_crc_t* h, uint8_t* data, int len) { int i, k, len8, res8, a = 0; uint32_t crc = 0; uint8_t* pter; - srslte_crc_set_init(h, 0); + srsran_crc_set_init(h, 0); // Pack bits into bytes len8 = (len >> 3); @@ -104,11 +104,11 @@ uint32_t srslte_crc_checksum(srslte_crc_t* h, uint8_t* data, int len) byte |= ((uint8_t) * (pter + k)) << (7 - k); } } else { - byte = (uint8_t)(srslte_bit_pack(&pter, 8) & 0xFF); + byte = (uint8_t)(srsran_bit_pack(&pter, 8) & 0xFF); } - srslte_crc_checksum_put_byte(h, byte); + srsran_crc_checksum_put_byte(h, byte); } - crc = (uint32_t)srslte_crc_checksum_get(h); + crc = (uint32_t)srsran_crc_checksum_get(h); // Reverse CRC res8 positions if (a == 1) { @@ -120,25 +120,25 @@ uint32_t srslte_crc_checksum(srslte_crc_t* h, uint8_t* data, int len) } // len is multiple of 8 -uint32_t srslte_crc_checksum_byte(srslte_crc_t* h, const uint8_t* data, int len) +uint32_t srsran_crc_checksum_byte(srsran_crc_t* h, const uint8_t* data, int len) { int i; uint32_t crc = 0; - srslte_crc_set_init(h, 0); + srsran_crc_set_init(h, 0); // Calculate CRC for (i = 0; i < len / 8; i++) { - srslte_crc_checksum_put_byte(h, data[i]); + srsran_crc_checksum_put_byte(h, data[i]); } - crc = (uint32_t)srslte_crc_checksum_get(h); + crc = (uint32_t)srsran_crc_checksum_get(h); return crc; } -uint32_t srslte_crc_attach_byte(srslte_crc_t* h, uint8_t* data, int len) +uint32_t srsran_crc_attach_byte(srsran_crc_t* h, uint8_t* data, int len) { - uint32_t checksum = srslte_crc_checksum_byte(h, data, len); + uint32_t checksum = srsran_crc_checksum_byte(h, data, len); // Add CRC for (int i = 0; i < h->order / 8; i++) { @@ -150,12 +150,12 @@ uint32_t srslte_crc_attach_byte(srslte_crc_t* h, uint8_t* data, int len) /** Appends crc_order checksum bits to the buffer data. * The buffer data must be len + crc_order bytes */ -uint32_t srslte_crc_attach(srslte_crc_t* h, uint8_t* data, int len) +uint32_t srsran_crc_attach(srsran_crc_t* h, uint8_t* data, int len) { - uint32_t checksum = srslte_crc_checksum(h, data, len); + uint32_t checksum = srsran_crc_checksum(h, data, len); // Add CRC uint8_t* ptr = &data[len]; - srslte_bit_unpack(checksum, &ptr, h->order); + srsran_bit_unpack(checksum, &ptr, h->order); return checksum; } diff --git a/lib/src/phy/fec/ldpc/CMakeLists.txt b/lib/src/phy/fec/ldpc/CMakeLists.txt index 5ae7551e6..02d811113 100644 --- a/lib/src/phy/fec/ldpc/CMakeLists.txt +++ b/lib/src/phy/fec/ldpc/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of diff --git a/lib/src/phy/fec/ldpc/base_graph.c b/lib/src/phy/fec/ldpc/base_graph.c index b7bde7e52..b1b387601 100644 --- a/lib/src/phy/fec/ldpc/base_graph.c +++ b/lib/src/phy/fec/ldpc/base_graph.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -29,8 +29,8 @@ #include -#include "srslte/phy/fec/ldpc/base_graph.h" -#include "srslte/phy/utils/debug.h" +#include "srsran/phy/fec/ldpc/base_graph.h" +#include "srsran/phy/utils/debug.h" /*! * \brief Lifting size look-up table. @@ -4450,12 +4450,12 @@ static const int8_t BG2_positions[BG2M][MAX_CNCT] = { /*! * Returns a pointer to the desired variation of the selected base graph. */ -static inline const uint16_t* get_cnct_matrix(srslte_basegraph_t bg, uint8_t ls) +static inline const uint16_t* get_cnct_matrix(srsran_basegraph_t bg, uint8_t ls) { return (bg == BG1 ? (const uint16_t*)BG1_matrices[ls] : (const uint16_t*)BG2_matrices[ls]); } -int create_compact_pcm(uint16_t* pcm, int8_t (*positions)[MAX_CNCT], srslte_basegraph_t bg, uint16_t ls) +int create_compact_pcm(uint16_t* pcm, int8_t (*positions)[MAX_CNCT], srsran_basegraph_t bg, uint16_t ls) { uint8_t ls_index = 0; uint16_t value = 0; diff --git a/lib/src/phy/fec/ldpc/ldpc_avx2_consts.h b/lib/src/phy/fec/ldpc/ldpc_avx2_consts.h index 6c7f435df..5e91d7787 100644 --- a/lib/src/phy/fec/ldpc/ldpc_avx2_consts.h +++ b/lib/src/phy/fec/ldpc/ldpc_avx2_consts.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -84,7 +84,7 @@ static const __m256i mask_even_epi8 = {0x00FF00FF00FF00FF, * \brief Mask needed for node rotation: mask_least_epi8[i] marks the bits * corresponding to the \b i least significant chars. */ -static const __m256i mask_least_epi8[SRSLTE_AVX2_B_SIZE + 1] = { +static const __m256i mask_least_epi8[SRSRAN_AVX2_B_SIZE + 1] = { {0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000}, // NOLINT {0x00000000000000FF, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000}, // NOLINT {0x000000000000FFFF, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000}, // NOLINT @@ -121,9 +121,9 @@ static const __m256i mask_least_epi8[SRSLTE_AVX2_B_SIZE + 1] = { /*! * \brief Mask needed for node rotation: mask_most_epi8[i] marks the bits - * corresponding to the SRSLTE_AVX2_B_SIZE - \b i most significant chars. + * corresponding to the SRSRAN_AVX2_B_SIZE - \b i most significant chars. */ -static const __m256i mask_most_epi8[SRSLTE_AVX2_B_SIZE + 1] = { +static const __m256i mask_most_epi8[SRSRAN_AVX2_B_SIZE + 1] = { {0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF}, // NOLINT {0xFFFFFFFFFFFFFF00, 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF}, // NOLINT {0xFFFFFFFFFFFF0000, 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF}, // NOLINT diff --git a/lib/src/phy/fec/ldpc/ldpc_avx512_consts.h b/lib/src/phy/fec/ldpc/ldpc_avx512_consts.h index 5251a2e4c..b3e1a40dd 100644 --- a/lib/src/phy/fec/ldpc/ldpc_avx512_consts.h +++ b/lib/src/phy/fec/ldpc/ldpc_avx512_consts.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/lib/src/phy/fec/ldpc/ldpc_dec_all.h b/lib/src/phy/fec/ldpc/ldpc_dec_all.h index 1527cf5b8..a8deceb67 100644 --- a/lib/src/phy/fec/ldpc/ldpc_dec_all.h +++ b/lib/src/phy/fec/ldpc/ldpc_dec_all.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -20,10 +20,10 @@ * */ -#ifndef SRSLTE_LDPCDEC_ALL_H -#define SRSLTE_LDPCDEC_ALL_H +#ifndef SRSRAN_LDPCDEC_ALL_H +#define SRSRAN_LDPCDEC_ALL_H -#include +#include #include /*! @@ -307,21 +307,21 @@ int extract_ldpc_message_c_flood(void* p, uint8_t* message, uint16_t liftK); /*! * Creates the registers used by the optimized 8-bit-based implementation of the LDPC decoder (LS <= \ref - * SRSLTE_AVX2_B_SIZE). \param[in] bgN Codeword length. \param[in] bgM Number of check nodes. + * SRSRAN_AVX2_B_SIZE). \param[in] bgN Codeword length. \param[in] bgM Number of check nodes. * \param[in] ls Lifting size. \param[in] scaling_fctr Scaling factor of the normalized min-sum algorithm. * \return A pointer to the created registers (an ldpc_regs_c_avx2 structure). */ void* create_ldpc_dec_c_avx2(uint8_t bgN, uint8_t bgM, uint16_t ls, float scaling_fctr); /*! - * Destroys the inner registers of the optimized 8-bit integer-based LDPC decoder (LS <= \ref SRSLTE_AVX2_B_SIZE). + * Destroys the inner registers of the optimized 8-bit integer-based LDPC decoder (LS <= \ref SRSRAN_AVX2_B_SIZE). * \param[in] p A pointer to the dismantled decoder registers (an ldpc_regs_c_avx2 structure). */ void delete_ldpc_dec_c_avx2(void* p); /*! * Initializes the inner registers of the optimized 8-bit integer-based LDPC decoder before - * carrying out the actual decoding (LS <= \ref SRSLTE_AVX2_B_SIZE). + * carrying out the actual decoding (LS <= \ref SRSRAN_AVX2_B_SIZE). * \param[in,out] p A pointer to the decoder registers (an ldpc_regs_c_avx2 structure). * \param[in] llrs A pointer to the array of LLR values from the channel. * \param[in] ls The lifting size. @@ -330,7 +330,7 @@ void delete_ldpc_dec_c_avx2(void* p); int init_ldpc_dec_c_avx2(void* p, const int8_t* llrs, uint16_t ls); /*! - * Updates the messages from variable nodes to check nodes (optimized 8-bit version, LS <= \ref SRSLTE_AVX2_B_SIZE). + * Updates the messages from variable nodes to check nodes (optimized 8-bit version, LS <= \ref SRSRAN_AVX2_B_SIZE). * \param[in,out] p A pointer to the decoder registers (an ldpc_regs_c_avx2 structure). * \param[in] i_layer The index of the variable-to-check layer to update. * \return An integer: 0 if the function executes correctly, -1 otherwise. @@ -338,7 +338,7 @@ int init_ldpc_dec_c_avx2(void* p, const int8_t* llrs, uint16_t ls); int update_ldpc_var_to_check_c_avx2(void* p, int i_layer); /*! - * Updates the messages from check nodes to variable nodes (optimized 8-bit version, LS <= \ref SRSLTE_AVX2_B_SIZE). + * Updates the messages from check nodes to variable nodes (optimized 8-bit version, LS <= \ref SRSRAN_AVX2_B_SIZE). * \param[in,out] p A pointer to the decoder registers (an ldpc_regs_c_avx2 structure). * \param[in] i_layer The index of the variable-to-check layer to update. * \param[in] this_pcm A pointer to the row of the parity check matrix (i.e. base @@ -355,7 +355,7 @@ int update_ldpc_check_to_var_c_avx2(void* p, /*! * Updates the current estimate of the (soft) bits of the codeword (optimized 8-bit version, LS <= \ref - * SRSLTE_AVX2_B_SIZE). \param[in,out] p A pointer to the decoder registers (an ldpc_regs_c_avx2 structure). + * SRSRAN_AVX2_B_SIZE). \param[in,out] p A pointer to the decoder registers (an ldpc_regs_c_avx2 structure). * \param[in] i_layer The index of the variable-to-check layer to update. * \param[in] these_var_indices * Contains the indices of the variable nodes connected @@ -366,7 +366,7 @@ int update_ldpc_soft_bits_c_avx2(void* p, int i_layer, const int8_t (*these_var_ /*! * Returns the decoded message (hard bits) from the current soft bits (optimized 8-bit version, LS <= \ref - * SRSLTE_AVX2_B_SIZE). + * SRSRAN_AVX2_B_SIZE). * \param[in] p A pointer to the decoder registers (an ldpc_regs_c_avx2 structure). * \param[out] message A pointer to the decoded message. * \param[in] liftK The length of the decoded message. @@ -376,7 +376,7 @@ int extract_ldpc_message_c_avx2(void* p, uint8_t* message, uint16_t liftK); /*! * Creates the registers used by the optimized 8-bit-based implementation of the LDPC decoder (LS > \ref - * SRSLTE_AVX2_B_SIZE). + * SRSRAN_AVX2_B_SIZE). * \param[in] bgN Codeword length. \param[in] bgM Number of check nodes. * \param[in] ls Lifting size. \param[in] scaling_fctr Scaling factor of the normalized min-sum algorithm. * \return A pointer to the created registers (an ldpc_regs_c_avx2long structure). @@ -384,14 +384,14 @@ int extract_ldpc_message_c_avx2(void* p, uint8_t* message, uint16_t liftK); void* create_ldpc_dec_c_avx2long(uint8_t bgN, uint8_t bgM, uint16_t ls, float scaling_fctr); /*! - * Destroys the inner registers of the optimized 8-bit integer-based LDPC decoder (LS > \ref SRSLTE_AVX2_B_SIZE). + * Destroys the inner registers of the optimized 8-bit integer-based LDPC decoder (LS > \ref SRSRAN_AVX2_B_SIZE). * \param[in] p A pointer to the dismantled decoder registers (an ldpc_regs_c_avx2long structure). */ void delete_ldpc_dec_c_avx2long(void* p); /*! * Initializes the inner registers of the optimized 8-bit integer-based LDPC decoder before - * carrying out the actual decoding (LS > \ref SRSLTE_AVX2_B_SIZE). + * carrying out the actual decoding (LS > \ref SRSRAN_AVX2_B_SIZE). * \param[in,out] p A pointer to the decoder registers (an ldpc_regs_c_avx2long structure). * \param[in] llrs A pointer to the array of LLR values from the channel. * \param[in] ls The lifting size. @@ -400,7 +400,7 @@ void delete_ldpc_dec_c_avx2long(void* p); int init_ldpc_dec_c_avx2long(void* p, const int8_t* llrs, uint16_t ls); /*! - * Updates the messages from variable nodes to check nodes (optimized 8-bit version, LS > \ref SRSLTE_AVX2_B_SIZE). + * Updates the messages from variable nodes to check nodes (optimized 8-bit version, LS > \ref SRSRAN_AVX2_B_SIZE). * \param[in,out] p A pointer to the decoder registers (an ldpc_regs_c_avx2long structure). * \param[in] i_layer The index of the variable-to-check layer to update. * \return An integer: 0 if the function executes correctly, -1 otherwise. @@ -408,7 +408,7 @@ int init_ldpc_dec_c_avx2long(void* p, const int8_t* llrs, uint16_t ls); int update_ldpc_var_to_check_c_avx2long(void* p, int i_layer); /*! - * Updates the messages from check nodes to variable nodes (optimized 8-bit version, LS > \ref SRSLTE_AVX2_B_SIZE). + * Updates the messages from check nodes to variable nodes (optimized 8-bit version, LS > \ref SRSRAN_AVX2_B_SIZE). * \param[in,out] p A pointer to the decoder registers (an ldpc_regs_c_avx2long structure). * \param[in] i_layer The index of the variable-to-check layer to update. * \param[in] this_pcm A pointer to the row of the parity check matrix (i.e. base @@ -425,7 +425,7 @@ int update_ldpc_check_to_var_c_avx2long(void* p, /*! * Updates the current estimate of the (soft) bits of the codeword (optimized 8-bit version, LS > \ref - * SRSLTE_AVX2_B_SIZE). \param[in,out] p A pointer to the decoder registers (an ldpc_regs_c_avx2long structure). + * SRSRAN_AVX2_B_SIZE). \param[in,out] p A pointer to the decoder registers (an ldpc_regs_c_avx2long structure). * \param[in] i_layer The index of the variable-to-check layer to update. * \param[in] these_var_indices * Contains the indices of the variable nodes connected @@ -436,7 +436,7 @@ int update_ldpc_soft_bits_c_avx2long(void* p, int i_layer, const int8_t (*these_ /*! * Returns the decoded message (hard bits) from the current soft bits (optimized 8-bit version, LS > \ref - * SRSLTE_AVX2_B_SIZE). \param[in] p A pointer to the decoder registers (an ldpc_regs_c_avx2long structure). + * SRSRAN_AVX2_B_SIZE). \param[in] p A pointer to the decoder registers (an ldpc_regs_c_avx2long structure). * \param[out] message A pointer to the decoded message. * \param[in] liftK The length of the decoded message. * \return An integer: 0 if the function executes correctly, -1 otherwise. @@ -445,7 +445,7 @@ int extract_ldpc_message_c_avx2long(void* p, uint8_t* message, uint16_t liftK); /*! * Creates the registers used by the optimized 8-bit-based implementation of the LDPC decoder - * (flooded scheduling, LS <= \ref SRSLTE_AVX2_B_SIZE). + * (flooded scheduling, LS <= \ref SRSRAN_AVX2_B_SIZE). * \param[in] bgN Codeword length. * \param[in] bgM Number of check nodes. * \param[in] ls Lifting size. @@ -456,14 +456,14 @@ void* create_ldpc_dec_c_avx2_flood(uint8_t bgN, uint8_t bgM, uint16_t ls, float /*! * Destroys the inner registers of the optimized 8-bit integer-based LDPC decoder - * (flooded scheduling, LS <= \ref SRSLTE_AVX2_B_SIZE). + * (flooded scheduling, LS <= \ref SRSRAN_AVX2_B_SIZE). * \param[in] p A pointer to the dismantled decoder registers (an ldpc_regs_c_avx2_flood structure). */ void delete_ldpc_dec_c_avx2_flood(void* p); /*! * Initializes the inner registers of the optimized 8-bit integer-based LDPC decoder before - * carrying out the actual decoding (flooded scheduling, LS <= \ref SRSLTE_AVX2_B_SIZE). + * carrying out the actual decoding (flooded scheduling, LS <= \ref SRSRAN_AVX2_B_SIZE). * \param[in,out] p A pointer to the decoder registers (an ldpc_regs_c_avx2_flood structure). * \param[in] llrs A pointer to the array of LLR values from the channel. * \param[in] ls The lifting size. @@ -472,7 +472,7 @@ void delete_ldpc_dec_c_avx2_flood(void* p); int init_ldpc_dec_c_avx2_flood(void* p, const int8_t* llrs, uint16_t ls); /*! - * Updates the messages from variable nodes to check nodes (optimized 8-bit version, LS <= \ref SRSLTE_AVX2_B_SIZE). + * Updates the messages from variable nodes to check nodes (optimized 8-bit version, LS <= \ref SRSRAN_AVX2_B_SIZE). * \param[in,out] p A pointer to the decoder registers (an ldpc_regs_c_avx2_flood structure). * \param[in] i_layer The index of the variable-to-check layer to update. * \return An integer: 0 if the function executes correctly, -1 otherwise. @@ -481,7 +481,7 @@ int update_ldpc_var_to_check_c_avx2_flood(void* p, int i_layer); /*! * Updates the messages from check nodes to variable nodes - * (optimized 8-bit version, flooded scheduling, LS <= \ref SRSLTE_AVX2_B_SIZE). + * (optimized 8-bit version, flooded scheduling, LS <= \ref SRSRAN_AVX2_B_SIZE). * \param[in,out] p A pointer to the decoder registers (an ldpc_regs_c_avx2_flood structure). * \param[in] i_layer The index of the variable-to-check layer to update. * \param[in] this_pcm A pointer to the row of the parity check matrix (i.e. base @@ -498,7 +498,7 @@ int update_ldpc_check_to_var_c_avx2_flood(void* p, /*! * Updates the current estimate of the (soft) bits of the codeword - * (optimized 8-bit version, flooded scheduling, LS <= \ref SRSLTE_AVX2_B_SIZE). + * (optimized 8-bit version, flooded scheduling, LS <= \ref SRSRAN_AVX2_B_SIZE). * \param[in,out] p A pointer to the decoder registers (an ldpc_regs_c_avx2_flood structure). * \param[in] these_var_indices * Contains the indices of the variable nodes connected @@ -509,7 +509,7 @@ int update_ldpc_soft_bits_c_avx2_flood(void* p, const int8_t (*these_var_indices /*! * Returns the decoded message (hard bits) from the current soft bits - * (flooded scheduling, optimized 8-bit version, LS <= \ref SRSLTE_AVX2_B_SIZE). + * (flooded scheduling, optimized 8-bit version, LS <= \ref SRSRAN_AVX2_B_SIZE). * \param[in] p A pointer to the decoder registers (an ldpc_regs_c_avx2_flood structure). * \param[out] message A pointer to the decoded message. * \param[in] liftK The length of the decoded message. @@ -519,7 +519,7 @@ int extract_ldpc_message_c_avx2_flood(void* p, uint8_t* message, uint16_t liftK) /*! * Creates the registers used by the optimized 8-bit-based implementation of the LDPC decoder - * (flooded scheduling, LS > \ref SRSLTE_AVX2_B_SIZE). + * (flooded scheduling, LS > \ref SRSRAN_AVX2_B_SIZE). * \param[in] bgN Codeword length. * \param[in] bgM Number of check nodes. * \param[in] ls Lifting size. @@ -530,14 +530,14 @@ void* create_ldpc_dec_c_avx2long_flood(uint8_t bgN, uint8_t bgM, uint16_t ls, fl /*! * Destroys the inner registers of the optimized 8-bit integer-based LDPC decoder (flooded scheduling, LS > \ref - * SRSLTE_AVX2_B_SIZE). \param[in] p A pointer to the dismantled decoder registers (an ldpc_regs_c_avx2long_flood + * SRSRAN_AVX2_B_SIZE). \param[in] p A pointer to the dismantled decoder registers (an ldpc_regs_c_avx2long_flood * structure). */ void delete_ldpc_dec_c_avx2long_flood(void* p); /*! * Initializes the inner registers of the optimized 8-bit integer-based LDPC decoder before - * carrying out the actual decoding (flooded scheduling, LS > \ref SRSLTE_AVX2_B_SIZE). + * carrying out the actual decoding (flooded scheduling, LS > \ref SRSRAN_AVX2_B_SIZE). * \param[in,out] p A pointer to the decoder registers (an ldpc_regs_c_avx2long_flood structure). * \param[in] llrs A pointer to the array of LLR values from the channel. * \param[in] ls The lifting size. @@ -547,7 +547,7 @@ int init_ldpc_dec_c_avx2long_flood(void* p, const int8_t* llrs, uint16_t ls); /*! * Updates the messages from variable nodes to check nodes (optimized 8-bit version, - * flooded scheduling, LS > \ref SRSLTE_AVX2_B_SIZE). + * flooded scheduling, LS > \ref SRSRAN_AVX2_B_SIZE). * \param[in,out] p A pointer to the decoder registers (an ldpc_regs_c_avx2long_flood structure). * \param[in] i_layer The index of the variable-to-check layer to update. * \return An integer: 0 if the function executes correctly, -1 otherwise. @@ -556,7 +556,7 @@ int update_ldpc_var_to_check_c_avx2long_flood(void* p, int i_layer); /*! * Updates the messages from check nodes to variable nodes (optimized 8-bit version, - * flooded scheduling, LS > \ref SRSLTE_AVX2_B_SIZE). + * flooded scheduling, LS > \ref SRSRAN_AVX2_B_SIZE). * \param[in,out] p A pointer to the decoder registers (an ldpc_regs_c_avx2long_flood structure). * \param[in] i_layer The index of the variable-to-check layer to update. * \param[in] this_pcm A pointer to the row of the parity check matrix (i.e. base @@ -573,7 +573,7 @@ int update_ldpc_check_to_var_c_avx2long_flood(void* p, /*! * Updates the current estimate of the (soft) bits of the codeword (optimized 8-bit version, - * flooded scheduling, LS > \ref SRSLTE_AVX2_B_SIZE). + * flooded scheduling, LS > \ref SRSRAN_AVX2_B_SIZE). * \param[in,out] p A pointer to the decoder registers (an ldpc_regs_c_avx2long_flood structure). * \param[in] these_var_indices * Contains the indices of the variable nodes connected @@ -584,7 +584,7 @@ int update_ldpc_soft_bits_c_avx2long_flood(void* p, const int8_t (*these_var_ind /*! * Returns the decoded message (hard bits) from the current soft bits (optimized 8-bit version, - * flooded scheduling, LS > \ref SRSLTE_AVX2_B_SIZE). + * flooded scheduling, LS > \ref SRSRAN_AVX2_B_SIZE). * \param[in] p A pointer to the decoder registers (an ldpc_regs_c_avx2long_flood structure). * \param[out] message A pointer to the decoded message. * \param[in] liftK The length of the decoded message. @@ -594,21 +594,21 @@ int extract_ldpc_message_c_avx2long_flood(void* p, uint8_t* message, uint16_t li /*! * Creates the registers used by the optimized 8-bit-based implementation of the LDPC decoder (LS > \ref - * SRSLTE_AVX512_B_SIZE). \param[in] bgN Codeword length. \param[in] bgM Number of check nodes. + * SRSRAN_AVX512_B_SIZE). \param[in] bgN Codeword length. \param[in] bgM Number of check nodes. * \param[in] ls Lifting size. \param[in] scaling_fctr Scaling factor of the normalized min-sum algorithm. * \return A pointer to the created registers (an ldpc_regs_c_avx512long structure). */ void* create_ldpc_dec_c_avx512long(uint8_t bgN, uint8_t bgM, uint16_t ls, float scaling_fctr); /*! - * Destroys the inner registers of the optimized 8-bit integer-based LDPC decoder (LS > \ref SRSLTE_AVX512_B_SIZE). + * Destroys the inner registers of the optimized 8-bit integer-based LDPC decoder (LS > \ref SRSRAN_AVX512_B_SIZE). * \param[in] p A pointer to the dismantled decoder registers (an ldpc_regs_c_avx512long structure). */ void delete_ldpc_dec_c_avx512long(void* p); /*! * Initializes the inner registers of the optimized 8-bit integer-based LDPC decoder before - * carrying out the actual decoding (LS > \ref SRSLTE_AVX512_B_SIZE). + * carrying out the actual decoding (LS > \ref SRSRAN_AVX512_B_SIZE). * \param[in,out] p A pointer to the decoder registers (an ldpc_regs_c_avx512long structure). * \param[in] llrs A pointer to the array of LLR values from the channel. * \param[in] ls The lifting size. @@ -617,7 +617,7 @@ void delete_ldpc_dec_c_avx512long(void* p); int init_ldpc_dec_c_avx512long(void* p, const int8_t* llrs, uint16_t ls); /*! - * Updates the messages from variable nodes to check nodes (optimized 8-bit version, LS > \ref SRSLTE_AVX512_B_SIZE). + * Updates the messages from variable nodes to check nodes (optimized 8-bit version, LS > \ref SRSRAN_AVX512_B_SIZE). * \param[in,out] p A pointer to the decoder registers (an ldpc_regs_c_avx512long structure). * \param[in] i_layer The index of the variable-to-check layer to update. * \return An integer: 0 if the function executes correctly, -1 otherwise. @@ -625,7 +625,7 @@ int init_ldpc_dec_c_avx512long(void* p, const int8_t* llrs, uint16_t ls); int update_ldpc_var_to_check_c_avx512long(void* p, int i_layer); /*! - * Updates the messages from check nodes to variable nodes (optimized 8-bit version, LS > \ref SRSLTE_AVX512_B_SIZE). + * Updates the messages from check nodes to variable nodes (optimized 8-bit version, LS > \ref SRSRAN_AVX512_B_SIZE). * \param[in,out] p A pointer to the decoder registers (an ldpc_regs_c_avx512long structure). * \param[in] i_layer The index of the variable-to-check layer to update. * \param[in] this_pcm A pointer to the row of the parity check matrix (i.e. base @@ -642,7 +642,7 @@ int update_ldpc_check_to_var_c_avx512long(void* p, /*! * Updates the current estimate of the (soft) bits of the codeword (optimized 8-bit version, LS > \ref - * SRSLTE_AVX512_B_SIZE). + * SRSRAN_AVX512_B_SIZE). * \param[in,out] p A pointer to the decoder registers (an ldpc_regs_c_avx512long structure). * \param[in] i_layer The index of the variable-to-check layer to update. * \param[in] these_var_indices Contains the indices of the variable nodes connected to the current layer. @@ -652,7 +652,7 @@ int update_ldpc_soft_bits_c_avx512long(void* p, int i_layer, const int8_t (*thes /*! * Returns the decoded message (hard bits) from the current soft bits (optimized 8-bit version, LS > \ref - * SRSLTE_AVX512_B_SIZE). + * SRSRAN_AVX512_B_SIZE). * \param[in] p A pointer to the decoder registers (an ldpc_regs_c_avx512long structure). * \param[out] message A pointer to the decoded message. * \param[in] liftK The length of the decoded message. @@ -662,7 +662,7 @@ int extract_ldpc_message_c_avx512long(void* p, uint8_t* message, uint16_t liftK) /*! * Creates the registers used by the optimized 8-bit-based implementation of the LDPC decoder (LS <= \ref - * SRSLTE_AVX512_B_SIZE). + * SRSRAN_AVX512_B_SIZE). * \param[in] bgN Codeword length. \param[in] bgM Number of check nodes. * \param[in] ls Lifting size. \param[in] scaling_fctr Scaling factor of the normalized min-sum algorithm. * \return A pointer to the created registers (an ldpc_regs_c_avx512 structure). @@ -670,14 +670,14 @@ int extract_ldpc_message_c_avx512long(void* p, uint8_t* message, uint16_t liftK) void* create_ldpc_dec_c_avx512(uint8_t bgN, uint8_t bgM, uint16_t ls, float scaling_fctr); /*! - * Destroys the inner registers of the optimized 8-bit integer-based LDPC decoder (LS <= \ref SRSLTE_AVX512_B_SIZE). + * Destroys the inner registers of the optimized 8-bit integer-based LDPC decoder (LS <= \ref SRSRAN_AVX512_B_SIZE). * \param[in] p A pointer to the dismantled decoder registers (an ldpc_regs_c_avx512 structure). */ void delete_ldpc_dec_c_avx512(void* p); /*! * Initializes the inner registers of the optimized 8-bit integer-based LDPC decoder before - * carrying out the actual decoding (LS <= \ref SRSLTE_AVX512_B_SIZE). + * carrying out the actual decoding (LS <= \ref SRSRAN_AVX512_B_SIZE). * \param[in,out] p A pointer to the decoder registers (an ldpc_regs_c_avx512 structure). * \param[in] llrs A pointer to the array of LLR values from the channel. * \param[in] ls The lifting size. @@ -686,7 +686,7 @@ void delete_ldpc_dec_c_avx512(void* p); int init_ldpc_dec_c_avx512(void* p, const int8_t* llrs, uint16_t ls); /*! - * Updates the messages from variable nodes to check nodes (optimized 8-bit version, LS <= \ref SRSLTE_AVX512_B_SIZE). + * Updates the messages from variable nodes to check nodes (optimized 8-bit version, LS <= \ref SRSRAN_AVX512_B_SIZE). * \param[in,out] p A pointer to the decoder registers (an ldpc_regs_c_avx512 structure). * \param[in] i_layer The index of the variable-to-check layer to update. * \return An integer: 0 if the function executes correctly, -1 otherwise. @@ -694,7 +694,7 @@ int init_ldpc_dec_c_avx512(void* p, const int8_t* llrs, uint16_t ls); int update_ldpc_var_to_check_c_avx512(void* p, int i_layer); /*! - * Updates the messages from check nodes to variable nodes (optimized 8-bit version, LS <= \ref SRSLTE_AVX512_B_SIZE). + * Updates the messages from check nodes to variable nodes (optimized 8-bit version, LS <= \ref SRSRAN_AVX512_B_SIZE). * \param[in,out] p A pointer to the decoder registers (an ldpc_regs_c_avx512 structure). * \param[in] i_layer The index of the variable-to-check layer to update. * \param[in] this_pcm A pointer to the row of the parity check matrix (i.e. base @@ -711,7 +711,7 @@ int update_ldpc_check_to_var_c_avx512(void* p, /*! * Updates the current estimate of the (soft) bits of the codeword (optimized 8-bit version, LS <= \ref - * SRSLTE_AVX512_B_SIZE). \param[in,out] p A pointer to the decoder registers (an ldpc_regs_c_avx512 structure). + * SRSRAN_AVX512_B_SIZE). \param[in,out] p A pointer to the decoder registers (an ldpc_regs_c_avx512 structure). * \param[in] i_layer The index of the variable-to-check layer to update. * \param[in] these_var_indices * Contains the indices of the variable nodes connected @@ -722,7 +722,7 @@ int update_ldpc_soft_bits_c_avx512(void* p, int i_layer, const int8_t (*these_va /*! * Returns the decoded message (hard bits) from the current soft bits (optimized 8-bit version, LS <= \ref - * SRSLTE_AVX512_B_SIZE). \param[in] p A pointer to the decoder registers (an ldpc_regs_c_avx512 structure). + * SRSRAN_AVX512_B_SIZE). \param[in] p A pointer to the decoder registers (an ldpc_regs_c_avx512 structure). * \param[out] message A pointer to the decoded message. * \param[in] liftK The length of the decoded message. * \return An integer: 0 if the function executes correctly, -1 otherwise. @@ -731,7 +731,7 @@ int extract_ldpc_message_c_avx512(void* p, uint8_t* message, uint16_t liftK); /*! * Creates the registers used by the optimized 8-bit-based implementation of the LDPC decoder - * (flooded scheduling, LS > \ref SRSLTE_AVX512_B_SIZE). + * (flooded scheduling, LS > \ref SRSRAN_AVX512_B_SIZE). * \param[in] bgN Codeword length. * \param[in] bgM Number of check nodes. * \param[in] ls Lifting size. @@ -742,14 +742,14 @@ void* create_ldpc_dec_c_avx512long_flood(uint8_t bgN, uint8_t bgM, uint16_t ls, /*! * Destroys the inner registers of the optimized 8-bit integer-based LDPC decoder (flooded scheduling, LS > \ref - * SRSLTE_AVX512_B_SIZE). \param[in] p A pointer to the dismantled decoder registers (an ldpc_regs_c_avx512long_flood + * SRSRAN_AVX512_B_SIZE). \param[in] p A pointer to the dismantled decoder registers (an ldpc_regs_c_avx512long_flood * structure). */ void delete_ldpc_dec_c_avx512long_flood(void* p); /*! * Initializes the inner registers of the optimized 8-bit integer-based LDPC decoder before - * carrying out the actual decoding (flooded scheduling, LS > \ref SRSLTE_AVX512_B_SIZE). + * carrying out the actual decoding (flooded scheduling, LS > \ref SRSRAN_AVX512_B_SIZE). * \param[in,out] p A pointer to the decoder registers (an ldpc_regs_c_avx512long_flood structure). * \param[in] llrs A pointer to the array of LLR values from the channel. * \param[in] ls The lifting size. @@ -759,7 +759,7 @@ int init_ldpc_dec_c_avx512long_flood(void* p, const int8_t* llrs, uint16_t ls); /*! * Updates the messages from variable nodes to check nodes (optimized 8-bit version, - * flooded scheduling, LS > \ref SRSLTE_AVX512_B_SIZE). + * flooded scheduling, LS > \ref SRSRAN_AVX512_B_SIZE). * \param[in,out] p A pointer to the decoder registers (an ldpc_regs_c_avx512long_flood structure). * \param[in] i_layer The index of the variable-to-check layer to update. * \return An integer: 0 if the function executes correctly, -1 otherwise. @@ -768,7 +768,7 @@ int update_ldpc_var_to_check_c_avx512long_flood(void* p, int i_layer); /*! * Updates the messages from check nodes to variable nodes (optimized 8-bit version, - * flooded scheduling, LS > \ref SRSLTE_AVX512_B_SIZE). + * flooded scheduling, LS > \ref SRSRAN_AVX512_B_SIZE). * \param[in,out] p A pointer to the decoder registers (an ldpc_regs_c_avx512long_flood structure). * \param[in] i_layer The index of the variable-to-check layer to update. * \param[in] this_pcm A pointer to the row of the parity check matrix (i.e. base @@ -785,7 +785,7 @@ int update_ldpc_check_to_var_c_avx512long_flood(void* p, /*! * Updates the current estimate of the (soft) bits of the codeword (optimized 8-bit version, - * flooded scheduling, LS > \ref SRSLTE_AVX512_B_SIZE). + * flooded scheduling, LS > \ref SRSRAN_AVX512_B_SIZE). * \param[in,out] p A pointer to the decoder registers (an ldpc_regs_c_avx512long_flood structure). * \param[in] these_var_indices * Contains the indices of the variable nodes connected @@ -796,7 +796,7 @@ int update_ldpc_soft_bits_c_avx512long_flood(void* p, const int8_t (*these_var_i /*! * Returns the decoded message (hard bits) from the current soft bits (optimized 8-bit version, - * flooded scheduling, LS > \ref SRSLTE_AVX512_B_SIZE). + * flooded scheduling, LS > \ref SRSRAN_AVX512_B_SIZE). * \param[in] p A pointer to the decoder registers (an ldpc_regs_c_avx512long_flood structure). * \param[out] message A pointer to the decoded message. * \param[in] liftK The length of the decoded message. @@ -804,4 +804,4 @@ int update_ldpc_soft_bits_c_avx512long_flood(void* p, const int8_t (*these_var_i */ int extract_ldpc_message_c_avx512long_flood(void* p, uint8_t* message, uint16_t liftK); -#endif // SRSLTE_LDPCDEC_ALL_H +#endif // SRSRAN_LDPCDEC_ALL_H diff --git a/lib/src/phy/fec/ldpc/ldpc_dec_c.c b/lib/src/phy/fec/ldpc/ldpc_dec_c.c index 5a5f015c3..bfb1d6c1b 100644 --- a/lib/src/phy/fec/ldpc/ldpc_dec_c.c +++ b/lib/src/phy/fec/ldpc/ldpc_dec_c.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -31,8 +31,8 @@ #include #include "ldpc_dec_all.h" -#include "srslte/phy/fec/ldpc/base_graph.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/fec/ldpc/base_graph.h" +#include "srsran/phy/utils/vector.h" #define F2I 100 /*!< \brief Used for float to int conversion---float f is stored as (int)(f*F2I). */ @@ -88,18 +88,18 @@ void* create_ldpc_dec_c(uint8_t bgN, uint8_t bgM, uint16_t ls, float scaling_fct return NULL; } - if ((vp->soft_bits = srslte_vec_i8_malloc(liftN)) == NULL) { + if ((vp->soft_bits = srsran_vec_i8_malloc(liftN)) == NULL) { free(vp); return NULL; } - if ((vp->check_to_var = srslte_vec_i8_malloc((hrrN + ls) * bgM)) == NULL) { + if ((vp->check_to_var = srsran_vec_i8_malloc((hrrN + ls) * bgM)) == NULL) { free(vp->soft_bits); free(vp); return NULL; } - if ((vp->var_to_check = srslte_vec_i8_malloc((hrrN + ls))) == NULL) { + if ((vp->var_to_check = srsran_vec_i8_malloc((hrrN + ls))) == NULL) { free(vp->check_to_var); free(vp->soft_bits); free(vp); @@ -114,7 +114,7 @@ void* create_ldpc_dec_c(uint8_t bgN, uint8_t bgM, uint16_t ls, float scaling_fct return NULL; } - if ((vp->min_v_index = srslte_vec_i32_malloc(ls)) == NULL) { + if ((vp->min_v_index = srsran_vec_i32_malloc(ls)) == NULL) { free(vp->min_v2c); free(vp->var_to_check); free(vp->check_to_var); @@ -123,7 +123,7 @@ void* create_ldpc_dec_c(uint8_t bgN, uint8_t bgM, uint16_t ls, float scaling_fct return NULL; } - if ((vp->prod_v2c = srslte_vec_i32_malloc(ls)) == NULL) { + if ((vp->prod_v2c = srsran_vec_i32_malloc(ls)) == NULL) { free(vp->min_v_index); free(vp->min_v2c); free(vp->var_to_check); diff --git a/lib/src/phy/fec/ldpc/ldpc_dec_c_avx2.c b/lib/src/phy/fec/ldpc/ldpc_dec_c_avx2.c index fb17191ee..acd9e3ea8 100644 --- a/lib/src/phy/fec/ldpc/ldpc_dec_c_avx2.c +++ b/lib/src/phy/fec/ldpc/ldpc_dec_c_avx2.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -32,8 +32,8 @@ #include "../utils_avx2.h" #include "ldpc_dec_all.h" -#include "srslte/phy/fec/ldpc/base_graph.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/fec/ldpc/base_graph.h" +#include "srsran/phy/utils/vector.h" #ifdef LV_HAVE_AVX2 @@ -47,7 +47,7 @@ * \brief Represents a node of the base factor graph. */ typedef union bg_node_t { - int8_t c[SRSLTE_AVX2_B_SIZE]; /*!< Each base node may contain up to \ref SRSLTE_AVX2_B_SIZE lifted nodes. */ + int8_t c[SRSRAN_AVX2_B_SIZE]; /*!< Each base node may contain up to \ref SRSRAN_AVX2_B_SIZE lifted nodes. */ __m256i v; /*!< All the lifted nodes of the current base node as a 256-bit line. */ } bg_node_t; @@ -145,29 +145,29 @@ void* create_ldpc_dec_c_avx2(uint8_t bgN, uint8_t bgM, uint16_t ls, float scalin uint8_t bgK = bgN - bgM; uint16_t hrr = bgK + 4; - if ((vp = srslte_vec_malloc(sizeof(struct ldpc_regs_c_avx2))) == NULL) { + if ((vp = srsran_vec_malloc(sizeof(struct ldpc_regs_c_avx2))) == NULL) { return NULL; } - if ((vp->soft_bits = srslte_vec_malloc(bgN * sizeof(bg_node_t))) == NULL) { + if ((vp->soft_bits = srsran_vec_malloc(bgN * sizeof(bg_node_t))) == NULL) { free(vp); return NULL; } - if ((vp->check_to_var = srslte_vec_malloc((hrr + 1) * bgM * sizeof(__m256i))) == NULL) { + if ((vp->check_to_var = srsran_vec_malloc((hrr + 1) * bgM * sizeof(__m256i))) == NULL) { free(vp->soft_bits); free(vp); return NULL; } - if ((vp->var_to_check = srslte_vec_malloc((hrr + 1) * sizeof(__m256i))) == NULL) { + if ((vp->var_to_check = srsran_vec_malloc((hrr + 1) * sizeof(__m256i))) == NULL) { free(vp->check_to_var); free(vp->soft_bits); free(vp); return NULL; } - if ((vp->rotated_v2c = srslte_vec_malloc((hrr + 1) * sizeof(__m256i))) == NULL) { + if ((vp->rotated_v2c = srsran_vec_malloc((hrr + 1) * sizeof(__m256i))) == NULL) { free(vp->var_to_check); free(vp->check_to_var); free(vp->soft_bits); @@ -216,7 +216,7 @@ int init_ldpc_dec_c_avx2(void* p, const int8_t* llrs, uint16_t ls) for (j = 0; j < ls; j++) { vp->soft_bits[i].c[j] = llrs[(i - 2) * ls + j]; } - bzero(&(vp->soft_bits[i].c[ls]), (SRSLTE_AVX2_B_SIZE - ls) * sizeof(int8_t)); + bzero(&(vp->soft_bits[i].c[ls]), (SRSRAN_AVX2_B_SIZE - ls) * sizeof(int8_t)); } bzero(vp->check_to_var, (vp->hrr + 1) * vp->bgM * sizeof(__m256i)); @@ -488,7 +488,7 @@ static __m256i rotate_node_left(__m256i a, int imm, uint16_t ls) return a; } __m256i step1 = _mm256_rotatelli_si256(a, imm); - if (ls == SRSLTE_AVX2_B_SIZE) { + if (ls == SRSRAN_AVX2_B_SIZE) { return step1; } @@ -509,7 +509,7 @@ static __m256i rotate_node_right(__m256i a, int imm, uint16_t ls) return a; } __m256i step1 = _mm256_rotaterli_si256(a, imm); - if (ls == SRSLTE_AVX2_B_SIZE) { + if (ls == SRSRAN_AVX2_B_SIZE) { return step1; } diff --git a/lib/src/phy/fec/ldpc/ldpc_dec_c_avx2_flood.c b/lib/src/phy/fec/ldpc/ldpc_dec_c_avx2_flood.c index 0975891f8..a682b149b 100644 --- a/lib/src/phy/fec/ldpc/ldpc_dec_c_avx2_flood.c +++ b/lib/src/phy/fec/ldpc/ldpc_dec_c_avx2_flood.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -32,8 +32,8 @@ #include "../utils_avx2.h" #include "ldpc_dec_all.h" -#include "srslte/phy/fec/ldpc/base_graph.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/fec/ldpc/base_graph.h" +#include "srsran/phy/utils/vector.h" #ifdef LV_HAVE_AVX2 @@ -47,7 +47,7 @@ * \brief Represents a node of the base factor graph. */ typedef union bg_node_t { - int8_t c[SRSLTE_AVX2_B_SIZE]; /*!< Each base node may contain up to \ref SRSLTE_AVX2_B_SIZE lifted nodes. */ + int8_t c[SRSRAN_AVX2_B_SIZE]; /*!< Each base node may contain up to \ref SRSRAN_AVX2_B_SIZE lifted nodes. */ __m256i v; /*!< All the lifted nodes of the current base node as a 256-bit line. */ } bg_node_t; @@ -146,29 +146,29 @@ void* create_ldpc_dec_c_avx2_flood(uint8_t bgN, uint8_t bgM, uint16_t ls, float uint8_t bgK = bgN - bgM; uint16_t hrr = bgK + 4; - if ((vp = srslte_vec_malloc(sizeof(struct ldpc_regs_c_avx2_flood))) == NULL) { + if ((vp = srsran_vec_malloc(sizeof(struct ldpc_regs_c_avx2_flood))) == NULL) { return NULL; } - if ((vp->llrs = srslte_vec_malloc(bgN * sizeof(__m256i))) == NULL) { + if ((vp->llrs = srsran_vec_malloc(bgN * sizeof(__m256i))) == NULL) { free(vp); return NULL; } - if ((vp->soft_bits = srslte_vec_malloc(bgN * sizeof(bg_node_t))) == NULL) { + if ((vp->soft_bits = srsran_vec_malloc(bgN * sizeof(bg_node_t))) == NULL) { free(vp->llrs); free(vp); return NULL; } - if ((vp->check_to_var = srslte_vec_malloc((hrr + 1) * bgM * sizeof(__m256i))) == NULL) { + if ((vp->check_to_var = srsran_vec_malloc((hrr + 1) * bgM * sizeof(__m256i))) == NULL) { free(vp->soft_bits); free(vp->llrs); free(vp); return NULL; } - if ((vp->var_to_check = srslte_vec_malloc((hrr + 1) * bgM * sizeof(__m256i))) == NULL) { + if ((vp->var_to_check = srsran_vec_malloc((hrr + 1) * bgM * sizeof(__m256i))) == NULL) { free(vp->check_to_var); free(vp->soft_bits); free(vp->llrs); @@ -176,7 +176,7 @@ void* create_ldpc_dec_c_avx2_flood(uint8_t bgN, uint8_t bgM, uint16_t ls, float return NULL; } - if ((vp->rotated_v2c = srslte_vec_malloc((hrr + 1) * sizeof(__m256i))) == NULL) { + if ((vp->rotated_v2c = srsran_vec_malloc((hrr + 1) * sizeof(__m256i))) == NULL) { free(vp->var_to_check); free(vp->check_to_var); free(vp->soft_bits); @@ -229,7 +229,7 @@ int init_ldpc_dec_c_avx2_flood(void* p, const int8_t* llrs, uint16_t ls) for (j = 0; j < ls; j++) { vp->soft_bits[i].c[j] = llrs[(i - 2) * ls + j]; } - bzero(&(vp->soft_bits[i].c[ls]), (SRSLTE_AVX2_B_SIZE - ls) * sizeof(int8_t)); + bzero(&(vp->soft_bits[i].c[ls]), (SRSRAN_AVX2_B_SIZE - ls) * sizeof(int8_t)); vp->llrs[i] = vp->soft_bits[i].v; } @@ -513,7 +513,7 @@ static __m256i rotate_node_left(__m256i a, int imm, uint16_t ls) return a; } __m256i step1 = _mm256_rotatelli_si256(a, imm); - if (ls == SRSLTE_AVX2_B_SIZE) { + if (ls == SRSRAN_AVX2_B_SIZE) { return step1; } @@ -534,7 +534,7 @@ static __m256i rotate_node_right(__m256i a, int imm, uint16_t ls) return a; } __m256i step1 = _mm256_rotaterli_si256(a, imm); - if (ls == SRSLTE_AVX2_B_SIZE) { + if (ls == SRSRAN_AVX2_B_SIZE) { return step1; } diff --git a/lib/src/phy/fec/ldpc/ldpc_dec_c_avx2long.c b/lib/src/phy/fec/ldpc/ldpc_dec_c_avx2long.c index 6e591065c..06e3ab90e 100644 --- a/lib/src/phy/fec/ldpc/ldpc_dec_c_avx2long.c +++ b/lib/src/phy/fec/ldpc/ldpc_dec_c_avx2long.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -32,8 +32,8 @@ #include "../utils_avx2.h" #include "ldpc_dec_all.h" -#include "srslte/phy/fec/ldpc/base_graph.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/fec/ldpc/base_graph.h" +#include "srsran/phy/utils/vector.h" #ifdef LV_HAVE_AVX2 @@ -47,7 +47,7 @@ * \brief Represents a node of the base factor graph. */ typedef union bg_node_t { - int8_t c[SRSLTE_AVX2_B_SIZE]; /*!< Each base node may contain up to \ref SRSLTE_AVX2_B_SIZE lifted nodes. */ + int8_t c[SRSRAN_AVX2_B_SIZE]; /*!< Each base node may contain up to \ref SRSRAN_AVX2_B_SIZE lifted nodes. */ __m256i v; /*!< All the lifted nodes of the current base node as a 256-bit line. */ } bg_node_t; @@ -128,26 +128,26 @@ void* create_ldpc_dec_c_avx2long(uint8_t bgN, uint8_t bgM, uint16_t ls, float sc uint8_t bgK = bgN - bgM; uint16_t hrr = bgK + 4; - if ((vp = srslte_vec_malloc(sizeof(struct ldpc_regs_c_avx2long))) == NULL) { + if ((vp = srsran_vec_malloc(sizeof(struct ldpc_regs_c_avx2long))) == NULL) { return NULL; } // compute number of subnodes - int left_out = ls % SRSLTE_AVX2_B_SIZE; - int n_subnodes = ls / SRSLTE_AVX2_B_SIZE + (left_out > 0); + int left_out = ls % SRSRAN_AVX2_B_SIZE; + int n_subnodes = ls / SRSRAN_AVX2_B_SIZE + (left_out > 0); - if ((vp->soft_bits = srslte_vec_malloc(bgN * n_subnodes * sizeof(bg_node_t))) == NULL) { + if ((vp->soft_bits = srsran_vec_malloc(bgN * n_subnodes * sizeof(bg_node_t))) == NULL) { free(vp); return NULL; } - if ((vp->check_to_var = srslte_vec_malloc((hrr + 1) * bgM * n_subnodes * sizeof(__m256i))) == NULL) { + if ((vp->check_to_var = srsran_vec_malloc((hrr + 1) * bgM * n_subnodes * sizeof(__m256i))) == NULL) { free(vp->soft_bits); free(vp); return NULL; } - if ((vp->var_to_check_to_free = srslte_vec_malloc(((hrr + 1) * n_subnodes + 2) * sizeof(__m256i))) == NULL) { + if ((vp->var_to_check_to_free = srsran_vec_malloc(((hrr + 1) * n_subnodes + 2) * sizeof(__m256i))) == NULL) { free(vp->check_to_var); free(vp->soft_bits); free(vp); @@ -155,7 +155,7 @@ void* create_ldpc_dec_c_avx2long(uint8_t bgN, uint8_t bgM, uint16_t ls, float sc } vp->var_to_check = &vp->var_to_check_to_free[1]; - if ((vp->minp_v2c_epi8 = srslte_vec_malloc(n_subnodes * sizeof(__m256i))) == NULL) { + if ((vp->minp_v2c_epi8 = srsran_vec_malloc(n_subnodes * sizeof(__m256i))) == NULL) { free(vp->var_to_check_to_free); free(vp->check_to_var); free(vp->soft_bits); @@ -163,7 +163,7 @@ void* create_ldpc_dec_c_avx2long(uint8_t bgN, uint8_t bgM, uint16_t ls, float sc return NULL; } - if ((vp->mins_v2c_epi8 = srslte_vec_malloc(n_subnodes * sizeof(__m256i))) == NULL) { + if ((vp->mins_v2c_epi8 = srsran_vec_malloc(n_subnodes * sizeof(__m256i))) == NULL) { free(vp->minp_v2c_epi8); free(vp->var_to_check_to_free); free(vp->check_to_var); @@ -172,7 +172,7 @@ void* create_ldpc_dec_c_avx2long(uint8_t bgN, uint8_t bgM, uint16_t ls, float sc return NULL; } - if ((vp->prod_v2c_epi8 = srslte_vec_malloc(n_subnodes * sizeof(__m256i))) == NULL) { + if ((vp->prod_v2c_epi8 = srsran_vec_malloc(n_subnodes * sizeof(__m256i))) == NULL) { free(vp->mins_v2c_epi8); free(vp->minp_v2c_epi8); free(vp->var_to_check_to_free); @@ -182,7 +182,7 @@ void* create_ldpc_dec_c_avx2long(uint8_t bgN, uint8_t bgM, uint16_t ls, float sc return NULL; } - if ((vp->min_ix_epi8 = srslte_vec_malloc(n_subnodes * sizeof(__m256i))) == NULL) { + if ((vp->min_ix_epi8 = srsran_vec_malloc(n_subnodes * sizeof(__m256i))) == NULL) { free(vp->prod_v2c_epi8); free(vp->mins_v2c_epi8); free(vp->minp_v2c_epi8); @@ -193,7 +193,7 @@ void* create_ldpc_dec_c_avx2long(uint8_t bgN, uint8_t bgM, uint16_t ls, float sc return NULL; } - if ((vp->rotated_v2c = srslte_vec_malloc((hrr + 1) * n_subnodes * sizeof(__m256i))) == NULL) { + if ((vp->rotated_v2c = srsran_vec_malloc((hrr + 1) * n_subnodes * sizeof(__m256i))) == NULL) { free(vp->min_ix_epi8); free(vp->prod_v2c_epi8); free(vp->mins_v2c_epi8); @@ -205,7 +205,7 @@ void* create_ldpc_dec_c_avx2long(uint8_t bgN, uint8_t bgM, uint16_t ls, float sc return NULL; } - if ((vp->this_c2v_epi8_to_free = srslte_vec_malloc((n_subnodes + 2) * sizeof(__m256i))) == NULL) { + if ((vp->this_c2v_epi8_to_free = srsran_vec_malloc((n_subnodes + 2) * sizeof(__m256i))) == NULL) { free(vp->rotated_v2c); free(vp->min_ix_epi8); free(vp->prod_v2c_epi8); @@ -268,11 +268,11 @@ int init_ldpc_dec_c_avx2long(void* p, const int8_t* llrs, uint16_t ls) } for (i = 2; i < vp->bgN; i++) { for (j = 0; j < vp->n_subnodes; j++) { - for (k = 0; (k < SRSLTE_AVX2_B_SIZE) && (j * SRSLTE_AVX2_B_SIZE + k < ls); k++) { - vp->soft_bits[i * vp->n_subnodes + j].c[k] = llrs[(i - 2) * ls + j * SRSLTE_AVX2_B_SIZE + k]; + for (k = 0; (k < SRSRAN_AVX2_B_SIZE) && (j * SRSRAN_AVX2_B_SIZE + k < ls); k++) { + vp->soft_bits[i * vp->n_subnodes + j].c[k] = llrs[(i - 2) * ls + j * SRSRAN_AVX2_B_SIZE + k]; } } - bzero(&(vp->soft_bits[i * vp->n_subnodes + j - 1].c[k]), (SRSLTE_AVX2_B_SIZE - k) * sizeof(int8_t)); + bzero(&(vp->soft_bits[i * vp->n_subnodes + j - 1].c[k]), (SRSRAN_AVX2_B_SIZE - k) * sizeof(int8_t)); } bzero(vp->check_to_var, (vp->hrr + 1) * vp->bgM * vp->n_subnodes * sizeof(__m256i)); @@ -468,8 +468,8 @@ int extract_ldpc_message_c_avx2long(void* p, uint8_t* message, uint16_t liftK) for (int i = 0; i < liftK / vp->ls; i++) { for (j = 0; j < vp->n_subnodes; j++) { - for (k = 0; (k < SRSLTE_AVX2_B_SIZE) && (j * SRSLTE_AVX2_B_SIZE + k < vp->ls); k++) { - message[i * vp->ls + j * SRSLTE_AVX2_B_SIZE + k] = (vp->soft_bits[i * vp->n_subnodes + j].c[k] < 0); + for (k = 0; (k < SRSRAN_AVX2_B_SIZE) && (j * SRSRAN_AVX2_B_SIZE + k < vp->ls); k++) { + message[i * vp->ls + j * SRSRAN_AVX2_B_SIZE + k] = (vp->soft_bits[i * vp->n_subnodes + j].c[k] < 0); } } } @@ -513,22 +513,22 @@ static void rotate_node_right(const __m256i* in_256i, __m256i* out, uint16_t shi { const int8_t* in = (const int8_t*)in_256i; - int16_t n_type1 = (ls - shift) / SRSLTE_AVX2_B_SIZE - (ls == SRSLTE_AVX2_B_SIZE); - int16_t n_type2 = n_subnodes - n_type1 - 1 - (ls == SRSLTE_AVX2_B_SIZE); - int16_t gap = (ls - shift) % SRSLTE_AVX2_B_SIZE; + int16_t n_type1 = (ls - shift) / SRSRAN_AVX2_B_SIZE - (ls == SRSRAN_AVX2_B_SIZE); + int16_t n_type2 = n_subnodes - n_type1 - 1 - (ls == SRSRAN_AVX2_B_SIZE); + int16_t gap = (ls - shift) % SRSRAN_AVX2_B_SIZE; int16_t i = 0; for (; i < n_type1; i++) { - out[i] = _mm256_loadu_si256((const __m256i*)(in + shift + i * SRSLTE_AVX2_B_SIZE)); + out[i] = _mm256_loadu_si256((const __m256i*)(in + shift + i * SRSRAN_AVX2_B_SIZE)); } - __m256i tmp1 = _mm256_loadu_si256((const __m256i*)(in + shift + i * SRSLTE_AVX2_B_SIZE)); + __m256i tmp1 = _mm256_loadu_si256((const __m256i*)(in + shift + i * SRSRAN_AVX2_B_SIZE)); __m256i tmp2 = _mm256_loadu_si256((const __m256i*)(in - gap)); out[i] = _mm256_blendv_epi8(tmp1, tmp2, mask_most_epi8[gap]); for (i = 1; i <= n_type2; i++) { - out[n_type1 + i] = _mm256_loadu_si256((const __m256i*)(in - gap + i * SRSLTE_AVX2_B_SIZE)); + out[n_type1 + i] = _mm256_loadu_si256((const __m256i*)(in - gap + i * SRSRAN_AVX2_B_SIZE)); } } diff --git a/lib/src/phy/fec/ldpc/ldpc_dec_c_avx2long_flood.c b/lib/src/phy/fec/ldpc/ldpc_dec_c_avx2long_flood.c index 920b853ba..1fddbcd66 100644 --- a/lib/src/phy/fec/ldpc/ldpc_dec_c_avx2long_flood.c +++ b/lib/src/phy/fec/ldpc/ldpc_dec_c_avx2long_flood.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -32,8 +32,8 @@ #include "../utils_avx2.h" #include "ldpc_dec_all.h" -#include "srslte/phy/fec/ldpc/base_graph.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/fec/ldpc/base_graph.h" +#include "srsran/phy/utils/vector.h" #ifdef LV_HAVE_AVX2 @@ -47,7 +47,7 @@ * \brief Represents a node of the base factor graph. */ typedef union bg_node_t { - int8_t c[SRSLTE_AVX2_B_SIZE]; /*!< Each base node may contain up to \ref SRSLTE_AVX2_B_SIZE lifted nodes. */ + int8_t c[SRSRAN_AVX2_B_SIZE]; /*!< Each base node may contain up to \ref SRSRAN_AVX2_B_SIZE lifted nodes. */ __m256i v; /*!< All the lifted nodes of the current base node as a 256-bit line. */ } bg_node_t; @@ -128,33 +128,33 @@ void* create_ldpc_dec_c_avx2long_flood(uint8_t bgN, uint8_t bgM, uint16_t ls, fl uint8_t bgK = bgN - bgM; uint16_t hrr = bgK + 4; - if ((vp = srslte_vec_malloc(sizeof(struct ldpc_regs_c_avx2long_flood))) == NULL) { + if ((vp = srsran_vec_malloc(sizeof(struct ldpc_regs_c_avx2long_flood))) == NULL) { return NULL; } // compute number of subnodes - int left_out = ls % SRSLTE_AVX2_B_SIZE; - int n_subnodes = ls / SRSLTE_AVX2_B_SIZE + (left_out > 0); + int left_out = ls % SRSRAN_AVX2_B_SIZE; + int n_subnodes = ls / SRSRAN_AVX2_B_SIZE + (left_out > 0); - if ((vp->llrs = srslte_vec_malloc(bgN * n_subnodes * sizeof(__m256i))) == NULL) { + if ((vp->llrs = srsran_vec_malloc(bgN * n_subnodes * sizeof(__m256i))) == NULL) { free(vp); return NULL; } - if ((vp->soft_bits = srslte_vec_malloc(bgN * n_subnodes * sizeof(bg_node_t))) == NULL) { + if ((vp->soft_bits = srsran_vec_malloc(bgN * n_subnodes * sizeof(bg_node_t))) == NULL) { free(vp->llrs); free(vp); return NULL; } - if ((vp->check_to_var = srslte_vec_malloc((hrr + 1) * bgM * n_subnodes * sizeof(__m256i))) == NULL) { + if ((vp->check_to_var = srsran_vec_malloc((hrr + 1) * bgM * n_subnodes * sizeof(__m256i))) == NULL) { free(vp->soft_bits); free(vp->llrs); free(vp); return NULL; } - if ((vp->var_to_check_to_free = srslte_vec_malloc(((hrr + 1) * bgM * n_subnodes + 2) * sizeof(__m256i))) == NULL) { + if ((vp->var_to_check_to_free = srsran_vec_malloc(((hrr + 1) * bgM * n_subnodes + 2) * sizeof(__m256i))) == NULL) { free(vp->check_to_var); free(vp->soft_bits); free(vp->llrs); @@ -163,7 +163,7 @@ void* create_ldpc_dec_c_avx2long_flood(uint8_t bgN, uint8_t bgM, uint16_t ls, fl } vp->var_to_check = &vp->var_to_check_to_free[1]; - if ((vp->minp_v2c_epi8 = srslte_vec_malloc(n_subnodes * sizeof(__m256i))) == NULL) { + if ((vp->minp_v2c_epi8 = srsran_vec_malloc(n_subnodes * sizeof(__m256i))) == NULL) { free(vp->var_to_check_to_free); free(vp->check_to_var); free(vp->soft_bits); @@ -172,7 +172,7 @@ void* create_ldpc_dec_c_avx2long_flood(uint8_t bgN, uint8_t bgM, uint16_t ls, fl return NULL; } - if ((vp->mins_v2c_epi8 = srslte_vec_malloc(n_subnodes * sizeof(__m256i))) == NULL) { + if ((vp->mins_v2c_epi8 = srsran_vec_malloc(n_subnodes * sizeof(__m256i))) == NULL) { free(vp->minp_v2c_epi8); free(vp->var_to_check_to_free); free(vp->check_to_var); @@ -182,7 +182,7 @@ void* create_ldpc_dec_c_avx2long_flood(uint8_t bgN, uint8_t bgM, uint16_t ls, fl return NULL; } - if ((vp->prod_v2c_epi8 = srslte_vec_malloc(n_subnodes * sizeof(__m256i))) == NULL) { + if ((vp->prod_v2c_epi8 = srsran_vec_malloc(n_subnodes * sizeof(__m256i))) == NULL) { free(vp->mins_v2c_epi8); free(vp->minp_v2c_epi8); free(vp->var_to_check_to_free); @@ -193,7 +193,7 @@ void* create_ldpc_dec_c_avx2long_flood(uint8_t bgN, uint8_t bgM, uint16_t ls, fl return NULL; } - if ((vp->min_ix_epi8 = srslte_vec_malloc(n_subnodes * sizeof(__m256i))) == NULL) { + if ((vp->min_ix_epi8 = srsran_vec_malloc(n_subnodes * sizeof(__m256i))) == NULL) { free(vp->prod_v2c_epi8); free(vp->mins_v2c_epi8); free(vp->minp_v2c_epi8); @@ -205,7 +205,7 @@ void* create_ldpc_dec_c_avx2long_flood(uint8_t bgN, uint8_t bgM, uint16_t ls, fl return NULL; } - if ((vp->rotated_v2c = srslte_vec_malloc((hrr + 1) * n_subnodes * sizeof(__m256i))) == NULL) { + if ((vp->rotated_v2c = srsran_vec_malloc((hrr + 1) * n_subnodes * sizeof(__m256i))) == NULL) { free(vp->min_ix_epi8); free(vp->prod_v2c_epi8); free(vp->mins_v2c_epi8); @@ -218,7 +218,7 @@ void* create_ldpc_dec_c_avx2long_flood(uint8_t bgN, uint8_t bgM, uint16_t ls, fl return NULL; } - if ((vp->this_c2v_epi8_to_free = srslte_vec_malloc((n_subnodes + 2) * sizeof(__m256i))) == NULL) { + if ((vp->this_c2v_epi8_to_free = srsran_vec_malloc((n_subnodes + 2) * sizeof(__m256i))) == NULL) { free(vp->rotated_v2c); free(vp->min_ix_epi8); free(vp->prod_v2c_epi8); @@ -284,13 +284,13 @@ int init_ldpc_dec_c_avx2long_flood(void* p, const int8_t* llrs, uint16_t ls) } for (i = 2; i < vp->bgN; i++) { for (j = 0; j < vp->n_subnodes; j++) { - for (k = 0; (k < SRSLTE_AVX2_B_SIZE) && (j * SRSLTE_AVX2_B_SIZE + k < ls); k++) { - vp->soft_bits[i * vp->n_subnodes + j].c[k] = llrs[(i - 2) * ls + j * SRSLTE_AVX2_B_SIZE + k]; + for (k = 0; (k < SRSRAN_AVX2_B_SIZE) && (j * SRSRAN_AVX2_B_SIZE + k < ls); k++) { + vp->soft_bits[i * vp->n_subnodes + j].c[k] = llrs[(i - 2) * ls + j * SRSRAN_AVX2_B_SIZE + k]; } vp->llrs[i * vp->n_subnodes + j] = vp->soft_bits[i * vp->n_subnodes + j].v; } - bzero(&(vp->soft_bits[i * vp->n_subnodes + j - 1].c[k]), (SRSLTE_AVX2_B_SIZE - k) * sizeof(int8_t)); - bzero((int8_t*)(vp->llrs + i * vp->n_subnodes + j - 1) + k, (SRSLTE_AVX2_B_SIZE - k) * sizeof(int8_t)); + bzero(&(vp->soft_bits[i * vp->n_subnodes + j - 1].c[k]), (SRSRAN_AVX2_B_SIZE - k) * sizeof(int8_t)); + bzero((int8_t*)(vp->llrs + i * vp->n_subnodes + j - 1) + k, (SRSRAN_AVX2_B_SIZE - k) * sizeof(int8_t)); } bzero(vp->check_to_var, (vp->hrr + 1) * vp->bgM * vp->n_subnodes * sizeof(__m256i)); @@ -493,8 +493,8 @@ int extract_ldpc_message_c_avx2long_flood(void* p, uint8_t* message, uint16_t li for (int i = 0; i < liftK / vp->ls; i++) { for (j = 0; j < vp->n_subnodes; j++) { - for (k = 0; (k < SRSLTE_AVX2_B_SIZE) && (j * SRSLTE_AVX2_B_SIZE + k < vp->ls); k++) { - message[i * vp->ls + j * SRSLTE_AVX2_B_SIZE + k] = (vp->soft_bits[i * vp->n_subnodes + j].c[k] < 0); + for (k = 0; (k < SRSRAN_AVX2_B_SIZE) && (j * SRSRAN_AVX2_B_SIZE + k < vp->ls); k++) { + message[i * vp->ls + j * SRSRAN_AVX2_B_SIZE + k] = (vp->soft_bits[i * vp->n_subnodes + j].c[k] < 0); } } } @@ -538,22 +538,22 @@ static void rotate_node_right(const __m256i* in_256i, __m256i* out, uint16_t shi { const int8_t* in = (const int8_t*)in_256i; - int16_t n_type1 = (ls - shift) / SRSLTE_AVX2_B_SIZE - (ls == SRSLTE_AVX2_B_SIZE); - int16_t n_type2 = n_subnodes - n_type1 - 1 - (ls == SRSLTE_AVX2_B_SIZE); - int16_t gap = (ls - shift) % SRSLTE_AVX2_B_SIZE; + int16_t n_type1 = (ls - shift) / SRSRAN_AVX2_B_SIZE - (ls == SRSRAN_AVX2_B_SIZE); + int16_t n_type2 = n_subnodes - n_type1 - 1 - (ls == SRSRAN_AVX2_B_SIZE); + int16_t gap = (ls - shift) % SRSRAN_AVX2_B_SIZE; int16_t i = 0; for (; i < n_type1; i++) { - out[i] = _mm256_loadu_si256((const __m256i*)(in + shift + i * SRSLTE_AVX2_B_SIZE)); + out[i] = _mm256_loadu_si256((const __m256i*)(in + shift + i * SRSRAN_AVX2_B_SIZE)); } - __m256i tmp1 = _mm256_loadu_si256((const __m256i*)(in + shift + i * SRSLTE_AVX2_B_SIZE)); + __m256i tmp1 = _mm256_loadu_si256((const __m256i*)(in + shift + i * SRSRAN_AVX2_B_SIZE)); __m256i tmp2 = _mm256_loadu_si256((const __m256i*)(in - gap)); out[i] = _mm256_blendv_epi8(tmp1, tmp2, mask_most_epi8[gap]); for (i = 1; i <= n_type2; i++) { - out[n_type1 + i] = _mm256_loadu_si256((const __m256i*)(in - gap + i * SRSLTE_AVX2_B_SIZE)); + out[n_type1 + i] = _mm256_loadu_si256((const __m256i*)(in - gap + i * SRSRAN_AVX2_B_SIZE)); } } diff --git a/lib/src/phy/fec/ldpc/ldpc_dec_c_avx512.c b/lib/src/phy/fec/ldpc/ldpc_dec_c_avx512.c index ac7a62079..9868f7112 100644 --- a/lib/src/phy/fec/ldpc/ldpc_dec_c_avx512.c +++ b/lib/src/phy/fec/ldpc/ldpc_dec_c_avx512.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -33,8 +33,8 @@ #include "../utils_avx512.h" #include "ldpc_dec_all.h" -#include "srslte/phy/fec/ldpc/base_graph.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/fec/ldpc/base_graph.h" +#include "srsran/phy/utils/vector.h" #ifdef LV_HAVE_AVX512 @@ -54,7 +54,7 @@ static const int8_t infinity7 = (1U << 6U) - 1; * \brief Represents a node of the base factor graph. */ typedef union bg_node_avx512_t { - int8_t* c; /*!< Each base node may contain up to \ref SRSLTE_AVX512_B_SIZE lifted nodes. */ + int8_t* c; /*!< Each base node may contain up to \ref SRSRAN_AVX512_B_SIZE lifted nodes. */ __m512i* v; /*!< All the lifted nodes of the current base node as a 512-bit line. */ } bg_node_avx512_t; @@ -123,33 +123,33 @@ void* create_ldpc_dec_c_avx512(uint8_t bgN, uint8_t bgM, uint16_t ls, float scal uint8_t bgK = bgN - bgM; uint16_t hrr = bgK + 4; - if ((vp = SRSLTE_MEM_ALLOC(struct ldpc_regs_c_avx512, 1)) == NULL) { + if ((vp = SRSRAN_MEM_ALLOC(struct ldpc_regs_c_avx512, 1)) == NULL) { return NULL; } - SRSLTE_MEM_ZERO(vp, struct ldpc_regs_c_avx512, 1); + SRSRAN_MEM_ZERO(vp, struct ldpc_regs_c_avx512, 1); - if ((vp->soft_bits.v = SRSLTE_MEM_ALLOC(__m512i, bgN)) == NULL) { + if ((vp->soft_bits.v = SRSRAN_MEM_ALLOC(__m512i, bgN)) == NULL) { delete_ldpc_dec_c_avx512(vp); return NULL; } - if ((vp->check_to_var = SRSLTE_MEM_ALLOC(__m512i, (hrr + 1) * bgM)) == NULL) { + if ((vp->check_to_var = SRSRAN_MEM_ALLOC(__m512i, (hrr + 1) * bgM)) == NULL) { delete_ldpc_dec_c_avx512(vp); return NULL; } - if ((vp->var_to_check_to_free = SRSLTE_MEM_ALLOC(__m512i, (hrr + 1) + 2)) == NULL) { + if ((vp->var_to_check_to_free = SRSRAN_MEM_ALLOC(__m512i, (hrr + 1) + 2)) == NULL) { delete_ldpc_dec_c_avx512(vp); return NULL; } vp->var_to_check = &vp->var_to_check_to_free[1]; - if ((vp->rotated_v2c = SRSLTE_MEM_ALLOC(__m512i, hrr + 1)) == NULL) { + if ((vp->rotated_v2c = SRSRAN_MEM_ALLOC(__m512i, hrr + 1)) == NULL) { delete_ldpc_dec_c_avx512(vp); return NULL; } - if ((vp->this_c2v_epi8_to_free = SRSLTE_MEM_ALLOC(__m512i, 1 + 2)) == NULL) { + if ((vp->this_c2v_epi8_to_free = SRSRAN_MEM_ALLOC(__m512i, 1 + 2)) == NULL) { delete_ldpc_dec_c_avx512(vp); return NULL; } @@ -205,20 +205,20 @@ int init_ldpc_dec_c_avx512(void* p, const int8_t* llrs, uint16_t ls) int k = 0; // First 2 punctured bits - int ini = SRSLTE_AVX512_B_SIZE + SRSLTE_AVX512_B_SIZE; - srslte_vec_i8_zero(vp->soft_bits.c, ini); + int ini = SRSRAN_AVX512_B_SIZE + SRSRAN_AVX512_B_SIZE; + srsran_vec_i8_zero(vp->soft_bits.c, ini); for (i = 0; i < vp->finalN; i = i + ls) { for (k = 0; k < ls; k++) { vp->soft_bits.c[ini + k] = llrs[i + k]; } // this might be removed - srslte_vec_i8_zero(&vp->soft_bits.c[ini + ls], SRSLTE_AVX512_B_SIZE - ls); - ini = ini + SRSLTE_AVX512_B_SIZE; + srsran_vec_i8_zero(&vp->soft_bits.c[ini + ls], SRSRAN_AVX512_B_SIZE - ls); + ini = ini + SRSRAN_AVX512_B_SIZE; } - SRSLTE_MEM_ZERO(vp->check_to_var, __m512i, (vp->hrr + 1) * vp->bgM); - SRSLTE_MEM_ZERO(vp->var_to_check, __m512i, vp->hrr + 1); + SRSRAN_MEM_ZERO(vp->check_to_var, __m512i, (vp->hrr + 1) * vp->bgM); + SRSRAN_MEM_ZERO(vp->var_to_check, __m512i, vp->hrr + 1); return 0; } @@ -235,7 +235,7 @@ int extract_ldpc_message_c_avx512(void* p, uint8_t* message, uint16_t liftK) for (int k = 0; k < vp->ls; k++) { message[i + k] = (vp->soft_bits.c[ini + k] < 0); } - ini = ini + SRSLTE_AVX512_B_SIZE; + ini = ini + SRSRAN_AVX512_B_SIZE; } return 0; @@ -435,7 +435,7 @@ static void rotate_node_right(const uint8_t* mem_addr, __m512i* out, uint16_t th } else { // if the last is broken, take _shift bits from the end and "shift" bits from the begin. _shift = ls - this_shift; - shift = SRSLTE_AVX512_B_SIZE - _shift; + shift = SRSRAN_AVX512_B_SIZE - _shift; mask1 = (1ULL << _shift) - 1; // i.e. 000001111 _shift =4 mask2 = (1ULL << shift) - 1; diff --git a/lib/src/phy/fec/ldpc/ldpc_dec_c_avx512long.c b/lib/src/phy/fec/ldpc/ldpc_dec_c_avx512long.c index 08882ae8d..72c247879 100644 --- a/lib/src/phy/fec/ldpc/ldpc_dec_c_avx512long.c +++ b/lib/src/phy/fec/ldpc/ldpc_dec_c_avx512long.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -33,8 +33,8 @@ #include "../utils_avx512.h" #include "ldpc_dec_all.h" -#include "srslte/phy/fec/ldpc/base_graph.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/fec/ldpc/base_graph.h" +#include "srsran/phy/utils/vector.h" #ifdef LV_HAVE_AVX512 @@ -54,7 +54,7 @@ static const int8_t infinity7 = (1U << 6U) - 1; * \brief Represents a node of the base factor graph. */ typedef union bg_node_avx512_t { - int8_t c[SRSLTE_AVX512_B_SIZE]; /*!< Each base node may contain up to \ref SRSLTE_AVX512_B_SIZE lifted nodes. */ + int8_t c[SRSRAN_AVX512_B_SIZE]; /*!< Each base node may contain up to \ref SRSRAN_AVX512_B_SIZE lifted nodes. */ __m512i v; /*!< All the lifted nodes of the current base node as a 512-bit line. */ } bg_node_avx512_t; @@ -129,26 +129,26 @@ void* create_ldpc_dec_c_avx512long(uint8_t bgN, uint8_t bgM, uint16_t ls, float uint8_t bgK = bgN - bgM; uint16_t hrr = bgK + 4; - if ((vp = srslte_vec_malloc(sizeof(struct ldpc_regs_c_avx512long))) == NULL) { + if ((vp = srsran_vec_malloc(sizeof(struct ldpc_regs_c_avx512long))) == NULL) { return NULL; } // compute number of subnodes - int left_out = ls % SRSLTE_AVX512_B_SIZE; - int n_subnodes = ls / SRSLTE_AVX512_B_SIZE + (left_out > 0); + int left_out = ls % SRSRAN_AVX512_B_SIZE; + int n_subnodes = ls / SRSRAN_AVX512_B_SIZE + (left_out > 0); - if ((vp->soft_bits = srslte_vec_malloc(bgN * n_subnodes * sizeof(bg_node_avx512_t))) == NULL) { + if ((vp->soft_bits = srsran_vec_malloc(bgN * n_subnodes * sizeof(bg_node_avx512_t))) == NULL) { free(vp); return NULL; } - if ((vp->check_to_var = srslte_vec_malloc((hrr + 1) * bgM * n_subnodes * sizeof(__m512i))) == NULL) { + if ((vp->check_to_var = srsran_vec_malloc((hrr + 1) * bgM * n_subnodes * sizeof(__m512i))) == NULL) { free(vp->soft_bits); free(vp); return NULL; } - if ((vp->var_to_check_to_free = srslte_vec_malloc(((hrr + 1) * n_subnodes + 2) * sizeof(__m512i))) == NULL) { + if ((vp->var_to_check_to_free = srsran_vec_malloc(((hrr + 1) * n_subnodes + 2) * sizeof(__m512i))) == NULL) { free(vp->check_to_var); free(vp->soft_bits); free(vp); @@ -156,7 +156,7 @@ void* create_ldpc_dec_c_avx512long(uint8_t bgN, uint8_t bgM, uint16_t ls, float } vp->var_to_check = &vp->var_to_check_to_free[1]; - if ((vp->minp_v2c_epi8 = srslte_vec_malloc(n_subnodes * sizeof(__m512i))) == NULL) { + if ((vp->minp_v2c_epi8 = srsran_vec_malloc(n_subnodes * sizeof(__m512i))) == NULL) { free(vp->var_to_check_to_free); free(vp->check_to_var); free(vp->soft_bits); @@ -164,7 +164,7 @@ void* create_ldpc_dec_c_avx512long(uint8_t bgN, uint8_t bgM, uint16_t ls, float return NULL; } - if ((vp->mins_v2c_epi8 = srslte_vec_malloc(n_subnodes * sizeof(__m512i))) == NULL) { + if ((vp->mins_v2c_epi8 = srsran_vec_malloc(n_subnodes * sizeof(__m512i))) == NULL) { free(vp->minp_v2c_epi8); free(vp->var_to_check_to_free); free(vp->check_to_var); @@ -173,7 +173,7 @@ void* create_ldpc_dec_c_avx512long(uint8_t bgN, uint8_t bgM, uint16_t ls, float return NULL; } - if ((vp->prod_v2c_epi8 = srslte_vec_malloc(n_subnodes * sizeof(__m512i))) == NULL) { + if ((vp->prod_v2c_epi8 = srsran_vec_malloc(n_subnodes * sizeof(__m512i))) == NULL) { free(vp->mins_v2c_epi8); free(vp->minp_v2c_epi8); free(vp->var_to_check_to_free); @@ -183,7 +183,7 @@ void* create_ldpc_dec_c_avx512long(uint8_t bgN, uint8_t bgM, uint16_t ls, float return NULL; } - if ((vp->min_ix_epi8 = srslte_vec_malloc(n_subnodes * sizeof(__m512i))) == NULL) { + if ((vp->min_ix_epi8 = srsran_vec_malloc(n_subnodes * sizeof(__m512i))) == NULL) { free(vp->prod_v2c_epi8); free(vp->mins_v2c_epi8); free(vp->minp_v2c_epi8); @@ -194,7 +194,7 @@ void* create_ldpc_dec_c_avx512long(uint8_t bgN, uint8_t bgM, uint16_t ls, float return NULL; } - if ((vp->rotated_v2c = srslte_vec_malloc((hrr + 1) * n_subnodes * sizeof(__m512i))) == NULL) { + if ((vp->rotated_v2c = srsran_vec_malloc((hrr + 1) * n_subnodes * sizeof(__m512i))) == NULL) { free(vp->min_ix_epi8); free(vp->prod_v2c_epi8); free(vp->mins_v2c_epi8); @@ -206,7 +206,7 @@ void* create_ldpc_dec_c_avx512long(uint8_t bgN, uint8_t bgM, uint16_t ls, float return NULL; } - if ((vp->this_c2v_epi8_to_free = srslte_vec_malloc((n_subnodes + 2) * sizeof(__m512i))) == NULL) { + if ((vp->this_c2v_epi8_to_free = srsran_vec_malloc((n_subnodes + 2) * sizeof(__m512i))) == NULL) { free(vp->rotated_v2c); free(vp->min_ix_epi8); free(vp->prod_v2c_epi8); @@ -227,7 +227,7 @@ void* create_ldpc_dec_c_avx512long(uint8_t bgN, uint8_t bgM, uint16_t ls, float vp->ls = ls; vp->n_subnodes = n_subnodes; - vp->node_size = SRSLTE_AVX512_B_SIZE * vp->n_subnodes; + vp->node_size = SRSRAN_AVX512_B_SIZE * vp->n_subnodes; vp->finalN = (bgN - 2) * ls; // correction > 1/16 to compensate the scaling error (2^16-1)/2^16 incurred in _mm512_scalei_epi8 vp->scaling_fctr = _mm512_set1_epi16((uint16_t)((scaling_fctr + 0.00001525879) * F2I)); @@ -514,7 +514,7 @@ static void rotate_node_right(const uint8_t* mem_addr, __m512i* out, uint16_t th int jj = 0; // copy full avx512 registers from this_shift_2 - for (j = this_shift; j <= ls - SRSLTE_AVX512_B_SIZE; j = j + SRSLTE_AVX512_B_SIZE) { + for (j = this_shift; j <= ls - SRSRAN_AVX512_B_SIZE; j = j + SRSRAN_AVX512_B_SIZE) { out[jj] = _mm512_loadu_si512(mem_addr + j); jj = jj + 1; } @@ -522,7 +522,7 @@ static void rotate_node_right(const uint8_t* mem_addr, __m512i* out, uint16_t th // if the last is broken, take _shift bits from the end and "shift" bits from the begin. if (ls > j) { _shift = ls - j; - shift = SRSLTE_AVX512_B_SIZE - _shift; + shift = SRSRAN_AVX512_B_SIZE - _shift; mask1 = (1ULL << _shift) - 1; // i.e. 000001111 _shift =4 mask2 = (1ULL << shift) - 1; mask2 = mask2 << _shift; // i.e. 000110000 shift = 2, _shift = 4 @@ -534,7 +534,7 @@ static void rotate_node_right(const uint8_t* mem_addr, __m512i* out, uint16_t th } // copy full avx512 registers from the start of mem_addr - for (j = shift; j < this_shift; j = j + SRSLTE_AVX512_B_SIZE) { + for (j = shift; j < this_shift; j = j + SRSRAN_AVX512_B_SIZE) { out[jj] = _mm512_loadu_si512(mem_addr + j); // the excess is filled with something arbitrary jj = jj + 1; diff --git a/lib/src/phy/fec/ldpc/ldpc_dec_c_avx512long_flood.c b/lib/src/phy/fec/ldpc/ldpc_dec_c_avx512long_flood.c index 82012ddc9..bfccb61e2 100644 --- a/lib/src/phy/fec/ldpc/ldpc_dec_c_avx512long_flood.c +++ b/lib/src/phy/fec/ldpc/ldpc_dec_c_avx512long_flood.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -33,8 +33,8 @@ #include "../utils_avx512.h" #include "ldpc_dec_all.h" -#include "srslte/phy/fec/ldpc/base_graph.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/fec/ldpc/base_graph.h" +#include "srsran/phy/utils/vector.h" #ifdef LV_HAVE_AVX512 @@ -54,7 +54,7 @@ static const int8_t infinity7 = (1U << 6U) - 1; * \brief Represents a node of the base factor graph. */ typedef union bg_node_avx512_t { - int8_t c[SRSLTE_AVX512_B_SIZE]; /*!< Each base node may contain up to \ref SRSLTE_AVX512_B_SIZE lifted nodes. */ + int8_t c[SRSRAN_AVX512_B_SIZE]; /*!< Each base node may contain up to \ref SRSRAN_AVX512_B_SIZE lifted nodes. */ __m512i v; /*!< All the lifted nodes of the current base node as a 512-bit line. */ } bg_node_avx512_t; @@ -128,33 +128,33 @@ void* create_ldpc_dec_c_avx512long_flood(uint8_t bgN, uint8_t bgM, uint16_t ls, uint8_t bgK = bgN - bgM; uint16_t hrr = bgK + 4; - if ((vp = srslte_vec_malloc(sizeof(struct ldpc_regs_c_avx512long_flood))) == NULL) { + if ((vp = srsran_vec_malloc(sizeof(struct ldpc_regs_c_avx512long_flood))) == NULL) { return NULL; } // compute number of subnodes - int left_out = ls % SRSLTE_AVX512_B_SIZE; - int n_subnodes = ls / SRSLTE_AVX512_B_SIZE + (left_out > 0); + int left_out = ls % SRSRAN_AVX512_B_SIZE; + int n_subnodes = ls / SRSRAN_AVX512_B_SIZE + (left_out > 0); - if ((vp->llrs = srslte_vec_malloc(bgN * n_subnodes * sizeof(__m512i))) == NULL) { + if ((vp->llrs = srsran_vec_malloc(bgN * n_subnodes * sizeof(__m512i))) == NULL) { free(vp); return NULL; } - if ((vp->soft_bits = srslte_vec_malloc(bgN * n_subnodes * sizeof(bg_node_avx512_t))) == NULL) { + if ((vp->soft_bits = srsran_vec_malloc(bgN * n_subnodes * sizeof(bg_node_avx512_t))) == NULL) { free(vp->llrs); free(vp); return NULL; } - if ((vp->check_to_var = srslte_vec_malloc((hrr + 1) * bgM * n_subnodes * sizeof(__m512i))) == NULL) { + if ((vp->check_to_var = srsran_vec_malloc((hrr + 1) * bgM * n_subnodes * sizeof(__m512i))) == NULL) { free(vp->soft_bits); free(vp->llrs); free(vp); return NULL; } - if ((vp->var_to_check_to_free = srslte_vec_malloc(((hrr + 1) * bgM * n_subnodes + 2) * sizeof(__m512i))) == NULL) { + if ((vp->var_to_check_to_free = srsran_vec_malloc(((hrr + 1) * bgM * n_subnodes + 2) * sizeof(__m512i))) == NULL) { free(vp->check_to_var); free(vp->soft_bits); free(vp->llrs); @@ -163,7 +163,7 @@ void* create_ldpc_dec_c_avx512long_flood(uint8_t bgN, uint8_t bgM, uint16_t ls, } vp->var_to_check = &vp->var_to_check_to_free[1]; - if ((vp->minp_v2c_epi8 = srslte_vec_malloc(n_subnodes * sizeof(__m512i))) == NULL) { + if ((vp->minp_v2c_epi8 = srsran_vec_malloc(n_subnodes * sizeof(__m512i))) == NULL) { free(vp->var_to_check_to_free); free(vp->check_to_var); free(vp->soft_bits); @@ -172,7 +172,7 @@ void* create_ldpc_dec_c_avx512long_flood(uint8_t bgN, uint8_t bgM, uint16_t ls, return NULL; } - if ((vp->mins_v2c_epi8 = srslte_vec_malloc(n_subnodes * sizeof(__m512i))) == NULL) { + if ((vp->mins_v2c_epi8 = srsran_vec_malloc(n_subnodes * sizeof(__m512i))) == NULL) { free(vp->minp_v2c_epi8); free(vp->var_to_check_to_free); free(vp->check_to_var); @@ -182,7 +182,7 @@ void* create_ldpc_dec_c_avx512long_flood(uint8_t bgN, uint8_t bgM, uint16_t ls, return NULL; } - if ((vp->prod_v2c_epi8 = srslte_vec_malloc(n_subnodes * sizeof(__m512i))) == NULL) { + if ((vp->prod_v2c_epi8 = srsran_vec_malloc(n_subnodes * sizeof(__m512i))) == NULL) { free(vp->mins_v2c_epi8); free(vp->minp_v2c_epi8); free(vp->var_to_check_to_free); @@ -193,7 +193,7 @@ void* create_ldpc_dec_c_avx512long_flood(uint8_t bgN, uint8_t bgM, uint16_t ls, return NULL; } - if ((vp->min_ix_epi8 = srslte_vec_malloc(n_subnodes * sizeof(__m512i))) == NULL) { + if ((vp->min_ix_epi8 = srsran_vec_malloc(n_subnodes * sizeof(__m512i))) == NULL) { free(vp->prod_v2c_epi8); free(vp->mins_v2c_epi8); free(vp->minp_v2c_epi8); @@ -205,7 +205,7 @@ void* create_ldpc_dec_c_avx512long_flood(uint8_t bgN, uint8_t bgM, uint16_t ls, return NULL; } - if ((vp->rotated_v2c = srslte_vec_malloc((hrr + 1) * n_subnodes * sizeof(__m512i))) == NULL) { + if ((vp->rotated_v2c = srsran_vec_malloc((hrr + 1) * n_subnodes * sizeof(__m512i))) == NULL) { free(vp->min_ix_epi8); free(vp->prod_v2c_epi8); free(vp->mins_v2c_epi8); @@ -218,7 +218,7 @@ void* create_ldpc_dec_c_avx512long_flood(uint8_t bgN, uint8_t bgM, uint16_t ls, return NULL; } - if ((vp->this_c2v_epi8_to_free = srslte_vec_malloc((n_subnodes + 2) * sizeof(__m512i))) == NULL) { + if ((vp->this_c2v_epi8_to_free = srsran_vec_malloc((n_subnodes + 2) * sizeof(__m512i))) == NULL) { free(vp->rotated_v2c); free(vp->min_ix_epi8); free(vp->prod_v2c_epi8); @@ -284,13 +284,13 @@ int init_ldpc_dec_c_avx512long_flood(void* p, const int8_t* llrs, uint16_t ls) } for (i = 2; i < vp->bgN; i++) { for (j = 0; j < vp->n_subnodes; j++) { - for (k = 0; (k < SRSLTE_AVX512_B_SIZE) && (j * SRSLTE_AVX512_B_SIZE + k < ls); k++) { - vp->soft_bits[i * vp->n_subnodes + j].c[k] = llrs[(i - 2) * ls + j * SRSLTE_AVX512_B_SIZE + k]; + for (k = 0; (k < SRSRAN_AVX512_B_SIZE) && (j * SRSRAN_AVX512_B_SIZE + k < ls); k++) { + vp->soft_bits[i * vp->n_subnodes + j].c[k] = llrs[(i - 2) * ls + j * SRSRAN_AVX512_B_SIZE + k]; } vp->llrs[i * vp->n_subnodes + j] = vp->soft_bits[i * vp->n_subnodes + j].v; } - bzero(&(vp->soft_bits[i * vp->n_subnodes + j - 1].c[k]), (SRSLTE_AVX512_B_SIZE - k) * sizeof(int8_t)); - bzero((int8_t*)(vp->llrs + i * vp->n_subnodes + j - 1) + k, (SRSLTE_AVX512_B_SIZE - k) * sizeof(int8_t)); + bzero(&(vp->soft_bits[i * vp->n_subnodes + j - 1].c[k]), (SRSRAN_AVX512_B_SIZE - k) * sizeof(int8_t)); + bzero((int8_t*)(vp->llrs + i * vp->n_subnodes + j - 1) + k, (SRSRAN_AVX512_B_SIZE - k) * sizeof(int8_t)); } bzero(vp->check_to_var, (vp->hrr + 1) * vp->bgM * vp->n_subnodes * sizeof(__m512i)); @@ -492,8 +492,8 @@ int extract_ldpc_message_c_avx512long_flood(void* p, uint8_t* message, uint16_t for (int i = 0; i < liftK / vp->ls; i++) { for (j = 0; j < vp->n_subnodes; j++) { - for (k = 0; (k < SRSLTE_AVX512_B_SIZE) && (j * SRSLTE_AVX512_B_SIZE + k < vp->ls); k++) { - message[i * vp->ls + j * SRSLTE_AVX512_B_SIZE + k] = (vp->soft_bits[i * vp->n_subnodes + j].c[k] < 0); + for (k = 0; (k < SRSRAN_AVX512_B_SIZE) && (j * SRSRAN_AVX512_B_SIZE + k < vp->ls); k++) { + message[i * vp->ls + j * SRSRAN_AVX512_B_SIZE + k] = (vp->soft_bits[i * vp->n_subnodes + j].c[k] < 0); } } } @@ -548,7 +548,7 @@ static void rotate_node_right(const uint8_t* mem_addr, __m512i* out, uint16_t th int jj = 0; // copy full avx512 registers from this_shift_2 - for (j = this_shift; j <= ls - SRSLTE_AVX512_B_SIZE; j = j + SRSLTE_AVX512_B_SIZE) { + for (j = this_shift; j <= ls - SRSRAN_AVX512_B_SIZE; j = j + SRSRAN_AVX512_B_SIZE) { out[jj] = _mm512_loadu_si512(mem_addr + j); jj = jj + 1; } @@ -556,7 +556,7 @@ static void rotate_node_right(const uint8_t* mem_addr, __m512i* out, uint16_t th // if the last is broken, take _shift bits from the end and "shift" bits from the begin. if (ls > j) { _shift = ls - j; - shift = SRSLTE_AVX512_B_SIZE - _shift; + shift = SRSRAN_AVX512_B_SIZE - _shift; mask1 = (1ULL << _shift) - 1; // i.e. 000001111 _shift =4 mask2 = (1ULL << shift) - 1; mask2 = mask2 << _shift; // i.e. 000110000 shift = 2, _shift = 4 @@ -568,7 +568,7 @@ static void rotate_node_right(const uint8_t* mem_addr, __m512i* out, uint16_t th } // copy full avx512 registers from the start of mem_addr, - for (j = shift; j < this_shift; j = j + SRSLTE_AVX512_B_SIZE) { + for (j = shift; j < this_shift; j = j + SRSRAN_AVX512_B_SIZE) { out[jj] = _mm512_loadu_si512(mem_addr + j); // the excess is filled with something arbitrary jj = jj + 1; diff --git a/lib/src/phy/fec/ldpc/ldpc_dec_c_flood.c b/lib/src/phy/fec/ldpc/ldpc_dec_c_flood.c index b72564931..0a7ba7d24 100644 --- a/lib/src/phy/fec/ldpc/ldpc_dec_c_flood.c +++ b/lib/src/phy/fec/ldpc/ldpc_dec_c_flood.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -31,8 +31,8 @@ #include #include "ldpc_dec_all.h" -#include "srslte/phy/fec/ldpc/base_graph.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/fec/ldpc/base_graph.h" +#include "srsran/phy/utils/vector.h" #define F2I 100 /*!< \brief Used for float to int conversion---float f is stored as (int)(f*F2I). */ @@ -89,25 +89,25 @@ void* create_ldpc_dec_c_flood(uint8_t bgN, uint8_t bgM, uint16_t ls, float scali return NULL; } - if ((vp->llrs = srslte_vec_i8_malloc(liftN)) == NULL) { + if ((vp->llrs = srsran_vec_i8_malloc(liftN)) == NULL) { free(vp); return NULL; } - if ((vp->soft_bits = srslte_vec_i8_malloc(liftN)) == NULL) { + if ((vp->soft_bits = srsran_vec_i8_malloc(liftN)) == NULL) { free(vp->llrs); free(vp); return NULL; } - if ((vp->check_to_var = srslte_vec_i8_malloc((hrrN + ls) * bgM)) == NULL) { + if ((vp->check_to_var = srsran_vec_i8_malloc((hrrN + ls) * bgM)) == NULL) { free(vp->soft_bits); free(vp->llrs); free(vp); return NULL; } - if ((vp->var_to_check = srslte_vec_i8_malloc((hrrN + ls) * bgM)) == NULL) { + if ((vp->var_to_check = srsran_vec_i8_malloc((hrrN + ls) * bgM)) == NULL) { free(vp->check_to_var); free(vp->soft_bits); free(vp->llrs); @@ -124,7 +124,7 @@ void* create_ldpc_dec_c_flood(uint8_t bgN, uint8_t bgM, uint16_t ls, float scali return NULL; } - if ((vp->min_v_index = srslte_vec_i32_malloc(ls)) == NULL) { + if ((vp->min_v_index = srsran_vec_i32_malloc(ls)) == NULL) { free(vp->min_v2c); free(vp->var_to_check); free(vp->check_to_var); @@ -134,7 +134,7 @@ void* create_ldpc_dec_c_flood(uint8_t bgN, uint8_t bgM, uint16_t ls, float scali return NULL; } - if ((vp->prod_v2c = srslte_vec_i32_malloc(ls)) == NULL) { + if ((vp->prod_v2c = srsran_vec_i32_malloc(ls)) == NULL) { free(vp->min_v_index); free(vp->min_v2c); free(vp->var_to_check); diff --git a/lib/src/phy/fec/ldpc/ldpc_dec_f.c b/lib/src/phy/fec/ldpc/ldpc_dec_f.c index 285ccafee..486269593 100644 --- a/lib/src/phy/fec/ldpc/ldpc_dec_f.c +++ b/lib/src/phy/fec/ldpc/ldpc_dec_f.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -29,9 +29,9 @@ #include "ldpc_dec_all.h" #include "math.h" -#include "srslte/phy/fec/ldpc/base_graph.h" +#include "srsran/phy/fec/ldpc/base_graph.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/utils/vector.h" /*! * \brief Inner registers for the LDPC decoder that works with real-valued LLRs. @@ -63,18 +63,18 @@ void* create_ldpc_dec_f(uint8_t bgN, uint8_t bgM, uint16_t ls, float scaling_fct return NULL; } - if ((vp->soft_bits = srslte_vec_f_malloc(liftN)) == NULL) { + if ((vp->soft_bits = srsran_vec_f_malloc(liftN)) == NULL) { free(vp); return NULL; } - if ((vp->check_to_var = srslte_vec_f_malloc((hrrN + ls) * bgM)) == NULL) { + if ((vp->check_to_var = srsran_vec_f_malloc((hrrN + ls) * bgM)) == NULL) { free(vp->soft_bits); free(vp); return NULL; } - if ((vp->var_to_check = srslte_vec_f_malloc((hrrN + ls))) == NULL) { + if ((vp->var_to_check = srsran_vec_f_malloc((hrrN + ls))) == NULL) { free(vp->check_to_var); free(vp->soft_bits); free(vp); @@ -89,7 +89,7 @@ void* create_ldpc_dec_f(uint8_t bgN, uint8_t bgM, uint16_t ls, float scaling_fct return NULL; } - if ((vp->min_v_index = srslte_vec_i32_malloc(ls)) == NULL) { + if ((vp->min_v_index = srsran_vec_i32_malloc(ls)) == NULL) { free(vp->min_v2c); free(vp->var_to_check); free(vp->check_to_var); @@ -98,7 +98,7 @@ void* create_ldpc_dec_f(uint8_t bgN, uint8_t bgM, uint16_t ls, float scaling_fct return NULL; } - if ((vp->prod_v2c = srslte_vec_i32_malloc(ls)) == NULL) { + if ((vp->prod_v2c = srsran_vec_i32_malloc(ls)) == NULL) { free(vp->min_v_index); free(vp->min_v2c); free(vp->var_to_check); @@ -163,11 +163,11 @@ int update_ldpc_var_to_check_f(void* p, int i_layer) float* this_check_to_var = vp->check_to_var + i_layer * (vp->hrrN + vp->ls); // Update the high-rate region. - srslte_vec_sub_fff(vp->soft_bits, this_check_to_var, vp->var_to_check, vp->hrrN); + srsran_vec_sub_fff(vp->soft_bits, this_check_to_var, vp->var_to_check, vp->hrrN); if (i_layer >= 4) { // Update the extension region. - srslte_vec_sub_fff(vp->soft_bits + vp->hrrN + (i_layer - 4) * vp->ls, + srsran_vec_sub_fff(vp->soft_bits + vp->hrrN + (i_layer - 4) * vp->ls, this_check_to_var + vp->hrrN, vp->var_to_check + vp->hrrN, vp->ls); diff --git a/lib/src/phy/fec/ldpc/ldpc_dec_s.c b/lib/src/phy/fec/ldpc/ldpc_dec_s.c index d77a93bf6..867994a58 100644 --- a/lib/src/phy/fec/ldpc/ldpc_dec_s.c +++ b/lib/src/phy/fec/ldpc/ldpc_dec_s.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -31,8 +31,8 @@ #include #include "ldpc_dec_all.h" -#include "srslte/phy/fec/ldpc/base_graph.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/fec/ldpc/base_graph.h" +#include "srsran/phy/utils/vector.h" #define F2I 100 /*!< \brief Used for float to int conversion---float f is stored as (int)(f*F2I). */ @@ -88,18 +88,18 @@ void* create_ldpc_dec_s(uint8_t bgN, uint8_t bgM, uint16_t ls, float scaling_fct return NULL; } - if ((vp->soft_bits = srslte_vec_i16_malloc(liftN)) == NULL) { + if ((vp->soft_bits = srsran_vec_i16_malloc(liftN)) == NULL) { free(vp); return NULL; } - if ((vp->check_to_var = srslte_vec_i16_malloc((hrrN + ls) * bgM)) == NULL) { + if ((vp->check_to_var = srsran_vec_i16_malloc((hrrN + ls) * bgM)) == NULL) { free(vp->soft_bits); free(vp); return NULL; } - if ((vp->var_to_check = srslte_vec_i16_malloc(hrrN + ls)) == NULL) { + if ((vp->var_to_check = srsran_vec_i16_malloc(hrrN + ls)) == NULL) { free(vp->check_to_var); free(vp->soft_bits); free(vp); @@ -114,7 +114,7 @@ void* create_ldpc_dec_s(uint8_t bgN, uint8_t bgM, uint16_t ls, float scaling_fct return NULL; } - if ((vp->min_v_index = srslte_vec_i32_malloc(ls)) == NULL) { + if ((vp->min_v_index = srsran_vec_i32_malloc(ls)) == NULL) { free(vp->min_v2c); free(vp->var_to_check); free(vp->check_to_var); @@ -123,7 +123,7 @@ void* create_ldpc_dec_s(uint8_t bgN, uint8_t bgM, uint16_t ls, float scaling_fct return NULL; } - if ((vp->prod_v2c = srslte_vec_i32_malloc(ls)) == NULL) { + if ((vp->prod_v2c = srsran_vec_i32_malloc(ls)) == NULL) { free(vp->min_v_index); free(vp->min_v2c); free(vp->var_to_check); diff --git a/lib/src/phy/fec/ldpc/ldpc_decoder.c b/lib/src/phy/fec/ldpc/ldpc_decoder.c index 641e7195b..04a5eaf85 100644 --- a/lib/src/phy/fec/ldpc/ldpc_decoder.c +++ b/lib/src/phy/fec/ldpc/ldpc_decoder.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -25,17 +25,17 @@ #include "../utils_avx2.h" #include "../utils_avx512.h" #include "ldpc_dec_all.h" -#include "srslte/phy/fec/ldpc/base_graph.h" -#include "srslte/phy/fec/ldpc/ldpc_decoder.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/fec/ldpc/base_graph.h" +#include "srsran/phy/fec/ldpc/ldpc_decoder.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" #define MAX_ITERATIONS 10 /*!< \brief Iterations of the BP algorithm. */ /*! Carries out the actual destruction of the memory allocated to the decoder, float-LLR case. */ static void free_dec_f(void* o) { - srslte_ldpc_decoder_t* q = o; + srsran_ldpc_decoder_t* q = o; if (q->var_indices) { free(q->var_indices); } @@ -48,7 +48,7 @@ static void free_dec_f(void* o) /*! Carries out the decoding with real-valued LLRs. */ static int decode_f(void* o, const float* llrs, uint8_t* message, uint32_t cdwd_rm_length) { - srslte_ldpc_decoder_t* q = o; + srsran_ldpc_decoder_t* q = o; if (cdwd_rm_length > q->liftN - 2 * q->ls) { cdwd_rm_length = q->liftN - 2 * q->ls; @@ -94,7 +94,7 @@ static int decode_f(void* o, const float* llrs, uint8_t* message, uint32_t cdwd_ } /*! Initializes the decoder to work with real valued LLRs. */ -static int init_f(srslte_ldpc_decoder_t* q) +static int init_f(srsran_ldpc_decoder_t* q) { q->free = free_dec_f; @@ -112,7 +112,7 @@ static int init_f(srslte_ldpc_decoder_t* q) /*! Carries out the actual destruction of the memory allocated to the decoder, 16-bit-LLR case. */ static void free_dec_s(void* o) { - srslte_ldpc_decoder_t* q = o; + srsran_ldpc_decoder_t* q = o; if (q->var_indices) { free(q->var_indices); } @@ -125,7 +125,7 @@ static void free_dec_s(void* o) /*! Carries out the decoding with 16-bit integer-valued LLRs. */ static int decode_s(void* o, const int16_t* llrs, uint8_t* message, uint32_t cdwd_rm_length) { - srslte_ldpc_decoder_t* q = o; + srsran_ldpc_decoder_t* q = o; // it must be smaller than the codeword size if (cdwd_rm_length > q->liftN - 2 * q->ls) { @@ -172,7 +172,7 @@ static int decode_s(void* o, const int16_t* llrs, uint8_t* message, uint32_t cdw } /*! Initializes the decoder to work with 16-bit integer-valued LLRs. */ -static int init_s(srslte_ldpc_decoder_t* q) +static int init_s(srsran_ldpc_decoder_t* q) { q->free = free_dec_s; @@ -190,7 +190,7 @@ static int init_s(srslte_ldpc_decoder_t* q) /*! Carries out the actual destruction of the memory allocated to the decoder, 8-bit-LLR case. */ static void free_dec_c(void* o) { - srslte_ldpc_decoder_t* q = o; + srsran_ldpc_decoder_t* q = o; if (q->var_indices) { free(q->var_indices); } @@ -203,7 +203,7 @@ static void free_dec_c(void* o) /*! Carries out the decoding with 8-bit integer-valued LLRs. */ static int decode_c(void* o, const int8_t* llrs, uint8_t* message, uint32_t cdwd_rm_length) { - srslte_ldpc_decoder_t* q = o; + srsran_ldpc_decoder_t* q = o; // it must be smaller than the codeword size if (cdwd_rm_length > q->liftN - 2 * q->ls) { @@ -250,7 +250,7 @@ static int decode_c(void* o, const int8_t* llrs, uint8_t* message, uint32_t cdwd } /*! Initializes the decoder to work with 8-bit integer-valued LLRs. */ -static int init_c(srslte_ldpc_decoder_t* q) +static int init_c(srsran_ldpc_decoder_t* q) { q->free = free_dec_c; @@ -268,7 +268,7 @@ static int init_c(srslte_ldpc_decoder_t* q) /*! Carries out the actual destruction of the memory allocated to the decoder, 8-bit-LLR flooded case. */ static void free_dec_c_flood(void* o) { - srslte_ldpc_decoder_t* q = o; + srsran_ldpc_decoder_t* q = o; if (q->var_indices) { free(q->var_indices); } @@ -281,7 +281,7 @@ static void free_dec_c_flood(void* o) /*! Carries out the decoding with 8-bit integer-valued LLRs, flooded scheduling. */ static int decode_c_flood(void* o, const int8_t* llrs, uint8_t* message, uint32_t cdwd_rm_length) { - srslte_ldpc_decoder_t* q = o; + srsran_ldpc_decoder_t* q = o; // it must be smaller than the codeword size if (cdwd_rm_length > q->liftN - 2 * q->ls) { @@ -328,7 +328,7 @@ static int decode_c_flood(void* o, const int8_t* llrs, uint8_t* message, uint32_ } /*! Initializes the decoder to work with 8-bit integer-valued LLRs. */ -static int init_c_flood(srslte_ldpc_decoder_t* q) +static int init_c_flood(srsran_ldpc_decoder_t* q) { q->free = free_dec_c_flood; @@ -347,7 +347,7 @@ static int init_c_flood(srslte_ldpc_decoder_t* q) /*! Carries out the actual destruction of the memory allocated to the decoder, 8-bit-LLR case (AVX2 implementation). */ static void free_dec_c_avx2(void* o) { - srslte_ldpc_decoder_t* q = o; + srsran_ldpc_decoder_t* q = o; if (q->var_indices) { free(q->var_indices); } @@ -360,7 +360,7 @@ static void free_dec_c_avx2(void* o) /*! Carries out the decoding with 8-bit integer-valued LLRs (AVX2 implementation). */ static int decode_c_avx2(void* o, const int8_t* llrs, uint8_t* message, uint32_t cdwd_rm_length) { - srslte_ldpc_decoder_t* q = o; + srsran_ldpc_decoder_t* q = o; // it must be smaller than the codeword size if (cdwd_rm_length > q->liftN - 2 * q->ls) { @@ -406,7 +406,7 @@ static int decode_c_avx2(void* o, const int8_t* llrs, uint8_t* message, uint32_t } /*! Initializes the decoder to work with 8-bit integer-valued LLRs (AVX2 implementation). */ -static int init_c_avx2(srslte_ldpc_decoder_t* q) +static int init_c_avx2(srsran_ldpc_decoder_t* q) { q->free = free_dec_c_avx2; @@ -425,7 +425,7 @@ static int init_c_avx2(srslte_ldpc_decoder_t* q) * large lifting size). */ static void free_dec_c_avx2long(void* o) { - srslte_ldpc_decoder_t* q = o; + srsran_ldpc_decoder_t* q = o; if (q->var_indices) { free(q->var_indices); } @@ -438,7 +438,7 @@ static void free_dec_c_avx2long(void* o) /*! Carries out the decoding with 8-bit integer-valued LLRs (AVX2 implementation, large lifting size). */ static int decode_c_avx2long(void* o, const int8_t* llrs, uint8_t* message, uint32_t cdwd_rm_length) { - srslte_ldpc_decoder_t* q = o; + srsran_ldpc_decoder_t* q = o; // it must be smaller than the codeword size if (cdwd_rm_length > q->liftN - 2 * q->ls) { @@ -484,7 +484,7 @@ static int decode_c_avx2long(void* o, const int8_t* llrs, uint8_t* message, uint } /*! Initializes the decoder to work with 8-bit integer-valued LLRs (AVX2 implementation, large lifting size). */ -static int init_c_avx2long(srslte_ldpc_decoder_t* q) +static int init_c_avx2long(srsran_ldpc_decoder_t* q) { q->free = free_dec_c_avx2long; @@ -503,7 +503,7 @@ static int init_c_avx2long(srslte_ldpc_decoder_t* q) * flooded scheduling). */ static void free_dec_c_avx2_flood(void* o) { - srslte_ldpc_decoder_t* q = o; + srsran_ldpc_decoder_t* q = o; if (q->var_indices) { free(q->var_indices); } @@ -516,7 +516,7 @@ static void free_dec_c_avx2_flood(void* o) /*! Carries out the decoding with 8-bit integer-valued LLRs (AVX2 implementation, flooded scheduling). */ static int decode_c_avx2_flood(void* o, const int8_t* llrs, uint8_t* message, uint32_t cdwd_rm_length) { - srslte_ldpc_decoder_t* q = o; + srsran_ldpc_decoder_t* q = o; // it must be smaller than the codeword size if (cdwd_rm_length > q->liftN - 2 * q->ls) { @@ -563,7 +563,7 @@ static int decode_c_avx2_flood(void* o, const int8_t* llrs, uint8_t* message, ui } /*! Initializes the decoder to work with 8-bit integer-valued LLRs (AVX2 implementation, flooded scheduling). */ -static int init_c_avx2_flood(srslte_ldpc_decoder_t* q) +static int init_c_avx2_flood(srsran_ldpc_decoder_t* q) { q->free = free_dec_c_avx2_flood; @@ -582,7 +582,7 @@ static int init_c_avx2_flood(srslte_ldpc_decoder_t* q) * (flooded scheduling, AVX2 implementation, large lifting size). */ static void free_dec_c_avx2long_flood(void* o) { - srslte_ldpc_decoder_t* q = o; + srsran_ldpc_decoder_t* q = o; if (q->var_indices) { free(q->var_indices); } @@ -596,7 +596,7 @@ static void free_dec_c_avx2long_flood(void* o) * size). */ static int decode_c_avx2long_flood(void* o, const int8_t* llrs, uint8_t* message, uint32_t cdwd_rm_length) { - srslte_ldpc_decoder_t* q = o; + srsran_ldpc_decoder_t* q = o; // it must be smaller than the codeword size if (cdwd_rm_length > q->liftN - 2 * q->ls) { @@ -645,7 +645,7 @@ static int decode_c_avx2long_flood(void* o, const int8_t* llrs, uint8_t* message /*! Initializes the decoder to work with 8-bit integer-valued LLRs * (flooded scheduling, AVX2 implementation, large lifting size). */ -static int init_c_avx2long_flood(srslte_ldpc_decoder_t* q) +static int init_c_avx2long_flood(srsran_ldpc_decoder_t* q) { q->free = free_dec_c_avx2long_flood; @@ -669,7 +669,7 @@ static int init_c_avx2long_flood(srslte_ldpc_decoder_t* q) */ static void free_dec_c_avx512(void* o) { - srslte_ldpc_decoder_t* q = o; + srsran_ldpc_decoder_t* q = o; if (q->var_indices) { free(q->var_indices); } @@ -682,7 +682,7 @@ static void free_dec_c_avx512(void* o) /*! Carries out the decoding with 8-bit integer-valued LLRs (AVX512 implementation). */ static int decode_c_avx512(void* o, const int8_t* llrs, uint8_t* message, uint32_t cdwd_rm_length) { - srslte_ldpc_decoder_t* q = o; + srsran_ldpc_decoder_t* q = o; // it must be smaller than the codeword size if (cdwd_rm_length > q->liftN - 2 * q->ls) { @@ -728,7 +728,7 @@ static int decode_c_avx512(void* o, const int8_t* llrs, uint8_t* message, uint32 } /*! Initializes the decoder to work with 8-bit integer-valued LLRs (AVX512 implementation). */ -static int init_c_avx512(srslte_ldpc_decoder_t* q) +static int init_c_avx512(srsran_ldpc_decoder_t* q) { q->free = free_dec_c_avx512; @@ -747,7 +747,7 @@ static int init_c_avx512(srslte_ldpc_decoder_t* q) * large lifting size). */ static void free_dec_c_avx512long(void* o) { - srslte_ldpc_decoder_t* q = o; + srsran_ldpc_decoder_t* q = o; if (q->var_indices) { free(q->var_indices); } @@ -760,7 +760,7 @@ static void free_dec_c_avx512long(void* o) /*! Carries out the decoding with 8-bit integer-valued LLRs (AVX512 implementation, large lifting size). */ static int decode_c_avx512long(void* o, const int8_t* llrs, uint8_t* message, uint32_t cdwd_rm_length) { - srslte_ldpc_decoder_t* q = o; + srsran_ldpc_decoder_t* q = o; // it must be smaller than the codeword size if (cdwd_rm_length > q->liftN - 2 * q->ls) { @@ -806,7 +806,7 @@ static int decode_c_avx512long(void* o, const int8_t* llrs, uint8_t* message, ui } /*! Initializes the decoder to work with 8-bit integer-valued LLRs (AVX512 implementation, large lifting size). */ -static int init_c_avx512long(srslte_ldpc_decoder_t* q) +static int init_c_avx512long(srsran_ldpc_decoder_t* q) { q->free = free_dec_c_avx512long; @@ -825,7 +825,7 @@ static int init_c_avx512long(srslte_ldpc_decoder_t* q) * (flooded scheduling, AVX512 implementation, large lifting size). */ static void free_dec_c_avx512long_flood(void* o) { - srslte_ldpc_decoder_t* q = o; + srsran_ldpc_decoder_t* q = o; if (q->var_indices) { free(q->var_indices); } @@ -839,7 +839,7 @@ static void free_dec_c_avx512long_flood(void* o) * size). */ static int decode_c_avx512long_flood(void* o, const int8_t* llrs, uint8_t* message, uint32_t cdwd_rm_length) { - srslte_ldpc_decoder_t* q = o; + srsran_ldpc_decoder_t* q = o; // it must be smaller than the codeword size if (cdwd_rm_length > q->liftN - 2 * q->ls) { @@ -888,7 +888,7 @@ static int decode_c_avx512long_flood(void* o, const int8_t* llrs, uint8_t* messa /*! Initializes the decoder to work with 8-bit integer-valued LLRs * (flooded scheduling, AVX512 implementation, large lifting size). */ -static int init_c_avx512long_flood(srslte_ldpc_decoder_t* q) +static int init_c_avx512long_flood(srsran_ldpc_decoder_t* q) { q->free = free_dec_c_avx512long_flood; @@ -905,9 +905,9 @@ static int init_c_avx512long_flood(srslte_ldpc_decoder_t* q) #endif // LV_HAVE_AVX512 -int srslte_ldpc_decoder_init(srslte_ldpc_decoder_t* q, - srslte_ldpc_decoder_type_t type, - srslte_basegraph_t bg, +int srsran_ldpc_decoder_init(srsran_ldpc_decoder_t* q, + srsran_ldpc_decoder_type_t type, + srsran_basegraph_t bg, uint16_t ls, float scaling_fctr) { @@ -939,13 +939,13 @@ int srslte_ldpc_decoder_init(srslte_ldpc_decoder_t* q, q->liftM = ls * q->bgM; q->liftN = ls * q->bgN; - q->pcm = srslte_vec_u16_malloc(q->bgM * q->bgN); + q->pcm = srsran_vec_u16_malloc(q->bgM * q->bgN); if (!q->pcm) { perror("malloc"); return -1; } - q->var_indices = srslte_vec_malloc(q->bgM * sizeof(int8_t[MAX_CNCT])); + q->var_indices = srsran_vec_malloc(q->bgM * sizeof(int8_t[MAX_CNCT])); if (!q->var_indices) { free(q->pcm); perror("malloc"); @@ -968,36 +968,36 @@ int srslte_ldpc_decoder_init(srslte_ldpc_decoder_t* q, q->scaling_fctr = scaling_fctr; switch (type) { - case SRSLTE_LDPC_DECODER_F: + case SRSRAN_LDPC_DECODER_F: return init_f(q); - case SRSLTE_LDPC_DECODER_S: + case SRSRAN_LDPC_DECODER_S: return init_s(q); - case SRSLTE_LDPC_DECODER_C: + case SRSRAN_LDPC_DECODER_C: return init_c(q); - case SRSLTE_LDPC_DECODER_C_FLOOD: + case SRSRAN_LDPC_DECODER_C_FLOOD: return init_c_flood(q); #ifdef LV_HAVE_AVX2 - case SRSLTE_LDPC_DECODER_C_AVX2: - if (ls <= SRSLTE_AVX2_B_SIZE) { + case SRSRAN_LDPC_DECODER_C_AVX2: + if (ls <= SRSRAN_AVX2_B_SIZE) { return init_c_avx2(q); } else { return init_c_avx2long(q); } - case SRSLTE_LDPC_DECODER_C_AVX2_FLOOD: - if (ls <= SRSLTE_AVX2_B_SIZE) { + case SRSRAN_LDPC_DECODER_C_AVX2_FLOOD: + if (ls <= SRSRAN_AVX2_B_SIZE) { return init_c_avx2_flood(q); } else { return init_c_avx2long_flood(q); } #endif // LV_HAVE_AVX2 #ifdef LV_HAVE_AVX512 - case SRSLTE_LDPC_DECODER_C_AVX512: - if (ls <= SRSLTE_AVX512_B_SIZE) { + case SRSRAN_LDPC_DECODER_C_AVX512: + if (ls <= SRSRAN_AVX512_B_SIZE) { return init_c_avx512(q); } else { return init_c_avx512long(q); } - case SRSLTE_LDPC_DECODER_C_AVX512_FLOOD: + case SRSRAN_LDPC_DECODER_C_AVX512_FLOOD: return init_c_avx512long_flood(q); #endif // LV_HAVE_AVX2 @@ -1007,20 +1007,20 @@ int srslte_ldpc_decoder_init(srslte_ldpc_decoder_t* q, } } -void srslte_ldpc_decoder_free(srslte_ldpc_decoder_t* q) +void srsran_ldpc_decoder_free(srsran_ldpc_decoder_t* q) { if (q->free) { q->free(q); } - bzero(q, sizeof(srslte_ldpc_decoder_t)); + bzero(q, sizeof(srsran_ldpc_decoder_t)); } -int srslte_ldpc_decoder_decode_f(srslte_ldpc_decoder_t* q, const float* llrs, uint8_t* message, uint32_t cdwd_rm_length) +int srsran_ldpc_decoder_decode_f(srsran_ldpc_decoder_t* q, const float* llrs, uint8_t* message, uint32_t cdwd_rm_length) { return q->decode_f(q, llrs, message, cdwd_rm_length); } -int srslte_ldpc_decoder_decode_s(srslte_ldpc_decoder_t* q, +int srsran_ldpc_decoder_decode_s(srsran_ldpc_decoder_t* q, const int16_t* llrs, uint8_t* message, uint32_t cdwd_rm_length) @@ -1028,12 +1028,12 @@ int srslte_ldpc_decoder_decode_s(srslte_ldpc_decoder_t* q, return q->decode_s(q, llrs, message, cdwd_rm_length); } -int srslte_ldpc_decoder_decode_c(srslte_ldpc_decoder_t* q, const int8_t* llrs, uint8_t* message) +int srsran_ldpc_decoder_decode_c(srsran_ldpc_decoder_t* q, const int8_t* llrs, uint8_t* message) { return q->decode_c(q, llrs, message, q->liftN - 2 * q->ls); } -int srslte_ldpc_decoder_decode_rm_c(srslte_ldpc_decoder_t* q, +int srsran_ldpc_decoder_decode_rm_c(srsran_ldpc_decoder_t* q, const int8_t* llrs, uint8_t* message, uint32_t cdwd_rm_length) diff --git a/lib/src/phy/fec/ldpc/ldpc_enc_all.h b/lib/src/phy/fec/ldpc/ldpc_enc_all.h index fc5e5792b..5b967a22b 100644 --- a/lib/src/phy/fec/ldpc/ldpc_enc_all.h +++ b/lib/src/phy/fec/ldpc/ldpc_enc_all.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -20,15 +20,15 @@ * */ -#ifndef SRSLTE_LDPCENC_ALL_H -#define SRSLTE_LDPCENC_ALL_H -#include "srslte/phy/fec/ldpc/ldpc_encoder.h" +#ifndef SRSRAN_LDPCENC_ALL_H +#define SRSRAN_LDPCENC_ALL_H +#include "srsran/phy/fec/ldpc/ldpc_encoder.h" /*! Computes the product between the first (K - 2) columns of the PCM and the systematic bits. * \param[in,out] q A pointer to an encoder. * \param[in] input The message to encode. */ -void preprocess_systematic_bits(srslte_ldpc_encoder_t* q, const uint8_t* input); +void preprocess_systematic_bits(srsran_ldpc_encoder_t* q, const uint8_t* input); /*! Computes the high-rate parity bits for BG1 and ls_index in {0, 1, 2, 3, 4, 5, 7}. * \param[in] o A pointer to an encoder. @@ -60,23 +60,23 @@ void encode_high_rate_case4(void* o, uint8_t* output); * \param[in] n_layers The number of layers to process (when doing rate matching not all * layers are needed). */ -void encode_ext_region(srslte_ldpc_encoder_t* q, uint8_t* output, uint8_t n_layers); +void encode_ext_region(srsran_ldpc_encoder_t* q, uint8_t* output, uint8_t n_layers); /*! - * Creates the inner registers required by the optimized LDPC encoder (LS <= \ref SRSLTE_AVX512_B_SIZE). + * Creates the inner registers required by the optimized LDPC encoder (LS <= \ref SRSRAN_AVX512_B_SIZE). * \param[in,out] q A pointer to an encoder. * \return A pointer to the newly created structure of registers. */ -void* create_ldpc_enc_avx2(srslte_ldpc_encoder_t* q); +void* create_ldpc_enc_avx2(srsran_ldpc_encoder_t* q); /*! - * Deletes the inner registers of an optimized LDPC encoder (LS <= \ref SRSLTE_AVX2_B_SIZE). + * Deletes the inner registers of an optimized LDPC encoder (LS <= \ref SRSRAN_AVX2_B_SIZE). * \param[in] p A pointer to the register structure. */ void delete_ldpc_enc_avx2(void* p); /*! - * Loads the message in the opimized encoder registers (LS <= \ref SRSLTE_AVX2_B_SIZE). + * Loads the message in the opimized encoder registers (LS <= \ref SRSRAN_AVX2_B_SIZE). * \param[in] p The register structure. * \param[in] input The message to encode. * \param[in] msg_len Number of variable nodes in one message. @@ -86,7 +86,7 @@ void delete_ldpc_enc_avx2(void* p); */ int load_avx2(void* p, const uint8_t* input, uint8_t msg_len, uint8_t cdwd_len, uint16_t ls); -/*! Extracts the final codeword from the optimized encoder registers (LS <= \ref SRSLTE_AVX2_B_SIZE). +/*! Extracts the final codeword from the optimized encoder registers (LS <= \ref SRSRAN_AVX2_B_SIZE). * \param[in] p The register structure. * \param[out] output The output codeword. * \param[in] cdwd_len The number of variable nodes (after rate-matching, if enabled). @@ -96,55 +96,55 @@ int load_avx2(void* p, const uint8_t* input, uint8_t msg_len, uint8_t cdwd_len, int return_codeword_avx2(void* p, uint8_t* output, uint8_t cdwd_len, uint16_t ls); /*! Computes the product between the first (K - 2) columns of the PCM and the - * systematic bits (SIMD-optimized version, LS <= \ref SRSLTE_AVX2_B_SIZE). + * systematic bits (SIMD-optimized version, LS <= \ref SRSRAN_AVX2_B_SIZE). * \param[in,out] q A pointer to an encoder. */ -void preprocess_systematic_bits_avx2(srslte_ldpc_encoder_t* q); +void preprocess_systematic_bits_avx2(srsran_ldpc_encoder_t* q); /*! Computes the high-rate parity bits for BG1 and ls_index in {0, 1, 2, 3, 4, 5, 7} - * (SIMD-optimized version, LS <= \ref SRSLTE_AVX2_B_SIZE). + * (SIMD-optimized version, LS <= \ref SRSRAN_AVX2_B_SIZE). * \param[in,out] o A pointer to an encoder. */ void encode_high_rate_case1_avx2(void* o); /*! Computes the high-rate parity bits for BG1 and ls_index in {6} (SIMD-optimized version, LS <= \ref - * SRSLTE_AVX2_B_SIZE). \param[in,out] o A pointer to an encoder. + * SRSRAN_AVX2_B_SIZE). \param[in,out] o A pointer to an encoder. */ void encode_high_rate_case2_avx2(void* o); /*! Computes the high-rate parity bits for BG2 and ls_index in {0, 1, 2, 4, 5, 6} (SIMD-optimized version, LS <= \ref - * SRSLTE_AVX2_B_SIZE). \param[in,out] o A pointer to an encoder. + * SRSRAN_AVX2_B_SIZE). \param[in,out] o A pointer to an encoder. */ void encode_high_rate_case3_avx2(void* o); /*! Computes the high-rate parity bits for BG2 and ls_index in {3, 7} (SIMD-optimized version, LS <= \ref - * SRSLTE_AVX2_B_SIZE). + * SRSRAN_AVX2_B_SIZE). * \param[in,out] o A pointer to an encoder. */ void encode_high_rate_case4_avx2(void* o); -/*! Computes the extended-region parity bits (SIMD-optimized version, LS <= \ref SRSLTE_AVX2_B_SIZE). +/*! Computes the extended-region parity bits (SIMD-optimized version, LS <= \ref SRSRAN_AVX2_B_SIZE). * \param[in,out] q A pointer to an encoder. * \param[in] n_layers The number of layers to process (when doing rate matching not all * layers are needed). */ -void encode_ext_region_avx2(srslte_ldpc_encoder_t* q, uint8_t n_layers); +void encode_ext_region_avx2(srsran_ldpc_encoder_t* q, uint8_t n_layers); /*! - * Creates the inner registers required by the optimized LDPC encoder (for LS > \ref SRSLTE_AVX2_B_SIZE). + * Creates the inner registers required by the optimized LDPC encoder (for LS > \ref SRSRAN_AVX2_B_SIZE). * \param[in,out] q A pointer to an encoder. * \return A pointer to the newly created structure of registers. */ -void* create_ldpc_enc_avx2long(srslte_ldpc_encoder_t* q); +void* create_ldpc_enc_avx2long(srsran_ldpc_encoder_t* q); /*! - * Deletes the inner registers of an optimized LDPC encoder (LS > \ref SRSLTE_AVX2_B_SIZE). + * Deletes the inner registers of an optimized LDPC encoder (LS > \ref SRSRAN_AVX2_B_SIZE). * \param[in] p A pointer to the register structure. */ void delete_ldpc_enc_avx2long(void* p); /*! - * Loads the message in the optimized encoder registers (LS > \ref SRSLTE_AVX2_B_SIZE). + * Loads the message in the optimized encoder registers (LS > \ref SRSRAN_AVX2_B_SIZE). * \param[in] p The register structure. * \param[in] input The message to encode. * \param[in] msg_len Number of variable nodes in one message. @@ -154,7 +154,7 @@ void delete_ldpc_enc_avx2long(void* p); */ int load_avx2long(void* p, const uint8_t* input, uint8_t msg_len, uint8_t cdwd_len, uint16_t ls); -/*! Extracts the final codeword from the optimized encoder registers (LS > \ref SRSLTE_AVX2_B_SIZE). +/*! Extracts the final codeword from the optimized encoder registers (LS > \ref SRSRAN_AVX2_B_SIZE). * \param[in] p The register structure. * \param[out] output The output codeword. * \param[in] cdwd_len The number of variable nodes (after rate-matching, if enabled). @@ -164,57 +164,57 @@ int load_avx2long(void* p, const uint8_t* input, uint8_t msg_len, uint8_t cdwd_l int return_codeword_avx2long(void* p, uint8_t* output, uint8_t cdwd_len, uint16_t ls); /*! Computes the product between the first (K - 2) columns of the PCM and the - * systematic bits (SIMD-optimized version, LS > \ref SRSLTE_AVX2_B_SIZE). + * systematic bits (SIMD-optimized version, LS > \ref SRSRAN_AVX2_B_SIZE). * \param[in,out] q A pointer to an encoder. */ -void preprocess_systematic_bits_avx2long(srslte_ldpc_encoder_t* q); +void preprocess_systematic_bits_avx2long(srsran_ldpc_encoder_t* q); /*! Computes the high-rate parity bits for BG1 and ls_index in {0, 1, 2, 3, 4, 5, 7} - * (SIMD-optimized version, LS > \ref SRSLTE_AVX2_B_SIZE). + * (SIMD-optimized version, LS > \ref SRSRAN_AVX2_B_SIZE). * \param[in,out] o A pointer to an encoder. */ void encode_high_rate_case1_avx2long(void* o); /*! Computes the high-rate parity bits for BG1 and ls_index in {6} (SIMD-optimized version, LS > \ref - * SRSLTE_AVX2_B_SIZE). + * SRSRAN_AVX2_B_SIZE). * \param[in,out] o A pointer to an encoder. */ void encode_high_rate_case2_avx2long(void* o); /*! Computes the high-rate parity bits for BG2 and ls_index in {0, 1, 2, 4, 5, 6} (SIMD-optimized version, LS > \ref - * SRSLTE_AVX2_B_SIZE). + * SRSRAN_AVX2_B_SIZE). * \param[in,out] o A pointer to an encoder. */ void encode_high_rate_case3_avx2long(void* o); /*! Computes the high-rate parity bits for BG2 and ls_index in {3, 7} (SIMD-optimized version, LS > \ref - * SRSLTE_AVX2_B_SIZE). + * SRSRAN_AVX2_B_SIZE). * \param[in,out] o A pointer to an encoder. */ void encode_high_rate_case4_avx2long(void* o); -/*! Computes the extended-region parity bits (SIMD-optimized version, LS > \ref SRSLTE_AVX2_B_SIZE). +/*! Computes the extended-region parity bits (SIMD-optimized version, LS > \ref SRSRAN_AVX2_B_SIZE). * \param[in,out] q A pointer to an encoder. * \param[in] n_layers The number of layers to process (when doing rate matching not all * layers are needed). */ -void encode_ext_region_avx2long(srslte_ldpc_encoder_t* q, uint8_t n_layers); +void encode_ext_region_avx2long(srsran_ldpc_encoder_t* q, uint8_t n_layers); /*! - * Creates the inner registers required by the optimized LDPC encoder (LS <= \ref SRSLTE_AVX2_B_SIZE). + * Creates the inner registers required by the optimized LDPC encoder (LS <= \ref SRSRAN_AVX2_B_SIZE). * \param[in,out] q A pointer to an encoder. * \return A pointer to the newly created structure of registers. */ -void* create_ldpc_enc_avx2(srslte_ldpc_encoder_t* q); +void* create_ldpc_enc_avx2(srsran_ldpc_encoder_t* q); /*! - * Deletes the inner registers of an optimized LDPC encoder (LS <= \ref SRSLTE_AVX2_B_SIZE). + * Deletes the inner registers of an optimized LDPC encoder (LS <= \ref SRSRAN_AVX2_B_SIZE). * \param[in] p A pointer to the register structure. */ void delete_ldpc_enc_avx2(void* p); /*! - * Loads the message in the opimized encoder registers (LS <= \ref SRSLTE_AVX2_B_SIZE). + * Loads the message in the opimized encoder registers (LS <= \ref SRSRAN_AVX2_B_SIZE). * \param[in] p The register structure. * \param[in] input The message to encode. * \param[in] msg_len Number of variable nodes in one message. @@ -224,7 +224,7 @@ void delete_ldpc_enc_avx2(void* p); */ int load_avx2(void* p, const uint8_t* input, uint8_t msg_len, uint8_t cdwd_len, uint16_t ls); -/*! Extracts the final codeword from the optimized encoder registers (LS <= \ref SRSLTE_AVX2_B_SIZE). +/*! Extracts the final codeword from the optimized encoder registers (LS <= \ref SRSRAN_AVX2_B_SIZE). * \param[in] p The register structure. * \param[out] output The output codeword. * \param[in] cdwd_len The number of variable nodes (after rate-matching, if enabled). @@ -234,55 +234,55 @@ int load_avx2(void* p, const uint8_t* input, uint8_t msg_len, uint8_t cdwd_len, int return_codeword_avx2(void* p, uint8_t* output, uint8_t cdwd_len, uint16_t ls); /*! Computes the product between the first (K - 2) columns of the PCM and the - * systematic bits (SIMD-optimized version, LS <= \ref SRSLTE_AVX2_B_SIZE). + * systematic bits (SIMD-optimized version, LS <= \ref SRSRAN_AVX2_B_SIZE). * \param[in,out] q A pointer to an encoder. */ -void preprocess_systematic_bits_avx2(srslte_ldpc_encoder_t* q); +void preprocess_systematic_bits_avx2(srsran_ldpc_encoder_t* q); /*! Computes the high-rate parity bits for BG1 and ls_index in {0, 1, 2, 3, 4, 5, 7} - * (SIMD-optimized version, LS <= \ref SRSLTE_AVX2_B_SIZE). + * (SIMD-optimized version, LS <= \ref SRSRAN_AVX2_B_SIZE). * \param[in,out] o A pointer to an encoder. */ void encode_high_rate_case1_avx2(void* o); /*! Computes the high-rate parity bits for BG1 and ls_index in {6} (SIMD-optimized version, LS <= \ref - * SRSLTE_AVX2_B_SIZE). \param[in,out] o A pointer to an encoder. + * SRSRAN_AVX2_B_SIZE). \param[in,out] o A pointer to an encoder. */ void encode_high_rate_case2_avx2(void* o); /*! Computes the high-rate parity bits for BG2 and ls_index in {0, 1, 2, 4, 5, 6} (SIMD-optimized version, LS <= \ref - * SRSLTE_AVX2_B_SIZE). \param[in,out] o A pointer to an encoder. + * SRSRAN_AVX2_B_SIZE). \param[in,out] o A pointer to an encoder. */ void encode_high_rate_case3_avx2(void* o); /*! Computes the high-rate parity bits for BG2 and ls_index in {3, 7} (SIMD-optimized version, LS <= \ref - * SRSLTE_AVX2_B_SIZE). + * SRSRAN_AVX2_B_SIZE). \param[in,out] o A pointer to an encoder. */ void encode_high_rate_case4_avx2(void* o); -/*! Computes the extended-region parity bits (SIMD-optimized version, LS <= \ref SRSLTE_AVX2_B_SIZE). +/*! Computes the extended-region parity bits (SIMD-optimized version, LS <= \ref SRSRAN_AVX2_B_SIZE). * \param[in,out] q A pointer to an encoder. * \param[in] n_layers The number of layers to process (when doing rate matching not all * layers are needed). */ -void encode_ext_region_avx2(srslte_ldpc_encoder_t* q, uint8_t n_layers); +void encode_ext_region_avx2(srsran_ldpc_encoder_t* q, uint8_t n_layers); /*! - * Creates the inner registers required by the optimized LDPC encoder (for LS > \ref SRSLTE_avx512_B_SIZE). + * Creates the inner registers required by the optimized LDPC encoder (for LS > \ref SRSRAN_avx512_B_SIZE). * \param[in,out] q A pointer to an encoder. * \return A pointer to the newly created structure of registers. */ -void* create_ldpc_enc_avx512long(srslte_ldpc_encoder_t* q); +void* create_ldpc_enc_avx512long(srsran_ldpc_encoder_t* q); /*! - * Deletes the inner registers of an optimized LDPC encoder (LS > \ref SRSLTE_avx512_B_SIZE). + * Deletes the inner registers of an optimized LDPC encoder (LS > \ref SRSRAN_avx512_B_SIZE). * \param[in] p A pointer to the register structure. */ void delete_ldpc_enc_avx512long(void* p); /*! - * Loads the message in the optimized encoder registers (LS > \ref SRSLTE_avx512_B_SIZE). + * Loads the message in the optimized encoder registers (LS > \ref SRSRAN_avx512_B_SIZE). * \param[in] p The register structure. * \param[in] input The message to encode. * \param[in] msg_len Number of variable nodes in one message. @@ -292,7 +292,7 @@ void delete_ldpc_enc_avx512long(void* p); */ int load_avx512long(void* p, const uint8_t* input, uint8_t msg_len, uint8_t cdwd_len, uint16_t ls); -/*! Extracts the final codeword from the optimized encoder registers (LS > \ref SRSLTE_avx512_B_SIZE). +/*! Extracts the final codeword from the optimized encoder registers (LS > \ref SRSRAN_avx512_B_SIZE). * \param[in] p The register structure. * \param[out] output The output codeword. * \param[in] cdwd_len The number of variable nodes (after rate-matching, if enabled). @@ -302,57 +302,57 @@ int load_avx512long(void* p, const uint8_t* input, uint8_t msg_len, uint8_t cdwd int return_codeword_avx512long(void* p, uint8_t* output, uint8_t cdwd_len, uint16_t ls); /*! Computes the product between the first (K - 2) columns of the PCM and the - * systematic bits (SIMD-optimized version, LS > \ref SRSLTE_avx512_B_SIZE). + * systematic bits (SIMD-optimized version, LS > \ref SRSRAN_avx512_B_SIZE). * \param[in,out] q A pointer to an encoder. */ -void preprocess_systematic_bits_avx512long(srslte_ldpc_encoder_t* q); +void preprocess_systematic_bits_avx512long(srsran_ldpc_encoder_t* q); /*! Computes the high-rate parity bits for BG1 and ls_index in {0, 1, 2, 3, 4, 5, 7} - * (SIMD-optimized version, LS > \ref SRSLTE_avx512_B_SIZE). + * (SIMD-optimized version, LS > \ref SRSRAN_avx512_B_SIZE). * \param[in,out] o A pointer to an encoder. */ void encode_high_rate_case1_avx512long(void* o); /*! Computes the high-rate parity bits for BG1 and ls_index in {6} (SIMD-optimized version, LS > \ref - * SRSLTE_avx512_B_SIZE). + * SRSRAN_avx512_B_SIZE). * \param[in,out] o A pointer to an encoder. */ void encode_high_rate_case2_avx512long(void* o); /*! Computes the high-rate parity bits for BG2 and ls_index in {0, 1, 2, 4, 5, 6} (SIMD-optimized version, LS > \ref - * SRSLTE_avx512_B_SIZE). + * SRSRAN_avx512_B_SIZE). * \param[in,out] o A pointer to an encoder. */ void encode_high_rate_case3_avx512long(void* o); /*! Computes the high-rate parity bits for BG2 and ls_index in {3, 7} (SIMD-optimized version, LS > \ref - * SRSLTE_avx512_B_SIZE). + * SRSRAN_avx512_B_SIZE). * \param[in,out] o A pointer to an encoder. */ void encode_high_rate_case4_avx512long(void* o); -/*! Computes the extended-region parity bits (SIMD-optimized version, LS > \ref SRSLTE_AVX512_B_SIZE). +/*! Computes the extended-region parity bits (SIMD-optimized version, LS > \ref SRSRAN_AVX512_B_SIZE). * \param[in,out] q A pointer to an encoder. * \param[in] n_layers The number of layers to process (when doing rate matching not all * layers are needed). */ -void encode_ext_region_avx512long(srslte_ldpc_encoder_t* q, uint8_t n_layers); +void encode_ext_region_avx512long(srsran_ldpc_encoder_t* q, uint8_t n_layers); /*! - * Creates the inner registers required by the optimized LDPC encoder (for LS <= \ref SRSLTE_AVX512_B_SIZE). + * Creates the inner registers required by the optimized LDPC encoder (for LS <= \ref SRSRAN_AVX512_B_SIZE). * \param[in,out] q A pointer to an encoder. * \return A pointer to the newly created structure of registers. */ -void* create_ldpc_enc_avx512(srslte_ldpc_encoder_t* q); +void* create_ldpc_enc_avx512(srsran_ldpc_encoder_t* q); /*! - * Deletes the inner registers of an optimized LDPC encoder (LS <= \ref SRSLTE_AVX512_B_SIZE). + * Deletes the inner registers of an optimized LDPC encoder (LS <= \ref SRSRAN_AVX512_B_SIZE). * \param[in] p A pointer to the register structure. */ void delete_ldpc_enc_avx512(void* p); /*! - * Loads the message in the optimized encoder registers (LS <= \ref SRSLTE_AVX512_B_SIZE). + * Loads the message in the optimized encoder registers (LS <= \ref SRSRAN_AVX512_B_SIZE). * \param[in] p The register structure. * \param[in] input The message to encode. * \param[in] msg_len Number of variable nodes in one message. @@ -362,7 +362,7 @@ void delete_ldpc_enc_avx512(void* p); */ int load_avx512(void* p, const uint8_t* input, uint8_t msg_len, uint8_t cdwd_len, uint16_t ls); -/*! Extracts the final codeword from the optimized encoder registers (LS <= \ref SRSLTE_AVX512_B_SIZE). +/*! Extracts the final codeword from the optimized encoder registers (LS <= \ref SRSRAN_AVX512_B_SIZE). * \param[in] p The register structure. * \param[out] output The output codeword. * \param[in] cdwd_len The number of variable nodes (after rate-matching, if enabled). @@ -372,40 +372,40 @@ int load_avx512(void* p, const uint8_t* input, uint8_t msg_len, uint8_t cdwd_len int return_codeword_avx512(void* p, uint8_t* output, uint8_t cdwd_len, uint16_t ls); /*! Computes the product between the first (K - 2) columns of the PCM and the - * systematic bits (SIMD-optimized version, LS <= \ref SRSLTE_AVX512_B_SIZE). + * systematic bits (SIMD-optimized version, LS <= \ref SRSRAN_AVX512_B_SIZE). * \param[in,out] q A pointer to an encoder. */ -void preprocess_systematic_bits_avx512(srslte_ldpc_encoder_t* q); +void preprocess_systematic_bits_avx512(srsran_ldpc_encoder_t* q); /*! Computes the high-rate parity bits for BG1 and ls_index in {0, 1, 2, 3, 4, 5, 7} - * (SIMD-optimized version, LS <= \ref SRSLTE_AVX512_B_SIZE). + * (SIMD-optimized version, LS <= \ref SRSRAN_AVX512_B_SIZE). * \param[in,out] o A pointer to an encoder. */ void encode_high_rate_case1_avx512(void* o); /*! Computes the high-rate parity bits for BG1 and ls_index in {6} (SIMD-optimized version, LS <= \ref - * SRSLTE_AVX512_B_SIZE). + * SRSRAN_AVX512_B_SIZE). * \param[in,out] o A pointer to an encoder. */ void encode_high_rate_case2_avx512(void* o); /*! Computes the high-rate parity bits for BG2 and ls_index in {0, 1, 2, 4, 5, 6} (SIMD-optimized version, LS > \ref - * SRSLTE_AVX512_B_SIZE). + * SRSRAN_AVX512_B_SIZE). * \param[in,out] o A pointer to an encoder. */ void encode_high_rate_case3_avx512(void* o); /*! Computes the high-rate parity bits for BG2 and ls_index in {3, 7} (SIMD-optimized version, LS <= \ref - * SRSLTE_AVX512_B_SIZE). + * SRSRAN_AVX512_B_SIZE). * \param[in,out] o A pointer to an encoder. */ void encode_high_rate_case4_avx512(void* o); -/*! Computes the extended-region parity bits (SIMD-optimized version, LS <= \ref SRSLTE_AVX512_B_SIZE). +/*! Computes the extended-region parity bits (SIMD-optimized version, LS <= \ref SRSRAN_AVX512_B_SIZE). * \param[in,out] q A pointer to an encoder. * \param[in] n_layers The number of layers to process (when doing rate matching not all * layers are needed). */ -void encode_ext_region_avx512(srslte_ldpc_encoder_t* q, uint8_t n_layers); +void encode_ext_region_avx512(srsran_ldpc_encoder_t* q, uint8_t n_layers); -#endif // SRSLTE_LDPCENC_ALL_H +#endif // SRSRAN_LDPCENC_ALL_H diff --git a/lib/src/phy/fec/ldpc/ldpc_enc_avx2.c b/lib/src/phy/fec/ldpc/ldpc_enc_avx2.c index 079320bf5..805c5ef0a 100644 --- a/lib/src/phy/fec/ldpc/ldpc_enc_avx2.c +++ b/lib/src/phy/fec/ldpc/ldpc_enc_avx2.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -24,10 +24,10 @@ #include "../utils_avx2.h" #include "ldpc_enc_all.h" -#include "srslte/phy/fec/ldpc/base_graph.h" -#include "srslte/phy/fec/ldpc/ldpc_encoder.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/fec/ldpc/base_graph.h" +#include "srsran/phy/fec/ldpc/ldpc_encoder.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" #ifdef LV_HAVE_AVX2 @@ -39,7 +39,7 @@ * \brief Represents a node of the base factor graph. */ typedef union bg_node_t { - uint8_t* c; /*!< Each base node may contain up to \ref SRSLTE_AVX2_B_SIZE lifted nodes. */ + uint8_t* c; /*!< Each base node may contain up to \ref SRSRAN_AVX2_B_SIZE lifted nodes. */ __m256i* v; /*!< All the lifted nodes of the current base node as a 256-bit line. */ } bg_node_t; @@ -91,20 +91,20 @@ static __m256i rotate_node_left(__m256i a, int imm, uint16_t ls); */ static __m256i rotate_node_right(__m256i a, int imm, uint16_t ls); -void* create_ldpc_enc_avx2(srslte_ldpc_encoder_t* q) +void* create_ldpc_enc_avx2(srsran_ldpc_encoder_t* q) { struct ldpc_enc_avx2* vp = NULL; - if ((vp = SRSLTE_MEM_ALLOC(struct ldpc_enc_avx2, 1)) == NULL) { + if ((vp = SRSRAN_MEM_ALLOC(struct ldpc_enc_avx2, 1)) == NULL) { return NULL; } - if ((vp->codeword.v = SRSLTE_MEM_ALLOC(__m256i, q->bgN)) == NULL) { + if ((vp->codeword.v = SRSRAN_MEM_ALLOC(__m256i, q->bgN)) == NULL) { delete_ldpc_enc_avx2(vp); return NULL; } - if ((vp->aux = SRSLTE_MEM_ALLOC(__m256i, q->bgM)) == NULL) { + if ((vp->aux = SRSRAN_MEM_ALLOC(__m256i, q->bgM)) == NULL) { delete_ldpc_enc_avx2(vp); return NULL; } @@ -137,17 +137,17 @@ int load_avx2(void* p, const uint8_t* input, const uint8_t msg_len, const uint8_ } int ini = 0; - int node_size = SRSLTE_AVX2_B_SIZE; + int node_size = SRSRAN_AVX2_B_SIZE; for (int i = 0; i < msg_len * ls; i = i + ls) { for (int k = 0; k < ls; k++) { vp->codeword.c[ini + k] = input[i + k]; } // this zero padding can be removed - srslte_vec_u8_zero(&vp->codeword.c[ini + ls], node_size - ls); + srsran_vec_u8_zero(&vp->codeword.c[ini + ls], node_size - ls); ini = ini + node_size; } - SRSLTE_MEM_ZERO(vp->codeword.v + msg_len, __m256i, cdwd_len - msg_len); + SRSRAN_MEM_ZERO(vp->codeword.v + msg_len, __m256i, cdwd_len - msg_len); return 0; } @@ -160,17 +160,17 @@ int return_codeword_avx2(void* p, uint8_t* output, const uint8_t cdwd_len, const return -1; } - int ini = SRSLTE_AVX2_B_SIZE + SRSLTE_AVX2_B_SIZE; + int ini = SRSRAN_AVX2_B_SIZE + SRSRAN_AVX2_B_SIZE; for (int i = 0; i < (cdwd_len - 2) * ls; i = i + ls) { for (int k = 0; k < ls; k++) { output[i + k] = vp->codeword.c[ini + k]; } - ini = ini + SRSLTE_AVX2_B_SIZE; + ini = ini + SRSRAN_AVX2_B_SIZE; } return 0; } -void encode_ext_region_avx2(srslte_ldpc_encoder_t* q, uint8_t n_layers) +void encode_ext_region_avx2(srsran_ldpc_encoder_t* q, uint8_t n_layers) { struct ldpc_enc_avx2* vp = q->ptr; @@ -201,7 +201,7 @@ void encode_ext_region_avx2(srslte_ldpc_encoder_t* q, uint8_t n_layers) } } -void preprocess_systematic_bits_avx2(srslte_ldpc_encoder_t* q) +void preprocess_systematic_bits_avx2(srsran_ldpc_encoder_t* q) { struct ldpc_enc_avx2* vp = q->ptr; @@ -242,7 +242,7 @@ void preprocess_systematic_bits_avx2(srslte_ldpc_encoder_t* q) void encode_high_rate_case1_avx2(void* o) { - srslte_ldpc_encoder_t* q = o; + srsran_ldpc_encoder_t* q = o; struct ldpc_enc_avx2* vp = q->ptr; int ls = q->ls; @@ -268,7 +268,7 @@ void encode_high_rate_case1_avx2(void* o) void encode_high_rate_case2_avx2(void* o) { - srslte_ldpc_encoder_t* q = o; + srsran_ldpc_encoder_t* q = o; struct ldpc_enc_avx2* vp = q->ptr; int ls = q->ls; @@ -294,7 +294,7 @@ void encode_high_rate_case2_avx2(void* o) void encode_high_rate_case3_avx2(void* o) { - srslte_ldpc_encoder_t* q = o; + srsran_ldpc_encoder_t* q = o; struct ldpc_enc_avx2* vp = q->ptr; int ls = q->ls; @@ -320,7 +320,7 @@ void encode_high_rate_case3_avx2(void* o) void encode_high_rate_case4_avx2(void* o) { - srslte_ldpc_encoder_t* q = o; + srsran_ldpc_encoder_t* q = o; struct ldpc_enc_avx2* vp = q->ptr; int ls = q->ls; @@ -402,7 +402,7 @@ static __m256i rotate_node_left(__m256i a, int imm, uint16_t ls) return a; } __m256i step1 = _mm256_rotatelli_si256(a, imm); - if (ls == SRSLTE_AVX2_B_SIZE) { + if (ls == SRSRAN_AVX2_B_SIZE) { return step1; } @@ -423,7 +423,7 @@ static __m256i rotate_node_right(__m256i a, int imm, uint16_t ls) return a; } __m256i step1 = _mm256_rotaterli_si256(a, imm); - if (ls == SRSLTE_AVX2_B_SIZE) { + if (ls == SRSRAN_AVX2_B_SIZE) { return step1; } diff --git a/lib/src/phy/fec/ldpc/ldpc_enc_avx2long.c b/lib/src/phy/fec/ldpc/ldpc_enc_avx2long.c index 6d8aa2ab6..ab45d509a 100644 --- a/lib/src/phy/fec/ldpc/ldpc_enc_avx2long.c +++ b/lib/src/phy/fec/ldpc/ldpc_enc_avx2long.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -24,10 +24,10 @@ #include "../utils_avx2.h" #include "ldpc_enc_all.h" -#include "srslte/phy/fec/ldpc/base_graph.h" -#include "srslte/phy/fec/ldpc/ldpc_encoder.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/fec/ldpc/base_graph.h" +#include "srsran/phy/fec/ldpc/ldpc_encoder.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" #ifdef LV_HAVE_AVX2 @@ -39,7 +39,7 @@ * \brief Represents a node of the base factor graph. */ typedef union bg_node_t { - uint8_t c[SRSLTE_AVX2_B_SIZE]; /*!< Each base node may contain up to \ref SRSLTE_AVX2_B_SIZE lifted nodes. */ + uint8_t c[SRSRAN_AVX2_B_SIZE]; /*!< Each base node may contain up to \ref SRSRAN_AVX2_B_SIZE lifted nodes. */ __m256i v; /*!< All the lifted nodes of the current base node as a 256-bit line. */ } bg_node_t; @@ -48,12 +48,12 @@ typedef union bg_node_t { */ struct ldpc_enc_avx2long { bg_node_t* codeword; /*!< \brief Contains the entire codeword, before puncturing. */ - bg_node_t* codeword_to_free; /*!< \brief Auxiliary pointer with a free memory of size SRSLTE_AVX2_B_SIZE previous to + bg_node_t* codeword_to_free; /*!< \brief Auxiliary pointer with a free memory of size SRSRAN_AVX2_B_SIZE previous to codeword */ __m256i* aux; /*!< \brief Auxiliary register. */ __m256i* rotated_node; /*!< \brief To store rotated versions of the nodes. */ __m256i* rotated_node_to_free; /*!< \brief Auxiliary pointer to store rotated versions of the nodes with extra free - memory of size SRSLTE_AVX2_B_SIZE previous to rotated_node */ + memory of size SRSRAN_AVX2_B_SIZE previous to rotated_node */ uint8_t n_subnodes; /*!< \brief Number of subnodes. */ uint16_t node_size; /*!< \brief Size of a node in bytes. */ }; @@ -70,7 +70,7 @@ struct ldpc_enc_avx2long { */ static void rotate_node_right(const __m256i* in_256i, __m256i* out, uint16_t shift, uint16_t ls, int8_t n_subnodes); -void* create_ldpc_enc_avx2long(srslte_ldpc_encoder_t* q) +void* create_ldpc_enc_avx2long(srsran_ldpc_encoder_t* q) { struct ldpc_enc_avx2long* vp = NULL; @@ -78,22 +78,22 @@ void* create_ldpc_enc_avx2long(srslte_ldpc_encoder_t* q) return NULL; } - int left_out = q->ls % SRSLTE_AVX2_B_SIZE; - vp->n_subnodes = q->ls / SRSLTE_AVX2_B_SIZE + (left_out > 0); + int left_out = q->ls % SRSRAN_AVX2_B_SIZE; + vp->n_subnodes = q->ls / SRSRAN_AVX2_B_SIZE + (left_out > 0); - if ((vp->codeword_to_free = srslte_vec_malloc((q->bgN * vp->n_subnodes + 1) * sizeof(bg_node_t))) == NULL) { + if ((vp->codeword_to_free = srsran_vec_malloc((q->bgN * vp->n_subnodes + 1) * sizeof(bg_node_t))) == NULL) { free(vp); return NULL; } vp->codeword = &vp->codeword_to_free[1]; - if ((vp->aux = srslte_vec_malloc(q->bgM * vp->n_subnodes * sizeof(__m256i))) == NULL) { + if ((vp->aux = srsran_vec_malloc(q->bgM * vp->n_subnodes * sizeof(__m256i))) == NULL) { free(vp->codeword_to_free); free(vp); return NULL; } - if ((vp->rotated_node_to_free = srslte_vec_malloc((vp->n_subnodes + 2) * sizeof(__m256i))) == NULL) { + if ((vp->rotated_node_to_free = srsran_vec_malloc((vp->n_subnodes + 2) * sizeof(__m256i))) == NULL) { free(vp->aux); free(vp->codeword_to_free); free(vp); @@ -101,7 +101,7 @@ void* create_ldpc_enc_avx2long(srslte_ldpc_encoder_t* q) } vp->rotated_node = &vp->rotated_node_to_free[1]; - vp->node_size = SRSLTE_AVX2_B_SIZE * vp->n_subnodes; + vp->node_size = SRSRAN_AVX2_B_SIZE * vp->n_subnodes; return vp; } @@ -159,7 +159,7 @@ int return_codeword_avx2long(void* p, uint8_t* output, const uint8_t cdwd_len, c return 0; } -void encode_ext_region_avx2long(srslte_ldpc_encoder_t* q, uint8_t n_layers) +void encode_ext_region_avx2long(srsran_ldpc_encoder_t* q, uint8_t n_layers) { struct ldpc_enc_avx2long* vp = q->ptr; @@ -197,7 +197,7 @@ void encode_ext_region_avx2long(srslte_ldpc_encoder_t* q, uint8_t n_layers) } } -void preprocess_systematic_bits_avx2long(srslte_ldpc_encoder_t* q) +void preprocess_systematic_bits_avx2long(srsran_ldpc_encoder_t* q) { struct ldpc_enc_avx2long* vp = q->ptr; @@ -241,7 +241,7 @@ void preprocess_systematic_bits_avx2long(srslte_ldpc_encoder_t* q) void encode_high_rate_case1_avx2long(void* o) { - srslte_ldpc_encoder_t* q = o; + srsran_ldpc_encoder_t* q = o; struct ldpc_enc_avx2long* vp = q->ptr; int ls = q->ls; @@ -272,7 +272,7 @@ void encode_high_rate_case1_avx2long(void* o) void encode_high_rate_case2_avx2long(void* o) { - srslte_ldpc_encoder_t* q = o; + srsran_ldpc_encoder_t* q = o; struct ldpc_enc_avx2long* vp = q->ptr; int ls = q->ls; @@ -303,7 +303,7 @@ void encode_high_rate_case2_avx2long(void* o) void encode_high_rate_case3_avx2long(void* o) { - srslte_ldpc_encoder_t* q = o; + srsran_ldpc_encoder_t* q = o; struct ldpc_enc_avx2long* vp = q->ptr; int ls = q->ls; @@ -334,7 +334,7 @@ void encode_high_rate_case3_avx2long(void* o) void encode_high_rate_case4_avx2long(void* o) { - srslte_ldpc_encoder_t* q = o; + srsran_ldpc_encoder_t* q = o; struct ldpc_enc_avx2long* vp = q->ptr; int ls = q->ls; @@ -367,22 +367,22 @@ static void rotate_node_right(const __m256i* in_256i, __m256i* out, uint16_t shi { const int8_t* in = (const int8_t*)in_256i; - int16_t n_type1 = (ls - shift) / SRSLTE_AVX2_B_SIZE - (ls == SRSLTE_AVX2_B_SIZE); - int16_t n_type2 = n_subnodes - n_type1 - 1 - (ls == SRSLTE_AVX2_B_SIZE); - int16_t gap = (ls - shift) % SRSLTE_AVX2_B_SIZE; + int16_t n_type1 = (ls - shift) / SRSRAN_AVX2_B_SIZE - (ls == SRSRAN_AVX2_B_SIZE); + int16_t n_type2 = n_subnodes - n_type1 - 1 - (ls == SRSRAN_AVX2_B_SIZE); + int16_t gap = (ls - shift) % SRSRAN_AVX2_B_SIZE; int16_t i = 0; for (; i < n_type1; i++) { - out[i] = _mm256_loadu_si256((const __m256i*)(in + shift + i * SRSLTE_AVX2_B_SIZE)); + out[i] = _mm256_loadu_si256((const __m256i*)(in + shift + i * SRSRAN_AVX2_B_SIZE)); } - __m256i tmp1 = _mm256_loadu_si256((const __m256i*)(in + shift + i * SRSLTE_AVX2_B_SIZE)); + __m256i tmp1 = _mm256_loadu_si256((const __m256i*)(in + shift + i * SRSRAN_AVX2_B_SIZE)); __m256i tmp2 = _mm256_loadu_si256((const __m256i*)(in - gap)); out[i] = _mm256_blendv_epi8(tmp1, tmp2, mask_most_epi8[gap]); for (i = 1; i <= n_type2; i++) { - out[n_type1 + i] = _mm256_loadu_si256((const __m256i*)(in - gap + i * SRSLTE_AVX2_B_SIZE)); + out[n_type1 + i] = _mm256_loadu_si256((const __m256i*)(in - gap + i * SRSRAN_AVX2_B_SIZE)); } } diff --git a/lib/src/phy/fec/ldpc/ldpc_enc_avx512.c b/lib/src/phy/fec/ldpc/ldpc_enc_avx512.c index 88cb559e6..d059f8798 100644 --- a/lib/src/phy/fec/ldpc/ldpc_enc_avx512.c +++ b/lib/src/phy/fec/ldpc/ldpc_enc_avx512.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -24,10 +24,10 @@ #include "../utils_avx512.h" #include "ldpc_enc_all.h" -#include "srslte/phy/fec/ldpc/base_graph.h" -#include "srslte/phy/fec/ldpc/ldpc_encoder.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/fec/ldpc/base_graph.h" +#include "srsran/phy/fec/ldpc/ldpc_encoder.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" #ifdef LV_HAVE_AVX512 @@ -39,7 +39,7 @@ * \brief Represents a node of the base factor graph. */ typedef union bg_node_avx512_t { - uint8_t c[SRSLTE_AVX512_B_SIZE]; /*!< Each base node may contain up to \ref SRSLTE_AVX512_B_SIZE lifted nodes. */ + uint8_t c[SRSRAN_AVX512_B_SIZE]; /*!< Each base node may contain up to \ref SRSRAN_AVX512_B_SIZE lifted nodes. */ __m512i v; /*!< All the lifted nodes of the current base node as a 512-bit line. */ } bg_node_avx512_t; @@ -48,13 +48,13 @@ typedef union bg_node_avx512_t { */ struct ldpc_enc_avx512 { bg_node_avx512_t* codeword; /*!< \brief Contains the entire codeword, before puncturing. */ - bg_node_avx512_t* codeword_to_free; /*!< \brief Auxiliary pointer with a free memory of size SRSLTE_AVX512_B_SIZE + bg_node_avx512_t* codeword_to_free; /*!< \brief Auxiliary pointer with a free memory of size SRSRAN_AVX512_B_SIZE previous to codeword. */ __m512i* aux; /*!< \brief Auxiliary register. */ __m512i* rotated_node; /*!< \brief To store rotated versions of the nodes. */ __m512i* rotated_node_to_free; /*!< \brief Auxiliary pointer to store rotated versions of the nodes with extra free - memory of size SRSLTE_AVX512_B_SIZE previous to rotated_node */ + memory of size SRSRAN_AVX512_B_SIZE previous to rotated_node */ }; /*! @@ -67,7 +67,7 @@ struct ldpc_enc_avx512 { */ static void rotate_node_right(const uint8_t* mem_addr, __m512i* out, uint16_t this_shift2, uint16_t ls); -void* create_ldpc_enc_avx512(srslte_ldpc_encoder_t* q) +void* create_ldpc_enc_avx512(srsran_ldpc_encoder_t* q) { struct ldpc_enc_avx512* vp = NULL; @@ -75,19 +75,19 @@ void* create_ldpc_enc_avx512(srslte_ldpc_encoder_t* q) return NULL; } - if ((vp->codeword_to_free = srslte_vec_malloc((q->bgN + 1) * sizeof(bg_node_avx512_t))) == NULL) { + if ((vp->codeword_to_free = srsran_vec_malloc((q->bgN + 1) * sizeof(bg_node_avx512_t))) == NULL) { free(vp); return NULL; } vp->codeword = &vp->codeword_to_free[1]; - if ((vp->aux = srslte_vec_malloc(q->bgM * sizeof(__m512i))) == NULL) { + if ((vp->aux = srsran_vec_malloc(q->bgM * sizeof(__m512i))) == NULL) { free(vp->codeword_to_free); free(vp); return NULL; } - if ((vp->rotated_node_to_free = srslte_vec_malloc((1 + 2) * sizeof(__m512i))) == NULL) { + if ((vp->rotated_node_to_free = srsran_vec_malloc((1 + 2) * sizeof(__m512i))) == NULL) { free(vp->aux); free(vp->codeword_to_free); free(vp); @@ -125,7 +125,7 @@ int load_avx512(void* p, const uint8_t* input, const uint8_t msg_len, const uint vp->codeword[i].c[k] = input[i * ls + k]; } // This zero padding might be remove - bzero(&(vp->codeword[i].c[k]), (SRSLTE_AVX512_B_SIZE - k) * sizeof(uint8_t)); + bzero(&(vp->codeword[i].c[k]), (SRSRAN_AVX512_B_SIZE - k) * sizeof(uint8_t)); } bzero(vp->codeword + i, (cdwd_len - msg_len) * sizeof(__m512i)); @@ -150,7 +150,7 @@ int return_codeword_avx512(void* p, uint8_t* output, const uint8_t cdwd_len, con return 0; } -void encode_ext_region_avx512(srslte_ldpc_encoder_t* q, uint8_t n_layers) +void encode_ext_region_avx512(srsran_ldpc_encoder_t* q, uint8_t n_layers) { struct ldpc_enc_avx512* vp = q->ptr; @@ -181,7 +181,7 @@ void encode_ext_region_avx512(srslte_ldpc_encoder_t* q, uint8_t n_layers) } } -void preprocess_systematic_bits_avx512(srslte_ldpc_encoder_t* q) +void preprocess_systematic_bits_avx512(srsran_ldpc_encoder_t* q) { struct ldpc_enc_avx512* vp = q->ptr; int N = q->bgN; @@ -222,7 +222,7 @@ void preprocess_systematic_bits_avx512(srslte_ldpc_encoder_t* q) void encode_high_rate_case1_avx512(void* o) { - srslte_ldpc_encoder_t* q = o; + srsran_ldpc_encoder_t* q = o; struct ldpc_enc_avx512* vp = q->ptr; int ls = q->ls; @@ -250,7 +250,7 @@ void encode_high_rate_case1_avx512(void* o) void encode_high_rate_case2_avx512(void* o) { - srslte_ldpc_encoder_t* q = o; + srsran_ldpc_encoder_t* q = o; struct ldpc_enc_avx512* vp = q->ptr; int ls = q->ls; @@ -279,7 +279,7 @@ void encode_high_rate_case2_avx512(void* o) void encode_high_rate_case3_avx512(void* o) { - srslte_ldpc_encoder_t* q = o; + srsran_ldpc_encoder_t* q = o; struct ldpc_enc_avx512* vp = q->ptr; int ls = q->ls; @@ -307,7 +307,7 @@ void encode_high_rate_case3_avx512(void* o) void encode_high_rate_case4_avx512(void* o) { - srslte_ldpc_encoder_t* q = o; + srsran_ldpc_encoder_t* q = o; struct ldpc_enc_avx512* vp = q->ptr; int ls = q->ls; @@ -347,7 +347,7 @@ static void rotate_node_right(const uint8_t* mem_addr, __m512i* out, uint16_t th } else { // if the last is broken, take _shift bits from the end and "shift" bits from the begin. _shift = ls - this_shift2; - shift = SRSLTE_AVX512_B_SIZE - _shift; + shift = SRSRAN_AVX512_B_SIZE - _shift; mask1 = (1ULL << _shift) - 1; // i.e. 000001111 _shift =4 mask2 = (1ULL << shift) - 1; diff --git a/lib/src/phy/fec/ldpc/ldpc_enc_avx512long.c b/lib/src/phy/fec/ldpc/ldpc_enc_avx512long.c index 76f69ba93..9e19f5bc9 100644 --- a/lib/src/phy/fec/ldpc/ldpc_enc_avx512long.c +++ b/lib/src/phy/fec/ldpc/ldpc_enc_avx512long.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -24,10 +24,10 @@ #include "../utils_avx512.h" #include "ldpc_enc_all.h" -#include "srslte/phy/fec/ldpc/base_graph.h" -#include "srslte/phy/fec/ldpc/ldpc_encoder.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/fec/ldpc/base_graph.h" +#include "srsran/phy/fec/ldpc/ldpc_encoder.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" #ifdef LV_HAVE_AVX512 @@ -39,7 +39,7 @@ * \brief Represents a node of the base factor graph. */ typedef union bg_node_avx512_t { - uint8_t c[SRSLTE_AVX512_B_SIZE]; /*!< Each base node may contain up to \ref SRSLTE_AVX512_B_SIZE lifted nodes. */ + uint8_t c[SRSRAN_AVX512_B_SIZE]; /*!< Each base node may contain up to \ref SRSRAN_AVX512_B_SIZE lifted nodes. */ __m512i v; /*!< All the lifted nodes of the current base node as a 512-bit line. */ } bg_node_avx512_t; @@ -48,12 +48,12 @@ typedef union bg_node_avx512_t { */ struct ldpc_enc_avx512long { bg_node_avx512_t* codeword; /*!< \brief Contains the entire codeword, before puncturing. */ - bg_node_avx512_t* codeword_to_free; /*!< \brief Auxiliary pointer with a free memory of size SRSLTE_AVX512_B_SIZE + bg_node_avx512_t* codeword_to_free; /*!< \brief Auxiliary pointer with a free memory of size SRSRAN_AVX512_B_SIZE previous to codeword. */ __m512i* aux; /*!< \brief Auxiliary register. */ __m512i* rotated_node; /*!< \brief To store rotated versions of the nodes. */ __m512i* rotated_node_to_free; /*!< \brief Auxiliary pointer to store rotated versions of the nodes with extra free - memory of size SRSLTE_AVX512_B_SIZE previous to rotated_node */ + memory of size SRSRAN_AVX512_B_SIZE previous to rotated_node */ uint8_t n_subnodes; /*!< \brief Number of subnodes. */ uint16_t node_size; /*!> \brief Size of a node in bytes. */ }; @@ -68,7 +68,7 @@ struct ldpc_enc_avx512long { */ static void rotate_node_right(const uint8_t* mem_addr, __m512i* out, uint16_t this_shift2, uint16_t ls); -void* create_ldpc_enc_avx512long(srslte_ldpc_encoder_t* q) +void* create_ldpc_enc_avx512long(srsran_ldpc_encoder_t* q) { struct ldpc_enc_avx512long* vp = NULL; @@ -76,22 +76,22 @@ void* create_ldpc_enc_avx512long(srslte_ldpc_encoder_t* q) return NULL; } - int left_out = q->ls % SRSLTE_AVX512_B_SIZE; - vp->n_subnodes = q->ls / SRSLTE_AVX512_B_SIZE + (left_out > 0); + int left_out = q->ls % SRSRAN_AVX512_B_SIZE; + vp->n_subnodes = q->ls / SRSRAN_AVX512_B_SIZE + (left_out > 0); - if ((vp->codeword_to_free = srslte_vec_malloc((q->bgN * vp->n_subnodes + 1) * sizeof(bg_node_avx512_t))) == NULL) { + if ((vp->codeword_to_free = srsran_vec_malloc((q->bgN * vp->n_subnodes + 1) * sizeof(bg_node_avx512_t))) == NULL) { free(vp); return NULL; } vp->codeword = &vp->codeword_to_free[1]; - if ((vp->aux = srslte_vec_malloc(q->bgM * vp->n_subnodes * sizeof(__m512i))) == NULL) { + if ((vp->aux = srsran_vec_malloc(q->bgM * vp->n_subnodes * sizeof(__m512i))) == NULL) { free(vp->codeword_to_free); free(vp); return NULL; } - if ((vp->rotated_node_to_free = srslte_vec_malloc((vp->n_subnodes + 2) * sizeof(__m512i))) == NULL) { + if ((vp->rotated_node_to_free = srsran_vec_malloc((vp->n_subnodes + 2) * sizeof(__m512i))) == NULL) { free(vp->aux); free(vp->codeword_to_free); free(vp); @@ -99,7 +99,7 @@ void* create_ldpc_enc_avx512long(srslte_ldpc_encoder_t* q) } vp->rotated_node = &vp->rotated_node_to_free[1]; - vp->node_size = SRSLTE_AVX512_B_SIZE * vp->n_subnodes; + vp->node_size = SRSRAN_AVX512_B_SIZE * vp->n_subnodes; return vp; } @@ -157,7 +157,7 @@ int return_codeword_avx512long(void* p, uint8_t* output, const uint8_t cdwd_len, return 0; } -void encode_ext_region_avx512long(srslte_ldpc_encoder_t* q, uint8_t n_layers) +void encode_ext_region_avx512long(srsran_ldpc_encoder_t* q, uint8_t n_layers) { struct ldpc_enc_avx512long* vp = q->ptr; int m = 0; @@ -193,7 +193,7 @@ void encode_ext_region_avx512long(srslte_ldpc_encoder_t* q, uint8_t n_layers) } } -void preprocess_systematic_bits_avx512long(srslte_ldpc_encoder_t* q) +void preprocess_systematic_bits_avx512long(srsran_ldpc_encoder_t* q) { struct ldpc_enc_avx512long* vp = q->ptr; @@ -239,7 +239,7 @@ void preprocess_systematic_bits_avx512long(srslte_ldpc_encoder_t* q) void encode_high_rate_case1_avx512long(void* o) { - srslte_ldpc_encoder_t* q = o; + srsran_ldpc_encoder_t* q = o; struct ldpc_enc_avx512long* vp = q->ptr; int ls = q->ls; @@ -270,7 +270,7 @@ void encode_high_rate_case1_avx512long(void* o) void encode_high_rate_case2_avx512long(void* o) { - srslte_ldpc_encoder_t* q = o; + srsran_ldpc_encoder_t* q = o; struct ldpc_enc_avx512long* vp = q->ptr; int ls = q->ls; @@ -301,7 +301,7 @@ void encode_high_rate_case2_avx512long(void* o) void encode_high_rate_case3_avx512long(void* o) { - srslte_ldpc_encoder_t* q = o; + srsran_ldpc_encoder_t* q = o; struct ldpc_enc_avx512long* vp = q->ptr; int ls = q->ls; @@ -332,7 +332,7 @@ void encode_high_rate_case3_avx512long(void* o) void encode_high_rate_case4_avx512long(void* o) { - srslte_ldpc_encoder_t* q = o; + srsran_ldpc_encoder_t* q = o; struct ldpc_enc_avx512long* vp = q->ptr; int ls = q->ls; @@ -376,7 +376,7 @@ static void rotate_node_right(const uint8_t* mem_addr, __m512i* out, uint16_t th int jj = 0; // copy full avx512 registers from this_shift_2 - for (j = this_shift2; j <= ls - SRSLTE_AVX512_B_SIZE; j = j + SRSLTE_AVX512_B_SIZE) { + for (j = this_shift2; j <= ls - SRSRAN_AVX512_B_SIZE; j = j + SRSRAN_AVX512_B_SIZE) { out[jj] = _mm512_loadu_si512(mem_addr + j); jj = jj + 1; } @@ -384,7 +384,7 @@ static void rotate_node_right(const uint8_t* mem_addr, __m512i* out, uint16_t th // if the last is broken, take _shift bits from the end and "shift" bits from the begin. if (ls > j) { _shift = ls - j; - shift = SRSLTE_AVX512_B_SIZE - _shift; + shift = SRSRAN_AVX512_B_SIZE - _shift; mask1 = (1ULL << _shift) - 1; // i.e. 000001111 _shift =4 mask2 = (1ULL << shift) - 1; @@ -397,7 +397,7 @@ static void rotate_node_right(const uint8_t* mem_addr, __m512i* out, uint16_t th } // copy full avx512 registers from the start of mem_addr, fill with zeros after out is filled with ls - for (j = shift; j < this_shift2; j = j + SRSLTE_AVX512_B_SIZE) { + for (j = shift; j < this_shift2; j = j + SRSRAN_AVX512_B_SIZE) { out[jj] = _mm512_loadu_si512(mem_addr + j); // the exes is filled with something arbitrary jj = jj + 1; diff --git a/lib/src/phy/fec/ldpc/ldpc_enc_c.c b/lib/src/phy/fec/ldpc/ldpc_enc_c.c index 0b3c8a427..c759733ba 100644 --- a/lib/src/phy/fec/ldpc/ldpc_enc_c.c +++ b/lib/src/phy/fec/ldpc/ldpc_enc_c.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -22,11 +22,11 @@ #include -#include "srslte/phy/fec/ldpc/base_graph.h" -#include "srslte/phy/fec/ldpc/ldpc_encoder.h" -#include "srslte/phy/utils/debug.h" +#include "srsran/phy/fec/ldpc/base_graph.h" +#include "srsran/phy/fec/ldpc/ldpc_encoder.h" +#include "srsran/phy/utils/debug.h" -void encode_ext_region(srslte_ldpc_encoder_t* q, uint8_t* output, uint8_t n_layers) +void encode_ext_region(srsran_ldpc_encoder_t* q, uint8_t* output, uint8_t n_layers) { uint8_t(*aux)[q->ls] = q->ptr; @@ -59,7 +59,7 @@ void encode_ext_region(srslte_ldpc_encoder_t* q, uint8_t* output, uint8_t n_laye } } -void preprocess_systematic_bits(srslte_ldpc_encoder_t* q, const uint8_t* input) +void preprocess_systematic_bits(srsran_ldpc_encoder_t* q, const uint8_t* input) { uint8_t(*aux)[q->ls] = q->ptr; @@ -100,7 +100,7 @@ void preprocess_systematic_bits(srslte_ldpc_encoder_t* q, const uint8_t* input) void encode_high_rate_case1(void* q_, uint8_t* output) { - srslte_ldpc_encoder_t* q = (srslte_ldpc_encoder_t*)q_; + srsran_ldpc_encoder_t* q = (srsran_ldpc_encoder_t*)q_; uint8_t(*aux)[q->ls] = q->ptr; int ls = q->ls; @@ -128,7 +128,7 @@ void encode_high_rate_case1(void* q_, uint8_t* output) void encode_high_rate_case2(void* q_, uint8_t* output) { - srslte_ldpc_encoder_t* q = (srslte_ldpc_encoder_t*)q_; + srsran_ldpc_encoder_t* q = (srsran_ldpc_encoder_t*)q_; uint8_t(*aux)[q->ls] = q->ptr; int ls = q->ls; @@ -158,7 +158,7 @@ void encode_high_rate_case2(void* q_, uint8_t* output) void encode_high_rate_case3(void* q_, uint8_t* output) { - srslte_ldpc_encoder_t* q = (srslte_ldpc_encoder_t*)q_; + srsran_ldpc_encoder_t* q = (srsran_ldpc_encoder_t*)q_; uint8_t(*aux)[q->ls] = q->ptr; int ls = q->ls; @@ -188,7 +188,7 @@ void encode_high_rate_case3(void* q_, uint8_t* output) void encode_high_rate_case4(void* q_, uint8_t* output) { - srslte_ldpc_encoder_t* q = (srslte_ldpc_encoder_t*)q_; + srsran_ldpc_encoder_t* q = (srsran_ldpc_encoder_t*)q_; uint8_t(*aux)[q->ls] = q->ptr; int ls = q->ls; diff --git a/lib/src/phy/fec/ldpc/ldpc_encoder.c b/lib/src/phy/fec/ldpc/ldpc_encoder.c index b688ce784..53fe29b3e 100644 --- a/lib/src/phy/fec/ldpc/ldpc_encoder.c +++ b/lib/src/phy/fec/ldpc/ldpc_encoder.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -25,15 +25,15 @@ #include "../utils_avx2.h" #include "../utils_avx512.h" #include "ldpc_enc_all.h" -#include "srslte/phy/fec/ldpc/base_graph.h" -#include "srslte/phy/fec/ldpc/ldpc_encoder.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/fec/ldpc/base_graph.h" +#include "srsran/phy/fec/ldpc/ldpc_encoder.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" /*! Carries out the actual destruction of the memory allocated to the encoder. */ static void free_enc_c(void* o) { - srslte_ldpc_encoder_t* q = o; + srsran_ldpc_encoder_t* q = o; if (q->pcm) { free(q->pcm); } @@ -45,7 +45,7 @@ static void free_enc_c(void* o) /*! Carries out the actual encoding with a non-optimized encoder. */ static int encode_c(void* o, const uint8_t* input, uint8_t* output, uint32_t input_length, uint32_t cdwd_rm_length) { - srslte_ldpc_encoder_t* q = o; + srsran_ldpc_encoder_t* q = o; if (input_length / q->bgK != q->ls) { ERROR("Dimension mismatch."); @@ -88,7 +88,7 @@ static int encode_c(void* o, const uint8_t* input, uint8_t* output, uint32_t inp } /*! Initializes a non-optimized encoder. */ -static int init_c(srslte_ldpc_encoder_t* q) +static int init_c(srsran_ldpc_encoder_t* q) { int ls_index = get_ls_index(q->ls); @@ -112,7 +112,7 @@ static int init_c(srslte_ldpc_encoder_t* q) q->free = free_enc_c; - q->ptr = srslte_vec_u8_malloc(q->bgM * q->ls); + q->ptr = srsran_vec_u8_malloc(q->bgM * q->ls); if (!q->ptr) { perror("malloc"); free_enc_c(q); @@ -128,7 +128,7 @@ static int init_c(srslte_ldpc_encoder_t* q) /*! Carries out the actual destruction of the memory allocated to the encoder. */ static void free_enc_avx2(void* o) { - srslte_ldpc_encoder_t* q = o; + srsran_ldpc_encoder_t* q = o; if (q->pcm) { free(q->pcm); } @@ -140,7 +140,7 @@ static void free_enc_avx2(void* o) /*! Carries out the actual encoding with an optimized encoder. */ static int encode_avx2(void* o, const uint8_t* input, uint8_t* output, uint32_t input_length, uint32_t cdwd_rm_length) { - srslte_ldpc_encoder_t* q = o; + srsran_ldpc_encoder_t* q = o; if (input_length / q->bgK != q->ls) { ERROR("Dimension mismatch."); @@ -182,7 +182,7 @@ static int encode_avx2(void* o, const uint8_t* input, uint8_t* output, uint32_t } /*! Initializes an optimized encoder. */ -static int init_avx2(srslte_ldpc_encoder_t* q) +static int init_avx2(srsran_ldpc_encoder_t* q) { int ls_index = get_ls_index(q->ls); @@ -220,7 +220,7 @@ static int init_avx2(srslte_ldpc_encoder_t* q) /*! Carries out the actual destruction of the memory allocated to the encoder. */ static void free_enc_avx2long(void* o) { - srslte_ldpc_encoder_t* q = o; + srsran_ldpc_encoder_t* q = o; if (q->pcm) { free(q->pcm); } @@ -233,7 +233,7 @@ static void free_enc_avx2long(void* o) static int encode_avx2long(void* o, const uint8_t* input, uint8_t* output, uint32_t input_length, uint32_t cdwd_rm_length) { - srslte_ldpc_encoder_t* q = o; + srsran_ldpc_encoder_t* q = o; if (input_length / q->bgK != q->ls) { ERROR("Dimension mismatch."); @@ -274,7 +274,7 @@ encode_avx2long(void* o, const uint8_t* input, uint8_t* output, uint32_t input_l } /*! Initializes an optimized encoder. */ -static int init_avx2long(srslte_ldpc_encoder_t* q) +static int init_avx2long(srsran_ldpc_encoder_t* q) { int ls_index = get_ls_index(q->ls); @@ -316,7 +316,7 @@ static int init_avx2long(srslte_ldpc_encoder_t* q) /*! Carries out the actual destruction of the memory allocated to the encoder. */ static void free_enc_avx512(void* o) { - srslte_ldpc_encoder_t* q = o; + srsran_ldpc_encoder_t* q = o; if (q->pcm) { free(q->pcm); } @@ -328,7 +328,7 @@ static void free_enc_avx512(void* o) /*! Carries out the actual encoding with an optimized encoder. */ static int encode_avx512(void* o, const uint8_t* input, uint8_t* output, uint32_t input_length, uint32_t cdwd_rm_length) { - srslte_ldpc_encoder_t* q = o; + srsran_ldpc_encoder_t* q = o; if (input_length / q->bgK != q->ls) { ERROR("Dimension mismatch."); @@ -370,7 +370,7 @@ static int encode_avx512(void* o, const uint8_t* input, uint8_t* output, uint32_ } /*! Initializes an optimized encoder. */ -static int init_avx512(srslte_ldpc_encoder_t* q) +static int init_avx512(srsran_ldpc_encoder_t* q) { int ls_index = get_ls_index(q->ls); @@ -408,7 +408,7 @@ static int init_avx512(srslte_ldpc_encoder_t* q) /*! Carries out the actual destruction of the memory allocated to the encoder. */ static void free_enc_avx512long(void* o) { - srslte_ldpc_encoder_t* q = o; + srsran_ldpc_encoder_t* q = o; if (q->pcm) { free(q->pcm); } @@ -421,7 +421,7 @@ static void free_enc_avx512long(void* o) static int encode_avx512long(void* o, const uint8_t* input, uint8_t* output, uint32_t input_length, uint32_t cdwd_rm_length) { - srslte_ldpc_encoder_t* q = o; + srsran_ldpc_encoder_t* q = o; if (input_length / q->bgK != q->ls) { ERROR("Dimension mismatch."); @@ -462,7 +462,7 @@ encode_avx512long(void* o, const uint8_t* input, uint8_t* output, uint32_t input } /*! Initializes an optimized encoder. */ -static int init_avx512long(srslte_ldpc_encoder_t* q) +static int init_avx512long(srsran_ldpc_encoder_t* q) { int ls_index = get_ls_index(q->ls); @@ -499,9 +499,9 @@ static int init_avx512long(srslte_ldpc_encoder_t* q) #endif -int srslte_ldpc_encoder_init(srslte_ldpc_encoder_t* q, - srslte_ldpc_encoder_type_t type, - srslte_basegraph_t bg, +int srsran_ldpc_encoder_init(srsran_ldpc_encoder_t* q, + srsran_ldpc_encoder_type_t type, + srsran_basegraph_t bg, uint16_t ls) { switch (bg) { @@ -525,7 +525,7 @@ int srslte_ldpc_encoder_init(srslte_ldpc_encoder_t* q, q->liftM = ls * q->bgM; q->liftN = ls * q->bgN; - q->pcm = srslte_vec_u16_malloc(q->bgM * q->bgN); + q->pcm = srsran_vec_u16_malloc(q->bgM * q->bgN); if (!q->pcm) { perror("malloc"); return -1; @@ -536,19 +536,19 @@ int srslte_ldpc_encoder_init(srslte_ldpc_encoder_t* q, } switch (type) { - case SRSLTE_LDPC_ENCODER_C: + case SRSRAN_LDPC_ENCODER_C: return init_c(q); #ifdef LV_HAVE_AVX2 - case SRSLTE_LDPC_ENCODER_AVX2: - if (ls <= SRSLTE_AVX2_B_SIZE) { + case SRSRAN_LDPC_ENCODER_AVX2: + if (ls <= SRSRAN_AVX2_B_SIZE) { return init_avx2(q); } else { return init_avx2long(q); } #endif // LV_HAVE_AVX2 #ifdef LV_HAVE_AVX512 - case SRSLTE_LDPC_ENCODER_AVX512: - if (ls <= SRSLTE_AVX512_B_SIZE) { + case SRSRAN_LDPC_ENCODER_AVX512: + if (ls <= SRSRAN_AVX512_B_SIZE) { return init_avx512(q); } else { return init_avx512long(q); @@ -559,20 +559,20 @@ int srslte_ldpc_encoder_init(srslte_ldpc_encoder_t* q, } } -void srslte_ldpc_encoder_free(srslte_ldpc_encoder_t* q) +void srsran_ldpc_encoder_free(srsran_ldpc_encoder_t* q) { if (q->free) { q->free(q); } - bzero(q, sizeof(srslte_ldpc_encoder_t)); + bzero(q, sizeof(srsran_ldpc_encoder_t)); } -int srslte_ldpc_encoder_encode(srslte_ldpc_encoder_t* q, const uint8_t* input, uint8_t* output, uint32_t input_length) +int srsran_ldpc_encoder_encode(srsran_ldpc_encoder_t* q, const uint8_t* input, uint8_t* output, uint32_t input_length) { return q->encode(q, input, output, input_length, q->liftN - 2 * q->ls); } -int srslte_ldpc_encoder_encode_rm(srslte_ldpc_encoder_t* q, +int srsran_ldpc_encoder_encode_rm(srsran_ldpc_encoder_t* q, const uint8_t* input, uint8_t* output, uint32_t input_length, diff --git a/lib/src/phy/fec/ldpc/ldpc_rm.c b/lib/src/phy/fec/ldpc/ldpc_rm.c index ac862c020..5ae4d91e8 100644 --- a/lib/src/phy/fec/ldpc/ldpc_rm.c +++ b/lib/src/phy/fec/ldpc/ldpc_rm.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -25,11 +25,11 @@ #include #include -#include "srslte/phy/fec/ldpc/ldpc_common.h" //FILLER_BIT definition -#include "srslte/phy/fec/ldpc/ldpc_rm.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/fec/ldpc/ldpc_common.h" //FILLER_BIT definition +#include "srsran/phy/fec/ldpc/ldpc_rm.h" +#include "srsran/phy/utils/vector.h" -#include "srslte/phy/utils/debug.h" +#include "srsran/phy/utils/debug.h" //#define debug /*! @@ -101,13 +101,13 @@ struct pRM_rx_c { /*! * Initialize rate-matching parameters */ -static int init_rm(srslte_ldpc_rm_t* p, +static int init_rm(srsran_ldpc_rm_t* p, const uint32_t E, const uint32_t F, const uint32_t bg, const uint32_t ls, const uint8_t rv, - const srslte_mod_t mod_type, + const srsran_mod_t mod_type, const uint32_t Nref) { if (p == NULL) { @@ -115,7 +115,7 @@ static int init_rm(srslte_ldpc_rm_t* p, } uint32_t basek0 = BASEK0[rv][bg]; - uint32_t mod_order = srslte_mod_bits_x_symbol(mod_type); + uint32_t mod_order = srsran_mod_bits_x_symbol(mod_type); uint32_t N = ls * BASEN[bg]; uint32_t K = ls * BASEK[bg]; @@ -395,7 +395,7 @@ bit_interleaver_rm_rx_c(const int8_t* input, int8_t* output, const uint32_t in_o } } -int srslte_ldpc_rm_tx_init(srslte_ldpc_rm_t* p) +int srsran_ldpc_rm_tx_init(srsran_ldpc_rm_t* p) { if (p == NULL) { return -1; @@ -410,7 +410,7 @@ int srslte_ldpc_rm_tx_init(srslte_ldpc_rm_t* p) p->ptr = pp; // allocate memory to the rm_codeword after bit selection. - if ((pp->tmp_rm_codeword = srslte_vec_u8_malloc(MAXE)) == NULL) { + if ((pp->tmp_rm_codeword = srsran_vec_u8_malloc(MAXE)) == NULL) { free(pp); return -1; } @@ -418,7 +418,7 @@ int srslte_ldpc_rm_tx_init(srslte_ldpc_rm_t* p) return 0; } -int srslte_ldpc_rm_rx_init_f(srslte_ldpc_rm_t* p) +int srsran_ldpc_rm_rx_init_f(srsran_ldpc_rm_t* p) { if (p == NULL) { return -1; @@ -433,12 +433,12 @@ int srslte_ldpc_rm_rx_init_f(srslte_ldpc_rm_t* p) p->ptr = pp; // allocate memory to the temporal buffer - if ((pp->tmp_rm_symbol = srslte_vec_f_malloc(MAXE)) == NULL) { + if ((pp->tmp_rm_symbol = srsran_vec_f_malloc(MAXE)) == NULL) { free(pp); return -1; } - if ((pp->indices = srslte_vec_u32_malloc(MAXE)) == NULL) { + if ((pp->indices = srsran_vec_u32_malloc(MAXE)) == NULL) { free(pp->tmp_rm_symbol); free(pp); return -1; @@ -446,7 +446,7 @@ int srslte_ldpc_rm_rx_init_f(srslte_ldpc_rm_t* p) return 0; } -int srslte_ldpc_rm_rx_init_s(srslte_ldpc_rm_t* p) +int srsran_ldpc_rm_rx_init_s(srsran_ldpc_rm_t* p) { if (p == NULL) { return -1; @@ -461,12 +461,12 @@ int srslte_ldpc_rm_rx_init_s(srslte_ldpc_rm_t* p) p->ptr = pp; // allocate memory to the temporal buffer - if ((pp->tmp_rm_symbol = srslte_vec_i16_malloc(MAXE)) == NULL) { + if ((pp->tmp_rm_symbol = srsran_vec_i16_malloc(MAXE)) == NULL) { free(pp); return -1; } - if ((pp->indices = srslte_vec_u32_malloc(MAXE)) == NULL) { + if ((pp->indices = srsran_vec_u32_malloc(MAXE)) == NULL) { free(pp->tmp_rm_symbol); free(pp); return -1; @@ -474,7 +474,7 @@ int srslte_ldpc_rm_rx_init_s(srslte_ldpc_rm_t* p) return 0; } -int srslte_ldpc_rm_rx_init_c(srslte_ldpc_rm_t* p) +int srsran_ldpc_rm_rx_init_c(srsran_ldpc_rm_t* p) { if (p == NULL) { return -1; @@ -489,12 +489,12 @@ int srslte_ldpc_rm_rx_init_c(srslte_ldpc_rm_t* p) p->ptr = pp; // allocate memory to the temporal buffer - if ((pp->tmp_rm_symbol = srslte_vec_i8_malloc(MAXE)) == NULL) { + if ((pp->tmp_rm_symbol = srsran_vec_i8_malloc(MAXE)) == NULL) { free(pp); return -1; } - if ((pp->indices = srslte_vec_u32_malloc(MAXE)) == NULL) { + if ((pp->indices = srsran_vec_u32_malloc(MAXE)) == NULL) { free(pp->tmp_rm_symbol); free(pp); return -1; @@ -503,7 +503,7 @@ int srslte_ldpc_rm_rx_init_c(srslte_ldpc_rm_t* p) return 0; } -void srslte_ldpc_rm_tx_free(srslte_ldpc_rm_t* q) +void srsran_ldpc_rm_tx_free(srsran_ldpc_rm_t* q) { if (q != NULL) { struct pRM_tx* qq = q->ptr; @@ -516,7 +516,7 @@ void srslte_ldpc_rm_tx_free(srslte_ldpc_rm_t* q) } } -void srslte_ldpc_rm_rx_free_f(srslte_ldpc_rm_t* q) +void srsran_ldpc_rm_rx_free_f(srsran_ldpc_rm_t* q) { if (q != NULL) { struct pRM_rx_f* qq = q->ptr; @@ -532,7 +532,7 @@ void srslte_ldpc_rm_rx_free_f(srslte_ldpc_rm_t* q) } } -void srslte_ldpc_rm_rx_free_s(srslte_ldpc_rm_t* q) +void srsran_ldpc_rm_rx_free_s(srsran_ldpc_rm_t* q) { if (q != NULL) { struct pRM_rx_s* qq = q->ptr; @@ -548,7 +548,7 @@ void srslte_ldpc_rm_rx_free_s(srslte_ldpc_rm_t* q) } } -void srslte_ldpc_rm_rx_free_c(srslte_ldpc_rm_t* q) +void srsran_ldpc_rm_rx_free_c(srsran_ldpc_rm_t* q) { if (q != NULL) { struct pRM_rx_c* qq = q->ptr; @@ -564,14 +564,14 @@ void srslte_ldpc_rm_rx_free_c(srslte_ldpc_rm_t* q) } } -int srslte_ldpc_rm_tx(srslte_ldpc_rm_t* q, +int srsran_ldpc_rm_tx(srsran_ldpc_rm_t* q, const uint8_t* input, uint8_t* output, const uint32_t E, - const srslte_basegraph_t bg, + const srsran_basegraph_t bg, const uint32_t ls, const uint8_t rv, - const srslte_mod_t mod_type, + const srsran_mod_t mod_type, const uint32_t Nref) { @@ -594,15 +594,15 @@ int srslte_ldpc_rm_tx(srslte_ldpc_rm_t* q, return 0; } -int srslte_ldpc_rm_rx_f(srslte_ldpc_rm_t* q, +int srsran_ldpc_rm_rx_f(srsran_ldpc_rm_t* q, const float* input, float* output, const uint32_t E, const uint32_t F, - const srslte_basegraph_t bg, + const srsran_basegraph_t bg, const uint32_t ls, const uint8_t rv, - const srslte_mod_t mod_type, + const srsran_mod_t mod_type, const uint32_t Nref) { if (init_rm(q, E, F, bg, ls, rv, mod_type, Nref) != 0) { @@ -625,15 +625,15 @@ int srslte_ldpc_rm_rx_f(srslte_ldpc_rm_t* q, return 0; } -int srslte_ldpc_rm_rx_s(srslte_ldpc_rm_t* q, +int srsran_ldpc_rm_rx_s(srsran_ldpc_rm_t* q, const int16_t* input, int16_t* output, const uint32_t E, const uint32_t F, - const srslte_basegraph_t bg, + const srsran_basegraph_t bg, const uint32_t ls, const uint8_t rv, - const srslte_mod_t mod_type, + const srsran_mod_t mod_type, const uint32_t Nref) { if (init_rm(q, E, F, bg, ls, rv, mod_type, Nref) != 0) { @@ -657,15 +657,15 @@ int srslte_ldpc_rm_rx_s(srslte_ldpc_rm_t* q, return 0; } -int srslte_ldpc_rm_rx_c(srslte_ldpc_rm_t* q, +int srsran_ldpc_rm_rx_c(srsran_ldpc_rm_t* q, const int8_t* input, int8_t* output, const uint32_t E, const uint32_t F, - const srslte_basegraph_t bg, + const srsran_basegraph_t bg, const uint32_t ls, const uint8_t rv, - const srslte_mod_t mod_type, + const srsran_mod_t mod_type, const uint32_t Nref) { if (init_rm(q, E, F, bg, ls, rv, mod_type, Nref) != 0) { diff --git a/lib/src/phy/fec/ldpc/test/CMakeLists.txt b/lib/src/phy/fec/ldpc/test/CMakeLists.txt index 09926fc74..8a53a3c5e 100644 --- a/lib/src/phy/fec/ldpc/test/CMakeLists.txt +++ b/lib/src/phy/fec/ldpc/test/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -9,40 +9,40 @@ set(CTEST_LABELS "lib;phy;fec;ldpc") add_executable(ldpc_enc_test ldpc_enc_test.c) -target_link_libraries(ldpc_enc_test srslte_phy) +target_link_libraries(ldpc_enc_test srsran_phy) add_executable(ldpc_dec_test ldpc_dec_test.c) -target_link_libraries(ldpc_dec_test srslte_phy) +target_link_libraries(ldpc_dec_test srsran_phy) add_executable(ldpc_dec_s_test ldpc_dec_s_test.c) -target_link_libraries(ldpc_dec_s_test srslte_phy) +target_link_libraries(ldpc_dec_s_test srsran_phy) add_executable(ldpc_dec_c_test ldpc_dec_c_test.c) -target_link_libraries(ldpc_dec_c_test srslte_phy) +target_link_libraries(ldpc_dec_c_test srsran_phy) add_executable(ldpc_chain_test ldpc_chain_test.c) -target_link_libraries(ldpc_chain_test srslte_phy) +target_link_libraries(ldpc_chain_test srsran_phy) add_executable(ldpc_rm_test ldpc_rm_test.c) -target_link_libraries(ldpc_rm_test srslte_phy) +target_link_libraries(ldpc_rm_test srsran_phy) add_executable(ldpc_rm_chain_test ldpc_rm_chain_test.c) -target_link_libraries(ldpc_rm_chain_test srslte_phy) +target_link_libraries(ldpc_rm_chain_test srsran_phy) if(HAVE_AVX2) add_executable(ldpc_enc_avx2_test ldpc_enc_avx2_test.c) - target_link_libraries(ldpc_enc_avx2_test srslte_phy) + target_link_libraries(ldpc_enc_avx2_test srsran_phy) add_executable(ldpc_dec_avx2_test ldpc_dec_avx2_test.c) - target_link_libraries(ldpc_dec_avx2_test srslte_phy) + target_link_libraries(ldpc_dec_avx2_test srsran_phy) endif(HAVE_AVX2) if(HAVE_AVX512) add_executable(ldpc_enc_avx512_test ldpc_enc_avx512_test.c) - target_link_libraries(ldpc_enc_avx512_test srslte_phy) + target_link_libraries(ldpc_enc_avx512_test srsran_phy) add_executable(ldpc_dec_avx512_test ldpc_dec_avx512_test.c) - target_link_libraries(ldpc_dec_avx512_test srslte_phy) + target_link_libraries(ldpc_dec_avx512_test srsran_phy) endif(HAVE_AVX512) ### Test LDPC libs diff --git a/lib/src/phy/fec/ldpc/test/ldpc_chain_test.c b/lib/src/phy/fec/ldpc/test/ldpc_chain_test.c index 28aa9d90c..c67d75f77 100644 --- a/lib/src/phy/fec/ldpc/test/ldpc_chain_test.c +++ b/lib/src/phy/fec/ldpc/test/ldpc_chain_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -46,15 +46,15 @@ #include #include -#include "srslte/phy/channel/ch_awgn.h" -#include "srslte/phy/fec/ldpc/ldpc_common.h" -#include "srslte/phy/fec/ldpc/ldpc_decoder.h" -#include "srslte/phy/fec/ldpc/ldpc_encoder.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/random.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/channel/ch_awgn.h" +#include "srsran/phy/fec/ldpc/ldpc_common.h" +#include "srsran/phy/fec/ldpc/ldpc_decoder.h" +#include "srsran/phy/fec/ldpc/ldpc_encoder.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/random.h" +#include "srsran/phy/utils/vector.h" -static srslte_basegraph_t base_graph = BG1; /*!< \brief Base Graph (BG1 or BG2). */ +static srsran_basegraph_t base_graph = BG1; /*!< \brief Base Graph (BG1 or BG2). */ static int lift_size = 2; /*!< \brief Lifting Size. */ static int rm_length = 0; /*!< \brief Codeword length after rate matching. */ static int finalK; /*!< \brief Number of uncoded bits (message length). */ @@ -148,20 +148,20 @@ int main(int argc, char** argv) parse_args(argc, argv); // create an LDPC encoder - srslte_ldpc_encoder_t encoder; + srsran_ldpc_encoder_t encoder; #ifdef LV_HAVE_AVX512 - if (srslte_ldpc_encoder_init(&encoder, SRSLTE_LDPC_ENCODER_AVX512, base_graph, lift_size) != 0) { + if (srsran_ldpc_encoder_init(&encoder, SRSRAN_LDPC_ENCODER_AVX512, base_graph, lift_size) != 0) { perror("encoder init"); exit(-1); } #else #ifdef LV_HAVE_AVX2 - if (srslte_ldpc_encoder_init(&encoder, SRSLTE_LDPC_ENCODER_AVX2, base_graph, lift_size) != 0) { + if (srsran_ldpc_encoder_init(&encoder, SRSRAN_LDPC_ENCODER_AVX2, base_graph, lift_size) != 0) { perror("encoder init"); exit(-1); } #else // no AVX2 - if (srslte_ldpc_encoder_init(&encoder, SRSLTE_LDPC_ENCODER_C, base_graph, lift_size) != 0) { + if (srsran_ldpc_encoder_init(&encoder, SRSRAN_LDPC_ENCODER_C, base_graph, lift_size) != 0) { perror("encoder init"); exit(-1); } @@ -169,40 +169,40 @@ int main(int argc, char** argv) #endif // LV_HAVE_AVX512 // create an LDPC decoder (float) - srslte_ldpc_decoder_t decoder_f; - if (srslte_ldpc_decoder_init(&decoder_f, SRSLTE_LDPC_DECODER_F, base_graph, lift_size, MS_SF) != 0) { + srsran_ldpc_decoder_t decoder_f; + if (srsran_ldpc_decoder_init(&decoder_f, SRSRAN_LDPC_DECODER_F, base_graph, lift_size, MS_SF) != 0) { perror("decoder init"); exit(-1); } // create an LDPC decoder (16 bit) - srslte_ldpc_decoder_t decoder_s; - if (srslte_ldpc_decoder_init(&decoder_s, SRSLTE_LDPC_DECODER_S, base_graph, lift_size, MS_SF) != 0) { + srsran_ldpc_decoder_t decoder_s; + if (srsran_ldpc_decoder_init(&decoder_s, SRSRAN_LDPC_DECODER_S, base_graph, lift_size, MS_SF) != 0) { perror("decoder init"); exit(-1); } // create an LDPC decoder (8 bit) - srslte_ldpc_decoder_t decoder_c; - if (srslte_ldpc_decoder_init(&decoder_c, SRSLTE_LDPC_DECODER_C, base_graph, lift_size, MS_SF) != 0) { + srsran_ldpc_decoder_t decoder_c; + if (srsran_ldpc_decoder_init(&decoder_c, SRSRAN_LDPC_DECODER_C, base_graph, lift_size, MS_SF) != 0) { perror("decoder init"); exit(-1); } // create an LDPC decoder (8 bit, flooded) - srslte_ldpc_decoder_t decoder_c_flood; - if (srslte_ldpc_decoder_init(&decoder_c_flood, SRSLTE_LDPC_DECODER_C_FLOOD, base_graph, lift_size, MS_SF) != 0) { + srsran_ldpc_decoder_t decoder_c_flood; + if (srsran_ldpc_decoder_init(&decoder_c_flood, SRSRAN_LDPC_DECODER_C_FLOOD, base_graph, lift_size, MS_SF) != 0) { perror("decoder init"); exit(-1); } #ifdef LV_HAVE_AVX2 // create an LDPC decoder (8 bit, AVX2 version) - srslte_ldpc_decoder_t decoder_avx; - if (srslte_ldpc_decoder_init(&decoder_avx, SRSLTE_LDPC_DECODER_C_AVX2, base_graph, lift_size, MS_SF) != 0) { + srsran_ldpc_decoder_t decoder_avx; + if (srsran_ldpc_decoder_init(&decoder_avx, SRSRAN_LDPC_DECODER_C_AVX2, base_graph, lift_size, MS_SF) != 0) { perror("decoder init"); exit(-1); } // create an LDPC decoder (8 bit, flooded scheduling, AVX2 version) - srslte_ldpc_decoder_t decoder_avx_flood; - if (srslte_ldpc_decoder_init(&decoder_avx_flood, SRSLTE_LDPC_DECODER_C_AVX2_FLOOD, base_graph, lift_size, MS_SF) != + srsran_ldpc_decoder_t decoder_avx_flood; + if (srsran_ldpc_decoder_init(&decoder_avx_flood, SRSRAN_LDPC_DECODER_C_AVX2_FLOOD, base_graph, lift_size, MS_SF) != 0) { perror("decoder init"); exit(-1); @@ -211,22 +211,22 @@ int main(int argc, char** argv) #ifdef LV_HAVE_AVX512 // create an LDPC decoder (8 bit, AVX512 version) - srslte_ldpc_decoder_t decoder_avx512; - if (srslte_ldpc_decoder_init(&decoder_avx512, SRSLTE_LDPC_DECODER_C_AVX512, base_graph, lift_size, MS_SF) != 0) { + srsran_ldpc_decoder_t decoder_avx512; + if (srsran_ldpc_decoder_init(&decoder_avx512, SRSRAN_LDPC_DECODER_C_AVX512, base_graph, lift_size, MS_SF) != 0) { perror("decoder init"); exit(-1); } // create an LDPC decoder (8 bit, flooded scheduling, AVX512 version) - srslte_ldpc_decoder_t decoder_avx512_flood; - if (srslte_ldpc_decoder_init( - &decoder_avx512_flood, SRSLTE_LDPC_DECODER_C_AVX512_FLOOD, base_graph, lift_size, MS_SF) != 0) { + srsran_ldpc_decoder_t decoder_avx512_flood; + if (srsran_ldpc_decoder_init( + &decoder_avx512_flood, SRSRAN_LDPC_DECODER_C_AVX512_FLOOD, base_graph, lift_size, MS_SF) != 0) { perror("decoder init"); exit(-1); } #endif // LV_HAVE_AVX512 // create a random generator - srslte_random_t random_gen = srslte_random_init(0); + srsran_random_t random_gen = srsran_random_init(0); uint32_t F = encoder.bgK - 5; // This value is arbitrary @@ -254,20 +254,20 @@ int main(int argc, char** argv) 1.0 * (encoder.liftK - F) / rm_length); printf("\n Signal-to-Noise Ratio -> %.2f dB\n", snr); - messages_true = srslte_vec_u8_malloc(finalK * batch_size); - messages_sim_f = srslte_vec_u8_malloc(finalK * batch_size); - messages_sim_s = srslte_vec_u8_malloc(finalK * batch_size); - messages_sim_c = srslte_vec_u8_malloc(finalK * batch_size); - messages_sim_c_flood = srslte_vec_u8_malloc(finalK * batch_size); - messages_sim_avx = srslte_vec_u8_malloc(finalK * batch_size); - messages_sim_avx_flood = srslte_vec_u8_malloc(finalK * batch_size); - messages_sim_avx512 = srslte_vec_u8_malloc(finalK * batch_size); - messages_sim_avx512_flood = srslte_vec_u8_malloc(finalK * batch_size); - codewords = srslte_vec_u8_malloc(finalN * batch_size); - symbols_rm = srslte_vec_f_malloc((rm_length + F) * batch_size); - symbols = srslte_vec_f_malloc(finalN * batch_size); - symbols_s = srslte_vec_i16_malloc(finalN * batch_size); - symbols_c = srslte_vec_i8_malloc(finalN * batch_size); + messages_true = srsran_vec_u8_malloc(finalK * batch_size); + messages_sim_f = srsran_vec_u8_malloc(finalK * batch_size); + messages_sim_s = srsran_vec_u8_malloc(finalK * batch_size); + messages_sim_c = srsran_vec_u8_malloc(finalK * batch_size); + messages_sim_c_flood = srsran_vec_u8_malloc(finalK * batch_size); + messages_sim_avx = srsran_vec_u8_malloc(finalK * batch_size); + messages_sim_avx_flood = srsran_vec_u8_malloc(finalK * batch_size); + messages_sim_avx512 = srsran_vec_u8_malloc(finalK * batch_size); + messages_sim_avx512_flood = srsran_vec_u8_malloc(finalK * batch_size); + codewords = srsran_vec_u8_malloc(finalN * batch_size); + symbols_rm = srsran_vec_f_malloc((rm_length + F) * batch_size); + symbols = srsran_vec_f_malloc(finalN * batch_size); + symbols_s = srsran_vec_i16_malloc(finalN * batch_size); + symbols_c = srsran_vec_i8_malloc(finalN * batch_size); if (!messages_true || !messages_sim_f || !messages_sim_s || !messages_sim_c || // !messages_sim_avx512 || !messages_sim_avx || !messages_sim_c_flood || !messages_sim_avx512_flood || !messages_sim_avx_flood || // @@ -302,7 +302,7 @@ int main(int argc, char** argv) int n_error_words_avx512_flood = 0; #endif // lV_HAVE_AVX512 - float noise_std_dev = srslte_convert_dB_to_amplitude(-snr); + float noise_std_dev = srsran_convert_dB_to_amplitude(-snr); int16_t inf15 = (1U << 14U) - 1; float gain_s = inf15 * noise_std_dev / 20 / (1 / noise_std_dev + 2); @@ -327,7 +327,7 @@ int main(int argc, char** argv) for (i = 0; i < batch_size; i++) { for (j = 0; j < finalK - F; j++) { - messages_true[i * finalK + j] = srslte_random_uniform_int_dist(random_gen, 0, 1); + messages_true[i * finalK + j] = srsran_random_uniform_int_dist(random_gen, 0, 1); } for (; j < finalK; j++) { messages_true[i * finalK + j] = FILLER_BIT; @@ -343,7 +343,7 @@ int main(int argc, char** argv) // Encode messages gettimeofday(&t[1], NULL); for (j = 0; j < batch_size; j++) { - srslte_ldpc_encoder_encode_rm( + srsran_ldpc_encoder_encode_rm( &encoder, messages_true + j * finalK, codewords + j * finalN, finalK, n_useful_symbols); } gettimeofday(&t[2], NULL); @@ -359,7 +359,7 @@ int main(int argc, char** argv) } // Apply AWGN - srslte_ch_awgn_f(symbols_rm, symbols_rm, noise_std_dev, batch_size * (rm_length + F)); + srsran_ch_awgn_f(symbols_rm, symbols_rm, noise_std_dev, batch_size * (rm_length + F)); // Convert symbols into LLRs for (i = 0; i < batch_size; i++) { @@ -376,7 +376,7 @@ int main(int argc, char** argv) // Recover messages gettimeofday(&t[1], NULL); for (j = 0; j < batch_size; j++) { - srslte_ldpc_decoder_decode_f(&decoder_f, symbols + j * finalN, messages_sim_f + j * finalK, n_useful_symbols); + srsran_ldpc_decoder_decode_f(&decoder_f, symbols + j * finalN, messages_sim_f + j * finalK, n_useful_symbols); } gettimeofday(&t[2], NULL); get_time_interval(t); @@ -394,12 +394,12 @@ int main(int argc, char** argv) //////// Fixed point - 16 bit // Quantize LLRs with 16 bits - srslte_vec_quant_fs(symbols, symbols_s, gain_s, 0, inf15, batch_size * finalN); + srsran_vec_quant_fs(symbols, symbols_s, gain_s, 0, inf15, batch_size * finalN); // Recover messages gettimeofday(&t[1], NULL); for (j = 0; j < batch_size; j++) { - srslte_ldpc_decoder_decode_s(&decoder_s, symbols_s + j * finalN, messages_sim_s + j * finalK, n_useful_symbols); + srsran_ldpc_decoder_decode_s(&decoder_s, symbols_s + j * finalN, messages_sim_s + j * finalK, n_useful_symbols); } gettimeofday(&t[2], NULL); get_time_interval(t); @@ -417,12 +417,12 @@ int main(int argc, char** argv) //////// Fixed point - 8 bit // Quantize LLRs with 8 bits - srslte_vec_quant_fc(symbols, symbols_c, gain_c, 0, inf7, batch_size * finalN); + srsran_vec_quant_fc(symbols, symbols_c, gain_c, 0, inf7, batch_size * finalN); // Recover messages gettimeofday(&t[1], NULL); for (j = 0; j < batch_size; j++) { - srslte_ldpc_decoder_decode_rm_c( + srsran_ldpc_decoder_decode_rm_c( &decoder_c, symbols_c + j * finalN, messages_sim_c + j * finalK, n_useful_symbols); } gettimeofday(&t[2], NULL); @@ -444,7 +444,7 @@ int main(int argc, char** argv) // Recover messages gettimeofday(&t[1], NULL); for (j = 0; j < batch_size; j++) { - srslte_ldpc_decoder_decode_rm_c( + srsran_ldpc_decoder_decode_rm_c( &decoder_c_flood, symbols_c + j * finalN, messages_sim_c_flood + j * finalK, n_useful_symbols); } gettimeofday(&t[2], NULL); @@ -467,7 +467,7 @@ int main(int argc, char** argv) // Recover messages gettimeofday(&t[1], NULL); for (j = 0; j < batch_size; j++) { - srslte_ldpc_decoder_decode_rm_c( + srsran_ldpc_decoder_decode_rm_c( &decoder_avx, symbols_c + j * finalN, messages_sim_avx + j * finalK, n_useful_symbols); } gettimeofday(&t[2], NULL); @@ -489,7 +489,7 @@ int main(int argc, char** argv) // Recover messages gettimeofday(&t[1], NULL); for (j = 0; j < batch_size; j++) { - srslte_ldpc_decoder_decode_rm_c( + srsran_ldpc_decoder_decode_rm_c( &decoder_avx_flood, symbols_c + j * finalN, messages_sim_avx_flood + j * finalK, n_useful_symbols); } gettimeofday(&t[2], NULL); @@ -513,7 +513,7 @@ int main(int argc, char** argv) // Recover messages gettimeofday(&t[1], NULL); for (j = 0; j < batch_size; j++) { - srslte_ldpc_decoder_decode_rm_c( + srsran_ldpc_decoder_decode_rm_c( &decoder_avx512, symbols_c + j * finalN, messages_sim_avx512 + j * finalK, n_useful_symbols); } gettimeofday(&t[2], NULL); @@ -534,7 +534,7 @@ int main(int argc, char** argv) // Recover messages gettimeofday(&t[1], NULL); for (j = 0; j < batch_size; j++) { - srslte_ldpc_decoder_decode_rm_c( + srsran_ldpc_decoder_decode_rm_c( &decoder_avx512_flood, symbols_c + j * finalN, messages_sim_avx512_flood + j * finalK, n_useful_symbols); } gettimeofday(&t[2], NULL); @@ -613,20 +613,20 @@ int main(int argc, char** argv) free(messages_sim_s); free(messages_sim_f); free(messages_true); - srslte_random_free(random_gen); + srsran_random_free(random_gen); #ifdef LV_HAVE_AVX2 - srslte_ldpc_decoder_free(&decoder_avx); - srslte_ldpc_decoder_free(&decoder_avx_flood); + srsran_ldpc_decoder_free(&decoder_avx); + srsran_ldpc_decoder_free(&decoder_avx_flood); #endif // LV_HAVE_AVX2 #ifdef LV_HAVE_AVX512 - srslte_ldpc_decoder_free(&decoder_avx512); - srslte_ldpc_decoder_free(&decoder_avx512_flood); + srsran_ldpc_decoder_free(&decoder_avx512); + srsran_ldpc_decoder_free(&decoder_avx512_flood); #endif // LV_HAVE_AVX2 - srslte_ldpc_decoder_free(&decoder_c_flood); - srslte_ldpc_decoder_free(&decoder_c); - srslte_ldpc_decoder_free(&decoder_s); - srslte_ldpc_decoder_free(&decoder_f); - srslte_ldpc_encoder_free(&encoder); + srsran_ldpc_decoder_free(&decoder_c_flood); + srsran_ldpc_decoder_free(&decoder_c); + srsran_ldpc_decoder_free(&decoder_s); + srsran_ldpc_decoder_free(&decoder_f); + srsran_ldpc_encoder_free(&encoder); } void print_decoder(char* title, int n_batches, int n_errors, double elapsed_time) diff --git a/lib/src/phy/fec/ldpc/test/ldpc_dec_avx2_test.c b/lib/src/phy/fec/ldpc/test/ldpc_dec_avx2_test.c index 73228d8d2..95d8abd9c 100644 --- a/lib/src/phy/fec/ldpc/test/ldpc_dec_avx2_test.c +++ b/lib/src/phy/fec/ldpc/test/ldpc_dec_avx2_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -25,17 +25,17 @@ * - **-l \** Lifting Size (according to 5GNR standard. Default 2). */ -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/utils/vector.h" #include #include #include #include -#include "srslte/phy/fec/ldpc/ldpc_common.h" -#include "srslte/phy/fec/ldpc/ldpc_decoder.h" -#include "srslte/phy/utils/debug.h" +#include "srsran/phy/fec/ldpc/ldpc_common.h" +#include "srsran/phy/fec/ldpc/ldpc_decoder.h" +#include "srsran/phy/utils/debug.h" -srslte_basegraph_t base_graph = BG1; /*!< \brief Base Graph (BG1 or BG2). */ +srsran_basegraph_t base_graph = BG1; /*!< \brief Base Graph (BG1 or BG2). */ int lift_size = 2; /*!< \brief Lifting Size. */ int finalK; /*!< \brief Number of uncoded bits (message length). */ int finalN; /*!< \brief Number of coded bits (codeword length). */ @@ -150,12 +150,12 @@ int main(int argc, char** argv) parse_args(argc, argv); - srslte_ldpc_decoder_type_t dectype = - (scheduling == 0) ? SRSLTE_LDPC_DECODER_C_AVX2 : SRSLTE_LDPC_DECODER_C_AVX2_FLOOD; + srsran_ldpc_decoder_type_t dectype = + (scheduling == 0) ? SRSRAN_LDPC_DECODER_C_AVX2 : SRSRAN_LDPC_DECODER_C_AVX2_FLOOD; // create an LDPC decoder - srslte_ldpc_decoder_t decoder; - if (srslte_ldpc_decoder_init(&decoder, dectype, base_graph, lift_size, 1) != 0) { + srsran_ldpc_decoder_t decoder; + if (srsran_ldpc_decoder_init(&decoder, dectype, base_graph, lift_size, 1) != 0) { perror("decoder init"); exit(-1); } @@ -174,10 +174,10 @@ int main(int argc, char** argv) finalK = decoder.liftK; finalN = decoder.liftN - 2 * lift_size; - messages_true = srslte_vec_u8_malloc(finalK * NOF_MESSAGES); - messages_sim = srslte_vec_u8_malloc(finalK * NOF_MESSAGES); - codewords = srslte_vec_u8_malloc(finalN * NOF_MESSAGES); - symbols = srslte_vec_i8_malloc(finalN * NOF_MESSAGES); + messages_true = srsran_vec_u8_malloc(finalK * NOF_MESSAGES); + messages_sim = srsran_vec_u8_malloc(finalK * NOF_MESSAGES); + codewords = srsran_vec_u8_malloc(finalN * NOF_MESSAGES); + symbols = srsran_vec_i8_malloc(finalN * NOF_MESSAGES); if (!messages_true || !messages_sim || !codewords || !symbols) { perror("malloc"); exit(-1); @@ -207,7 +207,7 @@ int main(int argc, char** argv) printf(" codeword %d\n", j); gettimeofday(&t[1], NULL); for (l = 0; l < nof_reps; l++) { - srslte_ldpc_decoder_decode_rm_c(&decoder, symbols + j * finalN, messages_sim + j * finalK, finalN); + srsran_ldpc_decoder_decode_rm_c(&decoder, symbols + j * finalN, messages_sim + j * finalK, finalN); } gettimeofday(&t[2], NULL); @@ -235,5 +235,5 @@ int main(int argc, char** argv) free(codewords); free(messages_sim); free(messages_true); - srslte_ldpc_decoder_free(&decoder); + srsran_ldpc_decoder_free(&decoder); } diff --git a/lib/src/phy/fec/ldpc/test/ldpc_dec_avx512_test.c b/lib/src/phy/fec/ldpc/test/ldpc_dec_avx512_test.c index 2e58d0af2..658bc5b45 100644 --- a/lib/src/phy/fec/ldpc/test/ldpc_dec_avx512_test.c +++ b/lib/src/phy/fec/ldpc/test/ldpc_dec_avx512_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -30,11 +30,11 @@ #include #include -#include "srslte/phy/fec/ldpc/ldpc_common.h" -#include "srslte/phy/fec/ldpc/ldpc_decoder.h" -#include "srslte/phy/utils/debug.h" +#include "srsran/phy/fec/ldpc/ldpc_common.h" +#include "srsran/phy/fec/ldpc/ldpc_decoder.h" +#include "srsran/phy/utils/debug.h" -srslte_basegraph_t base_graph = BG1; /*!< \brief Base Graph (BG1 or BG2). */ +srsran_basegraph_t base_graph = BG1; /*!< \brief Base Graph (BG1 or BG2). */ int lift_size = 2; /*!< \brief Lifting Size. */ int finalK; /*!< \brief Number of uncoded bits (message length). */ int finalN; /*!< \brief Number of coded bits (codeword length). */ @@ -149,12 +149,12 @@ int main(int argc, char** argv) parse_args(argc, argv); - srslte_ldpc_decoder_type_t dectype = - (scheduling == 0) ? SRSLTE_LDPC_DECODER_C_AVX512 : SRSLTE_LDPC_DECODER_C_AVX512_FLOOD; + srsran_ldpc_decoder_type_t dectype = + (scheduling == 0) ? SRSRAN_LDPC_DECODER_C_AVX512 : SRSRAN_LDPC_DECODER_C_AVX512_FLOOD; // create an LDPC decoder - srslte_ldpc_decoder_t decoder; - if (srslte_ldpc_decoder_init(&decoder, dectype, base_graph, lift_size, 1) != 0) { + srsran_ldpc_decoder_t decoder; + if (srsran_ldpc_decoder_init(&decoder, dectype, base_graph, lift_size, 1) != 0) { perror("decoder init"); exit(-1); } @@ -206,7 +206,7 @@ int main(int argc, char** argv) printf(" codeword %d\n", j); gettimeofday(&t[1], NULL); for (l = 0; l < nof_reps; l++) { - srslte_ldpc_decoder_decode_rm_c(&decoder, symbols + j * finalN, messages_sim + j * finalK, finalN); + srsran_ldpc_decoder_decode_rm_c(&decoder, symbols + j * finalN, messages_sim + j * finalK, finalN); } gettimeofday(&t[2], NULL); @@ -234,5 +234,5 @@ int main(int argc, char** argv) free(codewords); free(messages_sim); free(messages_true); - srslte_ldpc_decoder_free(&decoder); + srsran_ldpc_decoder_free(&decoder); } diff --git a/lib/src/phy/fec/ldpc/test/ldpc_dec_c_test.c b/lib/src/phy/fec/ldpc/test/ldpc_dec_c_test.c index ac4ab0d34..79508e64b 100644 --- a/lib/src/phy/fec/ldpc/test/ldpc_dec_c_test.c +++ b/lib/src/phy/fec/ldpc/test/ldpc_dec_c_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -25,17 +25,17 @@ * - **-l \** Lifting Size (according to 5GNR standard. Default 2). */ -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/utils/vector.h" #include #include #include #include -#include "srslte/phy/fec/ldpc/ldpc_common.h" -#include "srslte/phy/fec/ldpc/ldpc_decoder.h" -#include "srslte/phy/utils/debug.h" +#include "srsran/phy/fec/ldpc/ldpc_common.h" +#include "srsran/phy/fec/ldpc/ldpc_decoder.h" +#include "srsran/phy/utils/debug.h" -srslte_basegraph_t base_graph = BG1; /*!< \brief Base Graph (BG1 or BG2). */ +srsran_basegraph_t base_graph = BG1; /*!< \brief Base Graph (BG1 or BG2). */ int lift_size = 2; /*!< \brief Lifting Size. */ int finalK; /*!< \brief Number of uncoded bits (message length). */ int finalN; /*!< \brief Number of coded bits (codeword length). */ @@ -144,11 +144,11 @@ int main(int argc, char** argv) parse_args(argc, argv); - srslte_ldpc_decoder_type_t dectype = (scheduling == 0) ? SRSLTE_LDPC_DECODER_C : SRSLTE_LDPC_DECODER_C_FLOOD; + srsran_ldpc_decoder_type_t dectype = (scheduling == 0) ? SRSRAN_LDPC_DECODER_C : SRSRAN_LDPC_DECODER_C_FLOOD; // create an LDPC decoder - srslte_ldpc_decoder_t decoder; - if (srslte_ldpc_decoder_init(&decoder, dectype, base_graph, lift_size, 1) != 0) { + srsran_ldpc_decoder_t decoder; + if (srsran_ldpc_decoder_init(&decoder, dectype, base_graph, lift_size, 1) != 0) { perror("decoder init"); exit(-1); } @@ -167,10 +167,10 @@ int main(int argc, char** argv) finalK = decoder.liftK; finalN = decoder.liftN - 2 * lift_size; - messages_true = srslte_vec_u8_malloc(finalK * NOF_MESSAGES); - messages_sim = srslte_vec_u8_malloc(finalK * NOF_MESSAGES); - codewords = srslte_vec_u8_malloc(finalN * NOF_MESSAGES); - symbols = srslte_vec_i8_malloc(finalN * NOF_MESSAGES); + messages_true = srsran_vec_u8_malloc(finalK * NOF_MESSAGES); + messages_sim = srsran_vec_u8_malloc(finalK * NOF_MESSAGES); + codewords = srsran_vec_u8_malloc(finalN * NOF_MESSAGES); + symbols = srsran_vec_i8_malloc(finalN * NOF_MESSAGES); if (!messages_true || !messages_sim || !codewords || !symbols) { perror("malloc"); exit(-1); @@ -197,7 +197,7 @@ int main(int argc, char** argv) gettimeofday(&t[1], NULL); for (j = 0; j < NOF_MESSAGES; j++) { printf(" codeword %d\n", j); - srslte_ldpc_decoder_decode_rm_c(&decoder, symbols + j * finalN, messages_sim + j * finalK, finalN); + srsran_ldpc_decoder_decode_rm_c(&decoder, symbols + j * finalN, messages_sim + j * finalK, finalN); } gettimeofday(&t[2], NULL); get_time_interval(t); @@ -223,5 +223,5 @@ int main(int argc, char** argv) free(codewords); free(messages_sim); free(messages_true); - srslte_ldpc_decoder_free(&decoder); + srsran_ldpc_decoder_free(&decoder); } diff --git a/lib/src/phy/fec/ldpc/test/ldpc_dec_s_test.c b/lib/src/phy/fec/ldpc/test/ldpc_dec_s_test.c index 66fe19684..01b730537 100644 --- a/lib/src/phy/fec/ldpc/test/ldpc_dec_s_test.c +++ b/lib/src/phy/fec/ldpc/test/ldpc_dec_s_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -25,17 +25,17 @@ * - **-l \** Lifting Size (according to 5GNR standard. Default 2). */ -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/utils/vector.h" #include #include #include #include -#include "srslte/phy/fec/ldpc/ldpc_common.h" -#include "srslte/phy/fec/ldpc/ldpc_decoder.h" -#include "srslte/phy/utils/debug.h" +#include "srsran/phy/fec/ldpc/ldpc_common.h" +#include "srsran/phy/fec/ldpc/ldpc_decoder.h" +#include "srsran/phy/utils/debug.h" -srslte_basegraph_t base_graph = BG1; /*!< \brief Base Graph (BG1 or BG2). */ +srsran_basegraph_t base_graph = BG1; /*!< \brief Base Graph (BG1 or BG2). */ int lift_size = 2; /*!< \brief Lifting Size. */ int finalK; /*!< \brief Number of uncoded bits (message length). */ int finalN; /*!< \brief Number of coded bits (codeword length). */ @@ -140,8 +140,8 @@ int main(int argc, char** argv) parse_args(argc, argv); // create an LDPC decoder - srslte_ldpc_decoder_t decoder; - if (srslte_ldpc_decoder_init(&decoder, SRSLTE_LDPC_DECODER_S, base_graph, lift_size, 1) != 0) { + srsran_ldpc_decoder_t decoder; + if (srsran_ldpc_decoder_init(&decoder, SRSRAN_LDPC_DECODER_S, base_graph, lift_size, 1) != 0) { perror("decoder init"); exit(-1); } @@ -159,10 +159,10 @@ int main(int argc, char** argv) finalK = decoder.liftK; finalN = decoder.liftN - 2 * lift_size; - messages_true = srslte_vec_u8_malloc(finalK * NOF_MESSAGES); - messages_sim = srslte_vec_u8_malloc(finalK * NOF_MESSAGES); - codewords = srslte_vec_u8_malloc(finalN * NOF_MESSAGES); - symbols = srslte_vec_i16_malloc(finalN * NOF_MESSAGES); + messages_true = srsran_vec_u8_malloc(finalK * NOF_MESSAGES); + messages_sim = srsran_vec_u8_malloc(finalK * NOF_MESSAGES); + codewords = srsran_vec_u8_malloc(finalN * NOF_MESSAGES); + symbols = srsran_vec_i16_malloc(finalN * NOF_MESSAGES); if (!messages_true || !messages_sim || !codewords || !symbols) { perror("malloc"); exit(-1); @@ -189,7 +189,7 @@ int main(int argc, char** argv) gettimeofday(&t[1], NULL); for (j = 0; j < NOF_MESSAGES; j++) { printf(" codeword %d\n", j); - srslte_ldpc_decoder_decode_s(&decoder, symbols + j * finalN, messages_sim + j * finalK, finalN); + srsran_ldpc_decoder_decode_s(&decoder, symbols + j * finalN, messages_sim + j * finalK, finalN); } gettimeofday(&t[2], NULL); get_time_interval(t); @@ -215,5 +215,5 @@ int main(int argc, char** argv) free(codewords); free(messages_sim); free(messages_true); - srslte_ldpc_decoder_free(&decoder); + srsran_ldpc_decoder_free(&decoder); } diff --git a/lib/src/phy/fec/ldpc/test/ldpc_dec_test.c b/lib/src/phy/fec/ldpc/test/ldpc_dec_test.c index 3935b02bb..34aa5f504 100644 --- a/lib/src/phy/fec/ldpc/test/ldpc_dec_test.c +++ b/lib/src/phy/fec/ldpc/test/ldpc_dec_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -30,12 +30,12 @@ #include #include -#include "srslte/phy/fec/ldpc/ldpc_common.h" -#include "srslte/phy/fec/ldpc/ldpc_decoder.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/fec/ldpc/ldpc_common.h" +#include "srsran/phy/fec/ldpc/ldpc_decoder.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" -srslte_basegraph_t base_graph = BG1; /*!< \brief Base Graph (BG1 or BG2). */ +srsran_basegraph_t base_graph = BG1; /*!< \brief Base Graph (BG1 or BG2). */ int lift_size = 2; /*!< \brief Lifting Size. */ int finalK; /*!< \brief Number of uncoded bits (message length). */ int finalN; /*!< \brief Number of coded bits (codeword length). */ @@ -140,8 +140,8 @@ int main(int argc, char** argv) parse_args(argc, argv); // create an LDPC decoder - srslte_ldpc_decoder_t decoder; - if (srslte_ldpc_decoder_init(&decoder, SRSLTE_LDPC_DECODER_F, base_graph, lift_size, 1) != 0) { + srsran_ldpc_decoder_t decoder; + if (srsran_ldpc_decoder_init(&decoder, SRSRAN_LDPC_DECODER_F, base_graph, lift_size, 1) != 0) { perror("decoder init"); exit(-1); } @@ -159,10 +159,10 @@ int main(int argc, char** argv) finalK = decoder.liftK; finalN = decoder.liftN - 2 * lift_size; - messages_true = srslte_vec_u8_malloc(finalK * NOF_MESSAGES); - messages_sim = srslte_vec_u8_malloc(finalK * NOF_MESSAGES); - codewords = srslte_vec_u8_malloc(finalN * NOF_MESSAGES); - symbols = srslte_vec_f_malloc(finalN * NOF_MESSAGES); + messages_true = srsran_vec_u8_malloc(finalK * NOF_MESSAGES); + messages_sim = srsran_vec_u8_malloc(finalK * NOF_MESSAGES); + codewords = srsran_vec_u8_malloc(finalN * NOF_MESSAGES); + symbols = srsran_vec_f_malloc(finalN * NOF_MESSAGES); if (!messages_true || !messages_sim || !codewords || !symbols) { perror("malloc"); exit(-1); @@ -189,7 +189,7 @@ int main(int argc, char** argv) gettimeofday(&t[1], NULL); for (j = 0; j < NOF_MESSAGES; j++) { printf(" codeword %d\n", j); - srslte_ldpc_decoder_decode_f(&decoder, symbols + j * finalN, messages_sim + j * finalK, finalN); + srsran_ldpc_decoder_decode_f(&decoder, symbols + j * finalN, messages_sim + j * finalK, finalN); } gettimeofday(&t[2], NULL); get_time_interval(t); @@ -215,5 +215,5 @@ int main(int argc, char** argv) free(codewords); free(messages_sim); free(messages_true); - srslte_ldpc_decoder_free(&decoder); + srsran_ldpc_decoder_free(&decoder); } diff --git a/lib/src/phy/fec/ldpc/test/ldpc_enc_avx2_test.c b/lib/src/phy/fec/ldpc/test/ldpc_enc_avx2_test.c index efc1cd4a2..b144fd29a 100644 --- a/lib/src/phy/fec/ldpc/test/ldpc_enc_avx2_test.c +++ b/lib/src/phy/fec/ldpc/test/ldpc_enc_avx2_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -26,17 +26,17 @@ * - **-R \** Number of times tests are repeated (for computing throughput). */ -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/utils/vector.h" #include #include #include #include -#include "srslte/phy/fec/ldpc/ldpc_common.h" -#include "srslte/phy/fec/ldpc/ldpc_encoder.h" -#include "srslte/phy/utils/debug.h" +#include "srsran/phy/fec/ldpc/ldpc_common.h" +#include "srsran/phy/fec/ldpc/ldpc_encoder.h" +#include "srsran/phy/utils/debug.h" -srslte_basegraph_t base_graph = BG1; /*!< \brief Base Graph (BG1 or BG2). */ +srsran_basegraph_t base_graph = BG1; /*!< \brief Base Graph (BG1 or BG2). */ int lift_size = 2; /*!< \brief Lifting Size. */ int finalK; /*!< \brief Number of uncoded bits (message length). */ int finalN; /*!< \brief Number of coded bits (codeword length). */ @@ -147,8 +147,8 @@ int main(int argc, char** argv) parse_args(argc, argv); // create an LDPC encoder - srslte_ldpc_encoder_t encoder; - if (srslte_ldpc_encoder_init(&encoder, SRSLTE_LDPC_ENCODER_AVX2, base_graph, lift_size) != 0) { + srsran_ldpc_encoder_t encoder; + if (srsran_ldpc_encoder_init(&encoder, SRSRAN_LDPC_ENCODER_AVX2, base_graph, lift_size) != 0) { perror("encoder init"); exit(-1); } @@ -166,9 +166,9 @@ int main(int argc, char** argv) finalK = encoder.liftK; finalN = encoder.liftN - 2 * lift_size; - messages = srslte_vec_u8_malloc(finalK * NOF_MESSAGES); - codewords_true = srslte_vec_u8_malloc(finalN * NOF_MESSAGES); - codewords_sim = srslte_vec_u8_malloc(finalN * NOF_MESSAGES); + messages = srsran_vec_u8_malloc(finalK * NOF_MESSAGES); + codewords_true = srsran_vec_u8_malloc(finalN * NOF_MESSAGES); + codewords_sim = srsran_vec_u8_malloc(finalN * NOF_MESSAGES); if (!messages || !codewords_true || !codewords_sim) { perror("malloc"); exit(-1); @@ -193,7 +193,7 @@ int main(int argc, char** argv) printf(" codeword %d\n", j); gettimeofday(&t[1], NULL); for (l = 0; l < nof_reps; l++) { - srslte_ldpc_encoder_encode_rm(&encoder, messages + j * finalK, codewords_sim + j * finalN, finalK, finalN); + srsran_ldpc_encoder_encode_rm(&encoder, messages + j * finalK, codewords_sim + j * finalN, finalK, finalN); } gettimeofday(&t[2], NULL); get_time_interval(t); @@ -219,5 +219,5 @@ int main(int argc, char** argv) free(codewords_sim); free(codewords_true); free(messages); - srslte_ldpc_encoder_free(&encoder); + srsran_ldpc_encoder_free(&encoder); } diff --git a/lib/src/phy/fec/ldpc/test/ldpc_enc_avx512_test.c b/lib/src/phy/fec/ldpc/test/ldpc_enc_avx512_test.c index 0859af576..a54fc8054 100644 --- a/lib/src/phy/fec/ldpc/test/ldpc_enc_avx512_test.c +++ b/lib/src/phy/fec/ldpc/test/ldpc_enc_avx512_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -31,11 +31,11 @@ #include #include -#include "srslte/phy/fec/ldpc/ldpc_common.h" -#include "srslte/phy/fec/ldpc/ldpc_encoder.h" -#include "srslte/phy/utils/debug.h" +#include "srsran/phy/fec/ldpc/ldpc_common.h" +#include "srsran/phy/fec/ldpc/ldpc_encoder.h" +#include "srsran/phy/utils/debug.h" -srslte_basegraph_t base_graph = BG1; /*!< \brief Base Graph (BG1 or BG2). */ +srsran_basegraph_t base_graph = BG1; /*!< \brief Base Graph (BG1 or BG2). */ int lift_size = 2; /*!< \brief Lifting Size. */ int finalK; /*!< \brief Number of uncoded bits (message length). */ int finalN; /*!< \brief Number of coded bits (codeword length). */ @@ -146,8 +146,8 @@ int main(int argc, char** argv) parse_args(argc, argv); // create an LDPC encoder - srslte_ldpc_encoder_t encoder; - if (srslte_ldpc_encoder_init(&encoder, SRSLTE_LDPC_ENCODER_AVX512, base_graph, lift_size) != 0) { + srsran_ldpc_encoder_t encoder; + if (srsran_ldpc_encoder_init(&encoder, SRSRAN_LDPC_ENCODER_AVX512, base_graph, lift_size) != 0) { perror("encoder init"); exit(-1); } @@ -192,7 +192,7 @@ int main(int argc, char** argv) printf(" codeword %d\n", j); gettimeofday(&t[1], NULL); for (l = 0; l < nof_reps; l++) { - srslte_ldpc_encoder_encode_rm(&encoder, messages + j * finalK, codewords_sim + j * finalN, finalK, finalN); + srsran_ldpc_encoder_encode_rm(&encoder, messages + j * finalK, codewords_sim + j * finalN, finalK, finalN); } gettimeofday(&t[2], NULL); get_time_interval(t); @@ -217,5 +217,5 @@ int main(int argc, char** argv) free(codewords_sim); free(codewords_true); free(messages); - srslte_ldpc_encoder_free(&encoder); + srsran_ldpc_encoder_free(&encoder); } diff --git a/lib/src/phy/fec/ldpc/test/ldpc_enc_test.c b/lib/src/phy/fec/ldpc/test/ldpc_enc_test.c index e59540d36..a43885575 100644 --- a/lib/src/phy/fec/ldpc/test/ldpc_enc_test.c +++ b/lib/src/phy/fec/ldpc/test/ldpc_enc_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -31,12 +31,12 @@ #include #include -#include "srslte/phy/fec/ldpc/ldpc_common.h" -#include "srslte/phy/fec/ldpc/ldpc_encoder.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/fec/ldpc/ldpc_common.h" +#include "srsran/phy/fec/ldpc/ldpc_encoder.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" -static srslte_basegraph_t base_graph = BG1; /*!< \brief Base Graph (BG1 or BG2). */ +static srsran_basegraph_t base_graph = BG1; /*!< \brief Base Graph (BG1 or BG2). */ static int lift_size = 2; /*!< \brief Lifting Size. */ static int finalK; /*!< \brief Number of uncoded bits (message length). */ static int finalN; /*!< \brief Number of coded bits (codeword length). */ @@ -147,8 +147,8 @@ int main(int argc, char** argv) parse_args(argc, argv); // create an LDPC encoder - srslte_ldpc_encoder_t encoder; - if (srslte_ldpc_encoder_init(&encoder, SRSLTE_LDPC_ENCODER_C, base_graph, lift_size) != 0) { + srsran_ldpc_encoder_t encoder; + if (srsran_ldpc_encoder_init(&encoder, SRSRAN_LDPC_ENCODER_C, base_graph, lift_size) != 0) { perror("encoder init"); exit(-1); } @@ -166,9 +166,9 @@ int main(int argc, char** argv) finalK = encoder.liftK; finalN = encoder.liftN - 2 * lift_size; - messages = srslte_vec_u8_malloc(finalK * NOF_MESSAGES); - codewords_true = srslte_vec_u8_malloc(finalN * NOF_MESSAGES); - codewords_sim = srslte_vec_u8_malloc(finalN * NOF_MESSAGES); + messages = srsran_vec_u8_malloc(finalK * NOF_MESSAGES); + codewords_true = srsran_vec_u8_malloc(finalN * NOF_MESSAGES); + codewords_sim = srsran_vec_u8_malloc(finalN * NOF_MESSAGES); if (!messages || !codewords_true || !codewords_sim) { perror("malloc"); exit(-1); @@ -193,7 +193,7 @@ int main(int argc, char** argv) printf(" codeword %d\n", j); gettimeofday(&t[1], NULL); for (l = 0; l < nof_reps; l++) { - srslte_ldpc_encoder_encode_rm(&encoder, messages + j * finalK, codewords_sim + j * finalN, finalK, finalN); + srsran_ldpc_encoder_encode_rm(&encoder, messages + j * finalK, codewords_sim + j * finalN, finalK, finalN); } gettimeofday(&t[2], NULL); get_time_interval(t); @@ -219,5 +219,5 @@ int main(int argc, char** argv) free(codewords_sim); free(codewords_true); free(messages); - srslte_ldpc_encoder_free(&encoder); + srsran_ldpc_encoder_free(&encoder); } diff --git a/lib/src/phy/fec/ldpc/test/ldpc_rm_chain_test.c b/lib/src/phy/fec/ldpc/test/ldpc_rm_chain_test.c index d96d4f689..c022902c7 100644 --- a/lib/src/phy/fec/ldpc/test/ldpc_rm_chain_test.c +++ b/lib/src/phy/fec/ldpc/test/ldpc_rm_chain_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -43,21 +43,21 @@ #include #include -#include "srslte/phy/channel/ch_awgn.h" -#include "srslte/phy/fec/ldpc/ldpc_common.h" -#include "srslte/phy/fec/ldpc/ldpc_decoder.h" -#include "srslte/phy/fec/ldpc/ldpc_encoder.h" -#include "srslte/phy/fec/ldpc/ldpc_rm.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/random.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/channel/ch_awgn.h" +#include "srsran/phy/fec/ldpc/ldpc_common.h" +#include "srsran/phy/fec/ldpc/ldpc_decoder.h" +#include "srsran/phy/fec/ldpc/ldpc_encoder.h" +#include "srsran/phy/fec/ldpc/ldpc_rm.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/random.h" +#include "srsran/phy/utils/vector.h" -static srslte_basegraph_t base_graph = BG1; /*!< \brief Base Graph (BG1 or BG2). */ +static srsran_basegraph_t base_graph = BG1; /*!< \brief Base Graph (BG1 or BG2). */ static uint32_t lift_size = 2; /*!< \brief Lifting Size. */ static uint32_t rm_length = 0; /*!< \brief Codeword length after rate matching. */ static uint32_t F = 0; /*!< \brief Number of filler bits in each CBS. */ static uint8_t rv = 0; /*!< \brief Redundancy version {0-3}. */ -static srslte_mod_t mod_type = SRSLTE_MOD_BPSK; /*!< \brief Modulation type: BPSK, QPSK, QAM16, QAM64, QAM256 = 4 */ +static srsran_mod_t mod_type = SRSRAN_MOD_BPSK; /*!< \brief Modulation type: BPSK, QPSK, QAM16, QAM64, QAM256 = 4 */ static uint32_t Nref = 0; /*!< \brief Limited buffer size. */ static float snr = 0; /*!< \brief Signal-to-Noise Ratio [dB]. */ static uint8_t rm_aware = 1; /*!< \brief Flag rate matching aware encoding/decoding (1 to enable). */ @@ -114,7 +114,7 @@ void parse_args(int argc, char** argv) rv = (uint8_t)strtol(optarg, NULL, 10); break; case 'm': - mod_type = (srslte_mod_t)strtol(optarg, NULL, 10); + mod_type = (srsran_mod_t)strtol(optarg, NULL, 10); break; case 'M': Nref = (uint32_t)strtol(optarg, NULL, 10); @@ -175,21 +175,21 @@ int main(int argc, char** argv) parse_args(argc, argv); // create an LDPC encoder - srslte_ldpc_encoder_t encoder; + srsran_ldpc_encoder_t encoder; #ifdef LV_HAVE_AVX512 - if (srslte_ldpc_encoder_init(&encoder, SRSLTE_LDPC_ENCODER_AVX512, base_graph, lift_size) != 0) { + if (srsran_ldpc_encoder_init(&encoder, SRSRAN_LDPC_ENCODER_AVX512, base_graph, lift_size) != 0) { perror("encoder init"); exit(-1); } #else // no AVX512 #ifdef LV_HAVE_AVX2 - if (srslte_ldpc_encoder_init(&encoder, SRSLTE_LDPC_ENCODER_AVX2, base_graph, lift_size) != 0) { + if (srsran_ldpc_encoder_init(&encoder, SRSRAN_LDPC_ENCODER_AVX2, base_graph, lift_size) != 0) { perror("encoder init"); exit(-1); } #else // no AVX2 - if (srslte_ldpc_encoder_init(&encoder, SRSLTE_LDPC_ENCODER_C, base_graph, lift_size) != 0) { + if (srsran_ldpc_encoder_init(&encoder, SRSRAN_LDPC_ENCODER_C, base_graph, lift_size) != 0) { perror("encoder init"); exit(-1); } @@ -207,68 +207,68 @@ int main(int argc, char** argv) } // create a LDPC rate Matcher - srslte_ldpc_rm_t rm_tx; - if (srslte_ldpc_rm_tx_init(&rm_tx) != 0) { + srsran_ldpc_rm_t rm_tx; + if (srsran_ldpc_rm_tx_init(&rm_tx) != 0) { perror("rate matcher init"); exit(-1); } // create a LDPC rate DeMatcher - srslte_ldpc_rm_t rm_rx; - if (srslte_ldpc_rm_rx_init_f(&rm_rx) != 0) { + srsran_ldpc_rm_t rm_rx; + if (srsran_ldpc_rm_rx_init_f(&rm_rx) != 0) { perror("rate dematcher init"); exit(-1); } // create a LDPC rate DeMatcher (int16_t) - srslte_ldpc_rm_t rm_rx_s; - if (srslte_ldpc_rm_rx_init_s(&rm_rx_s) != 0) { + srsran_ldpc_rm_t rm_rx_s; + if (srsran_ldpc_rm_rx_init_s(&rm_rx_s) != 0) { perror("rate dematcher init (int16_t)"); exit(-1); } // create a LDPC rate DeMatcher (int8_t) - srslte_ldpc_rm_t rm_rx_c; - if (srslte_ldpc_rm_rx_init_c(&rm_rx_c) != 0) { + srsran_ldpc_rm_t rm_rx_c; + if (srsran_ldpc_rm_rx_init_c(&rm_rx_c) != 0) { perror("rate dematcher init (int8_t)"); exit(-1); } // create an LDPC decoder (float) - srslte_ldpc_decoder_t decoder_f; - if (srslte_ldpc_decoder_init(&decoder_f, SRSLTE_LDPC_DECODER_F, base_graph, lift_size, MS_SF) != 0) { + srsran_ldpc_decoder_t decoder_f; + if (srsran_ldpc_decoder_init(&decoder_f, SRSRAN_LDPC_DECODER_F, base_graph, lift_size, MS_SF) != 0) { perror("decoder init"); exit(-1); } // create an LDPC decoder (16 bit) - srslte_ldpc_decoder_t decoder_s; - if (srslte_ldpc_decoder_init(&decoder_s, SRSLTE_LDPC_DECODER_S, base_graph, lift_size, MS_SF) != 0) { + srsran_ldpc_decoder_t decoder_s; + if (srsran_ldpc_decoder_init(&decoder_s, SRSRAN_LDPC_DECODER_S, base_graph, lift_size, MS_SF) != 0) { perror("decoder init (int16_t)"); exit(-1); } // create an LDPC decoder (8 bit) - srslte_ldpc_decoder_t decoder_c; - if (srslte_ldpc_decoder_init(&decoder_c, SRSLTE_LDPC_DECODER_C, base_graph, lift_size, MS_SF) != 0) { + srsran_ldpc_decoder_t decoder_c; + if (srsran_ldpc_decoder_init(&decoder_c, SRSRAN_LDPC_DECODER_C, base_graph, lift_size, MS_SF) != 0) { perror("decoder init (int8_t)"); exit(-1); } // create an LDPC decoder (8 bit, flooded) - srslte_ldpc_decoder_t decoder_c_flood; - if (srslte_ldpc_decoder_init(&decoder_c_flood, SRSLTE_LDPC_DECODER_C_FLOOD, base_graph, lift_size, MS_SF) != 0) { + srsran_ldpc_decoder_t decoder_c_flood; + if (srsran_ldpc_decoder_init(&decoder_c_flood, SRSRAN_LDPC_DECODER_C_FLOOD, base_graph, lift_size, MS_SF) != 0) { perror("decoder init"); exit(-1); } #ifdef LV_HAVE_AVX2 // create an LDPC decoder (8 bit, AVX2 version) - srslte_ldpc_decoder_t decoder_avx; - if (srslte_ldpc_decoder_init(&decoder_avx, SRSLTE_LDPC_DECODER_C_AVX2, base_graph, lift_size, MS_SF) != 0) { + srsran_ldpc_decoder_t decoder_avx; + if (srsran_ldpc_decoder_init(&decoder_avx, SRSRAN_LDPC_DECODER_C_AVX2, base_graph, lift_size, MS_SF) != 0) { perror("decoder init"); exit(-1); } // create an LDPC decoder (8 bit, flooded scheduling, AVX2 version) - srslte_ldpc_decoder_t decoder_avx_flood; - if (srslte_ldpc_decoder_init(&decoder_avx_flood, SRSLTE_LDPC_DECODER_C_AVX2_FLOOD, base_graph, lift_size, MS_SF) != + srsran_ldpc_decoder_t decoder_avx_flood; + if (srsran_ldpc_decoder_init(&decoder_avx_flood, SRSRAN_LDPC_DECODER_C_AVX2_FLOOD, base_graph, lift_size, MS_SF) != 0) { perror("decoder init"); exit(-1); @@ -277,23 +277,23 @@ int main(int argc, char** argv) #ifdef LV_HAVE_AVX512 // create an LDPC decoder (8 bit, AVX2 version) - srslte_ldpc_decoder_t decoder_avx512; - if (srslte_ldpc_decoder_init(&decoder_avx512, SRSLTE_LDPC_DECODER_C_AVX512, base_graph, lift_size, MS_SF) != 0) { + srsran_ldpc_decoder_t decoder_avx512; + if (srsran_ldpc_decoder_init(&decoder_avx512, SRSRAN_LDPC_DECODER_C_AVX512, base_graph, lift_size, MS_SF) != 0) { perror("decoder init"); exit(-1); } // create an LDPC decoder (8 bit, flooded scheduling, AVX512 version) - srslte_ldpc_decoder_t decoder_avx512_flood; - if (srslte_ldpc_decoder_init( - &decoder_avx512_flood, SRSLTE_LDPC_DECODER_C_AVX512_FLOOD, base_graph, lift_size, MS_SF) != 0) { + srsran_ldpc_decoder_t decoder_avx512_flood; + if (srsran_ldpc_decoder_init( + &decoder_avx512_flood, SRSRAN_LDPC_DECODER_C_AVX512_FLOOD, base_graph, lift_size, MS_SF) != 0) { perror("decoder init"); exit(-1); } #endif // LV_HAVE_AVX512 // create a random generator - srslte_random_t random_gen = srslte_random_init(0); + srsran_random_t random_gen = srsran_random_init(0); printf("Test LDPC chain:\n"); printf(" Base Graph -> BG%d\n", encoder.bg + 1); @@ -317,24 +317,24 @@ int main(int argc, char** argv) 1.0 * (encoder.liftK - F) / rm_length); printf("\n Signal-to-Noise Ratio -> %.2f dB\n", snr); - messages_true = srslte_vec_u8_malloc(finalK * batch_size); - messages_sim_f = srslte_vec_u8_malloc(finalK * batch_size); - messages_sim_s = srslte_vec_u8_malloc(finalK * batch_size); - messages_sim_c = srslte_vec_u8_malloc(finalK * batch_size); - messages_sim_c_flood = srslte_vec_u8_malloc(finalK * batch_size); - messages_sim_avx = srslte_vec_u8_malloc(finalK * batch_size); - messages_sim_avx_flood = srslte_vec_u8_malloc(finalK * batch_size); - messages_sim_avx512 = srslte_vec_u8_malloc(finalK * batch_size); - messages_sim_avx512_flood = srslte_vec_u8_malloc(finalK * batch_size); - codewords = srslte_vec_u8_malloc(finalN * batch_size); - rm_codewords = srslte_vec_u8_malloc(rm_length * batch_size); - rm_symbols = srslte_vec_f_malloc(rm_length * batch_size); - rm_symbols_s = srslte_vec_i16_malloc(rm_length * batch_size); - rm_symbols_c = srslte_vec_i8_malloc(rm_length * batch_size); - - symbols = srslte_vec_f_malloc(finalN * batch_size); - symbols_s = srslte_vec_i16_malloc(finalN * batch_size); - symbols_c = srslte_vec_i8_malloc(finalN * batch_size); + messages_true = srsran_vec_u8_malloc(finalK * batch_size); + messages_sim_f = srsran_vec_u8_malloc(finalK * batch_size); + messages_sim_s = srsran_vec_u8_malloc(finalK * batch_size); + messages_sim_c = srsran_vec_u8_malloc(finalK * batch_size); + messages_sim_c_flood = srsran_vec_u8_malloc(finalK * batch_size); + messages_sim_avx = srsran_vec_u8_malloc(finalK * batch_size); + messages_sim_avx_flood = srsran_vec_u8_malloc(finalK * batch_size); + messages_sim_avx512 = srsran_vec_u8_malloc(finalK * batch_size); + messages_sim_avx512_flood = srsran_vec_u8_malloc(finalK * batch_size); + codewords = srsran_vec_u8_malloc(finalN * batch_size); + rm_codewords = srsran_vec_u8_malloc(rm_length * batch_size); + rm_symbols = srsran_vec_f_malloc(rm_length * batch_size); + rm_symbols_s = srsran_vec_i16_malloc(rm_length * batch_size); + rm_symbols_c = srsran_vec_i8_malloc(rm_length * batch_size); + + symbols = srsran_vec_f_malloc(finalN * batch_size); + symbols_s = srsran_vec_i16_malloc(finalN * batch_size); + symbols_c = srsran_vec_i8_malloc(finalN * batch_size); if (!messages_true || !messages_sim_f || !messages_sim_s || !messages_sim_c || // !messages_sim_avx || !messages_sim_avx || !messages_sim_c_flood || !messages_sim_avx_flood || // !messages_sim_avx512_flood || !codewords || !rm_codewords || !rm_symbols || !rm_symbols_s || !rm_symbols_c || @@ -370,7 +370,7 @@ int main(int argc, char** argv) int n_error_words_avx512_flood = 0; #endif // LV_HAVE_AVX512 - float noise_std_dev = srslte_convert_dB_to_amplitude(-snr); + float noise_std_dev = srsran_convert_dB_to_amplitude(-snr); int16_t inf15 = (1U << 14U) - 1; float gain_s = inf15 * noise_std_dev / 20 / (1 / noise_std_dev + 2); @@ -403,7 +403,7 @@ int main(int argc, char** argv) /* generate data_tx */ for (i = 0; i < batch_size; i++) { for (j = 0; j < finalK - F; j++) { - messages_true[i * finalK + j] = srslte_random_uniform_int_dist(random_gen, 0, 1); + messages_true[i * finalK + j] = srsran_random_uniform_int_dist(random_gen, 0, 1); } for (; j < finalK; j++) { messages_true[i * finalK + j] = FILLER_BIT; @@ -412,7 +412,7 @@ int main(int argc, char** argv) gettimeofday(&t[1], NULL); for (j = 0; j < batch_size; j++) { - srslte_ldpc_encoder_encode_rm( + srsran_ldpc_encoder_encode_rm( &encoder, messages_true + j * finalK, codewords + j * finalN, finalK, n_useful_symbols_enc); } gettimeofday(&t[2], NULL); @@ -421,7 +421,7 @@ int main(int argc, char** argv) // rate matching for (j = 0; j < batch_size; j++) { - srslte_ldpc_rm_tx(&rm_tx, + srsran_ldpc_rm_tx(&rm_tx, codewords + j * finalN, rm_codewords + j * rm_length, rm_length, @@ -439,7 +439,7 @@ int main(int argc, char** argv) } // Apply AWGN - srslte_ch_awgn_f(rm_symbols, rm_symbols, noise_std_dev, batch_size * rm_length); + srsran_ch_awgn_f(rm_symbols, rm_symbols, noise_std_dev, batch_size * rm_length); // Convert symbols into LLRs for (i = 0; i < batch_size; i++) { @@ -457,7 +457,7 @@ int main(int argc, char** argv) } for (i = 0; i < batch_size; i++) { - if (srslte_ldpc_rm_rx_f(&rm_rx, + if (srsran_ldpc_rm_rx_f(&rm_rx, rm_symbols + i * rm_length, symbols + i * finalN, rm_length, @@ -475,7 +475,7 @@ int main(int argc, char** argv) // Recover messages gettimeofday(&t[1], NULL); for (j = 0; j < batch_size; j++) { - srslte_ldpc_decoder_decode_f(&decoder_f, symbols + j * finalN, messages_sim_f + j * finalK, n_useful_symbols_dec); + srsran_ldpc_decoder_decode_f(&decoder_f, symbols + j * finalN, messages_sim_f + j * finalK, n_useful_symbols_dec); } gettimeofday(&t[2], NULL); get_time_interval(t); @@ -493,11 +493,11 @@ int main(int argc, char** argv) //////// Fixed point - 16 bit // Quantize LLRs with 16 bits - srslte_vec_quant_fs(rm_symbols, rm_symbols_s, gain_s, 0, inf15, batch_size * rm_length); + srsran_vec_quant_fs(rm_symbols, rm_symbols_s, gain_s, 0, inf15, batch_size * rm_length); // Rate dematcher for (i = 0; i < batch_size; i++) { - if (srslte_ldpc_rm_rx_s(&rm_rx_s, + if (srsran_ldpc_rm_rx_s(&rm_rx_s, rm_symbols_s + i * rm_length, symbols_s + i * finalN, rm_length, @@ -514,7 +514,7 @@ int main(int argc, char** argv) // Recover messages gettimeofday(&t[1], NULL); for (j = 0; j < batch_size; j++) { - srslte_ldpc_decoder_decode_s( + srsran_ldpc_decoder_decode_s( &decoder_s, symbols_s + j * finalN, messages_sim_s + j * finalK, n_useful_symbols_dec); } gettimeofday(&t[2], NULL); @@ -533,11 +533,11 @@ int main(int argc, char** argv) //////// Fixed point - 8 bit // Quantize LLRs with 8 bits - srslte_vec_quant_fc(rm_symbols, rm_symbols_c, gain_c, 0, inf7, batch_size * rm_length); + srsran_vec_quant_fc(rm_symbols, rm_symbols_c, gain_c, 0, inf7, batch_size * rm_length); // Rate dematcher for (i = 0; i < batch_size; i++) { - if (srslte_ldpc_rm_rx_c(&rm_rx_c, + if (srsran_ldpc_rm_rx_c(&rm_rx_c, rm_symbols_c + i * rm_length, symbols_c + i * finalN, rm_length, @@ -554,7 +554,7 @@ int main(int argc, char** argv) // Recover messages gettimeofday(&t[1], NULL); for (j = 0; j < batch_size; j++) { - srslte_ldpc_decoder_decode_rm_c( + srsran_ldpc_decoder_decode_rm_c( &decoder_c, symbols_c + j * finalN, messages_sim_c + j * finalK, n_useful_symbols_dec); } gettimeofday(&t[2], NULL); @@ -576,7 +576,7 @@ int main(int argc, char** argv) // Recover messages gettimeofday(&t[1], NULL); for (j = 0; j < batch_size; j++) { - srslte_ldpc_decoder_decode_rm_c( + srsran_ldpc_decoder_decode_rm_c( &decoder_c_flood, symbols_c + j * finalN, messages_sim_c_flood + j * finalK, n_useful_symbols_dec); } gettimeofday(&t[2], NULL); @@ -599,7 +599,7 @@ int main(int argc, char** argv) // Recover messages gettimeofday(&t[1], NULL); for (j = 0; j < batch_size; j++) { - srslte_ldpc_decoder_decode_rm_c( + srsran_ldpc_decoder_decode_rm_c( &decoder_avx, symbols_c + j * finalN, messages_sim_avx + j * finalK, n_useful_symbols_dec); } gettimeofday(&t[2], NULL); @@ -621,7 +621,7 @@ int main(int argc, char** argv) // Recover messages gettimeofday(&t[1], NULL); for (j = 0; j < batch_size; j++) { - srslte_ldpc_decoder_decode_rm_c( + srsran_ldpc_decoder_decode_rm_c( &decoder_avx_flood, symbols_c + j * finalN, messages_sim_avx_flood + j * finalK, n_useful_symbols_dec); } gettimeofday(&t[2], NULL); @@ -645,7 +645,7 @@ int main(int argc, char** argv) // Recover messages gettimeofday(&t[1], NULL); for (j = 0; j < batch_size; j++) { - srslte_ldpc_decoder_decode_rm_c( + srsran_ldpc_decoder_decode_rm_c( &decoder_avx512, symbols_c + j * finalN, messages_sim_avx512 + j * finalK, finalN); } gettimeofday(&t[2], NULL); @@ -667,7 +667,7 @@ int main(int argc, char** argv) // Recover messages gettimeofday(&t[1], NULL); for (j = 0; j < batch_size; j++) { - srslte_ldpc_decoder_decode_rm_c( + srsran_ldpc_decoder_decode_rm_c( &decoder_avx512_flood, symbols_c + j * finalN, messages_sim_avx512_flood + j * finalK, finalN); } gettimeofday(&t[2], NULL); @@ -748,24 +748,24 @@ int main(int argc, char** argv) free(messages_sim_s); free(messages_sim_f); free(messages_true); - srslte_random_free(random_gen); + srsran_random_free(random_gen); #ifdef LV_HAVE_AVX2 - srslte_ldpc_decoder_free(&decoder_avx); - srslte_ldpc_decoder_free(&decoder_avx_flood); + srsran_ldpc_decoder_free(&decoder_avx); + srsran_ldpc_decoder_free(&decoder_avx_flood); #endif // LV_HAVE_AVX2 #ifdef LV_HAVE_AVX512 - srslte_ldpc_decoder_free(&decoder_avx512); - srslte_ldpc_decoder_free(&decoder_avx512_flood); + srsran_ldpc_decoder_free(&decoder_avx512); + srsran_ldpc_decoder_free(&decoder_avx512_flood); #endif // LV_HAVE_AVX512 - srslte_ldpc_decoder_free(&decoder_c_flood); - srslte_ldpc_decoder_free(&decoder_c); - srslte_ldpc_decoder_free(&decoder_s); - srslte_ldpc_decoder_free(&decoder_f); - srslte_ldpc_encoder_free(&encoder); - srslte_ldpc_rm_tx_free(&rm_tx); - srslte_ldpc_rm_rx_free_f(&rm_rx); - srslte_ldpc_rm_rx_free_s(&rm_rx_s); - srslte_ldpc_rm_rx_free_c(&rm_rx_c); + srsran_ldpc_decoder_free(&decoder_c_flood); + srsran_ldpc_decoder_free(&decoder_c); + srsran_ldpc_decoder_free(&decoder_s); + srsran_ldpc_decoder_free(&decoder_f); + srsran_ldpc_encoder_free(&encoder); + srsran_ldpc_rm_tx_free(&rm_tx); + srsran_ldpc_rm_rx_free_f(&rm_rx); + srsran_ldpc_rm_rx_free_s(&rm_rx_s); + srsran_ldpc_rm_rx_free_c(&rm_rx_c); } void print_decoder(char* title, int n_batches, int n_errors, double elapsed_time) diff --git a/lib/src/phy/fec/ldpc/test/ldpc_rm_test.c b/lib/src/phy/fec/ldpc/test/ldpc_rm_test.c index ac31009fe..57d8cd652 100644 --- a/lib/src/phy/fec/ldpc/test/ldpc_rm_test.c +++ b/lib/src/phy/fec/ldpc/test/ldpc_rm_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -37,20 +37,20 @@ #include #include -#include "srslte/phy/fec/ldpc/ldpc_common.h" -#include "srslte/phy/fec/ldpc/ldpc_encoder.h" -#include "srslte/phy/fec/ldpc/ldpc_rm.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/random.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/fec/ldpc/ldpc_common.h" +#include "srsran/phy/fec/ldpc/ldpc_encoder.h" +#include "srsran/phy/fec/ldpc/ldpc_rm.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/random.h" +#include "srsran/phy/utils/vector.h" -static srslte_basegraph_t base_graph = BG2; /*!< \brief Base Graph (BG1 or BG2). */ +static srsran_basegraph_t base_graph = BG2; /*!< \brief Base Graph (BG1 or BG2). */ static uint32_t lift_size = 208; /*!< \brief Lifting Size. */ static uint32_t C = 2; /*!< \brief Number of code block segments (CBS). */ static uint32_t F = 10; /*!< \brief Number of filler bits in each CBS. */ static uint32_t E = 0; /*!< \brief Rate-matched codeword size (E = 0, no rate matching). */ static uint8_t rv = 0; /*!< \brief Redundancy version {0-3}. */ -static srslte_mod_t mod_type = SRSLTE_MOD_QPSK; /*!< \brief Modulation type: BPSK, QPSK, QAM16, QAM64, QAM256. */ +static srsran_mod_t mod_type = SRSRAN_MOD_QPSK; /*!< \brief Modulation type: BPSK, QPSK, QAM16, QAM64, QAM256. */ static uint32_t Nref = 0; /*!< \brief Limited buffer size.*/ static uint32_t N = 0; /*!< \brief Codeblock size (including punctured and filler bits). */ @@ -95,7 +95,7 @@ void parse_args(int argc, char** argv) rv = (uint8_t)strtol(optarg, NULL, 10); break; case 'm': - mod_type = (srslte_mod_t)strtol(optarg, NULL, 10); + mod_type = (srsran_mod_t)strtol(optarg, NULL, 10); break; case 'M': Nref = (uint32_t)strtol(optarg, NULL, 10); @@ -128,11 +128,11 @@ int main(int argc, char** argv) parse_args(argc, argv); - srslte_random_t random_gen = srslte_random_init(0); + srsran_random_t random_gen = srsran_random_init(0); // create an LDPC encoder - srslte_ldpc_encoder_t encoder; - if (srslte_ldpc_encoder_init(&encoder, SRSLTE_LDPC_ENCODER_C, base_graph, lift_size) != 0) { + srsran_ldpc_encoder_t encoder; + if (srsran_ldpc_encoder_init(&encoder, SRSRAN_LDPC_ENCODER_C, base_graph, lift_size) != 0) { perror("encoder init"); exit(-1); } @@ -147,29 +147,29 @@ int main(int argc, char** argv) } // create a LDPC rate Matcher - srslte_ldpc_rm_t rm_tx; - if (srslte_ldpc_rm_tx_init(&rm_tx) != 0) { + srsran_ldpc_rm_t rm_tx; + if (srsran_ldpc_rm_tx_init(&rm_tx) != 0) { perror("rate matcher init"); exit(-1); } // create a LDPC rate DeMatcher - srslte_ldpc_rm_t rm_rx; - if (srslte_ldpc_rm_rx_init_f(&rm_rx) != 0) { + srsran_ldpc_rm_t rm_rx; + if (srsran_ldpc_rm_rx_init_f(&rm_rx) != 0) { perror("rate dematcher init"); exit(-1); } // create a LDPC rate DeMatcher (int16_t) - srslte_ldpc_rm_t rm_rx_s; - if (srslte_ldpc_rm_rx_init_s(&rm_rx_s) != 0) { + srsran_ldpc_rm_t rm_rx_s; + if (srsran_ldpc_rm_rx_init_s(&rm_rx_s) != 0) { perror("rate dematcher init (int16_t)"); exit(-1); } // create a LDPC rate DeMatcher (int8_t) - srslte_ldpc_rm_t rm_rx_c; - if (srslte_ldpc_rm_rx_init_c(&rm_rx_c) != 0) { + srsran_ldpc_rm_t rm_rx_c; + if (srsran_ldpc_rm_rx_init_c(&rm_rx_c) != 0) { perror("rate dematcher init (int8_t)"); exit(-1); } @@ -192,15 +192,15 @@ int main(int argc, char** argv) printf(" Final code rate -> (K-F)/E = (%d - %d)/%d = %.3f\n", encoder.liftK, F, E, 1.0 * (encoder.liftK - F) / E); printf("\n"); - codeblocks = srslte_vec_u8_malloc(C * K); - codewords = srslte_vec_u8_malloc(C * N); - rm_codewords = srslte_vec_u8_malloc(C * E); - rm_symbols = srslte_vec_f_malloc(C * E); - rm_symbols_s = srslte_vec_i16_malloc(C * E); - rm_symbols_c = srslte_vec_i8_malloc(C * E); - unrm_symbols = srslte_vec_f_malloc(C * N); - unrm_symbols_s = srslte_vec_i16_malloc(C * N); - unrm_symbols_c = srslte_vec_i8_malloc(C * N); + codeblocks = srsran_vec_u8_malloc(C * K); + codewords = srsran_vec_u8_malloc(C * N); + rm_codewords = srsran_vec_u8_malloc(C * E); + rm_symbols = srsran_vec_f_malloc(C * E); + rm_symbols_s = srsran_vec_i16_malloc(C * E); + rm_symbols_c = srsran_vec_i8_malloc(C * E); + unrm_symbols = srsran_vec_f_malloc(C * N); + unrm_symbols_s = srsran_vec_i16_malloc(C * N); + unrm_symbols_c = srsran_vec_i8_malloc(C * N); if (!codeblocks || !codewords || !rm_codewords || !rm_symbols || !rm_symbols_s || !rm_symbols_c || !unrm_symbols || !unrm_symbols_s || !unrm_symbols_c) { perror("malloc"); @@ -210,7 +210,7 @@ int main(int argc, char** argv) // Generate random bits for (r = 0; r < C; r++) { for (i = 0; i < K - F; i++) { - codeblocks[r * K + i] = srslte_random_uniform_int_dist(random_gen, 0, 1); + codeblocks[r * K + i] = srsran_random_uniform_int_dist(random_gen, 0, 1); } for (; i < K; i++) { // add filler bits codeblocks[r * K + i] = FILLER_BIT; @@ -220,12 +220,12 @@ int main(int argc, char** argv) // Encode messages // gettimeofday(&t[1], NULL); for (r = 0; r < C; r++) { - if (srslte_ldpc_encoder_encode(&encoder, codeblocks + r * K, codewords + r * N, K)) { + if (srsran_ldpc_encoder_encode(&encoder, codeblocks + r * K, codewords + r * N, K)) { exit(-1); } // LDPC rate matching - if (srslte_ldpc_rm_tx( + if (srsran_ldpc_rm_tx( &rm_tx, codewords + r * N, rm_codewords + r * E, E, base_graph, lift_size, rv, mod_type, Nref)) { exit(-1); } @@ -247,15 +247,15 @@ int main(int argc, char** argv) bzero(unrm_symbols_s + r * N, N * sizeof(int16_t)); bzero(unrm_symbols_c + r * N, N * sizeof(int8_t)); - if (srslte_ldpc_rm_rx_f( + if (srsran_ldpc_rm_rx_f( &rm_rx, rm_symbols + r * E, unrm_symbols + r * N, E, F, base_graph, lift_size, rv, mod_type, Nref)) { exit(-1); } - if (srslte_ldpc_rm_rx_s( + if (srsran_ldpc_rm_rx_s( &rm_rx_s, rm_symbols_s + r * E, unrm_symbols_s + r * N, E, F, base_graph, lift_size, rv, mod_type, Nref)) { exit(-1); } - if (srslte_ldpc_rm_rx_c( + if (srsran_ldpc_rm_rx_c( &rm_rx_c, rm_symbols_c + r * E, unrm_symbols_c + r * N, E, F, base_graph, lift_size, rv, mod_type, Nref)) { exit(-1); } @@ -338,11 +338,11 @@ int main(int argc, char** argv) free(rm_codewords); free(codewords); free(codeblocks); - srslte_random_free(random_gen); - srslte_ldpc_encoder_free(&encoder); - srslte_ldpc_rm_tx_free(&rm_tx); - srslte_ldpc_rm_rx_free_f(&rm_rx); - srslte_ldpc_rm_rx_free_s(&rm_rx_s); - srslte_ldpc_rm_rx_free_c(&rm_rx_c); + srsran_random_free(random_gen); + srsran_ldpc_encoder_free(&encoder); + srsran_ldpc_rm_tx_free(&rm_tx); + srsran_ldpc_rm_rx_free_f(&rm_rx); + srsran_ldpc_rm_rx_free_s(&rm_rx_s); + srsran_ldpc_rm_rx_free_c(&rm_rx_c); return error; } diff --git a/lib/src/phy/fec/polar/CMakeLists.txt b/lib/src/phy/fec/polar/CMakeLists.txt index 729b1df19..ce8ad3506 100644 --- a/lib/src/phy/fec/polar/CMakeLists.txt +++ b/lib/src/phy/fec/polar/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of diff --git a/lib/src/phy/fec/polar/polar_chanalloc.c b/lib/src/phy/fec/polar/polar_chanalloc.c index b35ba2fd4..301c9cd58 100644 --- a/lib/src/phy/fec/polar/polar_chanalloc.c +++ b/lib/src/phy/fec/polar/polar_chanalloc.c @@ -1,8 +1,8 @@ /** * - * section COPYRIGHT + * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -20,10 +20,10 @@ * */ -#include "srslte/phy/fec/polar/polar_chanalloc.h" +#include "srsran/phy/fec/polar/polar_chanalloc.h" #include -void srslte_polar_chanalloc_tx(const uint8_t* message, +void srsran_polar_chanalloc_tx(const uint8_t* message, uint8_t* input_encoder, const uint16_t N, const uint16_t K, @@ -72,7 +72,7 @@ void srslte_polar_chanalloc_tx(const uint8_t* message, } } -void srslte_polar_chanalloc_rx(const uint8_t* output_decoder, +void srsran_polar_chanalloc_rx(const uint8_t* output_decoder, uint8_t* message, const uint16_t K, const uint8_t nPC, diff --git a/lib/src/phy/fec/polar/polar_code.c b/lib/src/phy/fec/polar/polar_code.c index f13e09381..51a675b25 100644 --- a/lib/src/phy/fec/polar/polar_code.c +++ b/lib/src/phy/fec/polar/polar_code.c @@ -1,8 +1,8 @@ /** * - * section COPYRIGHT + * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -24,12 +24,12 @@ * The frozen bit set provided by this function is used by the polar decoder. */ -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/utils/vector.h" #include #include -#include "srslte/phy/fec/polar/polar_code.h" -#include "srslte/phy/utils/debug.h" +#include "srsran/phy/fec/polar/polar_code.h" +#include "srsran/phy/utils/debug.h" /*! * Extracts the elements in x that are smaller than T or are in y. @@ -84,7 +84,7 @@ int cmpfunc(const void* a, const void* b) * Gets the codeword length N, nPC and nWmPC depending on the code parameters. * Returns -1 if not supported configuration, otherwise returns 0. */ -int get_code_params(srslte_polar_code_t* c, const uint16_t K, const uint16_t E, const uint8_t nMax) +int get_code_params(srsran_polar_code_t* c, const uint16_t K, const uint16_t E, const uint8_t nMax) { // include here also npc and nwmPC computatoins if (E > EMAX) { @@ -182,7 +182,7 @@ int get_code_params(srslte_polar_code_t* c, const uint16_t K, const uint16_t E, return 0; } -void srslte_polar_code_free(srslte_polar_code_t* c) +void srsran_polar_code_free(srsran_polar_code_t* c) { if (c != NULL) { free(c->F_set); @@ -191,15 +191,15 @@ void srslte_polar_code_free(srslte_polar_code_t* c) } // allocate resources to the message set, frozen set and parity set, polar code -int srslte_polar_code_init(srslte_polar_code_t* c) +int srsran_polar_code_init(srsran_polar_code_t* c) { - c->tmp_K_set = srslte_vec_u16_malloc(NMAX + 1); // +1 to mark the end with 1024 + c->tmp_K_set = srsran_vec_u16_malloc(NMAX + 1); // +1 to mark the end with 1024 if (!c->tmp_K_set) { perror("malloc"); exit(-1); } - c->F_set = srslte_vec_u16_malloc(NMAX); + c->F_set = srsran_vec_u16_malloc(NMAX); if (!c->F_set) { free(c->tmp_K_set); perror("malloc"); @@ -209,7 +209,7 @@ int srslte_polar_code_init(srslte_polar_code_t* c) return 0; } -int srslte_polar_code_get(srslte_polar_code_t* c, uint16_t K, uint16_t E, uint8_t nMax) +int srsran_polar_code_get(srsran_polar_code_t* c, uint16_t K, uint16_t E, uint8_t nMax) { if (c == NULL) { return -1; diff --git a/lib/src/phy/fec/polar/polar_decoder.c b/lib/src/phy/fec/polar/polar_decoder.c index 90e81dba3..4d583476f 100644 --- a/lib/src/phy/fec/polar/polar_decoder.c +++ b/lib/src/phy/fec/polar/polar_decoder.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -32,8 +32,8 @@ #include "polar_decoder_ssc_c_avx2.h" #include "polar_decoder_ssc_f.h" #include "polar_decoder_ssc_s.h" -#include "srslte/phy/fec/polar/polar_decoder.h" -#include "srslte/phy/utils/debug.h" +#include "srsran/phy/fec/polar/polar_decoder.h" +#include "srsran/phy/utils/debug.h" /*! SSC Polar decoder with float LLR inputs. */ static int decode_ssc_f(void* o, @@ -43,7 +43,7 @@ static int decode_ssc_f(void* o, const uint16_t* frozen_set, const uint16_t frozen_set_size) { - srslte_polar_decoder_t* q = o; + srsran_polar_decoder_t* q = o; init_polar_decoder_ssc_f(q->ptr, symbols, data, n, frozen_set, frozen_set_size); @@ -60,7 +60,7 @@ static int decode_ssc_s(void* o, const uint16_t* frozen_set, const uint16_t frozen_set_size) { - srslte_polar_decoder_t* q = o; + srsran_polar_decoder_t* q = o; init_polar_decoder_ssc_s(q->ptr, symbols, data, n, frozen_set, frozen_set_size); @@ -77,7 +77,7 @@ static int decode_ssc_c(void* o, const uint16_t* frozen_set, const uint16_t frozen_set_size) { - srslte_polar_decoder_t* q = o; + srsran_polar_decoder_t* q = o; init_polar_decoder_ssc_c(q->ptr, symbols, data, n, frozen_set, frozen_set_size); @@ -95,7 +95,7 @@ static int decode_ssc_c_avx2(void* o, const uint16_t* frozen_set, const uint16_t frozen_set_size) { - srslte_polar_decoder_t* q = o; + srsran_polar_decoder_t* q = o; init_polar_decoder_ssc_c_avx2(q->ptr, symbols, data, n, frozen_set, frozen_set_size); @@ -108,21 +108,21 @@ static int decode_ssc_c_avx2(void* o, /*! Destructor of a (float) SSC polar decoder. */ static void free_ssc_f(void* o) { - srslte_polar_decoder_t* q = o; + srsran_polar_decoder_t* q = o; delete_polar_decoder_ssc_f(q->ptr); } /*! Destructor of a (int16_t) SSC polar decoder. */ static void free_ssc_s(void* o) { - srslte_polar_decoder_t* q = o; + srsran_polar_decoder_t* q = o; delete_polar_decoder_ssc_s(q->ptr); } /*! Destructor of a (int8_t) SSC polar decoder. */ static void free_ssc_c(void* o) { - srslte_polar_decoder_t* q = o; + srsran_polar_decoder_t* q = o; delete_polar_decoder_ssc_c(q->ptr); } @@ -130,13 +130,13 @@ static void free_ssc_c(void* o) /*! Destructor of a (int8_t, avx2) SSC polar decoder. */ static void free_ssc_c_avx2(void* o) { - srslte_polar_decoder_t* q = o; + srsran_polar_decoder_t* q = o; delete_polar_decoder_ssc_c_avx2(q->ptr); } #endif /*! Initializes a polar decoder structure to use the SSC polar decoder algorithm with float LLR inputs. */ -static int init_ssc_f(srslte_polar_decoder_t* q) +static int init_ssc_f(srsran_polar_decoder_t* q) { q->decode_f = decode_ssc_f; q->free = free_ssc_f; @@ -150,7 +150,7 @@ static int init_ssc_f(srslte_polar_decoder_t* q) } /*! Initializes a polar decoder structure to use the SSC polar decoder algorithm with uint16_t LLR inputs. */ -static int init_ssc_s(srslte_polar_decoder_t* q) +static int init_ssc_s(srsran_polar_decoder_t* q) { q->decode_s = decode_ssc_s; q->free = free_ssc_s; @@ -164,7 +164,7 @@ static int init_ssc_s(srslte_polar_decoder_t* q) } /*! Initializes a polar decoder structure to use the SSC polar decoder algorithm with uint8_t LLR inputs. */ -static int init_ssc_c(srslte_polar_decoder_t* q) +static int init_ssc_c(srsran_polar_decoder_t* q) { q->decode_c = decode_ssc_c; q->free = free_ssc_c; @@ -180,7 +180,7 @@ static int init_ssc_c(srslte_polar_decoder_t* q) #ifdef LV_HAVE_AVX2 /*! Initializes a polar decoder structure to use the SSC polar decoder algorithm with uint8_t LLR inputs and AVX2 * instructions. */ -static int init_ssc_c_avx2(srslte_polar_decoder_t* q) +static int init_ssc_c_avx2(srsran_polar_decoder_t* q) { q->decode_c = decode_ssc_c_avx2; q->free = free_ssc_c_avx2; @@ -194,18 +194,18 @@ static int init_ssc_c_avx2(srslte_polar_decoder_t* q) } #endif -int srslte_polar_decoder_init(srslte_polar_decoder_t* q, srslte_polar_decoder_type_t type, const uint8_t nMax) +int srsran_polar_decoder_init(srsran_polar_decoder_t* q, srsran_polar_decoder_type_t type, const uint8_t nMax) { q->nMax = nMax; switch (type) { - case SRSLTE_POLAR_DECODER_SSC_F: + case SRSRAN_POLAR_DECODER_SSC_F: return init_ssc_f(q); - case SRSLTE_POLAR_DECODER_SSC_S: + case SRSRAN_POLAR_DECODER_SSC_S: return init_ssc_s(q); - case SRSLTE_POLAR_DECODER_SSC_C: + case SRSRAN_POLAR_DECODER_SSC_C: return init_ssc_c(q); #ifdef LV_HAVE_AVX2 - case SRSLTE_POLAR_DECODER_SSC_C_AVX2: + case SRSRAN_POLAR_DECODER_SSC_C_AVX2: return init_ssc_c_avx2(q); #endif default: @@ -215,15 +215,15 @@ int srslte_polar_decoder_init(srslte_polar_decoder_t* q, srslte_polar_decoder_ty return 0; } -void srslte_polar_decoder_free(srslte_polar_decoder_t* q) +void srsran_polar_decoder_free(srsran_polar_decoder_t* q) { if (q->free) { q->free(q); } - memset(q, 0, sizeof(srslte_polar_decoder_t)); + memset(q, 0, sizeof(srsran_polar_decoder_t)); } -int srslte_polar_decoder_decode_f(srslte_polar_decoder_t* q, +int srsran_polar_decoder_decode_f(srsran_polar_decoder_t* q, const float* llr, uint8_t* data_decoded, const uint8_t n, @@ -237,7 +237,7 @@ int srslte_polar_decoder_decode_f(srslte_polar_decoder_t* q, return -1; } -int srslte_polar_decoder_decode_s(srslte_polar_decoder_t* q, +int srsran_polar_decoder_decode_s(srsran_polar_decoder_t* q, const int16_t* llr, uint8_t* data_decoded, const uint8_t n, @@ -251,7 +251,7 @@ int srslte_polar_decoder_decode_s(srslte_polar_decoder_t* q, return -1; } -int srslte_polar_decoder_decode_c(srslte_polar_decoder_t* q, +int srsran_polar_decoder_decode_c(srsran_polar_decoder_t* q, const int8_t* llr, uint8_t* data_decoded, const uint8_t n, diff --git a/lib/src/phy/fec/polar/polar_decoder_ssc_all.c b/lib/src/phy/fec/polar/polar_decoder_ssc_all.c index 2e07c351c..5b769e5d6 100644 --- a/lib/src/phy/fec/polar/polar_decoder_ssc_all.c +++ b/lib/src/phy/fec/polar/polar_decoder_ssc_all.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -22,7 +22,7 @@ */ #include "polar_decoder_ssc_all.h" #include "../utils_avx2.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/utils/vector.h" /*! * \brief Structure with pointers needed to obtain the node_type @@ -41,13 +41,13 @@ void* create_tmp_node_type(const uint8_t nMax) if ((tmp = malloc(sizeof(struct Tmp_node_type))) == NULL) { return NULL; } - SRSLTE_MEM_ZERO(tmp, struct Tmp_node_type, 1); + SRSRAN_MEM_ZERO(tmp, struct Tmp_node_type, 1); uint16_t max_code_size = (1U << nMax); uint8_t nMax_1 = nMax - 1; uint16_t max_code_half_size = (1U << nMax_1); - tmp->is_not_rate_0 = srslte_vec_u8_malloc(2 * max_code_size); + tmp->is_not_rate_0 = srsran_vec_u8_malloc(2 * max_code_size); if (!tmp->is_not_rate_0) { free(tmp); perror("malloc"); @@ -56,7 +56,7 @@ void* create_tmp_node_type(const uint8_t nMax) tmp->is_rate_1 = tmp->is_not_rate_0 + max_code_size; - tmp->i_odd = srslte_vec_u16_malloc(max_code_half_size); + tmp->i_odd = srsran_vec_u16_malloc(max_code_half_size); if (!tmp->i_odd) { free(tmp->is_not_rate_0); free(tmp); @@ -64,7 +64,7 @@ void* create_tmp_node_type(const uint8_t nMax) return NULL; } - tmp->i_even = srslte_vec_u16_malloc(max_code_half_size); + tmp->i_even = srsran_vec_u16_malloc(max_code_half_size); if (!tmp->i_even) { free(tmp->is_not_rate_0); free(tmp->i_odd); @@ -167,21 +167,21 @@ int init_node_type(const uint16_t* frozen_set, struct Params* param) uint16_t code_size = param->code_stage_size[param->code_size_log]; uint16_t code_half_size = param->code_stage_size[param->code_size_log - 1]; - is_not_rate_0 = srslte_vec_u8_malloc(2 * code_size); + is_not_rate_0 = srsran_vec_u8_malloc(2 * code_size); if (!is_not_rate_0) { perror("malloc"); return -1; } is_rate_1 = is_not_rate_0 + code_size; - i_odd = srslte_vec_u16_malloc(code_half_size); + i_odd = srsran_vec_u16_malloc(code_half_size); if (!i_odd) { free(is_not_rate_0); perror("malloc"); return -1; } - i_even = srslte_vec_u16_malloc(code_half_size); + i_even = srsran_vec_u16_malloc(code_half_size); if (!i_even) { free(is_not_rate_0); free(i_odd); diff --git a/lib/src/phy/fec/polar/polar_decoder_ssc_all.h b/lib/src/phy/fec/polar/polar_decoder_ssc_all.h index 14c6727fc..a59fd0e5f 100644 --- a/lib/src/phy/fec/polar/polar_decoder_ssc_all.h +++ b/lib/src/phy/fec/polar/polar_decoder_ssc_all.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/lib/src/phy/fec/polar/polar_decoder_ssc_c.c b/lib/src/phy/fec/polar/polar_decoder_ssc_c.c index 1f4a37cc3..f8b779376 100644 --- a/lib/src/phy/fec/polar/polar_decoder_ssc_c.c +++ b/lib/src/phy/fec/polar/polar_decoder_ssc_c.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -26,16 +26,16 @@ // (1) #include "polar_decoder_ssc_c.h" // (2) the naming of the external function, which finish with _s instead of _f // (3) the initialization of them of the set functions in create_polar_decoder_ssc_s -// pp->f = srslte_vec_function_f_ccc; -// pp->g = srslte_vec_function_g_bccc; -// pp->xor = srslte_vec_xor_bbb; -// pp->hard_bit = srslte_vec_hard_bit_cc; +// pp->f = srsran_vec_function_f_ccc; +// pp->g = srsran_vec_function_g_bccc; +// pp->xor = srsran_vec_xor_bbb; +// pp->hard_bit = srsran_vec_hard_bit_cc; #include "polar_decoder_ssc_c.h" #include "../utils_avx2.h" #include "polar_decoder_vector.h" -#include "srslte/phy/fec/polar/polar_encoder.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/fec/polar/polar_encoder.h" +#include "srsran/phy/utils/vector.h" /*! * \brief Describes an SSC polar decoder (8-bit version). @@ -47,7 +47,7 @@ struct pSSC_c { struct Params* param; /*!< \brief Pointer to a Params structure. */ struct State* state; /*!< \brief Pointer to a State. */ void* tmp_node_type; /*!< \brief Pointer to a Tmp_node_type. */ - srslte_polar_encoder_t* enc; /*!< \brief Pointer to a srslte_polar_encoder_t. */ + srsran_polar_encoder_t* enc; /*!< \brief Pointer to a srsran_polar_encoder_t. */ void (*f)(const int8_t* x, const int8_t* y, int8_t* z, const uint16_t len); /*!< \brief Pointer to the function-f. */ void (*g)(const uint8_t* b, const int8_t* x, @@ -87,9 +87,9 @@ static void rate_1_node(void* p, uint8_t* message); /*! * ::RATE_R nodes at stage \f$ s \f$ return the associated \f$2^s\f$ decoded bit by calling * the child nodes to the right and left of the decoding tree and then polar encoding (xor) their output. - * At stage \f$ s \f$, this function runs function srslte_vec_function_f_fff() and srslte_vec_function_g_bfff() + * At stage \f$ s \f$, this function runs function srsran_vec_function_f_fff() and srsran_vec_function_g_bfff() * with vector size \f$2^{ s - 1}\f$ and updates \a llr0 and \a llr1 memory space for stage \f$(s - 1)\f$. - * This function also runs srslte_vec_xor_bbb() with vector size \f$2^{s-1}\f$ and + * This function also runs srsran_vec_xor_bbb() with vector size \f$2^{s-1}\f$ and * updates \a estbits memory space for stage \f$(s + 1)\f$. * */ @@ -185,7 +185,7 @@ void delete_polar_decoder_ssc_c(void* p) free(pp->state); } if (pp->enc) { - srslte_polar_encoder_free(pp->enc); + srsran_polar_encoder_free(pp->enc); free(pp->enc); } if (pp->tmp_node_type) { @@ -203,28 +203,28 @@ void* create_polar_decoder_ssc_c(const uint8_t nMax) if ((pp = malloc(sizeof(struct pSSC_c))) == NULL) { return NULL; } - SRSLTE_MEM_ZERO(pp, struct pSSC_c, 1); + SRSRAN_MEM_ZERO(pp, struct pSSC_c, 1); // set functions - pp->f = srslte_vec_function_f_ccc; - pp->g = srslte_vec_function_g_bccc; - pp->xor = srslte_vec_xor_bbb; - pp->hard_bit = srslte_vec_hard_bit_cc; + pp->f = srsran_vec_function_f_ccc; + pp->g = srsran_vec_function_g_bccc; + pp->xor = srsran_vec_xor_bbb; + pp->hard_bit = srsran_vec_hard_bit_cc; // encoder of maximum size - if ((pp->enc = SRSLTE_MEM_ALLOC(srslte_polar_encoder_t, 1)) == NULL) { + if ((pp->enc = SRSRAN_MEM_ALLOC(srsran_polar_encoder_t, 1)) == NULL) { delete_polar_decoder_ssc_c(pp); return NULL; } - srslte_polar_encoder_init(pp->enc, SRSLTE_POLAR_ENCODER_PIPELINED, nMax); + srsran_polar_encoder_init(pp->enc, SRSRAN_POLAR_ENCODER_PIPELINED, nMax); // algorithm constants/parameters - if ((pp->param = SRSLTE_MEM_ALLOC(struct Params, 1)) == NULL) { + if ((pp->param = SRSRAN_MEM_ALLOC(struct Params, 1)) == NULL) { delete_polar_decoder_ssc_c(pp); return NULL; } - if ((pp->param->code_stage_size = srslte_vec_u16_malloc(nMax + 1)) == NULL) { + if ((pp->param->code_stage_size = srsran_vec_u16_malloc(nMax + 1)) == NULL) { delete_polar_decoder_ssc_c(pp); return NULL; } @@ -242,7 +242,7 @@ void* create_polar_decoder_ssc_c(const uint8_t nMax) free(pp); return NULL; } - if ((pp->state->active_node_per_stage = srslte_vec_u16_malloc(nMax + 1)) == NULL) { + if ((pp->state->active_node_per_stage = srsran_vec_u16_malloc(nMax + 1)) == NULL) { free(pp->state); free(pp->param->code_stage_size); free(pp->param); @@ -254,7 +254,7 @@ void* create_polar_decoder_ssc_c(const uint8_t nMax) // allocates memory for estimated bits per stage uint16_t est_bits_size = pp->param->code_stage_size[nMax]; - pp->est_bit = srslte_vec_u8_malloc(est_bits_size); // every 32 chars are aligned + pp->est_bit = srsran_vec_u8_malloc(est_bits_size); // every 32 chars are aligned // allocate memory for LLR pointers. pp->llr0 = malloc((nMax + 1) * sizeof(int8_t*)); @@ -262,7 +262,7 @@ void* create_polar_decoder_ssc_c(const uint8_t nMax) // There are LLR buffers for n = 0 to n = code_size_log. Each with size 2^n. Thus, // the total memory needed is 2^(n+1)-1. - // Only the stages starting at multiples of SRSLTE_AVX2_B_SIZE are aligned. + // Only the stages starting at multiples of SRSRAN_AVX2_B_SIZE are aligned. // Let n_simd_llr be the exponent of the SIMD size in nummer of LLRs. // i.e. in a SIMD instruction we can load 2^(n_simd_llr) LLR values @@ -271,7 +271,7 @@ void* create_polar_decoder_ssc_c(const uint8_t nMax) uint8_t n_llr_all_stages = nMax + 1; // there are 2^(n_llr_all_stages) - 1 LLR values summing up all stages. uint16_t llr_all_stages = 1U << n_llr_all_stages; - pp->llr0[0] = srslte_vec_i8_malloc(llr_all_stages); // 32*8=256 + pp->llr0[0] = srsran_vec_i8_malloc(llr_all_stages); // 32*8=256 // allocate memory to the polar decoder instance if (pp->llr0[0] == NULL) { free(pp->est_bit); @@ -295,7 +295,7 @@ void* create_polar_decoder_ssc_c(const uint8_t nMax) // allocate memory to node_type_ssc. Stage s has 2^(N-s) nodes s=0,...,N. // Thus, same size as LLRs all stages. - pp->param->node_type[0] = srslte_vec_u8_malloc(llr_all_stages); // 32*8=256 + pp->param->node_type[0] = srsran_vec_u8_malloc(llr_all_stages); // 32*8=256 if (pp->param->node_type[0] == NULL) { free(pp->param->node_type); @@ -395,7 +395,7 @@ static void rate_1_node(void* p, uint8_t* message) pp->hard_bit(LLR, codeword, code_stage_size); if (stage != 0) { - srslte_polar_encoder_encode(pp->enc, codeword, message + bit_pos, stage); + srsran_polar_encoder_encode(pp->enc, codeword, message + bit_pos, stage); } else { message[bit_pos] = codeword[0]; } diff --git a/lib/src/phy/fec/polar/polar_decoder_ssc_c.h b/lib/src/phy/fec/polar/polar_decoder_ssc_c.h index e718cec92..573101496 100644 --- a/lib/src/phy/fec/polar/polar_decoder_ssc_c.h +++ b/lib/src/phy/fec/polar/polar_decoder_ssc_c.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/lib/src/phy/fec/polar/polar_decoder_ssc_c_avx2.c b/lib/src/phy/fec/polar/polar_decoder_ssc_c_avx2.c index 6be94df6e..dd569b101 100644 --- a/lib/src/phy/fec/polar/polar_decoder_ssc_c_avx2.c +++ b/lib/src/phy/fec/polar/polar_decoder_ssc_c_avx2.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -25,8 +25,8 @@ #include "polar_decoder_ssc_c_avx2.h" #include "../utils_avx2.h" #include "polar_decoder_vector_avx2.h" -#include "srslte/phy/fec/polar/polar_encoder.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/fec/polar/polar_encoder.h" +#include "srsran/phy/utils/vector.h" #ifdef LV_HAVE_AVX2 @@ -48,7 +48,7 @@ struct pSSC_c_avx2 { struct Params* param; /*!< \brief Pointer to a Params structure. */ struct StateAVX2* state; /*!< \brief Pointer to a State. */ void* tmp_node_type; /*!< \brief Pointer to a Tmp_node_type. */ - srslte_polar_encoder_t* enc; /*!< \brief Pointer to a srslte_polar_encoder_t. */ + srsran_polar_encoder_t* enc; /*!< \brief Pointer to a srsran_polar_encoder_t. */ void (*f)(const int8_t* x, const int8_t* y, int8_t* z, const uint16_t len); /*!< \brief Pointer to the function-f. */ void (*g)(const uint8_t* b, const int8_t* x, @@ -84,9 +84,9 @@ static int max(int a, int b) * * ::RATE_R nodes at stage \f$ s \f$ return the associated \f$2^s\f$ decoded bits by calling * the child nodes to the right and left of the decoding tree and then polar encoding (xor) their output. - * At stage \f$ s \f$, this function runs function srslte_vec_function_f_fff() and srslte_vec_function_g_bfff() + * At stage \f$ s \f$, this function runs function srsran_vec_function_f_fff() and srsran_vec_function_g_bfff() * with vector size \f$2^{ s - 1}\f$ and updates \a llr0 and \a llr1 memory space for stage \f$(s - 1)\f$. - * This function also runs srslte_vec_xor_bbb() with vector size \f$2^{s-1}\f$ and + * This function also runs srsran_vec_xor_bbb() with vector size \f$2^{s-1}\f$ and * updates \a estbits memory space for stage \f$(s + 1)\f$. * */ @@ -125,7 +125,7 @@ void delete_polar_decoder_ssc_c_avx2(void* p) free(pp->state); } if (pp->enc) { - srslte_polar_encoder_free(pp->enc); + srsran_polar_encoder_free(pp->enc); free(pp->enc); } if (pp->tmp_node_type) { @@ -144,18 +144,18 @@ void* create_polar_decoder_ssc_c_avx2(const uint8_t nMax) } // set functions - pp->f = srslte_vec_function_f_ccc_avx2; - pp->g = srslte_vec_function_g_bccc_avx2; - pp->xor = srslte_vec_xor_bbb_avx2; - pp->hard_bit = srslte_vec_hard_bit_cc_avx2; + pp->f = srsran_vec_function_f_ccc_avx2; + pp->g = srsran_vec_function_g_bccc_avx2; + pp->xor = srsran_vec_xor_bbb_avx2; + pp->hard_bit = srsran_vec_hard_bit_cc_avx2; // encoder of maximum size - if ((pp->enc = malloc(sizeof(srslte_polar_encoder_t))) == NULL) { + if ((pp->enc = malloc(sizeof(srsran_polar_encoder_t))) == NULL) { free(pp); return NULL; } - srslte_polar_encoder_init(pp->enc, SRSLTE_POLAR_ENCODER_AVX2, nMax); + srsran_polar_encoder_init(pp->enc, SRSRAN_POLAR_ENCODER_AVX2, nMax); // algorithm constants/parameters if ((pp->param = malloc(sizeof(struct Params))) == NULL) { @@ -164,7 +164,7 @@ void* create_polar_decoder_ssc_c_avx2(const uint8_t nMax) return NULL; } - if ((pp->param->code_stage_size = srslte_vec_u16_malloc(nMax + 1)) == NULL) { + if ((pp->param->code_stage_size = srsran_vec_u16_malloc(nMax + 1)) == NULL) { free(pp->param); free(pp->enc); free(pp); @@ -186,16 +186,16 @@ void* create_polar_decoder_ssc_c_avx2(const uint8_t nMax) } // allocates memory for estimated bits per stage - // allocates extra SRSLTE_AVX2_B_SIZE bytes to allow store the output of 256-bit instructions - int est_bit_size = pp->param->code_stage_size[nMax] + SRSLTE_AVX2_B_SIZE; + // allocates extra SRSRAN_AVX2_B_SIZE bytes to allow store the output of 256-bit instructions + int est_bit_size = pp->param->code_stage_size[nMax] + SRSRAN_AVX2_B_SIZE; - pp->est_bit = srslte_vec_u8_malloc(est_bit_size); // every 32 chars are aligned + pp->est_bit = srsran_vec_u8_malloc(est_bit_size); // every 32 chars are aligned // allocate memory for LLR pointers. pp->llr0 = malloc((nMax + 1) * sizeof(int8_t*)); pp->llr1 = malloc((nMax + 1) * sizeof(int8_t*)); - // LLR MEMORY NOT ALIGNED FOR LLR_BUFFERS_SIZE < SRSLTE_SIMB_LLR_ALIGNED + // LLR MEMORY NOT ALIGNED FOR LLR_BUFFERS_SIZE < SRSRAN_SIMB_LLR_ALIGNED // We do not align the memory at lower stages, as if done, after each function f and function g // operation, the second half of the output vector needs to be moved to the next @@ -204,22 +204,22 @@ void* create_polar_decoder_ssc_c_avx2(const uint8_t nMax) uint8_t n_llr_all_stages = nMax + 1; // there are 2^(n_llr_all_stages) - 1 LLR values summing up all stages. uint16_t llr_all_stages = 1U << n_llr_all_stages; - // Reserve at least SRSLTE_AVX2_B_SIZE bytes for each stage, so that there is space for the output + // Reserve at least SRSRAN_AVX2_B_SIZE bytes for each stage, so that there is space for the output // of the 32-bytes mm256 vectorized functions. // llr1 (second half) of lower stages is not aligned. uint16_t llr_all_stages_avx2 = llr_all_stages; if (nMax >= 5) { - llr_all_stages_avx2 += SRSLTE_AVX2_B_SIZE * 5; + llr_all_stages_avx2 += SRSRAN_AVX2_B_SIZE * 5; } else { - llr_all_stages_avx2 += (nMax + 1) * SRSLTE_AVX2_B_SIZE; + llr_all_stages_avx2 += (nMax + 1) * SRSRAN_AVX2_B_SIZE; } - // add extra SRSLTE_AVX2_B_SIZE llrs positions for hard_bit functions on the last bits have + // add extra SRSRAN_AVX2_B_SIZE llrs positions for hard_bit functions on the last bits have // access to allocated memory - llr_all_stages_avx2 += SRSLTE_AVX2_B_SIZE; + llr_all_stages_avx2 += SRSRAN_AVX2_B_SIZE; - pp->llr0[0] = srslte_vec_i8_malloc(llr_all_stages_avx2); // 32*8=256 + pp->llr0[0] = srsran_vec_i8_malloc(llr_all_stages_avx2); // 32*8=256 // allocate memory to the polar decoder instance if (pp->llr0[0] == NULL) { @@ -229,16 +229,16 @@ void* create_polar_decoder_ssc_c_avx2(const uint8_t nMax) pp->llr1[0] = pp->llr0[0] + 1; for (uint8_t s = 1; s < nMax + 1; s++) { - pp->llr0[s] = pp->llr0[s - 1] + max(SRSLTE_AVX2_B_SIZE, pp->param->code_stage_size[s - 1]); + pp->llr0[s] = pp->llr0[s - 1] + max(SRSRAN_AVX2_B_SIZE, pp->param->code_stage_size[s - 1]); pp->llr1[s] = pp->llr0[s] + pp->param->code_stage_size[s - 1]; } // allocate memory for node type pointers, one per stage. - pp->param->node_type = SRSLTE_MEM_ALLOC(uint8_t*, nMax + 1); + pp->param->node_type = SRSRAN_MEM_ALLOC(uint8_t*, nMax + 1); // allocate memory to node_type_ssc. Stage s has 2^(N-s) nodes s=0,...,N. // Thus, same size as LLRs all stages. - pp->param->node_type[0] = srslte_vec_u8_malloc(llr_all_stages); // 32*8=256 + pp->param->node_type[0] = srsran_vec_u8_malloc(llr_all_stages); // 32*8=256 if (pp->param->node_type[0] == NULL) { delete_polar_decoder_ssc_c_avx2(pp); @@ -281,7 +281,7 @@ int init_polar_decoder_ssc_c_avx2(void* p, memset(data_decoded, 0, code_size); // Initialize est_bit vector to all zeros - int est_bit_size = pp->param->code_stage_size[code_size_log] + SRSLTE_AVX2_B_SIZE; + int est_bit_size = pp->param->code_stage_size[code_size_log] + SRSRAN_AVX2_B_SIZE; memset(pp->est_bit, 0, est_bit_size); // Initializes LLR buffer for the last stage/level with the input LLRs values @@ -313,10 +313,10 @@ int polar_decoder_ssc_c_avx2(void* p, uint8_t* data_decoded) simplified_node(pp); // est_bit contains the coded bits. To obtain the message, we call the encoder - srslte_polar_encoder_encode(pp->enc, pp->est_bit, data_decoded, pp->param->code_size_log); + srsran_polar_encoder_encode(pp->enc, pp->est_bit, data_decoded, pp->param->code_size_log); // transform {0,-128} into {0, 1} - srslte_vec_sign_to_bit_c_avx2(data_decoded, 1U << pp->param->code_size_log); + srsran_vec_sign_to_bit_c_avx2(data_decoded, 1U << pp->param->code_size_log); return 0; } diff --git a/lib/src/phy/fec/polar/polar_decoder_ssc_c_avx2.h b/lib/src/phy/fec/polar/polar_decoder_ssc_c_avx2.h index 903bc4264..6f275ea9d 100644 --- a/lib/src/phy/fec/polar/polar_decoder_ssc_c_avx2.h +++ b/lib/src/phy/fec/polar/polar_decoder_ssc_c_avx2.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/lib/src/phy/fec/polar/polar_decoder_ssc_f.c b/lib/src/phy/fec/polar/polar_decoder_ssc_f.c index d893d15d2..58d580cfb 100644 --- a/lib/src/phy/fec/polar/polar_decoder_ssc_f.c +++ b/lib/src/phy/fec/polar/polar_decoder_ssc_f.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -25,8 +25,8 @@ #include "polar_decoder_ssc_f.h" #include "../utils_avx2.h" #include "polar_decoder_vector.h" -#include "srslte/phy/fec/polar/polar_encoder.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/fec/polar/polar_encoder.h" +#include "srsran/phy/utils/vector.h" /*! * \brief Describes an SSC polar decoder (float version). @@ -38,7 +38,7 @@ struct pSSC_f { struct Params* param; /*!< \brief Pointer to a Params structure. */ struct State* state; /*!< \brief Pointer to a State. */ void* tmp_node_type; /*!< \brief Pointer to a Tmp_node_type. */ - srslte_polar_encoder_t* enc; /*!< \brief Pointer to a srslte_polar_encoder_t. */ + srsran_polar_encoder_t* enc; /*!< \brief Pointer to a srsran_polar_encoder_t. */ void (*f)(const float* x, const float* y, float* z, const uint16_t len); /*!< \brief Pointer to the function-f. */ void (*g)(const uint8_t* b, const float* x, @@ -78,9 +78,9 @@ static void rate_1_node(void* p, uint8_t* message); /*! * ::RATE_R nodes at stage \f$ s \f$ return the associated \f$2^s\f$ decoded bit by calling * the child nodes to the right and left of the decoding tree and then polar encoding (xor) their output. - * At stage \f$ s \f$, this function runs function srslte_vec_function_f_fff() and srslte_vec_function_g_bfff() + * At stage \f$ s \f$, this function runs function srsran_vec_function_f_fff() and srsran_vec_function_g_bfff() * with vector size \f$2^{ s - 1}\f$ and updates \a llr0 and \a llr1 memory space for stage \f$(s - 1)\f$. - * This function also runs srslte_vec_xor_bbb() with vector size \f$2^{s-1}\f$ and + * This function also runs srsran_vec_xor_bbb() with vector size \f$2^{s-1}\f$ and * updates \a estbits memory space for stage \f$(s + 1)\f$. * */ @@ -156,7 +156,7 @@ void delete_polar_decoder_ssc_f(void* p) free(pp->param); free(pp->state->active_node_per_stage); free(pp->state); - srslte_polar_encoder_free(pp->enc); + srsran_polar_encoder_free(pp->enc); free(pp->enc); // free(pp->frozen_set); // this is not SSC responsibility. delete_tmp_node_type(pp->tmp_node_type); @@ -174,17 +174,17 @@ void* create_polar_decoder_ssc_f(const uint8_t nMax) } // set functions - pp->f = srslte_vec_function_f_fff; - pp->g = srslte_vec_function_g_bfff; - pp->xor = srslte_vec_xor_bbb; - pp->hard_bit = srslte_vec_hard_bit_fc; + pp->f = srsran_vec_function_f_fff; + pp->g = srsran_vec_function_g_bfff; + pp->xor = srsran_vec_xor_bbb; + pp->hard_bit = srsran_vec_hard_bit_fc; // encoder of maximum size - if ((pp->enc = malloc(sizeof(srslte_polar_encoder_t))) == NULL) { + if ((pp->enc = malloc(sizeof(srsran_polar_encoder_t))) == NULL) { free(pp); return NULL; } - srslte_polar_encoder_init(pp->enc, SRSLTE_POLAR_ENCODER_PIPELINED, nMax); + srsran_polar_encoder_init(pp->enc, SRSRAN_POLAR_ENCODER_PIPELINED, nMax); // algorithm constants/parameters if ((pp->param = malloc(sizeof(struct Params))) == NULL) { @@ -193,7 +193,7 @@ void* create_polar_decoder_ssc_f(const uint8_t nMax) return NULL; } - if ((pp->param->code_stage_size = srslte_vec_u16_malloc(nMax + 1)) == NULL) { + if ((pp->param->code_stage_size = srsran_vec_u16_malloc(nMax + 1)) == NULL) { free(pp->param); free(pp->enc); free(pp); @@ -213,7 +213,7 @@ void* create_polar_decoder_ssc_f(const uint8_t nMax) free(pp); return NULL; } - if ((pp->state->active_node_per_stage = srslte_vec_u16_malloc(nMax + 1)) == NULL) { + if ((pp->state->active_node_per_stage = srsran_vec_u16_malloc(nMax + 1)) == NULL) { free(pp->state); free(pp->param->code_stage_size); free(pp->param); @@ -225,7 +225,7 @@ void* create_polar_decoder_ssc_f(const uint8_t nMax) // allocates memory for estimated bits per stage uint16_t est_bits_size = pp->param->code_stage_size[nMax]; - pp->est_bit = srslte_vec_u8_malloc(est_bits_size); // every 32 chars are aligned + pp->est_bit = srsran_vec_u8_malloc(est_bits_size); // every 32 chars are aligned // allocate memory for LLR pointers. pp->llr0 = malloc((nMax + 1) * sizeof(float*)); @@ -233,7 +233,7 @@ void* create_polar_decoder_ssc_f(const uint8_t nMax) // There are LLR buffers for n = 0 to n = code_size_log. Each with size 2^n. Thus, // the total memory needed is 2^(n+1)-1. - // Only the stages starting at multiples of SRSLTE_AVX2_B_SIZE are aligned. + // Only the stages starting at multiples of SRSRAN_AVX2_B_SIZE are aligned. // Let n_simd_llr be the exponent of the SIMD size in nummer of LLRs. // i.e. in a SIMD instruction we can load 2^(n_simd_llr) LLR values @@ -242,7 +242,7 @@ void* create_polar_decoder_ssc_f(const uint8_t nMax) uint8_t n_llr_all_stages = nMax + 1; // there are 2^(n_llr_all_stages) - 1 LLR values summing up all stages. uint16_t llr_all_stages = 1U << n_llr_all_stages; - pp->llr0[0] = srslte_vec_f_malloc(llr_all_stages); // 32*8=256 + pp->llr0[0] = srsran_vec_f_malloc(llr_all_stages); // 32*8=256 // allocate memory to the polar decoder instance if (pp->llr0[0] == NULL) { @@ -269,7 +269,7 @@ void* create_polar_decoder_ssc_f(const uint8_t nMax) // allocate memory to node_type_ssc. Stage s has 2^(N-s) nodes s=0,...,N. // Thus, same size as LLRs all stages. - pp->param->node_type[0] = srslte_vec_u8_malloc(llr_all_stages); // 32*8=256 + pp->param->node_type[0] = srsran_vec_u8_malloc(llr_all_stages); // 32*8=256 if (pp->param->node_type[0] == NULL) { free(pp->llr0[0]); @@ -370,7 +370,7 @@ static void rate_1_node(void* p, uint8_t* message) pp->hard_bit(LLR, codeword, code_stage_size); if (stage != 0) { - srslte_polar_encoder_encode(pp->enc, codeword, message + bit_pos, stage); + srsran_polar_encoder_encode(pp->enc, codeword, message + bit_pos, stage); } else { message[bit_pos] = codeword[0]; } diff --git a/lib/src/phy/fec/polar/polar_decoder_ssc_f.h b/lib/src/phy/fec/polar/polar_decoder_ssc_f.h index dc6bd22bd..4e958ea30 100644 --- a/lib/src/phy/fec/polar/polar_decoder_ssc_f.h +++ b/lib/src/phy/fec/polar/polar_decoder_ssc_f.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/lib/src/phy/fec/polar/polar_decoder_ssc_s.c b/lib/src/phy/fec/polar/polar_decoder_ssc_s.c index 39fe40c30..7034bc71f 100644 --- a/lib/src/phy/fec/polar/polar_decoder_ssc_s.c +++ b/lib/src/phy/fec/polar/polar_decoder_ssc_s.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -26,16 +26,16 @@ // (1) #include "polar_decoder_ssc_s.h" // (2) the naming of the external function, which finish with _s instead of _f // (3) the initialization of them of the set functions in create_polar_decoder_ssc_s -// pp->f = srslte_vec_function_f_sss; -// pp->g = srslte_vec_function_g_bsss; -// pp->xor = srslte_vec_xor_bbb; -// pp->hard_bit = srslte_vec_hard_bit_sc; +// pp->f = srsran_vec_function_f_sss; +// pp->g = srsran_vec_function_g_bsss; +// pp->xor = srsran_vec_xor_bbb; +// pp->hard_bit = srsran_vec_hard_bit_sc; #include "polar_decoder_ssc_s.h" #include "../utils_avx2.h" #include "polar_decoder_vector.h" -#include "srslte/phy/fec/polar/polar_encoder.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/fec/polar/polar_encoder.h" +#include "srsran/phy/utils/vector.h" /*! * \brief Type indicator for printing LLRs if debugging @@ -52,7 +52,7 @@ struct pSSC_s { struct Params* param; /*!< \brief Pointer to a Params structure. */ struct State* state; /*!< \brief Pointer to a State. */ void* tmp_node_type; /*!< \brief Pointer to a Tmp_node_type. */ - srslte_polar_encoder_t* enc; /*!< \brief Pointer to a srslte_polar_encoder_t. */ + srsran_polar_encoder_t* enc; /*!< \brief Pointer to a srsran_polar_encoder_t. */ void (*f)(const int16_t* x, const int16_t* y, int16_t* z, @@ -95,9 +95,9 @@ static void rate_1_node(void* p, uint8_t* message); /*! * ::RATE_R nodes at stage \f$ s \f$ return the associated \f$2^s\f$ decoded bit by calling * the child nodes to the right and left of the decoding tree and then polar encoding (xor) their output. - * At stage \f$ s \f$, this function runs function srslte_vec_function_f_fff() and srslte_vec_function_g_bfff() + * At stage \f$ s \f$, this function runs function srsran_vec_function_f_fff() and srsran_vec_function_g_bfff() * with vector size \f$2^{ s - 1}\f$ and updates \a llr0 and \a llr1 memory space for stage \f$(s - 1)\f$. - * This function also runs srslte_vec_xor_bbb() with vector size \f$2^{s-1}\f$ and + * This function also runs srsran_vec_xor_bbb() with vector size \f$2^{s-1}\f$ and * updates \a estbits memory space for stage \f$(s + 1)\f$. * */ @@ -174,7 +174,7 @@ void delete_polar_decoder_ssc_s(void* p) free(pp->param); free(pp->state->active_node_per_stage); free(pp->state); - srslte_polar_encoder_free(pp->enc); + srsran_polar_encoder_free(pp->enc); free(pp->enc); // free(pp->frozen_set); // this is not SSC responsibility. delete_tmp_node_type(pp->tmp_node_type); @@ -192,17 +192,17 @@ void* create_polar_decoder_ssc_s(const uint8_t nMax) } // set functions - pp->f = srslte_vec_function_f_sss; - pp->g = srslte_vec_function_g_bsss; - pp->xor = srslte_vec_xor_bbb; - pp->hard_bit = srslte_vec_hard_bit_sc; + pp->f = srsran_vec_function_f_sss; + pp->g = srsran_vec_function_g_bsss; + pp->xor = srsran_vec_xor_bbb; + pp->hard_bit = srsran_vec_hard_bit_sc; // encoder of maximum size - if ((pp->enc = malloc(sizeof(srslte_polar_encoder_t))) == NULL) { + if ((pp->enc = malloc(sizeof(srsran_polar_encoder_t))) == NULL) { free(pp); return NULL; } - srslte_polar_encoder_init(pp->enc, SRSLTE_POLAR_ENCODER_PIPELINED, nMax); + srsran_polar_encoder_init(pp->enc, SRSRAN_POLAR_ENCODER_PIPELINED, nMax); // algorithm constants/parameters if ((pp->param = malloc(sizeof(struct Params))) == NULL) { @@ -211,7 +211,7 @@ void* create_polar_decoder_ssc_s(const uint8_t nMax) return NULL; } - if ((pp->param->code_stage_size = srslte_vec_u16_malloc(nMax + 1)) == NULL) { + if ((pp->param->code_stage_size = srsran_vec_u16_malloc(nMax + 1)) == NULL) { free(pp->param); free(pp->enc); free(pp); @@ -231,7 +231,7 @@ void* create_polar_decoder_ssc_s(const uint8_t nMax) free(pp); return NULL; } - if ((pp->state->active_node_per_stage = srslte_vec_u16_malloc(nMax + 1)) == NULL) { + if ((pp->state->active_node_per_stage = srsran_vec_u16_malloc(nMax + 1)) == NULL) { free(pp->state); free(pp->param->code_stage_size); free(pp->param); @@ -243,7 +243,7 @@ void* create_polar_decoder_ssc_s(const uint8_t nMax) // allocates memory for estimated bits per stage uint16_t est_bits_size = pp->param->code_stage_size[nMax]; - pp->est_bit = srslte_vec_u8_malloc(est_bits_size); // every 32 chars are aligned + pp->est_bit = srsran_vec_u8_malloc(est_bits_size); // every 32 chars are aligned // allocate memory for LLR pointers. pp->llr0 = malloc((nMax + 1) * sizeof(int16_t*)); @@ -251,7 +251,7 @@ void* create_polar_decoder_ssc_s(const uint8_t nMax) // There are LLR buffers for n = 0 to n = code_size_log. Each with size 2^n. Thus, // the total memory needed is 2^(n+1)-1. - // Only the stages starting at multiples of SRSLTE_AVX2_B_SIZE are aligned. + // Only the stages starting at multiples of SRSRAN_AVX2_B_SIZE are aligned. // Let n_simd_llr be the exponent of the SIMD size in nummer of LLRs. // i.e. in a SIMD instruction we can load 2^(n_simd_llr) LLR values @@ -260,7 +260,7 @@ void* create_polar_decoder_ssc_s(const uint8_t nMax) uint8_t n_llr_all_stages = nMax + 1; // there are 2^(n_llr_all_stages) - 1 LLR values summing up all stages. uint16_t llr_all_stages = 1U << n_llr_all_stages; - pp->llr0[0] = srslte_vec_i16_malloc(llr_all_stages); // 32*8=256 + pp->llr0[0] = srsran_vec_i16_malloc(llr_all_stages); // 32*8=256 // allocate memory to the polar decoder instance if (pp->llr0[0] == NULL) { free(pp->est_bit); @@ -284,7 +284,7 @@ void* create_polar_decoder_ssc_s(const uint8_t nMax) // allocate memory to node_type_ssc. Stage s has 2^(N-s) nodes s=0,...,N. // Thus, same size as LLRs all stages. - pp->param->node_type[0] = srslte_vec_u8_malloc(llr_all_stages); // 32*8=256 + pp->param->node_type[0] = srsran_vec_u8_malloc(llr_all_stages); // 32*8=256 if (pp->param->node_type[0] == NULL) { free(pp->param->node_type); @@ -383,7 +383,7 @@ static void rate_1_node(void* p, uint8_t* message) pp->hard_bit(LLR, codeword, code_stage_size); if (stage != 0) { - srslte_polar_encoder_encode(pp->enc, codeword, message + bit_pos, stage); + srsran_polar_encoder_encode(pp->enc, codeword, message + bit_pos, stage); } else { message[bit_pos] = codeword[0]; } diff --git a/lib/src/phy/fec/polar/polar_decoder_ssc_s.h b/lib/src/phy/fec/polar/polar_decoder_ssc_s.h index 3019e7f1c..64eba4ef8 100644 --- a/lib/src/phy/fec/polar/polar_decoder_ssc_s.h +++ b/lib/src/phy/fec/polar/polar_decoder_ssc_s.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/lib/src/phy/fec/polar/polar_decoder_vector.c b/lib/src/phy/fec/polar/polar_decoder_vector.c index fc0e29169..3ea2359cd 100644 --- a/lib/src/phy/fec/polar/polar_decoder_vector.c +++ b/lib/src/phy/fec/polar/polar_decoder_vector.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -51,7 +51,7 @@ static int sgn(float v) } \ } -void srslte_vec_function_f_fff(const float* x, const float* y, float* z, const uint16_t len) +void srsran_vec_function_f_fff(const float* x, const float* y, float* z, const uint16_t len) { float L0 = NAN; float L1 = NAN; @@ -74,7 +74,7 @@ void srslte_vec_function_f_fff(const float* x, const float* y, float* z, const u } } -void srslte_vec_function_f_sss(const int16_t* x, const int16_t* y, int16_t* z, const uint16_t len) +void srsran_vec_function_f_sss(const int16_t* x, const int16_t* y, int16_t* z, const uint16_t len) { int16_t L0 = 0; @@ -98,7 +98,7 @@ void srslte_vec_function_f_sss(const int16_t* x, const int16_t* y, int16_t* z, c } } -void srslte_vec_function_f_ccc(const int8_t* x, const int8_t* y, int8_t* z, const uint16_t len) +void srsran_vec_function_f_ccc(const int8_t* x, const int8_t* y, int8_t* z, const uint16_t len) { int8_t L0 = 0; int8_t L1 = 0; @@ -121,22 +121,22 @@ void srslte_vec_function_f_ccc(const int8_t* x, const int8_t* y, int8_t* z, cons } } -void srslte_vec_hard_bit_fc(const float* x, uint8_t* z, const uint16_t len) +void srsran_vec_hard_bit_fc(const float* x, uint8_t* z, const uint16_t len) { hard_bit; } -void srslte_vec_hard_bit_sc(const int16_t* x, uint8_t* z, const uint16_t len) +void srsran_vec_hard_bit_sc(const int16_t* x, uint8_t* z, const uint16_t len) { hard_bit; } -void srslte_vec_hard_bit_cc(const int8_t* x, uint8_t* z, const uint16_t len) +void srsran_vec_hard_bit_cc(const int8_t* x, uint8_t* z, const uint16_t len) { hard_bit; } -void srslte_vec_function_g_bfff(const uint8_t* b, const float* x, const float* y, float* z, const uint16_t len) +void srsran_vec_function_g_bfff(const uint8_t* b, const float* x, const float* y, float* z, const uint16_t len) { float L0 = NAN; @@ -152,7 +152,7 @@ void srslte_vec_function_g_bfff(const uint8_t* b, const float* x, const float* y } } -void srslte_vec_function_g_bsss(const uint8_t* b, const int16_t* x, const int16_t* y, int16_t* z, const uint16_t len) +void srsran_vec_function_g_bsss(const uint8_t* b, const int16_t* x, const int16_t* y, int16_t* z, const uint16_t len) { int16_t L0 = 0; @@ -179,7 +179,7 @@ void srslte_vec_function_g_bsss(const uint8_t* b, const int16_t* x, const int16_ } } -void srslte_vec_function_g_bccc(const uint8_t* b, const int8_t* x, const int8_t* y, int8_t* z, const uint16_t len) +void srsran_vec_function_g_bccc(const uint8_t* b, const int8_t* x, const int8_t* y, int8_t* z, const uint16_t len) { int8_t L0 = 0; diff --git a/lib/src/phy/fec/polar/polar_decoder_vector.h b/lib/src/phy/fec/polar/polar_decoder_vector.h index aa6bd56f2..4fda4983b 100644 --- a/lib/src/phy/fec/polar/polar_decoder_vector.h +++ b/lib/src/phy/fec/polar/polar_decoder_vector.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -22,7 +22,7 @@ #ifndef POLAR_VECTOR_FUNCTIONS_H #define POLAR_VECTOR_FUNCTIONS_H -#include "srslte/config.h" +#include "srsran/config.h" #include /*! @@ -32,7 +32,7 @@ * \param[out] z A pointer to a vector of floats. * \param[in] len Length of vectors x, y and z. */ -SRSLTE_API void srslte_vec_function_f_fff(const float* x, const float* y, float* z, uint16_t len); +SRSRAN_API void srsran_vec_function_f_fff(const float* x, const float* y, float* z, uint16_t len); /*! * Computes \f$ z = sign(x) \times sign(y) \times \min(abs(x), abs(y)) \f$ elementwise (box-plus operator). @@ -41,7 +41,7 @@ SRSLTE_API void srslte_vec_function_f_fff(const float* x, const float* y, float* * \param[out] z A pointer to a vector of int16_t. * \param[in] len Length of vectors x, y and z. */ -SRSLTE_API void srslte_vec_function_f_sss(const int16_t* x, const int16_t* y, int16_t* z, uint16_t len); +SRSRAN_API void srsran_vec_function_f_sss(const int16_t* x, const int16_t* y, int16_t* z, uint16_t len); /*! * Computes \f$ z = sign(x) \times sign(y) \times \min(abs(x), abs(y)) \f$ elementwise (box-plus operator). @@ -50,7 +50,7 @@ SRSLTE_API void srslte_vec_function_f_sss(const int16_t* x, const int16_t* y, in * \param[out] z A pointer to a vector of int8_t. * \param[in] len Length of vectors x, y and z. */ -SRSLTE_API void srslte_vec_function_f_ccc(const int8_t* x, const int8_t* y, int8_t* z, uint16_t len); +SRSRAN_API void srsran_vec_function_f_ccc(const int8_t* x, const int8_t* y, int8_t* z, uint16_t len); /*! * Returns \f$ z = x + y \f$ if \f$ (b = 1) \f$ and \f$ z= -x + y \f$ if \f$ (b = 0)\f$. @@ -60,7 +60,7 @@ SRSLTE_API void srslte_vec_function_f_ccc(const int8_t* x, const int8_t* y, int8 * \param[out] z A pointer to a vector of floats. * \param[in] len Length of vectors b, x, y and z. */ -SRSLTE_API void srslte_vec_function_g_bfff(const uint8_t* b, const float* x, const float* y, float* z, uint16_t len); +SRSRAN_API void srsran_vec_function_g_bfff(const uint8_t* b, const float* x, const float* y, float* z, uint16_t len); /*! * Returns \f$ z = x + y \f$ if \f$ (b = 1) \f$ and \f$ z= -x + y \f$ if \f$ (b = 0)\f$. @@ -70,8 +70,8 @@ SRSLTE_API void srslte_vec_function_g_bfff(const uint8_t* b, const float* x, con * \param[out] z A pointer to a vector of int16_t. * \param[in] len Length of vectors b, x, y and z. */ -SRSLTE_API void -srslte_vec_function_g_bsss(const uint8_t* b, const int16_t* x, const int16_t* y, int16_t* z, uint16_t len); +SRSRAN_API void +srsran_vec_function_g_bsss(const uint8_t* b, const int16_t* x, const int16_t* y, int16_t* z, uint16_t len); /*! * Returns \f$ z = x + y \f$ if \f$ (b = 1) \f$ and \f$ z= -x + y \f$ if \f$ (b = 0)\f$. @@ -81,7 +81,7 @@ srslte_vec_function_g_bsss(const uint8_t* b, const int16_t* x, const int16_t* y, * \param[out] z A pointer to a vector of int8_t. * \param[in] len Length of vectors b, x, y and z. */ -SRSLTE_API void srslte_vec_function_g_bccc(const uint8_t* b, const int8_t* x, const int8_t* y, int8_t* z, uint16_t len); +SRSRAN_API void srsran_vec_function_g_bccc(const uint8_t* b, const int8_t* x, const int8_t* y, int8_t* z, uint16_t len); /*! * Returns 1 if \f$ (x < 0) \f$ and 0 if \f$ (x >= 0) \f$. @@ -89,7 +89,7 @@ SRSLTE_API void srslte_vec_function_g_bccc(const uint8_t* b, const int8_t* x, co * \param[out] z A pointer to a vector of uint8_t with 0's and 1's. * \param[in] len Length of vectors x and z. */ -SRSLTE_API void srslte_vec_hard_bit_fc(const float* x, uint8_t* z, uint16_t len); +SRSRAN_API void srsran_vec_hard_bit_fc(const float* x, uint8_t* z, uint16_t len); /*! * Returns 1 if \f$ (x < 0) \f$ and 0 if \f$ (x >= 0) \f$. @@ -97,7 +97,7 @@ SRSLTE_API void srslte_vec_hard_bit_fc(const float* x, uint8_t* z, uint16_t len) * \param[out] z A pointer to a vector of uint8_t with 0's and 1's. * \param[in] len Length of vectors x and z. */ -SRSLTE_API void srslte_vec_hard_bit_sc(const int16_t* x, uint8_t* z, uint16_t len); +SRSRAN_API void srsran_vec_hard_bit_sc(const int16_t* x, uint8_t* z, uint16_t len); /*! * Returns 1 if \f$ (x < 0) \f$ and 0 if \f$ (x >= 0) \f$. @@ -105,6 +105,6 @@ SRSLTE_API void srslte_vec_hard_bit_sc(const int16_t* x, uint8_t* z, uint16_t le * \param[out] z A pointer to a vector of uint8_t with 0's and 1's. * \param[in] len Length of vectors x and z. */ -SRSLTE_API void srslte_vec_hard_bit_cc(const int8_t* x, uint8_t* z, uint16_t len); +SRSRAN_API void srsran_vec_hard_bit_cc(const int8_t* x, uint8_t* z, uint16_t len); #endif // POLAR_VECTOR_FUNCTIONS_H diff --git a/lib/src/phy/fec/polar/polar_decoder_vector_avx2.c b/lib/src/phy/fec/polar/polar_decoder_vector_avx2.c index ea889c0ef..3d2b64db8 100644 --- a/lib/src/phy/fec/polar/polar_decoder_vector_avx2.c +++ b/lib/src/phy/fec/polar/polar_decoder_vector_avx2.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -39,10 +39,10 @@ // General remarks // We replace bits by {0, 128} (uint8_t) or {0, -128} (int8_t) -void srslte_vec_function_f_ccc_avx2(const int8_t* x, const int8_t* y, int8_t* z, const uint16_t len) +void srsran_vec_function_f_ccc_avx2(const int8_t* x, const int8_t* y, int8_t* z, const uint16_t len) { - for (int i = 0; i < len; i += SRSLTE_AVX2_B_SIZE) { + for (int i = 0; i < len; i += SRSRAN_AVX2_B_SIZE) { __m256i m_x = _mm256_loadu_si256((__m256i*)&x[i]); __m256i m_y = _mm256_loadu_si256((__m256i*)&y[i]); @@ -56,13 +56,13 @@ void srslte_vec_function_f_ccc_avx2(const int8_t* x, const int8_t* y, int8_t* z, } } -void srslte_vec_function_g_bccc_avx2(const uint8_t* b, const int8_t* x, const int8_t* y, int8_t* z, const uint16_t len) +void srsran_vec_function_g_bccc_avx2(const uint8_t* b, const int8_t* x, const int8_t* y, int8_t* z, const uint16_t len) { const __m256i M_1 = _mm256_set1_epi8(1); const __m256i M_NEG127 = _mm256_set1_epi8(-127); - for (int i = 0; i < len; i += SRSLTE_AVX2_B_SIZE) { + for (int i = 0; i < len; i += SRSRAN_AVX2_B_SIZE) { __m256i m_x = _mm256_loadu_si256((__m256i*)&x[i]); __m256i m_y = _mm256_loadu_si256((__m256i*)&y[i]); @@ -78,10 +78,10 @@ void srslte_vec_function_g_bccc_avx2(const uint8_t* b, const int8_t* x, const in } } -void srslte_vec_xor_bbb_avx2(const uint8_t* x, const uint8_t* y, uint8_t* z, uint16_t len) +void srsran_vec_xor_bbb_avx2(const uint8_t* x, const uint8_t* y, uint8_t* z, uint16_t len) { - for (int i = 0; i < len; i += SRSLTE_AVX2_B_SIZE) { + for (int i = 0; i < len; i += SRSRAN_AVX2_B_SIZE) { __m256i m_x = _mm256_loadu_si256((__m256i*)&x[i]); __m256i m_y = _mm256_loadu_si256((__m256i*)&y[i]); @@ -91,27 +91,27 @@ void srslte_vec_xor_bbb_avx2(const uint8_t* x, const uint8_t* y, uint8_t* z, uin } } -void srslte_vec_hard_bit_cc_avx2(const int8_t* x, uint8_t* z, const uint16_t len) +void srsran_vec_hard_bit_cc_avx2(const int8_t* x, uint8_t* z, const uint16_t len) { const __m256i M_MSB_MASK = _mm256_set1_epi8(MSB_MASK); - for (int i = 0; i < len; i += SRSLTE_AVX2_B_SIZE) { + for (int i = 0; i < len; i += SRSRAN_AVX2_B_SIZE) { __m256i m_x = _mm256_loadu_si256((__m256i*)&x[i]); __m256i m_z = _mm256_and_si256(m_x, M_MSB_MASK); _mm256_storeu_si256((__m256i*)&z[i], m_z); } - // restore, by setting to 0, the memory positions between z + len and z + len + SRSLTE_AVX2_B_SIZE - memset(z + len, 0, SRSLTE_AVX2_B_SIZE); + // restore, by setting to 0, the memory positions between z + len and z + len + SRSRAN_AVX2_B_SIZE + memset(z + len, 0, SRSRAN_AVX2_B_SIZE); } -void srslte_vec_sign_to_bit_c_avx2(uint8_t* x, uint16_t len) +void srsran_vec_sign_to_bit_c_avx2(uint8_t* x, uint16_t len) { const __m256i M_NEG1 = _mm256_set1_epi8(-1); int i = 0; - for (; i < len - SRSLTE_AVX2_B_SIZE + 1; i += SRSLTE_AVX2_B_SIZE) { + for (; i < len - SRSRAN_AVX2_B_SIZE + 1; i += SRSRAN_AVX2_B_SIZE) { __m256i m_x = _mm256_loadu_si256((__m256i*)&x[i]); __m256i m_abs_x = _mm256_sign_epi8(M_NEG1, m_x); diff --git a/lib/src/phy/fec/polar/polar_decoder_vector_avx2.h b/lib/src/phy/fec/polar/polar_decoder_vector_avx2.h index 1a4651862..23a15307c 100644 --- a/lib/src/phy/fec/polar/polar_decoder_vector_avx2.h +++ b/lib/src/phy/fec/polar/polar_decoder_vector_avx2.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -23,58 +23,58 @@ #ifndef POLAR_VECTOR_FUNCTIONS_AVX2_H #define POLAR_VECTOR_FUNCTIONS_AVX2_H #include "../utils_avx2.h" -#include "srslte/config.h" +#include "srsran/config.h" #include /*! * Transforms input uint8_t bits represented by {0, 128} to {0, 1} with AVX2 instructions, - * the output must have size larger than \ref SRSLTE_AVX2_B_SIZE. + * the output must have size larger than \ref SRSRAN_AVX2_B_SIZE. * Specifically, the function returns 0 if x=0 and 1 if x<0, otherwise the output is not defined. * \param[in, out] x A pointer to a vector of uint8_t. * \param[in] len Length of vectors x, y and z. */ -SRSLTE_API void srslte_vec_sign_to_bit_c_avx2(uint8_t* x, uint16_t len); +SRSRAN_API void srsran_vec_sign_to_bit_c_avx2(uint8_t* x, uint16_t len); /*! * Computes \f$ z = sign(x) \times sign(y) \times \min(abs(x), abs(y)) \f$ elementwise * (box-plus operator) with AVX2 instructions, - * the output must have size larger than \ref SRSLTE_AVX2_B_SIZE. + * the output must have size larger than \ref SRSRAN_AVX2_B_SIZE. * \param[in] x A pointer to a vector of int8_t. * \param[in] y A pointer to a vector of int8_t. * \param[out] z A pointer to a vector of int8_t. * \param[in] len Length of vectors x, y and z. */ -SRSLTE_API void srslte_vec_function_f_ccc_avx2(const int8_t* x, const int8_t* y, int8_t* z, uint16_t len); +SRSRAN_API void srsran_vec_function_f_ccc_avx2(const int8_t* x, const int8_t* y, int8_t* z, uint16_t len); /*! * Returns \f$ z = x + y \f$ if \f$ (b = 1) \f$ and \f$ z= -x + y \f$ if \f$ (b = 0)\f$ with AVX2 instructions, - * the output must have size larger than \ref SRSLTE_AVX2_B_SIZE. + * the output must have size larger than \ref SRSRAN_AVX2_B_SIZE. * \param[in] b A pointer to a vectors of uint8_t with 0's and 1's. * \param[in] x A pointer to a vector of int8_t. * \param[in] y A pointer to a vector of int8_t. * \param[out] z A pointer to a vector of int8_t. * \param[in] len Length of vectors b, x, y and z. */ -SRSLTE_API void -srslte_vec_function_g_bccc_avx2(const uint8_t* b, const int8_t* x, const int8_t* y, int8_t* z, uint16_t len); +SRSRAN_API void +srsran_vec_function_g_bccc_avx2(const uint8_t* b, const int8_t* x, const int8_t* y, int8_t* z, uint16_t len); /*! * Computes \f$ z = x \oplus y \f$ elementwise with AVX2 instructions, - * the output must have size larger than \ref SRSLTE_AVX2_B_SIZE. + * the output must have size larger than \ref SRSRAN_AVX2_B_SIZE. * \param[in] x A pointer to a vector of uint8_t with 0's and 1's. * \param[in] y A pointer to a vector of uint8_t with 0's and 1's. * \param[out] z A pointer to a vector of uint8_t with 0's and 1's. * \param[in] len Length of vectors x, y and z. */ -SRSLTE_API void srslte_vec_xor_bbb_avx2(const uint8_t* x, const uint8_t* y, uint8_t* z, uint16_t len); +SRSRAN_API void srsran_vec_xor_bbb_avx2(const uint8_t* x, const uint8_t* y, uint8_t* z, uint16_t len); /*! * Returns 1 if \f$ (x < 0) \f$ and 0 if \f$ (x >= 0) \f$ with AVX2 instructions, - * the output must have size larger that \ref SRSLTE_AVX2_B_SIZE. + * the output must have size larger that \ref SRSRAN_AVX2_B_SIZE. * \param[in] x A pointer to a vector of int8_t. * \param[out] z A pointer to a vector of uint8_t with 0's and 1's. * \param[in] len Length of vectors x and z. */ -SRSLTE_API void srslte_vec_hard_bit_cc_avx2(const int8_t* x, uint8_t* z, uint16_t len); +SRSRAN_API void srsran_vec_hard_bit_cc_avx2(const int8_t* x, uint8_t* z, uint16_t len); #endif // POLAR_VECTOR_FUNCTIONS_H diff --git a/lib/src/phy/fec/polar/polar_encoder.c b/lib/src/phy/fec/polar/polar_encoder.c index a36f6e38d..52fe3a30e 100644 --- a/lib/src/phy/fec/polar/polar_encoder.c +++ b/lib/src/phy/fec/polar/polar_encoder.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -21,7 +21,7 @@ * 5G uses a polar encoder with maximum sizes \f$2^n\f$ with \f$n = 5,...,10\f$. * */ -#include "srslte/phy/fec/polar/polar_encoder.h" +#include "srsran/phy/fec/polar/polar_encoder.h" #include "polar_encoder_avx2.h" #include "polar_encoder_pipelined.h" #include @@ -35,7 +35,7 @@ /*! AVX2 polar encoder */ static int encode_avx2(void* o, const uint8_t* input, uint8_t* output, const uint8_t code_size_log) { - srslte_polar_encoder_t* q = o; + srsran_polar_encoder_t* q = o; polar_encoder_encode_avx2(q->ptr, input, output, code_size_log); return 0; @@ -44,12 +44,12 @@ static int encode_avx2(void* o, const uint8_t* input, uint8_t* output, const uin /*! Carries out the actual destruction of the memory allocated to the AVX2 encoder. */ static void free_avx2(void* o) { - srslte_polar_encoder_t* q = o; + srsran_polar_encoder_t* q = o; delete_polar_encoder_avx2(q->ptr); } /*! Initializes a polar encoder structure to use the AVX2 polar encoder algorithm*/ -static int init_avx2(srslte_polar_encoder_t* q, const uint8_t code_size_log) +static int init_avx2(srsran_polar_encoder_t* q, const uint8_t code_size_log) { q->encode = encode_avx2; q->free = free_avx2; @@ -64,7 +64,7 @@ static int init_avx2(srslte_polar_encoder_t* q, const uint8_t code_size_log) /*! Pipelined polar encoder */ static int encode_pipelined(void* o, const uint8_t* input, uint8_t* output, const uint8_t code_size_log) { - srslte_polar_encoder_t* q = o; + srsran_polar_encoder_t* q = o; polar_encoder_encode_pipelined(q->ptr, input, output, code_size_log); return 0; @@ -73,12 +73,12 @@ static int encode_pipelined(void* o, const uint8_t* input, uint8_t* output, cons /*! Carries out the actual destruction of the memory allocated to the pipelined encoder. */ static void free_pipelined(void* o) { - srslte_polar_encoder_t* q = o; + srsran_polar_encoder_t* q = o; delete_polar_encoder_pipelined(q->ptr); } /*! Initializes a polar encoder structure to use the pipeline polar encoder algorithm*/ -static int init_pipelined(srslte_polar_encoder_t* q, const uint8_t code_size_log) +static int init_pipelined(srsran_polar_encoder_t* q, const uint8_t code_size_log) { q->encode = encode_pipelined; q->free = free_pipelined; @@ -89,13 +89,13 @@ static int init_pipelined(srslte_polar_encoder_t* q, const uint8_t code_size_log return 0; } -int srslte_polar_encoder_init(srslte_polar_encoder_t* q, srslte_polar_encoder_type_t type, const uint8_t code_size_log) +int srsran_polar_encoder_init(srsran_polar_encoder_t* q, srsran_polar_encoder_type_t type, const uint8_t code_size_log) { switch (type) { // NOLINT - case SRSLTE_POLAR_ENCODER_PIPELINED: + case SRSRAN_POLAR_ENCODER_PIPELINED: return init_pipelined(q, code_size_log); #ifdef LV_HAVE_AVX2 - case SRSLTE_POLAR_ENCODER_AVX2: + case SRSRAN_POLAR_ENCODER_AVX2: return init_avx2(q, code_size_log); #endif // LV_HAVE_AVX2 default: @@ -104,15 +104,15 @@ int srslte_polar_encoder_init(srslte_polar_encoder_t* q, srslte_polar_encoder_ty return 0; } -void srslte_polar_encoder_free(srslte_polar_encoder_t* q) +void srsran_polar_encoder_free(srsran_polar_encoder_t* q) { if (q->free) { q->free(q); } - memset(q, 0, sizeof(srslte_polar_encoder_t)); + memset(q, 0, sizeof(srsran_polar_encoder_t)); } -int srslte_polar_encoder_encode(srslte_polar_encoder_t* q, +int srsran_polar_encoder_encode(srsran_polar_encoder_t* q, const uint8_t* input, uint8_t* output, const uint8_t code_size_log) diff --git a/lib/src/phy/fec/polar/polar_encoder_avx2.c b/lib/src/phy/fec/polar/polar_encoder_avx2.c index 8474d31bb..8443ad8e1 100644 --- a/lib/src/phy/fec/polar/polar_encoder_avx2.c +++ b/lib/src/phy/fec/polar/polar_encoder_avx2.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -23,7 +23,7 @@ */ #include "../utils_avx2.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/utils/vector.h" #include #include #include @@ -66,10 +66,10 @@ void* create_polar_encoder_avx2(const uint8_t code_size_log) uint16_t code_size = 1U << code_size_log; - if (code_size_log > SRSLTE_AVX2_B_SIZE_LOG) { - q->tmp = srslte_vec_u8_malloc(code_size); + if (code_size_log > SRSRAN_AVX2_B_SIZE_LOG) { + q->tmp = srsran_vec_u8_malloc(code_size); } else { - q->tmp = srslte_vec_u8_malloc(SRSLTE_AVX2_B_SIZE); + q->tmp = srsran_vec_u8_malloc(SRSRAN_AVX2_B_SIZE); } if (!q->tmp) { free(q); @@ -85,7 +85,7 @@ void* create_polar_encoder_avx2(const uint8_t code_size_log) /*! * Runs, in parallel, \f$ 2^{5-stage}\f$ polar encoders of size \f$ 2^{stage} \f$ each for s=1 to 5. */ -static inline void srslte_vec_polar_encoder_32_avx2(const uint8_t* x, uint8_t* z, uint8_t stage) +static inline void srsran_vec_polar_encoder_32_avx2(const uint8_t* x, uint8_t* z, uint8_t stage) { const __m256i MZERO = _mm256_set1_epi8(0); @@ -118,10 +118,10 @@ static inline void srslte_vec_polar_encoder_32_avx2(const uint8_t* x, uint8_t* z /*! * Computes \f$ z = x \oplus y \f$ elementwise with AVX2 instructions. */ -static inline void srslte_vec_xor_bbb_avx2(const uint8_t* x, const uint8_t* y, uint8_t* z, uint16_t len) +static inline void srsran_vec_xor_bbb_avx2(const uint8_t* x, const uint8_t* y, uint8_t* z, uint16_t len) { - for (int i = 0; i < len; i += SRSLTE_AVX2_B_SIZE) { + for (int i = 0; i < len; i += SRSRAN_AVX2_B_SIZE) { __m256i simd_x = _mm256_loadu_si256((__m256i*)&x[i]); __m256i simd_y = _mm256_loadu_si256((__m256i*)&y[i]); @@ -160,7 +160,7 @@ int polar_encoder_encode_avx2(void* p, const uint8_t* input, uint8_t* output, co uint32_t code_half_size_stage = 0; uint32_t num_blocks = 0; uint32_t s = code_size_log; - for (; s > SRSLTE_AVX2_B_SIZE_LOG; s--) { + for (; s > SRSRAN_AVX2_B_SIZE_LOG; s--) { code_size_stage = 1U << s; code_half_size_stage = 1U << (s - 1); num_blocks = 1U << (code_size_log - s); @@ -169,19 +169,19 @@ int polar_encoder_encode_avx2(void* p, const uint8_t* input, uint8_t* output, co x = &tmp[b * code_size_stage]; y = x + code_half_size_stage; z = x; - srslte_vec_xor_bbb_avx2(x, y, z, code_half_size_stage); + srsran_vec_xor_bbb_avx2(x, y, z, code_half_size_stage); } } uint32_t num_simd_size_blocks = 1; - if (code_size_log > SRSLTE_AVX2_B_SIZE_LOG) { - num_simd_size_blocks = 1U << (code_size_log - SRSLTE_AVX2_B_SIZE_LOG); + if (code_size_log > SRSRAN_AVX2_B_SIZE_LOG) { + num_simd_size_blocks = 1U << (code_size_log - SRSRAN_AVX2_B_SIZE_LOG); } for (uint32_t b = 0; b < num_simd_size_blocks; b++) { - x = &tmp[b * SRSLTE_AVX2_B_SIZE]; + x = &tmp[b * SRSRAN_AVX2_B_SIZE]; z = x; - srslte_vec_polar_encoder_32_avx2(x, z, s); + srsran_vec_polar_encoder_32_avx2(x, z, s); } memcpy(output, tmp, code_size * sizeof(uint8_t)); diff --git a/lib/src/phy/fec/polar/polar_encoder_avx2.h b/lib/src/phy/fec/polar/polar_encoder_avx2.h index 05d4f940c..691a744f4 100644 --- a/lib/src/phy/fec/polar/polar_encoder_avx2.h +++ b/lib/src/phy/fec/polar/polar_encoder_avx2.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -37,7 +37,7 @@ void delete_polar_encoder_avx2(void* p); * \param[in] input The encoder input vector. * \param[out] output The encoder output vector. * \param[in] code_size_log The \f$ log_2\f$ of the number of bits of the encoder input/output vector. - * It can less or equal to the maximum code_size_log specified in q.code_size_log of the srslte_polar_encoder_t + * It can less or equal to the maximum code_size_log specified in q.code_size_log of the srsran_polar_encoder_t * structure \return An integer: 0 if the function executes correctly, -1 otherwise. */ int polar_encoder_encode_avx2(void* p, const uint8_t* input, uint8_t* output, uint8_t code_size_log); diff --git a/lib/src/phy/fec/polar/polar_encoder_pipelined.c b/lib/src/phy/fec/polar/polar_encoder_pipelined.c index 7284c2c42..eb071b2c3 100644 --- a/lib/src/phy/fec/polar/polar_encoder_pipelined.c +++ b/lib/src/phy/fec/polar/polar_encoder_pipelined.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -25,8 +25,8 @@ * */ -#include "srslte/phy/fec/polar/polar_encoder.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/fec/polar/polar_encoder.h" +#include "srsran/phy/utils/vector.h" #include #include #include @@ -72,14 +72,14 @@ void* create_polar_encoder_pipelined(const uint8_t code_size_log) uint16_t code_size = 1U << code_size_log; uint16_t code_half_size = code_size / 2; - q->i_odd = srslte_vec_u16_malloc(code_half_size); + q->i_odd = srsran_vec_u16_malloc(code_half_size); if (!q->i_odd) { free(q); perror("malloc"); return NULL; } - q->i_even = srslte_vec_u16_malloc(code_half_size); + q->i_even = srsran_vec_u16_malloc(code_half_size); if (!q->i_even) { free(q->i_odd); free(q); @@ -87,7 +87,7 @@ void* create_polar_encoder_pipelined(const uint8_t code_size_log) return NULL; } - q->tmp = srslte_vec_u8_malloc(code_size); + q->tmp = srsran_vec_u8_malloc(code_size); if (!q->tmp) { free(q->i_even); free(q->i_odd); diff --git a/lib/src/phy/fec/polar/polar_encoder_pipelined.h b/lib/src/phy/fec/polar/polar_encoder_pipelined.h index 4bfb2bb3e..4bef93cdf 100644 --- a/lib/src/phy/fec/polar/polar_encoder_pipelined.h +++ b/lib/src/phy/fec/polar/polar_encoder_pipelined.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -37,7 +37,7 @@ void delete_polar_encoder_pipelined(void* p); * \param[in] input The encoder input vector. * \param[out] output The encoder output vector. * \param[in] code_size_log The \f$\log_2\f$ of the number of bits of the encoder input/output vector. - * It can less or equal to the maximum code_size_log specified in q.code_size_log of the srslte_polar_encoder_t + * It can less or equal to the maximum code_size_log specified in q.code_size_log of the srsran_polar_encoder_t * structure \return An integer: 0 if the function executes correctly, -1 otherwise. */ int polar_encoder_encode_pipelined(void* p, const uint8_t* input, uint8_t* output, uint8_t code_size_log); diff --git a/lib/src/phy/fec/polar/polar_interleaver.c b/lib/src/phy/fec/polar/polar_interleaver.c index af6041690..27475ae3c 100644 --- a/lib/src/phy/fec/polar/polar_interleaver.c +++ b/lib/src/phy/fec/polar/polar_interleaver.c @@ -1,8 +1,8 @@ /** * - * section COPYRIGHT + * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,13 +10,13 @@ * */ -#include "srslte/phy/fec/polar/polar_interleaver.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/fec/polar/polar_interleaver.h" +#include "srsran/phy/utils/vector.h" #include #include // Table 5.3.1.1-1: Interleaving pattern -static const uint16_t polar_interleaver_pattern[SRSLTE_POLAR_INTERLEAVER_K_MAX_IL] = { +static const uint16_t polar_interleaver_pattern[SRSRAN_POLAR_INTERLEAVER_K_MAX_IL] = { 0, 2, 4, 7, 9, 14, 19, 20, 24, 25, 26, 28, 31, 34, 42, 45, 49, 50, 51, 53, 54, 56, 58, 59, 61, 62, 65, 66, 67, 69, 70, 71, 72, 76, 77, 81, 82, 83, 87, 88, 89, 91, 93, 95, 98, 101, 104, 106, 108, 110, 111, 113, 115, 118, 119, 120, 122, 123, 126, 127, 129, 132, 134, @@ -26,7 +26,7 @@ static const uint16_t polar_interleaver_pattern[SRSLTE_POLAR_INTERLEAVER_K_MAX_I 136, 142, 12, 17, 23, 37, 48, 75, 80, 86, 137, 143, 13, 18, 38, 144, 39, 145, 40, 146, 41, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163}; -void srslte_polar_interleaver_run(const void* in, void* out, uint32_t S, uint32_t K, bool dir) +void srsran_polar_interleaver_run(const void* in, void* out, uint32_t S, uint32_t K, bool dir) { if (in == NULL || out == NULL) { return; @@ -36,9 +36,9 @@ void srslte_polar_interleaver_run(const void* in, void* out, uint32_t S, uint32_ uint8_t* out_ptr = (uint8_t*)out; uint32_t k = 0; - for (uint32_t m = 0; m < SRSLTE_POLAR_INTERLEAVER_K_MAX_IL; m++) { - if (polar_interleaver_pattern[m] >= SRSLTE_POLAR_INTERLEAVER_K_MAX_IL - K) { - uint32_t pi_k = polar_interleaver_pattern[m] - (SRSLTE_POLAR_INTERLEAVER_K_MAX_IL - K); + for (uint32_t m = 0; m < SRSRAN_POLAR_INTERLEAVER_K_MAX_IL; m++) { + if (polar_interleaver_pattern[m] >= SRSRAN_POLAR_INTERLEAVER_K_MAX_IL - K) { + uint32_t pi_k = polar_interleaver_pattern[m] - (SRSRAN_POLAR_INTERLEAVER_K_MAX_IL - K); if (dir) { memcpy(out_ptr + S * k, in_ptr + S * pi_k, S); } else { diff --git a/lib/src/phy/fec/polar/polar_rm.c b/lib/src/phy/fec/polar/polar_rm.c index c988960c5..b22b64cbf 100644 --- a/lib/src/phy/fec/polar/polar_rm.c +++ b/lib/src/phy/fec/polar/polar_rm.c @@ -1,8 +1,8 @@ /** * - * section COPYRIGHT + * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -20,14 +20,14 @@ * */ -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/utils/vector.h" #include #include -#include "srslte/phy/fec/polar/polar_code.h" -#include "srslte/phy/fec/polar/polar_rm.h" +#include "srsran/phy/fec/polar/polar_code.h" +#include "srsran/phy/fec/polar/polar_rm.h" -#include "srslte/phy/utils/debug.h" +#include "srsran/phy/utils/debug.h" /*! * \brief Describes an rate matcher. @@ -356,7 +356,7 @@ static void ch_interleaver_rm_rx_c(const int8_t* f, int8_t* e, const uint32_t E) } } -int srslte_polar_rm_tx_init(srslte_polar_rm_t* p) +int srsran_polar_rm_tx_init(srsran_polar_rm_t* p) { if (p == NULL) { return -1; @@ -371,14 +371,14 @@ int srslte_polar_rm_tx_init(srslte_polar_rm_t* p) p->ptr = pp; // allocate memory to the blk interleaved codeword - if ((pp->y_e = srslte_vec_u8_malloc(EMAX)) == NULL) { + if ((pp->y_e = srsran_vec_u8_malloc(EMAX)) == NULL) { free(pp); return -1; } return 0; } -int srslte_polar_rm_rx_init_f(srslte_polar_rm_t* p) +int srsran_polar_rm_rx_init_f(srsran_polar_rm_t* p) { if (p == NULL) { @@ -394,7 +394,7 @@ int srslte_polar_rm_rx_init_f(srslte_polar_rm_t* p) p->ptr = pp; // allocate memory to the temporal buffer of chDeInterleaved llrs - if ((pp->y_e = srslte_vec_f_malloc(EMAX + NMAX)) == NULL) { + if ((pp->y_e = srsran_vec_f_malloc(EMAX + NMAX)) == NULL) { free(pp); return -1; } @@ -403,7 +403,7 @@ int srslte_polar_rm_rx_init_f(srslte_polar_rm_t* p) return 0; } -int srslte_polar_rm_rx_init_s(srslte_polar_rm_t* p) +int srsran_polar_rm_rx_init_s(srsran_polar_rm_t* p) { if (p == NULL) { @@ -419,7 +419,7 @@ int srslte_polar_rm_rx_init_s(srslte_polar_rm_t* p) p->ptr = pp; // allocate memory to the temporal buffer of chDeInterleaved llrs - if ((pp->y_e = srslte_vec_i16_malloc(EMAX + NMAX)) == NULL) { + if ((pp->y_e = srsran_vec_i16_malloc(EMAX + NMAX)) == NULL) { free(pp); return -1; } @@ -428,7 +428,7 @@ int srslte_polar_rm_rx_init_s(srslte_polar_rm_t* p) return 0; } -int srslte_polar_rm_rx_init_c(srslte_polar_rm_t* p) +int srsran_polar_rm_rx_init_c(srsran_polar_rm_t* p) { if (p == NULL) { @@ -444,7 +444,7 @@ int srslte_polar_rm_rx_init_c(srslte_polar_rm_t* p) p->ptr = pp; // allocate memory to the temporal buffer of chDeInterleaved llrs - if ((pp->y_e = srslte_vec_i8_malloc(EMAX + NMAX)) == NULL) { + if ((pp->y_e = srsran_vec_i8_malloc(EMAX + NMAX)) == NULL) { free(pp); return -1; } @@ -453,7 +453,7 @@ int srslte_polar_rm_rx_init_c(srslte_polar_rm_t* p) return 0; } -void srslte_polar_rm_tx_free(srslte_polar_rm_t* q) +void srsran_polar_rm_tx_free(srsran_polar_rm_t* q) { if (q != NULL) { struct pRM_tx* qq = q->ptr; @@ -462,7 +462,7 @@ void srslte_polar_rm_tx_free(srslte_polar_rm_t* q) } } -void srslte_polar_rm_rx_free_f(srslte_polar_rm_t* q) +void srsran_polar_rm_rx_free_f(srsran_polar_rm_t* q) { if (q != NULL) { struct pRM_rx_f* qq = q->ptr; @@ -472,7 +472,7 @@ void srslte_polar_rm_rx_free_f(srslte_polar_rm_t* q) } } -void srslte_polar_rm_rx_free_s(srslte_polar_rm_t* q) +void srsran_polar_rm_rx_free_s(srsran_polar_rm_t* q) { if (q != NULL) { struct pRM_rx_s* qq = q->ptr; @@ -482,7 +482,7 @@ void srslte_polar_rm_rx_free_s(srslte_polar_rm_t* q) } } -void srslte_polar_rm_rx_free_c(srslte_polar_rm_t* q) +void srsran_polar_rm_rx_free_c(srsran_polar_rm_t* q) { if (q != NULL) { struct pRM_rx_c* qq = q->ptr; @@ -492,7 +492,7 @@ void srslte_polar_rm_rx_free_c(srslte_polar_rm_t* q) } } -int srslte_polar_rm_tx(srslte_polar_rm_t* q, +int srsran_polar_rm_tx(srsran_polar_rm_t* q, const uint8_t* input, uint8_t* output, const uint8_t n, @@ -521,7 +521,7 @@ int srslte_polar_rm_tx(srslte_polar_rm_t* q, return 0; } -int srslte_polar_rm_rx_f(srslte_polar_rm_t* q, +int srsran_polar_rm_rx_f(srsran_polar_rm_t* q, const float* input, float* output, const uint32_t E, @@ -549,7 +549,7 @@ int srslte_polar_rm_rx_f(srslte_polar_rm_t* q, return 0; } -int srslte_polar_rm_rx_s(srslte_polar_rm_t* q, +int srsran_polar_rm_rx_s(srsran_polar_rm_t* q, const int16_t* input, int16_t* output, const uint32_t E, @@ -577,7 +577,7 @@ int srslte_polar_rm_rx_s(srslte_polar_rm_t* q, return 0; } -int srslte_polar_rm_rx_c(srslte_polar_rm_t* q, +int srsran_polar_rm_rx_c(srsran_polar_rm_t* q, const int8_t* input, int8_t* output, const uint32_t E, diff --git a/lib/src/phy/fec/polar/test/CMakeLists.txt b/lib/src/phy/fec/polar/test/CMakeLists.txt index 9f992fb2d..299266e94 100644 --- a/lib/src/phy/fec/polar/test/CMakeLists.txt +++ b/lib/src/phy/fec/polar/test/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -12,7 +12,7 @@ add_library(polar_test_utils polar_sets.c subchannel_allocation.c) add_executable(polar_chain_test polar_chain_test.c) -target_link_libraries(polar_chain_test srslte_phy polar_test_utils) +target_link_libraries(polar_chain_test srsran_phy polar_test_utils) ### Test polar libs function(polar_tests_lite) @@ -91,5 +91,5 @@ polar_tests(101) # Polar inter-leaver test add_executable(polar_interleaver_test polar_interleaver_test.c) -target_link_libraries(polar_interleaver_test srslte_phy) +target_link_libraries(polar_interleaver_test srsran_phy) add_nr_test(polar_interleaver_test polar_interleaver_test) diff --git a/lib/src/phy/fec/polar/test/polar_chain_test.c b/lib/src/phy/fec/polar/test/polar_chain_test.c index 27ef750a8..7fe0dd490 100644 --- a/lib/src/phy/fec/polar/test/polar_chain_test.c +++ b/lib/src/phy/fec/polar/test/polar_chain_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -51,13 +51,13 @@ #include "math.h" -#include "srslte/phy/channel/ch_awgn.h" -#include "srslte/phy/common/timestamp.h" -#include "srslte/phy/utils/bit.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/phy_logger.h" -#include "srslte/phy/utils/random.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/channel/ch_awgn.h" +#include "srsran/phy/common/timestamp.h" +#include "srsran/phy/utils/bit.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/phy_logger.h" +#include "srsran/phy/utils/random.h" +#include "srsran/phy/utils/vector.h" #include #include @@ -66,14 +66,14 @@ #include // utils lib -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/utils/vector.h" // polar libs -#include "srslte/phy/fec/polar/polar_chanalloc.h" -#include "srslte/phy/fec/polar/polar_code.h" -#include "srslte/phy/fec/polar/polar_decoder.h" -#include "srslte/phy/fec/polar/polar_encoder.h" -#include "srslte/phy/fec/polar/polar_rm.h" +#include "srsran/phy/fec/polar/polar_chanalloc.h" +#include "srsran/phy/fec/polar/polar_code.h" +#include "srsran/phy/fec/polar/polar_decoder.h" +#include "srsran/phy/fec/polar/polar_encoder.h" +#include "srsran/phy/fec/polar/polar_rm.h" //#define debug //#define DATA_ALL_ONES @@ -216,90 +216,90 @@ int main(int argc, char** argv) float gain_c_avx2 = NAN; #endif - srslte_polar_code_t code; - srslte_polar_encoder_t enc; - srslte_polar_decoder_t dec; - srslte_polar_decoder_t dec_s; // 16-bit - srslte_polar_decoder_t dec_c; // 8-bit - srslte_polar_rm_t rm_tx; - srslte_polar_rm_t rm_rx_f; - srslte_polar_rm_t rm_rx_s; - srslte_polar_rm_t rm_rx_c; + srsran_polar_code_t code; + srsran_polar_encoder_t enc; + srsran_polar_decoder_t dec; + srsran_polar_decoder_t dec_s; // 16-bit + srsran_polar_decoder_t dec_c; // 8-bit + srsran_polar_rm_t rm_tx; + srsran_polar_rm_t rm_rx_f; + srsran_polar_rm_t rm_rx_s; + srsran_polar_rm_t rm_rx_c; #ifdef LV_HAVE_AVX2 - srslte_polar_encoder_t enc_avx2; - srslte_polar_decoder_t dec_c_avx2; // 8-bit + srsran_polar_encoder_t enc_avx2; + srsran_polar_decoder_t dec_c_avx2; // 8-bit #endif // LV_HAVE_AVX2 parse_args(argc, argv); // uinitialize polar code - srslte_polar_code_init(&code); + srsran_polar_code_init(&code); // initialize encoder pipeline - srslte_polar_encoder_init(&enc, SRSLTE_POLAR_ENCODER_PIPELINED, nMax); + srsran_polar_encoder_init(&enc, SRSRAN_POLAR_ENCODER_PIPELINED, nMax); // initialize rate-matcher - srslte_polar_rm_tx_init(&rm_tx); + srsran_polar_rm_tx_init(&rm_tx); // initialize rate-matcher - srslte_polar_rm_rx_init_f(&rm_rx_f); + srsran_polar_rm_rx_init_f(&rm_rx_f); // initialize rate-matcher - srslte_polar_rm_rx_init_s(&rm_rx_s); + srsran_polar_rm_rx_init_s(&rm_rx_s); // initialize rate-matcher - srslte_polar_rm_rx_init_c(&rm_rx_c); + srsran_polar_rm_rx_init_c(&rm_rx_c); // initialize a POLAR decoder (float) - srslte_polar_decoder_init(&dec, SRSLTE_POLAR_DECODER_SSC_F, nMax); + srsran_polar_decoder_init(&dec, SRSRAN_POLAR_DECODER_SSC_F, nMax); // initialize a POLAR decoder (16 bit) - srslte_polar_decoder_init(&dec_s, SRSLTE_POLAR_DECODER_SSC_S, nMax); + srsran_polar_decoder_init(&dec_s, SRSRAN_POLAR_DECODER_SSC_S, nMax); // initialize a POLAR decoder (8 bit) - srslte_polar_decoder_init(&dec_c, SRSLTE_POLAR_DECODER_SSC_C, nMax); + srsran_polar_decoder_init(&dec_c, SRSRAN_POLAR_DECODER_SSC_C, nMax); #ifdef LV_HAVE_AVX2 // initialize encoder avx2 - srslte_polar_encoder_init(&enc_avx2, SRSLTE_POLAR_ENCODER_AVX2, nMax); + srsran_polar_encoder_init(&enc_avx2, SRSRAN_POLAR_ENCODER_AVX2, nMax); // initialize a POLAR decoder (8 bit, avx2) - srslte_polar_decoder_init(&dec_c_avx2, SRSLTE_POLAR_DECODER_SSC_C_AVX2, nMax); + srsran_polar_decoder_init(&dec_c_avx2, SRSRAN_POLAR_DECODER_SSC_C_AVX2, nMax); #endif // LV_HAVE_AVX2 #ifdef DATA_ALL_ONES #else - srslte_random_t random_gen = srslte_random_init(0); + srsran_random_t random_gen = srsran_random_init(0); #endif - data_tx = srslte_vec_u8_malloc(K * BATCH_SIZE); - data_rx = srslte_vec_u8_malloc(K * BATCH_SIZE); - data_rx_s = srslte_vec_u8_malloc(K * BATCH_SIZE); - data_rx_c = srslte_vec_u8_malloc(K * BATCH_SIZE); - data_rx_c_avx2 = srslte_vec_u8_malloc(K * BATCH_SIZE); + data_tx = srsran_vec_u8_malloc(K * BATCH_SIZE); + data_rx = srsran_vec_u8_malloc(K * BATCH_SIZE); + data_rx_s = srsran_vec_u8_malloc(K * BATCH_SIZE); + data_rx_c = srsran_vec_u8_malloc(K * BATCH_SIZE); + data_rx_c_avx2 = srsran_vec_u8_malloc(K * BATCH_SIZE); - input_enc = srslte_vec_u8_malloc(NMAX * BATCH_SIZE); - output_enc = srslte_vec_u8_malloc(NMAX * BATCH_SIZE); - output_enc_avx2 = srslte_vec_u8_malloc(NMAX * BATCH_SIZE); + input_enc = srsran_vec_u8_malloc(NMAX * BATCH_SIZE); + output_enc = srsran_vec_u8_malloc(NMAX * BATCH_SIZE); + output_enc_avx2 = srsran_vec_u8_malloc(NMAX * BATCH_SIZE); - rm_codeword = srslte_vec_u8_malloc(E * BATCH_SIZE); + rm_codeword = srsran_vec_u8_malloc(E * BATCH_SIZE); - rm_llr = srslte_vec_f_malloc(E * BATCH_SIZE); - rm_llr_s = srslte_vec_i16_malloc(E * BATCH_SIZE); - rm_llr_c = srslte_vec_i8_malloc(E * BATCH_SIZE); - rm_llr_c_avx2 = srslte_vec_i8_malloc(E * BATCH_SIZE); + rm_llr = srsran_vec_f_malloc(E * BATCH_SIZE); + rm_llr_s = srsran_vec_i16_malloc(E * BATCH_SIZE); + rm_llr_c = srsran_vec_i8_malloc(E * BATCH_SIZE); + rm_llr_c_avx2 = srsran_vec_i8_malloc(E * BATCH_SIZE); - llr = srslte_vec_f_malloc(NMAX * BATCH_SIZE); - llr_s = srslte_vec_i16_malloc(NMAX * BATCH_SIZE); - llr_c = srslte_vec_i8_malloc(NMAX * BATCH_SIZE); - llr_c_avx2 = srslte_vec_i8_malloc(NMAX * BATCH_SIZE); + llr = srsran_vec_f_malloc(NMAX * BATCH_SIZE); + llr_s = srsran_vec_i16_malloc(NMAX * BATCH_SIZE); + llr_c = srsran_vec_i8_malloc(NMAX * BATCH_SIZE); + llr_c_avx2 = srsran_vec_i8_malloc(NMAX * BATCH_SIZE); - output_dec = srslte_vec_u8_malloc(NMAX * BATCH_SIZE); - output_dec_s = srslte_vec_u8_malloc(NMAX * BATCH_SIZE); - output_dec_c = srslte_vec_u8_malloc(NMAX * BATCH_SIZE); - output_dec_c_avx2 = srslte_vec_u8_malloc(NMAX * BATCH_SIZE); + output_dec = srsran_vec_u8_malloc(NMAX * BATCH_SIZE); + output_dec_s = srsran_vec_u8_malloc(NMAX * BATCH_SIZE); + output_dec_c = srsran_vec_u8_malloc(NMAX * BATCH_SIZE); + output_dec_c_avx2 = srsran_vec_u8_malloc(NMAX * BATCH_SIZE); if (!data_tx || !data_rx || !data_rx_s || !data_rx_c || !data_rx_c_avx2 || !input_enc || !output_enc || !output_enc_avx2 || !rm_codeword || !rm_llr || !rm_llr_s || !rm_llr_c || !rm_llr_c_avx2 || !llr || !llr_s || @@ -319,13 +319,13 @@ int main(int argc, char** argv) for (int i = 0; i < snr_points; i++) { snr_db = SNR_MIN + i * snr_inc; snr_db_vec[i] = snr_db; - var[i] = srslte_convert_dB_to_amplitude(-snr_db); + var[i] = srsran_convert_dB_to_amplitude(-snr_db); } snr_db_vec[snr_points] = 101; // include the no noise case snr_points++; } else { snr_db_vec[0] = snr_db; - var[0] = srslte_convert_dB_to_amplitude(-snr_db); + var[0] = srsran_convert_dB_to_amplitude(-snr_db); snr_points = 1; } @@ -390,13 +390,13 @@ int main(int argc, char** argv) #else for (int i = 0; i < BATCH_SIZE; i++) { for (j = 0; j < K; j++) { - data_tx[i * K + j] = srslte_random_uniform_int_dist(random_gen, 0, 1); + data_tx[i * K + j] = srsran_random_uniform_int_dist(random_gen, 0, 1); } } #endif // get polar code, compute frozen_set (F_set), message_set (K_set) and parity bit set (PC_set) - if (srslte_polar_code_get(&code, K, E, nMax) == -1) { + if (srsran_polar_code_get(&code, K, E, nMax) == -1) { return -1; } @@ -415,14 +415,14 @@ int main(int argc, char** argv) } // subchannel_allocation block for (int i = 0; i < BATCH_SIZE; i++) { - srslte_polar_chanalloc_tx( + srsran_polar_chanalloc_tx( data_tx + i * K, input_enc + i * code.N, code.N, code.K, code.nPC, code.K_set, code.PC_set); } // encoding pipeline gettimeofday(&t[1], NULL); for (j = 0; j < BATCH_SIZE; j++) { - srslte_polar_encoder_encode(&enc, input_enc + j * code.N, output_enc + j * code.N, code.n); + srsran_polar_encoder_encode(&enc, input_enc + j * code.N, output_enc + j * code.N, code.n); } gettimeofday(&t[2], NULL); get_time_interval(t); @@ -431,14 +431,14 @@ int main(int argc, char** argv) // rate matcher for (j = 0; j < BATCH_SIZE; j++) { - srslte_polar_rm_tx(&rm_tx, output_enc + j * code.N, rm_codeword + j * E, code.n, E, K, bil); + srsran_polar_rm_tx(&rm_tx, output_enc + j * code.N, rm_codeword + j * E, code.n, E, K, bil); } #ifdef LV_HAVE_AVX2 // encoding avx2 gettimeofday(&t[1], NULL); for (j = 0; j < BATCH_SIZE; j++) { - srslte_polar_encoder_encode(&enc_avx2, input_enc + j * code.N, output_enc_avx2 + j * code.N, code.n); + srsran_polar_encoder_encode(&enc_avx2, input_enc + j * code.N, output_enc_avx2 + j * code.N, code.n); } gettimeofday(&t[2], NULL); get_time_interval(t); @@ -447,7 +447,7 @@ int main(int argc, char** argv) // check errors with respect the output of the pipeline encoder for (int i = 0; i < BATCH_SIZE; i++) { - if (srslte_bit_diff(output_enc + i * code.N, output_enc_avx2 + i * code.N, code.N) != 0) { + if (srsran_bit_diff(output_enc + i * code.N, output_enc_avx2 + i * code.N, code.N) != 0) { printf("ERROR: Wrong avx2 encoder output. SNR= %f, Batch: %d\n", snr_db_vec[i_snr], i); exit(-1); } @@ -460,7 +460,7 @@ int main(int argc, char** argv) // add noise if (snr_db_vec[i_snr] != 101) { - srslte_ch_awgn_f(rm_llr, rm_llr, var[i_snr], BATCH_SIZE * E); + srsran_ch_awgn_f(rm_llr, rm_llr, var[i_snr], BATCH_SIZE * E); // Convert symbols into LLRs for (j = 0; j < BATCH_SIZE * code.N; j++) { @@ -471,13 +471,13 @@ int main(int argc, char** argv) // rate-Dematcher for (j = 0; j < BATCH_SIZE; j++) { - srslte_polar_rm_rx_f(&rm_rx_f, rm_llr + j * E, llr + j * code.N, E, code.n, K, bil); + srsran_polar_rm_rx_f(&rm_rx_f, rm_llr + j * E, llr + j * code.N, E, code.n, K, bil); } // decoding float point gettimeofday(&t[1], NULL); for (j = 0; j < BATCH_SIZE; j++) { - srslte_polar_decoder_decode_f( + srsran_polar_decoder_decode_f( &dec, llr + j * code.N, output_dec + j * code.N, code.n, code.F_set, code.F_set_size); } @@ -487,7 +487,7 @@ int main(int argc, char** argv) // extract message bits - float decoder for (j = 0; j < BATCH_SIZE; j++) { - srslte_polar_chanalloc_rx(output_dec + j * code.N, data_rx + j * K, code.K, code.nPC, code.K_set, code.PC_set); + srsran_polar_chanalloc_rx(output_dec + j * code.N, data_rx + j * K, code.K, code.nPC, code.K_set, code.PC_set); } // check errors - float decpder @@ -495,7 +495,7 @@ int main(int argc, char** argv) int i_error = 0; #endif for (int i = 0; i < BATCH_SIZE; i++) { - errors_symb = srslte_bit_diff(data_tx + i * K, data_rx + i * K, K); + errors_symb = srsran_bit_diff(data_tx + i * K, data_rx + i * K, K); if (errors_symb != 0) { n_error_words[i_snr]++; @@ -505,22 +505,22 @@ int main(int argc, char** argv) // decoding 16-bit // 16-quantization if (snr_db_vec[i_snr] == 101) { - srslte_vec_quant_fs(rm_llr, rm_llr_s, 8192, 0, 32767, BATCH_SIZE * E); + srsran_vec_quant_fs(rm_llr, rm_llr_s, 8192, 0, 32767, BATCH_SIZE * E); } else { gain_s = inf16 * var[i_snr] / 20 / (1 / var[i_snr] + 2); // printf("gain_s: %f, inf16:%d\n", gain_s, inf16); - srslte_vec_quant_fs(rm_llr, rm_llr_s, gain_s, 0, inf16, BATCH_SIZE * E); + srsran_vec_quant_fs(rm_llr, rm_llr_s, gain_s, 0, inf16, BATCH_SIZE * E); } // Rate dematcher for (j = 0; j < BATCH_SIZE; j++) { - srslte_polar_rm_rx_s(&rm_rx_s, rm_llr_s + j * E, llr_s + j * code.N, E, code.n, K, bil); + srsran_polar_rm_rx_s(&rm_rx_s, rm_llr_s + j * E, llr_s + j * code.N, E, code.n, K, bil); } // decoding 16-bit gettimeofday(&t[1], NULL); for (j = 0; j < BATCH_SIZE; j++) { - srslte_polar_decoder_decode_s( + srsran_polar_decoder_decode_s( &dec_s, llr_s + j * code.N, output_dec_s + j * code.N, code.n, code.F_set, code.F_set_size); } @@ -530,13 +530,13 @@ int main(int argc, char** argv) // extract message bits 16-bit decoder for (j = 0; j < BATCH_SIZE; j++) { - srslte_polar_chanalloc_rx( + srsran_polar_chanalloc_rx( output_dec_s + j * code.N, data_rx_s + j * K, code.K, code.nPC, code.K_set, code.PC_set); } // check errors 16-bit decoder for (int i = 0; i < BATCH_SIZE; i++) { - errors_symb_s = srslte_bit_diff(data_tx + i * K, data_rx_s + i * K, K); + errors_symb_s = srsran_bit_diff(data_tx + i * K, data_rx_s + i * K, K); if (errors_symb_s != 0) { n_error_words_s[i_snr]++; @@ -546,21 +546,21 @@ int main(int argc, char** argv) // 8-bit decoding // 8-bit quantization if (snr_db_vec[i_snr] == 101) { - srslte_vec_quant_fc(rm_llr, rm_llr_c, 32, 0, 127, BATCH_SIZE * E); + srsran_vec_quant_fc(rm_llr, rm_llr_c, 32, 0, 127, BATCH_SIZE * E); } else { gain_c = inf8 * var[i_snr] / 20 / (1 / var[i_snr] + 2); - srslte_vec_quant_fc(rm_llr, rm_llr_c, gain_c, 0, inf8, BATCH_SIZE * E); + srsran_vec_quant_fc(rm_llr, rm_llr_c, gain_c, 0, inf8, BATCH_SIZE * E); } // Rate dematcher for (j = 0; j < BATCH_SIZE; j++) { - srslte_polar_rm_rx_c(&rm_rx_c, rm_llr_c + j * E, llr_c + j * code.N, E, code.n, K, bil); + srsran_polar_rm_rx_c(&rm_rx_c, rm_llr_c + j * E, llr_c + j * code.N, E, code.n, K, bil); } // Decoding gettimeofday(&t[1], NULL); for (j = 0; j < BATCH_SIZE; j++) { - srslte_polar_decoder_decode_c( + srsran_polar_decoder_decode_c( &dec_c, llr_c + j * code.N, output_dec_c + j * code.N, code.n, code.F_set, code.F_set_size); } gettimeofday(&t[2], NULL); @@ -569,14 +569,13 @@ int main(int argc, char** argv) // extract message bits for (j = 0; j < BATCH_SIZE; j++) { - srslte_polar_chanalloc_rx( + srsran_polar_chanalloc_rx( output_dec_c + j * code.N, data_rx_c + j * K, code.K, code.nPC, code.K_set, code.PC_set); } // check errors 8-bits decoder for (int i = 0; i < BATCH_SIZE; i++) { - - errors_symb_c = srslte_bit_diff(data_tx + i * K, data_rx_c + i * K, K); + errors_symb_c = srsran_bit_diff(data_tx + i * K, data_rx_c + i * K, K); if (errors_symb_c != 0) { n_error_words_c[i_snr]++; @@ -587,20 +586,20 @@ int main(int argc, char** argv) // 8-bit avx2 decoding // 8-bit quantization if (snr_db_vec[i_snr] == 101) { - srslte_vec_quant_fc(rm_llr, rm_llr_c_avx2, 32, 0, 127, BATCH_SIZE * E); + srsran_vec_quant_fc(rm_llr, rm_llr_c_avx2, 32, 0, 127, BATCH_SIZE * E); } else { gain_c_avx2 = inf8 * var[i_snr] / 20 / (1 / var[i_snr] + 2); - srslte_vec_quant_fc(rm_llr, rm_llr_c_avx2, gain_c_avx2, 0, inf8, BATCH_SIZE * E); + srsran_vec_quant_fc(rm_llr, rm_llr_c_avx2, gain_c_avx2, 0, inf8, BATCH_SIZE * E); } // Rate dematcher for (j = 0; j < BATCH_SIZE; j++) { - srslte_polar_rm_rx_c(&rm_rx_c, rm_llr_c_avx2 + j * E, llr_c_avx2 + j * code.N, E, code.n, K, bil); + srsran_polar_rm_rx_c(&rm_rx_c, rm_llr_c_avx2 + j * E, llr_c_avx2 + j * code.N, E, code.n, K, bil); } gettimeofday(&t[1], NULL); for (j = 0; j < BATCH_SIZE; j++) { - srslte_polar_decoder_decode_c( + srsran_polar_decoder_decode_c( &dec_c_avx2, llr_c_avx2 + j * code.N, output_dec_c_avx2 + j * code.N, code.n, code.F_set, code.F_set_size); } gettimeofday(&t[2], NULL); @@ -609,14 +608,13 @@ int main(int argc, char** argv) // extract message bits for (j = 0; j < BATCH_SIZE; j++) { - srslte_polar_chanalloc_rx( + srsran_polar_chanalloc_rx( output_dec_c_avx2 + j * code.N, data_rx_c_avx2 + j * K, code.K, code.nPC, code.K_set, code.PC_set); } // check errors 8-bits decoder for (int i = 0; i < BATCH_SIZE; i++) { - - errors_symb_c_avx2 = srslte_bit_diff(data_tx + i * K, data_rx_c_avx2 + i * K, K); + errors_symb_c_avx2 = srsran_bit_diff(data_tx + i * K, data_rx_c_avx2 + i * K, K); if (errors_symb_c_avx2 != 0) { n_error_words_c_avx2[i_snr]++; @@ -797,21 +795,21 @@ int main(int argc, char** argv) #ifdef DATA_ALL_ONES #else - srslte_random_free(random_gen); + srsran_random_free(random_gen); #endif // free code - srslte_polar_code_free(&code); - srslte_polar_encoder_free(&enc); - srslte_polar_decoder_free(&dec); - srslte_polar_decoder_free(&dec_s); - srslte_polar_decoder_free(&dec_c); - srslte_polar_rm_rx_free_f(&rm_rx_f); - srslte_polar_rm_rx_free_s(&rm_rx_s); - srslte_polar_rm_rx_free_c(&rm_rx_c); - srslte_polar_rm_tx_free(&rm_tx); + srsran_polar_code_free(&code); + srsran_polar_encoder_free(&enc); + srsran_polar_decoder_free(&dec); + srsran_polar_decoder_free(&dec_s); + srsran_polar_decoder_free(&dec_c); + srsran_polar_rm_rx_free_f(&rm_rx_f); + srsran_polar_rm_rx_free_s(&rm_rx_s); + srsran_polar_rm_rx_free_c(&rm_rx_c); + srsran_polar_rm_tx_free(&rm_tx); #ifdef LV_HAVE_AVX2 - srslte_polar_encoder_free(&enc_avx2); - srslte_polar_decoder_free(&dec_c_avx2); + srsran_polar_encoder_free(&enc_avx2); + srsran_polar_decoder_free(&dec_c_avx2); #endif // LV_HAVE_AVX2 int expected_errors = 0; diff --git a/lib/src/phy/fec/polar/test/polar_interleaver_gold.h b/lib/src/phy/fec/polar/test/polar_interleaver_gold.h index 889997ef2..ce42a140c 100644 --- a/lib/src/phy/fec/polar/test/polar_interleaver_gold.h +++ b/lib/src/phy/fec/polar/test/polar_interleaver_gold.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/lib/src/phy/fec/polar/test/polar_interleaver_test.c b/lib/src/phy/fec/polar/test/polar_interleaver_test.c index 151ca85bb..ad50d2fdf 100644 --- a/lib/src/phy/fec/polar/test/polar_interleaver_test.c +++ b/lib/src/phy/fec/polar/test/polar_interleaver_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,8 +11,8 @@ */ #include "polar_interleaver_gold.h" -#include "srslte/common/test_common.h" -#include "srslte/phy/fec/polar/polar_interleaver.h" +#include "srsran/common/test_common.h" +#include "srsran/phy/fec/polar/polar_interleaver.h" int main(int argc, char** argv) { @@ -21,14 +21,14 @@ int main(int argc, char** argv) uint32_t K = polar_interleaver_gold[idx].K; // Create indexes in order - uint16_t indexes_in[SRSLTE_POLAR_INTERLEAVER_K_MAX_IL]; + uint16_t indexes_in[SRSRAN_POLAR_INTERLEAVER_K_MAX_IL]; for (uint16_t i = 0; i < (uint16_t)K; i++) { indexes_in[i] = i; } // Run interleaver forward - uint16_t indexes_out[SRSLTE_POLAR_INTERLEAVER_K_MAX_IL]; - srslte_polar_interleaver_run_u16(indexes_in, indexes_out, K, true); + uint16_t indexes_out[SRSRAN_POLAR_INTERLEAVER_K_MAX_IL]; + srsran_polar_interleaver_run_u16(indexes_in, indexes_out, K, true); // Check indexes for (uint32_t i = 0; i < K; i++) { @@ -36,7 +36,7 @@ int main(int argc, char** argv) } // Run interleaver backwards - srslte_polar_interleaver_run_u16(indexes_out, indexes_in, K, false); + srsran_polar_interleaver_run_u16(indexes_out, indexes_in, K, false); // Check indexes for (uint16_t i = 0; i < (uint16_t)K; i++) { @@ -46,5 +46,5 @@ int main(int argc, char** argv) idx++; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } \ No newline at end of file diff --git a/lib/src/phy/fec/polar/test/polar_sets.c b/lib/src/phy/fec/polar/test/polar_sets.c index 28a1dad1a..06d2531cb 100644 --- a/lib/src/phy/fec/polar/test/polar_sets.c +++ b/lib/src/phy/fec/polar/test/polar_sets.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -27,12 +27,12 @@ #include "polar_sets.h" #include -#include +#include #include #include //exit #include -void srslte_polar_code_sets_free(srslte_polar_sets_t* c) +void srsran_polar_code_sets_free(srsran_polar_sets_t* c) { if (c != NULL) { free(c->frozen_set); @@ -42,7 +42,7 @@ void srslte_polar_code_sets_free(srslte_polar_sets_t* c) } } -int srslte_polar_code_sets_read(srslte_polar_sets_t* c, +int srsran_polar_code_sets_read(srsran_polar_sets_t* c, const uint16_t message_size, const uint8_t code_size_log, const uint16_t rate_matching_size, @@ -59,25 +59,25 @@ int srslte_polar_code_sets_read(srslte_polar_sets_t* c, c->info_set_size = message_size + parity_set_size; c->message_set_size = message_size; - c->frozen_set = srslte_vec_u16_malloc(c->frozen_set_size); + c->frozen_set = srsran_vec_u16_malloc(c->frozen_set_size); if (!c->frozen_set) { perror("malloc"); exit(-1); } - c->info_set = srslte_vec_u16_malloc(c->info_set_size); + c->info_set = srsran_vec_u16_malloc(c->info_set_size); if (!c->info_set) { perror("malloc"); exit(-1); } - c->message_set = srslte_vec_u16_malloc(c->message_set_size); + c->message_set = srsran_vec_u16_malloc(c->message_set_size); if (!c->message_set) { perror("malloc"); exit(-1); } - c->parity_set = srslte_vec_u16_malloc(parity_set_size); + c->parity_set = srsran_vec_u16_malloc(parity_set_size); if (!c->parity_set) { perror("malloc"); exit(-1); diff --git a/lib/src/phy/fec/polar/test/polar_sets.h b/lib/src/phy/fec/polar/test/polar_sets.h index cf8ac4805..8fb58afd9 100644 --- a/lib/src/phy/fec/polar/test/polar_sets.h +++ b/lib/src/phy/fec/polar/test/polar_sets.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -24,10 +24,10 @@ * */ -#ifndef SRSLTE_POLAR_SETS_H -#define SRSLTE_POLAR_SETS_H +#ifndef SRSRAN_POLAR_SETS_H +#define SRSRAN_POLAR_SETS_H -#include "srslte/config.h" +#include "srsran/config.h" #include /*! @@ -43,7 +43,7 @@ typedef struct { parity check bits.*/ uint16_t* parity_set; /*!< \brief Pointer to the indices of the encoder input vector containing the parity bits.*/ uint16_t* frozen_set; /*!< \brief Pointer to the indices of the encoder input vector containing frozen bits.*/ -} srslte_polar_sets_t; +} srsran_polar_sets_t; /*! * Initializes the different index sets as needed by the subchannel allocation block and/or by the polar decoder. @@ -55,7 +55,7 @@ typedef struct { * \param[in] nWmPC Number of parity bits of minimum weight type. * \return An integer: 0 if the function executes correctly, -1 otherwise. */ -int srslte_polar_code_sets_read(srslte_polar_sets_t* c, +int srsran_polar_code_sets_read(srsran_polar_sets_t* c, uint16_t message_size, uint8_t code_size_log, uint16_t rate_matching_size, @@ -66,6 +66,6 @@ int srslte_polar_code_sets_read(srslte_polar_sets_t* c, * The polar set "destructor": it frees all the resources. * \param[in] c A pointer to the dismantled polar set. */ -void srslte_polar_code_sets_free(srslte_polar_sets_t* c); +void srsran_polar_code_sets_free(srsran_polar_sets_t* c); -#endif // SRSLTE_POLAR_SETS_H +#endif // SRSRAN_POLAR_SETS_H diff --git a/lib/src/phy/fec/polar/test/subchannel_allocation.c b/lib/src/phy/fec/polar/test/subchannel_allocation.c index 7002434f2..f99c58c16 100644 --- a/lib/src/phy/fec/polar/test/subchannel_allocation.c +++ b/lib/src/phy/fec/polar/test/subchannel_allocation.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -26,7 +26,7 @@ #include "subchannel_allocation.h" #include //memset -void srslte_subchannel_allocation_init(srslte_subchn_alloc_t* c, +void srsran_subchannel_allocation_init(srsran_subchn_alloc_t* c, const uint8_t code_size_log, const uint16_t message_set_size, uint16_t* message_set) @@ -36,7 +36,7 @@ void srslte_subchannel_allocation_init(srslte_subchn_alloc_t* c, c->message_set = message_set; } -void srslte_subchannel_allocation(const srslte_subchn_alloc_t* c, const uint8_t* message, uint8_t* input_encoder) +void srsran_subchannel_allocation(const srsran_subchn_alloc_t* c, const uint8_t* message, uint8_t* input_encoder) { memset(input_encoder, 0, c->code_size * sizeof(uint8_t)); @@ -47,7 +47,7 @@ void srslte_subchannel_allocation(const srslte_subchn_alloc_t* c, const uint8_t* } } -void srslte_subchannel_deallocation(const srslte_subchn_alloc_t* c, const uint8_t* output_decoder, uint8_t* message) +void srsran_subchannel_deallocation(const srsran_subchn_alloc_t* c, const uint8_t* output_decoder, uint8_t* message) { uint16_t i_o = 0; for (uint16_t i = 0; i < c->message_size; i++) { diff --git a/lib/src/phy/fec/polar/test/subchannel_allocation.h b/lib/src/phy/fec/polar/test/subchannel_allocation.h index 54990a0d6..cddb7c001 100644 --- a/lib/src/phy/fec/polar/test/subchannel_allocation.h +++ b/lib/src/phy/fec/polar/test/subchannel_allocation.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -23,31 +23,31 @@ * */ -#ifndef SRSLTE_SUB_CHANNEL_ALLOC_H -#define SRSLTE_SUB_CHANNEL_ALLOC_H +#ifndef SRSRAN_SUB_CHANNEL_ALLOC_H +#define SRSRAN_SUB_CHANNEL_ALLOC_H -#include "srslte/config.h" +#include "srsran/config.h" #include "stdint.h" /*! * \brief Describes a subchannel allocation. */ -typedef struct SRSLTE_API { +typedef struct SRSRAN_API { uint16_t code_size; /*!< \brief Number of bits, \f$N\f$, of the encoder input/output vector. */ uint16_t message_size; /*!< \brief Number of bits, \f$K\f$, of data + CRC. */ uint16_t* message_set; /*!< \brief Pointer to the indices of the encoder input vector containing data and CRC bits. */ -} srslte_subchn_alloc_t; +} srsran_subchn_alloc_t; /*! * Initializes a subchannel allocation instance. - * \param[out] c A pointer to the srslte_subchn_alloc_t structure + * \param[out] c A pointer to the srsran_subchn_alloc_t structure * containing the parameters needed by the subchannel allocation function. * \param[in] code_size_log The \f$ log_2\f$ of the number of bits of the decoder input/output vector. * \param[in] message_set_size Number of data + CRC bits. * \param[in] message_set Pointer to the indices of the encoder input vector containing * data and CRC bits. */ -void srslte_subchannel_allocation_init(srslte_subchn_alloc_t* c, +void srsran_subchannel_allocation_init(srsran_subchn_alloc_t* c, uint8_t code_size_log, uint16_t message_set_size, uint16_t* message_set); @@ -57,21 +57,21 @@ void srslte_subchannel_allocation_init(srslte_subchn_alloc_t* c, * positions specified in \a c->message_set and zeros to the remaining * positions. This function is not fully 5G compliant as parity bits positions * are set to 0. - * \param[in] c A pointer to the srslte_subchn_alloc_t structure containing + * \param[in] c A pointer to the srsran_subchn_alloc_t structure containing * the parameters needed by the subchannel allocation function. * \param[in] message A pointer to the vector with the message bits (data and CRC). * \param[out] input_encoder A pointer to the encoder input bit vector. */ -void srslte_subchannel_allocation(const srslte_subchn_alloc_t* c, const uint8_t* message, uint8_t* input_encoder); +void srsran_subchannel_allocation(const srsran_subchn_alloc_t* c, const uint8_t* message, uint8_t* input_encoder); /*! * Extracts message bits (data + CRC) from the decoder output vector * according to the positions specified in \a c->message_set. - * \param[in] c A pointer to the srslte_subchn_alloc_t structure containing the + * \param[in] c A pointer to the srsran_subchn_alloc_t structure containing the * parameters needed by the subchannel allocation function. * \param[in] output_decoder A pointer to the decoder output bit vector. * \param[out] message A pointer to the vector with the message bits (data and CRC). */ -void srslte_subchannel_deallocation(const srslte_subchn_alloc_t* c, const uint8_t* output_decoder, uint8_t* message); +void srsran_subchannel_deallocation(const srsran_subchn_alloc_t* c, const uint8_t* output_decoder, uint8_t* message); -#endif // SRSLTE_SUB_CHANNEL_ALLOC_H +#endif // SRSRAN_SUB_CHANNEL_ALLOC_H diff --git a/lib/src/phy/fec/softbuffer.c b/lib/src/phy/fec/softbuffer.c index c78c3e5c7..e1966dc8a 100644 --- a/lib/src/phy/fec/softbuffer.c +++ b/lib/src/phy/fec/softbuffer.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -16,91 +16,91 @@ #include #include -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/fec/softbuffer.h" -#include "srslte/phy/fec/turbo/turbodecoder_gen.h" -#include "srslte/phy/phch/ra.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/fec/softbuffer.h" +#include "srsran/phy/fec/turbo/turbodecoder_gen.h" +#include "srsran/phy/phch/ra.h" +#include "srsran/phy/utils/vector.h" -#define MAX_PDSCH_RE(cp) (2 * SRSLTE_CP_NSYMB(cp) * 12) +#define MAX_PDSCH_RE(cp) (2 * SRSRAN_CP_NSYMB(cp) * 12) -int srslte_softbuffer_rx_init(srslte_softbuffer_rx_t* q, uint32_t nof_prb) +int srsran_softbuffer_rx_init(srsran_softbuffer_rx_t* q, uint32_t nof_prb) { - int ret = srslte_ra_tbs_from_idx(SRSLTE_RA_NOF_TBS_IDX - 1, nof_prb); + int ret = srsran_ra_tbs_from_idx(SRSRAN_RA_NOF_TBS_IDX - 1, nof_prb); - if (ret == SRSLTE_ERROR) { - return SRSLTE_ERROR; + if (ret == SRSRAN_ERROR) { + return SRSRAN_ERROR; } - uint32_t max_cb = (uint32_t)ret / (SRSLTE_TCOD_MAX_LEN_CB - 24) + 1; + uint32_t max_cb = (uint32_t)ret / (SRSRAN_TCOD_MAX_LEN_CB - 24) + 1; uint32_t max_cb_size = SOFTBUFFER_SIZE; - return srslte_softbuffer_rx_init_guru(q, max_cb, max_cb_size); + return srsran_softbuffer_rx_init_guru(q, max_cb, max_cb_size); } -int srslte_softbuffer_rx_init_guru(srslte_softbuffer_rx_t* q, uint32_t max_cb, uint32_t max_cb_size) +int srsran_softbuffer_rx_init_guru(srsran_softbuffer_rx_t* q, uint32_t max_cb, uint32_t max_cb_size) { - int ret = SRSLTE_ERROR; + int ret = SRSRAN_ERROR; // Protect pointer if (!q) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } // Initialise object - SRSLTE_MEM_ZERO(q, srslte_softbuffer_rx_t, 1); + SRSRAN_MEM_ZERO(q, srsran_softbuffer_rx_t, 1); // Set internal attributes q->max_cb = max_cb; q->max_cb_size = max_cb_size; - q->buffer_f = SRSLTE_MEM_ALLOC(int16_t*, q->max_cb); + q->buffer_f = SRSRAN_MEM_ALLOC(int16_t*, q->max_cb); if (!q->buffer_f) { perror("malloc"); goto clean_exit; } - SRSLTE_MEM_ZERO(q->buffer_f, int16_t*, q->max_cb); + SRSRAN_MEM_ZERO(q->buffer_f, int16_t*, q->max_cb); - q->data = SRSLTE_MEM_ALLOC(uint8_t*, q->max_cb); + q->data = SRSRAN_MEM_ALLOC(uint8_t*, q->max_cb); if (!q->data) { perror("malloc"); goto clean_exit; } - SRSLTE_MEM_ZERO(q->data, uint8_t*, q->max_cb); + SRSRAN_MEM_ZERO(q->data, uint8_t*, q->max_cb); - q->cb_crc = SRSLTE_MEM_ALLOC(bool, q->max_cb); + q->cb_crc = SRSRAN_MEM_ALLOC(bool, q->max_cb); if (!q->cb_crc) { perror("malloc"); goto clean_exit; } for (uint32_t i = 0; i < q->max_cb; i++) { - q->buffer_f[i] = srslte_vec_i16_malloc(q->max_cb_size); + q->buffer_f[i] = srsran_vec_i16_malloc(q->max_cb_size); if (!q->buffer_f[i]) { perror("malloc"); goto clean_exit; } - q->data[i] = srslte_vec_u8_malloc(q->max_cb_size / 8); + q->data[i] = srsran_vec_u8_malloc(q->max_cb_size / 8); if (!q->data[i]) { perror("malloc"); goto clean_exit; } } - srslte_softbuffer_rx_reset(q); + srsran_softbuffer_rx_reset(q); // Consider success - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; clean_exit: if (ret) { - srslte_softbuffer_rx_free(q); + srsran_softbuffer_rx_free(q); } return ret; } -void srslte_softbuffer_rx_free(srslte_softbuffer_rx_t* q) +void srsran_softbuffer_rx_free(srsran_softbuffer_rx_t* q) { if (q) { if (q->buffer_f) { @@ -123,22 +123,22 @@ void srslte_softbuffer_rx_free(srslte_softbuffer_rx_t* q) free(q->cb_crc); } - SRSLTE_MEM_ZERO(q, srslte_softbuffer_rx_t, 1); + SRSRAN_MEM_ZERO(q, srsran_softbuffer_rx_t, 1); } } -void srslte_softbuffer_rx_reset_tbs(srslte_softbuffer_rx_t* q, uint32_t tbs) +void srsran_softbuffer_rx_reset_tbs(srsran_softbuffer_rx_t* q, uint32_t tbs) { - uint32_t nof_cb = (tbs + 24) / (SRSLTE_TCOD_MAX_LEN_CB - 24) + 1; - srslte_softbuffer_rx_reset_cb(q, SRSLTE_MIN(nof_cb, q->max_cb)); + uint32_t nof_cb = (tbs + 24) / (SRSRAN_TCOD_MAX_LEN_CB - 24) + 1; + srsran_softbuffer_rx_reset_cb(q, SRSRAN_MIN(nof_cb, q->max_cb)); } -void srslte_softbuffer_rx_reset(srslte_softbuffer_rx_t* q) +void srsran_softbuffer_rx_reset(srsran_softbuffer_rx_t* q) { - srslte_softbuffer_rx_reset_cb(q, q->max_cb); + srsran_softbuffer_rx_reset_cb(q, q->max_cb); } -void srslte_softbuffer_rx_reset_cb(srslte_softbuffer_rx_t* q, uint32_t nof_cb) +void srsran_softbuffer_rx_reset_cb(srsran_softbuffer_rx_t* q, uint32_t nof_cb) { if (q->buffer_f) { if (nof_cb > q->max_cb) { @@ -146,67 +146,67 @@ void srslte_softbuffer_rx_reset_cb(srslte_softbuffer_rx_t* q, uint32_t nof_cb) } for (uint32_t i = 0; i < nof_cb; i++) { if (q->buffer_f[i]) { - srslte_vec_i16_zero(q->buffer_f[i], q->max_cb_size); + srsran_vec_i16_zero(q->buffer_f[i], q->max_cb_size); } if (q->data[i]) { - srslte_vec_u8_zero(q->data[i], q->max_cb_size / 8); + srsran_vec_u8_zero(q->data[i], q->max_cb_size / 8); } } } if (q->cb_crc) { - SRSLTE_MEM_ZERO(q->cb_crc, bool, q->max_cb); + SRSRAN_MEM_ZERO(q->cb_crc, bool, q->max_cb); } q->tb_crc = false; } -int srslte_softbuffer_tx_init(srslte_softbuffer_tx_t* q, uint32_t nof_prb) +int srsran_softbuffer_tx_init(srsran_softbuffer_tx_t* q, uint32_t nof_prb) { - int ret = srslte_ra_tbs_from_idx(SRSLTE_RA_NOF_TBS_IDX - 1, nof_prb); - if (ret == SRSLTE_ERROR) { - return SRSLTE_ERROR; + int ret = srsran_ra_tbs_from_idx(SRSRAN_RA_NOF_TBS_IDX - 1, nof_prb); + if (ret == SRSRAN_ERROR) { + return SRSRAN_ERROR; } - uint32_t max_cb = (uint32_t)ret / (SRSLTE_TCOD_MAX_LEN_CB - 24) + 1; + uint32_t max_cb = (uint32_t)ret / (SRSRAN_TCOD_MAX_LEN_CB - 24) + 1; uint32_t max_cb_size = SOFTBUFFER_SIZE; - return srslte_softbuffer_tx_init_guru(q, max_cb, max_cb_size); + return srsran_softbuffer_tx_init_guru(q, max_cb, max_cb_size); } -int srslte_softbuffer_tx_init_guru(srslte_softbuffer_tx_t* q, uint32_t max_cb, uint32_t max_cb_size) +int srsran_softbuffer_tx_init_guru(srsran_softbuffer_tx_t* q, uint32_t max_cb, uint32_t max_cb_size) { // Protect pointer if (!q) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } // Initialise object - SRSLTE_MEM_ZERO(q, srslte_softbuffer_tx_t, 1); + SRSRAN_MEM_ZERO(q, srsran_softbuffer_tx_t, 1); // Set internal attributes q->max_cb = max_cb; q->max_cb_size = max_cb_size; - q->buffer_b = SRSLTE_MEM_ALLOC(uint8_t*, q->max_cb); + q->buffer_b = SRSRAN_MEM_ALLOC(uint8_t*, q->max_cb); if (!q->buffer_b) { perror("malloc"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - SRSLTE_MEM_ZERO(q->buffer_b, uint8_t*, q->max_cb); + SRSRAN_MEM_ZERO(q->buffer_b, uint8_t*, q->max_cb); // TODO: Use HARQ buffer limitation based on UE category for (uint32_t i = 0; i < q->max_cb; i++) { - q->buffer_b[i] = srslte_vec_u8_malloc(q->max_cb_size); + q->buffer_b[i] = srsran_vec_u8_malloc(q->max_cb_size); if (!q->buffer_b[i]) { perror("malloc"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } - srslte_softbuffer_tx_reset(q); + srsran_softbuffer_tx_reset(q); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -void srslte_softbuffer_tx_free(srslte_softbuffer_tx_t* q) +void srsran_softbuffer_tx_free(srsran_softbuffer_tx_t* q) { if (q) { if (q->buffer_b) { @@ -217,22 +217,22 @@ void srslte_softbuffer_tx_free(srslte_softbuffer_tx_t* q) } free(q->buffer_b); } - SRSLTE_MEM_ZERO(q, srslte_softbuffer_tx_t, 1); + SRSRAN_MEM_ZERO(q, srsran_softbuffer_tx_t, 1); } } -void srslte_softbuffer_tx_reset_tbs(srslte_softbuffer_tx_t* q, uint32_t tbs) +void srsran_softbuffer_tx_reset_tbs(srsran_softbuffer_tx_t* q, uint32_t tbs) { - uint32_t nof_cb = (tbs + 24) / (SRSLTE_TCOD_MAX_LEN_CB - 24) + 1; - srslte_softbuffer_tx_reset_cb(q, nof_cb); + uint32_t nof_cb = (tbs + 24) / (SRSRAN_TCOD_MAX_LEN_CB - 24) + 1; + srsran_softbuffer_tx_reset_cb(q, nof_cb); } -void srslte_softbuffer_tx_reset(srslte_softbuffer_tx_t* q) +void srsran_softbuffer_tx_reset(srsran_softbuffer_tx_t* q) { - srslte_softbuffer_tx_reset_cb(q, q->max_cb); + srsran_softbuffer_tx_reset_cb(q, q->max_cb); } -void srslte_softbuffer_tx_reset_cb(srslte_softbuffer_tx_t* q, uint32_t nof_cb) +void srsran_softbuffer_tx_reset_cb(srsran_softbuffer_tx_t* q, uint32_t nof_cb) { if (q->buffer_b) { if (nof_cb > q->max_cb) { @@ -240,7 +240,7 @@ void srslte_softbuffer_tx_reset_cb(srslte_softbuffer_tx_t* q, uint32_t nof_cb) } for (uint32_t i = 0; i < nof_cb; i++) { if (q->buffer_b[i]) { - srslte_vec_u8_zero(q->buffer_b[i], q->max_cb_size); + srsran_vec_u8_zero(q->buffer_b[i], q->max_cb_size); } } } diff --git a/lib/src/phy/fec/test/CMakeLists.txt b/lib/src/phy/fec/test/CMakeLists.txt index be61c4a5d..07f7ba58e 100644 --- a/lib/src/phy/fec/test/CMakeLists.txt +++ b/lib/src/phy/fec/test/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -11,7 +11,7 @@ ######################################################################## add_executable(crc_test crc_test.c) -target_link_libraries(crc_test srslte_phy) +target_link_libraries(crc_test srsran_phy) add_test(crc_24A crc_test -n 5001 -l 24 -p 0x1864CFB -s 1) add_test(crc_24B crc_test -n 5001 -l 24 -p 0x1800063 -s 1) diff --git a/lib/src/phy/fec/test/crc_test.c b/lib/src/phy/fec/test/crc_test.c index 0c88d8ce6..9f4416a87 100644 --- a/lib/src/phy/fec/test/crc_test.c +++ b/lib/src/phy/fec/test/crc_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -19,7 +19,7 @@ #include #include "crc_test.h" -#include "srslte/srslte.h" +#include "srsran/srsran.h" int num_bits = 5001, crc_length = 24; uint32_t crc_poly = 0x1864CFB; @@ -32,7 +32,7 @@ void usage(char* prog) printf("\t-l crc_length [Default %d]\n", crc_length); printf("\t-p crc_poly (Hex) [Default 0x%x]\n", crc_poly); printf("\t-s seed [Default 0=time]\n"); - printf("\t-v [set srslte_verbose to debug, default none]\n"); + printf("\t-v [set srsran_verbose to debug, default none]\n"); } void parse_args(int argc, char** argv) @@ -53,7 +53,7 @@ void parse_args(int argc, char** argv) seed = (uint32_t)strtoul(argv[optind], NULL, 0); break; case 'v': - srslte_verbose++; + srsran_verbose++; break; default: usage(argv[0]); @@ -67,11 +67,11 @@ int main(int argc, char** argv) int i; uint8_t* data; uint32_t crc_word, expected_word; - srslte_crc_t crc_p; + srsran_crc_t crc_p; parse_args(argc, argv); - data = srslte_vec_u8_malloc(num_bits + crc_length * 2); + data = srsran_vec_u8_malloc(num_bits + crc_length * 2); if (!data) { perror("malloc"); exit(-1); @@ -87,18 +87,18 @@ int main(int argc, char** argv) data[i] = rand() % 2; } - if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_INFO && !handler_registered) { + if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_INFO && !handler_registered) { INFO("data="); - srslte_vec_fprint_b(stdout, data, num_bits); + srsran_vec_fprint_b(stdout, data, num_bits); } // Initialize CRC params and tables - if (srslte_crc_init(&crc_p, crc_poly, crc_length)) { + if (srsran_crc_init(&crc_p, crc_poly, crc_length)) { exit(-1); } // generate CRC word - crc_word = srslte_crc_checksum(&crc_p, data, num_bits); + crc_word = srsran_crc_checksum(&crc_p, data, num_bits); INFO("checksum=%x", crc_word); diff --git a/lib/src/phy/fec/test/crc_test.h b/lib/src/phy/fec/test/crc_test.h index a417fa748..60e495d50 100644 --- a/lib/src/phy/fec/test/crc_test.h +++ b/lib/src/phy/fec/test/crc_test.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -12,8 +12,8 @@ #include -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/fec/crc.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/fec/crc.h" typedef struct { int n; @@ -25,12 +25,12 @@ typedef struct { static expected_word_t expected_words[] = { - {5001, 24, SRSLTE_LTE_CRC24A, 1, 0x1C5C97}, // LTE CRC24A (36.212 Sec 5.1.1) - {5001, 24, SRSLTE_LTE_CRC24B, 1, 0x36D1F0}, // LTE CRC24B - {5001, 16, SRSLTE_LTE_CRC16, 1, 0x7FF4}, // LTE CRC16: 0x7FF4 - {5001, 8, SRSLTE_LTE_CRC8, 1, 0xF0}, // LTE CRC8 0xF8 - {30, 11, SRSLTE_LTE_CRC11, 1, 0x114}, // NR CRC11 0x114 - {20, 6, SRSLTE_LTE_CRC6, 1, 0x1F}, // NR CRC6 0x1F + {5001, 24, SRSRAN_LTE_CRC24A, 1, 0x1C5C97}, // LTE CRC24A (36.212 Sec 5.1.1) + {5001, 24, SRSRAN_LTE_CRC24B, 1, 0x36D1F0}, // LTE CRC24B + {5001, 16, SRSRAN_LTE_CRC16, 1, 0x7FF4}, // LTE CRC16: 0x7FF4 + {5001, 8, SRSRAN_LTE_CRC8, 1, 0xF0}, // LTE CRC8 0xF8 + {30, 11, SRSRAN_LTE_CRC11, 1, 0x114}, // NR CRC11 0x114 + {20, 6, SRSRAN_LTE_CRC6, 1, 0x1F}, // NR CRC6 0x1F {-1, -1, 0, 0, 0}}; diff --git a/lib/src/phy/fec/turbo/CMakeLists.txt b/lib/src/phy/fec/turbo/CMakeLists.txt index 9b7812852..1af59e135 100644 --- a/lib/src/phy/fec/turbo/CMakeLists.txt +++ b/lib/src/phy/fec/turbo/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of diff --git a/lib/src/phy/fec/turbo/rm_conv.c b/lib/src/phy/fec/turbo/rm_conv.c index b4b11d743..8b2f5a03c 100644 --- a/lib/src/phy/fec/turbo/rm_conv.c +++ b/lib/src/phy/fec/turbo/rm_conv.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -14,8 +14,8 @@ #include #include -#include "srslte/phy/fec/convolutional/rm_conv.h" -#include "srslte/phy/utils/debug.h" +#include "srsran/phy/fec/convolutional/rm_conv.h" +#include "srsran/phy/utils/debug.h" #define NCOLS 32 #define NROWS_MAX NCOLS @@ -31,7 +31,7 @@ uint8_t RM_PERM_CC_INV[NCOLS] = {16, 0, 24, 8, 20, 4, 28, 12, 18, 2, 26, 10, 22, * @param[in] input Unpacked bit array. Size in_len * @param[output] output Unpacked bit array. Size out_len <= in_len */ -int srslte_rm_conv_tx(uint8_t* input, uint32_t in_len, uint8_t* output, uint32_t out_len) +int srsran_rm_conv_tx(uint8_t* input, uint32_t in_len, uint8_t* output, uint32_t out_len) { uint8_t tmp[3 * NCOLS * NROWS_MAX]; int nrows, ndummy, K_p; @@ -54,7 +54,7 @@ int srslte_rm_conv_tx(uint8_t* input, uint32_t in_len, uint8_t* output, uint32_t for (j = 0; j < NCOLS; j++) { for (i = 0; i < nrows; i++) { if (i * NCOLS + RM_PERM_CC[j] < ndummy) { - tmp[k] = SRSLTE_TX_NULL; + tmp[k] = SRSRAN_TX_NULL; } else { tmp[k] = input[(i * NCOLS + RM_PERM_CC[j] - ndummy) * 3 + s]; } @@ -66,7 +66,7 @@ int srslte_rm_conv_tx(uint8_t* input, uint32_t in_len, uint8_t* output, uint32_t k = 0; j = 0; while (k < out_len) { - if (tmp[j] != SRSLTE_TX_NULL) { + if (tmp[j] != SRSRAN_TX_NULL) { output[k] = tmp[j]; k++; } @@ -81,7 +81,7 @@ int srslte_rm_conv_tx(uint8_t* input, uint32_t in_len, uint8_t* output, uint32_t /* Undoes Convolutional Code Rate Matching. * 3GPP TS 36.212 v10.1.0 section 5.1.4.2 */ -int srslte_rm_conv_rx(float* input, uint32_t in_len, float* output, uint32_t out_len) +int srsran_rm_conv_rx(float* input, uint32_t in_len, float* output, uint32_t out_len) { int nrows, ndummy, K_p; int i, j, k; @@ -102,7 +102,7 @@ int srslte_rm_conv_rx(float* input, uint32_t in_len, float* output, uint32_t out } for (i = 0; i < 3 * K_p; i++) { - tmp[i] = SRSLTE_RX_NULL; + tmp[i] = SRSRAN_RX_NULL; } /* Undo bit collection. Account for dummy bits */ @@ -113,9 +113,9 @@ int srslte_rm_conv_rx(float* input, uint32_t in_len, float* output, uint32_t out d_j = (j % K_p) % nrows; if (d_j * NCOLS + RM_PERM_CC[d_i] >= ndummy) { - if (tmp[j] == SRSLTE_RX_NULL) { + if (tmp[j] == SRSRAN_RX_NULL) { tmp[j] = input[k]; - } else if (input[k] != SRSLTE_RX_NULL) { + } else if (input[k] != SRSRAN_RX_NULL) { tmp[j] += input[k]; /* soft combine LLRs */ } k++; @@ -132,7 +132,7 @@ int srslte_rm_conv_rx(float* input, uint32_t in_len, float* output, uint32_t out d_j = (i + ndummy) % NCOLS; for (j = 0; j < 3; j++) { float o = tmp[K_p * j + RM_PERM_CC_INV[d_j] * nrows + d_i]; - if (o != SRSLTE_RX_NULL) { + if (o != SRSRAN_RX_NULL) { output[i * 3 + j] = o; } else { output[i * 3 + j] = 0; @@ -147,7 +147,7 @@ int srslte_rm_conv_rx(float* input, uint32_t in_len, float* output, uint32_t out /* Undoes Convolutional Code Rate Matching. * 3GPP TS 36.212 v10.1.0 section 5.1.4.2 */ -int srslte_rm_conv_rx_s(int16_t* input, uint32_t in_len, int16_t* output, uint32_t out_len) +int srsran_rm_conv_rx_s(int16_t* input, uint32_t in_len, int16_t* output, uint32_t out_len) { int nrows, ndummy, K_p; int i, j, k; @@ -168,7 +168,7 @@ int srslte_rm_conv_rx_s(int16_t* input, uint32_t in_len, int16_t* output, uint32 } for (i = 0; i < 3 * K_p; i++) { - tmp[i] = SRSLTE_RX_NULL; + tmp[i] = SRSRAN_RX_NULL; } /* Undo bit collection. Account for dummy bits */ @@ -179,9 +179,9 @@ int srslte_rm_conv_rx_s(int16_t* input, uint32_t in_len, int16_t* output, uint32 d_j = (j % K_p) % nrows; if (d_j * NCOLS + RM_PERM_CC[d_i] >= ndummy) { - if (tmp[j] == SRSLTE_RX_NULL) { + if (tmp[j] == SRSRAN_RX_NULL) { tmp[j] = input[k]; - } else if (input[k] != SRSLTE_RX_NULL) { + } else if (input[k] != SRSRAN_RX_NULL) { tmp[j] += input[k]; /* soft combine LLRs */ } k++; @@ -198,7 +198,7 @@ int srslte_rm_conv_rx_s(int16_t* input, uint32_t in_len, int16_t* output, uint32 d_j = (i + ndummy) % NCOLS; for (j = 0; j < 3; j++) { int16_t o = tmp[K_p * j + RM_PERM_CC_INV[d_j] * nrows + d_i]; - if (o != SRSLTE_RX_NULL) { + if (o != SRSRAN_RX_NULL) { output[i * 3 + j] = o; } else { output[i * 3 + j] = 0; diff --git a/lib/src/phy/fec/turbo/rm_turbo.c b/lib/src/phy/fec/turbo/rm_turbo.c index e94ddb5ef..56e68f0ad 100644 --- a/lib/src/phy/fec/turbo/rm_turbo.c +++ b/lib/src/phy/fec/turbo/rm_turbo.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -17,21 +17,21 @@ #include #include -#include "srslte/phy/fec/cbsegm.h" -#include "srslte/phy/fec/turbo/rm_turbo.h" -#include "srslte/phy/utils/bit.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/fec/cbsegm.h" +#include "srsran/phy/fec/turbo/rm_turbo.h" +#include "srsran/phy/utils/bit.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" #ifdef LV_HAVE_SSE #include -int srslte_rm_turbo_rx_lut_sse(int16_t* input, +int srsran_rm_turbo_rx_lut_sse(int16_t* input, int16_t* output, uint16_t* deinter, uint32_t in_len, uint32_t cb_idx, uint32_t rv_idx); -int srslte_rm_turbo_rx_lut_sse_8bit(int8_t* input, +int srsran_rm_turbo_rx_lut_sse_8bit(int8_t* input, int8_t* output, uint16_t* deinter, uint32_t in_len, @@ -41,13 +41,13 @@ int srslte_rm_turbo_rx_lut_sse_8bit(int8_t* input, #ifdef LV_HAVE_AVX #include -int srslte_rm_turbo_rx_lut_avx(int16_t* input, +int srsran_rm_turbo_rx_lut_avx(int16_t* input, int16_t* output, uint16_t* deinter, uint32_t in_len, uint32_t cb_idx, uint32_t rv_idx); -int srslte_rm_turbo_rx_lut_avx_8bit(int8_t* input, +int srsran_rm_turbo_rx_lut_avx_8bit(int8_t* input, int8_t* output, uint16_t* deinter, uint32_t in_len, @@ -64,15 +64,15 @@ static uint8_t RM_PERM_TC[NCOLS] = {0, 16, 8, 24, 4, 20, 12, 28, 2, 18, 10, 26, /* Align tables to 16-byte boundary */ static uint16_t interleaver_systematic_bits[192][6160]; // 4 tail bits -static srslte_bit_interleaver_t bit_interleavers_systematic_bits[192]; +static srsran_bit_interleaver_t bit_interleavers_systematic_bits[192]; static uint16_t interleaver_parity_bits[192][2 * 6160]; -static srslte_bit_interleaver_t bit_interleavers_parity_bits[192]; +static srsran_bit_interleaver_t bit_interleavers_parity_bits[192]; static uint16_t deinterleaver[192][4][18448]; -static int k0_vec[SRSLTE_NOF_TC_CB_SIZES][4][2]; +static int k0_vec[SRSRAN_NOF_TC_CB_SIZES][4][2]; static bool rm_turbo_tables_generated = false; // Store deinterleaver version for sub-block turbo decoder -#if SRSLTE_TDEC_EXPECT_INPUT_SB == 1 +#if SRSRAN_TDEC_EXPECT_INPUT_SB == 1 // Prepare bit for sub-block decoder processing. These are the nof subblock sizes #define NOF_DEINTER_TABLE_SB_IDX 3 const static int deinter_table_sb_idx[NOF_DEINTER_TABLE_SB_IDX] = {8, 16, 32}; @@ -93,7 +93,7 @@ static uint16_t deinterleaver_sb[NOF_DEINTER_TABLE_SB_IDX][192][4][18448]; static uint16_t temp_table1[3 * 6176], temp_table2[3 * 6176]; -static void srslte_rm_turbo_gentable_systematic(uint16_t* table_bits, int k0_vec_[4][2], uint32_t nrows, int ndummy) +static void srsran_rm_turbo_gentable_systematic(uint16_t* table_bits, int k0_vec_[4][2], uint32_t nrows, int ndummy) { bool last_is_null = true; int k_b = 0, buff_idx = 0; @@ -119,7 +119,7 @@ static void srslte_rm_turbo_gentable_systematic(uint16_t* table_bits, int k0_vec } static void -srslte_rm_turbo_gentable_parity(uint16_t* table_parity, int k0_vec_[4][2], int offset, uint16_t nrows, int ndummy) +srsran_rm_turbo_gentable_parity(uint16_t* table_parity, int k0_vec_[4][2], int offset, uint16_t nrows, int ndummy) { bool last_is_null = true; int k_b = 0, buff_idx0 = 0; @@ -163,7 +163,7 @@ srslte_rm_turbo_gentable_parity(uint16_t* table_parity, int k0_vec_[4][2], int o } } -static void srslte_rm_turbo_gentable_receive(uint16_t* table, uint32_t cb_len, uint32_t rv_idx) +static void srsran_rm_turbo_gentable_receive(uint16_t* table, uint32_t cb_len, uint32_t rv_idx) { int nrows = (uint32_t)(cb_len / 3 - 1) / NCOLS + 1; int ndummy = nrows * NCOLS - cb_len / 3; @@ -237,7 +237,7 @@ static void srslte_rm_turbo_gentable_receive(uint16_t* table, uint32_t cb_len, u table[i] = temp_table2[temp_table1[i]]; } } -#if SRSLTE_TDEC_EXPECT_INPUT_SB == 1 +#if SRSRAN_TDEC_EXPECT_INPUT_SB == 1 #define inter(x, win) ((x % (long_cb / win)) * (win) + x / (long_cb / win)) /* Prepare output for sliding window decoder: @@ -250,7 +250,7 @@ static void srslte_rm_turbo_gentable_receive(uint16_t* table, uint32_t cb_len, u */ static void interleave_table_sb(uint16_t* in, uint16_t* out, uint32_t cb_idx, uint32_t nof_sb) { - int long_cb = srslte_cbsegm_cbsize(cb_idx); + int long_cb = srsran_cbsegm_cbsize(cb_idx); int out_len = 3 * long_cb + 12; for (int i = 0; i < out_len; i++) { // Do not change tail bit order @@ -264,12 +264,12 @@ static void interleave_table_sb(uint16_t* in, uint16_t* out, uint32_t cb_idx, ui } #endif -void srslte_rm_turbo_gentables() +void srsran_rm_turbo_gentables() { if (!rm_turbo_tables_generated) { rm_turbo_tables_generated = true; - for (int cb_idx = 0; cb_idx < SRSLTE_NOF_TC_CB_SIZES; cb_idx++) { - int cb_len = srslte_cbsegm_cbsize(cb_idx); + for (int cb_idx = 0; cb_idx < SRSRAN_NOF_TC_CB_SIZES; cb_idx++) { + int cb_len = srsran_cbsegm_cbsize(cb_idx); int in_len = 3 * cb_len + 12; int nrows = (in_len / 3 - 1) / NCOLS + 1; @@ -283,20 +283,20 @@ void srslte_rm_turbo_gentables() k0_vec[cb_idx][i][0] = nrows * (2 * (uint16_t)ceilf((float)(3 * K_p) / (float)(8 * nrows)) * i + 2); k0_vec[cb_idx][i][1] = -1; } - srslte_rm_turbo_gentable_systematic(interleaver_systematic_bits[cb_idx], k0_vec[cb_idx], nrows, ndummy); - srslte_bit_interleaver_init(&bit_interleavers_systematic_bits[cb_idx], + srsran_rm_turbo_gentable_systematic(interleaver_systematic_bits[cb_idx], k0_vec[cb_idx], nrows, ndummy); + srsran_bit_interleaver_init(&bit_interleavers_systematic_bits[cb_idx], interleaver_systematic_bits[cb_idx], - (uint32_t)srslte_cbsegm_cbsize(cb_idx) + 4); + (uint32_t)srsran_cbsegm_cbsize(cb_idx) + 4); - srslte_rm_turbo_gentable_parity(interleaver_parity_bits[cb_idx], k0_vec[cb_idx], in_len / 3, nrows, ndummy); - srslte_bit_interleaver_init(&bit_interleavers_parity_bits[cb_idx], + srsran_rm_turbo_gentable_parity(interleaver_parity_bits[cb_idx], k0_vec[cb_idx], in_len / 3, nrows, ndummy); + srsran_bit_interleaver_init(&bit_interleavers_parity_bits[cb_idx], interleaver_parity_bits[cb_idx], - (uint32_t)(srslte_cbsegm_cbsize(cb_idx) + 4) * 2); + (uint32_t)(srsran_cbsegm_cbsize(cb_idx) + 4) * 2); for (int i = 0; i < 4; i++) { - srslte_rm_turbo_gentable_receive(deinterleaver[cb_idx][i], in_len, i); + srsran_rm_turbo_gentable_receive(deinterleaver[cb_idx][i], in_len, i); -#if SRSLTE_TDEC_EXPECT_INPUT_SB == 1 +#if SRSRAN_TDEC_EXPECT_INPUT_SB == 1 for (uint32_t s = 0; s < NOF_DEINTER_TABLE_SB_IDX; s++) { interleave_table_sb( deinterleaver[cb_idx][i], deinterleaver_sb[s][cb_idx][i], cb_idx, deinter_table_sb_idx[s]); @@ -307,12 +307,12 @@ void srslte_rm_turbo_gentables() } } -void srslte_rm_turbo_free_tables() +void srsran_rm_turbo_free_tables() { if (rm_turbo_tables_generated) { - for (int i = 0; i < SRSLTE_NOF_TC_CB_SIZES; i++) { - srslte_bit_interleaver_free(&bit_interleavers_systematic_bits[i]); - srslte_bit_interleaver_free(&bit_interleavers_parity_bits[i]); + for (int i = 0; i < SRSRAN_NOF_TC_CB_SIZES; i++) { + srsran_bit_interleaver_free(&bit_interleavers_systematic_bits[i]); + srsran_bit_interleaver_free(&bit_interleavers_parity_bits[i]); } rm_turbo_tables_generated = false; } @@ -333,7 +333,7 @@ void srslte_rm_turbo_free_tables() * * @return Error code */ -int srslte_rm_turbo_tx_lut(uint8_t* w_buff, +int srsran_rm_turbo_tx_lut(uint8_t* w_buff, uint8_t* systematic, uint8_t* parity, uint8_t* output, @@ -342,18 +342,18 @@ int srslte_rm_turbo_tx_lut(uint8_t* w_buff, uint32_t w_offset, uint32_t rv_idx) { - if (rv_idx < 4 && cb_idx < SRSLTE_NOF_TC_CB_SIZES) { - int in_len = 3 * srslte_cbsegm_cbsize(cb_idx) + 12; + if (rv_idx < 4 && cb_idx < SRSRAN_NOF_TC_CB_SIZES) { + int in_len = 3 * srsran_cbsegm_cbsize(cb_idx) + 12; /* Sub-block interleaver (5.1.4.1.1) and bit collection */ if (rv_idx == 0) { // Systematic bits - // srslte_bit_interleave(systematic, w_buff, interleaver_systematic_bits[cb_idx], in_len/3); - srslte_bit_interleaver_run(&bit_interleavers_systematic_bits[cb_idx], systematic, w_buff, 0); + // srsran_bit_interleave(systematic, w_buff, interleaver_systematic_bits[cb_idx], in_len/3); + srsran_bit_interleaver_run(&bit_interleavers_systematic_bits[cb_idx], systematic, w_buff, 0); // Parity bits - // srslte_bit_interleave_w_offset(parity, &w_buff[in_len/24], interleaver_parity_bits[cb_idx], 2*in_len/3, 4); - srslte_bit_interleaver_run(&bit_interleavers_parity_bits[cb_idx], parity, &w_buff[in_len / 24], 4); + // srsran_bit_interleave_w_offset(parity, &w_buff[in_len/24], interleaver_parity_bits[cb_idx], 2*in_len/3, 4); + srsran_bit_interleaver_run(&bit_interleavers_parity_bits[cb_idx], parity, &w_buff[in_len / 24], 4); } /* Bit selection and transmission 5.1.4.1.2 */ @@ -364,7 +364,7 @@ int srslte_rm_turbo_tx_lut(uint8_t* w_buff, if (cp_len + r_ptr >= in_len) { cp_len = in_len - r_ptr; } - srslte_bit_copy(output, w_len + w_offset, w_buff, r_ptr, cp_len); + srsran_bit_copy(output, w_len + w_offset, w_buff, r_ptr, cp_len); r_ptr += cp_len; if (r_ptr >= in_len) { r_ptr -= in_len; @@ -374,41 +374,41 @@ int srslte_rm_turbo_tx_lut(uint8_t* w_buff, return 0; } else { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } } -int srslte_rm_turbo_rx_lut(int16_t* input, int16_t* output, uint32_t in_len, uint32_t cb_idx, uint32_t rv_idx) +int srsran_rm_turbo_rx_lut(int16_t* input, int16_t* output, uint32_t in_len, uint32_t cb_idx, uint32_t rv_idx) { - return srslte_rm_turbo_rx_lut_(input, output, in_len, cb_idx, rv_idx, true); + return srsran_rm_turbo_rx_lut_(input, output, in_len, cb_idx, rv_idx, true); } /** * Undoes rate matching for LTE Turbo Coder. Expands rate matched buffer to full size buffer. * * @param[in] input Input buffer of size in_len - * @param[out] output Output buffer of size 3*srslte_cbsegm_cbsize(cb_idx)+12 + * @param[out] output Output buffer of size 3*srsran_cbsegm_cbsize(cb_idx)+12 * @param[in] cb_idx Code block table index * @param[in] rv_idx Redundancy Version from DCI control message * @return Error code */ -int srslte_rm_turbo_rx_lut_(int16_t* input, +int srsran_rm_turbo_rx_lut_(int16_t* input, int16_t* output, uint32_t in_len, uint32_t cb_idx, uint32_t rv_idx, bool enable_input_tdec) { - if (rv_idx < 4 && cb_idx < SRSLTE_NOF_TC_CB_SIZES) { -#if SRSLTE_TDEC_EXPECT_INPUT_SB == 1 - int cb_len = srslte_cbsegm_cbsize(cb_idx); - int idx = deinter_table_idx_from_sb_len(srslte_tdec_autoimp_get_subblocks(cb_len)); + if (rv_idx < 4 && cb_idx < SRSRAN_NOF_TC_CB_SIZES) { +#if SRSRAN_TDEC_EXPECT_INPUT_SB == 1 + int cb_len = srsran_cbsegm_cbsize(cb_idx); + int idx = deinter_table_idx_from_sb_len(srsran_tdec_autoimp_get_subblocks(cb_len)); uint16_t* deinter = NULL; if (idx < 0 || !enable_input_tdec) { deinter = deinterleaver[cb_idx][rv_idx]; } else if (idx < NOF_DEINTER_TABLE_SB_IDX) { deinter = deinterleaver_sb[idx][cb_idx][rv_idx]; } else { - ERROR("Sub-block size index %d not supported in srslte_rm_turbo_rx_lut()", idx); + ERROR("Sub-block size index %d not supported in srsran_rm_turbo_rx_lut()", idx); return -1; } #else @@ -416,12 +416,12 @@ int srslte_rm_turbo_rx_lut_(int16_t* input, #endif #ifdef LV_HAVE_AVX - return srslte_rm_turbo_rx_lut_avx(input, output, deinter, in_len, cb_idx, rv_idx); + return srsran_rm_turbo_rx_lut_avx(input, output, deinter, in_len, cb_idx, rv_idx); #else #ifdef LV_HAVE_SSE - return srslte_rm_turbo_rx_lut_sse(input, output, deinter, in_len, cb_idx, rv_idx); + return srsran_rm_turbo_rx_lut_sse(input, output, deinter, in_len, cb_idx, rv_idx); #else - uint32_t out_len = 3 * srslte_cbsegm_cbsize(cb_idx) + 12; + uint32_t out_len = 3 * srsran_cbsegm_cbsize(cb_idx) + 12; for (int i = 0; i < in_len; i++) { output[deinter[i % out_len]] += input[i]; @@ -431,23 +431,23 @@ int srslte_rm_turbo_rx_lut_(int16_t* input, #endif } else { printf("Invalid inputs rv_idx=%d, cb_idx=%d\n", rv_idx, cb_idx); - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } } -int srslte_rm_turbo_rx_lut_8bit(int8_t* input, int8_t* output, uint32_t in_len, uint32_t cb_idx, uint32_t rv_idx) +int srsran_rm_turbo_rx_lut_8bit(int8_t* input, int8_t* output, uint32_t in_len, uint32_t cb_idx, uint32_t rv_idx) { - if (rv_idx < 4 && cb_idx < SRSLTE_NOF_TC_CB_SIZES) { -#if SRSLTE_TDEC_EXPECT_INPUT_SB == 1 - int cb_len = srslte_cbsegm_cbsize(cb_idx); - int idx = deinter_table_idx_from_sb_len(srslte_tdec_autoimp_get_subblocks_8bit(cb_len)); + if (rv_idx < 4 && cb_idx < SRSRAN_NOF_TC_CB_SIZES) { +#if SRSRAN_TDEC_EXPECT_INPUT_SB == 1 + int cb_len = srsran_cbsegm_cbsize(cb_idx); + int idx = deinter_table_idx_from_sb_len(srsran_tdec_autoimp_get_subblocks_8bit(cb_len)); uint16_t* deinter = NULL; if (idx < 0) { deinter = deinterleaver[cb_idx][rv_idx]; } else if (idx < NOF_DEINTER_TABLE_SB_IDX) { deinter = deinterleaver_sb[idx][cb_idx][rv_idx]; } else { - ERROR("Sub-block size index %d not supported in srslte_rm_turbo_rx_lut()", idx); + ERROR("Sub-block size index %d not supported in srsran_rm_turbo_rx_lut()", idx); return -1; } #else @@ -458,9 +458,9 @@ int srslte_rm_turbo_rx_lut_8bit(int8_t* input, int8_t* output, uint32_t in_len, // Warning: Need to check if 8-bit sse version is correct #ifdef LV_HAVE_SSE - return srslte_rm_turbo_rx_lut_sse_8bit(input, output, deinter, in_len, cb_idx, rv_idx); + return srsran_rm_turbo_rx_lut_sse_8bit(input, output, deinter, in_len, cb_idx, rv_idx); #else - uint32_t out_len = 3 * srslte_cbsegm_cbsize(cb_idx) + 12; + uint32_t out_len = 3 * srsran_cbsegm_cbsize(cb_idx) + 12; for (int i = 0; i < in_len; i++) { output[deinter[i % out_len]] += input[i]; @@ -469,7 +469,7 @@ int srslte_rm_turbo_rx_lut_8bit(int8_t* input, int8_t* output, uint32_t in_len, #endif } else { printf("Invalid inputs rv_idx=%d, cb_idx=%d\n", rv_idx, cb_idx); - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } } @@ -480,15 +480,15 @@ int srslte_rm_turbo_rx_lut_8bit(int8_t* input, int8_t* output, uint32_t in_len, l = (uint16_t)_mm_extract_epi16(lutVal, j); \ output[l] += x; -int srslte_rm_turbo_rx_lut_sse(int16_t* input, +int srsran_rm_turbo_rx_lut_sse(int16_t* input, int16_t* output, uint16_t* deinter, uint32_t in_len, uint32_t cb_idx, uint32_t rv_idx) { - if (rv_idx < 4 && cb_idx < SRSLTE_NOF_TC_CB_SIZES) { - uint32_t out_len = 3 * srslte_cbsegm_cbsize(cb_idx) + 12; + if (rv_idx < 4 && cb_idx < SRSRAN_NOF_TC_CB_SIZES) { + uint32_t out_len = 3 * srsran_cbsegm_cbsize(cb_idx) + 12; const __m128i* xPtr = (const __m128i*)input; const __m128i* lutPtr = (const __m128i*)deinter; @@ -560,7 +560,7 @@ int srslte_rm_turbo_rx_lut_sse(int16_t* input, return 0; } else { printf("Invalid inputs rv_idx=%d, cb_idx=%d\n", rv_idx, cb_idx); - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } } @@ -574,15 +574,15 @@ int srslte_rm_turbo_rx_lut_sse(int16_t* input, l = (uint16_t)_mm_extract_epi16(lutVal2, j); \ output[l] += x; -int srslte_rm_turbo_rx_lut_sse_8bit(int8_t* input, +int srsran_rm_turbo_rx_lut_sse_8bit(int8_t* input, int8_t* output, uint16_t* deinter, uint32_t in_len, uint32_t cb_idx, uint32_t rv_idx) { - if (rv_idx < 4 && cb_idx < SRSLTE_NOF_TC_CB_SIZES) { - uint32_t out_len = 3 * srslte_cbsegm_cbsize(cb_idx) + 12; + if (rv_idx < 4 && cb_idx < SRSRAN_NOF_TC_CB_SIZES) { + uint32_t out_len = 3 * srsran_cbsegm_cbsize(cb_idx) + 12; const __m128i* xPtr = (const __m128i*)input; const __m128i* lutPtr = (const __m128i*)deinter; @@ -682,7 +682,7 @@ int srslte_rm_turbo_rx_lut_sse_8bit(int8_t* input, return 0; } else { printf("Invalid inputs rv_idx=%d, cb_idx=%d\n", rv_idx, cb_idx); - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } } @@ -695,15 +695,15 @@ int srslte_rm_turbo_rx_lut_sse_8bit(int8_t* input, l = (uint16_t)_mm256_extract_epi16(lutVal, j); \ output[l] += x; -int srslte_rm_turbo_rx_lut_avx(int16_t* input, +int srsran_rm_turbo_rx_lut_avx(int16_t* input, int16_t* output, uint16_t* deinter, uint32_t in_len, uint32_t cb_idx, uint32_t rv_idx) { - if (rv_idx < 4 && cb_idx < SRSLTE_NOF_TC_CB_SIZES) { - uint32_t out_len = 3 * srslte_cbsegm_cbsize(cb_idx) + 12; + if (rv_idx < 4 && cb_idx < SRSRAN_NOF_TC_CB_SIZES) { + uint32_t out_len = 3 * srsran_cbsegm_cbsize(cb_idx) + 12; const __m256i* xPtr = (const __m256i*)input; const __m256i* lutPtr = (const __m256i*)deinter; @@ -797,7 +797,7 @@ int srslte_rm_turbo_rx_lut_avx(int16_t* input, return 0; } else { printf("Invalid inputs rv_idx=%d, cb_idx=%d\n", rv_idx, cb_idx); - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } } @@ -811,15 +811,15 @@ int srslte_rm_turbo_rx_lut_avx(int16_t* input, l = (uint16_t)_mm256_extract_epi16(lutVal2, j); \ output[l] += x; -int srslte_rm_turbo_rx_lut_avx_8bit(int8_t* input, +int srsran_rm_turbo_rx_lut_avx_8bit(int8_t* input, int8_t* output, uint16_t* deinter, uint32_t in_len, uint32_t cb_idx, uint32_t rv_idx) { - if (rv_idx < 4 && cb_idx < SRSLTE_NOF_TC_CB_SIZES) { - uint32_t out_len = 3 * srslte_cbsegm_cbsize(cb_idx) + 12; + if (rv_idx < 4 && cb_idx < SRSRAN_NOF_TC_CB_SIZES) { + uint32_t out_len = 3 * srsran_cbsegm_cbsize(cb_idx) + 12; const __m256i* xPtr = (const __m256i*)input; const __m256i* lutPtr = (const __m256i*)deinter; @@ -951,7 +951,7 @@ int srslte_rm_turbo_rx_lut_avx_8bit(int8_t* input, return 0; } else { printf("Invalid inputs rv_idx=%d, cb_idx=%d\n", rv_idx, cb_idx); - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } } @@ -969,7 +969,7 @@ int srslte_rm_turbo_rx_lut_avx_8bit(int8_t* input, * * TODO: Soft buffer size limitation according to UE category */ -int srslte_rm_turbo_tx(uint8_t* w_buff, +int srsran_rm_turbo_tx(uint8_t* w_buff, uint32_t w_buff_len, uint8_t* input, uint32_t in_len, @@ -1016,7 +1016,7 @@ int srslte_rm_turbo_tx(uint8_t* w_buff, kidx = K_p + 2 * (k % K_p); } if (i * NCOLS + RM_PERM_TC[j] < ndummy) { - w_buff[kidx] = SRSLTE_TX_NULL; + w_buff[kidx] = SRSRAN_TX_NULL; } else { w_buff[kidx] = input[(i * NCOLS + RM_PERM_TC[j] - ndummy) * 3 + s]; } @@ -1029,7 +1029,7 @@ int srslte_rm_turbo_tx(uint8_t* w_buff, for (k = 0; k < K_p; k++) { kidx = (RM_PERM_TC[k / nrows] + NCOLS * (k % nrows) + 1) % K_p; if ((kidx - ndummy) < 0) { - w_buff[K_p + 2 * k + 1] = SRSLTE_TX_NULL; + w_buff[K_p + 2 * k + 1] = SRSRAN_TX_NULL; } else { w_buff[K_p + 2 * k + 1] = input[3 * (kidx - ndummy) + 2]; } @@ -1044,7 +1044,7 @@ int srslte_rm_turbo_tx(uint8_t* w_buff, j = 0; while (k < out_len) { - if (w_buff[(k0 + j) % N_cb] != SRSLTE_TX_NULL) { + if (w_buff[(k0 + j) % N_cb] != SRSRAN_TX_NULL) { output[k] = w_buff[(k0 + j) % N_cb]; k++; } @@ -1058,7 +1058,7 @@ int srslte_rm_turbo_tx(uint8_t* w_buff, * * Soft-combines the data available in w_buff */ -int srslte_rm_turbo_rx(float* w_buff, +int srsran_rm_turbo_rx(float* w_buff, uint32_t w_buff_len, float* input, uint32_t in_len, @@ -1129,9 +1129,9 @@ int srslte_rm_turbo_rx(float* w_buff, } if (!isdummy) { - if (w_buff[jp] == SRSLTE_RX_NULL) { + if (w_buff[jp] == SRSRAN_RX_NULL) { w_buff[jp] = input[k]; - } else if (input[k] != SRSLTE_RX_NULL) { + } else if (input[k] != SRSRAN_RX_NULL) { w_buff[jp] += input[k]; /* soft combine LLRs */ } k++; @@ -1140,7 +1140,7 @@ int srslte_rm_turbo_rx(float* w_buff, } // printf("wbuff:\n"); - // srslte_vec_fprint_f(stdout, w_buff, out_len); + // srsran_vec_fprint_f(stdout, w_buff, out_len); /* interleaving and bit selection */ for (i = 0; i < out_len / 3; i++) { @@ -1156,7 +1156,7 @@ int srslte_rm_turbo_rx(float* w_buff, kidx = (k / NCOLS + nrows * RM_PERM_TC[k % NCOLS]) % K_p; kidx = 2 * kidx + K_p + 1; } - if (w_buff[kidx] != SRSLTE_RX_NULL) { + if (w_buff[kidx] != SRSRAN_RX_NULL) { output[i * 3 + j] = w_buff[kidx]; } else { output[i * 3 + j] = 0; diff --git a/lib/src/phy/fec/turbo/tc_interl_lte.c b/lib/src/phy/fec/turbo/tc_interl_lte.c index ebf80ee51..224ba5622 100644 --- a/lib/src/phy/fec/turbo/tc_interl_lte.c +++ b/lib/src/phy/fec/turbo/tc_interl_lte.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -14,12 +14,12 @@ #include #include -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/fec/cbsegm.h" -#include "srslte/phy/fec/turbo/tc_interl.h" -#include "srslte/phy/fec/turbo/turbocoder.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/fec/cbsegm.h" +#include "srsran/phy/fec/turbo/tc_interl.h" +#include "srsran/phy/fec/turbo/turbocoder.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" /************************************************ * @@ -27,7 +27,7 @@ * ************************************************/ -const uint32_t f1_list[SRSLTE_NOF_TC_CB_SIZES] = { +const uint32_t f1_list[SRSRAN_NOF_TC_CB_SIZES] = { 3, 7, 19, 7, 7, 11, 5, 11, 7, 41, 103, 15, 9, 17, 9, 21, 101, 21, 57, 23, 13, 27, 11, 27, 85, 29, 33, 15, 17, 33, 103, 19, 19, 37, 19, 21, 21, 115, 193, 21, 133, 81, 45, 23, 243, 151, 155, 25, 51, 47, 91, 29, 29, 247, 29, 89, 91, 157, 55, 31, 17, 35, 227, @@ -38,7 +38,7 @@ const uint32_t f1_list[SRSLTE_NOF_TC_CB_SIZES] = { 57, 313, 271, 179, 331, 363, 375, 127, 31, 33, 43, 33, 477, 35, 233, 357, 337, 37, 71, 71, 37, 39, 127, 39, 39, 31, 113, 41, 251, 43, 21, 43, 45, 45, 161, 89, 323, 47, 23, 47, 263}; -const uint32_t f2_list[SRSLTE_NOF_TC_CB_SIZES] = { +const uint32_t f2_list[SRSRAN_NOF_TC_CB_SIZES] = { 10, 12, 42, 16, 18, 20, 22, 24, 26, 84, 90, 32, 34, 108, 38, 120, 84, 44, 46, 48, 50, 52, 36, 56, 58, 60, 62, 32, 198, 68, 210, 36, 74, 76, 78, 120, 82, 84, 86, 44, 90, 46, 94, 48, 98, 40, 102, 52, 106, 72, 110, 168, 114, 58, 118, 180, 122, 62, 84, 64, 66, 68, 420, @@ -49,15 +49,15 @@ const uint32_t f2_list[SRSLTE_NOF_TC_CB_SIZES] = { 336, 228, 232, 236, 120, 244, 248, 168, 64, 130, 264, 134, 408, 138, 280, 142, 480, 146, 444, 120, 152, 462, 234, 158, 80, 96, 902, 166, 336, 170, 86, 174, 176, 178, 120, 182, 184, 186, 94, 190, 480}; -int srslte_tc_interl_LTE_gen(srslte_tc_interl_t* h, uint32_t long_cb) +int srsran_tc_interl_LTE_gen(srsran_tc_interl_t* h, uint32_t long_cb) { - return srslte_tc_interl_LTE_gen_interl(h, long_cb, 1); + return srsran_tc_interl_LTE_gen_interl(h, long_cb, 1); } #define deinter(x, win) ((x % (long_cb / win)) * (win) + x / (long_cb / win)) #define inter(x, win) ((x % win) * (long_cb / win) + x / win) -int srslte_tc_interl_LTE_gen_interl(srslte_tc_interl_t* h, uint32_t long_cb, uint32_t interl_win) +int srsran_tc_interl_LTE_gen_interl(srsran_tc_interl_t* h, uint32_t long_cb, uint32_t interl_win) { uint32_t cb_table_idx, f1, f2; uint64_t i, j; @@ -67,7 +67,7 @@ int srslte_tc_interl_LTE_gen_interl(srslte_tc_interl_t* h, uint32_t long_cb, uin return -1; } - cb_table_idx = srslte_cbsegm_cbindex(long_cb); + cb_table_idx = srsran_cbsegm_cbindex(long_cb); if (cb_table_idx == -1) { ERROR("Can't find long_cb=%d in valid TC CB table", long_cb); return -1; @@ -84,8 +84,8 @@ int srslte_tc_interl_LTE_gen_interl(srslte_tc_interl_t* h, uint32_t long_cb, uin h->reverse[j] = (uint32_t)i; } if (interl_win != 1) { - uint16_t* f = srslte_vec_u16_malloc(long_cb); - uint16_t* r = srslte_vec_u16_malloc(long_cb); + uint16_t* f = srsran_vec_u16_malloc(long_cb); + uint16_t* r = srsran_vec_u16_malloc(long_cb); memcpy(f, h->forward, long_cb * sizeof(uint16_t)); memcpy(r, h->reverse, long_cb * sizeof(uint16_t)); for (i = 0; i < long_cb; i++) { diff --git a/lib/src/phy/fec/turbo/tc_interl_umts.c b/lib/src/phy/fec/turbo/tc_interl_umts.c index 8eca86e26..3d3405366 100644 --- a/lib/src/phy/fec/turbo/tc_interl_umts.c +++ b/lib/src/phy/fec/turbo/tc_interl_umts.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -15,11 +15,11 @@ #include #include -#include "srslte/phy/fec/turbo/tc_interl.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/fec/turbo/tc_interl.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" -#define TURBO_SRSLTE_TCOD_RATE 3 +#define TURBO_SRSRAN_TCOD_RATE 3 uint32_t mcd(uint32_t x, uint32_t y); @@ -39,15 +39,15 @@ const unsigned short table_p[52] = {7, 11, 13, 17, 19, 23, 29, 31, 37, const uint8_t table_v[52] = {3, 2, 2, 3, 2, 5, 2, 3, 2, 6, 3, 5, 2, 2, 2, 2, 7, 5, 3, 2, 3, 5, 2, 5, 2, 6, 3, 3, 2, 3, 2, 2, 6, 5, 2, 5, 2, 2, 2, 19, 5, 2, 3, 2, 3, 2, 6, 3, 7, 7, 6, 3}; -int srslte_tc_interl_init(srslte_tc_interl_t* h, uint32_t max_long_cb) +int srsran_tc_interl_init(srsran_tc_interl_t* h, uint32_t max_long_cb) { int ret = -1; - h->forward = srslte_vec_u16_malloc(max_long_cb); + h->forward = srsran_vec_u16_malloc(max_long_cb); if (!h->forward) { perror("malloc"); goto clean_exit; } - h->reverse = srslte_vec_u16_malloc(max_long_cb); + h->reverse = srsran_vec_u16_malloc(max_long_cb); if (!h->reverse) { perror("malloc"); goto clean_exit; @@ -56,12 +56,12 @@ int srslte_tc_interl_init(srslte_tc_interl_t* h, uint32_t max_long_cb) ret = 0; clean_exit: if (ret == -1) { - srslte_tc_interl_free(h); + srsran_tc_interl_free(h); } return ret; } -void srslte_tc_interl_free(srslte_tc_interl_t* h) +void srsran_tc_interl_free(srsran_tc_interl_t* h) { if (h->forward) { free(h->forward); @@ -69,10 +69,10 @@ void srslte_tc_interl_free(srslte_tc_interl_t* h) if (h->reverse) { free(h->reverse); } - bzero(h, sizeof(srslte_tc_interl_t)); + bzero(h, sizeof(srsran_tc_interl_t)); } -int srslte_tc_interl_UMTS_gen(srslte_tc_interl_t* h, uint32_t long_cb) +int srsran_tc_interl_UMTS_gen(srsran_tc_interl_t* h, uint32_t long_cb) { uint32_t i, j; diff --git a/lib/src/phy/fec/turbo/test/CMakeLists.txt b/lib/src/phy/fec/turbo/test/CMakeLists.txt index 5163bc13e..0bea5d78f 100644 --- a/lib/src/phy/fec/turbo/test/CMakeLists.txt +++ b/lib/src/phy/fec/turbo/test/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -13,10 +13,10 @@ set(CTEST_LABELS "lib;phy;fec;turbo") ######################################################################## add_executable(rm_conv_test rm_conv_test.c) -target_link_libraries(rm_conv_test srslte_phy) +target_link_libraries(rm_conv_test srsran_phy) add_executable(rm_turbo_test rm_turbo_test.c) -target_link_libraries(rm_turbo_test srslte_phy) +target_link_libraries(rm_turbo_test srsran_phy) add_lte_test(rm_conv_test_1 rm_conv_test -t 480 -r 1920) add_lte_test(rm_conv_test_2 rm_conv_test -t 1920 -r 480) @@ -28,7 +28,7 @@ add_lte_test(rm_turbo_test_2 rm_turbo_test -e 8192) # Turbo Coder TEST ######################################################################## add_executable(turbodecoder_test turbodecoder_test.c) -target_link_libraries(turbodecoder_test srslte_phy) +target_link_libraries(turbodecoder_test srsran_phy) add_lte_test(turbodecoder_test_504_1 turbodecoder_test -n 100 -s 1 -l 504 -e 1.0 -t) add_lte_test(turbodecoder_test_504_2 turbodecoder_test -n 100 -s 1 -l 504 -e 2.0 -t) @@ -36,5 +36,5 @@ add_lte_test(turbodecoder_test_6114_1_5 turbodecoder_test -n 100 -s 1 -l 6144 -e add_lte_test(turbodecoder_test_known turbodecoder_test -n 1 -s 1 -k -e 0.5) add_executable(turbocoder_test turbocoder_test.c) -target_link_libraries(turbocoder_test srslte_phy) +target_link_libraries(turbocoder_test srsran_phy) add_lte_test(turbocoder_test_all turbocoder_test) diff --git a/lib/src/phy/fec/turbo/test/rm_conv_test.c b/lib/src/phy/fec/turbo/test/rm_conv_test.c index 3f40fd976..50d73d233 100644 --- a/lib/src/phy/fec/turbo/test/rm_conv_test.c +++ b/lib/src/phy/fec/turbo/test/rm_conv_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -19,7 +19,7 @@ #include #include -#include "srslte/srslte.h" +#include "srsran/srsran.h" static uint32_t nof_tx_bits = 0; static uint32_t nof_rx_bits = 0; @@ -64,22 +64,22 @@ int main(int argc, char** argv) parse_args(argc, argv); - bits = srslte_vec_u8_malloc(nof_tx_bits); + bits = srsran_vec_u8_malloc(nof_tx_bits); if (!bits) { perror("malloc"); exit(-1); } - rm_bits = srslte_vec_u8_malloc(nof_rx_bits); + rm_bits = srsran_vec_u8_malloc(nof_rx_bits); if (!rm_bits) { perror("malloc"); exit(-1); } - rm_symbols = srslte_vec_f_malloc(nof_rx_bits); + rm_symbols = srsran_vec_f_malloc(nof_rx_bits); if (!rm_symbols) { perror("malloc"); exit(-1); } - unrm_symbols = srslte_vec_f_malloc(nof_tx_bits); + unrm_symbols = srsran_vec_f_malloc(nof_tx_bits); if (!unrm_symbols) { perror("malloc"); exit(-1); @@ -89,7 +89,7 @@ int main(int argc, char** argv) bits[i] = rand() % 2; } - if (srslte_rm_conv_tx(bits, nof_tx_bits, rm_bits, nof_rx_bits)) { + if (srsran_rm_conv_tx(bits, nof_tx_bits, rm_bits, nof_rx_bits)) { exit(-1); } @@ -97,7 +97,7 @@ int main(int argc, char** argv) rm_symbols[i] = rm_bits[i] ? 1 : -1; } - if (srslte_rm_conv_rx(rm_symbols, nof_rx_bits, unrm_symbols, nof_tx_bits)) { + if (srsran_rm_conv_rx(rm_symbols, nof_rx_bits, unrm_symbols, nof_tx_bits)) { exit(-1); } diff --git a/lib/src/phy/fec/turbo/test/rm_turbo_test.c b/lib/src/phy/fec/turbo/test/rm_turbo_test.c index 3d987c529..d38590299 100644 --- a/lib/src/phy/fec/turbo/test/rm_turbo_test.c +++ b/lib/src/phy/fec/turbo/test/rm_turbo_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -19,7 +19,7 @@ #include #include -#include "srslte/srslte.h" +#include "srsran/srsran.h" uint32_t nof_e_bits = 0; uint32_t rv_idx = 0; @@ -75,29 +75,29 @@ int main(int argc, char** argv) parse_args(argc, argv); - srslte_rm_turbo_gentables(); + srsran_rm_turbo_gentables(); - rm_bits_s = srslte_vec_i16_malloc(nof_e_bits); + rm_bits_s = srsran_vec_i16_malloc(nof_e_bits); if (!rm_bits_s) { perror("malloc"); exit(-1); } - rm_bits_f = srslte_vec_f_malloc(nof_e_bits); + rm_bits_f = srsran_vec_f_malloc(nof_e_bits); if (!rm_bits_f) { perror("malloc"); exit(-1); } - rm_bits = srslte_vec_u8_malloc(nof_e_bits); + rm_bits = srsran_vec_u8_malloc(nof_e_bits); if (!rm_bits) { perror("malloc"); exit(-1); } - rm_bits2 = srslte_vec_u8_malloc(nof_e_bits); + rm_bits2 = srsran_vec_u8_malloc(nof_e_bits); if (!rm_bits2) { perror("malloc"); exit(-1); } - rm_bits2_bytes = srslte_vec_u8_malloc(nof_e_bits / 8 + 1); + rm_bits2_bytes = srsran_vec_u8_malloc(nof_e_bits / 8 + 1); if (!rm_bits2_bytes) { perror("malloc"); exit(-1); @@ -116,7 +116,7 @@ int main(int argc, char** argv) for (cb_idx = st; cb_idx < end; cb_idx++) { for (rv_idx = rv_st; rv_idx < rv_end; rv_idx++) { - uint32_t long_cb_enc = 3 * srslte_cbsegm_cbsize(cb_idx) + 12; + uint32_t long_cb_enc = 3 * srsran_cbsegm_cbsize(cb_idx) + 12; printf("checking cb_idx=%3d rv_idx=%d...", cb_idx, rv_idx); @@ -126,10 +126,10 @@ int main(int argc, char** argv) bzero(buff_b, BUFFSZ * sizeof(uint8_t)); - srslte_rm_turbo_tx(buff_b, BUFFSZ, bits, long_cb_enc, rm_bits, nof_e_bits, 0); + srsran_rm_turbo_tx(buff_b, BUFFSZ, bits, long_cb_enc, rm_bits, nof_e_bits, 0); if (rv_idx > 0) { - srslte_rm_turbo_tx(buff_b, BUFFSZ, bits, long_cb_enc, rm_bits, nof_e_bits, rv_idx); + srsran_rm_turbo_tx(buff_b, BUFFSZ, bits, long_cb_enc, rm_bits, nof_e_bits, rv_idx); } for (int i = 0; i < long_cb_enc / 3; i++) { @@ -138,19 +138,19 @@ int main(int argc, char** argv) parity[i + long_cb_enc / 3] = bits[3 * i + 2]; } - srslte_bit_pack_vector(systematic, systematic_bytes, long_cb_enc / 3); - srslte_bit_pack_vector(parity, parity_bytes, 2 * long_cb_enc / 3); + srsran_bit_pack_vector(systematic, systematic_bytes, long_cb_enc / 3); + srsran_bit_pack_vector(parity, parity_bytes, 2 * long_cb_enc / 3); bzero(buff_b, BUFFSZ * sizeof(uint8_t)); bzero(rm_bits2_bytes, nof_e_bits / 8); - srslte_rm_turbo_tx_lut(buff_b, systematic_bytes, parity_bytes, rm_bits2_bytes, cb_idx, nof_e_bits, 0, 0); + srsran_rm_turbo_tx_lut(buff_b, systematic_bytes, parity_bytes, rm_bits2_bytes, cb_idx, nof_e_bits, 0, 0); if (rv_idx > 0) { bzero(rm_bits2_bytes, nof_e_bits / 8); - srslte_rm_turbo_tx_lut(buff_b, systematic_bytes, parity_bytes, rm_bits2_bytes, cb_idx, nof_e_bits, 0, rv_idx); + srsran_rm_turbo_tx_lut(buff_b, systematic_bytes, parity_bytes, rm_bits2_bytes, cb_idx, nof_e_bits, 0, rv_idx); } - srslte_bit_unpack_vector(rm_bits2_bytes, rm_bits2, nof_e_bits); + srsran_bit_unpack_vector(rm_bits2_bytes, rm_bits2, nof_e_bits); for (int i = 0; i < nof_e_bits; i++) { if (rm_bits2[i] != rm_bits[i]) { @@ -166,11 +166,11 @@ int main(int argc, char** argv) rm_bits_s[i] = (short)rm_bits_f[i]; } - srslte_vec_f_zero(buff_f, BUFFSZ); - srslte_rm_turbo_rx(buff_f, BUFFSZ, rm_bits_f, nof_e_bits, bits_f, long_cb_enc, rv_idx, 0); + srsran_vec_f_zero(buff_f, BUFFSZ); + srsran_rm_turbo_rx(buff_f, BUFFSZ, rm_bits_f, nof_e_bits, bits_f, long_cb_enc, rv_idx, 0); bzero(bits2_s, long_cb_enc * sizeof(short)); - srslte_rm_turbo_rx_lut_(rm_bits_s, bits2_s, nof_e_bits, cb_idx, rv_idx, false); + srsran_rm_turbo_rx_lut_(rm_bits_s, bits2_s, nof_e_bits, cb_idx, rv_idx, false); for (int i = 0; i < long_cb_enc; i++) { if (bits_f[i] != bits2_s[i]) { @@ -183,7 +183,7 @@ int main(int argc, char** argv) } } - srslte_rm_turbo_free_tables(); + srsran_rm_turbo_free_tables(); free(rm_bits_s); free(rm_bits_f); free(rm_bits); diff --git a/lib/src/phy/fec/turbo/test/turbocoder_test.c b/lib/src/phy/fec/turbo/test/turbocoder_test.c index a89910d56..cb31a1c3c 100644 --- a/lib/src/phy/fec/turbo/test/turbocoder_test.c +++ b/lib/src/phy/fec/turbo/test/turbocoder_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -15,8 +15,8 @@ #include #include -#include "srslte/phy/utils/random.h" -#include "srslte/srslte.h" +#include "srsran/phy/utils/random.h" +#include "srsran/srsran.h" uint32_t long_cb = 0; @@ -35,7 +35,7 @@ void parse_args(int argc, char** argv) long_cb = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'v': - srslte_verbose++; + srsran_verbose++; break; default: usage(argv[0]); @@ -53,46 +53,46 @@ uint8_t output_bits2[3 * 6144 + 12]; int main(int argc, char** argv) { - srslte_random_t random_gen = srslte_random_init(0); + srsran_random_t random_gen = srsran_random_init(0); parse_args(argc, argv); - srslte_tcod_t tcod; - srslte_tcod_init(&tcod, 6144); + srsran_tcod_t tcod; + srsran_tcod_init(&tcod, 6144); uint32_t st = 0, end = 187; if (long_cb) { - st = srslte_cbsegm_cbindex(long_cb); + st = srsran_cbsegm_cbindex(long_cb); end = st; } for (uint32_t len = st; len <= end; len++) { - long_cb = srslte_cbsegm_cbsize(len); + long_cb = srsran_cbsegm_cbsize(len); printf("Checking long_cb=%d\n", long_cb); for (int i = 0; i < long_cb / 8; i++) { - input_bytes[i] = srslte_random_uniform_int_dist(random_gen, 0, 256); + input_bytes[i] = srsran_random_uniform_int_dist(random_gen, 0, 256); } - srslte_bit_unpack_vector(input_bytes, input_bits, long_cb); + srsran_bit_unpack_vector(input_bytes, input_bits, long_cb); - if (SRSLTE_VERBOSE_ISINFO()) { + if (SRSRAN_VERBOSE_ISINFO()) { printf("Input bits:\n"); for (int i = 0; i < long_cb / 8; i++) { - srslte_vec_fprint_b(stdout, &input_bits[i * 8], 8); + srsran_vec_fprint_b(stdout, &input_bits[i * 8], 8); } } /* Create CRC for Transport Block, it is not currently used but it is required */ - srslte_crc_t crc_tb; + srsran_crc_t crc_tb; bzero(&crc_tb, sizeof(crc_tb)); - if (srslte_crc_init(&crc_tb, SRSLTE_LTE_CRC24A, 24)) { + if (srsran_crc_init(&crc_tb, SRSRAN_LTE_CRC24A, 24)) { printf("error initialising CRC\n"); exit(-1); } - srslte_tcod_encode(&tcod, input_bits, output_bits, long_cb); - srslte_tcod_encode_lut(&tcod, &crc_tb, NULL, input_bytes, parity, len, false); + srsran_tcod_encode(&tcod, input_bits, output_bits, long_cb); + srsran_tcod_encode_lut(&tcod, &crc_tb, NULL, input_bytes, parity, len, false); - srslte_bit_unpack_vector(parity, parity_bits, 2 * (long_cb + 4)); + srsran_bit_unpack_vector(parity, parity_bits, 2 * (long_cb + 4)); for (int i = 0; i < long_cb; i++) { output_bits2[3 * i] = input_bits[i]; @@ -100,9 +100,9 @@ int main(int argc, char** argv) output_bits2[3 * i + 2] = parity_bits[i + long_cb + 4]; } - if (SRSLTE_VERBOSE_ISINFO()) { - srslte_vec_fprint_b(stdout, output_bits2, 3 * long_cb); - srslte_vec_fprint_b(stdout, output_bits, 3 * long_cb); + if (SRSRAN_VERBOSE_ISINFO()) { + srsran_vec_fprint_b(stdout, output_bits2, 3 * long_cb); + srsran_vec_fprint_b(stdout, output_bits, 3 * long_cb); printf("\n"); } for (int i = 0; i < 2 * long_cb; i++) { @@ -113,8 +113,8 @@ int main(int argc, char** argv) } } - srslte_tcod_free(&tcod); - srslte_random_free(random_gen); + srsran_tcod_free(&tcod); + srsran_random_free(random_gen); printf("Done\n"); exit(0); } diff --git a/lib/src/phy/fec/turbo/test/turbodecoder_test.c b/lib/src/phy/fec/turbo/test/turbodecoder_test.c index 9538a1655..0d903ad97 100644 --- a/lib/src/phy/fec/turbo/test/turbodecoder_test.c +++ b/lib/src/phy/fec/turbo/test/turbodecoder_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -18,8 +18,8 @@ #include #include -#include "srslte/srslte.h" -#include +#include "srsran/srsran.h" +#include #include #include @@ -37,7 +37,7 @@ int test_known_data = 0; int test_errors = 0; int nof_repetitions = 1; -srslte_tdec_impl_type_t tdec_type; +srsran_tdec_impl_type_t tdec_type; #define SNR_POINTS 4 #define SNR_MIN 1.0 @@ -85,7 +85,7 @@ void parse_args(int argc, char** argv) frame_length = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'd': - tdec_type = (srslte_tdec_impl_type_t)strtol(argv[optind], NULL, 10); + tdec_type = (srsran_tdec_impl_type_t)strtol(argv[optind], NULL, 10); break; case 'e': ebno_db = strtof(argv[optind], NULL); @@ -94,7 +94,7 @@ void parse_args(int argc, char** argv) seed = (uint32_t)strtoul(argv[optind], NULL, 0); break; case 'v': - srslte_verbose++; + srsran_verbose++; break; default: usage(argv[0]); @@ -105,7 +105,7 @@ void parse_args(int argc, char** argv) int main(int argc, char** argv) { - srslte_random_t random_gen = srslte_random_init(0); + srsran_random_t random_gen = srsran_random_init(0); uint32_t frame_cnt; float* llr; short* llr_s; @@ -118,8 +118,8 @@ int main(int argc, char** argv) uint32_t coded_length; struct timeval tdata[3]; float mean_usec; - srslte_tdec_t tdec; - srslte_tcod_t tcod; + srsran_tdec_t tdec; + srsran_tcod_t tcod; parse_args(argc, argv); @@ -131,70 +131,70 @@ int main(int argc, char** argv) if (test_known_data) { frame_length = KNOWN_DATA_LEN; } else { - frame_length = srslte_cbsegm_cbsize(srslte_cbsegm_cbindex(frame_length)); + frame_length = srsran_cbsegm_cbsize(srsran_cbsegm_cbindex(frame_length)); } - coded_length = 3 * (frame_length) + SRSLTE_TCOD_TOTALTAIL; + coded_length = 3 * (frame_length) + SRSRAN_TCOD_TOTALTAIL; printf(" Frame length: %d\n", frame_length); if (ebno_db < 100.0) { printf(" EbNo: %.2f\n", ebno_db); } - data_tx = srslte_vec_u8_malloc(frame_length); + data_tx = srsran_vec_u8_malloc(frame_length); if (!data_tx) { perror("malloc"); exit(-1); } - data_rx = srslte_vec_u8_malloc(frame_length); + data_rx = srsran_vec_u8_malloc(frame_length); if (!data_rx) { perror("malloc"); exit(-1); } - data_rx_bytes = srslte_vec_u8_malloc(frame_length); + data_rx_bytes = srsran_vec_u8_malloc(frame_length); if (!data_rx_bytes) { perror("malloc"); exit(-1); } - symbols = srslte_vec_u8_malloc(coded_length); + symbols = srsran_vec_u8_malloc(coded_length); if (!symbols) { perror("malloc"); exit(-1); } - llr = srslte_vec_f_malloc(coded_length); + llr = srsran_vec_f_malloc(coded_length); if (!llr) { perror("malloc"); exit(-1); } - llr_s = srslte_vec_i16_malloc(coded_length); + llr_s = srsran_vec_i16_malloc(coded_length); if (!llr_s) { perror("malloc"); exit(-1); } - llr_c = srslte_vec_u8_malloc(coded_length); + llr_c = srsran_vec_u8_malloc(coded_length); if (!llr_c) { perror("malloc"); exit(-1); } - if (srslte_tcod_init(&tcod, frame_length)) { + if (srsran_tcod_init(&tcod, frame_length)) { ERROR("Error initiating Turbo coder"); exit(-1); } #ifdef HAVE_NEON - tdec_type = SRSLTE_TDEC_NEON_WINDOW; + tdec_type = SRSRAN_TDEC_NEON_WINDOW; #else - // tdec_type = SRSLTE_TDEC_SSE_WINDOW; + // tdec_type = SRSRAN_TDEC_SSE_WINDOW; #endif - if (srslte_tdec_init_manual(&tdec, frame_length, tdec_type)) { + if (srsran_tdec_init_manual(&tdec, frame_length, tdec_type)) { ERROR("Error initiating Turbo decoder"); exit(-1); } - srslte_tdec_force_not_sb(&tdec); + srsran_tdec_force_not_sb(&tdec); float ebno_inc, esno_db; ebno_inc = (SNR_MAX - SNR_MIN) / SNR_POINTS; @@ -202,12 +202,12 @@ int main(int argc, char** argv) snr_points = SNR_POINTS; for (i = 0; i < snr_points; i++) { ebno_db = SNR_MIN + i * ebno_inc; - esno_db = ebno_db + srslte_convert_power_to_dB(1.0f / 3.0f); - var[i] = srslte_convert_dB_to_amplitude(-esno_db); + esno_db = ebno_db + srsran_convert_power_to_dB(1.0f / 3.0f); + var[i] = srsran_convert_dB_to_amplitude(-esno_db); } } else { - esno_db = ebno_db + srslte_convert_power_to_dB(1.0f / 3.0f); - var[0] = srslte_convert_dB_to_amplitude(-esno_db); + esno_db = ebno_db + srsran_convert_power_to_dB(1.0f / 3.0f); + var[0] = srsran_convert_dB_to_amplitude(-esno_db); snr_points = 1; } for (i = 0; i < snr_points; i++) { @@ -220,7 +220,7 @@ int main(int argc, char** argv) if (test_known_data) { data_tx[j] = known_data[j]; } else { - data_tx[j] = srslte_random_uniform_int_dist(random_gen, 0, 1); + data_tx[j] = srsran_random_uniform_int_dist(random_gen, 0, 1); } } @@ -230,20 +230,20 @@ int main(int argc, char** argv) symbols[j] = known_data_encoded[j]; } } else { - srslte_tcod_encode(&tcod, data_tx, symbols, frame_length); + srsran_tcod_encode(&tcod, data_tx, symbols, frame_length); } for (j = 0; j < coded_length; j++) { llr[j] = symbols[j] ? 1 : -1; } - srslte_ch_awgn_f(llr, llr, var[i], coded_length); + srsran_ch_awgn_f(llr, llr, var[i], coded_length); for (j = 0; j < coded_length; j++) { llr_s[j] = (int16_t)(100 * llr[j]); } /* decoder */ - srslte_tdec_new_cb(&tdec, frame_length); + srsran_tdec_new_cb(&tdec, frame_length); uint32_t t; if (nof_iterations == -1) { @@ -254,7 +254,7 @@ int main(int argc, char** argv) gettimeofday(&tdata[1], NULL); for (int k = 0; k < nof_repetitions; k++) { - srslte_tdec_run_all(&tdec, llr_s, data_rx_bytes, t, frame_length); + srsran_tdec_run_all(&tdec, llr_s, data_rx_bytes, t, frame_length); } gettimeofday(&tdata[2], NULL); get_time_interval(tdata); @@ -262,9 +262,9 @@ int main(int argc, char** argv) frame_cnt++; uint32_t errors_this = 0; - srslte_bit_unpack_vector(data_rx_bytes, data_rx, frame_length); + srsran_bit_unpack_vector(data_rx_bytes, data_rx, frame_length); - errors_this = srslte_bit_diff(data_tx, data_rx, frame_length); + errors_this = srsran_bit_diff(data_tx, data_rx, frame_length); // printf("error[%d]=%d\n", cb, errors_this); errors += errors_this; printf("Eb/No: %2.2f %10d/%d ", SNR_MIN + i * ebno_inc, frame_cnt, nof_frames); @@ -290,9 +290,9 @@ int main(int argc, char** argv) free(llr_s); free(data_rx); - srslte_tdec_free(&tdec); - srslte_tcod_free(&tcod); - srslte_random_free(random_gen); + srsran_tdec_free(&tdec); + srsran_tcod_free(&tcod); + srsran_random_free(random_gen); printf("\n"); printf("Done\n"); diff --git a/lib/src/phy/fec/turbo/test/turbodecoder_test.h b/lib/src/phy/fec/turbo/test/turbodecoder_test.h index 8157e0bcf..496fd6b9e 100644 --- a/lib/src/phy/fec/turbo/test/turbodecoder_test.h +++ b/lib/src/phy/fec/turbo/test/turbodecoder_test.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/lib/src/phy/fec/turbo/turbocoder.c b/lib/src/phy/fec/turbo/turbocoder.c index 869e4c818..e8b924e63 100644 --- a/lib/src/phy/fec/turbo/turbocoder.c +++ b/lib/src/phy/fec/turbo/turbocoder.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -15,11 +15,11 @@ #include #include -#include "srslte/phy/fec/cbsegm.h" -#include "srslte/phy/fec/turbo/turbocoder.h" -#include "srslte/phy/utils/bit.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/fec/cbsegm.h" +#include "srsran/phy/fec/turbo/turbocoder.h" +#include "srsran/phy/utils/bit.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" #define NOF_REGS 3 @@ -33,23 +33,23 @@ typedef struct { static tcod_lut_t tcod_lut[8][256]; static uint16_t tcod_per_fw[188][6144]; -static srslte_bit_interleaver_t tcod_interleavers[188]; +static srsran_bit_interleaver_t tcod_interleavers[188]; static bool table_initiated = false; -int srslte_tcod_init(srslte_tcod_t* h, uint32_t max_long_cb) +int srsran_tcod_init(srsran_tcod_t* h, uint32_t max_long_cb) { h->max_long_cb = max_long_cb; - h->temp = srslte_vec_malloc(max_long_cb / 8); + h->temp = srsran_vec_malloc(max_long_cb / 8); if (!table_initiated) { table_initiated = true; - srslte_tcod_gentable(); + srsran_tcod_gentable(); } return 0; } -void srslte_tcod_free(srslte_tcod_t* h) +void srsran_tcod_free(srsran_tcod_t* h) { h->max_long_cb = 0; if (h->temp) { @@ -58,14 +58,14 @@ void srslte_tcod_free(srslte_tcod_t* h) if (table_initiated) { for (int i = 0; i < 188; i++) { - srslte_bit_interleaver_free(&tcod_interleavers[i]); + srsran_bit_interleaver_free(&tcod_interleavers[i]); } table_initiated = false; } } /* Expects bits (1 byte = 1 bit) and produces bits. The systematic and parity bits are interlaced in the output */ -int srslte_tcod_encode(srslte_tcod_t* h, uint8_t* input, uint8_t* output, uint32_t long_cb) +int srsran_tcod_encode(srsran_tcod_t* h, uint8_t* input, uint8_t* output, uint32_t long_cb) { uint8_t reg1_0, reg1_1, reg1_2, reg2_0, reg2_1, reg2_2; uint32_t i, k = 0, j; @@ -78,7 +78,7 @@ int srslte_tcod_encode(srslte_tcod_t* h, uint8_t* input, uint8_t* output, uint32 return -1; } - int longcb_idx = srslte_cbsegm_cbindex(long_cb); + int longcb_idx = srsran_cbsegm_cbindex(long_cb); if (longcb_idx < 0) { ERROR("Invalid CB size %d", long_cb); return -1; @@ -96,7 +96,7 @@ int srslte_tcod_encode(srslte_tcod_t* h, uint8_t* input, uint8_t* output, uint32 k = 0; for (i = 0; i < long_cb; i++) { - if (input[i] == SRSLTE_TX_NULL) { + if (input[i] == SRSRAN_TX_NULL) { bit = 0; } else { bit = input[i]; @@ -112,15 +112,15 @@ int srslte_tcod_encode(srslte_tcod_t* h, uint8_t* input, uint8_t* output, uint32 reg1_1 = reg1_0; reg1_0 = in; - if (input[i] == SRSLTE_TX_NULL) { - output[k] = SRSLTE_TX_NULL; + if (input[i] == SRSRAN_TX_NULL) { + output[k] = SRSRAN_TX_NULL; } else { output[k] = out; } k++; bit = input[per[i]]; - if (bit == SRSLTE_TX_NULL) { + if (bit == SRSRAN_TX_NULL) { bit = 0; } @@ -176,16 +176,16 @@ int srslte_tcod_encode(srslte_tcod_t* h, uint8_t* input, uint8_t* output, uint32 } /* Expects bytes and produces bytes. The systematic and parity bits are interlaced in the output */ -int srslte_tcod_encode_lut(srslte_tcod_t* h, - srslte_crc_t* crc_tb, - srslte_crc_t* crc_cb, +int srsran_tcod_encode_lut(srsran_tcod_t* h, + srsran_crc_t* crc_tb, + srsran_crc_t* crc_cb, uint8_t* input, uint8_t* parity, uint32_t cblen_idx, bool last_cb) { if (cblen_idx < 188) { - uint32_t long_cb = (uint32_t)srslte_cbsegm_cbsize(cblen_idx); + uint32_t long_cb = (uint32_t)srsran_cbsegm_cbsize(cblen_idx); if (long_cb % 8) { ERROR("Turbo coder LUT implementation long_cb must be multiple of 8"); @@ -194,7 +194,7 @@ int srslte_tcod_encode_lut(srslte_tcod_t* h, /* Reset CRC */ if (crc_cb) { - srslte_crc_set_init(crc_cb, 0); + srsran_crc_set_init(crc_cb, 0); } /* Parity bits for the 1st constituent encoders */ @@ -207,10 +207,10 @@ int srslte_tcod_encode_lut(srslte_tcod_t* h, uint8_t in = input[i]; /* Put byte in TB CRC and save latest checksum */ - srslte_crc_checksum_put_byte(crc_tb, in); + srsran_crc_checksum_put_byte(crc_tb, in); /* Put byte in CB CRC and save latest checksum */ - srslte_crc_checksum_put_byte(crc_cb, in); + srsran_crc_checksum_put_byte(crc_cb, in); /* Run actual encoder */ tcod_lut_t l = tcod_lut[state0][in]; @@ -219,14 +219,14 @@ int srslte_tcod_encode_lut(srslte_tcod_t* h, } if (last_cb) { - uint32_t checksum = (uint32_t)srslte_crc_checksum_get(crc_tb); + uint32_t checksum = (uint32_t)srsran_crc_checksum_get(crc_tb); for (int i = 0; i < crc_tb->order / 8; i++) { int mask_shift = 8 * (crc_tb->order / 8 - i - 1); int idx = block_size_nocrc + i; uint8_t in = (uint8_t)((checksum >> mask_shift) & 0xff); /* Put byte in CB CRC and save latest checksum */ - srslte_crc_checksum_put_byte(crc_cb, in); + srsran_crc_checksum_put_byte(crc_cb, in); input[idx] = in; tcod_lut_t l = tcod_lut[state0][in]; @@ -235,7 +235,7 @@ int srslte_tcod_encode_lut(srslte_tcod_t* h, } } - uint32_t checksum = (uint32_t)srslte_crc_checksum_get(crc_cb); + uint32_t checksum = (uint32_t)srsran_crc_checksum_get(crc_cb); for (int i = 0; i < crc_cb->order / 8; i++) { int mask_shift = 8 * (crc_cb->order / 8 - i - 1); int idx = (long_cb - crc_cb->order) / 8 + i; @@ -254,7 +254,7 @@ int srslte_tcod_encode_lut(srslte_tcod_t* h, for (uint32_t i = 0; i < block_size_nocrc; i++) { uint8_t in = input[i]; - srslte_crc_checksum_put_byte(crc_tb, in); + srsran_crc_checksum_put_byte(crc_tb, in); tcod_lut_t l = tcod_lut[state0][in]; parity[i] = l.output; @@ -262,7 +262,7 @@ int srslte_tcod_encode_lut(srslte_tcod_t* h, } if (last_cb) { - uint32_t checksum = (uint32_t)srslte_crc_checksum_get(crc_tb); + uint32_t checksum = (uint32_t)srsran_crc_checksum_get(crc_tb); for (int i = 0; i < crc_tb->order / 8; i++) { int mask_shift = 8 * (crc_tb->order / 8 - i - 1); int idx = block_size_nocrc + i; @@ -278,8 +278,8 @@ int srslte_tcod_encode_lut(srslte_tcod_t* h, parity[long_cb / 8] = 0; // will put tail here later /* Interleave input */ - srslte_bit_interleaver_run(&tcod_interleavers[cblen_idx], input, h->temp, 0); - // srslte_bit_interleave(input, h->temp, tcod_per_fw[cblen_idx], long_cb); + srsran_bit_interleaver_run(&tcod_interleavers[cblen_idx], input, h->temp, 0); + // srsran_bit_interleave(input, h->temp, tcod_per_fw[cblen_idx], long_cb); /* Parity bits for the 2nd constituent encoders */ uint8_t state1 = 0; @@ -348,11 +348,11 @@ int srslte_tcod_encode_lut(srslte_tcod_t* h, } } uint8_t* x = tailv[0]; - input[long_cb / 8] = (srslte_bit_pack(&x, 4) << 4); + input[long_cb / 8] = (srsran_bit_pack(&x, 4) << 4); x = tailv[1]; - parity[long_cb / 8] |= (srslte_bit_pack(&x, 4) << 4); + parity[long_cb / 8] |= (srsran_bit_pack(&x, 4) << 4); x = tailv[2]; - parity[2 * long_cb / 8] |= (srslte_bit_pack(&x, 4) & 0xf); + parity[2 * long_cb / 8] |= (srsran_bit_pack(&x, 4) & 0xf); return 3 * long_cb + TOTALTAIL; } else { @@ -360,18 +360,18 @@ int srslte_tcod_encode_lut(srslte_tcod_t* h, } } -void srslte_tcod_gentable() +void srsran_tcod_gentable() { - srslte_tc_interl_t interl; + srsran_tc_interl_t interl; - if (srslte_tc_interl_init(&interl, 6144)) { + if (srsran_tc_interl_init(&interl, 6144)) { ERROR("Error initiating interleave"); return; } for (uint32_t len = 0; len < 188; len++) { - uint32_t long_cb = srslte_cbsegm_cbsize(len); - if (srslte_tc_interl_LTE_gen(&interl, long_cb)) { + uint32_t long_cb = srsran_cbsegm_cbsize(len); + if (srsran_tc_interl_LTE_gen(&interl, long_cb)) { ERROR("Error initiating TC interleaver for long_cb=%d", long_cb); return; } @@ -379,7 +379,7 @@ void srslte_tcod_gentable() for (uint32_t i = 0; i < long_cb; i++) { tcod_per_fw[len][i] = interl.forward[i]; } - srslte_bit_interleaver_init(&tcod_interleavers[len], tcod_per_fw[len], long_cb); + srsran_bit_interleaver_init(&tcod_interleavers[len], tcod_per_fw[len], long_cb); for (uint32_t i = long_cb; i < 6144; i++) { tcod_per_fw[len][i] = 0; } @@ -410,5 +410,5 @@ void srslte_tcod_gentable() } } - srslte_tc_interl_free(&interl); + srsran_tc_interl_free(&interl); } diff --git a/lib/src/phy/fec/turbo/turbodecoder.c b/lib/src/phy/fec/turbo/turbodecoder.c index 2d5424aee..90cf46f14 100644 --- a/lib/src/phy/fec/turbo/turbodecoder.c +++ b/lib/src/phy/fec/turbo/turbodecoder.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -15,15 +15,15 @@ #include #include -#include "srslte/phy/fec/turbo/turbodecoder.h" -#include "srslte/phy/utils/vector.h" -#include "srslte/srslte.h" +#include "srsran/phy/fec/turbo/turbodecoder.h" +#include "srsran/phy/utils/vector.h" +#include "srsran/srsran.h" #define debug_enabled 0 /* Generic (no SSE) implementation */ -#include "srslte/phy/fec/turbo/turbodecoder_gen.h" -srslte_tdec_16bit_impl_t gen_impl = {tdec_gen_init, +#include "srsran/phy/fec/turbo/turbodecoder_gen.h" +srsran_tdec_16bit_impl_t gen_impl = {tdec_gen_init, tdec_gen_free, tdec_gen_dec, tdec_gen_extract_input, @@ -31,8 +31,8 @@ srslte_tdec_16bit_impl_t gen_impl = {tdec_gen_init, /* SSE no-window implementation */ #ifdef LV_HAVE_SSE -#include "srslte/phy/fec/turbo/turbodecoder_sse.h" -srslte_tdec_16bit_impl_t sse_impl = {tdec_sse_init, +#include "srsran/phy/fec/turbo/turbodecoder_sse.h" +srsran_tdec_16bit_impl_t sse_impl = {tdec_sse_init, tdec_sse_free, tdec_sse_dec, tdec_sse_extract_input, @@ -41,10 +41,10 @@ srslte_tdec_16bit_impl_t sse_impl = {tdec_sse_init, /* SSE window implementation */ #define WINIMP_IS_SSE16 -#include "srslte/phy/fec/turbo/turbodecoder_win.h" +#include "srsran/phy/fec/turbo/turbodecoder_win.h" #undef WINIMP_IS_SSE16 -srslte_tdec_16bit_impl_t sse16_win_impl = {tdec_winsse16_init, +srsran_tdec_16bit_impl_t sse16_win_impl = {tdec_winsse16_init, tdec_winsse16_free, tdec_winsse16_dec, tdec_winsse16_extract_input, @@ -54,9 +54,9 @@ srslte_tdec_16bit_impl_t sse16_win_impl = {tdec_winsse16_init, /* AVX window implementation */ #ifdef LV_HAVE_AVX2 #define WINIMP_IS_AVX16 -#include "srslte/phy/fec/turbo/turbodecoder_win.h" +#include "srsran/phy/fec/turbo/turbodecoder_win.h" #undef WINIMP_IS_AVX16 -srslte_tdec_16bit_impl_t avx16_win_impl = {tdec_winavx16_init, +srsran_tdec_16bit_impl_t avx16_win_impl = {tdec_winavx16_init, tdec_winavx16_free, tdec_winavx16_dec, tdec_winavx16_extract_input, @@ -66,10 +66,10 @@ srslte_tdec_16bit_impl_t avx16_win_impl = {tdec_winavx16_init, /* SSE window implementation */ #ifdef LV_HAVE_SSE #define WINIMP_IS_SSE8 -#include "srslte/phy/fec/turbo/turbodecoder_win.h" +#include "srsran/phy/fec/turbo/turbodecoder_win.h" #undef WINIMP_IS_SSE8 -srslte_tdec_8bit_impl_t sse8_win_impl = {tdec_winsse8_init, +srsran_tdec_8bit_impl_t sse8_win_impl = {tdec_winsse8_init, tdec_winsse8_free, tdec_winsse8_dec, tdec_winsse8_extract_input, @@ -79,9 +79,9 @@ srslte_tdec_8bit_impl_t sse8_win_impl = {tdec_winsse8_init, /* AVX window implementation */ #ifdef LV_HAVE_AVX2 #define WINIMP_IS_AVX8 -#include "srslte/phy/fec/turbo/turbodecoder_win.h" +#include "srsran/phy/fec/turbo/turbodecoder_win.h" #undef WINIMP_IS_AVX8 -srslte_tdec_8bit_impl_t avx8_win_impl = {tdec_winavx8_init, +srsran_tdec_8bit_impl_t avx8_win_impl = {tdec_winavx8_init, tdec_winavx8_free, tdec_winavx8_dec, tdec_winavx8_extract_input, @@ -90,10 +90,10 @@ srslte_tdec_8bit_impl_t avx8_win_impl = {tdec_winavx8_init, #ifdef HAVE_NEON #define WINIMP_IS_NEON16 -#include "srslte/phy/fec/turbodecoder_win.h" +#include "srsran/phy/fec/turbodecoder_win.h" #undef WINIMP_IS_NEON16 -srslte_tdec_16bit_impl_t arm16_win_impl = {tdec_winarm16_init, +srsran_tdec_16bit_impl_t arm16_win_impl = {tdec_winarm16_init, tdec_winarm16_free, tdec_winarm16_dec, tdec_winarm16_extract_input, @@ -110,16 +110,16 @@ srslte_tdec_16bit_impl_t arm16_win_impl = {tdec_winarm16_init, // Include interfaces for 8 and 16 bit decoder implementations #define LLR_IS_8BIT -#include "srslte/phy/fec/turbo/turbodecoder_iter.h" +#include "srsran/phy/fec/turbo/turbodecoder_iter.h" #undef LLR_IS_8BIT #define LLR_IS_16BIT -#include "srslte/phy/fec/turbo/turbodecoder_iter.h" +#include "srsran/phy/fec/turbo/turbodecoder_iter.h" #undef LLR_IS_16BIT -int srslte_tdec_init(srslte_tdec_t* h, uint32_t max_long_cb) +int srsran_tdec_init(srsran_tdec_t* h, uint32_t max_long_cb) { - return srslte_tdec_init_manual(h, max_long_cb, SRSLTE_TDEC_AUTO); + return srsran_tdec_init_manual(h, max_long_cb, SRSRAN_TDEC_AUTO); } uint32_t interleaver_idx(uint32_t nof_subblocks) @@ -139,51 +139,51 @@ uint32_t interleaver_idx(uint32_t nof_subblocks) } /* Initializes the turbo decoder object */ -int srslte_tdec_init_manual(srslte_tdec_t* h, uint32_t max_long_cb, srslte_tdec_impl_type_t dec_type) +int srsran_tdec_init_manual(srsran_tdec_t* h, uint32_t max_long_cb, srsran_tdec_impl_type_t dec_type) { int ret = -1; - bzero(h, sizeof(srslte_tdec_t)); - uint32_t len = max_long_cb + SRSLTE_TCOD_TOTALTAIL; + bzero(h, sizeof(srsran_tdec_t)); + uint32_t len = max_long_cb + SRSRAN_TCOD_TOTALTAIL; h->dec_type = dec_type; // Set manual switch (dec_type) { - case SRSLTE_TDEC_AUTO: + case SRSRAN_TDEC_AUTO: break; #ifdef LV_HAVE_SSE - case SRSLTE_TDEC_SSE: + case SRSRAN_TDEC_SSE: h->dec16[0] = &sse_impl; - h->current_llr_type = SRSLTE_TDEC_16; + h->current_llr_type = SRSRAN_TDEC_16; break; - case SRSLTE_TDEC_SSE_WINDOW: + case SRSRAN_TDEC_SSE_WINDOW: h->dec16[0] = &sse16_win_impl; - h->current_llr_type = SRSLTE_TDEC_16; + h->current_llr_type = SRSRAN_TDEC_16; break; - case SRSLTE_TDEC_SSE8_WINDOW: + case SRSRAN_TDEC_SSE8_WINDOW: h->dec8[0] = &sse8_win_impl; - h->current_llr_type = SRSLTE_TDEC_8; + h->current_llr_type = SRSRAN_TDEC_8; break; #endif /* LV_HAVE_SSE */ #ifdef HAVE_NEON - case SRSLTE_TDEC_NEON_WINDOW: + case SRSRAN_TDEC_NEON_WINDOW: h->dec16[0] = &arm16_win_impl; - h->current_llr_type = SRSLTE_TDEC_16; + h->current_llr_type = SRSRAN_TDEC_16; break; #else /* HAVE_NEON */ - case SRSLTE_TDEC_GENERIC: + case SRSRAN_TDEC_GENERIC: h->dec16[0] = &gen_impl; - h->current_llr_type = SRSLTE_TDEC_16; + h->current_llr_type = SRSRAN_TDEC_16; break; #endif /* HAVE_NEON */ #ifdef LV_HAVE_AVX2 - case SRSLTE_TDEC_AVX_WINDOW: + case SRSRAN_TDEC_AVX_WINDOW: h->dec16[0] = &avx16_win_impl; - h->current_llr_type = SRSLTE_TDEC_16; + h->current_llr_type = SRSRAN_TDEC_16; break; - case SRSLTE_TDEC_AVX8_WINDOW: + case SRSRAN_TDEC_AVX8_WINDOW: h->dec8[0] = &avx8_win_impl; - h->current_llr_type = SRSLTE_TDEC_8; + h->current_llr_type = SRSRAN_TDEC_8; break; #endif /* LV_HAVE_AVX2 */ default: @@ -193,48 +193,48 @@ int srslte_tdec_init_manual(srslte_tdec_t* h, uint32_t max_long_cb, srslte_tdec_ h->max_long_cb = max_long_cb; - h->app1 = srslte_vec_i16_malloc(len); + h->app1 = srsran_vec_i16_malloc(len); if (!h->app1) { - perror("srslte_vec_malloc"); + perror("srsran_vec_malloc"); goto clean_and_exit; } - h->app2 = srslte_vec_i16_malloc(len); + h->app2 = srsran_vec_i16_malloc(len); if (!h->app2) { - perror("srslte_vec_malloc"); + perror("srsran_vec_malloc"); goto clean_and_exit; } - h->ext1 = srslte_vec_i16_malloc(len); + h->ext1 = srsran_vec_i16_malloc(len); if (!h->ext1) { - perror("srslte_vec_malloc"); + perror("srsran_vec_malloc"); goto clean_and_exit; } - h->ext2 = srslte_vec_i16_malloc(len); + h->ext2 = srsran_vec_i16_malloc(len); if (!h->ext2) { - perror("srslte_vec_malloc"); + perror("srsran_vec_malloc"); goto clean_and_exit; } - h->syst0 = srslte_vec_i16_malloc(len); + h->syst0 = srsran_vec_i16_malloc(len); if (!h->syst0) { - perror("srslte_vec_malloc"); + perror("srsran_vec_malloc"); goto clean_and_exit; } - h->parity0 = srslte_vec_i16_malloc(len); + h->parity0 = srsran_vec_i16_malloc(len); if (!h->parity0) { - perror("srslte_vec_malloc"); + perror("srsran_vec_malloc"); goto clean_and_exit; } - h->parity1 = srslte_vec_i16_malloc(len); + h->parity1 = srsran_vec_i16_malloc(len); if (!h->parity1) { - perror("srslte_vec_malloc"); + perror("srsran_vec_malloc"); goto clean_and_exit; } - h->input_conv = srslte_vec_i16_malloc(len * 3 + 32 * 3); + h->input_conv = srsran_vec_i16_malloc(len * 3 + 32 * 3); if (!h->input_conv) { - perror("srslte_vec_malloc"); + perror("srsran_vec_malloc"); goto clean_and_exit; } - if (dec_type == SRSLTE_TDEC_AUTO) { + if (dec_type == SRSRAN_TDEC_AUTO) { #ifdef HAVE_NEON h->dec16[AUTO_16_GEN] = &gen_impl; h->dec16[AUTO_16_NEONWIN] = &arm16_win_impl; @@ -251,14 +251,14 @@ int srslte_tdec_init_manual(srslte_tdec_t* h, uint32_t max_long_cb, srslte_tdec_ h->dec16[AUTO_16_SSEWIN] = &gen_impl; #endif /* HAVE_NEON | LV_HAVE_SSE */ - for (int td = 0; td < SRSLTE_TDEC_NOF_AUTO_MODES_16; td++) { + for (int td = 0; td < SRSRAN_TDEC_NOF_AUTO_MODES_16; td++) { if (h->dec16[td]) { if ((h->nof_blocks16[td] = h->dec16[td]->tdec_init(&h->dec16_hdlr[td], h->max_long_cb)) < 0) { goto clean_and_exit; } } } - for (int td = 0; td < SRSLTE_TDEC_NOF_AUTO_MODES_8; td++) { + for (int td = 0; td < SRSRAN_TDEC_NOF_AUTO_MODES_8; td++) { if (h->dec8[td]) { if ((h->nof_blocks8[td] = h->dec8[td]->tdec_init(&h->dec8_hdlr[td], h->max_long_cb)) < 0) { goto clean_and_exit; @@ -268,16 +268,16 @@ int srslte_tdec_init_manual(srslte_tdec_t* h, uint32_t max_long_cb, srslte_tdec_ // Compute 1 interleaver for each possible nof_subblocks (1, 8, 16 or 32) for (int s = 0; s < 4; s++) { - for (int i = 0; i < SRSLTE_NOF_TC_CB_SIZES; i++) { - if (srslte_tc_interl_init(&h->interleaver[s][i], srslte_cbsegm_cbsize(i)) < 0) { + for (int i = 0; i < SRSRAN_NOF_TC_CB_SIZES; i++) { + if (srsran_tc_interl_init(&h->interleaver[s][i], srsran_cbsegm_cbsize(i)) < 0) { goto clean_and_exit; } - srslte_tc_interl_LTE_gen_interl(&h->interleaver[s][i], srslte_cbsegm_cbsize(i), s ? (8 << (s - 1)) : 1); + srsran_tc_interl_LTE_gen_interl(&h->interleaver[s][i], srsran_cbsegm_cbsize(i), s ? (8 << (s - 1)) : 1); } } } else { uint32_t nof_subblocks; - if (dec_type < SRSLTE_TDEC_SSE8_WINDOW) { + if (dec_type < SRSRAN_TDEC_SSE8_WINDOW) { if ((h->nof_blocks16[0] = h->dec16[0]->tdec_init(&h->dec16_hdlr[0], h->max_long_cb)) < 0) { goto clean_and_exit; } @@ -288,12 +288,12 @@ int srslte_tdec_init_manual(srslte_tdec_t* h, uint32_t max_long_cb, srslte_tdec_ } nof_subblocks = h->nof_blocks8[0]; } - for (int i = 0; i < SRSLTE_NOF_TC_CB_SIZES; i++) { - if (srslte_tc_interl_init(&h->interleaver[interleaver_idx(nof_subblocks)][i], srslte_cbsegm_cbsize(i)) < 0) { + for (int i = 0; i < SRSRAN_NOF_TC_CB_SIZES; i++) { + if (srsran_tc_interl_init(&h->interleaver[interleaver_idx(nof_subblocks)][i], srsran_cbsegm_cbsize(i)) < 0) { goto clean_and_exit; } - srslte_tc_interl_LTE_gen_interl( - &h->interleaver[interleaver_idx(nof_subblocks)][i], srslte_cbsegm_cbsize(i), nof_subblocks); + srsran_tc_interl_LTE_gen_interl( + &h->interleaver[interleaver_idx(nof_subblocks)][i], srsran_cbsegm_cbsize(i), nof_subblocks); } } @@ -302,12 +302,12 @@ int srslte_tdec_init_manual(srslte_tdec_t* h, uint32_t max_long_cb, srslte_tdec_ clean_and_exit: if (ret == -1) { - srslte_tdec_free(h); + srsran_tdec_free(h); } return ret; } -void srslte_tdec_free(srslte_tdec_t* h) +void srsran_tdec_free(srsran_tdec_t* h) { if (h->app1) { free(h->app1); @@ -334,33 +334,33 @@ void srslte_tdec_free(srslte_tdec_t* h) free(h->input_conv); } - for (int td = 0; td < SRSLTE_TDEC_NOF_AUTO_MODES_8; td++) { + for (int td = 0; td < SRSRAN_TDEC_NOF_AUTO_MODES_8; td++) { if (h->dec8[td] && h->dec8_hdlr[td]) { h->dec8[td]->tdec_free(h->dec8_hdlr[td]); } } - for (int td = 0; td < SRSLTE_TDEC_NOF_AUTO_MODES_16; td++) { + for (int td = 0; td < SRSRAN_TDEC_NOF_AUTO_MODES_16; td++) { if (h->dec16[td] && h->dec16_hdlr[td]) { h->dec16[td]->tdec_free(h->dec16_hdlr[td]); } } for (int s = 0; s < 4; s++) { - for (int i = 0; i < SRSLTE_NOF_TC_CB_SIZES; i++) { - srslte_tc_interl_free(&h->interleaver[s][i]); + for (int i = 0; i < SRSRAN_NOF_TC_CB_SIZES; i++) { + srsran_tc_interl_free(&h->interleaver[s][i]); } } - bzero(h, sizeof(srslte_tdec_t)); + bzero(h, sizeof(srsran_tdec_t)); } -void srslte_tdec_force_not_sb(srslte_tdec_t* h) +void srsran_tdec_force_not_sb(srsran_tdec_t* h) { h->force_not_sb = true; } -static void tdec_decision_byte(srslte_tdec_t* h, uint8_t* output) +static void tdec_decision_byte(srsran_tdec_t* h, uint8_t* output) { - if (h->current_llr_type == SRSLTE_TDEC_16) { + if (h->current_llr_type == SRSRAN_TDEC_16) { h->dec16[h->current_dec]->tdec_decision_byte(!(h->n_iter % 2) ? h->app1 : h->ext1, output, h->current_long_cb); } else { h->dec8[h->current_dec]->tdec_decision_byte( @@ -369,7 +369,7 @@ static void tdec_decision_byte(srslte_tdec_t* h, uint8_t* output) } /* Returns number of subblocks in automatic mode for this long_cb */ -uint32_t srslte_tdec_autoimp_get_subblocks(uint32_t long_cb) +uint32_t srsran_tdec_autoimp_get_subblocks(uint32_t long_cb) { #ifdef LV_HAVE_AVX2 if (!(long_cb % 16) && long_cb > 800) { @@ -385,7 +385,7 @@ uint32_t srslte_tdec_autoimp_get_subblocks(uint32_t long_cb) static int tdec_sb_idx(uint32_t long_cb) { - uint32_t nof_sb = srslte_tdec_autoimp_get_subblocks(long_cb); + uint32_t nof_sb = srsran_tdec_autoimp_get_subblocks(long_cb); switch (nof_sb) { case 16: return AUTO_16_AVXWIN; @@ -398,7 +398,7 @@ static int tdec_sb_idx(uint32_t long_cb) return 0; } -uint32_t srslte_tdec_autoimp_get_subblocks_8bit(uint32_t long_cb) +uint32_t srsran_tdec_autoimp_get_subblocks_8bit(uint32_t long_cb) { #ifdef LV_HAVE_AVX2 if (!(long_cb % 32) && long_cb > 2048) { @@ -416,7 +416,7 @@ uint32_t srslte_tdec_autoimp_get_subblocks_8bit(uint32_t long_cb) static int tdec_sb_idx_8(uint32_t long_cb) { - uint32_t nof_sb = srslte_tdec_autoimp_get_subblocks_8bit(long_cb); + uint32_t nof_sb = srsran_tdec_autoimp_get_subblocks_8bit(long_cb); switch (nof_sb) { case 32: return AUTO_8_AVXWIN; @@ -446,17 +446,17 @@ static void convert_16_to_8(int16_t* in, int8_t* out, uint32_t len) } } -static void tdec_iteration_8(srslte_tdec_t* h, int8_t* input) +static void tdec_iteration_8(srsran_tdec_t* h, int8_t* input) { // Select decoder if in auto mode - if (h->dec_type == SRSLTE_TDEC_AUTO) { - h->current_llr_type = SRSLTE_TDEC_8; + if (h->dec_type == SRSRAN_TDEC_AUTO) { + h->current_llr_type = SRSRAN_TDEC_8; h->current_dec = tdec_sb_idx_8(h->current_long_cb); h->current_inter_idx = interleaver_idx(h->nof_blocks8[h->current_dec]); // If long_cb is not multiple of any 8-bit decoder, use a 16-bit decoder and do type conversion if (h->current_dec >= 10) { - h->current_llr_type = SRSLTE_TDEC_16; + h->current_llr_type = SRSRAN_TDEC_16; h->current_dec -= 10; h->current_inter_idx = interleaver_idx(h->nof_blocks16[h->current_dec]); } @@ -464,7 +464,7 @@ static void tdec_iteration_8(srslte_tdec_t* h, int8_t* input) h->current_dec = 0; } - if (h->current_llr_type == SRSLTE_TDEC_16) { + if (h->current_llr_type == SRSRAN_TDEC_16) { if (!h->n_iter) { convert_8_to_16(input, h->input_conv, 3 * h->current_long_cb + 12); } @@ -474,18 +474,18 @@ static void tdec_iteration_8(srslte_tdec_t* h, int8_t* input) } } -static void tdec_iteration_16(srslte_tdec_t* h, int16_t* input) +static void tdec_iteration_16(srsran_tdec_t* h, int16_t* input) { // Select decoder if in auto mode - if (h->dec_type == SRSLTE_TDEC_AUTO) { - h->current_llr_type = SRSLTE_TDEC_16; + if (h->dec_type == SRSRAN_TDEC_AUTO) { + h->current_llr_type = SRSRAN_TDEC_16; h->current_dec = tdec_sb_idx(h->current_long_cb); } else { h->current_dec = 0; } h->current_inter_idx = interleaver_idx(h->nof_blocks16[h->current_dec]); - if (h->current_llr_type == SRSLTE_TDEC_8) { + if (h->current_llr_type == SRSRAN_TDEC_8) { h->current_inter_idx = interleaver_idx(h->nof_blocks8[h->current_dec]); if (!h->n_iter) { @@ -498,7 +498,7 @@ static void tdec_iteration_16(srslte_tdec_t* h, int16_t* input) } /* Resets the decoder and sets the codeblock length */ -int srslte_tdec_new_cb(srslte_tdec_t* h, uint32_t long_cb) +int srsran_tdec_new_cb(srsran_tdec_t* h, uint32_t long_cb) { if (long_cb > h->max_long_cb) { ERROR("TDEC was initialized for max_long_cb=%d", h->max_long_cb); @@ -507,7 +507,7 @@ int srslte_tdec_new_cb(srslte_tdec_t* h, uint32_t long_cb) h->n_iter = 0; h->current_long_cb = long_cb; - h->current_cbidx = srslte_cbsegm_cbindex(long_cb); + h->current_cbidx = srsran_cbsegm_cbindex(long_cb); if (h->current_cbidx < 0) { ERROR("Invalid CB length %d", long_cb); return -1; @@ -515,7 +515,7 @@ int srslte_tdec_new_cb(srslte_tdec_t* h, uint32_t long_cb) return 0; } -void srslte_tdec_iteration(srslte_tdec_t* h, int16_t* input, uint8_t* output) +void srsran_tdec_iteration(srsran_tdec_t* h, int16_t* input, uint8_t* output) { if (h->current_cbidx >= 0) { tdec_iteration_16(h, input); @@ -524,10 +524,10 @@ void srslte_tdec_iteration(srslte_tdec_t* h, int16_t* input, uint8_t* output) } /* Runs nof_iterations iterations and decides the output bits */ -int srslte_tdec_run_all(srslte_tdec_t* h, int16_t* input, uint8_t* output, uint32_t nof_iterations, uint32_t long_cb) +int srsran_tdec_run_all(srsran_tdec_t* h, int16_t* input, uint8_t* output, uint32_t nof_iterations, uint32_t long_cb) { - if (srslte_tdec_new_cb(h, long_cb)) { - return SRSLTE_ERROR; + if (srsran_tdec_new_cb(h, long_cb)) { + return SRSRAN_ERROR; } do { @@ -536,10 +536,10 @@ int srslte_tdec_run_all(srslte_tdec_t* h, int16_t* input, uint8_t* output, uint3 tdec_decision_byte(h, output); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -void srslte_tdec_iteration_8bit(srslte_tdec_t* h, int8_t* input, uint8_t* output) +void srsran_tdec_iteration_8bit(srsran_tdec_t* h, int8_t* input, uint8_t* output) { if (h->current_cbidx >= 0) { tdec_iteration_8(h, input); @@ -548,14 +548,14 @@ void srslte_tdec_iteration_8bit(srslte_tdec_t* h, int8_t* input, uint8_t* output } /* Runs nof_iterations iterations and decides the output bits */ -int srslte_tdec_run_all_8bit(srslte_tdec_t* h, +int srsran_tdec_run_all_8bit(srsran_tdec_t* h, int8_t* input, uint8_t* output, uint32_t nof_iterations, uint32_t long_cb) { - if (srslte_tdec_new_cb(h, long_cb)) { - return SRSLTE_ERROR; + if (srsran_tdec_new_cb(h, long_cb)) { + return SRSRAN_ERROR; } do { @@ -564,10 +564,10 @@ int srslte_tdec_run_all_8bit(srslte_tdec_t* h, tdec_decision_byte(h, output); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_tdec_get_nof_iterations(srslte_tdec_t* h) +int srsran_tdec_get_nof_iterations(srsran_tdec_t* h) { return h->n_iter; } diff --git a/lib/src/phy/fec/turbo/turbodecoder_gen.c b/lib/src/phy/fec/turbo/turbodecoder_gen.c index 521950e63..9d240ee3d 100644 --- a/lib/src/phy/fec/turbo/turbodecoder_gen.c +++ b/lib/src/phy/fec/turbo/turbodecoder_gen.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -17,8 +17,8 @@ #include #include -#include "srslte/phy/fec/turbo/turbodecoder_gen.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/fec/turbo/turbodecoder_gen.h" +#include "srsran/phy/utils/vector.h" #define NUMSTATES 8 #define NINPUTS 2 @@ -32,9 +32,9 @@ #if debug_enabled #define debug_state \ printf("k=%5d, in=%5d, pa=%3d, out=%5d, alpha=", k, x, parity[k - 1], out); \ - srslte_vec_fprint_s(stdout, alpha, 8); \ + srsran_vec_fprint_s(stdout, alpha, 8); \ printf(", beta="); \ - srslte_vec_fprint_s(stdout, &beta[8 * (k)], 8); \ + srsran_vec_fprint_s(stdout, &beta[8 * (k)], 8); \ printf("\n"); #else #define debug_state @@ -51,7 +51,7 @@ static void map_gen_beta(tdec_gen_t* s, int16_t* input, int16_t* app, int16_t* p int16_t m_b[8], new[8], old[8]; int16_t x, y, xy; int k; - uint32_t end = long_cb + SRSLTE_TCOD_RATE; + uint32_t end = long_cb + SRSRAN_TCOD_RATE; int16_t* beta = s->beta; uint32_t i; @@ -194,9 +194,9 @@ int tdec_gen_init(void** hh, uint32_t max_long_cb) tdec_gen_t* h = (tdec_gen_t*)*hh; - h->beta = srslte_vec_i16_malloc((max_long_cb + SRSLTE_TCOD_TOTALTAIL + 1) * NUMSTATES); + h->beta = srsran_vec_i16_malloc((max_long_cb + SRSRAN_TCOD_TOTALTAIL + 1) * NUMSTATES); if (!h->beta) { - perror("srslte_vec_malloc"); + perror("srsran_vec_malloc"); return -1; } h->max_long_cb = max_long_cb; @@ -235,16 +235,16 @@ void tdec_gen_extract_input(int16_t* input, { // Prepare systematic and parity bits for MAP DEC #1 for (uint32_t i = 0; i < long_cb; i++) { - syst[i] = input[SRSLTE_TCOD_RATE * i]; - parity0[i] = input[SRSLTE_TCOD_RATE * i + 1]; - parity1[i] = input[SRSLTE_TCOD_RATE * i + 2]; + syst[i] = input[SRSRAN_TCOD_RATE * i]; + parity0[i] = input[SRSRAN_TCOD_RATE * i + 1]; + parity1[i] = input[SRSRAN_TCOD_RATE * i + 2]; } - for (uint32_t i = long_cb; i < long_cb + SRSLTE_TCOD_RATE; i++) { - syst[i] = input[SRSLTE_TCOD_RATE * long_cb + NINPUTS * (i - long_cb)]; - parity0[i] = input[SRSLTE_TCOD_RATE * long_cb + NINPUTS * (i - long_cb) + 1]; + for (uint32_t i = long_cb; i < long_cb + SRSRAN_TCOD_RATE; i++) { + syst[i] = input[SRSRAN_TCOD_RATE * long_cb + NINPUTS * (i - long_cb)]; + parity0[i] = input[SRSRAN_TCOD_RATE * long_cb + NINPUTS * (i - long_cb) + 1]; - app2[i] = input[SRSLTE_TCOD_RATE * long_cb + NINPUTS * SRSLTE_TCOD_RATE + NINPUTS * (i - long_cb)]; - parity1[i] = input[SRSLTE_TCOD_RATE * long_cb + NINPUTS * SRSLTE_TCOD_RATE + NINPUTS * (i - long_cb) + 1]; + app2[i] = input[SRSRAN_TCOD_RATE * long_cb + NINPUTS * SRSRAN_TCOD_RATE + NINPUTS * (i - long_cb)]; + parity1[i] = input[SRSRAN_TCOD_RATE * long_cb + NINPUTS * SRSRAN_TCOD_RATE + NINPUTS * (i - long_cb) + 1]; } } diff --git a/lib/src/phy/fec/turbo/turbodecoder_sse.c b/lib/src/phy/fec/turbo/turbodecoder_sse.c index 639912ca6..e776a2f44 100644 --- a/lib/src/phy/fec/turbo/turbodecoder_sse.c +++ b/lib/src/phy/fec/turbo/turbodecoder_sse.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -17,8 +17,8 @@ #include #include -#include "srslte/phy/fec/turbo/turbodecoder_sse.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/fec/turbo/turbodecoder_sse.h" +#include "srsran/phy/utils/vector.h" #include @@ -380,14 +380,14 @@ int tdec_sse_init(void** hh, uint32_t max_long_cb) h->max_long_cb = max_long_cb; - h->alpha = srslte_vec_i16_malloc((max_long_cb + TOTALTAIL + 1) * NUMSTATES); + h->alpha = srsran_vec_i16_malloc((max_long_cb + TOTALTAIL + 1) * NUMSTATES); if (!h->alpha) { - perror("srslte_vec_malloc"); + perror("srsran_vec_malloc"); return -1; } - h->branch = srslte_vec_i16_malloc((max_long_cb + TOTALTAIL + 1) * NUMSTATES); + h->branch = srsran_vec_i16_malloc((max_long_cb + TOTALTAIL + 1) * NUMSTATES); if (!h->branch) { - perror("srslte_vec_malloc"); + perror("srsran_vec_malloc"); return -1; } return 1; diff --git a/lib/src/phy/fec/utils_avx2.h b/lib/src/phy/fec/utils_avx2.h index c914e51e4..0aff4fcc2 100644 --- a/lib/src/phy/fec/utils_avx2.h +++ b/lib/src/phy/fec/utils_avx2.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -20,10 +20,10 @@ * */ -#ifndef SRSLTE_UTILS_AVX2_H -#define SRSLTE_UTILS_AVX2_H +#ifndef SRSRAN_UTILS_AVX2_H +#define SRSRAN_UTILS_AVX2_H -#define SRSLTE_AVX2_B_SIZE 32 /*!< \brief Number of packed bytes in an AVX2 instruction. */ -#define SRSLTE_AVX2_B_SIZE_LOG 5 /*!< \brief \f$\log_2\f$ of \ref SRSLTE_AVX2_B_SIZE. */ +#define SRSRAN_AVX2_B_SIZE 32 /*!< \brief Number of packed bytes in an AVX2 instruction. */ +#define SRSRAN_AVX2_B_SIZE_LOG 5 /*!< \brief \f$\log_2\f$ of \ref SRSRAN_AVX2_B_SIZE. */ -#endif // SRSLTE_UTILS_AVX2_H +#endif // SRSRAN_UTILS_AVX2_H diff --git a/lib/src/phy/fec/utils_avx512.h b/lib/src/phy/fec/utils_avx512.h index dc650b519..5b47d14be 100644 --- a/lib/src/phy/fec/utils_avx512.h +++ b/lib/src/phy/fec/utils_avx512.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -20,10 +20,10 @@ * */ -#ifndef SRSLTE_UTILS_AVX512_H -#define SRSLTE_UTILS_AVX512_H +#ifndef SRSRAN_UTILS_AVX512_H +#define SRSRAN_UTILS_AVX512_H -#define SRSLTE_AVX512_B_SIZE 64 /*!< \brief Number of packed bytes in an AVX512 instruction. */ -#define SRSLTE_AVX512_B_SIZE_LOG 6 /*!< \brief \f$\log_2\f$ of \ref SRSLTE_AVX512_B_SIZE. */ +#define SRSRAN_AVX512_B_SIZE 64 /*!< \brief Number of packed bytes in an AVX512 instruction. */ +#define SRSRAN_AVX512_B_SIZE_LOG 6 /*!< \brief \f$\log_2\f$ of \ref SRSRAN_AVX512_B_SIZE. */ -#endif // SRSLTE_UTILS_AVX512_H +#endif // SRSRAN_UTILS_AVX512_H diff --git a/lib/src/phy/io/CMakeLists.txt b/lib/src/phy/io/CMakeLists.txt index f07e154bd..f76e17190 100644 --- a/lib/src/phy/io/CMakeLists.txt +++ b/lib/src/phy/io/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -7,4 +7,4 @@ # file(GLOB SOURCES "*.c") -add_library(srslte_io OBJECT ${SOURCES}) +add_library(srsran_io OBJECT ${SOURCES}) diff --git a/lib/src/phy/io/binsource.c b/lib/src/phy/io/binsource.c index 788e45262..d51feb0ae 100644 --- a/lib/src/phy/io/binsource.c +++ b/lib/src/phy/io/binsource.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -14,21 +14,21 @@ #include #include -#include "srslte/phy/io/binsource.h" -#include "srslte/phy/utils/bit.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/io/binsource.h" +#include "srsran/phy/utils/bit.h" +#include "srsran/phy/utils/vector.h" #define DIV(a, b) ((a - 1) / b + 1) /* Internal functions */ -static int gen_seq_buff(srslte_binsource_t* q, int nwords) +static int gen_seq_buff(srsran_binsource_t* q, int nwords) { if (q->seq_buff_nwords != nwords) { free(q->seq_buff); q->seq_buff_nwords = 0; } if (!q->seq_buff_nwords) { - q->seq_buff = srslte_vec_u32_malloc(nwords); + q->seq_buff = srsran_vec_u32_malloc(nwords); if (!q->seq_buff) { return -1; } @@ -45,26 +45,26 @@ static int gen_seq_buff(srslte_binsource_t* q, int nwords) /** * Initializes the binsource object. */ -void srslte_binsource_init(srslte_binsource_t* q) +void srsran_binsource_init(srsran_binsource_t* q) { - bzero((void*)q, sizeof(srslte_binsource_t)); + bzero((void*)q, sizeof(srsran_binsource_t)); } /** * Destroys binsource object */ -void srslte_binsource_free(srslte_binsource_t* q) +void srsran_binsource_free(srsran_binsource_t* q) { if (q->seq_buff) { free(q->seq_buff); } - bzero(q, sizeof(srslte_binsource_t)); + bzero(q, sizeof(srsran_binsource_t)); } /** * Sets a new seed */ -void srslte_binsource_seed_set(srslte_binsource_t* q, uint32_t seed) +void srsran_binsource_seed_set(srsran_binsource_t* q, uint32_t seed) { q->seed = seed; } @@ -72,7 +72,7 @@ void srslte_binsource_seed_set(srslte_binsource_t* q, uint32_t seed) /** * Sets local time as seed. */ -void srslte_binsource_seed_time(srslte_binsource_t* q) +void srsran_binsource_seed_time(srsran_binsource_t* q) { struct timeval t1; gettimeofday(&t1, NULL); @@ -82,7 +82,7 @@ void srslte_binsource_seed_time(srslte_binsource_t* q) /** * Generates a sequence of nbits random bits */ -int srslte_binsource_cache_gen(srslte_binsource_t* q, int nbits) +int srsran_binsource_cache_gen(srsran_binsource_t* q, int nbits) { if (gen_seq_buff(q, DIV(nbits, 32))) { return -1; @@ -97,25 +97,25 @@ static int int_2_bits(uint32_t* src, uint8_t* dst, int nbits) int n; n = nbits / 32; for (int i = 0; i < n; i++) { - srslte_bit_unpack(src[i], &dst, 32); + srsran_bit_unpack(src[i], &dst, 32); } - srslte_bit_unpack(src[n], &dst, nbits - n * 32); + srsran_bit_unpack(src[n], &dst, nbits - n * 32); return n; } /** - * Copies the next random bits to the buffer bits from the array generated by srslte_binsource_cache_gen + * Copies the next random bits to the buffer bits from the array generated by srsran_binsource_cache_gen */ -void srslte_binsource_cache_cpy(srslte_binsource_t* q, uint8_t* bits, int nbits) +void srsran_binsource_cache_cpy(srsran_binsource_t* q, uint8_t* bits, int nbits) { q->seq_cache_rp += int_2_bits(&q->seq_buff[q->seq_cache_rp], bits, nbits); } /** * Stores in the bits buffer a sequence of nbits pseudo-random bits. - * Overwrites the bits generated using srslte_binsource_cache_gen. + * Overwrites the bits generated using srsran_binsource_cache_gen. */ -int srslte_binsource_generate(srslte_binsource_t* q, uint8_t* bits, int nbits) +int srsran_binsource_generate(srsran_binsource_t* q, uint8_t* bits, int nbits) { if (gen_seq_buff(q, DIV(nbits, 32))) { diff --git a/lib/src/phy/io/filesink.c b/lib/src/phy/io/filesink.c index 497f584b3..141fc8898 100644 --- a/lib/src/phy/io/filesink.c +++ b/lib/src/phy/io/filesink.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -15,11 +15,11 @@ #include #include -#include "srslte/phy/io/filesink.h" +#include "srsran/phy/io/filesink.h" -int srslte_filesink_init(srslte_filesink_t* q, char* filename, srslte_datatype_t type) +int srsran_filesink_init(srsran_filesink_t* q, char* filename, srsran_datatype_t type) { - bzero(q, sizeof(srslte_filesink_t)); + bzero(q, sizeof(srsran_filesink_t)); q->f = fopen(filename, "w"); if (!q->f) { perror("fopen"); @@ -29,15 +29,15 @@ int srslte_filesink_init(srslte_filesink_t* q, char* filename, srslte_datatype_t return 0; } -void srslte_filesink_free(srslte_filesink_t* q) +void srsran_filesink_free(srsran_filesink_t* q) { if (q->f) { fclose(q->f); } - bzero(q, sizeof(srslte_filesink_t)); + bzero(q, sizeof(srsran_filesink_t)); } -int srslte_filesink_write(srslte_filesink_t* q, void* buffer, int nsamples) +int srsran_filesink_write(srsran_filesink_t* q, void* buffer, int nsamples) { int i = 0; float* fbuf = (float*)buffer; @@ -46,15 +46,15 @@ int srslte_filesink_write(srslte_filesink_t* q, void* buffer, int nsamples) int size = 0; switch (q->type) { - case SRSLTE_TEXT: + case SRSRAN_TEXT: fprintf(q->f, "%s", (char*)buffer); break; - case SRSLTE_FLOAT: + case SRSRAN_FLOAT: for (i = 0; i < nsamples; i++) { fprintf(q->f, "%g\n", fbuf[i]); } break; - case SRSLTE_COMPLEX_FLOAT: + case SRSRAN_COMPLEX_FLOAT: for (i = 0; i < nsamples; i++) { if (__imag__ cbuf[i] >= 0) fprintf(q->f, "%g+%gi\n", __real__ cbuf[i], __imag__ cbuf[i]); @@ -62,7 +62,7 @@ int srslte_filesink_write(srslte_filesink_t* q, void* buffer, int nsamples) fprintf(q->f, "%g-%gi\n", __real__ cbuf[i], fabsf(__imag__ cbuf[i])); } break; - case SRSLTE_COMPLEX_SHORT: + case SRSRAN_COMPLEX_SHORT: for (i = 0; i < nsamples; i++) { if (__imag__ sbuf[i] >= 0) fprintf(q->f, "%hd+%hdi\n", __real__ sbuf[i], __imag__ sbuf[i]); @@ -70,14 +70,14 @@ int srslte_filesink_write(srslte_filesink_t* q, void* buffer, int nsamples) fprintf(q->f, "%hd-%hdi\n", __real__ sbuf[i], (short)abs(__imag__ sbuf[i])); } break; - case SRSLTE_FLOAT_BIN: - case SRSLTE_COMPLEX_FLOAT_BIN: - case SRSLTE_COMPLEX_SHORT_BIN: - if (q->type == SRSLTE_FLOAT_BIN) { + case SRSRAN_FLOAT_BIN: + case SRSRAN_COMPLEX_FLOAT_BIN: + case SRSRAN_COMPLEX_SHORT_BIN: + if (q->type == SRSRAN_FLOAT_BIN) { size = sizeof(float); - } else if (q->type == SRSLTE_COMPLEX_FLOAT_BIN) { + } else if (q->type == SRSRAN_COMPLEX_FLOAT_BIN) { size = sizeof(_Complex float); - } else if (q->type == SRSLTE_COMPLEX_SHORT_BIN) { + } else if (q->type == SRSRAN_COMPLEX_SHORT_BIN) { size = sizeof(_Complex short); } return fwrite(buffer, size, nsamples, q->f); @@ -88,7 +88,7 @@ int srslte_filesink_write(srslte_filesink_t* q, void* buffer, int nsamples) return i; } -int srslte_filesink_write_multi(srslte_filesink_t* q, void** buffer, int nsamples, int nchannels) +int srsran_filesink_write_multi(srsran_filesink_t* q, void** buffer, int nsamples, int nchannels) { int i, j; float** fbuf = (float**)buffer; @@ -97,35 +97,35 @@ int srslte_filesink_write_multi(srslte_filesink_t* q, void** buffer, int nsample int size = 0; switch (q->type) { - case SRSLTE_FLOAT: + case SRSRAN_FLOAT: for (i = 0; i < nsamples; i++) { for (j = 0; j < nchannels; j++) { fprintf(q->f, "%g%c", fbuf[j][i], (j != (nchannels - 1)) ? '\t' : '\n'); } } break; - case SRSLTE_COMPLEX_FLOAT: + case SRSRAN_COMPLEX_FLOAT: for (i = 0; i < nsamples; i++) { for (j = 0; j < nchannels; j++) { fprintf(q->f, "%g%+gi%c", __real__ cbuf[j][i], __imag__ cbuf[j][i], (j != (nchannels - 1)) ? '\t' : '\n'); } } break; - case SRSLTE_COMPLEX_SHORT: + case SRSRAN_COMPLEX_SHORT: for (i = 0; i < nsamples; i++) { for (j = 0; j < nchannels; j++) { fprintf(q->f, "%hd%+hdi%c", __real__ sbuf[j][i], __imag__ sbuf[j][i], (j != (nchannels - 1)) ? '\t' : '\n'); } } break; - case SRSLTE_FLOAT_BIN: - case SRSLTE_COMPLEX_FLOAT_BIN: - case SRSLTE_COMPLEX_SHORT_BIN: - if (q->type == SRSLTE_FLOAT_BIN) { + case SRSRAN_FLOAT_BIN: + case SRSRAN_COMPLEX_FLOAT_BIN: + case SRSRAN_COMPLEX_SHORT_BIN: + if (q->type == SRSRAN_FLOAT_BIN) { size = sizeof(float); - } else if (q->type == SRSLTE_COMPLEX_FLOAT_BIN) { + } else if (q->type == SRSRAN_COMPLEX_FLOAT_BIN) { size = sizeof(_Complex float); - } else if (q->type == SRSLTE_COMPLEX_SHORT_BIN) { + } else if (q->type == SRSRAN_COMPLEX_SHORT_BIN) { size = sizeof(_Complex short); } if (nchannels > 1) { diff --git a/lib/src/phy/io/filesource.c b/lib/src/phy/io/filesource.c index 1ba337f04..39cdfb59a 100644 --- a/lib/src/phy/io/filesource.c +++ b/lib/src/phy/io/filesource.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -14,12 +14,12 @@ #include #include -#include "srslte/phy/io/filesource.h" -#include "srslte/phy/utils/debug.h" +#include "srsran/phy/io/filesource.h" +#include "srsran/phy/utils/debug.h" -int srslte_filesource_init(srslte_filesource_t* q, char* filename, srslte_datatype_t type) +int srsran_filesource_init(srsran_filesource_t* q, char* filename, srsran_datatype_t type) { - bzero(q, sizeof(srslte_filesource_t)); + bzero(q, sizeof(srsran_filesource_t)); q->f = fopen(filename, "r"); if (!q->f) { perror("fopen"); @@ -29,18 +29,18 @@ int srslte_filesource_init(srslte_filesource_t* q, char* filename, srslte_dataty return 0; } -void srslte_filesource_free(srslte_filesource_t* q) +void srsran_filesource_free(srsran_filesource_t* q) { if (q->f) { fclose(q->f); } - bzero(q, sizeof(srslte_filesource_t)); + bzero(q, sizeof(srsran_filesource_t)); } -void srslte_filesource_seek(srslte_filesource_t* q, int pos) +void srsran_filesource_seek(srsran_filesource_t* q, int pos) { if (fseek(q->f, pos, SEEK_SET) != 0) { - perror("srslte_filesource_seek"); + perror("srsran_filesource_seek"); } } @@ -62,7 +62,7 @@ int read_complex_f(FILE* f, _Complex float* y) } } -int srslte_filesource_read(srslte_filesource_t* q, void* buffer, int nsamples) +int srsran_filesource_read(srsran_filesource_t* q, void* buffer, int nsamples) { int i; float* fbuf = (float*)buffer; @@ -71,33 +71,33 @@ int srslte_filesource_read(srslte_filesource_t* q, void* buffer, int nsamples) int size = 0; switch (q->type) { - case SRSLTE_FLOAT: + case SRSRAN_FLOAT: for (i = 0; i < nsamples; i++) { if (EOF == fscanf(q->f, "%g\n", &fbuf[i])) break; } break; - case SRSLTE_COMPLEX_FLOAT: + case SRSRAN_COMPLEX_FLOAT: for (i = 0; i < nsamples; i++) { if (read_complex_f(q->f, &cbuf[i])) { break; } } break; - case SRSLTE_COMPLEX_SHORT: + case SRSRAN_COMPLEX_SHORT: for (i = 0; i < nsamples; i++) { if (EOF == fscanf(q->f, "%hd%hdi\n", &(__real__ sbuf[i]), &(__imag__ sbuf[i]))) break; } break; - case SRSLTE_FLOAT_BIN: - case SRSLTE_COMPLEX_FLOAT_BIN: - case SRSLTE_COMPLEX_SHORT_BIN: - if (q->type == SRSLTE_FLOAT_BIN) { + case SRSRAN_FLOAT_BIN: + case SRSRAN_COMPLEX_FLOAT_BIN: + case SRSRAN_COMPLEX_SHORT_BIN: + if (q->type == SRSRAN_FLOAT_BIN) { size = sizeof(float); - } else if (q->type == SRSLTE_COMPLEX_FLOAT_BIN) { + } else if (q->type == SRSRAN_COMPLEX_FLOAT_BIN) { size = sizeof(_Complex float); - } else if (q->type == SRSLTE_COMPLEX_SHORT_BIN) { + } else if (q->type == SRSRAN_COMPLEX_SHORT_BIN) { size = sizeof(_Complex short); } return fread(buffer, size, nsamples, q->f); @@ -109,21 +109,21 @@ int srslte_filesource_read(srslte_filesource_t* q, void* buffer, int nsamples) return i; } -int srslte_filesource_read_multi(srslte_filesource_t* q, void** buffer, int nsamples, int nof_channels) +int srsran_filesource_read_multi(srsran_filesource_t* q, void** buffer, int nsamples, int nof_channels) { int i, j, count = 0; _Complex float** cbuf = (_Complex float**)buffer; switch (q->type) { - case SRSLTE_FLOAT: - case SRSLTE_COMPLEX_FLOAT: - case SRSLTE_COMPLEX_SHORT: - case SRSLTE_FLOAT_BIN: - case SRSLTE_COMPLEX_SHORT_BIN: + case SRSRAN_FLOAT: + case SRSRAN_COMPLEX_FLOAT: + case SRSRAN_COMPLEX_SHORT: + case SRSRAN_FLOAT_BIN: + case SRSRAN_COMPLEX_SHORT_BIN: ERROR("%s.%d:Read Mode not implemented\n", __FILE__, __LINE__); - count = SRSLTE_ERROR; + count = SRSRAN_ERROR; break; - case SRSLTE_COMPLEX_FLOAT_BIN: + case SRSRAN_COMPLEX_FLOAT_BIN: for (i = 0; i < nsamples; i++) { for (j = 0; j < nof_channels; j++) { count += fread(&cbuf[j][i], sizeof(cf_t), (size_t)1, q->f); @@ -131,7 +131,7 @@ int srslte_filesource_read_multi(srslte_filesource_t* q, void** buffer, int nsam } break; default: - count = SRSLTE_ERROR; + count = SRSRAN_ERROR; break; } return count; diff --git a/lib/src/phy/io/netsink.c b/lib/src/phy/io/netsink.c index 6788cee85..6a05d1d17 100644 --- a/lib/src/phy/io/netsink.c +++ b/lib/src/phy/io/netsink.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -21,13 +21,13 @@ #include #include -#include "srslte/phy/io/netsink.h" +#include "srsran/phy/io/netsink.h" -int srslte_netsink_init(srslte_netsink_t* q, const char* address, uint16_t port, srslte_netsink_type_t type) +int srsran_netsink_init(srsran_netsink_t* q, const char* address, uint16_t port, srsran_netsink_type_t type) { - bzero(q, sizeof(srslte_netsink_t)); + bzero(q, sizeof(srsran_netsink_t)); - q->sockfd = socket(AF_INET, type == SRSLTE_NETSINK_TCP ? SOCK_STREAM : SOCK_DGRAM, 0); + q->sockfd = socket(AF_INET, type == SRSRAN_NETSINK_TCP ? SOCK_STREAM : SOCK_DGRAM, 0); if (q->sockfd < 0) { perror("socket"); return -1; @@ -52,15 +52,15 @@ int srslte_netsink_init(srslte_netsink_t* q, const char* address, uint16_t port, return 0; } -void srslte_netsink_free(srslte_netsink_t* q) +void srsran_netsink_free(srsran_netsink_t* q) { if (q->sockfd) { close(q->sockfd); } - bzero(q, sizeof(srslte_netsink_t)); + bzero(q, sizeof(srsran_netsink_t)); } -int srslte_netsink_set_nonblocking(srslte_netsink_t* q) +int srsran_netsink_set_nonblocking(srsran_netsink_t* q) { if (fcntl(q->sockfd, F_SETFL, O_NONBLOCK)) { perror("fcntl"); @@ -69,7 +69,7 @@ int srslte_netsink_set_nonblocking(srslte_netsink_t* q) return 0; } -int srslte_netsink_write(srslte_netsink_t* q, void* buffer, int nof_bytes) +int srsran_netsink_write(srsran_netsink_t* q, void* buffer, int nof_bytes) { if (!q->connected) { if (connect(q->sockfd, &q->servaddr, sizeof(q->servaddr)) < 0) { @@ -90,7 +90,7 @@ int srslte_netsink_write(srslte_netsink_t* q, void* buffer, int nof_bytes) if (n < 0) { if (errno == ECONNRESET) { close(q->sockfd); - q->sockfd = socket(AF_INET, q->type == SRSLTE_NETSINK_TCP ? SOCK_STREAM : SOCK_DGRAM, 0); + q->sockfd = socket(AF_INET, q->type == SRSRAN_NETSINK_TCP ? SOCK_STREAM : SOCK_DGRAM, 0); if (q->sockfd < 0) { perror("socket"); return -1; diff --git a/lib/src/phy/io/netsource.c b/lib/src/phy/io/netsource.c index 810d0fa3e..a4f23066c 100644 --- a/lib/src/phy/io/netsource.c +++ b/lib/src/phy/io/netsource.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -20,13 +20,13 @@ #include #include -#include "srslte/phy/io/netsource.h" +#include "srsran/phy/io/netsource.h" -int srslte_netsource_init(srslte_netsource_t* q, const char* address, uint16_t port, srslte_netsource_type_t type) +int srsran_netsource_init(srsran_netsource_t* q, const char* address, uint16_t port, srsran_netsource_type_t type) { - bzero(q, sizeof(srslte_netsource_t)); + bzero(q, sizeof(srsran_netsource_t)); - q->sockfd = socket(AF_INET, type == SRSLTE_NETSOURCE_TCP ? SOCK_STREAM : SOCK_DGRAM, 0); + q->sockfd = socket(AF_INET, type == SRSRAN_NETSOURCE_TCP ? SOCK_STREAM : SOCK_DGRAM, 0); if (q->sockfd < 0) { perror("socket"); @@ -58,17 +58,17 @@ int srslte_netsource_init(srslte_netsource_t* q, const char* address, uint16_t p return 0; } -void srslte_netsource_free(srslte_netsource_t* q) +void srsran_netsource_free(srsran_netsource_t* q) { if (q->sockfd) { close(q->sockfd); } - bzero(q, sizeof(srslte_netsource_t)); + bzero(q, sizeof(srsran_netsource_t)); } -int srslte_netsource_read(srslte_netsource_t* q, void* buffer, int nbytes) +int srsran_netsource_read(srsran_netsource_t* q, void* buffer, int nbytes) { - if (q->type == SRSLTE_NETSOURCE_UDP) { + if (q->type == SRSRAN_NETSOURCE_UDP) { int n = recv(q->sockfd, buffer, nbytes, 0); if (n == -1) { @@ -105,7 +105,7 @@ int srslte_netsource_read(srslte_netsource_t* q, void* buffer, int nbytes) } } -int srslte_netsource_write(srslte_netsource_t* q, void* buffer, int nbytes) +int srsran_netsource_write(srsran_netsource_t* q, void* buffer, int nbytes) { // Loop until all bytes are sent char* ptr = (char*)buffer; @@ -113,15 +113,15 @@ int srslte_netsource_write(srslte_netsource_t* q, void* buffer, int nbytes) ssize_t i = send(q->connfd, ptr, nbytes, 0); if (i < 1) { perror("Error calling send()\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } ptr += i; nbytes -= i; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_netsource_set_nonblocking(srslte_netsource_t* q) +int srsran_netsource_set_nonblocking(srsran_netsource_t* q) { if (fcntl(q->sockfd, F_SETFL, O_NONBLOCK)) { perror("fcntl"); @@ -130,7 +130,7 @@ int srslte_netsource_set_nonblocking(srslte_netsource_t* q) return 0; } -int srslte_netsource_set_timeout(srslte_netsource_t* q, uint32_t microseconds) +int srsran_netsource_set_timeout(srsran_netsource_t* q, uint32_t microseconds) { struct timeval t; t.tv_sec = 0; diff --git a/lib/src/phy/mimo/CMakeLists.txt b/lib/src/phy/mimo/CMakeLists.txt index 46587a678..fd8a30660 100644 --- a/lib/src/phy/mimo/CMakeLists.txt +++ b/lib/src/phy/mimo/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -7,5 +7,5 @@ # file(GLOB SOURCES "*.c") -add_library(srslte_mimo OBJECT ${SOURCES}) +add_library(srsran_mimo OBJECT ${SOURCES}) add_subdirectory(test) diff --git a/lib/src/phy/mimo/layermap.c b/lib/src/phy/mimo/layermap.c index a975c2646..db6a8bce6 100644 --- a/lib/src/phy/mimo/layermap.c +++ b/lib/src/phy/mimo/layermap.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -14,19 +14,19 @@ #include #include -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/common/phy_common_nr.h" -#include "srslte/phy/mimo/layermap.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/common/phy_common_nr.h" +#include "srsran/phy/mimo/layermap.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" -int srslte_layermap_single(cf_t* d, cf_t* x, int nof_symbols) +int srsran_layermap_single(cf_t* d, cf_t* x, int nof_symbols) { memcpy(x, d, sizeof(cf_t) * nof_symbols); return nof_symbols; } -int srslte_layermap_diversity(cf_t* d, cf_t* x[SRSLTE_MAX_LAYERS], int nof_layers, int nof_symbols) +int srsran_layermap_diversity(cf_t* d, cf_t* x[SRSRAN_MAX_LAYERS], int nof_layers, int nof_symbols) { int i, j; for (i = 0; i < nof_symbols / nof_layers; i++) { @@ -37,26 +37,26 @@ int srslte_layermap_diversity(cf_t* d, cf_t* x[SRSLTE_MAX_LAYERS], int nof_layer return i; } -int srslte_layermap_multiplex(cf_t* d[SRSLTE_MAX_CODEWORDS], - cf_t* x[SRSLTE_MAX_LAYERS], +int srsran_layermap_multiplex(cf_t* d[SRSRAN_MAX_CODEWORDS], + cf_t* x[SRSRAN_MAX_LAYERS], int nof_cw, int nof_layers, - int nof_symbols[SRSLTE_MAX_CODEWORDS]) + int nof_symbols[SRSRAN_MAX_CODEWORDS]) { if (nof_cw == nof_layers) { for (int i = 0; i < nof_cw; i++) { - srslte_vec_cf_copy(x[i], d[i], (uint32_t)nof_symbols[0]); + srsran_vec_cf_copy(x[i], d[i], (uint32_t)nof_symbols[0]); } return nof_symbols[0]; } else if (nof_cw == 1) { - return srslte_layermap_diversity(d[0], x, nof_layers, nof_symbols[0]); + return srsran_layermap_diversity(d[0], x, nof_layers, nof_symbols[0]); } else { int n[2]; n[0] = nof_layers / nof_cw; n[1] = nof_layers - n[0]; if (nof_symbols[0] / n[0] == nof_symbols[1] / n[1]) { - srslte_layermap_diversity(d[0], x, n[0], nof_symbols[0]); - srslte_layermap_diversity(d[1], &x[n[0]], n[1], nof_symbols[1]); + srsran_layermap_diversity(d[0], x, n[0], nof_symbols[0]); + srsran_layermap_diversity(d[1], &x[n[0]], n[1], nof_symbols[1]); return nof_symbols[0] / n[0]; } else { @@ -71,19 +71,19 @@ int srslte_layermap_multiplex(cf_t* d[SRSLTE_MAX_CODEWORDS], * Based on 36.211 6.3.3 * Returns the number of symbols per layer (M_symb^layer in the specs) */ -int srslte_layermap_type(cf_t* d[SRSLTE_MAX_CODEWORDS], - cf_t* x[SRSLTE_MAX_LAYERS], +int srsran_layermap_type(cf_t* d[SRSRAN_MAX_CODEWORDS], + cf_t* x[SRSRAN_MAX_LAYERS], int nof_cw, int nof_layers, - int nof_symbols[SRSLTE_MAX_CODEWORDS], - srslte_tx_scheme_t type) + int nof_symbols[SRSRAN_MAX_CODEWORDS], + srsran_tx_scheme_t type) { - if (nof_cw > SRSLTE_MAX_CODEWORDS) { - ERROR("Maximum number of codewords is %d (nof_cw=%d)", SRSLTE_MAX_CODEWORDS, nof_cw); + if (nof_cw > SRSRAN_MAX_CODEWORDS) { + ERROR("Maximum number of codewords is %d (nof_cw=%d)", SRSRAN_MAX_CODEWORDS, nof_cw); return -1; } - if (nof_layers > SRSLTE_MAX_LAYERS) { - ERROR("Maximum number of layers is %d (nof_layers=%d)", SRSLTE_MAX_LAYERS, nof_layers); + if (nof_layers > SRSRAN_MAX_LAYERS) { + ERROR("Maximum number of layers is %d (nof_layers=%d)", SRSRAN_MAX_LAYERS, nof_layers); return -1; } if (nof_layers < nof_cw) { @@ -92,18 +92,18 @@ int srslte_layermap_type(cf_t* d[SRSLTE_MAX_CODEWORDS], } switch (type) { - case SRSLTE_TXSCHEME_PORT0: + case SRSRAN_TXSCHEME_PORT0: if (nof_cw == 1 && nof_layers == 1) { - return srslte_layermap_single(d[0], x[0], nof_symbols[0]); + return srsran_layermap_single(d[0], x[0], nof_symbols[0]); } else { ERROR("Number of codewords and layers must be 1 for transmission on single antenna ports"); return -1; } break; - case SRSLTE_TXSCHEME_DIVERSITY: + case SRSRAN_TXSCHEME_DIVERSITY: if (nof_cw == 1) { if (nof_layers == 2 || nof_layers == 4) { - return srslte_layermap_diversity(d[0], x, nof_layers, nof_symbols[0]); + return srsran_layermap_diversity(d[0], x, nof_layers, nof_symbols[0]); } else { ERROR("Number of layers must be 2 or 4 for transmit diversity"); return -1; @@ -113,20 +113,20 @@ int srslte_layermap_type(cf_t* d[SRSLTE_MAX_CODEWORDS], return -1; } break; - case SRSLTE_TXSCHEME_SPATIALMUX: - case SRSLTE_TXSCHEME_CDD: - return srslte_layermap_multiplex(d, x, nof_cw, nof_layers, nof_symbols); + case SRSRAN_TXSCHEME_SPATIALMUX: + case SRSRAN_TXSCHEME_CDD: + return srsran_layermap_multiplex(d, x, nof_cw, nof_layers, nof_symbols); break; } return 0; } -int srslte_layerdemap_single(cf_t* x, cf_t* d, int nof_symbols) +int srsran_layerdemap_single(cf_t* x, cf_t* d, int nof_symbols) { memcpy(d, x, sizeof(cf_t) * nof_symbols); return nof_symbols; } -int srslte_layerdemap_diversity(cf_t* x[SRSLTE_MAX_LAYERS], cf_t* d, int nof_layers, int nof_layer_symbols) +int srsran_layerdemap_diversity(cf_t* x[SRSRAN_MAX_LAYERS], cf_t* d, int nof_layers, int nof_layer_symbols) { int i, j; for (i = 0; i < nof_layer_symbols; i++) { @@ -137,15 +137,15 @@ int srslte_layerdemap_diversity(cf_t* x[SRSLTE_MAX_LAYERS], cf_t* d, int nof_lay return nof_layer_symbols * nof_layers; } -int srslte_layerdemap_multiplex(cf_t* x[SRSLTE_MAX_LAYERS], - cf_t* d[SRSLTE_MAX_CODEWORDS], +int srsran_layerdemap_multiplex(cf_t* x[SRSRAN_MAX_LAYERS], + cf_t* d[SRSRAN_MAX_CODEWORDS], int nof_layers, int nof_cw, int nof_layer_symbols, - int nof_symbols[SRSLTE_MAX_CODEWORDS]) + int nof_symbols[SRSRAN_MAX_CODEWORDS]) { if (nof_cw == 1) { - return srslte_layerdemap_diversity(x, d[0], nof_layers, nof_layer_symbols); + return srsran_layerdemap_diversity(x, d[0], nof_layers, nof_layer_symbols); } else { int n[2]; n[0] = nof_layers / nof_cw; @@ -153,8 +153,8 @@ int srslte_layerdemap_multiplex(cf_t* x[SRSLTE_MAX_LAYERS], nof_symbols[0] = n[0] * nof_layer_symbols; nof_symbols[1] = n[1] * nof_layer_symbols; - nof_symbols[0] = srslte_layerdemap_diversity(x, d[0], n[0], nof_layer_symbols); - nof_symbols[1] = srslte_layerdemap_diversity(&x[n[0]], d[1], n[1], nof_layer_symbols); + nof_symbols[0] = srsran_layerdemap_diversity(x, d[0], n[0], nof_layer_symbols); + nof_symbols[1] = srsran_layerdemap_diversity(&x[n[0]], d[1], n[1], nof_layer_symbols); } return 0; } @@ -164,20 +164,20 @@ int srslte_layerdemap_multiplex(cf_t* x[SRSLTE_MAX_LAYERS], * Returns 0 on ok and saves the number of symbols per codeword (M_symb^(q) in the specs) in * nof_symbols. Returns -1 on error */ -int srslte_layerdemap_type(cf_t* x[SRSLTE_MAX_LAYERS], - cf_t* d[SRSLTE_MAX_CODEWORDS], +int srsran_layerdemap_type(cf_t* x[SRSRAN_MAX_LAYERS], + cf_t* d[SRSRAN_MAX_CODEWORDS], int nof_layers, int nof_cw, int nof_layer_symbols, - int nof_symbols[SRSLTE_MAX_CODEWORDS], - srslte_tx_scheme_t type) + int nof_symbols[SRSRAN_MAX_CODEWORDS], + srsran_tx_scheme_t type) { - if (nof_cw > SRSLTE_MAX_CODEWORDS) { - ERROR("Maximum number of codewords is %d (nof_cw=%d)", SRSLTE_MAX_CODEWORDS, nof_cw); + if (nof_cw > SRSRAN_MAX_CODEWORDS) { + ERROR("Maximum number of codewords is %d (nof_cw=%d)", SRSRAN_MAX_CODEWORDS, nof_cw); return -1; } - if (nof_layers > SRSLTE_MAX_LAYERS) { - ERROR("Maximum number of layers is %d (nof_layers=%d)", SRSLTE_MAX_LAYERS, nof_layers); + if (nof_layers > SRSRAN_MAX_LAYERS) { + ERROR("Maximum number of layers is %d (nof_layers=%d)", SRSRAN_MAX_LAYERS, nof_layers); return -1; } if (nof_layers < nof_cw) { @@ -186,19 +186,19 @@ int srslte_layerdemap_type(cf_t* x[SRSLTE_MAX_LAYERS], } switch (type) { - case SRSLTE_TXSCHEME_PORT0: + case SRSRAN_TXSCHEME_PORT0: if (nof_cw == 1 && nof_layers == 1) { - nof_symbols[0] = srslte_layerdemap_single(x[0], d[0], nof_layer_symbols); + nof_symbols[0] = srsran_layerdemap_single(x[0], d[0], nof_layer_symbols); nof_symbols[1] = 0; } else { ERROR("Number of codewords and layers must be 1 for transmission on single antenna ports"); return -1; } break; - case SRSLTE_TXSCHEME_DIVERSITY: + case SRSRAN_TXSCHEME_DIVERSITY: if (nof_cw == 1) { if (nof_layers == 2 || nof_layers == 4) { - nof_symbols[0] = srslte_layerdemap_diversity(x, d[0], nof_layers, nof_layer_symbols); + nof_symbols[0] = srsran_layerdemap_diversity(x, d[0], nof_layers, nof_layer_symbols); nof_symbols[1] = 0; } else { ERROR("Number of layers must be 2 or 4 for transmit diversity"); @@ -209,15 +209,15 @@ int srslte_layerdemap_type(cf_t* x[SRSLTE_MAX_LAYERS], return -1; } break; - case SRSLTE_TXSCHEME_SPATIALMUX: - case SRSLTE_TXSCHEME_CDD: - return srslte_layerdemap_multiplex(x, d, nof_layers, nof_cw, nof_layer_symbols, nof_symbols); + case SRSRAN_TXSCHEME_SPATIALMUX: + case SRSRAN_TXSCHEME_CDD: + return srsran_layerdemap_multiplex(x, d, nof_layers, nof_cw, nof_layer_symbols, nof_symbols); break; } return 0; } -int srslte_layermap_nr(cf_t** d, int nof_cw, cf_t** x, int nof_layers, uint32_t nof_re) +int srsran_layermap_nr(cf_t** d, int nof_cw, cf_t** x, int nof_layers, uint32_t nof_re) { if (nof_cw == 1 && nof_layers > 0 && nof_layers < 5) { for (uint32_t i = 0; i < nof_re / nof_layers; i++) { @@ -225,10 +225,10 @@ int srslte_layermap_nr(cf_t** d, int nof_cw, cf_t** x, int nof_layers, uint32_t x[j][i] = d[0][nof_layers * i + j]; } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } - if (nof_cw == 2 && nof_layers >= 5 && nof_layers <= SRSLTE_MAX_LAYERS_NR) { + if (nof_cw == 2 && nof_layers >= 5 && nof_layers <= SRSRAN_MAX_LAYERS_NR) { uint32_t nof_layers_cw1 = nof_layers / 2; for (uint32_t i = 0; i < nof_re / nof_layers_cw1; i++) { for (uint32_t j = 0; j < nof_layers_cw1; j++) { @@ -243,14 +243,14 @@ int srslte_layermap_nr(cf_t** d, int nof_cw, cf_t** x, int nof_layers, uint32_t } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } ERROR("Error. Incompatible number of layers (%d) and codewords (%d)", nof_layers, nof_cw); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } -int srslte_layerdemap_nr(cf_t** d, int nof_cw, cf_t** x, int nof_layers, uint32_t nof_re) +int srsran_layerdemap_nr(cf_t** d, int nof_cw, cf_t** x, int nof_layers, uint32_t nof_re) { if (nof_cw == 1 && nof_layers > 0 && nof_layers < 5) { for (uint32_t i = 0; i < nof_re / nof_layers; i++) { @@ -258,10 +258,10 @@ int srslte_layerdemap_nr(cf_t** d, int nof_cw, cf_t** x, int nof_layers, uint32_ d[0][nof_layers * i + j] = x[j][i]; } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } - if (nof_cw == 2 && nof_layers >= 5 && nof_layers <= SRSLTE_MAX_LAYERS_NR) { + if (nof_cw == 2 && nof_layers >= 5 && nof_layers <= SRSRAN_MAX_LAYERS_NR) { uint32_t nof_layers_cw1 = nof_layers / 2; for (uint32_t i = 0; i < nof_re / nof_layers_cw1; i++) { for (uint32_t j = 0; j < nof_layers_cw1; j++) { @@ -276,9 +276,9 @@ int srslte_layerdemap_nr(cf_t** d, int nof_cw, cf_t** x, int nof_layers, uint32_ } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } ERROR("Error. Incompatible number of layers (%d) and codewords (%d)", nof_layers, nof_cw); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } diff --git a/lib/src/phy/mimo/precoding.c b/lib/src/phy/mimo/precoding.c index d0202c976..275cdbfb7 100644 --- a/lib/src/phy/mimo/precoding.c +++ b/lib/src/phy/mimo/precoding.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -15,25 +15,25 @@ #include #include -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/mimo/precoding.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/mat.h" -#include "srslte/phy/utils/simd.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/mimo/precoding.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/mat.h" +#include "srsran/phy/utils/simd.h" +#include "srsran/phy/utils/vector.h" #ifdef LV_HAVE_SSE #include -int srslte_predecoding_single_sse(cf_t* y[SRSLTE_MAX_PORTS], - cf_t* h[SRSLTE_MAX_PORTS], +int srsran_predecoding_single_sse(cf_t* y[SRSRAN_MAX_PORTS], + cf_t* h[SRSRAN_MAX_PORTS], cf_t* x, int nof_rxant, int nof_symbols, float scaling, float noise_estimate); -int srslte_predecoding_diversity2_sse(cf_t* y[SRSLTE_MAX_PORTS], - cf_t* h[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS], - cf_t* x[SRSLTE_MAX_LAYERS], +int srsran_predecoding_diversity2_sse(cf_t* y[SRSRAN_MAX_PORTS], + cf_t* h[SRSRAN_MAX_PORTS][SRSRAN_MAX_PORTS], + cf_t* x[SRSRAN_MAX_LAYERS], int nof_rxant, int nof_symbols, float scaling); @@ -41,17 +41,17 @@ int srslte_predecoding_diversity2_sse(cf_t* y[SRSLTE_MAX_PORTS], #ifdef LV_HAVE_AVX #include -int srslte_predecoding_single_avx(cf_t* y[SRSLTE_MAX_PORTS], - cf_t* h[SRSLTE_MAX_PORTS], +int srsran_predecoding_single_avx(cf_t* y[SRSRAN_MAX_PORTS], + cf_t* h[SRSRAN_MAX_PORTS], cf_t* x, int nof_rxant, int nof_symbols, float scaling, float noise_estimate); #endif -#include "srslte/phy/utils/mat.h" +#include "srsran/phy/utils/mat.h" -static srslte_mimo_decoder_t mimo_decoder = SRSLTE_MIMO_DECODER_MMSE; +static srsran_mimo_decoder_t mimo_decoder = SRSRAN_MIMO_DECODER_MMSE; /************************************************ * @@ -64,8 +64,8 @@ static srslte_mimo_decoder_t mimo_decoder = SRSLTE_MIMO_DECODER_MMSE; #define PROD(a, b) \ _mm_addsub_ps(_mm_mul_ps(a, _mm_moveldup_ps(b)), _mm_mul_ps(_mm_shuffle_ps(a, a, 0xB1), _mm_movehdup_ps(b))) -int srslte_predecoding_single_sse(cf_t* y[SRSLTE_MAX_PORTS], - cf_t* h[SRSLTE_MAX_PORTS], +int srsran_predecoding_single_sse(cf_t* y[SRSRAN_MAX_PORTS], + cf_t* h[SRSRAN_MAX_PORTS], cf_t* x, int nof_rxant, int nof_symbols, @@ -170,8 +170,8 @@ int srslte_predecoding_single_sse(cf_t* y[SRSLTE_MAX_PORTS], _mm256_addsub_ps(_mm256_mul_ps(a, _mm256_moveldup_ps(b)), \ _mm256_mul_ps(_mm256_shuffle_ps(a, a, 0xB1), _mm256_movehdup_ps(b))) -int srslte_predecoding_single_avx(cf_t* y[SRSLTE_MAX_PORTS], - cf_t* h[SRSLTE_MAX_PORTS], +int srsran_predecoding_single_avx(cf_t* y[SRSRAN_MAX_PORTS], + cf_t* h[SRSRAN_MAX_PORTS], cf_t* x, int nof_rxant, int nof_symbols, @@ -275,8 +275,8 @@ int srslte_predecoding_single_avx(cf_t* y[SRSLTE_MAX_PORTS], #endif -int srslte_predecoding_single_gen(cf_t* y[SRSLTE_MAX_PORTS], - cf_t* h[SRSLTE_MAX_PORTS], +int srsran_predecoding_single_gen(cf_t* y[SRSRAN_MAX_PORTS], + cf_t* h[SRSRAN_MAX_PORTS], cf_t* x, int nof_rxant, int nof_symbols, @@ -295,8 +295,8 @@ int srslte_predecoding_single_gen(cf_t* y[SRSLTE_MAX_PORTS], return nof_symbols; } -int srslte_predecoding_single_csi(cf_t* y[SRSLTE_MAX_PORTS], - cf_t* h[SRSLTE_MAX_PORTS], +int srsran_predecoding_single_csi(cf_t* y[SRSRAN_MAX_PORTS], + cf_t* h[SRSRAN_MAX_PORTS], cf_t* x, float* csi, int nof_rxant, @@ -306,27 +306,27 @@ int srslte_predecoding_single_csi(cf_t* y[SRSLTE_MAX_PORTS], { int i = 0; -#if SRSLTE_SIMD_CF_SIZE - const simd_f_t _noise = srslte_simd_f_set1(noise_estimate); - const simd_f_t _scaling = srslte_simd_f_set1(1.0f / scaling); +#if SRSRAN_SIMD_CF_SIZE + const simd_f_t _noise = srsran_simd_f_set1(noise_estimate); + const simd_f_t _scaling = srsran_simd_f_set1(1.0f / scaling); - for (; i < nof_symbols - SRSLTE_SIMD_CF_SIZE + 1; i += SRSLTE_SIMD_CF_SIZE) { - simd_cf_t _r = srslte_simd_cf_zero(); - simd_f_t _hh = srslte_simd_f_zero(); + for (; i < nof_symbols - SRSRAN_SIMD_CF_SIZE + 1; i += SRSRAN_SIMD_CF_SIZE) { + simd_cf_t _r = srsran_simd_cf_zero(); + simd_f_t _hh = srsran_simd_f_zero(); for (int p = 0; p < nof_rxant; p++) { - simd_cf_t _y = srslte_simd_cfi_load(&y[p][i]); - simd_cf_t _h = srslte_simd_cfi_load(&h[p][i]); + simd_cf_t _y = srsran_simd_cfi_load(&y[p][i]); + simd_cf_t _h = srsran_simd_cfi_load(&h[p][i]); - _r = srslte_simd_cf_add(_r, srslte_simd_cf_conjprod(_y, _h)); - _hh = srslte_simd_f_add(_hh, srslte_simd_cf_re(srslte_simd_cf_conjprod(_h, _h))); + _r = srsran_simd_cf_add(_r, srsran_simd_cf_conjprod(_y, _h)); + _hh = srsran_simd_f_add(_hh, srsran_simd_cf_re(srsran_simd_cf_conjprod(_h, _h))); } - simd_f_t _csi = srslte_simd_f_add(_hh, _noise); - simd_cf_t _x = srslte_simd_cf_mul(srslte_simd_cf_mul(_r, _scaling), srslte_simd_f_rcp(_csi)); + simd_f_t _csi = srsran_simd_f_add(_hh, _noise); + simd_cf_t _x = srsran_simd_cf_mul(srsran_simd_cf_mul(_r, _scaling), srsran_simd_f_rcp(_csi)); - srslte_simd_f_store(&csi[i], _csi); - srslte_simd_cfi_store(&x[i], _x); + srsran_simd_f_store(&csi[i], _csi); + srsran_simd_cfi_store(&x[i], _x); } #endif @@ -345,7 +345,7 @@ int srslte_predecoding_single_csi(cf_t* y[SRSLTE_MAX_PORTS], } /* ZF/MMSE SISO equalizer x=y(h'h+no)^(-1)h' (ZF if n0=0.0)*/ -int srslte_predecoding_single(cf_t* y_, +int srsran_predecoding_single(cf_t* y_, cf_t* h_, cf_t* x, float* csi, @@ -353,72 +353,72 @@ int srslte_predecoding_single(cf_t* y_, float scaling, float noise_estimate) { - cf_t* y[SRSLTE_MAX_PORTS]; - cf_t* h[SRSLTE_MAX_PORTS]; + cf_t* y[SRSRAN_MAX_PORTS]; + cf_t* h[SRSRAN_MAX_PORTS]; y[0] = y_; h[0] = h_; int nof_rxant = 1; if (csi) { - return srslte_predecoding_single_csi(y, h, x, csi, nof_rxant, nof_symbols, scaling, noise_estimate); + return srsran_predecoding_single_csi(y, h, x, csi, nof_rxant, nof_symbols, scaling, noise_estimate); } #ifdef LV_HAVE_AVX if (nof_symbols > 32 && nof_rxant <= 2) { - return srslte_predecoding_single_avx(y, h, x, nof_rxant, nof_symbols, scaling, noise_estimate); + return srsran_predecoding_single_avx(y, h, x, nof_rxant, nof_symbols, scaling, noise_estimate); } else { - return srslte_predecoding_single_gen(y, h, x, nof_rxant, nof_symbols, scaling, noise_estimate); + return srsran_predecoding_single_gen(y, h, x, nof_rxant, nof_symbols, scaling, noise_estimate); } #else #ifdef LV_HAVE_SSE if (nof_symbols > 32 && nof_rxant <= 2) { - return srslte_predecoding_single_sse(y, h, x, nof_rxant, nof_symbols, scaling, noise_estimate); + return srsran_predecoding_single_sse(y, h, x, nof_rxant, nof_symbols, scaling, noise_estimate); } else { - return srslte_predecoding_single_gen(y, h, x, nof_rxant, nof_symbols, scaling, noise_estimate); + return srsran_predecoding_single_gen(y, h, x, nof_rxant, nof_symbols, scaling, noise_estimate); } #else - return srslte_predecoding_single_gen(y, h, x, nof_rxant, nof_symbols, scaling, noise_estimate); + return srsran_predecoding_single_gen(y, h, x, nof_rxant, nof_symbols, scaling, noise_estimate); #endif #endif } /* ZF/MMSE SISO equalizer x=y(h'h+no)^(-1)h' (ZF if n0=0.0)*/ -int srslte_predecoding_single_multi(cf_t* y[SRSLTE_MAX_PORTS], - cf_t* h[SRSLTE_MAX_PORTS], +int srsran_predecoding_single_multi(cf_t* y[SRSRAN_MAX_PORTS], + cf_t* h[SRSRAN_MAX_PORTS], cf_t* x, - float* csi[SRSLTE_MAX_CODEWORDS], + float* csi[SRSRAN_MAX_CODEWORDS], int nof_rxant, int nof_symbols, float scaling, float noise_estimate) { if (csi && csi[0]) { - return srslte_predecoding_single_csi(y, h, x, csi[0], nof_rxant, nof_symbols, scaling, noise_estimate); + return srsran_predecoding_single_csi(y, h, x, csi[0], nof_rxant, nof_symbols, scaling, noise_estimate); } #ifdef LV_HAVE_AVX if (nof_symbols > 32) { - return srslte_predecoding_single_avx(y, h, x, nof_rxant, nof_symbols, scaling, noise_estimate); + return srsran_predecoding_single_avx(y, h, x, nof_rxant, nof_symbols, scaling, noise_estimate); } else { - return srslte_predecoding_single_gen(y, h, x, nof_rxant, nof_symbols, scaling, noise_estimate); + return srsran_predecoding_single_gen(y, h, x, nof_rxant, nof_symbols, scaling, noise_estimate); } #else #ifdef LV_HAVE_SSE if (nof_symbols > 32) { - return srslte_predecoding_single_sse(y, h, x, nof_rxant, nof_symbols, scaling, noise_estimate); + return srsran_predecoding_single_sse(y, h, x, nof_rxant, nof_symbols, scaling, noise_estimate); } else { - return srslte_predecoding_single_gen(y, h, x, nof_rxant, nof_symbols, scaling, noise_estimate); + return srsran_predecoding_single_gen(y, h, x, nof_rxant, nof_symbols, scaling, noise_estimate); } #else - return srslte_predecoding_single_gen(y, h, x, nof_rxant, nof_symbols, scaling, noise_estimate); + return srsran_predecoding_single_gen(y, h, x, nof_rxant, nof_symbols, scaling, noise_estimate); #endif #endif } /* C implementatino of the SFBC equalizer */ -int srslte_predecoding_diversity_gen_(cf_t* y[SRSLTE_MAX_PORTS], - cf_t* h[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS], - cf_t* x[SRSLTE_MAX_LAYERS], +int srsran_predecoding_diversity_gen_(cf_t* y[SRSRAN_MAX_PORTS], + cf_t* h[SRSRAN_MAX_PORTS][SRSRAN_MAX_PORTS], + cf_t* x[SRSRAN_MAX_LAYERS], int nof_rxant, int nof_ports, int nof_symbols, @@ -493,22 +493,22 @@ int srslte_predecoding_diversity_gen_(cf_t* y[SRSLTE_MAX_PORTS], } } -int srslte_predecoding_diversity_gen(cf_t* y[SRSLTE_MAX_PORTS], - cf_t* h[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS], - cf_t* x[SRSLTE_MAX_LAYERS], +int srsran_predecoding_diversity_gen(cf_t* y[SRSRAN_MAX_PORTS], + cf_t* h[SRSRAN_MAX_PORTS][SRSRAN_MAX_PORTS], + cf_t* x[SRSRAN_MAX_LAYERS], int nof_rxant, int nof_ports, int nof_symbols, float scaling) { - return srslte_predecoding_diversity_gen_(y, h, x, nof_rxant, nof_ports, nof_symbols, 0, scaling); + return srsran_predecoding_diversity_gen_(y, h, x, nof_rxant, nof_ports, nof_symbols, 0, scaling); } /* SSE implementation of the 2-port SFBC equalizer */ #ifdef LV_HAVE_SSE -int srslte_predecoding_diversity2_sse(cf_t* y[SRSLTE_MAX_PORTS], - cf_t* h[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS], - cf_t* x[SRSLTE_MAX_LAYERS], +int srsran_predecoding_diversity2_sse(cf_t* y[SRSRAN_MAX_PORTS], + cf_t* h[SRSRAN_MAX_PORTS][SRSRAN_MAX_PORTS], + cf_t* x[SRSRAN_MAX_LAYERS], int nof_rxant, int nof_symbols, float scaling) @@ -629,20 +629,20 @@ int srslte_predecoding_diversity2_sse(cf_t* y[SRSLTE_MAX_PORTS], x1Ptr += 4; } // Compute remaining symbols using generic implementation - srslte_predecoding_diversity_gen_(y, h, x, nof_rxant, 2, nof_symbols, 4 * (nof_symbols / 4), scaling); + srsran_predecoding_diversity_gen_(y, h, x, nof_rxant, 2, nof_symbols, 4 * (nof_symbols / 4), scaling); return nof_symbols; } #endif -int srslte_predecoding_diversity(cf_t* y_, - cf_t* h_[SRSLTE_MAX_PORTS], - cf_t* x[SRSLTE_MAX_LAYERS], +int srsran_predecoding_diversity(cf_t* y_, + cf_t* h_[SRSRAN_MAX_PORTS], + cf_t* x[SRSRAN_MAX_LAYERS], int nof_ports, int nof_symbols, float scaling) { - cf_t* h[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS]; - cf_t* y[SRSLTE_MAX_PORTS]; + cf_t* h[SRSRAN_MAX_PORTS][SRSRAN_MAX_PORTS]; + cf_t* y[SRSRAN_MAX_PORTS]; uint32_t nof_rxant = 1; for (int i = 0; i < nof_ports; i++) { @@ -652,19 +652,19 @@ int srslte_predecoding_diversity(cf_t* y_, #ifdef LV_HAVE_SSE if (nof_symbols > 32 && nof_ports == 2) { - return srslte_predecoding_diversity2_sse(y, h, x, nof_rxant, nof_symbols, scaling); + return srsran_predecoding_diversity2_sse(y, h, x, nof_rxant, nof_symbols, scaling); } else { - return srslte_predecoding_diversity_gen(y, h, x, nof_rxant, nof_ports, nof_symbols, scaling); + return srsran_predecoding_diversity_gen(y, h, x, nof_rxant, nof_ports, nof_symbols, scaling); } #else - return srslte_predecoding_diversity_gen(y, h, x, nof_rxant, nof_ports, nof_symbols, scaling); + return srsran_predecoding_diversity_gen(y, h, x, nof_rxant, nof_ports, nof_symbols, scaling); #endif } -int srslte_predecoding_diversity_csi(cf_t* y[SRSLTE_MAX_PORTS], - cf_t* h[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS], - cf_t* x[SRSLTE_MAX_LAYERS], - float* csi[SRSLTE_MAX_CODEWORDS], +int srsran_predecoding_diversity_csi(cf_t* y[SRSRAN_MAX_PORTS], + cf_t* h[SRSRAN_MAX_PORTS][SRSRAN_MAX_PORTS], + cf_t* x[SRSRAN_MAX_LAYERS], + float* csi[SRSRAN_MAX_CODEWORDS], int nof_rxant, int nof_ports, int nof_symbols, @@ -768,34 +768,34 @@ int srslte_predecoding_diversity_csi(cf_t* y[SRSLTE_MAX_PORTS], } } -int srslte_predecoding_diversity_multi(cf_t* y[SRSLTE_MAX_PORTS], - cf_t* h[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS], - cf_t* x[SRSLTE_MAX_LAYERS], - float* csi[SRSLTE_MAX_CODEWORDS], +int srsran_predecoding_diversity_multi(cf_t* y[SRSRAN_MAX_PORTS], + cf_t* h[SRSRAN_MAX_PORTS][SRSRAN_MAX_PORTS], + cf_t* x[SRSRAN_MAX_LAYERS], + float* csi[SRSRAN_MAX_CODEWORDS], int nof_rxant, int nof_ports, int nof_symbols, float scaling) { if (csi && csi[0]) { - return srslte_predecoding_diversity_csi(y, h, x, csi, nof_rxant, nof_ports, nof_symbols, scaling); + return srsran_predecoding_diversity_csi(y, h, x, csi, nof_rxant, nof_ports, nof_symbols, scaling); } else { #ifdef LV_HAVE_SSE if (nof_symbols > 32 && nof_ports == 2) { - return srslte_predecoding_diversity2_sse(y, h, x, nof_rxant, nof_symbols, scaling); + return srsran_predecoding_diversity2_sse(y, h, x, nof_rxant, nof_symbols, scaling); } else { - return srslte_predecoding_diversity_gen(y, h, x, nof_rxant, nof_ports, nof_symbols, scaling); + return srsran_predecoding_diversity_gen(y, h, x, nof_rxant, nof_ports, nof_symbols, scaling); } #else - return srslte_predecoding_diversity_gen(y, h, x, nof_rxant, nof_ports, nof_symbols, scaling); + return srsran_predecoding_diversity_gen(y, h, x, nof_rxant, nof_ports, nof_symbols, scaling); #endif } } -int srslte_precoding_mimo_2x2_gen(cf_t W[2][2], - cf_t* y[SRSLTE_MAX_PORTS], - cf_t* h[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS], - cf_t* x[SRSLTE_MAX_LAYERS], +int srsran_precoding_mimo_2x2_gen(cf_t W[2][2], + cf_t* y[SRSRAN_MAX_PORTS], + cf_t* h[SRSRAN_MAX_PORTS][SRSRAN_MAX_PORTS], + cf_t* x[SRSRAN_MAX_LAYERS], int nof_symbols, float scaling, float noise_estimate) @@ -826,65 +826,65 @@ int srslte_precoding_mimo_2x2_gen(cf_t W[2][2], x[1][i] = (Gx[1][0] * y[0][i] + Gx[1][1] * y[1][i]) * scaling; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -static int srslte_predecoding_ccd_2x2_zf_csi(cf_t* y[SRSLTE_MAX_PORTS], - cf_t* h[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS], - cf_t* x[SRSLTE_MAX_LAYERS], - float* csi[SRSLTE_MAX_CODEWORDS], +static int srsran_predecoding_ccd_2x2_zf_csi(cf_t* y[SRSRAN_MAX_PORTS], + cf_t* h[SRSRAN_MAX_PORTS][SRSRAN_MAX_PORTS], + cf_t* x[SRSRAN_MAX_LAYERS], + float* csi[SRSRAN_MAX_CODEWORDS], int nof_symbols, float scaling) { uint32_t i = 0; float norm = 2.0f / scaling; -#if SRSLTE_SIMD_CF_SIZE != 0 -#if SRSLTE_SIMD_CF_SIZE == 16 - float _mask1[SRSLTE_SIMD_CF_SIZE] = { +#if SRSRAN_SIMD_CF_SIZE != 0 +#if SRSRAN_SIMD_CF_SIZE == 16 + float _mask1[SRSRAN_SIMD_CF_SIZE] = { +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f}; - float _mask2[SRSLTE_SIMD_CF_SIZE] = { + float _mask2[SRSRAN_SIMD_CF_SIZE] = { -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f}; -#elif SRSLTE_SIMD_CF_SIZE == 8 - float _mask1[SRSLTE_SIMD_CF_SIZE] = {+0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f}; - float _mask2[SRSLTE_SIMD_CF_SIZE] = {-0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f}; -#elif SRSLTE_SIMD_CF_SIZE == 4 - float _mask1[SRSLTE_SIMD_CF_SIZE] = {+0.0f, -0.0f, +0.0f, -0.0f}; - float _mask2[SRSLTE_SIMD_CF_SIZE] = {-0.0f, +0.0f, -0.0f, +0.0f}; +#elif SRSRAN_SIMD_CF_SIZE == 8 + float _mask1[SRSRAN_SIMD_CF_SIZE] = {+0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f}; + float _mask2[SRSRAN_SIMD_CF_SIZE] = {-0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f}; +#elif SRSRAN_SIMD_CF_SIZE == 4 + float _mask1[SRSRAN_SIMD_CF_SIZE] = {+0.0f, -0.0f, +0.0f, -0.0f}; + float _mask2[SRSRAN_SIMD_CF_SIZE] = {-0.0f, +0.0f, -0.0f, +0.0f}; #endif - simd_f_t mask1 = srslte_simd_f_loadu(_mask1); - simd_f_t mask2 = srslte_simd_f_loadu(_mask2); + simd_f_t mask1 = srsran_simd_f_loadu(_mask1); + simd_f_t mask2 = srsran_simd_f_loadu(_mask2); - for (; i < nof_symbols - SRSLTE_SIMD_CF_SIZE + 1; i += SRSLTE_SIMD_CF_SIZE) { + for (; i < nof_symbols - SRSRAN_SIMD_CF_SIZE + 1; i += SRSRAN_SIMD_CF_SIZE) { /* Load channel */ - simd_cf_t h00i = srslte_simd_cfi_load(&h[0][0][i]); - simd_cf_t h01i = srslte_simd_cfi_load(&h[0][1][i]); - simd_cf_t h10i = srslte_simd_cfi_load(&h[1][0][i]); - simd_cf_t h11i = srslte_simd_cfi_load(&h[1][1][i]); + simd_cf_t h00i = srsran_simd_cfi_load(&h[0][0][i]); + simd_cf_t h01i = srsran_simd_cfi_load(&h[0][1][i]); + simd_cf_t h10i = srsran_simd_cfi_load(&h[1][0][i]); + simd_cf_t h11i = srsran_simd_cfi_load(&h[1][1][i]); /* Apply precoding */ simd_cf_t h00, h01, h10, h11; - h00 = srslte_simd_cf_add(h00i, srslte_simd_cf_neg_mask(h10i, mask1)); - h10 = srslte_simd_cf_add(h01i, srslte_simd_cf_neg_mask(h11i, mask1)); - h01 = srslte_simd_cf_add(h00i, srslte_simd_cf_neg_mask(h10i, mask2)); - h11 = srslte_simd_cf_add(h01i, srslte_simd_cf_neg_mask(h11i, mask2)); + h00 = srsran_simd_cf_add(h00i, srsran_simd_cf_neg_mask(h10i, mask1)); + h10 = srsran_simd_cf_add(h01i, srsran_simd_cf_neg_mask(h11i, mask1)); + h01 = srsran_simd_cf_add(h00i, srsran_simd_cf_neg_mask(h10i, mask2)); + h11 = srsran_simd_cf_add(h01i, srsran_simd_cf_neg_mask(h11i, mask2)); - simd_cf_t y0 = srslte_simd_cfi_load(&y[0][i]); - simd_cf_t y1 = srslte_simd_cfi_load(&y[1][i]); + simd_cf_t y0 = srsran_simd_cfi_load(&y[0][i]); + simd_cf_t y1 = srsran_simd_cfi_load(&y[1][i]); simd_cf_t x0, x1; simd_f_t csi0, csi1; - srslte_mat_2x2_zf_csi_simd(y0, y1, h00, h01, h10, h11, &x0, &x1, &csi0, &csi1, norm); + srsran_mat_2x2_zf_csi_simd(y0, y1, h00, h01, h10, h11, &x0, &x1, &csi0, &csi1, norm); - srslte_simd_cfi_store(&x[0][i], x0); - srslte_simd_cfi_store(&x[1][i], x1); + srsran_simd_cfi_store(&x[0][i], x0); + srsran_simd_cfi_store(&x[1][i], x1); - srslte_simd_f_store(&csi[0][i], csi0); - srslte_simd_f_store(&csi[1][i], csi1); + srsran_simd_f_store(&csi[0][i], csi0); + srsran_simd_f_store(&csi[1][i], csi1); } -#endif /* SRSLTE_SIMD_CF_SIZE != 0 */ +#endif /* SRSRAN_SIMD_CF_SIZE != 0 */ cf_t h00, h01, h10, h11, det; for (; i < nof_symbols; i++) { @@ -918,60 +918,60 @@ static int srslte_predecoding_ccd_2x2_zf_csi(cf_t* y[SRSLTE_MAX_PORTS], csi[0][i] = 1.0f; csi[1][i] = 1.0f; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -static int srslte_predecoding_ccd_2x2_zf(cf_t* y[SRSLTE_MAX_PORTS], - cf_t* h[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS], - cf_t* x[SRSLTE_MAX_LAYERS], +static int srsran_predecoding_ccd_2x2_zf(cf_t* y[SRSRAN_MAX_PORTS], + cf_t* h[SRSRAN_MAX_PORTS][SRSRAN_MAX_PORTS], + cf_t* x[SRSRAN_MAX_LAYERS], int nof_symbols, float scaling) { uint32_t i = 0; float norm = 2.0f / scaling; -#if SRSLTE_SIMD_CF_SIZE != 0 -#if SRSLTE_SIMD_CF_SIZE == 16 - float _mask1[SRSLTE_SIMD_CF_SIZE] = { +#if SRSRAN_SIMD_CF_SIZE != 0 +#if SRSRAN_SIMD_CF_SIZE == 16 + float _mask1[SRSRAN_SIMD_CF_SIZE] = { +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f}; - float _mask2[SRSLTE_SIMD_CF_SIZE] = { + float _mask2[SRSRAN_SIMD_CF_SIZE] = { -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f}; -#elif SRSLTE_SIMD_CF_SIZE == 8 - float _mask1[SRSLTE_SIMD_CF_SIZE] = {+0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f}; - float _mask2[SRSLTE_SIMD_CF_SIZE] = {-0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f}; -#elif SRSLTE_SIMD_CF_SIZE == 4 - float _mask1[SRSLTE_SIMD_CF_SIZE] = {+0.0f, -0.0f, +0.0f, -0.0f}; - float _mask2[SRSLTE_SIMD_CF_SIZE] = {-0.0f, +0.0f, -0.0f, +0.0f}; +#elif SRSRAN_SIMD_CF_SIZE == 8 + float _mask1[SRSRAN_SIMD_CF_SIZE] = {+0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f}; + float _mask2[SRSRAN_SIMD_CF_SIZE] = {-0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f}; +#elif SRSRAN_SIMD_CF_SIZE == 4 + float _mask1[SRSRAN_SIMD_CF_SIZE] = {+0.0f, -0.0f, +0.0f, -0.0f}; + float _mask2[SRSRAN_SIMD_CF_SIZE] = {-0.0f, +0.0f, -0.0f, +0.0f}; #endif - simd_f_t mask1 = srslte_simd_f_loadu(_mask1); - simd_f_t mask2 = srslte_simd_f_loadu(_mask2); + simd_f_t mask1 = srsran_simd_f_loadu(_mask1); + simd_f_t mask2 = srsran_simd_f_loadu(_mask2); - for (; i < nof_symbols - SRSLTE_SIMD_CF_SIZE + 1; i += SRSLTE_SIMD_CF_SIZE) { + for (; i < nof_symbols - SRSRAN_SIMD_CF_SIZE + 1; i += SRSRAN_SIMD_CF_SIZE) { /* Load channel */ - simd_cf_t h00i = srslte_simd_cfi_load(&h[0][0][i]); - simd_cf_t h01i = srslte_simd_cfi_load(&h[0][1][i]); - simd_cf_t h10i = srslte_simd_cfi_load(&h[1][0][i]); - simd_cf_t h11i = srslte_simd_cfi_load(&h[1][1][i]); + simd_cf_t h00i = srsran_simd_cfi_load(&h[0][0][i]); + simd_cf_t h01i = srsran_simd_cfi_load(&h[0][1][i]); + simd_cf_t h10i = srsran_simd_cfi_load(&h[1][0][i]); + simd_cf_t h11i = srsran_simd_cfi_load(&h[1][1][i]); /* Apply precoding */ simd_cf_t h00, h01, h10, h11; - h00 = srslte_simd_cf_add(h00i, srslte_simd_cf_neg_mask(h10i, mask1)); - h10 = srslte_simd_cf_add(h01i, srslte_simd_cf_neg_mask(h11i, mask1)); - h01 = srslte_simd_cf_add(h00i, srslte_simd_cf_neg_mask(h10i, mask2)); - h11 = srslte_simd_cf_add(h01i, srslte_simd_cf_neg_mask(h11i, mask2)); + h00 = srsran_simd_cf_add(h00i, srsran_simd_cf_neg_mask(h10i, mask1)); + h10 = srsran_simd_cf_add(h01i, srsran_simd_cf_neg_mask(h11i, mask1)); + h01 = srsran_simd_cf_add(h00i, srsran_simd_cf_neg_mask(h10i, mask2)); + h11 = srsran_simd_cf_add(h01i, srsran_simd_cf_neg_mask(h11i, mask2)); - simd_cf_t y0 = srslte_simd_cfi_load(&y[0][i]); - simd_cf_t y1 = srslte_simd_cfi_load(&y[1][i]); + simd_cf_t y0 = srsran_simd_cfi_load(&y[0][i]); + simd_cf_t y1 = srsran_simd_cfi_load(&y[1][i]); simd_cf_t x0, x1; - srslte_mat_2x2_zf_simd(y0, y1, h00, h01, h10, h11, &x0, &x1, norm); + srsran_mat_2x2_zf_simd(y0, y1, h00, h01, h10, h11, &x0, &x1, norm); - srslte_simd_cfi_store(&x[0][i], x0); - srslte_simd_cfi_store(&x[1][i], x1); + srsran_simd_cfi_store(&x[0][i], x0); + srsran_simd_cfi_store(&x[1][i], x1); } -#endif /* SRSLTE_SIMD_CF_SIZE != 0 */ +#endif /* SRSRAN_SIMD_CF_SIZE != 0 */ cf_t h00, h01, h10, h11, det; for (; i < nof_symbols; i++) { @@ -999,13 +999,13 @@ static int srslte_predecoding_ccd_2x2_zf(cf_t* y[SRSLTE_MAX_PORTS], x[0][i] = (+h11 * y[0][i] - h01 * y[1][i]) * det; x[1][i] = (-h10 * y[0][i] + h00 * y[1][i]) * det; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -static int srslte_predecoding_ccd_zf(cf_t* y[SRSLTE_MAX_PORTS], - cf_t* h[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS], - cf_t* x[SRSLTE_MAX_LAYERS], - float* csi[SRSLTE_MAX_CODEWORDS], +static int srsran_predecoding_ccd_zf(cf_t* y[SRSRAN_MAX_PORTS], + cf_t* h[SRSRAN_MAX_PORTS][SRSRAN_MAX_PORTS], + cf_t* x[SRSRAN_MAX_LAYERS], + float* csi[SRSRAN_MAX_CODEWORDS], int nof_rxant, int nof_ports, int nof_layers, @@ -1015,9 +1015,9 @@ static int srslte_predecoding_ccd_zf(cf_t* y[SRSLTE_MAX_PORTS], if (nof_ports == 2 && nof_rxant == 2) { if (nof_layers == 2) { if (csi && csi[0]) { - return srslte_predecoding_ccd_2x2_zf_csi(y, h, x, csi, nof_symbols, scaling); + return srsran_predecoding_ccd_2x2_zf_csi(y, h, x, csi, nof_symbols, scaling); } else { - return srslte_predecoding_ccd_2x2_zf(y, h, x, nof_symbols, scaling); + return srsran_predecoding_ccd_2x2_zf(y, h, x, nof_symbols, scaling); } } else { ERROR("Error predecoding CCD: Invalid number of layers %d", nof_layers); @@ -1028,13 +1028,13 @@ static int srslte_predecoding_ccd_zf(cf_t* y[SRSLTE_MAX_PORTS], } else { ERROR("Error predecoding CCD: Invalid combination of ports %d and rx antennax %d", nof_ports, nof_rxant); } - return SRSLTE_ERROR; + return SRSRAN_ERROR; } -static int srslte_predecoding_ccd_2x2_mmse_csi(cf_t* y[SRSLTE_MAX_PORTS], - cf_t* h[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS], - cf_t* x[SRSLTE_MAX_LAYERS], - float* csi[SRSLTE_MAX_CODEWORDS], +static int srsran_predecoding_ccd_2x2_mmse_csi(cf_t* y[SRSRAN_MAX_PORTS], + cf_t* h[SRSRAN_MAX_PORTS][SRSRAN_MAX_PORTS], + cf_t* x[SRSRAN_MAX_LAYERS], + float* csi[SRSRAN_MAX_CODEWORDS], int nof_symbols, float scaling, float noise_estimate) @@ -1042,52 +1042,52 @@ static int srslte_predecoding_ccd_2x2_mmse_csi(cf_t* y[SRSLTE_MAX_PORTS], int i = 0; float norm = 2.0f / scaling; -#if SRSLTE_SIMD_CF_SIZE != 0 -#if SRSLTE_SIMD_CF_SIZE == 16 - float _mask1[SRSLTE_SIMD_CF_SIZE] = { +#if SRSRAN_SIMD_CF_SIZE != 0 +#if SRSRAN_SIMD_CF_SIZE == 16 + float _mask1[SRSRAN_SIMD_CF_SIZE] = { +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f}; - float _mask2[SRSLTE_SIMD_CF_SIZE] = { + float _mask2[SRSRAN_SIMD_CF_SIZE] = { -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f}; -#elif SRSLTE_SIMD_CF_SIZE == 8 - float _mask1[SRSLTE_SIMD_CF_SIZE] = {+0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f}; - float _mask2[SRSLTE_SIMD_CF_SIZE] = {-0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f}; -#elif SRSLTE_SIMD_CF_SIZE == 4 - float _mask1[SRSLTE_SIMD_CF_SIZE] = {+0.0f, -0.0f, +0.0f, -0.0f}; - float _mask2[SRSLTE_SIMD_CF_SIZE] = {-0.0f, +0.0f, -0.0f, +0.0f}; +#elif SRSRAN_SIMD_CF_SIZE == 8 + float _mask1[SRSRAN_SIMD_CF_SIZE] = {+0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f}; + float _mask2[SRSRAN_SIMD_CF_SIZE] = {-0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f}; +#elif SRSRAN_SIMD_CF_SIZE == 4 + float _mask1[SRSRAN_SIMD_CF_SIZE] = {+0.0f, -0.0f, +0.0f, -0.0f}; + float _mask2[SRSRAN_SIMD_CF_SIZE] = {-0.0f, +0.0f, -0.0f, +0.0f}; #endif - simd_f_t mask1 = srslte_simd_f_loadu(_mask1); - simd_f_t mask2 = srslte_simd_f_loadu(_mask2); + simd_f_t mask1 = srsran_simd_f_loadu(_mask1); + simd_f_t mask2 = srsran_simd_f_loadu(_mask2); - for (; i < nof_symbols - SRSLTE_SIMD_CF_SIZE + 1; i += SRSLTE_SIMD_CF_SIZE) { + for (; i < nof_symbols - SRSRAN_SIMD_CF_SIZE + 1; i += SRSRAN_SIMD_CF_SIZE) { /* Load channel */ - simd_cf_t h00i = srslte_simd_cfi_load(&h[0][0][i]); - simd_cf_t h01i = srslte_simd_cfi_load(&h[0][1][i]); - simd_cf_t h10i = srslte_simd_cfi_load(&h[1][0][i]); - simd_cf_t h11i = srslte_simd_cfi_load(&h[1][1][i]); + simd_cf_t h00i = srsran_simd_cfi_load(&h[0][0][i]); + simd_cf_t h01i = srsran_simd_cfi_load(&h[0][1][i]); + simd_cf_t h10i = srsran_simd_cfi_load(&h[1][0][i]); + simd_cf_t h11i = srsran_simd_cfi_load(&h[1][1][i]); /* Apply precoding */ simd_cf_t h00, h01, h10, h11; - h00 = srslte_simd_cf_add(h00i, srslte_simd_cf_neg_mask(h10i, mask1)); - h10 = srslte_simd_cf_add(h01i, srslte_simd_cf_neg_mask(h11i, mask1)); - h01 = srslte_simd_cf_add(h00i, srslte_simd_cf_neg_mask(h10i, mask2)); - h11 = srslte_simd_cf_add(h01i, srslte_simd_cf_neg_mask(h11i, mask2)); + h00 = srsran_simd_cf_add(h00i, srsran_simd_cf_neg_mask(h10i, mask1)); + h10 = srsran_simd_cf_add(h01i, srsran_simd_cf_neg_mask(h11i, mask1)); + h01 = srsran_simd_cf_add(h00i, srsran_simd_cf_neg_mask(h10i, mask2)); + h11 = srsran_simd_cf_add(h01i, srsran_simd_cf_neg_mask(h11i, mask2)); - simd_cf_t y0 = srslte_simd_cfi_load(&y[0][i]); - simd_cf_t y1 = srslte_simd_cfi_load(&y[1][i]); + simd_cf_t y0 = srsran_simd_cfi_load(&y[0][i]); + simd_cf_t y1 = srsran_simd_cfi_load(&y[1][i]); simd_cf_t x0, x1; simd_f_t csi0, csi1; - srslte_mat_2x2_mmse_csi_simd(y0, y1, h00, h01, h10, h11, &x0, &x1, &csi0, &csi1, noise_estimate, norm); + srsran_mat_2x2_mmse_csi_simd(y0, y1, h00, h01, h10, h11, &x0, &x1, &csi0, &csi1, noise_estimate, norm); - srslte_simd_cfi_store(&x[0][i], x0); - srslte_simd_cfi_store(&x[1][i], x1); + srsran_simd_cfi_store(&x[0][i], x0); + srsran_simd_cfi_store(&x[1][i], x1); - srslte_simd_f_store(&csi[0][i], csi0); - srslte_simd_f_store(&csi[1][i], csi1); + srsran_simd_f_store(&csi[0][i], csi0); + srsran_simd_f_store(&csi[1][i], csi1); } -#endif /* SRSLTE_SIMD_CF_SIZE != 0 */ +#endif /* SRSRAN_SIMD_CF_SIZE != 0 */ cf_t h00, h01, h10, h11; for (; i < nof_symbols; i++) { @@ -1096,7 +1096,7 @@ static int srslte_predecoding_ccd_2x2_mmse_csi(cf_t* y[SRSLTE_MAX_PORTS], h10 = +h[0][1][i] + h[1][1][i]; h01 = +h[0][0][i] - h[1][0][i]; h11 = +h[0][1][i] - h[1][1][i]; - srslte_mat_2x2_mmse_csi_gen( + srsran_mat_2x2_mmse_csi_gen( y[0][i], y[1][i], h00, h01, h10, h11, &x[0][i], &x[1][i], &csi[0][i], &csi[1][i], noise_estimate, norm); i++; @@ -1105,15 +1105,15 @@ static int srslte_predecoding_ccd_2x2_mmse_csi(cf_t* y[SRSLTE_MAX_PORTS], h10 = h[0][1][i] - h[1][1][i]; h01 = h[0][0][i] + h[1][0][i]; h11 = h[0][1][i] + h[1][1][i]; - srslte_mat_2x2_mmse_csi_gen( + srsran_mat_2x2_mmse_csi_gen( y[0][i], y[1][i], h00, h01, h10, h11, &x[0][i], &x[1][i], &csi[0][i], &csi[1][i], noise_estimate, norm); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -static int srslte_predecoding_ccd_2x2_mmse(cf_t* y[SRSLTE_MAX_PORTS], - cf_t* h[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS], - cf_t* x[SRSLTE_MAX_LAYERS], +static int srsran_predecoding_ccd_2x2_mmse(cf_t* y[SRSRAN_MAX_PORTS], + cf_t* h[SRSRAN_MAX_PORTS][SRSRAN_MAX_PORTS], + cf_t* x[SRSRAN_MAX_LAYERS], int nof_symbols, float scaling, float noise_estimate) @@ -1121,47 +1121,47 @@ static int srslte_predecoding_ccd_2x2_mmse(cf_t* y[SRSLTE_MAX_PORTS], int i = 0; float norm = 2.0f / scaling; -#if SRSLTE_SIMD_CF_SIZE != 0 -#if SRSLTE_SIMD_CF_SIZE == 16 - float _mask1[SRSLTE_SIMD_CF_SIZE] = { +#if SRSRAN_SIMD_CF_SIZE != 0 +#if SRSRAN_SIMD_CF_SIZE == 16 + float _mask1[SRSRAN_SIMD_CF_SIZE] = { +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f}; - float _mask2[SRSLTE_SIMD_CF_SIZE] = { + float _mask2[SRSRAN_SIMD_CF_SIZE] = { -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f}; -#elif SRSLTE_SIMD_CF_SIZE == 8 - float _mask1[SRSLTE_SIMD_CF_SIZE] = {+0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f}; - float _mask2[SRSLTE_SIMD_CF_SIZE] = {-0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f}; -#elif SRSLTE_SIMD_CF_SIZE == 4 - float _mask1[SRSLTE_SIMD_CF_SIZE] = {+0.0f, -0.0f, +0.0f, -0.0f}; - float _mask2[SRSLTE_SIMD_CF_SIZE] = {-0.0f, +0.0f, -0.0f, +0.0f}; +#elif SRSRAN_SIMD_CF_SIZE == 8 + float _mask1[SRSRAN_SIMD_CF_SIZE] = {+0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f}; + float _mask2[SRSRAN_SIMD_CF_SIZE] = {-0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f}; +#elif SRSRAN_SIMD_CF_SIZE == 4 + float _mask1[SRSRAN_SIMD_CF_SIZE] = {+0.0f, -0.0f, +0.0f, -0.0f}; + float _mask2[SRSRAN_SIMD_CF_SIZE] = {-0.0f, +0.0f, -0.0f, +0.0f}; #endif - simd_f_t mask1 = srslte_simd_f_loadu(_mask1); - simd_f_t mask2 = srslte_simd_f_loadu(_mask2); + simd_f_t mask1 = srsran_simd_f_loadu(_mask1); + simd_f_t mask2 = srsran_simd_f_loadu(_mask2); - for (; i < nof_symbols - SRSLTE_SIMD_CF_SIZE + 1; i += SRSLTE_SIMD_CF_SIZE) { + for (; i < nof_symbols - SRSRAN_SIMD_CF_SIZE + 1; i += SRSRAN_SIMD_CF_SIZE) { /* Load channel */ - simd_cf_t h00i = srslte_simd_cfi_load(&h[0][0][i]); - simd_cf_t h01i = srslte_simd_cfi_load(&h[0][1][i]); - simd_cf_t h10i = srslte_simd_cfi_load(&h[1][0][i]); - simd_cf_t h11i = srslte_simd_cfi_load(&h[1][1][i]); + simd_cf_t h00i = srsran_simd_cfi_load(&h[0][0][i]); + simd_cf_t h01i = srsran_simd_cfi_load(&h[0][1][i]); + simd_cf_t h10i = srsran_simd_cfi_load(&h[1][0][i]); + simd_cf_t h11i = srsran_simd_cfi_load(&h[1][1][i]); /* Apply precoding */ simd_cf_t h00, h01, h10, h11; - h00 = srslte_simd_cf_add(h00i, srslte_simd_cf_neg_mask(h10i, mask1)); - h10 = srslte_simd_cf_add(h01i, srslte_simd_cf_neg_mask(h11i, mask1)); - h01 = srslte_simd_cf_add(h00i, srslte_simd_cf_neg_mask(h10i, mask2)); - h11 = srslte_simd_cf_add(h01i, srslte_simd_cf_neg_mask(h11i, mask2)); + h00 = srsran_simd_cf_add(h00i, srsran_simd_cf_neg_mask(h10i, mask1)); + h10 = srsran_simd_cf_add(h01i, srsran_simd_cf_neg_mask(h11i, mask1)); + h01 = srsran_simd_cf_add(h00i, srsran_simd_cf_neg_mask(h10i, mask2)); + h11 = srsran_simd_cf_add(h01i, srsran_simd_cf_neg_mask(h11i, mask2)); - simd_cf_t y0 = srslte_simd_cfi_load(&y[0][i]); - simd_cf_t y1 = srslte_simd_cfi_load(&y[1][i]); + simd_cf_t y0 = srsran_simd_cfi_load(&y[0][i]); + simd_cf_t y1 = srsran_simd_cfi_load(&y[1][i]); simd_cf_t x0, x1; - srslte_mat_2x2_mmse_simd(y0, y1, h00, h01, h10, h11, &x0, &x1, noise_estimate, norm); + srsran_mat_2x2_mmse_simd(y0, y1, h00, h01, h10, h11, &x0, &x1, noise_estimate, norm); - srslte_simd_cfi_store(&x[0][i], x0); - srslte_simd_cfi_store(&x[1][i], x1); + srsran_simd_cfi_store(&x[0][i], x0); + srsran_simd_cfi_store(&x[1][i], x1); } -#endif /* SRSLTE_SIMD_CF_SIZE != 0 */ +#endif /* SRSRAN_SIMD_CF_SIZE != 0 */ cf_t h00, h01, h10, h11; for (; i < nof_symbols; i++) { @@ -1170,7 +1170,7 @@ static int srslte_predecoding_ccd_2x2_mmse(cf_t* y[SRSLTE_MAX_PORTS], h10 = +h[0][1][i] + h[1][1][i]; h01 = +h[0][0][i] - h[1][0][i]; h11 = +h[0][1][i] - h[1][1][i]; - srslte_mat_2x2_mmse_gen(y[0][i], y[1][i], h00, h01, h10, h11, &x[0][i], &x[1][i], noise_estimate, norm); + srsran_mat_2x2_mmse_gen(y[0][i], y[1][i], h00, h01, h10, h11, &x[0][i], &x[1][i], noise_estimate, norm); i++; @@ -1179,15 +1179,15 @@ static int srslte_predecoding_ccd_2x2_mmse(cf_t* y[SRSLTE_MAX_PORTS], h10 = h[0][1][i] - h[1][1][i]; h01 = h[0][0][i] + h[1][0][i]; h11 = h[0][1][i] + h[1][1][i]; - srslte_mat_2x2_mmse_gen(y[0][i], y[1][i], h00, h01, h10, h11, &x[0][i], &x[1][i], noise_estimate, norm); + srsran_mat_2x2_mmse_gen(y[0][i], y[1][i], h00, h01, h10, h11, &x[0][i], &x[1][i], noise_estimate, norm); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_predecoding_ccd_mmse(cf_t* y[SRSLTE_MAX_PORTS], - cf_t* h[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS], - cf_t* x[SRSLTE_MAX_LAYERS], - float* csi[SRSLTE_MAX_CODEWORDS], +int srsran_predecoding_ccd_mmse(cf_t* y[SRSRAN_MAX_PORTS], + cf_t* h[SRSRAN_MAX_PORTS][SRSRAN_MAX_PORTS], + cf_t* x[SRSRAN_MAX_LAYERS], + float* csi[SRSRAN_MAX_CODEWORDS], int nof_rxant, int nof_ports, int nof_layers, @@ -1198,9 +1198,9 @@ int srslte_predecoding_ccd_mmse(cf_t* y[SRSLTE_MAX_PORTS], if (nof_ports == 2 && nof_rxant == 2) { if (nof_layers == 2) { if (csi && csi[0]) - return srslte_predecoding_ccd_2x2_mmse_csi(y, h, x, csi, nof_symbols, scaling, noise_estimate); + return srsran_predecoding_ccd_2x2_mmse_csi(y, h, x, csi, nof_symbols, scaling, noise_estimate); else { - return srslte_predecoding_ccd_2x2_mmse(y, h, x, nof_symbols, scaling, noise_estimate); + return srsran_predecoding_ccd_2x2_mmse(y, h, x, nof_symbols, scaling, noise_estimate); } } else { ERROR("Error predecoding CCD: Invalid number of layers %d", nof_layers); @@ -1211,12 +1211,12 @@ int srslte_predecoding_ccd_mmse(cf_t* y[SRSLTE_MAX_PORTS], } else { ERROR("Error predecoding CCD: Invalid combination of ports %d and rx antennax %d", nof_ports, nof_rxant); } - return SRSLTE_ERROR; + return SRSRAN_ERROR; } -static int srslte_predecoding_multiplex_2x2_zf_csi(cf_t* y[SRSLTE_MAX_PORTS], - cf_t* h[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS], - cf_t* x[SRSLTE_MAX_LAYERS], +static int srsran_predecoding_multiplex_2x2_zf_csi(cf_t* y[SRSRAN_MAX_PORTS], + cf_t* h[SRSRAN_MAX_PORTS][SRSRAN_MAX_PORTS], + cf_t* x[SRSRAN_MAX_LAYERS], float* csi, int codebook_idx, int nof_symbols, @@ -1235,15 +1235,15 @@ static int srslte_predecoding_multiplex_2x2_zf_csi(cf_t* y[SRSLTE_MAX_PORTS], break; default: ERROR("Wrong codebook_idx=%d", codebook_idx); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } -#if SRSLTE_SIMD_CF_SIZE != 0 - for (; i < nof_symbols - SRSLTE_SIMD_CF_SIZE + 1; i += SRSLTE_SIMD_CF_SIZE) { - simd_cf_t h00i = srslte_simd_cfi_load(&h[0][0][i]); - simd_cf_t h01i = srslte_simd_cfi_load(&h[0][1][i]); - simd_cf_t h10i = srslte_simd_cfi_load(&h[1][0][i]); - simd_cf_t h11i = srslte_simd_cfi_load(&h[1][1][i]); +#if SRSRAN_SIMD_CF_SIZE != 0 + for (; i < nof_symbols - SRSRAN_SIMD_CF_SIZE + 1; i += SRSRAN_SIMD_CF_SIZE) { + simd_cf_t h00i = srsran_simd_cfi_load(&h[0][0][i]); + simd_cf_t h01i = srsran_simd_cfi_load(&h[0][1][i]); + simd_cf_t h10i = srsran_simd_cfi_load(&h[1][0][i]); + simd_cf_t h11i = srsran_simd_cfi_load(&h[1][1][i]); simd_cf_t h00, h01, h10, h11; switch (codebook_idx) { @@ -1254,36 +1254,36 @@ static int srslte_predecoding_multiplex_2x2_zf_csi(cf_t* y[SRSLTE_MAX_PORTS], h11 = h11i; break; case 1: - h00 = srslte_simd_cf_add(h00i, h10i); - h01 = srslte_simd_cf_sub(h00i, h10i); - h10 = srslte_simd_cf_add(h01i, h11i); - h11 = srslte_simd_cf_sub(h01i, h11i); + h00 = srsran_simd_cf_add(h00i, h10i); + h01 = srsran_simd_cf_sub(h00i, h10i); + h10 = srsran_simd_cf_add(h01i, h11i); + h11 = srsran_simd_cf_sub(h01i, h11i); break; case 2: - h00 = srslte_simd_cf_add(h00i, srslte_simd_cf_mulj(h10i)); - h01 = srslte_simd_cf_sub(h00i, srslte_simd_cf_mulj(h10i)); - h10 = srslte_simd_cf_add(h01i, srslte_simd_cf_mulj(h11i)); - h11 = srslte_simd_cf_sub(h01i, srslte_simd_cf_mulj(h11i)); + h00 = srsran_simd_cf_add(h00i, srsran_simd_cf_mulj(h10i)); + h01 = srsran_simd_cf_sub(h00i, srsran_simd_cf_mulj(h10i)); + h10 = srsran_simd_cf_add(h01i, srsran_simd_cf_mulj(h11i)); + h11 = srsran_simd_cf_sub(h01i, srsran_simd_cf_mulj(h11i)); break; default: ERROR("Wrong codebook_idx=%d", codebook_idx); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - simd_cf_t y0 = srslte_simd_cfi_load(&y[0][i]); - simd_cf_t y1 = srslte_simd_cfi_load(&y[1][i]); + simd_cf_t y0 = srsran_simd_cfi_load(&y[0][i]); + simd_cf_t y1 = srsran_simd_cfi_load(&y[1][i]); simd_cf_t x0, x1; simd_f_t csi0, csi1; - srslte_mat_2x2_zf_csi_simd(y0, y1, h00, h01, h10, h11, &x0, &x1, &csi0, &csi1, norm); + srsran_mat_2x2_zf_csi_simd(y0, y1, h00, h01, h10, h11, &x0, &x1, &csi0, &csi1, norm); - srslte_simd_cfi_store(&x[0][i], x0); - srslte_simd_cfi_store(&x[1][i], x1); + srsran_simd_cfi_store(&x[0][i], x0); + srsran_simd_cfi_store(&x[1][i], x1); - srslte_simd_f_store(&csi[i], csi0); - srslte_simd_f_store(&csi[i], csi1); + srsran_simd_f_store(&csi[i], csi0); + srsran_simd_f_store(&csi[i], csi1); } -#endif /* SRSLTE_SIMD_CF_SIZE */ +#endif /* SRSRAN_SIMD_CF_SIZE */ for (; i < nof_symbols; i++) { cf_t h00, h01, h10, h11; @@ -1309,7 +1309,7 @@ static int srslte_predecoding_multiplex_2x2_zf_csi(cf_t* y[SRSLTE_MAX_PORTS], break; default: ERROR("Wrong codebook_idx=%d", codebook_idx); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } cf_t det = (h00 * h11 - h01 * h10); @@ -1321,13 +1321,13 @@ static int srslte_predecoding_multiplex_2x2_zf_csi(cf_t* y[SRSLTE_MAX_PORTS], csi[i] = 1.0f; csi[i] = 1.0f; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Generic implementation of ZF 2x2 Spatial Multiplexity equalizer -static int srslte_predecoding_multiplex_2x2_zf(cf_t* y[SRSLTE_MAX_PORTS], - cf_t* h[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS], - cf_t* x[SRSLTE_MAX_LAYERS], +static int srsran_predecoding_multiplex_2x2_zf(cf_t* y[SRSRAN_MAX_PORTS], + cf_t* h[SRSRAN_MAX_PORTS][SRSRAN_MAX_PORTS], + cf_t* x[SRSRAN_MAX_LAYERS], int codebook_idx, int nof_symbols, float scaling) @@ -1345,15 +1345,15 @@ static int srslte_predecoding_multiplex_2x2_zf(cf_t* y[SRSLTE_MAX_PORTS], break; default: ERROR("Wrong codebook_idx=%d", codebook_idx); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } -#if SRSLTE_SIMD_CF_SIZE != 0 - for (; i < nof_symbols - SRSLTE_SIMD_CF_SIZE + 1; i += SRSLTE_SIMD_CF_SIZE) { - simd_cf_t h00i = srslte_simd_cfi_load(&h[0][0][i]); - simd_cf_t h01i = srslte_simd_cfi_load(&h[0][1][i]); - simd_cf_t h10i = srslte_simd_cfi_load(&h[1][0][i]); - simd_cf_t h11i = srslte_simd_cfi_load(&h[1][1][i]); +#if SRSRAN_SIMD_CF_SIZE != 0 + for (; i < nof_symbols - SRSRAN_SIMD_CF_SIZE + 1; i += SRSRAN_SIMD_CF_SIZE) { + simd_cf_t h00i = srsran_simd_cfi_load(&h[0][0][i]); + simd_cf_t h01i = srsran_simd_cfi_load(&h[0][1][i]); + simd_cf_t h10i = srsran_simd_cfi_load(&h[1][0][i]); + simd_cf_t h11i = srsran_simd_cfi_load(&h[1][1][i]); simd_cf_t h00, h01, h10, h11; switch (codebook_idx) { @@ -1364,33 +1364,33 @@ static int srslte_predecoding_multiplex_2x2_zf(cf_t* y[SRSLTE_MAX_PORTS], h11 = h11i; break; case 1: - h00 = srslte_simd_cf_add(h00i, h10i); - h01 = srslte_simd_cf_sub(h00i, h10i); - h10 = srslte_simd_cf_add(h01i, h11i); - h11 = srslte_simd_cf_sub(h01i, h11i); + h00 = srsran_simd_cf_add(h00i, h10i); + h01 = srsran_simd_cf_sub(h00i, h10i); + h10 = srsran_simd_cf_add(h01i, h11i); + h11 = srsran_simd_cf_sub(h01i, h11i); break; case 2: - h00 = srslte_simd_cf_add(h00i, srslte_simd_cf_mulj(h10i)); - h01 = srslte_simd_cf_sub(h00i, srslte_simd_cf_mulj(h10i)); - h10 = srslte_simd_cf_add(h01i, srslte_simd_cf_mulj(h11i)); - h11 = srslte_simd_cf_sub(h01i, srslte_simd_cf_mulj(h11i)); + h00 = srsran_simd_cf_add(h00i, srsran_simd_cf_mulj(h10i)); + h01 = srsran_simd_cf_sub(h00i, srsran_simd_cf_mulj(h10i)); + h10 = srsran_simd_cf_add(h01i, srsran_simd_cf_mulj(h11i)); + h11 = srsran_simd_cf_sub(h01i, srsran_simd_cf_mulj(h11i)); break; default: ERROR("Wrong codebook_idx=%d", codebook_idx); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - simd_cf_t y0 = srslte_simd_cfi_load(&y[0][i]); - simd_cf_t y1 = srslte_simd_cfi_load(&y[1][i]); + simd_cf_t y0 = srsran_simd_cfi_load(&y[0][i]); + simd_cf_t y1 = srsran_simd_cfi_load(&y[1][i]); simd_cf_t x0, x1; simd_f_t csi0, csi1; - srslte_mat_2x2_zf_csi_simd(y0, y1, h00, h01, h10, h11, &x0, &x1, &csi0, &csi1, norm); + srsran_mat_2x2_zf_csi_simd(y0, y1, h00, h01, h10, h11, &x0, &x1, &csi0, &csi1, norm); - srslte_simd_cfi_store(&x[0][i], x0); - srslte_simd_cfi_store(&x[1][i], x1); + srsran_simd_cfi_store(&x[0][i], x0); + srsran_simd_cfi_store(&x[1][i], x1); } -#endif /* SRSLTE_SIMD_CF_SIZE */ +#endif /* SRSRAN_SIMD_CF_SIZE */ for (; i < nof_symbols; i++) { cf_t h00, h01, h10, h11; @@ -1416,19 +1416,19 @@ static int srslte_predecoding_multiplex_2x2_zf(cf_t* y[SRSLTE_MAX_PORTS], break; default: ERROR("Wrong codebook_idx=%d", codebook_idx); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - srslte_mat_2x2_zf_gen(y[0][i], y[1][i], h00, h01, h10, h11, &x[0][i], &x[1][i], norm); + srsran_mat_2x2_zf_gen(y[0][i], y[1][i], h00, h01, h10, h11, &x[0][i], &x[1][i], norm); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Generic implementation of ZF 2x2 Spatial Multiplexity equalizer -static int srslte_predecoding_multiplex_2x2_mmse_csi(cf_t* y[SRSLTE_MAX_PORTS], - cf_t* h[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS], - cf_t* x[SRSLTE_MAX_LAYERS], - float* csi[SRSLTE_MAX_CODEWORDS], +static int srsran_predecoding_multiplex_2x2_mmse_csi(cf_t* y[SRSRAN_MAX_PORTS], + cf_t* h[SRSRAN_MAX_PORTS][SRSRAN_MAX_PORTS], + cf_t* x[SRSRAN_MAX_LAYERS], + float* csi[SRSRAN_MAX_CODEWORDS], int codebook_idx, int nof_symbols, float scaling, @@ -1447,15 +1447,15 @@ static int srslte_predecoding_multiplex_2x2_mmse_csi(cf_t* y[SRSLTE_MAX_PORTS], break; default: ERROR("Wrong codebook_idx=%d", codebook_idx); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } -#if SRSLTE_SIMD_CF_SIZE != 0 - for (; i < nof_symbols - SRSLTE_SIMD_CF_SIZE + 1; i += SRSLTE_SIMD_CF_SIZE) { - simd_cf_t h00i = srslte_simd_cfi_load(&h[0][0][i]); - simd_cf_t h01i = srslte_simd_cfi_load(&h[0][1][i]); - simd_cf_t h10i = srslte_simd_cfi_load(&h[1][0][i]); - simd_cf_t h11i = srslte_simd_cfi_load(&h[1][1][i]); +#if SRSRAN_SIMD_CF_SIZE != 0 + for (; i < nof_symbols - SRSRAN_SIMD_CF_SIZE + 1; i += SRSRAN_SIMD_CF_SIZE) { + simd_cf_t h00i = srsran_simd_cfi_load(&h[0][0][i]); + simd_cf_t h01i = srsran_simd_cfi_load(&h[0][1][i]); + simd_cf_t h10i = srsran_simd_cfi_load(&h[1][0][i]); + simd_cf_t h11i = srsran_simd_cfi_load(&h[1][1][i]); simd_cf_t h00, h01, h10, h11; switch (codebook_idx) { @@ -1466,36 +1466,36 @@ static int srslte_predecoding_multiplex_2x2_mmse_csi(cf_t* y[SRSLTE_MAX_PORTS], h11 = h11i; break; case 1: - h00 = srslte_simd_cf_add(h00i, h10i); - h01 = srslte_simd_cf_sub(h00i, h10i); - h10 = srslte_simd_cf_add(h01i, h11i); - h11 = srslte_simd_cf_sub(h01i, h11i); + h00 = srsran_simd_cf_add(h00i, h10i); + h01 = srsran_simd_cf_sub(h00i, h10i); + h10 = srsran_simd_cf_add(h01i, h11i); + h11 = srsran_simd_cf_sub(h01i, h11i); break; case 2: - h00 = srslte_simd_cf_add(h00i, srslte_simd_cf_mulj(h10i)); - h01 = srslte_simd_cf_sub(h00i, srslte_simd_cf_mulj(h10i)); - h10 = srslte_simd_cf_add(h01i, srslte_simd_cf_mulj(h11i)); - h11 = srslte_simd_cf_sub(h01i, srslte_simd_cf_mulj(h11i)); + h00 = srsran_simd_cf_add(h00i, srsran_simd_cf_mulj(h10i)); + h01 = srsran_simd_cf_sub(h00i, srsran_simd_cf_mulj(h10i)); + h10 = srsran_simd_cf_add(h01i, srsran_simd_cf_mulj(h11i)); + h11 = srsran_simd_cf_sub(h01i, srsran_simd_cf_mulj(h11i)); break; default: ERROR("Wrong codebook_idx=%d", codebook_idx); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - simd_cf_t y0 = srslte_simd_cfi_load(&y[0][i]); - simd_cf_t y1 = srslte_simd_cfi_load(&y[1][i]); + simd_cf_t y0 = srsran_simd_cfi_load(&y[0][i]); + simd_cf_t y1 = srsran_simd_cfi_load(&y[1][i]); simd_cf_t x0, x1; simd_f_t csi0, csi1; - srslte_mat_2x2_mmse_csi_simd(y0, y1, h00, h01, h10, h11, &x0, &x1, &csi0, &csi1, noise_estimate, norm); + srsran_mat_2x2_mmse_csi_simd(y0, y1, h00, h01, h10, h11, &x0, &x1, &csi0, &csi1, noise_estimate, norm); - srslte_simd_cfi_store(&x[0][i], x0); - srslte_simd_cfi_store(&x[1][i], x1); + srsran_simd_cfi_store(&x[0][i], x0); + srsran_simd_cfi_store(&x[1][i], x1); - srslte_simd_f_store(&csi[0][i], csi0); - srslte_simd_f_store(&csi[1][i], csi1); + srsran_simd_f_store(&csi[0][i], csi0); + srsran_simd_f_store(&csi[1][i], csi1); } -#endif /* SRSLTE_SIMD_CF_SIZE */ +#endif /* SRSRAN_SIMD_CF_SIZE */ for (; i < nof_symbols; i++) { cf_t h00, h01, h10, h11; @@ -1521,18 +1521,18 @@ static int srslte_predecoding_multiplex_2x2_mmse_csi(cf_t* y[SRSLTE_MAX_PORTS], break; default: ERROR("Wrong codebook_idx=%d", codebook_idx); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - srslte_mat_2x2_mmse_csi_gen( + srsran_mat_2x2_mmse_csi_gen( y[0][i], y[1][i], h00, h01, h10, h11, &x[0][i], &x[1][i], &csi[0][i], &csi[1][i], noise_estimate, norm); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -static int srslte_predecoding_multiplex_2x2_mmse(cf_t* y[SRSLTE_MAX_PORTS], - cf_t* h[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS], - cf_t* x[SRSLTE_MAX_LAYERS], +static int srsran_predecoding_multiplex_2x2_mmse(cf_t* y[SRSRAN_MAX_PORTS], + cf_t* h[SRSRAN_MAX_PORTS][SRSRAN_MAX_PORTS], + cf_t* x[SRSRAN_MAX_LAYERS], int codebook_idx, int nof_symbols, float scaling, @@ -1551,15 +1551,15 @@ static int srslte_predecoding_multiplex_2x2_mmse(cf_t* y[SRSLTE_MAX_PORTS], break; default: ERROR("Wrong codebook_idx=%d", codebook_idx); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } -#if SRSLTE_SIMD_CF_SIZE != 0 - for (; i < nof_symbols - SRSLTE_SIMD_CF_SIZE + 1; i += SRSLTE_SIMD_CF_SIZE) { - simd_cf_t h00i = srslte_simd_cfi_load(&h[0][0][i]); - simd_cf_t h01i = srslte_simd_cfi_load(&h[0][1][i]); - simd_cf_t h10i = srslte_simd_cfi_load(&h[1][0][i]); - simd_cf_t h11i = srslte_simd_cfi_load(&h[1][1][i]); +#if SRSRAN_SIMD_CF_SIZE != 0 + for (; i < nof_symbols - SRSRAN_SIMD_CF_SIZE + 1; i += SRSRAN_SIMD_CF_SIZE) { + simd_cf_t h00i = srsran_simd_cfi_load(&h[0][0][i]); + simd_cf_t h01i = srsran_simd_cfi_load(&h[0][1][i]); + simd_cf_t h10i = srsran_simd_cfi_load(&h[1][0][i]); + simd_cf_t h11i = srsran_simd_cfi_load(&h[1][1][i]); simd_cf_t h00, h01, h10, h11; switch (codebook_idx) { @@ -1570,33 +1570,33 @@ static int srslte_predecoding_multiplex_2x2_mmse(cf_t* y[SRSLTE_MAX_PORTS], h11 = h11i; break; case 1: - h00 = srslte_simd_cf_add(h00i, h10i); - h01 = srslte_simd_cf_sub(h00i, h10i); - h10 = srslte_simd_cf_add(h01i, h11i); - h11 = srslte_simd_cf_sub(h01i, h11i); + h00 = srsran_simd_cf_add(h00i, h10i); + h01 = srsran_simd_cf_sub(h00i, h10i); + h10 = srsran_simd_cf_add(h01i, h11i); + h11 = srsran_simd_cf_sub(h01i, h11i); break; case 2: - h00 = srslte_simd_cf_add(h00i, srslte_simd_cf_mulj(h10i)); - h01 = srslte_simd_cf_sub(h00i, srslte_simd_cf_mulj(h10i)); - h10 = srslte_simd_cf_add(h01i, srslte_simd_cf_mulj(h11i)); - h11 = srslte_simd_cf_sub(h01i, srslte_simd_cf_mulj(h11i)); + h00 = srsran_simd_cf_add(h00i, srsran_simd_cf_mulj(h10i)); + h01 = srsran_simd_cf_sub(h00i, srsran_simd_cf_mulj(h10i)); + h10 = srsran_simd_cf_add(h01i, srsran_simd_cf_mulj(h11i)); + h11 = srsran_simd_cf_sub(h01i, srsran_simd_cf_mulj(h11i)); break; default: ERROR("Wrong codebook_idx=%d", codebook_idx); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - simd_cf_t y0 = srslte_simd_cfi_load(&y[0][i]); - simd_cf_t y1 = srslte_simd_cfi_load(&y[1][i]); + simd_cf_t y0 = srsran_simd_cfi_load(&y[0][i]); + simd_cf_t y1 = srsran_simd_cfi_load(&y[1][i]); simd_cf_t x0, x1; simd_f_t csi0, csi1; - srslte_mat_2x2_mmse_csi_simd(y0, y1, h00, h01, h10, h11, &x0, &x1, &csi0, &csi1, noise_estimate, norm); + srsran_mat_2x2_mmse_csi_simd(y0, y1, h00, h01, h10, h11, &x0, &x1, &csi0, &csi1, noise_estimate, norm); - srslte_simd_cfi_store(&x[0][i], x0); - srslte_simd_cfi_store(&x[1][i], x1); + srsran_simd_cfi_store(&x[0][i], x0); + srsran_simd_cfi_store(&x[1][i], x1); } -#endif /* SRSLTE_SIMD_CF_SIZE */ +#endif /* SRSRAN_SIMD_CF_SIZE */ for (; i < nof_symbols; i++) { cf_t h00, h01, h10, h11; @@ -1622,18 +1622,18 @@ static int srslte_predecoding_multiplex_2x2_mmse(cf_t* y[SRSLTE_MAX_PORTS], break; default: ERROR("Wrong codebook_idx=%d", codebook_idx); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - srslte_mat_2x2_mmse_gen(y[0][i], y[1][i], h00, h01, h10, h11, &x[0][i], &x[1][i], noise_estimate, norm); + srsran_mat_2x2_mmse_gen(y[0][i], y[1][i], h00, h01, h10, h11, &x[0][i], &x[1][i], noise_estimate, norm); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Implementation of MRC 2x1 (two antennas into one layer) Spatial Multiplexing equalizer -static int srslte_predecoding_multiplex_2x1_mrc(cf_t* y[SRSLTE_MAX_PORTS], - cf_t* h[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS], - cf_t* x[SRSLTE_MAX_LAYERS], +static int srsran_predecoding_multiplex_2x1_mrc(cf_t* y[SRSRAN_MAX_PORTS], + cf_t* h[SRSRAN_MAX_PORTS][SRSRAN_MAX_PORTS], + cf_t* x[SRSRAN_MAX_LAYERS], int codebook_idx, int nof_symbols, float scaling) @@ -1641,45 +1641,45 @@ static int srslte_predecoding_multiplex_2x1_mrc(cf_t* y[SRSLTE_MAX_PORTS], float norm = (float)M_SQRT2 / scaling; int i = 0; -#if SRSLTE_SIMD_CF_SIZE != 0 - simd_f_t _norm = srslte_simd_f_set1(norm); +#if SRSRAN_SIMD_CF_SIZE != 0 + simd_f_t _norm = srsran_simd_f_set1(norm); - for (; i < nof_symbols - SRSLTE_SIMD_CF_SIZE + 1; i += SRSLTE_SIMD_CF_SIZE) { - simd_cf_t x0 = srslte_simd_cf_set1(0.0f); - simd_f_t hh = srslte_simd_f_set1(0.0f); + for (; i < nof_symbols - SRSRAN_SIMD_CF_SIZE + 1; i += SRSRAN_SIMD_CF_SIZE) { + simd_cf_t x0 = srsran_simd_cf_set1(0.0f); + simd_f_t hh = srsran_simd_f_set1(0.0f); for (int k = 0; k < 2; k++) { - simd_cf_t h0xi = srslte_simd_cfi_load(&h[0][k][i]); - simd_cf_t h1xi = srslte_simd_cfi_load(&h[1][k][i]); - simd_cf_t yx = srslte_simd_cfi_load(&y[k][i]); + simd_cf_t h0xi = srsran_simd_cfi_load(&h[0][k][i]); + simd_cf_t h1xi = srsran_simd_cfi_load(&h[1][k][i]); + simd_cf_t yx = srsran_simd_cfi_load(&y[k][i]); simd_cf_t hx; switch (codebook_idx) { case 0: - hx = srslte_simd_cf_add(h0xi, h1xi); + hx = srsran_simd_cf_add(h0xi, h1xi); break; case 1: - hx = srslte_simd_cf_sub(h0xi, h1xi); + hx = srsran_simd_cf_sub(h0xi, h1xi); break; case 2: - hx = srslte_simd_cf_add(h0xi, srslte_simd_cf_mulj(h1xi)); + hx = srsran_simd_cf_add(h0xi, srsran_simd_cf_mulj(h1xi)); break; case 3: - hx = srslte_simd_cf_sub(h0xi, srslte_simd_cf_mulj(h1xi)); + hx = srsran_simd_cf_sub(h0xi, srsran_simd_cf_mulj(h1xi)); break; default: ERROR("Wrong codebook_idx=%d", codebook_idx); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - hh = srslte_simd_f_add(srslte_simd_cf_re(srslte_simd_cf_conjprod(hx, hx)), hh); - x0 = srslte_simd_cf_add(srslte_simd_cf_conjprod(yx, hx), x0); + hh = srsran_simd_f_add(srsran_simd_cf_re(srsran_simd_cf_conjprod(hx, hx)), hh); + x0 = srsran_simd_cf_add(srsran_simd_cf_conjprod(yx, hx), x0); } - hh = srslte_simd_f_mul(_norm, srslte_simd_f_rcp(hh)); - srslte_simd_cfi_store(&x[0][i], srslte_simd_cf_mul(x0, hh)); + hh = srsran_simd_f_mul(_norm, srsran_simd_f_rcp(hh)); + srsran_simd_cfi_store(&x[0][i], srsran_simd_cf_mul(x0, hh)); } -#endif /* SRSLTE_SIMD_CF_SIZE */ +#endif /* SRSRAN_SIMD_CF_SIZE */ for (; i < nof_symbols; i += 1) { cf_t h0, h1; @@ -1704,20 +1704,20 @@ static int srslte_predecoding_multiplex_2x1_mrc(cf_t* y[SRSLTE_MAX_PORTS], break; default: ERROR("Wrong codebook_idx=%d", codebook_idx); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } hh = norm / (crealf(h0) * crealf(h0) + cimagf(h0) * cimagf(h0) + crealf(h1) * crealf(h1) + cimagf(h1) * cimagf(h1)); x[0][i] = (conjf(h0) * y[0][i] + conjf(h1) * y[1][i]) * hh; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Generic implementation of MRC 2x1 (two antennas into one layer) Spatial Multiplexing equalizer -static int srslte_predecoding_multiplex_2x1_mrc_csi(cf_t* y[SRSLTE_MAX_PORTS], - cf_t* h[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS], - cf_t* x[SRSLTE_MAX_LAYERS], +static int srsran_predecoding_multiplex_2x1_mrc_csi(cf_t* y[SRSRAN_MAX_PORTS], + cf_t* h[SRSRAN_MAX_PORTS][SRSRAN_MAX_PORTS], + cf_t* x[SRSRAN_MAX_LAYERS], float* csi, int codebook_idx, int nof_symbols, @@ -1726,46 +1726,46 @@ static int srslte_predecoding_multiplex_2x1_mrc_csi(cf_t* y[SRSLTE_MAX_PORTS], float norm = (float)M_SQRT2 / scaling; int i = 0; -#if SRSLTE_SIMD_CF_SIZE != 0 - simd_f_t _norm = srslte_simd_f_set1(norm); +#if SRSRAN_SIMD_CF_SIZE != 0 + simd_f_t _norm = srsran_simd_f_set1(norm); - for (; i < nof_symbols - SRSLTE_SIMD_CF_SIZE + 1; i += SRSLTE_SIMD_CF_SIZE) { - simd_cf_t x0 = srslte_simd_cf_set1(0.0f); - simd_f_t hh = srslte_simd_f_set1(0.0f); + for (; i < nof_symbols - SRSRAN_SIMD_CF_SIZE + 1; i += SRSRAN_SIMD_CF_SIZE) { + simd_cf_t x0 = srsran_simd_cf_set1(0.0f); + simd_f_t hh = srsran_simd_f_set1(0.0f); for (int k = 0; k < 2; k++) { - simd_cf_t h0xi = srslte_simd_cfi_load(&h[0][k][i]); - simd_cf_t h1xi = srslte_simd_cfi_load(&h[1][k][i]); - simd_cf_t yx = srslte_simd_cfi_load(&y[k][i]); + simd_cf_t h0xi = srsran_simd_cfi_load(&h[0][k][i]); + simd_cf_t h1xi = srsran_simd_cfi_load(&h[1][k][i]); + simd_cf_t yx = srsran_simd_cfi_load(&y[k][i]); simd_cf_t hx; switch (codebook_idx) { case 0: - hx = srslte_simd_cf_add(h0xi, h1xi); + hx = srsran_simd_cf_add(h0xi, h1xi); break; case 1: - hx = srslte_simd_cf_sub(h0xi, h1xi); + hx = srsran_simd_cf_sub(h0xi, h1xi); break; case 2: - hx = srslte_simd_cf_add(h0xi, srslte_simd_cf_mulj(h1xi)); + hx = srsran_simd_cf_add(h0xi, srsran_simd_cf_mulj(h1xi)); break; case 3: - hx = srslte_simd_cf_sub(h0xi, srslte_simd_cf_mulj(h1xi)); + hx = srsran_simd_cf_sub(h0xi, srsran_simd_cf_mulj(h1xi)); break; default: ERROR("Wrong codebook_idx=%d", codebook_idx); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - hh = srslte_simd_f_add(srslte_simd_cf_re(srslte_simd_cf_conjprod(hx, hx)), hh); - x0 = srslte_simd_cf_add(srslte_simd_cf_conjprod(yx, hx), x0); + hh = srsran_simd_f_add(srsran_simd_cf_re(srsran_simd_cf_conjprod(hx, hx)), hh); + x0 = srsran_simd_cf_add(srsran_simd_cf_conjprod(yx, hx), x0); } - hh = srslte_simd_f_mul(_norm, srslte_simd_f_rcp(hh)); - srslte_simd_cfi_store(&x[0][i], srslte_simd_cf_mul(x0, hh)); - srslte_simd_f_store(&csi[i], srslte_simd_f_mul(srslte_simd_f_rcp(hh), srslte_simd_f_set1((float)M_SQRT1_2))); + hh = srsran_simd_f_mul(_norm, srsran_simd_f_rcp(hh)); + srsran_simd_cfi_store(&x[0][i], srsran_simd_cf_mul(x0, hh)); + srsran_simd_f_store(&csi[i], srsran_simd_f_mul(srsran_simd_f_rcp(hh), srsran_simd_f_set1((float)M_SQRT1_2))); } -#endif /* SRSLTE_SIMD_CF_SIZE */ +#endif /* SRSRAN_SIMD_CF_SIZE */ for (; i < nof_symbols; i += 1) { cf_t h0, h1; @@ -1790,7 +1790,7 @@ static int srslte_predecoding_multiplex_2x1_mrc_csi(cf_t* y[SRSLTE_MAX_PORTS], break; default: ERROR("Wrong codebook_idx=%d", codebook_idx); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } _csi = crealf(h0) * crealf(h0) + cimagf(h0) * cimagf(h0) + crealf(h1) * crealf(h1) + cimagf(h1) * cimagf(h1); @@ -1799,13 +1799,13 @@ static int srslte_predecoding_multiplex_2x1_mrc_csi(cf_t* y[SRSLTE_MAX_PORTS], x[0][i] = (conjf(h0) * y[0][i] + conjf(h1) * y[1][i]) * hh; csi[i] = _csi / norm * (float)M_SQRT1_2; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -static int srslte_predecoding_multiplex(cf_t* y[SRSLTE_MAX_PORTS], - cf_t* h[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS], - cf_t* x[SRSLTE_MAX_LAYERS], - float* csi[SRSLTE_MAX_CODEWORDS], +static int srsran_predecoding_multiplex(cf_t* y[SRSRAN_MAX_PORTS], + cf_t* h[SRSRAN_MAX_PORTS][SRSRAN_MAX_PORTS], + cf_t* x[SRSRAN_MAX_LAYERS], + float* csi[SRSRAN_MAX_CODEWORDS], int nof_rxant, int nof_ports, int nof_layers, @@ -1817,27 +1817,27 @@ static int srslte_predecoding_multiplex(cf_t* y[SRSLTE_MAX_PORTS], if (nof_ports == 2 && nof_rxant <= 2) { if (nof_layers == 2) { switch (mimo_decoder) { - case SRSLTE_MIMO_DECODER_ZF: + case SRSRAN_MIMO_DECODER_ZF: if (csi && csi[0]) { - return srslte_predecoding_multiplex_2x2_zf_csi(y, h, x, csi[0], codebook_idx, nof_symbols, scaling); + return srsran_predecoding_multiplex_2x2_zf_csi(y, h, x, csi[0], codebook_idx, nof_symbols, scaling); } else { - return srslte_predecoding_multiplex_2x2_zf(y, h, x, codebook_idx, nof_symbols, scaling); + return srsran_predecoding_multiplex_2x2_zf(y, h, x, codebook_idx, nof_symbols, scaling); } break; - case SRSLTE_MIMO_DECODER_MMSE: + case SRSRAN_MIMO_DECODER_MMSE: if (csi && csi[0]) { - return srslte_predecoding_multiplex_2x2_mmse_csi( + return srsran_predecoding_multiplex_2x2_mmse_csi( y, h, x, csi, codebook_idx, nof_symbols, scaling, noise_estimate); } else { - return srslte_predecoding_multiplex_2x2_mmse(y, h, x, codebook_idx, nof_symbols, scaling, noise_estimate); + return srsran_predecoding_multiplex_2x2_mmse(y, h, x, codebook_idx, nof_symbols, scaling, noise_estimate); } break; } } else { if (csi && csi[0]) { - return srslte_predecoding_multiplex_2x1_mrc_csi(y, h, x, csi[0], codebook_idx, nof_symbols, scaling); + return srsran_predecoding_multiplex_2x1_mrc_csi(y, h, x, csi[0], codebook_idx, nof_symbols, scaling); } else { - return srslte_predecoding_multiplex_2x1_mrc(y, h, x, codebook_idx, nof_symbols, scaling); + return srsran_predecoding_multiplex_2x1_mrc(y, h, x, codebook_idx, nof_symbols, scaling); } } } else if (nof_ports == 4) { @@ -1845,74 +1845,74 @@ static int srslte_predecoding_multiplex(cf_t* y[SRSLTE_MAX_PORTS], } else { ERROR("Error predecoding multiplex: Invalid combination of ports %d and rx antennas %d", nof_ports, nof_rxant); } - return SRSLTE_ERROR; + return SRSRAN_ERROR; } -void srslte_predecoding_set_mimo_decoder(srslte_mimo_decoder_t _mimo_decoder) +void srsran_predecoding_set_mimo_decoder(srsran_mimo_decoder_t _mimo_decoder) { mimo_decoder = _mimo_decoder; } /* 36.211 v10.3.0 Section 6.3.4 */ -int srslte_predecoding_type(cf_t* y[SRSLTE_MAX_PORTS], - cf_t* h[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS], - cf_t* x[SRSLTE_MAX_LAYERS], - float* csi[SRSLTE_MAX_CODEWORDS], +int srsran_predecoding_type(cf_t* y[SRSRAN_MAX_PORTS], + cf_t* h[SRSRAN_MAX_PORTS][SRSRAN_MAX_PORTS], + cf_t* x[SRSRAN_MAX_LAYERS], + float* csi[SRSRAN_MAX_CODEWORDS], int nof_rxant, int nof_ports, int nof_layers, int codebook_idx, int nof_symbols, - srslte_tx_scheme_t type, + srsran_tx_scheme_t type, float scaling, float noise_estimate) { - if (nof_ports > SRSLTE_MAX_PORTS) { - ERROR("Maximum number of ports is %d (nof_ports=%d)", SRSLTE_MAX_PORTS, nof_ports); - return SRSLTE_ERROR; + if (nof_ports > SRSRAN_MAX_PORTS) { + ERROR("Maximum number of ports is %d (nof_ports=%d)", SRSRAN_MAX_PORTS, nof_ports); + return SRSRAN_ERROR; } - if (nof_layers > SRSLTE_MAX_LAYERS) { - ERROR("Maximum number of layers is %d (nof_layers=%d)", SRSLTE_MAX_LAYERS, nof_layers); - return SRSLTE_ERROR; + if (nof_layers > SRSRAN_MAX_LAYERS) { + ERROR("Maximum number of layers is %d (nof_layers=%d)", SRSRAN_MAX_LAYERS, nof_layers); + return SRSRAN_ERROR; } switch (type) { - case SRSLTE_TXSCHEME_CDD: + case SRSRAN_TXSCHEME_CDD: if (nof_layers == 2) { switch (mimo_decoder) { - case SRSLTE_MIMO_DECODER_ZF: - return srslte_predecoding_ccd_zf(y, h, x, csi, nof_rxant, nof_ports, nof_layers, nof_symbols, scaling); - case SRSLTE_MIMO_DECODER_MMSE: - return srslte_predecoding_ccd_mmse( + case SRSRAN_MIMO_DECODER_ZF: + return srsran_predecoding_ccd_zf(y, h, x, csi, nof_rxant, nof_ports, nof_layers, nof_symbols, scaling); + case SRSRAN_MIMO_DECODER_MMSE: + return srsran_predecoding_ccd_mmse( y, h, x, csi, nof_rxant, nof_ports, nof_layers, nof_symbols, scaling, noise_estimate); } } else { ERROR("Invalid number of layers %d", nof_layers); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_ERROR; - case SRSLTE_TXSCHEME_PORT0: + return SRSRAN_ERROR; + case SRSRAN_TXSCHEME_PORT0: if (nof_ports == 1 && nof_layers == 1) { - return srslte_predecoding_single_multi(y, h[0], x[0], csi, nof_rxant, nof_symbols, scaling, noise_estimate); + return srsran_predecoding_single_multi(y, h[0], x[0], csi, nof_rxant, nof_symbols, scaling, noise_estimate); } else { ERROR("Number of ports and layers must be 1 for transmission on single antenna ports (%d, %d)", nof_ports, nof_layers); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - case SRSLTE_TXSCHEME_DIVERSITY: + case SRSRAN_TXSCHEME_DIVERSITY: if (nof_ports == nof_layers) { - return srslte_predecoding_diversity_multi(y, h, x, csi, nof_rxant, nof_ports, nof_symbols, scaling); + return srsran_predecoding_diversity_multi(y, h, x, csi, nof_rxant, nof_ports, nof_symbols, scaling); } else { ERROR("Error number of layers must equal number of ports in transmit diversity"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - case SRSLTE_TXSCHEME_SPATIALMUX: - return srslte_predecoding_multiplex( + case SRSRAN_TXSCHEME_SPATIALMUX: + return srsran_predecoding_multiplex( y, h, x, csi, nof_rxant, nof_ports, nof_layers, codebook_idx, nof_symbols, scaling, noise_estimate); default: ERROR("Invalid Txscheme=%d", type); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } @@ -1922,17 +1922,17 @@ int srslte_predecoding_type(cf_t* y[SRSLTE_MAX_PORTS], * **************************************************/ -int srslte_precoding_single(cf_t* x, cf_t* y, int nof_symbols, float scaling) +int srsran_precoding_single(cf_t* x, cf_t* y, int nof_symbols, float scaling) { if (scaling == 1.0f) { memcpy(y, x, nof_symbols * sizeof(cf_t)); } else { - srslte_vec_sc_prod_cfc(x, scaling, y, (uint32_t)nof_symbols); + srsran_vec_sc_prod_cfc(x, scaling, y, (uint32_t)nof_symbols); } return nof_symbols; } -int srslte_precoding_diversity(cf_t* x[SRSLTE_MAX_LAYERS], - cf_t* y[SRSLTE_MAX_PORTS], +int srsran_precoding_diversity(cf_t* x[SRSRAN_MAX_LAYERS], + cf_t* y[SRSRAN_MAX_PORTS], int nof_ports, int nof_symbols, float scaling) @@ -1946,8 +1946,8 @@ int srslte_precoding_diversity(cf_t* x[SRSLTE_MAX_LAYERS], y[1][2 * i + 1] = conjf(x[0][i]); } // normalize - srslte_vec_sc_prod_cfc(y[0], scaling * M_SQRT1_2, y[0], 2 * nof_symbols); - srslte_vec_sc_prod_cfc(y[1], scaling * M_SQRT1_2, y[1], 2 * nof_symbols); + srsran_vec_sc_prod_cfc(y[0], scaling * M_SQRT1_2, y[0], 2 * nof_symbols); + srsran_vec_sc_prod_cfc(y[1], scaling * M_SQRT1_2, y[1], 2 * nof_symbols); return 2 * i; } else if (nof_ports == 4) { scaling /= M_SQRT2; @@ -1984,7 +1984,7 @@ int srslte_precoding_diversity(cf_t* x[SRSLTE_MAX_LAYERS], #ifdef LV_HAVE_AVX -int srslte_precoding_cdd_2x2_avx(cf_t* x[SRSLTE_MAX_LAYERS], cf_t* y[SRSLTE_MAX_PORTS], int nof_symbols, float scaling) +int srsran_precoding_cdd_2x2_avx(cf_t* x[SRSRAN_MAX_LAYERS], cf_t* y[SRSRAN_MAX_PORTS], int nof_symbols, float scaling) { __m256 norm_avx = _mm256_set1_ps(0.5f * scaling); for (int i = 0; i < nof_symbols - 3; i += 4) { @@ -2009,7 +2009,7 @@ int srslte_precoding_cdd_2x2_avx(cf_t* x[SRSLTE_MAX_LAYERS], cf_t* y[SRSLTE_MAX_ #ifdef LV_HAVE_SSE -int srslte_precoding_cdd_2x2_sse(cf_t* x[SRSLTE_MAX_LAYERS], cf_t* y[SRSLTE_MAX_PORTS], int nof_symbols, float scaling) +int srsran_precoding_cdd_2x2_sse(cf_t* x[SRSRAN_MAX_LAYERS], cf_t* y[SRSRAN_MAX_PORTS], int nof_symbols, float scaling) { __m128 norm_sse = _mm_set1_ps(0.5f * scaling); for (int i = 0; i < nof_symbols - 1; i += 2) { @@ -2032,7 +2032,7 @@ int srslte_precoding_cdd_2x2_sse(cf_t* x[SRSLTE_MAX_LAYERS], cf_t* y[SRSLTE_MAX_ #endif /* LV_HAVE_SSE */ -int srslte_precoding_cdd_2x2_gen(cf_t* x[SRSLTE_MAX_LAYERS], cf_t* y[SRSLTE_MAX_PORTS], int nof_symbols, float scaling) +int srsran_precoding_cdd_2x2_gen(cf_t* x[SRSRAN_MAX_LAYERS], cf_t* y[SRSRAN_MAX_PORTS], int nof_symbols, float scaling) { scaling /= 2.0f; for (int i = 0; i < nof_symbols; i++) { @@ -2045,8 +2045,8 @@ int srslte_precoding_cdd_2x2_gen(cf_t* x[SRSLTE_MAX_LAYERS], cf_t* y[SRSLTE_MAX_ return 2 * nof_symbols; } -int srslte_precoding_cdd(cf_t* x[SRSLTE_MAX_LAYERS], - cf_t* y[SRSLTE_MAX_PORTS], +int srsran_precoding_cdd(cf_t* x[SRSRAN_MAX_LAYERS], + cf_t* y[SRSRAN_MAX_PORTS], int nof_layers, int nof_ports, int nof_symbols, @@ -2058,12 +2058,12 @@ int srslte_precoding_cdd(cf_t* x[SRSLTE_MAX_LAYERS], return -1; } #ifdef LV_HAVE_AVX - return srslte_precoding_cdd_2x2_avx(x, y, nof_symbols, scaling); + return srsran_precoding_cdd_2x2_avx(x, y, nof_symbols, scaling); #else #ifdef LV_HAVE_SSE - return srslte_precoding_cdd_2x2_sse(x, y, nof_symbols, scaling); + return srsran_precoding_cdd_2x2_sse(x, y, nof_symbols, scaling); #else - return srslte_precoding_cdd_2x2_gen(x, y, nof_symbols, scaling); + return srsran_precoding_cdd_2x2_gen(x, y, nof_symbols, scaling); #endif /* LV_HAVE_SSE */ #endif /* LV_HAVE_AVX */ } else if (nof_ports == 4) { @@ -2075,8 +2075,8 @@ int srslte_precoding_cdd(cf_t* x[SRSLTE_MAX_LAYERS], } } -int srslte_precoding_multiplex(cf_t* x[SRSLTE_MAX_LAYERS], - cf_t* y[SRSLTE_MAX_PORTS], +int srsran_precoding_multiplex(cf_t* x[SRSRAN_MAX_LAYERS], + cf_t* y[SRSRAN_MAX_PORTS], int nof_layers, int nof_ports, int codebook_idx, @@ -2089,34 +2089,34 @@ int srslte_precoding_multiplex(cf_t* x[SRSLTE_MAX_LAYERS], scaling *= M_SQRT1_2; switch (codebook_idx) { case 0: - srslte_vec_sc_prod_cfc(x[0], scaling, y[0], nof_symbols); - srslte_vec_sc_prod_cfc(x[0], scaling, y[1], nof_symbols); + srsran_vec_sc_prod_cfc(x[0], scaling, y[0], nof_symbols); + srsran_vec_sc_prod_cfc(x[0], scaling, y[1], nof_symbols); break; case 1: - srslte_vec_sc_prod_cfc(x[0], scaling, y[0], nof_symbols); - srslte_vec_sc_prod_cfc(x[0], -scaling, y[1], nof_symbols); + srsran_vec_sc_prod_cfc(x[0], scaling, y[0], nof_symbols); + srsran_vec_sc_prod_cfc(x[0], -scaling, y[1], nof_symbols); break; case 2: - srslte_vec_sc_prod_cfc(x[0], scaling, y[0], nof_symbols); - srslte_vec_sc_prod_ccc(x[0], _Complex_I * scaling, y[1], nof_symbols); + srsran_vec_sc_prod_cfc(x[0], scaling, y[0], nof_symbols); + srsran_vec_sc_prod_ccc(x[0], _Complex_I * scaling, y[1], nof_symbols); break; case 3: - srslte_vec_sc_prod_cfc(x[0], scaling, y[0], nof_symbols); - srslte_vec_sc_prod_ccc(x[0], -_Complex_I * scaling, y[1], nof_symbols); + srsran_vec_sc_prod_cfc(x[0], scaling, y[0], nof_symbols); + srsran_vec_sc_prod_ccc(x[0], -_Complex_I * scaling, y[1], nof_symbols); break; default: ERROR("Invalid multiplex combination: codebook_idx=%d, nof_layers=%d, nof_ports=%d", codebook_idx, nof_layers, nof_ports); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } else if (nof_layers == 2) { switch (codebook_idx) { case 0: scaling *= M_SQRT1_2; - srslte_vec_sc_prod_cfc(x[0], scaling, y[0], nof_symbols); - srslte_vec_sc_prod_cfc(x[1], scaling, y[1], nof_symbols); + srsran_vec_sc_prod_cfc(x[0], scaling, y[0], nof_symbols); + srsran_vec_sc_prod_cfc(x[1], scaling, y[1], nof_symbols); break; case 1: scaling /= 2.0f; @@ -2190,7 +2190,7 @@ int srslte_precoding_multiplex(cf_t* x[SRSLTE_MAX_LAYERS], codebook_idx, nof_layers, nof_ports); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } else { ERROR("Not implemented"); @@ -2198,62 +2198,62 @@ int srslte_precoding_multiplex(cf_t* x[SRSLTE_MAX_LAYERS], } else { ERROR("Not implemented"); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } /* 36.211 v10.3.0 Section 6.3.4 */ -int srslte_precoding_type(cf_t* x[SRSLTE_MAX_LAYERS], - cf_t* y[SRSLTE_MAX_PORTS], +int srsran_precoding_type(cf_t* x[SRSRAN_MAX_LAYERS], + cf_t* y[SRSRAN_MAX_PORTS], int nof_layers, int nof_ports, int codebook_idx, int nof_symbols, float scaling, - srslte_tx_scheme_t type) + srsran_tx_scheme_t type) { - if (nof_ports > SRSLTE_MAX_PORTS) { - ERROR("Maximum number of ports is %d (nof_ports=%d)", SRSLTE_MAX_PORTS, nof_ports); + if (nof_ports > SRSRAN_MAX_PORTS) { + ERROR("Maximum number of ports is %d (nof_ports=%d)", SRSRAN_MAX_PORTS, nof_ports); return -1; } - if (nof_layers > SRSLTE_MAX_LAYERS) { - ERROR("Maximum number of layers is %d (nof_layers=%d)", SRSLTE_MAX_LAYERS, nof_layers); + if (nof_layers > SRSRAN_MAX_LAYERS) { + ERROR("Maximum number of layers is %d (nof_layers=%d)", SRSRAN_MAX_LAYERS, nof_layers); return -1; } switch (type) { - case SRSLTE_TXSCHEME_CDD: - return srslte_precoding_cdd(x, y, nof_layers, nof_ports, nof_symbols, scaling); - case SRSLTE_TXSCHEME_PORT0: + case SRSRAN_TXSCHEME_CDD: + return srsran_precoding_cdd(x, y, nof_layers, nof_ports, nof_symbols, scaling); + case SRSRAN_TXSCHEME_PORT0: if (nof_ports == 1 && nof_layers == 1) { - return srslte_precoding_single(x[0], y[0], nof_symbols, scaling); + return srsran_precoding_single(x[0], y[0], nof_symbols, scaling); } else { ERROR("Number of ports and layers must be 1 for transmission on single antenna ports"); return -1; } break; - case SRSLTE_TXSCHEME_DIVERSITY: + case SRSRAN_TXSCHEME_DIVERSITY: if (nof_ports == nof_layers) { - return srslte_precoding_diversity(x, y, nof_ports, nof_symbols, scaling); + return srsran_precoding_diversity(x, y, nof_ports, nof_symbols, scaling); } else { ERROR("Error number of layers must equal number of ports in transmit diversity"); return -1; } - case SRSLTE_TXSCHEME_SPATIALMUX: - return srslte_precoding_multiplex(x, y, nof_layers, nof_ports, codebook_idx, (uint32_t)nof_symbols, scaling); + case SRSRAN_TXSCHEME_SPATIALMUX: + return srsran_precoding_multiplex(x, y, nof_layers, nof_ports, codebook_idx, (uint32_t)nof_symbols, scaling); default: - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_ERROR; + return SRSRAN_ERROR; } #define PMI_SEL_PRECISION 24 /* PMI Select for 1 layer */ -int srslte_precoding_pmi_select_1l_gen(cf_t* h[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS], +int srsran_precoding_pmi_select_1l_gen(cf_t* h[SRSRAN_MAX_PORTS][SRSRAN_MAX_PORTS], uint32_t nof_symbols, float noise_estimate, uint32_t* pmi, - float sinr_list[SRSLTE_MAX_CODEBOOKS]) + float sinr_list[SRSRAN_MAX_CODEBOOKS]) { #define SQRT1_2 ((float)M_SQRT1_2) float max_sinr = 0.0; @@ -2313,7 +2313,7 @@ int srslte_precoding_pmi_select_1l_gen(cf_t* h[SRSLTE_MAX_PORTS][SRSLTE_MAX_ c = b0 - _Complex_I * b1; break; default: - return SRSLTE_ERROR; + return SRSRAN_ERROR; } c *= SQRT1_2; @@ -2335,99 +2335,99 @@ int srslte_precoding_pmi_select_1l_gen(cf_t* h[SRSLTE_MAX_PORTS][SRSLTE_MAX_ return i; } -#if SRSLTE_SIMD_CF_SIZE != 0 +#if SRSRAN_SIMD_CF_SIZE != 0 /* PMI Select for 1 layer */ -int srslte_precoding_pmi_select_1l_simd(cf_t* h[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS], +int srsran_precoding_pmi_select_1l_simd(cf_t* h[SRSRAN_MAX_PORTS][SRSRAN_MAX_PORTS], uint32_t nof_symbols, float noise_estimate, uint32_t* pmi, - float sinr_list[SRSLTE_MAX_CODEBOOKS]) + float sinr_list[SRSRAN_MAX_CODEBOOKS]) { float max_sinr = 0.0; - simd_f_t simd_f_norm = srslte_simd_f_set1(0.5f); + simd_f_t simd_f_norm = srsran_simd_f_set1(0.5f); for (uint32_t i = 0; i < 4; i++) { float sinr_acc = 0; float count = 0; - for (uint32_t j = 0; j < nof_symbols - PMI_SEL_PRECISION * SRSLTE_SIMD_CF_SIZE + 1; - j += PMI_SEL_PRECISION * SRSLTE_SIMD_CF_SIZE) { + for (uint32_t j = 0; j < nof_symbols - PMI_SEL_PRECISION * SRSRAN_SIMD_CF_SIZE + 1; + j += PMI_SEL_PRECISION * SRSRAN_SIMD_CF_SIZE) { // 0. Load channel matrix - srslte_simd_aligned cf_t h00_v[SRSLTE_SIMD_CF_SIZE]; - srslte_simd_aligned cf_t h01_v[SRSLTE_SIMD_CF_SIZE]; - srslte_simd_aligned cf_t h10_v[SRSLTE_SIMD_CF_SIZE]; - srslte_simd_aligned cf_t h11_v[SRSLTE_SIMD_CF_SIZE]; + srsran_simd_aligned cf_t h00_v[SRSRAN_SIMD_CF_SIZE]; + srsran_simd_aligned cf_t h01_v[SRSRAN_SIMD_CF_SIZE]; + srsran_simd_aligned cf_t h10_v[SRSRAN_SIMD_CF_SIZE]; + srsran_simd_aligned cf_t h11_v[SRSRAN_SIMD_CF_SIZE]; - for (uint32_t k = 0; k < SRSLTE_SIMD_CF_SIZE; k++) { + for (uint32_t k = 0; k < SRSRAN_SIMD_CF_SIZE; k++) { h00_v[k] = h[0][0][j + PMI_SEL_PRECISION * k]; h01_v[k] = h[1][0][j + PMI_SEL_PRECISION * k]; h10_v[k] = h[0][1][j + PMI_SEL_PRECISION * k]; h11_v[k] = h[1][1][j + PMI_SEL_PRECISION * k]; } - simd_cf_t h00 = srslte_simd_cfi_load(h00_v); - simd_cf_t h01 = srslte_simd_cfi_load(h01_v); - simd_cf_t h10 = srslte_simd_cfi_load(h10_v); - simd_cf_t h11 = srslte_simd_cfi_load(h11_v); + simd_cf_t h00 = srsran_simd_cfi_load(h00_v); + simd_cf_t h01 = srsran_simd_cfi_load(h01_v); + simd_cf_t h10 = srsran_simd_cfi_load(h10_v); + simd_cf_t h11 = srsran_simd_cfi_load(h11_v); /* 1. B = W'* H' */ simd_cf_t a0, a1; switch (i) { case 0: - a0 = srslte_simd_cf_add(srslte_simd_cf_conj(h00), srslte_simd_cf_conj(h01)); - a1 = srslte_simd_cf_add(srslte_simd_cf_conj(h10), srslte_simd_cf_conj(h11)); + a0 = srsran_simd_cf_add(srsran_simd_cf_conj(h00), srsran_simd_cf_conj(h01)); + a1 = srsran_simd_cf_add(srsran_simd_cf_conj(h10), srsran_simd_cf_conj(h11)); break; case 1: - a0 = srslte_simd_cf_sub(srslte_simd_cf_conj(h00), srslte_simd_cf_conj(h01)); - a1 = srslte_simd_cf_sub(srslte_simd_cf_conj(h10), srslte_simd_cf_conj(h11)); + a0 = srsran_simd_cf_sub(srsran_simd_cf_conj(h00), srsran_simd_cf_conj(h01)); + a1 = srsran_simd_cf_sub(srsran_simd_cf_conj(h10), srsran_simd_cf_conj(h11)); break; case 2: - a0 = srslte_simd_cf_sub(srslte_simd_cf_conj(h00), srslte_simd_cf_mulj(srslte_simd_cf_conj(h01))); - a1 = srslte_simd_cf_sub(srslte_simd_cf_conj(h10), srslte_simd_cf_mulj(srslte_simd_cf_conj(h11))); + a0 = srsran_simd_cf_sub(srsran_simd_cf_conj(h00), srsran_simd_cf_mulj(srsran_simd_cf_conj(h01))); + a1 = srsran_simd_cf_sub(srsran_simd_cf_conj(h10), srsran_simd_cf_mulj(srsran_simd_cf_conj(h11))); break; default: - a0 = srslte_simd_cf_add(srslte_simd_cf_conj(h00), srslte_simd_cf_mulj(srslte_simd_cf_conj(h01))); - a1 = srslte_simd_cf_add(srslte_simd_cf_conj(h10), srslte_simd_cf_mulj(srslte_simd_cf_conj(h11))); + a0 = srsran_simd_cf_add(srsran_simd_cf_conj(h00), srsran_simd_cf_mulj(srsran_simd_cf_conj(h01))); + a1 = srsran_simd_cf_add(srsran_simd_cf_conj(h10), srsran_simd_cf_mulj(srsran_simd_cf_conj(h11))); break; } /* 2. B = W' * H' * H = A * H */ - simd_cf_t b0 = srslte_simd_cf_add(srslte_simd_cf_prod(a0, h00), srslte_simd_cf_prod(a1, h10)); - simd_cf_t b1 = srslte_simd_cf_add(srslte_simd_cf_prod(a0, h01), srslte_simd_cf_prod(a1, h11)); + simd_cf_t b0 = srsran_simd_cf_add(srsran_simd_cf_prod(a0, h00), srsran_simd_cf_prod(a1, h10)); + simd_cf_t b1 = srsran_simd_cf_add(srsran_simd_cf_prod(a0, h01), srsran_simd_cf_prod(a1, h11)); /* 3. C = W' * H' * H * W' = B * W */ simd_cf_t c; switch (i) { case 0: - c = srslte_simd_cf_add(b0, b1); + c = srsran_simd_cf_add(b0, b1); break; case 1: - c = srslte_simd_cf_sub(b0, b1); + c = srsran_simd_cf_sub(b0, b1); break; case 2: - c = srslte_simd_cf_add(b0, srslte_simd_cf_mulj(b1)); + c = srsran_simd_cf_add(b0, srsran_simd_cf_mulj(b1)); break; case 3: - c = srslte_simd_cf_sub(b0, srslte_simd_cf_mulj(b1)); + c = srsran_simd_cf_sub(b0, srsran_simd_cf_mulj(b1)); break; default: - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - simd_f_t gamma = srslte_simd_f_mul(srslte_simd_cf_re(c), simd_f_norm); + simd_f_t gamma = srsran_simd_f_mul(srsran_simd_cf_re(c), simd_f_norm); // Horizontal accumulation - for (int k = 1; k < SRSLTE_SIMD_F_SIZE; k *= 2) { - gamma = srslte_simd_f_hadd(gamma, gamma); + for (int k = 1; k < SRSRAN_SIMD_F_SIZE; k *= 2) { + gamma = srsran_simd_f_hadd(gamma, gamma); } // Temporal store accumulated values - srslte_simd_aligned float v[SRSLTE_SIMD_F_SIZE]; - srslte_simd_f_store(v, gamma); + srsran_simd_aligned float v[SRSRAN_SIMD_F_SIZE]; + srsran_simd_f_store(v, gamma); // Average and accumulate SINR loop - sinr_acc += (v[0] / SRSLTE_SIMD_CF_SIZE); + sinr_acc += (v[0] / SRSRAN_SIMD_CF_SIZE); // Increase loop counter count += 1; @@ -2455,35 +2455,35 @@ int srslte_precoding_pmi_select_1l_simd(cf_t* h[SRSLTE_MAX_PORTS][SRSLTE_MAX return 4; } -#endif /* SRSLTE_SIMD_CF_SIZE != 0 */ +#endif /* SRSRAN_SIMD_CF_SIZE != 0 */ -int srslte_precoding_pmi_select_1l(cf_t* h[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS], +int srsran_precoding_pmi_select_1l(cf_t* h[SRSRAN_MAX_PORTS][SRSRAN_MAX_PORTS], uint32_t nof_symbols, float noise_estimate, uint32_t* pmi, - float sinr_list[SRSLTE_MAX_CODEBOOKS]) + float sinr_list[SRSRAN_MAX_CODEBOOKS]) { int ret; -#if SRSLTE_SIMD_CF_SIZE != 0 - ret = srslte_precoding_pmi_select_1l_simd(h, nof_symbols, noise_estimate, pmi, sinr_list); +#if SRSRAN_SIMD_CF_SIZE != 0 + ret = srsran_precoding_pmi_select_1l_simd(h, nof_symbols, noise_estimate, pmi, sinr_list); #else - ret = srslte_precoding_pmi_select_1l_gen(h, nof_symbols, noise_estimate, pmi, sinr_list); -#endif /* SRSLTE_SIMD_CF_SIZE != 0 */ + ret = srsran_precoding_pmi_select_1l_gen(h, nof_symbols, noise_estimate, pmi, sinr_list); +#endif /* SRSRAN_SIMD_CF_SIZE != 0 */ INFO("Precoder PMI Select for 1 layer SINR=[%.1fdB; %.1fdB; %.1fdB; %.1fdB] PMI=%d", - srslte_convert_power_to_dB(sinr_list[0]), - srslte_convert_power_to_dB(sinr_list[1]), - srslte_convert_power_to_dB(sinr_list[2]), - srslte_convert_power_to_dB(sinr_list[3]), + srsran_convert_power_to_dB(sinr_list[0]), + srsran_convert_power_to_dB(sinr_list[1]), + srsran_convert_power_to_dB(sinr_list[2]), + srsran_convert_power_to_dB(sinr_list[3]), *pmi); return ret; } -int srslte_precoding_pmi_select_2l_gen(cf_t* h[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS], +int srsran_precoding_pmi_select_2l_gen(cf_t* h[SRSRAN_MAX_PORTS][SRSRAN_MAX_PORTS], uint32_t nof_symbols, float noise_estimate, uint32_t* pmi, - float sinr_list[SRSLTE_MAX_CODEBOOKS]) + float sinr_list[SRSRAN_MAX_CODEBOOKS]) { float max_sinr = 0.0; uint32_t i, count; @@ -2515,7 +2515,7 @@ int srslte_precoding_pmi_select_2l_gen(cf_t* h[SRSLTE_MAX_PORTS][SRSLTE_MAX_ a11 = conjf(h10) + _Complex_I * conjf(h11); break; default: - return SRSLTE_ERROR; + return SRSRAN_ERROR; } /* 2. B = W' * H' * H = A * H */ @@ -2540,7 +2540,7 @@ int srslte_precoding_pmi_select_2l_gen(cf_t* h[SRSLTE_MAX_PORTS][SRSLTE_MAX_ c11 = b10 - _Complex_I * b11; break; default: - return SRSLTE_ERROR; + return SRSRAN_ERROR; } c00 *= 0.25; c01 *= 0.25; @@ -2581,21 +2581,21 @@ int srslte_precoding_pmi_select_2l_gen(cf_t* h[SRSLTE_MAX_PORTS][SRSLTE_MAX_ return i; } -#if SRSLTE_SIMD_CF_SIZE != 0 +#if SRSRAN_SIMD_CF_SIZE != 0 -int srslte_precoding_pmi_select_2l_simd(cf_t* h[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS], +int srsran_precoding_pmi_select_2l_simd(cf_t* h[SRSRAN_MAX_PORTS][SRSRAN_MAX_PORTS], int nof_symbols, float noise_estimate, uint32_t* pmi, - float sinr_list[SRSLTE_MAX_CODEBOOKS]) + float sinr_list[SRSRAN_MAX_CODEBOOKS]) { // SIMD Constants - const simd_cf_t simd_cf_noise_estimate = srslte_simd_cf_set1(noise_estimate); - const simd_f_t simd_f_noise_estimate = srslte_simd_f_set1(noise_estimate); - const simd_f_t simd_f_norm = srslte_simd_f_set1(0.25f); - const simd_f_t simd_f_ones = srslte_simd_f_set1(1.0f); - const simd_f_t simd_f_det_min = srslte_simd_f_set1(1e-10f); - const simd_f_t simd_f_gamma_min = srslte_simd_f_set1(1e-9f); + const simd_cf_t simd_cf_noise_estimate = srsran_simd_cf_set1(noise_estimate); + const simd_f_t simd_f_noise_estimate = srsran_simd_f_set1(noise_estimate); + const simd_f_t simd_f_norm = srsran_simd_f_set1(0.25f); + const simd_f_t simd_f_ones = srsran_simd_f_set1(1.0f); + const simd_f_t simd_f_det_min = srsran_simd_f_set1(1e-10f); + const simd_f_t simd_f_gamma_min = srsran_simd_f_set1(1e-9f); float max_sinr = 0.0f; @@ -2603,110 +2603,110 @@ int srslte_precoding_pmi_select_2l_simd(cf_t* h[SRSLTE_MAX_PORTS][SRSLTE_MAX float count = 0.0f; float sinr_acc = 0.0f; - for (uint32_t j = 0; j < nof_symbols - PMI_SEL_PRECISION * SRSLTE_SIMD_CF_SIZE + 1; - j += PMI_SEL_PRECISION * SRSLTE_SIMD_CF_SIZE) { + for (uint32_t j = 0; j < nof_symbols - PMI_SEL_PRECISION * SRSRAN_SIMD_CF_SIZE + 1; + j += PMI_SEL_PRECISION * SRSRAN_SIMD_CF_SIZE) { // 0. Load channel matrix - srslte_simd_aligned cf_t h00_v[SRSLTE_SIMD_CF_SIZE]; - srslte_simd_aligned cf_t h01_v[SRSLTE_SIMD_CF_SIZE]; - srslte_simd_aligned cf_t h10_v[SRSLTE_SIMD_CF_SIZE]; - srslte_simd_aligned cf_t h11_v[SRSLTE_SIMD_CF_SIZE]; + srsran_simd_aligned cf_t h00_v[SRSRAN_SIMD_CF_SIZE]; + srsran_simd_aligned cf_t h01_v[SRSRAN_SIMD_CF_SIZE]; + srsran_simd_aligned cf_t h10_v[SRSRAN_SIMD_CF_SIZE]; + srsran_simd_aligned cf_t h11_v[SRSRAN_SIMD_CF_SIZE]; - for (uint32_t k = 0; k < SRSLTE_SIMD_CF_SIZE; k++) { + for (uint32_t k = 0; k < SRSRAN_SIMD_CF_SIZE; k++) { h00_v[k] = h[0][0][j + PMI_SEL_PRECISION * k]; h01_v[k] = h[1][0][j + PMI_SEL_PRECISION * k]; h10_v[k] = h[0][1][j + PMI_SEL_PRECISION * k]; h11_v[k] = h[1][1][j + PMI_SEL_PRECISION * k]; } - simd_cf_t h00 = srslte_simd_cfi_load(h00_v); - simd_cf_t h01 = srslte_simd_cfi_load(h01_v); - simd_cf_t h10 = srslte_simd_cfi_load(h10_v); - simd_cf_t h11 = srslte_simd_cfi_load(h11_v); + simd_cf_t h00 = srsran_simd_cfi_load(h00_v); + simd_cf_t h01 = srsran_simd_cfi_load(h01_v); + simd_cf_t h10 = srsran_simd_cfi_load(h10_v); + simd_cf_t h11 = srsran_simd_cfi_load(h11_v); // 1. B = W'* H' simd_cf_t a00, a01, a10, a11; switch (i) { case 0: - a00 = srslte_simd_cf_add(srslte_simd_cf_conj(h00), srslte_simd_cf_conj(h01)); - a01 = srslte_simd_cf_add(srslte_simd_cf_conj(h10), srslte_simd_cf_conj(h11)); - a10 = srslte_simd_cf_sub(srslte_simd_cf_conj(h00), srslte_simd_cf_conj(h01)); - a11 = srslte_simd_cf_sub(srslte_simd_cf_conj(h10), srslte_simd_cf_conj(h11)); + a00 = srsran_simd_cf_add(srsran_simd_cf_conj(h00), srsran_simd_cf_conj(h01)); + a01 = srsran_simd_cf_add(srsran_simd_cf_conj(h10), srsran_simd_cf_conj(h11)); + a10 = srsran_simd_cf_sub(srsran_simd_cf_conj(h00), srsran_simd_cf_conj(h01)); + a11 = srsran_simd_cf_sub(srsran_simd_cf_conj(h10), srsran_simd_cf_conj(h11)); break; case 1: - a00 = srslte_simd_cf_sub(srslte_simd_cf_conj(h00), srslte_simd_cf_mulj(srslte_simd_cf_conj(h01))); - a01 = srslte_simd_cf_sub(srslte_simd_cf_conj(h10), srslte_simd_cf_mulj(srslte_simd_cf_conj(h11))); - a10 = srslte_simd_cf_add(srslte_simd_cf_conj(h00), srslte_simd_cf_mulj(srslte_simd_cf_conj(h01))); - a11 = srslte_simd_cf_add(srslte_simd_cf_conj(h10), srslte_simd_cf_mulj(srslte_simd_cf_conj(h11))); + a00 = srsran_simd_cf_sub(srsran_simd_cf_conj(h00), srsran_simd_cf_mulj(srsran_simd_cf_conj(h01))); + a01 = srsran_simd_cf_sub(srsran_simd_cf_conj(h10), srsran_simd_cf_mulj(srsran_simd_cf_conj(h11))); + a10 = srsran_simd_cf_add(srsran_simd_cf_conj(h00), srsran_simd_cf_mulj(srsran_simd_cf_conj(h01))); + a11 = srsran_simd_cf_add(srsran_simd_cf_conj(h10), srsran_simd_cf_mulj(srsran_simd_cf_conj(h11))); break; default: - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // 2. B = W' * H' * H = A * H - simd_cf_t b00 = srslte_simd_cf_add(srslte_simd_cf_prod(a00, h00), srslte_simd_cf_prod(a01, h10)); - simd_cf_t b01 = srslte_simd_cf_add(srslte_simd_cf_prod(a00, h01), srslte_simd_cf_prod(a01, h11)); - simd_cf_t b10 = srslte_simd_cf_add(srslte_simd_cf_prod(a10, h00), srslte_simd_cf_prod(a11, h10)); - simd_cf_t b11 = srslte_simd_cf_add(srslte_simd_cf_prod(a10, h01), srslte_simd_cf_prod(a11, h11)); + simd_cf_t b00 = srsran_simd_cf_add(srsran_simd_cf_prod(a00, h00), srsran_simd_cf_prod(a01, h10)); + simd_cf_t b01 = srsran_simd_cf_add(srsran_simd_cf_prod(a00, h01), srsran_simd_cf_prod(a01, h11)); + simd_cf_t b10 = srsran_simd_cf_add(srsran_simd_cf_prod(a10, h00), srsran_simd_cf_prod(a11, h10)); + simd_cf_t b11 = srsran_simd_cf_add(srsran_simd_cf_prod(a10, h01), srsran_simd_cf_prod(a11, h11)); // 3. C = W' * H' * H * W' = B * W simd_cf_t c00, c01, c10, c11; switch (i) { case 0: - c00 = srslte_simd_cf_add(b00, b01); - c01 = srslte_simd_cf_sub(b00, b01); - c10 = srslte_simd_cf_add(b10, b11); - c11 = srslte_simd_cf_sub(b10, b11); + c00 = srsran_simd_cf_add(b00, b01); + c01 = srsran_simd_cf_sub(b00, b01); + c10 = srsran_simd_cf_add(b10, b11); + c11 = srsran_simd_cf_sub(b10, b11); break; case 1: - c00 = srslte_simd_cf_add(b00, srslte_simd_cf_mulj(b01)); - c01 = srslte_simd_cf_sub(b00, srslte_simd_cf_mulj(b01)); - c10 = srslte_simd_cf_add(b10, srslte_simd_cf_mulj(b11)); - c11 = srslte_simd_cf_sub(b10, srslte_simd_cf_mulj(b11)); + c00 = srsran_simd_cf_add(b00, srsran_simd_cf_mulj(b01)); + c01 = srsran_simd_cf_sub(b00, srsran_simd_cf_mulj(b01)); + c10 = srsran_simd_cf_add(b10, srsran_simd_cf_mulj(b11)); + c11 = srsran_simd_cf_sub(b10, srsran_simd_cf_mulj(b11)); break; default: - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - c00 = srslte_simd_cf_mul(c00, simd_f_norm); - c01 = srslte_simd_cf_mul(c01, simd_f_norm); - c10 = srslte_simd_cf_mul(c10, simd_f_norm); - c11 = srslte_simd_cf_mul(c11, simd_f_norm); + c00 = srsran_simd_cf_mul(c00, simd_f_norm); + c01 = srsran_simd_cf_mul(c01, simd_f_norm); + c10 = srsran_simd_cf_mul(c10, simd_f_norm); + c11 = srsran_simd_cf_mul(c11, simd_f_norm); // 4. C += noise * I - c00 = srslte_simd_cf_add(c00, simd_cf_noise_estimate); - c11 = srslte_simd_cf_add(c11, simd_cf_noise_estimate); + c00 = srsran_simd_cf_add(c00, simd_cf_noise_estimate); + c11 = srsran_simd_cf_add(c11, simd_cf_noise_estimate); // 5. detC - simd_f_t detC = srslte_simd_cf_re(srslte_mat_2x2_det_simd(c00, c01, c10, c11)); + simd_f_t detC = srsran_simd_cf_re(srsran_mat_2x2_det_simd(c00, c01, c10, c11)); // Avoid zero determinant - detC = srslte_simd_f_select(detC, simd_f_det_min, srslte_simd_f_min(detC, simd_f_det_min)); + detC = srsran_simd_f_select(detC, simd_f_det_min, srsran_simd_f_min(detC, simd_f_det_min)); - simd_f_t inv_detC = srslte_simd_f_rcp(detC); - inv_detC = srslte_simd_f_mul(simd_f_noise_estimate, inv_detC); + simd_f_t inv_detC = srsran_simd_f_rcp(detC); + inv_detC = srsran_simd_f_mul(simd_f_noise_estimate, inv_detC); - simd_f_t den0 = srslte_simd_f_mul(srslte_simd_cf_re(c00), inv_detC); - simd_f_t den1 = srslte_simd_f_mul(srslte_simd_cf_re(c11), inv_detC); + simd_f_t den0 = srsran_simd_f_mul(srsran_simd_cf_re(c00), inv_detC); + simd_f_t den1 = srsran_simd_f_mul(srsran_simd_cf_re(c11), inv_detC); - simd_f_t gamma0 = srslte_simd_f_sub(srslte_simd_f_rcp(den0), simd_f_ones); - simd_f_t gamma1 = srslte_simd_f_sub(srslte_simd_f_rcp(den1), simd_f_ones); + simd_f_t gamma0 = srsran_simd_f_sub(srsran_simd_f_rcp(den0), simd_f_ones); + simd_f_t gamma1 = srsran_simd_f_sub(srsran_simd_f_rcp(den1), simd_f_ones); // Avoid negative gamma - gamma0 = srslte_simd_f_select(gamma0, simd_f_gamma_min, srslte_simd_f_min(gamma0, simd_f_gamma_min)); - gamma1 = srslte_simd_f_select(gamma1, simd_f_gamma_min, srslte_simd_f_min(gamma1, simd_f_gamma_min)); + gamma0 = srsran_simd_f_select(gamma0, simd_f_gamma_min, srsran_simd_f_min(gamma0, simd_f_gamma_min)); + gamma1 = srsran_simd_f_select(gamma1, simd_f_gamma_min, srsran_simd_f_min(gamma1, simd_f_gamma_min)); - simd_f_t gamma_sum = srslte_simd_f_hadd(gamma0, gamma1); + simd_f_t gamma_sum = srsran_simd_f_hadd(gamma0, gamma1); // Horizontal accumulation - for (int k = 1; k < SRSLTE_SIMD_F_SIZE; k *= 2) { - gamma_sum = srslte_simd_f_hadd(gamma_sum, gamma_sum); + for (int k = 1; k < SRSRAN_SIMD_F_SIZE; k *= 2) { + gamma_sum = srsran_simd_f_hadd(gamma_sum, gamma_sum); } // Temporal store accumulated values - srslte_simd_aligned float v[SRSLTE_SIMD_F_SIZE]; - srslte_simd_f_store(v, gamma_sum); + srsran_simd_aligned float v[SRSRAN_SIMD_F_SIZE]; + srsran_simd_f_store(v, gamma_sum); // Average and accumulate SINR loop - sinr_acc += (v[0] / SRSLTE_SIMD_CF_SIZE); + sinr_acc += (v[0] / SRSRAN_SIMD_CF_SIZE); // Increase loop counter count += 1.0f; @@ -2735,36 +2735,36 @@ int srslte_precoding_pmi_select_2l_simd(cf_t* h[SRSLTE_MAX_PORTS][SRSLTE_MAX return 2; } -#endif /* SRSLTE_SIMD_CF_SIZE != 0 */ +#endif /* SRSRAN_SIMD_CF_SIZE != 0 */ /* PMI Select for 2 layers */ -int srslte_precoding_pmi_select_2l(cf_t* h[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS], +int srsran_precoding_pmi_select_2l(cf_t* h[SRSRAN_MAX_PORTS][SRSRAN_MAX_PORTS], uint32_t nof_symbols, float noise_estimate, uint32_t* pmi, - float sinr_list[SRSLTE_MAX_CODEBOOKS]) + float sinr_list[SRSRAN_MAX_CODEBOOKS]) { int ret; -#if SRSLTE_SIMD_CF_SIZE != 0 - ret = srslte_precoding_pmi_select_2l_simd(h, nof_symbols, noise_estimate, pmi, sinr_list); +#if SRSRAN_SIMD_CF_SIZE != 0 + ret = srsran_precoding_pmi_select_2l_simd(h, nof_symbols, noise_estimate, pmi, sinr_list); #else - ret = srslte_precoding_pmi_select_2l_gen(h, nof_symbols, noise_estimate, pmi, sinr_list); -#endif /* SRSLTE_SIMD_CF_SIZE != 0 */ + ret = srsran_precoding_pmi_select_2l_gen(h, nof_symbols, noise_estimate, pmi, sinr_list); +#endif /* SRSRAN_SIMD_CF_SIZE != 0 */ INFO("Precoder PMI Select for 2 layers SINR=[%.1fdB; %.1fdB] PMI=%d", - srslte_convert_power_to_dB(sinr_list[0]), - srslte_convert_power_to_dB(sinr_list[1]), + srsran_convert_power_to_dB(sinr_list[0]), + srsran_convert_power_to_dB(sinr_list[1]), *pmi); return ret; } -int srslte_precoding_pmi_select(cf_t* h[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS], +int srsran_precoding_pmi_select(cf_t* h[SRSRAN_MAX_PORTS][SRSRAN_MAX_PORTS], uint32_t nof_symbols, float noise_estimate, int nof_layers, uint32_t* pmi, - float sinr[SRSLTE_MAX_CODEBOOKS]) + float sinr[SRSRAN_MAX_CODEBOOKS]) { int ret; @@ -2774,19 +2774,19 @@ int srslte_precoding_pmi_select(cf_t* h[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS], } if (nof_layers == 1) { - ret = srslte_precoding_pmi_select_1l(h, nof_symbols, noise_estimate, pmi, sinr); + ret = srsran_precoding_pmi_select_1l(h, nof_symbols, noise_estimate, pmi, sinr); } else if (nof_layers == 2) { - ret = srslte_precoding_pmi_select_2l(h, nof_symbols, noise_estimate, pmi, sinr); + ret = srsran_precoding_pmi_select_2l(h, nof_symbols, noise_estimate, pmi, sinr); } else { ERROR("Unsupported number of layers"); - ret = SRSLTE_ERROR_INVALID_INPUTS; + ret = SRSRAN_ERROR_INVALID_INPUTS; } return ret; } /* PMI Select for 1 layer */ -float srslte_precoding_2x2_cn_gen(cf_t* h[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS], uint32_t nof_symbols) +float srsran_precoding_2x2_cn_gen(cf_t* h[SRSRAN_MAX_PORTS][SRSRAN_MAX_PORTS], uint32_t nof_symbols) { uint32_t count = 0; float cn_avg = 0.0f; @@ -2799,7 +2799,7 @@ float srslte_precoding_2x2_cn_gen(cf_t* h[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS], u cf_t h11 = h[1][1][i]; float cn = 0.0f; - if (srslte_mat_2x2_cn(h00, h01, h10, h11, &cn) == SRSLTE_SUCCESS) { + if (srsran_mat_2x2_cn(h00, h01, h10, h11, &cn) == SRSRAN_SUCCESS) { cn_avg += cn; count++; } @@ -2814,17 +2814,17 @@ float srslte_precoding_2x2_cn_gen(cf_t* h[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS], u /* Computes the condition number for a given number of antennas, * stores in the parameter *cn the Condition Number in dB */ -int srslte_precoding_cn(cf_t* h[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS], +int srsran_precoding_cn(cf_t* h[SRSRAN_MAX_PORTS][SRSRAN_MAX_PORTS], uint32_t nof_tx_antennas, uint32_t nof_rx_antennas, uint32_t nof_symbols, float* cn) { if (nof_tx_antennas == 2 && nof_rx_antennas == 2) { - *cn = srslte_precoding_2x2_cn_gen(h, nof_symbols); - return SRSLTE_SUCCESS; + *cn = srsran_precoding_2x2_cn_gen(h, nof_symbols); + return SRSRAN_SUCCESS; } else { ERROR("MIMO Condition Number calculation not implemented for %d×%d", nof_tx_antennas, nof_rx_antennas); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } diff --git a/lib/src/phy/mimo/test/CMakeLists.txt b/lib/src/phy/mimo/test/CMakeLists.txt index ce31a1ff2..aea7b5016 100644 --- a/lib/src/phy/mimo/test/CMakeLists.txt +++ b/lib/src/phy/mimo/test/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -11,7 +11,7 @@ ######################################################################## add_executable(layermap_test layermap_test.c) -target_link_libraries(layermap_test srslte_phy) +target_link_libraries(layermap_test srsran_phy) add_test(layermap_single layermap_test -n 1000 -m p0 -c 1 -l 1) @@ -33,7 +33,7 @@ add_test(layermap_multiplex_24 layermap_test -n 1000 -m mux -c 2 -l 4) ######################################################################## add_executable(precoding_test precoder_test.c) -target_link_libraries(precoding_test srslte_phy) +target_link_libraries(precoding_test srsran_phy) add_test(precoding_single precoding_test -n 1000 -m p0) add_test(precoding_diversity2 precoding_test -n 1000 -m div -l 2 -p 2) @@ -61,7 +61,7 @@ add_test(precoding_multiplex_2l_cb2_mmse precoding_test -m mux -l 2 -p 2 -r 2 -n ######################################################################## add_executable(pmi_select_test pmi_select_test.c) -target_link_libraries(pmi_select_test srslte_phy) +target_link_libraries(pmi_select_test srsran_phy) add_test(pmi_select_test pmi_select_test) diff --git a/lib/src/phy/mimo/test/layermap_test.c b/lib/src/phy/mimo/test/layermap_test.c index 83e2ac486..2fd90258b 100644 --- a/lib/src/phy/mimo/test/layermap_test.c +++ b/lib/src/phy/mimo/test/layermap_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,7 +11,7 @@ */ #include -#include +#include #include #include #include @@ -20,7 +20,7 @@ #include #include -#include "srslte/srslte.h" +#include "srsran/srsran.h" int nof_symbols = 1000; int nof_cw = 1, nof_layers = 1; @@ -30,10 +30,10 @@ void usage(char* prog) { printf("Usage: %s -m [%s|%s|%s|%s] -c [nof_cw] -l [nof_layers]\n", prog, - srslte_mimotype2str(0), - srslte_mimotype2str(1), - srslte_mimotype2str(2), - srslte_mimotype2str(3)); + srsran_mimotype2str(0), + srsran_mimotype2str(1), + srsran_mimotype2str(2), + srsran_mimotype2str(3)); printf("\t-n num_symbols [Default %d]\n", nof_symbols); } @@ -67,16 +67,16 @@ void parse_args(int argc, char** argv) int main(int argc, char** argv) { - srslte_random_t random = srslte_random_init(0); + srsran_random_t random = srsran_random_init(0); int i, j, num_errors, symbols_layer; - cf_t * d[SRSLTE_MAX_CODEWORDS], *x[SRSLTE_MAX_LAYERS], *dp[SRSLTE_MAX_CODEWORDS]; - srslte_tx_scheme_t type; - int nof_symb_cw[SRSLTE_MAX_CODEWORDS]; + cf_t * d[SRSRAN_MAX_CODEWORDS], *x[SRSRAN_MAX_LAYERS], *dp[SRSRAN_MAX_CODEWORDS]; + srsran_tx_scheme_t type; + int nof_symb_cw[SRSRAN_MAX_CODEWORDS]; int n[2]; parse_args(argc, argv); - if (srslte_str2mimotype(mimo_type_name, &type)) { + if (srsran_str2mimotype(mimo_type_name, &type)) { ERROR("Invalid MIMO type %s", mimo_type_name); exit(-1); } @@ -92,19 +92,19 @@ int main(int argc, char** argv) } for (i = 0; i < nof_cw; i++) { - d[i] = srslte_vec_cf_malloc(nof_symb_cw[i]); + d[i] = srsran_vec_cf_malloc(nof_symb_cw[i]); if (!d[i]) { perror("malloc"); exit(-1); } - dp[i] = srslte_vec_cf_malloc(nof_symb_cw[i]); + dp[i] = srsran_vec_cf_malloc(nof_symb_cw[i]); if (!dp[i]) { perror("malloc"); exit(-1); } } for (i = 0; i < nof_layers; i++) { - x[i] = srslte_vec_cf_malloc(nof_symbols); + x[i] = srsran_vec_cf_malloc(nof_symbols); if (!x[i]) { perror("malloc"); exit(-1); @@ -114,18 +114,18 @@ int main(int argc, char** argv) /* generate random data */ for (i = 0; i < nof_cw; i++) { for (j = 0; j < nof_symb_cw[i]; j++) { - d[i][j] = srslte_random_uniform_complex_dist(random, -10, 10); + d[i][j] = srsran_random_uniform_complex_dist(random, -10, 10); } } /* layer mapping */ - if ((symbols_layer = srslte_layermap_type(d, x, nof_cw, nof_layers, nof_symb_cw, type)) < 0) { + if ((symbols_layer = srsran_layermap_type(d, x, nof_cw, nof_layers, nof_symb_cw, type)) < 0) { ERROR("Error layer mapper encoder"); exit(-1); } /* layer de-mapping */ - if (srslte_layerdemap_type(x, dp, nof_layers, nof_cw, nof_symbols / nof_layers, nof_symb_cw, type) < 0) { + if (srsran_layerdemap_type(x, dp, nof_layers, nof_cw, nof_symbols / nof_layers, nof_symb_cw, type) < 0) { ERROR("Error layer mapper encoder"); exit(-1); } @@ -148,7 +148,7 @@ int main(int argc, char** argv) free(x[i]); } - srslte_random_free(random); + srsran_random_free(random); if (num_errors) { printf("%d Errors\n", num_errors); diff --git a/lib/src/phy/mimo/test/pmi_select_test.c b/lib/src/phy/mimo/test/pmi_select_test.c index 1f56aa325..bb7939acc 100644 --- a/lib/src/phy/mimo/test/pmi_select_test.c +++ b/lib/src/phy/mimo/test/pmi_select_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -21,29 +21,29 @@ #include #include "pmi_select_test.h" -#include "srslte/phy/mimo/precoding.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/mimo/precoding.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" int main(int argc, char** argv) { - cf_t* h[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS]; + cf_t* h[SRSRAN_MAX_PORTS][SRSRAN_MAX_PORTS]; float noise_estimate; - float sinr_1l[SRSLTE_MAX_CODEBOOKS]; - float sinr_2l[SRSLTE_MAX_CODEBOOKS]; + float sinr_1l[SRSRAN_MAX_CODEBOOKS]; + float sinr_2l[SRSRAN_MAX_CODEBOOKS]; float cn; uint32_t pmi[2]; - uint32_t nof_symbols = (uint32_t)SRSLTE_SF_LEN_RE(6, SRSLTE_CP_NORM); - int ret = SRSLTE_ERROR; + uint32_t nof_symbols = (uint32_t)SRSRAN_SF_LEN_RE(6, SRSRAN_CP_NORM); + int ret = SRSRAN_ERROR; /* Allocate channels */ - for (int i = 0; i < SRSLTE_MAX_PORTS; i++) { - for (int j = 0; j < SRSLTE_MAX_PORTS; j++) { - h[i][j] = srslte_vec_cf_malloc(nof_symbols); + for (int i = 0; i < SRSRAN_MAX_PORTS; i++) { + for (int j = 0; j < SRSRAN_MAX_PORTS; j++) { + h[i][j] = srsran_vec_cf_malloc(nof_symbols); if (!h[i][j]) { goto clean; } - srslte_vec_cf_zero(h[i][j], nof_symbols); + srsran_vec_cf_zero(h[i][j], nof_symbols); } } @@ -65,7 +65,7 @@ int main(int argc, char** argv) noise_estimate = gold->n; /* PMI select for 1 layer */ - ret = srslte_precoding_pmi_select(h, nof_symbols, noise_estimate, 1, &pmi[0], sinr_1l); + ret = srsran_precoding_pmi_select(h, nof_symbols, noise_estimate, 1, &pmi[0], sinr_1l); if (ret < 0) { ERROR("During PMI selection for 1 layer"); goto clean; @@ -97,7 +97,7 @@ int main(int argc, char** argv) } /* PMI select for 2 layer */ - ret = srslte_precoding_pmi_select(h, nof_symbols, noise_estimate, 2, &pmi[1], sinr_2l); + ret = srsran_precoding_pmi_select(h, nof_symbols, noise_estimate, 2, &pmi[1], sinr_2l); if (ret < 0) { ERROR("During PMI selection for 2 layer"); goto clean; @@ -129,7 +129,7 @@ int main(int argc, char** argv) } /* Condition number */ - if (srslte_precoding_cn(h, 2, 2, nof_symbols, &cn)) { + if (srsran_precoding_cn(h, 2, 2, nof_symbols, &cn)) { ERROR("Test case %d condition number returned error", c + 1); goto clean; } @@ -142,11 +142,11 @@ int main(int argc, char** argv) } /* Test passed */ - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; clean: - for (int i = 0; i < SRSLTE_MAX_PORTS; i++) { - for (int j = 0; j < SRSLTE_MAX_PORTS; j++) { + for (int i = 0; i < SRSRAN_MAX_PORTS; i++) { + for (int j = 0; j < SRSRAN_MAX_PORTS; j++) { if (h[i][j]) { free(h[i][j]); } diff --git a/lib/src/phy/mimo/test/pmi_select_test.h b/lib/src/phy/mimo/test/pmi_select_test.h index c45fc1da2..8da9202e7 100644 --- a/lib/src/phy/mimo/test/pmi_select_test.h +++ b/lib/src/phy/mimo/test/pmi_select_test.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -15,8 +15,8 @@ #define PMI_SELECT_TEST_NOF_CASES 20 +#include "srsran/config.h" #include -#include "srslte/config.h" typedef struct { cf_t h[2][2]; /* Channel estimate */ diff --git a/lib/src/phy/mimo/test/precoder_test.c b/lib/src/phy/mimo/test/precoder_test.c index 38f8a0971..950711a1b 100644 --- a/lib/src/phy/mimo/test/precoder_test.c +++ b/lib/src/phy/mimo/test/precoder_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,7 +11,7 @@ */ #include -#include +#include #include #include #include @@ -20,8 +20,8 @@ #include #include -#include "srslte/phy/channel/ch_awgn.h" -#include "srslte/srslte.h" +#include "srsran/phy/channel/ch_awgn.h" +#include "srsran/srsran.h" #define MSE_THRESHOLD 0.0005 @@ -32,17 +32,17 @@ char* mimo_type_name = NULL; char decoder_type_name[17] = "zf"; float snr_db = 100.0f; float scaling = 0.1f; -static srslte_random_t random_gen = NULL; +static srsran_random_t random_gen = NULL; void usage(char* prog) { printf("Usage: %s -m [%s|%s|%s|%s] -l [nof_layers] -p [nof_tx_ports]\n" " -r [nof_rx_ports] -g [scaling]\n", prog, - srslte_mimotype2str(0), - srslte_mimotype2str(1), - srslte_mimotype2str(2), - srslte_mimotype2str(3)); + srsran_mimotype2str(0), + srsran_mimotype2str(1), + srsran_mimotype2str(2), + srsran_mimotype2str(3)); printf("\t-n num_symbols [Default %d]\n", nof_symbols); printf("\t-c codebook_idx [Default %d]\n", codebook_idx); printf("\t-s SNR in dB [Default %.1fdB]*\n", snr_db); @@ -96,27 +96,27 @@ void parse_args(int argc, char** argv) } } -void populate_channel_cdd(cf_t* h[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS], uint32_t n) +void populate_channel_cdd(cf_t* h[SRSRAN_MAX_PORTS][SRSRAN_MAX_PORTS], uint32_t n) { int i, j, k; for (i = 0; i < nof_tx_ports; i++) { for (j = 0; j < nof_rx_ports; j++) { for (k = 0; k < n; k++) { - h[i][j][k] = srslte_random_uniform_complex_dist(random_gen, -1.0f, +1.0f); + h[i][j][k] = srsran_random_uniform_complex_dist(random_gen, -1.0f, +1.0f); } } } } -void populate_channel_diversity(cf_t* h[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS], uint32_t n) +void populate_channel_diversity(cf_t* h[SRSRAN_MAX_PORTS][SRSRAN_MAX_PORTS], uint32_t n) { int i, j, k, l; for (i = 0; i < nof_tx_ports; i++) { for (j = 0; j < nof_rx_ports; j++) { for (k = 0; k < n / nof_layers; k++) { - cf_t hsymb = srslte_random_uniform_complex_dist(random_gen, -1.0f, +1.0f); + cf_t hsymb = srsran_random_uniform_complex_dist(random_gen, -1.0f, +1.0f); for (l = 0; l < nof_layers; l++) { // assume the channel is the same for all symbols h[i][j][k * nof_layers + l] = hsymb; @@ -131,67 +131,67 @@ void populate_channel_single(cf_t* h) int i; for (i = 0; i < nof_re; i++) { - h[i] = srslte_random_uniform_complex_dist(random_gen, -1.0f, +1.0f); + h[i] = srsran_random_uniform_complex_dist(random_gen, -1.0f, +1.0f); } } -void populate_channel(srslte_tx_scheme_t type, cf_t* h[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS]) +void populate_channel(srsran_tx_scheme_t type, cf_t* h[SRSRAN_MAX_PORTS][SRSRAN_MAX_PORTS]) { switch (type) { - case SRSLTE_TXSCHEME_SPATIALMUX: - case SRSLTE_TXSCHEME_CDD: + case SRSRAN_TXSCHEME_SPATIALMUX: + case SRSRAN_TXSCHEME_CDD: populate_channel_cdd(h, (uint32_t)nof_re); break; - case SRSLTE_TXSCHEME_DIVERSITY: + case SRSRAN_TXSCHEME_DIVERSITY: populate_channel_diversity(h, (uint32_t)nof_re); break; - case SRSLTE_TXSCHEME_PORT0: + case SRSRAN_TXSCHEME_PORT0: default: populate_channel_single(h[0][0]); } } -static void awgn(cf_t* y[SRSLTE_MAX_PORTS], uint32_t n, float snr) +static void awgn(cf_t* y[SRSRAN_MAX_PORTS], uint32_t n, float snr) { int i; - float std_dev = srslte_convert_dB_to_amplitude(-(snr + 3.0f)) * scaling; + float std_dev = srsran_convert_dB_to_amplitude(-(snr + 3.0f)) * scaling; for (i = 0; i < nof_rx_ports; i++) { - srslte_ch_awgn_c(y[i], y[i], std_dev, n); + srsran_ch_awgn_c(y[i], y[i], std_dev, n); } } int main(int argc, char** argv) { - int i, j, k, nof_errors = 0, ret = SRSLTE_SUCCESS; + int i, j, k, nof_errors = 0, ret = SRSRAN_SUCCESS; float mse; - cf_t *x[SRSLTE_MAX_LAYERS], *r[SRSLTE_MAX_PORTS], *y[SRSLTE_MAX_PORTS], *h[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS], - *xr[SRSLTE_MAX_LAYERS]; - srslte_tx_scheme_t type; + cf_t *x[SRSRAN_MAX_LAYERS], *r[SRSRAN_MAX_PORTS], *y[SRSRAN_MAX_PORTS], *h[SRSRAN_MAX_PORTS][SRSRAN_MAX_PORTS], + *xr[SRSRAN_MAX_LAYERS]; + srsran_tx_scheme_t type; parse_args(argc, argv); /* Check input ranges */ - if (nof_tx_ports > SRSLTE_MAX_PORTS || nof_rx_ports > SRSLTE_MAX_PORTS || nof_layers > SRSLTE_MAX_LAYERS) { + if (nof_tx_ports > SRSRAN_MAX_PORTS || nof_rx_ports > SRSRAN_MAX_PORTS || nof_layers > SRSRAN_MAX_LAYERS) { ERROR("Invalid number of layers or ports"); exit(-1); } /* Parse MIMO Type */ - if (srslte_str2mimotype(mimo_type_name, &type)) { + if (srsran_str2mimotype(mimo_type_name, &type)) { ERROR("Invalid MIMO type %s", mimo_type_name); exit(-1); } /* Check scenario conditions are OK */ switch (type) { - case SRSLTE_TXSCHEME_DIVERSITY: + case SRSRAN_TXSCHEME_DIVERSITY: nof_re = nof_layers * nof_symbols; break; - case SRSLTE_TXSCHEME_SPATIALMUX: + case SRSRAN_TXSCHEME_SPATIALMUX: nof_re = nof_symbols; break; - case SRSLTE_TXSCHEME_CDD: + case SRSRAN_TXSCHEME_CDD: nof_re = nof_symbols * nof_tx_ports / nof_layers; if (nof_rx_ports != 2 || nof_tx_ports != 2) { ERROR("CDD nof_tx_ports=%d nof_rx_ports=%d is not currently supported", nof_tx_ports, nof_rx_ports); @@ -205,25 +205,25 @@ int main(int argc, char** argv) /* Allocate x and xr (received symbols) in memory for each layer */ for (i = 0; i < nof_layers; i++) { /* Source data */ - x[i] = srslte_vec_cf_malloc(nof_symbols); + x[i] = srsran_vec_cf_malloc(nof_symbols); if (!x[i]) { - perror("srslte_vec_malloc"); + perror("srsran_vec_malloc"); exit(-1); } /* Sink data */ - xr[i] = srslte_vec_cf_malloc(nof_symbols); + xr[i] = srsran_vec_cf_malloc(nof_symbols); if (!xr[i]) { - perror("srslte_vec_malloc"); + perror("srsran_vec_malloc"); exit(-1); } } /* Allocate y in memory for tx each port */ for (i = 0; i < nof_tx_ports; i++) { - y[i] = srslte_vec_cf_malloc(nof_re); + y[i] = srsran_vec_cf_malloc(nof_re); if (!y[i]) { - perror("srslte_vec_malloc"); + perror("srsran_vec_malloc"); exit(-1); } } @@ -231,9 +231,9 @@ int main(int argc, char** argv) /* Allocate h in memory for each cross channel and layer */ for (i = 0; i < nof_tx_ports; i++) { for (j = 0; j < nof_rx_ports; j++) { - h[i][j] = srslte_vec_cf_malloc(nof_re); + h[i][j] = srsran_vec_cf_malloc(nof_re); if (!h[i][j]) { - perror("srslte_vec_malloc"); + perror("srsran_vec_malloc"); exit(-1); } } @@ -241,24 +241,24 @@ int main(int argc, char** argv) /* Allocate r */ for (i = 0; i < nof_rx_ports; i++) { - r[i] = srslte_vec_cf_malloc(nof_re); + r[i] = srsran_vec_cf_malloc(nof_re); if (!r[i]) { - perror("srslte_vec_malloc"); + perror("srsran_vec_malloc"); exit(-1); } } /* Generate source random data */ - random_gen = srslte_random_init(0); + random_gen = srsran_random_init(0); for (i = 0; i < nof_layers; i++) { for (j = 0; j < nof_symbols; j++) { - __real__ x[i][j] = (2 * srslte_random_uniform_int_dist(random_gen, 0, 1) - 1) * M_SQRT1_2; - __imag__ x[i][j] = (2 * srslte_random_uniform_int_dist(random_gen, 0, 1) - 1) * M_SQRT1_2; + __real__ x[i][j] = (2 * srsran_random_uniform_int_dist(random_gen, 0, 1) - 1) * M_SQRT1_2; + __imag__ x[i][j] = (2 * srsran_random_uniform_int_dist(random_gen, 0, 1) - 1) * M_SQRT1_2; } } /* Execute Precoding (Tx) */ - if (srslte_precoding_type(x, y, nof_layers, nof_tx_ports, codebook_idx, nof_symbols, scaling, type) < 0) { + if (srsran_precoding_type(x, y, nof_layers, nof_tx_ports, codebook_idx, nof_symbols, scaling, type) < 0) { ERROR("Error layer mapper encoder"); exit(-1); } @@ -281,18 +281,18 @@ int main(int argc, char** argv) /* If CDD or Spatial muliplex choose decoder */ if (strncmp(decoder_type_name, "zf", 16) == 0) { - srslte_predecoding_set_mimo_decoder(SRSLTE_MIMO_DECODER_ZF); + srsran_predecoding_set_mimo_decoder(SRSRAN_MIMO_DECODER_ZF); } else if (strncmp(decoder_type_name, "mmse", 16) == 0) { - srslte_predecoding_set_mimo_decoder(SRSLTE_MIMO_DECODER_MMSE); + srsran_predecoding_set_mimo_decoder(SRSRAN_MIMO_DECODER_MMSE); } else { - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; goto quit; } /* predecoding / equalization */ struct timeval t[3]; gettimeofday(&t[1], NULL); - srslte_predecoding_type(r, + srsran_predecoding_type(r, h, xr, NULL, @@ -303,7 +303,7 @@ int main(int argc, char** argv) nof_re, type, scaling, - srslte_convert_dB_to_power(-snr_db)); + srsran_convert_dB_to_power(-snr_db)); gettimeofday(&t[2], NULL); get_time_interval(t); @@ -327,11 +327,11 @@ int main(int argc, char** argv) mse / nof_layers / nof_symbols, (float)nof_errors / (4.0f * nof_re)); if (mse / nof_layers / nof_symbols > MSE_THRESHOLD) { - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } quit: - srslte_random_free(random_gen); + srsran_random_free(random_gen); /* Free all data */ for (i = 0; i < nof_layers; i++) { diff --git a/lib/src/phy/modem/CMakeLists.txt b/lib/src/phy/modem/CMakeLists.txt index ed9574ff3..8f90ec34a 100644 --- a/lib/src/phy/modem/CMakeLists.txt +++ b/lib/src/phy/modem/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -7,5 +7,5 @@ # file(GLOB SOURCES "*.c") -add_library(srslte_modem OBJECT ${SOURCES}) +add_library(srsran_modem OBJECT ${SOURCES}) add_subdirectory(test) diff --git a/lib/src/phy/modem/demod_hard.c b/lib/src/phy/modem/demod_hard.c index 2af422777..03bada3dc 100644 --- a/lib/src/phy/modem/demod_hard.c +++ b/lib/src/phy/modem/demod_hard.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -14,44 +14,44 @@ #include #include "hard_demod_lte.h" -#include "srslte/phy/modem/demod_hard.h" +#include "srsran/phy/modem/demod_hard.h" -void srslte_demod_hard_init(srslte_demod_hard_t* q) +void srsran_demod_hard_init(srsran_demod_hard_t* q) { - bzero((void*)q, sizeof(srslte_demod_hard_t)); + bzero((void*)q, sizeof(srsran_demod_hard_t)); } -void srslte_demod_hard_table_set(srslte_demod_hard_t* q, srslte_mod_t mod) +void srsran_demod_hard_table_set(srsran_demod_hard_t* q, srsran_mod_t mod) { q->mod = mod; } -int srslte_demod_hard_demodulate(srslte_demod_hard_t* q, cf_t* symbols, uint8_t* bits, uint32_t nsymbols) +int srsran_demod_hard_demodulate(srsran_demod_hard_t* q, cf_t* symbols, uint8_t* bits, uint32_t nsymbols) { int nbits = -1; switch (q->mod) { - case SRSLTE_MOD_BPSK: + case SRSRAN_MOD_BPSK: hard_bpsk_demod(symbols, bits, nsymbols); nbits = nsymbols; break; - case SRSLTE_MOD_QPSK: + case SRSRAN_MOD_QPSK: hard_qpsk_demod(symbols, bits, nsymbols); nbits = nsymbols * 2; break; - case SRSLTE_MOD_16QAM: + case SRSRAN_MOD_16QAM: hard_qam16_demod(symbols, bits, nsymbols); nbits = nsymbols * 4; break; - case SRSLTE_MOD_64QAM: + case SRSRAN_MOD_64QAM: hard_qam64_demod(symbols, bits, nsymbols); nbits = nsymbols * 6; break; - case SRSLTE_MOD_256QAM: + case SRSRAN_MOD_256QAM: hard_qam256_demod(symbols, bits, nsymbols); nbits = nsymbols * 8; break; - case SRSLTE_MOD_NITEMS: + case SRSRAN_MOD_NITEMS: default:; // Do nothing } return nbits; diff --git a/lib/src/phy/modem/demod_soft.c b/lib/src/phy/modem/demod_soft.c index 3048a0d82..dac7a5f09 100644 --- a/lib/src/phy/modem/demod_soft.c +++ b/lib/src/phy/modem/demod_soft.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -14,10 +14,10 @@ #include #include -#include "srslte/phy/modem/demod_soft.h" -#include "srslte/phy/utils/bit.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/modem/demod_soft.h" +#include "srsran/phy/utils/bit.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" #ifdef HAVE_NEONv8 #include @@ -122,17 +122,17 @@ void demod_bpsk_lte(const cf_t* symbols, float* llr, int nsymbols) void demod_qpsk_lte_b(const cf_t* symbols, int8_t* llr, int nsymbols) { - srslte_vec_convert_fb((const float*)symbols, -SCALE_BYTE_CONV_QPSK * M_SQRT2, llr, nsymbols * 2); + srsran_vec_convert_fb((const float*)symbols, -SCALE_BYTE_CONV_QPSK * M_SQRT2, llr, nsymbols * 2); } void demod_qpsk_lte_s(const cf_t* symbols, short* llr, int nsymbols) { - srslte_vec_convert_fi((const float*)symbols, -SCALE_SHORT_CONV_QPSK * M_SQRT2, llr, nsymbols * 2); + srsran_vec_convert_fi((const float*)symbols, -SCALE_SHORT_CONV_QPSK * M_SQRT2, llr, nsymbols * 2); } void demod_qpsk_lte(const cf_t* symbols, float* llr, int nsymbols) { - srslte_vec_sc_prod_fff((const float*)symbols, -M_SQRT2, llr, nsymbols * 2); + srsran_vec_sc_prod_fff((const float*)symbols, -M_SQRT2, llr, nsymbols * 2); } void demod_16qam_lte(const cf_t* symbols, float* llr, int nsymbols) @@ -856,22 +856,22 @@ void demod_256qam_lte_s(const cf_t* symbols, short* llr, int nsymbols) } } -int srslte_demod_soft_demodulate(srslte_mod_t modulation, const cf_t* symbols, float* llr, int nsymbols) +int srsran_demod_soft_demodulate(srsran_mod_t modulation, const cf_t* symbols, float* llr, int nsymbols) { switch (modulation) { - case SRSLTE_MOD_BPSK: + case SRSRAN_MOD_BPSK: demod_bpsk_lte(symbols, llr, nsymbols); break; - case SRSLTE_MOD_QPSK: + case SRSRAN_MOD_QPSK: demod_qpsk_lte(symbols, llr, nsymbols); break; - case SRSLTE_MOD_16QAM: + case SRSRAN_MOD_16QAM: demod_16qam_lte(symbols, llr, nsymbols); break; - case SRSLTE_MOD_64QAM: + case SRSRAN_MOD_64QAM: demod_64qam_lte(symbols, llr, nsymbols); break; - case SRSLTE_MOD_256QAM: + case SRSRAN_MOD_256QAM: demod_256qam_lte(symbols, llr, nsymbols); break; default: @@ -881,22 +881,22 @@ int srslte_demod_soft_demodulate(srslte_mod_t modulation, const cf_t* symbols, f return 0; } -int srslte_demod_soft_demodulate_s(srslte_mod_t modulation, const cf_t* symbols, short* llr, int nsymbols) +int srsran_demod_soft_demodulate_s(srsran_mod_t modulation, const cf_t* symbols, short* llr, int nsymbols) { switch (modulation) { - case SRSLTE_MOD_BPSK: + case SRSRAN_MOD_BPSK: demod_bpsk_lte_s(symbols, llr, nsymbols); break; - case SRSLTE_MOD_QPSK: + case SRSRAN_MOD_QPSK: demod_qpsk_lte_s(symbols, llr, nsymbols); break; - case SRSLTE_MOD_16QAM: + case SRSRAN_MOD_16QAM: demod_16qam_lte_s(symbols, llr, nsymbols); break; - case SRSLTE_MOD_64QAM: + case SRSRAN_MOD_64QAM: demod_64qam_lte_s(symbols, llr, nsymbols); break; - case SRSLTE_MOD_256QAM: + case SRSRAN_MOD_256QAM: demod_256qam_lte_s(symbols, llr, nsymbols); break; default: @@ -906,22 +906,22 @@ int srslte_demod_soft_demodulate_s(srslte_mod_t modulation, const cf_t* symbols, return 0; } -int srslte_demod_soft_demodulate_b(srslte_mod_t modulation, const cf_t* symbols, int8_t* llr, int nsymbols) +int srsran_demod_soft_demodulate_b(srsran_mod_t modulation, const cf_t* symbols, int8_t* llr, int nsymbols) { switch (modulation) { - case SRSLTE_MOD_BPSK: + case SRSRAN_MOD_BPSK: demod_bpsk_lte_b(symbols, llr, nsymbols); break; - case SRSLTE_MOD_QPSK: + case SRSRAN_MOD_QPSK: demod_qpsk_lte_b(symbols, llr, nsymbols); break; - case SRSLTE_MOD_16QAM: + case SRSRAN_MOD_16QAM: demod_16qam_lte_b(symbols, llr, nsymbols); break; - case SRSLTE_MOD_64QAM: + case SRSRAN_MOD_64QAM: demod_64qam_lte_b(symbols, llr, nsymbols); break; - case SRSLTE_MOD_256QAM: + case SRSRAN_MOD_256QAM: demod_256qam_lte_b(symbols, llr, nsymbols); break; default: diff --git a/lib/src/phy/modem/hard_demod_lte.c b/lib/src/phy/modem/hard_demod_lte.c index 5e63bcf11..b521e40a4 100644 --- a/lib/src/phy/modem/hard_demod_lte.c +++ b/lib/src/phy/modem/hard_demod_lte.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,15 +10,15 @@ * */ -#ifndef SRSLTE_HARD_DEMOD_LTE_H_ -#define SRSLTE_HARD_DEMOD_LTE_H_ +#ifndef SRSRAN_HARD_DEMOD_LTE_H_ +#define SRSRAN_HARD_DEMOD_LTE_H_ #include #include #include #include "hard_demod_lte.h" -#include "srslte/phy/modem/demod_hard.h" +#include "srsran/phy/modem/demod_hard.h" /** * @ingroup Hard BPSK demodulator @@ -276,4 +276,4 @@ inline void hard_qam256_demod(const cf_t* in, uint8_t* out, uint32_t N) } } -#endif /* SRSLTE_HARD_DEMOD_LTE_H_ */ \ No newline at end of file +#endif /* SRSRAN_HARD_DEMOD_LTE_H_ */ \ No newline at end of file diff --git a/lib/src/phy/modem/hard_demod_lte.h b/lib/src/phy/modem/hard_demod_lte.h index cdf19a2bb..2da70fb45 100644 --- a/lib/src/phy/modem/hard_demod_lte.h +++ b/lib/src/phy/modem/hard_demod_lte.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,8 +10,8 @@ * */ +#include "srsran/config.h" #include -#include "srslte/config.h" /* Thresholds for Demodulation */ /* Assume perfect amplitude and phase alignment. diff --git a/lib/src/phy/modem/lte_tables.c b/lib/src/phy/modem/lte_tables.c index c6a4f5731..c67beae3a 100644 --- a/lib/src/phy/modem/lte_tables.c +++ b/lib/src/phy/modem/lte_tables.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -16,7 +16,7 @@ #include #include "lte_tables.h" -#include "srslte/phy/modem/modem_table.h" +#include "srsran/phy/modem/modem_table.h" /** * Set the BPSK modulation table */ diff --git a/lib/src/phy/modem/lte_tables.h b/lib/src/phy/modem/lte_tables.h index 670d332f5..3ca0559d7 100644 --- a/lib/src/phy/modem/lte_tables.h +++ b/lib/src/phy/modem/lte_tables.h @@ -2,17 +2,17 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of * the distribution. * */ -#ifndef SRSLTE_LTE_TABLES_H_ -#define SRSLTE_LTE_TABLES_H_ +#ifndef SRSRAN_LTE_TABLES_H_ +#define SRSRAN_LTE_TABLES_H_ -#include +#include #define BPSK_LEVEL M_SQRT1_2 @@ -48,4 +48,4 @@ void set_64QAMtable(cf_t* table); void set_256QAMtable(cf_t* table); -#endif /* SRSLTE_LTE_TABLES_H_ */ +#endif /* SRSRAN_LTE_TABLES_H_ */ diff --git a/lib/src/phy/modem/mod.c b/lib/src/phy/modem/mod.c index 7fd445386..20478fc0d 100644 --- a/lib/src/phy/modem/mod.c +++ b/lib/src/phy/modem/mod.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -15,30 +15,30 @@ #include #include -#include "srslte/phy/modem/mod.h" -#include "srslte/phy/utils/bit.h" -#include "srslte/phy/utils/debug.h" +#include "srsran/phy/modem/mod.h" +#include "srsran/phy/utils/bit.h" +#include "srsran/phy/utils/debug.h" /** Low-level API */ -int srslte_mod_modulate(const srslte_modem_table_t* q, uint8_t* bits, cf_t* symbols, uint32_t nbits) +int srsran_mod_modulate(const srsran_modem_table_t* q, uint8_t* bits, cf_t* symbols, uint32_t nbits) { uint32_t i, j, idx; uint8_t* b_ptr = (uint8_t*)bits; j = 0; for (i = 0; i < nbits; i += q->nbits_x_symbol) { - idx = srslte_bit_pack(&b_ptr, q->nbits_x_symbol); + idx = srsran_bit_pack(&b_ptr, q->nbits_x_symbol); if (idx < q->nsymbols) { symbols[j] = q->symbol_table[idx]; } else { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } j++; } return j; } -static void mod_bpsk_bytes(const srslte_modem_table_t* q, const uint8_t* bits, cf_t* symbols, uint32_t nbits) +static void mod_bpsk_bytes(const srsran_modem_table_t* q, const uint8_t* bits, cf_t* symbols, uint32_t nbits) { uint8_t mask_bpsk[8] = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01}; uint8_t shift_bpsk[8] = {7, 6, 5, 4, 3, 2, 1, 0}; @@ -51,7 +51,7 @@ static void mod_bpsk_bytes(const srslte_modem_table_t* q, const uint8_t* bits, c } } -static void mod_qpsk_bytes(const srslte_modem_table_t* q, const uint8_t* bits, cf_t* symbols, uint32_t nbits) +static void mod_qpsk_bytes(const srsran_modem_table_t* q, const uint8_t* bits, cf_t* symbols, uint32_t nbits) { uint8_t mask_qpsk[4] = {0xc0, 0x30, 0x0c, 0x03}; uint8_t shift_qpsk[4] = {6, 4, 2, 0}; @@ -64,7 +64,7 @@ static void mod_qpsk_bytes(const srslte_modem_table_t* q, const uint8_t* bits, c } } -static void mod_16qam_bytes(const srslte_modem_table_t* q, const uint8_t* bits, cf_t* symbols, uint32_t nbits) +static void mod_16qam_bytes(const srsran_modem_table_t* q, const uint8_t* bits, cf_t* symbols, uint32_t nbits) { for (int i = 0; i < nbits / 8; i++) { memcpy(&symbols[2 * i], &q->symbol_table_16qam[bits[i]], sizeof(qam16_packed_t)); @@ -75,7 +75,7 @@ static void mod_16qam_bytes(const srslte_modem_table_t* q, const uint8_t* bits, } } -static void mod_64qam_bytes(const srslte_modem_table_t* q, const uint8_t* bits, cf_t* symbols, uint32_t nbits) +static void mod_64qam_bytes(const srsran_modem_table_t* q, const uint8_t* bits, cf_t* symbols, uint32_t nbits) { uint8_t in0, in1, in2, in3; uint32_t in80, in81, in82; @@ -115,7 +115,7 @@ static void mod_64qam_bytes(const srslte_modem_table_t* q, const uint8_t* bits, } } -static void mod_256qam_bytes(const srslte_modem_table_t* q, const uint8_t* bits, cf_t* symbols, uint32_t nbits) +static void mod_256qam_bytes(const srsran_modem_table_t* q, const uint8_t* bits, cf_t* symbols, uint32_t nbits) { for (int i = 0; i < nbits / 8; i++) { symbols[i] = q->symbol_table[bits[i]]; @@ -123,11 +123,11 @@ static void mod_256qam_bytes(const srslte_modem_table_t* q, const uint8_t* bits, } /* Assumes packet bits as input */ -int srslte_mod_modulate_bytes(const srslte_modem_table_t* q, const uint8_t* bits, cf_t* symbols, uint32_t nbits) +int srsran_mod_modulate_bytes(const srsran_modem_table_t* q, const uint8_t* bits, cf_t* symbols, uint32_t nbits) { if (!q->byte_tables_init) { - ERROR("Error need to initiated modem tables for packeted bits before calling srslte_mod_modulate_bytes()"); - return SRSLTE_ERROR; + ERROR("Error need to initiated modem tables for packeted bits before calling srsran_mod_modulate_bytes()"); + return SRSRAN_ERROR; } if (nbits % q->nbits_x_symbol) { ERROR("Error modulator expects number of bits (%d) to be multiple of %d", nbits, q->nbits_x_symbol); @@ -150,8 +150,8 @@ int srslte_mod_modulate_bytes(const srslte_modem_table_t* q, const uint8_t* bits mod_256qam_bytes(q, bits, symbols, nbits); break; default: - ERROR("srslte_mod_modulate_bytes() accepts QPSK/16QAM/64QAM modulations only"); - return SRSLTE_ERROR; + ERROR("srsran_mod_modulate_bytes() accepts QPSK/16QAM/64QAM modulations only"); + return SRSRAN_ERROR; } return nbits / q->nbits_x_symbol; } diff --git a/lib/src/phy/modem/modem_table.c b/lib/src/phy/modem/modem_table.c index 9894cbe34..4225c078f 100644 --- a/lib/src/phy/modem/modem_table.c +++ b/lib/src/phy/modem/modem_table.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -18,22 +18,22 @@ #include #include "lte_tables.h" -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/modem/modem_table.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/modem/modem_table.h" +#include "srsran/phy/utils/vector.h" /** Internal functions */ -static int table_create(srslte_modem_table_t* q) +static int table_create(srsran_modem_table_t* q) { - q->symbol_table = srslte_vec_cf_malloc(q->nsymbols); + q->symbol_table = srsran_vec_cf_malloc(q->nsymbols); return q->symbol_table == NULL; } -void srslte_modem_table_init(srslte_modem_table_t* q) +void srsran_modem_table_init(srsran_modem_table_t* q) { - bzero((void*)q, sizeof(srslte_modem_table_t)); + bzero((void*)q, sizeof(srsran_modem_table_t)); } -void srslte_modem_table_free(srslte_modem_table_t* q) +void srsran_modem_table_free(srsran_modem_table_t* q) { if (q->symbol_table) { free(q->symbol_table); @@ -47,86 +47,86 @@ void srslte_modem_table_free(srslte_modem_table_t* q) if (q->symbol_table_16qam) { free(q->symbol_table_16qam); } - bzero(q, sizeof(srslte_modem_table_t)); + bzero(q, sizeof(srsran_modem_table_t)); } -void srslte_modem_table_reset(srslte_modem_table_t* q) +void srsran_modem_table_reset(srsran_modem_table_t* q) { - srslte_modem_table_free(q); - srslte_modem_table_init(q); + srsran_modem_table_free(q); + srsran_modem_table_init(q); } -int srslte_modem_table_set(srslte_modem_table_t* q, cf_t* table, uint32_t nsymbols, uint32_t nbits_x_symbol) +int srsran_modem_table_set(srsran_modem_table_t* q, cf_t* table, uint32_t nsymbols, uint32_t nbits_x_symbol) { if (q->nsymbols) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } q->nsymbols = nsymbols; if (table_create(q)) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } memcpy(q->symbol_table, table, q->nsymbols * sizeof(cf_t)); q->nbits_x_symbol = nbits_x_symbol; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_modem_table_lte(srslte_modem_table_t* q, srslte_mod_t modulation) +int srsran_modem_table_lte(srsran_modem_table_t* q, srsran_mod_t modulation) { - srslte_modem_table_init(q); + srsran_modem_table_init(q); switch (modulation) { - case SRSLTE_MOD_BPSK: + case SRSRAN_MOD_BPSK: q->nbits_x_symbol = 1; q->nsymbols = 2; if (table_create(q)) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } set_BPSKtable(q->symbol_table); break; - case SRSLTE_MOD_QPSK: + case SRSRAN_MOD_QPSK: q->nbits_x_symbol = 2; q->nsymbols = 4; if (table_create(q)) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } set_QPSKtable(q->symbol_table); break; - case SRSLTE_MOD_16QAM: + case SRSRAN_MOD_16QAM: q->nbits_x_symbol = 4; q->nsymbols = 16; if (table_create(q)) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } set_16QAMtable(q->symbol_table); break; - case SRSLTE_MOD_64QAM: + case SRSRAN_MOD_64QAM: q->nbits_x_symbol = 6; q->nsymbols = 64; if (table_create(q)) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } set_64QAMtable(q->symbol_table); break; - case SRSLTE_MOD_256QAM: + case SRSRAN_MOD_256QAM: q->nbits_x_symbol = 8; q->nsymbols = 256; if (table_create(q)) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } set_256QAMtable(q->symbol_table); break; - case SRSLTE_MOD_NITEMS: + case SRSRAN_MOD_NITEMS: default:; // Do nothing } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -void srslte_modem_table_bytes(srslte_modem_table_t* q) +void srsran_modem_table_bytes(srsran_modem_table_t* q) { uint8_t mask_qpsk[4] = {0xc0, 0x30, 0xc, 0x3}; uint8_t mask_16qam[2] = {0xf0, 0xf}; switch (q->nbits_x_symbol) { case 1: - q->symbol_table_bpsk = srslte_vec_malloc(sizeof(bpsk_packed_t) * 256); + q->symbol_table_bpsk = srsran_vec_malloc(sizeof(bpsk_packed_t) * 256); for (uint32_t i = 0; i < 256; i++) { for (int j = 0; j < 8; j++) { q->symbol_table_bpsk[i].symbol[j] = q->symbol_table[(i & (1 << (7 - j))) >> (7 - j)]; @@ -135,7 +135,7 @@ void srslte_modem_table_bytes(srslte_modem_table_t* q) q->byte_tables_init = true; break; case 2: - q->symbol_table_qpsk = srslte_vec_malloc(sizeof(qpsk_packed_t) * 256); + q->symbol_table_qpsk = srsran_vec_malloc(sizeof(qpsk_packed_t) * 256); for (uint32_t i = 0; i < 256; i++) { for (int j = 0; j < 4; j++) { q->symbol_table_qpsk[i].symbol[j] = q->symbol_table[(i & mask_qpsk[j]) >> (6 - j * 2)]; @@ -144,7 +144,7 @@ void srslte_modem_table_bytes(srslte_modem_table_t* q) q->byte_tables_init = true; break; case 4: - q->symbol_table_16qam = srslte_vec_malloc(sizeof(qam16_packed_t) * 256); + q->symbol_table_16qam = srsran_vec_malloc(sizeof(qam16_packed_t) * 256); for (uint32_t i = 0; i < 256; i++) { for (int j = 0; j < 2; j++) { q->symbol_table_16qam[i].symbol[j] = q->symbol_table[(i & mask_16qam[j]) >> (4 - j * 4)]; diff --git a/lib/src/phy/modem/test/CMakeLists.txt b/lib/src/phy/modem/test/CMakeLists.txt index 19f00d1ad..14c1bbd93 100644 --- a/lib/src/phy/modem/test/CMakeLists.txt +++ b/lib/src/phy/modem/test/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -11,7 +11,7 @@ ######################################################################## add_executable(modem_test modem_test.c) -target_link_libraries(modem_test srslte_phy) +target_link_libraries(modem_test srsran_phy) add_test(modem_bpsk modem_test -n 1024 -m 1) add_test(modem_qpsk modem_test -n 1024 -m 2) @@ -26,7 +26,7 @@ add_test(modem_qam64_soft modem_test -n 1008 -m 6) add_test(modem_qam256_soft modem_test -n 1024 -m 8) add_executable(soft_demod_test soft_demod_test.c) -target_link_libraries(soft_demod_test srslte_phy) +target_link_libraries(soft_demod_test srsran_phy) diff --git a/lib/src/phy/modem/test/modem_test.c b/lib/src/phy/modem/test/modem_test.c index 690850e83..f369f9cd7 100644 --- a/lib/src/phy/modem/test/modem_test.c +++ b/lib/src/phy/modem/test/modem_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -19,13 +19,13 @@ #include #include -#include "srslte/srslte.h" +#include "srsran/srsran.h" time_t start, finish; struct timeval x, y; static uint32_t num_bits = 1000; -static srslte_mod_t modulation = SRSLTE_MOD_BPSK; +static srsran_mod_t modulation = SRSRAN_MOD_BPSK; void usage(char* prog) { @@ -45,19 +45,19 @@ void parse_args(int argc, char** argv) case 'm': switch (strtol(argv[optind], NULL, 10)) { case 1: - modulation = SRSLTE_MOD_BPSK; + modulation = SRSRAN_MOD_BPSK; break; case 2: - modulation = SRSLTE_MOD_QPSK; + modulation = SRSRAN_MOD_QPSK; break; case 4: - modulation = SRSLTE_MOD_16QAM; + modulation = SRSRAN_MOD_16QAM; break; case 6: - modulation = SRSLTE_MOD_64QAM; + modulation = SRSRAN_MOD_64QAM; break; case 8: - modulation = SRSLTE_MOD_256QAM; + modulation = SRSRAN_MOD_256QAM; break; default: ERROR("Invalid modulation %ld. Possible values: " @@ -75,9 +75,9 @@ void parse_args(int argc, char** argv) int main(int argc, char** argv) { - int ret = SRSLTE_SUCCESS; + int ret = SRSRAN_SUCCESS; int i; - srslte_modem_table_t mod; + srsran_modem_table_t mod; uint8_t * input, *input_bytes, *output; cf_t * symbols, *symbols_bytes; float* llr; @@ -85,12 +85,12 @@ int main(int argc, char** argv) parse_args(argc, argv); /* initialize objects */ - if (srslte_modem_table_lte(&mod, modulation)) { + if (srsran_modem_table_lte(&mod, modulation)) { ERROR("Error initializing modem table"); exit(-1); } - srslte_modem_table_bytes(&mod); + srsran_modem_table_bytes(&mod); /* check that num_bits is multiple of num_bits x symbol */ if (num_bits % mod.nbits_x_symbol) { @@ -99,33 +99,33 @@ int main(int argc, char** argv) } /* allocate buffers */ - input = srslte_vec_u8_malloc(num_bits); + input = srsran_vec_u8_malloc(num_bits); if (!input) { perror("malloc"); exit(-1); } - input_bytes = srslte_vec_u8_malloc(num_bits / 8); + input_bytes = srsran_vec_u8_malloc(num_bits / 8); if (!input_bytes) { perror("malloc"); exit(-1); } - output = srslte_vec_u8_malloc(num_bits); + output = srsran_vec_u8_malloc(num_bits); if (!output) { perror("malloc"); exit(-1); } - symbols = srslte_vec_cf_malloc(num_bits / mod.nbits_x_symbol); + symbols = srsran_vec_cf_malloc(num_bits / mod.nbits_x_symbol); if (!symbols) { perror("malloc"); exit(-1); } - symbols_bytes = srslte_vec_cf_malloc(num_bits / mod.nbits_x_symbol); + symbols_bytes = srsran_vec_cf_malloc(num_bits / mod.nbits_x_symbol); if (!symbols_bytes) { perror("malloc"); exit(-1); } - llr = srslte_vec_f_malloc(num_bits); + llr = srsran_vec_f_malloc(num_bits); if (!llr) { perror("malloc"); exit(-1); @@ -141,7 +141,7 @@ int main(int argc, char** argv) gettimeofday(&t[1], NULL); int ntrials = 100; for (int i = 0; i < ntrials; i++) { - srslte_mod_modulate(&mod, input, symbols, num_bits); + srsran_mod_modulate(&mod, input, symbols, num_bits); } gettimeofday(&t[2], NULL); get_time_interval(t); @@ -149,10 +149,10 @@ int main(int argc, char** argv) printf("Bit: %ld us\n", t[0].tv_usec); /* Test packed implementation */ - srslte_bit_pack_vector(input, input_bytes, num_bits); + srsran_bit_pack_vector(input, input_bytes, num_bits); gettimeofday(&t[1], NULL); for (int i = 0; i < ntrials; i++) { - srslte_mod_modulate_bytes(&mod, input_bytes, symbols_bytes, num_bits); + srsran_mod_modulate_bytes(&mod, input_bytes, symbols_bytes, num_bits); } gettimeofday(&t[2], NULL); get_time_interval(t); @@ -165,12 +165,12 @@ int main(int argc, char** argv) } } - srslte_vec_f_zero(llr, num_bits / mod.nbits_x_symbol); + srsran_vec_f_zero(llr, num_bits / mod.nbits_x_symbol); printf("Symbols OK\n"); /* demodulate */ gettimeofday(&x, NULL); - srslte_demod_soft_demodulate(modulation, symbols, llr, num_bits / mod.nbits_x_symbol); + srsran_demod_soft_demodulate(modulation, symbols, llr, num_bits / mod.nbits_x_symbol); gettimeofday(&y, NULL); printf("\nElapsed time [us]: %ld\n", y.tv_usec - x.tv_usec); for (i = 0; i < num_bits; i++) { @@ -178,10 +178,10 @@ int main(int argc, char** argv) } /* check errors */ - for (i = 0; i < num_bits && ret == SRSLTE_SUCCESS; i++) { + for (i = 0; i < num_bits && ret == SRSRAN_SUCCESS; i++) { if (input[i] != output[i]) { ERROR("Error in bit %d", i); - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } } @@ -192,7 +192,7 @@ int main(int argc, char** argv) free(input); free(input_bytes); - srslte_modem_table_free(&mod); + srsran_modem_table_free(&mod); exit(ret); } diff --git a/lib/src/phy/modem/test/soft_demod_test.c b/lib/src/phy/modem/test/soft_demod_test.c index 83ecc86ef..ee3ee49f3 100644 --- a/lib/src/phy/modem/test/soft_demod_test.c +++ b/lib/src/phy/modem/test/soft_demod_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -19,18 +19,18 @@ #include #include -#include "srslte/srslte.h" +#include "srsran/srsran.h" static uint32_t nof_frames = 10; static uint32_t num_bits = 1000; -static srslte_mod_t modulation = SRSLTE_MOD_NITEMS; +static srsran_mod_t modulation = SRSRAN_MOD_NITEMS; void usage(char* prog) { printf("Usage: %s [nfv] -m modulation (1: BPSK, 2: QPSK, 4: QAM16, 6: QAM64)\n", prog); printf("\t-n num_bits [Default %d]\n", num_bits); printf("\t-f nof_frames [Default %d]\n", nof_frames); - printf("\t-v srslte_verbose [Default None]\n"); + printf("\t-v srsran_verbose [Default None]\n"); } void parse_args(int argc, char** argv) @@ -45,24 +45,24 @@ void parse_args(int argc, char** argv) nof_frames = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'v': - srslte_verbose++; + srsran_verbose++; break; case 'm': switch (strtol(argv[optind], NULL, 10)) { case 1: - modulation = SRSLTE_MOD_BPSK; + modulation = SRSRAN_MOD_BPSK; break; case 2: - modulation = SRSLTE_MOD_QPSK; + modulation = SRSRAN_MOD_QPSK; break; case 4: - modulation = SRSLTE_MOD_16QAM; + modulation = SRSRAN_MOD_16QAM; break; case 6: - modulation = SRSLTE_MOD_64QAM; + modulation = SRSRAN_MOD_64QAM; break; case 8: - modulation = SRSLTE_MOD_256QAM; + modulation = SRSRAN_MOD_256QAM; break; default: ERROR("Invalid modulation %d. Possible values: " @@ -76,7 +76,7 @@ void parse_args(int argc, char** argv) exit(-1); } } - if (modulation == SRSLTE_MOD_NITEMS) { + if (modulation == SRSRAN_MOD_NITEMS) { usage(argv[0]); exit(-1); } @@ -85,15 +85,15 @@ void parse_args(int argc, char** argv) float mse_threshold() { switch (modulation) { - case SRSLTE_MOD_BPSK: + case SRSRAN_MOD_BPSK: return 1.0e-6; - case SRSLTE_MOD_QPSK: + case SRSRAN_MOD_QPSK: return 1.0e-6; - case SRSLTE_MOD_16QAM: + case SRSRAN_MOD_16QAM: return 0.11; - case SRSLTE_MOD_64QAM: + case SRSRAN_MOD_64QAM: return 0.19; - case SRSLTE_MOD_256QAM: + case SRSRAN_MOD_256QAM: return 0.3; default: return -1.0f; @@ -103,7 +103,7 @@ float mse_threshold() int main(int argc, char** argv) { int i; - srslte_modem_table_t mod; + srsran_modem_table_t mod; uint8_t * input, *output; cf_t* symbols; float* llr; @@ -113,7 +113,7 @@ int main(int argc, char** argv) parse_args(argc, argv); /* initialize objects */ - if (srslte_modem_table_lte(&mod, modulation)) { + if (srsran_modem_table_lte(&mod, modulation)) { ERROR("Error initializing modem table"); exit(-1); } @@ -122,35 +122,35 @@ int main(int argc, char** argv) num_bits = mod.nbits_x_symbol * (num_bits / mod.nbits_x_symbol); /* allocate buffers */ - input = srslte_vec_u8_malloc(num_bits); + input = srsran_vec_u8_malloc(num_bits); if (!input) { perror("malloc"); exit(-1); } - output = srslte_vec_u8_malloc(num_bits); + output = srsran_vec_u8_malloc(num_bits); if (!output) { perror("malloc"); exit(-1); } - symbols = srslte_vec_cf_malloc(num_bits / mod.nbits_x_symbol); + symbols = srsran_vec_cf_malloc(num_bits / mod.nbits_x_symbol); if (!symbols) { perror("malloc"); exit(-1); } - llr = srslte_vec_f_malloc(num_bits); + llr = srsran_vec_f_malloc(num_bits); if (!llr) { perror("malloc"); exit(-1); } - llr_s = srslte_vec_i16_malloc(num_bits); + llr_s = srsran_vec_i16_malloc(num_bits); if (!llr_s) { perror("malloc"); exit(-1); } - llr_b = srslte_vec_i8_malloc(num_bits); + llr_b = srsran_vec_i8_malloc(num_bits); if (!llr_b) { perror("malloc"); exit(-1); @@ -170,51 +170,51 @@ int main(int argc, char** argv) } /* modulate */ - srslte_mod_modulate(&mod, input, symbols, num_bits); + srsran_mod_modulate(&mod, input, symbols, num_bits); gettimeofday(&t[1], NULL); - srslte_demod_soft_demodulate(modulation, symbols, llr, num_bits / mod.nbits_x_symbol); + srsran_demod_soft_demodulate(modulation, symbols, llr, num_bits / mod.nbits_x_symbol); gettimeofday(&t[2], NULL); get_time_interval(t); /* compute exponentially averaged execution time */ if (n > 0) { - mean_texec = SRSLTE_VEC_CMA((float)t[0].tv_usec, mean_texec, n - 1); + mean_texec = SRSRAN_VEC_CMA((float)t[0].tv_usec, mean_texec, n - 1); } gettimeofday(&t[1], NULL); - srslte_demod_soft_demodulate_s(modulation, symbols, llr_s, num_bits / mod.nbits_x_symbol); + srsran_demod_soft_demodulate_s(modulation, symbols, llr_s, num_bits / mod.nbits_x_symbol); gettimeofday(&t[2], NULL); get_time_interval(t); if (n > 0) { - mean_texec_s = SRSLTE_VEC_CMA((float)t[0].tv_usec, mean_texec_s, n - 1); + mean_texec_s = SRSRAN_VEC_CMA((float)t[0].tv_usec, mean_texec_s, n - 1); } gettimeofday(&t[1], NULL); - srslte_demod_soft_demodulate_b(modulation, symbols, llr_b, num_bits / mod.nbits_x_symbol); + srsran_demod_soft_demodulate_b(modulation, symbols, llr_b, num_bits / mod.nbits_x_symbol); gettimeofday(&t[2], NULL); get_time_interval(t); if (n > 0) { - mean_texec_b = SRSLTE_VEC_CMA((float)t[0].tv_usec, mean_texec_b, n - 1); + mean_texec_b = SRSRAN_VEC_CMA((float)t[0].tv_usec, mean_texec_b, n - 1); } - if (SRSLTE_VERBOSE_ISDEBUG()) { + if (SRSRAN_VERBOSE_ISDEBUG()) { printf("bits="); - srslte_vec_fprint_b(stdout, input, num_bits); + srsran_vec_fprint_b(stdout, input, num_bits); printf("symbols="); - srslte_vec_fprint_c(stdout, symbols, num_bits / mod.nbits_x_symbol); + srsran_vec_fprint_c(stdout, symbols, num_bits / mod.nbits_x_symbol); printf("llr="); - srslte_vec_fprint_f(stdout, llr, num_bits); + srsran_vec_fprint_f(stdout, llr, num_bits); printf("llr_s="); - srslte_vec_fprint_s(stdout, llr_s, num_bits); + srsran_vec_fprint_s(stdout, llr_s, num_bits); printf("llr_b="); - srslte_vec_fprint_bs(stdout, llr_b, num_bits); + srsran_vec_fprint_bs(stdout, llr_b, num_bits); } // Check demodulation errors @@ -235,7 +235,7 @@ clean_exit: free(output); free(input); - srslte_modem_table_free(&mod); + srsran_modem_table_free(&mod); printf("Mean Throughput: %.2f/%.2f/%.2f. Mbps ExTime: %.2f/%.2f/%.2f us\n", num_bits / mean_texec, diff --git a/lib/src/phy/phch/CMakeLists.txt b/lib/src/phy/phch/CMakeLists.txt index da426aa32..4de64b398 100644 --- a/lib/src/phy/phch/CMakeLists.txt +++ b/lib/src/phy/phch/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -7,5 +7,5 @@ # file(GLOB SOURCES "*.c") -add_library(srslte_phch OBJECT ${SOURCES}) +add_library(srsran_phch OBJECT ${SOURCES}) add_subdirectory(test) diff --git a/lib/src/phy/phch/cqi.c b/lib/src/phy/phch/cqi.c index c0b559215..374e50238 100644 --- a/lib/src/phy/phch/cqi.c +++ b/lib/src/phy/phch/cqi.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,7 +10,7 @@ * */ -#include "srslte/srslte.h" +#include "srsran/srsran.h" #include #include #include @@ -20,43 +20,43 @@ #include #include -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/phch/cqi.h" -#include "srslte/phy/utils/bit.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/phch/cqi.h" +#include "srsran/phy/utils/bit.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" /******************************************************* * PACKING FUNCTIONS * *******************************************************/ -static int cqi_hl_subband_pack(srslte_cqi_cfg_t* cfg, srslte_cqi_hl_subband_t* msg, uint8_t* buff) +static int cqi_hl_subband_pack(srsran_cqi_cfg_t* cfg, srsran_cqi_hl_subband_t* msg, uint8_t* buff) { uint8_t* body_ptr = buff; uint32_t bit_count = 0; /* Unpack codeword 0, common for 3GPP 36.212 Tables 5.2.2.6.2-1 and 5.2.2.6.2-2 */ - srslte_bit_unpack(msg->wideband_cqi_cw0, &body_ptr, 4); - srslte_bit_unpack(msg->subband_diff_cqi_cw0, &body_ptr, 2 * cfg->N); + srsran_bit_unpack(msg->wideband_cqi_cw0, &body_ptr, 4); + srsran_bit_unpack(msg->subband_diff_cqi_cw0, &body_ptr, 2 * cfg->N); bit_count += 4 + 2 * cfg->N; /* Unpack codeword 1, 3GPP 36.212 Table 5.2.2.6.2-2 */ if (cfg->rank_is_not_one) { - srslte_bit_unpack(msg->wideband_cqi_cw1, &body_ptr, 4); - srslte_bit_unpack(msg->subband_diff_cqi_cw1, &body_ptr, 2 * cfg->N); + srsran_bit_unpack(msg->wideband_cqi_cw1, &body_ptr, 4); + srsran_bit_unpack(msg->subband_diff_cqi_cw1, &body_ptr, 2 * cfg->N); bit_count += 4 + 2 * cfg->N; } /* If PMI is present, unpack it */ if (cfg->pmi_present) { if (cfg->four_antenna_ports) { - srslte_bit_unpack(msg->pmi, &body_ptr, 4); + srsran_bit_unpack(msg->pmi, &body_ptr, 4); bit_count += 4; } else { if (cfg->rank_is_not_one) { - srslte_bit_unpack(msg->pmi, &body_ptr, 1); + srsran_bit_unpack(msg->pmi, &body_ptr, 1); bit_count += 1; } else { - srslte_bit_unpack(msg->pmi, &body_ptr, 2); + srsran_bit_unpack(msg->pmi, &body_ptr, 2); bit_count += 2; } } @@ -65,35 +65,35 @@ static int cqi_hl_subband_pack(srslte_cqi_cfg_t* cfg, srslte_cqi_hl_subband_t* m return bit_count; } -static int cqi_ue_subband_pack(srslte_cqi_cfg_t* cfg, srslte_cqi_ue_subband_t* msg, uint8_t* buff) +static int cqi_ue_subband_pack(srsran_cqi_cfg_t* cfg, srsran_cqi_ue_subband_t* msg, uint8_t* buff) { uint8_t* body_ptr = buff; - srslte_bit_unpack(msg->wideband_cqi, &body_ptr, 4); - srslte_bit_unpack(msg->subband_diff_cqi, &body_ptr, 2); - srslte_bit_unpack(msg->subband_diff_cqi, &body_ptr, cfg->L); + srsran_bit_unpack(msg->wideband_cqi, &body_ptr, 4); + srsran_bit_unpack(msg->subband_diff_cqi, &body_ptr, 2); + srsran_bit_unpack(msg->subband_diff_cqi, &body_ptr, cfg->L); return 4 + 2 + cfg->L; } /* Pack CQI following 3GPP TS 36.212 Tables 5.2.3.3.1-1 and 5.2.3.3.1-2 */ -static int cqi_format2_wideband_pack(srslte_cqi_cfg_t* cfg, srslte_cqi_format2_wideband_t* msg, uint8_t* buff) +static int cqi_format2_wideband_pack(srsran_cqi_cfg_t* cfg, srsran_cqi_format2_wideband_t* msg, uint8_t* buff) { uint8_t* body_ptr = buff; - srslte_bit_unpack(msg->wideband_cqi, &body_ptr, 4); + srsran_bit_unpack(msg->wideband_cqi, &body_ptr, 4); if (cfg->pmi_present) { if (cfg->four_antenna_ports) { if (cfg->rank_is_not_one) { - srslte_bit_unpack(msg->spatial_diff_cqi, &body_ptr, 3); + srsran_bit_unpack(msg->spatial_diff_cqi, &body_ptr, 3); } - srslte_bit_unpack(msg->pmi, &body_ptr, 4); + srsran_bit_unpack(msg->pmi, &body_ptr, 4); } else { if (cfg->rank_is_not_one) { - srslte_bit_unpack(msg->spatial_diff_cqi, &body_ptr, 3); - srslte_bit_unpack(msg->pmi, &body_ptr, 1); + srsran_bit_unpack(msg->spatial_diff_cqi, &body_ptr, 3); + srsran_bit_unpack(msg->pmi, &body_ptr, 1); } else { - srslte_bit_unpack(msg->pmi, &body_ptr, 2); + srsran_bit_unpack(msg->pmi, &body_ptr, 2); } } } @@ -101,24 +101,24 @@ static int cqi_format2_wideband_pack(srslte_cqi_cfg_t* cfg, srslte_cqi_format2_w return (int)(body_ptr - buff); } -static int cqi_format2_subband_pack(srslte_cqi_cfg_t* cfg, srslte_cqi_format2_subband_t* msg, uint8_t* buff) +static int cqi_format2_subband_pack(srsran_cqi_cfg_t* cfg, srsran_cqi_format2_subband_t* msg, uint8_t* buff) { uint8_t* body_ptr = buff; - srslte_bit_unpack(msg->subband_cqi, &body_ptr, 4); - srslte_bit_unpack(msg->subband_label, &body_ptr, cfg->subband_label_2_bits ? 2 : 1); + srsran_bit_unpack(msg->subband_cqi, &body_ptr, 4); + srsran_bit_unpack(msg->subband_label, &body_ptr, cfg->subband_label_2_bits ? 2 : 1); return 4 + ((cfg->subband_label_2_bits) ? 2 : 1); } -int srslte_cqi_value_pack(srslte_cqi_cfg_t* cfg, srslte_cqi_value_t* value, uint8_t buff[SRSLTE_CQI_MAX_BITS]) +int srsran_cqi_value_pack(srsran_cqi_cfg_t* cfg, srsran_cqi_value_t* value, uint8_t buff[SRSRAN_CQI_MAX_BITS]) { switch (cfg->type) { - case SRSLTE_CQI_TYPE_WIDEBAND: + case SRSRAN_CQI_TYPE_WIDEBAND: return cqi_format2_wideband_pack(cfg, &value->wideband, buff); - case SRSLTE_CQI_TYPE_SUBBAND: + case SRSRAN_CQI_TYPE_SUBBAND: return cqi_format2_subband_pack(cfg, &value->subband, buff); - case SRSLTE_CQI_TYPE_SUBBAND_UE: + case SRSRAN_CQI_TYPE_SUBBAND_UE: return cqi_ue_subband_pack(cfg, &value->subband_ue, buff); - case SRSLTE_CQI_TYPE_SUBBAND_HL: + case SRSRAN_CQI_TYPE_SUBBAND_HL: return cqi_hl_subband_pack(cfg, &value->subband_hl, buff); } return -1; @@ -128,33 +128,33 @@ int srslte_cqi_value_pack(srslte_cqi_cfg_t* cfg, srslte_cqi_value_t* value, uint * UNPACKING FUNCTIONS * *******************************************************/ -int cqi_hl_subband_unpack(srslte_cqi_cfg_t* cfg, uint8_t* buff, srslte_cqi_hl_subband_t* msg) +int cqi_hl_subband_unpack(srsran_cqi_cfg_t* cfg, uint8_t* buff, srsran_cqi_hl_subband_t* msg) { uint8_t* body_ptr = buff; uint32_t bit_count = 0; - msg->wideband_cqi_cw0 = (uint8_t)srslte_bit_pack(&body_ptr, 4); - msg->subband_diff_cqi_cw0 = srslte_bit_pack(&body_ptr, 2 * cfg->N); + msg->wideband_cqi_cw0 = (uint8_t)srsran_bit_pack(&body_ptr, 4); + msg->subband_diff_cqi_cw0 = srsran_bit_pack(&body_ptr, 2 * cfg->N); bit_count += 4 + 2 * cfg->N; /* Unpack codeword 1, 3GPP 36.212 Table 5.2.2.6.2-2 */ if (cfg->rank_is_not_one) { - msg->wideband_cqi_cw1 = (uint8_t)srslte_bit_pack(&body_ptr, 4); - msg->subband_diff_cqi_cw1 = srslte_bit_pack(&body_ptr, 2 * cfg->N); + msg->wideband_cqi_cw1 = (uint8_t)srsran_bit_pack(&body_ptr, 4); + msg->subband_diff_cqi_cw1 = srsran_bit_pack(&body_ptr, 2 * cfg->N); bit_count += 4 + 2 * cfg->N; } /* If PMI is present, unpack it */ if (cfg->pmi_present) { if (cfg->four_antenna_ports) { - msg->pmi = (uint8_t)srslte_bit_pack(&body_ptr, 4); + msg->pmi = (uint8_t)srsran_bit_pack(&body_ptr, 4); bit_count += 4; } else { if (cfg->rank_is_not_one) { - msg->pmi = (uint8_t)srslte_bit_pack(&body_ptr, 1); + msg->pmi = (uint8_t)srsran_bit_pack(&body_ptr, 1); bit_count += 1; } else { - msg->pmi = (uint8_t)srslte_bit_pack(&body_ptr, 2); + msg->pmi = (uint8_t)srsran_bit_pack(&body_ptr, 2); bit_count += 2; } } @@ -163,58 +163,58 @@ int cqi_hl_subband_unpack(srslte_cqi_cfg_t* cfg, uint8_t* buff, srslte_cqi_hl_su return bit_count; } -int cqi_ue_subband_unpack(srslte_cqi_cfg_t* cfg, uint8_t* buff, srslte_cqi_ue_subband_t* msg) +int cqi_ue_subband_unpack(srsran_cqi_cfg_t* cfg, uint8_t* buff, srsran_cqi_ue_subband_t* msg) { uint8_t* body_ptr = buff; - msg->wideband_cqi = srslte_bit_pack(&body_ptr, 4); - msg->subband_diff_cqi = srslte_bit_pack(&body_ptr, 2); - msg->subband_diff_cqi = srslte_bit_pack(&body_ptr, cfg->L); + msg->wideband_cqi = srsran_bit_pack(&body_ptr, 4); + msg->subband_diff_cqi = srsran_bit_pack(&body_ptr, 2); + msg->subband_diff_cqi = srsran_bit_pack(&body_ptr, cfg->L); return 4 + 2 + cfg->L; } /* Unpack CQI following 3GPP TS 36.212 Tables 5.2.3.3.1-1 and 5.2.3.3.1-2 */ -static int cqi_format2_wideband_unpack(srslte_cqi_cfg_t* cfg, uint8_t* buff, srslte_cqi_format2_wideband_t* msg) +static int cqi_format2_wideband_unpack(srsran_cqi_cfg_t* cfg, uint8_t* buff, srsran_cqi_format2_wideband_t* msg) { uint8_t* body_ptr = buff; - msg->wideband_cqi = (uint8_t)srslte_bit_pack(&body_ptr, 4); + msg->wideband_cqi = (uint8_t)srsran_bit_pack(&body_ptr, 4); if (cfg->pmi_present) { if (cfg->four_antenna_ports) { if (cfg->rank_is_not_one) { - msg->spatial_diff_cqi = (uint8_t)srslte_bit_pack(&body_ptr, 3); + msg->spatial_diff_cqi = (uint8_t)srsran_bit_pack(&body_ptr, 3); } - msg->pmi = (uint8_t)srslte_bit_pack(&body_ptr, 4); + msg->pmi = (uint8_t)srsran_bit_pack(&body_ptr, 4); } else { if (cfg->rank_is_not_one) { - msg->spatial_diff_cqi = (uint8_t)srslte_bit_pack(&body_ptr, 3); - msg->pmi = (uint8_t)srslte_bit_pack(&body_ptr, 1); + msg->spatial_diff_cqi = (uint8_t)srsran_bit_pack(&body_ptr, 3); + msg->pmi = (uint8_t)srsran_bit_pack(&body_ptr, 1); } else { - msg->pmi = (uint8_t)srslte_bit_pack(&body_ptr, 2); + msg->pmi = (uint8_t)srsran_bit_pack(&body_ptr, 2); } } } return 4; } -static int cqi_format2_subband_unpack(srslte_cqi_cfg_t* cfg, uint8_t* buff, srslte_cqi_format2_subband_t* msg) +static int cqi_format2_subband_unpack(srsran_cqi_cfg_t* cfg, uint8_t* buff, srsran_cqi_format2_subband_t* msg) { uint8_t* body_ptr = buff; - msg->subband_cqi = srslte_bit_pack(&body_ptr, 4); - msg->subband_label = srslte_bit_pack(&body_ptr, cfg->subband_label_2_bits ? 2 : 1); + msg->subband_cqi = srsran_bit_pack(&body_ptr, 4); + msg->subband_label = srsran_bit_pack(&body_ptr, cfg->subband_label_2_bits ? 2 : 1); return 4 + ((cfg->subband_label_2_bits) ? 2 : 1); } -int srslte_cqi_value_unpack(srslte_cqi_cfg_t* cfg, uint8_t buff[SRSLTE_CQI_MAX_BITS], srslte_cqi_value_t* value) +int srsran_cqi_value_unpack(srsran_cqi_cfg_t* cfg, uint8_t buff[SRSRAN_CQI_MAX_BITS], srsran_cqi_value_t* value) { switch (cfg->type) { - case SRSLTE_CQI_TYPE_WIDEBAND: + case SRSRAN_CQI_TYPE_WIDEBAND: return cqi_format2_wideband_unpack(cfg, buff, &value->wideband); - case SRSLTE_CQI_TYPE_SUBBAND: + case SRSRAN_CQI_TYPE_SUBBAND: return cqi_format2_subband_unpack(cfg, buff, &value->subband); - case SRSLTE_CQI_TYPE_SUBBAND_UE: + case SRSRAN_CQI_TYPE_SUBBAND_UE: return cqi_ue_subband_unpack(cfg, buff, &value->subband_ue); - case SRSLTE_CQI_TYPE_SUBBAND_HL: + case SRSRAN_CQI_TYPE_SUBBAND_HL: return cqi_hl_subband_unpack(cfg, buff, &value->subband_hl); } return -1; @@ -225,7 +225,7 @@ int srslte_cqi_value_unpack(srslte_cqi_cfg_t* cfg, uint8_t buff[SRSLTE_CQI_MAX_B *******************************************************/ static int -cqi_format2_wideband_tostring(srslte_cqi_cfg_t* cfg, srslte_cqi_format2_wideband_t* msg, char* buff, uint32_t buff_len) +cqi_format2_wideband_tostring(srsran_cqi_cfg_t* cfg, srsran_cqi_format2_wideband_t* msg, char* buff, uint32_t buff_len) { int n = 0; @@ -242,7 +242,7 @@ cqi_format2_wideband_tostring(srslte_cqi_cfg_t* cfg, srslte_cqi_format2_wideband } static int -cqi_format2_subband_tostring(srslte_cqi_cfg_t* cfg, srslte_cqi_format2_subband_t* msg, char* buff, uint32_t buff_len) +cqi_format2_subband_tostring(srsran_cqi_cfg_t* cfg, srsran_cqi_format2_subband_t* msg, char* buff, uint32_t buff_len) { int n = 0; @@ -252,7 +252,7 @@ cqi_format2_subband_tostring(srslte_cqi_cfg_t* cfg, srslte_cqi_format2_subband_t return n; } -static int cqi_ue_subband_tostring(srslte_cqi_cfg_t* cfg, srslte_cqi_ue_subband_t* msg, char* buff, uint32_t buff_len) +static int cqi_ue_subband_tostring(srsran_cqi_cfg_t* cfg, srsran_cqi_ue_subband_t* msg, char* buff, uint32_t buff_len) { int n = 0; @@ -263,7 +263,7 @@ static int cqi_ue_subband_tostring(srslte_cqi_cfg_t* cfg, srslte_cqi_ue_subband_ return n; } -static int cqi_hl_subband_tostring(srslte_cqi_cfg_t* cfg, srslte_cqi_hl_subband_t* msg, char* buff, uint32_t buff_len) +static int cqi_hl_subband_tostring(srsran_cqi_cfg_t* cfg, srsran_cqi_hl_subband_t* msg, char* buff, uint32_t buff_len) { int n = 0; @@ -284,21 +284,21 @@ static int cqi_hl_subband_tostring(srslte_cqi_cfg_t* cfg, srslte_cqi_hl_subband_ return n; } -int srslte_cqi_value_tostring(srslte_cqi_cfg_t* cfg, srslte_cqi_value_t* value, char* buff, uint32_t buff_len) +int srsran_cqi_value_tostring(srsran_cqi_cfg_t* cfg, srsran_cqi_value_t* value, char* buff, uint32_t buff_len) { int ret = -1; switch (cfg->type) { - case SRSLTE_CQI_TYPE_WIDEBAND: + case SRSRAN_CQI_TYPE_WIDEBAND: ret = cqi_format2_wideband_tostring(cfg, &value->wideband, buff, buff_len); break; - case SRSLTE_CQI_TYPE_SUBBAND: + case SRSRAN_CQI_TYPE_SUBBAND: ret = cqi_format2_subband_tostring(cfg, &value->subband, buff, buff_len); break; - case SRSLTE_CQI_TYPE_SUBBAND_UE: + case SRSRAN_CQI_TYPE_SUBBAND_UE: ret = cqi_ue_subband_tostring(cfg, &value->subband_ue, buff, buff_len); break; - case SRSLTE_CQI_TYPE_SUBBAND_HL: + case SRSRAN_CQI_TYPE_SUBBAND_HL: ret = cqi_hl_subband_tostring(cfg, &value->subband_hl, buff, buff_len); break; default: @@ -308,7 +308,7 @@ int srslte_cqi_value_tostring(srslte_cqi_cfg_t* cfg, srslte_cqi_value_t* value, return ret; } -int srslte_cqi_size(srslte_cqi_cfg_t* cfg) +int srsran_cqi_size(srsran_cqi_cfg_t* cfg) { int size = 0; @@ -317,7 +317,7 @@ int srslte_cqi_size(srslte_cqi_cfg_t* cfg) } switch (cfg->type) { - case SRSLTE_CQI_TYPE_WIDEBAND: + case SRSRAN_CQI_TYPE_WIDEBAND: /* Compute size according to 3GPP TS 36.212 Tables 5.2.3.3.1-1 and 5.2.3.3.1-2 */ size = 4; if (cfg->pmi_present) { @@ -339,13 +339,13 @@ int srslte_cqi_size(srslte_cqi_cfg_t* cfg) } } break; - case SRSLTE_CQI_TYPE_SUBBAND: + case SRSRAN_CQI_TYPE_SUBBAND: size = 4 + ((cfg->subband_label_2_bits) ? 2 : 1); break; - case SRSLTE_CQI_TYPE_SUBBAND_UE: + case SRSRAN_CQI_TYPE_SUBBAND_UE: size = 4 + 2 + cfg->L; break; - case SRSLTE_CQI_TYPE_SUBBAND_HL: + case SRSRAN_CQI_TYPE_SUBBAND_HL: /* First codeword */ size += 4 + 2 * cfg->N; @@ -368,7 +368,7 @@ int srslte_cqi_size(srslte_cqi_cfg_t* cfg) } break; default: - size = SRSLTE_ERROR; + size = SRSRAN_ERROR; } return size; } @@ -517,15 +517,15 @@ static bool ri_send(uint32_t I_cqi_pmi, uint32_t I_ri, uint32_t tti, bool is_fdd return false; } -bool srslte_cqi_periodic_ri_send(const srslte_cqi_report_cfg_t* cfg, uint32_t tti, srslte_frame_type_t frame_type) +bool srsran_cqi_periodic_ri_send(const srsran_cqi_report_cfg_t* cfg, uint32_t tti, srsran_frame_type_t frame_type) { return cfg->periodic_configured && cfg->ri_idx_present && - ri_send(cfg->pmi_idx, cfg->ri_idx, tti, frame_type == SRSLTE_FDD); + ri_send(cfg->pmi_idx, cfg->ri_idx, tti, frame_type == SRSRAN_FDD); } -bool srslte_cqi_periodic_send(const srslte_cqi_report_cfg_t* cfg, uint32_t tti, srslte_frame_type_t frame_type) +bool srsran_cqi_periodic_send(const srsran_cqi_report_cfg_t* cfg, uint32_t tti, srsran_frame_type_t frame_type) { - return cfg->periodic_configured && cqi_send(cfg->pmi_idx, tti, frame_type == SRSLTE_FDD); + return cfg->periodic_configured && cqi_send(cfg->pmi_idx, tti, frame_type == SRSRAN_FDD); } // CQI-to-Spectral Efficiency: 36.213 Table 7.2.3-1 @@ -564,7 +564,7 @@ static float cqi_to_coderate_table2[16] = {0, 6.9141, 7.4063}; -float srslte_cqi_to_coderate(uint32_t cqi, bool use_alt_table) +float srsran_cqi_to_coderate(uint32_t cqi, bool use_alt_table) { if (cqi < 16) { return use_alt_table ? cqi_to_coderate_table2[cqi] : cqi_to_coderate[cqi]; @@ -582,7 +582,7 @@ static float cqi_to_snr_table[15] = {1.95, 4, 6, 8, 10, 11.95, 14.05, 16, 17.9, // From experimental measurements @ 5 MHz // static float cqi_to_snr_table[15] = { 1, 1.75, 3, 4, 5, 6, 7.5, 9, 11.5, 13.0, 15.0, 18, 20, 22.5, 26.5}; -uint8_t srslte_cqi_from_snr(float snr) +uint8_t srsran_cqi_from_snr(float snr) { for (int cqi = 14; cqi >= 0; cqi--) { if (snr >= cqi_to_snr_table[cqi]) { @@ -614,7 +614,7 @@ static int cqi_hl_get_subband_size(int nof_prb) /* Returns the number of subbands to be reported in CQI measurements as * defined in clause 7.2 in TS 36.213, i.e., the N parameter */ -int srslte_cqi_hl_get_no_subbands(int nof_prb) +int srsran_cqi_hl_get_no_subbands(int nof_prb) { int hl_size = cqi_hl_get_subband_size(nof_prb); if (hl_size > 0) { @@ -624,7 +624,7 @@ int srslte_cqi_hl_get_no_subbands(int nof_prb) } } -void srslte_cqi_to_str(const uint8_t* cqi_value, int cqi_len, char* str, int str_len) +void srsran_cqi_to_str(const uint8_t* cqi_value, int cqi_len, char* str, int str_len) { int i = 0; diff --git a/lib/src/phy/phch/csi.c b/lib/src/phy/phch/csi.c index 1d5519d89..8c6dff16a 100644 --- a/lib/src/phy/phch/csi.c +++ b/lib/src/phy/phch/csi.c @@ -2,43 +2,43 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of * the distribution. * */ -#include "srslte/phy/phch/csi.h" -#include "srslte/phy/utils/bit.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/phch/csi.h" +#include "srsran/phy/utils/bit.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" #include #define CSI_WIDEBAND_CSI_NOF_BITS 4 /// Implements SNRI to CQI conversion -uint32_t csi_snri_db_to_cqi(srslte_csi_cqi_table_t table, float snri_db) +uint32_t csi_snri_db_to_cqi(srsran_csi_cqi_table_t table, float snri_db) { return 6; } // Implements CSI report triggers -static bool csi_report_trigger(const srslte_csi_hl_report_cfg_t* cfg, uint32_t slot_idx) +static bool csi_report_trigger(const srsran_csi_hl_report_cfg_t* cfg, uint32_t slot_idx) { switch (cfg->type) { - case SRSLTE_CSI_REPORT_TYPE_PERIODIC: + case SRSRAN_CSI_REPORT_TYPE_PERIODIC: return (slot_idx + cfg->periodic.period - cfg->periodic.offset) % cfg->periodic.period == 0; default:; // Do nothing } return false; } -static void csi_wideband_cri_ri_pmi_cqi_quantify(const srslte_csi_hl_report_cfg_t* cfg, - const srslte_csi_measurements_t* channel_meas, - const srslte_csi_measurements_t* interf_meas, - srslte_csi_report_cfg_t* report_cfg, - srslte_csi_report_value_t* report_value) +static void csi_wideband_cri_ri_pmi_cqi_quantify(const srsran_csi_hl_report_cfg_t* cfg, + const srsran_csi_measurements_t* channel_meas, + const srsran_csi_measurements_t* interf_meas, + srsran_csi_report_cfg_t* report_cfg, + srsran_csi_report_value_t* report_value) { // Take SNR by default float wideband_sinr_db = channel_meas->wideband_snr_db; @@ -50,13 +50,13 @@ static void csi_wideband_cri_ri_pmi_cqi_quantify(const srslte_csi_hl_report_cfg_ // Fill report configuration report_cfg->type = cfg->type; - report_cfg->quantity = SRSLTE_CSI_REPORT_QUANTITY_CRI_RI_PMI_CQI; - report_cfg->freq_cfg = SRSLTE_CSI_REPORT_FREQ_WIDEBAND; + report_cfg->quantity = SRSRAN_CSI_REPORT_QUANTITY_CRI_RI_PMI_CQI; + report_cfg->freq_cfg = SRSRAN_CSI_REPORT_FREQ_WIDEBAND; report_cfg->nof_ports = channel_meas->nof_ports; report_cfg->K_csi_rs = channel_meas->K_csi_rs; // Save PUCCH resource only if periodic type - if (cfg->type == SRSLTE_CSI_REPORT_TYPE_PERIODIC) { + if (cfg->type == SRSRAN_CSI_REPORT_TYPE_PERIODIC) { report_cfg->pucch_resource = cfg->periodic.resource; } @@ -66,7 +66,7 @@ static void csi_wideband_cri_ri_pmi_cqi_quantify(const srslte_csi_hl_report_cfg_ report_value->wideband_cri_ri_pmi_cqi.pmi = 0; } -static uint32_t csi_wideband_cri_ri_pmi_cqi_nof_bits(const srslte_csi_report_cfg_t* cfg) +static uint32_t csi_wideband_cri_ri_pmi_cqi_nof_bits(const srsran_csi_report_cfg_t* cfg) { // Compute number of bits for CRI uint32_t nof_bits_cri = 0; @@ -83,8 +83,8 @@ static uint32_t csi_wideband_cri_ri_pmi_cqi_nof_bits(const srslte_csi_report_cfg return 0; } -static uint32_t csi_wideband_cri_ri_pmi_cqi_pack(const srslte_csi_report_cfg_t* cfg, - const srslte_csi_report_value_t* value, +static uint32_t csi_wideband_cri_ri_pmi_cqi_pack(const srsran_csi_report_cfg_t* cfg, + const srsran_csi_report_value_t* value, uint8_t* o_csi1) { // Compute number of bits for CRI @@ -94,17 +94,17 @@ static uint32_t csi_wideband_cri_ri_pmi_cqi_pack(const srslte_csi_report_cfg_t* } // Write wideband CQI - srslte_bit_unpack(value->wideband_cri_ri_pmi_cqi.cqi, &o_csi1, CSI_WIDEBAND_CSI_NOF_BITS); + srsran_bit_unpack(value->wideband_cri_ri_pmi_cqi.cqi, &o_csi1, CSI_WIDEBAND_CSI_NOF_BITS); // Compute number of bits for CRI and write - srslte_bit_unpack(value->cri, &o_csi1, nof_bits_cri); + srsran_bit_unpack(value->cri, &o_csi1, nof_bits_cri); return nof_bits_cri + CSI_WIDEBAND_CSI_NOF_BITS; } -static uint32_t csi_wideband_cri_ri_pmi_cqi_unpack(const srslte_csi_report_cfg_t* cfg, +static uint32_t csi_wideband_cri_ri_pmi_cqi_unpack(const srsran_csi_report_cfg_t* cfg, uint8_t* o_csi1, - srslte_csi_report_value_t* value) + srsran_csi_report_value_t* value) { // Compute number of bits for CRI uint32_t nof_bits_cri = 0; @@ -113,75 +113,75 @@ static uint32_t csi_wideband_cri_ri_pmi_cqi_unpack(const srslte_csi_report_cfg_t } // Write wideband CQI - value->wideband_cri_ri_pmi_cqi.cqi = srslte_bit_pack(&o_csi1, CSI_WIDEBAND_CSI_NOF_BITS); + value->wideband_cri_ri_pmi_cqi.cqi = srsran_bit_pack(&o_csi1, CSI_WIDEBAND_CSI_NOF_BITS); // Compute number of bits for CRI and write - value->cri = srslte_bit_pack(&o_csi1, nof_bits_cri); + value->cri = srsran_bit_pack(&o_csi1, nof_bits_cri); return nof_bits_cri + CSI_WIDEBAND_CSI_NOF_BITS; } -static uint32_t csi_none_nof_bits(const srslte_csi_report_cfg_t* cfg) +static uint32_t csi_none_nof_bits(const srsran_csi_report_cfg_t* cfg) { return cfg->K_csi_rs; } static uint32_t -csi_none_pack(const srslte_csi_report_cfg_t* cfg, const srslte_csi_report_value_t* value, uint8_t* o_csi1) +csi_none_pack(const srsran_csi_report_cfg_t* cfg, const srsran_csi_report_value_t* value, uint8_t* o_csi1) { - srslte_vec_u8_copy(o_csi1, (uint8_t*)value->none, cfg->K_csi_rs); + srsran_vec_u8_copy(o_csi1, (uint8_t*)value->none, cfg->K_csi_rs); return cfg->K_csi_rs; } static uint32_t -csi_none_unpack(const srslte_csi_report_cfg_t* cfg, const uint8_t* o_csi1, srslte_csi_report_value_t* value) +csi_none_unpack(const srsran_csi_report_cfg_t* cfg, const uint8_t* o_csi1, srsran_csi_report_value_t* value) { - srslte_vec_u8_copy((uint8_t*)value->none, o_csi1, cfg->K_csi_rs); + srsran_vec_u8_copy((uint8_t*)value->none, o_csi1, cfg->K_csi_rs); return cfg->K_csi_rs; } -int srslte_csi_generate_reports(const srslte_csi_hl_cfg_t* cfg, +int srsran_csi_generate_reports(const srsran_csi_hl_cfg_t* cfg, uint32_t slot_idx, - const srslte_csi_measurements_t measurements[SRSLTE_CSI_MAX_NOF_RESOURCES], - srslte_csi_report_cfg_t report_cfg[SRSLTE_CSI_MAX_NOF_REPORT], - srslte_csi_report_value_t report_value[SRSLTE_CSI_MAX_NOF_REPORT]) + const srsran_csi_measurements_t measurements[SRSRAN_CSI_MAX_NOF_RESOURCES], + srsran_csi_report_cfg_t report_cfg[SRSRAN_CSI_MAX_NOF_REPORT], + srsran_csi_report_value_t report_value[SRSRAN_CSI_MAX_NOF_REPORT]) { uint32_t count = 0; // Check inputs if (cfg == NULL || measurements == NULL || report_cfg == NULL || report_value == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } // Iterate every possible configured CSI report - for (uint32_t i = 0; i < SRSLTE_CSI_MAX_NOF_REPORT; i++) { + for (uint32_t i = 0; i < SRSRAN_CSI_MAX_NOF_REPORT; i++) { // Skip if report is not configured or triggered if (!csi_report_trigger(&cfg->reports[i], slot_idx)) { continue; } // Select channel measurement - if (cfg->reports->channel_meas_id >= SRSLTE_CSI_MAX_NOF_RESOURCES) { + if (cfg->reports->channel_meas_id >= SRSRAN_CSI_MAX_NOF_RESOURCES) { ERROR("Channel measurement ID (%d) is out of range", cfg->reports->channel_meas_id); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - const srslte_csi_measurements_t* channel_meas = &measurements[cfg->reports->channel_meas_id]; + const srsran_csi_measurements_t* channel_meas = &measurements[cfg->reports->channel_meas_id]; // Select interference measurement - const srslte_csi_measurements_t* interf_meas = NULL; + const srsran_csi_measurements_t* interf_meas = NULL; if (cfg->reports->interf_meas_present) { - if (cfg->reports->interf_meas_id >= SRSLTE_CSI_MAX_NOF_RESOURCES) { + if (cfg->reports->interf_meas_id >= SRSRAN_CSI_MAX_NOF_RESOURCES) { ERROR("Interference measurement ID (%d) is out of range", cfg->reports->interf_meas_id); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } interf_meas = &measurements[cfg->reports->interf_meas_id]; } // Quantify measurements according to frequency and quantity configuration - if (cfg->reports->freq_cfg == SRSLTE_CSI_REPORT_FREQ_WIDEBAND && - cfg->reports->quantity == SRSLTE_CSI_REPORT_QUANTITY_CRI_RI_PMI_CQI) { + if (cfg->reports->freq_cfg == SRSRAN_CSI_REPORT_FREQ_WIDEBAND && + cfg->reports->quantity == SRSRAN_CSI_REPORT_QUANTITY_CRI_RI_PMI_CQI) { csi_wideband_cri_ri_pmi_cqi_quantify( &cfg->reports[i], channel_meas, interf_meas, &report_cfg[count], &report_value[count]); count++; @@ -193,21 +193,21 @@ int srslte_csi_generate_reports(const srslte_csi_hl_cfg_t* cfg, return (int)count; } -int srslte_csi_part1_nof_bits(const srslte_csi_report_cfg_t* report_list, uint32_t nof_reports) +int srsran_csi_part1_nof_bits(const srsran_csi_report_cfg_t* report_list, uint32_t nof_reports) { uint32_t count = 0; // Check input pointer if (report_list == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } // Iterate all report configurations for (uint32_t i = 0; i < nof_reports; i++) { - const srslte_csi_report_cfg_t* report = &report_list[i]; - if (report->quantity && report->quantity == SRSLTE_CSI_REPORT_QUANTITY_CRI_RI_PMI_CQI) { + const srsran_csi_report_cfg_t* report = &report_list[i]; + if (report->quantity && report->quantity == SRSRAN_CSI_REPORT_QUANTITY_CRI_RI_PMI_CQI) { count += csi_wideband_cri_ri_pmi_cqi_nof_bits(report); - } else if (report->quantity == SRSLTE_CSI_REPORT_QUANTITY_NONE) { + } else if (report->quantity == SRSRAN_CSI_REPORT_QUANTITY_NONE) { count += csi_none_nof_bits(report); } } @@ -215,7 +215,7 @@ int srslte_csi_part1_nof_bits(const srslte_csi_report_cfg_t* report_list, uint32 return (int)count; } -bool srslte_csi_has_part2(const srslte_csi_report_cfg_t* report_list, uint32_t nof_reports) +bool srsran_csi_has_part2(const srsran_csi_report_cfg_t* report_list, uint32_t nof_reports) { if (report_list == NULL || nof_reports == 0) { return false; @@ -229,8 +229,8 @@ bool srslte_csi_has_part2(const srslte_csi_report_cfg_t* report_list, uint32_t n return false; } -int srslte_csi_part1_pack(const srslte_csi_report_cfg_t* report_cfg, - const srslte_csi_report_value_t* report_value, +int srsran_csi_part1_pack(const srsran_csi_report_cfg_t* report_cfg, + const srsran_csi_report_value_t* report_value, uint32_t nof_reports, uint8_t* o_csi1, uint32_t max_o_csi1) @@ -238,20 +238,20 @@ int srslte_csi_part1_pack(const srslte_csi_report_cfg_t* report_cfg, uint32_t count = 0; if (report_cfg == NULL || report_value == NULL || o_csi1 == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } - int n = srslte_csi_part1_nof_bits(report_cfg, nof_reports); + int n = srsran_csi_part1_nof_bits(report_cfg, nof_reports); if (n > (int)max_o_csi1) { ERROR("The maximum number of CSI bits (%d) is not enough to accommodate %d bits", max_o_csi1, n); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } for (uint32_t i = 0; i < nof_reports && count < max_o_csi1; i++) { - if (report_cfg[i].freq_cfg == SRSLTE_CSI_REPORT_FREQ_WIDEBAND && - report_cfg[i].quantity == SRSLTE_CSI_REPORT_QUANTITY_CRI_RI_PMI_CQI) { + if (report_cfg[i].freq_cfg == SRSRAN_CSI_REPORT_FREQ_WIDEBAND && + report_cfg[i].quantity == SRSRAN_CSI_REPORT_QUANTITY_CRI_RI_PMI_CQI) { count += csi_wideband_cri_ri_pmi_cqi_pack(&report_cfg[i], &report_value[i], &o_csi1[count]); - } else if (report_cfg[i].quantity == SRSLTE_CSI_REPORT_QUANTITY_NONE) { + } else if (report_cfg[i].quantity == SRSRAN_CSI_REPORT_QUANTITY_NONE) { count += csi_none_pack(&report_cfg[i], &report_value[i], &o_csi1[count]); } else { ERROR("CSI frequency (%d) and quantity (%d) combination is not implemented", @@ -263,29 +263,29 @@ int srslte_csi_part1_pack(const srslte_csi_report_cfg_t* report_cfg, return (int)count; } -int srslte_csi_part1_unpack(const srslte_csi_report_cfg_t* report_cfg, +int srsran_csi_part1_unpack(const srsran_csi_report_cfg_t* report_cfg, uint32_t nof_reports, uint8_t* o_csi1, uint32_t max_o_csi1, - srslte_csi_report_value_t* report_value) + srsran_csi_report_value_t* report_value) { uint32_t count = 0; if (report_cfg == NULL || report_value == NULL || o_csi1 == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } - int n = srslte_csi_part1_nof_bits(report_cfg, nof_reports); + int n = srsran_csi_part1_nof_bits(report_cfg, nof_reports); if (n > (int)max_o_csi1) { ERROR("The maximum number of CSI bits (%d) is not enough to accommodate %d bits", max_o_csi1, n); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } for (uint32_t i = 0; i < nof_reports && count < max_o_csi1; i++) { - if (report_cfg[i].freq_cfg == SRSLTE_CSI_REPORT_FREQ_WIDEBAND && - report_cfg[i].quantity == SRSLTE_CSI_REPORT_QUANTITY_CRI_RI_PMI_CQI) { + if (report_cfg[i].freq_cfg == SRSRAN_CSI_REPORT_FREQ_WIDEBAND && + report_cfg[i].quantity == SRSRAN_CSI_REPORT_QUANTITY_CRI_RI_PMI_CQI) { count += csi_wideband_cri_ri_pmi_cqi_unpack(&report_cfg[i], &o_csi1[count], &report_value[i]); - } else if (report_cfg[i].quantity == SRSLTE_CSI_REPORT_QUANTITY_NONE) { + } else if (report_cfg[i].quantity == SRSRAN_CSI_REPORT_QUANTITY_NONE) { count += csi_none_unpack(&report_cfg[i], &o_csi1[count], &report_value[i]); } else { ERROR("CSI frequency (%d) and quantity (%d) combination is not implemented", @@ -297,21 +297,21 @@ int srslte_csi_part1_unpack(const srslte_csi_report_cfg_t* report_cfg, return (int)count; } -uint32_t srslte_csi_str(const srslte_csi_report_cfg_t* report_cfg, - const srslte_csi_report_value_t* report_value, +uint32_t srsran_csi_str(const srsran_csi_report_cfg_t* report_cfg, + const srsran_csi_report_value_t* report_value, uint32_t nof_reports, char* str, uint32_t str_len) { uint32_t len = 0; for (uint32_t i = 0; i < nof_reports; i++) { - if (report_cfg[i].freq_cfg == SRSLTE_CSI_REPORT_FREQ_WIDEBAND && - report_cfg[i].quantity == SRSLTE_CSI_REPORT_QUANTITY_CRI_RI_PMI_CQI) { - len = srslte_print_check(str, str_len, len, ", cqi=%d", report_value[i].wideband_cri_ri_pmi_cqi.cqi); - } else if (report_cfg[i].quantity == SRSLTE_CSI_REPORT_QUANTITY_NONE) { + if (report_cfg[i].freq_cfg == SRSRAN_CSI_REPORT_FREQ_WIDEBAND && + report_cfg[i].quantity == SRSRAN_CSI_REPORT_QUANTITY_CRI_RI_PMI_CQI) { + len = srsran_print_check(str, str_len, len, ", cqi=%d", report_value[i].wideband_cri_ri_pmi_cqi.cqi); + } else if (report_cfg[i].quantity == SRSRAN_CSI_REPORT_QUANTITY_NONE) { char tmp[20] = {}; - srslte_vec_sprint_bin(tmp, sizeof(tmp), report_value[i].none, report_cfg->K_csi_rs); - len = srslte_print_check(str, str_len, len, ", csi=%s", tmp); + srsran_vec_sprint_bin(tmp, sizeof(tmp), report_value[i].none, report_cfg->K_csi_rs); + len = srsran_print_check(str, str_len, len, ", csi=%s", tmp); } } return len; diff --git a/lib/src/phy/phch/dci.c b/lib/src/phy/phch/dci.c index 1c8553c81..e672d21a2 100644 --- a/lib/src/phy/phch/dci.c +++ b/lib/src/phy/phch/dci.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -19,49 +19,49 @@ #include #include -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/phch/dci.h" -#include "srslte/phy/utils/bit.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" -#include "srslte/srslte.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/phch/dci.h" +#include "srsran/phy/utils/bit.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" +#include "srsran/srsran.h" -#define IS_TDD (cell->frame_type == SRSLTE_TDD) +#define IS_TDD (cell->frame_type == SRSRAN_TDD) #define IS_TDD_CFG0 (IS_TDD && (sf->tdd_config.sf_config == 0)) #define HARQ_PID_LEN ((IS_TDD | IS_TDD_CFG0) ? 4 : 3) /* Unpack RAR UL dci as defined in Section 6.2 of 36.213 */ -void srslte_dci_rar_unpack(uint8_t payload[SRSLTE_RAR_GRANT_LEN], srslte_dci_rar_grant_t* rar) +void srsran_dci_rar_unpack(uint8_t payload[SRSRAN_RAR_GRANT_LEN], srsran_dci_rar_grant_t* rar) { uint8_t* ptr = payload; - rar->hopping_flag = srslte_bit_pack(&ptr, 1) ? true : false; - rar->rba = srslte_bit_pack(&ptr, 10); - rar->trunc_mcs = srslte_bit_pack(&ptr, 4); - rar->tpc_pusch = srslte_bit_pack(&ptr, 3); - rar->ul_delay = srslte_bit_pack(&ptr, 1) ? true : false; - rar->cqi_request = srslte_bit_pack(&ptr, 1) ? true : false; + rar->hopping_flag = srsran_bit_pack(&ptr, 1) ? true : false; + rar->rba = srsran_bit_pack(&ptr, 10); + rar->trunc_mcs = srsran_bit_pack(&ptr, 4); + rar->tpc_pusch = srsran_bit_pack(&ptr, 3); + rar->ul_delay = srsran_bit_pack(&ptr, 1) ? true : false; + rar->cqi_request = srsran_bit_pack(&ptr, 1) ? true : false; } /* Pack RAR UL dci as defined in Section 6.2 of 36.213 */ -void srslte_dci_rar_pack(srslte_dci_rar_grant_t* rar, uint8_t payload[SRSLTE_RAR_GRANT_LEN]) +void srsran_dci_rar_pack(srsran_dci_rar_grant_t* rar, uint8_t payload[SRSRAN_RAR_GRANT_LEN]) { uint8_t* ptr = payload; - srslte_bit_unpack(rar->hopping_flag ? 1 : 0, &ptr, 1); - srslte_bit_unpack(rar->rba, &ptr, 10); - srslte_bit_unpack(rar->trunc_mcs, &ptr, 4); - srslte_bit_unpack(rar->tpc_pusch, &ptr, 3); - srslte_bit_unpack(rar->ul_delay ? 1 : 0, &ptr, 1); - srslte_bit_unpack(rar->cqi_request ? 1 : 0, &ptr, 1); + srsran_bit_unpack(rar->hopping_flag ? 1 : 0, &ptr, 1); + srsran_bit_unpack(rar->rba, &ptr, 10); + srsran_bit_unpack(rar->trunc_mcs, &ptr, 4); + srsran_bit_unpack(rar->tpc_pusch, &ptr, 3); + srsran_bit_unpack(rar->ul_delay ? 1 : 0, &ptr, 1); + srsran_bit_unpack(rar->cqi_request ? 1 : 0, &ptr, 1); } /* Creates an equivalent DCI UL grant from the random access respone message */ -int srslte_dci_rar_to_ul_dci(srslte_cell_t* cell, srslte_dci_rar_grant_t* rar, srslte_dci_ul_t* dci_ul) +int srsran_dci_rar_to_ul_dci(srsran_cell_t* cell, srsran_dci_rar_grant_t* rar, srsran_dci_ul_t* dci_ul) { - bzero(dci_ul, sizeof(srslte_dci_ul_t)); + bzero(dci_ul, sizeof(srsran_dci_ul_t)); if (!rar->hopping_flag) { - dci_ul->freq_hop_fl = SRSLTE_RA_PUSCH_HOP_DISABLED; + dci_ul->freq_hop_fl = SRSRAN_RA_PUSCH_HOP_DISABLED; } else { ERROR("TODO: Frequency hopping in RAR not implemented"); dci_ul->freq_hop_fl = 1; @@ -78,7 +78,7 @@ int srslte_dci_rar_to_ul_dci(srslte_cell_t* cell, srslte_dci_rar_grant_t* rar, s dci_ul->tb.rv = -1; dci_ul->dai = 3; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } static uint32_t riv_nbits(uint32_t nof_prb) @@ -102,7 +102,7 @@ static bool is_ambiguous_size(uint32_t size) /********************************** * PAYLOAD sizeof functions * ********************************/ -static uint32_t dci_format0_sizeof_(const srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf, srslte_dci_cfg_t* cfg) +static uint32_t dci_format0_sizeof_(const srsran_cell_t* cell, srsran_dl_sf_cfg_t* sf, srsran_dci_cfg_t* cfg) { uint32_t n = 0; @@ -147,7 +147,7 @@ static uint32_t dci_format0_sizeof_(const srslte_cell_t* cell, srslte_dl_sf_cfg_ return n; } -static uint32_t dci_format1A_sizeof(const srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf, srslte_dci_cfg_t* cfg) +static uint32_t dci_format1A_sizeof(const srsran_cell_t* cell, srsran_dl_sf_cfg_t* sf, srsran_dci_cfg_t* cfg) { uint32_t n = 0; @@ -193,7 +193,7 @@ static uint32_t dci_format1A_sizeof(const srslte_cell_t* cell, srslte_dl_sf_cfg_ return n; } -static uint32_t dci_format0_sizeof(const srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf, srslte_dci_cfg_t* cfg) +static uint32_t dci_format0_sizeof(const srsran_cell_t* cell, srsran_dl_sf_cfg_t* sf, srsran_dci_cfg_t* cfg) { uint32_t n = dci_format0_sizeof_(cell, sf, cfg); while (n < dci_format1A_sizeof(cell, sf, cfg)) { @@ -202,9 +202,9 @@ static uint32_t dci_format0_sizeof(const srslte_cell_t* cell, srslte_dl_sf_cfg_t return n; } -static uint32_t dci_format1_sizeof(const srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf, srslte_dci_cfg_t* cfg) +static uint32_t dci_format1_sizeof(const srsran_cell_t* cell, srsran_dl_sf_cfg_t* sf, srsran_dci_cfg_t* cfg) { - uint32_t n = (uint32_t)ceilf((float)cell->nof_prb / srslte_ra_type0_P(cell->nof_prb)) + 5 + HARQ_PID_LEN + 1 + 2 + 2 + + uint32_t n = (uint32_t)ceilf((float)cell->nof_prb / srsran_ra_type0_P(cell->nof_prb)) + 5 + HARQ_PID_LEN + 1 + 2 + 2 + (cfg->cif_enabled ? 3 : 0) + (IS_TDD ? 2 : 0); if (cell->nof_prb > 10) { n++; @@ -215,10 +215,10 @@ static uint32_t dci_format1_sizeof(const srslte_cell_t* cell, srslte_dl_sf_cfg_t return n; } -static uint32_t dci_format1C_sizeof(const srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf, srslte_dci_cfg_t* cfg) +static uint32_t dci_format1C_sizeof(const srsran_cell_t* cell, srsran_dl_sf_cfg_t* sf, srsran_dci_cfg_t* cfg) { - uint32_t n_vrb_dl_gap1 = srslte_ra_type2_n_vrb_dl(cell->nof_prb, true); - uint32_t n_step = srslte_ra_type2_n_rb_step(cell->nof_prb); + uint32_t n_vrb_dl_gap1 = srsran_ra_type2_n_vrb_dl(cell->nof_prb, true); + uint32_t n_step = srsran_ra_type2_n_rb_step(cell->nof_prb); uint32_t n = riv_nbits((uint32_t)n_vrb_dl_gap1 / n_step) + 5; if (cell->nof_prb >= 50) { n++; @@ -236,7 +236,7 @@ static uint32_t tpmi_bits(uint32_t nof_ports) } } -static uint32_t dci_format1B_sizeof(const srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf, srslte_dci_cfg_t* cfg) +static uint32_t dci_format1B_sizeof(const srsran_cell_t* cell, srsran_dl_sf_cfg_t* sf, srsran_dci_cfg_t* cfg) { uint32_t n = 0; @@ -282,7 +282,7 @@ static uint32_t dci_format1B_sizeof(const srslte_cell_t* cell, srslte_dl_sf_cfg_ return n; } -static uint32_t dci_format1D_sizeof(const srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf, srslte_dci_cfg_t* cfg) +static uint32_t dci_format1D_sizeof(const srsran_cell_t* cell, srsran_dl_sf_cfg_t* sf, srsran_dci_cfg_t* cfg) { // same size as format1B return dci_format1B_sizeof(cell, sf, cfg); @@ -298,9 +298,9 @@ static uint32_t precoding_bits_f2(uint32_t nof_ports) } } -static uint32_t dci_format2_sizeof(const srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf, srslte_dci_cfg_t* cfg) +static uint32_t dci_format2_sizeof(const srsran_cell_t* cell, srsran_dl_sf_cfg_t* sf, srsran_dci_cfg_t* cfg) { - uint32_t n = (uint32_t)ceilf((float)cell->nof_prb / srslte_ra_type0_P(cell->nof_prb)) + 2 + HARQ_PID_LEN + 1 + + uint32_t n = (uint32_t)ceilf((float)cell->nof_prb / srsran_ra_type0_P(cell->nof_prb)) + 2 + HARQ_PID_LEN + 1 + 2 * (5 + 1 + 2) + precoding_bits_f2(cell->nof_ports) + (cfg->cif_enabled ? 3 : 0) + (IS_TDD ? 2 : 0); if (cell->nof_prb > 10) { n++; @@ -321,9 +321,9 @@ static uint32_t precoding_bits_f2a(uint32_t nof_ports) } } -static uint32_t dci_format2A_sizeof(const srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf, srslte_dci_cfg_t* cfg) +static uint32_t dci_format2A_sizeof(const srsran_cell_t* cell, srsran_dl_sf_cfg_t* sf, srsran_dci_cfg_t* cfg) { - uint32_t n = (uint32_t)ceilf((float)cell->nof_prb / srslte_ra_type0_P(cell->nof_prb)) + 2 + HARQ_PID_LEN + 1 + + uint32_t n = (uint32_t)ceilf((float)cell->nof_prb / srsran_ra_type0_P(cell->nof_prb)) + 2 + HARQ_PID_LEN + 1 + 2 * (5 + 1 + 2) + precoding_bits_f2a(cell->nof_ports) + (cfg->cif_enabled ? 3 : 0) + (IS_TDD ? 2 : 0); if (cell->nof_prb > 10) { n++; @@ -334,9 +334,9 @@ static uint32_t dci_format2A_sizeof(const srslte_cell_t* cell, srslte_dl_sf_cfg_ return n; } -static uint32_t dci_format2B_sizeof(const srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf, srslte_dci_cfg_t* cfg) +static uint32_t dci_format2B_sizeof(const srsran_cell_t* cell, srsran_dl_sf_cfg_t* sf, srsran_dci_cfg_t* cfg) { - uint32_t n = (uint32_t)ceilf((float)cell->nof_prb / srslte_ra_type0_P(cell->nof_prb)) + 2 + HARQ_PID_LEN + 1 + + uint32_t n = (uint32_t)ceilf((float)cell->nof_prb / srsran_ra_type0_P(cell->nof_prb)) + 2 + HARQ_PID_LEN + 1 + 2 * (5 + 1 + 2) + (cfg->cif_enabled ? 3 : 0) + (IS_TDD ? 2 : 0); if (cell->nof_prb > 10) { n++; @@ -347,45 +347,45 @@ static uint32_t dci_format2B_sizeof(const srslte_cell_t* cell, srslte_dl_sf_cfg_ return n; } -uint32_t srslte_dci_format_sizeof(const srslte_cell_t* cell, - srslte_dl_sf_cfg_t* sf, - srslte_dci_cfg_t* cfg, - srslte_dci_format_t format) +uint32_t srsran_dci_format_sizeof(const srsran_cell_t* cell, + srsran_dl_sf_cfg_t* sf, + srsran_dci_cfg_t* cfg, + srsran_dci_format_t format) { - srslte_dl_sf_cfg_t _sf; + srsran_dl_sf_cfg_t _sf; if (sf == NULL) { ZERO_OBJECT(_sf); sf = &_sf; } - srslte_dci_cfg_t _cfg; + srsran_dci_cfg_t _cfg; if (cfg == NULL) { ZERO_OBJECT(_cfg); cfg = &_cfg; } switch (format) { - case SRSLTE_DCI_FORMAT0: + case SRSRAN_DCI_FORMAT0: return dci_format0_sizeof(cell, sf, cfg); - case SRSLTE_DCI_FORMAT1: + case SRSRAN_DCI_FORMAT1: return dci_format1_sizeof(cell, sf, cfg); - case SRSLTE_DCI_FORMAT1A: + case SRSRAN_DCI_FORMAT1A: return dci_format1A_sizeof(cell, sf, cfg); - case SRSLTE_DCI_FORMAT1C: + case SRSRAN_DCI_FORMAT1C: return dci_format1C_sizeof(cell, sf, cfg); - case SRSLTE_DCI_FORMAT1B: + case SRSRAN_DCI_FORMAT1B: return dci_format1B_sizeof(cell, sf, cfg); - case SRSLTE_DCI_FORMAT1D: + case SRSRAN_DCI_FORMAT1D: return dci_format1D_sizeof(cell, sf, cfg); - case SRSLTE_DCI_FORMAT2: + case SRSRAN_DCI_FORMAT2: return dci_format2_sizeof(cell, sf, cfg); - case SRSLTE_DCI_FORMAT2A: + case SRSRAN_DCI_FORMAT2A: return dci_format2A_sizeof(cell, sf, cfg); - case SRSLTE_DCI_FORMAT2B: + case SRSRAN_DCI_FORMAT2B: return dci_format2B_sizeof(cell, sf, cfg); /* - case SRSLTE_DCI_FORMAT3: + case SRSRAN_DCI_FORMAT3: return dci_format3_sizeof(nof_prb); - case SRSLTE_DCI_FORMAT3A: + case SRSRAN_DCI_FORMAT3A: return dci_format3A_sizeof(nof_prb); */ default: @@ -403,22 +403,22 @@ uint32_t srslte_dci_format_sizeof(const srslte_cell_t* cell, * * TODO: TPC and cyclic shift for DM RS not implemented */ -static int dci_format0_pack(srslte_cell_t* cell, - srslte_dl_sf_cfg_t* sf, - srslte_dci_cfg_t* cfg, - srslte_dci_ul_t* dci, - srslte_dci_msg_t* msg) +static int dci_format0_pack(srsran_cell_t* cell, + srsran_dl_sf_cfg_t* sf, + srsran_dci_cfg_t* cfg, + srsran_dci_ul_t* dci, + srsran_dci_msg_t* msg) { /* pack bits */ uint8_t* y = msg->payload; uint32_t n_ul_hop; if (dci->cif_present) { - srslte_bit_unpack(dci->cif, &y, 3); + srsran_bit_unpack(dci->cif, &y, 3); } *y++ = 0; // format differentiation - if (dci->freq_hop_fl == SRSLTE_RA_PUSCH_HOP_DISABLED) { // frequency hopping + if (dci->freq_hop_fl == SRSRAN_RA_PUSCH_HOP_DISABLED) { // frequency hopping *y++ = 0; n_ul_hop = 0; } else { @@ -436,18 +436,18 @@ static int dci_format0_pack(srslte_cell_t* cell, /* pack RIV according to 8.1 of 36.213 */ uint32_t riv = dci->type2_alloc.riv; - srslte_bit_unpack(riv, &y, riv_nbits(cell->nof_prb) - n_ul_hop); + srsran_bit_unpack(riv, &y, riv_nbits(cell->nof_prb) - n_ul_hop); /* pack MCS according to 8.6.1 of 36.213 */ - srslte_bit_unpack(dci->tb.mcs_idx, &y, 5); + srsran_bit_unpack(dci->tb.mcs_idx, &y, 5); *y++ = dci->tb.ndi; // TCP command for PUSCH - srslte_bit_unpack(dci->tpc_pusch, &y, 2); + srsran_bit_unpack(dci->tpc_pusch, &y, 2); // DM RS not implemented - srslte_bit_unpack(dci->n_dmrs, &y, 3); + srsran_bit_unpack(dci->n_dmrs, &y, 3); // CSI request – 1 or 2 bits as defined in section 7.2.1 of 36.213. The 2-bit field applies to UEs that are configured // with more than one DL cell and when the corresponding DCI format is mapped onto the UE specific search space given @@ -467,12 +467,12 @@ static int dci_format0_pack(srslte_cell_t* cell, } // Padding with zeros - uint32_t n = srslte_dci_format_sizeof(cell, sf, cfg, SRSLTE_DCI_FORMAT0); + uint32_t n = srsran_dci_format_sizeof(cell, sf, cfg, SRSRAN_DCI_FORMAT0); while (y - msg->payload < n) { *y++ = 0; } msg->nof_bits = (y - msg->payload); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } /* Unpacks DCI format 0 data and store result in msg according @@ -480,31 +480,31 @@ static int dci_format0_pack(srslte_cell_t* cell, * * TODO: TPC and cyclic shift for DM RS not implemented */ -static int dci_format0_unpack(srslte_cell_t* cell, - srslte_dl_sf_cfg_t* sf, - srslte_dci_cfg_t* cfg, - srslte_dci_msg_t* msg, - srslte_dci_ul_t* dci) +static int dci_format0_unpack(srsran_cell_t* cell, + srsran_dl_sf_cfg_t* sf, + srsran_dci_cfg_t* cfg, + srsran_dci_msg_t* msg, + srsran_dci_ul_t* dci) { /* pack bits */ uint8_t* y = msg->payload; uint32_t n_ul_hop; if (cfg->cif_enabled) { - dci->cif = srslte_bit_pack(&y, 3); + dci->cif = srsran_bit_pack(&y, 3); dci->cif_present = true; } if (*y++ != 0) { INFO("DCI message is Format1A"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Update DCI format - msg->format = SRSLTE_DCI_FORMAT0; + msg->format = SRSRAN_DCI_FORMAT0; if (*y++ == 0) { - dci->freq_hop_fl = SRSLTE_RA_PUSCH_HOP_DISABLED; + dci->freq_hop_fl = SRSRAN_RA_PUSCH_HOP_DISABLED; n_ul_hop = 0; } else { if (cell->nof_prb < 50) { @@ -517,32 +517,32 @@ static int dci_format0_unpack(srslte_cell_t* cell, } } /* unpack RIV according to 8.1 of 36.213 */ - uint32_t riv = srslte_bit_pack(&y, riv_nbits(cell->nof_prb) - n_ul_hop); + uint32_t riv = srsran_bit_pack(&y, riv_nbits(cell->nof_prb) - n_ul_hop); dci->type2_alloc.riv = riv; /* unpack MCS according to 8.6 of 36.213 */ - dci->tb.mcs_idx = srslte_bit_pack(&y, 5); + dci->tb.mcs_idx = srsran_bit_pack(&y, 5); dci->tb.ndi = *y++ ? true : false; // TPC command for scheduled PUSCH - dci->tpc_pusch = srslte_bit_pack(&y, 2); + dci->tpc_pusch = srsran_bit_pack(&y, 2); // Cyclic shift for DMRS - dci->n_dmrs = srslte_bit_pack(&y, 3); + dci->n_dmrs = srsran_bit_pack(&y, 3); // TDD fields if (IS_TDD_CFG0) { - dci->ul_idx = srslte_bit_pack(&y, 2); + dci->ul_idx = srsran_bit_pack(&y, 2); dci->is_tdd = true; } else if (IS_TDD) { - dci->dai = srslte_bit_pack(&y, 2); + dci->dai = srsran_bit_pack(&y, 2); dci->is_tdd = true; } // CQI request if (cfg->multiple_csi_request_enabled && !cfg->is_not_ue_ss) { dci->multiple_csi_request_present = true; - dci->multiple_csi_request = srslte_bit_pack(&y, 2); + dci->multiple_csi_request = srsran_bit_pack(&y, 2); } else { dci->cqi_request = *y++ ? true : false; } @@ -558,7 +558,7 @@ static int dci_format0_unpack(srslte_cell_t* cell, dci->ra_type = *y++ ? true : false; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } /* Packs DCI format 1 data to a sequence of bits and store them in msg according @@ -567,11 +567,11 @@ static int dci_format0_unpack(srslte_cell_t* cell, * TODO: TPC commands */ -static int dci_format1_pack(srslte_cell_t* cell, - srslte_dl_sf_cfg_t* sf, - srslte_dci_cfg_t* cfg, - srslte_dci_dl_t* dci, - srslte_dci_msg_t* msg) +static int dci_format1_pack(srsran_cell_t* cell, + srsran_dl_sf_cfg_t* sf, + srsran_dci_cfg_t* cfg, + srsran_dci_dl_t* dci, + srsran_dci_msg_t* msg) { uint32_t nof_prb = cell->nof_prb; @@ -579,7 +579,7 @@ static int dci_format1_pack(srslte_cell_t* cell, uint8_t* y = msg->payload; if (dci->cif_present) { - srslte_bit_unpack(dci->cif, &y, 3); + srsran_bit_unpack(dci->cif, &y, 3); } if (nof_prb > 10) { @@ -587,36 +587,36 @@ static int dci_format1_pack(srslte_cell_t* cell, } /* Resource allocation: type0 or type 1 */ - uint32_t P = srslte_ra_type0_P(nof_prb); + uint32_t P = srsran_ra_type0_P(nof_prb); uint32_t alloc_size = (uint32_t)ceilf((float)nof_prb / P); switch (dci->alloc_type) { - case SRSLTE_RA_ALLOC_TYPE0: - srslte_bit_unpack((uint32_t)dci->type0_alloc.rbg_bitmask, &y, alloc_size); + case SRSRAN_RA_ALLOC_TYPE0: + srsran_bit_unpack((uint32_t)dci->type0_alloc.rbg_bitmask, &y, alloc_size); break; - case SRSLTE_RA_ALLOC_TYPE1: - srslte_bit_unpack((uint32_t)dci->type1_alloc.rbg_subset, &y, (int)ceilf(log2f(P))); + case SRSRAN_RA_ALLOC_TYPE1: + srsran_bit_unpack((uint32_t)dci->type1_alloc.rbg_subset, &y, (int)ceilf(log2f(P))); *y++ = dci->type1_alloc.shift ? 1 : 0; - srslte_bit_unpack((uint32_t)dci->type1_alloc.vrb_bitmask, &y, alloc_size - (int)ceilf(log2f(P)) - 1); + srsran_bit_unpack((uint32_t)dci->type1_alloc.vrb_bitmask, &y, alloc_size - (int)ceilf(log2f(P)) - 1); break; default: ERROR("Format 1 accepts type0 or type1 resource allocation only"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } /* pack MCS */ - srslte_bit_unpack(dci->tb[0].mcs_idx, &y, 5); + srsran_bit_unpack(dci->tb[0].mcs_idx, &y, 5); /* harq process number */ - srslte_bit_unpack(dci->pid, &y, HARQ_PID_LEN); + srsran_bit_unpack(dci->pid, &y, HARQ_PID_LEN); *y++ = dci->tb[0].ndi; // rv version - srslte_bit_unpack(dci->tb[0].rv, &y, 2); + srsran_bit_unpack(dci->tb[0].rv, &y, 2); // TCP command for PUCCH - srslte_bit_unpack(dci->tpc_pucch, &y, 2); + srsran_bit_unpack(dci->tpc_pucch, &y, 2); - uint32_t n = srslte_dci_format_sizeof(cell, sf, cfg, SRSLTE_DCI_FORMAT1); + uint32_t n = srsran_dci_format_sizeof(cell, sf, cfg, SRSRAN_DCI_FORMAT1); while (y - msg->payload < n) { *y++ = 0; } @@ -626,97 +626,97 @@ static int dci_format1_pack(srslte_cell_t* cell, ERROR("Invalid message length for format 1 (Cross scheduling %s)", dci->cif_present ? "enabled" : "disabled"); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -static int dci_format1_unpack(srslte_cell_t* cell, - srslte_dl_sf_cfg_t* sf, - srslte_dci_cfg_t* cfg, - srslte_dci_msg_t* msg, - srslte_dci_dl_t* dci) +static int dci_format1_unpack(srsran_cell_t* cell, + srsran_dl_sf_cfg_t* sf, + srsran_dci_cfg_t* cfg, + srsran_dci_msg_t* msg, + srsran_dci_dl_t* dci) { /* pack bits */ uint8_t* y = msg->payload; - /* Make sure it's a SRSLTE_DCI_FORMAT1 message */ - uint32_t msg_len = srslte_dci_format_sizeof(cell, sf, cfg, SRSLTE_DCI_FORMAT1); + /* Make sure it's a SRSRAN_DCI_FORMAT1 message */ + uint32_t msg_len = srsran_dci_format_sizeof(cell, sf, cfg, SRSRAN_DCI_FORMAT1); if (msg->nof_bits != msg_len) { ERROR("Invalid message length (%d!=%d) for format 1", msg->nof_bits, msg_len); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (cfg->cif_enabled) { - dci->cif = srslte_bit_pack(&y, 3); + dci->cif = srsran_bit_pack(&y, 3); dci->cif_present = true; } if (cell->nof_prb > 10) { dci->alloc_type = *y++; } else { - dci->alloc_type = SRSLTE_RA_ALLOC_TYPE0; + dci->alloc_type = SRSRAN_RA_ALLOC_TYPE0; } /* Resource allocation: type0 or type 1 */ - uint32_t P = srslte_ra_type0_P(cell->nof_prb); + uint32_t P = srsran_ra_type0_P(cell->nof_prb); uint32_t alloc_size = (uint32_t)ceilf((float)cell->nof_prb / P); switch (dci->alloc_type) { - case SRSLTE_RA_ALLOC_TYPE0: - dci->type0_alloc.rbg_bitmask = srslte_bit_pack(&y, alloc_size); + case SRSRAN_RA_ALLOC_TYPE0: + dci->type0_alloc.rbg_bitmask = srsran_bit_pack(&y, alloc_size); break; - case SRSLTE_RA_ALLOC_TYPE1: - dci->type1_alloc.rbg_subset = srslte_bit_pack(&y, (int)ceilf(log2f(P))); + case SRSRAN_RA_ALLOC_TYPE1: + dci->type1_alloc.rbg_subset = srsran_bit_pack(&y, (int)ceilf(log2f(P))); dci->type1_alloc.shift = *y++ ? true : false; - dci->type1_alloc.vrb_bitmask = srslte_bit_pack(&y, alloc_size - (int)ceilf(log2f(P)) - 1); + dci->type1_alloc.vrb_bitmask = srsran_bit_pack(&y, alloc_size - (int)ceilf(log2f(P)) - 1); break; default: ERROR("Format 1 accepts type0 or type1 resource allocation only"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } /* unpack MCS according to 7.1.7 of 36.213 */ - dci->tb[0].mcs_idx = srslte_bit_pack(&y, 5); + dci->tb[0].mcs_idx = srsran_bit_pack(&y, 5); /* harq process number */ - dci->pid = srslte_bit_pack(&y, HARQ_PID_LEN); + dci->pid = srsran_bit_pack(&y, HARQ_PID_LEN); dci->tb[0].ndi = *y++ ? true : false; // rv version - dci->tb[0].rv = srslte_bit_pack(&y, 2); + dci->tb[0].rv = srsran_bit_pack(&y, 2); // TPC PUCCH - dci->tpc_pucch = srslte_bit_pack(&y, 2); + dci->tpc_pucch = srsran_bit_pack(&y, 2); // TDD if (IS_TDD) { - dci->dai = srslte_bit_pack(&y, 2); + dci->dai = srsran_bit_pack(&y, 2); dci->is_tdd = true; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } /* Packs DCI format 1A for compact scheduling of PDSCH words according to 36.212 5.3.3.1.3 * * TODO: RA procedure initiated by PDCCH, TPC commands */ -static int dci_format1As_pack(srslte_cell_t* cell, - srslte_dl_sf_cfg_t* sf, - srslte_dci_cfg_t* cfg, - srslte_dci_dl_t* dci, - srslte_dci_msg_t* msg) +static int dci_format1As_pack(srsran_cell_t* cell, + srsran_dl_sf_cfg_t* sf, + srsran_dci_cfg_t* cfg, + srsran_dci_dl_t* dci, + srsran_dci_msg_t* msg) { uint32_t nof_prb = cell->nof_prb; /* pack bits */ uint8_t* y = msg->payload; if (dci->cif_present) { - srslte_bit_unpack(dci->cif, &y, 3); + srsran_bit_unpack(dci->cif, &y, 3); } *y++ = 1; // format differentiation - if (dci->alloc_type != SRSLTE_RA_ALLOC_TYPE2) { + if (dci->alloc_type != SRSRAN_RA_ALLOC_TYPE2) { ERROR("Format 1A accepts type2 resource allocation only"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } *y++ = dci->type2_alloc.mode; // localized or distributed VRB assignment @@ -724,19 +724,19 @@ static int dci_format1As_pack(srslte_cell_t* cell, /* pack RIV according to 7.1.6.3 of 36.213 */ uint32_t riv = dci->type2_alloc.riv; uint32_t nb_gap = 0; - if (SRSLTE_RNTI_ISUSER(dci->rnti) && dci->type2_alloc.mode == SRSLTE_RA_TYPE2_DIST && nof_prb >= 50) { + if (SRSRAN_RNTI_ISUSER(dci->rnti) && dci->type2_alloc.mode == SRSRAN_RA_TYPE2_DIST && nof_prb >= 50) { nb_gap = 1; *y++ = dci->type2_alloc.n_gap; } - srslte_bit_unpack(riv, &y, riv_nbits(nof_prb) - nb_gap); + srsran_bit_unpack(riv, &y, riv_nbits(nof_prb) - nb_gap); // in format1A, MCS = TBS according to 7.1.7.2 of 36.213 - srslte_bit_unpack(dci->tb[0].mcs_idx, &y, 5); + srsran_bit_unpack(dci->tb[0].mcs_idx, &y, 5); - srslte_bit_unpack(dci->pid, &y, HARQ_PID_LEN); + srsran_bit_unpack(dci->pid, &y, HARQ_PID_LEN); - if (!SRSLTE_RNTI_ISUSER(dci->rnti)) { - if (nof_prb >= 50 && dci->type2_alloc.mode == SRSLTE_RA_TYPE2_DIST) { + if (!SRSRAN_RNTI_ISUSER(dci->rnti)) { + if (nof_prb >= 50 && dci->type2_alloc.mode == SRSRAN_RA_TYPE2_DIST) { *y++ = dci->type2_alloc.n_gap; } else { y++; // bit reserved @@ -746,9 +746,9 @@ static int dci_format1As_pack(srslte_cell_t* cell, } // rv version - srslte_bit_unpack(dci->tb[0].rv, &y, 2); + srsran_bit_unpack(dci->tb[0].rv, &y, 2); - if (SRSLTE_RNTI_ISUSER(dci->rnti)) { + if (SRSRAN_RNTI_ISUSER(dci->rnti)) { // TPC not implemented *y++ = 0; *y++ = 0; @@ -758,39 +758,39 @@ static int dci_format1As_pack(srslte_cell_t* cell, } // Padding with zeros - uint32_t n = srslte_dci_format_sizeof(cell, sf, cfg, SRSLTE_DCI_FORMAT1A); + uint32_t n = srsran_dci_format_sizeof(cell, sf, cfg, SRSRAN_DCI_FORMAT1A); while (y - msg->payload < n) { *y++ = 0; } msg->nof_bits = (y - msg->payload); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } /* Unpacks DCI format 1A for compact scheduling of PDSCH words according to 36.212 5.3.3.1.3 * */ -static int dci_format1As_unpack(srslte_cell_t* cell, - srslte_dl_sf_cfg_t* sf, - srslte_dci_cfg_t* cfg, - srslte_dci_msg_t* msg, - srslte_dci_dl_t* dci) +static int dci_format1As_unpack(srsran_cell_t* cell, + srsran_dl_sf_cfg_t* sf, + srsran_dci_cfg_t* cfg, + srsran_dci_msg_t* msg, + srsran_dci_dl_t* dci) { /* pack bits */ uint8_t* y = msg->payload; if (cfg->cif_enabled) { - dci->cif = srslte_bit_pack(&y, 3); + dci->cif = srsran_bit_pack(&y, 3); dci->cif_present = true; } if (*y++ != 1) { INFO("DCI message is Format0"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Update DCI format - msg->format = SRSLTE_DCI_FORMAT1A; + msg->format = SRSRAN_DCI_FORMAT1A; // Check if RA procedure by PDCCH order if (*y == 0) { @@ -811,38 +811,38 @@ static int dci_format1As_unpack(srslte_cell_t* cell, y += 1 + nof_bits; dci->is_ra_order = true; - dci->ra_preamble = srslte_bit_pack(&y, 6); - dci->ra_mask_idx = srslte_bit_pack(&y, 4); + dci->ra_preamble = srsran_bit_pack(&y, 6); + dci->ra_mask_idx = srsran_bit_pack(&y, 4); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } } } dci->is_ra_order = false; - dci->alloc_type = SRSLTE_RA_ALLOC_TYPE2; + dci->alloc_type = SRSRAN_RA_ALLOC_TYPE2; dci->type2_alloc.mode = *y++; // by default, set N_gap to 1 - dci->type2_alloc.n_gap = SRSLTE_RA_TYPE2_NG1; + dci->type2_alloc.n_gap = SRSRAN_RA_TYPE2_NG1; /* unpack RIV */ uint32_t nb_gap = 0; - if (SRSLTE_RNTI_ISUSER(msg->rnti) && dci->type2_alloc.mode == SRSLTE_RA_TYPE2_DIST && cell->nof_prb >= 50) { + if (SRSRAN_RNTI_ISUSER(msg->rnti) && dci->type2_alloc.mode == SRSRAN_RA_TYPE2_DIST && cell->nof_prb >= 50) { nb_gap = 1; dci->type2_alloc.n_gap = *y++; } - uint32_t riv = srslte_bit_pack(&y, riv_nbits(cell->nof_prb) - nb_gap); + uint32_t riv = srsran_bit_pack(&y, riv_nbits(cell->nof_prb) - nb_gap); dci->type2_alloc.riv = riv; // unpack MCS - dci->tb[0].mcs_idx = srslte_bit_pack(&y, 5); + dci->tb[0].mcs_idx = srsran_bit_pack(&y, 5); - dci->pid = srslte_bit_pack(&y, HARQ_PID_LEN); + dci->pid = srsran_bit_pack(&y, HARQ_PID_LEN); - if (!SRSLTE_RNTI_ISUSER(msg->rnti)) { - if (cell->nof_prb >= 50 && dci->type2_alloc.mode == SRSLTE_RA_TYPE2_DIST) { + if (!SRSRAN_RNTI_ISUSER(msg->rnti)) { + if (cell->nof_prb >= 50 && dci->type2_alloc.mode == SRSRAN_RA_TYPE2_DIST) { dci->type2_alloc.n_gap = *y++; } else { y++; // NDI reserved @@ -852,9 +852,9 @@ static int dci_format1As_unpack(srslte_cell_t* cell, } // rv version - dci->tb[0].rv = srslte_bit_pack(&y, 2); + dci->tb[0].rv = srsran_bit_pack(&y, 2); - if (SRSLTE_RNTI_ISUSER(msg->rnti)) { + if (SRSRAN_RNTI_ISUSER(msg->rnti)) { // TPC not implemented y++; y++; @@ -865,71 +865,71 @@ static int dci_format1As_unpack(srslte_cell_t* cell, // TDD if (IS_TDD) { - dci->dai = srslte_bit_pack(&y, 2); + dci->dai = srsran_bit_pack(&y, 2); dci->is_tdd = true; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -static int dci_format1B_unpack(srslte_cell_t* cell, - srslte_dl_sf_cfg_t* sf, - srslte_dci_cfg_t* cfg, - srslte_dci_msg_t* msg, - srslte_dci_dl_t* dci) +static int dci_format1B_unpack(srsran_cell_t* cell, + srsran_dl_sf_cfg_t* sf, + srsran_dci_cfg_t* cfg, + srsran_dci_msg_t* msg, + srsran_dci_dl_t* dci) { /* pack bits */ uint8_t* y = msg->payload; if (cfg->cif_enabled) { - dci->cif = srslte_bit_pack(&y, 3); + dci->cif = srsran_bit_pack(&y, 3); dci->cif_present = true; } - dci->alloc_type = SRSLTE_RA_ALLOC_TYPE2; + dci->alloc_type = SRSRAN_RA_ALLOC_TYPE2; dci->type2_alloc.mode = *y++; // by default, set N_gap to 1 - dci->type2_alloc.n_gap = SRSLTE_RA_TYPE2_NG1; + dci->type2_alloc.n_gap = SRSRAN_RA_TYPE2_NG1; /* unpack RIV according to 7.1.6.3 of 36.213 */ uint32_t nb_gap = 0; - if (dci->type2_alloc.mode == SRSLTE_RA_TYPE2_DIST && cell->nof_prb >= 50) { + if (dci->type2_alloc.mode == SRSRAN_RA_TYPE2_DIST && cell->nof_prb >= 50) { nb_gap = 1; dci->type2_alloc.n_gap = *y++; } - uint32_t riv = srslte_bit_pack(&y, riv_nbits(cell->nof_prb) - nb_gap); + uint32_t riv = srsran_bit_pack(&y, riv_nbits(cell->nof_prb) - nb_gap); dci->type2_alloc.riv = riv; // unpack MCS, Harq pid and ndi - dci->tb[0].mcs_idx = srslte_bit_pack(&y, 5); - dci->pid = srslte_bit_pack(&y, HARQ_PID_LEN); + dci->tb[0].mcs_idx = srsran_bit_pack(&y, 5); + dci->pid = srsran_bit_pack(&y, HARQ_PID_LEN); dci->tb[0].ndi = *y++ ? true : false; - dci->tb[0].rv = srslte_bit_pack(&y, 2); + dci->tb[0].rv = srsran_bit_pack(&y, 2); // TPC PUCCH - dci->tpc_pucch = srslte_bit_pack(&y, 2); + dci->tpc_pucch = srsran_bit_pack(&y, 2); // TDD if (IS_TDD) { - dci->dai = srslte_bit_pack(&y, 2); + dci->dai = srsran_bit_pack(&y, 2); dci->is_tdd = true; } - dci->pinfo = srslte_bit_pack(&y, tpmi_bits(cell->nof_ports)); + dci->pinfo = srsran_bit_pack(&y, tpmi_bits(cell->nof_ports)); dci->pconf = *y++ ? true : false; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } /* Format 1C for compact scheduling of PDSCH words * */ -static int dci_format1Cs_pack(srslte_cell_t* cell, - srslte_dl_sf_cfg_t* sf, - srslte_dci_cfg_t* cfg, - srslte_dci_dl_t* dci, - srslte_dci_msg_t* msg) +static int dci_format1Cs_pack(srsran_cell_t* cell, + srsran_dl_sf_cfg_t* sf, + srsran_dci_cfg_t* cfg, + srsran_dci_dl_t* dci, + srsran_dci_msg_t* msg) { uint32_t nof_prb = cell->nof_prb; @@ -937,123 +937,123 @@ static int dci_format1Cs_pack(srslte_cell_t* cell, uint8_t* y = msg->payload; if (dci->cif_present) { - srslte_bit_unpack(dci->cif, &y, 3); + srsran_bit_unpack(dci->cif, &y, 3); } - if (dci->alloc_type != SRSLTE_RA_ALLOC_TYPE2 || dci->type2_alloc.mode != SRSLTE_RA_TYPE2_DIST) { + if (dci->alloc_type != SRSRAN_RA_ALLOC_TYPE2 || dci->type2_alloc.mode != SRSRAN_RA_TYPE2_DIST) { ERROR("Format 1C accepts distributed type2 resource allocation only"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (nof_prb >= 50) { *y++ = dci->type2_alloc.n_gap; } - uint32_t n_step = srslte_ra_type2_n_rb_step(nof_prb); - uint32_t n_vrb_dl = srslte_ra_type2_n_vrb_dl(nof_prb, dci->type2_alloc.n_gap == SRSLTE_RA_TYPE2_NG1); + uint32_t n_step = srsran_ra_type2_n_rb_step(nof_prb); + uint32_t n_vrb_dl = srsran_ra_type2_n_vrb_dl(nof_prb, dci->type2_alloc.n_gap == SRSRAN_RA_TYPE2_NG1); uint32_t riv = dci->type2_alloc.riv; - srslte_bit_unpack(riv, &y, riv_nbits((int)n_vrb_dl / n_step)); + srsran_bit_unpack(riv, &y, riv_nbits((int)n_vrb_dl / n_step)); // in format1C, MCS = TBS according to 7.1.7.2 of 36.213 - srslte_bit_unpack(dci->tb[0].mcs_idx, &y, 5); + srsran_bit_unpack(dci->tb[0].mcs_idx, &y, 5); msg->nof_bits = (y - msg->payload); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -static int dci_format1Cs_unpack(srslte_cell_t* cell, - srslte_dl_sf_cfg_t* sf, - srslte_dci_cfg_t* cfg, - srslte_dci_msg_t* msg, - srslte_dci_dl_t* dci) +static int dci_format1Cs_unpack(srsran_cell_t* cell, + srsran_dl_sf_cfg_t* sf, + srsran_dci_cfg_t* cfg, + srsran_dci_msg_t* msg, + srsran_dci_dl_t* dci) { /* pack bits */ uint8_t* y = msg->payload; - if (msg->nof_bits != srslte_dci_format_sizeof(cell, sf, cfg, SRSLTE_DCI_FORMAT1C)) { + if (msg->nof_bits != srsran_dci_format_sizeof(cell, sf, cfg, SRSRAN_DCI_FORMAT1C)) { ERROR("Invalid message length for format 1C"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - dci->alloc_type = SRSLTE_RA_ALLOC_TYPE2; - dci->type2_alloc.mode = SRSLTE_RA_TYPE2_DIST; + dci->alloc_type = SRSRAN_RA_ALLOC_TYPE2; + dci->type2_alloc.mode = SRSRAN_RA_TYPE2_DIST; if (cell->nof_prb >= 50) { dci->type2_alloc.n_gap = *y++; } - uint32_t n_step = srslte_ra_type2_n_rb_step(cell->nof_prb); - uint32_t n_vrb_dl = srslte_ra_type2_n_vrb_dl(cell->nof_prb, dci->type2_alloc.n_gap == SRSLTE_RA_TYPE2_NG1); + uint32_t n_step = srsran_ra_type2_n_rb_step(cell->nof_prb); + uint32_t n_vrb_dl = srsran_ra_type2_n_vrb_dl(cell->nof_prb, dci->type2_alloc.n_gap == SRSRAN_RA_TYPE2_NG1); - uint32_t riv = srslte_bit_pack(&y, riv_nbits((int)n_vrb_dl / n_step)); + uint32_t riv = srsran_bit_pack(&y, riv_nbits((int)n_vrb_dl / n_step)); dci->type2_alloc.riv = riv; - dci->tb[0].mcs_idx = srslte_bit_pack(&y, 5); + dci->tb[0].mcs_idx = srsran_bit_pack(&y, 5); dci->tb[0].rv = -1; // Get RV later msg->nof_bits = (y - msg->payload); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -static int dci_format1D_unpack(srslte_cell_t* cell, - srslte_dl_sf_cfg_t* sf, - srslte_dci_cfg_t* cfg, - srslte_dci_msg_t* msg, - srslte_dci_dl_t* dci) +static int dci_format1D_unpack(srsran_cell_t* cell, + srsran_dl_sf_cfg_t* sf, + srsran_dci_cfg_t* cfg, + srsran_dci_msg_t* msg, + srsran_dci_dl_t* dci) { /* pack bits */ uint8_t* y = msg->payload; if (cfg->cif_enabled) { - dci->cif = srslte_bit_pack(&y, 3); + dci->cif = srsran_bit_pack(&y, 3); dci->cif_present = true; } - dci->alloc_type = SRSLTE_RA_ALLOC_TYPE2; + dci->alloc_type = SRSRAN_RA_ALLOC_TYPE2; dci->type2_alloc.mode = *y++; // by default, set N_gap to 1 - dci->type2_alloc.n_gap = SRSLTE_RA_TYPE2_NG1; + dci->type2_alloc.n_gap = SRSRAN_RA_TYPE2_NG1; /* unpack RIV according to 7.1.6.3 of 36.213 */ uint32_t nb_gap = 0; - if (dci->type2_alloc.mode == SRSLTE_RA_TYPE2_DIST && cell->nof_prb >= 50) { + if (dci->type2_alloc.mode == SRSRAN_RA_TYPE2_DIST && cell->nof_prb >= 50) { nb_gap = 1; dci->type2_alloc.n_gap = *y++; } - uint32_t riv = srslte_bit_pack(&y, riv_nbits(cell->nof_prb) - nb_gap); + uint32_t riv = srsran_bit_pack(&y, riv_nbits(cell->nof_prb) - nb_gap); dci->type2_alloc.riv = riv; // unpack MCS, Harq pid and ndi - dci->tb[0].mcs_idx = srslte_bit_pack(&y, 5); - dci->pid = srslte_bit_pack(&y, HARQ_PID_LEN); + dci->tb[0].mcs_idx = srsran_bit_pack(&y, 5); + dci->pid = srsran_bit_pack(&y, HARQ_PID_LEN); dci->tb[0].ndi = *y++ ? true : false; - dci->tb[0].rv = srslte_bit_pack(&y, 2); + dci->tb[0].rv = srsran_bit_pack(&y, 2); // TPC PUCCH - dci->tpc_pucch = srslte_bit_pack(&y, 2); + dci->tpc_pucch = srsran_bit_pack(&y, 2); // TDD if (IS_TDD) { - dci->dai = srslte_bit_pack(&y, 2); + dci->dai = srsran_bit_pack(&y, 2); dci->is_tdd = true; } - dci->pinfo = srslte_bit_pack(&y, tpmi_bits(cell->nof_ports)); + dci->pinfo = srsran_bit_pack(&y, tpmi_bits(cell->nof_ports)); dci->power_offset = *y++ ? true : false; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -static int dci_format2AB_pack(srslte_cell_t* cell, - srslte_dl_sf_cfg_t* sf, - srslte_dci_cfg_t* cfg, - srslte_dci_dl_t* dci, - srslte_dci_msg_t* msg) +static int dci_format2AB_pack(srsran_cell_t* cell, + srsran_dl_sf_cfg_t* sf, + srsran_dci_cfg_t* cfg, + srsran_dci_dl_t* dci, + srsran_dci_msg_t* msg) { uint32_t nof_prb = cell->nof_prb; uint32_t nof_ports = cell->nof_ports; @@ -1062,7 +1062,7 @@ static int dci_format2AB_pack(srslte_cell_t* cell, uint8_t* y = msg->payload; if (dci->cif_present) { - srslte_bit_unpack(dci->cif, &y, 3); + srsran_bit_unpack(dci->cif, &y, 3); } if (nof_prb > 10) { @@ -1070,113 +1070,113 @@ static int dci_format2AB_pack(srslte_cell_t* cell, } /* Resource allocation: type0 or type 1 */ - uint32_t P = srslte_ra_type0_P(nof_prb); + uint32_t P = srsran_ra_type0_P(nof_prb); uint32_t alloc_size = (uint32_t)ceilf((float)nof_prb / P); switch (dci->alloc_type) { - case SRSLTE_RA_ALLOC_TYPE0: - srslte_bit_unpack((uint32_t)dci->type0_alloc.rbg_bitmask, &y, alloc_size); + case SRSRAN_RA_ALLOC_TYPE0: + srsran_bit_unpack((uint32_t)dci->type0_alloc.rbg_bitmask, &y, alloc_size); break; - case SRSLTE_RA_ALLOC_TYPE1: - srslte_bit_unpack((uint32_t)dci->type1_alloc.rbg_subset, &y, (int)ceilf(log2f(P))); + case SRSRAN_RA_ALLOC_TYPE1: + srsran_bit_unpack((uint32_t)dci->type1_alloc.rbg_subset, &y, (int)ceilf(log2f(P))); *y++ = dci->type1_alloc.shift ? 1 : 0; - srslte_bit_unpack((uint32_t)dci->type1_alloc.vrb_bitmask, &y, alloc_size - (int)ceilf(log2f(P)) - 1); + srsran_bit_unpack((uint32_t)dci->type1_alloc.vrb_bitmask, &y, alloc_size - (int)ceilf(log2f(P)) - 1); break; default: ERROR("Format 1 accepts type0 or type1 resource allocation only"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } /* TCP command for PUCCH */ - srslte_bit_unpack(dci->tpc_pucch, &y, 2); + srsran_bit_unpack(dci->tpc_pucch, &y, 2); /* harq process number */ - srslte_bit_unpack(dci->pid, &y, HARQ_PID_LEN); + srsran_bit_unpack(dci->pid, &y, HARQ_PID_LEN); // Transpor block to codeword swap flag - if (msg->format == SRSLTE_DCI_FORMAT2B) { + if (msg->format == SRSRAN_DCI_FORMAT2B) { *y++ = dci->sram_id; } else { *y++ = dci->tb_cw_swap; } /* pack TB1 */ - srslte_bit_unpack(dci->tb[0].mcs_idx, &y, 5); + srsran_bit_unpack(dci->tb[0].mcs_idx, &y, 5); *y++ = dci->tb[0].ndi; - srslte_bit_unpack(dci->tb[0].rv, &y, 2); + srsran_bit_unpack(dci->tb[0].rv, &y, 2); /* pack TB2 */ - srslte_bit_unpack(dci->tb[1].mcs_idx, &y, 5); + srsran_bit_unpack(dci->tb[1].mcs_idx, &y, 5); *y++ = dci->tb[1].ndi; - srslte_bit_unpack(dci->tb[1].rv, &y, 2); + srsran_bit_unpack(dci->tb[1].rv, &y, 2); // Precoding information - if (msg->format == SRSLTE_DCI_FORMAT2) { - srslte_bit_unpack(dci->pinfo, &y, precoding_bits_f2(nof_ports)); - } else if (msg->format == SRSLTE_DCI_FORMAT2A) { - srslte_bit_unpack(dci->pinfo, &y, precoding_bits_f2a(nof_ports)); + if (msg->format == SRSRAN_DCI_FORMAT2) { + srsran_bit_unpack(dci->pinfo, &y, precoding_bits_f2(nof_ports)); + } else if (msg->format == SRSRAN_DCI_FORMAT2A) { + srsran_bit_unpack(dci->pinfo, &y, precoding_bits_f2a(nof_ports)); } // Padding with zeros - uint32_t n = srslte_dci_format_sizeof(cell, sf, cfg, msg->format); + uint32_t n = srsran_dci_format_sizeof(cell, sf, cfg, msg->format); while (y - msg->payload < n) { *y++ = 0; } msg->nof_bits = (y - msg->payload); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -static int dci_format2AB_unpack(srslte_cell_t* cell, - srslte_dl_sf_cfg_t* sf, - srslte_dci_cfg_t* cfg, - srslte_dci_msg_t* msg, - srslte_dci_dl_t* dci) +static int dci_format2AB_unpack(srsran_cell_t* cell, + srsran_dl_sf_cfg_t* sf, + srsran_dci_cfg_t* cfg, + srsran_dci_msg_t* msg, + srsran_dci_dl_t* dci) { /* pack bits */ uint8_t* y = msg->payload; if (cfg->cif_enabled) { - dci->cif = srslte_bit_pack(&y, 3); + dci->cif = srsran_bit_pack(&y, 3); dci->cif_present = true; } if (cell->nof_prb > 10) { dci->alloc_type = *y++; } else { - dci->alloc_type = SRSLTE_RA_ALLOC_TYPE0; + dci->alloc_type = SRSRAN_RA_ALLOC_TYPE0; } /* Resource allocation: type0 or type 1 */ - uint32_t P = srslte_ra_type0_P(cell->nof_prb); + uint32_t P = srsran_ra_type0_P(cell->nof_prb); uint32_t alloc_size = (uint32_t)ceilf((float)cell->nof_prb / P); switch (dci->alloc_type) { - case SRSLTE_RA_ALLOC_TYPE0: - dci->type0_alloc.rbg_bitmask = srslte_bit_pack(&y, alloc_size); + case SRSRAN_RA_ALLOC_TYPE0: + dci->type0_alloc.rbg_bitmask = srsran_bit_pack(&y, alloc_size); break; - case SRSLTE_RA_ALLOC_TYPE1: - dci->type1_alloc.rbg_subset = srslte_bit_pack(&y, (int)ceilf(log2f(P))); + case SRSRAN_RA_ALLOC_TYPE1: + dci->type1_alloc.rbg_subset = srsran_bit_pack(&y, (int)ceilf(log2f(P))); dci->type1_alloc.shift = *y++ ? true : false; - dci->type1_alloc.vrb_bitmask = srslte_bit_pack(&y, alloc_size - (int)ceilf(log2f(P)) - 1); + dci->type1_alloc.vrb_bitmask = srsran_bit_pack(&y, alloc_size - (int)ceilf(log2f(P)) - 1); break; default: ERROR("Format2 accepts type0 or type1 resource allocation only"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // TPC PUCCH - dci->tpc_pucch = srslte_bit_pack(&y, 2); + dci->tpc_pucch = srsran_bit_pack(&y, 2); // TDD if (IS_TDD) { - dci->dai = srslte_bit_pack(&y, 2); + dci->dai = srsran_bit_pack(&y, 2); dci->is_tdd = true; } /* harq process number */ - dci->pid = srslte_bit_pack(&y, HARQ_PID_LEN); + dci->pid = srsran_bit_pack(&y, HARQ_PID_LEN); // Transpor block to codeword swap flag - if (msg->format == SRSLTE_DCI_FORMAT2B) { + if (msg->format == SRSRAN_DCI_FORMAT2B) { dci->sram_id = *y++ ? true : false; } else { dci->tb_cw_swap = *y++ ? true : false; @@ -1184,148 +1184,148 @@ static int dci_format2AB_unpack(srslte_cell_t* cell, uint32_t nof_tb = 0; /* unpack MCS according to 7.1.7 of 36.213 */ - for (uint32_t i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { - dci->tb[i].mcs_idx = srslte_bit_pack(&y, 5); + for (uint32_t i = 0; i < SRSRAN_MAX_CODEWORDS; i++) { + dci->tb[i].mcs_idx = srsran_bit_pack(&y, 5); dci->tb[i].ndi = *y++ ? true : false; - dci->tb[i].rv = srslte_bit_pack(&y, 2); - if (SRSLTE_DCI_IS_TB_EN(dci->tb[i])) { + dci->tb[i].rv = srsran_bit_pack(&y, 2); + if (SRSRAN_DCI_IS_TB_EN(dci->tb[i])) { nof_tb++; } } // Precoding information - if (msg->format == SRSLTE_DCI_FORMAT2) { - dci->pinfo = srslte_bit_pack(&y, precoding_bits_f2(cell->nof_ports)); - } else if (msg->format == SRSLTE_DCI_FORMAT2A) { - dci->pinfo = srslte_bit_pack(&y, precoding_bits_f2a(cell->nof_ports)); + if (msg->format == SRSRAN_DCI_FORMAT2) { + dci->pinfo = srsran_bit_pack(&y, precoding_bits_f2(cell->nof_ports)); + } else if (msg->format == SRSRAN_DCI_FORMAT2A) { + dci->pinfo = srsran_bit_pack(&y, precoding_bits_f2a(cell->nof_ports)); } // Apply TB swap table according to 3GPP 36.212 R8, section 5.3.3.1.5 if (nof_tb == 2) { // Table 5.3.3.1.5-1 - for (uint32_t i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { + for (uint32_t i = 0; i < SRSRAN_MAX_CODEWORDS; i++) { dci->tb[i].cw_idx = (((dci->tb_cw_swap) ? 1 : 0) + i) % nof_tb; } } else { // Table 5.3.3.1.5-2 - for (uint32_t i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { + for (uint32_t i = 0; i < SRSRAN_MAX_CODEWORDS; i++) { dci->tb[i].cw_idx = 0; } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_dci_msg_pack_pdsch(srslte_cell_t* cell, - srslte_dl_sf_cfg_t* sf, - srslte_dci_cfg_t* cfg, - srslte_dci_dl_t* dci, - srslte_dci_msg_t* msg) +int srsran_dci_msg_pack_pdsch(srsran_cell_t* cell, + srsran_dl_sf_cfg_t* sf, + srsran_dci_cfg_t* cfg, + srsran_dci_dl_t* dci, + srsran_dci_msg_t* msg) { - int ret = SRSLTE_ERROR; + int ret = SRSRAN_ERROR; msg->rnti = dci->rnti; msg->location = dci->location; msg->format = dci->format; - srslte_dci_cfg_t _dci_cfg; + srsran_dci_cfg_t _dci_cfg; if (!cfg) { ZERO_OBJECT(_dci_cfg); cfg = &_dci_cfg; } switch (msg->format) { - case SRSLTE_DCI_FORMAT1: + case SRSRAN_DCI_FORMAT1: ret = dci_format1_pack(cell, sf, cfg, dci, msg); break; - case SRSLTE_DCI_FORMAT1A: + case SRSRAN_DCI_FORMAT1A: ret = dci_format1As_pack(cell, sf, cfg, dci, msg); break; - case SRSLTE_DCI_FORMAT1C: + case SRSRAN_DCI_FORMAT1C: ret = dci_format1Cs_pack(cell, sf, cfg, dci, msg); break; - case SRSLTE_DCI_FORMAT2: - case SRSLTE_DCI_FORMAT2A: - case SRSLTE_DCI_FORMAT2B: + case SRSRAN_DCI_FORMAT2: + case SRSRAN_DCI_FORMAT2A: + case SRSRAN_DCI_FORMAT2B: ret = dci_format2AB_pack(cell, sf, cfg, dci, msg); break; default: - ERROR("DCI pack pdsch: Invalid DCI format %s", srslte_dci_format_string(msg->format)); + ERROR("DCI pack pdsch: Invalid DCI format %s", srsran_dci_format_string(msg->format)); } -#if SRSLTE_DCI_HEXDEBUG - srslte_vec_sprint_hex(dci->hex_str, sizeof(dci->hex_str), msg->payload, msg->nof_bits); +#if SRSRAN_DCI_HEXDEBUG + srsran_vec_sprint_hex(dci->hex_str, sizeof(dci->hex_str), msg->payload, msg->nof_bits); dci->nof_bits = msg->nof_bits; -#endif /* SRSLTE_DCI_HEXDEBUG */ +#endif /* SRSRAN_DCI_HEXDEBUG */ return ret; } -int srslte_dci_msg_unpack_pdsch(srslte_cell_t* cell, - srslte_dl_sf_cfg_t* sf, - srslte_dci_cfg_t* cfg, - srslte_dci_msg_t* msg, - srslte_dci_dl_t* dci) +int srsran_dci_msg_unpack_pdsch(srsran_cell_t* cell, + srsran_dl_sf_cfg_t* sf, + srsran_dci_cfg_t* cfg, + srsran_dci_msg_t* msg, + srsran_dci_dl_t* dci) { // Initialize DCI - bzero(dci, sizeof(srslte_dci_dl_t)); + bzero(dci, sizeof(srsran_dci_dl_t)); // Enable just 1 TB per default - for (int i = 1; i < SRSLTE_MAX_CODEWORDS; i++) { - SRSLTE_DCI_TB_DISABLE(dci->tb[i]); + for (int i = 1; i < SRSRAN_MAX_CODEWORDS; i++) { + SRSRAN_DCI_TB_DISABLE(dci->tb[i]); } dci->rnti = msg->rnti; dci->location = msg->location; dci->format = msg->format; - srslte_dci_cfg_t _dci_cfg; + srsran_dci_cfg_t _dci_cfg; if (!cfg) { ZERO_OBJECT(_dci_cfg); cfg = &_dci_cfg; } -#if SRSLTE_DCI_HEXDEBUG +#if SRSRAN_DCI_HEXDEBUG dci->hex_str[0] = '\0'; - srslte_vec_sprint_hex(dci->hex_str, sizeof(dci->hex_str), msg->payload, msg->nof_bits); + srsran_vec_sprint_hex(dci->hex_str, sizeof(dci->hex_str), msg->payload, msg->nof_bits); dci->nof_bits = msg->nof_bits; #endif // Set dwpts flag dci->is_dwpts = - cell->frame_type == SRSLTE_TDD && srslte_sfidx_tdd_type(sf->tdd_config, sf->tti % 10) == SRSLTE_TDD_SF_S; + cell->frame_type == SRSRAN_TDD && srsran_sfidx_tdd_type(sf->tdd_config, sf->tti % 10) == SRSRAN_TDD_SF_S; switch (msg->format) { - case SRSLTE_DCI_FORMAT1: + case SRSRAN_DCI_FORMAT1: return dci_format1_unpack(cell, sf, cfg, msg, dci); - case SRSLTE_DCI_FORMAT1A: + case SRSRAN_DCI_FORMAT1A: return dci_format1As_unpack(cell, sf, cfg, msg, dci); - case SRSLTE_DCI_FORMAT1B: + case SRSRAN_DCI_FORMAT1B: return dci_format1B_unpack(cell, sf, cfg, msg, dci); - case SRSLTE_DCI_FORMAT1C: + case SRSRAN_DCI_FORMAT1C: return dci_format1Cs_unpack(cell, sf, cfg, msg, dci); - case SRSLTE_DCI_FORMAT1D: + case SRSRAN_DCI_FORMAT1D: return dci_format1D_unpack(cell, sf, cfg, msg, dci); - case SRSLTE_DCI_FORMAT2: - case SRSLTE_DCI_FORMAT2A: - case SRSLTE_DCI_FORMAT2B: + case SRSRAN_DCI_FORMAT2: + case SRSRAN_DCI_FORMAT2A: + case SRSRAN_DCI_FORMAT2B: return dci_format2AB_unpack(cell, sf, cfg, msg, dci); default: - ERROR("DCI unpack pdsch: Invalid DCI format %s", srslte_dci_format_string(msg->format)); - return SRSLTE_ERROR; + ERROR("DCI unpack pdsch: Invalid DCI format %s", srsran_dci_format_string(msg->format)); + return SRSRAN_ERROR; } } -int srslte_dci_msg_pack_pusch(srslte_cell_t* cell, - srslte_dl_sf_cfg_t* sf, - srslte_dci_cfg_t* cfg, - srslte_dci_ul_t* dci, - srslte_dci_msg_t* msg) +int srsran_dci_msg_pack_pusch(srsran_cell_t* cell, + srsran_dl_sf_cfg_t* sf, + srsran_dci_cfg_t* cfg, + srsran_dci_ul_t* dci, + srsran_dci_msg_t* msg) { msg->rnti = dci->rnti; msg->location = dci->location; msg->format = dci->format; - srslte_dci_cfg_t _dci_cfg; + srsran_dci_cfg_t _dci_cfg; if (!cfg) { ZERO_OBJECT(_dci_cfg); cfg = &_dci_cfg; @@ -1333,44 +1333,44 @@ int srslte_dci_msg_pack_pusch(srslte_cell_t* cell, int n = dci_format0_pack(cell, sf, cfg, dci, msg); -#if SRSLTE_DCI_HEXDEBUG +#if SRSRAN_DCI_HEXDEBUG dci->hex_str[0] = '\0'; - srslte_vec_sprint_hex(dci->hex_str, sizeof(dci->hex_str), msg->payload, msg->nof_bits); + srsran_vec_sprint_hex(dci->hex_str, sizeof(dci->hex_str), msg->payload, msg->nof_bits); dci->nof_bits = msg->nof_bits; -#endif /* SRSLTE_DCI_HEXDEBUG */ +#endif /* SRSRAN_DCI_HEXDEBUG */ return n; } -int srslte_dci_msg_unpack_pusch(srslte_cell_t* cell, - srslte_dl_sf_cfg_t* sf, - srslte_dci_cfg_t* cfg, - srslte_dci_msg_t* msg, - srslte_dci_ul_t* dci) +int srsran_dci_msg_unpack_pusch(srsran_cell_t* cell, + srsran_dl_sf_cfg_t* sf, + srsran_dci_cfg_t* cfg, + srsran_dci_msg_t* msg, + srsran_dci_ul_t* dci) { // Initialize DCI - bzero(dci, sizeof(srslte_dci_ul_t)); + bzero(dci, sizeof(srsran_dci_ul_t)); dci->rnti = msg->rnti; dci->location = msg->location; dci->format = msg->format; - srslte_dci_cfg_t _dci_cfg; + srsran_dci_cfg_t _dci_cfg; if (!cfg) { ZERO_OBJECT(_dci_cfg); cfg = &_dci_cfg; } -#if SRSLTE_DCI_HEXDEBUG +#if SRSRAN_DCI_HEXDEBUG dci->hex_str[0] = '\0'; - srslte_vec_sprint_hex(dci->hex_str, sizeof(dci->hex_str), msg->payload, msg->nof_bits); + srsran_vec_sprint_hex(dci->hex_str, sizeof(dci->hex_str), msg->payload, msg->nof_bits); dci->nof_bits = msg->nof_bits; -#endif /* SRSLTE_DCI_HEXDEBUG */ +#endif /* SRSRAN_DCI_HEXDEBUG */ return dci_format0_unpack(cell, sf, cfg, msg, dci); } -bool srslte_location_find(const srslte_dci_location_t* locations, uint32_t nof_locations, srslte_dci_location_t x) +bool srsran_location_find(const srsran_dci_location_t* locations, uint32_t nof_locations, srsran_dci_location_t x) { for (uint32_t i = 0; i < nof_locations; i++) { if (locations[i].L == x.L && locations[i].ncce == x.ncce) { @@ -1380,7 +1380,7 @@ bool srslte_location_find(const srslte_dci_location_t* locations, uint32_t nof_l return false; } -bool srslte_location_find_ncce(const srslte_dci_location_t* locations, uint32_t nof_locations, uint32_t ncce) +bool srsran_location_find_ncce(const srsran_dci_location_t* locations, uint32_t nof_locations, uint32_t ncce) { for (uint32_t i = 0; i < nof_locations; i++) { if (locations[i].ncce == ncce) { @@ -1391,29 +1391,29 @@ bool srslte_location_find_ncce(const srslte_dci_location_t* locations, uint32_t } // Set the configuration for Format0/1A messages allocated on Common SS -void srslte_dci_cfg_set_common_ss(srslte_dci_cfg_t* cfg) +void srsran_dci_cfg_set_common_ss(srsran_dci_cfg_t* cfg) { cfg->is_not_ue_ss = true; } -int srslte_dci_location_set(srslte_dci_location_t* c, uint32_t L, uint32_t nCCE) +int srsran_dci_location_set(srsran_dci_location_t* c, uint32_t L, uint32_t nCCE) { if (L <= 3) { c->L = L; } else { ERROR("Invalid L %d", L); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (nCCE <= 87) { c->ncce = nCCE; } else { ERROR("Invalid nCCE %d", nCCE); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -bool srslte_dci_location_isvalid(srslte_dci_location_t* c) +bool srsran_dci_location_isvalid(srsran_dci_location_t* c) { if (c->L <= 3 && c->ncce <= 87) { return true; @@ -1422,103 +1422,103 @@ bool srslte_dci_location_isvalid(srslte_dci_location_t* c) } } -srslte_dci_format_t srslte_dci_format_from_string(char* str) +srsran_dci_format_t srsran_dci_format_from_string(char* str) { if (!strcmp(str, "Format0")) { - return SRSLTE_DCI_FORMAT0; + return SRSRAN_DCI_FORMAT0; } else if (!strcmp(str, "Format1")) { - return SRSLTE_DCI_FORMAT1; + return SRSRAN_DCI_FORMAT1; } else if (!strcmp(str, "Format1A")) { - return SRSLTE_DCI_FORMAT1A; + return SRSRAN_DCI_FORMAT1A; } else if (!strcmp(str, "Format1B")) { - return SRSLTE_DCI_FORMAT1B; + return SRSRAN_DCI_FORMAT1B; } else if (!strcmp(str, "Format1C")) { - return SRSLTE_DCI_FORMAT1C; + return SRSRAN_DCI_FORMAT1C; } else if (!strcmp(str, "Format1D")) { - return SRSLTE_DCI_FORMAT1D; + return SRSRAN_DCI_FORMAT1D; } else if (!strcmp(str, "Format2")) { - return SRSLTE_DCI_FORMAT2; + return SRSRAN_DCI_FORMAT2; } else if (!strcmp(str, "Format2A")) { - return SRSLTE_DCI_FORMAT2A; + return SRSRAN_DCI_FORMAT2A; } else if (!strcmp(str, "Format2B")) { - return SRSLTE_DCI_FORMAT2B; + return SRSRAN_DCI_FORMAT2B; } else if (!strcmp(str, "FormatN0")) { - return SRSLTE_DCI_FORMATN0; + return SRSRAN_DCI_FORMATN0; } else if (!strcmp(str, "FormatN1")) { - return SRSLTE_DCI_FORMATN1; + return SRSRAN_DCI_FORMATN1; } else if (!strcmp(str, "FormatN2")) { - return SRSLTE_DCI_FORMATN2; + return SRSRAN_DCI_FORMATN2; } else { - return SRSLTE_DCI_NOF_FORMATS; + return SRSRAN_DCI_NOF_FORMATS; } } -char* srslte_dci_format_string(srslte_dci_format_t format) +char* srsran_dci_format_string(srsran_dci_format_t format) { switch (format) { - case SRSLTE_DCI_FORMAT0: + case SRSRAN_DCI_FORMAT0: return "Format0 "; - case SRSLTE_DCI_FORMAT1: + case SRSRAN_DCI_FORMAT1: return "Format1 "; - case SRSLTE_DCI_FORMAT1A: + case SRSRAN_DCI_FORMAT1A: return "Format1A"; - case SRSLTE_DCI_FORMAT1B: + case SRSRAN_DCI_FORMAT1B: return "Format1B"; - case SRSLTE_DCI_FORMAT1C: + case SRSRAN_DCI_FORMAT1C: return "Format1C"; - case SRSLTE_DCI_FORMAT1D: + case SRSRAN_DCI_FORMAT1D: return "Format1D"; - case SRSLTE_DCI_FORMAT2: + case SRSRAN_DCI_FORMAT2: return "Format2 "; - case SRSLTE_DCI_FORMAT2A: + case SRSRAN_DCI_FORMAT2A: return "Format2A"; - case SRSLTE_DCI_FORMAT2B: + case SRSRAN_DCI_FORMAT2B: return "Format2B"; - case SRSLTE_DCI_FORMATN0: + case SRSRAN_DCI_FORMATN0: return "FormatN0"; - case SRSLTE_DCI_FORMATN1: + case SRSRAN_DCI_FORMATN1: return "FormatN1"; - case SRSLTE_DCI_FORMATN2: + case SRSRAN_DCI_FORMATN2: return "FormatN2"; default: return "N/A"; // fatal error } } -char* srslte_dci_format_string_short(srslte_dci_format_t format) +char* srsran_dci_format_string_short(srsran_dci_format_t format) { switch (format) { - case SRSLTE_DCI_FORMAT0: + case SRSRAN_DCI_FORMAT0: return "0"; - case SRSLTE_DCI_FORMAT1: + case SRSRAN_DCI_FORMAT1: return "1"; - case SRSLTE_DCI_FORMAT1A: + case SRSRAN_DCI_FORMAT1A: return "1A"; - case SRSLTE_DCI_FORMAT1B: + case SRSRAN_DCI_FORMAT1B: return "1B"; - case SRSLTE_DCI_FORMAT1C: + case SRSRAN_DCI_FORMAT1C: return "1C"; - case SRSLTE_DCI_FORMAT1D: + case SRSRAN_DCI_FORMAT1D: return "1D"; - case SRSLTE_DCI_FORMAT2: + case SRSRAN_DCI_FORMAT2: return "2"; - case SRSLTE_DCI_FORMAT2A: + case SRSRAN_DCI_FORMAT2A: return "2A"; - case SRSLTE_DCI_FORMAT2B: + case SRSRAN_DCI_FORMAT2B: return "2B"; default: return "N/A"; // fatal error } } -static char* ra_type_string(srslte_ra_type_t alloc_type) +static char* ra_type_string(srsran_ra_type_t alloc_type) { switch (alloc_type) { - case SRSLTE_RA_ALLOC_TYPE0: + case SRSRAN_RA_ALLOC_TYPE0: return "Type 0"; - case SRSLTE_RA_ALLOC_TYPE1: + case SRSRAN_RA_ALLOC_TYPE1: return "Type 1"; - case SRSLTE_RA_ALLOC_TYPE2: + case SRSRAN_RA_ALLOC_TYPE2: return "Type 2"; default: return "N/A"; @@ -1540,22 +1540,22 @@ static char* freq_hop_fl_string(int freq_hop) return "n/a"; } -void srslte_dci_dl_fprint(FILE* f, srslte_dci_dl_t* dci, uint32_t nof_prb) +void srsran_dci_dl_fprint(FILE* f, srsran_dci_dl_t* dci, uint32_t nof_prb) { fprintf(f, " - Resource Allocation Type:\t\t%s\n", ra_type_string(dci->alloc_type)); switch (dci->alloc_type) { - case SRSLTE_RA_ALLOC_TYPE0: - fprintf(f, " + Resource Block Group Size:\t\t%d\n", srslte_ra_type0_P(nof_prb)); + case SRSRAN_RA_ALLOC_TYPE0: + fprintf(f, " + Resource Block Group Size:\t\t%d\n", srsran_ra_type0_P(nof_prb)); fprintf(f, " + RBG Bitmap:\t\t\t0x%x\n", dci->type0_alloc.rbg_bitmask); break; - case SRSLTE_RA_ALLOC_TYPE1: - fprintf(f, " + Resource Block Group Size:\t\t%d\n", srslte_ra_type0_P(nof_prb)); + case SRSRAN_RA_ALLOC_TYPE1: + fprintf(f, " + Resource Block Group Size:\t\t%d\n", srsran_ra_type0_P(nof_prb)); fprintf(f, " + RBG Bitmap:\t\t\t0x%x\n", dci->type1_alloc.vrb_bitmask); fprintf(f, " + RBG Subset:\t\t\t%d\n", dci->type1_alloc.rbg_subset); fprintf(f, " + RBG Shift:\t\t\t\t%s\n", dci->type1_alloc.shift ? "Yes" : "No"); break; - case SRSLTE_RA_ALLOC_TYPE2: - fprintf(f, " + Type:\t\t\t\t%s\n", dci->type2_alloc.mode == SRSLTE_RA_TYPE2_LOC ? "Localized" : "Distributed"); + case SRSRAN_RA_ALLOC_TYPE2: + fprintf(f, " + Type:\t\t\t\t%s\n", dci->type2_alloc.mode == SRSRAN_RA_TYPE2_LOC ? "Localized" : "Distributed"); fprintf(f, " + Resource Indicator Value:\t\t%d\n", dci->type2_alloc.riv); break; } @@ -1566,9 +1566,9 @@ void srslte_dci_dl_fprint(FILE* f, srslte_dci_dl_t* dci, uint32_t nof_prb) fprintf(f, " - TPC command for PUCCH:\t\t--\n"); fprintf(f, " - Transport blocks swapped:\t\t%s\n", (dci->tb_cw_swap) ? "true" : "false"); - for (uint32_t i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { - fprintf(f, " - Transport block %d enabled:\t\t%s\n", i, SRSLTE_DCI_IS_TB_EN(dci->tb[i]) ? "true" : "false"); - if (SRSLTE_DCI_IS_TB_EN(dci->tb[i])) { + for (uint32_t i = 0; i < SRSRAN_MAX_CODEWORDS; i++) { + fprintf(f, " - Transport block %d enabled:\t\t%s\n", i, SRSRAN_DCI_IS_TB_EN(dci->tb[i]) ? "true" : "false"); + if (SRSRAN_DCI_IS_TB_EN(dci->tb[i])) { fprintf(f, " + Modulation and coding scheme index:\t%d\n", dci->tb[i].mcs_idx); fprintf(f, " + New data indicator:\t\t\t%s\n", dci->tb[i].ndi ? "Yes" : "No"); fprintf(f, " + Redundancy version:\t\t\t%d\n", dci->tb[i].rv); @@ -1576,52 +1576,52 @@ void srslte_dci_dl_fprint(FILE* f, srslte_dci_dl_t* dci, uint32_t nof_prb) } } -static uint32_t print_multi(char* info_str, uint32_t n, uint32_t len, const srslte_dci_dl_t* dci_dl, uint32_t value_id) +static uint32_t print_multi(char* info_str, uint32_t n, uint32_t len, const srsran_dci_dl_t* dci_dl, uint32_t value_id) { uint32_t nof_tb = 1; - if (dci_dl->format >= SRSLTE_DCI_FORMAT2) { + if (dci_dl->format >= SRSRAN_DCI_FORMAT2) { nof_tb = 2; } for (uint32_t i = 0; i < nof_tb; i++) { switch (value_id) { case 0: - n = srslte_print_check(info_str, len, n, "%d", dci_dl->tb[i].mcs_idx); + n = srsran_print_check(info_str, len, n, "%d", dci_dl->tb[i].mcs_idx); break; case 1: - n = srslte_print_check(info_str, len, n, "%d", dci_dl->tb[i].rv); + n = srsran_print_check(info_str, len, n, "%d", dci_dl->tb[i].rv); break; case 2: - n = srslte_print_check(info_str, len, n, "%d", dci_dl->tb[i].ndi); + n = srsran_print_check(info_str, len, n, "%d", dci_dl->tb[i].ndi); break; } - if (i < SRSLTE_MAX_CODEWORDS - 1 && nof_tb > 1) { - n = srslte_print_check(info_str, len, n, "/"); + if (i < SRSRAN_MAX_CODEWORDS - 1 && nof_tb > 1) { + n = srsran_print_check(info_str, len, n, "/"); } } return n; } -uint32_t srslte_dci_dl_info(const srslte_dci_dl_t* dci_dl, char* info_str, uint32_t len) +uint32_t srsran_dci_dl_info(const srsran_dci_dl_t* dci_dl, char* info_str, uint32_t len) { uint32_t n = 0; - n = srslte_print_check(info_str, + n = srsran_print_check(info_str, len, 0, "f=%s, cce=%2d, L=%d", - srslte_dci_format_string_short(dci_dl->format), + srsran_dci_format_string_short(dci_dl->format), dci_dl->location.ncce, dci_dl->location.L); if (dci_dl->cif_present) { - n = srslte_print_check(info_str, len, n, ", cif=%d", dci_dl->cif); + n = srsran_print_check(info_str, len, n, ", cif=%d", dci_dl->cif); } switch (dci_dl->alloc_type) { - case SRSLTE_RA_ALLOC_TYPE0: - n = srslte_print_check(info_str, len, n, ", rbg=0x%x", dci_dl->type0_alloc.rbg_bitmask); + case SRSRAN_RA_ALLOC_TYPE0: + n = srsran_print_check(info_str, len, n, ", rbg=0x%x", dci_dl->type0_alloc.rbg_bitmask); break; - case SRSLTE_RA_ALLOC_TYPE1: - n = srslte_print_check(info_str, + case SRSRAN_RA_ALLOC_TYPE1: + n = srsran_print_check(info_str, len, n, ", vrb=0x%x, rbg_s=%d, sh=%d", @@ -1629,53 +1629,53 @@ uint32_t srslte_dci_dl_info(const srslte_dci_dl_t* dci_dl, char* info_str, uint3 dci_dl->type1_alloc.rbg_subset, dci_dl->type1_alloc.shift); break; - case SRSLTE_RA_ALLOC_TYPE2: - n = srslte_print_check(info_str, len, n, ", riv=%d", dci_dl->type2_alloc.riv); + case SRSRAN_RA_ALLOC_TYPE2: + n = srsran_print_check(info_str, len, n, ", riv=%d", dci_dl->type2_alloc.riv); break; } - n = srslte_print_check(info_str, len, n, ", pid=%d", dci_dl->pid); + n = srsran_print_check(info_str, len, n, ", pid=%d", dci_dl->pid); - n = srslte_print_check(info_str, len, n, ", mcs={", 0); + n = srsran_print_check(info_str, len, n, ", mcs={", 0); n = print_multi(info_str, n, len, dci_dl, 0); - n = srslte_print_check(info_str, len, n, "}", 0); - n = srslte_print_check(info_str, len, n, ", ndi={", 0); + n = srsran_print_check(info_str, len, n, "}", 0); + n = srsran_print_check(info_str, len, n, ", ndi={", 0); n = print_multi(info_str, n, len, dci_dl, 2); - n = srslte_print_check(info_str, len, n, "}", 0); + n = srsran_print_check(info_str, len, n, "}", 0); - if (dci_dl->format == SRSLTE_DCI_FORMAT1 || dci_dl->format == SRSLTE_DCI_FORMAT1A || - dci_dl->format == SRSLTE_DCI_FORMAT1B || dci_dl->format == SRSLTE_DCI_FORMAT2 || - dci_dl->format == SRSLTE_DCI_FORMAT2A || dci_dl->format == SRSLTE_DCI_FORMAT2B) { - n = srslte_print_check(info_str, len, n, ", tpc_pucch=%d", dci_dl->tpc_pucch); + if (dci_dl->format == SRSRAN_DCI_FORMAT1 || dci_dl->format == SRSRAN_DCI_FORMAT1A || + dci_dl->format == SRSRAN_DCI_FORMAT1B || dci_dl->format == SRSRAN_DCI_FORMAT2 || + dci_dl->format == SRSRAN_DCI_FORMAT2A || dci_dl->format == SRSRAN_DCI_FORMAT2B) { + n = srsran_print_check(info_str, len, n, ", tpc_pucch=%d", dci_dl->tpc_pucch); } if (dci_dl->is_tdd) { - n = srslte_print_check(info_str, len, n, ", dai=%d", dci_dl->dai); + n = srsran_print_check(info_str, len, n, ", dai=%d", dci_dl->dai); } - if (dci_dl->format == SRSLTE_DCI_FORMAT2 || dci_dl->format == SRSLTE_DCI_FORMAT2A || - dci_dl->format == SRSLTE_DCI_FORMAT2B) { - n = srslte_print_check(info_str, len, n, ", tb_sw=%d, pinfo=%d", dci_dl->tb_cw_swap, dci_dl->pinfo); + if (dci_dl->format == SRSRAN_DCI_FORMAT2 || dci_dl->format == SRSRAN_DCI_FORMAT2A || + dci_dl->format == SRSRAN_DCI_FORMAT2B) { + n = srsran_print_check(info_str, len, n, ", tb_sw=%d, pinfo=%d", dci_dl->tb_cw_swap, dci_dl->pinfo); } -#if SRSLTE_DCI_HEXDEBUG - n = srslte_print_check(info_str, len, n, ", len=%d, hex=%s", dci_dl->nof_bits, dci_dl->hex_str); -#endif /* SRSLTE_DCI_HEXDEBUG */ +#if SRSRAN_DCI_HEXDEBUG + n = srsran_print_check(info_str, len, n, ", len=%d, hex=%s", dci_dl->nof_bits, dci_dl->hex_str); +#endif /* SRSRAN_DCI_HEXDEBUG */ return n; } -uint32_t srslte_dci_ul_info(srslte_dci_ul_t* dci_ul, char* info_str, uint32_t len) +uint32_t srsran_dci_ul_info(srsran_dci_ul_t* dci_ul, char* info_str, uint32_t len) { uint32_t n = 0; - n = srslte_print_check(info_str, len, n, "f=0, "); + n = srsran_print_check(info_str, len, n, "f=0, "); if (dci_ul->cif_present) { - n = srslte_print_check(info_str, len, n, "cif=%d, ", dci_ul->cif); + n = srsran_print_check(info_str, len, n, "cif=%d, ", dci_ul->cif); } - n = srslte_print_check(info_str, + n = srsran_print_check(info_str, len, n, "cce=%2d, L=%d, riv=%d, mcs=%d, rv=%d, ndi=%d, f_h=%s, cqi=%s, tpc_pusch=%d, dmrs_cs=%d", @@ -1691,48 +1691,48 @@ uint32_t srslte_dci_ul_info(srslte_dci_ul_t* dci_ul, char* info_str, uint32_t le dci_ul->n_dmrs); if (dci_ul->multiple_csi_request_present) { - n = srslte_print_check(info_str, len, n, ", csi=%d", dci_ul->multiple_csi_request); + n = srsran_print_check(info_str, len, n, ", csi=%d", dci_ul->multiple_csi_request); } if (dci_ul->srs_request_present) { - n = srslte_print_check(info_str, len, n, ", srs_request=%s", dci_ul->srs_request ? "yes" : "no"); + n = srsran_print_check(info_str, len, n, ", srs_request=%s", dci_ul->srs_request ? "yes" : "no"); } if (dci_ul->ra_type_present) { - n = srslte_print_check(info_str, len, n, ", ra_type=%s", dci_ul->ra_type ? "yes" : "no"); + n = srsran_print_check(info_str, len, n, ", ra_type=%s", dci_ul->ra_type ? "yes" : "no"); } if (dci_ul->is_tdd) { - n = srslte_print_check(info_str, len, n, ", ul_idx=%d, dai=%d", dci_ul->ul_idx, dci_ul->dai); + n = srsran_print_check(info_str, len, n, ", ul_idx=%d, dai=%d", dci_ul->ul_idx, dci_ul->dai); } -#if SRSLTE_DCI_HEXDEBUG - n = srslte_print_check(info_str, len, n, ", len=%d, hex=%s", dci_ul->nof_bits, dci_ul->hex_str); -#endif /* SRSLTE_DCI_HEXDEBUG */ +#if SRSRAN_DCI_HEXDEBUG + n = srsran_print_check(info_str, len, n, ", len=%d, hex=%s", dci_ul->nof_bits, dci_ul->hex_str); +#endif /* SRSRAN_DCI_HEXDEBUG */ return n; } -uint32_t srslte_dci_format_max_tb(srslte_dci_format_t format) +uint32_t srsran_dci_format_max_tb(srsran_dci_format_t format) { uint32_t ret = 0; switch (format) { - case SRSLTE_DCI_FORMAT0: - case SRSLTE_DCI_FORMAT1: - case SRSLTE_DCI_FORMAT1A: - case SRSLTE_DCI_FORMAT1C: - case SRSLTE_DCI_FORMAT1B: - case SRSLTE_DCI_FORMAT1D: - case SRSLTE_DCI_FORMATN0: - case SRSLTE_DCI_FORMATN1: - case SRSLTE_DCI_FORMATN2: - case SRSLTE_DCI_FORMAT_RAR: + case SRSRAN_DCI_FORMAT0: + case SRSRAN_DCI_FORMAT1: + case SRSRAN_DCI_FORMAT1A: + case SRSRAN_DCI_FORMAT1C: + case SRSRAN_DCI_FORMAT1B: + case SRSRAN_DCI_FORMAT1D: + case SRSRAN_DCI_FORMATN0: + case SRSRAN_DCI_FORMATN1: + case SRSRAN_DCI_FORMATN2: + case SRSRAN_DCI_FORMAT_RAR: ret = 1; break; - case SRSLTE_DCI_FORMAT2: - case SRSLTE_DCI_FORMAT2A: - case SRSLTE_DCI_FORMAT2B: + case SRSRAN_DCI_FORMAT2: + case SRSRAN_DCI_FORMAT2A: + case SRSRAN_DCI_FORMAT2B: ret = 2; break; - case SRSLTE_DCI_NOF_FORMATS: + case SRSRAN_DCI_NOF_FORMATS: default: ret = 0; break; diff --git a/lib/src/phy/phch/dci_nbiot.c b/lib/src/phy/phch/dci_nbiot.c index 37135a0b2..c0cedc535 100644 --- a/lib/src/phy/phch/dci_nbiot.c +++ b/lib/src/phy/phch/dci_nbiot.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -19,126 +19,126 @@ #include #include -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/phch/dci_nbiot.h" -#include "srslte/phy/utils/bit.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/phch/dci_nbiot.h" +#include "srsran/phy/utils/bit.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" /* Creates the UL NPUSCH resource allocation grant from the random access respone message */ -int srslte_nbiot_dci_rar_to_ul_grant(srslte_nbiot_dci_rar_grant_t* rar, - srslte_ra_nbiot_ul_grant_t* grant, +int srsran_nbiot_dci_rar_to_ul_grant(srsran_nbiot_dci_rar_grant_t* rar, + srsran_ra_nbiot_ul_grant_t* grant, uint32_t rx_tti) { // create DCI from rar grant - srslte_ra_nbiot_ul_dci_t dci; - bzero(&dci, sizeof(srslte_ra_nbiot_ul_dci_t)); + srsran_ra_nbiot_ul_dci_t dci; + bzero(&dci, sizeof(srsran_ra_nbiot_ul_dci_t)); dci.i_rep = rar->n_rep; dci.i_sc = rar->i_sc; dci.i_mcs = rar->i_mcs; dci.i_delay = rar->i_delay; - dci.sc_spacing = (rar->sc_spacing == 1) ? SRSLTE_NPUSCH_SC_SPACING_15000 : SRSLTE_NPUSCH_SC_SPACING_3750; + dci.sc_spacing = (rar->sc_spacing == 1) ? SRSRAN_NPUSCH_SC_SPACING_15000 : SRSRAN_NPUSCH_SC_SPACING_3750; // use DCI to fill default UL grant values - grant->format = SRSLTE_NPUSCH_FORMAT1; // UL-SCH is always format 1 - if (srslte_ra_nbiot_ul_rar_dci_to_grant(&dci, grant, rx_tti)) { + grant->format = SRSRAN_NPUSCH_FORMAT1; // UL-SCH is always format 1 + if (srsran_ra_nbiot_ul_rar_dci_to_grant(&dci, grant, rx_tti)) { fprintf(stderr, "Error converting RAR DCI to grant.\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (SRSLTE_VERBOSE_ISINFO()) { - srslte_ra_nbiot_ul_grant_fprint(stdout, grant); + if (SRSRAN_VERBOSE_ISINFO()) { + srsran_ra_nbiot_ul_grant_fprint(stdout, grant); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } /* Unpack RAR UL grant as defined in Section 16.3.3 of 36.213 */ -void srslte_nbiot_dci_rar_grant_unpack(srslte_nbiot_dci_rar_grant_t* rar, - const uint8_t grant[SRSLTE_NBIOT_RAR_GRANT_LEN]) +void srsran_nbiot_dci_rar_grant_unpack(srsran_nbiot_dci_rar_grant_t* rar, + const uint8_t grant[SRSRAN_NBIOT_RAR_GRANT_LEN]) { uint8_t* grant_ptr = (uint8_t*)grant; - rar->sc_spacing = srslte_bit_pack(&grant_ptr, 1); - rar->i_sc = srslte_bit_pack(&grant_ptr, 6); - rar->i_delay = srslte_bit_pack(&grant_ptr, 2); - rar->n_rep = srslte_bit_pack(&grant_ptr, 3); - rar->i_mcs = srslte_bit_pack(&grant_ptr, 3); + rar->sc_spacing = srsran_bit_pack(&grant_ptr, 1); + rar->i_sc = srsran_bit_pack(&grant_ptr, 6); + rar->i_delay = srsran_bit_pack(&grant_ptr, 2); + rar->n_rep = srsran_bit_pack(&grant_ptr, 3); + rar->i_mcs = srsran_bit_pack(&grant_ptr, 3); } // Creates the UL NPUSCH resource allocation grant from a DCI format N0 message -int srslte_nbiot_dci_msg_to_ul_grant(const srslte_dci_msg_t* msg, - srslte_ra_nbiot_ul_dci_t* ul_dci, - srslte_ra_nbiot_ul_grant_t* grant, +int srsran_nbiot_dci_msg_to_ul_grant(const srsran_dci_msg_t* msg, + srsran_ra_nbiot_ul_dci_t* ul_dci, + srsran_ra_nbiot_ul_grant_t* grant, const uint32_t rx_tti, - const srslte_npusch_sc_spacing_t spacing) + const srsran_npusch_sc_spacing_t spacing) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (msg != NULL && ul_dci != NULL && grant != NULL) { - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; - bzero(ul_dci, sizeof(srslte_ra_nbiot_ul_dci_t)); - bzero(grant, sizeof(srslte_ra_nbiot_ul_grant_t)); + bzero(ul_dci, sizeof(srsran_ra_nbiot_ul_dci_t)); + bzero(grant, sizeof(srsran_ra_nbiot_ul_grant_t)); - if (srslte_dci_msg_unpack_npusch(msg, ul_dci)) { + if (srsran_dci_msg_unpack_npusch(msg, ul_dci)) { return ret; } - if (srslte_ra_nbiot_ul_dci_to_grant(ul_dci, grant, rx_tti, spacing)) { + if (srsran_ra_nbiot_ul_dci_to_grant(ul_dci, grant, rx_tti, spacing)) { return ret; } - if (SRSLTE_VERBOSE_ISINFO()) { - srslte_ra_npusch_fprint(stdout, ul_dci); - srslte_ra_nbiot_ul_grant_fprint(stdout, grant); + if (SRSRAN_VERBOSE_ISINFO()) { + srsran_ra_npusch_fprint(stdout, ul_dci); + srsran_ra_nbiot_ul_grant_fprint(stdout, grant); } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } /* Unpacks a NB-IoT DCI message and configures the DL grant object */ -int srslte_nbiot_dci_msg_to_dl_grant(const srslte_dci_msg_t* msg, +int srsran_nbiot_dci_msg_to_dl_grant(const srsran_dci_msg_t* msg, const uint16_t msg_rnti, - srslte_ra_nbiot_dl_dci_t* dl_dci, - srslte_ra_nbiot_dl_grant_t* grant, + srsran_ra_nbiot_dl_dci_t* dl_dci, + srsran_ra_nbiot_dl_grant_t* grant, const uint32_t sfn, const uint32_t sf_idx, const uint32_t r_max, - const srslte_nbiot_mode_t mode) + const srsran_nbiot_mode_t mode) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (msg != NULL && grant != NULL && dl_dci != NULL) { - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; - bzero(dl_dci, sizeof(srslte_ra_nbiot_dl_dci_t)); - bzero(grant, sizeof(srslte_ra_nbiot_dl_grant_t)); + bzero(dl_dci, sizeof(srsran_ra_nbiot_dl_dci_t)); + bzero(grant, sizeof(srsran_ra_nbiot_dl_grant_t)); bool crc_is_crnti = false; - if (msg_rnti >= SRSLTE_CRNTI_START && msg_rnti <= SRSLTE_CRNTI_END) { + if (msg_rnti >= SRSRAN_CRNTI_START && msg_rnti <= SRSRAN_CRNTI_END) { crc_is_crnti = true; } - srslte_dci_format_t tmp = msg->format; - ret = srslte_dci_msg_unpack_npdsch(msg, dl_dci, crc_is_crnti); + srsran_dci_format_t tmp = msg->format; + ret = srsran_dci_msg_unpack_npdsch(msg, dl_dci, crc_is_crnti); if (ret) { - fprintf(stderr, "Can't unpack DCI message %s (%d)\n", srslte_dci_format_string(tmp), tmp); + fprintf(stderr, "Can't unpack DCI message %s (%d)\n", srsran_dci_format_string(tmp), tmp); return ret; } - ret = srslte_ra_nbiot_dl_dci_to_grant(dl_dci, grant, sfn, sf_idx, r_max, false, mode); + ret = srsran_ra_nbiot_dl_dci_to_grant(dl_dci, grant, sfn, sf_idx, r_max, false, mode); if (ret) { - fprintf(stderr, "Can't convert DCI %s to grant (%d)\n", srslte_dci_format_string(tmp), tmp); + fprintf(stderr, "Can't convert DCI %s to grant (%d)\n", srsran_dci_format_string(tmp), tmp); return ret; } - if (SRSLTE_VERBOSE_ISINFO()) { - srslte_nbiot_dl_dci_fprint(stdout, dl_dci); - srslte_ra_nbiot_dl_grant_fprint(stdout, grant); + if (SRSRAN_VERBOSE_ISINFO()) { + srsran_nbiot_dl_dci_fprint(stdout, dl_dci); + srsran_ra_nbiot_dl_grant_fprint(stdout, grant); } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } @@ -148,7 +148,7 @@ int srslte_nbiot_dci_msg_to_dl_grant(const srslte_dci_msg_t* msg, // #1 1 0 0 // #2 1 0 1 // #3 2 1 0 -bool srslte_nbiot_dci_location_isvalid(const srslte_dci_location_t* c) +bool srsran_nbiot_dci_location_isvalid(const srsran_dci_location_t* c) { if ((c->L == 1 && c->ncce <= 1) || (c->L == 2 && c->ncce == 0)) { return true; @@ -178,7 +178,7 @@ uint32_t dci_formatN2_sizeof() * * TODO: TPC and cyclic shift for DM RS not implemented */ -int dci_formatN0_pack(srslte_ra_nbiot_ul_dci_t* data, srslte_dci_msg_t* msg, uint32_t nof_prb) +int dci_formatN0_pack(srsran_ra_nbiot_ul_dci_t* data, srsran_dci_msg_t* msg, uint32_t nof_prb) { // pack bits uint8_t* y = msg->payload; @@ -203,7 +203,7 @@ int dci_formatN0_pack(srslte_ra_nbiot_ul_dci_t* data, srslte_dci_msg_t* msg, uin // DCI subframe repetition number – 2 bits - return SRSLTE_ERROR; + return SRSRAN_ERROR; } /* Packs DCI format N1 data to a sequence of bits and store them in msg according @@ -211,7 +211,7 @@ int dci_formatN0_pack(srslte_ra_nbiot_ul_dci_t* data, srslte_dci_msg_t* msg, uin * * TODO: implement packing for NPRACH case */ -int dci_formatN1_pack(const srslte_ra_nbiot_dl_dci_t* data, srslte_dci_msg_t* msg, bool crc_is_crnti) +int dci_formatN1_pack(const srsran_ra_nbiot_dl_dci_t* data, srsran_dci_msg_t* msg, bool crc_is_crnti) { int last_bits_val = 0; uint8_t* y = (uint8_t*)msg->payload; @@ -231,16 +231,16 @@ int dci_formatN1_pack(const srslte_ra_nbiot_dl_dci_t* data, srslte_dci_msg_t* ms // default NPDSCH scheduling // Scheduling delay – 3 bits - srslte_bit_unpack(data->alloc.i_delay, &y, 3); + srsran_bit_unpack(data->alloc.i_delay, &y, 3); // Resource assignment – 3 bits - srslte_bit_unpack(data->alloc.i_sf, &y, 3); + srsran_bit_unpack(data->alloc.i_sf, &y, 3); // Modulation and coding scheme – 4 bits - srslte_bit_unpack(data->mcs_idx, &y, 4); + srsran_bit_unpack(data->mcs_idx, &y, 4); // Repetition number – 4 bits - srslte_bit_unpack(data->alloc.i_rep, &y, 4); + srsran_bit_unpack(data->alloc.i_rep, &y, 4); // New data indicator – 1 bit if (crc_is_crnti) { @@ -254,7 +254,7 @@ int dci_formatN1_pack(const srslte_ra_nbiot_dl_dci_t* data, srslte_dci_msg_t* ms // reserved y += 4; } else { - srslte_bit_unpack(data->alloc.harq_ack, &y, 4); + srsran_bit_unpack(data->alloc.harq_ack, &y, 4); } } @@ -265,75 +265,75 @@ int dci_formatN1_pack(const srslte_ra_nbiot_dl_dci_t* data, srslte_dci_msg_t* ms } msg->nof_bits = (y - msg->payload); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // According to Section 6.4.3.1 in TS36.212 v13.2.0 -int dci_formatN0_unpack(const srslte_dci_msg_t* msg, srslte_ra_nbiot_ul_dci_t* data) +int dci_formatN0_unpack(const srsran_dci_msg_t* msg, srsran_ra_nbiot_ul_dci_t* data) { uint8_t* y = (uint8_t*)msg->payload; // make sure it has the expected length if (msg->nof_bits != dci_formatN1_sizeof()) { fprintf(stderr, "Invalid message length for format N1\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Format differentiation - 1 bit - data->format = srslte_bit_pack(&y, 1); + data->format = srsran_bit_pack(&y, 1); // Subcarrier indication – 6 bits - data->i_sc = srslte_bit_pack(&y, 6); + data->i_sc = srsran_bit_pack(&y, 6); // Resource assignment – 3 bits - data->i_ru = srslte_bit_pack(&y, 3); + data->i_ru = srsran_bit_pack(&y, 3); // Scheduling delay – 2 bits - data->i_delay = srslte_bit_pack(&y, 2); + data->i_delay = srsran_bit_pack(&y, 2); // Modulation and coding scheme – 4 - data->i_mcs = srslte_bit_pack(&y, 4); + data->i_mcs = srsran_bit_pack(&y, 4); // Redundancy version – 1 bit - data->i_rv = srslte_bit_pack(&y, 1); + data->i_rv = srsran_bit_pack(&y, 1); // Repetition number – 3 bits - data->i_rep = srslte_bit_pack(&y, 3); + data->i_rep = srsran_bit_pack(&y, 3); // New data indicator – 1 bit - data->ndi = srslte_bit_pack(&y, 1); + data->ndi = srsran_bit_pack(&y, 1); // DCI subframe repetition number – 2 bits - data->dci_sf_rep_num = srslte_bit_pack(&y, 2); + data->dci_sf_rep_num = srsran_bit_pack(&y, 2); // According to 16.5.1.1, SC spacing is determined by RAR grant // TODO: Add support for 3.75kHz - data->sc_spacing = SRSLTE_NPUSCH_SC_SPACING_15000; + data->sc_spacing = SRSRAN_NPUSCH_SC_SPACING_15000; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int dci_formatN1_unpack(const srslte_dci_msg_t* msg, srslte_ra_nbiot_dl_dci_t* data, bool crc_is_crnti) +int dci_formatN1_unpack(const srsran_dci_msg_t* msg, srsran_ra_nbiot_dl_dci_t* data, bool crc_is_crnti) { uint8_t* y = (uint8_t*)msg->payload; // make sure it has the expected length if (msg->nof_bits != dci_formatN1_sizeof()) { fprintf(stderr, "Invalid message length for format N1\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Format differentiation - 1 bit - data->format = srslte_bit_pack(&y, 1); + data->format = srsran_bit_pack(&y, 1); data->dci_is_n2 = false; // The NPDCCH order indicator (if bit is one, this is for RA procedure) - data->alloc.is_ra = srslte_bit_pack(&y, 1); + data->alloc.is_ra = srsran_bit_pack(&y, 1); if (data->alloc.is_ra) { // This is a RA precedure, set field according to Section 6.4.3.2 in TS36.212 - data->alloc.nprach_start = srslte_bit_pack(&y, 2); - data->alloc.nprach_sc = srslte_bit_pack(&y, 6); + data->alloc.nprach_start = srsran_bit_pack(&y, 2); + data->alloc.nprach_sc = srsran_bit_pack(&y, 6); // set remaining field to 1 data->alloc.i_delay = 0xffff; data->alloc.i_sf = 0xffff; @@ -346,16 +346,16 @@ int dci_formatN1_unpack(const srslte_dci_msg_t* msg, srslte_ra_nbiot_dl_dci_t* d // default NPDSCH scheduling // Scheduling delay – 3 bits - data->alloc.i_delay = srslte_bit_pack(&y, 3); + data->alloc.i_delay = srsran_bit_pack(&y, 3); // Resource assignment – 3 bits - data->alloc.i_sf = srslte_bit_pack(&y, 3); + data->alloc.i_sf = srsran_bit_pack(&y, 3); // Modulation and coding scheme – 4 bits - data->mcs_idx = srslte_bit_pack(&y, 4); + data->mcs_idx = srsran_bit_pack(&y, 4); // Repetition number – 4 bits - data->alloc.i_rep = srslte_bit_pack(&y, 4); + data->alloc.i_rep = srsran_bit_pack(&y, 4); // New data indicator – 1 bit if (crc_is_crnti) { @@ -365,59 +365,59 @@ int dci_formatN1_unpack(const srslte_dci_msg_t* msg, srslte_ra_nbiot_dl_dci_t* d } // HARQ-ACK resource – 4 bits - data->alloc.harq_ack = srslte_bit_pack(&y, 4); + data->alloc.harq_ack = srsran_bit_pack(&y, 4); // DCI subframe repetition number – 2 bits - data->alloc.dci_sf_rep_num = srslte_bit_pack(&y, 2); + data->alloc.dci_sf_rep_num = srsran_bit_pack(&y, 2); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int dci_formatN2_unpack(const srslte_dci_msg_t* msg, srslte_ra_nbiot_dl_dci_t* data) +int dci_formatN2_unpack(const srsran_dci_msg_t* msg, srsran_ra_nbiot_dl_dci_t* data) { uint8_t* y = (uint8_t*)msg->payload; // make sure it has the expected length if (msg->nof_bits != dci_formatN2_sizeof()) { fprintf(stderr, "Invalid message length for format N2\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } data->dci_is_n2 = true; // Flag for paging/direct indication differentiation – 1 bit, with value 0 for direct indication and value 1 for // paging - data->format = srslte_bit_pack(&y, 1); + data->format = srsran_bit_pack(&y, 1); if (data->format == 0) { // Direct Indication information – 8 bits provide direct indication of system information update and other fields - data->dir_indication_info = srslte_bit_pack(&y, 8); + data->dir_indication_info = srsran_bit_pack(&y, 8); } else { // Paging // Resource assignment – 3 bits - data->alloc.i_sf = srslte_bit_pack(&y, 3); + data->alloc.i_sf = srsran_bit_pack(&y, 3); // Modulation and coding scheme – 4 bits - data->mcs_idx = srslte_bit_pack(&y, 4); + data->mcs_idx = srsran_bit_pack(&y, 4); // Repetition number – 4 bits - data->alloc.i_rep = srslte_bit_pack(&y, 4); + data->alloc.i_rep = srsran_bit_pack(&y, 4); // DCI subframe repetition number – 3 bits - data->alloc.dci_sf_rep_num = srslte_bit_pack(&y, 3); + data->alloc.dci_sf_rep_num = srsran_bit_pack(&y, 3); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -uint32_t srslte_dci_nbiot_format_sizeof(const srslte_dci_format_t format) +uint32_t srsran_dci_nbiot_format_sizeof(const srsran_dci_format_t format) { switch (format) { - case SRSLTE_DCI_FORMATN0: + case SRSRAN_DCI_FORMATN0: return dci_formatN0_sizeof(); - case SRSLTE_DCI_FORMATN1: + case SRSRAN_DCI_FORMATN1: return dci_formatN1_sizeof(); - case SRSLTE_DCI_FORMATN2: + case SRSRAN_DCI_FORMATN2: return dci_formatN2_sizeof(); default: printf("Error computing DCI bits: Unknown format %d\n", format); @@ -425,41 +425,41 @@ uint32_t srslte_dci_nbiot_format_sizeof(const srslte_dci_format_t format) } } -int srslte_dci_msg_unpack_npdsch(const srslte_dci_msg_t* msg, srslte_ra_nbiot_dl_dci_t* data, const bool crc_is_crnti) +int srsran_dci_msg_unpack_npdsch(const srsran_dci_msg_t* msg, srsran_ra_nbiot_dl_dci_t* data, const bool crc_is_crnti) { switch (msg->format) { - case SRSLTE_DCI_FORMATN1: + case SRSRAN_DCI_FORMATN1: return dci_formatN1_unpack(msg, data, crc_is_crnti); - case SRSLTE_DCI_FORMATN2: + case SRSRAN_DCI_FORMATN2: return dci_formatN2_unpack(msg, data); default: - fprintf(stderr, "DCI unpack npdsch: Invalid DCI format %s\n", srslte_dci_format_string(msg->format)); - return SRSLTE_ERROR; + fprintf(stderr, "DCI unpack npdsch: Invalid DCI format %s\n", srsran_dci_format_string(msg->format)); + return SRSRAN_ERROR; } } -int srslte_dci_msg_unpack_npusch(const srslte_dci_msg_t* msg, srslte_ra_nbiot_ul_dci_t* data) +int srsran_dci_msg_unpack_npusch(const srsran_dci_msg_t* msg, srsran_ra_nbiot_ul_dci_t* data) { switch (msg->format) { - case SRSLTE_DCI_FORMATN0: + case SRSRAN_DCI_FORMATN0: return dci_formatN0_unpack(msg, data); default: - fprintf(stderr, "DCI unpack npusch: Invalid DCI format %s\n", srslte_dci_format_string(msg->format)); - return SRSLTE_ERROR; + fprintf(stderr, "DCI unpack npusch: Invalid DCI format %s\n", srsran_dci_format_string(msg->format)); + return SRSRAN_ERROR; } } -int srslte_dci_msg_pack_npdsch(const srslte_ra_nbiot_dl_dci_t* data, - const srslte_dci_format_t format, - srslte_dci_msg_t* msg, +int srsran_dci_msg_pack_npdsch(const srsran_ra_nbiot_dl_dci_t* data, + const srsran_dci_format_t format, + srsran_dci_msg_t* msg, const bool crc_is_crnti) { msg->format = format; switch (format) { - case SRSLTE_DCI_FORMATN1: + case SRSRAN_DCI_FORMATN1: return dci_formatN1_pack(data, msg, crc_is_crnti); default: - fprintf(stderr, "DCI pack npdsch: Invalid DCI format %s in \n", srslte_dci_format_string(format)); - return SRSLTE_ERROR; + fprintf(stderr, "DCI pack npdsch: Invalid DCI format %s in \n", srsran_dci_format_string(format)); + return SRSRAN_ERROR; } } diff --git a/lib/src/phy/phch/dci_nr.c b/lib/src/phy/phch/dci_nr.c index 2bb86b332..a6c9b205d 100644 --- a/lib/src/phy/phch/dci_nr.c +++ b/lib/src/phy/phch/dci_nr.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,41 +10,41 @@ * */ -#include "srslte/phy/phch/dci_nr.h" -#include "srslte/phy/utils/bit.h" -#include "srslte/phy/utils/debug.h" +#include "srsran/phy/phch/dci_nr.h" +#include "srsran/phy/utils/bit.h" +#include "srsran/phy/utils/debug.h" -static int dci_nr_format_0_0_freq_resource_size(const srslte_carrier_nr_t* carrier) +static int dci_nr_format_0_0_freq_resource_size(const srsran_carrier_nr_t* carrier) { if (carrier == NULL) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } return (int)ceil(log2(carrier->nof_prb * (carrier->nof_prb + 1) / 2.0)); } -static int dci_nr_format_1_0_freq_resource_size(const srslte_carrier_nr_t* carrier, - const srslte_coreset_t* coreset0, - srslte_rnti_type_t rnti_type) +static int dci_nr_format_1_0_freq_resource_size(const srsran_carrier_nr_t* carrier, + const srsran_coreset_t* coreset0, + srsran_rnti_type_t rnti_type) { if (carrier == NULL) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } uint32_t N_DL_BWP_RB = carrier->nof_prb; - if (rnti_type == srslte_rnti_type_ra && coreset0 != NULL) { - N_DL_BWP_RB = srslte_coreset_get_bw(coreset0); - } else if (rnti_type == srslte_rnti_type_p || rnti_type == srslte_rnti_type_si) { + if (rnti_type == srsran_rnti_type_ra && coreset0 != NULL) { + N_DL_BWP_RB = srsran_coreset_get_bw(coreset0); + } else if (rnti_type == srsran_rnti_type_p || rnti_type == srsran_rnti_type_si) { if (coreset0 == NULL) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - N_DL_BWP_RB = srslte_coreset_get_bw(coreset0); + N_DL_BWP_RB = srsran_coreset_get_bw(coreset0); } return (int)ceil(log2(N_DL_BWP_RB * (N_DL_BWP_RB + 1) / 2.0)); } -bool srslte_dci_nr_format_1_0_valid(const srslte_dci_msg_nr_t* dci) +bool srsran_dci_nr_format_1_0_valid(const srsran_dci_msg_nr_t* dci) { // Check pointer if (dci == NULL) { @@ -52,12 +52,12 @@ bool srslte_dci_nr_format_1_0_valid(const srslte_dci_msg_nr_t* dci) } // Wrong format - if (dci->format != srslte_dci_format_nr_1_0) { + if (dci->format != srsran_dci_format_nr_1_0) { return false; } // The format bit is only present for these RNTI - if (dci->rnti_type == srslte_rnti_type_c || dci->rnti_type == srslte_rnti_type_tc) { + if (dci->rnti_type == srsran_rnti_type_c || dci->rnti_type == srsran_rnti_type_tc) { return dci->payload[0] == 1; } @@ -65,10 +65,10 @@ bool srslte_dci_nr_format_1_0_valid(const srslte_dci_msg_nr_t* dci) return true; } -int srslte_dci_nr_pack(const srslte_carrier_nr_t* carrier, - const srslte_coreset_t* coreset, - const srslte_dci_dl_nr_t* dci, - srslte_dci_msg_nr_t* msg) +int srsran_dci_nr_pack(const srsran_carrier_nr_t* carrier, + const srsran_coreset_t* coreset, + const srsran_dci_dl_nr_t* dci, + srsran_dci_msg_nr_t* msg) { // Copy DCI MSG fields msg->location = dci->location; @@ -80,39 +80,39 @@ int srslte_dci_nr_pack(const srslte_carrier_nr_t* carrier, // Pack DCI switch (msg->format) { - case srslte_dci_format_nr_1_0: - if (srslte_dci_nr_format_1_0_pack(carrier, coreset, dci, msg) < SRSLTE_SUCCESS) { + case srsran_dci_format_nr_1_0: + if (srsran_dci_nr_format_1_0_pack(carrier, coreset, dci, msg) < SRSRAN_SUCCESS) { ERROR("Error packing DL DCI"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } break; default: ERROR("Unsupported DCI format %d", msg->format); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_dci_nr_format_0_0_pack(const srslte_carrier_nr_t* carrier, - const srslte_coreset_t* coreset0, - const srslte_dci_ul_nr_t* dci, - srslte_dci_msg_nr_t* msg) +int srsran_dci_nr_format_0_0_pack(const srsran_carrier_nr_t* carrier, + const srsran_coreset_t* coreset0, + const srsran_dci_ul_nr_t* dci, + srsran_dci_msg_nr_t* msg) { uint32_t trim = 0; // hard-coded bit trimming bool enable_hopping = false; // hard-coded PUSCH hopping uint32_t padding = 8; // Hard-coded padding bool supplementary_uplink = false; // Hard-coded supplementary Uplink uint8_t* y = msg->payload; - srslte_rnti_type_t rnti_type = msg->rnti_type; + srsran_rnti_type_t rnti_type = msg->rnti_type; if (carrier == NULL) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Check RNTI type - if (rnti_type != srslte_rnti_type_c && rnti_type != srslte_rnti_type_cs && rnti_type != srslte_rnti_type_mcs_c) { - return SRSLTE_ERROR; + if (rnti_type != srsran_rnti_type_c && rnti_type != srsran_rnti_type_cs && rnti_type != srsran_rnti_type_mcs_c) { + return SRSRAN_ERROR; } // Identifier for DCI formats – 1 bits @@ -121,35 +121,35 @@ int srslte_dci_nr_format_0_0_pack(const srslte_carrier_nr_t* carrier, // For PUSCH hopping with resource allocation type 1 N UL_hop MSB bits are used to indicate the frequency offset int N_UL_hop = (enable_hopping) ? ((carrier->nof_prb < 50) ? 1 : 2) : 0; - srslte_bit_unpack(dci->frequency_offset, &y, N_UL_hop); + srsran_bit_unpack(dci->frequency_offset, &y, N_UL_hop); // Frequency domain resource assignment int N = dci_nr_format_0_0_freq_resource_size(carrier); - if (N < SRSLTE_SUCCESS || N - N_UL_hop <= 0) { - return SRSLTE_ERROR; + if (N < SRSRAN_SUCCESS || N - N_UL_hop <= 0) { + return SRSRAN_ERROR; } - srslte_bit_unpack(dci->freq_domain_assigment, &y, N - N_UL_hop - trim); + srsran_bit_unpack(dci->freq_domain_assigment, &y, N - N_UL_hop - trim); // Time domain resource assignment – 4 bits - srslte_bit_unpack(dci->time_domain_assigment, &y, 4); + srsran_bit_unpack(dci->time_domain_assigment, &y, 4); // Frequency hopping flag – 1 bit - srslte_bit_unpack(dci->freq_hopping_flag, &y, 1); + srsran_bit_unpack(dci->freq_hopping_flag, &y, 1); // Modulation and coding scheme – 5 bits - srslte_bit_unpack(dci->mcs, &y, 5); + srsran_bit_unpack(dci->mcs, &y, 5); // New data indicator – 1 bit - srslte_bit_unpack(dci->ndi, &y, 1); + srsran_bit_unpack(dci->ndi, &y, 1); // Redundancy version – 2 bits - srslte_bit_unpack(dci->rv, &y, 2); + srsran_bit_unpack(dci->rv, &y, 2); // HARQ process number – 4 bits - srslte_bit_unpack(dci->pid, &y, 4); + srsran_bit_unpack(dci->pid, &y, 4); // TPC command for scheduled PUSCH – 2 bits - srslte_bit_unpack(dci->tpc, &y, 2); + srsran_bit_unpack(dci->tpc, &y, 2); // Padding goes here for (uint32_t i = 0; i < padding; i++) { @@ -161,26 +161,26 @@ int srslte_dci_nr_format_0_0_pack(const srslte_carrier_nr_t* carrier, *(y++) = 0; } - msg->nof_bits = srslte_dci_nr_format_0_0_sizeof(carrier, coreset0, rnti_type); + msg->nof_bits = srsran_dci_nr_format_0_0_sizeof(carrier, coreset0, rnti_type); if (msg->nof_bits != y - msg->payload) { ERROR("Unpacked bits read (%d) do NOT match payload size (%d)", msg->nof_bits, (int)(y - msg->payload)); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_dci_nr_format_0_0_unpack(const srslte_carrier_nr_t* carrier, - const srslte_coreset_t* coreset, - srslte_dci_msg_nr_t* msg, - srslte_dci_ul_nr_t* dci) +int srsran_dci_nr_format_0_0_unpack(const srsran_carrier_nr_t* carrier, + const srsran_coreset_t* coreset, + srsran_dci_msg_nr_t* msg, + srsran_dci_ul_nr_t* dci) { uint32_t trim = 0; // hard-coded bit trimming bool enable_hopping = false; // hard-coded PUSCH hopping uint32_t padding = 8; // Hard-coded padding bool supplementary_uplink = false; // Hard-coded supplementary Uplink uint8_t* y = msg->payload; - srslte_rnti_type_t rnti_type = msg->rnti_type; + srsran_rnti_type_t rnti_type = msg->rnti_type; // Copy DCI MSG fields dci->location = msg->location; @@ -191,59 +191,59 @@ int srslte_dci_nr_format_0_0_unpack(const srslte_carrier_nr_t* carrier, dci->format = msg->format; if (carrier == NULL) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Check RNTI type - if (rnti_type != srslte_rnti_type_c && rnti_type != srslte_rnti_type_cs && rnti_type != srslte_rnti_type_mcs_c) { - ERROR("Unsupported %s", srslte_rnti_type_str(rnti_type)); - return SRSLTE_ERROR; + if (rnti_type != srsran_rnti_type_c && rnti_type != srsran_rnti_type_cs && rnti_type != srsran_rnti_type_mcs_c) { + ERROR("Unsupported %s", srsran_rnti_type_str(rnti_type)); + return SRSRAN_ERROR; } - if (msg->nof_bits != srslte_dci_nr_format_0_0_sizeof(carrier, coreset, rnti_type)) { + if (msg->nof_bits != srsran_dci_nr_format_0_0_sizeof(carrier, coreset, rnti_type)) { ERROR("Invalid number of bits %d, expected %d", msg->nof_bits, - srslte_dci_nr_format_0_0_sizeof(carrier, coreset, rnti_type)); - return SRSLTE_ERROR; + srsran_dci_nr_format_0_0_sizeof(carrier, coreset, rnti_type)); + return SRSRAN_ERROR; } // Identifier for DCI formats – 1 bits if (*(y++) != 0) { ERROR("Wrond DCI format"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // For PUSCH hopping with resource allocation type 1 N UL_hop MSB bits are used to indicate the frequency offset int N_UL_hop = (enable_hopping) ? ((carrier->nof_prb < 50) ? 1 : 2) : 0; - dci->frequency_offset = srslte_bit_pack(&y, N_UL_hop); + dci->frequency_offset = srsran_bit_pack(&y, N_UL_hop); // Frequency domain resource assignment int N = dci_nr_format_0_0_freq_resource_size(carrier); - if (N < SRSLTE_SUCCESS || N - N_UL_hop <= 0) { - return SRSLTE_ERROR; + if (N < SRSRAN_SUCCESS || N - N_UL_hop <= 0) { + return SRSRAN_ERROR; } - dci->freq_domain_assigment = srslte_bit_pack(&y, N - N_UL_hop - trim); + dci->freq_domain_assigment = srsran_bit_pack(&y, N - N_UL_hop - trim); // Time domain resource assignment – 4 bits - dci->time_domain_assigment = srslte_bit_pack(&y, 4); + dci->time_domain_assigment = srsran_bit_pack(&y, 4); // Frequency hopping flag – 1 bit - dci->freq_hopping_flag = srslte_bit_pack(&y, 1); + dci->freq_hopping_flag = srsran_bit_pack(&y, 1); // Modulation and coding scheme – 5 bits - dci->mcs = srslte_bit_pack(&y, 5); + dci->mcs = srsran_bit_pack(&y, 5); // New data indicator – 1 bit - dci->ndi = srslte_bit_pack(&y, 1); + dci->ndi = srsran_bit_pack(&y, 1); // Redundancy version – 2 bits - dci->rv = srslte_bit_pack(&y, 2); + dci->rv = srsran_bit_pack(&y, 2); // HARQ process number – 4 bits - dci->pid = srslte_bit_pack(&y, 4); + dci->pid = srsran_bit_pack(&y, 4); // TPC command for scheduled PUSCH – 2 bits - dci->tpc = srslte_bit_pack(&y, 2); + dci->tpc = srsran_bit_pack(&y, 2); // Padding goes here for (uint32_t i = 0; i < padding; i++) { @@ -255,12 +255,12 @@ int srslte_dci_nr_format_0_0_unpack(const srslte_carrier_nr_t* carrier, y++; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_dci_nr_format_0_0_sizeof(const srslte_carrier_nr_t* carrier, - const srslte_coreset_t* coreset, - srslte_rnti_type_t rnti_type) +int srsran_dci_nr_format_0_0_sizeof(const srsran_carrier_nr_t* carrier, + const srsran_coreset_t* coreset, + srsran_rnti_type_t rnti_type) { uint32_t trim = 0; // hard-coded bit trimming bool enable_hopping = false; // hard-coded PUSCH hopping @@ -277,8 +277,8 @@ int srslte_dci_nr_format_0_0_sizeof(const srslte_carrier_nr_t* carrier, // Frequency domain resource assignment int N = dci_nr_format_0_0_freq_resource_size(carrier); - if (N < SRSLTE_SUCCESS || N - N_UL_hop <= 0) { - return SRSLTE_ERROR; + if (N < SRSRAN_SUCCESS || N - N_UL_hop <= 0) { + return SRSRAN_ERROR; } count += N - N_UL_hop - trim; @@ -314,45 +314,45 @@ int srslte_dci_nr_format_0_0_sizeof(const srslte_carrier_nr_t* carrier, return count; } -static int dci_nr_format_0_0_to_str(const srslte_dci_ul_nr_t* dci, char* str, uint32_t str_len) +static int dci_nr_format_0_0_to_str(const srsran_dci_ul_nr_t* dci, char* str, uint32_t str_len) { uint32_t len = 0; // Print format - len = srslte_print_check( + len = srsran_print_check( str, str_len, len, "rnti=%04x L=%d cce=%d dci=0_0 ", dci->rnti, dci->location.L, dci->location.ncce); // Frequency domain resource assignment - len = srslte_print_check(str, str_len, len, "f_alloc=0x%x ", dci->freq_domain_assigment); + len = srsran_print_check(str, str_len, len, "f_alloc=0x%x ", dci->freq_domain_assigment); // Time domain resource assignment – 4 bits - len = srslte_print_check(str, str_len, len, "t_alloc=0x%x ", dci->time_domain_assigment); + len = srsran_print_check(str, str_len, len, "t_alloc=0x%x ", dci->time_domain_assigment); // Frequency hopping flag – 1 bit - len = srslte_print_check(str, str_len, len, "hop=%c ", dci->freq_hopping_flag == 0 ? 'n' : 'y'); + len = srsran_print_check(str, str_len, len, "hop=%c ", dci->freq_hopping_flag == 0 ? 'n' : 'y'); // Modulation and coding scheme – 5 bits - len = srslte_print_check(str, str_len, len, "mcs=%d ", dci->mcs); + len = srsran_print_check(str, str_len, len, "mcs=%d ", dci->mcs); // New data indicator – 1 bit - len = srslte_print_check(str, str_len, len, "ndi=%d ", dci->ndi); + len = srsran_print_check(str, str_len, len, "ndi=%d ", dci->ndi); // Redundancy version – 2 bits - len = srslte_print_check(str, str_len, len, "rv=%d ", dci->rv); + len = srsran_print_check(str, str_len, len, "rv=%d ", dci->rv); // HARQ process number – 4 bits - len = srslte_print_check(str, str_len, len, "harq_id=%d ", dci->harq_feedback); + len = srsran_print_check(str, str_len, len, "harq_id=%d ", dci->harq_feedback); // TPC command for scheduled PUSCH – 2 bits - len = srslte_print_check(str, str_len, len, "tpc=%d ", dci->tpc); + len = srsran_print_check(str, str_len, len, "tpc=%d ", dci->tpc); return len; } -int srslte_dci_nr_rar_unpack(srslte_dci_msg_nr_t* msg, srslte_dci_ul_nr_t* dci) +int srsran_dci_nr_rar_unpack(srsran_dci_msg_nr_t* msg, srsran_dci_ul_nr_t* dci) { if (msg == NULL || dci == NULL) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } uint8_t* y = msg->payload; @@ -366,169 +366,169 @@ int srslte_dci_nr_rar_unpack(srslte_dci_msg_nr_t* msg, srslte_dci_ul_nr_t* dci) dci->format = msg->format; // Frequency hopping flag - 1 bit - dci->freq_hopping_flag = srslte_bit_pack(&y, 1); + dci->freq_hopping_flag = srsran_bit_pack(&y, 1); // PUSCH frequency resource allocation - 14 bits - dci->freq_domain_assigment = srslte_bit_pack(&y, 14); + dci->freq_domain_assigment = srsran_bit_pack(&y, 14); // PUSCH time resource allocation - 4 bits - dci->time_domain_assigment = srslte_bit_pack(&y, 4); + dci->time_domain_assigment = srsran_bit_pack(&y, 4); // MCS -4 bits - dci->mcs = srslte_bit_pack(&y, 4); + dci->mcs = srsran_bit_pack(&y, 4); // TPC command for PUSCH - 3 bits - dci->tpc = srslte_bit_pack(&y, 3); + dci->tpc = srsran_bit_pack(&y, 3); // CSI request - 1 bits - dci->csi_request = srslte_bit_pack(&y, 3); + dci->csi_request = srsran_bit_pack(&y, 3); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -static int dci_nr_rar_to_str(const srslte_dci_ul_nr_t* dci, char* str, uint32_t str_len) +static int dci_nr_rar_to_str(const srsran_dci_ul_nr_t* dci, char* str, uint32_t str_len) { uint32_t len = 0; // Print format - len = srslte_print_check(str, str_len, len, "rnti=%04x dci=rar ", dci->rnti); + len = srsran_print_check(str, str_len, len, "rnti=%04x dci=rar ", dci->rnti); // Frequency hopping flag - len = srslte_print_check(str, str_len, len, "hop=%d ", dci->freq_hopping_flag); + len = srsran_print_check(str, str_len, len, "hop=%d ", dci->freq_hopping_flag); // PUSCH frequency resource allocation - len = srslte_print_check(str, str_len, len, "f_alloc=0x%x ", dci->freq_domain_assigment); + len = srsran_print_check(str, str_len, len, "f_alloc=0x%x ", dci->freq_domain_assigment); // PUSCH time resource allocation - len = srslte_print_check(str, str_len, len, "t_alloc=0x%x ", dci->time_domain_assigment); + len = srsran_print_check(str, str_len, len, "t_alloc=0x%x ", dci->time_domain_assigment); // Modulation and coding scheme - len = srslte_print_check(str, str_len, len, "mcs=%d ", dci->mcs); + len = srsran_print_check(str, str_len, len, "mcs=%d ", dci->mcs); // TPC command for scheduled PUSCH - len = srslte_print_check(str, str_len, len, "tpc=%d ", dci->tpc); + len = srsran_print_check(str, str_len, len, "tpc=%d ", dci->tpc); // CSI request - len = srslte_print_check(str, str_len, len, "csi=%d ", dci->csi_request); + len = srsran_print_check(str, str_len, len, "csi=%d ", dci->csi_request); return len; } -int srslte_dci_nr_format_1_0_pack(const srslte_carrier_nr_t* carrier, - const srslte_coreset_t* coreset, - const srslte_dci_dl_nr_t* dci, - srslte_dci_msg_nr_t* msg) +int srsran_dci_nr_format_1_0_pack(const srsran_carrier_nr_t* carrier, + const srsran_coreset_t* coreset, + const srsran_dci_dl_nr_t* dci, + srsran_dci_msg_nr_t* msg) { uint8_t* y = msg->payload; - srslte_rnti_type_t rnti_type = msg->rnti_type; + srsran_rnti_type_t rnti_type = msg->rnti_type; if (carrier == NULL) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Identifier for DCI formats – 1 bits - if (rnti_type == srslte_rnti_type_c || rnti_type == srslte_rnti_type_tc) { + if (rnti_type == srsran_rnti_type_c || rnti_type == srsran_rnti_type_tc) { *y = 1; y++; } - if (rnti_type == srslte_rnti_type_p) { + if (rnti_type == srsran_rnti_type_p) { // Short Messages Indicator – 2 bits - srslte_bit_unpack(dci->smi, &y, 2); + srsran_bit_unpack(dci->smi, &y, 2); // Short Messages – 8 bits - srslte_bit_unpack(dci->sm, &y, 8); + srsran_bit_unpack(dci->sm, &y, 8); } // Frequency domain resource assignment int N = dci_nr_format_1_0_freq_resource_size(carrier, coreset, rnti_type); - if (N < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (N < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } - srslte_bit_unpack(dci->freq_domain_assigment, &y, N); + srsran_bit_unpack(dci->freq_domain_assigment, &y, N); // Time domain resource assignment – 4 bits - srslte_bit_unpack(dci->time_domain_assigment, &y, 4); + srsran_bit_unpack(dci->time_domain_assigment, &y, 4); // VRB-to-PRB mapping – 1 bit - srslte_bit_unpack(dci->vrb_to_prb_mapping, &y, 1); + srsran_bit_unpack(dci->vrb_to_prb_mapping, &y, 1); // Modulation and coding scheme – 5 bits - srslte_bit_unpack(dci->mcs, &y, 5); + srsran_bit_unpack(dci->mcs, &y, 5); // TB scaling – 2 bits - if (rnti_type == srslte_rnti_type_p || rnti_type == srslte_rnti_type_ra) { - srslte_bit_unpack(dci->tb_scaling, &y, 2); + if (rnti_type == srsran_rnti_type_p || rnti_type == srsran_rnti_type_ra) { + srsran_bit_unpack(dci->tb_scaling, &y, 2); } // New data indicator – 1 bit - if (rnti_type == srslte_rnti_type_c || rnti_type == srslte_rnti_type_tc) { - srslte_bit_unpack(dci->ndi, &y, 1); + if (rnti_type == srsran_rnti_type_c || rnti_type == srsran_rnti_type_tc) { + srsran_bit_unpack(dci->ndi, &y, 1); } // Redundancy version – 2 bits - if (rnti_type == srslte_rnti_type_c || rnti_type == srslte_rnti_type_si || rnti_type == srslte_rnti_type_tc) { - srslte_bit_unpack(dci->rv, &y, 2); + if (rnti_type == srsran_rnti_type_c || rnti_type == srsran_rnti_type_si || rnti_type == srsran_rnti_type_tc) { + srsran_bit_unpack(dci->rv, &y, 2); } // HARQ process number – 4 bits - if (rnti_type == srslte_rnti_type_c || rnti_type == srslte_rnti_type_tc) { - srslte_bit_unpack(dci->pid, &y, 4); + if (rnti_type == srsran_rnti_type_c || rnti_type == srsran_rnti_type_tc) { + srsran_bit_unpack(dci->pid, &y, 4); } // System information indicator – 1 bit - if (rnti_type == srslte_rnti_type_si) { - srslte_bit_unpack(dci->sii, &y, 1); + if (rnti_type == srsran_rnti_type_si) { + srsran_bit_unpack(dci->sii, &y, 1); } // Downlink assignment index – 2 bits - if (rnti_type == srslte_rnti_type_c || rnti_type == srslte_rnti_type_tc) { - srslte_bit_unpack(dci->dai, &y, 2); + if (rnti_type == srsran_rnti_type_c || rnti_type == srsran_rnti_type_tc) { + srsran_bit_unpack(dci->dai, &y, 2); } // TPC command for scheduled PUCCH – 2 bits - if (rnti_type == srslte_rnti_type_c || rnti_type == srslte_rnti_type_tc) { - srslte_bit_unpack(dci->tpc, &y, 2); + if (rnti_type == srsran_rnti_type_c || rnti_type == srsran_rnti_type_tc) { + srsran_bit_unpack(dci->tpc, &y, 2); } // PUCCH resource indicator – 3 bits - if (rnti_type == srslte_rnti_type_c || rnti_type == srslte_rnti_type_tc) { - srslte_bit_unpack(dci->pucch_resource, &y, 3); + if (rnti_type == srsran_rnti_type_c || rnti_type == srsran_rnti_type_tc) { + srsran_bit_unpack(dci->pucch_resource, &y, 3); } // PDSCH-to-HARQ_feedback timing indicator – 3 bits - if (rnti_type == srslte_rnti_type_c || rnti_type == srslte_rnti_type_tc) { - srslte_bit_unpack(dci->harq_feedback, &y, 3); + if (rnti_type == srsran_rnti_type_c || rnti_type == srsran_rnti_type_tc) { + srsran_bit_unpack(dci->harq_feedback, &y, 3); } // Reserved bits ... - if (rnti_type == srslte_rnti_type_p) { + if (rnti_type == srsran_rnti_type_p) { // ... – 6 bits - srslte_bit_unpack(dci->reserved, &y, 6); - } else if (rnti_type == srslte_rnti_type_si) { + srsran_bit_unpack(dci->reserved, &y, 6); + } else if (rnti_type == srsran_rnti_type_si) { // ... – 15 bits - srslte_bit_unpack(dci->reserved, &y, 15); - } else if (rnti_type == srslte_rnti_type_ra) { + srsran_bit_unpack(dci->reserved, &y, 15); + } else if (rnti_type == srsran_rnti_type_ra) { // ... – 16 bits - srslte_bit_unpack(dci->reserved, &y, 16); + srsran_bit_unpack(dci->reserved, &y, 16); } - msg->nof_bits = srslte_dci_nr_format_1_0_sizeof(carrier, coreset, rnti_type); + msg->nof_bits = srsran_dci_nr_format_1_0_sizeof(carrier, coreset, rnti_type); if (msg->nof_bits != y - msg->payload) { ERROR("Unpacked bits read (%d) do NOT match payload size (%d)", msg->nof_bits, (int)(y - msg->payload)); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_dci_nr_format_1_0_unpack(const srslte_carrier_nr_t* carrier, - const srslte_coreset_t* coreset, - srslte_dci_msg_nr_t* msg, - srslte_dci_dl_nr_t* dci) +int srsran_dci_nr_format_1_0_unpack(const srsran_carrier_nr_t* carrier, + const srsran_coreset_t* coreset, + srsran_dci_msg_nr_t* msg, + srsran_dci_dl_nr_t* dci) { uint8_t* y = msg->payload; - srslte_rnti_type_t rnti_type = msg->rnti_type; + srsran_rnti_type_t rnti_type = msg->rnti_type; // Copy DCI MSG fields dci->location = msg->location; @@ -538,123 +538,123 @@ int srslte_dci_nr_format_1_0_unpack(const srslte_carrier_nr_t* carrier, dci->rnti = msg->rnti; dci->format = msg->format; - if (msg->nof_bits != srslte_dci_nr_format_1_0_sizeof(carrier, coreset, rnti_type)) { + if (msg->nof_bits != srsran_dci_nr_format_1_0_sizeof(carrier, coreset, rnti_type)) { ERROR("Invalid number of bits %d, expected %d", msg->nof_bits, - srslte_dci_nr_format_1_0_sizeof(carrier, coreset, rnti_type)); - return SRSLTE_ERROR; + srsran_dci_nr_format_1_0_sizeof(carrier, coreset, rnti_type)); + return SRSRAN_ERROR; } // Identifier for DCI formats – 1 bits - if (rnti_type == srslte_rnti_type_c || rnti_type == srslte_rnti_type_tc) { + if (rnti_type == srsran_rnti_type_c || rnti_type == srsran_rnti_type_tc) { // The value of this bit field is always set to 1, indicating a DL DCI format if (*(y++) != 1) { ERROR("Wrond DCI format"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } - if (rnti_type == srslte_rnti_type_p) { + if (rnti_type == srsran_rnti_type_p) { // Short Messages Indicator – 2 bits - dci->smi = srslte_bit_pack(&y, 2); + dci->smi = srsran_bit_pack(&y, 2); // Short Messages – 8 bits - dci->sm = srslte_bit_pack(&y, 8); + dci->sm = srsran_bit_pack(&y, 8); } // Frequency domain resource assignment int N = dci_nr_format_1_0_freq_resource_size(carrier, coreset, rnti_type); - if (N < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (N < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } - dci->freq_domain_assigment = srslte_bit_pack(&y, N); + dci->freq_domain_assigment = srsran_bit_pack(&y, N); // Time domain resource assignment – 4 bits - dci->time_domain_assigment = srslte_bit_pack(&y, 4); + dci->time_domain_assigment = srsran_bit_pack(&y, 4); // VRB-to-PRB mapping – 1 bit - dci->vrb_to_prb_mapping = srslte_bit_pack(&y, 1); + dci->vrb_to_prb_mapping = srsran_bit_pack(&y, 1); // Modulation and coding scheme – 5 bits - dci->mcs = srslte_bit_pack(&y, 5); + dci->mcs = srsran_bit_pack(&y, 5); // TB scaling – 2 bits - if (rnti_type == srslte_rnti_type_p || rnti_type == srslte_rnti_type_ra) { - dci->tb_scaling = srslte_bit_pack(&y, 2); + if (rnti_type == srsran_rnti_type_p || rnti_type == srsran_rnti_type_ra) { + dci->tb_scaling = srsran_bit_pack(&y, 2); } // New data indicator – 1 bit - if (rnti_type == srslte_rnti_type_c || rnti_type == srslte_rnti_type_tc) { - dci->ndi = srslte_bit_pack(&y, 1); + if (rnti_type == srsran_rnti_type_c || rnti_type == srsran_rnti_type_tc) { + dci->ndi = srsran_bit_pack(&y, 1); } // Redundancy version – 2 bits - if (rnti_type == srslte_rnti_type_c || rnti_type == srslte_rnti_type_si || rnti_type == srslte_rnti_type_tc) { - dci->rv = srslte_bit_pack(&y, 2); + if (rnti_type == srsran_rnti_type_c || rnti_type == srsran_rnti_type_si || rnti_type == srsran_rnti_type_tc) { + dci->rv = srsran_bit_pack(&y, 2); } // HARQ process number – 4 bits - if (rnti_type == srslte_rnti_type_c || rnti_type == srslte_rnti_type_tc) { - dci->pid = srslte_bit_pack(&y, 4); + if (rnti_type == srsran_rnti_type_c || rnti_type == srsran_rnti_type_tc) { + dci->pid = srsran_bit_pack(&y, 4); } // System information indicator – 1 bit - if (rnti_type == srslte_rnti_type_si) { - dci->sii = srslte_bit_pack(&y, 1); + if (rnti_type == srsran_rnti_type_si) { + dci->sii = srsran_bit_pack(&y, 1); } // Downlink assignment index – 2 bits - if (rnti_type == srslte_rnti_type_c || rnti_type == srslte_rnti_type_tc) { - dci->dai = srslte_bit_pack(&y, 2); + if (rnti_type == srsran_rnti_type_c || rnti_type == srsran_rnti_type_tc) { + dci->dai = srsran_bit_pack(&y, 2); } // TPC command for scheduled PUCCH – 2 bits - if (rnti_type == srslte_rnti_type_c || rnti_type == srslte_rnti_type_tc) { - dci->tpc = srslte_bit_pack(&y, 2); + if (rnti_type == srsran_rnti_type_c || rnti_type == srsran_rnti_type_tc) { + dci->tpc = srsran_bit_pack(&y, 2); } // PUCCH resource indicator – 3 bits - if (rnti_type == srslte_rnti_type_c || rnti_type == srslte_rnti_type_tc) { - dci->pucch_resource = srslte_bit_pack(&y, 3); + if (rnti_type == srsran_rnti_type_c || rnti_type == srsran_rnti_type_tc) { + dci->pucch_resource = srsran_bit_pack(&y, 3); } // PDSCH-to-HARQ_feedback timing indicator – 3 bits - if (rnti_type == srslte_rnti_type_c || rnti_type == srslte_rnti_type_tc) { - dci->harq_feedback = srslte_bit_pack(&y, 3); + if (rnti_type == srsran_rnti_type_c || rnti_type == srsran_rnti_type_tc) { + dci->harq_feedback = srsran_bit_pack(&y, 3); } // Reserved bits ... - if (rnti_type == srslte_rnti_type_p) { + if (rnti_type == srsran_rnti_type_p) { // ... – 6 bits - dci->reserved = srslte_bit_pack(&y, 6); - } else if (rnti_type == srslte_rnti_type_si) { + dci->reserved = srsran_bit_pack(&y, 6); + } else if (rnti_type == srsran_rnti_type_si) { // ... – 15 bits - dci->reserved = srslte_bit_pack(&y, 15); - } else if (rnti_type == srslte_rnti_type_ra) { + dci->reserved = srsran_bit_pack(&y, 15); + } else if (rnti_type == srsran_rnti_type_ra) { // ... – 16 bits - dci->reserved = srslte_bit_pack(&y, 16); + dci->reserved = srsran_bit_pack(&y, 16); } if (msg->nof_bits != y - msg->payload) { ERROR("Unpacked bits read (%d) do NOT match payload size (%d)", msg->nof_bits, (int)(y - msg->payload)); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_dci_nr_format_1_0_sizeof(const srslte_carrier_nr_t* carrier, - const srslte_coreset_t* coreset, - srslte_rnti_type_t rnti_type) +int srsran_dci_nr_format_1_0_sizeof(const srsran_carrier_nr_t* carrier, + const srsran_coreset_t* coreset, + srsran_rnti_type_t rnti_type) { int count = 0; // Identifier for DCI formats – 1 bits - if (rnti_type == srslte_rnti_type_c || rnti_type == srslte_rnti_type_tc) { + if (rnti_type == srsran_rnti_type_c || rnti_type == srsran_rnti_type_tc) { count += 1; } - if (rnti_type == srslte_rnti_type_p) { + if (rnti_type == srsran_rnti_type_p) { // Short Messages Indicator – 2 bits count += 2; @@ -664,8 +664,8 @@ int srslte_dci_nr_format_1_0_sizeof(const srslte_carrier_nr_t* carrier, // Frequency domain resource assignment int N = dci_nr_format_1_0_freq_resource_size(carrier, coreset, rnti_type); - if (N < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (N < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } count += N; @@ -679,58 +679,58 @@ int srslte_dci_nr_format_1_0_sizeof(const srslte_carrier_nr_t* carrier, count += 5; // TB scaling – 2 bits - if (rnti_type == srslte_rnti_type_p || rnti_type == srslte_rnti_type_ra) { + if (rnti_type == srsran_rnti_type_p || rnti_type == srsran_rnti_type_ra) { count += 2; } // New data indicator – 1 bit - if (rnti_type == srslte_rnti_type_c || rnti_type == srslte_rnti_type_tc) { + if (rnti_type == srsran_rnti_type_c || rnti_type == srsran_rnti_type_tc) { count += 1; } // Redundancy version – 2 bits - if (rnti_type == srslte_rnti_type_c || rnti_type == srslte_rnti_type_si || rnti_type == srslte_rnti_type_tc) { + if (rnti_type == srsran_rnti_type_c || rnti_type == srsran_rnti_type_si || rnti_type == srsran_rnti_type_tc) { count += 2; } // HARQ process number – 4 bits - if (rnti_type == srslte_rnti_type_c || rnti_type == srslte_rnti_type_tc) { + if (rnti_type == srsran_rnti_type_c || rnti_type == srsran_rnti_type_tc) { count += 4; } // System information indicator – 1 bit - if (rnti_type == srslte_rnti_type_si) { + if (rnti_type == srsran_rnti_type_si) { count += 1; } // Downlink assignment index – 2 bits - if (rnti_type == srslte_rnti_type_c || rnti_type == srslte_rnti_type_tc) { + if (rnti_type == srsran_rnti_type_c || rnti_type == srsran_rnti_type_tc) { count += 2; } // TPC command for scheduled PUCCH – 2 bits - if (rnti_type == srslte_rnti_type_c || rnti_type == srslte_rnti_type_tc) { + if (rnti_type == srsran_rnti_type_c || rnti_type == srsran_rnti_type_tc) { count += 2; } // PUCCH resource indicator – 3 bits - if (rnti_type == srslte_rnti_type_c || rnti_type == srslte_rnti_type_tc) { + if (rnti_type == srsran_rnti_type_c || rnti_type == srsran_rnti_type_tc) { count += 3; } // PDSCH-to-HARQ_feedback timing indicator – 3 bits - if (rnti_type == srslte_rnti_type_c || rnti_type == srslte_rnti_type_tc) { + if (rnti_type == srsran_rnti_type_c || rnti_type == srsran_rnti_type_tc) { count += 3; } // Reserved bits ... - if (rnti_type == srslte_rnti_type_p) { + if (rnti_type == srsran_rnti_type_p) { // ... – 6 bits count += 2; - } else if (rnti_type == srslte_rnti_type_si) { + } else if (rnti_type == srsran_rnti_type_si) { // ... – 15 bits count += 15; - } else if (rnti_type == srslte_rnti_type_ra) { + } else if (rnti_type == srsran_rnti_type_ra) { // ... – 16 bits count += 16; } @@ -738,107 +738,107 @@ int srslte_dci_nr_format_1_0_sizeof(const srslte_carrier_nr_t* carrier, return count; } -static int dci_nr_format_1_0_to_str(const srslte_dci_dl_nr_t* dci, char* str, uint32_t str_len) +static int dci_nr_format_1_0_to_str(const srsran_dci_dl_nr_t* dci, char* str, uint32_t str_len) { uint32_t len = 0; // Print format - len = srslte_print_check( + len = srsran_print_check( str, str_len, len, "rnti=%04x L=%d cce=%d dci=1_0 ", dci->rnti, dci->location.L, dci->location.ncce); - if (dci->rnti_type == srslte_rnti_type_p) { - len = srslte_print_check(str, str_len, len, "smi=%d sm=%d ", dci->smi, dci->sm); + if (dci->rnti_type == srsran_rnti_type_p) { + len = srsran_print_check(str, str_len, len, "smi=%d sm=%d ", dci->smi, dci->sm); } // Frequency domain resource assignment - len = srslte_print_check(str, str_len, len, "f_alloc=0x%x ", dci->freq_domain_assigment); + len = srsran_print_check(str, str_len, len, "f_alloc=0x%x ", dci->freq_domain_assigment); // Time domain resource assignment – 4 bits - len = srslte_print_check(str, str_len, len, "t_alloc=0x%x ", dci->time_domain_assigment); + len = srsran_print_check(str, str_len, len, "t_alloc=0x%x ", dci->time_domain_assigment); // VRB-to-PRB mapping – 1 bit - len = srslte_print_check(str, str_len, len, "vrb_to_prb_map=%d ", dci->vrb_to_prb_mapping); + len = srsran_print_check(str, str_len, len, "vrb_to_prb_map=%d ", dci->vrb_to_prb_mapping); // Modulation and coding scheme – 5 bits - len = srslte_print_check(str, str_len, len, "mcs=%d ", dci->mcs); + len = srsran_print_check(str, str_len, len, "mcs=%d ", dci->mcs); // TB scaling – 2 bits - if (dci->rnti_type == srslte_rnti_type_p || dci->rnti_type == srslte_rnti_type_ra) { - len = srslte_print_check(str, str_len, len, "tb_scaling=%d ", dci->tb_scaling); + if (dci->rnti_type == srsran_rnti_type_p || dci->rnti_type == srsran_rnti_type_ra) { + len = srsran_print_check(str, str_len, len, "tb_scaling=%d ", dci->tb_scaling); } // New data indicator – 1 bit - if (dci->rnti_type == srslte_rnti_type_c || dci->rnti_type == srslte_rnti_type_tc) { - len = srslte_print_check(str, str_len, len, "ndi=%d ", dci->ndi); + if (dci->rnti_type == srsran_rnti_type_c || dci->rnti_type == srsran_rnti_type_tc) { + len = srsran_print_check(str, str_len, len, "ndi=%d ", dci->ndi); } // Redundancy version – 2 bits - if (dci->rnti_type == srslte_rnti_type_c || dci->rnti_type == srslte_rnti_type_si || - dci->rnti_type == srslte_rnti_type_tc) { - len = srslte_print_check(str, str_len, len, "rv=%d ", dci->rv); + if (dci->rnti_type == srsran_rnti_type_c || dci->rnti_type == srsran_rnti_type_si || + dci->rnti_type == srsran_rnti_type_tc) { + len = srsran_print_check(str, str_len, len, "rv=%d ", dci->rv); } // HARQ process number – 4 bits - if (dci->rnti_type == srslte_rnti_type_c || dci->rnti_type == srslte_rnti_type_tc) { - len = srslte_print_check(str, str_len, len, "harq_id=%d ", dci->harq_feedback); + if (dci->rnti_type == srsran_rnti_type_c || dci->rnti_type == srsran_rnti_type_tc) { + len = srsran_print_check(str, str_len, len, "harq_id=%d ", dci->harq_feedback); } // System information indicator – 1 bit - if (dci->rnti_type == srslte_rnti_type_si) { - len = srslte_print_check(str, str_len, len, "sii=%d ", dci->sii); + if (dci->rnti_type == srsran_rnti_type_si) { + len = srsran_print_check(str, str_len, len, "sii=%d ", dci->sii); } // Downlink assignment index – 2 bits - if (dci->rnti_type == srslte_rnti_type_c || dci->rnti_type == srslte_rnti_type_tc) { - len = srslte_print_check(str, str_len, len, "dai=%d ", dci->dai); + if (dci->rnti_type == srsran_rnti_type_c || dci->rnti_type == srsran_rnti_type_tc) { + len = srsran_print_check(str, str_len, len, "dai=%d ", dci->dai); } // TPC command for scheduled PUCCH – 2 bits - if (dci->rnti_type == srslte_rnti_type_c || dci->rnti_type == srslte_rnti_type_tc) { - len = srslte_print_check(str, str_len, len, "pucch_tpc=%d ", dci->tpc); + if (dci->rnti_type == srsran_rnti_type_c || dci->rnti_type == srsran_rnti_type_tc) { + len = srsran_print_check(str, str_len, len, "pucch_tpc=%d ", dci->tpc); } // PUCCH resource indicator – 3 bits - if (dci->rnti_type == srslte_rnti_type_c || dci->rnti_type == srslte_rnti_type_tc) { - len = srslte_print_check(str, str_len, len, "pucch_res=%d ", dci->pucch_resource); + if (dci->rnti_type == srsran_rnti_type_c || dci->rnti_type == srsran_rnti_type_tc) { + len = srsran_print_check(str, str_len, len, "pucch_res=%d ", dci->pucch_resource); } // PDSCH-to-HARQ_feedback timing indicator – 3 bits - if (dci->rnti_type == srslte_rnti_type_c || dci->rnti_type == srslte_rnti_type_tc) { - len = srslte_print_check(str, str_len, len, "harq_feedback=%d ", dci->harq_feedback); + if (dci->rnti_type == srsran_rnti_type_c || dci->rnti_type == srsran_rnti_type_tc) { + len = srsran_print_check(str, str_len, len, "harq_feedback=%d ", dci->harq_feedback); } // Reserved bits ... - if (dci->rnti_type == srslte_rnti_type_p || dci->rnti_type == srslte_rnti_type_si || - dci->rnti_type == srslte_rnti_type_ra) { - len = srslte_print_check(str, str_len, len, "reserved=0x%x ", dci->reserved); + if (dci->rnti_type == srsran_rnti_type_p || dci->rnti_type == srsran_rnti_type_si || + dci->rnti_type == srsran_rnti_type_ra) { + len = srsran_print_check(str, str_len, len, "reserved=0x%x ", dci->reserved); } return len; } -int srslte_dci_ul_nr_to_str(const srslte_dci_ul_nr_t* dci, char* str, uint32_t str_len) +int srsran_dci_ul_nr_to_str(const srsran_dci_ul_nr_t* dci, char* str, uint32_t str_len) { // Pack DCI switch (dci->format) { - case srslte_dci_format_nr_0_0: + case srsran_dci_format_nr_0_0: return dci_nr_format_0_0_to_str(dci, str, str_len); - case srslte_dci_format_nr_rar: + case srsran_dci_format_nr_rar: return dci_nr_rar_to_str(dci, str, str_len); default:; // Do nothing } - return srslte_print_check(str, str_len, 0, "unknown"); + return srsran_print_check(str, str_len, 0, "unknown"); } -int srslte_dci_dl_nr_to_str(const srslte_dci_dl_nr_t* dci, char* str, uint32_t str_len) +int srsran_dci_dl_nr_to_str(const srsran_dci_dl_nr_t* dci, char* str, uint32_t str_len) { // Pack DCI switch (dci->format) { - case srslte_dci_format_nr_1_0: + case srsran_dci_format_nr_1_0: return dci_nr_format_1_0_to_str(dci, str, str_len); default:; // Do nothing } - return srslte_print_check(str, str_len, 0, "unknown"); + return srsran_print_check(str, str_len, 0, "unknown"); } diff --git a/lib/src/phy/phch/mib_sl.c b/lib/src/phy/phch/mib_sl.c index be810419e..35a6423b8 100644 --- a/lib/src/phy/phch/mib_sl.c +++ b/lib/src/phy/phch/mib_sl.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -12,17 +12,17 @@ #include -#include "srslte/phy/phch/mib_sl.h" -#include "srslte/phy/utils/bit.h" +#include "srsran/phy/phch/mib_sl.h" +#include "srsran/phy/utils/bit.h" -int srslte_mib_sl_init(srslte_mib_sl_t* q, srslte_sl_tm_t tm) +int srsran_mib_sl_init(srsran_mib_sl_t* q, srsran_sl_tm_t tm) { - if (tm == SRSLTE_SIDELINK_TM1 || tm == SRSLTE_SIDELINK_TM2) { - q->mib_sl_len = SRSLTE_MIB_SL_LEN; - } else if (tm == SRSLTE_SIDELINK_TM3 || tm == SRSLTE_SIDELINK_TM4) { - q->mib_sl_len = SRSLTE_MIB_SL_V2X_LEN; + if (tm == SRSRAN_SIDELINK_TM1 || tm == SRSRAN_SIDELINK_TM2) { + q->mib_sl_len = SRSRAN_MIB_SL_LEN; + } else if (tm == SRSRAN_SIDELINK_TM3 || tm == SRSRAN_SIDELINK_TM4) { + q->mib_sl_len = SRSRAN_MIB_SL_V2X_LEN; } else { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } q->sl_bandwidth_r12 = 0; @@ -31,17 +31,17 @@ int srslte_mib_sl_init(srslte_mib_sl_t* q, srslte_sl_tm_t tm) q->in_coverage_r12 = false; q->tdd_config_sl_r12 = 0; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_mib_sl_set(srslte_mib_sl_t* q, +int srsran_mib_sl_set(srsran_mib_sl_t* q, uint32_t nof_prb, uint32_t tdd_config, uint32_t direct_frame_number, uint32_t direct_subframe_number, bool in_coverage) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL) { switch (nof_prb) { case 6: @@ -64,39 +64,39 @@ int srslte_mib_sl_set(srslte_mib_sl_t* q, break; default: printf("Invalid bandwidth\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } q->tdd_config_sl_r12 = tdd_config; q->direct_frame_number_r12 = direct_frame_number; q->direct_subframe_number_r12 = direct_subframe_number; q->in_coverage_r12 = in_coverage; - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } -void srslte_mib_sl_pack(srslte_mib_sl_t* q, uint8_t* msg) +void srsran_mib_sl_pack(srsran_mib_sl_t* q, uint8_t* msg) { - bzero(msg, sizeof(uint8_t) * SRSLTE_MIB_SL_MAX_LEN); - srslte_bit_unpack(q->sl_bandwidth_r12, &msg, 3); - srslte_bit_unpack(q->tdd_config_sl_r12, &msg, 3); - srslte_bit_unpack(q->direct_frame_number_r12, &msg, 10); - srslte_bit_unpack(q->direct_subframe_number_r12, &msg, 4); - srslte_bit_unpack((uint32_t)q->in_coverage_r12, &msg, 1); + bzero(msg, sizeof(uint8_t) * SRSRAN_MIB_SL_MAX_LEN); + srsran_bit_unpack(q->sl_bandwidth_r12, &msg, 3); + srsran_bit_unpack(q->tdd_config_sl_r12, &msg, 3); + srsran_bit_unpack(q->direct_frame_number_r12, &msg, 10); + srsran_bit_unpack(q->direct_subframe_number_r12, &msg, 4); + srsran_bit_unpack((uint32_t)q->in_coverage_r12, &msg, 1); } -void srslte_mib_sl_unpack(srslte_mib_sl_t* q, uint8_t* msg) +void srsran_mib_sl_unpack(srsran_mib_sl_t* q, uint8_t* msg) { - q->sl_bandwidth_r12 = srslte_bit_pack(&msg, 3); - q->tdd_config_sl_r12 = srslte_bit_pack(&msg, 3); - q->direct_frame_number_r12 = srslte_bit_pack(&msg, 10); - q->direct_subframe_number_r12 = srslte_bit_pack(&msg, 4); - q->in_coverage_r12 = (bool)srslte_bit_pack(&msg, 1); + q->sl_bandwidth_r12 = srsran_bit_pack(&msg, 3); + q->tdd_config_sl_r12 = srsran_bit_pack(&msg, 3); + q->direct_frame_number_r12 = srsran_bit_pack(&msg, 10); + q->direct_subframe_number_r12 = srsran_bit_pack(&msg, 4); + q->in_coverage_r12 = (bool)srsran_bit_pack(&msg, 1); } -void srslte_mib_sl_printf(FILE* f, srslte_mib_sl_t* q) +void srsran_mib_sl_printf(FILE* f, srsran_mib_sl_t* q) { fprintf(f, " - Bandwidth: %i\n", q->sl_bandwidth_r12); fprintf(f, " - Direct Frame Number: %i\n", q->direct_frame_number_r12); @@ -105,9 +105,9 @@ void srslte_mib_sl_printf(FILE* f, srslte_mib_sl_t* q) fprintf(f, " - In coverage: %s\n", q->in_coverage_r12 ? "yes" : "no"); } -void srslte_mib_sl_free(srslte_mib_sl_t* q) +void srsran_mib_sl_free(srsran_mib_sl_t* q) { if (q != NULL) { - bzero(q, sizeof(srslte_mib_sl_t)); + bzero(q, sizeof(srsran_mib_sl_t)); } } diff --git a/lib/src/phy/phch/npbch.c b/lib/src/phy/phch/npbch.c index 679b53cc4..3afa468d6 100644 --- a/lib/src/phy/phch/npbch.c +++ b/lib/src/phy/phch/npbch.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -21,17 +21,17 @@ #include #include "prb_dl.h" -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/phch/npbch.h" -#include "srslte/phy/phch/ra_nbiot.h" -#include "srslte/phy/utils/bit.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/phch/npbch.h" +#include "srsran/phy/phch/ra_nbiot.h" +#include "srsran/phy/utils/bit.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" -#define SRSLTE_NBIOT_NPBCH_NUM_REFS_PER_SYMB 4 +#define SRSRAN_NBIOT_NPBCH_NUM_REFS_PER_SYMB 4 // Table 5.3.1.1-1 in 36.212 v13.3.0 -const uint8_t srslte_npbch_crc_mask[4][16] = {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +const uint8_t srsran_npbch_crc_mask[4][16] = {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1}}; @@ -40,28 +40,28 @@ const uint8_t srslte_npbch_crc_mask[4][16] = {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, * At the receiver, the field nof_ports in the cell structure indicates the * maximum number of BS transmitter ports to look for. */ -int srslte_npbch_init(srslte_npbch_t* q) +int srsran_npbch_init(srsran_npbch_t* q) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL) { - bzero(q, sizeof(srslte_npbch_t)); + bzero(q, sizeof(srsran_npbch_t)); - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; - q->nof_symbols = SRSLTE_NPBCH_NUM_RE; + q->nof_symbols = SRSRAN_NPBCH_NUM_RE; - if (srslte_modem_table_lte(&q->mod, SRSLTE_MOD_QPSK)) { + if (srsran_modem_table_lte(&q->mod, SRSRAN_MOD_QPSK)) { fprintf(stderr, "Error initiating modem table.\n"); goto clean; } int poly[3] = {0x6D, 0x4F, 0x57}; - if (srslte_viterbi_init(&q->decoder, SRSLTE_VITERBI_37, poly, SRSLTE_MIB_NB_CRC_LEN, true)) { + if (srsran_viterbi_init(&q->decoder, SRSRAN_VITERBI_37, poly, SRSRAN_MIB_NB_CRC_LEN, true)) { fprintf(stderr, "Error initiating Viterbi.\n"); goto clean; } - if (srslte_crc_init(&q->crc, SRSLTE_LTE_CRC16, 16)) { + if (srsran_crc_init(&q->crc, SRSRAN_LTE_CRC16, 16)) { fprintf(stderr, "Error initiating CRC object.\n"); goto clean; } @@ -70,59 +70,59 @@ int srslte_npbch_init(srslte_npbch_t* q) q->encoder.tail_biting = true; memcpy(q->encoder.poly, poly, 3 * sizeof(int)); - q->d = srslte_vec_cf_malloc(q->nof_symbols); + q->d = srsran_vec_cf_malloc(q->nof_symbols); if (!q->d) { fprintf(stderr, "Error allocating memory.\n"); goto clean; } - for (uint32_t i = 0; i < SRSLTE_MAX_PORTS; i++) { - q->ce[i] = srslte_vec_cf_malloc(q->nof_symbols); + for (uint32_t i = 0; i < SRSRAN_MAX_PORTS; i++) { + q->ce[i] = srsran_vec_cf_malloc(q->nof_symbols); if (!q->ce[i]) { fprintf(stderr, "Error allocating memory.\n"); goto clean; } - q->x[i] = srslte_vec_cf_malloc(q->nof_symbols); + q->x[i] = srsran_vec_cf_malloc(q->nof_symbols); if (!q->x[i]) { fprintf(stderr, "Error allocating memory.\n"); goto clean; } - q->symbols[i] = srslte_vec_cf_malloc(q->nof_symbols * SRSLTE_NPBCH_NUM_FRAMES); + q->symbols[i] = srsran_vec_cf_malloc(q->nof_symbols * SRSRAN_NPBCH_NUM_FRAMES); if (!q->symbols[i]) { fprintf(stderr, "Error allocating memory.\n"); goto clean; } } - q->llr = srslte_vec_f_malloc(q->nof_symbols * SRSLTE_NPBCH_NUM_FRAMES * 2); + q->llr = srsran_vec_f_malloc(q->nof_symbols * SRSRAN_NPBCH_NUM_FRAMES * 2); if (!q->llr) { fprintf(stderr, "Error allocating memory.\n"); goto clean; } - q->temp = srslte_vec_f_malloc(q->nof_symbols * SRSLTE_NPBCH_NUM_FRAMES * 2); + q->temp = srsran_vec_f_malloc(q->nof_symbols * SRSRAN_NPBCH_NUM_FRAMES * 2); if (!q->temp) { fprintf(stderr, "Error allocating memory.\n"); goto clean; } - q->rm_b = srslte_vec_u8_malloc(q->nof_symbols * SRSLTE_NPBCH_NUM_FRAMES * 2); + q->rm_b = srsran_vec_u8_malloc(q->nof_symbols * SRSRAN_NPBCH_NUM_FRAMES * 2); if (!q->rm_b) { fprintf(stderr, "Error allocating memory.\n"); goto clean; } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } clean: - if (ret == SRSLTE_ERROR) { - srslte_npbch_free(q); + if (ret == SRSRAN_ERROR) { + srsran_npbch_free(q); } return ret; } -void srslte_npbch_free(srslte_npbch_t* q) +void srsran_npbch_free(srsran_npbch_t* q) { if (q->d) { free(q->d); } - for (uint32_t i = 0; i < SRSLTE_MAX_PORTS; i++) { + for (uint32_t i = 0; i < SRSRAN_MAX_PORTS; i++) { if (q->ce[i]) { free(q->ce[i]); } @@ -142,74 +142,74 @@ void srslte_npbch_free(srslte_npbch_t* q) if (q->rm_b) { free(q->rm_b); } - for (uint32_t i = 0; i < SRSLTE_NPBCH_NUM_BLOCKS; i++) { - srslte_sequence_free(&q->seq_r14[i]); + for (uint32_t i = 0; i < SRSRAN_NPBCH_NUM_BLOCKS; i++) { + srsran_sequence_free(&q->seq_r14[i]); } - srslte_sequence_free(&q->seq); - srslte_modem_table_free(&q->mod); - srslte_viterbi_free(&q->decoder); + srsran_sequence_free(&q->seq); + srsran_modem_table_free(&q->mod); + srsran_viterbi_free(&q->decoder); } -int srslte_npbch_set_cell(srslte_npbch_t* q, srslte_nbiot_cell_t cell) +int srsran_npbch_set_cell(srsran_npbch_t* q, srsran_nbiot_cell_t cell) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; - if (q != NULL && srslte_nbiot_cell_isvalid(&cell)) { + if (q != NULL && srsran_nbiot_cell_isvalid(&cell)) { // set ports configuration if (cell.nof_ports == 0) { q->search_all_ports = true; - cell.nof_ports = SRSLTE_NBIOT_MAX_PORTS; + cell.nof_ports = SRSRAN_NBIOT_MAX_PORTS; } else { q->search_all_ports = false; } if (q->cell.n_id_ncell != cell.n_id_ncell || q->cell.base.nof_prb == 0) { q->cell = cell; - if (srslte_sequence_npbch(&q->seq, q->cell.base.cp, q->cell.n_id_ncell)) { + if (srsran_sequence_npbch(&q->seq, q->cell.base.cp, q->cell.n_id_ncell)) { fprintf(stderr, "Error initiating NPBCH sequence.\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // pre-compute the 8 rotation sequences for R14 if (q->cell.is_r14) { - for (uint32_t i = 0; i < SRSLTE_NPBCH_NUM_BLOCKS; i++) { - if (srslte_sequence_npbch_r14(&q->seq_r14[i], q->cell.n_id_ncell, i)) { - return SRSLTE_ERROR; + for (uint32_t i = 0; i < SRSRAN_NPBCH_NUM_BLOCKS; i++) { + if (srsran_sequence_npbch_r14(&q->seq_r14[i], q->cell.n_id_ncell, i)) { + return SRSRAN_ERROR; } } } } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } /** Packs the MIB-NB, according to TS 36.331 v13.2.0 Section 6.7.2 */ -void srslte_npbch_mib_pack(uint32_t hfn, uint32_t sfn, srslte_mib_nb_t mib, uint8_t* payload) +void srsran_npbch_mib_pack(uint32_t hfn, uint32_t sfn, srsran_mib_nb_t mib, uint8_t* payload) { uint8_t* msg = payload; - bzero(msg, SRSLTE_MIB_NB_LEN); + bzero(msg, SRSRAN_MIB_NB_LEN); // System Frame Number (SFN), 4 MSB - srslte_bit_unpack(sfn >> 6, &msg, 4); + srsran_bit_unpack(sfn >> 6, &msg, 4); // Hyper Frame Number (HFB), 2 LSB - srslte_bit_unpack(hfn, &msg, 2); + srsran_bit_unpack(hfn, &msg, 2); // schedulingInfoSIB1, integer 0-15, 4 bits - srslte_bit_unpack(mib.sched_info_sib1, &msg, 4); + srsran_bit_unpack(mib.sched_info_sib1, &msg, 4); // system info value tag, integer 0-31, 5 bits - srslte_bit_unpack(mib.sys_info_tag, &msg, 5); + srsran_bit_unpack(mib.sys_info_tag, &msg, 5); // access barring enabled, 1 bit - srslte_bit_unpack(mib.ac_barring, &msg, 1); + srsran_bit_unpack(mib.ac_barring, &msg, 1); // operation mode info, 2 for mode + 5 for config, 7 bits in total - srslte_bit_unpack(mib.mode, &msg, 2); + srsran_bit_unpack(mib.mode, &msg, 2); // 11 spare bits } @@ -217,19 +217,19 @@ void srslte_npbch_mib_pack(uint32_t hfn, uint32_t sfn, srslte_mib_nb_t mib, uint /** Unpacks MIB-NB from NPBCH message. * msg buffer must be 34 byte length at least */ -void srslte_npbch_mib_unpack(uint8_t* msg, srslte_mib_nb_t* mib) +void srsran_npbch_mib_unpack(uint8_t* msg, srsran_mib_nb_t* mib) { if (mib) { - mib->sfn = (srslte_bit_pack(&msg, 4) << 6) & 0x3C0; - mib->hfn = srslte_bit_pack(&msg, 2) & 0x3; - mib->sched_info_sib1 = srslte_bit_pack(&msg, 4) & 0x0000ffff; - mib->sys_info_tag = srslte_bit_pack(&msg, 5) & 0x0001ffff; - mib->ac_barring = srslte_bit_pack(&msg, 1) & 0x1; - mib->mode = srslte_bit_pack(&msg, 2) & 0x0000000B; + mib->sfn = (srsran_bit_pack(&msg, 4) << 6) & 0x3C0; + mib->hfn = srsran_bit_pack(&msg, 2) & 0x3; + mib->sched_info_sib1 = srsran_bit_pack(&msg, 4) & 0x0000ffff; + mib->sys_info_tag = srsran_bit_pack(&msg, 5) & 0x0001ffff; + mib->ac_barring = srsran_bit_pack(&msg, 1) & 0x1; + mib->mode = srsran_bit_pack(&msg, 2) & 0x0000000B; } } -void srslte_mib_nb_printf(FILE* stream, srslte_nbiot_cell_t cell, srslte_mib_nb_t* mib) +void srsran_mib_nb_printf(FILE* stream, srsran_nbiot_cell_t cell, srsran_mib_nb_t* mib) { fprintf(stream, " - N_id_ncell: %d\n", cell.n_id_ncell); fprintf(stream, " - Release: %s\n", cell.is_r14 ? "r14" : "r13"); @@ -237,38 +237,38 @@ void srslte_mib_nb_printf(FILE* stream, srslte_nbiot_cell_t cell, srslte_mib_nb_ fprintf(stream, " - SFN: %d\n", mib->sfn); fprintf(stream, " - HFN (2 LSB): %d\n", mib->hfn); fprintf(stream, " - Sched. Info SIB1 %d\n", mib->sched_info_sib1); - fprintf(stream, " - First frame %d\n", srslte_ra_nbiot_get_starting_sib1_frame(cell.n_id_ncell, mib)); - fprintf(stream, " - #repetitions %d\n", srslte_ra_n_rep_sib1_nb(mib)); - fprintf(stream, " - TBS %d\n", srslte_ra_nbiot_get_sib1_tbs(mib)); + fprintf(stream, " - First frame %d\n", srsran_ra_nbiot_get_starting_sib1_frame(cell.n_id_ncell, mib)); + fprintf(stream, " - #repetitions %d\n", srsran_ra_n_rep_sib1_nb(mib)); + fprintf(stream, " - TBS %d\n", srsran_ra_nbiot_get_sib1_tbs(mib)); fprintf(stream, " - System Info Val %d\n", mib->sys_info_tag); fprintf(stream, " - AC barring %s\n", mib->ac_barring ? "Yes" : "No"); - fprintf(stream, " - Operating mode %s\n", srslte_nbiot_mode_string(mib->mode)); + fprintf(stream, " - Operating mode %s\n", srsran_nbiot_mode_string(mib->mode)); } -int srslte_npbch_put_subframe(srslte_npbch_t* q, - uint8_t bch_payload[SRSLTE_MIB_NB_LEN], - cf_t* sf[SRSLTE_MAX_PORTS], +int srsran_npbch_put_subframe(srsran_npbch_t* q, + uint8_t bch_payload[SRSRAN_MIB_NB_LEN], + cf_t* sf[SRSRAN_MAX_PORTS], uint32_t frame_idx) { - return srslte_npbch_encode(q, bch_payload, sf, frame_idx); + return srsran_npbch_encode(q, bch_payload, sf, frame_idx); } /** Converts the MIB-NB message to symbols mapped to the first subframe, * The MIB-NB is split over 8 blocks, each of which is repeated 8 times, always in SF0, * it therefore lasts for 640ms. */ -int srslte_npbch_encode(srslte_npbch_t* q, - uint8_t bch_payload[SRSLTE_MIB_NB_LEN], - cf_t* sf[SRSLTE_MAX_PORTS], +int srsran_npbch_encode(srsran_npbch_t* q, + uint8_t bch_payload[SRSRAN_MIB_NB_LEN], + cf_t* sf[SRSRAN_MAX_PORTS], uint32_t frame_idx) { - int block_idx = (frame_idx / SRSLTE_NPBCH_NUM_REP) % SRSLTE_NPBCH_NUM_BLOCKS; - cf_t* x[SRSLTE_MAX_LAYERS]; + int block_idx = (frame_idx / SRSRAN_NPBCH_NUM_REP) % SRSRAN_NPBCH_NUM_BLOCKS; + cf_t* x[SRSRAN_MAX_LAYERS]; if (q != NULL && bch_payload != NULL && q->cell.nof_ports != 0) { for (int i = 0; i < q->cell.nof_ports; i++) { if (sf[i] == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } } // Set pointers for layermapping & precoding @@ -278,58 +278,58 @@ int srslte_npbch_encode(srslte_npbch_t* q, for (int i = 0; i < q->cell.nof_ports; i++) { x[i] = q->x[i]; } - memset(&x[q->cell.nof_ports], 0, sizeof(cf_t*) * (SRSLTE_MAX_LAYERS - q->cell.nof_ports)); + memset(&x[q->cell.nof_ports], 0, sizeof(cf_t*) * (SRSRAN_MAX_LAYERS - q->cell.nof_ports)); // generate new BCH message every 64 frames - if ((frame_idx % SRSLTE_NPBCH_NUM_FRAMES) == 0) { + if ((frame_idx % SRSRAN_NPBCH_NUM_FRAMES) == 0) { INFO("Encoding new NPBCH signal in frame %d.", frame_idx); - memcpy(q->data, bch_payload, sizeof(uint8_t) * SRSLTE_MIB_NB_LEN); + memcpy(q->data, bch_payload, sizeof(uint8_t) * SRSRAN_MIB_NB_LEN); // encode and rate-match - srslte_crc_attach(&q->crc, q->data, SRSLTE_MIB_NB_LEN); - srslte_npbch_crc_set_mask(q->data, q->cell.nof_ports); + srsran_crc_attach(&q->crc, q->data, SRSRAN_MIB_NB_LEN); + srsran_npbch_crc_set_mask(q->data, q->cell.nof_ports); - srslte_convcoder_encode(&q->encoder, q->data, q->data_enc, SRSLTE_MIB_NB_CRC_LEN); + srsran_convcoder_encode(&q->encoder, q->data, q->data_enc, SRSRAN_MIB_NB_CRC_LEN); - srslte_rm_conv_tx(q->data_enc, SRSLTE_MIB_NB_ENC_LEN, q->rm_b, SRSLTE_NPBCH_NUM_BLOCKS * nof_bits); + srsran_rm_conv_tx(q->data_enc, SRSRAN_MIB_NB_ENC_LEN, q->rm_b, SRSRAN_NPBCH_NUM_BLOCKS * nof_bits); } // Scramble and modulate a new block every 8 frames - if (frame_idx % SRSLTE_NPBCH_NUM_REP == 0) { + if (frame_idx % SRSRAN_NPBCH_NUM_REP == 0) { INFO("Modulating MIB-NB block %d in frame %d.", block_idx, frame_idx); - srslte_scrambling_b_offset(&q->seq, &q->rm_b[block_idx * nof_bits], block_idx * nof_bits, nof_bits); - srslte_mod_modulate(&q->mod, &q->rm_b[block_idx * nof_bits], q->d, nof_bits); + srsran_scrambling_b_offset(&q->seq, &q->rm_b[block_idx * nof_bits], block_idx * nof_bits, nof_bits); + srsran_mod_modulate(&q->mod, &q->rm_b[block_idx * nof_bits], q->d, nof_bits); // layer mapping & precoding if (q->cell.nof_ports > 1) { - srslte_layermap_diversity(q->d, x, q->cell.nof_ports, q->nof_symbols); - srslte_precoding_diversity(x, q->symbols, q->cell.nof_ports, q->nof_symbols / q->cell.nof_ports, 1.0); + srsran_layermap_diversity(q->d, x, q->cell.nof_ports, q->nof_symbols); + srsran_precoding_diversity(x, q->symbols, q->cell.nof_ports, q->nof_symbols / q->cell.nof_ports, 1.0); } else { memcpy(q->symbols[0], q->d, q->nof_symbols * sizeof(cf_t)); } } - // Write exactly SRSLTE_NPBCH_NUM_RE (assumes symbols have been modulated before) + // Write exactly SRSRAN_NPBCH_NUM_RE (assumes symbols have been modulated before) for (int i = 0; i < q->cell.nof_ports; i++) { if (q->cell.is_r14) { DEBUG("Applying phase rotation on port %d in frame %d.", i, frame_idx); - srslte_npbch_rotate(q, frame_idx, q->symbols[i], q->symbols[i], q->nof_symbols, false); + srsran_npbch_rotate(q, frame_idx, q->symbols[i], q->symbols[i], q->nof_symbols, false); } DEBUG("Putting MIB-NB block %d on port %d in frame %d.", block_idx, i, frame_idx); - if (srslte_npbch_cp(q->symbols[i], sf[i], q->cell, true) != SRSLTE_NPBCH_NUM_RE) { + if (srsran_npbch_cp(q->symbols[i], sf[i], q->cell, true) != SRSRAN_NPBCH_NUM_RE) { INFO("Error while mapping NPBCH symbols."); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } else { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } } -int srslte_npbch_rotate(srslte_npbch_t* q, +int srsran_npbch_rotate(srsran_npbch_t* q, uint32_t nf, cf_t* input_signal, cf_t* output_signal, @@ -361,18 +361,18 @@ int srslte_npbch_rotate(srslte_npbch_t* q, output_signal[i] = back ? input_signal[i] / phi_f : input_signal[i] * phi_f; - if (SRSLTE_VERBOSE_ISDEBUG()) { + if (SRSRAN_VERBOSE_ISDEBUG()) { printf("i=%d c_2i=%d, c_2i+1=%d -> phi_f=", i, c_2i, c_2ip1); - srslte_vec_fprint_c(stdout, &phi_f, 1); + srsran_vec_fprint_c(stdout, &phi_f, 1); printf("input:\n"); - srslte_vec_fprint_c(stdout, &input_signal[i], 1); + srsran_vec_fprint_c(stdout, &input_signal[i], 1); printf("output:\n"); - srslte_vec_fprint_c(stdout, &output_signal[i], 1); + srsran_vec_fprint_c(stdout, &output_signal[i], 1); printf("\n\n"); } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } /* Decodes the NPBCH channel @@ -383,18 +383,18 @@ int srslte_npbch_rotate(srslte_npbch_t* q, * * Returns 1 if successfully decoded MIB-NB, 0 if not and -1 on error */ -int srslte_npbch_decode_nf(srslte_npbch_t* q, +int srsran_npbch_decode_nf(srsran_npbch_t* q, cf_t* sf_symbols, - cf_t* ce[SRSLTE_MAX_PORTS], + cf_t* ce[SRSRAN_MAX_PORTS], float noise_estimate, - uint8_t bch_payload[SRSLTE_MIB_NB_LEN], + uint8_t bch_payload[SRSRAN_MIB_NB_LEN], uint32_t* nof_tx_ports, int* sfn_offset, int nf) { - cf_t* x[SRSLTE_MAX_LAYERS] = {NULL}; + cf_t* x[SRSRAN_MAX_LAYERS] = {NULL}; - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL && sf_symbols != NULL && q->cell.nof_ports != 0) { for (int i = 0; i < q->cell.nof_ports; i++) { @@ -403,18 +403,18 @@ int srslte_npbch_decode_nf(srslte_npbch_t* q, } } - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; // Set pointers for layermapping & precoding int nof_bits = 2 * q->nof_symbols; // number of layers equals number of ports - for (int i = 0; i < SRSLTE_MAX_PORTS; i++) { + for (int i = 0; i < SRSRAN_MAX_PORTS; i++) { x[i] = q->x[i]; } // extract symbols - int nof_ext_syms = srslte_npbch_cp(sf_symbols, q->symbols[0], q->cell, false); + int nof_ext_syms = srsran_npbch_cp(sf_symbols, q->symbols[0], q->cell, false); if (q->nof_symbols != nof_ext_syms) { fprintf(stderr, "There was an error getting the PBCH symbols\n"); return ret; @@ -422,12 +422,12 @@ int srslte_npbch_decode_nf(srslte_npbch_t* q, if (q->cell.is_r14) { // de-rotate symbols - srslte_npbch_rotate(q, nf, q->symbols[0], q->symbols[0], q->nof_symbols, true); + srsran_npbch_rotate(q, nf, q->symbols[0], q->symbols[0], q->nof_symbols, true); } // extract channel estimates for (int i = 0; i < q->cell.nof_ports; i++) { - if (q->nof_symbols != srslte_npbch_cp(ce[i], q->ce[i], q->cell, false)) { + if (q->nof_symbols != srsran_npbch_cp(ce[i], q->ce[i], q->cell, false)) { fprintf(stderr, "There was an error getting the PBCH symbols\n"); return ret; } @@ -448,21 +448,21 @@ int srslte_npbch_decode_nf(srslte_npbch_t* q, // in control channels, only diversity is supported if (nant == 1) { // no need for layer demapping - srslte_predecoding_single(q->symbols[0], q->ce[0], q->d, NULL, q->nof_symbols, 1.0, noise_estimate); + srsran_predecoding_single(q->symbols[0], q->ce[0], q->d, NULL, q->nof_symbols, 1.0, noise_estimate); } else { - srslte_predecoding_diversity(q->symbols[0], q->ce, x, nant, q->nof_symbols, 1.0); - srslte_layerdemap_diversity(x, q->d, nant, q->nof_symbols / nant); + srsran_predecoding_diversity(q->symbols[0], q->ce, x, nant, q->nof_symbols, 1.0); + srsran_layerdemap_diversity(x, q->d, nant, q->nof_symbols / nant); } // demodulate symbols - srslte_demod_soft_demodulate(SRSLTE_MOD_QPSK, q->d, &q->llr[nof_bits * (q->frame_idx - 1)], q->nof_symbols); + srsran_demod_soft_demodulate(SRSRAN_MOD_QPSK, q->d, &q->llr[nof_bits * (q->frame_idx - 1)], q->nof_symbols); // only one subframe DEBUG("Trying to decode NPBCH .."); // TODO: simplified decoding only using first MIB block - ret = srslte_npbch_decode_frame(q, 0, nf, 1, nof_bits, nant); - if (ret == SRSLTE_SUCCESS) { + ret = srsran_npbch_decode_frame(q, 0, nf, 1, nof_bits, nant); + if (ret == SRSRAN_SUCCESS) { if (sfn_offset) { *sfn_offset = (int)0; } @@ -470,7 +470,7 @@ int srslte_npbch_decode_nf(srslte_npbch_t* q, *nof_tx_ports = nant; } if (bch_payload) { - memcpy(bch_payload, q->data, sizeof(uint8_t) * SRSLTE_MIB_NB_LEN); + memcpy(bch_payload, q->data, sizeof(uint8_t) * SRSRAN_MIB_NB_LEN); } INFO("Successfully decoded NPBCH sfn_offset=%d", q->frame_idx - 1); q->frame_idx = 0; @@ -485,62 +485,62 @@ int srslte_npbch_decode_nf(srslte_npbch_t* q, return ret; } -int srslte_npbch_decode(srslte_npbch_t* q, +int srsran_npbch_decode(srsran_npbch_t* q, cf_t* sf_symbols, - cf_t* ce[SRSLTE_MAX_PORTS], + cf_t* ce[SRSRAN_MAX_PORTS], float noise_estimate, - uint8_t bch_payload[SRSLTE_MIB_NB_LEN], + uint8_t bch_payload[SRSRAN_MIB_NB_LEN], uint32_t* nof_tx_ports, int* sfn_offset) { - return srslte_npbch_decode_nf(q, sf_symbols, ce, noise_estimate, bch_payload, nof_tx_ports, sfn_offset, 0); + return srsran_npbch_decode_nf(q, sf_symbols, ce, noise_estimate, bch_payload, nof_tx_ports, sfn_offset, 0); } -void srslte_npbch_decode_reset(srslte_npbch_t* q) +void srsran_npbch_decode_reset(srsran_npbch_t* q) { q->frame_idx = 0; } -int srslte_npbch_decode_frame(srslte_npbch_t* q, +int srsran_npbch_decode_frame(srsran_npbch_t* q, uint32_t src, uint32_t dst, uint32_t n, uint32_t nof_bits, uint32_t nof_ports) { - srslte_vec_f_copy(&q->temp[dst * nof_bits], &q->llr[src * nof_bits], n * nof_bits); + srsran_vec_f_copy(&q->temp[dst * nof_bits], &q->llr[src * nof_bits], n * nof_bits); // descramble - srslte_scrambling_f_offset(&q->seq, &q->temp[dst * nof_bits], dst * nof_bits, n * nof_bits); + srsran_scrambling_f_offset(&q->seq, &q->temp[dst * nof_bits], dst * nof_bits, n * nof_bits); for (int j = 0; j < dst * nof_bits; j++) { - q->temp[j] = SRSLTE_RX_NULL; + q->temp[j] = SRSRAN_RX_NULL; } - for (int j = (dst + n) * nof_bits; j < SRSLTE_NPBCH_NUM_BLOCKS * nof_bits; j++) { - q->temp[j] = SRSLTE_RX_NULL; + for (int j = (dst + n) * nof_bits; j < SRSRAN_NPBCH_NUM_BLOCKS * nof_bits; j++) { + q->temp[j] = SRSRAN_RX_NULL; } // unrate matching - srslte_rm_conv_rx(q->temp, SRSLTE_NPBCH_NUM_BLOCKS * nof_bits, q->rm_f, SRSLTE_MIB_NB_ENC_LEN); + srsran_rm_conv_rx(q->temp, SRSRAN_NPBCH_NUM_BLOCKS * nof_bits, q->rm_f, SRSRAN_MIB_NB_ENC_LEN); // Normalize LLR - srslte_vec_sc_prod_fff(q->rm_f, 1.0 / ((float)2 * n), q->rm_f, SRSLTE_MIB_NB_ENC_LEN); + srsran_vec_sc_prod_fff(q->rm_f, 1.0 / ((float)2 * n), q->rm_f, SRSRAN_MIB_NB_ENC_LEN); // decode - srslte_viterbi_decode_f(&q->decoder, q->rm_f, q->data, SRSLTE_MIB_NB_CRC_LEN); + srsran_viterbi_decode_f(&q->decoder, q->rm_f, q->data, SRSRAN_MIB_NB_CRC_LEN); - if (srslte_npbch_crc_check(q, q->data, nof_ports) == 0) { - return SRSLTE_SUCCESS; + if (srsran_npbch_crc_check(q, q->data, nof_ports) == 0) { + return SRSRAN_SUCCESS; } else { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } -void srslte_npbch_crc_set_mask(uint8_t* data, int nof_ports) +void srsran_npbch_crc_set_mask(uint8_t* data, int nof_ports) { int i; for (i = 0; i < 16; i++) { - data[SRSLTE_MIB_NB_LEN + i] = (data[SRSLTE_MIB_NB_LEN + i] + srslte_npbch_crc_mask[nof_ports - 1][i]) % 2; + data[SRSRAN_MIB_NB_LEN + i] = (data[SRSRAN_MIB_NB_LEN + i] + srsran_npbch_crc_mask[nof_ports - 1][i]) % 2; } } @@ -550,21 +550,21 @@ void srslte_npbch_crc_set_mask(uint8_t* data, int nof_ports) * * Returns 0 if the data is correct, -1 otherwise */ -uint32_t srslte_npbch_crc_check(srslte_npbch_t* q, uint8_t* bits, uint32_t nof_ports) +uint32_t srsran_npbch_crc_check(srsran_npbch_t* q, uint8_t* bits, uint32_t nof_ports) { - uint8_t data[SRSLTE_MIB_NB_CRC_LEN]; - memcpy(data, bits, SRSLTE_MIB_NB_CRC_LEN * sizeof(uint8_t)); - srslte_npbch_crc_set_mask(data, nof_ports); - int ret = srslte_crc_checksum(&q->crc, data, SRSLTE_MIB_NB_CRC_LEN); + uint8_t data[SRSRAN_MIB_NB_CRC_LEN]; + memcpy(data, bits, SRSRAN_MIB_NB_CRC_LEN * sizeof(uint8_t)); + srsran_npbch_crc_set_mask(data, nof_ports); + int ret = srsran_crc_checksum(&q->crc, data, SRSRAN_MIB_NB_CRC_LEN); if (ret == 0) { uint32_t chkzeros = 0; - for (int i = 0; i < SRSLTE_MIB_NB_LEN; i++) { + for (int i = 0; i < SRSRAN_MIB_NB_LEN; i++) { chkzeros += data[i]; } if (chkzeros) { return 0; } else { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } else { return ret; @@ -576,11 +576,11 @@ uint32_t srslte_npbch_crc_check(srslte_npbch_t* q, uint8_t* bits, uint32_t nof_p * four ports for CRS * Returns the number of symbols written/read */ -int srslte_npbch_cp(cf_t* input, cf_t* output, srslte_nbiot_cell_t cell, bool put) +int srsran_npbch_cp(cf_t* input, cf_t* output, srsran_nbiot_cell_t cell, bool put) { cf_t * in_ptr = input, *out_ptr = output; uint32_t offset = 0; // the number of REs left out before start of the REF signal RE - uint32_t delta = 3 * cell.base.nof_prb * SRSLTE_NRE + cell.nbiot_prb * SRSLTE_NRE; + uint32_t delta = 3 * cell.base.nof_prb * SRSRAN_NRE + cell.nbiot_prb * SRSRAN_NRE; if (put) { out_ptr += delta; @@ -588,7 +588,7 @@ int srslte_npbch_cp(cf_t* input, cf_t* output, srslte_nbiot_cell_t cell, bool pu in_ptr += delta; } - for (uint32_t l = 3; l < SRSLTE_CP_NORM_SF_NSYMB; l++) { + for (uint32_t l = 3; l < SRSRAN_CP_NORM_SF_NSYMB; l++) { delta = 0; if (l == 3 || l == 9 || l == 10) { // copy entire symbol @@ -597,7 +597,7 @@ int srslte_npbch_cp(cf_t* input, cf_t* output, srslte_nbiot_cell_t cell, bool pu // skip LTE CRS and NRS and always assume 4 reference symbols per OFDM symbol offset = cell.n_id_ncell % 3; prb_cp_ref( - &in_ptr, &out_ptr, offset, SRSLTE_NBIOT_NPBCH_NUM_REFS_PER_SYMB, SRSLTE_NBIOT_NPBCH_NUM_REFS_PER_SYMB, put); + &in_ptr, &out_ptr, offset, SRSRAN_NBIOT_NPBCH_NUM_REFS_PER_SYMB, SRSRAN_NBIOT_NPBCH_NUM_REFS_PER_SYMB, put); delta = (cell.n_id_ncell % 3 == 2 ? 1 : 0); } diff --git a/lib/src/phy/phch/npdcch.c b/lib/src/phy/phch/npdcch.c index 4eae7c836..ee5016d9c 100644 --- a/lib/src/phy/phch/npdcch.c +++ b/lib/src/phy/phch/npdcch.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -19,91 +19,91 @@ #include #include "prb_dl.h" -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/phch/dci_nbiot.h" -#include "srslte/phy/phch/npdcch.h" -#include "srslte/phy/utils/bit.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/phch/dci_nbiot.h" +#include "srsran/phy/phch/npdcch.h" +#include "srsran/phy/utils/bit.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" #define DUMP_SIGNALS 0 #define RE_EXT_DEBUG 0 /** Initializes the NPDCCH transmitter and receiver */ -int srslte_npdcch_init(srslte_npdcch_t* q) +int srsran_npdcch_init(srsran_npdcch_t* q) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL) { - ret = SRSLTE_ERROR; - bzero(q, sizeof(srslte_npdcch_t)); + ret = SRSRAN_ERROR; + bzero(q, sizeof(srsran_npdcch_t)); q->nof_cce = 2; // One Format1 NPDCCH occupying both NCCEs // Allocate memory for the maximum number of NPDCCH bits, i.e. one full PRB - q->max_bits = SRSLTE_CP_NORM_SF_NSYMB * SRSLTE_NRE * 2; + q->max_bits = SRSRAN_CP_NORM_SF_NSYMB * SRSRAN_NRE * 2; q->ncce_bits = q->max_bits / 2; INFO("Init NPDCCH: Max bits: %d, %d ports.", q->max_bits, q->cell.nof_ports); - if (srslte_modem_table_lte(&q->mod, SRSLTE_MOD_QPSK)) { + if (srsran_modem_table_lte(&q->mod, SRSRAN_MOD_QPSK)) { goto clean; } - if (srslte_crc_init(&q->crc, SRSLTE_LTE_CRC16, 16)) { + if (srsran_crc_init(&q->crc, SRSRAN_LTE_CRC16, 16)) { goto clean; } int poly[3] = {0x6D, 0x4F, 0x57}; - if (srslte_viterbi_init(&q->decoder, SRSLTE_VITERBI_37, poly, SRSLTE_NBIOT_DCI_MAX_SIZE + 16, true)) { + if (srsran_viterbi_init(&q->decoder, SRSRAN_VITERBI_37, poly, SRSRAN_NBIOT_DCI_MAX_SIZE + 16, true)) { goto clean; } - q->e = srslte_vec_u8_malloc(q->max_bits); + q->e = srsran_vec_u8_malloc(q->max_bits); if (!q->e) { goto clean; } for (int i = 0; i < 2; i++) { - q->llr[i] = srslte_vec_f_malloc(q->max_bits); + q->llr[i] = srsran_vec_f_malloc(q->max_bits); if (!q->llr[i]) { goto clean; } - srslte_vec_f_zero(q->llr[i], q->max_bits); + srsran_vec_f_zero(q->llr[i], q->max_bits); } - q->d = srslte_vec_cf_malloc(q->max_bits / 2); + q->d = srsran_vec_cf_malloc(q->max_bits / 2); if (!q->d) { goto clean; } - for (uint32_t i = 0; i < SRSLTE_MAX_PORTS; i++) { - q->ce[i] = srslte_vec_cf_malloc(q->max_bits / 2); + for (uint32_t i = 0; i < SRSRAN_MAX_PORTS; i++) { + q->ce[i] = srsran_vec_cf_malloc(q->max_bits / 2); if (!q->ce[i]) { goto clean; } for (uint32_t k = 0; k < q->max_bits / 2; k++) { q->ce[i][k] = 1; } - q->x[i] = srslte_vec_cf_malloc(q->max_bits / 2); + q->x[i] = srsran_vec_cf_malloc(q->max_bits / 2); if (!q->x[i]) { goto clean; } - q->symbols[i] = srslte_vec_cf_malloc(q->max_bits / 2); + q->symbols[i] = srsran_vec_cf_malloc(q->max_bits / 2); if (!q->symbols[i]) { goto clean; } memset(q->symbols[i], 0, sizeof(cf_t) * q->max_bits / 2); } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } clean: - if (ret == SRSLTE_ERROR) { - srslte_npdcch_free(q); + if (ret == SRSRAN_ERROR) { + srsran_npdcch_free(q); } return ret; } -void srslte_npdcch_free(srslte_npdcch_t* q) +void srsran_npdcch_free(srsran_npdcch_t* q) { if (q->e) { free(q->e); @@ -118,7 +118,7 @@ void srslte_npdcch_free(srslte_npdcch_t* q) if (q->d) { free(q->d); } - for (uint32_t i = 0; i < SRSLTE_MAX_PORTS; i++) { + for (uint32_t i = 0; i < SRSRAN_MAX_PORTS; i++) { if (q->ce[i]) { free(q->ce[i]); } @@ -130,27 +130,27 @@ void srslte_npdcch_free(srslte_npdcch_t* q) } } - for (uint32_t i = 0; i < SRSLTE_NOF_SF_X_FRAME; i++) { - srslte_sequence_free(&q->seq[i]); + for (uint32_t i = 0; i < SRSRAN_NOF_SF_X_FRAME; i++) { + srsran_sequence_free(&q->seq[i]); } - srslte_modem_table_free(&q->mod); - srslte_viterbi_free(&q->decoder); + srsran_modem_table_free(&q->mod); + srsran_viterbi_free(&q->decoder); - bzero(q, sizeof(srslte_npdcch_t)); + bzero(q, sizeof(srsran_npdcch_t)); } -int srslte_npdcch_set_cell(srslte_npdcch_t* q, srslte_nbiot_cell_t cell) +int srsran_npdcch_set_cell(srsran_npdcch_t* q, srsran_nbiot_cell_t cell) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; - if (q != NULL && srslte_nbiot_cell_isvalid(&cell)) { - ret = SRSLTE_ERROR; + if (q != NULL && srsran_nbiot_cell_isvalid(&cell)) { + ret = SRSRAN_ERROR; if (q->cell.n_id_ncell != cell.n_id_ncell || q->cell.base.nof_prb == 0) { q->cell = cell; - if (q->cell.mode == SRSLTE_NBIOT_MODE_INBAND_SAME_PCI || q->cell.mode == SRSLTE_NBIOT_MODE_INBAND_DIFFERENT_PCI) { + if (q->cell.mode == SRSRAN_NBIOT_MODE_INBAND_SAME_PCI || q->cell.mode == SRSRAN_NBIOT_MODE_INBAND_DIFFERENT_PCI) { q->i_n_start = 3; } else { q->i_n_start = 0; @@ -170,77 +170,77 @@ int srslte_npdcch_set_cell(srslte_npdcch_t* q, srslte_nbiot_cell_t cell) } // Update the maximum number of NPDCCH bits, i.e. one PRB minus the starting offset minus the reference symbols - q->max_bits = srslte_ra_nbiot_dl_grant_nof_re(q->cell, q->i_n_start) * 2; + q->max_bits = srsran_ra_nbiot_dl_grant_nof_re(q->cell, q->i_n_start) * 2; q->ncce_bits = q->max_bits / 2; - for (int i = 0; i < SRSLTE_NOF_SF_X_FRAME; i++) { - if (srslte_sequence_npdcch(&q->seq[i], 2 * i, q->cell.n_id_ncell, q->max_bits)) { - return SRSLTE_ERROR; + for (int i = 0; i < SRSRAN_NOF_SF_X_FRAME; i++) { + if (srsran_sequence_npdcch(&q->seq[i], 2 * i, q->cell.n_id_ncell, q->max_bits)) { + return SRSRAN_ERROR; } } } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } -int srslte_npdcch_dci_decode(srslte_npdcch_t* q, float* e, uint8_t* data, uint32_t E, uint32_t nof_bits, uint16_t* crc) +int srsran_npdcch_dci_decode(srsran_npdcch_t* q, float* e, uint8_t* data, uint32_t E, uint32_t nof_bits, uint16_t* crc) { uint16_t p_bits, crc_res; uint8_t* x; if (q != NULL) { - if (data != NULL && E <= q->max_bits && nof_bits <= SRSLTE_DCI_MAX_BITS) { - srslte_vec_f_zero(q->rm_f, 3 * (SRSLTE_DCI_MAX_BITS + 16)); + if (data != NULL && E <= q->max_bits && nof_bits <= SRSRAN_DCI_MAX_BITS) { + srsran_vec_f_zero(q->rm_f, 3 * (SRSRAN_DCI_MAX_BITS + 16)); uint32_t coded_len = 3 * (nof_bits + 16); // unrate matching - srslte_rm_conv_rx(e, E, q->rm_f, coded_len); + srsran_rm_conv_rx(e, E, q->rm_f, coded_len); // viterbi decoder - srslte_viterbi_decode_f(&q->decoder, q->rm_f, data, nof_bits + 16); + srsran_viterbi_decode_f(&q->decoder, q->rm_f, data, nof_bits + 16); x = &data[nof_bits]; - p_bits = (uint16_t)srslte_bit_pack(&x, 16); - crc_res = ((uint16_t)srslte_crc_checksum(&q->crc, data, nof_bits) & 0xffff); + p_bits = (uint16_t)srsran_bit_pack(&x, 16); + crc_res = ((uint16_t)srsran_crc_checksum(&q->crc, data, nof_bits) & 0xffff); if (crc) { *crc = p_bits ^ crc_res; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } else { fprintf(stderr, "Invalid parameters: E: %d, max_bits: %d, nof_bits: %d\n", E, q->max_bits, nof_bits); - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } } else { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } } -/** Tries to decode a DCI message from the LLRs stored in the srslte_npdcch_t structure by the function - * srslte_npdcch_extract_llr(). This function can be called multiple times. +/** Tries to decode a DCI message from the LLRs stored in the srsran_npdcch_t structure by the function + * srsran_npdcch_extract_llr(). This function can be called multiple times. * The decoded message is stored in msg and the CRC remainder in crc_rem pointer * */ -int srslte_npdcch_decode_msg(srslte_npdcch_t* q, - srslte_dci_msg_t* msg, - srslte_dci_location_t* location, - srslte_dci_format_t format, +int srsran_npdcch_decode_msg(srsran_npdcch_t* q, + srsran_dci_msg_t* msg, + srsran_dci_location_t* location, + srsran_dci_format_t format, uint16_t* crc_rem) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; int num_decoded_symbols = 0; - if (q != NULL && msg != NULL && srslte_nbiot_dci_location_isvalid(location)) { - uint32_t nof_bits = (format == SRSLTE_DCI_FORMATN2) ? 15 : 23; + if (q != NULL && msg != NULL && srsran_nbiot_dci_location_isvalid(location)) { + uint32_t nof_bits = (format == SRSRAN_DCI_FORMATN2) ? 15 : 23; uint32_t e_bits = q->ncce_bits * location->L; // Get the right softbits for this aggregation level float* llr = (location->L == 1) ? q->llr[0] : q->llr[1]; - if (SRSLTE_VERBOSE_ISDEBUG()) { + if (SRSRAN_VERBOSE_ISDEBUG()) { DEBUG("LLR:"); - srslte_vec_fprint_f(stdout, llr, q->max_bits); + srsran_vec_fprint_f(stdout, llr, q->max_bits); } double mean = 0; @@ -249,13 +249,13 @@ int srslte_npdcch_decode_msg(srslte_npdcch_t* q, } mean /= e_bits; if (mean > 0.3) { - ret = srslte_npdcch_dci_decode(q, &llr[location->ncce * q->ncce_bits], msg->payload, e_bits, nof_bits, crc_rem); - if (ret == SRSLTE_SUCCESS) { + ret = srsran_npdcch_dci_decode(q, &llr[location->ncce * q->ncce_bits], msg->payload, e_bits, nof_bits, crc_rem); + if (ret == SRSRAN_SUCCESS) { num_decoded_symbols = e_bits / 2; msg->nof_bits = nof_bits; // Check format differentiation - if (format == SRSLTE_DCI_FORMATN0 || format == SRSLTE_DCI_FORMATN1) { - msg->format = (msg->payload[0] == 0) ? SRSLTE_DCI_FORMATN0 : SRSLTE_DCI_FORMATN1; + if (format == SRSRAN_DCI_FORMATN0 || format == SRSRAN_DCI_FORMATN1) { + msg->format = (msg->payload[0] == 0) ? SRSRAN_DCI_FORMATN0 : SRSRAN_DCI_FORMATN1; } else { msg->format = format; } @@ -266,7 +266,7 @@ int srslte_npdcch_decode_msg(srslte_npdcch_t* q, DEBUG("Decoded DCI: nCCE=%d, L=%d, format=%s, msg_len=%d, mean=%f, crc_rem=0x%x", location->ncce, location->L, - srslte_dci_format_string(msg->format), + srsran_dci_format_string(msg->format), nof_bits, mean, *crc_rem); @@ -274,7 +274,7 @@ int srslte_npdcch_decode_msg(srslte_npdcch_t* q, } else { DEBUG("Skipping DCI: nCCE=%d, L=%d, msg_len=%d, mean=%f", location->ncce, location->L, nof_bits, mean); } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } else { fprintf(stderr, "Invalid parameters, location=%d,%d\n", location->ncce, location->L); } @@ -283,39 +283,39 @@ int srslte_npdcch_decode_msg(srslte_npdcch_t* q, return ret; } -/** Extracts the LLRs from srslte_dci_location_t location of the subframe and stores them in the srslte_npdcch_t - * structure. DCI messages can be extracted from this location calling the function srslte_npdcch_decode_msg(). Every +/** Extracts the LLRs from srsran_dci_location_t location of the subframe and stores them in the srsran_npdcch_t + * structure. DCI messages can be extracted from this location calling the function srsran_npdcch_decode_msg(). Every * time this function is called (with a different location), the last demodulated symbols are overwritten and new * messages from other locations can be decoded */ -int srslte_npdcch_extract_llr(srslte_npdcch_t* q, +int srsran_npdcch_extract_llr(srsran_npdcch_t* q, cf_t* sf_symbols, - cf_t* ce[SRSLTE_MAX_PORTS], + cf_t* ce[SRSRAN_MAX_PORTS], float noise_estimate, uint32_t sf_idx) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; /* Set pointers for layermapping & precoding */ uint32_t num_symbols, e_bits; float* llr; - cf_t* x[SRSLTE_MAX_LAYERS]; + cf_t* x[SRSRAN_MAX_LAYERS]; if (q != NULL && sf_idx < 10) { - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; - for (int i = 0; i < SRSLTE_NPDCCH_FORMAT_NITEMS; i++) { + for (int i = 0; i < SRSRAN_NPDCCH_FORMAT_NITEMS; i++) { // set parameters according to NPDCCH format switch (i) { - case SRSLTE_NPDCCH_FORMAT0_LOWER_HALF: + case SRSRAN_NPDCCH_FORMAT0_LOWER_HALF: e_bits = q->ncce_bits; llr = q->llr[0]; break; - case SRSLTE_NPDCCH_FORMAT0_UPPER_HALF: + case SRSRAN_NPDCCH_FORMAT0_UPPER_HALF: e_bits = q->ncce_bits; llr = &q->llr[0][q->ncce_bits]; break; - case SRSLTE_NPDCCH_FORMAT1: + case SRSRAN_NPDCCH_FORMAT1: e_bits = q->ncce_bits * 2; llr = q->llr[1]; break; @@ -324,36 +324,36 @@ int srslte_npdcch_extract_llr(srslte_npdcch_t* q, } num_symbols = e_bits / 2; - DEBUG("Extracting LLRs for NPDCCH %s: E: %d, SF: %d", srslte_npdcch_format_text[i], e_bits, sf_idx); + DEBUG("Extracting LLRs for NPDCCH %s: E: %d, SF: %d", srsran_npdcch_format_text[i], e_bits, sf_idx); - if (i != SRSLTE_NPDCCH_FORMAT0_UPPER_HALF) { + if (i != SRSRAN_NPDCCH_FORMAT0_UPPER_HALF) { // don't overwrite lower half LLRs - srslte_vec_f_zero(llr, q->max_bits); + srsran_vec_f_zero(llr, q->max_bits); } // number of layers equals number of ports for (int f = 0; f < q->cell.nof_ports; f++) { x[f] = q->x[f]; } - memset(&x[q->cell.nof_ports], 0, sizeof(cf_t*) * (SRSLTE_MAX_LAYERS - q->cell.nof_ports)); + memset(&x[q->cell.nof_ports], 0, sizeof(cf_t*) * (SRSRAN_MAX_LAYERS - q->cell.nof_ports)); // extract symbols - int n = srslte_npdcch_get(q, sf_symbols, q->symbols[0], i); + int n = srsran_npdcch_get(q, sf_symbols, q->symbols[0], i); if (num_symbols != n) { fprintf(stderr, "Expected %d NPDCCH symbols but got %d symbols\n", num_symbols, n); return ret; } #if DUMP_SIGNALS - if (SRSLTE_VERBOSE_ISDEBUG()) { + if (SRSRAN_VERBOSE_ISDEBUG()) { DEBUG("SAVED FILE npdcch_rx_mapping_output.bin: NPDCCH after extracting symbols"); - srslte_vec_save_file("npdcch_rx_mapping_output.bin", q->symbols[0], n * sizeof(cf_t)); + srsran_vec_save_file("npdcch_rx_mapping_output.bin", q->symbols[0], n * sizeof(cf_t)); } #endif // extract channel estimates for (int p = 0; p < q->cell.nof_ports; p++) { - n = srslte_npdcch_get(q, ce[p], q->ce[p], i); + n = srsran_npdcch_get(q, ce[p], q->ce[p], i); if (num_symbols != n) { fprintf(stderr, "Expected %d NPDCCH symbols but got %d symbols\n", num_symbols, n); return ret; @@ -363,34 +363,34 @@ int srslte_npdcch_extract_llr(srslte_npdcch_t* q, // in control channels, only diversity is supported if (q->cell.nof_ports == 1) { // no need for layer demapping - srslte_predecoding_single(q->symbols[0], q->ce[0], q->d, NULL, num_symbols, 1.0, noise_estimate); + srsran_predecoding_single(q->symbols[0], q->ce[0], q->d, NULL, num_symbols, 1.0, noise_estimate); } else { - srslte_predecoding_diversity(q->symbols[0], q->ce, x, q->cell.nof_ports, num_symbols, 1.0); - srslte_layerdemap_diversity(x, q->d, q->cell.nof_ports, num_symbols / q->cell.nof_ports); + srsran_predecoding_diversity(q->symbols[0], q->ce, x, q->cell.nof_ports, num_symbols, 1.0); + srsran_layerdemap_diversity(x, q->d, q->cell.nof_ports, num_symbols / q->cell.nof_ports); } #if DUMP_SIGNALS - if (SRSLTE_VERBOSE_ISDEBUG()) { + if (SRSRAN_VERBOSE_ISDEBUG()) { DEBUG("SAVED FILE npdcch_rx_predecode_output.bin: NPDCCH after predecoding symbols"); - srslte_vec_save_file("npdcch_rx_predecode_output.bin", q->d, q->num_decoded_symbols * sizeof(cf_t)); + srsran_vec_save_file("npdcch_rx_predecode_output.bin", q->d, q->num_decoded_symbols * sizeof(cf_t)); } #endif // demodulate symbols - srslte_demod_soft_demodulate(SRSLTE_MOD_QPSK, q->d, llr, num_symbols); + srsran_demod_soft_demodulate(SRSRAN_MOD_QPSK, q->d, llr, num_symbols); // descramble - srslte_scrambling_f_offset(&q->seq[sf_idx], llr, 0, e_bits); + srsran_scrambling_f_offset(&q->seq[sf_idx], llr, 0, e_bits); #if DUMP_SIGNALS - if (SRSLTE_VERBOSE_ISDEBUG()) { + if (SRSRAN_VERBOSE_ISDEBUG()) { DEBUG("SAVED FILE npdcch_rx_descramble_output.bin: NPDCCH after de-scrambling"); - srslte_vec_save_file("npdcch_rx_descramble_output.bin", llr, e_bits); + srsran_vec_save_file("npdcch_rx_descramble_output.bin", llr, e_bits); } #endif } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } @@ -402,81 +402,81 @@ static void crc_set_mask_rnti(uint8_t* crc, uint16_t rnti) DEBUG("Mask CRC with RNTI 0x%x", rnti); - srslte_bit_unpack(rnti, &r, 16); + srsran_bit_unpack(rnti, &r, 16); for (uint32_t i = 0; i < 16; i++) { crc[i] = (crc[i] + mask[i]) % 2; } } -void srslte_npdcch_dci_encode_conv(srslte_npdcch_t* q, +void srsran_npdcch_dci_encode_conv(srsran_npdcch_t* q, uint8_t* data, uint32_t nof_bits, uint8_t* coded_data, uint16_t rnti) { - srslte_convcoder_t encoder; + srsran_convcoder_t encoder; int poly[3] = {0x6D, 0x4F, 0x57}; encoder.K = 7; encoder.R = 3; encoder.tail_biting = true; memcpy(encoder.poly, poly, 3 * sizeof(int)); - srslte_crc_attach(&q->crc, data, nof_bits); + srsran_crc_attach(&q->crc, data, nof_bits); crc_set_mask_rnti(&data[nof_bits], rnti); #if DUMP_SIGNALS - if (SRSLTE_VERBOSE_ISDEBUG()) { + if (SRSRAN_VERBOSE_ISDEBUG()) { DEBUG("SAVED FILE npdcch_tx_convcoder_input.bin: NPDCCH before convolution coding"); - srslte_vec_save_file("npdcch_tx_convcoder_input.bin", data, nof_bits + 16); + srsran_vec_save_file("npdcch_tx_convcoder_input.bin", data, nof_bits + 16); } #endif - srslte_convcoder_encode(&encoder, data, coded_data, nof_bits + 16); + srsran_convcoder_encode(&encoder, data, coded_data, nof_bits + 16); } /** 36.212 5.3.3.2 to 5.3.3.4 * TODO: UE transmit antenna selection CRC mask */ -int srslte_npdcch_dci_encode(srslte_npdcch_t* q, +int srsran_npdcch_dci_encode(srsran_npdcch_t* q, uint8_t* data, uint8_t* e, uint32_t nof_bits, uint32_t E, uint16_t rnti) { - uint8_t tmp[3 * (SRSLTE_DCI_MAX_BITS + 16)]; + uint8_t tmp[3 * (SRSRAN_DCI_MAX_BITS + 16)]; - if (q != NULL && data != NULL && e != NULL && nof_bits < SRSLTE_DCI_MAX_BITS && E <= q->max_bits) { - srslte_npdcch_dci_encode_conv(q, data, nof_bits, tmp, rnti); + if (q != NULL && data != NULL && e != NULL && nof_bits < SRSRAN_DCI_MAX_BITS && E <= q->max_bits) { + srsran_npdcch_dci_encode_conv(q, data, nof_bits, tmp, rnti); DEBUG("CConv output: "); - if (SRSLTE_VERBOSE_ISDEBUG()) { - srslte_vec_fprint_b(stdout, tmp, 3 * (nof_bits + 16)); + if (SRSRAN_VERBOSE_ISDEBUG()) { + srsran_vec_fprint_b(stdout, tmp, 3 * (nof_bits + 16)); } - srslte_rm_conv_tx(tmp, 3 * (nof_bits + 16), e, E); + srsran_rm_conv_tx(tmp, 3 * (nof_bits + 16), e, E); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } else { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } } -int srslte_npdcch_encode(srslte_npdcch_t* q, - srslte_dci_msg_t* msg, - srslte_dci_location_t location, +int srsran_npdcch_encode(srsran_npdcch_t* q, + srsran_dci_msg_t* msg, + srsran_dci_location_t location, uint16_t rnti, - cf_t* sf_symbols[SRSLTE_MAX_PORTS], + cf_t* sf_symbols[SRSRAN_MAX_PORTS], uint32_t nsubframe) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; - if (q != NULL && sf_symbols != NULL && nsubframe < 10 && srslte_nbiot_dci_location_isvalid(&location)) { - ret = SRSLTE_ERROR; + if (q != NULL && sf_symbols != NULL && nsubframe < 10 && srsran_nbiot_dci_location_isvalid(&location)) { + ret = SRSRAN_ERROR; uint32_t e_bits = q->nof_cce * q->ncce_bits; uint32_t nof_symbols = e_bits / 2; - if (msg->nof_bits < SRSLTE_DCI_MAX_BITS - 16) { + if (msg->nof_bits < SRSRAN_DCI_MAX_BITS - 16) { DEBUG("Encoding DCI: Nbits: %d, E: %d, nCCE: %d, L: %d, RNTI: 0x%x, sf_idx: %d", msg->nof_bits, e_bits, @@ -485,64 +485,64 @@ int srslte_npdcch_encode(srslte_npdcch_t* q, rnti, nsubframe); - if (srslte_npdcch_dci_encode(q, msg->payload, q->e, msg->nof_bits, e_bits, rnti) != SRSLTE_SUCCESS) { + if (srsran_npdcch_dci_encode(q, msg->payload, q->e, msg->nof_bits, e_bits, rnti) != SRSRAN_SUCCESS) { fprintf(stderr, "Error encoding DCI\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // number of layers equals number of ports - cf_t* x[SRSLTE_MAX_LAYERS] = {NULL}; + cf_t* x[SRSRAN_MAX_LAYERS] = {NULL}; for (int i = 0; i < q->cell.nof_ports; i++) { x[i] = q->x[i]; } - memset(&x[q->cell.nof_ports], 0, sizeof(cf_t*) * (SRSLTE_MAX_LAYERS - q->cell.nof_ports)); + memset(&x[q->cell.nof_ports], 0, sizeof(cf_t*) * (SRSRAN_MAX_LAYERS - q->cell.nof_ports)); #if DUMP_SIGNALS - if (SRSLTE_VERBOSE_ISDEBUG()) { + if (SRSRAN_VERBOSE_ISDEBUG()) { DEBUG("SAVED FILE npdcch_tx_scramble_input.bin: NPDCCH before scrambling"); - srslte_vec_save_file("npdcch_tx_scramble_input.bin", q->e, e_bits); + srsran_vec_save_file("npdcch_tx_scramble_input.bin", q->e, e_bits); } #endif - srslte_scrambling_b_offset(&q->seq[nsubframe], q->e, 72 * location.ncce, e_bits); + srsran_scrambling_b_offset(&q->seq[nsubframe], q->e, 72 * location.ncce, e_bits); #if DUMP_SIGNALS - if (SRSLTE_VERBOSE_ISDEBUG()) { + if (SRSRAN_VERBOSE_ISDEBUG()) { DEBUG("SAVED FILE npdcch_tx_mod_input.bin: NPDCCH before modulation"); - srslte_vec_save_file("npdcch_tx_mod_input.bin", q->e, e_bits); + srsran_vec_save_file("npdcch_tx_mod_input.bin", q->e, e_bits); } #endif - srslte_mod_modulate(&q->mod, q->e, q->d, e_bits); + srsran_mod_modulate(&q->mod, q->e, q->d, e_bits); #if DUMP_SIGNALS - if (SRSLTE_VERBOSE_ISDEBUG()) { + if (SRSRAN_VERBOSE_ISDEBUG()) { DEBUG("SAVED FILE npdcch_tx_precode_input.bin: NPDCCH before precoding symbols"); - srslte_vec_save_file("npdcch_tx_precode_input.bin", q->d, nof_symbols * sizeof(cf_t)); + srsran_vec_save_file("npdcch_tx_precode_input.bin", q->d, nof_symbols * sizeof(cf_t)); } #endif // layer mapping & precoding if (q->cell.nof_ports > 1) { - srslte_layermap_diversity(q->d, x, q->cell.nof_ports, nof_symbols); - srslte_precoding_diversity(x, q->symbols, q->cell.nof_ports, nof_symbols / q->cell.nof_ports, 1.0); + srsran_layermap_diversity(q->d, x, q->cell.nof_ports, nof_symbols); + srsran_precoding_diversity(x, q->symbols, q->cell.nof_ports, nof_symbols / q->cell.nof_ports, 1.0); } else { memcpy(q->symbols[0], q->d, nof_symbols * sizeof(cf_t)); } #if DUMP_SIGNALS - if (SRSLTE_VERBOSE_ISDEBUG()) { + if (SRSRAN_VERBOSE_ISDEBUG()) { DEBUG("SAVED FILE npdcch_tx_mapping_input.bin: NPDCCH before mapping to resource elements"); - srslte_vec_save_file("npdcch_tx_mapping_input.bin", q->symbols[0], nof_symbols * sizeof(cf_t)); + srsran_vec_save_file("npdcch_tx_mapping_input.bin", q->symbols[0], nof_symbols * sizeof(cf_t)); } #endif // mapping to resource elements for (int i = 0; i < q->cell.nof_ports; i++) { - srslte_npdcch_put(q, q->symbols[i], sf_symbols[i], SRSLTE_NPDCCH_FORMAT1); + srsran_npdcch_put(q, q->symbols[i], sf_symbols[i], SRSRAN_NPDCCH_FORMAT1); } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } else { fprintf(stderr, "Illegal DCI message nCCE: %d, L: %d, nof_cce: %d\n", location.ncce, location.L, q->nof_cce); } @@ -557,7 +557,7 @@ int srslte_npdcch_encode(srslte_npdcch_t* q, * in the structure pointed by c. * Returns the number of candidates saved in the array c. */ -uint32_t srslte_npdcch_ue_locations(srslte_dci_location_t* c, uint32_t max_candidates) +uint32_t srsran_npdcch_ue_locations(srsran_dci_location_t* c, uint32_t max_candidates) { // NPDCCH format 1 takes both NCCE c[0].L = 2; @@ -573,16 +573,16 @@ uint32_t srslte_npdcch_ue_locations(srslte_dci_location_t* c, uint32_t max_candi return max_candidates; } -uint32_t srslte_npdcch_common_locations(srslte_dci_location_t* c, uint32_t max_candidates) +uint32_t srsran_npdcch_common_locations(srsran_dci_location_t* c, uint32_t max_candidates) { - return srslte_npdcch_ue_locations(c, max_candidates); + return srsran_npdcch_ue_locations(c, max_candidates); } -int srslte_npdcch_cp(srslte_npdcch_t* q, cf_t* input, cf_t* output, bool put, srslte_npdcch_format_t format) +int srsran_npdcch_cp(srsran_npdcch_t* q, cf_t* input, cf_t* output, bool put, srsran_npdcch_format_t format) { // sanity check if (q == NULL || input == NULL || output == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } #if RE_EXT_DEBUG @@ -593,18 +593,18 @@ int srslte_npdcch_cp(srslte_npdcch_t* q, cf_t* input, cf_t* output, bool put, sr bool skip_crs = false; if (put) { - out_ptr += (q->i_n_start * q->cell.base.nof_prb * SRSLTE_NRE) + q->cell.nbiot_prb * SRSLTE_NRE; + out_ptr += (q->i_n_start * q->cell.base.nof_prb * SRSRAN_NRE) + q->cell.nbiot_prb * SRSRAN_NRE; } else { - in_ptr += (q->i_n_start * q->cell.base.nof_prb * SRSLTE_NRE) + q->cell.nbiot_prb * SRSLTE_NRE; + in_ptr += (q->i_n_start * q->cell.base.nof_prb * SRSRAN_NRE) + q->cell.nbiot_prb * SRSRAN_NRE; } - if (q->cell.mode == SRSLTE_NBIOT_MODE_INBAND_SAME_PCI || q->cell.mode == SRSLTE_NBIOT_MODE_INBAND_DIFFERENT_PCI) { + if (q->cell.mode == SRSRAN_NBIOT_MODE_INBAND_SAME_PCI || q->cell.mode == SRSRAN_NBIOT_MODE_INBAND_DIFFERENT_PCI) { skip_crs = true; } // start mapping at specified OFDM symbol - for (int l = q->i_n_start; l < SRSLTE_CP_NORM_SF_NSYMB; l++) { - uint32_t delta = (q->cell.base.nof_prb - 1) * SRSLTE_NRE; // the number of REs skipped in each OFDM symbol + for (int l = q->i_n_start; l < SRSRAN_CP_NORM_SF_NSYMB; l++) { + uint32_t delta = (q->cell.base.nof_prb - 1) * SRSRAN_NRE; // the number of REs skipped in each OFDM symbol uint32_t offset = 0; // the number of REs left out before start of the REF signal RE if (l == 5 || l == 6 || l == 12 || l == 13) { // always skip NRS @@ -621,44 +621,44 @@ int srslte_npdcch_cp(srslte_npdcch_t* q, cf_t* input, cf_t* output, bool put, sr delta = (q->cell.n_id_ncell + ((q->cell.n_id_ncell >= 5) ? 0 : 3)) % 6 == 5 ? 1 : 0; } else { // TODO: not handled right now - return SRSLTE_ERROR; + return SRSRAN_ERROR; } switch (format) { - case SRSLTE_NPDCCH_FORMAT0_LOWER_HALF: + case SRSRAN_NPDCCH_FORMAT0_LOWER_HALF: prb_cp_ref(&in_ptr, &out_ptr, offset, q->nof_nbiot_refs, q->nof_nbiot_refs, put); // we have copied too much, rewind ptr if (put) { - in_ptr -= (SRSLTE_NRE - q->nof_nbiot_refs) / 2; + in_ptr -= (SRSRAN_NRE - q->nof_nbiot_refs) / 2; } else { - out_ptr -= (SRSLTE_NRE - q->nof_nbiot_refs) / 2; + out_ptr -= (SRSRAN_NRE - q->nof_nbiot_refs) / 2; } break; - case SRSLTE_NPDCCH_FORMAT0_UPPER_HALF: + case SRSRAN_NPDCCH_FORMAT0_UPPER_HALF: // TODO: this causes valgrind to detect an invalid memory access #if 0 // skip lower half if (put) { - out_ptr += SRSLTE_NRE / 2; + out_ptr += SRSRAN_NRE / 2; } else { - in_ptr += SRSLTE_NRE / 2; + in_ptr += SRSRAN_NRE / 2; } #endif // copy REs prb_cp_ref(&in_ptr, &out_ptr, offset, q->nof_nbiot_refs, q->nof_nbiot_refs, put); // we have copied too much, rewind ptr if (put) { - in_ptr -= (SRSLTE_NRE - q->nof_nbiot_refs) / 2; + in_ptr -= (SRSRAN_NRE - q->nof_nbiot_refs) / 2; } else { - out_ptr -= (SRSLTE_NRE - q->nof_nbiot_refs) / 2; + out_ptr -= (SRSRAN_NRE - q->nof_nbiot_refs) / 2; } break; - case SRSLTE_NPDCCH_FORMAT1: + case SRSRAN_NPDCCH_FORMAT1: prb_cp_ref(&in_ptr, &out_ptr, offset, q->nof_nbiot_refs, q->nof_nbiot_refs, put); break; default: printf("Wrong NPDCCH format!\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } else if ((l == 0 || l == 4 || l == 7 || l == 11) && skip_crs) { // skip LTE's CRS (TODO: use base cell ID?) @@ -676,65 +676,65 @@ int srslte_npdcch_cp(srslte_npdcch_t* q, cf_t* input, cf_t* output, bool put, sr } switch (format) { - case SRSLTE_NPDCCH_FORMAT0_LOWER_HALF: + case SRSRAN_NPDCCH_FORMAT0_LOWER_HALF: prb_cp_ref(&in_ptr, &out_ptr, offset, q->nof_lte_refs, q->nof_lte_refs, put); // we have copied too much, rewind ptr if (put) { - in_ptr -= (SRSLTE_NRE - q->nof_lte_refs) / 2; + in_ptr -= (SRSRAN_NRE - q->nof_lte_refs) / 2; } else { - out_ptr -= (SRSLTE_NRE - q->nof_lte_refs) / 2; + out_ptr -= (SRSRAN_NRE - q->nof_lte_refs) / 2; } break; - case SRSLTE_NPDCCH_FORMAT0_UPPER_HALF: + case SRSRAN_NPDCCH_FORMAT0_UPPER_HALF: // skip lower half if (put) { - out_ptr += SRSLTE_NRE / 2; + out_ptr += SRSRAN_NRE / 2; } else { - in_ptr += SRSLTE_NRE / 2; + in_ptr += SRSRAN_NRE / 2; } // copy REs prb_cp_ref(&in_ptr, &out_ptr, offset, q->nof_lte_refs, q->nof_lte_refs, put); // we have copied too much, rewind ptr if (put) { - in_ptr -= (SRSLTE_NRE - q->nof_lte_refs) / 2; + in_ptr -= (SRSRAN_NRE - q->nof_lte_refs) / 2; } else { - out_ptr -= (SRSLTE_NRE - q->nof_lte_refs) / 2; + out_ptr -= (SRSRAN_NRE - q->nof_lte_refs) / 2; } break; - case SRSLTE_NPDCCH_FORMAT1: + case SRSRAN_NPDCCH_FORMAT1: prb_cp_ref(&in_ptr, &out_ptr, offset, q->nof_lte_refs, q->nof_lte_refs, put); break; default: printf("Wrong NPDCCH format!\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } else { switch (format) { - case SRSLTE_NPDCCH_FORMAT0_LOWER_HALF: + case SRSRAN_NPDCCH_FORMAT0_LOWER_HALF: prb_cp_half(&in_ptr, &out_ptr, 1); // skip upper half if (put) { - out_ptr += SRSLTE_NRE / 2; + out_ptr += SRSRAN_NRE / 2; } else { - in_ptr += SRSLTE_NRE / 2; + in_ptr += SRSRAN_NRE / 2; } break; - case SRSLTE_NPDCCH_FORMAT0_UPPER_HALF: + case SRSRAN_NPDCCH_FORMAT0_UPPER_HALF: // skip lower half if (put) { - out_ptr += SRSLTE_NRE / 2; + out_ptr += SRSRAN_NRE / 2; } else { - in_ptr += SRSLTE_NRE / 2; + in_ptr += SRSRAN_NRE / 2; } prb_cp_half(&in_ptr, &out_ptr, 1); break; - case SRSLTE_NPDCCH_FORMAT1: + case SRSRAN_NPDCCH_FORMAT1: // occupy entire symbol prb_cp(&in_ptr, &out_ptr, 1); break; default: printf("Wrong NPDCCH format!\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } @@ -751,7 +751,7 @@ int srslte_npdcch_cp(srslte_npdcch_t* q, cf_t* input, cf_t* output, bool put, sr abs((int)(output - out_ptr)), l, num_extracted_this_sym); - srslte_vec_fprint_c(stdout, &output[num_extracted], num_extracted_this_sym); + srsran_vec_fprint_c(stdout, &output[num_extracted], num_extracted_this_sym); num_extracted = abs((int)(output - out_ptr)); #endif } @@ -773,9 +773,9 @@ int srslte_npdcch_cp(srslte_npdcch_t* q, cf_t* input, cf_t* output, bool put, sr * * 36.211 10.3 section 6.3.5 */ -int srslte_npdcch_put(srslte_npdcch_t* q, cf_t* symbols, cf_t* sf_symbols, srslte_npdcch_format_t format) +int srsran_npdcch_put(srsran_npdcch_t* q, cf_t* symbols, cf_t* sf_symbols, srsran_npdcch_format_t format) { - return srslte_npdcch_cp(q, symbols, sf_symbols, true, format); + return srsran_npdcch_cp(q, symbols, sf_symbols, true, format); } /** @@ -785,7 +785,7 @@ int srslte_npdcch_put(srslte_npdcch_t* q, cf_t* symbols, cf_t* sf_symbols, srslt * * 36.211 10.3 section 6.3.5 */ -int srslte_npdcch_get(srslte_npdcch_t* q, cf_t* sf_symbols, cf_t* symbols, srslte_npdcch_format_t format) +int srsran_npdcch_get(srsran_npdcch_t* q, cf_t* sf_symbols, cf_t* symbols, srsran_npdcch_format_t format) { - return srslte_npdcch_cp(q, sf_symbols, symbols, false, format); + return srsran_npdcch_cp(q, sf_symbols, symbols, false, format); } diff --git a/lib/src/phy/phch/npdsch.c b/lib/src/phy/phch/npdsch.c index a48bc5d1f..5982d5ef3 100644 --- a/lib/src/phy/phch/npdsch.c +++ b/lib/src/phy/phch/npdsch.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -19,19 +19,19 @@ #include #include "prb_dl.h" -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/fec/convolutional/rm_conv.h" -#include "srslte/phy/phch/npdsch.h" -#include "srslte/phy/utils/bit.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/fec/convolutional/rm_conv.h" +#include "srsran/phy/phch/npdsch.h" +#include "srsran/phy/utils/bit.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" -#define CURRENT_SFLEN_RE SRSLTE_SF_LEN_RE(q->cell.base.nof_prb, q->cell.base.cp) +#define CURRENT_SFLEN_RE SRSRAN_SF_LEN_RE(q->cell.base.nof_prb, q->cell.base.cp) #define DUMP_SIGNALS 0 #define RE_EXT_DEBUG 0 -int srslte_npdsch_cp(srslte_npdsch_t* q, cf_t* input, cf_t* output, srslte_ra_nbiot_dl_grant_t* grant, bool put) +int srsran_npdsch_cp(srsran_npdsch_t* q, cf_t* input, cf_t* output, srsran_ra_nbiot_dl_grant_t* grant, bool put) { uint32_t l, nof_lte_refs, nof_nbiot_refs; cf_t * in_ptr = input, *out_ptr = output; @@ -46,9 +46,9 @@ int srslte_npdsch_cp(srslte_npdsch_t* q, cf_t* input, cf_t* output, srslte_ra_nb } if (put) { - out_ptr += (grant->l_start * q->cell.base.nof_prb * SRSLTE_NRE) + q->cell.nbiot_prb * SRSLTE_NRE; + out_ptr += (grant->l_start * q->cell.base.nof_prb * SRSRAN_NRE) + q->cell.nbiot_prb * SRSRAN_NRE; } else { - in_ptr += (grant->l_start * q->cell.base.nof_prb * SRSLTE_NRE) + q->cell.nbiot_prb * SRSLTE_NRE; + in_ptr += (grant->l_start * q->cell.base.nof_prb * SRSRAN_NRE) + q->cell.nbiot_prb * SRSRAN_NRE; } if (q->cell.nof_ports == 1) { @@ -64,11 +64,11 @@ int srslte_npdsch_cp(srslte_npdsch_t* q, cf_t* input, cf_t* output, srslte_ra_nb } bool skip_crs = false; - if (q->cell.mode == SRSLTE_NBIOT_MODE_INBAND_SAME_PCI || q->cell.mode == SRSLTE_NBIOT_MODE_INBAND_DIFFERENT_PCI) { + if (q->cell.mode == SRSRAN_NBIOT_MODE_INBAND_SAME_PCI || q->cell.mode == SRSRAN_NBIOT_MODE_INBAND_DIFFERENT_PCI) { skip_crs = true; } - if (q->cell.mode == SRSLTE_NBIOT_MODE_INBAND_SAME_PCI && q->cell.n_id_ncell != q->cell.base.id) { + if (q->cell.mode == SRSRAN_NBIOT_MODE_INBAND_SAME_PCI && q->cell.n_id_ncell != q->cell.base.id) { fprintf(stderr, "Cell IDs must match in operation mode inband same PCI (%d != %d)\n", q->cell.n_id_ncell, @@ -77,8 +77,8 @@ int srslte_npdsch_cp(srslte_npdsch_t* q, cf_t* input, cf_t* output, srslte_ra_nb } // start mapping at specified OFDM symbol - for (l = grant->l_start; l < SRSLTE_CP_NORM_SF_NSYMB; l++) { - uint32_t delta = (q->cell.base.nof_prb - 1) * SRSLTE_NRE; // the number of REs skipped in each OFDM symbol + for (l = grant->l_start; l < SRSRAN_CP_NORM_SF_NSYMB; l++) { + uint32_t delta = (q->cell.base.nof_prb - 1) * SRSRAN_NRE; // the number of REs skipped in each OFDM symbol uint32_t offset = 0; // the number of REs left out before start of the REF signal RE if (l == 5 || l == 6 || l == 12 || l == 13) { // always skip NRS @@ -95,7 +95,7 @@ int srslte_npdsch_cp(srslte_npdsch_t* q, cf_t* input, cf_t* output, srslte_ra_nb delta = (q->cell.n_id_ncell + ((q->cell.n_id_ncell >= 5) ? 0 : 3)) % 6 == 5 ? 1 : 0; } else { fprintf(stderr, "Error %d NB-IoT reference symbols not supported.\n", nof_nbiot_refs); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } prb_cp_ref(&in_ptr, &out_ptr, offset, nof_nbiot_refs, nof_nbiot_refs, put); } else if ((l == 0 || l == 4 || l == 7 || l == 11) && skip_crs) { @@ -131,7 +131,7 @@ int srslte_npdsch_cp(srslte_npdsch_t* q, cf_t* input, cf_t* output, srslte_ra_nb abs((int)(output - out_ptr)), l, num_extracted_this_sym); - srslte_vec_fprint_c(stdout, &output[num_extracted], num_extracted_this_sym); + srsran_vec_fprint_c(stdout, &output[num_extracted], num_extracted_this_sym); num_extracted = abs((int)(output - out_ptr)); #endif } @@ -153,9 +153,9 @@ int srslte_npdsch_cp(srslte_npdsch_t* q, cf_t* input, cf_t* output, srslte_ra_nb * * 36.211 10.3 section 6.3.5 */ -int srslte_npdsch_put(srslte_npdsch_t* q, cf_t* symbols, cf_t* sf_symbols, srslte_ra_nbiot_dl_grant_t* grant) +int srsran_npdsch_put(srsran_npdsch_t* q, cf_t* symbols, cf_t* sf_symbols, srsran_ra_nbiot_dl_grant_t* grant) { - return srslte_npdsch_cp(q, symbols, sf_symbols, grant, true); + return srsran_npdsch_cp(q, symbols, sf_symbols, grant, true); } /** @@ -165,34 +165,34 @@ int srslte_npdsch_put(srslte_npdsch_t* q, cf_t* symbols, cf_t* sf_symbols, srslt * * 36.211 10.3 section 6.3.5 */ -int srslte_npdsch_get(srslte_npdsch_t* q, cf_t* sf_symbols, cf_t* symbols, srslte_ra_nbiot_dl_grant_t* grant) +int srsran_npdsch_get(srsran_npdsch_t* q, cf_t* sf_symbols, cf_t* symbols, srsran_ra_nbiot_dl_grant_t* grant) { - return srslte_npdsch_cp(q, sf_symbols, symbols, grant, false); + return srsran_npdsch_cp(q, sf_symbols, symbols, grant, false); } /** Initializes the NPDSCH transmitter and receiver */ -int srslte_npdsch_init(srslte_npdsch_t* q) +int srsran_npdsch_init(srsran_npdsch_t* q) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL) { - bzero(q, sizeof(srslte_npdsch_t)); - ret = SRSLTE_ERROR; + bzero(q, sizeof(srsran_npdsch_t)); + ret = SRSRAN_ERROR; - q->max_re = SRSLTE_NPDSCH_MAX_RE * SRSLTE_NPDSCH_MAX_NOF_SF; + q->max_re = SRSRAN_NPDSCH_MAX_RE * SRSRAN_NPDSCH_MAX_NOF_SF; q->rnti_is_set = false; INFO("Init NPDSCH: max_re's: %d", q->max_re); - if (srslte_modem_table_lte(&q->mod, SRSLTE_MOD_QPSK)) { + if (srsran_modem_table_lte(&q->mod, SRSRAN_MOD_QPSK)) { goto clean; } int poly[3] = {0x6D, 0x4F, 0x57}; - if (srslte_viterbi_init(&q->decoder, SRSLTE_VITERBI_37, poly, SRSLTE_NPDSCH_MAX_TBS_CRC, true)) { + if (srsran_viterbi_init(&q->decoder, SRSRAN_VITERBI_37, poly, SRSRAN_NPDSCH_MAX_TBS_CRC, true)) { goto clean; } - if (srslte_crc_init(&q->crc, SRSLTE_LTE_CRC24A, SRSLTE_NPDSCH_CRC_LEN)) { + if (srsran_crc_init(&q->crc, SRSRAN_LTE_CRC24A, SRSRAN_NPDSCH_CRC_LEN)) { goto clean; } q->encoder.K = 7; @@ -200,55 +200,55 @@ int srslte_npdsch_init(srslte_npdsch_t* q) q->encoder.tail_biting = true; memcpy(q->encoder.poly, poly, 3 * sizeof(int)); - q->d = srslte_vec_cf_malloc(q->max_re); + q->d = srsran_vec_cf_malloc(q->max_re); if (!q->d) { goto clean; } - for (uint32_t i = 0; i < SRSLTE_MAX_PORTS; i++) { - q->ce[i] = srslte_vec_cf_malloc(q->max_re); + for (uint32_t i = 0; i < SRSRAN_MAX_PORTS; i++) { + q->ce[i] = srsran_vec_cf_malloc(q->max_re); if (!q->ce[i]) { goto clean; } for (int k = 0; k < q->max_re / 2; k++) { q->ce[i][k] = 1; } - q->x[i] = srslte_vec_cf_malloc(q->max_re); + q->x[i] = srsran_vec_cf_malloc(q->max_re); if (!q->x[i]) { goto clean; } - q->symbols[i] = srslte_vec_cf_malloc(q->max_re); + q->symbols[i] = srsran_vec_cf_malloc(q->max_re); if (!q->symbols[i]) { goto clean; } - q->sib_symbols[i] = srslte_vec_cf_malloc(q->max_re); + q->sib_symbols[i] = srsran_vec_cf_malloc(q->max_re); if (!q->sib_symbols[i]) { goto clean; } } - q->llr = srslte_vec_f_malloc(q->max_re * 2); + q->llr = srsran_vec_f_malloc(q->max_re * 2); if (!q->llr) { goto clean; } bzero(q->llr, sizeof(float) * q->max_re * 2); - q->temp = srslte_vec_u8_malloc(SRSLTE_NPDSCH_MAX_TBS_CRC); + q->temp = srsran_vec_u8_malloc(SRSRAN_NPDSCH_MAX_TBS_CRC); if (!q->temp) { goto clean; } - q->rm_b = srslte_vec_u8_malloc(q->max_re * 2); + q->rm_b = srsran_vec_u8_malloc(q->max_re * 2); if (!q->rm_b) { goto clean; } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } clean: - if (ret == SRSLTE_ERROR) { - srslte_npdsch_free(q); + if (ret == SRSRAN_ERROR) { + srsran_npdsch_free(q); } return ret; } -void srslte_npdsch_free(srslte_npdsch_t* q) +void srsran_npdsch_free(srsran_npdsch_t* q) { if (q->d) { free(q->d); @@ -262,7 +262,7 @@ void srslte_npdsch_free(srslte_npdsch_t* q) if (q->llr) { free(q->llr); } - for (uint32_t i = 0; i < SRSLTE_MAX_PORTS; i++) { + for (uint32_t i = 0; i < SRSRAN_MAX_PORTS; i++) { if (q->ce[i]) { free(q->ce[i]); } @@ -276,20 +276,20 @@ void srslte_npdsch_free(srslte_npdsch_t* q) free(q->sib_symbols[i]); } } - for (uint32_t i = 0; i < SRSLTE_NPDSCH_NUM_SEQ; i++) { - srslte_sequence_free(&q->seq[i]); + for (uint32_t i = 0; i < SRSRAN_NPDSCH_NUM_SEQ; i++) { + srsran_sequence_free(&q->seq[i]); } - srslte_modem_table_free(&q->mod); - srslte_viterbi_free(&q->decoder); - bzero(q, sizeof(srslte_npdsch_t)); + srsran_modem_table_free(&q->mod); + srsran_viterbi_free(&q->decoder); + bzero(q, sizeof(srsran_npdsch_t)); } -int srslte_npdsch_set_cell(srslte_npdsch_t* q, srslte_nbiot_cell_t cell) +int srsran_npdsch_set_cell(srsran_npdsch_t* q, srsran_nbiot_cell_t cell) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; - if (q != NULL && srslte_nbiot_cell_isvalid(&cell)) { + if (q != NULL && srsran_nbiot_cell_isvalid(&cell)) { q->cell = cell; INFO("NPDSCH: Cell config n_id_ncell=%d, %d ports, %d PRBs base cell, max_symbols: %d", @@ -298,7 +298,7 @@ int srslte_npdsch_set_cell(srslte_npdsch_t* q, srslte_nbiot_cell_t cell) q->cell.base.nof_prb, q->max_re); - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } @@ -307,55 +307,55 @@ int srslte_npdsch_set_cell(srslte_npdsch_t* q, srslte_nbiot_cell_t cell) * to execute, so shall be called once the final C-RNTI has been allocated for the session. * It computes sequences for all subframes for both even and odd SFN's, a total of 20 */ -int srslte_npdsch_set_rnti(srslte_npdsch_t* q, uint16_t rnti) +int srsran_npdsch_set_rnti(srsran_npdsch_t* q, uint16_t rnti) { for (int k = 0; k < 2; k++) { - for (int i = 0; i < SRSLTE_NOF_SF_X_FRAME; i++) { - if (srslte_sequence_npdsch(&q->seq[k * SRSLTE_NOF_SF_X_FRAME + i], + for (int i = 0; i < SRSRAN_NOF_SF_X_FRAME; i++) { + if (srsran_sequence_npdsch(&q->seq[k * SRSRAN_NOF_SF_X_FRAME + i], rnti, 0, k, 2 * i, q->cell.n_id_ncell, - q->max_re * srslte_mod_bits_x_symbol(SRSLTE_MOD_QPSK))) { - return SRSLTE_ERROR; + q->max_re * srsran_mod_bits_x_symbol(SRSRAN_MOD_QPSK))) { + return SRSRAN_ERROR; } } } q->rnti_is_set = true; q->rnti = rnti; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_npdsch_decode(srslte_npdsch_t* q, - srslte_npdsch_cfg_t* cfg, - srslte_softbuffer_rx_t* softbuffer, +int srsran_npdsch_decode(srsran_npdsch_t* q, + srsran_npdsch_cfg_t* cfg, + srsran_softbuffer_rx_t* softbuffer, cf_t* sf_symbols, - cf_t* ce[SRSLTE_MAX_PORTS], + cf_t* ce[SRSRAN_MAX_PORTS], float noise_estimate, uint32_t sfn, uint8_t* data) { if (q != NULL && sf_symbols != NULL && data != NULL && cfg != NULL) { if (q->rnti_is_set) { - return srslte_npdsch_decode_rnti(q, cfg, softbuffer, sf_symbols, ce, noise_estimate, q->rnti, sfn, data, 0); + return srsran_npdsch_decode_rnti(q, cfg, softbuffer, sf_symbols, ce, noise_estimate, q->rnti, sfn, data, 0); } else { - fprintf(stderr, "Must call srslte_npdsch_set_rnti() before calling srslte_npdsch_decode()\n"); - return SRSLTE_ERROR; + fprintf(stderr, "Must call srsran_npdsch_set_rnti() before calling srsran_npdsch_decode()\n"); + return SRSRAN_ERROR; } } else { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } } /** Decodes the NPDSCH from the received symbols */ -int srslte_npdsch_decode_rnti(srslte_npdsch_t* q, - srslte_npdsch_cfg_t* cfg, - srslte_softbuffer_rx_t* softbuffer, +int srsran_npdsch_decode_rnti(srsran_npdsch_t* q, + srsran_npdsch_cfg_t* cfg, + srsran_softbuffer_rx_t* softbuffer, cf_t* sf_symbols, - cf_t* ce[SRSLTE_MAX_PORTS], + cf_t* ce[SRSRAN_MAX_PORTS], float noise_estimate, uint16_t rnti, uint32_t sfn, @@ -364,13 +364,13 @@ int srslte_npdsch_decode_rnti(srslte_npdsch_t* q, { // Set pointers for layermapping & precoding uint32_t n; - cf_t* x[SRSLTE_MAX_LAYERS]; + cf_t* x[SRSRAN_MAX_LAYERS]; if (q != NULL && sf_symbols != NULL && data != NULL && cfg != NULL) { INFO("%d.x: Decoding NPDSCH: RNTI: 0x%x, Mod %s, TBS: %d, NofSymbols: %d * %d, NofBitsE: %d * %d", sfn, rnti, - srslte_mod_string(cfg->grant.mcs[0].mod), + srsran_mod_string(cfg->grant.mcs[0].mod), cfg->grant.mcs[0].tbs, cfg->grant.nof_sf, cfg->nbits.nof_re, @@ -381,24 +381,24 @@ int srslte_npdsch_decode_rnti(srslte_npdsch_t* q, for (int i = 0; i < q->cell.nof_ports; i++) { x[i] = q->x[i]; } - memset(&x[q->cell.nof_ports], 0, sizeof(cf_t*) * (SRSLTE_MAX_LAYERS - q->cell.nof_ports)); + memset(&x[q->cell.nof_ports], 0, sizeof(cf_t*) * (SRSRAN_MAX_LAYERS - q->cell.nof_ports)); // extract RE of all subframes of this grant uint32_t total_syms = 0; for (int i = 0; i < cfg->grant.nof_sf; i++) { // extract symbols - n = srslte_npdsch_get(q, &sf_symbols[i * CURRENT_SFLEN_RE], &q->symbols[0][i * cfg->nbits.nof_re], &cfg->grant); + n = srsran_npdsch_get(q, &sf_symbols[i * CURRENT_SFLEN_RE], &q->symbols[0][i * cfg->nbits.nof_re], &cfg->grant); if (n != cfg->nbits.nof_re) { fprintf(stderr, "Error expecting %d symbols but got %d\n", cfg->nbits.nof_re, n); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // extract channel estimates for (int k = 0; k < q->cell.nof_ports; k++) { - n = srslte_npdsch_get(q, &ce[k][i * CURRENT_SFLEN_RE], &q->ce[k][i * cfg->nbits.nof_re], &cfg->grant); + n = srsran_npdsch_get(q, &ce[k][i * CURRENT_SFLEN_RE], &q->ce[k][i * cfg->nbits.nof_re], &cfg->grant); if (n != cfg->nbits.nof_re) { fprintf(stderr, "Error expecting %d symbols but got %d\n", cfg->nbits.nof_re, n); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } total_syms += cfg->nbits.nof_re; @@ -406,13 +406,13 @@ int srslte_npdsch_decode_rnti(srslte_npdsch_t* q, if (total_syms != cfg->grant.nof_sf * cfg->nbits.nof_re) { fprintf(stderr, "Error expecting %d symbols but got %d\n", cfg->grant.nof_sf * cfg->nbits.nof_re, total_syms); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } #if DUMP_SIGNALS - if (SRSLTE_VERBOSE_ISDEBUG()) { + if (SRSRAN_VERBOSE_ISDEBUG()) { DEBUG("SAVED FILE npdsch_rx_mapping_output.bin: NPDSCH after extracting symbols", 0); - srslte_vec_save_file( + srsran_vec_save_file( "npdsch_rx_mapping_output.bin", q->symbols[0], cfg->grant.nof_sf * cfg->nbits.nof_re * sizeof(cf_t)); } #endif @@ -420,110 +420,110 @@ int srslte_npdsch_decode_rnti(srslte_npdsch_t* q, /* TODO: only diversity is supported */ if (q->cell.nof_ports == 1) { // no need for layer demapping - srslte_predecoding_single( + srsran_predecoding_single( q->symbols[0], q->ce[0], q->d, NULL, cfg->grant.nof_sf * cfg->nbits.nof_re, 1.0, noise_estimate); } else { - srslte_predecoding_diversity( + srsran_predecoding_diversity( q->symbols[0], q->ce, x, q->cell.nof_ports, cfg->grant.nof_sf * cfg->nbits.nof_re, 1.0); - srslte_layerdemap_diversity( + srsran_layerdemap_diversity( x, q->d, q->cell.nof_ports, cfg->grant.nof_sf * cfg->nbits.nof_re / q->cell.nof_ports); } #if DUMP_SIGNALS - if (SRSLTE_VERBOSE_ISDEBUG()) { + if (SRSRAN_VERBOSE_ISDEBUG()) { DEBUG("SAVED FILE npdsch_rx_predecode_output.bin: NPDSCH after predecoding symbols", 0); - srslte_vec_save_file( + srsran_vec_save_file( "npdsch_rx_predecode_output.bin", q->d, cfg->grant.nof_sf * cfg->nbits.nof_re * sizeof(cf_t)); } #endif // demodulate symbols - srslte_demod_soft_demodulate(SRSLTE_MOD_QPSK, q->d, q->llr, cfg->grant.nof_sf * cfg->nbits.nof_re); + srsran_demod_soft_demodulate(SRSRAN_MOD_QPSK, q->d, q->llr, cfg->grant.nof_sf * cfg->nbits.nof_re); #if DUMP_SIGNALS uint8_t demodbuf[320]; hard_qpsk_demod(q->d, demodbuf, cfg->nbits.nof_re); - if (SRSLTE_VERBOSE_ISDEBUG()) { + if (SRSRAN_VERBOSE_ISDEBUG()) { DEBUG("SAVED FILE npdsch_rx_demod_output.bin: NPDSCH after (hard) de-modulation", 0); - srslte_vec_save_file("npdsch_rx_demod_output.bin", demodbuf, cfg->nbits.nof_bits); + srsran_vec_save_file("npdsch_rx_demod_output.bin", demodbuf, cfg->nbits.nof_bits); } #endif // descramble - if (q->cell.is_r14 && rnti == SRSLTE_SIRNTI) { - srslte_sequence_t seq; - if (srslte_sequence_npdsch_bcch_r14( + if (q->cell.is_r14 && rnti == SRSRAN_SIRNTI) { + srsran_sequence_t seq; + if (srsran_sequence_npdsch_bcch_r14( &seq, cfg->grant.start_sfn, q->cell.n_id_ncell, cfg->grant.nof_sf * cfg->nbits.nof_bits)) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - srslte_scrambling_f_offset(&seq, q->llr, 0, cfg->grant.nof_sf * cfg->nbits.nof_bits); - srslte_sequence_free(&seq); + srsran_scrambling_f_offset(&seq, q->llr, 0, cfg->grant.nof_sf * cfg->nbits.nof_bits); + srsran_sequence_free(&seq); } else { if (rnti != q->rnti) { - srslte_sequence_t seq; - if (srslte_sequence_npdsch(&seq, + srsran_sequence_t seq; + if (srsran_sequence_npdsch(&seq, rnti, 0, cfg->grant.start_sfn, 2 * cfg->grant.start_sfidx, q->cell.n_id_ncell, cfg->grant.nof_sf * cfg->nbits.nof_bits)) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - srslte_scrambling_f_offset(&seq, q->llr, 0, cfg->grant.nof_sf * cfg->nbits.nof_bits); - srslte_sequence_free(&seq); + srsran_scrambling_f_offset(&seq, q->llr, 0, cfg->grant.nof_sf * cfg->nbits.nof_bits); + srsran_sequence_free(&seq); } else { // odd SFN's take the second half of the seq array - int seq_pos = ((cfg->grant.start_sfn % 2) * SRSLTE_NOF_SF_X_FRAME) + cfg->grant.start_sfidx; - srslte_scrambling_f_offset(&q->seq[seq_pos], q->llr, 0, cfg->grant.nof_sf * cfg->nbits.nof_bits); + int seq_pos = ((cfg->grant.start_sfn % 2) * SRSRAN_NOF_SF_X_FRAME) + cfg->grant.start_sfidx; + srsran_scrambling_f_offset(&q->seq[seq_pos], q->llr, 0, cfg->grant.nof_sf * cfg->nbits.nof_bits); } } #if DUMP_SIGNALS - if (SRSLTE_VERBOSE_ISDEBUG()) { + if (SRSRAN_VERBOSE_ISDEBUG()) { DEBUG("SAVED FILE npdsch_rx_descramble_output.bin: NPDSCH after de-scrambling", 0); - srslte_vec_save_file("npdsch_rx_descramble_output.bin", q->llr, cfg->nbits.nof_bits); + srsran_vec_save_file("npdsch_rx_descramble_output.bin", q->llr, cfg->nbits.nof_bits); } #endif // decode only this transmission - return srslte_npdsch_rm_and_decode(q, cfg, q->llr, data); + return srsran_npdsch_rm_and_decode(q, cfg, q->llr, data); } else { - fprintf(stderr, "srslte_npdsch_decode_rnti() called with invalid parameters.\n"); - return SRSLTE_ERROR_INVALID_INPUTS; + fprintf(stderr, "srsran_npdsch_decode_rnti() called with invalid parameters.\n"); + return SRSRAN_ERROR_INVALID_INPUTS; } } -int srslte_npdsch_rm_and_decode(srslte_npdsch_t* q, srslte_npdsch_cfg_t* cfg, float* softbits, uint8_t* data) +int srsran_npdsch_rm_and_decode(srsran_npdsch_t* q, srsran_npdsch_cfg_t* cfg, float* softbits, uint8_t* data) { // unrate-matching - uint32_t coded_len = 3 * (cfg->grant.mcs[0].tbs + SRSLTE_NPDSCH_CRC_LEN); - bzero(q->rm_f, sizeof(float) * SRSLTE_NPDSCH_MAX_TBS_ENC); - srslte_rm_conv_rx(softbits, cfg->grant.nof_sf * cfg->nbits.nof_bits, q->rm_f, coded_len); + uint32_t coded_len = 3 * (cfg->grant.mcs[0].tbs + SRSRAN_NPDSCH_CRC_LEN); + bzero(q->rm_f, sizeof(float) * SRSRAN_NPDSCH_MAX_TBS_ENC); + srsran_rm_conv_rx(softbits, cfg->grant.nof_sf * cfg->nbits.nof_bits, q->rm_f, coded_len); // TODO: normalization needed? // viterbi decoder - srslte_viterbi_decode_f(&q->decoder, q->rm_f, q->temp, cfg->grant.mcs[0].tbs + SRSLTE_NPDSCH_CRC_LEN); + srsran_viterbi_decode_f(&q->decoder, q->rm_f, q->temp, cfg->grant.mcs[0].tbs + SRSRAN_NPDSCH_CRC_LEN); #if DUMP_SIGNALS - if (SRSLTE_VERBOSE_ISDEBUG()) { + if (SRSRAN_VERBOSE_ISDEBUG()) { DEBUG("SAVED FILE npdsch_rx_viterbidecode_output.bin: NPDSCH after viterbi decoding", 0); - srslte_vec_save_file("npdsch_rx_viterbidecode_output.bin", q->temp, cfg->grant.mcs[0].tbs + SRSLTE_NPDSCH_CRC_LEN); + srsran_vec_save_file("npdsch_rx_viterbidecode_output.bin", q->temp, cfg->grant.mcs[0].tbs + SRSRAN_NPDSCH_CRC_LEN); } #endif // verify CRC sum uint8_t* x = &q->temp[cfg->grant.mcs[0].tbs]; - uint32_t tx_sum = srslte_bit_pack(&x, SRSLTE_NPDSCH_CRC_LEN); - uint32_t rx_sum = srslte_crc_checksum(&q->crc, q->temp, cfg->grant.mcs[0].tbs); + uint32_t tx_sum = srsran_bit_pack(&x, SRSRAN_NPDSCH_CRC_LEN); + uint32_t rx_sum = srsran_crc_checksum(&q->crc, q->temp, cfg->grant.mcs[0].tbs); if (rx_sum == tx_sum && rx_sum != 0) { - srslte_bit_pack_vector(q->temp, data, cfg->grant.mcs[0].tbs); - return SRSLTE_SUCCESS; + srsran_bit_pack_vector(q->temp, data, cfg->grant.mcs[0].tbs); + return SRSRAN_SUCCESS; } else { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } @@ -533,76 +533,76 @@ int srslte_npdsch_rm_and_decode(srslte_npdsch_t* q, srslte_npdsch_cfg_t* cfg, fl * it uses the is_encoded flag in the NPDSCH config object. * The same applies to its sister functions below. */ -int srslte_npdsch_encode(srslte_npdsch_t* q, - srslte_npdsch_cfg_t* cfg, - srslte_softbuffer_tx_t* softbuffer, +int srsran_npdsch_encode(srsran_npdsch_t* q, + srsran_npdsch_cfg_t* cfg, + srsran_softbuffer_tx_t* softbuffer, uint8_t* data, - cf_t* sf_symbols[SRSLTE_MAX_PORTS]) + cf_t* sf_symbols[SRSRAN_MAX_PORTS]) { if (q != NULL && data != NULL && cfg != NULL) { if (q->rnti_is_set) { - return srslte_npdsch_encode_rnti(q, cfg, softbuffer, data, q->rnti, sf_symbols); + return srsran_npdsch_encode_rnti(q, cfg, softbuffer, data, q->rnti, sf_symbols); } else { - fprintf(stderr, "Must call srslte_npdsch_set_rnti() to set the encoder/decoder RNTI\n"); - return SRSLTE_ERROR; + fprintf(stderr, "Must call srsran_npdsch_set_rnti() to set the encoder/decoder RNTI\n"); + return SRSRAN_ERROR; } } else { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } } /** Converts the PDSCH data bits to symbols mapped to the slot ready for transmission */ -int srslte_npdsch_encode_rnti(srslte_npdsch_t* q, - srslte_npdsch_cfg_t* cfg, - srslte_softbuffer_tx_t* softbuffer, +int srsran_npdsch_encode_rnti(srsran_npdsch_t* q, + srsran_npdsch_cfg_t* cfg, + srsran_softbuffer_tx_t* softbuffer, uint8_t* data, uint16_t rnti, - cf_t* sf_symbols[SRSLTE_MAX_PORTS]) + cf_t* sf_symbols[SRSRAN_MAX_PORTS]) { if (rnti != q->rnti) { // TODO: skip sequence init if cfg->is_encoded==true - srslte_sequence_t seq; - if (q->cell.is_r14 && rnti == SRSLTE_SIRNTI) { - if (srslte_sequence_npdsch_bcch_r14( + srsran_sequence_t seq; + if (q->cell.is_r14 && rnti == SRSRAN_SIRNTI) { + if (srsran_sequence_npdsch_bcch_r14( &seq, cfg->grant.start_sfn, q->cell.n_id_ncell, cfg->grant.nof_sf * cfg->nbits.nof_bits)) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } else { - if (srslte_sequence_npdsch(&seq, + if (srsran_sequence_npdsch(&seq, rnti, 0, cfg->grant.start_sfidx, 2 * cfg->grant.start_sfidx, q->cell.n_id_ncell, cfg->nbits.nof_bits * cfg->grant.nof_sf)) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } - int r = srslte_npdsch_encode_seq(q, cfg, softbuffer, data, &seq, sf_symbols); - srslte_sequence_free(&seq); + int r = srsran_npdsch_encode_seq(q, cfg, softbuffer, data, &seq, sf_symbols); + srsran_sequence_free(&seq); return r; } else { - int seq_pos = ((cfg->grant.start_sfn % 2) * SRSLTE_NOF_SF_X_FRAME) + cfg->grant.start_sfidx; - return srslte_npdsch_encode_seq(q, cfg, softbuffer, data, &q->seq[seq_pos], sf_symbols); + int seq_pos = ((cfg->grant.start_sfn % 2) * SRSRAN_NOF_SF_X_FRAME) + cfg->grant.start_sfidx; + return srsran_npdsch_encode_seq(q, cfg, softbuffer, data, &q->seq[seq_pos], sf_symbols); } } -int srslte_npdsch_encode_seq(srslte_npdsch_t* q, - srslte_npdsch_cfg_t* cfg, - srslte_softbuffer_tx_t* softbuffer, +int srsran_npdsch_encode_seq(srsran_npdsch_t* q, + srsran_npdsch_cfg_t* cfg, + srsran_softbuffer_tx_t* softbuffer, uint8_t* data, - srslte_sequence_t* seq, - cf_t* sf_symbols[SRSLTE_MAX_PORTS]) + srsran_sequence_t* seq, + cf_t* sf_symbols[SRSRAN_MAX_PORTS]) { /* Set pointers for layermapping & precoding */ - cf_t* x[SRSLTE_MAX_LAYERS]; - int ret = SRSLTE_ERROR_INVALID_INPUTS; + cf_t* x[SRSRAN_MAX_LAYERS]; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL && data != NULL && cfg != NULL) { for (int i = 0; i < q->cell.nof_ports; i++) { if (sf_symbols[i] == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } // Set up pointer for Tx symbols @@ -610,7 +610,7 @@ int srslte_npdsch_encode_seq(srslte_npdsch_t* q, } if (cfg->grant.mcs[0].tbs == 0) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } if (cfg->nbits.nof_re > q->max_re) { @@ -619,13 +619,13 @@ int srslte_npdsch_encode_seq(srslte_npdsch_t* q, cfg->nbits.nof_re, q->max_re, q->cell.base.nof_prb); - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } // make sure to run run full NPDSCH procedure only once if (!cfg->is_encoded) { INFO("Encoding NPDSCH: Mod %s, NofBits: %d, NofSymbols: %d * %d, NofBitsE: %d * %d", - srslte_mod_string(cfg->grant.mcs[0].mod), + srsran_mod_string(cfg->grant.mcs[0].mod), cfg->grant.mcs[0].tbs, cfg->grant.nof_sf, cfg->nbits.nof_re, @@ -636,72 +636,72 @@ int srslte_npdsch_encode_seq(srslte_npdsch_t* q, for (int i = 0; i < q->cell.nof_ports; i++) { x[i] = q->x[i]; } - memset(&x[q->cell.nof_ports], 0, sizeof(cf_t*) * (SRSLTE_MAX_LAYERS - q->cell.nof_ports)); + memset(&x[q->cell.nof_ports], 0, sizeof(cf_t*) * (SRSRAN_MAX_LAYERS - q->cell.nof_ports)); int len = cfg->grant.mcs[0].tbs; // unpack input - srslte_bit_unpack_vector(data, q->data, len); + srsran_bit_unpack_vector(data, q->data, len); // attach CRC - srslte_crc_attach(&q->crc, q->data, len); - len += SRSLTE_NPDSCH_CRC_LEN; + srsran_crc_attach(&q->crc, q->data, len); + len += SRSRAN_NPDSCH_CRC_LEN; #if DUMP_SIGNALS - if (SRSLTE_VERBOSE_ISDEBUG()) { + if (SRSRAN_VERBOSE_ISDEBUG()) { DEBUG("SAVED FILE npdsch_tx_convcoder_input.bin: NPDSCH before convolution coding", 0); - srslte_vec_save_file("npdsch_tx_convcoder_input.bin", q->data, len); + srsran_vec_save_file("npdsch_tx_convcoder_input.bin", q->data, len); } #endif // encode - srslte_convcoder_encode(&q->encoder, q->data, q->data_enc, len); + srsran_convcoder_encode(&q->encoder, q->data, q->data_enc, len); len *= 3; // rate-match to allocated bits and scramble output - srslte_rm_conv_tx(q->data_enc, len, q->rm_b, cfg->nbits.nof_bits * cfg->grant.nof_sf); + srsran_rm_conv_tx(q->data_enc, len, q->rm_b, cfg->nbits.nof_bits * cfg->grant.nof_sf); len = cfg->nbits.nof_bits * cfg->grant.nof_sf; #if DUMP_SIGNALS - if (SRSLTE_VERBOSE_ISDEBUG()) { + if (SRSRAN_VERBOSE_ISDEBUG()) { DEBUG("SAVED FILE npdsch_tx_scramble_input.bin: NPDSCH before scrambling", 0); - srslte_vec_save_file("npdsch_tx_scramble_input.bin", q->rm_b, len); + srsran_vec_save_file("npdsch_tx_scramble_input.bin", q->rm_b, len); } #endif // scramble - srslte_scrambling_b_offset(seq, q->rm_b, 0, len); + srsran_scrambling_b_offset(seq, q->rm_b, 0, len); #if DUMP_SIGNALS - if (SRSLTE_VERBOSE_ISDEBUG()) { + if (SRSRAN_VERBOSE_ISDEBUG()) { DEBUG("SAVED FILE npdsch_tx_mod_input.bin: NPDSCH before modulation", 0); - srslte_vec_save_file("npdsch_tx_mod_input.bin", q->rm_b, len); + srsran_vec_save_file("npdsch_tx_mod_input.bin", q->rm_b, len); } #endif // modulate bits - srslte_mod_modulate(&q->mod, (uint8_t*)q->rm_b, q->d, len); + srsran_mod_modulate(&q->mod, (uint8_t*)q->rm_b, q->d, len); len = cfg->nbits.nof_re * cfg->grant.nof_sf; #if DUMP_SIGNALS - if (SRSLTE_VERBOSE_ISDEBUG()) { + if (SRSRAN_VERBOSE_ISDEBUG()) { DEBUG("SAVED FILE npdsch_tx_precode_input.bin: NPDSCH before precoding symbols", 0); - srslte_vec_save_file("npdsch_tx_precode_input.bin", q->d, len * sizeof(cf_t)); + srsran_vec_save_file("npdsch_tx_precode_input.bin", q->d, len * sizeof(cf_t)); } #endif // TODO: only diversity supported if (q->cell.base.nof_ports > 1) { - srslte_layermap_diversity(q->d, x, q->cell.base.nof_ports, len); - srslte_precoding_diversity(x, q->tx_syms, q->cell.base.nof_ports, len / q->cell.base.nof_ports, 1.0); + srsran_layermap_diversity(q->d, x, q->cell.base.nof_ports, len); + srsran_precoding_diversity(x, q->tx_syms, q->cell.base.nof_ports, len / q->cell.base.nof_ports, 1.0); } else { memcpy(q->tx_syms[0], q->d, len * sizeof(cf_t)); } #if DUMP_SIGNALS - if (SRSLTE_VERBOSE_ISDEBUG()) { + if (SRSRAN_VERBOSE_ISDEBUG()) { DEBUG("SAVED FILE npdsch_tx_mapping_input.bin: NPDSCH before mapping to resource elements", 0); - srslte_vec_save_file("npdsch_tx_mapping_input.bin", q->tx_syms[0], len * sizeof(cf_t)); + srsran_vec_save_file("npdsch_tx_mapping_input.bin", q->tx_syms[0], len * sizeof(cf_t)); } #endif @@ -719,7 +719,7 @@ int srslte_npdsch_encode_seq(srslte_npdsch_t* q, cfg->num_sf + 1, cfg->grant.nof_sf * cfg->grant.nof_rep); for (int i = 0; i < q->cell.nof_ports; i++) { - srslte_npdsch_put(q, &q->tx_syms[i][cfg->sf_idx * cfg->nbits.nof_re], sf_symbols[i], &cfg->grant); + srsran_npdsch_put(q, &q->tx_syms[i][cfg->sf_idx * cfg->nbits.nof_re], sf_symbols[i], &cfg->grant); } cfg->num_sf++; @@ -733,7 +733,7 @@ int srslte_npdsch_encode_seq(srslte_npdsch_t* q, } else { // NPDSCH without BCCH transmits up to 3 repetitions after another cfg->rep_idx++; - int m = SRSLTE_MIN(cfg->grant.nof_rep, 4); + int m = SRSRAN_MIN(cfg->grant.nof_rep, 4); if (cfg->rep_idx % m == 0) { cfg->sf_idx++; // start with first SF again after all have been tx'ed m-times @@ -745,35 +745,35 @@ int srslte_npdsch_encode_seq(srslte_npdsch_t* q, } } } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } -/* Configures the structure srslte_npdsch_cfg_t from a DL grant. +/* Configures the structure srsran_npdsch_cfg_t from a DL grant. * If grant is NULL, the grant is assumed to be already stored in cfg->grant */ -int srslte_npdsch_cfg(srslte_npdsch_cfg_t* cfg, - srslte_nbiot_cell_t cell, - srslte_ra_nbiot_dl_grant_t* grant, +int srsran_npdsch_cfg(srsran_npdsch_cfg_t* cfg, + srsran_nbiot_cell_t cell, + srsran_ra_nbiot_dl_grant_t* grant, uint32_t sf_idx) { if (cfg) { if (grant) { - memcpy(&cfg->grant, grant, sizeof(srslte_ra_nbiot_dl_grant_t)); + memcpy(&cfg->grant, grant, sizeof(srsran_ra_nbiot_dl_grant_t)); } // Compute number of RE - srslte_ra_nbiot_dl_grant_to_nbits(&cfg->grant, cell, sf_idx, &cfg->nbits); + srsran_ra_nbiot_dl_grant_to_nbits(&cfg->grant, cell, sf_idx, &cfg->nbits); cfg->sf_idx = 0; cfg->rep_idx = 0; cfg->num_sf = 0; cfg->is_encoded = false; cfg->has_bcch = cfg->grant.has_sib1; // The UE needs to set this to true for other SIBs too - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } else { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } } @@ -786,14 +786,14 @@ int srslte_npdsch_cfg(srslte_npdsch_cfg_t* cfg, * \param msg The packed SIB1-NB * \param sib The SIB structure containing the MIB-part of the HFN */ -void srslte_npdsch_sib1_unpack(uint8_t* const msg, srslte_sys_info_block_type_1_nb_t* sib) +void srsran_npdsch_sib1_unpack(uint8_t* const msg, srsran_sys_info_block_type_1_nb_t* sib) { - uint8_t unpacked[SRSLTE_NPDSCH_MAX_TBS]; - srslte_bit_unpack_vector(msg, unpacked, SRSLTE_NPDSCH_MAX_TBS); + uint8_t unpacked[SRSRAN_NPDSCH_MAX_TBS]; + srsran_bit_unpack_vector(msg, unpacked, SRSRAN_NPDSCH_MAX_TBS); uint8_t* tmp = unpacked; if (sib) { tmp += 12; - sib->hyper_sfn = ((srslte_bit_pack(&tmp, 8) & 0xFF) << 2 | (sib->hyper_sfn & 0x3)) & 0x3FF; + sib->hyper_sfn = ((srsran_bit_pack(&tmp, 8) & 0xFF) << 2 | (sib->hyper_sfn & 0x3)) & 0x3FF; } } diff --git a/lib/src/phy/phch/pbch.c b/lib/src/phy/phch/pbch.c index 6ebabe2ca..4b2b5bcf9 100644 --- a/lib/src/phy/phch/pbch.c +++ b/lib/src/phy/phch/pbch.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,7 +10,7 @@ * */ -#include "srslte/srslte.h" +#include "srsran/srsran.h" #include #include #include @@ -21,28 +21,28 @@ #include #include "prb_dl.h" -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/phch/pbch.h" -#include "srslte/phy/utils/bit.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/phch/pbch.h" +#include "srsran/phy/utils/bit.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" #define PBCH_RE_CP_NORM 240 #define PBCH_RE_CP_EXT 216 -const uint8_t srslte_crc_mask[4][16] = {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +const uint8_t srsran_crc_mask[4][16] = {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1}}; -bool srslte_pbch_exists(int nframe, int nslot) +bool srsran_pbch_exists(int nframe, int nslot) { return (!(nframe % 5) && nslot == 1); } cf_t* offset_original; -int srslte_pbch_cp(cf_t* input, cf_t* output, srslte_cell_t cell, bool put) +int srsran_pbch_cp(cf_t* input, cf_t* output, srsran_cell_t cell, bool put) { int i; cf_t* ptr; @@ -51,37 +51,37 @@ int srslte_pbch_cp(cf_t* input, cf_t* output, srslte_cell_t cell, bool put) if (put) { ptr = input; - output += cell.nof_prb * SRSLTE_NRE / 2 - 36; + output += cell.nof_prb * SRSRAN_NRE / 2 - 36; } else { ptr = output; - input += cell.nof_prb * SRSLTE_NRE / 2 - 36; + input += cell.nof_prb * SRSRAN_NRE / 2 - 36; } /* symbol 0 & 1 */ for (i = 0; i < 2; i++) { prb_cp_ref(&input, &output, cell.id % 3, 4, 4 * 6, put); if (put) { - output += cell.nof_prb * SRSLTE_NRE - 2 * 36 + (cell.id % 3 == 2 ? 1 : 0); + output += cell.nof_prb * SRSRAN_NRE - 2 * 36 + (cell.id % 3 == 2 ? 1 : 0); } else { - input += cell.nof_prb * SRSLTE_NRE - 2 * 36 + (cell.id % 3 == 2 ? 1 : 0); + input += cell.nof_prb * SRSRAN_NRE - 2 * 36 + (cell.id % 3 == 2 ? 1 : 0); } } /* symbols 2 & 3 */ - if (SRSLTE_CP_ISNORM(cell.cp)) { + if (SRSRAN_CP_ISNORM(cell.cp)) { for (i = 0; i < 2; i++) { prb_cp(&input, &output, 6); if (put) { - output += cell.nof_prb * SRSLTE_NRE - 2 * 36; + output += cell.nof_prb * SRSRAN_NRE - 2 * 36; } else { - input += cell.nof_prb * SRSLTE_NRE - 2 * 36; + input += cell.nof_prb * SRSRAN_NRE - 2 * 36; } } } else { prb_cp(&input, &output, 6); if (put) { - output += cell.nof_prb * SRSLTE_NRE - 2 * 36; + output += cell.nof_prb * SRSRAN_NRE - 2 * 36; } else { - input += cell.nof_prb * SRSLTE_NRE - 2 * 36; + input += cell.nof_prb * SRSRAN_NRE - 2 * 36; } prb_cp_ref(&input, &output, cell.id % 3, 4, 4 * 6, put); } @@ -103,9 +103,9 @@ int srslte_pbch_cp(cf_t* input, cf_t* output, srslte_cell_t cell, bool put) * @param[out] slot1_data Complex symbol buffer for slot1 * @param[in] cell Cell configuration */ -int srslte_pbch_put(cf_t* pbch, cf_t* slot1_data, srslte_cell_t cell) +int srsran_pbch_put(cf_t* pbch, cf_t* slot1_data, srsran_cell_t cell) { - return srslte_pbch_cp(pbch, slot1_data, cell, true); + return srsran_pbch_cp(pbch, slot1_data, cell, true); } /** @@ -119,32 +119,32 @@ int srslte_pbch_put(cf_t* pbch, cf_t* slot1_data, srslte_cell_t cell) * @param[out] pbch Extracted complex PBCH symbols * @param[in] cell Cell configuration */ -int srslte_pbch_get(cf_t* slot1_data, cf_t* pbch, srslte_cell_t cell) +int srsran_pbch_get(cf_t* slot1_data, cf_t* pbch, srsran_cell_t cell) { - return srslte_pbch_cp(slot1_data, pbch, cell, false); + return srsran_pbch_cp(slot1_data, pbch, cell, false); } /** Initializes the PBCH transmitter and receiver. * At the receiver, the field nof_ports in the cell structure indicates the * maximum number of BS transmitter ports to look for. */ -int srslte_pbch_init(srslte_pbch_t* q) +int srsran_pbch_init(srsran_pbch_t* q) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL) { - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; - bzero(q, sizeof(srslte_pbch_t)); + bzero(q, sizeof(srsran_pbch_t)); - if (srslte_modem_table_lte(&q->mod, SRSLTE_MOD_QPSK)) { + if (srsran_modem_table_lte(&q->mod, SRSRAN_MOD_QPSK)) { goto clean; } int poly[3] = {0x6D, 0x4F, 0x57}; - if (srslte_viterbi_init(&q->decoder, SRSLTE_VITERBI_37, poly, 40, true)) { + if (srsran_viterbi_init(&q->decoder, SRSRAN_VITERBI_37, poly, 40, true)) { goto clean; } - if (srslte_crc_init(&q->crc, SRSLTE_LTE_CRC16, 16)) { + if (srsran_crc_init(&q->crc, SRSRAN_LTE_CRC16, 16)) { goto clean; } q->encoder.K = 7; @@ -154,54 +154,54 @@ int srslte_pbch_init(srslte_pbch_t* q) q->nof_symbols = PBCH_RE_CP_NORM; - q->d = srslte_vec_cf_malloc(q->nof_symbols); + q->d = srsran_vec_cf_malloc(q->nof_symbols); if (!q->d) { goto clean; } int i; - for (i = 0; i < SRSLTE_MAX_PORTS; i++) { - q->ce[i] = srslte_vec_cf_malloc(q->nof_symbols); + for (i = 0; i < SRSRAN_MAX_PORTS; i++) { + q->ce[i] = srsran_vec_cf_malloc(q->nof_symbols); if (!q->ce[i]) { goto clean; } - q->x[i] = srslte_vec_cf_malloc(q->nof_symbols); + q->x[i] = srsran_vec_cf_malloc(q->nof_symbols); if (!q->x[i]) { goto clean; } - q->symbols[i] = srslte_vec_cf_malloc(q->nof_symbols); + q->symbols[i] = srsran_vec_cf_malloc(q->nof_symbols); if (!q->symbols[i]) { goto clean; } } - q->llr = srslte_vec_f_malloc(q->nof_symbols * 4 * 2); + q->llr = srsran_vec_f_malloc(q->nof_symbols * 4 * 2); if (!q->llr) { goto clean; } - q->temp = srslte_vec_f_malloc(q->nof_symbols * 4 * 2); + q->temp = srsran_vec_f_malloc(q->nof_symbols * 4 * 2); if (!q->temp) { goto clean; } - q->rm_b = srslte_vec_u8_malloc(q->nof_symbols * 4 * 2); + q->rm_b = srsran_vec_u8_malloc(q->nof_symbols * 4 * 2); if (!q->rm_b) { goto clean; } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } clean: - if (ret == SRSLTE_ERROR) { - srslte_pbch_free(q); + if (ret == SRSRAN_ERROR) { + srsran_pbch_free(q); } return ret; } -void srslte_pbch_free(srslte_pbch_t* q) +void srsran_pbch_free(srsran_pbch_t* q) { - srslte_sequence_free(&q->seq); - srslte_modem_table_free(&q->mod); - srslte_viterbi_free(&q->decoder); + srsran_sequence_free(&q->seq); + srsran_modem_table_free(&q->mod); + srsran_viterbi_free(&q->decoder); int i; - for (i = 0; i < SRSLTE_MAX_PORTS; i++) { + for (i = 0; i < SRSRAN_MAX_PORTS; i++) { if (q->ce[i]) { free(q->ce[i]); } @@ -224,30 +224,30 @@ void srslte_pbch_free(srslte_pbch_t* q) if (q->d) { free(q->d); } - bzero(q, sizeof(srslte_pbch_t)); + bzero(q, sizeof(srsran_pbch_t)); } -int srslte_pbch_set_cell(srslte_pbch_t* q, srslte_cell_t cell) +int srsran_pbch_set_cell(srsran_pbch_t* q, srsran_cell_t cell) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; - if (q != NULL && srslte_cell_isvalid(&cell)) { + if (q != NULL && srsran_cell_isvalid(&cell)) { if (cell.nof_ports == 0) { q->search_all_ports = true; - cell.nof_ports = SRSLTE_MAX_PORTS; + cell.nof_ports = SRSRAN_MAX_PORTS; } else { q->search_all_ports = false; } if (q->cell.id != cell.id || q->cell.nof_prb == 0) { q->cell = cell; - if (srslte_sequence_pbch(&q->seq, q->cell.cp, q->cell.id)) { - return SRSLTE_ERROR; + if (srsran_sequence_pbch(&q->seq, q->cell.cp, q->cell.id)) { + return SRSRAN_ERROR; } } - q->nof_symbols = (SRSLTE_CP_ISNORM(q->cell.cp)) ? PBCH_RE_CP_NORM : PBCH_RE_CP_EXT; + q->nof_symbols = (SRSRAN_CP_ISNORM(q->cell.cp)) ? PBCH_RE_CP_NORM : PBCH_RE_CP_EXT; - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } @@ -259,11 +259,11 @@ int srslte_pbch_set_cell(srslte_pbch_t* q, srslte_cell_t cell) * @param[out] sfn System frame number * @param[out] cell MIB information about PHICH and system bandwidth will be saved here */ -void srslte_pbch_mib_unpack(uint8_t* msg, srslte_cell_t* cell, uint32_t* sfn) +void srsran_pbch_mib_unpack(uint8_t* msg, srsran_cell_t* cell, uint32_t* sfn) { int phich_res; - uint32_t bw_idx = srslte_bit_pack(&msg, 3); + uint32_t bw_idx = srsran_bit_pack(&msg, 3); switch (bw_idx) { case 0: cell->nof_prb = 6; @@ -276,29 +276,29 @@ void srslte_pbch_mib_unpack(uint8_t* msg, srslte_cell_t* cell, uint32_t* sfn) break; } if (*msg) { - cell->phich_length = SRSLTE_PHICH_EXT; + cell->phich_length = SRSRAN_PHICH_EXT; } else { - cell->phich_length = SRSLTE_PHICH_NORM; + cell->phich_length = SRSRAN_PHICH_NORM; } msg++; - phich_res = srslte_bit_pack(&msg, 2); + phich_res = srsran_bit_pack(&msg, 2); switch (phich_res) { case 0: - cell->phich_resources = SRSLTE_PHICH_R_1_6; + cell->phich_resources = SRSRAN_PHICH_R_1_6; break; case 1: - cell->phich_resources = SRSLTE_PHICH_R_1_2; + cell->phich_resources = SRSRAN_PHICH_R_1_2; break; case 2: - cell->phich_resources = SRSLTE_PHICH_R_1; + cell->phich_resources = SRSRAN_PHICH_R_1; break; case 3: - cell->phich_resources = SRSLTE_PHICH_R_2; + cell->phich_resources = SRSRAN_PHICH_R_2; break; } if (sfn) { - *sfn = srslte_bit_pack(&msg, 8) << 2; + *sfn = srsran_bit_pack(&msg, 8) << 2; } } @@ -309,7 +309,7 @@ void srslte_pbch_mib_unpack(uint8_t* msg, srslte_cell_t* cell, uint32_t* sfn) * @param[in] sfn System frame number * @param[in] cell Cell configuration to be encoded in MIB */ -void srslte_pbch_mib_pack(srslte_cell_t* cell, uint32_t sfn, uint8_t* payload) +void srsran_pbch_mib_pack(srsran_cell_t* cell, uint32_t sfn, uint8_t* payload) { int bw, phich_res = 0; @@ -324,39 +324,39 @@ void srslte_pbch_mib_pack(srslte_cell_t* cell, uint32_t sfn, uint8_t* payload) } else { bw = 1 + cell->nof_prb / 25; } - srslte_bit_unpack(bw, &msg, 3); + srsran_bit_unpack(bw, &msg, 3); - *msg = cell->phich_length == SRSLTE_PHICH_EXT; + *msg = cell->phich_length == SRSRAN_PHICH_EXT; msg++; switch (cell->phich_resources) { - case SRSLTE_PHICH_R_1_6: + case SRSRAN_PHICH_R_1_6: phich_res = 0; break; - case SRSLTE_PHICH_R_1_2: + case SRSRAN_PHICH_R_1_2: phich_res = 1; break; - case SRSLTE_PHICH_R_1: + case SRSRAN_PHICH_R_1: phich_res = 2; break; - case SRSLTE_PHICH_R_2: + case SRSRAN_PHICH_R_2: phich_res = 3; break; } - srslte_bit_unpack(phich_res, &msg, 2); - srslte_bit_unpack(sfn >> 2, &msg, 8); + srsran_bit_unpack(phich_res, &msg, 2); + srsran_bit_unpack(sfn >> 2, &msg, 8); } -void srslte_pbch_decode_reset(srslte_pbch_t* q) +void srsran_pbch_decode_reset(srsran_pbch_t* q) { q->frame_idx = 0; } -void srslte_crc_set_mask(uint8_t* data, int nof_ports) +void srsran_crc_set_mask(uint8_t* data, int nof_ports) { int i; for (i = 0; i < 16; i++) { - data[SRSLTE_BCH_PAYLOAD_LEN + i] = (data[SRSLTE_BCH_PAYLOAD_LEN + i] + srslte_crc_mask[nof_ports - 1][i]) % 2; + data[SRSRAN_BCH_PAYLOAD_LEN + i] = (data[SRSRAN_BCH_PAYLOAD_LEN + i] + srsran_crc_mask[nof_ports - 1][i]) % 2; } } @@ -366,57 +366,57 @@ void srslte_crc_set_mask(uint8_t* data, int nof_ports) * * Returns 0 if the data is correct, -1 otherwise */ -uint32_t srslte_pbch_crc_check(srslte_pbch_t* q, uint8_t* bits, uint32_t nof_ports) +uint32_t srsran_pbch_crc_check(srsran_pbch_t* q, uint8_t* bits, uint32_t nof_ports) { - uint8_t data[SRSLTE_BCH_PAYLOADCRC_LEN]; - memcpy(data, bits, SRSLTE_BCH_PAYLOADCRC_LEN * sizeof(uint8_t)); - srslte_crc_set_mask(data, nof_ports); - int ret = srslte_crc_checksum(&q->crc, data, SRSLTE_BCH_PAYLOADCRC_LEN); + uint8_t data[SRSRAN_BCH_PAYLOADCRC_LEN]; + memcpy(data, bits, SRSRAN_BCH_PAYLOADCRC_LEN * sizeof(uint8_t)); + srsran_crc_set_mask(data, nof_ports); + int ret = srsran_crc_checksum(&q->crc, data, SRSRAN_BCH_PAYLOADCRC_LEN); if (ret == 0) { uint32_t chkzeros = 0; - for (int i = 0; i < SRSLTE_BCH_PAYLOAD_LEN; i++) { + for (int i = 0; i < SRSRAN_BCH_PAYLOAD_LEN; i++) { chkzeros += data[i]; } if (chkzeros) { return 0; } else { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } else { return ret; } } -int decode_frame(srslte_pbch_t* q, uint32_t src, uint32_t dst, uint32_t n, uint32_t nof_bits, uint32_t nof_ports) +int decode_frame(srsran_pbch_t* q, uint32_t src, uint32_t dst, uint32_t n, uint32_t nof_bits, uint32_t nof_ports) { int j; if (dst + n <= 4 && src + n <= 4) { - srslte_vec_f_copy(&q->temp[dst * nof_bits], &q->llr[src * nof_bits], n * nof_bits); + srsran_vec_f_copy(&q->temp[dst * nof_bits], &q->llr[src * nof_bits], n * nof_bits); /* descramble */ - srslte_scrambling_f_offset(&q->seq, &q->temp[dst * nof_bits], dst * nof_bits, n * nof_bits); + srsran_scrambling_f_offset(&q->seq, &q->temp[dst * nof_bits], dst * nof_bits, n * nof_bits); for (j = 0; j < dst * nof_bits; j++) { - q->temp[j] = SRSLTE_RX_NULL; + q->temp[j] = SRSRAN_RX_NULL; } for (j = (dst + n) * nof_bits; j < 4 * nof_bits; j++) { - q->temp[j] = SRSLTE_RX_NULL; + q->temp[j] = SRSRAN_RX_NULL; } /* unrate matching */ - srslte_rm_conv_rx(q->temp, 4 * nof_bits, q->rm_f, SRSLTE_BCH_ENCODED_LEN); + srsran_rm_conv_rx(q->temp, 4 * nof_bits, q->rm_f, SRSRAN_BCH_ENCODED_LEN); /* Normalize LLR */ - srslte_vec_sc_prod_fff(q->rm_f, 1.0 / ((float)2 * n), q->rm_f, SRSLTE_BCH_ENCODED_LEN); + srsran_vec_sc_prod_fff(q->rm_f, 1.0 / ((float)2 * n), q->rm_f, SRSRAN_BCH_ENCODED_LEN); /* decode */ - srslte_viterbi_decode_f(&q->decoder, q->rm_f, q->data, SRSLTE_BCH_PAYLOADCRC_LEN); + srsran_viterbi_decode_f(&q->decoder, q->rm_f, q->data, SRSRAN_BCH_PAYLOADCRC_LEN); - if (!srslte_pbch_crc_check(q, q->data, nof_ports)) { + if (!srsran_pbch_crc_check(q, q->data, nof_ports)) { return 1; } else { - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } } else { ERROR("Error in PBCH decoder: Invalid frame pointers dst=%d, src=%d, n=%d", src, dst, n); @@ -432,10 +432,10 @@ int decode_frame(srslte_pbch_t* q, uint32_t src, uint32_t dst, uint32_t n, uint3 * * Returns 1 if successfully decoded MIB, 0 if not and -1 on error */ -int srslte_pbch_decode(srslte_pbch_t* q, - srslte_chest_dl_res_t* channel, - cf_t* sf_symbols[SRSLTE_MAX_PORTS], - uint8_t bch_payload[SRSLTE_BCH_PAYLOAD_LEN], +int srsran_pbch_decode(srsran_pbch_t* q, + srsran_chest_dl_res_t* channel, + cf_t* sf_symbols[SRSRAN_MAX_PORTS], + uint8_t bch_payload[SRSRAN_BCH_PAYLOAD_LEN], uint32_t* nof_tx_ports, int* sfn_offset) { @@ -443,37 +443,37 @@ int srslte_pbch_decode(srslte_pbch_t* q, uint32_t nant; int i; int nof_bits; - cf_t* x[SRSLTE_MAX_LAYERS]; + cf_t* x[SRSRAN_MAX_LAYERS]; - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL && sf_symbols != NULL) { - cf_t* slot1_symbols = &sf_symbols[0][SRSLTE_SLOT_LEN_RE(q->cell.nof_prb, q->cell.cp)]; + cf_t* slot1_symbols = &sf_symbols[0][SRSRAN_SLOT_LEN_RE(q->cell.nof_prb, q->cell.cp)]; - cf_t* ce_slot1[SRSLTE_MAX_PORTS]; - for (int i = 0; i < SRSLTE_MAX_PORTS; i++) { - ce_slot1[i] = &channel->ce[i][0][SRSLTE_SLOT_LEN_RE(q->cell.nof_prb, q->cell.cp)]; + cf_t* ce_slot1[SRSRAN_MAX_PORTS]; + for (int i = 0; i < SRSRAN_MAX_PORTS; i++) { + ce_slot1[i] = &channel->ce[i][0][SRSRAN_SLOT_LEN_RE(q->cell.nof_prb, q->cell.cp)]; } /* Set pointers for layermapping & precoding */ nof_bits = 2 * q->nof_symbols; /* number of layers equals number of ports */ - for (i = 0; i < SRSLTE_MAX_PORTS; i++) { + for (i = 0; i < SRSRAN_MAX_PORTS; i++) { x[i] = q->x[i]; } /* extract symbols */ - if (q->nof_symbols != srslte_pbch_get(slot1_symbols, q->symbols[0], q->cell)) { + if (q->nof_symbols != srsran_pbch_get(slot1_symbols, q->symbols[0], q->cell)) { ERROR("There was an error getting the PBCH symbols"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } /* extract channel estimates */ for (i = 0; i < q->cell.nof_ports; i++) { - if (q->nof_symbols != srslte_pbch_get(ce_slot1[i], q->ce[i], q->cell)) { + if (q->nof_symbols != srsran_pbch_get(ce_slot1[i], q->ce[i], q->cell)) { ERROR("There was an error getting the PBCH symbols"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } @@ -496,14 +496,14 @@ int srslte_pbch_decode(srslte_pbch_t* q, /* in control channels, only diversity is supported */ if (nant == 1) { /* no need for layer demapping */ - srslte_predecoding_single(q->symbols[0], q->ce[0], q->d, NULL, q->nof_symbols, 1.0f, channel->noise_estimate); + srsran_predecoding_single(q->symbols[0], q->ce[0], q->d, NULL, q->nof_symbols, 1.0f, channel->noise_estimate); } else { - srslte_predecoding_diversity(q->symbols[0], q->ce, x, nant, q->nof_symbols, 1.0f); - srslte_layerdemap_diversity(x, q->d, nant, q->nof_symbols / nant); + srsran_predecoding_diversity(q->symbols[0], q->ce, x, nant, q->nof_symbols, 1.0f); + srsran_layerdemap_diversity(x, q->d, nant, q->nof_symbols / nant); } /* demodulate symbols */ - srslte_demod_soft_demodulate(SRSLTE_MOD_QPSK, q->d, &q->llr[nof_bits * (frame_idx - 1)], q->nof_symbols); + srsran_demod_soft_demodulate(SRSRAN_MOD_QPSK, q->d, &q->llr[nof_bits * (frame_idx - 1)], q->nof_symbols); /* We don't know where the 40 ms begin, so we try all combinations. E.g. if we received * 4 frames, try 1,2,3,4 individually, 12, 23, 34 in pairs, 123, 234 and finally 1234. @@ -521,14 +521,14 @@ int srslte_pbch_decode(srslte_pbch_t* q, *nof_tx_ports = nant; } if (bch_payload) { - memcpy(bch_payload, q->data, sizeof(uint8_t) * SRSLTE_BCH_PAYLOAD_LEN); + memcpy(bch_payload, q->data, sizeof(uint8_t) * SRSRAN_BCH_PAYLOAD_LEN); } INFO("Decoded PBCH: src=%d, dst=%d, nb=%d, sfn_offset=%d", src, dst, nb + 1, (int)dst - src + frame_idx - 1); - srslte_pbch_decode_reset(q); + srsran_pbch_decode_reset(q); return 1; } } @@ -549,14 +549,14 @@ int srslte_pbch_decode(srslte_pbch_t* q, /** Converts the MIB message to symbols mapped to SLOT #1 ready for transmission */ -int srslte_pbch_encode(srslte_pbch_t* q, - uint8_t bch_payload[SRSLTE_BCH_PAYLOAD_LEN], - cf_t* sf_symbols[SRSLTE_MAX_PORTS], +int srsran_pbch_encode(srsran_pbch_t* q, + uint8_t bch_payload[SRSRAN_BCH_PAYLOAD_LEN], + cf_t* sf_symbols[SRSRAN_MAX_PORTS], uint32_t frame_idx) { int i; int nof_bits; - cf_t* x[SRSLTE_MAX_LAYERS]; + cf_t* x[SRSRAN_MAX_LAYERS]; if (q != NULL && bch_payload != NULL) { /* Set pointers for layermapping & precoding */ @@ -566,37 +566,37 @@ int srslte_pbch_encode(srslte_pbch_t* q, for (i = 0; i < q->cell.nof_ports; i++) { x[i] = q->x[i]; } - memset(&x[q->cell.nof_ports], 0, sizeof(cf_t*) * (SRSLTE_MAX_LAYERS - q->cell.nof_ports)); + memset(&x[q->cell.nof_ports], 0, sizeof(cf_t*) * (SRSRAN_MAX_LAYERS - q->cell.nof_ports)); frame_idx = frame_idx % 4; - memcpy(q->data, bch_payload, sizeof(uint8_t) * SRSLTE_BCH_PAYLOAD_LEN); + memcpy(q->data, bch_payload, sizeof(uint8_t) * SRSRAN_BCH_PAYLOAD_LEN); /* encode & modulate */ - srslte_crc_attach(&q->crc, q->data, SRSLTE_BCH_PAYLOAD_LEN); - srslte_crc_set_mask(q->data, q->cell.nof_ports); + srsran_crc_attach(&q->crc, q->data, SRSRAN_BCH_PAYLOAD_LEN); + srsran_crc_set_mask(q->data, q->cell.nof_ports); - srslte_convcoder_encode(&q->encoder, q->data, q->data_enc, SRSLTE_BCH_PAYLOADCRC_LEN); + srsran_convcoder_encode(&q->encoder, q->data, q->data_enc, SRSRAN_BCH_PAYLOADCRC_LEN); - srslte_rm_conv_tx(q->data_enc, SRSLTE_BCH_ENCODED_LEN, q->rm_b, 4 * nof_bits); + srsran_rm_conv_tx(q->data_enc, SRSRAN_BCH_ENCODED_LEN, q->rm_b, 4 * nof_bits); - srslte_scrambling_b_offset(&q->seq, &q->rm_b[frame_idx * nof_bits], frame_idx * nof_bits, nof_bits); - srslte_mod_modulate(&q->mod, &q->rm_b[frame_idx * nof_bits], q->d, nof_bits); + srsran_scrambling_b_offset(&q->seq, &q->rm_b[frame_idx * nof_bits], frame_idx * nof_bits, nof_bits); + srsran_mod_modulate(&q->mod, &q->rm_b[frame_idx * nof_bits], q->d, nof_bits); /* layer mapping & precoding */ if (q->cell.nof_ports > 1) { - srslte_layermap_diversity(q->d, x, q->cell.nof_ports, q->nof_symbols); - srslte_precoding_diversity(x, q->symbols, q->cell.nof_ports, q->nof_symbols / q->cell.nof_ports, 1.0f); + srsran_layermap_diversity(q->d, x, q->cell.nof_ports, q->nof_symbols); + srsran_precoding_diversity(x, q->symbols, q->cell.nof_ports, q->nof_symbols / q->cell.nof_ports, 1.0f); } else { memcpy(q->symbols[0], q->d, q->nof_symbols * sizeof(cf_t)); } /* mapping to resource elements */ for (i = 0; i < q->cell.nof_ports; i++) { - srslte_pbch_put(q->symbols[i], &sf_symbols[i][SRSLTE_SLOT_LEN_RE(q->cell.nof_prb, q->cell.cp)], q->cell); + srsran_pbch_put(q->symbols[i], &sf_symbols[i][SRSRAN_SLOT_LEN_RE(q->cell.nof_prb, q->cell.cp)], q->cell); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } else { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } } diff --git a/lib/src/phy/phch/pcfich.c b/lib/src/phy/phch/pcfich.c index bc56e568f..c584e0c9b 100644 --- a/lib/src/phy/phch/pcfich.c +++ b/lib/src/phy/phch/pcfich.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -19,12 +19,12 @@ #include #include -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/phch/pcfich.h" -#include "srslte/phy/phch/regs.h" -#include "srslte/phy/utils/bit.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/phch/pcfich.h" +#include "srsran/phy/phch/regs.h" +#include "srsran/phy/utils/bit.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" // Table 5.3.4-1 static uint8_t cfi_table[4][PCFICH_CFI_LEN] = { @@ -34,7 +34,7 @@ static uint8_t cfi_table[4][PCFICH_CFI_LEN] = { {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} // reserved }; -bool srslte_pcfich_exists(int nframe, int nslot) +bool srsran_pcfich_exists(int nframe, int nslot) { return true; } @@ -42,18 +42,18 @@ bool srslte_pcfich_exists(int nframe, int nslot) /** Initializes the pcfich channel receiver. * On ERROR returns -1 and frees the structrure */ -int srslte_pcfich_init(srslte_pcfich_t* q, uint32_t nof_rx_antennas) +int srsran_pcfich_init(srsran_pcfich_t* q, uint32_t nof_rx_antennas) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL) { - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; - bzero(q, sizeof(srslte_pcfich_t)); + bzero(q, sizeof(srsran_pcfich_t)); q->nof_rx_antennas = nof_rx_antennas; q->nof_symbols = PCFICH_RE; - if (srslte_modem_table_lte(&q->mod, SRSLTE_MOD_QPSK)) { + if (srsran_modem_table_lte(&q->mod, SRSRAN_MOD_QPSK)) { goto clean; } @@ -64,41 +64,41 @@ int srslte_pcfich_init(srslte_pcfich_t* q, uint32_t nof_rx_antennas) } } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } clean: - if (ret == SRSLTE_ERROR) { - srslte_pcfich_free(q); + if (ret == SRSRAN_ERROR) { + srsran_pcfich_free(q); } return ret; } -void srslte_pcfich_free(srslte_pcfich_t* q) +void srsran_pcfich_free(srsran_pcfich_t* q) { - for (int ns = 0; ns < SRSLTE_NOF_SF_X_FRAME; ns++) { - srslte_sequence_free(&q->seq[ns]); + for (int ns = 0; ns < SRSRAN_NOF_SF_X_FRAME; ns++) { + srsran_sequence_free(&q->seq[ns]); } - srslte_modem_table_free(&q->mod); + srsran_modem_table_free(&q->mod); - bzero(q, sizeof(srslte_pcfich_t)); + bzero(q, sizeof(srsran_pcfich_t)); } -int srslte_pcfich_set_cell(srslte_pcfich_t* q, srslte_regs_t* regs, srslte_cell_t cell) +int srsran_pcfich_set_cell(srsran_pcfich_t* q, srsran_regs_t* regs, srsran_cell_t cell) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; - if (q != NULL && regs != NULL && srslte_cell_isvalid(&cell)) { + if (q != NULL && regs != NULL && srsran_cell_isvalid(&cell)) { q->regs = regs; if (cell.id != q->cell.id || q->cell.nof_prb == 0) { q->cell = cell; - for (int nsf = 0; nsf < SRSLTE_NOF_SF_X_FRAME; nsf++) { - if (srslte_sequence_pcfich(&q->seq[nsf], 2 * nsf, q->cell.id)) { - return SRSLTE_ERROR; + for (int nsf = 0; nsf < SRSRAN_NOF_SF_X_FRAME; nsf++) { + if (srsran_sequence_pcfich(&q->seq[nsf], 2 * nsf, q->cell.id)) { + return SRSRAN_ERROR; } } } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } @@ -106,7 +106,7 @@ int srslte_pcfich_set_cell(srslte_pcfich_t* q, srslte_regs_t* regs, srslte_cell_ /** Finds the CFI with minimum distance with the vector of received 32 bits. * Saves the CFI value in the cfi pointer and returns the distance. */ -float srslte_pcfich_cfi_decode(srslte_pcfich_t* q, uint32_t* cfi) +float srsran_pcfich_cfi_decode(srsran_pcfich_t* q, uint32_t* cfi) { int i; int index = 0; @@ -114,7 +114,7 @@ float srslte_pcfich_cfi_decode(srslte_pcfich_t* q, uint32_t* cfi) float corr[3]; for (i = 0; i < 3; i++) { - corr[i] = srslte_vec_dot_prod_fff(q->cfi_table_float[i], q->data_f, PCFICH_CFI_LEN); + corr[i] = srsran_vec_dot_prod_fff(q->cfi_table_float[i], q->data_f, PCFICH_CFI_LEN); if (corr[i] > max_corr) { max_corr = corr[i]; index = i; @@ -130,13 +130,13 @@ float srslte_pcfich_cfi_decode(srslte_pcfich_t* q, uint32_t* cfi) /** Encodes the CFI producing a vector of 32 bits. * 36.211 10.3 section 5.3.4 */ -int srslte_pcfich_cfi_encode(uint32_t cfi, uint8_t bits[PCFICH_CFI_LEN]) +int srsran_pcfich_cfi_encode(uint32_t cfi, uint8_t bits[PCFICH_CFI_LEN]) { if (cfi < 1 || cfi > 3) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } else { memcpy(bits, cfi_table[cfi - 1], PCFICH_CFI_LEN * sizeof(uint8_t)); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } } @@ -144,41 +144,41 @@ int srslte_pcfich_cfi_encode(uint32_t cfi, uint8_t bits[PCFICH_CFI_LEN]) * * Returns 1 if successfully decoded the CFI, 0 if not and -1 on error */ -int srslte_pcfich_decode(srslte_pcfich_t* q, - srslte_dl_sf_cfg_t* sf, - srslte_chest_dl_res_t* channel, - cf_t* sf_symbols[SRSLTE_MAX_PORTS], +int srsran_pcfich_decode(srsran_pcfich_t* q, + srsran_dl_sf_cfg_t* sf, + srsran_chest_dl_res_t* channel, + cf_t* sf_symbols[SRSRAN_MAX_PORTS], float* corr_result) { /* Set pointers for layermapping & precoding */ int i; - cf_t* x[SRSLTE_MAX_LAYERS]; + cf_t* x[SRSRAN_MAX_LAYERS]; if (q != NULL && sf_symbols != NULL) { uint32_t sf_idx = sf->tti % 10; /* number of layers equals number of ports */ - for (i = 0; i < SRSLTE_MAX_PORTS; i++) { + for (i = 0; i < SRSRAN_MAX_PORTS; i++) { x[i] = q->x[i]; } - cf_t* q_symbols[SRSLTE_MAX_PORTS]; - cf_t* q_ce[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS]; + cf_t* q_symbols[SRSRAN_MAX_PORTS]; + cf_t* q_ce[SRSRAN_MAX_PORTS][SRSRAN_MAX_PORTS]; /* extract symbols */ for (int j = 0; j < q->nof_rx_antennas; j++) { - if (q->nof_symbols != srslte_regs_pcfich_get(q->regs, sf_symbols[j], q->symbols[j])) { + if (q->nof_symbols != srsran_regs_pcfich_get(q->regs, sf_symbols[j], q->symbols[j])) { ERROR("There was an error getting the PCFICH symbols"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } q_symbols[j] = q->symbols[j]; /* extract channel estimates */ for (i = 0; i < q->cell.nof_ports; i++) { - if (q->nof_symbols != srslte_regs_pcfich_get(q->regs, channel->ce[i][j], q->ce[i][j])) { + if (q->nof_symbols != srsran_regs_pcfich_get(q->regs, channel->ce[i][j], q->ce[i][j])) { ERROR("There was an error getting the PCFICH symbols"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } q_ce[i][j] = q->ce[i][j]; } @@ -187,34 +187,34 @@ int srslte_pcfich_decode(srslte_pcfich_t* q, /* in control channels, only diversity is supported */ if (q->cell.nof_ports == 1) { /* no need for layer demapping */ - srslte_predecoding_single_multi( + srsran_predecoding_single_multi( q_symbols, q_ce[0], q->d, NULL, q->nof_rx_antennas, q->nof_symbols, 1.0f, channel->noise_estimate); } else { - srslte_predecoding_diversity_multi( + srsran_predecoding_diversity_multi( q_symbols, q_ce, x, NULL, q->nof_rx_antennas, q->cell.nof_ports, q->nof_symbols, 1.0f); - srslte_layerdemap_diversity(x, q->d, q->cell.nof_ports, q->nof_symbols / q->cell.nof_ports); + srsran_layerdemap_diversity(x, q->d, q->cell.nof_ports, q->nof_symbols / q->cell.nof_ports); } /* demodulate symbols */ - srslte_demod_soft_demodulate(SRSLTE_MOD_QPSK, q->d, q->data_f, q->nof_symbols); + srsran_demod_soft_demodulate(SRSRAN_MOD_QPSK, q->d, q->data_f, q->nof_symbols); /* Scramble with the sequence for slot nslot */ - srslte_scrambling_f(&q->seq[sf_idx], q->data_f); + srsran_scrambling_f(&q->seq[sf_idx], q->data_f); /* decode CFI */ - float corr = srslte_pcfich_cfi_decode(q, &sf->cfi); + float corr = srsran_pcfich_cfi_decode(q, &sf->cfi); if (corr_result) { *corr_result = corr; } return 1; } else { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } } /** Encodes CFI and maps symbols to the slot */ -int srslte_pcfich_encode(srslte_pcfich_t* q, srslte_dl_sf_cfg_t* sf, cf_t* slot_symbols[SRSLTE_MAX_PORTS]) +int srsran_pcfich_encode(srsran_pcfich_t* q, srsran_dl_sf_cfg_t* sf, cf_t* slot_symbols[SRSRAN_MAX_PORTS]) { int i; @@ -222,42 +222,42 @@ int srslte_pcfich_encode(srslte_pcfich_t* q, srslte_dl_sf_cfg_t* sf, cf_t* slot_ uint32_t sf_idx = sf->tti % 10; /* Set pointers for layermapping & precoding */ - cf_t* x[SRSLTE_MAX_LAYERS]; - cf_t* q_symbols[SRSLTE_MAX_PORTS]; + cf_t* x[SRSRAN_MAX_LAYERS]; + cf_t* q_symbols[SRSRAN_MAX_PORTS]; /* number of layers equals number of ports */ for (i = 0; i < q->cell.nof_ports; i++) { x[i] = q->x[i]; } - for (i = 0; i < SRSLTE_MAX_PORTS; i++) { + for (i = 0; i < SRSRAN_MAX_PORTS; i++) { q_symbols[i] = q->symbols[i]; } /* pack CFI */ - srslte_pcfich_cfi_encode(sf->cfi, q->data); + srsran_pcfich_cfi_encode(sf->cfi, q->data); /* scramble for slot sequence nslot */ - srslte_scrambling_b(&q->seq[sf_idx], q->data); + srsran_scrambling_b(&q->seq[sf_idx], q->data); - srslte_mod_modulate(&q->mod, q->data, q->d, PCFICH_CFI_LEN); + srsran_mod_modulate(&q->mod, q->data, q->d, PCFICH_CFI_LEN); /* layer mapping & precoding */ if (q->cell.nof_ports > 1) { - srslte_layermap_diversity(q->d, x, q->cell.nof_ports, q->nof_symbols); - srslte_precoding_diversity(x, q_symbols, q->cell.nof_ports, q->nof_symbols / q->cell.nof_ports, 1.0f); + srsran_layermap_diversity(q->d, x, q->cell.nof_ports, q->nof_symbols); + srsran_precoding_diversity(x, q_symbols, q->cell.nof_ports, q->nof_symbols / q->cell.nof_ports, 1.0f); } else { memcpy(q->symbols[0], q->d, q->nof_symbols * sizeof(cf_t)); } /* mapping to resource elements */ for (i = 0; i < q->cell.nof_ports; i++) { - if (srslte_regs_pcfich_put(q->regs, q->symbols[i], slot_symbols[i]) < 0) { + if (srsran_regs_pcfich_put(q->regs, q->symbols[i], slot_symbols[i]) < 0) { ERROR("Error putting PCHICH resource elements"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } else { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } } diff --git a/lib/src/phy/phch/pdcch.c b/lib/src/phy/phch/pdcch.c index 3f7324939..f7a4acf74 100644 --- a/lib/src/phy/phch/pdcch.c +++ b/lib/src/phy/phch/pdcch.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -18,13 +18,13 @@ #include #include -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/phch/dci.h" -#include "srslte/phy/phch/pdcch.h" -#include "srslte/phy/phch/regs.h" -#include "srslte/phy/utils/bit.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/phch/dci.h" +#include "srsran/phy/phch/pdcch.h" +#include "srsran/phy/phch/regs.h" +#include "srsran/phy/utils/bit.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" #define PDCCH_NOF_FORMATS 4 #define PDCCH_FORMAT_NOF_CCE(i) (1 << i) @@ -34,19 +34,19 @@ #define NOF_CCE(cfi) ((cfi > 0 && cfi < 4) ? q->nof_cce[cfi - 1] : 0) #define NOF_REGS(cfi) ((cfi > 0 && cfi < 4) ? q->nof_regs[cfi - 1] : 0) -float srslte_pdcch_coderate(uint32_t nof_bits, uint32_t l) +float srsran_pdcch_coderate(uint32_t nof_bits, uint32_t l) { return (float)(nof_bits + 16) / (4 * PDCCH_FORMAT_NOF_REGS(l)); } /** Initializes the PDCCH transmitter and receiver */ -static int pdcch_init(srslte_pdcch_t* q, uint32_t max_prb, uint32_t nof_rx_antennas, bool is_ue) +static int pdcch_init(srsran_pdcch_t* q, uint32_t max_prb, uint32_t nof_rx_antennas, bool is_ue) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL) { - ret = SRSLTE_ERROR; - bzero(q, sizeof(srslte_pdcch_t)); + ret = SRSRAN_ERROR; + bzero(q, sizeof(srsran_pdcch_t)); q->nof_rx_antennas = nof_rx_antennas; q->is_ue = is_ue; /* Allocate memory for the maximum number of PDCCH bits (CFI=3) */ @@ -54,47 +54,47 @@ static int pdcch_init(srslte_pdcch_t* q, uint32_t max_prb, uint32_t nof_rx_anten INFO("Init PDCCH: Max bits: %d", q->max_bits); - if (srslte_modem_table_lte(&q->mod, SRSLTE_MOD_QPSK)) { + if (srsran_modem_table_lte(&q->mod, SRSRAN_MOD_QPSK)) { goto clean; } - if (srslte_crc_init(&q->crc, SRSLTE_LTE_CRC16, 16)) { + if (srsran_crc_init(&q->crc, SRSRAN_LTE_CRC16, 16)) { goto clean; } int poly[3] = {0x6D, 0x4F, 0x57}; - if (srslte_viterbi_init(&q->decoder, SRSLTE_VITERBI_37, poly, SRSLTE_DCI_MAX_BITS + 16, true)) { + if (srsran_viterbi_init(&q->decoder, SRSRAN_VITERBI_37, poly, SRSRAN_DCI_MAX_BITS + 16, true)) { goto clean; } - q->e = srslte_vec_u8_malloc(q->max_bits); + q->e = srsran_vec_u8_malloc(q->max_bits); if (!q->e) { goto clean; } - q->llr = srslte_vec_f_malloc(q->max_bits); + q->llr = srsran_vec_f_malloc(q->max_bits); if (!q->llr) { goto clean; } - srslte_vec_f_zero(q->llr, q->max_bits); + srsran_vec_f_zero(q->llr, q->max_bits); - q->d = srslte_vec_cf_malloc(q->max_bits / 2); + q->d = srsran_vec_cf_malloc(q->max_bits / 2); if (!q->d) { goto clean; } - for (int i = 0; i < SRSLTE_MAX_PORTS; i++) { - q->x[i] = srslte_vec_cf_malloc(q->max_bits / 2); + for (int i = 0; i < SRSRAN_MAX_PORTS; i++) { + q->x[i] = srsran_vec_cf_malloc(q->max_bits / 2); if (!q->x[i]) { goto clean; } - q->symbols[i] = srslte_vec_cf_malloc(q->max_bits / 2); + q->symbols[i] = srsran_vec_cf_malloc(q->max_bits / 2); if (!q->symbols[i]) { goto clean; } if (q->is_ue) { for (int j = 0; j < q->nof_rx_antennas; j++) { - q->ce[i][j] = srslte_vec_cf_malloc(q->max_bits / 2); + q->ce[i][j] = srsran_vec_cf_malloc(q->max_bits / 2); if (!q->ce[i][j]) { goto clean; } @@ -102,26 +102,26 @@ static int pdcch_init(srslte_pdcch_t* q, uint32_t max_prb, uint32_t nof_rx_anten } } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } clean: - if (ret == SRSLTE_ERROR) { - srslte_pdcch_free(q); + if (ret == SRSRAN_ERROR) { + srsran_pdcch_free(q); } return ret; } -int srslte_pdcch_init_enb(srslte_pdcch_t* q, uint32_t max_prb) +int srsran_pdcch_init_enb(srsran_pdcch_t* q, uint32_t max_prb) { return pdcch_init(q, max_prb, 0, false); } -int srslte_pdcch_init_ue(srslte_pdcch_t* q, uint32_t max_prb, uint32_t nof_rx_antennas) +int srsran_pdcch_init_ue(srsran_pdcch_t* q, uint32_t max_prb, uint32_t nof_rx_antennas) { return pdcch_init(q, max_prb, nof_rx_antennas, true); } -void srslte_pdcch_free(srslte_pdcch_t* q) +void srsran_pdcch_free(srsran_pdcch_t* q) { if (q->e) { free(q->e); @@ -132,7 +132,7 @@ void srslte_pdcch_free(srslte_pdcch_t* q) if (q->d) { free(q->d); } - for (int i = 0; i < SRSLTE_MAX_PORTS; i++) { + for (int i = 0; i < SRSRAN_MAX_PORTS; i++) { if (q->x[i]) { free(q->x[i]); } @@ -147,22 +147,22 @@ void srslte_pdcch_free(srslte_pdcch_t* q) } } } - for (int i = 0; i < SRSLTE_NOF_SF_X_FRAME; i++) { - srslte_sequence_free(&q->seq[i]); + for (int i = 0; i < SRSRAN_NOF_SF_X_FRAME; i++) { + srsran_sequence_free(&q->seq[i]); } - srslte_modem_table_free(&q->mod); - srslte_viterbi_free(&q->decoder); + srsran_modem_table_free(&q->mod); + srsran_viterbi_free(&q->decoder); - bzero(q, sizeof(srslte_pdcch_t)); + bzero(q, sizeof(srsran_pdcch_t)); } -void srslte_pdcch_set_regs(srslte_pdcch_t* q, srslte_regs_t* regs) +void srsran_pdcch_set_regs(srsran_pdcch_t* q, srsran_regs_t* regs) { q->regs = regs; for (int cfi = 0; cfi < 3; cfi++) { - q->nof_regs[cfi] = (srslte_regs_pdcch_nregs(q->regs, cfi + 1) / 9) * 9; + q->nof_regs[cfi] = (srsran_regs_pdcch_nregs(q->regs, cfi + 1) / 9) * 9; q->nof_cce[cfi] = q->nof_regs[cfi] / 9; } @@ -170,47 +170,47 @@ void srslte_pdcch_set_regs(srslte_pdcch_t* q, srslte_regs_t* regs) q->max_bits = (NOF_REGS(3) / 9) * 72; } -int srslte_pdcch_set_cell(srslte_pdcch_t* q, srslte_regs_t* regs, srslte_cell_t cell) +int srsran_pdcch_set_cell(srsran_pdcch_t* q, srsran_regs_t* regs, srsran_cell_t cell) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; - if (q != NULL && regs != NULL && srslte_cell_isvalid(&cell)) { - srslte_pdcch_set_regs(q, regs); + if (q != NULL && regs != NULL && srsran_cell_isvalid(&cell)) { + srsran_pdcch_set_regs(q, regs); INFO("PDCCH: Cell config PCI=%d, %d ports.", q->cell.id, q->cell.nof_ports); if (q->cell.id != cell.id || q->cell.nof_prb == 0) { q->cell = cell; - for (int i = 0; i < SRSLTE_NOF_SF_X_FRAME; i++) { + for (int i = 0; i < SRSRAN_NOF_SF_X_FRAME; i++) { // we need to pregenerate the sequence for the maximum number of bits, which is 8 times // the maximum number of REGs (for CFI=3) - if (srslte_sequence_pdcch(&q->seq[i], 2 * i, q->cell.id, 8 * srslte_regs_pdcch_nregs(q->regs, 3))) { - return SRSLTE_ERROR; + if (srsran_sequence_pdcch(&q->seq[i], 2 * i, q->cell.id, 8 * srsran_regs_pdcch_nregs(q->regs, 3))) { + return SRSRAN_ERROR; } } } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } -uint32_t srslte_pdcch_ue_locations(srslte_pdcch_t* q, - srslte_dl_sf_cfg_t* sf, - srslte_dci_location_t* c, +uint32_t srsran_pdcch_ue_locations(srsran_pdcch_t* q, + srsran_dl_sf_cfg_t* sf, + srsran_dci_location_t* c, uint32_t max_candidates, uint16_t rnti) { - return srslte_pdcch_ue_locations_ncce(NOF_CCE(sf->cfi), c, max_candidates, sf->tti % 10, rnti); + return srsran_pdcch_ue_locations_ncce(NOF_CCE(sf->cfi), c, max_candidates, sf->tti % 10, rnti); } -uint32_t srslte_pdcch_ue_locations_ncce(uint32_t nof_cce, - srslte_dci_location_t* c, +uint32_t srsran_pdcch_ue_locations_ncce(uint32_t nof_cce, + srsran_dci_location_t* c, uint32_t max_candidates, uint32_t sf_idx, uint16_t rnti) { - return srslte_pdcch_ue_locations_ncce_L(nof_cce, c, max_candidates, sf_idx, rnti, -1); + return srsran_pdcch_ue_locations_ncce_L(nof_cce, c, max_candidates, sf_idx, rnti, -1); } /** 36.213 v9.1.1 @@ -218,8 +218,8 @@ uint32_t srslte_pdcch_ue_locations_ncce(uint32_t nof_cce, * in the structure pointed by c. * Returns the number of candidates saved in the array c. */ -uint32_t srslte_pdcch_ue_locations_ncce_L(uint32_t nof_cce, - srslte_dci_location_t* c, +uint32_t srsran_pdcch_ue_locations_ncce_L(uint32_t nof_cce, + srsran_dci_location_t* c, uint32_t max_candidates, uint32_t sf_idx, uint16_t rnti, @@ -287,19 +287,19 @@ uint32_t srslte_pdcch_ue_locations_ncce_L(uint32_t nof_cce, * Returns the number of candidates saved in the array c. */ uint32_t -srslte_pdcch_common_locations(srslte_pdcch_t* q, srslte_dci_location_t* c, uint32_t max_candidates, uint32_t cfi) +srsran_pdcch_common_locations(srsran_pdcch_t* q, srsran_dci_location_t* c, uint32_t max_candidates, uint32_t cfi) { - return srslte_pdcch_common_locations_ncce(NOF_CCE(cfi), c, max_candidates); + return srsran_pdcch_common_locations_ncce(NOF_CCE(cfi), c, max_candidates); } -uint32_t srslte_pdcch_common_locations_ncce(uint32_t nof_cce, srslte_dci_location_t* c, uint32_t max_candidates) +uint32_t srsran_pdcch_common_locations_ncce(uint32_t nof_cce, srsran_dci_location_t* c, uint32_t max_candidates) { uint32_t i, l, L, k; k = 0; for (l = 2; l <= 3; l++) { L = (1 << l); - for (i = 0; i < SRSLTE_MIN(nof_cce, 16) / (L); i++) { + for (i = 0; i < SRSRAN_MIN(nof_cce, 16) / (L); i++) { // Simplified expression, derived from: // L * ((Yk + m) % (N_cce / L)) + i uint32_t ncce = L * i; @@ -323,57 +323,57 @@ uint32_t srslte_pdcch_common_locations_ncce(uint32_t nof_cce, srslte_dci_locatio * * TODO: UE transmit antenna selection CRC mask */ -int srslte_pdcch_dci_decode(srslte_pdcch_t* q, float* e, uint8_t* data, uint32_t E, uint32_t nof_bits, uint16_t* crc) +int srsran_pdcch_dci_decode(srsran_pdcch_t* q, float* e, uint8_t* data, uint32_t E, uint32_t nof_bits, uint16_t* crc) { uint16_t p_bits, crc_res; uint8_t* x; if (q != NULL) { - if (data != NULL && E <= q->max_bits && nof_bits <= SRSLTE_DCI_MAX_BITS) { - srslte_vec_f_zero(q->rm_f, 3 * (SRSLTE_DCI_MAX_BITS + 16)); + if (data != NULL && E <= q->max_bits && nof_bits <= SRSRAN_DCI_MAX_BITS) { + srsran_vec_f_zero(q->rm_f, 3 * (SRSRAN_DCI_MAX_BITS + 16)); uint32_t coded_len = 3 * (nof_bits + 16); /* unrate matching */ - srslte_rm_conv_rx(e, E, q->rm_f, coded_len); + srsran_rm_conv_rx(e, E, q->rm_f, coded_len); /* viterbi decoder */ - srslte_viterbi_decode_f(&q->decoder, q->rm_f, data, nof_bits + 16); + srsran_viterbi_decode_f(&q->decoder, q->rm_f, data, nof_bits + 16); x = &data[nof_bits]; - p_bits = (uint16_t)srslte_bit_pack(&x, 16); - crc_res = ((uint16_t)srslte_crc_checksum(&q->crc, data, nof_bits) & 0xffff); + p_bits = (uint16_t)srsran_bit_pack(&x, 16); + crc_res = ((uint16_t)srsran_crc_checksum(&q->crc, data, nof_bits) & 0xffff); if (crc) { *crc = p_bits ^ crc_res; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } else { ERROR("Invalid parameters: E: %d, max_bits: %d, nof_bits: %d", E, q->max_bits, nof_bits); - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } } else { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } } -/** Tries to decode a DCI message from the LLRs stored in the srslte_pdcch_t structure by the function - * srslte_pdcch_extract_llr(). This function can be called multiple times. +/** Tries to decode a DCI message from the LLRs stored in the srsran_pdcch_t structure by the function + * srsran_pdcch_extract_llr(). This function can be called multiple times. * The location to search for is obtained from msg. * The decoded message is stored in msg and the CRC remainder in msg->rnti * */ -int srslte_pdcch_decode_msg(srslte_pdcch_t* q, srslte_dl_sf_cfg_t* sf, srslte_dci_cfg_t* dci_cfg, srslte_dci_msg_t* msg) +int srsran_pdcch_decode_msg(srsran_pdcch_t* q, srsran_dl_sf_cfg_t* sf, srsran_dci_cfg_t* dci_cfg, srsran_dci_msg_t* msg) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; - if (q != NULL && msg != NULL && srslte_dci_location_isvalid(&msg->location)) { + int ret = SRSRAN_ERROR_INVALID_INPUTS; + if (q != NULL && msg != NULL && srsran_dci_location_isvalid(&msg->location)) { if (msg->location.ncce * 72 + PDCCH_FORMAT_NOF_BITS(msg->location.L) > NOF_CCE(sf->cfi) * 72) { ERROR("Invalid location: nCCE: %d, L: %d, NofCCE: %d", msg->location.ncce, msg->location.L, NOF_CCE(sf->cfi)); } else { - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; - uint32_t nof_bits = srslte_dci_format_sizeof(&q->cell, sf, dci_cfg, msg->format); + uint32_t nof_bits = srsran_dci_format_sizeof(&q->cell, sf, dci_cfg, msg->format); uint32_t e_bits = PDCCH_FORMAT_NOF_BITS(msg->location.L); double mean = 0; @@ -382,12 +382,12 @@ int srslte_pdcch_decode_msg(srslte_pdcch_t* q, srslte_dl_sf_cfg_t* sf, srslte_dc } mean /= e_bits; if (mean > 0.3) { - ret = srslte_pdcch_dci_decode(q, &q->llr[msg->location.ncce * 72], msg->payload, e_bits, nof_bits, &msg->rnti); - if (ret == SRSLTE_SUCCESS) { + ret = srsran_pdcch_dci_decode(q, &q->llr[msg->location.ncce * 72], msg->payload, e_bits, nof_bits, &msg->rnti); + if (ret == SRSRAN_SUCCESS) { msg->nof_bits = nof_bits; // Check format differentiation - if (msg->format == SRSLTE_DCI_FORMAT0 || msg->format == SRSLTE_DCI_FORMAT1A) { - msg->format = (msg->payload[dci_cfg->cif_enabled ? 3 : 0] == 0) ? SRSLTE_DCI_FORMAT0 : SRSLTE_DCI_FORMAT1A; + if (msg->format == SRSRAN_DCI_FORMAT0 || msg->format == SRSRAN_DCI_FORMAT1A) { + msg->format = (msg->payload[dci_cfg->cif_enabled ? 3 : 0] == 0) ? SRSRAN_DCI_FORMAT0 : SRSRAN_DCI_FORMAT1A; } } else { ERROR("Error calling pdcch_dci_decode"); @@ -395,7 +395,7 @@ int srslte_pdcch_decode_msg(srslte_pdcch_t* q, srslte_dl_sf_cfg_t* sf, srslte_dc INFO("Decoded DCI: nCCE=%d, L=%d, format=%s, msg_len=%d, mean=%f, crc_rem=0x%x", msg->location.ncce, msg->location.L, - srslte_dci_format_string(msg->format), + srsran_dci_format_string(msg->format), nof_bits, mean, msg->rnti); @@ -409,25 +409,25 @@ int srslte_pdcch_decode_msg(srslte_pdcch_t* q, srslte_dl_sf_cfg_t* sf, srslte_dc return ret; } -/** Performs PDCCH receiver processing to extract LLR for all control region. LLR bits are stored in srslte_pdcch_t - * object. DCI can be decoded from given locations in successive calls to srslte_pdcch_decode_msg() +/** Performs PDCCH receiver processing to extract LLR for all control region. LLR bits are stored in srsran_pdcch_t + * object. DCI can be decoded from given locations in successive calls to srsran_pdcch_decode_msg() */ -int srslte_pdcch_extract_llr(srslte_pdcch_t* q, - srslte_dl_sf_cfg_t* sf, - srslte_chest_dl_res_t* channel, - cf_t* sf_symbols[SRSLTE_MAX_PORTS]) +int srsran_pdcch_extract_llr(srsran_pdcch_t* q, + srsran_dl_sf_cfg_t* sf, + srsran_chest_dl_res_t* channel, + cf_t* sf_symbols[SRSRAN_MAX_PORTS]) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; /* Set pointers for layermapping & precoding */ uint32_t i, nof_symbols; - cf_t* x[SRSLTE_MAX_LAYERS]; + cf_t* x[SRSRAN_MAX_LAYERS]; if (q != NULL && sf->cfi > 0 && sf->cfi < 4) { uint32_t e_bits = 72 * NOF_CCE(sf->cfi); nof_symbols = e_bits / 2; - ret = SRSLTE_ERROR; - srslte_vec_f_zero(q->llr, q->max_bits); + ret = SRSRAN_ERROR; + srsran_vec_f_zero(q->llr, q->max_bits); DEBUG("Extracting LLRs: E: %d, SF: %d, CFI: %d", e_bits, sf->tti % 10, sf->cfi); @@ -435,11 +435,11 @@ int srslte_pdcch_extract_llr(srslte_pdcch_t* q, for (i = 0; i < q->cell.nof_ports; i++) { x[i] = q->x[i]; } - memset(&x[q->cell.nof_ports], 0, sizeof(cf_t*) * (SRSLTE_MAX_LAYERS - q->cell.nof_ports)); + memset(&x[q->cell.nof_ports], 0, sizeof(cf_t*) * (SRSRAN_MAX_LAYERS - q->cell.nof_ports)); /* extract symbols */ for (int j = 0; j < q->nof_rx_antennas; j++) { - int n = srslte_regs_pdcch_get(q->regs, sf->cfi, sf_symbols[j], q->symbols[j]); + int n = srsran_regs_pdcch_get(q->regs, sf->cfi, sf_symbols[j], q->symbols[j]); if (nof_symbols != n) { ERROR("Expected %d PDCCH symbols but got %d symbols", nof_symbols, n); return ret; @@ -447,7 +447,7 @@ int srslte_pdcch_extract_llr(srslte_pdcch_t* q, /* extract channel estimates */ for (i = 0; i < q->cell.nof_ports; i++) { - n = srslte_regs_pdcch_get(q->regs, sf->cfi, channel->ce[i][j], q->ce[i][j]); + n = srsran_regs_pdcch_get(q->regs, sf->cfi, channel->ce[i][j], q->ce[i][j]); if (nof_symbols != n) { ERROR("Expected %d PDCCH symbols but got %d symbols", nof_symbols, n); return ret; @@ -458,21 +458,21 @@ int srslte_pdcch_extract_llr(srslte_pdcch_t* q, /* in control channels, only diversity is supported */ if (q->cell.nof_ports == 1) { /* no need for layer demapping */ - srslte_predecoding_single_multi( + srsran_predecoding_single_multi( q->symbols, q->ce[0], q->d, NULL, q->nof_rx_antennas, nof_symbols, 1.0f, channel->noise_estimate / 2); } else { - srslte_predecoding_diversity_multi( + srsran_predecoding_diversity_multi( q->symbols, q->ce, x, NULL, q->nof_rx_antennas, q->cell.nof_ports, nof_symbols, 1.0f); - srslte_layerdemap_diversity(x, q->d, q->cell.nof_ports, nof_symbols / q->cell.nof_ports); + srsran_layerdemap_diversity(x, q->d, q->cell.nof_ports, nof_symbols / q->cell.nof_ports); } /* demodulate symbols */ - srslte_demod_soft_demodulate(SRSLTE_MOD_QPSK, q->d, q->llr, nof_symbols); + srsran_demod_soft_demodulate(SRSRAN_MOD_QPSK, q->d, q->llr, nof_symbols); /* descramble */ - srslte_scrambling_f_offset(&q->seq[sf->tti % 10], q->llr, 0, e_bits); + srsran_scrambling_f_offset(&q->seq[sf->tti % 10], q->llr, 0, e_bits); - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } @@ -485,55 +485,55 @@ static void crc_set_mask_rnti(uint8_t* crc, uint16_t rnti) DEBUG("Mask CRC with RNTI 0x%x", rnti); - srslte_bit_unpack(rnti, &r, 16); + srsran_bit_unpack(rnti, &r, 16); for (i = 0; i < 16; i++) { crc[i] = (crc[i] + mask[i]) % 2; } } -void srslte_pdcch_dci_encode_conv(srslte_pdcch_t* q, +void srsran_pdcch_dci_encode_conv(srsran_pdcch_t* q, uint8_t* data, uint32_t nof_bits, uint8_t* coded_data, uint16_t rnti) { - srslte_convcoder_t encoder; + srsran_convcoder_t encoder; int poly[3] = {0x6D, 0x4F, 0x57}; encoder.K = 7; encoder.R = 3; encoder.tail_biting = true; memcpy(encoder.poly, poly, 3 * sizeof(int)); - srslte_crc_attach(&q->crc, data, nof_bits); + srsran_crc_attach(&q->crc, data, nof_bits); crc_set_mask_rnti(&data[nof_bits], rnti); - srslte_convcoder_encode(&encoder, data, coded_data, nof_bits + 16); + srsran_convcoder_encode(&encoder, data, coded_data, nof_bits + 16); } /** 36.212 5.3.3.2 to 5.3.3.4 * TODO: UE transmit antenna selection CRC mask */ -int srslte_pdcch_dci_encode(srslte_pdcch_t* q, uint8_t* data, uint8_t* e, uint32_t nof_bits, uint32_t E, uint16_t rnti) +int srsran_pdcch_dci_encode(srsran_pdcch_t* q, uint8_t* data, uint8_t* e, uint32_t nof_bits, uint32_t E, uint16_t rnti) { - uint8_t tmp[3 * (SRSLTE_DCI_MAX_BITS + 16)]; + uint8_t tmp[3 * (SRSRAN_DCI_MAX_BITS + 16)]; - if (q != NULL && data != NULL && e != NULL && nof_bits < SRSLTE_DCI_MAX_BITS && E < q->max_bits) { - srslte_pdcch_dci_encode_conv(q, data, nof_bits, tmp, rnti); + if (q != NULL && data != NULL && e != NULL && nof_bits < SRSRAN_DCI_MAX_BITS && E < q->max_bits) { + srsran_pdcch_dci_encode_conv(q, data, nof_bits, tmp, rnti); DEBUG("CConv output: "); - if (SRSLTE_VERBOSE_ISDEBUG()) { - srslte_vec_fprint_b(stdout, tmp, 3 * (nof_bits + 16)); + if (SRSRAN_VERBOSE_ISDEBUG()) { + srsran_vec_fprint_b(stdout, tmp, 3 * (nof_bits + 16)); } - srslte_rm_conv_tx(tmp, 3 * (nof_bits + 16), e, E); + srsran_rm_conv_tx(tmp, 3 * (nof_bits + 16), e, E); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } else { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } } -/** Encodes ONE DCI message and allocates the encoded bits to the srslte_dci_location_t indicated by +/** Encodes ONE DCI message and allocates the encoded bits to the srsran_dci_location_t indicated by * the parameter location. The CRC is scrambled with the RNTI parameter. * This function can be called multiple times and encoded DCI messages will be allocated to the * sf_symbols buffer ready for transmission. @@ -541,23 +541,23 @@ int srslte_pdcch_dci_encode(srslte_pdcch_t* q, uint8_t* data, uint8_t* e, uint32 * * @TODO: Use a bitmask and CFI to ensure message locations are valid and old messages are not overwritten. */ -int srslte_pdcch_encode(srslte_pdcch_t* q, - srslte_dl_sf_cfg_t* sf, - srslte_dci_msg_t* msg, - cf_t* sf_symbols[SRSLTE_MAX_PORTS]) +int srsran_pdcch_encode(srsran_pdcch_t* q, + srsran_dl_sf_cfg_t* sf, + srsran_dci_msg_t* msg, + cf_t* sf_symbols[SRSRAN_MAX_PORTS]) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; uint32_t i; - cf_t* x[SRSLTE_MAX_LAYERS]; + cf_t* x[SRSRAN_MAX_LAYERS]; uint32_t nof_symbols; - if (q != NULL && sf_symbols != NULL && sf->cfi > 0 && sf->cfi < 4 && srslte_dci_location_isvalid(&msg->location)) { + if (q != NULL && sf_symbols != NULL && sf->cfi > 0 && sf->cfi < 4 && srsran_dci_location_isvalid(&msg->location)) { uint32_t e_bits = PDCCH_FORMAT_NOF_BITS(msg->location.L); nof_symbols = e_bits / 2; - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; if (msg->location.ncce + PDCCH_FORMAT_NOF_CCE(msg->location.L) <= NOF_CCE(sf->cfi) && - msg->nof_bits < SRSLTE_DCI_MAX_BITS - 16) { + msg->nof_bits < SRSRAN_DCI_MAX_BITS - 16) { DEBUG("Encoding DCI: Nbits: %d, E: %d, nCCE: %d, L: %d, RNTI: 0x%x", msg->nof_bits, e_bits, @@ -565,34 +565,34 @@ int srslte_pdcch_encode(srslte_pdcch_t* q, msg->location.L, msg->rnti); - srslte_pdcch_dci_encode(q, msg->payload, q->e, msg->nof_bits, e_bits, msg->rnti); + srsran_pdcch_dci_encode(q, msg->payload, q->e, msg->nof_bits, e_bits, msg->rnti); /* number of layers equals number of ports */ for (i = 0; i < q->cell.nof_ports; i++) { x[i] = q->x[i]; } - memset(&x[q->cell.nof_ports], 0, sizeof(cf_t*) * (SRSLTE_MAX_LAYERS - q->cell.nof_ports)); + memset(&x[q->cell.nof_ports], 0, sizeof(cf_t*) * (SRSRAN_MAX_LAYERS - q->cell.nof_ports)); - srslte_scrambling_b_offset(&q->seq[sf->tti % 10], q->e, 72 * msg->location.ncce, e_bits); + srsran_scrambling_b_offset(&q->seq[sf->tti % 10], q->e, 72 * msg->location.ncce, e_bits); DEBUG("Scrambling output: "); - if (SRSLTE_VERBOSE_ISDEBUG()) { - srslte_vec_fprint_b(stdout, q->e, e_bits); + if (SRSRAN_VERBOSE_ISDEBUG()) { + srsran_vec_fprint_b(stdout, q->e, e_bits); } - srslte_mod_modulate(&q->mod, q->e, q->d, e_bits); + srsran_mod_modulate(&q->mod, q->e, q->d, e_bits); /* layer mapping & precoding */ if (q->cell.nof_ports > 1) { - srslte_layermap_diversity(q->d, x, q->cell.nof_ports, nof_symbols); - srslte_precoding_diversity(x, q->symbols, q->cell.nof_ports, nof_symbols / q->cell.nof_ports, 1.0f); + srsran_layermap_diversity(q->d, x, q->cell.nof_ports, nof_symbols); + srsran_precoding_diversity(x, q->symbols, q->cell.nof_ports, nof_symbols / q->cell.nof_ports, 1.0f); } else { memcpy(q->symbols[0], q->d, nof_symbols * sizeof(cf_t)); } /* mapping to resource elements */ for (i = 0; i < q->cell.nof_ports; i++) { - srslte_regs_pdcch_put_offset(q->regs, + srsran_regs_pdcch_put_offset(q->regs, sf->cfi, q->symbols[i], sf_symbols[i], @@ -600,7 +600,7 @@ int srslte_pdcch_encode(srslte_pdcch_t* q, PDCCH_FORMAT_NOF_REGS(msg->location.L)); } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } else { ERROR("Illegal DCI message nCCE: %d, L: %d, nof_cce: %d, nof_bits=%d", diff --git a/lib/src/phy/phch/pdcch_nr.c b/lib/src/phy/phch/pdcch_nr.c index 27aca08ac..c29946e50 100644 --- a/lib/src/phy/phch/pdcch_nr.c +++ b/lib/src/phy/phch/pdcch_nr.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,15 +10,15 @@ * */ -#include "srslte/phy/phch/pdcch_nr.h" -#include "srslte/phy/common/sequence.h" -#include "srslte/phy/fec/polar/polar_chanalloc.h" -#include "srslte/phy/fec/polar/polar_interleaver.h" -#include "srslte/phy/mimo/precoding.h" -#include "srslte/phy/modem/demod_soft.h" -#include "srslte/phy/utils/bit.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/phch/pdcch_nr.h" +#include "srsran/phy/common/sequence.h" +#include "srsran/phy/fec/polar/polar_chanalloc.h" +#include "srsran/phy/fec/polar/polar_interleaver.h" +#include "srsran/phy/mimo/precoding.h" +#include "srsran/phy/modem/demod_soft.h" +#include "srsran/phy/utils/bit.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" #define PDCCH_NR_POLAR_RM_IBIL 0 @@ -28,7 +28,7 @@ /** * @brief Recursive Y_p_n function */ -static uint32_t srslte_pdcch_calculate_Y_p_n(uint32_t coreset_id, uint16_t rnti, uint32_t n) +static uint32_t srsran_pdcch_calculate_Y_p_n(uint32_t coreset_id, uint16_t rnti, uint32_t n) { static const uint32_t A_p[3] = {39827, 39829, 39839}; const uint32_t D = 65537; @@ -46,16 +46,16 @@ static uint32_t srslte_pdcch_calculate_Y_p_n(uint32_t coreset_id, uint16_t rnti, * downlink control channel assignment * */ -static int srslte_pdcch_nr_get_ncce(const srslte_coreset_t* coreset, - const srslte_search_space_t* search_space, +static int srsran_pdcch_nr_get_ncce(const srsran_coreset_t* coreset, + const srsran_search_space_t* search_space, uint16_t rnti, uint32_t aggregation_level, uint32_t slot_idx, uint32_t candidate) { - if (aggregation_level >= SRSLTE_SEARCH_SPACE_NOF_AGGREGATION_LEVELS_NR) { + if (aggregation_level >= SRSRAN_SEARCH_SPACE_NOF_AGGREGATION_LEVELS_NR) { ERROR("Invalid aggregation level %d;", aggregation_level); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } uint32_t L = 1U << aggregation_level; // Aggregation level @@ -65,45 +65,45 @@ static int srslte_pdcch_nr_get_ncce(const srslte_coreset_t* coreset, if (M == 0) { ERROR("Invalid number of candidates %d for aggregation level %d", M, aggregation_level); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Every REG is 1PRB wide and a CCE is 6 REG. So, the number of N_CCE is a sixth of the bandwidth times the number of // symbols - uint32_t N_cce = srslte_coreset_get_bw(coreset) * coreset->duration / 6; + uint32_t N_cce = srsran_coreset_get_bw(coreset) * coreset->duration / 6; if (N_cce < L) { ERROR("Error number of CCE %d is lower than the aggregation level %d", N_cce, L); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Calculate Y_p_n for UE search space only uint32_t Y_p_n = 0; - if (search_space->type == srslte_search_space_type_ue) { - Y_p_n = srslte_pdcch_calculate_Y_p_n(coreset->id, rnti, slot_idx); + if (search_space->type == srsran_search_space_type_ue) { + Y_p_n = srsran_pdcch_calculate_Y_p_n(coreset->id, rnti, slot_idx); } return (int)(L * ((Y_p_n + (m * N_cce) / (L * M) + n_ci) % (N_cce / L))); } -int srslte_pdcch_nr_locations_coreset(const srslte_coreset_t* coreset, - const srslte_search_space_t* search_space, +int srsran_pdcch_nr_locations_coreset(const srsran_coreset_t* coreset, + const srsran_search_space_t* search_space, uint16_t rnti, uint32_t aggregation_level, uint32_t slot_idx, - uint32_t locations[SRSLTE_SEARCH_SPACE_MAX_NOF_CANDIDATES_NR]) + uint32_t locations[SRSRAN_SEARCH_SPACE_MAX_NOF_CANDIDATES_NR]) { if (coreset == NULL || search_space == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } uint32_t nof_candidates = search_space->nof_candidates[aggregation_level]; - nof_candidates = SRSLTE_MIN(nof_candidates, SRSLTE_SEARCH_SPACE_MAX_NOF_CANDIDATES_NR); + nof_candidates = SRSRAN_MIN(nof_candidates, SRSRAN_SEARCH_SPACE_MAX_NOF_CANDIDATES_NR); for (uint32_t candidate = 0; candidate < nof_candidates; candidate++) { - int ret = srslte_pdcch_nr_get_ncce(coreset, search_space, rnti, aggregation_level, slot_idx, candidate); - if (ret < SRSLTE_SUCCESS) { + int ret = srsran_pdcch_nr_get_ncce(coreset, search_space, rnti, aggregation_level, slot_idx, candidate); + if (ret < SRSRAN_SUCCESS) { return ret; } @@ -113,129 +113,129 @@ int srslte_pdcch_nr_locations_coreset(const srslte_coreset_t* coreset, return nof_candidates; } -int srslte_pdcch_nr_max_candidates_coreset(const srslte_coreset_t* coreset, uint32_t aggregation_level) +int srsran_pdcch_nr_max_candidates_coreset(const srsran_coreset_t* coreset, uint32_t aggregation_level) { if (coreset == NULL) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - uint32_t coreset_bw = srslte_coreset_get_bw(coreset); + uint32_t coreset_bw = srsran_coreset_get_bw(coreset); uint32_t nof_cce = (coreset_bw * coreset->duration) / 6; uint32_t L = 1U << aggregation_level; uint32_t nof_candidates = nof_cce / L; - return SRSLTE_MIN(nof_candidates, SRSLTE_SEARCH_SPACE_MAX_NOF_CANDIDATES_NR); + return SRSRAN_MIN(nof_candidates, SRSRAN_SEARCH_SPACE_MAX_NOF_CANDIDATES_NR); } -static int pdcch_nr_init_common(srslte_pdcch_nr_t* q, const srslte_pdcch_nr_args_t* args) +static int pdcch_nr_init_common(srsran_pdcch_nr_t* q, const srsran_pdcch_nr_args_t* args) { if (q == NULL || args == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } q->meas_time_en = args->measure_time; - q->c = srslte_vec_u8_malloc(SRSLTE_PDCCH_MAX_RE * 2); + q->c = srsran_vec_u8_malloc(SRSRAN_PDCCH_MAX_RE * 2); if (q->c == NULL) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - q->d = srslte_vec_u8_malloc(SRSLTE_PDCCH_MAX_RE * 2); + q->d = srsran_vec_u8_malloc(SRSRAN_PDCCH_MAX_RE * 2); if (q->d == NULL) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - q->f = srslte_vec_u8_malloc(SRSLTE_PDCCH_MAX_RE * 2); + q->f = srsran_vec_u8_malloc(SRSRAN_PDCCH_MAX_RE * 2); if (q->f == NULL) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - q->symbols = srslte_vec_cf_malloc(SRSLTE_PDCCH_MAX_RE); + q->symbols = srsran_vec_cf_malloc(SRSRAN_PDCCH_MAX_RE); if (q->symbols == NULL) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - q->allocated = srslte_vec_u8_malloc(NMAX); + q->allocated = srsran_vec_u8_malloc(NMAX); if (q->allocated == NULL) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_crc_init(&q->crc24c, SRSLTE_LTE_CRC24C, 24) < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (srsran_crc_init(&q->crc24c, SRSRAN_LTE_CRC24C, 24) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } - if (srslte_polar_code_init(&q->code) < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (srsran_polar_code_init(&q->code) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } - srslte_modem_table_lte(&q->modem_table, SRSLTE_MOD_QPSK); + srsran_modem_table_lte(&q->modem_table, SRSRAN_MOD_QPSK); if (args->measure_evm) { - srslte_modem_table_bytes(&q->modem_table); + srsran_modem_table_bytes(&q->modem_table); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_pdcch_nr_init_tx(srslte_pdcch_nr_t* q, const srslte_pdcch_nr_args_t* args) +int srsran_pdcch_nr_init_tx(srsran_pdcch_nr_t* q, const srsran_pdcch_nr_args_t* args) { - if (pdcch_nr_init_common(q, args) < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (pdcch_nr_init_common(q, args) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } q->is_tx = true; - srslte_polar_encoder_type_t encoder_type = - (args->disable_simd) ? SRSLTE_POLAR_ENCODER_PIPELINED : SRSLTE_POLAR_ENCODER_AVX2; + srsran_polar_encoder_type_t encoder_type = + (args->disable_simd) ? SRSRAN_POLAR_ENCODER_PIPELINED : SRSRAN_POLAR_ENCODER_AVX2; - if (srslte_polar_encoder_init(&q->encoder, encoder_type, NMAX_LOG) < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (srsran_polar_encoder_init(&q->encoder, encoder_type, NMAX_LOG) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } - if (srslte_polar_rm_tx_init(&q->rm) < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (srsran_polar_rm_tx_init(&q->rm) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_pdcch_nr_init_rx(srslte_pdcch_nr_t* q, const srslte_pdcch_nr_args_t* args) +int srsran_pdcch_nr_init_rx(srsran_pdcch_nr_t* q, const srsran_pdcch_nr_args_t* args) { - if (pdcch_nr_init_common(q, args) < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (pdcch_nr_init_common(q, args) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } - srslte_polar_decoder_type_t decoder_type = - (args->disable_simd) ? SRSLTE_POLAR_DECODER_SSC_C : SRSLTE_POLAR_DECODER_SSC_C_AVX2; + srsran_polar_decoder_type_t decoder_type = + (args->disable_simd) ? SRSRAN_POLAR_DECODER_SSC_C : SRSRAN_POLAR_DECODER_SSC_C_AVX2; - if (srslte_polar_decoder_init(&q->decoder, decoder_type, NMAX_LOG) < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (srsran_polar_decoder_init(&q->decoder, decoder_type, NMAX_LOG) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } - if (srslte_polar_rm_rx_init_c(&q->rm) < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (srsran_polar_rm_rx_init_c(&q->rm) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } if (args->measure_evm) { - q->evm_buffer = srslte_evm_buffer_alloc(SRSLTE_PDCCH_MAX_RE * 2); + q->evm_buffer = srsran_evm_buffer_alloc(SRSRAN_PDCCH_MAX_RE * 2); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -void srslte_pdcch_nr_free(srslte_pdcch_nr_t* q) +void srsran_pdcch_nr_free(srsran_pdcch_nr_t* q) { if (q == NULL) { return; } - srslte_polar_code_free(&q->code); + srsran_polar_code_free(&q->code); if (q->is_tx) { - srslte_polar_encoder_free(&q->encoder); - srslte_polar_rm_tx_free(&q->rm); + srsran_polar_encoder_free(&q->encoder); + srsran_polar_rm_tx_free(&q->rm); } else { - srslte_polar_decoder_free(&q->decoder); - srslte_polar_rm_rx_free_c(&q->rm); + srsran_polar_decoder_free(&q->decoder); + srsran_polar_rm_rx_free_c(&q->rm); } if (q->c) { @@ -258,21 +258,21 @@ void srslte_pdcch_nr_free(srslte_pdcch_nr_t* q) free(q->symbols); } - srslte_modem_table_free(&q->modem_table); + srsran_modem_table_free(&q->modem_table); if (q->evm_buffer) { - srslte_evm_free(q->evm_buffer); + srsran_evm_free(q->evm_buffer); } - SRSLTE_MEM_ZERO(q, srslte_pdcch_nr_t, 1); + SRSRAN_MEM_ZERO(q, srsran_pdcch_nr_t, 1); } -int srslte_pdcch_nr_set_carrier(srslte_pdcch_nr_t* q, - const srslte_carrier_nr_t* carrier, - const srslte_coreset_t* coreset) +int srsran_pdcch_nr_set_carrier(srsran_pdcch_nr_t* q, + const srsran_carrier_nr_t* carrier, + const srsran_coreset_t* coreset) { if (q == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } if (carrier != NULL) { @@ -283,11 +283,11 @@ int srslte_pdcch_nr_set_carrier(srslte_pdcch_nr_t* q, q->coreset = *coreset; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -static uint32_t pdcch_nr_cp(const srslte_pdcch_nr_t* q, - const srslte_dci_location_t* dci_location, +static uint32_t pdcch_nr_cp(const srsran_pdcch_nr_t* q, + const srsran_dci_location_t* dci_location, cf_t* slot_grid, cf_t* symbols, bool put) @@ -295,8 +295,8 @@ static uint32_t pdcch_nr_cp(const srslte_pdcch_nr_t* q, uint32_t L = 1U << dci_location->L; // Calculate begin and end sub-carrier index for the selected candidate - uint32_t k_begin = (dci_location->ncce * SRSLTE_NRE * 6) / q->coreset.duration; - uint32_t k_end = k_begin + (L * 6 * SRSLTE_NRE) / q->coreset.duration; + uint32_t k_begin = (dci_location->ncce * SRSRAN_NRE * 6) / q->coreset.duration; + uint32_t k_end = k_begin + (L * 6 * SRSRAN_NRE) / q->coreset.duration; uint32_t count = 0; @@ -304,14 +304,14 @@ static uint32_t pdcch_nr_cp(const srslte_pdcch_nr_t* q, for (uint32_t l = 0; l < q->coreset.duration; l++) { // Iterate over frequency resource groups uint32_t k = 0; - for (uint32_t r = 0; r < SRSLTE_CORESET_FREQ_DOMAIN_RES_SIZE; r++) { + for (uint32_t r = 0; r < SRSRAN_CORESET_FREQ_DOMAIN_RES_SIZE; r++) { if (q->coreset.freq_resources[r]) { - for (uint32_t i = r * 6 * SRSLTE_NRE; i < (r + 1) * 6 * SRSLTE_NRE; i++, k++) { + for (uint32_t i = r * 6 * SRSRAN_NRE; i < (r + 1) * 6 * SRSRAN_NRE; i++, k++) { if (k >= k_begin && k < k_end && k % 4 != 1) { if (put) { - slot_grid[q->carrier.nof_prb * SRSLTE_NRE * l + i] = symbols[count++]; + slot_grid[q->carrier.nof_prb * SRSRAN_NRE * l + i] = symbols[count++]; } else { - symbols[count++] = slot_grid[q->carrier.nof_prb * SRSLTE_NRE * l + i]; + symbols[count++] = slot_grid[q->carrier.nof_prb * SRSRAN_NRE * l + i]; } } } @@ -322,21 +322,21 @@ static uint32_t pdcch_nr_cp(const srslte_pdcch_nr_t* q, return count; } -static uint32_t pdcch_nr_c_init(const srslte_pdcch_nr_t* q, const srslte_dci_msg_nr_t* dci_msg) +static uint32_t pdcch_nr_c_init(const srsran_pdcch_nr_t* q, const srsran_dci_msg_nr_t* dci_msg) { - uint32_t n_id = (dci_msg->search_space == srslte_search_space_type_ue && q->coreset.dmrs_scrambling_id_present) + uint32_t n_id = (dci_msg->search_space == srsran_search_space_type_ue && q->coreset.dmrs_scrambling_id_present) ? q->coreset.dmrs_scrambling_id : q->carrier.id; - uint32_t n_rnti = (dci_msg->search_space == srslte_search_space_type_ue && q->coreset.dmrs_scrambling_id_present) + uint32_t n_rnti = (dci_msg->search_space == srsran_search_space_type_ue && q->coreset.dmrs_scrambling_id_present) ? dci_msg->rnti : 0U; return ((n_rnti << 16U) + n_id) & 0x7fffffffU; } -int srslte_pdcch_nr_encode(srslte_pdcch_nr_t* q, const srslte_dci_msg_nr_t* dci_msg, cf_t* slot_symbols) +int srsran_pdcch_nr_encode(srsran_pdcch_nr_t* q, const srsran_dci_msg_nr_t* dci_msg, cf_t* slot_symbols) { if (q == NULL || dci_msg == NULL || slot_symbols == NULL) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } struct timeval t[3]; @@ -346,76 +346,76 @@ int srslte_pdcch_nr_encode(srslte_pdcch_nr_t* q, const srslte_dci_msg_nr_t* dci_ // Calculate... q->K = dci_msg->nof_bits + 24U; // Payload size including CRC - q->M = (1U << dci_msg->location.L) * (SRSLTE_NRE - 3U) * 6U; // Number of RE + q->M = (1U << dci_msg->location.L) * (SRSRAN_NRE - 3U) * 6U; // Number of RE q->E = q->M * 2; // Number of Rate-Matched bits uint32_t cinit = pdcch_nr_c_init(q, dci_msg); // Pseudo-random sequence initiation // Get polar code - if (srslte_polar_code_get(&q->code, q->K, q->E, 9U) < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (srsran_polar_code_get(&q->code, q->K, q->E, 9U) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } PDCCH_INFO_TX("K=%d; E=%d; M=%d; n=%d; cinit=%08x;", q->K, q->E, q->M, q->code.n, cinit); // Set first L bits to ones, c will have an offset of 24 bits uint8_t* c = q->c; - srslte_bit_unpack(UINT32_MAX, &c, 24U); + srsran_bit_unpack(UINT32_MAX, &c, 24U); // Copy DCI message - srslte_vec_u8_copy(c, dci_msg->payload, dci_msg->nof_bits); + srsran_vec_u8_copy(c, dci_msg->payload, dci_msg->nof_bits); // Append CRC - srslte_crc_attach(&q->crc24c, q->c, q->K); + srsran_crc_attach(&q->crc24c, q->c, q->K); - PDCCH_INFO_TX("Append CRC %06x", (uint32_t)srslte_crc_checksum_get(&q->crc24c)); + PDCCH_INFO_TX("Append CRC %06x", (uint32_t)srsran_crc_checksum_get(&q->crc24c)); // Unpack RNTI uint8_t unpacked_rnti[16] = {}; uint8_t* ptr = unpacked_rnti; - srslte_bit_unpack(dci_msg->rnti, &ptr, 16); + srsran_bit_unpack(dci_msg->rnti, &ptr, 16); // Scramble CRC with RNTI - srslte_vec_xor_bbb(unpacked_rnti, &c[q->K - 16], &c[q->K - 16], 16); + srsran_vec_xor_bbb(unpacked_rnti, &c[q->K - 16], &c[q->K - 16], 16); // Interleave - uint8_t c_prime[SRSLTE_POLAR_INTERLEAVER_K_MAX_IL]; - srslte_polar_interleaver_run_u8(c, c_prime, q->K, true); + uint8_t c_prime[SRSRAN_POLAR_INTERLEAVER_K_MAX_IL]; + srsran_polar_interleaver_run_u8(c, c_prime, q->K, true); // Print c and c_prime (after interleaving) - if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_INFO && !handler_registered) { + if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_INFO && !handler_registered) { PDCCH_INFO_TX("c="); - srslte_vec_fprint_hex(stdout, c, q->K); + srsran_vec_fprint_hex(stdout, c, q->K); PDCCH_INFO_TX("c_prime="); - srslte_vec_fprint_hex(stdout, c_prime, q->K); + srsran_vec_fprint_hex(stdout, c_prime, q->K); } // Allocate channel - srslte_polar_chanalloc_tx(c_prime, q->allocated, q->code.N, q->code.K, q->code.nPC, q->code.K_set, q->code.PC_set); + srsran_polar_chanalloc_tx(c_prime, q->allocated, q->code.N, q->code.K, q->code.nPC, q->code.K_set, q->code.PC_set); // Encode bits - if (srslte_polar_encoder_encode(&q->encoder, q->allocated, q->d, q->code.n) < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (srsran_polar_encoder_encode(&q->encoder, q->allocated, q->d, q->code.n) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } // Print d - if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_INFO && !handler_registered) { + if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_INFO && !handler_registered) { PDCCH_INFO_TX("d="); - srslte_vec_fprint_byte(stdout, q->d, q->code.N); + srsran_vec_fprint_byte(stdout, q->d, q->code.N); } // Rate matching - srslte_polar_rm_tx(&q->rm, q->d, q->f, q->code.n, q->E, q->K, PDCCH_NR_POLAR_RM_IBIL); + srsran_polar_rm_tx(&q->rm, q->d, q->f, q->code.n, q->E, q->K, PDCCH_NR_POLAR_RM_IBIL); // Scrambling - srslte_sequence_apply_bit(q->f, q->f, q->E, cinit); + srsran_sequence_apply_bit(q->f, q->f, q->E, cinit); // Modulation - srslte_mod_modulate(&q->modem_table, q->f, q->symbols, q->E); + srsran_mod_modulate(&q->modem_table, q->f, q->symbols, q->E); // Put symbols in grid uint32_t m = pdcch_nr_cp(q, &dci_msg->location, slot_symbols, q->symbols, true); if (q->M != m) { ERROR("Unmatch number of RE (%d != %d)", m, q->M); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (q->meas_time_en) { @@ -424,23 +424,23 @@ int srslte_pdcch_nr_encode(srslte_pdcch_nr_t* q, const srslte_dci_msg_nr_t* dci_ q->meas_time_us = (uint32_t)t[0].tv_usec; } - if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_INFO && !handler_registered) { + if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_INFO && !handler_registered) { char str[128] = {}; - srslte_pdcch_nr_info(q, NULL, str, sizeof(str)); + srsran_pdcch_nr_info(q, NULL, str, sizeof(str)); PDCCH_INFO_TX("%s", str); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_pdcch_nr_decode(srslte_pdcch_nr_t* q, +int srsran_pdcch_nr_decode(srsran_pdcch_nr_t* q, cf_t* slot_symbols, - srslte_dmrs_pdcch_ce_t* ce, - srslte_dci_msg_nr_t* dci_msg, - srslte_pdcch_nr_res_t* res) + srsran_dmrs_pdcch_ce_t* ce, + srsran_dci_msg_nr_t* dci_msg, + srsran_pdcch_nr_res_t* res) { if (q == NULL || dci_msg == NULL || ce == NULL || slot_symbols == NULL || res == NULL) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } struct timeval t[3]; @@ -450,18 +450,18 @@ int srslte_pdcch_nr_decode(srslte_pdcch_nr_t* q, // Calculate... q->K = dci_msg->nof_bits + 24U; // Payload size including CRC - q->M = (1U << dci_msg->location.L) * (SRSLTE_NRE - 3U) * 6U; // Number of RE + q->M = (1U << dci_msg->location.L) * (SRSRAN_NRE - 3U) * 6U; // Number of RE q->E = q->M * 2; // Number of Rate-Matched bits // Check number of estimates is correct if (ce->nof_re != q->M) { ERROR("Invalid number of channel estimates (%d != %d)", q->M, ce->nof_re); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Get polar code - if (srslte_polar_code_get(&q->code, q->K, q->E, 9U) < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (srsran_polar_code_get(&q->code, q->K, q->E, 9U) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } PDCCH_INFO_RX("K=%d; E=%d; M=%d; n=%d;", q->K, q->E, q->M, q->code.n); @@ -469,31 +469,31 @@ int srslte_pdcch_nr_decode(srslte_pdcch_nr_t* q, uint32_t m = pdcch_nr_cp(q, &dci_msg->location, slot_symbols, q->symbols, false); if (q->M != m) { ERROR("Unmatch number of RE (%d != %d)", m, q->M); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Print channel estimates if enabled - if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_INFO && !handler_registered) { + if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_INFO && !handler_registered) { PDCCH_INFO_RX("ce="); - srslte_vec_fprint_c(stdout, ce->ce, q->M); + srsran_vec_fprint_c(stdout, ce->ce, q->M); } // Equalise - srslte_predecoding_single(q->symbols, ce->ce, q->symbols, NULL, q->M, 1.0f, ce->noise_var); + srsran_predecoding_single(q->symbols, ce->ce, q->symbols, NULL, q->M, 1.0f, ce->noise_var); // Print symbols if enabled - if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_INFO && !handler_registered) { + if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_INFO && !handler_registered) { PDCCH_INFO_RX("symbols="); - srslte_vec_fprint_c(stdout, q->symbols, q->M); + srsran_vec_fprint_c(stdout, q->symbols, q->M); } // Demodulation int8_t* llr = (int8_t*)q->f; - srslte_demod_soft_demodulate_b(SRSLTE_MOD_QPSK, q->symbols, llr, q->M); + srsran_demod_soft_demodulate_b(SRSRAN_MOD_QPSK, q->symbols, llr, q->M); // Measure EVM if configured if (q->evm_buffer != NULL) { - res->evm = srslte_evm_run_b(q->evm_buffer, &q->modem_table, q->symbols, llr, q->E); + res->evm = srsran_evm_run_b(q->evm_buffer, &q->modem_table, q->symbols, llr, q->E); } else { res->evm = NAN; } @@ -504,66 +504,66 @@ int srslte_pdcch_nr_decode(srslte_pdcch_nr_t* q, } // Descrambling - srslte_sequence_apply_c(llr, llr, q->E, pdcch_nr_c_init(q, dci_msg)); + srsran_sequence_apply_c(llr, llr, q->E, pdcch_nr_c_init(q, dci_msg)); // Un-rate matching int8_t* d = (int8_t*)q->d; - if (srslte_polar_rm_rx_c(&q->rm, llr, d, q->E, q->code.n, q->K, PDCCH_NR_POLAR_RM_IBIL) < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (srsran_polar_rm_rx_c(&q->rm, llr, d, q->E, q->code.n, q->K, PDCCH_NR_POLAR_RM_IBIL) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } // Print d - if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_INFO && !handler_registered) { + if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_INFO && !handler_registered) { PDCCH_INFO_RX("d="); - srslte_vec_fprint_bs(stdout, d, q->K); + srsran_vec_fprint_bs(stdout, d, q->K); } // Decode - if (srslte_polar_decoder_decode_c(&q->decoder, d, q->allocated, q->code.n, q->code.F_set, q->code.F_set_size) < - SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (srsran_polar_decoder_decode_c(&q->decoder, d, q->allocated, q->code.n, q->code.F_set, q->code.F_set_size) < + SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } // De-allocate channel - uint8_t c_prime[SRSLTE_POLAR_INTERLEAVER_K_MAX_IL]; - srslte_polar_chanalloc_rx(q->allocated, c_prime, q->code.K, q->code.nPC, q->code.K_set, q->code.PC_set); + uint8_t c_prime[SRSRAN_POLAR_INTERLEAVER_K_MAX_IL]; + srsran_polar_chanalloc_rx(q->allocated, c_prime, q->code.K, q->code.nPC, q->code.K_set, q->code.PC_set); // Set first L bits to ones, c will have an offset of 24 bits uint8_t* c = q->c; - srslte_bit_unpack(UINT32_MAX, &c, 24U); + srsran_bit_unpack(UINT32_MAX, &c, 24U); // De-interleave - srslte_polar_interleaver_run_u8(c_prime, c, q->K, false); + srsran_polar_interleaver_run_u8(c_prime, c, q->K, false); // Print c - if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_INFO && !handler_registered) { + if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_INFO && !handler_registered) { PDCCH_INFO_RX("c_prime="); - srslte_vec_fprint_hex(stdout, c_prime, q->K); + srsran_vec_fprint_hex(stdout, c_prime, q->K); PDCCH_INFO_RX("c="); - srslte_vec_fprint_hex(stdout, c, q->K); + srsran_vec_fprint_hex(stdout, c, q->K); } // Unpack RNTI uint8_t unpacked_rnti[16] = {}; uint8_t* ptr = unpacked_rnti; - srslte_bit_unpack(dci_msg->rnti, &ptr, 16); + srsran_bit_unpack(dci_msg->rnti, &ptr, 16); // De-Scramble CRC with RNTI - srslte_vec_xor_bbb(unpacked_rnti, &c[q->K - 16], &c[q->K - 16], 16); + srsran_vec_xor_bbb(unpacked_rnti, &c[q->K - 16], &c[q->K - 16], 16); // Check CRC ptr = &c[q->K - 24]; - uint32_t checksum1 = srslte_crc_checksum(&q->crc24c, q->c, q->K); - uint32_t checksum2 = srslte_bit_pack(&ptr, 24); + uint32_t checksum1 = srsran_crc_checksum(&q->crc24c, q->c, q->K); + uint32_t checksum2 = srsran_bit_pack(&ptr, 24); res->crc = checksum1 == checksum2; - if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_INFO && !handler_registered) { + if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_INFO && !handler_registered) { PDCCH_INFO_RX("CRC={%06x, %06x}; msg=", checksum1, checksum2); - srslte_vec_fprint_hex(stdout, c, dci_msg->nof_bits); + srsran_vec_fprint_hex(stdout, c, dci_msg->nof_bits); } // Copy DCI message - srslte_vec_u8_copy(dci_msg->payload, c, dci_msg->nof_bits); + srsran_vec_u8_copy(dci_msg->payload, c, dci_msg->nof_bits); if (q->meas_time_en) { gettimeofday(&t[2], NULL); @@ -571,16 +571,16 @@ int srslte_pdcch_nr_decode(srslte_pdcch_nr_t* q, q->meas_time_us = (uint32_t)t[0].tv_usec; } - if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_INFO && !handler_registered) { + if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_INFO && !handler_registered) { char str[128] = {}; - srslte_pdcch_nr_info(q, res, str, sizeof(str)); + srsran_pdcch_nr_info(q, res, str, sizeof(str)); PDCCH_INFO_RX("%s", str); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -uint32_t srslte_pdcch_nr_info(const srslte_pdcch_nr_t* q, const srslte_pdcch_nr_res_t* res, char* str, uint32_t str_len) +uint32_t srsran_pdcch_nr_info(const srsran_pdcch_nr_t* q, const srsran_pdcch_nr_res_t* res, char* str, uint32_t str_len) { int len = 0; @@ -588,18 +588,18 @@ uint32_t srslte_pdcch_nr_info(const srslte_pdcch_nr_t* q, const srslte_pdcch_nr_ return len; } - len = srslte_print_check(str, str_len, len, "K=%d,E=%d", q->K, q->E); + len = srsran_print_check(str, str_len, len, "K=%d,E=%d", q->K, q->E); if (res != NULL) { - len = srslte_print_check(str, str_len, len, ",crc=%s", res->crc ? "OK" : "KO"); + len = srsran_print_check(str, str_len, len, ",crc=%s", res->crc ? "OK" : "KO"); if (q->evm_buffer && res) { - len = srslte_print_check(str, str_len, len, ",evm=%.2f", res->evm); + len = srsran_print_check(str, str_len, len, ",evm=%.2f", res->evm); } } if (q->meas_time_en) { - len = srslte_print_check(str, str_len, len, ",t=%d us", q->meas_time_us); + len = srsran_print_check(str, str_len, len, ",t=%d us", q->meas_time_us); } return len; diff --git a/lib/src/phy/phch/pdsch.c b/lib/src/phy/phch/pdsch.c index c92b6f4c1..fcfb32b02 100644 --- a/lib/src/phy/phch/pdsch.c +++ b/lib/src/phy/phch/pdsch.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,7 +10,7 @@ * */ -#include "srslte/srslte.h" +#include "srsran/srsran.h" #include #include #include @@ -21,26 +21,26 @@ #include #include "prb_dl.h" -#include "srslte/phy/phch/pdsch.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/phch/pdsch.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" #ifdef LV_HAVE_SSE #include #endif /* LV_HAVE_SSE */ -#define MAX_PDSCH_RE(cp) (2 * SRSLTE_CP_NSYMB(cp) * 12) +#define MAX_PDSCH_RE(cp) (2 * SRSRAN_CP_NSYMB(cp) * 12) /* 3GPP 36.213 Table 5.2-1: The cell-specific ratio rho_B / rho_A for 1, 2, or 4 cell specific antenna ports */ const static float pdsch_cfg_cell_specific_ratio_table[2][4] = { /* One antenna port */ {1.0f / 1.0f, 4.0f / 5.0f, 3.0f / 5.0f, 2.0f / 5.0f}, /* Two or more antenna port */ {5.0f / 4.0f, 1.0f / 1.0f, 3.0f / 4.0f, 1.0f / 2.0f}}; -const static srslte_mod_t modulations[5] = {SRSLTE_MOD_BPSK, - SRSLTE_MOD_QPSK, - SRSLTE_MOD_16QAM, - SRSLTE_MOD_64QAM, - SRSLTE_MOD_256QAM}; +const static srsran_mod_t modulations[5] = {SRSRAN_MOD_BPSK, + SRSRAN_MOD_QPSK, + SRSRAN_MOD_16QAM, + SRSRAN_MOD_64QAM, + SRSRAN_MOD_256QAM}; typedef struct { /* Thread identifier: they must set before thread creation */ @@ -50,12 +50,12 @@ typedef struct { bool* ack; /* Configuration Encoder/Decoder: they must be set before posting start semaphore */ - srslte_dl_sf_cfg_t* sf; - srslte_pdsch_cfg_t* cfg; - srslte_sch_t dl_sch; + srsran_dl_sf_cfg_t* sf; + srsran_pdsch_cfg_t* cfg; + srsran_sch_t dl_sch; /* Encoder/Decoder data pointers: they must be set before posting start semaphore */ - srslte_pdsch_res_t* data; + srsran_pdsch_res_t* data; /* Execution status */ int ret_status; @@ -67,12 +67,12 @@ typedef struct { /* Thread flags */ bool started; bool quit; -} srslte_pdsch_coworker_t; +} srsran_pdsch_coworker_t; -static void* srslte_pdsch_decode_thread(void* arg); +static void* srsran_pdsch_decode_thread(void* arg); -static inline bool pdsch_cp_skip_symbol(const srslte_cell_t* cell, - const srslte_pdsch_grant_t* grant, +static inline bool pdsch_cp_skip_symbol(const srsran_cell_t* cell, + const srsran_pdsch_grant_t* grant, uint32_t sf_idx, uint32_t s, uint32_t l, @@ -80,7 +80,7 @@ static inline bool pdsch_cp_skip_symbol(const srslte_cell_t* cell, { // Skip center block signals if ((n >= cell->nof_prb / 2 - 3 && n < cell->nof_prb / 2 + 3 + (cell->nof_prb % 2))) { - if (cell->frame_type == SRSLTE_FDD) { + if (cell->frame_type == SRSRAN_FDD) { // FDD PSS/SSS if (s == 0 && (sf_idx == 0 || sf_idx == 5) && (l >= grant->nof_symb_slot[s] - 2)) { return true; @@ -104,7 +104,7 @@ static inline bool pdsch_cp_skip_symbol(const srslte_cell_t* cell, return false; } -static inline uint32_t pdsch_cp_crs_offset(const srslte_cell_t* cell, uint32_t l, bool has_crs) +static inline uint32_t pdsch_cp_crs_offset(const srsran_cell_t* cell, uint32_t l, bool has_crs) { // No CRS, return 0 if (!has_crs) { @@ -124,10 +124,10 @@ static inline uint32_t pdsch_cp_crs_offset(const srslte_cell_t* cell, uint32_t l return cell->id % 3; } -static int srslte_pdsch_cp(const srslte_pdsch_t* q, +static int srsran_pdsch_cp(const srsran_pdsch_t* q, cf_t* input, cf_t* output, - const srslte_pdsch_grant_t* grant, + const srsran_pdsch_grant_t* grant, uint32_t lstart_grant, uint32_t sf_idx, bool put) @@ -137,13 +137,13 @@ static int srslte_pdsch_cp(const srslte_pdsch_t* q, uint32_t nof_refs = (q->cell.nof_ports == 1) ? 2 : 4; // Iterate over slots - for (uint32_t s = 0; s < SRSLTE_NOF_SLOTS_PER_SF; s++) { + for (uint32_t s = 0; s < SRSRAN_NOF_SLOTS_PER_SF; s++) { // Skip PDCCH symbols uint32_t lstart = (s == 0) ? lstart_grant : 0; // Iterate over symbols for (uint32_t l = lstart; l < grant->nof_symb_slot[s]; l++) { - bool has_crs = SRSLTE_SYMBOL_HAS_REF(l, q->cell.cp, q->cell.nof_ports); + bool has_crs = SRSRAN_SYMBOL_HAS_REF(l, q->cell.cp, q->cell.nof_ports); uint32_t crs_offset = pdsch_cp_crs_offset(&q->cell, l, has_crs); // Grid symbol @@ -157,9 +157,9 @@ static int srslte_pdsch_cp(const srslte_pdsch_t* q, // Get grid pointer if (put) { - out_ptr = &output[(lp * q->cell.nof_prb + n) * SRSLTE_NRE]; + out_ptr = &output[(lp * q->cell.nof_prb + n) * SRSRAN_NRE]; } else { - in_ptr = &input[(lp * q->cell.nof_prb + n) * SRSLTE_NRE]; + in_ptr = &input[(lp * q->cell.nof_prb + n) * SRSRAN_NRE]; } // This is a symbol in a normal PRB with or without references @@ -183,9 +183,9 @@ static int srslte_pdsch_cp(const srslte_pdsch_t* q, // Upper sync block half RB // Skip half RB on the grid if (put) { - out_ptr += SRSLTE_NRE / 2; + out_ptr += SRSRAN_NRE / 2; } else { - in_ptr += SRSLTE_NRE / 2; + in_ptr += SRSRAN_NRE / 2; } if (has_crs) { @@ -217,14 +217,14 @@ static int srslte_pdsch_cp(const srslte_pdsch_t* q, * * 36.211 10.3 section 6.3.5 */ -int srslte_pdsch_put(srslte_pdsch_t* q, +int srsran_pdsch_put(srsran_pdsch_t* q, cf_t* symbols, cf_t* sf_symbols, - srslte_pdsch_grant_t* grant, + srsran_pdsch_grant_t* grant, uint32_t lstart, uint32_t subframe) { - return srslte_pdsch_cp(q, symbols, sf_symbols, grant, lstart, subframe, true); + return srsran_pdsch_cp(q, symbols, sf_symbols, grant, lstart, subframe, true); } /** @@ -234,24 +234,24 @@ int srslte_pdsch_put(srslte_pdsch_t* q, * * 36.211 10.3 section 6.3.5 */ -int srslte_pdsch_get(srslte_pdsch_t* q, +int srsran_pdsch_get(srsran_pdsch_t* q, cf_t* sf_symbols, cf_t* symbols, - srslte_pdsch_grant_t* grant, + srsran_pdsch_grant_t* grant, uint32_t lstart, uint32_t subframe) { - return srslte_pdsch_cp(q, sf_symbols, symbols, grant, lstart, subframe, false); + return srsran_pdsch_cp(q, sf_symbols, symbols, grant, lstart, subframe, false); } /** Initializes the PDSCH transmitter and receiver */ -static int pdsch_init(srslte_pdsch_t* q, uint32_t max_prb, bool is_ue, uint32_t nof_antennas) +static int pdsch_init(srsran_pdsch_t* q, uint32_t max_prb, bool is_ue, uint32_t nof_antennas) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL) { - bzero(q, sizeof(srslte_pdsch_t)); - ret = SRSLTE_ERROR; + bzero(q, sizeof(srsran_pdsch_t)); + ret = SRSRAN_ERROR; q->max_re = max_prb * MAX_PDSCH_RE(q->cell.cp); q->is_ue = is_ue; @@ -259,33 +259,33 @@ static int pdsch_init(srslte_pdsch_t* q, uint32_t max_prb, bool is_ue, uint32_t INFO("Init PDSCH: %d PRBs, max_symbols: %d", max_prb, q->max_re); - for (int i = 0; i < SRSLTE_MOD_NITEMS; i++) { - if (srslte_modem_table_lte(&q->mod[i], modulations[i])) { + for (int i = 0; i < SRSRAN_MOD_NITEMS; i++) { + if (srsran_modem_table_lte(&q->mod[i], modulations[i])) { goto clean; } - srslte_modem_table_bytes(&q->mod[i]); + srsran_modem_table_bytes(&q->mod[i]); } - if (srslte_sch_init(&q->dl_sch)) { + if (srsran_sch_init(&q->dl_sch)) { ERROR("Initiating DL SCH"); goto clean; } - for (int i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { + for (int i = 0; i < SRSRAN_MAX_CODEWORDS; i++) { // Allocate int16_t for reception (LLRs) - q->e[i] = srslte_vec_i16_malloc(q->max_re * srslte_mod_bits_x_symbol(SRSLTE_MOD_256QAM)); + q->e[i] = srsran_vec_i16_malloc(q->max_re * srsran_mod_bits_x_symbol(SRSRAN_MOD_256QAM)); if (!q->e[i]) { goto clean; } - q->d[i] = srslte_vec_cf_malloc(q->max_re); + q->d[i] = srsran_vec_cf_malloc(q->max_re); if (!q->d[i]) { goto clean; } // If it is the UE, allocate EVM buffer, for only minimum PRB if (is_ue) { - q->evm_buffer[i] = srslte_evm_buffer_alloc(srslte_ra_tbs_from_idx(SRSLTE_RA_NOF_TBS_IDX - 1, 6)); + q->evm_buffer[i] = srsran_evm_buffer_alloc(srsran_ra_tbs_from_idx(SRSRAN_RA_NOF_TBS_IDX - 1, 6)); if (!q->evm_buffer[i]) { ERROR("Allocating EVM buffer"); goto clean; @@ -293,18 +293,18 @@ static int pdsch_init(srslte_pdsch_t* q, uint32_t max_prb, bool is_ue, uint32_t } } - for (int i = 0; i < SRSLTE_MAX_PORTS; i++) { - q->x[i] = srslte_vec_cf_malloc(q->max_re); + for (int i = 0; i < SRSRAN_MAX_PORTS; i++) { + q->x[i] = srsran_vec_cf_malloc(q->max_re); if (!q->x[i]) { goto clean; } - q->symbols[i] = srslte_vec_cf_malloc(q->max_re); + q->symbols[i] = srsran_vec_cf_malloc(q->max_re); if (!q->symbols[i]) { goto clean; } if (q->is_ue) { - for (int j = 0; j < SRSLTE_MAX_PORTS; j++) { - q->ce[i][j] = srslte_vec_cf_malloc(q->max_re); + for (int j = 0; j < SRSRAN_MAX_PORTS; j++) { + q->ce[i][j] = srsran_vec_cf_malloc(q->max_re); if (!q->ce[i][j]) { goto clean; } @@ -312,38 +312,38 @@ static int pdsch_init(srslte_pdsch_t* q, uint32_t max_prb, bool is_ue, uint32_t } } - for (int i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { + for (int i = 0; i < SRSRAN_MAX_CODEWORDS; i++) { if (!q->csi[i]) { - q->csi[i] = srslte_vec_f_malloc(q->max_re * 2); + q->csi[i] = srsran_vec_f_malloc(q->max_re * 2); if (!q->csi[i]) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } clean: - if (ret == SRSLTE_ERROR) { - srslte_pdsch_free(q); + if (ret == SRSRAN_ERROR) { + srsran_pdsch_free(q); } return ret; } -int srslte_pdsch_init_ue(srslte_pdsch_t* q, uint32_t max_prb, uint32_t nof_antennas) +int srsran_pdsch_init_ue(srsran_pdsch_t* q, uint32_t max_prb, uint32_t nof_antennas) { return pdsch_init(q, max_prb, true, nof_antennas); } -int srslte_pdsch_init_enb(srslte_pdsch_t* q, uint32_t max_prb) +int srsran_pdsch_init_enb(srsran_pdsch_t* q, uint32_t max_prb) { return pdsch_init(q, max_prb, false, 0); } -static void srslte_pdsch_disable_coworker(srslte_pdsch_t* q) +static void srsran_pdsch_disable_coworker(srsran_pdsch_t* q) { - srslte_pdsch_coworker_t* h = (srslte_pdsch_coworker_t*)q->coworker_ptr; + srsran_pdsch_coworker_t* h = (srsran_pdsch_coworker_t*)q->coworker_ptr; if (h) { /* Stop threads */ h->quit = true; @@ -352,7 +352,7 @@ static void srslte_pdsch_disable_coworker(srslte_pdsch_t* q) pthread_join(h->pthread, NULL); pthread_detach(h->pthread); - srslte_sch_free(&h->dl_sch); + srsran_sch_free(&h->dl_sch); free(h); @@ -360,51 +360,51 @@ static void srslte_pdsch_disable_coworker(srslte_pdsch_t* q) } } -int srslte_pdsch_enable_coworker(srslte_pdsch_t* q) +int srsran_pdsch_enable_coworker(srsran_pdsch_t* q) { - int ret = SRSLTE_SUCCESS; + int ret = SRSRAN_SUCCESS; if (!q->coworker_ptr) { - srslte_pdsch_coworker_t* h = calloc(sizeof(srslte_pdsch_coworker_t), 1); + srsran_pdsch_coworker_t* h = calloc(sizeof(srsran_pdsch_coworker_t), 1); if (!h) { ERROR("Allocating coworker"); - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; goto clean; } q->coworker_ptr = h; - if (srslte_sch_init(&h->dl_sch)) { + if (srsran_sch_init(&h->dl_sch)) { ERROR("Initiating DL SCH"); - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; goto clean; } if (sem_init(&h->start, 0, 0)) { ERROR("Creating semaphore"); - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; goto clean; } if (sem_init(&h->finish, 0, 0)) { ERROR("Creating semaphore"); - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; goto clean; } - pthread_create(&h->pthread, NULL, srslte_pdsch_decode_thread, (void*)h); + pthread_create(&h->pthread, NULL, srsran_pdsch_decode_thread, (void*)h); } clean: if (ret) { - srslte_pdsch_disable_coworker(q); + srsran_pdsch_disable_coworker(q); } return ret; } -void srslte_pdsch_free(srslte_pdsch_t* q) +void srsran_pdsch_free(srsran_pdsch_t* q) { - srslte_pdsch_disable_coworker(q); + srsran_pdsch_disable_coworker(q); - for (int i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { + for (int i = 0; i < SRSRAN_MAX_CODEWORDS; i++) { if (q->e[i]) { free(q->e[i]); } @@ -418,14 +418,14 @@ void srslte_pdsch_free(srslte_pdsch_t* q) } if (q->evm_buffer[i]) { - srslte_evm_free(q->evm_buffer[i]); + srsran_evm_free(q->evm_buffer[i]); } } /* Free sch objects */ - srslte_sch_free(&q->dl_sch); + srsran_sch_free(&q->dl_sch); - for (int i = 0; i < SRSLTE_MAX_PORTS; i++) { + for (int i = 0; i < SRSRAN_MAX_PORTS; i++) { if (q->x[i]) { free(q->x[i]); } @@ -433,7 +433,7 @@ void srslte_pdsch_free(srslte_pdsch_t* q) free(q->symbols[i]); } if (q->is_ue) { - for (int j = 0; j < SRSLTE_MAX_PORTS; j++) { + for (int j = 0; j < SRSRAN_MAX_PORTS; j++) { if (q->ce[i][j]) { free(q->ce[i][j]); } @@ -441,25 +441,25 @@ void srslte_pdsch_free(srslte_pdsch_t* q) } } - for (int i = 0; i < SRSLTE_MOD_NITEMS; i++) { - srslte_modem_table_free(&q->mod[i]); + for (int i = 0; i < SRSRAN_MOD_NITEMS; i++) { + srsran_modem_table_free(&q->mod[i]); } - bzero(q, sizeof(srslte_pdsch_t)); + bzero(q, sizeof(srsran_pdsch_t)); } -int srslte_pdsch_set_cell(srslte_pdsch_t* q, srslte_cell_t cell) +int srsran_pdsch_set_cell(srsran_pdsch_t* q, srsran_cell_t cell) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; - if (q != NULL && srslte_cell_isvalid(&cell)) { + if (q != NULL && srsran_cell_isvalid(&cell)) { q->cell = cell; q->max_re = q->cell.nof_prb * MAX_PDSCH_RE(q->cell.cp); // Resize EVM buffer, only for UE if (q->is_ue) { - for (int i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { - srslte_evm_buffer_resize(q->evm_buffer[i], srslte_ra_tbs_from_idx(SRSLTE_RA_NOF_TBS_IDX - 1, cell.nof_prb)); + for (int i = 0; i < SRSRAN_MAX_CODEWORDS; i++) { + srsran_evm_buffer_resize(q->evm_buffer[i], srsran_ra_tbs_from_idx(SRSRAN_RA_NOF_TBS_IDX - 1, cell.nof_prb)); } } @@ -469,18 +469,18 @@ int srslte_pdsch_set_cell(srslte_pdsch_t* q, srslte_cell_t cell) q->cell.nof_prb, q->max_re); - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } -static float apply_power_allocation(srslte_pdsch_t* q, srslte_pdsch_cfg_t* cfg, cf_t* sf_symbols_m[SRSLTE_MAX_PORTS]) +static float apply_power_allocation(srsran_pdsch_t* q, srsran_pdsch_cfg_t* cfg, cf_t* sf_symbols_m[SRSRAN_MAX_PORTS]) { uint32_t nof_symbols_slot = cfg->grant.nof_symb_slot[0]; - uint32_t nof_re_symbol = SRSLTE_NRE * q->cell.nof_prb; + uint32_t nof_re_symbol = SRSRAN_NRE * q->cell.nof_prb; /* Set power allocation according to 3GPP 36.213 clause 5.2 Downlink power allocation */ - float rho_a = srslte_convert_dB_to_amplitude(cfg->p_a) * ((q->cell.nof_ports == 1) ? 1.0f : M_SQRT2); + float rho_a = srsran_convert_dB_to_amplitude(cfg->p_a) * ((q->cell.nof_ports == 1) ? 1.0f : M_SQRT2); uint32_t idx0 = (q->cell.nof_ports == 1) ? 0 : 1; float cell_specific_ratio = pdsch_cfg_cell_specific_ratio_table[idx0][cfg->p_b]; @@ -493,17 +493,17 @@ static float apply_power_allocation(srslte_pdsch_t* q, srslte_pdsch_cfg_t* cfg, for (uint32_t j = 0; j < 2; j++) { cf_t* ptr; ptr = sf_symbols_m[i] + nof_re_symbol * (j * nof_symbols_slot + 0); - srslte_vec_sc_prod_cfc(ptr, scaling, ptr, nof_re_symbol); - if (q->cell.cp == SRSLTE_CP_NORM) { + srsran_vec_sc_prod_cfc(ptr, scaling, ptr, nof_re_symbol); + if (q->cell.cp == SRSRAN_CP_NORM) { ptr = sf_symbols_m[i] + nof_re_symbol * (j * nof_symbols_slot + 4); - srslte_vec_sc_prod_cfc(ptr, scaling, ptr, nof_re_symbol); + srsran_vec_sc_prod_cfc(ptr, scaling, ptr, nof_re_symbol); } else { ptr = sf_symbols_m[i] + nof_re_symbol * (j * nof_symbols_slot + 3); - srslte_vec_sc_prod_cfc(ptr, scaling, ptr, nof_re_symbol); + srsran_vec_sc_prod_cfc(ptr, scaling, ptr, nof_re_symbol); } if (q->cell.nof_ports == 4) { ptr = sf_symbols_m[i] + nof_re_symbol * (j * nof_symbols_slot + 1); - srslte_vec_sc_prod_cfc(ptr, scaling, ptr, nof_re_symbol); + srsran_vec_sc_prod_cfc(ptr, scaling, ptr, nof_re_symbol); } } } @@ -511,30 +511,30 @@ static float apply_power_allocation(srslte_pdsch_t* q, srslte_pdsch_cfg_t* cfg, return rho_a; } -static void csi_correction(srslte_pdsch_t* q, srslte_pdsch_cfg_t* cfg, uint32_t codeword_idx, uint32_t tb_idx, void* e) +static void csi_correction(srsran_pdsch_t* q, srsran_pdsch_cfg_t* cfg, uint32_t codeword_idx, uint32_t tb_idx, void* e) { uint32_t qm = 0; switch (cfg->grant.tb[tb_idx].mod) { - case SRSLTE_MOD_BPSK: + case SRSRAN_MOD_BPSK: qm = 1; break; - case SRSLTE_MOD_QPSK: + case SRSRAN_MOD_QPSK: qm = 2; break; - case SRSLTE_MOD_16QAM: + case SRSRAN_MOD_16QAM: qm = 4; break; - case SRSLTE_MOD_64QAM: + case SRSRAN_MOD_64QAM: qm = 6; break; - case SRSLTE_MOD_256QAM: + case SRSRAN_MOD_256QAM: qm = 8; break; default: ERROR("No modulation"); } - const uint32_t csi_max_idx = srslte_vec_max_fi(q->csi[codeword_idx], cfg->grant.tb[tb_idx].nof_bits / qm); + const uint32_t csi_max_idx = srsran_vec_max_fi(q->csi[codeword_idx], cfg->grant.tb[tb_idx].nof_bits / qm); float csi_max = 1.0f; if (csi_max_idx < cfg->grant.tb[tb_idx].nof_bits / qm) { csi_max = q->csi[codeword_idx][csi_max_idx]; @@ -558,7 +558,7 @@ static void csi_correction(srslte_pdsch_t* q, srslte_pdsch_cfg_t* cfg, uint32_t __m64* _e = (__m64*)e; switch (cfg->grant.tb[tb_idx].mod) { - case SRSLTE_MOD_QPSK: + case SRSRAN_MOD_QPSK: for (; i < cfg->grant.tb[tb_idx].nof_bits - 3; i += 4) { __m128 _csi1 = _mm_set1_ps(*(csi_v++)); __m128 _csi2 = _mm_set1_ps(*(csi_v++)); @@ -570,7 +570,7 @@ static void csi_correction(srslte_pdsch_t* q, srslte_pdsch_cfg_t* cfg, uint32_t _e += 1; } break; - case SRSLTE_MOD_16QAM: + case SRSRAN_MOD_16QAM: for (; i < cfg->grant.tb[tb_idx].nof_bits - 3; i += 4) { __m128 _csi = _mm_set1_ps(*(csi_v++)); @@ -580,7 +580,7 @@ static void csi_correction(srslte_pdsch_t* q, srslte_pdsch_cfg_t* cfg, uint32_t _e += 1; } break; - case SRSLTE_MOD_64QAM: + case SRSRAN_MOD_64QAM: for (; i < cfg->grant.tb[tb_idx].nof_bits - 11; i += 12) { __m128 _csi1 = _mm_set1_ps(*(csi_v++)); __m128 _csi3 = _mm_set1_ps(*(csi_v++)); @@ -595,9 +595,9 @@ static void csi_correction(srslte_pdsch_t* q, srslte_pdsch_cfg_t* cfg, uint32_t _e += 3; } break; - case SRSLTE_MOD_BPSK: + case SRSRAN_MOD_BPSK: break; - case SRSLTE_MOD_256QAM: + case SRSRAN_MOD_256QAM: for (; i < cfg->grant.tb[tb_idx].nof_bits - 7; i += 8) { __m128 _csi = _mm_set1_ps(*(csi_v++)); @@ -608,7 +608,7 @@ static void csi_correction(srslte_pdsch_t* q, srslte_pdsch_cfg_t* cfg, uint32_t _e += 2; } break; - case SRSLTE_MOD_NITEMS: + case SRSRAN_MOD_NITEMS: default:; // Do nothing } @@ -624,12 +624,12 @@ static void csi_correction(srslte_pdsch_t* q, srslte_pdsch_cfg_t* cfg, uint32_t } } -static void pdsch_decode_debug(srslte_pdsch_t* q, - srslte_pdsch_cfg_t* cfg, - cf_t* sf_symbols[SRSLTE_MAX_PORTS], - cf_t* ce[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS]) +static void pdsch_decode_debug(srsran_pdsch_t* q, + srsran_pdsch_cfg_t* cfg, + cf_t* sf_symbols[SRSRAN_MAX_PORTS], + cf_t* ce[SRSRAN_MAX_PORTS][SRSRAN_MAX_PORTS]) { - if (SRSLTE_VERBOSE_ISDEBUG()) { + if (SRSRAN_VERBOSE_ISDEBUG()) { char filename[FILENAME_MAX]; for (int j = 0; j < q->nof_rx_antennas; j++) { if (snprintf(filename, FILENAME_MAX, "subframe_p%d.dat", j) < 0) { @@ -637,7 +637,7 @@ static void pdsch_decode_debug(srslte_pdsch_t* q, break; } DEBUG("SAVED FILE %s: received subframe symbols", filename); - srslte_vec_save_file(filename, sf_symbols[j], SRSLTE_NOF_RE(q->cell) * sizeof(cf_t)); + srsran_vec_save_file(filename, sf_symbols[j], SRSRAN_NOF_RE(q->cell) * sizeof(cf_t)); for (int i = 0; i < q->cell.nof_ports; i++) { if (snprintf(filename, FILENAME_MAX, "hest_%d%d.dat", i, j) < 0) { @@ -645,7 +645,7 @@ static void pdsch_decode_debug(srslte_pdsch_t* q, break; } DEBUG("SAVED FILE %s: channel estimates for Tx %d and Rx %d", filename, j, i); - srslte_vec_save_file(filename, ce[i][j], SRSLTE_NOF_RE(q->cell) * sizeof(cf_t)); + srsran_vec_save_file(filename, ce[i][j], SRSRAN_NOF_RE(q->cell) * sizeof(cf_t)); } } for (int i = 0; i < cfg->grant.nof_layers; i++) { @@ -654,40 +654,40 @@ static void pdsch_decode_debug(srslte_pdsch_t* q, break; } DEBUG("SAVED FILE %s: symbols after equalization", filename); - srslte_vec_save_file(filename, q->d[i], cfg->grant.nof_re * sizeof(cf_t)); + srsran_vec_save_file(filename, q->d[i], cfg->grant.nof_re * sizeof(cf_t)); if (snprintf(filename, FILENAME_MAX, "llr_%d.dat", i) < 0) { ERROR("Generating file name"); break; } DEBUG("SAVED FILE %s: LLR estimates after demodulation and descrambling", filename); - srslte_vec_save_file(filename, q->e[i], cfg->grant.tb[0].nof_bits * sizeof(int16_t)); + srsran_vec_save_file(filename, q->e[i], cfg->grant.tb[0].nof_bits * sizeof(int16_t)); } } } -static int srslte_pdsch_codeword_decode(srslte_pdsch_t* q, - srslte_dl_sf_cfg_t* sf, - srslte_pdsch_cfg_t* cfg, - srslte_sch_t* dl_sch, - srslte_pdsch_res_t* data, +static int srsran_pdsch_codeword_decode(srsran_pdsch_t* q, + srsran_dl_sf_cfg_t* sf, + srsran_pdsch_cfg_t* cfg, + srsran_sch_t* dl_sch, + srsran_pdsch_res_t* data, uint32_t tb_idx, bool* ack) { - srslte_ra_tb_t* mcs = &cfg->grant.tb[tb_idx]; + srsran_ra_tb_t* mcs = &cfg->grant.tb[tb_idx]; uint32_t rv = mcs->rv; uint32_t codeword_idx = mcs->cw_idx; uint32_t nof_layers = cfg->grant.nof_layers; - srslte_softbuffer_rx_t* softbuffer = cfg->softbuffers.rx[tb_idx]; + srsran_softbuffer_rx_t* softbuffer = cfg->softbuffers.rx[tb_idx]; - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (softbuffer && data && ack && cfg->grant.tb[tb_idx].nof_bits && cfg->grant.nof_re) { INFO("Decoding PDSCH SF: %d (CW%d -> TB%d), Mod %s, NofBits: %d, NofSymbols: %d, NofBitsE: %d, rv_idx: %d", sf->tti % 10, codeword_idx, tb_idx, - srslte_mod_string(mcs->mod), + srsran_mod_string(mcs->mod), mcs->tbs, cfg->grant.nof_re, cfg->grant.tb[tb_idx].nof_bits, @@ -698,19 +698,19 @@ static int srslte_pdsch_codeword_decode(srslte_pdsch_t* q, * thus we don't need tot set it in the LLRs normalization */ if (q->llr_is_8bit) { - srslte_demod_soft_demodulate_b(mcs->mod, q->d[codeword_idx], q->e[codeword_idx], cfg->grant.nof_re); + srsran_demod_soft_demodulate_b(mcs->mod, q->d[codeword_idx], q->e[codeword_idx], cfg->grant.nof_re); } else { - srslte_demod_soft_demodulate_s(mcs->mod, q->d[codeword_idx], q->e[codeword_idx], cfg->grant.nof_re); + srsran_demod_soft_demodulate_s(mcs->mod, q->d[codeword_idx], q->e[codeword_idx], cfg->grant.nof_re); } if (cfg->meas_evm_en && q->evm_buffer[codeword_idx]) { if (q->llr_is_8bit) { - data[tb_idx].evm = srslte_evm_run_b(q->evm_buffer[codeword_idx], + data[tb_idx].evm = srsran_evm_run_b(q->evm_buffer[codeword_idx], &q->mod[mcs->mod], q->d[codeword_idx], q->e[codeword_idx], cfg->grant.tb[tb_idx].nof_bits); } else { - data[tb_idx].evm = srslte_evm_run_s(q->evm_buffer[codeword_idx], + data[tb_idx].evm = srsran_evm_run_s(q->evm_buffer[codeword_idx], &q->mod[mcs->mod], q->d[codeword_idx], q->e[codeword_idx], @@ -722,19 +722,19 @@ static int srslte_pdsch_codeword_decode(srslte_pdsch_t* q, /* Bit scrambling */ if (q->llr_is_8bit) { - srslte_sequence_pdsch_apply_c(q->e[codeword_idx], + srsran_sequence_pdsch_apply_c(q->e[codeword_idx], q->e[codeword_idx], cfg->rnti, codeword_idx, - 2 * (sf->tti % SRSLTE_NOF_SF_X_FRAME), + 2 * (sf->tti % SRSRAN_NOF_SF_X_FRAME), q->cell.id, cfg->grant.tb[tb_idx].nof_bits); } else { - srslte_sequence_pdsch_apply_s(q->e[codeword_idx], + srsran_sequence_pdsch_apply_s(q->e[codeword_idx], q->e[codeword_idx], cfg->rnti, codeword_idx, - 2 * (sf->tti % SRSLTE_NOF_SF_X_FRAME), + 2 * (sf->tti % SRSRAN_NOF_SF_X_FRAME), q->cell.id, cfg->grant.tb[tb_idx].nof_bits); } @@ -744,16 +744,16 @@ static int srslte_pdsch_codeword_decode(srslte_pdsch_t* q, } /* Return */ - ret = srslte_dlsch_decode2(dl_sch, cfg, q->e[codeword_idx], data[tb_idx].payload, tb_idx, nof_layers); + ret = srsran_dlsch_decode2(dl_sch, cfg, q->e[codeword_idx], data[tb_idx].payload, tb_idx, nof_layers); - if (ret == SRSLTE_SUCCESS) { + if (ret == SRSRAN_SUCCESS) { *ack = true; - } else if (ret == SRSLTE_ERROR) { + } else if (ret == SRSRAN_ERROR) { *ack = false; - ret = SRSLTE_SUCCESS; - } else if (ret == SRSLTE_ERROR_INVALID_INPUTS) { + ret = SRSRAN_SUCCESS; + } else if (ret == SRSRAN_ERROR_INVALID_INPUTS) { *ack = false; - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } } else { ERROR("Invalid parameters in TB%d &softbuffer=%p &data=%p &ack=%p, nbits=%d, nof_re=%d", @@ -768,15 +768,15 @@ static int srslte_pdsch_codeword_decode(srslte_pdsch_t* q, return ret; } -static void* srslte_pdsch_decode_thread(void* arg) +static void* srsran_pdsch_decode_thread(void* arg) { - srslte_pdsch_coworker_t* q = (srslte_pdsch_coworker_t*)arg; + srsran_pdsch_coworker_t* q = (srsran_pdsch_coworker_t*)arg; INFO("[PDSCH Coworker] waiting for data"); sem_wait(&q->start); while (!q->quit) { - q->ret_status = srslte_pdsch_codeword_decode(q->pdsch_ptr, q->sf, q->cfg, &q->dl_sch, q->data, q->tb_idx, q->ack); + q->ret_status = srsran_pdsch_codeword_decode(q->pdsch_ptr, q->sf, q->cfg, &q->dl_sch, q->data, q->tb_idx, q->ack); /* Post finish semaphore */ sem_post(&q->finish); @@ -792,12 +792,12 @@ static void* srslte_pdsch_decode_thread(void* arg) /** Decodes the PDSCH from the received symbols */ -int srslte_pdsch_decode(srslte_pdsch_t* q, - srslte_dl_sf_cfg_t* sf, - srslte_pdsch_cfg_t* cfg, - srslte_chest_dl_res_t* channel, - cf_t* sf_symbols[SRSLTE_MAX_PORTS], - srslte_pdsch_res_t data[SRSLTE_MAX_CODEWORDS]) +int srsran_pdsch_decode(srsran_pdsch_t* q, + srsran_dl_sf_cfg_t* sf, + srsran_pdsch_cfg_t* cfg, + srsran_chest_dl_res_t* channel, + cf_t* sf_symbols[SRSRAN_MAX_PORTS], + srsran_pdsch_res_t data[SRSRAN_MAX_CODEWORDS]) { /* Set pointers for layermapping & precoding */ uint32_t i; @@ -820,45 +820,45 @@ int srslte_pdsch_decode(srslte_pdsch_t* q, } if (cfg->max_nof_iterations) { - srslte_sch_set_max_noi(&q->dl_sch, cfg->max_nof_iterations); + srsran_sch_set_max_noi(&q->dl_sch, cfg->max_nof_iterations); } - float noise_estimate = cfg->decoder_type == SRSLTE_MIMO_DECODER_ZF ? 0 : channel->noise_estimate; + float noise_estimate = cfg->decoder_type == SRSRAN_MIMO_DECODER_ZF ? 0 : channel->noise_estimate; INFO("Decoding PDSCH SF: %d, RNTI: 0x%x, NofSymbols: %d, C_prb=%d, mod=%s, nof_layers=%d, nof_tb=%d", sf->tti % 10, cfg->rnti, cfg->grant.nof_re, cfg->grant.nof_prb, - srslte_mod_string(cfg->grant.tb[0].mod), + srsran_mod_string(cfg->grant.tb[0].mod), cfg->grant.nof_layers, nof_tb); // Extract Symbols and Channel Estimates - uint32_t lstart = SRSLTE_NOF_CTRL_SYMBOLS(q->cell, sf->cfi); + uint32_t lstart = SRSRAN_NOF_CTRL_SYMBOLS(q->cell, sf->cfi); for (int j = 0; j < q->nof_rx_antennas; j++) { - int n = srslte_pdsch_get(q, sf_symbols[j], q->symbols[j], &cfg->grant, lstart, sf->tti % 10); + int n = srsran_pdsch_get(q, sf_symbols[j], q->symbols[j], &cfg->grant, lstart, sf->tti % 10); if (n != cfg->grant.nof_re) { ERROR("Error expecting %d symbols but got %d", cfg->grant.nof_re, n); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } for (i = 0; i < q->cell.nof_ports; i++) { - n = srslte_pdsch_get(q, channel->ce[i][j], q->ce[i][j], &cfg->grant, lstart, sf->tti % 10); + n = srsran_pdsch_get(q, channel->ce[i][j], q->ce[i][j], &cfg->grant, lstart, sf->tti % 10); if (n != cfg->grant.nof_re) { ERROR("Error expecting %d symbols but got %d", cfg->grant.nof_re, n); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } } - if (cfg->grant.nof_layers == 0 || cfg->grant.nof_layers > SRSLTE_MAX_LAYERS) { + if (cfg->grant.nof_layers == 0 || cfg->grant.nof_layers > SRSRAN_MAX_LAYERS) { ERROR("PDSCH Number of layers (%d) is out-of-bounds", cfg->grant.nof_layers); - return SRSLTE_ERROR_OUT_OF_BOUNDS; + return SRSRAN_ERROR_OUT_OF_BOUNDS; } // Prepare layers - int nof_symbols[SRSLTE_MAX_CODEWORDS]; + int nof_symbols[SRSRAN_MAX_CODEWORDS]; nof_symbols[0] = cfg->grant.nof_re * nof_tb / cfg->grant.nof_layers; nof_symbols[1] = cfg->grant.nof_re * nof_tb / cfg->grant.nof_layers; @@ -872,7 +872,7 @@ int srslte_pdsch_decode(srslte_pdsch_t* q, // Pre-decoder uint32_t codebook_idx = nof_tb == 1 ? cfg->grant.pmi : (cfg->grant.pmi + 1); - if (srslte_predecoding_type(q->symbols, + if (srsran_predecoding_type(q->symbols, q->ce, x, q->csi, @@ -885,22 +885,22 @@ int srslte_pdsch_decode(srslte_pdsch_t* q, pdsch_scaling, noise_estimate) < 0) { ERROR("Error predecoding"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Layer demapping only if necessary if (cfg->grant.nof_layers != nof_tb) { - srslte_layerdemap_type(x, q->d, cfg->grant.nof_layers, nof_tb, nof_symbols[0], nof_symbols, cfg->grant.tx_scheme); + srsran_layerdemap_type(x, q->d, cfg->grant.nof_layers, nof_tb, nof_symbols[0], nof_symbols, cfg->grant.tx_scheme); } /* Codeword decoding: Implementation of 3GPP 36.212 Table 5.3.3.1.5-1 and Table 5.3.3.1.5-2 */ - for (uint32_t tb_idx = 0; tb_idx < SRSLTE_MAX_TB; tb_idx++) { + for (uint32_t tb_idx = 0; tb_idx < SRSRAN_MAX_TB; tb_idx++) { /* Decode only if transport block is enabled and the default ACK is not true */ if (cfg->grant.tb[tb_idx].enabled) { if (!data[tb_idx].crc) { - int ret = SRSLTE_SUCCESS; + int ret = SRSRAN_SUCCESS; if (cfg->grant.nof_tb > 1 && tb_idx == 0 && q->coworker_ptr) { - srslte_pdsch_coworker_t* h = (srslte_pdsch_coworker_t*)q->coworker_ptr; + srsran_pdsch_coworker_t* h = (srsran_pdsch_coworker_t*)q->coworker_ptr; h->pdsch_ptr = q; h->cfg = cfg; @@ -913,9 +913,9 @@ int srslte_pdsch_decode(srslte_pdsch_t* q, sem_post(&h->start); } else { - ret = srslte_pdsch_codeword_decode(q, sf, cfg, &q->dl_sch, data, tb_idx, &data[tb_idx].crc); + ret = srsran_pdsch_codeword_decode(q, sf, cfg, &q->dl_sch, data, tb_idx, &data[tb_idx].crc); - data[tb_idx].avg_iterations_block = srslte_sch_last_noi(&q->dl_sch); + data[tb_idx].avg_iterations_block = srsran_sch_last_noi(&q->dl_sch); } /* Check if there has been any execution error */ @@ -927,7 +927,7 @@ int srslte_pdsch_decode(srslte_pdsch_t* q, } if (q->coworker_ptr) { - srslte_pdsch_coworker_t* h = (srslte_pdsch_coworker_t*)q->coworker_ptr; + srsran_pdsch_coworker_t* h = (srsran_pdsch_coworker_t*)q->coworker_ptr; if (h->started) { int err = sem_wait(&h->finish); if (err) { @@ -936,7 +936,7 @@ int srslte_pdsch_decode(srslte_pdsch_t* q, if (h->ret_status) { ERROR("PDSCH Coworker Decoder: Error decoding"); } - data[h->tb_idx].avg_iterations_block = srslte_sch_last_noi(&q->dl_sch); + data[h->tb_idx].avg_iterations_block = srsran_sch_last_noi(&q->dl_sch); h->started = false; } } @@ -950,45 +950,45 @@ int srslte_pdsch_decode(srslte_pdsch_t* q, } if (cfg->meas_evm_en) { - for (uint32_t i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { + for (uint32_t i = 0; i < SRSRAN_MAX_CODEWORDS; i++) { if (cfg->grant.tb[i].enabled && !isnan(data[i].evm)) { - q->avg_evm = SRSLTE_VEC_EMA(data[i].evm, q->avg_evm, 0.1); + q->avg_evm = SRSRAN_VEC_EMA(data[i].evm, q->avg_evm, 0.1); } } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } else { ERROR("Invalid inputs"); - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } } -static int srslte_pdsch_codeword_encode(srslte_pdsch_t* q, - srslte_dl_sf_cfg_t* sf, - srslte_pdsch_cfg_t* cfg, - srslte_softbuffer_tx_t* softbuffer, +static int srsran_pdsch_codeword_encode(srsran_pdsch_t* q, + srsran_dl_sf_cfg_t* sf, + srsran_pdsch_cfg_t* cfg, + srsran_softbuffer_tx_t* softbuffer, uint8_t* data, uint32_t tb_idx, uint32_t nof_layers) { - srslte_ra_tb_t* mcs = &cfg->grant.tb[tb_idx]; + srsran_ra_tb_t* mcs = &cfg->grant.tb[tb_idx]; uint32_t rv = cfg->grant.tb[tb_idx].rv; uint32_t codeword_idx = cfg->grant.tb[tb_idx].cw_idx; if (!softbuffer) { ERROR("Error encoding (TB%d -> CW%d), softbuffer=NULL", tb_idx, codeword_idx); - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } if (cfg->grant.tb[tb_idx].enabled) { - if (cfg->rnti != SRSLTE_SIRNTI) { + if (cfg->rnti != SRSRAN_SIRNTI) { INFO("Encoding PDSCH SF: %d (TB%d -> CW%d), Mod %s, NofBits: %d, NofSymbols: %d, NofBitsE: %d, rv_idx: %d", sf->tti % 10, tb_idx, codeword_idx, - srslte_mod_string(mcs->mod), + srsran_mod_string(mcs->mod), mcs->tbs, cfg->grant.nof_re, cfg->grant.tb[tb_idx].nof_bits, @@ -996,41 +996,41 @@ static int srslte_pdsch_codeword_encode(srslte_pdsch_t* q, } /* Channel coding */ - if (srslte_dlsch_encode2(&q->dl_sch, cfg, data, q->e[codeword_idx], tb_idx, nof_layers)) { + if (srsran_dlsch_encode2(&q->dl_sch, cfg, data, q->e[codeword_idx], tb_idx, nof_layers)) { ERROR("Error encoding (TB%d -> CW%d)", tb_idx, codeword_idx); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } /* Bit scrambling */ - srslte_sequence_pdsch_apply_pack((uint8_t*)q->e[codeword_idx], + srsran_sequence_pdsch_apply_pack((uint8_t*)q->e[codeword_idx], (uint8_t*)q->e[codeword_idx], cfg->rnti, codeword_idx, - 2 * (sf->tti % SRSLTE_NOF_SF_X_FRAME), + 2 * (sf->tti % SRSRAN_NOF_SF_X_FRAME), q->cell.id, cfg->grant.tb[tb_idx].nof_bits); /* Bit mapping */ - srslte_mod_modulate_bytes( + srsran_mod_modulate_bytes( &q->mod[mcs->mod], (uint8_t*)q->e[codeword_idx], q->d[codeword_idx], cfg->grant.tb[tb_idx].nof_bits); } else { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_pdsch_encode(srslte_pdsch_t* q, - srslte_dl_sf_cfg_t* sf, - srslte_pdsch_cfg_t* cfg, - uint8_t* data[SRSLTE_MAX_CODEWORDS], - cf_t* sf_symbols[SRSLTE_MAX_PORTS]) +int srsran_pdsch_encode(srsran_pdsch_t* q, + srsran_dl_sf_cfg_t* sf, + srsran_pdsch_cfg_t* cfg, + uint8_t* data[SRSRAN_MAX_CODEWORDS], + cf_t* sf_symbols[SRSRAN_MAX_PORTS]) { int i; /* Set pointers for layermapping & precoding */ - cf_t* x[SRSLTE_MAX_LAYERS]; - int ret = SRSLTE_ERROR_INVALID_INPUTS; + cf_t* x[SRSRAN_MAX_LAYERS]; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL && cfg != NULL) { struct timeval t[3]; @@ -1043,14 +1043,14 @@ int srslte_pdsch_encode(srslte_pdsch_t* q, for (i = 0; i < q->cell.nof_ports; i++) { if (sf_symbols[i] == NULL) { ERROR("Error NULL pointer in sf_symbols[%d]", i); - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } } /* If both transport block size is zero return error */ if (!nof_tb) { ERROR("Error number of TB is zero"); - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } if (cfg->grant.nof_re > q->max_re) { @@ -1058,15 +1058,15 @@ int srslte_pdsch_encode(srslte_pdsch_t* q, cfg->grant.nof_re, q->max_re, q->cell.nof_prb); - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } float rho_a = apply_power_allocation(q, cfg, sf_symbols); /* Implementation of 3GPP 36.212 Table 5.3.3.1.5-1 and Table 5.3.3.1.5-2 */ - for (uint32_t tb_idx = 0; tb_idx < SRSLTE_MAX_TB; tb_idx++) { + for (uint32_t tb_idx = 0; tb_idx < SRSRAN_MAX_TB; tb_idx++) { if (cfg->grant.tb[tb_idx].enabled) { - ret |= srslte_pdsch_codeword_encode( + ret |= srsran_pdsch_codeword_encode( q, sf, cfg, cfg->softbuffers.tx[tb_idx], data[tb_idx], tb_idx, cfg->grant.nof_layers); } } @@ -1077,7 +1077,7 @@ int srslte_pdsch_encode(srslte_pdsch_t* q, scaling = rho_a; } - if (cfg->rnti != SRSLTE_SIRNTI) { + if (cfg->rnti != SRSRAN_SIRNTI) { INFO("Encoding PDSCH SF: %d rho_a=%f, nof_ports=%d, nof_layers=%d, nof_tb=%d, pmi=%d, tx_scheme=%s", sf->tti % 10, rho_a, @@ -1085,7 +1085,7 @@ int srslte_pdsch_encode(srslte_pdsch_t* q, cfg->grant.nof_layers, nof_tb, cfg->grant.pmi, - srslte_mimotype2str(cfg->grant.tx_scheme)); + srsran_mimotype2str(cfg->grant.tx_scheme)); } // Layer mapping & precode if necessary @@ -1102,19 +1102,19 @@ int srslte_pdsch_encode(srslte_pdsch_t* q, for (i = 0; i < cfg->grant.nof_layers; i++) { x[i] = q->x[i]; } - memset(&x[cfg->grant.nof_layers], 0, sizeof(cf_t*) * (SRSLTE_MAX_LAYERS - cfg->grant.nof_layers)); + memset(&x[cfg->grant.nof_layers], 0, sizeof(cf_t*) * (SRSRAN_MAX_LAYERS - cfg->grant.nof_layers)); - nof_symbols = srslte_layermap_type(q->d, + nof_symbols = srsran_layermap_type(q->d, x, nof_tb, cfg->grant.nof_layers, - (int[SRSLTE_MAX_CODEWORDS]){cfg->grant.nof_re, cfg->grant.nof_re}, + (int[SRSRAN_MAX_CODEWORDS]){cfg->grant.nof_re, cfg->grant.nof_re}, cfg->grant.tx_scheme); } /* Precode */ uint32_t codebook_idx = nof_tb == 1 ? cfg->grant.pmi : (cfg->grant.pmi + 1); - srslte_precoding_type(x, + srsran_precoding_type(x, q->symbols, cfg->grant.nof_layers, q->cell.nof_ports, @@ -1126,14 +1126,14 @@ int srslte_pdsch_encode(srslte_pdsch_t* q, if (scaling == 1.0f) { memcpy(q->symbols[0], q->d[0], cfg->grant.nof_re * sizeof(cf_t)); } else { - srslte_vec_sc_prod_cfc(q->d[0], scaling, q->symbols[0], cfg->grant.nof_re); + srsran_vec_sc_prod_cfc(q->d[0], scaling, q->symbols[0], cfg->grant.nof_re); } } /* mapping to resource elements */ - uint32_t lstart = SRSLTE_NOF_CTRL_SYMBOLS(q->cell, sf->cfi); + uint32_t lstart = SRSRAN_NOF_CTRL_SYMBOLS(q->cell, sf->cfi); for (i = 0; i < q->cell.nof_ports; i++) { - srslte_pdsch_put(q, q->symbols[i], sf_symbols[i], &cfg->grant, lstart, sf->tti % 10); + srsran_pdsch_put(q, q->symbols[i], sf_symbols[i], &cfg->grant, lstart, sf->tti % 10); } if (cfg->meas_time_en) { @@ -1142,99 +1142,99 @@ int srslte_pdsch_encode(srslte_pdsch_t* q, cfg->meas_time_value = t[0].tv_usec; } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } -int srslte_pdsch_select_pmi(srslte_pdsch_t* q, - srslte_chest_dl_res_t* channel, +int srsran_pdsch_select_pmi(srsran_pdsch_t* q, + srsran_chest_dl_res_t* channel, uint32_t nof_layers, uint32_t* best_pmi, - float sinr[SRSLTE_MAX_CODEBOOKS]) + float sinr[SRSRAN_MAX_CODEBOOKS]) { - uint32_t nof_ce = SRSLTE_NOF_RE(q->cell); + uint32_t nof_ce = SRSRAN_NOF_RE(q->cell); uint32_t pmi = 0; - if (srslte_precoding_pmi_select(channel->ce, nof_ce, channel->noise_estimate, nof_layers, &pmi, sinr) < 0) { + if (srsran_precoding_pmi_select(channel->ce, nof_ce, channel->noise_estimate, nof_layers, &pmi, sinr) < 0) { ERROR("PMI Select for %d layers", nof_layers); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (best_pmi) { *best_pmi = pmi; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_pdsch_compute_cn(srslte_pdsch_t* q, srslte_chest_dl_res_t* channel, float* cn) +int srsran_pdsch_compute_cn(srsran_pdsch_t* q, srsran_chest_dl_res_t* channel, float* cn) { - return srslte_precoding_cn(channel->ce, q->cell.nof_ports, q->nof_rx_antennas, SRSLTE_NOF_RE(q->cell), cn); + return srsran_precoding_cn(channel->ce, q->cell.nof_ports, q->nof_rx_antennas, SRSRAN_NOF_RE(q->cell), cn); } -uint32_t srslte_pdsch_grant_rx_info(srslte_pdsch_grant_t* grant, - srslte_pdsch_res_t res[SRSLTE_MAX_CODEWORDS], +uint32_t srsran_pdsch_grant_rx_info(srsran_pdsch_grant_t* grant, + srsran_pdsch_res_t res[SRSRAN_MAX_CODEWORDS], char* str, uint32_t str_len) { - uint32_t len = srslte_ra_dl_info(grant, str, str_len); + uint32_t len = srsran_ra_dl_info(grant, str, str_len); - len = srslte_print_check(str, str_len, len, ", crc={", 0); - for (uint32_t i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { + len = srsran_print_check(str, str_len, len, ", crc={", 0); + for (uint32_t i = 0; i < SRSRAN_MAX_CODEWORDS; i++) { if (grant->tb[i].enabled) { - len = srslte_print_check(str, str_len, len, "%s", res[i].crc ? "OK" : "KO"); - if (i < SRSLTE_MAX_CODEWORDS - 1) { + len = srsran_print_check(str, str_len, len, "%s", res[i].crc ? "OK" : "KO"); + if (i < SRSRAN_MAX_CODEWORDS - 1) { if (grant->tb[i + 1].enabled) { - len = srslte_print_check(str, str_len, len, "/", 0); + len = srsran_print_check(str, str_len, len, "/", 0); } } } } - len = srslte_print_check(str, str_len, len, "}", 0); + len = srsran_print_check(str, str_len, len, "}", 0); // Average iterations between nof TB and divide by 2 to get full decoder iterations - len = srslte_print_check( + len = srsran_print_check( str, str_len, len, ", it=%.1f", (res[0].avg_iterations_block + res[1].avg_iterations_block) / grant->nof_tb / 2); return len; } uint32_t -srslte_pdsch_rx_info(srslte_pdsch_cfg_t* cfg, srslte_pdsch_res_t res[SRSLTE_MAX_CODEWORDS], char* str, uint32_t str_len) +srsran_pdsch_rx_info(srsran_pdsch_cfg_t* cfg, srsran_pdsch_res_t res[SRSRAN_MAX_CODEWORDS], char* str, uint32_t str_len) { - uint32_t len = srslte_print_check(str, str_len, 0, "rnti=0x%x", cfg->rnti); - len += srslte_pdsch_grant_rx_info(&cfg->grant, res, &str[len], str_len - len); + uint32_t len = srsran_print_check(str, str_len, 0, "rnti=0x%x", cfg->rnti); + len += srsran_pdsch_grant_rx_info(&cfg->grant, res, &str[len], str_len - len); if (cfg->meas_evm_en) { - len = srslte_print_check(str, str_len, len, ", evm={", 0); - for (uint32_t i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { + len = srsran_print_check(str, str_len, len, ", evm={", 0); + for (uint32_t i = 0; i < SRSRAN_MAX_CODEWORDS; i++) { if (cfg->grant.tb[i].enabled && !isnan(res[i].evm)) { - len = srslte_print_check(str, str_len, len, "%.2f", res[i].evm); - if (i < SRSLTE_MAX_CODEWORDS - 1) { + len = srsran_print_check(str, str_len, len, "%.2f", res[i].evm); + if (i < SRSRAN_MAX_CODEWORDS - 1) { if (cfg->grant.tb[i + 1].enabled) { - len = srslte_print_check(str, str_len, len, "/", 0); + len = srsran_print_check(str, str_len, len, "/", 0); } } } } - len = srslte_print_check(str, str_len, len, "}", 0); + len = srsran_print_check(str, str_len, len, "}", 0); } if (cfg->meas_time_en) { - len = srslte_print_check(str, str_len, len, ", t=%d us", cfg->meas_time_value); + len = srsran_print_check(str, str_len, len, ", t=%d us", cfg->meas_time_value); } return len; } -uint32_t srslte_pdsch_tx_info(srslte_pdsch_cfg_t* cfg, char* str, uint32_t str_len) +uint32_t srsran_pdsch_tx_info(srsran_pdsch_cfg_t* cfg, char* str, uint32_t str_len) { - uint32_t len = srslte_print_check(str, str_len, 0, "rnti=0x%x", cfg->rnti); - len += srslte_ra_dl_info(&cfg->grant, &str[len], str_len); + uint32_t len = srsran_print_check(str, str_len, 0, "rnti=0x%x", cfg->rnti); + len += srsran_ra_dl_info(&cfg->grant, &str[len], str_len); if (cfg->meas_time_en) { - len = srslte_print_check(str, str_len, len, ", t=%d us", cfg->meas_time_value); + len = srsran_print_check(str, str_len, len, ", t=%d us", cfg->meas_time_value); } return len; } diff --git a/lib/src/phy/phch/pdsch_nr.c b/lib/src/phy/phch/pdsch_nr.c index 38b651e3e..c60e86c13 100644 --- a/lib/src/phy/phch/pdsch_nr.c +++ b/lib/src/phy/phch/pdsch_nr.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,75 +10,75 @@ * */ -#include "srslte/phy/phch/pdsch_nr.h" -#include "srslte/phy/common/phy_common_nr.h" -#include "srslte/phy/mimo/layermap.h" -#include "srslte/phy/mimo/precoding.h" -#include "srslte/phy/modem/demod_soft.h" -#include "srslte/phy/phch/ra_nr.h" +#include "srsran/phy/phch/pdsch_nr.h" +#include "srsran/phy/common/phy_common_nr.h" +#include "srsran/phy/mimo/layermap.h" +#include "srsran/phy/mimo/precoding.h" +#include "srsran/phy/modem/demod_soft.h" +#include "srsran/phy/phch/ra_nr.h" -int pdsch_nr_init_common(srslte_pdsch_nr_t* q, const srslte_pdsch_nr_args_t* args) +int pdsch_nr_init_common(srsran_pdsch_nr_t* q, const srsran_pdsch_nr_args_t* args) { - for (srslte_mod_t mod = SRSLTE_MOD_BPSK; mod < SRSLTE_MOD_NITEMS; mod++) { - if (srslte_modem_table_lte(&q->modem_tables[mod], mod) < SRSLTE_SUCCESS) { - ERROR("Error initialising modem table for %s", srslte_mod_string(mod)); - return SRSLTE_ERROR; + for (srsran_mod_t mod = SRSRAN_MOD_BPSK; mod < SRSRAN_MOD_NITEMS; mod++) { + if (srsran_modem_table_lte(&q->modem_tables[mod], mod) < SRSRAN_SUCCESS) { + ERROR("Error initialising modem table for %s", srsran_mod_string(mod)); + return SRSRAN_ERROR; } if (args->measure_evm) { - srslte_modem_table_bytes(&q->modem_tables[mod]); + srsran_modem_table_bytes(&q->modem_tables[mod]); } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_pdsch_nr_init_enb(srslte_pdsch_nr_t* q, const srslte_pdsch_nr_args_t* args) +int srsran_pdsch_nr_init_enb(srsran_pdsch_nr_t* q, const srsran_pdsch_nr_args_t* args) { if (q == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } - if (pdsch_nr_init_common(q, args) < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (pdsch_nr_init_common(q, args) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } - if (srslte_sch_nr_init_tx(&q->sch, &args->sch)) { + if (srsran_sch_nr_init_tx(&q->sch, &args->sch)) { ERROR("Initialising SCH"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_pdsch_nr_init_ue(srslte_pdsch_nr_t* q, const srslte_pdsch_nr_args_t* args) +int srsran_pdsch_nr_init_ue(srsran_pdsch_nr_t* q, const srsran_pdsch_nr_args_t* args) { if (q == NULL || args == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } - if (pdsch_nr_init_common(q, args) < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (pdsch_nr_init_common(q, args) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } - if (srslte_sch_nr_init_rx(&q->sch, &args->sch)) { + if (srsran_sch_nr_init_rx(&q->sch, &args->sch)) { ERROR("Initialising SCH"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (args->measure_evm) { - q->evm_buffer = srslte_evm_buffer_alloc(8); + q->evm_buffer = srsran_evm_buffer_alloc(8); if (q->evm_buffer == NULL) { ERROR("Initialising EVM"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } q->meas_time_en = args->measure_time; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_pdsch_nr_set_carrier(srslte_pdsch_nr_t* q, const srslte_carrier_nr_t* carrier) +int srsran_pdsch_nr_set_carrier(srsran_pdsch_nr_t* q, const srsran_carrier_nr_t* carrier) { // Set carrier q->carrier = *carrier; @@ -89,7 +89,7 @@ int srslte_pdsch_nr_set_carrier(srslte_pdsch_nr_t* q, const srslte_carrier_nr_t* q->max_prb = carrier->nof_prb; // Free current allocations - for (uint32_t i = 0; i < SRSLTE_MAX_LAYERS_NR; i++) { + for (uint32_t i = 0; i < SRSRAN_MAX_LAYERS_NR; i++) { if (q->x[i] != NULL) { free(q->x[i]); } @@ -97,10 +97,10 @@ int srslte_pdsch_nr_set_carrier(srslte_pdsch_nr_t* q, const srslte_carrier_nr_t* // Allocate for new sizes for (uint32_t i = 0; i < q->max_layers; i++) { - q->x[i] = srslte_vec_cf_malloc(SRSLTE_SLOT_LEN_RE_NR(q->max_prb)); + q->x[i] = srsran_vec_cf_malloc(SRSRAN_SLOT_LEN_RE_NR(q->max_prb)); if (q->x[i] == NULL) { ERROR("Malloc"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } } @@ -112,42 +112,42 @@ int srslte_pdsch_nr_set_carrier(srslte_pdsch_nr_t* q, const srslte_carrier_nr_t* for (uint32_t i = 0; i < max_cw; i++) { if (q->b[i] == NULL) { - q->b[i] = srslte_vec_u8_malloc(SRSLTE_SLOT_MAX_NOF_BITS_NR); + q->b[i] = srsran_vec_u8_malloc(SRSRAN_SLOT_MAX_NOF_BITS_NR); if (q->b[i] == NULL) { ERROR("Malloc"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } if (q->d[i] == NULL) { - q->d[i] = srslte_vec_cf_malloc(SRSLTE_SLOT_MAX_LEN_RE_NR); + q->d[i] = srsran_vec_cf_malloc(SRSRAN_SLOT_MAX_LEN_RE_NR); if (q->d[i] == NULL) { ERROR("Malloc"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } } } // Set carrier in SCH - if (srslte_sch_nr_set_carrier(&q->sch, carrier) < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (srsran_sch_nr_set_carrier(&q->sch, carrier) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } if (q->evm_buffer != NULL) { - srslte_evm_buffer_resize(q->evm_buffer, SRSLTE_SLOT_LEN_RE_NR(q->max_prb) * SRSLTE_MAX_QM); + srsran_evm_buffer_resize(q->evm_buffer, SRSRAN_SLOT_LEN_RE_NR(q->max_prb) * SRSRAN_MAX_QM); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -void srslte_pdsch_nr_free(srslte_pdsch_nr_t* q) +void srsran_pdsch_nr_free(srsran_pdsch_nr_t* q) { if (q == NULL) { return; } - for (uint32_t cw = 0; cw < SRSLTE_MAX_CODEWORDS; cw++) { + for (uint32_t cw = 0; cw < SRSRAN_MAX_CODEWORDS; cw++) { if (q->b[cw]) { free(q->b[cw]); } @@ -157,20 +157,20 @@ void srslte_pdsch_nr_free(srslte_pdsch_nr_t* q) } } - srslte_sch_nr_free(&q->sch); + srsran_sch_nr_free(&q->sch); - for (uint32_t i = 0; i < SRSLTE_MAX_LAYERS_NR; i++) { + for (uint32_t i = 0; i < SRSRAN_MAX_LAYERS_NR; i++) { if (q->x[i]) { free(q->x[i]); } } - for (srslte_mod_t mod = SRSLTE_MOD_BPSK; mod < SRSLTE_MOD_NITEMS; mod++) { - srslte_modem_table_free(&q->modem_tables[mod]); + for (srsran_mod_t mod = SRSRAN_MOD_BPSK; mod < SRSRAN_MOD_NITEMS; mod++) { + srsran_modem_table_free(&q->modem_tables[mod]); } if (q->evm_buffer != NULL) { - srslte_evm_free(q->evm_buffer); + srsran_evm_free(q->evm_buffer); } } @@ -181,12 +181,12 @@ void srslte_pdsch_nr_free(srslte_pdsch_nr_t* q) * @param count number of resource elements to copy * @param put Direction, symbols are copied into sf_symbols if put is true, otherwise sf_symbols are copied into symbols */ -static void srslte_pdsch_re_cp(cf_t* sf_symbols, cf_t* symbols, uint32_t count, bool put) +static void srsran_pdsch_re_cp(cf_t* sf_symbols, cf_t* symbols, uint32_t count, bool put) { if (put) { - srslte_vec_cf_copy(sf_symbols, symbols, count); + srsran_vec_cf_copy(sf_symbols, symbols, count); } else { - srslte_vec_cf_copy(symbols, sf_symbols, count); + srsran_vec_cf_copy(symbols, sf_symbols, count); } } @@ -202,8 +202,8 @@ static void srslte_pdsch_re_cp(cf_t* sf_symbols, cf_t* symbols, uint32_t count, * - 1, data is mapped in RE marked as 2 * - Otherwise, no data is mapped in this symbol */ -static uint32_t srslte_pdsch_nr_cp_dmrs_type1(const srslte_pdsch_nr_t* q, - const srslte_sch_grant_nr_t* grant, +static uint32_t srsran_pdsch_nr_cp_dmrs_type1(const srsran_pdsch_nr_t* q, + const srsran_sch_grant_nr_t* grant, cf_t* symbols, cf_t* sf_symbols, bool put) @@ -217,11 +217,11 @@ static uint32_t srslte_pdsch_nr_cp_dmrs_type1(const srslte_pdsch_nr_t* q, for (uint32_t i = 0; i < q->carrier.nof_prb; i++) { if (grant->prb_idx[i]) { - for (uint32_t j = 0; j < SRSLTE_NRE; j += 2) { + for (uint32_t j = 0; j < SRSRAN_NRE; j += 2) { if (put) { - sf_symbols[i * SRSLTE_NRE + delta + j + 1] = symbols[count++]; + sf_symbols[i * SRSRAN_NRE + delta + j + 1] = symbols[count++]; } else { - symbols[count++] = sf_symbols[i * SRSLTE_NRE + delta + j + 1]; + symbols[count++] = sf_symbols[i * SRSRAN_NRE + delta + j + 1]; } } } @@ -243,8 +243,8 @@ static uint32_t srslte_pdsch_nr_cp_dmrs_type1(const srslte_pdsch_nr_t* q, * - 2, data is mapped in RE marked as 3 * - otherwise, no data is mapped in this symbol */ -static uint32_t srslte_pdsch_nr_cp_dmrs_type2(const srslte_pdsch_nr_t* q, - const srslte_sch_grant_nr_t* grant, +static uint32_t srsran_pdsch_nr_cp_dmrs_type2(const srsran_pdsch_nr_t* q, + const srsran_sch_grant_nr_t* grant, cf_t* symbols, cf_t* sf_symbols, bool put) @@ -261,11 +261,11 @@ static uint32_t srslte_pdsch_nr_cp_dmrs_type2(const srslte_pdsch_nr_t* q, for (uint32_t i = 0; i < q->carrier.nof_prb; i++) { if (grant->prb_idx[i]) { // Copy RE between pilot pairs - srslte_pdsch_re_cp(&sf_symbols[i * SRSLTE_NRE + re_offset], &symbols[count], re_count, put); + srsran_pdsch_re_cp(&sf_symbols[i * SRSRAN_NRE + re_offset], &symbols[count], re_count, put); count += re_count; // Copy RE after second pilot - srslte_pdsch_re_cp(&sf_symbols[(i + 1) * SRSLTE_NRE - re_count], &symbols[count], re_count, put); + srsran_pdsch_re_cp(&sf_symbols[(i + 1) * SRSRAN_NRE - re_count], &symbols[count], re_count, put); count += re_count; } } @@ -273,31 +273,31 @@ static uint32_t srslte_pdsch_nr_cp_dmrs_type2(const srslte_pdsch_nr_t* q, return count; } -static uint32_t srslte_pdsch_nr_cp_dmrs(const srslte_pdsch_nr_t* q, - const srslte_sch_cfg_nr_t* cfg, - const srslte_sch_grant_nr_t* grant, +static uint32_t srsran_pdsch_nr_cp_dmrs(const srsran_pdsch_nr_t* q, + const srsran_sch_cfg_nr_t* cfg, + const srsran_sch_grant_nr_t* grant, cf_t* symbols, cf_t* sf_symbols, bool put) { uint32_t count = 0; - const srslte_dmrs_sch_cfg_t* dmrs_cfg = &cfg->dmrs; + const srsran_dmrs_sch_cfg_t* dmrs_cfg = &cfg->dmrs; switch (dmrs_cfg->type) { - case srslte_dmrs_sch_type_1: - count = srslte_pdsch_nr_cp_dmrs_type1(q, grant, symbols, sf_symbols, put); + case srsran_dmrs_sch_type_1: + count = srsran_pdsch_nr_cp_dmrs_type1(q, grant, symbols, sf_symbols, put); break; - case srslte_dmrs_sch_type_2: - count = srslte_pdsch_nr_cp_dmrs_type2(q, grant, symbols, sf_symbols, put); + case srsran_dmrs_sch_type_2: + count = srsran_pdsch_nr_cp_dmrs_type2(q, grant, symbols, sf_symbols, put); break; } return count; } -static uint32_t srslte_pdsch_nr_cp_clean(const srslte_pdsch_nr_t* q, - const srslte_sch_grant_nr_t* grant, +static uint32_t srsran_pdsch_nr_cp_clean(const srsran_pdsch_nr_t* q, + const srsran_sch_grant_nr_t* grant, cf_t* symbols, cf_t* sf_symbols, bool put) @@ -310,15 +310,15 @@ static uint32_t srslte_pdsch_nr_cp_clean(const srslte_pdsch_nr_t* q, if (grant->prb_idx[i]) { // If fist continuous block, save start if (length == 0) { - start = i * SRSLTE_NRE; + start = i * SRSRAN_NRE; } - length += SRSLTE_NRE; + length += SRSRAN_NRE; } else { // Consecutive block is finished if (put) { - srslte_vec_cf_copy(&sf_symbols[start], &symbols[count], length); + srsran_vec_cf_copy(&sf_symbols[start], &symbols[count], length); } else { - srslte_vec_cf_copy(&symbols[count], &sf_symbols[start], length); + srsran_vec_cf_copy(&symbols[count], &sf_symbols[start], length); } // Increase RE count @@ -332,9 +332,9 @@ static uint32_t srslte_pdsch_nr_cp_clean(const srslte_pdsch_nr_t* q, // Copy last contiguous block if (length > 0) { if (put) { - srslte_vec_cf_copy(&sf_symbols[start], &symbols[count], length); + srsran_vec_cf_copy(&sf_symbols[start], &symbols[count], length); } else { - srslte_vec_cf_copy(&symbols[count], &sf_symbols[start], length); + srsran_vec_cf_copy(&symbols[count], &sf_symbols[start], length); } count += length; } @@ -342,26 +342,26 @@ static uint32_t srslte_pdsch_nr_cp_clean(const srslte_pdsch_nr_t* q, return count; } -static int srslte_pdsch_nr_cp(const srslte_pdsch_nr_t* q, - const srslte_sch_cfg_nr_t* cfg, - const srslte_sch_grant_nr_t* grant, +static int srsran_pdsch_nr_cp(const srsran_pdsch_nr_t* q, + const srsran_sch_cfg_nr_t* cfg, + const srsran_sch_grant_nr_t* grant, cf_t* symbols, cf_t* sf_symbols, bool put) { uint32_t count = 0; - uint32_t dmrs_l_idx[SRSLTE_DMRS_SCH_MAX_SYMBOLS] = {}; + uint32_t dmrs_l_idx[SRSRAN_DMRS_SCH_MAX_SYMBOLS] = {}; uint32_t dmrs_l_count = 0; // Get symbol indexes carrying DMRS - int32_t nof_dmrs_symbols = srslte_dmrs_sch_get_symbols_idx(&cfg->dmrs, grant, dmrs_l_idx); - if (nof_dmrs_symbols < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + int32_t nof_dmrs_symbols = srsran_dmrs_sch_get_symbols_idx(&cfg->dmrs, grant, dmrs_l_idx); + if (nof_dmrs_symbols < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } - if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_DEBUG && !handler_registered) { + if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_DEBUG && !handler_registered) { DEBUG("dmrs_l_idx="); - srslte_vec_fprint_i(stdout, (int32_t*)dmrs_l_idx, nof_dmrs_symbols); + srsran_vec_fprint_i(stdout, (int32_t*)dmrs_l_idx, nof_dmrs_symbols); } for (uint32_t l = grant->S; l < grant->S + grant->L; l++) { @@ -373,40 +373,40 @@ static int srslte_pdsch_nr_cp(const srslte_pdsch_nr_t* q, } if (l == dmrs_l_idx[dmrs_l_count]) { - count += srslte_pdsch_nr_cp_dmrs( - q, cfg, grant, &symbols[count], &sf_symbols[l * q->carrier.nof_prb * SRSLTE_NRE], put); + count += srsran_pdsch_nr_cp_dmrs( + q, cfg, grant, &symbols[count], &sf_symbols[l * q->carrier.nof_prb * SRSRAN_NRE], put); } else { count += - srslte_pdsch_nr_cp_clean(q, grant, &symbols[count], &sf_symbols[l * q->carrier.nof_prb * SRSLTE_NRE], put); + srsran_pdsch_nr_cp_clean(q, grant, &symbols[count], &sf_symbols[l * q->carrier.nof_prb * SRSRAN_NRE], put); } } return count; } -static int srslte_pdsch_nr_put(const srslte_pdsch_nr_t* q, - const srslte_sch_cfg_nr_t* cfg, - const srslte_sch_grant_nr_t* grant, +static int srsran_pdsch_nr_put(const srsran_pdsch_nr_t* q, + const srsran_sch_cfg_nr_t* cfg, + const srsran_sch_grant_nr_t* grant, cf_t* symbols, cf_t* sf_symbols) { - return srslte_pdsch_nr_cp(q, cfg, grant, symbols, sf_symbols, true); + return srsran_pdsch_nr_cp(q, cfg, grant, symbols, sf_symbols, true); } -static int srslte_pdsch_nr_get(const srslte_pdsch_nr_t* q, - const srslte_sch_cfg_nr_t* cfg, - const srslte_sch_grant_nr_t* grant, +static int srsran_pdsch_nr_get(const srsran_pdsch_nr_t* q, + const srsran_sch_cfg_nr_t* cfg, + const srsran_sch_grant_nr_t* grant, cf_t* symbols, cf_t* sf_symbols) { - return srslte_pdsch_nr_cp(q, cfg, grant, symbols, sf_symbols, false); + return srsran_pdsch_nr_cp(q, cfg, grant, symbols, sf_symbols, false); } static uint32_t -pdsch_nr_cinit(const srslte_carrier_nr_t* carrier, const srslte_sch_cfg_nr_t* cfg, uint16_t rnti, uint32_t cw_idx) +pdsch_nr_cinit(const srsran_carrier_nr_t* carrier, const srsran_sch_cfg_nr_t* cfg, uint16_t rnti, uint32_t cw_idx) { uint32_t n_id = carrier->id; - if (cfg->scrambling_id_present && SRSLTE_RNTI_ISUSER(rnti)) { + if (cfg->scrambling_id_present && SRSRAN_RNTI_ISUSER(rnti)) { n_id = cfg->scambling_id; } uint32_t cinit = (((uint32_t)rnti) << 15U) + (cw_idx << 14U) + n_id; @@ -416,64 +416,64 @@ pdsch_nr_cinit(const srslte_carrier_nr_t* carrier, const srslte_sch_cfg_nr_t* cf return cinit; } -static inline int pdsch_nr_encode_codeword(srslte_pdsch_nr_t* q, - const srslte_sch_cfg_nr_t* cfg, - const srslte_sch_tb_t* tb, +static inline int pdsch_nr_encode_codeword(srsran_pdsch_nr_t* q, + const srsran_sch_cfg_nr_t* cfg, + const srsran_sch_tb_t* tb, const uint8_t* data, uint16_t rnti) { // Early return if TB is not enabled if (!tb->enabled) { - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Check codeword index if (tb->cw_idx >= q->max_cw) { ERROR("Unsupported codeword index %d", tb->cw_idx); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Check modulation - if (tb->mod >= SRSLTE_MOD_NITEMS) { - ERROR("Invalid modulation %s", srslte_mod_string(tb->mod)); - return SRSLTE_ERROR_OUT_OF_BOUNDS; + if (tb->mod >= SRSRAN_MOD_NITEMS) { + ERROR("Invalid modulation %s", srsran_mod_string(tb->mod)); + return SRSRAN_ERROR_OUT_OF_BOUNDS; } // Encode SCH - if (srslte_dlsch_nr_encode(&q->sch, &cfg->sch_cfg, tb, data, q->b[tb->cw_idx]) < SRSLTE_SUCCESS) { + if (srsran_dlsch_nr_encode(&q->sch, &cfg->sch_cfg, tb, data, q->b[tb->cw_idx]) < SRSRAN_SUCCESS) { ERROR("Error in DL-SCH encoding"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_DEBUG && !handler_registered) { + if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_DEBUG && !handler_registered) { DEBUG("b="); - srslte_vec_fprint_b(stdout, q->b[tb->cw_idx], tb->nof_bits); + srsran_vec_fprint_b(stdout, q->b[tb->cw_idx], tb->nof_bits); } // 7.3.1.1 Scrambling uint32_t cinit = pdsch_nr_cinit(&q->carrier, cfg, rnti, tb->cw_idx); - srslte_sequence_apply_bit(q->b[tb->cw_idx], q->b[tb->cw_idx], tb->nof_bits, cinit); + srsran_sequence_apply_bit(q->b[tb->cw_idx], q->b[tb->cw_idx], tb->nof_bits, cinit); // 7.3.1.2 Modulation - srslte_mod_modulate(&q->modem_tables[tb->mod], q->b[tb->cw_idx], q->d[tb->cw_idx], tb->nof_bits); + srsran_mod_modulate(&q->modem_tables[tb->mod], q->b[tb->cw_idx], q->d[tb->cw_idx], tb->nof_bits); - if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_DEBUG && !handler_registered) { + if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_DEBUG && !handler_registered) { DEBUG("d="); - srslte_vec_fprint_c(stdout, q->d[tb->cw_idx], tb->nof_re); + srsran_vec_fprint_c(stdout, q->d[tb->cw_idx], tb->nof_re); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_pdsch_nr_encode(srslte_pdsch_nr_t* q, - const srslte_sch_cfg_nr_t* cfg, - const srslte_sch_grant_nr_t* grant, - uint8_t* data[SRSLTE_MAX_TB], - cf_t* sf_symbols[SRSLTE_MAX_PORTS]) +int srsran_pdsch_nr_encode(srsran_pdsch_nr_t* q, + const srsran_sch_cfg_nr_t* cfg, + const srsran_sch_grant_nr_t* grant, + uint8_t* data[SRSRAN_MAX_TB], + cf_t* sf_symbols[SRSRAN_MAX_PORTS]) { // Check input pointers if (!q || !cfg || !grant || !data || !sf_symbols) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } struct timeval t[3]; @@ -484,17 +484,17 @@ int srslte_pdsch_nr_encode(srslte_pdsch_nr_t* q, // Check number of layers if (q->max_layers < grant->nof_layers) { ERROR("Error number of layers (%d) exceeds configured maximum (%d)", grant->nof_layers, q->max_layers); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // 7.3.1.1 and 7.3.1.2 uint32_t nof_cw = 0; - for (uint32_t tb = 0; tb < SRSLTE_MAX_TB; tb++) { + for (uint32_t tb = 0; tb < SRSRAN_MAX_TB; tb++) { nof_cw += grant->tb[tb].enabled ? 1 : 0; - if (pdsch_nr_encode_codeword(q, cfg, &grant->tb[tb], data[tb], grant->rnti) < SRSLTE_SUCCESS) { + if (pdsch_nr_encode_codeword(q, cfg, &grant->tb[tb], data[tb], grant->rnti) < SRSRAN_SUCCESS) { ERROR("Error encoding TB %d", tb); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } @@ -502,7 +502,7 @@ int srslte_pdsch_nr_encode(srslte_pdsch_nr_t* q, cf_t** x = q->d; if (grant->nof_layers > 1) { x = q->x; - srslte_layermap_nr(q->d, nof_cw, x, grant->nof_layers, grant->nof_layers); + srsran_layermap_nr(q->d, nof_cw, x, grant->nof_layers, grant->nof_layers); } // 7.3.1.4 Antenna port mapping @@ -512,15 +512,15 @@ int srslte_pdsch_nr_encode(srslte_pdsch_nr_t* q, // ... Not implemented // 7.3.1.6 Mapping from virtual to physical resource blocks - int n = srslte_pdsch_nr_put(q, cfg, grant, x[0], sf_symbols[0]); - if (n < SRSLTE_SUCCESS) { + int n = srsran_pdsch_nr_put(q, cfg, grant, x[0], sf_symbols[0]); + if (n < SRSRAN_SUCCESS) { ERROR("Putting NR PDSCH resources"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (n != grant->tb[0].nof_re) { ERROR("Unmatched number of RE (%d != %d)", n, grant->tb[0].nof_re); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (q->meas_time_en) { @@ -529,46 +529,46 @@ int srslte_pdsch_nr_encode(srslte_pdsch_nr_t* q, q->meas_time_us = (uint32_t)t[0].tv_usec; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -static inline int pdsch_nr_decode_codeword(srslte_pdsch_nr_t* q, - const srslte_sch_cfg_nr_t* cfg, - const srslte_sch_tb_t* tb, - srslte_pdsch_res_nr_t* res, +static inline int pdsch_nr_decode_codeword(srsran_pdsch_nr_t* q, + const srsran_sch_cfg_nr_t* cfg, + const srsran_sch_tb_t* tb, + srsran_pdsch_res_nr_t* res, uint16_t rnti) { // Early return if TB is not enabled if (!tb->enabled) { - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Check codeword index if (tb->cw_idx >= q->max_cw) { ERROR("Unsupported codeword index %d", tb->cw_idx); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Check modulation - if (tb->mod >= SRSLTE_MOD_NITEMS) { - ERROR("Invalid modulation %s", srslte_mod_string(tb->mod)); - return SRSLTE_ERROR_OUT_OF_BOUNDS; + if (tb->mod >= SRSRAN_MOD_NITEMS) { + ERROR("Invalid modulation %s", srsran_mod_string(tb->mod)); + return SRSRAN_ERROR_OUT_OF_BOUNDS; } - if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_DEBUG && !handler_registered) { + if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_DEBUG && !handler_registered) { DEBUG("d="); - srslte_vec_fprint_c(stdout, q->d[tb->cw_idx], tb->nof_re); + srsran_vec_fprint_c(stdout, q->d[tb->cw_idx], tb->nof_re); } // Demodulation int8_t* llr = (int8_t*)q->b[tb->cw_idx]; - if (srslte_demod_soft_demodulate_b(tb->mod, q->d[tb->cw_idx], llr, tb->nof_re)) { - return SRSLTE_ERROR; + if (srsran_demod_soft_demodulate_b(tb->mod, q->d[tb->cw_idx], llr, tb->nof_re)) { + return SRSRAN_ERROR; } // EVM if (q->evm_buffer != NULL) { - res->evm = srslte_evm_run_b(q->evm_buffer, &q->modem_tables[tb->mod], q->d[tb->cw_idx], llr, tb->nof_bits); + res->evm = srsran_evm_run_b(q->evm_buffer, &q->modem_tables[tb->mod], q->d[tb->cw_idx], llr, tb->nof_bits); } // Change LLR sign @@ -577,32 +577,32 @@ static inline int pdsch_nr_decode_codeword(srslte_pdsch_nr_t* q, } // Descrambling - srslte_sequence_apply_c(llr, llr, tb->nof_bits, pdsch_nr_cinit(&q->carrier, cfg, rnti, tb->cw_idx)); + srsran_sequence_apply_c(llr, llr, tb->nof_bits, pdsch_nr_cinit(&q->carrier, cfg, rnti, tb->cw_idx)); - if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_DEBUG && !handler_registered) { + if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_DEBUG && !handler_registered) { DEBUG("b="); - srslte_vec_fprint_b(stdout, q->b[tb->cw_idx], tb->nof_bits); + srsran_vec_fprint_b(stdout, q->b[tb->cw_idx], tb->nof_bits); } // Decode SCH - if (srslte_dlsch_nr_decode(&q->sch, &cfg->sch_cfg, tb, llr, res->payload, &res->crc) < SRSLTE_SUCCESS) { + if (srsran_dlsch_nr_decode(&q->sch, &cfg->sch_cfg, tb, llr, res->payload, &res->crc) < SRSRAN_SUCCESS) { ERROR("Error in DL-SCH encoding"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_pdsch_nr_decode(srslte_pdsch_nr_t* q, - const srslte_sch_cfg_nr_t* cfg, - const srslte_sch_grant_nr_t* grant, - srslte_chest_dl_res_t* channel, - cf_t* sf_symbols[SRSLTE_MAX_PORTS], - srslte_pdsch_res_nr_t data[SRSLTE_MAX_TB]) +int srsran_pdsch_nr_decode(srsran_pdsch_nr_t* q, + const srsran_sch_cfg_nr_t* cfg, + const srsran_sch_grant_nr_t* grant, + srsran_chest_dl_res_t* channel, + cf_t* sf_symbols[SRSRAN_MAX_PORTS], + srsran_pdsch_res_nr_t data[SRSRAN_MAX_TB]) { // Check input pointers if (!q || !cfg || !grant || !data || !sf_symbols) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } struct timeval t[3]; @@ -611,29 +611,29 @@ int srslte_pdsch_nr_decode(srslte_pdsch_nr_t* q, } uint32_t nof_cw = 0; - for (uint32_t tb = 0; tb < SRSLTE_MAX_TB; tb++) { + for (uint32_t tb = 0; tb < SRSRAN_MAX_TB; tb++) { nof_cw += grant->tb[tb].enabled ? 1 : 0; } - uint32_t nof_re = srslte_ra_dl_nr_slot_nof_re(cfg, grant); + uint32_t nof_re = srsran_ra_dl_nr_slot_nof_re(cfg, grant); if (channel->nof_re != nof_re) { ERROR("Inconsistent number of RE (%d!=%d)", channel->nof_re, nof_re); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Demapping from virtual to physical resource blocks - uint32_t nof_re_get = srslte_pdsch_nr_get(q, cfg, grant, q->x[0], sf_symbols[0]); + uint32_t nof_re_get = srsran_pdsch_nr_get(q, cfg, grant, q->x[0], sf_symbols[0]); if (nof_re_get != nof_re) { ERROR("Inconsistent number of RE (%d!=%d)", nof_re_get, nof_re); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_DEBUG && !handler_registered) { + if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_DEBUG && !handler_registered) { DEBUG("ce="); - srslte_vec_fprint_c(stdout, channel->ce[0][0], nof_re); + srsran_vec_fprint_c(stdout, channel->ce[0][0], nof_re); DEBUG("x="); - srslte_vec_fprint_c(stdout, q->x[0], nof_re); + srsran_vec_fprint_c(stdout, q->x[0], nof_re); } // Demapping to virtual resource blocks @@ -641,21 +641,21 @@ int srslte_pdsch_nr_decode(srslte_pdsch_nr_t* q, // Antenna port demapping // ... Not implemented - srslte_predecoding_type( - q->x, channel->ce, q->d, NULL, 1, 1, 1, 0, nof_re, SRSLTE_TXSCHEME_PORT0, 1.0f, channel->noise_estimate); + srsran_predecoding_type( + q->x, channel->ce, q->d, NULL, 1, 1, 1, 0, nof_re, SRSRAN_TXSCHEME_PORT0, 1.0f, channel->noise_estimate); // Layer demapping if (grant->nof_layers > 1) { - srslte_layerdemap_nr(q->d, nof_cw, q->x, grant->nof_layers, nof_re); + srsran_layerdemap_nr(q->d, nof_cw, q->x, grant->nof_layers, nof_re); } // SCH decode - for (uint32_t tb = 0; tb < SRSLTE_MAX_TB; tb++) { + for (uint32_t tb = 0; tb < SRSRAN_MAX_TB; tb++) { nof_cw += grant->tb[tb].enabled ? 1 : 0; - if (pdsch_nr_decode_codeword(q, cfg, &grant->tb[tb], &data[tb], grant->rnti) < SRSLTE_SUCCESS) { + if (pdsch_nr_decode_codeword(q, cfg, &grant->tb[tb], &data[tb], grant->rnti) < SRSRAN_SUCCESS) { ERROR("Error encoding TB %d", tb); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } @@ -665,26 +665,26 @@ int srslte_pdsch_nr_decode(srslte_pdsch_nr_t* q, q->meas_time_us = (uint32_t)t[0].tv_usec; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -static uint32_t srslte_pdsch_nr_grant_info(const srslte_sch_cfg_nr_t* cfg, - const srslte_sch_grant_nr_t* grant, +static uint32_t srsran_pdsch_nr_grant_info(const srsran_sch_cfg_nr_t* cfg, + const srsran_sch_grant_nr_t* grant, char* str, uint32_t str_len) { uint32_t len = 0; - len = srslte_print_check(str, str_len, len, "rnti=0x%x", grant->rnti); + len = srsran_print_check(str, str_len, len, "rnti=0x%x", grant->rnti); - uint32_t first_prb = SRSLTE_MAX_PRB_NR; - for (uint32_t i = 0; i < SRSLTE_MAX_PRB_NR && first_prb == SRSLTE_MAX_PRB_NR; i++) { + uint32_t first_prb = SRSRAN_MAX_PRB_NR; + for (uint32_t i = 0; i < SRSRAN_MAX_PRB_NR && first_prb == SRSRAN_MAX_PRB_NR; i++) { if (grant->prb_idx[i]) { first_prb = i; } } // Append time-domain resource mapping - len = srslte_print_check(str, + len = srsran_print_check(str, str_len, len, ",k0=%d,prb=%d:%d,symb=%d:%d,mapping=%s", @@ -693,85 +693,85 @@ static uint32_t srslte_pdsch_nr_grant_info(const srslte_sch_cfg_nr_t* cfg, grant->nof_prb, grant->S, grant->L, - srslte_sch_mapping_type_to_str(grant->mapping)); + srsran_sch_mapping_type_to_str(grant->mapping)); // Skip frequency domain resources... // ... // Append spatial resources - len = srslte_print_check(str, str_len, len, ",Nl=%d", grant->nof_layers); + len = srsran_print_check(str, str_len, len, ",Nl=%d", grant->nof_layers); // Append scrambling ID - len = srslte_print_check(str, str_len, len, ",n_scid=%d,", grant->n_scid); + len = srsran_print_check(str, str_len, len, ",n_scid=%d,", grant->n_scid); // Append TB info - for (uint32_t i = 0; i < SRSLTE_MAX_TB; i++) { - len += srslte_sch_nr_tb_info(&grant->tb[i], &str[len], str_len - len); + for (uint32_t i = 0; i < SRSRAN_MAX_TB; i++) { + len += srsran_sch_nr_tb_info(&grant->tb[i], &str[len], str_len - len); } return len; } -uint32_t srslte_pdsch_nr_rx_info(const srslte_pdsch_nr_t* q, - const srslte_sch_cfg_nr_t* cfg, - const srslte_sch_grant_nr_t* grant, - const srslte_pdsch_res_nr_t res[SRSLTE_MAX_CODEWORDS], +uint32_t srsran_pdsch_nr_rx_info(const srsran_pdsch_nr_t* q, + const srsran_sch_cfg_nr_t* cfg, + const srsran_sch_grant_nr_t* grant, + const srsran_pdsch_res_nr_t res[SRSRAN_MAX_CODEWORDS], char* str, uint32_t str_len) { uint32_t len = 0; - len += srslte_pdsch_nr_grant_info(cfg, grant, &str[len], str_len - len); + len += srsran_pdsch_nr_grant_info(cfg, grant, &str[len], str_len - len); if (q->evm_buffer != NULL) { - len = srslte_print_check(str, str_len, len, ",evm={", 0); - for (uint32_t i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { + len = srsran_print_check(str, str_len, len, ",evm={", 0); + for (uint32_t i = 0; i < SRSRAN_MAX_CODEWORDS; i++) { if (grant->tb[i].enabled && !isnan(res[i].evm)) { - len = srslte_print_check(str, str_len, len, "%.2f", res[i].evm); - if (i < SRSLTE_MAX_CODEWORDS - 1) { + len = srsran_print_check(str, str_len, len, "%.2f", res[i].evm); + if (i < SRSRAN_MAX_CODEWORDS - 1) { if (grant->tb[i + 1].enabled) { - len = srslte_print_check(str, str_len, len, ",", 0); + len = srsran_print_check(str, str_len, len, ",", 0); } } } } - len = srslte_print_check(str, str_len, len, "}", 0); + len = srsran_print_check(str, str_len, len, "}", 0); } if (res != NULL) { - len = srslte_print_check(str, str_len, len, ",crc={", 0); - for (uint32_t i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { + len = srsran_print_check(str, str_len, len, ",crc={", 0); + for (uint32_t i = 0; i < SRSRAN_MAX_CODEWORDS; i++) { if (grant->tb[i].enabled) { - len = srslte_print_check(str, str_len, len, "%s", res[i].crc ? "OK" : "KO"); - if (i < SRSLTE_MAX_CODEWORDS - 1) { + len = srsran_print_check(str, str_len, len, "%s", res[i].crc ? "OK" : "KO"); + if (i < SRSRAN_MAX_CODEWORDS - 1) { if (grant->tb[i + 1].enabled) { - len = srslte_print_check(str, str_len, len, ",", 0); + len = srsran_print_check(str, str_len, len, ",", 0); } } } } - len = srslte_print_check(str, str_len, len, "}", 0); + len = srsran_print_check(str, str_len, len, "}", 0); } if (q->meas_time_en) { - len = srslte_print_check(str, str_len, len, ", t=%d us", q->meas_time_us); + len = srsran_print_check(str, str_len, len, ", t=%d us", q->meas_time_us); } return len; } -uint32_t srslte_pdsch_nr_tx_info(const srslte_pdsch_nr_t* q, - const srslte_sch_cfg_nr_t* cfg, - const srslte_sch_grant_nr_t* grant, +uint32_t srsran_pdsch_nr_tx_info(const srsran_pdsch_nr_t* q, + const srsran_sch_cfg_nr_t* cfg, + const srsran_sch_grant_nr_t* grant, char* str, uint32_t str_len) { uint32_t len = 0; - len += srslte_pdsch_nr_grant_info(cfg, grant, &str[len], str_len - len); + len += srsran_pdsch_nr_grant_info(cfg, grant, &str[len], str_len - len); if (q->meas_time_en) { - len = srslte_print_check(str, str_len, len, ", t=%d us", q->meas_time_us); + len = srsran_print_check(str, str_len, len, ", t=%d us", q->meas_time_us); } return len; diff --git a/lib/src/phy/phch/phich.c b/lib/src/phy/phch/phich.c index f71980c61..66b424f0b 100644 --- a/lib/src/phy/phch/phich.c +++ b/lib/src/phy/phch/phich.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -20,15 +20,15 @@ #include #include -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/phch/phich.h" -#include "srslte/phy/phch/regs.h" -#include "srslte/phy/utils/bit.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/phch/phich.h" +#include "srsran/phy/phch/regs.h" +#include "srsran/phy/utils/bit.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" /** Table 6.9.1-2 */ -const cf_t w_normal[SRSLTE_PHICH_NORM_NSEQUENCES][4] = {{1, 1, 1, 1}, +const cf_t w_normal[SRSRAN_PHICH_NORM_NSEQUENCES][4] = {{1, 1, 1, 1}, {1, -1, 1, -1}, {1, 1, -1, -1}, {1, -1, -1, 1}, @@ -36,96 +36,96 @@ const cf_t w_normal[SRSLTE_PHICH_NORM_NSEQUENCES][4] = {{1, 1, 1, 1}, {I, -I, I, -I}, {I, I, -I, -I}, {I, -I, -I, I}}; -const cf_t w_ext[SRSLTE_PHICH_EXT_NSEQUENCES][2] = {{1, 1}, {1, -1}, {I, I}, {I, -I}}; +const cf_t w_ext[SRSRAN_PHICH_EXT_NSEQUENCES][2] = {{1, 1}, {1, -1}, {I, I}, {I, -I}}; -uint32_t srslte_phich_ngroups(srslte_phich_t* q) +uint32_t srsran_phich_ngroups(srsran_phich_t* q) { - return srslte_regs_phich_ngroups(q->regs); + return srsran_regs_phich_ngroups(q->regs); } -uint32_t srslte_phich_nsf(srslte_phich_t* q) +uint32_t srsran_phich_nsf(srsran_phich_t* q) { - if (SRSLTE_CP_ISNORM(q->cell.cp)) { - return SRSLTE_PHICH_NORM_NSF; + if (SRSRAN_CP_ISNORM(q->cell.cp)) { + return SRSRAN_PHICH_NORM_NSF; } else { - return SRSLTE_PHICH_EXT_NSF; + return SRSRAN_PHICH_EXT_NSF; } } -void srslte_phich_reset(srslte_phich_t* q, cf_t* slot_symbols[SRSLTE_MAX_PORTS]) +void srsran_phich_reset(srsran_phich_t* q, cf_t* slot_symbols[SRSRAN_MAX_PORTS]) { int i; - for (i = 0; i < SRSLTE_MAX_PORTS; i++) { - srslte_regs_phich_reset(q->regs, slot_symbols[i]); + for (i = 0; i < SRSRAN_MAX_PORTS; i++) { + srsran_regs_phich_reset(q->regs, slot_symbols[i]); } } /** Initializes the phich channel receiver */ -int srslte_phich_init(srslte_phich_t* q, uint32_t nof_rx_antennas) +int srsran_phich_init(srsran_phich_t* q, uint32_t nof_rx_antennas) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL) { - bzero(q, sizeof(srslte_phich_t)); - ret = SRSLTE_ERROR; + bzero(q, sizeof(srsran_phich_t)); + ret = SRSRAN_ERROR; q->nof_rx_antennas = nof_rx_antennas; - if (srslte_modem_table_lte(&q->mod, SRSLTE_MOD_BPSK)) { + if (srsran_modem_table_lte(&q->mod, SRSRAN_MOD_BPSK)) { goto clean; } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } clean: - if (ret == SRSLTE_ERROR) { - srslte_phich_free(q); + if (ret == SRSRAN_ERROR) { + srsran_phich_free(q); } return ret; } -void srslte_phich_free(srslte_phich_t* q) +void srsran_phich_free(srsran_phich_t* q) { - for (int ns = 0; ns < SRSLTE_NOF_SF_X_FRAME; ns++) { - srslte_sequence_free(&q->seq[ns]); + for (int ns = 0; ns < SRSRAN_NOF_SF_X_FRAME; ns++) { + srsran_sequence_free(&q->seq[ns]); } - srslte_modem_table_free(&q->mod); + srsran_modem_table_free(&q->mod); - bzero(q, sizeof(srslte_phich_t)); + bzero(q, sizeof(srsran_phich_t)); } -void srslte_phich_set_regs(srslte_phich_t* q, srslte_regs_t* regs) +void srsran_phich_set_regs(srsran_phich_t* q, srsran_regs_t* regs) { q->regs = regs; } -int srslte_phich_set_cell(srslte_phich_t* q, srslte_regs_t* regs, srslte_cell_t cell) +int srsran_phich_set_cell(srsran_phich_t* q, srsran_regs_t* regs, srsran_cell_t cell) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; - if (q != NULL && regs != NULL && srslte_cell_isvalid(&cell)) { + if (q != NULL && regs != NULL && srsran_cell_isvalid(&cell)) { q->regs = regs; if (cell.id != q->cell.id || q->cell.nof_prb == 0) { q->cell = cell; - for (int nsf = 0; nsf < SRSLTE_NOF_SF_X_FRAME; nsf++) { - if (srslte_sequence_phich(&q->seq[nsf], 2 * nsf, q->cell.id)) { - return SRSLTE_ERROR; + for (int nsf = 0; nsf < SRSRAN_NOF_SF_X_FRAME; nsf++) { + if (srsran_sequence_phich(&q->seq[nsf], 2 * nsf, q->cell.id)) { + return SRSRAN_ERROR; } } } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } /* Computes n_group and n_seq according to Section 9.1.2 in 36.213 */ -void srslte_phich_calc(srslte_phich_t* q, srslte_phich_grant_t* grant, srslte_phich_resource_t* n_phich) +void srsran_phich_calc(srsran_phich_t* q, srsran_phich_grant_t* grant, srsran_phich_resource_t* n_phich) { - uint32_t Ngroups = srslte_regs_phich_ngroups_m1(q->regs); + uint32_t Ngroups = srsran_regs_phich_ngroups_m1(q->regs); if (Ngroups) { if (n_phich) { n_phich->ngroup = (grant->n_prb_lowest + grant->n_dmrs) % Ngroups + grant->I_phich * Ngroups; - n_phich->nseq = ((grant->n_prb_lowest / Ngroups) + grant->n_dmrs) % (2 * srslte_phich_nsf(q)); + n_phich->nseq = ((grant->n_prb_lowest / Ngroups) + grant->n_dmrs) % (2 * srsran_phich_nsf(q)); } } else { ERROR("PHICH: Error computing PHICH groups. Ngroups is zero"); @@ -135,20 +135,20 @@ void srslte_phich_calc(srslte_phich_t* q, srslte_phich_grant_t* grant, srslte_ph /* Decodes ACK * */ -uint8_t srslte_phich_ack_decode(float bits[SRSLTE_PHICH_NBITS], float* distance) +uint8_t srsran_phich_ack_decode(float bits[SRSRAN_PHICH_NBITS], float* distance) { int i; float ack_table[2][3] = {{-1.0, -1.0, -1.0}, {1.0, 1.0, 1.0}}; float max_corr = -9999; uint8_t index = 0; - if (SRSLTE_VERBOSE_ISINFO()) { + if (SRSRAN_VERBOSE_ISINFO()) { INFO("Received bits: "); - srslte_vec_fprint_f(stdout, bits, SRSLTE_PHICH_NBITS); + srsran_vec_fprint_f(stdout, bits, SRSRAN_PHICH_NBITS); } for (i = 0; i < 2; i++) { - float corr = srslte_vec_dot_prod_fff(ack_table[i], bits, SRSLTE_PHICH_NBITS) / SRSLTE_PHICH_NBITS; + float corr = srsran_vec_dot_prod_fff(ack_table[i], bits, SRSRAN_PHICH_NBITS) / SRSRAN_PHICH_NBITS; INFO("Corr%d=%f", i, corr); if (corr > max_corr) { max_corr = corr; @@ -164,72 +164,72 @@ uint8_t srslte_phich_ack_decode(float bits[SRSLTE_PHICH_NBITS], float* distance) /** Encodes the ACK * 36.212 */ -void srslte_phich_ack_encode(uint8_t ack, uint8_t bits[SRSLTE_PHICH_NBITS]) +void srsran_phich_ack_encode(uint8_t ack, uint8_t bits[SRSRAN_PHICH_NBITS]) { memset(bits, ack, 3 * sizeof(uint8_t)); } -int srslte_phich_decode(srslte_phich_t* q, - srslte_dl_sf_cfg_t* sf, - srslte_chest_dl_res_t* channel, - srslte_phich_resource_t n_phich, - cf_t* sf_symbols[SRSLTE_MAX_PORTS], - srslte_phich_res_t* result) +int srsran_phich_decode(srsran_phich_t* q, + srsran_dl_sf_cfg_t* sf, + srsran_chest_dl_res_t* channel, + srsran_phich_resource_t n_phich, + cf_t* sf_symbols[SRSRAN_MAX_PORTS], + srsran_phich_res_t* result) { /* Set pointers for layermapping & precoding */ int i, j; - cf_t* x[SRSLTE_MAX_LAYERS]; + cf_t* x[SRSRAN_MAX_LAYERS]; if (q == NULL || sf_symbols == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } uint32_t sf_idx = sf->tti % 10; - if (sf_idx >= SRSLTE_NOF_SF_X_FRAME) { + if (sf_idx >= SRSRAN_NOF_SF_X_FRAME) { ERROR("Invalid nslot %d", sf_idx); - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } - if (SRSLTE_CP_ISEXT(q->cell.cp)) { - if (n_phich.nseq >= SRSLTE_PHICH_EXT_NSEQUENCES) { + if (SRSRAN_CP_ISEXT(q->cell.cp)) { + if (n_phich.nseq >= SRSRAN_PHICH_EXT_NSEQUENCES) { ERROR("Invalid nseq %d", n_phich.nseq); - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } } else { - if (n_phich.nseq >= SRSLTE_PHICH_NORM_NSEQUENCES) { + if (n_phich.nseq >= SRSRAN_PHICH_NORM_NSEQUENCES) { ERROR("Invalid nseq %d", n_phich.nseq); - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } } - if (n_phich.ngroup >= srslte_regs_phich_ngroups(q->regs)) { + if (n_phich.ngroup >= srsran_regs_phich_ngroups(q->regs)) { ERROR("Invalid ngroup %d", n_phich.ngroup); - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } DEBUG("Decoding PHICH Ngroup: %d, Nseq: %d", n_phich.ngroup, n_phich.nseq); /* number of layers equals number of ports */ - for (i = 0; i < SRSLTE_MAX_PORTS; i++) { + for (i = 0; i < SRSRAN_MAX_PORTS; i++) { x[i] = q->x[i]; } - cf_t* q_ce[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS]; - cf_t* q_sf_symbols[SRSLTE_MAX_PORTS]; + cf_t* q_ce[SRSRAN_MAX_PORTS][SRSRAN_MAX_PORTS]; + cf_t* q_sf_symbols[SRSRAN_MAX_PORTS]; /* extract symbols */ for (int j = 0; j < q->nof_rx_antennas; j++) { - if (SRSLTE_PHICH_MAX_NSYMB != srslte_regs_phich_get(q->regs, sf_symbols[j], q->sf_symbols[j], n_phich.ngroup)) { + if (SRSRAN_PHICH_MAX_NSYMB != srsran_regs_phich_get(q->regs, sf_symbols[j], q->sf_symbols[j], n_phich.ngroup)) { ERROR("There was an error getting the phich symbols"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } q_sf_symbols[j] = q->sf_symbols[j]; /* extract channel estimates */ for (i = 0; i < q->cell.nof_ports; i++) { - if (SRSLTE_PHICH_MAX_NSYMB != srslte_regs_phich_get(q->regs, channel->ce[i][j], q->ce[i][j], n_phich.ngroup)) { + if (SRSRAN_PHICH_MAX_NSYMB != srsran_regs_phich_get(q->regs, channel->ce[i][j], q->ce[i][j], n_phich.ngroup)) { ERROR("There was an error getting the phich symbols"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } q_ce[i][j] = q->ce[i][j]; } @@ -238,157 +238,157 @@ int srslte_phich_decode(srslte_phich_t* q, /* in control channels, only diversity is supported */ if (q->cell.nof_ports == 1) { /* no need for layer demapping */ - srslte_predecoding_single_multi( - q_sf_symbols, q_ce[0], q->d0, NULL, q->nof_rx_antennas, SRSLTE_PHICH_MAX_NSYMB, 1.0f, channel->noise_estimate); + srsran_predecoding_single_multi( + q_sf_symbols, q_ce[0], q->d0, NULL, q->nof_rx_antennas, SRSRAN_PHICH_MAX_NSYMB, 1.0f, channel->noise_estimate); } else { - srslte_predecoding_diversity_multi( - q_sf_symbols, q_ce, x, NULL, q->nof_rx_antennas, q->cell.nof_ports, SRSLTE_PHICH_MAX_NSYMB, 1.0f); - srslte_layerdemap_diversity(x, q->d0, q->cell.nof_ports, SRSLTE_PHICH_MAX_NSYMB / q->cell.nof_ports); + srsran_predecoding_diversity_multi( + q_sf_symbols, q_ce, x, NULL, q->nof_rx_antennas, q->cell.nof_ports, SRSRAN_PHICH_MAX_NSYMB, 1.0f); + srsran_layerdemap_diversity(x, q->d0, q->cell.nof_ports, SRSRAN_PHICH_MAX_NSYMB / q->cell.nof_ports); } DEBUG("Recv!!: "); DEBUG("d0: "); - if (SRSLTE_VERBOSE_ISDEBUG()) - srslte_vec_fprint_c(stdout, q->d0, SRSLTE_PHICH_MAX_NSYMB); + if (SRSRAN_VERBOSE_ISDEBUG()) + srsran_vec_fprint_c(stdout, q->d0, SRSRAN_PHICH_MAX_NSYMB); - if (SRSLTE_CP_ISEXT(q->cell.cp)) { + if (SRSRAN_CP_ISEXT(q->cell.cp)) { if (n_phich.ngroup % 2) { - for (i = 0; i < SRSLTE_PHICH_EXT_MSYMB / 2; i++) { + for (i = 0; i < SRSRAN_PHICH_EXT_MSYMB / 2; i++) { q->d[2 * i + 0] = q->d0[4 * i + 2]; q->d[2 * i + 1] = q->d0[4 * i + 3]; } } else { - for (i = 0; i < SRSLTE_PHICH_EXT_MSYMB / 2; i++) { + for (i = 0; i < SRSRAN_PHICH_EXT_MSYMB / 2; i++) { q->d[2 * i + 0] = q->d0[4 * i]; q->d[2 * i + 1] = q->d0[4 * i + 1]; } } } else { - memcpy(q->d, q->d0, SRSLTE_PHICH_MAX_NSYMB * sizeof(cf_t)); + memcpy(q->d, q->d0, SRSRAN_PHICH_MAX_NSYMB * sizeof(cf_t)); } DEBUG("d: "); - if (SRSLTE_VERBOSE_ISDEBUG()) - srslte_vec_fprint_c(stdout, q->d, SRSLTE_PHICH_EXT_MSYMB); + if (SRSRAN_VERBOSE_ISDEBUG()) + srsran_vec_fprint_c(stdout, q->d, SRSRAN_PHICH_EXT_MSYMB); - srslte_scrambling_c(&q->seq[sf_idx], q->d); + srsran_scrambling_c(&q->seq[sf_idx], q->d); /* De-spreading */ - if (SRSLTE_CP_ISEXT(q->cell.cp)) { - for (i = 0; i < SRSLTE_PHICH_NBITS; i++) { + if (SRSRAN_CP_ISEXT(q->cell.cp)) { + for (i = 0; i < SRSRAN_PHICH_NBITS; i++) { q->z[i] = 0; - for (j = 0; j < SRSLTE_PHICH_EXT_NSF; j++) { - q->z[i] += conjf(w_ext[n_phich.nseq][j]) * q->d[i * SRSLTE_PHICH_EXT_NSF + j] / SRSLTE_PHICH_EXT_NSF; + for (j = 0; j < SRSRAN_PHICH_EXT_NSF; j++) { + q->z[i] += conjf(w_ext[n_phich.nseq][j]) * q->d[i * SRSRAN_PHICH_EXT_NSF + j] / SRSRAN_PHICH_EXT_NSF; } } } else { - for (i = 0; i < SRSLTE_PHICH_NBITS; i++) { + for (i = 0; i < SRSRAN_PHICH_NBITS; i++) { q->z[i] = 0; - for (j = 0; j < SRSLTE_PHICH_NORM_NSF; j++) { - q->z[i] += conjf(w_normal[n_phich.nseq][j]) * q->d[i * SRSLTE_PHICH_NORM_NSF + j] / SRSLTE_PHICH_NORM_NSF; + for (j = 0; j < SRSRAN_PHICH_NORM_NSF; j++) { + q->z[i] += conjf(w_normal[n_phich.nseq][j]) * q->d[i * SRSRAN_PHICH_NORM_NSF + j] / SRSRAN_PHICH_NORM_NSF; } } } DEBUG("z: "); - if (SRSLTE_VERBOSE_ISDEBUG()) - srslte_vec_fprint_c(stdout, q->z, SRSLTE_PHICH_NBITS); + if (SRSRAN_VERBOSE_ISDEBUG()) + srsran_vec_fprint_c(stdout, q->z, SRSRAN_PHICH_NBITS); - srslte_demod_soft_demodulate(SRSLTE_MOD_BPSK, q->z, q->data_rx, SRSLTE_PHICH_NBITS); + srsran_demod_soft_demodulate(SRSRAN_MOD_BPSK, q->z, q->data_rx, SRSRAN_PHICH_NBITS); if (result) { - result->ack_value = srslte_phich_ack_decode(q->data_rx, &result->distance); + result->ack_value = srsran_phich_ack_decode(q->data_rx, &result->distance); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } /** Encodes ACK/NACK bits, modulates and inserts into resource. - * The parameter ack is an array of srslte_phich_ngroups() pointers to buffers of nof_sequences uint8_ts + * The parameter ack is an array of srsran_phich_ngroups() pointers to buffers of nof_sequences uint8_ts */ -int srslte_phich_encode(srslte_phich_t* q, - srslte_dl_sf_cfg_t* sf, - srslte_phich_resource_t n_phich, +int srsran_phich_encode(srsran_phich_t* q, + srsran_dl_sf_cfg_t* sf, + srsran_phich_resource_t n_phich, uint8_t ack, - cf_t* sf_symbols[SRSLTE_MAX_PORTS]) + cf_t* sf_symbols[SRSRAN_MAX_PORTS]) { int i; if (q == NULL || sf_symbols == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } uint32_t sf_idx = sf->tti % 10; - if (sf_idx >= SRSLTE_NOF_SF_X_FRAME) { + if (sf_idx >= SRSRAN_NOF_SF_X_FRAME) { ERROR("Invalid nslot %d", sf_idx); - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } - if (SRSLTE_CP_ISEXT(q->cell.cp)) { - if (n_phich.nseq >= SRSLTE_PHICH_EXT_NSEQUENCES) { + if (SRSRAN_CP_ISEXT(q->cell.cp)) { + if (n_phich.nseq >= SRSRAN_PHICH_EXT_NSEQUENCES) { ERROR("Invalid nseq %d", n_phich.nseq); - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } } else { - if (n_phich.nseq >= SRSLTE_PHICH_NORM_NSEQUENCES) { + if (n_phich.nseq >= SRSRAN_PHICH_NORM_NSEQUENCES) { ERROR("Invalid nseq %d", n_phich.nseq); - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } } - if (n_phich.ngroup >= srslte_regs_phich_ngroups(q->regs)) { + if (n_phich.ngroup >= srsran_regs_phich_ngroups(q->regs)) { ERROR("Invalid ngroup %d", n_phich.ngroup); - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } /* Set pointers for layermapping & precoding */ - cf_t* x[SRSLTE_MAX_LAYERS]; - cf_t* symbols_precoding[SRSLTE_MAX_PORTS]; + cf_t* x[SRSRAN_MAX_LAYERS]; + cf_t* symbols_precoding[SRSRAN_MAX_PORTS]; /* number of layers equals number of ports */ for (i = 0; i < q->cell.nof_ports; i++) { x[i] = q->x[i]; } - for (i = 0; i < SRSLTE_MAX_PORTS; i++) { + for (i = 0; i < SRSRAN_MAX_PORTS; i++) { symbols_precoding[i] = q->sf_symbols[i]; } /* encode ACK/NACK bit */ - srslte_phich_ack_encode(ack, q->data); + srsran_phich_ack_encode(ack, q->data); - srslte_mod_modulate(&q->mod, q->data, q->z, SRSLTE_PHICH_NBITS); + srsran_mod_modulate(&q->mod, q->data, q->z, SRSRAN_PHICH_NBITS); DEBUG("data: "); - if (SRSLTE_VERBOSE_ISDEBUG()) - srslte_vec_fprint_c(stdout, q->z, SRSLTE_PHICH_NBITS); + if (SRSRAN_VERBOSE_ISDEBUG()) + srsran_vec_fprint_c(stdout, q->z, SRSRAN_PHICH_NBITS); /* Spread with w */ - if (SRSLTE_CP_ISEXT(q->cell.cp)) { - for (i = 0; i < SRSLTE_PHICH_EXT_MSYMB; i++) { - q->d[i] = w_ext[n_phich.nseq][i % SRSLTE_PHICH_EXT_NSF] * q->z[i / SRSLTE_PHICH_EXT_NSF]; + if (SRSRAN_CP_ISEXT(q->cell.cp)) { + for (i = 0; i < SRSRAN_PHICH_EXT_MSYMB; i++) { + q->d[i] = w_ext[n_phich.nseq][i % SRSRAN_PHICH_EXT_NSF] * q->z[i / SRSRAN_PHICH_EXT_NSF]; } } else { - for (i = 0; i < SRSLTE_PHICH_NORM_MSYMB; i++) { - q->d[i] = w_normal[n_phich.nseq][i % SRSLTE_PHICH_NORM_NSF] * q->z[i / SRSLTE_PHICH_NORM_NSF]; + for (i = 0; i < SRSRAN_PHICH_NORM_MSYMB; i++) { + q->d[i] = w_normal[n_phich.nseq][i % SRSRAN_PHICH_NORM_NSF] * q->z[i / SRSRAN_PHICH_NORM_NSF]; } } DEBUG("d: "); - if (SRSLTE_VERBOSE_ISDEBUG()) - srslte_vec_fprint_c(stdout, q->d, SRSLTE_PHICH_EXT_MSYMB); + if (SRSRAN_VERBOSE_ISDEBUG()) + srsran_vec_fprint_c(stdout, q->d, SRSRAN_PHICH_EXT_MSYMB); - srslte_scrambling_c(&q->seq[sf_idx], q->d); + srsran_scrambling_c(&q->seq[sf_idx], q->d); /* align to REG */ - if (SRSLTE_CP_ISEXT(q->cell.cp)) { + if (SRSRAN_CP_ISEXT(q->cell.cp)) { if (n_phich.ngroup % 2) { - for (i = 0; i < SRSLTE_PHICH_EXT_MSYMB / 2; i++) { + for (i = 0; i < SRSRAN_PHICH_EXT_MSYMB / 2; i++) { q->d0[4 * i + 0] = 0; q->d0[4 * i + 1] = 0; q->d0[4 * i + 2] = q->d[2 * i]; q->d0[4 * i + 3] = q->d[2 * i + 1]; } } else { - for (i = 0; i < SRSLTE_PHICH_EXT_MSYMB / 2; i++) { + for (i = 0; i < SRSRAN_PHICH_EXT_MSYMB / 2; i++) { q->d0[4 * i + 0] = q->d[2 * i]; q->d0[4 * i + 1] = q->d[2 * i + 1]; q->d0[4 * i + 2] = 0; @@ -396,30 +396,30 @@ int srslte_phich_encode(srslte_phich_t* q, } } } else { - memcpy(q->d0, q->d, SRSLTE_PHICH_MAX_NSYMB * sizeof(cf_t)); + memcpy(q->d0, q->d, SRSRAN_PHICH_MAX_NSYMB * sizeof(cf_t)); } DEBUG("d0: "); - if (SRSLTE_VERBOSE_ISDEBUG()) - srslte_vec_fprint_c(stdout, q->d0, SRSLTE_PHICH_MAX_NSYMB); + if (SRSRAN_VERBOSE_ISDEBUG()) + srsran_vec_fprint_c(stdout, q->d0, SRSRAN_PHICH_MAX_NSYMB); /* layer mapping & precoding */ if (q->cell.nof_ports > 1) { - srslte_layermap_diversity(q->d0, x, q->cell.nof_ports, SRSLTE_PHICH_MAX_NSYMB); - srslte_precoding_diversity( - x, symbols_precoding, q->cell.nof_ports, SRSLTE_PHICH_MAX_NSYMB / q->cell.nof_ports, 1.0f); + srsran_layermap_diversity(q->d0, x, q->cell.nof_ports, SRSRAN_PHICH_MAX_NSYMB); + srsran_precoding_diversity( + x, symbols_precoding, q->cell.nof_ports, SRSRAN_PHICH_MAX_NSYMB / q->cell.nof_ports, 1.0f); /**TODO: According to 6.9.2, Precoding for 4 tx ports is different! */ } else { - memcpy(q->sf_symbols[0], q->d0, SRSLTE_PHICH_MAX_NSYMB * sizeof(cf_t)); + memcpy(q->sf_symbols[0], q->d0, SRSRAN_PHICH_MAX_NSYMB * sizeof(cf_t)); } /* mapping to resource elements */ for (i = 0; i < q->cell.nof_ports; i++) { - if (srslte_regs_phich_add(q->regs, q->sf_symbols[i], n_phich.ngroup, sf_symbols[i]) < 0) { + if (srsran_regs_phich_add(q->regs, q->sf_symbols[i], n_phich.ngroup, sf_symbols[i]) < 0) { ERROR("Error putting PCHICH resource elements"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } diff --git a/lib/src/phy/phch/pmch.c b/lib/src/phy/phch/pmch.c index 903c9d434..3c6b7dc07 100644 --- a/lib/src/phy/phch/pmch.c +++ b/lib/src/phy/phch/pmch.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -20,17 +20,17 @@ #include #include "prb_dl.h" -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/phch/pmch.h" -#include "srslte/phy/utils/bit.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/phch/pmch.h" +#include "srsran/phy/utils/bit.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" -#define MAX_PMCH_RE (2 * SRSLTE_CP_EXT_NSYMB * 12) +#define MAX_PMCH_RE (2 * SRSRAN_CP_EXT_NSYMB * 12) -const static srslte_mod_t modulations[4] = {SRSLTE_MOD_BPSK, SRSLTE_MOD_QPSK, SRSLTE_MOD_16QAM, SRSLTE_MOD_64QAM}; +const static srsran_mod_t modulations[4] = {SRSRAN_MOD_BPSK, SRSRAN_MOD_QPSK, SRSRAN_MOD_16QAM, SRSRAN_MOD_64QAM}; -static int pmch_cp(srslte_pmch_t* q, cf_t* input, cf_t* output, uint32_t lstart_grant, bool put) +static int pmch_cp(srsran_pmch_t* q, cf_t* input, cf_t* output, uint32_t lstart_grant, bool put) { uint32_t s, n, l, lp, lstart, lend, nof_refs; cf_t * in_ptr = input, *out_ptr = output; @@ -46,7 +46,7 @@ static int pmch_cp(srslte_pmch_t* q, cf_t* input, cf_t* output, uint32_t lstart_ #endif nof_refs = 6; for (s = 0; s < 2; s++) { - for (l = 0; l < SRSLTE_CP_EXT_NSYMB; l++) { + for (l = 0; l < SRSRAN_CP_EXT_NSYMB; l++) { for (n = 0; n < q->cell.nof_prb; n++) { // If this PRB is assigned if (true) { @@ -55,16 +55,16 @@ static int pmch_cp(srslte_pmch_t* q, cf_t* input, cf_t* output, uint32_t lstart_ } else { lstart = 0; } - lend = SRSLTE_CP_EXT_NSYMB; - lp = l + s * SRSLTE_CP_EXT_NSYMB; + lend = SRSRAN_CP_EXT_NSYMB; + lp = l + s * SRSRAN_CP_EXT_NSYMB; if (put) { - out_ptr = &output[(lp * q->cell.nof_prb + n) * SRSLTE_NRE]; + out_ptr = &output[(lp * q->cell.nof_prb + n) * SRSRAN_NRE]; } else { - in_ptr = &input[(lp * q->cell.nof_prb + n) * SRSLTE_NRE]; + in_ptr = &input[(lp * q->cell.nof_prb + n) * SRSRAN_NRE]; } // This is a symbol in a normal PRB with or without references if (l >= lstart && l < lend) { - if (SRSLTE_SYMBOL_HAS_REF_MBSFN(l, s)) { + if (SRSRAN_SYMBOL_HAS_REF_MBSFN(l, s)) { if (l == 0 && s == 1) { offset = 1; } else { @@ -97,7 +97,7 @@ static int pmch_cp(srslte_pmch_t* q, cf_t* input, cf_t* output, uint32_t lstart_ * * 36.211 10.3 section 6.3.5 */ -static int pmch_put(srslte_pmch_t* q, cf_t* symbols, cf_t* sf_symbols, uint32_t lstart) +static int pmch_put(srsran_pmch_t* q, cf_t* symbols, cf_t* sf_symbols, uint32_t lstart) { return pmch_cp(q, symbols, sf_symbols, lstart, true); } @@ -109,18 +109,18 @@ static int pmch_put(srslte_pmch_t* q, cf_t* symbols, cf_t* sf_symbols, uint32_t * * 36.211 10.3 section 6.3.5 */ -static int pmch_get(srslte_pmch_t* q, cf_t* sf_symbols, cf_t* symbols, uint32_t lstart) +static int pmch_get(srsran_pmch_t* q, cf_t* sf_symbols, cf_t* symbols, uint32_t lstart) { return pmch_cp(q, sf_symbols, symbols, lstart, false); } -int srslte_pmch_init(srslte_pmch_t* q, uint32_t max_prb, uint32_t nof_rx_antennas) +int srsran_pmch_init(srsran_pmch_t* q, uint32_t max_prb, uint32_t nof_rx_antennas) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; - if (q != NULL && nof_rx_antennas <= SRSLTE_MAX_PORTS) { - bzero(q, sizeof(srslte_pmch_t)); - ret = SRSLTE_ERROR; + if (q != NULL && nof_rx_antennas <= SRSRAN_MAX_PORTS) { + bzero(q, sizeof(srsran_pmch_t)); + ret = SRSRAN_ERROR; q->cell.nof_prb = max_prb; q->cell.nof_ports = 1; @@ -130,60 +130,60 @@ int srslte_pmch_init(srslte_pmch_t* q, uint32_t max_prb, uint32_t nof_rx_antenna INFO("Init PMCH: %d PRBs, max_symbols: %d", max_prb, q->max_re); for (int i = 0; i < 4; i++) { - if (srslte_modem_table_lte(&q->mod[i], modulations[i])) { + if (srsran_modem_table_lte(&q->mod[i], modulations[i])) { goto clean; } - srslte_modem_table_bytes(&q->mod[i]); + srsran_modem_table_bytes(&q->mod[i]); } - srslte_sch_init(&q->dl_sch); + srsran_sch_init(&q->dl_sch); // Allocate int16_t for reception (LLRs) - q->e = srslte_vec_i16_malloc(q->max_re * srslte_mod_bits_x_symbol(SRSLTE_MOD_64QAM)); + q->e = srsran_vec_i16_malloc(q->max_re * srsran_mod_bits_x_symbol(SRSRAN_MOD_64QAM)); if (!q->e) { goto clean; } - q->d = srslte_vec_cf_malloc(q->max_re); + q->d = srsran_vec_cf_malloc(q->max_re); if (!q->d) { goto clean; } - for (int i = 0; i < SRSLTE_MAX_PORTS; i++) { - q->x[i] = srslte_vec_cf_malloc(q->max_re); + for (int i = 0; i < SRSRAN_MAX_PORTS; i++) { + q->x[i] = srsran_vec_cf_malloc(q->max_re); if (!q->x[i]) { goto clean; } for (int j = 0; j < q->nof_rx_antennas; j++) { - q->ce[i][j] = srslte_vec_cf_malloc(q->max_re); + q->ce[i][j] = srsran_vec_cf_malloc(q->max_re); if (!q->ce[i][j]) { goto clean; } } } for (int j = 0; j < q->nof_rx_antennas; j++) { - q->symbols[j] = srslte_vec_cf_malloc(q->max_re); + q->symbols[j] = srsran_vec_cf_malloc(q->max_re); if (!q->symbols[j]) { goto clean; } } - q->seqs = calloc(SRSLTE_MAX_MBSFN_AREA_IDS, sizeof(srslte_pmch_seq_t*)); + q->seqs = calloc(SRSRAN_MAX_MBSFN_AREA_IDS, sizeof(srsran_pmch_seq_t*)); if (!q->seqs) { perror("calloc"); goto clean; } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } clean: - if (ret == SRSLTE_ERROR) { - srslte_pmch_free(q); + if (ret == SRSRAN_ERROR) { + srsran_pmch_free(q); } return ret; } -void srslte_pmch_free(srslte_pmch_t* q) +void srsran_pmch_free(srsran_pmch_t* q) { if (q->e) { free(q->e); @@ -191,7 +191,7 @@ void srslte_pmch_free(srslte_pmch_t* q) if (q->d) { free(q->d); } - for (uint32_t i = 0; i < SRSLTE_MAX_PORTS; i++) { + for (uint32_t i = 0; i < SRSRAN_MAX_PORTS; i++) { if (q->x[i]) { free(q->x[i]); } @@ -207,27 +207,27 @@ void srslte_pmch_free(srslte_pmch_t* q) } } if (q->seqs) { - for (uint32_t i = 0; i < SRSLTE_MAX_MBSFN_AREA_IDS; i++) { + for (uint32_t i = 0; i < SRSRAN_MAX_MBSFN_AREA_IDS; i++) { if (q->seqs[i]) { - srslte_pmch_free_area_id(q, i); + srsran_pmch_free_area_id(q, i); } } free(q->seqs); } for (uint32_t i = 0; i < 4; i++) { - srslte_modem_table_free(&q->mod[i]); + srsran_modem_table_free(&q->mod[i]); } - srslte_sch_free(&q->dl_sch); + srsran_sch_free(&q->dl_sch); - bzero(q, sizeof(srslte_pmch_t)); + bzero(q, sizeof(srsran_pmch_t)); } -int srslte_pmch_set_cell(srslte_pmch_t* q, srslte_cell_t cell) +int srsran_pmch_set_cell(srsran_pmch_t* q, srsran_cell_t cell) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; - if (q != NULL && srslte_cell_isvalid(&cell)) { + if (q != NULL && srsran_cell_isvalid(&cell)) { q->cell = cell; q->max_re = q->cell.nof_prb * MAX_PMCH_RE; @@ -237,7 +237,7 @@ int srslte_pmch_set_cell(srslte_pmch_t* q, srslte_cell_t cell) q->cell.nof_prb, q->max_re); - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } @@ -245,28 +245,28 @@ int srslte_pmch_set_cell(srslte_pmch_t* q, srslte_cell_t cell) /* Precalculate the scramble sequences for a given MBSFN area ID. This function takes a while * to execute. */ -int srslte_pmch_set_area_id(srslte_pmch_t* q, uint16_t area_id) +int srsran_pmch_set_area_id(srsran_pmch_t* q, uint16_t area_id) { uint32_t i; if (!q->seqs[area_id]) { - q->seqs[area_id] = calloc(1, sizeof(srslte_pmch_seq_t)); + q->seqs[area_id] = calloc(1, sizeof(srsran_pmch_seq_t)); if (q->seqs[area_id]) { - for (i = 0; i < SRSLTE_NOF_SF_X_FRAME; i++) { - if (srslte_sequence_pmch( - &q->seqs[area_id]->seq[i], 2 * i, area_id, q->max_re * srslte_mod_bits_x_symbol(SRSLTE_MOD_64QAM))) { - return SRSLTE_ERROR; + for (i = 0; i < SRSRAN_NOF_SF_X_FRAME; i++) { + if (srsran_sequence_pmch( + &q->seqs[area_id]->seq[i], 2 * i, area_id, q->max_re * srsran_mod_bits_x_symbol(SRSRAN_MOD_64QAM))) { + return SRSRAN_ERROR; } } } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -void srslte_pmch_free_area_id(srslte_pmch_t* q, uint16_t area_id) +void srsran_pmch_free_area_id(srsran_pmch_t* q, uint16_t area_id) { if (q->seqs[area_id]) { - for (int i = 0; i < SRSLTE_NOF_SF_X_FRAME; i++) { - srslte_sequence_free(&q->seqs[area_id]->seq[i]); + for (int i = 0; i < SRSRAN_NOF_SF_X_FRAME; i++) { + srsran_sequence_free(&q->seqs[area_id]->seq[i]); } free(q->seqs[area_id]); q->seqs[area_id] = NULL; @@ -275,23 +275,23 @@ void srslte_pmch_free_area_id(srslte_pmch_t* q, uint16_t area_id) /** Decodes the pmch from the received symbols */ -int srslte_pmch_decode(srslte_pmch_t* q, - srslte_dl_sf_cfg_t* sf, - srslte_pmch_cfg_t* cfg, - srslte_chest_dl_res_t* channel, - cf_t* sf_symbols[SRSLTE_MAX_PORTS], - srslte_pdsch_res_t* out) +int srsran_pmch_decode(srsran_pmch_t* q, + srsran_dl_sf_cfg_t* sf, + srsran_pmch_cfg_t* cfg, + srsran_chest_dl_res_t* channel, + cf_t* sf_symbols[SRSRAN_MAX_PORTS], + srsran_pdsch_res_t* out) { /* Set pointers for layermapping & precoding */ uint32_t i, n; - cf_t* x[SRSLTE_MAX_LAYERS]; + cf_t* x[SRSRAN_MAX_LAYERS]; if (q != NULL && sf_symbols != NULL && out != NULL && cfg != NULL) { INFO("Decoding PMCH SF: %d, MBSFN area ID: 0x%x, Mod %s, TBS: %d, NofSymbols: %d, NofBitsE: %d, rv_idx: %d, " "C_prb=%d, cfi=%d", sf->tti % 10, cfg->area_id, - srslte_mod_string(cfg->pdsch_cfg.grant.tb[0].mod), + srsran_mod_string(cfg->pdsch_cfg.grant.tb[0].mod), cfg->pdsch_cfg.grant.tb[0].tbs, cfg->pdsch_cfg.grant.nof_re, cfg->pdsch_cfg.grant.tb[0].nof_bits, @@ -303,9 +303,9 @@ int srslte_pmch_decode(srslte_pmch_t* q, for (i = 0; i < q->cell.nof_ports; i++) { x[i] = q->x[i]; } - memset(&x[q->cell.nof_ports], 0, sizeof(cf_t*) * (SRSLTE_MAX_LAYERS - q->cell.nof_ports)); + memset(&x[q->cell.nof_ports], 0, sizeof(cf_t*) * (SRSRAN_MAX_LAYERS - q->cell.nof_ports)); - uint32_t lstart = SRSLTE_NOF_CTRL_SYMBOLS(q->cell, sf->cfi); + uint32_t lstart = SRSRAN_NOF_CTRL_SYMBOLS(q->cell, sf->cfi); for (int j = 0; j < q->nof_rx_antennas; j++) { /* extract symbols */ n = pmch_get(q, sf_symbols[j], q->symbols[j], lstart); @@ -314,7 +314,7 @@ int srslte_pmch_decode(srslte_pmch_t* q, cfg->pdsch_cfg.grant.nof_re, n, lstart); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } /* extract channel estimates */ @@ -322,13 +322,13 @@ int srslte_pmch_decode(srslte_pmch_t* q, n = pmch_get(q, channel->ce[i][j], q->ce[i][j], lstart); if (n != cfg->pdsch_cfg.grant.nof_re) { ERROR("PMCH 2 extract chest error expecting %d symbols but got %d", cfg->pdsch_cfg.grant.nof_re, n); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } } // No tx diversity in MBSFN - srslte_predecoding_single_multi(q->symbols, + srsran_predecoding_single_multi(q->symbols, q->ce[0], q->d, NULL, @@ -337,51 +337,51 @@ int srslte_pmch_decode(srslte_pmch_t* q, 1.0f, channel->noise_estimate); - if (SRSLTE_VERBOSE_ISDEBUG()) { + if (SRSRAN_VERBOSE_ISDEBUG()) { DEBUG("SAVED FILE subframe.dat: received subframe symbols"); - srslte_vec_save_file("subframe2.dat", q->symbols[0], cfg->pdsch_cfg.grant.nof_re * sizeof(cf_t)); + srsran_vec_save_file("subframe2.dat", q->symbols[0], cfg->pdsch_cfg.grant.nof_re * sizeof(cf_t)); DEBUG("SAVED FILE hest0.dat: channel estimates for port 4"); printf("nof_prb=%d, cp=%d, nof_re=%d, grant_re=%d\n", q->cell.nof_prb, q->cell.cp, - SRSLTE_NOF_RE(q->cell), + SRSRAN_NOF_RE(q->cell), cfg->pdsch_cfg.grant.nof_re); - srslte_vec_save_file("hest2.dat", channel->ce[0][0], SRSLTE_NOF_RE(q->cell) * sizeof(cf_t)); + srsran_vec_save_file("hest2.dat", channel->ce[0][0], SRSRAN_NOF_RE(q->cell) * sizeof(cf_t)); DEBUG("SAVED FILE pmch_symbols.dat: symbols after equalization"); - srslte_vec_save_file("pmch_symbols.bin", q->d, cfg->pdsch_cfg.grant.nof_re * sizeof(cf_t)); + srsran_vec_save_file("pmch_symbols.bin", q->d, cfg->pdsch_cfg.grant.nof_re * sizeof(cf_t)); } /* demodulate symbols * The MAX-log-MAP algorithm used in turbo decoding is unsensitive to SNR estimation, * thus we don't need tot set it in thde LLRs normalization */ - srslte_demod_soft_demodulate_s(cfg->pdsch_cfg.grant.tb[0].mod, q->d, q->e, cfg->pdsch_cfg.grant.nof_re); + srsran_demod_soft_demodulate_s(cfg->pdsch_cfg.grant.tb[0].mod, q->d, q->e, cfg->pdsch_cfg.grant.nof_re); /* descramble */ - srslte_scrambling_s_offset(&q->seqs[cfg->area_id]->seq[sf->tti % 10], q->e, 0, cfg->pdsch_cfg.grant.tb[0].nof_bits); + srsran_scrambling_s_offset(&q->seqs[cfg->area_id]->seq[sf->tti % 10], q->e, 0, cfg->pdsch_cfg.grant.tb[0].nof_bits); - if (SRSLTE_VERBOSE_ISDEBUG()) { + if (SRSRAN_VERBOSE_ISDEBUG()) { DEBUG("SAVED FILE llr.dat: LLR estimates after demodulation and descrambling"); - srslte_vec_save_file("llr.dat", q->e, cfg->pdsch_cfg.grant.tb[0].nof_bits * sizeof(int16_t)); + srsran_vec_save_file("llr.dat", q->e, cfg->pdsch_cfg.grant.tb[0].nof_bits * sizeof(int16_t)); } - out[0].crc = (srslte_dlsch_decode(&q->dl_sch, &cfg->pdsch_cfg, q->e, out[0].payload) == 0); - out[0].avg_iterations_block = srslte_sch_last_noi(&q->dl_sch); + out[0].crc = (srsran_dlsch_decode(&q->dl_sch, &cfg->pdsch_cfg, q->e, out[0].payload) == 0); + out[0].avg_iterations_block = srsran_sch_last_noi(&q->dl_sch); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } else { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } } -void srslte_configure_pmch(srslte_pmch_cfg_t* pmch_cfg, srslte_cell_t* cell, srslte_mbsfn_cfg_t* mbsfn_cfg) +void srsran_configure_pmch(srsran_pmch_cfg_t* pmch_cfg, srsran_cell_t* cell, srsran_mbsfn_cfg_t* mbsfn_cfg) { pmch_cfg->area_id = 1; pmch_cfg->pdsch_cfg.grant.nof_layers = 1; pmch_cfg->pdsch_cfg.grant.nof_prb = cell->nof_prb; pmch_cfg->pdsch_cfg.grant.tb[0].mcs_idx = mbsfn_cfg->mbsfn_mcs; pmch_cfg->pdsch_cfg.grant.tb[0].enabled = mbsfn_cfg->enable; - pmch_cfg->pdsch_cfg.grant.tb[0].rv = SRSLTE_PMCH_RV; + pmch_cfg->pdsch_cfg.grant.tb[0].rv = SRSRAN_PMCH_RV; pmch_cfg->pdsch_cfg.grant.last_tbs[0] = 0; - srslte_dl_fill_ra_mcs(&pmch_cfg->pdsch_cfg.grant.tb[0], + srsran_dl_fill_ra_mcs(&pmch_cfg->pdsch_cfg.grant.tb[0], pmch_cfg->pdsch_cfg.grant.last_tbs[0], pmch_cfg->pdsch_cfg.grant.nof_prb, false); @@ -394,25 +394,25 @@ void srslte_configure_pmch(srslte_pmch_cfg_t* pmch_cfg, srslte_cell_t* cell, srs } } -int srslte_pmch_encode(srslte_pmch_t* q, - srslte_dl_sf_cfg_t* sf, - srslte_pmch_cfg_t* cfg, +int srsran_pmch_encode(srsran_pmch_t* q, + srsran_dl_sf_cfg_t* sf, + srsran_pmch_cfg_t* cfg, uint8_t* data, - cf_t* sf_symbols[SRSLTE_MAX_PORTS]) + cf_t* sf_symbols[SRSRAN_MAX_PORTS]) { int i; /* Set pointers for layermapping & precoding */ - cf_t* x[SRSLTE_MAX_LAYERS]; - int ret = SRSLTE_ERROR_INVALID_INPUTS; + cf_t* x[SRSRAN_MAX_LAYERS]; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL && cfg != NULL) { for (i = 0; i < q->cell.nof_ports; i++) { if (sf_symbols[i] == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } } if (cfg->pdsch_cfg.grant.tb[0].tbs == 0) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } if (cfg->pdsch_cfg.grant.nof_re > q->max_re) { @@ -420,12 +420,12 @@ int srslte_pmch_encode(srslte_pmch_t* q, cfg->pdsch_cfg.grant.nof_re, q->max_re, q->cell.nof_prb); - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } INFO("Encoding PMCH SF: %d, Mod %s, NofBits: %d, NofSymbols: %d, NofBitsE: %d, rv_idx: %d", sf->tti % 10, - srslte_mod_string(cfg->pdsch_cfg.grant.tb[0].mod), + srsran_mod_string(cfg->pdsch_cfg.grant.tb[0].mod), cfg->pdsch_cfg.grant.tb[0].tbs, cfg->pdsch_cfg.grant.nof_re, cfg->pdsch_cfg.grant.tb[0].nof_bits, @@ -435,31 +435,31 @@ int srslte_pmch_encode(srslte_pmch_t* q, for (i = 0; i < q->cell.nof_ports; i++) { x[i] = q->x[i]; } - memset(&x[q->cell.nof_ports], 0, sizeof(cf_t*) * (SRSLTE_MAX_LAYERS - q->cell.nof_ports)); + memset(&x[q->cell.nof_ports], 0, sizeof(cf_t*) * (SRSRAN_MAX_LAYERS - q->cell.nof_ports)); // TODO: use tb_encode directly - if (srslte_dlsch_encode(&q->dl_sch, &cfg->pdsch_cfg, data, q->e)) { + if (srsran_dlsch_encode(&q->dl_sch, &cfg->pdsch_cfg, data, q->e)) { ERROR("Error encoding TB"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } /* scramble */ - srslte_scrambling_bytes( + srsran_scrambling_bytes( &q->seqs[cfg->area_id]->seq[sf->tti % 10], (uint8_t*)q->e, cfg->pdsch_cfg.grant.tb[0].nof_bits); - srslte_mod_modulate_bytes( + srsran_mod_modulate_bytes( &q->mod[cfg->pdsch_cfg.grant.tb[0].mod], (uint8_t*)q->e, q->d, cfg->pdsch_cfg.grant.tb[0].nof_bits); /* No tx diversity in MBSFN */ memcpy(q->symbols[0], q->d, cfg->pdsch_cfg.grant.nof_re * sizeof(cf_t)); /* mapping to resource elements */ - uint32_t lstart = SRSLTE_NOF_CTRL_SYMBOLS(q->cell, sf->cfi); + uint32_t lstart = SRSRAN_NOF_CTRL_SYMBOLS(q->cell, sf->cfi); for (i = 0; i < q->cell.nof_ports; i++) { pmch_put(q, q->symbols[i], sf_symbols[i], lstart); } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } diff --git a/lib/src/phy/phch/prach.c b/lib/src/phy/phch/prach.c index 89af51066..744ed57a7 100644 --- a/lib/src/phy/phch/prach.c +++ b/lib/src/phy/phch/prach.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -14,10 +14,10 @@ #include #include -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/phch/prach.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/phch/prach.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" #include "prach_tables.h" @@ -42,9 +42,9 @@ // Define read-only complex exponential tables for two possibles size of sequences, common for all possible PRACH // objects -#define PRACH_N_ZC_LONG_LUT_SIZE (2 * SRSLTE_PRACH_N_ZC_LONG) +#define PRACH_N_ZC_LONG_LUT_SIZE (2 * SRSRAN_PRACH_N_ZC_LONG) static cf_t cexp_table_long[PRACH_N_ZC_LONG_LUT_SIZE] = {}; -#define PRACH_N_ZC_SHORT_LUT_SIZE (2 * SRSLTE_PRACH_N_ZC_SHORT) +#define PRACH_N_ZC_SHORT_LUT_SIZE (2 * SRSRAN_PRACH_N_ZC_SHORT) static cf_t cexp_table_short[PRACH_N_ZC_SHORT_LUT_SIZE] = {}; // Use constructor attribute for writing complex exponential tables @@ -65,8 +65,8 @@ static void prach_cexp(uint32_t N_zc, uint32_t u, cf_t* root) { #ifdef PRACH_USE_CEXP_LUT // Use long N_zc table (839 length) - if (N_zc == SRSLTE_PRACH_N_ZC_LONG) { - for (int j = 0; j < SRSLTE_PRACH_N_ZC_LONG; j++) { + if (N_zc == SRSRAN_PRACH_N_ZC_LONG) { + for (int j = 0; j < SRSRAN_PRACH_N_ZC_LONG; j++) { uint32_t phase_idx = u * j * (j + 1); root[j] = cexp_table_long[phase_idx % PRACH_N_ZC_LONG_LUT_SIZE]; } @@ -74,8 +74,8 @@ static void prach_cexp(uint32_t N_zc, uint32_t u, cf_t* root) } // Use short N_zc table (139 length) - if (N_zc == SRSLTE_PRACH_N_ZC_SHORT) { - for (int j = 0; j < SRSLTE_PRACH_N_ZC_SHORT; j++) { + if (N_zc == SRSRAN_PRACH_N_ZC_SHORT) { + for (int j = 0; j < SRSRAN_PRACH_N_ZC_SHORT; j++) { uint32_t phase_idx = u * j * (j + 1); root[j] = cexp_table_short[phase_idx % PRACH_N_ZC_SHORT_LUT_SIZE]; } @@ -90,52 +90,52 @@ static void prach_cexp(uint32_t N_zc, uint32_t u, cf_t* root) } } -int srslte_prach_set_cell_(srslte_prach_t* p, +int srsran_prach_set_cell_(srsran_prach_t* p, uint32_t N_ifft_ul, - srslte_prach_cfg_t* cfg, - srslte_tdd_config_t* tdd_config); + srsran_prach_cfg_t* cfg, + srsran_tdd_config_t* tdd_config); -uint32_t srslte_prach_get_preamble_format(uint32_t config_idx) +uint32_t srsran_prach_get_preamble_format(uint32_t config_idx) { return config_idx / 16; } -srslte_prach_sfn_t srslte_prach_get_sfn(uint32_t config_idx) +srsran_prach_sfn_t srsran_prach_get_sfn(uint32_t config_idx) { if ((config_idx % 16) < 3 || (config_idx % 16) == 15) { - return SRSLTE_PRACH_SFN_EVEN; + return SRSRAN_PRACH_SFN_EVEN; } else { - return SRSLTE_PRACH_SFN_ANY; + return SRSRAN_PRACH_SFN_ANY; } } /* Returns true if current_tti is a valid opportunity for PRACH transmission and the is an allowed subframe, * or allowed_subframe == -1 */ -bool srslte_prach_tti_opportunity(srslte_prach_t* p, uint32_t current_tti, int allowed_subframe) +bool srsran_prach_tti_opportunity(srsran_prach_t* p, uint32_t current_tti, int allowed_subframe) { uint32_t config_idx = p->config_idx; if (!p->tdd_config.configured) { - return srslte_prach_tti_opportunity_config_fdd(config_idx, current_tti, allowed_subframe); + return srsran_prach_tti_opportunity_config_fdd(config_idx, current_tti, allowed_subframe); } else { - return srslte_prach_tti_opportunity_config_tdd( + return srsran_prach_tti_opportunity_config_tdd( config_idx, p->tdd_config.sf_config, current_tti, &p->current_prach_idx); } } -bool srslte_prach_tti_opportunity_config_fdd(uint32_t config_idx, uint32_t current_tti, int allowed_subframe) +bool srsran_prach_tti_opportunity_config_fdd(uint32_t config_idx, uint32_t current_tti, int allowed_subframe) { // Get SFN and sf_idx from the PRACH configuration index - srslte_prach_sfn_t prach_sfn = srslte_prach_get_sfn(config_idx); + srsran_prach_sfn_t prach_sfn = srsran_prach_get_sfn(config_idx); // This is the only option which provides always an opportunity for PRACH transmission. if (config_idx == 14) { return true; } - if ((prach_sfn == SRSLTE_PRACH_SFN_EVEN && ((current_tti / 10) % 2) == 0) || prach_sfn == SRSLTE_PRACH_SFN_ANY) { - srslte_prach_sf_config_t sf_config; - srslte_prach_sf_config(config_idx, &sf_config); + if ((prach_sfn == SRSRAN_PRACH_SFN_EVEN && ((current_tti / 10) % 2) == 0) || prach_sfn == SRSRAN_PRACH_SFN_ANY) { + srsran_prach_sf_config_t sf_config; + srsran_prach_sf_config(config_idx, &sf_config); for (int i = 0; i < sf_config.nof_sf; i++) { if (((current_tti % 10) == sf_config.sf[i] && allowed_subframe == -1) || ((current_tti % 10) == sf_config.sf[i] && (current_tti % 10) == allowed_subframe)) { @@ -146,7 +146,7 @@ bool srslte_prach_tti_opportunity_config_fdd(uint32_t config_idx, uint32_t curre return false; } -uint32_t srslte_prach_nof_f_idx_tdd(uint32_t config_idx, uint32_t tdd_ul_dl_config) +uint32_t srsran_prach_nof_f_idx_tdd(uint32_t config_idx, uint32_t tdd_ul_dl_config) { if (config_idx < 64 && tdd_ul_dl_config < 7) { return prach_tdd_loc_table[config_idx][tdd_ul_dl_config].nof_elems; @@ -156,7 +156,7 @@ uint32_t srslte_prach_nof_f_idx_tdd(uint32_t config_idx, uint32_t tdd_ul_dl_conf } } -uint32_t srslte_prach_f_id_tdd(uint32_t config_idx, uint32_t tdd_ul_dl_config, uint32_t prach_idx) +uint32_t srsran_prach_f_id_tdd(uint32_t config_idx, uint32_t tdd_ul_dl_config, uint32_t prach_idx) { if (config_idx < 64 && tdd_ul_dl_config < 7) { return prach_tdd_loc_table[config_idx][tdd_ul_dl_config].elems[prach_idx].f; @@ -166,7 +166,7 @@ uint32_t srslte_prach_f_id_tdd(uint32_t config_idx, uint32_t tdd_ul_dl_config, u } } -uint32_t srslte_prach_f_ra_tdd(uint32_t config_idx, +uint32_t srsran_prach_f_ra_tdd(uint32_t config_idx, uint32_t tdd_ul_dl_config, uint32_t current_tti, uint32_t prach_idx, @@ -205,7 +205,7 @@ uint32_t srslte_prach_f_ra_tdd(uint32_t config_idx, } } -bool srslte_prach_tti_opportunity_config_tdd(uint32_t config_idx, +bool srsran_prach_tti_opportunity_config_tdd(uint32_t config_idx, uint32_t tdd_ul_dl_config, uint32_t current_tti, uint32_t* prach_idx) @@ -237,8 +237,8 @@ bool srslte_prach_tti_opportunity_config_tdd(uint32_t config_idx, } } else { // Only UpTs subframes - srslte_tdd_config_t c = {tdd_ul_dl_config, 0, true}; - if (srslte_sfidx_tdd_type(c, sf_idx) == SRSLTE_TDD_SF_S) { + srsran_tdd_config_t c = {tdd_ul_dl_config, 0, true}; + if (srsran_sfidx_tdd_type(c, sf_idx) == SRSRAN_TDD_SF_S) { if (prach_idx) { *prach_idx = i; } @@ -251,9 +251,9 @@ bool srslte_prach_tti_opportunity_config_tdd(uint32_t config_idx, return false; } -void srslte_prach_sf_config(uint32_t config_idx, srslte_prach_sf_config_t* sf_config) +void srsran_prach_sf_config(uint32_t config_idx, srsran_prach_sf_config_t* sf_config) { - memcpy(sf_config, &prach_sf_config[config_idx % 16], sizeof(srslte_prach_sf_config_t)); + memcpy(sf_config, &prach_sf_config[config_idx % 16], sizeof(srsran_prach_sf_config_t)); } // For debug use only @@ -266,20 +266,20 @@ void print(void* d, uint32_t size, uint32_t len, char* file_str) } /// Calculates the FFT of the specified sequence index if not previously done and returns a pointer to the result. -static cf_t* get_precoded_dft(srslte_prach_t* p, uint32_t idx) +static cf_t* get_precoded_dft(srsran_prach_t* p, uint32_t idx) { assert(idx < 64 && "Invalid idx value"); // Generate FFT for this sequence if it does not exist yet. uint64_t gen_mask = (uint64_t)1 << idx; if (!(p->dft_gen_bitmap & gen_mask)) { - srslte_dft_run(&p->zc_fft, p->seqs[idx], p->dft_seqs[idx]); + srsran_dft_run(&p->zc_fft, p->seqs[idx], p->dft_seqs[idx]); p->dft_gen_bitmap |= gen_mask; } return p->dft_seqs[idx]; } -int srslte_prach_gen_seqs(srslte_prach_t* p) +int srsran_prach_gen_seqs(srsran_prach_t* p) { uint32_t u = 0; uint32_t v = 1; @@ -374,73 +374,73 @@ int srslte_prach_gen_seqs(srslte_prach_t* p) // for (int j = 0; j < p->N_zc; j++) { // p->seqs[i][j] = root[(j + C_v) % p->N_zc]; // } - srslte_vec_cf_copy(p->seqs[i], &root[C_v], p->N_zc - C_v); - srslte_vec_cf_copy(&p->seqs[i][p->N_zc - C_v], root, C_v); + srsran_vec_cf_copy(p->seqs[i], &root[C_v], p->N_zc - C_v); + srsran_vec_cf_copy(&p->seqs[i][p->N_zc - C_v], root, C_v); v++; } return 0; } -int srslte_prach_set_cfg(srslte_prach_t* p, srslte_prach_cfg_t* cfg, uint32_t nof_prb) +int srsran_prach_set_cfg(srsran_prach_t* p, srsran_prach_cfg_t* cfg, uint32_t nof_prb) { - return srslte_prach_set_cell_(p, srslte_symbol_sz(nof_prb), cfg, &cfg->tdd_config); + return srsran_prach_set_cell_(p, srsran_symbol_sz(nof_prb), cfg, &cfg->tdd_config); } -int srslte_prach_init(srslte_prach_t* p, uint32_t max_N_ifft_ul) +int srsran_prach_init(srsran_prach_t* p, uint32_t max_N_ifft_ul) { - int ret = SRSLTE_ERROR; + int ret = SRSRAN_ERROR; if (p != NULL && max_N_ifft_ul < 2049) { - bzero(p, sizeof(srslte_prach_t)); + bzero(p, sizeof(srsran_prach_t)); p->max_N_ifft_ul = max_N_ifft_ul; // Set up containers - p->prach_bins = srslte_vec_cf_malloc(SRSLTE_PRACH_N_ZC_LONG); - p->corr_spec = srslte_vec_cf_malloc(SRSLTE_PRACH_N_ZC_LONG); - p->corr = srslte_vec_f_malloc(SRSLTE_PRACH_N_ZC_LONG); - p->cross = srslte_vec_cf_malloc(SRSLTE_PRACH_N_ZC_LONG); - p->corr_freq = srslte_vec_cf_malloc(SRSLTE_PRACH_N_ZC_LONG); + p->prach_bins = srsran_vec_cf_malloc(SRSRAN_PRACH_N_ZC_LONG); + p->corr_spec = srsran_vec_cf_malloc(SRSRAN_PRACH_N_ZC_LONG); + p->corr = srsran_vec_f_malloc(SRSRAN_PRACH_N_ZC_LONG); + p->cross = srsran_vec_cf_malloc(SRSRAN_PRACH_N_ZC_LONG); + p->corr_freq = srsran_vec_cf_malloc(SRSRAN_PRACH_N_ZC_LONG); // Set up ZC FFTS - if (srslte_dft_plan(&p->zc_fft, SRSLTE_PRACH_N_ZC_LONG, SRSLTE_DFT_FORWARD, SRSLTE_DFT_COMPLEX)) { - return SRSLTE_ERROR; + if (srsran_dft_plan(&p->zc_fft, SRSRAN_PRACH_N_ZC_LONG, SRSRAN_DFT_FORWARD, SRSRAN_DFT_COMPLEX)) { + return SRSRAN_ERROR; } - srslte_dft_plan_set_mirror(&p->zc_fft, false); - srslte_dft_plan_set_norm(&p->zc_fft, true); + srsran_dft_plan_set_mirror(&p->zc_fft, false); + srsran_dft_plan_set_norm(&p->zc_fft, true); - if (srslte_dft_plan(&p->zc_ifft, SRSLTE_PRACH_N_ZC_LONG, SRSLTE_DFT_BACKWARD, SRSLTE_DFT_COMPLEX)) { - return SRSLTE_ERROR; + if (srsran_dft_plan(&p->zc_ifft, SRSRAN_PRACH_N_ZC_LONG, SRSRAN_DFT_BACKWARD, SRSRAN_DFT_COMPLEX)) { + return SRSRAN_ERROR; } - srslte_dft_plan_set_mirror(&p->zc_ifft, false); - srslte_dft_plan_set_norm(&p->zc_ifft, false); + srsran_dft_plan_set_mirror(&p->zc_ifft, false); + srsran_dft_plan_set_norm(&p->zc_ifft, false); uint32_t fft_size_alloc = max_N_ifft_ul * DELTA_F / DELTA_F_RA; - p->ifft_in = srslte_vec_cf_malloc(fft_size_alloc); - p->ifft_out = srslte_vec_cf_malloc(fft_size_alloc); - if (srslte_dft_plan(&p->ifft, fft_size_alloc, SRSLTE_DFT_BACKWARD, SRSLTE_DFT_COMPLEX)) { + p->ifft_in = srsran_vec_cf_malloc(fft_size_alloc); + p->ifft_out = srsran_vec_cf_malloc(fft_size_alloc); + if (srsran_dft_plan(&p->ifft, fft_size_alloc, SRSRAN_DFT_BACKWARD, SRSRAN_DFT_COMPLEX)) { ERROR("Error creating DFT plan"); return -1; } - srslte_dft_plan_set_mirror(&p->ifft, true); - srslte_dft_plan_set_norm(&p->ifft, true); + srsran_dft_plan_set_mirror(&p->ifft, true); + srsran_dft_plan_set_norm(&p->ifft, true); - if (srslte_dft_plan(&p->fft, fft_size_alloc, SRSLTE_DFT_FORWARD, SRSLTE_DFT_COMPLEX)) { + if (srsran_dft_plan(&p->fft, fft_size_alloc, SRSRAN_DFT_FORWARD, SRSRAN_DFT_COMPLEX)) { ERROR("Error creating DFT plan"); return -1; } - p->signal_fft = srslte_vec_cf_malloc(fft_size_alloc); + p->signal_fft = srsran_vec_cf_malloc(fft_size_alloc); if (!p->signal_fft) { ERROR("Error allocating memory"); return -1; } - srslte_dft_plan_set_mirror(&p->fft, true); - srslte_dft_plan_set_norm(&p->fft, true); + srsran_dft_plan_set_mirror(&p->fft, true); + srsran_dft_plan_set_norm(&p->fft, true); - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } else { ERROR("Invalid parameters"); } @@ -448,19 +448,19 @@ int srslte_prach_init(srslte_prach_t* p, uint32_t max_N_ifft_ul) return ret; } -int srslte_prach_set_cell_(srslte_prach_t* p, +int srsran_prach_set_cell_(srsran_prach_t* p, uint32_t N_ifft_ul, - srslte_prach_cfg_t* cfg, - srslte_tdd_config_t* tdd_config) + srsran_prach_cfg_t* cfg, + srsran_tdd_config_t* tdd_config) { - int ret = SRSLTE_ERROR; + int ret = SRSRAN_ERROR; if (p != NULL && N_ifft_ul < 2049 && cfg->config_idx < 64 && cfg->root_seq_idx < MAX_ROOTS) { if (N_ifft_ul > p->max_N_ifft_ul) { ERROR("PRACH: Error in set_cell(): N_ifft_ul must be lower or equal max_N_ifft_ul in init()"); return -1; } - uint32_t preamble_format = srslte_prach_get_preamble_format(cfg->config_idx); + uint32_t preamble_format = srsran_prach_get_preamble_format(cfg->config_idx); p->is_nr = cfg->is_nr; p->config_idx = cfg->config_idx; p->f = preamble_format; @@ -483,44 +483,44 @@ int srslte_prach_set_cell_(srslte_prach_t* p, // Determine N_zc and N_cs if (4 == preamble_format) { if (p->zczc < 7) { - p->N_zc = SRSLTE_PRACH_N_ZC_SHORT; + p->N_zc = SRSRAN_PRACH_N_ZC_SHORT; p->N_cs = prach_Ncs_format4[p->zczc]; } else { ERROR("Invalid zeroCorrelationZoneConfig=%d for format4", p->zczc); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } else { - p->N_zc = SRSLTE_PRACH_N_ZC_LONG; + p->N_zc = SRSRAN_PRACH_N_ZC_LONG; if (p->hs) { if (p->zczc < 15) { p->N_cs = prach_Ncs_restricted[p->zczc]; } else { ERROR("Invalid zeroCorrelationZoneConfig=%d for restricted set", p->zczc); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } else { if (p->zczc < 16) { p->N_cs = prach_Ncs_unrestricted[p->zczc]; } else { ERROR("Invalid zeroCorrelationZoneConfig=%d", p->zczc); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } } // Set up ZC FFTS - if (p->N_zc != SRSLTE_PRACH_N_ZC_LONG) { - if (srslte_dft_replan(&p->zc_fft, p->N_zc)) { - return SRSLTE_ERROR; + if (p->N_zc != SRSRAN_PRACH_N_ZC_LONG) { + if (srsran_dft_replan(&p->zc_fft, p->N_zc)) { + return SRSRAN_ERROR; } - if (srslte_dft_replan(&p->zc_ifft, p->N_zc)) { - return SRSLTE_ERROR; + if (srsran_dft_replan(&p->zc_ifft, p->N_zc)) { + return SRSRAN_ERROR; } } // Generate our 64 sequences p->N_roots = 0; - srslte_prach_gen_seqs(p); + srsran_prach_gen_seqs(p); // Ensure num_ra_preambles is valid, if not assign default value if (p->num_ra_preambles < 4 || p->num_ra_preambles > p->N_roots) { p->num_ra_preambles = p->N_roots; @@ -544,28 +544,28 @@ int srslte_prach_set_cell_(srslte_prach_t* p, p->deadzone = (uint32_t) ceil((float) samp_rate/((float) p->N_zc*subcarrier_spacing)); }*/ - if (srslte_dft_replan(&p->ifft, p->N_ifft_prach)) { + if (srsran_dft_replan(&p->ifft, p->N_ifft_prach)) { ERROR("Error creating DFT plan"); return -1; } - if (srslte_dft_replan(&p->fft, p->N_ifft_prach)) { + if (srsran_dft_replan(&p->fft, p->N_ifft_prach)) { ERROR("Error creating DFT plan"); return -1; } p->N_seq = prach_Tseq[p->f] * p->N_ifft_ul / 2048; p->N_cp = prach_Tcp[p->f] * p->N_ifft_ul / 2048; - p->T_seq = prach_Tseq[p->f] * SRSLTE_LTE_TS; - p->T_tot = (prach_Tseq[p->f] + prach_Tcp[p->f]) * SRSLTE_LTE_TS; + p->T_seq = prach_Tseq[p->f] * SRSRAN_LTE_TS; + p->T_tot = (prach_Tseq[p->f] + prach_Tcp[p->f]) * SRSRAN_LTE_TS; if (p->successive_cancellation) { for (int i = 0; i < 64; i++) { if (!p->td_signals[i]) { - p->td_signals[i] = srslte_vec_malloc(sizeof(cf_t) * (p->N_seq + p->N_cp)); + p->td_signals[i] = srsran_vec_malloc(sizeof(cf_t) * (p->N_seq + p->N_cp)); } } } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } else { ERROR("Invalid parameters N_ifft_ul=%d; config_idx=%d; root_seq_idx=%d;", N_ifft_ul, @@ -576,12 +576,12 @@ int srslte_prach_set_cell_(srslte_prach_t* p, return ret; } -int srslte_prach_gen(srslte_prach_t* p, uint32_t seq_index, uint32_t freq_offset, cf_t* signal) +int srsran_prach_gen(srsran_prach_t* p, uint32_t seq_index, uint32_t freq_offset, cf_t* signal) { - int ret = SRSLTE_ERROR; + int ret = SRSRAN_ERROR; if (p != NULL && seq_index < N_SEQS && signal != NULL) { // Calculate parameters - uint32_t N_rb_ul = srslte_nof_prb(p->N_ifft_ul); + uint32_t N_rb_ul = srsran_nof_prb(p->N_ifft_ul); uint32_t k_0 = freq_offset * N_RB_SC - N_rb_ul * N_RB_SC / 2 + p->N_ifft_ul / 2; uint32_t K = DELTA_F / DELTA_F_RA; uint32_t begin = PHI + (K * k_0) + (p->is_nr ? 1 : (K / 2)); @@ -599,7 +599,7 @@ int srslte_prach_gen(srslte_prach_t* p, uint32_t seq_index, uint32_t freq_offset memcpy(&p->ifft_in[begin], get_precoded_dft(p, seq_index), p->N_zc * sizeof(cf_t)); memset(&p->ifft_in[begin + p->N_zc], 0, (p->N_ifft_prach - begin - p->N_zc) * sizeof(cf_t)); - srslte_dft_run(&p->ifft, p->ifft_in, p->ifft_out); + srsran_dft_run(&p->ifft, p->ifft_in, p->ifft_out); // Copy CP into buffer memcpy(signal, &p->ifft_out[p->N_ifft_prach - p->N_cp], p->N_cp * sizeof(cf_t)); @@ -611,48 +611,48 @@ int srslte_prach_gen(srslte_prach_t* p, uint32_t seq_index, uint32_t freq_offset if (p->td_signals[seq_index]) { memcpy(p->td_signals[seq_index], signal, (p->N_seq + p->N_cp) * sizeof(cf_t)); } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } -void srslte_prach_set_detect_factor(srslte_prach_t* p, float ratio) +void srsran_prach_set_detect_factor(srsran_prach_t* p, float ratio) { p->detect_factor = ratio; } -int srslte_prach_detect(srslte_prach_t* p, +int srsran_prach_detect(srsran_prach_t* p, uint32_t freq_offset, cf_t* signal, uint32_t sig_len, uint32_t* indices, uint32_t* n_indices) { - return srslte_prach_detect_offset(p, freq_offset, signal, sig_len, indices, NULL, NULL, n_indices); + return srsran_prach_detect_offset(p, freq_offset, signal, sig_len, indices, NULL, NULL, n_indices); } /// this function subtracts the detected prach preamble from the signal so as to allow for lower power prach signals to /// be detected more easily in the subsequent searches -void srslte_prach_cancellation(srslte_prach_t* p) +void srsran_prach_cancellation(srsran_prach_t* p) { - srslte_vec_cf_zero(p->sub, p->N_zc * 2); - srslte_vec_cf_copy(p->sub, get_precoded_dft(p, p->root_seqs_idx[p->prach_cancel.idx]), p->N_zc); + srsran_vec_cf_zero(p->sub, p->N_zc * 2); + srsran_vec_cf_copy(p->sub, get_precoded_dft(p, p->root_seqs_idx[p->prach_cancel.idx]), p->N_zc); - srslte_vec_prod_ccc(p->sub, p->prach_cancel.phase_array, p->sub, p->N_zc); + srsran_vec_prod_ccc(p->sub, p->prach_cancel.phase_array, p->sub, p->N_zc); #ifdef PRACH_CANCELLATION_HARD - srslte_vec_prod_conj_ccc(p->prach_bins, p->sub, p->corr_spec, p->N_zc); - srslte_dft_run(&p->zc_ifft, p->corr_spec, p->corr_spec); - srslte_vec_abs_square_cf(p->corr_spec, p->corr, p->N_zc); + srsran_vec_prod_conj_ccc(p->prach_bins, p->sub, p->corr_spec, p->N_zc); + srsran_dft_run(&p->zc_ifft, p->corr_spec, p->corr_spec); + srsran_vec_abs_square_cf(p->corr_spec, p->corr, p->N_zc); prach_cancel->factor = sqrt(p->corr[0] / (p->N_zc * p->N_zc)); #endif - srslte_vec_sc_prod_cfc(p->sub, p->prach_cancel.factor, p->sub, p->N_zc); - srslte_vec_sub_ccc(p->prach_bins, p->sub, p->prach_bins, p->N_zc); + srsran_vec_sc_prod_cfc(p->sub, p->prach_cancel.factor, p->sub, p->N_zc); + srsran_vec_sub_ccc(p->prach_bins, p->sub, p->prach_bins, p->N_zc); } // this function checks if we have already detected and stored this particular PRACH index and if so, doesnt store it // again in the detected prachs array -bool srslte_prach_have_stored(int current_idx, uint32_t* indices, uint32_t n_indices) +bool srsran_prach_have_stored(int current_idx, uint32_t* indices, uint32_t n_indices) { for (int i = 0; i < n_indices; i++) { if (indices[i] == current_idx) { @@ -662,7 +662,7 @@ bool srslte_prach_have_stored(int current_idx, uint32_t* indices, uint32_t n_ind return false; } // set the offset based on the time domain time offset estimation -float srslte_prach_get_offset_secs(srslte_prach_t* p, int n_win) +float srsran_prach_get_offset_secs(srsran_prach_t* p, int n_win) { // takes the offset in samples and converts to time in seconds return (float)p->peak_offsets[n_win] / (float)(DELTA_F_RA * p->N_zc); @@ -670,11 +670,11 @@ float srslte_prach_get_offset_secs(srslte_prach_t* p, int n_win) // calculates the timing offset of the incoming PRACH by calculating the phase in frequency - alternative to time domain // approach -float srslte_prach_calculate_time_offset_secs(srslte_prach_t* p, cf_t* cross) +float srsran_prach_calculate_time_offset_secs(srsran_prach_t* p, cf_t* cross) { // calculate the phase of the cross correlation - float freq_domain_phase = cargf(srslte_vec_acc_cc(cross, p->N_zc)); - float ratio = (float)(p->N_ifft_ul * DELTA_F) / (float)(SRSLTE_PRACH_N_ZC_LONG * DELTA_F_RA); + float freq_domain_phase = cargf(srsran_vec_acc_cc(cross, p->N_zc)); + float ratio = (float)(p->N_ifft_ul * DELTA_F) / (float)(SRSRAN_PRACH_N_ZC_LONG * DELTA_F_RA); // converting from phase to number of samples float num_samples = roundf((ratio * freq_domain_phase * p->N_zc) / (2 * M_PI)); @@ -683,16 +683,16 @@ float srslte_prach_calculate_time_offset_secs(srslte_prach_t* p, cf_t* cross) } // calculates the aggregate phase offset of the incomming PRACH signal so it can be applied to the reference signal // before it is subtracted from the input -void srslte_prach_calculate_correction_array(srslte_prach_t* p, cf_t* corr_freq) +void srsran_prach_calculate_correction_array(srsran_prach_t* p, cf_t* corr_freq) { - srslte_vec_arg_deg_cf(corr_freq, 0, p->phase, p->N_zc); + srsran_vec_arg_deg_cf(corr_freq, 0, p->phase, p->N_zc); for (int i = 0; i < p->N_zc; i++) { p->prach_cancel.phase_array[i] = cexpf(_Complex_I * (p->phase[i] / (180.0f / M_PI))); } } // This function carries out the main processing on the incomming PRACH signal -int srslte_prach_process(srslte_prach_t* p, +int srsran_prach_process(srsran_prach_t* p, cf_t* signal, uint32_t* indices, float* t_offsets, @@ -705,22 +705,22 @@ int srslte_prach_process(srslte_prach_t* p, float max_to_cancel = 0; cancellation_idx = -1; int max_idx = 0; - srslte_vec_cf_zero(p->cross, p->N_zc); - srslte_vec_cf_zero(p->corr_freq, p->N_zc); + srsran_vec_cf_zero(p->cross, p->N_zc); + srsran_vec_cf_zero(p->corr_freq, p->N_zc); for (int i = 0; i < p->num_ra_preambles; i++) { cf_t* root_spec = get_precoded_dft(p, p->root_seqs_idx[i]); - srslte_vec_prod_conj_ccc(p->prach_bins, root_spec, p->corr_spec, p->N_zc); + srsran_vec_prod_conj_ccc(p->prach_bins, root_spec, p->corr_spec, p->N_zc); - srslte_vec_prod_conj_ccc(p->corr_spec, &p->corr_spec[1], p->cross, p->N_zc - 1); + srsran_vec_prod_conj_ccc(p->corr_spec, &p->corr_spec[1], p->cross, p->N_zc - 1); if (p->successive_cancellation) { - srslte_vec_cf_copy(p->corr_freq, p->corr_spec, p->N_zc); + srsran_vec_cf_copy(p->corr_freq, p->corr_spec, p->N_zc); } - srslte_dft_run(&p->zc_ifft, p->corr_spec, p->corr_spec); + srsran_dft_run(&p->zc_ifft, p->corr_spec, p->corr_spec); - srslte_vec_abs_square_cf(p->corr_spec, p->corr, p->N_zc); + srsran_vec_abs_square_cf(p->corr_spec, p->corr, p->N_zc); - float corr_ave = srslte_vec_acc_ff(p->corr, p->N_zc) / p->N_zc; + float corr_ave = srsran_vec_acc_ff(p->corr, p->N_zc) / p->N_zc; uint32_t winsize = 0; if (p->N_cs != 0) { @@ -760,9 +760,9 @@ int srslte_prach_process(srslte_prach_t* p, max_to_cancel = max_peak; p->prach_cancel.idx = cancellation_idx; p->prach_cancel.factor = (sqrt(max_peak / (p->N_zc * p->N_zc))); - srslte_prach_calculate_correction_array(p, p->corr_freq); + srsran_prach_calculate_correction_array(p, p->corr_freq); } - if (srslte_prach_have_stored(((i * n_wins) + j), indices, *n_indices)) { + if (srsran_prach_have_stored(((i * n_wins) + j), indices, *n_indices)) { break; } } @@ -774,8 +774,8 @@ int srslte_prach_process(srslte_prach_t* p, if (t_offsets) { // saves the PRACH offset in seconds to t_offsets, time domain or freq domain base calc t_offsets[*n_indices] = (p->freq_domain_offset_calc) - ? (srslte_prach_calculate_time_offset_secs(p, p->cross)) - : (srslte_prach_get_offset_secs(p, j)); + ? (srsran_prach_calculate_time_offset_secs(p, p->cross)) + : (srsran_prach_get_offset_secs(p, j)); } (*n_indices)++; } @@ -784,14 +784,14 @@ int srslte_prach_process(srslte_prach_t* p, } if (cancellation_idx != -1) { // if a peak has been found, this applies cancellation, if many found, subtracts strongest - srslte_prach_cancellation(p); + srsran_prach_cancellation(p); } else { return 1; } return 0; } -int srslte_prach_detect_offset(srslte_prach_t* p, +int srsran_prach_detect_offset(srsran_prach_t* p, uint32_t freq_offset, cf_t* signal, uint32_t sig_len, @@ -800,22 +800,22 @@ int srslte_prach_detect_offset(srslte_prach_t* p, float* peak_to_avg, uint32_t* n_indices) { - int ret = SRSLTE_ERROR; + int ret = SRSRAN_ERROR; if (p != NULL && signal != NULL && sig_len > 0 && indices != NULL) { if (sig_len < p->N_ifft_prach) { - ERROR("srslte_prach_detect: Signal length is %d and should be %d", sig_len, p->N_ifft_prach); - return SRSLTE_ERROR_INVALID_INPUTS; + ERROR("srsran_prach_detect: Signal length is %d and should be %d", sig_len, p->N_ifft_prach); + return SRSRAN_ERROR_INVALID_INPUTS; } int cancellation_idx = -2; - bzero(&p->prach_cancel, sizeof(srslte_prach_cancellation_t)); + bzero(&p->prach_cancel, sizeof(srsran_prach_cancellation_t)); // FFT incoming signal - srslte_dft_run(&p->fft, signal, p->signal_fft); + srsran_dft_run(&p->fft, signal, p->signal_fft); *n_indices = 0; // Extract bins of interest - uint32_t N_rb_ul = srslte_nof_prb(p->N_ifft_ul); + uint32_t N_rb_ul = srsran_nof_prb(p->N_ifft_ul); uint32_t k_0 = freq_offset * N_RB_SC - N_rb_ul * N_RB_SC / 2 + p->N_ifft_ul / 2; uint32_t K = DELTA_F / DELTA_F_RA; uint32_t begin = PHI + (K * k_0) + (K / 2); @@ -825,30 +825,30 @@ int srslte_prach_detect_offset(srslte_prach_t* p, // if successive cancellation is enabled, we perform the entire search process p->num_ra_preambles times, removing // the highest power PRACH preamble each time. for (int l = 0; l < loops; l++) { - if (srslte_prach_process( + if (srsran_prach_process( p, signal, indices, t_offsets, peak_to_avg, n_indices, cancellation_idx, begin, sig_len)) { break; } } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } -int srslte_prach_free(srslte_prach_t* p) +int srsran_prach_free(srsran_prach_t* p) { free(p->prach_bins); free(p->corr_spec); free(p->corr); - srslte_dft_plan_free(&p->ifft); + srsran_dft_plan_free(&p->ifft); free(p->ifft_in); free(p->ifft_out); free(p->cross); free(p->corr_freq); - srslte_dft_plan_free(&p->fft); - srslte_dft_plan_free(&p->zc_fft); - srslte_dft_plan_free(&p->zc_ifft); + srsran_dft_plan_free(&p->fft); + srsran_dft_plan_free(&p->zc_fft); + srsran_dft_plan_free(&p->zc_ifft); if (p->signal_fft) { free(p->signal_fft); @@ -858,12 +858,12 @@ int srslte_prach_free(srslte_prach_t* p) free(p->td_signals[i]); } - bzero(p, sizeof(srslte_prach_t)); + bzero(p, sizeof(srsran_prach_t)); return 0; } -int srslte_prach_print_seqs(srslte_prach_t* p) +int srsran_prach_print_seqs(srsran_prach_t* p) { for (int i = 0; i < N_SEQS; i++) { FILE* f; diff --git a/lib/src/phy/phch/prach_tables.h b/lib/src/phy/phch/prach_tables.h index 92aaadb84..334910ea5 100644 --- a/lib/src/phy/phch/prach_tables.h +++ b/lib/src/phy/phch/prach_tables.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,7 +10,7 @@ * */ -#include "srslte/phy/phch/prach.h" +#include "srsran/phy/phch/prach.h" /****************************************************** * Reference tables from 3GPP TS 36.211 v10.7.0 @@ -80,7 +80,7 @@ uint32_t prach_zc_roots_format4[138] = { 47, 92, 48, 91, 49, 90, 50, 89, 51, 88, 52, 87, 53, 86, 54, 85, 55, 84, 56, 83, 57, 82, 58, 81, 59, 80, 60, 79, 61, 78, 62, 77, 63, 76, 64, 75, 65, 74, 66, 73, 67, 72, 68, 71, 69, 70}; -srslte_prach_sf_config_t prach_sf_config[16] = {{1, {1, 0, 0, 0, 0}}, +srsran_prach_sf_config_t prach_sf_config[16] = {{1, {1, 0, 0, 0, 0}}, {1, {4, 0, 0, 0, 0}}, {1, {7, 0, 0, 0, 0}}, {1, {1, 0, 0, 0, 0}}, @@ -97,7 +97,7 @@ srslte_prach_sf_config_t prach_sf_config[16] = {{1, {1, 0, 0, 0, 0}}, {-1, {0, 0, 0, 0, 0}}, // this means all subframes {1, {9, 0, 0, 0, 0}}}; -srslte_prach_tdd_loc_table_t prach_tdd_loc_table[64][7] = { +srsran_prach_tdd_loc_table_t prach_tdd_loc_table[64][7] = { {{1, {{0, 1, 0, 2}}}, {1, {{0, 1, 0, 1}}}, {1, {{0, 1, 0, 0}}}, diff --git a/lib/src/phy/phch/prb_dl.c b/lib/src/phy/phch/prb_dl.c index 7a06fc4e8..7907d7c25 100644 --- a/lib/src/phy/phch/prb_dl.c +++ b/lib/src/phy/phch/prb_dl.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -14,14 +14,14 @@ #include #include "prb_dl.h" -#include "srslte/phy/common/phy_common.h" +#include "srsran/phy/common/phy_common.h" //#define DEBUG_IDX #ifdef DEBUG_IDX extern cf_t* offset_original; -SRSLTE_API int indices[100000]; -SRSLTE_API int indices_ptr = 0; +SRSRAN_API int indices[100000]; +SRSRAN_API int indices_ptr = 0; #endif void print_indexes(cf_t* offset, int len) @@ -38,7 +38,7 @@ void prb_cp_ref(cf_t** input, cf_t** output, int offset, int nof_refs, int nof_i { int i; - int ref_interval = ((SRSLTE_NRE / nof_refs) - 1); + int ref_interval = ((SRSRAN_NRE / nof_refs) - 1); memcpy(*output, *input, offset * sizeof(cf_t)); print_indexes(*input, offset); *input += offset; @@ -69,18 +69,18 @@ void prb_cp_ref(cf_t** input, cf_t** output, int offset, int nof_refs, int nof_i void prb_cp(cf_t** input, cf_t** output, int nof_prb) { - memcpy(*output, *input, sizeof(cf_t) * SRSLTE_NRE * nof_prb); - print_indexes(*input, SRSLTE_NRE); - *input += nof_prb * SRSLTE_NRE; - *output += nof_prb * SRSLTE_NRE; + memcpy(*output, *input, sizeof(cf_t) * SRSRAN_NRE * nof_prb); + print_indexes(*input, SRSRAN_NRE); + *input += nof_prb * SRSRAN_NRE; + *output += nof_prb * SRSRAN_NRE; } void prb_cp_half(cf_t** input, cf_t** output, int nof_prb) { - memcpy(*output, *input, sizeof(cf_t) * SRSLTE_NRE * nof_prb / 2); - print_indexes(*input, SRSLTE_NRE / 2); - *input += nof_prb * SRSLTE_NRE / 2; - *output += nof_prb * SRSLTE_NRE / 2; + memcpy(*output, *input, sizeof(cf_t) * SRSRAN_NRE * nof_prb / 2); + print_indexes(*input, SRSRAN_NRE / 2); + *input += nof_prb * SRSRAN_NRE / 2; + *output += nof_prb * SRSRAN_NRE / 2; } void prb_put_ref_(cf_t** input, cf_t** output, int offset, int nof_refs, int nof_intervals) diff --git a/lib/src/phy/phch/prb_dl.h b/lib/src/phy/phch/prb_dl.h index 539f9348b..a164dc535 100644 --- a/lib/src/phy/phch/prb_dl.h +++ b/lib/src/phy/phch/prb_dl.h @@ -2,21 +2,21 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of * the distribution. * */ -#ifndef SRSLTE_PRB_DL_H_ -#define SRSLTE_PRB_DL_H_ +#ifndef SRSRAN_PRB_DL_H_ +#define SRSRAN_PRB_DL_H_ -#include "srslte/config.h" +#include "srsran/config.h" void prb_cp_ref(cf_t** input, cf_t** output, int offset, int nof_refs, int nof_intervals, bool advance_input); void prb_cp(cf_t** input, cf_t** output, int nof_prb); void prb_cp_half(cf_t** input, cf_t** output, int nof_prb); void prb_put_ref_(cf_t** input, cf_t** output, int offset, int nof_refs, int nof_intervals); -#endif /* SRSLTE_PRB_DL_H_ */ +#endif /* SRSRAN_PRB_DL_H_ */ diff --git a/lib/src/phy/phch/psbch.c b/lib/src/phy/phch/psbch.c index 380f6363f..dabe254d3 100644 --- a/lib/src/phy/phch/psbch.c +++ b/lib/src/phy/phch/psbch.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,75 +10,75 @@ * */ -#include "srslte/phy/phch/psbch.h" -#include "srslte/phy/fec/convolutional/rm_conv.h" -#include "srslte/phy/modem/mod.h" -#include "srslte/phy/phch/sch.h" -#include "srslte/phy/utils/bit.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/phch/psbch.h" +#include "srsran/phy/fec/convolutional/rm_conv.h" +#include "srsran/phy/modem/mod.h" +#include "srsran/phy/phch/sch.h" +#include "srsran/phy/utils/bit.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" #include #include -int srslte_psbch_init(srslte_psbch_t* q, uint32_t nof_prb, uint32_t N_sl_id, srslte_sl_tm_t tm, srslte_cp_t cp) +int srsran_psbch_init(srsran_psbch_t* q, uint32_t nof_prb, uint32_t N_sl_id, srsran_sl_tm_t tm, srsran_cp_t cp) { - bzero(q, sizeof(srslte_psbch_t)); + bzero(q, sizeof(srsran_psbch_t)); q->N_sl_id = N_sl_id; q->tm = tm; q->nof_prb = nof_prb; - if (SRSLTE_CP_ISEXT(cp) && (tm >= SRSLTE_SIDELINK_TM3)) { + if (SRSRAN_CP_ISEXT(cp) && (tm >= SRSRAN_SIDELINK_TM3)) { ERROR("Selected TM does not support extended CP"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } q->cp = cp; // Calculate rate matching params - if (q->tm <= SRSLTE_SIDELINK_TM2) { - q->nof_data_symbols = SRSLTE_PSBCH_TM12_NUM_DATA_SYMBOLS; - q->sl_bch_tb_len = SRSLTE_MIB_SL_LEN; - if (SRSLTE_CP_ISEXT(cp)) { - q->nof_data_symbols = SRSLTE_PSBCH_TM12_NUM_DATA_SYMBOLS_EXT; + if (q->tm <= SRSRAN_SIDELINK_TM2) { + q->nof_data_symbols = SRSRAN_PSBCH_TM12_NUM_DATA_SYMBOLS; + q->sl_bch_tb_len = SRSRAN_MIB_SL_LEN; + if (SRSRAN_CP_ISEXT(cp)) { + q->nof_data_symbols = SRSRAN_PSBCH_TM12_NUM_DATA_SYMBOLS_EXT; } } else { - q->nof_data_symbols = SRSLTE_PSBCH_TM34_NUM_DATA_SYMBOLS; - q->sl_bch_tb_len = SRSLTE_MIB_SL_V2X_LEN; + q->nof_data_symbols = SRSRAN_PSBCH_TM34_NUM_DATA_SYMBOLS; + q->sl_bch_tb_len = SRSRAN_MIB_SL_V2X_LEN; } q->nof_tx_symbols = q->nof_data_symbols - 1; ///< Last OFDM symbol is used channel processing but not transmitted - q->nof_data_re = q->nof_data_symbols * (SRSLTE_NRE * SRSLTE_PSBCH_NOF_PRB); - q->nof_tx_re = q->nof_tx_symbols * (SRSLTE_NRE * SRSLTE_PSBCH_NOF_PRB); - q->sl_bch_tb_crc_len = q->sl_bch_tb_len + SRSLTE_SL_BCH_CRC_LEN; + q->nof_data_re = q->nof_data_symbols * (SRSRAN_NRE * SRSRAN_PSBCH_NOF_PRB); + q->nof_tx_re = q->nof_tx_symbols * (SRSRAN_NRE * SRSRAN_PSBCH_NOF_PRB); + q->sl_bch_tb_crc_len = q->sl_bch_tb_len + SRSRAN_SL_BCH_CRC_LEN; q->sl_bch_encoded_len = 3 * q->sl_bch_tb_crc_len; - q->c = srslte_vec_u8_malloc(q->sl_bch_tb_crc_len); + q->c = srsran_vec_u8_malloc(q->sl_bch_tb_crc_len); if (!q->c) { ERROR("Error allocating memory"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - q->d = srslte_vec_u8_malloc(q->sl_bch_encoded_len); + q->d = srsran_vec_u8_malloc(q->sl_bch_encoded_len); if (!q->d) { ERROR("Error allocating memory"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - q->d_16 = srslte_vec_i16_malloc(q->sl_bch_encoded_len); + q->d_16 = srsran_vec_i16_malloc(q->sl_bch_encoded_len); if (!q->d_16) { ERROR("Error allocating memory"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // CRC - if (srslte_crc_init(&q->crc_mib_sl, SRSLTE_LTE_CRC16, SRSLTE_SL_BCH_CRC_LEN)) { + if (srsran_crc_init(&q->crc_mib_sl, SRSRAN_LTE_CRC16, SRSRAN_SL_BCH_CRC_LEN)) { ERROR("Error crc init"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - q->crc_temp = srslte_vec_u8_malloc(SRSLTE_SL_BCH_CRC_LEN); + q->crc_temp = srsran_vec_u8_malloc(SRSRAN_SL_BCH_CRC_LEN); if (!q->crc_temp) { ERROR("Error allocating memory"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Channel coding @@ -88,164 +88,164 @@ int srslte_psbch_init(srslte_psbch_t* q, uint32_t nof_prb, uint32_t N_sl_id, srs int poly[3] = {0x6D, 0x4F, 0x57}; memcpy(q->encoder.poly, poly, 3 * sizeof(int)); - if (srslte_viterbi_init(&q->dec, SRSLTE_VITERBI_37, poly, q->sl_bch_tb_crc_len, true)) { - return SRSLTE_ERROR; + if (srsran_viterbi_init(&q->dec, SRSRAN_VITERBI_37, poly, q->sl_bch_tb_crc_len, true)) { + return SRSRAN_ERROR; } // QPSK modulation // 3GPP TS 36.211 version 15.6.0 Release 15 Sec. 9.6 - Table 9.6.2-1: PSBCH modulation schemes - q->Qm = srslte_mod_bits_x_symbol(SRSLTE_MOD_QPSK); + q->Qm = srsran_mod_bits_x_symbol(SRSRAN_MOD_QPSK); q->E = q->nof_data_re * q->Qm; - q->e = srslte_vec_u8_malloc(q->E); + q->e = srsran_vec_u8_malloc(q->E); if (!q->e) { ERROR("Error allocating memory"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - q->e_16 = srslte_vec_i16_malloc(q->E); + q->e_16 = srsran_vec_i16_malloc(q->E); if (!q->e_16) { ERROR("Error allocating memory"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - q->e_bytes = srslte_vec_u8_malloc(q->E / 8); + q->e_bytes = srsran_vec_u8_malloc(q->E / 8); if (!q->e_bytes) { ERROR("Error allocating memory"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Scrambling - bzero(&q->seq, sizeof(srslte_sequence_t)); - if (srslte_sequence_LTE_pr(&q->seq, q->E, N_sl_id) != SRSLTE_SUCCESS) { - ERROR("Error srslte_sequence_LTE_pr"); - return SRSLTE_ERROR; + bzero(&q->seq, sizeof(srsran_sequence_t)); + if (srsran_sequence_LTE_pr(&q->seq, q->E, N_sl_id) != SRSRAN_SUCCESS) { + ERROR("Error srsran_sequence_LTE_pr"); + return SRSRAN_ERROR; } - q->codeword = srslte_vec_u8_malloc(q->E); + q->codeword = srsran_vec_u8_malloc(q->E); if (!q->codeword) { ERROR("Error allocating memory"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - q->codeword_bytes = srslte_vec_u8_malloc(q->E / 8); + q->codeword_bytes = srsran_vec_u8_malloc(q->E / 8); if (!q->codeword_bytes) { ERROR("Error allocating memory"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Interleaving - q->interleaver_lut = srslte_vec_u32_malloc(q->E); + q->interleaver_lut = srsran_vec_u32_malloc(q->E); if (!q->interleaver_lut) { ERROR("Error allocating memory"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Modulation QPSK - if (srslte_modem_table_lte(&q->mod, SRSLTE_MOD_QPSK) != SRSLTE_SUCCESS) { - ERROR("Error srslte_modem_table_lte"); - return SRSLTE_ERROR; + if (srsran_modem_table_lte(&q->mod, SRSRAN_MOD_QPSK) != SRSRAN_SUCCESS) { + ERROR("Error srsran_modem_table_lte"); + return SRSRAN_ERROR; } - q->mod_symbols = srslte_vec_cf_malloc(q->nof_data_re); + q->mod_symbols = srsran_vec_cf_malloc(q->nof_data_re); if (!q->mod_symbols) { ERROR("Error allocating memory"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Soft-demod - q->llr = srslte_vec_i16_malloc(q->E); + q->llr = srsran_vec_i16_malloc(q->E); if (!q->llr) { ERROR("Error allocating memory"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Transform precoding q->precoding_scaling = 1.0f; - if (srslte_dft_precoding_init_tx(&q->dft_precoder, SRSLTE_PSBCH_NOF_PRB) != SRSLTE_SUCCESS) { - ERROR("Error srslte_dft_precoding_init"); - return SRSLTE_ERROR; + if (srsran_dft_precoding_init_tx(&q->dft_precoder, SRSRAN_PSBCH_NOF_PRB) != SRSRAN_SUCCESS) { + ERROR("Error srsran_dft_precoding_init"); + return SRSRAN_ERROR; } - q->scfdma_symbols = srslte_vec_cf_malloc(q->nof_data_re); + q->scfdma_symbols = srsran_vec_cf_malloc(q->nof_data_re); if (!q->scfdma_symbols) { ERROR("Error allocating memory"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } ///< Make sure last bits are zero as they are not considered during unpack - srslte_vec_cf_zero(q->scfdma_symbols, q->nof_data_re); + srsran_vec_cf_zero(q->scfdma_symbols, q->nof_data_re); - if (srslte_dft_precoding_init_rx(&q->idft_precoder, SRSLTE_PSBCH_NOF_PRB) != SRSLTE_SUCCESS) { - ERROR("Error srslte_idft_precoding_init"); - return SRSLTE_ERROR; + if (srsran_dft_precoding_init_rx(&q->idft_precoder, SRSRAN_PSBCH_NOF_PRB) != SRSRAN_SUCCESS) { + ERROR("Error srsran_idft_precoding_init"); + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_psbch_encode(srslte_psbch_t* q, uint8_t* input, uint32_t input_len, cf_t* sf_buffer) +int srsran_psbch_encode(srsran_psbch_t* q, uint8_t* input, uint32_t input_len, cf_t* sf_buffer) { if (input == NULL || input_len > q->sl_bch_tb_len) { ERROR("Can't encode PSBCH, input too long (%d > %d)", input_len, q->sl_bch_tb_len); - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } // Copy into codeword buffer - srslte_vec_u8_copy(q->c, input, input_len); + srsran_vec_u8_copy(q->c, input, input_len); // CRC Attachment - srslte_crc_attach(&q->crc_mib_sl, q->c, input_len); + srsran_crc_attach(&q->crc_mib_sl, q->c, input_len); // Channel Coding - srslte_convcoder_encode(&q->encoder, q->c, q->d, q->sl_bch_tb_crc_len); + srsran_convcoder_encode(&q->encoder, q->c, q->d, q->sl_bch_tb_crc_len); // Rate matching - srslte_rm_conv_tx(q->d, q->sl_bch_encoded_len, q->e, q->E); + srsran_rm_conv_tx(q->d, q->sl_bch_encoded_len, q->e, q->E); // Interleaving - srslte_bit_pack_vector(q->e, q->e_bytes, q->E); - srslte_sl_ulsch_interleave(q->e_bytes, // input bytes + srsran_bit_pack_vector(q->e, q->e_bytes, q->E); + srsran_sl_ulsch_interleave(q->e_bytes, // input bytes q->Qm, // modulation q->nof_data_re, // prime number q->nof_data_symbols, // number of symbols q->codeword_bytes // output ); - srslte_bit_unpack_vector(q->codeword_bytes, q->codeword, q->E); + srsran_bit_unpack_vector(q->codeword_bytes, q->codeword, q->E); // Scrambling - srslte_scrambling_b(&q->seq, q->codeword); + srsran_scrambling_b(&q->seq, q->codeword); // Modulation - srslte_mod_modulate(&q->mod, q->codeword, q->mod_symbols, q->E); + srsran_mod_modulate(&q->mod, q->codeword, q->mod_symbols, q->E); // Layer Mapping // Void: Single layer // 3GPP TS 36.211 version 15.6.0 Release 15 Sec. 9.6.3 // Transform precoding - srslte_dft_precoding(&q->dft_precoder, q->mod_symbols, q->scfdma_symbols, SRSLTE_PSBCH_NOF_PRB, q->nof_data_symbols); + srsran_dft_precoding(&q->dft_precoder, q->mod_symbols, q->scfdma_symbols, SRSRAN_PSBCH_NOF_PRB, q->nof_data_symbols); // Precoding // Void: Single antenna port // 3GPP TS 36.211 version 15.6.0 Release 15 Sec. 9.6.5 // RE mapping - srslte_psbch_put(q, q->scfdma_symbols, sf_buffer); + srsran_psbch_put(q, q->scfdma_symbols, sf_buffer); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_psbch_decode(srslte_psbch_t* q, cf_t* equalized_sf_syms, uint8_t* output, uint32_t max_output_len) +int srsran_psbch_decode(srsran_psbch_t* q, cf_t* equalized_sf_syms, uint8_t* output, uint32_t max_output_len) { if (max_output_len < q->sl_bch_tb_len) { ERROR("Can't decode PSBCH, provided buffer too small (%d < %d)", max_output_len, q->sl_bch_tb_len); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // RE extraction - if (q->nof_tx_re != srslte_psbch_get(q, equalized_sf_syms, q->scfdma_symbols)) { + if (q->nof_tx_re != srsran_psbch_get(q, equalized_sf_syms, q->scfdma_symbols)) { ERROR("There was an error getting the PSBCH symbols"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Precoding @@ -253,104 +253,104 @@ int srslte_psbch_decode(srslte_psbch_t* q, cf_t* equalized_sf_syms, uint8_t* out // 3GPP TS 36.211 version 15.6.0 Release 15 Sec. 9.6.5 // Transform precoding - srslte_dft_precoding(&q->idft_precoder, q->scfdma_symbols, q->mod_symbols, SRSLTE_PSBCH_NOF_PRB, q->nof_data_symbols); + srsran_dft_precoding(&q->idft_precoder, q->scfdma_symbols, q->mod_symbols, SRSRAN_PSBCH_NOF_PRB, q->nof_data_symbols); // Layer Mapping // Void: Single layer // 3GPP TS 36.211 version 15.6.0 Release 15 Sec. 9.6.3 // Demodulation - srslte_demod_soft_demodulate_s(SRSLTE_MOD_QPSK, q->mod_symbols, q->llr, q->nof_data_re); + srsran_demod_soft_demodulate_s(SRSRAN_MOD_QPSK, q->mod_symbols, q->llr, q->nof_data_re); // De-scramble - srslte_scrambling_s(&q->seq, q->llr); + srsran_scrambling_s(&q->seq, q->llr); // Deinterleaving - srslte_sl_ulsch_deinterleave(q->llr, q->Qm, q->nof_data_re, q->nof_data_symbols, q->e_16, q->interleaver_lut); + srsran_sl_ulsch_deinterleave(q->llr, q->Qm, q->nof_data_re, q->nof_data_symbols, q->e_16, q->interleaver_lut); // Rate match - srslte_rm_conv_rx_s(q->e_16, q->E, q->d_16, q->sl_bch_encoded_len); + srsran_rm_conv_rx_s(q->e_16, q->E, q->d_16, q->sl_bch_encoded_len); // Channel decoding - srslte_viterbi_decode_s(&q->dec, q->d_16, q->c, q->sl_bch_tb_crc_len); + srsran_viterbi_decode_s(&q->dec, q->d_16, q->c, q->sl_bch_tb_crc_len); // Copy received crc to temp - srslte_vec_u8_copy(q->crc_temp, &q->c[q->sl_bch_tb_len], SRSLTE_SL_BCH_CRC_LEN); + srsran_vec_u8_copy(q->crc_temp, &q->c[q->sl_bch_tb_len], SRSRAN_SL_BCH_CRC_LEN); // Re-attach crc - srslte_crc_attach(&q->crc_mib_sl, q->c, q->sl_bch_tb_len); + srsran_crc_attach(&q->crc_mib_sl, q->c, q->sl_bch_tb_len); // CRC check - if (srslte_bit_diff(q->crc_temp, &q->c[q->sl_bch_tb_len], SRSLTE_SL_BCH_CRC_LEN) != 0) { - return SRSLTE_ERROR; + if (srsran_bit_diff(q->crc_temp, &q->c[q->sl_bch_tb_len], SRSRAN_SL_BCH_CRC_LEN) != 0) { + return SRSRAN_ERROR; } // Remove CRC and copy to output buffer - srslte_vec_u8_copy(output, q->c, q->sl_bch_tb_len); + srsran_vec_u8_copy(output, q->c, q->sl_bch_tb_len); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_psbch_reset(srslte_psbch_t* q, uint32_t N_sl_id) +int srsran_psbch_reset(srsran_psbch_t* q, uint32_t N_sl_id) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL) { if (q->N_sl_id != N_sl_id) { q->N_sl_id = N_sl_id; // Regen scrambling sequence - if (srslte_sequence_LTE_pr(&q->seq, q->E, N_sl_id) != SRSLTE_SUCCESS) { - ERROR("Error srslte_sequence_LTE_pr"); - return SRSLTE_ERROR; + if (srsran_sequence_LTE_pr(&q->seq, q->E, N_sl_id) != SRSRAN_SUCCESS) { + ERROR("Error srsran_sequence_LTE_pr"); + return SRSRAN_ERROR; } } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } -int srslte_psbch_put(srslte_psbch_t* q, cf_t* symbols, cf_t* sf_buffer) +int srsran_psbch_put(srsran_psbch_t* q, cf_t* symbols, cf_t* sf_buffer) { uint32_t sample_pos = 0; - uint32_t k = q->nof_prb * SRSLTE_NRE / 2 - 36; + uint32_t k = q->nof_prb * SRSRAN_NRE / 2 - 36; // Mapping to physical resources - for (uint32_t i = 0; i < srslte_sl_get_num_symbols(q->tm, q->cp); i++) { - if (srslte_psbch_is_symbol(SRSLTE_SIDELINK_DATA_SYMBOL, q->tm, i, q->cp)) { - srslte_vec_cf_copy( - &sf_buffer[k + i * q->nof_prb * SRSLTE_NRE], &symbols[sample_pos], SRSLTE_NRE * SRSLTE_PSBCH_NOF_PRB); - sample_pos += (SRSLTE_NRE * SRSLTE_PSBCH_NOF_PRB); + for (uint32_t i = 0; i < srsran_sl_get_num_symbols(q->tm, q->cp); i++) { + if (srsran_psbch_is_symbol(SRSRAN_SIDELINK_DATA_SYMBOL, q->tm, i, q->cp)) { + srsran_vec_cf_copy( + &sf_buffer[k + i * q->nof_prb * SRSRAN_NRE], &symbols[sample_pos], SRSRAN_NRE * SRSRAN_PSBCH_NOF_PRB); + sample_pos += (SRSRAN_NRE * SRSRAN_PSBCH_NOF_PRB); } } return sample_pos; } -int srslte_psbch_get(srslte_psbch_t* q, cf_t* sf_buffer, cf_t* symbols) +int srsran_psbch_get(srsran_psbch_t* q, cf_t* sf_buffer, cf_t* symbols) { uint32_t sample_pos = 0; - uint32_t k = q->nof_prb * SRSLTE_NRE / 2 - 36; + uint32_t k = q->nof_prb * SRSRAN_NRE / 2 - 36; // Get PSBCH REs - for (uint32_t i = 0; i < srslte_sl_get_num_symbols(q->tm, q->cp); i++) { - if (srslte_psbch_is_symbol(SRSLTE_SIDELINK_DATA_SYMBOL, q->tm, i, q->cp)) { - srslte_vec_cf_copy( - &symbols[sample_pos], &sf_buffer[k + i * q->nof_prb * SRSLTE_NRE], SRSLTE_NRE * SRSLTE_PSBCH_NOF_PRB); - sample_pos += (SRSLTE_NRE * SRSLTE_PSBCH_NOF_PRB); + for (uint32_t i = 0; i < srsran_sl_get_num_symbols(q->tm, q->cp); i++) { + if (srsran_psbch_is_symbol(SRSRAN_SIDELINK_DATA_SYMBOL, q->tm, i, q->cp)) { + srsran_vec_cf_copy( + &symbols[sample_pos], &sf_buffer[k + i * q->nof_prb * SRSRAN_NRE], SRSRAN_NRE * SRSRAN_PSBCH_NOF_PRB); + sample_pos += (SRSRAN_NRE * SRSRAN_PSBCH_NOF_PRB); } } return sample_pos; } -void srslte_psbch_free(srslte_psbch_t* q) +void srsran_psbch_free(srsran_psbch_t* q) { if (q) { - srslte_dft_precoding_free(&q->dft_precoder); - srslte_dft_precoding_free(&q->idft_precoder); - srslte_viterbi_free(&q->dec); - srslte_sequence_free(&q->seq); - srslte_modem_table_free(&q->mod); + srsran_dft_precoding_free(&q->dft_precoder); + srsran_dft_precoding_free(&q->idft_precoder); + srsran_viterbi_free(&q->dec); + srsran_sequence_free(&q->seq); + srsran_modem_table_free(&q->mod); if (q->crc_temp) { free(q->crc_temp); @@ -393,6 +393,6 @@ void srslte_psbch_free(srslte_psbch_t* q) free(q->scfdma_symbols); } - bzero(q, sizeof(srslte_psbch_t)); + bzero(q, sizeof(srsran_psbch_t)); } } diff --git a/lib/src/phy/phch/pscch.c b/lib/src/phy/phch/pscch.c index afa48ef6f..9743e95a9 100644 --- a/lib/src/phy/phch/pscch.c +++ b/lib/src/phy/phch/pscch.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -14,43 +14,43 @@ #include #include -#include "srslte/phy/fec/convolutional/rm_conv.h" -#include "srslte/phy/modem/demod_soft.h" -#include "srslte/phy/modem/mod.h" -#include "srslte/phy/phch/pscch.h" -#include "srslte/phy/phch/sch.h" -#include "srslte/phy/scrambling/scrambling.h" -#include "srslte/phy/utils/bit.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" - -int srslte_pscch_init(srslte_pscch_t* q, uint32_t max_prb) +#include "srsran/phy/fec/convolutional/rm_conv.h" +#include "srsran/phy/modem/demod_soft.h" +#include "srsran/phy/modem/mod.h" +#include "srsran/phy/phch/pscch.h" +#include "srsran/phy/phch/sch.h" +#include "srsran/phy/scrambling/scrambling.h" +#include "srsran/phy/utils/bit.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" + +int srsran_pscch_init(srsran_pscch_t* q, uint32_t max_prb) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL) { - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; q->max_prb = max_prb; // CRC uint32_t crc_poly = 0x11021; - if (srslte_crc_init(&q->crc, crc_poly, SRSLTE_SCI_CRC_LEN)) { - return SRSLTE_ERROR; + if (srsran_crc_init(&q->crc, crc_poly, SRSRAN_SCI_CRC_LEN)) { + return SRSRAN_ERROR; } - q->c = srslte_vec_u8_malloc(SRSLTE_SCI_MAX_LEN + SRSLTE_SCI_CRC_LEN); + q->c = srsran_vec_u8_malloc(SRSRAN_SCI_MAX_LEN + SRSRAN_SCI_CRC_LEN); if (!q->c) { ERROR("Error allocating memory"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - q->sci_crc = srslte_vec_u8_malloc(SRSLTE_SCI_CRC_LEN); + q->sci_crc = srsran_vec_u8_malloc(SRSRAN_SCI_CRC_LEN); if (!q->sci_crc) { ERROR("Error allocating memory"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Max E value for memory allocation - uint32_t E_max = SRSLTE_NRE * SRSLTE_PSCCH_MAX_NUM_DATA_SYMBOLS * SRSLTE_PSCCH_MAX_NOF_PRB * SRSLTE_PSCCH_QM; + uint32_t E_max = SRSRAN_NRE * SRSRAN_PSCCH_MAX_NUM_DATA_SYMBOLS * SRSRAN_PSCCH_MAX_NOF_PRB * SRSRAN_PSCCH_QM; // Channel Coding q->encoder.K = 7; @@ -58,120 +58,120 @@ int srslte_pscch_init(srslte_pscch_t* q, uint32_t max_prb) q->encoder.tail_biting = true; int poly[3] = {0x6D, 0x4F, 0x57}; memcpy(q->encoder.poly, poly, 3 * sizeof(int)); - q->d = srslte_vec_u8_malloc(E_max); + q->d = srsran_vec_u8_malloc(E_max); if (!q->d) { ERROR("Error allocating memory"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - srslte_vec_u8_zero(q->d, E_max); + srsran_vec_u8_zero(q->d, E_max); - q->d_16 = srslte_vec_i16_malloc(E_max); + q->d_16 = srsran_vec_i16_malloc(E_max); if (!q->d_16) { ERROR("Error allocating memory"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - srslte_viterbi_init( - &q->dec, SRSLTE_VITERBI_37, q->encoder.poly, SRSLTE_SCI_MAX_LEN + SRSLTE_SCI_CRC_LEN, q->encoder.tail_biting); + srsran_viterbi_init( + &q->dec, SRSRAN_VITERBI_37, q->encoder.poly, SRSRAN_SCI_MAX_LEN + SRSRAN_SCI_CRC_LEN, q->encoder.tail_biting); - q->e = srslte_vec_u8_malloc(E_max); + q->e = srsran_vec_u8_malloc(E_max); if (!q->e) { ERROR("Error allocating memory"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - q->e_16 = srslte_vec_i16_malloc(E_max); + q->e_16 = srsran_vec_i16_malloc(E_max); if (!q->e_16) { ERROR("Error allocating memory"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - q->e_bytes = srslte_vec_u8_malloc(E_max / 8); + q->e_bytes = srsran_vec_u8_malloc(E_max / 8); if (!q->e_bytes) { ERROR("Error allocating memory"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - q->interleaver_lut = srslte_vec_u32_malloc(E_max); + q->interleaver_lut = srsran_vec_u32_malloc(E_max); if (!q->interleaver_lut) { ERROR("Error allocating memory"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - q->codeword = srslte_vec_u8_malloc(E_max); + q->codeword = srsran_vec_u8_malloc(E_max); if (!q->codeword) { ERROR("Error allocating memory"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - q->codeword_bytes = srslte_vec_u8_malloc(E_max / 8); + q->codeword_bytes = srsran_vec_u8_malloc(E_max / 8); if (!q->codeword_bytes) { ERROR("Error allocating memory"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Scrambling - bzero(&q->seq, sizeof(srslte_sequence_t)); - srslte_sequence_LTE_pr(&q->seq, E_max, SRSLTE_PSCCH_SCRAMBLING_SEED); + bzero(&q->seq, sizeof(srsran_sequence_t)); + srsran_sequence_LTE_pr(&q->seq, E_max, SRSRAN_PSCCH_SCRAMBLING_SEED); // Modulation - if (srslte_modem_table_lte(&q->mod, SRSLTE_MOD_QPSK)) { - return SRSLTE_ERROR; + if (srsran_modem_table_lte(&q->mod, SRSRAN_MOD_QPSK)) { + return SRSRAN_ERROR; } - q->mod_symbols = srslte_vec_cf_malloc(E_max / SRSLTE_PSCCH_QM); + q->mod_symbols = srsran_vec_cf_malloc(E_max / SRSRAN_PSCCH_QM); if (!q->mod_symbols) { ERROR("Error allocating memory"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - srslte_vec_cf_zero(q->mod_symbols, E_max / SRSLTE_PSCCH_QM); + srsran_vec_cf_zero(q->mod_symbols, E_max / SRSRAN_PSCCH_QM); - q->llr = srslte_vec_i16_malloc(E_max); + q->llr = srsran_vec_i16_malloc(E_max); if (!q->llr) { ERROR("Error allocating memory"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // DFT Precoding - if (srslte_dft_precoding_init(&q->dft_precoder, SRSLTE_PSCCH_MAX_NOF_PRB, true)) { - return SRSLTE_ERROR; + if (srsran_dft_precoding_init(&q->dft_precoder, SRSRAN_PSCCH_MAX_NOF_PRB, true)) { + return SRSRAN_ERROR; } - q->scfdma_symbols = srslte_vec_cf_malloc(E_max / SRSLTE_PSCCH_QM); + q->scfdma_symbols = srsran_vec_cf_malloc(E_max / SRSRAN_PSCCH_QM); if (!q->scfdma_symbols) { ERROR("Error allocating memory"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - srslte_vec_cf_zero(q->scfdma_symbols, E_max / SRSLTE_PSCCH_QM); + srsran_vec_cf_zero(q->scfdma_symbols, E_max / SRSRAN_PSCCH_QM); // IDFT Predecoding - if (srslte_dft_precoding_init(&q->idft_precoder, SRSLTE_PSCCH_MAX_NOF_PRB, false)) { - return SRSLTE_ERROR; + if (srsran_dft_precoding_init(&q->idft_precoder, SRSRAN_PSCCH_MAX_NOF_PRB, false)) { + return SRSRAN_ERROR; } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } -int srslte_pscch_set_cell(srslte_pscch_t* q, srslte_cell_sl_t cell) +int srsran_pscch_set_cell(srsran_pscch_t* q, srsran_cell_sl_t cell) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL && cell.nof_prb <= q->max_prb) { - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; - if (cell.tm == SRSLTE_SIDELINK_TM1 || cell.tm == SRSLTE_SIDELINK_TM2) { - q->sci_len = srslte_sci_format0_sizeof(cell.nof_prb); - q->nof_symbols = SRSLTE_PSCCH_TM12_NUM_DATA_SYMBOLS; - q->pscch_nof_prb = SRSLTE_PSCCH_TM12_NOF_PRB; - q->E = SRSLTE_PSCCH_TM12_NOF_CODED_BITS; + if (cell.tm == SRSRAN_SIDELINK_TM1 || cell.tm == SRSRAN_SIDELINK_TM2) { + q->sci_len = srsran_sci_format0_sizeof(cell.nof_prb); + q->nof_symbols = SRSRAN_PSCCH_TM12_NUM_DATA_SYMBOLS; + q->pscch_nof_prb = SRSRAN_PSCCH_TM12_NOF_PRB; + q->E = SRSRAN_PSCCH_TM12_NOF_CODED_BITS; - if (cell.cp == SRSLTE_CP_EXT) { - q->nof_symbols = SRSLTE_PSCCH_TM12_NUM_DATA_SYMBOLS_EXT; + if (cell.cp == SRSRAN_CP_EXT) { + q->nof_symbols = SRSRAN_PSCCH_TM12_NUM_DATA_SYMBOLS_EXT; } - } else if (cell.tm == SRSLTE_SIDELINK_TM3 || cell.tm == SRSLTE_SIDELINK_TM4) { - q->sci_len = SRSLTE_SCI_TM34_LEN; - q->nof_symbols = SRSLTE_PSCCH_TM34_NUM_DATA_SYMBOLS; - q->pscch_nof_prb = SRSLTE_PSCCH_TM34_NOF_PRB; - q->E = SRSLTE_PSCCH_TM34_NOF_CODED_BITS; + } else if (cell.tm == SRSRAN_SIDELINK_TM3 || cell.tm == SRSRAN_SIDELINK_TM4) { + q->sci_len = SRSRAN_SCI_TM34_LEN; + q->nof_symbols = SRSRAN_PSCCH_TM34_NUM_DATA_SYMBOLS; + q->pscch_nof_prb = SRSRAN_PSCCH_TM34_NOF_PRB; + q->E = SRSRAN_PSCCH_TM34_NOF_CODED_BITS; } else { return ret; } @@ -179,69 +179,69 @@ int srslte_pscch_set_cell(srslte_pscch_t* q, srslte_cell_sl_t cell) q->cell = cell; ///< Last OFDM symbol is processed but not transmitted - q->nof_tx_re = (q->nof_symbols - 1) * SRSLTE_NRE * q->pscch_nof_prb; + q->nof_tx_re = (q->nof_symbols - 1) * SRSRAN_NRE * q->pscch_nof_prb; - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } -int srslte_pscch_encode(srslte_pscch_t* q, uint8_t* sci, cf_t* sf_buffer, uint32_t prb_start_idx) +int srsran_pscch_encode(srsran_pscch_t* q, uint8_t* sci, cf_t* sf_buffer, uint32_t prb_start_idx) { memcpy(q->c, sci, sizeof(uint8_t) * q->sci_len); // CRC Attachment - srslte_crc_attach(&q->crc, q->c, q->sci_len); + srsran_crc_attach(&q->crc, q->c, q->sci_len); // Channel Coding - srslte_convcoder_encode(&q->encoder, q->c, q->d, q->sci_len + SRSLTE_SCI_CRC_LEN); + srsran_convcoder_encode(&q->encoder, q->c, q->d, q->sci_len + SRSRAN_SCI_CRC_LEN); // Rate Matching - if (srslte_rm_conv_tx(q->d, (3 * (q->sci_len + SRSLTE_SCI_CRC_LEN)), q->e, q->E)) { - return SRSLTE_ERROR; + if (srsran_rm_conv_tx(q->d, (3 * (q->sci_len + SRSRAN_SCI_CRC_LEN)), q->e, q->E)) { + return SRSRAN_ERROR; } // Interleaving - srslte_bit_pack_vector(q->e, q->e_bytes, q->E); - srslte_sl_ulsch_interleave(q->e_bytes, // input bytes - SRSLTE_PSCCH_QM, // modulation - q->E / SRSLTE_PSCCH_QM, // prime number + srsran_bit_pack_vector(q->e, q->e_bytes, q->E); + srsran_sl_ulsch_interleave(q->e_bytes, // input bytes + SRSRAN_PSCCH_QM, // modulation + q->E / SRSRAN_PSCCH_QM, // prime number q->nof_symbols, // nof pscch symbols q->codeword_bytes // output ); - srslte_bit_unpack_vector(q->codeword_bytes, q->codeword, q->E); + srsran_bit_unpack_vector(q->codeword_bytes, q->codeword, q->E); // Scrambling - srslte_scrambling_b(&q->seq, q->codeword); + srsran_scrambling_b(&q->seq, q->codeword); // Modulation - srslte_mod_modulate(&q->mod, q->codeword, q->mod_symbols, q->E); + srsran_mod_modulate(&q->mod, q->codeword, q->mod_symbols, q->E); // Layer Mapping // Void: Single layer // 3GPP TS 36.211 version 15.6.0 Release 15 Sec. 9.4.3 // DFT Precoding - srslte_dft_precoding(&q->dft_precoder, q->mod_symbols, q->scfdma_symbols, q->pscch_nof_prb, q->nof_symbols); + srsran_dft_precoding(&q->dft_precoder, q->mod_symbols, q->scfdma_symbols, q->pscch_nof_prb, q->nof_symbols); // Precoding // Void: Single antenna port // 3GPP TS 36.211 version 15.6.0 Release 15 Sec. 9.4.5 - if (srslte_pscch_put(q, sf_buffer, prb_start_idx) != q->nof_tx_re) { + if (srsran_pscch_put(q, sf_buffer, prb_start_idx) != q->nof_tx_re) { printf("Error during PSCCH RE mapping\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_pscch_decode(srslte_pscch_t* q, cf_t* equalized_sf_syms, uint8_t* sci, uint32_t prb_start_idx) +int srsran_pscch_decode(srsran_pscch_t* q, cf_t* equalized_sf_syms, uint8_t* sci, uint32_t prb_start_idx) { - if (srslte_pscch_get(q, equalized_sf_syms, prb_start_idx) != q->nof_tx_re) { + if (srsran_pscch_get(q, equalized_sf_syms, prb_start_idx) != q->nof_tx_re) { printf("Error during PSCCH RE extraction\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Precoding @@ -249,87 +249,87 @@ int srslte_pscch_decode(srslte_pscch_t* q, cf_t* equalized_sf_syms, uint8_t* sci // 3GPP TS 36.211 version 15.6.0 Release 15 Sec. 9.4.5 // IDFT Precoding - srslte_dft_precoding(&q->idft_precoder, q->scfdma_symbols, q->mod_symbols, q->pscch_nof_prb, q->nof_symbols); + srsran_dft_precoding(&q->idft_precoder, q->scfdma_symbols, q->mod_symbols, q->pscch_nof_prb, q->nof_symbols); // Layer Mapping // Void: Single layer // 3GPP TS 36.211 version 15.6.0 Release 15 Sec. 9.4.3 // Demodulation - srslte_demod_soft_demodulate_s(SRSLTE_MOD_QPSK, q->mod_symbols, q->llr, q->E / SRSLTE_PSCCH_QM); + srsran_demod_soft_demodulate_s(SRSRAN_MOD_QPSK, q->mod_symbols, q->llr, q->E / SRSRAN_PSCCH_QM); // Descrambling - srslte_scrambling_s(&q->seq, q->llr); + srsran_scrambling_s(&q->seq, q->llr); // Deinterleaving - srslte_sl_ulsch_deinterleave( - q->llr, SRSLTE_PSCCH_QM, q->E / SRSLTE_PSCCH_QM, q->nof_symbols, q->e_16, q->interleaver_lut); + srsran_sl_ulsch_deinterleave( + q->llr, SRSRAN_PSCCH_QM, q->E / SRSRAN_PSCCH_QM, q->nof_symbols, q->e_16, q->interleaver_lut); // Rate matching - srslte_rm_conv_rx_s(q->e_16, q->E, q->d_16, (3 * (q->sci_len + SRSLTE_SCI_CRC_LEN))); + srsran_rm_conv_rx_s(q->e_16, q->E, q->d_16, (3 * (q->sci_len + SRSRAN_SCI_CRC_LEN))); // Channel decoding - srslte_viterbi_decode_s(&q->dec, q->d_16, q->c, q->sci_len + SRSLTE_SCI_CRC_LEN); + srsran_viterbi_decode_s(&q->dec, q->d_16, q->c, q->sci_len + SRSRAN_SCI_CRC_LEN); // Copy received crc - memcpy(q->sci_crc, &q->c[q->sci_len], sizeof(uint8_t) * SRSLTE_SCI_CRC_LEN); + memcpy(q->sci_crc, &q->c[q->sci_len], sizeof(uint8_t) * SRSRAN_SCI_CRC_LEN); // Re-attach crc - srslte_crc_attach(&q->crc, q->c, q->sci_len); + srsran_crc_attach(&q->crc, q->c, q->sci_len); // CRC check - if (srslte_bit_diff(q->sci_crc, &q->c[q->sci_len], SRSLTE_SCI_CRC_LEN) != 0) { - return SRSLTE_ERROR; + if (srsran_bit_diff(q->sci_crc, &q->c[q->sci_len], SRSRAN_SCI_CRC_LEN) != 0) { + return SRSRAN_ERROR; } // Remove CRC and copy content to sci buffer memcpy(sci, q->c, sizeof(uint8_t) * q->sci_len); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_pscch_put(srslte_pscch_t* q, cf_t* sf_buffer, uint32_t prb_start_idx) +int srsran_pscch_put(srsran_pscch_t* q, cf_t* sf_buffer, uint32_t prb_start_idx) { int sample_pos = 0; - int k = prb_start_idx * SRSLTE_NRE; - for (int i = 0; i < srslte_sl_get_num_symbols(q->cell.tm, q->cell.cp); ++i) { - if (srslte_pscch_is_symbol(SRSLTE_SIDELINK_DATA_SYMBOL, q->cell.tm, i, q->cell.cp)) { - memcpy(&sf_buffer[k + i * q->cell.nof_prb * SRSLTE_NRE], + int k = prb_start_idx * SRSRAN_NRE; + for (int i = 0; i < srsran_sl_get_num_symbols(q->cell.tm, q->cell.cp); ++i) { + if (srsran_pscch_is_symbol(SRSRAN_SIDELINK_DATA_SYMBOL, q->cell.tm, i, q->cell.cp)) { + memcpy(&sf_buffer[k + i * q->cell.nof_prb * SRSRAN_NRE], &q->scfdma_symbols[sample_pos], - sizeof(cf_t) * (SRSLTE_NRE * q->pscch_nof_prb)); - sample_pos += (SRSLTE_NRE * q->pscch_nof_prb); + sizeof(cf_t) * (SRSRAN_NRE * q->pscch_nof_prb)); + sample_pos += (SRSRAN_NRE * q->pscch_nof_prb); } } return sample_pos; } -int srslte_pscch_get(srslte_pscch_t* q, cf_t* sf_buffer, uint32_t prb_start_idx) +int srsran_pscch_get(srsran_pscch_t* q, cf_t* sf_buffer, uint32_t prb_start_idx) { int sample_pos = 0; - int k = prb_start_idx * SRSLTE_NRE; - for (int i = 0; i < srslte_sl_get_num_symbols(q->cell.tm, q->cell.cp); ++i) { - if (srslte_pscch_is_symbol(SRSLTE_SIDELINK_DATA_SYMBOL, q->cell.tm, i, q->cell.cp)) { + int k = prb_start_idx * SRSRAN_NRE; + for (int i = 0; i < srsran_sl_get_num_symbols(q->cell.tm, q->cell.cp); ++i) { + if (srsran_pscch_is_symbol(SRSRAN_SIDELINK_DATA_SYMBOL, q->cell.tm, i, q->cell.cp)) { memcpy(&q->scfdma_symbols[sample_pos], - &sf_buffer[k + i * q->cell.nof_prb * SRSLTE_NRE], - sizeof(cf_t) * (SRSLTE_NRE * q->pscch_nof_prb)); - sample_pos += (SRSLTE_NRE * q->pscch_nof_prb); + &sf_buffer[k + i * q->cell.nof_prb * SRSRAN_NRE], + sizeof(cf_t) * (SRSRAN_NRE * q->pscch_nof_prb)); + sample_pos += (SRSRAN_NRE * q->pscch_nof_prb); } } // Force zeros in last symbol - srslte_vec_cf_zero(&q->scfdma_symbols[sample_pos], SRSLTE_NRE * q->pscch_nof_prb); + srsran_vec_cf_zero(&q->scfdma_symbols[sample_pos], SRSRAN_NRE * q->pscch_nof_prb); return sample_pos; } -void srslte_pscch_free(srslte_pscch_t* q) +void srsran_pscch_free(srsran_pscch_t* q) { if (q != NULL) { - srslte_dft_precoding_free(&q->dft_precoder); - srslte_dft_precoding_free(&q->idft_precoder); - srslte_viterbi_free(&q->dec); - srslte_sequence_free(&q->seq); - srslte_modem_table_free(&q->mod); + srsran_dft_precoding_free(&q->dft_precoder); + srsran_dft_precoding_free(&q->idft_precoder); + srsran_viterbi_free(&q->dec); + srsran_sequence_free(&q->seq); + srsran_modem_table_free(&q->mod); if (q->sci_crc) { free(q->sci_crc); @@ -371,6 +371,6 @@ void srslte_pscch_free(srslte_pscch_t* q) free(q->scfdma_symbols); } - bzero(q, sizeof(srslte_pscch_t)); + bzero(q, sizeof(srsran_pscch_t)); } } diff --git a/lib/src/phy/phch/pssch.c b/lib/src/phy/phch/pssch.c index 965d7dc20..2bf6282c0 100644 --- a/lib/src/phy/phch/pssch.c +++ b/lib/src/phy/phch/pssch.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -12,250 +12,250 @@ #include -#include "srslte/phy/fec/turbo/rm_turbo.h" -#include "srslte/phy/modem/demod_soft.h" -#include "srslte/phy/phch/pssch.h" -#include "srslte/phy/phch/ra.h" -#include "srslte/phy/phch/sch.h" -#include "srslte/phy/utils/bit.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/fec/turbo/rm_turbo.h" +#include "srsran/phy/modem/demod_soft.h" +#include "srsran/phy/phch/pssch.h" +#include "srsran/phy/phch/ra.h" +#include "srsran/phy/phch/sch.h" +#include "srsran/phy/utils/bit.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" -int srslte_pssch_init(srslte_pssch_t* q, srslte_cell_sl_t cell, srslte_sl_comm_resource_pool_t sl_comm_resource_pool) +int srsran_pssch_init(srsran_pssch_t* q, srsran_cell_sl_t cell, srsran_sl_comm_resource_pool_t sl_comm_resource_pool) { if (q == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } q->cell = cell; q->sl_comm_resource_pool = sl_comm_resource_pool; - if (cell.tm == SRSLTE_SIDELINK_TM1 || cell.tm == SRSLTE_SIDELINK_TM2) { - if (cell.cp == SRSLTE_CP_NORM) { - q->nof_data_symbols = SRSLTE_PSSCH_TM12_NUM_DATA_SYMBOLS; + if (cell.tm == SRSRAN_SIDELINK_TM1 || cell.tm == SRSRAN_SIDELINK_TM2) { + if (cell.cp == SRSRAN_CP_NORM) { + q->nof_data_symbols = SRSRAN_PSSCH_TM12_NUM_DATA_SYMBOLS; } else { - q->nof_data_symbols = SRSLTE_PSSCH_TM12_NUM_DATA_SYMBOLS_CP_EXT; + q->nof_data_symbols = SRSRAN_PSSCH_TM12_NUM_DATA_SYMBOLS_CP_EXT; } - } else if (cell.tm == SRSLTE_SIDELINK_TM3 || cell.tm == SRSLTE_SIDELINK_TM4) { - if (cell.cp == SRSLTE_CP_NORM) { - q->nof_data_symbols = SRSLTE_PSSCH_TM34_NUM_DATA_SYMBOLS; + } else if (cell.tm == SRSRAN_SIDELINK_TM3 || cell.tm == SRSRAN_SIDELINK_TM4) { + if (cell.cp == SRSRAN_CP_NORM) { + q->nof_data_symbols = SRSRAN_PSSCH_TM34_NUM_DATA_SYMBOLS; } else { ERROR("Invalid CP for PSSCH, SL TM 3/4"); - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } } else { ERROR("Invalid SL TM"); - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } // Transport Block - q->b = srslte_vec_u8_malloc(SRSLTE_SL_SCH_MAX_TB_LEN + SRSLTE_PSSCH_CRC_LEN); + q->b = srsran_vec_u8_malloc(SRSRAN_SL_SCH_MAX_TB_LEN + SRSRAN_PSSCH_CRC_LEN); if (!q->b) { ERROR("Error allocating memory"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Transport Block CRC - if (srslte_crc_init(&q->tb_crc, SRSLTE_LTE_CRC24A, SRSLTE_PSSCH_CRC_LEN)) { + if (srsran_crc_init(&q->tb_crc, SRSRAN_LTE_CRC24A, SRSRAN_PSSCH_CRC_LEN)) { ERROR("Error Transport Block CRC init"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - q->tb_crc_temp = srslte_vec_u8_malloc(SRSLTE_PSSCH_CRC_LEN); + q->tb_crc_temp = srsran_vec_u8_malloc(SRSRAN_PSSCH_CRC_LEN); if (!q->tb_crc_temp) { ERROR("Error allocating memory"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Code Block Segmentation - q->c_r = srslte_vec_u8_malloc(SRSLTE_TCOD_MAX_LEN_CB); + q->c_r = srsran_vec_u8_malloc(SRSRAN_TCOD_MAX_LEN_CB); if (!q->c_r) { ERROR("Error allocating memory"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - q->f_16 = srslte_vec_i16_malloc(SRSLTE_MAX_CODEWORD_LEN); + q->f_16 = srsran_vec_i16_malloc(SRSRAN_MAX_CODEWORD_LEN); if (!q->f_16) { ERROR("Error allocating memory"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - q->c_r_bytes = srslte_vec_u8_malloc(SRSLTE_TCOD_MAX_LEN_CB / 8); + q->c_r_bytes = srsran_vec_u8_malloc(SRSRAN_TCOD_MAX_LEN_CB / 8); if (!q->c_r_bytes) { ERROR("Error allocating memory"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Code Block CRC - if (srslte_crc_init(&q->cb_crc, SRSLTE_LTE_CRC24B, SRSLTE_PSSCH_CRC_LEN)) { + if (srsran_crc_init(&q->cb_crc, SRSRAN_LTE_CRC24B, SRSRAN_PSSCH_CRC_LEN)) { ERROR("Error Code Block CRC init"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - q->cb_crc_temp = srslte_vec_u8_malloc(SRSLTE_PSSCH_CRC_LEN); + q->cb_crc_temp = srsran_vec_u8_malloc(SRSRAN_PSSCH_CRC_LEN); if (!q->cb_crc_temp) { ERROR("Error allocating memory"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Channel Coding - srslte_tcod_init(&q->tcod, SRSLTE_TCOD_MAX_LEN_CB); - q->d_r = srslte_vec_u8_malloc(SRSLTE_PSSCH_MAX_CODED_BITS); + srsran_tcod_init(&q->tcod, SRSRAN_TCOD_MAX_LEN_CB); + q->d_r = srsran_vec_u8_malloc(SRSRAN_PSSCH_MAX_CODED_BITS); if (!q->d_r) { ERROR("Error allocating memory"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - srslte_tdec_init(&q->tdec, SRSLTE_TCOD_MAX_LEN_CB); - srslte_tdec_force_not_sb(&q->tdec); - q->d_r_16 = srslte_vec_i16_malloc(SRSLTE_PSSCH_MAX_CODED_BITS); + srsran_tdec_init(&q->tdec, SRSRAN_TCOD_MAX_LEN_CB); + srsran_tdec_force_not_sb(&q->tdec); + q->d_r_16 = srsran_vec_i16_malloc(SRSRAN_PSSCH_MAX_CODED_BITS); if (!q->d_r_16) { ERROR("Error allocating memory"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Rate Matching - q->e_r = srslte_vec_u8_malloc(SRSLTE_MAX_CODEWORD_LEN); + q->e_r = srsran_vec_u8_malloc(SRSRAN_MAX_CODEWORD_LEN); if (!q->e_r) { ERROR("Error allocating memory"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - q->buff_b = srslte_vec_u8_malloc(SRSLTE_PSSCH_MAX_CODED_BITS); + q->buff_b = srsran_vec_u8_malloc(SRSRAN_PSSCH_MAX_CODED_BITS); if (!q->buff_b) { ERROR("Error allocating memory"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - srslte_vec_u8_zero(q->buff_b, SRSLTE_PSSCH_MAX_CODED_BITS); - q->e_r_16 = srslte_vec_i16_malloc(SRSLTE_MAX_CODEWORD_LEN); + srsran_vec_u8_zero(q->buff_b, SRSRAN_PSSCH_MAX_CODED_BITS); + q->e_r_16 = srsran_vec_i16_malloc(SRSRAN_MAX_CODEWORD_LEN); if (!q->e_r_16) { ERROR("Error allocating memory"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - srslte_rm_turbo_gentables(); + srsran_rm_turbo_gentables(); // Code Block Concatenation - q->f = srslte_vec_u8_malloc(SRSLTE_MAX_CODEWORD_LEN); + q->f = srsran_vec_u8_malloc(SRSRAN_MAX_CODEWORD_LEN); if (!q->f) { ERROR("Error allocating memory"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Interleaving - q->f_bytes = srslte_vec_u8_malloc(SRSLTE_MAX_CODEWORD_LEN / 8); + q->f_bytes = srsran_vec_u8_malloc(SRSRAN_MAX_CODEWORD_LEN / 8); if (!q->f_bytes) { ERROR("Error allocating memory"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - q->interleaver_lut = srslte_vec_u32_malloc(SRSLTE_MAX_CODEWORD_LEN); + q->interleaver_lut = srsran_vec_u32_malloc(SRSRAN_MAX_CODEWORD_LEN); if (!q->interleaver_lut) { ERROR("Error allocating memory"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - srslte_vec_u32_zero(q->interleaver_lut, SRSLTE_MAX_CODEWORD_LEN); + srsran_vec_u32_zero(q->interleaver_lut, SRSRAN_MAX_CODEWORD_LEN); // Scrambling - q->codeword = srslte_vec_u8_malloc(SRSLTE_MAX_CODEWORD_LEN); + q->codeword = srsran_vec_u8_malloc(SRSRAN_MAX_CODEWORD_LEN); if (!q->codeword) { ERROR("Error allocating memory"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - q->codeword_bytes = srslte_vec_u8_malloc(SRSLTE_MAX_CODEWORD_LEN / 8); + q->codeword_bytes = srsran_vec_u8_malloc(SRSRAN_MAX_CODEWORD_LEN / 8); if (!q->codeword_bytes) { ERROR("Error allocating memory"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Modulation - q->symbols = srslte_vec_cf_malloc(SRSLTE_MAX_CODEWORD_LEN); + q->symbols = srsran_vec_cf_malloc(SRSRAN_MAX_CODEWORD_LEN); if (!q->symbols) { ERROR("Error allocating memory"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - srslte_vec_cf_zero(q->symbols, SRSLTE_MAX_CODEWORD_LEN); + srsran_vec_cf_zero(q->symbols, SRSRAN_MAX_CODEWORD_LEN); - q->bits_after_demod = srslte_vec_u8_malloc(SRSLTE_MAX_CODEWORD_LEN); + q->bits_after_demod = srsran_vec_u8_malloc(SRSRAN_MAX_CODEWORD_LEN); if (!q->bits_after_demod) { ERROR("Error allocating memory"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - q->bytes_after_demod = srslte_vec_u8_malloc(SRSLTE_MAX_CODEWORD_LEN / 8); + q->bytes_after_demod = srsran_vec_u8_malloc(SRSRAN_MAX_CODEWORD_LEN / 8); if (!q->bytes_after_demod) { ERROR("Error allocating memory"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - for (int i = 0; i < SRSLTE_MOD_NITEMS; i++) { - if (srslte_modem_table_lte(&q->mod[i], (srslte_mod_t)i)) { + for (int i = 0; i < SRSRAN_MOD_NITEMS; i++) { + if (srsran_modem_table_lte(&q->mod[i], (srsran_mod_t)i)) { ERROR("Error initiating modem tables"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } // Demodulation - q->llr = srslte_vec_i16_malloc(SRSLTE_MAX_CODEWORD_LEN); + q->llr = srsran_vec_i16_malloc(SRSRAN_MAX_CODEWORD_LEN); if (!q->llr) { ERROR("Error allocating memory"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Transform Precoding - q->scfdma_symbols = srslte_vec_cf_malloc(q->nof_data_symbols * SRSLTE_NRE * SRSLTE_MAX_PRB); + q->scfdma_symbols = srsran_vec_cf_malloc(q->nof_data_symbols * SRSRAN_NRE * SRSRAN_MAX_PRB); if (!q->scfdma_symbols) { ERROR("Error allocating memory"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_dft_precoding_init(&q->dft_precoder, SRSLTE_MAX_PRB, true)) { + if (srsran_dft_precoding_init(&q->dft_precoder, SRSRAN_MAX_PRB, true)) { ERROR("Error DFT precoder init"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_dft_precoding_init(&q->idft_precoder, SRSLTE_MAX_PRB, false)) { + if (srsran_dft_precoding_init(&q->idft_precoder, SRSRAN_MAX_PRB, false)) { ERROR("Error in DFT precoder init"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_pssch_set_cfg(srslte_pssch_t* q, srslte_pssch_cfg_t pssch_cfg) +int srsran_pssch_set_cfg(srsran_pssch_t* q, srsran_pssch_cfg_t pssch_cfg) { if (q == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } q->pssch_cfg = pssch_cfg; - q->mod_idx = srslte_ra_ul_mod_from_mcs(pssch_cfg.mcs_idx); - q->Qm = srslte_mod_bits_x_symbol(q->mod_idx); + q->mod_idx = srsran_ra_ul_mod_from_mcs(pssch_cfg.mcs_idx); + q->Qm = srsran_mod_bits_x_symbol(q->mod_idx); q->sl_sch_tb_len = - srslte_ra_tbs_from_idx(srslte_ra_tbs_idx_from_mcs(pssch_cfg.mcs_idx, false, true), pssch_cfg.nof_prb); + srsran_ra_tbs_from_idx(srsran_ra_tbs_idx_from_mcs(pssch_cfg.mcs_idx, false, true), pssch_cfg.nof_prb); - if (q->cell.tm == SRSLTE_SIDELINK_TM1 || q->cell.tm == SRSLTE_SIDELINK_TM2) { - q->nof_data_symbols = SRSLTE_PSSCH_TM12_NUM_DATA_SYMBOLS; + if (q->cell.tm == SRSRAN_SIDELINK_TM1 || q->cell.tm == SRSRAN_SIDELINK_TM2) { + q->nof_data_symbols = SRSRAN_PSSCH_TM12_NUM_DATA_SYMBOLS; - if (q->cell.cp == SRSLTE_CP_EXT) { - q->nof_data_symbols = SRSLTE_PSSCH_TM12_NUM_DATA_SYMBOLS_CP_EXT; + if (q->cell.cp == SRSRAN_CP_EXT) { + q->nof_data_symbols = SRSRAN_PSSCH_TM12_NUM_DATA_SYMBOLS_CP_EXT; } - } else if (q->cell.tm == SRSLTE_SIDELINK_TM3 || q->cell.tm == SRSLTE_SIDELINK_TM4) { - q->nof_data_symbols = SRSLTE_PSSCH_TM34_NUM_DATA_SYMBOLS; + } else if (q->cell.tm == SRSRAN_SIDELINK_TM3 || q->cell.tm == SRSRAN_SIDELINK_TM4) { + q->nof_data_symbols = SRSRAN_PSSCH_TM34_NUM_DATA_SYMBOLS; } else { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } q->nof_tx_symbols = q->nof_data_symbols - 1; // Last OFDM symbol is used in channel processing but not transmitted - q->nof_tx_re = q->nof_tx_symbols * SRSLTE_NRE * pssch_cfg.nof_prb; - q->nof_data_re = q->nof_data_symbols * SRSLTE_NRE * pssch_cfg.nof_prb; + q->nof_tx_re = q->nof_tx_symbols * SRSRAN_NRE * pssch_cfg.nof_prb; + q->nof_data_re = q->nof_data_symbols * SRSRAN_NRE * pssch_cfg.nof_prb; q->E = q->nof_data_re * q->Qm; - q->G = srslte_mod_bits_x_symbol(srslte_ra_ul_mod_from_mcs(pssch_cfg.mcs_idx)) * q->nof_data_re; + q->G = srsran_mod_bits_x_symbol(srsran_ra_ul_mod_from_mcs(pssch_cfg.mcs_idx)) * q->nof_data_re; q->scfdma_symbols_len = q->G / q->Qm; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_pssch_encode(srslte_pssch_t* q, uint8_t* input, uint32_t input_len, cf_t* sf_buffer) +int srsran_pssch_encode(srsran_pssch_t* q, uint8_t* input, uint32_t input_len, cf_t* sf_buffer) { if (!input || input_len > q->sl_sch_tb_len) { ERROR("Can't encode PSSCH, input too long (%d > %d)", input_len, q->sl_sch_tb_len); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - srslte_cbsegm(&q->cb_segm, q->sl_sch_tb_len); - uint32_t L = SRSLTE_PSSCH_CRC_LEN; + srsran_cbsegm(&q->cb_segm, q->sl_sch_tb_len); + uint32_t L = SRSRAN_PSSCH_CRC_LEN; if (q->cb_segm.C == 1) { L = 0; } @@ -271,7 +271,7 @@ int srslte_pssch_encode(srslte_pssch_t* q, uint8_t* input, uint32_t input_len, c memcpy(q->b, input, sizeof(uint8_t) * input_len); // Transport block CRC attachment - srslte_crc_attach(&q->tb_crc, q->b, q->sl_sch_tb_len); + srsran_crc_attach(&q->tb_crc, q->b, q->sl_sch_tb_len); for (int r = 0; r < q->cb_segm.C; r++) { // Code block segmentation @@ -288,7 +288,7 @@ int srslte_pssch_encode(srslte_pssch_t* q, uint8_t* input, uint32_t input_len, c } if (r == 0) { - memset(q->c_r, SRSLTE_TX_NULL, sizeof(uint8_t) * q->cb_segm.F); + memset(q->c_r, SRSRAN_TX_NULL, sizeof(uint8_t) * q->cb_segm.F); memcpy(&q->c_r[q->cb_segm.F], q->b, sizeof(uint8_t) * (K_r - L)); s += (K_r - L - q->cb_segm.F); } else { @@ -299,29 +299,29 @@ int srslte_pssch_encode(srslte_pssch_t* q, uint8_t* input, uint32_t input_len, c // Code block CRC attachment if (q->cb_segm.C > 1) { if (r == 0) { - srslte_vec_u8_zero(q->c_r, q->cb_segm.F); + srsran_vec_u8_zero(q->c_r, q->cb_segm.F); } - srslte_crc_attach(&q->cb_crc, q->c_r, (int)(K_r - L)); + srsran_crc_attach(&q->cb_crc, q->c_r, (int)(K_r - L)); if (r == 0) { - memset(q->c_r, SRSLTE_TX_NULL, sizeof(uint8_t) * q->cb_segm.F); + memset(q->c_r, SRSRAN_TX_NULL, sizeof(uint8_t) * q->cb_segm.F); } } // Channel coding - srslte_tcod_encode(&q->tcod, q->c_r, q->d_r, K_r); + srsran_tcod_encode(&q->tcod, q->c_r, q->d_r, K_r); // Rate matching - srslte_vec_u8_zero(q->buff_b, SRSLTE_PSSCH_MAX_CODED_BITS); - srslte_rm_turbo_tx(q->buff_b, SRSLTE_PSSCH_MAX_CODED_BITS, q->d_r, 3 * K_r + SRSLTE_TCOD_TOTALTAIL, q->e_r, E_r, 0); + srsran_vec_u8_zero(q->buff_b, SRSRAN_PSSCH_MAX_CODED_BITS); + srsran_rm_turbo_tx(q->buff_b, SRSRAN_PSSCH_MAX_CODED_BITS, q->d_r, 3 * K_r + SRSRAN_TCOD_TOTALTAIL, q->e_r, E_r, 0); if (q->pssch_cfg.rv_idx > 0) { - srslte_rm_turbo_tx(q->buff_b, - SRSLTE_PSSCH_MAX_CODED_BITS, + srsran_rm_turbo_tx(q->buff_b, + SRSRAN_PSSCH_MAX_CODED_BITS, q->d_r, - 3 * K_r + SRSLTE_TCOD_TOTALTAIL, + 3 * K_r + SRSRAN_TCOD_TOTALTAIL, q->e_r, E_r, - srslte_pssch_rv[q->pssch_cfg.rv_idx]); + srsran_pssch_rv[q->pssch_cfg.rv_idx]); } // Code block concatenation @@ -330,49 +330,49 @@ int srslte_pssch_encode(srslte_pssch_t* q, uint8_t* input, uint32_t input_len, c } // Interleaving - srslte_bit_pack_vector(q->f, q->f_bytes, q->G); - srslte_sl_ulsch_interleave(q->f_bytes, q->Qm, q->G / q->Qm, q->nof_data_symbols, q->codeword_bytes); - srslte_bit_unpack_vector(q->codeword_bytes, q->codeword, q->G); + srsran_bit_pack_vector(q->f, q->f_bytes, q->G); + srsran_sl_ulsch_interleave(q->f_bytes, q->Qm, q->G / q->Qm, q->nof_data_symbols, q->codeword_bytes); + srsran_bit_unpack_vector(q->codeword_bytes, q->codeword, q->G); // Scrambling follows 3GPP TS 36.211 version 15.6.0 Release 15 Sec. 9.3.1 - srslte_sequence_LTE_pr( + srsran_sequence_LTE_pr( &q->scrambling_seq, q->G, q->pssch_cfg.N_x_id * 16384 + (q->pssch_cfg.sf_idx % 10) * 512 + 510); - srslte_scrambling_b(&q->scrambling_seq, q->codeword); + srsran_scrambling_b(&q->scrambling_seq, q->codeword); // Modulation - srslte_mod_modulate(&q->mod[q->mod_idx], q->codeword, q->symbols, q->G); + srsran_mod_modulate(&q->mod[q->mod_idx], q->codeword, q->symbols, q->G); // Layer Mapping // Voided: Single layer // 3GPP TS 36.211 version 15.6.0 Release 15 Sec. 9.3.3 // Transform Precoding - srslte_dft_precoding(&q->dft_precoder, q->symbols, q->scfdma_symbols, q->pssch_cfg.nof_prb, q->nof_data_symbols); + srsran_dft_precoding(&q->dft_precoder, q->symbols, q->scfdma_symbols, q->pssch_cfg.nof_prb, q->nof_data_symbols); // Precoding // Voided: Single antenna port // 3GPP TS 36.211 version 15.6.0 Release 15 Sec. 9.3.5 // RE mapping - if (q->nof_tx_re != srslte_pssch_put(q, sf_buffer, q->scfdma_symbols)) { + if (q->nof_tx_re != srsran_pssch_put(q, sf_buffer, q->scfdma_symbols)) { ERROR("There was an error mapping the PSSCH symbols"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_pssch_decode(srslte_pssch_t* q, cf_t* equalized_sf_syms, uint8_t* output, uint32_t output_len) +int srsran_pssch_decode(srsran_pssch_t* q, cf_t* equalized_sf_syms, uint8_t* output, uint32_t output_len) { if (output_len < q->sl_sch_tb_len) { ERROR("Can't decode PSSCH, provided buffer too small (%d < %d)", output_len, q->sl_sch_tb_len); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // RE extraction - if (q->nof_tx_re != srslte_pssch_get(q, equalized_sf_syms, q->scfdma_symbols)) { + if (q->nof_tx_re != srsran_pssch_get(q, equalized_sf_syms, q->scfdma_symbols)) { ERROR("There was an error getting the PSSCH symbols"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Precoding @@ -380,10 +380,10 @@ int srslte_pssch_decode(srslte_pssch_t* q, cf_t* equalized_sf_syms, uint8_t* out // 3GPP TS 36.211 version 15.6.0 Release 15 Sec. 9.3.5 // Transform Predecoding - if (srslte_dft_precoding( + if (srsran_dft_precoding( &q->idft_precoder, q->scfdma_symbols, q->symbols, q->pssch_cfg.nof_prb, q->nof_data_symbols) != - SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } // Layer Mapping @@ -391,15 +391,15 @@ int srslte_pssch_decode(srslte_pssch_t* q, cf_t* equalized_sf_syms, uint8_t* out // 3GPP TS 36.211 version 15.6.0 Release 15 Sec. 9.3.3 // Demodulation - srslte_demod_soft_demodulate_s(q->Qm / 2, q->symbols, q->llr, q->G / q->Qm); + srsran_demod_soft_demodulate_s(q->Qm / 2, q->symbols, q->llr, q->G / q->Qm); // Descramble follows 3GPP TS 36.211 version 15.6.0 Release 15 Sec. 9.3.1 - srslte_sequence_LTE_pr( + srsran_sequence_LTE_pr( &q->scrambling_seq, q->G, q->pssch_cfg.N_x_id * 16384 + (q->pssch_cfg.sf_idx % 10) * 512 + 510); - srslte_scrambling_s(&q->scrambling_seq, q->llr); + srsran_scrambling_s(&q->scrambling_seq, q->llr); - srslte_cbsegm(&q->cb_segm, q->sl_sch_tb_len); - uint32_t L = SRSLTE_PSSCH_CRC_LEN; + srsran_cbsegm(&q->cb_segm, q->sl_sch_tb_len); + uint32_t L = SRSRAN_PSSCH_CRC_LEN; if (q->cb_segm.C == 1) { L = 0; } @@ -412,7 +412,7 @@ int srslte_pssch_decode(srslte_pssch_t* q, cf_t* equalized_sf_syms, uint8_t* out uint32_t gamma = Gp % q->cb_segm.C; // Deinterleaving - srslte_sl_ulsch_deinterleave(q->llr, q->Qm, q->G / q->Qm, q->nof_data_symbols, q->f_16, q->interleaver_lut); + srsran_sl_ulsch_deinterleave(q->llr, q->Qm, q->G / q->Qm, q->nof_data_symbols, q->f_16, q->interleaver_lut); for (int r = 0; r < q->cb_segm.C; r++) { // Code block segmentation @@ -433,24 +433,24 @@ int srslte_pssch_decode(srslte_pssch_t* q, cf_t* equalized_sf_syms, uint8_t* out // Rate matching uint32_t cb_len_idx = r < q->cb_segm.C1 ? q->cb_segm.K1_idx : q->cb_segm.K2_idx; - srslte_vec_i16_zero(q->d_r_16, SRSLTE_PSSCH_MAX_CODED_BITS); - srslte_rm_turbo_rx_lut_(q->e_r_16, q->d_r_16, E_r, cb_len_idx, srslte_pssch_rv[q->pssch_cfg.rv_idx], false); + srsran_vec_i16_zero(q->d_r_16, SRSRAN_PSSCH_MAX_CODED_BITS); + srsran_rm_turbo_rx_lut_(q->e_r_16, q->d_r_16, E_r, cb_len_idx, srsran_pssch_rv[q->pssch_cfg.rv_idx], false); // Channel decoding - srslte_tdec_new_cb(&q->tdec, K_r); - srslte_tdec_run_all(&q->tdec, q->d_r_16, q->c_r_bytes, 3, K_r); - srslte_bit_unpack_vector(q->c_r_bytes, q->c_r, K_r); + srsran_tdec_new_cb(&q->tdec, K_r); + srsran_tdec_run_all(&q->tdec, q->d_r_16, q->c_r_bytes, 3, K_r); + srsran_bit_unpack_vector(q->c_r_bytes, q->c_r, K_r); if (q->cb_segm.C > 1) { // Copy received crc to temp memcpy(q->cb_crc_temp, &q->c_r[(K_r - L)], sizeof(uint8_t) * L); // Re-attach crc - srslte_crc_attach(&q->cb_crc, q->c_r, (int)(K_r - L)); + srsran_crc_attach(&q->cb_crc, q->c_r, (int)(K_r - L)); // CRC check - if (srslte_bit_diff(q->cb_crc_temp, &q->c_r[(K_r - L)], L) != 0) { - return SRSLTE_ERROR; + if (srsran_bit_diff(q->cb_crc_temp, &q->c_r[(K_r - L)], L) != 0) { + return SRSRAN_ERROR; } } @@ -465,60 +465,60 @@ int srslte_pssch_decode(srslte_pssch_t* q, cf_t* equalized_sf_syms, uint8_t* out } // Copy received crc to temp - memcpy(q->tb_crc_temp, &q->b[B - SRSLTE_PSSCH_CRC_LEN], sizeof(uint8_t) * SRSLTE_PSSCH_CRC_LEN); + memcpy(q->tb_crc_temp, &q->b[B - SRSRAN_PSSCH_CRC_LEN], sizeof(uint8_t) * SRSRAN_PSSCH_CRC_LEN); // Re-attach crc - srslte_crc_attach(&q->tb_crc, q->b, (int)(B - SRSLTE_PSSCH_CRC_LEN)); + srsran_crc_attach(&q->tb_crc, q->b, (int)(B - SRSRAN_PSSCH_CRC_LEN)); // CRC check - if (srslte_bit_diff(q->tb_crc_temp, &q->b[(B - SRSLTE_PSSCH_CRC_LEN)], SRSLTE_PSSCH_CRC_LEN) != 0) { - return SRSLTE_ERROR; + if (srsran_bit_diff(q->tb_crc_temp, &q->b[(B - SRSRAN_PSSCH_CRC_LEN)], SRSRAN_PSSCH_CRC_LEN) != 0) { + return SRSRAN_ERROR; } // Remove CRC and copy to output buffer memcpy(output, q->b, sizeof(uint8_t) * q->sl_sch_tb_len); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_pssch_put(srslte_pssch_t* q, cf_t* sf_buffer, cf_t* symbols) +int srsran_pssch_put(srsran_pssch_t* q, cf_t* sf_buffer, cf_t* symbols) { uint32_t sample_pos = 0; - uint32_t k = q->pssch_cfg.prb_start_idx * SRSLTE_NRE; - for (int i = 0; i < srslte_sl_get_num_symbols(q->cell.tm, q->cell.cp); i++) { - if (srslte_pssch_is_symbol(SRSLTE_SIDELINK_DATA_SYMBOL, q->cell.tm, i, q->cell.cp)) { - if (q->cell.tm == SRSLTE_SIDELINK_TM1 || q->cell.tm == SRSLTE_SIDELINK_TM2) { + uint32_t k = q->pssch_cfg.prb_start_idx * SRSRAN_NRE; + for (int i = 0; i < srsran_sl_get_num_symbols(q->cell.tm, q->cell.cp); i++) { + if (srsran_pssch_is_symbol(SRSRAN_SIDELINK_DATA_SYMBOL, q->cell.tm, i, q->cell.cp)) { + if (q->cell.tm == SRSRAN_SIDELINK_TM1 || q->cell.tm == SRSRAN_SIDELINK_TM2) { if (q->pssch_cfg.nof_prb <= q->sl_comm_resource_pool.prb_num) { - k = q->pssch_cfg.prb_start_idx * SRSLTE_NRE; - memcpy(&sf_buffer[k + i * q->cell.nof_prb * SRSLTE_NRE], + k = q->pssch_cfg.prb_start_idx * SRSRAN_NRE; + memcpy(&sf_buffer[k + i * q->cell.nof_prb * SRSRAN_NRE], &symbols[sample_pos], - sizeof(cf_t) * (SRSLTE_NRE * q->pssch_cfg.nof_prb)); - sample_pos += (SRSLTE_NRE * q->pssch_cfg.nof_prb); + sizeof(cf_t) * (SRSRAN_NRE * q->pssch_cfg.nof_prb)); + sample_pos += (SRSRAN_NRE * q->pssch_cfg.nof_prb); } else { // First band - k = q->pssch_cfg.prb_start_idx * SRSLTE_NRE; - memcpy(&sf_buffer[k + i * q->cell.nof_prb * SRSLTE_NRE], + k = q->pssch_cfg.prb_start_idx * SRSRAN_NRE; + memcpy(&sf_buffer[k + i * q->cell.nof_prb * SRSRAN_NRE], &symbols[sample_pos], - sizeof(cf_t) * (SRSLTE_NRE * q->sl_comm_resource_pool.prb_num)); - sample_pos += (SRSLTE_NRE * q->sl_comm_resource_pool.prb_num); + sizeof(cf_t) * (SRSRAN_NRE * q->sl_comm_resource_pool.prb_num)); + sample_pos += (SRSRAN_NRE * q->sl_comm_resource_pool.prb_num); // Second band if ((q->sl_comm_resource_pool.prb_num * 2) > (q->sl_comm_resource_pool.prb_end - q->sl_comm_resource_pool.prb_start + 1)) { - k = (q->sl_comm_resource_pool.prb_end + 1 - q->sl_comm_resource_pool.prb_num + 1) * SRSLTE_NRE; + k = (q->sl_comm_resource_pool.prb_end + 1 - q->sl_comm_resource_pool.prb_num + 1) * SRSRAN_NRE; } else { - k = (q->sl_comm_resource_pool.prb_end + 1 - q->sl_comm_resource_pool.prb_num) * SRSLTE_NRE; + k = (q->sl_comm_resource_pool.prb_end + 1 - q->sl_comm_resource_pool.prb_num) * SRSRAN_NRE; } - memcpy(&sf_buffer[k + i * q->cell.nof_prb * SRSLTE_NRE], + memcpy(&sf_buffer[k + i * q->cell.nof_prb * SRSRAN_NRE], &symbols[sample_pos], - sizeof(cf_t) * (SRSLTE_NRE * (q->pssch_cfg.nof_prb - q->sl_comm_resource_pool.prb_num))); - sample_pos += (SRSLTE_NRE * (q->pssch_cfg.nof_prb - q->sl_comm_resource_pool.prb_num)); + sizeof(cf_t) * (SRSRAN_NRE * (q->pssch_cfg.nof_prb - q->sl_comm_resource_pool.prb_num))); + sample_pos += (SRSRAN_NRE * (q->pssch_cfg.nof_prb - q->sl_comm_resource_pool.prb_num)); } - } else if (q->cell.tm == SRSLTE_SIDELINK_TM3 || q->cell.tm == SRSLTE_SIDELINK_TM4) { - memcpy(&sf_buffer[k + i * q->cell.nof_prb * SRSLTE_NRE], + } else if (q->cell.tm == SRSRAN_SIDELINK_TM3 || q->cell.tm == SRSRAN_SIDELINK_TM4) { + memcpy(&sf_buffer[k + i * q->cell.nof_prb * SRSRAN_NRE], &symbols[sample_pos], - sizeof(cf_t) * (SRSLTE_NRE * q->pssch_cfg.nof_prb)); - sample_pos += (SRSLTE_NRE * q->pssch_cfg.nof_prb); + sizeof(cf_t) * (SRSRAN_NRE * q->pssch_cfg.nof_prb)); + sample_pos += (SRSRAN_NRE * q->pssch_cfg.nof_prb); } } } @@ -526,44 +526,44 @@ int srslte_pssch_put(srslte_pssch_t* q, cf_t* sf_buffer, cf_t* symbols) return sample_pos; } -int srslte_pssch_get(srslte_pssch_t* q, cf_t* sf_buffer, cf_t* symbols) +int srsran_pssch_get(srsran_pssch_t* q, cf_t* sf_buffer, cf_t* symbols) { uint32_t sample_pos = 0; - uint32_t k = q->pssch_cfg.prb_start_idx * SRSLTE_NRE; - for (int i = 0; i < srslte_sl_get_num_symbols(q->cell.tm, q->cell.cp); i++) { - if (srslte_pssch_is_symbol(SRSLTE_SIDELINK_DATA_SYMBOL, q->cell.tm, i, q->cell.cp)) { - if (q->cell.tm == SRSLTE_SIDELINK_TM1 || q->cell.tm == SRSLTE_SIDELINK_TM2) { + uint32_t k = q->pssch_cfg.prb_start_idx * SRSRAN_NRE; + for (int i = 0; i < srsran_sl_get_num_symbols(q->cell.tm, q->cell.cp); i++) { + if (srsran_pssch_is_symbol(SRSRAN_SIDELINK_DATA_SYMBOL, q->cell.tm, i, q->cell.cp)) { + if (q->cell.tm == SRSRAN_SIDELINK_TM1 || q->cell.tm == SRSRAN_SIDELINK_TM2) { if (q->pssch_cfg.nof_prb <= q->sl_comm_resource_pool.prb_num) { - k = q->pssch_cfg.prb_start_idx * SRSLTE_NRE; + k = q->pssch_cfg.prb_start_idx * SRSRAN_NRE; memcpy(&symbols[sample_pos], - &sf_buffer[k + i * q->cell.nof_prb * SRSLTE_NRE], - sizeof(cf_t) * (SRSLTE_NRE * q->pssch_cfg.nof_prb)); - sample_pos += (SRSLTE_NRE * q->pssch_cfg.nof_prb); + &sf_buffer[k + i * q->cell.nof_prb * SRSRAN_NRE], + sizeof(cf_t) * (SRSRAN_NRE * q->pssch_cfg.nof_prb)); + sample_pos += (SRSRAN_NRE * q->pssch_cfg.nof_prb); } else { // First band - k = q->pssch_cfg.prb_start_idx * SRSLTE_NRE; + k = q->pssch_cfg.prb_start_idx * SRSRAN_NRE; memcpy(&symbols[sample_pos], - &sf_buffer[k + i * q->cell.nof_prb * SRSLTE_NRE], - sizeof(cf_t) * (SRSLTE_NRE * q->sl_comm_resource_pool.prb_num)); - sample_pos += (SRSLTE_NRE * q->sl_comm_resource_pool.prb_num); + &sf_buffer[k + i * q->cell.nof_prb * SRSRAN_NRE], + sizeof(cf_t) * (SRSRAN_NRE * q->sl_comm_resource_pool.prb_num)); + sample_pos += (SRSRAN_NRE * q->sl_comm_resource_pool.prb_num); // Second band if ((q->sl_comm_resource_pool.prb_num * 2) > (q->sl_comm_resource_pool.prb_end - q->sl_comm_resource_pool.prb_start + 1)) { - k = (q->sl_comm_resource_pool.prb_end + 1 - q->sl_comm_resource_pool.prb_num + 1) * SRSLTE_NRE; + k = (q->sl_comm_resource_pool.prb_end + 1 - q->sl_comm_resource_pool.prb_num + 1) * SRSRAN_NRE; } else { - k = (q->sl_comm_resource_pool.prb_end + 1 - q->sl_comm_resource_pool.prb_num) * SRSLTE_NRE; + k = (q->sl_comm_resource_pool.prb_end + 1 - q->sl_comm_resource_pool.prb_num) * SRSRAN_NRE; } memcpy(&symbols[sample_pos], - &sf_buffer[k + i * q->cell.nof_prb * SRSLTE_NRE], - sizeof(cf_t) * (SRSLTE_NRE * (q->pssch_cfg.nof_prb - q->sl_comm_resource_pool.prb_num))); - sample_pos += (SRSLTE_NRE * (q->pssch_cfg.nof_prb - q->sl_comm_resource_pool.prb_num)); + &sf_buffer[k + i * q->cell.nof_prb * SRSRAN_NRE], + sizeof(cf_t) * (SRSRAN_NRE * (q->pssch_cfg.nof_prb - q->sl_comm_resource_pool.prb_num))); + sample_pos += (SRSRAN_NRE * (q->pssch_cfg.nof_prb - q->sl_comm_resource_pool.prb_num)); } - } else if (q->cell.tm == SRSLTE_SIDELINK_TM3 || q->cell.tm == SRSLTE_SIDELINK_TM4) { + } else if (q->cell.tm == SRSRAN_SIDELINK_TM3 || q->cell.tm == SRSRAN_SIDELINK_TM4) { memcpy(&symbols[sample_pos], - &sf_buffer[k + i * q->cell.nof_prb * SRSLTE_NRE], - sizeof(cf_t) * (SRSLTE_NRE * q->pssch_cfg.nof_prb)); - sample_pos += (SRSLTE_NRE * q->pssch_cfg.nof_prb); + &sf_buffer[k + i * q->cell.nof_prb * SRSRAN_NRE], + sizeof(cf_t) * (SRSRAN_NRE * q->pssch_cfg.nof_prb)); + sample_pos += (SRSRAN_NRE * q->pssch_cfg.nof_prb); } } } @@ -571,18 +571,18 @@ int srslte_pssch_get(srslte_pssch_t* q, cf_t* sf_buffer, cf_t* symbols) return sample_pos; } -void srslte_pssch_free(srslte_pssch_t* q) +void srsran_pssch_free(srsran_pssch_t* q) { if (q) { - srslte_dft_precoding_free(&q->dft_precoder); - srslte_dft_precoding_free(&q->idft_precoder); - srslte_tcod_free(&q->tcod); - srslte_tdec_free(&q->tdec); - srslte_sequence_free(&q->scrambling_seq); - srslte_rm_turbo_free_tables(); + srsran_dft_precoding_free(&q->dft_precoder); + srsran_dft_precoding_free(&q->idft_precoder); + srsran_tcod_free(&q->tcod); + srsran_tdec_free(&q->tdec); + srsran_sequence_free(&q->scrambling_seq); + srsran_rm_turbo_free_tables(); - for (int i = 0; i < SRSLTE_MOD_NITEMS; i++) { - srslte_modem_table_free(&q->mod[i]); + for (int i = 0; i < SRSRAN_MOD_NITEMS; i++) { + srsran_modem_table_free(&q->mod[i]); } if (q->b) { @@ -649,6 +649,6 @@ void srslte_pssch_free(srslte_pssch_t* q) free(q->bytes_after_demod); } - bzero(q, sizeof(srslte_pssch_t)); + bzero(q, sizeof(srsran_pssch_t)); } } \ No newline at end of file diff --git a/lib/src/phy/phch/pucch.c b/lib/src/phy/phch/pucch.c index 6cda1d597..225730341 100644 --- a/lib/src/phy/phch/pucch.c +++ b/lib/src/phy/phch/pucch.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,8 +10,8 @@ * */ -#include "srslte/phy/fec/block/block.h" -#include "srslte/srslte.h" +#include "srsran/phy/fec/block/block.h" +#include "srsran/srsran.h" #include #include #include @@ -22,70 +22,70 @@ #include #include -#include "srslte/phy/ch_estimation/refsignal_ul.h" -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/common/sequence.h" -#include "srslte/phy/common/zc_sequence.h" -#include "srslte/phy/mimo/precoding.h" -#include "srslte/phy/modem/demod_soft.h" -#include "srslte/phy/phch/pucch.h" -#include "srslte/phy/scrambling/scrambling.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/ch_estimation/refsignal_ul.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/common/sequence.h" +#include "srsran/phy/common/zc_sequence.h" +#include "srsran/phy/mimo/precoding.h" +#include "srsran/phy/modem/demod_soft.h" +#include "srsran/phy/phch/pucch.h" +#include "srsran/phy/scrambling/scrambling.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" -#define MAX_PUSCH_RE(cp) (2 * SRSLTE_CP_NSYMB(cp) * 12) +#define MAX_PUSCH_RE(cp) (2 * SRSRAN_CP_NSYMB(cp) * 12) /** Initializes the PUCCH transmitter and receiver */ -int srslte_pucch_init_(srslte_pucch_t* q, bool is_ue) +int srsran_pucch_init_(srsran_pucch_t* q, bool is_ue) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL) { - ret = SRSLTE_ERROR; - bzero(q, sizeof(srslte_pucch_t)); + ret = SRSRAN_ERROR; + bzero(q, sizeof(srsran_pucch_t)); - if (srslte_modem_table_lte(&q->mod, SRSLTE_MOD_QPSK)) { - return SRSLTE_ERROR; + if (srsran_modem_table_lte(&q->mod, SRSRAN_MOD_QPSK)) { + return SRSRAN_ERROR; } q->is_ue = is_ue; - if (srslte_sequence_init(&q->seq_f2, 20)) { + if (srsran_sequence_init(&q->seq_f2, 20)) { goto clean_exit; } - srslte_uci_cqi_pucch_init(&q->cqi); + srsran_uci_cqi_pucch_init(&q->cqi); - q->z = srslte_vec_cf_malloc(SRSLTE_PUCCH_MAX_SYMBOLS); - q->z_tmp = srslte_vec_cf_malloc(SRSLTE_PUCCH_MAX_SYMBOLS); + q->z = srsran_vec_cf_malloc(SRSRAN_PUCCH_MAX_SYMBOLS); + q->z_tmp = srsran_vec_cf_malloc(SRSRAN_PUCCH_MAX_SYMBOLS); if (!q->is_ue) { - q->ce = srslte_vec_cf_malloc(SRSLTE_PUCCH_MAX_SYMBOLS); + q->ce = srsran_vec_cf_malloc(SRSRAN_PUCCH_MAX_SYMBOLS); } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } clean_exit: - if (ret == SRSLTE_ERROR) { - srslte_pucch_free(q); + if (ret == SRSRAN_ERROR) { + srsran_pucch_free(q); } return ret; } -int srslte_pucch_init_ue(srslte_pucch_t* q) +int srsran_pucch_init_ue(srsran_pucch_t* q) { - return srslte_pucch_init_(q, true); + return srsran_pucch_init_(q, true); } -int srslte_pucch_init_enb(srslte_pucch_t* q) +int srsran_pucch_init_enb(srsran_pucch_t* q) { - return srslte_pucch_init_(q, false); + return srsran_pucch_init_(q, false); } -void srslte_pucch_free(srslte_pucch_t* q) +void srsran_pucch_free(srsran_pucch_t* q) { - srslte_sequence_free(&q->seq_f2); + srsran_sequence_free(&q->seq_f2); - srslte_uci_cqi_pucch_free(&q->cqi); + srsran_uci_cqi_pucch_free(&q->cqi); if (q->z) { free(q->z); } @@ -96,28 +96,28 @@ void srslte_pucch_free(srslte_pucch_t* q) free(q->ce); } - srslte_modem_table_free(&q->mod); - bzero(q, sizeof(srslte_pucch_t)); + srsran_modem_table_free(&q->mod); + bzero(q, sizeof(srsran_pucch_t)); } -int srslte_pucch_set_cell(srslte_pucch_t* q, srslte_cell_t cell) +int srsran_pucch_set_cell(srsran_pucch_t* q, srsran_cell_t cell) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; - if (q != NULL && srslte_cell_isvalid(&cell)) { + int ret = SRSRAN_ERROR_INVALID_INPUTS; + if (q != NULL && srsran_cell_isvalid(&cell)) { if (cell.id != q->cell.id || q->cell.nof_prb == 0) { q->cell = cell; // Precompute group hopping values u. - if (srslte_group_hopping_f_gh(q->f_gh, q->cell.id)) { - return SRSLTE_ERROR; + if (srsran_group_hopping_f_gh(q->f_gh, q->cell.id)) { + return SRSRAN_ERROR; } - if (srslte_pucch_n_cs_cell(q->cell, q->n_cs_cell)) { - return SRSLTE_ERROR; + if (srsran_pucch_n_cs_cell(q->cell, q->n_cs_cell)) { + return SRSRAN_ERROR; } } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } @@ -151,46 +151,46 @@ static cf_t uci_encode_format1b(uint8_t bits[2]) /* Encode PUCCH bits according to Table 5.4.1-1 in Section 5.4.1 of 36.211 */ static int -uci_mod_bits(srslte_pucch_t* q, srslte_ul_sf_cfg_t* sf, srslte_pucch_cfg_t* cfg, uint8_t bits[SRSLTE_PUCCH_MAX_BITS]) +uci_mod_bits(srsran_pucch_t* q, srsran_ul_sf_cfg_t* sf, srsran_pucch_cfg_t* cfg, uint8_t bits[SRSRAN_PUCCH_MAX_BITS]) { uint8_t tmp[2]; switch (cfg->format) { - case SRSLTE_PUCCH_FORMAT_1: + case SRSRAN_PUCCH_FORMAT_1: q->d[0] = uci_encode_format1(); break; - case SRSLTE_PUCCH_FORMAT_1A: + case SRSRAN_PUCCH_FORMAT_1A: q->d[0] = uci_encode_format1a(bits[0]); break; - case SRSLTE_PUCCH_FORMAT_1B: + case SRSRAN_PUCCH_FORMAT_1B: tmp[0] = bits[0]; tmp[1] = bits[1]; q->d[0] = uci_encode_format1b(tmp); break; - case SRSLTE_PUCCH_FORMAT_2: - case SRSLTE_PUCCH_FORMAT_2A: - case SRSLTE_PUCCH_FORMAT_2B: - if (srslte_sequence_pucch(&q->seq_f2, cfg->rnti, 2 * (sf->tti % 10), q->cell.id)) { + case SRSRAN_PUCCH_FORMAT_2: + case SRSRAN_PUCCH_FORMAT_2A: + case SRSRAN_PUCCH_FORMAT_2B: + if (srsran_sequence_pucch(&q->seq_f2, cfg->rnti, 2 * (sf->tti % 10), q->cell.id)) { ERROR("Error computing PUCCH Format 2 scrambling sequence\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - srslte_vec_u8_copy(q->bits_scram, bits, SRSLTE_PUCCH2_NOF_BITS); - srslte_scrambling_b_offset(&q->seq_f2, q->bits_scram, 0, SRSLTE_PUCCH2_NOF_BITS); - srslte_mod_modulate(&q->mod, q->bits_scram, q->d, SRSLTE_PUCCH2_NOF_BITS); + srsran_vec_u8_copy(q->bits_scram, bits, SRSRAN_PUCCH2_NOF_BITS); + srsran_scrambling_b_offset(&q->seq_f2, q->bits_scram, 0, SRSRAN_PUCCH2_NOF_BITS); + srsran_mod_modulate(&q->mod, q->bits_scram, q->d, SRSRAN_PUCCH2_NOF_BITS); break; - case SRSLTE_PUCCH_FORMAT_3: - if (srslte_sequence_pucch(&q->seq_f2, cfg->rnti, 2 * (sf->tti % 10), q->cell.id)) { + case SRSRAN_PUCCH_FORMAT_3: + if (srsran_sequence_pucch(&q->seq_f2, cfg->rnti, 2 * (sf->tti % 10), q->cell.id)) { ERROR("Error computing PUCCH Format 2 scrambling sequence\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - srslte_vec_u8_copy(q->bits_scram, bits, SRSLTE_PUCCH3_NOF_BITS); - srslte_scrambling_b_offset(&q->seq_f2, q->bits_scram, 0, SRSLTE_PUCCH3_NOF_BITS); - srslte_mod_modulate(&q->mod, q->bits_scram, q->d, SRSLTE_PUCCH3_NOF_BITS); + srsran_vec_u8_copy(q->bits_scram, bits, SRSRAN_PUCCH3_NOF_BITS); + srsran_scrambling_b_offset(&q->seq_f2, q->bits_scram, 0, SRSRAN_PUCCH3_NOF_BITS); + srsran_mod_modulate(&q->mod, q->bits_scram, q->d, SRSRAN_PUCCH3_NOF_BITS); break; default: - ERROR("PUCCH format %s not supported", srslte_pucch_format_text(cfg->format)); - return SRSLTE_ERROR; + ERROR("PUCCH format %s not supported", srsran_pucch_format_text(cfg->format)); + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } /* 3GPP 36211 Table 5.5.2.2.2-1: Demodulation reference signal location for different PUCCH formats. */ @@ -243,22 +243,22 @@ static const cf_t pucch3_w_n_oc_5[5][5] = { static const cf_t pucch3_w_n_oc_4[4][4] = {{+1, +1, +1, +1}, {+1, -1, +1, -1}, {+1, +1, -1, -1}, {+1, -1, -1, +1}}; -static uint32_t get_N_sf(srslte_pucch_format_t format, uint32_t slot_idx, bool shortened) +static uint32_t get_N_sf(srsran_pucch_format_t format, uint32_t slot_idx, bool shortened) { switch (format) { - case SRSLTE_PUCCH_FORMAT_1: - case SRSLTE_PUCCH_FORMAT_1A: - case SRSLTE_PUCCH_FORMAT_1B: + case SRSRAN_PUCCH_FORMAT_1: + case SRSRAN_PUCCH_FORMAT_1A: + case SRSRAN_PUCCH_FORMAT_1B: if (!slot_idx) { return 4; } else { return shortened ? 3 : 4; } - case SRSLTE_PUCCH_FORMAT_2: - case SRSLTE_PUCCH_FORMAT_2A: - case SRSLTE_PUCCH_FORMAT_2B: - return SRSLTE_PUCCH2_N_SF; - case SRSLTE_PUCCH_FORMAT_3: + case SRSRAN_PUCCH_FORMAT_2: + case SRSRAN_PUCCH_FORMAT_2A: + case SRSRAN_PUCCH_FORMAT_2B: + return SRSRAN_PUCCH2_N_SF; + case SRSRAN_PUCCH_FORMAT_3: if (!slot_idx) { return 5; } else { @@ -270,33 +270,33 @@ static uint32_t get_N_sf(srslte_pucch_format_t format, uint32_t slot_idx, bool s return 0; } -static uint32_t get_pucch_symbol(uint32_t m, srslte_pucch_format_t format, srslte_cp_t cp) +static uint32_t get_pucch_symbol(uint32_t m, srsran_pucch_format_t format, srsran_cp_t cp) { switch (format) { - case SRSLTE_PUCCH_FORMAT_1: - case SRSLTE_PUCCH_FORMAT_1A: - case SRSLTE_PUCCH_FORMAT_1B: + case SRSRAN_PUCCH_FORMAT_1: + case SRSRAN_PUCCH_FORMAT_1A: + case SRSRAN_PUCCH_FORMAT_1B: if (m < 4) { - if (SRSLTE_CP_ISNORM(cp)) { + if (SRSRAN_CP_ISNORM(cp)) { return pucch_symbol_format1_cpnorm[m]; } else { return pucch_symbol_format1_cpext[m]; } } break; - case SRSLTE_PUCCH_FORMAT_2: - case SRSLTE_PUCCH_FORMAT_2A: - case SRSLTE_PUCCH_FORMAT_2B: + case SRSRAN_PUCCH_FORMAT_2: + case SRSRAN_PUCCH_FORMAT_2A: + case SRSRAN_PUCCH_FORMAT_2B: if (m < 5) { - if (SRSLTE_CP_ISNORM(cp)) { + if (SRSRAN_CP_ISNORM(cp)) { return pucch_symbol_format2_3_cpnorm[m]; } else { return pucch_symbol_format2_3_cpext[m]; } } break; - case SRSLTE_PUCCH_FORMAT_3: - if (SRSLTE_CP_ISNORM(cp)) { + case SRSRAN_PUCCH_FORMAT_3: + if (SRSRAN_CP_ISNORM(cp)) { return pucch_symbol_format2_3_cpnorm[m % 5]; } else { return pucch_symbol_format2_3_cpext[m % 5]; @@ -309,17 +309,17 @@ static uint32_t get_pucch_symbol(uint32_t m, srslte_pucch_format_t format, srslt } /* Map PUCCH symbols to physical resources according to 5.4.3 in 36.211 */ -static int pucch_cp(srslte_pucch_t* q, - srslte_ul_sf_cfg_t* sf, - srslte_pucch_cfg_t* cfg, +static int pucch_cp(srsran_pucch_t* q, + srsran_ul_sf_cfg_t* sf, + srsran_pucch_cfg_t* cfg, cf_t* source, cf_t* dest, bool source_is_grid) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q && source && dest) { - ret = SRSLTE_ERROR; - uint32_t nsymbols = SRSLTE_CP_ISNORM(q->cell.cp) ? SRSLTE_CP_NORM_NSYMB : SRSLTE_CP_EXT_NSYMB; + ret = SRSRAN_ERROR; + uint32_t nsymbols = SRSRAN_CP_ISNORM(q->cell.cp) ? SRSRAN_CP_NORM_NSYMB : SRSRAN_CP_EXT_NSYMB; uint32_t n_re = 0; uint32_t N_sf_0 = get_N_sf(cfg->format, 0, sf->shortened); @@ -327,24 +327,24 @@ static int pucch_cp(srslte_pucch_t* q, uint32_t N_sf = get_N_sf(cfg->format, ns % 2, sf->shortened); // Determine n_prb - uint32_t n_prb = srslte_pucch_n_prb(&q->cell, cfg, ns); + uint32_t n_prb = srsran_pucch_n_prb(&q->cell, cfg, ns); if (n_prb < q->cell.nof_prb) { for (uint32_t i = 0; i < N_sf; i++) { uint32_t l = get_pucch_symbol(i, cfg->format, q->cell.cp); if (!source_is_grid) { - memcpy(&dest[SRSLTE_RE_IDX(q->cell.nof_prb, l + ns * nsymbols, n_prb * SRSLTE_NRE)], - &source[i * SRSLTE_NRE + ns * N_sf_0 * SRSLTE_NRE], - SRSLTE_NRE * sizeof(cf_t)); + memcpy(&dest[SRSRAN_RE_IDX(q->cell.nof_prb, l + ns * nsymbols, n_prb * SRSRAN_NRE)], + &source[i * SRSRAN_NRE + ns * N_sf_0 * SRSRAN_NRE], + SRSRAN_NRE * sizeof(cf_t)); } else { - memcpy(&dest[i * SRSLTE_NRE + ns * N_sf_0 * SRSLTE_NRE], - &source[SRSLTE_RE_IDX(q->cell.nof_prb, l + ns * nsymbols, n_prb * SRSLTE_NRE)], - SRSLTE_NRE * sizeof(cf_t)); + memcpy(&dest[i * SRSRAN_NRE + ns * N_sf_0 * SRSRAN_NRE], + &source[SRSRAN_RE_IDX(q->cell.nof_prb, l + ns * nsymbols, n_prb * SRSRAN_NRE)], + SRSRAN_NRE * sizeof(cf_t)); } - n_re += SRSLTE_NRE; + n_re += SRSRAN_NRE; } } else { ERROR("Invalid PUCCH n_prb=%d", n_prb); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } ret = n_re; @@ -352,37 +352,37 @@ static int pucch_cp(srslte_pucch_t* q, return ret; } -static int pucch_put(srslte_pucch_t* q, srslte_ul_sf_cfg_t* sf, srslte_pucch_cfg_t* cfg, cf_t* z, cf_t* output) +static int pucch_put(srsran_pucch_t* q, srsran_ul_sf_cfg_t* sf, srsran_pucch_cfg_t* cfg, cf_t* z, cf_t* output) { return pucch_cp(q, sf, cfg, z, output, false); } -static int pucch_get(srslte_pucch_t* q, srslte_ul_sf_cfg_t* sf, srslte_pucch_cfg_t* cfg, cf_t* input, cf_t* z) +static int pucch_get(srsran_pucch_t* q, srsran_ul_sf_cfg_t* sf, srsran_pucch_cfg_t* cfg, cf_t* input, cf_t* z) { return pucch_cp(q, sf, cfg, input, z, true); } -static int encode_signal_format12(srslte_pucch_t* q, - srslte_ul_sf_cfg_t* sf, - srslte_pucch_cfg_t* cfg, - uint8_t bits[SRSLTE_PUCCH_MAX_BITS], - cf_t z[SRSLTE_PUCCH_MAX_SYMBOLS], +static int encode_signal_format12(srsran_pucch_t* q, + srsran_ul_sf_cfg_t* sf, + srsran_pucch_cfg_t* cfg, + uint8_t bits[SRSRAN_PUCCH_MAX_BITS], + cf_t z[SRSRAN_PUCCH_MAX_SYMBOLS], bool signal_only) { if (!signal_only) { if (uci_mod_bits(q, sf, cfg, bits)) { ERROR("Error encoding PUCCH bits"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } else { // Set all ones - for (uint32_t i = 0; i < SRSLTE_PUCCH_MAX_BITS / 2; i++) { + for (uint32_t i = 0; i < SRSRAN_PUCCH_MAX_BITS / 2; i++) { q->d[i] = 1.0f; } } uint32_t N_sf_0 = get_N_sf(cfg->format, 0, sf->shortened); - uint32_t sf_idx = sf->tti % SRSLTE_NOF_SF_X_FRAME; - for (uint32_t ns = SRSLTE_NOF_SLOTS_PER_SF * sf_idx; ns < SRSLTE_NOF_SLOTS_PER_SF * (sf_idx + 1); ns++) { + uint32_t sf_idx = sf->tti % SRSRAN_NOF_SF_X_FRAME; + for (uint32_t ns = SRSRAN_NOF_SLOTS_PER_SF * sf_idx; ns < SRSRAN_NOF_SLOTS_PER_SF * (sf_idx + 1); ns++) { uint32_t N_sf = get_N_sf(cfg->format, ns % 2, sf->shortened); DEBUG("ns=%d, N_sf=%d", ns, N_sf); // Get group hopping number u @@ -395,19 +395,19 @@ static int encode_signal_format12(srslte_pucch_t* q, uint32_t N_sf_widx = N_sf == 3 ? 1 : 0; for (uint32_t m = 0; m < N_sf; m++) { // Calculate sequence z pointer for this symbol m - cf_t* z_m = &z[(ns % 2) * N_sf_0 * SRSLTE_PUCCH_N_SEQ + m * SRSLTE_PUCCH_N_SEQ]; + cf_t* z_m = &z[(ns % 2) * N_sf_0 * SRSRAN_PUCCH_N_SEQ + m * SRSRAN_PUCCH_N_SEQ]; // Get symbol index uint32_t l = get_pucch_symbol(m, cfg->format, q->cell.cp); cf_t w_m = 1.0; - if (cfg->format >= SRSLTE_PUCCH_FORMAT_2) { - float alpha = srslte_pucch_alpha_format2(q->n_cs_cell, cfg, ns, l); - srslte_zc_sequence_generate_lte(u, 0, alpha, SRSLTE_PUCCH_N_SEQ / SRSLTE_NRE, z_m); + if (cfg->format >= SRSRAN_PUCCH_FORMAT_2) { + float alpha = srsran_pucch_alpha_format2(q->n_cs_cell, cfg, ns, l); + srsran_zc_sequence_generate_lte(u, 0, alpha, SRSRAN_PUCCH_N_SEQ / SRSRAN_NRE, z_m); w_m = q->d[(ns % 2) * N_sf + m]; } else { uint32_t n_prime_ns = 0; uint32_t n_oc = 0; - float alpha = srslte_pucch_alpha_format1(q->n_cs_cell, cfg, q->cell.cp, true, ns, l, &n_oc, &n_prime_ns); + float alpha = srsran_pucch_alpha_format1(q->n_cs_cell, cfg, q->cell.cp, true, ns, l, &n_oc, &n_prime_ns); float S_ns = 0; if (n_prime_ns % 2) { S_ns = M_PI / 2; @@ -419,31 +419,31 @@ static int encode_signal_format12(srslte_pucch_t* q, n_oc, n_prime_ns, cfg->n_rb_2); - srslte_zc_sequence_generate_lte(u, 0, alpha, SRSLTE_PUCCH_N_SEQ / SRSLTE_NRE, z_m); + srsran_zc_sequence_generate_lte(u, 0, alpha, SRSRAN_PUCCH_N_SEQ / SRSRAN_NRE, z_m); w_m = q->d[0] * cexpf(I * (w_n_oc[N_sf_widx][n_oc % 3][m] + S_ns)); } // Apply w_m - srslte_vec_sc_prod_ccc(z_m, w_m, z_m, SRSLTE_PUCCH_N_SEQ); + srsran_vec_sc_prod_ccc(z_m, w_m, z_m, SRSRAN_PUCCH_N_SEQ); } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -static int encode_signal_format3(srslte_pucch_t* q, - srslte_ul_sf_cfg_t* sf, - srslte_pucch_cfg_t* cfg, - uint8_t bits[SRSLTE_PUCCH_MAX_BITS], - cf_t z[SRSLTE_PUCCH_MAX_SYMBOLS], +static int encode_signal_format3(srsran_pucch_t* q, + srsran_ul_sf_cfg_t* sf, + srsran_pucch_cfg_t* cfg, + uint8_t bits[SRSRAN_PUCCH_MAX_BITS], + cf_t z[SRSRAN_PUCCH_MAX_SYMBOLS], bool signal_only) { if (!signal_only) { if (uci_mod_bits(q, sf, cfg, bits)) { ERROR("Error encoding PUCCH bits"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } else { - for (int i = 0; i < SRSLTE_PUCCH_MAX_BITS / 2; i++) { + for (int i = 0; i < SRSRAN_PUCCH_MAX_BITS / 2; i++) { q->d[i] = 1.0; } } @@ -459,41 +459,41 @@ static int encode_signal_format3(srslte_pucch_t* q, for (uint32_t n = 0; n < N_sf_0 + N_sf_1; n++) { uint32_t l = get_pucch_symbol(n, cfg->format, q->cell.cp); - uint32_t n_cs_cell = q->n_cs_cell[(2 * (sf->tti % 10) + ((n < N_sf_0) ? 0 : 1)) % SRSLTE_NSLOTS_X_FRAME][l]; + uint32_t n_cs_cell = q->n_cs_cell[(2 * (sf->tti % 10) + ((n < N_sf_0) ? 0 : 1)) % SRSRAN_NSLOTS_X_FRAME][l]; - cf_t y_n[SRSLTE_NRE]; - srslte_vec_cf_zero(y_n, SRSLTE_NRE); + cf_t y_n[SRSRAN_NRE]; + srsran_vec_cf_zero(y_n, SRSRAN_NRE); cf_t h; if (n < N_sf_0) { h = w_n_oc_0[n] * cexpf(I * M_PI * floorf(n_cs_cell / 64.0f) / 2); - for (uint32_t i = 0; i < SRSLTE_NRE; i++) { - y_n[i] = h * q->d[(i + n_cs_cell) % SRSLTE_NRE]; + for (uint32_t i = 0; i < SRSRAN_NRE; i++) { + y_n[i] = h * q->d[(i + n_cs_cell) % SRSRAN_NRE]; } } else { h = w_n_oc_1[n - N_sf_0] * cexpf(I * M_PI * floorf(n_cs_cell / 64.0f) / 2); - for (uint32_t i = 0; i < SRSLTE_NRE; i++) { - y_n[i] = h * q->d[((i + n_cs_cell) % SRSLTE_NRE) + SRSLTE_NRE]; + for (uint32_t i = 0; i < SRSRAN_NRE; i++) { + y_n[i] = h * q->d[((i + n_cs_cell) % SRSRAN_NRE) + SRSRAN_NRE]; } } - for (int k = 0; k < SRSLTE_NRE; k++) { + for (int k = 0; k < SRSRAN_NRE; k++) { cf_t acc = 0.0f; - for (int i = 0; i < SRSLTE_NRE; i++) { - acc += y_n[i] * cexpf(-I * 2.0 * M_PI * i * k / (float)SRSLTE_NRE); + for (int i = 0; i < SRSRAN_NRE; i++) { + acc += y_n[i] * cexpf(-I * 2.0 * M_PI * i * k / (float)SRSRAN_NRE); } - z[n * SRSLTE_NRE + k] = acc / sqrtf(SRSLTE_NRE); + z[n * SRSRAN_NRE + k] = acc / sqrtf(SRSRAN_NRE); } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -static int decode_signal_format3(srslte_pucch_t* q, - srslte_ul_sf_cfg_t* sf, - srslte_pucch_cfg_t* cfg, - uint8_t bits[SRSLTE_PUCCH_MAX_BITS], - cf_t z[SRSLTE_PUCCH_MAX_SYMBOLS]) +static int decode_signal_format3(srsran_pucch_t* q, + srsran_ul_sf_cfg_t* sf, + srsran_pucch_cfg_t* cfg, + uint8_t bits[SRSRAN_PUCCH_MAX_BITS], + cf_t z[SRSRAN_PUCCH_MAX_SYMBOLS]) { uint32_t N_sf_0 = get_N_sf(cfg->format, 0, sf->shortened); uint32_t N_sf_1 = get_N_sf(cfg->format, 1, sf->shortened); @@ -504,56 +504,56 @@ static int decode_signal_format3(srslte_pucch_t* q, cf_t* w_n_oc_0 = (cf_t*)pucch3_w_n_oc_5[n_oc_0]; cf_t* w_n_oc_1 = (cf_t*)((N_sf_1 == 5) ? pucch3_w_n_oc_5[n_oc_1] : pucch3_w_n_oc_4[n_oc_1]); - memset(q->d, 0, sizeof(cf_t) * 2 * SRSLTE_NRE); + memset(q->d, 0, sizeof(cf_t) * 2 * SRSRAN_NRE); for (uint32_t n = 0; n < N_sf_0 + N_sf_1; n++) { uint32_t l = get_pucch_symbol(n, cfg->format, q->cell.cp); - uint32_t n_cs_cell = q->n_cs_cell[(2 * (sf->tti % 10) + ((n < N_sf_0) ? 0 : 1)) % SRSLTE_NSLOTS_X_FRAME][l]; + uint32_t n_cs_cell = q->n_cs_cell[(2 * (sf->tti % 10) + ((n < N_sf_0) ? 0 : 1)) % SRSRAN_NSLOTS_X_FRAME][l]; - cf_t y_n[SRSLTE_NRE] = {}; + cf_t y_n[SRSRAN_NRE] = {}; // Do FFT - for (int k = 0; k < SRSLTE_NRE; k++) { + for (int k = 0; k < SRSRAN_NRE; k++) { cf_t acc = 0.0f; - for (int i = 0; i < SRSLTE_NRE; i++) { - acc += z[n * SRSLTE_NRE + i] * cexpf(I * 2.0 * M_PI * i * k / (float)SRSLTE_NRE); + for (int i = 0; i < SRSRAN_NRE; i++) { + acc += z[n * SRSRAN_NRE + i] * cexpf(I * 2.0 * M_PI * i * k / (float)SRSRAN_NRE); } - y_n[k] = acc / sqrtf(SRSLTE_NRE); + y_n[k] = acc / sqrtf(SRSRAN_NRE); } if (n < N_sf_0) { cf_t h = w_n_oc_0[n] * cexpf(-I * M_PI * floorf(n_cs_cell / 64.0f) / 2); - for (uint32_t i = 0; i < SRSLTE_NRE; i++) { - q->d[(i + n_cs_cell) % SRSLTE_NRE] += h * y_n[i]; + for (uint32_t i = 0; i < SRSRAN_NRE; i++) { + q->d[(i + n_cs_cell) % SRSRAN_NRE] += h * y_n[i]; } } else { cf_t h = w_n_oc_1[n - N_sf_0] * cexpf(-I * M_PI * floorf(n_cs_cell / 64.0f) / 2); - for (uint32_t i = 0; i < SRSLTE_NRE; i++) { - q->d[((i + n_cs_cell) % SRSLTE_NRE) + SRSLTE_NRE] += h * y_n[i]; + for (uint32_t i = 0; i < SRSRAN_NRE; i++) { + q->d[((i + n_cs_cell) % SRSRAN_NRE) + SRSRAN_NRE] += h * y_n[i]; } } } - srslte_vec_sc_prod_cfc(q->d, 2.0f / (N_sf_0 + N_sf_1), q->d, SRSLTE_NRE * 2); + srsran_vec_sc_prod_cfc(q->d, 2.0f / (N_sf_0 + N_sf_1), q->d, SRSRAN_NRE * 2); - srslte_demod_soft_demodulate_s(SRSLTE_MOD_QPSK, q->d, q->llr, SRSLTE_PUCCH3_NOF_BITS); + srsran_demod_soft_demodulate_s(SRSRAN_MOD_QPSK, q->d, q->llr, SRSRAN_PUCCH3_NOF_BITS); - if (srslte_sequence_pucch(&q->seq_f2, cfg->rnti, 2 * (sf->tti % 10), q->cell.id)) { + if (srsran_sequence_pucch(&q->seq_f2, cfg->rnti, 2 * (sf->tti % 10), q->cell.id)) { ERROR("Error computing PUCCH Format 2 scrambling sequence\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - srslte_scrambling_s_offset(&q->seq_f2, q->llr, 0, SRSLTE_PUCCH3_NOF_BITS); + srsran_scrambling_s_offset(&q->seq_f2, q->llr, 0, SRSRAN_PUCCH3_NOF_BITS); - return (int)srslte_block_decode_i16(q->llr, SRSLTE_PUCCH3_NOF_BITS, bits, SRSLTE_UCI_MAX_ACK_SR_BITS); + return (int)srsran_block_decode_i16(q->llr, SRSRAN_PUCCH3_NOF_BITS, bits, SRSRAN_UCI_MAX_ACK_SR_BITS); } -static int encode_signal(srslte_pucch_t* q, - srslte_ul_sf_cfg_t* sf, - srslte_pucch_cfg_t* cfg, - uint8_t bits[SRSLTE_PUCCH_MAX_BITS], - cf_t z[SRSLTE_PUCCH_MAX_SYMBOLS]) +static int encode_signal(srsran_pucch_t* q, + srsran_ul_sf_cfg_t* sf, + srsran_pucch_cfg_t* cfg, + uint8_t bits[SRSRAN_PUCCH_MAX_BITS], + cf_t z[SRSRAN_PUCCH_MAX_SYMBOLS]) { - if (cfg->format == SRSLTE_PUCCH_FORMAT_3) { + if (cfg->format == SRSRAN_PUCCH_FORMAT_3) { return encode_signal_format3(q, sf, cfg, bits, z, false); } else { return encode_signal_format12(q, sf, cfg, bits, z, false); @@ -561,78 +561,78 @@ static int encode_signal(srslte_pucch_t* q, } // Encode bits from uci_data -static int encode_bits(srslte_pucch_cfg_t* cfg, - srslte_uci_value_t* uci_data, - srslte_pucch_format_t format, - uint8_t pucch_bits[SRSLTE_PUCCH_MAX_BITS], - uint8_t pucch2_bits[SRSLTE_PUCCH_MAX_BITS]) +static int encode_bits(srsran_pucch_cfg_t* cfg, + srsran_uci_value_t* uci_data, + srsran_pucch_format_t format, + uint8_t pucch_bits[SRSRAN_PUCCH_MAX_BITS], + uint8_t pucch2_bits[SRSRAN_PUCCH_MAX_BITS]) { - if (format < SRSLTE_PUCCH_FORMAT_2) { - srslte_vec_u8_copy(pucch_bits, uci_data->ack.ack_value, srslte_uci_cfg_total_ack(&cfg->uci_cfg)); - } else if (format >= SRSLTE_PUCCH_FORMAT_2 && format < SRSLTE_PUCCH_FORMAT_3) { + if (format < SRSRAN_PUCCH_FORMAT_2) { + srsran_vec_u8_copy(pucch_bits, uci_data->ack.ack_value, srsran_uci_cfg_total_ack(&cfg->uci_cfg)); + } else if (format >= SRSRAN_PUCCH_FORMAT_2 && format < SRSRAN_PUCCH_FORMAT_3) { /* Put RI (goes alone) */ if (cfg->uci_cfg.cqi.ri_len) { uint8_t temp[2] = {uci_data->ri, 0}; - srslte_uci_encode_cqi_pucch(temp, cfg->uci_cfg.cqi.ri_len, pucch_bits); + srsran_uci_encode_cqi_pucch(temp, cfg->uci_cfg.cqi.ri_len, pucch_bits); } else { /* Put CQI Report*/ - uint8_t buff[SRSLTE_CQI_MAX_BITS]; - int uci_cqi_len = srslte_cqi_value_pack(&cfg->uci_cfg.cqi, &uci_data->cqi, buff); + uint8_t buff[SRSRAN_CQI_MAX_BITS]; + int uci_cqi_len = srsran_cqi_value_pack(&cfg->uci_cfg.cqi, &uci_data->cqi, buff); if (uci_cqi_len < 0) { ERROR("Error encoding CQI"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - srslte_uci_encode_cqi_pucch(buff, (uint32_t)uci_cqi_len, pucch_bits); + srsran_uci_encode_cqi_pucch(buff, (uint32_t)uci_cqi_len, pucch_bits); } - if (format > SRSLTE_PUCCH_FORMAT_2) { + if (format > SRSRAN_PUCCH_FORMAT_2) { pucch2_bits[0] = uci_data->ack.ack_value[0]; pucch2_bits[1] = uci_data->ack.ack_value[1]; // this will be ignored in format 2a } - } else if (format == SRSLTE_PUCCH_FORMAT_3) { - uint8_t temp[SRSLTE_UCI_MAX_ACK_BITS + 1]; + } else if (format == SRSRAN_PUCCH_FORMAT_3) { + uint8_t temp[SRSRAN_UCI_MAX_ACK_BITS + 1]; uint32_t k = 0; - for (; k < srslte_uci_cfg_total_ack(&cfg->uci_cfg); k++) { + for (; k < srsran_uci_cfg_total_ack(&cfg->uci_cfg); k++) { temp[k] = (uint8_t)((uci_data->ack.ack_value[k] == 1) ? 1 : 0); } if (cfg->uci_cfg.is_scheduling_request_tti) { temp[k] = (uint8_t)(uci_data->scheduling_request ? 1 : 0); k++; } - srslte_block_encode(temp, k, pucch_bits, SRSLTE_PUCCH3_NOF_BITS); + srsran_block_encode(temp, k, pucch_bits, SRSRAN_PUCCH3_NOF_BITS); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -static bool decode_signal(srslte_pucch_t* q, - srslte_ul_sf_cfg_t* sf, - srslte_pucch_cfg_t* cfg, - uint8_t pucch_bits[SRSLTE_CQI_MAX_BITS], +static bool decode_signal(srsran_pucch_t* q, + srsran_ul_sf_cfg_t* sf, + srsran_pucch_cfg_t* cfg, + uint8_t pucch_bits[SRSRAN_CQI_MAX_BITS], uint32_t nof_re, uint32_t nof_uci_bits, float* correlation) { - int16_t llr_pucch2[SRSLTE_CQI_MAX_BITS]; + int16_t llr_pucch2[SRSRAN_CQI_MAX_BITS]; bool detected = false; float corr = 0, corr_max = -1e9; uint8_t b_max = 0, b2_max = 0; // default bit value, eg. HI is NACK - cf_t ref[SRSLTE_PUCCH_MAX_SYMBOLS]; + cf_t ref[SRSRAN_PUCCH_MAX_SYMBOLS]; switch (cfg->format) { - case SRSLTE_PUCCH_FORMAT_1: + case SRSRAN_PUCCH_FORMAT_1: encode_signal(q, sf, cfg, pucch_bits, q->z_tmp); - corr = srslte_vec_corr_ccc(q->z, q->z_tmp, nof_re); + corr = srsran_vec_corr_ccc(q->z, q->z_tmp, nof_re); if (corr >= cfg->threshold_format1) { detected = true; } DEBUG("format1 corr=%f, nof_re=%d, th=%f", corr, nof_re, cfg->threshold_format1); break; - case SRSLTE_PUCCH_FORMAT_1A: + case SRSRAN_PUCCH_FORMAT_1A: detected = 0; for (uint8_t b = 0; b < 2; b++) { pucch_bits[0] = b; encode_signal(q, sf, cfg, pucch_bits, q->z_tmp); - corr = srslte_vec_corr_ccc(q->z, q->z_tmp, nof_re); + corr = srsran_vec_corr_ccc(q->z, q->z_tmp, nof_re); if (corr > corr_max) { corr_max = corr; b_max = b; @@ -645,14 +645,14 @@ static bool decode_signal(srslte_pucch_t* q, corr = corr_max; pucch_bits[0] = b_max; break; - case SRSLTE_PUCCH_FORMAT_1B: + case SRSRAN_PUCCH_FORMAT_1B: detected = 0; for (uint8_t b = 0; b < 2; b++) { for (uint8_t b2 = 0; b2 < 2; b2++) { pucch_bits[0] = b; pucch_bits[1] = b2; encode_signal(q, sf, cfg, pucch_bits, q->z_tmp); - corr = srslte_vec_corr_ccc(q->z, q->z_tmp, nof_re); + corr = srsran_vec_corr_ccc(q->z, q->z_tmp, nof_re); if (corr > corr_max) { corr_max = corr; b_max = b; @@ -668,39 +668,39 @@ static bool decode_signal(srslte_pucch_t* q, pucch_bits[0] = b_max; pucch_bits[1] = b2_max; break; - case SRSLTE_PUCCH_FORMAT_2: - case SRSLTE_PUCCH_FORMAT_2A: - case SRSLTE_PUCCH_FORMAT_2B: - if (srslte_sequence_pucch(&q->seq_f2, cfg->rnti, 2 * (sf->tti % 10), q->cell.id)) { + case SRSRAN_PUCCH_FORMAT_2: + case SRSRAN_PUCCH_FORMAT_2A: + case SRSRAN_PUCCH_FORMAT_2B: + if (srsran_sequence_pucch(&q->seq_f2, cfg->rnti, 2 * (sf->tti % 10), q->cell.id)) { ERROR("Error computing PUCCH Format 2 scrambling sequence\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } encode_signal_format12(q, sf, cfg, NULL, ref, true); - srslte_vec_prod_conj_ccc(q->z, ref, q->z_tmp, SRSLTE_PUCCH_MAX_SYMBOLS); - for (int i = 0; i < (SRSLTE_PUCCH2_N_SF * SRSLTE_NOF_SLOTS_PER_SF); i++) { - q->z[i] = srslte_vec_acc_cc(&q->z_tmp[i * SRSLTE_NRE], SRSLTE_NRE) / SRSLTE_NRE; + srsran_vec_prod_conj_ccc(q->z, ref, q->z_tmp, SRSRAN_PUCCH_MAX_SYMBOLS); + for (int i = 0; i < (SRSRAN_PUCCH2_N_SF * SRSRAN_NOF_SLOTS_PER_SF); i++) { + q->z[i] = srsran_vec_acc_cc(&q->z_tmp[i * SRSRAN_NRE], SRSRAN_NRE) / SRSRAN_NRE; } - srslte_demod_soft_demodulate_s(SRSLTE_MOD_QPSK, q->z, llr_pucch2, SRSLTE_PUCCH2_NOF_BITS / 2); - srslte_scrambling_s_offset(&q->seq_f2, llr_pucch2, 0, SRSLTE_PUCCH2_NOF_BITS); + srsran_demod_soft_demodulate_s(SRSRAN_MOD_QPSK, q->z, llr_pucch2, SRSRAN_PUCCH2_NOF_BITS / 2); + srsran_scrambling_s_offset(&q->seq_f2, llr_pucch2, 0, SRSRAN_PUCCH2_NOF_BITS); // Calculate the LLR RMS for normalising - float llr_pow = srslte_vec_avg_power_sf(llr_pucch2, SRSLTE_PUCCH2_NOF_BITS); + float llr_pow = srsran_vec_avg_power_sf(llr_pucch2, SRSRAN_PUCCH2_NOF_BITS); if (isnormal(llr_pow)) { - float llr_rms = sqrtf(llr_pow) * SRSLTE_PUCCH2_NOF_BITS; - corr = ((float)srslte_uci_decode_cqi_pucch(&q->cqi, llr_pucch2, pucch_bits, nof_uci_bits)) / (llr_rms); + float llr_rms = sqrtf(llr_pow) * SRSRAN_PUCCH2_NOF_BITS; + corr = ((float)srsran_uci_decode_cqi_pucch(&q->cqi, llr_pucch2, pucch_bits, nof_uci_bits)) / (llr_rms); } else { corr = 0; } detected = true; break; - case SRSLTE_PUCCH_FORMAT_3: + case SRSRAN_PUCCH_FORMAT_3: corr = (float)decode_signal_format3(q, sf, cfg, pucch_bits, q->z) / 4800.0f; detected = corr > cfg->threshold_data_valid_format3; break; default: ERROR("PUCCH format %d not implemented", cfg->format); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (correlation) { *correlation = corr; @@ -708,14 +708,14 @@ static bool decode_signal(srslte_pucch_t* q, return detected; } -static void decode_bits(srslte_pucch_cfg_t* cfg, +static void decode_bits(srsran_pucch_cfg_t* cfg, bool pucch_found, - uint8_t pucch_bits[SRSLTE_PUCCH_MAX_BITS], - uint8_t pucch2_bits[SRSLTE_PUCCH_MAX_BITS], - srslte_uci_value_t* uci_data) + uint8_t pucch_bits[SRSRAN_PUCCH_MAX_BITS], + uint8_t pucch2_bits[SRSRAN_PUCCH_MAX_BITS], + srsran_uci_value_t* uci_data) { - if (cfg->format == SRSLTE_PUCCH_FORMAT_3) { - uint32_t nof_ack = srslte_uci_cfg_total_ack(&cfg->uci_cfg); + if (cfg->format == SRSRAN_PUCCH_FORMAT_3) { + uint32_t nof_ack = srsran_uci_cfg_total_ack(&cfg->uci_cfg); memcpy(uci_data->ack.ack_value, pucch_bits, nof_ack); uci_data->scheduling_request = (pucch_bits[nof_ack] == 1); uci_data->ack.valid = pucch_found; @@ -726,7 +726,7 @@ static void decode_bits(srslte_pucch_cfg_t* cfg, } // Save ACK bits - for (uint32_t a = 0; a < srslte_pucch_nof_ack_format(cfg->format); a++) { + for (uint32_t a = 0; a < srsran_pucch_nof_ack_format(cfg->format); a++) { if (cfg->uci_cfg.cqi.data_enable || cfg->uci_cfg.cqi.ri_len) { uci_data->ack.ack_value[a] = pucch2_bits[a]; } else { @@ -736,7 +736,7 @@ static void decode_bits(srslte_pucch_cfg_t* cfg, // PUCCH2 CQI bits are already decoded if (cfg->uci_cfg.cqi.data_enable) { - srslte_cqi_value_unpack(&cfg->uci_cfg.cqi, pucch_bits, &uci_data->cqi); + srsran_cqi_value_unpack(&cfg->uci_cfg.cqi, pucch_bits, &uci_data->cqi); } if (cfg->uci_cfg.cqi.ri_len) { @@ -746,77 +746,77 @@ static void decode_bits(srslte_pucch_cfg_t* cfg, } /* Encode, modulate and resource mapping of UCI data over PUCCH */ -int srslte_pucch_encode(srslte_pucch_t* q, - srslte_ul_sf_cfg_t* sf, - srslte_pucch_cfg_t* cfg, - srslte_uci_value_t* uci_data, +int srsran_pucch_encode(srsran_pucch_t* q, + srsran_ul_sf_cfg_t* sf, + srsran_pucch_cfg_t* cfg, + srsran_uci_value_t* uci_data, cf_t* sf_symbols) { - uint8_t pucch_bits[SRSLTE_PUCCH_MAX_BITS]; - srslte_vec_u8_zero(pucch_bits, SRSLTE_PUCCH_MAX_BITS); + uint8_t pucch_bits[SRSRAN_PUCCH_MAX_BITS]; + srsran_vec_u8_zero(pucch_bits, SRSRAN_PUCCH_MAX_BITS); - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL && sf_symbols != NULL) { // Encode bits from UCI data for this format encode_bits(cfg, uci_data, cfg->format, pucch_bits, cfg->pucch2_drs_bits); if (encode_signal(q, sf, cfg, pucch_bits, q->z)) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (pucch_put(q, sf, cfg, q->z, sf_symbols) < 0) { ERROR("Error putting PUCCH symbols"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } /* Equalize, demodulate and decode PUCCH bits according to Section 5.4.1 of 36.211 */ -int srslte_pucch_decode(srslte_pucch_t* q, - srslte_ul_sf_cfg_t* sf, - srslte_pucch_cfg_t* cfg, - srslte_chest_ul_res_t* channel, +int srsran_pucch_decode(srsran_pucch_t* q, + srsran_ul_sf_cfg_t* sf, + srsran_pucch_cfg_t* cfg, + srsran_chest_ul_res_t* channel, cf_t* sf_symbols, - srslte_pucch_res_t* data) + srsran_pucch_res_t* data) { - uint8_t pucch_bits[SRSLTE_CQI_MAX_BITS]; - bzero(pucch_bits, SRSLTE_CQI_MAX_BITS * sizeof(uint8_t)); + uint8_t pucch_bits[SRSRAN_CQI_MAX_BITS]; + bzero(pucch_bits, SRSRAN_CQI_MAX_BITS * sizeof(uint8_t)); - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL && cfg != NULL && channel != NULL && data != NULL) { - uint32_t nof_cqi_bits = srslte_cqi_size(&cfg->uci_cfg.cqi); + uint32_t nof_cqi_bits = srsran_cqi_size(&cfg->uci_cfg.cqi); uint32_t nof_uci_bits = cfg->uci_cfg.cqi.ri_len ? cfg->uci_cfg.cqi.ri_len : nof_cqi_bits; int nof_re = pucch_get(q, sf, cfg, sf_symbols, q->z_tmp); if (nof_re < 0) { ERROR("Error getting PUCCH symbols"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (pucch_get(q, sf, cfg, channel->ce, q->ce) < 0) { ERROR("Error getting PUCCH symbols"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Equalization - srslte_predecoding_single(q->z_tmp, q->ce, q->z, NULL, nof_re, 1.0f, channel->noise_estimate); + srsran_predecoding_single(q->z_tmp, q->ce, q->z, NULL, nof_re, 1.0f, channel->noise_estimate); // Perform DMRS Detection, if enabled if (isnormal(cfg->threshold_dmrs_detection)) { - cf_t _dmrs_corr = srslte_vec_acc_cc(q->ce, SRSLTE_NRE) / SRSLTE_NRE; + cf_t _dmrs_corr = srsran_vec_acc_cc(q->ce, SRSRAN_NRE) / SRSRAN_NRE; float rms = __real__(conjf(_dmrs_corr) * _dmrs_corr); - float power = srslte_vec_avg_power_cf(q->ce, SRSLTE_NRE); + float power = srsran_vec_avg_power_cf(q->ce, SRSRAN_NRE); data->dmrs_correlation = rms / power; // Return not detected if the ratio is 0, NAN, +/- Infinity or below threshold if (!isnormal(data->dmrs_correlation) || data->dmrs_correlation < cfg->threshold_dmrs_detection) { data->correlation = 0.0f; data->detected = false; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } } @@ -830,55 +830,55 @@ int srslte_pucch_decode(srslte_pucch_t* q, // Accept ACK and CQI only if correlation above threshold switch (cfg->format) { - case SRSLTE_PUCCH_FORMAT_1A: - case SRSLTE_PUCCH_FORMAT_1B: + case SRSRAN_PUCCH_FORMAT_1A: + case SRSRAN_PUCCH_FORMAT_1B: data->uci_data.ack.valid = data->correlation > cfg->threshold_data_valid_format1a; break; - case SRSLTE_PUCCH_FORMAT_2: - case SRSLTE_PUCCH_FORMAT_2A: - case SRSLTE_PUCCH_FORMAT_2B: + case SRSRAN_PUCCH_FORMAT_2: + case SRSRAN_PUCCH_FORMAT_2A: + case SRSRAN_PUCCH_FORMAT_2B: data->detected = data->correlation > cfg->threshold_data_valid_format2; data->uci_data.ack.valid = data->detected; data->uci_data.cqi.data_crc = data->detected; break; - case SRSLTE_PUCCH_FORMAT_1: - case SRSLTE_PUCCH_FORMAT_3: + case SRSRAN_PUCCH_FORMAT_1: + case SRSRAN_PUCCH_FORMAT_3: default:; // Not considered, do nothing } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } -char* srslte_pucch_format_text(srslte_pucch_format_t format) +char* srsran_pucch_format_text(srsran_pucch_format_t format) { char* ret = NULL; switch (format) { - case SRSLTE_PUCCH_FORMAT_1: + case SRSRAN_PUCCH_FORMAT_1: ret = "Format 1"; break; - case SRSLTE_PUCCH_FORMAT_1A: + case SRSRAN_PUCCH_FORMAT_1A: ret = "Format 1A"; break; - case SRSLTE_PUCCH_FORMAT_1B: + case SRSRAN_PUCCH_FORMAT_1B: ret = "Format 1B"; break; - case SRSLTE_PUCCH_FORMAT_2: + case SRSRAN_PUCCH_FORMAT_2: ret = "Format 2"; break; - case SRSLTE_PUCCH_FORMAT_2A: + case SRSRAN_PUCCH_FORMAT_2A: ret = "Format 2A"; break; - case SRSLTE_PUCCH_FORMAT_2B: + case SRSRAN_PUCCH_FORMAT_2B: ret = "Format 2B"; break; - case SRSLTE_PUCCH_FORMAT_3: + case SRSRAN_PUCCH_FORMAT_3: ret = "Format 3"; break; - case SRSLTE_PUCCH_FORMAT_ERROR: + case SRSRAN_PUCCH_FORMAT_ERROR: default: ret = "Format Error"; } @@ -886,33 +886,33 @@ char* srslte_pucch_format_text(srslte_pucch_format_t format) return ret; } -char* srslte_pucch_format_text_short(srslte_pucch_format_t format) +char* srsran_pucch_format_text_short(srsran_pucch_format_t format) { char* ret = NULL; switch (format) { - case SRSLTE_PUCCH_FORMAT_1: + case SRSRAN_PUCCH_FORMAT_1: ret = "1"; break; - case SRSLTE_PUCCH_FORMAT_1A: + case SRSRAN_PUCCH_FORMAT_1A: ret = "1a"; break; - case SRSLTE_PUCCH_FORMAT_1B: + case SRSRAN_PUCCH_FORMAT_1B: ret = "1b"; break; - case SRSLTE_PUCCH_FORMAT_2: + case SRSRAN_PUCCH_FORMAT_2: ret = "2"; break; - case SRSLTE_PUCCH_FORMAT_2A: + case SRSRAN_PUCCH_FORMAT_2A: ret = "2a"; break; - case SRSLTE_PUCCH_FORMAT_2B: + case SRSRAN_PUCCH_FORMAT_2B: ret = "2b"; break; - case SRSLTE_PUCCH_FORMAT_3: + case SRSRAN_PUCCH_FORMAT_3: ret = "3"; break; - case SRSLTE_PUCCH_FORMAT_ERROR: + case SRSRAN_PUCCH_FORMAT_ERROR: default: ret = "Err"; break; @@ -921,17 +921,17 @@ char* srslte_pucch_format_text_short(srslte_pucch_format_t format) return ret; } -uint32_t srslte_pucch_nof_ack_format(srslte_pucch_format_t format) +uint32_t srsran_pucch_nof_ack_format(srsran_pucch_format_t format) { uint32_t ret = 0; switch (format) { - case SRSLTE_PUCCH_FORMAT_1A: - case SRSLTE_PUCCH_FORMAT_2A: + case SRSRAN_PUCCH_FORMAT_1A: + case SRSRAN_PUCCH_FORMAT_2A: ret = 1; break; - case SRSLTE_PUCCH_FORMAT_1B: - case SRSLTE_PUCCH_FORMAT_2B: + case SRSRAN_PUCCH_FORMAT_1B: + case SRSRAN_PUCCH_FORMAT_2B: ret = 2; break; default: @@ -943,7 +943,7 @@ uint32_t srslte_pucch_nof_ack_format(srslte_pucch_format_t format) } /* Verify PUCCH configuration as given in Section 5.4 36.211 */ -bool srslte_pucch_cfg_isvalid(srslte_pucch_cfg_t* cfg, uint32_t nof_prb) +bool srsran_pucch_cfg_isvalid(srsran_pucch_cfg_t* cfg, uint32_t nof_prb) { if (cfg->delta_pucch_shift > 0 && cfg->delta_pucch_shift < 4 && cfg->N_cs < 8 && (cfg->N_cs % cfg->delta_pucch_shift) == 0 && cfg->n_rb_2 <= nof_prb) { @@ -953,9 +953,9 @@ bool srslte_pucch_cfg_isvalid(srslte_pucch_cfg_t* cfg, uint32_t nof_prb) } } -uint32_t srslte_pucch_n_prb(const srslte_cell_t* cell, const srslte_pucch_cfg_t* cfg, uint32_t ns) +uint32_t srsran_pucch_n_prb(const srsran_cell_t* cell, const srsran_pucch_cfg_t* cfg, uint32_t ns) { - uint32_t m = srslte_pucch_m(cfg, cell->cp); + uint32_t m = srsran_pucch_m(cfg, cell->cp); // Determine n_prb uint32_t n_prb = m / 2; if ((m + ns) % 2) { @@ -965,27 +965,27 @@ uint32_t srslte_pucch_n_prb(const srslte_cell_t* cell, const srslte_pucch_cfg_t* } // Compute m according to Section 5.4.3 of 36.211 -uint32_t srslte_pucch_m(const srslte_pucch_cfg_t* cfg, srslte_cp_t cp) +uint32_t srsran_pucch_m(const srsran_pucch_cfg_t* cfg, srsran_cp_t cp) { uint32_t m = 0; switch (cfg->format) { - case SRSLTE_PUCCH_FORMAT_1: - case SRSLTE_PUCCH_FORMAT_1A: - case SRSLTE_PUCCH_FORMAT_1B: + case SRSRAN_PUCCH_FORMAT_1: + case SRSRAN_PUCCH_FORMAT_1A: + case SRSRAN_PUCCH_FORMAT_1B: m = cfg->n_rb_2; - uint32_t c = SRSLTE_CP_ISNORM(cp) ? 3 : 2; + uint32_t c = SRSRAN_CP_ISNORM(cp) ? 3 : 2; if (cfg->n_pucch >= c * cfg->N_cs / cfg->delta_pucch_shift) { - m = (cfg->n_pucch - c * cfg->N_cs / cfg->delta_pucch_shift) / (c * SRSLTE_NRE / cfg->delta_pucch_shift) + + m = (cfg->n_pucch - c * cfg->N_cs / cfg->delta_pucch_shift) / (c * SRSRAN_NRE / cfg->delta_pucch_shift) + cfg->n_rb_2 + (uint32_t)ceilf((float)cfg->N_cs / 8); } break; - case SRSLTE_PUCCH_FORMAT_2: - case SRSLTE_PUCCH_FORMAT_2A: - case SRSLTE_PUCCH_FORMAT_2B: - m = cfg->n_pucch / SRSLTE_NRE; + case SRSRAN_PUCCH_FORMAT_2: + case SRSRAN_PUCCH_FORMAT_2A: + case SRSRAN_PUCCH_FORMAT_2B: + m = cfg->n_pucch / SRSRAN_NRE; break; - case SRSLTE_PUCCH_FORMAT_3: + case SRSRAN_PUCCH_FORMAT_3: m = cfg->n_pucch / 5; break; default: @@ -996,53 +996,53 @@ uint32_t srslte_pucch_m(const srslte_pucch_cfg_t* cfg, srslte_cp_t cp) } /* Generates n_cs_cell according to Sec 5.4 of 36.211 */ -int srslte_pucch_n_cs_cell(srslte_cell_t cell, uint32_t n_cs_cell[SRSLTE_NSLOTS_X_FRAME][SRSLTE_CP_NORM_NSYMB]) +int srsran_pucch_n_cs_cell(srsran_cell_t cell, uint32_t n_cs_cell[SRSRAN_NSLOTS_X_FRAME][SRSRAN_CP_NORM_NSYMB]) { - srslte_sequence_t seq; - bzero(&seq, sizeof(srslte_sequence_t)); + srsran_sequence_t seq; + bzero(&seq, sizeof(srsran_sequence_t)); - srslte_sequence_LTE_pr(&seq, 8 * SRSLTE_CP_NSYMB(cell.cp) * SRSLTE_NSLOTS_X_FRAME, cell.id); + srsran_sequence_LTE_pr(&seq, 8 * SRSRAN_CP_NSYMB(cell.cp) * SRSRAN_NSLOTS_X_FRAME, cell.id); - for (uint32_t ns = 0; ns < SRSLTE_NSLOTS_X_FRAME; ns++) { - for (uint32_t l = 0; l < SRSLTE_CP_NSYMB(cell.cp); l++) { + for (uint32_t ns = 0; ns < SRSRAN_NSLOTS_X_FRAME; ns++) { + for (uint32_t l = 0; l < SRSRAN_CP_NSYMB(cell.cp); l++) { n_cs_cell[ns][l] = 0; for (uint32_t i = 0; i < 8; i++) { - n_cs_cell[ns][l] += seq.c[8 * SRSLTE_CP_NSYMB(cell.cp) * ns + 8 * l + i] << i; + n_cs_cell[ns][l] += seq.c[8 * SRSRAN_CP_NSYMB(cell.cp) * ns + 8 * l + i] << i; } } } - srslte_sequence_free(&seq); - return SRSLTE_SUCCESS; + srsran_sequence_free(&seq); + return SRSRAN_SUCCESS; } -int srslte_pucch_collision(const srslte_cell_t* cell, const srslte_pucch_cfg_t* cfg1, const srslte_pucch_cfg_t* cfg2) +int srsran_pucch_collision(const srsran_cell_t* cell, const srsran_pucch_cfg_t* cfg1, const srsran_pucch_cfg_t* cfg2) { // Invalid inputs, return false if (!cell || !cfg1 || !cfg2) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } // Different formats, not possible to compute collision if (cfg1->format != cfg2->format) { - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // If resources are the same, return collision and do not compute more if (cfg1->n_pucch == cfg2->n_pucch) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Calculate frequency domain resource - uint32_t m1 = srslte_pucch_m(cfg1, cell->cp); - uint32_t m2 = srslte_pucch_m(cfg2, cell->cp); + uint32_t m1 = srsran_pucch_m(cfg1, cell->cp); + uint32_t m2 = srsran_pucch_m(cfg2, cell->cp); // Check if they are different, no collison if (m1 != m2) { - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } - uint32_t n_cs_cell[SRSLTE_NSLOTS_X_FRAME][SRSLTE_CP_NORM_NSYMB] = {}; - srslte_pucch_n_cs_cell(*cell, n_cs_cell); + uint32_t n_cs_cell[SRSRAN_NSLOTS_X_FRAME][SRSRAN_CP_NORM_NSYMB] = {}; + srsran_pucch_n_cs_cell(*cell, n_cs_cell); float alpha1, alpha2; uint32_t n_oc1 = 0; @@ -1051,104 +1051,104 @@ int srslte_pucch_collision(const srslte_cell_t* cell, const srslte_pucch_cfg_t* uint32_t n_prime2 = 0; switch (cfg1->format) { - case SRSLTE_PUCCH_FORMAT_1: - case SRSLTE_PUCCH_FORMAT_1A: - case SRSLTE_PUCCH_FORMAT_1B: - srslte_pucch_alpha_format1(n_cs_cell, cfg1, cell->cp, false, 0, 0, &n_oc1, &n_prime1); - srslte_pucch_alpha_format1(n_cs_cell, cfg2, cell->cp, false, 0, 0, &n_oc2, &n_prime2); - return ((n_oc1 == n_oc2) && (n_prime1 % 2 == n_prime2 % 2)) ? SRSLTE_ERROR : SRSLTE_SUCCESS; - - case SRSLTE_PUCCH_FORMAT_2: - case SRSLTE_PUCCH_FORMAT_2A: - case SRSLTE_PUCCH_FORMAT_2B: - alpha1 = srslte_pucch_alpha_format2(n_cs_cell, cfg1, 0, 0); - alpha2 = srslte_pucch_alpha_format2(n_cs_cell, cfg2, 0, 0); - return (alpha1 == alpha2) ? SRSLTE_ERROR : SRSLTE_SUCCESS; - - case SRSLTE_PUCCH_FORMAT_3: - return (cfg1->n_pucch % 5 == cfg2->n_pucch % 5) ? SRSLTE_ERROR : SRSLTE_SUCCESS; - - case SRSLTE_PUCCH_FORMAT_ERROR: + case SRSRAN_PUCCH_FORMAT_1: + case SRSRAN_PUCCH_FORMAT_1A: + case SRSRAN_PUCCH_FORMAT_1B: + srsran_pucch_alpha_format1(n_cs_cell, cfg1, cell->cp, false, 0, 0, &n_oc1, &n_prime1); + srsran_pucch_alpha_format1(n_cs_cell, cfg2, cell->cp, false, 0, 0, &n_oc2, &n_prime2); + return ((n_oc1 == n_oc2) && (n_prime1 % 2 == n_prime2 % 2)) ? SRSRAN_ERROR : SRSRAN_SUCCESS; + + case SRSRAN_PUCCH_FORMAT_2: + case SRSRAN_PUCCH_FORMAT_2A: + case SRSRAN_PUCCH_FORMAT_2B: + alpha1 = srsran_pucch_alpha_format2(n_cs_cell, cfg1, 0, 0); + alpha2 = srsran_pucch_alpha_format2(n_cs_cell, cfg2, 0, 0); + return (alpha1 == alpha2) ? SRSRAN_ERROR : SRSRAN_SUCCESS; + + case SRSRAN_PUCCH_FORMAT_3: + return (cfg1->n_pucch % 5 == cfg2->n_pucch % 5) ? SRSRAN_ERROR : SRSRAN_SUCCESS; + + case SRSRAN_PUCCH_FORMAT_ERROR: default:; // Do nothing } - return SRSLTE_ERROR; + return SRSRAN_ERROR; } -int srslte_pucch_cfg_assert(const srslte_cell_t* cell, const srslte_pucch_cfg_t* cfg) +int srsran_pucch_cfg_assert(const srsran_cell_t* cell, const srsran_pucch_cfg_t* cfg) { // Invalid inouts, return error if (!cell || !cfg) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } // Load base configuration - srslte_pucch_cfg_t cfg1 = *cfg; - srslte_pucch_cfg_t cfg2 = *cfg; + srsran_pucch_cfg_t cfg1 = *cfg; + srsran_pucch_cfg_t cfg2 = *cfg; // Set Format 1b - cfg1.format = SRSLTE_PUCCH_FORMAT_1B; - cfg2.format = SRSLTE_PUCCH_FORMAT_1B; + cfg1.format = SRSRAN_PUCCH_FORMAT_1B; + cfg2.format = SRSRAN_PUCCH_FORMAT_1B; // Check collision with N_pucch_1 Vs n_pucch_sr cfg1.n_pucch = cfg->N_pucch_1; cfg2.n_pucch = cfg->n_pucch_sr; - if (srslte_pucch_collision(cell, &cfg1, &cfg2) != SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (srsran_pucch_collision(cell, &cfg1, &cfg2) != SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } - if (cfg->ack_nack_feedback_mode == SRSLTE_PUCCH_ACK_NACK_FEEDBACK_MODE_CS) { + if (cfg->ack_nack_feedback_mode == SRSRAN_PUCCH_ACK_NACK_FEEDBACK_MODE_CS) { // Checks channel selection resources do not collide with N_pucch_1 - for (uint32_t i = 0; i < SRSLTE_PUCCH_SIZE_AN_CS; i++) { - for (uint32_t j = 0; j < SRSLTE_PUCCH_NOF_AN_CS; j++) { + for (uint32_t i = 0; i < SRSRAN_PUCCH_SIZE_AN_CS; i++) { + for (uint32_t j = 0; j < SRSRAN_PUCCH_NOF_AN_CS; j++) { cfg2.n_pucch = cfg2.n1_pucch_an_cs[i][j]; // Check collision with N_pucch_1 cfg1.n_pucch = cfg->N_pucch_1; - if (srslte_pucch_collision(cell, &cfg1, &cfg2) != SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (srsran_pucch_collision(cell, &cfg1, &cfg2) != SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } // Check collision with n_pucch_sr cfg1.n_pucch = cfg->n_pucch_sr; - if (srslte_pucch_collision(cell, &cfg1, &cfg2) != SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (srsran_pucch_collision(cell, &cfg1, &cfg2) != SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } // Check collision with j + 1 - cfg1.n_pucch = cfg2.n1_pucch_an_cs[i][(j + 1) % SRSLTE_PUCCH_NOF_AN_CS]; - if (srslte_pucch_collision(cell, &cfg1, &cfg2) != SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + cfg1.n_pucch = cfg2.n1_pucch_an_cs[i][(j + 1) % SRSRAN_PUCCH_NOF_AN_CS]; + if (srsran_pucch_collision(cell, &cfg1, &cfg2) != SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } } } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } /* Calculates alpha for format 1/a/b according to 5.5.2.2.2 (is_dmrs=true) or 5.4.1 (is_dmrs=false) of 36.211 */ -float srslte_pucch_alpha_format1(const uint32_t n_cs_cell[SRSLTE_NSLOTS_X_FRAME][SRSLTE_CP_NORM_NSYMB], - const srslte_pucch_cfg_t* cfg, - srslte_cp_t cp, +float srsran_pucch_alpha_format1(const uint32_t n_cs_cell[SRSRAN_NSLOTS_X_FRAME][SRSRAN_CP_NORM_NSYMB], + const srsran_pucch_cfg_t* cfg, + srsran_cp_t cp, bool is_dmrs, uint32_t ns, uint32_t l, uint32_t* n_oc_ptr, uint32_t* n_prime_ns) { - uint32_t c = SRSLTE_CP_ISNORM(cp) ? 3 : 2; - uint32_t N_prime = (cfg->n_pucch < c * cfg->N_cs / cfg->delta_pucch_shift) ? cfg->N_cs : SRSLTE_NRE; + uint32_t c = SRSRAN_CP_ISNORM(cp) ? 3 : 2; + uint32_t N_prime = (cfg->n_pucch < c * cfg->N_cs / cfg->delta_pucch_shift) ? cfg->N_cs : SRSRAN_NRE; uint32_t n_prime = cfg->n_pucch; if (cfg->n_pucch >= c * cfg->N_cs / cfg->delta_pucch_shift) { - n_prime = (cfg->n_pucch - c * cfg->N_cs / cfg->delta_pucch_shift) % (c * SRSLTE_NRE / cfg->delta_pucch_shift); + n_prime = (cfg->n_pucch - c * cfg->N_cs / cfg->delta_pucch_shift) % (c * SRSRAN_NRE / cfg->delta_pucch_shift); } if (ns % 2) { if (cfg->n_pucch >= c * cfg->N_cs / cfg->delta_pucch_shift) { - n_prime = (c * (n_prime + 1)) % (c * SRSLTE_NRE / cfg->delta_pucch_shift + 1) - 1; + n_prime = (c * (n_prime + 1)) % (c * SRSRAN_NRE / cfg->delta_pucch_shift + 1) - 1; } else { - uint32_t d = SRSLTE_CP_ISNORM(cp) ? 2 : 0; + uint32_t d = SRSRAN_CP_ISNORM(cp) ? 2 : 0; uint32_t h = (n_prime + d) % (c * N_prime / cfg->delta_pucch_shift); n_prime = (h / c) + (h % c) * N_prime / cfg->delta_pucch_shift; } @@ -1158,21 +1158,21 @@ float srslte_pucch_alpha_format1(const uint32_t n_cs_cell[SRSLTE_NSLO *n_prime_ns = n_prime; } - uint32_t n_oc_div = (!is_dmrs && SRSLTE_CP_ISEXT(cp)) ? 2 : 1; + uint32_t n_oc_div = (!is_dmrs && SRSRAN_CP_ISEXT(cp)) ? 2 : 1; uint32_t n_oc = (n_prime * cfg->delta_pucch_shift) / N_prime; - if (!is_dmrs && SRSLTE_CP_ISEXT(cp)) { + if (!is_dmrs && SRSRAN_CP_ISEXT(cp)) { n_oc *= 2; } if (n_oc_ptr) { *n_oc_ptr = n_oc; } uint32_t n_cs = 0; - if (SRSLTE_CP_ISNORM(cp)) { + if (SRSRAN_CP_ISNORM(cp)) { n_cs = (n_cs_cell[ns][l] + (n_prime * cfg->delta_pucch_shift + (n_oc % cfg->delta_pucch_shift)) % N_prime) % - SRSLTE_NRE; + SRSRAN_NRE; } else { - n_cs = (n_cs_cell[ns][l] + (n_prime * cfg->delta_pucch_shift + n_oc / n_oc_div) % N_prime) % SRSLTE_NRE; + n_cs = (n_cs_cell[ns][l] + (n_prime * cfg->delta_pucch_shift + n_oc / n_oc_div) % N_prime) % SRSRAN_NRE; } DEBUG("n_cs=%d, N_prime=%d, delta_pucch=%d, n_prime=%d, ns=%d, l=%d, ns_cs_cell=%d", @@ -1184,44 +1184,44 @@ float srslte_pucch_alpha_format1(const uint32_t n_cs_cell[SRSLTE_NSLO l, n_cs_cell[ns][l]); - return 2 * M_PI * (n_cs) / SRSLTE_NRE; + return 2 * M_PI * (n_cs) / SRSRAN_NRE; } /* Calculates alpha for format 2/a/b according to 5.4.2 of 36.211 */ -float srslte_pucch_alpha_format2(const uint32_t n_cs_cell[SRSLTE_NSLOTS_X_FRAME][SRSLTE_CP_NORM_NSYMB], - const srslte_pucch_cfg_t* cfg, +float srsran_pucch_alpha_format2(const uint32_t n_cs_cell[SRSRAN_NSLOTS_X_FRAME][SRSRAN_CP_NORM_NSYMB], + const srsran_pucch_cfg_t* cfg, uint32_t ns, uint32_t l) { - uint32_t n_prime = cfg->n_pucch % SRSLTE_NRE; - if (cfg->n_pucch >= SRSLTE_NRE * cfg->n_rb_2) { - n_prime = (cfg->n_pucch + cfg->N_cs + 1) % SRSLTE_NRE; + uint32_t n_prime = cfg->n_pucch % SRSRAN_NRE; + if (cfg->n_pucch >= SRSRAN_NRE * cfg->n_rb_2) { + n_prime = (cfg->n_pucch + cfg->N_cs + 1) % SRSRAN_NRE; } if (ns % 2) { - n_prime = (SRSLTE_NRE * (n_prime + 1)) % (SRSLTE_NRE + 1) - 1; - if (cfg->n_pucch >= SRSLTE_NRE * cfg->n_rb_2) { - int x = (SRSLTE_NRE - 2 - (int)cfg->n_pucch) % SRSLTE_NRE; + n_prime = (SRSRAN_NRE * (n_prime + 1)) % (SRSRAN_NRE + 1) - 1; + if (cfg->n_pucch >= SRSRAN_NRE * cfg->n_rb_2) { + int x = (SRSRAN_NRE - 2 - (int)cfg->n_pucch) % SRSRAN_NRE; if (x >= 0) { n_prime = (uint32_t)x; } else { - n_prime = SRSLTE_NRE + x; + n_prime = SRSRAN_NRE + x; } } } - uint32_t n_cs = (n_cs_cell[ns][l] + n_prime) % SRSLTE_NRE; - float alpha = 2 * M_PI * (n_cs) / SRSLTE_NRE; + uint32_t n_cs = (n_cs_cell[ns][l] + n_prime) % SRSRAN_NRE; + float alpha = 2 * M_PI * (n_cs) / SRSRAN_NRE; DEBUG("n_pucch: %d, ns: %d, l: %d, n_prime: %d, n_cs: %d, alpha=%f", cfg->n_pucch, ns, l, n_prime, n_cs, alpha); return alpha; } /* Modulates bit 20 and 21 for Formats 2a and 2b as in Table 5.4.2-1 in 36.211 */ -int srslte_pucch_format2ab_mod_bits(srslte_pucch_format_t format, uint8_t bits[2], cf_t* d_10) +int srsran_pucch_format2ab_mod_bits(srsran_pucch_format_t format, uint8_t bits[2], cf_t* d_10) { if (d_10) { - if (format == SRSLTE_PUCCH_FORMAT_2A) { + if (format == SRSRAN_PUCCH_FORMAT_2A) { *d_10 = bits[0] ? -1.0 : 1.0; - return SRSLTE_SUCCESS; - } else if (format == SRSLTE_PUCCH_FORMAT_2B) { + return SRSRAN_SUCCESS; + } else if (format == SRSRAN_PUCCH_FORMAT_2B) { if (bits[0] == 0) { if (bits[1] == 0) { *d_10 = 1.0; @@ -1235,52 +1235,52 @@ int srslte_pucch_format2ab_mod_bits(srslte_pucch_format_t format, uint8_t bits[2 *d_10 = -1.0; } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } else { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } else { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } -void srslte_pucch_tx_info(srslte_pucch_cfg_t* cfg, srslte_uci_value_t* uci_data, char* str, uint32_t str_len) +void srsran_pucch_tx_info(srsran_pucch_cfg_t* cfg, srsran_uci_value_t* uci_data, char* str, uint32_t str_len) { - uint32_t n = srslte_print_check(str, + uint32_t n = srsran_print_check(str, str_len, 0, "rnti=0x%x, f=%s, n_pucch=%d", cfg->rnti, - srslte_pucch_format_text_short(cfg->format), + srsran_pucch_format_text_short(cfg->format), cfg->n_pucch); if (uci_data) { - srslte_uci_data_info(&cfg->uci_cfg, uci_data, &str[n], str_len - n); + srsran_uci_data_info(&cfg->uci_cfg, uci_data, &str[n], str_len - n); } } -void srslte_pucch_rx_info(srslte_pucch_cfg_t* cfg, srslte_pucch_res_t* pucch_res, char* str, uint32_t str_len) +void srsran_pucch_rx_info(srsran_pucch_cfg_t* cfg, srsran_pucch_res_t* pucch_res, char* str, uint32_t str_len) { - uint32_t n = srslte_print_check(str, + uint32_t n = srsran_print_check(str, str_len, 0, "rnti=0x%x, f=%s, n_pucch=%d", cfg->rnti, - srslte_pucch_format_text_short(cfg->format), + srsran_pucch_format_text_short(cfg->format), cfg->n_pucch); if (pucch_res) { if (isnormal(cfg->threshold_dmrs_detection)) { - n = srslte_print_check( + n = srsran_print_check( str, str_len, n, ", dmrs_corr=%.3f, snr=%.1f dB", pucch_res->dmrs_correlation, pucch_res->snr_db); } - n = srslte_print_check(str, str_len, n, ", corr=%.3f", pucch_res->correlation); + n = srsran_print_check(str, str_len, n, ", corr=%.3f", pucch_res->correlation); - n += srslte_uci_data_info(&cfg->uci_cfg, &pucch_res->uci_data, &str[n], str_len - n); + n += srsran_uci_data_info(&cfg->uci_cfg, &pucch_res->uci_data, &str[n], str_len - n); if (pucch_res->ta_valid) { - n = srslte_print_check(str, str_len, n, ", ta=%.1f us", pucch_res->ta_us); + n = srsran_print_check(str, str_len, n, ", ta=%.1f us", pucch_res->ta_us); } } } diff --git a/lib/src/phy/phch/pucch_cfg_nr.c b/lib/src/phy/phch/pucch_cfg_nr.c index 8aa2702db..3e79902cb 100644 --- a/lib/src/phy/phch/pucch_cfg_nr.c +++ b/lib/src/phy/phch/pucch_cfg_nr.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,186 +10,186 @@ * */ -#include "srslte/phy/phch/pucch_cfg_nr.h" -#include "srslte/phy/common/phy_common_nr.h" -#include "srslte/phy/utils/debug.h" +#include "srsran/phy/phch/pucch_cfg_nr.h" +#include "srsran/phy/common/phy_common_nr.h" +#include "srsran/phy/utils/debug.h" -static int pucch_nr_cfg_format0_resource_valid(const srslte_pucch_nr_resource_t* resource) +static int pucch_nr_cfg_format0_resource_valid(const srsran_pucch_nr_resource_t* resource) { - if (resource->format != SRSLTE_PUCCH_NR_FORMAT_0) { + if (resource->format != SRSRAN_PUCCH_NR_FORMAT_0) { ERROR("Invalid format (%d)", resource->format); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (resource->nof_symbols < SRSLTE_PUCCH_NR_FORMAT0_MIN_NSYMB || - resource->nof_symbols > SRSLTE_PUCCH_NR_FORMAT0_MAX_NSYMB) { + if (resource->nof_symbols < SRSRAN_PUCCH_NR_FORMAT0_MIN_NSYMB || + resource->nof_symbols > SRSRAN_PUCCH_NR_FORMAT0_MAX_NSYMB) { ERROR("Invalid number of symbols (%d)", resource->nof_symbols); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (resource->initial_cyclic_shift > SRSLTE_PUCCH_NR_FORMAT0_MAX_CS) { + if (resource->initial_cyclic_shift > SRSRAN_PUCCH_NR_FORMAT0_MAX_CS) { ERROR("Invalid initial cyclic shift (%d)", resource->initial_cyclic_shift); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (resource->start_symbol_idx > SRSLTE_PUCCH_NR_FORMAT0_MAX_STARTSYMB) { + if (resource->start_symbol_idx > SRSRAN_PUCCH_NR_FORMAT0_MAX_STARTSYMB) { ERROR("Invalid initial start symbol idx (%d)", resource->start_symbol_idx); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -static int pucch_nr_cfg_format1_resource_valid(const srslte_pucch_nr_resource_t* resource) +static int pucch_nr_cfg_format1_resource_valid(const srsran_pucch_nr_resource_t* resource) { - if (resource->format != SRSLTE_PUCCH_NR_FORMAT_1) { + if (resource->format != SRSRAN_PUCCH_NR_FORMAT_1) { ERROR("Invalid format (%d)", resource->format); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (resource->nof_symbols < SRSLTE_PUCCH_NR_FORMAT1_MIN_NSYMB || - resource->nof_symbols > SRSLTE_PUCCH_NR_FORMAT1_MAX_NSYMB) { + if (resource->nof_symbols < SRSRAN_PUCCH_NR_FORMAT1_MIN_NSYMB || + resource->nof_symbols > SRSRAN_PUCCH_NR_FORMAT1_MAX_NSYMB) { ERROR("Invalid number of symbols (%d)", resource->nof_symbols); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (resource->initial_cyclic_shift > SRSLTE_PUCCH_NR_FORMAT1_MAX_CS) { + if (resource->initial_cyclic_shift > SRSRAN_PUCCH_NR_FORMAT1_MAX_CS) { ERROR("Invalid initial cyclic shift (%d)", resource->initial_cyclic_shift); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (resource->start_symbol_idx > SRSLTE_PUCCH_NR_FORMAT1_MAX_STARTSYMB) { + if (resource->start_symbol_idx > SRSRAN_PUCCH_NR_FORMAT1_MAX_STARTSYMB) { ERROR("Invalid initial start symbol idx (%d)", resource->start_symbol_idx); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (resource->time_domain_occ > SRSLTE_PUCCH_NR_FORMAT1_MAX_TOCC) { + if (resource->time_domain_occ > SRSRAN_PUCCH_NR_FORMAT1_MAX_TOCC) { ERROR("Invalid time domain occ (%d)", resource->time_domain_occ); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -static int pucch_nr_cfg_format2_resource_valid(const srslte_pucch_nr_resource_t* resource) +static int pucch_nr_cfg_format2_resource_valid(const srsran_pucch_nr_resource_t* resource) { - if (resource->format != SRSLTE_PUCCH_NR_FORMAT_2) { + if (resource->format != SRSRAN_PUCCH_NR_FORMAT_2) { ERROR("Invalid format (%d)", resource->format); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (resource->nof_symbols < SRSLTE_PUCCH_NR_FORMAT2_MIN_NSYMB || - resource->nof_symbols > SRSLTE_PUCCH_NR_FORMAT2_MAX_NSYMB) { + if (resource->nof_symbols < SRSRAN_PUCCH_NR_FORMAT2_MIN_NSYMB || + resource->nof_symbols > SRSRAN_PUCCH_NR_FORMAT2_MAX_NSYMB) { ERROR("Invalid number of symbols (%d)", resource->nof_symbols); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (resource->nof_prb < SRSLTE_PUCCH_NR_FORMAT2_MIN_NPRB || resource->nof_prb > SRSLTE_PUCCH_NR_FORMAT2_MAX_NPRB) { + if (resource->nof_prb < SRSRAN_PUCCH_NR_FORMAT2_MIN_NPRB || resource->nof_prb > SRSRAN_PUCCH_NR_FORMAT2_MAX_NPRB) { ERROR("Invalid number of prb (%d)", resource->nof_prb); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (resource->start_symbol_idx > SRSLTE_PUCCH_NR_FORMAT2_MAX_STARTSYMB) { + if (resource->start_symbol_idx > SRSRAN_PUCCH_NR_FORMAT2_MAX_STARTSYMB) { ERROR("Invalid initial start symbol idx (%d)", resource->start_symbol_idx); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -static int pucch_nr_cfg_format3_resource_valid(const srslte_pucch_nr_resource_t* resource) +static int pucch_nr_cfg_format3_resource_valid(const srsran_pucch_nr_resource_t* resource) { - if (resource->format != SRSLTE_PUCCH_NR_FORMAT_3) { + if (resource->format != SRSRAN_PUCCH_NR_FORMAT_3) { ERROR("Invalid format (%d)", resource->format); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (resource->nof_symbols < SRSLTE_PUCCH_NR_FORMAT3_MIN_NSYMB || - resource->nof_symbols > SRSLTE_PUCCH_NR_FORMAT3_MAX_NSYMB) { + if (resource->nof_symbols < SRSRAN_PUCCH_NR_FORMAT3_MIN_NSYMB || + resource->nof_symbols > SRSRAN_PUCCH_NR_FORMAT3_MAX_NSYMB) { ERROR("Invalid number of symbols (%d)", resource->nof_symbols); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (resource->nof_prb < SRSLTE_PUCCH_NR_FORMAT3_MIN_NPRB || resource->nof_prb > SRSLTE_PUCCH_NR_FORMAT3_MAX_NPRB) { + if (resource->nof_prb < SRSRAN_PUCCH_NR_FORMAT3_MIN_NPRB || resource->nof_prb > SRSRAN_PUCCH_NR_FORMAT3_MAX_NPRB) { ERROR("Invalid number of prb (%d)", resource->nof_prb); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (resource->start_symbol_idx > SRSLTE_PUCCH_NR_FORMAT3_MAX_STARTSYMB) { + if (resource->start_symbol_idx > SRSRAN_PUCCH_NR_FORMAT3_MAX_STARTSYMB) { ERROR("Invalid initial start symbol idx (%d)", resource->start_symbol_idx); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -static int pucch_nr_cfg_format4_resource_valid(const srslte_pucch_nr_resource_t* resource) +static int pucch_nr_cfg_format4_resource_valid(const srsran_pucch_nr_resource_t* resource) { - if (resource->format != SRSLTE_PUCCH_NR_FORMAT_4) { + if (resource->format != SRSRAN_PUCCH_NR_FORMAT_4) { ERROR("Invalid format (%d)", resource->format); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (resource->nof_symbols < SRSLTE_PUCCH_NR_FORMAT4_MIN_NSYMB || - resource->nof_symbols > SRSLTE_PUCCH_NR_FORMAT4_MAX_NSYMB) { + if (resource->nof_symbols < SRSRAN_PUCCH_NR_FORMAT4_MIN_NSYMB || + resource->nof_symbols > SRSRAN_PUCCH_NR_FORMAT4_MAX_NSYMB) { ERROR("Invalid number of symbols (%d)", resource->nof_symbols); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (resource->start_symbol_idx > SRSLTE_PUCCH_NR_FORMAT4_MAX_STARTSYMB) { + if (resource->start_symbol_idx > SRSRAN_PUCCH_NR_FORMAT4_MAX_STARTSYMB) { ERROR("Invalid initial start symbol idx (%d)", resource->start_symbol_idx); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (resource->occ_lenth != 2 && resource->occ_lenth != 4) { ERROR("Invalid OCC length (%d)", resource->occ_lenth); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_pucch_nr_cfg_resource_valid(const srslte_pucch_nr_resource_t* resource) +int srsran_pucch_nr_cfg_resource_valid(const srsran_pucch_nr_resource_t* resource) { // Check pointer if (resource == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } - if (resource->starting_prb > SRSLTE_MAX_NRE_NR - 1) { - return SRSLTE_ERROR; + if (resource->starting_prb > SRSRAN_MAX_NRE_NR - 1) { + return SRSRAN_ERROR; } if (resource->intra_slot_hopping) { ERROR("Intra-slot hopping is not implemented"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (resource->second_hop_prb > SRSLTE_MAX_NRE_NR - 1) { - return SRSLTE_ERROR; + if (resource->second_hop_prb > SRSRAN_MAX_NRE_NR - 1) { + return SRSRAN_ERROR; } - if (resource->max_code_rate > SRSLTE_PUCCH_NR_MAX_CODE_RATE) { + if (resource->max_code_rate > SRSRAN_PUCCH_NR_MAX_CODE_RATE) { ERROR("Invalid maximum code rate (%d)", resource->max_code_rate); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } switch (resource->format) { - case SRSLTE_PUCCH_NR_FORMAT_0: + case SRSRAN_PUCCH_NR_FORMAT_0: return pucch_nr_cfg_format0_resource_valid(resource); - case SRSLTE_PUCCH_NR_FORMAT_1: + case SRSRAN_PUCCH_NR_FORMAT_1: return pucch_nr_cfg_format1_resource_valid(resource); - case SRSLTE_PUCCH_NR_FORMAT_2: + case SRSRAN_PUCCH_NR_FORMAT_2: return pucch_nr_cfg_format2_resource_valid(resource); - case SRSLTE_PUCCH_NR_FORMAT_3: + case SRSRAN_PUCCH_NR_FORMAT_3: return pucch_nr_cfg_format3_resource_valid(resource); - case SRSLTE_PUCCH_NR_FORMAT_4: + case SRSRAN_PUCCH_NR_FORMAT_4: return pucch_nr_cfg_format4_resource_valid(resource); - case SRSLTE_PUCCH_NR_FORMAT_ERROR: + case SRSRAN_PUCCH_NR_FORMAT_ERROR: default: ERROR("Invalid case"); break; } - return SRSLTE_ERROR; + return SRSRAN_ERROR; } diff --git a/lib/src/phy/phch/pucch_nr.c b/lib/src/phy/phch/pucch_nr.c index 4f06dde7e..67a41d4e7 100644 --- a/lib/src/phy/phch/pucch_nr.c +++ b/lib/src/phy/phch/pucch_nr.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,19 +10,19 @@ * */ -#include "srslte/phy/phch/pucch_nr.h" -#include "srslte/phy/common/phy_common_nr.h" -#include "srslte/phy/common/sequence.h" -#include "srslte/phy/common/zc_sequence.h" -#include "srslte/phy/mimo/precoding.h" -#include "srslte/phy/modem/demod_soft.h" -#include "srslte/phy/modem/mod.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/phch/pucch_nr.h" +#include "srsran/phy/common/phy_common_nr.h" +#include "srsran/phy/common/sequence.h" +#include "srsran/phy/common/zc_sequence.h" +#include "srsran/phy/mimo/precoding.h" +#include "srsran/phy/modem/demod_soft.h" +#include "srsran/phy/modem/mod.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" #include -int srslte_pucch_nr_group_sequence(const srslte_carrier_nr_t* carrier, - const srslte_pucch_nr_common_cfg_t* cfg, +int srsran_pucch_nr_group_sequence(const srsran_carrier_nr_t* carrier, + const srsran_pucch_nr_common_cfg_t* cfg, uint32_t* u_, uint32_t* v_) { @@ -31,18 +31,18 @@ int srslte_pucch_nr_group_sequence(const srslte_carrier_nr_t* carrier, uint32_t n_id = cfg->hopping_id_present ? cfg->hopping_id : carrier->id; switch (cfg->group_hopping) { - case SRSLTE_PUCCH_NR_GROUP_HOPPING_NEITHER: - f_ss = n_id % SRSLTE_ZC_SEQUENCE_NOF_GROUPS; + case SRSRAN_PUCCH_NR_GROUP_HOPPING_NEITHER: + f_ss = n_id % SRSRAN_ZC_SEQUENCE_NOF_GROUPS; break; - case SRSLTE_PUCCH_NR_GROUP_HOPPING_ENABLE: + case SRSRAN_PUCCH_NR_GROUP_HOPPING_ENABLE: ERROR("Group hopping is not implemented"); - return SRSLTE_ERROR; - case SRSLTE_PUCCH_NR_GROUP_HOPPING_DISABLE: + return SRSRAN_ERROR; + case SRSRAN_PUCCH_NR_GROUP_HOPPING_DISABLE: ERROR("Hopping is not implemented"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - uint32_t u = (f_gh + f_ss) % SRSLTE_ZC_SEQUENCE_NOF_GROUPS; + uint32_t u = (f_gh + f_ss) % SRSRAN_ZC_SEQUENCE_NOF_GROUPS; uint32_t v = 0; if (u_) { @@ -53,13 +53,13 @@ int srslte_pucch_nr_group_sequence(const srslte_carrier_nr_t* carrier, *v_ = v; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Implements TS 38.211 clause 6.3.2.2.2 Cyclic shift hopping -int srslte_pucch_nr_alpha_idx(const srslte_carrier_nr_t* carrier, - const srslte_pucch_nr_common_cfg_t* cfg, - const srslte_slot_cfg_t* slot, +int srsran_pucch_nr_alpha_idx(const srsran_carrier_nr_t* carrier, + const srsran_pucch_nr_common_cfg_t* cfg, + const srsran_slot_cfg_t* slot, uint32_t l, uint32_t l_prime, uint32_t m0, @@ -67,32 +67,32 @@ int srslte_pucch_nr_alpha_idx(const srslte_carrier_nr_t* carrier, uint32_t* alpha_idx) { if (carrier == NULL || cfg == NULL || slot == NULL || alpha_idx == NULL) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Compute number of slot - uint32_t n_slot = SRSLTE_SLOT_NR_MOD(carrier->numerology, slot->idx); + uint32_t n_slot = SRSRAN_SLOT_NR_MOD(carrier->numerology, slot->idx); // Generate pseudo-random sequence uint32_t cinit = cfg->hopping_id_present ? cfg->hopping_id : carrier->id; - uint8_t cs[SRSLTE_NSYMB_PER_SLOT_NR * SRSLTE_NSLOTS_PER_FRAME_NR(SRSLTE_NR_MAX_NUMEROLOGY) * 8U] = {}; - srslte_sequence_apply_bit( - cs, cs, SRSLTE_NSYMB_PER_SLOT_NR * SRSLTE_NSLOTS_PER_FRAME_NR(carrier->numerology) * 8, cinit); + uint8_t cs[SRSRAN_NSYMB_PER_SLOT_NR * SRSRAN_NSLOTS_PER_FRAME_NR(SRSRAN_NR_MAX_NUMEROLOGY) * 8U] = {}; + srsran_sequence_apply_bit( + cs, cs, SRSRAN_NSYMB_PER_SLOT_NR * SRSRAN_NSLOTS_PER_FRAME_NR(carrier->numerology) * 8, cinit); // Create n_cs parameter uint32_t n_cs = 0; for (uint32_t m = 0; m < 8; m++) { - n_cs += cs[(SRSLTE_NSYMB_PER_SLOT_NR * n_slot + (l + l_prime)) * 8 + m] << m; + n_cs += cs[(SRSRAN_NSYMB_PER_SLOT_NR * n_slot + (l + l_prime)) * 8 + m] << m; } - *alpha_idx = (m0 + m_cs + n_cs) % SRSLTE_NRE; + *alpha_idx = (m0 + m_cs + n_cs) % SRSRAN_NRE; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // TS 38.211 Table 6.3.2.4.1-2: Orthogonal sequences for PUCCH format 1 static uint32_t - pucch_nr_format1_rho[SRSLTE_PUCCH_NR_FORMAT1_N_MAX][SRSLTE_PUCCH_NR_FORMAT1_N_MAX][SRSLTE_PUCCH_NR_FORMAT1_N_MAX] = + pucch_nr_format1_rho[SRSRAN_PUCCH_NR_FORMAT1_N_MAX][SRSRAN_PUCCH_NR_FORMAT1_N_MAX][SRSRAN_PUCCH_NR_FORMAT1_N_MAX] = {{{0}, {0, 0}, {0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0}}, {{}, {0, 1}, {0, 1, 2}, {0, 2, 0, 2}, {0, 1, 2, 3, 4}, {0, 1, 2, 3, 4, 5}, {0, 1, 2, 3, 4, 5, 6}}, {{}, {}, {0, 2, 1}, {0, 0, 2, 2}, {0, 2, 4, 1, 3}, {0, 2, 4, 0, 2, 4}, {0, 2, 4, 6, 1, 3, 5}}, @@ -101,101 +101,101 @@ static uint32_t {{}, {}, {}, {}, {}, {0, 5, 4, 3, 2, 1}, {0, 5, 3, 1, 6, 4, 2}}, {{}, {}, {}, {}, {}, {}, {0, 6, 5, 4, 3, 2, 1}}}; -int srslte_pucch_nr_init(srslte_pucch_nr_t* q, const srslte_pucch_nr_args_t* args) +int srsran_pucch_nr_init(srsran_pucch_nr_t* q, const srsran_pucch_nr_args_t* args) { if (q == NULL || args == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } // Make sure object is zeroed - SRSLTE_MEM_ZERO(q, srslte_pucch_nr_t, 1); + SRSRAN_MEM_ZERO(q, srsran_pucch_nr_t, 1); // Save maximum number of PRB - q->max_prb = SRSLTE_MAX_PRB_NR; + q->max_prb = SRSRAN_MAX_PRB_NR; if (args->max_nof_prb != 0) { q->max_prb = args->max_nof_prb; } // Initialise ZC sequences for 1PRB - float alphas_1prb[SRSLTE_NRE] = {}; - for (uint32_t i = 0; i < SRSLTE_NRE; i++) { - alphas_1prb[i] = 2.0f * (float)M_PI * (float)i / (float)SRSLTE_NRE; + float alphas_1prb[SRSRAN_NRE] = {}; + for (uint32_t i = 0; i < SRSRAN_NRE; i++) { + alphas_1prb[i] = 2.0f * (float)M_PI * (float)i / (float)SRSRAN_NRE; } - srslte_zc_sequence_lut_init_nr(&q->r_uv_1prb, 1, 0, alphas_1prb, SRSLTE_NRE); + srsran_zc_sequence_lut_init_nr(&q->r_uv_1prb, 1, 0, alphas_1prb, SRSRAN_NRE); // Initialise BPSK modulation table - if (srslte_modem_table_lte(&q->bpsk, SRSLTE_MOD_BPSK) < SRSLTE_SUCCESS) { + if (srsran_modem_table_lte(&q->bpsk, SRSRAN_MOD_BPSK) < SRSRAN_SUCCESS) { ERROR("Initiating modem table"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Initialise QPSK modulation table - if (srslte_modem_table_lte(&q->qpsk, SRSLTE_MOD_QPSK) < SRSLTE_SUCCESS) { + if (srsran_modem_table_lte(&q->qpsk, SRSRAN_MOD_QPSK) < SRSRAN_SUCCESS) { ERROR("Initiating modem table"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - for (uint32_t n_pucch = 1; n_pucch <= SRSLTE_PUCCH_NR_FORMAT1_N_MAX; n_pucch++) { - for (uint32_t i = 0; i < SRSLTE_PUCCH_NR_FORMAT1_N_MAX; i++) { - for (uint32_t m = 0; m < SRSLTE_PUCCH_NR_FORMAT1_N_MAX; m++) { + for (uint32_t n_pucch = 1; n_pucch <= SRSRAN_PUCCH_NR_FORMAT1_N_MAX; n_pucch++) { + for (uint32_t i = 0; i < SRSRAN_PUCCH_NR_FORMAT1_N_MAX; i++) { + for (uint32_t m = 0; m < SRSRAN_PUCCH_NR_FORMAT1_N_MAX; m++) { uint32_t rho = pucch_nr_format1_rho[i][n_pucch - 1][m]; q->format1_w_i_m[i][n_pucch - 1][m] = cexpf(I * 2.0f * (float)M_PI * (float)rho / n_pucch); } } } - if (srslte_uci_nr_init(&q->uci, &args->uci) < SRSLTE_SUCCESS) { + if (srsran_uci_nr_init(&q->uci, &args->uci) < SRSRAN_SUCCESS) { ERROR("Initiating UCI encoder/decoder"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Allocate encoded bits b - uint32_t max_encoded_bits = q->max_prb * SRSLTE_NRE * 2 * SRSLTE_NSYMB_PER_SLOT_NR; // Assumes QPSK (Qm = 2) - q->b = srslte_vec_u8_malloc(max_encoded_bits); + uint32_t max_encoded_bits = q->max_prb * SRSRAN_NRE * 2 * SRSRAN_NSYMB_PER_SLOT_NR; // Assumes QPSK (Qm = 2) + q->b = srsran_vec_u8_malloc(max_encoded_bits); if (q->b == NULL) { ERROR("Malloc"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Allocate encoded symbols d - q->d = srslte_vec_cf_malloc(max_encoded_bits / 2); + q->d = srsran_vec_cf_malloc(max_encoded_bits / 2); if (q->d == NULL) { ERROR("Malloc"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Allocate temporal channel estimates - q->ce = srslte_vec_cf_malloc(max_encoded_bits / 2); + q->ce = srsran_vec_cf_malloc(max_encoded_bits / 2); if (q->ce == NULL) { ERROR("Malloc"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_pucch_nr_set_carrier(srslte_pucch_nr_t* q, const srslte_carrier_nr_t* carrier) +int srsran_pucch_nr_set_carrier(srsran_pucch_nr_t* q, const srsran_carrier_nr_t* carrier) { if (q == NULL || carrier == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } q->carrier = *carrier; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -void srslte_pucch_nr_free(srslte_pucch_nr_t* q) +void srsran_pucch_nr_free(srsran_pucch_nr_t* q) { if (q == NULL) { return; } - srslte_uci_nr_free(&q->uci); - srslte_zc_sequence_lut_free(&q->r_uv_1prb); + srsran_uci_nr_free(&q->uci); + srsran_zc_sequence_lut_free(&q->r_uv_1prb); - srslte_modem_table_free(&q->bpsk); - srslte_modem_table_free(&q->qpsk); + srsran_modem_table_free(&q->bpsk); + srsran_modem_table_free(&q->qpsk); if (q->b != NULL) { free(q->b); @@ -208,80 +208,80 @@ void srslte_pucch_nr_free(srslte_pucch_nr_t* q) free(q->ce); } - SRSLTE_MEM_ZERO(q, srslte_pucch_nr_t, 1); + SRSRAN_MEM_ZERO(q, srsran_pucch_nr_t, 1); } -int srslte_pucch_nr_format0_encode(const srslte_pucch_nr_t* q, - const srslte_pucch_nr_common_cfg_t* cfg, - const srslte_slot_cfg_t* slot, - srslte_pucch_nr_resource_t* resource, +int srsran_pucch_nr_format0_encode(const srsran_pucch_nr_t* q, + const srsran_pucch_nr_common_cfg_t* cfg, + const srsran_slot_cfg_t* slot, + srsran_pucch_nr_resource_t* resource, uint32_t m_cs, cf_t* slot_symbols) { if (cfg == NULL || slot == NULL || resource == NULL || slot_symbols == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } - if (srslte_pucch_nr_cfg_resource_valid(resource) < SRSLTE_SUCCESS) { + if (srsran_pucch_nr_cfg_resource_valid(resource) < SRSRAN_SUCCESS) { ERROR("Invalid PUCCH format 0 resource"); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } uint32_t u = 0; uint32_t v = 0; - if (srslte_pucch_nr_group_sequence(&q->carrier, cfg, &u, &v) < SRSLTE_SUCCESS) { + if (srsran_pucch_nr_group_sequence(&q->carrier, cfg, &u, &v) < SRSRAN_SUCCESS) { ERROR("Error getting group sequence"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } uint32_t l_prime = resource->start_symbol_idx; for (uint32_t l = 0; l < resource->nof_symbols; l++) { // Get Alpha index uint32_t alpha_idx = 0; - if (srslte_pucch_nr_alpha_idx( - &q->carrier, cfg, slot, l, l_prime, resource->initial_cyclic_shift, m_cs, &alpha_idx) < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (srsran_pucch_nr_alpha_idx( + &q->carrier, cfg, slot, l, l_prime, resource->initial_cyclic_shift, m_cs, &alpha_idx) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } // get r_uv sequence from LUT object - const cf_t* r_uv = srslte_zc_sequence_lut_get(&q->r_uv_1prb, u, v, alpha_idx); + const cf_t* r_uv = srsran_zc_sequence_lut_get(&q->r_uv_1prb, u, v, alpha_idx); if (r_uv == NULL) { ERROR("Getting r_uv sequence"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Get start of the sequence in resource grid - cf_t* slot_symbols_ptr = &slot_symbols[(q->carrier.nof_prb * (l + l_prime) + resource->starting_prb) * SRSLTE_NRE]; + cf_t* slot_symbols_ptr = &slot_symbols[(q->carrier.nof_prb * (l + l_prime) + resource->starting_prb) * SRSRAN_NRE]; // Copy sequence in grid - srslte_vec_cf_copy(slot_symbols_ptr, r_uv, SRSLTE_NRE); + srsran_vec_cf_copy(slot_symbols_ptr, r_uv, SRSRAN_NRE); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_pucch_nr_format0_measure(const srslte_pucch_nr_t* q, - const srslte_pucch_nr_common_cfg_t* cfg, - const srslte_slot_cfg_t* slot, - srslte_pucch_nr_resource_t* resource, +int srsran_pucch_nr_format0_measure(const srsran_pucch_nr_t* q, + const srsran_pucch_nr_common_cfg_t* cfg, + const srsran_slot_cfg_t* slot, + srsran_pucch_nr_resource_t* resource, uint32_t m_cs, const cf_t* slot_symbols, - srslte_pucch_nr_measure_t* measure) + srsran_pucch_nr_measure_t* measure) { if (cfg == NULL || slot == NULL || resource == NULL || slot_symbols == NULL || measure == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } - if (srslte_pucch_nr_cfg_resource_valid(resource) < SRSLTE_SUCCESS) { + if (srsran_pucch_nr_cfg_resource_valid(resource) < SRSRAN_SUCCESS) { ERROR("Invalid PUCCH format 0 resource"); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } uint32_t u = 0; uint32_t v = 0; - if (srslte_pucch_nr_group_sequence(&q->carrier, cfg, &u, &v) < SRSLTE_SUCCESS) { + if (srsran_pucch_nr_group_sequence(&q->carrier, cfg, &u, &v) < SRSRAN_SUCCESS) { ERROR("Error getting group sequence"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } uint32_t l_prime = resource->start_symbol_idx; @@ -290,28 +290,28 @@ int srslte_pucch_nr_format0_measure(const srslte_pucch_nr_t* q, for (uint32_t l = 0; l < resource->nof_symbols; l++) { // Get Alpha index uint32_t alpha_idx = 0; - if (srslte_pucch_nr_alpha_idx( - &q->carrier, cfg, slot, l, l_prime, resource->initial_cyclic_shift, m_cs, &alpha_idx) < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (srsran_pucch_nr_alpha_idx( + &q->carrier, cfg, slot, l, l_prime, resource->initial_cyclic_shift, m_cs, &alpha_idx) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } // get r_uv sequence from LUT object - const cf_t* r_uv = srslte_zc_sequence_lut_get(&q->r_uv_1prb, u, v, alpha_idx); + const cf_t* r_uv = srsran_zc_sequence_lut_get(&q->r_uv_1prb, u, v, alpha_idx); if (r_uv == NULL) { ERROR("Getting r_uv sequence"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Get start of the sequence in resource grid const cf_t* slot_symbols_ptr = - &slot_symbols[(q->carrier.nof_prb * (l + l_prime) + resource->starting_prb) * SRSLTE_NRE]; + &slot_symbols[(q->carrier.nof_prb * (l + l_prime) + resource->starting_prb) * SRSRAN_NRE]; // Measure EPRE and average - epre += srslte_vec_avg_power_cf(slot_symbols_ptr, SRSLTE_NRE) / resource->nof_symbols; + epre += srsran_vec_avg_power_cf(slot_symbols_ptr, SRSRAN_NRE) / resource->nof_symbols; // Do correlation - cf_t corr = srslte_vec_dot_prod_conj_ccc(r_uv, slot_symbols_ptr, SRSLTE_NRE); - corr /= SRSLTE_NRE; + cf_t corr = srsran_vec_dot_prod_conj_ccc(r_uv, slot_symbols_ptr, SRSRAN_NRE); + corr /= SRSRAN_NRE; // Measure RSRP and average rsrp += (__real__ corr * __real__ corr + __imag__ corr * __imag__ corr) / resource->nof_symbols; @@ -319,20 +319,20 @@ int srslte_pucch_nr_format0_measure(const srslte_pucch_nr_t* q, // Save measurement measure->rsrp = rsrp; - measure->rsrp_dBfs = srslte_convert_power_to_dB(rsrp); + measure->rsrp_dBfs = srsran_convert_power_to_dB(rsrp); measure->epre = epre; - measure->epre_dBfs = srslte_convert_power_to_dB(epre); + measure->epre_dBfs = srsran_convert_power_to_dB(epre); if (isnormal(epre)) { measure->norm_corr = rsrp / epre; } else { measure->norm_corr = 0.0f; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Implements TS 38.211 table 6.3.2.4.1-1 Number of PUCCH symbols and the corresponding N_PUC... -static uint32_t pucch_nr_format1_n_pucch(const srslte_pucch_nr_resource_t* resource, uint32_t m_prime) +static uint32_t pucch_nr_format1_n_pucch(const srsran_pucch_nr_resource_t* resource, uint32_t m_prime) { if (resource->intra_slot_hopping) { if (m_prime == 0) { @@ -349,17 +349,17 @@ static uint32_t pucch_nr_format1_n_pucch(const srslte_pucch_nr_resource_t* resou return resource->nof_symbols / 2; } -cf_t srslte_pucch_nr_format1_w(const srslte_pucch_nr_t* q, uint32_t n_pucch, uint32_t i, uint32_t m) +cf_t srsran_pucch_nr_format1_w(const srsran_pucch_nr_t* q, uint32_t n_pucch, uint32_t i, uint32_t m) { - if (n_pucch < 1 || n_pucch > SRSLTE_PUCCH_NR_FORMAT1_N_MAX) { + if (n_pucch < 1 || n_pucch > SRSRAN_PUCCH_NR_FORMAT1_N_MAX) { ERROR("Invalid n_pucch"); return NAN; } - if (i >= SRSLTE_PUCCH_NR_FORMAT1_N_MAX) { + if (i >= SRSRAN_PUCCH_NR_FORMAT1_N_MAX) { ERROR("Invalid i"); return NAN; } - if (m >= SRSLTE_PUCCH_NR_FORMAT1_N_MAX) { + if (m >= SRSRAN_PUCCH_NR_FORMAT1_N_MAX) { ERROR("Invalid m"); return NAN; } @@ -368,42 +368,42 @@ cf_t srslte_pucch_nr_format1_w(const srslte_pucch_nr_t* q, uint32_t n_pucch, uin return q->format1_w_i_m[i][n_pucch - 1][m]; } -int srslte_pucch_nr_format1_encode(const srslte_pucch_nr_t* q, - const srslte_pucch_nr_common_cfg_t* cfg, - const srslte_slot_cfg_t* slot, - const srslte_pucch_nr_resource_t* resource, +int srsran_pucch_nr_format1_encode(const srsran_pucch_nr_t* q, + const srsran_pucch_nr_common_cfg_t* cfg, + const srsran_slot_cfg_t* slot, + const srsran_pucch_nr_resource_t* resource, uint8_t* b, uint32_t nof_bits, cf_t* slot_symbols) { if (q == NULL || cfg == NULL || slot == NULL || resource == NULL || b == NULL || slot_symbols == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } - if (srslte_pucch_nr_cfg_resource_valid(resource) < SRSLTE_SUCCESS) { + if (srsran_pucch_nr_cfg_resource_valid(resource) < SRSRAN_SUCCESS) { ERROR("Invalid PUCCH format 1 resource"); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } - if (nof_bits > SRSLTE_PUCCH_NR_FORMAT1_MAX_NOF_BITS) { + if (nof_bits > SRSRAN_PUCCH_NR_FORMAT1_MAX_NOF_BITS) { ERROR("Invalid number of bits (%d)", nof_bits); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Modulate d cf_t d = 0; if (nof_bits == 1) { - srslte_mod_modulate(&q->bpsk, b, &d, nof_bits); + srsran_mod_modulate(&q->bpsk, b, &d, nof_bits); } else { - srslte_mod_modulate(&q->qpsk, b, &d, nof_bits); + srsran_mod_modulate(&q->qpsk, b, &d, nof_bits); } // Get group sequence uint32_t u = 0; uint32_t v = 0; - if (srslte_pucch_nr_group_sequence(&q->carrier, cfg, &u, &v) < SRSLTE_SUCCESS) { + if (srsran_pucch_nr_group_sequence(&q->carrier, cfg, &u, &v) < SRSRAN_SUCCESS) { ERROR("Error getting group sequence"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Calculate number of symbols carrying PUCCH (No DMRS) @@ -412,64 +412,64 @@ int srslte_pucch_nr_format1_encode(const srslte_pucch_nr_t* q, uint32_t l_prime = resource->start_symbol_idx; for (uint32_t l = 1, m = 0; l < resource->nof_symbols; l += 2, m++) { // Get start of the sequence in resource grid - cf_t* slot_symbols_ptr = &slot_symbols[(q->carrier.nof_prb * (l + l_prime) + resource->starting_prb) * SRSLTE_NRE]; + cf_t* slot_symbols_ptr = &slot_symbols[(q->carrier.nof_prb * (l + l_prime) + resource->starting_prb) * SRSRAN_NRE]; // Get Alpha index uint32_t alpha_idx = 0; - if (srslte_pucch_nr_alpha_idx(&q->carrier, cfg, slot, l, l_prime, resource->initial_cyclic_shift, 0, &alpha_idx) < - SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (srsran_pucch_nr_alpha_idx(&q->carrier, cfg, slot, l, l_prime, resource->initial_cyclic_shift, 0, &alpha_idx) < + SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } // get r_uv sequence from LUT object - const cf_t* r_uv = srslte_zc_sequence_lut_get(&q->r_uv_1prb, u, v, alpha_idx); + const cf_t* r_uv = srsran_zc_sequence_lut_get(&q->r_uv_1prb, u, v, alpha_idx); if (r_uv == NULL) { ERROR("Getting r_uv sequence"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Compute y = d(0) * r_uv - cf_t y[SRSLTE_NRE]; - srslte_vec_sc_prod_ccc(r_uv, d, y, SRSLTE_NRE); + cf_t y[SRSRAN_NRE]; + srsran_vec_sc_prod_ccc(r_uv, d, y, SRSRAN_NRE); // Get w_i_m - cf_t w_i_m = srslte_pucch_nr_format1_w(q, n_pucch, resource->time_domain_occ, m); + cf_t w_i_m = srsran_pucch_nr_format1_w(q, n_pucch, resource->time_domain_occ, m); // Compute z(n) = w(i) * y(n) - cf_t z[SRSLTE_NRE]; - srslte_vec_sc_prod_ccc(y, w_i_m, z, SRSLTE_NRE); + cf_t z[SRSRAN_NRE]; + srsran_vec_sc_prod_ccc(y, w_i_m, z, SRSRAN_NRE); // Put z in the grid - srslte_vec_cf_copy(slot_symbols_ptr, z, SRSLTE_NRE); + srsran_vec_cf_copy(slot_symbols_ptr, z, SRSRAN_NRE); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_pucch_nr_format1_decode(srslte_pucch_nr_t* q, - const srslte_pucch_nr_common_cfg_t* cfg, - const srslte_slot_cfg_t* slot, - const srslte_pucch_nr_resource_t* resource, - srslte_chest_ul_res_t* chest_res, +int srsran_pucch_nr_format1_decode(srsran_pucch_nr_t* q, + const srsran_pucch_nr_common_cfg_t* cfg, + const srsran_slot_cfg_t* slot, + const srsran_pucch_nr_resource_t* resource, + srsran_chest_ul_res_t* chest_res, cf_t* slot_symbols, - uint8_t b[SRSLTE_PUCCH_NR_FORMAT1_MAX_NOF_BITS], + uint8_t b[SRSRAN_PUCCH_NR_FORMAT1_MAX_NOF_BITS], uint32_t nof_bits) { uint32_t m_cs = 0; if (q == NULL || cfg == NULL || slot == NULL || resource == NULL || chest_res == NULL || b == NULL || slot_symbols == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } - if (srslte_pucch_nr_cfg_resource_valid(resource) < SRSLTE_SUCCESS) { + if (srsran_pucch_nr_cfg_resource_valid(resource) < SRSRAN_SUCCESS) { ERROR("Invalid PUCCH format 1 resource"); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } - if (nof_bits > SRSLTE_PUCCH_NR_FORMAT1_MAX_NOF_BITS) { + if (nof_bits > SRSRAN_PUCCH_NR_FORMAT1_MAX_NOF_BITS) { ERROR("Invalid number of bits (%d)", nof_bits); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Received symbol d @@ -478,9 +478,9 @@ int srslte_pucch_nr_format1_decode(srslte_pucch_nr_t* q, // Get group sequence uint32_t u = 0; uint32_t v = 0; - if (srslte_pucch_nr_group_sequence(&q->carrier, cfg, &u, &v) < SRSLTE_SUCCESS) { + if (srsran_pucch_nr_group_sequence(&q->carrier, cfg, &u, &v) < SRSRAN_SUCCESS) { ERROR("Error getting group sequence"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Calculate number of symbols carrying PUCCH (No DMRS) @@ -489,52 +489,52 @@ int srslte_pucch_nr_format1_decode(srslte_pucch_nr_t* q, uint32_t l_prime = resource->start_symbol_idx; for (uint32_t l = 1, m = 0; l < resource->nof_symbols; l += 2, m++) { // Get start of the sequence in resource grid - cf_t* slot_symbols_ptr = &slot_symbols[(q->carrier.nof_prb * (l + l_prime) + resource->starting_prb) * SRSLTE_NRE]; - cf_t* ce_ptr = &chest_res->ce[(q->carrier.nof_prb * (l + l_prime) + resource->starting_prb) * SRSLTE_NRE]; + cf_t* slot_symbols_ptr = &slot_symbols[(q->carrier.nof_prb * (l + l_prime) + resource->starting_prb) * SRSRAN_NRE]; + cf_t* ce_ptr = &chest_res->ce[(q->carrier.nof_prb * (l + l_prime) + resource->starting_prb) * SRSRAN_NRE]; // Equalise x = w(i) * d' * r_uv(n) - cf_t x[SRSLTE_NRE]; - srslte_predecoding_single(slot_symbols_ptr, ce_ptr, x, NULL, SRSLTE_NRE, 1.0f, chest_res->noise_estimate); + cf_t x[SRSRAN_NRE]; + srsran_predecoding_single(slot_symbols_ptr, ce_ptr, x, NULL, SRSRAN_NRE, 1.0f, chest_res->noise_estimate); // Get Alpha index uint32_t alpha_idx = 0; - if (srslte_pucch_nr_alpha_idx( - &q->carrier, cfg, slot, l, l_prime, resource->initial_cyclic_shift, m_cs, &alpha_idx) < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (srsran_pucch_nr_alpha_idx( + &q->carrier, cfg, slot, l, l_prime, resource->initial_cyclic_shift, m_cs, &alpha_idx) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } // get r_uv sequence from LUT object - const cf_t* r_uv = srslte_zc_sequence_lut_get(&q->r_uv_1prb, u, v, alpha_idx); + const cf_t* r_uv = srsran_zc_sequence_lut_get(&q->r_uv_1prb, u, v, alpha_idx); if (r_uv == NULL) { ERROR("Getting r_uv sequence"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Get w_i_m - cf_t w_i_m = srslte_pucch_nr_format1_w(q, n_pucch, resource->time_domain_occ, m); + cf_t w_i_m = srsran_pucch_nr_format1_w(q, n_pucch, resource->time_domain_occ, m); // Compute z(n) = w(i) * r_uv(n) - cf_t z[SRSLTE_NRE]; - srslte_vec_sc_prod_ccc(r_uv, w_i_m, z, SRSLTE_NRE); + cf_t z[SRSRAN_NRE]; + srsran_vec_sc_prod_ccc(r_uv, w_i_m, z, SRSRAN_NRE); // Compute d = sum(x * conj(w(i) * r_uv(n))) = sum(w(i) * d' * r_uv(n) * conj(w(i) * r_uv(n))) = d' - d += srslte_vec_dot_prod_conj_ccc(x, z, SRSLTE_NRE); + d += srsran_vec_dot_prod_conj_ccc(x, z, SRSRAN_NRE); } // Demodulate d - float llr[SRSLTE_PUCCH_NR_FORMAT1_MAX_NOF_BITS]; - srslte_demod_soft_demodulate((nof_bits == 1) ? SRSLTE_MOD_BPSK : SRSLTE_MOD_QPSK, &d, llr, 1); + float llr[SRSRAN_PUCCH_NR_FORMAT1_MAX_NOF_BITS]; + srsran_demod_soft_demodulate((nof_bits == 1) ? SRSRAN_MOD_BPSK : SRSRAN_MOD_QPSK, &d, llr, 1); // Hard decision for (uint32_t i = 0; i < nof_bits; i++) { b[i] = llr[i] > 0.0f ? 1 : 0; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -static uint32_t pucch_nr_format2_cinit(const srslte_carrier_nr_t* carrier, - const srslte_pucch_nr_common_cfg_t* pucch_cfg, - const srslte_uci_cfg_nr_t* uci_cfg) +static uint32_t pucch_nr_format2_cinit(const srsran_carrier_nr_t* carrier, + const srsran_pucch_nr_common_cfg_t* pucch_cfg, + const srsran_uci_cfg_nr_t* uci_cfg) { uint32_t n_id = (pucch_cfg->scrambling_id_present) ? pucch_cfg->scrambling_id_present : carrier->id; @@ -542,69 +542,69 @@ static uint32_t pucch_nr_format2_cinit(const srslte_carrier_nr_t* carri } // Implements TS 38.211 section 6.3.2.5 PUCCH format 2 -static int pucch_nr_format2_encode(srslte_pucch_nr_t* q, - const srslte_carrier_nr_t* carrier, - const srslte_pucch_nr_common_cfg_t* cfg, - const srslte_pucch_nr_resource_t* resource, - const srslte_uci_cfg_nr_t* uci_cfg, +static int pucch_nr_format2_encode(srsran_pucch_nr_t* q, + const srsran_carrier_nr_t* carrier, + const srsran_pucch_nr_common_cfg_t* cfg, + const srsran_pucch_nr_resource_t* resource, + const srsran_uci_cfg_nr_t* uci_cfg, cf_t* slot_symbols) { // Validate configuration - if (srslte_pucch_nr_cfg_resource_valid(resource) < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (srsran_pucch_nr_cfg_resource_valid(resource) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } // Calculate number of encoded symbols - uint32_t E = srslte_uci_nr_pucch_format_2_3_4_E(resource); + uint32_t E = srsran_uci_nr_pucch_format_2_3_4_E(resource); // 6.3.2.5.1 Scrambling uint32_t cinit = pucch_nr_format2_cinit(carrier, cfg, uci_cfg); - srslte_sequence_apply_bit(q->b, q->b, E, cinit); + srsran_sequence_apply_bit(q->b, q->b, E, cinit); // 6.3.2.5.2 Modulation - srslte_mod_modulate(&q->qpsk, q->b, q->d, E); + srsran_mod_modulate(&q->qpsk, q->b, q->d, E); // 6.3.2.5.3 Mapping to physical resources uint32_t l_start = resource->start_symbol_idx; uint32_t l_end = resource->start_symbol_idx + resource->nof_symbols; - uint32_t k_start = SRSLTE_MIN(carrier->nof_prb - 1, resource->starting_prb) * SRSLTE_NRE; - uint32_t k_end = SRSLTE_MIN(carrier->nof_prb, resource->starting_prb + resource->nof_prb) * SRSLTE_NRE; + uint32_t k_start = SRSRAN_MIN(carrier->nof_prb - 1, resource->starting_prb) * SRSRAN_NRE; + uint32_t k_end = SRSRAN_MIN(carrier->nof_prb, resource->starting_prb + resource->nof_prb) * SRSRAN_NRE; for (uint32_t l = l_start, i = 0; l < l_end; l++) { - cf_t* symbol_ptr = &slot_symbols[l * carrier->nof_prb * SRSLTE_NRE]; + cf_t* symbol_ptr = &slot_symbols[l * carrier->nof_prb * SRSRAN_NRE]; for (uint32_t k = k_start; k < k_end; k += 3) { symbol_ptr[k] = q->d[i++]; symbol_ptr[k + 2] = q->d[i++]; } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -static int pucch_nr_format2_decode(srslte_pucch_nr_t* q, - const srslte_carrier_nr_t* carrier, - const srslte_pucch_nr_common_cfg_t* cfg, - const srslte_pucch_nr_resource_t* resource, - const srslte_uci_cfg_nr_t* uci_cfg, - srslte_chest_ul_res_t* chest_res, +static int pucch_nr_format2_decode(srsran_pucch_nr_t* q, + const srsran_carrier_nr_t* carrier, + const srsran_pucch_nr_common_cfg_t* cfg, + const srsran_pucch_nr_resource_t* resource, + const srsran_uci_cfg_nr_t* uci_cfg, + srsran_chest_ul_res_t* chest_res, cf_t* slot_symbols, int8_t* llr) { // Validate configuration - if (srslte_pucch_nr_cfg_resource_valid(resource) < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (srsran_pucch_nr_cfg_resource_valid(resource) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } // Calculate number of encoded symbols - uint32_t E = srslte_uci_nr_pucch_format_2_3_4_E(resource); + uint32_t E = srsran_uci_nr_pucch_format_2_3_4_E(resource); // Undo mapping to physical resources uint32_t l_start = resource->start_symbol_idx; uint32_t l_end = resource->start_symbol_idx + resource->nof_symbols; - uint32_t k_start = resource->starting_prb * SRSLTE_NRE; - uint32_t k_end = (resource->starting_prb + resource->nof_prb) * SRSLTE_NRE; + uint32_t k_start = resource->starting_prb * SRSRAN_NRE; + uint32_t k_end = (resource->starting_prb + resource->nof_prb) * SRSRAN_NRE; for (uint32_t l = l_start, i = 0; l < l_end; l++) { - cf_t* symbol_ptr = &slot_symbols[l * carrier->nof_prb * SRSLTE_NRE]; - cf_t* ce_ptr = &chest_res->ce[l * carrier->nof_prb * SRSLTE_NRE]; + cf_t* symbol_ptr = &slot_symbols[l * carrier->nof_prb * SRSRAN_NRE]; + cf_t* ce_ptr = &chest_res->ce[l * carrier->nof_prb * SRSRAN_NRE]; for (uint32_t k = k_start; k < k_end; k += 3) { q->d[i] = symbol_ptr[k]; q->ce[i] = ce_ptr[k]; @@ -615,121 +615,121 @@ static int pucch_nr_format2_decode(srslte_pucch_nr_t* q, } } - if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_INFO && !handler_registered) { + if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_INFO && !handler_registered) { INFO("d="); - srslte_vec_fprint_c(stdout, q->d, resource->nof_symbols * resource->nof_prb * (SRSLTE_NRE - 4)); + srsran_vec_fprint_c(stdout, q->d, resource->nof_symbols * resource->nof_prb * (SRSRAN_NRE - 4)); INFO("ce="); - srslte_vec_fprint_c(stdout, q->ce, resource->nof_symbols * resource->nof_prb * (SRSLTE_NRE - 4)); + srsran_vec_fprint_c(stdout, q->ce, resource->nof_symbols * resource->nof_prb * (SRSRAN_NRE - 4)); } // Equalise - if (srslte_predecoding_single(q->d, q->ce, q->d, NULL, E, 1.0f, chest_res->noise_estimate) < SRSLTE_SUCCESS) { + if (srsran_predecoding_single(q->d, q->ce, q->d, NULL, E, 1.0f, chest_res->noise_estimate) < SRSRAN_SUCCESS) { ERROR("Error Pre-decoding"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Soft-demodulate - if (srslte_demod_soft_demodulate_b(SRSLTE_MOD_QPSK, q->d, llr, E) < SRSLTE_SUCCESS) { + if (srsran_demod_soft_demodulate_b(SRSRAN_MOD_QPSK, q->d, llr, E) < SRSRAN_SUCCESS) { ERROR("Error soft-demodulate"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Undo Scrambling uint32_t cinit = pucch_nr_format2_cinit(carrier, cfg, uci_cfg); - srslte_sequence_apply_c(llr, llr, E, cinit); + srsran_sequence_apply_c(llr, llr, E, cinit); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_pucch_nr_format_2_3_4_encode(srslte_pucch_nr_t* q, - const srslte_pucch_nr_common_cfg_t* cfg, - const srslte_slot_cfg_t* slot, - const srslte_pucch_nr_resource_t* resource, - const srslte_uci_cfg_nr_t* uci_cfg, - const srslte_uci_value_nr_t* uci_value, +int srsran_pucch_nr_format_2_3_4_encode(srsran_pucch_nr_t* q, + const srsran_pucch_nr_common_cfg_t* cfg, + const srsran_slot_cfg_t* slot, + const srsran_pucch_nr_resource_t* resource, + const srsran_uci_cfg_nr_t* uci_cfg, + const srsran_uci_value_nr_t* uci_value, cf_t* slot_symbols) { // Validate input pointers if (q == NULL || cfg == NULL || slot == NULL || resource == NULL || uci_cfg == NULL || uci_value == NULL || slot_symbols == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } // Encode PUCCH message - if (srslte_uci_nr_encode_pucch(&q->uci, resource, uci_cfg, uci_value, q->b) < SRSLTE_SUCCESS) { + if (srsran_uci_nr_encode_pucch(&q->uci, resource, uci_cfg, uci_value, q->b) < SRSRAN_SUCCESS) { ERROR("Error encoding UCI"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Modulate PUCCH switch (resource->format) { - case SRSLTE_PUCCH_NR_FORMAT_2: + case SRSRAN_PUCCH_NR_FORMAT_2: return pucch_nr_format2_encode(q, &q->carrier, cfg, resource, uci_cfg, slot_symbols); - case SRSLTE_PUCCH_NR_FORMAT_3: - case SRSLTE_PUCCH_NR_FORMAT_4: + case SRSRAN_PUCCH_NR_FORMAT_3: + case SRSRAN_PUCCH_NR_FORMAT_4: ERROR("Not implemented"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; default: - case SRSLTE_PUCCH_NR_FORMAT_ERROR: + case SRSRAN_PUCCH_NR_FORMAT_ERROR: ERROR("Invalid format"); } - return SRSLTE_ERROR; + return SRSRAN_ERROR; } -int srslte_pucch_nr_format_2_3_4_decode(srslte_pucch_nr_t* q, - const srslte_pucch_nr_common_cfg_t* cfg, - const srslte_slot_cfg_t* slot, - const srslte_pucch_nr_resource_t* resource, - const srslte_uci_cfg_nr_t* uci_cfg, - srslte_chest_ul_res_t* chest_res, +int srsran_pucch_nr_format_2_3_4_decode(srsran_pucch_nr_t* q, + const srsran_pucch_nr_common_cfg_t* cfg, + const srsran_slot_cfg_t* slot, + const srsran_pucch_nr_resource_t* resource, + const srsran_uci_cfg_nr_t* uci_cfg, + srsran_chest_ul_res_t* chest_res, cf_t* slot_symbols, - srslte_uci_value_nr_t* uci_value) + srsran_uci_value_nr_t* uci_value) { // Validate input pointers if (q == NULL || cfg == NULL || slot == NULL || resource == NULL || uci_cfg == NULL || chest_res == NULL || uci_value == NULL || slot_symbols == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } // Demodulate PUCCH message int8_t* llr = (int8_t*)q->b; switch (resource->format) { - case SRSLTE_PUCCH_NR_FORMAT_2: + case SRSRAN_PUCCH_NR_FORMAT_2: if (pucch_nr_format2_decode(q, &q->carrier, cfg, resource, uci_cfg, chest_res, slot_symbols, llr) < - SRSLTE_SUCCESS) { + SRSRAN_SUCCESS) { ERROR("Demodulating PUCCH format 2"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } break; - case SRSLTE_PUCCH_NR_FORMAT_3: - case SRSLTE_PUCCH_NR_FORMAT_4: + case SRSRAN_PUCCH_NR_FORMAT_3: + case SRSRAN_PUCCH_NR_FORMAT_4: ERROR("Not implemented"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; default: - case SRSLTE_PUCCH_NR_FORMAT_ERROR: + case SRSRAN_PUCCH_NR_FORMAT_ERROR: ERROR("Invalid format"); } // Decode PUCCH message - if (srslte_uci_nr_decode_pucch(&q->uci, resource, uci_cfg, llr, uci_value) < SRSLTE_SUCCESS) { + if (srsran_uci_nr_decode_pucch(&q->uci, resource, uci_cfg, llr, uci_value) < SRSRAN_SUCCESS) { ERROR("Error encoding UCI"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -static uint32_t pucch_nr_resource_info(const srslte_pucch_nr_resource_t* r, char* str, uint32_t str_len) +static uint32_t pucch_nr_resource_info(const srsran_pucch_nr_resource_t* r, char* str, uint32_t str_len) { uint32_t len = 0; uint32_t nof_prb = 1; - if (r->format == SRSLTE_PUCCH_NR_FORMAT_2 || r->format == SRSLTE_PUCCH_NR_FORMAT_3) { + if (r->format == SRSRAN_PUCCH_NR_FORMAT_2 || r->format == SRSRAN_PUCCH_NR_FORMAT_3) { nof_prb = r->nof_prb; } - len = srslte_print_check(str, + len = srsran_print_check(str, str_len, len, "f=%d, prb=%d:%d, symb=%d:%d", @@ -740,26 +740,26 @@ static uint32_t pucch_nr_resource_info(const srslte_pucch_nr_resource_t* r, char r->nof_symbols); if (r->intra_slot_hopping) { - len = srslte_print_check(str, str_len, len, ", hop=%d", r->second_hop_prb); + len = srsran_print_check(str, str_len, len, ", hop=%d", r->second_hop_prb); } - if (r->format == SRSLTE_PUCCH_NR_FORMAT_0 || r->format == SRSLTE_PUCCH_NR_FORMAT_1) { - len = srslte_print_check(str, str_len, len, ", cs=%d", r->initial_cyclic_shift); + if (r->format == SRSRAN_PUCCH_NR_FORMAT_0 || r->format == SRSRAN_PUCCH_NR_FORMAT_1) { + len = srsran_print_check(str, str_len, len, ", cs=%d", r->initial_cyclic_shift); } - if (r->format == SRSLTE_PUCCH_NR_FORMAT_1) { - len = srslte_print_check(str, str_len, len, ", occ=%d", r->time_domain_occ); + if (r->format == SRSRAN_PUCCH_NR_FORMAT_1) { + len = srsran_print_check(str, str_len, len, ", occ=%d", r->time_domain_occ); } - if (r->format == SRSLTE_PUCCH_NR_FORMAT_4) { - len = srslte_print_check(str, str_len, len, ", occ=%d:%d", r->occ_index, r->occ_lenth); + if (r->format == SRSRAN_PUCCH_NR_FORMAT_4) { + len = srsran_print_check(str, str_len, len, ", occ=%d:%d", r->occ_index, r->occ_lenth); } return len; } -uint32_t srslte_pucch_nr_tx_info(const srslte_pucch_nr_resource_t* resource, - const srslte_uci_data_nr_t* uci_data, +uint32_t srsran_pucch_nr_tx_info(const srsran_pucch_nr_resource_t* resource, + const srsran_uci_data_nr_t* uci_data, char* str, uint32_t str_len) { @@ -767,9 +767,9 @@ uint32_t srslte_pucch_nr_tx_info(const srslte_pucch_nr_resource_t* resource, len += pucch_nr_resource_info(resource, &str[len], str_len - len); - len = srslte_print_check(str, str_len, len, ", "); + len = srsran_print_check(str, str_len, len, ", "); - len += srslte_uci_nr_info(uci_data, &str[len], str_len - len); + len += srsran_uci_nr_info(uci_data, &str[len], str_len - len); return len; } diff --git a/lib/src/phy/phch/pucch_proc.c b/lib/src/phy/phch/pucch_proc.c index 73956f363..ab7ac0a01 100644 --- a/lib/src/phy/phch/pucch_proc.c +++ b/lib/src/phy/phch/pucch_proc.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,10 +10,10 @@ * */ -#include -#include +#include +#include -static bool pucch_proc_tx_sr(const srslte_uci_cfg_t* uci_cfg, const srslte_uci_value_t* uci_value) +static bool pucch_proc_tx_sr(const srsran_uci_cfg_t* uci_cfg, const srsran_uci_value_t* uci_value) { // Check SR transmission if (uci_value) { @@ -24,31 +24,31 @@ static bool pucch_proc_tx_sr(const srslte_uci_cfg_t* uci_cfg, const srslte_uci_v return uci_cfg->is_scheduling_request_tti; } -srslte_pucch_format_t srslte_pucch_proc_select_format(const srslte_cell_t* cell, - const srslte_pucch_cfg_t* cfg, - const srslte_uci_cfg_t* uci_cfg, - const srslte_uci_value_t* uci_value) +srsran_pucch_format_t srsran_pucch_proc_select_format(const srsran_cell_t* cell, + const srsran_pucch_cfg_t* cfg, + const srsran_uci_cfg_t* uci_cfg, + const srsran_uci_value_t* uci_value) { - srslte_pucch_format_t format = SRSLTE_PUCCH_FORMAT_ERROR; - uint32_t total_ack = srslte_uci_cfg_total_ack(uci_cfg); + srsran_pucch_format_t format = SRSRAN_PUCCH_FORMAT_ERROR; + uint32_t total_ack = srsran_uci_cfg_total_ack(uci_cfg); // No CQI data if (!uci_cfg->cqi.data_enable && uci_cfg->cqi.ri_len == 0) { - if (cfg->ack_nack_feedback_mode == SRSLTE_PUCCH_ACK_NACK_FEEDBACK_MODE_PUCCH3 && + if (cfg->ack_nack_feedback_mode == SRSRAN_PUCCH_ACK_NACK_FEEDBACK_MODE_PUCCH3 && total_ack > uci_cfg->ack[0].nof_acks) { - format = SRSLTE_PUCCH_FORMAT_3; + format = SRSRAN_PUCCH_FORMAT_3; } // 1-bit ACK + optional SR else if (total_ack == 1) { - format = SRSLTE_PUCCH_FORMAT_1A; + format = SRSRAN_PUCCH_FORMAT_1A; } // 2-bit ACK + optional SR else if (total_ack >= 2 && total_ack <= 4) { - format = SRSLTE_PUCCH_FORMAT_1B; // with channel selection if > 2 + format = SRSRAN_PUCCH_FORMAT_1B; // with channel selection if > 2 } // If UCI value is provided, use SR signal only, otherwise SR request opportunity else if (pucch_proc_tx_sr(uci_cfg, uci_value)) { - format = SRSLTE_PUCCH_FORMAT_1; + format = SRSRAN_PUCCH_FORMAT_1; } else { ERROR("Error selecting PUCCH format: Unsupported number of ACK bits %d", total_ack); } @@ -57,54 +57,54 @@ srslte_pucch_format_t srslte_pucch_proc_select_format(const srslte_cell_t* else { // CQI and no ack if (total_ack == 0) { - format = SRSLTE_PUCCH_FORMAT_2; + format = SRSRAN_PUCCH_FORMAT_2; } // CQI + 1-bit ACK - else if (total_ack == 1 && SRSLTE_CP_ISNORM(cell->cp)) { - format = SRSLTE_PUCCH_FORMAT_2A; + else if (total_ack == 1 && SRSRAN_CP_ISNORM(cell->cp)) { + format = SRSRAN_PUCCH_FORMAT_2A; } // CQI + 2-bit ACK else if (total_ack == 2) { - format = SRSLTE_PUCCH_FORMAT_2B; + format = SRSRAN_PUCCH_FORMAT_2B; } // CQI + 1-bit ACK + extended cyclic prefix - else if (total_ack == 1 && SRSLTE_CP_ISEXT(cell->cp)) { - format = SRSLTE_PUCCH_FORMAT_2B; + else if (total_ack == 1 && SRSRAN_CP_ISEXT(cell->cp)) { + format = SRSRAN_PUCCH_FORMAT_2B; } } - if (format == SRSLTE_PUCCH_FORMAT_ERROR) { + if (format == SRSRAN_PUCCH_FORMAT_ERROR) { ERROR("Returned Error while selecting PUCCH format"); } return format; } -static int pucch_cs_resources(const srslte_pucch_cfg_t* cfg, - const srslte_uci_cfg_t* uci_cfg, - uint32_t n_pucch_i[SRSLTE_PUCCH_MAX_ALLOC]) +static int pucch_cs_resources(const srsran_pucch_cfg_t* cfg, + const srsran_uci_cfg_t* uci_cfg, + uint32_t n_pucch_i[SRSRAN_PUCCH_MAX_ALLOC]) { // Check inputs if (!cfg || !uci_cfg || !n_pucch_i) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } // Determine up to 4 PUCCH resources n_pucch_j associated with HARQ-ACK(j) int k = 0; - for (int i = 0; i < SRSLTE_PUCCH_CS_MAX_CARRIERS && k < SRSLTE_PUCCH_CS_MAX_ACK; i++) { + for (int i = 0; i < SRSRAN_PUCCH_CS_MAX_CARRIERS && k < SRSRAN_PUCCH_CS_MAX_ACK; i++) { if (uci_cfg->ack[i].grant_cc_idx == 0) { // - for a PDSCH transmission indicated by the detection of a corresponding PDCCH in subframe n − 4 on the primary // cell, or for a PDCCH indicating downlink SPS release (defined in subclause 9.2) in subframe n − 4 on the // primary cell, the PUCCH resource is n_pucch_i = n_cce + N_pucch_1, and for transmission mode that supports up // to two transport blocks, the PUCCH resource n_pucch_i+1 = n_cce + N_pucch_1 + 1 - for (uint32_t j = 0; j < uci_cfg->ack[i].nof_acks && k < SRSLTE_PUCCH_CS_MAX_ACK; j++) { + for (uint32_t j = 0; j < uci_cfg->ack[i].nof_acks && k < SRSRAN_PUCCH_CS_MAX_ACK; j++) { n_pucch_i[k++] = uci_cfg->ack[i].ncce[0] + cfg->N_pucch_1 + j; } } else if (i == 0) { // - for a PDSCH transmission on the primary cell where there is not a corresponding PDCCH detected in subframe // n − 4 , the value of n_pucch_i is determined according to higher layer configuration and Table 9.2-2. For // transmission mode that supports up to two transport blocks, the PUCCH resource n_pucch_i+1 = n_pucch_i + 1 - for (uint32_t j = 0; j < uci_cfg->ack[i].nof_acks && k < SRSLTE_PUCCH_CS_MAX_ACK; j++) { - n_pucch_i[k++] = cfg->n1_pucch_an_cs[uci_cfg->ack[i].tpc_for_pucch % SRSLTE_PUCCH_SIZE_AN_CS][0] + j; + for (uint32_t j = 0; j < uci_cfg->ack[i].nof_acks && k < SRSRAN_PUCCH_CS_MAX_ACK; j++) { + n_pucch_i[k++] = cfg->n1_pucch_an_cs[uci_cfg->ack[i].tpc_for_pucch % SRSRAN_PUCCH_SIZE_AN_CS][0] + j; } } else { // - for a PDSCH transmission indicated by the detection of a corresponding PDCCH in subframe n − 4 on the @@ -115,9 +115,9 @@ static int pucch_cs_resources(const srslte_pucch_cfg_t* cfg, // 10.1.2.2.1-2. For a UE configured for a transmission mode that supports up to two transport blocks a PUCCH // resource value in Table 10.1.2.2.1-2 maps to two PUCCH resources (n_pucch_i, n_pucch_i + 1), otherwise the // PUCCH resource value maps to a single PUCCH resource n_pucch_i. - for (uint32_t j = 0; j < uci_cfg->ack[i].nof_acks && k < SRSLTE_PUCCH_CS_MAX_ACK; j++) { + for (uint32_t j = 0; j < uci_cfg->ack[i].nof_acks && k < SRSRAN_PUCCH_CS_MAX_ACK; j++) { n_pucch_i[k++] = - cfg->n1_pucch_an_cs[uci_cfg->ack[i].tpc_for_pucch % SRSLTE_PUCCH_SIZE_AN_CS][j % SRSLTE_PUCCH_NOF_AN_CS]; + cfg->n1_pucch_an_cs[uci_cfg->ack[i].tpc_for_pucch % SRSRAN_PUCCH_SIZE_AN_CS][j % SRSRAN_PUCCH_NOF_AN_CS]; } } } @@ -129,28 +129,28 @@ static int pucch_cs_resources(const srslte_pucch_cfg_t* cfg, do { \ if (j == J && b[0] == B0 && b[1] == B1) { \ uint8_t pos[] = {__VA_ARGS__}; \ - for (uint32_t i = 0; i < sizeof(pos) && pos[i] < SRSLTE_PUCCH_CS_MAX_ACK; i++) { \ + for (uint32_t i = 0; i < sizeof(pos) && pos[i] < SRSRAN_PUCCH_CS_MAX_ACK; i++) { \ uci_value[pos[i]] = 1; \ } \ - ret = SRSLTE_SUCCESS; \ + ret = SRSRAN_SUCCESS; \ } \ } while (false) -static int puccch_cs_get_ack_a2(uint32_t j, const uint8_t b[2], uint8_t uci_value[SRSLTE_UCI_MAX_ACK_BITS]) +static int puccch_cs_get_ack_a2(uint32_t j, const uint8_t b[2], uint8_t uci_value[SRSRAN_UCI_MAX_ACK_BITS]) { - int ret = SRSLTE_ERROR; + int ret = SRSRAN_ERROR; PUCCH_CS_SET_ACK(1, 1, 1, 0, 1); PUCCH_CS_SET_ACK(0, 1, 1, 0); PUCCH_CS_SET_ACK(1, 0, 0, 1); - PUCCH_CS_SET_ACK(1, 0, 0, SRSLTE_PUCCH_CS_MAX_ACK); + PUCCH_CS_SET_ACK(1, 0, 0, SRSRAN_PUCCH_CS_MAX_ACK); return ret; } -static int puccch_cs_get_ack_a3(uint32_t j, const uint8_t b[2], uint8_t uci_value[SRSLTE_UCI_MAX_ACK_BITS]) +static int puccch_cs_get_ack_a3(uint32_t j, const uint8_t b[2], uint8_t uci_value[SRSRAN_UCI_MAX_ACK_BITS]) { - int ret = SRSLTE_ERROR; + int ret = SRSRAN_ERROR; PUCCH_CS_SET_ACK(1, 1, 1, 0, 1, 2); PUCCH_CS_SET_ACK(1, 1, 0, 0, 2); @@ -159,14 +159,14 @@ static int puccch_cs_get_ack_a3(uint32_t j, const uint8_t b[2], uint8_t uci_valu PUCCH_CS_SET_ACK(0, 1, 1, 0, 1); PUCCH_CS_SET_ACK(0, 1, 0, 0); PUCCH_CS_SET_ACK(0, 0, 1, 1); - PUCCH_CS_SET_ACK(1, 0, 0, SRSLTE_PUCCH_CS_MAX_ACK); + PUCCH_CS_SET_ACK(1, 0, 0, SRSRAN_PUCCH_CS_MAX_ACK); return ret; } -static int puccch_cs_get_ack_a4(uint32_t j, const uint8_t b[2], uint8_t uci_value[SRSLTE_UCI_MAX_ACK_BITS]) +static int puccch_cs_get_ack_a4(uint32_t j, const uint8_t b[2], uint8_t uci_value[SRSRAN_UCI_MAX_ACK_BITS]) { - int ret = SRSLTE_ERROR; + int ret = SRSRAN_ERROR; PUCCH_CS_SET_ACK(1, 1, 1, 0, 1, 2, 3); PUCCH_CS_SET_ACK(2, 0, 1, 0, 2, 3); @@ -183,24 +183,24 @@ static int puccch_cs_get_ack_a4(uint32_t j, const uint8_t b[2], uint8_t uci_valu PUCCH_CS_SET_ACK(0, 1, 1, 0, 1); PUCCH_CS_SET_ACK(0, 1, 0, 0); PUCCH_CS_SET_ACK(0, 0, 1, 1); - PUCCH_CS_SET_ACK(0, 0, 0, SRSLTE_PUCCH_CS_MAX_ACK); + PUCCH_CS_SET_ACK(0, 0, 0, SRSRAN_PUCCH_CS_MAX_ACK); return ret; } -int srslte_pucch_cs_get_ack(const srslte_pucch_cfg_t* cfg, - const srslte_uci_cfg_t* uci_cfg, +int srsran_pucch_cs_get_ack(const srsran_pucch_cfg_t* cfg, + const srsran_uci_cfg_t* uci_cfg, uint32_t j, const uint8_t b[2], - srslte_uci_value_t* uci_value) + srsran_uci_value_t* uci_value) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (cfg && uci_cfg && uci_value) { // Set bits to 0 by default - memset(uci_value->ack.ack_value, 0, SRSLTE_UCI_MAX_ACK_BITS); + memset(uci_value->ack.ack_value, 0, SRSRAN_UCI_MAX_ACK_BITS); - uint32_t nof_ack = srslte_uci_cfg_total_ack(uci_cfg); + uint32_t nof_ack = srsran_uci_cfg_total_ack(uci_cfg); switch (nof_ack) { case 2: // A = 2 @@ -217,19 +217,19 @@ int srslte_pucch_cs_get_ack(const srslte_pucch_cfg_t* cfg, default: // Unhandled case ERROR("Unexpected number of ACK (%d)", nof_ack); - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } } return ret; } -static int pucch_f3_resources(const srslte_pucch_cfg_t* cfg, const srslte_uci_cfg_t* uci_cfg, uint32_t* n_pucch_3) +static int pucch_f3_resources(const srsran_pucch_cfg_t* cfg, const srsran_uci_cfg_t* uci_cfg, uint32_t* n_pucch_3) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (cfg && uci_cfg && n_pucch_3) { - n_pucch_3[0] = cfg->n3_pucch_an_list[uci_cfg->ack[0].tpc_for_pucch % SRSLTE_PUCCH_SIZE_AN_CS]; + n_pucch_3[0] = cfg->n3_pucch_an_list[uci_cfg->ack[0].tpc_for_pucch % SRSRAN_PUCCH_SIZE_AN_CS]; ret = 1; } @@ -241,7 +241,7 @@ static uint32_t get_Np(uint32_t p, uint32_t nof_prb) if (p == 0) { return 0; } else { - return nof_prb * (SRSLTE_NRE * p - 4) / 36; + return nof_prb * (SRSRAN_NRE * p - 4) / 36; } } @@ -260,12 +260,12 @@ static uint32_t n_pucch_i_tdd(uint32_t ncce, uint32_t N_pucch_1, uint32_t nof_pr return 0; } -static int pucch_tdd_resources(const srslte_cell_t* cell, - const srslte_pucch_cfg_t* cfg, - const srslte_uci_cfg_t* uci_cfg, - uint32_t n_pucch_tdd[SRSLTE_PUCCH_MAX_ALLOC]) +static int pucch_tdd_resources(const srsran_cell_t* cell, + const srsran_pucch_cfg_t* cfg, + const srsran_uci_cfg_t* uci_cfg, + uint32_t n_pucch_tdd[SRSRAN_PUCCH_MAX_ALLOC]) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; for (uint32_t i = 0; i < uci_cfg->ack[0].tdd_ack_M; i++) { n_pucch_tdd[i] = @@ -275,42 +275,42 @@ static int pucch_tdd_resources(const srslte_cell_t* cell, return ret; } -int srslte_pucch_proc_get_resources(const srslte_cell_t* cell, - const srslte_pucch_cfg_t* cfg, - const srslte_uci_cfg_t* uci_cfg, - const srslte_uci_value_t* uci_value, +int srsran_pucch_proc_get_resources(const srsran_cell_t* cell, + const srsran_pucch_cfg_t* cfg, + const srsran_uci_cfg_t* uci_cfg, + const srsran_uci_value_t* uci_value, uint32_t* n_pucch_i) { if (!cfg || !cell || !uci_cfg || !n_pucch_i) { ERROR("pucch_resource_selection(): Invalid parameters"); - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } - uint32_t total_nof_ack = srslte_uci_cfg_total_ack(uci_cfg); + uint32_t total_nof_ack = srsran_uci_cfg_total_ack(uci_cfg); // Available scheduling request and PUCCH format is not PUCCH3 - if (pucch_proc_tx_sr(uci_cfg, uci_value) && cfg->format != SRSLTE_PUCCH_FORMAT_3) { + if (pucch_proc_tx_sr(uci_cfg, uci_value) && cfg->format != SRSRAN_PUCCH_FORMAT_3) { n_pucch_i[0] = cfg->n_pucch_sr; return 1; } // PUCCH formats 1, 1A and 1B (normal anb channel selection modes) - if (cfg->format < SRSLTE_PUCCH_FORMAT_2) { + if (cfg->format < SRSRAN_PUCCH_FORMAT_2) { if (cfg->sps_enabled) { n_pucch_i[0] = cfg->n_pucch_1[uci_cfg->ack[0].tpc_for_pucch % 4]; return 1; } - if (cell->frame_type == SRSLTE_TDD) { + if (cell->frame_type == SRSRAN_TDD) { return pucch_tdd_resources(cell, cfg, uci_cfg, n_pucch_i); } - if (cfg->ack_nack_feedback_mode == SRSLTE_PUCCH_ACK_NACK_FEEDBACK_MODE_CS) { + if (cfg->ack_nack_feedback_mode == SRSRAN_PUCCH_ACK_NACK_FEEDBACK_MODE_CS) { return pucch_cs_resources(cfg, uci_cfg, n_pucch_i); } - if (cfg->ack_nack_feedback_mode == SRSLTE_PUCCH_ACK_NACK_FEEDBACK_MODE_NORMAL || - (cfg->ack_nack_feedback_mode == SRSLTE_PUCCH_ACK_NACK_FEEDBACK_MODE_PUCCH3 && + if (cfg->ack_nack_feedback_mode == SRSRAN_PUCCH_ACK_NACK_FEEDBACK_MODE_NORMAL || + (cfg->ack_nack_feedback_mode == SRSRAN_PUCCH_ACK_NACK_FEEDBACK_MODE_PUCCH3 && total_nof_ack == uci_cfg->ack[0].nof_acks)) { // If normal or feedback mode PUCCH3 with only data in PCell n_pucch_i[0] = uci_cfg->ack[0].ncce[0] + cfg->N_pucch_1; @@ -318,12 +318,12 @@ int srslte_pucch_proc_get_resources(const srslte_cell_t* cell, } // Otherwise an error shall be prompt - ERROR("Unhandled PUCCH format mode %s", srslte_ack_nack_feedback_mode_string(cfg->ack_nack_feedback_mode)); - return SRSLTE_ERROR; + ERROR("Unhandled PUCCH format mode %s", srsran_ack_nack_feedback_mode_string(cfg->ack_nack_feedback_mode)); + return SRSRAN_ERROR; } // PUCCH format 3 - if (cfg->format == SRSLTE_PUCCH_FORMAT_3) { + if (cfg->format == SRSRAN_PUCCH_FORMAT_3) { return pucch_f3_resources(cfg, uci_cfg, n_pucch_i); } @@ -333,15 +333,15 @@ int srslte_pucch_proc_get_resources(const srslte_cell_t* cell, } // Selection of n_pucch for PUCCH Format 1a and 1b with channel selection for 1 and 2 CC -static uint32_t get_npucch_cs(const srslte_pucch_cfg_t* cfg, - const srslte_uci_cfg_t* uci_cfg, - const uint32_t n_pucch_i[SRSLTE_PUCCH_MAX_ALLOC], - uint8_t b[SRSLTE_UCI_MAX_ACK_BITS]) +static uint32_t get_npucch_cs(const srsran_pucch_cfg_t* cfg, + const srsran_uci_cfg_t* uci_cfg, + const uint32_t n_pucch_i[SRSRAN_PUCCH_MAX_ALLOC], + uint8_t b[SRSRAN_UCI_MAX_ACK_BITS]) { uint32_t n_pucch = 0; // Do resource selection and bit mapping according to tables 10.1.2.2.1-3, 10.1.2.2.1-4 and 10.1.2.2.1-5 - uint32_t nof_ack = srslte_uci_cfg_total_ack(uci_cfg); + uint32_t nof_ack = srsran_uci_cfg_total_ack(uci_cfg); switch (nof_ack) { case 1: // 1-bit is Format1A always @@ -421,7 +421,7 @@ static uint32_t get_npucch_cs(const srslte_pucch_cfg_t* cfg, } break; default: - ERROR("Too many (%d) ACK for this CS mode", srslte_uci_cfg_total_ack(uci_cfg)); + ERROR("Too many (%d) ACK for this CS mode", srsran_uci_cfg_total_ack(uci_cfg)); } return n_pucch; @@ -458,7 +458,7 @@ static void set_b01(uint8_t* b, uint8_t x) // n_pucch and b0b1 selection for TDD, tables 10.1-2, 10.1-3 and 10.1-4 static uint32_t -get_npucch_tdd(const uint32_t n_pucch[4], const srslte_uci_cfg_t* uci_cfg, uint8_t b[SRSLTE_UCI_MAX_ACK_BITS]) +get_npucch_tdd(const uint32_t n_pucch[4], const srsran_uci_cfg_t* uci_cfg, uint8_t b[SRSRAN_UCI_MAX_ACK_BITS]) { switch (uci_cfg->ack[0].nof_acks) { case 1: @@ -577,17 +577,17 @@ get_npucch_tdd(const uint32_t n_pucch[4], const srslte_uci_cfg_t* uci_cfg, uint8 return 0; } -uint32_t srslte_pucch_proc_get_npucch(const srslte_cell_t* cell, - const srslte_pucch_cfg_t* cfg, - const srslte_uci_cfg_t* uci_cfg, - const srslte_uci_value_t* uci_value, - uint8_t b[SRSLTE_UCI_MAX_ACK_BITS]) +uint32_t srsran_pucch_proc_get_npucch(const srsran_cell_t* cell, + const srsran_pucch_cfg_t* cfg, + const srsran_uci_cfg_t* uci_cfg, + const srsran_uci_value_t* uci_value, + uint8_t b[SRSRAN_UCI_MAX_ACK_BITS]) { - uint32_t n_pucch_i[SRSLTE_PUCCH_MAX_ALLOC] = {}; - int nof_resources = srslte_pucch_proc_get_resources(cell, cfg, uci_cfg, uci_value, n_pucch_i); + uint32_t n_pucch_i[SRSRAN_PUCCH_MAX_ALLOC] = {}; + int nof_resources = srsran_pucch_proc_get_resources(cell, cfg, uci_cfg, uci_value, n_pucch_i); // Copy original bits in b - memcpy(b, uci_value->ack.ack_value, SRSLTE_UCI_MAX_ACK_BITS); + memcpy(b, uci_value->ack.ack_value, SRSRAN_UCI_MAX_ACK_BITS); // If error occurred, return 0 if (nof_resources < 1) { @@ -600,12 +600,12 @@ uint32_t srslte_pucch_proc_get_npucch(const srslte_cell_t* cell, } // Select TDD resource - if (cell->frame_type == SRSLTE_TDD) { + if (cell->frame_type == SRSRAN_TDD) { return get_npucch_tdd(n_pucch_i, uci_cfg, b); } // Select Channel Selection resource - if (cfg->ack_nack_feedback_mode == SRSLTE_PUCCH_ACK_NACK_FEEDBACK_MODE_CS) { + if (cfg->ack_nack_feedback_mode == SRSRAN_PUCCH_ACK_NACK_FEEDBACK_MODE_CS) { return get_npucch_cs(cfg, uci_cfg, n_pucch_i, b); } diff --git a/lib/src/phy/phch/pusch.c b/lib/src/phy/phch/pusch.c index 8c142333a..67f20e5be 100644 --- a/lib/src/phy/phch/pusch.c +++ b/lib/src/phy/phch/pusch.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,7 +10,7 @@ * */ -#include "srslte/srslte.h" +#include "srsran/srsran.h" #include #include #include @@ -20,24 +20,24 @@ #include #include -#include "srslte/phy/ch_estimation/refsignal_ul.h" -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/dft/dft_precoding.h" -#include "srslte/phy/phch/pusch.h" -#include "srslte/phy/phch/pusch_cfg.h" -#include "srslte/phy/phch/uci.h" -#include "srslte/phy/utils/bit.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/ch_estimation/refsignal_ul.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/dft/dft_precoding.h" +#include "srsran/phy/phch/pusch.h" +#include "srsran/phy/phch/pusch_cfg.h" +#include "srsran/phy/phch/uci.h" +#include "srsran/phy/utils/bit.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" -#define MAX_PUSCH_RE(cp) (2 * SRSLTE_CP_NSYMB(cp) * 12) +#define MAX_PUSCH_RE(cp) (2 * SRSRAN_CP_NSYMB(cp) * 12) #define ACK_SNR_TH -1.0 /* Allocate/deallocate PUSCH RBs to the resource grid */ -static int pusch_cp(srslte_pusch_t* q, - srslte_pusch_grant_t* grant, +static int pusch_cp(srsran_pusch_t* q, + srsran_pusch_grant_t* grant, cf_t* input, cf_t* output, bool is_shortened, @@ -47,7 +47,7 @@ static int pusch_cp(srslte_pusch_t* q, cf_t* out_ptr = output; uint32_t L_ref = 3; - if (SRSLTE_CP_ISEXT(q->cell.cp)) { + if (SRSRAN_CP_ISEXT(q->cell.cp)) { L_ref = 2; } for (uint32_t slot = 0; slot < 2; slot++) { @@ -60,20 +60,20 @@ static int pusch_cp(srslte_pusch_t* q, grant->L_prb, grant->n_prb_tilde[slot], slot); - for (uint32_t l = 0; l < SRSLTE_CP_NSYMB(q->cell.cp) - N_srs; l++) { + for (uint32_t l = 0; l < SRSRAN_CP_NSYMB(q->cell.cp) - N_srs; l++) { if (l != L_ref) { - uint32_t idx = SRSLTE_RE_IDX( - q->cell.nof_prb, l + slot * SRSLTE_CP_NSYMB(q->cell.cp), grant->n_prb_tilde[slot] * SRSLTE_NRE); + uint32_t idx = SRSRAN_RE_IDX( + q->cell.nof_prb, l + slot * SRSRAN_CP_NSYMB(q->cell.cp), grant->n_prb_tilde[slot] * SRSRAN_NRE); if (advance_input) { out_ptr = &output[idx]; } else { in_ptr = &input[idx]; } - memcpy(out_ptr, in_ptr, grant->L_prb * SRSLTE_NRE * sizeof(cf_t)); + memcpy(out_ptr, in_ptr, grant->L_prb * SRSRAN_NRE * sizeof(cf_t)); if (advance_input) { - in_ptr += grant->L_prb * SRSLTE_NRE; + in_ptr += grant->L_prb * SRSRAN_NRE; } else { - out_ptr += grant->L_prb * SRSLTE_NRE; + out_ptr += grant->L_prb * SRSRAN_NRE; } } } @@ -85,98 +85,98 @@ static int pusch_cp(srslte_pusch_t* q, } } -static int pusch_put(srslte_pusch_t* q, srslte_pusch_grant_t* grant, cf_t* input, cf_t* output, bool is_shortened) +static int pusch_put(srsran_pusch_t* q, srsran_pusch_grant_t* grant, cf_t* input, cf_t* output, bool is_shortened) { return pusch_cp(q, grant, input, output, is_shortened, true); } -static int pusch_get(srslte_pusch_t* q, srslte_pusch_grant_t* grant, cf_t* input, cf_t* output, bool is_shortened) +static int pusch_get(srsran_pusch_t* q, srsran_pusch_grant_t* grant, cf_t* input, cf_t* output, bool is_shortened) { return pusch_cp(q, grant, input, output, is_shortened, false); } /** Initializes the PDCCH transmitter and receiver */ -static int pusch_init(srslte_pusch_t* q, uint32_t max_prb, bool is_ue) +static int pusch_init(srsran_pusch_t* q, uint32_t max_prb, bool is_ue) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL) { - bzero(q, sizeof(srslte_pusch_t)); - ret = SRSLTE_ERROR; - q->max_re = max_prb * MAX_PUSCH_RE(SRSLTE_CP_NORM); + bzero(q, sizeof(srsran_pusch_t)); + ret = SRSRAN_ERROR; + q->max_re = max_prb * MAX_PUSCH_RE(SRSRAN_CP_NORM); INFO("Init PUSCH: %d PRBs", max_prb); - for (srslte_mod_t i = 0; i < SRSLTE_MOD_NITEMS; i++) { - if (srslte_modem_table_lte(&q->mod[i], i)) { + for (srsran_mod_t i = 0; i < SRSRAN_MOD_NITEMS; i++) { + if (srsran_modem_table_lte(&q->mod[i], i)) { goto clean; } - srslte_modem_table_bytes(&q->mod[i]); + srsran_modem_table_bytes(&q->mod[i]); } q->is_ue = is_ue; - srslte_sch_init(&q->ul_sch); + srsran_sch_init(&q->ul_sch); - if (srslte_dft_precoding_init(&q->dft_precoding, max_prb, is_ue)) { + if (srsran_dft_precoding_init(&q->dft_precoding, max_prb, is_ue)) { ERROR("Error initiating DFT transform precoding"); goto clean; } // Allocate int16 for reception (LLRs). Buffer casted to uint8_t for transmission - q->q = srslte_vec_i16_malloc(q->max_re * srslte_mod_bits_x_symbol(SRSLTE_MOD_64QAM)); + q->q = srsran_vec_i16_malloc(q->max_re * srsran_mod_bits_x_symbol(SRSRAN_MOD_64QAM)); if (!q->q) { goto clean; } // Allocate int16 for reception (LLRs). Buffer casted to uint8_t for transmission - q->g = srslte_vec_i16_malloc(q->max_re * srslte_mod_bits_x_symbol(SRSLTE_MOD_64QAM)); + q->g = srsran_vec_i16_malloc(q->max_re * srsran_mod_bits_x_symbol(SRSRAN_MOD_64QAM)); if (!q->g) { goto clean; } - q->d = srslte_vec_cf_malloc(q->max_re); + q->d = srsran_vec_cf_malloc(q->max_re); if (!q->d) { goto clean; } // Allocate eNb specific buffers if (!q->is_ue) { - q->ce = srslte_vec_cf_malloc(q->max_re); + q->ce = srsran_vec_cf_malloc(q->max_re); if (!q->ce) { goto clean; } - q->evm_buffer = srslte_evm_buffer_alloc(srslte_ra_tbs_from_idx(SRSLTE_RA_NOF_TBS_IDX - 1, 6)); + q->evm_buffer = srsran_evm_buffer_alloc(srsran_ra_tbs_from_idx(SRSRAN_RA_NOF_TBS_IDX - 1, 6)); if (!q->evm_buffer) { ERROR("Allocating EVM buffer"); goto clean; } } - q->z = srslte_vec_cf_malloc(q->max_re); + q->z = srsran_vec_cf_malloc(q->max_re); if (!q->z) { goto clean; } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } clean: - if (ret == SRSLTE_ERROR) { - srslte_pusch_free(q); + if (ret == SRSRAN_ERROR) { + srsran_pusch_free(q); } return ret; } -int srslte_pusch_init_ue(srslte_pusch_t* q, uint32_t max_prb) +int srsran_pusch_init_ue(srsran_pusch_t* q, uint32_t max_prb) { return pusch_init(q, max_prb, true); } -int srslte_pusch_init_enb(srslte_pusch_t* q, uint32_t max_prb) +int srsran_pusch_init_enb(srsran_pusch_t* q, uint32_t max_prb) { return pusch_init(q, max_prb, false); } -void srslte_pusch_free(srslte_pusch_t* q) +void srsran_pusch_free(srsran_pusch_t* q) { int i; @@ -196,71 +196,71 @@ void srslte_pusch_free(srslte_pusch_t* q) free(q->z); } if (q->evm_buffer) { - srslte_evm_free(q->evm_buffer); + srsran_evm_free(q->evm_buffer); } - srslte_dft_precoding_free(&q->dft_precoding); + srsran_dft_precoding_free(&q->dft_precoding); - for (i = 0; i < SRSLTE_MOD_NITEMS; i++) { - srslte_modem_table_free(&q->mod[i]); + for (i = 0; i < SRSRAN_MOD_NITEMS; i++) { + srsran_modem_table_free(&q->mod[i]); } - srslte_sch_free(&q->ul_sch); + srsran_sch_free(&q->ul_sch); - bzero(q, sizeof(srslte_pusch_t)); + bzero(q, sizeof(srsran_pusch_t)); } -int srslte_pusch_set_cell(srslte_pusch_t* q, srslte_cell_t cell) +int srsran_pusch_set_cell(srsran_pusch_t* q, srsran_cell_t cell) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; - if (q != NULL && srslte_cell_isvalid(&cell)) { + if (q != NULL && srsran_cell_isvalid(&cell)) { // Resize EVM buffer, only for eNb if (!q->is_ue && q->evm_buffer) { - srslte_evm_buffer_resize(q->evm_buffer, srslte_ra_tbs_from_idx(SRSLTE_RA_NOF_TBS_IDX - 1, cell.nof_prb)); + srsran_evm_buffer_resize(q->evm_buffer, srsran_ra_tbs_from_idx(SRSRAN_RA_NOF_TBS_IDX - 1, cell.nof_prb)); } q->cell = cell; q->max_re = cell.nof_prb * MAX_PUSCH_RE(cell.cp); - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } -int srslte_pusch_assert_grant(const srslte_pusch_grant_t* grant) +int srsran_pusch_assert_grant(const srsran_pusch_grant_t* grant) { // Check for valid number of PRB - if (!srslte_dft_precoding_valid_prb(grant->L_prb)) { - return SRSLTE_ERROR_INVALID_INPUTS; + if (!srsran_dft_precoding_valid_prb(grant->L_prb)) { + return SRSRAN_ERROR_INVALID_INPUTS; } // Check RV limits, -1 is for RAR, 0-3 normal HARQ if (grant->tb.rv < -1 || grant->tb.rv > 3) { - return SRSLTE_ERROR_OUT_OF_BOUNDS; + return SRSRAN_ERROR_OUT_OF_BOUNDS; } // Check for positive TBS if (grant->tb.tbs < 0) { - return SRSLTE_ERROR_OUT_OF_BOUNDS; + return SRSRAN_ERROR_OUT_OF_BOUNDS; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } /** Converts the PUSCH data bits to symbols mapped to the slot ready for transmission */ -int srslte_pusch_encode(srslte_pusch_t* q, - srslte_ul_sf_cfg_t* sf, - srslte_pusch_cfg_t* cfg, - srslte_pusch_data_t* data, +int srsran_pusch_encode(srsran_pusch_t* q, + srsran_ul_sf_cfg_t* sf, + srsran_pusch_cfg_t* cfg, + srsran_pusch_data_t* data, cf_t* sf_symbols) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL && cfg != NULL) { /* Limit UL modulation if not supported by the UE or disabled by higher layers */ if (!cfg->enable_64qam) { - if (cfg->grant.tb.mod >= SRSLTE_MOD_64QAM) { - cfg->grant.tb.mod = SRSLTE_MOD_16QAM; - cfg->grant.tb.nof_bits = cfg->grant.nof_re * srslte_mod_bits_x_symbol(SRSLTE_MOD_16QAM); + if (cfg->grant.tb.mod >= SRSRAN_MOD_64QAM) { + cfg->grant.tb.mod = SRSRAN_MOD_16QAM; + cfg->grant.tb.nof_bits = cfg->grant.nof_re * srsran_mod_bits_x_symbol(SRSRAN_MOD_16QAM); } } @@ -269,17 +269,17 @@ int srslte_pusch_encode(srslte_pusch_t* q, cfg->grant.nof_re, q->max_re, q->cell.nof_prb); - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } - int err = srslte_pusch_assert_grant(&cfg->grant); - if (err != SRSLTE_SUCCESS) { + int err = srsran_pusch_assert_grant(&cfg->grant); + if (err != SRSRAN_SUCCESS) { return err; } INFO("Encoding PUSCH SF: %d, Mod %s, RNTI: %d, TBS: %d, NofRE: %d, NofSymbols=%d, NofBitsE: %d, rv_idx: %d", sf->tti % 10, - srslte_mod_string(cfg->grant.tb.mod), + srsran_mod_string(cfg->grant.tb.mod), cfg->rnti, cfg->grant.tb.tbs, cfg->grant.nof_re, @@ -288,18 +288,18 @@ int srslte_pusch_encode(srslte_pusch_t* q, cfg->grant.tb.rv); bzero(q->q, cfg->grant.tb.nof_bits); - if ((ret = srslte_ulsch_encode(&q->ul_sch, cfg, data->ptr, &data->uci, q->g, q->q)) < 0) { + if ((ret = srsran_ulsch_encode(&q->ul_sch, cfg, data->ptr, &data->uci, q->g, q->q)) < 0) { ERROR("Error encoding TB"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } uint32_t nof_ri_ack_bits = (uint32_t)ret; // Run scrambling - srslte_sequence_pusch_apply_pack((uint8_t*)q->q, + srsran_sequence_pusch_apply_pack((uint8_t*)q->q, (uint8_t*)q->q, cfg->rnti, - 2 * (sf->tti % SRSLTE_NOF_SF_X_FRAME), + 2 * (sf->tti % SRSRAN_NOF_SF_X_FRAME), q->cell.id, cfg->grant.tb.nof_bits); @@ -322,10 +322,10 @@ int srslte_pusch_encode(srslte_pusch_t* q, } // Bit mapping - srslte_mod_modulate_bytes(&q->mod[cfg->grant.tb.mod], (uint8_t*)q->q, q->d, cfg->grant.tb.nof_bits); + srsran_mod_modulate_bytes(&q->mod[cfg->grant.tb.mod], (uint8_t*)q->q, q->d, cfg->grant.tb.nof_bits); // DFT precoding - srslte_dft_precoding(&q->dft_precoding, q->d, q->z, cfg->grant.L_prb, cfg->grant.nof_symb); + srsran_dft_precoding(&q->dft_precoding, q->d, q->z, cfg->grant.L_prb, cfg->grant.nof_symb); // Mapping to resource elements uint32_t n = pusch_put(q, &cfg->grant, q->z, sf_symbols, sf->shortened); @@ -336,24 +336,24 @@ int srslte_pusch_encode(srslte_pusch_t* q, sf->tti, sf->shortened, cfg->grant.L_prb); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } /** Decodes the PUSCH from the received symbols */ -int srslte_pusch_decode(srslte_pusch_t* q, - srslte_ul_sf_cfg_t* sf, - srslte_pusch_cfg_t* cfg, - srslte_chest_ul_res_t* channel, +int srsran_pusch_decode(srsran_pusch_t* q, + srsran_ul_sf_cfg_t* sf, + srsran_pusch_cfg_t* cfg, + srsran_chest_ul_res_t* channel, cf_t* sf_symbols, - srslte_pusch_res_t* out) + srsran_pusch_res_t* out) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; uint32_t n; if (q != NULL && sf_symbols != NULL && out != NULL && cfg != NULL) { @@ -364,15 +364,15 @@ int srslte_pusch_decode(srslte_pusch_t* q, /* Limit UL modulation if not supported by the UE or disabled by higher layers */ if (!cfg->enable_64qam) { - if (cfg->grant.tb.mod >= SRSLTE_MOD_64QAM) { - cfg->grant.tb.mod = SRSLTE_MOD_16QAM; - cfg->grant.tb.nof_bits = cfg->grant.nof_re * srslte_mod_bits_x_symbol(SRSLTE_MOD_16QAM); + if (cfg->grant.tb.mod >= SRSRAN_MOD_64QAM) { + cfg->grant.tb.mod = SRSRAN_MOD_16QAM; + cfg->grant.tb.nof_bits = cfg->grant.nof_re * srsran_mod_bits_x_symbol(SRSRAN_MOD_16QAM); } } INFO("Decoding PUSCH SF: %d, Mod %s, NofBits: %d, NofRE: %d, NofSymbols=%d, NofBitsE: %d, rv_idx: %d", sf->tti % 10, - srslte_mod_string(cfg->grant.tb.mod), + srsran_mod_string(cfg->grant.tb.mod), cfg->grant.tb.tbs, cfg->grant.nof_re, cfg->grant.nof_symb, @@ -383,12 +383,12 @@ int srslte_pusch_decode(srslte_pusch_t* q, n = pusch_get(q, &cfg->grant, sf_symbols, q->d, sf->shortened); if (n != cfg->grant.nof_re) { ERROR("Error expecting %d symbols but got %d", cfg->grant.nof_re, n); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Measure Energy per Resource Element if (cfg->meas_epre_en) { - out->epre_dbfs = srslte_convert_power_to_dB(srslte_vec_avg_power_cf(q->d, n)); + out->epre_dbfs = srsran_convert_power_to_dB(srsran_vec_avg_power_cf(q->d, n)); } else { out->epre_dbfs = NAN; } @@ -397,27 +397,27 @@ int srslte_pusch_decode(srslte_pusch_t* q, n = pusch_get(q, &cfg->grant, channel->ce, q->ce, sf->shortened); if (n != cfg->grant.nof_re) { ERROR("Error expecting %d symbols but got %d", cfg->grant.nof_re, n); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Equalization - srslte_predecoding_single(q->d, q->ce, q->z, NULL, cfg->grant.nof_re, 1.0f, channel->noise_estimate); + srsran_predecoding_single(q->d, q->ce, q->z, NULL, cfg->grant.nof_re, 1.0f, channel->noise_estimate); // DFT predecoding - srslte_dft_precoding(&q->dft_precoding, q->z, q->d, cfg->grant.L_prb, cfg->grant.nof_symb); + srsran_dft_precoding(&q->dft_precoding, q->z, q->d, cfg->grant.L_prb, cfg->grant.nof_symb); // Soft demodulation if (q->llr_is_8bit) { - srslte_demod_soft_demodulate_b(cfg->grant.tb.mod, q->d, q->q, cfg->grant.nof_re); + srsran_demod_soft_demodulate_b(cfg->grant.tb.mod, q->d, q->q, cfg->grant.nof_re); } else { - srslte_demod_soft_demodulate_s(cfg->grant.tb.mod, q->d, q->q, cfg->grant.nof_re); + srsran_demod_soft_demodulate_s(cfg->grant.tb.mod, q->d, q->q, cfg->grant.nof_re); } if (cfg->meas_evm_en && q->evm_buffer) { if (q->llr_is_8bit) { - out->evm = srslte_evm_run_b(q->evm_buffer, &q->mod[cfg->grant.tb.mod], q->d, q->q, cfg->grant.tb.nof_bits); + out->evm = srsran_evm_run_b(q->evm_buffer, &q->mod[cfg->grant.tb.mod], q->d, q->q, cfg->grant.tb.nof_bits); } else { - out->evm = srslte_evm_run_s(q->evm_buffer, &q->mod[cfg->grant.tb.mod], q->d, q->q, cfg->grant.tb.nof_bits); + out->evm = srsran_evm_run_s(q->evm_buffer, &q->mod[cfg->grant.tb.mod], q->d, q->q, cfg->grant.tb.nof_bits); } } else { out->evm = NAN; @@ -425,31 +425,31 @@ int srslte_pusch_decode(srslte_pusch_t* q, // Descrambling if (q->llr_is_8bit) { - srslte_sequence_pusch_apply_c( - q->q, q->q, cfg->rnti, 2 * (sf->tti % SRSLTE_NOF_SF_X_FRAME), q->cell.id, cfg->grant.tb.nof_bits); + srsran_sequence_pusch_apply_c( + q->q, q->q, cfg->rnti, 2 * (sf->tti % SRSRAN_NOF_SF_X_FRAME), q->cell.id, cfg->grant.tb.nof_bits); } else { - srslte_sequence_pusch_apply_s( - q->q, q->q, cfg->rnti, 2 * (sf->tti % SRSLTE_NOF_SF_X_FRAME), q->cell.id, cfg->grant.tb.nof_bits); + srsran_sequence_pusch_apply_s( + q->q, q->q, cfg->rnti, 2 * (sf->tti % SRSRAN_NOF_SF_X_FRAME), q->cell.id, cfg->grant.tb.nof_bits); } // Generate packed sequence for UCI decoder uint8_t* c = (uint8_t*)q->z; // Reuse Z - srslte_sequence_pusch_gen_unpack( - c, cfg->rnti, 2 * (sf->tti % SRSLTE_NOF_SF_X_FRAME), q->cell.id, cfg->grant.tb.nof_bits); + srsran_sequence_pusch_gen_unpack( + c, cfg->rnti, 2 * (sf->tti % SRSRAN_NOF_SF_X_FRAME), q->cell.id, cfg->grant.tb.nof_bits); // Set max number of iterations - srslte_sch_set_max_noi(&q->ul_sch, cfg->max_nof_iterations); + srsran_sch_set_max_noi(&q->ul_sch, cfg->max_nof_iterations); // Decode - ret = srslte_ulsch_decode(&q->ul_sch, cfg, q->q, q->g, c, out->data, &out->uci); + ret = srsran_ulsch_decode(&q->ul_sch, cfg, q->q, q->g, c, out->data, &out->uci); out->crc = (ret == 0); // Save number of iterations out->avg_iterations_block = q->ul_sch.avg_iterations; // Save O_cqi for power control - cfg->last_O_cqi = srslte_cqi_size(&cfg->uci_cfg.cqi); - ret = SRSLTE_SUCCESS; + cfg->last_O_cqi = srsran_cqi_size(&cfg->uci_cfg.cqi); + ret = SRSRAN_SUCCESS; if (cfg->meas_time_en) { gettimeofday(&t[2], NULL); @@ -461,72 +461,72 @@ int srslte_pusch_decode(srslte_pusch_t* q, return ret; } -uint32_t srslte_pusch_grant_tx_info(srslte_pusch_grant_t* grant, - srslte_uci_cfg_t* uci_cfg, - srslte_uci_value_t* uci_data, +uint32_t srsran_pusch_grant_tx_info(srsran_pusch_grant_t* grant, + srsran_uci_cfg_t* uci_cfg, + srsran_uci_value_t* uci_data, char* str, uint32_t str_len) { - uint32_t len = srslte_ra_ul_info(grant, str, str_len); + uint32_t len = srsran_ra_ul_info(grant, str, str_len); if (uci_data) { - len += srslte_uci_data_info(uci_cfg, uci_data, &str[len], str_len - len); + len += srsran_uci_data_info(uci_cfg, uci_data, &str[len], str_len - len); } return len; } -uint32_t srslte_pusch_tx_info(srslte_pusch_cfg_t* cfg, srslte_uci_value_t* uci_data, char* str, uint32_t str_len) +uint32_t srsran_pusch_tx_info(srsran_pusch_cfg_t* cfg, srsran_uci_value_t* uci_data, char* str, uint32_t str_len) { - uint32_t len = srslte_print_check(str, str_len, 0, "rnti=0x%x", cfg->rnti); + uint32_t len = srsran_print_check(str, str_len, 0, "rnti=0x%x", cfg->rnti); - len += srslte_pusch_grant_tx_info(&cfg->grant, &cfg->uci_cfg, uci_data, &str[len], str_len - len); + len += srsran_pusch_grant_tx_info(&cfg->grant, &cfg->uci_cfg, uci_data, &str[len], str_len - len); if (cfg->meas_time_en) { - len = srslte_print_check(str, str_len, len, ", t=%d us", cfg->meas_time_value); + len = srsran_print_check(str, str_len, len, ", t=%d us", cfg->meas_time_value); } return len; } -uint32_t srslte_pusch_rx_info(srslte_pusch_cfg_t* cfg, - srslte_pusch_res_t* res, - srslte_chest_ul_res_t* chest_res, +uint32_t srsran_pusch_rx_info(srsran_pusch_cfg_t* cfg, + srsran_pusch_res_t* res, + srsran_chest_ul_res_t* chest_res, char* str, uint32_t str_len) { - uint32_t len = srslte_print_check(str, str_len, 0, "rnti=0x%x", cfg->rnti); + uint32_t len = srsran_print_check(str, str_len, 0, "rnti=0x%x", cfg->rnti); - len += srslte_ra_ul_info(&cfg->grant, &str[len], str_len); + len += srsran_ra_ul_info(&cfg->grant, &str[len], str_len); - len = srslte_print_check( + len = srsran_print_check( str, str_len, len, ", crc=%s, avg_iter=%.1f", res->crc ? "OK" : "KO", res->avg_iterations_block); - len += srslte_uci_data_info(&cfg->uci_cfg, &res->uci, &str[len], str_len - len); + len += srsran_uci_data_info(&cfg->uci_cfg, &res->uci, &str[len], str_len - len); - len = srslte_print_check(str, str_len, len, ", snr=%.1f dB", chest_res->snr_db); + len = srsran_print_check(str, str_len, len, ", snr=%.1f dB", chest_res->snr_db); // Append Energy Per Resource Element if (cfg->meas_epre_en) { - len = srslte_print_check(str, str_len, len, ", epre=%.1f dBfs", res->epre_dbfs); + len = srsran_print_check(str, str_len, len, ", epre=%.1f dBfs", res->epre_dbfs); } // Append Time Aligment information if available if (cfg->meas_ta_en) { - len = srslte_print_check(str, str_len, len, ", ta=%.1f us", chest_res->ta_us); + len = srsran_print_check(str, str_len, len, ", ta=%.1f us", chest_res->ta_us); } // Append CFO information if available if (!isnan(chest_res->cfo_hz)) { - len = srslte_print_check(str, str_len, len, ", cfo=%.1f hz", chest_res->cfo_hz); + len = srsran_print_check(str, str_len, len, ", cfo=%.1f hz", chest_res->cfo_hz); } // Append EVM measurement if available if (cfg->meas_evm_en) { - len = srslte_print_check(str, str_len, len, ", evm=%.1f %%", res->evm * 100); + len = srsran_print_check(str, str_len, len, ", evm=%.1f %%", res->evm * 100); } if (cfg->meas_time_en) { - len = srslte_print_check(str, str_len, len, ", t=%d us", cfg->meas_time_value); + len = srsran_print_check(str, str_len, len, ", t=%d us", cfg->meas_time_value); } return len; } diff --git a/lib/src/phy/phch/pusch_nr.c b/lib/src/phy/phch/pusch_nr.c index 2f887b95c..8e678b920 100644 --- a/lib/src/phy/phch/pusch_nr.c +++ b/lib/src/phy/phch/pusch_nr.c @@ -2,107 +2,107 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of * the distribution. * */ -#include "srslte/phy/phch/pusch_nr.h" -#include "srslte/phy/common/phy_common_nr.h" -#include "srslte/phy/mimo/layermap.h" -#include "srslte/phy/mimo/precoding.h" -#include "srslte/phy/modem/demod_soft.h" -#include "srslte/phy/phch/csi.h" -#include "srslte/phy/phch/ra_nr.h" -#include "srslte/phy/phch/uci_cfg.h" - -int pusch_nr_init_common(srslte_pusch_nr_t* q, const srslte_pusch_nr_args_t* args) +#include "srsran/phy/phch/pusch_nr.h" +#include "srsran/phy/common/phy_common_nr.h" +#include "srsran/phy/mimo/layermap.h" +#include "srsran/phy/mimo/precoding.h" +#include "srsran/phy/modem/demod_soft.h" +#include "srsran/phy/phch/csi.h" +#include "srsran/phy/phch/ra_nr.h" +#include "srsran/phy/phch/uci_cfg.h" + +int pusch_nr_init_common(srsran_pusch_nr_t* q, const srsran_pusch_nr_args_t* args) { - for (srslte_mod_t mod = SRSLTE_MOD_BPSK; mod < SRSLTE_MOD_NITEMS; mod++) { - if (srslte_modem_table_lte(&q->modem_tables[mod], mod) < SRSLTE_SUCCESS) { - ERROR("Error initialising modem table for %s", srslte_mod_string(mod)); - return SRSLTE_ERROR; + for (srsran_mod_t mod = SRSRAN_MOD_BPSK; mod < SRSRAN_MOD_NITEMS; mod++) { + if (srsran_modem_table_lte(&q->modem_tables[mod], mod) < SRSRAN_SUCCESS) { + ERROR("Error initialising modem table for %s", srsran_mod_string(mod)); + return SRSRAN_ERROR; } if (args->measure_evm) { - srslte_modem_table_bytes(&q->modem_tables[mod]); + srsran_modem_table_bytes(&q->modem_tables[mod]); } } - if (srslte_uci_nr_init(&q->uci, &args->uci) < SRSLTE_SUCCESS) { + if (srsran_uci_nr_init(&q->uci, &args->uci) < SRSRAN_SUCCESS) { ERROR("Initialising UCI"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - q->g_ulsch = srslte_vec_u8_malloc(SRSLTE_SLOT_MAX_NOF_BITS_NR); - q->g_ack = srslte_vec_u8_malloc(SRSLTE_SLOT_MAX_NOF_BITS_NR); - q->g_csi1 = srslte_vec_u8_malloc(SRSLTE_SLOT_MAX_NOF_BITS_NR); - q->g_csi2 = srslte_vec_u8_malloc(SRSLTE_SLOT_MAX_NOF_BITS_NR); + q->g_ulsch = srsran_vec_u8_malloc(SRSRAN_SLOT_MAX_NOF_BITS_NR); + q->g_ack = srsran_vec_u8_malloc(SRSRAN_SLOT_MAX_NOF_BITS_NR); + q->g_csi1 = srsran_vec_u8_malloc(SRSRAN_SLOT_MAX_NOF_BITS_NR); + q->g_csi2 = srsran_vec_u8_malloc(SRSRAN_SLOT_MAX_NOF_BITS_NR); if (q->g_ack == NULL || q->g_csi1 == NULL || q->g_csi2 == NULL || q->g_ulsch == NULL) { ERROR("Malloc"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - q->pos_ulsch = srslte_vec_u32_malloc(SRSLTE_SLOT_MAX_NOF_BITS_NR); - q->pos_ack = srslte_vec_u32_malloc(SRSLTE_SLOT_MAX_NOF_BITS_NR); - q->pos_csi1 = srslte_vec_u32_malloc(SRSLTE_SLOT_MAX_NOF_BITS_NR); - q->pos_csi2 = srslte_vec_u32_malloc(SRSLTE_SLOT_MAX_NOF_BITS_NR); + q->pos_ulsch = srsran_vec_u32_malloc(SRSRAN_SLOT_MAX_NOF_BITS_NR); + q->pos_ack = srsran_vec_u32_malloc(SRSRAN_SLOT_MAX_NOF_BITS_NR); + q->pos_csi1 = srsran_vec_u32_malloc(SRSRAN_SLOT_MAX_NOF_BITS_NR); + q->pos_csi2 = srsran_vec_u32_malloc(SRSRAN_SLOT_MAX_NOF_BITS_NR); if (q->pos_ack == NULL || q->pos_csi1 == NULL || q->pos_csi2 == NULL || q->pos_ulsch == NULL) { ERROR("Malloc"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_pusch_nr_init_ue(srslte_pusch_nr_t* q, const srslte_pusch_nr_args_t* args) +int srsran_pusch_nr_init_ue(srsran_pusch_nr_t* q, const srsran_pusch_nr_args_t* args) { if (q == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } - if (pusch_nr_init_common(q, args) < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (pusch_nr_init_common(q, args) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } - if (srslte_sch_nr_init_tx(&q->sch, &args->sch)) { + if (srsran_sch_nr_init_tx(&q->sch, &args->sch)) { ERROR("Initialising SCH"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_pusch_nr_init_gnb(srslte_pusch_nr_t* q, const srslte_pusch_nr_args_t* args) +int srsran_pusch_nr_init_gnb(srsran_pusch_nr_t* q, const srsran_pusch_nr_args_t* args) { if (q == NULL || args == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } - if (pusch_nr_init_common(q, args) < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (pusch_nr_init_common(q, args) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } - if (srslte_sch_nr_init_rx(&q->sch, &args->sch) < SRSLTE_SUCCESS) { + if (srsran_sch_nr_init_rx(&q->sch, &args->sch) < SRSRAN_SUCCESS) { ERROR("Initialising SCH"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (args->measure_evm) { - q->evm_buffer = srslte_evm_buffer_alloc(8); + q->evm_buffer = srsran_evm_buffer_alloc(8); if (q->evm_buffer == NULL) { ERROR("Initialising EVM"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } q->meas_time_en = args->measure_time; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_pusch_nr_set_carrier(srslte_pusch_nr_t* q, const srslte_carrier_nr_t* carrier) +int srsran_pusch_nr_set_carrier(srsran_pusch_nr_t* q, const srsran_carrier_nr_t* carrier) { // Set carrier q->carrier = *carrier; @@ -113,7 +113,7 @@ int srslte_pusch_nr_set_carrier(srslte_pusch_nr_t* q, const srslte_carrier_nr_t* q->max_prb = carrier->nof_prb; // Free current allocations - for (uint32_t i = 0; i < SRSLTE_MAX_LAYERS_NR; i++) { + for (uint32_t i = 0; i < SRSRAN_MAX_LAYERS_NR; i++) { if (q->x[i] != NULL) { free(q->x[i]); } @@ -121,10 +121,10 @@ int srslte_pusch_nr_set_carrier(srslte_pusch_nr_t* q, const srslte_carrier_nr_t* // Allocate for new sizes for (uint32_t i = 0; i < q->max_layers; i++) { - q->x[i] = srslte_vec_cf_malloc(SRSLTE_SLOT_LEN_RE_NR(q->max_prb)); + q->x[i] = srsran_vec_cf_malloc(SRSRAN_SLOT_LEN_RE_NR(q->max_prb)); if (q->x[i] == NULL) { ERROR("Malloc"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } } @@ -136,36 +136,36 @@ int srslte_pusch_nr_set_carrier(srslte_pusch_nr_t* q, const srslte_carrier_nr_t* for (uint32_t i = 0; i < max_cw; i++) { if (q->b[i] == NULL) { - q->b[i] = srslte_vec_u8_malloc(SRSLTE_SLOT_MAX_NOF_BITS_NR); + q->b[i] = srsran_vec_u8_malloc(SRSRAN_SLOT_MAX_NOF_BITS_NR); if (q->b[i] == NULL) { ERROR("Malloc"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } if (q->d[i] == NULL) { - q->d[i] = srslte_vec_cf_malloc(SRSLTE_SLOT_MAX_LEN_RE_NR); + q->d[i] = srsran_vec_cf_malloc(SRSRAN_SLOT_MAX_LEN_RE_NR); if (q->d[i] == NULL) { ERROR("Malloc"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } } } // Set carrier in SCH - if (srslte_sch_nr_set_carrier(&q->sch, carrier) < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (srsran_sch_nr_set_carrier(&q->sch, carrier) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } if (q->evm_buffer != NULL) { - srslte_evm_buffer_resize(q->evm_buffer, SRSLTE_SLOT_LEN_RE_NR(q->max_prb) * SRSLTE_MAX_QM); + srsran_evm_buffer_resize(q->evm_buffer, SRSRAN_SLOT_LEN_RE_NR(q->max_prb) * SRSRAN_MAX_QM); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -void srslte_pusch_nr_free(srslte_pusch_nr_t* q) +void srsran_pusch_nr_free(srsran_pusch_nr_t* q) { if (q == NULL) { return; @@ -197,7 +197,7 @@ void srslte_pusch_nr_free(srslte_pusch_nr_t* q) free(q->pos_csi2); } - for (uint32_t cw = 0; cw < SRSLTE_MAX_CODEWORDS; cw++) { + for (uint32_t cw = 0; cw < SRSRAN_MAX_CODEWORDS; cw++) { if (q->b[cw]) { free(q->b[cw]); } @@ -207,24 +207,24 @@ void srslte_pusch_nr_free(srslte_pusch_nr_t* q) } } - srslte_sch_nr_free(&q->sch); - srslte_uci_nr_free(&q->uci); + srsran_sch_nr_free(&q->sch); + srsran_uci_nr_free(&q->uci); - for (uint32_t i = 0; i < SRSLTE_MAX_LAYERS_NR; i++) { + for (uint32_t i = 0; i < SRSRAN_MAX_LAYERS_NR; i++) { if (q->x[i]) { free(q->x[i]); } } - for (srslte_mod_t mod = SRSLTE_MOD_BPSK; mod < SRSLTE_MOD_NITEMS; mod++) { - srslte_modem_table_free(&q->modem_tables[mod]); + for (srsran_mod_t mod = SRSRAN_MOD_BPSK; mod < SRSRAN_MOD_NITEMS; mod++) { + srsran_modem_table_free(&q->modem_tables[mod]); } if (q->evm_buffer != NULL) { - srslte_evm_free(q->evm_buffer); + srsran_evm_free(q->evm_buffer); } - SRSLTE_MEM_ZERO(q, srslte_pusch_nr_t, 1); + SRSRAN_MEM_ZERO(q, srsran_pusch_nr_t, 1); } /** @@ -234,12 +234,12 @@ void srslte_pusch_nr_free(srslte_pusch_nr_t* q) * @param count number of resource elements to copy * @param put Direction, symbols are copied into sf_symbols if put is true, otherwise sf_symbols are copied into symbols */ -static void srslte_pusch_re_cp(cf_t* sf_symbols, cf_t* symbols, uint32_t count, bool put) +static void srsran_pusch_re_cp(cf_t* sf_symbols, cf_t* symbols, uint32_t count, bool put) { if (put) { - srslte_vec_cf_copy(sf_symbols, symbols, count); + srsran_vec_cf_copy(sf_symbols, symbols, count); } else { - srslte_vec_cf_copy(symbols, sf_symbols, count); + srsran_vec_cf_copy(symbols, sf_symbols, count); } } @@ -255,8 +255,8 @@ static void srslte_pusch_re_cp(cf_t* sf_symbols, cf_t* symbols, uint32_t count, * - 1, data is mapped in RE marked as 2 * - Otherwise, no data is mapped in this symbol */ -static uint32_t srslte_pusch_nr_cp_dmrs_type1(const srslte_pusch_nr_t* q, - const srslte_sch_grant_nr_t* grant, +static uint32_t srsran_pusch_nr_cp_dmrs_type1(const srsran_pusch_nr_t* q, + const srsran_sch_grant_nr_t* grant, cf_t* symbols, cf_t* sf_symbols, bool put) @@ -270,11 +270,11 @@ static uint32_t srslte_pusch_nr_cp_dmrs_type1(const srslte_pusch_nr_t* q, for (uint32_t i = 0; i < q->carrier.nof_prb; i++) { if (grant->prb_idx[i]) { - for (uint32_t j = 0; j < SRSLTE_NRE; j += 2) { + for (uint32_t j = 0; j < SRSRAN_NRE; j += 2) { if (put) { - sf_symbols[i * SRSLTE_NRE + delta + j + 1] = symbols[count++]; + sf_symbols[i * SRSRAN_NRE + delta + j + 1] = symbols[count++]; } else { - symbols[count++] = sf_symbols[i * SRSLTE_NRE + delta + j + 1]; + symbols[count++] = sf_symbols[i * SRSRAN_NRE + delta + j + 1]; } } } @@ -296,8 +296,8 @@ static uint32_t srslte_pusch_nr_cp_dmrs_type1(const srslte_pusch_nr_t* q, * - 2, data is mapped in RE marked as 3 * - otherwise, no data is mapped in this symbol */ -static uint32_t srslte_pusch_nr_cp_dmrs_type2(const srslte_pusch_nr_t* q, - const srslte_sch_grant_nr_t* grant, +static uint32_t srsran_pusch_nr_cp_dmrs_type2(const srsran_pusch_nr_t* q, + const srsran_sch_grant_nr_t* grant, cf_t* symbols, cf_t* sf_symbols, bool put) @@ -314,11 +314,11 @@ static uint32_t srslte_pusch_nr_cp_dmrs_type2(const srslte_pusch_nr_t* q, for (uint32_t i = 0; i < q->carrier.nof_prb; i++) { if (grant->prb_idx[i]) { // Copy RE between pilot pairs - srslte_pusch_re_cp(&sf_symbols[i * SRSLTE_NRE + re_offset], &symbols[count], re_count, put); + srsran_pusch_re_cp(&sf_symbols[i * SRSRAN_NRE + re_offset], &symbols[count], re_count, put); count += re_count; // Copy RE after second pilot - srslte_pusch_re_cp(&sf_symbols[(i + 1) * SRSLTE_NRE - re_count], &symbols[count], re_count, put); + srsran_pusch_re_cp(&sf_symbols[(i + 1) * SRSRAN_NRE - re_count], &symbols[count], re_count, put); count += re_count; } } @@ -326,31 +326,31 @@ static uint32_t srslte_pusch_nr_cp_dmrs_type2(const srslte_pusch_nr_t* q, return count; } -static uint32_t srslte_pusch_nr_cp_dmrs(const srslte_pusch_nr_t* q, - const srslte_sch_cfg_nr_t* cfg, - const srslte_sch_grant_nr_t* grant, +static uint32_t srsran_pusch_nr_cp_dmrs(const srsran_pusch_nr_t* q, + const srsran_sch_cfg_nr_t* cfg, + const srsran_sch_grant_nr_t* grant, cf_t* symbols, cf_t* sf_symbols, bool put) { uint32_t count = 0; - const srslte_dmrs_sch_cfg_t* dmrs_cfg = &cfg->dmrs; + const srsran_dmrs_sch_cfg_t* dmrs_cfg = &cfg->dmrs; switch (dmrs_cfg->type) { - case srslte_dmrs_sch_type_1: - count = srslte_pusch_nr_cp_dmrs_type1(q, grant, symbols, sf_symbols, put); + case srsran_dmrs_sch_type_1: + count = srsran_pusch_nr_cp_dmrs_type1(q, grant, symbols, sf_symbols, put); break; - case srslte_dmrs_sch_type_2: - count = srslte_pusch_nr_cp_dmrs_type2(q, grant, symbols, sf_symbols, put); + case srsran_dmrs_sch_type_2: + count = srsran_pusch_nr_cp_dmrs_type2(q, grant, symbols, sf_symbols, put); break; } return count; } -static uint32_t srslte_pusch_nr_cp_clean(const srslte_pusch_nr_t* q, - const srslte_sch_grant_nr_t* grant, +static uint32_t srsran_pusch_nr_cp_clean(const srsran_pusch_nr_t* q, + const srsran_sch_grant_nr_t* grant, cf_t* symbols, cf_t* sf_symbols, bool put) @@ -363,15 +363,15 @@ static uint32_t srslte_pusch_nr_cp_clean(const srslte_pusch_nr_t* q, if (grant->prb_idx[i]) { // If fist continuous block, save start if (length == 0) { - start = i * SRSLTE_NRE; + start = i * SRSRAN_NRE; } - length += SRSLTE_NRE; + length += SRSRAN_NRE; } else { // Consecutive block is finished if (put) { - srslte_vec_cf_copy(&sf_symbols[start], &symbols[count], length); + srsran_vec_cf_copy(&sf_symbols[start], &symbols[count], length); } else { - srslte_vec_cf_copy(&symbols[count], &sf_symbols[start], length); + srsran_vec_cf_copy(&symbols[count], &sf_symbols[start], length); } // Increase RE count @@ -385,9 +385,9 @@ static uint32_t srslte_pusch_nr_cp_clean(const srslte_pusch_nr_t* q, // Copy last contiguous block if (length > 0) { if (put) { - srslte_vec_cf_copy(&sf_symbols[start], &symbols[count], length); + srsran_vec_cf_copy(&sf_symbols[start], &symbols[count], length); } else { - srslte_vec_cf_copy(&symbols[count], &sf_symbols[start], length); + srsran_vec_cf_copy(&symbols[count], &sf_symbols[start], length); } count += length; } @@ -395,26 +395,26 @@ static uint32_t srslte_pusch_nr_cp_clean(const srslte_pusch_nr_t* q, return count; } -static int srslte_pusch_nr_cp(const srslte_pusch_nr_t* q, - const srslte_sch_cfg_nr_t* cfg, - const srslte_sch_grant_nr_t* grant, +static int srsran_pusch_nr_cp(const srsran_pusch_nr_t* q, + const srsran_sch_cfg_nr_t* cfg, + const srsran_sch_grant_nr_t* grant, cf_t* symbols, cf_t* sf_symbols, bool put) { uint32_t count = 0; - uint32_t dmrs_l_idx[SRSLTE_DMRS_SCH_MAX_SYMBOLS] = {}; + uint32_t dmrs_l_idx[SRSRAN_DMRS_SCH_MAX_SYMBOLS] = {}; uint32_t dmrs_l_count = 0; // Get symbol indexes carrying DMRS - int32_t nof_dmrs_symbols = srslte_dmrs_sch_get_symbols_idx(&cfg->dmrs, grant, dmrs_l_idx); - if (nof_dmrs_symbols < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + int32_t nof_dmrs_symbols = srsran_dmrs_sch_get_symbols_idx(&cfg->dmrs, grant, dmrs_l_idx); + if (nof_dmrs_symbols < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } - if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_DEBUG && !handler_registered) { + if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_DEBUG && !handler_registered) { DEBUG("dmrs_l_idx="); - srslte_vec_fprint_i(stdout, (int32_t*)dmrs_l_idx, nof_dmrs_symbols); + srsran_vec_fprint_i(stdout, (int32_t*)dmrs_l_idx, nof_dmrs_symbols); } for (uint32_t l = grant->S; l < grant->S + grant->L; l++) { @@ -426,40 +426,40 @@ static int srslte_pusch_nr_cp(const srslte_pusch_nr_t* q, } if (l == dmrs_l_idx[dmrs_l_count]) { - count += srslte_pusch_nr_cp_dmrs( - q, cfg, grant, &symbols[count], &sf_symbols[l * q->carrier.nof_prb * SRSLTE_NRE], put); + count += srsran_pusch_nr_cp_dmrs( + q, cfg, grant, &symbols[count], &sf_symbols[l * q->carrier.nof_prb * SRSRAN_NRE], put); } else { count += - srslte_pusch_nr_cp_clean(q, grant, &symbols[count], &sf_symbols[l * q->carrier.nof_prb * SRSLTE_NRE], put); + srsran_pusch_nr_cp_clean(q, grant, &symbols[count], &sf_symbols[l * q->carrier.nof_prb * SRSRAN_NRE], put); } } return count; } -static int srslte_pusch_nr_put(const srslte_pusch_nr_t* q, - const srslte_sch_cfg_nr_t* cfg, - const srslte_sch_grant_nr_t* grant, +static int srsran_pusch_nr_put(const srsran_pusch_nr_t* q, + const srsran_sch_cfg_nr_t* cfg, + const srsran_sch_grant_nr_t* grant, cf_t* symbols, cf_t* sf_symbols) { - return srslte_pusch_nr_cp(q, cfg, grant, symbols, sf_symbols, true); + return srsran_pusch_nr_cp(q, cfg, grant, symbols, sf_symbols, true); } -static int srslte_pusch_nr_get(const srslte_pusch_nr_t* q, - const srslte_sch_cfg_nr_t* cfg, - const srslte_sch_grant_nr_t* grant, +static int srsran_pusch_nr_get(const srsran_pusch_nr_t* q, + const srsran_sch_cfg_nr_t* cfg, + const srsran_sch_grant_nr_t* grant, cf_t* symbols, cf_t* sf_symbols) { - return srslte_pusch_nr_cp(q, cfg, grant, symbols, sf_symbols, false); + return srsran_pusch_nr_cp(q, cfg, grant, symbols, sf_symbols, false); } static uint32_t -pusch_nr_cinit(const srslte_carrier_nr_t* carrier, const srslte_sch_cfg_nr_t* cfg, uint16_t rnti, uint32_t cw_idx) +pusch_nr_cinit(const srsran_carrier_nr_t* carrier, const srsran_sch_cfg_nr_t* cfg, uint16_t rnti, uint32_t cw_idx) { uint32_t n_id = carrier->id; - if (cfg->scrambling_id_present && SRSLTE_RNTI_ISUSER(rnti)) { + if (cfg->scrambling_id_present && SRSRAN_RNTI_ISUSER(rnti)) { n_id = cfg->scambling_id; } uint32_t cinit = (((uint32_t)rnti) << 15U) + (cw_idx << 14U) + n_id; @@ -469,25 +469,25 @@ pusch_nr_cinit(const srslte_carrier_nr_t* carrier, const srslte_sch_cfg_nr_t* cf return cinit; } -static inline int pusch_nr_fill_uci_cfg(srslte_pusch_nr_t* q, const srslte_sch_cfg_nr_t* cfg) +static inline int pusch_nr_fill_uci_cfg(srsran_pusch_nr_t* q, const srsran_sch_cfg_nr_t* cfg) { if (cfg->grant.nof_prb == 0) { ERROR("Invalid number of PRB (%d)", cfg->grant.nof_prb); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Initially, copy all fields q->uci_cfg = cfg->uci; // Reset UCI PUSCH configuration - SRSLTE_MEM_ZERO(&q->uci_cfg.pusch, srslte_uci_nr_pusch_cfg_t, 1); + SRSRAN_MEM_ZERO(&q->uci_cfg.pusch, srsran_uci_nr_pusch_cfg_t, 1); // Get DMRS symbol indexes uint32_t nof_dmrs_l = 0; - uint32_t dmrs_l[SRSLTE_DMRS_SCH_MAX_SYMBOLS] = {}; - int n = srslte_dmrs_sch_get_symbols_idx(&cfg->dmrs, &cfg->grant, dmrs_l); - if (n < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + uint32_t dmrs_l[SRSRAN_DMRS_SCH_MAX_SYMBOLS] = {}; + int n = srsran_dmrs_sch_get_symbols_idx(&cfg->dmrs, &cfg->grant, dmrs_l); + if (n < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } nof_dmrs_l = (uint32_t)n; @@ -523,10 +523,10 @@ static inline int pusch_nr_fill_uci_cfg(srslte_pusch_nr_t* q, const srslte_sch_c } // Number of DMRS per PRB - uint32_t n_sc_dmrs = SRSLTE_DMRS_SCH_SC(cfg->grant.nof_dmrs_cdm_groups_without_data, cfg->dmrs.type); + uint32_t n_sc_dmrs = SRSRAN_DMRS_SCH_SC(cfg->grant.nof_dmrs_cdm_groups_without_data, cfg->dmrs.type); // Set UCI RE number of candidates per OFDM symbol according to TS 38.312 6.3.2.4.2.1 - for (uint32_t l = 0, dmrs_l_idx = 0; l < SRSLTE_NSYMB_PER_SLOT_NR; l++) { + for (uint32_t l = 0, dmrs_l_idx = 0; l < SRSRAN_NSYMB_PER_SLOT_NR; l++) { // Skip if OFDM symbol is outside of the PUSCH transmission if (l < cfg->grant.S || l >= (cfg->grant.S + cfg->grant.L)) { q->uci_cfg.pusch.M_pusch_sc[l] = 0; @@ -537,7 +537,7 @@ static inline int pusch_nr_fill_uci_cfg(srslte_pusch_nr_t* q, const srslte_sch_c // OFDM symbol carries DMRS if (l == dmrs_l[dmrs_l_idx]) { // Calculate PUSCH RE candidates - q->uci_cfg.pusch.M_pusch_sc[l] = cfg->grant.nof_prb * (SRSLTE_NRE - n_sc_dmrs); + q->uci_cfg.pusch.M_pusch_sc[l] = cfg->grant.nof_prb * (SRSRAN_NRE - n_sc_dmrs); // The Number of RE candidates for UCI are 0 q->uci_cfg.pusch.M_uci_sc[l] = 0; @@ -553,17 +553,17 @@ static inline int pusch_nr_fill_uci_cfg(srslte_pusch_nr_t* q, const srslte_sch_c uint32_t M_ptrs_sc = 0; // Not implemented yet // Number of RE given by the grant - q->uci_cfg.pusch.M_pusch_sc[l] = cfg->grant.nof_prb * SRSLTE_NRE; + q->uci_cfg.pusch.M_pusch_sc[l] = cfg->grant.nof_prb * SRSRAN_NRE; // Calculate the number of UCI candidates q->uci_cfg.pusch.M_uci_sc[l] = q->uci_cfg.pusch.M_pusch_sc[l] - M_ptrs_sc; } // Generate SCH Transport block information - srslte_sch_nr_tb_info_t sch_tb_info = {}; - if (srslte_sch_nr_fill_tb_info(&q->carrier, &cfg->sch_cfg, &cfg->grant.tb[0], &sch_tb_info) < SRSLTE_SUCCESS) { + srsran_sch_nr_tb_info_t sch_tb_info = {}; + if (srsran_sch_nr_fill_tb_info(&q->carrier, &cfg->sch_cfg, &cfg->grant.tb[0], &sch_tb_info) < SRSRAN_SUCCESS) { ERROR("Generating TB info"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Calculate the sum of codeblock sizes @@ -581,18 +581,18 @@ static inline int pusch_nr_fill_uci_cfg(srslte_pusch_nr_t* q, const srslte_sch_c q->uci_cfg.pusch.beta_csi1_offset = cfg->beta_csi_part1_offset; q->uci_cfg.pusch.nof_re = cfg->grant.tb[0].nof_re; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Implements TS 38.212 6.2.7 Data and control multiplexing (for NR-PUSCH) -static int pusch_nr_gen_mux_uci(srslte_pusch_nr_t* q, const srslte_uci_cfg_nr_t* cfg) +static int pusch_nr_gen_mux_uci(srsran_pusch_nr_t* q, const srsran_uci_cfg_nr_t* cfg) { // Decide whether UCI shall be multiplexed q->uci_mux = (q->G_ack > 0 || q->G_csi1 > 0 || q->G_csi2 > 0); // Check if UCI multiplexing is NOT required if (!q->uci_mux) { - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Bit positions @@ -613,14 +613,14 @@ static int pusch_nr_gen_mux_uci(srslte_pusch_nr_t* q, const srslte_uci_cfg_nr_t* // Other... uint32_t Nl = cfg->pusch.nof_layers; - uint32_t Qm = srslte_mod_bits_x_symbol(cfg->pusch.modulation); + uint32_t Qm = srsran_mod_bits_x_symbol(cfg->pusch.modulation); // if the number of HARQ-ACK information bits to be transmitted on PUSCH is 0, 1 or 2 bits uint32_t G_ack_rvd = 0; if (cfg->o_ack <= 2) { // the number of reserved resource elements for potential HARQ-ACK transmission is calculated according to Clause // 6.3.2.4.2.1, by setting O_ACK = 2 ; - G_ack_rvd = srslte_uci_nr_pusch_ack_nof_bits(&q->uci_cfg.pusch, 2); + G_ack_rvd = srsran_uci_nr_pusch_ack_nof_bits(&q->uci_cfg.pusch, 2); // Disable non reserved HARQ-ACK bits G_ack = 0; @@ -633,7 +633,7 @@ static int pusch_nr_gen_mux_uci(srslte_pusch_nr_t* q, const srslte_uci_cfg_nr_t* uint32_t m_ulsch_count = 0; uint32_t m_all_count = 0; - for (uint32_t l = 0; l < SRSLTE_NSYMB_PER_SLOT_NR; l++) { + for (uint32_t l = 0; l < SRSRAN_NSYMB_PER_SLOT_NR; l++) { // Skip if symbol has potential for data if (cfg->pusch.M_pusch_sc[l] == 0) { continue; @@ -660,7 +660,7 @@ static int pusch_nr_gen_mux_uci(srslte_pusch_nr_t* q, const srslte_uci_cfg_nr_t* ack_m_re_count = M_ulsch_sc; if (G_ack_rvd - m_ack_count < M_uci_sc * Nl * Qm) { ack_d = (M_uci_sc * Nl * Qm) / (G_ack_rvd - m_ack_count); - ack_m_re_count = SRSLTE_CEIL(G_ack_rvd - m_ack_count, Nl * Qm); + ack_m_re_count = SRSRAN_CEIL(G_ack_rvd - m_ack_count, Nl * Qm); } M_uci_rvd = ack_m_re_count; } else if (m_ack_count < G_ack) { @@ -668,7 +668,7 @@ static int pusch_nr_gen_mux_uci(srslte_pusch_nr_t* q, const srslte_uci_cfg_nr_t* ack_m_re_count = M_ulsch_sc; if (G_ack - m_ack_count < M_uci_sc * Nl * Qm) { ack_d = (M_uci_sc * Nl * Qm) / (G_ack - m_ack_count); - ack_m_re_count = SRSLTE_CEIL(G_ack - m_ack_count, Nl * Qm); + ack_m_re_count = SRSRAN_CEIL(G_ack - m_ack_count, Nl * Qm); } M_uci_sc -= ack_m_re_count; } @@ -682,7 +682,7 @@ static int pusch_nr_gen_mux_uci(srslte_pusch_nr_t* q, const srslte_uci_cfg_nr_t* csi1_m_re_count = M_uci_sc - M_uci_rvd; if (G_csi1 - m_csi1_count < (M_uci_sc - M_uci_rvd) * Nl * Qm) { csi1_d = ((M_uci_sc - M_uci_rvd) * Nl * Qm) / (G_csi1 - m_csi1_count); - csi1_m_re_count = SRSLTE_CEIL(G_csi1 - m_csi1_count, Nl * Qm); + csi1_m_re_count = SRSRAN_CEIL(G_csi1 - m_csi1_count, Nl * Qm); } M_uci_sc -= csi1_m_re_count; } @@ -695,7 +695,7 @@ static int pusch_nr_gen_mux_uci(srslte_pusch_nr_t* q, const srslte_uci_cfg_nr_t* csi2_m_re_count = M_uci_sc - M_uci_rvd; if (G_csi2 - m_csi2_count < (M_uci_sc - M_uci_rvd) * Nl * Qm) { csi2_d = ((M_uci_sc - M_uci_rvd) * Nl * Qm) / (G_csi2 - m_csi2_count); - csi2_m_re_count = SRSLTE_CEIL(G_csi2 - m_csi2_count, Nl * Qm); + csi2_m_re_count = SRSRAN_CEIL(G_csi2 - m_csi2_count, Nl * Qm); } M_uci_sc -= csi2_m_re_count; } @@ -789,65 +789,65 @@ static int pusch_nr_gen_mux_uci(srslte_pusch_nr_t* q, const srslte_uci_cfg_nr_t* } // Print debug information if configured for ity - if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_DEBUG && !handler_registered) { + if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_DEBUG && !handler_registered) { if (m_ulsch_count != 0) { DEBUG("UL-SCH bit positions:"); - srslte_vec_fprint_i(stdout, (int*)pos_ulsch, m_ulsch_count); + srsran_vec_fprint_i(stdout, (int*)pos_ulsch, m_ulsch_count); } if (m_ack_count != 0 && cfg->o_ack > 0) { DEBUG("HARQ-ACK bit positions [%d]:", m_ack_count); - srslte_vec_fprint_i(stdout, (int*)pos_ack, m_ack_count); + srsran_vec_fprint_i(stdout, (int*)pos_ack, m_ack_count); } if (m_csi1_count != 0) { DEBUG("CSI part 1 bit positions [%d]:", m_csi1_count); - srslte_vec_fprint_i(stdout, (int*)pos_csi1, m_csi1_count); + srsran_vec_fprint_i(stdout, (int*)pos_csi1, m_csi1_count); } if (m_csi2_count != 0) { DEBUG("CSI part 2 bit positions [%d]:", m_csi2_count); - srslte_vec_fprint_i(stdout, (int*)pos_csi2, m_csi2_count); + srsran_vec_fprint_i(stdout, (int*)pos_csi2, m_csi2_count); } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -static inline int pusch_nr_encode_codeword(srslte_pusch_nr_t* q, - const srslte_sch_cfg_nr_t* cfg, - const srslte_sch_tb_t* tb, +static inline int pusch_nr_encode_codeword(srsran_pusch_nr_t* q, + const srsran_sch_cfg_nr_t* cfg, + const srsran_sch_tb_t* tb, const uint8_t* data, - const srslte_uci_value_nr_t* uci, + const srsran_uci_value_nr_t* uci, uint16_t rnti) { // Early return if TB is not enabled if (!tb->enabled) { - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Check codeword index if (tb->cw_idx >= q->max_cw) { ERROR("Unsupported codeword index %d", tb->cw_idx); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Check modulation - if (tb->mod >= SRSLTE_MOD_NITEMS) { - ERROR("Invalid modulation %s", srslte_mod_string(tb->mod)); - return SRSLTE_ERROR_OUT_OF_BOUNDS; + if (tb->mod >= SRSRAN_MOD_NITEMS) { + ERROR("Invalid modulation %s", srsran_mod_string(tb->mod)); + return SRSRAN_ERROR_OUT_OF_BOUNDS; } // Encode HARQ-ACK bits - int E_uci_ack = srslte_uci_nr_encode_pusch_ack(&q->uci, &q->uci_cfg, uci, q->g_ack); - if (E_uci_ack < SRSLTE_SUCCESS) { + int E_uci_ack = srsran_uci_nr_encode_pusch_ack(&q->uci, &q->uci_cfg, uci, q->g_ack); + if (E_uci_ack < SRSRAN_SUCCESS) { ERROR("Error encoding HARQ-ACK bits"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } q->G_ack = (uint32_t)E_uci_ack; // Encode CSI part 1 - int E_uci_csi1 = srslte_uci_nr_encode_pusch_csi1(&q->uci, &q->uci_cfg, uci, q->g_csi1); - if (E_uci_csi1 < SRSLTE_SUCCESS) { + int E_uci_csi1 = srsran_uci_nr_encode_pusch_csi1(&q->uci, &q->uci_cfg, uci, q->g_csi1); + if (E_uci_csi1 < SRSRAN_SUCCESS) { ERROR("Error encoding HARQ-ACK bits"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } q->G_csi1 = (uint32_t)E_uci_csi1; @@ -856,15 +856,15 @@ static inline int pusch_nr_encode_codeword(srslte_pusch_nr_t* q, q->G_csi2 = 0; // Generate PUSCH UCI/UL-SCH multiplexing - if (pusch_nr_gen_mux_uci(q, &q->uci_cfg) < SRSLTE_SUCCESS) { + if (pusch_nr_gen_mux_uci(q, &q->uci_cfg) < SRSRAN_SUCCESS) { ERROR("Error generating PUSCH mux tables"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Encode SCH - if (srslte_ulsch_nr_encode(&q->sch, &cfg->sch_cfg, tb, data, q->g_ulsch) < SRSLTE_SUCCESS) { + if (srsran_ulsch_nr_encode(&q->sch, &cfg->sch_cfg, tb, data, q->g_ulsch) < SRSRAN_SUCCESS) { ERROR("Error in SCH encoding"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Multiplex UL-SCH with UCI only if it is necessary @@ -894,14 +894,14 @@ static inline int pusch_nr_encode_codeword(srslte_pusch_nr_t* q, } } - if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_DEBUG && !handler_registered) { + if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_DEBUG && !handler_registered) { DEBUG("b="); - srslte_vec_fprint_b(stdout, b, tb->nof_bits); + srsran_vec_fprint_b(stdout, b, tb->nof_bits); } // 7.3.1.1 Scrambling uint32_t cinit = pusch_nr_cinit(&q->carrier, cfg, rnti, tb->cw_idx); - srslte_sequence_apply_bit(b, q->b[tb->cw_idx], tb->nof_bits, cinit); + srsran_sequence_apply_bit(b, q->b[tb->cw_idx], tb->nof_bits, cinit); // Special Scrambling condition if (q->uci_cfg.o_ack <= 2) { @@ -918,25 +918,25 @@ static inline int pusch_nr_encode_codeword(srslte_pusch_nr_t* q, } // 7.3.1.2 Modulation - srslte_mod_modulate(&q->modem_tables[tb->mod], q->b[tb->cw_idx], q->d[tb->cw_idx], tb->nof_bits); + srsran_mod_modulate(&q->modem_tables[tb->mod], q->b[tb->cw_idx], q->d[tb->cw_idx], tb->nof_bits); - if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_DEBUG && !handler_registered) { + if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_DEBUG && !handler_registered) { DEBUG("d="); - srslte_vec_fprint_c(stdout, q->d[tb->cw_idx], tb->nof_re); + srsran_vec_fprint_c(stdout, q->d[tb->cw_idx], tb->nof_re); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_pusch_nr_encode(srslte_pusch_nr_t* q, - const srslte_sch_cfg_nr_t* cfg, - const srslte_sch_grant_nr_t* grant, - const srslte_pusch_data_nr_t* data, - cf_t* sf_symbols[SRSLTE_MAX_PORTS]) +int srsran_pusch_nr_encode(srsran_pusch_nr_t* q, + const srsran_sch_cfg_nr_t* cfg, + const srsran_sch_grant_nr_t* grant, + const srsran_pusch_data_nr_t* data, + cf_t* sf_symbols[SRSRAN_MAX_PORTS]) { // Check input pointers if (!q || !cfg || !grant || !data || !sf_symbols) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } struct timeval t[3]; @@ -947,24 +947,24 @@ int srslte_pusch_nr_encode(srslte_pusch_nr_t* q, // Check number of layers if (q->max_layers < grant->nof_layers) { ERROR("Error number of layers (%d) exceeds configured maximum (%d)", grant->nof_layers, q->max_layers); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Fill UCI configuration for PUSCH configuration - if (pusch_nr_fill_uci_cfg(q, cfg) < SRSLTE_SUCCESS) { + if (pusch_nr_fill_uci_cfg(q, cfg) < SRSRAN_SUCCESS) { ERROR("Error filling UCI configuration for PUSCH"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // 7.3.1.1 and 7.3.1.2 uint32_t nof_cw = 0; - for (uint32_t tb = 0; tb < SRSLTE_MAX_TB; tb++) { + for (uint32_t tb = 0; tb < SRSRAN_MAX_TB; tb++) { nof_cw += grant->tb[tb].enabled ? 1 : 0; if (pusch_nr_encode_codeword(q, cfg, &grant->tb[tb], data[tb].payload, &data[0].uci, grant->rnti) < - SRSLTE_SUCCESS) { + SRSRAN_SUCCESS) { ERROR("Error encoding TB %d", tb); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } @@ -972,7 +972,7 @@ int srslte_pusch_nr_encode(srslte_pusch_nr_t* q, cf_t** x = q->d; if (grant->nof_layers > 1) { x = q->x; - srslte_layermap_nr(q->d, nof_cw, x, grant->nof_layers, grant->nof_layers); + srsran_layermap_nr(q->d, nof_cw, x, grant->nof_layers, grant->nof_layers); } // 7.3.1.4 Antenna port mapping @@ -982,15 +982,15 @@ int srslte_pusch_nr_encode(srslte_pusch_nr_t* q, // ... Not implemented // 7.3.1.6 Mapping from virtual to physical resource blocks - int n = srslte_pusch_nr_put(q, cfg, grant, x[0], sf_symbols[0]); - if (n < SRSLTE_SUCCESS) { + int n = srsran_pusch_nr_put(q, cfg, grant, x[0], sf_symbols[0]); + if (n < SRSRAN_SUCCESS) { ERROR("Putting NR PUSCH resources"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (n != grant->tb[0].nof_re) { ERROR("Unmatched number of RE (%d != %d)", n, grant->tb[0].nof_re); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (q->meas_time_en) { @@ -999,50 +999,50 @@ int srslte_pusch_nr_encode(srslte_pusch_nr_t* q, q->meas_time_us = (uint32_t)t[0].tv_usec; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -static inline int pusch_nr_decode_codeword(srslte_pusch_nr_t* q, - const srslte_sch_cfg_nr_t* cfg, - const srslte_sch_tb_t* tb, - srslte_pusch_res_nr_t* res, +static inline int pusch_nr_decode_codeword(srsran_pusch_nr_t* q, + const srsran_sch_cfg_nr_t* cfg, + const srsran_sch_tb_t* tb, + srsran_pusch_res_nr_t* res, uint16_t rnti) { // Early return if TB is not enabled if (!tb->enabled) { - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Check codeword index if (tb->cw_idx >= q->max_cw) { ERROR("Unsupported codeword index %d", tb->cw_idx); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Check modulation - if (tb->mod >= SRSLTE_MOD_NITEMS) { - ERROR("Invalid modulation %s", srslte_mod_string(tb->mod)); - return SRSLTE_ERROR_OUT_OF_BOUNDS; + if (tb->mod >= SRSRAN_MOD_NITEMS) { + ERROR("Invalid modulation %s", srsran_mod_string(tb->mod)); + return SRSRAN_ERROR_OUT_OF_BOUNDS; } - if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_DEBUG && !handler_registered) { + if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_DEBUG && !handler_registered) { DEBUG("d="); - srslte_vec_fprint_c(stdout, q->d[tb->cw_idx], tb->nof_re); + srsran_vec_fprint_c(stdout, q->d[tb->cw_idx], tb->nof_re); } // Calculate HARQ-ACK bits - int n = srslte_uci_nr_pusch_ack_nof_bits(&q->uci_cfg.pusch, q->uci_cfg.o_ack); - if (n < SRSLTE_SUCCESS) { + int n = srsran_uci_nr_pusch_ack_nof_bits(&q->uci_cfg.pusch, q->uci_cfg.o_ack); + if (n < SRSRAN_SUCCESS) { ERROR("Calculating G_ack"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } q->G_ack = (uint32_t)n; // Calculate CSI part 1 bits - n = srslte_uci_nr_pusch_csi1_nof_bits(&q->uci_cfg); - if (n < SRSLTE_SUCCESS) { + n = srsran_uci_nr_pusch_csi1_nof_bits(&q->uci_cfg); + if (n < SRSRAN_SUCCESS) { ERROR("Calculating G_csi1"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } q->G_csi1 = (uint32_t)n; @@ -1051,28 +1051,28 @@ static inline int pusch_nr_decode_codeword(srslte_pusch_nr_t* q, q->G_csi2 = 0; // Generate PUSCH UCI/UL-SCH multiplexing - if (pusch_nr_gen_mux_uci(q, &q->uci_cfg) < SRSLTE_SUCCESS) { + if (pusch_nr_gen_mux_uci(q, &q->uci_cfg) < SRSRAN_SUCCESS) { ERROR("Error generating PUSCH mux tables"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Demodulation int8_t* llr = (int8_t*)q->b[tb->cw_idx]; - if (srslte_demod_soft_demodulate_b(tb->mod, q->d[tb->cw_idx], llr, tb->nof_re)) { - return SRSLTE_ERROR; + if (srsran_demod_soft_demodulate_b(tb->mod, q->d[tb->cw_idx], llr, tb->nof_re)) { + return SRSRAN_ERROR; } // EVM if (q->evm_buffer != NULL) { - res->evm = srslte_evm_run_b(q->evm_buffer, &q->modem_tables[tb->mod], q->d[tb->cw_idx], llr, tb->nof_bits); + res->evm = srsran_evm_run_b(q->evm_buffer, &q->modem_tables[tb->mod], q->d[tb->cw_idx], llr, tb->nof_bits); } // Descrambling - srslte_sequence_apply_c(llr, llr, tb->nof_bits, pusch_nr_cinit(&q->carrier, cfg, rnti, tb->cw_idx)); + srsran_sequence_apply_c(llr, llr, tb->nof_bits, pusch_nr_cinit(&q->carrier, cfg, rnti, tb->cw_idx)); - if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_DEBUG && !handler_registered) { + if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_DEBUG && !handler_registered) { DEBUG("b="); - srslte_vec_fprint_bs(stdout, llr, tb->nof_bits); + srsran_vec_fprint_bs(stdout, llr, tb->nof_bits); } // Demultiplex UCI only if necessary @@ -1106,17 +1106,17 @@ static inline int pusch_nr_decode_codeword(srslte_pusch_nr_t* q, // Decode HARQ-ACK if (q->G_ack) { - if (srslte_uci_nr_decode_pusch_ack(&q->uci, &q->uci_cfg, g_ack, &res->uci)) { + if (srsran_uci_nr_decode_pusch_ack(&q->uci, &q->uci_cfg, g_ack, &res->uci)) { ERROR("Error in UCI decoding"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } // Decode CSI part 1 if (q->G_csi1) { - if (srslte_uci_nr_decode_pusch_csi1(&q->uci, &q->uci_cfg, g_csi1, &res->uci)) { + if (srsran_uci_nr_decode_pusch_csi1(&q->uci, &q->uci_cfg, g_csi1, &res->uci)) { ERROR("Error in UCI decoding"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } @@ -1133,25 +1133,25 @@ static inline int pusch_nr_decode_codeword(srslte_pusch_nr_t* q, // Decode Ul-SCH if (tb->nof_bits != 0) { - if (srslte_ulsch_nr_decode(&q->sch, &cfg->sch_cfg, tb, llr, res->payload, &res->crc) < SRSLTE_SUCCESS) { + if (srsran_ulsch_nr_decode(&q->sch, &cfg->sch_cfg, tb, llr, res->payload, &res->crc) < SRSRAN_SUCCESS) { ERROR("Error in SCH decoding"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_pusch_nr_decode(srslte_pusch_nr_t* q, - const srslte_sch_cfg_nr_t* cfg, - const srslte_sch_grant_nr_t* grant, - srslte_chest_dl_res_t* channel, - cf_t* sf_symbols[SRSLTE_MAX_PORTS], - srslte_pusch_res_nr_t data[SRSLTE_MAX_TB]) +int srsran_pusch_nr_decode(srsran_pusch_nr_t* q, + const srsran_sch_cfg_nr_t* cfg, + const srsran_sch_grant_nr_t* grant, + srsran_chest_dl_res_t* channel, + cf_t* sf_symbols[SRSRAN_MAX_PORTS], + srsran_pusch_res_nr_t data[SRSRAN_MAX_TB]) { // Check input pointers if (!q || !cfg || !grant || !data || !sf_symbols) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } struct timeval t[3]; @@ -1162,39 +1162,39 @@ int srslte_pusch_nr_decode(srslte_pusch_nr_t* q, // Check number of layers if (q->max_layers < grant->nof_layers) { ERROR("Error number of layers (%d) exceeds configured maximum (%d)", grant->nof_layers, q->max_layers); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Fill UCI configuration for PUSCH configuration - if (pusch_nr_fill_uci_cfg(q, cfg) < SRSLTE_SUCCESS) { + if (pusch_nr_fill_uci_cfg(q, cfg) < SRSRAN_SUCCESS) { ERROR("Error filling UCI configuration for PUSCH"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } uint32_t nof_cw = 0; - for (uint32_t tb = 0; tb < SRSLTE_MAX_TB; tb++) { + for (uint32_t tb = 0; tb < SRSRAN_MAX_TB; tb++) { nof_cw += grant->tb[tb].enabled ? 1 : 0; } - uint32_t nof_re = srslte_ra_dl_nr_slot_nof_re(cfg, grant); + uint32_t nof_re = srsran_ra_dl_nr_slot_nof_re(cfg, grant); if (channel->nof_re != nof_re) { ERROR("Inconsistent number of RE (%d!=%d)", channel->nof_re, nof_re); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Demapping from virtual to physical resource blocks - uint32_t nof_re_get = srslte_pusch_nr_get(q, cfg, grant, q->x[0], sf_symbols[0]); + uint32_t nof_re_get = srsran_pusch_nr_get(q, cfg, grant, q->x[0], sf_symbols[0]); if (nof_re_get != nof_re) { ERROR("Inconsistent number of RE (%d!=%d)", nof_re_get, nof_re); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_DEBUG && !handler_registered) { + if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_DEBUG && !handler_registered) { DEBUG("ce="); - srslte_vec_fprint_c(stdout, channel->ce[0][0], nof_re); + srsran_vec_fprint_c(stdout, channel->ce[0][0], nof_re); DEBUG("x="); - srslte_vec_fprint_c(stdout, q->x[0], nof_re); + srsran_vec_fprint_c(stdout, q->x[0], nof_re); } // Demapping to virtual resource blocks @@ -1202,21 +1202,21 @@ int srslte_pusch_nr_decode(srslte_pusch_nr_t* q, // Antenna port demapping // ... Not implemented - srslte_predecoding_type( - q->x, channel->ce, q->d, NULL, 1, 1, 1, 0, nof_re, SRSLTE_TXSCHEME_PORT0, 1.0f, channel->noise_estimate); + srsran_predecoding_type( + q->x, channel->ce, q->d, NULL, 1, 1, 1, 0, nof_re, SRSRAN_TXSCHEME_PORT0, 1.0f, channel->noise_estimate); // Layer demapping if (grant->nof_layers > 1) { - srslte_layerdemap_nr(q->d, nof_cw, q->x, grant->nof_layers, nof_re); + srsran_layerdemap_nr(q->d, nof_cw, q->x, grant->nof_layers, nof_re); } // SCH decode - for (uint32_t tb = 0; tb < SRSLTE_MAX_TB; tb++) { + for (uint32_t tb = 0; tb < SRSRAN_MAX_TB; tb++) { nof_cw += grant->tb[tb].enabled ? 1 : 0; - if (pusch_nr_decode_codeword(q, cfg, &grant->tb[tb], &data[tb], grant->rnti) < SRSLTE_SUCCESS) { + if (pusch_nr_decode_codeword(q, cfg, &grant->tb[tb], &data[tb], grant->rnti) < SRSRAN_SUCCESS) { ERROR("Error encoding TB %d", tb); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } @@ -1226,26 +1226,26 @@ int srslte_pusch_nr_decode(srslte_pusch_nr_t* q, q->meas_time_us = (uint32_t)t[0].tv_usec; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -static uint32_t srslte_pusch_nr_grant_info(const srslte_sch_cfg_nr_t* cfg, - const srslte_sch_grant_nr_t* grant, +static uint32_t srsran_pusch_nr_grant_info(const srsran_sch_cfg_nr_t* cfg, + const srsran_sch_grant_nr_t* grant, char* str, uint32_t str_len) { uint32_t len = 0; - len = srslte_print_check(str, str_len, len, "rnti=0x%x", grant->rnti); + len = srsran_print_check(str, str_len, len, "rnti=0x%x", grant->rnti); - uint32_t first_prb = SRSLTE_MAX_PRB_NR; - for (uint32_t i = 0; i < SRSLTE_MAX_PRB_NR && first_prb == SRSLTE_MAX_PRB_NR; i++) { + uint32_t first_prb = SRSRAN_MAX_PRB_NR; + for (uint32_t i = 0; i < SRSRAN_MAX_PRB_NR && first_prb == SRSRAN_MAX_PRB_NR; i++) { if (grant->prb_idx[i]) { first_prb = i; } } // Append time-domain resource mapping - len = srslte_print_check(str, + len = srsran_print_check(str, str_len, len, ",k2=%d,prb=%d:%d,S=%d,L=%d,mapping=%s", @@ -1254,29 +1254,29 @@ static uint32_t srslte_pusch_nr_grant_info(const srslte_sch_cfg_nr_t* cfg, grant->nof_prb, grant->S, grant->L, - srslte_sch_mapping_type_to_str(grant->mapping)); + srsran_sch_mapping_type_to_str(grant->mapping)); // Skip frequency domain resources... // ... // Append spatial resources - len = srslte_print_check(str, str_len, len, ",Nl=%d", grant->nof_layers); + len = srsran_print_check(str, str_len, len, ",Nl=%d", grant->nof_layers); // Append scrambling ID - len = srslte_print_check(str, str_len, len, ",n_scid=%d,", grant->n_scid); + len = srsran_print_check(str, str_len, len, ",n_scid=%d,", grant->n_scid); // Append TB info - for (uint32_t i = 0; i < SRSLTE_MAX_TB; i++) { - len += srslte_sch_nr_tb_info(&grant->tb[i], &str[len], str_len - len); + for (uint32_t i = 0; i < SRSRAN_MAX_TB; i++) { + len += srsran_sch_nr_tb_info(&grant->tb[i], &str[len], str_len - len); } return len; } -uint32_t srslte_pusch_nr_rx_info(const srslte_pusch_nr_t* q, - const srslte_sch_cfg_nr_t* cfg, - const srslte_sch_grant_nr_t* grant, - const srslte_pusch_res_nr_t res[SRSLTE_MAX_CODEWORDS], +uint32_t srsran_pusch_nr_rx_info(const srsran_pusch_nr_t* q, + const srsran_sch_cfg_nr_t* cfg, + const srsran_sch_grant_nr_t* grant, + const srsran_pusch_res_nr_t res[SRSRAN_MAX_CODEWORDS], char* str, uint32_t str_len) { @@ -1286,54 +1286,54 @@ uint32_t srslte_pusch_nr_rx_info(const srslte_pusch_nr_t* q, return 0; } - len += srslte_pusch_nr_grant_info(cfg, grant, &str[len], str_len - len); + len += srsran_pusch_nr_grant_info(cfg, grant, &str[len], str_len - len); if (q->evm_buffer != NULL) { - len = srslte_print_check(str, str_len, len, ",evm={", 0); - for (uint32_t i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { + len = srsran_print_check(str, str_len, len, ",evm={", 0); + for (uint32_t i = 0; i < SRSRAN_MAX_CODEWORDS; i++) { if (grant->tb[i].enabled && !isnan(res[i].evm)) { - len = srslte_print_check(str, str_len, len, "%.2f", res[i].evm); - if (i < SRSLTE_MAX_CODEWORDS - 1) { + len = srsran_print_check(str, str_len, len, "%.2f", res[i].evm); + if (i < SRSRAN_MAX_CODEWORDS - 1) { if (grant->tb[i + 1].enabled) { - len = srslte_print_check(str, str_len, len, ",", 0); + len = srsran_print_check(str, str_len, len, ",", 0); } } } } - len = srslte_print_check(str, str_len, len, "}", 0); + len = srsran_print_check(str, str_len, len, "}", 0); } if (res != NULL) { - srslte_uci_data_nr_t uci_data = {}; + srsran_uci_data_nr_t uci_data = {}; uci_data.cfg = cfg->uci; uci_data.value = res[0].uci; - len += srslte_uci_nr_info(&uci_data, &str[len], str_len - len); + len += srsran_uci_nr_info(&uci_data, &str[len], str_len - len); - len = srslte_print_check(str, str_len, len, ",crc={", 0); - for (uint32_t i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { + len = srsran_print_check(str, str_len, len, ",crc={", 0); + for (uint32_t i = 0; i < SRSRAN_MAX_CODEWORDS; i++) { if (grant->tb[i].enabled) { - len = srslte_print_check(str, str_len, len, "%s", res[i].crc ? "OK" : "KO"); - if (i < SRSLTE_MAX_CODEWORDS - 1) { + len = srsran_print_check(str, str_len, len, "%s", res[i].crc ? "OK" : "KO"); + if (i < SRSRAN_MAX_CODEWORDS - 1) { if (grant->tb[i + 1].enabled) { - len = srslte_print_check(str, str_len, len, ",", 0); + len = srsran_print_check(str, str_len, len, ",", 0); } } } } - len = srslte_print_check(str, str_len, len, "}", 0); + len = srsran_print_check(str, str_len, len, "}", 0); } if (q->meas_time_en) { - len = srslte_print_check(str, str_len, len, ", t=%d us", q->meas_time_us); + len = srsran_print_check(str, str_len, len, ", t=%d us", q->meas_time_us); } return len; } -uint32_t srslte_pusch_nr_tx_info(const srslte_pusch_nr_t* q, - const srslte_sch_cfg_nr_t* cfg, - const srslte_sch_grant_nr_t* grant, - const srslte_uci_value_nr_t* uci_value, +uint32_t srsran_pusch_nr_tx_info(const srsran_pusch_nr_t* q, + const srsran_sch_cfg_nr_t* cfg, + const srsran_sch_grant_nr_t* grant, + const srsran_uci_value_nr_t* uci_value, char* str, uint32_t str_len) { @@ -1343,17 +1343,17 @@ uint32_t srslte_pusch_nr_tx_info(const srslte_pusch_nr_t* q, return 0; } - len += srslte_pusch_nr_grant_info(cfg, grant, &str[len], str_len - len); + len += srsran_pusch_nr_grant_info(cfg, grant, &str[len], str_len - len); if (uci_value != NULL) { - srslte_uci_data_nr_t uci_data = {}; + srsran_uci_data_nr_t uci_data = {}; uci_data.cfg = cfg->uci; uci_data.value = *uci_value; - len += srslte_uci_nr_info(&uci_data, &str[len], str_len - len); + len += srsran_uci_nr_info(&uci_data, &str[len], str_len - len); } if (q->meas_time_en) { - len = srslte_print_check(str, str_len, len, ", t=%d us", q->meas_time_us); + len = srsran_print_check(str, str_len, len, ", t=%d us", q->meas_time_us); } return len; diff --git a/lib/src/phy/phch/ra.c b/lib/src/phy/phch/ra.c index d15bcfef6..1a53a0061 100644 --- a/lib/src/phy/phch/ra.c +++ b/lib/src/phy/phch/ra.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,12 +10,12 @@ * */ -#include "srslte/phy/phch/ra.h" -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/utils/bit.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" -#include "srslte/srslte.h" +#include "srsran/phy/phch/ra.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/utils/bit.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" +#include "srsran/srsran.h" #include #include #include @@ -25,7 +25,7 @@ #include "tbs_tables.h" /* Convert Type2 scheduling L_crb and RB_start to RIV value */ -uint32_t srslte_ra_type2_to_riv(uint32_t L_crb, uint32_t RB_start, uint32_t nof_prb) +uint32_t srsran_ra_type2_to_riv(uint32_t L_crb, uint32_t RB_start, uint32_t nof_prb) { uint32_t riv; if ((L_crb - 1) <= nof_prb / 2) { @@ -37,7 +37,7 @@ uint32_t srslte_ra_type2_to_riv(uint32_t L_crb, uint32_t RB_start, uint32_t nof_ } /* Convert Type2 scheduling RIV value to L_crb and RB_start values */ -void srslte_ra_type2_from_riv(uint32_t riv, uint32_t* L_crb, uint32_t* RB_start, uint32_t nof_prb, uint32_t nof_vrb) +void srsran_ra_type2_from_riv(uint32_t riv, uint32_t* L_crb, uint32_t* RB_start, uint32_t nof_prb, uint32_t nof_vrb) { *L_crb = (uint32_t)(riv / nof_prb) + 1; *RB_start = (uint32_t)(riv % nof_prb); @@ -48,7 +48,7 @@ void srslte_ra_type2_from_riv(uint32_t riv, uint32_t* L_crb, uint32_t* RB_start, } /* RBG size for type0 scheduling as in table 7.1.6.1-1 of 36.213 */ -uint32_t srslte_ra_type0_P(uint32_t nof_prb) +uint32_t srsran_ra_type0_P(uint32_t nof_prb) { if (nof_prb <= 10) { return 1; @@ -62,14 +62,14 @@ uint32_t srslte_ra_type0_P(uint32_t nof_prb) } /* Returns N_rb_type1 according to section 7.1.6.2 */ -uint32_t srslte_ra_type1_N_rb(uint32_t nof_prb) +uint32_t srsran_ra_type1_N_rb(uint32_t nof_prb) { - uint32_t P = srslte_ra_type0_P(nof_prb); + uint32_t P = srsran_ra_type0_P(nof_prb); return (uint32_t)ceilf((float)nof_prb / P) - (uint32_t)ceilf(log2f((float)P)) - 1; } /* Table 6.2.3.2-1 in 36.211 */ -uint32_t srslte_ra_type2_ngap(uint32_t nof_prb, bool ngap_is_1) +uint32_t srsran_ra_type2_ngap(uint32_t nof_prb, bool ngap_is_1) { if (nof_prb <= 10) { return nof_prb / 2; @@ -93,7 +93,7 @@ uint32_t srslte_ra_type2_ngap(uint32_t nof_prb, bool ngap_is_1) } /* Table 7.1.6.3-1 in 36.213 */ -uint32_t srslte_ra_type2_n_rb_step(uint32_t nof_prb) +uint32_t srsran_ra_type2_n_rb_step(uint32_t nof_prb) { if (nof_prb < 50) { return 2; @@ -103,9 +103,9 @@ uint32_t srslte_ra_type2_n_rb_step(uint32_t nof_prb) } /* as defined in 6.2.3.2 of 36.211 */ -uint32_t srslte_ra_type2_n_vrb_dl(uint32_t nof_prb, bool ngap_is_1) +uint32_t srsran_ra_type2_n_vrb_dl(uint32_t nof_prb, bool ngap_is_1) { - uint32_t ngap = srslte_ra_type2_ngap(nof_prb, ngap_is_1); + uint32_t ngap = srsran_ra_type2_ngap(nof_prb, ngap_is_1); if (ngap_is_1) { return 2 * (ngap < (nof_prb - ngap) ? ngap : nof_prb - ngap); } else { @@ -114,71 +114,71 @@ uint32_t srslte_ra_type2_n_vrb_dl(uint32_t nof_prb, bool ngap_is_1) } /* Modulation and TBS index table for PDSCH from 3GPP TS 36.213 v10.3.0 table 7.1.7.1-1 */ -static int srslte_ra_dl_tbs_idx_from_mcs(uint32_t mcs, bool use_tbs_index_alt) +static int srsran_ra_dl_tbs_idx_from_mcs(uint32_t mcs, bool use_tbs_index_alt) { if (use_tbs_index_alt && mcs < 28) { return dl_mcs_tbs_idx_table2[mcs]; } else if (!use_tbs_index_alt && mcs < 29) { return dl_mcs_tbs_idx_table[mcs]; } else { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } -static int srslte_ra_ul_tbs_idx_from_mcs(uint32_t mcs) +static int srsran_ra_ul_tbs_idx_from_mcs(uint32_t mcs) { if (mcs < 29) { return ul_mcs_tbs_idx_table[mcs]; } else { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } -int srslte_ra_tbs_idx_from_mcs(uint32_t mcs, bool use_tbs_index_alt, bool is_ul) +int srsran_ra_tbs_idx_from_mcs(uint32_t mcs, bool use_tbs_index_alt, bool is_ul) { - return (is_ul) ? srslte_ra_ul_tbs_idx_from_mcs(mcs) : srslte_ra_dl_tbs_idx_from_mcs(mcs, use_tbs_index_alt); + return (is_ul) ? srsran_ra_ul_tbs_idx_from_mcs(mcs) : srsran_ra_dl_tbs_idx_from_mcs(mcs, use_tbs_index_alt); } -srslte_mod_t srslte_ra_dl_mod_from_mcs(uint32_t mcs, bool use_tbs_index_alt) +srsran_mod_t srsran_ra_dl_mod_from_mcs(uint32_t mcs, bool use_tbs_index_alt) { if (use_tbs_index_alt) { // 3GPP 36.213 R12 Table 7.1.7.1-1A if (mcs < 5 || mcs == 28) { - return SRSLTE_MOD_QPSK; + return SRSRAN_MOD_QPSK; } else if (mcs < 11 || mcs == 29) { - return SRSLTE_MOD_16QAM; + return SRSRAN_MOD_16QAM; } else if (mcs < 20 || mcs == 30) { - return SRSLTE_MOD_64QAM; + return SRSRAN_MOD_64QAM; } else { - return SRSLTE_MOD_256QAM; + return SRSRAN_MOD_256QAM; } } else { // 3GPP 36.213 R12 Table 7.1.7.1-1 if (mcs < 10 || mcs == 29) { - return SRSLTE_MOD_QPSK; + return SRSRAN_MOD_QPSK; } else if (mcs < 17 || mcs == 30) { - return SRSLTE_MOD_16QAM; + return SRSRAN_MOD_16QAM; } else { - return SRSLTE_MOD_64QAM; + return SRSRAN_MOD_64QAM; } } } -srslte_mod_t srslte_ra_ul_mod_from_mcs(uint32_t mcs) +srsran_mod_t srsran_ra_ul_mod_from_mcs(uint32_t mcs) { /* Table 8.6.1-1 on 36.213 */ if (mcs <= 10) { - return SRSLTE_MOD_QPSK; + return SRSRAN_MOD_QPSK; } else if (mcs <= 20) { - return SRSLTE_MOD_16QAM; + return SRSRAN_MOD_16QAM; } else if (mcs <= 28) { - return SRSLTE_MOD_64QAM; + return SRSRAN_MOD_64QAM; } else { - return SRSLTE_MOD_BPSK; + return SRSRAN_MOD_BPSK; } } -static int srslte_ra_dl_mcs_from_tbs_idx(uint32_t tbs_idx, bool use_tbs_index_alt) +static int srsran_ra_dl_mcs_from_tbs_idx(uint32_t tbs_idx, bool use_tbs_index_alt) { if (use_tbs_index_alt) { for (int mcs = 27; mcs >= 0; mcs--) { @@ -193,10 +193,10 @@ static int srslte_ra_dl_mcs_from_tbs_idx(uint32_t tbs_idx, bool use_tbs_index_al } } } - return SRSLTE_ERROR; + return SRSRAN_ERROR; } -static int srslte_ra_ul_mcs_from_tbs_idx(uint32_t tbs_idx) +static int srsran_ra_ul_mcs_from_tbs_idx(uint32_t tbs_idx) { // Note: go in descent order to find max mcs possible for (int mcs = 28; mcs >= 0; mcs--) { @@ -204,21 +204,21 @@ static int srslte_ra_ul_mcs_from_tbs_idx(uint32_t tbs_idx) return mcs; } } - return SRSLTE_ERROR; + return SRSRAN_ERROR; } -int srslte_ra_mcs_from_tbs_idx(uint32_t tbs_idx, bool use_tbs_index_alt, bool is_ul) +int srsran_ra_mcs_from_tbs_idx(uint32_t tbs_idx, bool use_tbs_index_alt, bool is_ul) { - return is_ul ? srslte_ra_ul_mcs_from_tbs_idx(tbs_idx) : srslte_ra_dl_mcs_from_tbs_idx(tbs_idx, use_tbs_index_alt); + return is_ul ? srsran_ra_ul_mcs_from_tbs_idx(tbs_idx) : srsran_ra_dl_mcs_from_tbs_idx(tbs_idx, use_tbs_index_alt); } /* Table 7.1.7.2.1-1: Transport block size table on 36.213 */ -int srslte_ra_tbs_from_idx(uint32_t tbs_idx, uint32_t n_prb) +int srsran_ra_tbs_from_idx(uint32_t tbs_idx, uint32_t n_prb) { - if (tbs_idx < SRSLTE_RA_NOF_TBS_IDX && n_prb > 0 && n_prb <= SRSLTE_MAX_PRB) { + if (tbs_idx < SRSRAN_RA_NOF_TBS_IDX && n_prb > 0 && n_prb <= SRSRAN_MAX_PRB) { return tbs_table[tbs_idx][n_prb - 1]; } else { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } @@ -230,10 +230,10 @@ int srslte_ra_tbs_from_idx(uint32_t tbs_idx, uint32_t n_prb) * \remark taken from table 7.1.7.2 on 36.213 * @return upper bound of TBS index (0..27), -2 if bad arguments */ -int srslte_ra_tbs_to_table_idx(uint32_t tbs, uint32_t n_prb, uint32_t max_tbs_idx) +int srsran_ra_tbs_to_table_idx(uint32_t tbs, uint32_t n_prb, uint32_t max_tbs_idx) { - if (n_prb == 0 || n_prb > SRSLTE_MAX_PRB) { - return SRSLTE_ERROR_INVALID_INPUTS; + if (n_prb == 0 || n_prb > SRSRAN_MAX_PRB) { + return SRSRAN_ERROR_INVALID_INPUTS; } if (tbs < tbs_table[0][n_prb - 1]) { return 0; @@ -243,5 +243,5 @@ int srslte_ra_tbs_to_table_idx(uint32_t tbs, uint32_t n_prb, uint32_t max_tbs_id return tbs_idx + 1; } } - return SRSLTE_ERROR; + return SRSRAN_ERROR; } diff --git a/lib/src/phy/phch/ra_dl.c b/lib/src/phy/phch/ra_dl.c index 589c16699..ae40ca1bb 100644 --- a/lib/src/phy/phch/ra_dl.c +++ b/lib/src/phy/phch/ra_dl.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,13 +10,13 @@ * */ -#include "srslte/phy/phch/ra_dl.h" -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/phch/ra.h" -#include "srslte/phy/utils/bit.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" -#include "srslte/srslte.h" +#include "srsran/phy/phch/ra_dl.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/phch/ra.h" +#include "srsran/phy/utils/bit.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" +#include "srsran/srsran.h" #include #include #include @@ -30,55 +30,55 @@ const int tbs_format1c_table[32] = {40, 56, 72, 120, 136, 144, 176, 208 904, 1000, 1064, 1128, 1224, 1288, 1384, 1480, 1608, 1736}; /* Returns the number of RE in a PRB in a slot and subframe */ -uint32_t ra_re_x_prb(const srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf, uint32_t slot, uint32_t prb_idx) +uint32_t ra_re_x_prb(const srsran_cell_t* cell, srsran_dl_sf_cfg_t* sf, uint32_t slot, uint32_t prb_idx) { uint32_t subframe = sf->tti % 10; - uint32_t nof_ctrl_symbols = SRSLTE_NOF_CTRL_SYMBOLS((*cell), sf->cfi); + uint32_t nof_ctrl_symbols = SRSRAN_NOF_CTRL_SYMBOLS((*cell), sf->cfi); uint32_t re; bool skip_refs = true; - srslte_cp_t cp_ = cell->cp; - if (SRSLTE_SF_MBSFN == sf->sf_type) { - cp_ = SRSLTE_CP_EXT; + srsran_cp_t cp_ = cell->cp; + if (SRSRAN_SF_MBSFN == sf->sf_type) { + cp_ = SRSRAN_CP_EXT; } - uint32_t nof_symbols = SRSLTE_CP_NSYMB(cp_); - if (cell->frame_type == SRSLTE_TDD && srslte_sfidx_tdd_type(sf->tdd_config, subframe) == SRSLTE_TDD_SF_S) { - nof_symbols = srslte_sfidx_tdd_nof_dw_slot(sf->tdd_config, slot, cp_); + uint32_t nof_symbols = SRSRAN_CP_NSYMB(cp_); + if (cell->frame_type == SRSRAN_TDD && srsran_sfidx_tdd_type(sf->tdd_config, subframe) == SRSRAN_TDD_SF_S) { + nof_symbols = srsran_sfidx_tdd_nof_dw_slot(sf->tdd_config, slot, cp_); } if (slot == 0) { - re = (nof_symbols - nof_ctrl_symbols) * SRSLTE_NRE; + re = (nof_symbols - nof_ctrl_symbols) * SRSRAN_NRE; } else { - re = nof_symbols * SRSLTE_NRE; + re = nof_symbols * SRSRAN_NRE; } /* if it's the prb in the middle, there are less RE due to PBCH and PSS/SSS */ - if (cell->frame_type == SRSLTE_FDD) { + if (cell->frame_type == SRSRAN_FDD) { if ((subframe == 0 || subframe == 5) && (prb_idx >= cell->nof_prb / 2 - 3 && prb_idx < cell->nof_prb / 2 + 3 + (cell->nof_prb % 2))) { if (subframe == 0) { if (slot == 0) { - re = (nof_symbols - nof_ctrl_symbols - 2) * SRSLTE_NRE; + re = (nof_symbols - nof_ctrl_symbols - 2) * SRSRAN_NRE; } else { - if (SRSLTE_CP_ISEXT(cp_)) { - re = (nof_symbols - 4) * SRSLTE_NRE; + if (SRSRAN_CP_ISEXT(cp_)) { + re = (nof_symbols - 4) * SRSRAN_NRE; skip_refs = false; } else { - re = (nof_symbols - 4) * SRSLTE_NRE + 2 * cell->nof_ports; + re = (nof_symbols - 4) * SRSRAN_NRE + 2 * cell->nof_ports; } } } else if (subframe == 5) { if (slot == 0) { - re = (nof_symbols - nof_ctrl_symbols - 2) * SRSLTE_NRE; + re = (nof_symbols - nof_ctrl_symbols - 2) * SRSRAN_NRE; } } if ((cell->nof_prb % 2) && (prb_idx == cell->nof_prb / 2 - 3 || prb_idx == cell->nof_prb / 2 + 3)) { if (slot == 0) { - re += 2 * SRSLTE_NRE / 2; + re += 2 * SRSRAN_NRE / 2; } else if (subframe == 0) { - re += 4 * SRSLTE_NRE / 2 - cell->nof_ports; - if (SRSLTE_CP_ISEXT(cp_)) { + re += 4 * SRSRAN_NRE / 2 - cell->nof_ports; + if (SRSRAN_CP_ISEXT(cp_)) { re -= cell->nof_ports > 2 ? 2 : cell->nof_ports; } } @@ -88,24 +88,24 @@ uint32_t ra_re_x_prb(const srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf, uint32_t if ((((subframe == 0 || subframe == 5) && slot == 1) || ((subframe == 1 || subframe == 6) && slot == 0)) && (prb_idx >= cell->nof_prb / 2 - 3 && prb_idx < cell->nof_prb / 2 + 3 + (cell->nof_prb % 2))) { if (subframe == 0) { - if (SRSLTE_CP_ISEXT(cp_)) { - re = (nof_symbols - 5) * SRSLTE_NRE; + if (SRSRAN_CP_ISEXT(cp_)) { + re = (nof_symbols - 5) * SRSRAN_NRE; skip_refs = false; } else { - re = (nof_symbols - 5) * SRSLTE_NRE + 2 * cell->nof_ports; + re = (nof_symbols - 5) * SRSRAN_NRE + 2 * cell->nof_ports; } } else if (subframe == 5) { - re = (nof_symbols - 1) * SRSLTE_NRE; + re = (nof_symbols - 1) * SRSRAN_NRE; } else if (subframe == 1) { - re = (nof_symbols - nof_ctrl_symbols - 1) * SRSLTE_NRE; + re = (nof_symbols - nof_ctrl_symbols - 1) * SRSRAN_NRE; } else if (subframe == 6) { - re = (nof_symbols - nof_ctrl_symbols - 1) * SRSLTE_NRE; + re = (nof_symbols - nof_ctrl_symbols - 1) * SRSRAN_NRE; } if ((cell->nof_prb % 2) && (prb_idx == cell->nof_prb / 2 - 3 || prb_idx == cell->nof_prb / 2 + 3)) { - re += SRSLTE_NRE / 2; + re += SRSRAN_NRE / 2; if (subframe == 0) { - re += 4 * SRSLTE_NRE / 2 - cell->nof_ports; - if (SRSLTE_CP_ISEXT(cp_)) { + re += 4 * SRSRAN_NRE / 2 - cell->nof_ports; + if (SRSRAN_CP_ISEXT(cp_)) { re -= cell->nof_ports > 2 ? 2 : cell->nof_ports; } } @@ -115,11 +115,11 @@ uint32_t ra_re_x_prb(const srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf, uint32_t // remove references if (skip_refs) { - if (sf->sf_type == SRSLTE_SF_NORM) { + if (sf->sf_type == SRSRAN_SF_NORM) { switch (cell->nof_ports) { case 1: case 2: - if ((cp_ == SRSLTE_CP_NORM && nof_symbols >= 5) || (cp_ == SRSLTE_CP_EXT && nof_symbols >= 4)) { + if ((cp_ == SRSRAN_CP_NORM && nof_symbols >= 5) || (cp_ == SRSRAN_CP_EXT && nof_symbols >= 4)) { re -= 2 * (slot + 1) * cell->nof_ports; } else if (slot == 1) { if (nof_symbols >= 1) { @@ -129,13 +129,13 @@ uint32_t ra_re_x_prb(const srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf, uint32_t break; case 4: if (slot == 1) { - if ((cp_ == SRSLTE_CP_NORM && nof_symbols >= 5) || (cp_ == SRSLTE_CP_EXT && nof_symbols >= 4)) { + if ((cp_ == SRSRAN_CP_NORM && nof_symbols >= 5) || (cp_ == SRSRAN_CP_EXT && nof_symbols >= 4)) { re -= 12; } else if (nof_symbols >= 2) { re -= 8; } } else { - if ((cp_ == SRSLTE_CP_NORM && nof_symbols >= 5) || (cp_ == SRSLTE_CP_EXT && nof_symbols >= 4)) { + if ((cp_ == SRSRAN_CP_NORM && nof_symbols >= 5) || (cp_ == SRSRAN_CP_EXT && nof_symbols >= 4)) { re -= 4; if (nof_ctrl_symbols == 1) { re -= 4; @@ -145,7 +145,7 @@ uint32_t ra_re_x_prb(const srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf, uint32_t break; } } - if (sf->sf_type == SRSLTE_SF_MBSFN) { + if (sf->sf_type == SRSRAN_SF_MBSFN) { re -= 6 * (slot + 1); } } @@ -158,18 +158,18 @@ uint32_t ra_re_x_prb(const srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf, uint32_t * This function only writes grant->prb_idx and grant->nof_prb. */ /** Compute PRB allocation for Downlink as defined in 7.1.6 of 36.213 */ -int srslte_ra_dl_grant_to_grant_prb_allocation(const srslte_dci_dl_t* dci, - srslte_pdsch_grant_t* grant, +int srsran_ra_dl_grant_to_grant_prb_allocation(const srsran_dci_dl_t* dci, + srsran_pdsch_grant_t* grant, uint32_t nof_prb) { int i, j; uint32_t bitmask; - uint32_t P = srslte_ra_type0_P(nof_prb); + uint32_t P = srsran_ra_type0_P(nof_prb); uint32_t n_rb_rbg_subset, n_rb_type1; uint32_t L_crb = 0, RB_start = 0, nof_vrb = 0, nof_prb_t2 = 0, n_step = 0; switch (dci->alloc_type) { - case SRSLTE_RA_ALLOC_TYPE0: + case SRSRAN_RA_ALLOC_TYPE0: bitmask = dci->type0_alloc.rbg_bitmask; int nb = (int)ceilf((float)nof_prb / P); for (i = 0; i < nb; i++) { @@ -182,15 +182,15 @@ int srslte_ra_dl_grant_to_grant_prb_allocation(const srslte_dci_dl_t* dci, } } } - memcpy(&grant->prb_idx[1], &grant->prb_idx[0], SRSLTE_MAX_PRB * sizeof(bool)); + memcpy(&grant->prb_idx[1], &grant->prb_idx[0], SRSRAN_MAX_PRB * sizeof(bool)); break; - case SRSLTE_RA_ALLOC_TYPE1: + case SRSRAN_RA_ALLOC_TYPE1: // Make sure the rbg_subset is valid if (dci->type1_alloc.rbg_subset >= P) { ERROR("Invalid RBG subset=%d for nof_prb=%d where P=%d", dci->type1_alloc.rbg_subset, nof_prb, P); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - n_rb_type1 = srslte_ra_type1_N_rb(nof_prb); + n_rb_type1 = srsran_ra_type1_N_rb(nof_prb); uint32_t temp = ((nof_prb - 1) / P) % P; if (dci->type1_alloc.rbg_subset < temp) { n_rb_rbg_subset = ((nof_prb - 1) / (P * P)) * P + P; @@ -209,51 +209,51 @@ int srslte_ra_dl_grant_to_grant_prb_allocation(const srslte_dci_dl_t* dci, grant->nof_prb++; } else { ERROR("Invalid idx=%d in Type1 RA, nof_prb=%d", idx, nof_prb); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } } - memcpy(&grant->prb_idx[1], &grant->prb_idx[0], SRSLTE_MAX_PRB * sizeof(bool)); + memcpy(&grant->prb_idx[1], &grant->prb_idx[0], SRSRAN_MAX_PRB * sizeof(bool)); break; - case SRSLTE_RA_ALLOC_TYPE2: + case SRSRAN_RA_ALLOC_TYPE2: - if (dci->type2_alloc.mode == SRSLTE_RA_TYPE2_LOC) { + if (dci->type2_alloc.mode == SRSRAN_RA_TYPE2_LOC) { nof_vrb = nof_prb; } else { - nof_vrb = srslte_ra_type2_n_vrb_dl(nof_prb, dci->type2_alloc.n_gap == SRSLTE_RA_TYPE2_NG1); + nof_vrb = srsran_ra_type2_n_vrb_dl(nof_prb, dci->type2_alloc.n_gap == SRSRAN_RA_TYPE2_NG1); } - if (dci->format == SRSLTE_DCI_FORMAT1C) { - n_step = srslte_ra_type2_n_rb_step(nof_prb); + if (dci->format == SRSRAN_DCI_FORMAT1C) { + n_step = srsran_ra_type2_n_rb_step(nof_prb); nof_vrb /= n_step; nof_prb_t2 = nof_vrb; } else { nof_prb_t2 = nof_prb; } - srslte_ra_type2_from_riv(dci->type2_alloc.riv, &L_crb, &RB_start, nof_prb_t2, nof_vrb); + srsran_ra_type2_from_riv(dci->type2_alloc.riv, &L_crb, &RB_start, nof_prb_t2, nof_vrb); - if (dci->format == SRSLTE_DCI_FORMAT1C) { + if (dci->format == SRSRAN_DCI_FORMAT1C) { L_crb *= n_step; RB_start *= n_step; } - if (dci->type2_alloc.mode == SRSLTE_RA_TYPE2_LOC) { + if (dci->type2_alloc.mode == SRSRAN_RA_TYPE2_LOC) { for (i = 0; i < L_crb; i++) { grant->prb_idx[0][i + RB_start] = true; grant->nof_prb++; } - memcpy(&grant->prb_idx[1], &grant->prb_idx[0], SRSLTE_MAX_PRB * sizeof(bool)); + memcpy(&grant->prb_idx[1], &grant->prb_idx[0], SRSRAN_MAX_PRB * sizeof(bool)); } else { /* Mapping of Virtual to Physical RB for distributed type is defined in * 6.2.3.2 of 36.211 */ int N_gap, N_tilde_vrb, n_tilde_vrb, n_tilde_prb, n_tilde2_prb, N_null, N_row, n_vrb; int n_tilde_prb_odd, n_tilde_prb_even; - if (dci->type2_alloc.n_gap == SRSLTE_RA_TYPE2_NG1) { - N_tilde_vrb = srslte_ra_type2_n_vrb_dl(nof_prb, true); - N_gap = srslte_ra_type2_ngap(nof_prb, true); + if (dci->type2_alloc.n_gap == SRSRAN_RA_TYPE2_NG1) { + N_tilde_vrb = srsran_ra_type2_n_vrb_dl(nof_prb, true); + N_gap = srsran_ra_type2_ngap(nof_prb, true); } else { - N_tilde_vrb = 2 * srslte_ra_type2_n_vrb_dl(nof_prb, true); - N_gap = srslte_ra_type2_ngap(nof_prb, false); + N_tilde_vrb = 2 * srsran_ra_type2_n_vrb_dl(nof_prb, true); + N_gap = srsran_ra_type2_ngap(nof_prb, false); } N_row = (int)ceilf((float)N_tilde_vrb / (4 * P)) * P; N_null = 4 * N_row - N_tilde_vrb; @@ -278,13 +278,13 @@ int srslte_ra_dl_grant_to_grant_prb_allocation(const srslte_dci_dl_t* dci, if (n_tilde_prb_odd < nof_prb) { grant->prb_idx[0][n_tilde_prb_odd] = true; } else { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } else { if (n_tilde_prb_odd + N_gap - N_tilde_vrb / 2 < nof_prb) { grant->prb_idx[0][n_tilde_prb_odd + N_gap - N_tilde_vrb / 2] = true; } else { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } grant->nof_prb++; @@ -292,37 +292,37 @@ int srslte_ra_dl_grant_to_grant_prb_allocation(const srslte_dci_dl_t* dci, if (n_tilde_prb_even < nof_prb) { grant->prb_idx[1][n_tilde_prb_even] = true; } else { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } else { if (n_tilde_prb_even + N_gap - N_tilde_vrb / 2 < nof_prb) { grant->prb_idx[1][n_tilde_prb_even + N_gap - N_tilde_vrb / 2] = true; } else { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } } } break; default: - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_dl_fill_ra_mcs(srslte_ra_tb_t* tb, int last_tbs, uint32_t nprb, bool pdsch_use_tbs_index_alt) +int srsran_dl_fill_ra_mcs(srsran_ra_tb_t* tb, int last_tbs, uint32_t nprb, bool pdsch_use_tbs_index_alt) { // Get modulation - tb->mod = srslte_ra_dl_mod_from_mcs(tb->mcs_idx, pdsch_use_tbs_index_alt); + tb->mod = srsran_ra_dl_mod_from_mcs(tb->mcs_idx, pdsch_use_tbs_index_alt); // Get Transport block size index - int i_tbs = srslte_ra_tbs_idx_from_mcs(tb->mcs_idx, pdsch_use_tbs_index_alt, false); + int i_tbs = srsran_ra_tbs_idx_from_mcs(tb->mcs_idx, pdsch_use_tbs_index_alt, false); // If i_tbs = -1, TBS is determined from the latest PDCCH for this TB (7.1.7.2 36.213) int tbs = 0; if (i_tbs >= 0) { - tbs = srslte_ra_tbs_from_idx((uint32_t)i_tbs, nprb); + tbs = srsran_ra_tbs_from_idx((uint32_t)i_tbs, nprb); tb->tbs = tbs; } else { tb->tbs = last_tbs; @@ -333,19 +333,19 @@ int srslte_dl_fill_ra_mcs(srslte_ra_tb_t* tb, int last_tbs, uint32_t nprb, bool /* Modulation order and transport block size determination 7.1.7 in 36.213 * */ -static int dl_dci_compute_tb(bool pdsch_use_tbs_index_alt, const srslte_dci_dl_t* dci, srslte_pdsch_grant_t* grant) +static int dl_dci_compute_tb(bool pdsch_use_tbs_index_alt, const srsran_dci_dl_t* dci, srsran_pdsch_grant_t* grant) { uint32_t n_prb = 0; int tbs = -1; uint32_t i_tbs = 0; // Copy info and Enable/Disable TB - for (uint32_t i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { + for (uint32_t i = 0; i < SRSRAN_MAX_CODEWORDS; i++) { grant->tb[i].mcs_idx = dci->tb[i].mcs_idx; grant->tb[i].rv = dci->tb[i].rv; grant->tb[i].cw_idx = dci->tb[i].cw_idx; - if ((SRSLTE_DCI_IS_TB_EN(dci->tb[i]) && dci->format >= SRSLTE_DCI_FORMAT2) || - (dci->format < SRSLTE_DCI_FORMAT2 && i == 0)) { + if ((SRSRAN_DCI_IS_TB_EN(dci->tb[i]) && dci->format >= SRSRAN_DCI_FORMAT2) || + (dci->format < SRSRAN_DCI_FORMAT2 && i == 0)) { grant->tb[i].enabled = true; grant->nof_tb++; } else { @@ -358,123 +358,123 @@ static int dl_dci_compute_tb(bool pdsch_use_tbs_index_alt, const srslte_dci_dl_t // - if the PDSCH is assigned by a PDCCH/EPDCCH with DCI format 1/1B/1D/2/2A/2B/2C/2D with // - CRC scrambled by C-RNTI, // Otherwise, use 64QAM table (default table for R8). - if (dci->format == SRSLTE_DCI_FORMAT1A || !SRSLTE_RNTI_ISUSER(dci->rnti)) { + if (dci->format == SRSRAN_DCI_FORMAT1A || !SRSRAN_RNTI_ISUSER(dci->rnti)) { pdsch_use_tbs_index_alt = false; } - if (!SRSLTE_RNTI_ISUSER(dci->rnti) && !SRSLTE_RNTI_ISMBSFN(dci->rnti)) { - if (dci->format == SRSLTE_DCI_FORMAT1A) { - n_prb = dci->type2_alloc.n_prb1a == SRSLTE_RA_TYPE2_NPRB1A_2 ? 2 : 3; + if (!SRSRAN_RNTI_ISUSER(dci->rnti) && !SRSRAN_RNTI_ISMBSFN(dci->rnti)) { + if (dci->format == SRSRAN_DCI_FORMAT1A) { + n_prb = dci->type2_alloc.n_prb1a == SRSRAN_RA_TYPE2_NPRB1A_2 ? 2 : 3; i_tbs = dci->tb[0].mcs_idx; - tbs = srslte_ra_tbs_from_idx(i_tbs, n_prb); + tbs = srsran_ra_tbs_from_idx(i_tbs, n_prb); if (tbs < 0) { ERROR("Invalid TBS_index=%d or n_prb=%d", i_tbs, n_prb); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - } else if (dci->format == SRSLTE_DCI_FORMAT1C) { + } else if (dci->format == SRSRAN_DCI_FORMAT1C) { if (dci->tb[0].mcs_idx < 32) { tbs = tbs_format1c_table[dci->tb[0].mcs_idx]; } else { ERROR("Error decoding DCI: Invalid mcs_idx=%d in Format1C", dci->tb[0].mcs_idx); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } else { ERROR("Error decoding DCI: P/SI/RA-RNTI supports Format1A/1C only"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - grant->tb[0].mod = SRSLTE_MOD_QPSK; + grant->tb[0].mod = SRSRAN_MOD_QPSK; if (tbs >= 0) { grant->tb[0].tbs = (uint32_t)tbs; } else { ERROR("Invalid TBS=%d", tbs); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } else { if (dci->is_dwpts) { - n_prb = SRSLTE_MAX(1, 0.75 * grant->nof_prb); + n_prb = SRSRAN_MAX(1, 0.75 * grant->nof_prb); } else { n_prb = grant->nof_prb; } - for (uint32_t i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { + for (uint32_t i = 0; i < SRSRAN_MAX_CODEWORDS; i++) { if (grant->tb[i].enabled) { - grant->tb[i].tbs = srslte_dl_fill_ra_mcs(&grant->tb[i], grant->last_tbs[i], n_prb, pdsch_use_tbs_index_alt); + grant->tb[i].tbs = srsran_dl_fill_ra_mcs(&grant->tb[i], grant->last_tbs[i], n_prb, pdsch_use_tbs_index_alt); if (grant->tb[i].tbs < 0) { char str[128]; - srslte_dci_dl_info(dci, str, sizeof(str)); + srsran_dci_dl_info(dci, str, sizeof(str)); INFO("Error computing TBS from %s", str); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } else { grant->tb[i].tbs = 0; } } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -void srslte_ra_dl_compute_nof_re(const srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf, srslte_pdsch_grant_t* grant) +void srsran_ra_dl_compute_nof_re(const srsran_cell_t* cell, srsran_dl_sf_cfg_t* sf, srsran_pdsch_grant_t* grant) { // Compute number of RE - grant->nof_re = srslte_ra_dl_grant_nof_re(cell, sf, grant); - srslte_cp_t cp_ = SRSLTE_SF_NORM == sf->sf_type ? cell->cp : SRSLTE_CP_EXT; - if (cell->frame_type == SRSLTE_FDD) { - grant->nof_symb_slot[0] = SRSLTE_CP_NSYMB(cp_); - grant->nof_symb_slot[1] = SRSLTE_CP_NSYMB(cp_); + grant->nof_re = srsran_ra_dl_grant_nof_re(cell, sf, grant); + srsran_cp_t cp_ = SRSRAN_SF_NORM == sf->sf_type ? cell->cp : SRSRAN_CP_EXT; + if (cell->frame_type == SRSRAN_FDD) { + grant->nof_symb_slot[0] = SRSRAN_CP_NSYMB(cp_); + grant->nof_symb_slot[1] = SRSRAN_CP_NSYMB(cp_); } else { - if (srslte_sfidx_tdd_type(sf->tdd_config, sf->tti % 10) == SRSLTE_TDD_SF_S) { - grant->nof_symb_slot[0] = srslte_sfidx_tdd_nof_dw_slot(sf->tdd_config, 0, cp_); - grant->nof_symb_slot[1] = srslte_sfidx_tdd_nof_dw_slot(sf->tdd_config, 1, cp_); + if (srsran_sfidx_tdd_type(sf->tdd_config, sf->tti % 10) == SRSRAN_TDD_SF_S) { + grant->nof_symb_slot[0] = srsran_sfidx_tdd_nof_dw_slot(sf->tdd_config, 0, cp_); + grant->nof_symb_slot[1] = srsran_sfidx_tdd_nof_dw_slot(sf->tdd_config, 1, cp_); } else { - grant->nof_symb_slot[0] = SRSLTE_CP_NSYMB(cp_); - grant->nof_symb_slot[1] = SRSLTE_CP_NSYMB(cp_); + grant->nof_symb_slot[0] = SRSRAN_CP_NSYMB(cp_); + grant->nof_symb_slot[1] = SRSRAN_CP_NSYMB(cp_); } } - for (int i = 0; i < SRSLTE_MAX_TB; i++) { + for (int i = 0; i < SRSRAN_MAX_TB; i++) { /* Compute number of RE for first transport block */ if (grant->tb[i].enabled) { - grant->tb[i].nof_bits = grant->nof_re * srslte_mod_bits_x_symbol(grant->tb[i].mod); + grant->tb[i].nof_bits = grant->nof_re * srsran_mod_bits_x_symbol(grant->tb[i].mod); } } } /* Determine MIMO type based on number of cell ports and receive antennas, transport blocks and pinfo */ static int -config_mimo_type(const srslte_cell_t* cell, srslte_tm_t tm, const srslte_dci_dl_t* dci, srslte_pdsch_grant_t* grant) +config_mimo_type(const srsran_cell_t* cell, srsran_tm_t tm, const srsran_dci_dl_t* dci, srsran_pdsch_grant_t* grant) { - grant->tx_scheme = SRSLTE_TXSCHEME_PORT0; + grant->tx_scheme = SRSRAN_TXSCHEME_PORT0; bool valid_config = true; uint32_t nof_tb = grant->nof_tb; switch (tm) { /* Implemented Tx Modes */ - case SRSLTE_TM1: - case SRSLTE_TM2: + case SRSRAN_TM1: + case SRSRAN_TM2: if (cell->nof_ports > 1) { - grant->tx_scheme = SRSLTE_TXSCHEME_DIVERSITY; + grant->tx_scheme = SRSRAN_TXSCHEME_DIVERSITY; } else { - grant->tx_scheme = SRSLTE_TXSCHEME_PORT0; + grant->tx_scheme = SRSRAN_TXSCHEME_PORT0; } if (nof_tb != 1) { - ERROR("Wrong number of transport blocks (%d) for %s.", nof_tb, srslte_mimotype2str(grant->tx_scheme)); + ERROR("Wrong number of transport blocks (%d) for %s.", nof_tb, srsran_mimotype2str(grant->tx_scheme)); valid_config = false; } break; - case SRSLTE_TM3: + case SRSRAN_TM3: if (nof_tb == 1) { - grant->tx_scheme = SRSLTE_TXSCHEME_DIVERSITY; + grant->tx_scheme = SRSRAN_TXSCHEME_DIVERSITY; } else if (nof_tb == 2) { - grant->tx_scheme = SRSLTE_TXSCHEME_CDD; + grant->tx_scheme = SRSRAN_TXSCHEME_CDD; } else { ERROR("Invalid number of transport blocks (%d) for TM3", nof_tb); valid_config = false; } break; - case SRSLTE_TM4: + case SRSRAN_TM4: if (nof_tb == 1) { - grant->tx_scheme = (dci->pinfo == 0) ? SRSLTE_TXSCHEME_DIVERSITY : SRSLTE_TXSCHEME_SPATIALMUX; + grant->tx_scheme = (dci->pinfo == 0) ? SRSRAN_TXSCHEME_DIVERSITY : SRSRAN_TXSCHEME_SPATIALMUX; } else if (nof_tb == 2) { - grant->tx_scheme = SRSLTE_TXSCHEME_SPATIALMUX; + grant->tx_scheme = SRSRAN_TXSCHEME_SPATIALMUX; } else { ERROR("Invalid number of transport blocks (%d) for TM4", nof_tb); valid_config = false; @@ -482,10 +482,10 @@ config_mimo_type(const srslte_cell_t* cell, srslte_tm_t tm, const srslte_dci_dl_ break; /* Not implemented cases */ - case SRSLTE_TM5: - case SRSLTE_TM6: - case SRSLTE_TM7: - case SRSLTE_TM8: + case SRSRAN_TM5: + case SRSRAN_TM6: + case SRSRAN_TM7: + case SRSRAN_TM8: ERROR("Not implemented Tx mode (%d)", tm + 1); break; @@ -493,14 +493,14 @@ config_mimo_type(const srslte_cell_t* cell, srslte_tm_t tm, const srslte_dci_dl_ default: ERROR("Wrong Tx mode (%d)", tm + 1); } - return valid_config ? SRSLTE_SUCCESS : SRSLTE_ERROR; + return valid_config ? SRSRAN_SUCCESS : SRSRAN_ERROR; } /* Translates Precoding Information (pinfo) to Precoding matrix Index (pmi) as 3GPP 36.212 Table 5.3.3.1.5-4 */ -static int config_mimo_pmi(const srslte_cell_t* cell, const srslte_dci_dl_t* dci, srslte_pdsch_grant_t* grant) +static int config_mimo_pmi(const srsran_cell_t* cell, const srsran_dci_dl_t* dci, srsran_pdsch_grant_t* grant) { uint32_t nof_tb = grant->nof_tb; - if (grant->tx_scheme == SRSLTE_TXSCHEME_SPATIALMUX) { + if (grant->tx_scheme == SRSRAN_TXSCHEME_SPATIALMUX) { if (nof_tb == 1) { if (dci->pinfo > 0 && dci->pinfo < 5) { grant->pmi = dci->pinfo - 1; @@ -512,8 +512,8 @@ static int config_mimo_pmi(const srslte_cell_t* cell, const srslte_dci_dl_t* dci if (dci->pinfo == 2) { ERROR("Not implemented codebook index (nof_tb=%d (%d/%d), pinfo=%d)", nof_tb, - SRSLTE_DCI_IS_TB_EN(grant->tb[0]), - SRSLTE_DCI_IS_TB_EN(grant->tb[1]), + SRSRAN_DCI_IS_TB_EN(grant->tb[0]), + SRSRAN_DCI_IS_TB_EN(grant->tb[1]), dci->pinfo); return -1; } else if (dci->pinfo > 2) { @@ -528,42 +528,42 @@ static int config_mimo_pmi(const srslte_cell_t* cell, const srslte_dci_dl_t* dci } /* Determine number of MIMO layers */ -static int config_mimo_layers(const srslte_cell_t* cell, const srslte_dci_dl_t* dci, srslte_pdsch_grant_t* grant) +static int config_mimo_layers(const srsran_cell_t* cell, const srsran_dci_dl_t* dci, srsran_pdsch_grant_t* grant) { uint32_t nof_tb = grant->nof_tb; switch (grant->tx_scheme) { - case SRSLTE_TXSCHEME_PORT0: + case SRSRAN_TXSCHEME_PORT0: if (nof_tb != 1) { ERROR("Wrong number of transport blocks (%d) for single antenna.", nof_tb); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } grant->nof_layers = 1; break; - case SRSLTE_TXSCHEME_DIVERSITY: + case SRSRAN_TXSCHEME_DIVERSITY: if (nof_tb != 1) { ERROR("Wrong number of transport blocks (%d) for transmit diversity.", nof_tb); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } grant->nof_layers = cell->nof_ports; break; - case SRSLTE_TXSCHEME_SPATIALMUX: + case SRSRAN_TXSCHEME_SPATIALMUX: if (nof_tb == 1) { grant->nof_layers = 1; } else if (nof_tb == 2) { grant->nof_layers = 2; } else { ERROR("Wrong number of transport blocks (%d) for spatial multiplexing.", nof_tb); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } INFO("PDSCH configured for Spatial Multiplex; nof_codewords=%d; nof_layers=%d; pmi=%d", nof_tb, grant->nof_layers, grant->pmi); break; - case SRSLTE_TXSCHEME_CDD: + case SRSRAN_TXSCHEME_CDD: if (nof_tb != 2) { ERROR("Wrong number of transport blocks (%d) for CDD.", nof_tb); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } grant->nof_layers = 2; break; @@ -572,7 +572,7 @@ static int config_mimo_layers(const srslte_cell_t* cell, const srslte_dci_dl_t* } static int -config_mimo(const srslte_cell_t* cell, srslte_tm_t tm, const srslte_dci_dl_t* dci, srslte_pdsch_grant_t* grant) +config_mimo(const srsran_cell_t* cell, srsran_tm_t tm, const srsran_dci_dl_t* dci, srsran_pdsch_grant_t* grant) { if (config_mimo_type(cell, tm, dci, grant)) { ERROR("Configuring MIMO type"); @@ -598,49 +598,49 @@ config_mimo(const srslte_cell_t* cell, srslte_tm_t tm, const srslte_dci_dl_t* dc **********/ /** Compute the DL grant parameters */ -int srslte_ra_dl_dci_to_grant(const srslte_cell_t* cell, - srslte_dl_sf_cfg_t* sf, - srslte_tm_t tm, +int srsran_ra_dl_dci_to_grant(const srsran_cell_t* cell, + srsran_dl_sf_cfg_t* sf, + srsran_tm_t tm, bool pdsch_use_tbs_index_alt, - const srslte_dci_dl_t* dci, - srslte_pdsch_grant_t* grant) + const srsran_dci_dl_t* dci, + srsran_pdsch_grant_t* grant) { - bzero(grant, sizeof(srslte_pdsch_grant_t)); + bzero(grant, sizeof(srsran_pdsch_grant_t)); // Compute PRB allocation - int ret = srslte_ra_dl_grant_to_grant_prb_allocation(dci, grant, cell->nof_prb); - if (ret == SRSLTE_SUCCESS) { + int ret = srsran_ra_dl_grant_to_grant_prb_allocation(dci, grant, cell->nof_prb); + if (ret == SRSRAN_SUCCESS) { // Compute MCS ret = dl_dci_compute_tb(pdsch_use_tbs_index_alt, dci, grant); - if (ret == SRSLTE_SUCCESS) { + if (ret == SRSRAN_SUCCESS) { // Compute number of RE and number of ack_value in grant - srslte_ra_dl_compute_nof_re(cell, sf, grant); + srsran_ra_dl_compute_nof_re(cell, sf, grant); // Apply Section 7.1.7.3. If RA-RNTI and Format1C rv_idx=0 - if (dci->format == SRSLTE_DCI_FORMAT1C) { - if ((SRSLTE_RNTI_ISRAR(dci->rnti)) || dci->rnti == SRSLTE_PRNTI) { - for (uint32_t i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { + if (dci->format == SRSRAN_DCI_FORMAT1C) { + if ((SRSRAN_RNTI_ISRAR(dci->rnti)) || dci->rnti == SRSRAN_PRNTI) { + for (uint32_t i = 0; i < SRSRAN_MAX_CODEWORDS; i++) { grant->tb[i].rv = 0; } } } } else { INFO("Configuring TB Info"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } else { ERROR("Configuring resource allocation"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Configure MIMO for this TM return config_mimo(cell, tm, dci, grant); } -uint32_t srslte_ra_dl_approx_nof_re(const srslte_cell_t* cell, uint32_t nof_prb, uint32_t nof_ctrl_symbols) +uint32_t srsran_ra_dl_approx_nof_re(const srsran_cell_t* cell, uint32_t nof_prb, uint32_t nof_ctrl_symbols) { uint32_t nof_refs = 0; - uint32_t nof_symb = 2 * SRSLTE_CP_NSYMB(cell->cp) - nof_ctrl_symbols; + uint32_t nof_symb = 2 * SRSRAN_CP_NSYMB(cell->cp) - nof_ctrl_symbols; switch (cell->nof_ports) { case 1: nof_refs = 2 * 3; @@ -652,11 +652,11 @@ uint32_t srslte_ra_dl_approx_nof_re(const srslte_cell_t* cell, uint32_t nof_prb, nof_refs = 4 * 4; break; } - return nof_prb * (nof_symb * SRSLTE_NRE - nof_refs); + return nof_prb * (nof_symb * SRSRAN_NRE - nof_refs); } /* Computes the number of RE for each PRB in the prb_dist structure */ -uint32_t srslte_ra_dl_grant_nof_re(const srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf, srslte_pdsch_grant_t* grant) +uint32_t srsran_ra_dl_grant_nof_re(const srsran_cell_t* cell, srsran_dl_sf_cfg_t* sf, srsran_pdsch_grant_t* grant) { uint32_t j, s; // Compute number of RE per PRB @@ -671,24 +671,24 @@ uint32_t srslte_ra_dl_grant_nof_re(const srslte_cell_t* cell, srslte_dl_sf_cfg_t return nof_re; } -static uint32_t print_multi(char* info_str, uint32_t n, uint32_t len, srslte_pdsch_grant_t* grant, uint32_t value_id) +static uint32_t print_multi(char* info_str, uint32_t n, uint32_t len, srsran_pdsch_grant_t* grant, uint32_t value_id) { - for (uint32_t i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { + for (uint32_t i = 0; i < SRSRAN_MAX_CODEWORDS; i++) { if (grant->tb[i].enabled) { switch (value_id) { case 0: - n = srslte_print_check(info_str, len, n, "%d", grant->tb[i].rv); + n = srsran_print_check(info_str, len, n, "%d", grant->tb[i].rv); break; case 1: - n = srslte_print_check(info_str, len, n, "%d", grant->tb[i].tbs / 8); + n = srsran_print_check(info_str, len, n, "%d", grant->tb[i].tbs / 8); break; case 2: - n = srslte_print_check(info_str, len, n, "%d", srslte_mod_bits_x_symbol(grant->tb[i].mod)); + n = srsran_print_check(info_str, len, n, "%d", srsran_mod_bits_x_symbol(grant->tb[i].mod)); break; } - if (i < SRSLTE_MAX_CODEWORDS - 1) { + if (i < SRSRAN_MAX_CODEWORDS - 1) { if (grant->tb[i + 1].enabled) { - n = srslte_print_check(info_str, len, n, "/"); + n = srsran_print_check(info_str, len, n, "/"); } } } @@ -696,32 +696,32 @@ static uint32_t print_multi(char* info_str, uint32_t n, uint32_t len, srslte_pds return n; } -uint32_t srslte_ra_dl_info(srslte_pdsch_grant_t* grant, char* info_str, uint32_t len) +uint32_t srsran_ra_dl_info(srsran_pdsch_grant_t* grant, char* info_str, uint32_t len) { int n = 0; - n = srslte_print_check(info_str, len, n, ", nof_prb=%d, nof_re=%d", grant->nof_prb, grant->nof_re); + n = srsran_print_check(info_str, len, n, ", nof_prb=%d, nof_re=%d", grant->nof_prb, grant->nof_re); - n = srslte_print_check(info_str, len, n, ", tbs={", 0); + n = srsran_print_check(info_str, len, n, ", tbs={", 0); n = print_multi(info_str, n, len, grant, 1); - n = srslte_print_check(info_str, len, n, "}", 0); - n = srslte_print_check(info_str, len, n, ", mod={", 0); + n = srsran_print_check(info_str, len, n, "}", 0); + n = srsran_print_check(info_str, len, n, ", mod={", 0); n = print_multi(info_str, n, len, grant, 2); - n = srslte_print_check(info_str, len, n, "}", 0); - n = srslte_print_check(info_str, len, n, ", rv={", 0); + n = srsran_print_check(info_str, len, n, "}", 0); + n = srsran_print_check(info_str, len, n, ", rv={", 0); n = print_multi(info_str, n, len, grant, 0); - n = srslte_print_check(info_str, len, n, "}", 0); + n = srsran_print_check(info_str, len, n, "}", 0); - if (grant->tx_scheme != SRSLTE_TXSCHEME_PORT0) { - n = srslte_print_check(info_str, + if (grant->tx_scheme != SRSRAN_TXSCHEME_PORT0) { + n = srsran_print_check(info_str, len, n, ", tx=%s, nof_tb=%d, nof_l=%d", - srslte_mimotype2str(grant->tx_scheme), + srsran_mimotype2str(grant->tx_scheme), grant->nof_tb, grant->nof_layers); - if (grant->tx_scheme == SRSLTE_TXSCHEME_SPATIALMUX) { - n = srslte_print_check(info_str, len, n, ", pmi=%d", grant->pmi); + if (grant->tx_scheme == SRSRAN_TXSCHEME_SPATIALMUX) { + n = srsran_print_check(info_str, len, n, ", pmi=%d", grant->pmi); } } return n; diff --git a/lib/src/phy/phch/ra_dl_nr.c b/lib/src/phy/phch/ra_dl_nr.c index 9acee8cc6..b8419d08b 100644 --- a/lib/src/phy/phch/ra_dl_nr.c +++ b/lib/src/phy/phch/ra_dl_nr.c @@ -2,16 +2,16 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of * the distribution. * */ -#include "srslte/phy/phch/ra_dl_nr.h" +#include "srsran/phy/phch/ra_dl_nr.h" #include "ra_helper.h" -#include "srslte/phy/utils/debug.h" +#include "srsran/phy/utils/debug.h" // Validate S and L combination for TypeA time domain resource allocation static bool check_time_ra_typeA(uint32_t* S, uint32_t* L) @@ -47,153 +47,153 @@ static bool check_time_ra_typeB(uint32_t* S, uint32_t* L) return false; } -bool srslte_ra_dl_nr_time_validate(srslte_sch_grant_nr_t* grant) +bool srsran_ra_dl_nr_time_validate(srsran_sch_grant_nr_t* grant) { - if (grant->mapping == srslte_sch_mapping_type_A) { + if (grant->mapping == srsran_sch_mapping_type_A) { return check_time_ra_typeA(&grant->S, &grant->L); } else { return check_time_ra_typeB(&grant->S, &grant->L); } } -int srslte_ra_dl_nr_time_default_A(uint32_t m, srslte_dmrs_sch_typeA_pos_t dmrs_typeA_pos, srslte_sch_grant_nr_t* grant) +int srsran_ra_dl_nr_time_default_A(uint32_t m, srsran_dmrs_sch_typeA_pos_t dmrs_typeA_pos, srsran_sch_grant_nr_t* grant) { if (grant == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } - if (m >= SRSLTE_MAX_NOF_DL_ALLOCATION) { + if (m >= SRSRAN_MAX_NOF_DL_ALLOCATION) { ERROR("m (%d) is out-of-range", m); - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } // Select k0 grant->k = 0; // Select PDSCH mapping - static srslte_sch_mapping_type_t pdsch_mapping_lut[16] = {srslte_sch_mapping_type_A, - srslte_sch_mapping_type_A, - srslte_sch_mapping_type_A, - srslte_sch_mapping_type_A, - srslte_sch_mapping_type_A, - srslte_sch_mapping_type_B, - srslte_sch_mapping_type_B, - srslte_sch_mapping_type_B, - srslte_sch_mapping_type_B, - srslte_sch_mapping_type_B, - srslte_sch_mapping_type_B, - srslte_sch_mapping_type_A, - srslte_sch_mapping_type_A, - srslte_sch_mapping_type_A, - srslte_sch_mapping_type_B, - srslte_sch_mapping_type_B}; + static srsran_sch_mapping_type_t pdsch_mapping_lut[16] = {srsran_sch_mapping_type_A, + srsran_sch_mapping_type_A, + srsran_sch_mapping_type_A, + srsran_sch_mapping_type_A, + srsran_sch_mapping_type_A, + srsran_sch_mapping_type_B, + srsran_sch_mapping_type_B, + srsran_sch_mapping_type_B, + srsran_sch_mapping_type_B, + srsran_sch_mapping_type_B, + srsran_sch_mapping_type_B, + srsran_sch_mapping_type_A, + srsran_sch_mapping_type_A, + srsran_sch_mapping_type_A, + srsran_sch_mapping_type_B, + srsran_sch_mapping_type_B}; grant->mapping = pdsch_mapping_lut[m]; - static uint32_t S_pos2[SRSLTE_MAX_NOF_DL_ALLOCATION] = {2, 2, 2, 2, 2, 9, 4, 5, 5, 9, 12, 1, 1, 2, 4, 8}; - static uint32_t L_pos2[SRSLTE_MAX_NOF_DL_ALLOCATION] = {12, 10, 9, 7, 5, 4, 4, 7, 2, 2, 2, 13, 6, 4, 7, 4}; - static uint32_t S_pos3[SRSLTE_MAX_NOF_DL_ALLOCATION] = {3, 3, 3, 3, 3, 10, 6, 5, 5, 9, 12, 1, 1, 2, 4, 8}; - static uint32_t L_pos3[SRSLTE_MAX_NOF_DL_ALLOCATION] = {11, 9, 8, 6, 4, 4, 4, 7, 2, 2, 2, 13, 6, 4, 7, 4}; + static uint32_t S_pos2[SRSRAN_MAX_NOF_DL_ALLOCATION] = {2, 2, 2, 2, 2, 9, 4, 5, 5, 9, 12, 1, 1, 2, 4, 8}; + static uint32_t L_pos2[SRSRAN_MAX_NOF_DL_ALLOCATION] = {12, 10, 9, 7, 5, 4, 4, 7, 2, 2, 2, 13, 6, 4, 7, 4}; + static uint32_t S_pos3[SRSRAN_MAX_NOF_DL_ALLOCATION] = {3, 3, 3, 3, 3, 10, 6, 5, 5, 9, 12, 1, 1, 2, 4, 8}; + static uint32_t L_pos3[SRSRAN_MAX_NOF_DL_ALLOCATION] = {11, 9, 8, 6, 4, 4, 4, 7, 2, 2, 2, 13, 6, 4, 7, 4}; // Select start symbol (S) and length (L) switch (dmrs_typeA_pos) { - case srslte_dmrs_sch_typeA_pos_2: + case srsran_dmrs_sch_typeA_pos_2: grant->S = S_pos2[m]; grant->L = L_pos2[m]; break; - case srslte_dmrs_sch_typeA_pos_3: + case srsran_dmrs_sch_typeA_pos_3: grant->S = S_pos3[m]; grant->L = L_pos3[m]; break; default: ERROR("Undefined case (%d)", dmrs_typeA_pos); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -static void ra_dl_nr_time_hl(const srslte_sch_time_ra_t* hl_ra_cfg, srslte_sch_grant_nr_t* grant) +static void ra_dl_nr_time_hl(const srsran_sch_time_ra_t* hl_ra_cfg, srsran_sch_grant_nr_t* grant) { // Compute S and L from SLIV from higher layers - ra_helper_compute_s_and_l(SRSLTE_NSYMB_PER_SLOT_NR, hl_ra_cfg->sliv, &grant->S, &grant->L); + ra_helper_compute_s_and_l(SRSRAN_NSYMB_PER_SLOT_NR, hl_ra_cfg->sliv, &grant->S, &grant->L); grant->k = hl_ra_cfg->k; grant->mapping = hl_ra_cfg->mapping_type; } -int srslte_ra_dl_nr_time(const srslte_sch_hl_cfg_nr_t* cfg, - const srslte_rnti_type_t rnti_type, - const srslte_search_space_type_t ss_type, +int srsran_ra_dl_nr_time(const srsran_sch_hl_cfg_nr_t* cfg, + const srsran_rnti_type_t rnti_type, + const srsran_search_space_type_t ss_type, const uint32_t coreset_id, const uint8_t m, - srslte_sch_grant_nr_t* grant) + srsran_sch_grant_nr_t* grant) { if (cfg == NULL || grant == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } - if (m >= SRSLTE_MAX_NOF_DL_ALLOCATION) { + if (m >= SRSRAN_MAX_NOF_DL_ALLOCATION) { ERROR("m (%d) is out-of-range", m); - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } // Determine which PDSCH Time domain RA configuration to apply (TS 38.214 Table 5.1.2.1.1-1) - if (rnti_type == srslte_rnti_type_si && ss_type == srslte_search_space_type_common_0) { + if (rnti_type == srsran_rnti_type_si && ss_type == srsran_search_space_type_common_0) { // Row 1 ERROR("Row not implemented"); - } else if (rnti_type == srslte_rnti_type_si && ss_type == srslte_search_space_type_common_0A) { + } else if (rnti_type == srsran_rnti_type_si && ss_type == srsran_search_space_type_common_0A) { // Row 2 ERROR("Row not implemented"); - } else if ((rnti_type == srslte_rnti_type_ra || rnti_type == srslte_rnti_type_tc) && - ss_type == srslte_search_space_type_common_1) { + } else if ((rnti_type == srsran_rnti_type_ra || rnti_type == srsran_rnti_type_tc) && + ss_type == srsran_search_space_type_common_1) { // Row 3 if (cfg->nof_common_time_ra > 0) { ra_dl_nr_time_hl(&cfg->common_time_ra[m], grant); } else { // Note: Only Default A is supported, which corresponds SS/PBCH block and coreset mux pattern 1 - srslte_ra_dl_nr_time_default_A(m, cfg->typeA_pos, grant); + srsran_ra_dl_nr_time_default_A(m, cfg->typeA_pos, grant); } - } else if (rnti_type == srslte_rnti_type_p && ss_type == srslte_search_space_type_common_2) { + } else if (rnti_type == srsran_rnti_type_p && ss_type == srsran_search_space_type_common_2) { // Row 4 ERROR("Row not implemented"); - } else if ((rnti_type == srslte_rnti_type_c || rnti_type == srslte_rnti_type_mcs_c || - rnti_type == srslte_rnti_type_cs) && - SRSLTE_SEARCH_SPACE_IS_COMMON(ss_type) && coreset_id == 0) { + } else if ((rnti_type == srsran_rnti_type_c || rnti_type == srsran_rnti_type_mcs_c || + rnti_type == srsran_rnti_type_cs) && + SRSRAN_SEARCH_SPACE_IS_COMMON(ss_type) && coreset_id == 0) { // Row 5 if (cfg->nof_common_time_ra > 0) { ra_dl_nr_time_hl(&cfg->common_time_ra[m], grant); } else { - srslte_ra_dl_nr_time_default_A(m, cfg->typeA_pos, grant); + srsran_ra_dl_nr_time_default_A(m, cfg->typeA_pos, grant); } - } else if ((rnti_type == srslte_rnti_type_c || rnti_type == srslte_rnti_type_mcs_c || - rnti_type == srslte_rnti_type_cs) && - ((SRSLTE_SEARCH_SPACE_IS_COMMON(ss_type) && coreset_id != 0) || ss_type == srslte_search_space_type_ue)) { + } else if ((rnti_type == srsran_rnti_type_c || rnti_type == srsran_rnti_type_mcs_c || + rnti_type == srsran_rnti_type_cs) && + ((SRSRAN_SEARCH_SPACE_IS_COMMON(ss_type) && coreset_id != 0) || ss_type == srsran_search_space_type_ue)) { // Row 6 if (cfg->nof_dedicated_time_ra > 0) { ra_dl_nr_time_hl(&cfg->dedicated_time_ra[m], grant); } else if (cfg->nof_common_time_ra > 0) { ra_dl_nr_time_hl(&cfg->common_time_ra[m], grant); } else { - srslte_ra_dl_nr_time_default_A(m, cfg->typeA_pos, grant); + srsran_ra_dl_nr_time_default_A(m, cfg->typeA_pos, grant); } } else { ERROR("Unhandled case"); } // Validate S and L parameters - if (!srslte_ra_dl_nr_time_validate(grant)) { + if (!srsran_ra_dl_nr_time_validate(grant)) { ERROR("Invalid Time RA S=%d; L=%d; m=%d", grant->S, grant->L, m); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_ra_dl_nr_nof_dmrs_cdm_groups_without_data_format_1_0(const srslte_dmrs_sch_cfg_t* cfg, - srslte_sch_grant_nr_t* grant) +int srsran_ra_dl_nr_nof_dmrs_cdm_groups_without_data_format_1_0(const srsran_dmrs_sch_cfg_t* cfg, + srsran_sch_grant_nr_t* grant) { if (cfg == NULL || grant == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } /* According to TS 38.214 V15.10.0 5.1.6.1.3 CSI-RS for mobility: @@ -202,17 +202,17 @@ int srslte_ra_dl_nr_nof_dmrs_cdm_groups_without_data_format_1_0(const srslte_dmr * shall assume that the number of DM-RS CDM groups without data is 2 which corresponds to CDM group {0,1} for all * other cases. */ - if (cfg->length == srslte_dmrs_sch_len_2) { + if (cfg->length == srsran_dmrs_sch_len_2) { grant->nof_dmrs_cdm_groups_without_data = 1; } else { grant->nof_dmrs_cdm_groups_without_data = 2; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } /* RBG size for type0 scheduling as in table 5.1.2.2.1-1 of 36.214 */ -uint32_t srslte_ra_dl_nr_type0_P(uint32_t bwp_size, bool config_is_1) +uint32_t srsran_ra_dl_nr_type0_P(uint32_t bwp_size, bool config_is_1) { if (bwp_size <= 36) { return config_is_1 ? 2 : 4; @@ -225,12 +225,12 @@ uint32_t srslte_ra_dl_nr_type0_P(uint32_t bwp_size, bool config_is_1) } } -static int ra_freq_type0(const srslte_carrier_nr_t* carrier, - const srslte_sch_hl_cfg_nr_t* cfg, - const srslte_dci_dl_nr_t* dci_dl, - srslte_sch_grant_nr_t* grant) +static int ra_freq_type0(const srsran_carrier_nr_t* carrier, + const srsran_sch_hl_cfg_nr_t* cfg, + const srsran_dci_dl_nr_t* dci_dl, + srsran_sch_grant_nr_t* grant) { - uint32_t P = srslte_ra_dl_nr_type0_P(carrier->nof_prb, cfg->rbg_size_cfg_1); + uint32_t P = srsran_ra_dl_nr_type0_P(carrier->nof_prb, cfg->rbg_size_cfg_1); uint32_t N_rbg = (int)ceilf((float)(carrier->nof_prb + (carrier->start % P)) / P); uint32_t rbg_offset = 0; @@ -254,22 +254,22 @@ static int ra_freq_type0(const srslte_carrier_nr_t* carrier, return 0; } -int srslte_ra_dl_nr_freq(const srslte_carrier_nr_t* carrier, - const srslte_sch_hl_cfg_nr_t* cfg, - const srslte_dci_dl_nr_t* dci_dl, - srslte_sch_grant_nr_t* grant) +int srsran_ra_dl_nr_freq(const srsran_carrier_nr_t* carrier, + const srsran_sch_hl_cfg_nr_t* cfg, + const srsran_dci_dl_nr_t* dci_dl, + srsran_sch_grant_nr_t* grant) { if (cfg == NULL || grant == NULL || dci_dl == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } // RA scheme - if (dci_dl->format == srslte_dci_format_nr_1_0) { + if (dci_dl->format == srsran_dci_format_nr_1_0) { // when the scheduling grant is received with DCI format 1_0 , then downlink resource allocation type 1 is used. return ra_helper_freq_type1(carrier->nof_prb, dci_dl->freq_domain_assigment, grant); } ra_freq_type0(carrier, cfg, dci_dl, grant); ERROR("Only DCI Format 1_0 is supported"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } diff --git a/lib/src/phy/phch/ra_helper.h b/lib/src/phy/phch/ra_helper.h index 0e27b6216..bdb0c45a0 100644 --- a/lib/src/phy/phch/ra_helper.h +++ b/lib/src/phy/phch/ra_helper.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,10 +10,10 @@ * */ -#ifndef SRSLTE_RA_HELPER_H -#define SRSLTE_RA_HELPER_H +#ifndef SRSRAN_RA_HELPER_H +#define SRSRAN_RA_HELPER_H -#include "srslte/phy/utils/debug.h" +#include "srsran/phy/utils/debug.h" #include static inline void ra_helper_compute_s_and_l(uint32_t N, uint32_t v, uint32_t* S, uint32_t* L) @@ -29,7 +29,7 @@ static inline void ra_helper_compute_s_and_l(uint32_t N, uint32_t v, uint32_t* S } } -static int ra_helper_freq_type1(uint32_t N_bwp_size, uint32_t riv, srslte_sch_grant_nr_t* grant) +static int ra_helper_freq_type1(uint32_t N_bwp_size, uint32_t riv, srsran_sch_grant_nr_t* grant) { uint32_t start = 0; uint32_t len = 0; @@ -37,7 +37,7 @@ static int ra_helper_freq_type1(uint32_t N_bwp_size, uint32_t riv, srslte_sch_gr if (start + len > N_bwp_size) { ERROR("RIV 0x%x for BWP size %d resulted in freq=%d:%d", riv, N_bwp_size, start, len); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } for (uint32_t i = 0; i < start; i++) { @@ -48,12 +48,12 @@ static int ra_helper_freq_type1(uint32_t N_bwp_size, uint32_t riv, srslte_sch_gr grant->prb_idx[i] = true; } - for (uint32_t i = start + len; i < SRSLTE_MAX_PRB_NR; i++) { + for (uint32_t i = start + len; i < SRSRAN_MAX_PRB_NR; i++) { grant->prb_idx[i] = false; } grant->nof_prb = len; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -#endif // SRSLTE_RA_HELPER_H +#endif // SRSRAN_RA_HELPER_H diff --git a/lib/src/phy/phch/ra_nbiot.c b/lib/src/phy/phch/ra_nbiot.c index 395a6e6cb..464b22da6 100644 --- a/lib/src/phy/phch/ra_nbiot.c +++ b/lib/src/phy/phch/ra_nbiot.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,11 +10,11 @@ * */ -#include "srslte/phy/phch/ra_nbiot.h" -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/utils/bit.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/phch/ra_nbiot.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/utils/bit.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" #include "tbs_tables_nbiot.h" #include #include @@ -61,22 +61,22 @@ const int first_frame_sib1[3][4] = {{0, 16, 32, 48}, {0, 16, -1, -1}, {0, 1, -1, const int i_mcs_to_i_tbs_npusch[11] = {0, 2, 1, 3, 4, 5, 6, 7, 8, 9, 10}; /// ACK/NACH resource computation TS 36.213 Section 16.4.2, for 15kHz and 3.75kHz -const int ack_nack_resource_field_to_sc[SRSLTE_NPUSCH_SC_SPACING_NITEMS][16] = { +const int ack_nack_resource_field_to_sc[SRSRAN_NPUSCH_SC_SPACING_NITEMS][16] = { {0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3}, {38, 39, 40, 41, 42, 43, 44, 45, 38, 39, 40, 41, 42, 43, 44, 45}}; -const int ack_nack_resource_field_to_k0[SRSLTE_NPUSCH_SC_SPACING_NITEMS][16] = { +const int ack_nack_resource_field_to_k0[SRSRAN_NPUSCH_SC_SPACING_NITEMS][16] = { {13, 13, 13, 13, 15, 15, 15, 15, 17, 17, 17, 17, 18, 18, 18, 18}, {13, 13, 13, 13, 13, 13, 13, 13, 21, 21, 21, 21, 21, 21, 21, 21}}; /// Calculate the number of resource elements per subframe that carry data -uint32_t srslte_ra_nbiot_dl_grant_nof_re(srslte_nbiot_cell_t cell, uint32_t l_start) +uint32_t srsran_ra_nbiot_dl_grant_nof_re(srsran_nbiot_cell_t cell, uint32_t l_start) { /// start with one full PRB - uint32_t re = SRSLTE_CP_NORM_SF_NSYMB * SRSLTE_NRE; + uint32_t re = SRSRAN_CP_NORM_SF_NSYMB * SRSRAN_NRE; /// remove lstart number of symbols - re -= l_start * SRSLTE_NRE; + re -= l_start * SRSRAN_NRE; /// remove NRS switch (cell.nof_ports) { @@ -90,7 +90,7 @@ uint32_t srslte_ra_nbiot_dl_grant_nof_re(srslte_nbiot_cell_t cell, uint32_t l_st } /// remove CRS for inband deployments - if (cell.mode <= SRSLTE_NBIOT_MODE_INBAND_DIFFERENT_PCI) { + if (cell.mode <= SRSRAN_NBIOT_MODE_INBAND_DIFFERENT_PCI) { switch (cell.base.nof_ports) { case 1: case 2: @@ -107,30 +107,30 @@ uint32_t srslte_ra_nbiot_dl_grant_nof_re(srslte_nbiot_cell_t cell, uint32_t l_st return re; } -void srslte_ra_nbiot_dl_grant_to_nbits(srslte_ra_nbiot_dl_grant_t* grant, - srslte_nbiot_cell_t cell, +void srsran_ra_nbiot_dl_grant_to_nbits(srsran_ra_nbiot_dl_grant_t* grant, + srsran_nbiot_cell_t cell, uint32_t sf_idx, - srslte_ra_nbits_t* nbits) + srsran_ra_nbits_t* nbits) { /// Compute number of RE nbits->lstart = grant->l_start; - nbits->nof_re = srslte_ra_nbiot_dl_grant_nof_re(cell, grant->l_start); - nbits->nof_symb = 2 * SRSLTE_CP_NSYMB(cell.base.cp) - nbits->lstart; + nbits->nof_re = srsran_ra_nbiot_dl_grant_nof_re(cell, grant->l_start); + nbits->nof_symb = 2 * SRSRAN_CP_NSYMB(cell.base.cp) - nbits->lstart; nbits->nof_bits = nbits->nof_re * grant->Qm; } /// Transport block size determination 16.4.1.5 in 36.213 v13.2.0 -static int nbiot_dl_dci_to_grant_mcs(srslte_ra_nbiot_dl_dci_t* dci, srslte_ra_nbiot_dl_grant_t* grant) +static int nbiot_dl_dci_to_grant_mcs(srsran_ra_nbiot_dl_dci_t* dci, srsran_ra_nbiot_dl_grant_t* grant) { int tbs = -1; uint32_t i_tbs = 0, i_sf = 0; - grant->mcs[0].mod = SRSLTE_MOD_QPSK; + grant->mcs[0].mod = SRSRAN_MOD_QPSK; // limit config values in DCI - dci->alloc.sched_info_sib1 = SRSLTE_MIN(dci->alloc.sched_info_sib1, MAX_I_TBS_VAL_SIB); - dci->mcs_idx = SRSLTE_MIN(dci->mcs_idx, MAX_I_TBS_VAL); - dci->alloc.i_sf = SRSLTE_MIN(dci->alloc.i_sf, MAX_I_SF_VAL); + dci->alloc.sched_info_sib1 = SRSRAN_MIN(dci->alloc.sched_info_sib1, MAX_I_TBS_VAL_SIB); + dci->mcs_idx = SRSRAN_MIN(dci->mcs_idx, MAX_I_TBS_VAL); + dci->alloc.i_sf = SRSRAN_MIN(dci->alloc.i_sf, MAX_I_SF_VAL); if (dci->alloc.has_sib1) { i_tbs = dci->alloc.sched_info_sib1; @@ -143,30 +143,30 @@ static int nbiot_dl_dci_to_grant_mcs(srslte_ra_nbiot_dl_dci_t* dci, srslte_ra_nb if (tbs <= 0) { INFO("Unsupported resource allocation specified: i_tbs=%d [0,12], i_sf=%d [0,7]", i_tbs, i_sf); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } else { grant->mcs[0].tbs = (uint32_t)tbs; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } } -int srslte_ra_n_rep_from_dci(srslte_ra_nbiot_dl_dci_t* dci) +int srsran_ra_n_rep_from_dci(srsran_ra_nbiot_dl_dci_t* dci) { return (dci->alloc.has_sib1 ? n_rep_table_sib1[dci->alloc.sched_info_sib1] : n_rep_table[dci->alloc.i_rep]); } -int srslte_ra_n_rep_sib1_nb(srslte_mib_nb_t* mib) +int srsran_ra_n_rep_sib1_nb(srsran_mib_nb_t* mib) { return n_rep_table_sib1[mib->sched_info_sib1]; } -int srslte_ra_nbiot_get_sib1_tbs(srslte_mib_nb_t* mib) +int srsran_ra_nbiot_get_sib1_tbs(srsran_mib_nb_t* mib) { - uint32_t i_tbs = SRSLTE_MIN(mib->sched_info_sib1, MAX_I_TBS_VAL_SIB); + uint32_t i_tbs = SRSRAN_MIN(mib->sched_info_sib1, MAX_I_TBS_VAL_SIB); return tbs_table_nbiot_sib1[i_tbs]; } -int srslte_ra_nbiot_get_npdsch_tbs(uint32_t i_tbs, uint32_t i_sf) +int srsran_ra_nbiot_get_npdsch_tbs(uint32_t i_tbs, uint32_t i_sf) { if (i_tbs <= 12 && i_sf <= 7) { return tbs_table_nbiot[i_tbs][i_sf]; @@ -175,7 +175,7 @@ int srslte_ra_nbiot_get_npdsch_tbs(uint32_t i_tbs, uint32_t i_sf) } } -int srslte_ra_nbiot_get_npusch_tbs(uint32_t i_tbs, uint32_t i_ru) +int srsran_ra_nbiot_get_npusch_tbs(uint32_t i_tbs, uint32_t i_ru) { if (i_tbs <= 12 && i_ru <= 7) { return tbs_table_npusch[i_tbs][i_ru]; @@ -184,9 +184,9 @@ int srslte_ra_nbiot_get_npusch_tbs(uint32_t i_tbs, uint32_t i_ru) } } -uint32_t srslte_ra_n_rep_sib1_nb_idx(srslte_mib_nb_t* mib) +uint32_t srsran_ra_n_rep_sib1_nb_idx(srsran_mib_nb_t* mib) { - switch (srslte_ra_n_rep_sib1_nb(mib)) { + switch (srsran_ra_n_rep_sib1_nb(mib)) { case 4: return 0; case 8: @@ -198,18 +198,18 @@ uint32_t srslte_ra_n_rep_sib1_nb_idx(srslte_mib_nb_t* mib) } } -int srslte_ra_nbiot_get_starting_sib1_frame(uint32_t cell_id, srslte_mib_nb_t* mib) +int srsran_ra_nbiot_get_starting_sib1_frame(uint32_t cell_id, srsran_mib_nb_t* mib) { - return first_frame_sib1[srslte_ra_n_rep_sib1_nb_idx(mib)][cell_id % (srslte_ra_n_rep_sib1_nb(mib) == 4 ? 4 : 2)]; + return first_frame_sib1[srsran_ra_n_rep_sib1_nb_idx(mib)][cell_id % (srsran_ra_n_rep_sib1_nb(mib) == 4 ? 4 : 2)]; } -int srslte_ra_nbiot_sib1_start(uint32_t n_id_ncell, srslte_mib_nb_t* mib) +int srsran_ra_nbiot_sib1_start(uint32_t n_id_ncell, srsran_mib_nb_t* mib) { - return ((srslte_ra_n_rep_sib1_nb(mib) == 16 && n_id_ncell % 2 == 1) ? 1 : 0); + return ((srsran_ra_n_rep_sib1_nb(mib) == 16 && n_id_ncell % 2 == 1) ? 1 : 0); } /// Section 16.4.1 in 36.213 v13.3.0 -int srslte_ra_k0_from_dci(srslte_ra_nbiot_dl_dci_t* dci, uint32_t r_max) +int srsran_ra_k0_from_dci(srsran_ra_nbiot_dl_dci_t* dci, uint32_t r_max) { if (dci->dci_is_n2) { return 0; @@ -222,7 +222,7 @@ int srslte_ra_k0_from_dci(srslte_ra_nbiot_dl_dci_t* dci, uint32_t r_max) } } -int srslte_ra_n_sf_from_dci(srslte_ra_nbiot_dl_dci_t* dci) +int srsran_ra_n_sf_from_dci(srsran_ra_nbiot_dl_dci_t* dci) { if (dci->alloc.i_sf < 6) { return dci->alloc.i_sf + 1; @@ -237,53 +237,53 @@ int srslte_ra_n_sf_from_dci(srslte_ra_nbiot_dl_dci_t* dci) /// According to TS 36.211 Sec 10.2.6 before obtaining operationModeInfo, /// only sf_idx 0, 4 and 9 if no NSSS is sent carry NRS -bool srslte_ra_nbiot_dl_has_ref_signal(uint32_t tti) +bool srsran_ra_nbiot_dl_has_ref_signal(uint32_t tti) { return (tti % 10 == 0 || tti % 10 == 4 || (tti % 10 == 9 && (tti / 10 % 2 != 0))); } /// According to TS 36.211 Sec 10.2.6 in opMode standalone and guardband, /// only sf_idx 0, 1, 3, 4, and 9 if no NSSS is sent carry NRS -bool srslte_ra_nbiot_dl_has_ref_signal_standalone(uint32_t tti) +bool srsran_ra_nbiot_dl_has_ref_signal_standalone(uint32_t tti) { return (tti % 10 == 0 || tti % 10 == 1 || tti % 10 == 3 || tti % 10 == 4 || (tti % 10 == 9 && (tti / 10 % 2 != 0))); } /// According to TS 36.211 Sec 10.2.6 before optaining operationModeInfo /// Only sf_idx 0, 4 and 9 if no NSSS is sent carry NRS -bool srslte_ra_nbiot_dl_has_ref_signal_inband(uint32_t tti) +bool srsran_ra_nbiot_dl_has_ref_signal_inband(uint32_t tti) { - return srslte_ra_nbiot_dl_has_ref_signal(tti); + return srsran_ra_nbiot_dl_has_ref_signal(tti); } /// Valid NB-IoT DL subframes are subframes that DON'T carry: /// - NPBCH (subframe 0) /// - NPSS (subframe 5) /// - NSSS (subframe 9 in all even frames) -bool srslte_ra_nbiot_is_valid_dl_sf(uint32_t tti) +bool srsran_ra_nbiot_is_valid_dl_sf(uint32_t tti) { return !(tti % 10 == 0 || tti % 10 == 5 || (tti % 10 == 9 && ((tti / 10) % 2 == 0))); } -int srslte_ra_nbiot_dl_dci_to_grant(srslte_ra_nbiot_dl_dci_t* dci, - srslte_ra_nbiot_dl_grant_t* grant, +int srsran_ra_nbiot_dl_dci_to_grant(srsran_ra_nbiot_dl_dci_t* dci, + srsran_ra_nbiot_dl_grant_t* grant, uint32_t sfn, uint32_t sf_idx, uint32_t r_max, bool is_prescheduled, - srslte_nbiot_mode_t mode) + srsran_nbiot_mode_t mode) { if (!nbiot_dl_dci_to_grant_mcs(dci, grant)) { /// Fill rest of grant structure grant->mcs[0].mcs_idx = dci->mcs_idx; - grant->Qm = srslte_mod_bits_x_symbol(grant->mcs[0].mod); - grant->k0 = srslte_ra_k0_from_dci(dci, r_max); - grant->nof_sf = dci->alloc.has_sib1 ? 8 : srslte_ra_n_sf_from_dci(dci); - grant->nof_rep = srslte_ra_n_rep_from_dci(dci); + grant->Qm = srsran_mod_bits_x_symbol(grant->mcs[0].mod); + grant->k0 = srsran_ra_k0_from_dci(dci, r_max); + grant->nof_sf = dci->alloc.has_sib1 ? 8 : srsran_ra_n_sf_from_dci(dci); + grant->nof_rep = srsran_ra_n_rep_from_dci(dci); grant->has_sib1 = dci->alloc.has_sib1; grant->ack_nack_resource = dci->alloc.harq_ack; - if (mode == SRSLTE_NBIOT_MODE_INBAND_SAME_PCI || mode == SRSLTE_NBIOT_MODE_INBAND_DIFFERENT_PCI) { + if (mode == SRSRAN_NBIOT_MODE_INBAND_SAME_PCI || mode == SRSRAN_NBIOT_MODE_INBAND_DIFFERENT_PCI) { grant->l_start = dci->alloc.has_sib1 ? 3 : EUTRA_CONTROL_REGION_SIZE; } else { grant->l_start = 0; @@ -295,36 +295,36 @@ int srslte_ra_nbiot_dl_dci_to_grant(srslte_ra_nbiot_dl_dci_t* dci, uint32_t tx_tti = (rx_tti + offset + grant->k0) % 10240; /// make sure tx_tti is a valid DL sf - while (!srslte_ra_nbiot_is_valid_dl_sf(tx_tti)) { + while (!srsran_ra_nbiot_is_valid_dl_sf(tx_tti)) { tx_tti = (tx_tti + 1) % 10240; } grant->start_hfn = 0; // not handling HFN grant->start_sfn = tx_tti / 10; grant->start_sfidx = tx_tti % 10; } else { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -void srslte_nbiot_dl_dci_fprint(FILE* f, srslte_ra_nbiot_dl_dci_t* dci) +void srsran_nbiot_dl_dci_fprint(FILE* f, srsran_ra_nbiot_dl_dci_t* dci) { fprintf(f, "NB-IoT DL DCI:\n"); fprintf(f, " - Format flag:\t\t\t\t%d\n", dci->format); fprintf(f, " + FormatN%d DCI:\t\t\t%s\n", dci->format ? 1 : 0, dci->format ? "Downlink" : "Uplink"); fprintf(f, " - PDCCH Order:\t\t\t\t%d\n", dci->alloc.is_ra); - fprintf(f, " - Scheduling delay:\t\t\t%d (%d subframes)\n", dci->alloc.i_delay, srslte_ra_k0_from_dci(dci, 64)); + fprintf(f, " - Scheduling delay:\t\t\t%d (%d subframes)\n", dci->alloc.i_delay, srsran_ra_k0_from_dci(dci, 64)); fprintf(f, " - Resource assignment:\t\t\t%d\n", dci->alloc.i_sf); - fprintf(f, " + Number of subframes:\t\t%d\n", srslte_ra_n_sf_from_dci(dci)); + fprintf(f, " + Number of subframes:\t\t%d\n", srsran_ra_n_sf_from_dci(dci)); fprintf(f, " - Modulation and coding scheme index:\t%d\n", dci->mcs_idx); fprintf(f, " - Repetition number:\t\t\t%d\n", dci->alloc.i_rep); - fprintf(f, " + Number of repetitions:\t\t%d\n", srslte_ra_n_rep_from_dci(dci)); + fprintf(f, " + Number of repetitions:\t\t%d\n", srsran_ra_n_rep_from_dci(dci)); fprintf(f, " - New data indicator:\t\t\t%d\n", dci->ndi); fprintf(f, " - HARQ-ACK resource:\t\t\t%d\n", dci->alloc.harq_ack); fprintf(f, " - DCI subframe repetition number:\t%d\n", dci->alloc.dci_sf_rep_num); } -void srslte_ra_npusch_fprint(FILE* f, srslte_ra_nbiot_ul_dci_t* dci) +void srsran_ra_npusch_fprint(FILE* f, srsran_ra_nbiot_ul_dci_t* dci) { fprintf(f, "NB-IoT UL DCI:\n"); fprintf(f, " - Format flag:\t\t\t\t%d\n", dci->format); @@ -338,7 +338,7 @@ void srslte_ra_npusch_fprint(FILE* f, srslte_ra_nbiot_ul_dci_t* dci) fprintf(f, " - DCI subframe repetition number:\t%d\n", dci->dci_sf_rep_num); } -void srslte_ra_nbiot_dl_grant_fprint(FILE* f, srslte_ra_nbiot_dl_grant_t* grant) +void srsran_ra_nbiot_dl_grant_fprint(FILE* f, srsran_ra_nbiot_dl_grant_t* grant) { fprintf(f, "DL grant config:\n"); fprintf(f, " - Number of subframes:\t\t\t%d\n", grant->nof_sf); @@ -346,33 +346,33 @@ void srslte_ra_nbiot_dl_grant_fprint(FILE* f, srslte_ra_nbiot_dl_grant_t* grant) fprintf(f, " - Total number of subframes:\t\t%d\n", grant->nof_sf * grant->nof_rep); fprintf(f, " - Starting SFN:\t\t\t%d\n", grant->start_sfn); fprintf(f, " - Starting SF index:\t\t\t%d\n", grant->start_sfidx); - fprintf(f, " - Modulation type:\t\t\t%s\n", srslte_mod_string(grant->mcs[0].mod)); + fprintf(f, " - Modulation type:\t\t\t%s\n", srsran_mod_string(grant->mcs[0].mod)); fprintf(f, " - Transport block size:\t\t%d\n", grant->mcs[0].tbs); } -void srslte_ra_nbiot_ul_grant_fprint(FILE* f, srslte_ra_nbiot_ul_grant_t* grant) +void srsran_ra_nbiot_ul_grant_fprint(FILE* f, srsran_ra_nbiot_ul_grant_t* grant) { fprintf(f, "UL grant config:\n"); - fprintf(f, " - NPUSCH format:\t\t%s\n", srslte_npusch_format_text[grant->format]); + fprintf(f, " - NPUSCH format:\t\t%s\n", srsran_npusch_format_text[grant->format]); fprintf(f, " - Delay:\t\t\t%d subframes\n", grant->k0); fprintf(f, " - Tx TTI:\t\t\t%d\n", grant->tx_tti); - fprintf(f, " - Subcarriers:\t\t\t%d (%s)\n", grant->nof_sc, srslte_npusch_sc_spacing_text[grant->sc_spacing]); + fprintf(f, " - Subcarriers:\t\t\t%d (%s)\n", grant->nof_sc, srsran_npusch_sc_spacing_text[grant->sc_spacing]); fprintf(f, " - Number of slots:\t\t%d\n", grant->nof_slots); fprintf(f, " - Number of resource units:\t%d\n", grant->nof_ru); fprintf(f, " - Number of repetitions:\t%d\n", grant->nof_rep); - fprintf(f, " - Modulation type:\t\t%s\n", srslte_mod_string(grant->mcs.mod)); + fprintf(f, " - Modulation type:\t\t%s\n", srsran_mod_string(grant->mcs.mod)); fprintf(f, " - Transport block size:\t%d\n", grant->mcs.tbs); } /// UL RA for Msg3, i.e. RAR grant -int srslte_ra_nbiot_ul_rar_dci_to_grant(srslte_ra_nbiot_ul_dci_t* dci, - srslte_ra_nbiot_ul_grant_t* grant, +int srsran_ra_nbiot_ul_rar_dci_to_grant(srsran_ra_nbiot_ul_dci_t* dci, + srsran_ra_nbiot_ul_grant_t* grant, uint32_t rx_tti) { /// use DCI to fill default UL grant values - if (srslte_ra_nbiot_ul_dci_to_grant(dci, grant, rx_tti, SRSLTE_NPUSCH_SC_SPACING_15000)) { + if (srsran_ra_nbiot_ul_dci_to_grant(dci, grant, rx_tti, SRSRAN_NPUSCH_SC_SPACING_15000)) { fprintf(stderr, "Error while reading UL DCI for RAR grant.\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } /// now update all RAR specific fields @@ -394,34 +394,34 @@ int srslte_ra_nbiot_ul_rar_dci_to_grant(srslte_ra_nbiot_ul_dci_t* dci, break; default: fprintf(stderr, "Invalid i_mcs value in UL DCI for RAR grant.\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } /// set modulation grant->mcs.tbs = 88; - if (grant->sc_spacing == SRSLTE_NPUSCH_SC_SPACING_15000 && dci->i_sc > 11) { - grant->mcs.mod = SRSLTE_MOD_QPSK; + if (grant->sc_spacing == SRSRAN_NPUSCH_SC_SPACING_15000 && dci->i_sc > 11) { + grant->mcs.mod = SRSRAN_MOD_QPSK; } else if (dci->i_sc <= 11) { - // TODO: Use SRSLTE_MOD_PI2_BPSK and SRSLTE_MOD_PI4_QPSK - grant->mcs.mod = (dci->i_mcs == 0) ? SRSLTE_MOD_BPSK : SRSLTE_MOD_QPSK; + // TODO: Use SRSRAN_MOD_PI2_BPSK and SRSRAN_MOD_PI4_QPSK + grant->mcs.mod = (dci->i_mcs == 0) ? SRSRAN_MOD_BPSK : SRSRAN_MOD_QPSK; } return 0; } /// Fill a grant for NPUSCH without UL-SCH data but for UL control information -void srslte_ra_nbiot_ul_get_uci_grant(srslte_ra_nbiot_ul_grant_t* grant, +void srsran_ra_nbiot_ul_get_uci_grant(srsran_ra_nbiot_ul_grant_t* grant, const uint8_t resource_field, const uint32_t tti) { - bzero(grant, sizeof(srslte_ra_nbiot_ul_grant_t)); - grant->format = SRSLTE_NPUSCH_FORMAT2; - grant->sc_spacing = SRSLTE_NPUSCH_SC_SPACING_15000; + bzero(grant, sizeof(srsran_ra_nbiot_ul_grant_t)); + grant->format = SRSRAN_NPUSCH_FORMAT2; + grant->sc_spacing = SRSRAN_NPUSCH_SC_SPACING_15000; grant->sc_alloc_set[0] = ack_nack_resource_field_to_sc[grant->sc_spacing][resource_field]; grant->nof_sc = 1; grant->k0 = ack_nack_resource_field_to_k0[grant->sc_spacing][resource_field]; grant->tx_tti = (tti + grant->k0) % 10240; grant->mcs.mcs_idx = 1; - grant->mcs.mod = SRSLTE_MOD_BPSK; + grant->mcs.mod = SRSRAN_MOD_BPSK; grant->mcs.tbs = 16; grant->Qm = 1; grant->nof_ru = 1; @@ -431,14 +431,14 @@ void srslte_ra_nbiot_ul_get_uci_grant(srslte_ra_nbiot_ul_grant_t* grant, } /// Transport block size determination 16.5.1.2 in 36.213 v13.2.0 -int srslte_ra_nbiot_ul_dci_to_grant(srslte_ra_nbiot_ul_dci_t* dci, - srslte_ra_nbiot_ul_grant_t* grant, +int srsran_ra_nbiot_ul_dci_to_grant(srsran_ra_nbiot_ul_dci_t* dci, + srsran_ra_nbiot_ul_grant_t* grant, uint32_t rx_tti, - srslte_npusch_sc_spacing_t spacing) + srsran_npusch_sc_spacing_t spacing) { - bzero(grant, sizeof(srslte_ra_nbiot_ul_grant_t)); - grant->format = SRSLTE_NPUSCH_FORMAT1; - grant->sc_spacing = SRSLTE_NPUSCH_SC_SPACING_15000; + bzero(grant, sizeof(srsran_ra_nbiot_ul_grant_t)); + grant->format = SRSRAN_NPUSCH_FORMAT1; + grant->sc_spacing = SRSRAN_NPUSCH_SC_SPACING_15000; int tbs = -1; uint32_t i_tbs = 0; @@ -450,18 +450,18 @@ int srslte_ra_nbiot_ul_dci_to_grant(srslte_ra_nbiot_ul_dci_t* dci, grant->nof_sc = 1; } else { printf("UL i_sc > 11 not implemented yet!\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } grant->nof_ru = n_ru_table_npusch[dci->i_ru]; grant->nof_rep = n_rep_table_npusch[dci->i_rep]; if (grant->nof_rep != 1) { printf("NPUSCH repetitions are currently not supported!\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } /// Compute number of slots according to Table Table 10.1.2.3-1 in 36.211 switch (grant->format) { - case SRSLTE_NPUSCH_FORMAT1: + case SRSRAN_NPUSCH_FORMAT1: if (grant->nof_sc == 1) { grant->nof_slots = 16; } else if (grant->nof_sc == 3) { @@ -474,12 +474,12 @@ int srslte_ra_nbiot_ul_dci_to_grant(srslte_ra_nbiot_ul_dci_t* dci, DEBUG("Unsupported value for N_sc_RU=%d", grant->nof_sc); } break; - case SRSLTE_NPUSCH_FORMAT2: + case SRSRAN_NPUSCH_FORMAT2: grant->nof_slots = 4; break; default: fprintf(stderr, "Invalid NPUSCH format.\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } grant->nof_slots *= grant->nof_ru; @@ -511,20 +511,20 @@ int srslte_ra_nbiot_ul_dci_to_grant(srslte_ra_nbiot_ul_dci_t* dci, /// set fixed values grant->sc_spacing = spacing; grant->mcs.mcs_idx = dci->i_mcs; - grant->mcs.mod = (grant->Qm == 1) ? SRSLTE_MOD_BPSK : SRSLTE_MOD_QPSK; + grant->mcs.mod = (grant->Qm == 1) ? SRSRAN_MOD_BPSK : SRSRAN_MOD_QPSK; if (tbs < 0) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } else { grant->mcs.tbs = (uint32_t)tbs; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } } -void srslte_ra_nbiot_ul_grant_to_nbits(srslte_ra_nbiot_ul_grant_t* grant, srslte_ra_nbits_t* nbits) +void srsran_ra_nbiot_ul_grant_to_nbits(srsran_ra_nbiot_ul_grant_t* grant, srsran_ra_nbits_t* nbits) { /// set DMRS symbols according to TS 36.211 v13.3 Table 10.1.4.2-1 - int num_dmrs_syms = (grant->format == SRSLTE_NPUSCH_FORMAT1) ? 1 : 3; + int num_dmrs_syms = (grant->format == SRSRAN_NPUSCH_FORMAT1) ? 1 : 3; /// computer number of RUs nbits->nof_symb = 7; @@ -534,7 +534,7 @@ void srslte_ra_nbiot_ul_grant_to_nbits(srslte_ra_nbiot_ul_grant_t* grant, srslte nbits->nof_bits = nbits->nof_re * grant->Qm; } -float srslte_ra_nbiot_get_delta_f(srslte_npusch_sc_spacing_t spacing) +float srsran_ra_nbiot_get_delta_f(srsran_npusch_sc_spacing_t spacing) { - return ((spacing == SRSLTE_NPUSCH_SC_SPACING_15000) ? 15000 : 3750); + return ((spacing == SRSRAN_NPUSCH_SC_SPACING_15000) ? 15000 : 3750); } diff --git a/lib/src/phy/phch/ra_nr.c b/lib/src/phy/phch/ra_nr.c index d2c7f4ee2..a4ab97397 100644 --- a/lib/src/phy/phch/ra_nr.c +++ b/lib/src/phy/phch/ra_nr.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,15 +10,15 @@ * */ -#include "srslte/phy/phch/ra_nr.h" -#include "srslte/phy/phch/csi.h" -#include "srslte/phy/phch/pdsch_nr.h" -#include "srslte/phy/phch/ra_dl_nr.h" -#include "srslte/phy/phch/ra_ul_nr.h" -#include "srslte/phy/utils/debug.h" +#include "srsran/phy/phch/ra_nr.h" +#include "srsran/phy/phch/csi.h" +#include "srsran/phy/phch/pdsch_nr.h" +#include "srsran/phy/phch/ra_dl_nr.h" +#include "srsran/phy/phch/ra_ul_nr.h" +#include "srsran/phy/utils/debug.h" typedef struct { - srslte_mod_t modulation; + srsran_mod_t modulation; double R; // Target code Rate R x [1024] double S; // Spectral efficiency } mcs_entry_t; @@ -31,7 +31,7 @@ typedef struct { #define RA_NR_BETA_OFFSET_CSI_SIZE 32 #define RA_NR_READ_TABLE(N) \ - static double srslte_ra_nr_R_from_mcs_table##N(uint32_t mcs_idx) \ + static double srsran_ra_nr_R_from_mcs_table##N(uint32_t mcs_idx) \ { \ if (mcs_idx >= RA_NR_MCS_SIZE_TABLE##N) { \ return NAN; \ @@ -40,10 +40,10 @@ typedef struct { return ra_nr_table##N[mcs_idx].R; \ } \ \ - static srslte_mod_t srslte_ra_nr_modulation_from_mcs_table##N(uint32_t mcs_idx) \ + static srsran_mod_t srsran_ra_nr_modulation_from_mcs_table##N(uint32_t mcs_idx) \ { \ if (mcs_idx >= RA_NR_MCS_SIZE_TABLE##N) { \ - return SRSLTE_MOD_NITEMS; \ + return SRSRAN_MOD_NITEMS; \ } \ \ return ra_nr_table##N[mcs_idx].modulation; \ @@ -53,46 +53,46 @@ typedef struct { * TS 38.214 V15.10.0 Table 5.1.3.1-1: MCS index table 1 for PDSCH */ static const mcs_entry_t ra_nr_table1[RA_NR_MCS_SIZE_TABLE1] = { - {SRSLTE_MOD_QPSK, 120, 0.2344}, {SRSLTE_MOD_QPSK, 157, 0.3066}, {SRSLTE_MOD_QPSK, 193, 0.3770}, - {SRSLTE_MOD_QPSK, 251, 0.4902}, {SRSLTE_MOD_QPSK, 308, 0.6016}, {SRSLTE_MOD_QPSK, 379, 0.7402}, - {SRSLTE_MOD_QPSK, 449, 0.8770}, {SRSLTE_MOD_QPSK, 526, 1.0273}, {SRSLTE_MOD_QPSK, 602, 1.1758}, - {SRSLTE_MOD_QPSK, 679, 1.3262}, {SRSLTE_MOD_16QAM, 340, 1.3281}, {SRSLTE_MOD_16QAM, 378, 1.4766}, - {SRSLTE_MOD_16QAM, 434, 1.6953}, {SRSLTE_MOD_16QAM, 490, 1.9141}, {SRSLTE_MOD_16QAM, 553, 2.1602}, - {SRSLTE_MOD_16QAM, 616, 2.4063}, {SRSLTE_MOD_16QAM, 658, 2.5703}, {SRSLTE_MOD_64QAM, 438, 2.5664}, - {SRSLTE_MOD_64QAM, 466, 2.7305}, {SRSLTE_MOD_64QAM, 517, 3.0293}, {SRSLTE_MOD_64QAM, 567, 3.3223}, - {SRSLTE_MOD_64QAM, 616, 3.6094}, {SRSLTE_MOD_64QAM, 666, 3.9023}, {SRSLTE_MOD_64QAM, 719, 4.2129}, - {SRSLTE_MOD_64QAM, 772, 4.5234}, {SRSLTE_MOD_64QAM, 822, 4.8164}, {SRSLTE_MOD_64QAM, 873, 5.1152}, - {SRSLTE_MOD_64QAM, 910, 5.3320}, {SRSLTE_MOD_64QAM, 948, 5.5547}}; + {SRSRAN_MOD_QPSK, 120, 0.2344}, {SRSRAN_MOD_QPSK, 157, 0.3066}, {SRSRAN_MOD_QPSK, 193, 0.3770}, + {SRSRAN_MOD_QPSK, 251, 0.4902}, {SRSRAN_MOD_QPSK, 308, 0.6016}, {SRSRAN_MOD_QPSK, 379, 0.7402}, + {SRSRAN_MOD_QPSK, 449, 0.8770}, {SRSRAN_MOD_QPSK, 526, 1.0273}, {SRSRAN_MOD_QPSK, 602, 1.1758}, + {SRSRAN_MOD_QPSK, 679, 1.3262}, {SRSRAN_MOD_16QAM, 340, 1.3281}, {SRSRAN_MOD_16QAM, 378, 1.4766}, + {SRSRAN_MOD_16QAM, 434, 1.6953}, {SRSRAN_MOD_16QAM, 490, 1.9141}, {SRSRAN_MOD_16QAM, 553, 2.1602}, + {SRSRAN_MOD_16QAM, 616, 2.4063}, {SRSRAN_MOD_16QAM, 658, 2.5703}, {SRSRAN_MOD_64QAM, 438, 2.5664}, + {SRSRAN_MOD_64QAM, 466, 2.7305}, {SRSRAN_MOD_64QAM, 517, 3.0293}, {SRSRAN_MOD_64QAM, 567, 3.3223}, + {SRSRAN_MOD_64QAM, 616, 3.6094}, {SRSRAN_MOD_64QAM, 666, 3.9023}, {SRSRAN_MOD_64QAM, 719, 4.2129}, + {SRSRAN_MOD_64QAM, 772, 4.5234}, {SRSRAN_MOD_64QAM, 822, 4.8164}, {SRSRAN_MOD_64QAM, 873, 5.1152}, + {SRSRAN_MOD_64QAM, 910, 5.3320}, {SRSRAN_MOD_64QAM, 948, 5.5547}}; /** * TS 38.214 V15.10.0 Table 5.1.3.1-2: MCS index table 2 for PDSCH */ static const mcs_entry_t ra_nr_table2[RA_NR_MCS_SIZE_TABLE2] = { - {SRSLTE_MOD_QPSK, 120, 0.2344}, {SRSLTE_MOD_QPSK, 193, 0.3770}, {SRSLTE_MOD_QPSK, 308, 0.6016}, - {SRSLTE_MOD_QPSK, 449, 0.8770}, {SRSLTE_MOD_QPSK, 602, 1.1758}, {SRSLTE_MOD_16QAM, 378, 1.4766}, - {SRSLTE_MOD_16QAM, 434, 1.6953}, {SRSLTE_MOD_16QAM, 490, 1.9141}, {SRSLTE_MOD_16QAM, 553, 2.1602}, - {SRSLTE_MOD_16QAM, 616, 2.4063}, {SRSLTE_MOD_16QAM, 658, 2.5703}, {SRSLTE_MOD_64QAM, 466, 2.7305}, - {SRSLTE_MOD_64QAM, 517, 3.0293}, {SRSLTE_MOD_64QAM, 567, 3.3223}, {SRSLTE_MOD_64QAM, 616, 3.6094}, - {SRSLTE_MOD_64QAM, 666, 3.9023}, {SRSLTE_MOD_64QAM, 719, 4.2129}, {SRSLTE_MOD_64QAM, 772, 4.5234}, - {SRSLTE_MOD_64QAM, 822, 4.8164}, {SRSLTE_MOD_64QAM, 873, 5.1152}, {SRSLTE_MOD_256QAM, 682.5, 5.3320}, - {SRSLTE_MOD_256QAM, 711, 5.5547}, {SRSLTE_MOD_256QAM, 754, 5.8906}, {SRSLTE_MOD_256QAM, 797, 6.2266}, - {SRSLTE_MOD_256QAM, 841, 6.5703}, {SRSLTE_MOD_256QAM, 885, 6.9141}, {SRSLTE_MOD_256QAM, 916.5, 7.1602}, - {SRSLTE_MOD_256QAM, 948, 7.4063}}; + {SRSRAN_MOD_QPSK, 120, 0.2344}, {SRSRAN_MOD_QPSK, 193, 0.3770}, {SRSRAN_MOD_QPSK, 308, 0.6016}, + {SRSRAN_MOD_QPSK, 449, 0.8770}, {SRSRAN_MOD_QPSK, 602, 1.1758}, {SRSRAN_MOD_16QAM, 378, 1.4766}, + {SRSRAN_MOD_16QAM, 434, 1.6953}, {SRSRAN_MOD_16QAM, 490, 1.9141}, {SRSRAN_MOD_16QAM, 553, 2.1602}, + {SRSRAN_MOD_16QAM, 616, 2.4063}, {SRSRAN_MOD_16QAM, 658, 2.5703}, {SRSRAN_MOD_64QAM, 466, 2.7305}, + {SRSRAN_MOD_64QAM, 517, 3.0293}, {SRSRAN_MOD_64QAM, 567, 3.3223}, {SRSRAN_MOD_64QAM, 616, 3.6094}, + {SRSRAN_MOD_64QAM, 666, 3.9023}, {SRSRAN_MOD_64QAM, 719, 4.2129}, {SRSRAN_MOD_64QAM, 772, 4.5234}, + {SRSRAN_MOD_64QAM, 822, 4.8164}, {SRSRAN_MOD_64QAM, 873, 5.1152}, {SRSRAN_MOD_256QAM, 682.5, 5.3320}, + {SRSRAN_MOD_256QAM, 711, 5.5547}, {SRSRAN_MOD_256QAM, 754, 5.8906}, {SRSRAN_MOD_256QAM, 797, 6.2266}, + {SRSRAN_MOD_256QAM, 841, 6.5703}, {SRSRAN_MOD_256QAM, 885, 6.9141}, {SRSRAN_MOD_256QAM, 916.5, 7.1602}, + {SRSRAN_MOD_256QAM, 948, 7.4063}}; /** * TS 38.214 V15.10.0 Table 5.1.3.1-3: MCS index table 3 for PDSCH */ static const mcs_entry_t ra_nr_table3[RA_NR_MCS_SIZE_TABLE3] = { - {SRSLTE_MOD_QPSK, 30, 0.0586}, {SRSLTE_MOD_QPSK, 40, 0.0781}, {SRSLTE_MOD_QPSK, 50, 0.0977}, - {SRSLTE_MOD_QPSK, 64, 0.1250}, {SRSLTE_MOD_QPSK, 78, 0.1523}, {SRSLTE_MOD_QPSK, 99, 0.1934}, - {SRSLTE_MOD_QPSK, 120, 0.2344}, {SRSLTE_MOD_QPSK, 157, 0.3066}, {SRSLTE_MOD_QPSK, 193, 0.3770}, - {SRSLTE_MOD_QPSK, 251, 0.4902}, {SRSLTE_MOD_QPSK, 308, 0.6016}, {SRSLTE_MOD_QPSK, 379, 0.7402}, - {SRSLTE_MOD_QPSK, 449, 0.8770}, {SRSLTE_MOD_QPSK, 526, 1.0273}, {SRSLTE_MOD_QPSK, 602, 1.1758}, - {SRSLTE_MOD_16QAM, 340, 1.3281}, {SRSLTE_MOD_16QAM, 378, 1.4766}, {SRSLTE_MOD_16QAM, 434, 1.6953}, - {SRSLTE_MOD_16QAM, 490, 1.9141}, {SRSLTE_MOD_16QAM, 553, 2.1602}, {SRSLTE_MOD_16QAM, 616, 2.4063}, - {SRSLTE_MOD_64QAM, 438, 2.5664}, {SRSLTE_MOD_64QAM, 466, 2.7305}, {SRSLTE_MOD_64QAM, 517, 3.0293}, - {SRSLTE_MOD_64QAM, 567, 3.3223}, {SRSLTE_MOD_64QAM, 616, 3.6094}, {SRSLTE_MOD_64QAM, 666, 3.9023}, - {SRSLTE_MOD_64QAM, 719, 4.2129}, {SRSLTE_MOD_64QAM, 772, 4.5234}}; + {SRSRAN_MOD_QPSK, 30, 0.0586}, {SRSRAN_MOD_QPSK, 40, 0.0781}, {SRSRAN_MOD_QPSK, 50, 0.0977}, + {SRSRAN_MOD_QPSK, 64, 0.1250}, {SRSRAN_MOD_QPSK, 78, 0.1523}, {SRSRAN_MOD_QPSK, 99, 0.1934}, + {SRSRAN_MOD_QPSK, 120, 0.2344}, {SRSRAN_MOD_QPSK, 157, 0.3066}, {SRSRAN_MOD_QPSK, 193, 0.3770}, + {SRSRAN_MOD_QPSK, 251, 0.4902}, {SRSRAN_MOD_QPSK, 308, 0.6016}, {SRSRAN_MOD_QPSK, 379, 0.7402}, + {SRSRAN_MOD_QPSK, 449, 0.8770}, {SRSRAN_MOD_QPSK, 526, 1.0273}, {SRSRAN_MOD_QPSK, 602, 1.1758}, + {SRSRAN_MOD_16QAM, 340, 1.3281}, {SRSRAN_MOD_16QAM, 378, 1.4766}, {SRSRAN_MOD_16QAM, 434, 1.6953}, + {SRSRAN_MOD_16QAM, 490, 1.9141}, {SRSRAN_MOD_16QAM, 553, 2.1602}, {SRSRAN_MOD_16QAM, 616, 2.4063}, + {SRSRAN_MOD_64QAM, 438, 2.5664}, {SRSRAN_MOD_64QAM, 466, 2.7305}, {SRSRAN_MOD_64QAM, 517, 3.0293}, + {SRSRAN_MOD_64QAM, 567, 3.3223}, {SRSRAN_MOD_64QAM, 616, 3.6094}, {SRSRAN_MOD_64QAM, 666, 3.9023}, + {SRSRAN_MOD_64QAM, 719, 4.2129}, {SRSRAN_MOD_64QAM, 772, 4.5234}}; /** * Generate MCS table access functions @@ -130,20 +130,20 @@ static const float ra_nr_beta_offset_csi_table[RA_NR_BETA_OFFSET_HARQACK_SIZE] = typedef enum { ra_nr_table_1 = 0, ra_nr_table_2, ra_nr_table_3 } ra_nr_table_t; -static ra_nr_table_t ra_nr_select_table_pusch_noprecoding(srslte_mcs_table_t mcs_table, - srslte_dci_format_nr_t dci_format, - srslte_search_space_type_t search_space_type, - srslte_rnti_type_t rnti_type) +static ra_nr_table_t ra_nr_select_table_pusch_noprecoding(srsran_mcs_table_t mcs_table, + srsran_dci_format_nr_t dci_format, + srsran_search_space_type_t search_space_type, + srsran_rnti_type_t rnti_type) { // Non-implemented parameters bool mcs_c_rnti = false; - srslte_mcs_table_t configured_grant_table = srslte_mcs_table_64qam; + srsran_mcs_table_t configured_grant_table = srsran_mcs_table_64qam; // - if mcs-Table in pusch-Config is set to 'qam256', and // - PUSCH is scheduled by a PDCCH with DCI format 0_1 with // - CRC scrambled by C-RNTI or SP-CSI-RNTI, - if (mcs_table == srslte_mcs_table_256qam && dci_format == srslte_dci_format_nr_0_1 && - (rnti_type == srslte_rnti_type_c || rnti_type == srslte_rnti_type_sp_csi)) { + if (mcs_table == srsran_mcs_table_256qam && dci_format == srsran_dci_format_nr_0_1 && + (rnti_type == srsran_rnti_type_c || rnti_type == srsran_rnti_type_sp_csi)) { return ra_nr_table_2; } @@ -151,53 +151,53 @@ static ra_nr_table_t ra_nr_select_table_pusch_noprecoding(srslte_mcs_table_t // - mcs-Table in pusch-Config is set to 'qam64LowSE', and the // - PUSCH is scheduled by a PDCCH in a UE-specific search space with // - CRC scrambled by C-RNTI or SP-CSI-RNTI, - if (!mcs_c_rnti && mcs_table == srslte_mcs_table_qam64LowSE && dci_format != srslte_dci_format_nr_rar && - search_space_type == srslte_search_space_type_ue && - (rnti_type == srslte_rnti_type_c || rnti_type == srslte_rnti_type_sp_csi)) { + if (!mcs_c_rnti && mcs_table == srsran_mcs_table_qam64LowSE && dci_format != srsran_dci_format_nr_rar && + search_space_type == srsran_search_space_type_ue && + (rnti_type == srsran_rnti_type_c || rnti_type == srsran_rnti_type_sp_csi)) { return ra_nr_table_3; } // - the UE is configured with MCS-C-RNTI, and // - the PUSCH is scheduled by a PDCCH with // - CRC scrambled by MCS-C-RNTI, - if (mcs_c_rnti && dci_format != srslte_dci_format_nr_rar && rnti_type == srslte_rnti_type_mcs_c) { + if (mcs_c_rnti && dci_format != srsran_dci_format_nr_rar && rnti_type == srsran_rnti_type_mcs_c) { return ra_nr_table_3; } // - mcs-Table in configuredGrantConfig is set to 'qam256', // - if PUSCH is scheduled by a PDCCH with CRC scrambled by CS-RNTI or // - if PUSCH is transmitted with configured grant - if (configured_grant_table == srslte_mcs_table_256qam && - (rnti_type == srslte_rnti_type_cs || dci_format == srslte_dci_format_nr_cg)) { + if (configured_grant_table == srsran_mcs_table_256qam && + (rnti_type == srsran_rnti_type_cs || dci_format == srsran_dci_format_nr_cg)) { return ra_nr_table_2; } // - mcs-Table in configuredGrantConfig is set to 'qam64LowSE' // - if PUSCH is scheduled by a PDCCH with CRC scrambled by CS-RNTI or // - if PUSCH is transmitted with configured grant, - if (configured_grant_table == srslte_mcs_table_qam64LowSE && - (rnti_type == srslte_rnti_type_cs || dci_format == srslte_dci_format_nr_cg)) { + if (configured_grant_table == srsran_mcs_table_qam64LowSE && + (rnti_type == srsran_rnti_type_cs || dci_format == srsran_dci_format_nr_cg)) { return ra_nr_table_3; } return ra_nr_table_1; } -static ra_nr_table_t ra_nr_select_table_pdsch(srslte_mcs_table_t mcs_table, - srslte_dci_format_nr_t dci_format, - srslte_search_space_type_t search_space_type, - srslte_rnti_type_t rnti_type) +static ra_nr_table_t ra_nr_select_table_pdsch(srsran_mcs_table_t mcs_table, + srsran_dci_format_nr_t dci_format, + srsran_search_space_type_t search_space_type, + srsran_rnti_type_t rnti_type) { // Non-implemented parameters bool sps_config_mcs_table_present = false; - srslte_mcs_table_t sps_config_mcs_table = srslte_mcs_table_64qam; + srsran_mcs_table_t sps_config_mcs_table = srsran_mcs_table_64qam; bool is_pdcch_sps = false; // - the higher layer parameter mcs-Table given by PDSCH-Config is set to 'qam256', and // - the PDSCH is scheduled by a PDCCH with DCI format 1_1 with // - CRC scrambled by C-RNTI - if (mcs_table == srslte_mcs_table_256qam && dci_format == srslte_dci_format_nr_1_1 && - rnti_type == srslte_rnti_type_c) { + if (mcs_table == srsran_mcs_table_256qam && dci_format == srsran_dci_format_nr_1_1 && + rnti_type == srsran_rnti_type_c) { return ra_nr_table_1; } @@ -205,8 +205,8 @@ static ra_nr_table_t ra_nr_select_table_pdsch(srslte_mcs_table_t mcs_tab // the higher layer parameter mcs-Table given by PDSCH-Config is set to 'qam64LowSE', and // the PDSCH is scheduled by a PDCCH in a UE-specific search space with // CRC scrambled by C - RNTI - if (mcs_table == srslte_mcs_table_qam64LowSE && search_space_type == srslte_search_space_type_ue && - rnti_type == srslte_rnti_type_c) { + if (mcs_table == srsran_mcs_table_qam64LowSE && search_space_type == srsran_search_space_type_ue && + rnti_type == srsran_rnti_type_c) { return ra_nr_table_3; } @@ -214,16 +214,16 @@ static ra_nr_table_t ra_nr_select_table_pdsch(srslte_mcs_table_t mcs_tab // - the higher layer parameter mcs-Table given by PDSCH-Config is set to 'qam256', // - if the PDSCH is scheduled by a PDCCH with DCI format 1_1 with CRC scrambled by CS-RNTI or // - if the PDSCH is scheduled without corresponding PDCCH transmission using SPS-Config, - if (!sps_config_mcs_table_present && mcs_table == srslte_mcs_table_256qam && - ((dci_format == srslte_dci_format_nr_1_1 && rnti_type == srslte_rnti_type_c) || (!is_pdcch_sps))) { + if (!sps_config_mcs_table_present && mcs_table == srsran_mcs_table_256qam && + ((dci_format == srsran_dci_format_nr_1_1 && rnti_type == srsran_rnti_type_c) || (!is_pdcch_sps))) { return ra_nr_table_2; } // - the UE is configured with the higher layer parameter mcs-Table given by SPS-Config set to 'qam64LowSE' // - if the PDSCH is scheduled by a PDCCH with CRC scrambled by CS-RNTI or // - if the PDSCH is scheduled without corresponding PDCCH transmission using SPS-Config, - if (sps_config_mcs_table_present && sps_config_mcs_table == srslte_mcs_table_qam64LowSE && - (rnti_type == srslte_rnti_type_cs || is_pdcch_sps)) { + if (sps_config_mcs_table_present && sps_config_mcs_table == srsran_mcs_table_qam64LowSE && + (rnti_type == srsran_rnti_type_cs || is_pdcch_sps)) { return ra_nr_table_3; } @@ -231,35 +231,35 @@ static ra_nr_table_t ra_nr_select_table_pdsch(srslte_mcs_table_t mcs_tab return ra_nr_table_1; } -static ra_nr_table_t ra_nr_select_table(srslte_mcs_table_t mcs_table, - srslte_dci_format_nr_t dci_format, - srslte_search_space_type_t search_space_type, - srslte_rnti_type_t rnti_type) +static ra_nr_table_t ra_nr_select_table(srsran_mcs_table_t mcs_table, + srsran_dci_format_nr_t dci_format, + srsran_search_space_type_t search_space_type, + srsran_rnti_type_t rnti_type) { // Check if it is a PUSCH transmission - if (dci_format == srslte_dci_format_nr_0_0 || dci_format == srslte_dci_format_nr_0_1 || - dci_format == srslte_dci_format_nr_rar || dci_format == srslte_dci_format_nr_cg) { + if (dci_format == srsran_dci_format_nr_0_0 || dci_format == srsran_dci_format_nr_0_1 || + dci_format == srsran_dci_format_nr_rar || dci_format == srsran_dci_format_nr_cg) { return ra_nr_select_table_pusch_noprecoding(mcs_table, dci_format, search_space_type, rnti_type); } return ra_nr_select_table_pdsch(mcs_table, dci_format, search_space_type, rnti_type); } -double srslte_ra_nr_R_from_mcs(srslte_mcs_table_t mcs_table, - srslte_dci_format_nr_t dci_format, - srslte_search_space_type_t search_space_type, - srslte_rnti_type_t rnti_type, +double srsran_ra_nr_R_from_mcs(srsran_mcs_table_t mcs_table, + srsran_dci_format_nr_t dci_format, + srsran_search_space_type_t search_space_type, + srsran_rnti_type_t rnti_type, uint32_t mcs_idx) { ra_nr_table_t table = ra_nr_select_table(mcs_table, dci_format, search_space_type, rnti_type); switch (table) { case ra_nr_table_1: - return srslte_ra_nr_R_from_mcs_table1(mcs_idx) / 1024.0; + return srsran_ra_nr_R_from_mcs_table1(mcs_idx) / 1024.0; case ra_nr_table_2: - return srslte_ra_nr_R_from_mcs_table2(mcs_idx) / 1024.0; + return srsran_ra_nr_R_from_mcs_table2(mcs_idx) / 1024.0; case ra_nr_table_3: - return srslte_ra_nr_R_from_mcs_table3(mcs_idx) / 1024.0; + return srsran_ra_nr_R_from_mcs_table3(mcs_idx) / 1024.0; default: ERROR("Invalid table %d", table); } @@ -267,67 +267,67 @@ double srslte_ra_nr_R_from_mcs(srslte_mcs_table_t mcs_table, return NAN; } -srslte_mod_t srslte_ra_nr_mod_from_mcs(srslte_mcs_table_t mcs_table, - srslte_dci_format_nr_t dci_format, - srslte_search_space_type_t search_space_type, - srslte_rnti_type_t rnti_type, +srsran_mod_t srsran_ra_nr_mod_from_mcs(srsran_mcs_table_t mcs_table, + srsran_dci_format_nr_t dci_format, + srsran_search_space_type_t search_space_type, + srsran_rnti_type_t rnti_type, uint32_t mcs_idx) { ra_nr_table_t table = ra_nr_select_table(mcs_table, dci_format, search_space_type, rnti_type); switch (table) { case ra_nr_table_1: - return srslte_ra_nr_modulation_from_mcs_table1(mcs_idx); + return srsran_ra_nr_modulation_from_mcs_table1(mcs_idx); case ra_nr_table_2: - return srslte_ra_nr_modulation_from_mcs_table2(mcs_idx); + return srsran_ra_nr_modulation_from_mcs_table2(mcs_idx); case ra_nr_table_3: - return srslte_ra_nr_modulation_from_mcs_table3(mcs_idx); + return srsran_ra_nr_modulation_from_mcs_table3(mcs_idx); default: ERROR("Invalid table %d", table); } - return SRSLTE_MOD_NITEMS; + return SRSRAN_MOD_NITEMS; } -int srslte_ra_dl_nr_slot_nof_re(const srslte_sch_cfg_nr_t* pdsch_cfg, const srslte_sch_grant_nr_t* grant) +int srsran_ra_dl_nr_slot_nof_re(const srsran_sch_cfg_nr_t* pdsch_cfg, const srsran_sch_grant_nr_t* grant) { // the number of symbols of the PDSCH allocation within the slot int n_sh_symb = grant->L; // the number of REs for DM-RS per PRB in the scheduled duration - int n_prb_dmrs = srslte_dmrs_sch_get_N_prb(&pdsch_cfg->dmrs, grant); - if (n_prb_dmrs < SRSLTE_SUCCESS) { + int n_prb_dmrs = srsran_dmrs_sch_get_N_prb(&pdsch_cfg->dmrs, grant); + if (n_prb_dmrs < SRSRAN_SUCCESS) { ERROR("Invalid number of DMRS RE"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // the overhead configured by higher layer parameter xOverhead in PDSCH-ServingCellConfig uint32_t n_prb_oh = 0; switch (pdsch_cfg->sch_cfg.xoverhead) { - case srslte_xoverhead_0: + case srsran_xoverhead_0: n_prb_oh = 0; break; - case srslte_xoverhead_6: + case srsran_xoverhead_6: n_prb_oh = 6; break; - case srslte_xoverhead_12: + case srsran_xoverhead_12: n_prb_oh = 12; break; - case srslte_xoverhead_18: + case srsran_xoverhead_18: n_prb_oh = 18; break; } // Compute total number of n_re used for PDSCH - uint32_t n_re_prime = SRSLTE_NRE * n_sh_symb - n_prb_dmrs - n_prb_oh; + uint32_t n_re_prime = SRSRAN_NRE * n_sh_symb - n_prb_dmrs - n_prb_oh; uint32_t n_prb = 0; - for (uint32_t i = 0; i < SRSLTE_MAX_PRB_NR; i++) { + for (uint32_t i = 0; i < SRSRAN_MAX_PRB_NR; i++) { n_prb += (uint32_t)grant->prb_idx[i]; } // Return the number of resource elements for PDSCH - return SRSLTE_MIN(SRSLTE_MAX_NRE_NR, n_re_prime) * n_prb; + return SRSRAN_MIN(SRSRAN_MAX_NRE_NR, n_re_prime) * n_prb; } #define POW2(N) (1U << (N)) @@ -335,8 +335,8 @@ int srslte_ra_dl_nr_slot_nof_re(const srslte_sch_cfg_nr_t* pdsch_cfg, const srsl static uint32_t ra_nr_tbs_from_n_info3(uint32_t n_info) { // quantized intermediate number of information bits - uint32_t n = (uint32_t)SRSLTE_MAX(3.0, floor(log2(n_info)) - 6.0); - uint32_t n_info_prime = SRSLTE_MAX(ra_nr_tbs_table[0], POW2(n) * SRSLTE_FLOOR(n_info, POW2(n))); + uint32_t n = (uint32_t)SRSRAN_MAX(3.0, floor(log2(n_info)) - 6.0); + uint32_t n_info_prime = SRSRAN_MAX(ra_nr_tbs_table[0], POW2(n) * SRSRAN_FLOOR(n_info, POW2(n))); // use Table 5.1.3.2-1 find the closest TBS that is not less than n_info_prime for (uint32_t i = 0; i < RA_NR_TBS_SIZE_TABLE; i++) { @@ -352,19 +352,19 @@ static uint32_t ra_nr_tbs_from_n_info4(uint32_t n_info, double R) { // quantized intermediate number of information bits uint32_t n = (uint32_t)(floor(log2(n_info - 24.0)) - 5.0); - uint32_t n_info_prime = SRSLTE_MAX(3840, POW2(n) * SRSLTE_ROUND(n_info - 24.0, POW2(n))); + uint32_t n_info_prime = SRSRAN_MAX(3840, POW2(n) * SRSRAN_ROUND(n_info - 24.0, POW2(n))); if (R <= 0.25) { - uint32_t C = SRSLTE_CEIL(n_info_prime + 24U, 3816U); - return 8U * C * SRSLTE_CEIL(n_info_prime + 24U, 8U * C) - 24U; + uint32_t C = SRSRAN_CEIL(n_info_prime + 24U, 3816U); + return 8U * C * SRSRAN_CEIL(n_info_prime + 24U, 8U * C) - 24U; } if (n_info_prime > 8424) { - uint32_t C = SRSLTE_CEIL(n_info_prime + 24U, 8424U); - return 8U * C * SRSLTE_CEIL(n_info_prime + 24U, 8U * C) - 24U; + uint32_t C = SRSRAN_CEIL(n_info_prime + 24U, 8424U); + return 8U * C * SRSRAN_CEIL(n_info_prime + 24U, 8U * C) - 24U; } - return 8U * SRSLTE_CEIL(n_info_prime + 24U, 8U) - 24U; + return 8U * SRSRAN_CEIL(n_info_prime + 24U, 8U) - 24U; } /** @@ -383,7 +383,7 @@ static double ra_nr_get_scaling(uint32_t tb_scaling_field) return NAN; } -uint32_t srslte_ra_nr_tbs(uint32_t N_re, double S, double R, uint32_t Qm, uint32_t nof_layers) +uint32_t srsran_ra_nr_tbs(uint32_t N_re, double S, double R, uint32_t Qm, uint32_t nof_layers) { if (!isnormal(S)) { S = 1.0; @@ -405,54 +405,54 @@ uint32_t srslte_ra_nr_tbs(uint32_t N_re, double S, double R, uint32_t Qm, uint32 return ra_nr_tbs_from_n_info4(n_info, R); } -int srslte_ra_nr_fill_tb(const srslte_sch_cfg_nr_t* pdsch_cfg, - const srslte_sch_grant_nr_t* grant, +int srsran_ra_nr_fill_tb(const srsran_sch_cfg_nr_t* pdsch_cfg, + const srsran_sch_grant_nr_t* grant, uint32_t mcs_idx, - srslte_sch_tb_t* tb) + srsran_sch_tb_t* tb) { uint32_t cw_idx = 0; // Get target Rate - double R = srslte_ra_nr_R_from_mcs( + double R = srsran_ra_nr_R_from_mcs( pdsch_cfg->sch_cfg.mcs_table, grant->dci_format, grant->dci_search_space, grant->rnti_type, mcs_idx); if (!isnormal(R)) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Get modulation - srslte_mod_t m = srslte_ra_nr_mod_from_mcs( + srsran_mod_t m = srsran_ra_nr_mod_from_mcs( pdsch_cfg->sch_cfg.mcs_table, grant->dci_format, grant->dci_search_space, grant->rnti_type, mcs_idx); - if (m >= SRSLTE_MOD_NITEMS) { - return SRSLTE_ERROR; + if (m >= SRSRAN_MOD_NITEMS) { + return SRSRAN_ERROR; } // Get modulation order - uint32_t Qm = srslte_mod_bits_x_symbol(m); + uint32_t Qm = srsran_mod_bits_x_symbol(m); if (Qm == 0) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // For the PDSCH assigned by a // - PDCCH with DCI format 1_0 with // - CRC scrambled by P-RNTI, or RA-RNTI, double S = 1.0; - if ((SRSLTE_RNTI_ISRAR(grant->rnti) || SRSLTE_RNTI_ISPA(grant->rnti)) && - grant->dci_format == srslte_dci_format_nr_1_0) { + if ((SRSRAN_RNTI_ISRAR(grant->rnti) || SRSRAN_RNTI_ISPA(grant->rnti)) && + grant->dci_format == srsran_dci_format_nr_1_0) { // where the scaling factor S is determined based on the TB scaling // field in the DCI as in Table 5.1.3.2-2. S = ra_nr_get_scaling(grant->tb_scaling_field); // If the scaling is invalid return error if (!isnormal(S)) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } // 1) The UE shall first determine the number of REs (N RE ) within the slot. - int N_re = srslte_ra_dl_nr_slot_nof_re(pdsch_cfg, grant); - if (N_re <= SRSLTE_SUCCESS) { + int N_re = srsran_ra_dl_nr_slot_nof_re(pdsch_cfg, grant); + if (N_re <= SRSRAN_SUCCESS) { ERROR("Invalid number of RE"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Calculate number of layers accordingly @@ -462,74 +462,74 @@ int srslte_ra_nr_fill_tb(const srslte_sch_cfg_nr_t* pdsch_cfg, tb->N_L = (cw_idx == 0) ? nof_layers_cw1 : nof_layers_cw2; // Steps 2,3,4 - tb->tbs = (int)srslte_ra_nr_tbs(N_re, S, R, Qm, tb->N_L); + tb->tbs = (int)srsran_ra_nr_tbs(N_re, S, R, Qm, tb->N_L); tb->R = R; tb->mod = m; tb->nof_re = N_re * grant->nof_layers; tb->nof_bits = tb->nof_re * Qm; tb->enabled = true; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -static int ra_dl_dmrs(const srslte_sch_hl_cfg_nr_t* pdsch_hl_cfg, - srslte_sch_grant_nr_t* pdsch_grant, - srslte_dmrs_sch_cfg_t* dmrs_cfg) +static int ra_dl_dmrs(const srsran_sch_hl_cfg_nr_t* pdsch_hl_cfg, + srsran_sch_grant_nr_t* pdsch_grant, + srsran_dmrs_sch_cfg_t* dmrs_cfg) { - const bool dedicated_dmrs_present = (pdsch_grant->mapping == srslte_sch_mapping_type_A) + const bool dedicated_dmrs_present = (pdsch_grant->mapping == srsran_sch_mapping_type_A) ? pdsch_hl_cfg->dmrs_typeA.present : pdsch_hl_cfg->dmrs_typeB.present; - if (pdsch_grant->dci_format == srslte_dci_format_nr_1_0 || !dedicated_dmrs_present) { - if (pdsch_grant->mapping == srslte_sch_mapping_type_A) { + if (pdsch_grant->dci_format == srsran_dci_format_nr_1_0 || !dedicated_dmrs_present) { + if (pdsch_grant->mapping == srsran_sch_mapping_type_A) { // Absent default values are defined is TS 38.331 - DMRS-DownlinkConfig - dmrs_cfg->additional_pos = srslte_dmrs_sch_add_pos_2; - dmrs_cfg->type = srslte_dmrs_sch_type_1; - dmrs_cfg->length = srslte_dmrs_sch_len_1; + dmrs_cfg->additional_pos = srsran_dmrs_sch_add_pos_2; + dmrs_cfg->type = srsran_dmrs_sch_type_1; + dmrs_cfg->length = srsran_dmrs_sch_len_1; dmrs_cfg->scrambling_id0_present = false; dmrs_cfg->scrambling_id1_present = false; - if (pdsch_grant->dci_format == srslte_dci_format_nr_1_0) { - if (srslte_ra_dl_nr_nof_dmrs_cdm_groups_without_data_format_1_0(dmrs_cfg, pdsch_grant) < SRSLTE_SUCCESS) { + if (pdsch_grant->dci_format == srsran_dci_format_nr_1_0) { + if (srsran_ra_dl_nr_nof_dmrs_cdm_groups_without_data_format_1_0(dmrs_cfg, pdsch_grant) < SRSRAN_SUCCESS) { ERROR("Error loading number of DMRS CDM groups"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } else { ERROR("Invalid case"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } ERROR("Unsupported configuration"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_ERROR; + return SRSRAN_ERROR; } -int srslte_ra_dl_dci_to_grant_nr(const srslte_carrier_nr_t* carrier, - const srslte_sch_hl_cfg_nr_t* pdsch_hl_cfg, - const srslte_dci_dl_nr_t* dci_dl, - srslte_sch_cfg_nr_t* pdsch_cfg, - srslte_sch_grant_nr_t* pdsch_grant) +int srsran_ra_dl_dci_to_grant_nr(const srsran_carrier_nr_t* carrier, + const srsran_sch_hl_cfg_nr_t* pdsch_hl_cfg, + const srsran_dci_dl_nr_t* dci_dl, + srsran_sch_cfg_nr_t* pdsch_cfg, + srsran_sch_grant_nr_t* pdsch_grant) { // 5.2.1.1 Resource allocation in time domain - if (srslte_ra_dl_nr_time(pdsch_hl_cfg, + if (srsran_ra_dl_nr_time(pdsch_hl_cfg, dci_dl->rnti_type, dci_dl->search_space, dci_dl->coreset_id, dci_dl->time_domain_assigment, - pdsch_grant) < SRSLTE_SUCCESS) { + pdsch_grant) < SRSRAN_SUCCESS) { ERROR("Error computing time domain resource allocation"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // 5.1.2.2 Resource allocation in frequency domain - if (srslte_ra_dl_nr_freq(carrier, pdsch_hl_cfg, dci_dl, pdsch_grant) < SRSLTE_SUCCESS) { + if (srsran_ra_dl_nr_freq(carrier, pdsch_hl_cfg, dci_dl, pdsch_grant) < SRSRAN_SUCCESS) { ERROR("Error computing frequency domain resource allocation"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // 5.1.2.3 Physical resource block (PRB) bundling @@ -542,41 +542,41 @@ int srslte_ra_dl_dci_to_grant_nr(const srslte_carrier_nr_t* carrier, pdsch_grant->tb[0].rv = dci_dl->rv; // 5.1.6.2 DM-RS reception procedure - if (ra_dl_dmrs(pdsch_hl_cfg, pdsch_grant, &pdsch_cfg->dmrs) < SRSLTE_SUCCESS) { + if (ra_dl_dmrs(pdsch_hl_cfg, pdsch_grant, &pdsch_cfg->dmrs) < SRSRAN_SUCCESS) { ERROR("Error selecting DMRS configuration"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // 5.1.3 Modulation order, target code rate, redundancy version and transport block size determination - if (srslte_ra_nr_fill_tb(pdsch_cfg, pdsch_grant, dci_dl->mcs, &pdsch_grant->tb[0]) < SRSLTE_SUCCESS) { + if (srsran_ra_nr_fill_tb(pdsch_cfg, pdsch_grant, dci_dl->mcs, &pdsch_grant->tb[0]) < SRSRAN_SUCCESS) { ERROR("Error filing tb"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } static int -ra_ul_dmrs(const srslte_sch_hl_cfg_nr_t* pusch_hl_cfg, srslte_sch_grant_nr_t* pusch_grant, srslte_sch_cfg_nr_t* cfg) +ra_ul_dmrs(const srsran_sch_hl_cfg_nr_t* pusch_hl_cfg, srsran_sch_grant_nr_t* pusch_grant, srsran_sch_cfg_nr_t* cfg) { - const bool dedicated_dmrs_present = (pusch_grant->mapping == srslte_sch_mapping_type_A) + const bool dedicated_dmrs_present = (pusch_grant->mapping == srsran_sch_mapping_type_A) ? pusch_hl_cfg->dmrs_typeA.present : pusch_hl_cfg->dmrs_typeB.present; - if (pusch_grant->dci_format == srslte_dci_format_nr_0_0 || !dedicated_dmrs_present) { - if (pusch_grant->mapping == srslte_sch_mapping_type_A) { + if (pusch_grant->dci_format == srsran_dci_format_nr_0_0 || !dedicated_dmrs_present) { + if (pusch_grant->mapping == srsran_sch_mapping_type_A) { // Absent default values are defined is TS 38.331 - DMRS-DownlinkConfig - cfg->dmrs.additional_pos = srslte_dmrs_sch_add_pos_2; - cfg->dmrs.type = srslte_dmrs_sch_type_1; - cfg->dmrs.length = srslte_dmrs_sch_len_1; + cfg->dmrs.additional_pos = srsran_dmrs_sch_add_pos_2; + cfg->dmrs.type = srsran_dmrs_sch_type_1; + cfg->dmrs.length = srsran_dmrs_sch_len_1; cfg->dmrs.scrambling_id0_present = false; cfg->dmrs.scrambling_id1_present = false; } else { ERROR("Unsupported configuration"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } else { - if (pusch_grant->mapping == srslte_sch_mapping_type_A) { + if (pusch_grant->mapping == srsran_sch_mapping_type_A) { cfg->dmrs.additional_pos = pusch_hl_cfg->dmrs_typeA.additional_pos; cfg->dmrs.type = pusch_hl_cfg->dmrs_typeA.type; cfg->dmrs.length = pusch_hl_cfg->dmrs_typeA.length; @@ -592,46 +592,46 @@ ra_ul_dmrs(const srslte_sch_hl_cfg_nr_t* pusch_hl_cfg, srslte_sch_grant_nr_t* pu } // Set number of DMRS CDM groups without data - if (pusch_grant->dci_format == srslte_dci_format_nr_0_0) { - if (srslte_ra_ul_nr_nof_dmrs_cdm_groups_without_data_format_0_0(cfg, pusch_grant) < SRSLTE_SUCCESS) { + if (pusch_grant->dci_format == srsran_dci_format_nr_0_0) { + if (srsran_ra_ul_nr_nof_dmrs_cdm_groups_without_data_format_0_0(cfg, pusch_grant) < SRSRAN_SUCCESS) { ERROR("Error loading number of DMRS CDM groups"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } else { ERROR("Invalid case"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Set DMRS power offset Table 6.2.2-1: The ratio of PUSCH EPRE to DM-RS EPRE - if (srslte_ra_ul_nr_dmrs_power_offset(pusch_grant) < SRSLTE_SUCCESS) { + if (srsran_ra_ul_nr_dmrs_power_offset(pusch_grant) < SRSRAN_SUCCESS) { ERROR("Error setting DMRS power offset"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_ra_ul_dci_to_grant_nr(const srslte_carrier_nr_t* carrier, - const srslte_sch_hl_cfg_nr_t* pusch_hl_cfg, - const srslte_dci_ul_nr_t* dci_ul, - srslte_sch_cfg_nr_t* pusch_cfg, - srslte_sch_grant_nr_t* pusch_grant) +int srsran_ra_ul_dci_to_grant_nr(const srsran_carrier_nr_t* carrier, + const srsran_sch_hl_cfg_nr_t* pusch_hl_cfg, + const srsran_dci_ul_nr_t* dci_ul, + srsran_sch_cfg_nr_t* pusch_cfg, + srsran_sch_grant_nr_t* pusch_grant) { // 5.2.1.1 Resource allocation in time domain - if (srslte_ra_ul_nr_time(pusch_hl_cfg, + if (srsran_ra_ul_nr_time(pusch_hl_cfg, dci_ul->rnti_type, dci_ul->search_space, dci_ul->coreset_id, dci_ul->time_domain_assigment, - pusch_grant) < SRSLTE_SUCCESS) { + pusch_grant) < SRSRAN_SUCCESS) { ERROR("Error computing time domain resource allocation"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // 5.1.2.2 Resource allocation in frequency domain - if (srslte_ra_ul_nr_freq(carrier, pusch_hl_cfg, dci_ul, pusch_grant) < SRSLTE_SUCCESS) { + if (srsran_ra_ul_nr_freq(carrier, pusch_hl_cfg, dci_ul, pusch_grant) < SRSRAN_SUCCESS) { ERROR("Error computing frequency domain resource allocation"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // 5.1.2.3 Physical resource block (PRB) bundling @@ -643,26 +643,26 @@ int srslte_ra_ul_dci_to_grant_nr(const srslte_carrier_nr_t* carrier, pusch_grant->rnti_type = dci_ul->rnti_type; // 5.1.6.2 DM-RS reception procedure - if (ra_ul_dmrs(pusch_hl_cfg, pusch_grant, pusch_cfg) < SRSLTE_SUCCESS) { + if (ra_ul_dmrs(pusch_hl_cfg, pusch_grant, pusch_cfg) < SRSRAN_SUCCESS) { ERROR("Error selecting DMRS configuration"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // 5.1.3 Modulation order, target code rate, redundancy version and transport block size determination - if (srslte_ra_nr_fill_tb(pusch_cfg, pusch_grant, dci_ul->mcs, &pusch_grant->tb[0]) < SRSLTE_SUCCESS) { + if (srsran_ra_nr_fill_tb(pusch_cfg, pusch_grant, dci_ul->mcs, &pusch_grant->tb[0]) < SRSRAN_SUCCESS) { ERROR("Error filing tb"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } /* * Implements clauses related to HARQ-ACK beta offset selection from the section `9.3 UCI reporting in physical uplink * shared channel` */ -static float ra_ul_beta_offset_ack_semistatic(const srslte_beta_offsets_t* beta_offsets, - const srslte_uci_cfg_nr_t* uci_cfg) +static float ra_ul_beta_offset_ack_semistatic(const srsran_beta_offsets_t* beta_offsets, + const srsran_uci_cfg_nr_t* uci_cfg) { // Select Beta Offset index from the number of HARQ-ACK bits uint32_t beta_offset_index = beta_offsets->ack_index1; @@ -689,12 +689,12 @@ static float ra_ul_beta_offset_ack_semistatic(const srslte_beta_offsets_t* beta_ * Implements clauses related to HARQ-ACK beta offset selection from the section `9.3 UCI reporting in physical uplink * shared channel` */ -static float ra_ul_beta_offset_csi_semistatic(const srslte_beta_offsets_t* beta_offsets, - const srslte_uci_cfg_nr_t* uci_cfg, +static float ra_ul_beta_offset_csi_semistatic(const srsran_beta_offsets_t* beta_offsets, + const srsran_uci_cfg_nr_t* uci_cfg, bool part2) { // Calculate number of CSI bits; CSI part 2 is not supported. - uint32_t O_csi = part2 ? 0 : srslte_csi_part1_nof_bits(uci_cfg->csi, uci_cfg->nof_csi); + uint32_t O_csi = part2 ? 0 : srsran_csi_part1_nof_bits(uci_cfg->csi, uci_cfg->nof_csi); // Select Beta Offset index from the number of HARQ-ACK bits uint32_t beta_offset_index = part2 ? beta_offsets->csi2_index1 : beta_offsets->csi1_index1; @@ -715,35 +715,35 @@ static float ra_ul_beta_offset_csi_semistatic(const srslte_beta_offsets_t* beta_ return ra_nr_beta_offset_csi_table[beta_offset_index]; } -int srslte_ra_ul_set_grant_uci_nr(const srslte_sch_hl_cfg_nr_t* pusch_hl_cfg, - const srslte_uci_cfg_nr_t* uci_cfg, - srslte_sch_cfg_nr_t* pusch_cfg) +int srsran_ra_ul_set_grant_uci_nr(const srsran_sch_hl_cfg_nr_t* pusch_hl_cfg, + const srsran_uci_cfg_nr_t* uci_cfg, + srsran_sch_cfg_nr_t* pusch_cfg) { // Select beta offsets pusch_cfg->beta_harq_ack_offset = ra_ul_beta_offset_ack_semistatic(&pusch_hl_cfg->beta_offsets, uci_cfg); if (!isnormal(pusch_cfg->beta_harq_ack_offset)) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } pusch_cfg->beta_csi_part1_offset = ra_ul_beta_offset_csi_semistatic(&pusch_hl_cfg->beta_offsets, uci_cfg, false); if (!isnormal(pusch_cfg->beta_csi_part1_offset)) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } pusch_cfg->beta_csi_part2_offset = ra_ul_beta_offset_csi_semistatic(&pusch_hl_cfg->beta_offsets, uci_cfg, true); if (!isnormal(pusch_cfg->beta_csi_part2_offset)) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // pusch_cfg->beta_csi_part2_offset = pusch_hl_cfg->beta_offset_csi2; pusch_cfg->scaling = pusch_hl_cfg->scaling; if (!isnormal(pusch_cfg->scaling)) { ERROR("Invalid Scaling (%f)", pusch_cfg->scaling); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Copy UCI configuration pusch_cfg->uci = *uci_cfg; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } \ No newline at end of file diff --git a/lib/src/phy/phch/ra_sl.c b/lib/src/phy/phch/ra_sl.c index 7a604e5fd..f597d266a 100644 --- a/lib/src/phy/phch/ra_sl.c +++ b/lib/src/phy/phch/ra_sl.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -12,12 +12,12 @@ #include -#include "srslte/phy/common/phy_common_sl.h" -#include "srslte/phy/phch/ra.h" -#include "srslte/phy/phch/ra_sl.h" -#include "srslte/phy/utils/random.h" +#include "srsran/phy/common/phy_common_sl.h" +#include "srsran/phy/phch/ra.h" +#include "srsran/phy/phch/ra_sl.h" +#include "srsran/phy/utils/random.h" -int srslte_sl_get_available_pool_prb(uint32_t prb_num, uint32_t prb_start, uint32_t prb_end) +int srsran_sl_get_available_pool_prb(uint32_t prb_num, uint32_t prb_start, uint32_t prb_end) { if ((prb_num * 2) <= (prb_end - prb_start + 1)) { return prb_num * 2; @@ -26,7 +26,7 @@ int srslte_sl_get_available_pool_prb(uint32_t prb_num, uint32_t prb_start, uint3 } } -int srslte_pscch_resources(uint32_t prb_num, +int srsran_pscch_resources(uint32_t prb_num, uint32_t prb_start, uint32_t prb_end, uint8_t* pscch_sf_bitmap, @@ -35,7 +35,7 @@ int srslte_pscch_resources(uint32_t prb_num, uint32_t* m_a, uint32_t* l_b) { - uint8_t M = srslte_sl_get_available_pool_prb(prb_num, prb_start, prb_end); + uint8_t M = srsran_sl_get_available_pool_prb(prb_num, prb_start, prb_end); uint32_t L = 0; for (uint32_t i = 0; i < period_length; i++) { if (pscch_sf_bitmap[i] == 1) { @@ -45,7 +45,7 @@ int srslte_pscch_resources(uint32_t prb_num, if (L == 0) { // ERROR("Invalid PSCCH subframe bitmap"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } n_pscch = n_pscch % (L * M / 2); @@ -80,122 +80,122 @@ int srslte_pscch_resources(uint32_t prb_num, } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // 3GPP TS 36.213 Section 8.1.1. Uplink resource allocation type 0 -uint32_t srslte_ra_sl_type0_to_riv(uint32_t nof_prb, uint32_t prb_start, uint32_t L_crb) +uint32_t srsran_ra_sl_type0_to_riv(uint32_t nof_prb, uint32_t prb_start, uint32_t L_crb) { - return srslte_ra_type2_to_riv(L_crb, prb_start, nof_prb); + return srsran_ra_type2_to_riv(L_crb, prb_start, nof_prb); } // 3GPP TS 36.213 Section 8.1.1. Uplink resource allocation type 0 -void srslte_ra_sl_type0_from_riv(uint32_t riv, uint32_t nof_prb, uint32_t* L_crb, uint32_t* prb_start) +void srsran_ra_sl_type0_from_riv(uint32_t riv, uint32_t nof_prb, uint32_t* L_crb, uint32_t* prb_start) { - srslte_ra_type2_from_riv(riv, L_crb, prb_start, nof_prb, nof_prb); + srsran_ra_type2_from_riv(riv, L_crb, prb_start, nof_prb, nof_prb); } -int srslte_ra_sl_pssch_allowed_sf(uint32_t pssch_sf_idx, uint32_t trp_idx, uint32_t duplex_mode, uint32_t tdd_config) +int srsran_ra_sl_pssch_allowed_sf(uint32_t pssch_sf_idx, uint32_t trp_idx, uint32_t duplex_mode, uint32_t tdd_config) { - if (duplex_mode == SRSLTE_SL_DUPLEX_MODE_FDD) { - return srslte_sl_N_TRP_8[trp_idx][pssch_sf_idx % 8]; + if (duplex_mode == SRSRAN_SL_DUPLEX_MODE_FDD) { + return srsran_sl_N_TRP_8[trp_idx][pssch_sf_idx % 8]; } switch (tdd_config) { // N_TRP = 6 case 3: case 6: - return srslte_sl_N_TRP_6[trp_idx][pssch_sf_idx % 6]; + return srsran_sl_N_TRP_6[trp_idx][pssch_sf_idx % 6]; // N_TRP = 7 case 0: - return srslte_sl_N_TRP_7[trp_idx][pssch_sf_idx % 7]; + return srsran_sl_N_TRP_7[trp_idx][pssch_sf_idx % 7]; // N_TRP = 8 case 1: case 2: case 4: case 5: - return srslte_sl_N_TRP_8[trp_idx][pssch_sf_idx % 8]; + return srsran_sl_N_TRP_8[trp_idx][pssch_sf_idx % 8]; default: return 0; } } -int srslte_sci_generate_trp_idx(uint32_t duplex_mode, uint32_t tdd_config, uint32_t k_TRP) +int srsran_sci_generate_trp_idx(uint32_t duplex_mode, uint32_t tdd_config, uint32_t k_TRP) { - int retval = SRSLTE_ERROR; + int retval = SRSRAN_ERROR; struct timeval tv; gettimeofday(&tv, NULL); - srslte_random_t random = srslte_random_init(tv.tv_usec); + srsran_random_t random = srsran_random_init(tv.tv_usec); // N_TRP = 8 - if (duplex_mode == SRSLTE_SL_DUPLEX_MODE_FDD || tdd_config == 1 || tdd_config == 2 || tdd_config == 4 || + if (duplex_mode == SRSRAN_SL_DUPLEX_MODE_FDD || tdd_config == 1 || tdd_config == 2 || tdd_config == 4 || tdd_config == 5) { switch (k_TRP) { case 1: - retval = srslte_sl_N_TRP_8_k_1[srslte_random_uniform_int_dist(random, 0, sizeof(srslte_sl_N_TRP_8_k_1) - 1)]; + retval = srsran_sl_N_TRP_8_k_1[srsran_random_uniform_int_dist(random, 0, sizeof(srsran_sl_N_TRP_8_k_1) - 1)]; break; case 2: - retval = srslte_sl_N_TRP_8_k_2[srslte_random_uniform_int_dist(random, 0, sizeof(srslte_sl_N_TRP_8_k_2) - 1)]; + retval = srsran_sl_N_TRP_8_k_2[srsran_random_uniform_int_dist(random, 0, sizeof(srsran_sl_N_TRP_8_k_2) - 1)]; break; case 4: - retval = srslte_sl_N_TRP_8_k_4[srslte_random_uniform_int_dist(random, 0, sizeof(srslte_sl_N_TRP_8_k_4) - 1)]; + retval = srsran_sl_N_TRP_8_k_4[srsran_random_uniform_int_dist(random, 0, sizeof(srsran_sl_N_TRP_8_k_4) - 1)]; break; case 8: - retval = srslte_sl_N_TRP_8_k_8[srslte_random_uniform_int_dist(random, 0, sizeof(srslte_sl_N_TRP_8_k_8) - 1)]; + retval = srsran_sl_N_TRP_8_k_8[srsran_random_uniform_int_dist(random, 0, sizeof(srsran_sl_N_TRP_8_k_8) - 1)]; break; } // N_TRP = 7 } else if (tdd_config == 0) { switch (k_TRP) { case 1: - retval = srslte_sl_N_TRP_7_k_1[srslte_random_uniform_int_dist(random, 0, sizeof(srslte_sl_N_TRP_7_k_1) - 1)]; + retval = srsran_sl_N_TRP_7_k_1[srsran_random_uniform_int_dist(random, 0, sizeof(srsran_sl_N_TRP_7_k_1) - 1)]; break; case 2: - retval = srslte_sl_N_TRP_7_k_2[srslte_random_uniform_int_dist(random, 0, sizeof(srslte_sl_N_TRP_7_k_2) - 1)]; + retval = srsran_sl_N_TRP_7_k_2[srsran_random_uniform_int_dist(random, 0, sizeof(srsran_sl_N_TRP_7_k_2) - 1)]; break; case 3: - retval = srslte_sl_N_TRP_7_k_3[srslte_random_uniform_int_dist(random, 0, sizeof(srslte_sl_N_TRP_7_k_3) - 1)]; + retval = srsran_sl_N_TRP_7_k_3[srsran_random_uniform_int_dist(random, 0, sizeof(srsran_sl_N_TRP_7_k_3) - 1)]; break; case 4: - retval = srslte_sl_N_TRP_7_k_4[srslte_random_uniform_int_dist(random, 0, sizeof(srslte_sl_N_TRP_7_k_4) - 1)]; + retval = srsran_sl_N_TRP_7_k_4[srsran_random_uniform_int_dist(random, 0, sizeof(srsran_sl_N_TRP_7_k_4) - 1)]; break; case 5: - retval = srslte_sl_N_TRP_7_k_5[srslte_random_uniform_int_dist(random, 0, sizeof(srslte_sl_N_TRP_7_k_5) - 1)]; + retval = srsran_sl_N_TRP_7_k_5[srsran_random_uniform_int_dist(random, 0, sizeof(srsran_sl_N_TRP_7_k_5) - 1)]; break; case 6: - retval = srslte_sl_N_TRP_7_k_6[srslte_random_uniform_int_dist(random, 0, sizeof(srslte_sl_N_TRP_7_k_6) - 1)]; + retval = srsran_sl_N_TRP_7_k_6[srsran_random_uniform_int_dist(random, 0, sizeof(srsran_sl_N_TRP_7_k_6) - 1)]; break; case 7: - retval = srslte_sl_N_TRP_7_k_7[srslte_random_uniform_int_dist(random, 0, sizeof(srslte_sl_N_TRP_7_k_7) - 1)]; + retval = srsran_sl_N_TRP_7_k_7[srsran_random_uniform_int_dist(random, 0, sizeof(srsran_sl_N_TRP_7_k_7) - 1)]; break; } // N_TRP = 6 } else if (tdd_config == 3 || tdd_config == 6) { switch (k_TRP) { case 1: - retval = srslte_sl_N_TRP_6_k_1[srslte_random_uniform_int_dist(random, 0, sizeof(srslte_sl_N_TRP_6_k_1) - 1)]; + retval = srsran_sl_N_TRP_6_k_1[srsran_random_uniform_int_dist(random, 0, sizeof(srsran_sl_N_TRP_6_k_1) - 1)]; break; case 2: - retval = srslte_sl_N_TRP_6_k_2[srslte_random_uniform_int_dist(random, 0, sizeof(srslte_sl_N_TRP_6_k_2) - 1)]; + retval = srsran_sl_N_TRP_6_k_2[srsran_random_uniform_int_dist(random, 0, sizeof(srsran_sl_N_TRP_6_k_2) - 1)]; break; case 3: - retval = srslte_sl_N_TRP_6_k_3[srslte_random_uniform_int_dist(random, 0, sizeof(srslte_sl_N_TRP_6_k_3) - 1)]; + retval = srsran_sl_N_TRP_6_k_3[srsran_random_uniform_int_dist(random, 0, sizeof(srsran_sl_N_TRP_6_k_3) - 1)]; break; case 4: - retval = srslte_sl_N_TRP_6_k_4[srslte_random_uniform_int_dist(random, 0, sizeof(srslte_sl_N_TRP_6_k_4) - 1)]; + retval = srsran_sl_N_TRP_6_k_4[srsran_random_uniform_int_dist(random, 0, sizeof(srsran_sl_N_TRP_6_k_4) - 1)]; break; case 5: - retval = srslte_sl_N_TRP_6_k_5[srslte_random_uniform_int_dist(random, 0, sizeof(srslte_sl_N_TRP_6_k_5) - 1)]; + retval = srsran_sl_N_TRP_6_k_5[srsran_random_uniform_int_dist(random, 0, sizeof(srsran_sl_N_TRP_6_k_5) - 1)]; break; case 6: - retval = srslte_sl_N_TRP_6_k_6[srslte_random_uniform_int_dist(random, 0, sizeof(srslte_sl_N_TRP_6_k_6) - 1)]; + retval = srsran_sl_N_TRP_6_k_6[srsran_random_uniform_int_dist(random, 0, sizeof(srsran_sl_N_TRP_6_k_6) - 1)]; break; } } else { - retval = SRSLTE_SUCCESS; + retval = SRSRAN_SUCCESS; } - srslte_random_free(random); + srsran_random_free(random); return retval; } diff --git a/lib/src/phy/phch/ra_ul.c b/lib/src/phy/phch/ra_ul.c index 2681fca90..6c53cc56a 100644 --- a/lib/src/phy/phch/ra_ul.c +++ b/lib/src/phy/phch/ra_ul.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,12 +10,12 @@ * */ -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/phch/ra.h" -#include "srslte/phy/utils/bit.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" -#include "srslte/srslte.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/phch/ra.h" +#include "srsran/phy/utils/bit.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" +#include "srsran/srsran.h" #include #include #include @@ -29,7 +29,7 @@ * **********/ -static int f_hop_sum(srslte_ra_ul_pusch_hopping_t* q, uint32_t i) +static int f_hop_sum(srsran_ra_ul_pusch_hopping_t* q, uint32_t i) { uint32_t sum = 0; for (uint32_t k = i * 10 + 1; k < i * 10 + 9; i++) { @@ -38,7 +38,7 @@ static int f_hop_sum(srslte_ra_ul_pusch_hopping_t* q, uint32_t i) return sum; } -static int f_hop(srslte_ra_ul_pusch_hopping_t* q, srslte_pusch_hopping_cfg_t* hopping, int i) +static int f_hop(srsran_ra_ul_pusch_hopping_t* q, srsran_pusch_hopping_cfg_t* hopping, int i) { if (i == -1) { return 0; @@ -53,10 +53,10 @@ static int f_hop(srslte_ra_ul_pusch_hopping_t* q, srslte_pusch_hopping_cfg_t* ho } } -static int f_m(srslte_ra_ul_pusch_hopping_t* q, srslte_pusch_hopping_cfg_t* hopping, uint32_t i, uint32_t current_tx_nb) +static int f_m(srsran_ra_ul_pusch_hopping_t* q, srsran_pusch_hopping_cfg_t* hopping, uint32_t i, uint32_t current_tx_nb) { if (hopping->n_sb == 1) { - if (hopping->hop_mode == SRSLTE_PUSCH_HOP_MODE_INTER_SF) { + if (hopping->hop_mode == SRSRAN_PUSCH_HOP_MODE_INTER_SF) { return current_tx_nb % 2; } else { return i % 2; @@ -66,12 +66,12 @@ static int f_m(srslte_ra_ul_pusch_hopping_t* q, srslte_pusch_hopping_cfg_t* hopp } } /* Computes PUSCH frequency hopping as defined in Section 8.4 of 36.213 */ -static void compute_freq_hopping(srslte_ra_ul_pusch_hopping_t* q, - srslte_ul_sf_cfg_t* sf, - srslte_pusch_hopping_cfg_t* hopping_cfg, - srslte_pusch_grant_t* grant) +static void compute_freq_hopping(srsran_ra_ul_pusch_hopping_t* q, + srsran_ul_sf_cfg_t* sf, + srsran_pusch_hopping_cfg_t* hopping_cfg, + srsran_pusch_grant_t* grant) { - if (q->cell.frame_type == SRSLTE_TDD) { + if (q->cell.frame_type == SRSRAN_TDD) { ERROR("Error frequency hopping for TDD not implemented (c_init for each subframe, see end of 5.3.4 36.211)"); } @@ -80,7 +80,7 @@ static void compute_freq_hopping(srslte_ra_ul_pusch_hopping_t* q, uint32_t n_prb_tilde = grant->n_prb[slot]; if (grant->freq_hopping == 1) { - if (hopping_cfg->hop_mode == SRSLTE_PUSCH_HOP_MODE_INTER_SF) { + if (hopping_cfg->hop_mode == SRSRAN_PUSCH_HOP_MODE_INTER_SF) { n_prb_tilde = grant->n_prb[hopping_cfg->current_tx_nb % 2]; } else { n_prb_tilde = grant->n_prb[slot]; @@ -93,7 +93,7 @@ static void compute_freq_hopping(srslte_ra_ul_pusch_hopping_t* q, n_vrb_tilde -= (hopping_cfg->hopping_offset - 1) / 2 + 1; } int i = 0; - if (hopping_cfg->hop_mode == SRSLTE_PUSCH_HOP_MODE_INTER_SF) { + if (hopping_cfg->hop_mode == SRSRAN_PUSCH_HOP_MODE_INTER_SF) { i = sf->tti % 10; } else { i = 2 * sf->tti % 10 + slot; @@ -119,27 +119,27 @@ static void compute_freq_hopping(srslte_ra_ul_pusch_hopping_t* q, } } -static int ra_ul_grant_to_grant_prb_allocation(srslte_dci_ul_t* dci, - srslte_pusch_grant_t* grant, +static int ra_ul_grant_to_grant_prb_allocation(srsran_dci_ul_t* dci, + srsran_pusch_grant_t* grant, uint32_t n_rb_ho, uint32_t nof_prb) { uint32_t n_prb_1 = 0; uint32_t n_rb_pusch = 0; - srslte_ra_type2_from_riv(dci->type2_alloc.riv, &grant->L_prb, &n_prb_1, nof_prb, nof_prb); + srsran_ra_type2_from_riv(dci->type2_alloc.riv, &grant->L_prb, &n_prb_1, nof_prb, nof_prb); if (n_rb_ho % 2) { n_rb_ho++; } - if (dci->freq_hop_fl == SRSLTE_RA_PUSCH_HOP_DISABLED || dci->freq_hop_fl == SRSLTE_RA_PUSCH_HOP_TYPE2) { + if (dci->freq_hop_fl == SRSRAN_RA_PUSCH_HOP_DISABLED || dci->freq_hop_fl == SRSRAN_RA_PUSCH_HOP_TYPE2) { /* For no freq hopping or type2 freq hopping, n_prb is the same * n_prb_tilde is calculated during resource mapping */ for (uint32_t i = 0; i < 2; i++) { grant->n_prb[i] = n_prb_1; } - if (dci->freq_hop_fl == SRSLTE_RA_PUSCH_HOP_DISABLED) { + if (dci->freq_hop_fl == SRSRAN_RA_PUSCH_HOP_DISABLED) { grant->freq_hopping = 0; } else { grant->freq_hopping = 2; @@ -155,23 +155,23 @@ static int ra_ul_grant_to_grant_prb_allocation(srslte_dci_ul_t* dci, grant->n_prb[0] = n_prb_1; if (n_prb_1 < n_rb_ho / 2) { INFO("Invalid Frequency Hopping parameters. Offset: %d, n_prb_1: %d", n_rb_ho, n_prb_1); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } uint32_t n_prb_1_tilde = n_prb_1; // prb idx for slot 1 switch (dci->freq_hop_fl) { - case SRSLTE_RA_PUSCH_HOP_QUART: + case SRSRAN_RA_PUSCH_HOP_QUART: grant->n_prb[1] = (n_rb_pusch / 4 + n_prb_1_tilde) % n_rb_pusch; break; - case SRSLTE_RA_PUSCH_HOP_QUART_NEG: + case SRSRAN_RA_PUSCH_HOP_QUART_NEG: if (n_prb_1 < n_rb_pusch / 4) { grant->n_prb[1] = (n_rb_pusch + n_prb_1_tilde - n_rb_pusch / 4); } else { grant->n_prb[1] = (n_prb_1_tilde - n_rb_pusch / 4); } break; - case SRSLTE_RA_PUSCH_HOP_HALF: + case SRSRAN_RA_PUSCH_HOP_HALF: grant->n_prb[1] = (n_rb_pusch / 2 + n_prb_1_tilde) % n_rb_pusch; break; default: @@ -182,32 +182,32 @@ static int ra_ul_grant_to_grant_prb_allocation(srslte_dci_ul_t* dci, } if (grant->n_prb[0] + grant->L_prb <= nof_prb && grant->n_prb[1] + grant->L_prb <= nof_prb) { - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } else { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } -static void ul_fill_ra_mcs(srslte_ra_tb_t* tb, srslte_ra_tb_t* last_tb, uint32_t L_prb, bool cqi_request) +static void ul_fill_ra_mcs(srsran_ra_tb_t* tb, srsran_ra_tb_t* last_tb, uint32_t L_prb, bool cqi_request) { // 8.6.2 First paragraph if (tb->mcs_idx <= 28) { /* Table 8.6.1-1 on 36.213 */ if (tb->mcs_idx < 11) { - tb->mod = SRSLTE_MOD_QPSK; - tb->tbs = srslte_ra_tbs_from_idx(tb->mcs_idx, L_prb); + tb->mod = SRSRAN_MOD_QPSK; + tb->tbs = srsran_ra_tbs_from_idx(tb->mcs_idx, L_prb); } else if (tb->mcs_idx < 21) { - tb->mod = SRSLTE_MOD_16QAM; - tb->tbs = srslte_ra_tbs_from_idx(tb->mcs_idx - 1, L_prb); + tb->mod = SRSRAN_MOD_16QAM; + tb->tbs = srsran_ra_tbs_from_idx(tb->mcs_idx - 1, L_prb); } else if (tb->mcs_idx < 29) { - tb->mod = SRSLTE_MOD_64QAM; - tb->tbs = srslte_ra_tbs_from_idx(tb->mcs_idx - 2, L_prb); + tb->mod = SRSRAN_MOD_64QAM; + tb->tbs = srsran_ra_tbs_from_idx(tb->mcs_idx - 2, L_prb); } else { ERROR("Invalid MCS index %d", tb->mcs_idx); } } else if (tb->mcs_idx == 29 && cqi_request && L_prb <= 4) { // 8.6.1 and 8.6.2 36.213 second paragraph - tb->mod = SRSLTE_MOD_QPSK; + tb->mod = SRSRAN_MOD_QPSK; tb->tbs = 0; tb->rv = 1; } else if (tb->mcs_idx >= 29) { @@ -218,11 +218,11 @@ static void ul_fill_ra_mcs(srslte_ra_tb_t* tb, srslte_ra_tb_t* last_tb, uint32_t } } -void srslte_ra_ul_compute_nof_re(srslte_pusch_grant_t* grant, srslte_cp_t cp, uint32_t N_srs) +void srsran_ra_ul_compute_nof_re(srsran_pusch_grant_t* grant, srsran_cp_t cp, uint32_t N_srs) { - grant->nof_symb = 2 * (SRSLTE_CP_NSYMB(cp) - 1) - N_srs; - grant->nof_re = grant->nof_symb * grant->L_prb * SRSLTE_NRE; - grant->tb.nof_bits = grant->nof_re * srslte_mod_bits_x_symbol(grant->tb.mod); + grant->nof_symb = 2 * (SRSRAN_CP_NSYMB(cp) - 1) - N_srs; + grant->nof_re = grant->nof_symb * grant->L_prb * SRSRAN_NRE; + grant->tb.nof_bits = grant->nof_re * srsran_mod_bits_x_symbol(grant->tb.mod); } /********** @@ -233,33 +233,33 @@ void srslte_ra_ul_compute_nof_re(srslte_pusch_grant_t* grant, srslte_cp_t cp, ui /* Initializes the Pseudo-Random sequence to the provided cell id. Can be called multiple times without allocating new * memory */ -int srslte_ra_ul_pusch_hopping_init(srslte_ra_ul_pusch_hopping_t* q, srslte_cell_t cell) +int srsran_ra_ul_pusch_hopping_init(srsran_ra_ul_pusch_hopping_t* q, srsran_cell_t cell) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q) { if (cell.id != q->cell.id || !q->initialized) { q->cell = cell; q->initialized = true; /* Precompute sequence for type2 frequency hopping */ - if (srslte_sequence_LTE_pr(&q->seq_type2_fo, 210, q->cell.id)) { + if (srsran_sequence_LTE_pr(&q->seq_type2_fo, 210, q->cell.id)) { ERROR("Error initiating type2 frequency hopping sequence"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } } return ret; } -void srslte_ra_ul_pusch_hopping_free(srslte_ra_ul_pusch_hopping_t* q) +void srsran_ra_ul_pusch_hopping_free(srsran_ra_ul_pusch_hopping_t* q) { - srslte_sequence_free(&q->seq_type2_fo); + srsran_sequence_free(&q->seq_type2_fo); } -void srslte_ra_ul_pusch_hopping(srslte_ra_ul_pusch_hopping_t* q, - srslte_ul_sf_cfg_t* sf, - srslte_pusch_hopping_cfg_t* hopping_cfg, - srslte_pusch_grant_t* grant) +void srsran_ra_ul_pusch_hopping(srsran_ra_ul_pusch_hopping_t* q, + srsran_ul_sf_cfg_t* sf, + srsran_pusch_hopping_cfg_t* hopping_cfg, + srsran_pusch_grant_t* grant) { /* Compute PUSCH frequency hopping */ if (hopping_cfg->hopping_enabled) { @@ -271,11 +271,11 @@ void srslte_ra_ul_pusch_hopping(srslte_ra_ul_pusch_hopping_t* q, } /** Compute PRB allocation for Uplink as defined in 8.1 and 8.4 of 36.213 */ -int srslte_ra_ul_dci_to_grant(srslte_cell_t* cell, - srslte_ul_sf_cfg_t* sf, - srslte_pusch_hopping_cfg_t* hopping_cfg, - srslte_dci_ul_t* dci, - srslte_pusch_grant_t* grant) +int srsran_ra_ul_dci_to_grant(srsran_cell_t* cell, + srsran_ul_sf_cfg_t* sf, + srsran_pusch_hopping_cfg_t* hopping_cfg, + srsran_dci_ul_t* dci, + srsran_pusch_grant_t* grant) { // Compute PRB allocation if (!ra_ul_grant_to_grant_prb_allocation(dci, grant, hopping_cfg->n_rb_ho, cell->nof_prb)) { @@ -287,7 +287,7 @@ int srslte_ra_ul_dci_to_grant(srslte_cell_t* cell, ul_fill_ra_mcs(&grant->tb, &grant->last_tb, grant->L_prb, dci->cqi_request); /* Compute RE assuming shortened is false*/ - srslte_ra_ul_compute_nof_re(grant, cell->cp, 0); + srsran_ra_ul_compute_nof_re(grant, cell->cp, 0); // TODO: Need to compute hopping here before determining if there is collision with SRS, but only MAC knows if it's // a @@ -298,18 +298,18 @@ int srslte_ra_ul_dci_to_grant(srslte_cell_t* cell, if (grant->nof_symb == 0 || grant->nof_re == 0) { INFO("Error converting ul_dci to grant, nof_symb=%d, nof_re=%d", grant->nof_symb, grant->nof_re); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } else { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } -uint32_t srslte_ra_ul_info(const srslte_pusch_grant_t* grant, char* info_str, uint32_t len) +uint32_t srsran_ra_ul_info(const srsran_pusch_grant_t* grant, char* info_str, uint32_t len) { - return srslte_print_check(info_str, + return srsran_print_check(info_str, len, 0, ", rb=(%d,%d), nof_re=%d, tbs=%d, mod=%d, rv=%d", @@ -317,6 +317,6 @@ uint32_t srslte_ra_ul_info(const srslte_pusch_grant_t* grant, char* info_str, ui grant->n_prb_tilde[0] + grant->L_prb - 1, grant->nof_re, grant->tb.tbs / 8, - srslte_mod_bits_x_symbol(grant->tb.mod), + srsran_mod_bits_x_symbol(grant->tb.mod), grant->tb.rv); } diff --git a/lib/src/phy/phch/ra_ul_nr.c b/lib/src/phy/phch/ra_ul_nr.c index 55366fc28..41fe9ed30 100644 --- a/lib/src/phy/phch/ra_ul_nr.c +++ b/lib/src/phy/phch/ra_ul_nr.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,54 +10,54 @@ * */ -#include "srslte/phy/phch/ra_ul_nr.h" +#include "srsran/phy/phch/ra_ul_nr.h" #include "ra_helper.h" -#include "srslte/phy/ch_estimation/dmrs_pucch.h" -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/phch/csi.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/ch_estimation/dmrs_pucch.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/phch/csi.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" typedef struct { - srslte_sch_mapping_type_t mapping; + srsran_sch_mapping_type_t mapping; uint32_t K2; uint32_t S; uint32_t L; } ue_ra_time_resource_t; -static const ue_ra_time_resource_t ue_ul_default_A_lut[16] = {{srslte_sch_mapping_type_A, 0, 0, 14}, - {srslte_sch_mapping_type_A, 0, 0, 12}, - {srslte_sch_mapping_type_A, 0, 0, 10}, - {srslte_sch_mapping_type_B, 0, 2, 10}, - {srslte_sch_mapping_type_B, 0, 4, 10}, - {srslte_sch_mapping_type_B, 0, 4, 8}, - {srslte_sch_mapping_type_B, 0, 4, 6}, - {srslte_sch_mapping_type_A, 1, 0, 14}, - {srslte_sch_mapping_type_A, 1, 0, 12}, - {srslte_sch_mapping_type_A, 1, 0, 10}, - {srslte_sch_mapping_type_A, 2, 0, 14}, - {srslte_sch_mapping_type_A, 2, 0, 12}, - {srslte_sch_mapping_type_A, 2, 0, 10}, - {srslte_sch_mapping_type_B, 0, 8, 6}, - {srslte_sch_mapping_type_A, 3, 0, 14}, - {srslte_sch_mapping_type_A, 3, 0, 10}}; - -int srslte_ra_ul_nr_pusch_time_resource_default_A(uint32_t scs_cfg, uint32_t m, srslte_sch_grant_nr_t* grant) +static const ue_ra_time_resource_t ue_ul_default_A_lut[16] = {{srsran_sch_mapping_type_A, 0, 0, 14}, + {srsran_sch_mapping_type_A, 0, 0, 12}, + {srsran_sch_mapping_type_A, 0, 0, 10}, + {srsran_sch_mapping_type_B, 0, 2, 10}, + {srsran_sch_mapping_type_B, 0, 4, 10}, + {srsran_sch_mapping_type_B, 0, 4, 8}, + {srsran_sch_mapping_type_B, 0, 4, 6}, + {srsran_sch_mapping_type_A, 1, 0, 14}, + {srsran_sch_mapping_type_A, 1, 0, 12}, + {srsran_sch_mapping_type_A, 1, 0, 10}, + {srsran_sch_mapping_type_A, 2, 0, 14}, + {srsran_sch_mapping_type_A, 2, 0, 12}, + {srsran_sch_mapping_type_A, 2, 0, 10}, + {srsran_sch_mapping_type_B, 0, 8, 6}, + {srsran_sch_mapping_type_A, 3, 0, 14}, + {srsran_sch_mapping_type_A, 3, 0, 10}}; + +int srsran_ra_ul_nr_pusch_time_resource_default_A(uint32_t scs_cfg, uint32_t m, srsran_sch_grant_nr_t* grant) { uint32_t j[4] = {1, 1, 2, 3}; if (grant == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } if (scs_cfg > 4) { ERROR("Invalid numerology (%d)", scs_cfg); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (m >= 16) { ERROR("m (%d) is out-of-range", m); - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } // Select mapping @@ -66,13 +66,13 @@ int srslte_ra_ul_nr_pusch_time_resource_default_A(uint32_t scs_cfg, uint32_t m, grant->S = ue_ul_default_A_lut[m].S; grant->L = ue_ul_default_A_lut[m].L; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -static void ra_ul_nr_time_hl(const srslte_sch_time_ra_t* hl_ra_cfg, srslte_sch_grant_nr_t* grant) +static void ra_ul_nr_time_hl(const srsran_sch_time_ra_t* hl_ra_cfg, srsran_sch_grant_nr_t* grant) { // Compute S and L from SLIV from higher layers - ra_helper_compute_s_and_l(SRSLTE_NSYMB_PER_SLOT_NR, hl_ra_cfg->sliv, &grant->S, &grant->L); + ra_helper_compute_s_and_l(SRSRAN_NSYMB_PER_SLOT_NR, hl_ra_cfg->sliv, &grant->S, &grant->L); grant->k = hl_ra_cfg->k; grant->mapping = hl_ra_cfg->mapping_type; @@ -112,63 +112,63 @@ static bool check_time_ra_typeB(uint32_t* S, uint32_t* L) return false; } -bool srslte_ra_ul_nr_time_validate(srslte_sch_grant_nr_t* grant) +bool srsran_ra_ul_nr_time_validate(srsran_sch_grant_nr_t* grant) { - if (grant->mapping == srslte_sch_mapping_type_A) { + if (grant->mapping == srsran_sch_mapping_type_A) { return check_time_ra_typeA(&grant->S, &grant->L); } return check_time_ra_typeB(&grant->S, &grant->L); } -int srslte_ra_ul_nr_time(const srslte_sch_hl_cfg_nr_t* cfg, - const srslte_rnti_type_t rnti_type, - const srslte_search_space_type_t ss_type, +int srsran_ra_ul_nr_time(const srsran_sch_hl_cfg_nr_t* cfg, + const srsran_rnti_type_t rnti_type, + const srsran_search_space_type_t ss_type, const uint32_t coreset_id, const uint8_t m, - srslte_sch_grant_nr_t* grant) + srsran_sch_grant_nr_t* grant) { if (cfg == NULL || grant == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } - if (m >= SRSLTE_MAX_NOF_DL_ALLOCATION) { + if (m >= SRSRAN_MAX_NOF_DL_ALLOCATION) { ERROR("m (%d) is out-of-range", m); - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } // Determine which PUSCH Time domain RA configuration to apply (TS 38.214 Table 6.1.2.1.1-1:) - if (ss_type == srslte_search_space_type_rar) { + if (ss_type == srsran_search_space_type_rar) { // Row 1 if (cfg->nof_common_time_ra == 0) { - srslte_ra_ul_nr_pusch_time_resource_default_A(cfg->scs_cfg, m, grant); - } else if (m < SRSLTE_MAX_NOF_DL_ALLOCATION && m < cfg->nof_common_time_ra) { + srsran_ra_ul_nr_pusch_time_resource_default_A(cfg->scs_cfg, m, grant); + } else if (m < SRSRAN_MAX_NOF_DL_ALLOCATION && m < cfg->nof_common_time_ra) { ra_ul_nr_time_hl(&cfg->common_time_ra[m], grant); } else { ERROR("Time domain resource selection (m=%d) exceeds the maximum value (%d)", m, - SRSLTE_MIN(cfg->nof_common_time_ra, SRSLTE_MAX_NOF_DL_ALLOCATION)); + SRSRAN_MIN(cfg->nof_common_time_ra, SRSRAN_MAX_NOF_DL_ALLOCATION)); } - } else if ((rnti_type == srslte_rnti_type_c || rnti_type == srslte_rnti_type_mcs_c || - rnti_type == srslte_rnti_type_tc || rnti_type == srslte_rnti_type_cs) && - SRSLTE_SEARCH_SPACE_IS_COMMON(ss_type) && coreset_id == 0) { + } else if ((rnti_type == srsran_rnti_type_c || rnti_type == srsran_rnti_type_mcs_c || + rnti_type == srsran_rnti_type_tc || rnti_type == srsran_rnti_type_cs) && + SRSRAN_SEARCH_SPACE_IS_COMMON(ss_type) && coreset_id == 0) { // Row 2 if (cfg->nof_common_time_ra == 0) { - srslte_ra_ul_nr_pusch_time_resource_default_A(cfg->scs_cfg, m, grant); - } else if (m < SRSLTE_MAX_NOF_DL_ALLOCATION) { + srsran_ra_ul_nr_pusch_time_resource_default_A(cfg->scs_cfg, m, grant); + } else if (m < SRSRAN_MAX_NOF_DL_ALLOCATION) { ra_ul_nr_time_hl(&cfg->common_time_ra[m], grant); } - } else if ((rnti_type == srslte_rnti_type_c || rnti_type == srslte_rnti_type_mcs_c || - rnti_type == srslte_rnti_type_tc || rnti_type == srslte_rnti_type_cs || - rnti_type == srslte_rnti_type_sp_csi) && - ((SRSLTE_SEARCH_SPACE_IS_COMMON(ss_type) && coreset_id != 0) || ss_type == srslte_search_space_type_ue)) { + } else if ((rnti_type == srsran_rnti_type_c || rnti_type == srsran_rnti_type_mcs_c || + rnti_type == srsran_rnti_type_tc || rnti_type == srsran_rnti_type_cs || + rnti_type == srsran_rnti_type_sp_csi) && + ((SRSRAN_SEARCH_SPACE_IS_COMMON(ss_type) && coreset_id != 0) || ss_type == srsran_search_space_type_ue)) { // Row 3 if (cfg->nof_dedicated_time_ra > 0) { ra_ul_nr_time_hl(&cfg->dedicated_time_ra[m], grant); } else if (cfg->nof_common_time_ra > 0) { ra_ul_nr_time_hl(&cfg->common_time_ra[m], grant); } else { - srslte_ra_ul_nr_pusch_time_resource_default_A(cfg->scs_cfg, m, grant); + srsran_ra_ul_nr_pusch_time_resource_default_A(cfg->scs_cfg, m, grant); } } else { ERROR("Unhandled case"); @@ -177,29 +177,29 @@ int srslte_ra_ul_nr_time(const srslte_sch_hl_cfg_nr_t* cfg, // Table 6.1.2.1.1-5 defines the additional subcarrier spacing specific slot delay value for the first transmission of // PUSCH scheduled by the RAR. When the UE transmits a PUSCH scheduled by RAR, the Δ value specific to the PUSCH // subcarrier spacing μ PUSCH is applied in addition to the K 2 value. - if (ss_type == srslte_search_space_type_rar) { + if (ss_type == srsran_search_space_type_rar) { uint32_t delta[4] = {2, 3, 4, 6}; if (cfg->scs_cfg >= 4) { ERROR("Invalid numerology"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } grant->k += delta[cfg->scs_cfg]; } // Validate S and L parameters - if (!srslte_ra_ul_nr_time_validate(grant)) { + if (!srsran_ra_ul_nr_time_validate(grant)) { ERROR("Invalid Time RA S=%d; L=%d; m=%d", grant->S, grant->L, m); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_ra_ul_nr_nof_dmrs_cdm_groups_without_data_format_0_0(const srslte_sch_cfg_nr_t* cfg, - srslte_sch_grant_nr_t* grant) +int srsran_ra_ul_nr_nof_dmrs_cdm_groups_without_data_format_0_0(const srsran_sch_cfg_nr_t* cfg, + srsran_sch_grant_nr_t* grant) { if (cfg == NULL || grant == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } /* According to TS 38.214 V15.10.0 6.2.2 UE DM-RS transmission procedure: @@ -213,31 +213,31 @@ int srslte_ra_ul_nr_nof_dmrs_cdm_groups_without_data_format_0_0(const srslte_sch */ if (grant->L <= 2 && !cfg->enable_transform_precoder) { grant->nof_dmrs_cdm_groups_without_data = 1; - // } else if (grant->L > 2 && cfg->dmrs_cg.type == srslte_dmrs_sch_type_2){ + // } else if (grant->L > 2 && cfg->dmrs_cg.type == srsran_dmrs_sch_type_2){ // grant->nof_dmrs_cdm_groups_without_data = 3; } else { grant->nof_dmrs_cdm_groups_without_data = 2; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_ra_ul_nr_dmrs_power_offset(srslte_sch_grant_nr_t* grant) +int srsran_ra_ul_nr_dmrs_power_offset(srsran_sch_grant_nr_t* grant) { if (grant == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } float ratio_dB[3] = {0, -3, -4.77}; if (grant->nof_dmrs_cdm_groups_without_data < 1 || grant->nof_dmrs_cdm_groups_without_data > 3) { ERROR("Invalid number of DMRS CDM groups without data (%d)", grant->nof_dmrs_cdm_groups_without_data); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - grant->beta_dmrs = srslte_convert_dB_to_amplitude(-ratio_dB[grant->nof_dmrs_cdm_groups_without_data - 1]); + grant->beta_dmrs = srsran_convert_dB_to_amplitude(-ratio_dB[grant->nof_dmrs_cdm_groups_without_data - 1]); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } #define RA_UL_PUCCH_CODE_RATE_N 8 @@ -247,7 +247,7 @@ static const double ra_ul_pucch_code_rate_table[RA_UL_PUCCH_CODE_RATE_N] = {0.08, 0.15, 0.25, 0.35, 0.45, 0.60, 0.80, RA_UL_PUCCH_CODE_RATE_RESERVED}; // Implements TS 38.213 Table 9.2.5.2-1: Code rate r corresponding to value of maxCodeRate -static double ra_ul_nr_pucch_code_rate_r(const srslte_pucch_nr_resource_t* resource) +static double ra_ul_nr_pucch_code_rate_r(const srsran_pucch_nr_resource_t* resource) { if (resource->max_code_rate >= RA_UL_PUCCH_CODE_RATE_RESERVED) { ERROR("Invalid code rate"); @@ -258,52 +258,52 @@ static double ra_ul_nr_pucch_code_rate_r(const srslte_pucch_nr_resource_t* resou } // Calculate number of PRBs for PUCCH format 2, or PUCCH format 3, or PUCCH format 4, respectively -// static int ra_ul_nr_pucch_Mrb(const srslte_pucch_nr_resource_t* resource) +// static int ra_ul_nr_pucch_Mrb(const srsran_pucch_nr_resource_t* resource) //{ // switch (resource->format) { -// case SRSLTE_PUCCH_NR_FORMAT_2: -// case SRSLTE_PUCCH_NR_FORMAT_3: +// case SRSRAN_PUCCH_NR_FORMAT_2: +// case SRSRAN_PUCCH_NR_FORMAT_3: // return resource->nof_prb; -// case SRSLTE_PUCCH_NR_FORMAT_4: -// return SRSLTE_PUCCH_NR_FORMAT4_NPRB; +// case SRSRAN_PUCCH_NR_FORMAT_4: +// return SRSRAN_PUCCH_NR_FORMAT4_NPRB; // default: // ERROR("Invalid case"); // break; // } -// return SRSLTE_ERROR; +// return SRSRAN_ERROR; //} // Calculate number of subcarriers per resource block for payload (No DMRS) -static int ra_ul_nr_pucch_nre(const srslte_pucch_nr_resource_t* resource) +static int ra_ul_nr_pucch_nre(const srsran_pucch_nr_resource_t* resource) { switch (resource->format) { - case SRSLTE_PUCCH_NR_FORMAT_2: - return SRSLTE_NRE - 4; - case SRSLTE_PUCCH_NR_FORMAT_3: - return SRSLTE_NRE; - case SRSLTE_PUCCH_NR_FORMAT_4: - return SRSLTE_NRE / resource->occ_lenth; + case SRSRAN_PUCCH_NR_FORMAT_2: + return SRSRAN_NRE - 4; + case SRSRAN_PUCCH_NR_FORMAT_3: + return SRSRAN_NRE; + case SRSRAN_PUCCH_NR_FORMAT_4: + return SRSRAN_NRE / resource->occ_lenth; default: ERROR("Invalid case"); break; } - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Calculate number of PUCCH symbols excluding the ones used exclusively for DMRS for formats 3 and 4 -static int ra_ul_nr_pucch_nsymb(const srslte_pucch_nr_resource_t* resource) +static int ra_ul_nr_pucch_nsymb(const srsran_pucch_nr_resource_t* resource) { switch (resource->format) { - case SRSLTE_PUCCH_NR_FORMAT_2: + case SRSRAN_PUCCH_NR_FORMAT_2: return resource->nof_symbols; - case SRSLTE_PUCCH_NR_FORMAT_3: - case SRSLTE_PUCCH_NR_FORMAT_4: { - uint32_t idx[SRSLTE_DMRS_PUCCH_FORMAT_3_4_MAX_NSYMB] = {}; + case SRSRAN_PUCCH_NR_FORMAT_3: + case SRSRAN_PUCCH_NR_FORMAT_4: { + uint32_t idx[SRSRAN_DMRS_PUCCH_FORMAT_3_4_MAX_NSYMB] = {}; // Get number of DMRS symbols for format 3 or 4 - int nsymb_dmrs = srslte_dmrs_pucch_format_3_4_get_symbol_idx(resource, idx); - if (nsymb_dmrs < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + int nsymb_dmrs = srsran_dmrs_pucch_format_3_4_get_symbol_idx(resource, idx); + if (nsymb_dmrs < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } return (int)resource->nof_symbols - nsymb_dmrs; @@ -312,109 +312,109 @@ static int ra_ul_nr_pucch_nsymb(const srslte_pucch_nr_resource_t* resource) ERROR("Invalid case"); break; } - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Calculate number of PUCCH symbols excluding the ones used exclusively for DMRS for formats 3 and 4 -static int ra_ul_nr_pucch_qm(const srslte_pucch_nr_resource_t* resource) +static int ra_ul_nr_pucch_qm(const srsran_pucch_nr_resource_t* resource) { switch (resource->format) { - case SRSLTE_PUCCH_NR_FORMAT_2: + case SRSRAN_PUCCH_NR_FORMAT_2: return 2; - case SRSLTE_PUCCH_NR_FORMAT_3: - case SRSLTE_PUCCH_NR_FORMAT_4: + case SRSRAN_PUCCH_NR_FORMAT_3: + case SRSRAN_PUCCH_NR_FORMAT_4: return resource->enable_pi_bpsk ? 1 : 2; default: ERROR("Invalid case"); break; } - return SRSLTE_ERROR; + return SRSRAN_ERROR; } -int srslte_ra_ul_nr_pucch_format_2_3_min_prb(const srslte_pucch_nr_resource_t* resource, - const srslte_uci_cfg_nr_t* uci_cfg) +int srsran_ra_ul_nr_pucch_format_2_3_min_prb(const srsran_pucch_nr_resource_t* resource, + const srsran_uci_cfg_nr_t* uci_cfg) { if (resource == NULL || uci_cfg == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } // Get maximum allowed code rate double r = ra_ul_nr_pucch_code_rate_r(resource); if (!isnormal(r)) { ERROR("Invalid coderate %f", r); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Get number of RE/PRB int nre = ra_ul_nr_pucch_nre(resource); - if (nre < SRSLTE_SUCCESS) { + if (nre < SRSRAN_SUCCESS) { ERROR("Getting nre"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Get number of symbols int nsymb = ra_ul_nr_pucch_nsymb(resource); - if (nsymb < SRSLTE_SUCCESS) { + if (nsymb < SRSRAN_SUCCESS) { ERROR("Getting nsymb"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Get modulation order int qm = ra_ul_nr_pucch_qm(resource); - if (qm < SRSLTE_SUCCESS) { + if (qm < SRSRAN_SUCCESS) { ERROR("Getting qm"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Calculate denominator double nof_bits_rb = r * nre * nsymb * qm; if (!isnormal(nof_bits_rb)) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Compute total number of UCI bits - uint32_t O_total = uci_cfg->o_ack + uci_cfg->o_sr + srslte_csi_part1_nof_bits(uci_cfg->csi, uci_cfg->nof_csi); + uint32_t O_total = uci_cfg->o_ack + uci_cfg->o_sr + srsran_csi_part1_nof_bits(uci_cfg->csi, uci_cfg->nof_csi); // Add CRC bits if any - O_total += srslte_uci_nr_crc_len(O_total); + O_total += srsran_uci_nr_crc_len(O_total); // Return the minimum return (int)ceil(O_total / nof_bits_rb); } -int srslte_ra_ul_nr_freq(const srslte_carrier_nr_t* carrier, - const srslte_sch_hl_cfg_nr_t* cfg, - const srslte_dci_ul_nr_t* dci_ul, - srslte_sch_grant_nr_t* grant) +int srsran_ra_ul_nr_freq(const srsran_carrier_nr_t* carrier, + const srsran_sch_hl_cfg_nr_t* cfg, + const srsran_dci_ul_nr_t* dci_ul, + srsran_sch_grant_nr_t* grant) { if (cfg == NULL || grant == NULL || dci_ul == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } // RA scheme - if (dci_ul->format == srslte_dci_format_nr_0_0) { + if (dci_ul->format == srsran_dci_format_nr_0_0) { // when the scheduling grant is received with DCI format 1_0 , then downlink resource allocation type 1 is used. return ra_helper_freq_type1(carrier->nof_prb, dci_ul->freq_domain_assigment, grant); } ERROR("Only DCI Format 0_0 is supported"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Implements TS 38.213 Table 9.2.1-1: PUCCH resource sets before dedicated PUCCH resource configuration -static int ra_ul_nr_pucch_resource_default(uint32_t r_pucch, srslte_pucch_nr_resource_t* resource) +static int ra_ul_nr_pucch_resource_default(uint32_t r_pucch, srsran_pucch_nr_resource_t* resource) { ERROR("Not implemented"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } -static int ra_ul_nr_pucch_resource_hl(const srslte_pucch_nr_hl_cfg_t* cfg, +static int ra_ul_nr_pucch_resource_hl(const srsran_pucch_nr_hl_cfg_t* cfg, uint32_t O_uci, uint32_t pucch_resource_id, - srslte_pucch_nr_resource_t* resource) + srsran_pucch_nr_resource_t* resource) { - uint32_t N2 = cfg->sets[1].max_payload_size > 0 ? cfg->sets[1].max_payload_size : SRSLTE_UCI_NR_MAX_NOF_BITS; - uint32_t N3 = cfg->sets[2].max_payload_size > 0 ? cfg->sets[2].max_payload_size : SRSLTE_UCI_NR_MAX_NOF_BITS; + uint32_t N2 = cfg->sets[1].max_payload_size > 0 ? cfg->sets[1].max_payload_size : SRSRAN_UCI_NR_MAX_NOF_BITS; + uint32_t N3 = cfg->sets[2].max_payload_size > 0 ? cfg->sets[2].max_payload_size : SRSRAN_UCI_NR_MAX_NOF_BITS; // If the UE transmits O UCI UCI information bits, that include HARQ-ACK information bits, the UE determines a PUCCH // resource set to be... @@ -427,65 +427,65 @@ static int ra_ul_nr_pucch_resource_hl(const srslte_pucch_nr_hl_cfg_t* cfg, resource_set_id = 2; } else if (cfg->sets[3].nof_resources == 0) { ERROR("Invalid PUCCH resource configuration, N3=%d, O_uci=%d", N3, O_uci); - return SRSLTE_ERROR; - } else if (O_uci > SRSLTE_UCI_NR_MAX_NOF_BITS) { - ERROR("The number of UCI bits (%d), exceeds the maximum (%d)", O_uci, SRSLTE_UCI_NR_MAX_NOF_BITS); - return SRSLTE_ERROR; + return SRSRAN_ERROR; + } else if (O_uci > SRSRAN_UCI_NR_MAX_NOF_BITS) { + ERROR("The number of UCI bits (%d), exceeds the maximum (%d)", O_uci, SRSRAN_UCI_NR_MAX_NOF_BITS); + return SRSRAN_ERROR; } // Select resource from the set - if (pucch_resource_id >= SRSLTE_PUCCH_NR_MAX_NOF_RESOURCES_PER_SET || + if (pucch_resource_id >= SRSRAN_PUCCH_NR_MAX_NOF_RESOURCES_PER_SET || pucch_resource_id >= cfg->sets[resource_set_id].nof_resources) { ERROR("The PUCCH resource identifier (%d) exceeds the number of configured resources (%d) for set identifier %d", pucch_resource_id, cfg->sets[resource_set_id].nof_resources, resource_set_id); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } *resource = cfg->sets[resource_set_id].resources[pucch_resource_id]; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_ra_ul_nr_pucch_resource(const srslte_pucch_nr_hl_cfg_t* pucch_cfg, - const srslte_uci_cfg_nr_t* uci_cfg, - srslte_pucch_nr_resource_t* resource) +int srsran_ra_ul_nr_pucch_resource(const srsran_pucch_nr_hl_cfg_t* pucch_cfg, + const srsran_uci_cfg_nr_t* uci_cfg, + srsran_pucch_nr_resource_t* resource) { if (pucch_cfg == NULL || uci_cfg == NULL || resource == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } - uint32_t O_uci = srslte_uci_nr_total_bits(uci_cfg); + uint32_t O_uci = srsran_uci_nr_total_bits(uci_cfg); // Use SR PUCCH resource // - At least one positive SR // - up to 2 HARQ-ACK // - No CSI report - if (uci_cfg->pucch.sr_positive_present > 0 && uci_cfg->o_ack <= SRSLTE_PUCCH_NR_FORMAT1_MAX_NOF_BITS && + if (uci_cfg->pucch.sr_positive_present > 0 && uci_cfg->o_ack <= SRSRAN_PUCCH_NR_FORMAT1_MAX_NOF_BITS && uci_cfg->nof_csi == 0) { uint32_t sr_resource_id = uci_cfg->pucch.sr_resource_id; - if (sr_resource_id >= SRSLTE_PUCCH_MAX_NOF_SR_RESOURCES) { - ERROR("SR resource ID (%d) exceeds the maximum ID (%d)", sr_resource_id, SRSLTE_PUCCH_MAX_NOF_SR_RESOURCES); - return SRSLTE_ERROR; + if (sr_resource_id >= SRSRAN_PUCCH_MAX_NOF_SR_RESOURCES) { + ERROR("SR resource ID (%d) exceeds the maximum ID (%d)", sr_resource_id, SRSRAN_PUCCH_MAX_NOF_SR_RESOURCES); + return SRSRAN_ERROR; } if (!pucch_cfg->sr_resources[sr_resource_id].configured) { ERROR("SR resource ID (%d) is not configured", sr_resource_id); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Set PUCCH resource *resource = pucch_cfg->sr_resources[sr_resource_id].resource; // No more logic is required in this case - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Use format 2, 3 or 4 resource from higher layers // - Irrelevant SR opportunities // - More than 2 HARQ-ACK // - No CSI report - if (uci_cfg->o_sr > 0 && uci_cfg->o_ack > SRSLTE_PUCCH_NR_FORMAT1_MAX_NOF_BITS && uci_cfg->nof_csi == 0) { + if (uci_cfg->o_sr > 0 && uci_cfg->o_ack > SRSRAN_PUCCH_NR_FORMAT1_MAX_NOF_BITS && uci_cfg->nof_csi == 0) { return ra_ul_nr_pucch_resource_hl(pucch_cfg, O_uci, uci_cfg->pucch.resource_id, resource); } @@ -493,9 +493,9 @@ int srslte_ra_ul_nr_pucch_resource(const srslte_pucch_nr_hl_cfg_t* pucch_cfg, // - Irrelevant SR opportunities // - No HARQ-ACK // - Single periodic CSI report - if (uci_cfg->o_ack == 0 && uci_cfg->nof_csi == 1 && uci_cfg->csi[0].type == SRSLTE_CSI_REPORT_TYPE_PERIODIC) { + if (uci_cfg->o_ack == 0 && uci_cfg->nof_csi == 1 && uci_cfg->csi[0].type == SRSRAN_CSI_REPORT_TYPE_PERIODIC) { *resource = uci_cfg->csi[0].pucch_resource; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // If a UE does not have dedicated PUCCH resource configuration, provided by PUCCH-ResourceSet in PUCCH-Config, @@ -508,7 +508,7 @@ int srslte_ra_ul_nr_pucch_resource(const srslte_pucch_nr_hl_cfg_t* pucch_cfg, return ra_ul_nr_pucch_resource_hl(pucch_cfg, O_uci, uci_cfg->pucch.resource_id, resource); } -uint32_t srslte_ra_ul_nr_nof_sr_bits(uint32_t K) +uint32_t srsran_ra_ul_nr_nof_sr_bits(uint32_t K) { if (K > 0) { return (uint32_t)ceilf(log2f((float)K + 1.0f)); diff --git a/lib/src/phy/phch/regs.c b/lib/src/phy/phch/regs.c index fa48e25bb..f52829d59 100644 --- a/lib/src/phy/phch/regs.c +++ b/lib/src/phy/phch/regs.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -15,20 +15,20 @@ #include #include -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/phch/regs.h" -#include "srslte/phy/utils/debug.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/phch/regs.h" +#include "srsran/phy/utils/debug.h" -#define REG_IDX(r, i, n) r->k[i] + r->l* n* SRSLTE_NRE +#define REG_IDX(r, i, n) r->k[i] + r->l* n* SRSRAN_NRE -srslte_regs_reg_t* regs_find_reg(srslte_regs_t* h, uint32_t k, uint32_t l); -int regs_put_reg(srslte_regs_reg_t* reg, cf_t* reg_data, cf_t* slot_symbols, uint32_t nof_prb); +srsran_regs_reg_t* regs_find_reg(srsran_regs_t* h, uint32_t k, uint32_t l); +int regs_put_reg(srsran_regs_reg_t* reg, cf_t* reg_data, cf_t* slot_symbols, uint32_t nof_prb); -int regs_add_reg(srslte_regs_reg_t* reg, cf_t* reg_data, cf_t* slot_symbols, uint32_t nof_prb); +int regs_add_reg(srsran_regs_reg_t* reg, cf_t* reg_data, cf_t* slot_symbols, uint32_t nof_prb); -int regs_get_reg(srslte_regs_reg_t* reg, cf_t* slot_symbols, cf_t* reg_data, uint32_t nof_prb); +int regs_get_reg(srsran_regs_reg_t* reg, cf_t* slot_symbols, cf_t* reg_data, uint32_t nof_prb); -int regs_reset_reg(srslte_regs_reg_t* reg, cf_t* slot_symbols, uint32_t nof_prb); +int regs_reset_reg(srsran_regs_reg_t* reg, cf_t* slot_symbols, uint32_t nof_prb); /*************************************************************** * @@ -36,7 +36,7 @@ int regs_reset_reg(srslte_regs_reg_t* reg, cf_t* slot_symbols, uint32_t nof_prb) * ***************************************************************/ -void regs_pdcch_free(srslte_regs_t* h) +void regs_pdcch_free(srsran_regs_t* h) { int i; for (i = 0; i < 3; i++) { @@ -54,15 +54,15 @@ const uint8_t PDCCH_PERM[PDCCH_NCOLS] = {1, 17, 9, 25, 5, 21, 13, 29, 3, 19, 11, /** Initialize REGs for PDCCH * 36.211 10.3 section 6.8.5 */ -int regs_pdcch_init(srslte_regs_t* h) +int regs_pdcch_init(srsran_regs_t* h) { int i, m, cfi, nof_ctrl_symbols; - int ret = SRSLTE_ERROR; + int ret = SRSRAN_ERROR; int nrows, ndummy, j; uint32_t k, kp; - srslte_regs_reg_t** tmp = NULL; + srsran_regs_reg_t** tmp = NULL; - bzero(&h->pdcch, sizeof(srslte_regs_ch_t)); + bzero(&h->pdcch, sizeof(srsran_regs_ch_t)); for (cfi = 0; cfi < 3; cfi++) { if (h->cell.nof_prb <= 10) { @@ -71,7 +71,7 @@ int regs_pdcch_init(srslte_regs_t* h) nof_ctrl_symbols = cfi + 1; } - tmp = malloc(sizeof(srslte_regs_reg_t*) * h->nof_regs); + tmp = malloc(sizeof(srsran_regs_reg_t*) * h->nof_regs); if (!tmp) { perror("malloc"); goto clean_and_exit; @@ -88,7 +88,7 @@ int regs_pdcch_init(srslte_regs_t* h) h->pdcch[cfi].nof_regs = m; - h->pdcch[cfi].regs = malloc(sizeof(srslte_regs_reg_t*) * h->pdcch[cfi].nof_regs); + h->pdcch[cfi].regs = malloc(sizeof(srsran_regs_reg_t*) * h->pdcch[cfi].nof_regs); if (!h->pdcch[cfi].regs) { perror("malloc"); goto clean_and_exit; @@ -125,34 +125,34 @@ int regs_pdcch_init(srslte_regs_t* h) tmp = NULL; } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; clean_and_exit: if (tmp) { free(tmp); } - if (ret == SRSLTE_ERROR) { + if (ret == SRSRAN_ERROR) { regs_pdcch_free(h); } return ret; } -int srslte_regs_pdcch_nregs(srslte_regs_t* h, uint32_t cfi) +int srsran_regs_pdcch_nregs(srsran_regs_t* h, uint32_t cfi) { if (cfi < 1 || cfi > 3) { ERROR("Invalid CFI=%d", cfi); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } else { return (int)h->pdcch[cfi - 1].nof_regs; } } -int srslte_regs_pdcch_ncce(srslte_regs_t* h, uint32_t cfi) +int srsran_regs_pdcch_ncce(srsran_regs_t* h, uint32_t cfi) { - int nregs = srslte_regs_pdcch_nregs(h, cfi); + int nregs = srsran_regs_pdcch_nregs(h, cfi); if (nregs > 0) { return (uint32_t)(nregs / 9); } else { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } @@ -160,7 +160,7 @@ int srslte_regs_pdcch_ncce(srslte_regs_t* h, uint32_t cfi) * second part of 6.8.5 in 36.211 */ -int srslte_regs_pdcch_put_offset(srslte_regs_t* h, +int srsran_regs_pdcch_put_offset(srsran_regs_t* h, uint32_t cfi, cf_t* d, cf_t* slot_symbols, @@ -169,7 +169,7 @@ int srslte_regs_pdcch_put_offset(srslte_regs_t* h, { if (cfi < 1 || cfi > 3) { ERROR("Invalid CFI=%d", cfi); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (start_reg + nof_regs <= h->pdcch[cfi - 1].nof_regs) { uint32_t i, k; @@ -181,20 +181,20 @@ int srslte_regs_pdcch_put_offset(srslte_regs_t* h, return k; } else { ERROR("Out of range: start_reg + nof_reg must be lower than %d", h->pdcch[cfi - 1].nof_regs); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } -int srslte_regs_pdcch_put(srslte_regs_t* h, uint32_t cfi, cf_t* d, cf_t* slot_symbols) +int srsran_regs_pdcch_put(srsran_regs_t* h, uint32_t cfi, cf_t* d, cf_t* slot_symbols) { if (cfi < 1 || cfi > 3) { ERROR("Invalid CFI=%d", cfi); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return srslte_regs_pdcch_put_offset(h, cfi, d, slot_symbols, 0, h->pdcch[cfi - 1].nof_regs); + return srsran_regs_pdcch_put_offset(h, cfi, d, slot_symbols, 0, h->pdcch[cfi - 1].nof_regs); } -int srslte_regs_pdcch_get_offset(srslte_regs_t* h, +int srsran_regs_pdcch_get_offset(srsran_regs_t* h, uint32_t cfi, cf_t* slot_symbols, cf_t* d, @@ -203,7 +203,7 @@ int srslte_regs_pdcch_get_offset(srslte_regs_t* h, { if (cfi < 1 || cfi > 3) { ERROR("Invalid CFI=%d", cfi); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (start_reg + nof_regs <= h->pdcch[cfi - 1].nof_regs) { uint32_t i, k; @@ -215,17 +215,17 @@ int srslte_regs_pdcch_get_offset(srslte_regs_t* h, return k; } else { ERROR("Out of range: start_reg + nof_reg must be lower than %d", h->pdcch[cfi - 1].nof_regs); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } -int srslte_regs_pdcch_get(srslte_regs_t* h, uint32_t cfi, cf_t* slot_symbols, cf_t* d) +int srsran_regs_pdcch_get(srsran_regs_t* h, uint32_t cfi, cf_t* slot_symbols, cf_t* d) { if (cfi < 1 || cfi > 3) { ERROR("Invalid CFI=%d", cfi); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return srslte_regs_pdcch_get_offset(h, cfi, slot_symbols, d, 0, h->pdcch[cfi - 1].nof_regs); + return srsran_regs_pdcch_get_offset(h, cfi, slot_symbols, d, 0, h->pdcch[cfi - 1].nof_regs); } /*************************************************************** @@ -237,28 +237,28 @@ int srslte_regs_pdcch_get(srslte_regs_t* h, uint32_t cfi, cf_t* slot_symbols, cf /** Initialize REGs for PHICH * 36.211 10.3 section 6.9.3 */ -int regs_phich_init(srslte_regs_t* h, uint32_t phich_mi, bool mbsfn_or_sf1_6_tdd) +int regs_phich_init(srsran_regs_t* h, uint32_t phich_mi, bool mbsfn_or_sf1_6_tdd) { float ng; uint32_t i, ni, li, n[3], nreg, mi; - srslte_regs_reg_t** regs_phich[3]; - int ret = SRSLTE_ERROR; + srsran_regs_reg_t** regs_phich[3]; + int ret = SRSRAN_ERROR; for (int i = 0; i < 3; i++) { regs_phich[i] = NULL; } switch (h->phich_res) { - case SRSLTE_PHICH_R_1_6: + case SRSRAN_PHICH_R_1_6: ng = (float)1 / 6; break; - case SRSLTE_PHICH_R_1_2: + case SRSRAN_PHICH_R_1_2: ng = (float)1 / 2; break; - case SRSLTE_PHICH_R_1: + case SRSRAN_PHICH_R_1: ng = 1; break; - case SRSLTE_PHICH_R_2: + case SRSRAN_PHICH_R_2: ng = 2; break; default: @@ -267,18 +267,18 @@ int regs_phich_init(srslte_regs_t* h, uint32_t phich_mi, bool mbsfn_or_sf1_6_tdd } h->ngroups_phich_m1 = (int)ceilf(ng * ((float)h->cell.nof_prb / 8)); h->ngroups_phich = (int)phich_mi * h->ngroups_phich_m1; - h->phich = malloc(sizeof(srslte_regs_ch_t) * h->ngroups_phich); + h->phich = malloc(sizeof(srsran_regs_ch_t) * h->ngroups_phich); if (!h->phich) { perror("malloc"); return -1; } INFO("Creating %d PHICH mapping units. %s length, Ng=%.2f", h->ngroups_phich, - h->phich_len == SRSLTE_PHICH_EXT ? "Extended" : "Normal", + h->phich_len == SRSRAN_PHICH_EXT ? "Extended" : "Normal", ng); for (i = 0; i < h->ngroups_phich; i++) { h->phich[i].nof_regs = REGS_PHICH_REGS_X_GROUP; - h->phich[i].regs = malloc(sizeof(srslte_regs_reg_t*) * REGS_PHICH_REGS_X_GROUP); + h->phich[i].regs = malloc(sizeof(srsran_regs_reg_t*) * REGS_PHICH_REGS_X_GROUP); if (!h->phich[i].regs) { perror("malloc"); goto clean_and_exit; @@ -295,9 +295,9 @@ int regs_phich_init(srslte_regs_t* h, uint32_t phich_mi, bool mbsfn_or_sf1_6_tdd } } - bzero(regs_phich, sizeof(srslte_regs_reg_t*) * 3); + bzero(regs_phich, sizeof(srsran_regs_reg_t*) * 3); for (i = 0; i < 3; i++) { - regs_phich[i] = malloc(n[i] * sizeof(srslte_regs_reg_t*)); + regs_phich[i] = malloc(n[i] * sizeof(srsran_regs_reg_t*)); if (!regs_phich[i]) { perror("malloc"); goto clean_and_exit; @@ -317,15 +317,15 @@ int regs_phich_init(srslte_regs_t* h, uint32_t phich_mi, bool mbsfn_or_sf1_6_tdd for (mi = 0; mi < h->ngroups_phich; mi++) { // here ngroups is the number of mapping units for (i = 0; i < 3; i++) { // Step 7 - if (h->phich_len == SRSLTE_PHICH_NORM) { + if (h->phich_len == SRSRAN_PHICH_NORM) { li = 0; - } else if (h->phich_len == SRSLTE_PHICH_EXT && mbsfn_or_sf1_6_tdd) { + } else if (h->phich_len == SRSRAN_PHICH_EXT && mbsfn_or_sf1_6_tdd) { li = (mi / 2 + i + 1) % 2; } else { li = i; } // Step 8 - if (h->phich_len == SRSLTE_PHICH_EXT && mbsfn_or_sf1_6_tdd) { + if (h->phich_len == SRSRAN_PHICH_EXT && mbsfn_or_sf1_6_tdd) { ni = ((h->cell.id * n[li] / n[1]) + mi + i * n[li] / 3) % n[li]; } else { ni = ((h->cell.id * n[li] / n[0]) + mi + i * n[li] / 3) % n[li]; @@ -339,13 +339,13 @@ int regs_phich_init(srslte_regs_t* h, uint32_t phich_mi, bool mbsfn_or_sf1_6_tdd // now the number of mapping units = number of groups for normal cp. For extended cp // ngroups = 2 * number mapping units - if (SRSLTE_CP_ISEXT(h->cell.cp)) { + if (SRSRAN_CP_ISEXT(h->cell.cp)) { h->ngroups_phich *= 2; } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; clean_and_exit: - if (ret == SRSLTE_ERROR) { + if (ret == SRSRAN_ERROR) { if (h->phich) { for (i = 0; i < h->ngroups_phich; i++) { if (h->phich[i].regs) { @@ -363,11 +363,11 @@ clean_and_exit: return ret; } -void regs_phich_free(srslte_regs_t* h) +void regs_phich_free(srsran_regs_t* h) { uint32_t i; if (h->phich) { - if (SRSLTE_CP_ISEXT(h->cell.cp)) { + if (SRSRAN_CP_ISEXT(h->cell.cp)) { h->ngroups_phich /= 2; } for (i = 0; i < h->ngroups_phich; i++) { @@ -381,7 +381,7 @@ void regs_phich_free(srslte_regs_t* h) } } -uint32_t srslte_regs_phich_nregs(srslte_regs_t* h) +uint32_t srsran_regs_phich_nregs(srsran_regs_t* h) { uint32_t i; uint32_t n; @@ -392,12 +392,12 @@ uint32_t srslte_regs_phich_nregs(srslte_regs_t* h) return n; } -uint32_t srslte_regs_phich_ngroups(srslte_regs_t* h) +uint32_t srsran_regs_phich_ngroups(srsran_regs_t* h) { return h->ngroups_phich; } -uint32_t srslte_regs_phich_ngroups_m1(srslte_regs_t* h) +uint32_t srsran_regs_phich_ngroups_m1(srsran_regs_t* h) { return h->ngroups_phich_m1; } @@ -405,21 +405,21 @@ uint32_t srslte_regs_phich_ngroups_m1(srslte_regs_t* h) /** * Adds the PHICH symbols to the resource grid pointed by slot_symbols. * - * Each subframe, the user shall call the srslte_v function before adding PHICH symbols. + * Each subframe, the user shall call the srsran_v function before adding PHICH symbols. * * Returns the number of written symbols, or -1 on error */ -int srslte_regs_phich_add(srslte_regs_t* h, cf_t symbols[REGS_PHICH_NSYM], uint32_t ngroup, cf_t* slot_symbols) +int srsran_regs_phich_add(srsran_regs_t* h, cf_t symbols[REGS_PHICH_NSYM], uint32_t ngroup, cf_t* slot_symbols) { uint32_t i; if (ngroup >= h->ngroups_phich) { ERROR("Error invalid ngroup %d", ngroup); - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } - if (SRSLTE_CP_ISEXT(h->cell.cp)) { + if (SRSRAN_CP_ISEXT(h->cell.cp)) { ngroup /= 2; } - srslte_regs_ch_t* rch = &h->phich[ngroup]; + srsran_regs_ch_t* rch = &h->phich[ngroup]; for (i = 0; i < rch->nof_regs && i * REGS_RE_X_REG < REGS_PHICH_NSYM; i++) { regs_add_reg(rch->regs[i], &symbols[i * REGS_RE_X_REG], slot_symbols, h->cell.nof_prb); } @@ -431,22 +431,22 @@ int srslte_regs_phich_add(srslte_regs_t* h, cf_t symbols[REGS_PHICH_NSYM], uint3 * * Returns the number of written symbols, or -1 on error */ -int srslte_regs_phich_reset(srslte_regs_t* h, cf_t* slot_symbols) +int srsran_regs_phich_reset(srsran_regs_t* h, cf_t* slot_symbols) { uint32_t i; uint32_t ngroup, ng; - for (ngroup = 0; ngroup < h->ngroups_phich; SRSLTE_CP_ISEXT(h->cell.cp) ? ngroup += 2 : ngroup++) { - if (SRSLTE_CP_ISEXT(h->cell.cp)) { + for (ngroup = 0; ngroup < h->ngroups_phich; SRSRAN_CP_ISEXT(h->cell.cp) ? ngroup += 2 : ngroup++) { + if (SRSRAN_CP_ISEXT(h->cell.cp)) { ng = ngroup / 2; } else { ng = ngroup; } - srslte_regs_ch_t* rch = &h->phich[ng]; + srsran_regs_ch_t* rch = &h->phich[ng]; for (i = 0; i < rch->nof_regs && i * REGS_RE_X_REG < REGS_PHICH_NSYM; i++) { regs_reset_reg(rch->regs[i], slot_symbols, h->cell.nof_prb); } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } /** @@ -454,17 +454,17 @@ int srslte_regs_phich_reset(srslte_regs_t* h, cf_t* slot_symbols) * * Returns the number of written symbols, or -1 on error */ -int srslte_regs_phich_get(srslte_regs_t* h, cf_t* slot_symbols, cf_t symbols[REGS_PHICH_NSYM], uint32_t ngroup) +int srsran_regs_phich_get(srsran_regs_t* h, cf_t* slot_symbols, cf_t symbols[REGS_PHICH_NSYM], uint32_t ngroup) { uint32_t i; if (ngroup >= h->ngroups_phich) { ERROR("Error invalid ngroup %d", ngroup); - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } - if (SRSLTE_CP_ISEXT(h->cell.cp)) { + if (SRSRAN_CP_ISEXT(h->cell.cp)) { ngroup /= 2; } - srslte_regs_ch_t* rch = &h->phich[ngroup]; + srsran_regs_ch_t* rch = &h->phich[ngroup]; for (i = 0; i < rch->nof_regs && i * REGS_RE_X_REG < REGS_PHICH_NSYM; i++) { regs_get_reg(rch->regs[i], slot_symbols, &symbols[i * REGS_RE_X_REG], h->cell.nof_prb); } @@ -480,40 +480,40 @@ int srslte_regs_phich_get(srslte_regs_t* h, cf_t* slot_symbols, cf_t symbols[REG /** Initialize REGs for PCFICH * 36.211 10.3 section 6.7.4 */ -int regs_pcfich_init(srslte_regs_t* h) +int regs_pcfich_init(srsran_regs_t* h) { uint32_t i; uint32_t k_hat, k; - srslte_regs_ch_t* ch = &h->pcfich; + srsran_regs_ch_t* ch = &h->pcfich; - ch->regs = malloc(sizeof(srslte_regs_reg_t*) * REGS_PCFICH_NREGS); + ch->regs = malloc(sizeof(srsran_regs_reg_t*) * REGS_PCFICH_NREGS); if (!ch->regs) { perror("malloc"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } ch->nof_regs = REGS_PCFICH_NREGS; INFO("PCFICH allocating %d regs. CellID: %d, PRB: %d", ch->nof_regs, h->cell.id, h->cell.nof_prb); - k_hat = (SRSLTE_NRE / 2) * (h->cell.id % (2 * h->cell.nof_prb)); + k_hat = (SRSRAN_NRE / 2) * (h->cell.id % (2 * h->cell.nof_prb)); for (i = 0; i < REGS_PCFICH_NREGS; i++) { - k = (k_hat + (i * h->cell.nof_prb / 2) * (SRSLTE_NRE / 2)) % (h->cell.nof_prb * SRSLTE_NRE); + k = (k_hat + (i * h->cell.nof_prb / 2) * (SRSRAN_NRE / 2)) % (h->cell.nof_prb * SRSRAN_NRE); ch->regs[i] = regs_find_reg(h, k, 0); if (!ch->regs[i]) { ERROR("Error allocating PCFICH: REG (%d,0) not found", k); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } else if (ch->regs[i]->assigned) { ERROR("Error allocating PCFICH: REG (%d,0) already allocated", k); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } else { ch->regs[i]->assigned = true; DEBUG("Assigned PCFICH REG#%d (%d,0)", i, k); } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -void regs_pcfich_free(srslte_regs_t* h) +void regs_pcfich_free(srsran_regs_t* h) { if (h->pcfich.regs) { free(h->pcfich.regs); @@ -521,7 +521,7 @@ void regs_pcfich_free(srslte_regs_t* h) } } -uint32_t srslte_regs_pcfich_nregs(srslte_regs_t* h) +uint32_t srsran_regs_pcfich_nregs(srsran_regs_t* h) { return h->pcfich.nof_regs; } @@ -531,9 +531,9 @@ uint32_t srslte_regs_pcfich_nregs(srslte_regs_t* h) * * Returns the number of written symbols, or -1 on error */ -int srslte_regs_pcfich_put(srslte_regs_t* h, cf_t symbols[REGS_PCFICH_NSYM], cf_t* slot_symbols) +int srsran_regs_pcfich_put(srsran_regs_t* h, cf_t symbols[REGS_PCFICH_NSYM], cf_t* slot_symbols) { - srslte_regs_ch_t* rch = &h->pcfich; + srsran_regs_ch_t* rch = &h->pcfich; uint32_t i; for (i = 0; i < rch->nof_regs && i * REGS_RE_X_REG < REGS_PCFICH_NSYM; i++) { @@ -547,9 +547,9 @@ int srslte_regs_pcfich_put(srslte_regs_t* h, cf_t symbols[REGS_PCFICH_NSYM], cf_ * * Returns the number of written symbols, or -1 on error */ -int srslte_regs_pcfich_get(srslte_regs_t* h, cf_t* slot_symbols, cf_t ch_data[REGS_PCFICH_NSYM]) +int srsran_regs_pcfich_get(srsran_regs_t* h, cf_t* slot_symbols, cf_t ch_data[REGS_PCFICH_NSYM]) { - srslte_regs_ch_t* rch = &h->pcfich; + srsran_regs_ch_t* rch = &h->pcfich; uint32_t i; for (i = 0; i < rch->nof_regs && i * REGS_RE_X_REG < REGS_PCFICH_NSYM; i++) { regs_get_reg(rch->regs[i], slot_symbols, &ch_data[i * REGS_RE_X_REG], h->cell.nof_prb); @@ -563,7 +563,7 @@ int srslte_regs_pcfich_get(srslte_regs_t* h, cf_t* slot_symbols, cf_t ch_data[RE * ***************************************************************/ -srslte_regs_reg_t* regs_find_reg(srslte_regs_t* h, uint32_t k, uint32_t l) +srsran_regs_reg_t* regs_find_reg(srsran_regs_t* h, uint32_t k, uint32_t l) { uint32_t i; for (i = 0; i < h->nof_regs; i++) { @@ -578,7 +578,7 @@ srslte_regs_reg_t* regs_find_reg(srslte_regs_t* h, uint32_t k, uint32_t l) * Returns the number of REGs in a PRB * 36.211 Section 6.2.4 */ -int regs_num_x_symbol(uint32_t symbol, uint32_t nof_port, srslte_cp_t cp) +int regs_num_x_symbol(uint32_t symbol, uint32_t nof_port, srsran_cp_t cp) { switch (symbol) { case 0: @@ -592,20 +592,20 @@ int regs_num_x_symbol(uint32_t symbol, uint32_t nof_port, srslte_cp_t cp) return 2; default: ERROR("Invalid number of ports %d", nof_port); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } break; case 2: return 3; case 3: - if (SRSLTE_CP_ISNORM(cp)) { + if (SRSRAN_CP_ISNORM(cp)) { return 3; } else { return 2; } default: ERROR("Invalid symbol %d", symbol); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } @@ -613,7 +613,7 @@ int regs_num_x_symbol(uint32_t symbol, uint32_t nof_port, srslte_cp_t cp) * Initializes the indices of a REG * 36.211 Section 6.2.4 */ -int regs_reg_init(srslte_regs_reg_t* reg, uint32_t symbol, uint32_t nreg, uint32_t k0, uint32_t maxreg, uint32_t vo) +int regs_reg_init(srsran_regs_reg_t* reg, uint32_t symbol, uint32_t nreg, uint32_t k0, uint32_t maxreg, uint32_t vo) { uint32_t i, j, z; @@ -640,7 +640,7 @@ int regs_reg_init(srslte_regs_reg_t* reg, uint32_t symbol, uint32_t nreg, uint32 } if (j != 4) { ERROR("Something went wrong: expected 2 references"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } break; @@ -653,12 +653,12 @@ int regs_reg_init(srslte_regs_reg_t* reg, uint32_t symbol, uint32_t nreg, uint32 break; default: ERROR("Invalid number of REGs per PRB: %d", maxreg); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -void srslte_regs_free(srslte_regs_t* h) +void srsran_regs_free(srsran_regs_t* h) { if (h->regs) { free(h->regs); @@ -667,12 +667,12 @@ void srslte_regs_free(srslte_regs_t* h) regs_phich_free(h); regs_pdcch_free(h); - bzero(h, sizeof(srslte_regs_t)); + bzero(h, sizeof(srsran_regs_t)); } -int srslte_regs_init(srslte_regs_t* h, srslte_cell_t cell) +int srsran_regs_init(srsran_regs_t* h, srsran_cell_t cell) { - return srslte_regs_init_opts(h, cell, 1, false); + return srsran_regs_init_opts(h, cell, 1, false); } /** @@ -680,17 +680,17 @@ int srslte_regs_init(srslte_regs_t* h, srslte_cell_t cell) * Sets all REG indices and initializes PCFICH, PHICH and PDCCH REGs * Returns 0 if OK, -1 on error */ -int srslte_regs_init_opts(srslte_regs_t* h, srslte_cell_t cell, uint32_t phich_mi, bool mbsfn_or_sf1_6_tdd) +int srsran_regs_init_opts(srsran_regs_t* h, srsran_cell_t cell, uint32_t phich_mi, bool mbsfn_or_sf1_6_tdd) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; uint32_t i, k; uint32_t j[4], jmax, prb; uint32_t n[4], vo; uint32_t max_ctrl_symbols; - if (h != NULL && srslte_cell_isvalid(&cell)) { - bzero(h, sizeof(srslte_regs_t)); - ret = SRSLTE_ERROR; + if (h != NULL && srsran_cell_isvalid(&cell)) { + bzero(h, sizeof(srsran_regs_t)); + ret = SRSRAN_ERROR; max_ctrl_symbols = cell.nof_prb <= 10 ? 4 : 3; vo = cell.id % 3; @@ -711,8 +711,8 @@ int srslte_regs_init_opts(srslte_regs_t* h, srslte_cell_t cell, uint32_t phich_m h->nof_regs, h->cell.id, h->cell.nof_prb, - SRSLTE_CP_ISNORM(h->cell.cp) ? "Normal" : "Extended"); - h->regs = malloc(sizeof(srslte_regs_reg_t) * h->nof_regs); + SRSRAN_CP_ISNORM(h->cell.cp) ? "Normal" : "Extended"); + h->regs = malloc(sizeof(srsran_regs_reg_t) * h->nof_regs); if (!h->regs) { perror("malloc"); goto clean_and_exit; @@ -723,7 +723,7 @@ int srslte_regs_init_opts(srslte_regs_t* h, srslte_cell_t cell, uint32_t phich_m k = i = prb = jmax = 0; while (k < h->nof_regs) { if (n[i] == 3 || (n[i] == 2 && jmax != 1)) { - if (regs_reg_init(&h->regs[k], i, j[i], prb * SRSLTE_NRE, n[i], vo)) { + if (regs_reg_init(&h->regs[k], i, j[i], prb * SRSRAN_NRE, n[i], vo)) { ERROR("Error initializing REGs"); goto clean_and_exit; } @@ -760,12 +760,12 @@ int srslte_regs_init_opts(srslte_regs_t* h, srslte_cell_t cell, uint32_t phich_m goto clean_and_exit; } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } clean_and_exit: if (h) { - if (ret != SRSLTE_SUCCESS) { - srslte_regs_free(h); + if (ret != SRSRAN_SUCCESS) { + srsran_regs_free(h); } } return ret; @@ -774,7 +774,7 @@ clean_and_exit: /** * Puts one REG data (4 symbols) in the slot symbols array */ -int regs_put_reg(srslte_regs_reg_t* reg, cf_t* reg_data, cf_t* slot_symbols, uint32_t nof_prb) +int regs_put_reg(srsran_regs_reg_t* reg, cf_t* reg_data, cf_t* slot_symbols, uint32_t nof_prb) { uint32_t i; for (i = 0; i < REGS_RE_X_REG; i++) { @@ -787,7 +787,7 @@ int regs_put_reg(srslte_regs_reg_t* reg, cf_t* reg_data, cf_t* slot_symbols, uin * Adds one REG data (4 symbols) in the slot symbols array * Used by PHICH */ -int regs_add_reg(srslte_regs_reg_t* reg, cf_t* reg_data, cf_t* slot_symbols, uint32_t nof_prb) +int regs_add_reg(srsran_regs_reg_t* reg, cf_t* reg_data, cf_t* slot_symbols, uint32_t nof_prb) { uint32_t i; for (i = 0; i < REGS_RE_X_REG; i++) { @@ -799,7 +799,7 @@ int regs_add_reg(srslte_regs_reg_t* reg, cf_t* reg_data, cf_t* slot_symbols, uin /** * Reset REG data (4 symbols) in the slot symbols array */ -int regs_reset_reg(srslte_regs_reg_t* reg, cf_t* slot_symbols, uint32_t nof_prb) +int regs_reset_reg(srsran_regs_reg_t* reg, cf_t* slot_symbols, uint32_t nof_prb) { uint32_t i; for (i = 0; i < REGS_RE_X_REG; i++) { @@ -811,7 +811,7 @@ int regs_reset_reg(srslte_regs_reg_t* reg, cf_t* slot_symbols, uint32_t nof_prb) /** * Gets one REG data (4 symbols) from the slot symbols array */ -int regs_get_reg(srslte_regs_reg_t* reg, cf_t* slot_symbols, cf_t* reg_data, uint32_t nof_prb) +int regs_get_reg(srsran_regs_reg_t* reg, cf_t* slot_symbols, cf_t* reg_data, uint32_t nof_prb) { uint32_t i; for (i = 0; i < REGS_RE_X_REG; i++) { diff --git a/lib/src/phy/phch/sch.c b/lib/src/phy/phch/sch.c index a4a538971..46f1b8f76 100644 --- a/lib/src/phy/phch/sch.c +++ b/lib/src/phy/phch/sch.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,10 +10,10 @@ * */ -#include "srslte/phy/utils/bit.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" -#include "srslte/srslte.h" +#include "srsran/phy/utils/bit.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" +#include "srsran/srsran.h" #include #include #include @@ -23,7 +23,7 @@ #include #include -#define SRSLTE_PDSCH_MAX_TDEC_ITERS 10 +#define SRSRAN_PDSCH_MAX_TDEC_ITERS 10 #ifdef LV_HAVE_SSE #include @@ -77,7 +77,7 @@ static inline float get_beta_cqi_offset(uint32_t idx) return ret; } -float srslte_sch_beta_cqi(uint32_t I_cqi) +float srsran_sch_beta_cqi(uint32_t I_cqi) { if (I_cqi < 16) { return get_beta_cqi_offset(I_cqi); @@ -86,7 +86,7 @@ float srslte_sch_beta_cqi(uint32_t I_cqi) } } -float srslte_sch_beta_ack(uint32_t I_harq) +float srsran_sch_beta_ack(uint32_t I_harq) { if (I_harq < 16) { return get_beta_harq_offset(I_harq); @@ -95,7 +95,7 @@ float srslte_sch_beta_ack(uint32_t I_harq) } } -uint32_t srslte_sch_find_Ioffset_ack(float beta) +uint32_t srsran_sch_find_Ioffset_ack(float beta) { for (int i = 0; i < 16; i++) { if (get_beta_harq_offset(i) >= beta) { @@ -105,7 +105,7 @@ uint32_t srslte_sch_find_Ioffset_ack(float beta) return 0; } -uint32_t srslte_sch_find_Ioffset_ri(float beta) +uint32_t srsran_sch_find_Ioffset_ri(float beta) { for (int i = 0; i < 16; i++) { if (get_beta_ri_offset(i) >= beta) { @@ -115,7 +115,7 @@ uint32_t srslte_sch_find_Ioffset_ri(float beta) return 0; } -uint32_t srslte_sch_find_Ioffset_cqi(float beta) +uint32_t srsran_sch_find_Ioffset_cqi(float beta) { for (int i = 0; i < 16; i++) { if (get_beta_cqi_offset(i) >= beta) { @@ -125,72 +125,72 @@ uint32_t srslte_sch_find_Ioffset_cqi(float beta) return 0; } -#define SCH_MAX_G_BITS (SRSLTE_MAX_PRB * 12 * 12 * 12) +#define SCH_MAX_G_BITS (SRSRAN_MAX_PRB * 12 * 12 * 12) -int srslte_sch_init(srslte_sch_t* q) +int srsran_sch_init(srsran_sch_t* q) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q) { - ret = SRSLTE_ERROR; - bzero(q, sizeof(srslte_sch_t)); + ret = SRSRAN_ERROR; + bzero(q, sizeof(srsran_sch_t)); - if (srslte_crc_init(&q->crc_tb, SRSLTE_LTE_CRC24A, 24)) { + if (srsran_crc_init(&q->crc_tb, SRSRAN_LTE_CRC24A, 24)) { ERROR("Error initiating CRC"); goto clean; } - if (srslte_crc_init(&q->crc_cb, SRSLTE_LTE_CRC24B, 24)) { + if (srsran_crc_init(&q->crc_cb, SRSRAN_LTE_CRC24B, 24)) { ERROR("Error initiating CRC"); goto clean; } - if (srslte_tcod_init(&q->encoder, SRSLTE_TCOD_MAX_LEN_CB)) { + if (srsran_tcod_init(&q->encoder, SRSRAN_TCOD_MAX_LEN_CB)) { ERROR("Error initiating Turbo Coder"); goto clean; } - if (srslte_tdec_init(&q->decoder, SRSLTE_TCOD_MAX_LEN_CB)) { + if (srsran_tdec_init(&q->decoder, SRSRAN_TCOD_MAX_LEN_CB)) { ERROR("Error initiating Turbo Decoder"); goto clean; } - q->max_iterations = SRSLTE_PDSCH_MAX_TDEC_ITERS; + q->max_iterations = SRSRAN_PDSCH_MAX_TDEC_ITERS; - srslte_rm_turbo_gentables(); + srsran_rm_turbo_gentables(); // Allocate int16 for reception (LLRs) - q->cb_in = srslte_vec_u8_malloc((SRSLTE_TCOD_MAX_LEN_CB + 8) / 8); + q->cb_in = srsran_vec_u8_malloc((SRSRAN_TCOD_MAX_LEN_CB + 8) / 8); if (!q->cb_in) { goto clean; } - q->parity_bits = srslte_vec_u8_malloc((3 * SRSLTE_TCOD_MAX_LEN_CB + 16) / 8); + q->parity_bits = srsran_vec_u8_malloc((3 * SRSRAN_TCOD_MAX_LEN_CB + 16) / 8); if (!q->parity_bits) { goto clean; } - q->temp_g_bits = srslte_vec_u8_malloc(SCH_MAX_G_BITS); + q->temp_g_bits = srsran_vec_u8_malloc(SCH_MAX_G_BITS); if (!q->temp_g_bits) { goto clean; } - bzero(q->temp_g_bits, SRSLTE_MAX_PRB * 12 * 12 * 12); - q->ul_interleaver = srslte_vec_u32_malloc(SCH_MAX_G_BITS); + bzero(q->temp_g_bits, SRSRAN_MAX_PRB * 12 * 12 * 12); + q->ul_interleaver = srsran_vec_u32_malloc(SCH_MAX_G_BITS); if (!q->ul_interleaver) { goto clean; } - if (srslte_uci_cqi_init(&q->uci_cqi)) { + if (srsran_uci_cqi_init(&q->uci_cqi)) { goto clean; } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } clean: - if (ret == SRSLTE_ERROR) { - srslte_sch_free(q); + if (ret == SRSRAN_ERROR) { + srsran_sch_free(q); } return ret; } -void srslte_sch_free(srslte_sch_t* q) +void srsran_sch_free(srsran_sch_t* q) { - srslte_rm_turbo_free_tables(); + srsran_rm_turbo_free_tables(); if (q->cb_in) { free(q->cb_in); @@ -204,22 +204,22 @@ void srslte_sch_free(srslte_sch_t* q) if (q->ul_interleaver) { free(q->ul_interleaver); } - srslte_tdec_free(&q->decoder); - srslte_tcod_free(&q->encoder); - srslte_uci_cqi_free(&q->uci_cqi); - bzero(q, sizeof(srslte_sch_t)); + srsran_tdec_free(&q->decoder); + srsran_tcod_free(&q->encoder); + srsran_uci_cqi_free(&q->uci_cqi); + bzero(q, sizeof(srsran_sch_t)); } -void srslte_sch_set_max_noi(srslte_sch_t* q, uint32_t max_iterations) +void srsran_sch_set_max_noi(srsran_sch_t* q, uint32_t max_iterations) { if (max_iterations == 0) { - max_iterations = SRSLTE_PDSCH_MAX_TDEC_ITERS; + max_iterations = SRSRAN_PDSCH_MAX_TDEC_ITERS; } q->max_iterations = max_iterations; } -float srslte_sch_last_noi(srslte_sch_t* q) +float srsran_sch_last_noi(srsran_sch_t* q) { return q->avg_iterations; } @@ -227,9 +227,9 @@ float srslte_sch_last_noi(srslte_sch_t* q) /* Encode a transport block according to 36.212 5.3.2 * */ -static int encode_tb_off(srslte_sch_t* q, - srslte_softbuffer_tx_t* softbuffer, - srslte_cbsegm_t* cb_segm, +static int encode_tb_off(srsran_sch_t* q, + srsran_softbuffer_tx_t* softbuffer, + srsran_cbsegm_t* cb_segm, uint32_t Qm, uint32_t rv, uint32_t nof_e_bits, @@ -239,12 +239,12 @@ static int encode_tb_off(srslte_sch_t* q, { uint32_t i; uint32_t cb_len = 0, rp = 0, wp = 0, rlen = 0, n_e = 0; - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL && e_bits != NULL && cb_segm != NULL && softbuffer != NULL) { if (cb_segm->F) { ERROR("Error filler bits are not supported. Use standard TBS"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (cb_segm->C > softbuffer->max_cb) { @@ -260,7 +260,7 @@ static int encode_tb_off(srslte_sch_t* q, } /* Reset TB CRC */ - srslte_crc_set_init(&q->crc_tb, 0); + srsran_crc_set_init(&q->crc_tb, 0); wp = 0; rp = 0; @@ -305,7 +305,7 @@ static int encode_tb_off(srslte_sch_t* q, /* Turbo Encoding * If Codeblock CRC is required it is given the CRC instance pointer, otherwise CRC pointer shall be NULL */ - srslte_tcod_encode_lut(&q->encoder, + srsran_tcod_encode_lut(&q->encoder, &q->crc_tb, (cb_segm->C > 1) ? &q->crc_cb : NULL, q->cb_in, @@ -316,7 +316,7 @@ static int encode_tb_off(srslte_sch_t* q, DEBUG("RM cblen_idx=%d, n_e=%d, wp=%d, nof_e_bits=%d", cblen_idx, n_e, wp, nof_e_bits); /* Rate matching */ - if (srslte_rm_turbo_tx_lut(softbuffer->buffer_b[i], + if (srsran_rm_turbo_tx_lut(softbuffer->buffer_b[i], q->cb_in, q->parity_bits, &e_bits[(wp + w_offset) / 8], @@ -325,7 +325,7 @@ static int encode_tb_off(srslte_sch_t* q, (wp + w_offset) % 8, rv)) { ERROR("Error in rate matching"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } /* Set read/write pointers */ @@ -334,16 +334,16 @@ static int encode_tb_off(srslte_sch_t* q, } INFO("END CB#%d: wp: %d, rp: %d", i, wp, rp); - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } else { ERROR("Invalid parameters: e_bits=%d, cb_segm=%d, softbuffer=%d", e_bits != 0, cb_segm != 0, softbuffer != 0); } return ret; } -static int encode_tb(srslte_sch_t* q, - srslte_softbuffer_tx_t* soft_buffer, - srslte_cbsegm_t* cb_segm, +static int encode_tb(srsran_sch_t* q, + srsran_softbuffer_tx_t* soft_buffer, + srsran_cbsegm_t* cb_segm, uint32_t Qm, uint32_t rv, uint32_t nof_e_bits, @@ -353,9 +353,9 @@ static int encode_tb(srslte_sch_t* q, return encode_tb_off(q, soft_buffer, cb_segm, Qm, rv, nof_e_bits, data, e_bits, 0); } -bool decode_tb_cb(srslte_sch_t* q, - srslte_softbuffer_rx_t* softbuffer, - srslte_cbsegm_t* cb_segm, +bool decode_tb_cb(srsran_sch_t* q, + srsran_softbuffer_rx_t* softbuffer, + srsran_cbsegm_t* cb_segm, uint32_t Qm, uint32_t rv, uint32_t nof_e_bits, @@ -365,8 +365,8 @@ bool decode_tb_cb(srslte_sch_t* q, int8_t* e_bits_b = e_bits; int16_t* e_bits_s = e_bits; - if (cb_segm->C > SRSLTE_MAX_CODEBLOCKS) { - ERROR("Error SRSLTE_MAX_CODEBLOCKS=%d", SRSLTE_MAX_CODEBLOCKS); + if (cb_segm->C > SRSRAN_MAX_CODEBLOCKS) { + ERROR("Error SRSRAN_MAX_CODEBLOCKS=%d", SRSRAN_MAX_CODEBLOCKS); return false; } @@ -392,33 +392,33 @@ bool decode_tb_cb(srslte_sch_t* q, } if (q->llr_is_8bit) { - if (srslte_rm_turbo_rx_lut_8bit(&e_bits_b[rp], (int8_t*)softbuffer->buffer_f[cb_idx], n_e2, cb_len_idx, rv)) { + if (srsran_rm_turbo_rx_lut_8bit(&e_bits_b[rp], (int8_t*)softbuffer->buffer_f[cb_idx], n_e2, cb_len_idx, rv)) { ERROR("Error in rate matching"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } else { - if (srslte_rm_turbo_rx_lut(&e_bits_s[rp], softbuffer->buffer_f[cb_idx], n_e2, cb_len_idx, rv)) { + if (srsran_rm_turbo_rx_lut(&e_bits_s[rp], softbuffer->buffer_f[cb_idx], n_e2, cb_len_idx, rv)) { ERROR("Error in rate matching"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } - srslte_tdec_new_cb(&q->decoder, cb_len); + srsran_tdec_new_cb(&q->decoder, cb_len); // Run iterations and use CRC for early stopping bool early_stop = false; uint32_t cb_noi = 0; do { if (q->llr_is_8bit) { - srslte_tdec_iteration_8bit(&q->decoder, (int8_t*)softbuffer->buffer_f[cb_idx], &data[cb_idx * rlen / 8]); + srsran_tdec_iteration_8bit(&q->decoder, (int8_t*)softbuffer->buffer_f[cb_idx], &data[cb_idx * rlen / 8]); } else { - srslte_tdec_iteration(&q->decoder, softbuffer->buffer_f[cb_idx], &data[cb_idx * rlen / 8]); + srsran_tdec_iteration(&q->decoder, softbuffer->buffer_f[cb_idx], &data[cb_idx * rlen / 8]); } q->avg_iterations++; cb_noi++; uint32_t len_crc; - srslte_crc_t* crc_ptr; + srsran_crc_t* crc_ptr; if (cb_segm->C > 1) { len_crc = cb_len; @@ -429,7 +429,7 @@ bool decode_tb_cb(srslte_sch_t* q, } // CRC is OK - if (!srslte_crc_checksum_byte(crc_ptr, &data[cb_idx * rlen / 8], len_crc)) { + if (!srsran_crc_checksum_byte(crc_ptr, &data[cb_idx * rlen / 8], len_crc)) { softbuffer->cb_crc[cb_idx] = true; early_stop = true; @@ -490,9 +490,9 @@ bool decode_tb_cb(srslte_sch_t* q, * @param[out] data Decoded transport block * @return negative if error in parameters or CRC error in decoding */ -static int decode_tb(srslte_sch_t* q, - srslte_softbuffer_rx_t* softbuffer, - srslte_cbsegm_t* cb_segm, +static int decode_tb(srsran_sch_t* q, + srsran_softbuffer_rx_t* softbuffer, + srsran_cbsegm_t* cb_segm, uint32_t Qm, uint32_t rv, uint32_t nof_e_bits, @@ -501,12 +501,12 @@ static int decode_tb(srslte_sch_t* q, { if (q != NULL && data != NULL && softbuffer != NULL && e_bits != NULL && cb_segm != NULL) { if (cb_segm->tbs == 0 || cb_segm->C == 0) { - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } if (cb_segm->F) { fprintf(stderr, "Error filler bits are not supported. Use standard TBS\n"); - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } if (cb_segm->C > softbuffer->max_cb) { @@ -514,7 +514,7 @@ static int decode_tb(srslte_sch_t* q, "Error number of CB to decode (%d) exceeds soft buffer size (%d CBs)\n", cb_segm->C, softbuffer->max_cb); - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } bool crc_ok = true; @@ -530,7 +530,7 @@ static int decode_tb(srslte_sch_t* q, uint32_t par_rx = 0, par_tx = 0; // Compute transport block CRC - par_rx = srslte_crc_checksum_byte(&q->crc_tb, data, cb_segm->tbs); + par_rx = srsran_crc_checksum_byte(&q->crc_tb, data, cb_segm->tbs); // check parity bits par_tx = ((uint32_t)data[cb_segm->tbs / 8 + 0]) << 16 | ((uint32_t)data[cb_segm->tbs / 8 + 1]) << 8 | @@ -538,13 +538,13 @@ static int decode_tb(srslte_sch_t* q, if (par_rx == par_tx && par_rx) { INFO("TB decoded OK"); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } else { INFO("Error in TB parity: par_tx=0x%x, par_rx=0x%x", par_tx, par_rx); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } else { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } else { ERROR("Missing inputs: data=%d, softbuffer=%d, e_bits=%d, cb_segm=%d", @@ -552,17 +552,17 @@ static int decode_tb(srslte_sch_t* q, softbuffer != 0, e_bits != 0, cb_segm != 0); - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } } -int srslte_dlsch_decode(srslte_sch_t* q, srslte_pdsch_cfg_t* cfg, int16_t* e_bits, uint8_t* data) +int srsran_dlsch_decode(srsran_sch_t* q, srsran_pdsch_cfg_t* cfg, int16_t* e_bits, uint8_t* data) { - return srslte_dlsch_decode2(q, cfg, e_bits, data, 0, 1); + return srsran_dlsch_decode2(q, cfg, e_bits, data, 0, 1); } -int srslte_dlsch_decode2(srslte_sch_t* q, - srslte_pdsch_cfg_t* cfg, +int srsran_dlsch_decode2(srsran_sch_t* q, + srsran_pdsch_cfg_t* cfg, int16_t* e_bits, uint8_t* data, int tb_idx, @@ -574,13 +574,13 @@ int srslte_dlsch_decode2(srslte_sch_t* q, Nl = 2; } // Prepare cbsegm - srslte_cbsegm_t cb_segm; - if (srslte_cbsegm(&cb_segm, (uint32_t)cfg->grant.tb[tb_idx].tbs)) { + srsran_cbsegm_t cb_segm; + if (srsran_cbsegm(&cb_segm, (uint32_t)cfg->grant.tb[tb_idx].tbs)) { ERROR("Error computing Codeword (%d) segmentation for TBS=%d", tb_idx, cfg->grant.tb[tb_idx].tbs); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - uint32_t Qm = srslte_mod_bits_x_symbol(cfg->grant.tb[tb_idx].mod); + uint32_t Qm = srsran_mod_bits_x_symbol(cfg->grant.tb[tb_idx].mod); return decode_tb(q, cfg->softbuffers.rx[tb_idx], @@ -602,13 +602,13 @@ int srslte_dlsch_decode2(srslte_sch_t* q, * @param e_bits * @return Error code */ -int srslte_dlsch_encode(srslte_sch_t* q, srslte_pdsch_cfg_t* cfg, uint8_t* data, uint8_t* e_bits) +int srsran_dlsch_encode(srsran_sch_t* q, srsran_pdsch_cfg_t* cfg, uint8_t* data, uint8_t* e_bits) { - return srslte_dlsch_encode2(q, cfg, data, e_bits, 0, 1); + return srsran_dlsch_encode2(q, cfg, data, e_bits, 0, 1); } -int srslte_dlsch_encode2(srslte_sch_t* q, - srslte_pdsch_cfg_t* cfg, +int srsran_dlsch_encode2(srsran_sch_t* q, + srsran_pdsch_cfg_t* cfg, uint8_t* data, uint8_t* e_bits, int tb_idx, @@ -621,13 +621,13 @@ int srslte_dlsch_encode2(srslte_sch_t* q, } // Prepare cbsegm - srslte_cbsegm_t cb_segm; - if (srslte_cbsegm(&cb_segm, (uint32_t)cfg->grant.tb[tb_idx].tbs)) { + srsran_cbsegm_t cb_segm; + if (srsran_cbsegm(&cb_segm, (uint32_t)cfg->grant.tb[tb_idx].tbs)) { ERROR("Error computing Codeword (%d) segmentation for TBS=%d", tb_idx, cfg->grant.tb[tb_idx].tbs); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - uint32_t Qm = srslte_mod_bits_x_symbol(cfg->grant.tb[tb_idx].mod); + uint32_t Qm = srsran_mod_bits_x_symbol(cfg->grant.tb[tb_idx].mod); return encode_tb(q, cfg->softbuffers.tx[tb_idx], @@ -919,7 +919,7 @@ static void ulsch_interleave(uint8_t* g_bits, uint32_t H_prime_total, uint32_t N_pusch_symbs, uint8_t* q_bits, - srslte_uci_bit_t* ri_bits, + srsran_uci_bit_t* ri_bits, uint32_t nof_ri_bits, uint8_t* ri_present) { @@ -980,7 +980,7 @@ void ulsch_deinterleave(int16_t* q_bits, uint32_t H_prime_total, uint32_t N_pusch_symbs, int16_t* g_bits, - srslte_uci_bit_t* ri_bits, + srsran_uci_bit_t* ri_bits, uint32_t nof_ri_bits, uint8_t* ri_present, uint32_t* inteleaver_lut) @@ -994,7 +994,7 @@ void ulsch_deinterleave(int16_t* q_bits, // Generate interleaver table and interleave samples ulsch_interleave_gen(H_prime_total, N_pusch_symbs, Qm, ri_present, inteleaver_lut); - srslte_vec_lut_sis(q_bits, inteleaver_lut, g_bits, H_prime_total * Qm); + srsran_vec_lut_sis(q_bits, inteleaver_lut, g_bits, H_prime_total * Qm); // Reset temp_buffer because will be reused next time if (nof_ri_bits > 0) { @@ -1004,11 +1004,11 @@ void ulsch_deinterleave(int16_t* q_bits, } } -static int uci_decode_ri_ack(srslte_sch_t* q, - srslte_pusch_cfg_t* cfg, +static int uci_decode_ri_ack(srsran_sch_t* q, + srsran_pusch_cfg_t* cfg, int16_t* q_bits, uint8_t* c_seq, - srslte_uci_value_t* uci_data) + srsran_uci_value_t* uci_data) { int ret = 0; @@ -1016,24 +1016,24 @@ static int uci_decode_ri_ack(srslte_sch_t* q, uint32_t Q_prime_ri = 0; uint32_t nb_q = cfg->grant.tb.nof_bits; - uint32_t Qm = srslte_mod_bits_x_symbol(cfg->grant.tb.mod); + uint32_t Qm = srsran_mod_bits_x_symbol(cfg->grant.tb.mod); // If there is RI and CQI, assume RI = 1 for the purpose of RI/ACK decoding (3GPP 36.212 Clause 5.2.4.1. ) if (cfg->uci_cfg.cqi.data_enable) { - if (cfg->uci_cfg.cqi.type == SRSLTE_CQI_TYPE_SUBBAND_HL && cfg->uci_cfg.cqi.ri_len) { + if (cfg->uci_cfg.cqi.type == SRSRAN_CQI_TYPE_SUBBAND_HL && cfg->uci_cfg.cqi.ri_len) { cfg->uci_cfg.cqi.rank_is_not_one = false; } } - uint32_t cqi_len = srslte_cqi_size(&cfg->uci_cfg.cqi); + uint32_t cqi_len = srsran_cqi_size(&cfg->uci_cfg.cqi); // Deinterleave and decode HARQ bits - if (srslte_uci_cfg_total_ack(&cfg->uci_cfg) > 0) { + if (srsran_uci_cfg_total_ack(&cfg->uci_cfg) > 0) { float beta = get_beta_harq_offset(cfg->uci_offset.I_offset_ack); if (cfg->grant.tb.tbs == 0) { beta /= get_beta_cqi_offset(cfg->uci_offset.I_offset_cqi); } - ret = srslte_uci_decode_ack_ri(cfg, + ret = srsran_uci_decode_ack_ri(cfg, q_bits, c_seq, beta, @@ -1042,7 +1042,7 @@ static int uci_decode_ri_ack(srslte_sch_t* q, q->ack_ri_bits, uci_data->ack.ack_value, &uci_data->ack.valid, - srslte_uci_cfg_total_ack(&cfg->uci_cfg), + srsran_uci_cfg_total_ack(&cfg->uci_cfg), false); if (ret < 0) { return ret; @@ -1061,7 +1061,7 @@ static int uci_decode_ri_ack(srslte_sch_t* q, if (cfg->grant.tb.tbs == 0) { beta /= get_beta_cqi_offset(cfg->uci_offset.I_offset_cqi); } - ret = srslte_uci_decode_ack_ri(cfg, + ret = srsran_uci_decode_ack_ri(cfg, q_bits, c_seq, beta, @@ -1080,7 +1080,7 @@ static int uci_decode_ri_ack(srslte_sch_t* q, // Now set correct RI if (cfg->uci_cfg.cqi.data_enable) { - if (cfg->uci_cfg.cqi.type == SRSLTE_CQI_TYPE_SUBBAND_HL && cfg->uci_cfg.cqi.ri_len) { + if (cfg->uci_cfg.cqi.type == SRSRAN_CQI_TYPE_SUBBAND_HL && cfg->uci_cfg.cqi.ri_len) { cfg->uci_cfg.cqi.rank_is_not_one = uci_data->ri > 0; } } @@ -1088,32 +1088,32 @@ static int uci_decode_ri_ack(srslte_sch_t* q, return Q_prime_ri; } -int srslte_ulsch_decode(srslte_sch_t* q, - srslte_pusch_cfg_t* cfg, +int srsran_ulsch_decode(srsran_sch_t* q, + srsran_pusch_cfg_t* cfg, int16_t* q_bits, int16_t* g_bits, uint8_t* c_seq, uint8_t* data, - srslte_uci_value_t* uci_data) + srsran_uci_value_t* uci_data) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; // Prepare cbsegm - srslte_cbsegm_t cb_segm; - if (srslte_cbsegm(&cb_segm, (uint32_t)cfg->grant.tb.tbs)) { + srsran_cbsegm_t cb_segm; + if (srsran_cbsegm(&cb_segm, (uint32_t)cfg->grant.tb.tbs)) { ERROR("Error computing segmentation for TBS=%d", cfg->grant.tb.tbs); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } uint32_t nb_q = cfg->grant.tb.nof_bits; - uint32_t Qm = srslte_mod_bits_x_symbol(cfg->grant.tb.mod); + uint32_t Qm = srsran_mod_bits_x_symbol(cfg->grant.tb.mod); cfg->K_segm = cb_segm.C1 * cb_segm.K1 + cb_segm.C2 * cb_segm.K2; // Decode RI/HARQ values if ((ret = uci_decode_ri_ack(q, cfg, q_bits, c_seq, uci_data)) < 0) { ERROR("Error decoding RI/HARQ bits"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } uint32_t Q_prime_ri = (uint32_t)ret; @@ -1133,10 +1133,10 @@ int srslte_ulsch_decode(srslte_sch_t* q, uint32_t Q_prime_cqi = 0; uint32_t e_offset = 0; if (cfg->uci_cfg.cqi.data_enable) { - uint32_t cqi_len = srslte_cqi_size(&cfg->uci_cfg.cqi); - uint8_t cqi_buff[SRSLTE_CQI_MAX_BITS]; + uint32_t cqi_len = srsran_cqi_size(&cfg->uci_cfg.cqi); + uint8_t cqi_buff[SRSRAN_CQI_MAX_BITS]; ZERO_OBJECT(cqi_buff); - ret = srslte_uci_decode_cqi_pusch(&q->uci_cqi, + ret = srsran_uci_decode_cqi_pusch(&q->uci_cqi, cfg, g_bits, get_beta_cqi_offset(cfg->uci_offset.I_offset_cqi), @@ -1147,7 +1147,7 @@ int srslte_ulsch_decode(srslte_sch_t* q, if (ret < 0) { return ret; } - srslte_cqi_value_unpack(&cfg->uci_cfg.cqi, cqi_buff, &uci_data->cqi); + srsran_cqi_value_unpack(&cfg->uci_cfg.cqi, cqi_buff, &uci_data->cqi); Q_prime_cqi = (uint32_t)ret; } @@ -1161,10 +1161,10 @@ int srslte_ulsch_decode(srslte_sch_t* q, return ret; } -int srslte_ulsch_encode(srslte_sch_t* q, - srslte_pusch_cfg_t* cfg, +int srsran_ulsch_encode(srsran_sch_t* q, + srsran_pusch_cfg_t* cfg, uint8_t* data, - srslte_uci_value_t* uci_data, + srsran_uci_value_t* uci_data, uint8_t* g_bits, uint8_t* q_bits) { @@ -1176,36 +1176,36 @@ int srslte_ulsch_encode(srslte_sch_t* q, uint32_t Q_prime_ri = 0; uint32_t nb_q = cfg->grant.tb.nof_bits; - uint32_t Qm = srslte_mod_bits_x_symbol(cfg->grant.tb.mod); + uint32_t Qm = srsran_mod_bits_x_symbol(cfg->grant.tb.mod); if (Qm == 0) { ERROR("Invalid input"); - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } if (cfg->grant.nof_symb == 0) { ERROR("Invalid input"); - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } // Prepare cbsegm - srslte_cbsegm_t cb_segm; - if (srslte_cbsegm(&cb_segm, (uint32_t)cfg->grant.tb.tbs)) { + srsran_cbsegm_t cb_segm; + if (srsran_cbsegm(&cb_segm, (uint32_t)cfg->grant.tb.tbs)) { ERROR("Error computing segmentation for TBS=%d", cfg->grant.tb.tbs); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } cfg->K_segm = cb_segm.C1 * cb_segm.K1 + cb_segm.C2 * cb_segm.K2; int uci_cqi_len = 0; - uint8_t cqi_buff[SRSLTE_CQI_MAX_BITS]; + uint8_t cqi_buff[SRSRAN_CQI_MAX_BITS]; ZERO_OBJECT(cqi_buff); if (cfg->uci_cfg.cqi.data_enable) { - uci_cqi_len = (uint32_t)srslte_cqi_value_pack(&cfg->uci_cfg.cqi, &uci_data->cqi, cqi_buff); + uci_cqi_len = (uint32_t)srsran_cqi_value_pack(&cfg->uci_cfg.cqi, &uci_data->cqi, cqi_buff); if (uci_cqi_len < 0) { ERROR("Error encoding CQI bits"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } @@ -1215,7 +1215,7 @@ int srslte_ulsch_encode(srslte_sch_t* q, beta /= get_beta_cqi_offset(cfg->uci_offset.I_offset_cqi); } uint8_t ri[2] = {uci_data->ri, 0}; - ret = srslte_uci_encode_ack_ri(cfg, + ret = srsran_uci_encode_ack_ri(cfg, ri, cfg->uci_cfg.cqi.ri_len, (uint32_t)uci_cqi_len, @@ -1232,7 +1232,7 @@ int srslte_ulsch_encode(srslte_sch_t* q, // Encode CQI if (uci_cqi_len > 0) { - ret = srslte_uci_encode_cqi_pusch(&q->uci_cqi, + ret = srsran_uci_encode_cqi_pusch(&q->uci_cqi, cfg, cqi_buff, (uint32_t)uci_cqi_len, @@ -1244,10 +1244,10 @@ int srslte_ulsch_encode(srslte_sch_t* q, } Q_prime_cqi = (uint32_t)ret; - srslte_bit_pack_vector(q->temp_g_bits, g_bits, Q_prime_cqi * Qm); + srsran_bit_pack_vector(q->temp_g_bits, g_bits, Q_prime_cqi * Qm); // Reset the buffer because will be reused in ulsch_interleave - srslte_vec_u8_zero(q->temp_g_bits, Q_prime_cqi * Qm); + srsran_vec_u8_zero(q->temp_g_bits, Q_prime_cqi * Qm); } e_offset += Q_prime_cqi * Qm; @@ -1266,14 +1266,14 @@ int srslte_ulsch_encode(srslte_sch_t* q, ulsch_interleave(g_bits, Qm, nb_q / Qm, cfg->grant.nof_symb, q_bits, q->ack_ri_bits, Q_prime_ri * Qm, q->temp_g_bits); // Encode (and interleave) ACK - if (srslte_uci_cfg_total_ack(&cfg->uci_cfg) > 0) { + if (srsran_uci_cfg_total_ack(&cfg->uci_cfg) > 0) { float beta = get_beta_harq_offset(cfg->uci_offset.I_offset_ack); if (cb_segm.tbs == 0) { beta /= get_beta_cqi_offset(cfg->uci_offset.I_offset_cqi); } - ret = srslte_uci_encode_ack_ri(cfg, + ret = srsran_uci_encode_ack_ri(cfg, uci_data->ack.ack_value, - srslte_uci_cfg_total_ack(&cfg->uci_cfg), + srsran_uci_cfg_total_ack(&cfg->uci_cfg), (uint32_t)uci_cqi_len, beta, nb_q / Qm, @@ -1306,7 +1306,7 @@ int srslte_ulsch_encode(srslte_sch_t* q, return nof_ri_ack_bits; } -void srslte_sl_ulsch_interleave(uint8_t* g_bits, +void srsran_sl_ulsch_interleave(uint8_t* g_bits, uint32_t Qm, uint32_t H_prime_total, uint32_t N_pusch_symbs, @@ -1315,7 +1315,7 @@ void srslte_sl_ulsch_interleave(uint8_t* g_bits, ulsch_interleave(g_bits, Qm, H_prime_total, N_pusch_symbs, q_bits, NULL, 0, false); } -void srslte_sl_ulsch_deinterleave(int16_t* q_bits, +void srsran_sl_ulsch_deinterleave(int16_t* q_bits, uint32_t Qm, uint32_t H_prime_total, uint32_t N_pusch_symbs, diff --git a/lib/src/phy/phch/sch_nr.c b/lib/src/phy/phch/sch_nr.c index 174f76e1d..c77964f58 100644 --- a/lib/src/phy/phch/sch_nr.c +++ b/lib/src/phy/phch/sch_nr.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,24 +10,24 @@ * */ -#include "srslte/phy/phch/sch_nr.h" -#include "srslte/config.h" -#include "srslte/phy/fec/cbsegm.h" -#include "srslte/phy/fec/ldpc/ldpc_common.h" -#include "srslte/phy/fec/ldpc/ldpc_rm.h" -#include "srslte/phy/phch/ra_nr.h" -#include "srslte/phy/utils/bit.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/phch/sch_nr.h" +#include "srsran/config.h" +#include "srsran/phy/fec/cbsegm.h" +#include "srsran/phy/fec/ldpc/ldpc_common.h" +#include "srsran/phy/fec/ldpc/ldpc_rm.h" +#include "srsran/phy/phch/ra_nr.h" +#include "srsran/phy/utils/bit.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" #define SCH_INFO_TX(...) INFO("SCH Tx: " __VA_ARGS__) #define SCH_INFO_RX(...) INFO("SCH Rx: " __VA_ARGS__) -srslte_basegraph_t srslte_sch_nr_select_basegraph(uint32_t tbs, double R) +srsran_basegraph_t srsran_sch_nr_select_basegraph(uint32_t tbs, double R) { // if A ≤ 292 , or if A ≤ 3824 and R ≤ 0.67 , or if R ≤ 0 . 25 , LDPC base graph 2 is used; // otherwise, LDPC base graph 1 is used - srslte_basegraph_t bg = BG1; + srsran_basegraph_t bg = BG1; if ((tbs <= 292) || (tbs <= 3824 && R <= 0.67) || (R <= 0.25)) { bg = BG2; } @@ -65,39 +65,39 @@ uint32_t sch_nr_n_prb_lbrm(uint32_t nof_prb) return 273; } -int srslte_sch_nr_fill_tb_info(const srslte_carrier_nr_t* carrier, - const srslte_sch_cfg_t* sch_cfg, - const srslte_sch_tb_t* tb, - srslte_sch_nr_tb_info_t* cfg) +int srsran_sch_nr_fill_tb_info(const srsran_carrier_nr_t* carrier, + const srsran_sch_cfg_t* sch_cfg, + const srsran_sch_tb_t* tb, + srsran_sch_nr_tb_info_t* cfg) { if (!sch_cfg || !tb || !cfg) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } // LDPC base graph selection - srslte_basegraph_t bg = srslte_sch_nr_select_basegraph(tb->tbs, tb->R); + srsran_basegraph_t bg = srsran_sch_nr_select_basegraph(tb->tbs, tb->R); // Compute code block segmentation - srslte_cbsegm_t cbsegm = {}; + srsran_cbsegm_t cbsegm = {}; if (bg == BG1) { - if (srslte_cbsegm_ldpc_bg1(&cbsegm, tb->tbs) != SRSLTE_SUCCESS) { + if (srsran_cbsegm_ldpc_bg1(&cbsegm, tb->tbs) != SRSRAN_SUCCESS) { ERROR("Error: calculating LDPC BG1 code block segmentation for tbs=%d", tb->tbs); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } else { - if (srslte_cbsegm_ldpc_bg2(&cbsegm, tb->tbs) != SRSLTE_SUCCESS) { + if (srsran_cbsegm_ldpc_bg2(&cbsegm, tb->tbs) != SRSRAN_SUCCESS) { ERROR("Error: calculating LDPC BG1 code block segmentation for tbs=%d", tb->tbs); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } if (cbsegm.Z > MAX_LIFTSIZE) { ERROR("Error: lifting size Z=%d is out-of-range maximum is %d", cbsegm.Z, MAX_LIFTSIZE); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } cfg->bg = bg; - cfg->Qm = srslte_mod_bits_x_symbol(tb->mod); + cfg->Qm = srsran_mod_bits_x_symbol(tb->mod); cfg->A = tb->tbs; cfg->L_tb = cbsegm.L_tb; cfg->L_cb = cbsegm.L_cb; @@ -113,8 +113,8 @@ int srslte_sch_nr_fill_tb_info(const srslte_carrier_nr_t* carrier, // Calculate Nref uint32_t N_re_lbrm = 156 * sch_nr_n_prb_lbrm(carrier->nof_prb); double TCR_lbrm = 948.0 / 1024.0; - uint32_t Qm_lbrm = (sch_cfg->mcs_table == srslte_mcs_table_256qam) ? 8 : 6; - uint32_t TBS_LRBM = srslte_ra_nr_tbs(N_re_lbrm, 1.0, TCR_lbrm, Qm_lbrm, carrier->max_mimo_layers); + uint32_t Qm_lbrm = (sch_cfg->mcs_table == srsran_mcs_table_256qam) ? 8 : 6; + uint32_t TBS_LRBM = srsran_ra_nr_tbs(N_re_lbrm, 1.0, TCR_lbrm, Qm_lbrm, carrier->max_mimo_layers); double R = 2.0 / 3.0; cfg->Nref = ceil(TBS_LRBM / (cbsegm.C * R)); @@ -122,18 +122,18 @@ int srslte_sch_nr_fill_tb_info(const srslte_carrier_nr_t* carrier, for (uint32_t r = 0; r < cbsegm.C; r++) { cfg->mask[r] = true; } - for (uint32_t r = cbsegm.C; r < SRSLTE_SCH_NR_MAX_NOF_CB_LDPC; r++) { + for (uint32_t r = cbsegm.C; r < SRSRAN_SCH_NR_MAX_NOF_CB_LDPC; r++) { cfg->mask[r] = false; } cfg->C = cbsegm.C; cfg->Cp = cbsegm.C; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } #define MOD(NUM, DEN) ((NUM) % (DEN)) -static inline uint32_t sch_nr_get_E(const srslte_sch_nr_tb_info_t* cfg, uint32_t j) +static inline uint32_t sch_nr_get_E(const srsran_sch_nr_tb_info_t* cfg, uint32_t j) { if (cfg->Nl == 0 || cfg->Qm == 0 || cfg->Cp == 0) { ERROR("Invalid Nl (%d), Qm (%d) or Cp (%d)", cfg->Nl, cfg->Qm, cfg->Cp); @@ -143,54 +143,54 @@ static inline uint32_t sch_nr_get_E(const srslte_sch_nr_tb_info_t* cfg, uint32_t if (j <= (cfg->Cp - MOD(cfg->G / (cfg->Nl * cfg->Qm), cfg->Cp) - 1)) { return cfg->Nl * cfg->Qm * (cfg->G / (cfg->Nl * cfg->Qm * cfg->Cp)); } - return cfg->Nl * cfg->Qm * SRSLTE_CEIL(cfg->G, cfg->Nl * cfg->Qm * cfg->Cp); + return cfg->Nl * cfg->Qm * SRSRAN_CEIL(cfg->G, cfg->Nl * cfg->Qm * cfg->Cp); } -static inline int sch_nr_init_common(srslte_sch_nr_t* q) +static inline int sch_nr_init_common(srsran_sch_nr_t* q) { if (q == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } - if (srslte_crc_init(&q->crc_tb_24, SRSLTE_LTE_CRC24A, 24) < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (srsran_crc_init(&q->crc_tb_24, SRSRAN_LTE_CRC24A, 24) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } - if (srslte_crc_init(&q->crc_cb, SRSLTE_LTE_CRC24B, 24) < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (srsran_crc_init(&q->crc_cb, SRSRAN_LTE_CRC24B, 24) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } - if (srslte_crc_init(&q->crc_tb_16, SRSLTE_LTE_CRC16, 16) < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (srsran_crc_init(&q->crc_tb_16, SRSRAN_LTE_CRC16, 16) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } if (!q->temp_cb) { - q->temp_cb = srslte_vec_u8_malloc(SRSLTE_LDPC_MAX_LEN_CB * 8); + q->temp_cb = srsran_vec_u8_malloc(SRSRAN_LDPC_MAX_LEN_CB * 8); if (!q->temp_cb) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_sch_nr_init_tx(srslte_sch_nr_t* q, const srslte_sch_nr_args_t* args) +int srsran_sch_nr_init_tx(srsran_sch_nr_t* q, const srsran_sch_nr_args_t* args) { int ret = sch_nr_init_common(q); - if (ret < SRSLTE_SUCCESS) { + if (ret < SRSRAN_SUCCESS) { return ret; } - srslte_ldpc_encoder_type_t encoder_type = SRSLTE_LDPC_ENCODER_C; + srsran_ldpc_encoder_type_t encoder_type = SRSRAN_LDPC_ENCODER_C; #ifdef LV_HAVE_AVX512 if (!args->disable_simd) { - encoder_type = SRSLTE_LDPC_ENCODER_AVX512; + encoder_type = SRSRAN_LDPC_ENCODER_AVX512; } #else // LV_HAVE_AVX512 #ifdef LV_HAVE_AVX2 if (!args->disable_simd) { - encoder_type = SRSLTE_LDPC_ENCODER_AVX2; + encoder_type = SRSRAN_LDPC_ENCODER_AVX2; } #endif // LV_HAVE_AVX2 #endif // LV_HAVE_AVX612 @@ -206,56 +206,56 @@ int srslte_sch_nr_init_tx(srslte_sch_nr_t* q, const srslte_sch_nr_args_t* args) continue; } - q->encoder_bg1[ls] = SRSLTE_MEM_ALLOC(srslte_ldpc_encoder_t, 1); + q->encoder_bg1[ls] = SRSRAN_MEM_ALLOC(srsran_ldpc_encoder_t, 1); if (!q->encoder_bg1[ls]) { ERROR("Error: calloc"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - SRSLTE_MEM_ZERO(q->encoder_bg1[ls], srslte_ldpc_encoder_t, 1); + SRSRAN_MEM_ZERO(q->encoder_bg1[ls], srsran_ldpc_encoder_t, 1); - if (srslte_ldpc_encoder_init(q->encoder_bg1[ls], encoder_type, BG1, ls) < SRSLTE_SUCCESS) { + if (srsran_ldpc_encoder_init(q->encoder_bg1[ls], encoder_type, BG1, ls) < SRSRAN_SUCCESS) { ERROR("Error: initialising BG1 LDPC encoder for ls=%d", ls); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - q->encoder_bg2[ls] = SRSLTE_MEM_ALLOC(srslte_ldpc_encoder_t, 1); + q->encoder_bg2[ls] = SRSRAN_MEM_ALLOC(srsran_ldpc_encoder_t, 1); if (!q->encoder_bg2[ls]) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - SRSLTE_MEM_ZERO(q->encoder_bg2[ls], srslte_ldpc_encoder_t, 1); + SRSRAN_MEM_ZERO(q->encoder_bg2[ls], srsran_ldpc_encoder_t, 1); - if (srslte_ldpc_encoder_init(q->encoder_bg2[ls], encoder_type, BG2, ls) < SRSLTE_SUCCESS) { + if (srsran_ldpc_encoder_init(q->encoder_bg2[ls], encoder_type, BG2, ls) < SRSRAN_SUCCESS) { ERROR("Error: initialising BG2 LDPC encoder for ls=%d", ls); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } - if (srslte_ldpc_rm_tx_init(&q->tx_rm) < SRSLTE_SUCCESS) { + if (srsran_ldpc_rm_tx_init(&q->tx_rm) < SRSRAN_SUCCESS) { ERROR("Error: initialising Tx LDPC Rate matching"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_sch_nr_init_rx(srslte_sch_nr_t* q, const srslte_sch_nr_args_t* args) +int srsran_sch_nr_init_rx(srsran_sch_nr_t* q, const srsran_sch_nr_args_t* args) { int ret = sch_nr_init_common(q); - if (ret < SRSLTE_SUCCESS) { + if (ret < SRSRAN_SUCCESS) { return ret; } - srslte_ldpc_decoder_type_t decoder_type = - args->decoder_use_flooded ? SRSLTE_LDPC_DECODER_C_FLOOD : SRSLTE_LDPC_DECODER_C; + srsran_ldpc_decoder_type_t decoder_type = + args->decoder_use_flooded ? SRSRAN_LDPC_DECODER_C_FLOOD : SRSRAN_LDPC_DECODER_C; #ifdef LV_HAVE_AVX512 if (!args->disable_simd) { - decoder_type = args->decoder_use_flooded ? SRSLTE_LDPC_DECODER_C_AVX512_FLOOD : SRSLTE_LDPC_DECODER_C_AVX512; + decoder_type = args->decoder_use_flooded ? SRSRAN_LDPC_DECODER_C_AVX512_FLOOD : SRSRAN_LDPC_DECODER_C_AVX512; } #else // LV_HAVE_AVX512 #ifdef LV_HAVE_AVX2 if (!args->disable_simd) { - decoder_type = args->decoder_use_flooded ? SRSLTE_LDPC_DECODER_C_AVX2_FLOOD : SRSLTE_LDPC_DECODER_C_AVX2; + decoder_type = args->decoder_use_flooded ? SRSRAN_LDPC_DECODER_C_AVX2_FLOOD : SRSRAN_LDPC_DECODER_C_AVX2; } #endif // LV_HAVE_AVX2 #endif // LV_HAVE_AVX512 @@ -275,49 +275,49 @@ int srslte_sch_nr_init_rx(srslte_sch_nr_t* q, const srslte_sch_nr_args_t* args) continue; } - q->decoder_bg1[ls] = calloc(1, sizeof(srslte_ldpc_decoder_t)); + q->decoder_bg1[ls] = calloc(1, sizeof(srsran_ldpc_decoder_t)); if (!q->decoder_bg1[ls]) { ERROR("Error: calloc"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_ldpc_decoder_init(q->decoder_bg1[ls], decoder_type, BG1, ls, scaling_factor) < SRSLTE_SUCCESS) { + if (srsran_ldpc_decoder_init(q->decoder_bg1[ls], decoder_type, BG1, ls, scaling_factor) < SRSRAN_SUCCESS) { ERROR("Error: initialising BG1 LDPC decoder for ls=%d", ls); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - q->decoder_bg2[ls] = calloc(1, sizeof(srslte_ldpc_decoder_t)); + q->decoder_bg2[ls] = calloc(1, sizeof(srsran_ldpc_decoder_t)); if (!q->decoder_bg2[ls]) { ERROR("Error: calloc"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_ldpc_decoder_init(q->decoder_bg2[ls], decoder_type, BG2, ls, scaling_factor) < SRSLTE_SUCCESS) { + if (srsran_ldpc_decoder_init(q->decoder_bg2[ls], decoder_type, BG2, ls, scaling_factor) < SRSRAN_SUCCESS) { ERROR("Error: initialising BG2 LDPC decoder for ls=%d", ls); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } - if (srslte_ldpc_rm_rx_init_c(&q->rx_rm) < SRSLTE_SUCCESS) { + if (srsran_ldpc_rm_rx_init_c(&q->rx_rm) < SRSRAN_SUCCESS) { ERROR("Error: initialising Rx LDPC Rate matching"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_sch_nr_set_carrier(srslte_sch_nr_t* q, const srslte_carrier_nr_t* carrier) +int srsran_sch_nr_set_carrier(srsran_sch_nr_t* q, const srsran_carrier_nr_t* carrier) { if (!q) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } q->carrier = *carrier; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -void srslte_sch_nr_free(srslte_sch_nr_t* q) +void srsran_sch_nr_free(srsran_sch_nr_t* q) { // Protect pointer if (!q) { @@ -330,65 +330,65 @@ void srslte_sch_nr_free(srslte_sch_nr_t* q) for (uint16_t ls = 0; ls <= MAX_LIFTSIZE; ls++) { if (q->encoder_bg1[ls]) { - srslte_ldpc_encoder_free(q->encoder_bg1[ls]); + srsran_ldpc_encoder_free(q->encoder_bg1[ls]); free(q->encoder_bg1[ls]); } if (q->encoder_bg2[ls]) { - srslte_ldpc_encoder_free(q->encoder_bg2[ls]); + srsran_ldpc_encoder_free(q->encoder_bg2[ls]); free(q->encoder_bg2[ls]); } if (q->decoder_bg1[ls]) { - srslte_ldpc_decoder_free(q->decoder_bg1[ls]); + srsran_ldpc_decoder_free(q->decoder_bg1[ls]); free(q->decoder_bg1[ls]); } if (q->decoder_bg2[ls]) { - srslte_ldpc_decoder_free(q->decoder_bg2[ls]); + srsran_ldpc_decoder_free(q->decoder_bg2[ls]); free(q->decoder_bg2[ls]); } } - srslte_ldpc_rm_tx_free(&q->tx_rm); - srslte_ldpc_rm_rx_free_c(&q->rx_rm); + srsran_ldpc_rm_tx_free(&q->tx_rm); + srsran_ldpc_rm_rx_free_c(&q->rx_rm); } -static inline int sch_nr_encode(srslte_sch_nr_t* q, - const srslte_sch_cfg_t* sch_cfg, - const srslte_sch_tb_t* tb, +static inline int sch_nr_encode(srsran_sch_nr_t* q, + const srsran_sch_cfg_t* sch_cfg, + const srsran_sch_tb_t* tb, const uint8_t* data, uint8_t* e_bits) { // Pointer protection if (!q || !sch_cfg || !tb || !data || !e_bits) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } if (!tb->softbuffer.tx) { ERROR("Error: Missing Tx softbuffer"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } const uint8_t* input_ptr = data; uint8_t* output_ptr = e_bits; - srslte_sch_nr_tb_info_t cfg = {}; - if (srslte_sch_nr_fill_tb_info(&q->carrier, sch_cfg, tb, &cfg) < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + srsran_sch_nr_tb_info_t cfg = {}; + if (srsran_sch_nr_fill_tb_info(&q->carrier, sch_cfg, tb, &cfg) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } // Select encoder and CRC - srslte_ldpc_encoder_t* encoder = (cfg.bg == BG1) ? q->encoder_bg1[cfg.Z] : q->encoder_bg2[cfg.Z]; - srslte_crc_t* crc_tb = (cfg.L_tb == 24) ? &q->crc_tb_24 : &q->crc_tb_16; + srsran_ldpc_encoder_t* encoder = (cfg.bg == BG1) ? q->encoder_bg1[cfg.Z] : q->encoder_bg2[cfg.Z]; + srsran_crc_t* crc_tb = (cfg.L_tb == 24) ? &q->crc_tb_24 : &q->crc_tb_16; // Check encoder if (encoder == NULL) { ERROR("Error: encoder for lifting size Z=%d not found (tbs=%d)", cfg.Z, tb->tbs); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Check CRC for TB if (crc_tb == NULL) { ERROR("Error: CRC for TB not found"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Soft-buffer number of code-block protection @@ -397,7 +397,7 @@ static inline int sch_nr_encode(srslte_sch_nr_t* q, tb->softbuffer.tx->max_cb, tb->tbs, cfg.C); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (tb->softbuffer.tx->max_cb_size < (encoder->liftN - 2 * cfg.Z)) { @@ -405,14 +405,14 @@ static inline int sch_nr_encode(srslte_sch_nr_t* q, tb->softbuffer.tx->max_cb_size, tb->tbs, (encoder->liftN - 2 * cfg.Z)); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Calculate TB CRC - uint32_t checksum_tb = srslte_crc_checksum_byte(crc_tb, data, tb->tbs); - if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_DEBUG && !handler_registered) { + uint32_t checksum_tb = srsran_crc_checksum_byte(crc_tb, data, tb->tbs); + if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_DEBUG && !handler_registered) { DEBUG("tb="); - srslte_vec_fprint_byte(stdout, data, tb->tbs / 8); + srsran_vec_fprint_byte(stdout, data, tb->tbs / 8); } // For each code block... @@ -422,7 +422,7 @@ static inline int sch_nr_encode(srslte_sch_nr_t* q, uint8_t* rm_buffer = tb->softbuffer.tx->buffer_b[r]; if (rm_buffer == NULL) { ERROR("Error: soft-buffer provided NULL buffer for cb_idx=%d", r); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // If data provided, encode and store in RM circular buffer @@ -434,28 +434,28 @@ static inline int sch_nr_encode(srslte_sch_nr_t* q, cb_len -= cfg.L_tb; // Copy payload without TB CRC - srslte_bit_unpack_vector(input_ptr, q->temp_cb, (int)cb_len); + srsran_bit_unpack_vector(input_ptr, q->temp_cb, (int)cb_len); // Append TB CRC uint8_t* ptr = &q->temp_cb[cb_len]; - srslte_bit_unpack(checksum_tb, &ptr, cfg.L_tb); + srsran_bit_unpack(checksum_tb, &ptr, cfg.L_tb); SCH_INFO_TX("CB %d: appending TB CRC=%06x", r, checksum_tb); } else { // Copy payload - srslte_bit_unpack_vector(input_ptr, q->temp_cb, (int)cb_len); + srsran_bit_unpack_vector(input_ptr, q->temp_cb, (int)cb_len); } - if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_DEBUG && !handler_registered) { + if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_DEBUG && !handler_registered) { DEBUG("cb%d=", r); - srslte_vec_fprint_byte(stdout, input_ptr, cb_len / 8); + srsran_vec_fprint_byte(stdout, input_ptr, cb_len / 8); } input_ptr += cb_len / 8; // Attach code block CRC if required if (cfg.L_cb) { - srslte_crc_attach(&q->crc_cb, q->temp_cb, (int)(cfg.Kp - cfg.L_cb)); - SCH_INFO_TX("CB %d: CRC=%06x", r, (uint32_t)srslte_crc_checksum_get(&q->crc_cb)); + srsran_crc_attach(&q->crc_cb, q->temp_cb, (int)(cfg.Kp - cfg.L_cb)); + SCH_INFO_TX("CB %d: CRC=%06x", r, (uint32_t)srsran_crc_checksum_get(&q->crc_cb)); } // Insert filler bits @@ -464,11 +464,11 @@ static inline int sch_nr_encode(srslte_sch_nr_t* q, } // Encode code block - srslte_ldpc_encoder_encode(encoder, q->temp_cb, rm_buffer, cfg.Kr); + srsran_ldpc_encoder_encode(encoder, q->temp_cb, rm_buffer, cfg.Kr); - if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_DEBUG && !handler_registered) { + if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_DEBUG && !handler_registered) { DEBUG("encoded="); - srslte_vec_fprint_b(stdout, rm_buffer, encoder->liftN - 2 * encoder->ls); + srsran_vec_fprint_b(stdout, rm_buffer, encoder->liftN - 2 * encoder->ls); } } @@ -491,51 +491,51 @@ static inline int sch_nr_encode(srslte_sch_nr_t* q, tb->rv, cfg.Qm, cfg.Nref); - srslte_ldpc_rm_tx(&q->tx_rm, rm_buffer, output_ptr, E, cfg.bg, cfg.Z, tb->rv, tb->mod, cfg.Nref); + srsran_ldpc_rm_tx(&q->tx_rm, rm_buffer, output_ptr, E, cfg.bg, cfg.Z, tb->rv, tb->mod, cfg.Nref); output_ptr += E; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int sch_nr_decode(srslte_sch_nr_t* q, - const srslte_sch_cfg_t* sch_cfg, - const srslte_sch_tb_t* tb, +int sch_nr_decode(srsran_sch_nr_t* q, + const srsran_sch_cfg_t* sch_cfg, + const srsran_sch_tb_t* tb, int8_t* e_bits, uint8_t* data, bool* crc_ok) { // Pointer protection if (!q || !sch_cfg || !tb || !data || !e_bits || !crc_ok) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } int8_t* input_ptr = e_bits; - srslte_sch_nr_tb_info_t cfg = {}; - if (srslte_sch_nr_fill_tb_info(&q->carrier, sch_cfg, tb, &cfg) < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + srsran_sch_nr_tb_info_t cfg = {}; + if (srsran_sch_nr_fill_tb_info(&q->carrier, sch_cfg, tb, &cfg) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } // Select encoder and CRC - srslte_ldpc_decoder_t* decoder = (cfg.bg == BG1) ? q->decoder_bg1[cfg.Z] : q->decoder_bg2[cfg.Z]; - srslte_crc_t* crc_tb = (cfg.L_tb == 24) ? &q->crc_tb_24 : &q->crc_tb_16; + srsran_ldpc_decoder_t* decoder = (cfg.bg == BG1) ? q->decoder_bg1[cfg.Z] : q->decoder_bg2[cfg.Z]; + srsran_crc_t* crc_tb = (cfg.L_tb == 24) ? &q->crc_tb_24 : &q->crc_tb_16; // Check decoder if (decoder == NULL) { ERROR("Error: decoder for lifting size Z=%d not found", cfg.Z); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Check CRC for TB if (crc_tb == NULL) { ERROR("Error: CRC for TB not found"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Soft-buffer number of code-block protection if (tb->softbuffer.rx->max_cb < cfg.Cp || tb->softbuffer.rx->max_cb_size < (decoder->liftN - 2 * cfg.Z)) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Counter of code blocks that have matched CRC @@ -548,7 +548,7 @@ int sch_nr_decode(srslte_sch_nr_t* q, int8_t* rm_buffer = (int8_t*)tb->softbuffer.tx->buffer_b[r]; if (!rm_buffer) { ERROR("Error: soft-buffer provided NULL buffer for cb_idx=%d", r); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Skip CB if mask indicates no transmission of the CB @@ -581,17 +581,17 @@ int sch_nr_decode(srslte_sch_nr_t* q, tb->rv, cfg.Qm, cfg.Nref); - srslte_ldpc_rm_rx_c(&q->rx_rm, input_ptr, rm_buffer, E, cfg.F, cfg.bg, cfg.Z, tb->rv, tb->mod, cfg.Nref); + srsran_ldpc_rm_rx_c(&q->rx_rm, input_ptr, rm_buffer, E, cfg.F, cfg.bg, cfg.Z, tb->rv, tb->mod, cfg.Nref); // Decode - srslte_ldpc_decoder_decode_c(decoder, rm_buffer, q->temp_cb); + srsran_ldpc_decoder_decode_c(decoder, rm_buffer, q->temp_cb); // Compute CB CRC uint32_t cb_len = cfg.Kp - cfg.L_cb; if (cfg.L_cb) { uint8_t* ptr = q->temp_cb + cb_len; - uint32_t checksum1 = srslte_crc_checksum(&q->crc_cb, q->temp_cb, (int)cb_len); - uint32_t checksum2 = srslte_bit_pack(&ptr, cfg.L_cb); + uint32_t checksum1 = srsran_crc_checksum(&q->crc_cb, q->temp_cb, (int)cb_len); + uint32_t checksum2 = srsran_bit_pack(&ptr, cfg.L_cb); tb->softbuffer.rx->cb_crc[r] = (checksum1 == checksum2); SCH_INFO_RX("CB %d/%d: CRC={%06x, %06x} ... %s", @@ -606,7 +606,7 @@ int sch_nr_decode(srslte_sch_nr_t* q, // Pack and count CRC OK only if CRC is match if (tb->softbuffer.rx->cb_crc[r]) { - srslte_bit_pack_vector(q->temp_cb, tb->softbuffer.rx->data[r], cb_len); + srsran_bit_pack_vector(q->temp_cb, tb->softbuffer.rx->data[r], cb_len); cb_ok++; } @@ -626,18 +626,18 @@ int sch_nr_decode(srslte_sch_nr_t* q, cb_len -= cfg.L_tb; } - srslte_vec_u8_copy(output_ptr, tb->softbuffer.rx->data[r], cb_len / 8); + srsran_vec_u8_copy(output_ptr, tb->softbuffer.rx->data[r], cb_len / 8); output_ptr += cb_len / 8; - if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_DEBUG && !handler_registered) { + if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_DEBUG && !handler_registered) { DEBUG("CB %d:", r); - srslte_vec_fprint_byte(stdout, tb->softbuffer.rx->data[r], cb_len / 8); + srsran_vec_fprint_byte(stdout, tb->softbuffer.rx->data[r], cb_len / 8); } if (r == cfg.C - 1) { uint8_t tb_crc_unpacked[24] = {}; uint8_t* tb_crc_unpacked_ptr = tb_crc_unpacked; - srslte_bit_unpack_vector(&tb->softbuffer.rx->data[r][cb_len / 8], tb_crc_unpacked, cfg.L_tb); - checksum2 = srslte_bit_pack(&tb_crc_unpacked_ptr, cfg.L_tb); + srsran_bit_unpack_vector(&tb->softbuffer.rx->data[r][cb_len / 8], tb_crc_unpacked, cfg.L_tb); + checksum2 = srsran_bit_pack(&tb_crc_unpacked_ptr, cfg.L_tb); } } @@ -648,33 +648,33 @@ int sch_nr_decode(srslte_sch_nr_t* q, } // Calculate TB CRC from packed data - uint32_t checksum1 = srslte_crc_checksum_byte(crc_tb, data, tb->tbs); + uint32_t checksum1 = srsran_crc_checksum_byte(crc_tb, data, tb->tbs); *crc_ok = (checksum1 == checksum2 && !all_zeros); SCH_INFO_RX("TB: TBS=%d; CRC={%06x, %06x}", tb->tbs, checksum1, checksum2); - if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_DEBUG && !handler_registered) { + if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_DEBUG && !handler_registered) { DEBUG("Decode: "); - srslte_vec_fprint_byte(stdout, data, tb->tbs / 8); + srsran_vec_fprint_byte(stdout, data, tb->tbs / 8); } } else { *crc_ok = false; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_dlsch_nr_encode(srslte_sch_nr_t* q, - const srslte_sch_cfg_t* pdsch_cfg, - const srslte_sch_tb_t* tb, +int srsran_dlsch_nr_encode(srsran_sch_nr_t* q, + const srsran_sch_cfg_t* pdsch_cfg, + const srsran_sch_tb_t* tb, const uint8_t* data, uint8_t* e_bits) { return sch_nr_encode(q, pdsch_cfg, tb, data, e_bits); } -int srslte_dlsch_nr_decode(srslte_sch_nr_t* q, - const srslte_sch_cfg_t* sch_cfg, - const srslte_sch_tb_t* tb, +int srsran_dlsch_nr_decode(srsran_sch_nr_t* q, + const srsran_sch_cfg_t* sch_cfg, + const srsran_sch_tb_t* tb, int8_t* e_bits, uint8_t* data, bool* crc_ok) @@ -682,18 +682,18 @@ int srslte_dlsch_nr_decode(srslte_sch_nr_t* q, return sch_nr_decode(q, sch_cfg, tb, e_bits, data, crc_ok); } -int srslte_ulsch_nr_encode(srslte_sch_nr_t* q, - const srslte_sch_cfg_t* pdsch_cfg, - const srslte_sch_tb_t* tb, +int srsran_ulsch_nr_encode(srsran_sch_nr_t* q, + const srsran_sch_cfg_t* pdsch_cfg, + const srsran_sch_tb_t* tb, const uint8_t* data, uint8_t* e_bits) { return sch_nr_encode(q, pdsch_cfg, tb, data, e_bits); } -int srslte_ulsch_nr_decode(srslte_sch_nr_t* q, - const srslte_sch_cfg_t* sch_cfg, - const srslte_sch_tb_t* tb, +int srsran_ulsch_nr_decode(srsran_sch_nr_t* q, + const srsran_sch_cfg_t* sch_cfg, + const srsran_sch_tb_t* tb, int8_t* e_bits, uint8_t* data, bool* crc_ok) @@ -701,16 +701,16 @@ int srslte_ulsch_nr_decode(srslte_sch_nr_t* q, return sch_nr_decode(q, sch_cfg, tb, e_bits, data, crc_ok); } -int srslte_sch_nr_tb_info(const srslte_sch_tb_t* tb, char* str, uint32_t str_len) +int srsran_sch_nr_tb_info(const srsran_sch_tb_t* tb, char* str, uint32_t str_len) { int len = 0; if (tb->enabled) { - len += srslte_print_check(str, + len += srsran_print_check(str, str_len, len, "tb={mod=%s,Nl=%d,tbs=%d,R=%.3f,rv=%d,Nre=%d,Nbit=%d,cw=%d}", - srslte_mod_string(tb->mod), + srsran_mod_string(tb->mod), tb->N_L, tb->tbs / 8, tb->R, diff --git a/lib/src/phy/phch/sci.c b/lib/src/phy/phch/sci.c index 0befc3082..e762c830a 100644 --- a/lib/src/phy/phch/sci.c +++ b/lib/src/phy/phch/sci.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -12,85 +12,85 @@ #include -#include "srslte/phy/phch/sci.h" -#include "srslte/phy/utils/bit.h" +#include "srsran/phy/phch/sci.h" +#include "srsran/phy/utils/bit.h" -int srslte_sci_init(srslte_sci_t* q, srslte_cell_sl_t cell, srslte_sl_comm_resource_pool_t sl_comm_resource_pool) +int srsran_sci_init(srsran_sci_t* q, srsran_cell_sl_t cell, srsran_sl_comm_resource_pool_t sl_comm_resource_pool) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL) { - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; - bzero(q, sizeof(srslte_sci_t)); + bzero(q, sizeof(srsran_sci_t)); q->nof_prb = cell.nof_prb; q->tm = cell.tm; - if (cell.tm == SRSLTE_SIDELINK_TM1 || cell.tm == SRSLTE_SIDELINK_TM2) { - q->format = SRSLTE_SCI_FORMAT0; - q->sci_len = srslte_sci_format0_sizeof(cell.nof_prb); + if (cell.tm == SRSRAN_SIDELINK_TM1 || cell.tm == SRSRAN_SIDELINK_TM2) { + q->format = SRSRAN_SCI_FORMAT0; + q->sci_len = srsran_sci_format0_sizeof(cell.nof_prb); - } else if (cell.tm == SRSLTE_SIDELINK_TM3 || cell.tm == SRSLTE_SIDELINK_TM4) { - q->format = SRSLTE_SCI_FORMAT1; - q->sci_len = SRSLTE_SCI_TM34_LEN; + } else if (cell.tm == SRSRAN_SIDELINK_TM3 || cell.tm == SRSRAN_SIDELINK_TM4) { + q->format = SRSRAN_SCI_FORMAT1; + q->sci_len = SRSRAN_SCI_TM34_LEN; q->size_sub_channel = sl_comm_resource_pool.size_sub_channel; q->num_sub_channel = sl_comm_resource_pool.num_sub_channel; } else { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } -int srslte_sci_format0_pack(srslte_sci_t* q, uint8_t* output) +int srsran_sci_format0_pack(srsran_sci_t* q, uint8_t* output) { if (!q) { printf("Error packing SCI Format 0\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - bzero(output, sizeof(uint8_t) * SRSLTE_SCI_MAX_LEN); - srslte_bit_unpack((uint32_t)q->freq_hopping_flag, &output, 1); + bzero(output, sizeof(uint8_t) * SRSRAN_SCI_MAX_LEN); + srsran_bit_unpack((uint32_t)q->freq_hopping_flag, &output, 1); if (q->freq_hopping_flag) { printf("Frequency Hopping in Sidelink is not supported\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } else { - srslte_bit_unpack(q->riv, &output, (uint32_t)ceil(log2(((q->nof_prb) * (q->nof_prb + 1) / 2)))); + srsran_bit_unpack(q->riv, &output, (uint32_t)ceil(log2(((q->nof_prb) * (q->nof_prb + 1) / 2)))); } - srslte_bit_unpack(q->trp_idx, &output, 7); - srslte_bit_unpack(q->mcs_idx, &output, 5); - srslte_bit_unpack(q->timing_advance, &output, 11); - srslte_bit_unpack(q->N_sa_id, &output, 8); + srsran_bit_unpack(q->trp_idx, &output, 7); + srsran_bit_unpack(q->mcs_idx, &output, 5); + srsran_bit_unpack(q->timing_advance, &output, 11); + srsran_bit_unpack(q->N_sa_id, &output, 8); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_sci_format1_pack(srslte_sci_t* q, uint8_t* output) +int srsran_sci_format1_pack(srsran_sci_t* q, uint8_t* output) { if (!q) { printf("Error packing SCI Format 1\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - bzero(output, sizeof(uint8_t) * SRSLTE_SCI_MAX_LEN); - srslte_bit_unpack(q->priority, &output, 3); - srslte_bit_unpack(q->resource_reserv, &output, 4); - srslte_bit_unpack(q->riv, &output, (uint32_t)ceil(log2(((q->num_sub_channel) * (q->num_sub_channel + 1) / 2)))); - srslte_bit_unpack(q->time_gap, &output, 4); - srslte_bit_unpack(q->mcs_idx, &output, 5); - srslte_bit_unpack(q->retransmission, &output, 1); + bzero(output, sizeof(uint8_t) * SRSRAN_SCI_MAX_LEN); + srsran_bit_unpack(q->priority, &output, 3); + srsran_bit_unpack(q->resource_reserv, &output, 4); + srsran_bit_unpack(q->riv, &output, (uint32_t)ceil(log2(((q->num_sub_channel) * (q->num_sub_channel + 1) / 2)))); + srsran_bit_unpack(q->time_gap, &output, 4); + srsran_bit_unpack(q->mcs_idx, &output, 5); + srsran_bit_unpack(q->retransmission, &output, 1); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_sci_format0_unpack(srslte_sci_t* q, uint8_t* input) +int srsran_sci_format0_unpack(srsran_sci_t* q, uint8_t* input) { if (!q) { printf("Error unpacking SCI Format 0\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Sanity check: avoid SCIs with all 0s @@ -101,34 +101,34 @@ int srslte_sci_format0_unpack(srslte_sci_t* q, uint8_t* input) } } if (i == q->sci_len) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - q->freq_hopping_flag = (bool)srslte_bit_pack(&input, 1); + q->freq_hopping_flag = (bool)srsran_bit_pack(&input, 1); if (q->freq_hopping_flag) { printf("Frequency Hopping in Sidelink is not supported\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } else { - q->riv = srslte_bit_pack(&input, (uint32_t)ceil(log2(((q->nof_prb) * (q->nof_prb + 1) / 2)))); + q->riv = srsran_bit_pack(&input, (uint32_t)ceil(log2(((q->nof_prb) * (q->nof_prb + 1) / 2)))); } - q->trp_idx = srslte_bit_pack(&input, 7); - q->mcs_idx = srslte_bit_pack(&input, 5); - q->timing_advance = srslte_bit_pack(&input, 11); - q->N_sa_id = srslte_bit_pack(&input, 8); + q->trp_idx = srsran_bit_pack(&input, 7); + q->mcs_idx = srsran_bit_pack(&input, 5); + q->timing_advance = srsran_bit_pack(&input, 11); + q->N_sa_id = srsran_bit_pack(&input, 8); // Sanity check if (q->mcs_idx >= 29) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_sci_format1_unpack(srslte_sci_t* q, uint8_t* input) +int srsran_sci_format1_unpack(srsran_sci_t* q, uint8_t* input) { if (!q) { printf("Error unpacking SCI Format 1\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Sanity check: avoid SCIs with all 0s @@ -139,42 +139,42 @@ int srslte_sci_format1_unpack(srslte_sci_t* q, uint8_t* input) } } if (i == q->sci_len) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - q->priority = srslte_bit_pack(&input, 3); - q->resource_reserv = srslte_bit_pack(&input, 4); - q->riv = srslte_bit_pack(&input, (uint32_t)ceil(log2(((q->num_sub_channel) * (q->num_sub_channel + 1) / 2)))); - q->time_gap = srslte_bit_pack(&input, 4); - q->mcs_idx = srslte_bit_pack(&input, 5); - q->retransmission = srslte_bit_pack(&input, 1); - q->transmission_format = srslte_bit_pack(&input, 1); + q->priority = srsran_bit_pack(&input, 3); + q->resource_reserv = srsran_bit_pack(&input, 4); + q->riv = srsran_bit_pack(&input, (uint32_t)ceil(log2(((q->num_sub_channel) * (q->num_sub_channel + 1) / 2)))); + q->time_gap = srsran_bit_pack(&input, 4); + q->mcs_idx = srsran_bit_pack(&input, 5); + q->retransmission = srsran_bit_pack(&input, 1); + q->transmission_format = srsran_bit_pack(&input, 1); // Sanity check if (q->mcs_idx >= 29) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -void srslte_sci_info(const srslte_sci_t* q, char* str, uint32_t len) +void srsran_sci_info(const srsran_sci_t* q, char* str, uint32_t len) { uint32_t n = 0; - n = srslte_print_check(str, len, n, "SCI%i: riv=%i, mcs=%i", q->format, q->riv, q->mcs_idx); + n = srsran_print_check(str, len, n, "SCI%i: riv=%i, mcs=%i", q->format, q->riv, q->mcs_idx); - if (q->format == SRSLTE_SCI_FORMAT0) { - n = srslte_print_check(str, - SRSLTE_SCI_MSG_MAX_LEN, + if (q->format == SRSRAN_SCI_FORMAT0) { + n = srsran_print_check(str, + SRSRAN_SCI_MSG_MAX_LEN, n, ", trp_idx=%i, t_adv=%i, n_sa_id=%i, freqhoppflg=%s", q->trp_idx, q->timing_advance, q->N_sa_id, q->freq_hopping_flag ? "true" : "false"); - } else if (q->format == SRSLTE_SCI_FORMAT1) { - n = srslte_print_check(str, - SRSLTE_SCI_MSG_MAX_LEN, + } else if (q->format == SRSRAN_SCI_FORMAT1) { + n = srsran_print_check(str, + SRSRAN_SCI_MSG_MAX_LEN, n, ", priority=%i, res_rsrv=%i, t_gap=%i, rtx=%i, txformat=%d", q->priority, @@ -185,9 +185,9 @@ void srslte_sci_info(const srslte_sci_t* q, char* str, uint32_t len) } } -void srslte_sci_free(srslte_sci_t* q) +void srsran_sci_free(srsran_sci_t* q) { if (q != NULL) { - bzero(q, sizeof(srslte_sci_t)); + bzero(q, sizeof(srsran_sci_t)); } } diff --git a/lib/src/phy/phch/sequences.c b/lib/src/phy/phch/sequences.c index dd73dc8b1..44c25ef8a 100644 --- a/lib/src/phy/phch/sequences.c +++ b/lib/src/phy/phch/sequences.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,41 +10,41 @@ * */ -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/common/sequence.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/common/sequence.h" +#include "srsran/phy/utils/vector.h" #include /** * 36.211 6.6.1 */ -int srslte_sequence_pbch(srslte_sequence_t* seq, srslte_cp_t cp, uint32_t cell_id) +int srsran_sequence_pbch(srsran_sequence_t* seq, srsran_cp_t cp, uint32_t cell_id) { - return srslte_sequence_LTE_pr(seq, SRSLTE_CP_ISNORM(cp) ? 1920 : 1728, cell_id); + return srsran_sequence_LTE_pr(seq, SRSRAN_CP_ISNORM(cp) ? 1920 : 1728, cell_id); } /** * 36.211 6.7.1 */ -int srslte_sequence_pcfich(srslte_sequence_t* seq, uint32_t nslot, uint32_t cell_id) +int srsran_sequence_pcfich(srsran_sequence_t* seq, uint32_t nslot, uint32_t cell_id) { - return srslte_sequence_LTE_pr(seq, 32, (nslot / 2 + 1) * (2 * cell_id + 1) * 512 + cell_id); + return srsran_sequence_LTE_pr(seq, 32, (nslot / 2 + 1) * (2 * cell_id + 1) * 512 + cell_id); } /** * 36.211 6.9.1 */ -int srslte_sequence_phich(srslte_sequence_t* seq, uint32_t nslot, uint32_t cell_id) +int srsran_sequence_phich(srsran_sequence_t* seq, uint32_t nslot, uint32_t cell_id) { - return srslte_sequence_LTE_pr(seq, 12, (nslot / 2 + 1) * (2 * cell_id + 1) * 512 + cell_id); + return srsran_sequence_LTE_pr(seq, 12, (nslot / 2 + 1) * (2 * cell_id + 1) * 512 + cell_id); } /** * 36.211 6.8.2 */ -int srslte_sequence_pdcch(srslte_sequence_t* seq, uint32_t nslot, uint32_t cell_id, uint32_t len) +int srsran_sequence_pdcch(srsran_sequence_t* seq, uint32_t nslot, uint32_t cell_id, uint32_t len) { - return srslte_sequence_LTE_pr(seq, len, (nslot / 2) * 512 + cell_id); + return srsran_sequence_LTE_pr(seq, len, (nslot / 2) * 512 + cell_id); } /** @@ -55,12 +55,12 @@ static inline uint32_t sequence_pdsch_seed(uint16_t rnti, int q, uint32_t nslot, return (rnti << 14) + (q << 13) + ((nslot / 2) << 9) + cell_id; } -int srslte_sequence_pdsch(srslte_sequence_t* seq, uint16_t rnti, int q, uint32_t nslot, uint32_t cell_id, uint32_t len) +int srsran_sequence_pdsch(srsran_sequence_t* seq, uint16_t rnti, int q, uint32_t nslot, uint32_t cell_id, uint32_t len) { - return srslte_sequence_LTE_pr(seq, len, sequence_pdsch_seed(rnti, q, nslot, cell_id)); + return srsran_sequence_LTE_pr(seq, len, sequence_pdsch_seed(rnti, q, nslot, cell_id)); } -void srslte_sequence_pdsch_apply_pack(const uint8_t* in, +void srsran_sequence_pdsch_apply_pack(const uint8_t* in, uint8_t* out, uint16_t rnti, int q, @@ -68,10 +68,10 @@ void srslte_sequence_pdsch_apply_pack(const uint8_t* in, uint32_t cell_id, uint32_t len) { - srslte_sequence_apply_packed(in, out, len, sequence_pdsch_seed(rnti, q, nslot, cell_id)); + srsran_sequence_apply_packed(in, out, len, sequence_pdsch_seed(rnti, q, nslot, cell_id)); } -void srslte_sequence_pdsch_apply_f(const float* in, +void srsran_sequence_pdsch_apply_f(const float* in, float* out, uint16_t rnti, int q, @@ -79,10 +79,10 @@ void srslte_sequence_pdsch_apply_f(const float* in, uint32_t cell_id, uint32_t len) { - srslte_sequence_apply_f(in, out, len, sequence_pdsch_seed(rnti, q, nslot, cell_id)); + srsran_sequence_apply_f(in, out, len, sequence_pdsch_seed(rnti, q, nslot, cell_id)); } -void srslte_sequence_pdsch_apply_s(const int16_t* in, +void srsran_sequence_pdsch_apply_s(const int16_t* in, int16_t* out, uint16_t rnti, int q, @@ -90,10 +90,10 @@ void srslte_sequence_pdsch_apply_s(const int16_t* in, uint32_t cell_id, uint32_t len) { - srslte_sequence_apply_s(in, out, len, sequence_pdsch_seed(rnti, q, nslot, cell_id)); + srsran_sequence_apply_s(in, out, len, sequence_pdsch_seed(rnti, q, nslot, cell_id)); } -void srslte_sequence_pdsch_apply_c(const int8_t* in, +void srsran_sequence_pdsch_apply_c(const int8_t* in, int8_t* out, uint16_t rnti, int q, @@ -101,7 +101,7 @@ void srslte_sequence_pdsch_apply_c(const int8_t* in, uint32_t cell_id, uint32_t len) { - srslte_sequence_apply_c(in, out, len, sequence_pdsch_seed(rnti, q, nslot, cell_id)); + srsran_sequence_apply_c(in, out, len, sequence_pdsch_seed(rnti, q, nslot, cell_id)); } /** @@ -112,79 +112,79 @@ static inline uint32_t sequence_pusch_seed(uint16_t rnti, uint32_t nslot, uint32 return (rnti << 14) + ((nslot / 2) << 9) + cell_id; } -int srslte_sequence_pusch(srslte_sequence_t* seq, uint16_t rnti, uint32_t nslot, uint32_t cell_id, uint32_t len) +int srsran_sequence_pusch(srsran_sequence_t* seq, uint16_t rnti, uint32_t nslot, uint32_t cell_id, uint32_t len) { - return srslte_sequence_LTE_pr(seq, len, sequence_pusch_seed(rnti, nslot, cell_id)); + return srsran_sequence_LTE_pr(seq, len, sequence_pusch_seed(rnti, nslot, cell_id)); } -void srslte_sequence_pusch_apply_pack(const uint8_t* in, +void srsran_sequence_pusch_apply_pack(const uint8_t* in, uint8_t* out, uint16_t rnti, uint32_t nslot, uint32_t cell_id, uint32_t len) { - srslte_sequence_apply_packed(in, out, len, sequence_pusch_seed(rnti, nslot, cell_id)); + srsran_sequence_apply_packed(in, out, len, sequence_pusch_seed(rnti, nslot, cell_id)); } -void srslte_sequence_pusch_apply_s(const int16_t* in, +void srsran_sequence_pusch_apply_s(const int16_t* in, int16_t* out, uint16_t rnti, uint32_t nslot, uint32_t cell_id, uint32_t len) { - srslte_sequence_apply_s(in, out, len, sequence_pusch_seed(rnti, nslot, cell_id)); + srsran_sequence_apply_s(in, out, len, sequence_pusch_seed(rnti, nslot, cell_id)); } -void srslte_sequence_pusch_gen_unpack(uint8_t* out, uint16_t rnti, uint32_t nslot, uint32_t cell_id, uint32_t len) +void srsran_sequence_pusch_gen_unpack(uint8_t* out, uint16_t rnti, uint32_t nslot, uint32_t cell_id, uint32_t len) { - srslte_vec_u8_zero(out, len); + srsran_vec_u8_zero(out, len); - srslte_sequence_apply_bit(out, out, len, sequence_pusch_seed(rnti, nslot, cell_id)); + srsran_sequence_apply_bit(out, out, len, sequence_pusch_seed(rnti, nslot, cell_id)); } -void srslte_sequence_pusch_apply_c(const int8_t* in, +void srsran_sequence_pusch_apply_c(const int8_t* in, int8_t* out, uint16_t rnti, uint32_t nslot, uint32_t cell_id, uint32_t len) { - srslte_sequence_apply_c(in, out, len, sequence_pusch_seed(rnti, nslot, cell_id)); + srsran_sequence_apply_c(in, out, len, sequence_pusch_seed(rnti, nslot, cell_id)); } /** * 36.211 5.4.2 */ -int srslte_sequence_pucch(srslte_sequence_t* seq, uint16_t rnti, uint32_t nslot, uint32_t cell_id) +int srsran_sequence_pucch(srsran_sequence_t* seq, uint16_t rnti, uint32_t nslot, uint32_t cell_id) { - return srslte_sequence_LTE_pr(seq, 12 * 4, ((((nslot / 2) + 1) * (2 * cell_id + 1)) << 16) + rnti); + return srsran_sequence_LTE_pr(seq, 12 * 4, ((((nslot / 2) + 1) * (2 * cell_id + 1)) << 16) + rnti); } -int srslte_sequence_pmch(srslte_sequence_t* seq, uint32_t nslot, uint32_t mbsfn_id, uint32_t len) +int srsran_sequence_pmch(srsran_sequence_t* seq, uint32_t nslot, uint32_t mbsfn_id, uint32_t len) { - bzero(seq, sizeof(srslte_sequence_t)); - return srslte_sequence_LTE_pr(seq, len, (((nslot / 2) << 9) + mbsfn_id)); + bzero(seq, sizeof(srsran_sequence_t)); + return srsran_sequence_LTE_pr(seq, len, (((nslot / 2) << 9) + mbsfn_id)); } /** * 36.211 6.6.1 and 10.2.4.1 (13.2.0) */ -int srslte_sequence_npbch(srslte_sequence_t* seq, srslte_cp_t cp, uint32_t cell_id) +int srsran_sequence_npbch(srsran_sequence_t* seq, srsran_cp_t cp, uint32_t cell_id) { - bzero(seq, sizeof(srslte_sequence_t)); - return srslte_sequence_LTE_pr(seq, SRSLTE_NBIOT_NPBCH_NOF_TOTAL_BITS, cell_id); + bzero(seq, sizeof(srsran_sequence_t)); + return srsran_sequence_LTE_pr(seq, SRSRAN_NBIOT_NPBCH_NOF_TOTAL_BITS, cell_id); } /** * 36.211 6.6.1 and 10.2.4.4 (14.2.0) */ -int srslte_sequence_npbch_r14(srslte_sequence_t* seq, uint32_t n_id_ncell, uint32_t nf) +int srsran_sequence_npbch_r14(srsran_sequence_t* seq, uint32_t n_id_ncell, uint32_t nf) { - bzero(seq, sizeof(srslte_sequence_t)); - return srslte_sequence_LTE_pr(seq, - SRSLTE_NBIOT_NPBCH_NOF_BITS_SF, + bzero(seq, sizeof(srsran_sequence_t)); + return srsran_sequence_LTE_pr(seq, + SRSRAN_NBIOT_NPBCH_NOF_BITS_SF, (n_id_ncell + 1) * (((nf % 8) + 1) * ((nf % 8) + 1) * ((nf % 8) + 1)) * 512 + n_id_ncell); } @@ -192,7 +192,7 @@ int srslte_sequence_npbch_r14(srslte_sequence_t* seq, uint32_t n_id_ncell, uint3 /** * 36.211 6.3.1 and 10.2.3.1 (13.2.0) */ -int srslte_sequence_npdsch(srslte_sequence_t* seq, +int srsran_sequence_npdsch(srsran_sequence_t* seq, uint16_t rnti, int q, uint32_t nf, @@ -200,47 +200,47 @@ int srslte_sequence_npdsch(srslte_sequence_t* seq, uint32_t cell_id, uint32_t len) { - bzero(seq, sizeof(srslte_sequence_t)); - return srslte_sequence_LTE_pr(seq, len, (rnti << 14) + ((nf % 2) << 13) + ((nslot / 2) << 9) + cell_id); + bzero(seq, sizeof(srsran_sequence_t)); + return srsran_sequence_LTE_pr(seq, len, (rnti << 14) + ((nf % 2) << 13) + ((nslot / 2) << 9) + cell_id); } /** * 36.211 6.3.1 and 10.2.3.1 (14.2.0) */ -int srslte_sequence_npdsch_bcch_r14(srslte_sequence_t* seq, uint32_t nf, uint32_t n_id_ncell, uint32_t len) +int srsran_sequence_npdsch_bcch_r14(srsran_sequence_t* seq, uint32_t nf, uint32_t n_id_ncell, uint32_t len) { - bzero(seq, sizeof(srslte_sequence_t)); - return srslte_sequence_LTE_pr(seq, len, (0xffff << 15) + (n_id_ncell + 1) * ((nf % 61) + 1)); + bzero(seq, sizeof(srsran_sequence_t)); + return srsran_sequence_LTE_pr(seq, len, (0xffff << 15) + (n_id_ncell + 1) * ((nf % 61) + 1)); } /** * 36.211 6.6.1 and 10.2.5.2 (13.2.0) */ -int srslte_sequence_npdcch(srslte_sequence_t* seq, uint32_t nslot, uint32_t cell_id, uint32_t len) +int srsran_sequence_npdcch(srsran_sequence_t* seq, uint32_t nslot, uint32_t cell_id, uint32_t len) { - bzero(seq, sizeof(srslte_sequence_t)); - return srslte_sequence_LTE_pr(seq, len, (nslot / 2) * 512 + cell_id); + bzero(seq, sizeof(srsran_sequence_t)); + return srsran_sequence_LTE_pr(seq, len, (nslot / 2) * 512 + cell_id); } /** * 36.211 5.3.1 and 10.1.3.1 (13.2.0) */ -int srslte_sequence_npusch(srslte_sequence_t* seq, +int srsran_sequence_npusch(srsran_sequence_t* seq, uint16_t rnti, uint32_t nf, uint32_t nslot, uint32_t cell_id, uint32_t len) { - bzero(seq, sizeof(srslte_sequence_t)); - return srslte_sequence_LTE_pr(seq, len, (rnti << 14) + ((nf % 2) << 13) + ((nslot / 2) << 9) + cell_id); + bzero(seq, sizeof(srsran_sequence_t)); + return srsran_sequence_LTE_pr(seq, len, (rnti << 14) + ((nf % 2) << 13) + ((nslot / 2) << 9) + cell_id); } /** * 36.211 7.2.0 and 10.1.6.1 (13.2.0) */ -int srslte_sequence_nprach(srslte_sequence_t* seq, uint32_t cell_id) +int srsran_sequence_nprach(srsran_sequence_t* seq, uint32_t cell_id) { - bzero(seq, sizeof(srslte_sequence_t)); - return srslte_sequence_LTE_pr(seq, 1600, cell_id); + bzero(seq, sizeof(srsran_sequence_t)); + return srsran_sequence_LTE_pr(seq, 1600, cell_id); } \ No newline at end of file diff --git a/lib/src/phy/phch/tbs_tables.h b/lib/src/phy/phch/tbs_tables.h index ab520d74a..ecc02ef57 100644 --- a/lib/src/phy/phch/tbs_tables.h +++ b/lib/src/phy/phch/tbs_tables.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,8 +10,8 @@ * */ -#ifndef SRSLTE_TBS_TABLES_H_ -#define SRSLTE_TBS_TABLES_H_ +#ifndef SRSRAN_TBS_TABLES_H_ +#define SRSRAN_TBS_TABLES_H_ /* Modulation and TBS index table for PDSCH from 3GPP TS 36.213 v10.3.0 table 7.1.7.1-1 */ static const int dl_mcs_tbs_idx_table[29] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 10, 11, 12, 13, @@ -26,7 +26,7 @@ static const int ul_mcs_tbs_idx_table[29] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 23, 24, 25, 26}; /* Transport Block Size from 3GPP TS 36.213 v12.13.0 table 7.1.7.2.1-1 */ -static const int tbs_table[SRSLTE_RA_NOF_TBS_IDX][110] = { +static const int tbs_table[SRSRAN_RA_NOF_TBS_IDX][110] = { /* The matrix below is automatically generated from ETSI TS 136 213 V12.13.0 (2019-03) */ {16, 32, 56, 88, 120, 152, 176, 208, 224, 256, 288, 328, 344, 376, 392, 424, 456, 488, 504, 536, 568, 600, 616, 648, 680, 712, 744, 776, 776, 808, 840, 872, 904, 936, 968, 1000, 1032, 1032, @@ -261,4 +261,4 @@ static const int tbs_table[SRSLTE_RA_NOF_TBS_IDX][110] = { 81176, 81176, 81176, 81176, 84760, 84760, 84760, 87936, 87936, 87936, 90816, 90816, 90816, 93800, 93800, 93800, 93800, 97896, 97896, 97896, 97896, 97896, 97896, 97896, 97896, 97896, 97896, 97896, 97896, 97896}}; -#endif /* SRSLTE_TBS_TABLES_H_ */ +#endif /* SRSRAN_TBS_TABLES_H_ */ diff --git a/lib/src/phy/phch/tbs_tables_nbiot.h b/lib/src/phy/phch/tbs_tables_nbiot.h index cab2041f3..b715ee49b 100644 --- a/lib/src/phy/phch/tbs_tables_nbiot.h +++ b/lib/src/phy/phch/tbs_tables_nbiot.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,8 +10,8 @@ * */ -#ifndef SRSLTE_TBS_TABLES_NBIOT_H -#define SRSLTE_TBS_TABLES_NBIOT_H +#ifndef SRSRAN_TBS_TABLES_NBIOT_H +#define SRSRAN_TBS_TABLES_NBIOT_H // Transport Block Size from 3GPP TS 36.213 v13.2.0 table 16.4.1.5.1-1 const int tbs_table_nbiot[13][8] = {{16, 32, 56, 88, 120, 152, 208, 256}, @@ -48,4 +48,4 @@ const int tbs_table_npusch[13][8] = {{16, 32, 56, 88, 120, 152, 208, 256}, {176, 376, 584, 776, 1000, 0, 0, 0}, {208, 440, 680, 1000, 0, 0, 0, 0}}; -#endif // SRSLTE_TBS_TABLES_NBIOT_H \ No newline at end of file +#endif // SRSRAN_TBS_TABLES_NBIOT_H \ No newline at end of file diff --git a/lib/src/phy/phch/test/CMakeLists.txt b/lib/src/phy/phch/test/CMakeLists.txt index 39dd38552..84d7636df 100644 --- a/lib/src/phy/phch/test/CMakeLists.txt +++ b/lib/src/phy/phch/test/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -13,7 +13,7 @@ set(CTEST_LABELS "lib;phy;phch") ######################################################################## add_executable(pbch_test pbch_test.c) -target_link_libraries(pbch_test srslte_phy) +target_link_libraries(pbch_test srsran_phy) add_lte_test(pbch_test_6 pbch_test -p 1 -n 6 -c 100) add_lte_test(pbch_test_62 pbch_test -p 2 -n 6 -c 100) @@ -27,7 +27,7 @@ add_lte_test(pbch_test_504 pbch_test -p 4 -n 50 -c 50) ######################################################################## add_executable(psbch_test psbch_test.c) -target_link_libraries(psbch_test srslte_phy) +target_link_libraries(psbch_test srsran_phy) # TM2 self tests add_lte_test(psbch_test_self_test_tm2_p6_c168_self psbch_test -p 6 -c 168 -t 2) @@ -42,7 +42,7 @@ add_lte_test(psbch_test_self_test_tm4_p50_c168_self psbch_test -p 50 -c 252 -t 4 add_lte_test(psbch_test_self_test_tm4_p100_c168_self psbch_test -p 100 -c 335 -t 4) add_executable(psbch_file_test psbch_file_test.c) -target_link_libraries(psbch_file_test srslte_phy) +target_link_libraries(psbch_file_test srsran_phy) # TM2 file tests add_lte_test(psbch_file_test_ideal_tm2_p6_c0 psbch_file_test -p 6 -c 0 -d -i ${CMAKE_HOME_DIRECTORY}/lib/src/phy/phch/test/signal_sidelink_ideal_tm2_p6_c0_s1.92e6.dat) @@ -60,7 +60,7 @@ add_lte_test(psbch_file_test_cmw_tm4_p50_c169 psbch_file_test -p 50 -c 169 -t 4 ######################################################################## add_executable(pscch_test pscch_test.c) -target_link_libraries(pscch_test srslte_phy) +target_link_libraries(pscch_test srsran_phy) # TM2 self tests add_lte_test(pscch_test_tm2_p6 pscch_test -p 6) @@ -83,7 +83,7 @@ add_lte_test(pscch_test_tm4_p100 pscch_test -p 100 -t 4) ######################################################################## add_executable(pssch_test pssch_test.c) -target_link_libraries(pssch_test srslte_phy) +target_link_libraries(pssch_test srsran_phy) # TM2 self tests add_lte_test(pssch_test_tm2_p6 pssch_test -p 6 -m 2) @@ -108,7 +108,7 @@ add_lte_test(pssch_test_tm4_p100 pssch_test -p 100 -t 4 -m 21) ######################################################################## add_executable(pssch_pscch_file_test pssch_pscch_file_test.c) -target_link_libraries(pssch_pscch_file_test srslte_phy) +target_link_libraries(pssch_pscch_file_test srsran_phy) # TM2 file tests add_lte_test(pssch_pscch_file_test_ideal_tm2_p100 pssch_pscch_file_test -p 100 -d -i ${CMAKE_HOME_DIRECTORY}/lib/src/phy/phch/test/signal_sidelink_ideal_tm2_p100_c335_s30.72e6.dat) @@ -150,7 +150,7 @@ set_property(TEST pssch_pscch_test_tm4_p50_uxm4 PROPERTY PASS_REGULAR_EXPRESSION ######################################################################## add_executable(npbch_test npbch_test.c) -target_link_libraries(npbch_test srslte_phy) +target_link_libraries(npbch_test srsran_phy) add_lte_test(npbch_test npbch_test) add_lte_test(npbch_file_test_r13 npbch_file_test -i ${CMAKE_CURRENT_SOURCE_DIR}/signal_nbiot_amari_nid0_sfn514_sib2.bin) @@ -163,7 +163,7 @@ add_lte_test(npbch_file_test_nid257_r14 npbch_file_test -l 257 -R -r 7 -i ${CMAK ######################################################################## add_executable(pcfich_test pcfich_test.c) -target_link_libraries(pcfich_test srslte_phy) +target_link_libraries(pcfich_test srsran_phy) add_lte_test(pcfich_test_6 pcfich_test -p 1 -n 6) add_lte_test(pcfich_test_62 pcfich_test -p 2 -n 6) @@ -177,7 +177,7 @@ add_lte_test(pcfich_test_104 pcfich_test -p 4 -n 10) ######################################################################## add_executable(phich_test phich_test.c) -target_link_libraries(phich_test srslte_phy) +target_link_libraries(phich_test srsran_phy) add_lte_test(phich_test_6 phich_test -p 1 -n 6) add_lte_test(phich_test_62 phich_test -p 2 -n 6) @@ -196,7 +196,7 @@ add_lte_test(phich_test_104 phich_test -p 4 -n 10 -e -l -g 1/2) ######################################################################## add_executable(pdcch_test pdcch_test.c) -target_link_libraries(pdcch_test srslte_phy) +target_link_libraries(pdcch_test srsran_phy) add_lte_test(pdcch_test_6 pdcch_test -n 6) add_lte_test(pdcch_test_15 pdcch_test -n 15) @@ -217,7 +217,7 @@ add_lte_test(pdcch_test_100_mimo pdcch_test -n 100 -p 2) ######################################################################## add_executable(pdsch_test pdsch_test.c) -target_link_libraries(pdsch_test srslte_phy) +target_link_libraries(pdsch_test srsran_phy) add_lte_test(pdsch_test_qpsk pdsch_test -m 10 -n 50 -r 1) add_lte_test(pdsch_test_qam16 pdsch_test -m 20 -n 100) @@ -325,7 +325,7 @@ add_lte_test(pdsch_test_multiplex2cw_p1_100 pdsch_test -x 4 -a 2 -t 0 -p 1 -n 10 ######################################################################## add_executable(pmch_test pmch_test.c) -target_link_libraries(pmch_test srslte_phy) +target_link_libraries(pmch_test srsran_phy) add_lte_test(pmch_test_qpsk pmch_test -m 6 -n 50) add_lte_test(pmch_test_qam16 pmch_test -m 15 -n 100) @@ -337,7 +337,7 @@ add_lte_test(pmch_test_qam64 pmch_test -m 25 -n 100) ######################################################################## add_executable(npdsch_test npdsch_test.c) -target_link_libraries(npdsch_test srslte_phy) +target_link_libraries(npdsch_test srsran_phy) add_lte_test(npdsch_test_tbs208 npdsch_test -m 12) add_lte_test(npdsch_test_tbs104 npdsch_test -m 7) @@ -390,7 +390,7 @@ add_lte_test(npdsch_test_cellid5_inband_diffpci_2port_2port npdsch_test -l 5 -M ######################################################################## add_executable(dci_nbiot_test dci_nbiot_test.c) -target_link_libraries(dci_nbiot_test srslte_phy) +target_link_libraries(dci_nbiot_test srsran_phy) add_lte_test(dci_nbiot_test dci_nbiot_test) ######################################################################## @@ -398,30 +398,30 @@ add_lte_test(dci_nbiot_test dci_nbiot_test) ######################################################################## add_executable(pbch_file_test pbch_file_test.c) -target_link_libraries(pbch_file_test srslte_phy) +target_link_libraries(pbch_file_test srsran_phy) add_executable(pcfich_file_test pcfich_file_test.c) -target_link_libraries(pcfich_file_test srslte_phy) +target_link_libraries(pcfich_file_test srsran_phy) add_executable(phich_file_test phich_file_test.c) -target_link_libraries(phich_file_test srslte_phy) +target_link_libraries(phich_file_test srsran_phy) add_executable(pdcch_file_test pdcch_file_test.c) -target_link_libraries(pdcch_file_test srslte_phy) +target_link_libraries(pdcch_file_test srsran_phy) add_executable(pdsch_pdcch_file_test pdsch_pdcch_file_test.c) -target_link_libraries(pdsch_pdcch_file_test srslte_phy) +target_link_libraries(pdsch_pdcch_file_test srsran_phy) add_executable(npbch_file_test npbch_file_test.c) -target_link_libraries(npbch_file_test srslte_phy) +target_link_libraries(npbch_file_test srsran_phy) add_executable(npdsch_npdcch_file_test npdsch_npdcch_file_test.c) -target_link_libraries(npdsch_npdcch_file_test srslte_phy) +target_link_libraries(npdsch_npdcch_file_test srsran_phy) add_lte_test(pbch_file_test pbch_file_test -i ${CMAKE_CURRENT_SOURCE_DIR}/signal.1.92M.dat) add_executable(pmch_file_test pmch_file_test.c) -target_link_libraries(pmch_file_test srslte_phy) +target_link_libraries(pmch_file_test srsran_phy) add_lte_test(pbch_file_test pbch_file_test -i ${CMAKE_CURRENT_SOURCE_DIR}/signal.1.92M.dat) add_lte_test(pcfich_file_test pcfich_file_test -c 150 -n 50 -p 2 -i ${CMAKE_CURRENT_SOURCE_DIR}/signal.10M.dat) @@ -435,11 +435,11 @@ add_lte_test(pmch_file_test pmch_file_test -i ${CMAKE_CURRENT_SOURCE_DIR}/pmch_ ######################################################################## add_executable(npdcch_test npdcch_test.c) -target_link_libraries(npdcch_test srslte_phy) +target_link_libraries(npdcch_test srsran_phy) add_lte_test(npdcch_formatN1_test npdcch_test -o FormatN1) add_executable(npdcch_file_test npdcch_file_test.c) -target_link_libraries(npdcch_file_test srslte_phy) +target_link_libraries(npdcch_file_test srsran_phy) add_lte_test(npdcch_formatN0_file_test npdcch_file_test -c 0 -t 8624 -r 258 -L 1 -l 0 -v -o FormatN0 -i ${CMAKE_CURRENT_SOURCE_DIR}/signal_nbiot_dci_formatN0_L_1_nid0_tti_8624_rnti_0x102.bin) add_lte_test(npdcch_formatN1_file_test npdcch_file_test -c 0 -t 5461 -r 137 -L 2 -l 0 -v -o FormatN1 -i ${CMAKE_CURRENT_SOURCE_DIR}/signal_nbiot_dci_formatN1_nid0_tti_5461_rnti_0x89.bin) @@ -451,7 +451,7 @@ add_lte_test(npdsch_npdcch_dci_formatN1_test npdsch_npdcch_file_test -c 0 -s 1 - ######################################################################## add_executable(pusch_test pusch_test.c) -target_link_libraries(pusch_test srslte_phy) +target_link_libraries(pusch_test srsran_phy) if (NOT DEFINED TEST_EXTENSION) set(TEST_EXTENSION Normal) @@ -533,7 +533,7 @@ endforeach (cell_n_prb) ######################################################################## add_executable(pucch_test pucch_test.c) -target_link_libraries(pucch_test srslte_phy) +target_link_libraries(pucch_test srsran_phy) add_lte_test(pucch_test pucch_test) add_lte_test(pucch_test_uci_cqi_decoder pucch_test -q) @@ -543,7 +543,7 @@ add_lte_test(pucch_test_uci_cqi_decoder pucch_test -q) ######################################################################## add_executable(prach_test prach_test.c) -target_link_libraries(prach_test srslte_phy) +target_link_libraries(prach_test srsran_phy) add_lte_test(prach prach_test) @@ -567,7 +567,7 @@ add_lte_test(prach_zc2 prach_test -z 2) add_lte_test(prach_zc3 prach_test -z 3) add_executable(prach_test_multi prach_test_multi.c) -target_link_libraries(prach_test_multi srslte_phy) +target_link_libraries(prach_test_multi srsran_phy) add_lte_test(prach_test_multi prach_test_multi) @@ -609,7 +609,7 @@ add_lte_test(prach_test_multi_freq_offset_test_n4_o800_prb50 prach_test_multi -n if(RF_FOUND) add_executable(prach_test_usrp prach_test_usrp.c) - target_link_libraries(prach_test_usrp srslte_rf srslte_phy pthread) + target_link_libraries(prach_test_usrp srsran_rf srsran_phy pthread) endif(RF_FOUND) ######################################################################## @@ -617,19 +617,19 @@ endif(RF_FOUND) ######################################################################## add_executable(pucch_nr_test pucch_nr_test.c) -target_link_libraries(pucch_nr_test srslte_phy) +target_link_libraries(pucch_nr_test srsran_phy) add_nr_test(pucch_nr_test pucch_nr_test) add_executable(sch_nr_test sch_nr_test.c) -target_link_libraries(sch_nr_test srslte_phy) +target_link_libraries(sch_nr_test srsran_phy) add_nr_test(sch_nr_test sch_nr_test -m 0 -p 1) add_executable(pdsch_nr_test pdsch_nr_test.c) -target_link_libraries(pdsch_nr_test srslte_phy) +target_link_libraries(pdsch_nr_test srsran_phy) add_nr_test(pdsch_nr_test pdsch_nr_test -p 6 -m 20) add_executable(pusch_nr_test pusch_nr_test.c) -target_link_libraries(pusch_nr_test srslte_phy) +target_link_libraries(pusch_nr_test srsran_phy) add_nr_test(pusch_nr_test pusch_nr_test -p 6 -m 20) add_nr_test(pusch_nr_ack1_test pusch_nr_test -p 50 -m 20 -A 1) add_nr_test(pusch_nr_ack2_test pusch_nr_test -p 50 -m 20 -A 2) @@ -644,5 +644,5 @@ add_nr_test(pusch_nr_ack20_csi4_test pusch_nr_test -p 50 -m 20 -A 20 -C 4) add_executable(pdcch_nr_test pdcch_nr_test.c) -target_link_libraries(pdcch_nr_test srslte_phy) +target_link_libraries(pdcch_nr_test srsran_phy) add_nr_test(pdcch_nr_test pdcch_nr_test) diff --git a/lib/src/phy/phch/test/dci_nbiot_test.c b/lib/src/phy/phch/test/dci_nbiot_test.c index 64a5c102e..f41f653d0 100644 --- a/lib/src/phy/phch/test/dci_nbiot_test.c +++ b/lib/src/phy/phch/test/dci_nbiot_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -15,13 +15,13 @@ #include #include -#include "srslte/phy/ue/ue_dl_nbiot.h" -#include "srslte/phy/utils/bit.h" +#include "srsran/phy/ue/ue_dl_nbiot.h" +#include "srsran/phy/utils/bit.h" void usage(char* prog) { printf("Usage: %s [cpndv]\n", prog); - printf("\t-v [set srslte_verbose to debug, default none]\n"); + printf("\t-v [set srsran_verbose to debug, default none]\n"); } void parse_args(int argc, char** argv) @@ -30,7 +30,7 @@ void parse_args(int argc, char** argv) while ((opt = getopt(argc, argv, "cpndv")) != -1) { switch (opt) { case 'v': - srslte_verbose++; + srsran_verbose++; break; default: usage(argv[0]); @@ -44,57 +44,57 @@ void parse_args(int argc, char** argv) // to the next valid DL subframe. int dl_timing_test() { - srslte_nbiot_cell_t cell = {.base = {.nof_prb = 1, .nof_ports = 1, .cp = SRSLTE_CP_NORM, .id = 0}, + srsran_nbiot_cell_t cell = {.base = {.nof_prb = 1, .nof_ports = 1, .cp = SRSRAN_CP_NORM, .id = 0}, .nbiot_prb = 0, .n_id_ncell = 0, .nof_ports = 1, - .mode = SRSLTE_NBIOT_MODE_STANDALONE}; + .mode = SRSRAN_NBIOT_MODE_STANDALONE}; - cf_t rx_buff[SRSLTE_SF_LEN_PRB_NBIOT]; - cf_t* buff_ptrs[SRSLTE_MAX_PORTS] = {rx_buff, NULL, NULL, NULL}; - srslte_nbiot_ue_dl_t ue_dl = {}; - if (srslte_nbiot_ue_dl_init(&ue_dl, buff_ptrs, SRSLTE_NBIOT_MAX_PRB, SRSLTE_NBIOT_NUM_RX_ANTENNAS)) { + cf_t rx_buff[SRSRAN_SF_LEN_PRB_NBIOT]; + cf_t* buff_ptrs[SRSRAN_MAX_PORTS] = {rx_buff, NULL, NULL, NULL}; + srsran_nbiot_ue_dl_t ue_dl = {}; + if (srsran_nbiot_ue_dl_init(&ue_dl, buff_ptrs, SRSRAN_NBIOT_MAX_PRB, SRSRAN_NBIOT_NUM_RX_ANTENNAS)) { fprintf(stderr, "Error initializing UE DL\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_nbiot_ue_dl_set_cell(&ue_dl, cell)) { + if (srsran_nbiot_ue_dl_set_cell(&ue_dl, cell)) { fprintf(stderr, "Setting cell in UE DL\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - srslte_mib_nb_t mib = {}; + srsran_mib_nb_t mib = {}; mib.sched_info_sib1 = 2; - srslte_nbiot_ue_dl_set_mib(&ue_dl, mib); + srsran_nbiot_ue_dl_set_mib(&ue_dl, mib); // a dummy grant uint8_t dci_bits_packed[] = {0x81, 0x00, 0x00}; - srslte_dci_msg_t dci_tmp = {}; - dci_tmp.format = SRSLTE_DCI_FORMATN1; + srsran_dci_msg_t dci_tmp = {}; + dci_tmp.format = SRSRAN_DCI_FORMATN1; dci_tmp.nof_bits = 23; - srslte_bit_unpack_vector(dci_bits_packed, dci_tmp.payload, dci_tmp.nof_bits); + srsran_bit_unpack_vector(dci_bits_packed, dci_tmp.payload, dci_tmp.nof_bits); // turn DCI into grant - srslte_ra_nbiot_dl_dci_t dl_dci; - srslte_ra_nbiot_dl_grant_t dl_grant; + srsran_ra_nbiot_dl_dci_t dl_dci; + srsran_ra_nbiot_dl_grant_t dl_grant; int sfn = 185; int sf_idx = 9; - srslte_nbiot_dci_msg_to_dl_grant(&dci_tmp, 0x1234, &dl_dci, &dl_grant, sfn, sf_idx, 3, SRSLTE_NBIOT_MODE_STANDALONE); + srsran_nbiot_dci_msg_to_dl_grant(&dci_tmp, 0x1234, &dl_dci, &dl_grant, sfn, sf_idx, 3, SRSRAN_NBIOT_MODE_STANDALONE); // make sure NPDSCH start is not on a SIB1 subframe - srslte_nbiot_ue_dl_check_grant(&ue_dl, &dl_grant); + srsran_nbiot_ue_dl_check_grant(&ue_dl, &dl_grant); // print final grant - srslte_ra_nbiot_dl_grant_fprint(stdout, &dl_grant); + srsran_ra_nbiot_dl_grant_fprint(stdout, &dl_grant); - srslte_nbiot_ue_dl_free(&ue_dl); + srsran_nbiot_ue_dl_free(&ue_dl); // only success if starting subframe is not a SIB1 subframe if (dl_grant.start_sfidx != 4) { - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } - return SRSLTE_ERROR; + return SRSRAN_ERROR; } int main(int argc, char** argv) @@ -103,8 +103,8 @@ int main(int argc, char** argv) if (dl_timing_test() != 0) { printf("Error running DL timing test.\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } diff --git a/lib/src/phy/phch/test/npbch_file_test.c b/lib/src/phy/phch/test/npbch_file_test.c index cb14be046..fc8a1a16d 100644 --- a/lib/src/phy/phch/test/npbch_file_test.c +++ b/lib/src/phy/phch/test/npbch_file_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -16,16 +16,16 @@ #include #include -#include "srslte/phy/ch_estimation/chest_dl_nbiot.h" -#include "srslte/phy/dft/ofdm.h" -#include "srslte/phy/io/filesource.h" -#include "srslte/phy/phch/npbch.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/ch_estimation/chest_dl_nbiot.h" +#include "srsran/phy/dft/ofdm.h" +#include "srsran/phy/io/filesource.h" +#include "srsran/phy/phch/npbch.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" char* input_file_name = NULL; -srslte_nbiot_cell_t cell = {.base = {.nof_prb = 1, .nof_ports = 2, .cp = SRSLTE_CP_NORM, .id = 0}, +srsran_nbiot_cell_t cell = {.base = {.nof_prb = 1, .nof_ports = 2, .cp = SRSRAN_CP_NORM, .id = 0}, .nbiot_prb = 0, .n_id_ncell = 0, .nof_ports = 0, @@ -36,13 +36,13 @@ bool do_chest = true; int nf = 0; int sf_idx = 0; -#define SFLEN (1 * SRSLTE_SF_LEN(srslte_symbol_sz(cell.base.nof_prb))) +#define SFLEN (1 * SRSRAN_SF_LEN(srsran_symbol_sz(cell.base.nof_prb))) -srslte_filesource_t fsrc; -cf_t * input_buffer, *fft_buffer, *ce[SRSLTE_MAX_PORTS]; -srslte_npbch_t npbch; -srslte_ofdm_t fft; -srslte_chest_dl_nbiot_t chest; +srsran_filesource_t fsrc; +cf_t * input_buffer, *fft_buffer, *ce[SRSRAN_MAX_PORTS]; +srsran_npbch_t npbch; +srsran_ofdm_t fft; +srsran_chest_dl_nbiot_t chest; void usage(char* prog) { @@ -55,7 +55,7 @@ void usage(char* prog) printf("\t-n nof_frames [Default %d]\n", nof_frames); printf("\t-R Whether this is a R14 signal [Default %s]\n", cell.is_r14 ? "Yes" : "No"); - printf("\t-v [set srslte_verbose to debug, default none]\n"); + printf("\t-v [set srsran_verbose to debug, default none]\n"); } void parse_args(int argc, char** argv) @@ -83,7 +83,7 @@ void parse_args(int argc, char** argv) sf_idx = (int)(strtol(argv[optind], NULL, 10) % 10); break; case 'v': - srslte_verbose++; + srsran_verbose++; break; case 'r': nf = (int)strtol(argv[optind], NULL, 10); @@ -106,61 +106,61 @@ int base_init() { srand(0); - if (srslte_filesource_init(&fsrc, input_file_name, SRSLTE_COMPLEX_FLOAT_BIN)) { + if (srsran_filesource_init(&fsrc, input_file_name, SRSRAN_COMPLEX_FLOAT_BIN)) { fprintf(stderr, "Error opening file %s\n", input_file_name); exit(-1); } - input_buffer = srslte_vec_cf_malloc(SFLEN); + input_buffer = srsran_vec_cf_malloc(SFLEN); if (!input_buffer) { perror("malloc"); exit(-1); } - fft_buffer = srslte_vec_cf_malloc(SRSLTE_SF_LEN(srslte_symbol_sz(cell.base.nof_prb))); + fft_buffer = srsran_vec_cf_malloc(SRSRAN_SF_LEN(srsran_symbol_sz(cell.base.nof_prb))); if (!fft_buffer) { perror("malloc"); return -1; } for (int i = 0; i < cell.base.nof_ports; i++) { - ce[i] = srslte_vec_cf_malloc(SRSLTE_SF_LEN_RE(cell.base.nof_prb, cell.base.cp)); + ce[i] = srsran_vec_cf_malloc(SRSRAN_SF_LEN_RE(cell.base.nof_prb, cell.base.cp)); if (!ce[i]) { perror("malloc"); return -1; } - for (int j = 0; j < SRSLTE_SF_LEN_RE(cell.base.nof_prb, cell.base.cp); j++) { + for (int j = 0; j < SRSRAN_SF_LEN_RE(cell.base.nof_prb, cell.base.cp); j++) { ce[i][j] = 1.0; } } - if (srslte_chest_dl_nbiot_init(&chest, SRSLTE_NBIOT_MAX_PRB)) { + if (srsran_chest_dl_nbiot_init(&chest, SRSRAN_NBIOT_MAX_PRB)) { fprintf(stderr, "Error initializing equalizer\n"); return -1; } - if (srslte_chest_dl_nbiot_set_cell(&chest, cell) != SRSLTE_SUCCESS) { + if (srsran_chest_dl_nbiot_set_cell(&chest, cell) != SRSRAN_SUCCESS) { fprintf(stderr, "Error setting equalizer cell configuration\n"); return -1; } - if (srslte_ofdm_rx_init(&fft, cell.base.cp, input_buffer, fft_buffer, cell.base.nof_prb)) { + if (srsran_ofdm_rx_init(&fft, cell.base.cp, input_buffer, fft_buffer, cell.base.nof_prb)) { fprintf(stderr, "Error initializing FFT\n"); return -1; } - srslte_ofdm_set_freq_shift(&fft, SRSLTE_NBIOT_FREQ_SHIFT_FACTOR); + srsran_ofdm_set_freq_shift(&fft, SRSRAN_NBIOT_FREQ_SHIFT_FACTOR); - if (srslte_npbch_init(&npbch)) { + if (srsran_npbch_init(&npbch)) { fprintf(stderr, "Error initiating NPBCH\n"); return -1; } - if (srslte_npbch_set_cell(&npbch, cell)) { + if (srsran_npbch_set_cell(&npbch, cell)) { fprintf(stderr, "Error setting cell in NPBCH object\n"); exit(-1); } // setting ports to 2 to make test not fail cell.nof_ports = 2; - if (!srslte_nbiot_cell_isvalid(&cell)) { + if (!srsran_nbiot_cell_isvalid(&cell)) { fprintf(stderr, "Invalid cell properties\n"); return -1; } @@ -171,25 +171,25 @@ int base_init() void base_free() { - srslte_filesource_free(&fsrc); + srsran_filesource_free(&fsrc); free(input_buffer); free(fft_buffer); - srslte_filesource_free(&fsrc); + srsran_filesource_free(&fsrc); for (int i = 0; i < cell.base.nof_ports; i++) { free(ce[i]); } - srslte_chest_dl_nbiot_free(&chest); - srslte_ofdm_rx_free(&fft); + srsran_chest_dl_nbiot_free(&chest); + srsran_ofdm_rx_free(&fft); - srslte_npbch_free(&npbch); + srsran_npbch_free(&npbch); } int main(int argc, char** argv) { - uint8_t bch_payload[SRSLTE_MIB_NB_LEN] = {}; - int ret = SRSLTE_ERROR; + uint8_t bch_payload[SRSRAN_MIB_NB_LEN] = {}; + int ret = SRSRAN_ERROR; uint32_t nof_tx_ports = 0; int sfn_offset = 0; @@ -212,45 +212,45 @@ int main(int argc, char** argv) int nread = 0; do { - nread = srslte_filesource_read(&fsrc, input_buffer, SFLEN); + nread = srsran_filesource_read(&fsrc, input_buffer, SFLEN); if (nread == SFLEN) { // do IFFT and channel estimation only on subframes that are known to contain NRS if (sf_idx == 0 || sf_idx == 4) { INFO("%d.%d: Estimating channel.", frame_cnt, sf_idx); - srslte_ofdm_rx_sf(&fft); - // srslte_ofdm_set_normalize(&fft, true); + srsran_ofdm_rx_sf(&fft); + // srsran_ofdm_set_normalize(&fft, true); if (do_chest) { - srslte_chest_dl_nbiot_estimate(&chest, fft_buffer, ce, sf_idx); + srsran_chest_dl_nbiot_estimate(&chest, fft_buffer, ce, sf_idx); } } // but NPBCH processing only for 1st subframe if (sf_idx == 0) { - float noise_est = (do_chest) ? srslte_chest_dl_nbiot_get_noise_estimate(&chest) : 0.0; + float noise_est = (do_chest) ? srsran_chest_dl_nbiot_get_noise_estimate(&chest) : 0.0; if (frame_cnt % 8 == 0) { DEBUG("Reseting NPBCH decoder."); - srslte_npbch_decode_reset(&npbch); + srsran_npbch_decode_reset(&npbch); } INFO("%d.0: Calling NPBCH decoder (noise_est=%.2f)", frame_cnt, noise_est); - ret = srslte_npbch_decode_nf(&npbch, fft_buffer, ce, noise_est, bch_payload, &nof_tx_ports, NULL, nf); + ret = srsran_npbch_decode_nf(&npbch, fft_buffer, ce, noise_est, bch_payload, &nof_tx_ports, NULL, nf); - if (ret == SRSLTE_SUCCESS) { + if (ret == SRSRAN_SUCCESS) { printf("MIB-NB decoded OK. Nof ports: %d. SFN offset: %d Payload: ", nof_tx_ports, sfn_offset); - srslte_vec_fprint_hex(stdout, bch_payload, SRSLTE_MIB_NB_LEN); - srslte_mib_nb_t mib_nb; - srslte_npbch_mib_unpack(bch_payload, &mib_nb); - srslte_mib_nb_printf(stdout, cell, &mib_nb); + srsran_vec_fprint_hex(stdout, bch_payload, SRSRAN_MIB_NB_LEN); + srsran_mib_nb_t mib_nb; + srsran_npbch_mib_unpack(bch_payload, &mib_nb); + srsran_mib_nb_printf(stdout, cell, &mib_nb); nof_decoded_mibs++; } - if (SRSLTE_VERBOSE_ISDEBUG()) { + if (SRSRAN_VERBOSE_ISDEBUG()) { if (do_chest) { DEBUG("SAVED FILE npbch_rx_chest_on.bin: NPBCH with chest"); - srslte_vec_save_file("npbch_rx_chest_on.bin", npbch.d, npbch.nof_symbols * sizeof(cf_t)); + srsran_vec_save_file("npbch_rx_chest_on.bin", npbch.d, npbch.nof_symbols * sizeof(cf_t)); } else { DEBUG("SAVED FILE npbch_rx_chest_off.bin: NPBCH without chest"); - srslte_vec_save_file("npbch_rx_chest_off.bin", npbch.d, npbch.nof_symbols * sizeof(cf_t)); + srsran_vec_save_file("npbch_rx_chest_off.bin", npbch.d, npbch.nof_symbols * sizeof(cf_t)); } } } @@ -270,7 +270,7 @@ int main(int argc, char** argv) printf("nof_decoded_mibs=%d\n", nof_decoded_mibs); - ret = (nof_decoded_mibs > 0) ? SRSLTE_SUCCESS : SRSLTE_ERROR; + ret = (nof_decoded_mibs > 0) ? SRSRAN_SUCCESS : SRSRAN_ERROR; return ret; } diff --git a/lib/src/phy/phch/test/npbch_test.c b/lib/src/phy/phch/test/npbch_test.c index a3791bed0..afae36af7 100644 --- a/lib/src/phy/phch/test/npbch_test.c +++ b/lib/src/phy/phch/test/npbch_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -17,13 +17,13 @@ #include #include -#include "srslte/phy/phch/npbch.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/phch/npbch.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" #define HAVE_OFDM 0 #define HAVE_MIB_NB 1 -srslte_nbiot_cell_t cell = {}; +srsran_nbiot_cell_t cell = {}; void usage(char* prog) { @@ -31,7 +31,7 @@ void usage(char* prog) printf("\t-c cell id [Default %d]\n", cell.base.id); printf("\t-p cell.nof_ports [Default %d]\n", cell.base.nof_ports); printf("\t-n cell.nof_prb [Default %d]\n", cell.base.nof_prb); - printf("\t-v [set srslte_verbose to debug, default none]\n"); + printf("\t-v [set srsran_verbose to debug, default none]\n"); } void parse_args(int argc, char** argv) @@ -49,7 +49,7 @@ void parse_args(int argc, char** argv) cell.base.id = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'v': - srslte_verbose++; + srsran_verbose++; break; default: usage(argv[0]); @@ -60,16 +60,16 @@ void parse_args(int argc, char** argv) int re_extract_test() { - int ret = SRSLTE_ERROR; + int ret = SRSRAN_ERROR; - srslte_nbiot_cell_t cell2 = {}; + srsran_nbiot_cell_t cell2 = {}; cell2.base.id = 257; cell2.base.nof_ports = 1; cell2.n_id_ncell = 257; cell2.nof_ports = 1; cell2.base.nof_prb = 1; - if (!srslte_nbiot_cell_isvalid(&cell2)) { + if (!srsran_nbiot_cell_isvalid(&cell2)) { printf("cell is not properly configured\n"); return ret; } @@ -80,17 +80,17 @@ int re_extract_test() } cf_t npbch_syms[100]; - int nof_ext_syms = srslte_npbch_cp(sf_syms, npbch_syms, cell2, false); + int nof_ext_syms = srsran_npbch_cp(sf_syms, npbch_syms, cell2, false); - if (SRSLTE_VERBOSE_ISINFO()) { + if (SRSRAN_VERBOSE_ISINFO()) { for (int i = 0; i < nof_ext_syms; i++) { printf("re%d:", i); - srslte_vec_fprint_c(stdout, &npbch_syms[i], 1); + srsran_vec_fprint_c(stdout, &npbch_syms[i], 1); } } if (nof_ext_syms == 100) { - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; printf("RE extraction ok!\n"); } return ret; @@ -98,17 +98,17 @@ int re_extract_test() int main(int argc, char** argv) { - int ret = SRSLTE_ERROR; - srslte_npbch_t npbch; - uint8_t bch_payload_tx[SRSLTE_MIB_NB_LEN], bch_payload_rx[SRSLTE_MIB_NB_LEN]; - cf_t* ce[SRSLTE_MAX_PORTS]; + int ret = SRSRAN_ERROR; + srsran_npbch_t npbch; + uint8_t bch_payload_tx[SRSRAN_MIB_NB_LEN], bch_payload_rx[SRSRAN_MIB_NB_LEN]; + cf_t* ce[SRSRAN_MAX_PORTS]; int nof_re; - cf_t* sf_symbols[SRSLTE_MAX_PORTS]; + cf_t* sf_symbols[SRSRAN_MAX_PORTS]; uint32_t nof_rx_ports; parse_args(argc, argv); - if (re_extract_test() != SRSLTE_SUCCESS) { + if (re_extract_test() != SRSRAN_SUCCESS) { return ret; } @@ -116,11 +116,11 @@ int main(int argc, char** argv) cell.base.nof_prb = 1; cell.nof_ports = 1; - nof_re = SRSLTE_SF_LEN_RE(cell.base.nof_prb, SRSLTE_CP_NORM); + nof_re = SRSRAN_SF_LEN_RE(cell.base.nof_prb, SRSRAN_CP_NORM); /* init memory */ for (int i = 0; i < cell.nof_ports; i++) { - ce[i] = srslte_vec_cf_malloc(nof_re); + ce[i] = srsran_vec_cf_malloc(nof_re); if (!ce[i]) { perror("malloc"); exit(-1); @@ -128,7 +128,7 @@ int main(int argc, char** argv) for (int j = 0; j < nof_re; j++) { ce[i][j] = 1; } - sf_symbols[i] = srslte_vec_cf_malloc(nof_re); + sf_symbols[i] = srsran_vec_cf_malloc(nof_re); if (!sf_symbols[i]) { perror("malloc"); exit(-1); @@ -136,33 +136,33 @@ int main(int argc, char** argv) memset(sf_symbols[i], 0, sizeof(cf_t) * nof_re); } - if (srslte_npbch_init(&npbch)) { + if (srsran_npbch_init(&npbch)) { fprintf(stderr, "Error creating NPBCH object\n"); exit(-1); } - if (srslte_npbch_set_cell(&npbch, cell)) { + if (srsran_npbch_set_cell(&npbch, cell)) { fprintf(stderr, "Error setting cell in NPBCH object\n"); exit(-1); } #if HAVE_MIB_NB - srslte_mib_nb_t mib_nb = {}; + srsran_mib_nb_t mib_nb = {}; mib_nb.sched_info_sib1 = 3; // according to Table 16.4.1.3-3 in 36.213 that means 4 NPDSCH repetitions mib_nb.sys_info_tag = 1; mib_nb.ac_barring = false; - mib_nb.mode = SRSLTE_NBIOT_MODE_STANDALONE; + mib_nb.mode = SRSRAN_NBIOT_MODE_STANDALONE; uint32_t hfn = 82; uint32_t sfn = 0; - srslte_npbch_mib_pack(hfn, sfn, mib_nb, bch_payload_tx); + srsran_npbch_mib_pack(hfn, sfn, mib_nb, bch_payload_tx); #else // srand(0); srand(time(NULL)); - for (i = 0; i < SRSLTE_MIB_NB_LEN; i++) { + for (i = 0; i < SRSRAN_MIB_NB_LEN; i++) { bch_payload_tx[i] = rand() % 2; } #endif - if (srslte_npbch_put_subframe(&npbch, bch_payload_tx, sf_symbols, 0)) { + if (srsran_npbch_put_subframe(&npbch, bch_payload_tx, sf_symbols, 0)) { fprintf(stderr, "Error encoding NPBCH\n"); exit(-1); } @@ -177,35 +177,35 @@ int main(int argc, char** argv) #if HAVE_OFDM cf_t td_signal[nof_re * 2]; - srslte_ofdm_t ofdm_tx; - srslte_ofdm_t ofdm_rx; + srsran_ofdm_t ofdm_tx; + srsran_ofdm_t ofdm_rx; - if (srslte_ofdm_tx_init(&ofdm_tx, SRSLTE_CP_NORM, cell.base.nof_prb)) { + if (srsran_ofdm_tx_init(&ofdm_tx, SRSRAN_CP_NORM, cell.base.nof_prb)) { fprintf(stderr, "Error creating iFFT object\n"); exit(-1); } - // srslte_ofdm_set_normalize(&ofdm_tx, true); + // srsran_ofdm_set_normalize(&ofdm_tx, true); - if (srslte_ofdm_rx_init(&ofdm_rx, SRSLTE_CP_NORM, cell.base.nof_prb)) { + if (srsran_ofdm_rx_init(&ofdm_rx, SRSRAN_CP_NORM, cell.base.nof_prb)) { fprintf(stderr, "Error initializing FFT\n"); return -1; } // transfer into time doamin and back - srslte_ofdm_tx_sf(&ofdm_tx, sf_symbols[0], td_signal); - srslte_ofdm_rx_sf(&ofdm_rx, td_signal, sf_symbols[0]); + srsran_ofdm_tx_sf(&ofdm_tx, sf_symbols[0], td_signal); + srsran_ofdm_rx_sf(&ofdm_rx, td_signal, sf_symbols[0]); - srslte_ofdm_tx_free(&ofdm_tx); - srslte_ofdm_rx_free(&ofdm_rx); + srsran_ofdm_tx_free(&ofdm_tx); + srsran_ofdm_rx_free(&ofdm_rx); #endif - srslte_npbch_decode_reset(&npbch); - if (srslte_npbch_decode(&npbch, sf_symbols[0], ce, 0, bch_payload_rx, &nof_rx_ports, NULL)) { + srsran_npbch_decode_reset(&npbch); + if (srsran_npbch_decode(&npbch, sf_symbols[0], ce, 0, bch_payload_rx, &nof_rx_ports, NULL)) { printf("Error decoding\n"); exit(-1); } - srslte_npbch_free(&npbch); + srsran_npbch_free(&npbch); for (int i = 0; i < cell.nof_ports; i++) { free(ce[i]); @@ -213,17 +213,17 @@ int main(int argc, char** argv) } printf("Tx ports: %d - Rx ports: %d\n", cell.nof_ports, nof_rx_ports); printf("Tx payload: "); - srslte_vec_fprint_hex(stdout, bch_payload_tx, SRSLTE_MIB_NB_LEN); + srsran_vec_fprint_hex(stdout, bch_payload_tx, SRSRAN_MIB_NB_LEN); printf("Rx payload: "); - srslte_vec_fprint_hex(stdout, bch_payload_rx, SRSLTE_MIB_NB_LEN); + srsran_vec_fprint_hex(stdout, bch_payload_rx, SRSRAN_MIB_NB_LEN); #if HAVE_MIB_NB - srslte_mib_nb_t mib_nb_rx; - srslte_npbch_mib_unpack(bch_payload_rx, &mib_nb_rx); - srslte_mib_nb_printf(stdout, cell, &mib_nb_rx); + srsran_mib_nb_t mib_nb_rx; + srsran_npbch_mib_unpack(bch_payload_rx, &mib_nb_rx); + srsran_mib_nb_printf(stdout, cell, &mib_nb_rx); #endif - if (nof_rx_ports == cell.nof_ports && !memcmp(bch_payload_rx, bch_payload_tx, sizeof(uint8_t) * SRSLTE_MIB_NB_LEN)) { + if (nof_rx_ports == cell.nof_ports && !memcmp(bch_payload_rx, bch_payload_tx, sizeof(uint8_t) * SRSRAN_MIB_NB_LEN)) { printf("OK\n"); exit(0); } else { diff --git a/lib/src/phy/phch/test/npdcch_file_test.c b/lib/src/phy/phch/test/npdcch_file_test.c index 1f1fddc7b..1a19ced39 100644 --- a/lib/src/phy/phch/test/npdcch_file_test.c +++ b/lib/src/phy/phch/test/npdcch_file_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,43 +10,43 @@ * */ -#include "srslte/phy/ch_estimation/chest_dl_nbiot.h" -#include "srslte/phy/dft/ofdm.h" -#include "srslte/phy/io/filesource.h" -#include "srslte/phy/phch/dci_nbiot.h" -#include "srslte/phy/phch/npdcch.h" -#include "srslte/phy/phch/ra_nbiot.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/ch_estimation/chest_dl_nbiot.h" +#include "srsran/phy/dft/ofdm.h" +#include "srsran/phy/io/filesource.h" +#include "srsran/phy/phch/dci_nbiot.h" +#include "srsran/phy/phch/npdcch.h" +#include "srsran/phy/phch/ra_nbiot.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" #include #include #include #include char* input_file_name = NULL; -srslte_dci_format_t dci_format = SRSLTE_DCI_FORMATN0; +srsran_dci_format_t dci_format = SRSRAN_DCI_FORMATN0; uint16_t rnti = 0; uint32_t tti = 0; int nof_frames = 1; -srslte_dci_location_t dci_location = {}; +srsran_dci_location_t dci_location = {}; -srslte_nbiot_cell_t cell = {.base = {.nof_prb = 1, .nof_ports = 1, .cp = SRSLTE_CP_NORM, .id = 0}, +srsran_nbiot_cell_t cell = {.base = {.nof_prb = 1, .nof_ports = 1, .cp = SRSRAN_CP_NORM, .id = 0}, .nbiot_prb = 0, .n_id_ncell = 0, .nof_ports = 1, - .mode = SRSLTE_NBIOT_MODE_STANDALONE}; + .mode = SRSRAN_NBIOT_MODE_STANDALONE}; void usage(char* prog) { printf("Usage: %s [cprndv] -i input_file\n", prog); printf("\t-c cell id [Default %d]\n", cell.base.id); printf("\t-p cell.nof_ports [Default %d]\n", cell.base.nof_ports); - printf("\t-o DCI Format [Default %s]\n", srslte_dci_format_string(dci_format)); + printf("\t-o DCI Format [Default %s]\n", srsran_dci_format_string(dci_format)); printf("\t-L DCI location L value [Default %d]\n", dci_location.L); printf("\t-l DCI location ncee value [Default %d]\n", dci_location.ncce); printf("\t-r rnti [Default %d]\n", rnti); printf("\t-t tti [Default %d]\n", tti); - printf("\t-v [set srslte_verbose to debug, default none]\n"); + printf("\t-v [set srsran_verbose to debug, default none]\n"); } void parse_args(int argc, char** argv) @@ -73,8 +73,8 @@ void parse_args(int argc, char** argv) rnti = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'o': - dci_format = srslte_dci_format_from_string(argv[optind]); - if (dci_format == SRSLTE_DCI_NOF_FORMATS) { + dci_format = srsran_dci_format_from_string(argv[optind]); + if (dci_format == SRSRAN_DCI_NOF_FORMATS) { ERROR("Error unsupported format %s", argv[optind]); exit(-1); } @@ -83,7 +83,7 @@ void parse_args(int argc, char** argv) tti = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'v': - srslte_verbose++; + srsran_verbose++; break; default: usage(argv[0]); @@ -98,13 +98,13 @@ void parse_args(int argc, char** argv) int main(int argc, char** argv) { - cf_t * input_buffer = NULL, *fft_buffer = NULL, *ce[SRSLTE_MAX_PORTS] = {NULL}; - srslte_filesource_t fsrc; - srslte_chest_dl_nbiot_t chest; - srslte_ofdm_t fft; - srslte_npdcch_t npdcch = {}; - srslte_dci_msg_t dci_rx = {}; - int ret = SRSLTE_ERROR; + cf_t * input_buffer = NULL, *fft_buffer = NULL, *ce[SRSRAN_MAX_PORTS] = {NULL}; + srsran_filesource_t fsrc; + srsran_chest_dl_nbiot_t chest; + srsran_ofdm_t fft; + srsran_npdcch_t npdcch = {}; + srsran_dci_msg_t dci_rx = {}; + int ret = SRSRAN_ERROR; int frame_cnt = 0; int nof_decoded_dcis = 0; int nread = 0; @@ -112,11 +112,11 @@ int main(int argc, char** argv) parse_args(argc, argv); // we need to allocate RE's for a full 6 PRB cell - int nof_re = 6 * SRSLTE_SF_LEN_RE(cell.base.nof_prb, cell.base.cp); + int nof_re = 6 * SRSRAN_SF_LEN_RE(cell.base.nof_prb, cell.base.cp); // init memory - for (int i = 0; i < SRSLTE_MAX_PORTS; i++) { - ce[i] = srslte_vec_cf_malloc(nof_re); + for (int i = 0; i < SRSRAN_MAX_PORTS; i++) { + ce[i] = srsran_vec_cf_malloc(nof_re); if (!ce[i]) { perror("malloc"); goto quit; @@ -126,69 +126,69 @@ int main(int argc, char** argv) } } - if (srslte_filesource_init(&fsrc, input_file_name, SRSLTE_COMPLEX_FLOAT_BIN)) { + if (srsran_filesource_init(&fsrc, input_file_name, SRSRAN_COMPLEX_FLOAT_BIN)) { fprintf(stderr, "Error opening file %s\n", input_file_name); goto quit; } - uint32_t sf_len = SRSLTE_SF_LEN(srslte_symbol_sz(cell.base.nof_prb)); + uint32_t sf_len = SRSRAN_SF_LEN(srsran_symbol_sz(cell.base.nof_prb)); - input_buffer = srslte_vec_cf_malloc(sf_len); + input_buffer = srsran_vec_cf_malloc(sf_len); if (!input_buffer) { perror("malloc"); goto quit; } - fft_buffer = srslte_vec_cf_malloc(sf_len); + fft_buffer = srsran_vec_cf_malloc(sf_len); if (!fft_buffer) { perror("malloc"); goto quit; } - if (srslte_chest_dl_nbiot_init(&chest, SRSLTE_NBIOT_MAX_PRB)) { + if (srsran_chest_dl_nbiot_init(&chest, SRSRAN_NBIOT_MAX_PRB)) { fprintf(stderr, "Error initializing equalizer\n"); goto quit; } - if (srslte_chest_dl_nbiot_set_cell(&chest, cell) != SRSLTE_SUCCESS) { + if (srsran_chest_dl_nbiot_set_cell(&chest, cell) != SRSRAN_SUCCESS) { fprintf(stderr, "Error setting equalizer cell configuration\n"); goto quit; } - if (srslte_ofdm_rx_init(&fft, cell.base.cp, input_buffer, fft_buffer, cell.base.nof_prb)) { + if (srsran_ofdm_rx_init(&fft, cell.base.cp, input_buffer, fft_buffer, cell.base.nof_prb)) { fprintf(stderr, "Error initializing FFT\n"); goto quit; } - srslte_ofdm_set_freq_shift(&fft, SRSLTE_NBIOT_FREQ_SHIFT_FACTOR); + srsran_ofdm_set_freq_shift(&fft, SRSRAN_NBIOT_FREQ_SHIFT_FACTOR); - if (srslte_npdcch_init(&npdcch)) { + if (srsran_npdcch_init(&npdcch)) { fprintf(stderr, "Error creating NPDCCH object\n"); goto quit; } - if (srslte_npdcch_set_cell(&npdcch, cell)) { + if (srsran_npdcch_set_cell(&npdcch, cell)) { fprintf(stderr, "Error configuring NPDCCH object\n"); goto quit; } do { - nread = srslte_filesource_read(&fsrc, input_buffer, sf_len); + nread = srsran_filesource_read(&fsrc, input_buffer, sf_len); if (nread == sf_len) { // Run FFT and estimate channel - srslte_ofdm_rx_sf(&fft); + srsran_ofdm_rx_sf(&fft); INFO("%d.%d: Estimating channel.", frame_cnt, tti % 10); - srslte_chest_dl_nbiot_estimate(&chest, fft_buffer, ce, tti % 10); + srsran_chest_dl_nbiot_estimate(&chest, fft_buffer, ce, tti % 10); // Extract LLR - float noise_est = srslte_chest_dl_nbiot_get_noise_estimate(&chest); - if (srslte_npdcch_extract_llr(&npdcch, fft_buffer, ce, noise_est, tti % 10)) { + float noise_est = srsran_chest_dl_nbiot_get_noise_estimate(&chest); + if (srsran_npdcch_extract_llr(&npdcch, fft_buffer, ce, noise_est, tti % 10)) { fprintf(stderr, "Error extracting LLRs\n"); goto quit; } uint16_t crc_rem = 0; - if (srslte_npdcch_decode_msg(&npdcch, &dci_rx, &dci_location, dci_format, &crc_rem)) { + if (srsran_npdcch_decode_msg(&npdcch, &dci_rx, &dci_location, dci_format, &crc_rem)) { fprintf(stderr, "Error decoding DCI message\n"); goto quit; } @@ -196,20 +196,20 @@ int main(int argc, char** argv) printf("Received invalid DCI CRC 0x%x\n", crc_rem); goto quit; } else { - if (dci_format == SRSLTE_DCI_FORMATN0) { + if (dci_format == SRSRAN_DCI_FORMATN0) { // process as UL grant - srslte_ra_nbiot_ul_dci_t dci_unpacked; - srslte_ra_nbiot_ul_grant_t grant; + srsran_ra_nbiot_ul_dci_t dci_unpacked; + srsran_ra_nbiot_ul_grant_t grant; // Creates the UL NPUSCH resource allocation grant from a DCI format N0 message - if (srslte_nbiot_dci_msg_to_ul_grant(&dci_rx, &dci_unpacked, &grant, tti, SRSLTE_NPUSCH_SC_SPACING_15000)) { + if (srsran_nbiot_dci_msg_to_ul_grant(&dci_rx, &dci_unpacked, &grant, tti, SRSRAN_NPUSCH_SC_SPACING_15000)) { fprintf(stderr, "Error unpacking DCI\n"); goto quit; } } else { // process as DL grant - srslte_ra_nbiot_dl_dci_t dci_unpacked; - srslte_ra_nbiot_dl_grant_t grant; - if (srslte_nbiot_dci_msg_to_dl_grant( + srsran_ra_nbiot_dl_dci_t dci_unpacked; + srsran_ra_nbiot_dl_grant_t grant; + if (srsran_nbiot_dci_msg_to_dl_grant( &dci_rx, rnti, &dci_unpacked, &grant, tti / 10, tti % 10, 64 /* TODO: remove */, cell.mode)) { fprintf(stderr, "Error unpacking DCI\n"); goto quit; @@ -228,21 +228,21 @@ int main(int argc, char** argv) } while (nread > 0 && frame_cnt < nof_frames); quit: - srslte_npdcch_free(&npdcch); - srslte_filesource_free(&fsrc); + srsran_npdcch_free(&npdcch); + srsran_filesource_free(&fsrc); free(input_buffer); free(fft_buffer); - srslte_chest_dl_nbiot_free(&chest); - srslte_ofdm_rx_free(&fft); + srsran_chest_dl_nbiot_free(&chest); + srsran_ofdm_rx_free(&fft); - for (int i = 0; i < SRSLTE_MAX_PORTS; i++) { + for (int i = 0; i < SRSRAN_MAX_PORTS; i++) { if (ce[i]) { free(ce[i]); } } if (nof_decoded_dcis > 0) { printf("Ok\n"); - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } else { printf("Error\n"); } diff --git a/lib/src/phy/phch/test/npdcch_test.c b/lib/src/phy/phch/test/npdcch_test.c index eb78d0da0..f523a1c7b 100644 --- a/lib/src/phy/phch/test/npdcch_test.c +++ b/lib/src/phy/phch/test/npdcch_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -16,31 +16,31 @@ #include #include -#include "srslte/phy/phch/dci_nbiot.h" -#include "srslte/phy/phch/npdcch.h" -#include "srslte/phy/phch/ra_nbiot.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/phch/dci_nbiot.h" +#include "srsran/phy/phch/npdcch.h" +#include "srsran/phy/phch/ra_nbiot.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" #define RNTI (0x1234) #define HAVE_OFDM 0 -srslte_dci_format_t dci_format = SRSLTE_DCI_FORMATN0; +srsran_dci_format_t dci_format = SRSRAN_DCI_FORMATN0; -srslte_nbiot_cell_t cell = {.base = {.nof_prb = 1, .nof_ports = 1, .cp = SRSLTE_CP_NORM, .id = 0}, +srsran_nbiot_cell_t cell = {.base = {.nof_prb = 1, .nof_ports = 1, .cp = SRSRAN_CP_NORM, .id = 0}, .nbiot_prb = 0, .n_id_ncell = 0, .nof_ports = 1, - .mode = SRSLTE_NBIOT_MODE_STANDALONE}; + .mode = SRSRAN_NBIOT_MODE_STANDALONE}; void usage(char* prog) { printf("Usage: %s [cpndv]\n", prog); printf("\t-c cell id [Default %d]\n", cell.base.id); - printf("\t-o DCI Format [Default %s]\n", srslte_dci_format_string(dci_format)); + printf("\t-o DCI Format [Default %s]\n", srsran_dci_format_string(dci_format)); printf("\t-p cell.nof_ports [Default %d]\n", cell.base.nof_ports); printf("\t-n cell.nof_prb [Default %d]\n", cell.base.nof_prb); - printf("\t-v [set srslte_verbose to debug, default none]\n"); + printf("\t-v [set srsran_verbose to debug, default none]\n"); } void parse_args(int argc, char** argv) @@ -58,14 +58,14 @@ void parse_args(int argc, char** argv) cell.base.id = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'o': - dci_format = srslte_dci_format_from_string(argv[optind]); - if (dci_format == SRSLTE_DCI_NOF_FORMATS) { + dci_format = srsran_dci_format_from_string(argv[optind]); + if (dci_format == SRSRAN_DCI_NOF_FORMATS) { ERROR("Error unsupported format %s", argv[optind]); exit(-1); } break; case 'v': - srslte_verbose++; + srsran_verbose++; break; default: usage(argv[0]); @@ -76,25 +76,25 @@ void parse_args(int argc, char** argv) int main(int argc, char** argv) { - srslte_npdcch_t npdcch = {}; - srslte_dci_msg_t dci_tx = {}, dci_rx = {}; - srslte_dci_location_t dci_location = {}; + srsran_npdcch_t npdcch = {}; + srsran_dci_msg_t dci_tx = {}, dci_rx = {}; + srsran_dci_location_t dci_location = {}; uint32_t tti = 6521; uint16_t rnti = 0x1234; - cf_t* ce[SRSLTE_MAX_PORTS] = {NULL}; - cf_t* slot_symbols[SRSLTE_MAX_PORTS] = {NULL}; - int ret = SRSLTE_ERROR; + cf_t* ce[SRSRAN_MAX_PORTS] = {NULL}; + cf_t* slot_symbols[SRSRAN_MAX_PORTS] = {NULL}; + int ret = SRSRAN_ERROR; parse_args(argc, argv); // we need to allocate RE's for a full 6 PRB cell - int nof_re = 6 * SRSLTE_SF_LEN_RE(cell.base.nof_prb, cell.base.cp); + int nof_re = 6 * SRSRAN_SF_LEN_RE(cell.base.nof_prb, cell.base.cp); // init memory - for (int i = 0; i < SRSLTE_MAX_PORTS; i++) { - ce[i] = srslte_vec_cf_malloc(nof_re); + for (int i = 0; i < SRSRAN_MAX_PORTS; i++) { + ce[i] = srsran_vec_cf_malloc(nof_re); if (!ce[i]) { perror("malloc"); exit(-1); @@ -102,7 +102,7 @@ int main(int argc, char** argv) for (int j = 0; j < nof_re; j++) { ce[i][j] = 1; } - slot_symbols[i] = srslte_vec_cf_malloc(nof_re); + slot_symbols[i] = srsran_vec_cf_malloc(nof_re); if (!slot_symbols[i]) { perror("malloc"); exit(-1); @@ -113,31 +113,31 @@ int main(int argc, char** argv) cf_t td_signal[nof_re * 2]; #endif - if (srslte_npdcch_init(&npdcch)) { + if (srsran_npdcch_init(&npdcch)) { fprintf(stderr, "Error creating NPDCCH object\n"); exit(-1); } - if (srslte_npdcch_set_cell(&npdcch, cell)) { + if (srsran_npdcch_set_cell(&npdcch, cell)) { fprintf(stderr, "Error configuring NPDCCH object\n"); exit(-1); } - if (dci_format == SRSLTE_DCI_FORMATN0) { + if (dci_format == SRSRAN_DCI_FORMATN0) { // UL grant - srslte_ra_nbiot_ul_dci_t dci = {}; + srsran_ra_nbiot_ul_dci_t dci = {}; dci.format = dci_format; - srslte_ra_nbiot_ul_grant_t grant; - if (srslte_ra_nbiot_ul_dci_to_grant(&dci, &grant, tti, SRSLTE_NPUSCH_SC_SPACING_15000)) { + srsran_ra_nbiot_ul_grant_t grant; + if (srsran_ra_nbiot_ul_dci_to_grant(&dci, &grant, tti, SRSRAN_NPUSCH_SC_SPACING_15000)) { fprintf(stderr, "Error converting DCI message\n"); } fprintf(stderr, "FormatN0 packing not supported\n"); - return SRSLTE_ERROR; - } else if (dci_format == SRSLTE_DCI_FORMATN1) { + return SRSRAN_ERROR; + } else if (dci_format == SRSRAN_DCI_FORMATN1) { // DL grant - srslte_ra_nbiot_dl_dci_t ra_dl = {}; + srsran_ra_nbiot_dl_dci_t ra_dl = {}; ra_dl.mcs_idx = 5; ra_dl.ndi = 0; ra_dl.rv_idx = 0; @@ -150,17 +150,17 @@ int main(int argc, char** argv) ra_dl.alloc.i_rep = 0; ra_dl.alloc.harq_ack = 1; ra_dl.alloc.i_n_start = 0; - srslte_nbiot_dl_dci_fprint(stdout, &ra_dl); + srsran_nbiot_dl_dci_fprint(stdout, &ra_dl); // pack DCI - srslte_dci_msg_pack_npdsch(&ra_dl, dci_format, &dci_tx, false); - srslte_dci_location_set(&dci_location, 2, 0); + srsran_dci_msg_pack_npdsch(&ra_dl, dci_format, &dci_tx, false); + srsran_dci_location_set(&dci_location, 2, 0); } else { fprintf(stderr, "FormatN2 packing not supported\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_npdcch_encode(&npdcch, &dci_tx, dci_location, RNTI, slot_symbols, 0)) { + if (srsran_npdcch_encode(&npdcch, &dci_tx, dci_location, RNTI, slot_symbols, 0)) { fprintf(stderr, "Error encoding DCI message\n"); goto quit; } @@ -173,34 +173,34 @@ int main(int argc, char** argv) } #if HAVE_OFDM - srslte_ofdm_t ofdm_tx; - srslte_ofdm_t ofdm_rx; + srsran_ofdm_t ofdm_tx; + srsran_ofdm_t ofdm_rx; - if (srslte_ofdm_tx_init(&ofdm_tx, SRSLTE_CP_NORM, slot_symbols[0], td_signal, cell.base.nof_prb)) { + if (srsran_ofdm_tx_init(&ofdm_tx, SRSRAN_CP_NORM, slot_symbols[0], td_signal, cell.base.nof_prb)) { fprintf(stderr, "Error creating iFFT object\n"); exit(-1); } - // srslte_ofdm_set_normalize(&ofdm_tx, true); + // srsran_ofdm_set_normalize(&ofdm_tx, true); - if (srslte_ofdm_rx_init(&ofdm_rx, SRSLTE_CP_NORM, td_signal, slot_symbols[0], cell.base.nof_prb)) { + if (srsran_ofdm_rx_init(&ofdm_rx, SRSRAN_CP_NORM, td_signal, slot_symbols[0], cell.base.nof_prb)) { fprintf(stderr, "Error initializing FFT\n"); return -1; } // transfer into time doamin and back - srslte_ofdm_tx_sf(&ofdm_tx); - srslte_ofdm_rx_sf(&ofdm_rx); + srsran_ofdm_tx_sf(&ofdm_tx); + srsran_ofdm_rx_sf(&ofdm_rx); - srslte_ofdm_tx_free(&ofdm_tx); - srslte_ofdm_rx_free(&ofdm_rx); + srsran_ofdm_tx_free(&ofdm_tx); + srsran_ofdm_rx_free(&ofdm_rx); #endif - if (srslte_npdcch_extract_llr(&npdcch, slot_symbols[0], ce, 0, 0)) { + if (srsran_npdcch_extract_llr(&npdcch, slot_symbols[0], ce, 0, 0)) { fprintf(stderr, "Error extracting LLRs\n"); goto quit; } uint16_t crc_rem = 0; - if (srslte_npdcch_decode_msg(&npdcch, &dci_rx, &dci_location, dci_format, &crc_rem)) { + if (srsran_npdcch_decode_msg(&npdcch, &dci_rx, &dci_location, dci_format, &crc_rem)) { fprintf(stderr, "Error decoding DCI message\n"); goto quit; } @@ -215,27 +215,27 @@ int main(int argc, char** argv) goto quit; } - if (dci_format == SRSLTE_DCI_FORMATN0) { + if (dci_format == SRSRAN_DCI_FORMATN0) { // UL grant // .. } else { // DL grant - srslte_ra_nbiot_dl_dci_t dci_unpacked; - srslte_ra_nbiot_dl_grant_t grant; - if (srslte_nbiot_dci_msg_to_dl_grant( + srsran_ra_nbiot_dl_dci_t dci_unpacked; + srsran_ra_nbiot_dl_grant_t grant; + if (srsran_nbiot_dci_msg_to_dl_grant( &dci_rx, rnti, &dci_unpacked, &grant, tti / 10, tti % 10, 64 /* todo: remove */, cell.mode)) { fprintf(stderr, "Error unpacking DCI\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - srslte_nbiot_dl_dci_fprint(stdout, &dci_unpacked); + srsran_nbiot_dl_dci_fprint(stdout, &dci_unpacked); } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; quit: - srslte_npdcch_free(&npdcch); + srsran_npdcch_free(&npdcch); - for (int i = 0; i < SRSLTE_MAX_PORTS; i++) { + for (int i = 0; i < SRSRAN_MAX_PORTS; i++) { if (ce[i]) { free(ce[i]); } diff --git a/lib/src/phy/phch/test/npdsch_npdcch_file_test.c b/lib/src/phy/phch/test/npdsch_npdcch_file_test.c index 39d4ada8a..699034d9f 100644 --- a/lib/src/phy/phch/test/npdsch_npdcch_file_test.c +++ b/lib/src/phy/phch/test/npdsch_npdcch_file_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -15,45 +15,45 @@ #include #include -#include "srslte/phy/channel/ch_awgn.h" -#include "srslte/phy/io/filesource.h" -#include "srslte/phy/phch/npdsch.h" -#include "srslte/phy/ue/ue_dl_nbiot.h" -#include "srslte/phy/utils/debug.h" +#include "srsran/phy/channel/ch_awgn.h" +#include "srsran/phy/io/filesource.h" +#include "srsran/phy/phch/npdsch.h" +#include "srsran/phy/ue/ue_dl_nbiot.h" +#include "srsran/phy/utils/debug.h" #define DUMP_SIGNAL 0 char* input_file_name = NULL; -static srslte_nbiot_cell_t cell = {.base = {.nof_prb = 1, .nof_ports = 1, .cp = SRSLTE_CP_NORM, .id = 0}, +static srsran_nbiot_cell_t cell = {.base = {.nof_prb = 1, .nof_ports = 1, .cp = SRSRAN_CP_NORM, .id = 0}, .nbiot_prb = 0, .n_id_ncell = 0, .nof_ports = 1, - .mode = SRSLTE_NBIOT_MODE_STANDALONE, + .mode = SRSRAN_NBIOT_MODE_STANDALONE, .is_r14 = true}; int flen; -uint16_t rnti = SRSLTE_SIRNTI; +uint16_t rnti = SRSRAN_SIRNTI; int sfn = 0; int nof_frames = 0; int max_frames = 1; uint32_t sf_idx = 0; uint32_t sched_info_tag = 0; // Value of schedulingInfoSIB1-NB-r13 -srslte_mib_nb_t mib; +srsran_mib_nb_t mib; bool decode_sib1 = false; float snr = -1.0; -srslte_dci_format_t dci_format = SRSLTE_DCI_FORMAT1; -srslte_filesource_t fsrc; -srslte_nbiot_ue_dl_t ue_dl; -cf_t* buff_ptrs[SRSLTE_MAX_PORTS] = {NULL, NULL, NULL, NULL}; +srsran_dci_format_t dci_format = SRSRAN_DCI_FORMAT1; +srsran_filesource_t fsrc; +srsran_nbiot_ue_dl_t ue_dl; +cf_t* buff_ptrs[SRSRAN_MAX_PORTS] = {NULL, NULL, NULL, NULL}; void usage(char* prog) { printf("Usage: %s [rovcnwmpstRx] -i input_file\n", prog); - printf("\t-o DCI format [Default %s]\n", srslte_dci_format_string(dci_format)); + printf("\t-o DCI format [Default %s]\n", srsran_dci_format_string(dci_format)); printf("\t-c n_id_ncell [Default %d]\n", cell.n_id_ncell); printf("\t-s Start subframe_idx [Default %d]\n", sf_idx); printf("\t-w Start SFN [Default %d]\n", nof_frames); @@ -65,7 +65,7 @@ void usage(char* prog) printf("\t-m max_frames [Default %d]\n", max_frames); printf("\t-R Is R14 cell [Default %s]\n", cell.is_r14 ? "Yes" : "No"); printf("\t-x SNR-10 (apply noise to input file) [Default %f]\n", snr); - printf("\t-v [set srslte_verbose to debug, default none]\n"); + printf("\t-v [set srsran_verbose to debug, default none]\n"); } void parse_args(int argc, char** argv) @@ -107,8 +107,8 @@ void parse_args(int argc, char** argv) cell.base.nof_ports = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'o': - dci_format = srslte_dci_format_from_string(argv[optind]); - if (dci_format == SRSLTE_DCI_NOF_FORMATS) { + dci_format = srsran_dci_format_from_string(argv[optind]); + if (dci_format == SRSRAN_DCI_NOF_FORMATS) { fprintf(stderr, "Error unsupported format %s\n", argv[optind]); exit(-1); } @@ -117,7 +117,7 @@ void parse_args(int argc, char** argv) snr = strtof(argv[optind], NULL); break; case 'v': - srslte_verbose++; + srsran_verbose++; break; default: usage(argv[0]); @@ -132,32 +132,32 @@ void parse_args(int argc, char** argv) int base_init() { - if (srslte_filesource_init(&fsrc, input_file_name, SRSLTE_COMPLEX_FLOAT_BIN)) { + if (srsran_filesource_init(&fsrc, input_file_name, SRSRAN_COMPLEX_FLOAT_BIN)) { fprintf(stderr, "Error opening file %s\n", input_file_name); exit(-1); } - flen = 2 * (SRSLTE_SLOT_LEN(srslte_symbol_sz(cell.base.nof_prb))); - buff_ptrs[0] = srslte_vec_cf_malloc(flen); + flen = 2 * (SRSRAN_SLOT_LEN(srsran_symbol_sz(cell.base.nof_prb))); + buff_ptrs[0] = srsran_vec_cf_malloc(flen); if (!buff_ptrs[0]) { perror("malloc"); exit(-1); } - if (srslte_nbiot_ue_dl_init(&ue_dl, buff_ptrs, SRSLTE_NBIOT_MAX_PRB, SRSLTE_NBIOT_NUM_RX_ANTENNAS)) { + if (srsran_nbiot_ue_dl_init(&ue_dl, buff_ptrs, SRSRAN_NBIOT_MAX_PRB, SRSRAN_NBIOT_NUM_RX_ANTENNAS)) { fprintf(stderr, "Error initializing UE DL\n"); return -1; } - if (srslte_nbiot_ue_dl_set_cell(&ue_dl, cell)) { + if (srsran_nbiot_ue_dl_set_cell(&ue_dl, cell)) { fprintf(stderr, "Configuring cell in UE DL\n"); return -1; } mib.sched_info_sib1 = sched_info_tag; - srslte_nbiot_ue_dl_set_mib(&ue_dl, mib); - srslte_nbiot_ue_dl_set_rnti(&ue_dl, rnti); - // srslte_mib_nb_printf(stdout, 0, &mib); + srsran_nbiot_ue_dl_set_mib(&ue_dl, mib); + srsran_nbiot_ue_dl_set_rnti(&ue_dl, rnti); + // srsran_mib_nb_printf(stdout, 0, &mib); DEBUG("Memory init OK"); return 0; @@ -165,10 +165,10 @@ int base_init() void base_free() { - srslte_filesource_free(&fsrc); - srslte_nbiot_ue_dl_free(&ue_dl); + srsran_filesource_free(&fsrc); + srsran_nbiot_ue_dl_free(&ue_dl); - for (int i = 0; i < SRSLTE_MAX_PORTS; i++) { + for (int i = 0; i < SRSRAN_MAX_PORTS; i++) { if (buff_ptrs[i] != NULL) { free(buff_ptrs[i]); } @@ -179,7 +179,7 @@ int main(int argc, char** argv) { int dci_formatN0_detected = 0; int dci_formatN1_detected = 0; - srslte_dci_format_t last_dci_format = SRSLTE_DCI_FORMAT0; + srsran_dci_format_t last_dci_format = SRSRAN_DCI_FORMAT0; if (argc < 3) { usage(argv[0]); @@ -203,74 +203,74 @@ int main(int argc, char** argv) int nread = 0; if (decode_sib1) { - srslte_nbiot_ue_dl_decode_sib1(&ue_dl, sfn); + srsran_nbiot_ue_dl_decode_sib1(&ue_dl, sfn); } do { - nread = srslte_filesource_read(&fsrc, buff_ptrs[0], flen); + nread = srsran_filesource_read(&fsrc, buff_ptrs[0], flen); if (nread > 0) { DEBUG("%d.%d: Reading %d samples.", sfn, sf_idx, nread); // add some noise to the signal if (snr != -1.0) { float nstd = powf(10.0f, -snr / 20.0f); - srslte_ch_awgn_c(buff_ptrs[0], buff_ptrs[0], nstd, nread); + srsran_ch_awgn_c(buff_ptrs[0], buff_ptrs[0], nstd, nread); } // try to decode - if (srslte_ra_nbiot_is_valid_dl_sf(sfn * 10 + sf_idx)) { + if (srsran_ra_nbiot_is_valid_dl_sf(sfn * 10 + sf_idx)) { int n; - if (srslte_nbiot_ue_dl_has_grant(&ue_dl)) { + if (srsran_nbiot_ue_dl_has_grant(&ue_dl)) { // attempt to decode NPDSCH - n = srslte_nbiot_ue_dl_decode_npdsch(&ue_dl, buff_ptrs[0], data, sfn, sf_idx, rnti); - if (n == SRSLTE_SUCCESS) { + n = srsran_nbiot_ue_dl_decode_npdsch(&ue_dl, buff_ptrs[0], data, sfn, sf_idx, rnti); + if (n == SRSRAN_SUCCESS) { INFO("NPDSCH decoded ok."); if (decode_sib1) { - srslte_nbiot_ue_dl_decode_sib1(&ue_dl, sfn); + srsran_nbiot_ue_dl_decode_sib1(&ue_dl, sfn); } - } else if (n == SRSLTE_ERROR && decode_sib1) { + } else if (n == SRSRAN_ERROR && decode_sib1) { // reactivate SIB1 reception - srslte_nbiot_ue_dl_decode_sib1(&ue_dl, sfn); + srsran_nbiot_ue_dl_decode_sib1(&ue_dl, sfn); } } else { // decode NPDCCH - srslte_dci_msg_t dci_msg; - n = srslte_nbiot_ue_dl_decode_npdcch(&ue_dl, buff_ptrs[0], sfn, sf_idx, rnti, &dci_msg); - if (n == SRSLTE_NBIOT_UE_DL_FOUND_DCI) { - INFO("Found %s DCI for RNTI=0x%x", srslte_dci_format_string(dci_msg.format), rnti); + srsran_dci_msg_t dci_msg; + n = srsran_nbiot_ue_dl_decode_npdcch(&ue_dl, buff_ptrs[0], sfn, sf_idx, rnti, &dci_msg); + if (n == SRSRAN_NBIOT_UE_DL_FOUND_DCI) { + INFO("Found %s DCI for RNTI=0x%x", srsran_dci_format_string(dci_msg.format), rnti); last_dci_format = dci_msg.format; - if (dci_msg.format == SRSLTE_DCI_FORMATN0) { + if (dci_msg.format == SRSRAN_DCI_FORMATN0) { // try to convert to UL grant - srslte_ra_nbiot_ul_dci_t dci_unpacked; - srslte_ra_nbiot_ul_grant_t grant; + srsran_ra_nbiot_ul_dci_t dci_unpacked; + srsran_ra_nbiot_ul_grant_t grant; // Creates the UL NPUSCH resource allocation grant from a DCI format N0 message - if (srslte_nbiot_dci_msg_to_ul_grant( - &dci_msg, &dci_unpacked, &grant, sfn * 10 + sf_idx, SRSLTE_NPUSCH_SC_SPACING_15000)) { + if (srsran_nbiot_dci_msg_to_ul_grant( + &dci_msg, &dci_unpacked, &grant, sfn * 10 + sf_idx, SRSRAN_NPUSCH_SC_SPACING_15000)) { fprintf(stderr, "Error unpacking DCI\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } dci_formatN0_detected++; // we don't use UL grants any further - } else if (dci_msg.format == SRSLTE_DCI_FORMATN1) { + } else if (dci_msg.format == SRSRAN_DCI_FORMATN1) { // try to convert DCI to DL grant - srslte_ra_nbiot_dl_dci_t dci_unpacked; - srslte_ra_nbiot_dl_grant_t grant; - if (srslte_nbiot_dci_msg_to_dl_grant( + srsran_ra_nbiot_dl_dci_t dci_unpacked; + srsran_ra_nbiot_dl_grant_t grant; + if (srsran_nbiot_dci_msg_to_dl_grant( &dci_msg, rnti, &dci_unpacked, &grant, sfn, sf_idx, 64 /* fixme: remove */, cell.mode)) { fprintf(stderr, "Error unpacking DCI\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } dci_formatN1_detected++; // activate grant - srslte_nbiot_ue_dl_set_grant(&ue_dl, &grant); + srsran_nbiot_ue_dl_set_grant(&ue_dl, &grant); } else { fprintf(stderr, "Unsupported DCI format.\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } } @@ -298,7 +298,7 @@ int main(int argc, char** argv) #if DUMP_SIGNAL printf("Saving signal...\n"); - srslte_nb_ue_dl_save_signal(&ue_dl, &ue_dl.softbuffer, sf_idx); + srsran_nb_ue_dl_save_signal(&ue_dl, &ue_dl.softbuffer, sf_idx); #endif base_free(); @@ -309,19 +309,19 @@ int main(int argc, char** argv) // exit value depends on actual test // check if we are testing for correct DCI deconding - if (dci_format == SRSLTE_DCI_FORMATN0 || dci_format == SRSLTE_DCI_FORMATN1 || dci_format == SRSLTE_DCI_FORMATN2) { + if (dci_format == SRSRAN_DCI_FORMATN0 || dci_format == SRSRAN_DCI_FORMATN1 || dci_format == SRSRAN_DCI_FORMATN2) { // this is a DCI test, check if last DCI matches requested type if (last_dci_format == dci_format) { - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } else { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } // success if at least one NPDSCH could be decoded if (pkts_ok > 0) - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; // return error by default - return SRSLTE_ERROR; + return SRSRAN_ERROR; } diff --git a/lib/src/phy/phch/test/npdsch_test.c b/lib/src/phy/phch/test/npdsch_test.c index d1e4b31ff..6b04363b6 100644 --- a/lib/src/phy/phch/test/npdsch_test.c +++ b/lib/src/phy/phch/test/npdsch_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -17,27 +17,27 @@ #include #include -#include "srslte/phy/ch_estimation/chest_dl_nbiot.h" -#include "srslte/phy/ch_estimation/refsignal_dl.h" -#include "srslte/phy/ch_estimation/refsignal_dl_nbiot.h" -#include "srslte/phy/dft/ofdm.h" -#include "srslte/phy/io/filesource.h" -#include "srslte/phy/phch/npdsch.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/ch_estimation/chest_dl_nbiot.h" +#include "srsran/phy/ch_estimation/refsignal_dl.h" +#include "srsran/phy/ch_estimation/refsignal_dl_nbiot.h" +#include "srsran/phy/dft/ofdm.h" +#include "srsran/phy/io/filesource.h" +#include "srsran/phy/phch/npdsch.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" -#define SRSLTE_NBIOT_SFLEN SRSLTE_SF_LEN(srslte_symbol_sz(cell.base.nof_prb)) +#define SRSRAN_NBIOT_SFLEN SRSRAN_SF_LEN(srsran_symbol_sz(cell.base.nof_prb)) #define SFN 0 #define SF_IDX 1 -#define SRSLTE_NBIOT_NOF_RE_X_PRB (SRSLTE_CP_NORM_SF_NSYMB * SRSLTE_NRE) +#define SRSRAN_NBIOT_NOF_RE_X_PRB (SRSRAN_CP_NORM_SF_NSYMB * SRSRAN_NRE) // Enable to measure execution time //#define DO_OFDM uint32_t nof_ports_lte = 0; uint32_t nof_ports_nbiot = 1; -srslte_nbiot_mode_t mode = SRSLTE_NBIOT_MODE_INBAND_SAME_PCI; +srsran_nbiot_mode_t mode = SRSRAN_NBIOT_MODE_INBAND_SAME_PCI; uint32_t expected_nof_re = 0; uint32_t n_id_ncell = 0; @@ -62,7 +62,7 @@ void usage(char* prog) printf("\t-p Base cell cell nof_ports [Default %d]\n", nof_ports_lte); printf("\t-P NB-IoT cell nof_ports [Default %d]\n", nof_ports_nbiot); printf("\t-x Expected number of resource elements [Default %d]\n", expected_nof_re); - printf("\t-v [set srslte_verbose to debug, default none]\n"); + printf("\t-v [set srsran_verbose to debug, default none]\n"); } void parse_args(int argc, char** argv) @@ -101,7 +101,7 @@ void parse_args(int argc, char** argv) expected_nof_re = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'v': - srslte_verbose++; + srsran_verbose++; break; default: usage(argv[0]); @@ -113,23 +113,23 @@ void parse_args(int argc, char** argv) /* fills a list with RE indices containing either NRS or CRS given a particular cell configration * @return number of RE containing reference signals */ -int get_ref_res(srslte_nbiot_cell_t cell, int32_t* re_with_refs) +int get_ref_res(srsran_nbiot_cell_t cell, int32_t* re_with_refs) { - bzero(re_with_refs, SRSLTE_NBIOT_MAX_NUM_RE_WITH_REFS * sizeof(uint32_t)); + bzero(re_with_refs, SRSRAN_NBIOT_MAX_NUM_RE_WITH_REFS * sizeof(uint32_t)); uint32_t num_ref = 0; // add all RE that contain NRS for (int p = 0; p < cell.nof_ports; p++) { DEBUG("Adding NRS for port=%d n_id_ncell=%d", p, cell.n_id_ncell); - uint32_t nof_syms = srslte_refsignal_dl_nbiot_nof_symbols(p); + uint32_t nof_syms = srsran_refsignal_dl_nbiot_nof_symbols(p); for (int l = 0; l < nof_syms; l++) { - uint32_t nsymbol = srslte_refsignal_nrs_nsymbol(l); + uint32_t nsymbol = srsran_refsignal_nrs_nsymbol(l); DEBUG(" - adding NRS for symbol=%d", nsymbol); // two references per symbol - for (int m = 0; m < SRSLTE_NBIOT_NUM_NRS_X_SYM_X_PORT; m++) { - uint32_t fidx = srslte_refsignal_dl_nbiot_fidx(cell, l, p, m); - uint32_t re_idx = SRSLTE_RE_IDX(cell.base.nof_prb, nsymbol, fidx); + for (int m = 0; m < SRSRAN_NBIOT_NUM_NRS_X_SYM_X_PORT; m++) { + uint32_t fidx = srsran_refsignal_dl_nbiot_fidx(cell, l, p, m); + uint32_t re_idx = SRSRAN_RE_IDX(cell.base.nof_prb, nsymbol, fidx); DEBUG(" - adding NRS at re_idx=%d with fidx=%d", re_idx, fidx); re_with_refs[num_ref] = re_idx; num_ref++; @@ -140,15 +140,15 @@ int get_ref_res(srslte_nbiot_cell_t cell, int32_t* re_with_refs) // add all RE that contain CRS for (int p = 0; p < cell.base.nof_ports; p++) { DEBUG("Adding CRS for port=%d cell_id=%d", p, cell.base.id); - uint32_t nof_syms = srslte_refsignal_cs_nof_symbols(NULL, NULL, p); + uint32_t nof_syms = srsran_refsignal_cs_nof_symbols(NULL, NULL, p); for (int l = 0; l < nof_syms; l++) { - uint32_t nsymbol = srslte_refsignal_cs_nsymbol(l, cell.base.cp, p); + uint32_t nsymbol = srsran_refsignal_cs_nsymbol(l, cell.base.cp, p); DEBUG(" - adding CRS for symbol=%d", nsymbol); // two references per symbol for (int m = 0; m < 2; m++) { - uint32_t fidx = ((srslte_refsignal_cs_v(p, l) + (cell.base.id % 6)) % 6) + m * 6; - uint32_t re_idx = SRSLTE_RE_IDX(cell.base.nof_prb, nsymbol, fidx); + uint32_t fidx = ((srsran_refsignal_cs_v(p, l) + (cell.base.id % 6)) % 6) + m * 6; + uint32_t re_idx = SRSRAN_RE_IDX(cell.base.nof_prb, nsymbol, fidx); DEBUG(" - adding CRS at re_idx=%d with fidx=%d", re_idx, fidx); re_with_refs[num_ref] = re_idx; num_ref++; @@ -158,40 +158,40 @@ int get_ref_res(srslte_nbiot_cell_t cell, int32_t* re_with_refs) // print all RE's that contain references printf("RE that contain reference signals:\n"); - srslte_vec_fprint_i(stdout, re_with_refs, num_ref); + srsran_vec_fprint_i(stdout, re_with_refs, num_ref); return num_ref; } -int extract_re(srslte_nbiot_cell_t cell, uint32_t l_start, uint32_t expected_nof_re) +int extract_re(srsran_nbiot_cell_t cell, uint32_t l_start, uint32_t expected_nof_re) { - srslte_npdsch_t npdsch; - bzero(&npdsch, sizeof(srslte_npdsch_t)); + srsran_npdsch_t npdsch; + bzero(&npdsch, sizeof(srsran_npdsch_t)); npdsch.cell = cell; - if (!srslte_nbiot_cell_isvalid(&npdsch.cell)) { + if (!srsran_nbiot_cell_isvalid(&npdsch.cell)) { printf("cell is not properly configured\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // fill dummy values in RE - cf_t sf_syms[SRSLTE_NBIOT_NOF_RE_X_PRB]; - for (int i = 0; i < SRSLTE_NBIOT_NOF_RE_X_PRB; i++) { + cf_t sf_syms[SRSRAN_NBIOT_NOF_RE_X_PRB]; + for (int i = 0; i < SRSRAN_NBIOT_NOF_RE_X_PRB; i++) { sf_syms[i] = i; } - srslte_ra_nbiot_dl_grant_t dl_grant; - bzero(&dl_grant, sizeof(srslte_ra_nbiot_dl_grant_t)); + srsran_ra_nbiot_dl_grant_t dl_grant; + bzero(&dl_grant, sizeof(srsran_ra_nbiot_dl_grant_t)); dl_grant.l_start = l_start; - cf_t npdsch_syms[SRSLTE_NPDSCH_MAX_RE]; - int nof_ext_syms = srslte_npdsch_cp(&npdsch, sf_syms, npdsch_syms, &dl_grant, false); + cf_t npdsch_syms[SRSRAN_NPDSCH_MAX_RE]; + int nof_ext_syms = srsran_npdsch_cp(&npdsch, sf_syms, npdsch_syms, &dl_grant, false); #if 0 - if (SRSLTE_VERBOSE_ISDEBUG()) { + if (SRSRAN_VERBOSE_ISDEBUG()) { for (int i = 0; i < nof_ext_syms; i++) { printf("re%d:", i); - srslte_vec_fprint_c(stdout, &npdsch_syms[i], 1); + srsran_vec_fprint_c(stdout, &npdsch_syms[i], 1); } } #endif @@ -199,11 +199,11 @@ int extract_re(srslte_nbiot_cell_t cell, uint32_t l_start, uint32_t expected_nof // check number of extracted REs if (nof_ext_syms != expected_nof_re) { printf("RE extraction failed (expected %d, but got %d)!\n", expected_nof_re, nof_ext_syms); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // check that there are not REs containing NRS or CRS - int32_t re_with_refs[SRSLTE_NBIOT_MAX_NUM_RE_WITH_REFS]; + int32_t re_with_refs[SRSRAN_NBIOT_MAX_NUM_RE_WITH_REFS]; int num_re_with_refs = get_ref_res(cell, re_with_refs); // for each extracted data symbol, check if it collides with a reference signal @@ -211,13 +211,13 @@ int extract_re(srslte_nbiot_cell_t cell, uint32_t l_start, uint32_t expected_nof for (int l = 0; l < nof_ext_syms; l++) { if (npdsch_syms[l] == re_with_refs[i]) { printf("Extracted data RE is also a reference signal %d: ", l); - srslte_vec_fprint_c(stdout, &npdsch_syms[l], 1); - return SRSLTE_ERROR; + srsran_vec_fprint_c(stdout, &npdsch_syms[l], 1); + return SRSRAN_ERROR; } } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int re_extract_test(int argc, char** argv) @@ -226,156 +226,156 @@ int re_extract_test(int argc, char** argv) if (expected_nof_re == 0) { printf("Skipping RE extraction test because number of expected REs isn't given!\n"); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } - srslte_nbiot_cell_t cell = {}; + srsran_nbiot_cell_t cell = {}; // Standalone mode with l_start=0 gives the maximum number of REs cell.mode = mode; cell.base.nof_prb = 1; - cell.base.id = (mode == SRSLTE_NBIOT_MODE_INBAND_SAME_PCI) ? n_id_ncell : rand() % SRSLTE_NUM_PCI; + cell.base.id = (mode == SRSRAN_NBIOT_MODE_INBAND_SAME_PCI) ? n_id_ncell : rand() % SRSRAN_NUM_PCI; cell.n_id_ncell = n_id_ncell; cell.nof_ports = nof_ports_nbiot; cell.base.nof_ports = nof_ports_lte; uint32_t l_start = 0; - if (extract_re(cell, l_start, expected_nof_re) != SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (extract_re(cell, l_start, expected_nof_re) != SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int coding_test(int argc, char** argv) { - int ret = SRSLTE_ERROR; + int ret = SRSRAN_ERROR; struct timeval t[3]; - srslte_ra_nbiot_dl_grant_t grant; - srslte_npdsch_cfg_t npdsch_cfg; - srslte_npdsch_t npdsch; + srsran_ra_nbiot_dl_grant_t grant; + srsran_npdsch_cfg_t npdsch_cfg; + srsran_npdsch_t npdsch; uint8_t* data = NULL; uint8_t* rx_data = NULL; - cf_t* ce[SRSLTE_MAX_PORTS] = {NULL}; + cf_t* ce[SRSRAN_MAX_PORTS] = {NULL}; cf_t* sf_symbols = NULL; - cf_t* slot_symbols[SRSLTE_MAX_PORTS] = {NULL}; - srslte_ofdm_t ofdm_tx, ofdm_rx; + cf_t* slot_symbols[SRSRAN_MAX_PORTS] = {NULL}; + srsran_ofdm_t ofdm_tx, ofdm_rx; parse_args(argc, argv); // setup cell config for this test - srslte_nbiot_cell_t cell = {}; + srsran_nbiot_cell_t cell = {}; cell.base.nof_prb = 1; - cell.base.cp = SRSLTE_CP_NORM; + cell.base.cp = SRSRAN_CP_NORM; cell.base.nof_ports = 1; cell.nof_ports = 1; - cell.mode = SRSLTE_NBIOT_MODE_STANDALONE; + cell.mode = SRSRAN_NBIOT_MODE_STANDALONE; cell.n_id_ncell = n_id_ncell; - if (!srslte_nbiot_cell_isvalid(&cell)) { + if (!srsran_nbiot_cell_isvalid(&cell)) { printf("Cell is not properly configured\n"); return ret; } - bzero(&npdsch, sizeof(srslte_npdsch_t)); - bzero(&npdsch_cfg, sizeof(srslte_npdsch_cfg_t)); - bzero(ce, sizeof(cf_t*) * SRSLTE_MAX_PORTS); - bzero(slot_symbols, sizeof(cf_t*) * SRSLTE_MAX_PORTS); + bzero(&npdsch, sizeof(srsran_npdsch_t)); + bzero(&npdsch_cfg, sizeof(srsran_npdsch_cfg_t)); + bzero(ce, sizeof(cf_t*) * SRSRAN_MAX_PORTS); + bzero(slot_symbols, sizeof(cf_t*) * SRSRAN_MAX_PORTS); - srslte_ra_nbiot_dl_dci_t dci; - bzero(&dci, sizeof(srslte_ra_nbiot_dl_dci_t)); + srsran_ra_nbiot_dl_dci_t dci; + bzero(&dci, sizeof(srsran_ra_nbiot_dl_dci_t)); dci.mcs_idx = i_tbs_val; dci.rv_idx = rv_idx; - if (srslte_ra_nbiot_dl_dci_to_grant(&dci, &grant, SFN, SF_IDX, DUMMY_R_MAX, false, cell.mode)) { + if (srsran_ra_nbiot_dl_dci_to_grant(&dci, &grant, SFN, SF_IDX, DUMMY_R_MAX, false, cell.mode)) { fprintf(stderr, "Error computing resource allocation\n"); return ret; } - if (!srslte_nbiot_cell_isvalid(&cell)) { + if (!srsran_nbiot_cell_isvalid(&cell)) { fprintf(stderr, "Cell configuration invalid.\n"); exit(-1); } /* Configure NPDSCH */ - if (srslte_npdsch_cfg(&npdsch_cfg, cell, &grant, subframe)) { + if (srsran_npdsch_cfg(&npdsch_cfg, cell, &grant, subframe)) { fprintf(stderr, "Error configuring NPDSCH\n"); exit(-1); } /* init memory */ - for (int i = 0; i < SRSLTE_MAX_PORTS; i++) { - ce[i] = srslte_vec_malloc(sizeof(cf_t) * SRSLTE_SF_LEN_RE(cell.base.nof_prb, cell.base.cp)); + for (int i = 0; i < SRSRAN_MAX_PORTS; i++) { + ce[i] = srsran_vec_malloc(sizeof(cf_t) * SRSRAN_SF_LEN_RE(cell.base.nof_prb, cell.base.cp)); if (!ce[i]) { - perror("srslte_vec_malloc"); + perror("srsran_vec_malloc"); goto quit; } - for (int j = 0; j < SRSLTE_SF_LEN_RE(cell.base.nof_prb, cell.base.cp); j++) { + for (int j = 0; j < SRSRAN_SF_LEN_RE(cell.base.nof_prb, cell.base.cp); j++) { ce[i][j] = 1; } - slot_symbols[i] = srslte_vec_malloc(sizeof(cf_t) * SRSLTE_SF_LEN_RE(cell.base.nof_prb, cell.base.cp)); + slot_symbols[i] = srsran_vec_malloc(sizeof(cf_t) * SRSRAN_SF_LEN_RE(cell.base.nof_prb, cell.base.cp)); if (!slot_symbols[i]) { - perror("srslte_vec_malloc"); + perror("srsran_vec_malloc"); goto quit; } - memset(slot_symbols[i], 0, sizeof(cf_t) * SRSLTE_SF_LEN_RE(cell.base.nof_prb, cell.base.cp)); + memset(slot_symbols[i], 0, sizeof(cf_t) * SRSRAN_SF_LEN_RE(cell.base.nof_prb, cell.base.cp)); } - sf_symbols = srslte_vec_malloc(sizeof(cf_t) * SRSLTE_NBIOT_SFLEN); - memset(sf_symbols, 0, sizeof(cf_t) * SRSLTE_NBIOT_SFLEN); + sf_symbols = srsran_vec_malloc(sizeof(cf_t) * SRSRAN_NBIOT_SFLEN); + memset(sf_symbols, 0, sizeof(cf_t) * SRSRAN_NBIOT_SFLEN); - data = srslte_vec_malloc(sizeof(uint8_t) * grant.mcs[0].tbs / 8); + data = srsran_vec_malloc(sizeof(uint8_t) * grant.mcs[0].tbs / 8); if (!data) { - perror("srslte_vec_malloc"); + perror("srsran_vec_malloc"); goto quit; } - rx_data = srslte_vec_malloc(sizeof(uint8_t) * grant.mcs[0].tbs / 8); + rx_data = srsran_vec_malloc(sizeof(uint8_t) * grant.mcs[0].tbs / 8); if (!rx_data) { - perror("srslte_vec_malloc"); + perror("srsran_vec_malloc"); goto quit; } - srslte_ofdm_tx_init(&ofdm_tx, cell.base.cp, slot_symbols[0], sf_symbols, cell.base.nof_prb); - srslte_ofdm_rx_init(&ofdm_rx, cell.base.cp, sf_symbols, slot_symbols[0], cell.base.nof_prb); + srsran_ofdm_tx_init(&ofdm_tx, cell.base.cp, slot_symbols[0], sf_symbols, cell.base.nof_prb); + srsran_ofdm_rx_init(&ofdm_rx, cell.base.cp, sf_symbols, slot_symbols[0], cell.base.nof_prb); - if (srslte_npdsch_init(&npdsch)) { + if (srsran_npdsch_init(&npdsch)) { fprintf(stderr, "Error creating NPDSCH object\n"); goto quit; } - if (srslte_npdsch_set_cell(&npdsch, cell)) { + if (srsran_npdsch_set_cell(&npdsch, cell)) { fprintf(stderr, "Error configuring NPDSCH object\n"); goto quit; } - srslte_npdsch_set_rnti(&npdsch, rnti); + srsran_npdsch_set_rnti(&npdsch, rnti); if (input_file) { - srslte_filesource_t fsrc; - if (srslte_filesource_init(&fsrc, input_file, SRSLTE_COMPLEX_FLOAT_BIN)) { + srsran_filesource_t fsrc; + if (srsran_filesource_init(&fsrc, input_file, SRSRAN_COMPLEX_FLOAT_BIN)) { fprintf(stderr, "Error opening file %s\n", input_file); exit(-1); } #ifdef DO_OFDM - srslte_filesource_read(&fsrc, sf_symbols, SRSLTE_SF_LEN_PRB(cell.base.nof_prb)); + srsran_filesource_read(&fsrc, sf_symbols, SRSRAN_SF_LEN_PRB(cell.base.nof_prb)); #else - srslte_filesource_read(&fsrc, slot_symbols[0], SRSLTE_SF_LEN_RE(cell.base.nof_prb, cell.base.cp)); + srsran_filesource_read(&fsrc, slot_symbols[0], SRSRAN_SF_LEN_RE(cell.base.nof_prb, cell.base.cp)); #endif - srslte_chest_dl_nbiot_t chest; - if (srslte_chest_dl_nbiot_init(&chest, SRSLTE_NBIOT_MAX_PRB)) { + srsran_chest_dl_nbiot_t chest; + if (srsran_chest_dl_nbiot_init(&chest, SRSRAN_NBIOT_MAX_PRB)) { printf("Error initializing equalizer\n"); exit(-1); } - if (srslte_chest_dl_nbiot_set_cell(&chest, cell) != SRSLTE_SUCCESS) { + if (srsran_chest_dl_nbiot_set_cell(&chest, cell) != SRSRAN_SUCCESS) { fprintf(stderr, "Error setting channel estimator's cell configuration\n"); return -1; } - srslte_chest_dl_nbiot_estimate(&chest, slot_symbols[0], ce, subframe); - srslte_chest_dl_nbiot_free(&chest); + srsran_chest_dl_nbiot_estimate(&chest, slot_symbols[0], ce, subframe); + srsran_chest_dl_nbiot_free(&chest); - srslte_filesource_free(&fsrc); + srsran_filesource_free(&fsrc); } // generate random data @@ -385,7 +385,7 @@ int coding_test(int argc, char** argv) } if (!input_file) { - if (srslte_npdsch_encode(&npdsch, &npdsch_cfg, NULL, data, slot_symbols)) { + if (srsran_npdsch_encode(&npdsch, &npdsch_cfg, NULL, data, slot_symbols)) { fprintf(stderr, "Error encoding NPDSCH\n"); goto quit; } @@ -393,12 +393,12 @@ int coding_test(int argc, char** argv) #ifdef DO_OFDM // Transform to OFDM symbols - srslte_ofdm_tx_sf(&ofdm_tx); + srsran_ofdm_tx_sf(&ofdm_tx); #endif - if (SRSLTE_VERBOSE_ISDEBUG()) { + if (SRSRAN_VERBOSE_ISDEBUG()) { DEBUG("SAVED FILE npdsch_tx_sf.bin: transmitted subframe symbols"); - srslte_vec_save_file("npdsch_tx_sf.bin", sf_symbols, SRSLTE_NBIOT_SFLEN * sizeof(cf_t)); + srsran_vec_save_file("npdsch_tx_sf.bin", sf_symbols, SRSRAN_NBIOT_SFLEN * sizeof(cf_t)); } int M = 1; @@ -407,18 +407,18 @@ int coding_test(int argc, char** argv) for (int i = 0; i < M; i++) { #ifdef DO_OFDM - srslte_ofdm_rx_sf(&ofdm_rx); + srsran_ofdm_rx_sf(&ofdm_rx); #endif - r = srslte_npdsch_decode(&npdsch, &npdsch_cfg, NULL, slot_symbols[0], ce, 0, 0, rx_data); + r = srsran_npdsch_decode(&npdsch, &npdsch_cfg, NULL, slot_symbols[0], ce, 0, 0, rx_data); } gettimeofday(&t[2], NULL); get_time_interval(t); // compare transmitted and received data printf("Tx payload: "); - srslte_vec_fprint_b(stdout, data, grant.mcs[0].tbs / 8); + srsran_vec_fprint_b(stdout, data, grant.mcs[0].tbs / 8); printf("Rx payload: "); - srslte_vec_fprint_b(stdout, rx_data, grant.mcs[0].tbs / 8); + srsran_vec_fprint_b(stdout, rx_data, grant.mcs[0].tbs / 8); if (memcmp(data, rx_data, sizeof(uint8_t) * grant.mcs[0].tbs / 8) == 0) { printf("DECODED in %.2f (PHY bitrate=%.2f Mbps. Processing bitrate=%.2f Mbps)\n", @@ -429,15 +429,15 @@ int coding_test(int argc, char** argv) printf("Error!\n"); } if (r) { - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; goto quit; } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; quit: - srslte_npdsch_free(&npdsch); + srsran_npdsch_free(&npdsch); - for (int i = 0; i < SRSLTE_MAX_PORTS; i++) { + for (int i = 0; i < SRSRAN_MAX_PORTS; i++) { if (ce[i]) { free(ce[i]); } @@ -456,25 +456,25 @@ quit: free(sf_symbols); } - srslte_ofdm_tx_free(&ofdm_tx); - srslte_ofdm_rx_free(&ofdm_rx); + srsran_ofdm_tx_free(&ofdm_tx); + srsran_ofdm_rx_free(&ofdm_rx); return ret; } int main(int argc, char** argv) { - int ret = SRSLTE_ERROR; + int ret = SRSRAN_ERROR; - if (re_extract_test(argc, argv) != SRSLTE_SUCCESS) { + if (re_extract_test(argc, argv) != SRSRAN_SUCCESS) { printf("Resource element extraction test failed!\n"); return ret; } - if (coding_test(argc, argv) != SRSLTE_SUCCESS) { + if (coding_test(argc, argv) != SRSRAN_SUCCESS) { printf("NPDSCH En- and Decoding test failed!\n"); return ret; } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; return ret; } diff --git a/lib/src/phy/phch/test/pbch_file_test.c b/lib/src/phy/phch/test/pbch_file_test.c index f83ebebed..be7cc06ed 100644 --- a/lib/src/phy/phch/test/pbch_file_test.c +++ b/lib/src/phy/phch/test/pbch_file_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -16,34 +16,34 @@ #include #include -#include "srslte/srslte.h" +#include "srsran/srsran.h" char* input_file_name = NULL; -srslte_cell_t cell = { +srsran_cell_t cell = { 6, // nof_prb 2, // nof_ports 150, // cell_id - SRSLTE_CP_NORM, // cyclic prefix - SRSLTE_PHICH_NORM, // PHICH length - SRSLTE_PHICH_R_1, // PHICH resources - SRSLTE_FDD, + SRSRAN_CP_NORM, // cyclic prefix + SRSRAN_PHICH_NORM, // PHICH length + SRSRAN_PHICH_R_1, // PHICH resources + SRSRAN_FDD, }; int nof_frames = 1; -uint8_t bch_payload_file[SRSLTE_BCH_PAYLOAD_LEN] = {0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, +uint8_t bch_payload_file[SRSRAN_BCH_PAYLOAD_LEN] = {0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; -#define FLEN (10 * SRSLTE_SF_LEN(srslte_symbol_sz(cell.nof_prb))) +#define FLEN (10 * SRSRAN_SF_LEN(srsran_symbol_sz(cell.nof_prb))) -srslte_filesource_t fsrc; -cf_t * input_buffer, *fft_buffer[SRSLTE_MAX_CODEWORDS]; -srslte_pbch_t pbch; -srslte_ofdm_t fft; -srslte_chest_dl_t chest; -srslte_chest_dl_res_t chest_res; +srsran_filesource_t fsrc; +cf_t * input_buffer, *fft_buffer[SRSRAN_MAX_CODEWORDS]; +srsran_pbch_t pbch; +srsran_ofdm_t fft; +srsran_chest_dl_t chest; +srsran_chest_dl_res_t chest_res; void usage(char* prog) { @@ -52,7 +52,7 @@ void usage(char* prog) printf("\t-p nof_prb [Default %d]\n", cell.nof_prb); printf("\t-e Set extended prefix [Default Normal]\n"); printf("\t-n nof_frames [Default %d]\n", nof_frames); - printf("\t-v [set srslte_verbose to debug, default none]\n"); + printf("\t-v [set srsran_verbose to debug, default none]\n"); } void parse_args(int argc, char** argv) @@ -74,10 +74,10 @@ void parse_args(int argc, char** argv) nof_frames = (int)strtol(argv[optind], NULL, 10); break; case 'v': - srslte_verbose++; + srsran_verbose++; break; case 'e': - cell.cp = SRSLTE_CP_EXT; + cell.cp = SRSRAN_CP_EXT; break; default: usage(argv[0]); @@ -92,51 +92,51 @@ void parse_args(int argc, char** argv) int base_init() { - if (srslte_filesource_init(&fsrc, input_file_name, SRSLTE_COMPLEX_FLOAT_BIN)) { + if (srsran_filesource_init(&fsrc, input_file_name, SRSRAN_COMPLEX_FLOAT_BIN)) { ERROR("Error opening file %s", input_file_name); exit(-1); } - input_buffer = srslte_vec_cf_malloc(FLEN); + input_buffer = srsran_vec_cf_malloc(FLEN); if (!input_buffer) { perror("malloc"); exit(-1); } - fft_buffer[0] = srslte_vec_cf_malloc(SRSLTE_NOF_RE(cell)); + fft_buffer[0] = srsran_vec_cf_malloc(SRSRAN_NOF_RE(cell)); if (!fft_buffer[0]) { perror("malloc"); return -1; } - if (!srslte_cell_isvalid(&cell)) { + if (!srsran_cell_isvalid(&cell)) { ERROR("Invalid cell properties"); return -1; } - if (srslte_chest_dl_init(&chest, cell.nof_prb, 1)) { + if (srsran_chest_dl_init(&chest, cell.nof_prb, 1)) { ERROR("Error initializing equalizer"); return -1; } - if (srslte_chest_dl_res_init(&chest_res, cell.nof_prb)) { + if (srsran_chest_dl_res_init(&chest_res, cell.nof_prb)) { ERROR("Error initializing equalizer"); return -1; } - if (srslte_chest_dl_set_cell(&chest, cell)) { + if (srsran_chest_dl_set_cell(&chest, cell)) { ERROR("Error initializing equalizer"); return -1; } - if (srslte_ofdm_rx_init(&fft, cell.cp, input_buffer, fft_buffer[0], cell.nof_prb)) { + if (srsran_ofdm_rx_init(&fft, cell.cp, input_buffer, fft_buffer[0], cell.nof_prb)) { ERROR("Error initializing FFT"); return -1; } - if (srslte_pbch_init(&pbch)) { + if (srsran_pbch_init(&pbch)) { ERROR("Error initiating PBCH"); return -1; } - if (srslte_pbch_set_cell(&pbch, cell)) { + if (srsran_pbch_set_cell(&pbch, cell)) { ERROR("Error initiating PBCH"); return -1; } @@ -147,22 +147,22 @@ int base_init() void base_free() { - srslte_filesource_free(&fsrc); + srsran_filesource_free(&fsrc); free(input_buffer); free(fft_buffer[0]); - srslte_filesource_free(&fsrc); - srslte_chest_dl_res_free(&chest_res); - srslte_chest_dl_free(&chest); - srslte_ofdm_rx_free(&fft); + srsran_filesource_free(&fsrc); + srsran_chest_dl_res_free(&chest_res); + srsran_chest_dl_free(&chest); + srsran_ofdm_rx_free(&fft); - srslte_pbch_free(&pbch); + srsran_pbch_free(&pbch); } int main(int argc, char** argv) { - uint8_t bch_payload[SRSLTE_BCH_PAYLOAD_LEN]; + uint8_t bch_payload[SRSRAN_BCH_PAYLOAD_LEN]; int n; uint32_t nof_tx_ports; int sfn_offset; @@ -183,22 +183,22 @@ int main(int argc, char** argv) int nof_decoded_mibs = 0; int nread = 0; do { - nread = srslte_filesource_read(&fsrc, input_buffer, FLEN); + nread = srsran_filesource_read(&fsrc, input_buffer, FLEN); if (nread > 0) { // process 1st subframe only - srslte_ofdm_rx_sf(&fft); + srsran_ofdm_rx_sf(&fft); - srslte_dl_sf_cfg_t dl_sf; + srsran_dl_sf_cfg_t dl_sf; ZERO_OBJECT(dl_sf); /* Get channel estimates for each port */ - srslte_chest_dl_estimate(&chest, &dl_sf, fft_buffer, &chest_res); + srsran_chest_dl_estimate(&chest, &dl_sf, fft_buffer, &chest_res); INFO("Decoding PBCH"); - srslte_pbch_decode_reset(&pbch); - n = srslte_pbch_decode(&pbch, &chest_res, fft_buffer, bch_payload, &nof_tx_ports, &sfn_offset); + srsran_pbch_decode_reset(&pbch); + n = srsran_pbch_decode(&pbch, &chest_res, fft_buffer, bch_payload, &nof_tx_ports, &sfn_offset); if (n == 1) { nof_decoded_mibs++; @@ -221,8 +221,8 @@ int main(int argc, char** argv) exit(-1); } else { printf("MIB decoded OK. Nof ports: %d. SFN offset: %d Payload: ", nof_tx_ports, sfn_offset); - srslte_vec_fprint_hex(stdout, bch_payload, SRSLTE_BCH_PAYLOAD_LEN); - if (nof_tx_ports == 2 && sfn_offset == 0 && !memcmp(bch_payload, bch_payload_file, SRSLTE_BCH_PAYLOAD_LEN)) { + srsran_vec_fprint_hex(stdout, bch_payload, SRSRAN_BCH_PAYLOAD_LEN); + if (nof_tx_ports == 2 && sfn_offset == 0 && !memcmp(bch_payload, bch_payload_file, SRSRAN_BCH_PAYLOAD_LEN)) { printf("This is the signal.1.92M.dat file\n"); exit(0); } else { diff --git a/lib/src/phy/phch/test/pbch_test.c b/lib/src/phy/phch/test/pbch_test.c index 546ef3866..4c0d7b8f9 100644 --- a/lib/src/phy/phch/test/pbch_test.c +++ b/lib/src/phy/phch/test/pbch_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -17,16 +17,16 @@ #include #include -#include "srslte/srslte.h" +#include "srsran/srsran.h" -srslte_cell_t cell = { +srsran_cell_t cell = { 6, // nof_prb 1, // nof_ports 1, // cell_id - SRSLTE_CP_NORM, // cyclic prefix - SRSLTE_PHICH_NORM, // PHICH length - SRSLTE_PHICH_R_1, // PHICH resources - SRSLTE_FDD, + SRSRAN_CP_NORM, // cyclic prefix + SRSRAN_PHICH_NORM, // PHICH length + SRSRAN_PHICH_R_1, // PHICH resources + SRSRAN_FDD, }; @@ -36,7 +36,7 @@ void usage(char* prog) printf("\t-c cell id [Default %d]\n", cell.id); printf("\t-p cell.nof_ports [Default %d]\n", cell.nof_ports); printf("\t-n cell.nof_prb [Default %d]\n", cell.nof_prb); - printf("\t-v [set srslte_verbose to debug, default none]\n"); + printf("\t-v [set srsran_verbose to debug, default none]\n"); } void parse_args(int argc, char** argv) @@ -54,7 +54,7 @@ void parse_args(int argc, char** argv) cell.id = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'v': - srslte_verbose++; + srsran_verbose++; break; default: usage(argv[0]); @@ -65,47 +65,47 @@ void parse_args(int argc, char** argv) int main(int argc, char** argv) { - srslte_chest_dl_res_t chest_dl_res; - srslte_pbch_t pbch; - uint8_t bch_payload_tx[SRSLTE_BCH_PAYLOAD_LEN], bch_payload_rx[SRSLTE_BCH_PAYLOAD_LEN]; + srsran_chest_dl_res_t chest_dl_res; + srsran_pbch_t pbch; + uint8_t bch_payload_tx[SRSRAN_BCH_PAYLOAD_LEN], bch_payload_rx[SRSRAN_BCH_PAYLOAD_LEN]; int i, j, k; int nof_re; - cf_t* sf_symbols[SRSLTE_MAX_PORTS]; + cf_t* sf_symbols[SRSRAN_MAX_PORTS]; uint32_t nof_rx_ports; parse_args(argc, argv); - nof_re = SRSLTE_SF_LEN_RE(cell.nof_prb, SRSLTE_CP_NORM); + nof_re = SRSRAN_SF_LEN_RE(cell.nof_prb, SRSRAN_CP_NORM); /* init memory */ - srslte_chest_dl_res_init(&chest_dl_res, cell.nof_prb); + srsran_chest_dl_res_init(&chest_dl_res, cell.nof_prb); for (i = 0; i < cell.nof_ports; i++) { for (j = 0; j < cell.nof_ports; j++) { for (k = 0; k < nof_re; k++) { chest_dl_res.ce[i][j][k] = 1; } } - sf_symbols[i] = srslte_vec_cf_malloc(nof_re); + sf_symbols[i] = srsran_vec_cf_malloc(nof_re); if (!sf_symbols[i]) { perror("malloc"); exit(-1); } } - if (srslte_pbch_init(&pbch)) { + if (srsran_pbch_init(&pbch)) { ERROR("Error creating PBCH object"); exit(-1); } - if (srslte_pbch_set_cell(&pbch, cell)) { + if (srsran_pbch_set_cell(&pbch, cell)) { ERROR("Error creating PBCH object"); exit(-1); } srand(time(NULL)); - for (i = 0; i < SRSLTE_BCH_PAYLOAD_LEN; i++) { + for (i = 0; i < SRSRAN_BCH_PAYLOAD_LEN; i++) { bch_payload_tx[i] = rand() % 2; } - srslte_pbch_encode(&pbch, bch_payload_tx, sf_symbols, 0); + srsran_pbch_encode(&pbch, bch_payload_tx, sf_symbols, 0); /* combine outputs */ for (i = 1; i < cell.nof_ports; i++) { @@ -114,28 +114,28 @@ int main(int argc, char** argv) } } - srslte_pbch_decode_reset(&pbch); - if (1 != srslte_pbch_decode(&pbch, &chest_dl_res, sf_symbols, bch_payload_rx, &nof_rx_ports, NULL)) { + srsran_pbch_decode_reset(&pbch); + if (1 != srsran_pbch_decode(&pbch, &chest_dl_res, sf_symbols, bch_payload_rx, &nof_rx_ports, NULL)) { printf("Error decoding\n"); exit(-1); } - srslte_pbch_free(&pbch); + srsran_pbch_free(&pbch); for (i = 0; i < cell.nof_ports; i++) { free(sf_symbols[i]); } - srslte_chest_dl_res_free(&chest_dl_res); + srsran_chest_dl_res_free(&chest_dl_res); printf("Tx ports: %d - Rx ports: %d\n", cell.nof_ports, nof_rx_ports); printf("Tx payload: "); - srslte_vec_fprint_hex(stdout, bch_payload_tx, SRSLTE_BCH_PAYLOAD_LEN); + srsran_vec_fprint_hex(stdout, bch_payload_tx, SRSRAN_BCH_PAYLOAD_LEN); printf("Rx payload: "); - srslte_vec_fprint_hex(stdout, bch_payload_rx, SRSLTE_BCH_PAYLOAD_LEN); + srsran_vec_fprint_hex(stdout, bch_payload_rx, SRSRAN_BCH_PAYLOAD_LEN); if (nof_rx_ports == cell.nof_ports && - !memcmp(bch_payload_rx, bch_payload_tx, sizeof(uint8_t) * SRSLTE_BCH_PAYLOAD_LEN)) { + !memcmp(bch_payload_rx, bch_payload_tx, sizeof(uint8_t) * SRSRAN_BCH_PAYLOAD_LEN)) { printf("OK\n"); exit(0); } else { diff --git a/lib/src/phy/phch/test/pcfich_file_test.c b/lib/src/phy/phch/test/pcfich_file_test.c index f8e7ca0cb..8622d373d 100644 --- a/lib/src/phy/phch/test/pcfich_file_test.c +++ b/lib/src/phy/phch/test/pcfich_file_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -16,29 +16,29 @@ #include #include -#include "srslte/srslte.h" +#include "srsran/srsran.h" char* input_file_name = NULL; char* matlab_file_name = NULL; -srslte_cell_t cell = {.nof_prb = 6, +srsran_cell_t cell = {.nof_prb = 6, .nof_ports = 1, - .cp = SRSLTE_CP_NORM, - .phich_length = SRSLTE_PHICH_NORM, - .phich_resources = SRSLTE_PHICH_R_1, - .frame_type = SRSLTE_FDD}; + .cp = SRSRAN_CP_NORM, + .phich_length = SRSRAN_PHICH_NORM, + .phich_resources = SRSRAN_PHICH_R_1, + .frame_type = SRSRAN_FDD}; int flen; FILE* fmatlab = NULL; -srslte_filesource_t fsrc; -cf_t * input_buffer, *fft_buffer[SRSLTE_MAX_CODEWORDS]; -srslte_pcfich_t pcfich; -srslte_regs_t regs; -srslte_ofdm_t fft; -srslte_chest_dl_t chest; -srslte_chest_dl_res_t chest_res; +srsran_filesource_t fsrc; +cf_t * input_buffer, *fft_buffer[SRSRAN_MAX_CODEWORDS]; +srsran_pcfich_t pcfich; +srsran_regs_t regs; +srsran_ofdm_t fft; +srsran_chest_dl_t chest; +srsran_chest_dl_res_t chest_res; bool use_standard_lte_rates = false; void usage(char* prog) @@ -50,7 +50,7 @@ void usage(char* prog) printf("\t-n cell.nof_prb [Default %d]\n", cell.nof_prb); printf("\t-e Set extended prefix [Default Normal]\n"); printf("\n-d Use standard LTE rates [Default No]\n"); - printf("\t-v [set srslte_verbose to debug, default none]\n"); + printf("\t-v [set srsran_verbose to debug, default none]\n"); } void parse_args(int argc, char** argv) @@ -77,10 +77,10 @@ void parse_args(int argc, char** argv) matlab_file_name = argv[optind]; break; case 'v': - srslte_verbose++; + srsran_verbose++; break; case 'e': - cell.cp = SRSLTE_CP_EXT; + cell.cp = SRSRAN_CP_EXT; break; default: usage(argv[0]); @@ -95,9 +95,9 @@ void parse_args(int argc, char** argv) int base_init() { - srslte_use_standard_symbol_size(use_standard_lte_rates); + srsran_use_standard_symbol_size(use_standard_lte_rates); - if (srslte_filesource_init(&fsrc, input_file_name, SRSLTE_COMPLEX_FLOAT_BIN)) { + if (srsran_filesource_init(&fsrc, input_file_name, SRSRAN_COMPLEX_FLOAT_BIN)) { ERROR("Error opening file %s", input_file_name); exit(-1); } @@ -112,48 +112,48 @@ int base_init() fmatlab = NULL; } - flen = SRSLTE_SF_LEN(srslte_symbol_sz(cell.nof_prb)); + flen = SRSRAN_SF_LEN(srsran_symbol_sz(cell.nof_prb)); - input_buffer = srslte_vec_cf_malloc(flen); + input_buffer = srsran_vec_cf_malloc(flen); if (!input_buffer) { perror("malloc"); exit(-1); } - fft_buffer[0] = srslte_vec_cf_malloc(SRSLTE_NOF_RE(cell)); + fft_buffer[0] = srsran_vec_cf_malloc(SRSRAN_NOF_RE(cell)); if (!fft_buffer[0]) { perror("malloc"); return -1; } - if (srslte_chest_dl_init(&chest, cell.nof_prb, 1)) { + if (srsran_chest_dl_init(&chest, cell.nof_prb, 1)) { ERROR("Error initializing equalizer"); return -1; } - if (srslte_chest_dl_res_init(&chest_res, cell.nof_prb)) { + if (srsran_chest_dl_res_init(&chest_res, cell.nof_prb)) { ERROR("Error initializing equalizer"); return -1; } - if (srslte_chest_dl_set_cell(&chest, cell)) { + if (srsran_chest_dl_set_cell(&chest, cell)) { ERROR("Error initializing equalizer"); return -1; } - if (srslte_ofdm_rx_init(&fft, cell.cp, input_buffer, fft_buffer[0], cell.nof_prb)) { + if (srsran_ofdm_rx_init(&fft, cell.cp, input_buffer, fft_buffer[0], cell.nof_prb)) { ERROR("Error initializing FFT"); return -1; } - if (srslte_regs_init(®s, cell)) { + if (srsran_regs_init(®s, cell)) { ERROR("Error initiating REGs"); return -1; } - if (srslte_pcfich_init(&pcfich, 1)) { + if (srsran_pcfich_init(&pcfich, 1)) { ERROR("Error creating PBCH object"); return -1; } - if (srslte_pcfich_set_cell(&pcfich, ®s, cell)) { + if (srsran_pcfich_set_cell(&pcfich, ®s, cell)) { ERROR("Error creating PBCH object"); return -1; } @@ -164,7 +164,7 @@ int base_init() void base_free() { - srslte_filesource_free(&fsrc); + srsran_filesource_free(&fsrc); if (fmatlab) { fclose(fmatlab); } @@ -172,14 +172,14 @@ void base_free() free(input_buffer); free(fft_buffer[0]); - srslte_filesource_free(&fsrc); + srsran_filesource_free(&fsrc); - srslte_chest_dl_res_free(&chest_res); - srslte_chest_dl_free(&chest); - srslte_ofdm_rx_free(&fft); + srsran_chest_dl_res_free(&chest_res); + srsran_chest_dl_free(&chest); + srsran_ofdm_rx_free(&fft); - srslte_pcfich_free(&pcfich); - srslte_regs_free(®s); + srsran_pcfich_free(&pcfich); + srsran_regs_free(®s); } int main(int argc, char** argv) @@ -199,37 +199,37 @@ int main(int argc, char** argv) exit(-1); } - n = srslte_filesource_read(&fsrc, input_buffer, flen); + n = srsran_filesource_read(&fsrc, input_buffer, flen); - srslte_ofdm_rx_sf(&fft); + srsran_ofdm_rx_sf(&fft); if (fmatlab) { fprintf(fmatlab, "infft="); - srslte_vec_fprint_c(fmatlab, input_buffer, flen); + srsran_vec_fprint_c(fmatlab, input_buffer, flen); fprintf(fmatlab, ";\n"); fprintf(fmatlab, "outfft="); - srslte_vec_sc_prod_cfc(fft_buffer[0], 1000.0, fft_buffer[0], SRSLTE_CP_NSYMB(cell.cp) * cell.nof_prb * SRSLTE_NRE); - srslte_vec_fprint_c(fmatlab, fft_buffer[0], SRSLTE_CP_NSYMB(cell.cp) * cell.nof_prb * SRSLTE_NRE); + srsran_vec_sc_prod_cfc(fft_buffer[0], 1000.0, fft_buffer[0], SRSRAN_CP_NSYMB(cell.cp) * cell.nof_prb * SRSRAN_NRE); + srsran_vec_fprint_c(fmatlab, fft_buffer[0], SRSRAN_CP_NSYMB(cell.cp) * cell.nof_prb * SRSRAN_NRE); fprintf(fmatlab, ";\n"); - srslte_vec_sc_prod_cfc(fft_buffer[0], 0.001, fft_buffer[0], SRSLTE_CP_NSYMB(cell.cp) * cell.nof_prb * SRSLTE_NRE); + srsran_vec_sc_prod_cfc(fft_buffer[0], 0.001, fft_buffer[0], SRSRAN_CP_NSYMB(cell.cp) * cell.nof_prb * SRSRAN_NRE); } - srslte_dl_sf_cfg_t dl_sf; + srsran_dl_sf_cfg_t dl_sf; ZERO_OBJECT(dl_sf); /* Get channel estimates for each port */ - srslte_chest_dl_estimate(&chest, &dl_sf, fft_buffer, &chest_res); + srsran_chest_dl_estimate(&chest, &dl_sf, fft_buffer, &chest_res); INFO("Decoding PCFICH"); - n = srslte_pcfich_decode(&pcfich, &dl_sf, &chest_res, fft_buffer, &cfi_corr); + n = srsran_pcfich_decode(&pcfich, &dl_sf, &chest_res, fft_buffer, &cfi_corr); printf("cfi: %d, distance: %f\n", dl_sf.cfi, cfi_corr); - srslte_vec_save_file("input", input_buffer, SRSLTE_SF_LEN_PRB(cell.nof_prb) * sizeof(cf_t)); - srslte_vec_save_file("chest", chest_res.ce[0][0], SRSLTE_SF_LEN(cell.nof_prb) * sizeof(cf_t)); - srslte_vec_save_file("fft", fft_buffer[0], SRSLTE_NOF_RE(cell) * sizeof(cf_t)); - srslte_vec_save_file("d", pcfich.d, pcfich.nof_symbols * sizeof(cf_t)); + srsran_vec_save_file("input", input_buffer, SRSRAN_SF_LEN_PRB(cell.nof_prb) * sizeof(cf_t)); + srsran_vec_save_file("chest", chest_res.ce[0][0], SRSRAN_SF_LEN(cell.nof_prb) * sizeof(cf_t)); + srsran_vec_save_file("fft", fft_buffer[0], SRSRAN_NOF_RE(cell) * sizeof(cf_t)); + srsran_vec_save_file("d", pcfich.d, pcfich.nof_symbols * sizeof(cf_t)); base_free(); diff --git a/lib/src/phy/phch/test/pcfich_test.c b/lib/src/phy/phch/test/pcfich_test.c index bbbfd55e2..117878597 100644 --- a/lib/src/phy/phch/test/pcfich_test.c +++ b/lib/src/phy/phch/test/pcfich_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -16,16 +16,16 @@ #include #include -#include "srslte/srslte.h" +#include "srsran/srsran.h" -srslte_cell_t cell = { +srsran_cell_t cell = { 6, // nof_prb 1, // nof_ports 1000, // cell_id - SRSLTE_CP_NORM, // cyclic prefix - SRSLTE_PHICH_NORM, // PHICH length - SRSLTE_PHICH_R_1, // PHICH resources - SRSLTE_FDD, + SRSRAN_CP_NORM, // cyclic prefix + SRSRAN_PHICH_NORM, // PHICH length + SRSRAN_PHICH_R_1, // PHICH resources + SRSRAN_FDD, }; @@ -35,7 +35,7 @@ void usage(char* prog) printf("\t-c cell id [Default %d]\n", cell.id); printf("\t-p nof_ports [Default %d]\n", cell.nof_ports); printf("\t-n nof_prb [Default %d]\n", cell.nof_prb); - printf("\t-v [set srslte_verbose to debug, default none]\n"); + printf("\t-v [set srsran_verbose to debug, default none]\n"); } void parse_args(int argc, char** argv) @@ -53,7 +53,7 @@ void parse_args(int argc, char** argv) cell.id = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'v': - srslte_verbose++; + srsran_verbose++; break; default: usage(argv[0]); @@ -64,27 +64,27 @@ void parse_args(int argc, char** argv) int main(int argc, char** argv) { - srslte_chest_dl_res_t chest_res; - srslte_pcfich_t pcfich; - srslte_regs_t regs; + srsran_chest_dl_res_t chest_res; + srsran_pcfich_t pcfich; + srsran_regs_t regs; int i, j; int nof_re; - cf_t* slot_symbols[SRSLTE_MAX_PORTS]; + cf_t* slot_symbols[SRSRAN_MAX_PORTS]; uint32_t cfi, nsf; int cid, max_cid; float corr_res; parse_args(argc, argv); - nof_re = SRSLTE_CP_NORM_NSYMB * cell.nof_prb * SRSLTE_NRE; + nof_re = SRSRAN_CP_NORM_NSYMB * cell.nof_prb * SRSRAN_NRE; /* init memory */ - srslte_chest_dl_res_init(&chest_res, cell.nof_prb); - srslte_chest_dl_res_set_identity(&chest_res); - srslte_chest_dl_res_set_identity(&chest_res); + srsran_chest_dl_res_init(&chest_res, cell.nof_prb); + srsran_chest_dl_res_set_identity(&chest_res); + srsran_chest_dl_res_set_identity(&chest_res); - for (i = 0; i < SRSLTE_MAX_PORTS; i++) { - slot_symbols[i] = srslte_vec_cf_malloc(nof_re); + for (i = 0; i < SRSRAN_MAX_PORTS; i++) { + slot_symbols[i] = srsran_vec_cf_malloc(nof_re); if (!slot_symbols[i]) { perror("malloc"); exit(-1); @@ -99,7 +99,7 @@ int main(int argc, char** argv) max_cid = cell.id; } - srslte_dl_sf_cfg_t dl_sf; + srsran_dl_sf_cfg_t dl_sf; ZERO_OBJECT(dl_sf); while (cid <= max_cid) { @@ -107,16 +107,16 @@ int main(int argc, char** argv) printf("Testing CellID=%d...\n", cid); - if (srslte_regs_init(®s, cell)) { + if (srsran_regs_init(®s, cell)) { ERROR("Error initiating regs"); exit(-1); } - if (srslte_pcfich_init(&pcfich, 1)) { + if (srsran_pcfich_init(&pcfich, 1)) { ERROR("Error creating PBCH object"); exit(-1); } - if (srslte_pcfich_set_cell(&pcfich, ®s, cell)) { + if (srsran_pcfich_set_cell(&pcfich, ®s, cell)) { ERROR("Error creating PBCH object"); exit(-1); } @@ -126,7 +126,7 @@ int main(int argc, char** argv) for (cfi = 1; cfi < 4; cfi++) { dl_sf.cfi = cfi; - srslte_pcfich_encode(&pcfich, &dl_sf, slot_symbols); + srsran_pcfich_encode(&pcfich, &dl_sf, slot_symbols); /* combine outputs */ for (i = 1; i < cell.nof_ports; i++) { @@ -134,18 +134,18 @@ int main(int argc, char** argv) slot_symbols[0][j] += slot_symbols[i][j]; } } - if (srslte_pcfich_decode(&pcfich, &dl_sf, &chest_res, slot_symbols, &corr_res) < 0) { + if (srsran_pcfich_decode(&pcfich, &dl_sf, &chest_res, slot_symbols, &corr_res) < 0) { exit(-1); } INFO("cfi_tx: %d, cfi_rx: %d, ns: %d, distance: %f", cfi, dl_sf.cfi, nsf, corr_res); } } - srslte_pcfich_free(&pcfich); - srslte_regs_free(®s); + srsran_pcfich_free(&pcfich); + srsran_regs_free(®s); cid++; } - srslte_chest_dl_res_free(&chest_res); - for (i = 0; i < SRSLTE_MAX_PORTS; i++) { + srsran_chest_dl_res_free(&chest_res); + for (i = 0; i < SRSRAN_MAX_PORTS; i++) { free(slot_symbols[i]); } printf("OK\n"); diff --git a/lib/src/phy/phch/test/pdcch_file_test.c b/lib/src/phy/phch/test/pdcch_file_test.c index 9a9bc072b..a46ec6b56 100644 --- a/lib/src/phy/phch/test/pdcch_file_test.c +++ b/lib/src/phy/phch/test/pdcch_file_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -16,47 +16,47 @@ #include #include -#include "srslte/srslte.h" +#include "srsran/srsran.h" char* input_file_name = NULL; -srslte_cell_t cell = { +srsran_cell_t cell = { 6, // cell.cell.cell.nof_prb 1, // cell.cell.nof_ports 0, // cell.id - SRSLTE_CP_NORM, // cyclic prefix - SRSLTE_PHICH_NORM, // PHICH length - SRSLTE_PHICH_R_1, // PHICH resources - SRSLTE_FDD, + SRSRAN_CP_NORM, // cyclic prefix + SRSRAN_PHICH_NORM, // PHICH length + SRSRAN_PHICH_R_1, // PHICH resources + SRSRAN_FDD, }; uint32_t cfi = 2; int flen; -uint16_t rnti = SRSLTE_SIRNTI; +uint16_t rnti = SRSRAN_SIRNTI; int max_frames = 10; -srslte_dci_format_t dci_format = SRSLTE_DCI_FORMAT1A; -srslte_filesource_t fsrc; -srslte_pdcch_t pdcch; -cf_t * input_buffer, *fft_buffer[SRSLTE_MAX_CODEWORDS]; -srslte_regs_t regs; -srslte_ofdm_t fft; -srslte_chest_dl_t chest; -srslte_chest_dl_res_t chest_res; +srsran_dci_format_t dci_format = SRSRAN_DCI_FORMAT1A; +srsran_filesource_t fsrc; +srsran_pdcch_t pdcch; +cf_t * input_buffer, *fft_buffer[SRSRAN_MAX_CODEWORDS]; +srsran_regs_t regs; +srsran_ofdm_t fft; +srsran_chest_dl_t chest; +srsran_chest_dl_res_t chest_res; void usage(char* prog) { printf("Usage: %s [vcfoe] -i input_file\n", prog); printf("\t-c cell.id [Default %d]\n", cell.id); printf("\t-f cfi [Default %d]\n", cfi); - printf("\t-o DCI Format [Default %s]\n", srslte_dci_format_string(dci_format)); + printf("\t-o DCI Format [Default %s]\n", srsran_dci_format_string(dci_format)); printf("\t-r rnti [Default SI-RNTI]\n"); printf("\t-p cell.nof_ports [Default %d]\n", cell.nof_ports); printf("\t-n cell.nof_prb [Default %d]\n", cell.nof_prb); printf("\t-m max_frames [Default %d]\n", max_frames); printf("\t-e Set extended prefix [Default Normal]\n"); - printf("\t-v [set srslte_verbose to debug, default none]\n"); + printf("\t-v [set srsran_verbose to debug, default none]\n"); } void parse_args(int argc, char** argv) @@ -86,17 +86,17 @@ void parse_args(int argc, char** argv) cell.nof_ports = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'o': - dci_format = srslte_dci_format_from_string(argv[optind]); - if (dci_format == SRSLTE_DCI_NOF_FORMATS) { + dci_format = srsran_dci_format_from_string(argv[optind]); + if (dci_format == SRSRAN_DCI_NOF_FORMATS) { ERROR("Error unsupported format %s", argv[optind]); exit(-1); } break; case 'v': - srslte_verbose++; + srsran_verbose++; break; case 'e': - cell.cp = SRSLTE_CP_EXT; + cell.cp = SRSRAN_CP_EXT; break; default: usage(argv[0]); @@ -111,53 +111,53 @@ void parse_args(int argc, char** argv) int base_init() { - if (srslte_filesource_init(&fsrc, input_file_name, SRSLTE_COMPLEX_FLOAT_BIN)) { + if (srsran_filesource_init(&fsrc, input_file_name, SRSRAN_COMPLEX_FLOAT_BIN)) { ERROR("Error opening file %s", input_file_name); exit(-1); } - flen = 2 * (SRSLTE_SLOT_LEN(srslte_symbol_sz(cell.nof_prb))); + flen = 2 * (SRSRAN_SLOT_LEN(srsran_symbol_sz(cell.nof_prb))); - input_buffer = srslte_vec_cf_malloc(flen); + input_buffer = srsran_vec_cf_malloc(flen); if (!input_buffer) { perror("malloc"); exit(-1); } - fft_buffer[0] = srslte_vec_cf_malloc(SRSLTE_NOF_RE(cell)); + fft_buffer[0] = srsran_vec_cf_malloc(SRSRAN_NOF_RE(cell)); if (!fft_buffer[0]) { perror("malloc"); return -1; } - if (srslte_chest_dl_init(&chest, cell.nof_prb, 1)) { + if (srsran_chest_dl_init(&chest, cell.nof_prb, 1)) { ERROR("Error initializing equalizer"); return -1; } - if (srslte_chest_dl_res_init(&chest_res, cell.nof_prb)) { + if (srsran_chest_dl_res_init(&chest_res, cell.nof_prb)) { ERROR("Error initializing equalizer"); return -1; } - if (srslte_chest_dl_set_cell(&chest, cell)) { + if (srsran_chest_dl_set_cell(&chest, cell)) { ERROR("Error initializing equalizer"); return -1; } - if (srslte_ofdm_rx_init(&fft, cell.cp, input_buffer, fft_buffer[0], cell.nof_prb)) { + if (srsran_ofdm_rx_init(&fft, cell.cp, input_buffer, fft_buffer[0], cell.nof_prb)) { ERROR("Error initializing FFT"); return -1; } - if (srslte_regs_init(®s, cell)) { + if (srsran_regs_init(®s, cell)) { ERROR("Error initiating regs"); return -1; } - if (srslte_pdcch_init_ue(&pdcch, cell.nof_prb, 1)) { + if (srsran_pdcch_init_ue(&pdcch, cell.nof_prb, 1)) { ERROR("Error creating PDCCH object"); exit(-1); } - if (srslte_pdcch_set_cell(&pdcch, ®s, cell)) { + if (srsran_pdcch_set_cell(&pdcch, ®s, cell)) { ERROR("Error creating PDCCH object"); exit(-1); } @@ -168,19 +168,19 @@ int base_init() void base_free() { - srslte_filesource_free(&fsrc); + srsran_filesource_free(&fsrc); free(input_buffer); free(fft_buffer[0]); - srslte_filesource_free(&fsrc); + srsran_filesource_free(&fsrc); - srslte_chest_dl_res_free(&chest_res); - srslte_chest_dl_free(&chest); - srslte_ofdm_rx_free(&fft); + srsran_chest_dl_res_free(&chest_res); + srsran_chest_dl_free(&chest); + srsran_ofdm_rx_free(&fft); - srslte_pdcch_free(&pdcch); - srslte_regs_free(®s); + srsran_pdcch_free(&pdcch); + srsran_regs_free(®s); } int main(int argc, char** argv) @@ -188,9 +188,9 @@ int main(int argc, char** argv) int i; int frame_cnt; int ret; - srslte_dci_location_t locations[SRSLTE_MAX_CANDIDATES]; + srsran_dci_location_t locations[SRSRAN_MAX_CANDIDATES]; uint32_t nof_locations; - srslte_dci_msg_t dci_msg; + srsran_dci_msg_t dci_msg; if (argc < 3) { usage(argv[0]); @@ -207,33 +207,33 @@ int main(int argc, char** argv) ret = -1; frame_cnt = 0; do { - srslte_filesource_read(&fsrc, input_buffer, flen); + srsran_filesource_read(&fsrc, input_buffer, flen); INFO("Reading %d samples sub-frame %d", flen, frame_cnt); - srslte_ofdm_rx_sf(&fft); + srsran_ofdm_rx_sf(&fft); - srslte_dl_sf_cfg_t dl_sf; + srsran_dl_sf_cfg_t dl_sf; ZERO_OBJECT(dl_sf); dl_sf.tti = frame_cnt; dl_sf.cfi = cfi; /* Get channel estimates for each port */ - srslte_chest_dl_estimate(&chest, &dl_sf, fft_buffer, &chest_res); + srsran_chest_dl_estimate(&chest, &dl_sf, fft_buffer, &chest_res); - if (srslte_pdcch_extract_llr(&pdcch, &dl_sf, &chest_res, fft_buffer)) { + if (srsran_pdcch_extract_llr(&pdcch, &dl_sf, &chest_res, fft_buffer)) { ERROR("Error extracting LLRs"); return -1; } - if (rnti == SRSLTE_SIRNTI) { + if (rnti == SRSRAN_SIRNTI) { INFO("Initializing common search space for SI-RNTI"); - nof_locations = srslte_pdcch_common_locations(&pdcch, locations, SRSLTE_MAX_CANDIDATES, cfi); + nof_locations = srsran_pdcch_common_locations(&pdcch, locations, SRSRAN_MAX_CANDIDATES, cfi); } else { INFO("Initializing user-specific search space for RNTI: 0x%x", rnti); - nof_locations = srslte_pdcch_ue_locations(&pdcch, &dl_sf, locations, SRSLTE_MAX_CANDIDATES, rnti); + nof_locations = srsran_pdcch_ue_locations(&pdcch, &dl_sf, locations, SRSRAN_MAX_CANDIDATES, rnti); } - srslte_dci_cfg_t dci_cfg; + srsran_dci_cfg_t dci_cfg; ZERO_OBJECT(dci_cfg); ZERO_OBJECT(dci_msg); @@ -241,19 +241,19 @@ int main(int argc, char** argv) for (i = 0; i < nof_locations && dci_msg.rnti != rnti; i++) { dci_msg.location = locations[i]; dci_msg.format = dci_format; - if (srslte_pdcch_decode_msg(&pdcch, &dl_sf, &dci_cfg, &dci_msg)) { + if (srsran_pdcch_decode_msg(&pdcch, &dl_sf, &dci_cfg, &dci_msg)) { ERROR("Error decoding DCI msg"); return -1; } } if (dci_msg.rnti == rnti) { - srslte_dci_dl_t dci; - bzero(&dci, sizeof(srslte_dci_dl_t)); - if (srslte_dci_msg_unpack_pdsch(&cell, &dl_sf, &dci_cfg, &dci_msg, &dci)) { + srsran_dci_dl_t dci; + bzero(&dci, sizeof(srsran_dci_dl_t)); + if (srsran_dci_msg_unpack_pdsch(&cell, &dl_sf, &dci_cfg, &dci_msg, &dci)) { ERROR("Can't unpack DCI message"); } else { - if (dci.alloc_type == SRSLTE_RA_ALLOC_TYPE2 && dci.type2_alloc.mode == SRSLTE_RA_TYPE2_LOC && + if (dci.alloc_type == SRSRAN_RA_ALLOC_TYPE2 && dci.type2_alloc.mode == SRSRAN_RA_TYPE2_LOC && dci.type2_alloc.riv == 11 && dci.tb[0].rv == 0 && dci.pid == 0 && dci.tb[0].mcs_idx == 2) { printf("This is the file signal.1.92M.amar.dat\n"); ret = 0; diff --git a/lib/src/phy/phch/test/pdcch_nr_test.c b/lib/src/phy/phch/test/pdcch_nr_test.c index 2d1b8ab1b..23e6da6d5 100644 --- a/lib/src/phy/phch/test/pdcch_nr_test.c +++ b/lib/src/phy/phch/test/pdcch_nr_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,12 +10,12 @@ * */ -#include "srslte/common/test_common.h" -#include "srslte/phy/phch/pdcch_nr.h" -#include "srslte/phy/utils/random.h" +#include "srsran/common/test_common.h" +#include "srsran/phy/phch/pdcch_nr.h" +#include "srsran/phy/utils/random.h" #include -static srslte_carrier_nr_t carrier = { +static srsran_carrier_nr_t carrier = { 0, // cell_id 0, // numerology 50, // nof_prb @@ -31,28 +31,28 @@ typedef struct { uint64_t count; } proc_time_t; -static proc_time_t enc_time[SRSLTE_SEARCH_SPACE_NOF_AGGREGATION_LEVELS_NR] = {}; -static proc_time_t dec_time[SRSLTE_SEARCH_SPACE_NOF_AGGREGATION_LEVELS_NR] = {}; +static proc_time_t enc_time[SRSRAN_SEARCH_SPACE_NOF_AGGREGATION_LEVELS_NR] = {}; +static proc_time_t dec_time[SRSRAN_SEARCH_SPACE_NOF_AGGREGATION_LEVELS_NR] = {}; -static int test(srslte_pdcch_nr_t* tx, - srslte_pdcch_nr_t* rx, +static int test(srsran_pdcch_nr_t* tx, + srsran_pdcch_nr_t* rx, cf_t* grid, - srslte_dmrs_pdcch_ce_t* ce, - srslte_dci_msg_nr_t* dci_msg_tx) + srsran_dmrs_pdcch_ce_t* ce, + srsran_dci_msg_nr_t* dci_msg_tx) { // Encode PDCCH - TESTASSERT(srslte_pdcch_nr_encode(tx, dci_msg_tx, grid) == SRSLTE_SUCCESS); + TESTASSERT(srsran_pdcch_nr_encode(tx, dci_msg_tx, grid) == SRSRAN_SUCCESS); enc_time[dci_msg_tx->location.L].time_us += tx->meas_time_us; enc_time[dci_msg_tx->location.L].count++; // Init Rx MSG - srslte_pdcch_nr_res_t res = {}; - srslte_dci_msg_nr_t dci_msg_rx = *dci_msg_tx; - srslte_vec_u8_zero(dci_msg_rx.payload, dci_msg_rx.nof_bits); + srsran_pdcch_nr_res_t res = {}; + srsran_dci_msg_nr_t dci_msg_rx = *dci_msg_tx; + srsran_vec_u8_zero(dci_msg_rx.payload, dci_msg_rx.nof_bits); // Decode PDCCH - TESTASSERT(srslte_pdcch_nr_decode(rx, grid, ce, &dci_msg_rx, &res) == SRSLTE_SUCCESS); + TESTASSERT(srsran_pdcch_nr_decode(rx, grid, ce, &dci_msg_rx, &res) == SRSRAN_SUCCESS); dec_time[dci_msg_tx->location.L].time_us += rx->meas_time_us; dec_time[dci_msg_tx->location.L].count++; @@ -61,7 +61,7 @@ static int test(srslte_pdcch_nr_t* tx, TESTASSERT(res.evm < 0.01f); TESTASSERT(res.crc); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } static void usage(char* prog) @@ -69,7 +69,7 @@ static void usage(char* prog) printf("Usage: %s [pFv] \n", prog); printf("\t-p Number of carrier PRB [Default %d]\n", carrier.nof_prb); printf("\t-F Fast CORESET frequency resource sweeping [Default %s]\n", fast_sweep ? "Enabled" : "Disabled"); - printf("\t-v [set srslte_verbose to debug, default none]\n"); + printf("\t-v [set srsran_verbose to debug, default none]\n"); } static int parse_args(int argc, char** argv) @@ -84,95 +84,95 @@ static int parse_args(int argc, char** argv) fast_sweep ^= true; break; case 'v': - srslte_verbose++; + srsran_verbose++; break; default: usage(argv[0]); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int main(int argc, char** argv) { - int ret = SRSLTE_ERROR; + int ret = SRSRAN_ERROR; - srslte_pdcch_nr_args_t args = {}; + srsran_pdcch_nr_args_t args = {}; args.disable_simd = false; args.measure_evm = true; args.measure_time = true; - srslte_pdcch_nr_t pdcch_tx = {}; - srslte_pdcch_nr_t pdcch_rx = {}; + srsran_pdcch_nr_t pdcch_tx = {}; + srsran_pdcch_nr_t pdcch_rx = {}; - if (parse_args(argc, argv) < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (parse_args(argc, argv) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } - uint32_t grid_sz = carrier.nof_prb * SRSLTE_NRE * SRSLTE_NSYMB_PER_SLOT_NR; - srslte_random_t rand_gen = srslte_random_init(1234); - srslte_dmrs_pdcch_ce_t* ce = SRSLTE_MEM_ALLOC(srslte_dmrs_pdcch_ce_t, 1); - cf_t* buffer = srslte_vec_cf_malloc(grid_sz); + uint32_t grid_sz = carrier.nof_prb * SRSRAN_NRE * SRSRAN_NSYMB_PER_SLOT_NR; + srsran_random_t rand_gen = srsran_random_init(1234); + srsran_dmrs_pdcch_ce_t* ce = SRSRAN_MEM_ALLOC(srsran_dmrs_pdcch_ce_t, 1); + cf_t* buffer = srsran_vec_cf_malloc(grid_sz); if (rand_gen == NULL || ce == NULL || buffer == NULL) { ERROR("Error malloc"); goto clean_exit; } - SRSLTE_MEM_ZERO(ce, srslte_dmrs_pdcch_ce_t, 1); + SRSRAN_MEM_ZERO(ce, srsran_dmrs_pdcch_ce_t, 1); - if (srslte_pdcch_nr_init_tx(&pdcch_tx, &args) < SRSLTE_SUCCESS) { + if (srsran_pdcch_nr_init_tx(&pdcch_tx, &args) < SRSRAN_SUCCESS) { ERROR("Error init"); goto clean_exit; } - if (srslte_pdcch_nr_init_rx(&pdcch_rx, &args) < SRSLTE_SUCCESS) { + if (srsran_pdcch_nr_init_rx(&pdcch_rx, &args) < SRSRAN_SUCCESS) { ERROR("Error init"); goto clean_exit; } - srslte_coreset_t coreset = {}; - uint32_t nof_frequency_resource = SRSLTE_MIN(SRSLTE_CORESET_FREQ_DOMAIN_RES_SIZE, carrier.nof_prb / 6); + srsran_coreset_t coreset = {}; + uint32_t nof_frequency_resource = SRSRAN_MIN(SRSRAN_CORESET_FREQ_DOMAIN_RES_SIZE, carrier.nof_prb / 6); for (uint32_t frequency_resources = 1; frequency_resources < (1U << nof_frequency_resource); frequency_resources = (fast_sweep) ? ((frequency_resources << 1U) | 1U) : (frequency_resources + 1)) { for (uint32_t i = 0; i < nof_frequency_resource; i++) { uint32_t mask = ((frequency_resources >> i) & 1U); coreset.freq_resources[i] = (mask == 1); } - for (coreset.duration = SRSLTE_CORESET_DURATION_MIN; coreset.duration <= SRSLTE_CORESET_DURATION_MAX; + for (coreset.duration = SRSRAN_CORESET_DURATION_MIN; coreset.duration <= SRSRAN_CORESET_DURATION_MAX; coreset.duration++) { - srslte_search_space_t search_space = {}; - search_space.type = srslte_search_space_type_ue; + srsran_search_space_t search_space = {}; + search_space.type = srsran_search_space_type_ue; - if (srslte_pdcch_nr_set_carrier(&pdcch_tx, &carrier, &coreset) < SRSLTE_SUCCESS) { + if (srsran_pdcch_nr_set_carrier(&pdcch_tx, &carrier, &coreset) < SRSRAN_SUCCESS) { ERROR("Error setting carrier"); goto clean_exit; } - if (srslte_pdcch_nr_set_carrier(&pdcch_rx, &carrier, &coreset) < SRSLTE_SUCCESS) { + if (srsran_pdcch_nr_set_carrier(&pdcch_rx, &carrier, &coreset) < SRSRAN_SUCCESS) { ERROR("Error setting carrier"); goto clean_exit; } // Fill search space maximum number of candidates - for (uint32_t aggregation_level = 0; aggregation_level < SRSLTE_SEARCH_SPACE_NOF_AGGREGATION_LEVELS_NR; + for (uint32_t aggregation_level = 0; aggregation_level < SRSRAN_SEARCH_SPACE_NOF_AGGREGATION_LEVELS_NR; aggregation_level++) { search_space.nof_candidates[aggregation_level] = - srslte_pdcch_nr_max_candidates_coreset(&coreset, aggregation_level); + srsran_pdcch_nr_max_candidates_coreset(&coreset, aggregation_level); } - for (uint32_t aggregation_level = 0; aggregation_level < SRSLTE_SEARCH_SPACE_NOF_AGGREGATION_LEVELS_NR; + for (uint32_t aggregation_level = 0; aggregation_level < SRSRAN_SEARCH_SPACE_NOF_AGGREGATION_LEVELS_NR; aggregation_level++) { uint32_t L = 1U << aggregation_level; - for (uint32_t slot_idx = 0; slot_idx < SRSLTE_NSLOTS_PER_FRAME_NR(carrier.numerology); slot_idx++) { - uint32_t dci_locations[SRSLTE_SEARCH_SPACE_MAX_NOF_CANDIDATES_NR] = {}; + for (uint32_t slot_idx = 0; slot_idx < SRSRAN_NSLOTS_PER_FRAME_NR(carrier.numerology); slot_idx++) { + uint32_t dci_locations[SRSRAN_SEARCH_SPACE_MAX_NOF_CANDIDATES_NR] = {}; // Calculate candidate locations - int n = srslte_pdcch_nr_locations_coreset( + int n = srsran_pdcch_nr_locations_coreset( &coreset, &search_space, rnti, aggregation_level, slot_idx, dci_locations); - if (n < SRSLTE_SUCCESS) { + if (n < SRSRAN_SUCCESS) { ERROR("Error calculating locations in CORESET"); goto clean_exit; } @@ -184,26 +184,26 @@ int main(int argc, char** argv) for (uint32_t ncce_idx = 0; ncce_idx < n; ncce_idx++) { // Init MSG - srslte_dci_msg_nr_t dci_msg = {}; - dci_msg.format = srslte_dci_format_nr_1_0; - dci_msg.rnti_type = srslte_rnti_type_c; + srsran_dci_msg_nr_t dci_msg = {}; + dci_msg.format = srsran_dci_format_nr_1_0; + dci_msg.rnti_type = srsran_rnti_type_c; dci_msg.location.L = aggregation_level; dci_msg.location.ncce = dci_locations[ncce_idx]; - dci_msg.nof_bits = srslte_dci_nr_format_1_0_sizeof(&carrier, &coreset, dci_msg.rnti_type); + dci_msg.nof_bits = srsran_dci_nr_format_1_0_sizeof(&carrier, &coreset, dci_msg.rnti_type); // Generate random payload for (uint32_t i = 0; i < dci_msg.nof_bits; i++) { - dci_msg.payload[i] = srslte_random_uniform_int_dist(rand_gen, 0, 1); + dci_msg.payload[i] = srsran_random_uniform_int_dist(rand_gen, 0, 1); } // Set channel estimate number of elements and set out-of-range values to zero - ce->nof_re = (SRSLTE_NRE - 3) * 6 * L; - for (uint32_t i = 0; i < SRSLTE_PDCCH_MAX_RE; i++) { + ce->nof_re = (SRSRAN_NRE - 3) * 6 * L; + for (uint32_t i = 0; i < SRSRAN_PDCCH_MAX_RE; i++) { ce->ce[i] = (i < ce->nof_re) ? 1.0f : 0.0f; } ce->noise_var = 0.0f; - if (test(&pdcch_tx, &pdcch_rx, buffer, ce, &dci_msg) < SRSLTE_SUCCESS) { + if (test(&pdcch_tx, &pdcch_rx, buffer, ce, &dci_msg) < SRSRAN_SUCCESS) { ERROR("test failed"); goto clean_exit; } @@ -218,7 +218,7 @@ int main(int argc, char** argv) printf("| %6s | %6s | %6s | %6s |\n", " L ", "Count", "Encode", "Decode"); printf("| %6s | %6s | %6s | %6s |\n", " ", " ", " (us) ", " (us) "); printf("+--------+--------+--------+--------+\n"); - for (uint32_t i = 0; i < SRSLTE_SEARCH_SPACE_NOF_AGGREGATION_LEVELS_NR; i++) { + for (uint32_t i = 0; i < SRSRAN_SEARCH_SPACE_NOF_AGGREGATION_LEVELS_NR; i++) { if (enc_time[i].count > 0 && dec_time[i].count) { printf("| %6" PRIu32 "| %6" PRIu64 " | %6.1f | %6.1f |\n", i, @@ -229,9 +229,9 @@ int main(int argc, char** argv) } printf("+--------+--------+--------+--------+\n"); - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; clean_exit: - srslte_random_free(rand_gen); + srsran_random_free(rand_gen); if (ce) { free(ce); @@ -241,10 +241,10 @@ clean_exit: free(buffer); } - srslte_pdcch_nr_free(&pdcch_tx); - srslte_pdcch_nr_free(&pdcch_rx); + srsran_pdcch_nr_free(&pdcch_tx); + srsran_pdcch_nr_free(&pdcch_rx); - if (ret == SRSLTE_SUCCESS) { + if (ret == SRSRAN_SUCCESS) { printf("Passed!\n"); } else { printf("Failed!\n"); diff --git a/lib/src/phy/phch/test/pdcch_test.c b/lib/src/phy/phch/test/pdcch_test.c index 8561e80a6..b1db65c0a 100644 --- a/lib/src/phy/phch/test/pdcch_test.c +++ b/lib/src/phy/phch/test/pdcch_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -15,19 +15,19 @@ #include #include -#include "srslte/srslte.h" +#include "srsran/srsran.h" -srslte_cell_t cell = {.nof_prb = 6, +srsran_cell_t cell = {.nof_prb = 6, .nof_ports = 1, .id = 1, - .cp = SRSLTE_CP_NORM, - .phich_resources = SRSLTE_PHICH_R_1, - .phich_length = SRSLTE_PHICH_NORM}; + .cp = SRSRAN_CP_NORM, + .phich_resources = SRSRAN_PHICH_R_1, + .phich_length = SRSRAN_PHICH_NORM}; uint32_t cfi = 1; uint32_t nof_rx_ant = 1; bool print_dci_table; -srslte_dci_cfg_t dci_cfg = {}; +srsran_dci_cfg_t dci_cfg = {}; void usage(char* prog) { @@ -39,7 +39,7 @@ void usage(char* prog) printf("\t-A nof_rx_ant [Default %d]\n", nof_rx_ant); printf("\t-d Print DCI table [Default %s]\n", print_dci_table ? "yes" : "no"); printf("\t-x Enable/Disable Cross-scheduling [Default %s]\n", dci_cfg.cif_enabled ? "enabled" : "disabled"); - printf("\t-v [set srslte_verbose to debug, default none]\n"); + printf("\t-v [set srsran_verbose to debug, default none]\n"); } void parse_args(int argc, char** argv) @@ -69,7 +69,7 @@ void parse_args(int argc, char** argv) dci_cfg.cif_enabled ^= true; break; case 'v': - srslte_verbose++; + srsran_verbose++; break; default: usage(argv[0]); @@ -82,8 +82,8 @@ int test_dci_payload_size() { int i, j; int x[5]; - const srslte_dci_format_t formats[] = { - SRSLTE_DCI_FORMAT0, SRSLTE_DCI_FORMAT1, SRSLTE_DCI_FORMAT1A, SRSLTE_DCI_FORMAT1C, SRSLTE_DCI_FORMAT2A}; + const srsran_dci_format_t formats[] = { + SRSRAN_DCI_FORMAT0, SRSRAN_DCI_FORMAT1, SRSRAN_DCI_FORMAT1A, SRSRAN_DCI_FORMAT1C, SRSRAN_DCI_FORMAT2A}; const int prb[6] = {6, 15, 25, 50, 75, 100}; const int dci_sz[6][5] = {{21, 19, 21, 8, 28}, {22, 23, 22, 10, 31}, @@ -92,10 +92,10 @@ int test_dci_payload_size() {27, 33, 27, 14, 42}, {28, 39, 28, 15, 48}}; - srslte_dl_sf_cfg_t dl_sf; + srsran_dl_sf_cfg_t dl_sf; ZERO_OBJECT(dl_sf); - srslte_cell_t cell_test; + srsran_cell_t cell_test; ZERO_OBJECT(cell_test); cell_test.nof_ports = 1; @@ -108,10 +108,10 @@ int test_dci_payload_size() cell_test.nof_prb = n; for (j = 0; j < 5; j++) { - x[j] = srslte_dci_format_sizeof(&cell_test, &dl_sf, &dci_cfg, formats[j]); + x[j] = srsran_dci_format_sizeof(&cell_test, &dl_sf, &dci_cfg, formats[j]); if (x[j] != dci_sz[i][j]) { ERROR("Invalid DCI payload size for %s and %d PRB. Is %d and should be %d", - srslte_dci_format_string(formats[j]), + srsran_dci_format_string(formats[j]), n, x[j], dci_sz[i][j]); @@ -128,7 +128,7 @@ int test_dci_payload_size() printf(" {"); for (j = 0; j < 4; j++) { cell_test.nof_prb = i; - printf("%d", srslte_dci_format_sizeof(&cell, &dl_sf, &dci_cfg, formats[j])); + printf("%d", srsran_dci_format_sizeof(&cell, &dl_sf, &dci_cfg, formats[j])); if (j < 3) { printf(", "); } @@ -145,22 +145,22 @@ int test_dci_payload_size() } typedef struct { - srslte_dci_msg_t dci_tx, dci_rx; - srslte_dci_location_t dci_location; - srslte_dci_format_t dci_format; - srslte_dci_dl_t ra_dl_tx; - srslte_dci_dl_t ra_dl_rx; + srsran_dci_msg_t dci_tx, dci_rx; + srsran_dci_location_t dci_location; + srsran_dci_format_t dci_format; + srsran_dci_dl_t ra_dl_tx; + srsran_dci_dl_t ra_dl_rx; } testcase_dci_t; int main(int argc, char** argv) { - srslte_chest_dl_res_t chest_dl_res; - srslte_pdcch_t pdcch_tx, pdcch_rx; + srsran_chest_dl_res_t chest_dl_res; + srsran_pdcch_t pdcch_tx, pdcch_rx; testcase_dci_t testcases[10]; - srslte_regs_t regs; + srsran_regs_t regs; int i; int nof_re; - cf_t* slot_symbols[SRSLTE_MAX_PORTS]; + cf_t* slot_symbols[SRSRAN_MAX_PORTS]; int nof_dcis; bzero(&testcases, sizeof(testcase_dci_t) * 10); @@ -169,7 +169,7 @@ int main(int argc, char** argv) parse_args(argc, argv); - nof_re = SRSLTE_CP_NORM_NSYMB * cell.nof_prb * SRSLTE_NRE; + nof_re = SRSRAN_CP_NORM_NSYMB * cell.nof_prb * SRSRAN_NRE; if (test_dci_payload_size()) { exit(-1); @@ -177,50 +177,50 @@ int main(int argc, char** argv) /* init memory */ - srslte_chest_dl_res_init(&chest_dl_res, cell.nof_prb); - srslte_chest_dl_res_set_identity(&chest_dl_res); + srsran_chest_dl_res_init(&chest_dl_res, cell.nof_prb); + srsran_chest_dl_res_set_identity(&chest_dl_res); - for (i = 0; i < SRSLTE_MAX_PORTS; i++) { - slot_symbols[i] = srslte_vec_cf_malloc(nof_re); + for (i = 0; i < SRSRAN_MAX_PORTS; i++) { + slot_symbols[i] = srsran_vec_cf_malloc(nof_re); if (!slot_symbols[i]) { perror("malloc"); exit(-1); } - srslte_vec_cf_zero(slot_symbols[i], nof_re); + srsran_vec_cf_zero(slot_symbols[i], nof_re); } - if (srslte_regs_init(®s, cell)) { + if (srsran_regs_init(®s, cell)) { ERROR("Error initiating regs"); exit(-1); } - if (srslte_pdcch_init_enb(&pdcch_tx, cell.nof_prb)) { + if (srsran_pdcch_init_enb(&pdcch_tx, cell.nof_prb)) { ERROR("Error creating PDCCH object"); exit(-1); } - if (srslte_pdcch_set_cell(&pdcch_tx, ®s, cell)) { + if (srsran_pdcch_set_cell(&pdcch_tx, ®s, cell)) { ERROR("Error setting cell in PDCCH object"); exit(-1); } - if (srslte_pdcch_init_ue(&pdcch_rx, cell.nof_prb, nof_rx_ant)) { + if (srsran_pdcch_init_ue(&pdcch_rx, cell.nof_prb, nof_rx_ant)) { ERROR("Error creating PDCCH object"); exit(-1); } - if (srslte_pdcch_set_cell(&pdcch_rx, ®s, cell)) { + if (srsran_pdcch_set_cell(&pdcch_rx, ®s, cell)) { ERROR("Error setting cell in PDCCH object"); exit(-1); } /* Resource allocate init */ nof_dcis = 0; - srslte_dci_dl_t dci; + srsran_dci_dl_t dci; ZERO_OBJECT(dci); dci.pid = 5; dci.tb[0].mcs_idx = 5; dci.tb[0].ndi = 0; dci.tb[0].rv = 1; - dci.alloc_type = SRSLTE_RA_ALLOC_TYPE0; + dci.alloc_type = SRSRAN_RA_ALLOC_TYPE0; dci.type0_alloc.rbg_bitmask = 0x5; dci.cif_present = dci_cfg.cif_enabled; if (dci_cfg.cif_enabled) { @@ -229,7 +229,7 @@ int main(int argc, char** argv) /* Format 1 Test case */ if (cell.nof_ports == 1) { - testcases[nof_dcis].dci_format = SRSLTE_DCI_FORMAT1; + testcases[nof_dcis].dci_format = SRSRAN_DCI_FORMAT1; if (dci_cfg.cif_enabled) { dci.cif = (uint32_t)(random() & 0x7); } @@ -238,7 +238,7 @@ int main(int argc, char** argv) /* Format 1 Test case */ dci.tb[0].mcs_idx = 15; - testcases[nof_dcis].dci_format = SRSLTE_DCI_FORMAT1; + testcases[nof_dcis].dci_format = SRSRAN_DCI_FORMAT1; if (dci_cfg.cif_enabled) { dci.cif = (uint32_t)(random() & 0x7); } @@ -251,7 +251,7 @@ int main(int argc, char** argv) dci.tb[1].mcs_idx = 13; dci.tb[1].rv = 3; dci.tb[1].ndi = true; - testcases[nof_dcis].dci_format = SRSLTE_DCI_FORMAT2A; + testcases[nof_dcis].dci_format = SRSRAN_DCI_FORMAT2A; if (dci_cfg.cif_enabled) { dci.cif = (uint32_t)(random() & 0x7); } @@ -264,7 +264,7 @@ int main(int argc, char** argv) dci.tb[1].mcs_idx = 28; dci.tb[1].rv = 1; dci.tb[1].ndi = false; - testcases[nof_dcis].dci_format = SRSLTE_DCI_FORMAT2; + testcases[nof_dcis].dci_format = SRSRAN_DCI_FORMAT2; if (dci_cfg.cif_enabled) { dci.cif = (uint32_t)(random() & 0x7); } @@ -272,10 +272,10 @@ int main(int argc, char** argv) nof_dcis++; } - srslte_dci_cfg_t dci_cfg; + srsran_dci_cfg_t dci_cfg; ZERO_OBJECT(dci_cfg); - srslte_dl_sf_cfg_t dl_sf; + srsran_dl_sf_cfg_t dl_sf; ZERO_OBJECT(dl_sf); dl_sf.cfi = cfi; @@ -287,27 +287,27 @@ int main(int argc, char** argv) testcases[i].ra_dl_tx.rnti = (uint16_t)(1234 + i); testcases[i].ra_dl_tx.format = testcases[i].dci_format; - srslte_dci_msg_pack_pdsch(&cell, &dl_sf, &dci_cfg, &testcases[i].ra_dl_tx, &testcases[i].dci_tx); - srslte_dci_location_set(&testcases[i].dci_location, 0, (uint32_t)i); + srsran_dci_msg_pack_pdsch(&cell, &dl_sf, &dci_cfg, &testcases[i].ra_dl_tx, &testcases[i].dci_tx); + srsran_dci_location_set(&testcases[i].dci_location, 0, (uint32_t)i); testcases[i].dci_tx.format = testcases[i].dci_format; testcases[i].dci_tx.location = testcases[i].dci_location; // Enable just 1 TB per default - if (testcases[i].dci_format < SRSLTE_DCI_FORMAT2) { - for (int j = 1; j < SRSLTE_MAX_CODEWORDS; j++) { - SRSLTE_DCI_TB_DISABLE(testcases[i].ra_dl_tx.tb[j]); + if (testcases[i].dci_format < SRSRAN_DCI_FORMAT2) { + for (int j = 1; j < SRSRAN_MAX_CODEWORDS; j++) { + SRSRAN_DCI_TB_DISABLE(testcases[i].ra_dl_tx.tb[j]); } } - if (srslte_pdcch_encode(&pdcch_tx, &dl_sf, &testcases[i].dci_tx, slot_symbols)) { + if (srsran_pdcch_encode(&pdcch_tx, &dl_sf, &testcases[i].dci_tx, slot_symbols)) { ERROR("Error encoding DCI message"); goto quit; } } /* Execute 'Rx' */ - if (srslte_pdcch_extract_llr(&pdcch_rx, &dl_sf, &chest_dl_res, slot_symbols)) { + if (srsran_pdcch_extract_llr(&pdcch_rx, &dl_sf, &chest_dl_res, slot_symbols)) { ERROR("Error extracting LLRs"); goto quit; } @@ -316,11 +316,11 @@ int main(int argc, char** argv) for (i = 0; i < nof_dcis; i++) { testcases[i].dci_rx.format = testcases[i].dci_format; testcases[i].dci_rx.location = testcases[i].dci_location; - if (srslte_pdcch_decode_msg(&pdcch_rx, &dl_sf, &dci_cfg, &testcases[i].dci_rx)) { + if (srsran_pdcch_decode_msg(&pdcch_rx, &dl_sf, &dci_cfg, &testcases[i].dci_rx)) { ERROR("Error decoding DCI message"); goto quit; } - if (srslte_dci_msg_unpack_pdsch(&cell, &dl_sf, &dci_cfg, &testcases[i].dci_rx, &testcases[i].ra_dl_rx)) { + if (srsran_dci_msg_unpack_pdsch(&cell, &dl_sf, &dci_cfg, &testcases[i].dci_rx, &testcases[i].ra_dl_rx)) { ERROR("Error unpacking DCI message"); goto quit; } @@ -338,7 +338,7 @@ int main(int argc, char** argv) printf("Error in DCI %d: Received data does not match\n", i); goto quit; } -#if SRSLTE_DCI_HEXDEBUG +#if SRSRAN_DCI_HEXDEBUG // Ignore Hex str bzero(testcases[i].ra_dl_rx.hex_str, sizeof(testcases[i].ra_dl_rx.hex_str)); testcases[i].ra_dl_rx.nof_bits = 0; @@ -346,21 +346,21 @@ int main(int argc, char** argv) // Ignore DCI location testcases[i].ra_dl_rx.location = testcases[i].ra_dl_tx.location; // Ignore cw_idx - for (int j = 0; j < SRSLTE_MAX_CODEWORDS; j++) { + for (int j = 0; j < SRSRAN_MAX_CODEWORDS; j++) { testcases[i].ra_dl_rx.tb[j].cw_idx = testcases[i].ra_dl_tx.tb[j].cw_idx; } - if (memcmp(&testcases[i].ra_dl_tx, &testcases[i].ra_dl_rx, sizeof(srslte_dci_dl_t))) { + if (memcmp(&testcases[i].ra_dl_tx, &testcases[i].ra_dl_rx, sizeof(srsran_dci_dl_t))) { uint8_t* x = (uint8_t*)&testcases[i].ra_dl_rx; uint8_t* y = (uint8_t*)&testcases[i].ra_dl_tx; - for (int j = 0; j < sizeof(srslte_dci_dl_t); j++) { + for (int j = 0; j < sizeof(srsran_dci_dl_t); j++) { if (x[j] != y[j]) { printf("error in byte %d, rx=%d, tx=%d\n", j, x[j], y[j]); } } printf("tx: "); - srslte_vec_fprint_byte(stdout, (uint8_t*)&testcases[i].ra_dl_tx, sizeof(srslte_dci_dl_t)); + srsran_vec_fprint_byte(stdout, (uint8_t*)&testcases[i].ra_dl_tx, sizeof(srsran_dci_dl_t)); printf("rx: "); - srslte_vec_fprint_byte(stdout, (uint8_t*)&testcases[i].ra_dl_rx, sizeof(srslte_dci_dl_t)); + srsran_vec_fprint_byte(stdout, (uint8_t*)&testcases[i].ra_dl_rx, sizeof(srsran_dci_dl_t)); printf("Error in RA %d: Received data does not match\n", i); printf(" Field | Tx | Rx \n"); printf("--------------+----------+----------\n"); @@ -387,12 +387,12 @@ int main(int argc, char** argv) ret = 0; quit: - srslte_pdcch_free(&pdcch_tx); - srslte_pdcch_free(&pdcch_rx); - srslte_chest_dl_res_free(&chest_dl_res); - srslte_regs_free(®s); + srsran_pdcch_free(&pdcch_tx); + srsran_pdcch_free(&pdcch_rx); + srsran_chest_dl_res_free(&chest_dl_res); + srsran_regs_free(®s); - for (i = 0; i < SRSLTE_MAX_PORTS; i++) { + for (i = 0; i < SRSRAN_MAX_PORTS; i++) { free(slot_symbols[i]); } if (ret) { diff --git a/lib/src/phy/phch/test/pdsch_nr_test.c b/lib/src/phy/phch/test/pdsch_nr_test.c index 6e26a2508..ca34bb90f 100644 --- a/lib/src/phy/phch/test/pdsch_nr_test.c +++ b/lib/src/phy/phch/test/pdsch_nr_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,28 +10,28 @@ * */ -#include "srslte/phy/phch/pdsch_nr.h" -#include "srslte/phy/phch/ra_dl_nr.h" -#include "srslte/phy/phch/ra_nr.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/random.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/phch/pdsch_nr.h" +#include "srsran/phy/phch/ra_dl_nr.h" +#include "srsran/phy/phch/ra_nr.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/random.h" +#include "srsran/phy/utils/vector.h" #include #include #include -static srslte_carrier_nr_t carrier = { +static srsran_carrier_nr_t carrier = { 1, // cell_id 0, // numerology - SRSLTE_MAX_PRB_NR, // nof_prb + SRSRAN_MAX_PRB_NR, // nof_prb 0, // start 1 // max_mimo_layers }; static uint32_t n_prb = 0; // Set to 0 for steering static uint32_t mcs = 30; // Set to 30 for steering -static srslte_sch_cfg_nr_t pdsch_cfg = {}; -static srslte_sch_grant_nr_t pdsch_grant = {}; +static srsran_sch_cfg_nr_t pdsch_cfg = {}; +static srsran_sch_grant_nr_t pdsch_grant = {}; static uint16_t rnti = 0x1234; void usage(char* prog) @@ -40,9 +40,9 @@ void usage(char* prog) printf("\t-p Number of grant PRB, set to 0 for steering [Default %d]\n", n_prb); printf("\t-m MCS PRB, set to >28 for steering [Default %d]\n", mcs); printf("\t-T Provide MCS table (64qam, 256qam, 64qamLowSE) [Default %s]\n", - srslte_mcs_table_to_str(pdsch_cfg.sch_cfg.mcs_table)); + srsran_mcs_table_to_str(pdsch_cfg.sch_cfg.mcs_table)); printf("\t-L Provide number of layers [Default %d]\n", carrier.max_mimo_layers); - printf("\t-v [set srslte_verbose to debug, default none]\n"); + printf("\t-v [set srsran_verbose to debug, default none]\n"); } int parse_args(int argc, char** argv) @@ -57,69 +57,69 @@ int parse_args(int argc, char** argv) mcs = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'T': - pdsch_cfg.sch_cfg.mcs_table = srslte_mcs_table_from_str(argv[optind]); + pdsch_cfg.sch_cfg.mcs_table = srsran_mcs_table_from_str(argv[optind]); break; case 'L': carrier.max_mimo_layers = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'v': - srslte_verbose++; + srsran_verbose++; break; default: usage(argv[0]); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int main(int argc, char** argv) { - int ret = SRSLTE_ERROR; - srslte_pdsch_nr_t pdsch_tx = {}; - srslte_pdsch_nr_t pdsch_rx = {}; - srslte_chest_dl_res_t chest = {}; - srslte_pdsch_res_nr_t pdsch_res[SRSLTE_MAX_TB] = {}; - srslte_random_t rand_gen = srslte_random_init(1234); + int ret = SRSRAN_ERROR; + srsran_pdsch_nr_t pdsch_tx = {}; + srsran_pdsch_nr_t pdsch_rx = {}; + srsran_chest_dl_res_t chest = {}; + srsran_pdsch_res_nr_t pdsch_res[SRSRAN_MAX_TB] = {}; + srsran_random_t rand_gen = srsran_random_init(1234); - uint8_t* data_tx[SRSLTE_MAX_TB] = {}; - uint8_t* data_rx[SRSLTE_MAX_CODEWORDS] = {}; - cf_t* sf_symbols[SRSLTE_MAX_LAYERS_NR] = {}; + uint8_t* data_tx[SRSRAN_MAX_TB] = {}; + uint8_t* data_rx[SRSRAN_MAX_CODEWORDS] = {}; + cf_t* sf_symbols[SRSRAN_MAX_LAYERS_NR] = {}; // Set default PDSCH configuration - pdsch_cfg.sch_cfg.mcs_table = srslte_mcs_table_64qam; + pdsch_cfg.sch_cfg.mcs_table = srsran_mcs_table_64qam; - if (parse_args(argc, argv) < SRSLTE_SUCCESS) { + if (parse_args(argc, argv) < SRSRAN_SUCCESS) { goto clean_exit; } - srslte_pdsch_nr_args_t pdsch_args = {}; + srsran_pdsch_nr_args_t pdsch_args = {}; pdsch_args.sch.disable_simd = false; pdsch_args.measure_evm = true; - if (srslte_pdsch_nr_init_enb(&pdsch_tx, &pdsch_args) < SRSLTE_SUCCESS) { + if (srsran_pdsch_nr_init_enb(&pdsch_tx, &pdsch_args) < SRSRAN_SUCCESS) { ERROR("Error initiating PDSCH for Tx"); goto clean_exit; } - if (srslte_pdsch_nr_init_ue(&pdsch_rx, &pdsch_args) < SRSLTE_SUCCESS) { + if (srsran_pdsch_nr_init_ue(&pdsch_rx, &pdsch_args) < SRSRAN_SUCCESS) { ERROR("Error initiating SCH NR for Rx"); goto clean_exit; } - if (srslte_pdsch_nr_set_carrier(&pdsch_tx, &carrier)) { + if (srsran_pdsch_nr_set_carrier(&pdsch_tx, &carrier)) { ERROR("Error setting SCH NR carrier"); goto clean_exit; } - if (srslte_pdsch_nr_set_carrier(&pdsch_rx, &carrier)) { + if (srsran_pdsch_nr_set_carrier(&pdsch_rx, &carrier)) { ERROR("Error setting SCH NR carrier"); goto clean_exit; } for (uint32_t i = 0; i < carrier.max_mimo_layers; i++) { - sf_symbols[i] = srslte_vec_cf_malloc(SRSLTE_SLOT_LEN_RE_NR(carrier.nof_prb)); + sf_symbols[i] = srsran_vec_cf_malloc(SRSRAN_SLOT_LEN_RE_NR(carrier.nof_prb)); if (sf_symbols[i] == NULL) { ERROR("Error malloc"); goto clean_exit; @@ -127,8 +127,8 @@ int main(int argc, char** argv) } for (uint32_t i = 0; i < pdsch_tx.max_cw; i++) { - data_tx[i] = srslte_vec_u8_malloc(SRSLTE_SLOT_MAX_NOF_BITS_NR); - data_rx[i] = srslte_vec_u8_malloc(SRSLTE_SLOT_MAX_NOF_BITS_NR); + data_tx[i] = srsran_vec_u8_malloc(SRSRAN_SLOT_MAX_NOF_BITS_NR); + data_rx[i] = srsran_vec_u8_malloc(SRSRAN_SLOT_MAX_NOF_BITS_NR); if (data_tx[i] == NULL || data_rx[i] == NULL) { ERROR("Error malloc"); goto clean_exit; @@ -137,87 +137,87 @@ int main(int argc, char** argv) pdsch_res[i].payload = data_rx[i]; } - srslte_softbuffer_tx_t softbuffer_tx = {}; - srslte_softbuffer_rx_t softbuffer_rx = {}; + srsran_softbuffer_tx_t softbuffer_tx = {}; + srsran_softbuffer_rx_t softbuffer_rx = {}; - if (srslte_softbuffer_tx_init_guru(&softbuffer_tx, SRSLTE_SCH_NR_MAX_NOF_CB_LDPC, SRSLTE_LDPC_MAX_LEN_ENCODED_CB) < - SRSLTE_SUCCESS) { + if (srsran_softbuffer_tx_init_guru(&softbuffer_tx, SRSRAN_SCH_NR_MAX_NOF_CB_LDPC, SRSRAN_LDPC_MAX_LEN_ENCODED_CB) < + SRSRAN_SUCCESS) { ERROR("Error init soft-buffer"); goto clean_exit; } - if (srslte_softbuffer_rx_init_guru(&softbuffer_rx, SRSLTE_SCH_NR_MAX_NOF_CB_LDPC, SRSLTE_LDPC_MAX_LEN_ENCODED_CB) < - SRSLTE_SUCCESS) { + if (srsran_softbuffer_rx_init_guru(&softbuffer_rx, SRSRAN_SCH_NR_MAX_NOF_CB_LDPC, SRSRAN_LDPC_MAX_LEN_ENCODED_CB) < + SRSRAN_SUCCESS) { ERROR("Error init soft-buffer"); goto clean_exit; } // Use grant default A time resources with m=0 - if (srslte_ra_dl_nr_time_default_A(0, pdsch_cfg.dmrs.typeA_pos, &pdsch_grant) < SRSLTE_SUCCESS) { + if (srsran_ra_dl_nr_time_default_A(0, pdsch_cfg.dmrs.typeA_pos, &pdsch_grant) < SRSRAN_SUCCESS) { ERROR("Error loading default grant"); goto clean_exit; } // Load number of DMRS CDM groups without data - if (srslte_ra_dl_nr_nof_dmrs_cdm_groups_without_data_format_1_0(&pdsch_cfg.dmrs, &pdsch_grant) < SRSLTE_SUCCESS) { + if (srsran_ra_dl_nr_nof_dmrs_cdm_groups_without_data_format_1_0(&pdsch_cfg.dmrs, &pdsch_grant) < SRSRAN_SUCCESS) { ERROR("Error loading number of DMRS CDM groups without data"); goto clean_exit; } pdsch_grant.nof_layers = carrier.max_mimo_layers; - pdsch_grant.dci_format = srslte_dci_format_nr_1_0; + pdsch_grant.dci_format = srsran_dci_format_nr_1_0; pdsch_grant.rnti = rnti; uint32_t n_prb_start = 1; uint32_t n_prb_end = carrier.nof_prb + 1; if (n_prb > 0) { - n_prb_start = SRSLTE_MIN(n_prb, n_prb_end - 1); - n_prb_end = SRSLTE_MIN(n_prb + 1, n_prb_end); + n_prb_start = SRSRAN_MIN(n_prb, n_prb_end - 1); + n_prb_end = SRSRAN_MIN(n_prb + 1, n_prb_end); } uint32_t mcs_start = 0; - uint32_t mcs_end = pdsch_cfg.sch_cfg.mcs_table == srslte_mcs_table_256qam ? 28 : 29; + uint32_t mcs_end = pdsch_cfg.sch_cfg.mcs_table == srsran_mcs_table_256qam ? 28 : 29; if (mcs < mcs_end) { - mcs_start = SRSLTE_MIN(mcs, mcs_end - 1); - mcs_end = SRSLTE_MIN(mcs + 1, mcs_end); + mcs_start = SRSRAN_MIN(mcs, mcs_end - 1); + mcs_end = SRSRAN_MIN(mcs + 1, mcs_end); } - if (srslte_chest_dl_res_init(&chest, carrier.nof_prb) < SRSLTE_SUCCESS) { + if (srsran_chest_dl_res_init(&chest, carrier.nof_prb) < SRSRAN_SUCCESS) { ERROR("Initiating chest"); goto clean_exit; } for (n_prb = n_prb_start; n_prb < n_prb_end; n_prb++) { for (mcs = mcs_start; mcs < mcs_end; mcs++) { - for (uint32_t n = 0; n < SRSLTE_MAX_PRB_NR; n++) { + for (uint32_t n = 0; n < SRSRAN_MAX_PRB_NR; n++) { pdsch_grant.prb_idx[n] = (n < n_prb); } - if (srslte_ra_nr_fill_tb(&pdsch_cfg, &pdsch_grant, mcs, &pdsch_grant.tb[0]) < SRSLTE_SUCCESS) { + if (srsran_ra_nr_fill_tb(&pdsch_cfg, &pdsch_grant, mcs, &pdsch_grant.tb[0]) < SRSRAN_SUCCESS) { ERROR("Error filing tb"); goto clean_exit; } - for (uint32_t tb = 0; tb < SRSLTE_MAX_TB; tb++) { + for (uint32_t tb = 0; tb < SRSRAN_MAX_TB; tb++) { // Skip TB if no allocated if (data_tx[tb] == NULL) { continue; } for (uint32_t i = 0; i < pdsch_grant.tb[tb].tbs; i++) { - data_tx[tb][i] = (uint8_t)srslte_random_uniform_int_dist(rand_gen, 0, UINT8_MAX); + data_tx[tb][i] = (uint8_t)srsran_random_uniform_int_dist(rand_gen, 0, UINT8_MAX); } pdsch_grant.tb[tb].softbuffer.tx = &softbuffer_tx; } - if (srslte_pdsch_nr_encode(&pdsch_tx, &pdsch_cfg, &pdsch_grant, data_tx, sf_symbols) < SRSLTE_SUCCESS) { + if (srsran_pdsch_nr_encode(&pdsch_tx, &pdsch_cfg, &pdsch_grant, data_tx, sf_symbols) < SRSRAN_SUCCESS) { ERROR("Error encoding"); goto clean_exit; } - for (uint32_t tb = 0; tb < SRSLTE_MAX_TB; tb++) { + for (uint32_t tb = 0; tb < SRSRAN_MAX_TB; tb++) { pdsch_grant.tb[tb].softbuffer.rx = &softbuffer_rx; - srslte_softbuffer_rx_reset(pdsch_grant.tb[tb].softbuffer.rx); + srsran_softbuffer_rx_reset(pdsch_grant.tb[tb].softbuffer.rx); } for (uint32_t i = 0; i < pdsch_grant.tb->nof_re; i++) { @@ -225,7 +225,7 @@ int main(int argc, char** argv) } chest.nof_re = pdsch_grant.tb->nof_re; - if (srslte_pdsch_nr_decode(&pdsch_rx, &pdsch_cfg, &pdsch_grant, &chest, sf_symbols, pdsch_res) < SRSLTE_SUCCESS) { + if (srsran_pdsch_nr_decode(&pdsch_rx, &pdsch_cfg, &pdsch_grant, &chest, sf_symbols, pdsch_res) < SRSRAN_SUCCESS) { ERROR("Error encoding"); goto clean_exit; } @@ -236,7 +236,7 @@ int main(int argc, char** argv) } float mse = 0.0f; - uint32_t nof_re = srslte_ra_dl_nr_slot_nof_re(&pdsch_cfg, &pdsch_grant); + uint32_t nof_re = srsran_ra_dl_nr_slot_nof_re(&pdsch_cfg, &pdsch_grant); for (uint32_t i = 0; i < pdsch_grant.nof_layers; i++) { for (uint32_t j = 0; j < nof_re; j++) { mse += cabsf(pdsch_tx.d[i][j] - pdsch_rx.d[i][j]); @@ -249,9 +249,9 @@ int main(int argc, char** argv) ERROR("MSE error (%f) is too high", mse); for (uint32_t i = 0; i < pdsch_grant.nof_layers; i++) { printf("d_tx[%d]=", i); - srslte_vec_fprint_c(stdout, pdsch_tx.d[i], nof_re); + srsran_vec_fprint_c(stdout, pdsch_tx.d[i], nof_re); printf("d_rx[%d]=", i); - srslte_vec_fprint_c(stdout, pdsch_rx.d[i], nof_re); + srsran_vec_fprint_c(stdout, pdsch_rx.d[i], nof_re); } goto clean_exit; } @@ -264,9 +264,9 @@ int main(int argc, char** argv) if (memcmp(data_tx[0], data_rx[0], pdsch_grant.tb[0].tbs / 8) != 0) { ERROR("Failed to match Tx/Rx data; n_prb=%d; mcs=%d; TBS=%d;", n_prb, mcs, pdsch_grant.tb[0].tbs); printf("Tx data: "); - srslte_vec_fprint_byte(stdout, data_tx[0], pdsch_grant.tb[0].tbs / 8); + srsran_vec_fprint_byte(stdout, data_tx[0], pdsch_grant.tb[0].tbs / 8); printf("Rx data: "); - srslte_vec_fprint_byte(stdout, data_rx[0], pdsch_grant.tb[0].tbs / 8); + srsran_vec_fprint_byte(stdout, data_rx[0], pdsch_grant.tb[0].tbs / 8); goto clean_exit; } @@ -274,14 +274,14 @@ int main(int argc, char** argv) } } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; clean_exit: - srslte_chest_dl_res_free(&chest); - srslte_random_free(rand_gen); - srslte_pdsch_nr_free(&pdsch_tx); - srslte_pdsch_nr_free(&pdsch_rx); - for (uint32_t i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { + srsran_chest_dl_res_free(&chest); + srsran_random_free(rand_gen); + srsran_pdsch_nr_free(&pdsch_tx); + srsran_pdsch_nr_free(&pdsch_rx); + for (uint32_t i = 0; i < SRSRAN_MAX_CODEWORDS; i++) { if (data_tx[i]) { free(data_tx[i]); } @@ -289,13 +289,13 @@ clean_exit: free(data_rx[i]); } } - for (uint32_t i = 0; i < SRSLTE_MAX_LAYERS_NR; i++) { + for (uint32_t i = 0; i < SRSRAN_MAX_LAYERS_NR; i++) { if (sf_symbols[i]) { free(sf_symbols[i]); } } - srslte_softbuffer_tx_free(&softbuffer_tx); - srslte_softbuffer_rx_free(&softbuffer_rx); + srsran_softbuffer_tx_free(&softbuffer_tx); + srsran_softbuffer_rx_free(&softbuffer_rx); return ret; } diff --git a/lib/src/phy/phch/test/pdsch_pdcch_file_test.c b/lib/src/phy/phch/test/pdsch_pdcch_file_test.c index 8e3f3e7b9..238984289 100644 --- a/lib/src/phy/phch/test/pdsch_pdcch_file_test.c +++ b/lib/src/phy/phch/test/pdsch_pdcch_file_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -16,38 +16,38 @@ #include #include -#include "srslte/srslte.h" +#include "srsran/srsran.h" char* input_file_name = NULL; -srslte_cell_t cell = { +srsran_cell_t cell = { 6, // nof_prb 1, // nof_ports 0, // cell_id - SRSLTE_CP_NORM, // cyclic prefix - SRSLTE_PHICH_NORM, // PHICH length - SRSLTE_PHICH_R_1, // PHICH resources - SRSLTE_FDD, + SRSRAN_CP_NORM, // cyclic prefix + SRSRAN_PHICH_NORM, // PHICH length + SRSRAN_PHICH_R_1, // PHICH resources + SRSRAN_FDD, }; int flen; uint32_t cfi = 2; -uint16_t rnti = SRSLTE_SIRNTI; +uint16_t rnti = SRSRAN_SIRNTI; int max_frames = 10; uint32_t sf_idx = 0; -srslte_dci_format_t dci_format = SRSLTE_DCI_FORMAT1A; -srslte_filesource_t fsrc; -srslte_ue_dl_t ue_dl; -cf_t* input_buffer[SRSLTE_MAX_PORTS]; +srsran_dci_format_t dci_format = SRSRAN_DCI_FORMAT1A; +srsran_filesource_t fsrc; +srsran_ue_dl_t ue_dl; +cf_t* input_buffer[SRSRAN_MAX_PORTS]; void usage(char* prog) { printf("Usage: %s [rovfcenmps] -i input_file\n", prog); - printf("\t-o DCI format [Default %s]\n", srslte_dci_format_string(dci_format)); + printf("\t-o DCI format [Default %s]\n", srsran_dci_format_string(dci_format)); printf("\t-c cell.id [Default %d]\n", cell.id); printf("\t-s Start subframe_idx [Default %d]\n", sf_idx); printf("\t-f cfi [Default %d]\n", cfi); @@ -56,7 +56,7 @@ void usage(char* prog) printf("\t-n cell.nof_prb [Default %d]\n", cell.nof_prb); printf("\t-m max_frames [Default %d]\n", max_frames); printf("\t-e Set extended prefix [Default Normal]\n"); - printf("\t-v [set srslte_verbose to debug, default none]\n"); + printf("\t-v [set srsran_verbose to debug, default none]\n"); } void parse_args(int argc, char** argv) @@ -89,17 +89,17 @@ void parse_args(int argc, char** argv) cell.nof_ports = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'o': - dci_format = srslte_dci_format_from_string(argv[optind]); - if (dci_format == SRSLTE_DCI_NOF_FORMATS) { + dci_format = srsran_dci_format_from_string(argv[optind]); + if (dci_format == SRSRAN_DCI_NOF_FORMATS) { ERROR("Error unsupported format %s", argv[optind]); exit(-1); } break; case 'v': - srslte_verbose++; + srsran_verbose++; break; case 'e': - cell.cp = SRSLTE_CP_EXT; + cell.cp = SRSRAN_CP_EXT; break; default: usage(argv[0]); @@ -114,24 +114,24 @@ void parse_args(int argc, char** argv) int base_init() { - if (srslte_filesource_init(&fsrc, input_file_name, SRSLTE_COMPLEX_FLOAT_BIN)) { + if (srsran_filesource_init(&fsrc, input_file_name, SRSRAN_COMPLEX_FLOAT_BIN)) { ERROR("Error opening file %s", input_file_name); exit(-1); } - flen = SRSLTE_SF_LEN(srslte_symbol_sz(cell.nof_prb)); + flen = SRSRAN_SF_LEN(srsran_symbol_sz(cell.nof_prb)); - input_buffer[0] = srslte_vec_cf_malloc(flen); + input_buffer[0] = srsran_vec_cf_malloc(flen); if (!input_buffer[0]) { perror("malloc"); exit(-1); } - if (srslte_ue_dl_init(&ue_dl, input_buffer, cell.nof_prb, 1)) { + if (srsran_ue_dl_init(&ue_dl, input_buffer, cell.nof_prb, 1)) { ERROR("Error initializing UE DL"); return -1; } - if (srslte_ue_dl_set_cell(&ue_dl, cell)) { + if (srsran_ue_dl_set_cell(&ue_dl, cell)) { ERROR("Error initializing UE DL"); return -1; } @@ -142,8 +142,8 @@ int base_init() void base_free() { - srslte_filesource_free(&fsrc); - srslte_ue_dl_free(&ue_dl); + srsran_filesource_free(&fsrc); + srsran_ue_dl_free(&ue_dl); free(input_buffer[0]); } @@ -151,8 +151,8 @@ int main(int argc, char** argv) { int nof_frames; int ret; - bool acks[SRSLTE_MAX_TB]; - bzero(acks, sizeof(bool) * SRSLTE_MAX_TB); + bool acks[SRSRAN_MAX_TB]; + bzero(acks, sizeof(bool) * SRSRAN_MAX_TB); if (argc < 3) { usage(argv[0]); @@ -171,28 +171,28 @@ int main(int argc, char** argv) exit(-1); } - srslte_ue_dl_cfg_t ue_dl_cfg; + srsran_ue_dl_cfg_t ue_dl_cfg; ZERO_OBJECT(ue_dl_cfg); - srslte_dl_sf_cfg_t dl_sf; + srsran_dl_sf_cfg_t dl_sf; ZERO_OBJECT(dl_sf); - srslte_pdsch_cfg_t pdsch_cfg; + srsran_pdsch_cfg_t pdsch_cfg; ZERO_OBJECT(pdsch_cfg); - srslte_softbuffer_rx_t softbuffer_rx; - srslte_softbuffer_rx_init(&softbuffer_rx, cell.nof_prb); + srsran_softbuffer_rx_t softbuffer_rx; + srsran_softbuffer_rx_init(&softbuffer_rx, cell.nof_prb); pdsch_cfg.softbuffers.rx[0] = &softbuffer_rx; pdsch_cfg.rnti = rnti; ret = -1; nof_frames = 0; do { - srslte_filesource_read(&fsrc, input_buffer[0], flen); + srsran_filesource_read(&fsrc, input_buffer[0], flen); INFO("Reading %d samples sub-frame %d", flen, sf_idx); dl_sf.tti = sf_idx; - ret = srslte_ue_dl_find_and_decode(&ue_dl, &dl_sf, &ue_dl_cfg, &pdsch_cfg, data, acks); + ret = srsran_ue_dl_find_and_decode(&ue_dl, &dl_sf, &ue_dl_cfg, &pdsch_cfg, data, acks); if (ret > 0) { printf("PDSCH Decoded OK!\n"); } else if (ret == 0) { diff --git a/lib/src/phy/phch/test/pdsch_test.c b/lib/src/phy/phch/test/pdsch_test.c index b6bd622ac..e915e2949 100644 --- a/lib/src/phy/phch/test/pdsch_test.c +++ b/lib/src/phy/phch/test/pdsch_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -16,27 +16,27 @@ #include #include -#include "srslte/srslte.h" +#include "srsran/srsran.h" // Enable to measure execution time -#define NOF_CE_SYMBOLS SRSLTE_NOF_RE(cell) +#define NOF_CE_SYMBOLS SRSRAN_NOF_RE(cell) -static srslte_cell_t cell = { +static srsran_cell_t cell = { 6, // nof_prb 1, // nof_ports 0, // cell_id - SRSLTE_CP_NORM, // cyclic prefix - SRSLTE_PHICH_NORM, // PHICH length - SRSLTE_PHICH_R_1_6, // PHICH resources - SRSLTE_FDD, + SRSRAN_CP_NORM, // cyclic prefix + SRSRAN_PHICH_NORM, // PHICH length + SRSRAN_PHICH_R_1_6, // PHICH resources + SRSRAN_FDD, }; -static srslte_tm_t tm = SRSLTE_TM1; +static srsran_tm_t tm = SRSRAN_TM1; static uint32_t cfi = 1; -static uint32_t mcs[SRSLTE_MAX_CODEWORDS] = {0, 0}; +static uint32_t mcs[SRSRAN_MAX_CODEWORDS] = {0, 0}; static uint32_t subframe = 1; -static int rv_idx[SRSLTE_MAX_CODEWORDS] = {0, 1}; +static int rv_idx[SRSRAN_MAX_CODEWORDS] = {0, 1}; static uint16_t rnti = 1234; static uint32_t nof_rx_antennas = 1; static bool tb_cw_swap = false; @@ -67,7 +67,7 @@ void usage(char* prog) printf("\t-p pmi (multiplex only) [Default %d]\n", pmi); printf("\t-w Swap Transport Blocks\n"); printf("\t-j Enable PDSCH decoder coworker\n"); - printf("\t-v [set srslte_verbose to debug, default none]\n"); + printf("\t-v [set srsran_verbose to debug, default none]\n"); printf("\t-q Enable/Disable 256QAM modulation (default %s)\n", enable_256qam ? "enabled" : "disabled"); } @@ -107,7 +107,7 @@ void parse_args(int argc, char** argv) cfi = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'x': - tm = (srslte_tm_t)(strtol(argv[optind], NULL, 10) - 1); + tm = (srsran_tm_t)(strtol(argv[optind], NULL, 10) - 1); break; case 'p': pmi = (uint32_t)strtol(argv[optind], NULL, 10); @@ -128,7 +128,7 @@ void parse_args(int argc, char** argv) enable_coworker = true; break; case 'v': - srslte_verbose++; + srsran_verbose++; break; case 'q': enable_256qam ^= true; @@ -140,17 +140,17 @@ void parse_args(int argc, char** argv) } } -static int check_softbits(srslte_pdsch_t* pdsch_enb, - srslte_pdsch_t* pdsch_ue, - srslte_pdsch_cfg_t* pdsch_cfg, +static int check_softbits(srsran_pdsch_t* pdsch_enb, + srsran_pdsch_t* pdsch_ue, + srsran_pdsch_cfg_t* pdsch_cfg, uint32_t sf_idx, int tb) { - int ret = SRSLTE_SUCCESS; + int ret = SRSRAN_SUCCESS; if (!pdsch_ue->llr_is_8bit && !tb_cw_swap) { // Scramble - srslte_sequence_pdsch_apply_c(pdsch_ue->e[tb], + srsran_sequence_pdsch_apply_c(pdsch_ue->e[tb], pdsch_ue->e[tb], rnti, pdsch_cfg->grant.tb[tb].cw_idx, @@ -168,7 +168,7 @@ static int check_softbits(srslte_pdsch_t* pdsch_enb, rx_bytes[i] = w; } if (memcmp(pdsch_ue->e[tb], pdsch_enb->e[tb], pdsch_cfg->grant.tb[tb].nof_bits / 8) != 0) { - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } } return ret; @@ -178,22 +178,22 @@ int main(int argc, char** argv) { int ret = -1; struct timeval t[3] = {}; - srslte_softbuffer_tx_t* softbuffers_tx[SRSLTE_MAX_CODEWORDS]; - bool acks[SRSLTE_MAX_CODEWORDS] = {false}; - - uint8_t* data_tx[SRSLTE_MAX_CODEWORDS] = {NULL}; - uint8_t* data_rx[SRSLTE_MAX_CODEWORDS] = {NULL}; - srslte_softbuffer_rx_t* softbuffers_rx[SRSLTE_MAX_CODEWORDS]; - srslte_pdsch_cfg_t pdsch_cfg; - srslte_dl_sf_cfg_t dl_sf; - cf_t* tx_slot_symbols[SRSLTE_MAX_PORTS]; - cf_t* rx_slot_symbols[SRSLTE_MAX_PORTS]; - srslte_pdsch_t pdsch_tx, pdsch_rx; - srslte_ofdm_t ofdm_tx[SRSLTE_MAX_PORTS]; - srslte_ofdm_t ofdm_rx[SRSLTE_MAX_PORTS]; - srslte_chest_dl_t chest; - srslte_chest_dl_res_t chest_res; - srslte_pdsch_res_t pdsch_res[SRSLTE_MAX_CODEWORDS]; + srsran_softbuffer_tx_t* softbuffers_tx[SRSRAN_MAX_CODEWORDS]; + bool acks[SRSRAN_MAX_CODEWORDS] = {false}; + + uint8_t* data_tx[SRSRAN_MAX_CODEWORDS] = {NULL}; + uint8_t* data_rx[SRSRAN_MAX_CODEWORDS] = {NULL}; + srsran_softbuffer_rx_t* softbuffers_rx[SRSRAN_MAX_CODEWORDS]; + srsran_pdsch_cfg_t pdsch_cfg; + srsran_dl_sf_cfg_t dl_sf; + cf_t* tx_slot_symbols[SRSRAN_MAX_PORTS]; + cf_t* rx_slot_symbols[SRSRAN_MAX_PORTS]; + srsran_pdsch_t pdsch_tx, pdsch_rx; + srsran_ofdm_t ofdm_tx[SRSRAN_MAX_PORTS]; + srsran_ofdm_t ofdm_rx[SRSRAN_MAX_PORTS]; + srsran_chest_dl_t chest; + srsran_chest_dl_res_t chest_res; + srsran_pdsch_res_t pdsch_res[SRSRAN_MAX_CODEWORDS]; /* Initialise to zeros */ ZERO_OBJECT(softbuffers_tx); @@ -214,7 +214,7 @@ int main(int argc, char** argv) parse_args(argc, argv); - if (tm == SRSLTE_TM1) { + if (tm == SRSRAN_TM1) { cell.nof_ports = 1; mcs[1] = 0; rv_idx[1] = 1; @@ -222,19 +222,19 @@ int main(int argc, char** argv) cell.nof_ports = 2; } - srslte_dci_dl_t dci; + srsran_dci_dl_t dci; ZERO_OBJECT(dci); switch (tm) { - case SRSLTE_TM1: - case SRSLTE_TM2: - dci.format = SRSLTE_DCI_FORMAT1A; + case SRSRAN_TM1: + case SRSRAN_TM2: + dci.format = SRSRAN_DCI_FORMAT1A; break; - case SRSLTE_TM3: - dci.format = SRSLTE_DCI_FORMAT2A; + case SRSRAN_TM3: + dci.format = SRSRAN_DCI_FORMAT2A; break; - case SRSLTE_TM4: - dci.format = SRSLTE_DCI_FORMAT2; + case SRSRAN_TM4: + dci.format = SRSRAN_DCI_FORMAT2; break; default: fprintf(stderr, "Error unsupported tm=%d\n", tm); @@ -245,15 +245,15 @@ int main(int argc, char** argv) /* If transport block 0 is enabled */ uint32_t nof_tb = 0; - for (int i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { + for (int i = 0; i < SRSRAN_MAX_CODEWORDS; i++) { dci.tb[i].mcs_idx = mcs[i]; dci.tb[i].rv = rv_idx[i]; - if (SRSLTE_DCI_IS_TB_EN(dci.tb[i])) { + if (SRSRAN_DCI_IS_TB_EN(dci.tb[i])) { nof_tb++; } } - for (int i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { + for (int i = 0; i < SRSRAN_MAX_CODEWORDS; i++) { dci.tb[i].cw_idx = (((tb_cw_swap) ? 1 : 0) + i) % nof_tb; } @@ -264,46 +264,46 @@ int main(int argc, char** argv) // Enable power allocation pdsch_cfg.power_scale = true; pdsch_cfg.p_a = 0.0f; // 0 dB - pdsch_cfg.p_b = (tm > SRSLTE_TM1) ? 1 : 0; // 0 dB + pdsch_cfg.p_b = (tm > SRSRAN_TM1) ? 1 : 0; // 0 dB /* Generate dci from DCI */ - if (srslte_ra_dl_dci_to_grant(&cell, &dl_sf, tm, enable_256qam, &dci, &pdsch_cfg.grant)) { + if (srsran_ra_dl_dci_to_grant(&cell, &dl_sf, tm, enable_256qam, &dci, &pdsch_cfg.grant)) { ERROR("Error computing resource allocation"); return ret; } - srslte_chest_dl_res_init(&chest_res, cell.nof_prb); - srslte_chest_dl_res_set_identity(&chest_res); + srsran_chest_dl_res_init(&chest_res, cell.nof_prb); + srsran_chest_dl_res_set_identity(&chest_res); /* init memory */ - for (uint32_t i = 0; i < SRSLTE_MAX_PORTS; i++) { - rx_slot_symbols[i] = srslte_vec_cf_malloc(SRSLTE_NOF_RE(cell)); + for (uint32_t i = 0; i < SRSRAN_MAX_PORTS; i++) { + rx_slot_symbols[i] = srsran_vec_cf_malloc(SRSRAN_NOF_RE(cell)); if (!rx_slot_symbols[i]) { - perror("srslte_vec_malloc"); + perror("srsran_vec_malloc"); goto quit; } } for (uint32_t i = 0; i < cell.nof_ports; i++) { - tx_slot_symbols[i] = calloc(SRSLTE_NOF_RE(cell), sizeof(cf_t)); + tx_slot_symbols[i] = calloc(SRSRAN_NOF_RE(cell), sizeof(cf_t)); if (!tx_slot_symbols[i]) { - perror("srslte_vec_malloc"); + perror("srsran_vec_malloc"); goto quit; } } - for (uint32_t i = 0; i < SRSLTE_MAX_TB; i++) { + for (uint32_t i = 0; i < SRSRAN_MAX_TB; i++) { if (pdsch_cfg.grant.tb[i].enabled) { - data_tx[i] = srslte_vec_u8_malloc(pdsch_cfg.grant.tb[i].tbs); + data_tx[i] = srsran_vec_u8_malloc(pdsch_cfg.grant.tb[i].tbs); if (!data_tx[i]) { - perror("srslte_vec_malloc"); + perror("srsran_vec_malloc"); goto quit; } bzero(data_tx[i], sizeof(uint8_t) * pdsch_cfg.grant.tb[i].tbs); - data_rx[i] = srslte_vec_u8_malloc(pdsch_cfg.grant.tb[i].tbs); + data_rx[i] = srsran_vec_u8_malloc(pdsch_cfg.grant.tb[i].tbs); if (!data_rx[i]) { - perror("srslte_vec_malloc"); + perror("srsran_vec_malloc"); goto quit; } bzero(data_rx[i], sizeof(uint8_t) * pdsch_cfg.grant.tb[i].tbs); @@ -314,11 +314,11 @@ int main(int argc, char** argv) } } - if (srslte_pdsch_init_ue(&pdsch_rx, cell.nof_prb, nof_rx_antennas)) { + if (srsran_pdsch_init_ue(&pdsch_rx, cell.nof_prb, nof_rx_antennas)) { ERROR("Error creating PDSCH object"); goto quit; } - if (srslte_pdsch_set_cell(&pdsch_rx, cell)) { + if (srsran_pdsch_set_cell(&pdsch_rx, cell)) { ERROR("Error creating PDSCH object"); goto quit; } @@ -326,64 +326,64 @@ int main(int argc, char** argv) pdsch_rx.llr_is_8bit = use_8_bit; pdsch_rx.dl_sch.llr_is_8bit = use_8_bit; - for (uint32_t i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { - softbuffers_rx[i] = calloc(sizeof(srslte_softbuffer_rx_t), 1); + for (uint32_t i = 0; i < SRSRAN_MAX_CODEWORDS; i++) { + softbuffers_rx[i] = calloc(sizeof(srsran_softbuffer_rx_t), 1); if (!softbuffers_rx[i]) { ERROR("Error allocating RX soft buffer"); goto quit; } - if (srslte_softbuffer_rx_init(softbuffers_rx[i], cell.nof_prb)) { + if (srsran_softbuffer_rx_init(softbuffers_rx[i], cell.nof_prb)) { ERROR("Error initiating RX soft buffer"); goto quit; } - srslte_softbuffer_rx_reset(softbuffers_rx[i]); + srsran_softbuffer_rx_reset(softbuffers_rx[i]); } if (input_file) { - srslte_filesource_t fsrc; - if (srslte_filesource_init(&fsrc, input_file, SRSLTE_COMPLEX_FLOAT_BIN)) { + srsran_filesource_t fsrc; + if (srsran_filesource_init(&fsrc, input_file, SRSRAN_COMPLEX_FLOAT_BIN)) { ERROR("Error opening file %s", input_file); goto quit; } - if (srslte_chest_dl_init(&chest, cell.nof_prb, 1)) { + if (srsran_chest_dl_init(&chest, cell.nof_prb, 1)) { ERROR("Error initializing equalizer"); exit(-1); } - if (srslte_chest_dl_set_cell(&chest, cell)) { + if (srsran_chest_dl_set_cell(&chest, cell)) { printf("Error initializing equalizer\n"); exit(-1); } - srslte_chest_dl_estimate(&chest, &dl_sf, rx_slot_symbols, &chest_res); - srslte_chest_dl_free(&chest); + srsran_chest_dl_estimate(&chest, &dl_sf, rx_slot_symbols, &chest_res); + srsran_chest_dl_free(&chest); - srslte_filesource_free(&fsrc); + srsran_filesource_free(&fsrc); } else { - if (srslte_pdsch_init_enb(&pdsch_tx, cell.nof_prb)) { + if (srsran_pdsch_init_enb(&pdsch_tx, cell.nof_prb)) { ERROR("Error creating PDSCH object"); goto quit; } - if (srslte_pdsch_set_cell(&pdsch_tx, cell)) { + if (srsran_pdsch_set_cell(&pdsch_tx, cell)) { ERROR("Error creating PDSCH object"); goto quit; } - for (uint32_t i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { - softbuffers_tx[i] = calloc(sizeof(srslte_softbuffer_tx_t), 1); + for (uint32_t i = 0; i < SRSRAN_MAX_CODEWORDS; i++) { + softbuffers_tx[i] = calloc(sizeof(srsran_softbuffer_tx_t), 1); if (!softbuffers_tx[i]) { ERROR("Error allocating TX soft buffer"); } - if (srslte_softbuffer_tx_init(softbuffers_tx[i], cell.nof_prb)) { + if (srsran_softbuffer_tx_init(softbuffers_tx[i], cell.nof_prb)) { ERROR("Error initiating TX soft buffer"); goto quit; } } - for (int tb = 0; tb < SRSLTE_MAX_CODEWORDS; tb++) { + for (int tb = 0; tb < SRSRAN_MAX_CODEWORDS; tb++) { if (pdsch_cfg.grant.tb[tb].enabled) { for (int byte = 0; byte < pdsch_cfg.grant.tb[tb].tbs / 8; byte++) { data_tx[tb][byte] = (uint8_t)(rand() % 256); @@ -392,28 +392,28 @@ int main(int argc, char** argv) } /*uint8_t databit[100000]; - srslte_bit_unpack_vector(data, databit, dci.mcs.tbs); - srslte_vec_save_file("data_in", databit, dci.mcs.tbs);*/ + srsran_bit_unpack_vector(data, databit, dci.mcs.tbs); + srsran_vec_save_file("data_in", databit, dci.mcs.tbs);*/ pdsch_cfg.rnti = rnti; pdsch_cfg.softbuffers.tx[0] = softbuffers_tx[0]; pdsch_cfg.softbuffers.tx[1] = softbuffers_tx[1]; if (rv_idx[0] != 0) { - for (int i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { + for (int i = 0; i < SRSRAN_MAX_CODEWORDS; i++) { pdsch_cfg.grant.tb[i].rv = 0; } /* Do 1st transmission for rv_idx!=0 */ - if (srslte_pdsch_encode(&pdsch_tx, &dl_sf, &pdsch_cfg, data_tx, tx_slot_symbols)) { + if (srsran_pdsch_encode(&pdsch_tx, &dl_sf, &pdsch_cfg, data_tx, tx_slot_symbols)) { ERROR("Error encoding PDSCH"); goto quit; } } gettimeofday(&t[1], NULL); - for (int i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { + for (int i = 0; i < SRSRAN_MAX_CODEWORDS; i++) { pdsch_cfg.grant.tb[i].rv = rv_idx[i]; } for (uint32_t k = 0; k < M; k++) { - if (srslte_pdsch_encode(&pdsch_tx, &dl_sf, &pdsch_cfg, data_tx, tx_slot_symbols)) { + if (srsran_pdsch_encode(&pdsch_tx, &dl_sf, &pdsch_cfg, data_tx, tx_slot_symbols)) { ERROR("Error encoding PDSCH"); goto quit; } @@ -427,7 +427,7 @@ int main(int argc, char** argv) /* combine outputs */ for (uint32_t j = 0; j < nof_rx_antennas; j++) { - for (uint32_t k = 0; k < SRSLTE_NOF_RE(cell); k++) { + for (uint32_t k = 0; k < SRSRAN_NOF_RE(cell); k++) { rx_slot_symbols[j][k] = 0.0f; for (uint32_t i = 0; i < cell.nof_ports; i++) { rx_slot_symbols[j][k] += tx_slot_symbols[i][k] * chest_res.ce[i][j][k]; @@ -440,18 +440,18 @@ int main(int argc, char** argv) INFO(" nof_prb=%d", cell.nof_prb); INFO(" nof_ports=%d", cell.nof_ports); INFO(" id=%d", cell.id); - INFO(" cp=%s", srslte_cp_string(cell.cp)); + INFO(" cp=%s", srsran_cp_string(cell.cp)); INFO(" phich_length=%d", (int)cell.phich_length); INFO(" phich_resources=%d", (int)cell.phich_resources); INFO(" nof_prb=%d", pdsch_cfg.grant.nof_prb); INFO(" sf_idx=%d", dl_sf.tti); INFO(" nof_tb=%d", pdsch_cfg.grant.nof_tb); - for (uint32_t i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { + for (uint32_t i = 0; i < SRSRAN_MAX_CODEWORDS; i++) { INFO(" Tranport block index %d:", i); INFO(" enabled=%d", pdsch_cfg.grant.tb[i].enabled); INFO(" mcs.idx=%d", pdsch_cfg.grant.tb[i].mcs_idx); INFO(" mcs.tbs=%d", pdsch_cfg.grant.tb[i].tbs); - INFO(" mcs.mod=%s", srslte_mod_string(pdsch_cfg.grant.tb[i].mod)); + INFO(" mcs.mod=%s", srsran_mod_string(pdsch_cfg.grant.tb[i].mod)); INFO(" rv=%d", pdsch_cfg.grant.tb[i].rv); INFO(" nof_bits=%d", pdsch_cfg.grant.tb[i].nof_bits); INFO(" nof_re=%d", pdsch_cfg.grant.nof_re); @@ -459,26 +459,26 @@ int main(int argc, char** argv) int r = 0; if (enable_coworker) { - srslte_pdsch_enable_coworker(&pdsch_rx); + srsran_pdsch_enable_coworker(&pdsch_rx); } - for (uint32_t i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { + for (uint32_t i = 0; i < SRSRAN_MAX_CODEWORDS; i++) { pdsch_cfg.softbuffers.rx[i] = softbuffers_rx[i]; pdsch_res[i].payload = data_rx[i]; } gettimeofday(&t[1], NULL); for (uint32_t k = 0; k < M; k++) { - for (uint32_t i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { + for (uint32_t i = 0; i < SRSRAN_MAX_CODEWORDS; i++) { if (pdsch_cfg.grant.tb[i].enabled) { - srslte_softbuffer_rx_reset_tbs(softbuffers_rx[i], (uint32_t)pdsch_cfg.grant.tb[i].tbs); + srsran_softbuffer_rx_reset_tbs(softbuffers_rx[i], (uint32_t)pdsch_cfg.grant.tb[i].tbs); } } /* Set ACKs to zero, otherwise will not decode if there are positive ACKs*/ bzero(acks, sizeof(acks)); - r = srslte_pdsch_decode(&pdsch_rx, &dl_sf, &pdsch_cfg, &chest_res, rx_slot_symbols, pdsch_res); + r = srsran_pdsch_decode(&pdsch_rx, &dl_sf, &pdsch_cfg, &chest_res, rx_slot_symbols, pdsch_res); } gettimeofday(&t[2], NULL); get_time_interval(t); @@ -495,7 +495,7 @@ int main(int argc, char** argv) } /* Check Tx and Rx bytes */ - for (int tb = 0; tb < SRSLTE_MAX_CODEWORDS; tb++) { + for (int tb = 0; tb < SRSRAN_MAX_CODEWORDS; tb++) { if (pdsch_cfg.grant.tb[tb].enabled) { if (check_softbits(&pdsch_tx, &pdsch_rx, &pdsch_cfg, subframe, tb)) { printf("TB%d: The received softbits in subframe %d DO NOT match the encoded bits (crc=%d)\n", @@ -510,7 +510,7 @@ int main(int argc, char** argv) tb, data_tx[tb][byte], data_rx[tb][byte]); - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; goto quit; } } @@ -519,32 +519,32 @@ int main(int argc, char** argv) } /* Check all transport blocks have been decoded OK */ - for (int tb = 0; tb < SRSLTE_MAX_CODEWORDS; tb++) { + for (int tb = 0; tb < SRSRAN_MAX_CODEWORDS; tb++) { if (pdsch_cfg.grant.tb[tb].enabled) { - ret |= (acks[tb]) ? SRSLTE_SUCCESS : SRSLTE_ERROR; + ret |= (acks[tb]) ? SRSRAN_SUCCESS : SRSRAN_ERROR; } } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; quit: for (uint32_t i = 0; i < cell.nof_ports; i++) { - srslte_ofdm_tx_free(&ofdm_tx[i]); + srsran_ofdm_tx_free(&ofdm_tx[i]); } for (uint32_t i = 0; i < nof_rx_antennas; i++) { - srslte_ofdm_rx_free(&ofdm_rx[i]); + srsran_ofdm_rx_free(&ofdm_rx[i]); } - srslte_chest_dl_res_free(&chest_res); - srslte_chest_dl_free(&chest); - srslte_pdsch_free(&pdsch_tx); - srslte_pdsch_free(&pdsch_rx); - for (uint32_t i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { - srslte_softbuffer_tx_free(softbuffers_tx[i]); + srsran_chest_dl_res_free(&chest_res); + srsran_chest_dl_free(&chest); + srsran_pdsch_free(&pdsch_tx); + srsran_pdsch_free(&pdsch_rx); + for (uint32_t i = 0; i < SRSRAN_MAX_CODEWORDS; i++) { + srsran_softbuffer_tx_free(softbuffers_tx[i]); if (softbuffers_tx[i]) { free(softbuffers_tx[i]); } - srslte_softbuffer_rx_free(softbuffers_rx[i]); + srsran_softbuffer_rx_free(softbuffers_rx[i]); if (softbuffers_rx[i]) { free(softbuffers_rx[i]); } @@ -558,7 +558,7 @@ quit: } } - for (uint32_t i = 0; i < SRSLTE_MAX_PORTS; i++) { + for (uint32_t i = 0; i < SRSRAN_MAX_PORTS; i++) { if (tx_slot_symbols[i]) { free(tx_slot_symbols[i]); } diff --git a/lib/src/phy/phch/test/phich_file_test.c b/lib/src/phy/phch/test/phich_file_test.c index d31c5f9db..dc9e61c9a 100644 --- a/lib/src/phy/phch/test/phich_file_test.c +++ b/lib/src/phy/phch/test/phich_file_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -16,19 +16,19 @@ #include #include -#include "srslte/srslte.h" +#include "srsran/srsran.h" char* input_file_name = NULL; char* matlab_file_name = NULL; -srslte_cell_t cell = { +srsran_cell_t cell = { 50, // cell.nof_prb 2, // cell.nof_ports 150, // cell.id - SRSLTE_CP_NORM, // cyclic prefix - SRSLTE_PHICH_NORM, // PHICH length - SRSLTE_PHICH_R_1, // PHICH resources - SRSLTE_FDD, + SRSRAN_CP_NORM, // cyclic prefix + SRSRAN_PHICH_NORM, // PHICH length + SRSRAN_PHICH_R_1, // PHICH resources + SRSRAN_FDD, }; @@ -38,13 +38,13 @@ int numsubframe = 0; FILE* fmatlab = NULL; -srslte_filesource_t fsrc; -cf_t * input_buffer, *fft_buffer[SRSLTE_MAX_CODEWORDS]; -srslte_phich_t phich; -srslte_regs_t regs; -srslte_ofdm_t fft; -srslte_chest_dl_t chest; -srslte_chest_dl_res_t chest_res; +srsran_filesource_t fsrc; +cf_t * input_buffer, *fft_buffer[SRSRAN_MAX_CODEWORDS]; +srsran_phich_t phich; +srsran_regs_t regs; +srsran_ofdm_t fft; +srsran_chest_dl_t chest; +srsran_chest_dl_res_t chest_res; void usage(char* prog) { @@ -57,7 +57,7 @@ void usage(char* prog) printf("\t-g phich ng factor: 1/6, 1/2, 1, 2 [Default 1]\n"); printf("\t-e phich extended length [Default normal]\n"); printf("\t-l extended cyclic prefix [Default normal]\n"); - printf("\t-v [set srslte_verbose to debug, default none]\n"); + printf("\t-v [set srsran_verbose to debug, default none]\n"); } void parse_args(int argc, char** argv) @@ -79,19 +79,19 @@ void parse_args(int argc, char** argv) break; case 'g': if (!strcmp(argv[optind], "1/6")) { - cell.phich_resources = SRSLTE_PHICH_R_1_6; + cell.phich_resources = SRSRAN_PHICH_R_1_6; } else if (!strcmp(argv[optind], "1/2")) { - cell.phich_resources = SRSLTE_PHICH_R_1_2; + cell.phich_resources = SRSRAN_PHICH_R_1_2; } else if (!strcmp(argv[optind], "1")) { - cell.phich_resources = SRSLTE_PHICH_R_1; + cell.phich_resources = SRSRAN_PHICH_R_1; } else if (!strcmp(argv[optind], "2")) { - cell.phich_resources = SRSLTE_PHICH_R_2; + cell.phich_resources = SRSRAN_PHICH_R_2; } else { ERROR("Invalid phich ng factor %s. Setting to default.", argv[optind]); } break; case 'e': - cell.phich_length = SRSLTE_PHICH_EXT; + cell.phich_length = SRSRAN_PHICH_EXT; break; case 'n': cell.nof_prb = (uint32_t)strtol(argv[optind], NULL, 10); @@ -100,10 +100,10 @@ void parse_args(int argc, char** argv) cell.nof_ports = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'v': - srslte_verbose++; + srsran_verbose++; break; case 'l': - cell.cp = SRSLTE_CP_EXT; + cell.cp = SRSRAN_CP_EXT; break; default: usage(argv[0]); @@ -118,7 +118,7 @@ void parse_args(int argc, char** argv) int base_init() { - if (srslte_filesource_init(&fsrc, input_file_name, SRSLTE_COMPLEX_FLOAT_BIN)) { + if (srsran_filesource_init(&fsrc, input_file_name, SRSRAN_COMPLEX_FLOAT_BIN)) { ERROR("Error opening file %s", input_file_name); exit(-1); } @@ -133,48 +133,48 @@ int base_init() fmatlab = NULL; } - flen = SRSLTE_SF_LEN(srslte_symbol_sz(cell.nof_prb)); + flen = SRSRAN_SF_LEN(srsran_symbol_sz(cell.nof_prb)); - input_buffer = srslte_vec_cf_malloc(flen); + input_buffer = srsran_vec_cf_malloc(flen); if (!input_buffer) { perror("malloc"); exit(-1); } - fft_buffer[0] = srslte_vec_cf_malloc(SRSLTE_NOF_RE(cell)); + fft_buffer[0] = srsran_vec_cf_malloc(SRSRAN_NOF_RE(cell)); if (!fft_buffer[0]) { perror("malloc"); return -1; } - if (srslte_chest_dl_init(&chest, cell.nof_prb, 1)) { + if (srsran_chest_dl_init(&chest, cell.nof_prb, 1)) { ERROR("Error initializing equalizer"); return -1; } - if (srslte_chest_dl_res_init(&chest_res, cell.nof_prb)) { + if (srsran_chest_dl_res_init(&chest_res, cell.nof_prb)) { ERROR("Error initializing equalizer"); return -1; } - if (srslte_chest_dl_set_cell(&chest, cell)) { + if (srsran_chest_dl_set_cell(&chest, cell)) { ERROR("Error initializing equalizer"); return -1; } - if (srslte_ofdm_rx_init(&fft, cell.cp, input_buffer, fft_buffer[0], cell.nof_prb)) { + if (srsran_ofdm_rx_init(&fft, cell.cp, input_buffer, fft_buffer[0], cell.nof_prb)) { ERROR("Error initializing FFT"); return -1; } - if (srslte_regs_init(®s, cell)) { + if (srsran_regs_init(®s, cell)) { ERROR("Error initiating regs"); return -1; } - if (srslte_phich_init(&phich, 1)) { + if (srsran_phich_init(&phich, 1)) { ERROR("Error creating PBCH object"); return -1; } - if (srslte_phich_set_cell(&phich, ®s, cell)) { + if (srsran_phich_set_cell(&phich, ®s, cell)) { ERROR("Error creating PBCH object"); return -1; } @@ -185,7 +185,7 @@ int base_init() void base_free() { - srslte_filesource_free(&fsrc); + srsran_filesource_free(&fsrc); if (fmatlab) { fclose(fmatlab); } @@ -193,14 +193,14 @@ void base_free() free(input_buffer); free(fft_buffer[0]); - srslte_filesource_free(&fsrc); + srsran_filesource_free(&fsrc); - srslte_chest_dl_res_free(&chest_res); - srslte_chest_dl_free(&chest); - srslte_ofdm_rx_free(&fft); + srsran_chest_dl_res_free(&chest_res); + srsran_chest_dl_free(&chest); + srsran_ofdm_rx_free(&fft); - srslte_phich_free(&phich); - srslte_regs_free(®s); + srsran_phich_free(&phich); + srsran_regs_free(®s); } int main(int argc, char** argv) @@ -215,46 +215,46 @@ int main(int argc, char** argv) parse_args(argc, argv); - max_nseq = SRSLTE_CP_ISNORM(cell.cp) ? SRSLTE_PHICH_NORM_NSEQUENCES : SRSLTE_PHICH_EXT_NSEQUENCES; + max_nseq = SRSRAN_CP_ISNORM(cell.cp) ? SRSRAN_PHICH_NORM_NSEQUENCES : SRSRAN_PHICH_EXT_NSEQUENCES; if (base_init()) { ERROR("Error initializing memory"); exit(-1); } - n = srslte_filesource_read(&fsrc, input_buffer, flen); + n = srsran_filesource_read(&fsrc, input_buffer, flen); - srslte_ofdm_rx_sf(&fft); + srsran_ofdm_rx_sf(&fft); if (fmatlab) { fprintf(fmatlab, "infft="); - srslte_vec_fprint_c(fmatlab, input_buffer, flen); + srsran_vec_fprint_c(fmatlab, input_buffer, flen); fprintf(fmatlab, ";\n"); fprintf(fmatlab, "outfft="); - srslte_vec_fprint_c(fmatlab, fft_buffer[0], SRSLTE_CP_NSYMB(cell.cp) * cell.nof_prb * SRSLTE_NRE); + srsran_vec_fprint_c(fmatlab, fft_buffer[0], SRSRAN_CP_NSYMB(cell.cp) * cell.nof_prb * SRSRAN_NRE); fprintf(fmatlab, ";\n"); } - srslte_dl_sf_cfg_t dl_sf; + srsran_dl_sf_cfg_t dl_sf; ZERO_OBJECT(dl_sf); dl_sf.tti = numsubframe; /* Get channel estimates for each port */ - srslte_chest_dl_estimate(&chest, &dl_sf, fft_buffer, &chest_res); + srsran_chest_dl_estimate(&chest, &dl_sf, fft_buffer, &chest_res); INFO("Decoding PHICH"); /* Receive all PHICH groups and sequence numbers */ - for (ngroup = 0; ngroup < srslte_phich_ngroups(&phich); ngroup++) { + for (ngroup = 0; ngroup < srsran_phich_ngroups(&phich); ngroup++) { for (nseq = 0; nseq < max_nseq; nseq++) { - srslte_phich_resource_t resource; + srsran_phich_resource_t resource; resource.ngroup = ngroup; resource.nseq = nseq; - srslte_phich_res_t res; + srsran_phich_res_t res; - if (srslte_phich_decode(&phich, &dl_sf, &chest_res, resource, fft_buffer, &res) < 0) { + if (srsran_phich_decode(&phich, &dl_sf, &chest_res, resource, fft_buffer, &res) < 0) { printf("Error decoding ACK\n"); exit(-1); } diff --git a/lib/src/phy/phch/test/phich_test.c b/lib/src/phy/phch/test/phich_test.c index 46a9dc47a..443590f86 100644 --- a/lib/src/phy/phch/test/phich_test.c +++ b/lib/src/phy/phch/test/phich_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -16,21 +16,21 @@ #include #include -#include "srslte/srslte.h" +#include "srsran/srsran.h" -srslte_cell_t cell = { +srsran_cell_t cell = { 6, // nof_prb 1, // nof_ports 1000, // cell_id - SRSLTE_CP_NORM, // cyclic prefix - SRSLTE_PHICH_NORM, // PHICH length - SRSLTE_PHICH_R_1_6, - SRSLTE_FDD, + SRSRAN_CP_NORM, // cyclic prefix + SRSRAN_PHICH_NORM, // PHICH length + SRSRAN_PHICH_R_1_6, + SRSRAN_FDD, }; -srslte_phich_r_t phich_res = SRSLTE_PHICH_R_1; -srslte_phich_length_t phich_length = SRSLTE_PHICH_NORM; +srsran_phich_r_t phich_res = SRSRAN_PHICH_R_1; +srsran_phich_length_t phich_length = SRSRAN_PHICH_NORM; void usage(char* prog) { @@ -41,7 +41,7 @@ void usage(char* prog) printf("\t-g phich ng factor: 1/6, 1/2, 1, 2 [Default 1]\n"); printf("\t-e phich extended length [Default normal]\n"); printf("\t-l extended cyclic prefix [Default normal]\n"); - printf("\t-v [set srslte_verbose to debug, default none]\n"); + printf("\t-v [set srsran_verbose to debug, default none]\n"); } void parse_args(int argc, char** argv) @@ -60,25 +60,25 @@ void parse_args(int argc, char** argv) break; case 'g': if (!strcmp(argv[optind], "1/6")) { - phich_res = SRSLTE_PHICH_R_1_6; + phich_res = SRSRAN_PHICH_R_1_6; } else if (!strcmp(argv[optind], "1/2")) { - phich_res = SRSLTE_PHICH_R_1_2; + phich_res = SRSRAN_PHICH_R_1_2; } else if (!strcmp(argv[optind], "1")) { - phich_res = SRSLTE_PHICH_R_1; + phich_res = SRSRAN_PHICH_R_1; } else if (!strcmp(argv[optind], "2")) { - phich_res = SRSLTE_PHICH_R_2; + phich_res = SRSRAN_PHICH_R_2; } else { ERROR("Invalid phich ng factor %s. Setting to default.", argv[optind]); } break; case 'e': - phich_length = SRSLTE_PHICH_EXT; + phich_length = SRSRAN_PHICH_EXT; break; case 'l': - cell.cp = SRSLTE_CP_EXT; + cell.cp = SRSRAN_CP_EXT; break; case 'v': - srslte_verbose++; + srsran_verbose++; break; default: usage(argv[0]); @@ -89,30 +89,30 @@ void parse_args(int argc, char** argv) int main(int argc, char** argv) { - srslte_phich_t phich; - srslte_regs_t regs; + srsran_phich_t phich; + srsran_regs_t regs; int i, j; int nof_re; - cf_t* slot_symbols[SRSLTE_MAX_PORTS]; - uint8_t ack[50][SRSLTE_PHICH_NORM_NSEQUENCES]; + cf_t* slot_symbols[SRSRAN_MAX_PORTS]; + uint8_t ack[50][SRSRAN_PHICH_NORM_NSEQUENCES]; uint32_t nsf; int cid, max_cid; uint32_t ngroup, nseq, max_nseq; parse_args(argc, argv); - max_nseq = SRSLTE_CP_ISNORM(cell.cp) ? SRSLTE_PHICH_NORM_NSEQUENCES : SRSLTE_PHICH_EXT_NSEQUENCES; + max_nseq = SRSRAN_CP_ISNORM(cell.cp) ? SRSRAN_PHICH_NORM_NSEQUENCES : SRSRAN_PHICH_EXT_NSEQUENCES; - nof_re = SRSLTE_CP_NORM_NSYMB * cell.nof_prb * SRSLTE_NRE; + nof_re = SRSRAN_CP_NORM_NSYMB * cell.nof_prb * SRSRAN_NRE; /* init memory */ - srslte_chest_dl_res_t chest_res; - srslte_chest_dl_res_init(&chest_res, cell.nof_prb); - srslte_chest_dl_res_set_ones(&chest_res); + srsran_chest_dl_res_t chest_res; + srsran_chest_dl_res_init(&chest_res, cell.nof_prb); + srsran_chest_dl_res_set_ones(&chest_res); - for (i = 0; i < SRSLTE_MAX_PORTS; i++) { - slot_symbols[i] = srslte_vec_cf_malloc(nof_re); + for (i = 0; i < SRSRAN_MAX_PORTS; i++) { + slot_symbols[i] = srsran_vec_cf_malloc(nof_re); if (!slot_symbols[i]) { perror("malloc"); exit(-1); @@ -126,7 +126,7 @@ int main(int argc, char** argv) cid = cell.id; max_cid = cell.id; } - if (srslte_phich_init(&phich, 1)) { + if (srsran_phich_init(&phich, 1)) { ERROR("Error creating PBCH object"); exit(-1); } @@ -135,35 +135,35 @@ int main(int argc, char** argv) printf("Testing CellID=%d...\n", cid); - if (srslte_regs_init(®s, cell)) { + if (srsran_regs_init(®s, cell)) { ERROR("Error initiating regs"); exit(-1); } - if (srslte_phich_set_cell(&phich, ®s, cell)) { + if (srsran_phich_set_cell(&phich, ®s, cell)) { ERROR("Error creating PBCH object"); exit(-1); } - srslte_dl_sf_cfg_t dl_sf; + srsran_dl_sf_cfg_t dl_sf; ZERO_OBJECT(dl_sf); for (nsf = 0; nsf < 10; nsf++) { dl_sf.tti = nsf; - srslte_phich_reset(&phich, slot_symbols); + srsran_phich_reset(&phich, slot_symbols); - srslte_phich_resource_t resource; + srsran_phich_resource_t resource; /* Transmit all PHICH groups and sequence numbers */ - for (ngroup = 0; ngroup < srslte_phich_ngroups(&phich); ngroup++) { + for (ngroup = 0; ngroup < srsran_phich_ngroups(&phich); ngroup++) { for (nseq = 0; nseq < max_nseq; nseq++) { resource.ngroup = ngroup; resource.nseq = nseq; ack[ngroup][nseq] = rand() % 2; - srslte_phich_encode(&phich, &dl_sf, resource, ack[ngroup][nseq], slot_symbols); + srsran_phich_encode(&phich, &dl_sf, resource, ack[ngroup][nseq], slot_symbols); } } /* combine outputs */ @@ -174,14 +174,14 @@ int main(int argc, char** argv) } /* Receive all PHICH groups and sequence numbers */ - for (ngroup = 0; ngroup < srslte_phich_ngroups(&phich); ngroup++) { + for (ngroup = 0; ngroup < srsran_phich_ngroups(&phich); ngroup++) { for (nseq = 0; nseq < max_nseq; nseq++) { resource.ngroup = ngroup; resource.nseq = nseq; - srslte_phich_res_t result; + srsran_phich_res_t result; - if (srslte_phich_decode(&phich, &dl_sf, &chest_res, resource, slot_symbols, &result) < 0) { + if (srsran_phich_decode(&phich, &dl_sf, &chest_res, resource, slot_symbols, &result) < 0) { printf("Error decoding ACK\n"); exit(-1); } @@ -203,14 +203,14 @@ int main(int argc, char** argv) } } } - srslte_regs_free(®s); + srsran_regs_free(®s); cid++; } - srslte_phich_free(&phich); + srsran_phich_free(&phich); - srslte_chest_dl_res_free(&chest_res); + srsran_chest_dl_res_free(&chest_res); - for (i = 0; i < SRSLTE_MAX_PORTS; i++) { + for (i = 0; i < SRSRAN_MAX_PORTS; i++) { free(slot_symbols[i]); } printf("OK\n"); diff --git a/lib/src/phy/phch/test/pmch_file_test.c b/lib/src/phy/phch/test/pmch_file_test.c index 028ebff58..4188bc9ed 100644 --- a/lib/src/phy/phch/test/pmch_file_test.c +++ b/lib/src/phy/phch/test/pmch_file_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -16,18 +16,18 @@ #include #include -#include "srslte/srslte.h" +#include "srsran/srsran.h" char* input_file_name = NULL; -srslte_cell_t cell = { +srsran_cell_t cell = { 100, // nof_prb 1, // nof_ports 1, // cell_id - SRSLTE_CP_EXT, // cyclic prefix - SRSLTE_PHICH_NORM, // PHICH length - SRSLTE_PHICH_R_1_6, - SRSLTE_FDD, + SRSRAN_CP_EXT, // cyclic prefix + SRSRAN_PHICH_NORM, // PHICH length + SRSRAN_PHICH_R_1_6, + SRSRAN_FDD, }; @@ -41,10 +41,10 @@ uint32_t sf_idx = 1; uint8_t non_mbsfn_region = 2; int mbsfn_area_id = 1; -srslte_softbuffer_rx_t softbuffer_rx = {}; -srslte_filesource_t fsrc; -srslte_ue_dl_t ue_dl; -cf_t* input_buffer[SRSLTE_MAX_PORTS]; +srsran_softbuffer_rx_t softbuffer_rx = {}; +srsran_filesource_t fsrc; +srsran_ue_dl_t ue_dl; +cf_t* input_buffer[SRSRAN_MAX_PORTS]; void usage(char* prog) { @@ -56,7 +56,7 @@ void usage(char* prog) printf("\t-n cell.nof_prb [Default %d]\n", cell.nof_prb); printf("\t-M mbsfn_area_id [Default %d]\n", mbsfn_area_id); printf("\t-e Set extended prefix [Default Normal]\n"); - printf("\t-v [set srslte_verbose to debug, default none]\n"); + printf("\t-v [set srsran_verbose to debug, default none]\n"); } void parse_args(int argc, char** argv) @@ -86,10 +86,10 @@ void parse_args(int argc, char** argv) mbsfn_area_id = (int)strtol(argv[optind], NULL, 10); break; case 'v': - srslte_verbose++; + srsran_verbose++; break; case 'e': - cell.cp = SRSLTE_CP_EXT; + cell.cp = SRSRAN_CP_EXT; break; default: usage(argv[0]); @@ -104,34 +104,34 @@ void parse_args(int argc, char** argv) int base_init() { - if (srslte_filesource_init(&fsrc, input_file_name, SRSLTE_COMPLEX_FLOAT_BIN)) { + if (srsran_filesource_init(&fsrc, input_file_name, SRSRAN_COMPLEX_FLOAT_BIN)) { ERROR("Error opening file %s", input_file_name); exit(-1); } - flen = 2 * (SRSLTE_SLOT_LEN(srslte_symbol_sz(cell.nof_prb))); + flen = 2 * (SRSRAN_SLOT_LEN(srsran_symbol_sz(cell.nof_prb))); - input_buffer[0] = srslte_vec_cf_malloc(flen); + input_buffer[0] = srsran_vec_cf_malloc(flen); if (!input_buffer[0]) { perror("malloc"); exit(-1); } - if (srslte_ue_dl_init(&ue_dl, input_buffer, cell.nof_prb, 1)) { + if (srsran_ue_dl_init(&ue_dl, input_buffer, cell.nof_prb, 1)) { ERROR("Error initializing UE DL"); return -1; } - if (srslte_ue_dl_set_cell(&ue_dl, cell)) { + if (srsran_ue_dl_set_cell(&ue_dl, cell)) { ERROR("Error initializing UE DL"); return -1; } - srslte_ue_dl_set_mbsfn_area_id(&ue_dl, mbsfn_area_id); - srslte_ue_dl_set_non_mbsfn_region(&ue_dl, non_mbsfn_region); + srsran_ue_dl_set_mbsfn_area_id(&ue_dl, mbsfn_area_id); + srsran_ue_dl_set_non_mbsfn_region(&ue_dl, non_mbsfn_region); - srslte_softbuffer_rx_init(&softbuffer_rx, cell.nof_prb); - srslte_softbuffer_rx_reset(&softbuffer_rx); + srsran_softbuffer_rx_init(&softbuffer_rx, cell.nof_prb); + srsran_softbuffer_rx_reset(&softbuffer_rx); DEBUG("Memory init OK"); return 0; @@ -139,9 +139,9 @@ int base_init() void base_free() { - srslte_filesource_free(&fsrc); - srslte_ue_dl_free(&ue_dl); - srslte_softbuffer_rx_free(&softbuffer_rx); + srsran_filesource_free(&fsrc); + srsran_ue_dl_free(&ue_dl); + srsran_softbuffer_rx_free(&softbuffer_rx); free(input_buffer[0]); } @@ -154,7 +154,7 @@ int main(int argc, char** argv) exit(-1); } parse_args(argc, argv); - srslte_use_standard_symbol_size(false); + srsran_use_standard_symbol_size(false); if (base_init()) { ERROR("Error initializing memory"); exit(-1); @@ -168,48 +168,48 @@ int main(int argc, char** argv) ret = -1; - srslte_filesource_read(&fsrc, input_buffer[0], flen); + srsran_filesource_read(&fsrc, input_buffer[0], flen); INFO("Reading %d samples sub-frame %d", flen, sf_idx); - srslte_dl_sf_cfg_t dl_sf; + srsran_dl_sf_cfg_t dl_sf; ZERO_OBJECT(dl_sf); dl_sf.cfi = cfi; dl_sf.tti = sf_idx; - dl_sf.sf_type = SRSLTE_SF_MBSFN; + dl_sf.sf_type = SRSRAN_SF_MBSFN; - srslte_ue_dl_cfg_t ue_dl_cfg; + srsran_ue_dl_cfg_t ue_dl_cfg; ZERO_OBJECT(ue_dl_cfg); ue_dl_cfg.chest_cfg.mbsfn_area_id = mbsfn_area_id; // Special configuration for MBSFN channel estimation - ue_dl_cfg.chest_cfg.filter_type = SRSLTE_CHEST_FILTER_TRIANGLE; + ue_dl_cfg.chest_cfg.filter_type = SRSRAN_CHEST_FILTER_TRIANGLE; ue_dl_cfg.chest_cfg.filter_coef[0] = 0.1; - ue_dl_cfg.chest_cfg.estimator_alg = SRSLTE_ESTIMATOR_ALG_INTERPOLATE; - ue_dl_cfg.chest_cfg.noise_alg = SRSLTE_NOISE_ALG_PSS; + ue_dl_cfg.chest_cfg.estimator_alg = SRSRAN_ESTIMATOR_ALG_INTERPOLATE; + ue_dl_cfg.chest_cfg.noise_alg = SRSRAN_NOISE_ALG_PSS; - if ((ret = srslte_ue_dl_decode_fft_estimate(&ue_dl, &dl_sf, &ue_dl_cfg)) < 0) { + if ((ret = srsran_ue_dl_decode_fft_estimate(&ue_dl, &dl_sf, &ue_dl_cfg)) < 0) { return ret; } dl_sf.cfi = cfi; - srslte_pmch_cfg_t pmch_cfg; + srsran_pmch_cfg_t pmch_cfg; ZERO_OBJECT(pmch_cfg); pmch_cfg.area_id = mbsfn_area_id; pmch_cfg.pdsch_cfg.softbuffers.rx[0] = &softbuffer_rx; - srslte_dci_dl_t dci; + srsran_dci_dl_t dci; ZERO_OBJECT(dci); - dci.rnti = SRSLTE_MRNTI; - dci.format = SRSLTE_DCI_FORMAT1; - dci.alloc_type = SRSLTE_RA_ALLOC_TYPE0; + dci.rnti = SRSRAN_MRNTI; + dci.format = SRSRAN_DCI_FORMAT1; + dci.alloc_type = SRSRAN_RA_ALLOC_TYPE0; dci.type0_alloc.rbg_bitmask = 0xffffffff; dci.tb[0].mcs_idx = 2; - SRSLTE_DCI_TB_DISABLE(dci.tb[1]); - srslte_ra_dl_dci_to_grant(&cell, &dl_sf, SRSLTE_TM1, false, &dci, &pmch_cfg.pdsch_cfg.grant); + SRSRAN_DCI_TB_DISABLE(dci.tb[1]); + srsran_ra_dl_dci_to_grant(&cell, &dl_sf, SRSRAN_TM1, false, &dci, &pmch_cfg.pdsch_cfg.grant); - srslte_pdsch_res_t pdsch_res; + srsran_pdsch_res_t pdsch_res; pdsch_res.payload = data; - ret = srslte_ue_dl_decode_pmch(&ue_dl, &dl_sf, &pmch_cfg, &pdsch_res); + ret = srsran_ue_dl_decode_pmch(&ue_dl, &dl_sf, &pmch_cfg, &pdsch_res); if (pdsch_res.crc == 1) { printf("PMCH Decoded OK!\n"); } else if (pdsch_res.crc == 0) { diff --git a/lib/src/phy/phch/test/pmch_test.c b/lib/src/phy/phch/test/pmch_test.c index d7c80c48d..89f87ccc8 100644 --- a/lib/src/phy/phch/test/pmch_test.c +++ b/lib/src/phy/phch/test/pmch_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,39 +10,39 @@ * */ -#include +#include #include #include #include #include #include -#include "srslte/srslte.h" +#include "srsran/srsran.h" // Enable to measure execution time #define DO_OFDM #ifdef DO_OFDM -#define NOF_CE_SYMBOLS SRSLTE_SF_LEN_PRB(cell.nof_prb) +#define NOF_CE_SYMBOLS SRSRAN_SF_LEN_PRB(cell.nof_prb) #else -#define NOF_CE_SYMBOLS SRSLTE_NOF_RE(cell) +#define NOF_CE_SYMBOLS SRSRAN_NOF_RE(cell) #endif -srslte_cell_t cell = { +srsran_cell_t cell = { 100, // nof_prb 1, // nof_ports 1, // cell_id - SRSLTE_CP_EXT, // cyclic prefix - SRSLTE_PHICH_NORM, // PHICH length - SRSLTE_PHICH_R_1_6, // PHICH resources - SRSLTE_FDD, + SRSRAN_CP_EXT, // cyclic prefix + SRSRAN_PHICH_NORM, // PHICH length + SRSRAN_PHICH_R_1_6, // PHICH resources + SRSRAN_FDD, }; uint32_t cfi = 2; uint32_t mcs_idx = 2; uint32_t subframe = 1; -int rv_idx[SRSLTE_MAX_CODEWORDS] = {0, 1}; +int rv_idx[SRSRAN_MAX_CODEWORDS] = {0, 1}; uint16_t rnti = 1234; uint32_t nof_rx_antennas = 1; uint32_t pmi = 0; @@ -64,7 +64,7 @@ void usage(char* prog) printf("\t-F cfi [Default %d]\n", cfi); printf("\t-n cell.nof_prb [Default %d]\n", cell.nof_prb); printf("\t-a nof_rx_antennas [Default %d]\n", nof_rx_antennas); - printf("\t-v [set srslte_verbose to debug, default none]\n"); + printf("\t-v [set srsran_verbose to debug, default none]\n"); } void parse_args(int argc, char** argv) @@ -103,7 +103,7 @@ void parse_args(int argc, char** argv) nof_rx_antennas = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'v': - srslte_verbose++; + srsran_verbose++; break; default: usage(argv[0]); @@ -119,72 +119,72 @@ int main(int argc, char** argv) struct timeval t[3]; int M = 1; - static uint8_t* data_tx[SRSLTE_MAX_CODEWORDS] = {NULL}; - static uint8_t* data_rx[SRSLTE_MAX_CODEWORDS] = {NULL}; - srslte_softbuffer_rx_t* softbuffers_rx[SRSLTE_MAX_CODEWORDS]; - srslte_softbuffer_tx_t* softbuffers_tx[SRSLTE_MAX_CODEWORDS]; - srslte_random_t random = srslte_random_init(0); + static uint8_t* data_tx[SRSRAN_MAX_CODEWORDS] = {NULL}; + static uint8_t* data_rx[SRSRAN_MAX_CODEWORDS] = {NULL}; + srsran_softbuffer_rx_t* softbuffers_rx[SRSRAN_MAX_CODEWORDS]; + srsran_softbuffer_tx_t* softbuffers_tx[SRSRAN_MAX_CODEWORDS]; + srsran_random_t random = srsran_random_init(0); #ifdef DO_OFDM - cf_t* tx_sf_symbols[SRSLTE_MAX_PORTS] = {}; - cf_t* rx_sf_symbols[SRSLTE_MAX_PORTS] = {}; + cf_t* tx_sf_symbols[SRSRAN_MAX_PORTS] = {}; + cf_t* rx_sf_symbols[SRSRAN_MAX_PORTS] = {}; #endif /* DO_OFDM */ - cf_t* tx_slot_symbols[SRSLTE_MAX_PORTS] = {}; - cf_t* rx_slot_symbols[SRSLTE_MAX_PORTS] = {}; + cf_t* tx_slot_symbols[SRSRAN_MAX_PORTS] = {}; + cf_t* rx_slot_symbols[SRSRAN_MAX_PORTS] = {}; - srslte_chest_dl_res_t chest_dl_res; - srslte_pmch_t pmch; - srslte_pmch_cfg_t pmch_cfg; - srslte_ofdm_t ifft_mbsfn[SRSLTE_MAX_PORTS], fft_mbsfn[SRSLTE_MAX_PORTS]; + srsran_chest_dl_res_t chest_dl_res; + srsran_pmch_t pmch; + srsran_pmch_cfg_t pmch_cfg; + srsran_ofdm_t ifft_mbsfn[SRSRAN_MAX_PORTS], fft_mbsfn[SRSRAN_MAX_PORTS]; parse_args(argc, argv); /* Initialise to zeros */ - bzero(&pmch, sizeof(srslte_pmch_t)); - bzero(tx_slot_symbols, sizeof(cf_t*) * SRSLTE_MAX_PORTS); - bzero(rx_slot_symbols, sizeof(cf_t*) * SRSLTE_MAX_PORTS); + bzero(&pmch, sizeof(srsran_pmch_t)); + bzero(tx_slot_symbols, sizeof(cf_t*) * SRSRAN_MAX_PORTS); + bzero(rx_slot_symbols, sizeof(cf_t*) * SRSRAN_MAX_PORTS); bzero(t, 3 * sizeof(struct timeval)); cell.nof_ports = 1; /* init memory */ - srslte_chest_dl_res_init(&chest_dl_res, cell.nof_prb); - srslte_chest_dl_res_set_identity(&chest_dl_res); + srsran_chest_dl_res_init(&chest_dl_res, cell.nof_prb); + srsran_chest_dl_res_set_identity(&chest_dl_res); - for (i = 0; i < SRSLTE_MAX_PORTS; i++) { - rx_slot_symbols[i] = srslte_vec_cf_malloc(SRSLTE_NOF_RE(cell)); + for (i = 0; i < SRSRAN_MAX_PORTS; i++) { + rx_slot_symbols[i] = srsran_vec_cf_malloc(SRSRAN_NOF_RE(cell)); if (!rx_slot_symbols[i]) { - perror("srslte_vec_malloc"); + perror("srsran_vec_malloc"); goto quit; } } - for (i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { - softbuffers_tx[i] = calloc(sizeof(srslte_softbuffer_tx_t), 1); + for (i = 0; i < SRSRAN_MAX_CODEWORDS; i++) { + softbuffers_tx[i] = calloc(sizeof(srsran_softbuffer_tx_t), 1); if (!softbuffers_tx[i]) { ERROR("Error allocating TX soft buffer"); } - if (srslte_softbuffer_tx_init(softbuffers_tx[i], cell.nof_prb)) { + if (srsran_softbuffer_tx_init(softbuffers_tx[i], cell.nof_prb)) { ERROR("Error initiating TX soft buffer"); goto quit; } } for (i = 0; i < cell.nof_ports; i++) { - tx_slot_symbols[i] = calloc(SRSLTE_NOF_RE(cell), sizeof(cf_t)); + tx_slot_symbols[i] = calloc(SRSRAN_NOF_RE(cell), sizeof(cf_t)); if (!tx_slot_symbols[i]) { - perror("srslte_vec_malloc"); + perror("srsran_vec_malloc"); goto quit; } } - for (i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { - softbuffers_rx[i] = calloc(sizeof(srslte_softbuffer_rx_t), 1); + for (i = 0; i < SRSRAN_MAX_CODEWORDS; i++) { + softbuffers_rx[i] = calloc(sizeof(srsran_softbuffer_rx_t), 1); if (!softbuffers_rx[i]) { ERROR("Error allocating RX soft buffer"); goto quit; } - if (srslte_softbuffer_rx_init(softbuffers_rx[i], cell.nof_prb)) { + if (srsran_softbuffer_rx_init(softbuffers_rx[i], cell.nof_prb)) { ERROR("Error initiating RX soft buffer"); goto quit; } @@ -193,66 +193,66 @@ int main(int argc, char** argv) #ifdef DO_OFDM for (i = 0; i < cell.nof_ports; i++) { - tx_sf_symbols[i] = srslte_vec_cf_malloc(SRSLTE_SF_LEN_PRB(cell.nof_prb)); - srslte_vec_cf_zero(tx_sf_symbols[i], SRSLTE_SF_LEN_PRB(cell.nof_prb)); - if (srslte_ofdm_tx_init_mbsfn(&ifft_mbsfn[i], SRSLTE_CP_EXT, tx_slot_symbols[i], tx_sf_symbols[i], cell.nof_prb)) { + tx_sf_symbols[i] = srsran_vec_cf_malloc(SRSRAN_SF_LEN_PRB(cell.nof_prb)); + srsran_vec_cf_zero(tx_sf_symbols[i], SRSRAN_SF_LEN_PRB(cell.nof_prb)); + if (srsran_ofdm_tx_init_mbsfn(&ifft_mbsfn[i], SRSRAN_CP_EXT, tx_slot_symbols[i], tx_sf_symbols[i], cell.nof_prb)) { ERROR("Error creating iFFT object"); exit(-1); } - srslte_ofdm_set_non_mbsfn_region(&ifft_mbsfn[i], non_mbsfn_region); - srslte_ofdm_set_normalize(&ifft_mbsfn[i], true); + srsran_ofdm_set_non_mbsfn_region(&ifft_mbsfn[i], non_mbsfn_region); + srsran_ofdm_set_normalize(&ifft_mbsfn[i], true); } for (i = 0; i < nof_rx_antennas; i++) { - rx_sf_symbols[i] = srslte_vec_cf_malloc(SRSLTE_SF_LEN_PRB(cell.nof_prb)); - srslte_vec_cf_zero(rx_sf_symbols[i], SRSLTE_SF_LEN_PRB(cell.nof_prb)); - if (srslte_ofdm_rx_init_mbsfn(&fft_mbsfn[i], SRSLTE_CP_EXT, rx_sf_symbols[i], rx_slot_symbols[i], cell.nof_prb)) { + rx_sf_symbols[i] = srsran_vec_cf_malloc(SRSRAN_SF_LEN_PRB(cell.nof_prb)); + srsran_vec_cf_zero(rx_sf_symbols[i], SRSRAN_SF_LEN_PRB(cell.nof_prb)); + if (srsran_ofdm_rx_init_mbsfn(&fft_mbsfn[i], SRSRAN_CP_EXT, rx_sf_symbols[i], rx_slot_symbols[i], cell.nof_prb)) { ERROR("Error creating iFFT object"); exit(-1); } - srslte_ofdm_set_non_mbsfn_region(&fft_mbsfn[i], non_mbsfn_region); - srslte_ofdm_set_normalize(&fft_mbsfn[i], true); + srsran_ofdm_set_non_mbsfn_region(&fft_mbsfn[i], non_mbsfn_region); + srsran_ofdm_set_normalize(&fft_mbsfn[i], true); } #endif /* DO_OFDM */ /* Configure PDSCH */ - srslte_dl_sf_cfg_t dl_sf; + srsran_dl_sf_cfg_t dl_sf; ZERO_OBJECT(dl_sf); dl_sf.cfi = cfi; dl_sf.tti = subframe; - dl_sf.sf_type = SRSLTE_SF_MBSFN; + dl_sf.sf_type = SRSRAN_SF_MBSFN; ZERO_OBJECT(pmch_cfg); pmch_cfg.area_id = mbsfn_area_id; pmch_cfg.pdsch_cfg.softbuffers.tx[0] = softbuffers_tx[0]; - srslte_dci_dl_t dci; + srsran_dci_dl_t dci; ZERO_OBJECT(dci); - dci.rnti = SRSLTE_MRNTI; - dci.format = SRSLTE_DCI_FORMAT1; - dci.alloc_type = SRSLTE_RA_ALLOC_TYPE0; + dci.rnti = SRSRAN_MRNTI; + dci.format = SRSRAN_DCI_FORMAT1; + dci.alloc_type = SRSRAN_RA_ALLOC_TYPE0; dci.type0_alloc.rbg_bitmask = 0xffffffff; dci.tb[0].mcs_idx = mcs_idx; - SRSLTE_DCI_TB_DISABLE(dci.tb[1]); - srslte_ra_dl_dci_to_grant(&cell, &dl_sf, SRSLTE_TM1, false, &dci, &pmch_cfg.pdsch_cfg.grant); + SRSRAN_DCI_TB_DISABLE(dci.tb[1]); + srsran_ra_dl_dci_to_grant(&cell, &dl_sf, SRSRAN_TM1, false, &dci, &pmch_cfg.pdsch_cfg.grant); - for (int i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { + for (int i = 0; i < SRSRAN_MAX_CODEWORDS; i++) { if (pmch_cfg.pdsch_cfg.grant.tb[i].enabled) { - data_tx[i] = srslte_vec_u8_malloc((uint32_t)pmch_cfg.pdsch_cfg.grant.tb[i].tbs); + data_tx[i] = srsran_vec_u8_malloc((uint32_t)pmch_cfg.pdsch_cfg.grant.tb[i].tbs); if (!data_tx[i]) { - perror("srslte_vec_malloc"); + perror("srsran_vec_malloc"); goto quit; } bzero(data_tx[i], sizeof(uint8_t) * pmch_cfg.pdsch_cfg.grant.tb[i].tbs); - data_rx[i] = srslte_vec_u8_malloc((uint32_t)pmch_cfg.pdsch_cfg.grant.tb[i].tbs); + data_rx[i] = srsran_vec_u8_malloc((uint32_t)pmch_cfg.pdsch_cfg.grant.tb[i].tbs); if (!data_rx[i]) { - perror("srslte_vec_malloc"); + perror("srsran_vec_malloc"); goto quit; } bzero(data_rx[i], sizeof(uint8_t) * pmch_cfg.pdsch_cfg.grant.tb[i].tbs); @@ -263,7 +263,7 @@ int main(int argc, char** argv) INFO(" nof_prb=%d", cell.nof_prb); INFO(" nof_ports=%d", cell.nof_ports); INFO(" id=%d", cell.id); - INFO(" cp=%s", srslte_cp_string(cell.cp)); + INFO(" cp=%s", srsran_cp_string(cell.cp)); INFO(" phich_length=%d", (int)cell.phich_length); INFO(" phich_resources=%d", (int)cell.phich_resources); INFO(" nof_prb=%d", pmch_cfg.pdsch_cfg.grant.nof_prb); @@ -272,25 +272,25 @@ int main(int argc, char** argv) INFO(" mcs.idx=0x%X", pmch_cfg.pdsch_cfg.grant.tb[0].mcs_idx); INFO(" mcs.tbs=%d", pmch_cfg.pdsch_cfg.grant.tb[0].tbs); - INFO(" mcs.mod=%s", srslte_mod_string(pmch_cfg.pdsch_cfg.grant.tb[0].mod)); + INFO(" mcs.mod=%s", srsran_mod_string(pmch_cfg.pdsch_cfg.grant.tb[0].mod)); INFO(" rv=%d", pmch_cfg.pdsch_cfg.grant.tb[0].rv); INFO(" nof_bits=%d", pmch_cfg.pdsch_cfg.grant.tb[0].nof_bits); INFO(" nof_re=%d", pmch_cfg.pdsch_cfg.grant.nof_re); - if (srslte_pmch_init(&pmch, cell.nof_prb, 1)) { + if (srsran_pmch_init(&pmch, cell.nof_prb, 1)) { ERROR("Error creating PMCH object"); } - srslte_pmch_set_area_id(&pmch, mbsfn_area_id); + srsran_pmch_set_area_id(&pmch, mbsfn_area_id); - for (int tb = 0; tb < SRSLTE_MAX_CODEWORDS; tb++) { + for (int tb = 0; tb < SRSRAN_MAX_CODEWORDS; tb++) { if (pmch_cfg.pdsch_cfg.grant.tb[tb].enabled) { for (int byte = 0; byte < pmch_cfg.pdsch_cfg.grant.tb[tb].tbs / 8; byte++) { - data_tx[tb][byte] = (uint8_t)srslte_random_uniform_int_dist(random, 0, 255); + data_tx[tb][byte] = (uint8_t)srsran_random_uniform_int_dist(random, 0, 255); } } } - if (srslte_pmch_encode(&pmch, &dl_sf, &pmch_cfg, data_tx[0], tx_slot_symbols)) { + if (srsran_pmch_encode(&pmch, &dl_sf, &pmch_cfg, data_tx[0], tx_slot_symbols)) { ERROR("Error encoding PDSCH"); exit(-1); } @@ -304,7 +304,7 @@ int main(int argc, char** argv) #ifdef DO_OFDM for (i = 0; i < cell.nof_ports; i++) { /* For each Tx antenna modulate OFDM */ - srslte_ofdm_tx_sf(&ifft_mbsfn[i]); + srsran_ofdm_tx_sf(&ifft_mbsfn[i]); } /* combine outputs */ @@ -320,7 +320,7 @@ int main(int argc, char** argv) #else /* combine outputs */ for (j = 0; j < nof_rx_antennas; j++) { - for (k = 0; k < SRSLTE_NOF_RE(cell); k++) { + for (k = 0; k < SRSRAN_NOF_RE(cell); k++) { rx_slot_symbols[j][k] = 0.0f; for (i = 0; i < cell.nof_ports; i++) { rx_slot_symbols[j][k] += tx_slot_symbols[i][k] * ce[i][j][k]; @@ -335,21 +335,21 @@ int main(int argc, char** argv) #ifdef DO_OFDM /* For each Rx antenna demodulate OFDM */ for (i = 0; i < nof_rx_antennas; i++) { - srslte_ofdm_rx_sf(&fft_mbsfn[i]); + srsran_ofdm_rx_sf(&fft_mbsfn[i]); } #endif - for (i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { + for (i = 0; i < SRSRAN_MAX_CODEWORDS; i++) { if (pmch_cfg.pdsch_cfg.grant.tb[i].enabled) { - srslte_softbuffer_rx_reset_tbs(softbuffers_rx[i], (uint32_t)pmch_cfg.pdsch_cfg.grant.tb[i].tbs); + srsran_softbuffer_rx_reset_tbs(softbuffers_rx[i], (uint32_t)pmch_cfg.pdsch_cfg.grant.tb[i].tbs); } } pmch_cfg.pdsch_cfg.softbuffers.rx[0] = softbuffers_rx[0]; - srslte_pdsch_res_t pdsch_res[2]; + srsran_pdsch_res_t pdsch_res[2]; pdsch_res[0].payload = data_rx[0]; - r = srslte_pmch_decode(&pmch, &dl_sf, &pmch_cfg, &chest_dl_res, rx_slot_symbols, pdsch_res); + r = srsran_pmch_decode(&pmch, &dl_sf, &pmch_cfg, &chest_dl_res, rx_slot_symbols, pdsch_res); gettimeofday(&t[2], NULL); get_time_interval(t); printf("DECODED %s in %.2f (PHY bitrate=%.2f Mbps. Processing bitrate=%.2f Mbps)\n", @@ -365,39 +365,39 @@ int main(int argc, char** argv) } /* Check Tx and Rx bytes */ - for (int tb = 0; tb < SRSLTE_MAX_CODEWORDS; tb++) { + for (int tb = 0; tb < SRSRAN_MAX_CODEWORDS; tb++) { if (pmch_cfg.pdsch_cfg.grant.tb[tb].enabled) { for (int byte = 0; byte < pmch_cfg.pdsch_cfg.grant.tb[tb].tbs / 8; byte++) { if (data_tx[tb][byte] != data_rx[tb][byte]) { ERROR("Found BYTE error in TB %d (%02X != %02X), quiting...", tb, data_tx[tb][byte], data_rx[tb][byte]); - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; goto quit; } } } } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; quit: for (i = 0; i < nof_rx_antennas; i++) { - srslte_ofdm_tx_free(&ifft_mbsfn[i]); - srslte_ofdm_rx_free(&fft_mbsfn[i]); + srsran_ofdm_tx_free(&ifft_mbsfn[i]); + srsran_ofdm_rx_free(&fft_mbsfn[i]); if (rx_sf_symbols[i]) { free(rx_sf_symbols[i]); } } - srslte_pmch_free(&pmch); - srslte_chest_dl_res_free(&chest_dl_res); - for (i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { - srslte_softbuffer_tx_free(softbuffers_tx[i]); + srsran_pmch_free(&pmch); + srsran_chest_dl_res_free(&chest_dl_res); + for (i = 0; i < SRSRAN_MAX_CODEWORDS; i++) { + srsran_softbuffer_tx_free(softbuffers_tx[i]); if (softbuffers_tx[i]) { free(softbuffers_tx[i]); } - srslte_softbuffer_rx_free(softbuffers_rx[i]); + srsran_softbuffer_rx_free(softbuffers_rx[i]); if (softbuffers_rx[i]) { free(softbuffers_rx[i]); } @@ -411,7 +411,7 @@ quit: } } - for (i = 0; i < SRSLTE_MAX_PORTS; i++) { + for (i = 0; i < SRSRAN_MAX_PORTS; i++) { if (tx_sf_symbols[i]) { free(tx_sf_symbols[i]); } @@ -422,7 +422,7 @@ quit: free(rx_slot_symbols[i]); } } - srslte_random_free(random); + srsran_random_free(random); if (ret) { printf("Error\n"); } else { diff --git a/lib/src/phy/phch/test/prach_test.c b/lib/src/phy/phch/test/prach_test.c index 53b03b9ea..26ee8f5be 100644 --- a/lib/src/phy/phch/test/prach_test.c +++ b/lib/src/phy/phch/test/prach_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -19,7 +19,7 @@ #include #include -#include "srslte/srslte.h" +#include "srsran/srsran.h" #define MAX_LEN 70176 @@ -65,14 +65,14 @@ static void parse_args(int argc, char** argv) int main(int argc, char** argv) { parse_args(argc, argv); - srslte_prach_t prach; + srsran_prach_t prach; bool high_speed_flag = false; cf_t preamble[MAX_LEN]; memset(preamble, 0, sizeof(cf_t) * MAX_LEN); - srslte_prach_cfg_t prach_cfg; + srsran_prach_cfg_t prach_cfg; ZERO_OBJECT(prach_cfg); prach_cfg.config_idx = config_idx; prach_cfg.hs_flag = high_speed_flag; @@ -81,13 +81,13 @@ int main(int argc, char** argv) prach_cfg.zero_corr_zone = zero_corr_zone; prach_cfg.num_ra_preambles = num_ra_preambles; - if (srslte_prach_init(&prach, srslte_symbol_sz(nof_prb))) { + if (srsran_prach_init(&prach, srsran_symbol_sz(nof_prb))) { return -1; } struct timeval t[3] = {}; gettimeofday(&t[1], NULL); - if (srslte_prach_set_cfg(&prach, &prach_cfg, nof_prb)) { + if (srsran_prach_set_cfg(&prach, &prach_cfg, nof_prb)) { ERROR("Error initiating PRACH object"); return -1; } @@ -102,12 +102,12 @@ int main(int argc, char** argv) indices[i] = 0; for (seq_index = 0; seq_index < 64; seq_index++) { - srslte_prach_gen(&prach, seq_index, 0, preamble); + srsran_prach_gen(&prach, seq_index, 0, preamble); uint32_t prach_len = prach.N_seq; gettimeofday(&t[1], NULL); - srslte_prach_detect(&prach, 0, &preamble[prach.N_cp], prach_len, indices, &n_indices); + srsran_prach_detect(&prach, 0, &preamble[prach.N_cp], prach_len, indices, &n_indices); gettimeofday(&t[2], NULL); get_time_interval(t); printf("texec=%ld us\n", t[0].tv_usec); @@ -115,7 +115,7 @@ int main(int argc, char** argv) return -1; } - srslte_prach_free(&prach); + srsran_prach_free(&prach); printf("Done\n"); exit(0); diff --git a/lib/src/phy/phch/test/prach_test_multi.c b/lib/src/phy/phch/test/prach_test_multi.c index f882d3318..d81588b1e 100644 --- a/lib/src/phy/phch/test/prach_test_multi.c +++ b/lib/src/phy/phch/test/prach_test_multi.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -18,9 +18,9 @@ #include #include -#include "srslte/phy/phch/prach.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/srslte.h" +#include "srsran/phy/phch/prach.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/srsran.h" #include #include char* input_file_name = NULL; @@ -40,7 +40,7 @@ bool test_successive_cancellation = false; bool test_offset_calculation = false; bool stagger_prach_power_and_phase = false; // this will work best with one or two simultaenous prach -srslte_filesource_t fsrc; +srsran_filesource_t fsrc; void usage(char* prog) { @@ -101,7 +101,7 @@ void parse_args(int argc, char** argv) } } // this function staggers power and phase of the different PRACH signals for more realisitc testing -void stagger_prach_powers(srslte_prach_t* prach, +void stagger_prach_powers(srsran_prach_t* prach, cf_t* preamble, cf_t* preamble_sum, int freq_offset, @@ -109,29 +109,29 @@ void stagger_prach_powers(srslte_prach_t* prach, int* offsets) { for (int seq_index = 0; seq_index < n_seqs; seq_index++) { - srslte_prach_gen(prach, seq_index, freq_offset, preamble); + srsran_prach_gen(prach, seq_index, freq_offset, preamble); if (seq_index == 0) { - srslte_vec_sc_prod_ccc(preamble, cexpf(_Complex_I * 0.5), preamble, prach->N_cp + prach->N_seq); - srslte_vec_sc_prod_cfc(preamble, 1, preamble, prach->N_cp + prach->N_seq); + srsran_vec_sc_prod_ccc(preamble, cexpf(_Complex_I * 0.5), preamble, prach->N_cp + prach->N_seq); + srsran_vec_sc_prod_cfc(preamble, 1, preamble, prach->N_cp + prach->N_seq); } if (seq_index == 1) { - srslte_vec_sc_prod_ccc(preamble, cexpf(_Complex_I * 1), preamble, prach->N_cp + prach->N_seq); - srslte_vec_sc_prod_cfc(preamble, 0.8, preamble, prach->N_cp + prach->N_seq); + srsran_vec_sc_prod_ccc(preamble, cexpf(_Complex_I * 1), preamble, prach->N_cp + prach->N_seq); + srsran_vec_sc_prod_cfc(preamble, 0.8, preamble, prach->N_cp + prach->N_seq); } if (seq_index == 2) { - srslte_vec_sc_prod_ccc(preamble, cexpf(_Complex_I * 0.1), preamble, prach->N_cp + prach->N_seq); - srslte_vec_sc_prod_cfc(preamble, 0.05, preamble, prach->N_cp + prach->N_seq); + srsran_vec_sc_prod_ccc(preamble, cexpf(_Complex_I * 0.1), preamble, prach->N_cp + prach->N_seq); + srsran_vec_sc_prod_cfc(preamble, 0.05, preamble, prach->N_cp + prach->N_seq); } if (seq_index == 3) { - srslte_vec_sc_prod_ccc(preamble, cexpf(_Complex_I * 0.9), preamble, prach->N_cp + prach->N_seq); - srslte_vec_sc_prod_cfc(preamble, 0.7, preamble, prach->N_cp + prach->N_seq); + srsran_vec_sc_prod_ccc(preamble, cexpf(_Complex_I * 0.9), preamble, prach->N_cp + prach->N_seq); + srsran_vec_sc_prod_cfc(preamble, 0.7, preamble, prach->N_cp + prach->N_seq); } if (seq_index == 4) { - srslte_vec_sc_prod_ccc(preamble, cexpf(_Complex_I * 0.3), preamble, prach->N_cp + prach->N_seq); - srslte_vec_sc_prod_cfc(preamble, 0.15, preamble, prach->N_cp + prach->N_seq); + srsran_vec_sc_prod_ccc(preamble, cexpf(_Complex_I * 0.3), preamble, prach->N_cp + prach->N_seq); + srsran_vec_sc_prod_cfc(preamble, 0.15, preamble, prach->N_cp + prach->N_seq); } if (seq_index == 5) { - srslte_vec_sc_prod_cfc(preamble, 0.15, preamble, prach->N_cp + prach->N_seq); + srsran_vec_sc_prod_cfc(preamble, 0.15, preamble, prach->N_cp + prach->N_seq); } int off = (offset == -1) ? offsets[seq_index] : offset; for (int i = 0; i < prach->N_cp + prach->N_seq; i++) { @@ -143,7 +143,7 @@ void stagger_prach_powers(srslte_prach_t* prach, int main(int argc, char** argv) { parse_args(argc, argv); - srslte_prach_t prach; + srsran_prach_t prach; bool high_speed_flag = false; srand(0); @@ -154,10 +154,10 @@ int main(int argc, char** argv) int offsets[64]; memset(offsets, 0, sizeof(int) * 64); float t_offsets[64]; - srslte_prach_cfg_t prach_cfg; + srsran_prach_cfg_t prach_cfg; ZERO_OBJECT(prach_cfg); if (input_file_name) { - if (srslte_filesource_init(&fsrc, input_file_name, SRSLTE_COMPLEX_FLOAT_BIN)) { + if (srsran_filesource_init(&fsrc, input_file_name, SRSRAN_COMPLEX_FLOAT_BIN)) { ERROR("Error opening file %s", input_file_name); exit(-1); } @@ -171,7 +171,7 @@ int main(int argc, char** argv) prach_cfg.enable_successive_cancellation = test_successive_cancellation; prach_cfg.enable_freq_domain_offset_calc = freq_domain_offset_calc; - int srate = srslte_sampling_freq_hz(nof_prb); + int srate = srsran_sampling_freq_hz(nof_prb); int divisor = srate / PRACH_SRATE; if (test_offset_calculation || test_successive_cancellation || stagger_prach_power_and_phase) { if (n_seqs > 6) { @@ -187,11 +187,11 @@ int main(int argc, char** argv) } } - if (srslte_prach_init(&prach, srslte_symbol_sz(nof_prb))) { + if (srsran_prach_init(&prach, srsran_symbol_sz(nof_prb))) { return -1; } - if (srslte_prach_set_cfg(&prach, &prach_cfg, nof_prb)) { + if (srsran_prach_set_cfg(&prach, &prach_cfg, nof_prb)) { ERROR("Error initiating PRACH object"); return -1; } @@ -203,12 +203,12 @@ int main(int argc, char** argv) for (int i = 0; i < 64; i++) indices[i] = 0; - srslte_prach_set_detect_factor(&prach, 10); + srsran_prach_set_detect_factor(&prach, 10); if (stagger_prach_power_and_phase) { stagger_prach_powers(&prach, preamble, preamble_sum, prach_cfg.freq_offset, n_seqs, offsets); } else { for (seq_index = 0; seq_index < n_seqs; seq_index++) { - srslte_prach_gen(&prach, seq_index, prach_cfg.freq_offset, preamble); + srsran_prach_gen(&prach, seq_index, prach_cfg.freq_offset, preamble); int off = (offset == -1) ? offsets[seq_index] : offset; for (int i = prach.N_cp; i < prach.N_cp + prach.N_seq; i++) { preamble_sum[i + off] += preamble[i]; @@ -217,7 +217,7 @@ int main(int argc, char** argv) } if (input_file_name) { - srslte_filesource_read(&fsrc, &preamble_sum[prach.N_cp], prach.N_seq); + srsran_filesource_read(&fsrc, &preamble_sum[prach.N_cp], prach.N_seq); } uint32_t prach_len = prach.N_seq; @@ -226,7 +226,7 @@ int main(int argc, char** argv) } struct timeval t[3]; gettimeofday(&t[1], NULL); - srslte_prach_detect_offset(&prach, 0, &preamble_sum[prach.N_cp], prach_len, indices, t_offsets, NULL, &n_indices); + srsran_prach_detect_offset(&prach, 0, &preamble_sum[prach.N_cp], prach_len, indices, t_offsets, NULL, &n_indices); gettimeofday(&t[2], NULL); get_time_interval(t); printf("texec=%ld us\n", t[0].tv_usec); @@ -251,7 +251,7 @@ int main(int argc, char** argv) return -1; } - srslte_prach_free(&prach); + srsran_prach_free(&prach); printf("Done\n"); exit(0); } diff --git a/lib/src/phy/phch/test/prach_test_usrp.c b/lib/src/phy/phch/test/prach_test_usrp.c index ca3068c23..79a2dd183 100644 --- a/lib/src/phy/phch/test/prach_test_usrp.c +++ b/lib/src/phy/phch/test/prach_test_usrp.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -12,15 +12,15 @@ #include #include -#include +#include #include #include #include #include #include -#include "srslte/phy/rf/rf.h" -#include "srslte/srslte.h" +#include "srsran/phy/rf/rf.h" +#include "srsran/srsran.h" #define MAX_LEN 70176 @@ -47,8 +47,8 @@ static float uhd_rx_gain = 40, uhd_tx_gain = 60, uhd_freq = 2.4e9; static char* uhd_args = ""; static char* device_name = ""; -// SRSLTE Verbose -SRSLTE_API extern int srslte_verbose; +// SRSRAN Verbose +SRSRAN_API extern int srsran_verbose; void usage(char* prog) { @@ -68,7 +68,7 @@ void usage(char* prog) printf(" -t Time advance (us) [Default %.1f us]\n", timeadv); printf(" -z Zero correlation zone config [Default %d]\n", zero_corr_zone); printf(" -o Save transmitted PRACH in file [Default no]\n"); - printf(" -v [set srslte_verbose to info, debug, default none]\n"); + printf(" -v [set srsran_verbose to info, debug, default none]\n"); printf("\n"); printf("Device arguments for:\n"); printf(" X300: type=x300,addr=192.168.40.2,send_frame_size=2000,recv_frame_size=2000\n"); @@ -118,7 +118,7 @@ void parse_args(int argc, char** argv) break; case 'p': nof_prb = (int)strtol(argv[optind], NULL, 10); - if (!srslte_nofprb_isvalid(nof_prb)) { + if (!srsran_nofprb_isvalid(nof_prb)) { ERROR("Invalid number of UL RB %d", nof_prb); exit(-1); } @@ -136,7 +136,7 @@ void parse_args(int argc, char** argv) seq_idx = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'v': - srslte_verbose++; + srsran_verbose++; break; case 'z': zero_corr_zone = (uint32_t)strtol(argv[optind], NULL, 10); @@ -148,22 +148,22 @@ void parse_args(int argc, char** argv) } } -void rf_msg_callback(void* arg, srslte_rf_error_t error) +void rf_msg_callback(void* arg, srsran_rf_error_t error) { switch (error.type) { - case SRSLTE_RF_ERROR_LATE: + case SRSRAN_RF_ERROR_LATE: printf("L"); break; - case SRSLTE_RF_ERROR_UNDERFLOW: + case SRSRAN_RF_ERROR_UNDERFLOW: printf("U"); break; - case SRSLTE_RF_ERROR_OVERFLOW: + case SRSRAN_RF_ERROR_OVERFLOW: printf("O"); break; - case SRSLTE_RF_ERROR_RX: + case SRSRAN_RF_ERROR_RX: printf("R"); break; - case SRSLTE_RF_ERROR_OTHER: + case SRSRAN_RF_ERROR_OTHER: printf("X"); break; } @@ -173,24 +173,24 @@ int main(int argc, char** argv) { parse_args(argc, argv); - srslte_prach_t prach = {}; - int srate = srslte_sampling_freq_hz(nof_prb); + srsran_prach_t prach = {}; + int srate = srsran_sampling_freq_hz(nof_prb); uint32_t flen = srate / 1000; // Allocate buffers - cf_t* preamble = srslte_vec_cf_malloc(MAX_LEN); - cf_t* zeros = srslte_vec_cf_malloc(flen); - cf_t* buffer = srslte_vec_cf_malloc(flen * nof_frames); + cf_t* preamble = srsran_vec_cf_malloc(MAX_LEN); + cf_t* zeros = srsran_vec_cf_malloc(flen); + cf_t* buffer = srsran_vec_cf_malloc(flen * nof_frames); if (!preamble || !zeros || !buffer) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - srslte_vec_cf_zero(preamble, MAX_LEN); - srslte_vec_cf_zero(zeros, flen); - srslte_vec_cf_zero(buffer, flen * nof_frames); + srsran_vec_cf_zero(preamble, MAX_LEN); + srsran_vec_cf_zero(zeros, flen); + srsran_vec_cf_zero(buffer, flen * nof_frames); - srslte_prach_cfg_t prach_cfg = {}; + srsran_prach_cfg_t prach_cfg = {}; prach_cfg.config_idx = preamble_format; prach_cfg.hs_flag = high_speed_flag; prach_cfg.freq_offset = 0; @@ -198,22 +198,22 @@ int main(int argc, char** argv) prach_cfg.zero_corr_zone = zero_corr_zone; prach_cfg.num_ra_preambles = num_ra_preambles; - if (srslte_prach_init(&prach, srslte_symbol_sz(nof_prb))) { - return SRSLTE_ERROR; + if (srsran_prach_init(&prach, srsran_symbol_sz(nof_prb))) { + return SRSRAN_ERROR; } - if (srslte_prach_set_cfg(&prach, &prach_cfg, nof_prb)) { + if (srsran_prach_set_cfg(&prach, &prach_cfg, nof_prb)) { ERROR("Error initiating PRACH object"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } printf("Generating PRACH\n"); - srslte_prach_gen(&prach, seq_idx, frequency_offset, preamble); + srsran_prach_gen(&prach, seq_idx, frequency_offset, preamble); // Send through UHD - srslte_rf_t rf; + srsran_rf_t rf; printf("Opening RF device...\n"); - if (srslte_rf_open_devname(&rf, device_name, uhd_args, 1)) { + if (srsran_rf_open_devname(&rf, device_name, uhd_args, 1)) { ERROR("Error opening &uhd"); exit(-1); } @@ -227,27 +227,27 @@ int main(int argc, char** argv) printf(" Continuous Tx: %s\n", continous_tx ? "true" : "false"); printf("\n"); - srslte_rf_set_rx_gain(&rf, uhd_rx_gain); - srslte_rf_set_tx_gain(&rf, uhd_tx_gain); - srslte_rf_set_rx_freq(&rf, 0, uhd_freq); - srslte_rf_set_tx_freq(&rf, 0, uhd_freq); + srsran_rf_set_rx_gain(&rf, uhd_rx_gain); + srsran_rf_set_tx_gain(&rf, uhd_tx_gain); + srsran_rf_set_rx_freq(&rf, 0, uhd_freq); + srsran_rf_set_tx_freq(&rf, 0, uhd_freq); printf("Setting sampling rate %.2f MHz\n", (float)srate / 1000000); - int srate_rf = (int)srslte_rf_set_rx_srate(&rf, (double)srate); + int srate_rf = (int)srsran_rf_set_rx_srate(&rf, (double)srate); if (srate_rf != srate) { ERROR("Could not set sampling rate"); exit(-1); } - srslte_rf_set_tx_srate(&rf, (double)srate); + srsran_rf_set_tx_srate(&rf, (double)srate); sleep(1); - srslte_timestamp_t tstamp; + srsran_timestamp_t tstamp; // Register error handler - srslte_rf_register_error_handler(&rf, rf_msg_callback, NULL); + srsran_rf_register_error_handler(&rf, rf_msg_callback, NULL); // Start streaming - srslte_rf_start_rx_stream(&rf, false); + srsran_rf_start_rx_stream(&rf, false); // Print Table legend printf("%8s; %5s; %5s; %5s; %6s; %5s; %9s;\n", "Time", "i", "count", "index", "usec", "samp", "Norm Peak"); @@ -271,14 +271,14 @@ int main(int argc, char** argv) // For a the number of frames for (uint32_t nframe = 0; nframe < nof_frames; nframe++) { INFO("Rep %d. Receiving frame %d", rep, nframe); - srslte_rf_recv_with_time(&rf, &buffer[flen * nframe], flen, true, &tstamp.full_secs, &tstamp.frac_secs); + srsran_rf_recv_with_time(&rf, &buffer[flen * nframe], flen, true, &tstamp.full_secs, &tstamp.frac_secs); - srslte_timestamp_add(&tstamp, 0, tx_delay_ms * 1e-3 - timeadv * 1e-6); + srsran_timestamp_add(&tstamp, 0, tx_delay_ms * 1e-3 - timeadv * 1e-6); if (nframe == 10 - tx_delay_ms) { - srslte_rf_send_timed2(&rf, preamble, flen, tstamp.full_secs, tstamp.frac_secs, false, !continous_tx); + srsran_rf_send_timed2(&rf, preamble, flen, tstamp.full_secs, tstamp.frac_secs, false, !continous_tx); INFO("Rep %d. Transmitting PRACH", rep); } else if (nframe == 10 - tx_delay_ms - 1 || continous_tx) { - srslte_rf_send_timed2(&rf, zeros, flen, tstamp.full_secs, tstamp.frac_secs, is_start_of_burst, false); + srsran_rf_send_timed2(&rf, zeros, flen, tstamp.full_secs, tstamp.frac_secs, is_start_of_burst, false); INFO("Rep %d. Transmitting Zeros", rep); is_start_of_burst = false; } @@ -289,7 +289,7 @@ int main(int argc, char** argv) float offsets[1024] = {}; float peak_to_avg[1024] = {}; uint32_t nof_detected = 0; - if (srslte_prach_detect_offset(&prach, + if (srsran_prach_detect_offset(&prach, frequency_offset, &buffer[flen * 10 + prach.N_cp], flen, @@ -319,13 +319,13 @@ int main(int argc, char** argv) peak_to_avg[i]); // Update stats - delay_us_min = SRSLTE_MIN(delay_us_min, offsets[i] * 1e6); - delay_us_max = SRSLTE_MAX(delay_us_max, offsets[i] * 1e6); - delay_us_avg = SRSLTE_VEC_CMA(offsets[i] * 1e6, delay_us_avg, count); + delay_us_min = SRSRAN_MIN(delay_us_min, offsets[i] * 1e6); + delay_us_max = SRSRAN_MAX(delay_us_max, offsets[i] * 1e6); + delay_us_avg = SRSRAN_VEC_CMA(offsets[i] * 1e6, delay_us_avg, count); - peak_min = SRSLTE_MIN(peak_min, peak_to_avg[i]); - peak_max = SRSLTE_MAX(peak_max, peak_to_avg[i]); - peak_avg = SRSLTE_VEC_CMA(peak_to_avg[i], peak_avg, count); + peak_min = SRSRAN_MIN(peak_min, peak_to_avg[i]); + peak_max = SRSRAN_MAX(peak_max, peak_to_avg[i]); + peak_avg = SRSRAN_VEC_CMA(peak_to_avg[i], peak_avg, count); count++; } @@ -333,7 +333,7 @@ int main(int argc, char** argv) // End burst if (continous_tx) { - srslte_rf_send_timed2(&rf, zeros, 0, tstamp.full_secs, tstamp.frac_secs, false, true); + srsran_rf_send_timed2(&rf, zeros, 0, tstamp.full_secs, tstamp.frac_secs, false, true); } // Print statistics @@ -350,14 +350,14 @@ int main(int argc, char** argv) // Save in file if filename is not empty if (output_filename) { // Save generated PRACH signal - srslte_vec_save_file("generated", preamble, (prach.N_seq + prach.N_cp) * sizeof(cf_t)); + srsran_vec_save_file("generated", preamble, (prach.N_seq + prach.N_cp) * sizeof(cf_t)); // Save last received buffer - srslte_vec_save_file(output_filename, buffer, 11 * flen * (uint32_t)sizeof(cf_t)); + srsran_vec_save_file(output_filename, buffer, 11 * flen * (uint32_t)sizeof(cf_t)); } - srslte_rf_close(&rf); - srslte_prach_free(&prach); + srsran_rf_close(&rf); + srsran_prach_free(&prach); TESTASSERT(count == nof_repetitions); TESTASSERT(delay_us_max - delay_us_min < 0.5); diff --git a/lib/src/phy/phch/test/psbch_file_test.c b/lib/src/phy/phch/test/psbch_file_test.c index 785b120f3..3f8ed8f87 100644 --- a/lib/src/phy/phch/test/psbch_file_test.c +++ b/lib/src/phy/phch/test/psbch_file_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -15,15 +15,15 @@ #include #include -#include "srslte/phy/ch_estimation/chest_sl.h" -#include "srslte/phy/dft/ofdm.h" -#include "srslte/phy/io/filesource.h" -#include "srslte/phy/phch/mib_sl.h" -#include "srslte/phy/phch/psbch.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/ch_estimation/chest_sl.h" +#include "srsran/phy/dft/ofdm.h" +#include "srsran/phy/io/filesource.h" +#include "srsran/phy/phch/mib_sl.h" +#include "srsran/phy/phch/psbch.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" -srslte_cell_sl_t cell = {.nof_prb = 6, .N_sl_id = 168, .tm = SRSLTE_SIDELINK_TM2, .cp = SRSLTE_CP_NORM}; +srsran_cell_sl_t cell = {.nof_prb = 6, .N_sl_id = 168, .tm = SRSRAN_SIDELINK_TM2, .cp = SRSRAN_CP_NORM}; char* input_file_name; uint32_t offset = 0; float frequency_offset = 0.0; @@ -31,7 +31,7 @@ float snr = 100.0; bool use_standard_lte_rates = false; bool do_equalization = true; -srslte_filesource_t fsrc; +srsran_filesource_t fsrc; void usage(char* prog) { @@ -43,7 +43,7 @@ void usage(char* prog) printf("\t-s skip equalization [Default no]\n"); printf("\t-c N_sl_id [Default %d]\n", cell.N_sl_id); printf("\t-t Sidelink transmission mode {1,2,3,4} [Default %d]\n", (cell.tm + 1)); - printf("\t-v [set srslte_verbose to debug, default none]\n"); + printf("\t-v [set srsran_verbose to debug, default none]\n"); } void parse_args(int argc, char** argv) @@ -61,7 +61,7 @@ void parse_args(int argc, char** argv) do_equalization = false; break; case 'e': - cell.cp = SRSLTE_CP_EXT; + cell.cp = SRSRAN_CP_EXT; break; case 'i': input_file_name = argv[optind]; @@ -72,16 +72,16 @@ void parse_args(int argc, char** argv) case 't': switch (strtol(argv[optind], NULL, 10)) { case 1: - cell.tm = SRSLTE_SIDELINK_TM1; + cell.tm = SRSRAN_SIDELINK_TM1; break; case 2: - cell.tm = SRSLTE_SIDELINK_TM2; + cell.tm = SRSRAN_SIDELINK_TM2; break; case 3: - cell.tm = SRSLTE_SIDELINK_TM3; + cell.tm = SRSRAN_SIDELINK_TM3; break; case 4: - cell.tm = SRSLTE_SIDELINK_TM4; + cell.tm = SRSRAN_SIDELINK_TM4; break; default: usage(argv[0]); @@ -89,14 +89,14 @@ void parse_args(int argc, char** argv) } break; case 'v': - srslte_verbose++; + srsran_verbose++; break; default: usage(argv[0]); exit(-1); } } - if (SRSLTE_CP_ISEXT(cell.cp) && cell.tm >= SRSLTE_SIDELINK_TM3) { + if (SRSRAN_CP_ISEXT(cell.cp) && cell.tm >= SRSRAN_SIDELINK_TM3) { ERROR("Selected TM does not support extended CP"); usage(argv[0]); exit(-1); @@ -105,115 +105,115 @@ void parse_args(int argc, char** argv) int main(int argc, char** argv) { - int ret = SRSLTE_ERROR; + int ret = SRSRAN_ERROR; parse_args(argc, argv); - srslte_use_standard_symbol_size(use_standard_lte_rates); + srsran_use_standard_symbol_size(use_standard_lte_rates); - int32_t symbol_sz = srslte_symbol_sz(cell.nof_prb); + int32_t symbol_sz = srsran_symbol_sz(cell.nof_prb); printf("Symbol SZ: %i\n", symbol_sz); - uint32_t sf_n_samples = srslte_symbol_sz(cell.nof_prb) * 15; + uint32_t sf_n_samples = srsran_symbol_sz(cell.nof_prb) * 15; printf("sf_n_samples: %i\n", sf_n_samples); - uint32_t sf_n_re = SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp); - cf_t* sf_buffer = srslte_vec_cf_malloc(sf_n_re); - cf_t* equalized_sf_buffer = srslte_vec_cf_malloc(sf_n_re); + uint32_t sf_n_re = SRSRAN_SF_LEN_RE(cell.nof_prb, cell.cp); + cf_t* sf_buffer = srsran_vec_cf_malloc(sf_n_re); + cf_t* equalized_sf_buffer = srsran_vec_cf_malloc(sf_n_re); - cf_t* input_buffer = srslte_vec_cf_malloc(sf_n_samples); - cf_t* output_buffer = srslte_vec_cf_malloc(sf_n_samples); + cf_t* input_buffer = srsran_vec_cf_malloc(sf_n_samples); + cf_t* output_buffer = srsran_vec_cf_malloc(sf_n_samples); // TX - srslte_ofdm_t ifft; - if (srslte_ofdm_tx_init(&ifft, cell.cp, sf_buffer, output_buffer, cell.nof_prb)) { + srsran_ofdm_t ifft; + if (srsran_ofdm_tx_init(&ifft, cell.cp, sf_buffer, output_buffer, cell.nof_prb)) { ERROR("Error creating IFFT object"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - srslte_ofdm_set_normalize(&ifft, true); - srslte_ofdm_set_freq_shift(&ifft, 0.5); + srsran_ofdm_set_normalize(&ifft, true); + srsran_ofdm_set_freq_shift(&ifft, 0.5); // RX - srslte_ofdm_t fft; - if (srslte_ofdm_rx_init(&fft, cell.cp, input_buffer, sf_buffer, cell.nof_prb)) { + srsran_ofdm_t fft; + if (srsran_ofdm_rx_init(&fft, cell.cp, input_buffer, sf_buffer, cell.nof_prb)) { fprintf(stderr, "Error creating FFT object\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - srslte_ofdm_set_normalize(&fft, true); - srslte_ofdm_set_freq_shift(&fft, -0.5); + srsran_ofdm_set_normalize(&fft, true); + srsran_ofdm_set_freq_shift(&fft, -0.5); // PSBCH - srslte_psbch_t psbch; - if (srslte_psbch_init(&psbch, cell.nof_prb, cell.N_sl_id, cell.tm, cell.cp) != SRSLTE_SUCCESS) { + srsran_psbch_t psbch; + if (srsran_psbch_init(&psbch, cell.nof_prb, cell.N_sl_id, cell.tm, cell.cp) != SRSRAN_SUCCESS) { ERROR("Error in psbch init"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // PSCBH DMRS - srslte_sl_comm_resource_pool_t sl_comm_resource_pool; - if (srslte_sl_comm_resource_pool_get_default_config(&sl_comm_resource_pool, cell) != SRSLTE_SUCCESS) { + srsran_sl_comm_resource_pool_t sl_comm_resource_pool; + if (srsran_sl_comm_resource_pool_get_default_config(&sl_comm_resource_pool, cell) != SRSRAN_SUCCESS) { ERROR("Error initializing sl_comm_resource_pool"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - srslte_chest_sl_t psbch_chest; - if (srslte_chest_sl_init(&psbch_chest, SRSLTE_SIDELINK_PSBCH, cell, sl_comm_resource_pool) != SRSLTE_SUCCESS) { + srsran_chest_sl_t psbch_chest; + if (srsran_chest_sl_init(&psbch_chest, SRSRAN_SIDELINK_PSBCH, cell, sl_comm_resource_pool) != SRSRAN_SUCCESS) { ERROR("Error in chest PSBCH init"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Read subframe from third party implementations - if (!input_file_name || srslte_filesource_init(&fsrc, input_file_name, SRSLTE_COMPLEX_FLOAT_BIN)) { + if (!input_file_name || srsran_filesource_init(&fsrc, input_file_name, SRSRAN_COMPLEX_FLOAT_BIN)) { printf("Error opening file %s\n", input_file_name); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - srslte_filesource_read(&fsrc, input_buffer, sf_n_samples); - // srslte_vec_sc_prod_cfc(input_buffer, sqrtf(symbol_sz), input_buffer, sf_n_samples); + srsran_filesource_read(&fsrc, input_buffer, sf_n_samples); + // srsran_vec_sc_prod_cfc(input_buffer, sqrtf(symbol_sz), input_buffer, sf_n_samples); // Run FFT - srslte_ofdm_rx_sf(&fft); + srsran_ofdm_rx_sf(&fft); // Equalize if (do_equalization) { - srslte_chest_sl_ls_estimate_equalize(&psbch_chest, sf_buffer, equalized_sf_buffer); + srsran_chest_sl_ls_estimate_equalize(&psbch_chest, sf_buffer, equalized_sf_buffer); } else { // just copy symbols memcpy(equalized_sf_buffer, sf_buffer, sizeof(cf_t) * sf_n_re); } // prepare Rx buffer - uint8_t mib_sl_rx[SRSLTE_MIB_SL_MAX_LEN] = {}; + uint8_t mib_sl_rx[SRSRAN_MIB_SL_MAX_LEN] = {}; // Decode PSBCH - if (srslte_psbch_decode(&psbch, equalized_sf_buffer, mib_sl_rx, sizeof(mib_sl_rx)) == SRSLTE_SUCCESS) { + if (srsran_psbch_decode(&psbch, equalized_sf_buffer, mib_sl_rx, sizeof(mib_sl_rx)) == SRSRAN_SUCCESS) { printf("Rx payload: "); - srslte_vec_fprint_hex(stdout, mib_sl_rx, sizeof(mib_sl_rx)); + srsran_vec_fprint_hex(stdout, mib_sl_rx, sizeof(mib_sl_rx)); // Unpack and print MIB-SL - srslte_mib_sl_t mib_sl; - srslte_mib_sl_init(&mib_sl, cell.tm); - srslte_mib_sl_unpack(&mib_sl, mib_sl_rx); - srslte_mib_sl_printf(stdout, &mib_sl); + srsran_mib_sl_t mib_sl; + srsran_mib_sl_init(&mib_sl, cell.tm); + srsran_mib_sl_unpack(&mib_sl, mib_sl_rx); + srsran_mib_sl_printf(stdout, &mib_sl); // check decoded bandwidth matches user configured value - if (srslte_mib_sl_bandwith_to_prb[mib_sl.sl_bandwidth_r12] == cell.nof_prb) { - ret = SRSLTE_SUCCESS; + if (srsran_mib_sl_bandwith_to_prb[mib_sl.sl_bandwidth_r12] == cell.nof_prb) { + ret = SRSRAN_SUCCESS; } } - if (SRSLTE_VERBOSE_ISDEBUG()) { + if (SRSRAN_VERBOSE_ISDEBUG()) { char* filename = (do_equalization) ? "psbch_rx_syms_eq_on.bin" : "psbch_rx_syms_eq_off.bin"; printf("Saving PSBCH symbols (%d) to %s\n", psbch.E / psbch.Qm, filename); - srslte_vec_save_file(filename, psbch.mod_symbols, psbch.E / psbch.Qm * sizeof(cf_t)); + srsran_vec_save_file(filename, psbch.mod_symbols, psbch.E / psbch.Qm * sizeof(cf_t)); } - srslte_ofdm_tx_free(&ifft); - srslte_ofdm_rx_free(&fft); + srsran_ofdm_tx_free(&ifft); + srsran_ofdm_rx_free(&fft); - srslte_filesource_free(&fsrc); + srsran_filesource_free(&fsrc); - srslte_chest_sl_free(&psbch_chest); - srslte_psbch_free(&psbch); + srsran_chest_sl_free(&psbch_chest); + srsran_psbch_free(&psbch); free(sf_buffer); free(equalized_sf_buffer); diff --git a/lib/src/phy/phch/test/psbch_test.c b/lib/src/phy/phch/test/psbch_test.c index df8de24da..7e9ddb55d 100644 --- a/lib/src/phy/phch/test/psbch_test.c +++ b/lib/src/phy/phch/test/psbch_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -14,13 +14,13 @@ #include #include -#include "srslte/common/test_common.h" -#include -#include -#include -#include +#include "srsran/common/test_common.h" +#include +#include +#include +#include -srslte_cell_sl_t cell = {.nof_prb = 6, .N_sl_id = 168, .tm = SRSLTE_SIDELINK_TM2, .cp = SRSLTE_CP_NORM}; +srsran_cell_sl_t cell = {.nof_prb = 6, .N_sl_id = 168, .tm = SRSRAN_SIDELINK_TM2, .cp = SRSRAN_CP_NORM}; void usage(char* prog) { @@ -29,7 +29,7 @@ void usage(char* prog) printf("\t-e extended CP [Default normal]\n"); printf("\t-c N_sl_id [Default %d]\n", cell.N_sl_id); printf("\t-t Sidelink transmission mode {1,2,3,4} [Default %d]\n", (cell.tm + 1)); - printf("\t-v [set srslte_verbose to debug, default none]\n"); + printf("\t-v [set srsran_verbose to debug, default none]\n"); } void parse_args(int argc, char** argv) @@ -41,7 +41,7 @@ void parse_args(int argc, char** argv) cell.N_sl_id = (int32_t)strtol(argv[optind], NULL, 10); break; case 'e': - cell.cp = SRSLTE_CP_EXT; + cell.cp = SRSRAN_CP_EXT; break; case 'p': cell.nof_prb = (uint32_t)strtol(argv[optind], NULL, 10); @@ -49,16 +49,16 @@ void parse_args(int argc, char** argv) case 't': switch (strtol(argv[optind], NULL, 10)) { case 1: - cell.tm = SRSLTE_SIDELINK_TM1; + cell.tm = SRSRAN_SIDELINK_TM1; break; case 2: - cell.tm = SRSLTE_SIDELINK_TM2; + cell.tm = SRSRAN_SIDELINK_TM2; break; case 3: - cell.tm = SRSLTE_SIDELINK_TM3; + cell.tm = SRSRAN_SIDELINK_TM3; break; case 4: - cell.tm = SRSLTE_SIDELINK_TM4; + cell.tm = SRSRAN_SIDELINK_TM4; break; default: usage(argv[0]); @@ -67,14 +67,14 @@ void parse_args(int argc, char** argv) } break; case 'v': - srslte_verbose++; + srsran_verbose++; break; default: usage(argv[0]); exit(-1); } } - if (SRSLTE_CP_ISEXT(cell.cp) && cell.tm >= SRSLTE_SIDELINK_TM3) { + if (SRSRAN_CP_ISEXT(cell.cp) && cell.tm >= SRSRAN_SIDELINK_TM3) { ERROR("Selected TM does not support extended CP"); usage(argv[0]); exit(-1); @@ -83,55 +83,55 @@ void parse_args(int argc, char** argv) int main(int argc, char** argv) { - int ret = SRSLTE_ERROR; + int ret = SRSRAN_ERROR; parse_args(argc, argv); - uint32_t sf_n_re = SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp); - cf_t* sf_buffer = srslte_vec_cf_malloc(sf_n_re); + uint32_t sf_n_re = SRSRAN_SF_LEN_RE(cell.nof_prb, cell.cp); + cf_t* sf_buffer = srsran_vec_cf_malloc(sf_n_re); // MIB-SL - srslte_mib_sl_t mib_sl; - srslte_mib_sl_init(&mib_sl, cell.tm); - srslte_mib_sl_set(&mib_sl, cell.nof_prb, 0, 128, 4, false); + srsran_mib_sl_t mib_sl; + srsran_mib_sl_init(&mib_sl, cell.tm); + srsran_mib_sl_set(&mib_sl, cell.nof_prb, 0, 128, 4, false); // PSBCH - srslte_psbch_t psbch; - if (srslte_psbch_init(&psbch, cell.nof_prb, cell.N_sl_id, cell.tm, cell.cp) != SRSLTE_SUCCESS) { + srsran_psbch_t psbch; + if (srsran_psbch_init(&psbch, cell.nof_prb, cell.N_sl_id, cell.tm, cell.cp) != SRSRAN_SUCCESS) { ERROR("Error in psbch init"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // MIB message bits - uint8_t mib_sl_tx[SRSLTE_MIB_SL_MAX_LEN] = {}; - srslte_mib_sl_pack(&mib_sl, mib_sl_tx); + uint8_t mib_sl_tx[SRSRAN_MIB_SL_MAX_LEN] = {}; + srsran_mib_sl_pack(&mib_sl, mib_sl_tx); printf("Tx payload: "); - srslte_vec_fprint_hex(stdout, mib_sl_tx, mib_sl.mib_sl_len); + srsran_vec_fprint_hex(stdout, mib_sl_tx, mib_sl.mib_sl_len); // Put MIB-SL into PSBCH - srslte_psbch_encode(&psbch, mib_sl_tx, mib_sl.mib_sl_len, sf_buffer); + srsran_psbch_encode(&psbch, mib_sl_tx, mib_sl.mib_sl_len, sf_buffer); // prepare Rx buffer - uint8_t mib_sl_rx[SRSLTE_MIB_SL_MAX_LEN] = {}; + uint8_t mib_sl_rx[SRSRAN_MIB_SL_MAX_LEN] = {}; // Decode PSBCH - if (srslte_psbch_decode(&psbch, sf_buffer, mib_sl_rx, sizeof(mib_sl_rx)) == SRSLTE_SUCCESS) { + if (srsran_psbch_decode(&psbch, sf_buffer, mib_sl_rx, sizeof(mib_sl_rx)) == SRSRAN_SUCCESS) { printf("Rx payload: "); - srslte_vec_fprint_hex(stdout, mib_sl_rx, mib_sl.mib_sl_len); + srsran_vec_fprint_hex(stdout, mib_sl_rx, mib_sl.mib_sl_len); - srslte_mib_sl_unpack(&mib_sl, mib_sl_rx); - srslte_mib_sl_printf(stdout, &mib_sl); + srsran_mib_sl_unpack(&mib_sl, mib_sl_rx); + srsran_mib_sl_printf(stdout, &mib_sl); // check decoded bandwidth matches user configured value - if (srslte_mib_sl_bandwith_to_prb[mib_sl.sl_bandwidth_r12] == cell.nof_prb) { - ret = SRSLTE_SUCCESS; + if (srsran_mib_sl_bandwith_to_prb[mib_sl.sl_bandwidth_r12] == cell.nof_prb) { + ret = SRSRAN_SUCCESS; } } // Sanity check (less REs are transmitted than mapped) - if (cell.tm <= SRSLTE_SIDELINK_TM2) { - if (SRSLTE_CP_ISNORM(cell.cp)) { + if (cell.tm <= SRSRAN_SIDELINK_TM2) { + if (SRSRAN_CP_ISNORM(cell.cp)) { // TM1 and TM2 have always 576 mapped PSBCH resource elements of which 504 are transmitted TESTASSERT(psbch.nof_data_re == 576); TESTASSERT(psbch.nof_tx_re == 504); @@ -146,14 +146,14 @@ int main(int argc, char** argv) TESTASSERT(psbch.nof_tx_re == 432); } - if (SRSLTE_VERBOSE_ISDEBUG()) { + if (SRSRAN_VERBOSE_ISDEBUG()) { printf("PSBCH eq. symbols (%d), saving to psbch_rx_syms.bin\n", psbch.E / psbch.Qm); - srslte_vec_fprint_c(stdout, psbch.mod_symbols, 8); - srslte_vec_save_file("psbch_rx_syms.bin", psbch.mod_symbols, psbch.E / psbch.Qm * sizeof(cf_t)); + srsran_vec_fprint_c(stdout, psbch.mod_symbols, 8); + srsran_vec_save_file("psbch_rx_syms.bin", psbch.mod_symbols, psbch.E / psbch.Qm * sizeof(cf_t)); } - srslte_mib_sl_free(&mib_sl); - srslte_psbch_free(&psbch); + srsran_mib_sl_free(&mib_sl); + srsran_psbch_free(&psbch); free(sf_buffer); return ret; diff --git a/lib/src/phy/phch/test/pscch_test.c b/lib/src/phy/phch/test/pscch_test.c index 8e997d6a3..78c6c5207 100644 --- a/lib/src/phy/phch/test/pscch_test.c +++ b/lib/src/phy/phch/test/pscch_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -15,12 +15,12 @@ #include #include -#include "srslte/phy/phch/pscch.h" -#include "srslte/phy/phch/sci.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/phch/pscch.h" +#include "srsran/phy/phch/sci.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" -srslte_cell_sl_t cell = {.nof_prb = 6, .N_sl_id = 168, .tm = SRSLTE_SIDELINK_TM2, .cp = SRSLTE_CP_NORM}; +srsran_cell_sl_t cell = {.nof_prb = 6, .N_sl_id = 168, .tm = SRSRAN_SIDELINK_TM2, .cp = SRSRAN_CP_NORM}; uint32_t prb_start_idx = 0; @@ -30,7 +30,7 @@ void usage(char* prog) printf("\t-p nof_prb [Default %d]\n", cell.nof_prb); printf("\t-c N_sl_id [Default %d]\n", cell.N_sl_id); printf("\t-t Sidelink transmission mode {1,2,3,4} [Default %d]\n", (cell.tm + 1)); - printf("\t-v [set srslte_verbose to debug, default none]\n"); + printf("\t-v [set srsran_verbose to debug, default none]\n"); } void parse_args(int argc, char** argv) @@ -47,16 +47,16 @@ void parse_args(int argc, char** argv) case 't': switch (strtol(argv[optind], NULL, 10)) { case 1: - cell.tm = SRSLTE_SIDELINK_TM1; + cell.tm = SRSRAN_SIDELINK_TM1; break; case 2: - cell.tm = SRSLTE_SIDELINK_TM2; + cell.tm = SRSRAN_SIDELINK_TM2; break; case 3: - cell.tm = SRSLTE_SIDELINK_TM3; + cell.tm = SRSRAN_SIDELINK_TM3; break; case 4: - cell.tm = SRSLTE_SIDELINK_TM4; + cell.tm = SRSRAN_SIDELINK_TM4; break; default: usage(argv[0]); @@ -65,14 +65,14 @@ void parse_args(int argc, char** argv) } break; case 'v': - srslte_verbose++; + srsran_verbose++; break; default: usage(argv[0]); exit(-1); } } - if (cell.cp == SRSLTE_CP_EXT && cell.tm >= SRSLTE_SIDELINK_TM3) { + if (cell.cp == SRSRAN_CP_EXT && cell.tm >= SRSRAN_SIDELINK_TM3) { ERROR("Selected TM does not support extended CP"); usage(argv[0]); exit(-1); @@ -81,89 +81,89 @@ void parse_args(int argc, char** argv) int main(int argc, char** argv) { - int ret = SRSLTE_ERROR; + int ret = SRSRAN_ERROR; parse_args(argc, argv); - srslte_sl_comm_resource_pool_t sl_comm_resource_pool; - if (srslte_sl_comm_resource_pool_get_default_config(&sl_comm_resource_pool, cell) != SRSLTE_SUCCESS) { + srsran_sl_comm_resource_pool_t sl_comm_resource_pool; + if (srsran_sl_comm_resource_pool_get_default_config(&sl_comm_resource_pool, cell) != SRSRAN_SUCCESS) { ERROR("Error initializing sl_comm_resource_pool"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - char sci_msg[SRSLTE_SCI_MSG_MAX_LEN] = {}; + char sci_msg[SRSRAN_SCI_MSG_MAX_LEN] = {}; - uint32_t sf_n_re = SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp); - cf_t* sf_buffer = srslte_vec_cf_malloc(sf_n_re); + uint32_t sf_n_re = SRSRAN_SF_LEN_RE(cell.nof_prb, cell.cp); + cf_t* sf_buffer = srsran_vec_cf_malloc(sf_n_re); // SCI - srslte_sci_t sci; - srslte_sci_init(&sci, cell, sl_comm_resource_pool); + srsran_sci_t sci; + srsran_sci_init(&sci, cell, sl_comm_resource_pool); sci.mcs_idx = 2; // PSCCH - srslte_pscch_t pscch; - if (srslte_pscch_init(&pscch, SRSLTE_MAX_PRB) != SRSLTE_SUCCESS) { + srsran_pscch_t pscch; + if (srsran_pscch_init(&pscch, SRSRAN_MAX_PRB) != SRSRAN_SUCCESS) { ERROR("Error in PSCCH init"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_pscch_set_cell(&pscch, cell) != SRSLTE_SUCCESS) { + if (srsran_pscch_set_cell(&pscch, cell) != SRSRAN_SUCCESS) { ERROR("Error in PSCCH init"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // SCI message bits - uint8_t sci_tx[SRSLTE_SCI_MAX_LEN] = {}; - if (sci.format == SRSLTE_SCI_FORMAT0) { - if (srslte_sci_format0_pack(&sci, sci_tx) != SRSLTE_SUCCESS) { + uint8_t sci_tx[SRSRAN_SCI_MAX_LEN] = {}; + if (sci.format == SRSRAN_SCI_FORMAT0) { + if (srsran_sci_format0_pack(&sci, sci_tx) != SRSRAN_SUCCESS) { printf("Error packing sci format 0\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - } else if (sci.format == SRSLTE_SCI_FORMAT1) { - if (srslte_sci_format1_pack(&sci, sci_tx) != SRSLTE_SUCCESS) { + } else if (sci.format == SRSRAN_SCI_FORMAT1) { + if (srsran_sci_format1_pack(&sci, sci_tx) != SRSRAN_SUCCESS) { printf("Error packing sci format 1\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } printf("Tx payload: "); - srslte_vec_fprint_hex(stdout, sci_tx, sci.sci_len); + srsran_vec_fprint_hex(stdout, sci_tx, sci.sci_len); // Put SCI into PSCCH - srslte_pscch_encode(&pscch, sci_tx, sf_buffer, prb_start_idx); + srsran_pscch_encode(&pscch, sci_tx, sf_buffer, prb_start_idx); // Prepare Rx buffer - uint8_t sci_rx[SRSLTE_SCI_MAX_LEN] = {}; + uint8_t sci_rx[SRSRAN_SCI_MAX_LEN] = {}; // Decode PSCCH - if (srslte_pscch_decode(&pscch, sf_buffer, sci_rx, prb_start_idx) == SRSLTE_SUCCESS) { + if (srsran_pscch_decode(&pscch, sf_buffer, sci_rx, prb_start_idx) == SRSRAN_SUCCESS) { printf("Rx payload: "); - srslte_vec_fprint_hex(stdout, sci_rx, sci.sci_len); + srsran_vec_fprint_hex(stdout, sci_rx, sci.sci_len); uint32_t riv_txed = sci.riv; - if (sci.format == SRSLTE_SCI_FORMAT0) { - if (srslte_sci_format0_unpack(&sci, sci_rx) != SRSLTE_SUCCESS) { + if (sci.format == SRSRAN_SCI_FORMAT0) { + if (srsran_sci_format0_unpack(&sci, sci_rx) != SRSRAN_SUCCESS) { printf("Error unpacking sci format 0\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - } else if (sci.format == SRSLTE_SCI_FORMAT1) { - if (srslte_sci_format1_unpack(&sci, sci_rx) != SRSLTE_SUCCESS) { + } else if (sci.format == SRSRAN_SCI_FORMAT1) { + if (srsran_sci_format1_unpack(&sci, sci_rx) != SRSRAN_SUCCESS) { printf("Error unpacking sci format 1\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } - srslte_sci_info(&sci, sci_msg, sizeof(sci_msg)); + srsran_sci_info(&sci, sci_msg, sizeof(sci_msg)); fprintf(stdout, "%s", sci_msg); if (sci.riv == riv_txed) { - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } } free(sf_buffer); - srslte_sci_free(&sci); - srslte_pscch_free(&pscch); + srsran_sci_free(&sci); + srsran_pscch_free(&pscch); return ret; } diff --git a/lib/src/phy/phch/test/pssch_pscch_file_test.c b/lib/src/phy/phch/test/pssch_pscch_file_test.c index 6279d5c80..398aed99f 100644 --- a/lib/src/phy/phch/test/pssch_pscch_file_test.c +++ b/lib/src/phy/phch/test/pssch_pscch_file_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -15,20 +15,20 @@ #include #include -#include "srslte/phy/ch_estimation/chest_sl.h" -#include "srslte/phy/channel/ch_awgn.h" -#include "srslte/phy/common/phy_common_sl.h" -#include "srslte/phy/dft/ofdm.h" -#include "srslte/phy/io/filesource.h" -#include "srslte/phy/phch/pscch.h" -#include "srslte/phy/phch/pssch.h" -#include "srslte/phy/phch/ra_sl.h" -#include "srslte/phy/phch/sci.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/ch_estimation/chest_sl.h" +#include "srsran/phy/channel/ch_awgn.h" +#include "srsran/phy/common/phy_common_sl.h" +#include "srsran/phy/dft/ofdm.h" +#include "srsran/phy/io/filesource.h" +#include "srsran/phy/phch/pscch.h" +#include "srsran/phy/phch/pssch.h" +#include "srsran/phy/phch/ra_sl.h" +#include "srsran/phy/phch/sci.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" static char* input_file_name = NULL; -static srslte_cell_sl_t cell = {.nof_prb = 6, .N_sl_id = 0, .tm = SRSLTE_SIDELINK_TM2, .cp = SRSLTE_CP_NORM}; +static srsran_cell_sl_t cell = {.nof_prb = 6, .N_sl_id = 0, .tm = SRSRAN_SIDELINK_TM2, .cp = SRSRAN_CP_NORM}; static bool use_standard_lte_rates = false; static uint32_t file_offset = 0; @@ -37,21 +37,21 @@ static uint32_t sf_n_re = 0; static cf_t* sf_buffer = NULL; static cf_t* equalized_sf_buffer = NULL; static cf_t* input_buffer = NULL; -static srslte_sci_t sci = {}; -static srslte_pscch_t pscch = {}; -static srslte_chest_sl_t pscch_chest = {}; -static srslte_pssch_t pssch = {}; -static srslte_chest_sl_t pssch_chest = {}; -static srslte_ofdm_t fft = {}; -static srslte_sl_comm_resource_pool_t sl_comm_resource_pool = {}; +static srsran_sci_t sci = {}; +static srsran_pscch_t pscch = {}; +static srsran_chest_sl_t pscch_chest = {}; +static srsran_pssch_t pssch = {}; +static srsran_chest_sl_t pssch_chest = {}; +static srsran_ofdm_t fft = {}; +static srsran_sl_comm_resource_pool_t sl_comm_resource_pool = {}; static uint32_t size_sub_channel = 10; static uint32_t num_sub_channel = 5; static uint32_t current_sf_idx = 0; -static srslte_chest_sl_cfg_t pscch_chest_sl_cfg = {}; -static srslte_chest_sl_cfg_t pssch_chest_sl_cfg = {}; +static srsran_chest_sl_cfg_t pscch_chest_sl_cfg = {}; +static srsran_chest_sl_cfg_t pssch_chest_sl_cfg = {}; -static srslte_filesource_t fsrc = {}; +static srsran_filesource_t fsrc = {}; void usage(char* prog) { @@ -65,7 +65,7 @@ void usage(char* prog) printf("\t-e Extended CP [Default normal]\n"); printf("\t-t Sidelink transmission mode {1,2,3,4} [Default %d]\n", (cell.tm + 1)); printf("\t-d use_standard_lte_rates [Default %i]\n", use_standard_lte_rates); - printf("\t-v [set srslte_verbose to debug, default none]\n"); + printf("\t-v [set srsran_verbose to debug, default none]\n"); } void parse_args(int argc, char** argv) @@ -80,7 +80,7 @@ void parse_args(int argc, char** argv) file_offset = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'e': - cell.cp = SRSLTE_CP_EXT; + cell.cp = SRSRAN_CP_EXT; break; case 'i': input_file_name = argv[optind]; @@ -98,20 +98,20 @@ void parse_args(int argc, char** argv) cell.nof_prb = (uint32_t)strtol(argv[optind], NULL, 10); break; case 't': - if (srslte_sl_tm_to_cell_sl_tm_t(&cell, strtol(argv[optind], NULL, 10)) != SRSLTE_SUCCESS) { + if (srsran_sl_tm_to_cell_sl_tm_t(&cell, strtol(argv[optind], NULL, 10)) != SRSRAN_SUCCESS) { usage(argv[0]); exit(-1); } break; case 'v': - srslte_verbose++; + srsran_verbose++; break; default: usage(argv[0]); exit(-1); } } - if (SRSLTE_CP_ISEXT(cell.cp) && cell.tm >= SRSLTE_SIDELINK_TM3) { + if (SRSRAN_CP_ISEXT(cell.cp) && cell.tm >= SRSRAN_SIDELINK_TM3) { ERROR("Selected TM does not support extended CP"); usage(argv[0]); exit(-1); @@ -120,95 +120,95 @@ void parse_args(int argc, char** argv) int base_init() { - sf_n_samples = srslte_symbol_sz(cell.nof_prb) * 15; - sf_n_re = SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp); + sf_n_samples = srsran_symbol_sz(cell.nof_prb) * 15; + sf_n_re = SRSRAN_SF_LEN_RE(cell.nof_prb, cell.cp); - if (srslte_sl_comm_resource_pool_get_default_config(&sl_comm_resource_pool, cell) != SRSLTE_SUCCESS) { + if (srsran_sl_comm_resource_pool_get_default_config(&sl_comm_resource_pool, cell) != SRSRAN_SUCCESS) { ERROR("Error initializing sl_comm_resource_pool"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } sl_comm_resource_pool.num_sub_channel = num_sub_channel; sl_comm_resource_pool.size_sub_channel = size_sub_channel; - sf_buffer = srslte_vec_cf_malloc(sf_n_re); + sf_buffer = srsran_vec_cf_malloc(sf_n_re); if (!sf_buffer) { ERROR("Error allocating memory"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - srslte_vec_cf_zero(sf_buffer, sf_n_re); + srsran_vec_cf_zero(sf_buffer, sf_n_re); - equalized_sf_buffer = srslte_vec_cf_malloc(sf_n_re); + equalized_sf_buffer = srsran_vec_cf_malloc(sf_n_re); if (!equalized_sf_buffer) { ERROR("Error allocating memory"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - srslte_vec_cf_zero(equalized_sf_buffer, sf_n_re); + srsran_vec_cf_zero(equalized_sf_buffer, sf_n_re); - input_buffer = srslte_vec_cf_malloc(sf_n_samples); + input_buffer = srsran_vec_cf_malloc(sf_n_samples); if (!input_buffer) { ERROR("Error allocating memory"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - srslte_vec_cf_zero(input_buffer, sf_n_samples); + srsran_vec_cf_zero(input_buffer, sf_n_samples); - srslte_sci_init(&sci, cell, sl_comm_resource_pool); + srsran_sci_init(&sci, cell, sl_comm_resource_pool); - if (srslte_pscch_init(&pscch, SRSLTE_MAX_PRB) != SRSLTE_SUCCESS) { + if (srsran_pscch_init(&pscch, SRSRAN_MAX_PRB) != SRSRAN_SUCCESS) { ERROR("Error in PSCCH init"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_pscch_set_cell(&pscch, cell) != SRSLTE_SUCCESS) { + if (srsran_pscch_set_cell(&pscch, cell) != SRSRAN_SUCCESS) { ERROR("Error in PSCCH set cell"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_chest_sl_init(&pscch_chest, SRSLTE_SIDELINK_PSCCH, cell, sl_comm_resource_pool) != SRSLTE_SUCCESS) { + if (srsran_chest_sl_init(&pscch_chest, SRSRAN_SIDELINK_PSCCH, cell, sl_comm_resource_pool) != SRSRAN_SUCCESS) { ERROR("Error in PSCCH DMRS init"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_pssch_init(&pssch, cell, sl_comm_resource_pool) != SRSLTE_SUCCESS) { + if (srsran_pssch_init(&pssch, cell, sl_comm_resource_pool) != SRSRAN_SUCCESS) { ERROR("Error initializing PSSCH"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_chest_sl_init(&pssch_chest, SRSLTE_SIDELINK_PSSCH, cell, sl_comm_resource_pool) != SRSLTE_SUCCESS) { + if (srsran_chest_sl_init(&pssch_chest, SRSRAN_SIDELINK_PSSCH, cell, sl_comm_resource_pool) != SRSRAN_SUCCESS) { ERROR("Error in chest PSSCH init"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (input_file_name) { - if (srslte_filesource_init(&fsrc, input_file_name, SRSLTE_COMPLEX_FLOAT_BIN)) { + if (srsran_filesource_init(&fsrc, input_file_name, SRSRAN_COMPLEX_FLOAT_BIN)) { printf("Error opening file %s", input_file_name); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } else { ERROR("Invalid input file name"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_ofdm_rx_init(&fft, cell.cp, input_buffer, sf_buffer, cell.nof_prb)) { + if (srsran_ofdm_rx_init(&fft, cell.cp, input_buffer, sf_buffer, cell.nof_prb)) { fprintf(stderr, "Error creating FFT object\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - srslte_ofdm_set_normalize(&fft, true); - srslte_ofdm_set_freq_shift(&fft, -0.5); + srsran_ofdm_set_normalize(&fft, true); + srsran_ofdm_set_freq_shift(&fft, -0.5); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } void base_free() { - srslte_filesource_free(&fsrc); - srslte_ofdm_rx_free(&fft); + srsran_filesource_free(&fsrc); + srsran_ofdm_rx_free(&fft); - srslte_sci_free(&sci); - srslte_pscch_free(&pscch); - srslte_chest_sl_free(&pscch_chest); + srsran_sci_free(&sci); + srsran_pscch_free(&pscch); + srsran_chest_sl_free(&pscch_chest); - srslte_pssch_free(&pssch); - srslte_chest_sl_free(&pssch_chest); + srsran_pssch_free(&pssch); + srsran_chest_sl_free(&pssch_chest); if (sf_buffer) { free(sf_buffer); @@ -223,24 +223,24 @@ void base_free() int main(int argc, char** argv) { - uint8_t sci_rx[SRSLTE_SCI_MAX_LEN] = {}; - int ret = SRSLTE_ERROR; + uint8_t sci_rx[SRSRAN_SCI_MAX_LEN] = {}; + int ret = SRSRAN_ERROR; parse_args(argc, argv); - srslte_use_standard_symbol_size(use_standard_lte_rates); + srsran_use_standard_symbol_size(use_standard_lte_rates); if (base_init()) { ERROR("Error initializing"); base_free(); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } bool sci_decoded = false; uint32_t num_decoded_sci = 0; - char sci_msg[SRSLTE_SCI_MSG_MAX_LEN] = {}; + char sci_msg[SRSRAN_SCI_MSG_MAX_LEN] = {}; uint32_t num_decoded_tb = 0; - uint8_t tb[SRSLTE_SL_SCH_MAX_TB_LEN] = {}; + uint8_t tb[SRSRAN_SL_SCH_MAX_TB_LEN] = {}; int max_num_subframes = 128; int num_subframes = 0; @@ -251,11 +251,11 @@ int main(int argc, char** argv) if (file_offset > 0) { printf("Offsetting file by %d samples.\n", file_offset); - srslte_filesource_seek(&fsrc, file_offset * sizeof(cf_t)); + srsran_filesource_seek(&fsrc, file_offset * sizeof(cf_t)); } do { - nread = srslte_filesource_read(&fsrc, input_buffer, sf_n_samples); + nread = srsran_filesource_read(&fsrc, input_buffer, sf_n_samples); if (nread < 0) { fprintf(stderr, "Error reading from file\n"); return ret; @@ -267,9 +267,9 @@ int main(int argc, char** argv) } // Convert to frequency domain - srslte_ofdm_rx_sf(&fft); + srsran_ofdm_rx_sf(&fft); - if (cell.tm == SRSLTE_SIDELINK_TM1 || cell.tm == SRSLTE_SIDELINK_TM2) { + if (cell.tm == SRSRAN_SIDELINK_TM1 || cell.tm == SRSRAN_SIDELINK_TM2) { // 3GPP TS 36.213 Section 14.2.1.2 UE procedure for determining subframes // and resource blocks for transmitting PSCCH for sidelink transmission mode 2 if (sl_comm_resource_pool.pscch_sf_bitmap[period_sf_idx] == 1) { @@ -278,12 +278,12 @@ int main(int argc, char** argv) pscch_prb_start_idx++) { // PSCCH Channel estimation pscch_chest_sl_cfg.prb_start_idx = pscch_prb_start_idx; - srslte_chest_sl_set_cfg(&pscch_chest, pscch_chest_sl_cfg); - srslte_chest_sl_ls_estimate_equalize(&pscch_chest, sf_buffer, equalized_sf_buffer); + srsran_chest_sl_set_cfg(&pscch_chest, pscch_chest_sl_cfg); + srsran_chest_sl_ls_estimate_equalize(&pscch_chest, sf_buffer, equalized_sf_buffer); - if (srslte_pscch_decode(&pscch, equalized_sf_buffer, sci_rx, pscch_prb_start_idx) == SRSLTE_SUCCESS) { - if (srslte_sci_format0_unpack(&sci, sci_rx) == SRSLTE_SUCCESS) { - srslte_sci_info(&sci, sci_msg, sizeof(sci_msg)); + if (srsran_pscch_decode(&pscch, equalized_sf_buffer, sci_rx, pscch_prb_start_idx) == SRSRAN_SUCCESS) { + if (srsran_sci_format0_unpack(&sci, sci_rx) == SRSRAN_SUCCESS) { + srsran_sci_info(&sci, sci_msg, sizeof(sci_msg)); fprintf(stdout, "%s", sci_msg); sci_decoded = true; @@ -301,13 +301,13 @@ int main(int argc, char** argv) } if ((sl_comm_resource_pool.pssch_sf_bitmap[period_sf_idx] == 1) && (sci_decoded == true)) { - if (srslte_ra_sl_pssch_allowed_sf(current_sf_idx, sci.trp_idx, SRSLTE_SL_DUPLEX_MODE_FDD, 0)) { + if (srsran_ra_sl_pssch_allowed_sf(current_sf_idx, sci.trp_idx, SRSRAN_SL_DUPLEX_MODE_FDD, 0)) { // Redundancy version uint32_t rv_idx = allowed_pssch_sf_idx % 4; uint32_t nof_prb_pssch = 0; uint32_t pssch_prb_start_idx = 0; - srslte_ra_sl_type0_from_riv(sci.riv, cell.nof_prb, &nof_prb_pssch, &pssch_prb_start_idx); + srsran_ra_sl_type0_from_riv(sci.riv, cell.nof_prb, &nof_prb_pssch, &pssch_prb_start_idx); printf("pssch_start_prb_idx = %i nof_prb = %i\n", pssch_prb_start_idx, nof_prb_pssch); // PSSCH Channel estimation @@ -315,14 +315,14 @@ int main(int argc, char** argv) pssch_chest_sl_cfg.sf_idx = current_sf_idx; pssch_chest_sl_cfg.prb_start_idx = pssch_prb_start_idx; pssch_chest_sl_cfg.nof_prb = nof_prb_pssch; - srslte_chest_sl_set_cfg(&pssch_chest, pssch_chest_sl_cfg); - srslte_chest_sl_ls_estimate_equalize(&pssch_chest, sf_buffer, equalized_sf_buffer); + srsran_chest_sl_set_cfg(&pssch_chest, pssch_chest_sl_cfg); + srsran_chest_sl_ls_estimate_equalize(&pssch_chest, sf_buffer, equalized_sf_buffer); - srslte_pssch_cfg_t pssch_cfg = { + srsran_pssch_cfg_t pssch_cfg = { pssch_prb_start_idx, nof_prb_pssch, sci.N_sa_id, sci.mcs_idx, rv_idx, current_sf_idx}; - if (srslte_pssch_set_cfg(&pssch, pssch_cfg) == SRSLTE_SUCCESS) { - if (srslte_pssch_decode(&pssch, equalized_sf_buffer, tb, SRSLTE_SL_SCH_MAX_TB_LEN) == SRSLTE_SUCCESS) { - srslte_vec_fprint_byte(stdout, tb, pssch.sl_sch_tb_len); + if (srsran_pssch_set_cfg(&pssch, pssch_cfg) == SRSRAN_SUCCESS) { + if (srsran_pssch_decode(&pssch, equalized_sf_buffer, tb, SRSRAN_SL_SCH_MAX_TB_LEN) == SRSRAN_SUCCESS) { + srsran_vec_fprint_byte(stdout, tb, pssch.sl_sch_tb_len); num_decoded_tb++; printf("> Transport Block SUCCESS! TB count: %i\n", num_decoded_tb); } @@ -331,7 +331,7 @@ int main(int argc, char** argv) } current_sf_idx++; } - } else if (cell.tm == SRSLTE_SIDELINK_TM3 || cell.tm == SRSLTE_SIDELINK_TM4) { + } else if (cell.tm == SRSRAN_SIDELINK_TM3 || cell.tm == SRSRAN_SIDELINK_TM4) { for (int sub_channel_idx = 0; sub_channel_idx < sl_comm_resource_pool.num_sub_channel; sub_channel_idx++) { uint32_t pscch_prb_start_idx = sl_comm_resource_pool.size_sub_channel * sub_channel_idx; @@ -339,12 +339,12 @@ int main(int argc, char** argv) // PSCCH Channel estimation pscch_chest_sl_cfg.cyclic_shift = cyclic_shift; pscch_chest_sl_cfg.prb_start_idx = pscch_prb_start_idx; - srslte_chest_sl_set_cfg(&pscch_chest, pscch_chest_sl_cfg); - srslte_chest_sl_ls_estimate_equalize(&pscch_chest, sf_buffer, equalized_sf_buffer); + srsran_chest_sl_set_cfg(&pscch_chest, pscch_chest_sl_cfg); + srsran_chest_sl_ls_estimate_equalize(&pscch_chest, sf_buffer, equalized_sf_buffer); - if (srslte_pscch_decode(&pscch, equalized_sf_buffer, sci_rx, pscch_prb_start_idx) == SRSLTE_SUCCESS) { - if (srslte_sci_format1_unpack(&sci, sci_rx) == SRSLTE_SUCCESS) { - srslte_sci_info(&sci, sci_msg, sizeof(sci_msg)); + if (srsran_pscch_decode(&pscch, equalized_sf_buffer, sci_rx, pscch_prb_start_idx) == SRSRAN_SUCCESS) { + if (srsran_sci_format1_unpack(&sci, sci_rx) == SRSRAN_SUCCESS) { + srsran_sci_info(&sci, sci_msg, sizeof(sci_msg)); fprintf(stdout, "%s", sci_msg); num_decoded_sci++; @@ -352,7 +352,7 @@ int main(int argc, char** argv) // Decode PSSCH uint32_t sub_channel_start_idx = 0; uint32_t L_subCH = 0; - srslte_ra_sl_type0_from_riv( + srsran_ra_sl_type0_from_riv( sci.riv, sl_comm_resource_pool.num_sub_channel, &L_subCH, &sub_channel_start_idx); // 3GPP TS 36.213 Section 14.1.1.4C @@ -362,11 +362,11 @@ int main(int argc, char** argv) pssch_prb_start_idx + sl_comm_resource_pool.start_prb_sub_channel; // make sure PRBs are valid for DFT precoding - nof_prb_pssch = srslte_dft_precoding_get_valid_prb(nof_prb_pssch); + nof_prb_pssch = srsran_dft_precoding_get_valid_prb(nof_prb_pssch); uint32_t N_x_id = 0; - for (int j = 0; j < SRSLTE_SCI_CRC_LEN; j++) { - N_x_id += pscch.sci_crc[j] * (1 << (SRSLTE_SCI_CRC_LEN - 1 - j)); + for (int j = 0; j < SRSRAN_SCI_CRC_LEN; j++) { + N_x_id += pscch.sci_crc[j] * (1 << (SRSRAN_SCI_CRC_LEN - 1 - j)); } uint32_t rv_idx = 0; @@ -379,30 +379,30 @@ int main(int argc, char** argv) pssch_chest_sl_cfg.sf_idx = current_sf_idx; pssch_chest_sl_cfg.prb_start_idx = pssch_prb_start_idx; pssch_chest_sl_cfg.nof_prb = nof_prb_pssch; - srslte_chest_sl_set_cfg(&pssch_chest, pssch_chest_sl_cfg); - srslte_chest_sl_ls_estimate_equalize(&pssch_chest, sf_buffer, equalized_sf_buffer); + srsran_chest_sl_set_cfg(&pssch_chest, pssch_chest_sl_cfg); + srsran_chest_sl_ls_estimate_equalize(&pssch_chest, sf_buffer, equalized_sf_buffer); - srslte_pssch_cfg_t pssch_cfg = { + srsran_pssch_cfg_t pssch_cfg = { pssch_prb_start_idx, nof_prb_pssch, N_x_id, sci.mcs_idx, rv_idx, current_sf_idx}; - if (srslte_pssch_set_cfg(&pssch, pssch_cfg) == SRSLTE_SUCCESS) { - if (srslte_pssch_decode(&pssch, equalized_sf_buffer, tb, SRSLTE_SL_SCH_MAX_TB_LEN) == SRSLTE_SUCCESS) { - srslte_vec_fprint_byte(stdout, tb, pssch.sl_sch_tb_len); + if (srsran_pssch_set_cfg(&pssch, pssch_cfg) == SRSRAN_SUCCESS) { + if (srsran_pssch_decode(&pssch, equalized_sf_buffer, tb, SRSRAN_SL_SCH_MAX_TB_LEN) == SRSRAN_SUCCESS) { + srsran_vec_fprint_byte(stdout, tb, pssch.sl_sch_tb_len); num_decoded_tb++; } - if (SRSLTE_VERBOSE_ISDEBUG()) { + if (SRSRAN_VERBOSE_ISDEBUG()) { char filename[64]; snprintf(filename, 64, "pssch_rx_syms_sf%d.bin", num_subframes); printf("Saving PSSCH symbols (%d) to %s (current_sf_idx=%d)\n", pssch.G / pssch.Qm, filename, current_sf_idx); - srslte_vec_save_file(filename, pssch.symbols, pssch.G / pssch.Qm * sizeof(cf_t)); + srsran_vec_save_file(filename, pssch.symbols, pssch.G / pssch.Qm * sizeof(cf_t)); } } } } - if (SRSLTE_VERBOSE_ISDEBUG()) { + if (SRSRAN_VERBOSE_ISDEBUG()) { char filename[64]; snprintf(filename, 64, @@ -410,8 +410,8 @@ int main(int argc, char** argv) num_subframes, cyclic_shift, pscch_prb_start_idx); - printf("Saving PSCCH symbols (%d) to %s\n", pscch.E / SRSLTE_PSCCH_QM, filename); - srslte_vec_save_file(filename, pscch.mod_symbols, pscch.E / SRSLTE_PSCCH_QM * sizeof(cf_t)); + printf("Saving PSCCH symbols (%d) to %s\n", pscch.E / SRSRAN_PSCCH_QM, filename); + srsran_vec_save_file(filename, pscch.mod_symbols, pscch.E / SRSRAN_PSCCH_QM * sizeof(cf_t)); } } } @@ -427,7 +427,7 @@ clean_exit: printf("num_decoded_sci=%d num_decoded_tb=%d\n", num_decoded_sci, num_decoded_tb); - ret = (num_decoded_sci > 0) ? SRSLTE_SUCCESS : SRSLTE_ERROR; + ret = (num_decoded_sci > 0) ? SRSRAN_SUCCESS : SRSRAN_ERROR; return ret; } \ No newline at end of file diff --git a/lib/src/phy/phch/test/pssch_test.c b/lib/src/phy/phch/test/pssch_test.c index 03ad9105e..0d5cf35a9 100644 --- a/lib/src/phy/phch/test/pssch_test.c +++ b/lib/src/phy/phch/test/pssch_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -14,16 +14,16 @@ #include #include -#include "srslte/phy/phch/pssch.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/random.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/phch/pssch.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/random.h" +#include "srsran/phy/utils/vector.h" -srslte_cell_sl_t cell = {.nof_prb = 6, .N_sl_id = 0, .tm = SRSLTE_SIDELINK_TM2, .cp = SRSLTE_CP_NORM}; +srsran_cell_sl_t cell = {.nof_prb = 6, .N_sl_id = 0, .tm = SRSRAN_SIDELINK_TM2, .cp = SRSRAN_CP_NORM}; static uint32_t mcs_idx = 4; static uint32_t prb_start_idx = 0; -static srslte_random_t random_gen = NULL; +static srsran_random_t random_gen = NULL; void usage(char* prog) { @@ -32,7 +32,7 @@ void usage(char* prog) printf("\t-m mcs_idx [Default %d]\n", mcs_idx); printf("\t-e extended CP [Default normal]\n"); printf("\t-t Sidelink transmission mode {1,2,3,4} [Default %d]\n", (cell.tm + 1)); - printf("\t-v [set srslte_verbose to debug, default none]\n"); + printf("\t-v [set srsran_verbose to debug, default none]\n"); } void parse_args(int argc, char** argv) @@ -41,7 +41,7 @@ void parse_args(int argc, char** argv) while ((opt = getopt(argc, argv, "emptv")) != -1) { switch (opt) { case 'e': - cell.cp = SRSLTE_CP_EXT; + cell.cp = SRSRAN_CP_EXT; break; case 'm': mcs_idx = (uint32_t)strtol(argv[optind], NULL, 10); @@ -50,20 +50,20 @@ void parse_args(int argc, char** argv) cell.nof_prb = (uint32_t)strtol(argv[optind], NULL, 10); break; case 't': - if (srslte_sl_tm_to_cell_sl_tm_t(&cell, strtol(argv[optind], NULL, 10)) != SRSLTE_SUCCESS) { + if (srsran_sl_tm_to_cell_sl_tm_t(&cell, strtol(argv[optind], NULL, 10)) != SRSRAN_SUCCESS) { usage(argv[0]); exit(-1); } break; case 'v': - srslte_verbose++; + srsran_verbose++; break; default: usage(argv[0]); exit(-1); } } - if (SRSLTE_CP_ISEXT(cell.cp) && cell.tm >= SRSLTE_SIDELINK_TM3) { + if (SRSRAN_CP_ISEXT(cell.cp) && cell.tm >= SRSRAN_SIDELINK_TM3) { ERROR("Selected TM does not support extended CP"); usage(argv[0]); exit(-1); @@ -72,40 +72,40 @@ void parse_args(int argc, char** argv) int main(int argc, char** argv) { - uint32_t ret = SRSLTE_ERROR; + uint32_t ret = SRSRAN_ERROR; parse_args(argc, argv); - srslte_sl_comm_resource_pool_t sl_comm_resource_pool; - if (srslte_sl_comm_resource_pool_get_default_config(&sl_comm_resource_pool, cell) != SRSLTE_SUCCESS) { + srsran_sl_comm_resource_pool_t sl_comm_resource_pool; + if (srsran_sl_comm_resource_pool_get_default_config(&sl_comm_resource_pool, cell) != SRSRAN_SUCCESS) { ERROR("Error initializing sl_comm_resource_pool"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - srslte_pssch_t pssch = {}; - if (srslte_pssch_init(&pssch, cell, sl_comm_resource_pool) != SRSLTE_SUCCESS) { + srsran_pssch_t pssch = {}; + if (srsran_pssch_init(&pssch, cell, sl_comm_resource_pool) != SRSRAN_SUCCESS) { ERROR("Error initializing PSSCH"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - uint32_t nof_prb_pssch = srslte_dft_precoding_get_valid_prb(cell.nof_prb); + uint32_t nof_prb_pssch = srsran_dft_precoding_get_valid_prb(cell.nof_prb); uint32_t N_x_id = 255; - uint32_t sf_n_re = SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp); - cf_t* sf_buffer = srslte_vec_cf_malloc(sf_n_re); + uint32_t sf_n_re = SRSRAN_SF_LEN_RE(cell.nof_prb, cell.cp); + cf_t* sf_buffer = srsran_vec_cf_malloc(sf_n_re); if (!sf_buffer) { ERROR("Error allocating memory"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - srslte_vec_cf_zero(sf_buffer, sf_n_re); + srsran_vec_cf_zero(sf_buffer, sf_n_re); // Transport block buffer - uint8_t tb[SRSLTE_SL_SCH_MAX_TB_LEN] = {}; + uint8_t tb[SRSRAN_SL_SCH_MAX_TB_LEN] = {}; // Rx transport block buffer - uint8_t tb_rx[SRSLTE_SL_SCH_MAX_TB_LEN] = {}; + uint8_t tb_rx[SRSRAN_SL_SCH_MAX_TB_LEN] = {}; - srslte_pssch_cfg_t pssch_cfg = {prb_start_idx, nof_prb_pssch, N_x_id, mcs_idx, 0, 0}; - if (srslte_pssch_set_cfg(&pssch, pssch_cfg) != SRSLTE_SUCCESS) { + srsran_pssch_cfg_t pssch_cfg = {prb_start_idx, nof_prb_pssch, N_x_id, mcs_idx, 0, 0}; + if (srsran_pssch_set_cfg(&pssch, pssch_cfg) != SRSRAN_SUCCESS) { ERROR("Error configuring PSSCH"); goto clean_exit; } @@ -113,38 +113,38 @@ int main(int argc, char** argv) // Randomize data to fill the transport block struct timeval tv; gettimeofday(&tv, NULL); - random_gen = srslte_random_init(tv.tv_usec); + random_gen = srsran_random_init(tv.tv_usec); for (int i = 0; i < pssch.sl_sch_tb_len; i++) { - tb[i] = srslte_random_uniform_int_dist(random_gen, 0, 1); + tb[i] = srsran_random_uniform_int_dist(random_gen, 0, 1); } // PSSCH encoding - if (srslte_pssch_encode(&pssch, tb, pssch.sl_sch_tb_len, sf_buffer) != SRSLTE_SUCCESS) { + if (srsran_pssch_encode(&pssch, tb, pssch.sl_sch_tb_len, sf_buffer) != SRSRAN_SUCCESS) { ERROR("Error encoding PSSCH"); goto clean_exit; } // PSSCH decoding - if (srslte_pssch_decode(&pssch, sf_buffer, tb_rx, pssch.sl_sch_tb_len) != SRSLTE_SUCCESS) { + if (srsran_pssch_decode(&pssch, sf_buffer, tb_rx, pssch.sl_sch_tb_len) != SRSRAN_SUCCESS) { ERROR("Error decoding PSSCH"); goto clean_exit; } if (memcmp(tb_rx, tb, pssch.sl_sch_tb_len) == 0) { - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } else { - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } clean_exit: if (random_gen) { - srslte_random_free(random_gen); + srsran_random_free(random_gen); } if (sf_buffer) { free(sf_buffer); } - srslte_pssch_free(&pssch); + srsran_pssch_free(&pssch); - printf("%s", ret == SRSLTE_SUCCESS ? "SUCCESS\n" : "FAILED\n"); + printf("%s", ret == SRSRAN_SUCCESS ? "SUCCESS\n" : "FAILED\n"); return ret; } \ No newline at end of file diff --git a/lib/src/phy/phch/test/pucch_nr_test.c b/lib/src/phy/phch/test/pucch_nr_test.c index bbabd4712..a50f280a7 100644 --- a/lib/src/phy/phch/test/pucch_nr_test.c +++ b/lib/src/phy/phch/test/pucch_nr_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,19 +10,19 @@ * */ -#include "srslte/common/test_common.h" -#include "srslte/phy/ch_estimation/dmrs_pucch.h" -#include "srslte/phy/channel/ch_awgn.h" -#include "srslte/phy/phch/pucch_nr.h" -#include "srslte/phy/phch/ra_ul_nr.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/random.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/common/test_common.h" +#include "srsran/phy/ch_estimation/dmrs_pucch.h" +#include "srsran/phy/channel/ch_awgn.h" +#include "srsran/phy/phch/pucch_nr.h" +#include "srsran/phy/phch/ra_ul_nr.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/random.h" +#include "srsran/phy/utils/vector.h" #include #include #include -static srslte_carrier_nr_t carrier = { +static srsran_carrier_nr_t carrier = { 0, // cell_id 0, // numerology 6, // nof_prb @@ -32,35 +32,35 @@ static srslte_carrier_nr_t carrier = { static uint32_t starting_prb_stride = 4; static uint32_t starting_symbol_stride = 4; -static srslte_random_t random_gen = NULL; +static srsran_random_t random_gen = NULL; static int format = -1; static float snr_db = 20.0f; -static srslte_channel_awgn_t awgn = {}; +static srsran_channel_awgn_t awgn = {}; -static int test_pucch_format0(srslte_pucch_nr_t* pucch, const srslte_pucch_nr_common_cfg_t* cfg, cf_t* slot_symbols) +static int test_pucch_format0(srsran_pucch_nr_t* pucch, const srsran_pucch_nr_common_cfg_t* cfg, cf_t* slot_symbols) { - srslte_slot_cfg_t slot = {}; - srslte_pucch_nr_resource_t resource = {}; - resource.format = SRSLTE_PUCCH_NR_FORMAT_0; + srsran_slot_cfg_t slot = {}; + srsran_pucch_nr_resource_t resource = {}; + resource.format = SRSRAN_PUCCH_NR_FORMAT_0; - for (slot.idx = 0; slot.idx < SRSLTE_NSLOTS_PER_FRAME_NR(carrier.numerology); slot.idx++) { + for (slot.idx = 0; slot.idx < SRSRAN_NSLOTS_PER_FRAME_NR(carrier.numerology); slot.idx++) { for (resource.starting_prb = 0; resource.starting_prb < carrier.nof_prb; resource.starting_prb += starting_prb_stride) { for (resource.nof_symbols = 1; resource.nof_symbols <= 2; resource.nof_symbols++) { for (resource.start_symbol_idx = 0; - resource.start_symbol_idx <= SRSLTE_NSYMB_PER_SLOT_NR - resource.nof_symbols; + resource.start_symbol_idx <= SRSRAN_NSYMB_PER_SLOT_NR - resource.nof_symbols; resource.start_symbol_idx += starting_symbol_stride) { for (resource.initial_cyclic_shift = 0; resource.initial_cyclic_shift <= 11; resource.initial_cyclic_shift++) { for (uint32_t m_cs = 0; m_cs <= 6; m_cs += 2) { - TESTASSERT(srslte_pucch_nr_format0_encode(pucch, cfg, &slot, &resource, m_cs, slot_symbols) == - SRSLTE_SUCCESS); + TESTASSERT(srsran_pucch_nr_format0_encode(pucch, cfg, &slot, &resource, m_cs, slot_symbols) == + SRSRAN_SUCCESS); // Measure PUCCH format 0 for all possible values of m_cs for (uint32_t m_cs_test = 0; m_cs_test <= 6; m_cs_test += 2) { - srslte_pucch_nr_measure_t measure = {}; - TESTASSERT(srslte_pucch_nr_format0_measure( - pucch, cfg, &slot, &resource, m_cs_test, slot_symbols, &measure) == SRSLTE_SUCCESS); + srsran_pucch_nr_measure_t measure = {}; + TESTASSERT(srsran_pucch_nr_format0_measure( + pucch, cfg, &slot, &resource, m_cs_test, slot_symbols, &measure) == SRSRAN_SUCCESS); if (m_cs == m_cs_test) { TESTASSERT(fabsf(measure.epre - 1) < 0.001); @@ -79,65 +79,65 @@ static int test_pucch_format0(srslte_pucch_nr_t* pucch, const srslte_pucch_nr_co } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -static int test_pucch_format1(srslte_pucch_nr_t* pucch, - const srslte_pucch_nr_common_cfg_t* cfg, - srslte_chest_ul_res_t* chest_res, +static int test_pucch_format1(srsran_pucch_nr_t* pucch, + const srsran_pucch_nr_common_cfg_t* cfg, + srsran_chest_ul_res_t* chest_res, cf_t* slot_symbols) { - srslte_slot_cfg_t slot = {}; - srslte_pucch_nr_resource_t resource = {}; - resource.format = SRSLTE_PUCCH_NR_FORMAT_1; + srsran_slot_cfg_t slot = {}; + srsran_pucch_nr_resource_t resource = {}; + resource.format = SRSRAN_PUCCH_NR_FORMAT_1; - for (slot.idx = 0; slot.idx < SRSLTE_NSLOTS_PER_FRAME_NR(carrier.numerology); slot.idx++) { + for (slot.idx = 0; slot.idx < SRSRAN_NSLOTS_PER_FRAME_NR(carrier.numerology); slot.idx++) { for (resource.starting_prb = 0; resource.starting_prb < carrier.nof_prb; resource.starting_prb += starting_prb_stride) { - for (resource.nof_symbols = SRSLTE_PUCCH_NR_FORMAT1_MIN_NSYMB; - resource.nof_symbols <= SRSLTE_PUCCH_NR_FORMAT1_MAX_NSYMB; + for (resource.nof_symbols = SRSRAN_PUCCH_NR_FORMAT1_MIN_NSYMB; + resource.nof_symbols <= SRSRAN_PUCCH_NR_FORMAT1_MAX_NSYMB; resource.nof_symbols++) { for (resource.start_symbol_idx = 0; resource.start_symbol_idx <= - SRSLTE_MIN(SRSLTE_PUCCH_NR_FORMAT1_MAX_STARTSYMB, SRSLTE_NSYMB_PER_SLOT_NR - resource.nof_symbols); + SRSRAN_MIN(SRSRAN_PUCCH_NR_FORMAT1_MAX_STARTSYMB, SRSRAN_NSYMB_PER_SLOT_NR - resource.nof_symbols); resource.start_symbol_idx += starting_symbol_stride) { - for (resource.time_domain_occ = 0; resource.time_domain_occ <= SRSLTE_PUCCH_NR_FORMAT1_MAX_TOCC; + for (resource.time_domain_occ = 0; resource.time_domain_occ <= SRSRAN_PUCCH_NR_FORMAT1_MAX_TOCC; resource.time_domain_occ++) { - for (resource.initial_cyclic_shift = 0; resource.initial_cyclic_shift <= SRSLTE_PUCCH_NR_FORMAT1_MAX_CS; + for (resource.initial_cyclic_shift = 0; resource.initial_cyclic_shift <= SRSRAN_PUCCH_NR_FORMAT1_MAX_CS; resource.initial_cyclic_shift++) { - for (uint32_t nof_bits = 1; nof_bits <= SRSLTE_PUCCH_NR_FORMAT1_MAX_NOF_BITS; nof_bits++) { + for (uint32_t nof_bits = 1; nof_bits <= SRSRAN_PUCCH_NR_FORMAT1_MAX_NOF_BITS; nof_bits++) { for (uint32_t word = 0; word < (1U << nof_bits); word++) { // Generate bits - uint8_t b[SRSLTE_PUCCH_NR_FORMAT1_MAX_NOF_BITS] = {}; + uint8_t b[SRSRAN_PUCCH_NR_FORMAT1_MAX_NOF_BITS] = {}; for (uint32_t i = 0; i < nof_bits; i++) { b[i] = (word >> i) & 1U; } // Encode PUCCH - TESTASSERT(srslte_pucch_nr_format1_encode(pucch, cfg, &slot, &resource, b, nof_bits, slot_symbols) == - SRSLTE_SUCCESS); + TESTASSERT(srsran_pucch_nr_format1_encode(pucch, cfg, &slot, &resource, b, nof_bits, slot_symbols) == + SRSRAN_SUCCESS); // Put DMRS - TESTASSERT(srslte_dmrs_pucch_format1_put(pucch, &carrier, cfg, &slot, &resource, slot_symbols) == - SRSLTE_SUCCESS); + TESTASSERT(srsran_dmrs_pucch_format1_put(pucch, &carrier, cfg, &slot, &resource, slot_symbols) == + SRSRAN_SUCCESS); // Apply AWGN - srslte_channel_awgn_run_c( - &awgn, slot_symbols, slot_symbols, carrier.nof_prb * SRSLTE_NRE * SRSLTE_NSYMB_PER_SLOT_NR); + srsran_channel_awgn_run_c( + &awgn, slot_symbols, slot_symbols, carrier.nof_prb * SRSRAN_NRE * SRSRAN_NSYMB_PER_SLOT_NR); // Estimate channel - TESTASSERT(srslte_dmrs_pucch_format1_estimate( - pucch, &carrier, cfg, &slot, &resource, slot_symbols, chest_res) == SRSLTE_SUCCESS); + TESTASSERT(srsran_dmrs_pucch_format1_estimate( + pucch, &carrier, cfg, &slot, &resource, slot_symbols, chest_res) == SRSRAN_SUCCESS); TESTASSERT(fabsf(chest_res->rsrp_dBfs - 0.0f) < 3.0f); TESTASSERT(fabsf(chest_res->epre_dBfs - 0.0f) < 3.0f); TESTASSERT(fabsf(chest_res->snr_db - snr_db) < 10.0f); // Decode PUCCH - uint8_t b_rx[SRSLTE_PUCCH_NR_FORMAT1_MAX_NOF_BITS]; - TESTASSERT(srslte_pucch_nr_format1_decode( + uint8_t b_rx[SRSRAN_PUCCH_NR_FORMAT1_MAX_NOF_BITS]; + TESTASSERT(srsran_pucch_nr_format1_decode( pucch, cfg, &slot, &resource, chest_res, slot_symbols, b_rx, nof_bits) == - SRSLTE_SUCCESS); + SRSRAN_SUCCESS); // Check received bits for (uint32_t i = 0; i < nof_bits; i++) { @@ -152,68 +152,68 @@ static int test_pucch_format1(srslte_pucch_nr_t* pucch, } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -static int test_pucch_format2(srslte_pucch_nr_t* pucch, - const srslte_pucch_nr_common_cfg_t* cfg, - srslte_chest_ul_res_t* chest_res, +static int test_pucch_format2(srsran_pucch_nr_t* pucch, + const srsran_pucch_nr_common_cfg_t* cfg, + srsran_chest_ul_res_t* chest_res, cf_t* slot_symbols) { - srslte_slot_cfg_t slot = {}; - srslte_pucch_nr_resource_t resource = {}; - resource.format = SRSLTE_PUCCH_NR_FORMAT_2; + srsran_slot_cfg_t slot = {}; + srsran_pucch_nr_resource_t resource = {}; + resource.format = SRSRAN_PUCCH_NR_FORMAT_2; - for (slot.idx = 0; slot.idx < SRSLTE_NSLOTS_PER_FRAME_NR(carrier.numerology); slot.idx++) { - for (resource.nof_symbols = SRSLTE_PUCCH_NR_FORMAT2_MIN_NSYMB; - resource.nof_symbols <= SRSLTE_PUCCH_NR_FORMAT2_MAX_NSYMB; + for (slot.idx = 0; slot.idx < SRSRAN_NSLOTS_PER_FRAME_NR(carrier.numerology); slot.idx++) { + for (resource.nof_symbols = SRSRAN_PUCCH_NR_FORMAT2_MIN_NSYMB; + resource.nof_symbols <= SRSRAN_PUCCH_NR_FORMAT2_MAX_NSYMB; resource.nof_symbols++) { for (resource.start_symbol_idx = 0; resource.start_symbol_idx <= - SRSLTE_MIN(SRSLTE_PUCCH_NR_FORMAT2_MAX_STARTSYMB, SRSLTE_NSYMB_PER_SLOT_NR - resource.nof_symbols); + SRSRAN_MIN(SRSRAN_PUCCH_NR_FORMAT2_MAX_STARTSYMB, SRSRAN_NSYMB_PER_SLOT_NR - resource.nof_symbols); resource.start_symbol_idx += starting_symbol_stride) { - srslte_uci_cfg_nr_t uci_cfg = {}; + srsran_uci_cfg_nr_t uci_cfg = {}; - for (uci_cfg.o_ack = SRSLTE_PUCCH_NR_FORMAT2_MIN_NOF_BITS; uci_cfg.o_ack <= SRSLTE_UCI_NR_MAX_ACK_BITS; + for (uci_cfg.o_ack = SRSRAN_PUCCH_NR_FORMAT2_MIN_NOF_BITS; uci_cfg.o_ack <= SRSRAN_UCI_NR_MAX_ACK_BITS; uci_cfg.o_ack++) { - srslte_uci_value_nr_t uci_value = {}; + srsran_uci_value_nr_t uci_value = {}; // Maximum code rate is reserved - uint32_t max_code_rate_end = SRSLTE_PUCCH_NR_MAX_CODE_RATE; + uint32_t max_code_rate_end = SRSRAN_PUCCH_NR_MAX_CODE_RATE; if (uci_cfg.o_ack == 11) { - max_code_rate_end = SRSLTE_PUCCH_NR_MAX_CODE_RATE - 1; + max_code_rate_end = SRSRAN_PUCCH_NR_MAX_CODE_RATE - 1; } for (resource.max_code_rate = 0; resource.max_code_rate < max_code_rate_end; resource.max_code_rate++) { // Skip case if not enough PRB are used - int min_nof_prb = srslte_ra_ul_nr_pucch_format_2_3_min_prb(&resource, &uci_cfg); - TESTASSERT(min_nof_prb > SRSLTE_SUCCESS); + int min_nof_prb = srsran_ra_ul_nr_pucch_format_2_3_min_prb(&resource, &uci_cfg); + TESTASSERT(min_nof_prb > SRSRAN_SUCCESS); for (resource.nof_prb = min_nof_prb; - resource.nof_prb < SRSLTE_MIN(carrier.nof_prb, SRSLTE_PUCCH_NR_FORMAT2_MAX_NPRB); + resource.nof_prb < SRSRAN_MIN(carrier.nof_prb, SRSRAN_PUCCH_NR_FORMAT2_MAX_NPRB); resource.nof_prb++) { for (resource.starting_prb = 0; resource.starting_prb < (carrier.nof_prb - resource.nof_prb); resource.starting_prb += starting_prb_stride) { // Generate ACKs for (uint32_t i = 0; i < uci_cfg.o_ack; i++) { - uci_value.ack[i] = (uint8_t)srslte_random_uniform_int_dist(random_gen, 0, 1); + uci_value.ack[i] = (uint8_t)srsran_random_uniform_int_dist(random_gen, 0, 1); } // Encode PUCCH - TESTASSERT(srslte_pucch_nr_format_2_3_4_encode( - pucch, cfg, &slot, &resource, &uci_cfg, &uci_value, slot_symbols) == SRSLTE_SUCCESS); + TESTASSERT(srsran_pucch_nr_format_2_3_4_encode( + pucch, cfg, &slot, &resource, &uci_cfg, &uci_value, slot_symbols) == SRSRAN_SUCCESS); // Put DMRS - TESTASSERT(srslte_dmrs_pucch_format2_put(pucch, &carrier, cfg, &slot, &resource, slot_symbols) == - SRSLTE_SUCCESS); + TESTASSERT(srsran_dmrs_pucch_format2_put(pucch, &carrier, cfg, &slot, &resource, slot_symbols) == + SRSRAN_SUCCESS); // Apply AWGN - srslte_channel_awgn_run_c( - &awgn, slot_symbols, slot_symbols, carrier.nof_prb * SRSLTE_NRE * SRSLTE_NSYMB_PER_SLOT_NR); + srsran_channel_awgn_run_c( + &awgn, slot_symbols, slot_symbols, carrier.nof_prb * SRSRAN_NRE * SRSRAN_NSYMB_PER_SLOT_NR); // Estimate channel - TESTASSERT(srslte_dmrs_pucch_format2_estimate( - pucch, &carrier, cfg, &slot, &resource, slot_symbols, chest_res) == SRSLTE_SUCCESS); + TESTASSERT(srsran_dmrs_pucch_format2_estimate( + pucch, &carrier, cfg, &slot, &resource, slot_symbols, chest_res) == SRSRAN_SUCCESS); INFO("RSRP=%+.2f; EPRE=%+.2f; SNR=%+.2f;", chest_res->rsrp_dBfs, chest_res->epre_dBfs, @@ -223,10 +223,10 @@ static int test_pucch_format2(srslte_pucch_nr_t* pucch, TESTASSERT(fabsf(chest_res->snr_db - snr_db) < 20.0f); // Decode PUCCH - srslte_uci_value_nr_t uci_value_rx = {}; - TESTASSERT(srslte_pucch_nr_format_2_3_4_decode( + srsran_uci_value_nr_t uci_value_rx = {}; + TESTASSERT(srsran_pucch_nr_format_2_3_4_decode( pucch, cfg, &slot, &resource, &uci_cfg, chest_res, slot_symbols, &uci_value_rx) == - SRSLTE_SUCCESS); + SRSRAN_SUCCESS); TESTASSERT(uci_value_rx.valid == true); @@ -241,7 +241,7 @@ static int test_pucch_format2(srslte_pucch_nr_t* pucch, } } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } static void usage(char* prog) @@ -272,7 +272,7 @@ static void parse_args(int argc, char** argv) snr_db = strtof(argv[optind], NULL); break; case 'v': - srslte_verbose++; + srsran_verbose++; break; default: usage(argv[0]); @@ -283,15 +283,15 @@ static void parse_args(int argc, char** argv) int main(int argc, char** argv) { - int ret = SRSLTE_ERROR; + int ret = SRSRAN_ERROR; parse_args(argc, argv); - uint32_t nof_re = carrier.nof_prb * SRSLTE_NRE * SRSLTE_NSYMB_PER_SLOT_NR; - cf_t* slot_symb = srslte_vec_cf_malloc(nof_re); - srslte_pucch_nr_t pucch = {}; - srslte_chest_ul_res_t chest_res = {}; + uint32_t nof_re = carrier.nof_prb * SRSRAN_NRE * SRSRAN_NSYMB_PER_SLOT_NR; + cf_t* slot_symb = srsran_vec_cf_malloc(nof_re); + srsran_pucch_nr_t pucch = {}; + srsran_chest_ul_res_t chest_res = {}; - random_gen = srslte_random_init(0x1234); + random_gen = srsran_random_init(0x1234); if (random_gen == NULL) { ERROR("Random init"); goto clean_exit; @@ -302,37 +302,37 @@ int main(int argc, char** argv) goto clean_exit; } - srslte_pucch_nr_args_t pucch_args = {}; - if (srslte_pucch_nr_init(&pucch, &pucch_args) < SRSLTE_SUCCESS) { + srsran_pucch_nr_args_t pucch_args = {}; + if (srsran_pucch_nr_init(&pucch, &pucch_args) < SRSRAN_SUCCESS) { ERROR("PUCCH init"); goto clean_exit; } - if (srslte_pucch_nr_set_carrier(&pucch, &carrier) < SRSLTE_SUCCESS) { + if (srsran_pucch_nr_set_carrier(&pucch, &carrier) < SRSRAN_SUCCESS) { ERROR("PUCCH set carrier"); goto clean_exit; } - if (srslte_chest_ul_res_init(&chest_res, carrier.nof_prb)) { + if (srsran_chest_ul_res_init(&chest_res, carrier.nof_prb)) { ERROR("Chest UL"); goto clean_exit; } - if (srslte_channel_awgn_init(&awgn, 1234) < SRSLTE_SUCCESS) { + if (srsran_channel_awgn_init(&awgn, 1234) < SRSRAN_SUCCESS) { ERROR("AWGN init"); goto clean_exit; } - if (srslte_channel_awgn_set_n0(&awgn, -snr_db) < SRSLTE_SUCCESS) { + if (srsran_channel_awgn_set_n0(&awgn, -snr_db) < SRSRAN_SUCCESS) { ERROR("AWGN set N0"); goto clean_exit; } - srslte_pucch_nr_common_cfg_t common_cfg = {}; + srsran_pucch_nr_common_cfg_t common_cfg = {}; // Test Format 0 if (format < 0 || format == 0) { - if (test_pucch_format0(&pucch, &common_cfg, slot_symb) < SRSLTE_SUCCESS) { + if (test_pucch_format0(&pucch, &common_cfg, slot_symb) < SRSRAN_SUCCESS) { ERROR("Failed PUCCH format 0"); goto clean_exit; } @@ -340,7 +340,7 @@ int main(int argc, char** argv) // Test Format 1 if (format < 0 || format == 1) { - if (test_pucch_format1(&pucch, &common_cfg, &chest_res, slot_symb) < SRSLTE_SUCCESS) { + if (test_pucch_format1(&pucch, &common_cfg, &chest_res, slot_symb) < SRSRAN_SUCCESS) { ERROR("Failed PUCCH format 1"); goto clean_exit; } @@ -348,24 +348,24 @@ int main(int argc, char** argv) // Test Format 2 if (format < 0 || format == 2) { - if (test_pucch_format2(&pucch, &common_cfg, &chest_res, slot_symb) < SRSLTE_SUCCESS) { + if (test_pucch_format2(&pucch, &common_cfg, &chest_res, slot_symb) < SRSRAN_SUCCESS) { ERROR("Failed PUCCH format 2"); goto clean_exit; } } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; clean_exit: if (slot_symb) { free(slot_symb); } - srslte_pucch_nr_free(&pucch); - srslte_chest_ul_res_free(&chest_res); - srslte_channel_awgn_free(&awgn); - srslte_random_free(random_gen); + srsran_pucch_nr_free(&pucch); + srsran_chest_ul_res_free(&chest_res); + srsran_channel_awgn_free(&awgn); + srsran_random_free(random_gen); - if (ret == SRSLTE_SUCCESS) { + if (ret == SRSRAN_SUCCESS) { printf("Test passed!\n"); } else { printf("Test failed!\n"); diff --git a/lib/src/phy/phch/test/pucch_test.c b/lib/src/phy/phch/test/pucch_test.c index a29bf0fec..ca8f98d26 100644 --- a/lib/src/phy/phch/test/pucch_test.c +++ b/lib/src/phy/phch/test/pucch_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -17,16 +17,16 @@ #include #include -#include "srslte/srslte.h" +#include "srsran/srsran.h" -static srslte_cell_t cell = { +static srsran_cell_t cell = { 25, // nof_prb 1, // nof_ports 1, // cell_id - SRSLTE_CP_NORM, // cyclic prefix - SRSLTE_PHICH_NORM, // PHICH length - SRSLTE_PHICH_R_1_6, // PHICH resources - SRSLTE_FDD, + SRSRAN_CP_NORM, // cyclic prefix + SRSRAN_PHICH_NORM, // PHICH length + SRSRAN_PHICH_R_1_6, // PHICH resources + SRSRAN_FDD, }; @@ -66,7 +66,7 @@ void parse_args(int argc, char** argv) snr_db = strtof(argv[optind], NULL); break; case 'v': - srslte_verbose++; + srsran_verbose++; break; default: usage(argv[0]); @@ -77,48 +77,48 @@ void parse_args(int argc, char** argv) int test_uci_cqi_pucch(void) { - int ret = SRSLTE_SUCCESS; - __attribute__((aligned(256))) uint8_t o_bits[SRSLTE_UCI_MAX_CQI_LEN_PUCCH] = {0}; - __attribute__((aligned(256))) uint8_t e_bits[SRSLTE_UCI_CQI_CODED_PUCCH_B] = {0}; - __attribute__((aligned(256))) int16_t e_symb[SRSLTE_UCI_CQI_CODED_PUCCH_B] = {0}; - __attribute__((aligned(256))) uint8_t d_bits[SRSLTE_UCI_MAX_CQI_LEN_PUCCH] = {0}; + int ret = SRSRAN_SUCCESS; + __attribute__((aligned(256))) uint8_t o_bits[SRSRAN_UCI_MAX_CQI_LEN_PUCCH] = {0}; + __attribute__((aligned(256))) uint8_t e_bits[SRSRAN_UCI_CQI_CODED_PUCCH_B] = {0}; + __attribute__((aligned(256))) int16_t e_symb[SRSRAN_UCI_CQI_CODED_PUCCH_B] = {0}; + __attribute__((aligned(256))) uint8_t d_bits[SRSRAN_UCI_MAX_CQI_LEN_PUCCH] = {0}; - srslte_uci_cqi_pucch_t uci_cqi_pucch = {0}; + srsran_uci_cqi_pucch_t uci_cqi_pucch = {0}; - srslte_uci_cqi_pucch_init(&uci_cqi_pucch); + srsran_uci_cqi_pucch_init(&uci_cqi_pucch); - for (uint32_t nof_bits = 1; nof_bits <= SRSLTE_UCI_MAX_CQI_LEN_PUCCH - 1; nof_bits++) { + for (uint32_t nof_bits = 1; nof_bits <= SRSRAN_UCI_MAX_CQI_LEN_PUCCH - 1; nof_bits++) { for (uint32_t cqi = 0; cqi < (1 << nof_bits); cqi++) { uint32_t recv; uint8_t* ptr = o_bits; - srslte_bit_unpack(cqi, &ptr, nof_bits); + srsran_bit_unpack(cqi, &ptr, nof_bits); - srslte_uci_encode_cqi_pucch(o_bits, nof_bits, e_bits); - // srslte_uci_encode_cqi_pucch_from_table(&uci_cqi_pucch, o_bits, nof_bits, e_bits); - for (int i = 0; i < SRSLTE_UCI_CQI_CODED_PUCCH_B; i++) { + srsran_uci_encode_cqi_pucch(o_bits, nof_bits, e_bits); + // srsran_uci_encode_cqi_pucch_from_table(&uci_cqi_pucch, o_bits, nof_bits, e_bits); + for (int i = 0; i < SRSRAN_UCI_CQI_CODED_PUCCH_B; i++) { e_symb[i] = 2 * e_bits[i] - 1; } - srslte_uci_decode_cqi_pucch(&uci_cqi_pucch, e_symb, d_bits, nof_bits); + srsran_uci_decode_cqi_pucch(&uci_cqi_pucch, e_symb, d_bits, nof_bits); ptr = d_bits; - recv = srslte_bit_pack(&ptr, nof_bits); + recv = srsran_bit_pack(&ptr, nof_bits); if (recv != cqi) { printf("Error! cqi = %d (len: %d), %X!=%X \n", cqi, nof_bits, cqi, recv); - if (srslte_verbose) { + if (srsran_verbose) { printf("original: "); - srslte_vec_fprint_b(stdout, o_bits, nof_bits); + srsran_vec_fprint_b(stdout, o_bits, nof_bits); printf(" decoded: "); - srslte_vec_fprint_b(stdout, d_bits, nof_bits); + srsran_vec_fprint_b(stdout, d_bits, nof_bits); } - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } } } - srslte_uci_cqi_pucch_free(&uci_cqi_pucch); + srsran_uci_cqi_pucch_free(&uci_cqi_pucch); if (ret) { printf("Error\n"); @@ -131,16 +131,16 @@ int test_uci_cqi_pucch(void) int main(int argc, char** argv) { - srslte_pucch_t pucch_ue = {}; - srslte_pucch_t pucch_enb = {}; - srslte_pucch_cfg_t pucch_cfg = {}; - srslte_refsignal_ul_t dmrs = {}; + srsran_pucch_t pucch_ue = {}; + srsran_pucch_t pucch_enb = {}; + srsran_pucch_cfg_t pucch_cfg = {}; + srsran_refsignal_ul_t dmrs = {}; cf_t* sf_symbols = NULL; - cf_t pucch_dmrs[2 * SRSLTE_NRE * 3]; + cf_t pucch_dmrs[2 * SRSRAN_NRE * 3]; int ret = -1; - srslte_chest_ul_t chest = {}; - srslte_chest_ul_res_t chest_res = {}; - srslte_channel_awgn_t awgn = {}; + srsran_chest_ul_t chest = {}; + srsran_chest_ul_res_t chest_res = {}; + srsran_channel_awgn_t awgn = {}; parse_args(argc, argv); @@ -148,61 +148,61 @@ int main(int argc, char** argv) return test_uci_cqi_pucch(); } - if (srslte_pucch_init_ue(&pucch_ue)) { + if (srsran_pucch_init_ue(&pucch_ue)) { ERROR("Error creating PDSCH object"); exit(-1); } - if (srslte_pucch_set_cell(&pucch_ue, cell)) { + if (srsran_pucch_set_cell(&pucch_ue, cell)) { ERROR("Error creating PDSCH object"); exit(-1); } - if (srslte_pucch_init_enb(&pucch_enb)) { + if (srsran_pucch_init_enb(&pucch_enb)) { ERROR("Error creating PDSCH object"); exit(-1); } - if (srslte_pucch_set_cell(&pucch_enb, cell)) { + if (srsran_pucch_set_cell(&pucch_enb, cell)) { ERROR("Error creating PDSCH object"); exit(-1); } - if (srslte_refsignal_ul_set_cell(&dmrs, cell)) { + if (srsran_refsignal_ul_set_cell(&dmrs, cell)) { ERROR("Error creating PDSCH object"); exit(-1); } - if (srslte_chest_ul_init(&chest, cell.nof_prb) < SRSLTE_SUCCESS) { + if (srsran_chest_ul_init(&chest, cell.nof_prb) < SRSRAN_SUCCESS) { ERROR("Error initiating channel estimator"); goto quit; } - if (srslte_chest_ul_res_init(&chest_res, cell.nof_prb) < SRSLTE_SUCCESS) { + if (srsran_chest_ul_res_init(&chest_res, cell.nof_prb) < SRSRAN_SUCCESS) { ERROR("Error initiating channel estimator result"); goto quit; } - if (srslte_chest_ul_set_cell(&chest, cell) < SRSLTE_SUCCESS) { + if (srsran_chest_ul_set_cell(&chest, cell) < SRSRAN_SUCCESS) { ERROR("Error setting channel estimator cell"); goto quit; } - if (srslte_channel_awgn_init(&awgn, 0x1234) < SRSLTE_SUCCESS) { + if (srsran_channel_awgn_init(&awgn, 0x1234) < SRSRAN_SUCCESS) { ERROR("Error initiating AWGN"); goto quit; } - if (srslte_channel_awgn_set_n0(&awgn, -snr_db) < SRSLTE_SUCCESS) { + if (srsran_channel_awgn_set_n0(&awgn, -snr_db) < SRSRAN_SUCCESS) { ERROR("Error setting AWGN"); goto quit; } - sf_symbols = srslte_vec_cf_malloc(SRSLTE_NOF_RE(cell)); + sf_symbols = srsran_vec_cf_malloc(SRSRAN_NOF_RE(cell)); if (!sf_symbols) { goto quit; } - srslte_ul_sf_cfg_t ul_sf; + srsran_ul_sf_cfg_t ul_sf; ZERO_OBJECT(ul_sf); - srslte_pucch_format_t format; - for (format = 0; format < SRSLTE_PUCCH_FORMAT_ERROR; format++) { + srsran_pucch_format_t format; + for (format = 0; format < SRSRAN_PUCCH_FORMAT_ERROR; format++) { for (uint32_t d = 1; d <= 3; d++) { for (uint32_t ncs = 0; ncs < 8; ncs += d) { for (uint32_t n_pucch = 1; n_pucch < 130; n_pucch += 50) { @@ -218,21 +218,21 @@ int main(int argc, char** argv) ul_sf.tti = subframe; - srslte_uci_data_t uci_data; + srsran_uci_data_t uci_data; ZERO_OBJECT(uci_data); switch (format) { - case SRSLTE_PUCCH_FORMAT_1: + case SRSRAN_PUCCH_FORMAT_1: uci_data.value.scheduling_request = true; break; - case SRSLTE_PUCCH_FORMAT_1A: - case SRSLTE_PUCCH_FORMAT_2A: + case SRSRAN_PUCCH_FORMAT_1A: + case SRSRAN_PUCCH_FORMAT_2A: uci_data.value.ack.ack_value[0] = 1; uci_data.cfg.ack[0].nof_acks = 1; break; - case SRSLTE_PUCCH_FORMAT_1B: - case SRSLTE_PUCCH_FORMAT_2B: - case SRSLTE_PUCCH_FORMAT_3: + case SRSRAN_PUCCH_FORMAT_1B: + case SRSRAN_PUCCH_FORMAT_2B: + case SRSRAN_PUCCH_FORMAT_3: uci_data.value.ack.ack_value[0] = 1; uci_data.value.ack.ack_value[1] = 1; uci_data.cfg.ack[0].nof_acks = 2; @@ -240,22 +240,22 @@ int main(int argc, char** argv) default: break; } - if (format >= SRSLTE_PUCCH_FORMAT_2) { + if (format >= SRSRAN_PUCCH_FORMAT_2) { uci_data.cfg.cqi.data_enable = true; } // Encode PUCCH signals gettimeofday(&t[1], NULL); - if (srslte_pucch_encode(&pucch_ue, &ul_sf, &pucch_cfg, &uci_data.value, sf_symbols)) { + if (srsran_pucch_encode(&pucch_ue, &ul_sf, &pucch_cfg, &uci_data.value, sf_symbols)) { ERROR("Error encoding PUCCH"); goto quit; } - if (srslte_refsignal_dmrs_pucch_gen(&dmrs, &ul_sf, &pucch_cfg, pucch_dmrs)) { + if (srsran_refsignal_dmrs_pucch_gen(&dmrs, &ul_sf, &pucch_cfg, pucch_dmrs)) { ERROR("Error encoding PUCCH"); goto quit; } - if (srslte_refsignal_dmrs_pucch_put(&dmrs, &pucch_cfg, pucch_dmrs, sf_symbols)) { + if (srsran_refsignal_dmrs_pucch_put(&dmrs, &pucch_cfg, pucch_dmrs, sf_symbols)) { ERROR("Error encoding PUCCH"); goto quit; } @@ -264,17 +264,17 @@ int main(int argc, char** argv) uint64_t t_enc = t[0].tv_usec + t[0].tv_sec * 1000000UL; // Run AWGN channel - srslte_channel_awgn_run_c(&awgn, sf_symbols, sf_symbols, SRSLTE_NOF_RE(cell)); + srsran_channel_awgn_run_c(&awgn, sf_symbols, sf_symbols, SRSRAN_NOF_RE(cell)); // Decode PUCCH signals gettimeofday(&t[1], NULL); - if (srslte_chest_ul_estimate_pucch(&chest, &ul_sf, &pucch_cfg, sf_symbols, &chest_res) < SRSLTE_SUCCESS) { + if (srsran_chest_ul_estimate_pucch(&chest, &ul_sf, &pucch_cfg, sf_symbols, &chest_res) < SRSRAN_SUCCESS) { ERROR("Error estimating PUCCH channel"); goto quit; } - srslte_pucch_res_t res = {}; - if (srslte_pucch_decode(&pucch_enb, &ul_sf, &pucch_cfg, &chest_res, sf_symbols, &res) < SRSLTE_SUCCESS) { + srsran_pucch_res_t res = {}; + if (srsran_pucch_decode(&pucch_enb, &ul_sf, &pucch_cfg, &chest_res, sf_symbols, &res) < SRSRAN_SUCCESS) { ERROR("Error decoding PUCCH"); goto quit; } @@ -310,11 +310,11 @@ int main(int argc, char** argv) ret = 0; quit: - srslte_pucch_free(&pucch_ue); - srslte_pucch_free(&pucch_enb); - srslte_chest_ul_free(&chest); - srslte_chest_ul_res_free(&chest_res); - srslte_channel_awgn_free(&awgn); + srsran_pucch_free(&pucch_ue); + srsran_pucch_free(&pucch_enb); + srsran_chest_ul_free(&chest); + srsran_chest_ul_res_free(&chest_res); + srsran_channel_awgn_free(&awgn); if (sf_symbols) { free(sf_symbols); } diff --git a/lib/src/phy/phch/test/pusch_nr_test.c b/lib/src/phy/phch/test/pusch_nr_test.c index 8fa57630f..65cff977a 100644 --- a/lib/src/phy/phch/test/pusch_nr_test.c +++ b/lib/src/phy/phch/test/pusch_nr_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,26 +10,26 @@ * */ -#include "srslte/phy/phch/pusch_nr.h" -#include "srslte/phy/phch/ra_nr.h" -#include "srslte/phy/phch/ra_ul_nr.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/random.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/phch/pusch_nr.h" +#include "srsran/phy/phch/ra_nr.h" +#include "srsran/phy/phch/ra_ul_nr.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/random.h" +#include "srsran/phy/utils/vector.h" #include #include -static srslte_carrier_nr_t carrier = { +static srsran_carrier_nr_t carrier = { 1, // cell_id 0, // numerology - SRSLTE_MAX_PRB_NR, // nof_prb + SRSRAN_MAX_PRB_NR, // nof_prb 0, // start 1 // max_mimo_layers }; static uint32_t n_prb = 0; // Set to 0 for steering static uint32_t mcs = 30; // Set to 30 for steering -static srslte_sch_cfg_nr_t pusch_cfg = {}; +static srsran_sch_cfg_nr_t pusch_cfg = {}; static uint16_t rnti = 0x1234; static uint32_t nof_ack_bits = 0; static uint32_t nof_csi_bits = 0; @@ -40,11 +40,11 @@ void usage(char* prog) printf("\t-p Number of grant PRB, set to 0 for steering [Default %d]\n", n_prb); printf("\t-m MCS PRB, set to >28 for steering [Default %d]\n", mcs); printf("\t-T Provide MCS table (64qam, 256qam, 64qamLowSE) [Default %s]\n", - srslte_mcs_table_to_str(pusch_cfg.sch_cfg.mcs_table)); + srsran_mcs_table_to_str(pusch_cfg.sch_cfg.mcs_table)); printf("\t-L Provide number of layers [Default %d]\n", carrier.max_mimo_layers); printf("\t-A Provide a number of HARQ-ACK bits [Default %d]\n", nof_ack_bits); printf("\t-C Provide a number of CSI bits [Default %d]\n", nof_csi_bits); - printf("\t-v [set srslte_verbose to debug, default none]\n"); + printf("\t-v [set srsran_verbose to debug, default none]\n"); } int parse_args(int argc, char** argv) @@ -59,7 +59,7 @@ int parse_args(int argc, char** argv) mcs = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'T': - pusch_cfg.sch_cfg.mcs_table = srslte_mcs_table_from_str(argv[optind]); + pusch_cfg.sch_cfg.mcs_table = srsran_mcs_table_from_str(argv[optind]); break; case 'L': carrier.max_mimo_layers = (uint32_t)strtol(argv[optind], NULL, 10); @@ -71,62 +71,62 @@ int parse_args(int argc, char** argv) nof_csi_bits = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'v': - srslte_verbose++; + srsran_verbose++; break; default: usage(argv[0]); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int main(int argc, char** argv) { - int ret = SRSLTE_ERROR; - srslte_pusch_nr_t pusch_tx = {}; - srslte_pusch_nr_t pusch_rx = {}; - srslte_chest_dl_res_t chest = {}; - srslte_random_t rand_gen = srslte_random_init(1234); + int ret = SRSRAN_ERROR; + srsran_pusch_nr_t pusch_tx = {}; + srsran_pusch_nr_t pusch_rx = {}; + srsran_chest_dl_res_t chest = {}; + srsran_random_t rand_gen = srsran_random_init(1234); - srslte_pusch_data_nr_t data_tx[SRSLTE_MAX_TB] = {}; - srslte_pusch_res_nr_t data_rx[SRSLTE_MAX_CODEWORDS] = {}; - cf_t* sf_symbols[SRSLTE_MAX_LAYERS_NR] = {}; + srsran_pusch_data_nr_t data_tx[SRSRAN_MAX_TB] = {}; + srsran_pusch_res_nr_t data_rx[SRSRAN_MAX_CODEWORDS] = {}; + cf_t* sf_symbols[SRSRAN_MAX_LAYERS_NR] = {}; // Set default PUSCH configuration - pusch_cfg.sch_cfg.mcs_table = srslte_mcs_table_64qam; + pusch_cfg.sch_cfg.mcs_table = srsran_mcs_table_64qam; - if (parse_args(argc, argv) < SRSLTE_SUCCESS) { + if (parse_args(argc, argv) < SRSRAN_SUCCESS) { goto clean_exit; } - srslte_pusch_nr_args_t pusch_args = {}; + srsran_pusch_nr_args_t pusch_args = {}; pusch_args.sch.disable_simd = false; pusch_args.measure_evm = true; - if (srslte_pusch_nr_init_ue(&pusch_tx, &pusch_args) < SRSLTE_SUCCESS) { + if (srsran_pusch_nr_init_ue(&pusch_tx, &pusch_args) < SRSRAN_SUCCESS) { ERROR("Error initiating PUSCH for Tx"); goto clean_exit; } - if (srslte_pusch_nr_init_gnb(&pusch_rx, &pusch_args) < SRSLTE_SUCCESS) { + if (srsran_pusch_nr_init_gnb(&pusch_rx, &pusch_args) < SRSRAN_SUCCESS) { ERROR("Error initiating SCH NR for Rx"); goto clean_exit; } - if (srslte_pusch_nr_set_carrier(&pusch_tx, &carrier)) { + if (srsran_pusch_nr_set_carrier(&pusch_tx, &carrier)) { ERROR("Error setting SCH NR carrier"); goto clean_exit; } - if (srslte_pusch_nr_set_carrier(&pusch_rx, &carrier)) { + if (srsran_pusch_nr_set_carrier(&pusch_rx, &carrier)) { ERROR("Error setting SCH NR carrier"); goto clean_exit; } for (uint32_t i = 0; i < carrier.max_mimo_layers; i++) { - sf_symbols[i] = srslte_vec_cf_malloc(SRSLTE_SLOT_LEN_RE_NR(carrier.nof_prb)); + sf_symbols[i] = srsran_vec_cf_malloc(SRSRAN_SLOT_LEN_RE_NR(carrier.nof_prb)); if (sf_symbols[i] == NULL) { ERROR("Error malloc"); goto clean_exit; @@ -134,90 +134,90 @@ int main(int argc, char** argv) } for (uint32_t i = 0; i < pusch_tx.max_cw; i++) { - data_tx[i].payload = srslte_vec_u8_malloc(SRSLTE_SLOT_MAX_NOF_BITS_NR); - data_rx[i].payload = srslte_vec_u8_malloc(SRSLTE_SLOT_MAX_NOF_BITS_NR); + data_tx[i].payload = srsran_vec_u8_malloc(SRSRAN_SLOT_MAX_NOF_BITS_NR); + data_rx[i].payload = srsran_vec_u8_malloc(SRSRAN_SLOT_MAX_NOF_BITS_NR); if (data_tx[i].payload == NULL || data_rx[i].payload == NULL) { ERROR("Error malloc"); goto clean_exit; } } - srslte_softbuffer_tx_t softbuffer_tx = {}; - srslte_softbuffer_rx_t softbuffer_rx = {}; + srsran_softbuffer_tx_t softbuffer_tx = {}; + srsran_softbuffer_rx_t softbuffer_rx = {}; - if (srslte_softbuffer_tx_init_guru(&softbuffer_tx, SRSLTE_SCH_NR_MAX_NOF_CB_LDPC, SRSLTE_LDPC_MAX_LEN_ENCODED_CB) < - SRSLTE_SUCCESS) { + if (srsran_softbuffer_tx_init_guru(&softbuffer_tx, SRSRAN_SCH_NR_MAX_NOF_CB_LDPC, SRSRAN_LDPC_MAX_LEN_ENCODED_CB) < + SRSRAN_SUCCESS) { ERROR("Error init soft-buffer"); goto clean_exit; } - if (srslte_softbuffer_rx_init_guru(&softbuffer_rx, SRSLTE_SCH_NR_MAX_NOF_CB_LDPC, SRSLTE_LDPC_MAX_LEN_ENCODED_CB) < - SRSLTE_SUCCESS) { + if (srsran_softbuffer_rx_init_guru(&softbuffer_rx, SRSRAN_SCH_NR_MAX_NOF_CB_LDPC, SRSRAN_LDPC_MAX_LEN_ENCODED_CB) < + SRSRAN_SUCCESS) { ERROR("Error init soft-buffer"); goto clean_exit; } // Use grant default A time resources with m=0 - if (srslte_ra_ul_nr_pusch_time_resource_default_A(carrier.numerology, 0, &pusch_cfg.grant) < SRSLTE_SUCCESS) { + if (srsran_ra_ul_nr_pusch_time_resource_default_A(carrier.numerology, 0, &pusch_cfg.grant) < SRSRAN_SUCCESS) { ERROR("Error loading default grant"); goto clean_exit; } // Load number of DMRS CDM groups without data - if (srslte_ra_ul_nr_nof_dmrs_cdm_groups_without_data_format_0_0(&pusch_cfg, &pusch_cfg.grant) < SRSLTE_SUCCESS) { + if (srsran_ra_ul_nr_nof_dmrs_cdm_groups_without_data_format_0_0(&pusch_cfg, &pusch_cfg.grant) < SRSRAN_SUCCESS) { ERROR("Error loading number of DMRS CDM groups without data"); goto clean_exit; } pusch_cfg.grant.nof_layers = carrier.max_mimo_layers; - pusch_cfg.grant.dci_format = srslte_dci_format_nr_1_0; + pusch_cfg.grant.dci_format = srsran_dci_format_nr_1_0; pusch_cfg.grant.rnti = rnti; uint32_t n_prb_start = 1; uint32_t n_prb_end = carrier.nof_prb + 1; if (n_prb > 0) { - n_prb_start = SRSLTE_MIN(n_prb, n_prb_end - 1); - n_prb_end = SRSLTE_MIN(n_prb + 1, n_prb_end); + n_prb_start = SRSRAN_MIN(n_prb, n_prb_end - 1); + n_prb_end = SRSRAN_MIN(n_prb + 1, n_prb_end); } uint32_t mcs_start = 0; - uint32_t mcs_end = pusch_cfg.sch_cfg.mcs_table == srslte_mcs_table_256qam ? 28 : 29; + uint32_t mcs_end = pusch_cfg.sch_cfg.mcs_table == srsran_mcs_table_256qam ? 28 : 29; if (mcs < mcs_end) { - mcs_start = SRSLTE_MIN(mcs, mcs_end - 1); - mcs_end = SRSLTE_MIN(mcs + 1, mcs_end); + mcs_start = SRSRAN_MIN(mcs, mcs_end - 1); + mcs_end = SRSRAN_MIN(mcs + 1, mcs_end); } pusch_cfg.scaling = 0.5f; pusch_cfg.beta_harq_ack_offset = 2.0f; pusch_cfg.beta_csi_part1_offset = 2.0f; - if (srslte_chest_dl_res_init(&chest, carrier.nof_prb) < SRSLTE_SUCCESS) { + if (srsran_chest_dl_res_init(&chest, carrier.nof_prb) < SRSRAN_SUCCESS) { ERROR("Initiating chest"); goto clean_exit; } for (n_prb = n_prb_start; n_prb < n_prb_end; n_prb++) { for (mcs = mcs_start; mcs < mcs_end; mcs++) { - for (uint32_t n = 0; n < SRSLTE_MAX_PRB_NR; n++) { + for (uint32_t n = 0; n < SRSRAN_MAX_PRB_NR; n++) { pusch_cfg.grant.prb_idx[n] = (n < n_prb); } pusch_cfg.grant.nof_prb = n_prb; - pusch_cfg.grant.dci_format = srslte_dci_format_nr_0_0; - if (srslte_ra_nr_fill_tb(&pusch_cfg, &pusch_cfg.grant, mcs, &pusch_cfg.grant.tb[0]) < SRSLTE_SUCCESS) { + pusch_cfg.grant.dci_format = srsran_dci_format_nr_0_0; + if (srsran_ra_nr_fill_tb(&pusch_cfg, &pusch_cfg.grant, mcs, &pusch_cfg.grant.tb[0]) < SRSRAN_SUCCESS) { ERROR("Error filing tb"); goto clean_exit; } // Generate SCH payload - for (uint32_t tb = 0; tb < SRSLTE_MAX_TB; tb++) { + for (uint32_t tb = 0; tb < SRSRAN_MAX_TB; tb++) { // Skip TB if no allocated if (data_tx[tb].payload == NULL) { continue; } for (uint32_t i = 0; i < pusch_cfg.grant.tb[tb].tbs; i++) { - data_tx[tb].payload[i] = (uint8_t)srslte_random_uniform_int_dist(rand_gen, 0, UINT8_MAX); + data_tx[tb].payload[i] = (uint8_t)srsran_random_uniform_int_dist(rand_gen, 0, UINT8_MAX); } pusch_cfg.grant.tb[tb].softbuffer.tx = &softbuffer_tx; } @@ -226,33 +226,33 @@ int main(int argc, char** argv) if (nof_ack_bits > 0) { pusch_cfg.uci.o_ack = nof_ack_bits; for (uint32_t i = 0; i < nof_ack_bits; i++) { - data_tx->uci.ack[i] = (uint8_t)srslte_random_uniform_int_dist(rand_gen, 0, 1); + data_tx->uci.ack[i] = (uint8_t)srsran_random_uniform_int_dist(rand_gen, 0, 1); } } // Generate CSI report bits - uint8_t csi_report_tx[SRSLTE_UCI_NR_MAX_CSI1_BITS] = {}; - uint8_t csi_report_rx[SRSLTE_UCI_NR_MAX_CSI1_BITS] = {}; + uint8_t csi_report_tx[SRSRAN_UCI_NR_MAX_CSI1_BITS] = {}; + uint8_t csi_report_rx[SRSRAN_UCI_NR_MAX_CSI1_BITS] = {}; if (nof_csi_bits > 0) { - pusch_cfg.uci.csi[0].quantity = SRSLTE_CSI_REPORT_QUANTITY_NONE; + pusch_cfg.uci.csi[0].quantity = SRSRAN_CSI_REPORT_QUANTITY_NONE; pusch_cfg.uci.csi[0].K_csi_rs = nof_csi_bits; pusch_cfg.uci.nof_csi = 1; data_tx->uci.csi[0].none = csi_report_tx; for (uint32_t i = 0; i < nof_csi_bits; i++) { - csi_report_tx[i] = (uint8_t)srslte_random_uniform_int_dist(rand_gen, 0, 1); + csi_report_tx[i] = (uint8_t)srsran_random_uniform_int_dist(rand_gen, 0, 1); } data_rx->uci.csi[0].none = csi_report_rx; } - if (srslte_pusch_nr_encode(&pusch_tx, &pusch_cfg, &pusch_cfg.grant, data_tx, sf_symbols) < SRSLTE_SUCCESS) { + if (srsran_pusch_nr_encode(&pusch_tx, &pusch_cfg, &pusch_cfg.grant, data_tx, sf_symbols) < SRSRAN_SUCCESS) { ERROR("Error encoding"); goto clean_exit; } - for (uint32_t tb = 0; tb < SRSLTE_MAX_TB; tb++) { + for (uint32_t tb = 0; tb < SRSRAN_MAX_TB; tb++) { pusch_cfg.grant.tb[tb].softbuffer.rx = &softbuffer_rx; - srslte_softbuffer_rx_reset(pusch_cfg.grant.tb[tb].softbuffer.rx); + srsran_softbuffer_rx_reset(pusch_cfg.grant.tb[tb].softbuffer.rx); } for (uint32_t i = 0; i < pusch_cfg.grant.tb->nof_re; i++) { @@ -260,8 +260,8 @@ int main(int argc, char** argv) } chest.nof_re = pusch_cfg.grant.tb->nof_re; - if (srslte_pusch_nr_decode(&pusch_rx, &pusch_cfg, &pusch_cfg.grant, &chest, sf_symbols, data_rx) < - SRSLTE_SUCCESS) { + if (srsran_pusch_nr_decode(&pusch_rx, &pusch_cfg, &pusch_cfg.grant, &chest, sf_symbols, data_rx) < + SRSRAN_SUCCESS) { ERROR("Error encoding"); goto clean_exit; } @@ -272,7 +272,7 @@ int main(int argc, char** argv) } float mse = 0.0f; - uint32_t nof_re = srslte_ra_dl_nr_slot_nof_re(&pusch_cfg, &pusch_cfg.grant); + uint32_t nof_re = srsran_ra_dl_nr_slot_nof_re(&pusch_cfg, &pusch_cfg.grant); for (uint32_t i = 0; i < pusch_cfg.grant.nof_layers; i++) { for (uint32_t j = 0; j < nof_re; j++) { mse += cabsf(pusch_tx.d[i][j] - pusch_rx.d[i][j]); @@ -285,9 +285,9 @@ int main(int argc, char** argv) ERROR("MSE error (%f) is too high", mse); for (uint32_t i = 0; i < pusch_cfg.grant.nof_layers; i++) { printf("d_tx[%d]=", i); - srslte_vec_fprint_c(stdout, pusch_tx.d[i], nof_re); + srsran_vec_fprint_c(stdout, pusch_tx.d[i], nof_re); printf("d_rx[%d]=", i); - srslte_vec_fprint_c(stdout, pusch_rx.d[i], nof_re); + srsran_vec_fprint_c(stdout, pusch_rx.d[i], nof_re); } goto clean_exit; } @@ -302,9 +302,9 @@ int main(int argc, char** argv) if (memcmp(data_tx[0].payload, data_rx[0].payload, pusch_cfg.grant.tb[0].tbs / 8) != 0) { ERROR("Failed to match Tx/Rx data; n_prb=%d; mcs=%d; TBS=%d;", n_prb, mcs, pusch_cfg.grant.tb[0].tbs); printf("Tx data: "); - srslte_vec_fprint_byte(stdout, data_tx[0].payload, pusch_cfg.grant.tb[0].tbs / 8); + srsran_vec_fprint_byte(stdout, data_tx[0].payload, pusch_cfg.grant.tb[0].tbs / 8); printf("Rx data: "); - srslte_vec_fprint_byte(stdout, data_tx[0].payload, pusch_cfg.grant.tb[0].tbs / 8); + srsran_vec_fprint_byte(stdout, data_tx[0].payload, pusch_cfg.grant.tb[0].tbs / 8); goto clean_exit; } @@ -321,9 +321,9 @@ int main(int argc, char** argv) if (memcmp(data_tx[0].uci.ack, data_rx[0].uci.ack, nof_ack_bits) != 0) { ERROR("UCI HARQ-ACK bits are unmatched"); printf("Tx data: "); - srslte_vec_fprint_byte(stdout, data_tx[0].uci.ack, nof_ack_bits); + srsran_vec_fprint_byte(stdout, data_tx[0].uci.ack, nof_ack_bits); printf("Rx data: "); - srslte_vec_fprint_byte(stdout, data_rx[0].uci.ack, nof_ack_bits); + srsran_vec_fprint_byte(stdout, data_rx[0].uci.ack, nof_ack_bits); goto clean_exit; } } @@ -333,9 +333,9 @@ int main(int argc, char** argv) if (memcmp(data_tx[0].uci.csi[0].none, data_rx[0].uci.csi[0].none, nof_csi_bits) != 0) { ERROR("UCI CSI bits are unmatched"); printf("Tx data: "); - srslte_vec_fprint_byte(stdout, data_tx[0].uci.csi[0].none, nof_csi_bits); + srsran_vec_fprint_byte(stdout, data_tx[0].uci.csi[0].none, nof_csi_bits); printf("Rx data: "); - srslte_vec_fprint_byte(stdout, data_rx[0].uci.csi[0].none, nof_csi_bits); + srsran_vec_fprint_byte(stdout, data_rx[0].uci.csi[0].none, nof_csi_bits); goto clean_exit; } } @@ -344,14 +344,14 @@ int main(int argc, char** argv) } } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; clean_exit: - srslte_chest_dl_res_free(&chest); - srslte_random_free(rand_gen); - srslte_pusch_nr_free(&pusch_tx); - srslte_pusch_nr_free(&pusch_rx); - for (uint32_t i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { + srsran_chest_dl_res_free(&chest); + srsran_random_free(rand_gen); + srsran_pusch_nr_free(&pusch_tx); + srsran_pusch_nr_free(&pusch_rx); + for (uint32_t i = 0; i < SRSRAN_MAX_CODEWORDS; i++) { if (data_tx[i].payload) { free(data_tx[i].payload); } @@ -359,13 +359,13 @@ clean_exit: free(data_rx[i].payload); } } - for (uint32_t i = 0; i < SRSLTE_MAX_LAYERS_NR; i++) { + for (uint32_t i = 0; i < SRSRAN_MAX_LAYERS_NR; i++) { if (sf_symbols[i]) { free(sf_symbols[i]); } } - srslte_softbuffer_tx_free(&softbuffer_tx); - srslte_softbuffer_rx_free(&softbuffer_rx); + srsran_softbuffer_tx_free(&softbuffer_tx); + srsran_softbuffer_rx_free(&softbuffer_rx); return ret; } diff --git a/lib/src/phy/phch/test/pusch_test.c b/lib/src/phy/phch/test/pusch_test.c index eb0ac7711..d4c1a2bc8 100644 --- a/lib/src/phy/phch/test/pusch_test.c +++ b/lib/src/phy/phch/test/pusch_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,38 +10,38 @@ * */ -#include "srslte/srslte.h" -#include -#include +#include "srsran/srsran.h" +#include +#include #include #include #include #include #include -#include "srslte/srslte.h" +#include "srsran/srsran.h" -static srslte_cell_t cell = { +static srsran_cell_t cell = { .nof_prb = 6, // nof_prb .nof_ports = 1, // nof_ports .id = 0, // cell_id - .cp = SRSLTE_CP_NORM, // cyclic prefix - .phich_length = SRSLTE_PHICH_NORM, // PHICH length - .phich_resources = SRSLTE_PHICH_R_1_6 // PHICH resources + .cp = SRSRAN_CP_NORM, // cyclic prefix + .phich_length = SRSRAN_PHICH_NORM, // PHICH length + .phich_resources = SRSRAN_PHICH_R_1_6 // PHICH resources }; -static srslte_uci_offset_cfg_t uci_cfg = { +static srsran_uci_offset_cfg_t uci_cfg = { .I_offset_cqi = 6, .I_offset_ri = 2, .I_offset_ack = 9, }; -static srslte_uci_data_t uci_data_tx = {}; +static srsran_uci_data_t uci_data_tx = {}; uint32_t L_rb = 2; uint32_t tbs = 0; uint32_t subframe = 10; -srslte_mod_t modulation = SRSLTE_MOD_QPSK; +srsran_mod_t modulation = SRSRAN_MOD_QPSK; uint32_t rv_idx = 0; int freq_hop = -1; int riv = -1; @@ -75,50 +75,50 @@ void usage(char* prog) printf("\n\tOther parameters:\n"); printf("\t\t-p enable_64qam [Default %s]\n", enable_64_qam ? "enabled" : "disabled"); printf("\t\t-s number of subframes [Default %d]\n", subframe); - printf("\t-v [set srslte_verbose to debug, default none]\n"); + printf("\t-v [set srsran_verbose to debug, default none]\n"); } void parse_extensive_param(char* param, char* arg) { - int ext_code = SRSLTE_SUCCESS; + int ext_code = SRSRAN_SUCCESS; if (!strcmp(param, "I_offset_cqi")) { uci_cfg.I_offset_cqi = (uint32_t)strtol(arg, NULL, 10); if (uci_cfg.I_offset_cqi > 15) { - ext_code = SRSLTE_ERROR; + ext_code = SRSRAN_ERROR; } } else if (!strcmp(param, "I_offset_ri")) { uci_cfg.I_offset_ri = (uint32_t)strtol(arg, NULL, 10); if (uci_cfg.I_offset_ri > 15) { - ext_code = SRSLTE_ERROR; + ext_code = SRSRAN_ERROR; } } else if (!strcmp(param, "I_offset_ack")) { uci_cfg.I_offset_ack = (uint32_t)strtol(arg, NULL, 10); if (uci_cfg.I_offset_ack > 15) { - ext_code = SRSLTE_ERROR; + ext_code = SRSRAN_ERROR; } } else if (!strcmp(param, "cqi")) { if (!strcmp(arg, "wideband")) { - uci_data_tx.cfg.cqi.type = SRSLTE_CQI_TYPE_WIDEBAND; + uci_data_tx.cfg.cqi.type = SRSRAN_CQI_TYPE_WIDEBAND; uci_data_tx.value.cqi.wideband.wideband_cqi = (uint8_t)(0x0f); uci_data_tx.cfg.cqi.data_enable = true; } else if (!strcmp(arg, "none")) { uci_data_tx.cfg.cqi.data_enable = false; } else { - ext_code = SRSLTE_ERROR; + ext_code = SRSRAN_ERROR; } } else if (!strcmp(param, "ri")) { uci_data_tx.value.ri = (uint8_t)strtol(arg, NULL, 10); if (uci_data_tx.value.ri > 1) { - ext_code = SRSLTE_ERROR; + ext_code = SRSRAN_ERROR; } else { uci_data_tx.cfg.cqi.ri_len = 1; } } else if (!strcmp(param, "uci_ack")) { - uci_data_tx.cfg.ack[0].nof_acks = SRSLTE_MIN((uint32_t)strtol(arg, NULL, 10), SRSLTE_UCI_MAX_ACK_BITS); + uci_data_tx.cfg.ack[0].nof_acks = SRSRAN_MIN((uint32_t)strtol(arg, NULL, 10), SRSRAN_UCI_MAX_ACK_BITS); } else if (!strcmp(param, "enable_64qam")) { enable_64_qam ^= true; } else { - ext_code = SRSLTE_ERROR; + ext_code = SRSRAN_ERROR; } if (ext_code) { @@ -161,7 +161,7 @@ void parse_args(int argc, char** argv) optind++; break; case 'v': - srslte_verbose++; + srsran_verbose++; break; default: usage(argv[0]); @@ -172,24 +172,24 @@ void parse_args(int argc, char** argv) int main(int argc, char** argv) { - srslte_random_t random_h = srslte_random_init(0); - srslte_chest_ul_res_t chest_res; - srslte_pusch_t pusch_tx; - srslte_pusch_t pusch_rx; + srsran_random_t random_h = srsran_random_init(0); + srsran_chest_ul_res_t chest_res; + srsran_pusch_t pusch_tx; + srsran_pusch_t pusch_rx; uint8_t* data = NULL; uint8_t* data_rx = NULL; cf_t* sf_symbols = NULL; int ret = -1; struct timeval t[3]; - srslte_pusch_cfg_t cfg; - srslte_softbuffer_tx_t softbuffer_tx; - srslte_softbuffer_rx_t softbuffer_rx; + srsran_pusch_cfg_t cfg; + srsran_softbuffer_tx_t softbuffer_tx; + srsran_softbuffer_rx_t softbuffer_rx; ZERO_OBJECT(uci_data_tx); - bzero(&cfg, sizeof(srslte_pusch_cfg_t)); + bzero(&cfg, sizeof(srsran_pusch_cfg_t)); - srslte_dci_ul_t dci; + srsran_dci_ul_t dci; ZERO_OBJECT(dci); parse_args(argc, argv); @@ -198,17 +198,17 @@ int main(int argc, char** argv) if (riv >= 0) { dci.type2_alloc.riv = (uint32_t)riv; } else { - dci.type2_alloc.riv = srslte_ra_type2_to_riv(L_rb, 0, cell.nof_prb); + dci.type2_alloc.riv = srsran_ra_type2_to_riv(L_rb, 0, cell.nof_prb); } dci.tb.mcs_idx = mcs_idx; - srslte_ul_sf_cfg_t ul_sf; + srsran_ul_sf_cfg_t ul_sf; ZERO_OBJECT(ul_sf); ul_sf.tti = 0; - srslte_pusch_hopping_cfg_t ul_hopping = {.n_sb = 1, .hopping_offset = 0, .hop_mode = 1}; + srsran_pusch_hopping_cfg_t ul_hopping = {.n_sb = 1, .hopping_offset = 0, .hop_mode = 1}; - if (srslte_ra_ul_dci_to_grant(&cell, &ul_sf, &ul_hopping, &dci, &cfg.grant)) { + if (srsran_ra_ul_dci_to_grant(&cell, &ul_sf, &ul_hopping, &dci, &cfg.grant)) { ERROR("Error computing resource allocation"); return ret; } @@ -216,19 +216,19 @@ int main(int argc, char** argv) cfg.grant.n_prb_tilde[0] = cfg.grant.n_prb[0]; cfg.grant.n_prb_tilde[1] = cfg.grant.n_prb[1]; - if (srslte_pusch_init_ue(&pusch_tx, cell.nof_prb)) { + if (srsran_pusch_init_ue(&pusch_tx, cell.nof_prb)) { ERROR("Error creating PUSCH object"); goto quit; } - if (srslte_pusch_set_cell(&pusch_tx, cell)) { + if (srsran_pusch_set_cell(&pusch_tx, cell)) { ERROR("Error creating PUSCH object"); goto quit; } - if (srslte_pusch_init_enb(&pusch_rx, cell.nof_prb)) { + if (srsran_pusch_init_enb(&pusch_rx, cell.nof_prb)) { ERROR("Error creating PUSCH object"); goto quit; } - if (srslte_pusch_set_cell(&pusch_rx, cell)) { + if (srsran_pusch_set_cell(&pusch_rx, cell)) { ERROR("Error creating PUSCH object"); goto quit; } @@ -237,94 +237,94 @@ int main(int argc, char** argv) dci.rnti = rnti; cfg.rnti = rnti; - uint32_t nof_re = SRSLTE_NRE * cell.nof_prb * 2 * SRSLTE_CP_NSYMB(cell.cp); - sf_symbols = srslte_vec_cf_malloc(nof_re); + uint32_t nof_re = SRSRAN_NRE * cell.nof_prb * 2 * SRSRAN_CP_NSYMB(cell.cp); + sf_symbols = srsran_vec_cf_malloc(nof_re); if (!sf_symbols) { perror("malloc"); exit(-1); } - data = srslte_vec_u8_malloc(150000); + data = srsran_vec_u8_malloc(150000); if (!data) { perror("malloc"); exit(-1); } - data_rx = srslte_vec_u8_malloc(150000); + data_rx = srsran_vec_u8_malloc(150000); if (!data_rx) { perror("malloc"); exit(-1); } - if (srslte_softbuffer_tx_init(&softbuffer_tx, 100)) { + if (srsran_softbuffer_tx_init(&softbuffer_tx, 100)) { ERROR("Error initiating soft buffer"); goto quit; } - if (srslte_softbuffer_rx_init(&softbuffer_rx, 100)) { + if (srsran_softbuffer_rx_init(&softbuffer_rx, 100)) { ERROR("Error initiating soft buffer"); goto quit; } - srslte_chest_ul_res_init(&chest_res, cell.nof_prb); - srslte_chest_ul_res_set_identity(&chest_res); + srsran_chest_ul_res_init(&chest_res, cell.nof_prb); + srsran_chest_ul_res_set_identity(&chest_res); cfg.enable_64qam = enable_64_qam; uint64_t decode_us = 0; uint64_t decode_bits = 0; for (int n = 0; n < subframe; n++) { - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; /* Configure PUSCH */ ul_sf.tti = (uint32_t)n; cfg.uci_offset = uci_cfg; - srslte_softbuffer_tx_reset(&softbuffer_tx); - srslte_softbuffer_rx_reset(&softbuffer_rx); + srsran_softbuffer_tx_reset(&softbuffer_tx); + srsran_softbuffer_rx_reset(&softbuffer_rx); for (uint32_t i = 0; i < cfg.grant.tb.tbs / 8; i++) { - data[i] = (uint8_t)srslte_random_uniform_int_dist(random_h, 0, 255); + data[i] = (uint8_t)srsran_random_uniform_int_dist(random_h, 0, 255); } for (uint32_t a = 0; a < uci_data_tx.cfg.ack[0].nof_acks; a++) { - uci_data_tx.value.ack.ack_value[a] = (uint8_t)srslte_random_uniform_int_dist(random_h, 0, 1); + uci_data_tx.value.ack.ack_value[a] = (uint8_t)srsran_random_uniform_int_dist(random_h, 0, 1); } - srslte_pusch_data_t pdata; + srsran_pusch_data_t pdata; pdata.ptr = data; pdata.uci = uci_data_tx.value; cfg.uci_cfg = uci_data_tx.cfg; cfg.softbuffers.tx = &softbuffer_tx; - if (srslte_pusch_encode(&pusch_tx, &ul_sf, &cfg, &pdata, sf_symbols)) { + if (srsran_pusch_encode(&pusch_tx, &ul_sf, &cfg, &pdata, sf_symbols)) { ERROR("Error encoding TB"); exit(-1); } if (rv_idx > 0) { cfg.grant.tb.rv = rv_idx; - if (srslte_pusch_encode(&pusch_tx, &ul_sf, &cfg, &pdata, sf_symbols)) { + if (srsran_pusch_encode(&pusch_tx, &ul_sf, &cfg, &pdata, sf_symbols)) { ERROR("Error encoding TB"); exit(-1); } } - srslte_pusch_res_t pusch_res = {}; + srsran_pusch_res_t pusch_res = {}; pusch_res.data = data_rx; cfg.softbuffers.rx = &softbuffer_rx; - memcpy(&cfg.uci_cfg, &uci_data_tx.cfg, sizeof(srslte_uci_cfg_t)); + memcpy(&cfg.uci_cfg, &uci_data_tx.cfg, sizeof(srsran_uci_cfg_t)); gettimeofday(&t[1], NULL); - int r = srslte_pusch_decode(&pusch_rx, &ul_sf, &cfg, &chest_res, sf_symbols, &pusch_res); + int r = srsran_pusch_decode(&pusch_rx, &ul_sf, &cfg, &chest_res, sf_symbols, &pusch_res); gettimeofday(&t[2], NULL); if (r) { printf("Error returned while decoding\n"); - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } if (memcmp(data_rx, data, (size_t)cfg.grant.tb.tbs / 8) != 0) { printf("Unmatched data detected\n"); - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } else { INFO("Rx Data is Ok"); } @@ -332,20 +332,20 @@ int main(int argc, char** argv) if (uci_data_tx.cfg.ack[0].nof_acks) { if (!pusch_res.uci.ack.valid) { printf("Invalid UCI ACK bit\n"); - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } else if (memcmp(uci_data_tx.value.ack.ack_value, pusch_res.uci.ack.ack_value, uci_data_tx.cfg.ack[0].nof_acks) != 0) { printf("UCI ACK bit error:\n"); printf("\tTx: "); - srslte_vec_fprint_byte(stdout, uci_data_tx.value.ack.ack_value, uci_data_tx.cfg.ack[0].nof_acks); + srsran_vec_fprint_byte(stdout, uci_data_tx.value.ack.ack_value, uci_data_tx.cfg.ack[0].nof_acks); printf("\tRx: "); - srslte_vec_fprint_byte(stdout, pusch_res.uci.ack.ack_value, cfg.uci_cfg.ack[0].nof_acks); - ret = SRSLTE_ERROR; + srsran_vec_fprint_byte(stdout, pusch_res.uci.ack.ack_value, cfg.uci_cfg.ack[0].nof_acks); + ret = SRSRAN_ERROR; } else { INFO("Rx ACK (%d bits) is Ok: ", uci_data_tx.cfg.ack[0].nof_acks); - if (srslte_verbose >= SRSLTE_VERBOSE_INFO) { - srslte_vec_fprint_byte(stdout, uci_data_tx.value.ack.ack_value, uci_data_tx.cfg.ack[0].nof_acks); + if (srsran_verbose >= SRSRAN_VERBOSE_INFO) { + srsran_vec_fprint_byte(stdout, uci_data_tx.value.ack.ack_value, uci_data_tx.cfg.ack[0].nof_acks); } } } @@ -353,7 +353,7 @@ int main(int argc, char** argv) if (uci_data_tx.cfg.cqi.ri_len) { if (uci_data_tx.value.ri != pusch_res.uci.ri) { printf("UCI RI bit error: %d != %d\n", uci_data_tx.value.ri, pusch_res.uci.ri); - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } else { INFO("Rx RI is Ok"); } @@ -363,7 +363,7 @@ int main(int argc, char** argv) uci_data_tx.value.cqi.data_crc = pusch_res.uci.cqi.data_crc; if (memcmp(&uci_data_tx.value.cqi, &pusch_res.uci.cqi, sizeof(pusch_res.uci.cqi)) != 0) { printf("CQI Decode failed at subframe %d\n", n); - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } else { INFO("Rx CQI is Ok (crc=%d, wb_cqi=%d)", pusch_res.uci.cqi.data_crc, pusch_res.uci.cqi.wideband.wideband_cqi); } @@ -386,12 +386,12 @@ int main(int argc, char** argv) printf("Decoded Rate: %f Mbps\n", (double)decode_bits / (double)decode_us); quit: - srslte_chest_ul_res_free(&chest_res); - srslte_pusch_free(&pusch_tx); - srslte_pusch_free(&pusch_rx); - srslte_softbuffer_tx_free(&softbuffer_tx); - srslte_softbuffer_rx_free(&softbuffer_rx); - srslte_random_free(random_h); + srsran_chest_ul_res_free(&chest_res); + srsran_pusch_free(&pusch_tx); + srsran_pusch_free(&pusch_rx); + srsran_softbuffer_tx_free(&softbuffer_tx); + srsran_softbuffer_rx_free(&softbuffer_rx); + srsran_random_free(random_h); if (sf_symbols) { free(sf_symbols); } diff --git a/lib/src/phy/phch/test/ra_nr_test.c b/lib/src/phy/phch/test/ra_nr_test.c index f43ab5c26..20adb2ba1 100644 --- a/lib/src/phy/phch/test/ra_nr_test.c +++ b/lib/src/phy/phch/test/ra_nr_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,36 +10,36 @@ * */ -#include "srslte/common/test_common.h" -#include "srslte/phy/phch/ra_dl_nr.h" -#include "srslte/phy/phch/ra_nr.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/random.h" +#include "srsran/common/test_common.h" +#include "srsran/phy/phch/ra_dl_nr.h" +#include "srsran/phy/phch/ra_nr.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/random.h" #include -static srslte_carrier_nr_t carrier = { +static srsran_carrier_nr_t carrier = { 1, // cell_id 0, // numerology - SRSLTE_MAX_PRB_NR, // nof_prb + SRSRAN_MAX_PRB_NR, // nof_prb 0, // start 1 // max_mimo_layers }; int test_type0_multiple() { - srslte_sch_cfg_nr_t sch_cfg = {}; - srslte_dci_dl_nr_t dci_dl = {}; - srslte_sch_grant_nr_t grant = {}; + srsran_sch_cfg_nr_t sch_cfg = {}; + srsran_dci_dl_nr_t dci_dl = {}; + srsran_sch_grant_nr_t grant = {}; carrier.nof_prb = 32; carrier.start = 48; sch_cfg.rbg_size_cfg_1 = false; - dci_dl.format = srslte_dci_format_nr_1_0; + dci_dl.format = srsran_dci_format_nr_1_0; dci_dl.freq_domain_assigment = 0xC0; // RBG 0 and 1 - TESTASSERT(srslte_ra_dl_nr_freq(&carrier, &sch_cfg, &dci_dl, &grant) == SRSLTE_SUCCESS); + TESTASSERT(srsran_ra_dl_nr_freq(&carrier, &sch_cfg, &dci_dl, &grant) == SRSRAN_SUCCESS); TESTASSERT(grant.nof_prb == 8); // P * 2 RBG for (uint32_t i = 0; i < grant.nof_prb; i++) { @@ -49,24 +49,24 @@ int test_type0_multiple() TESTASSERT(grant.prb_idx[i] == false); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_type0_not_multiple() { - srslte_sch_cfg_nr_t sch_cfg = {}; - srslte_dci_dl_nr_t dci_dl = {}; - srslte_sch_grant_nr_t grant = {}; + srsran_sch_cfg_nr_t sch_cfg = {}; + srsran_dci_dl_nr_t dci_dl = {}; + srsran_sch_grant_nr_t grant = {}; carrier.nof_prb = 33; carrier.start = 49; sch_cfg.rbg_size_cfg_1 = false; - dci_dl.format = srslte_dci_format_nr_1_0; + dci_dl.format = srsran_dci_format_nr_1_0; dci_dl.freq_domain_assigment = 0x1C0; // RBG 0, 1 and 2 - TESTASSERT(srslte_ra_dl_nr_freq(&carrier, &sch_cfg, &dci_dl, &grant) == SRSLTE_SUCCESS); + TESTASSERT(srsran_ra_dl_nr_freq(&carrier, &sch_cfg, &dci_dl, &grant) == SRSRAN_SUCCESS); TESTASSERT(grant.nof_prb == 11); // P + (P-1) RBG for (uint32_t i = 0; i < grant.nof_prb; i++) { @@ -76,11 +76,11 @@ int test_type0_not_multiple() TESTASSERT(grant.prb_idx[i] == false); } - bzero(&grant, sizeof(srslte_sch_grant_nr_t)); + bzero(&grant, sizeof(srsran_sch_grant_nr_t)); dci_dl.freq_domain_assigment = 0x3; // RBG 8 and 9 - TESTASSERT(srslte_ra_dl_nr_freq(&carrier, &sch_cfg, &dci_dl, &grant) == SRSLTE_SUCCESS); + TESTASSERT(srsran_ra_dl_nr_freq(&carrier, &sch_cfg, &dci_dl, &grant) == SRSRAN_SUCCESS); TESTASSERT(grant.nof_prb == 6); // P + (P-1) RBG for (uint32_t i = 0; i < carrier.nof_prb - grant.nof_prb; i++) { @@ -90,12 +90,12 @@ int test_type0_not_multiple() TESTASSERT(grant.prb_idx[i] == true); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int main(int argc, char** argv) { - // TESTASSERT(test_type0_multiple() == SRSLTE_SUCCESS); - TESTASSERT(test_type0_not_multiple() == SRSLTE_SUCCESS); - return SRSLTE_SUCCESS; + // TESTASSERT(test_type0_multiple() == SRSRAN_SUCCESS); + TESTASSERT(test_type0_not_multiple() == SRSRAN_SUCCESS); + return SRSRAN_SUCCESS; } diff --git a/lib/src/phy/phch/test/sch_nr_test.c b/lib/src/phy/phch/test/sch_nr_test.c index bfa7e125e..96c154234 100644 --- a/lib/src/phy/phch/test/sch_nr_test.c +++ b/lib/src/phy/phch/test/sch_nr_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,26 +10,26 @@ * */ -#include "srslte/phy/phch/ra_dl_nr.h" -#include "srslte/phy/phch/ra_nr.h" -#include "srslte/phy/phch/sch_nr.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/phch/ra_dl_nr.h" +#include "srsran/phy/phch/ra_nr.h" +#include "srsran/phy/phch/sch_nr.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" #include -#include +#include -static srslte_carrier_nr_t carrier = { +static srsran_carrier_nr_t carrier = { 0, // cell_id 0, // numerology - SRSLTE_MAX_PRB_NR, // nof_prb + SRSRAN_MAX_PRB_NR, // nof_prb 0, // start 1 // max_mimo_layers }; static uint32_t n_prb = 0; // Set to 0 for steering static uint32_t mcs = 30; // Set to 30 for steering -static srslte_sch_cfg_nr_t pdsch_cfg = {}; -static srslte_sch_grant_nr_t pdsch_grant = {}; +static srsran_sch_cfg_nr_t pdsch_cfg = {}; +static srsran_sch_grant_nr_t pdsch_grant = {}; void usage(char* prog) { @@ -37,9 +37,9 @@ void usage(char* prog) printf("\t-p Number of grant PRB, set to 0 for steering [Default %d]\n", n_prb); printf("\t-m MCS PRB, set to >28 for steering [Default %d]\n", mcs); printf("\t-T Provide MCS table (64qam, 256qam, 64qamLowSE) [Default %s]\n", - srslte_mcs_table_to_str(pdsch_cfg.sch_cfg.mcs_table)); + srsran_mcs_table_to_str(pdsch_cfg.sch_cfg.mcs_table)); printf("\t-L Provide number of layers [Default %d]\n", carrier.max_mimo_layers); - printf("\t-v [set srslte_verbose to debug, default none]\n"); + printf("\t-v [set srsran_verbose to debug, default none]\n"); } int parse_args(int argc, char** argv) @@ -54,39 +54,39 @@ int parse_args(int argc, char** argv) mcs = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'T': - pdsch_cfg.sch_cfg.mcs_table = srslte_mcs_table_from_str(argv[optind]); + pdsch_cfg.sch_cfg.mcs_table = srsran_mcs_table_from_str(argv[optind]); break; case 'L': carrier.max_mimo_layers = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'v': - srslte_verbose++; + srsran_verbose++; break; default: usage(argv[0]); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int main(int argc, char** argv) { - int ret = SRSLTE_ERROR; - srslte_sch_nr_t sch_nr_tx = {}; - srslte_sch_nr_t sch_nr_rx = {}; - srslte_random_t rand_gen = srslte_random_init(1234); + int ret = SRSRAN_ERROR; + srsran_sch_nr_t sch_nr_tx = {}; + srsran_sch_nr_t sch_nr_rx = {}; + srsran_random_t rand_gen = srsran_random_init(1234); - uint8_t* data_tx = srslte_vec_u8_malloc(1024 * 1024); - uint8_t* encoded = srslte_vec_u8_malloc(1024 * 1024 * 8); - int8_t* llr = srslte_vec_i8_malloc(1024 * 1024 * 8); - uint8_t* data_rx = srslte_vec_u8_malloc(1024 * 1024); + uint8_t* data_tx = srsran_vec_u8_malloc(1024 * 1024); + uint8_t* encoded = srsran_vec_u8_malloc(1024 * 1024 * 8); + int8_t* llr = srsran_vec_i8_malloc(1024 * 1024 * 8); + uint8_t* data_rx = srsran_vec_u8_malloc(1024 * 1024); // Set default PDSCH configuration - pdsch_cfg.sch_cfg.mcs_table = srslte_mcs_table_64qam; + pdsch_cfg.sch_cfg.mcs_table = srsran_mcs_table_64qam; - if (parse_args(argc, argv) < SRSLTE_SUCCESS) { + if (parse_args(argc, argv) < SRSRAN_SUCCESS) { goto clean_exit; } @@ -94,84 +94,84 @@ int main(int argc, char** argv) goto clean_exit; } - srslte_sch_nr_args_t args = {}; + srsran_sch_nr_args_t args = {}; args.disable_simd = false; - if (srslte_sch_nr_init_tx(&sch_nr_tx, &args) < SRSLTE_SUCCESS) { + if (srsran_sch_nr_init_tx(&sch_nr_tx, &args) < SRSRAN_SUCCESS) { ERROR("Error initiating SCH NR for Tx"); goto clean_exit; } - if (srslte_sch_nr_init_rx(&sch_nr_rx, &args) < SRSLTE_SUCCESS) { + if (srsran_sch_nr_init_rx(&sch_nr_rx, &args) < SRSRAN_SUCCESS) { ERROR("Error initiating SCH NR for Rx"); goto clean_exit; } - if (srslte_sch_nr_set_carrier(&sch_nr_tx, &carrier)) { + if (srsran_sch_nr_set_carrier(&sch_nr_tx, &carrier)) { ERROR("Error setting SCH NR carrier"); goto clean_exit; } - if (srslte_sch_nr_set_carrier(&sch_nr_rx, &carrier)) { + if (srsran_sch_nr_set_carrier(&sch_nr_rx, &carrier)) { ERROR("Error setting SCH NR carrier"); goto clean_exit; } - srslte_softbuffer_tx_t softbuffer_tx = {}; - srslte_softbuffer_rx_t softbuffer_rx = {}; + srsran_softbuffer_tx_t softbuffer_tx = {}; + srsran_softbuffer_rx_t softbuffer_rx = {}; - if (srslte_softbuffer_tx_init_guru(&softbuffer_tx, SRSLTE_SCH_NR_MAX_NOF_CB_LDPC, SRSLTE_LDPC_MAX_LEN_ENCODED_CB) < - SRSLTE_SUCCESS) { + if (srsran_softbuffer_tx_init_guru(&softbuffer_tx, SRSRAN_SCH_NR_MAX_NOF_CB_LDPC, SRSRAN_LDPC_MAX_LEN_ENCODED_CB) < + SRSRAN_SUCCESS) { ERROR("Error init soft-buffer"); goto clean_exit; } - if (srslte_softbuffer_rx_init_guru(&softbuffer_rx, SRSLTE_SCH_NR_MAX_NOF_CB_LDPC, SRSLTE_LDPC_MAX_LEN_ENCODED_CB) < - SRSLTE_SUCCESS) { + if (srsran_softbuffer_rx_init_guru(&softbuffer_rx, SRSRAN_SCH_NR_MAX_NOF_CB_LDPC, SRSRAN_LDPC_MAX_LEN_ENCODED_CB) < + SRSRAN_SUCCESS) { ERROR("Error init soft-buffer"); goto clean_exit; } // Use grant default A time resources with m=0 - if (srslte_ra_dl_nr_time_default_A(0, pdsch_cfg.dmrs.typeA_pos, &pdsch_grant) < SRSLTE_SUCCESS) { + if (srsran_ra_dl_nr_time_default_A(0, pdsch_cfg.dmrs.typeA_pos, &pdsch_grant) < SRSRAN_SUCCESS) { ERROR("Error loading default grant"); goto clean_exit; } pdsch_grant.nof_layers = carrier.max_mimo_layers; - pdsch_grant.dci_format = srslte_dci_format_nr_1_0; + pdsch_grant.dci_format = srsran_dci_format_nr_1_0; uint32_t n_prb_start = 1; uint32_t n_prb_end = carrier.nof_prb + 1; if (n_prb > 0) { - n_prb_start = SRSLTE_MIN(n_prb, n_prb_end - 1); - n_prb_end = SRSLTE_MIN(n_prb + 1, n_prb_end); + n_prb_start = SRSRAN_MIN(n_prb, n_prb_end - 1); + n_prb_end = SRSRAN_MIN(n_prb + 1, n_prb_end); } uint32_t mcs_start = 0; - uint32_t mcs_end = pdsch_cfg.sch_cfg.mcs_table == srslte_mcs_table_256qam ? 28 : 29; + uint32_t mcs_end = pdsch_cfg.sch_cfg.mcs_table == srsran_mcs_table_256qam ? 28 : 29; if (mcs < mcs_end) { - mcs_start = SRSLTE_MIN(mcs, mcs_end - 1); - mcs_end = SRSLTE_MIN(mcs + 1, mcs_end); + mcs_start = SRSRAN_MIN(mcs, mcs_end - 1); + mcs_end = SRSRAN_MIN(mcs + 1, mcs_end); } for (n_prb = n_prb_start; n_prb < n_prb_end; n_prb++) { for (mcs = mcs_start; mcs < mcs_end; mcs++) { - for (uint32_t n = 0; n < SRSLTE_MAX_PRB_NR; n++) { + for (uint32_t n = 0; n < SRSRAN_MAX_PRB_NR; n++) { pdsch_grant.prb_idx[n] = (n < n_prb); } - srslte_sch_tb_t tb = {}; - if (srslte_ra_nr_fill_tb(&pdsch_cfg, &pdsch_grant, mcs, &tb) < SRSLTE_SUCCESS) { + srsran_sch_tb_t tb = {}; + if (srsran_ra_nr_fill_tb(&pdsch_cfg, &pdsch_grant, mcs, &tb) < SRSRAN_SUCCESS) { ERROR("Error filing tb"); goto clean_exit; } for (uint32_t i = 0; i < tb.tbs; i++) { - data_tx[i] = (uint8_t)srslte_random_uniform_int_dist(rand_gen, 0, UINT8_MAX); + data_tx[i] = (uint8_t)srsran_random_uniform_int_dist(rand_gen, 0, UINT8_MAX); } tb.softbuffer.tx = &softbuffer_tx; - if (srslte_dlsch_nr_encode(&sch_nr_tx, &pdsch_cfg.sch_cfg, &tb, data_tx, encoded) < SRSLTE_SUCCESS) { + if (srsran_dlsch_nr_encode(&sch_nr_tx, &pdsch_cfg.sch_cfg, &tb, data_tx, encoded) < SRSRAN_SUCCESS) { ERROR("Error encoding"); goto clean_exit; } @@ -181,10 +181,10 @@ int main(int argc, char** argv) } tb.softbuffer.rx = &softbuffer_rx; - srslte_softbuffer_rx_reset(tb.softbuffer.rx); + srsran_softbuffer_rx_reset(tb.softbuffer.rx); bool crc = false; - if (srslte_dlsch_nr_decode(&sch_nr_rx, &pdsch_cfg.sch_cfg, &tb, llr, data_rx, &crc) < SRSLTE_SUCCESS) { + if (srsran_dlsch_nr_decode(&sch_nr_rx, &pdsch_cfg.sch_cfg, &tb, llr, data_rx, &crc) < SRSRAN_SUCCESS) { ERROR("Error encoding"); goto clean_exit; } @@ -197,9 +197,9 @@ int main(int argc, char** argv) if (memcmp(data_tx, data_rx, tb.tbs / 8) != 0) { ERROR("Failed to match Tx/Rx data; n_prb=%d; mcs=%d; TBS=%d;", n_prb, mcs, tb.tbs); printf("Tx data: "); - srslte_vec_fprint_byte(stdout, data_tx, tb.tbs / 8); + srsran_vec_fprint_byte(stdout, data_tx, tb.tbs / 8); printf("Rx data: "); - srslte_vec_fprint_byte(stdout, data_rx, tb.tbs / 8); + srsran_vec_fprint_byte(stdout, data_rx, tb.tbs / 8); goto clean_exit; } @@ -207,12 +207,12 @@ int main(int argc, char** argv) } } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; clean_exit: - srslte_random_free(rand_gen); - srslte_sch_nr_free(&sch_nr_tx); - srslte_sch_nr_free(&sch_nr_rx); + srsran_random_free(rand_gen); + srsran_sch_nr_free(&sch_nr_tx); + srsran_sch_nr_free(&sch_nr_rx); if (data_tx) { free(data_tx); } @@ -225,8 +225,8 @@ clean_exit: if (encoded) { free(encoded); } - srslte_softbuffer_tx_free(&softbuffer_tx); - srslte_softbuffer_rx_free(&softbuffer_rx); + srsran_softbuffer_tx_free(&softbuffer_tx); + srsran_softbuffer_rx_free(&softbuffer_rx); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } diff --git a/lib/src/phy/phch/uci.c b/lib/src/phy/phch/uci.c index d6c3abea7..503c9df33 100644 --- a/lib/src/phy/phch/uci.c +++ b/lib/src/phy/phch/uci.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -19,15 +19,15 @@ #include #include -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/fec/block/block.h" -#include "srslte/phy/fec/convolutional/convcoder.h" -#include "srslte/phy/fec/convolutional/rm_conv.h" -#include "srslte/phy/fec/crc.h" -#include "srslte/phy/phch/uci.h" -#include "srslte/phy/utils/bit.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/fec/block/block.h" +#include "srsran/phy/fec/convolutional/convcoder.h" +#include "srsran/phy/fec/convolutional/rm_conv.h" +#include "srsran/phy/fec/crc.h" +#include "srsran/phy/phch/uci.h" +#include "srsran/phy/utils/bit.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" /* Table 5.2.3.3-1: Basis sequences for (20, A) code */ static uint8_t M_basis_seq_pucch[20][13] = { @@ -43,29 +43,29 @@ static uint8_t M_basis_seq_pucch[20][13] = { {1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0}, {1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0}, }; -void srslte_uci_cqi_pucch_init(srslte_uci_cqi_pucch_t* q) +void srsran_uci_cqi_pucch_init(srsran_uci_cqi_pucch_t* q) { uint8_t word[16]; - uint32_t nwords = 1 << SRSLTE_UCI_MAX_CQI_LEN_PUCCH; - q->cqi_table = srslte_vec_malloc(nwords * sizeof(int8_t*)); - q->cqi_table_s = srslte_vec_malloc(nwords * sizeof(int16_t*)); + uint32_t nwords = 1 << SRSRAN_UCI_MAX_CQI_LEN_PUCCH; + q->cqi_table = srsran_vec_malloc(nwords * sizeof(int8_t*)); + q->cqi_table_s = srsran_vec_malloc(nwords * sizeof(int16_t*)); for (uint32_t w = 0; w < nwords; w++) { - q->cqi_table[w] = srslte_vec_malloc(SRSLTE_UCI_CQI_CODED_PUCCH_B * sizeof(int8_t)); - q->cqi_table_s[w] = srslte_vec_malloc(SRSLTE_UCI_CQI_CODED_PUCCH_B * sizeof(int16_t)); + q->cqi_table[w] = srsran_vec_malloc(SRSRAN_UCI_CQI_CODED_PUCCH_B * sizeof(int8_t)); + q->cqi_table_s[w] = srsran_vec_malloc(SRSRAN_UCI_CQI_CODED_PUCCH_B * sizeof(int16_t)); uint8_t* ptr = word; - srslte_bit_unpack(w, &ptr, SRSLTE_UCI_MAX_CQI_LEN_PUCCH); - srslte_uci_encode_cqi_pucch(word, SRSLTE_UCI_MAX_CQI_LEN_PUCCH, q->cqi_table[w]); - for (int j = 0; j < SRSLTE_UCI_CQI_CODED_PUCCH_B; j++) { + srsran_bit_unpack(w, &ptr, SRSRAN_UCI_MAX_CQI_LEN_PUCCH); + srsran_uci_encode_cqi_pucch(word, SRSRAN_UCI_MAX_CQI_LEN_PUCCH, q->cqi_table[w]); + for (int j = 0; j < SRSRAN_UCI_CQI_CODED_PUCCH_B; j++) { q->cqi_table_s[w][j] = (int16_t)(2 * q->cqi_table[w][j] - 1); } } } -void srslte_uci_cqi_pucch_free(srslte_uci_cqi_pucch_t* q) +void srsran_uci_cqi_pucch_free(srsran_uci_cqi_pucch_t* q) { - uint32_t nwords = 1 << SRSLTE_UCI_MAX_CQI_LEN_PUCCH; + uint32_t nwords = 1 << SRSRAN_UCI_MAX_CQI_LEN_PUCCH; for (uint32_t w = 0; w < nwords; w++) { if (q->cqi_table[w]) { free(q->cqi_table[w]); @@ -80,53 +80,53 @@ void srslte_uci_cqi_pucch_free(srslte_uci_cqi_pucch_t* q) /* Encode UCI CQI/PMI as described in 5.2.3.3 of 36.212 */ -int srslte_uci_encode_cqi_pucch(uint8_t* cqi_data, uint32_t cqi_len, uint8_t b_bits[SRSLTE_UCI_CQI_CODED_PUCCH_B]) +int srsran_uci_encode_cqi_pucch(uint8_t* cqi_data, uint32_t cqi_len, uint8_t b_bits[SRSRAN_UCI_CQI_CODED_PUCCH_B]) { - if (cqi_len <= SRSLTE_UCI_MAX_CQI_LEN_PUCCH) { - for (uint32_t i = 0; i < SRSLTE_UCI_CQI_CODED_PUCCH_B; i++) { + if (cqi_len <= SRSRAN_UCI_MAX_CQI_LEN_PUCCH) { + for (uint32_t i = 0; i < SRSRAN_UCI_CQI_CODED_PUCCH_B; i++) { uint64_t x = 0; for (uint32_t n = 0; n < cqi_len; n++) { x += cqi_data[n] * M_basis_seq_pucch[i][n]; } b_bits[i] = (uint8_t)(x % 2); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } else { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } } -int srslte_uci_encode_cqi_pucch_from_table(srslte_uci_cqi_pucch_t* q, +int srsran_uci_encode_cqi_pucch_from_table(srsran_uci_cqi_pucch_t* q, uint8_t* cqi_data, uint32_t cqi_len, - uint8_t b_bits[SRSLTE_UCI_CQI_CODED_PUCCH_B]) + uint8_t b_bits[SRSRAN_UCI_CQI_CODED_PUCCH_B]) { - if (cqi_len <= SRSLTE_UCI_MAX_CQI_LEN_PUCCH) { - bzero(&cqi_data[cqi_len], SRSLTE_UCI_MAX_CQI_LEN_PUCCH - cqi_len); + if (cqi_len <= SRSRAN_UCI_MAX_CQI_LEN_PUCCH) { + bzero(&cqi_data[cqi_len], SRSRAN_UCI_MAX_CQI_LEN_PUCCH - cqi_len); uint8_t* ptr = cqi_data; - uint32_t packed = srslte_bit_pack(&ptr, SRSLTE_UCI_MAX_CQI_LEN_PUCCH); - memcpy(b_bits, q->cqi_table[packed], SRSLTE_UCI_CQI_CODED_PUCCH_B); + uint32_t packed = srsran_bit_pack(&ptr, SRSRAN_UCI_MAX_CQI_LEN_PUCCH); + memcpy(b_bits, q->cqi_table[packed], SRSRAN_UCI_CQI_CODED_PUCCH_B); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } else { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } } /* Decode UCI CQI/PMI over PUCCH */ -int16_t srslte_uci_decode_cqi_pucch(srslte_uci_cqi_pucch_t* q, - int16_t b_bits[SRSLTE_CQI_MAX_BITS], +int16_t srsran_uci_decode_cqi_pucch(srsran_uci_cqi_pucch_t* q, + int16_t b_bits[SRSRAN_CQI_MAX_BITS], uint8_t* cqi_data, uint32_t cqi_len) { - if (cqi_len < SRSLTE_UCI_MAX_CQI_LEN_PUCCH && b_bits != NULL && cqi_data != NULL) { + if (cqi_len < SRSRAN_UCI_MAX_CQI_LEN_PUCCH && b_bits != NULL && cqi_data != NULL) { uint32_t max_w = 0; int32_t max_corr = INT32_MIN; - uint32_t nwords = 1 << SRSLTE_UCI_MAX_CQI_LEN_PUCCH; - for (uint32_t w = 0; w < nwords; w += 1 << (SRSLTE_UCI_MAX_CQI_LEN_PUCCH - cqi_len)) { + uint32_t nwords = 1 << SRSRAN_UCI_MAX_CQI_LEN_PUCCH; + for (uint32_t w = 0; w < nwords; w += 1 << (SRSRAN_UCI_MAX_CQI_LEN_PUCCH - cqi_len)) { // Calculate correlation with pregenerated word and select maximum - int32_t corr = srslte_vec_dot_prod_sss(q->cqi_table_s[w], b_bits, SRSLTE_UCI_CQI_CODED_PUCCH_B); + int32_t corr = srsran_vec_dot_prod_sss(q->cqi_table_s[w], b_bits, SRSRAN_UCI_CQI_CODED_PUCCH_B); if (corr > max_corr) { max_corr = corr; max_w = w; @@ -134,34 +134,34 @@ int16_t srslte_uci_decode_cqi_pucch(srslte_uci_cqi_pucch_t* q, } // Convert word to bits again uint8_t* ptr = cqi_data; - srslte_bit_unpack(max_w, &ptr, SRSLTE_UCI_MAX_CQI_LEN_PUCCH); + srsran_bit_unpack(max_w, &ptr, SRSRAN_UCI_MAX_CQI_LEN_PUCCH); INFO("Decoded CQI: w=%d, corr=%d", max_w, max_corr); return max_corr; } else { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } } -int srslte_uci_cqi_init(srslte_uci_cqi_pusch_t* q) +int srsran_uci_cqi_init(srsran_uci_cqi_pusch_t* q) { - if (srslte_crc_init(&q->crc, SRSLTE_LTE_CRC8, 8)) { - return SRSLTE_ERROR; + if (srsran_crc_init(&q->crc, SRSRAN_LTE_CRC8, 8)) { + return SRSRAN_ERROR; } int poly[3] = {0x6D, 0x4F, 0x57}; - if (srslte_viterbi_init(&q->viterbi, SRSLTE_VITERBI_37, poly, SRSLTE_UCI_MAX_CQI_LEN_PUSCH, true)) { - return SRSLTE_ERROR; + if (srsran_viterbi_init(&q->viterbi, SRSRAN_VITERBI_37, poly, SRSRAN_UCI_MAX_CQI_LEN_PUSCH, true)) { + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -void srslte_uci_cqi_free(srslte_uci_cqi_pusch_t* q) +void srsran_uci_cqi_free(srsran_uci_cqi_pusch_t* q) { - srslte_viterbi_free(&q->viterbi); + srsran_viterbi_free(&q->viterbi); } -static uint32_t Q_prime_cqi(srslte_pusch_cfg_t* cfg, uint32_t O, float beta, uint32_t Q_prime_ri) +static uint32_t Q_prime_cqi(srsran_pusch_cfg_t* cfg, uint32_t O, float beta, uint32_t Q_prime_ri) { uint32_t K = cfg->K_segm; @@ -170,54 +170,54 @@ static uint32_t Q_prime_cqi(srslte_pusch_cfg_t* cfg, uint32_t O, float beta, uin uint32_t x = 999999; if (K > 0) { - x = (uint32_t)ceilf((float)(O + L) * cfg->grant.L_prb * SRSLTE_NRE * cfg->grant.nof_symb * beta / K); + x = (uint32_t)ceilf((float)(O + L) * cfg->grant.L_prb * SRSRAN_NRE * cfg->grant.nof_symb * beta / K); } - Q_prime = SRSLTE_MIN(x, cfg->grant.L_prb * SRSLTE_NRE * cfg->grant.nof_symb - Q_prime_ri); + Q_prime = SRSRAN_MIN(x, cfg->grant.L_prb * SRSRAN_NRE * cfg->grant.nof_symb - Q_prime_ri); return Q_prime; } -uint32_t srslte_qprime_cqi_ext(uint32_t L_prb, uint32_t nof_symbols, uint32_t tbs, float beta) +uint32_t srsran_qprime_cqi_ext(uint32_t L_prb, uint32_t nof_symbols, uint32_t tbs, float beta) { - srslte_pusch_cfg_t cfg = {}; + srsran_pusch_cfg_t cfg = {}; cfg.grant.L_prb = L_prb; cfg.grant.nof_symb = nof_symbols; cfg.K_segm = tbs; // O is the number of CQI + CRC len (8). See 5.2.2.6 - return Q_prime_cqi(&cfg, SRSLTE_UCI_CQI_CODED_PUCCH_B + 8, beta, 0); + return Q_prime_cqi(&cfg, SRSRAN_UCI_CQI_CODED_PUCCH_B + 8, beta, 0); } /* Encode UCI CQI/PMI for payloads equal or lower to 11 bits (Sec 5.2.2.6.4) */ -int encode_cqi_short(srslte_uci_cqi_pusch_t* q, uint8_t* data, uint32_t nof_bits, uint8_t* q_bits, uint32_t Q) +int encode_cqi_short(srsran_uci_cqi_pusch_t* q, uint8_t* data, uint32_t nof_bits, uint8_t* q_bits, uint32_t Q) { - if (nof_bits <= SRSLTE_FEC_BLOCK_MAX_NOF_BITS && nof_bits > 0 && q != NULL && data != NULL && q_bits != NULL) { - srslte_block_encode(data, nof_bits, q_bits, Q); - return SRSLTE_SUCCESS; + if (nof_bits <= SRSRAN_FEC_BLOCK_MAX_NOF_BITS && nof_bits > 0 && q != NULL && data != NULL && q_bits != NULL) { + srsran_block_encode(data, nof_bits, q_bits, Q); + return SRSRAN_SUCCESS; } - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } // For decoding the block-encoded CQI we use ML decoding -int decode_cqi_short(srslte_uci_cqi_pusch_t* q, int16_t* q_bits, uint32_t Q, uint8_t* data, uint32_t nof_bits) +int decode_cqi_short(srsran_uci_cqi_pusch_t* q, int16_t* q_bits, uint32_t Q, uint8_t* data, uint32_t nof_bits) { - if (nof_bits <= SRSLTE_FEC_BLOCK_MAX_NOF_BITS && nof_bits > 0 && q != NULL && data != NULL && q_bits != NULL) { - int32_t max_corr = srslte_block_decode_i16(q_bits, Q, data, nof_bits); + if (nof_bits <= SRSRAN_FEC_BLOCK_MAX_NOF_BITS && nof_bits > 0 && q != NULL && data != NULL && q_bits != NULL) { + int32_t max_corr = srsran_block_decode_i16(q_bits, Q, data, nof_bits); INFO("Decoded CQI: corr=%d", max_corr); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } else { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } } /* Encode UCI CQI/PMI for payloads greater than 11 bits (go through CRC, conv coder and rate match) */ -int encode_cqi_long(srslte_uci_cqi_pusch_t* q, uint8_t* data, uint32_t nof_bits, uint8_t* q_bits, uint32_t Q) +int encode_cqi_long(srsran_uci_cqi_pusch_t* q, uint8_t* data, uint32_t nof_bits, uint8_t* q_bits, uint32_t Q) { - srslte_convcoder_t encoder; + srsran_convcoder_t encoder; - if (nof_bits + 8 < SRSLTE_UCI_MAX_CQI_LEN_PUSCH && q != NULL && data != NULL && q_bits != NULL) { + if (nof_bits + 8 < SRSRAN_UCI_MAX_CQI_LEN_PUSCH && q != NULL && data != NULL && q_bits != NULL) { int poly[3] = {0x6D, 0x4F, 0x57}; encoder.K = 7; encoder.R = 3; @@ -225,47 +225,47 @@ int encode_cqi_long(srslte_uci_cqi_pusch_t* q, uint8_t* data, uint32_t nof_bits, memcpy(encoder.poly, poly, 3 * sizeof(int)); memcpy(q->tmp_cqi, data, sizeof(uint8_t) * nof_bits); - srslte_crc_attach(&q->crc, q->tmp_cqi, nof_bits); + srsran_crc_attach(&q->crc, q->tmp_cqi, nof_bits); DEBUG("cqi_crc_tx="); - if (SRSLTE_VERBOSE_ISDEBUG()) { - srslte_vec_fprint_b(stdout, q->tmp_cqi, nof_bits + 8); + if (SRSRAN_VERBOSE_ISDEBUG()) { + srsran_vec_fprint_b(stdout, q->tmp_cqi, nof_bits + 8); } - srslte_convcoder_encode(&encoder, q->tmp_cqi, q->encoded_cqi, nof_bits + 8); + srsran_convcoder_encode(&encoder, q->tmp_cqi, q->encoded_cqi, nof_bits + 8); DEBUG("cconv_tx="); - if (SRSLTE_VERBOSE_ISDEBUG()) { - srslte_vec_fprint_b(stdout, q->encoded_cqi, 3 * (nof_bits + 8)); + if (SRSRAN_VERBOSE_ISDEBUG()) { + srsran_vec_fprint_b(stdout, q->encoded_cqi, 3 * (nof_bits + 8)); } - srslte_rm_conv_tx(q->encoded_cqi, 3 * (nof_bits + 8), q_bits, Q); + srsran_rm_conv_tx(q->encoded_cqi, 3 * (nof_bits + 8), q_bits, Q); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } else { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } } -int decode_cqi_long(srslte_uci_cqi_pusch_t* q, int16_t* q_bits, uint32_t Q, uint8_t* data, uint32_t nof_bits) +int decode_cqi_long(srsran_uci_cqi_pusch_t* q, int16_t* q_bits, uint32_t Q, uint8_t* data, uint32_t nof_bits) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; - if (nof_bits + 8 < SRSLTE_UCI_MAX_CQI_LEN_PUSCH && q != NULL && data != NULL && q_bits != NULL) { - srslte_rm_conv_rx_s(q_bits, Q, q->encoded_cqi_s, 3 * (nof_bits + 8)); + int ret = SRSRAN_ERROR_INVALID_INPUTS; + if (nof_bits + 8 < SRSRAN_UCI_MAX_CQI_LEN_PUSCH && q != NULL && data != NULL && q_bits != NULL) { + srsran_rm_conv_rx_s(q_bits, Q, q->encoded_cqi_s, 3 * (nof_bits + 8)); DEBUG("cconv_rx="); - if (SRSLTE_VERBOSE_ISDEBUG()) { - srslte_vec_fprint_s(stdout, q->encoded_cqi_s, 3 * (nof_bits + 8)); + if (SRSRAN_VERBOSE_ISDEBUG()) { + srsran_vec_fprint_s(stdout, q->encoded_cqi_s, 3 * (nof_bits + 8)); } - srslte_viterbi_decode_s(&q->viterbi, q->encoded_cqi_s, q->tmp_cqi, nof_bits + 8); + srsran_viterbi_decode_s(&q->viterbi, q->encoded_cqi_s, q->tmp_cqi, nof_bits + 8); DEBUG("cqi_crc_rx="); - if (SRSLTE_VERBOSE_ISDEBUG()) { - srslte_vec_fprint_b(stdout, q->tmp_cqi, nof_bits + 8); + if (SRSRAN_VERBOSE_ISDEBUG()) { + srsran_vec_fprint_b(stdout, q->tmp_cqi, nof_bits + 8); } - ret = srslte_crc_checksum(&q->crc, q->tmp_cqi, nof_bits + 8); + ret = srsran_crc_checksum(&q->crc, q->tmp_cqi, nof_bits + 8); if (ret == 0) { memcpy(data, q->tmp_cqi, nof_bits * sizeof(uint8_t)); ret = 1; @@ -278,8 +278,8 @@ int decode_cqi_long(srslte_uci_cqi_pusch_t* q, int16_t* q_bits, uint32_t Q, uint /* Encode UCI CQI/PMI */ -int srslte_uci_decode_cqi_pusch(srslte_uci_cqi_pusch_t* q, - srslte_pusch_cfg_t* cfg, +int srsran_uci_decode_cqi_pusch(srsran_uci_cqi_pusch_t* q, + srsran_pusch_cfg_t* cfg, int16_t* q_bits, float beta, uint32_t Q_prime_ri, @@ -292,9 +292,9 @@ int srslte_uci_decode_cqi_pusch(srslte_uci_cqi_pusch_t* q, return -1; } uint32_t Q_prime = Q_prime_cqi(cfg, cqi_len, beta, Q_prime_ri); - uint32_t Qm = srslte_mod_bits_x_symbol(cfg->grant.tb.mod); + uint32_t Qm = srsran_mod_bits_x_symbol(cfg->grant.tb.mod); - int ret = SRSLTE_ERROR; + int ret = SRSRAN_ERROR; if (cqi_len <= 11) { ret = decode_cqi_short(q, q_bits, Q_prime * Qm, cqi_data, cqi_len); if (cqi_ack) { @@ -322,8 +322,8 @@ int srslte_uci_decode_cqi_pusch(srslte_uci_cqi_pusch_t* q, /* Encode UCI CQI/PMI as described in 5.2.2.6 of 36.212 */ -int srslte_uci_encode_cqi_pusch(srslte_uci_cqi_pusch_t* q, - srslte_pusch_cfg_t* cfg, +int srsran_uci_encode_cqi_pusch(srsran_uci_cqi_pusch_t* q, + srsran_pusch_cfg_t* cfg, uint8_t* cqi_data, uint32_t cqi_len, float beta, @@ -336,9 +336,9 @@ int srslte_uci_encode_cqi_pusch(srslte_uci_cqi_pusch_t* q, } uint32_t Q_prime = Q_prime_cqi(cfg, cqi_len, beta, Q_prime_ri); - uint32_t Qm = srslte_mod_bits_x_symbol(cfg->grant.tb.mod); + uint32_t Qm = srsran_mod_bits_x_symbol(cfg->grant.tb.mod); - int ret = SRSLTE_ERROR; + int ret = SRSRAN_ERROR; if (cqi_len <= 11) { ret = encode_cqi_short(q, cqi_data, cqi_len, q_bits, Q_prime * Qm); } else { @@ -356,7 +356,7 @@ static int uci_ulsch_interleave_ack_gen(uint32_t ack_q_bit_idx, uint32_t Qm, uint32_t H_prime_total, uint32_t N_pusch_symbs, - srslte_uci_bit_t* ack_bits) + srsran_uci_bit_t* ack_bits) { const uint32_t ack_column_set_norm[4] = {2, 3, 8, 9}; const uint32_t ack_column_set_ext[4] = {1, 2, 6, 7}; @@ -368,13 +368,13 @@ static int uci_ulsch_interleave_ack_gen(uint32_t ack_q_bit_idx, for (uint32_t k = 0; k < Qm; k++) { ack_bits[k].position = row * Qm + (H_prime_total / N_pusch_symbs) * col * Qm + k; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } else { ERROR("Error interleaving UCI-ACK bit idx %d for H_prime_total=%d and N_pusch_symbs=%d", ack_q_bit_idx, H_prime_total, N_pusch_symbs); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } @@ -383,7 +383,7 @@ static int uci_ulsch_interleave_ri_gen(uint32_t ri_q_bit_idx, uint32_t Qm, uint32_t H_prime_total, uint32_t N_pusch_symbs, - srslte_uci_bit_t* ri_bits) + srsran_uci_bit_t* ri_bits) { static uint32_t ri_column_set_norm[4] = {1, 4, 7, 10}; static uint32_t ri_column_set_ext[4] = {0, 3, 5, 8}; @@ -396,17 +396,17 @@ static int uci_ulsch_interleave_ri_gen(uint32_t ri_q_bit_idx, for (uint32_t k = 0; k < Qm; k++) { ri_bits[k].position = row * Qm + (H_prime_total / N_pusch_symbs) * col * Qm + k; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } else { ERROR("Error interleaving UCI-RI bit idx %d for H_prime_total=%d and N_pusch_symbs=%d", ri_q_bit_idx, H_prime_total, N_pusch_symbs); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } -static uint32_t Q_prime_ri_ack(srslte_pusch_cfg_t* cfg, uint32_t O, uint32_t O_cqi, float beta) +static uint32_t Q_prime_ri_ack(srsran_pusch_cfg_t* cfg, uint32_t O, uint32_t O_cqi, float beta) { if (beta < 0) { ERROR("Error beta is reserved"); @@ -424,23 +424,23 @@ static uint32_t Q_prime_ri_ack(srslte_pusch_cfg_t* cfg, uint32_t O, uint32_t O_c } } - uint32_t x = (uint32_t)ceilf((float)O * cfg->grant.L_prb * SRSLTE_NRE * cfg->grant.nof_symb * beta / K); + uint32_t x = (uint32_t)ceilf((float)O * cfg->grant.L_prb * SRSRAN_NRE * cfg->grant.nof_symb * beta / K); - uint32_t Q_prime = SRSLTE_MIN(x, 4 * cfg->grant.L_prb * SRSLTE_NRE); + uint32_t Q_prime = SRSRAN_MIN(x, 4 * cfg->grant.L_prb * SRSRAN_NRE); return Q_prime; } -uint32_t srslte_qprime_ack_ext(uint32_t L_prb, uint32_t nof_symbols, uint32_t tbs, uint32_t nof_ack, float beta) +uint32_t srsran_qprime_ack_ext(uint32_t L_prb, uint32_t nof_symbols, uint32_t tbs, uint32_t nof_ack, float beta) { - srslte_pusch_cfg_t cfg = {}; + srsran_pusch_cfg_t cfg = {}; cfg.grant.L_prb = L_prb; cfg.grant.nof_symb = nof_symbols; cfg.K_segm = tbs; return Q_prime_ri_ack(&cfg, nof_ack, 0, beta); } -static uint32_t encode_ri_ack(const uint8_t data[2], uint32_t O_ack, uint8_t Qm, srslte_uci_bit_t* q_encoded_bits) +static uint32_t encode_ri_ack(const uint8_t data[2], uint32_t O_ack, uint8_t Qm, srsran_uci_bit_t* q_encoded_bits) { uint32_t i = 0; @@ -472,24 +472,24 @@ static uint32_t encode_ri_ack(const uint8_t data[2], uint32_t O_ack, uint8_t Qm, } static uint32_t -encode_ack_long(const uint8_t* data, uint32_t O_ack, uint8_t Q_m, uint32_t Q_prime, srslte_uci_bit_t* q_encoded_bits) +encode_ack_long(const uint8_t* data, uint32_t O_ack, uint8_t Q_m, uint32_t Q_prime, srsran_uci_bit_t* q_encoded_bits) { uint32_t Q_ack = Q_m * Q_prime; - if (O_ack > SRSLTE_UCI_MAX_ACK_BITS) { - ERROR("Error encoding long ACK bits: O_ack can't be higher than %d", SRSLTE_UCI_MAX_ACK_BITS); + if (O_ack > SRSRAN_UCI_MAX_ACK_BITS) { + ERROR("Error encoding long ACK bits: O_ack can't be higher than %d", SRSRAN_UCI_MAX_ACK_BITS); return 0; } // Encoded bits - uint8_t q[SRSLTE_FEC_BLOCK_SIZE] = {}; + uint8_t q[SRSRAN_FEC_BLOCK_SIZE] = {}; // Encode - srslte_block_encode(data, O_ack, q, SRSLTE_FEC_BLOCK_SIZE); + srsran_block_encode(data, O_ack, q, SRSRAN_FEC_BLOCK_SIZE); // Convert to UCI bits for (uint32_t i = 0; i < Q_ack; i++) { - q_encoded_bits[i].type = q[i % SRSLTE_FEC_BLOCK_SIZE] ? UCI_BIT_1 : UCI_BIT_0; + q_encoded_bits[i].type = q[i % SRSRAN_FEC_BLOCK_SIZE] ? UCI_BIT_1 : UCI_BIT_0; } return Q_ack; @@ -531,7 +531,7 @@ static int32_t decode_ri_ack_2bits(const int16_t* llr, uint32_t Qm, uint8_t data // Table 5.2.2.6-A const static uint8_t w_scram[4][4] = {{1, 1, 1, 1}, {1, 0, 1, 0}, {1, 1, 0, 0}, {1, 0, 0, 1}}; -static void uci_ack_scramble_tdd(srslte_uci_bit_t* q, uint32_t O_ack, uint32_t Q_ack, uint32_t N_bundle) +static void uci_ack_scramble_tdd(srsran_uci_bit_t* q, uint32_t O_ack, uint32_t Q_ack, uint32_t N_bundle) { if (N_bundle == 0) { return; @@ -541,7 +541,7 @@ static void uci_ack_scramble_tdd(srslte_uci_bit_t* q, uint32_t O_ack, uint32_t Q uint32_t m = O_ack == 1 ? 1 : 3; - srslte_uci_bit_type_t q_m1 = q[0].type; + srsran_uci_bit_type_t q_m1 = q[0].type; uint32_t k = 0; for (uint32_t i = 0; i < Q_ack; i++) { switch (q[i].type) { @@ -567,7 +567,7 @@ static void uci_ack_scramble_tdd(srslte_uci_bit_t* q, uint32_t O_ack, uint32_t Q /* Encode UCI ACK/RI bits as described in 5.2.2.6 of 36.212 * Currently only supporting 1-bit RI */ -int srslte_uci_encode_ack_ri(srslte_pusch_cfg_t* cfg, +int srsran_uci_encode_ack_ri(srsran_pusch_cfg_t* cfg, uint8_t* data, uint32_t O_ack, uint32_t O_cqi, @@ -575,7 +575,7 @@ int srslte_uci_encode_ack_ri(srslte_pusch_cfg_t* cfg, uint32_t H_prime_total, bool input_is_ri, uint32_t N_bundle, - srslte_uci_bit_t* bits) + srsran_uci_bit_t* bits) { if (beta < 0) { ERROR("Error beta is reserved"); @@ -584,7 +584,7 @@ int srslte_uci_encode_ack_ri(srslte_pusch_cfg_t* cfg, uint32_t Q_prime = Q_prime_ri_ack(cfg, O_ack, O_cqi, beta); uint32_t Q_ack = 0; - uint32_t Qm = srslte_mod_bits_x_symbol(cfg->grant.tb.mod); + uint32_t Qm = srsran_mod_bits_x_symbol(cfg->grant.tb.mod); if (O_ack < 3) { uint32_t enc_len = encode_ri_ack(data, O_ack, Qm, bits); @@ -620,13 +620,13 @@ int srslte_uci_encode_ack_ri(srslte_pusch_cfg_t* cfg, /* Decode UCI ACK/RI bits as described in 5.2.2.6 of 36.212 * Currently only supporting 1-bit RI */ -int srslte_uci_decode_ack_ri(srslte_pusch_cfg_t* cfg, +int srsran_uci_decode_ack_ri(srsran_pusch_cfg_t* cfg, int16_t* q_bits, uint8_t* c_seq, float beta, uint32_t H_prime_total, uint32_t O_cqi, - srslte_uci_bit_t* ack_ri_bits, + srsran_uci_bit_t* ack_ri_bits, uint8_t* data, bool* valid, uint32_t nof_bits, @@ -634,15 +634,15 @@ int srslte_uci_decode_ack_ri(srslte_pusch_cfg_t* cfg, { if (beta < 0) { ERROR("Error beta (%f) is reserved", beta); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } uint32_t Qprime = Q_prime_ri_ack(cfg, nof_bits, O_cqi, beta); - uint32_t Qm = srslte_mod_bits_x_symbol(cfg->grant.tb.mod); + uint32_t Qm = srsran_mod_bits_x_symbol(cfg->grant.tb.mod); int16_t llr_acc[32] = {}; ///< LLR accumulator uint32_t nof_acc = - (nof_bits == 1) ? Qm : (nof_bits == 2) ? Qm * 3 : SRSLTE_FEC_BLOCK_SIZE; ///< Number of required LLR + (nof_bits == 1) ? Qm : (nof_bits == 2) ? Qm * 3 : SRSRAN_FEC_BLOCK_SIZE; ///< Number of required LLR uint32_t count_acc = 0; ///< LLR counter for (uint32_t i = 0; i < Qprime; i++) { @@ -671,8 +671,8 @@ int srslte_uci_decode_ack_ri(srslte_pusch_cfg_t* cfg, llr_acc[acc_idx] += q; /// Limit accumulator boundaries - llr_acc[acc_idx] = SRSLTE_MIN(llr_acc[acc_idx], INT16_MAX / 2); - llr_acc[acc_idx] = SRSLTE_MAX(llr_acc[acc_idx], -INT16_MAX / 2); + llr_acc[acc_idx] = SRSRAN_MIN(llr_acc[acc_idx], INT16_MAX / 2); + llr_acc[acc_idx] = SRSRAN_MAX(llr_acc[acc_idx], -INT16_MAX / 2); } } @@ -688,7 +688,7 @@ int srslte_uci_decode_ack_ri(srslte_pusch_cfg_t* cfg, break; default: // For more than 2 bits... - corr = srslte_block_decode_i16(llr_acc, SRSLTE_FEC_BLOCK_SIZE, data, nof_bits); + corr = srsran_block_decode_i16(llr_acc, SRSRAN_FEC_BLOCK_SIZE, data, nof_bits); } if (valid) { @@ -698,54 +698,54 @@ int srslte_uci_decode_ack_ri(srslte_pusch_cfg_t* cfg, return (int)Qprime; } -uint32_t srslte_uci_cfg_total_ack(const srslte_uci_cfg_t* uci_cfg) +uint32_t srsran_uci_cfg_total_ack(const srsran_uci_cfg_t* uci_cfg) { uint32_t nof_ack = 0; - for (uint32_t i = 0; i < SRSLTE_MAX_CARRIERS; i++) { + for (uint32_t i = 0; i < SRSRAN_MAX_CARRIERS; i++) { nof_ack += uci_cfg->ack[i].nof_acks; } return nof_ack; } -void srslte_uci_data_reset(srslte_uci_data_t* uci_data) +void srsran_uci_data_reset(srsran_uci_data_t* uci_data) { - bzero(uci_data, sizeof(srslte_uci_data_t)); + bzero(uci_data, sizeof(srsran_uci_data_t)); /* Set all ACKs to DTX */ - memset(uci_data->value.ack.ack_value, 2, SRSLTE_UCI_MAX_ACK_BITS); + memset(uci_data->value.ack.ack_value, 2, SRSRAN_UCI_MAX_ACK_BITS); } -int srslte_uci_data_info(srslte_uci_cfg_t* uci_cfg, srslte_uci_value_t* uci_data, char* str, uint32_t str_len) +int srsran_uci_data_info(srsran_uci_cfg_t* uci_cfg, srsran_uci_value_t* uci_data, char* str, uint32_t str_len) { int n = 0; if (uci_cfg->is_scheduling_request_tti) { - n = srslte_print_check(str, str_len, n, ", sr=%s", uci_data->scheduling_request ? "yes" : "no"); + n = srsran_print_check(str, str_len, n, ", sr=%s", uci_data->scheduling_request ? "yes" : "no"); } - uint32_t nof_acks = srslte_uci_cfg_total_ack(uci_cfg); + uint32_t nof_acks = srsran_uci_cfg_total_ack(uci_cfg); if (nof_acks) { - n = srslte_print_check(str, str_len, n, ", ack="); + n = srsran_print_check(str, str_len, n, ", ack="); if (uci_data->ack.valid) { for (uint32_t i = 0; i < nof_acks; i++) { - n = srslte_print_check(str, str_len, n, "%d", uci_data->ack.ack_value[i]); + n = srsran_print_check(str, str_len, n, "%d", uci_data->ack.ack_value[i]); } if (uci_cfg->ack[0].N_bundle) { - n = srslte_print_check(str, str_len, n, ", n_bundle=%d", uci_cfg->ack[0].N_bundle); + n = srsran_print_check(str, str_len, n, ", n_bundle=%d", uci_cfg->ack[0].N_bundle); } } else { - n = srslte_print_check(str, str_len, n, "invalid"); + n = srsran_print_check(str, str_len, n, "invalid"); } } if (uci_cfg->cqi.ri_len) { - n = srslte_print_check(str, str_len, n, ", ri=%d", uci_data->ri); + n = srsran_print_check(str, str_len, n, ", ri=%d", uci_data->ri); } if (uci_cfg->cqi.data_enable) { - char cqi_str[SRSLTE_CQI_STR_MAX_CHAR] = ""; - srslte_cqi_value_tostring(&uci_cfg->cqi, &uci_data->cqi, cqi_str, SRSLTE_CQI_STR_MAX_CHAR); - n = srslte_print_check(str, str_len, n, "%s (cc=%d)", cqi_str, uci_cfg->cqi.scell_index); + char cqi_str[SRSRAN_CQI_STR_MAX_CHAR] = ""; + srsran_cqi_value_tostring(&uci_cfg->cqi, &uci_data->cqi, cqi_str, SRSRAN_CQI_STR_MAX_CHAR); + n = srsran_print_check(str, str_len, n, "%s (cc=%d)", cqi_str, uci_cfg->cqi.scell_index); } return n; diff --git a/lib/src/phy/phch/uci_nr.c b/lib/src/phy/phch/uci_nr.c index 04387ff6b..75506d1e9 100644 --- a/lib/src/phy/phch/uci_nr.c +++ b/lib/src/phy/phch/uci_nr.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,13 +10,13 @@ * */ -#include "srslte/phy/phch/uci_nr.h" -#include "srslte/phy/fec/block/block.h" -#include "srslte/phy/fec/polar/polar_chanalloc.h" -#include "srslte/phy/phch/csi.h" -#include "srslte/phy/phch/uci_cfg.h" -#include "srslte/phy/utils/bit.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/phch/uci_nr.h" +#include "srsran/phy/fec/block/block.h" +#include "srsran/phy/fec/polar/polar_chanalloc.h" +#include "srsran/phy/phch/csi.h" +#include "srsran/phy/phch/uci_cfg.h" +#include "srsran/phy/utils/bit.h" +#include "srsran/phy/utils/vector.h" #define UCI_NR_INFO_TX(...) INFO("UCI-NR Tx: " __VA_ARGS__) #define UCI_NR_INFO_RX(...) INFO("UCI-NR Rx: " __VA_ARGS__) @@ -28,85 +28,85 @@ #define UCI_NR_BLOCK_DEFAULT_CORR_THRESHOLD 0.5f #define UCI_NR_ONE_BIT_CORR_THRESHOLD 0.5f -uint32_t srslte_uci_nr_crc_len(uint32_t A) +uint32_t srsran_uci_nr_crc_len(uint32_t A) { return (A <= 11) ? 0 : (A < 20) ? 6 : 11; } -int srslte_uci_nr_init(srslte_uci_nr_t* q, const srslte_uci_nr_args_t* args) +int srsran_uci_nr_init(srsran_uci_nr_t* q, const srsran_uci_nr_args_t* args) { if (q == NULL || args == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } - srslte_polar_encoder_type_t polar_encoder_type = SRSLTE_POLAR_ENCODER_PIPELINED; - srslte_polar_decoder_type_t polar_decoder_type = SRSLTE_POLAR_DECODER_SSC_C; + srsran_polar_encoder_type_t polar_encoder_type = SRSRAN_POLAR_ENCODER_PIPELINED; + srsran_polar_decoder_type_t polar_decoder_type = SRSRAN_POLAR_DECODER_SSC_C; #ifdef LV_HAVE_AVX2 if (!args->disable_simd) { - polar_encoder_type = SRSLTE_POLAR_ENCODER_AVX2; - polar_decoder_type = SRSLTE_POLAR_DECODER_SSC_C_AVX2; + polar_encoder_type = SRSRAN_POLAR_ENCODER_AVX2; + polar_decoder_type = SRSRAN_POLAR_DECODER_SSC_C_AVX2; } #endif // LV_HAVE_AVX2 - if (srslte_polar_code_init(&q->code)) { + if (srsran_polar_code_init(&q->code)) { ERROR("Initialising polar code"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_polar_encoder_init(&q->encoder, polar_encoder_type, NMAX_LOG) < SRSLTE_SUCCESS) { + if (srsran_polar_encoder_init(&q->encoder, polar_encoder_type, NMAX_LOG) < SRSRAN_SUCCESS) { ERROR("Initialising polar encoder"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_polar_decoder_init(&q->decoder, polar_decoder_type, NMAX_LOG) < SRSLTE_SUCCESS) { + if (srsran_polar_decoder_init(&q->decoder, polar_decoder_type, NMAX_LOG) < SRSRAN_SUCCESS) { ERROR("Initialising polar encoder"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_polar_rm_tx_init(&q->rm_tx) < SRSLTE_SUCCESS) { + if (srsran_polar_rm_tx_init(&q->rm_tx) < SRSRAN_SUCCESS) { ERROR("Initialising polar RM"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_polar_rm_rx_init_c(&q->rm_rx) < SRSLTE_SUCCESS) { + if (srsran_polar_rm_rx_init_c(&q->rm_rx) < SRSRAN_SUCCESS) { ERROR("Initialising polar RM"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_crc_init(&q->crc6, SRSLTE_LTE_CRC6, 6) < SRSLTE_SUCCESS) { + if (srsran_crc_init(&q->crc6, SRSRAN_LTE_CRC6, 6) < SRSRAN_SUCCESS) { ERROR("Initialising CRC"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_crc_init(&q->crc11, SRSLTE_LTE_CRC11, 11) < SRSLTE_SUCCESS) { + if (srsran_crc_init(&q->crc11, SRSRAN_LTE_CRC11, 11) < SRSRAN_SUCCESS) { ERROR("Initialising CRC"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Allocate bit sequence with space for the CRC - q->bit_sequence = srslte_vec_u8_malloc(SRSLTE_UCI_NR_MAX_NOF_BITS); + q->bit_sequence = srsran_vec_u8_malloc(SRSRAN_UCI_NR_MAX_NOF_BITS); if (q->bit_sequence == NULL) { ERROR("Error malloc"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Allocate c with space for a and the CRC - q->c = srslte_vec_u8_malloc(SRSLTE_UCI_NR_MAX_NOF_BITS + UCI_NR_MAX_L); + q->c = srsran_vec_u8_malloc(SRSRAN_UCI_NR_MAX_NOF_BITS + UCI_NR_MAX_L); if (q->c == NULL) { ERROR("Error malloc"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - q->allocated = srslte_vec_u8_malloc(UCI_NR_POLAR_MAX); + q->allocated = srsran_vec_u8_malloc(UCI_NR_POLAR_MAX); if (q->allocated == NULL) { ERROR("Error malloc"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - q->d = srslte_vec_u8_malloc(UCI_NR_POLAR_MAX); + q->d = srsran_vec_u8_malloc(UCI_NR_POLAR_MAX); if (q->d == NULL) { ERROR("Error malloc"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (isnormal(args->block_code_threshold)) { @@ -120,20 +120,20 @@ int srslte_uci_nr_init(srslte_uci_nr_t* q, const srslte_uci_nr_args_t* args) q->one_bit_threshold = UCI_NR_ONE_BIT_CORR_THRESHOLD; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -void srslte_uci_nr_free(srslte_uci_nr_t* q) +void srsran_uci_nr_free(srsran_uci_nr_t* q) { if (q == NULL) { return; } - srslte_polar_code_free(&q->code); - srslte_polar_encoder_free(&q->encoder); - srslte_polar_decoder_free(&q->decoder); - srslte_polar_rm_tx_free(&q->rm_tx); - srslte_polar_rm_rx_free_c(&q->rm_rx); + srsran_polar_code_free(&q->code); + srsran_polar_encoder_free(&q->encoder); + srsran_polar_decoder_free(&q->decoder); + srsran_polar_rm_tx_free(&q->rm_tx); + srsran_polar_rm_rx_free_c(&q->rm_rx); if (q->bit_sequence != NULL) { free(q->bit_sequence); @@ -148,111 +148,111 @@ void srslte_uci_nr_free(srslte_uci_nr_t* q) free(q->d); } - SRSLTE_MEM_ZERO(q, srslte_uci_nr_t, 1); + SRSRAN_MEM_ZERO(q, srsran_uci_nr_t, 1); } -static int uci_nr_pack_ack_sr(const srslte_uci_cfg_nr_t* cfg, const srslte_uci_value_nr_t* value, uint8_t* sequence) +static int uci_nr_pack_ack_sr(const srsran_uci_cfg_nr_t* cfg, const srsran_uci_value_nr_t* value, uint8_t* sequence) { int A = 0; // Append ACK bits - srslte_vec_u8_copy(&sequence[A], value->ack, cfg->o_ack); + srsran_vec_u8_copy(&sequence[A], value->ack, cfg->o_ack); A += cfg->o_ack; // Append SR bits uint8_t* bits = &sequence[A]; - srslte_bit_unpack(value->sr, &bits, cfg->o_sr); + srsran_bit_unpack(value->sr, &bits, cfg->o_sr); A += cfg->o_sr; - if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_INFO && !handler_registered) { + if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_INFO && !handler_registered) { UCI_NR_INFO_TX("Packed UCI bits: "); - srslte_vec_fprint_byte(stdout, sequence, A); + srsran_vec_fprint_byte(stdout, sequence, A); } return A; } -static int uci_nr_unpack_ack_sr(const srslte_uci_cfg_nr_t* cfg, uint8_t* sequence, srslte_uci_value_nr_t* value) +static int uci_nr_unpack_ack_sr(const srsran_uci_cfg_nr_t* cfg, uint8_t* sequence, srsran_uci_value_nr_t* value) { int A = 0; // Append ACK bits - srslte_vec_u8_copy(value->ack, &sequence[A], cfg->o_ack); + srsran_vec_u8_copy(value->ack, &sequence[A], cfg->o_ack); A += cfg->o_ack; // Append SR bits uint8_t* bits = &sequence[A]; - value->sr = srslte_bit_pack(&bits, cfg->o_sr); + value->sr = srsran_bit_pack(&bits, cfg->o_sr); A += cfg->o_sr; - if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_INFO && !handler_registered) { + if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_INFO && !handler_registered) { UCI_NR_INFO_RX("Unpacked UCI bits: "); - srslte_vec_fprint_byte(stdout, sequence, A); + srsran_vec_fprint_byte(stdout, sequence, A); } return A; } -static int uci_nr_pack_ack_sr_csi(const srslte_uci_cfg_nr_t* cfg, const srslte_uci_value_nr_t* value, uint8_t* sequence) +static int uci_nr_pack_ack_sr_csi(const srsran_uci_cfg_nr_t* cfg, const srsran_uci_value_nr_t* value, uint8_t* sequence) { int A = 0; // Append ACK bits - srslte_vec_u8_copy(&sequence[A], value->ack, cfg->o_ack); + srsran_vec_u8_copy(&sequence[A], value->ack, cfg->o_ack); A += cfg->o_ack; // Append SR bits uint8_t* bits = &sequence[A]; - srslte_bit_unpack(value->sr, &bits, cfg->o_sr); + srsran_bit_unpack(value->sr, &bits, cfg->o_sr); A += cfg->o_sr; // Append CSI bits - int n = srslte_csi_part1_pack(cfg->csi, value->csi, cfg->nof_csi, bits, SRSLTE_UCI_NR_MAX_NOF_BITS - A); - if (n < SRSLTE_SUCCESS) { + int n = srsran_csi_part1_pack(cfg->csi, value->csi, cfg->nof_csi, bits, SRSRAN_UCI_NR_MAX_NOF_BITS - A); + if (n < SRSRAN_SUCCESS) { ERROR("Packing CSI part 1"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } A += n; - if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_INFO && !handler_registered) { + if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_INFO && !handler_registered) { UCI_NR_INFO_TX("Packed UCI bits: "); - srslte_vec_fprint_byte(stdout, sequence, A); + srsran_vec_fprint_byte(stdout, sequence, A); } return A; } -static int uci_nr_unpack_ack_sr_csi(const srslte_uci_cfg_nr_t* cfg, uint8_t* sequence, srslte_uci_value_nr_t* value) +static int uci_nr_unpack_ack_sr_csi(const srsran_uci_cfg_nr_t* cfg, uint8_t* sequence, srsran_uci_value_nr_t* value) { int A = 0; // Append ACK bits - srslte_vec_u8_copy(value->ack, &sequence[A], cfg->o_ack); + srsran_vec_u8_copy(value->ack, &sequence[A], cfg->o_ack); A += cfg->o_ack; // Append SR bits uint8_t* bits = &sequence[A]; - value->sr = srslte_bit_pack(&bits, cfg->o_sr); + value->sr = srsran_bit_pack(&bits, cfg->o_sr); A += cfg->o_sr; - if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_INFO && !handler_registered) { + if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_INFO && !handler_registered) { UCI_NR_INFO_RX("Unpacked UCI bits: "); - srslte_vec_fprint_byte(stdout, sequence, A); + srsran_vec_fprint_byte(stdout, sequence, A); } // Append CSI bits - int n = srslte_csi_part1_unpack(cfg->csi, cfg->nof_csi, bits, SRSLTE_UCI_NR_MAX_NOF_BITS - A, value->csi); - if (n < SRSLTE_SUCCESS) { + int n = srsran_csi_part1_unpack(cfg->csi, cfg->nof_csi, bits, SRSRAN_UCI_NR_MAX_NOF_BITS - A, value->csi); + if (n < SRSRAN_SUCCESS) { ERROR("Packing CSI part 1"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } return A; } -static int uci_nr_A(const srslte_uci_cfg_nr_t* cfg) +static int uci_nr_A(const srsran_uci_cfg_nr_t* cfg) { - int o_csi = srslte_csi_part1_nof_bits(cfg->csi, cfg->nof_csi); + int o_csi = srsran_csi_part1_nof_bits(cfg->csi, cfg->nof_csi); // 6.3.1.1.1 HARQ-ACK/SR only UCI bit sequence generation if (o_csi == 0) { @@ -266,12 +266,12 @@ static int uci_nr_A(const srslte_uci_cfg_nr_t* cfg) // 6.3.1.1.3 HARQ-ACK/SR and CSI ERROR("HARQ-ACK/SR and CSI encoding are not implemented"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } -static int uci_nr_pack_pucch(const srslte_uci_cfg_nr_t* cfg, const srslte_uci_value_nr_t* value, uint8_t* sequence) +static int uci_nr_pack_pucch(const srsran_uci_cfg_nr_t* cfg, const srsran_uci_value_nr_t* value, uint8_t* sequence) { - int o_csi = srslte_csi_part1_nof_bits(cfg->csi, cfg->nof_csi); + int o_csi = srsran_csi_part1_nof_bits(cfg->csi, cfg->nof_csi); // 6.3.1.1.1 HARQ-ACK/SR only UCI bit sequence generation if (o_csi == 0) { @@ -280,16 +280,16 @@ static int uci_nr_pack_pucch(const srslte_uci_cfg_nr_t* cfg, const srslte_uci_va // 6.3.1.1.2 CSI only if (cfg->o_ack == 0 && cfg->o_sr == 0) { - return srslte_csi_part1_pack(cfg->csi, value->csi, cfg->nof_csi, sequence, SRSLTE_UCI_NR_MAX_NOF_BITS); + return srsran_csi_part1_pack(cfg->csi, value->csi, cfg->nof_csi, sequence, SRSRAN_UCI_NR_MAX_NOF_BITS); } // 6.3.1.1.3 HARQ-ACK/SR and CSI return uci_nr_pack_ack_sr_csi(cfg, value, sequence); } -static int uci_nr_unpack_pucch(const srslte_uci_cfg_nr_t* cfg, uint8_t* sequence, srslte_uci_value_nr_t* value) +static int uci_nr_unpack_pucch(const srsran_uci_cfg_nr_t* cfg, uint8_t* sequence, srsran_uci_value_nr_t* value) { - int o_csi = srslte_csi_part1_nof_bits(cfg->csi, cfg->nof_csi); + int o_csi = srsran_csi_part1_nof_bits(cfg->csi, cfg->nof_csi); // 6.3.1.1.1 HARQ-ACK/SR only UCI bit sequence generation if (o_csi == 0) { @@ -299,31 +299,31 @@ static int uci_nr_unpack_pucch(const srslte_uci_cfg_nr_t* cfg, uint8_t* sequence // 6.3.1.1.2 CSI only if (cfg->o_ack == 0 && cfg->o_sr == 0) { ERROR("CSI only are not implemented"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // 6.3.1.1.3 HARQ-ACK/SR and CSI return uci_nr_unpack_ack_sr_csi(cfg, sequence, value); } -static int uci_nr_encode_1bit(srslte_uci_nr_t* q, const srslte_uci_cfg_nr_t* cfg, uint8_t* o, uint32_t E) +static int uci_nr_encode_1bit(srsran_uci_nr_t* q, const srsran_uci_cfg_nr_t* cfg, uint8_t* o, uint32_t E) { uint32_t i = 0; - srslte_uci_bit_type_t c0 = (q->bit_sequence[0] == 0) ? UCI_BIT_0 : UCI_BIT_1; + srsran_uci_bit_type_t c0 = (q->bit_sequence[0] == 0) ? UCI_BIT_0 : UCI_BIT_1; switch (cfg->pusch.modulation) { - case SRSLTE_MOD_BPSK: + case SRSRAN_MOD_BPSK: while (i < E) { o[i++] = c0; } break; - case SRSLTE_MOD_QPSK: + case SRSRAN_MOD_QPSK: while (i < E) { o[i++] = c0; o[i++] = (uint8_t)UCI_BIT_REPETITION; } break; - case SRSLTE_MOD_16QAM: + case SRSRAN_MOD_16QAM: while (i < E) { o[i++] = c0; o[i++] = (uint8_t)UCI_BIT_REPETITION; @@ -331,7 +331,7 @@ static int uci_nr_encode_1bit(srslte_uci_nr_t* q, const srslte_uci_cfg_nr_t* cfg o[i++] = (uint8_t)UCI_BIT_PLACEHOLDER; } break; - case SRSLTE_MOD_64QAM: + case SRSRAN_MOD_64QAM: while (i < E) { while (i < E) { o[i++] = c0; @@ -343,7 +343,7 @@ static int uci_nr_encode_1bit(srslte_uci_nr_t* q, const srslte_uci_cfg_nr_t* cfg } } break; - case SRSLTE_MOD_256QAM: + case SRSRAN_MOD_256QAM: while (i < E) { o[i++] = c0; o[i++] = (uint8_t)UCI_BIT_REPETITION; @@ -355,31 +355,31 @@ static int uci_nr_encode_1bit(srslte_uci_nr_t* q, const srslte_uci_cfg_nr_t* cfg o[i++] = (uint8_t)UCI_BIT_PLACEHOLDER; } break; - case SRSLTE_MOD_NITEMS: + case SRSRAN_MOD_NITEMS: default: ERROR("Invalid modulation"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_INFO && !handler_registered) { + if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_INFO && !handler_registered) { UCI_NR_INFO_TX("One bit encoded NR-UCI; o="); - srslte_vec_fprint_b(stdout, o, E); + srsran_vec_fprint_b(stdout, o, E); } return E; } -static int uci_nr_decode_1_bit(srslte_uci_nr_t* q, - const srslte_uci_cfg_nr_t* cfg, +static int uci_nr_decode_1_bit(srsran_uci_nr_t* q, + const srsran_uci_cfg_nr_t* cfg, uint32_t A, const int8_t* llr, uint32_t E, bool* decoded_ok) { - uint32_t Qm = srslte_mod_bits_x_symbol(cfg->pusch.modulation); + uint32_t Qm = srsran_mod_bits_x_symbol(cfg->pusch.modulation); if (Qm == 0) { - ERROR("Invalid modulation (%s)", srslte_mod_string(cfg->pusch.modulation)); - return SRSLTE_ERROR; + ERROR("Invalid modulation (%s)", srsran_mod_string(cfg->pusch.modulation)); + return SRSRAN_ERROR; } // Correlate LLR @@ -400,9 +400,9 @@ static int uci_nr_decode_1_bit(srslte_uci_nr_t* q, // Save decoded bit q->bit_sequence[0] = (corr < 0) ? 0 : 1; - if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_INFO && !handler_registered) { + if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_INFO && !handler_registered) { UCI_NR_INFO_RX("One bit decoding NR-UCI llr="); - srslte_vec_fprint_bs(stdout, llr, E); + srsran_vec_fprint_bs(stdout, llr, E); UCI_NR_INFO_RX("One bit decoding NR-UCI A=%d; E=%d; pwr=%f; corr=%f; norm=%f; thr=%f; %s", A, E, @@ -413,10 +413,10 @@ static int uci_nr_decode_1_bit(srslte_uci_nr_t* q, *decoded_ok ? "OK" : "KO"); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -static int uci_nr_encode_2bit(srslte_uci_nr_t* q, const srslte_uci_cfg_nr_t* cfg, uint8_t* o, uint32_t E) +static int uci_nr_encode_2bit(srsran_uci_nr_t* q, const srsran_uci_cfg_nr_t* cfg, uint8_t* o, uint32_t E) { uint32_t i = 0; uint8_t c0 = (uint8_t)((q->bit_sequence[0] == 0) ? UCI_BIT_0 : UCI_BIT_1); @@ -424,15 +424,15 @@ static int uci_nr_encode_2bit(srslte_uci_nr_t* q, const srslte_uci_cfg_nr_t* cfg uint8_t c2 = (uint8_t)(((q->bit_sequence[0] ^ q->bit_sequence[1]) == 0) ? UCI_BIT_0 : UCI_BIT_1); switch (cfg->pusch.modulation) { - case SRSLTE_MOD_BPSK: - case SRSLTE_MOD_QPSK: + case SRSRAN_MOD_BPSK: + case SRSRAN_MOD_QPSK: while (i < E) { o[i++] = c0; o[i++] = c1; o[i++] = c2; } break; - case SRSLTE_MOD_16QAM: + case SRSRAN_MOD_16QAM: while (i < E) { o[i++] = c0; o[i++] = c1; @@ -448,7 +448,7 @@ static int uci_nr_encode_2bit(srslte_uci_nr_t* q, const srslte_uci_cfg_nr_t* cfg o[i++] = (uint8_t)UCI_BIT_PLACEHOLDER; } break; - case SRSLTE_MOD_64QAM: + case SRSRAN_MOD_64QAM: while (i < E) { o[i++] = c0; o[i++] = c1; @@ -470,7 +470,7 @@ static int uci_nr_encode_2bit(srslte_uci_nr_t* q, const srslte_uci_cfg_nr_t* cfg o[i++] = (uint8_t)UCI_BIT_PLACEHOLDER; } break; - case SRSLTE_MOD_256QAM: + case SRSRAN_MOD_256QAM: while (i < E) { o[i++] = c0; @@ -499,31 +499,31 @@ static int uci_nr_encode_2bit(srslte_uci_nr_t* q, const srslte_uci_cfg_nr_t* cfg o[i++] = (uint8_t)UCI_BIT_PLACEHOLDER; } break; - case SRSLTE_MOD_NITEMS: + case SRSRAN_MOD_NITEMS: default: ERROR("Invalid modulation"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_INFO && !handler_registered) { + if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_INFO && !handler_registered) { UCI_NR_INFO_TX("Two bit encoded NR-UCI; E=%d; o=", E); - srslte_vec_fprint_b(stdout, o, E); + srsran_vec_fprint_b(stdout, o, E); } return E; } -static int uci_nr_decode_2_bit(srslte_uci_nr_t* q, - const srslte_uci_cfg_nr_t* cfg, +static int uci_nr_decode_2_bit(srsran_uci_nr_t* q, + const srsran_uci_cfg_nr_t* cfg, uint32_t A, const int8_t* llr, uint32_t E, bool* decoded_ok) { - uint32_t Qm = srslte_mod_bits_x_symbol(cfg->pusch.modulation); + uint32_t Qm = srsran_mod_bits_x_symbol(cfg->pusch.modulation); if (Qm == 0) { - ERROR("Invalid modulation (%s)", srslte_mod_string(cfg->pusch.modulation)); - return SRSLTE_ERROR; + ERROR("Invalid modulation (%s)", srsran_mod_string(cfg->pusch.modulation)); + return SRSRAN_ERROR; } // Correlate LLR @@ -551,9 +551,9 @@ static int uci_nr_decode_2_bit(srslte_uci_nr_t* q, q->bit_sequence[0] = c0 ? 1 : 0; q->bit_sequence[1] = c1 ? 1 : 0; - if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_INFO && !handler_registered) { + if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_INFO && !handler_registered) { UCI_NR_INFO_RX("Two bit decoding NR-UCI llr="); - srslte_vec_fprint_bs(stdout, llr, E); + srsran_vec_fprint_bs(stdout, llr, E); UCI_NR_INFO_RX("Two bit decoding NR-UCI A=%d; E=%d; Qm=%d; c0=%d; c1=%d; c2=%d %s", A, E, @@ -564,24 +564,24 @@ static int uci_nr_decode_2_bit(srslte_uci_nr_t* q, *decoded_ok ? "OK" : "KO"); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } static int -uci_nr_encode_3_11_bit(srslte_uci_nr_t* q, const srslte_uci_cfg_nr_t* cfg, uint32_t A, uint8_t* o, uint32_t E) +uci_nr_encode_3_11_bit(srsran_uci_nr_t* q, const srsran_uci_cfg_nr_t* cfg, uint32_t A, uint8_t* o, uint32_t E) { - srslte_block_encode(q->bit_sequence, A, o, E); + srsran_block_encode(q->bit_sequence, A, o, E); - if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_INFO && !handler_registered) { + if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_INFO && !handler_registered) { UCI_NR_INFO_TX("Block encoded UCI bits; o="); - srslte_vec_fprint_b(stdout, o, E); + srsran_vec_fprint_b(stdout, o, E); } return E; } -static int uci_nr_decode_3_11_bit(srslte_uci_nr_t* q, - const srslte_uci_cfg_nr_t* cfg, +static int uci_nr_decode_3_11_bit(srsran_uci_nr_t* q, + const srsran_uci_cfg_nr_t* cfg, uint32_t A, const int8_t* llr, uint32_t E, @@ -589,23 +589,23 @@ static int uci_nr_decode_3_11_bit(srslte_uci_nr_t* q, { // Check E for avoiding zero division if (E < 1) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } if (A == 11 && E <= 16) { ERROR("NR-UCI Impossible to decode A=%d; E=%d", A, E); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Compute average LLR power - float pwr = srslte_vec_avg_power_bf(llr, E); + float pwr = srsran_vec_avg_power_bf(llr, E); if (!isnormal(pwr)) { ERROR("Received all zeros"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Decode - float corr = (float)srslte_block_decode_i8(llr, E, q->bit_sequence, A); + float corr = (float)srsran_block_decode_i8(llr, E, q->bit_sequence, A); // Normalise correlation float norm_corr = corr / (sqrtf(pwr) * E); @@ -613,9 +613,9 @@ static int uci_nr_decode_3_11_bit(srslte_uci_nr_t* q, // Take decoded decision with threshold *decoded_ok = (corr > q->block_code_threshold); - if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_INFO && !handler_registered) { + if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_INFO && !handler_registered) { UCI_NR_INFO_RX("Block decoding NR-UCI llr="); - srslte_vec_fprint_bs(stdout, llr, E); + srsran_vec_fprint_bs(stdout, llr, E); UCI_NR_INFO_RX("Block decoding NR-UCI A=%d; E=%d; pwr=%f; corr=%f; norm=%f; thr=%f; %s", A, E, @@ -626,11 +626,11 @@ static int uci_nr_decode_3_11_bit(srslte_uci_nr_t* q, *decoded_ok ? "OK" : "KO"); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } static int -uci_nr_encode_11_1706_bit(srslte_uci_nr_t* q, const srslte_uci_cfg_nr_t* cfg, uint32_t A, uint8_t* o, uint32_t E_uci) +uci_nr_encode_11_1706_bit(srsran_uci_nr_t* q, const srsran_uci_cfg_nr_t* cfg, uint32_t A, uint8_t* o, uint32_t E_uci) { // If ( A ≥ 360 and E ≥ 1088 ) or if A ≥ 1013 , I seg = 1 ; otherwise I seg = 0 uint32_t I_seg = 0; @@ -639,22 +639,22 @@ uci_nr_encode_11_1706_bit(srslte_uci_nr_t* q, const srslte_uci_cfg_nr_t* cfg, ui } // Select CRC - uint32_t L = srslte_uci_nr_crc_len(A); - srslte_crc_t* crc = (L == 6) ? &q->crc6 : &q->crc11; + uint32_t L = srsran_uci_nr_crc_len(A); + srsran_crc_t* crc = (L == 6) ? &q->crc6 : &q->crc11; // Segmentation uint32_t C = 1; if (I_seg == 1) { C = 2; } - uint32_t A_prime = SRSLTE_CEIL(A, C) * C; + uint32_t A_prime = SRSRAN_CEIL(A, C) * C; // Get polar code uint32_t K_r = A_prime / C + L; uint32_t E_r = E_uci / C; - if (srslte_polar_code_get(&q->code, K_r, E_r, UCI_NR_PUCCH_POLAR_N_MAX) < SRSLTE_SUCCESS) { + if (srsran_polar_code_get(&q->code, K_r, E_r, UCI_NR_PUCCH_POLAR_N_MAX) < SRSRAN_SUCCESS) { ERROR("Error computing Polar code"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Write codeword @@ -674,46 +674,46 @@ uci_nr_encode_11_1706_bit(srslte_uci_nr_t* q, const srslte_uci_cfg_nr_t* cfg, ui } // Attach CRC - srslte_crc_attach(crc, q->c, A_prime / C); - UCI_NR_INFO_TX("Attaching %d/%d CRC%d=%" PRIx64, r, C, L, srslte_crc_checksum_get(crc)); + srsran_crc_attach(crc, q->c, A_prime / C); + UCI_NR_INFO_TX("Attaching %d/%d CRC%d=%" PRIx64, r, C, L, srsran_crc_checksum_get(crc)); - if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_INFO && !handler_registered) { + if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_INFO && !handler_registered) { UCI_NR_INFO_TX("Polar cb %d/%d c=", r, C); - srslte_vec_fprint_byte(stdout, q->c, K_r); + srsran_vec_fprint_byte(stdout, q->c, K_r); } // Allocate channel - srslte_polar_chanalloc_tx(q->c, q->allocated, q->code.N, q->code.K, q->code.nPC, q->code.K_set, q->code.PC_set); + srsran_polar_chanalloc_tx(q->c, q->allocated, q->code.N, q->code.K, q->code.nPC, q->code.K_set, q->code.PC_set); - if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_INFO && !handler_registered) { + if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_INFO && !handler_registered) { UCI_NR_INFO_TX("Polar alloc %d/%d ", r, C); - srslte_vec_fprint_byte(stdout, q->allocated, q->code.N); + srsran_vec_fprint_byte(stdout, q->allocated, q->code.N); } // Encode bits - if (srslte_polar_encoder_encode(&q->encoder, q->allocated, q->d, q->code.n) < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (srsran_polar_encoder_encode(&q->encoder, q->allocated, q->d, q->code.n) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } - if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_INFO && !handler_registered) { + if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_INFO && !handler_registered) { UCI_NR_INFO_TX("Polar encoded %d/%d ", r, C); - srslte_vec_fprint_byte(stdout, q->d, q->code.N); + srsran_vec_fprint_byte(stdout, q->d, q->code.N); } // Rate matching - srslte_polar_rm_tx(&q->rm_tx, q->d, &o[E_r * r], q->code.n, E_r, K_r, UCI_NR_POLAR_RM_IBIL); + srsran_polar_rm_tx(&q->rm_tx, q->d, &o[E_r * r], q->code.n, E_r, K_r, UCI_NR_POLAR_RM_IBIL); - if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_INFO && !handler_registered) { + if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_INFO && !handler_registered) { UCI_NR_INFO_TX("Polar RM cw %d/%d ", r, C); - srslte_vec_fprint_byte(stdout, &o[E_r * r], E_r); + srsran_vec_fprint_byte(stdout, &o[E_r * r], E_r); } } return E_uci; } -static int uci_nr_decode_11_1706_bit(srslte_uci_nr_t* q, - const srslte_uci_cfg_nr_t* cfg, +static int uci_nr_decode_11_1706_bit(srsran_uci_nr_t* q, + const srsran_uci_cfg_nr_t* cfg, uint32_t A, int8_t* llr, uint32_t E_uci, @@ -728,21 +728,21 @@ static int uci_nr_decode_11_1706_bit(srslte_uci_nr_t* q, } // Select CRC - uint32_t L = srslte_uci_nr_crc_len(A); - srslte_crc_t* crc = (L == 6) ? &q->crc6 : &q->crc11; + uint32_t L = srsran_uci_nr_crc_len(A); + srsran_crc_t* crc = (L == 6) ? &q->crc6 : &q->crc11; // Segmentation uint32_t C = 1; if (I_seg == 1) { C = 2; } - uint32_t A_prime = SRSLTE_CEIL(A, C) * C; + uint32_t A_prime = SRSRAN_CEIL(A, C) * C; // Get polar code uint32_t K_r = A_prime / C + L; uint32_t E_r = E_uci / C; - if (srslte_polar_code_get(&q->code, K_r, E_r, UCI_NR_PUCCH_POLAR_N_MAX) < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (srsran_polar_code_get(&q->code, K_r, E_r, UCI_NR_PUCCH_POLAR_N_MAX) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } // Negate all LLR @@ -754,38 +754,38 @@ static int uci_nr_decode_11_1706_bit(srslte_uci_nr_t* q, for (uint32_t r = 0, s = 0; r < C; r++) { uint32_t k = 0; - if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_INFO && !handler_registered) { + if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_INFO && !handler_registered) { UCI_NR_INFO_RX("Polar LLR %d/%d ", r, C); - srslte_vec_fprint_bs(stdout, &llr[E_r * r], q->code.N); + srsran_vec_fprint_bs(stdout, &llr[E_r * r], q->code.N); } // Undo rate matching int8_t* d = (int8_t*)q->d; - srslte_polar_rm_rx_c(&q->rm_rx, &llr[E_r * r], d, E_r, q->code.n, K_r, UCI_NR_POLAR_RM_IBIL); + srsran_polar_rm_rx_c(&q->rm_rx, &llr[E_r * r], d, E_r, q->code.n, K_r, UCI_NR_POLAR_RM_IBIL); // Decode bits - if (srslte_polar_decoder_decode_c(&q->decoder, d, q->allocated, q->code.n, q->code.F_set, q->code.F_set_size) < - SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (srsran_polar_decoder_decode_c(&q->decoder, d, q->allocated, q->code.n, q->code.F_set, q->code.F_set_size) < + SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } - if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_INFO && !handler_registered) { + if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_INFO && !handler_registered) { UCI_NR_INFO_RX("Polar alloc %d/%d ", r, C); - srslte_vec_fprint_byte(stdout, q->allocated, q->code.N); + srsran_vec_fprint_byte(stdout, q->allocated, q->code.N); } // Undo channel allocation - srslte_polar_chanalloc_rx(q->allocated, q->c, q->code.K, q->code.nPC, q->code.K_set, q->code.PC_set); + srsran_polar_chanalloc_rx(q->allocated, q->c, q->code.K, q->code.nPC, q->code.K_set, q->code.PC_set); - if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_INFO && !handler_registered) { + if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_INFO && !handler_registered) { UCI_NR_INFO_RX("Polar cb %d/%d c=", r, C); - srslte_vec_fprint_byte(stdout, q->c, K_r); + srsran_vec_fprint_byte(stdout, q->c, K_r); } // Calculate checksum uint8_t* ptr = &q->c[A_prime / C]; - uint32_t checksum1 = srslte_crc_checksum(crc, q->c, A_prime / C); - uint32_t checksum2 = srslte_bit_pack(&ptr, L); + uint32_t checksum1 = srsran_crc_checksum(crc, q->c, A_prime / C); + uint32_t checksum2 = srsran_bit_pack(&ptr, L); (*decoded_ok) = ((*decoded_ok) && (checksum1 == checksum2)); UCI_NR_INFO_RX("Checking %d/%d CRC%d={%02x,%02x}", r, C, L, checksum1, checksum2); @@ -802,10 +802,10 @@ static int uci_nr_decode_11_1706_bit(srslte_uci_nr_t* q, } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -static int uci_nr_encode(srslte_uci_nr_t* q, const srslte_uci_cfg_nr_t* uci_cfg, uint32_t A, uint8_t* o, uint32_t E_uci) +static int uci_nr_encode(srsran_uci_nr_t* q, const srsran_uci_cfg_nr_t* uci_cfg, uint32_t A, uint8_t* o, uint32_t E_uci) { // 5.3.3.1 Encoding of 1-bit information if (A == 1) { @@ -818,71 +818,71 @@ static int uci_nr_encode(srslte_uci_nr_t* q, const srslte_uci_cfg_nr_t* uci_cfg, } // 5.3.3.3 Encoding of other small block lengths - if (A <= SRSLTE_FEC_BLOCK_MAX_NOF_BITS) { + if (A <= SRSRAN_FEC_BLOCK_MAX_NOF_BITS) { return uci_nr_encode_3_11_bit(q, uci_cfg, A, o, E_uci); } // Encoding of other sizes up to 1906 - if (A < SRSLTE_UCI_NR_MAX_NOF_BITS) { + if (A < SRSRAN_UCI_NR_MAX_NOF_BITS) { return uci_nr_encode_11_1706_bit(q, uci_cfg, A, o, E_uci); } - return SRSLTE_ERROR; + return SRSRAN_ERROR; } -static int uci_nr_decode(srslte_uci_nr_t* q, - const srslte_uci_cfg_nr_t* uci_cfg, +static int uci_nr_decode(srsran_uci_nr_t* q, + const srsran_uci_cfg_nr_t* uci_cfg, int8_t* llr, uint32_t A, uint32_t E_uci, bool* valid) { if (q == NULL || uci_cfg == NULL || valid == NULL || llr == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } // Decode LLR if (A == 1) { - if (uci_nr_decode_1_bit(q, uci_cfg, A, llr, E_uci, valid) < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (uci_nr_decode_1_bit(q, uci_cfg, A, llr, E_uci, valid) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } } else if (A == 2) { - if (uci_nr_decode_2_bit(q, uci_cfg, A, llr, E_uci, valid) < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (uci_nr_decode_2_bit(q, uci_cfg, A, llr, E_uci, valid) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } } else if (A <= 11) { - if (uci_nr_decode_3_11_bit(q, uci_cfg, A, llr, E_uci, valid) < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (uci_nr_decode_3_11_bit(q, uci_cfg, A, llr, E_uci, valid) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } - } else if (A < SRSLTE_UCI_NR_MAX_NOF_BITS) { - if (uci_nr_decode_11_1706_bit(q, uci_cfg, A, llr, E_uci, valid) < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + } else if (A < SRSRAN_UCI_NR_MAX_NOF_BITS) { + if (uci_nr_decode_11_1706_bit(q, uci_cfg, A, llr, E_uci, valid) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } } else { ERROR("Invalid number of bits (A=%d)", A); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_uci_nr_pucch_format_2_3_4_E(const srslte_pucch_nr_resource_t* resource) +int srsran_uci_nr_pucch_format_2_3_4_E(const srsran_pucch_nr_resource_t* resource) { if (resource == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } switch (resource->format) { - case SRSLTE_PUCCH_NR_FORMAT_2: + case SRSRAN_PUCCH_NR_FORMAT_2: return (int)(16 * resource->nof_symbols * resource->nof_prb); - case SRSLTE_PUCCH_NR_FORMAT_3: + case SRSRAN_PUCCH_NR_FORMAT_3: if (!resource->enable_pi_bpsk) { return (int)(24 * resource->nof_symbols * resource->nof_prb); } return (int)(12 * resource->nof_symbols * resource->nof_prb); - case SRSLTE_PUCCH_NR_FORMAT_4: + case SRSRAN_PUCCH_NR_FORMAT_4: if (resource->occ_lenth != 1 && resource->occ_lenth != 2) { ERROR("Invalid spreading factor (%d)", resource->occ_lenth); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (!resource->enable_pi_bpsk) { return (int)(24 * resource->nof_symbols / resource->occ_lenth); @@ -891,131 +891,131 @@ int srslte_uci_nr_pucch_format_2_3_4_E(const srslte_pucch_nr_resource_t* resourc default: ERROR("Invalid case"); } - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Implements TS 38.212 Table 6.3.1.4.1-1: Rate matching output sequence length E UCI static int -uci_nr_pucch_E_uci(const srslte_pucch_nr_resource_t* pucch_cfg, const srslte_uci_cfg_nr_t* uci_cfg, uint32_t E_tot) +uci_nr_pucch_E_uci(const srsran_pucch_nr_resource_t* pucch_cfg, const srsran_uci_cfg_nr_t* uci_cfg, uint32_t E_tot) { // if (uci_cfg->o_csi1 != 0 && uci_cfg->o_csi2) { // ERROR("Simultaneous CSI part 1 and CSI part 2 is not implemented"); - // return SRSLTE_ERROR; + // return SRSRAN_ERROR; // } return E_tot; } -int srslte_uci_nr_encode_pucch(srslte_uci_nr_t* q, - const srslte_pucch_nr_resource_t* pucch_resource_cfg, - const srslte_uci_cfg_nr_t* uci_cfg, - const srslte_uci_value_nr_t* value, +int srsran_uci_nr_encode_pucch(srsran_uci_nr_t* q, + const srsran_pucch_nr_resource_t* pucch_resource_cfg, + const srsran_uci_cfg_nr_t* uci_cfg, + const srsran_uci_value_nr_t* value, uint8_t* o) { - int E_tot = srslte_uci_nr_pucch_format_2_3_4_E(pucch_resource_cfg); - if (E_tot < SRSLTE_SUCCESS) { + int E_tot = srsran_uci_nr_pucch_format_2_3_4_E(pucch_resource_cfg); + if (E_tot < SRSRAN_SUCCESS) { ERROR("Error calculating number of bits"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } int E_uci = uci_nr_pucch_E_uci(pucch_resource_cfg, uci_cfg, E_tot); - if (E_uci < SRSLTE_SUCCESS) { + if (E_uci < SRSRAN_SUCCESS) { ERROR("Error calculating number of bits"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // 6.3.1.1 UCI bit sequence generation int A = uci_nr_pack_pucch(uci_cfg, value, q->bit_sequence); - if (A < SRSLTE_SUCCESS) { + if (A < SRSRAN_SUCCESS) { ERROR("Generating bit sequence"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } return uci_nr_encode(q, uci_cfg, A, o, E_uci); } -int srslte_uci_nr_decode_pucch(srslte_uci_nr_t* q, - const srslte_pucch_nr_resource_t* pucch_resource_cfg, - const srslte_uci_cfg_nr_t* uci_cfg, +int srsran_uci_nr_decode_pucch(srsran_uci_nr_t* q, + const srsran_pucch_nr_resource_t* pucch_resource_cfg, + const srsran_uci_cfg_nr_t* uci_cfg, int8_t* llr, - srslte_uci_value_nr_t* value) + srsran_uci_value_nr_t* value) { - int E_tot = srslte_uci_nr_pucch_format_2_3_4_E(pucch_resource_cfg); - if (E_tot < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + int E_tot = srsran_uci_nr_pucch_format_2_3_4_E(pucch_resource_cfg); + if (E_tot < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } int E_uci = uci_nr_pucch_E_uci(pucch_resource_cfg, uci_cfg, E_tot); - if (E_uci < SRSLTE_SUCCESS) { + if (E_uci < SRSRAN_SUCCESS) { ERROR("Error calculating number of encoded PUCCH UCI bits"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // 6.3.1.1 UCI bit sequence generation int A = uci_nr_A(uci_cfg); - if (A < SRSLTE_SUCCESS) { + if (A < SRSRAN_SUCCESS) { ERROR("Error getting number of bits"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (uci_nr_decode(q, uci_cfg, llr, A, E_uci, &value->valid) < SRSLTE_SUCCESS) { + if (uci_nr_decode(q, uci_cfg, llr, A, E_uci, &value->valid) < SRSRAN_SUCCESS) { ERROR("Error decoding UCI bits"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Unpack bits - if (uci_nr_unpack_pucch(uci_cfg, q->bit_sequence, value) < SRSLTE_SUCCESS) { + if (uci_nr_unpack_pucch(uci_cfg, q->bit_sequence, value) < SRSRAN_SUCCESS) { ERROR("Error unpacking PUCCH UCI bits"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -uint32_t srslte_uci_nr_total_bits(const srslte_uci_cfg_nr_t* uci_cfg) +uint32_t srsran_uci_nr_total_bits(const srsran_uci_cfg_nr_t* uci_cfg) { if (uci_cfg == NULL) { return 0; } - return uci_cfg->o_ack + uci_cfg->o_sr + srslte_csi_part1_nof_bits(uci_cfg->csi, uci_cfg->nof_csi); + return uci_cfg->o_ack + uci_cfg->o_sr + srsran_csi_part1_nof_bits(uci_cfg->csi, uci_cfg->nof_csi); } -uint32_t srslte_uci_nr_info(const srslte_uci_data_nr_t* uci_data, char* str, uint32_t str_len) +uint32_t srsran_uci_nr_info(const srsran_uci_data_nr_t* uci_data, char* str, uint32_t str_len) { uint32_t len = 0; - len = srslte_print_check(str, str_len, len, "rnti=0x%x", uci_data->cfg.pucch.rnti); + len = srsran_print_check(str, str_len, len, "rnti=0x%x", uci_data->cfg.pucch.rnti); if (uci_data->cfg.o_ack > 0) { char str2[10]; - srslte_vec_sprint_bin(str2, 10, uci_data->value.ack, uci_data->cfg.o_ack); - len = srslte_print_check(str, str_len, len, ", ack=%s", str2); + srsran_vec_sprint_bin(str2, 10, uci_data->value.ack, uci_data->cfg.o_ack); + len = srsran_print_check(str, str_len, len, ", ack=%s", str2); } if (uci_data->cfg.nof_csi > 0) { - len += srslte_csi_str(uci_data->cfg.csi, uci_data->value.csi, uci_data->cfg.nof_csi, &str[len], str_len - len); + len += srsran_csi_str(uci_data->cfg.csi, uci_data->value.csi, uci_data->cfg.nof_csi, &str[len], str_len - len); } if (uci_data->cfg.o_sr > 0) { - len = srslte_print_check(str, str_len, len, ", sr=%d", uci_data->value.sr); + len = srsran_print_check(str, str_len, len, ", sr=%d", uci_data->value.sr); } return len; } -static int uci_nr_pusch_Q_prime_ack(const srslte_uci_nr_pusch_cfg_t* cfg, uint32_t O_ack) +static int uci_nr_pusch_Q_prime_ack(const srsran_uci_nr_pusch_cfg_t* cfg, uint32_t O_ack) { if (cfg == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } - uint32_t L_ack = srslte_uci_nr_crc_len(O_ack); // Number of CRC bits - uint32_t Qm = srslte_mod_bits_x_symbol(cfg->modulation); // modulation order of the PUSCH + uint32_t L_ack = srsran_uci_nr_crc_len(O_ack); // Number of CRC bits + uint32_t Qm = srsran_mod_bits_x_symbol(cfg->modulation); // modulation order of the PUSCH uint32_t M_uci_sum = 0; uint32_t M_uci_l0_sum = 0; - for (uint32_t l = 0; l < SRSLTE_NSYMB_PER_SLOT_NR; l++) { + for (uint32_t l = 0; l < SRSRAN_NSYMB_PER_SLOT_NR; l++) { M_uci_sum += cfg->M_uci_sc[l]; if (l >= cfg->l0) { M_uci_l0_sum += cfg->M_uci_sc[l]; @@ -1024,236 +1024,236 @@ static int uci_nr_pusch_Q_prime_ack(const srslte_uci_nr_pusch_cfg_t* cfg, uint32 if (!isnormal(cfg->R)) { ERROR("Invalid Rate (%f)", cfg->R); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (cfg->K_sum == 0) { - return (int)SRSLTE_MIN(ceilf(((O_ack + L_ack) * cfg->beta_harq_ack_offset) / (Qm * cfg->R)), + return (int)SRSRAN_MIN(ceilf(((O_ack + L_ack) * cfg->beta_harq_ack_offset) / (Qm * cfg->R)), cfg->alpha * M_uci_l0_sum); } - return (int)SRSLTE_MIN(ceilf(((O_ack + L_ack) * cfg->beta_harq_ack_offset * M_uci_sum) / cfg->K_sum), + return (int)SRSRAN_MIN(ceilf(((O_ack + L_ack) * cfg->beta_harq_ack_offset * M_uci_sum) / cfg->K_sum), cfg->alpha * M_uci_l0_sum); } -int srslte_uci_nr_pusch_ack_nof_bits(const srslte_uci_nr_pusch_cfg_t* cfg, uint32_t O_ack) +int srsran_uci_nr_pusch_ack_nof_bits(const srsran_uci_nr_pusch_cfg_t* cfg, uint32_t O_ack) { // Check inputs if (cfg == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } if (cfg->nof_layers == 0) { ERROR("Invalid number of layers (%d)", cfg->nof_layers); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } int Q_ack_prime = uci_nr_pusch_Q_prime_ack(cfg, O_ack); - if (Q_ack_prime < SRSLTE_SUCCESS) { + if (Q_ack_prime < SRSRAN_SUCCESS) { ERROR("Error calculating number of RE"); return Q_ack_prime; } - return (int)(Q_ack_prime * cfg->nof_layers * srslte_mod_bits_x_symbol(cfg->modulation)); + return (int)(Q_ack_prime * cfg->nof_layers * srsran_mod_bits_x_symbol(cfg->modulation)); } -int srslte_uci_nr_encode_pusch_ack(srslte_uci_nr_t* q, - const srslte_uci_cfg_nr_t* cfg, - const srslte_uci_value_nr_t* value, +int srsran_uci_nr_encode_pusch_ack(srsran_uci_nr_t* q, + const srsran_uci_cfg_nr_t* cfg, + const srsran_uci_value_nr_t* value, uint8_t* o) { int A = cfg->o_ack; // Check inputs if (q == NULL || cfg == NULL || value == NULL || o == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } // 6.3.2.1 UCI bit sequence generation // 6.3.2.1.1 HARQ-ACK - bool has_csi_part2 = srslte_csi_has_part2(cfg->csi, cfg->nof_csi); + bool has_csi_part2 = srsran_csi_has_part2(cfg->csi, cfg->nof_csi); if (cfg->pusch.K_sum == 0 && cfg->nof_csi > 1 && !has_csi_part2 && A < 2) { q->bit_sequence[0] = (A == 0) ? 0 : value->ack[0]; q->bit_sequence[1] = 0; A = 2; } else if (A == 0) { UCI_NR_INFO_TX("No HARQ-ACK to mux"); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } else { - srslte_vec_u8_copy(q->bit_sequence, value->ack, cfg->o_ack); + srsran_vec_u8_copy(q->bit_sequence, value->ack, cfg->o_ack); } // Compute total of encoded bits according to 6.3.2.4 Rate matching - int E_uci = srslte_uci_nr_pusch_ack_nof_bits(&cfg->pusch, A); - if (E_uci < SRSLTE_SUCCESS) { + int E_uci = srsran_uci_nr_pusch_ack_nof_bits(&cfg->pusch, A); + if (E_uci < SRSRAN_SUCCESS) { ERROR("Error calculating number of encoded bits"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } return uci_nr_encode(q, cfg, A, o, E_uci); } -int srslte_uci_nr_decode_pusch_ack(srslte_uci_nr_t* q, - const srslte_uci_cfg_nr_t* cfg, +int srsran_uci_nr_decode_pusch_ack(srsran_uci_nr_t* q, + const srsran_uci_cfg_nr_t* cfg, int8_t* llr, - srslte_uci_value_nr_t* value) + srsran_uci_value_nr_t* value) { int A = cfg->o_ack; // Check inputs if (q == NULL || cfg == NULL || llr == NULL || value == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } // 6.3.2.1 UCI bit sequence generation // 6.3.2.1.1 HARQ-ACK - bool has_csi_part2 = srslte_csi_has_part2(cfg->csi, cfg->nof_csi); + bool has_csi_part2 = srsran_csi_has_part2(cfg->csi, cfg->nof_csi); if (cfg->pusch.K_sum == 0 && cfg->nof_csi > 1 && !has_csi_part2 && cfg->o_ack < 2) { A = 2; } // Compute total of encoded bits according to 6.3.2.4 Rate matching - int E_uci = srslte_uci_nr_pusch_ack_nof_bits(&cfg->pusch, A); - if (E_uci < SRSLTE_SUCCESS) { + int E_uci = srsran_uci_nr_pusch_ack_nof_bits(&cfg->pusch, A); + if (E_uci < SRSRAN_SUCCESS) { ERROR("Error calculating number of encoded bits"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Decode - if (uci_nr_decode(q, cfg, llr, A, E_uci, &value->valid) < SRSLTE_SUCCESS) { + if (uci_nr_decode(q, cfg, llr, A, E_uci, &value->valid) < SRSRAN_SUCCESS) { ERROR("Error decoding UCI"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Unpack - srslte_vec_u8_copy(value->ack, q->bit_sequence, A); + srsran_vec_u8_copy(value->ack, q->bit_sequence, A); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -static int uci_nr_pusch_Q_prime_csi1(const srslte_uci_nr_pusch_cfg_t* cfg, uint32_t O_csi1, uint32_t O_ack) +static int uci_nr_pusch_Q_prime_csi1(const srsran_uci_nr_pusch_cfg_t* cfg, uint32_t O_csi1, uint32_t O_ack) { if (cfg == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } - uint32_t L_ack = srslte_uci_nr_crc_len(O_csi1); // Number of CRC bits - uint32_t Qm = srslte_mod_bits_x_symbol(cfg->modulation); // modulation order of the PUSCH + uint32_t L_ack = srsran_uci_nr_crc_len(O_csi1); // Number of CRC bits + uint32_t Qm = srsran_mod_bits_x_symbol(cfg->modulation); // modulation order of the PUSCH - int Q_prime_ack = uci_nr_pusch_Q_prime_ack(cfg, SRSLTE_MAX(2, O_ack)); - if (Q_prime_ack < SRSLTE_ERROR) { + int Q_prime_ack = uci_nr_pusch_Q_prime_ack(cfg, SRSRAN_MAX(2, O_ack)); + if (Q_prime_ack < SRSRAN_ERROR) { ERROR("Calculating Q_prime_ack"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } uint32_t M_uci_sum = 0; - for (uint32_t l = 0; l < SRSLTE_NSYMB_PER_SLOT_NR; l++) { + for (uint32_t l = 0; l < SRSRAN_NSYMB_PER_SLOT_NR; l++) { M_uci_sum += cfg->M_uci_sc[l]; } if (!isnormal(cfg->R)) { ERROR("Invalid Rate (%f)", cfg->R); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (cfg->K_sum == 0) { if (cfg->csi_part2_present) { - return (int)SRSLTE_MIN(ceilf(((O_csi1 + L_ack) * cfg->beta_csi1_offset) / (Qm * cfg->R)), + return (int)SRSRAN_MIN(ceilf(((O_csi1 + L_ack) * cfg->beta_csi1_offset) / (Qm * cfg->R)), cfg->alpha * M_uci_sum - Q_prime_ack); } return (int)(M_uci_sum - Q_prime_ack); } - return (int)SRSLTE_MIN(ceilf(((O_csi1 + L_ack) * cfg->beta_csi1_offset * M_uci_sum) / cfg->K_sum), + return (int)SRSRAN_MIN(ceilf(((O_csi1 + L_ack) * cfg->beta_csi1_offset * M_uci_sum) / cfg->K_sum), ceilf(cfg->alpha * M_uci_sum) - Q_prime_ack); } -int srslte_uci_nr_pusch_csi1_nof_bits(const srslte_uci_cfg_nr_t* cfg) +int srsran_uci_nr_pusch_csi1_nof_bits(const srsran_uci_cfg_nr_t* cfg) { // Check inputs if (cfg == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } - int O_csi1 = srslte_csi_part1_nof_bits(cfg->csi, cfg->nof_csi); - if (O_csi1 < SRSLTE_SUCCESS) { + int O_csi1 = srsran_csi_part1_nof_bits(cfg->csi, cfg->nof_csi); + if (O_csi1 < SRSRAN_SUCCESS) { ERROR("Errpr calculating CSI part 1 number of bits"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - uint32_t O_ack = SRSLTE_MAX(2, cfg->o_ack); + uint32_t O_ack = SRSRAN_MAX(2, cfg->o_ack); int Q_csi1_prime = uci_nr_pusch_Q_prime_csi1(&cfg->pusch, (uint32_t)O_csi1, O_ack); - if (Q_csi1_prime < SRSLTE_SUCCESS) { + if (Q_csi1_prime < SRSRAN_SUCCESS) { ERROR("Error calculating number of RE"); return Q_csi1_prime; } - return (int)(Q_csi1_prime * cfg->pusch.nof_layers * srslte_mod_bits_x_symbol(cfg->pusch.modulation)); + return (int)(Q_csi1_prime * cfg->pusch.nof_layers * srsran_mod_bits_x_symbol(cfg->pusch.modulation)); } -int srslte_uci_nr_encode_pusch_csi1(srslte_uci_nr_t* q, - const srslte_uci_cfg_nr_t* cfg, - const srslte_uci_value_nr_t* value, +int srsran_uci_nr_encode_pusch_csi1(srsran_uci_nr_t* q, + const srsran_uci_cfg_nr_t* cfg, + const srsran_uci_value_nr_t* value, uint8_t* o) { // Check inputs if (q == NULL || cfg == NULL || value == NULL || o == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } - int A = srslte_csi_part1_pack(cfg->csi, value->csi, cfg->nof_csi, q->bit_sequence, SRSLTE_UCI_NR_MAX_NOF_BITS); - if (A < SRSLTE_SUCCESS) { + int A = srsran_csi_part1_pack(cfg->csi, value->csi, cfg->nof_csi, q->bit_sequence, SRSRAN_UCI_NR_MAX_NOF_BITS); + if (A < SRSRAN_SUCCESS) { ERROR("Error packing CSI part 1 report"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (A == 0) { UCI_NR_INFO_TX("No CSI part 1 to mux"); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Compute total of encoded bits according to 6.3.2.4 Rate matching - int E_uci = srslte_uci_nr_pusch_csi1_nof_bits(cfg); - if (E_uci < SRSLTE_SUCCESS) { + int E_uci = srsran_uci_nr_pusch_csi1_nof_bits(cfg); + if (E_uci < SRSRAN_SUCCESS) { ERROR("Error calculating number of encoded bits"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } return uci_nr_encode(q, cfg, A, o, E_uci); } -int srslte_uci_nr_decode_pusch_csi1(srslte_uci_nr_t* q, - const srslte_uci_cfg_nr_t* cfg, +int srsran_uci_nr_decode_pusch_csi1(srsran_uci_nr_t* q, + const srsran_uci_cfg_nr_t* cfg, int8_t* llr, - srslte_uci_value_nr_t* value) + srsran_uci_value_nr_t* value) { // Check inputs if (q == NULL || cfg == NULL || llr == NULL || value == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } // Compute total of encoded bits according to 6.3.2.4 Rate matching - int E_uci = srslte_uci_nr_pusch_csi1_nof_bits(cfg); - if (E_uci < SRSLTE_SUCCESS) { + int E_uci = srsran_uci_nr_pusch_csi1_nof_bits(cfg); + if (E_uci < SRSRAN_SUCCESS) { ERROR("Error calculating number of encoded bits"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - int A = srslte_csi_part1_nof_bits(cfg->csi, cfg->nof_csi); - if (A < SRSLTE_SUCCESS) { + int A = srsran_csi_part1_nof_bits(cfg->csi, cfg->nof_csi); + if (A < SRSRAN_SUCCESS) { ERROR("Error getting number of CSI part 1 bits"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Decode - if (uci_nr_decode(q, cfg, llr, (uint32_t)A, (uint32_t)E_uci, &value->valid) < SRSLTE_SUCCESS) { + if (uci_nr_decode(q, cfg, llr, (uint32_t)A, (uint32_t)E_uci, &value->valid) < SRSRAN_SUCCESS) { ERROR("Error decoding UCI"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Unpack - if (srslte_csi_part1_unpack(cfg->csi, cfg->nof_csi, q->bit_sequence, A, value->csi) < SRSLTE_SUCCESS) { + if (srsran_csi_part1_unpack(cfg->csi, cfg->nof_csi, q->bit_sequence, A, value->csi) < SRSRAN_SUCCESS) { ERROR("Error unpacking CSI"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } \ No newline at end of file diff --git a/lib/src/phy/resampling/CMakeLists.txt b/lib/src/phy/resampling/CMakeLists.txt index 867045fe3..bd520600d 100644 --- a/lib/src/phy/resampling/CMakeLists.txt +++ b/lib/src/phy/resampling/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -7,5 +7,5 @@ # file(GLOB SOURCES "*.c") -add_library(srslte_resampling OBJECT ${SOURCES}) +add_library(srsran_resampling OBJECT ${SOURCES}) add_subdirectory(test) diff --git a/lib/src/phy/resampling/decim.c b/lib/src/phy/resampling/decim.c index 9743d7d6f..1193d6fc6 100644 --- a/lib/src/phy/resampling/decim.c +++ b/lib/src/phy/resampling/decim.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,13 +10,13 @@ * */ -#include "srslte/phy/resampling/decim.h" -#include "srslte/phy/utils/debug.h" +#include "srsran/phy/resampling/decim.h" +#include "srsran/phy/utils/debug.h" #include #include /* Performs integer linear decimation by a factor of M */ -void srslte_decim_c(cf_t* input, cf_t* output, int M, int len) +void srsran_decim_c(cf_t* input, cf_t* output, int M, int len) { int i; for (i = 0; i < len / M; i++) { @@ -25,7 +25,7 @@ void srslte_decim_c(cf_t* input, cf_t* output, int M, int len) } /* Performs integer linear decimation by a factor of M */ -void srslte_decim_f(float* input, float* output, int M, int len) +void srsran_decim_f(float* input, float* output, int M, int len) { int i; for (i = 0; i < len / M; i++) { diff --git a/lib/src/phy/resampling/interp.c b/lib/src/phy/resampling/interp.c index c7fa6750c..f496461f4 100644 --- a/lib/src/phy/resampling/interp.c +++ b/lib/src/phy/resampling/interp.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,24 +10,24 @@ * */ -#include "srslte/srslte.h" +#include "srsran/srsran.h" #include #include #include #include -#include "srslte/phy/resampling/interp.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/resampling/interp.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" /*************** STATIC FUNCTIONS ***********************/ -cf_t srslte_interp_linear_onesample(cf_t input0, cf_t input1) +cf_t srsran_interp_linear_onesample(cf_t input0, cf_t input1) { return 2 * input1 - input0; } -cf_t srslte_interp_linear_onesample_cabs(cf_t input0, cf_t input1) +cf_t srsran_interp_linear_onesample_cabs(cf_t input0, cf_t input1) { float re0 = 0, im0 = 0, re1 = 0, im1 = 0, re = 0, im = 0; re0 = crealf(input0); @@ -40,7 +40,7 @@ cf_t srslte_interp_linear_onesample_cabs(cf_t input0, cf_t input1) } /* Performs 1st order integer linear interpolation */ -void srslte_interp_linear_f(float* input, float* output, uint32_t M, uint32_t len) +void srsran_interp_linear_f(float* input, float* output, uint32_t M, uint32_t len) { uint32_t i, j; for (i = 0; i < len - 1; i++) { @@ -51,7 +51,7 @@ void srslte_interp_linear_f(float* input, float* output, uint32_t M, uint32_t le } /* Performs 1st order linear interpolation with out-of-bound interpolation */ -void srslte_interp_linear_offset_cabs(cf_t* input, +void srsran_interp_linear_offset_cabs(cf_t* input, cf_t* output, uint32_t M, uint32_t len, @@ -88,16 +88,16 @@ void srslte_interp_linear_offset_cabs(cf_t* input, } } -int srslte_interp_linear_vector_init(srslte_interp_linsrslte_vec_t* q, uint32_t vector_len) +int srsran_interp_linear_vector_init(srsran_interp_linsrsran_vec_t* q, uint32_t vector_len) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q) { - bzero(q, sizeof(srslte_interp_linsrslte_vec_t)); - ret = SRSLTE_SUCCESS; - q->diff_vec = srslte_vec_cf_malloc(vector_len); + bzero(q, sizeof(srsran_interp_linsrsran_vec_t)); + ret = SRSRAN_SUCCESS; + q->diff_vec = srsran_vec_cf_malloc(vector_len); if (!q->diff_vec) { perror("malloc"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } q->vector_len = vector_len; q->max_vector_len = vector_len; @@ -105,37 +105,37 @@ int srslte_interp_linear_vector_init(srslte_interp_linsrslte_vec_t* q, uint32_t return ret; } -int srslte_interp_linear_vector_resize(srslte_interp_linsrslte_vec_t* q, uint32_t vector_len) +int srsran_interp_linear_vector_resize(srsran_interp_linsrsran_vec_t* q, uint32_t vector_len) { if (vector_len <= q->max_vector_len) { q->vector_len = vector_len; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } else { ERROR("Error resizing interp_linear: vector_len must be lower or equal than initialized"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } -void srslte_interp_linear_vector_free(srslte_interp_linsrslte_vec_t* q) +void srsran_interp_linear_vector_free(srsran_interp_linsrsran_vec_t* q) { if (q->diff_vec) { free(q->diff_vec); } - bzero(q, sizeof(srslte_interp_linsrslte_vec_t)); + bzero(q, sizeof(srsran_interp_linsrsran_vec_t)); } -void srslte_interp_linear_vector(srslte_interp_linsrslte_vec_t* q, +void srsran_interp_linear_vector(srsran_interp_linsrsran_vec_t* q, cf_t* in0, cf_t* in1, cf_t* between, uint32_t in1_in0_d, uint32_t M) { - srslte_interp_linear_vector2(q, in0, in1, NULL, between, in1_in0_d, M); + srsran_interp_linear_vector2(q, in0, in1, NULL, between, in1_in0_d, M); } -void srslte_interp_linear_vector2(srslte_interp_linsrslte_vec_t* q, +void srsran_interp_linear_vector2(srsran_interp_linsrsran_vec_t* q, cf_t* in0, cf_t* in1, cf_t* start, @@ -143,10 +143,10 @@ void srslte_interp_linear_vector2(srslte_interp_linsrslte_vec_t* q, uint32_t in1_in0_d, uint32_t M) { - srslte_interp_linear_vector3(q, in0, in1, start, between, in1_in0_d, M, true, q->vector_len); + srsran_interp_linear_vector3(q, in0, in1, start, between, in1_in0_d, M, true, q->vector_len); } -void srslte_interp_linear_vector3(srslte_interp_linsrslte_vec_t* q, +void srsran_interp_linear_vector3(srsran_interp_linsrsran_vec_t* q, cf_t* in0, cf_t* in1, cf_t* start, @@ -158,49 +158,49 @@ void srslte_interp_linear_vector3(srslte_interp_linsrslte_vec_t* q, { uint32_t i; - srslte_vec_sub_ccc(in1, in0, q->diff_vec, len); - srslte_vec_sc_prod_cfc(q->diff_vec, (float)1 / in1_in0_d, q->diff_vec, len); + srsran_vec_sub_ccc(in1, in0, q->diff_vec, len); + srsran_vec_sc_prod_cfc(q->diff_vec, (float)1 / in1_in0_d, q->diff_vec, len); if (start) { - srslte_vec_sum_ccc(start, q->diff_vec, between, len); + srsran_vec_sum_ccc(start, q->diff_vec, between, len); } else { - srslte_vec_sum_ccc(in0, q->diff_vec, between, len); + srsran_vec_sum_ccc(in0, q->diff_vec, between, len); } for (i = 0; i < M - 1; i++) { // Operations are done to len samples but pointers are moved the full vector length if (to_right) { - srslte_vec_sum_ccc(between, q->diff_vec, &between[q->vector_len], len); + srsran_vec_sum_ccc(between, q->diff_vec, &between[q->vector_len], len); between += q->vector_len; } else { between -= q->vector_len; - srslte_vec_sum_ccc(&between[q->vector_len], q->diff_vec, between, len); + srsran_vec_sum_ccc(&between[q->vector_len], q->diff_vec, between, len); } } } -int srslte_interp_linear_init(srslte_interp_lin_t* q, uint32_t vector_len, uint32_t M) +int srsran_interp_linear_init(srsran_interp_lin_t* q, uint32_t vector_len, uint32_t M) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q) { - bzero(q, sizeof(srslte_interp_lin_t)); - ret = SRSLTE_SUCCESS; - q->diff_vec = srslte_vec_cf_malloc(vector_len); + bzero(q, sizeof(srsran_interp_lin_t)); + ret = SRSRAN_SUCCESS; + q->diff_vec = srsran_vec_cf_malloc(vector_len); if (!q->diff_vec) { perror("malloc"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - q->diff_vec2 = srslte_vec_cf_malloc(M * vector_len); + q->diff_vec2 = srsran_vec_cf_malloc(M * vector_len); if (!q->diff_vec2) { perror("malloc"); free(q->diff_vec); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - q->ramp = srslte_vec_f_malloc(M); + q->ramp = srsran_vec_f_malloc(M); if (!q->ramp) { perror("malloc"); free(q->ramp); free(q->diff_vec); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } for (int i = 0; i < M; i++) { @@ -215,7 +215,7 @@ int srslte_interp_linear_init(srslte_interp_lin_t* q, uint32_t vector_len, uint3 return ret; } -void srslte_interp_linear_free(srslte_interp_lin_t* q) +void srsran_interp_linear_free(srsran_interp_lin_t* q) { if (q->diff_vec) { free(q->diff_vec); @@ -227,10 +227,10 @@ void srslte_interp_linear_free(srslte_interp_lin_t* q) free(q->ramp); } - bzero(q, sizeof(srslte_interp_lin_t)); + bzero(q, sizeof(srsran_interp_lin_t)); } -int srslte_interp_linear_resize(srslte_interp_lin_t* q, uint32_t vector_len, uint32_t M) +int srsran_interp_linear_resize(srsran_interp_lin_t* q, uint32_t vector_len, uint32_t M) { if (vector_len <= q->max_vector_len && M <= q->max_M) { for (int i = 0; i < M; i++) { @@ -239,14 +239,14 @@ int srslte_interp_linear_resize(srslte_interp_lin_t* q, uint32_t vector_len, uin q->vector_len = vector_len; q->M = M; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } else { ERROR("Error resizing interp_linear: vector_len and M must be lower or equal than initialized"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } -void srslte_interp_linear_offset(srslte_interp_lin_t* q, cf_t* input, cf_t* output, uint32_t off_st, uint32_t off_end) +void srsran_interp_linear_offset(srsran_interp_lin_t* q, cf_t* input, cf_t* output, uint32_t off_st, uint32_t off_end) { uint32_t i, j; cf_t diff; @@ -255,16 +255,16 @@ void srslte_interp_linear_offset(srslte_interp_lin_t* q, cf_t* input, cf_t* outp for (j = 0; j < off_st; j++) { output[off_st - j - 1] = input[i] - (j + 1) * (input[i + 1] - input[i]) / q->M; } - srslte_vec_sub_ccc(&input[1], input, q->diff_vec, (q->vector_len - 1)); - srslte_vec_sc_prod_cfc(q->diff_vec, (float)1 / q->M, q->diff_vec, q->vector_len - 1); + srsran_vec_sub_ccc(&input[1], input, q->diff_vec, (q->vector_len - 1)); + srsran_vec_sc_prod_cfc(q->diff_vec, (float)1 / q->M, q->diff_vec, q->vector_len - 1); for (i = 0; i < q->vector_len - 1; i++) { for (j = 0; j < q->M; j++) { output[i * q->M + j + off_st] = input[i]; q->diff_vec2[i * q->M + j] = q->diff_vec[i]; } - srslte_vec_prod_cfc(&q->diff_vec2[i * q->M], q->ramp, &q->diff_vec2[i * q->M], q->M); + srsran_vec_prod_cfc(&q->diff_vec2[i * q->M], q->ramp, &q->diff_vec2[i * q->M], q->M); } - srslte_vec_sum_ccc(&output[off_st], q->diff_vec2, &output[off_st], q->M * (q->vector_len - 1)); + srsran_vec_sum_ccc(&output[off_st], q->diff_vec2, &output[off_st], q->M * (q->vector_len - 1)); if (q->vector_len > 1) { diff = input[q->vector_len - 1] - input[q->vector_len - 2]; diff --git a/lib/src/phy/resampling/resample_arb.c b/lib/src/phy/resampling/resample_arb.c index c73c5ca71..126f029f5 100644 --- a/lib/src/phy/resampling/resample_arb.c +++ b/lib/src/phy/resampling/resample_arb.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,14 +10,14 @@ * */ -#include "srslte/phy/resampling/resample_arb.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/resampling/resample_arb.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" #include #include // clang-format off -float srslte_resample_arb_polyfilt[SRSLTE_RESAMPLE_ARB_N][SRSLTE_RESAMPLE_ARB_M] __attribute__((aligned(256))) = +float srsran_resample_arb_polyfilt[SRSRAN_RESAMPLE_ARB_N][SRSRAN_RESAMPLE_ARB_M] __attribute__((aligned(256))) = {{0.000499262532685, 0.000859897001646, -0.008521087467670, 0.994530856609344, 0.017910413444042, -0.006922415923327, 0.002400347497314, 0.000000000000000 }, {-0.001216900418513, 0.008048813790083, -0.032752435654402, 0.991047739982605, 0.046474494040012, -0.015253192745149, 0.004479591734707, -0.001903604716063 }, {-0.002745266072452, 0.014606527984142, -0.054737392812967, 0.984105646610260, 0.077085755765438, -0.024075405672193, 0.006728826556355, -0.001750442315824 }, @@ -54,7 +54,7 @@ float srslte_resample_arb_polyfilt[SRSLTE_RESAMPLE_ARB_N][SRSLTE_RESAMPLE_ARB_M] - float srslte_resample_arb_polyfilt_35[SRSLTE_RESAMPLE_ARB_N_35][SRSLTE_RESAMPLE_ARB_M] __attribute__((aligned(256))) = + float srsran_resample_arb_polyfilt_35[SRSRAN_RESAMPLE_ARB_N_35][SRSRAN_RESAMPLE_ARB_M] __attribute__((aligned(256))) = {{0.000002955485215, 0.000657994314549, -0.033395686652146, 0.188481383863832, 0.704261032406613, 0.171322660416961, -0.032053439082436, 0.000722236729272}, {0.000003596427925, 0.000568080243211, -0.034615802155152, 0.206204344739138, 0.702921418438421, 0.154765509342932, -0.030612377229395, 0.000764085430796}, {0.000005121937258, 0.000449039680445, -0.035689076986744, 0.224449928603191, 0.700248311996698, 0.138842912406449, -0.029094366813032, 0.000786624971348}, @@ -92,33 +92,33 @@ float srslte_resample_arb_polyfilt[SRSLTE_RESAMPLE_ARB_N][SRSLTE_RESAMPLE_ARB_M] {0.000722236729272, -0.032053439082436, 0.171322660416961, 0.704261032406613, 0.188481383863832, -0.033395686652146, 0.000657994314549 , 0.000002955485215}}; // clang-format on -static inline cf_t srslte_resample_arb_dot_prod(cf_t* x, float* y, int len) +static inline cf_t srsran_resample_arb_dot_prod(cf_t* x, float* y, int len) { - cf_t res1 = srslte_vec_dot_prod_cfc(x, y, len); + cf_t res1 = srsran_vec_dot_prod_cfc(x, y, len); return res1; } // Right-shift our window of samples -void srslte_resample_arb_push(srslte_resample_arb_t* q, cf_t x) +void srsran_resample_arb_push(srsran_resample_arb_t* q, cf_t x) { - memmove(&q->reg[1], &q->reg[0], (SRSLTE_RESAMPLE_ARB_M - 1) * sizeof(cf_t)); + memmove(&q->reg[1], &q->reg[0], (SRSRAN_RESAMPLE_ARB_M - 1) * sizeof(cf_t)); q->reg[0] = x; } // Initialize our struct -void srslte_resample_arb_init(srslte_resample_arb_t* q, float rate, bool interpolate) +void srsran_resample_arb_init(srsran_resample_arb_t* q, float rate, bool interpolate) { - memset(q->reg, 0, SRSLTE_RESAMPLE_ARB_M * sizeof(cf_t)); + memset(q->reg, 0, SRSRAN_RESAMPLE_ARB_M * sizeof(cf_t)); q->acc = 0.0; q->rate = rate; q->interpolate = interpolate; - q->step = (1 / rate) * SRSLTE_RESAMPLE_ARB_N; + q->step = (1 / rate) * SRSRAN_RESAMPLE_ARB_N; } // Resample a block of input data -int srslte_resample_arb_compute(srslte_resample_arb_t* q, cf_t* input, cf_t* output, int n_in) +int srsran_resample_arb_compute(srsran_resample_arb_t* q, cf_t* input, cf_t* output, int n_in) { int cnt = 0; int n_out = 0; @@ -126,24 +126,24 @@ int srslte_resample_arb_compute(srslte_resample_arb_t* q, cf_t* input, cf_t* out cf_t res1, res2; cf_t* filter_input; float frac = 0; - memset(q->reg, 0, SRSLTE_RESAMPLE_ARB_M * sizeof(cf_t)); + memset(q->reg, 0, SRSRAN_RESAMPLE_ARB_M * sizeof(cf_t)); while (cnt < n_in) { - if (cnt < SRSLTE_RESAMPLE_ARB_M) { - memcpy(&q->reg[SRSLTE_RESAMPLE_ARB_M - cnt], input, (cnt) * sizeof(cf_t)); + if (cnt < SRSRAN_RESAMPLE_ARB_M) { + memcpy(&q->reg[SRSRAN_RESAMPLE_ARB_M - cnt], input, (cnt) * sizeof(cf_t)); filter_input = q->reg; } else { - filter_input = &input[cnt - SRSLTE_RESAMPLE_ARB_M]; + filter_input = &input[cnt - SRSRAN_RESAMPLE_ARB_M]; } - res1 = srslte_resample_arb_dot_prod(filter_input, srslte_resample_arb_polyfilt[idx], SRSLTE_RESAMPLE_ARB_M); + res1 = srsran_resample_arb_dot_prod(filter_input, srsran_resample_arb_polyfilt[idx], SRSRAN_RESAMPLE_ARB_M); if (q->interpolate) { - res2 = srslte_resample_arb_dot_prod( - filter_input, srslte_resample_arb_polyfilt[(idx + 1) % SRSLTE_RESAMPLE_ARB_N], SRSLTE_RESAMPLE_ARB_M); + res2 = srsran_resample_arb_dot_prod( + filter_input, srsran_resample_arb_polyfilt[(idx + 1) % SRSRAN_RESAMPLE_ARB_N], SRSRAN_RESAMPLE_ARB_M); } - if (idx == SRSLTE_RESAMPLE_ARB_N) { + if (idx == SRSRAN_RESAMPLE_ARB_N) { *output = res1; } else { *output = (q->interpolate) ? (res1 + (res2 - res1) * frac) : res1; @@ -154,9 +154,9 @@ int srslte_resample_arb_compute(srslte_resample_arb_t* q, cf_t* input, cf_t* out q->acc += q->step; idx = (int)(q->acc); - while (idx >= SRSLTE_RESAMPLE_ARB_N) { - q->acc -= SRSLTE_RESAMPLE_ARB_N; - idx -= SRSLTE_RESAMPLE_ARB_N; + while (idx >= SRSRAN_RESAMPLE_ARB_N) { + q->acc -= SRSRAN_RESAMPLE_ARB_N; + idx -= SRSRAN_RESAMPLE_ARB_N; if (cnt < n_in) { cnt++; } diff --git a/lib/src/phy/resampling/resampler.c b/lib/src/phy/resampling/resampler.c index b1ddf3955..6c398ae37 100644 --- a/lib/src/phy/resampling/resampler.c +++ b/lib/src/phy/resampling/resampler.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,12 +11,12 @@ */ #include -#include +#include #include #include -#include "srslte/phy/resampling/resampler.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/resampling/resampler.h" +#include "srsran/phy/utils/vector.h" /** * Raised cosine filter Roll-off @@ -35,38 +35,38 @@ */ #define RESAMPLER_FILTER_SIZE_MIN 64 -int srslte_resampler_fft_init(srslte_resampler_fft_t* q, srslte_resampler_mode_t mode, uint32_t ratio) +int srsran_resampler_fft_init(srsran_resampler_fft_t* q, srsran_resampler_mode_t mode, uint32_t ratio) { if (q == NULL || ratio == 0) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } // Initialising the resampler is unnecessary if (ratio == 1) { q->ratio = 1; - return SRSLTE_ERROR_OUT_OF_BOUNDS; + return SRSRAN_ERROR_OUT_OF_BOUNDS; } if (q->mode == mode && q->ratio == ratio) { - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Make sure interpolator is freed - srslte_resampler_fft_free(q); + srsran_resampler_fft_free(q); // Initialise sizes uint32_t base_size = - SRSLTE_MAX(RESAMPLER_FILTER_SIZE_MIN, (uint32_t)pow(2, ceilf(log2f(ratio) + RESAMPLER_FILTER_SIZE_POW))); + SRSRAN_MAX(RESAMPLER_FILTER_SIZE_MIN, (uint32_t)pow(2, ceilf(log2f(ratio) + RESAMPLER_FILTER_SIZE_POW))); uint32_t input_fft_size = 0; uint32_t output_fft_size = 0; uint32_t high_size = base_size * ratio; switch (mode) { - case SRSLTE_RESAMPLER_MODE_INTERPOLATE: + case SRSRAN_RESAMPLER_MODE_INTERPOLATE: input_fft_size = base_size; output_fft_size = high_size; break; - case SRSLTE_RESAMPLER_MODE_DECIMATE: + case SRSRAN_RESAMPLER_MODE_DECIMATE: default: input_fft_size = high_size; output_fft_size = base_size; @@ -77,38 +77,38 @@ int srslte_resampler_fft_init(srslte_resampler_fft_t* q, srslte_resampler_mode_t q->ratio = ratio; q->window_sz = input_fft_size / 4; - q->in_buffer = srslte_vec_cf_malloc(high_size); + q->in_buffer = srsran_vec_cf_malloc(high_size); if (q->in_buffer == NULL) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - q->out_buffer = srslte_vec_cf_malloc(high_size); + q->out_buffer = srsran_vec_cf_malloc(high_size); if (q->out_buffer == NULL) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } int err = - srslte_dft_plan_guru_c(&q->fft, input_fft_size, SRSLTE_DFT_FORWARD, q->in_buffer, q->out_buffer, 1, 1, 1, 1, 1); - if (err != SRSLTE_SUCCESS) { + srsran_dft_plan_guru_c(&q->fft, input_fft_size, SRSRAN_DFT_FORWARD, q->in_buffer, q->out_buffer, 1, 1, 1, 1, 1); + if (err != SRSRAN_SUCCESS) { ERROR("Initialising DFT"); return err; } - err = srslte_dft_plan_guru_c( - &q->ifft, output_fft_size, SRSLTE_DFT_BACKWARD, q->in_buffer, q->out_buffer, 1, 1, 1, 1, 1); - if (err != SRSLTE_SUCCESS) { + err = srsran_dft_plan_guru_c( + &q->ifft, output_fft_size, SRSRAN_DFT_BACKWARD, q->in_buffer, q->out_buffer, 1, 1, 1, 1, 1); + if (err != SRSRAN_SUCCESS) { ERROR("Initialising DFT"); return err; } - q->state = srslte_vec_cf_malloc(output_fft_size); + q->state = srsran_vec_cf_malloc(output_fft_size); if (q->state == NULL) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - q->filter = srslte_vec_cf_malloc(high_size); + q->filter = srsran_vec_cf_malloc(high_size); if (q->filter == NULL) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Compute time domain filter coefficients, see raised cosine formula in section "1.2 Impulse Response" of @@ -127,29 +127,29 @@ int srslte_resampler_fft_init(srslte_resampler_fft_t* q, srslte_resampler_mode_t } // Compute frequency domain coefficients, since the filter is symmetrical, it does not matter whether FFT or iFFT - if (mode == SRSLTE_RESAMPLER_MODE_INTERPOLATE) { - srslte_dft_run_guru_c(&q->ifft); + if (mode == SRSRAN_RESAMPLER_MODE_INTERPOLATE) { + srsran_dft_run_guru_c(&q->ifft); } else { - srslte_dft_run_guru_c(&q->fft); + srsran_dft_run_guru_c(&q->fft); } // Normalise filter float norm = 1.0f / (cabsf(q->out_buffer[0]) * (float)input_fft_size); - srslte_vec_sc_prod_cfc(q->out_buffer, norm, q->filter, high_size); + srsran_vec_sc_prod_cfc(q->out_buffer, norm, q->filter, high_size); // reset state - srslte_resampler_fft_reset_state(q); + srsran_resampler_fft_reset_state(q); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -void srslte_resampler_fft_reset_state(srslte_resampler_fft_t* q) +void srsran_resampler_fft_reset_state(srsran_resampler_fft_t* q) { q->state_len = 0; - srslte_vec_cf_zero(q->state, q->ifft.size); + srsran_vec_cf_zero(q->state, q->ifft.size); } -static void resampler_fft_interpolate(srslte_resampler_fft_t* q, const cf_t* input, cf_t* output, uint32_t nsamples) +static void resampler_fft_interpolate(srsran_resampler_fft_t* q, const cf_t* input, cf_t* output, uint32_t nsamples) { uint32_t count = 0; @@ -158,51 +158,51 @@ static void resampler_fft_interpolate(srslte_resampler_fft_t* q, const cf_t* inp } while (count < nsamples) { - uint32_t n = SRSLTE_MIN(q->window_sz, nsamples - count); + uint32_t n = SRSRAN_MIN(q->window_sz, nsamples - count); if (input) { // Copy input samples - srslte_vec_cf_copy(q->in_buffer, &input[count], n); + srsran_vec_cf_copy(q->in_buffer, &input[count], n); // Pad zeroes - srslte_vec_cf_zero(&q->in_buffer[n], q->fft.size - n); + srsran_vec_cf_zero(&q->in_buffer[n], q->fft.size - n); // Execute FFT - srslte_dft_run_guru_c(&q->fft); + srsran_dft_run_guru_c(&q->fft); // Replicate input spectrum for (uint32_t i = 1; i < q->ratio; i++) { - srslte_vec_cf_copy(&q->out_buffer[q->fft.size * i], q->out_buffer, q->fft.size); + srsran_vec_cf_copy(&q->out_buffer[q->fft.size * i], q->out_buffer, q->fft.size); } // Apply filtering - srslte_vec_prod_ccc(q->out_buffer, q->filter, q->in_buffer, q->ifft.size); + srsran_vec_prod_ccc(q->out_buffer, q->filter, q->in_buffer, q->ifft.size); // Execute iFFT - srslte_dft_run_guru_c(&q->ifft); + srsran_dft_run_guru_c(&q->ifft); } else { // Equivalent IFFT output of feeding zeroes - srslte_vec_cf_zero(q->out_buffer, q->ifft.size); + srsran_vec_cf_zero(q->out_buffer, q->ifft.size); } // Add previous state - srslte_vec_sum_ccc(q->out_buffer, q->state, q->out_buffer, q->state_len); + srsran_vec_sum_ccc(q->out_buffer, q->state, q->out_buffer, q->state_len); // Copy output if (output) { - srslte_vec_cf_copy(&output[count * q->ratio], q->out_buffer, n * q->ratio); + srsran_vec_cf_copy(&output[count * q->ratio], q->out_buffer, n * q->ratio); } // Save current state q->state_len = q->ifft.size - n * q->ratio; - srslte_vec_cf_copy(q->state, &q->out_buffer[n * q->ratio], q->state_len); + srsran_vec_cf_copy(q->state, &q->out_buffer[n * q->ratio], q->state_len); // Increment count count += n; } } -static void resampler_fft_decimate(srslte_resampler_fft_t* q, const cf_t* input, cf_t* output, uint32_t nsamples) +static void resampler_fft_decimate(srsran_resampler_fft_t* q, const cf_t* input, cf_t* output, uint32_t nsamples) { uint32_t count = 0; @@ -211,49 +211,49 @@ static void resampler_fft_decimate(srslte_resampler_fft_t* q, const cf_t* input, } while (count < nsamples) { - uint32_t n = SRSLTE_MIN(q->window_sz, nsamples - count); + uint32_t n = SRSRAN_MIN(q->window_sz, nsamples - count); if (input) { // Copy input samples - srslte_vec_cf_copy(q->in_buffer, &input[count], q->window_sz); + srsran_vec_cf_copy(q->in_buffer, &input[count], q->window_sz); // Pad zeroes - srslte_vec_cf_zero(&q->in_buffer[n], q->fft.size - n); + srsran_vec_cf_zero(&q->in_buffer[n], q->fft.size - n); // Execute FFT - srslte_dft_run_guru_c(&q->fft); + srsran_dft_run_guru_c(&q->fft); // Apply filtering and cut - srslte_vec_prod_ccc(q->out_buffer, q->filter, q->in_buffer, q->ifft.size / 2); - srslte_vec_prod_ccc(&q->out_buffer[q->fft.size - q->ifft.size / 2], + srsran_vec_prod_ccc(q->out_buffer, q->filter, q->in_buffer, q->ifft.size / 2); + srsran_vec_prod_ccc(&q->out_buffer[q->fft.size - q->ifft.size / 2], &q->filter[q->fft.size - q->ifft.size / 2], &q->in_buffer[q->ifft.size / 2], q->ifft.size / 2); // Execute iFFT - srslte_dft_run_guru_c(&q->ifft); + srsran_dft_run_guru_c(&q->ifft); } else { - srslte_vec_cf_zero(q->out_buffer, q->ifft.size); + srsran_vec_cf_zero(q->out_buffer, q->ifft.size); } // Add previous state - srslte_vec_sum_ccc(q->out_buffer, q->state, q->out_buffer, q->state_len); + srsran_vec_sum_ccc(q->out_buffer, q->state, q->out_buffer, q->state_len); // Copy output if (output) { - srslte_vec_cf_copy(&output[count / q->ratio], q->out_buffer, n / q->ratio); + srsran_vec_cf_copy(&output[count / q->ratio], q->out_buffer, n / q->ratio); } // Save current state q->state_len = q->ifft.size - n / q->ratio; - srslte_vec_cf_copy(q->state, &q->out_buffer[n / q->ratio], q->state_len); + srsran_vec_cf_copy(q->state, &q->out_buffer[n / q->ratio], q->state_len); // Increment count count += n; } } -void srslte_resampler_fft_run(srslte_resampler_fft_t* q, const cf_t* input, cf_t* output, uint32_t nsamples) +void srsran_resampler_fft_run(srsran_resampler_fft_t* q, const cf_t* input, cf_t* output, uint32_t nsamples) { if (q == NULL) { return; @@ -261,29 +261,29 @@ void srslte_resampler_fft_run(srslte_resampler_fft_t* q, const cf_t* input, cf_t // If the ratio is unset (0) or 1, copy samples and return if (q->ratio < 2) { - srslte_vec_cf_copy(output, input, nsamples); + srsran_vec_cf_copy(output, input, nsamples); return; } switch (q->mode) { - case SRSLTE_RESAMPLER_MODE_INTERPOLATE: + case SRSRAN_RESAMPLER_MODE_INTERPOLATE: resampler_fft_interpolate(q, input, output, nsamples); break; - case SRSLTE_RESAMPLER_MODE_DECIMATE: + case SRSRAN_RESAMPLER_MODE_DECIMATE: default: resampler_fft_decimate(q, input, output, nsamples); break; } } -void srslte_resampler_fft_free(srslte_resampler_fft_t* q) +void srsran_resampler_fft_free(srsran_resampler_fft_t* q) { if (q == NULL) { return; } - srslte_dft_plan_free(&q->fft); - srslte_dft_plan_free(&q->ifft); + srsran_dft_plan_free(&q->fft); + srsran_dft_plan_free(&q->ifft); if (q->state) { free(q->state); @@ -298,10 +298,10 @@ void srslte_resampler_fft_free(srslte_resampler_fft_t* q) free(q->filter); } - memset(q, 0, sizeof(srslte_resampler_fft_t)); + memset(q, 0, sizeof(srsran_resampler_fft_t)); } -uint32_t srslte_resampler_fft_get_delay(srslte_resampler_fft_t* q) +uint32_t srsran_resampler_fft_get_delay(srsran_resampler_fft_t* q) { if (q == NULL) { return UINT32_MAX; diff --git a/lib/src/phy/resampling/test/CMakeLists.txt b/lib/src/phy/resampling/test/CMakeLists.txt index 441724a2b..7571db59a 100644 --- a/lib/src/phy/resampling/test/CMakeLists.txt +++ b/lib/src/phy/resampling/test/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -11,10 +11,10 @@ ######################################################################## add_executable(resample_arb_test resample_arb_test.c) -target_link_libraries(resample_arb_test srslte_phy) +target_link_libraries(resample_arb_test srsran_phy) add_executable(resample_arb_bench resample_arb_bench.c) -target_link_libraries(resample_arb_bench srslte_phy) +target_link_libraries(resample_arb_bench srsran_phy) add_test(resample resample_arb_test) @@ -22,7 +22,7 @@ add_test(resample resample_arb_test) # FFT based interpolate/decimate ######################################################################## add_executable(resampler_test resampler_test.c) -target_link_libraries(resampler_test srslte_phy) +target_link_libraries(resampler_test srsran_phy) add_test(resampler_test_2 resampler_test -s 1920 -r 2 -f 2) add_test(resampler_test_3 resampler_test -s 1920 -r 2 -f 3) diff --git a/lib/src/phy/resampling/test/resample_arb_bench.c b/lib/src/phy/resampling/test/resample_arb_bench.c index fd87a50f5..9d1a529b9 100644 --- a/lib/src/phy/resampling/test/resample_arb_bench.c +++ b/lib/src/phy/resampling/test/resample_arb_bench.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -17,26 +17,26 @@ #include #include -#include "srslte/phy/resampling/resample_arb.h" -#include "srslte/srslte.h" +#include "srsran/phy/resampling/resample_arb.h" +#include "srsran/srsran.h" #define ITERATIONS 10000 int main(int argc, char** argv) { int N = 9000; float rate = 24.0 / 25.0; - cf_t* in = srslte_vec_cf_malloc(N); - cf_t* out = srslte_vec_cf_malloc(N); + cf_t* in = srsran_vec_cf_malloc(N); + cf_t* out = srsran_vec_cf_malloc(N); for (int i = 0; i < N; i++) in[i] = sin(i * 2 * M_PI / 100); - srslte_resample_arb_t r; - srslte_resample_arb_init(&r, rate, 0); + srsran_resample_arb_t r; + srsran_resample_arb_init(&r, rate, 0); clock_t start = clock(), diff; for (int xx = 0; xx < ITERATIONS; xx++) { - srslte_resample_arb_compute(&r, in, out, N); + srsran_resample_arb_compute(&r, in, out, N); } diff = clock() - start; diff --git a/lib/src/phy/resampling/test/resample_arb_test.c b/lib/src/phy/resampling/test/resample_arb_test.c index 2d6da8e34..4b8b14067 100644 --- a/lib/src/phy/resampling/test/resample_arb_test.c +++ b/lib/src/phy/resampling/test/resample_arb_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -17,8 +17,8 @@ #include #include -#include "srslte/phy/resampling/resample_arb.h" -#include "srslte/srslte.h" +#include "srsran/phy/resampling/resample_arb.h" +#include "srsran/srsran.h" int main(int argc, char** argv) { @@ -30,12 +30,12 @@ int main(int argc, char** argv) float rate = up / down; printf("Testing rate %f\n", rate); - cf_t* in = srslte_vec_cf_malloc(N); + cf_t* in = srsran_vec_cf_malloc(N); if (!in) { perror("malloc"); exit(-1); } - cf_t* out = srslte_vec_cf_malloc(N); + cf_t* out = srsran_vec_cf_malloc(N); if (!out) { perror("malloc"); exit(-1); @@ -45,9 +45,9 @@ int main(int argc, char** argv) in[i] = sin(i * 2 * M_PI / N); // Resample - srslte_resample_arb_t r; - srslte_resample_arb_init(&r, rate, 0); - int n_out = srslte_resample_arb_compute(&r, in, out, N); + srsran_resample_arb_t r; + srsran_resample_arb_init(&r, rate, 0); + int n_out = srsran_resample_arb_compute(&r, in, out, N); // Check interp values for (int i = delay + 1; i < n_out; i++) { diff --git a/lib/src/phy/resampling/test/resampler_test.c b/lib/src/phy/resampling/test/resampler_test.c index 82a0c353c..9478f3ffc 100644 --- a/lib/src/phy/resampling/test/resampler_test.c +++ b/lib/src/phy/resampling/test/resampler_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,9 +10,9 @@ * */ -#include "srslte/phy/resampling/resampler.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/resampling/resampler.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" #include #include #include @@ -54,30 +54,30 @@ static void parse_args(int argc, char** argv) int main(int argc, char** argv) { struct timeval t[3] = {}; - srslte_resampler_fft_t interp = {}; - srslte_resampler_fft_t decim = {}; + srsran_resampler_fft_t interp = {}; + srsran_resampler_fft_t decim = {}; parse_args(argc, argv); - cf_t* src = srslte_vec_cf_malloc(buffer_size); - cf_t* interpolated = srslte_vec_cf_malloc(buffer_size * factor); - cf_t* decimated = srslte_vec_cf_malloc(buffer_size); + cf_t* src = srsran_vec_cf_malloc(buffer_size); + cf_t* interpolated = srsran_vec_cf_malloc(buffer_size * factor); + cf_t* decimated = srsran_vec_cf_malloc(buffer_size); - if (srslte_resampler_fft_init(&interp, SRSLTE_RESAMPLER_MODE_INTERPOLATE, factor)) { - return SRSLTE_ERROR; + if (srsran_resampler_fft_init(&interp, SRSRAN_RESAMPLER_MODE_INTERPOLATE, factor)) { + return SRSRAN_ERROR; } - if (srslte_resampler_fft_init(&decim, SRSLTE_RESAMPLER_MODE_DECIMATE, factor)) { - return SRSLTE_ERROR; + if (srsran_resampler_fft_init(&decim, SRSRAN_RESAMPLER_MODE_DECIMATE, factor)) { + return SRSRAN_ERROR; } - srslte_vec_cf_zero(src, buffer_size); - srslte_vec_gen_sine(1.0f, 0.01f, src, buffer_size / 10); + srsran_vec_cf_zero(src, buffer_size); + srsran_vec_gen_sine(1.0f, 0.01f, src, buffer_size / 10); gettimeofday(&t[1], NULL); for (uint32_t r = 0; r < repetitions; r++) { - srslte_resampler_fft_run(&interp, src, interpolated, buffer_size); - srslte_resampler_fft_run(&decim, interpolated, decimated, buffer_size * factor); + srsran_resampler_fft_run(&interp, src, interpolated, buffer_size); + srsran_resampler_fft_run(&decim, interpolated, decimated, buffer_size * factor); } gettimeofday(&t[2], NULL); get_time_interval(t); @@ -85,25 +85,25 @@ int main(int argc, char** argv) printf("Done %.1f Msps\n", factor * buffer_size * repetitions / (double)duration_us); // printf("interp="); - // srslte_vec_fprint_c(stdout, interpolated, buffer_size * factor); + // srsran_vec_fprint_c(stdout, interpolated, buffer_size * factor); // Check error - uint32_t delay = srslte_resampler_fft_get_delay(&decim) * 2; + uint32_t delay = srsran_resampler_fft_get_delay(&decim) * 2; uint32_t nsamples = buffer_size - delay; - srslte_vec_sub_ccc(src, &decimated[delay], interpolated, nsamples); - float mse = sqrtf(srslte_vec_avg_power_cf(interpolated, nsamples)); + srsran_vec_sub_ccc(src, &decimated[delay], interpolated, nsamples); + float mse = sqrtf(srsran_vec_avg_power_cf(interpolated, nsamples)); printf("MSE: %f\n", mse); // printf("src="); - // srslte_vec_fprint_c(stdout, src, nsamples); + // srsran_vec_fprint_c(stdout, src, nsamples); // printf("decim="); - // srslte_vec_fprint_c(stdout, &decimated[delay], nsamples); + // srsran_vec_fprint_c(stdout, &decimated[delay], nsamples); - srslte_resampler_fft_free(&interp); - srslte_resampler_fft_free(&decim); + srsran_resampler_fft_free(&interp); + srsran_resampler_fft_free(&decim); free(src); free(interpolated); free(decimated); - return (mse < 0.1f) ? SRSLTE_SUCCESS : SRSLTE_ERROR; + return (mse < 0.1f) ? SRSRAN_SUCCESS : SRSRAN_ERROR; } \ No newline at end of file diff --git a/lib/src/phy/rf/CMakeLists.txt b/lib/src/phy/rf/CMakeLists.txt index 7b2b79f2f..6155dd877 100644 --- a/lib/src/phy/rf/CMakeLists.txt +++ b/lib/src/phy/rf/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -8,8 +8,8 @@ if(RF_FOUND) # This library is only used by the examples - add_library(srslte_rf_utils STATIC rf_utils.c) - target_link_libraries(srslte_rf_utils srslte_phy) + add_library(srsran_rf_utils STATIC rf_utils.c) + target_link_libraries(srsran_rf_utils srsran_phy) # Include common RF files set(SOURCES_RF "") @@ -33,7 +33,7 @@ if(RF_FOUND) if (UHD_FOUND AND UHD_ENABLE_CUSTOM_RFNOC) add_executable(rfnoc_test rfnoc_test.cc) - target_link_libraries(rfnoc_test srslte_rf ${UHD_LIBRARIES} ${Boost_LIBRARIES} /usr/lib/x86_64-linux-gnu/libboost_system.so) + target_link_libraries(rfnoc_test srsran_rf ${UHD_LIBRARIES} ${Boost_LIBRARIES} /usr/lib/x86_64-linux-gnu/libboost_system.so) message(info ${Boost_LIBRARIES}) endif (UHD_FOUND AND UHD_ENABLE_CUSTOM_RFNOC) @@ -52,28 +52,28 @@ if(RF_FOUND) list(APPEND SOURCES_RF rf_zmq_imp.c rf_zmq_imp_tx.c rf_zmq_imp_rx.c) endif (ZEROMQ_FOUND) - add_library(srslte_rf SHARED ${SOURCES_RF}) - target_link_libraries(srslte_rf srslte_rf_utils srslte_phy) - set_target_properties(srslte_rf PROPERTIES VERSION ${SRSLTE_VERSION_STRING} SOVERSION ${SRSLTE_SOVERSION}) + add_library(srsran_rf SHARED ${SOURCES_RF}) + target_link_libraries(srsran_rf srsran_rf_utils srsran_phy) + set_target_properties(srsran_rf PROPERTIES VERSION ${SRSRAN_VERSION_STRING} SOVERSION ${SRSRAN_SOVERSION}) if (UHD_FOUND) - target_link_libraries(srslte_rf ${UHD_LIBRARIES}) + target_link_libraries(srsran_rf ${UHD_LIBRARIES}) endif (UHD_FOUND) if (BLADERF_FOUND) - target_link_libraries(srslte_rf ${BLADERF_LIBRARIES}) + target_link_libraries(srsran_rf ${BLADERF_LIBRARIES}) endif (BLADERF_FOUND) if (SOAPYSDR_FOUND AND ENABLE_SOAPYSDR) - target_link_libraries(srslte_rf ${SOAPYSDR_LIBRARIES}) + target_link_libraries(srsran_rf ${SOAPYSDR_LIBRARIES}) endif (SOAPYSDR_FOUND AND ENABLE_SOAPYSDR) if (ZEROMQ_FOUND) - target_link_libraries(srslte_rf ${ZEROMQ_LIBRARIES}) + target_link_libraries(srsran_rf ${ZEROMQ_LIBRARIES}) add_executable(rf_zmq_test rf_zmq_test.c) - target_link_libraries(rf_zmq_test srslte_rf) + target_link_libraries(rf_zmq_test srsran_rf) #add_test(rf_zmq_test rf_zmq_test) endif (ZEROMQ_FOUND) - INSTALL(TARGETS srslte_rf DESTINATION ${LIBRARY_DIR}) + INSTALL(TARGETS srsran_rf DESTINATION ${LIBRARY_DIR}) endif(RF_FOUND) diff --git a/lib/src/phy/rf/rf_blade_imp.c b/lib/src/phy/rf/rf_blade_imp.c index b55870f87..52fca3fcb 100644 --- a/lib/src/phy/rf/rf_blade_imp.c +++ b/lib/src/phy/rf/rf_blade_imp.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -15,7 +15,7 @@ #include #include "rf_blade_imp.h" -#include "srslte/srslte.h" +#include "srsran/srsran.h" #define UNUSED __attribute__((unused)) #define CONVERT_BUFFER_SIZE (240 * 1024) @@ -28,10 +28,10 @@ typedef struct { int16_t tx_buffer[CONVERT_BUFFER_SIZE]; bool rx_stream_enabled; bool tx_stream_enabled; - srslte_rf_info_t info; + srsran_rf_info_t info; } rf_blade_handler_t; -static srslte_rf_error_handler_t blade_error_handler = NULL; +static srsran_rf_error_handler_t blade_error_handler = NULL; static void* blade_error_handler_arg = NULL; void rf_blade_suppress_stdout(UNUSED void* h) @@ -39,7 +39,7 @@ void rf_blade_suppress_stdout(UNUSED void* h) bladerf_log_set_verbosity(BLADERF_LOG_LEVEL_SILENT); } -void rf_blade_register_error_handler(UNUSED void* ptr, srslte_rf_error_handler_t new_handler, void* arg) +void rf_blade_register_error_handler(UNUSED void* ptr, srsran_rf_error_handler_t new_handler, void* arg) { blade_error_handler = new_handler; blade_error_handler_arg = arg; @@ -220,7 +220,7 @@ int rf_blade_open(char* args, void** h) handler->info.min_rx_gain = range_rx->min; handler->info.max_rx_gain = range_rx->max; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; clean_exit: free(handler); @@ -284,9 +284,9 @@ int rf_blade_set_rx_gain(void* h, double gain) status = bladerf_set_gain(handler->dev, BLADERF_RX_X1, (bladerf_gain)gain); if (status != 0) { ERROR("Failed to set RX gain: %s", bladerf_strerror(status)); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int rf_blade_set_rx_gain_ch(void* h, uint32_t ch, double gain) @@ -301,9 +301,9 @@ int rf_blade_set_tx_gain(void* h, double gain) status = bladerf_set_gain(handler->dev, BLADERF_TX_X1, (bladerf_gain)gain); if (status != 0) { ERROR("Failed to set TX gain: %s", bladerf_strerror(status)); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int rf_blade_set_tx_gain_ch(void* h, uint32_t ch, double gain) @@ -337,9 +337,9 @@ double rf_blade_get_tx_gain(void* h) return gain; } -srslte_rf_info_t* rf_blade_get_info(void* h) +srsran_rf_info_t* rf_blade_get_info(void* h) { - srslte_rf_info_t* info = NULL; + srsran_rf_info_t* info = NULL; if (h) { rf_blade_handler_t* handler = (rf_blade_handler_t*)h; @@ -439,9 +439,9 @@ int rf_blade_recv_with_time(void* h, return -1; } else if (meta.status & BLADERF_META_STATUS_OVERRUN) { if (blade_error_handler) { - srslte_rf_error_t error; + srsran_rf_error_t error; error.opt = meta.actual_count; - error.type = SRSLTE_RF_ERROR_OVERFLOW; + error.type = SRSRAN_RF_ERROR_OVERFLOW; blade_error_handler(blade_error_handler_arg, error); } else { /*ERROR("Overrun detected in scheduled RX. " @@ -450,7 +450,7 @@ int rf_blade_recv_with_time(void* h, } timestamp_to_secs(handler->rx_rate, meta.timestamp, secs, frac_secs); - srslte_vec_convert_if(handler->rx_buffer, 2048, data, 2 * nsamples); + srsran_vec_convert_if(handler->rx_buffer, 2048, data, 2 * nsamples); return nsamples; } @@ -492,14 +492,14 @@ int rf_blade_send_timed(void* h, return -1; } - srslte_vec_convert_fi(data, 2048, handler->tx_buffer, 2 * nsamples); + srsran_vec_convert_fi(data, 2048, handler->tx_buffer, 2 * nsamples); memset(&meta, 0, sizeof(meta)); if (is_start_of_burst) { if (has_time_spec) { // Convert time to ticks - srslte_timestamp_t ts = {.full_secs = secs, .frac_secs = frac_secs}; - meta.timestamp = srslte_timestamp_uint64(&ts, handler->tx_rate); + srsran_timestamp_t ts = {.full_secs = secs, .frac_secs = frac_secs}; + meta.timestamp = srsran_timestamp_uint64(&ts, handler->tx_rate); } else { meta.flags |= BLADERF_META_FLAG_TX_NOW; } @@ -508,13 +508,13 @@ int rf_blade_send_timed(void* h, if (is_end_of_burst) { meta.flags |= BLADERF_META_FLAG_TX_BURST_END; } - srslte_rf_error_t error; - bzero(&error, sizeof(srslte_rf_error_t)); + srsran_rf_error_t error; + bzero(&error, sizeof(srsran_rf_error_t)); status = bladerf_sync_tx(handler->dev, handler->tx_buffer, nsamples, &meta, 2000); if (status == BLADERF_ERR_TIME_PAST) { if (blade_error_handler) { - error.type = SRSLTE_RF_ERROR_LATE; + error.type = SRSRAN_RF_ERROR_LATE; blade_error_handler(blade_error_handler_arg, error); } else { ERROR("TX failed: %s", bladerf_strerror(status)); @@ -524,7 +524,7 @@ int rf_blade_send_timed(void* h, return status; } else if (meta.status == BLADERF_META_STATUS_UNDERRUN) { if (blade_error_handler) { - error.type = SRSLTE_RF_ERROR_UNDERFLOW; + error.type = SRSRAN_RF_ERROR_UNDERFLOW; blade_error_handler(blade_error_handler_arg, error); } else { ERROR("TX warning: underflow detected."); diff --git a/lib/src/phy/rf/rf_blade_imp.h b/lib/src/phy/rf/rf_blade_imp.h index ccae58981..f86e1e570 100644 --- a/lib/src/phy/rf/rf_blade_imp.h +++ b/lib/src/phy/rf/rf_blade_imp.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,68 +10,68 @@ * */ -#include "srslte/config.h" -#include "srslte/phy/rf/rf.h" +#include "srsran/config.h" +#include "srsran/phy/rf/rf.h" #define DEVNAME "bladerf" -SRSLTE_API int rf_blade_open(char* args, void** handler); +SRSRAN_API int rf_blade_open(char* args, void** handler); -SRSLTE_API int rf_blade_open_multi(char* args, void** handler, uint32_t nof_channels); +SRSRAN_API int rf_blade_open_multi(char* args, void** handler, uint32_t nof_channels); -SRSLTE_API const char* rf_blade_devname(void* h); +SRSRAN_API const char* rf_blade_devname(void* h); -SRSLTE_API int rf_blade_close(void* h); +SRSRAN_API int rf_blade_close(void* h); -SRSLTE_API int rf_blade_start_rx_stream(void* h, bool now); +SRSRAN_API int rf_blade_start_rx_stream(void* h, bool now); -SRSLTE_API int rf_blade_start_rx_stream_nsamples(void* h, uint32_t nsamples); +SRSRAN_API int rf_blade_start_rx_stream_nsamples(void* h, uint32_t nsamples); -SRSLTE_API int rf_blade_stop_rx_stream(void* h); +SRSRAN_API int rf_blade_stop_rx_stream(void* h); -SRSLTE_API void rf_blade_flush_buffer(void* h); +SRSRAN_API void rf_blade_flush_buffer(void* h); -SRSLTE_API bool rf_blade_has_rssi(void* h); +SRSRAN_API bool rf_blade_has_rssi(void* h); -SRSLTE_API float rf_blade_get_rssi(void* h); +SRSRAN_API float rf_blade_get_rssi(void* h); -SRSLTE_API double rf_blade_set_rx_srate(void* h, double freq); +SRSRAN_API double rf_blade_set_rx_srate(void* h, double freq); -SRSLTE_API int rf_blade_set_rx_gain(void* h, double gain); +SRSRAN_API int rf_blade_set_rx_gain(void* h, double gain); -SRSLTE_API int rf_blade_set_rx_gain_ch(void* h, uint32_t ch, double gain); +SRSRAN_API int rf_blade_set_rx_gain_ch(void* h, uint32_t ch, double gain); -SRSLTE_API float rf_blade_get_rx_gain_offset(void* h); +SRSRAN_API float rf_blade_get_rx_gain_offset(void* h); -SRSLTE_API double rf_blade_get_rx_gain(void* h); +SRSRAN_API double rf_blade_get_rx_gain(void* h); -SRSLTE_API double rf_blade_get_tx_gain(void* h); +SRSRAN_API double rf_blade_get_tx_gain(void* h); -SRSLTE_API srslte_rf_info_t* rf_blade_get_info(void* h); +SRSRAN_API srsran_rf_info_t* rf_blade_get_info(void* h); -SRSLTE_API void rf_blade_suppress_stdout(void* h); +SRSRAN_API void rf_blade_suppress_stdout(void* h); -SRSLTE_API void rf_blade_register_error_handler(void* h, srslte_rf_error_handler_t error_handler, void* arg); +SRSRAN_API void rf_blade_register_error_handler(void* h, srsran_rf_error_handler_t error_handler, void* arg); -SRSLTE_API double rf_blade_set_rx_freq(void* h, uint32_t ch, double freq); +SRSRAN_API double rf_blade_set_rx_freq(void* h, uint32_t ch, double freq); -SRSLTE_API int +SRSRAN_API int rf_blade_recv_with_time_multi(void* h, void** data, uint32_t nsamples, bool blocking, time_t* secs, double* frac_secs); -SRSLTE_API int +SRSRAN_API int rf_blade_recv_with_time(void* h, void* data, uint32_t nsamples, bool blocking, time_t* secs, double* frac_secs); -SRSLTE_API double rf_blade_set_tx_srate(void* h, double freq); +SRSRAN_API double rf_blade_set_tx_srate(void* h, double freq); -SRSLTE_API int rf_blade_set_tx_gain(void* h, double gain); +SRSRAN_API int rf_blade_set_tx_gain(void* h, double gain); -SRSLTE_API int rf_blade_set_tx_gain_ch(void* h, uint32_t ch, double gain); +SRSRAN_API int rf_blade_set_tx_gain_ch(void* h, uint32_t ch, double gain); -SRSLTE_API double rf_blade_set_tx_freq(void* h, uint32_t ch, double freq); +SRSRAN_API double rf_blade_set_tx_freq(void* h, uint32_t ch, double freq); -SRSLTE_API void rf_blade_get_time(void* h, time_t* secs, double* frac_secs); +SRSRAN_API void rf_blade_get_time(void* h, time_t* secs, double* frac_secs); -SRSLTE_API int rf_blade_send_timed_multi(void* h, +SRSRAN_API int rf_blade_send_timed_multi(void* h, void* data[4], int nsamples, time_t secs, @@ -81,7 +81,7 @@ SRSLTE_API int rf_blade_send_timed_multi(void* h, bool is_start_of_burst, bool is_end_of_burst); -SRSLTE_API int rf_blade_send_timed(void* h, +SRSRAN_API int rf_blade_send_timed(void* h, void* data, int nsamples, time_t secs, diff --git a/lib/src/phy/rf/rf_dev.h b/lib/src/phy/rf/rf_dev.h index 044f87b81..20a818149 100644 --- a/lib/src/phy/rf/rf_dev.h +++ b/lib/src/phy/rf/rf_dev.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,49 +10,49 @@ * */ -#include "srslte/phy/rf/rf.h" +#include "srsran/phy/rf/rf.h" #include /* RF frontend API */ typedef struct { const char* name; - const char* (*srslte_rf_devname)(void* h); - int (*srslte_rf_start_rx_stream)(void* h, bool now); - int (*srslte_rf_stop_rx_stream)(void* h); - void (*srslte_rf_flush_buffer)(void* h); - bool (*srslte_rf_has_rssi)(void* h); - float (*srslte_rf_get_rssi)(void* h); - void (*srslte_rf_suppress_stdout)(void* h); - void (*srslte_rf_register_error_handler)(void* h, srslte_rf_error_handler_t error_handler, void* arg); - int (*srslte_rf_open)(char* args, void** h); - int (*srslte_rf_open_multi)(char* args, void** h, uint32_t nof_channels); - int (*srslte_rf_close)(void* h); - double (*srslte_rf_set_rx_srate)(void* h, double freq); - int (*srslte_rf_set_rx_gain)(void* h, double gain); - int (*srslte_rf_set_rx_gain_ch)(void* h, uint32_t ch, double gain); - int (*srslte_rf_set_tx_gain)(void* h, double gain); - int (*srslte_rf_set_tx_gain_ch)(void* h, uint32_t ch, double gain); - double (*srslte_rf_get_rx_gain)(void* h); - double (*srslte_rf_get_tx_gain)(void* h); - srslte_rf_info_t* (*srslte_rf_get_info)(void* h); - double (*srslte_rf_set_rx_freq)(void* h, uint32_t ch, double freq); - double (*srslte_rf_set_tx_srate)(void* h, double freq); - double (*srslte_rf_set_tx_freq)(void* h, uint32_t ch, double freq); - void (*srslte_rf_get_time)(void* h, time_t* secs, double* frac_secs); - void (*srslte_rf_sync_pps)(void* h); - int (*srslte_rf_recv_with_time)(void* h, + const char* (*srsran_rf_devname)(void* h); + int (*srsran_rf_start_rx_stream)(void* h, bool now); + int (*srsran_rf_stop_rx_stream)(void* h); + void (*srsran_rf_flush_buffer)(void* h); + bool (*srsran_rf_has_rssi)(void* h); + float (*srsran_rf_get_rssi)(void* h); + void (*srsran_rf_suppress_stdout)(void* h); + void (*srsran_rf_register_error_handler)(void* h, srsran_rf_error_handler_t error_handler, void* arg); + int (*srsran_rf_open)(char* args, void** h); + int (*srsran_rf_open_multi)(char* args, void** h, uint32_t nof_channels); + int (*srsran_rf_close)(void* h); + double (*srsran_rf_set_rx_srate)(void* h, double freq); + int (*srsran_rf_set_rx_gain)(void* h, double gain); + int (*srsran_rf_set_rx_gain_ch)(void* h, uint32_t ch, double gain); + int (*srsran_rf_set_tx_gain)(void* h, double gain); + int (*srsran_rf_set_tx_gain_ch)(void* h, uint32_t ch, double gain); + double (*srsran_rf_get_rx_gain)(void* h); + double (*srsran_rf_get_tx_gain)(void* h); + srsran_rf_info_t* (*srsran_rf_get_info)(void* h); + double (*srsran_rf_set_rx_freq)(void* h, uint32_t ch, double freq); + double (*srsran_rf_set_tx_srate)(void* h, double freq); + double (*srsran_rf_set_tx_freq)(void* h, uint32_t ch, double freq); + void (*srsran_rf_get_time)(void* h, time_t* secs, double* frac_secs); + void (*srsran_rf_sync_pps)(void* h); + int (*srsran_rf_recv_with_time)(void* h, void* data, uint32_t nsamples, bool blocking, time_t* secs, double* frac_secs); - int (*srslte_rf_recv_with_time_multi)(void* h, + int (*srsran_rf_recv_with_time_multi)(void* h, void** data, uint32_t nsamples, bool blocking, time_t* secs, double* frac_secs); - int (*srslte_rf_send_timed)(void* h, + int (*srsran_rf_send_timed)(void* h, void* data, int nsamples, time_t secs, @@ -61,7 +61,7 @@ typedef struct { bool blocking, bool is_start_of_burst, bool is_end_of_burst); - int (*srslte_rf_send_timed_multi)(void* h, + int (*srsran_rf_send_timed_multi)(void* h, void** data, int nsamples, time_t secs, @@ -87,7 +87,7 @@ static rf_dev_t dev_uhd = {"UHD", rf_uhd_suppress_stdout, rf_uhd_register_error_handler, rf_uhd_open, - .srslte_rf_open_multi = rf_uhd_open_multi, + .srsran_rf_open_multi = rf_uhd_open_multi, rf_uhd_close, rf_uhd_set_rx_srate, rf_uhd_set_rx_gain, @@ -105,7 +105,7 @@ static rf_dev_t dev_uhd = {"UHD", rf_uhd_recv_with_time, rf_uhd_recv_with_time_multi, rf_uhd_send_timed, - .srslte_rf_send_timed_multi = rf_uhd_send_timed_multi}; + .srsran_rf_send_timed_multi = rf_uhd_send_timed_multi}; #endif /* Define implementation for bladeRF */ @@ -123,7 +123,7 @@ static rf_dev_t dev_blade = {"bladeRF", rf_blade_suppress_stdout, rf_blade_register_error_handler, rf_blade_open, - .srslte_rf_open_multi = rf_blade_open_multi, + .srsran_rf_open_multi = rf_blade_open_multi, rf_blade_close, rf_blade_set_rx_srate, rf_blade_set_rx_gain, @@ -141,7 +141,7 @@ static rf_dev_t dev_blade = {"bladeRF", rf_blade_recv_with_time, rf_blade_recv_with_time_multi, rf_blade_send_timed, - .srslte_rf_send_timed_multi = rf_blade_send_timed_multi}; + .srsran_rf_send_timed_multi = rf_blade_send_timed_multi}; #endif #ifdef ENABLE_SOAPYSDR @@ -176,7 +176,7 @@ static rf_dev_t dev_soapy = {"soapy", rf_soapy_recv_with_time, rf_soapy_recv_with_time_multi, rf_soapy_send_timed, - .srslte_rf_send_timed_multi = rf_soapy_send_timed_multi}; + .srsran_rf_send_timed_multi = rf_soapy_send_timed_multi}; #endif @@ -195,7 +195,7 @@ static rf_dev_t dev_zmq = {"zmq", rf_zmq_suppress_stdout, rf_zmq_register_error_handler, rf_zmq_open, - .srslte_rf_open_multi = rf_zmq_open_multi, + .srsran_rf_open_multi = rf_zmq_open_multi, rf_zmq_close, rf_zmq_set_rx_srate, rf_zmq_set_rx_gain, @@ -213,7 +213,7 @@ static rf_dev_t dev_zmq = {"zmq", rf_zmq_recv_with_time, rf_zmq_recv_with_time_multi, rf_zmq_send_timed, - .srslte_rf_send_timed_multi = rf_zmq_send_timed_multi}; + .srsran_rf_send_timed_multi = rf_zmq_send_timed_multi}; #endif //#define ENABLE_DUMMY_DEV diff --git a/lib/src/phy/rf/rf_helper.h b/lib/src/phy/rf/rf_helper.h index 9d5cba450..1b05a69c5 100644 --- a/lib/src/phy/rf/rf_helper.h +++ b/lib/src/phy/rf/rf_helper.h @@ -2,20 +2,20 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of * the distribution. * */ -#ifndef SRSLTE_RF_HELPER_H_ -#define SRSLTE_RF_HELPER_H_ +#ifndef SRSRAN_RF_HELPER_H_ +#define SRSRAN_RF_HELPER_H_ // A bunch of helper functions to process device arguments -#include "srslte/config.h" -#include "srslte/phy/rf/rf.h" +#include "srsran/config.h" +#include "srsran/phy/rf/rf.h" #include #include #include @@ -48,7 +48,7 @@ static inline void copy_subdev_string(char* dst, char* src) static inline int parse_string(char* args, const char* config_arg_base, int channel_index, char param_dst[RF_PARAM_LEN]) { - int ret = SRSLTE_ERROR; + int ret = SRSRAN_ERROR; if (args == NULL) { return ret; @@ -78,7 +78,7 @@ static inline int parse_string(char* args, const char* config_arg_base, int chan } if (snprintf(param_dst, RF_PARAM_LEN, "%s", config_str) < 0) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // concatenate key=value and remove both (avoid removing the same value twice if it occurs twice in rf_args) @@ -86,7 +86,7 @@ static inline int parse_string(char* args, const char* config_arg_base, int chan snprintf(config_pair, RF_PARAM_LEN * 2, "%s%s", config_key, config_str); remove_substring(args, config_pair); - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; @@ -98,7 +98,7 @@ static inline int parse_double(char* args, const char* config_arg_base, int chan int ret = parse_string(args, config_arg_base, channel_index, tmp_value); // Copy parsed value only if was found, otherwise it keeps the default - if (ret == SRSLTE_SUCCESS) { + if (ret == SRSRAN_SUCCESS) { *value = strtod(tmp_value, NULL); } @@ -111,7 +111,7 @@ static inline int parse_uint32(char* args, const char* config_arg_base, int chan int ret = parse_string(args, config_arg_base, channel_index, tmp_value); // Copy parsed value only if was found, otherwise it keeps the default - if (ret == SRSLTE_SUCCESS) { + if (ret == SRSRAN_SUCCESS) { *value = (uint32_t)strtof(tmp_value, NULL); } @@ -124,11 +124,11 @@ static inline int parse_int32(char* args, const char* config_arg_base, int chann int ret = parse_string(args, config_arg_base, channel_index, tmp_value); // Copy parsed value only if was found, otherwise it keeps the default - if (ret == SRSLTE_SUCCESS) { + if (ret == SRSRAN_SUCCESS) { *value = (int32_t)strtof(tmp_value, NULL); } return ret; } -#endif /* SRSLTE_RF_HELPER_H_ */ +#endif /* SRSRAN_RF_HELPER_H_ */ diff --git a/lib/src/phy/rf/rf_imp.c b/lib/src/phy/rf/rf_imp.c index f24c4bf1f..59f2e6920 100644 --- a/lib/src/phy/rf/rf_imp.c +++ b/lib/src/phy/rf/rf_imp.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,8 +13,8 @@ #include #include "rf_dev.h" -#include "srslte/phy/rf/rf.h" -#include "srslte/srslte.h" +#include "srsran/phy/rf/rf.h" +#include "srsran/srsran.h" int rf_get_available_devices(char** devnames, int max_strlen) { @@ -26,7 +26,7 @@ int rf_get_available_devices(char** devnames, int max_strlen) return i; } -int srslte_rf_set_rx_gain_th(srslte_rf_t* rf, double gain) +int srsran_rf_set_rx_gain_th(srsran_rf_t* rf, double gain) { if (gain > rf->cur_rx_gain + 2 || gain < rf->cur_rx_gain - 2) { pthread_mutex_lock(&rf->mutex); @@ -34,10 +34,10 @@ int srslte_rf_set_rx_gain_th(srslte_rf_t* rf, double gain) pthread_cond_signal(&rf->cond); pthread_mutex_unlock(&rf->mutex); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -void srslte_rf_set_tx_rx_gain_offset(srslte_rf_t* rf, double offset) +void srsran_rf_set_tx_rx_gain_offset(srsran_rf_t* rf, double offset) { rf->tx_rx_gain_offset = offset; } @@ -45,7 +45,7 @@ void srslte_rf_set_tx_rx_gain_offset(srslte_rf_t* rf, double offset) /* This thread listens for set_rx_gain commands to the USRP */ static void* thread_gain_fcn(void* h) { - srslte_rf_t* rf = (srslte_rf_t*)h; + srsran_rf_t* rf = (srsran_rf_t*)h; while (rf->thread_gain_run) { pthread_mutex_lock(&rf->mutex); @@ -53,12 +53,12 @@ static void* thread_gain_fcn(void* h) pthread_cond_wait(&rf->cond, &rf->mutex); } if (rf->new_rx_gain != rf->cur_rx_gain) { - srslte_rf_set_rx_gain(h, rf->new_rx_gain); - rf->cur_rx_gain = srslte_rf_get_rx_gain(h); + srsran_rf_set_rx_gain(h, rf->new_rx_gain); + rf->cur_rx_gain = srsran_rf_get_rx_gain(h); rf->new_rx_gain = rf->cur_rx_gain; } if (rf->tx_gain_same_rx) { - srslte_rf_set_tx_gain(h, rf->cur_rx_gain + rf->tx_rx_gain_offset); + srsran_rf_set_tx_gain(h, rf->cur_rx_gain + rf->tx_rx_gain_offset); } pthread_mutex_unlock(&rf->mutex); } @@ -66,7 +66,7 @@ static void* thread_gain_fcn(void* h) } /* Create auxiliary thread and mutexes for AGC */ -int srslte_rf_start_gain_thread(srslte_rf_t* rf, bool tx_gain_same_rx) +int srsran_rf_start_gain_thread(srsran_rf_t* rf, bool tx_gain_same_rx) { rf->tx_gain_same_rx = tx_gain_same_rx; rf->tx_rx_gain_offset = 0.0; @@ -85,12 +85,12 @@ int srslte_rf_start_gain_thread(srslte_rf_t* rf, bool tx_gain_same_rx) return 0; } -const char* srslte_rf_get_devname(srslte_rf_t* rf) +const char* srsran_rf_get_devname(srsran_rf_t* rf) { return ((rf_dev_t*)rf->dev)->name; } -int srslte_rf_open_devname(srslte_rf_t* rf, const char* devname, char* args, uint32_t nof_channels) +int srsran_rf_open_devname(srsran_rf_t* rf, const char* devname, char* args, uint32_t nof_channels) { rf->thread_gain_run = false; /* Try to open the device if name is provided */ @@ -100,7 +100,7 @@ int srslte_rf_open_devname(srslte_rf_t* rf, const char* devname, char* args, uin while (available_devices[i] != NULL) { if (!strcasecmp(available_devices[i]->name, devname)) { rf->dev = available_devices[i]; - return available_devices[i]->srslte_rf_open_multi(args, &rf->handler, nof_channels); + return available_devices[i]->srsran_rf_open_multi(args, &rf->handler, nof_channels); } i++; } @@ -111,7 +111,7 @@ int srslte_rf_open_devname(srslte_rf_t* rf, const char* devname, char* args, uin /* If in auto mode or provided device not found, try to open in order of apperance in available_devices[] array */ int i = 0; while (available_devices[i] != NULL) { - if (!available_devices[i]->srslte_rf_open_multi(args, &rf->handler, nof_channels)) { + if (!available_devices[i]->srsran_rf_open_multi(args, &rf->handler, nof_channels)) { rf->dev = available_devices[i]; return 0; } @@ -121,57 +121,57 @@ int srslte_rf_open_devname(srslte_rf_t* rf, const char* devname, char* args, uin return -1; } -const char* srslte_rf_name(srslte_rf_t* rf) +const char* srsran_rf_name(srsran_rf_t* rf) { - return ((rf_dev_t*)rf->dev)->srslte_rf_devname(rf->handler); + return ((rf_dev_t*)rf->dev)->srsran_rf_devname(rf->handler); } -int srslte_rf_start_rx_stream(srslte_rf_t* rf, bool now) +int srsran_rf_start_rx_stream(srsran_rf_t* rf, bool now) { - return ((rf_dev_t*)rf->dev)->srslte_rf_start_rx_stream(rf->handler, now); + return ((rf_dev_t*)rf->dev)->srsran_rf_start_rx_stream(rf->handler, now); } -int srslte_rf_stop_rx_stream(srslte_rf_t* rf) +int srsran_rf_stop_rx_stream(srsran_rf_t* rf) { - return ((rf_dev_t*)rf->dev)->srslte_rf_stop_rx_stream(rf->handler); + return ((rf_dev_t*)rf->dev)->srsran_rf_stop_rx_stream(rf->handler); } -void srslte_rf_flush_buffer(srslte_rf_t* rf) +void srsran_rf_flush_buffer(srsran_rf_t* rf) { - ((rf_dev_t*)rf->dev)->srslte_rf_flush_buffer(rf->handler); + ((rf_dev_t*)rf->dev)->srsran_rf_flush_buffer(rf->handler); } -bool srslte_rf_has_rssi(srslte_rf_t* rf) +bool srsran_rf_has_rssi(srsran_rf_t* rf) { - return ((rf_dev_t*)rf->dev)->srslte_rf_has_rssi(rf->handler); + return ((rf_dev_t*)rf->dev)->srsran_rf_has_rssi(rf->handler); } -float srslte_rf_get_rssi(srslte_rf_t* rf) +float srsran_rf_get_rssi(srsran_rf_t* rf) { - return ((rf_dev_t*)rf->dev)->srslte_rf_get_rssi(rf->handler); + return ((rf_dev_t*)rf->dev)->srsran_rf_get_rssi(rf->handler); } -void srslte_rf_suppress_stdout(srslte_rf_t* rf) +void srsran_rf_suppress_stdout(srsran_rf_t* rf) { - ((rf_dev_t*)rf->dev)->srslte_rf_suppress_stdout(rf->handler); + ((rf_dev_t*)rf->dev)->srsran_rf_suppress_stdout(rf->handler); } -void srslte_rf_register_error_handler(srslte_rf_t* rf, srslte_rf_error_handler_t error_handler, void* arg) +void srsran_rf_register_error_handler(srsran_rf_t* rf, srsran_rf_error_handler_t error_handler, void* arg) { - ((rf_dev_t*)rf->dev)->srslte_rf_register_error_handler(rf->handler, error_handler, arg); + ((rf_dev_t*)rf->dev)->srsran_rf_register_error_handler(rf->handler, error_handler, arg); } -int srslte_rf_open(srslte_rf_t* h, char* args) +int srsran_rf_open(srsran_rf_t* h, char* args) { - return srslte_rf_open_devname(h, NULL, args, 1); + return srsran_rf_open_devname(h, NULL, args, 1); } -int srslte_rf_open_multi(srslte_rf_t* h, char* args, uint32_t nof_channels) +int srsran_rf_open_multi(srsran_rf_t* h, char* args, uint32_t nof_channels) { - return srslte_rf_open_devname(h, NULL, args, nof_channels); + return srsran_rf_open_devname(h, NULL, args, nof_channels); } -int srslte_rf_close(srslte_rf_t* rf) +int srsran_rf_close(srsran_rf_t* rf) { // Stop gain thread if (rf->thread_gain_run) { @@ -180,117 +180,117 @@ int srslte_rf_close(srslte_rf_t* rf) pthread_join(rf->thread_gain, NULL); } - return ((rf_dev_t*)rf->dev)->srslte_rf_close(rf->handler); + return ((rf_dev_t*)rf->dev)->srsran_rf_close(rf->handler); } -double srslte_rf_set_rx_srate(srslte_rf_t* rf, double freq) +double srsran_rf_set_rx_srate(srsran_rf_t* rf, double freq) { - return ((rf_dev_t*)rf->dev)->srslte_rf_set_rx_srate(rf->handler, freq); + return ((rf_dev_t*)rf->dev)->srsran_rf_set_rx_srate(rf->handler, freq); } -int srslte_rf_set_rx_gain(srslte_rf_t* rf, double gain) +int srsran_rf_set_rx_gain(srsran_rf_t* rf, double gain) { - return ((rf_dev_t*)rf->dev)->srslte_rf_set_rx_gain(rf->handler, gain); + return ((rf_dev_t*)rf->dev)->srsran_rf_set_rx_gain(rf->handler, gain); } -int srslte_rf_set_rx_gain_ch(srslte_rf_t* rf, uint32_t ch, double gain) +int srsran_rf_set_rx_gain_ch(srsran_rf_t* rf, uint32_t ch, double gain) { - return ((rf_dev_t*)rf->dev)->srslte_rf_set_rx_gain_ch(rf->handler, ch, gain); + return ((rf_dev_t*)rf->dev)->srsran_rf_set_rx_gain_ch(rf->handler, ch, gain); } -double srslte_rf_get_rx_gain(srslte_rf_t* rf) +double srsran_rf_get_rx_gain(srsran_rf_t* rf) { - return ((rf_dev_t*)rf->dev)->srslte_rf_get_rx_gain(rf->handler); + return ((rf_dev_t*)rf->dev)->srsran_rf_get_rx_gain(rf->handler); } -double srslte_rf_get_tx_gain(srslte_rf_t* rf) +double srsran_rf_get_tx_gain(srsran_rf_t* rf) { - return ((rf_dev_t*)rf->dev)->srslte_rf_get_tx_gain(rf->handler); + return ((rf_dev_t*)rf->dev)->srsran_rf_get_tx_gain(rf->handler); } -srslte_rf_info_t* srslte_rf_get_info(srslte_rf_t* rf) +srsran_rf_info_t* srsran_rf_get_info(srsran_rf_t* rf) { - srslte_rf_info_t* ret = NULL; - if (((rf_dev_t*)rf->dev)->srslte_rf_get_info) { - ret = ((rf_dev_t*)rf->dev)->srslte_rf_get_info(rf->handler); + srsran_rf_info_t* ret = NULL; + if (((rf_dev_t*)rf->dev)->srsran_rf_get_info) { + ret = ((rf_dev_t*)rf->dev)->srsran_rf_get_info(rf->handler); } return ret; } -double srslte_rf_set_rx_freq(srslte_rf_t* rf, uint32_t ch, double freq) +double srsran_rf_set_rx_freq(srsran_rf_t* rf, uint32_t ch, double freq) { - return ((rf_dev_t*)rf->dev)->srslte_rf_set_rx_freq(rf->handler, ch, freq); + return ((rf_dev_t*)rf->dev)->srsran_rf_set_rx_freq(rf->handler, ch, freq); } -int srslte_rf_recv(srslte_rf_t* rf, void* data, uint32_t nsamples, bool blocking) +int srsran_rf_recv(srsran_rf_t* rf, void* data, uint32_t nsamples, bool blocking) { - return srslte_rf_recv_with_time(rf, data, nsamples, blocking, NULL, NULL); + return srsran_rf_recv_with_time(rf, data, nsamples, blocking, NULL, NULL); } -int srslte_rf_recv_multi(srslte_rf_t* rf, void** data, uint32_t nsamples, bool blocking) +int srsran_rf_recv_multi(srsran_rf_t* rf, void** data, uint32_t nsamples, bool blocking) { - return srslte_rf_recv_with_time_multi(rf, data, nsamples, blocking, NULL, NULL); + return srsran_rf_recv_with_time_multi(rf, data, nsamples, blocking, NULL, NULL); } -int srslte_rf_recv_with_time(srslte_rf_t* rf, +int srsran_rf_recv_with_time(srsran_rf_t* rf, void* data, uint32_t nsamples, bool blocking, time_t* secs, double* frac_secs) { - return ((rf_dev_t*)rf->dev)->srslte_rf_recv_with_time(rf->handler, data, nsamples, blocking, secs, frac_secs); + return ((rf_dev_t*)rf->dev)->srsran_rf_recv_with_time(rf->handler, data, nsamples, blocking, secs, frac_secs); } -int srslte_rf_recv_with_time_multi(srslte_rf_t* rf, +int srsran_rf_recv_with_time_multi(srsran_rf_t* rf, void** data, uint32_t nsamples, bool blocking, time_t* secs, double* frac_secs) { - return ((rf_dev_t*)rf->dev)->srslte_rf_recv_with_time_multi(rf->handler, data, nsamples, blocking, secs, frac_secs); + return ((rf_dev_t*)rf->dev)->srsran_rf_recv_with_time_multi(rf->handler, data, nsamples, blocking, secs, frac_secs); } -int srslte_rf_set_tx_gain(srslte_rf_t* rf, double gain) +int srsran_rf_set_tx_gain(srsran_rf_t* rf, double gain) { - return ((rf_dev_t*)rf->dev)->srslte_rf_set_tx_gain(rf->handler, gain); + return ((rf_dev_t*)rf->dev)->srsran_rf_set_tx_gain(rf->handler, gain); } -int srslte_rf_set_tx_gain_ch(srslte_rf_t* rf, uint32_t ch, double gain) +int srsran_rf_set_tx_gain_ch(srsran_rf_t* rf, uint32_t ch, double gain) { - return ((rf_dev_t*)rf->dev)->srslte_rf_set_tx_gain_ch(rf->handler, ch, gain); + return ((rf_dev_t*)rf->dev)->srsran_rf_set_tx_gain_ch(rf->handler, ch, gain); } -double srslte_rf_set_tx_srate(srslte_rf_t* rf, double freq) +double srsran_rf_set_tx_srate(srsran_rf_t* rf, double freq) { - return ((rf_dev_t*)rf->dev)->srslte_rf_set_tx_srate(rf->handler, freq); + return ((rf_dev_t*)rf->dev)->srsran_rf_set_tx_srate(rf->handler, freq); } -double srslte_rf_set_tx_freq(srslte_rf_t* rf, uint32_t ch, double freq) +double srsran_rf_set_tx_freq(srsran_rf_t* rf, uint32_t ch, double freq) { - return ((rf_dev_t*)rf->dev)->srslte_rf_set_tx_freq(rf->handler, ch, freq); + return ((rf_dev_t*)rf->dev)->srsran_rf_set_tx_freq(rf->handler, ch, freq); } -void srslte_rf_get_time(srslte_rf_t* rf, time_t* secs, double* frac_secs) +void srsran_rf_get_time(srsran_rf_t* rf, time_t* secs, double* frac_secs) { - return ((rf_dev_t*)rf->dev)->srslte_rf_get_time(rf->handler, secs, frac_secs); + return ((rf_dev_t*)rf->dev)->srsran_rf_get_time(rf->handler, secs, frac_secs); } -int srslte_rf_sync(srslte_rf_t* rf) +int srsran_rf_sync(srsran_rf_t* rf) { - int ret = SRSLTE_ERROR; + int ret = SRSRAN_ERROR; - if (((rf_dev_t*)rf->dev)->srslte_rf_sync_pps) { - ((rf_dev_t*)rf->dev)->srslte_rf_sync_pps(rf->handler); + if (((rf_dev_t*)rf->dev)->srsran_rf_sync_pps) { + ((rf_dev_t*)rf->dev)->srsran_rf_sync_pps(rf->handler); - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } -int srslte_rf_send_timed3(srslte_rf_t* rf, +int srsran_rf_send_timed3(srsran_rf_t* rf, void* data, int nsamples, time_t secs, @@ -301,11 +301,11 @@ int srslte_rf_send_timed3(srslte_rf_t* rf, bool is_end_of_burst) { return ((rf_dev_t*)rf->dev) - ->srslte_rf_send_timed( + ->srsran_rf_send_timed( rf->handler, data, nsamples, secs, frac_secs, has_time_spec, blocking, is_start_of_burst, is_end_of_burst); } -int srslte_rf_send_timed_multi(srslte_rf_t* rf, +int srsran_rf_send_timed_multi(srsran_rf_t* rf, void** data, int nsamples, time_t secs, @@ -315,11 +315,11 @@ int srslte_rf_send_timed_multi(srslte_rf_t* rf, bool is_end_of_burst) { return ((rf_dev_t*)rf->dev) - ->srslte_rf_send_timed_multi( + ->srsran_rf_send_timed_multi( rf->handler, data, nsamples, secs, frac_secs, true, blocking, is_start_of_burst, is_end_of_burst); } -int srslte_rf_send_multi(srslte_rf_t* rf, +int srsran_rf_send_multi(srsran_rf_t* rf, void** data, int nsamples, bool blocking, @@ -327,31 +327,31 @@ int srslte_rf_send_multi(srslte_rf_t* rf, bool is_end_of_burst) { return ((rf_dev_t*)rf->dev) - ->srslte_rf_send_timed_multi( + ->srsran_rf_send_timed_multi( rf->handler, data, nsamples, 0, 0, false, blocking, is_start_of_burst, is_end_of_burst); } -int srslte_rf_send(srslte_rf_t* rf, void* data, uint32_t nsamples, bool blocking) +int srsran_rf_send(srsran_rf_t* rf, void* data, uint32_t nsamples, bool blocking) { - return srslte_rf_send2(rf, data, nsamples, blocking, true, true); + return srsran_rf_send2(rf, data, nsamples, blocking, true, true); } -int srslte_rf_send2(srslte_rf_t* rf, +int srsran_rf_send2(srsran_rf_t* rf, void* data, uint32_t nsamples, bool blocking, bool start_of_burst, bool end_of_burst) { - return srslte_rf_send_timed3(rf, data, nsamples, 0, 0, false, blocking, start_of_burst, end_of_burst); + return srsran_rf_send_timed3(rf, data, nsamples, 0, 0, false, blocking, start_of_burst, end_of_burst); } -int srslte_rf_send_timed(srslte_rf_t* rf, void* data, int nsamples, time_t secs, double frac_secs) +int srsran_rf_send_timed(srsran_rf_t* rf, void* data, int nsamples, time_t secs, double frac_secs) { - return srslte_rf_send_timed2(rf, data, nsamples, secs, frac_secs, true, true); + return srsran_rf_send_timed2(rf, data, nsamples, secs, frac_secs, true, true); } -int srslte_rf_send_timed2(srslte_rf_t* rf, +int srsran_rf_send_timed2(srsran_rf_t* rf, void* data, int nsamples, time_t secs, @@ -359,5 +359,5 @@ int srslte_rf_send_timed2(srslte_rf_t* rf, bool is_start_of_burst, bool is_end_of_burst) { - return srslte_rf_send_timed3(rf, data, nsamples, secs, frac_secs, true, true, is_start_of_burst, is_end_of_burst); + return srsran_rf_send_timed3(rf, data, nsamples, secs, frac_secs, true, true, is_start_of_burst, is_end_of_burst); } diff --git a/lib/src/phy/rf/rf_soapy_imp.c b/lib/src/phy/rf/rf_soapy_imp.c index 206ba0010..dac04c128 100644 --- a/lib/src/phy/rf/rf_soapy_imp.c +++ b/lib/src/phy/rf/rf_soapy_imp.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -17,7 +17,7 @@ #include "rf_helper.h" #include "rf_soapy_imp.h" -#include "srslte/srslte.h" +#include "srsran/srsran.h" #include #include @@ -44,13 +44,13 @@ typedef struct { SoapySDRStream* txStream; bool tx_stream_active; bool rx_stream_active; - srslte_rf_info_t info; + srsran_rf_info_t info; double tx_rate; size_t rx_mtu, tx_mtu; size_t num_rx_channels; size_t num_tx_channels; - srslte_rf_error_handler_t soapy_error_handler; + srsran_rf_error_handler_t soapy_error_handler; void* soapy_error_handler_arg; bool async_thread_running; @@ -69,9 +69,9 @@ cf_t zero_mem[64 * 1024]; static void log_overflow(rf_soapy_handler_t* h) { if (h->soapy_error_handler) { - srslte_rf_error_t error; - bzero(&error, sizeof(srslte_rf_error_t)); - error.type = SRSLTE_RF_ERROR_OVERFLOW; + srsran_rf_error_t error; + bzero(&error, sizeof(srsran_rf_error_t)); + error.type = SRSRAN_RF_ERROR_OVERFLOW; h->soapy_error_handler(h->soapy_error_handler_arg, error); } else { h->num_overflows++; @@ -81,10 +81,10 @@ static void log_overflow(rf_soapy_handler_t* h) static void log_late(rf_soapy_handler_t* h, bool is_rx) { if (h->soapy_error_handler) { - srslte_rf_error_t error; - bzero(&error, sizeof(srslte_rf_error_t)); + srsran_rf_error_t error; + bzero(&error, sizeof(srsran_rf_error_t)); error.opt = is_rx ? 1 : 0; - error.type = SRSLTE_RF_ERROR_LATE; + error.type = SRSRAN_RF_ERROR_LATE; h->soapy_error_handler(h->soapy_error_handler_arg, error); } else { h->num_lates++; @@ -94,9 +94,9 @@ static void log_late(rf_soapy_handler_t* h, bool is_rx) static void log_underflow(rf_soapy_handler_t* h) { if (h->soapy_error_handler) { - srslte_rf_error_t error; - bzero(&error, sizeof(srslte_rf_error_t)); - error.type = SRSLTE_RF_ERROR_UNDERFLOW; + srsran_rf_error_t error; + bzero(&error, sizeof(srsran_rf_error_t)); + error.type = SRSRAN_RF_ERROR_UNDERFLOW; h->soapy_error_handler(h->soapy_error_handler_arg, error); } else { h->num_underflows++; @@ -168,7 +168,7 @@ void rf_soapy_suppress_stdout(void* h) // not supported } -void rf_soapy_register_error_handler(void* h, srslte_rf_error_handler_t new_handler, void* arg) +void rf_soapy_register_error_handler(void* h, srsran_rf_error_handler_t new_handler, void* arg) { rf_soapy_handler_t* handler = (rf_soapy_handler_t*)h; handler->soapy_error_handler = new_handler; @@ -206,12 +206,12 @@ int rf_soapy_start_rx_stream(void* h, bool now) if (handler->rx_stream_active == false) { if (SoapySDRDevice_activateStream(handler->device, handler->rxStream, 0, 0, 0) != 0) { printf("Error starting Rx streaming.\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } handler->rx_stream_active = true; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int rf_soapy_start_tx_stream(void* h) @@ -220,11 +220,11 @@ int rf_soapy_start_tx_stream(void* h) if (handler->tx_stream_active == false) { if (SoapySDRDevice_activateStream(handler->device, handler->txStream, 0, 0, 0) != 0) { printf("Error starting Tx streaming.\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } handler->tx_stream_active = true; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int rf_soapy_stop_rx_stream(void* h) @@ -232,11 +232,11 @@ int rf_soapy_stop_rx_stream(void* h) rf_soapy_handler_t* handler = (rf_soapy_handler_t*)h; if (SoapySDRDevice_deactivateStream(handler->device, handler->rxStream, 0, 0) != 0) { printf("Error deactivating Rx streaming.\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } handler->rx_stream_active = false; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int rf_soapy_stop_tx_stream(void* h) @@ -244,11 +244,11 @@ int rf_soapy_stop_tx_stream(void* h) rf_soapy_handler_t* handler = (rf_soapy_handler_t*)h; if (SoapySDRDevice_deactivateStream(handler->device, handler->txStream, 0, 0) != 0) { printf("Error deactivating Tx streaming.\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } handler->tx_stream_active = false; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } void rf_soapy_flush_buffer(void* h) @@ -285,7 +285,7 @@ int rf_soapy_open_multi(char* args, void** h, uint32_t num_requested_channels) if (length == 0) { printf("No Soapy devices found.\n"); SoapySDRKwargsList_clear(soapy_args, length); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } char* devname = DEVNAME_NONE; for (size_t i = 0; i < length; i++) { @@ -302,7 +302,7 @@ int rf_soapy_open_multi(char* args, void** h, uint32_t num_requested_channels) } // With the Lime we are better off using LTE sample rates - if (strcmp(devname, "Lime") && srslte_symbol_size_is_standard() == false) { + if (strcmp(devname, "Lime") && srsran_symbol_size_is_standard() == false) { printf("\033[0;31mConsider using LTE sample rates for better RF performance.\nEither compile with " "\'-DUSE_LTE_RATES=True\' or start srsENB or srsUE with \'--expert.lte_sample_rates=true\'\033[0m\n"); } @@ -326,13 +326,13 @@ int rf_soapy_open_multi(char* args, void** h, uint32_t num_requested_channels) } // select last device if dev_id exceeds available devices - dev_id = SRSLTE_MIN(dev_id, length - 1); + dev_id = SRSRAN_MIN(dev_id, length - 1); printf("Selecting Soapy device: %d\n", dev_id); SoapySDRDevice* sdr = SoapySDRDevice_make(&(soapy_args[dev_id])); if (sdr == NULL) { printf("Failed to create Soapy object\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } SoapySDRKwargsList_clear(soapy_args, length); @@ -354,7 +354,7 @@ int rf_soapy_open_multi(char* args, void** h, uint32_t num_requested_channels) // Setup Rx streamer size_t num_available_channels = SoapySDRDevice_getNumChannels(handler->device, SOAPY_SDR_RX); if ((num_available_channels > 0) && (num_requested_channels > 0)) { - handler->num_rx_channels = SRSLTE_MIN(num_available_channels, num_requested_channels); + handler->num_rx_channels = SRSRAN_MIN(num_available_channels, num_requested_channels); size_t rx_channels[handler->num_rx_channels]; for (int i = 0; i < handler->num_rx_channels; i++) { rx_channels[i] = i; @@ -374,7 +374,7 @@ int rf_soapy_open_multi(char* args, void** h, uint32_t num_requested_channels) if (handler->rxStream == NULL) { #endif printf("Rx setupStream fail: %s\n", SoapySDRDevice_lastError()); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } handler->rx_mtu = SoapySDRDevice_getStreamMTU(handler->device, handler->rxStream); } @@ -382,7 +382,7 @@ int rf_soapy_open_multi(char* args, void** h, uint32_t num_requested_channels) // Setup Tx streamer num_available_channels = SoapySDRDevice_getNumChannels(handler->device, SOAPY_SDR_TX); if ((num_available_channels > 0) && (num_requested_channels > 0)) { - handler->num_tx_channels = SRSLTE_MIN(num_available_channels, num_requested_channels); + handler->num_tx_channels = SRSRAN_MIN(num_available_channels, num_requested_channels); size_t tx_channels[handler->num_tx_channels]; for (int i = 0; i < handler->num_tx_channels; i++) { tx_channels[i] = i; @@ -402,7 +402,7 @@ int rf_soapy_open_multi(char* args, void** h, uint32_t num_requested_channels) if (handler->txStream == NULL) { #endif printf("Tx setupStream fail: %s\n", SoapySDRDevice_lastError()); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } handler->tx_mtu = SoapySDRDevice_getStreamMTU(handler->device, handler->txStream); } @@ -540,7 +540,7 @@ int rf_soapy_open_multi(char* args, void** h, uint32_t num_requested_channels) } #endif - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int rf_soapy_open(char* args, void** h) @@ -585,7 +585,7 @@ int rf_soapy_close(void* h) free(handler); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } double rf_soapy_set_rx_srate(void* h, double rate) @@ -603,7 +603,7 @@ double rf_soapy_set_rx_srate(void* h, double rate) for (uint32_t i = 0; i < handler->num_rx_channels; i++) { if (SoapySDRDevice_setSampleRate(handler->device, SOAPY_SDR_RX, i, rate) != 0) { printf("setSampleRate Rx fail: %s\n", SoapySDRDevice_lastError()); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } #if SET_RF_BW @@ -612,11 +612,11 @@ double rf_soapy_set_rx_srate(void* h, double rate) SoapySDRRange* bw_range = SoapySDRDevice_getBandwidthRange(handler->device, SOAPY_SDR_RX, 0, &bw_length); for (int k = 0; k < bw_length; ++k) { double bw = rate * 0.75; - bw = SRSLTE_MIN(bw, bw_range[k].maximum); - bw = SRSLTE_MAX(bw, bw_range[k].minimum); + bw = SRSRAN_MIN(bw, bw_range[k].maximum); + bw = SRSRAN_MAX(bw, bw_range[k].minimum); if (SoapySDRDevice_setBandwidth(handler->device, SOAPY_SDR_RX, i, bw) != 0) { printf("setBandwidth fail: %s\n", SoapySDRDevice_lastError()); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } printf("Set Rx bandwidth to %.2f MHz\n", SoapySDRDevice_getBandwidth(handler->device, SOAPY_SDR_RX, i) / 1e6); } @@ -648,7 +648,7 @@ double rf_soapy_set_tx_srate(void* h, double rate) for (uint32_t i = 0; i < handler->num_tx_channels; i++) { if (SoapySDRDevice_setSampleRate(handler->device, SOAPY_SDR_TX, i, rate) != 0) { printf("setSampleRate Tx fail: %s\n", SoapySDRDevice_lastError()); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } #if SET_RF_BW @@ -658,11 +658,11 @@ double rf_soapy_set_tx_srate(void* h, double rate) // try to set the BW a bit narrower than sampling rate to prevent aliasing but make sure to stay within device // boundaries double bw = rate * 0.75; - bw = SRSLTE_MAX(bw, bw_range[k].minimum); - bw = SRSLTE_MIN(bw, bw_range[k].maximum); + bw = SRSRAN_MAX(bw, bw_range[k].minimum); + bw = SRSRAN_MIN(bw, bw_range[k].maximum); if (SoapySDRDevice_setBandwidth(handler->device, SOAPY_SDR_TX, i, bw) != 0) { printf("setBandwidth fail: %s\n", SoapySDRDevice_lastError()); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } printf("Set Tx bandwidth to %.2f MHz\n", SoapySDRDevice_getBandwidth(handler->device, SOAPY_SDR_TX, i) / 1e6); } @@ -685,10 +685,10 @@ int rf_soapy_set_rx_gain(void* h, double gain) rf_soapy_handler_t* handler = (rf_soapy_handler_t*)h; for (uint32_t i = 0; i < handler->num_rx_channels; i++) { if (rf_soapy_set_rx_gain_ch(h, i, gain) < 0) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int rf_soapy_set_rx_gain_ch(void* h, uint32_t ch, double gain) @@ -696,9 +696,9 @@ int rf_soapy_set_rx_gain_ch(void* h, uint32_t ch, double gain) rf_soapy_handler_t* handler = (rf_soapy_handler_t*)h; if (SoapySDRDevice_setGain(handler->device, SOAPY_SDR_RX, ch, gain) != 0) { printf("setGain fail: %s\n", SoapySDRDevice_lastError()); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int rf_soapy_set_tx_gain(void* h, double gain) @@ -706,10 +706,10 @@ int rf_soapy_set_tx_gain(void* h, double gain) rf_soapy_handler_t* handler = (rf_soapy_handler_t*)h; for (uint32_t i = 0; i < handler->num_tx_channels; i++) { if (rf_soapy_set_tx_gain_ch(h, i, gain) < 0) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int rf_soapy_set_tx_gain_ch(void* h, uint32_t ch, double gain) @@ -717,9 +717,9 @@ int rf_soapy_set_tx_gain_ch(void* h, uint32_t ch, double gain) rf_soapy_handler_t* handler = (rf_soapy_handler_t*)h; if (SoapySDRDevice_setGain(handler->device, SOAPY_SDR_TX, ch, gain) != 0) { printf("setGain fail: %s\n", SoapySDRDevice_lastError()); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Return gain of first channel @@ -736,9 +736,9 @@ double rf_soapy_get_tx_gain(void* h) return SoapySDRDevice_getGain(handler->device, SOAPY_SDR_TX, 0); } -srslte_rf_info_t* rf_soapy_get_info(void* h) +srsran_rf_info_t* rf_soapy_get_info(void* h) { - srslte_rf_info_t* info = NULL; + srsran_rf_info_t* info = NULL; if (h) { rf_soapy_handler_t* handler = (rf_soapy_handler_t*)h; info = &handler->info; @@ -753,7 +753,7 @@ double rf_soapy_set_rx_freq(void* h, uint32_t ch, double freq) for (uint32_t i = 0; i < handler->num_rx_channels; i++) { if (SoapySDRDevice_setFrequency(handler->device, SOAPY_SDR_RX, i, freq, NULL) != 0) { printf("setFrequency fail: %s\n", SoapySDRDevice_lastError()); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } @@ -770,7 +770,7 @@ double rf_soapy_set_tx_freq(void* h, uint32_t ch, double freq) for (uint32_t i = 0; i < handler->num_tx_channels; i++) { if (SoapySDRDevice_setFrequency(handler->device, SOAPY_SDR_TX, i, freq, NULL) != 0) { printf("setFrequency fail: %s\n", SoapySDRDevice_lastError()); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } return SoapySDRDevice_getFrequency(handler->device, SOAPY_SDR_TX, 0); @@ -783,7 +783,7 @@ void rf_soapy_get_time(void* h, time_t* secs, double* frac_secs) // TODO: add multi-channel support int rf_soapy_recv_with_time_multi(void* h, - void* data[SRSLTE_MAX_PORTS], + void* data[SRSRAN_MAX_PORTS], uint32_t nsamples, bool blocking, time_t* secs, @@ -803,12 +803,12 @@ int rf_soapy_recv_with_time_multi(void* h, #endif do { - size_t rx_samples = SRSLTE_MIN(nsamples - n, handler->rx_mtu); + size_t rx_samples = SRSRAN_MIN(nsamples - n, handler->rx_mtu); #if PRINT_RX_STATS printf(" - rx_samples=%zd\n", rx_samples); #endif - void* buffs_ptr[SRSLTE_MAX_PORTS] = {}; + void* buffs_ptr[SRSRAN_MAX_PORTS] = {}; for (int i = 0; i < handler->num_rx_channels; i++) { cf_t* data_c = (cf_t*)data[i]; buffs_ptr[i] = &data_c[n]; @@ -861,14 +861,14 @@ int rf_soapy_send_timed(void* h, bool is_start_of_burst, bool is_end_of_burst) { - void* _data[SRSLTE_MAX_PORTS] = {data, zero_mem, zero_mem, zero_mem}; + void* _data[SRSRAN_MAX_PORTS] = {data, zero_mem, zero_mem, zero_mem}; return rf_soapy_send_timed_multi( h, _data, nsamples, secs, frac_secs, has_time_spec, blocking, is_start_of_burst, is_end_of_burst); } // Todo: Check correct handling of flags, use RF metrics API, fix timed transmissions int rf_soapy_send_timed_multi(void* h, - void* data[SRSLTE_MAX_PORTS], + void* data[SRSRAN_MAX_PORTS], int nsamples, time_t secs, double frac_secs, @@ -901,7 +901,7 @@ int rf_soapy_send_timed_multi(void* h, do { #if USE_TX_MTU - size_t tx_samples = SRSLTE_MIN(nsamples - n, handler->tx_mtu); + size_t tx_samples = SRSRAN_MIN(nsamples - n, handler->tx_mtu); #else size_t tx_samples = nsamples; if (tx_samples > nsamples - n) { @@ -928,7 +928,7 @@ int rf_soapy_send_timed_multi(void* h, printf(" - tx_samples=%zd at timeNs=%llu flags=%d\n", tx_samples, timeNs, flags); #endif - const void* buffs_ptr[SRSLTE_MAX_PORTS] = {}; + const void* buffs_ptr[SRSRAN_MAX_PORTS] = {}; for (int i = 0; i < handler->num_tx_channels; i++) { cf_t* data_c = data[i] ? data[i] : zero_mem; buffs_ptr[i] = &data_c[n]; @@ -976,7 +976,7 @@ int rf_soapy_send_timed_multi(void* h, default: ERROR("Error during writeStream"); exit(-1); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } trials++; diff --git a/lib/src/phy/rf/rf_soapy_imp.h b/lib/src/phy/rf/rf_soapy_imp.h index 586f1a5cc..bcda3e346 100644 --- a/lib/src/phy/rf/rf_soapy_imp.h +++ b/lib/src/phy/rf/rf_soapy_imp.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,74 +10,74 @@ * */ -#ifndef SRSLTE_RF_SOAPY_IMP_H_ -#define SRSLTE_RF_SOAPY_IMP_H_ +#ifndef SRSRAN_RF_SOAPY_IMP_H_ +#define SRSRAN_RF_SOAPY_IMP_H_ -#include "srslte/config.h" -#include "srslte/phy/rf/rf.h" +#include "srsran/config.h" +#include "srsran/phy/rf/rf.h" #include #include #define DEVNAME_NONE "none" #define DEVNAME_LIME "lime" #define DEVNAME_LIME_MINI "lime_mini" -SRSLTE_API int rf_soapy_open(char* args, void** handler); +SRSRAN_API int rf_soapy_open(char* args, void** handler); -SRSLTE_API int rf_soapy_open_multi(char* args, void** handler, uint32_t num_requested_channels); +SRSRAN_API int rf_soapy_open_multi(char* args, void** handler, uint32_t num_requested_channels); -SRSLTE_API const char* rf_soapy_devname(void* h); +SRSRAN_API const char* rf_soapy_devname(void* h); -SRSLTE_API int rf_soapy_close(void* h); +SRSRAN_API int rf_soapy_close(void* h); -SRSLTE_API int rf_soapy_start_rx_stream(void* h, bool now); +SRSRAN_API int rf_soapy_start_rx_stream(void* h, bool now); -SRSLTE_API int rf_soapy_stop_rx_stream(void* h); +SRSRAN_API int rf_soapy_stop_rx_stream(void* h); -SRSLTE_API void rf_soapy_calibrate_tx(void* h); +SRSRAN_API void rf_soapy_calibrate_tx(void* h); -SRSLTE_API void rf_soapy_flush_buffer(void* h); +SRSRAN_API void rf_soapy_flush_buffer(void* h); -SRSLTE_API bool rf_soapy_has_rssi(void* h); +SRSRAN_API bool rf_soapy_has_rssi(void* h); -SRSLTE_API float rf_soapy_get_rssi(void* h); +SRSRAN_API float rf_soapy_get_rssi(void* h); -SRSLTE_API void rf_soapy_set_master_clock_rate(void* h, double rate); +SRSRAN_API void rf_soapy_set_master_clock_rate(void* h, double rate); -SRSLTE_API double rf_soapy_set_rx_srate(void* h, double freq); +SRSRAN_API double rf_soapy_set_rx_srate(void* h, double freq); -SRSLTE_API int rf_soapy_set_rx_gain(void* h, double gain); +SRSRAN_API int rf_soapy_set_rx_gain(void* h, double gain); -SRSLTE_API int rf_soapy_set_rx_gain_ch(void* h, uint32_t ch, double gain); +SRSRAN_API int rf_soapy_set_rx_gain_ch(void* h, uint32_t ch, double gain); -SRSLTE_API double rf_soapy_get_rx_gain(void* h); +SRSRAN_API double rf_soapy_get_rx_gain(void* h); -SRSLTE_API int rf_soapy_set_tx_gain(void* h, double gain); +SRSRAN_API int rf_soapy_set_tx_gain(void* h, double gain); -SRSLTE_API int rf_soapy_set_tx_gain_ch(void* h, uint32_t ch, double gain); +SRSRAN_API int rf_soapy_set_tx_gain_ch(void* h, uint32_t ch, double gain); -SRSLTE_API double rf_soapy_get_tx_gain(void* h); +SRSRAN_API double rf_soapy_get_tx_gain(void* h); -SRSLTE_API srslte_rf_info_t* rf_soapy_get_info(void* h); +SRSRAN_API srsran_rf_info_t* rf_soapy_get_info(void* h); -SRSLTE_API void rf_soapy_suppress_stdout(void* h); +SRSRAN_API void rf_soapy_suppress_stdout(void* h); -SRSLTE_API void rf_soapy_register_error_handler(void* h, srslte_rf_error_handler_t error_handler, void* arg); +SRSRAN_API void rf_soapy_register_error_handler(void* h, srsran_rf_error_handler_t error_handler, void* arg); -SRSLTE_API double rf_soapy_set_rx_freq(void* h, uint32_t ch, double freq); +SRSRAN_API double rf_soapy_set_rx_freq(void* h, uint32_t ch, double freq); -SRSLTE_API int +SRSRAN_API int rf_soapy_recv_with_time(void* h, void* data, uint32_t nsamples, bool blocking, time_t* secs, double* frac_secs); -SRSLTE_API int +SRSRAN_API int rf_soapy_recv_with_time_multi(void* h, void** data, uint32_t nsamples, bool blocking, time_t* secs, double* frac_secs); -SRSLTE_API double rf_soapy_set_tx_srate(void* h, double freq); +SRSRAN_API double rf_soapy_set_tx_srate(void* h, double freq); -SRSLTE_API double rf_soapy_set_tx_freq(void* h, uint32_t ch, double freq); +SRSRAN_API double rf_soapy_set_tx_freq(void* h, uint32_t ch, double freq); -SRSLTE_API void rf_soapy_get_time(void* h, time_t* secs, double* frac_secs); +SRSRAN_API void rf_soapy_get_time(void* h, time_t* secs, double* frac_secs); -SRSLTE_API int rf_soapy_send_timed(void* h, +SRSRAN_API int rf_soapy_send_timed(void* h, void* data, int nsamples, time_t secs, @@ -97,4 +97,4 @@ int rf_soapy_send_timed_multi(void* h, bool is_start_of_burst, bool is_end_of_burst); -#endif /* SRSLTE_RF_SOAPY_IMP_H_ */ +#endif /* SRSRAN_RF_SOAPY_IMP_H_ */ diff --git a/lib/src/phy/rf/rf_uhd_generic.h b/lib/src/phy/rf/rf_uhd_generic.h index 2a7e51ebf..c5049666e 100644 --- a/lib/src/phy/rf/rf_uhd_generic.h +++ b/lib/src/phy/rf/rf_uhd_generic.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,8 +10,8 @@ * */ -#ifndef SRSLTE_RF_UHD_GENERIC_H -#define SRSLTE_RF_UHD_GENERIC_H +#ifndef SRSRAN_RF_UHD_GENERIC_H +#define SRSRAN_RF_UHD_GENERIC_H #include "rf_uhd_safe.h" @@ -370,4 +370,4 @@ public: } }; -#endif // SRSLTE_RF_UHD_GENERIC_H +#endif // SRSRAN_RF_UHD_GENERIC_H diff --git a/lib/src/phy/rf/rf_uhd_imp.cc b/lib/src/phy/rf/rf_uhd_imp.cc index eb2a9f62d..a2c4cb6aa 100644 --- a/lib/src/phy/rf/rf_uhd_imp.cc +++ b/lib/src/phy/rf/rf_uhd_imp.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -19,7 +19,7 @@ #include #include "rf_helper.h" -#include "srslte/srslte.h" +#include "srsran/srsran.h" #include "rf_uhd_generic.h" #include "rf_uhd_imp.h" @@ -116,7 +116,7 @@ struct rf_uhd_handler_t { std::string devname; std::shared_ptr uhd = nullptr; - srslte_rf_info_t info; + srsran_rf_info_t info; size_t rx_nof_samples = 0; size_t tx_nof_samples = 0; double tx_rate = 1.92e6; @@ -124,10 +124,10 @@ struct rf_uhd_handler_t { bool dynamic_master_rate = true; uint32_t nof_rx_channels = 0; uint32_t nof_tx_channels = 0; - std::array tx_freq = {}; - std::array rx_freq = {}; + std::array tx_freq = {}; + std::array rx_freq = {}; - srslte_rf_error_handler_t uhd_error_handler = nullptr; + srsran_rf_error_handler_t uhd_error_handler = nullptr; void* uhd_error_handler_arg = nullptr; rf_uhd_imp_underflow_state_t tx_state = RF_UHD_IMP_TX_STATE_START_BURST; @@ -188,9 +188,9 @@ static void log_overflow(rf_uhd_handler_t* h) } if (h->uhd_error_handler != nullptr) { - srslte_rf_error_t error; - bzero(&error, sizeof(srslte_rf_error_t)); - error.type = srslte_rf_error_t::SRSLTE_RF_ERROR_OVERFLOW; + srsran_rf_error_t error; + bzero(&error, sizeof(srsran_rf_error_t)); + error.type = srsran_rf_error_t::SRSRAN_RF_ERROR_OVERFLOW; h->uhd_error_handler(h->uhd_error_handler_arg, error); } } @@ -202,10 +202,10 @@ static void log_late(rf_uhd_handler_t* h, bool is_rx) } if (h->uhd_error_handler != nullptr) { - srslte_rf_error_t error; - bzero(&error, sizeof(srslte_rf_error_t)); + srsran_rf_error_t error; + bzero(&error, sizeof(srsran_rf_error_t)); error.opt = is_rx ? 1 : 0; - error.type = srslte_rf_error_t::SRSLTE_RF_ERROR_LATE; + error.type = srsran_rf_error_t::SRSRAN_RF_ERROR_LATE; h->uhd_error_handler(h->uhd_error_handler_arg, error); } } @@ -218,9 +218,9 @@ static void log_underflow(rf_uhd_handler_t* h) h->tx_state = RF_UHD_IMP_TX_STATE_END_OF_BURST; } if (h->uhd_error_handler != nullptr) { - srslte_rf_error_t error; - bzero(&error, sizeof(srslte_rf_error_t)); - error.type = srslte_rf_error_t::SRSLTE_RF_ERROR_UNDERFLOW; + srsran_rf_error_t error; + bzero(&error, sizeof(srsran_rf_error_t)); + error.type = srsran_rf_error_t::SRSRAN_RF_ERROR_UNDERFLOW; h->uhd_error_handler(h->uhd_error_handler_arg, error); } } @@ -231,9 +231,9 @@ static void log_rx_error(rf_uhd_handler_t* h) if (h->uhd_error_handler) { ERROR("USRP reported the following error: %s", h->uhd->last_error.c_str()); - srslte_rf_error_t error; - bzero(&error, sizeof(srslte_rf_error_t)); - error.type = srslte_rf_error_t::SRSLTE_RF_ERROR_RX; + srsran_rf_error_t error; + bzero(&error, sizeof(srsran_rf_error_t)); + error.type = srsran_rf_error_t::SRSRAN_RF_ERROR_RX; h->uhd_error_handler(h->uhd_error_handler_arg, error); } } @@ -309,7 +309,7 @@ void rf_uhd_suppress_stdout(void* h) rf_uhd_register_msg_handler_c(suppress_handler); } -void rf_uhd_register_error_handler(void* h, srslte_rf_error_handler_t new_handler, void* arg) +void rf_uhd_register_error_handler(void* h, srsran_rf_error_handler_t new_handler, void* arg) { rf_uhd_handler_t* handler = (rf_uhd_handler_t*)h; handler->uhd_error_handler = new_handler; @@ -346,7 +346,7 @@ static int set_time_to_gps_time(rf_uhd_handler_t* handler) std::vector sensors; if (handler->uhd->get_mboard_sensor_names(sensors) != UHD_ERROR_NONE) { print_usrp_error(handler); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Find sensor @@ -372,17 +372,17 @@ static int set_time_to_gps_time(rf_uhd_handler_t* handler) double frac_secs = 0.0; if (handler->uhd->get_sensor(sensor_name, frac_secs) != UHD_ERROR_NONE) { print_usrp_error(handler); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Get time and set printf("Setting USRP time to %fs\n", frac_secs); if (handler->uhd->set_time_unknown_pps(uhd::time_spec_t(frac_secs)) != UHD_ERROR_NONE) { print_usrp_error(handler); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // timeout in ms @@ -400,13 +400,13 @@ static int wait_sensor_locked(rf_uhd_handler_t* handler, // motherboard sensor if (handler->uhd->get_mboard_sensor_names(sensors) != UHD_ERROR_NONE) { print_usrp_error(handler); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } else { // daughterboard sensor if (handler->uhd->get_rx_sensor_names(sensors) != UHD_ERROR_NONE) { print_usrp_error(handler); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } @@ -434,12 +434,12 @@ static int wait_sensor_locked(rf_uhd_handler_t* handler, if (is_mboard) { if (handler->uhd->get_sensor(sensor_name, is_locked) != UHD_ERROR_NONE) { print_usrp_error(handler); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } else { if (handler->uhd->get_rx_sensor(sensor_name, is_locked) != UHD_ERROR_NONE) { print_usrp_error(handler); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } @@ -448,7 +448,7 @@ static int wait_sensor_locked(rf_uhd_handler_t* handler, timeout -= 1; // 1ms } while (not is_locked and timeout > 0); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } const char* rf_uhd_devname(void* h) @@ -469,7 +469,7 @@ bool rf_uhd_rx_wait_lo_locked(void* h) // blocks until sensor is blocked int error = wait_sensor_locked(handler, sensor_name, false, 300, is_locked); - if (not is_locked and error == SRSLTE_SUCCESS) { + if (not is_locked and error == SRSRAN_SUCCESS) { ERROR("Could not lock reference clock source. Sensor: %s=%s", sensor_name.c_str(), is_locked ? "true" : "false"); } @@ -481,18 +481,18 @@ static inline int rf_uhd_start_rx_stream_unsafe(rf_uhd_handler_t* handler) // Check if stream was not created or started if (not handler->uhd->is_rx_ready() or handler->rx_stream_enabled) { // Ignores command, the stream will start as soon as the Rx sampling rate is set - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Issue stream command if (handler->uhd->start_rx_stream(RF_UHD_IMP_STREAM_DELAY_S) != UHD_ERROR_NONE) { print_usrp_error(handler); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } handler->rx_stream_enabled = true; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int rf_uhd_start_rx_stream(void* h, bool now) @@ -508,18 +508,18 @@ static inline int rf_uhd_stop_rx_stream_unsafe(rf_uhd_handler_t* handler) // Check if stream was created or stream was not started if (not handler->uhd->is_rx_ready() or not handler->rx_stream_enabled) { // Ignores command, the stream will start as soon as the Rx sampling rate is set - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Issue stream command if (handler->uhd->stop_rx_stream() != UHD_ERROR_NONE) { print_usrp_error(handler); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } handler->rx_stream_enabled = false; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int rf_uhd_stop_rx_stream(void* h) @@ -527,15 +527,15 @@ int rf_uhd_stop_rx_stream(void* h) rf_uhd_handler_t* handler = (rf_uhd_handler_t*)h; std::unique_lock lock(handler->rx_mutex); - if (rf_uhd_stop_rx_stream_unsafe(handler) < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (rf_uhd_stop_rx_stream_unsafe(handler) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } // Make sure the Rx stream is flushed lock.unlock(); // Flush has its own lock rf_uhd_flush_buffer(h); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } void rf_uhd_flush_buffer(void* h) @@ -543,7 +543,7 @@ void rf_uhd_flush_buffer(void* h) rf_uhd_handler_t* handler = (rf_uhd_handler_t*)h; std::unique_lock lock(handler->rx_mutex); size_t rxd_samples = 0; - void* data[SRSLTE_MAX_CHANNELS] = {}; + void* data[SRSRAN_MAX_CHANNELS] = {}; // Set all pointers to zero buffer for (auto& i : data) { @@ -735,7 +735,7 @@ static int uhd_init(rf_uhd_handler_t* handler, char* args, uint32_t nof_channels // Make USRP if (handler->uhd->usrp_make(device_addr, nof_channels) != UHD_ERROR_NONE) { print_usrp_error(handler); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Set device internal name, it sets the device name to B200 by default @@ -756,7 +756,7 @@ static int uhd_init(rf_uhd_handler_t* handler, char* args, uint32_t nof_channels std::string mboard_name; if (handler->uhd->get_mboard_name(mboard_name) != UHD_ERROR_NONE) { print_usrp_error(handler); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Make upper case @@ -781,7 +781,7 @@ static int uhd_init(rf_uhd_handler_t* handler, char* args, uint32_t nof_channels // Set sync source if (handler->uhd->set_sync_source(clock_src) != UHD_ERROR_NONE) { print_usrp_error(handler); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (clock_src == "gpsdo") { @@ -796,7 +796,7 @@ static int uhd_init(rf_uhd_handler_t* handler, char* args, uint32_t nof_channels // blocks until clock source is locked int error = wait_sensor_locked(handler, sensor_name, true, 300, is_locked); // Print Not lock error if the return was succesful, wait_sensor_locked prints the error before returning - if (not is_locked and error == SRSLTE_SUCCESS) { + if (not is_locked and error == SRSRAN_SUCCESS) { ERROR( "Could not lock reference clock source. Sensor: %s=%s\n", sensor_name.c_str(), is_locked ? "true" : "false"); } @@ -808,11 +808,11 @@ static int uhd_init(rf_uhd_handler_t* handler, char* args, uint32_t nof_channels // Set default Tx/Rx rates if (handler->uhd->set_rx_rate(handler->rx_rate) != UHD_ERROR_NONE) { print_usrp_error(handler); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (handler->uhd->set_tx_rate(handler->tx_rate) != UHD_ERROR_NONE) { print_usrp_error(handler); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Reset timestamps @@ -822,12 +822,12 @@ static int uhd_init(rf_uhd_handler_t* handler, char* args, uint32_t nof_channels if (handler->uhd->get_rx_stream(handler->rx_nof_samples) != UHD_ERROR_NONE) { print_usrp_error(handler); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (handler->uhd->get_tx_stream(handler->tx_nof_samples) != UHD_ERROR_NONE) { print_usrp_error(handler); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Tune LOs if the default frequency is provided @@ -836,7 +836,7 @@ static int uhd_init(rf_uhd_handler_t* handler, char* args, uint32_t nof_channels if (std::isnormal(handler->rx_freq[i])) { if (handler->uhd->set_rx_freq(i, handler->rx_freq[i], handler->rx_freq[i]) != UHD_ERROR_NONE) { print_usrp_error(handler); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } rf_uhd_rx_wait_lo_locked(handler); require_wait_rx_lock = true; @@ -846,7 +846,7 @@ static int uhd_init(rf_uhd_handler_t* handler, char* args, uint32_t nof_channels if (std::isnormal(handler->tx_freq[i])) { if (handler->uhd->set_tx_freq(i, handler->tx_freq[i], handler->tx_freq[i]) != UHD_ERROR_NONE) { print_usrp_error(handler); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } } @@ -856,7 +856,7 @@ static int uhd_init(rf_uhd_handler_t* handler, char* args, uint32_t nof_channels uhd::gain_range_t rx_gain_range; if (handler->uhd->get_gain_range(tx_gain_range, rx_gain_range) != UHD_ERROR_NONE) { print_usrp_error(handler); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } handler->info.min_tx_gain = tx_gain_range.start(); handler->info.max_tx_gain = tx_gain_range.stop(); @@ -877,22 +877,22 @@ static int uhd_init(rf_uhd_handler_t* handler, char* args, uint32_t nof_channels // Restore priorities if (uhd_set_thread_priority(0, false) != UHD_ERROR_NONE) { print_usrp_error(handler); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int rf_uhd_open_multi(char* args, void** h, uint32_t nof_channels) { // Check valid handler pointer if (h == nullptr) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } - if (nof_channels > SRSLTE_MAX_CHANNELS) { - ERROR("Error opening UHD: maximum number of channels exceeded (%d>%d)", nof_channels, SRSLTE_MAX_CHANNELS); - return SRSLTE_ERROR; + if (nof_channels > SRSRAN_MAX_CHANNELS) { + ERROR("Error opening UHD: maximum number of channels exceeded (%d>%d)", nof_channels, SRSRAN_MAX_CHANNELS); + return SRSRAN_ERROR; } // Create UHD handler @@ -903,21 +903,21 @@ int rf_uhd_open_multi(char* args, void** h, uint32_t nof_channels) *h = handler; // Initialise UHD handler - if (uhd_init(handler, args, nof_channels) < SRSLTE_SUCCESS) { + if (uhd_init(handler, args, nof_channels) < SRSRAN_SUCCESS) { ERROR("uhd_init failed, freeing..."); // Free/Close UHD handler properly uhd_free(handler); *h = nullptr; - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int rf_uhd_close(void* h) { // Makes sure Tx is ended - void* buff[SRSLTE_MAX_CHANNELS] = {}; + void* buff[SRSRAN_MAX_CHANNELS] = {}; rf_uhd_send_timed_multi(h, buff, 0, 0, 0, false, true, false, true); // Makes sure Rx stream is stopped @@ -928,7 +928,7 @@ int rf_uhd_close(void* h) /// Free all UHD safe class uhd_free(handler); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } static inline void rf_uhd_set_master_clock_rate_unsafe(rf_uhd_handler_t* handler, double rate) @@ -945,11 +945,11 @@ static inline void rf_uhd_set_master_clock_rate_unsafe(rf_uhd_handler_t* handler static inline int rf_uhd_imp_end_burst(rf_uhd_handler_t* handler) { uhd::tx_metadata_t md; - void* buffs_ptr[SRSLTE_MAX_CHANNELS] = {}; + void* buffs_ptr[SRSRAN_MAX_CHANNELS] = {}; size_t txd_samples = 0; // Set buffer pointers - for (int i = 0; i < SRSLTE_MAX_CHANNELS; i++) { + for (int i = 0; i < SRSRAN_MAX_CHANNELS; i++) { buffs_ptr[i] = zero_mem; } @@ -961,13 +961,13 @@ static inline int rf_uhd_imp_end_burst(rf_uhd_handler_t* handler) // Actual base-band transmission if (handler->uhd->send(buffs_ptr, 0, md, RF_UHD_IMP_TRX_TIMEOUT_S, txd_samples) != UHD_ERROR_NONE) { print_usrp_error(handler); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Update TX state handler->tx_state = RF_UHD_IMP_TX_STATE_START_BURST; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } double rf_uhd_set_rx_srate(void* h, double freq) @@ -982,8 +982,8 @@ double rf_uhd_set_rx_srate(void* h, double freq) // Stop RX streamer if (RF_UHD_IMP_PROHIBITED_STOP_START.count(handler->devname) == 0) { - if (rf_uhd_stop_rx_stream_unsafe(handler) != SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (rf_uhd_stop_rx_stream_unsafe(handler) != SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } } @@ -996,7 +996,7 @@ double rf_uhd_set_rx_srate(void* h, double freq) uhd::time_spec_t timespec; if (handler->uhd->get_time_now(timespec) != UHD_ERROR_NONE) { print_usrp_error(handler); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } timespec += RF_UHD_IMP_TIMED_COMMAND_DELAY_S; handler->uhd->set_command_time(timespec); @@ -1005,13 +1005,13 @@ double rf_uhd_set_rx_srate(void* h, double freq) // Set RX rate if (handler->uhd->set_rx_rate(freq) != UHD_ERROR_NONE) { print_usrp_error(handler); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (RF_UHD_IMP_PROHIBITED_STREAM_REMAKE.count(handler->devname) == 0) { if (handler->uhd->get_rx_stream(handler->rx_nof_samples) != UHD_ERROR_NONE) { print_usrp_error(handler); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } @@ -1036,8 +1036,8 @@ double rf_uhd_set_tx_srate(void* h, double freq) // End burst if (handler->uhd->is_tx_ready() and handler->tx_state != RF_UHD_IMP_TX_STATE_START_BURST) { - if (rf_uhd_imp_end_burst(handler) != SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (rf_uhd_imp_end_burst(handler) != SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } } @@ -1050,7 +1050,7 @@ double rf_uhd_set_tx_srate(void* h, double freq) uhd::time_spec_t timespec; if (handler->uhd->get_time_now(timespec) != UHD_ERROR_NONE) { print_usrp_error(handler); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } timespec += RF_UHD_IMP_TIMED_COMMAND_DELAY_S; handler->uhd->set_command_time(timespec); @@ -1059,13 +1059,13 @@ double rf_uhd_set_tx_srate(void* h, double freq) // Set TX rate if (handler->uhd->set_tx_rate(freq) != UHD_ERROR_NONE) { print_usrp_error(handler); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (RF_UHD_IMP_PROHIBITED_STREAM_REMAKE.count(handler->devname) == 0) { if (handler->uhd->get_tx_stream(handler->tx_nof_samples) != UHD_ERROR_NONE) { print_usrp_error(handler); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } @@ -1085,10 +1085,10 @@ int rf_uhd_set_rx_gain(void* h, double gain) for (size_t i = 0; i < handler->nof_rx_channels; i++) { if (rf_uhd_set_rx_gain_ch(h, i, gain)) { print_usrp_error(handler); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int rf_uhd_set_rx_gain_ch(void* h, uint32_t ch, double gain) @@ -1096,9 +1096,9 @@ int rf_uhd_set_rx_gain_ch(void* h, uint32_t ch, double gain) rf_uhd_handler_t* handler = (rf_uhd_handler_t*)h; if (handler->uhd->set_rx_gain(ch, gain) != UHD_ERROR_NONE) { print_usrp_error(handler); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int rf_uhd_set_tx_gain(void* h, double gain) @@ -1107,10 +1107,10 @@ int rf_uhd_set_tx_gain(void* h, double gain) for (size_t i = 0; i < handler->nof_tx_channels; i++) { if (rf_uhd_set_tx_gain_ch(h, i, gain)) { print_usrp_error(handler); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int rf_uhd_set_tx_gain_ch(void* h, uint32_t ch, double gain) @@ -1118,9 +1118,9 @@ int rf_uhd_set_tx_gain_ch(void* h, uint32_t ch, double gain) rf_uhd_handler_t* handler = (rf_uhd_handler_t*)h; if (handler->uhd->set_tx_gain(ch, gain) != UHD_ERROR_NONE) { print_usrp_error(handler); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } double rf_uhd_get_rx_gain(void* h) @@ -1130,7 +1130,7 @@ double rf_uhd_get_rx_gain(void* h) if (handler->uhd->get_rx_gain(gain) != UHD_ERROR_NONE) { print_usrp_error(handler); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } return gain; @@ -1143,15 +1143,15 @@ double rf_uhd_get_tx_gain(void* h) if (handler->uhd->get_tx_gain(gain) != UHD_ERROR_NONE) { print_usrp_error(handler); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } return gain; } -srslte_rf_info_t* rf_uhd_get_info(void* h) +srsran_rf_info_t* rf_uhd_get_info(void* h) { - srslte_rf_info_t* info = nullptr; + srsran_rf_info_t* info = nullptr; if (h != nullptr) { rf_uhd_handler_t* handler = (rf_uhd_handler_t*)h; @@ -1252,7 +1252,7 @@ int rf_uhd_recv_with_time(void* h, void* data, uint32_t nsamples, bool blocking, } int rf_uhd_recv_with_time_multi(void* h, - void* data[SRSLTE_MAX_PORTS], + void* data[SRSRAN_MAX_PORTS], uint32_t nsamples, bool blocking, time_t* secs, @@ -1263,26 +1263,26 @@ int rf_uhd_recv_with_time_multi(void* h, size_t rxd_samples = 0; size_t rxd_samples_total = 0; uint32_t trials = 0; - int ret = SRSLTE_ERROR; + int ret = SRSRAN_ERROR; uhd::time_spec_t timespec; uhd::rx_metadata_t md; // Check Rx stream has been created if (not handler->uhd->is_rx_ready()) { // Ignores reception, the stream will start as soon as the Rx sampling rate is set - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Start stream if not started if (not handler->rx_stream_enabled) { - if (rf_uhd_start_rx_stream_unsafe(handler) != SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (rf_uhd_start_rx_stream_unsafe(handler) != SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } } // Receive stream in multiple blocks while (rxd_samples_total < nsamples && trials < RF_UHD_IMP_MAX_RX_TRIALS) { - void* buffs_ptr[SRSLTE_MAX_CHANNELS] = {}; + void* buffs_ptr[SRSRAN_MAX_CHANNELS] = {}; for (uint32_t i = 0; i < handler->nof_rx_channels; i++) { cf_t* data_c = (cf_t*)data[i]; buffs_ptr[i] = &data_c[rxd_samples_total]; @@ -1294,7 +1294,7 @@ int rf_uhd_recv_with_time_multi(void* h, if (handler->uhd->receive(buffs_ptr, num_rx_samples, md, 1.0, false, rxd_samples) != UHD_ERROR_NONE) { log_rx_error(handler); print_usrp_error(handler); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Save timespec for first block @@ -1326,7 +1326,7 @@ int rf_uhd_recv_with_time_multi(void* h, } if (trials >= RF_UHD_IMP_MAX_RX_TRIALS) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } ret = rxd_samples_total; @@ -1351,7 +1351,7 @@ int rf_uhd_send_timed(void* h, bool is_end_of_burst) { // Maximum number of channels to NULL - void* _data[SRSLTE_MAX_CHANNELS] = {}; + void* _data[SRSRAN_MAX_CHANNELS] = {}; // Set only first channel _data[0] = data; @@ -1373,13 +1373,13 @@ int rf_uhd_send_timed_multi(void* h, rf_uhd_handler_t* handler = (rf_uhd_handler_t*)h; std::unique_lock lock(handler->tx_mutex); uhd::tx_metadata_t md; - void* buffs_ptr[SRSLTE_MAX_CHANNELS] = {}; + void* buffs_ptr[SRSRAN_MAX_CHANNELS] = {}; size_t txd_samples = 0; int n = 0; // Check Tx stream has been created if (not handler->uhd->is_tx_ready()) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Run Underflow recovery state machine @@ -1389,14 +1389,14 @@ int rf_uhd_send_timed_multi(void* h, break; case RF_UHD_IMP_TX_STATE_END_OF_BURST: // Send end of burst and ignore transmission - if (rf_uhd_imp_end_burst(handler) != SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (rf_uhd_imp_end_burst(handler) != SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } // Flush receiver rf_uhd_flush_buffer(h); - return SRSLTE_ERROR; + return SRSRAN_ERROR; case RF_UHD_IMP_TX_STATE_START_BURST: // Set tart of burst to false if recovering from the Underflow is_start_of_burst = true; @@ -1410,7 +1410,7 @@ int rf_uhd_send_timed_multi(void* h, // It gets the USRP time for transmissions without time if (handler->uhd->get_time_now(md.time_spec) != UHD_ERROR_NONE) { print_usrp_error(handler); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Add time to metadata @@ -1422,8 +1422,8 @@ int rf_uhd_send_timed_multi(void* h, } // Generate transmission buffer pointers - cf_t* data_c[SRSLTE_MAX_CHANNELS] = {}; - for (uint32_t i = 0; i < SRSLTE_MAX_CHANNELS; i++) { + cf_t* data_c[SRSRAN_MAX_CHANNELS] = {}; + for (uint32_t i = 0; i < SRSRAN_MAX_CHANNELS; i++) { if (i < handler->nof_tx_channels) { data_c[i] = (data[i] != nullptr) ? (cf_t*)(data[i]) : zero_mem; } else { @@ -1454,14 +1454,14 @@ int rf_uhd_send_timed_multi(void* h, md.end_of_burst = is_end_of_burst; } - for (int i = 0; i < SRSLTE_MAX_CHANNELS; i++) { + for (int i = 0; i < SRSRAN_MAX_CHANNELS; i++) { void* buff = (void*)&data_c[i][n]; buffs_ptr[i] = buff; } if (handler->uhd->send(buffs_ptr, tx_samples, md, RF_UHD_IMP_TRX_TIMEOUT_S, txd_samples) != UHD_ERROR_NONE) { print_usrp_error(handler); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Next packets are not start of burst diff --git a/lib/src/phy/rf/rf_uhd_imp.h b/lib/src/phy/rf/rf_uhd_imp.h index ef83ad9ce..c668c770e 100644 --- a/lib/src/phy/rf/rf_uhd_imp.h +++ b/lib/src/phy/rf/rf_uhd_imp.h @@ -2,15 +2,15 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of * the distribution. * */ -#ifndef SRSLTE_RF_UHD_IMP_H_ -#define SRSLTE_RF_UHD_IMP_H_ +#ifndef SRSRAN_RF_UHD_IMP_H_ +#define SRSRAN_RF_UHD_IMP_H_ #include #include @@ -19,9 +19,9 @@ extern "C" { #endif -#include "srslte/config.h" -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/rf/rf.h" +#include "srsran/config.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/rf/rf.h" #define DEVNAME_B200 "uhd_b200" #define DEVNAME_X300 "uhd_x300" @@ -29,61 +29,61 @@ extern "C" { #define DEVNAME_E3X0 "uhd_e3x0" #define DEVNAME_UNKNOWN "uhd_unknown" -SRSLTE_API int rf_uhd_open(char* args, void** handler); +SRSRAN_API int rf_uhd_open(char* args, void** handler); -SRSLTE_API int rf_uhd_open_multi(char* args, void** handler, uint32_t nof_channels); +SRSRAN_API int rf_uhd_open_multi(char* args, void** handler, uint32_t nof_channels); -SRSLTE_API const char* rf_uhd_devname(void* h); +SRSRAN_API const char* rf_uhd_devname(void* h); -SRSLTE_API int rf_uhd_close(void* h); +SRSRAN_API int rf_uhd_close(void* h); -SRSLTE_API int rf_uhd_start_rx_stream(void* h, bool now); +SRSRAN_API int rf_uhd_start_rx_stream(void* h, bool now); -SRSLTE_API int rf_uhd_stop_rx_stream(void* h); +SRSRAN_API int rf_uhd_stop_rx_stream(void* h); -SRSLTE_API void rf_uhd_flush_buffer(void* h); +SRSRAN_API void rf_uhd_flush_buffer(void* h); -SRSLTE_API bool rf_uhd_has_rssi(void* h); +SRSRAN_API bool rf_uhd_has_rssi(void* h); -SRSLTE_API float rf_uhd_get_rssi(void* h); +SRSRAN_API float rf_uhd_get_rssi(void* h); -SRSLTE_API double rf_uhd_set_rx_srate(void* h, double freq); +SRSRAN_API double rf_uhd_set_rx_srate(void* h, double freq); -SRSLTE_API int rf_uhd_set_rx_gain(void* h, double gain); +SRSRAN_API int rf_uhd_set_rx_gain(void* h, double gain); -SRSLTE_API int rf_uhd_set_rx_gain_ch(void* h, uint32_t ch, double gain); +SRSRAN_API int rf_uhd_set_rx_gain_ch(void* h, uint32_t ch, double gain); -SRSLTE_API double rf_uhd_get_rx_gain(void* h); +SRSRAN_API double rf_uhd_get_rx_gain(void* h); -SRSLTE_API double rf_uhd_get_tx_gain(void* h); +SRSRAN_API double rf_uhd_get_tx_gain(void* h); -SRSLTE_API srslte_rf_info_t* rf_uhd_get_info(void* h); +SRSRAN_API srsran_rf_info_t* rf_uhd_get_info(void* h); -SRSLTE_API void rf_uhd_suppress_stdout(void* h); +SRSRAN_API void rf_uhd_suppress_stdout(void* h); -SRSLTE_API void rf_uhd_register_error_handler(void* h, srslte_rf_error_handler_t error_handler, void* arg); +SRSRAN_API void rf_uhd_register_error_handler(void* h, srsran_rf_error_handler_t error_handler, void* arg); -SRSLTE_API double rf_uhd_set_rx_freq(void* h, uint32_t ch, double freq); +SRSRAN_API double rf_uhd_set_rx_freq(void* h, uint32_t ch, double freq); -SRSLTE_API int +SRSRAN_API int rf_uhd_recv_with_time(void* h, void* data, uint32_t nsamples, bool blocking, time_t* secs, double* frac_secs); -SRSLTE_API int +SRSRAN_API int rf_uhd_recv_with_time_multi(void* h, void** data, uint32_t nsamples, bool blocking, time_t* secs, double* frac_secs); -SRSLTE_API double rf_uhd_set_tx_srate(void* h, double freq); +SRSRAN_API double rf_uhd_set_tx_srate(void* h, double freq); -SRSLTE_API int rf_uhd_set_tx_gain(void* h, double gain); +SRSRAN_API int rf_uhd_set_tx_gain(void* h, double gain); -SRSLTE_API int rf_uhd_set_tx_gain_ch(void* h, uint32_t ch, double gain); +SRSRAN_API int rf_uhd_set_tx_gain_ch(void* h, uint32_t ch, double gain); -SRSLTE_API double rf_uhd_set_tx_freq(void* h, uint32_t ch, double freq); +SRSRAN_API double rf_uhd_set_tx_freq(void* h, uint32_t ch, double freq); -SRSLTE_API void rf_uhd_get_time(void* h, time_t* secs, double* frac_secs); +SRSRAN_API void rf_uhd_get_time(void* h, time_t* secs, double* frac_secs); -SRSLTE_API void rf_uhd_sync_pps(void* h); +SRSRAN_API void rf_uhd_sync_pps(void* h); -SRSLTE_API int rf_uhd_send_timed(void* h, +SRSRAN_API int rf_uhd_send_timed(void* h, void* data, int nsamples, time_t secs, @@ -93,7 +93,7 @@ SRSLTE_API int rf_uhd_send_timed(void* h, bool is_start_of_burst, bool is_end_of_burst); -SRSLTE_API int rf_uhd_send_timed_multi(void* h, +SRSRAN_API int rf_uhd_send_timed_multi(void* h, void** data, int nsamples, time_t secs, @@ -107,4 +107,4 @@ SRSLTE_API int rf_uhd_send_timed_multi(void* h, } #endif -#endif /* SRSLTE_RF_UHD_IMP_H_ */ +#endif /* SRSRAN_RF_UHD_IMP_H_ */ diff --git a/lib/src/phy/rf/rf_uhd_rfnoc.h b/lib/src/phy/rf/rf_uhd_rfnoc.h index e63861411..e1fc9255c 100644 --- a/lib/src/phy/rf/rf_uhd_rfnoc.h +++ b/lib/src/phy/rf/rf_uhd_rfnoc.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,8 +10,8 @@ * */ -#ifndef SRSLTE_RF_UHD_RFNOC_H -#define SRSLTE_RF_UHD_RFNOC_H +#ifndef SRSRAN_RF_UHD_RFNOC_H +#define SRSRAN_RF_UHD_RFNOC_H #include #include @@ -761,4 +761,4 @@ public: } }; -#endif // SRSLTE_RF_UHD_RFNOC_H +#endif // SRSRAN_RF_UHD_RFNOC_H diff --git a/lib/src/phy/rf/rf_uhd_safe.h b/lib/src/phy/rf/rf_uhd_safe.h index 7141870c3..6120be7de 100644 --- a/lib/src/phy/rf/rf_uhd_safe.h +++ b/lib/src/phy/rf/rf_uhd_safe.h @@ -2,15 +2,15 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of * the distribution. * */ -#ifndef SRSLTE_RF_UHD_SAFE_H -#define SRSLTE_RF_UHD_SAFE_H +#ifndef SRSRAN_RF_UHD_SAFE_H +#define SRSRAN_RF_UHD_SAFE_H #include #include @@ -184,4 +184,4 @@ public: virtual bool is_tx_ready() { return tx_stream != nullptr; } }; -#endif // SRSLTE_RF_UHD_SAFE_H +#endif // SRSRAN_RF_UHD_SAFE_H diff --git a/lib/src/phy/rf/rf_utils.c b/lib/src/phy/rf/rf_utils.c index 152561910..54e18f2e2 100644 --- a/lib/src/phy/rf/rf_utils.c +++ b/lib/src/phy/rf/rf_utils.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -20,13 +20,13 @@ #include -#include "srslte/srslte.h" +#include "srsran/srsran.h" -#include "srslte/phy/rf/rf.h" -#include "srslte/phy/rf/rf_utils.h" -#include "srslte/phy/ue/ue_cell_search_nbiot.h" +#include "srsran/phy/rf/rf.h" +#include "srsran/phy/rf/rf_utils.h" +#include "srsran/phy/ue/ue_cell_search_nbiot.h" -int rf_rssi_scan(srslte_rf_t* rf, float* freqs, float* rssi, int nof_bands, double fs, int nsamp) +int rf_rssi_scan(srsran_rf_t* rf, float* freqs, float* rssi, int nof_bands, double fs, int nsamp) { int i, j; int ret = -1; @@ -38,31 +38,31 @@ int rf_rssi_scan(srslte_rf_t* rf, float* freqs, float* rssi, int nof_bands, doub goto free_and_exit; } - srslte_rf_set_rx_gain(rf, 20.0); - srslte_rf_set_rx_srate(rf, fs); + srsran_rf_set_rx_gain(rf, 20.0); + srsran_rf_set_rx_srate(rf, fs); for (i = 0; i < nof_bands; i++) { - srslte_rf_stop_rx_stream(rf); + srsran_rf_stop_rx_stream(rf); f = (double)freqs[i]; - srslte_rf_set_rx_freq(rf, 0, f); + srsran_rf_set_rx_freq(rf, 0, f); usleep(10000); - srslte_rf_start_rx_stream(rf, false); + srsran_rf_start_rx_stream(rf, false); /* discard first samples */ for (j = 0; j < 2; j++) { - if (srslte_rf_recv(rf, buffer, nsamp, 1) != nsamp) { + if (srsran_rf_recv(rf, buffer, nsamp, 1) != nsamp) { goto free_and_exit; } } - rssi[i] = srslte_vec_avg_power_cf(buffer, nsamp); - printf("[%3d]: Freq %4.1f Mhz - RSSI: %3.2f dBm\r", i, f / 1000000, srslte_convert_power_to_dBm(rssi[i])); + rssi[i] = srsran_vec_avg_power_cf(buffer, nsamp); + printf("[%3d]: Freq %4.1f Mhz - RSSI: %3.2f dBm\r", i, f / 1000000, srsran_convert_power_to_dBm(rssi[i])); fflush(stdout); - if (SRSLTE_VERBOSE_ISINFO()) { + if (SRSRAN_VERBOSE_ISINFO()) { printf("\n"); } } - srslte_rf_stop_rx_stream(rf); + srsran_rf_stop_rx_stream(rf); ret = 0; free_and_exit: @@ -70,133 +70,133 @@ free_and_exit: return ret; } -int srslte_rf_recv_wrapper_cs(void* h, cf_t* data[SRSLTE_MAX_PORTS], uint32_t nsamples, srslte_timestamp_t* t) +int srsran_rf_recv_wrapper_cs(void* h, cf_t* data[SRSRAN_MAX_PORTS], uint32_t nsamples, srsran_timestamp_t* t) { DEBUG(" ---- Receive %d samples ----", nsamples); - void* ptr[SRSLTE_MAX_CHANNELS] = {}; - for (int i = 0; i < SRSLTE_MAX_PORTS; i++) { + void* ptr[SRSRAN_MAX_CHANNELS] = {}; + for (int i = 0; i < SRSRAN_MAX_PORTS; i++) { ptr[i] = data[i]; } - return srslte_rf_recv_with_time_multi(h, ptr, nsamples, 1, NULL, NULL); + return srsran_rf_recv_with_time_multi(h, ptr, nsamples, 1, NULL, NULL); } -static SRSLTE_AGC_CALLBACK(srslte_rf_set_rx_gain_wrapper) +static SRSRAN_AGC_CALLBACK(srsran_rf_set_rx_gain_wrapper) { - srslte_rf_set_rx_gain((srslte_rf_t*)h, gain_db); + srsran_rf_set_rx_gain((srsran_rf_t*)h, gain_db); } /** This function is simply a wrapper to the ue_cell_search module for rf devices * Return 1 if the MIB is decoded, 0 if not or -1 on error. */ -int rf_mib_decoder(srslte_rf_t* rf, +int rf_mib_decoder(srsran_rf_t* rf, uint32_t nof_rx_channels, cell_search_cfg_t* config, - srslte_cell_t* cell, + srsran_cell_t* cell, float* cfo) { - int ret = SRSLTE_ERROR; - srslte_ue_mib_sync_t ue_mib; - uint8_t bch_payload[SRSLTE_BCH_PAYLOAD_LEN] = {}; + int ret = SRSRAN_ERROR; + srsran_ue_mib_sync_t ue_mib; + uint8_t bch_payload[SRSRAN_BCH_PAYLOAD_LEN] = {}; - if (srslte_ue_mib_sync_init_multi(&ue_mib, srslte_rf_recv_wrapper_cs, nof_rx_channels, (void*)rf)) { - fprintf(stderr, "Error initiating srslte_ue_mib_sync\n"); + if (srsran_ue_mib_sync_init_multi(&ue_mib, srsran_rf_recv_wrapper_cs, nof_rx_channels, (void*)rf)) { + fprintf(stderr, "Error initiating srsran_ue_mib_sync\n"); goto clean_exit; } - if (srslte_ue_mib_sync_set_cell(&ue_mib, *cell)) { - ERROR("Error initiating srslte_ue_mib_sync"); + if (srsran_ue_mib_sync_set_cell(&ue_mib, *cell)) { + ERROR("Error initiating srsran_ue_mib_sync"); goto clean_exit; } - int srate = srslte_sampling_freq_hz(SRSLTE_UE_MIB_NOF_PRB); + int srate = srsran_sampling_freq_hz(SRSRAN_UE_MIB_NOF_PRB); INFO("Setting sampling frequency %.2f MHz for PSS search", (float)srate / 1000000); - srslte_rf_set_rx_srate(rf, (float)srate); + srsran_rf_set_rx_srate(rf, (float)srate); INFO("Starting receiver..."); - srslte_rf_start_rx_stream(rf, false); + srsran_rf_start_rx_stream(rf, false); // Copy CFO estimate if provided and disable CP estimation during find if (cfo) { ue_mib.ue_sync.cfo_current_value = *cfo / 15000; ue_mib.ue_sync.cfo_is_copied = true; ue_mib.ue_sync.cfo_correct_enable_find = true; - srslte_sync_set_cfo_cp_enable(&ue_mib.ue_sync.sfind, false, 0); + srsran_sync_set_cfo_cp_enable(&ue_mib.ue_sync.sfind, false, 0); } /* Find and decode MIB */ - ret = srslte_ue_mib_sync_decode(&ue_mib, config->max_frames_pbch, bch_payload, &cell->nof_ports, NULL); + ret = srsran_ue_mib_sync_decode(&ue_mib, config->max_frames_pbch, bch_payload, &cell->nof_ports, NULL); if (ret < 0) { ERROR("Error decoding MIB"); goto clean_exit; } if (ret == 1) { - srslte_pbch_mib_unpack(bch_payload, cell, NULL); + srsran_pbch_mib_unpack(bch_payload, cell, NULL); } // Save CFO if (cfo) { - *cfo = srslte_ue_sync_get_cfo(&ue_mib.ue_sync); + *cfo = srsran_ue_sync_get_cfo(&ue_mib.ue_sync); } clean_exit: - srslte_rf_stop_rx_stream(rf); - srslte_ue_mib_sync_free(&ue_mib); + srsran_rf_stop_rx_stream(rf); + srsran_ue_mib_sync_free(&ue_mib); return ret; } /** This function is simply a wrapper to the ue_cell_search module for rf devices */ -int rf_cell_search(srslte_rf_t* rf, +int rf_cell_search(srsran_rf_t* rf, uint32_t nof_rx_channels, cell_search_cfg_t* config, int force_N_id_2, - srslte_cell_t* cell, + srsran_cell_t* cell, float* cfo) { - int ret = SRSLTE_ERROR; - srslte_ue_cellsearch_t cs; - srslte_ue_cellsearch_result_t found_cells[3]; + int ret = SRSRAN_ERROR; + srsran_ue_cellsearch_t cs; + srsran_ue_cellsearch_result_t found_cells[3]; - bzero(found_cells, 3 * sizeof(srslte_ue_cellsearch_result_t)); + bzero(found_cells, 3 * sizeof(srsran_ue_cellsearch_result_t)); - if (srslte_ue_cellsearch_init_multi( - &cs, config->max_frames_pss, srslte_rf_recv_wrapper_cs, nof_rx_channels, (void*)rf)) { + if (srsran_ue_cellsearch_init_multi( + &cs, config->max_frames_pss, srsran_rf_recv_wrapper_cs, nof_rx_channels, (void*)rf)) { fprintf(stderr, "Error initiating UE cell detect\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (config->nof_valid_pss_frames) { - srslte_ue_cellsearch_set_nof_valid_frames(&cs, config->nof_valid_pss_frames); + srsran_ue_cellsearch_set_nof_valid_frames(&cs, config->nof_valid_pss_frames); } - INFO("Setting sampling frequency %.2f MHz for PSS search", SRSLTE_CS_SAMP_FREQ / 1000000); - srslte_rf_set_rx_srate(rf, SRSLTE_CS_SAMP_FREQ); + INFO("Setting sampling frequency %.2f MHz for PSS search", SRSRAN_CS_SAMP_FREQ / 1000000); + srsran_rf_set_rx_srate(rf, SRSRAN_CS_SAMP_FREQ); INFO("Starting receiver..."); - srslte_rf_start_rx_stream(rf, false); + srsran_rf_start_rx_stream(rf, false); if (config->force_tdd) { - srslte_ue_sync_set_frame_type(&cs.ue_sync, SRSLTE_TDD); + srsran_ue_sync_set_frame_type(&cs.ue_sync, SRSRAN_TDD); } /* Find a cell in the given N_id_2 or go through the 3 of them to find the strongest */ uint32_t max_peak_cell = 0; if (force_N_id_2 >= 0) { - ret = srslte_ue_cellsearch_scan_N_id_2(&cs, force_N_id_2, &found_cells[force_N_id_2]); + ret = srsran_ue_cellsearch_scan_N_id_2(&cs, force_N_id_2, &found_cells[force_N_id_2]); max_peak_cell = force_N_id_2; } else { - ret = srslte_ue_cellsearch_scan(&cs, found_cells, &max_peak_cell); + ret = srsran_ue_cellsearch_scan(&cs, found_cells, &max_peak_cell); } - srslte_rf_stop_rx_stream(rf); + srsran_rf_stop_rx_stream(rf); if (ret < 0) { ERROR("Error searching cell"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } else if (ret == 0) { ERROR("Could not find any cell in this frequency"); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } for (int i = 0; i < 3; i++) { @@ -207,11 +207,11 @@ int rf_cell_search(srslte_rf_t* rf, } printf("Found Cell_id: %3d %s, CP: %s, DetectRatio=%2.0f%% PSR=%.2f, Power=%.1f dBm\n", found_cells[i].cell_id, - found_cells[i].frame_type == SRSLTE_FDD ? "FDD" : "TDD", - srslte_cp_string(found_cells[i].cp), + found_cells[i].frame_type == SRSRAN_FDD ? "FDD" : "TDD", + srsran_cp_string(found_cells[i].cp), found_cells[i].mode * 100, found_cells[i].psr, - srslte_convert_amplitude_to_dB(found_cells[i].peak * 1000)); + srsran_convert_amplitude_to_dB(found_cells[i].peak * 1000)); } // Save result @@ -226,7 +226,7 @@ int rf_cell_search(srslte_rf_t* rf, *cfo = found_cells[max_peak_cell].cfo; } - srslte_ue_cellsearch_free(&cs); + srsran_ue_cellsearch_free(&cs); return ret; } @@ -236,14 +236,14 @@ int rf_cell_search(srslte_rf_t* rf, * 0 if no cell was found or MIB could not be decoded, * -1 on error */ -int rf_search_and_decode_mib(srslte_rf_t* rf, +int rf_search_and_decode_mib(srsran_rf_t* rf, uint32_t nof_rx_channels, cell_search_cfg_t* config, int force_N_id_2, - srslte_cell_t* cell, + srsran_cell_t* cell, float* cfo) { - int ret = SRSLTE_ERROR; + int ret = SRSRAN_ERROR; printf("Searching for cell...\n"); ret = rf_cell_search(rf, nof_rx_channels, config, force_N_id_2, cell, cfo); @@ -252,51 +252,51 @@ int rf_search_and_decode_mib(srslte_rf_t* rf, ret = rf_mib_decoder(rf, nof_rx_channels, config, cell, cfo); if (ret < 0) { ERROR("Could not decode PBCH from CELL ID %d", cell->id); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } return ret; } -int rf_cell_search_nbiot(srslte_rf_t* rf, cell_search_cfg_t* config, srslte_nbiot_cell_t* cell, float* cfo) +int rf_cell_search_nbiot(srsran_rf_t* rf, cell_search_cfg_t* config, srsran_nbiot_cell_t* cell, float* cfo) { - int ret = SRSLTE_ERROR; - srslte_ue_cellsearch_nbiot_t cs = {}; - srslte_nbiot_ue_cellsearch_result_t found_cells[3] = {}; + int ret = SRSRAN_ERROR; + srsran_ue_cellsearch_nbiot_t cs = {}; + srsran_nbiot_ue_cellsearch_result_t found_cells[3] = {}; - if (srslte_ue_cellsearch_nbiot_init(&cs, config->max_frames_pss, srslte_rf_recv_wrapper_cs, (void*)rf)) { + if (srsran_ue_cellsearch_nbiot_init(&cs, config->max_frames_pss, srsran_rf_recv_wrapper_cs, (void*)rf)) { fprintf(stderr, "Error initiating UE cell detect\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (config->nof_valid_pss_frames) { - srslte_ue_cellsearch_nbiot_set_nof_valid_frames(&cs, config->nof_valid_pss_frames); + srsran_ue_cellsearch_nbiot_set_nof_valid_frames(&cs, config->nof_valid_pss_frames); } if (config->init_agc > 0) { - srslte_ue_sync_nbiot_start_agc(&cs.ue_sync, srslte_rf_set_rx_gain_wrapper, config->init_agc); + srsran_ue_sync_nbiot_start_agc(&cs.ue_sync, srsran_rf_set_rx_gain_wrapper, config->init_agc); } - DEBUG("Setting sampling frequency %.2f MHz for NPSS search", SRSLTE_CS_SAMP_FREQ / 1000000); - srslte_rf_set_rx_srate(rf, SRSLTE_CS_SAMP_FREQ); + DEBUG("Setting sampling frequency %.2f MHz for NPSS search", SRSRAN_CS_SAMP_FREQ / 1000000); + srsran_rf_set_rx_srate(rf, SRSRAN_CS_SAMP_FREQ); INFO("Starting receiver..."); - srslte_rf_start_rx_stream(rf, false); + srsran_rf_start_rx_stream(rf, false); - ret = srslte_ue_cellsearch_nbiot_scan(&cs); - if (ret == SRSLTE_ERROR) { + ret = srsran_ue_cellsearch_nbiot_scan(&cs); + if (ret == SRSRAN_ERROR) { fprintf(stderr, "Could not find any cell in this frequency\n"); goto clean_exit; } INFO("Stopping receiver..."); - srslte_rf_stop_rx_stream(rf); + srsran_rf_stop_rx_stream(rf); // Find a cell INFO("Running N_id_ncell detection"); uint32_t max_peak_cell = 0; - ret = srslte_ue_cellsearch_nbiot_detect(&cs, found_cells); - if (ret != SRSLTE_SUCCESS) { + ret = srsran_ue_cellsearch_nbiot_detect(&cs, found_cells); + if (ret != SRSRAN_SUCCESS) { fprintf(stderr, "Could not detect cell ID\n"); goto clean_exit; } @@ -327,12 +327,12 @@ int rf_cell_search_nbiot(srslte_rf_t* rf, cell_search_cfg_t* config, srslte_nbio // Save AGC value for MIB decoding if (config->init_agc > 0) { - config->init_agc = srslte_agc_get_gain(&cs.ue_sync.agc); + config->init_agc = srsran_agc_get_gain(&cs.ue_sync.agc); } clean_exit: - srslte_rf_stop_rx_stream(rf); - srslte_ue_cellsearch_nbiot_free(&cs); + srsran_rf_stop_rx_stream(rf); + srsran_ue_cellsearch_nbiot_free(&cs); return ret; } diff --git a/lib/src/phy/rf/rf_zmq_imp.c b/lib/src/phy/rf/rf_zmq_imp.c index 1b303b7a5..c63c4e878 100644 --- a/lib/src/phy/rf/rf_zmq_imp.c +++ b/lib/src/phy/rf/rf_zmq_imp.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -14,9 +14,9 @@ #include "rf_helper.h" #include "rf_zmq_imp_trx.h" #include -#include -#include -#include +#include +#include +#include #include #include #include @@ -25,7 +25,7 @@ typedef struct { // Common attributes char* devname; - srslte_rf_info_t info; + srsran_rf_info_t info; uint32_t nof_channels; // RF State @@ -33,18 +33,18 @@ typedef struct { uint32_t base_srate; uint32_t decim_factor; // decimation factor between base_srate used on transport on radio's rate double rx_gain; - uint32_t tx_freq_mhz[SRSLTE_MAX_CHANNELS]; - uint32_t rx_freq_mhz[SRSLTE_MAX_CHANNELS]; + uint32_t tx_freq_mhz[SRSRAN_MAX_CHANNELS]; + uint32_t rx_freq_mhz[SRSRAN_MAX_CHANNELS]; bool tx_off; char id[RF_PARAM_LEN]; // Server void* context; - rf_zmq_tx_t transmitter[SRSLTE_MAX_CHANNELS]; - rf_zmq_rx_t receiver[SRSLTE_MAX_CHANNELS]; + rf_zmq_tx_t transmitter[SRSRAN_MAX_CHANNELS]; + rf_zmq_rx_t receiver[SRSRAN_MAX_CHANNELS]; // Various sample buffers - cf_t* buffer_decimation[SRSLTE_MAX_CHANNELS]; + cf_t* buffer_decimation[SRSRAN_MAX_CHANNELS]; cf_t* buffer_tx; // Rx timestamp @@ -93,19 +93,19 @@ void rf_zmq_error(char* id, const char* format, ...) static inline int update_ts(void* h, uint64_t* ts, int nsamples, const char* dir) { - int ret = SRSLTE_ERROR; + int ret = SRSRAN_ERROR; if (h && nsamples > 0) { rf_zmq_handler_t* handler = (rf_zmq_handler_t*)h; (*ts) += nsamples; - srslte_timestamp_t _ts = {}; - srslte_timestamp_init_uint64(&_ts, *ts, handler->base_srate); + srsran_timestamp_t _ts = {}; + srsran_timestamp_init_uint64(&_ts, *ts, handler->base_srate); rf_zmq_info( handler->id, " -> next %s time after %d samples: %d + %.3f\n", dir, nsamples, _ts.full_secs, _ts.frac_secs); - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; @@ -113,7 +113,7 @@ static inline int update_ts(void* h, uint64_t* ts, int nsamples, const char* dir int rf_zmq_handle_error(char* id, const char* text) { - int ret = SRSLTE_SUCCESS; + int ret = SRSRAN_SUCCESS; int err = zmq_errno(); @@ -126,7 +126,7 @@ int rf_zmq_handle_error(char* id, const char* text) // critical non-handled errors default: - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; rf_zmq_error(id, "Error %s: %s\n", text, zmq_strerror(err)); } @@ -142,7 +142,7 @@ void rf_zmq_suppress_stdout(void* h) // do nothing } -void rf_zmq_register_error_handler(void* h, srslte_rf_error_handler_t new_handler, void* arg) +void rf_zmq_register_error_handler(void* h, srsran_rf_error_handler_t new_handler, void* arg) { // do nothing } @@ -154,7 +154,7 @@ const char* rf_zmq_devname(void* h) int rf_zmq_start_rx_stream(void* h, bool now) { - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int rf_zmq_stop_rx_stream(void* h) @@ -184,14 +184,14 @@ int rf_zmq_open(char* args, void** h) int rf_zmq_open_multi(char* args, void** h, uint32_t nof_channels) { - int ret = SRSLTE_ERROR; - if (h && nof_channels < SRSLTE_MAX_CHANNELS) { + int ret = SRSRAN_ERROR; + if (h && nof_channels < SRSRAN_MAX_CHANNELS) { *h = NULL; rf_zmq_handler_t* handler = (rf_zmq_handler_t*)malloc(sizeof(rf_zmq_handler_t)); if (!handler) { perror("malloc"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } bzero(handler, sizeof(rf_zmq_handler_t)); *h = handler; @@ -231,7 +231,7 @@ int rf_zmq_open_multi(char* args, void** h, uint32_t nof_channels) // rx_type char tmp[RF_PARAM_LEN] = {0}; - if (parse_string(args, "rx_type", -1, tmp) == SRSLTE_SUCCESS) { + if (parse_string(args, "rx_type", -1, tmp) == SRSRAN_SUCCESS) { if (!strcmp(tmp, "sub")) { rx_opts.socket_type = ZMQ_SUB; } else { @@ -242,7 +242,7 @@ int rf_zmq_open_multi(char* args, void** h, uint32_t nof_channels) // rx_format rx_opts.sample_format = ZMQ_TYPE_FC32; - if (parse_string(args, "rx_format", -1, tmp) == SRSLTE_SUCCESS) { + if (parse_string(args, "rx_format", -1, tmp) == SRSRAN_SUCCESS) { if (!strcmp(tmp, "sc16")) { rx_opts.sample_format = ZMQ_TYPE_SC16; } else { @@ -252,7 +252,7 @@ int rf_zmq_open_multi(char* args, void** h, uint32_t nof_channels) } // tx_type - if (parse_string(args, "tx_type", -1, tmp) == SRSLTE_SUCCESS) { + if (parse_string(args, "tx_type", -1, tmp) == SRSRAN_SUCCESS) { if (!strcmp(tmp, "pub")) { tx_opts.socket_type = ZMQ_PUB; } else { @@ -263,7 +263,7 @@ int rf_zmq_open_multi(char* args, void** h, uint32_t nof_channels) // tx_format tx_opts.sample_format = ZMQ_TYPE_FC32; - if (parse_string(args, "tx_format", -1, tmp) == SRSLTE_SUCCESS) { + if (parse_string(args, "tx_format", -1, tmp) == SRSRAN_SUCCESS) { if (!strcmp(tmp, "sc16")) { tx_opts.sample_format = ZMQ_TYPE_SC16; } else { @@ -330,7 +330,7 @@ int rf_zmq_open_multi(char* args, void** h, uint32_t nof_channels) // initialize transmitter if (strlen(tx_port) != 0) { - if (rf_zmq_tx_open(&handler->transmitter[i], tx_opts, handler->context, tx_port) != SRSLTE_SUCCESS) { + if (rf_zmq_tx_open(&handler->transmitter[i], tx_opts, handler->context, tx_port) != SRSRAN_SUCCESS) { fprintf(stderr, "[zmq] Error: opening transmitter\n"); goto clean_exit; } @@ -341,7 +341,7 @@ int rf_zmq_open_multi(char* args, void** h, uint32_t nof_channels) // initialize receiver if (strlen(rx_port) != 0) { - if (rf_zmq_rx_open(&handler->receiver[i], rx_opts, handler->context, rx_port) != SRSLTE_SUCCESS) { + if (rf_zmq_rx_open(&handler->receiver[i], rx_opts, handler->context, rx_port) != SRSRAN_SUCCESS) { fprintf(stderr, "[zmq] Error: opening receiver\n"); goto clean_exit; } @@ -357,20 +357,20 @@ int rf_zmq_open_multi(char* args, void** h, uint32_t nof_channels) // Create decimation and overflow buffer for (uint32_t i = 0; i < handler->nof_channels; i++) { - handler->buffer_decimation[i] = srslte_vec_malloc(ZMQ_MAX_BUFFER_SIZE); + handler->buffer_decimation[i] = srsran_vec_malloc(ZMQ_MAX_BUFFER_SIZE); if (!handler->buffer_decimation[i]) { fprintf(stderr, "Error: allocating decimation buffer\n"); goto clean_exit; } } - handler->buffer_tx = srslte_vec_malloc(ZMQ_MAX_BUFFER_SIZE); + handler->buffer_tx = srsran_vec_malloc(ZMQ_MAX_BUFFER_SIZE); if (!handler->buffer_tx) { fprintf(stderr, "Error: allocating tx buffer\n"); goto clean_exit; } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; clean_exit: if (ret) { @@ -412,7 +412,7 @@ int rf_zmq_close(void* h) // Free all free(handler); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } void update_rates(rf_zmq_handler_t* handler, double srate) @@ -465,7 +465,7 @@ int rf_zmq_set_rx_gain(void* h, double gain) rf_zmq_handler_t* handler = (rf_zmq_handler_t*)h; handler->rx_gain = gain; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int rf_zmq_set_rx_gain_ch(void* h, uint32_t ch, double gain) @@ -475,7 +475,7 @@ int rf_zmq_set_rx_gain_ch(void* h, uint32_t ch, double gain) int rf_zmq_set_tx_gain(void* h, double gain) { - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int rf_zmq_set_tx_gain_ch(void* h, uint32_t ch, double gain) @@ -498,9 +498,9 @@ double rf_zmq_get_tx_gain(void* h) return 0.0; } -srslte_rf_info_t* rf_zmq_get_info(void* h) +srsran_rf_info_t* rf_zmq_get_info(void* h) { - srslte_rf_info_t* info = NULL; + srsran_rf_info_t* info = NULL; if (h) { rf_zmq_handler_t* handler = (rf_zmq_handler_t*)h; info = &handler->info; @@ -604,14 +604,14 @@ int rf_zmq_recv_with_time_multi(void* h, time_t* secs, double* frac_secs) { - int ret = SRSLTE_ERROR; + int ret = SRSRAN_ERROR; if (h) { rf_zmq_handler_t* handler = (rf_zmq_handler_t*)h; // Map ports to data buffers according to the selected frequencies pthread_mutex_lock(&handler->rx_config_mutex); - cf_t* buffers[SRSLTE_MAX_CHANNELS] = {}; // Buffer pointers, NULL if unmatched + cf_t* buffers[SRSRAN_MAX_CHANNELS] = {}; // Buffer pointers, NULL if unmatched for (uint32_t i = 0; i < handler->nof_channels; i++) { bool mapped = false; @@ -644,8 +644,8 @@ int rf_zmq_recv_with_time_multi(void* h, // set timestamp for this reception if (secs != NULL && frac_secs != NULL) { - srslte_timestamp_t ts = {}; - srslte_timestamp_init_uint64(&ts, handler->next_rx_ts, handler->base_srate); + srsran_timestamp_t ts = {}; + srsran_timestamp_init_uint64(&ts, handler->next_rx_ts, handler->base_srate); *secs = ts.full_secs; *frac_secs = ts.frac_secs; } @@ -667,9 +667,9 @@ int rf_zmq_recv_with_time_multi(void* h, } // receive samples - srslte_timestamp_t ts_tx = {}, ts_rx = {}; - srslte_timestamp_init_uint64(&ts_tx, handler->transmitter[0].nsamples, handler->base_srate); - srslte_timestamp_init_uint64(&ts_rx, handler->next_rx_ts, handler->base_srate); + srsran_timestamp_t ts_tx = {}, ts_rx = {}; + srsran_timestamp_init_uint64(&ts_tx, handler->transmitter[0].nsamples, handler->base_srate); + srsran_timestamp_init_uint64(&ts_rx, handler->next_rx_ts, handler->base_srate); rf_zmq_info(handler->id, " - next rx time: %d + %.3f\n", ts_rx.full_secs, ts_rx.frac_secs); rf_zmq_info(handler->id, " - next tx time: %d + %.3f\n", ts_tx.full_secs, ts_tx.frac_secs); @@ -685,7 +685,7 @@ int rf_zmq_recv_with_time_multi(void* h, // copy from rx buffer as many samples as requested into provided buffer bool completed = false; - int32_t count[SRSLTE_MAX_CHANNELS] = {}; + int32_t count[SRSRAN_MAX_CHANNELS] = {}; while (!completed) { uint32_t completed_count = 0; @@ -714,10 +714,10 @@ int rf_zmq_recv_with_time_multi(void* h, } } #endif // ZMQ_MONITOR - if (n > SRSLTE_SUCCESS) { + if (n > SRSRAN_SUCCESS) { // No error count[i] += n; - } else if (n == SRSLTE_ERROR_TIMEOUT) { + } else if (n == SRSRAN_ERROR_TIMEOUT) { if (handler->receiver[i].log_trx_timeout) { fprintf(stderr, "Error: timeout receiving samples after %dms\n", handler->receiver[i].trx_timeout_ms); } @@ -725,7 +725,7 @@ int rf_zmq_recv_with_time_multi(void* h, if (handler->receiver[i].fail_on_disconnect) { goto clean_exit; } - } else if (n < SRSLTE_SUCCESS) { + } else if (n < SRSRAN_SUCCESS) { // Other error, exit fprintf(stderr, "Error: receiving data.\n"); goto clean_exit; @@ -742,7 +742,7 @@ int rf_zmq_recv_with_time_multi(void* h, rf_zmq_info(handler->id, " - read %d samples. %d samples available\n", NBYTES2NSAMPLES(nbytes), - NBYTES2NSAMPLES(srslte_ringbuffer_status(&handler->receiver[0].ringbuffer))); + NBYTES2NSAMPLES(srsran_ringbuffer_status(&handler->receiver[0].ringbuffer))); // decimate if needed if (decim_factor != 1) { @@ -771,10 +771,10 @@ int rf_zmq_recv_with_time_multi(void* h, } // Set gain - float scale = srslte_convert_dB_to_amplitude(handler->rx_gain); + float scale = srsran_convert_dB_to_amplitude(handler->rx_gain); for (uint32_t c = 0; c < handler->nof_channels; c++) { if (buffers[c]) { - srslte_vec_sc_prod_cfc(buffers[c], scale, buffers[c], nsamples); + srsran_vec_sc_prod_cfc(buffers[c], scale, buffers[c], nsamples); } } @@ -816,14 +816,14 @@ int rf_zmq_send_timed_multi(void* h, bool is_start_of_burst, bool is_end_of_burst) { - int ret = SRSLTE_ERROR; + int ret = SRSRAN_ERROR; if (h && data && nsamples > 0) { rf_zmq_handler_t* handler = (rf_zmq_handler_t*)h; // Map ports to data buffers according to the selected frequencies pthread_mutex_lock(&handler->tx_config_mutex); - cf_t* buffers[SRSLTE_MAX_CHANNELS] = {}; // Buffer pointers, NULL if unmatched + cf_t* buffers[SRSRAN_MAX_CHANNELS] = {}; // Buffer pointers, NULL if unmatched for (uint32_t i = 0; i < handler->nof_channels; i++) { bool mapped = false; @@ -856,16 +856,16 @@ int rf_zmq_send_timed_multi(void* h, // return if transmitter is switched off if (handler->tx_off) { - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // check if this is a tx in the future if (has_time_spec) { rf_zmq_info(handler->id, " - tx time: %d + %.3f\n", secs, frac_secs); - srslte_timestamp_t ts = {}; - srslte_timestamp_init(&ts, secs, frac_secs); - uint64_t tx_ts = srslte_timestamp_uint64(&ts, handler->base_srate); + srsran_timestamp_t ts = {}; + srsran_timestamp_init(&ts, secs, frac_secs); + uint64_t tx_ts = srsran_timestamp_uint64(&ts, handler->base_srate); int num_tx_gap_samples = 0; for (int i = 0; i < handler->nof_channels; i++) { @@ -917,19 +917,19 @@ int rf_zmq_send_timed_multi(void* h, } int n = rf_zmq_tx_baseband(&handler->transmitter[i], buf, nsamples_baseband); - if (n == SRSLTE_ERROR) { + if (n == SRSRAN_ERROR) { goto clean_exit; } } else { int n = rf_zmq_tx_zeros(&handler->transmitter[i], nsamples_baseband); - if (n == SRSLTE_ERROR) { + if (n == SRSRAN_ERROR) { goto clean_exit; } } } } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; clean_exit: diff --git a/lib/src/phy/rf/rf_zmq_imp.h b/lib/src/phy/rf/rf_zmq_imp.h index 424bfe81c..df409a9c2 100644 --- a/lib/src/phy/rf/rf_zmq_imp.h +++ b/lib/src/phy/rf/rf_zmq_imp.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,72 +10,72 @@ * */ -#ifndef SRSLTE_RF_ZMQ_IMP_H_ -#define SRSLTE_RF_ZMQ_IMP_H_ +#ifndef SRSRAN_RF_ZMQ_IMP_H_ +#define SRSRAN_RF_ZMQ_IMP_H_ #include #include -#include "srslte/config.h" -#include "srslte/phy/rf/rf.h" +#include "srsran/config.h" +#include "srsran/phy/rf/rf.h" #define DEVNAME_ZMQ "ZeroMQ" -SRSLTE_API int rf_zmq_open(char* args, void** handler); +SRSRAN_API int rf_zmq_open(char* args, void** handler); -SRSLTE_API int rf_zmq_open_multi(char* args, void** handler, uint32_t nof_channels); +SRSRAN_API int rf_zmq_open_multi(char* args, void** handler, uint32_t nof_channels); -SRSLTE_API const char* rf_zmq_devname(void* h); +SRSRAN_API const char* rf_zmq_devname(void* h); -SRSLTE_API int rf_zmq_close(void* h); +SRSRAN_API int rf_zmq_close(void* h); -SRSLTE_API int rf_zmq_start_rx_stream(void* h, bool now); +SRSRAN_API int rf_zmq_start_rx_stream(void* h, bool now); -SRSLTE_API int rf_zmq_start_rx_stream_nsamples(void* h, uint32_t nsamples); +SRSRAN_API int rf_zmq_start_rx_stream_nsamples(void* h, uint32_t nsamples); -SRSLTE_API int rf_zmq_stop_rx_stream(void* h); +SRSRAN_API int rf_zmq_stop_rx_stream(void* h); -SRSLTE_API void rf_zmq_flush_buffer(void* h); +SRSRAN_API void rf_zmq_flush_buffer(void* h); -SRSLTE_API bool rf_zmq_has_rssi(void* h); +SRSRAN_API bool rf_zmq_has_rssi(void* h); -SRSLTE_API float rf_zmq_get_rssi(void* h); +SRSRAN_API float rf_zmq_get_rssi(void* h); -SRSLTE_API double rf_zmq_set_rx_srate(void* h, double freq); +SRSRAN_API double rf_zmq_set_rx_srate(void* h, double freq); -SRSLTE_API int rf_zmq_set_rx_gain(void* h, double gain); +SRSRAN_API int rf_zmq_set_rx_gain(void* h, double gain); -SRSLTE_API int rf_zmq_set_rx_gain_ch(void* h, uint32_t ch, double gain); +SRSRAN_API int rf_zmq_set_rx_gain_ch(void* h, uint32_t ch, double gain); -SRSLTE_API double rf_zmq_get_rx_gain(void* h); +SRSRAN_API double rf_zmq_get_rx_gain(void* h); -SRSLTE_API double rf_zmq_get_tx_gain(void* h); +SRSRAN_API double rf_zmq_get_tx_gain(void* h); -SRSLTE_API srslte_rf_info_t* rf_zmq_get_info(void* h); +SRSRAN_API srsran_rf_info_t* rf_zmq_get_info(void* h); -SRSLTE_API void rf_zmq_suppress_stdout(void* h); +SRSRAN_API void rf_zmq_suppress_stdout(void* h); -SRSLTE_API void rf_zmq_register_error_handler(void* h, srslte_rf_error_handler_t error_handler, void* arg); +SRSRAN_API void rf_zmq_register_error_handler(void* h, srsran_rf_error_handler_t error_handler, void* arg); -SRSLTE_API double rf_zmq_set_rx_freq(void* h, uint32_t ch, double freq); +SRSRAN_API double rf_zmq_set_rx_freq(void* h, uint32_t ch, double freq); -SRSLTE_API int +SRSRAN_API int rf_zmq_recv_with_time(void* h, void* data, uint32_t nsamples, bool blocking, time_t* secs, double* frac_secs); -SRSLTE_API int +SRSRAN_API int rf_zmq_recv_with_time_multi(void* h, void** data, uint32_t nsamples, bool blocking, time_t* secs, double* frac_secs); -SRSLTE_API double rf_zmq_set_tx_srate(void* h, double freq); +SRSRAN_API double rf_zmq_set_tx_srate(void* h, double freq); -SRSLTE_API int rf_zmq_set_tx_gain(void* h, double gain); +SRSRAN_API int rf_zmq_set_tx_gain(void* h, double gain); -SRSLTE_API int rf_zmq_set_tx_gain_ch(void* h, uint32_t ch, double gain); +SRSRAN_API int rf_zmq_set_tx_gain_ch(void* h, uint32_t ch, double gain); -SRSLTE_API double rf_zmq_set_tx_freq(void* h, uint32_t ch, double freq); +SRSRAN_API double rf_zmq_set_tx_freq(void* h, uint32_t ch, double freq); -SRSLTE_API void rf_zmq_get_time(void* h, time_t* secs, double* frac_secs); +SRSRAN_API void rf_zmq_get_time(void* h, time_t* secs, double* frac_secs); -SRSLTE_API int rf_zmq_send_timed(void* h, +SRSRAN_API int rf_zmq_send_timed(void* h, void* data, int nsamples, time_t secs, @@ -85,7 +85,7 @@ SRSLTE_API int rf_zmq_send_timed(void* h, bool is_start_of_burst, bool is_end_of_burst); -SRSLTE_API int rf_zmq_send_timed_multi(void* h, +SRSRAN_API int rf_zmq_send_timed_multi(void* h, void* data[4], int nsamples, time_t secs, @@ -95,4 +95,4 @@ SRSLTE_API int rf_zmq_send_timed_multi(void* h, bool is_start_of_burst, bool is_end_of_burst); -#endif /* SRSLTE_RF_ZMQ_IMP_H_ */ +#endif /* SRSRAN_RF_ZMQ_IMP_H_ */ diff --git a/lib/src/phy/rf/rf_zmq_imp_rx.c b/lib/src/phy/rf/rf_zmq_imp_rx.c index a5f2f91e5..bb84f7506 100644 --- a/lib/src/phy/rf/rf_zmq_imp_rx.c +++ b/lib/src/phy/rf/rf_zmq_imp_rx.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -12,7 +12,7 @@ #include "rf_zmq_imp_trx.h" #include -#include +#include #include #include #include @@ -23,7 +23,7 @@ static void* rf_zmq_async_rx_thread(void* h) while (q->sock && q->running) { int nbytes = 0; - int n = SRSLTE_ERROR; + int n = SRSRAN_ERROR; uint8_t dummy = 0xFF; rf_zmq_info(q->id, "-- ASYNC RX wait...\n"); @@ -69,8 +69,8 @@ static void* rf_zmq_async_rx_thread(void* h) // Try to write in ring buffer while (n < 0 && q->running) { - n = srslte_ringbuffer_write_timed(&q->ringbuffer, q->temp_buffer, nbytes, q->trx_timeout_ms); - if (n == SRSLTE_ERROR_TIMEOUT && q->log_trx_timeout) { + n = srsran_ringbuffer_write_timed(&q->ringbuffer, q->temp_buffer, nbytes, q->trx_timeout_ms); + if (n == SRSRAN_ERROR_TIMEOUT && q->log_trx_timeout) { fprintf(stderr, "Error: timeout writing samples to ringbuffer after %dms\n", q->trx_timeout_ms); } } @@ -81,7 +81,7 @@ static void* rf_zmq_async_rx_thread(void* h) " - received %d baseband samples (%d B). %d samples available.\n", NBYTES2NSAMPLES(n), n, - NBYTES2NSAMPLES(srslte_ringbuffer_status(&q->ringbuffer))); + NBYTES2NSAMPLES(srsran_ringbuffer_status(&q->ringbuffer))); } } } @@ -91,7 +91,7 @@ static void* rf_zmq_async_rx_thread(void* h) int rf_zmq_rx_open(rf_zmq_rx_t* q, rf_zmq_opts_t opts, void* zmq_ctx, char* sock_args) { - int ret = SRSLTE_ERROR; + int ret = SRSRAN_ERROR; if (q) { // Zero object @@ -163,18 +163,18 @@ int rf_zmq_rx_open(rf_zmq_rx_t* q, rf_zmq_opts_t opts, void* zmq_ctx, char* sock } } - if (srslte_ringbuffer_init(&q->ringbuffer, ZMQ_MAX_BUFFER_SIZE)) { + if (srsran_ringbuffer_init(&q->ringbuffer, ZMQ_MAX_BUFFER_SIZE)) { fprintf(stderr, "Error: initiating ringbuffer\n"); goto clean_exit; } - q->temp_buffer = srslte_vec_malloc(ZMQ_MAX_BUFFER_SIZE); + q->temp_buffer = srsran_vec_malloc(ZMQ_MAX_BUFFER_SIZE); if (!q->temp_buffer) { fprintf(stderr, "Error: allocating rx buffer\n"); goto clean_exit; } - q->temp_buffer_convert = srslte_vec_malloc(ZMQ_MAX_BUFFER_SIZE); + q->temp_buffer_convert = srsran_vec_malloc(ZMQ_MAX_BUFFER_SIZE); if (!q->temp_buffer_convert) { fprintf(stderr, "Error: allocating rx buffer\n"); goto clean_exit; @@ -191,7 +191,7 @@ int rf_zmq_rx_open(rf_zmq_rx_t* q, rf_zmq_opts_t opts, void* zmq_ctx, char* sock goto clean_exit; } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } clean_exit: @@ -209,10 +209,10 @@ int rf_zmq_rx_baseband(rf_zmq_rx_t* q, cf_t* buffer, uint32_t nsamples) // If the read needs to be delayed while (q->sample_offset > 0) { - uint32_t n_offset = SRSLTE_MIN(q->sample_offset, NBYTES2NSAMPLES(ZMQ_MAX_BUFFER_SIZE)); - srslte_vec_zero(q->temp_buffer, n_offset); - int n = srslte_ringbuffer_write(&q->ringbuffer, q->temp_buffer, (int)(n_offset * sample_sz)); - if (n < SRSLTE_SUCCESS) { + uint32_t n_offset = SRSRAN_MIN(q->sample_offset, NBYTES2NSAMPLES(ZMQ_MAX_BUFFER_SIZE)); + srsran_vec_zero(q->temp_buffer, n_offset); + int n = srsran_ringbuffer_write(&q->ringbuffer, q->temp_buffer, (int)(n_offset * sample_sz)); + if (n < SRSRAN_SUCCESS) { return n; } q->sample_offset -= n_offset; @@ -220,22 +220,22 @@ int rf_zmq_rx_baseband(rf_zmq_rx_t* q, cf_t* buffer, uint32_t nsamples) // If the read needs to be advanced while (q->sample_offset < 0) { - uint32_t n_offset = SRSLTE_MIN(-q->sample_offset, NBYTES2NSAMPLES(ZMQ_MAX_BUFFER_SIZE)); + uint32_t n_offset = SRSRAN_MIN(-q->sample_offset, NBYTES2NSAMPLES(ZMQ_MAX_BUFFER_SIZE)); int n = - srslte_ringbuffer_read_timed(&q->ringbuffer, q->temp_buffer, (int)(n_offset * sample_sz), q->trx_timeout_ms); - if (n < SRSLTE_SUCCESS) { + srsran_ringbuffer_read_timed(&q->ringbuffer, q->temp_buffer, (int)(n_offset * sample_sz), q->trx_timeout_ms); + if (n < SRSRAN_SUCCESS) { return n; } q->sample_offset += n_offset; } - int n = srslte_ringbuffer_read_timed(&q->ringbuffer, dst_buffer, sample_sz * nsamples, q->trx_timeout_ms); + int n = srsran_ringbuffer_read_timed(&q->ringbuffer, dst_buffer, sample_sz * nsamples, q->trx_timeout_ms); if (n < 0) { return n; } if (q->sample_format == ZMQ_TYPE_SC16) { - srslte_vec_convert_if(dst_buffer, INT16_MAX, (float*)buffer, 2 * nsamples); + srsran_vec_convert_if(dst_buffer, INT16_MAX, (float*)buffer, 2 * nsamples); } return n; @@ -260,7 +260,7 @@ void rf_zmq_rx_close(rf_zmq_rx_t* q) pthread_detach(q->thread); } - srslte_ringbuffer_free(&q->ringbuffer); + srsran_ringbuffer_free(&q->ringbuffer); if (q->temp_buffer) { free(q->temp_buffer); diff --git a/lib/src/phy/rf/rf_zmq_imp_trx.h b/lib/src/phy/rf/rf_zmq_imp_trx.h index ba60fc787..1da44cac0 100644 --- a/lib/src/phy/rf/rf_zmq_imp_trx.h +++ b/lib/src/phy/rf/rf_zmq_imp_trx.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,11 +10,11 @@ * */ -#ifndef SRSLTE_RF_ZMQ_IMP_TRX_H -#define SRSLTE_RF_ZMQ_IMP_TRX_H +#ifndef SRSRAN_RF_ZMQ_IMP_TRX_H +#define SRSRAN_RF_ZMQ_IMP_TRX_H #include -#include +#include #include /* Definitions */ @@ -58,7 +58,7 @@ typedef struct { bool running; pthread_t thread; pthread_mutex_t mutex; - srslte_ringbuffer_t ringbuffer; + srsran_ringbuffer_t ringbuffer; cf_t* temp_buffer; void* temp_buffer_convert; uint32_t frequency_mhz; @@ -82,36 +82,36 @@ typedef struct { /* * Common functions */ -SRSLTE_API void rf_zmq_info(char* id, const char* format, ...); +SRSRAN_API void rf_zmq_info(char* id, const char* format, ...); -SRSLTE_API void rf_zmq_error(char* id, const char* format, ...); +SRSRAN_API void rf_zmq_error(char* id, const char* format, ...); -SRSLTE_API int rf_zmq_handle_error(char* id, const char* text); +SRSRAN_API int rf_zmq_handle_error(char* id, const char* text); /* * Transmitter functions */ -SRSLTE_API int rf_zmq_tx_open(rf_zmq_tx_t* q, rf_zmq_opts_t opts, void* zmq_ctx, char* sock_args); +SRSRAN_API int rf_zmq_tx_open(rf_zmq_tx_t* q, rf_zmq_opts_t opts, void* zmq_ctx, char* sock_args); -SRSLTE_API int rf_zmq_tx_align(rf_zmq_tx_t* q, uint64_t ts); +SRSRAN_API int rf_zmq_tx_align(rf_zmq_tx_t* q, uint64_t ts); -SRSLTE_API int rf_zmq_tx_baseband(rf_zmq_tx_t* q, cf_t* buffer, uint32_t nsamples); +SRSRAN_API int rf_zmq_tx_baseband(rf_zmq_tx_t* q, cf_t* buffer, uint32_t nsamples); -SRSLTE_API int rf_zmq_tx_zeros(rf_zmq_tx_t* q, uint32_t nsamples); +SRSRAN_API int rf_zmq_tx_zeros(rf_zmq_tx_t* q, uint32_t nsamples); -SRSLTE_API bool rf_zmq_tx_match_freq(rf_zmq_tx_t* q, uint32_t freq_hz); +SRSRAN_API bool rf_zmq_tx_match_freq(rf_zmq_tx_t* q, uint32_t freq_hz); -SRSLTE_API void rf_zmq_tx_close(rf_zmq_tx_t* q); +SRSRAN_API void rf_zmq_tx_close(rf_zmq_tx_t* q); /* * Receiver functions */ -SRSLTE_API int rf_zmq_rx_open(rf_zmq_rx_t* q, rf_zmq_opts_t opts, void* zmq_ctx, char* sock_args); +SRSRAN_API int rf_zmq_rx_open(rf_zmq_rx_t* q, rf_zmq_opts_t opts, void* zmq_ctx, char* sock_args); -SRSLTE_API int rf_zmq_rx_baseband(rf_zmq_rx_t* q, cf_t* buffer, uint32_t nsamples); +SRSRAN_API int rf_zmq_rx_baseband(rf_zmq_rx_t* q, cf_t* buffer, uint32_t nsamples); -SRSLTE_API bool rf_zmq_rx_match_freq(rf_zmq_rx_t* q, uint32_t freq_hz); +SRSRAN_API bool rf_zmq_rx_match_freq(rf_zmq_rx_t* q, uint32_t freq_hz); -SRSLTE_API void rf_zmq_rx_close(rf_zmq_rx_t* q); +SRSRAN_API void rf_zmq_rx_close(rf_zmq_rx_t* q); -#endif // SRSLTE_RF_ZMQ_IMP_TRX_H +#endif // SRSRAN_RF_ZMQ_IMP_TRX_H diff --git a/lib/src/phy/rf/rf_zmq_imp_tx.c b/lib/src/phy/rf/rf_zmq_imp_tx.c index 106c7f579..81417b53c 100644 --- a/lib/src/phy/rf/rf_zmq_imp_tx.c +++ b/lib/src/phy/rf/rf_zmq_imp_tx.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -12,15 +12,15 @@ #include "rf_zmq_imp_trx.h" #include -#include -#include +#include +#include #include #include #include int rf_zmq_tx_open(rf_zmq_tx_t* q, rf_zmq_opts_t opts, void* zmq_ctx, char* sock_args) { - int ret = SRSLTE_ERROR; + int ret = SRSRAN_ERROR; if (q) { // Zero object @@ -73,13 +73,13 @@ int rf_zmq_tx_open(rf_zmq_tx_t* q, rf_zmq_opts_t opts, void* zmq_ctx, char* sock goto clean_exit; } - q->temp_buffer_convert = srslte_vec_malloc(ZMQ_MAX_BUFFER_SIZE); + q->temp_buffer_convert = srsran_vec_malloc(ZMQ_MAX_BUFFER_SIZE); if (!q->temp_buffer_convert) { fprintf(stderr, "Error: allocating rx buffer\n"); goto clean_exit; } - q->zeros = srslte_vec_malloc(ZMQ_MAX_BUFFER_SIZE); + q->zeros = srsran_vec_malloc(ZMQ_MAX_BUFFER_SIZE); if (!q->zeros) { fprintf(stderr, "Error: allocating zeros\n"); goto clean_exit; @@ -88,7 +88,7 @@ int rf_zmq_tx_open(rf_zmq_tx_t* q, rf_zmq_opts_t opts, void* zmq_ctx, char* sock q->running = true; - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } clean_exit: @@ -97,7 +97,7 @@ clean_exit: static int _rf_zmq_tx_baseband(rf_zmq_tx_t* q, cf_t* buffer, uint32_t nsamples) { - int n = SRSLTE_ERROR; + int n = SRSRAN_ERROR; while (n < 0 && q->running) { // Receive Transmit request is socket type is REPLY @@ -106,7 +106,7 @@ static int _rf_zmq_tx_baseband(rf_zmq_tx_t* q, cf_t* buffer, uint32_t nsamples) n = zmq_recv(q->sock, &dummy, sizeof(dummy), 0); if (n < 0) { if (rf_zmq_handle_error(q->id, "tx request receive")) { - n = SRSLTE_ERROR; + n = SRSRAN_ERROR; goto clean_exit; } } else { @@ -125,7 +125,7 @@ static int _rf_zmq_tx_baseband(rf_zmq_tx_t* q, cf_t* buffer, uint32_t nsamples) if (q->sample_format == ZMQ_TYPE_SC16) { buf = q->temp_buffer_convert; sample_sz = 2 * sizeof(short); - srslte_vec_convert_fi((float*)buffer, INT16_MAX, (short*)q->temp_buffer_convert, 2 * nsamples); + srsran_vec_convert_fi((float*)buffer, INT16_MAX, (short*)q->temp_buffer_convert, 2 * nsamples); } // Send base-band if request was received @@ -133,7 +133,7 @@ static int _rf_zmq_tx_baseband(rf_zmq_tx_t* q, cf_t* buffer, uint32_t nsamples) n = zmq_send(q->sock, buf, (size_t)sample_sz * nsamples, 0); if (n < 0) { if (rf_zmq_handle_error(q->id, "tx baseband send")) { - n = SRSLTE_ERROR; + n = SRSRAN_ERROR; goto clean_exit; } } else if (n != NSAMPLES2NBYTES(nsamples)) { @@ -142,7 +142,7 @@ static int _rf_zmq_tx_baseband(rf_zmq_tx_t* q, cf_t* buffer, uint32_t nsamples) NSAMPLES2NBYTES(nsamples), n, strerror(zmq_errno())); - n = SRSLTE_ERROR; + n = SRSRAN_ERROR; goto clean_exit; } } @@ -184,7 +184,7 @@ int rf_zmq_tx_baseband(rf_zmq_tx_t* q, cf_t* buffer, uint32_t nsamples) _rf_zmq_tx_baseband(q, q->zeros, (uint32_t)q->sample_offset); q->sample_offset = 0; } else if (q->sample_offset < 0) { - n = SRSLTE_MIN(-q->sample_offset, nsamples); + n = SRSRAN_MIN(-q->sample_offset, nsamples); buffer += n; nsamples -= n; q->sample_offset += n; diff --git a/lib/src/phy/rf/rf_zmq_test.c b/lib/src/phy/rf/rf_zmq_test.c index c8857cef1..1418fc9a8 100644 --- a/lib/src/phy/rf/rf_zmq_test.c +++ b/lib/src/phy/rf/rf_zmq_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,9 +11,9 @@ */ #include "rf_zmq_imp.h" -#include "srslte/srslte.h" +#include "srsran/srsran.h" #include -#include +#include #include #include @@ -27,7 +27,7 @@ static cf_t ue_rx_buffer[RF_BUFFER_SIZE]; static cf_t enb_tx_buffer[RF_BUFFER_SIZE]; static cf_t enb_rx_buffer[RF_BUFFER_SIZE]; -static srslte_rf_t ue_radio, enb_radio; +static srsran_rf_t ue_radio, enb_radio; pthread_t rx_thread; void* ue_rx_thread_function(void* args) @@ -39,7 +39,7 @@ void* ue_rx_thread_function(void* args) // sleep(1); printf("opening rx device with args=%s\n", rf_args); - if (srslte_rf_open_devname(&ue_radio, "zmq", rf_args, NOF_RX_ANT)) { + if (srsran_rf_open_devname(&ue_radio, "zmq", rf_args, NOF_RX_ANT)) { fprintf(stderr, "Error opening rf\n"); exit(-1); } @@ -49,15 +49,15 @@ void* ue_rx_thread_function(void* args) uint32_t num_samps_per_slot = SF_LEN * 5; uint32_t num_rxed_samps = 0; for (uint32_t i = 0; i < num_slots; ++i) { - void* data_ptr[SRSLTE_MAX_PORTS] = {NULL}; + void* data_ptr[SRSRAN_MAX_PORTS] = {NULL}; data_ptr[0] = &ue_rx_buffer[i * num_samps_per_slot]; - num_rxed_samps += srslte_rf_recv_with_time_multi(&ue_radio, data_ptr, num_samps_per_slot, true, NULL, NULL); + num_rxed_samps += srsran_rf_recv_with_time_multi(&ue_radio, data_ptr, num_samps_per_slot, true, NULL, NULL); } printf("received %d samples.\n", num_rxed_samps); printf("closing ue norf device\n"); - srslte_rf_close(&ue_radio); + srsran_rf_close(&ue_radio); return NULL; } @@ -69,7 +69,7 @@ void enb_tx_function(const char* tx_args, bool timed_tx) rf_args[RF_PARAM_LEN - 1] = 0; printf("opening tx device with args=%s\n", rf_args); - if (srslte_rf_open_devname(&enb_radio, "zmq", rf_args, NOF_RX_ANT)) { + if (srsran_rf_open_devname(&enb_radio, "zmq", rf_args, NOF_RX_ANT)) { fprintf(stderr, "Error opening rf\n"); exit(-1); } @@ -83,18 +83,18 @@ void enb_tx_function(const char* tx_args, bool timed_tx) uint32_t num_txed_samples = 0; // initial transmission without ts - void* data_ptr[SRSLTE_MAX_PORTS] = {NULL}; + void* data_ptr[SRSRAN_MAX_PORTS] = {NULL}; data_ptr[0] = &enb_tx_buffer[num_txed_samples]; - int ret = srslte_rf_send_multi(&enb_radio, (void**)data_ptr, SF_LEN, true, true, false); + int ret = srsran_rf_send_multi(&enb_radio, (void**)data_ptr, SF_LEN, true, true, false); num_txed_samples += SF_LEN; // from here on, all transmissions are timed relative to the last rx time - srslte_timestamp_t rx_time, tx_time; + srsran_timestamp_t rx_time, tx_time; for (uint32_t i = 0; i < NUM_SF - ((timed_tx) ? TX_OFFSET_MS : 1); ++i) { // first recv samples data_ptr[0] = enb_rx_buffer; - srslte_rf_recv_with_time_multi(&enb_radio, data_ptr, SF_LEN, true, &rx_time.full_secs, &rx_time.frac_secs); + srsran_rf_recv_with_time_multi(&enb_radio, data_ptr, SF_LEN, true, &rx_time.full_secs, &rx_time.frac_secs); // prepare data buffer data_ptr[0] = &enb_tx_buffer[num_txed_samples]; @@ -102,15 +102,15 @@ void enb_tx_function(const char* tx_args, bool timed_tx) if (timed_tx) { // timed tx relative to receive time (this will cause a cap in the rx'ed samples at the UE resulting in 3 zero // subframes) - srslte_timestamp_copy(&tx_time, &rx_time); - srslte_timestamp_add(&tx_time, 0, TX_OFFSET_MS * 1e-3); - ret = srslte_rf_send_timed_multi( + srsran_timestamp_copy(&tx_time, &rx_time); + srsran_timestamp_add(&tx_time, 0, TX_OFFSET_MS * 1e-3); + ret = srsran_rf_send_timed_multi( &enb_radio, (void**)data_ptr, SF_LEN, tx_time.full_secs, tx_time.frac_secs, true, true, false); } else { // normal tx - ret = srslte_rf_send_multi(&enb_radio, (void**)data_ptr, SF_LEN, true, true, false); + ret = srsran_rf_send_multi(&enb_radio, (void**)data_ptr, SF_LEN, true, true, false); } - if (ret != SRSLTE_SUCCESS) { + if (ret != SRSRAN_SUCCESS) { fprintf(stderr, "Error sending data\n"); exit(-1); } @@ -121,12 +121,12 @@ void enb_tx_function(const char* tx_args, bool timed_tx) printf("transmitted %d samples in %d subframes\n", num_txed_samples, NUM_SF); printf("closing tx device\n"); - srslte_rf_close(&enb_radio); + srsran_rf_close(&enb_radio); } int run_test(const char* rx_args, const char* tx_args, bool timed_tx) { - int ret = SRSLTE_ERROR; + int ret = SRSRAN_ERROR; // make sure we can receive in slots if (NUM_SF % 5 != 0) { @@ -156,9 +156,9 @@ int run_test(const char* rx_args, const char* tx_args, bool timed_tx) #if 0 // print first 3 samples for each SF printf("enb_tx_buffer sf%d:\n", i); - srslte_vec_fprint_c(stdout, &enb_tx_buffer[i * SF_LEN], 3); + srsran_vec_fprint_c(stdout, &enb_tx_buffer[i * SF_LEN], 3); printf("ue_rx_buffer sf%d:\n", i); - srslte_vec_fprint_c(stdout, &ue_rx_buffer[sf_offet + i * SF_LEN], 3); + srsran_vec_fprint_c(stdout, &ue_rx_buffer[sf_offet + i * SF_LEN], 3); #endif if (memcmp(&ue_rx_buffer[sf_offet + i * SF_LEN], &enb_tx_buffer[i * SF_LEN], SF_LEN) != 0) { @@ -167,7 +167,7 @@ int run_test(const char* rx_args, const char* tx_args, bool timed_tx) } } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; exit: return ret; @@ -180,14 +180,14 @@ int param_test(const char* args_param, const int num_channels) rf_args[RF_PARAM_LEN - 1] = 0; printf("opening tx device with args=%s\n", rf_args); - if (srslte_rf_open_devname(&enb_radio, "zmq", rf_args, num_channels)) { + if (srsran_rf_open_devname(&enb_radio, "zmq", rf_args, num_channels)) { fprintf(stderr, "Error opening rf\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - srslte_rf_close(&enb_radio); + srsran_rf_close(&enb_radio); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int main() @@ -195,13 +195,13 @@ int main() // two Rx ports if (param_test("rx_port=ipc://dl0,rx_port1=ipc://dl1", 2)) { fprintf(stderr, "Param test failed!\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // multiple rx ports, no channel index provided if (param_test("rx_port=ipc://dl0,rx_port=ipc://dl1,rx_port=ipc://dl2,rx_port=ipc://dl3,base_srate=1.92e6", 4)) { fprintf(stderr, "Param test failed!\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // One Rx, one Tx and all generic options @@ -209,7 +209,7 @@ int main() "localhost:2000,rx_format=sc16,tx_format=sc16,tx_type=pub,rx_type=sub,base_srate=1.92e6,id=test", 1)) { fprintf(stderr, "Param test failed!\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // 1 port, 2 antennas, MIMO freq config @@ -218,12 +218,12 @@ int main() "localhost:2002,id=ue,base_srate=23.04e6,tx_freq0=2510e6,tx_freq1=2510e6,rx_freq0=2630e6,,rx_freq1=2630e6", 2)) { fprintf(stderr, "Param test failed!\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // single tx, single rx with continuous transmissions (no timed tx) using IPC transport if (run_test("rx_port=ipc://link1,id=ue,base_srate=1.92e6", "tx_port=ipc://link1,id=enb,base_srate=1.92e6", false) != - SRSLTE_SUCCESS) { + SRSRAN_SUCCESS) { fprintf(stderr, "Single tx, single rx test failed!\n"); return -1; } @@ -232,7 +232,7 @@ int main() if (run_test("tx_port=tcp://*:5554,rx_port=tcp://" "localhost:5555,id=ue,base_srate=1.92e6,log_trx_timeout=true,trx_timeout_ms=1000", "rx_port=tcp://localhost:5554,tx_port=tcp://*:5555,id=enb,base_srate=1.92e6", - false) != SRSLTE_SUCCESS) { + false) != SRSRAN_SUCCESS) { fprintf(stderr, "Two TRx radio test failed!\n"); return -1; } @@ -240,10 +240,10 @@ int main() // two trx radios with continous tx (no timed tx) using TCP for UL (UE tx) and IPC for eNB DL (eNB tx) if (run_test("tx_port=tcp://*:5554,rx_port=ipc://dl,id=ue,base_srate=1.92e6", "rx_port=tcp://localhost:5554,tx_port=ipc://dl,id=enb,base_srate=1.92e6", - true) != SRSLTE_SUCCESS) { + true) != SRSRAN_SUCCESS) { fprintf(stderr, "Two TRx radio test with timed tx failed!\n"); return -1; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } diff --git a/lib/src/phy/rf/rfnoc_test.cc b/lib/src/phy/rf/rfnoc_test.cc index 3bceb9344..1b3a3a59d 100644 --- a/lib/src/phy/rf/rfnoc_test.cc +++ b/lib/src/phy/rf/rfnoc_test.cc @@ -16,8 +16,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include @@ -119,8 +119,8 @@ private: while (tx_metadata.time_spec < config.duration_s + config.init_tx_time and running) { cf_t v = cexp_(2.0f * M_PI * float(txd_nsamples_total % config.period_nsamples) * config.get_freq_norm()); - srslte_vec_gen_sine(v, config.get_freq_norm(), tx_buffer[0], packet_size_nsamples); - srslte_vec_sc_prod_cfc(tx_buffer[0], -1, tx_buffer[1], packet_size_nsamples); + srsran_vec_gen_sine(v, config.get_freq_norm(), tx_buffer[0], packet_size_nsamples); + srsran_vec_sc_prod_cfc(tx_buffer[0], -1, tx_buffer[1], packet_size_nsamples); if (config.blocking) { std::unique_lock lock(mutex); @@ -183,7 +183,7 @@ private: // Update stats rxd_nsamples_total += rxd_nsamples; rxd_count++; - float avg_power = srslte_vec_avg_power_cf(rx_buffer[0], rxd_nsamples); + float avg_power = srsran_vec_avg_power_cf(rx_buffer[0], rxd_nsamples); if (std::isnan(avg_power) or avg_power > 1e-6) { Warning("-- RX " << rxd_count << " Received " << avg_power); } @@ -224,35 +224,35 @@ public: if (rfnoc->usrp_make(hint, config.nof_channels * config.nof_radios) != UHD_ERROR_NONE) { Warning(rfnoc->last_error); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (rfnoc->set_tx_rate(config.srate_hz) != UHD_ERROR_NONE) { Warning(rfnoc->last_error); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (rfnoc->set_rx_rate(config.srate_hz) != UHD_ERROR_NONE) { Warning(rfnoc->last_error); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } size_t nof_tx_samples = 0; size_t nof_rx_samples = 0; rfnoc->get_tx_stream(nof_tx_samples); rfnoc->get_rx_stream(nof_rx_samples); - packet_size_nsamples = SRSLTE_MIN(nof_tx_samples, nof_rx_samples); + packet_size_nsamples = SRSRAN_MIN(nof_tx_samples, nof_rx_samples); for (size_t j = 0; j < config.nof_channels; j++) { - tx_buffer[j] = srslte_vec_cf_malloc(packet_size_nsamples); - rx_buffer[j] = srslte_vec_cf_malloc(packet_size_nsamples); + tx_buffer[j] = srsran_vec_cf_malloc(packet_size_nsamples); + rx_buffer[j] = srsran_vec_cf_malloc(packet_size_nsamples); } if (rfnoc->start_rx_stream(config.init_tx_time) != UHD_ERROR_NONE) { Warning(rfnoc->last_error); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int run() @@ -276,7 +276,7 @@ public: Info("Rx packets: " << rxd_count); Info("Rx samples: " << rxd_nsamples_total); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } ~rfnoc_custom_testbench_s() @@ -296,17 +296,17 @@ static int test(const rfnoc_custom_testbench_s::config_s& config) { rfnoc_custom_testbench_s context(config); - TESTASSERT(context.init() == SRSLTE_SUCCESS); - TESTASSERT(context.run() == SRSLTE_SUCCESS); + TESTASSERT(context.init() == SRSRAN_SUCCESS); + TESTASSERT(context.run() == SRSRAN_SUCCESS); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } namespace bpo = boost::program_options; static int parse_args(int argc, char** argv, rfnoc_custom_testbench_s::config_s& args) { - int ret = SRSLTE_SUCCESS; + int ret = SRSRAN_SUCCESS; bpo::options_description options; bpo::options_description common("Common execution options"); @@ -332,14 +332,14 @@ static int parse_args(int argc, char** argv, rfnoc_custom_testbench_s::config_s& bpo::notify(vm); } catch (bpo::error& e) { std::cerr << e.what() << std::endl; - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } // help option was given or error - print usage and exit if (vm.count("help") || ret) { std::cout << "Usage: " << argv[0] << " [OPTIONS] config_file" << std::endl << std::endl; std::cout << options << std::endl << std::endl; - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } return ret; @@ -349,9 +349,9 @@ int main(int argc, char* argv[]) { rfnoc_custom_testbench_s::config_s config; - TESTASSERT(parse_args(argc, argv, config) == SRSLTE_SUCCESS); + TESTASSERT(parse_args(argc, argv, config) == SRSRAN_SUCCESS); - TESTASSERT(test(config) == SRSLTE_SUCCESS); + TESTASSERT(test(config) == SRSRAN_SUCCESS); return EXIT_SUCCESS; } diff --git a/lib/src/phy/scrambling/CMakeLists.txt b/lib/src/phy/scrambling/CMakeLists.txt index c0e6ac01e..60a8f86e6 100644 --- a/lib/src/phy/scrambling/CMakeLists.txt +++ b/lib/src/phy/scrambling/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -7,5 +7,5 @@ # file(GLOB SOURCES "*.c") -add_library(srslte_scrambling OBJECT ${SOURCES}) +add_library(srsran_scrambling OBJECT ${SOURCES}) add_subdirectory(test) diff --git a/lib/src/phy/scrambling/scrambling.c b/lib/src/phy/scrambling/scrambling.c index 987f2e348..822052493 100644 --- a/lib/src/phy/scrambling/scrambling.c +++ b/lib/src/phy/scrambling/scrambling.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,73 +10,73 @@ * */ -#include "srslte/phy/scrambling/scrambling.h" -#include "srslte/phy/utils/bit.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/scrambling/scrambling.h" +#include "srsran/phy/utils/bit.h" +#include "srsran/phy/utils/vector.h" #include -void srslte_scrambling_f(srslte_sequence_t* s, float* data) +void srsran_scrambling_f(srsran_sequence_t* s, float* data) { - srslte_scrambling_f_offset(s, data, 0, s->cur_len); + srsran_scrambling_f_offset(s, data, 0, s->cur_len); } -void srslte_scrambling_f_offset(srslte_sequence_t* s, float* data, int offset, int len) +void srsran_scrambling_f_offset(srsran_sequence_t* s, float* data, int offset, int len) { assert(len + offset <= s->cur_len); - srslte_vec_prod_fff(data, &s->c_float[offset], data, len); + srsran_vec_prod_fff(data, &s->c_float[offset], data, len); } -void srslte_scrambling_s(srslte_sequence_t* s, short* data) +void srsran_scrambling_s(srsran_sequence_t* s, short* data) { - srslte_scrambling_s_offset(s, data, 0, s->cur_len); + srsran_scrambling_s_offset(s, data, 0, s->cur_len); } -void srslte_scrambling_s_offset(srslte_sequence_t* s, short* data, int offset, int len) +void srsran_scrambling_s_offset(srsran_sequence_t* s, short* data, int offset, int len) { assert(len + offset <= s->cur_len); - srslte_vec_neg_sss(data, &s->c_short[offset], data, len); + srsran_vec_neg_sss(data, &s->c_short[offset], data, len); } -void srslte_scrambling_sb_offset(srslte_sequence_t* s, int8_t* data, int offset, int len) +void srsran_scrambling_sb_offset(srsran_sequence_t* s, int8_t* data, int offset, int len) { assert(len + offset <= s->cur_len); - srslte_vec_neg_bbb(data, &s->c_char[offset], data, len); + srsran_vec_neg_bbb(data, &s->c_char[offset], data, len); } -void srslte_scrambling_c(srslte_sequence_t* s, cf_t* data) +void srsran_scrambling_c(srsran_sequence_t* s, cf_t* data) { - srslte_scrambling_c_offset(s, data, 0, s->cur_len); + srsran_scrambling_c_offset(s, data, 0, s->cur_len); } -void srslte_scrambling_c_offset(srslte_sequence_t* s, cf_t* data, int offset, int len) +void srsran_scrambling_c_offset(srsran_sequence_t* s, cf_t* data, int offset, int len) { assert(len + offset <= s->cur_len); - srslte_vec_prod_cfc(data, &s->c_float[offset], data, len); + srsran_vec_prod_cfc(data, &s->c_float[offset], data, len); } static inline void scrambling_b(uint8_t* c, uint8_t* data, int len) { - srslte_vec_xor_bbb(c, data, data, len); + srsran_vec_xor_bbb(c, data, data, len); } -void srslte_scrambling_b(srslte_sequence_t* s, uint8_t* data) +void srsran_scrambling_b(srsran_sequence_t* s, uint8_t* data) { - srslte_scrambling_b_offset(s, data, 0, s->cur_len); + srsran_scrambling_b_offset(s, data, 0, s->cur_len); } -void srslte_scrambling_b_offset(srslte_sequence_t* s, uint8_t* data, int offset, int len) +void srsran_scrambling_b_offset(srsran_sequence_t* s, uint8_t* data, int offset, int len) { scrambling_b(&s->c[offset], data, len); } -void srslte_scrambling_bytes(srslte_sequence_t* s, uint8_t* data, int len) +void srsran_scrambling_bytes(srsran_sequence_t* s, uint8_t* data, int len) { scrambling_b(s->c_bytes, data, len / 8); // Scramble last bits if (len % 8) { uint8_t tmp_bits[8]; - srslte_bit_unpack_vector(&data[len / 8], tmp_bits, len % 8); + srsran_bit_unpack_vector(&data[len / 8], tmp_bits, len % 8); scrambling_b(&s->c[8 * (len / 8)], tmp_bits, len % 8); - srslte_bit_pack_vector(tmp_bits, &data[len / 8], len % 8); + srsran_bit_pack_vector(tmp_bits, &data[len / 8], len % 8); } } diff --git a/lib/src/phy/scrambling/test/CMakeLists.txt b/lib/src/phy/scrambling/test/CMakeLists.txt index 5f9b09e09..2184d7e10 100644 --- a/lib/src/phy/scrambling/test/CMakeLists.txt +++ b/lib/src/phy/scrambling/test/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -11,7 +11,7 @@ ######################################################################## add_executable(scrambling_test scrambling_test.c) -target_link_libraries(scrambling_test srslte_phy) +target_link_libraries(scrambling_test srsran_phy) add_test(scrambling_pbch_bit scrambling_test -s PBCH -c 50) add_test(scrambling_pbch_float scrambling_test -s PBCH -c 50 -f) diff --git a/lib/src/phy/scrambling/test/scrambling_test.c b/lib/src/phy/scrambling/test/scrambling_test.c index 12d909830..44ffea7c0 100644 --- a/lib/src/phy/scrambling/test/scrambling_test.c +++ b/lib/src/phy/scrambling/test/scrambling_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -19,11 +19,11 @@ #include #include -#include "srslte/srslte.h" +#include "srsran/srsran.h" -char* srslte_sequence_name = NULL; +char* srsran_sequence_name = NULL; bool do_floats = false; -srslte_cp_t cp = SRSLTE_CP_NORM; +srsran_cp_t cp = SRSRAN_CP_NORM; int cell_id = -1; int nof_bits = 100; @@ -47,13 +47,13 @@ void parse_args(int argc, char** argv) nof_bits = (int)strtol(argv[optind], NULL, 10); break; case 'e': - cp = SRSLTE_CP_EXT; + cp = SRSRAN_CP_EXT; break; case 'f': do_floats = true; break; case 's': - srslte_sequence_name = argv[optind]; + srsran_sequence_name = argv[optind]; break; default: usage(argv[0]); @@ -64,20 +64,20 @@ void parse_args(int argc, char** argv) usage(argv[0]); exit(-1); } - if (!srslte_sequence_name) { + if (!srsran_sequence_name) { usage(argv[0]); exit(-1); } } -int init_sequence(srslte_sequence_t* seq, char* name) +int init_sequence(srsran_sequence_t* seq, char* name) { if (!strcmp(name, "PBCH")) { - bzero(seq, sizeof(srslte_sequence_t)); - return srslte_sequence_pbch(seq, cp, cell_id); + bzero(seq, sizeof(srsran_sequence_t)); + return srsran_sequence_pbch(seq, cp, cell_id); } else if (!strcmp(name, "PDSCH")) { - bzero(seq, sizeof(srslte_sequence_t)); - return srslte_sequence_pdsch(seq, 1234, 0, 0, cell_id, nof_bits); + bzero(seq, sizeof(srsran_sequence_t)); + return srsran_sequence_pdsch(seq, 1234, 0, 0, cell_id, nof_bits); } else { ERROR("Unsupported sequence name %s", name); return -1; @@ -87,25 +87,25 @@ int init_sequence(srslte_sequence_t* seq, char* name) int main(int argc, char** argv) { int i; - srslte_sequence_t seq; + srsran_sequence_t seq; uint8_t * input_b, *scrambled_b; float * input_f, *scrambled_f; struct timeval t[3]; parse_args(argc, argv); - if (init_sequence(&seq, srslte_sequence_name) == -1) { - ERROR("Error initiating sequence %s", srslte_sequence_name); + if (init_sequence(&seq, srsran_sequence_name) == -1) { + ERROR("Error initiating sequence %s", srsran_sequence_name); exit(-1); } if (!do_floats) { - input_b = srslte_vec_u8_malloc(seq.cur_len); + input_b = srsran_vec_u8_malloc(seq.cur_len); if (!input_b) { perror("malloc"); exit(-1); } - scrambled_b = srslte_vec_u8_malloc(seq.cur_len); + scrambled_b = srsran_vec_u8_malloc(seq.cur_len); if (!scrambled_b) { perror("malloc"); exit(-1); @@ -117,9 +117,9 @@ int main(int argc, char** argv) } gettimeofday(&t[1], NULL); - srslte_scrambling_b(&seq, scrambled_b); + srsran_scrambling_b(&seq, scrambled_b); gettimeofday(&t[2], NULL); - srslte_scrambling_b(&seq, scrambled_b); + srsran_scrambling_b(&seq, scrambled_b); get_time_interval(t); printf("Texec=%ld us for %d bits\n", t[0].tv_usec, seq.cur_len); @@ -133,12 +133,12 @@ int main(int argc, char** argv) free(input_b); free(scrambled_b); } else { - input_f = srslte_vec_f_malloc(seq.cur_len); + input_f = srsran_vec_f_malloc(seq.cur_len); if (!input_f) { perror("malloc"); exit(-1); } - scrambled_f = srslte_vec_f_malloc(seq.cur_len); + scrambled_f = srsran_vec_f_malloc(seq.cur_len); if (!scrambled_f) { perror("malloc"); exit(-1); @@ -150,9 +150,9 @@ int main(int argc, char** argv) } gettimeofday(&t[1], NULL); - srslte_scrambling_f(&seq, scrambled_f); + srsran_scrambling_f(&seq, scrambled_f); gettimeofday(&t[2], NULL); - srslte_scrambling_f(&seq, scrambled_f); + srsran_scrambling_f(&seq, scrambled_f); get_time_interval(t); printf("Texec=%ld us for %d bits\n", t[0].tv_usec, seq.cur_len); @@ -170,12 +170,12 @@ int main(int argc, char** argv) int16_t *input_s, *scrambled_s; // Scramble also shorts - input_s = srslte_vec_i16_malloc(seq.cur_len); + input_s = srsran_vec_i16_malloc(seq.cur_len); if (!input_s) { perror("malloc"); exit(-1); } - scrambled_s = srslte_vec_i16_malloc(seq.cur_len); + scrambled_s = srsran_vec_i16_malloc(seq.cur_len); if (!scrambled_s) { perror("malloc"); exit(-1); @@ -187,9 +187,9 @@ int main(int argc, char** argv) } gettimeofday(&t[1], NULL); - srslte_scrambling_s(&seq, scrambled_s); + srsran_scrambling_s(&seq, scrambled_s); gettimeofday(&t[2], NULL); - srslte_scrambling_s(&seq, scrambled_s); + srsran_scrambling_s(&seq, scrambled_s); get_time_interval(t); printf("Texec short=%ld us for %d bits\n", t[0].tv_usec, seq.cur_len); @@ -207,12 +207,12 @@ int main(int argc, char** argv) int8_t *input_b, *scrambled_b; // Scramble also bytes - input_b = srslte_vec_i8_malloc(seq.cur_len); + input_b = srsran_vec_i8_malloc(seq.cur_len); if (!input_b) { perror("malloc"); exit(-1); } - scrambled_b = srslte_vec_i8_malloc(seq.cur_len); + scrambled_b = srsran_vec_i8_malloc(seq.cur_len); if (!scrambled_b) { perror("malloc"); exit(-1); @@ -224,9 +224,9 @@ int main(int argc, char** argv) } gettimeofday(&t[1], NULL); - srslte_scrambling_sb_offset(&seq, scrambled_b, 0, seq.cur_len); + srsran_scrambling_sb_offset(&seq, scrambled_b, 0, seq.cur_len); gettimeofday(&t[2], NULL); - srslte_scrambling_sb_offset(&seq, scrambled_b, 0, seq.cur_len); + srsran_scrambling_sb_offset(&seq, scrambled_b, 0, seq.cur_len); get_time_interval(t); printf("Texec char=%ld us for %d bits\n", t[0].tv_usec, seq.cur_len); @@ -242,6 +242,6 @@ int main(int argc, char** argv) free(scrambled_b); } printf("Ok\n"); - srslte_sequence_free(&seq); + srsran_sequence_free(&seq); exit(0); } diff --git a/lib/src/phy/sync/CMakeLists.txt b/lib/src/phy/sync/CMakeLists.txt index dee0406ec..d41e67a5a 100644 --- a/lib/src/phy/sync/CMakeLists.txt +++ b/lib/src/phy/sync/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -7,5 +7,5 @@ # file(GLOB SOURCES "*.c") -add_library(srslte_sync OBJECT ${SOURCES}) +add_library(srsran_sync OBJECT ${SOURCES}) add_subdirectory(test) diff --git a/lib/src/phy/sync/cfo.c b/lib/src/phy/sync/cfo.c index 4eb26fb0e..845d420d0 100644 --- a/lib/src/phy/sync/cfo.c +++ b/lib/src/phy/sync/cfo.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,29 +10,29 @@ * */ -#include "srslte/srslte.h" +#include "srsran/srsran.h" #include #include #include -#include "srslte/phy/sync/cfo.h" -#include "srslte/phy/utils/cexptab.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/sync/cfo.h" +#include "srsran/phy/utils/cexptab.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" /* Set next macro to 1 for using table generated CFO compensation */ -#define SRSLTE_CFO_USE_EXP_TABLE 0 +#define SRSRAN_CFO_USE_EXP_TABLE 0 -int srslte_cfo_init(srslte_cfo_t* h, uint32_t nsamples) +int srsran_cfo_init(srsran_cfo_t* h, uint32_t nsamples) { -#if SRSLTE_CFO_USE_EXP_TABLE - int ret = SRSLTE_ERROR; - bzero(h, sizeof(srslte_cfo_t)); +#if SRSRAN_CFO_USE_EXP_TABLE + int ret = SRSRAN_ERROR; + bzero(h, sizeof(srsran_cfo_t)); - if (srslte_cexptab_init(&h->tab, SRSLTE_CFO_CEXPTAB_SIZE)) { + if (srsran_cexptab_init(&h->tab, SRSRAN_CFO_CEXPTAB_SIZE)) { goto clean; } - h->cur_cexp = srslte_vec_cf_malloc(nsamples); + h->cur_cexp = srsran_vec_cf_malloc(nsamples); if (!h->cur_cexp) { goto clean; } @@ -40,62 +40,62 @@ int srslte_cfo_init(srslte_cfo_t* h, uint32_t nsamples) h->last_freq = 0; h->nsamples = nsamples; h->max_samples = nsamples; - srslte_cexptab_gen(&h->tab, h->cur_cexp, h->last_freq, h->nsamples); + srsran_cexptab_gen(&h->tab, h->cur_cexp, h->last_freq, h->nsamples); - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; clean: - if (ret == SRSLTE_ERROR) { - srslte_cfo_free(h); + if (ret == SRSRAN_ERROR) { + srsran_cfo_free(h); } return ret; -#else /* SRSLTE_CFO_USE_EXP_TABLE */ +#else /* SRSRAN_CFO_USE_EXP_TABLE */ h->nsamples = nsamples; - return SRSLTE_SUCCESS; -#endif /* SRSLTE_CFO_USE_EXP_TABLE */ + return SRSRAN_SUCCESS; +#endif /* SRSRAN_CFO_USE_EXP_TABLE */ } -void srslte_cfo_free(srslte_cfo_t* h) +void srsran_cfo_free(srsran_cfo_t* h) { -#if SRSLTE_CFO_USE_EXP_TABLE - srslte_cexptab_free(&h->tab); +#if SRSRAN_CFO_USE_EXP_TABLE + srsran_cexptab_free(&h->tab); if (h->cur_cexp) { free(h->cur_cexp); } -#endif /* SRSLTE_CFO_USE_EXP_TABLE */ - bzero(h, sizeof(srslte_cfo_t)); +#endif /* SRSRAN_CFO_USE_EXP_TABLE */ + bzero(h, sizeof(srsran_cfo_t)); } -void srslte_cfo_set_tol(srslte_cfo_t* h, float tol) +void srsran_cfo_set_tol(srsran_cfo_t* h, float tol) { h->tol = tol; } -int srslte_cfo_resize(srslte_cfo_t* h, uint32_t samples) +int srsran_cfo_resize(srsran_cfo_t* h, uint32_t samples) { -#if SRSLTE_CFO_USE_EXP_TABLE +#if SRSRAN_CFO_USE_EXP_TABLE if (samples <= h->max_samples) { - srslte_cexptab_gen(&h->tab, h->cur_cexp, h->last_freq, samples); + srsran_cexptab_gen(&h->tab, h->cur_cexp, h->last_freq, samples); h->nsamples = samples; } else { ERROR("Error in cfo_resize(): nof_samples must be lower than initialized"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } -#endif /* SRSLTE_CFO_USE_EXP_TABLE */ - return SRSLTE_SUCCESS; +#endif /* SRSRAN_CFO_USE_EXP_TABLE */ + return SRSRAN_SUCCESS; } -void srslte_cfo_correct(srslte_cfo_t* h, const cf_t* input, cf_t* output, float freq) +void srsran_cfo_correct(srsran_cfo_t* h, const cf_t* input, cf_t* output, float freq) { -#if SRSLTE_CFO_USE_EXP_TABLE +#if SRSRAN_CFO_USE_EXP_TABLE if (fabs(h->last_freq - freq) > h->tol) { h->last_freq = freq; - srslte_cexptab_gen(&h->tab, h->cur_cexp, h->last_freq, h->nsamples); + srsran_cexptab_gen(&h->tab, h->cur_cexp, h->last_freq, h->nsamples); DEBUG("CFO generating new table for frequency %.4fe-6", freq * 1e6); } - srslte_vec_prod_ccc(h->cur_cexp, input, output, h->nsamples); -#else /* SRSLTE_CFO_USE_EXP_TABLE */ - srslte_vec_apply_cfo(input, freq, output, h->nsamples); -#endif /* SRSLTE_CFO_USE_EXP_TABLE */ + srsran_vec_prod_ccc(h->cur_cexp, input, output, h->nsamples); +#else /* SRSRAN_CFO_USE_EXP_TABLE */ + srsran_vec_apply_cfo(input, freq, output, h->nsamples); +#endif /* SRSRAN_CFO_USE_EXP_TABLE */ } /* CFO correction which allows to specify the offset within the correction @@ -103,7 +103,7 @@ void srslte_cfo_correct(srslte_cfo_t* h, const cf_t* input, cf_t* output, float * Note that when correction table needs to be regenerated, the regeneration * takes place for the maximum number of samples */ -void srslte_cfo_correct_offset(srslte_cfo_t* h, +void srsran_cfo_correct_offset(srsran_cfo_t* h, const cf_t* input, cf_t* output, float freq, @@ -112,29 +112,29 @@ void srslte_cfo_correct_offset(srslte_cfo_t* h, { if (fabs(h->last_freq - freq) > h->tol) { h->last_freq = freq; - srslte_cexptab_gen(&h->tab, h->cur_cexp, h->last_freq, h->nsamples); + srsran_cexptab_gen(&h->tab, h->cur_cexp, h->last_freq, h->nsamples); DEBUG("CFO generating new table for frequency %.4fe-6", freq * 1e6); } - srslte_vec_prod_ccc(&h->cur_cexp[cexp_offset], input, output, nsamples); + srsran_vec_prod_ccc(&h->cur_cexp[cexp_offset], input, output, nsamples); } -float srslte_cfo_est_corr_cp(cf_t* input_buffer, uint32_t nof_prb) +float srsran_cfo_est_corr_cp(cf_t* input_buffer, uint32_t nof_prb) { - int nFFT = srslte_symbol_sz(nof_prb); + int nFFT = srsran_symbol_sz(nof_prb); int sf_n_samples = nFFT * 15; float tFFT = (float)(1 / 15000.0); - int cp_size = SRSLTE_CP_LEN_NORM(1, nFFT); + int cp_size = SRSRAN_CP_LEN_NORM(1, nFFT); // Compensate for initial SC-FDMA half subcarrier shift - srslte_vec_apply_cfo(input_buffer, (float)(1 / (nFFT * 15e3)) * (15e3 / 2.0), input_buffer, sf_n_samples); + srsran_vec_apply_cfo(input_buffer, (float)(1 / (nFFT * 15e3)) * (15e3 / 2.0), input_buffer, sf_n_samples); // Conjugate multiply the correlation inputs - cf_t cfo_estimated = srslte_vec_dot_prod_conj_ccc(&input_buffer[nFFT + SRSLTE_CP_LEN_NORM(0, nFFT)], - &input_buffer[2 * nFFT + SRSLTE_CP_LEN_NORM(0, nFFT)], + cf_t cfo_estimated = srsran_vec_dot_prod_conj_ccc(&input_buffer[nFFT + SRSRAN_CP_LEN_NORM(0, nFFT)], + &input_buffer[2 * nFFT + SRSRAN_CP_LEN_NORM(0, nFFT)], cp_size); // CFO correction and compensation for initial SC-FDMA half subcarrier shift float cfo = (float)(-1 * carg(cfo_estimated) / (float)(2 * M_PI * tFFT)); - srslte_vec_apply_cfo(input_buffer, (float)(1 / (nFFT * 15e3)) * ((-15e3 / 2.0) - cfo), input_buffer, sf_n_samples); + srsran_vec_apply_cfo(input_buffer, (float)(1 / (nFFT * 15e3)) * ((-15e3 / 2.0) - cfo), input_buffer, sf_n_samples); return cfo; } diff --git a/lib/src/phy/sync/cp.c b/lib/src/phy/sync/cp.c index 24241bcd6..e78c33011 100644 --- a/lib/src/phy/sync/cp.c +++ b/lib/src/phy/sync/cp.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,46 +10,46 @@ * */ -#include "srslte/srslte.h" +#include "srsran/srsran.h" #include -#include "srslte/phy/sync/cp.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/sync/cp.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" -int srslte_cp_synch_init(srslte_cp_synch_t* q, uint32_t symbol_sz) +int srsran_cp_synch_init(srsran_cp_synch_t* q, uint32_t symbol_sz) { q->symbol_sz = symbol_sz; q->max_symbol_sz = symbol_sz; - q->corr = srslte_vec_cf_malloc(q->symbol_sz); + q->corr = srsran_vec_cf_malloc(q->symbol_sz); if (!q->corr) { perror("malloc"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -void srslte_cp_synch_free(srslte_cp_synch_t* q) +void srsran_cp_synch_free(srsran_cp_synch_t* q) { if (q->corr) { free(q->corr); } } -int srslte_cp_synch_resize(srslte_cp_synch_t* q, uint32_t symbol_sz) +int srsran_cp_synch_resize(srsran_cp_synch_t* q, uint32_t symbol_sz) { if (symbol_sz > q->max_symbol_sz) { ERROR("Error in cp_synch_resize(): symbol_sz must be lower than initialized"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } q->symbol_sz = symbol_sz; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } uint32_t -srslte_cp_synch(srslte_cp_synch_t* q, const cf_t* input, uint32_t max_offset, uint32_t nof_symbols, uint32_t cp_len) +srsran_cp_synch(srsran_cp_synch_t* q, const cf_t* input, uint32_t max_offset, uint32_t nof_symbols, uint32_t cp_len) { if (max_offset > q->symbol_sz) { max_offset = q->symbol_sz; @@ -59,15 +59,15 @@ srslte_cp_synch(srslte_cp_synch_t* q, const cf_t* input, uint32_t max_offset, ui const cf_t* inputPtr = input; for (int n = 0; n < nof_symbols; n++) { uint32_t cplen = (n % 7) ? cp_len : cp_len + 1; - q->corr[i] += srslte_vec_dot_prod_conj_ccc(&inputPtr[i], &inputPtr[i + q->symbol_sz], cplen) / nof_symbols; + q->corr[i] += srsran_vec_dot_prod_conj_ccc(&inputPtr[i], &inputPtr[i + q->symbol_sz], cplen) / nof_symbols; inputPtr += q->symbol_sz + cplen; } } - uint32_t max_idx = srslte_vec_max_abs_ci(q->corr, max_offset); + uint32_t max_idx = srsran_vec_max_abs_ci(q->corr, max_offset); return max_idx; } -cf_t srslte_cp_synch_corr_output(srslte_cp_synch_t* q, uint32_t offset) +cf_t srsran_cp_synch_corr_output(srsran_cp_synch_t* q, uint32_t offset) { if (offset < q->symbol_sz) { return q->corr[offset]; diff --git a/lib/src/phy/sync/find_sss.c b/lib/src/phy/sync/find_sss.c index edfec9a85..50efe0897 100644 --- a/lib/src/phy/sync/find_sss.c +++ b/lib/src/phy/sync/find_sss.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -14,87 +14,87 @@ #include #include -#include "srslte/phy/sync/sss.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/sync/sss.h" +#include "srsran/phy/utils/vector.h" #define MAX_M 3 -static void corr_all_zs(cf_t z[SRSLTE_SSS_N], float s[SRSLTE_SSS_N][SRSLTE_SSS_N - 1], float output[SRSLTE_SSS_N]) +static void corr_all_zs(cf_t z[SRSRAN_SSS_N], float s[SRSRAN_SSS_N][SRSRAN_SSS_N - 1], float output[SRSRAN_SSS_N]) { uint32_t m; - cf_t tmp[SRSLTE_SSS_N]; + cf_t tmp[SRSRAN_SSS_N]; - for (m = 0; m < SRSLTE_SSS_N; m++) { - tmp[m] = srslte_vec_dot_prod_cfc(z, s[m], SRSLTE_SSS_N - 1); + for (m = 0; m < SRSRAN_SSS_N; m++) { + tmp[m] = srsran_vec_dot_prod_cfc(z, s[m], SRSRAN_SSS_N - 1); } - srslte_vec_abs_square_cf(tmp, output, SRSLTE_SSS_N); + srsran_vec_abs_square_cf(tmp, output, SRSRAN_SSS_N); } static void -corr_all_sz_partial(cf_t z[SRSLTE_SSS_N], float s[SRSLTE_SSS_N][SRSLTE_SSS_N], uint32_t M, float output[SRSLTE_SSS_N]) +corr_all_sz_partial(cf_t z[SRSRAN_SSS_N], float s[SRSRAN_SSS_N][SRSRAN_SSS_N], uint32_t M, float output[SRSRAN_SSS_N]) { - uint32_t Nm = SRSLTE_SSS_N / M; - cf_t tmp[SRSLTE_SSS_N]; - float tmp_abs[MAX_M - 1][SRSLTE_SSS_N]; + uint32_t Nm = SRSRAN_SSS_N / M; + cf_t tmp[SRSRAN_SSS_N]; + float tmp_abs[MAX_M - 1][SRSRAN_SSS_N]; int j, m; float* ptr; for (j = 0; j < M; j++) { - for (m = 0; m < SRSLTE_SSS_N; m++) { - tmp[m] = srslte_vec_dot_prod_cfc(&z[j * Nm], &s[m][j * Nm], Nm); + for (m = 0; m < SRSRAN_SSS_N; m++) { + tmp[m] = srsran_vec_dot_prod_cfc(&z[j * Nm], &s[m][j * Nm], Nm); } if (j == 0) { ptr = output; } else { ptr = tmp_abs[j - 1]; } - srslte_vec_abs_square_cf(tmp, ptr, SRSLTE_SSS_N); + srsran_vec_abs_square_cf(tmp, ptr, SRSRAN_SSS_N); } for (j = 1; j < M; j++) { - srslte_vec_sum_fff(tmp_abs[j - 1], output, output, SRSLTE_SSS_N); + srsran_vec_sum_fff(tmp_abs[j - 1], output, output, SRSRAN_SSS_N); } } -static void extract_pair_sss(srslte_sss_t* q, const cf_t* input, cf_t* ce, cf_t y[2][SRSLTE_SSS_N]) +static void extract_pair_sss(srsran_sss_t* q, const cf_t* input, cf_t* ce, cf_t y[2][SRSRAN_SSS_N]) { - cf_t input_fft[SRSLTE_SYMBOL_SZ_MAX]; + cf_t input_fft[SRSRAN_SYMBOL_SZ_MAX]; // Run FFT - srslte_dft_run_c(&q->dftp_input, input, input_fft); + srsran_dft_run_c(&q->dftp_input, input, input_fft); // Equalize if available channel estimate if (ce) { - srslte_vec_div_ccc( - &input_fft[q->fft_size / 2 - SRSLTE_SSS_N], ce, &input_fft[q->fft_size / 2 - SRSLTE_SSS_N], 2 * SRSLTE_SSS_N); + srsran_vec_div_ccc( + &input_fft[q->fft_size / 2 - SRSRAN_SSS_N], ce, &input_fft[q->fft_size / 2 - SRSRAN_SSS_N], 2 * SRSRAN_SSS_N); } // Extract FFT Data - for (int i = 0; i < SRSLTE_SSS_N; i++) { - y[0][i] = input_fft[q->fft_size / 2 - SRSLTE_SSS_N + 2 * i]; - y[1][i] = input_fft[q->fft_size / 2 - SRSLTE_SSS_N + 2 * i + 1]; + for (int i = 0; i < SRSRAN_SSS_N; i++) { + y[0][i] = input_fft[q->fft_size / 2 - SRSRAN_SSS_N + 2 * i]; + y[1][i] = input_fft[q->fft_size / 2 - SRSRAN_SSS_N + 2 * i + 1]; } // Normalize for (int i = 0; i < 2; i++) { - float avg_pow = srslte_vec_avg_power_cf(y[i], SRSLTE_SSS_N); + float avg_pow = srsran_vec_avg_power_cf(y[i], SRSRAN_SSS_N); float rms = (avg_pow != 0.0f) ? sqrtf(avg_pow) : 1.0f; - srslte_vec_sc_prod_cfc(y[i], 1.0 / rms, y[i], SRSLTE_SSS_N); + srsran_vec_sc_prod_cfc(y[i], 1.0 / rms, y[i], SRSRAN_SSS_N); } // Unmask signal with sequence generated from NID2 - srslte_vec_prod_cfc(y[0], q->fc_tables[q->N_id_2].c[0], y[0], SRSLTE_SSS_N); - srslte_vec_prod_cfc(y[1], q->fc_tables[q->N_id_2].c[1], y[1], SRSLTE_SSS_N); + srsran_vec_prod_cfc(y[0], q->fc_tables[q->N_id_2].c[0], y[0], SRSRAN_SSS_N); + srsran_vec_prod_cfc(y[1], q->fc_tables[q->N_id_2].c[1], y[1], SRSRAN_SSS_N); } -int srslte_sss_m0m1_diff(srslte_sss_t* q, +int srsran_sss_m0m1_diff(srsran_sss_t* q, const cf_t* input, uint32_t* m0, float* m0_value, uint32_t* m1, float* m1_value) { - return srslte_sss_m0m1_diff_coh(q, input, NULL, m0, m0_value, m1, m1_value); + return srsran_sss_m0m1_diff_coh(q, input, NULL, m0, m0_value, m1, m1_value); } /* Differential SSS estimation. @@ -105,39 +105,39 @@ int srslte_sss_m0m1_diff(srslte_sss_t* q, * */ -int srslte_sss_m0m1_diff_coh(srslte_sss_t* q, +int srsran_sss_m0m1_diff_coh(srsran_sss_t* q, const cf_t* input, - cf_t ce[2 * SRSLTE_SSS_N], + cf_t ce[2 * SRSRAN_SSS_N], uint32_t* m0, float* m0_value, uint32_t* m1, float* m1_value) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL && input != NULL && m0 != NULL && m1 != NULL) { - cf_t yprod[SRSLTE_SSS_N]; - cf_t y[2][SRSLTE_SSS_N]; + cf_t yprod[SRSRAN_SSS_N]; + cf_t y[2][SRSRAN_SSS_N]; extract_pair_sss(q, input, ce, y); - srslte_vec_prod_conj_ccc(&y[0][1], y[0], yprod, SRSLTE_SSS_N - 1); + srsran_vec_prod_conj_ccc(&y[0][1], y[0], yprod, SRSRAN_SSS_N - 1); corr_all_zs(yprod, q->fc_tables[q->N_id_2].sd, q->corr_output_m0); - *m0 = srslte_vec_max_fi(q->corr_output_m0, SRSLTE_SSS_N); + *m0 = srsran_vec_max_fi(q->corr_output_m0, SRSRAN_SSS_N); if (m0_value) { *m0_value = q->corr_output_m0[*m0]; } - srslte_vec_prod_cfc(y[1], q->fc_tables[q->N_id_2].z1[*m0], y[1], SRSLTE_SSS_N); - srslte_vec_prod_conj_ccc(&y[1][1], y[1], yprod, SRSLTE_SSS_N - 1); + srsran_vec_prod_cfc(y[1], q->fc_tables[q->N_id_2].z1[*m0], y[1], SRSRAN_SSS_N); + srsran_vec_prod_conj_ccc(&y[1][1], y[1], yprod, SRSRAN_SSS_N - 1); corr_all_zs(yprod, q->fc_tables[q->N_id_2].sd, q->corr_output_m1); - *m1 = srslte_vec_max_fi(q->corr_output_m1, SRSLTE_SSS_N); + *m1 = srsran_vec_max_fi(q->corr_output_m1, SRSRAN_SSS_N); if (m1_value) { *m1_value = q->corr_output_m1[*m1]; } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } @@ -149,60 +149,60 @@ int srslte_sss_m0m1_diff_coh(srslte_sss_t* q, * Jung-In Kim, Jung-Su Han, Hee-Jin Roh and Hyung-Jin Choi */ -int srslte_sss_m0m1_partial(srslte_sss_t* q, +int srsran_sss_m0m1_partial(srsran_sss_t* q, const cf_t* input, uint32_t M, - cf_t ce[2 * SRSLTE_SSS_N], + cf_t ce[2 * SRSRAN_SSS_N], uint32_t* m0, float* m0_value, uint32_t* m1, float* m1_value) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL && input != NULL && m0 != NULL && m1 != NULL && M <= MAX_M) { - cf_t y[2][SRSLTE_SSS_N]; + cf_t y[2][SRSRAN_SSS_N]; extract_pair_sss(q, input, ce, y); corr_all_sz_partial(y[0], q->fc_tables[q->N_id_2].s, M, q->corr_output_m0); - *m0 = srslte_vec_max_fi(q->corr_output_m0, SRSLTE_SSS_N); + *m0 = srsran_vec_max_fi(q->corr_output_m0, SRSRAN_SSS_N); if (m0_value) { *m0_value = q->corr_output_m0[*m0]; } - srslte_vec_prod_cfc(y[1], q->fc_tables[q->N_id_2].z1[*m0], y[1], SRSLTE_SSS_N); + srsran_vec_prod_cfc(y[1], q->fc_tables[q->N_id_2].z1[*m0], y[1], SRSRAN_SSS_N); corr_all_sz_partial(y[1], q->fc_tables[q->N_id_2].s, M, q->corr_output_m1); - *m1 = srslte_vec_max_fi(q->corr_output_m1, SRSLTE_SSS_N); + *m1 = srsran_vec_max_fi(q->corr_output_m1, SRSRAN_SSS_N); if (m1_value) { *m1_value = q->corr_output_m1[*m1]; } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } -void convert_tables(srslte_sss_fc_tables_t* fc_tables, srslte_sss_tables_t* in) +void convert_tables(srsran_sss_fc_tables_t* fc_tables, srsran_sss_tables_t* in) { uint32_t i, j; - for (i = 0; i < SRSLTE_SSS_N; i++) { - for (j = 0; j < SRSLTE_SSS_N; j++) { + for (i = 0; i < SRSRAN_SSS_N; i++) { + for (j = 0; j < SRSRAN_SSS_N; j++) { fc_tables->z1[i][j] = (float)in->z1[i][j]; } } - for (i = 0; i < SRSLTE_SSS_N; i++) { - for (j = 0; j < SRSLTE_SSS_N; j++) { + for (i = 0; i < SRSRAN_SSS_N; i++) { + for (j = 0; j < SRSRAN_SSS_N; j++) { fc_tables->s[i][j] = (float)in->s[i][j]; } } - for (i = 0; i < SRSLTE_SSS_N; i++) { - for (j = 0; j < SRSLTE_SSS_N - 1; j++) { + for (i = 0; i < SRSRAN_SSS_N; i++) { + for (j = 0; j < SRSRAN_SSS_N - 1; j++) { fc_tables->sd[i][j] = (float)in->s[i][j + 1] * in->s[i][j]; } } for (i = 0; i < 2; i++) { - for (j = 0; j < SRSLTE_SSS_N; j++) { + for (j = 0; j < SRSRAN_SSS_N; j++) { fc_tables->c[i][j] = (float)in->c[i][j]; } } diff --git a/lib/src/phy/sync/gen_sss.c b/lib/src/phy/sync/gen_sss.c index 018a5106b..e2db422a7 100644 --- a/lib/src/phy/sync/gen_sss.c +++ b/lib/src/phy/sync/gen_sss.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -12,7 +12,7 @@ #include -#include "srslte/phy/sync/sss.h" +#include "srsran/phy/sync/sss.h" /** * @brief Function documentation: initSSStables() @@ -23,33 +23,33 @@ void generate_zsc_tilde(int* z_tilde, int* s_tilde, int* c_tilde) { int i; - int x[SRSLTE_SSS_N]; - bzero(x, sizeof(int) * SRSLTE_SSS_N); + int x[SRSRAN_SSS_N]; + bzero(x, sizeof(int) * SRSRAN_SSS_N); x[4] = 1; for (i = 0; i < 26; i++) x[i + 5] = (x[i + 2] + x[i]) % 2; - for (i = 0; i < SRSLTE_SSS_N; i++) + for (i = 0; i < SRSRAN_SSS_N; i++) s_tilde[i] = 1 - 2 * x[i]; for (i = 0; i < 26; i++) x[i + 5] = (x[i + 3] + x[i]) % 2; - for (i = 0; i < SRSLTE_SSS_N; i++) + for (i = 0; i < SRSRAN_SSS_N; i++) c_tilde[i] = 1 - 2 * x[i]; for (i = 0; i < 26; i++) x[i + 5] = (x[i + 4] + x[i + 2] + x[i + 1] + x[i]) % 2; - for (i = 0; i < SRSLTE_SSS_N; i++) + for (i = 0; i < SRSRAN_SSS_N; i++) z_tilde[i] = 1 - 2 * x[i]; } void generate_m0m1(uint32_t N_id_1, uint32_t* m0, uint32_t* m1) { - uint32_t q_prime = N_id_1 / (SRSLTE_SSS_N - 1); - uint32_t q = (N_id_1 + (q_prime * (q_prime + 1) / 2)) / (SRSLTE_SSS_N - 1); + uint32_t q_prime = N_id_1 / (SRSRAN_SSS_N - 1); + uint32_t q = (N_id_1 + (q_prime * (q_prime + 1) / 2)) / (SRSRAN_SSS_N - 1); uint32_t m_prime = N_id_1 + (q * (q + 1) / 2); - *m0 = m_prime % SRSLTE_SSS_N; - *m1 = (*m0 + m_prime / SRSLTE_SSS_N + 1) % SRSLTE_SSS_N; + *m0 = m_prime % SRSRAN_SSS_N; + *m1 = (*m0 + m_prime / SRSRAN_SSS_N + 1) % SRSRAN_SSS_N; } /* table[m0][m1-1]=N_id_1 */ @@ -66,15 +66,15 @@ void generate_N_id_1_table(uint32_t table[30][30]) void generate_s(int* s, int* s_tilde, uint32_t m0_m1) { uint32_t i; - for (i = 0; i < SRSLTE_SSS_N; i++) { - s[i] = s_tilde[(i + m0_m1) % SRSLTE_SSS_N]; + for (i = 0; i < SRSRAN_SSS_N; i++) { + s[i] = s_tilde[(i + m0_m1) % SRSRAN_SSS_N]; } } -void generate_s_all(int s[SRSLTE_SSS_N][SRSLTE_SSS_N], int* s_tilde) +void generate_s_all(int s[SRSRAN_SSS_N][SRSRAN_SSS_N], int* s_tilde) { uint32_t i; - for (i = 0; i < SRSLTE_SSS_N; i++) { + for (i = 0; i < SRSRAN_SSS_N; i++) { generate_s(s[i], s_tilde, i); } } @@ -82,31 +82,31 @@ void generate_s_all(int s[SRSLTE_SSS_N][SRSLTE_SSS_N], int* s_tilde) void generate_c(int* c, int* c_tilde, uint32_t N_id_2, bool is_c0) { uint32_t i; - for (i = 0; i < SRSLTE_SSS_N; i++) { - c[i] = c_tilde[(i + N_id_2 + (is_c0 ? 3 : 0)) % SRSLTE_SSS_N]; + for (i = 0; i < SRSRAN_SSS_N; i++) { + c[i] = c_tilde[(i + N_id_2 + (is_c0 ? 3 : 0)) % SRSRAN_SSS_N]; } } void generate_z(int* z, int* z_tilde, uint32_t m0_m1) { uint32_t i; - for (i = 0; i < SRSLTE_SSS_N; i++) { - z[i] = z_tilde[(i + (m0_m1 % 8)) % SRSLTE_SSS_N]; + for (i = 0; i < SRSRAN_SSS_N; i++) { + z[i] = z_tilde[(i + (m0_m1 % 8)) % SRSRAN_SSS_N]; } } -void generate_z_all(int z[SRSLTE_SSS_N][SRSLTE_SSS_N], int* z_tilde) +void generate_z_all(int z[SRSRAN_SSS_N][SRSRAN_SSS_N], int* z_tilde) { uint32_t i; - for (i = 0; i < SRSLTE_SSS_N; i++) { + for (i = 0; i < SRSRAN_SSS_N; i++) { generate_z(z[i], z_tilde, i); } } -void generate_sss_all_tables(srslte_sss_tables_t* tables, uint32_t N_id_2) +void generate_sss_all_tables(srsran_sss_tables_t* tables, uint32_t N_id_2) { uint32_t i; - int s_t[SRSLTE_SSS_N], c_t[SRSLTE_SSS_N], z_t[SRSLTE_SSS_N]; + int s_t[SRSRAN_SSS_N], c_t[SRSRAN_SSS_N], z_t[SRSRAN_SSS_N]; generate_zsc_tilde(z_t, s_t, c_t); generate_s_all(tables->s, s_t); @@ -116,7 +116,7 @@ void generate_sss_all_tables(srslte_sss_tables_t* tables, uint32_t N_id_2) } } -void srslte_sss_generate(float* signal0, float* signal5, uint32_t cell_id) +void srsran_sss_generate(float* signal0, float* signal5, uint32_t cell_id) { uint32_t i; @@ -124,8 +124,8 @@ void srslte_sss_generate(float* signal0, float* signal5, uint32_t cell_id) uint32_t id2 = cell_id % 3; uint32_t m0; uint32_t m1; - int s_t[SRSLTE_SSS_N], c_t[SRSLTE_SSS_N], z_t[SRSLTE_SSS_N]; - int s0[SRSLTE_SSS_N], s1[SRSLTE_SSS_N], c0[SRSLTE_SSS_N], c1[SRSLTE_SSS_N], z1_0[SRSLTE_SSS_N], z1_1[SRSLTE_SSS_N]; + int s_t[SRSRAN_SSS_N], c_t[SRSRAN_SSS_N], z_t[SRSRAN_SSS_N]; + int s0[SRSRAN_SSS_N], s1[SRSRAN_SSS_N], c0[SRSRAN_SSS_N], c1[SRSRAN_SSS_N], z1_0[SRSRAN_SSS_N], z1_1[SRSRAN_SSS_N]; generate_m0m1(id1, &m0, &m1); generate_zsc_tilde(z_t, s_t, c_t); @@ -139,13 +139,13 @@ void srslte_sss_generate(float* signal0, float* signal5, uint32_t cell_id) generate_z(z1_0, z_t, m0); generate_z(z1_1, z_t, m1); - for (i = 0; i < SRSLTE_SSS_N; i++) { + for (i = 0; i < SRSRAN_SSS_N; i++) { /** Even Resource Elements: Sub-frame 0*/ signal0[2 * i] = (float)(s0[i] * c0[i]); /** Odd Resource Elements: Sub-frame 0*/ signal0[2 * i + 1] = (float)(s1[i] * c1[i] * z1_0[i]); } - for (i = 0; i < SRSLTE_SSS_N; i++) { + for (i = 0; i < SRSRAN_SSS_N; i++) { /** Even Resource Elements: Sub-frame 5*/ signal5[2 * i] = (float)(s1[i] * c0[i]); /** Odd Resource Elements: Sub-frame 5*/ diff --git a/lib/src/phy/sync/npss.c b/lib/src/phy/sync/npss.c index 8aa03b89b..d1f1e3d12 100644 --- a/lib/src/phy/sync/npss.c +++ b/lib/src/phy/sync/npss.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -17,62 +17,62 @@ #include #include -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/dft/dft.h" -#include "srslte/phy/io/filesink.h" -#include "srslte/phy/sync/npss.h" -#include "srslte/phy/utils/convolution.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/dft/dft.h" +#include "srsran/phy/io/filesink.h" +#include "srsran/phy/sync/npss.h" +#include "srsran/phy/utils/convolution.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" #define PRINT_ERR(err) fprintf(stderr, "%s(): %s", __PRETTY_FUNCTION__, err) #define DUMP_SIGNALS 0 #define DO_FREQ_SHIFT 1 -const float factor_lut[SRSLTE_NPSS_LEN] = {1, 1, 1, 1, -1, -1, 1, 1, 1, -1, 1}; +const float factor_lut[SRSRAN_NPSS_LEN] = {1, 1, 1, 1, -1, -1, 1, 1, 1, -1, 1}; /* Initializes the NPSS synchronization object. * * It correlates a signal of frame_size samples with the NPSS sequence in the time domain * The NPSS sequence is transformed using 11 * fft_size samples plus cyclic prefix. */ -int srslte_npss_synch_init(srslte_npss_synch_t* q, uint32_t frame_size, uint32_t fft_size) +int srsran_npss_synch_init(srsran_npss_synch_t* q, uint32_t frame_size, uint32_t fft_size) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL) { - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; - memset(q, 0, sizeof(srslte_npss_synch_t)); + memset(q, 0, sizeof(srsran_npss_synch_t)); q->fft_size = q->max_fft_size = fft_size; q->frame_size = q->max_frame_size = frame_size; q->ema_alpha = 0.2; - uint32_t buffer_size = SRSLTE_NPSS_CORR_FILTER_LEN + frame_size + 1; + uint32_t buffer_size = SRSRAN_NPSS_CORR_FILTER_LEN + frame_size + 1; - q->tmp_input = srslte_vec_cf_malloc(buffer_size); + q->tmp_input = srsran_vec_cf_malloc(buffer_size); if (!q->tmp_input) { PRINT_ERR("Error allocating memory\n"); goto clean_and_exit; } memset(q->tmp_input, 0, buffer_size * sizeof(cf_t)); - q->conv_output = srslte_vec_cf_malloc(buffer_size); + q->conv_output = srsran_vec_cf_malloc(buffer_size); if (!q->conv_output) { fprintf(stderr, "Error allocating memory\n"); goto clean_and_exit; } memset(q->conv_output, 0, sizeof(cf_t) * buffer_size); - q->conv_output_avg = srslte_vec_f_malloc(buffer_size); + q->conv_output_avg = srsran_vec_f_malloc(buffer_size); if (!q->conv_output_avg) { fprintf(stderr, "Error allocating memory\n"); goto clean_and_exit; } memset(q->conv_output_avg, 0, sizeof(float) * buffer_size); -#ifdef SRSLTE_NPSS_ACCUMULATE_ABS - q->conv_output_abs = srslte_vec_f_malloc(buffer_size); +#ifdef SRSRAN_NPSS_ACCUMULATE_ABS + q->conv_output_abs = srsran_vec_f_malloc(buffer_size); if (!q->conv_output_abs) { fprintf(stderr, "Error allocating memory\n"); goto clean_and_exit; @@ -80,7 +80,7 @@ int srslte_npss_synch_init(srslte_npss_synch_t* q, uint32_t frame_size, uint32_t memset(q->conv_output_abs, 0, sizeof(float) * buffer_size); #endif - q->npss_signal_time = srslte_vec_cf_malloc(buffer_size); + q->npss_signal_time = srsran_vec_cf_malloc(buffer_size); if (!q->npss_signal_time) { fprintf(stderr, "Error allocating memory\n"); goto clean_and_exit; @@ -88,86 +88,86 @@ int srslte_npss_synch_init(srslte_npss_synch_t* q, uint32_t frame_size, uint32_t memset(q->npss_signal_time, 0, sizeof(cf_t) * buffer_size); // The NPSS is translated into the time domain - if (srslte_npss_corr_init(q->npss_signal_time, fft_size, q->frame_size)) { + if (srsran_npss_corr_init(q->npss_signal_time, fft_size, q->frame_size)) { fprintf(stderr, "Error initiating NPSS detector for fft_size=%d\n", fft_size); goto clean_and_exit; } #ifdef CONVOLUTION_FFT - if (srslte_conv_fft_cc_init(&q->conv_fft, frame_size, SRSLTE_NPSS_CORR_FILTER_LEN)) { + if (srsran_conv_fft_cc_init(&q->conv_fft, frame_size, SRSRAN_NPSS_CORR_FILTER_LEN)) { fprintf(stderr, "Error initiating convolution FFT\n"); goto clean_and_exit; } // run convolution once to compute filter - srslte_corr_fft_cc_run(&q->conv_fft, q->tmp_input, q->npss_signal_time, q->conv_output); + srsran_corr_fft_cc_run(&q->conv_fft, q->tmp_input, q->npss_signal_time, q->conv_output); #endif - srslte_npss_synch_reset(q); + srsran_npss_synch_reset(q); - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } clean_and_exit: - if (ret == SRSLTE_ERROR) { - srslte_npss_synch_free(q); + if (ret == SRSRAN_ERROR) { + srsran_npss_synch_free(q); } return ret; } -int srslte_npss_synch_resize(srslte_npss_synch_t* q, uint32_t frame_size, uint32_t fft_size) +int srsran_npss_synch_resize(srsran_npss_synch_t* q, uint32_t frame_size, uint32_t fft_size) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL) { - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; if (fft_size > q->max_fft_size || frame_size > q->max_frame_size) { PRINT_ERR("fft_size and frame_size must be lower than initialized\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } q->ema_alpha = 0.2; q->fft_size = fft_size; q->frame_size = frame_size; - uint32_t buffer_size = SRSLTE_NPSS_CORR_FILTER_LEN + frame_size + 1; + uint32_t buffer_size = SRSRAN_NPSS_CORR_FILTER_LEN + frame_size + 1; memset(q->tmp_input, 0, buffer_size * sizeof(cf_t)); memset(q->conv_output, 0, sizeof(cf_t) * buffer_size); memset(q->conv_output_avg, 0, sizeof(float) * buffer_size); -#ifdef SRSLTE_NPSS_ACCUMULATE_ABS +#ifdef SRSRAN_NPSS_ACCUMULATE_ABS memset(q->conv_output_abs, 0, sizeof(float) * buffer_size); #endif // Re-generate NPSS sequences for this FFT size - if (srslte_npss_corr_init(q->npss_signal_time, fft_size, q->frame_size)) { + if (srsran_npss_corr_init(q->npss_signal_time, fft_size, q->frame_size)) { fprintf(stderr, "Error initiating NPSS detector for fft_size=%d\n", fft_size); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } #ifdef CONVOLUTION_FFT - if (srslte_conv_fft_cc_replan(&q->conv_fft, frame_size, SRSLTE_NPSS_CORR_FILTER_LEN)) { + if (srsran_conv_fft_cc_replan(&q->conv_fft, frame_size, SRSRAN_NPSS_CORR_FILTER_LEN)) { fprintf(stderr, "Error initiating convolution FFT\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } #endif - srslte_npss_synch_reset(q); + srsran_npss_synch_reset(q); - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } -int srslte_npss_corr_init(cf_t* npss_signal_time, const uint32_t fft_size, const uint32_t frame_size) +int srsran_npss_corr_init(cf_t* npss_signal_time, const uint32_t fft_size, const uint32_t frame_size) { - srslte_dft_plan_t plan; + srsran_dft_plan_t plan; _Complex float npss_signal_pad[fft_size]; - _Complex float npss_signal[SRSLTE_NPSS_TOT_LEN] = {}; + _Complex float npss_signal[SRSRAN_NPSS_TOT_LEN] = {}; // generate correlation sequence - srslte_npss_generate(npss_signal); + srsran_npss_generate(npss_signal); #if DUMP_SIGNALS - // srslte_vec_save_file("npss_corr_seq_freq.bin", npss_signal, SRSLTE_NPSS_TOT_LEN*sizeof(cf_t)); + // srsran_vec_save_file("npss_corr_seq_freq.bin", npss_signal, SRSRAN_NPSS_TOT_LEN*sizeof(cf_t)); #endif // zero buffers @@ -175,26 +175,26 @@ int srslte_npss_corr_init(cf_t* npss_signal_time, const uint32_t fft_size, const memset(npss_signal_pad, 0, fft_size * sizeof(cf_t)); // construct dft plan and convert signal into the time domain - if (srslte_dft_plan(&plan, fft_size, SRSLTE_DFT_BACKWARD, SRSLTE_DFT_COMPLEX)) { - return SRSLTE_ERROR; + if (srsran_dft_plan(&plan, fft_size, SRSRAN_DFT_BACKWARD, SRSRAN_DFT_COMPLEX)) { + return SRSRAN_ERROR; } - srslte_dft_plan_set_mirror(&plan, true); - srslte_dft_plan_set_dc(&plan, false); - srslte_dft_plan_set_norm(&plan, true); + srsran_dft_plan_set_mirror(&plan, true); + srsran_dft_plan_set_dc(&plan, false); + srsran_dft_plan_set_norm(&plan, true); // one symbol at a time cf_t* output = npss_signal_time; int output_len = 0; - for (int i = 0; i < SRSLTE_NPSS_NUM_OFDM_SYMS; i++) { + for (int i = 0; i < SRSRAN_NPSS_NUM_OFDM_SYMS; i++) { // zero buffer, copy NPSS symbol to appr. pos and transform to time-domain memset(npss_signal_pad, 0, fft_size * sizeof(cf_t)); // 5th NPSS symbol has CP length of 10 symbols - int cp_len = (i != 4) ? SRSLTE_CP_LEN_NORM(1, SRSLTE_NBIOT_FFT_SIZE) : SRSLTE_CP_LEN_NORM(0, SRSLTE_NBIOT_FFT_SIZE); - int k = (fft_size - SRSLTE_NRE) / 2; // place NPSS in the centre + int cp_len = (i != 4) ? SRSRAN_CP_LEN_NORM(1, SRSRAN_NBIOT_FFT_SIZE) : SRSRAN_CP_LEN_NORM(0, SRSRAN_NBIOT_FFT_SIZE); + int k = (fft_size - SRSRAN_NRE) / 2; // place NPSS in the centre - memcpy(&npss_signal_pad[k], &npss_signal[i * SRSLTE_NPSS_LEN], SRSLTE_NPSS_LEN * sizeof(cf_t)); - srslte_dft_run_c(&plan, npss_signal_pad, &output[cp_len]); + memcpy(&npss_signal_pad[k], &npss_signal[i * SRSRAN_NPSS_LEN], SRSRAN_NPSS_LEN * sizeof(cf_t)); + srsran_dft_run_c(&plan, npss_signal_pad, &output[cp_len]); // add CP memcpy(output, &output[fft_size], cp_len * sizeof(cf_t)); @@ -204,41 +204,41 @@ int srslte_npss_corr_init(cf_t* npss_signal_time, const uint32_t fft_size, const output_len += fft_size + cp_len; } - assert(output_len == SRSLTE_NPSS_CORR_FILTER_LEN); + assert(output_len == SRSRAN_NPSS_CORR_FILTER_LEN); #if DO_FREQ_SHIFT // shift entire signal in frequency domain by half a subcarrier - cf_t shift_buffer[SRSLTE_SF_LEN(fft_size)]; + cf_t shift_buffer[SRSRAN_SF_LEN(fft_size)]; cf_t* ptr = shift_buffer; for (uint32_t n = 0; n < 2; n++) { for (uint32_t i = 0; i < 7; i++) { - uint32_t cplen = SRSLTE_CP_LEN_NORM(i, fft_size); + uint32_t cplen = SRSRAN_CP_LEN_NORM(i, fft_size); for (uint32_t t = 0; t < fft_size + cplen; t++) { - ptr[t] = cexpf(I * 2 * M_PI * ((float)t - (float)cplen) * -SRSLTE_NBIOT_FREQ_SHIFT_FACTOR / fft_size); + ptr[t] = cexpf(I * 2 * M_PI * ((float)t - (float)cplen) * -SRSRAN_NBIOT_FREQ_SHIFT_FACTOR / fft_size); } ptr += fft_size + cplen; } } - srslte_vec_prod_ccc( - npss_signal_time, &shift_buffer[SRSLTE_NPSS_CORR_OFFSET], npss_signal_time, SRSLTE_NPSS_CORR_FILTER_LEN); - srslte_vec_sc_prod_cfc(npss_signal_time, 1.0 / 3, npss_signal_time, output_len); + srsran_vec_prod_ccc( + npss_signal_time, &shift_buffer[SRSRAN_NPSS_CORR_OFFSET], npss_signal_time, SRSRAN_NPSS_CORR_FILTER_LEN); + srsran_vec_sc_prod_cfc(npss_signal_time, 1.0 / 3, npss_signal_time, output_len); #endif - srslte_dft_plan_free(&plan); + srsran_dft_plan_free(&plan); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } /** Performs time-domain NPSS correlation. * Returns the index of the NPSS correlation peak in a subframe. - * The frame starts at corr_peak_pos-SRSLTE_NPSS_CORR_OFFSET+frame_size/2. + * The frame starts at corr_peak_pos-SRSRAN_NPSS_CORR_OFFSET+frame_size/2. * The value of the correlation is stored in corr_peak_value. * * Input buffer must be subframe_size long. */ -int srslte_npss_sync_find(srslte_npss_synch_t* q, cf_t* input, float* corr_peak_value) +int srsran_npss_sync_find(srsran_npss_synch_t* q, cf_t* input, float* corr_peak_value) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL && input != NULL) { uint32_t corr_peak_pos; @@ -248,48 +248,48 @@ int srslte_npss_sync_find(srslte_npss_synch_t* q, cf_t* input, float* corr_peak_ if (q->frame_size >= q->fft_size) { #ifdef CONVOLUTION_FFT memcpy(q->tmp_input, input, q->frame_size * sizeof(cf_t)); - conv_output_len = srslte_corr_fft_cc_run_opt(&q->conv_fft, q->tmp_input, q->npss_signal_time, q->conv_output); + conv_output_len = srsran_corr_fft_cc_run_opt(&q->conv_fft, q->tmp_input, q->npss_signal_time, q->conv_output); #else conv_output_len = - srslte_conv_cc(input, q->pss_signal_time[q->N_id_2], q->conv_output, q->frame_size, q->fft_size); + srsran_conv_cc(input, q->pss_signal_time[q->N_id_2], q->conv_output, q->frame_size, q->fft_size); #endif } else { for (int i = 0; i < q->frame_size; i++) { - q->conv_output[i] = srslte_vec_dot_prod_ccc(q->npss_signal_time, &input[i], q->fft_size); + q->conv_output[i] = srsran_vec_dot_prod_ccc(q->npss_signal_time, &input[i], q->fft_size); } conv_output_len = q->frame_size; } -#ifdef SRSLTE_NPSS_ABS_SQUARE - srslte_vec_abs_square_cf(q->conv_output, q->conv_output_abs, conv_output_len - 1); +#ifdef SRSRAN_NPSS_ABS_SQUARE + srsran_vec_abs_square_cf(q->conv_output, q->conv_output_abs, conv_output_len - 1); #else - srslte_vec_abs_cf(q->conv_output, q->conv_output_abs, conv_output_len - 1); + srsran_vec_abs_cf(q->conv_output, q->conv_output_abs, conv_output_len - 1); #endif if (q->ema_alpha < 1.0 && q->ema_alpha > 0.0) { - srslte_vec_sc_prod_fff(q->conv_output_abs, q->ema_alpha, q->conv_output_abs, conv_output_len - 1); - srslte_vec_sc_prod_fff(q->conv_output_avg, 1 - q->ema_alpha, q->conv_output_avg, conv_output_len - 1); + srsran_vec_sc_prod_fff(q->conv_output_abs, q->ema_alpha, q->conv_output_abs, conv_output_len - 1); + srsran_vec_sc_prod_fff(q->conv_output_avg, 1 - q->ema_alpha, q->conv_output_avg, conv_output_len - 1); - srslte_vec_sum_fff(q->conv_output_abs, q->conv_output_avg, q->conv_output_avg, conv_output_len - 1); + srsran_vec_sum_fff(q->conv_output_abs, q->conv_output_avg, q->conv_output_avg, conv_output_len - 1); } else { memcpy(q->conv_output_avg, q->conv_output_abs, sizeof(float) * (conv_output_len - 1)); } // Find maximum of the absolute value of the correlation - corr_peak_pos = srslte_vec_max_fi(q->conv_output_avg, conv_output_len - 1); + corr_peak_pos = srsran_vec_max_fi(q->conv_output_avg, conv_output_len - 1); #if DUMP_SIGNALS printf("Dumping debug signals.\n"); - srslte_vec_save_file("npss_find_input.bin", input, q->frame_size * sizeof(cf_t)); - srslte_vec_save_file("npss_corr_seq_time.bin", q->npss_signal_time, SRSLTE_NPSS_CORR_FILTER_LEN * sizeof(cf_t)); - srslte_vec_save_file("npss_find_conv_output_abs.bin", q->conv_output_abs, conv_output_len * sizeof(float)); - srslte_vec_save_file("npss_find_conv_output_avg.bin", q->conv_output_avg, conv_output_len * sizeof(float)); + srsran_vec_save_file("npss_find_input.bin", input, q->frame_size * sizeof(cf_t)); + srsran_vec_save_file("npss_corr_seq_time.bin", q->npss_signal_time, SRSRAN_NPSS_CORR_FILTER_LEN * sizeof(cf_t)); + srsran_vec_save_file("npss_find_conv_output_abs.bin", q->conv_output_abs, conv_output_len * sizeof(float)); + srsran_vec_save_file("npss_find_conv_output_avg.bin", q->conv_output_avg, conv_output_len * sizeof(float)); #endif // save absolute value q->peak_value = q->conv_output_avg[corr_peak_pos]; -#ifdef SRSLTE_NPSS_RETURN_PSR +#ifdef SRSRAN_NPSS_RETURN_PSR // Find second side lobe // Find end of peak lobe to the right @@ -314,9 +314,9 @@ int srslte_npss_sync_find(srslte_npss_synch_t* q, cf_t* input, float* corr_peak_ } int sl_distance_left = pl_lb; - int sl_right = pl_ub + srslte_vec_max_fi(&q->conv_output_avg[pl_ub], sl_distance_right); - int sl_left = srslte_vec_max_fi(q->conv_output_avg, sl_distance_left); - float side_lobe_value = SRSLTE_MAX(q->conv_output_avg[sl_right], q->conv_output_avg[sl_left]); + int sl_right = pl_ub + srsran_vec_max_fi(&q->conv_output_avg[pl_ub], sl_distance_right); + int sl_left = srsran_vec_max_fi(q->conv_output_avg, sl_distance_left); + float side_lobe_value = SRSRAN_MAX(q->conv_output_avg[sl_right], q->conv_output_avg[sl_left]); if (corr_peak_value) { *corr_peak_value = q->conv_output_avg[corr_peak_pos] / side_lobe_value; @@ -343,19 +343,19 @@ int srslte_npss_sync_find(srslte_npss_synch_t* q, cf_t* input, float* corr_peak_ return ret; } -void srslte_npss_synch_set_ema_alpha(srslte_npss_synch_t* q, float alpha) +void srsran_npss_synch_set_ema_alpha(srsran_npss_synch_t* q, float alpha) { q->ema_alpha = alpha; } -void srslte_npss_synch_free(srslte_npss_synch_t* q) +void srsran_npss_synch_free(srsran_npss_synch_t* q) { if (q) { if (q->npss_signal_time) { free(q->npss_signal_time); } #ifdef CONVOLUTION_FFT - srslte_conv_fft_cc_free(&q->conv_fft); + srsran_conv_fft_cc_free(&q->conv_fft); #endif if (q->tmp_input) { free(q->tmp_input); @@ -372,10 +372,10 @@ void srslte_npss_synch_free(srslte_npss_synch_t* q) } } -void srslte_npss_synch_reset(srslte_npss_synch_t* q) +void srsran_npss_synch_reset(srsran_npss_synch_t* q) { if (q->conv_output_avg) { - uint32_t buffer_size = SRSLTE_NPSS_CORR_FILTER_LEN + q->max_frame_size + 1; + uint32_t buffer_size = SRSRAN_NPSS_CORR_FILTER_LEN + q->max_frame_size + 1; memset(q->conv_output_avg, 0, sizeof(float) * buffer_size); } } @@ -384,10 +384,10 @@ void srslte_npss_synch_reset(srslte_npss_synch_t* q) * This function calculates the Zadoff-Chu sequence. * 36.211 13.2.0 section 10.2.7.1.1 * - * It produces SRSLTE_NPSS_LEN * SRSLTE_NPSS_NUM_SC = 11 * 11 = 121 samples. + * It produces SRSRAN_NPSS_LEN * SRSRAN_NPSS_NUM_SC = 11 * 11 = 121 samples. * @param signal Output array. */ -int srslte_npss_generate(cf_t* signal) +int srsran_npss_generate(cf_t* signal) { float arg; const float root_value = 5.0; @@ -397,14 +397,14 @@ int srslte_npss_generate(cf_t* signal) int n = 0; // iterate over symbol indices - for (l = 0; l < SRSLTE_CP_NORM_SF_NSYMB - 3; l++) { + for (l = 0; l < SRSRAN_CP_NORM_SF_NSYMB - 3; l++) { // iterate over subcarriers, leave out last one - for (n = 0; n < SRSLTE_NRE - 1; n++) { + for (n = 0; n < SRSRAN_NRE - 1; n++) { arg = (float)sign * M_PI * root_value * ((float)n * ((float)n + 1.0)) / 11.0; - __real__ signal[l * SRSLTE_NPSS_LEN + n] = cosf(arg); - __imag__ signal[l * SRSLTE_NPSS_LEN + n] = sinf(arg); + __real__ signal[l * SRSRAN_NPSS_LEN + n] = cosf(arg); + __imag__ signal[l * SRSRAN_NPSS_LEN + n] = sinf(arg); - signal[l * SRSLTE_NPSS_LEN + n] *= factor_lut[l]; + signal[l * SRSRAN_NPSS_LEN + n] *= factor_lut[l]; } } @@ -413,18 +413,18 @@ int srslte_npss_generate(cf_t* signal) /** 36.211 10.3 section 6.11.1.2 */ -void srslte_npss_put_subframe(srslte_npss_synch_t* q, +void srsran_npss_put_subframe(srsran_npss_synch_t* q, cf_t* npss_signal, cf_t* sf, const uint32_t nof_prb, const uint32_t nbiot_prb_offset) { // skip first 3 OFDM symbols over all PRBs completely - uint32_t k = 3 * nof_prb * SRSLTE_NRE + nbiot_prb_offset * SRSLTE_NRE; + uint32_t k = 3 * nof_prb * SRSRAN_NRE + nbiot_prb_offset * SRSRAN_NRE; // put NPSS in each of the 11 symbols of the subframe - for (int l = 0; l < SRSLTE_CP_NORM_SF_NSYMB - 3; l++) { - memcpy(&sf[k + SRSLTE_NPSS_LEN * l], &npss_signal[SRSLTE_NPSS_LEN * l], SRSLTE_NPSS_LEN * sizeof(cf_t)); - k += (nof_prb - 1) * SRSLTE_NRE + 1; // last SC of the PRB is also null + for (int l = 0; l < SRSRAN_CP_NORM_SF_NSYMB - 3; l++) { + memcpy(&sf[k + SRSRAN_NPSS_LEN * l], &npss_signal[SRSRAN_NPSS_LEN * l], SRSRAN_NPSS_LEN * sizeof(cf_t)); + k += (nof_prb - 1) * SRSRAN_NRE + 1; // last SC of the PRB is also null } } diff --git a/lib/src/phy/sync/nsss.c b/lib/src/phy/sync/nsss.c index 7cf3dc2c3..e4a25158d 100644 --- a/lib/src/phy/sync/nsss.c +++ b/lib/src/phy/sync/nsss.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -15,91 +15,91 @@ #include #include -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/sync/nsss.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/sync/nsss.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" #define PRINT_ERR(err) fprintf(stderr, "%s: %s", __PRETTY_FUNCTION__, err) #define DUMP_SIGNALS 0 #define DO_FREQ_SHIFT 1 -#define SRSLTE_NSSS_RETURN_PSR 0 +#define SRSRAN_NSSS_RETURN_PSR 0 -int srslte_nsss_synch_init(srslte_nsss_synch_t* q, uint32_t input_size, uint32_t fft_size) +int srsran_nsss_synch_init(srsran_nsss_synch_t* q, uint32_t input_size, uint32_t fft_size) { if (q != NULL && fft_size <= 2048) { - int ret = SRSLTE_ERROR; - bzero(q, sizeof(srslte_nsss_synch_t)); + int ret = SRSRAN_ERROR; + bzero(q, sizeof(srsran_nsss_synch_t)); q->fft_size = q->max_fft_size = fft_size; q->input_size = input_size; q->corr_peak_threshold = 2.0; - uint32_t buffer_size = SRSLTE_NSSS_CORR_FILTER_LEN + q->input_size + 1; + uint32_t buffer_size = SRSRAN_NSSS_CORR_FILTER_LEN + q->input_size + 1; DEBUG("NSSS buffer size is %d samples.", buffer_size); - q->tmp_input = srslte_vec_cf_malloc(buffer_size); + q->tmp_input = srsran_vec_cf_malloc(buffer_size); if (!q->tmp_input) { fprintf(stderr, "Error allocating memory\n"); goto clean_and_exit; } - srslte_vec_cf_zero(q->tmp_input, buffer_size); + srsran_vec_cf_zero(q->tmp_input, buffer_size); - q->conv_output = srslte_vec_cf_malloc(buffer_size); + q->conv_output = srsran_vec_cf_malloc(buffer_size); if (!q->conv_output) { fprintf(stderr, "Error allocating memory\n"); goto clean_and_exit; } - srslte_vec_cf_zero(q->conv_output, buffer_size); + srsran_vec_cf_zero(q->conv_output, buffer_size); - q->conv_output_abs = srslte_vec_f_malloc(buffer_size); + q->conv_output_abs = srsran_vec_f_malloc(buffer_size); if (!q->conv_output_abs) { fprintf(stderr, "Error allocating memory\n"); goto clean_and_exit; } - srslte_vec_f_zero(q->conv_output_abs, buffer_size); + srsran_vec_f_zero(q->conv_output_abs, buffer_size); - for (int i = 0; i < SRSLTE_NUM_PCI; i++) { - q->nsss_signal_time[i] = srslte_vec_cf_malloc(buffer_size); + for (int i = 0; i < SRSRAN_NUM_PCI; i++) { + q->nsss_signal_time[i] = srsran_vec_cf_malloc(buffer_size); if (!q->nsss_signal_time[i]) { fprintf(stderr, "Error allocating memory\n"); goto clean_and_exit; } - srslte_vec_cf_zero(q->nsss_signal_time[i], buffer_size); + srsran_vec_cf_zero(q->nsss_signal_time[i], buffer_size); } // generate NSSS sequences - if (srslte_nsss_corr_init(q)) { + if (srsran_nsss_corr_init(q)) { fprintf(stderr, "Error initiating NSSS detector for fft_size=%d\n", fft_size); goto clean_and_exit; } - if (srslte_conv_fft_cc_init(&q->conv_fft, q->input_size, SRSLTE_NSSS_CORR_FILTER_LEN)) { + if (srsran_conv_fft_cc_init(&q->conv_fft, q->input_size, SRSRAN_NSSS_CORR_FILTER_LEN)) { fprintf(stderr, "Error initiating convolution FFT\n"); goto clean_and_exit; } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; clean_and_exit: - if (ret == SRSLTE_ERROR) { - srslte_nsss_synch_free(q); + if (ret == SRSRAN_ERROR) { + srsran_nsss_synch_free(q); } return ret; } - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } -void srslte_nsss_synch_free(srslte_nsss_synch_t* q) +void srsran_nsss_synch_free(srsran_nsss_synch_t* q) { if (q) { - for (int i = 0; i < SRSLTE_NUM_PCI; i++) { + for (int i = 0; i < SRSRAN_NUM_PCI; i++) { if (q->nsss_signal_time[i]) { free(q->nsss_signal_time[i]); } } - srslte_conv_fft_cc_free(&q->conv_fft); + srsran_conv_fft_cc_free(&q->conv_fft); if (q->tmp_input) { free(q->tmp_input); } @@ -112,48 +112,48 @@ void srslte_nsss_synch_free(srslte_nsss_synch_t* q) } } -int srslte_nsss_synch_resize(srslte_nsss_synch_t* q, uint32_t fft_size) +int srsran_nsss_synch_resize(srsran_nsss_synch_t* q, uint32_t fft_size) { if (q != NULL && fft_size <= 2048) { if (fft_size > q->max_fft_size) { PRINT_ERR("fft_size must be lower than initialized\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } q->fft_size = fft_size; - if (srslte_nsss_corr_init(q) != SRSLTE_SUCCESS) { + if (srsran_nsss_corr_init(q) != SRSRAN_SUCCESS) { PRINT_ERR("Couldn't initialize NSSS sequence\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } -int srslte_nsss_corr_init(srslte_nsss_synch_t* q) +int srsran_nsss_corr_init(srsran_nsss_synch_t* q) { - srslte_dft_plan_t plan; + srsran_dft_plan_t plan; float complex nsss_signal_pad[q->fft_size]; // construct dft plan - if (srslte_dft_plan(&plan, q->fft_size, SRSLTE_DFT_BACKWARD, SRSLTE_DFT_COMPLEX)) { - return SRSLTE_ERROR; + if (srsran_dft_plan(&plan, q->fft_size, SRSRAN_DFT_BACKWARD, SRSRAN_DFT_COMPLEX)) { + return SRSRAN_ERROR; } - srslte_dft_plan_set_mirror(&plan, true); - srslte_dft_plan_set_dc(&plan, false); - srslte_dft_plan_set_norm(&plan, true); + srsran_dft_plan_set_mirror(&plan, true); + srsran_dft_plan_set_dc(&plan, false); + srsran_dft_plan_set_norm(&plan, true); #if DO_FREQ_SHIFT // shift entire signal in frequency domain by half a subcarrier - cf_t shift_buffer[SRSLTE_SF_LEN(q->fft_size)]; + cf_t shift_buffer[SRSRAN_SF_LEN(q->fft_size)]; cf_t* ptr = shift_buffer; for (uint32_t n = 0; n < 2; n++) { for (uint32_t i = 0; i < 7; i++) { - uint32_t cplen = SRSLTE_CP_LEN_NORM(i, q->fft_size); + uint32_t cplen = SRSRAN_CP_LEN_NORM(i, q->fft_size); for (uint32_t t = 0; t < q->fft_size + cplen; t++) { - ptr[t] = cexpf(I * 2 * M_PI * ((float)t - (float)cplen) * -SRSLTE_NBIOT_FREQ_SHIFT_FACTOR / q->fft_size); + ptr[t] = cexpf(I * 2 * M_PI * ((float)t - (float)cplen) * -SRSRAN_NBIOT_FREQ_SHIFT_FACTOR / q->fft_size); } ptr += q->fft_size + cplen; } @@ -162,29 +162,29 @@ int srslte_nsss_corr_init(srslte_nsss_synch_t* q) // generate correlation sequences DEBUG("Generating NSSS sequences"); - for (int i = 0; i < SRSLTE_NUM_PCI; i++) { - float complex nsss_signal[SRSLTE_NSSS_TOT_LEN] = {}; - srslte_nsss_generate(nsss_signal, i); + for (int i = 0; i < SRSRAN_NUM_PCI; i++) { + float complex nsss_signal[SRSRAN_NSSS_TOT_LEN] = {}; + srsran_nsss_generate(nsss_signal, i); // one symbol at a time cf_t* output = q->nsss_signal_time[i]; int output_len = 0; - for (int i = 0; i < SRSLTE_NSSS_NSYMB; i++) { + for (int i = 0; i < SRSRAN_NSSS_NSYMB; i++) { // zero buffer, copy NSSS symbol to appr. pos and transform to time-domain - srslte_vec_cf_zero(nsss_signal_pad, q->fft_size); + srsran_vec_cf_zero(nsss_signal_pad, q->fft_size); // 5th NSSS symbol has CP length of 10 symbols int cp_len = - (i != 4) ? SRSLTE_CP_LEN_NORM(1, SRSLTE_NBIOT_FFT_SIZE) : SRSLTE_CP_LEN_NORM(0, SRSLTE_NBIOT_FFT_SIZE); - int k = (q->fft_size - SRSLTE_NRE) / 2; // place seq in the centre + (i != 4) ? SRSRAN_CP_LEN_NORM(1, SRSRAN_NBIOT_FFT_SIZE) : SRSRAN_CP_LEN_NORM(0, SRSRAN_NBIOT_FFT_SIZE); + int k = (q->fft_size - SRSRAN_NRE) / 2; // place seq in the centre k = 57; // use generated sequence for theta_f = 0 int theta_f = 0; memcpy(&nsss_signal_pad[k], - &nsss_signal[(theta_f * SRSLTE_NSSS_LEN) + i * SRSLTE_NSSS_NSC], - SRSLTE_NSSS_NSC * sizeof(cf_t)); - srslte_dft_run_c(&plan, nsss_signal_pad, &output[cp_len]); + &nsss_signal[(theta_f * SRSRAN_NSSS_LEN) + i * SRSRAN_NSSS_NSC], + SRSRAN_NSSS_NSC * sizeof(cf_t)); + srsran_dft_run_c(&plan, nsss_signal_pad, &output[cp_len]); // add CP memcpy(output, &output[q->fft_size], cp_len * sizeof(cf_t)); @@ -193,60 +193,60 @@ int srslte_nsss_corr_init(srslte_nsss_synch_t* q) output += q->fft_size + cp_len; output_len += q->fft_size + cp_len; } - assert(output_len == SRSLTE_NSSS_CORR_FILTER_LEN); + assert(output_len == SRSRAN_NSSS_CORR_FILTER_LEN); #if DO_FREQ_SHIFT - srslte_vec_prod_ccc(q->nsss_signal_time[i], - &shift_buffer[SRSLTE_NSSS_CORR_OFFSET], + srsran_vec_prod_ccc(q->nsss_signal_time[i], + &shift_buffer[SRSRAN_NSSS_CORR_OFFSET], q->nsss_signal_time[i], - SRSLTE_NSSS_CORR_FILTER_LEN); - // srslte_vec_sc_prod_cfc(npss_signal_time, 1.0/3, npss_signal_time, output_len); + SRSRAN_NSSS_CORR_FILTER_LEN); + // srsran_vec_sc_prod_cfc(npss_signal_time, 1.0/3, npss_signal_time, output_len); #endif #if DUMP_SIGNALS #define MAX_FNAME_LEN 40 char fname[MAX_FNAME_LEN]; snprintf(fname, MAX_FNAME_LEN, "nsss_corr_seq_time_id%d.bin", i); - srslte_vec_save_file(fname, q->nsss_signal_time[i], SRSLTE_NSSS_CORR_FILTER_LEN * sizeof(cf_t)); + srsran_vec_save_file(fname, q->nsss_signal_time[i], SRSRAN_NSSS_CORR_FILTER_LEN * sizeof(cf_t)); snprintf(fname, MAX_FNAME_LEN, "nsss_corr_seq_freq_id%d.bin", i); - srslte_vec_save_file(fname, nsss_signal, SRSLTE_NSSS_TOT_LEN * sizeof(cf_t)); + srsran_vec_save_file(fname, nsss_signal, SRSRAN_NSSS_TOT_LEN * sizeof(cf_t)); #endif } - srslte_dft_plan_free(&plan); - return SRSLTE_SUCCESS; + srsran_dft_plan_free(&plan); + return SRSRAN_SUCCESS; } -int srslte_nsss_sync_find(srslte_nsss_synch_t* q, +int srsran_nsss_sync_find(srsran_nsss_synch_t* q, cf_t* input, float* corr_peak_value, uint32_t* cell_id, uint32_t* sfn_partial) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL && input != NULL && corr_peak_value != NULL && cell_id != NULL && sfn_partial != NULL) { float peak_value; - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; // save input memcpy(q->tmp_input, input, q->input_size * sizeof(cf_t)); - if (*cell_id == SRSLTE_CELL_ID_UNKNOWN) { + if (*cell_id == SRSRAN_CELL_ID_UNKNOWN) { DEBUG("N_id_ncell is not set. Perform exhaustive search on input."); // brute-force: correlate with all possible sequences until cell is found - for (int i = 0; i < SRSLTE_NUM_PCI; i++) { - srslte_nsss_sync_find_pci(q, q->tmp_input, i); + for (int i = 0; i < SRSRAN_NUM_PCI; i++) { + srsran_nsss_sync_find_pci(q, q->tmp_input, i); } // find maximum of all correlation maxima - uint32_t max_id = srslte_vec_max_fi(q->peak_values, SRSLTE_NUM_PCI); + uint32_t max_id = srsran_vec_max_fi(q->peak_values, SRSRAN_NUM_PCI); if (q->peak_values[max_id] > q->corr_peak_threshold) { // cell found, set return values *cell_id = max_id; - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } peak_value = q->peak_values[max_id]; @@ -254,10 +254,10 @@ int srslte_nsss_sync_find(srslte_nsss_synch_t* q, DEBUG("Current N_id_ncell is %d.", *cell_id); // run correlation only for given id - srslte_nsss_sync_find_pci(q, q->tmp_input, *cell_id); + srsran_nsss_sync_find_pci(q, q->tmp_input, *cell_id); if (q->peak_values[*cell_id] > q->corr_peak_threshold) { - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } peak_value = q->peak_values[*cell_id]; } @@ -274,23 +274,23 @@ int srslte_nsss_sync_find(srslte_nsss_synch_t* q, } // Correlates input signal with the NSSS sequence for a given n_id_ncell -void srslte_nsss_sync_find_pci(srslte_nsss_synch_t* q, cf_t* input, uint32_t cell_id) +void srsran_nsss_sync_find_pci(srsran_nsss_synch_t* q, cf_t* input, uint32_t cell_id) { // correlate input with NSSS sequences - uint32_t conv_output_len = srslte_corr_fft_cc_run(&q->conv_fft, input, q->nsss_signal_time[cell_id], q->conv_output); - srslte_vec_abs_cf(q->conv_output, q->conv_output_abs, conv_output_len - 1); + uint32_t conv_output_len = srsran_corr_fft_cc_run(&q->conv_fft, input, q->nsss_signal_time[cell_id], q->conv_output); + srsran_vec_abs_cf(q->conv_output, q->conv_output_abs, conv_output_len - 1); // Find maximum of the absolute value of the correlation - uint32_t corr_peak_pos = srslte_vec_max_fi(q->conv_output_abs, conv_output_len - 1); + uint32_t corr_peak_pos = srsran_vec_max_fi(q->conv_output_abs, conv_output_len - 1); #if DUMP_SIGNALS printf("Dumping debug signals for cell-id %d.\n", i); - srslte_vec_save_file("nsss_find_input.bin", input, q->input_size * sizeof(cf_t)); - srslte_vec_save_file("nsss_corr_seq_time.bin", q->nsss_signal_time[i], SRSLTE_NSSS_CORR_FILTER_LEN * sizeof(cf_t)); - srslte_vec_save_file("nsss_find_conv_output_abs.bin", q->conv_output_abs, conv_output_len * sizeof(float)); + srsran_vec_save_file("nsss_find_input.bin", input, q->input_size * sizeof(cf_t)); + srsran_vec_save_file("nsss_corr_seq_time.bin", q->nsss_signal_time[i], SRSRAN_NSSS_CORR_FILTER_LEN * sizeof(cf_t)); + srsran_vec_save_file("nsss_find_conv_output_abs.bin", q->conv_output_abs, conv_output_len * sizeof(float)); #endif -#if SRSLTE_NSSS_RETURN_PSR +#if SRSRAN_NSSS_RETURN_PSR // Find second side lobe // Find end of peak lobe to the right @@ -315,9 +315,9 @@ void srslte_nsss_sync_find_pci(srslte_nsss_synch_t* q, cf_t* input, uint32_t cel } int sl_distance_left = pl_lb; - int sl_right = pl_ub + srslte_vec_max_fi(&q->conv_output_abs[pl_ub], sl_distance_right); - int sl_left = srslte_vec_max_fi(q->conv_output_abs, sl_distance_left); - float side_lobe_value = SRSLTE_MAX(q->conv_output_abs[sl_right], q->conv_output_abs[sl_left]); + int sl_right = pl_ub + srsran_vec_max_fi(&q->conv_output_abs[pl_ub], sl_distance_right); + int sl_left = srsran_vec_max_fi(q->conv_output_abs, sl_distance_left); + float side_lobe_value = SRSRAN_MAX(q->conv_output_abs[sl_right], q->conv_output_abs[sl_left]); q->peak_values[cell_id] = q->conv_output_abs[corr_peak_pos] / side_lobe_value; DEBUG("NSSS n_id_ncell=%d at peak_pos=%2d, pl_ub=%2d, pl_lb=%2d, sl_right: %2d, sl_left: %2d, PSR: %.2f/%.2f=%.2f", cell_id, @@ -338,16 +338,16 @@ void srslte_nsss_sync_find_pci(srslte_nsss_synch_t* q, cf_t* input, uint32_t cel // generate the NSSS signal for each of 4 different cyclic shifts // return 4 * 132 = 528 complex samples -void srslte_nsss_generate(cf_t* signal, uint32_t cell_id) +void srsran_nsss_generate(cf_t* signal, uint32_t cell_id) { - if (srslte_cellid_isvalid(cell_id)) { + if (srsran_cellid_isvalid(cell_id)) { int u = cell_id % 126 + 3; int q = floor(cell_id / 126.0); int sign = -1; // iterate over all possible cyclic shifts - for (int theta_f = 0; theta_f < SRSLTE_NSSS_NUM_SEQ; theta_f++) { - for (int n = 0; n < SRSLTE_NSSS_LEN; n++) { + for (int theta_f = 0; theta_f < SRSRAN_NSSS_NUM_SEQ; theta_f++) { + for (int n = 0; n < SRSRAN_NSSS_LEN; n++) { int n_prime = n % 131; int m = n % 128; @@ -361,7 +361,7 @@ void srslte_nsss_generate(cf_t* signal, uint32_t cell_id) __real__ tmp2 = cosf(arg); __imag__ tmp2 = sinf(arg); - signal[theta_f * SRSLTE_NSSS_LEN + n] = b_q_m[q][m] * tmp1 * tmp2; + signal[theta_f * SRSRAN_NSSS_LEN + n] = b_q_m[q][m] * tmp1 * tmp2; } } } else { @@ -369,23 +369,23 @@ void srslte_nsss_generate(cf_t* signal, uint32_t cell_id) } } -void srslte_nsss_put_subframe(srslte_nsss_synch_t* q, +void srsran_nsss_put_subframe(srsran_nsss_synch_t* q, cf_t* nsss, cf_t* subframe, const int nf, const uint32_t nof_prb, const uint32_t nbiot_prb_offset) { - int theta_f = (int)floor(33 / 132.0 * (nf / 2.0)) % SRSLTE_NSSS_NUM_SEQ; + int theta_f = (int)floor(33 / 132.0 * (nf / 2.0)) % SRSRAN_NSSS_NUM_SEQ; // skip first 3 OFDM symbols over all PRBs completely - int k = 3 * nof_prb * SRSLTE_NRE + nbiot_prb_offset * SRSLTE_NRE; + int k = 3 * nof_prb * SRSRAN_NRE + nbiot_prb_offset * SRSRAN_NRE; DEBUG("%d.9: Putting NSSS with theta_f=%d", nf, theta_f); - for (int l = 0; l < SRSLTE_CP_NORM_SF_NSYMB - 3; l++) { - memcpy(&subframe[k + SRSLTE_NSSS_NSC * l], - &nsss[(theta_f * SRSLTE_NSSS_LEN) + (l * SRSLTE_NSSS_NSC)], - SRSLTE_NSSS_NSC * sizeof(cf_t)); - k += (nof_prb - 1) * SRSLTE_NRE; + for (int l = 0; l < SRSRAN_CP_NORM_SF_NSYMB - 3; l++) { + memcpy(&subframe[k + SRSRAN_NSSS_NSC * l], + &nsss[(theta_f * SRSRAN_NSSS_LEN) + (l * SRSRAN_NSSS_NSC)], + SRSRAN_NSSS_NSC * sizeof(cf_t)); + k += (nof_prb - 1) * SRSRAN_NRE; } } diff --git a/lib/src/phy/sync/pss.c b/lib/src/phy/sync/pss.c index 6d88cd99c..6dfc5b9d0 100644 --- a/lib/src/phy/sync/pss.c +++ b/lib/src/phy/sync/pss.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -16,57 +16,57 @@ #include #include -#include "srslte/phy/sync/pss.h" -#include "srslte/phy/utils/debug.h" +#include "srsran/phy/sync/pss.h" +#include "srsran/phy/utils/debug.h" -int srslte_pss_init_N_id_2(cf_t* pss_signal_freq, cf_t* pss_signal_time, uint32_t N_id_2, uint32_t fft_size, int cfo_i) +int srsran_pss_init_N_id_2(cf_t* pss_signal_freq, cf_t* pss_signal_time, uint32_t N_id_2, uint32_t fft_size, int cfo_i) { - srslte_dft_plan_t plan; + srsran_dft_plan_t plan; cf_t pss_signal_pad[2048]; - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; - if (srslte_N_id_2_isvalid(N_id_2) && fft_size <= 2048) { - srslte_pss_generate(pss_signal_freq, N_id_2); + if (srsran_N_id_2_isvalid(N_id_2) && fft_size <= 2048) { + srsran_pss_generate(pss_signal_freq, N_id_2); - srslte_vec_cf_zero(pss_signal_pad, fft_size); - srslte_vec_cf_zero(pss_signal_time, fft_size); - memcpy(&pss_signal_pad[(fft_size - SRSLTE_PSS_LEN) / 2 + cfo_i], pss_signal_freq, SRSLTE_PSS_LEN * sizeof(cf_t)); + srsran_vec_cf_zero(pss_signal_pad, fft_size); + srsran_vec_cf_zero(pss_signal_time, fft_size); + memcpy(&pss_signal_pad[(fft_size - SRSRAN_PSS_LEN) / 2 + cfo_i], pss_signal_freq, SRSRAN_PSS_LEN * sizeof(cf_t)); /* Convert signal into the time domain */ - if (srslte_dft_plan(&plan, fft_size, SRSLTE_DFT_BACKWARD, SRSLTE_DFT_COMPLEX)) { - return SRSLTE_ERROR; + if (srsran_dft_plan(&plan, fft_size, SRSRAN_DFT_BACKWARD, SRSRAN_DFT_COMPLEX)) { + return SRSRAN_ERROR; } - srslte_dft_plan_set_mirror(&plan, true); - srslte_dft_plan_set_dc(&plan, true); - srslte_dft_plan_set_norm(&plan, true); - srslte_dft_run_c(&plan, pss_signal_pad, pss_signal_time); + srsran_dft_plan_set_mirror(&plan, true); + srsran_dft_plan_set_dc(&plan, true); + srsran_dft_plan_set_norm(&plan, true); + srsran_dft_run_c(&plan, pss_signal_pad, pss_signal_time); - srslte_vec_conj_cc(pss_signal_time, pss_signal_time, fft_size); - srslte_vec_sc_prod_cfc(pss_signal_time, 1.0 / SRSLTE_PSS_LEN, pss_signal_time, fft_size); + srsran_vec_conj_cc(pss_signal_time, pss_signal_time, fft_size); + srsran_vec_sc_prod_cfc(pss_signal_time, 1.0 / SRSRAN_PSS_LEN, pss_signal_time, fft_size); - srslte_dft_plan_free(&plan); + srsran_dft_plan_free(&plan); - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } /* Initializes the PSS synchronization object with fft_size=128 */ -int srslte_pss_init(srslte_pss_t* q, uint32_t frame_size) +int srsran_pss_init(srsran_pss_t* q, uint32_t frame_size) { - return srslte_pss_init_fft(q, frame_size, 128); + return srsran_pss_init_fft(q, frame_size, 128); } -int srslte_pss_init_fft(srslte_pss_t* q, uint32_t frame_size, uint32_t fft_size) +int srsran_pss_init_fft(srsran_pss_t* q, uint32_t frame_size, uint32_t fft_size) { - return srslte_pss_init_fft_offset(q, frame_size, fft_size, 0); + return srsran_pss_init_fft_offset(q, frame_size, fft_size, 0); } -int srslte_pss_init_fft_offset(srslte_pss_t* q, uint32_t frame_size, uint32_t fft_size, int offset) +int srsran_pss_init_fft_offset(srsran_pss_t* q, uint32_t frame_size, uint32_t fft_size, int offset) { - return srslte_pss_init_fft_offset_decim(q, frame_size, fft_size, offset, 1); + return srsran_pss_init_fft_offset_decim(q, frame_size, fft_size, offset, 1); } /* Initializes the PSS synchronization object. @@ -74,19 +74,19 @@ int srslte_pss_init_fft_offset(srslte_pss_t* q, uint32_t frame_size, uint32_t ff * It correlates a signal of frame_size samples with the PSS sequence in the frequency * domain. The PSS sequence is transformed using fft_size samples. */ -int srslte_pss_init_fft_offset_decim(srslte_pss_t* q, +int srsran_pss_init_fft_offset_decim(srsran_pss_t* q, uint32_t max_frame_size, uint32_t max_fft_size, int offset, int decimate) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL) { - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; uint32_t N_id_2; uint32_t buffer_size; - bzero(q, sizeof(srslte_pss_t)); + bzero(q, sizeof(srsran_pss_t)); q->N_id_2 = 10; q->ema_alpha = 0.2; @@ -108,93 +108,93 @@ int srslte_pss_init_fft_offset_decim(srslte_pss_t* q, if (q->decimate > 1) { int filter_order = 3; - srslte_filt_decim_cc_init(&q->filter, q->decimate, filter_order); - q->filter.filter_output = srslte_vec_cf_malloc(buffer_size); - q->filter.downsampled_input = srslte_vec_cf_malloc(buffer_size + filter_order); + srsran_filt_decim_cc_init(&q->filter, q->decimate, filter_order); + q->filter.filter_output = srsran_vec_cf_malloc(buffer_size); + q->filter.downsampled_input = srsran_vec_cf_malloc(buffer_size + filter_order); printf("decimation for the PSS search is %d \n", q->decimate); } - if (srslte_dft_plan(&q->dftp_input, fft_size, SRSLTE_DFT_FORWARD, SRSLTE_DFT_COMPLEX)) { + if (srsran_dft_plan(&q->dftp_input, fft_size, SRSRAN_DFT_FORWARD, SRSRAN_DFT_COMPLEX)) { ERROR("Error creating DFT plan "); goto clean_and_exit; } - srslte_dft_plan_set_mirror(&q->dftp_input, true); - srslte_dft_plan_set_dc(&q->dftp_input, true); - srslte_dft_plan_set_norm(&q->dftp_input, false); + srsran_dft_plan_set_mirror(&q->dftp_input, true); + srsran_dft_plan_set_dc(&q->dftp_input, true); + srsran_dft_plan_set_norm(&q->dftp_input, false); - if (srslte_dft_plan(&q->idftp_input, fft_size, SRSLTE_DFT_BACKWARD, SRSLTE_DFT_COMPLEX)) { + if (srsran_dft_plan(&q->idftp_input, fft_size, SRSRAN_DFT_BACKWARD, SRSRAN_DFT_COMPLEX)) { ERROR("Error creating DFT plan "); goto clean_and_exit; } - srslte_dft_plan_set_mirror(&q->idftp_input, true); - srslte_dft_plan_set_dc(&q->idftp_input, true); - srslte_dft_plan_set_norm(&q->idftp_input, false); + srsran_dft_plan_set_mirror(&q->idftp_input, true); + srsran_dft_plan_set_dc(&q->idftp_input, true); + srsran_dft_plan_set_norm(&q->idftp_input, false); - srslte_vec_cf_zero(q->tmp_fft2, SRSLTE_SYMBOL_SZ_MAX); + srsran_vec_cf_zero(q->tmp_fft2, SRSRAN_SYMBOL_SZ_MAX); - q->tmp_input = srslte_vec_cf_malloc(buffer_size + frame_size * (q->decimate - 1)); + q->tmp_input = srsran_vec_cf_malloc(buffer_size + frame_size * (q->decimate - 1)); if (!q->tmp_input) { ERROR("Error allocating memory"); goto clean_and_exit; } - srslte_vec_cf_zero(&q->tmp_input[q->frame_size], q->fft_size); + srsran_vec_cf_zero(&q->tmp_input[q->frame_size], q->fft_size); - q->conv_output = srslte_vec_cf_malloc(buffer_size); + q->conv_output = srsran_vec_cf_malloc(buffer_size); if (!q->conv_output) { ERROR("Error allocating memory"); goto clean_and_exit; } - srslte_vec_cf_zero(q->conv_output, buffer_size); - q->conv_output_avg = srslte_vec_f_malloc(buffer_size); + srsran_vec_cf_zero(q->conv_output, buffer_size); + q->conv_output_avg = srsran_vec_f_malloc(buffer_size); if (!q->conv_output_avg) { ERROR("Error allocating memory"); goto clean_and_exit; } - srslte_vec_f_zero(q->conv_output_avg, buffer_size); -#ifdef SRSLTE_PSS_ACCUMULATE_ABS - q->conv_output_abs = srslte_vec_f_malloc(buffer_size); + srsran_vec_f_zero(q->conv_output_avg, buffer_size); +#ifdef SRSRAN_PSS_ACCUMULATE_ABS + q->conv_output_abs = srsran_vec_f_malloc(buffer_size); if (!q->conv_output_abs) { ERROR("Error allocating memory"); goto clean_and_exit; } - srslte_vec_f_zero(q->conv_output_abs, buffer_size); + srsran_vec_f_zero(q->conv_output_abs, buffer_size); #endif for (N_id_2 = 0; N_id_2 < 3; N_id_2++) { - q->pss_signal_time[N_id_2] = srslte_vec_cf_malloc(buffer_size); + q->pss_signal_time[N_id_2] = srsran_vec_cf_malloc(buffer_size); if (!q->pss_signal_time[N_id_2]) { ERROR("Error allocating memory"); goto clean_and_exit; } /* The PSS is translated into the time domain for each N_id_2 */ - if (srslte_pss_init_N_id_2(q->pss_signal_freq[N_id_2], q->pss_signal_time[N_id_2], N_id_2, fft_size, offset)) { + if (srsran_pss_init_N_id_2(q->pss_signal_freq[N_id_2], q->pss_signal_time[N_id_2], N_id_2, fft_size, offset)) { ERROR("Error initiating PSS detector for N_id_2=%d fft_size=%d", N_id_2, fft_size); goto clean_and_exit; } - srslte_vec_cf_zero(&q->pss_signal_time[N_id_2][q->fft_size], q->frame_size); + srsran_vec_cf_zero(&q->pss_signal_time[N_id_2][q->fft_size], q->frame_size); } #ifdef CONVOLUTION_FFT - if (srslte_conv_fft_cc_init(&q->conv_fft, frame_size, fft_size)) { + if (srsran_conv_fft_cc_init(&q->conv_fft, frame_size, fft_size)) { ERROR("Error initiating convolution FFT"); goto clean_and_exit; } for (N_id_2 = 0; N_id_2 < 3; N_id_2++) { - q->pss_signal_freq_full[N_id_2] = srslte_vec_cf_malloc(buffer_size); - srslte_dft_run_c(&q->conv_fft.filter_plan, q->pss_signal_time[N_id_2], q->pss_signal_freq_full[N_id_2]); + q->pss_signal_freq_full[N_id_2] = srsran_vec_cf_malloc(buffer_size); + srsran_dft_run_c(&q->conv_fft.filter_plan, q->pss_signal_time[N_id_2], q->pss_signal_freq_full[N_id_2]); } #endif - srslte_pss_reset(q); + srsran_pss_reset(q); - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } clean_and_exit: - if (ret == SRSLTE_ERROR) { - srslte_pss_free(q); + if (ret == SRSRAN_ERROR) { + srsran_pss_free(q); } return ret; } @@ -204,15 +204,15 @@ clean_and_exit: * It correlates a signal of frame_size samples with the PSS sequence in the frequency * domain. The PSS sequence is transformed using fft_size samples. */ -int srslte_pss_resize(srslte_pss_t* q, uint32_t frame_size, uint32_t fft_size, int offset) +int srsran_pss_resize(srsran_pss_t* q, uint32_t frame_size, uint32_t fft_size, int offset) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL) { - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; if (fft_size > q->max_fft_size || frame_size > q->max_frame_size) { ERROR("Error in pss_config(): fft_size and frame_size must be lower than initialized"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } uint32_t N_id_2; @@ -229,54 +229,54 @@ int srslte_pss_resize(srslte_pss_t* q, uint32_t frame_size, uint32_t fft_size, i buffer_size = fft_size + frame_size + 1; - if (srslte_dft_replan(&q->dftp_input, fft_size)) { + if (srsran_dft_replan(&q->dftp_input, fft_size)) { ERROR("Error creating DFT plan "); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_dft_replan(&q->idftp_input, fft_size)) { + if (srsran_dft_replan(&q->idftp_input, fft_size)) { ERROR("Error creating DFT plan "); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - srslte_vec_cf_zero(q->tmp_fft2, SRSLTE_SYMBOL_SZ_MAX); + srsran_vec_cf_zero(q->tmp_fft2, SRSRAN_SYMBOL_SZ_MAX); - srslte_vec_cf_zero(&q->tmp_input[q->frame_size], q->fft_size); - srslte_vec_cf_zero(q->conv_output, buffer_size); - srslte_vec_f_zero(q->conv_output_avg, buffer_size); + srsran_vec_cf_zero(&q->tmp_input[q->frame_size], q->fft_size); + srsran_vec_cf_zero(q->conv_output, buffer_size); + srsran_vec_f_zero(q->conv_output_avg, buffer_size); -#ifdef SRSLTE_PSS_ACCUMULATE_ABS - srslte_vec_f_zero(q->conv_output_abs, buffer_size); +#ifdef SRSRAN_PSS_ACCUMULATE_ABS + srsran_vec_f_zero(q->conv_output_abs, buffer_size); #endif // Generate PSS sequences for this FFT size for (N_id_2 = 0; N_id_2 < 3; N_id_2++) { - if (srslte_pss_init_N_id_2(q->pss_signal_freq[N_id_2], q->pss_signal_time[N_id_2], N_id_2, fft_size, offset)) { + if (srsran_pss_init_N_id_2(q->pss_signal_freq[N_id_2], q->pss_signal_time[N_id_2], N_id_2, fft_size, offset)) { ERROR("Error initiating PSS detector for N_id_2=%d fft_size=%d", N_id_2, fft_size); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - srslte_vec_cf_zero(&q->pss_signal_time[N_id_2][q->fft_size], q->frame_size); + srsran_vec_cf_zero(&q->pss_signal_time[N_id_2][q->fft_size], q->frame_size); } #ifdef CONVOLUTION_FFT - if (srslte_conv_fft_cc_replan(&q->conv_fft, frame_size, fft_size)) { + if (srsran_conv_fft_cc_replan(&q->conv_fft, frame_size, fft_size)) { ERROR("Error initiating convolution FFT"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } for (int i = 0; i < 3; i++) { - srslte_dft_run_c(&q->conv_fft.filter_plan, q->pss_signal_time[i], q->pss_signal_freq_full[i]); + srsran_dft_run_c(&q->conv_fft.filter_plan, q->pss_signal_time[i], q->pss_signal_freq_full[i]); } #endif - srslte_pss_reset(q); + srsran_pss_reset(q); - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } -void srslte_pss_free(srslte_pss_t* q) +void srsran_pss_free(srsran_pss_t* q) { uint32_t i; @@ -290,7 +290,7 @@ void srslte_pss_free(srslte_pss_t* q) } } #ifdef CONVOLUTION_FFT - srslte_conv_fft_cc_free(&q->conv_fft); + srsran_conv_fft_cc_free(&q->conv_fft); #endif if (q->tmp_input) { @@ -306,30 +306,30 @@ void srslte_pss_free(srslte_pss_t* q) free(q->conv_output_avg); } - srslte_dft_plan_free(&q->dftp_input); - srslte_dft_plan_free(&q->idftp_input); + srsran_dft_plan_free(&q->dftp_input); + srsran_dft_plan_free(&q->idftp_input); if (q->decimate > 1) { - srslte_filt_decim_cc_free(&q->filter); + srsran_filt_decim_cc_free(&q->filter); free(q->filter.filter_output); free(q->filter.downsampled_input); } - bzero(q, sizeof(srslte_pss_t)); + bzero(q, sizeof(srsran_pss_t)); } } -void srslte_pss_reset(srslte_pss_t* q) +void srsran_pss_reset(srsran_pss_t* q) { uint32_t buffer_size = q->fft_size + q->frame_size + 1; - srslte_vec_f_zero(q->conv_output_avg, buffer_size); + srsran_vec_f_zero(q->conv_output_avg, buffer_size); } /** * This function calculates the Zadoff-Chu sequence. * @param signal Output array. */ -int srslte_pss_generate(cf_t* signal, uint32_t N_id_2) +int srsran_pss_generate(cf_t* signal, uint32_t N_id_2) { int i; float arg; @@ -345,12 +345,12 @@ int srslte_pss_generate(cf_t* signal, uint32_t N_id_2) root_idx = N_id_2; - for (i = 0; i < SRSLTE_PSS_LEN / 2; i++) { + for (i = 0; i < SRSRAN_PSS_LEN / 2; i++) { arg = (float)sign * M_PI * root_value[root_idx] * ((float)i * ((float)i + 1.0)) / 63.0; __real__ signal[i] = cosf(arg); __imag__ signal[i] = sinf(arg); } - for (i = SRSLTE_PSS_LEN / 2; i < SRSLTE_PSS_LEN; i++) { + for (i = SRSRAN_PSS_LEN / 2; i < SRSRAN_PSS_LEN; i++) { arg = (float)sign * M_PI * root_value[root_idx] * (((float)i + 2.0) * ((float)i + 1.0)) / 63.0; __real__ signal[i] = cosf(arg); __imag__ signal[i] = sinf(arg); @@ -360,27 +360,27 @@ int srslte_pss_generate(cf_t* signal, uint32_t N_id_2) /** 36.211 10.3 section 6.11.1.2 */ -void srslte_pss_put_slot(cf_t* pss_signal, cf_t* slot, uint32_t nof_prb, srslte_cp_t cp) +void srsran_pss_put_slot(cf_t* pss_signal, cf_t* slot, uint32_t nof_prb, srsran_cp_t cp) { int k; - k = (SRSLTE_CP_NSYMB(cp) - 1) * nof_prb * SRSLTE_NRE + nof_prb * SRSLTE_NRE / 2 - 31; + k = (SRSRAN_CP_NSYMB(cp) - 1) * nof_prb * SRSRAN_NRE + nof_prb * SRSRAN_NRE / 2 - 31; memset(&slot[k - 5], 0, 5 * sizeof(cf_t)); - memcpy(&slot[k], pss_signal, SRSLTE_PSS_LEN * sizeof(cf_t)); - memset(&slot[k + SRSLTE_PSS_LEN], 0, 5 * sizeof(cf_t)); + memcpy(&slot[k], pss_signal, SRSRAN_PSS_LEN * sizeof(cf_t)); + memset(&slot[k + SRSRAN_PSS_LEN], 0, 5 * sizeof(cf_t)); } -void srslte_pss_get_slot(cf_t* slot, cf_t* pss_signal, uint32_t nof_prb, srslte_cp_t cp) +void srsran_pss_get_slot(cf_t* slot, cf_t* pss_signal, uint32_t nof_prb, srsran_cp_t cp) { int k; - k = (SRSLTE_CP_NSYMB(cp) - 1) * nof_prb * SRSLTE_NRE + nof_prb * SRSLTE_NRE / 2 - 31; - memcpy(pss_signal, &slot[k], SRSLTE_PSS_LEN * sizeof(cf_t)); + k = (SRSRAN_CP_NSYMB(cp) - 1) * nof_prb * SRSRAN_NRE + nof_prb * SRSRAN_NRE / 2 - 31; + memcpy(pss_signal, &slot[k], SRSRAN_PSS_LEN * sizeof(cf_t)); } /** Sets the current N_id_2 value. Returns -1 on ERROR(0 otherwise */ -int srslte_pss_set_N_id_2(srslte_pss_t* q, uint32_t N_id_2) +int srsran_pss_set_N_id_2(srsran_pss_t* q, uint32_t N_id_2) { - if (!srslte_N_id_2_isvalid((N_id_2))) { + if (!srsran_N_id_2_isvalid((N_id_2))) { ERROR("Invalid N_id_2 %d", N_id_2); return -1; } else { @@ -391,12 +391,12 @@ int srslte_pss_set_N_id_2(srslte_pss_t* q, uint32_t N_id_2) /* Sets the weight factor alpha for the exponential moving average of the PSS correlation output */ -void srslte_pss_set_ema_alpha(srslte_pss_t* q, float alpha) +void srsran_pss_set_ema_alpha(srsran_pss_t* q, float alpha) { q->ema_alpha = alpha; } -float compute_peak_sidelobe(srslte_pss_t* q, uint32_t corr_peak_pos, uint32_t conv_output_len) +float compute_peak_sidelobe(srsran_pss_t* q, uint32_t corr_peak_pos, uint32_t conv_output_len) { // Find end of peak lobe to the right int pl_ub = corr_peak_pos + 1; @@ -420,9 +420,9 @@ float compute_peak_sidelobe(srslte_pss_t* q, uint32_t corr_peak_pos, uint32_t co } int sl_distance_left = pl_lb; - int sl_right = pl_ub + srslte_vec_max_fi(&q->conv_output_avg[pl_ub], sl_distance_right); - int sl_left = srslte_vec_max_fi(q->conv_output_avg, sl_distance_left); - float side_lobe_value = SRSLTE_MAX(q->conv_output_avg[sl_right], q->conv_output_avg[sl_left]); + int sl_right = pl_ub + srsran_vec_max_fi(&q->conv_output_avg[pl_ub], sl_distance_right); + int sl_left = srsran_vec_max_fi(q->conv_output_avg, sl_distance_left); + float side_lobe_value = SRSRAN_MAX(q->conv_output_avg[sl_right], q->conv_output_avg[sl_left]); return q->conv_output_avg[corr_peak_pos] / side_lobe_value; } @@ -434,72 +434,72 @@ float compute_peak_sidelobe(srslte_pss_t* q, uint32_t corr_peak_pos, uint32_t co * * Input buffer must be subframe_size long. */ -int srslte_pss_find_pss(srslte_pss_t* q, const cf_t* input, float* corr_peak_value) +int srsran_pss_find_pss(srsran_pss_t* q, const cf_t* input, float* corr_peak_value) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL && input != NULL) { uint32_t corr_peak_pos; uint32_t conv_output_len; - if (!srslte_N_id_2_isvalid(q->N_id_2)) { + if (!srsran_N_id_2_isvalid(q->N_id_2)) { ERROR("Error finding PSS peak, Must set N_id_2 first"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } /* Correlate input with PSS sequence * * We do not reverse time-domain PSS signal because it's conjugate is symmetric. - * The conjugate operation on pss_signal_time has been done in srslte_pss_init_N_id_2 + * The conjugate operation on pss_signal_time has been done in srsran_pss_init_N_id_2 * This is why we can use FFT-based convolution */ if (q->frame_size >= q->fft_size) { #ifdef CONVOLUTION_FFT memcpy(q->tmp_input, input, (q->frame_size * q->decimate) * sizeof(cf_t)); if (q->decimate > 1) { - srslte_filt_decim_cc_execute(&(q->filter), + srsran_filt_decim_cc_execute(&(q->filter), q->tmp_input, q->filter.downsampled_input, q->filter.filter_output, (q->frame_size * q->decimate)); - conv_output_len = srslte_conv_fft_cc_run_opt( + conv_output_len = srsran_conv_fft_cc_run_opt( &q->conv_fft, q->filter.filter_output, q->pss_signal_freq_full[q->N_id_2], q->conv_output); } else { conv_output_len = - srslte_conv_fft_cc_run_opt(&q->conv_fft, q->tmp_input, q->pss_signal_freq_full[q->N_id_2], q->conv_output); + srsran_conv_fft_cc_run_opt(&q->conv_fft, q->tmp_input, q->pss_signal_freq_full[q->N_id_2], q->conv_output); } #else conv_output_len = - srslte_conv_cc(input, q->pss_signal_time[q->N_id_2], q->conv_output, q->frame_size, q->fft_size); + srsran_conv_cc(input, q->pss_signal_time[q->N_id_2], q->conv_output, q->frame_size, q->fft_size); #endif } else { for (int i = 0; i < q->frame_size; i++) { - q->conv_output[i] = srslte_vec_dot_prod_ccc(q->pss_signal_time[q->N_id_2], &input[i], q->fft_size); + q->conv_output[i] = srsran_vec_dot_prod_ccc(q->pss_signal_time[q->N_id_2], &input[i], q->fft_size); } conv_output_len = q->frame_size; } // Compute modulus square - srslte_vec_abs_square_cf(q->conv_output, q->conv_output_abs, conv_output_len - 1); + srsran_vec_abs_square_cf(q->conv_output, q->conv_output_abs, conv_output_len - 1); // If enabled, average the absolute value from previous calls if (q->ema_alpha < 1.0 && q->ema_alpha > 0.0) { - srslte_vec_sc_prod_fff(q->conv_output_abs, q->ema_alpha, q->conv_output_abs, conv_output_len - 1); - srslte_vec_sc_prod_fff(q->conv_output_avg, 1 - q->ema_alpha, q->conv_output_avg, conv_output_len - 1); + srsran_vec_sc_prod_fff(q->conv_output_abs, q->ema_alpha, q->conv_output_abs, conv_output_len - 1); + srsran_vec_sc_prod_fff(q->conv_output_avg, 1 - q->ema_alpha, q->conv_output_avg, conv_output_len - 1); - srslte_vec_sum_fff(q->conv_output_abs, q->conv_output_avg, q->conv_output_avg, conv_output_len - 1); + srsran_vec_sum_fff(q->conv_output_abs, q->conv_output_avg, q->conv_output_avg, conv_output_len - 1); } else { memcpy(q->conv_output_avg, q->conv_output_abs, sizeof(float) * (conv_output_len - 1)); } /* Find maximum of the absolute value of the correlation */ - corr_peak_pos = srslte_vec_max_fi(q->conv_output_avg, conv_output_len - 1); + corr_peak_pos = srsran_vec_max_fi(q->conv_output_avg, conv_output_len - 1); // save absolute value q->peak_value = q->conv_output_avg[corr_peak_pos]; -#ifdef SRSLTE_PSS_RETURN_PSR +#ifdef SRSRAN_PSS_RETURN_PSR if (corr_peak_value) { *corr_peak_value = compute_peak_sidelobe(q, corr_peak_pos, conv_output_len); } @@ -528,67 +528,67 @@ int srslte_pss_find_pss(srslte_pss_t* q, const cf_t* input, float* corr_peak_val * input signal is in the time-domain. * ce is the returned frequency-domain channel estimates. */ -int srslte_pss_chest(srslte_pss_t* q, const cf_t* input, cf_t ce[SRSLTE_PSS_LEN]) +int srsran_pss_chest(srsran_pss_t* q, const cf_t* input, cf_t ce[SRSRAN_PSS_LEN]) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL && input != NULL) { - if (!srslte_N_id_2_isvalid(q->N_id_2)) { + if (!srsran_N_id_2_isvalid(q->N_id_2)) { ERROR("Error finding PSS peak, Must set N_id_2 first"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } /* Transform to frequency-domain */ - srslte_dft_run_c(&q->dftp_input, input, q->tmp_fft); + srsran_dft_run_c(&q->dftp_input, input, q->tmp_fft); /* Compute channel estimate taking the PSS sequence as reference */ - srslte_vec_prod_conj_ccc( - &q->tmp_fft[(q->fft_size - SRSLTE_PSS_LEN) / 2], q->pss_signal_freq[q->N_id_2], ce, SRSLTE_PSS_LEN); + srsran_vec_prod_conj_ccc( + &q->tmp_fft[(q->fft_size - SRSRAN_PSS_LEN) / 2], q->pss_signal_freq[q->N_id_2], ce, SRSRAN_PSS_LEN); - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } /* input points to beginning of last OFDM symbol of slot 0 of subframe 0 or 5 - * It must be called after calling srslte_pss_cfo_compute() with filter enabled + * It must be called after calling srsran_pss_cfo_compute() with filter enabled */ -void srslte_pss_sic(srslte_pss_t* q, cf_t* input) +void srsran_pss_sic(srsran_pss_t* q, cf_t* input) { if (q->chest_on_filter) { - srslte_vec_cf_zero(q->tmp_fft, q->fft_size); + srsran_vec_cf_zero(q->tmp_fft, q->fft_size); // Pass transmitted PSS sequence through the channel - srslte_vec_prod_ccc( - q->pss_signal_freq[q->N_id_2], q->tmp_ce, &q->tmp_fft[(q->fft_size - SRSLTE_PSS_LEN) / 2], SRSLTE_PSS_LEN); + srsran_vec_prod_ccc( + q->pss_signal_freq[q->N_id_2], q->tmp_ce, &q->tmp_fft[(q->fft_size - SRSRAN_PSS_LEN) / 2], SRSRAN_PSS_LEN); // Get time-domain version of the received PSS - srslte_dft_run_c(&q->idftp_input, q->tmp_fft, q->tmp_fft2); + srsran_dft_run_c(&q->idftp_input, q->tmp_fft, q->tmp_fft2); // Substract received PSS from this N_id_2 from the input signal - srslte_vec_sc_prod_cfc(q->tmp_fft2, 1.0 / q->fft_size, q->tmp_fft2, q->fft_size); - srslte_vec_sub_ccc(input, q->tmp_fft2, input, q->fft_size); + srsran_vec_sc_prod_cfc(q->tmp_fft2, 1.0 / q->fft_size, q->tmp_fft2, q->fft_size); + srsran_vec_sub_ccc(input, q->tmp_fft2, input, q->fft_size); } else { - ERROR("Error calling srslte_pss_sic(): need to enable channel estimation on filtering"); + ERROR("Error calling srsran_pss_sic(): need to enable channel estimation on filtering"); } } // Frequency-domain filtering of the central 64 sub-carriers -void srslte_pss_filter(srslte_pss_t* q, const cf_t* input, cf_t* output) +void srsran_pss_filter(srsran_pss_t* q, const cf_t* input, cf_t* output) { - srslte_dft_run_c(&q->dftp_input, input, q->tmp_fft); + srsran_dft_run_c(&q->dftp_input, input, q->tmp_fft); - memcpy(&q->tmp_fft2[q->fft_size / 2 - SRSLTE_PSS_LEN / 2], - &q->tmp_fft[q->fft_size / 2 - SRSLTE_PSS_LEN / 2], - sizeof(cf_t) * SRSLTE_PSS_LEN); + memcpy(&q->tmp_fft2[q->fft_size / 2 - SRSRAN_PSS_LEN / 2], + &q->tmp_fft[q->fft_size / 2 - SRSRAN_PSS_LEN / 2], + sizeof(cf_t) * SRSRAN_PSS_LEN); if (q->chest_on_filter) { - srslte_vec_prod_conj_ccc( - &q->tmp_fft[(q->fft_size - SRSLTE_PSS_LEN) / 2], q->pss_signal_freq[q->N_id_2], q->tmp_ce, SRSLTE_PSS_LEN); + srsran_vec_prod_conj_ccc( + &q->tmp_fft[(q->fft_size - SRSRAN_PSS_LEN) / 2], q->pss_signal_freq[q->N_id_2], q->tmp_ce, SRSRAN_PSS_LEN); } - srslte_dft_run_c(&q->idftp_input, q->tmp_fft2, output); + srsran_dft_run_c(&q->idftp_input, q->tmp_fft2, output); } /* Returns the CFO estimation given a PSS received sequence @@ -596,19 +596,19 @@ void srslte_pss_filter(srslte_pss_t* q, const cf_t* input, cf_t* output) * Source: An Efficient CFO Estimation Algorithm for the Downlink of 3GPP-LTE * Feng Wang and Yu Zhu */ -float srslte_pss_cfo_compute(srslte_pss_t* q, const cf_t* pss_recv) +float srsran_pss_cfo_compute(srsran_pss_t* q, const cf_t* pss_recv) { cf_t y0, y1; const cf_t* pss_ptr = pss_recv; if (q->filter_pss_enable) { - srslte_pss_filter(q, pss_recv, q->tmp_fft); + srsran_pss_filter(q, pss_recv, q->tmp_fft); pss_ptr = (const cf_t*)q->tmp_fft; } - y0 = srslte_vec_dot_prod_ccc(q->pss_signal_time[q->N_id_2], pss_ptr, q->fft_size / 2); - y1 = srslte_vec_dot_prod_ccc( + y0 = srsran_vec_dot_prod_ccc(q->pss_signal_time[q->N_id_2], pss_ptr, q->fft_size / 2); + y1 = srsran_vec_dot_prod_ccc( &q->pss_signal_time[q->N_id_2][q->fft_size / 2], &pss_ptr[q->fft_size / 2], q->fft_size / 2); return cargf(conjf(y0) * y1) / M_PI; } diff --git a/lib/src/phy/sync/psss.c b/lib/src/phy/sync/psss.c index b58ac3d31..52f62e4f1 100644 --- a/lib/src/phy/sync/psss.c +++ b/lib/src/phy/sync/psss.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -15,115 +15,115 @@ #include #include -#include "srslte/phy/sync/psss.h" +#include "srsran/phy/sync/psss.h" -#include "srslte/phy/dft/ofdm.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector_simd.h" -#include +#include "srsran/phy/dft/ofdm.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector_simd.h" +#include // Generates the sidelink sequences that are used to detect PSSS -int srslte_psss_init(srslte_psss_t* q, uint32_t nof_prb, srslte_cp_t cp) +int srsran_psss_init(srsran_psss_t* q, uint32_t nof_prb, srsran_cp_t cp) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL) { // Generate the 2 PSSS sequences for (uint32_t i = 0; i < 2; i++) { - if (srslte_psss_generate(q->psss_signal[i], i) != SRSLTE_SUCCESS) { - ERROR("Error srslte_psss_generate"); - return SRSLTE_ERROR; + if (srsran_psss_generate(q->psss_signal[i], i) != SRSRAN_SUCCESS) { + ERROR("Error srsran_psss_generate"); + return SRSRAN_ERROR; } } /* * Initialization of buffers for find PSSS operations */ - uint32_t sf_n_samples = srslte_symbol_sz(nof_prb) * 15; + uint32_t sf_n_samples = srsran_symbol_sz(nof_prb) * 15; uint32_t fft_size = sf_n_samples * 2; - q->psss_sf_freq = srslte_vec_malloc(sizeof(cf_t*) * 2); + q->psss_sf_freq = srsran_vec_malloc(sizeof(cf_t*) * 2); if (!q->psss_sf_freq) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } for (uint32_t i = 0; i < 2; ++i) { - q->psss_sf_freq[i] = srslte_vec_cf_malloc(fft_size); + q->psss_sf_freq[i] = srsran_vec_cf_malloc(fft_size); if (!q->psss_sf_freq[i]) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } - q->input_pad_freq = srslte_vec_cf_malloc(fft_size); + q->input_pad_freq = srsran_vec_cf_malloc(fft_size); if (!q->input_pad_freq) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - q->input_pad_time = srslte_vec_cf_malloc(fft_size); + q->input_pad_time = srsran_vec_cf_malloc(fft_size); if (!q->input_pad_time) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - srslte_ofdm_t psss_tx; - if (srslte_ofdm_tx_init(&psss_tx, cp, q->input_pad_freq, q->input_pad_time, nof_prb)) { + srsran_ofdm_t psss_tx; + if (srsran_ofdm_tx_init(&psss_tx, cp, q->input_pad_freq, q->input_pad_time, nof_prb)) { printf("Error creating iFFT object\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - srslte_ofdm_set_normalize(&psss_tx, true); - srslte_ofdm_set_freq_shift(&psss_tx, 0.5); + srsran_ofdm_set_normalize(&psss_tx, true); + srsran_ofdm_set_freq_shift(&psss_tx, 0.5); - srslte_dft_plan_t plan; - if (srslte_dft_plan(&plan, fft_size, SRSLTE_DFT_FORWARD, SRSLTE_DFT_COMPLEX)) { - return SRSLTE_ERROR; + srsran_dft_plan_t plan; + if (srsran_dft_plan(&plan, fft_size, SRSRAN_DFT_FORWARD, SRSRAN_DFT_COMPLEX)) { + return SRSRAN_ERROR; } - srslte_dft_plan_set_norm(&plan, true); - srslte_dft_plan_set_mirror(&plan, true); + srsran_dft_plan_set_norm(&plan, true); + srsran_dft_plan_set_mirror(&plan, true); // Create empty subframes with only PSSS for (uint32_t N_id_2 = 0; N_id_2 < 2; ++N_id_2) { - srslte_vec_cf_zero(q->input_pad_freq, fft_size); - srslte_vec_cf_zero(q->input_pad_time, fft_size); + srsran_vec_cf_zero(q->input_pad_freq, fft_size); + srsran_vec_cf_zero(q->input_pad_time, fft_size); - srslte_psss_put_sf_buffer(q->psss_signal[N_id_2], q->input_pad_freq, nof_prb, cp); - srslte_ofdm_tx_sf(&psss_tx); + srsran_psss_put_sf_buffer(q->psss_signal[N_id_2], q->input_pad_freq, nof_prb, cp); + srsran_ofdm_tx_sf(&psss_tx); - srslte_dft_run_c(&plan, q->input_pad_time, q->psss_sf_freq[N_id_2]); - srslte_vec_conj_cc(q->psss_sf_freq[N_id_2], q->psss_sf_freq[N_id_2], fft_size); + srsran_dft_run_c(&plan, q->input_pad_time, q->psss_sf_freq[N_id_2]); + srsran_vec_conj_cc(q->psss_sf_freq[N_id_2], q->psss_sf_freq[N_id_2], fft_size); } - srslte_dft_plan_free(&plan); - srslte_ofdm_tx_free(&psss_tx); + srsran_dft_plan_free(&plan); + srsran_ofdm_tx_free(&psss_tx); - q->dot_prod_output = srslte_vec_cf_malloc(fft_size); + q->dot_prod_output = srsran_vec_cf_malloc(fft_size); if (!q->dot_prod_output) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - q->dot_prod_output_time = srslte_vec_cf_malloc(fft_size); + q->dot_prod_output_time = srsran_vec_cf_malloc(fft_size); if (!q->dot_prod_output_time) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - q->shifted_output = srslte_vec_cf_malloc(fft_size); + q->shifted_output = srsran_vec_cf_malloc(fft_size); if (!q->shifted_output) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - q->shifted_output_abs = srslte_vec_f_malloc(fft_size); + q->shifted_output_abs = srsran_vec_f_malloc(fft_size); if (!q->shifted_output_abs) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_dft_plan(&q->plan_input, fft_size, SRSLTE_DFT_FORWARD, SRSLTE_DFT_COMPLEX)) { - return SRSLTE_ERROR; + if (srsran_dft_plan(&q->plan_input, fft_size, SRSRAN_DFT_FORWARD, SRSRAN_DFT_COMPLEX)) { + return SRSRAN_ERROR; } - srslte_dft_plan_set_mirror(&q->plan_input, true); - // srslte_dft_plan_set_dc(&psss->plan_input, true); - srslte_dft_plan_set_norm(&q->plan_input, true); + srsran_dft_plan_set_mirror(&q->plan_input, true); + // srsran_dft_plan_set_dc(&psss->plan_input, true); + srsran_dft_plan_set_norm(&q->plan_input, true); - if (srslte_dft_plan(&q->plan_out, fft_size, SRSLTE_DFT_BACKWARD, SRSLTE_DFT_COMPLEX)) { - return SRSLTE_ERROR; + if (srsran_dft_plan(&q->plan_out, fft_size, SRSRAN_DFT_BACKWARD, SRSRAN_DFT_COMPLEX)) { + return SRSRAN_ERROR; } - // srslte_dft_plan_set_mirror(&psss->plan_out, true); - srslte_dft_plan_set_dc(&q->plan_out, true); - srslte_dft_plan_set_norm(&q->plan_out, true); + // srsran_dft_plan_set_mirror(&psss->plan_out, true); + srsran_dft_plan_set_dc(&q->plan_out, true); + srsran_dft_plan_set_norm(&q->plan_out, true); - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } @@ -133,7 +133,7 @@ int srslte_psss_init(srslte_psss_t* q, uint32_t nof_prb, srslte_cp_t cp) * @param signal Output array. * Reference: 3GPP TS 36.211 version 15.6.0 Release 15 Sec. 9.7.1.1 */ -int srslte_psss_generate(cf_t* psss_signal, uint32_t N_id_2) +int srsran_psss_generate(cf_t* psss_signal, uint32_t N_id_2) { int i; float arg; @@ -142,35 +142,35 @@ int srslte_psss_generate(cf_t* psss_signal, uint32_t N_id_2) if (N_id_2 > 1) { ERROR("Invalid N_id_2 %d", N_id_2); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - for (i = 0; i < SRSLTE_PSSS_LEN / 2; i++) { + for (i = 0; i < SRSRAN_PSSS_LEN / 2; i++) { arg = (float)sign * M_PI * root_value[N_id_2] * ((float)i * ((float)i + 1.0)) / 63.0; __real__ psss_signal[i] = cosf(arg); __imag__ psss_signal[i] = sinf(arg); } - for (i = SRSLTE_PSSS_LEN / 2; i < SRSLTE_PSSS_LEN; i++) { + for (i = SRSRAN_PSSS_LEN / 2; i < SRSRAN_PSSS_LEN; i++) { arg = (float)sign * M_PI * root_value[N_id_2] * (((float)i + 2.0) * ((float)i + 1.0)) / 63.0; __real__ psss_signal[i] = cosf(arg); __imag__ psss_signal[i] = sinf(arg); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } /** * Mapping PSSS to resource elements * Reference: 3GPP TS 36.211 version 15.6.0 Release 15 Sec. 9.7.1.2 */ -void srslte_psss_put_sf_buffer(cf_t* psss_signal, cf_t* sf_buffer, uint32_t nof_prb, srslte_cp_t cp) +void srsran_psss_put_sf_buffer(cf_t* psss_signal, cf_t* sf_buffer, uint32_t nof_prb, srsran_cp_t cp) { // Normal cyclic prefix l = 1,2 // Extended cyclic prefix l = 0,1 for (int i = 0; i < 2; i++) { - uint32_t k = (SRSLTE_CP_NSYMB(cp) - (5 + i)) * nof_prb * SRSLTE_NRE + nof_prb * SRSLTE_NRE / 2 - 31; - srslte_vec_cf_zero(&sf_buffer[k - 5], 5); - memcpy(&sf_buffer[k], psss_signal, SRSLTE_PSSS_LEN * sizeof(cf_t)); - srslte_vec_cf_zero(&sf_buffer[k + SRSLTE_PSSS_LEN], 5); + uint32_t k = (SRSRAN_CP_NSYMB(cp) - (5 + i)) * nof_prb * SRSRAN_NRE + nof_prb * SRSRAN_NRE / 2 - 31; + srsran_vec_cf_zero(&sf_buffer[k - 5], 5); + memcpy(&sf_buffer[k], psss_signal, SRSRAN_PSSS_LEN * sizeof(cf_t)); + srsran_vec_cf_zero(&sf_buffer[k + SRSRAN_PSSS_LEN], 5); } } @@ -181,41 +181,41 @@ void srslte_psss_put_sf_buffer(cf_t* psss_signal, cf_t* sf_buffer, uint32_t nof_ * * * Input buffer must be subframe_size long. */ -int srslte_psss_find(srslte_psss_t* q, cf_t* input, uint32_t nof_prb, srslte_cp_t cp) +int srsran_psss_find(srsran_psss_t* q, cf_t* input, uint32_t nof_prb, srsran_cp_t cp) { // One array for each N_id_2 float corr_peak_value[2] = {}; uint32_t corr_peak_pos[2] = {}; - uint32_t sf_n_samples = (uint32_t)SRSLTE_SF_LEN_PRB(nof_prb); + uint32_t sf_n_samples = (uint32_t)SRSRAN_SF_LEN_PRB(nof_prb); uint32_t fft_size = sf_n_samples * 2; - srslte_vec_cf_zero(q->input_pad_freq, fft_size); - srslte_vec_cf_zero(q->input_pad_time, fft_size); + srsran_vec_cf_zero(q->input_pad_freq, fft_size); + srsran_vec_cf_zero(q->input_pad_time, fft_size); memcpy(q->input_pad_time, input, sizeof(cf_t) * sf_n_samples); - srslte_dft_run_c(&q->plan_input, q->input_pad_time, q->input_pad_freq); + srsran_dft_run_c(&q->plan_input, q->input_pad_time, q->input_pad_freq); for (int i = 0; i < 2; i++) { // .* - srslte_vec_prod_ccc(q->psss_sf_freq[i], q->input_pad_freq, q->dot_prod_output, fft_size); + srsran_vec_prod_ccc(q->psss_sf_freq[i], q->input_pad_freq, q->dot_prod_output, fft_size); // IFFT - srslte_dft_run_c(&q->plan_out, q->dot_prod_output, q->dot_prod_output_time); + srsran_dft_run_c(&q->plan_out, q->dot_prod_output, q->dot_prod_output_time); - srslte_vec_cf_zero(q->shifted_output, fft_size); - srslte_vec_cf_copy(q->shifted_output, &q->dot_prod_output_time[fft_size / 2], fft_size / 2); - srslte_vec_cf_copy(&q->shifted_output[fft_size / 2], q->dot_prod_output_time, fft_size / 2); + srsran_vec_cf_zero(q->shifted_output, fft_size); + srsran_vec_cf_copy(q->shifted_output, &q->dot_prod_output_time[fft_size / 2], fft_size / 2); + srsran_vec_cf_copy(&q->shifted_output[fft_size / 2], q->dot_prod_output_time, fft_size / 2); // Peak detection q->corr_peak_pos = -1; - srslte_vec_f_zero(q->shifted_output_abs, fft_size); - srslte_vec_abs_cf_simd(q->shifted_output, q->shifted_output_abs, fft_size); + srsran_vec_f_zero(q->shifted_output_abs, fft_size); + srsran_vec_abs_cf_simd(q->shifted_output, q->shifted_output_abs, fft_size); // Experimental Validation - uint32_t symbol_sz = (uint32_t)srslte_symbol_sz(nof_prb); - int cp_len = SRSLTE_CP_SZ(symbol_sz, cp); + uint32_t symbol_sz = (uint32_t)srsran_symbol_sz(nof_prb); + int cp_len = SRSRAN_CP_SZ(symbol_sz, cp); // Correlation output peaks: // @@ -227,16 +227,16 @@ int srslte_psss_find(srslte_psss_t* q, cf_t* input, uint32_t nof_prb, srslte_cp_ // side peak main peak side peak // Find the main peak - q->corr_peak_pos = srslte_vec_max_fi(q->shifted_output_abs, fft_size); + q->corr_peak_pos = srsran_vec_max_fi(q->shifted_output_abs, fft_size); q->corr_peak_value = q->shifted_output_abs[q->corr_peak_pos]; if ((q->corr_peak_pos < sf_n_samples) || (q->corr_peak_pos > fft_size - symbol_sz)) { q->corr_peak_pos = -1; continue; } - srslte_vec_f_zero(&q->shifted_output_abs[q->corr_peak_pos - (symbol_sz / 2)], symbol_sz); + srsran_vec_f_zero(&q->shifted_output_abs[q->corr_peak_pos - (symbol_sz / 2)], symbol_sz); // Find the first side peak - uint32_t peak_1_pos = srslte_vec_max_fi(q->shifted_output_abs, fft_size); + uint32_t peak_1_pos = srsran_vec_max_fi(q->shifted_output_abs, fft_size); float peak_1_value = q->shifted_output_abs[peak_1_pos]; if ((peak_1_pos >= (q->corr_peak_pos - (symbol_sz + cp_len) - 2)) && (peak_1_pos <= (q->corr_peak_pos - (symbol_sz + cp_len) + 2))) { @@ -248,10 +248,10 @@ int srslte_psss_find(srslte_psss_t* q, cf_t* input, uint32_t nof_prb, srslte_cp_ q->corr_peak_pos = -1; continue; } - srslte_vec_f_zero(&q->shifted_output_abs[peak_1_pos - (symbol_sz / 2)], symbol_sz); + srsran_vec_f_zero(&q->shifted_output_abs[peak_1_pos - (symbol_sz / 2)], symbol_sz); // Find the second side peak - uint32_t peak_2_pos = srslte_vec_max_fi(q->shifted_output_abs, fft_size); + uint32_t peak_2_pos = srsran_vec_max_fi(q->shifted_output_abs, fft_size); float peak_2_value = q->shifted_output_abs[peak_2_pos]; if ((peak_2_pos >= (q->corr_peak_pos - (symbol_sz + cp_len) - 2)) && (peak_2_pos <= (q->corr_peak_pos - (symbol_sz + cp_len) + 2))) { @@ -263,7 +263,7 @@ int srslte_psss_find(srslte_psss_t* q, cf_t* input, uint32_t nof_prb, srslte_cp_ q->corr_peak_pos = -1; continue; } - srslte_vec_f_zero(&q->shifted_output_abs[peak_2_pos - (symbol_sz / 2)], symbol_sz); + srsran_vec_f_zero(&q->shifted_output_abs[peak_2_pos - (symbol_sz / 2)], symbol_sz); float threshold_above = q->corr_peak_value / 2.0f * 1.4f; if ((peak_1_value > threshold_above) || (peak_2_value > threshold_above)) { @@ -281,22 +281,22 @@ int srslte_psss_find(srslte_psss_t* q, cf_t* input, uint32_t nof_prb, srslte_cp_ corr_peak_pos[i] = (uint32_t)q->corr_peak_pos; } - q->N_id_2 = srslte_vec_max_fi(corr_peak_value, 2); + q->N_id_2 = srsran_vec_max_fi(corr_peak_value, 2); if (corr_peak_value[q->N_id_2] == 0.0f) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } q->corr_peak_pos = corr_peak_pos[q->N_id_2]; q->corr_peak_value = corr_peak_value[q->N_id_2]; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -void srslte_psss_free(srslte_psss_t* q) +void srsran_psss_free(srsran_psss_t* q) { if (q) { - srslte_dft_plan_free(&q->plan_out); - srslte_dft_plan_free(&q->plan_input); + srsran_dft_plan_free(&q->plan_out); + srsran_dft_plan_free(&q->plan_input); if (q->shifted_output) { free(q->shifted_output); @@ -325,6 +325,6 @@ void srslte_psss_free(srslte_psss_t* q) free(q->psss_sf_freq); } - bzero(q, sizeof(srslte_psss_t)); + bzero(q, sizeof(srsran_psss_t)); } } diff --git a/lib/src/phy/sync/refsignal_dl_sync.c b/lib/src/phy/sync/refsignal_dl_sync.c index a9b9b0851..82787d84e 100644 --- a/lib/src/phy/sync/refsignal_dl_sync.c +++ b/lib/src/phy/sync/refsignal_dl_sync.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,9 +13,9 @@ #include #include #include -#include -#include -#include +#include +#include +#include /* * Constants @@ -54,7 +54,7 @@ /* * Local Helpers */ -static inline void refsignal_set_results_not_found(srslte_refsignal_dl_sync_t* q) +static inline void refsignal_set_results_not_found(srsran_refsignal_dl_sync_t* q) { q->found = false; q->rsrp_dBfs = NAN; @@ -64,23 +64,23 @@ static inline void refsignal_set_results_not_found(srslte_refsignal_dl_sync_t* q q->peak_index = UINT32_MAX; } -static inline void refsignal_sf_prepare_correlation(srslte_refsignal_dl_sync_t* q) +static inline void refsignal_sf_prepare_correlation(srsran_refsignal_dl_sync_t* q) { uint32_t sf_len = q->ifft.sf_sz; cf_t* ptr_filt = q->conv_fft_cc.filter_fft; memcpy(ptr_filt, q->sequences[0], sizeof(cf_t) * sf_len); - srslte_vec_cf_zero(&ptr_filt[sf_len], sf_len); - srslte_dft_run_c(&q->conv_fft_cc.filter_plan, ptr_filt, ptr_filt); + srsran_vec_cf_zero(&ptr_filt[sf_len], sf_len); + srsran_dft_run_c(&q->conv_fft_cc.filter_plan, ptr_filt, ptr_filt); } static inline void -refsignal_sf_correlate(srslte_refsignal_dl_sync_t* q, cf_t* ptr_in, float* peak_value, uint32_t* peak_idx, float* rms) +refsignal_sf_correlate(srsran_refsignal_dl_sync_t* q, cf_t* ptr_in, float* peak_value, uint32_t* peak_idx, float* rms) { // Correlate - srslte_corr_fft_cc_run_opt(&q->conv_fft_cc, ptr_in, q->conv_fft_cc.filter_fft, q->correlation); + srsran_corr_fft_cc_run_opt(&q->conv_fft_cc, ptr_in, q->conv_fft_cc.filter_fft, q->correlation); // Find maximum, calculate RMS and peak - uint32_t imax = srslte_vec_max_abs_ci(q->correlation, q->ifft.sf_sz); + uint32_t imax = srsran_vec_max_abs_ci(q->correlation, q->ifft.sf_sz); if (peak_idx) { *peak_idx = imax; @@ -91,11 +91,11 @@ refsignal_sf_correlate(srslte_refsignal_dl_sync_t* q, cf_t* ptr_in, float* peak_ } if (rms) { - *rms = sqrtf(srslte_vec_avg_power_cf(q->correlation, q->ifft.sf_sz)); + *rms = sqrtf(srsran_vec_avg_power_cf(q->correlation, q->ifft.sf_sz)); } } -static inline void refsignal_dl_pss_sss_strength(srslte_refsignal_dl_sync_t* q, +static inline void refsignal_dl_pss_sss_strength(srsran_refsignal_dl_sync_t* q, cf_t* buffer, uint32_t sf_idx, float* pss_strength, @@ -103,85 +103,85 @@ static inline void refsignal_dl_pss_sss_strength(srslte_refsignal_dl_sync_t* q, float* sss_strength_false) { uint32_t symbol_sz = q->ifft.cfg.symbol_sz; - uint32_t cp_len0 = SRSLTE_CP_LEN_NORM(0, symbol_sz); - uint32_t cp_len1 = SRSLTE_CP_LEN_NORM(1, symbol_sz); + uint32_t cp_len0 = SRSRAN_CP_LEN_NORM(0, symbol_sz); + uint32_t cp_len1 = SRSRAN_CP_LEN_NORM(1, symbol_sz); uint32_t pss_n = cp_len0 + cp_len1 * 6 + symbol_sz * 6; uint32_t sss_n = cp_len0 + cp_len1 * 5 + symbol_sz * 5; - sf_idx %= SRSLTE_NOF_SF_X_FRAME; + sf_idx %= SRSRAN_NOF_SF_X_FRAME; - srslte_dl_sf_cfg_t dl_sf_cfg = {}; + srsran_dl_sf_cfg_t dl_sf_cfg = {}; dl_sf_cfg.tti = sf_idx; - float k = (float)(srslte_refsignal_cs_nof_re(&q->refsignal, &dl_sf_cfg, 0)) / (float)SRSLTE_PSS_LEN; + float k = (float)(srsran_refsignal_cs_nof_re(&q->refsignal, &dl_sf_cfg, 0)) / (float)SRSRAN_PSS_LEN; if (pss_strength) { - cf_t corr = srslte_vec_dot_prod_conj_ccc(&buffer[pss_n], &q->sequences[sf_idx][pss_n], symbol_sz); + cf_t corr = srsran_vec_dot_prod_conj_ccc(&buffer[pss_n], &q->sequences[sf_idx][pss_n], symbol_sz); *pss_strength = k * __real__(corr * conjf(corr)); } if (sss_strength) { - cf_t corr = srslte_vec_dot_prod_conj_ccc(&buffer[sss_n], &q->sequences[sf_idx][sss_n], symbol_sz); + cf_t corr = srsran_vec_dot_prod_conj_ccc(&buffer[sss_n], &q->sequences[sf_idx][sss_n], symbol_sz); *sss_strength = k * __real__(corr * conjf(corr)); } if (sss_strength_false) { - uint32_t sf_idx2 = (sf_idx + SRSLTE_NOF_SF_X_FRAME / 2) % SRSLTE_NOF_SF_X_FRAME; - cf_t corr = srslte_vec_dot_prod_conj_ccc(&buffer[sss_n], &q->sequences[sf_idx2][sss_n], symbol_sz); + uint32_t sf_idx2 = (sf_idx + SRSRAN_NOF_SF_X_FRAME / 2) % SRSRAN_NOF_SF_X_FRAME; + cf_t corr = srsran_vec_dot_prod_conj_ccc(&buffer[sss_n], &q->sequences[sf_idx2][sss_n], symbol_sz); *sss_strength_false = k * __real__(corr * conjf(corr)); } } -int srslte_refsignal_dl_sync_init(srslte_refsignal_dl_sync_t* q) +int srsran_refsignal_dl_sync_init(srsran_refsignal_dl_sync_t* q) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q) { // Initialise internals - memset(q, 0, sizeof(srslte_refsignal_dl_sync_t)); + memset(q, 0, sizeof(srsran_refsignal_dl_sync_t)); // Initialise Reference signals - ret = srslte_refsignal_cs_init(&q->refsignal, SRSLTE_MAX_PRB); + ret = srsran_refsignal_cs_init(&q->refsignal, SRSRAN_MAX_PRB); // Allocate time buffers - for (int i = 0; i < SRSLTE_NOF_SF_X_FRAME; i++) { - q->sequences[i] = srslte_vec_cf_malloc(SRSLTE_SF_LEN_MAX); + for (int i = 0; i < SRSRAN_NOF_SF_X_FRAME; i++) { + q->sequences[i] = srsran_vec_cf_malloc(SRSRAN_SF_LEN_MAX); if (!q->sequences[i]) { perror("Allocating sequence\n"); } } // Allocate Temporal OFDM buffer - q->ifft_buffer_in = srslte_vec_cf_malloc(SRSLTE_SF_LEN_MAX); + q->ifft_buffer_in = srsran_vec_cf_malloc(SRSRAN_SF_LEN_MAX); if (!q->ifft_buffer_in) { perror("Allocating ifft_buffer_in\n"); } - q->ifft_buffer_out = srslte_vec_cf_malloc(SRSLTE_SF_LEN_MAX); + q->ifft_buffer_out = srsran_vec_cf_malloc(SRSRAN_SF_LEN_MAX); if (!q->ifft_buffer_out) { perror("Allocating ifft_buffer_out\n"); } // Allocate correlation - q->correlation = srslte_vec_cf_malloc(SRSLTE_SF_LEN_MAX * 2); + q->correlation = srsran_vec_cf_malloc(SRSRAN_SF_LEN_MAX * 2); if (!q->correlation) { perror("Allocating correlation\n"); } // Initiate OFDM modulator if (!ret) { - ret = srslte_ofdm_tx_init(&q->ifft, SRSLTE_CP_NORM, q->ifft_buffer_in, q->ifft_buffer_out, SRSLTE_MAX_PRB); + ret = srsran_ofdm_tx_init(&q->ifft, SRSRAN_CP_NORM, q->ifft_buffer_in, q->ifft_buffer_out, SRSRAN_MAX_PRB); } // Set PRB if (!ret) { - ret = srslte_ofdm_tx_set_prb(&q->ifft, SRSLTE_CP_NORM, SRSLTE_MAX_PRB); + ret = srsran_ofdm_tx_set_prb(&q->ifft, SRSRAN_CP_NORM, SRSRAN_MAX_PRB); } // Initiate FFT Convolution if (!ret) { - ret = srslte_conv_fft_cc_init(&q->conv_fft_cc, q->ifft.sf_sz, q->ifft.sf_sz); + ret = srsran_conv_fft_cc_init(&q->conv_fft_cc, q->ifft.sf_sz, q->ifft.sf_sz); } // Set default results to not found @@ -191,68 +191,68 @@ int srslte_refsignal_dl_sync_init(srslte_refsignal_dl_sync_t* q) return ret; } -int srslte_refsignal_dl_sync_set_cell(srslte_refsignal_dl_sync_t* q, srslte_cell_t cell) +int srsran_refsignal_dl_sync_set_cell(srsran_refsignal_dl_sync_t* q, srsran_cell_t cell) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q) { - cf_t pss_signal[SRSLTE_PSS_LEN]; - float sss_signal0[SRSLTE_SSS_LEN]; - float sss_signal5[SRSLTE_SSS_LEN]; + cf_t pss_signal[SRSRAN_PSS_LEN]; + float sss_signal0[SRSRAN_SSS_LEN]; + float sss_signal5[SRSRAN_SSS_LEN]; // Generate Synchronization signals - srslte_pss_generate(pss_signal, cell.id % 3); - srslte_sss_generate(sss_signal0, sss_signal5, cell.id); + srsran_pss_generate(pss_signal, cell.id % 3); + srsran_sss_generate(sss_signal0, sss_signal5, cell.id); // Set cell for Ref signals - ret = srslte_refsignal_cs_set_cell(&q->refsignal, cell); + ret = srsran_refsignal_cs_set_cell(&q->refsignal, cell); // Resize OFDM - if (!ret && q->ifft.nof_re != cell.nof_prb * SRSLTE_NRE) { - ret = srslte_ofdm_tx_set_prb(&q->ifft, cell.cp, cell.nof_prb); + if (!ret && q->ifft.nof_re != cell.nof_prb * SRSRAN_NRE) { + ret = srsran_ofdm_tx_set_prb(&q->ifft, cell.cp, cell.nof_prb); } // Replan convolution if (q->conv_fft_cc.filter_len != q->ifft.sf_sz) { - srslte_conv_fft_cc_replan(&q->conv_fft_cc, q->ifft.sf_sz, q->ifft.sf_sz); + srsran_conv_fft_cc_replan(&q->conv_fft_cc, q->ifft.sf_sz, q->ifft.sf_sz); } // Generate frame with references if (!ret) { - for (int i = 0; i < SRSLTE_NOF_SF_X_FRAME && ret == SRSLTE_SUCCESS; i++) { + for (int i = 0; i < SRSRAN_NOF_SF_X_FRAME && ret == SRSRAN_SUCCESS; i++) { uint32_t nof_re = 0; // Default Subframe configuration - srslte_dl_sf_cfg_t dl_sf_cfg = {}; + srsran_dl_sf_cfg_t dl_sf_cfg = {}; dl_sf_cfg.tti = i; // Reset OFDM buffer - srslte_vec_cf_zero(q->ifft_buffer_in, q->ifft.sf_sz); + srsran_vec_cf_zero(q->ifft_buffer_in, q->ifft.sf_sz); // Put Synchronization signals if (i == 0 || i == 5) { - srslte_pss_put_slot(pss_signal, q->ifft_buffer_in, cell.nof_prb, cell.cp); - srslte_sss_put_slot(i ? sss_signal5 : sss_signal0, q->ifft_buffer_in, cell.nof_prb, cell.cp); + srsran_pss_put_slot(pss_signal, q->ifft_buffer_in, cell.nof_prb, cell.cp); + srsran_sss_put_slot(i ? sss_signal5 : sss_signal0, q->ifft_buffer_in, cell.nof_prb, cell.cp); } // Put Reference signals for (int p = 0; p < cell.nof_ports; p++) { - ret = srslte_refsignal_cs_put_sf(&q->refsignal, &dl_sf_cfg, p, q->ifft_buffer_in); + ret = srsran_refsignal_cs_put_sf(&q->refsignal, &dl_sf_cfg, p, q->ifft_buffer_in); // Increment number of resource elements if (p == 0) { - nof_re += srslte_refsignal_cs_nof_re(&q->refsignal, &dl_sf_cfg, p); + nof_re += srsran_refsignal_cs_nof_re(&q->refsignal, &dl_sf_cfg, p); } } // Run OFDM modulator - srslte_ofdm_tx_sf(&q->ifft); + srsran_ofdm_tx_sf(&q->ifft); // Undo scaling and normalize overall power to 1 float scale = 1.0f / nof_re; // Copy time domain signal, normalized by number of RE - srslte_vec_sc_prod_cfc(q->ifft_buffer_out, scale, q->sequences[i], q->ifft.sf_sz); + srsran_vec_sc_prod_cfc(q->ifft_buffer_out, scale, q->sequences[i], q->ifft.sf_sz); } } } @@ -260,12 +260,12 @@ int srslte_refsignal_dl_sync_set_cell(srslte_refsignal_dl_sync_t* q, srslte_cell return ret; } -void srslte_refsignal_dl_sync_free(srslte_refsignal_dl_sync_t* q) +void srsran_refsignal_dl_sync_free(srsran_refsignal_dl_sync_t* q) { if (q) { - srslte_refsignal_free(&q->refsignal); + srsran_refsignal_free(&q->refsignal); - srslte_ofdm_tx_free(&q->ifft); + srsran_ofdm_tx_free(&q->ifft); if (q->ifft_buffer_in) { free(q->ifft_buffer_in); @@ -279,19 +279,19 @@ void srslte_refsignal_dl_sync_free(srslte_refsignal_dl_sync_t* q) free(q->correlation); } - for (int i = 0; i < SRSLTE_NOF_SF_X_FRAME; i++) { + for (int i = 0; i < SRSRAN_NOF_SF_X_FRAME; i++) { if (q->sequences[i]) { free(q->sequences[i]); } } - srslte_conv_fft_cc_free(&q->conv_fft_cc); + srsran_conv_fft_cc_free(&q->conv_fft_cc); } } -int srslte_refsignal_dl_sync_find_peak(srslte_refsignal_dl_sync_t* q, cf_t* buffer, uint32_t nsamples) +int srsran_refsignal_dl_sync_find_peak(srsran_refsignal_dl_sync_t* q, cf_t* buffer, uint32_t nsamples) { - int ret = SRSLTE_ERROR; + int ret = SRSRAN_ERROR; float peak_value = 0.0f; int peak_idx = 0; float rms_avg = 0; @@ -301,7 +301,7 @@ int srslte_refsignal_dl_sync_find_peak(srslte_refsignal_dl_sync_t* q, cf_t* buff refsignal_sf_prepare_correlation(q); // Limit correlate for a frame or less - nsamples = SRSLTE_MIN(nsamples - sf_len, SRSLTE_NOF_SF_X_FRAME * sf_len); + nsamples = SRSRAN_MIN(nsamples - sf_len, SRSRAN_NOF_SF_X_FRAME * sf_len); // Correlation for (int n = 0; n < nsamples; n += sf_len) { @@ -334,12 +334,12 @@ int srslte_refsignal_dl_sync_find_peak(srslte_refsignal_dl_sync_t* q, cf_t* buff float rsrp_lin = 0.0f; float rsrp_lin_false = 0.0f; - srslte_refsignal_dl_sync_measure_sf(q, &buffer[peak_idx], 0, &rsrp_lin, NULL, NULL); - srslte_refsignal_dl_sync_measure_sf(q, &buffer[peak_idx], 5, &rsrp_lin_false, NULL, NULL); + srsran_refsignal_dl_sync_measure_sf(q, &buffer[peak_idx], 0, &rsrp_lin, NULL, NULL); + srsran_refsignal_dl_sync_measure_sf(q, &buffer[peak_idx], 5, &rsrp_lin_false, NULL, NULL); // Change base sub-frame if (sss_strength_false > sss_strength && rsrp_lin_false > rsrp_lin) { - ret += (q->ifft.sf_sz * SRSLTE_NOF_SF_X_FRAME) / 2; + ret += (q->ifft.sf_sz * SRSRAN_NOF_SF_X_FRAME) / 2; } } @@ -355,7 +355,7 @@ int srslte_refsignal_dl_sync_find_peak(srslte_refsignal_dl_sync_t* q, cf_t* buff return ret; } -void srslte_refsignal_dl_sync_run(srslte_refsignal_dl_sync_t* q, cf_t* buffer, uint32_t nsamples) +void srsran_refsignal_dl_sync_run(srsran_refsignal_dl_sync_t* q, cf_t* buffer, uint32_t nsamples) { if (q) { uint32_t sf_len = q->ifft.sf_sz; @@ -373,41 +373,41 @@ void srslte_refsignal_dl_sync_run(srslte_refsignal_dl_sync_t* q, cf_t* buffer, u bool false_alarm = false; // Stage 1: find peak - int peak_idx = srslte_refsignal_dl_sync_find_peak(q, buffer, nsamples); + int peak_idx = srsran_refsignal_dl_sync_find_peak(q, buffer, nsamples); // Stage 2: Proccess subframes if (peak_idx >= 0) { // Calculate initial subframe index and sample - uint32_t sf_idx_init = (2 * SRSLTE_NOF_SF_X_FRAME - peak_idx / sf_len) % SRSLTE_NOF_SF_X_FRAME; + uint32_t sf_idx_init = (2 * SRSRAN_NOF_SF_X_FRAME - peak_idx / sf_len) % SRSRAN_NOF_SF_X_FRAME; uint32_t n_init = peak_idx % sf_len; for (int sf_idx = sf_idx_init, n = n_init; n < (nsamples - sf_len + 1); - sf_idx = (sf_idx + 1) % SRSLTE_NOF_SF_X_FRAME, n += sf_len) { + sf_idx = (sf_idx + 1) % SRSRAN_NOF_SF_X_FRAME, n += sf_len) { cf_t* buf = &buffer[n]; // Measure subframe rsrp, rssi and accumulate float rsrp = 0.0f, rssi = 0.0f, cfo = 0.0f; - srslte_refsignal_dl_sync_measure_sf(q, buf, sf_idx, &rsrp, &rssi, &cfo); + srsran_refsignal_dl_sync_measure_sf(q, buf, sf_idx, &rsrp, &rssi, &cfo); // Update measurements rsrp_lin += rsrp; - rsrp_lin_min = SRSLTE_MIN(rsrp_lin_min, rsrp); - rsrp_lin_max = SRSLTE_MAX(rsrp_lin_max, rsrp); + rsrp_lin_min = SRSRAN_MIN(rsrp_lin_min, rsrp); + rsrp_lin_max = SRSRAN_MAX(rsrp_lin_max, rsrp); rssi_lin += rssi; cfo_acc += cfo; - cfo_min = SRSLTE_MIN(cfo_min, cfo); - cfo_max = SRSLTE_MAX(cfo_max, cfo); + cfo_min = SRSRAN_MIN(cfo_min, cfo); + cfo_max = SRSRAN_MAX(cfo_max, cfo); // Compute PSS/SSS strength - if (sf_idx % (SRSLTE_NOF_SF_X_FRAME / 2) == 0) { + if (sf_idx % (SRSRAN_NOF_SF_X_FRAME / 2) == 0) { float sss_strength = 0.0f; float sss_strength_false = 0.0f; refsignal_dl_pss_sss_strength(q, buf, sf_idx, NULL, &sss_strength, &sss_strength_false); float rsrp_false = 0.0f; - srslte_refsignal_dl_sync_measure_sf(q, buf, sf_idx + 1, &rsrp_false, NULL, NULL); + srsran_refsignal_dl_sync_measure_sf(q, buf, sf_idx + 1, &rsrp_false, NULL, NULL); sss_strength_avg += sss_strength; sss_strength_false_avg += sss_strength_false; @@ -423,16 +423,16 @@ void srslte_refsignal_dl_sync_run(srslte_refsignal_dl_sync_t* q, cf_t* buffer, u rsrp_lin /= sf_count; rssi_lin /= sf_count; cfo_acc /= sf_count; - sss_strength_avg /= (2.0f * sf_count / SRSLTE_NOF_SF_X_FRAME); - sss_strength_false_avg /= (2.0f * sf_count / SRSLTE_NOF_SF_X_FRAME); - rsrp_false_avg /= (2.0f * sf_count / SRSLTE_NOF_SF_X_FRAME); + sss_strength_avg /= (2.0f * sf_count / SRSRAN_NOF_SF_X_FRAME); + sss_strength_false_avg /= (2.0f * sf_count / SRSRAN_NOF_SF_X_FRAME); + rsrp_false_avg /= (2.0f * sf_count / SRSRAN_NOF_SF_X_FRAME); } // RSRP conversion to dB - float rsrp_dB_min = srslte_convert_power_to_dBm(rsrp_lin_min); - float rsrp_dB_max = srslte_convert_power_to_dBm(rsrp_lin_max); - float rsrp_dB = srslte_convert_power_to_dBm(rsrp_lin); - float rsrp_false_dB = srslte_convert_power_to_dBm(rsrp_false_avg); + float rsrp_dB_min = srsran_convert_power_to_dBm(rsrp_lin_min); + float rsrp_dB_max = srsran_convert_power_to_dBm(rsrp_lin_max); + float rsrp_dB = srsran_convert_power_to_dBm(rsrp_lin); + float rsrp_false_dB = srsran_convert_power_to_dBm(rsrp_false_avg); // Stage 3: Final false alarm decision uint32_t false_count = 0; @@ -485,10 +485,10 @@ void srslte_refsignal_dl_sync_run(srslte_refsignal_dl_sync_t* q, cf_t* buffer, u q->rsrp_dBfs = rsrp_dB; // Calculate RSSI in dBm - q->rssi_dBfs = srslte_convert_power_to_dBm(rssi_lin); + q->rssi_dBfs = srsran_convert_power_to_dBm(rssi_lin); // Calculate RSRQ - q->rsrq_dB = srslte_convert_power_to_dB(q->refsignal.cell.nof_prb) + q->rsrp_dBfs - q->rssi_dBfs; + q->rsrq_dB = srsran_convert_power_to_dB(q->refsignal.cell.nof_prb) + q->rsrp_dBfs - q->rssi_dBfs; q->found = true; q->cfo_Hz = cfo_acc; @@ -502,7 +502,7 @@ void srslte_refsignal_dl_sync_run(srslte_refsignal_dl_sync_t* q, cf_t* buffer, u } } -void srslte_refsignal_dl_sync_measure_sf(srslte_refsignal_dl_sync_t* q, +void srsran_refsignal_dl_sync_measure_sf(srsran_refsignal_dl_sync_t* q, cf_t* buffer, uint32_t sf_idx, float* rsrp, @@ -512,20 +512,20 @@ void srslte_refsignal_dl_sync_measure_sf(srslte_refsignal_dl_sync_t* q, float rsrp_lin = 0.0f; float rssi_lin = 0.0f; cf_t corr[4] = {}; - srslte_dl_sf_cfg_t dl_sf_cfg = {}; + srsran_dl_sf_cfg_t dl_sf_cfg = {}; dl_sf_cfg.tti = sf_idx; if (q) { - cf_t* sf_sequence = q->sequences[sf_idx % SRSLTE_NOF_SF_X_FRAME]; + cf_t* sf_sequence = q->sequences[sf_idx % SRSRAN_NOF_SF_X_FRAME]; uint32_t symbol_sz = q->ifft.cfg.symbol_sz; - uint32_t nsymbols = srslte_refsignal_cs_nof_symbols(&q->refsignal, &dl_sf_cfg, 0); - uint32_t cp_len0 = SRSLTE_CP_LEN_NORM(0, symbol_sz); - uint32_t cp_len1 = SRSLTE_CP_LEN_NORM(1, symbol_sz); + uint32_t nsymbols = srsran_refsignal_cs_nof_symbols(&q->refsignal, &dl_sf_cfg, 0); + uint32_t cp_len0 = SRSRAN_CP_LEN_NORM(0, symbol_sz); + uint32_t cp_len1 = SRSRAN_CP_LEN_NORM(1, symbol_sz); for (uint32_t l = 0; l < nsymbols; l++) { // Calculate FFT window offset for reference signals symbols - uint32_t symbidx = srslte_refsignal_cs_nsymbol(l, q->refsignal.cell.cp, 0); + uint32_t symbidx = srsran_refsignal_cs_nsymbol(l, q->refsignal.cell.cp, 0); uint32_t offset = cp_len0 + (symbol_sz + cp_len1) * symbidx; if (l >= nsymbols / 2) { @@ -533,14 +533,14 @@ void srslte_refsignal_dl_sync_measure_sf(srslte_refsignal_dl_sync_t* q, } // Complex correlation - corr[l] = srslte_vec_dot_prod_conj_ccc(&buffer[offset], &sf_sequence[offset], symbol_sz); + corr[l] = srsran_vec_dot_prod_conj_ccc(&buffer[offset], &sf_sequence[offset], symbol_sz); // Calculate RSRP rsrp_lin += __real__(corr[l] * conjf(corr[l])); // Calculate RSSI if (rssi) { - rssi_lin += srslte_vec_dot_prod_conj_ccc(&buffer[offset], &buffer[offset], symbol_sz); + rssi_lin += srsran_vec_dot_prod_conj_ccc(&buffer[offset], &buffer[offset], symbol_sz); } } diff --git a/lib/src/phy/sync/sfo.c b/lib/src/phy/sync/sfo.c index 68882de1c..c58313a41 100644 --- a/lib/src/phy/sync/sfo.c +++ b/lib/src/phy/sync/sfo.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,14 +10,14 @@ * */ -#include "srslte/phy/sync/sfo.h" +#include "srsran/phy/sync/sfo.h" #include #include /* Estimate SFO based on the array of time estimates t0 * of length len. The parameter period is the time between t0 samples */ -float srslte_sfo_estimate(int* t0, int len, float period) +float srsran_sfo_estimate(int* t0, int len, float period) { int i; float sfo = 0.0; @@ -27,10 +27,10 @@ float srslte_sfo_estimate(int* t0, int len, float period) return sfo; } -/* Same as srslte_sfo_estimate but period is non-uniform. +/* Same as srsran_sfo_estimate but period is non-uniform. * Vector t is the sampling time times period for each t0 */ -float srslte_sfo_estimate_period(int* t0, int* t, int len, float period) +float srsran_sfo_estimate_period(int* t0, int* t, int len, float period) { int i; float sfo = 0.0; diff --git a/lib/src/phy/sync/sss.c b/lib/src/phy/sync/sss.c index 2db73cdff..42fdd7c5f 100644 --- a/lib/src/phy/sync/sss.c +++ b/lib/src/phy/sync/sss.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -16,30 +16,30 @@ #include #include -#include "srslte/phy/dft/dft.h" -#include "srslte/phy/sync/sss.h" -#include "srslte/phy/utils/convolution.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/dft/dft.h" +#include "srsran/phy/sync/sss.h" +#include "srsran/phy/utils/convolution.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" -void generate_sss_all_tables(srslte_sss_tables_t* tables, uint32_t N_id_2); -void convert_tables(srslte_sss_fc_tables_t* fc_tables, srslte_sss_tables_t* in); +void generate_sss_all_tables(srsran_sss_tables_t* tables, uint32_t N_id_2); +void convert_tables(srsran_sss_fc_tables_t* fc_tables, srsran_sss_tables_t* in); void generate_N_id_1_table(uint32_t table[30][30]); -int srslte_sss_init(srslte_sss_t* q, uint32_t fft_size) +int srsran_sss_init(srsran_sss_t* q, uint32_t fft_size) { if (q != NULL && fft_size <= 2048) { uint32_t N_id_2; - srslte_sss_tables_t sss_tables; + srsran_sss_tables_t sss_tables; - bzero(q, sizeof(srslte_sss_t)); + bzero(q, sizeof(srsran_sss_t)); - if (srslte_dft_plan(&q->dftp_input, fft_size, SRSLTE_DFT_FORWARD, SRSLTE_DFT_COMPLEX)) { - srslte_sss_free(q); - return SRSLTE_ERROR; + if (srsran_dft_plan(&q->dftp_input, fft_size, SRSRAN_DFT_FORWARD, SRSRAN_DFT_COMPLEX)) { + srsran_sss_free(q); + return SRSRAN_ERROR; } - srslte_dft_plan_set_mirror(&q->dftp_input, true); - srslte_dft_plan_set_dc(&q->dftp_input, true); + srsran_dft_plan_set_mirror(&q->dftp_input, true); + srsran_dft_plan_set_dc(&q->dftp_input, true); q->fft_size = fft_size; q->max_fft_size = fft_size; @@ -51,72 +51,72 @@ int srslte_sss_init(srslte_sss_t* q, uint32_t fft_size) convert_tables(&q->fc_tables[N_id_2], &sss_tables); } q->N_id_2 = 0; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } -int srslte_sss_resize(srslte_sss_t* q, uint32_t fft_size) +int srsran_sss_resize(srsran_sss_t* q, uint32_t fft_size) { if (q != NULL && fft_size <= 2048) { if (fft_size > q->max_fft_size) { ERROR("Error in sss_synch_resize(): fft_size must be lower than initialized"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_dft_replan(&q->dftp_input, fft_size)) { - srslte_sss_free(q); - return SRSLTE_ERROR; + if (srsran_dft_replan(&q->dftp_input, fft_size)) { + srsran_sss_free(q); + return SRSRAN_ERROR; } q->fft_size = fft_size; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } -void srslte_sss_free(srslte_sss_t* q) +void srsran_sss_free(srsran_sss_t* q) { - srslte_dft_plan_free(&q->dftp_input); - bzero(q, sizeof(srslte_sss_t)); + srsran_dft_plan_free(&q->dftp_input); + bzero(q, sizeof(srsran_sss_t)); } /** Sets the N_id_2 to search for */ -int srslte_sss_set_N_id_2(srslte_sss_t* q, uint32_t N_id_2) +int srsran_sss_set_N_id_2(srsran_sss_t* q, uint32_t N_id_2) { - if (!srslte_N_id_2_isvalid(N_id_2)) { + if (!srsran_N_id_2_isvalid(N_id_2)) { ERROR("Invalid N_id_2 %d", N_id_2); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } else { q->N_id_2 = N_id_2; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } } /** 36.211 10.3 section 6.11.2.2 */ -void srslte_sss_put_slot(float* sss, cf_t* slot, uint32_t nof_prb, srslte_cp_t cp) +void srsran_sss_put_slot(float* sss, cf_t* slot, uint32_t nof_prb, srsran_cp_t cp) { uint32_t i, k; - k = (SRSLTE_CP_NSYMB(cp) - 2) * nof_prb * SRSLTE_NRE + nof_prb * SRSLTE_NRE / 2 - 31; + k = (SRSRAN_CP_NSYMB(cp) - 2) * nof_prb * SRSRAN_NRE + nof_prb * SRSRAN_NRE / 2 - 31; if (k > 5) { memset(&slot[k - 5], 0, 5 * sizeof(cf_t)); - for (i = 0; i < SRSLTE_SSS_LEN; i++) { + for (i = 0; i < SRSRAN_SSS_LEN; i++) { __real__ slot[k + i] = sss[i]; __imag__ slot[k + i] = 0; } - memset(&slot[k + SRSLTE_SSS_LEN], 0, 5 * sizeof(cf_t)); + memset(&slot[k + SRSRAN_SSS_LEN], 0, 5 * sizeof(cf_t)); } } /** Sets the SSS correlation peak detection threshold */ -void srslte_sss_set_threshold(srslte_sss_t* q, float threshold) +void srsran_sss_set_threshold(srsran_sss_t* q, float threshold) { q->corr_peak_threshold = threshold; } /** Returns the subframe index based on the m0 and m1 values */ -uint32_t srslte_sss_subframe(uint32_t m0, uint32_t m1) +uint32_t srsran_sss_subframe(uint32_t m0, uint32_t m1) { if (m1 > m0) { return 0; @@ -126,9 +126,9 @@ uint32_t srslte_sss_subframe(uint32_t m0, uint32_t m1) } /** Returns the N_id_1 value based on the m0 and m1 values */ -int srslte_sss_N_id_1(srslte_sss_t* q, uint32_t m0, uint32_t m1, float corr) +int srsran_sss_N_id_1(srsran_sss_t* q, uint32_t m0, uint32_t m1, float corr) { - int N_id_1 = SRSLTE_ERROR; + int N_id_1 = SRSRAN_ERROR; // Check threshold, consider not found (error) if the correlation is not above the threshold if (corr > q->corr_peak_threshold) { diff --git a/lib/src/phy/sync/ssss.c b/lib/src/phy/sync/ssss.c index bb717ac05..17a2d9140 100644 --- a/lib/src/phy/sync/ssss.c +++ b/lib/src/phy/sync/ssss.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -16,23 +16,23 @@ #include #include -#include "srslte/phy/sync/ssss.h" +#include "srsran/phy/sync/ssss.h" #include "gen_sss.c" -#include "srslte/config.h" -#include "srslte/phy/dft/ofdm.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/config.h" +#include "srsran/phy/dft/ofdm.h" +#include "srsran/phy/utils/vector.h" // Generates the Sidelink sequences that are used to detect SSSS -int srslte_ssss_init(srslte_ssss_t* q, uint32_t nof_prb, srslte_cp_t cp, srslte_sl_tm_t tm) +int srsran_ssss_init(srsran_ssss_t* q, uint32_t nof_prb, srsran_cp_t cp, srsran_sl_tm_t tm) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL) { - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; - uint32_t symbol_sz = srslte_symbol_sz(nof_prb); - int cp_len = SRSLTE_CP_SZ(symbol_sz, cp); - uint32_t sf_n_re = SRSLTE_CP_NSYMB(cp) * 12 * 2 * nof_prb; + uint32_t symbol_sz = srsran_symbol_sz(nof_prb); + int cp_len = SRSRAN_CP_SZ(symbol_sz, cp); + uint32_t sf_n_re = SRSRAN_CP_NSYMB(cp) * 12 * 2 * nof_prb; uint32_t sf_n_samples = symbol_sz * 15; uint32_t ssss_n_samples = @@ -41,92 +41,92 @@ int srslte_ssss_init(srslte_ssss_t* q, uint32_t nof_prb, srslte_cp_t cp, srslte_ // CP Normal: ssss (with its cp) starts at sample number: 11 symbol_sz + 2 CP_LEN_NORM_0 + 9 cp_len // CP Extended: ssss (with its cp) starts at sample number: 9 symbol_sz + 9 cp_len - uint32_t ssss_start = (cp == SRSLTE_CP_NORM) - ? (symbol_sz * 11 + (SRSLTE_CP_LEN_NORM(0, symbol_sz) * 2 + cp_len * 9)) + uint32_t ssss_start = (cp == SRSRAN_CP_NORM) + ? (symbol_sz * 11 + (SRSRAN_CP_LEN_NORM(0, symbol_sz) * 2 + cp_len * 9)) : ((symbol_sz + cp_len) * 9); - for (int i = 0; i < SRSLTE_SSSS_NOF_SEQ; ++i) { - srslte_ssss_generate(q->ssss_signal[i], i, tm); + for (int i = 0; i < SRSRAN_SSSS_NOF_SEQ; ++i) { + srsran_ssss_generate(q->ssss_signal[i], i, tm); } - if (srslte_dft_plan(&q->plan_input, ssss_n_samples, SRSLTE_DFT_FORWARD, SRSLTE_DFT_COMPLEX)) { - return SRSLTE_ERROR; + if (srsran_dft_plan(&q->plan_input, ssss_n_samples, SRSRAN_DFT_FORWARD, SRSRAN_DFT_COMPLEX)) { + return SRSRAN_ERROR; } - srslte_dft_plan_set_mirror(&q->plan_input, true); - srslte_dft_plan_set_norm(&q->plan_input, true); + srsran_dft_plan_set_mirror(&q->plan_input, true); + srsran_dft_plan_set_norm(&q->plan_input, true); - q->input_pad_freq = srslte_vec_cf_malloc(sf_n_re); + q->input_pad_freq = srsran_vec_cf_malloc(sf_n_re); if (!q->input_pad_freq) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - q->input_pad_time = srslte_vec_cf_malloc(sf_n_samples); + q->input_pad_time = srsran_vec_cf_malloc(sf_n_samples); if (!q->input_pad_time) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - srslte_ofdm_t ssss_ifft; - if (srslte_ofdm_tx_init(&ssss_ifft, cp, q->input_pad_freq, q->input_pad_time, nof_prb)) { + srsran_ofdm_t ssss_ifft; + if (srsran_ofdm_tx_init(&ssss_ifft, cp, q->input_pad_freq, q->input_pad_time, nof_prb)) { printf("Error creating iFFT object\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - srslte_ofdm_set_normalize(&ssss_ifft, true); - srslte_ofdm_set_freq_shift(&ssss_ifft, 0.5); + srsran_ofdm_set_normalize(&ssss_ifft, true); + srsran_ofdm_set_freq_shift(&ssss_ifft, 0.5); - q->ssss_sf_freq = srslte_vec_malloc(sizeof(cf_t*) * SRSLTE_SSSS_NOF_SEQ); + q->ssss_sf_freq = srsran_vec_malloc(sizeof(cf_t*) * SRSRAN_SSSS_NOF_SEQ); if (!q->ssss_sf_freq) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - for (int i = 0; i < SRSLTE_SSSS_NOF_SEQ; ++i) { - q->ssss_sf_freq[i] = srslte_vec_cf_malloc(ssss_n_samples); + for (int i = 0; i < SRSRAN_SSSS_NOF_SEQ; ++i) { + q->ssss_sf_freq[i] = srsran_vec_cf_malloc(ssss_n_samples); if (!q->ssss_sf_freq[i]) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } - for (int i = 0; i < SRSLTE_SSSS_NOF_SEQ; ++i) { - srslte_vec_cf_zero(q->input_pad_freq, ssss_n_samples); - srslte_vec_cf_zero(q->input_pad_time, ssss_n_samples); - srslte_vec_cf_zero(q->ssss_sf_freq[i], ssss_n_samples); + for (int i = 0; i < SRSRAN_SSSS_NOF_SEQ; ++i) { + srsran_vec_cf_zero(q->input_pad_freq, ssss_n_samples); + srsran_vec_cf_zero(q->input_pad_time, ssss_n_samples); + srsran_vec_cf_zero(q->ssss_sf_freq[i], ssss_n_samples); - srslte_ssss_put_sf_buffer(q->ssss_signal[i], q->input_pad_freq, nof_prb, cp); - srslte_ofdm_tx_sf(&ssss_ifft); + srsran_ssss_put_sf_buffer(q->ssss_signal[i], q->input_pad_freq, nof_prb, cp); + srsran_ofdm_tx_sf(&ssss_ifft); - srslte_dft_run_c(&q->plan_input, &q->input_pad_time[ssss_start], q->ssss_sf_freq[i]); - srslte_vec_conj_cc(q->ssss_sf_freq[i], q->ssss_sf_freq[i], ssss_n_samples); + srsran_dft_run_c(&q->plan_input, &q->input_pad_time[ssss_start], q->ssss_sf_freq[i]); + srsran_vec_conj_cc(q->ssss_sf_freq[i], q->ssss_sf_freq[i], ssss_n_samples); } - srslte_ofdm_tx_free(&ssss_ifft); + srsran_ofdm_tx_free(&ssss_ifft); - q->dot_prod_output = srslte_vec_cf_malloc(ssss_n_samples); + q->dot_prod_output = srsran_vec_cf_malloc(ssss_n_samples); if (!q->dot_prod_output) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - q->dot_prod_output_time = srslte_vec_cf_malloc(ssss_n_samples); + q->dot_prod_output_time = srsran_vec_cf_malloc(ssss_n_samples); if (!q->dot_prod_output_time) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - q->shifted_output = srslte_vec_cf_malloc(ssss_n_samples); + q->shifted_output = srsran_vec_cf_malloc(ssss_n_samples); if (!q->shifted_output) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } memset(q->shifted_output, 0, sizeof(cf_t) * ssss_n_samples); - q->shifted_output_abs = srslte_vec_f_malloc(ssss_n_samples); + q->shifted_output_abs = srsran_vec_f_malloc(ssss_n_samples); if (!q->shifted_output_abs) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } memset(q->shifted_output_abs, 0, sizeof(float) * ssss_n_samples); - if (srslte_dft_plan(&q->plan_out, ssss_n_samples, SRSLTE_DFT_BACKWARD, SRSLTE_DFT_COMPLEX)) { - return SRSLTE_ERROR; + if (srsran_dft_plan(&q->plan_out, ssss_n_samples, SRSRAN_DFT_BACKWARD, SRSRAN_DFT_COMPLEX)) { + return SRSRAN_ERROR; } - srslte_dft_plan_set_dc(&q->plan_out, true); - srslte_dft_plan_set_norm(&q->plan_out, true); - // srslte_dft_plan_set_mirror(&q->plan_out, true); + srsran_dft_plan_set_dc(&q->plan_out, true); + srsran_dft_plan_set_norm(&q->plan_out, true); + // srsran_dft_plan_set_mirror(&q->plan_out, true); - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } @@ -134,15 +134,15 @@ int srslte_ssss_init(srslte_ssss_t* q, uint32_t nof_prb, srslte_cp_t cp, srslte_ /** * Reference: 3GPP TS 36.211 version 15.6.0 Release 15 Sec. 9.7.2.1 */ -void srslte_ssss_generate(float* ssss_signal, uint32_t N_sl_id, srslte_sl_tm_t tm) +void srsran_ssss_generate(float* ssss_signal, uint32_t N_sl_id, srsran_sl_tm_t tm) { uint32_t id1 = N_sl_id % 168; uint32_t id2 = N_sl_id / 168; uint32_t m0; uint32_t m1; - int s_t[SRSLTE_SSSS_N], c_t[SRSLTE_SSSS_N], z_t[SRSLTE_SSSS_N]; - int s0[SRSLTE_SSSS_N], s1[SRSLTE_SSSS_N], c0[SRSLTE_SSSS_N], c1[SRSLTE_SSSS_N], z1_0[SRSLTE_SSSS_N], - z1_1[SRSLTE_SSSS_N]; + int s_t[SRSRAN_SSSS_N], c_t[SRSRAN_SSSS_N], z_t[SRSRAN_SSSS_N]; + int s0[SRSRAN_SSSS_N], s1[SRSRAN_SSSS_N], c0[SRSRAN_SSSS_N], c1[SRSRAN_SSSS_N], z1_0[SRSRAN_SSSS_N], + z1_1[SRSRAN_SSSS_N]; generate_m0m1(id1, &m0, &m1); generate_zsc_tilde(z_t, s_t, c_t); @@ -158,13 +158,13 @@ void srslte_ssss_generate(float* ssss_signal, uint32_t N_sl_id, srslte_sl_tm_t t // Transmission mode 1 and 2 uses only "subframe 0 sequence" in two symbols on subframe 0 depending on cp // Transmission mode 3 and 4 uses only "subframe 5 sequence" in two symbols on subframe 0 depending on cp - if (tm == SRSLTE_SIDELINK_TM1 || tm == SRSLTE_SIDELINK_TM2) { - for (uint32_t i = 0; i < SRSLTE_SSSS_N; i++) { + if (tm == SRSRAN_SIDELINK_TM1 || tm == SRSRAN_SIDELINK_TM2) { + for (uint32_t i = 0; i < SRSRAN_SSSS_N; i++) { ssss_signal[2 * i] = (float)(s0[i] * c0[i]); ssss_signal[2 * i + 1] = (float)(s1[i] * c1[i] * z1_0[i]); } - } else if (tm == SRSLTE_SIDELINK_TM3 || tm == SRSLTE_SIDELINK_TM4) { - for (uint32_t i = 0; i < SRSLTE_SSSS_N; i++) { + } else if (tm == SRSRAN_SIDELINK_TM3 || tm == SRSRAN_SIDELINK_TM4) { + for (uint32_t i = 0; i < SRSRAN_SSSS_N; i++) { ssss_signal[2 * i] = (float)(s1[i] * c0[i]); ssss_signal[2 * i + 1] = (float)(s0[i] * c1[i] * z1_1[i]); } @@ -175,19 +175,19 @@ void srslte_ssss_generate(float* ssss_signal, uint32_t N_sl_id, srslte_sl_tm_t t * Mapping SSSS to resource elements * Reference: 3GPP TS 36.211 version 15.6.0 Release 15 Sec. 9.7.2.2 */ -void srslte_ssss_put_sf_buffer(float* ssss_signal, cf_t* sf_buffer, uint32_t nof_prb, srslte_cp_t cp) +void srsran_ssss_put_sf_buffer(float* ssss_signal, cf_t* sf_buffer, uint32_t nof_prb, srsran_cp_t cp) { // Normal cycle prefix l = 4,5 // Extended cycle prefix l = 3,4 - uint32_t slot1_pos = SRSLTE_CP_NSYMB(cp) * SRSLTE_NRE * nof_prb; + uint32_t slot1_pos = SRSRAN_CP_NSYMB(cp) * SRSRAN_NRE * nof_prb; for (int i = 0; i < 2; i++) { - uint32_t k = (SRSLTE_CP_NSYMB(cp) - 3 + i) * nof_prb * SRSLTE_NRE + nof_prb * SRSLTE_NRE / 2 - 31; - srslte_vec_cf_zero(&sf_buffer[slot1_pos + k - 5], 5); - for (int j = 0; j < SRSLTE_SSSS_LEN; j++) { + uint32_t k = (SRSRAN_CP_NSYMB(cp) - 3 + i) * nof_prb * SRSRAN_NRE + nof_prb * SRSRAN_NRE / 2 - 31; + srsran_vec_cf_zero(&sf_buffer[slot1_pos + k - 5], 5); + for (int j = 0; j < SRSRAN_SSSS_LEN; j++) { __real__ sf_buffer[slot1_pos + k + j] = ssss_signal[j]; __imag__ sf_buffer[slot1_pos + k + j] = 0; } - srslte_vec_cf_zero(&sf_buffer[slot1_pos + k + SRSLTE_SSSS_LEN], 5); + srsran_vec_cf_zero(&sf_buffer[slot1_pos + k + SRSRAN_SSSS_LEN], 5); } } @@ -198,41 +198,41 @@ void srslte_ssss_put_sf_buffer(float* ssss_signal, cf_t* sf_buffer, uint32_t nof * The value of the correlation is stored in corr_peak_value. * */ -int srslte_ssss_find(srslte_ssss_t* q, cf_t* input, uint32_t nof_prb, uint32_t N_id_2, srslte_cp_t cp) +int srsran_ssss_find(srsran_ssss_t* q, cf_t* input, uint32_t nof_prb, uint32_t N_id_2, srsran_cp_t cp) { // One array for each sequence - float corr_peak_value[SRSLTE_SSSS_NOF_SEQ] = {}; - uint32_t corr_peak_pos[SRSLTE_SSSS_NOF_SEQ] = {}; + float corr_peak_value[SRSRAN_SSSS_NOF_SEQ] = {}; + uint32_t corr_peak_pos[SRSRAN_SSSS_NOF_SEQ] = {}; - uint32_t symbol_sz = srslte_symbol_sz(nof_prb); - int cp_len = SRSLTE_CP_SZ(symbol_sz, cp); + uint32_t symbol_sz = srsran_symbol_sz(nof_prb); + int cp_len = SRSRAN_CP_SZ(symbol_sz, cp); uint32_t ssss_n_samples = (symbol_sz + cp_len) * 2 + cp_len; // We need an extra cp_len in order to get the peaks centered after the correlation - srslte_vec_cf_zero(q->input_pad_freq, ssss_n_samples); - srslte_vec_cf_zero(q->input_pad_time, ssss_n_samples); + srsran_vec_cf_zero(q->input_pad_freq, ssss_n_samples); + srsran_vec_cf_zero(q->input_pad_time, ssss_n_samples); // CP Normal: ssss (with its cp) starts at sample number: 11 symbol_sz + 2 CP_LEN_NORM_0 + 9 cp_len // CP Extended: ssss (with its cp) starts at sample number: 9 symbol_sz + 9 cp_len - uint32_t ssss_start = (cp == SRSLTE_CP_NORM) ? (symbol_sz * 11 + (SRSLTE_CP_LEN_NORM(0, symbol_sz) * 2 + cp_len * 9)) + uint32_t ssss_start = (cp == SRSRAN_CP_NORM) ? (symbol_sz * 11 + (SRSRAN_CP_LEN_NORM(0, symbol_sz) * 2 + cp_len * 9)) : ((symbol_sz + cp_len) * 9); memcpy(q->input_pad_time, &input[ssss_start], sizeof(cf_t) * ssss_n_samples); - srslte_dft_run_c(&q->plan_input, q->input_pad_time, q->input_pad_freq); + srsran_dft_run_c(&q->plan_input, q->input_pad_time, q->input_pad_freq); // 0-167 or 168-335 for (int i = (168 * N_id_2); i < (168 * (N_id_2 + 1)); i++) { - srslte_vec_prod_ccc(q->ssss_sf_freq[i], q->input_pad_freq, q->dot_prod_output, ssss_n_samples); + srsran_vec_prod_ccc(q->ssss_sf_freq[i], q->input_pad_freq, q->dot_prod_output, ssss_n_samples); - srslte_dft_run_c(&q->plan_out, q->dot_prod_output, q->dot_prod_output_time); + srsran_dft_run_c(&q->plan_out, q->dot_prod_output, q->dot_prod_output_time); memcpy(q->shifted_output, &q->dot_prod_output_time[ssss_n_samples / 2], sizeof(cf_t) * ssss_n_samples / 2); memcpy(&q->shifted_output[ssss_n_samples / 2], q->dot_prod_output_time, sizeof(cf_t) * ssss_n_samples / 2); q->corr_peak_pos = -1; - srslte_vec_abs_square_cf(q->shifted_output, q->shifted_output_abs, ssss_n_samples); + srsran_vec_abs_square_cf(q->shifted_output, q->shifted_output_abs, ssss_n_samples); // Correlation output peaks: // @@ -244,16 +244,16 @@ int srslte_ssss_find(srslte_ssss_t* q, cf_t* input, uint32_t nof_prb, uint32_t N // side peak main peak side peak // Find the main peak - q->corr_peak_pos = srslte_vec_max_fi(q->shifted_output_abs, ssss_n_samples); + q->corr_peak_pos = srsran_vec_max_fi(q->shifted_output_abs, ssss_n_samples); q->corr_peak_value = q->shifted_output_abs[q->corr_peak_pos]; if ((q->corr_peak_pos < ssss_n_samples / 2) || (q->corr_peak_pos > ssss_n_samples / 2)) { q->corr_peak_pos = -1; continue; } - srslte_vec_f_zero(&q->shifted_output_abs[q->corr_peak_pos - (symbol_sz / 2)], symbol_sz); + srsran_vec_f_zero(&q->shifted_output_abs[q->corr_peak_pos - (symbol_sz / 2)], symbol_sz); // Find the first side peak - uint32_t peak_1_pos = srslte_vec_max_fi(q->shifted_output_abs, ssss_n_samples); + uint32_t peak_1_pos = srsran_vec_max_fi(q->shifted_output_abs, ssss_n_samples); float peak_1_value = q->shifted_output_abs[peak_1_pos]; if ((peak_1_pos >= (q->corr_peak_pos - (symbol_sz + cp_len) - 2)) && (peak_1_pos <= (q->corr_peak_pos - (symbol_sz + cp_len) + 2))) { @@ -263,10 +263,10 @@ int srslte_ssss_find(srslte_ssss_t* q, cf_t* input, uint32_t nof_prb, uint32_t N q->corr_peak_pos = -1; continue; } - srslte_vec_f_zero(&q->shifted_output_abs[peak_1_pos - ((cp_len - 2) / 2)], cp_len - 2); + srsran_vec_f_zero(&q->shifted_output_abs[peak_1_pos - ((cp_len - 2) / 2)], cp_len - 2); // Find the second side peak - uint32_t peak_2_pos = srslte_vec_max_fi(q->shifted_output_abs, ssss_n_samples); + uint32_t peak_2_pos = srsran_vec_max_fi(q->shifted_output_abs, ssss_n_samples); float peak_2_value = q->shifted_output_abs[peak_2_pos]; if ((peak_2_pos >= (q->corr_peak_pos - (symbol_sz + cp_len) - 2)) && (peak_2_pos <= (q->corr_peak_pos - (symbol_sz + cp_len) + 2))) { @@ -276,7 +276,7 @@ int srslte_ssss_find(srslte_ssss_t* q, cf_t* input, uint32_t nof_prb, uint32_t N q->corr_peak_pos = -1; continue; } - srslte_vec_f_zero(&q->shifted_output_abs[peak_2_pos - ((cp_len - 2) / 2)], cp_len - 2); + srsran_vec_f_zero(&q->shifted_output_abs[peak_2_pos - ((cp_len - 2) / 2)], cp_len - 2); float threshold_above = q->corr_peak_value / 2.0 * 1.6; if ((peak_1_value > threshold_above) || (peak_2_value > threshold_above)) { @@ -294,22 +294,22 @@ int srslte_ssss_find(srslte_ssss_t* q, cf_t* input, uint32_t nof_prb, uint32_t N corr_peak_pos[i] = q->corr_peak_pos; } - q->N_sl_id = srslte_vec_max_fi(corr_peak_value, SRSLTE_SSSS_NOF_SEQ); + q->N_sl_id = srsran_vec_max_fi(corr_peak_value, SRSRAN_SSSS_NOF_SEQ); if (corr_peak_value[q->N_sl_id] == 0.0) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } q->corr_peak_pos = corr_peak_pos[q->N_sl_id]; q->corr_peak_value = corr_peak_value[q->N_sl_id]; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -void srslte_ssss_free(srslte_ssss_t* q) +void srsran_ssss_free(srsran_ssss_t* q) { if (q) { - srslte_dft_plan_free(&q->plan_input); - srslte_dft_plan_free(&q->plan_out); + srsran_dft_plan_free(&q->plan_input); + srsran_dft_plan_free(&q->plan_out); if (q->shifted_output) { free(q->shifted_output); } @@ -329,7 +329,7 @@ void srslte_ssss_free(srslte_ssss_t* q) free(q->input_pad_time); } if (q->ssss_sf_freq) { - for (int N_sl_id = 0; N_sl_id < SRSLTE_SSSS_NOF_SEQ; ++N_sl_id) { + for (int N_sl_id = 0; N_sl_id < SRSRAN_SSSS_NOF_SEQ; ++N_sl_id) { if (q->ssss_sf_freq[N_sl_id]) { free(q->ssss_sf_freq[N_sl_id]); } @@ -337,6 +337,6 @@ void srslte_ssss_free(srslte_ssss_t* q) free(q->ssss_sf_freq); } - bzero(q, sizeof(srslte_ssss_t)); + bzero(q, sizeof(srsran_ssss_t)); } } \ No newline at end of file diff --git a/lib/src/phy/sync/sync.c b/lib/src/phy/sync/sync.c index 90f10039d..40faf3227 100644 --- a/lib/src/phy/sync/sync.c +++ b/lib/src/phy/sync/sync.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,17 +10,17 @@ * */ -#include "srslte/srslte.h" +#include "srsran/srsran.h" #include #include #include #include -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/sync/cfo.h" -#include "srslte/phy/sync/sync.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/sync/cfo.h" +#include "srsran/phy/sync/sync.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" #define CFO_EMA_ALPHA 0.1 #define CP_EMA_ALPHA 0.1 @@ -31,24 +31,24 @@ static bool fft_size_isvalid(uint32_t fft_size) { - if (fft_size >= SRSLTE_SYNC_FFT_SZ_MIN && fft_size <= SRSLTE_SYNC_FFT_SZ_MAX && (fft_size % 64) == 0) { + if (fft_size >= SRSRAN_SYNC_FFT_SZ_MIN && fft_size <= SRSRAN_SYNC_FFT_SZ_MAX && (fft_size % 64) == 0) { return true; } else { return false; } } -int srslte_sync_init(srslte_sync_t* q, uint32_t frame_size, uint32_t max_offset, uint32_t fft_size) +int srsran_sync_init(srsran_sync_t* q, uint32_t frame_size, uint32_t max_offset, uint32_t fft_size) { - return srslte_sync_init_decim(q, frame_size, max_offset, fft_size, 1); + return srsran_sync_init_decim(q, frame_size, max_offset, fft_size, 1); } -int srslte_sync_init_decim(srslte_sync_t* q, uint32_t frame_size, uint32_t max_offset, uint32_t fft_size, int decimate) +int srsran_sync_init_decim(srsran_sync_t* q, uint32_t frame_size, uint32_t max_offset, uint32_t fft_size, int decimate) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL && fft_size_isvalid(fft_size)) { - ret = SRSLTE_ERROR; - bzero(q, sizeof(srslte_sync_t)); + ret = SRSRAN_ERROR; + bzero(q, sizeof(srsran_sync_t)); q->N_id_2 = 1000; q->N_id_1 = 1000; @@ -70,93 +70,93 @@ int srslte_sync_init_decim(srslte_sync_t* q, uint32_t frame_size, uint32_t max_o q->max_offset = max_offset; q->max_frame_size = frame_size; - srslte_sync_cfo_reset(q, 0.0f); + srsran_sync_cfo_reset(q, 0.0f); - if (srslte_cfo_init(&q->cfo_corr_frame, q->frame_size)) { + if (srsran_cfo_init(&q->cfo_corr_frame, q->frame_size)) { ERROR("Error initiating CFO"); goto clean_exit; } - if (srslte_cfo_init(&q->cfo_corr_symbol, q->fft_size)) { + if (srsran_cfo_init(&q->cfo_corr_symbol, q->fft_size)) { ERROR("Error initiating CFO"); goto clean_exit; } // Set default CFO tolerance - srslte_sync_set_cfo_tol(q, DEFAULT_CFO_TOL); + srsran_sync_set_cfo_tol(q, DEFAULT_CFO_TOL); for (int i = 0; i < 2; i++) { - q->cfo_i_corr[i] = srslte_vec_cf_malloc(q->frame_size); + q->cfo_i_corr[i] = srsran_vec_cf_malloc(q->frame_size); if (!q->cfo_i_corr[i]) { perror("malloc"); goto clean_exit; } } - q->temp = srslte_vec_cf_malloc(2 * q->frame_size); + q->temp = srsran_vec_cf_malloc(2 * q->frame_size); if (!q->temp) { perror("malloc"); goto clean_exit; } - srslte_sync_set_cp(q, SRSLTE_CP_NORM); + srsran_sync_set_cp(q, SRSRAN_CP_NORM); q->decimate = decimate; if (!decimate) { decimate = 1; } - if (srslte_dft_plan(&q->idftp_sss, fft_size, SRSLTE_DFT_BACKWARD, SRSLTE_DFT_COMPLEX)) { + if (srsran_dft_plan(&q->idftp_sss, fft_size, SRSRAN_DFT_BACKWARD, SRSRAN_DFT_COMPLEX)) { ERROR("Error creating DFT plan "); goto clean_exit; } - srslte_dft_plan_set_mirror(&q->idftp_sss, true); - srslte_dft_plan_set_dc(&q->idftp_sss, true); - srslte_dft_plan_set_norm(&q->idftp_sss, false); + srsran_dft_plan_set_mirror(&q->idftp_sss, true); + srsran_dft_plan_set_dc(&q->idftp_sss, true); + srsran_dft_plan_set_norm(&q->idftp_sss, false); - if (srslte_pss_init_fft_offset_decim(&q->pss, max_offset, fft_size, 0, decimate)) { + if (srsran_pss_init_fft_offset_decim(&q->pss, max_offset, fft_size, 0, decimate)) { ERROR("Error initializing PSS object"); goto clean_exit; } - if (srslte_sss_init(&q->sss, fft_size)) { + if (srsran_sss_init(&q->sss, fft_size)) { ERROR("Error initializing SSS object"); goto clean_exit; } - if (srslte_cp_synch_init(&q->cp_synch, fft_size)) { + if (srsran_cp_synch_init(&q->cp_synch, fft_size)) { ERROR("Error initiating CFO"); goto clean_exit; } DEBUG("SYNC init with frame_size=%d, max_offset=%d and fft_size=%d", frame_size, max_offset, fft_size); - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } else { ERROR("Invalid parameters frame_size: %d, fft_size: %d", frame_size, fft_size); } clean_exit: - if (ret == SRSLTE_ERROR) { - srslte_sync_free(q); + if (ret == SRSRAN_ERROR) { + srsran_sync_free(q); } return ret; } -void srslte_sync_free(srslte_sync_t* q) +void srsran_sync_free(srsran_sync_t* q) { if (q) { - srslte_pss_free(&q->pss); - srslte_sss_free(&q->sss); - srslte_cfo_free(&q->cfo_corr_frame); - srslte_cfo_free(&q->cfo_corr_symbol); - srslte_cp_synch_free(&q->cp_synch); + srsran_pss_free(&q->pss); + srsran_sss_free(&q->sss); + srsran_cfo_free(&q->cfo_corr_frame); + srsran_cfo_free(&q->cfo_corr_symbol); + srsran_cp_synch_free(&q->cp_synch); - srslte_dft_plan_free(&q->idftp_sss); + srsran_dft_plan_free(&q->idftp_sss); for (int i = 0; i < 2; i++) { if (q->cfo_i_corr[i]) { free(q->cfo_i_corr[i]); } - srslte_pss_free(&q->pss_i[i]); + srsran_pss_free(&q->pss_i[i]); } if (q->temp) { @@ -165,53 +165,53 @@ void srslte_sync_free(srslte_sync_t* q) } } -int srslte_sync_resize(srslte_sync_t* q, uint32_t frame_size, uint32_t max_offset, uint32_t fft_size) +int srsran_sync_resize(srsran_sync_t* q, uint32_t frame_size, uint32_t max_offset, uint32_t fft_size) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL && fft_size_isvalid(fft_size)) { if (frame_size > q->max_frame_size) { ERROR("Error in sync_resize(): frame_size must be lower than initialized"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } q->fft_size = fft_size; q->frame_size = frame_size; q->max_offset = max_offset; - if (srslte_pss_resize(&q->pss, q->max_offset, q->fft_size, 0)) { + if (srsran_pss_resize(&q->pss, q->max_offset, q->fft_size, 0)) { ERROR("Error resizing PSS object"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_sss_resize(&q->sss, q->fft_size)) { + if (srsran_sss_resize(&q->sss, q->fft_size)) { ERROR("Error resizing SSS object"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_dft_replan(&q->idftp_sss, fft_size)) { + if (srsran_dft_replan(&q->idftp_sss, fft_size)) { ERROR("Error resizing DFT plan "); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_cp_synch_resize(&q->cp_synch, q->fft_size)) { + if (srsran_cp_synch_resize(&q->cp_synch, q->fft_size)) { ERROR("Error resizing CFO"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_cfo_resize(&q->cfo_corr_frame, q->frame_size)) { + if (srsran_cfo_resize(&q->cfo_corr_frame, q->frame_size)) { ERROR("Error resizing CFO"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_cfo_resize(&q->cfo_corr_symbol, q->fft_size)) { + if (srsran_cfo_resize(&q->cfo_corr_symbol, q->fft_size)) { ERROR("Error resizing CFO"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (q->cfo_i_initiated) { for (int i = 0; i < 2; i++) { int offset = (i == 0) ? -1 : 1; - if (srslte_pss_resize(&q->pss_i[i], q->max_offset, q->fft_size, offset)) { + if (srsran_pss_resize(&q->pss_i[i], q->max_offset, q->fft_size, offset)) { ERROR("Error initializing PSS object"); } for (int t = 0; t < q->frame_size; t++) { @@ -221,11 +221,11 @@ int srslte_sync_resize(srslte_sync_t* q, uint32_t frame_size, uint32_t max_offse } // Update CFO tolerance - srslte_sync_set_cfo_tol(q, q->current_cfo_tol); + srsran_sync_set_cfo_tol(q, q->current_cfo_tol); DEBUG("SYNC init with frame_size=%d, max_offset=%d and fft_size=%d", frame_size, max_offset, fft_size); - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } else { ERROR("Invalid parameters frame_size: %d, fft_size: %d", frame_size, fft_size); } @@ -233,110 +233,110 @@ int srslte_sync_resize(srslte_sync_t* q, uint32_t frame_size, uint32_t max_offse return ret; } -void srslte_sync_set_frame_type(srslte_sync_t* q, srslte_frame_type_t frame_type) +void srsran_sync_set_frame_type(srsran_sync_t* q, srsran_frame_type_t frame_type) { q->frame_type = frame_type; q->detect_frame_type = false; } -void srslte_sync_set_cfo_tol(srslte_sync_t* q, float tol) +void srsran_sync_set_cfo_tol(srsran_sync_t* q, float tol) { q->current_cfo_tol = tol; - srslte_cfo_set_tol(&q->cfo_corr_frame, tol / (15000.0 * q->fft_size)); - srslte_cfo_set_tol(&q->cfo_corr_symbol, tol / (15000.0 * q->fft_size)); + srsran_cfo_set_tol(&q->cfo_corr_frame, tol / (15000.0 * q->fft_size)); + srsran_cfo_set_tol(&q->cfo_corr_symbol, tol / (15000.0 * q->fft_size)); } -void srslte_sync_set_threshold(srslte_sync_t* q, float threshold) +void srsran_sync_set_threshold(srsran_sync_t* q, float threshold) { q->threshold = threshold; } -void srslte_sync_sss_en(srslte_sync_t* q, bool enabled) +void srsran_sync_sss_en(srsran_sync_t* q, bool enabled) { q->sss_en = enabled; } -bool srslte_sync_sss_detected(srslte_sync_t* q) +bool srsran_sync_sss_detected(srsran_sync_t* q) { return q->sss_detected; } -float srslte_sync_sss_correlation_peak(srslte_sync_t* q) +float srsran_sync_sss_correlation_peak(srsran_sync_t* q) { return q->sss_corr; } -bool srslte_sync_sss_available(srslte_sync_t* q) +bool srsran_sync_sss_available(srsran_sync_t* q) { return q->sss_available; } -int srslte_sync_get_cell_id(srslte_sync_t* q) +int srsran_sync_get_cell_id(srsran_sync_t* q) { - if (srslte_N_id_2_isvalid(q->N_id_2) && srslte_N_id_1_isvalid(q->N_id_1)) { + if (srsran_N_id_2_isvalid(q->N_id_2) && srsran_N_id_1_isvalid(q->N_id_1)) { return q->N_id_1 * 3 + q->N_id_2; } else { return -1; } } -int srslte_sync_set_N_id_2(srslte_sync_t* q, uint32_t N_id_2) +int srsran_sync_set_N_id_2(srsran_sync_t* q, uint32_t N_id_2) { - if (srslte_N_id_2_isvalid(N_id_2)) { + if (srsran_N_id_2_isvalid(N_id_2)) { q->N_id_2 = N_id_2; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } else { ERROR("Invalid N_id_2=%d", N_id_2); - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } } -static void generate_freq_sss(srslte_sync_t* q, uint32_t N_id_1) +static void generate_freq_sss(srsran_sync_t* q, uint32_t N_id_1) { - float sf[2][SRSLTE_SSS_LEN]; - cf_t symbol[SRSLTE_SYMBOL_SZ_MAX]; + float sf[2][SRSRAN_SSS_LEN]; + cf_t symbol[SRSRAN_SYMBOL_SZ_MAX]; q->N_id_1 = N_id_1; uint32_t cell_id = q->N_id_1 * 3 + q->N_id_2; - srslte_sss_generate(sf[0], sf[1], cell_id); + srsran_sss_generate(sf[0], sf[1], cell_id); uint32_t k = q->fft_size / 2 - 31; for (int n = 0; n < 2; n++) { - srslte_vec_cf_zero(symbol, q->fft_size); - for (uint32_t i = 0; i < SRSLTE_SSS_LEN; i++) { + srsran_vec_cf_zero(symbol, q->fft_size); + for (uint32_t i = 0; i < SRSRAN_SSS_LEN; i++) { __real__ symbol[k + i] = sf[n][i]; __imag__ symbol[k + i] = 0; } // Get freq-domain version of the SSS signal - srslte_dft_run_c(&q->idftp_sss, symbol, q->sss_signal[n]); + srsran_dft_run_c(&q->idftp_sss, symbol, q->sss_signal[n]); } q->sss_generated = true; DEBUG("Generated SSS for N_id_1=%d, cell_id=%d", N_id_1, cell_id); } -int srslte_sync_set_N_id_1(srslte_sync_t* q, uint32_t N_id_1) +int srsran_sync_set_N_id_1(srsran_sync_t* q, uint32_t N_id_1) { - if (srslte_N_id_1_isvalid(N_id_1)) { + if (srsran_N_id_1_isvalid(N_id_1)) { generate_freq_sss(q, N_id_1); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } else { ERROR("Invalid N_id_2=%d", N_id_1); - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } } -uint32_t srslte_sync_get_sf_idx(srslte_sync_t* q) +uint32_t srsran_sync_get_sf_idx(srsran_sync_t* q) { return q->sf_idx; } -float srslte_sync_get_cfo(srslte_sync_t* q) +float srsran_sync_get_cfo(srsran_sync_t* q) { return q->cfo_cp_mean + q->cfo_pss_mean + q->cfo_i_value; } -void srslte_sync_cfo_reset(srslte_sync_t* q, float init_cfo_hz) +void srsran_sync_cfo_reset(srsran_sync_t* q, float init_cfo_hz) { q->cfo_cp_mean = init_cfo_hz / 15e3f; q->cfo_cp_is_set = false; @@ -344,7 +344,7 @@ void srslte_sync_cfo_reset(srslte_sync_t* q, float init_cfo_hz) q->cfo_pss_is_set = false; } -void srslte_sync_copy_cfo(srslte_sync_t* q, srslte_sync_t* src_obj) +void srsran_sync_copy_cfo(srsran_sync_t* q, srsran_sync_t* src_obj) { q->cfo_cp_mean = src_obj->cfo_cp_mean; q->cfo_pss_mean = src_obj->cfo_pss_mean; @@ -353,13 +353,13 @@ void srslte_sync_copy_cfo(srslte_sync_t* q, srslte_sync_t* src_obj) q->cfo_pss_is_set = false; } -void srslte_sync_set_cfo_i_enable(srslte_sync_t* q, bool enable) +void srsran_sync_set_cfo_i_enable(srsran_sync_t* q, bool enable) { q->cfo_i_enable = enable; if (q->cfo_i_enable && !q->cfo_i_initiated) { for (int i = 0; i < 2; i++) { int offset = (i == 0) ? -1 : 1; - if (srslte_pss_init_fft_offset(&q->pss_i[i], q->max_offset, q->fft_size, offset)) { + if (srsran_pss_init_fft_offset(&q->pss_i[i], q->max_offset, q->fft_size, offset)) { ERROR("Error initializing PSS object"); } for (int t = 0; t < q->frame_size; t++) { @@ -370,7 +370,7 @@ void srslte_sync_set_cfo_i_enable(srslte_sync_t* q, bool enable) } } -void srslte_sync_set_sss_eq_enable(srslte_sync_t* q, bool enable) +void srsran_sync_set_sss_eq_enable(srsran_sync_t* q, bool enable) { q->sss_channel_equalize = enable; if (enable) { @@ -379,50 +379,50 @@ void srslte_sync_set_sss_eq_enable(srslte_sync_t* q, bool enable) } } -void srslte_sync_set_pss_filt_enable(srslte_sync_t* q, bool enable) +void srsran_sync_set_pss_filt_enable(srsran_sync_t* q, bool enable) { q->pss_filtering_enabled = enable; } -void srslte_sync_set_cfo_cp_enable(srslte_sync_t* q, bool enable, uint32_t nof_symbols) +void srsran_sync_set_cfo_cp_enable(srsran_sync_t* q, bool enable, uint32_t nof_symbols) { q->cfo_cp_enable = enable; q->cfo_cp_nsymbols = nof_symbols; } -void srslte_sync_set_cfo_pss_enable(srslte_sync_t* q, bool enable) +void srsran_sync_set_cfo_pss_enable(srsran_sync_t* q, bool enable) { q->cfo_pss_enable = enable; } -void srslte_sync_set_cfo_ema_alpha(srslte_sync_t* q, float alpha) +void srsran_sync_set_cfo_ema_alpha(srsran_sync_t* q, float alpha) { q->cfo_ema_alpha = alpha; } -float srslte_sync_get_peak_value(srslte_sync_t* q) +float srsran_sync_get_peak_value(srsran_sync_t* q) { return q->peak_value; } -void srslte_sync_cp_en(srslte_sync_t* q, bool enabled) +void srsran_sync_cp_en(srsran_sync_t* q, bool enabled) { q->detect_cp = enabled; } -void srslte_sync_set_em_alpha(srslte_sync_t* q, float alpha) +void srsran_sync_set_em_alpha(srsran_sync_t* q, float alpha) { - srslte_pss_set_ema_alpha(&q->pss, alpha); + srsran_pss_set_ema_alpha(&q->pss, alpha); } -srslte_cp_t srslte_sync_get_cp(srslte_sync_t* q) +srsran_cp_t srsran_sync_get_cp(srsran_sync_t* q) { return q->cp; } -void srslte_sync_set_cp(srslte_sync_t* q, srslte_cp_t cp) +void srsran_sync_set_cp(srsran_sync_t* q, srsran_cp_t cp) { q->cp = cp; - q->cp_len = SRSLTE_CP_ISNORM(q->cp) ? SRSLTE_CP_LEN_NORM(1, q->fft_size) : SRSLTE_CP_LEN_EXT(q->fft_size); + q->cp_len = SRSRAN_CP_ISNORM(q->cp) ? SRSRAN_CP_LEN_NORM(1, q->fft_size) : SRSRAN_CP_LEN_EXT(q->fft_size); if (q->frame_size < q->fft_size) { q->nof_symbols = 1; } else { @@ -430,7 +430,7 @@ void srslte_sync_set_cp(srslte_sync_t* q, srslte_cp_t cp) } } -void srslte_sync_set_sss_algorithm(srslte_sync_t* q, sss_alg_t alg) +void srsran_sync_set_sss_algorithm(srsran_sync_t* q, sss_alg_t alg) { q->sss_alg = alg; } @@ -439,13 +439,13 @@ void srslte_sync_set_sss_algorithm(srslte_sync_t* q, sss_alg_t alg) * "SSS Detection Method for Initial Cell Search in 3GPP LTE FDD/TDD Dual Mode Receiver" * by Jung-In Kim et al. */ -srslte_cp_t srslte_sync_detect_cp(srslte_sync_t* q, const cf_t* input, uint32_t peak_pos) +srsran_cp_t srsran_sync_detect_cp(srsran_sync_t* q, const cf_t* input, uint32_t peak_pos) { float R_norm = 0, R_ext = 0, C_norm = 0, C_ext = 0; float M_norm = 0, M_ext = 0; - uint32_t cp_norm_len = SRSLTE_CP_LEN_NORM(7, q->fft_size); - uint32_t cp_ext_len = SRSLTE_CP_LEN_EXT(q->fft_size); + uint32_t cp_norm_len = SRSRAN_CP_LEN_NORM(7, q->fft_size); + uint32_t cp_ext_len = SRSRAN_CP_LEN_EXT(q->fft_size); uint32_t nof_symbols = peak_pos / (q->fft_size + cp_ext_len); @@ -458,61 +458,61 @@ srslte_cp_t srslte_sync_detect_cp(srslte_sync_t* q, const cf_t* input, uint32_t const cf_t* input_cp_ext = &input[peak_pos - nof_symbols * (q->fft_size + cp_ext_len)]; for (int i = 0; i < nof_symbols; i++) { - R_norm += crealf(srslte_vec_dot_prod_conj_ccc(&input_cp_norm[q->fft_size], input_cp_norm, cp_norm_len)); - C_norm += cp_norm_len * srslte_vec_avg_power_cf(input_cp_norm, cp_norm_len); + R_norm += crealf(srsran_vec_dot_prod_conj_ccc(&input_cp_norm[q->fft_size], input_cp_norm, cp_norm_len)); + C_norm += cp_norm_len * srsran_vec_avg_power_cf(input_cp_norm, cp_norm_len); input_cp_norm += q->fft_size + cp_norm_len; } if (C_norm > 0) { M_norm = R_norm / C_norm; } - q->M_norm_avg = SRSLTE_VEC_EMA(M_norm / nof_symbols, q->M_norm_avg, CP_EMA_ALPHA); + q->M_norm_avg = SRSRAN_VEC_EMA(M_norm / nof_symbols, q->M_norm_avg, CP_EMA_ALPHA); for (int i = 0; i < nof_symbols; i++) { - R_ext += crealf(srslte_vec_dot_prod_conj_ccc(&input_cp_ext[q->fft_size], input_cp_ext, cp_ext_len)); - C_ext += cp_ext_len * srslte_vec_avg_power_cf(input_cp_ext, cp_ext_len); + R_ext += crealf(srsran_vec_dot_prod_conj_ccc(&input_cp_ext[q->fft_size], input_cp_ext, cp_ext_len)); + C_ext += cp_ext_len * srsran_vec_avg_power_cf(input_cp_ext, cp_ext_len); input_cp_ext += q->fft_size + cp_ext_len; } if (C_ext > 0) { M_ext = R_ext / C_ext; } - q->M_ext_avg = SRSLTE_VEC_EMA(M_ext / nof_symbols, q->M_ext_avg, CP_EMA_ALPHA); + q->M_ext_avg = SRSRAN_VEC_EMA(M_ext / nof_symbols, q->M_ext_avg, CP_EMA_ALPHA); if (q->M_norm_avg > q->M_ext_avg) { - return SRSLTE_CP_NORM; + return SRSRAN_CP_NORM; } else if (q->M_norm_avg < q->M_ext_avg) { - return SRSLTE_CP_EXT; + return SRSRAN_CP_EXT; } else { if (R_norm > R_ext) { - return SRSLTE_CP_NORM; + return SRSRAN_CP_NORM; } else { - return SRSLTE_CP_EXT; + return SRSRAN_CP_EXT; } } } else { - return SRSLTE_CP_NORM; + return SRSRAN_CP_NORM; } } /* Returns 1 if the SSS is found, 0 if not and -1 if there is not enough space * to correlate */ -static bool sync_sss_symbol(srslte_sync_t* q, const cf_t* input, uint32_t* sf_idx, uint32_t* N_id_1, float* corr) +static bool sync_sss_symbol(srsran_sync_t* q, const cf_t* input, uint32_t* sf_idx, uint32_t* N_id_1, float* corr) { int ret; - srslte_sss_set_N_id_2(&q->sss, q->N_id_2); + srsran_sss_set_N_id_2(&q->sss, q->N_id_2); // If N_Id_1 is set and SSS generated, correlate with sf0 and sf5 signals to find sf boundaries if (q->sss_generated) { bool c = q->pss.chest_on_filter; q->pss.chest_on_filter = false; - srslte_pss_filter(&q->pss, input, q->sss_recv); + srsran_pss_filter(&q->pss, input, q->sss_recv); q->pss.chest_on_filter = c; float res[2]; for (int s = 0; s < 2; s++) { - res[s] = cabsf(srslte_vec_dot_prod_conj_ccc(q->sss_signal[s], q->sss_recv, q->fft_size)); + res[s] = cabsf(srsran_vec_dot_prod_conj_ccc(q->sss_signal[s], q->sss_recv, q->fft_size)); } float ratio; if (res[0] > res[1]) { @@ -538,57 +538,57 @@ static bool sync_sss_symbol(srslte_sync_t* q, const cf_t* input, uint32_t* sf_id } else { switch (q->sss_alg) { case SSS_DIFF: - srslte_sss_m0m1_diff(&q->sss, input, &q->m0, &q->m0_value, &q->m1, &q->m1_value); + srsran_sss_m0m1_diff(&q->sss, input, &q->m0, &q->m0_value, &q->m1, &q->m1_value); break; case SSS_PARTIAL_3: - srslte_sss_m0m1_partial(&q->sss, input, 3, NULL, &q->m0, &q->m0_value, &q->m1, &q->m1_value); + srsran_sss_m0m1_partial(&q->sss, input, 3, NULL, &q->m0, &q->m0_value, &q->m1, &q->m1_value); break; case SSS_FULL: - srslte_sss_m0m1_partial(&q->sss, input, 1, NULL, &q->m0, &q->m0_value, &q->m1, &q->m1_value); + srsran_sss_m0m1_partial(&q->sss, input, 1, NULL, &q->m0, &q->m0_value, &q->m1, &q->m1_value); break; } *corr = q->m0_value + q->m1_value; - *sf_idx = srslte_sss_subframe(q->m0, q->m1); - ret = srslte_sss_N_id_1(&q->sss, q->m0, q->m1, *corr); + *sf_idx = srsran_sss_subframe(q->m0, q->m1); + ret = srsran_sss_N_id_1(&q->sss, q->m0, q->m1, *corr); if (ret >= 0) { *N_id_1 = (uint32_t)ret; INFO("SSS detected N_id_1=%d (corr=%7.1f), sf_idx=%d, %s CP", *N_id_1, *corr, *sf_idx, - SRSLTE_CP_ISNORM(q->cp) ? "Normal" : "Extended"); + SRSRAN_CP_ISNORM(q->cp) ? "Normal" : "Extended"); return true; } } return false; } -srslte_pss_t* srslte_sync_get_cur_pss_obj(srslte_sync_t* q) +srsran_pss_t* srsran_sync_get_cur_pss_obj(srsran_sync_t* q) { - srslte_pss_t* pss_obj[3] = {&q->pss_i[0], &q->pss, &q->pss_i[1]}; + srsran_pss_t* pss_obj[3] = {&q->pss_i[0], &q->pss, &q->pss_i[1]}; return pss_obj[q->cfo_i_value + 1]; } -static float cfo_cp_estimate(srslte_sync_t* q, const cf_t* input) +static float cfo_cp_estimate(srsran_sync_t* q, const cf_t* input) { uint32_t cp_offset = 0; - cp_offset = srslte_cp_synch( - &q->cp_synch, input, q->max_offset, q->cfo_cp_nsymbols, (uint32_t)SRSLTE_CP_LEN_NORM(1, q->fft_size)); - cf_t cp_corr_max = srslte_cp_synch_corr_output(&q->cp_synch, cp_offset); + cp_offset = srsran_cp_synch( + &q->cp_synch, input, q->max_offset, q->cfo_cp_nsymbols, (uint32_t)SRSRAN_CP_LEN_NORM(1, q->fft_size)); + cf_t cp_corr_max = srsran_cp_synch_corr_output(&q->cp_synch, cp_offset); float cfo = -cargf(cp_corr_max) / ((float)M_PI * 2.0f); return cfo; } -static int cfo_i_estimate(srslte_sync_t* q, const cf_t* input, int find_offset, int* peak_pos, int* cfo_i) +static int cfo_i_estimate(srsran_sync_t* q, const cf_t* input, int find_offset, int* peak_pos, int* cfo_i) { float peak_value; float max_peak_value = -99; int max_cfo_i = 0; - srslte_pss_t* pss_obj[3] = {&q->pss_i[0], &q->pss, &q->pss_i[1]}; + srsran_pss_t* pss_obj[3] = {&q->pss_i[0], &q->pss, &q->pss_i[1]}; for (int cfo = 0; cfo < 3; cfo++) { - srslte_pss_set_N_id_2(pss_obj[cfo], q->N_id_2); - int p = srslte_pss_find_pss(pss_obj[cfo], &input[find_offset], &peak_value); + srsran_pss_set_N_id_2(pss_obj[cfo], q->N_id_2); + int p = srsran_pss_find_pss(pss_obj[cfo], &input[find_offset], &peak_value); if (p < 0) { return -1; } @@ -607,27 +607,27 @@ static int cfo_i_estimate(srslte_sync_t* q, const cf_t* input, int find_offset, return 0; } -/** Finds the PSS sequence previously defined by a call to srslte_sync_set_N_id_2() +/** Finds the PSS sequence previously defined by a call to srsran_sync_set_N_id_2() * around the position find_offset in the buffer input. * - * Returns 1 if the correlation peak exceeds the threshold set by srslte_sync_set_threshold() + * Returns 1 if the correlation peak exceeds the threshold set by srsran_sync_set_threshold() * or 0 otherwise. Returns a negative number on error (if N_id_2 has not been set) * * The input signal is not modified. Any CFO correction is done in internal buffers * * The maximum of the correlation peak is always stored in *peak_position */ -srslte_sync_find_ret_t -srslte_sync_find(srslte_sync_t* q, const cf_t* input, uint32_t find_offset, uint32_t* peak_position) +srsran_sync_find_ret_t +srsran_sync_find(srsran_sync_t* q, const cf_t* input, uint32_t find_offset, uint32_t* peak_position) { - srslte_sync_find_ret_t ret = SRSLTE_SYNC_ERROR; + srsran_sync_find_ret_t ret = SRSRAN_SYNC_ERROR; int peak_pos = 0; if (!q) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } - if (input != NULL && srslte_N_id_2_isvalid(q->N_id_2) && fft_size_isvalid(q->fft_size)) { + if (input != NULL && srsran_N_id_2_isvalid(q->N_id_2) && fft_size_isvalid(q->fft_size)) { q->sss_detected = false; if (peak_position) { @@ -643,11 +643,11 @@ srslte_sync_find(srslte_sync_t* q, const cf_t* input, uint32_t find_offset, uint if (q->cfo_i_enable) { if (cfo_i_estimate(q, input_ptr, find_offset, &peak_pos, &q->cfo_i_value) < 0) { ERROR("Error calling finding PSS sequence at : %d ", peak_pos); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Correct it using precomputed signal and store in buffer (don't modify input signal) if (q->cfo_i_value != 0) { - srslte_vec_prod_ccc((cf_t*)input_ptr, q->cfo_i_corr[q->cfo_i_value < 0 ? 0 : 1], q->temp, q->frame_size); + srsran_vec_prod_ccc((cf_t*)input_ptr, q->cfo_i_corr[q->cfo_i_value < 0 ? 0 : 1], q->temp, q->frame_size); INFO("Compensating cfo_i=%d", q->cfo_i_value); input_ptr = q->temp; } @@ -664,24 +664,24 @@ srslte_sync_find(srslte_sync_t* q, const cf_t* input, uint32_t find_offset, uint q->cfo_cp_is_set = true; } else { /* compute exponential moving average CFO */ - q->cfo_cp_mean = SRSLTE_VEC_EMA(cfo_cp, q->cfo_cp_mean, q->cfo_ema_alpha); + q->cfo_cp_mean = SRSRAN_VEC_EMA(cfo_cp, q->cfo_cp_mean, q->cfo_ema_alpha); } DEBUG("CP-CFO: estimated=%f, mean=%f", cfo_cp, q->cfo_cp_mean); /* Correct CFO with the averaged CFO estimation */ - srslte_cfo_correct(&q->cfo_corr_frame, input_ptr, q->temp, -q->cfo_cp_mean / q->fft_size); + srsran_cfo_correct(&q->cfo_corr_frame, input_ptr, q->temp, -q->cfo_cp_mean / q->fft_size); input_ptr = q->temp; } /* Find maximum of PSS correlation. If Integer CFO is enabled, correlation is already done */ if (!q->cfo_i_enable) { - srslte_pss_set_N_id_2(&q->pss, q->N_id_2); - peak_pos = srslte_pss_find_pss(&q->pss, &input_ptr[find_offset], q->threshold > 0 ? &q->peak_value : NULL); + srsran_pss_set_N_id_2(&q->pss, q->N_id_2); + peak_pos = srsran_pss_find_pss(&q->pss, &input_ptr[find_offset], q->threshold > 0 ? &q->peak_value : NULL); if (peak_pos < 0) { ERROR("Error calling finding PSS sequence at : %d ", peak_pos); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } @@ -703,17 +703,17 @@ srslte_sync_find(srslte_sync_t* q, const cf_t* input, uint32_t find_offset, uint // Filter central bands before PSS-based CFO estimation const cf_t* pss_ptr = &input_ptr[find_offset + peak_pos - q->fft_size]; if (q->pss_filtering_enabled) { - srslte_pss_filter(&q->pss, pss_ptr, q->pss_filt); + srsran_pss_filter(&q->pss, pss_ptr, q->pss_filt); pss_ptr = q->pss_filt; } // PSS-based CFO estimation - q->cfo_pss = srslte_pss_cfo_compute(&q->pss, pss_ptr); + q->cfo_pss = srsran_pss_cfo_compute(&q->pss, pss_ptr); if (!q->cfo_pss_is_set) { q->cfo_pss_mean = q->cfo_pss; q->cfo_pss_is_set = true; } else if (15000 * fabsf(q->cfo_pss) < MAX_CFO_PSS_OFFSET) { - q->cfo_pss_mean = SRSLTE_VEC_EMA(q->cfo_pss, q->cfo_pss_mean, q->cfo_ema_alpha); + q->cfo_pss_mean = SRSRAN_VEC_EMA(q->cfo_pss, q->cfo_pss_mean, q->cfo_ema_alpha); } DEBUG("PSS-CFO: filter=%s, estimated=%f, mean=%f", @@ -723,19 +723,19 @@ srslte_sync_find(srslte_sync_t* q, const cf_t* input, uint32_t find_offset, uint } // If there is enough space for CP and SSS estimation - if (peak_pos + find_offset >= 2 * (q->fft_size + SRSLTE_CP_LEN_EXT(q->fft_size))) { + if (peak_pos + find_offset >= 2 * (q->fft_size + SRSRAN_CP_LEN_EXT(q->fft_size))) { // If SSS search is enabled, correlate SSS sequence if (q->sss_en) { int sss_idx; uint32_t nof_frame_type_trials; - srslte_frame_type_t frame_type_trials[2]; + srsran_frame_type_t frame_type_trials[2]; float sss_corr[2] = {}; uint32_t sf_idx[2], N_id_1[2]; if (q->detect_frame_type) { nof_frame_type_trials = 2; - frame_type_trials[0] = SRSLTE_FDD; - frame_type_trials[1] = SRSLTE_TDD; + frame_type_trials[0] = SRSRAN_FDD; + frame_type_trials[1] = SRSRAN_TDD; } else { frame_type_trials[0] = q->frame_type; nof_frame_type_trials = 1; @@ -744,12 +744,12 @@ srslte_sync_find(srslte_sync_t* q, const cf_t* input, uint32_t find_offset, uint q->sss_available = true; q->sss_detected = false; for (uint32_t f = 0; f < nof_frame_type_trials; f++) { - if (frame_type_trials[f] == SRSLTE_FDD) { - sss_idx = (int)find_offset + peak_pos - 2 * SRSLTE_SYMBOL_SZ(q->fft_size, q->cp) + - SRSLTE_CP_SZ(q->fft_size, q->cp); + if (frame_type_trials[f] == SRSRAN_FDD) { + sss_idx = (int)find_offset + peak_pos - 2 * SRSRAN_SYMBOL_SZ(q->fft_size, q->cp) + + SRSRAN_CP_SZ(q->fft_size, q->cp); } else { - sss_idx = (int)find_offset + peak_pos - 4 * SRSLTE_SYMBOL_SZ(q->fft_size, q->cp) + - SRSLTE_CP_SZ(q->fft_size, q->cp); + sss_idx = (int)find_offset + peak_pos - 4 * SRSRAN_SYMBOL_SZ(q->fft_size, q->cp) + + SRSRAN_CP_SZ(q->fft_size, q->cp); ; } @@ -758,13 +758,13 @@ srslte_sync_find(srslte_sync_t* q, const cf_t* input, uint32_t find_offset, uint // Correct CFO if detected in PSS if (q->cfo_pss_enable) { - srslte_cfo_correct(&q->cfo_corr_symbol, sss_ptr, q->sss_filt, -q->cfo_pss_mean / q->fft_size); + srsran_cfo_correct(&q->cfo_corr_symbol, sss_ptr, q->sss_filt, -q->cfo_pss_mean / q->fft_size); // Equalize channel if estimated in PSS if (q->sss_channel_equalize && q->pss.chest_on_filter && q->pss_filtering_enabled) { - srslte_vec_prod_ccc(&q->sss_filt[q->fft_size / 2 - SRSLTE_PSS_LEN / 2], + srsran_vec_prod_ccc(&q->sss_filt[q->fft_size / 2 - SRSRAN_PSS_LEN / 2], q->pss.tmp_ce, - &q->sss_filt[q->fft_size / 2 - SRSLTE_PSS_LEN / 2], - SRSLTE_PSS_LEN); + &q->sss_filt[q->fft_size / 2 - SRSRAN_PSS_LEN / 2], + SRSRAN_PSS_LEN); } sss_ptr = q->sss_filt; } @@ -778,22 +778,22 @@ srslte_sync_find(srslte_sync_t* q, const cf_t* input, uint32_t find_offset, uint if (q->detect_frame_type) { if (sss_corr[0] > sss_corr[1]) { - q->frame_type = SRSLTE_FDD; + q->frame_type = SRSRAN_FDD; q->sf_idx = sf_idx[0]; q->N_id_1 = N_id_1[0]; q->sss_corr = sss_corr[0]; } else { - q->frame_type = SRSLTE_TDD; + q->frame_type = SRSRAN_TDD; q->sf_idx = sf_idx[1] + 1; q->N_id_1 = N_id_1[1]; q->sss_corr = sss_corr[1]; } DEBUG("SYNC: Detected SSS %s, corr=%.2f/%.2f", - q->frame_type == SRSLTE_FDD ? "FDD" : "TDD", + q->frame_type == SRSRAN_FDD ? "FDD" : "TDD", sss_corr[0], sss_corr[1]); } else if (q->sss_detected) { - if (q->frame_type == SRSLTE_FDD) { + if (q->frame_type == SRSRAN_FDD) { q->sf_idx = sf_idx[0]; } else { q->sf_idx = sf_idx[0] + 1; @@ -805,15 +805,15 @@ srslte_sync_find(srslte_sync_t* q, const cf_t* input, uint32_t find_offset, uint // Detect CP length if (q->detect_cp) { - srslte_sync_set_cp(q, srslte_sync_detect_cp(q, input_ptr, peak_pos + find_offset)); + srsran_sync_set_cp(q, srsran_sync_detect_cp(q, input_ptr, peak_pos + find_offset)); } - ret = SRSLTE_SYNC_FOUND; + ret = SRSRAN_SYNC_FOUND; } else { - ret = SRSLTE_SYNC_FOUND_NOSPACE; + ret = SRSRAN_SYNC_FOUND_NOSPACE; } } else { - ret = SRSLTE_SYNC_NOFOUND; + ret = SRSRAN_SYNC_NOFOUND; } DEBUG("SYNC ret=%d N_id_2=%d find_offset=%d frame_len=%d, pos=%d peak=%.2f threshold=%.2f CFO=%.3f kHz", @@ -824,18 +824,18 @@ srslte_sync_find(srslte_sync_t* q, const cf_t* input, uint32_t find_offset, uint peak_pos, q->peak_value, q->threshold, - 15 * (srslte_sync_get_cfo(q))); + 15 * (srsran_sync_get_cfo(q))); - } else if (!srslte_N_id_2_isvalid(q->N_id_2)) { - ERROR("Must call srslte_sync_set_N_id_2() first!"); + } else if (!srsran_N_id_2_isvalid(q->N_id_2)) { + ERROR("Must call srsran_sync_set_N_id_2() first!"); } return ret; } -void srslte_sync_reset(srslte_sync_t* q) +void srsran_sync_reset(srsran_sync_t* q) { q->M_ext_avg = 0; q->M_norm_avg = 0; - srslte_pss_reset(&q->pss); + srsran_pss_reset(&q->pss); } diff --git a/lib/src/phy/sync/sync_nbiot.c b/lib/src/phy/sync/sync_nbiot.c index 9a04c7cad..b64406c8d 100644 --- a/lib/src/phy/sync/sync_nbiot.c +++ b/lib/src/phy/sync/sync_nbiot.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -15,11 +15,11 @@ #include #include -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/sync/cfo.h" -#include "srslte/phy/sync/sync_nbiot.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/sync/cfo.h" +#include "srsran/phy/sync/sync_nbiot.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" #define CFO_EMA_ALPHA 0.1 #define CP_EMA_ALPHA 0.1 @@ -29,14 +29,14 @@ * functions like CFO correction, etc. * */ -int srslte_sync_nbiot_init(srslte_sync_nbiot_t* q, uint32_t frame_size, uint32_t max_offset, uint32_t fft_size) +int srsran_sync_nbiot_init(srsran_sync_nbiot_t* q, uint32_t frame_size, uint32_t max_offset, uint32_t fft_size) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL) { - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; - q->n_id_ncell = SRSLTE_CELL_ID_UNKNOWN; + q->n_id_ncell = SRSRAN_CELL_ID_UNKNOWN; q->mean_cfo = 0; q->cfo_ema_alpha = CFO_EMA_ALPHA; q->fft_size = fft_size; @@ -46,70 +46,70 @@ int srslte_sync_nbiot_init(srslte_sync_nbiot_t* q, uint32_t frame_size, uint32_t q->threshold = 5.0; q->enable_cfo_estimation = true; - if (srslte_cfo_init(&q->cfocorr, q->frame_size)) { + if (srsran_cfo_init(&q->cfocorr, q->frame_size)) { fprintf(stderr, "Error initiating CFO\n"); goto clean_exit; } // Set default CFO tolerance - srslte_sync_nbiot_set_cfo_tol(q, DEFAULT_CFO_TOL); + srsran_sync_nbiot_set_cfo_tol(q, DEFAULT_CFO_TOL); // initialize shift buffer for CFO estimation - q->shift_buffer = srslte_vec_cf_malloc(SRSLTE_SF_LEN(q->fft_size)); + q->shift_buffer = srsran_vec_cf_malloc(SRSRAN_SF_LEN(q->fft_size)); if (!q->shift_buffer) { perror("malloc"); goto clean_exit; } - srslte_cexptab_gen_sf(q->shift_buffer, -SRSLTE_NBIOT_FREQ_SHIFT_FACTOR, q->fft_size); + srsran_cexptab_gen_sf(q->shift_buffer, -SRSRAN_NBIOT_FREQ_SHIFT_FACTOR, q->fft_size); // allocate memory for early CFO estimation - q->cfo_output = srslte_vec_cf_malloc(SRSLTE_NOF_SF_X_FRAME * SRSLTE_SF_LEN(q->fft_size)); + q->cfo_output = srsran_vec_cf_malloc(SRSRAN_NOF_SF_X_FRAME * SRSRAN_SF_LEN(q->fft_size)); if (!q->cfo_output) { perror("malloc"); goto clean_exit; } // configure CP - q->cp = SRSLTE_CP_NORM; - q->cp_len = SRSLTE_CP_LEN_NORM(1, q->fft_size); + q->cp = SRSRAN_CP_NORM; + q->cp_len = SRSRAN_CP_LEN_NORM(1, q->fft_size); if (q->frame_size < q->fft_size) { q->nof_symbols = 1; } else { q->nof_symbols = q->frame_size / (q->fft_size + q->cp_len) - 1; } - if (srslte_npss_synch_init(&q->npss, frame_size, fft_size)) { + if (srsran_npss_synch_init(&q->npss, frame_size, fft_size)) { fprintf(stderr, "Error initializing NPSS object\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_nsss_synch_init(&q->nsss, SRSLTE_NSSS_NUM_SF_DETECT * SRSLTE_SF_LEN_PRB_NBIOT, fft_size)) { + if (srsran_nsss_synch_init(&q->nsss, SRSRAN_NSSS_NUM_SF_DETECT * SRSRAN_SF_LEN_PRB_NBIOT, fft_size)) { fprintf(stderr, "Error initializing NSSS object\n"); exit(-1); } - if (srslte_cp_synch_init(&q->cp_synch, fft_size)) { + if (srsran_cp_synch_init(&q->cp_synch, fft_size)) { fprintf(stderr, "Error initiating CFO\n"); goto clean_exit; } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } clean_exit: - if (ret == SRSLTE_ERROR) { - srslte_sync_nbiot_free(q); + if (ret == SRSRAN_ERROR) { + srsran_sync_nbiot_free(q); } return ret; } -void srslte_sync_nbiot_free(srslte_sync_nbiot_t* q) +void srsran_sync_nbiot_free(srsran_sync_nbiot_t* q) { if (q) { - srslte_npss_synch_free(&q->npss); - srslte_nsss_synch_free(&q->nsss); - srslte_cfo_free(&q->cfocorr); - srslte_cp_synch_free(&q->cp_synch); + srsran_npss_synch_free(&q->npss); + srsran_nsss_synch_free(&q->nsss); + srsran_cfo_free(&q->cfocorr); + srsran_cp_synch_free(&q->cp_synch); if (q->shift_buffer) { free(q->shift_buffer); } @@ -119,15 +119,15 @@ void srslte_sync_nbiot_free(srslte_sync_nbiot_t* q) } } -int srslte_sync_nbiot_resize(srslte_sync_nbiot_t* q, uint32_t frame_size, uint32_t max_offset, uint32_t fft_size) +int srsran_sync_nbiot_resize(srsran_sync_nbiot_t* q, uint32_t frame_size, uint32_t max_offset, uint32_t fft_size) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL && frame_size <= 307200) { - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; if (frame_size > q->max_frame_size) { - fprintf(stderr, "Error in srslte_sync_nbiot_resize(): frame_size must be lower than initialized\n"); + fprintf(stderr, "Error in srsran_sync_nbiot_resize(): frame_size must be lower than initialized\n"); return ret; } q->mean_cfo = 0; @@ -139,31 +139,31 @@ int srslte_sync_nbiot_resize(srslte_sync_nbiot_t* q, uint32_t frame_size, uint32 q->frame_size = frame_size; q->max_offset = max_offset; - if (srslte_npss_synch_resize(&q->npss, max_offset, fft_size)) { + if (srsran_npss_synch_resize(&q->npss, max_offset, fft_size)) { fprintf(stderr, "Error resizing PSS object\n"); return ret; } - if (srslte_nsss_synch_resize(&q->nsss, fft_size)) { + if (srsran_nsss_synch_resize(&q->nsss, fft_size)) { fprintf(stderr, "Error resizing SSS object\n"); return ret; } - if (srslte_cp_synch_resize(&q->cp_synch, fft_size)) { + if (srsran_cp_synch_resize(&q->cp_synch, fft_size)) { fprintf(stderr, "Error resizing CFO\n"); return ret; } - if (srslte_cfo_resize(&q->cfocorr, q->frame_size)) { + if (srsran_cfo_resize(&q->cfocorr, q->frame_size)) { fprintf(stderr, "Error resizing CFO\n"); return ret; } // Update CFO tolerance - srslte_sync_nbiot_set_cfo_tol(q, q->current_cfo_tol); + srsran_sync_nbiot_set_cfo_tol(q, q->current_cfo_tol); DEBUG("NBIOT SYNC init with frame_size=%d, max_offset=%d and fft_size=%d", frame_size, max_offset, fft_size); - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } else { fprintf(stderr, "Invalid parameters frame_size: %d, fft_size: %d\n", frame_size, fft_size); } @@ -172,15 +172,15 @@ int srslte_sync_nbiot_resize(srslte_sync_nbiot_t* q, uint32_t frame_size, uint32 } /** Finds the NPSS sequence around the position find_offset in the buffer input. - * Returns 1 if the correlation peak exceeds the threshold set by srslte_sync_set_threshold() + * Returns 1 if the correlation peak exceeds the threshold set by srsran_sync_set_threshold() * or 0 otherwise. Returns a negative number on error. * * The maximum of the correlation peak is always stored in *peak_position */ -srslte_sync_find_ret_t -srslte_sync_nbiot_find(srslte_sync_nbiot_t* q, cf_t* input, uint32_t find_offset, uint32_t* peak_position) +srsran_sync_find_ret_t +srsran_sync_nbiot_find(srsran_sync_nbiot_t* q, cf_t* input, uint32_t find_offset, uint32_t* peak_position) { - srslte_sync_find_ret_t ret = SRSLTE_SYNC_NOFOUND; + srsran_sync_find_ret_t ret = SRSRAN_SYNC_NOFOUND; int peak_pos = 0; if (peak_position) { @@ -194,12 +194,12 @@ srslte_sync_nbiot_find(srslte_sync_nbiot_t* q, cf_t* input, uint32_t find_offset } // correct CFO using current estimate, store result in seperate buffer for NPSS detection - srslte_cfo_correct(&q->cfocorr, input, q->cfo_output, -q->mean_cfo / q->fft_size); + srsran_cfo_correct(&q->cfocorr, input, q->cfo_output, -q->mean_cfo / q->fft_size); - peak_pos = srslte_npss_sync_find(&q->npss, &q->cfo_output[find_offset], &q->peak_value); + peak_pos = srsran_npss_sync_find(&q->npss, &q->cfo_output[find_offset], &q->peak_value); if (peak_pos < 0) { fprintf(stderr, "Error calling finding NPSS sequence, peak pos: %d\n", peak_pos); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (peak_position) { @@ -208,24 +208,24 @@ srslte_sync_nbiot_find(srslte_sync_nbiot_t* q, cf_t* input, uint32_t find_offset /* If peak is over threshold return success */ if (q->peak_value >= q->threshold) { - ret = SRSLTE_SYNC_FOUND; + ret = SRSRAN_SYNC_FOUND; } // estimate CFO after NPSS has been detected if (q->enable_cfo_estimation) { // check if there are enough samples left - if (peak_pos + SRSLTE_NPSS_CFO_OFFSET + SRSLTE_NPSS_CFO_NUM_SAMPS + SRSLTE_NBIOT_FFT_SIZE < q->frame_size) { + if (peak_pos + SRSRAN_NPSS_CFO_OFFSET + SRSRAN_NPSS_CFO_NUM_SAMPS + SRSRAN_NBIOT_FFT_SIZE < q->frame_size) { // shift input signal - srslte_vec_prod_ccc(&q->shift_buffer[SRSLTE_SF_LEN(q->fft_size) / 2], - &input[peak_pos + SRSLTE_NPSS_CFO_OFFSET], - &input[peak_pos + SRSLTE_NPSS_CFO_OFFSET], - SRSLTE_NPSS_CFO_NUM_SAMPS); + srsran_vec_prod_ccc(&q->shift_buffer[SRSRAN_SF_LEN(q->fft_size) / 2], + &input[peak_pos + SRSRAN_NPSS_CFO_OFFSET], + &input[peak_pos + SRSRAN_NPSS_CFO_OFFSET], + SRSRAN_NPSS_CFO_NUM_SAMPS); // use second slot of the NPSS for CFO estimation - float cfo = cfo_estimate_nbiot(q, &input[peak_pos + SRSLTE_NPSS_CFO_OFFSET]); + float cfo = cfo_estimate_nbiot(q, &input[peak_pos + SRSRAN_NPSS_CFO_OFFSET]); // compute exponential moving average CFO - q->mean_cfo = SRSLTE_VEC_EMA(cfo, q->mean_cfo, q->cfo_ema_alpha); + q->mean_cfo = SRSRAN_VEC_EMA(cfo, q->mean_cfo, q->cfo_ema_alpha); DEBUG("CFO=%.4f, mean=%.4f (%.2f Hz), ema=%.2f", cfo, q->mean_cfo, q->mean_cfo * 15000, q->cfo_ema_alpha); } else { DEBUG("Not enough samples for CFO estimation. Skipping."); @@ -245,57 +245,57 @@ srslte_sync_nbiot_find(srslte_sync_nbiot_t* q, cf_t* input, uint32_t find_offset } // Use two OFDM symbols to estimate CFO -float cfo_estimate_nbiot(srslte_sync_nbiot_t* q, cf_t* input) +float cfo_estimate_nbiot(srsran_sync_nbiot_t* q, cf_t* input) { uint32_t cp_offset = 0; cp_offset = - srslte_cp_synch(&q->cp_synch, input, q->max_offset, SRSLTE_NPSS_CFO_NUM_SYMS, SRSLTE_CP_LEN_NORM(1, q->fft_size)); - cf_t cp_corr_max = srslte_cp_synch_corr_output(&q->cp_synch, cp_offset); + srsran_cp_synch(&q->cp_synch, input, q->max_offset, SRSRAN_NPSS_CFO_NUM_SYMS, SRSRAN_CP_LEN_NORM(1, q->fft_size)); + cf_t cp_corr_max = srsran_cp_synch_corr_output(&q->cp_synch, cp_offset); float cfo = -cargf(cp_corr_max) / M_PI / 2; return cfo; } -void srslte_sync_nbiot_set_threshold(srslte_sync_nbiot_t* q, float threshold) +void srsran_sync_nbiot_set_threshold(srsran_sync_nbiot_t* q, float threshold) { q->threshold = threshold; } -void srslte_sync_nbiot_set_cfo_enable(srslte_sync_nbiot_t* q, bool enable) +void srsran_sync_nbiot_set_cfo_enable(srsran_sync_nbiot_t* q, bool enable) { q->enable_cfo_estimation = enable; } -void srslte_sync_nbiot_set_cfo_cand_test_enable(srslte_sync_nbiot_t* q, bool enable) +void srsran_sync_nbiot_set_cfo_cand_test_enable(srsran_sync_nbiot_t* q, bool enable) { q->enable_cfo_cand_test = enable; } -int srslte_sync_nbiot_set_cfo_cand(srslte_sync_nbiot_t* q, const float* cand, const int num) +int srsran_sync_nbiot_set_cfo_cand(srsran_sync_nbiot_t* q, const float* cand, const int num) { if (num > MAX_NUM_CFO_CANDITATES) { printf("Too many candidates, maximum is %d.\n", MAX_NUM_CFO_CANDITATES); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } for (int i = 0; i < num; i++) { q->cfo_cand[i] = cand[i]; } q->cfo_num_cand = num; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -void srslte_sync_nbiot_set_cfo_tol(srslte_sync_nbiot_t* q, float tol) +void srsran_sync_nbiot_set_cfo_tol(srsran_sync_nbiot_t* q, float tol) { - srslte_cfo_set_tol(&q->cfocorr, tol / (15000.0 * q->fft_size)); + srsran_cfo_set_tol(&q->cfocorr, tol / (15000.0 * q->fft_size)); } -void srslte_sync_nbiot_set_cfo_ema_alpha(srslte_sync_nbiot_t* q, float alpha) +void srsran_sync_nbiot_set_cfo_ema_alpha(srsran_sync_nbiot_t* q, float alpha) { q->cfo_ema_alpha = alpha; } -void srslte_sync_nbiot_set_npss_ema_alpha(srslte_sync_nbiot_t* q, float alpha) +void srsran_sync_nbiot_set_npss_ema_alpha(srsran_sync_nbiot_t* q, float alpha) { - srslte_npss_synch_set_ema_alpha(&q->npss, alpha); + srsran_npss_synch_set_ema_alpha(&q->npss, alpha); } /** Determines the N_id_ncell using the samples in the buffer input. @@ -307,40 +307,40 @@ void srslte_sync_nbiot_set_npss_ema_alpha(srslte_sync_nbiot_t* q, float alpha) * Returns a negative number on error. * */ -int srslte_sync_nbiot_find_cell_id(srslte_sync_nbiot_t* q, cf_t* input) +int srsran_sync_nbiot_find_cell_id(srsran_sync_nbiot_t* q, cf_t* input) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; float peak_value; uint32_t sfn_partial; - if (q != NULL && input != NULL && q->frame_size == SRSLTE_SF_LEN_PRB_NBIOT) { - ret = srslte_nsss_sync_find(&q->nsss, input, &peak_value, &q->n_id_ncell, &sfn_partial); + if (q != NULL && input != NULL && q->frame_size == SRSRAN_SF_LEN_PRB_NBIOT) { + ret = srsran_nsss_sync_find(&q->nsss, input, &peak_value, &q->n_id_ncell, &sfn_partial); printf("NSSS with peak=%f, cell-id: %d, partial SFN: %x\n", peak_value, q->n_id_ncell, sfn_partial); } return ret; } -int srslte_sync_nbiot_get_cell_id(srslte_sync_nbiot_t* q) +int srsran_sync_nbiot_get_cell_id(srsran_sync_nbiot_t* q) { return q->n_id_ncell; } -float srslte_sync_nbiot_get_cfo(srslte_sync_nbiot_t* q) +float srsran_sync_nbiot_get_cfo(srsran_sync_nbiot_t* q) { return q->mean_cfo + q->cfo_i; } -void srslte_sync_nbiot_set_cfo(srslte_sync_nbiot_t* q, float cfo) +void srsran_sync_nbiot_set_cfo(srsran_sync_nbiot_t* q, float cfo) { q->mean_cfo = cfo; } -float srslte_sync_nbiot_get_peak_value(srslte_sync_nbiot_t* q) +float srsran_sync_nbiot_get_peak_value(srsran_sync_nbiot_t* q) { return q->peak_value; } -void srslte_sync_nbiot_reset(srslte_sync_nbiot_t* q) +void srsran_sync_nbiot_reset(srsran_sync_nbiot_t* q) { - srslte_npss_synch_reset(&q->npss); + srsran_npss_synch_reset(&q->npss); } diff --git a/lib/src/phy/sync/test/CMakeLists.txt b/lib/src/phy/sync/test/CMakeLists.txt index d4a1cf006..968c4146a 100644 --- a/lib/src/phy/sync/test/CMakeLists.txt +++ b/lib/src/phy/sync/test/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -11,20 +11,20 @@ ######################################################################## add_executable(pss_file pss_file.c) -target_link_libraries(pss_file srslte_phy) +target_link_libraries(pss_file srsran_phy) add_executable(npss_file npss_file.c) -target_link_libraries(npss_file srslte_phy) +target_link_libraries(npss_file srsran_phy) if(RF_FOUND) add_executable(pss_usrp pss_usrp.c) - target_link_libraries(pss_usrp srslte_rf srslte_phy) + target_link_libraries(pss_usrp srsran_rf srsran_phy) add_executable(npss_usrp npss_usrp.c) - target_link_libraries(npss_usrp srslte_rf srslte_phy) + target_link_libraries(npss_usrp srsran_rf srsran_phy) add_executable(nsss_usrp nsss_usrp.c) - target_link_libraries(nsss_usrp srslte_rf srslte_phy) + target_link_libraries(nsss_usrp srsran_rf srsran_phy) endif(RF_FOUND) if(SRSGUI_FOUND) @@ -43,16 +43,16 @@ endif(SRSGUI_FOUND) ######################################################################## add_executable(sync_test sync_test.c) -target_link_libraries(sync_test srslte_phy) +target_link_libraries(sync_test srsran_phy) add_executable(sync_nbiot_test sync_nbiot_test.c) -target_link_libraries(sync_nbiot_test srslte_phy) +target_link_libraries(sync_nbiot_test srsran_phy) add_executable(npss_test npss_test.c) -target_link_libraries(npss_test srslte_phy) +target_link_libraries(npss_test srsran_phy) add_executable(nsss_test nsss_test.c) -target_link_libraries(nsss_test srslte_phy) +target_link_libraries(nsss_test srsran_phy) add_test(sync_test_100 sync_test -o 100 -c 501) add_test(sync_test_400 sync_test -o 400 -c 2) @@ -77,10 +77,10 @@ add_test(nsss_test_nonoise_501 nsss_test -c 501) ######################################################################## add_executable(sync_sl_test sync_sl_test.c) -target_link_libraries(sync_sl_test srslte_phy) +target_link_libraries(sync_sl_test srsran_phy) add_executable(psss_file_test psss_file_test.c) -target_link_libraries(psss_file_test srslte_phy) +target_link_libraries(psss_file_test srsran_phy) # SL TM 2 add_test(sync_sl_test_tm2_p6_c_0 sync_sl_test -p 6 -d -i ${CMAKE_HOME_DIRECTORY}/lib/src/phy/phch/test/signal_sidelink_ideal_tm2_p6_c0_s1.92e6.dat) @@ -117,7 +117,7 @@ add_test(sync_sl_test_self_test_tm4_p25_c_168_fo_so sync_sl_test -p 25 -t 4 -c 1 ######################################################################## add_executable(cfo_test cfo_test.c) -target_link_libraries(cfo_test srslte_phy) +target_link_libraries(cfo_test srsran_phy) add_test(cfo_test_1 cfo_test -f 0.12345 -n 1000) add_test(cfo_test_2 cfo_test -f 0.99849 -n 1000) diff --git a/lib/src/phy/sync/test/cfo_test.c b/lib/src/phy/sync/test/cfo_test.c index f8348d36a..6fd1b5d97 100644 --- a/lib/src/phy/sync/test/cfo_test.c +++ b/lib/src/phy/sync/test/cfo_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -19,7 +19,7 @@ #include #include -#include "srslte/srslte.h" +#include "srsran/srsran.h" #define MAX_MSE 0.1 @@ -53,7 +53,7 @@ int main(int argc, char** argv) { int i; cf_t * input, *output; - srslte_cfo_t cfocorr; + srsran_cfo_t cfocorr; float mse; if (argc < 5) { @@ -63,12 +63,12 @@ int main(int argc, char** argv) parse_args(argc, argv); - input = srslte_vec_cf_malloc(num_samples); + input = srsran_vec_cf_malloc(num_samples); if (!input) { perror("malloc"); exit(-1); } - output = srslte_vec_cf_malloc(num_samples); + output = srsran_vec_cf_malloc(num_samples); if (!output) { perror("malloc"); exit(-1); @@ -79,20 +79,20 @@ int main(int argc, char** argv) output[i] = input[i]; } - if (srslte_cfo_init(&cfocorr, num_samples)) { + if (srsran_cfo_init(&cfocorr, num_samples)) { ERROR("Error initiating CFO"); return -1; } - srslte_cfo_correct(&cfocorr, output, output, freq); - srslte_cfo_correct(&cfocorr, output, output, -freq); + srsran_cfo_correct(&cfocorr, output, output, freq); + srsran_cfo_correct(&cfocorr, output, output, -freq); mse = 0; for (i = 0; i < num_samples; i++) { mse += cabsf(input[i] - output[i]) / num_samples; } - srslte_cfo_free(&cfocorr); + srsran_cfo_free(&cfocorr); free(input); free(output); diff --git a/lib/src/phy/sync/test/npss_file.c b/lib/src/phy/sync/test/npss_file.c index 1b2a7c73b..be3e955ee 100644 --- a/lib/src/phy/sync/test/npss_file.c +++ b/lib/src/phy/sync/test/npss_file.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,11 +10,11 @@ * */ -#include "srslte/phy/io/filesink.h" -#include "srslte/phy/io/filesource.h" -#include "srslte/phy/sync/npss.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/io/filesink.h" +#include "srsran/phy/io/filesource.h" +#include "srsran/phy/sync/npss.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" #include #include #include @@ -27,8 +27,8 @@ #define OUTPUT_FILENAME "npss_file.m" void write_to_file(); -srslte_nbiot_cell_t cell = { - .base = {.nof_prb = 1, .cp = SRSLTE_CP_NORM, .id = 0}, +srsran_nbiot_cell_t cell = { + .base = {.nof_prb = 1, .cp = SRSRAN_CP_NORM, .id = 0}, .base.nof_ports = 1, .nbiot_prb = 0, }; @@ -40,7 +40,7 @@ int nof_frames = 1; uint32_t fft_size = 128; float threshold = 0.4; int N_id_2_sync = -1; -srslte_cp_t cp = SRSLTE_CP_NORM; +srsran_cp_t cp = SRSRAN_CP_NORM; int file_offset = 0; bool save_frame_to_file = false; @@ -54,7 +54,7 @@ void usage(char* prog) printf("\t-s Safe to aligned frame to file [Default %d]\n", save_frame_to_file); printf("\t-t threshold [Default %.2f]\n", threshold); printf("\t-o file read offset [Default %d]\n", file_offset); - printf("\t-v srslte_verbose\n"); + printf("\t-v srsran_verbose\n"); } void parse_args(int argc, char** argv) @@ -81,7 +81,7 @@ void parse_args(int argc, char** argv) nof_frames = (int)strtol(argv[optind], NULL, 10); break; case 'v': - srslte_verbose++; + srsran_verbose++; break; default: usage(argv[0]); @@ -93,10 +93,10 @@ float m0_value, m1_value; int main(int argc, char** argv) { - srslte_filesource_t fsrc; + srsran_filesource_t fsrc; cf_t* buffer; int frame_cnt, n; - srslte_npss_synch_t npss; + srsran_npss_synch_t npss; int peak_idx, last_peak; float peak_value; float mean_peak; @@ -104,19 +104,19 @@ int main(int argc, char** argv) parse_args(argc, argv); - buffer = srslte_vec_cf_malloc(FLEN * 2); + buffer = srsran_vec_cf_malloc(FLEN * 2); if (!buffer) { perror("malloc"); exit(-1); } - if (srslte_npss_synch_init(&npss, FLEN, fft_size)) { + if (srsran_npss_synch_init(&npss, FLEN, fft_size)) { fprintf(stderr, "Error initializing NPSS object\n"); exit(-1); } printf("Opening file...\n"); - if (srslte_filesource_init(&fsrc, input_file_name, SRSLTE_COMPLEX_FLOAT_BIN)) { + if (srsran_filesource_init(&fsrc, input_file_name, SRSRAN_COMPLEX_FLOAT_BIN)) { fprintf(stderr, "Error opening file %s\n", input_file_name); exit(-1); } @@ -130,11 +130,11 @@ int main(int argc, char** argv) mean_peak = 0; int peak_offset = 0; - n = srslte_filesource_read(&fsrc, buffer, file_offset); + n = srsran_filesource_read(&fsrc, buffer, file_offset); bool save_and_exit = false; while (frame_cnt < nof_frames || nof_frames == -1) { - n = srslte_filesource_read(&fsrc, buffer, FLEN - peak_offset); + n = srsran_filesource_read(&fsrc, buffer, FLEN - peak_offset); if (n < 0) { fprintf(stderr, "Error reading samples\n"); exit(-1); @@ -147,17 +147,17 @@ int main(int argc, char** argv) if (save_frame_to_file && save_and_exit) { char* filename = "frame_hyp.bin"; printf("Saving entire frame to %s\n", filename); - srslte_vec_save_file(filename, buffer, FLEN * sizeof(cf_t)); + srsran_vec_save_file(filename, buffer, FLEN * sizeof(cf_t)); exit(-1); } - peak_idx = srslte_npss_sync_find(&npss, buffer, &peak_value); + peak_idx = srsran_npss_sync_find(&npss, buffer, &peak_value); if (peak_idx < 0) { fprintf(stderr, "Error finding NPSS peak\n"); exit(-1); } - mean_peak = SRSLTE_VEC_CMA(peak_value, mean_peak, frame_cnt); + mean_peak = SRSRAN_VEC_CMA(peak_value, mean_peak, frame_cnt); if (peak_value >= threshold) { nof_det++; @@ -166,7 +166,7 @@ int main(int argc, char** argv) if (save_frame_to_file && !save_and_exit) { cf_t dummy[FLEN]; // full frame printf("Peak_idx at %d\n", peak_idx); - int num_drop = peak_idx - SRSLTE_NPSS_CORR_OFFSET + FLEN / 2; + int num_drop = peak_idx - SRSRAN_NPSS_CORR_OFFSET + FLEN / 2; printf("Dropping %d samples!\n", num_drop); if (num_drop > FLEN) { @@ -174,7 +174,7 @@ int main(int argc, char** argv) num_drop = num_drop % FLEN; } - srslte_filesource_read(&fsrc, dummy, num_drop); + srsran_filesource_read(&fsrc, dummy, num_drop); save_and_exit = true; } @@ -202,7 +202,7 @@ int main(int argc, char** argv) (float)nof_det / frame_cnt, (float)nof_nopeakdet / frame_cnt); - if (SRSLTE_VERBOSE_ISINFO()) { + if (SRSRAN_VERBOSE_ISINFO()) { printf("\n"); } @@ -213,15 +213,15 @@ int main(int argc, char** argv) printf("NPSS detected #%d\n", nof_det); - srslte_vec_save_file( - "npss_find_conv_output_abs.bin", npss.conv_output_abs, (FLEN + SRSLTE_NPSS_CORR_FILTER_LEN) * sizeof(float)); - srslte_vec_save_file("npss_corr_seq_time.bin", npss.npss_signal_time, SRSLTE_NPSS_CORR_FILTER_LEN * sizeof(cf_t)); + srsran_vec_save_file( + "npss_find_conv_output_abs.bin", npss.conv_output_abs, (FLEN + SRSRAN_NPSS_CORR_FILTER_LEN) * sizeof(float)); + srsran_vec_save_file("npss_corr_seq_time.bin", npss.npss_signal_time, SRSRAN_NPSS_CORR_FILTER_LEN * sizeof(cf_t)); write_to_file(); - srslte_npss_synch_free(&npss); + srsran_npss_synch_free(&npss); free(buffer); - srslte_filesource_free(&fsrc); + srsran_filesource_free(&fsrc); printf("Ok\n"); exit(0); @@ -230,9 +230,9 @@ int main(int argc, char** argv) float tmp[1000000]; void write_to_file() { - srslte_filesink_t debug_fsink; + srsran_filesink_t debug_fsink; char fname[] = OUTPUT_FILENAME; - if (srslte_filesink_init(&debug_fsink, fname, SRSLTE_TEXT)) { + if (srsran_filesink_init(&debug_fsink, fname, SRSRAN_TEXT)) { fprintf(stderr, "Error opening file %s\n", fname); exit(-1); } @@ -243,7 +243,7 @@ void write_to_file() fprintf(debug_fsink.f, "pkg load signal;\n\n"); // the correlation sequence - fprintf(debug_fsink.f, "len = %u;\n", SRSLTE_NPSS_CORR_FILTER_LEN); + fprintf(debug_fsink.f, "len = %u;\n", SRSRAN_NPSS_CORR_FILTER_LEN); fprintf(debug_fsink.f, "sig1=read_complex('npss_corr_seq_time.bin', len);\n"); fprintf(debug_fsink.f, "figure;\n"); fprintf(debug_fsink.f, "t=1:len;\n"); @@ -271,7 +271,7 @@ void write_to_file() fprintf(debug_fsink.f, "\n\n"); // the correlation output - fprintf(debug_fsink.f, "num_samples = %u;\n", SRSLTE_NPSS_CORR_FILTER_LEN + FLEN - 1); + fprintf(debug_fsink.f, "num_samples = %u;\n", SRSRAN_NPSS_CORR_FILTER_LEN + FLEN - 1); fprintf(debug_fsink.f, "conv = read_real('npss_find_conv_output_abs.bin', num_samples);\n"); fprintf(debug_fsink.f, "t=1:length(conv);\n"); fprintf(debug_fsink.f, "\n\n"); @@ -292,6 +292,6 @@ void write_to_file() fprintf(debug_fsink.f, "ylabel('Correlation magnitude');\n"); fprintf(debug_fsink.f, "\n\n"); - srslte_filesink_free(&debug_fsink); + srsran_filesink_free(&debug_fsink); printf("data written to %s\n", OUTPUT_FILENAME); } diff --git a/lib/src/phy/sync/test/npss_test.c b/lib/src/phy/sync/test/npss_test.c index 81e421721..8c11be8b8 100644 --- a/lib/src/phy/sync/test/npss_test.c +++ b/lib/src/phy/sync/test/npss_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -20,20 +20,20 @@ #include #include -#include "srslte/phy/sync/npss.h" -#include "srslte/srslte.h" +#include "srsran/phy/sync/npss.h" +#include "srsran/srsran.h" #define OUTPUT_FILENAME "npss_test.m" void write_to_file(); #define DUMP_SIGNALS 0 -int input_len = SRSLTE_SF_LEN(SRSLTE_NBIOT_FFT_SIZE); +int input_len = SRSRAN_SF_LEN(SRSRAN_NBIOT_FFT_SIZE); void usage(char* prog) { printf("Usage: %s [cpoev]\n", prog); - printf("\t-v srslte_verbose\n"); + printf("\t-v srsran_verbose\n"); } void parse_args(int argc, char** argv) @@ -45,7 +45,7 @@ void parse_args(int argc, char** argv) input_len = (int)strtol(argv[optind], NULL, 10); break; case 'v': - srslte_verbose = SRSLTE_VERBOSE_DEBUG; + srsran_verbose = SRSRAN_VERBOSE_DEBUG; break; default: usage(argv[0]); @@ -59,66 +59,66 @@ int main(int argc, char** argv) cf_t* fft_buffer; cf_t* input_buffer; - srslte_npss_synch_t syncobj; - srslte_ofdm_t ifft; + srsran_npss_synch_t syncobj; + srsran_ofdm_t ifft; struct timeval t[3]; int fft_size; int peak_pos; float peak_value; - int ret = SRSLTE_ERROR; + int ret = SRSRAN_ERROR; parse_args(argc, argv); - if (input_len < SRSLTE_SF_LEN(SRSLTE_NBIOT_FFT_SIZE)) { + if (input_len < SRSRAN_SF_LEN(SRSRAN_NBIOT_FFT_SIZE)) { fprintf(stderr, "Input len too small (%d), must be at least one subframe\n", input_len); exit(-1); } - fft_size = srslte_symbol_sz(SRSLTE_NBIOT_DEFAULT_NUM_PRB_BASECELL); + fft_size = srsran_symbol_sz(SRSRAN_NBIOT_DEFAULT_NUM_PRB_BASECELL); if (fft_size < 0) { - fprintf(stderr, "Invalid nof_prb=%d\n", SRSLTE_NBIOT_DEFAULT_NUM_PRB_BASECELL); + fprintf(stderr, "Invalid nof_prb=%d\n", SRSRAN_NBIOT_DEFAULT_NUM_PRB_BASECELL); exit(-1); } printf("Input buffer length is %d samples\n", input_len); - uint32_t buffer_len = input_len + SRSLTE_NPSS_CORR_FILTER_LEN + 1; - fft_buffer = srslte_vec_cf_malloc(buffer_len); + uint32_t buffer_len = input_len + SRSRAN_NPSS_CORR_FILTER_LEN + 1; + fft_buffer = srsran_vec_cf_malloc(buffer_len); if (!fft_buffer) { perror("malloc"); exit(-1); } - srslte_vec_cf_zero(fft_buffer, buffer_len); + srsran_vec_cf_zero(fft_buffer, buffer_len); - input_buffer = srslte_vec_cf_malloc(input_len); + input_buffer = srsran_vec_cf_malloc(input_len); if (!input_buffer) { perror("malloc"); exit(-1); } - srslte_vec_cf_zero(input_buffer, input_len); + srsran_vec_cf_zero(input_buffer, input_len); - if (srslte_ofdm_tx_init(&ifft, SRSLTE_CP_NORM, input_buffer, fft_buffer, SRSLTE_NBIOT_DEFAULT_NUM_PRB_BASECELL)) { + if (srsran_ofdm_tx_init(&ifft, SRSRAN_CP_NORM, input_buffer, fft_buffer, SRSRAN_NBIOT_DEFAULT_NUM_PRB_BASECELL)) { fprintf(stderr, "Error creating iFFT object\n"); exit(-1); } - srslte_ofdm_set_freq_shift(&ifft, -SRSLTE_NBIOT_FREQ_SHIFT_FACTOR); + srsran_ofdm_set_freq_shift(&ifft, -SRSRAN_NBIOT_FREQ_SHIFT_FACTOR); - if (srslte_npss_synch_init(&syncobj, input_len, fft_size)) { + if (srsran_npss_synch_init(&syncobj, input_len, fft_size)) { fprintf(stderr, "Error initializing NPSS object\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // generate NPSS/NSSS signals - _Complex float npss_signal[SRSLTE_NPSS_TOT_LEN]; - srslte_npss_generate(npss_signal); - srslte_npss_put_subframe( - &syncobj, npss_signal, input_buffer, SRSLTE_NBIOT_DEFAULT_NUM_PRB_BASECELL, SRSLTE_NBIOT_DEFAULT_PRB_OFFSET); + _Complex float npss_signal[SRSRAN_NPSS_TOT_LEN]; + srsran_npss_generate(npss_signal); + srsran_npss_put_subframe( + &syncobj, npss_signal, input_buffer, SRSRAN_NBIOT_DEFAULT_NUM_PRB_BASECELL, SRSRAN_NBIOT_DEFAULT_PRB_OFFSET); // Transform to OFDM symbols - srslte_ofdm_tx_sf(&ifft); + srsran_ofdm_tx_sf(&ifft); // look for NPSS signal gettimeofday(&t[1], NULL); - peak_pos = srslte_npss_sync_find(&syncobj, fft_buffer, &peak_value); + peak_pos = srsran_npss_sync_find(&syncobj, fft_buffer, &peak_value); gettimeofday(&t[2], NULL); get_time_interval(t); printf("NPPS with peak=%f found at: %d (in %.0f usec)\n", @@ -128,22 +128,21 @@ int main(int argc, char** argv) // write results to file #if DUMP_SIGNALS - srslte_vec_save_file("npss_find_conv_output_abs.bin", syncobj.conv_output_abs, buffer_len * sizeof(float)); - srslte_vec_save_file("npss_sf_time.bin", fft_buffer, input_len * sizeof(cf_t)); - srslte_vec_save_file("npss_corr_seq_time.bin", syncobj.npss_signal_time, SRSLTE_NPSS_CORR_FILTER_LEN * sizeof(cf_t)); + srsran_vec_save_file("npss_find_conv_output_abs.bin", syncobj.conv_output_abs, buffer_len * sizeof(float)); + srsran_vec_save_file("npss_sf_time.bin", fft_buffer, input_len * sizeof(cf_t)); + srsran_vec_save_file("npss_corr_seq_time.bin", syncobj.npss_signal_time, SRSRAN_NPSS_CORR_FILTER_LEN * sizeof(cf_t)); write_to_file(); #endif // cleanup - srslte_npss_synch_free(&syncobj); + srsran_npss_synch_free(&syncobj); free(fft_buffer); free(input_buffer); - srslte_ofdm_tx_free(&ifft); + srsran_ofdm_tx_free(&ifft); - - if (peak_pos == SRSLTE_NPSS_CORR_OFFSET) { + if (peak_pos == SRSRAN_NPSS_CORR_OFFSET) { printf("Ok\n"); - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } else { printf("Failed\n"); } @@ -153,9 +152,9 @@ int main(int argc, char** argv) void write_to_file() { - srslte_filesink_t debug_fsink; + srsran_filesink_t debug_fsink; char fname[] = OUTPUT_FILENAME; - if (srslte_filesink_init(&debug_fsink, fname, SRSLTE_TEXT)) { + if (srsran_filesink_init(&debug_fsink, fname, SRSRAN_TEXT)) { fprintf(stderr, "Error opening file %s\n", fname); exit(-1); } @@ -166,7 +165,7 @@ void write_to_file() fprintf(debug_fsink.f, "pkg load signal;\n\n"); // the correlation sequence - fprintf(debug_fsink.f, "len = %u;\n", SRSLTE_NPSS_CORR_FILTER_LEN); + fprintf(debug_fsink.f, "len = %u;\n", SRSRAN_NPSS_CORR_FILTER_LEN); fprintf(debug_fsink.f, "sig1=read_complex('npss_corr_seq_time.bin', len);\n"); fprintf(debug_fsink.f, "figure;\n"); fprintf(debug_fsink.f, "t=1:len;\n"); @@ -186,7 +185,7 @@ void write_to_file() fprintf(debug_fsink.f, "\n\n"); // the correlation output - fprintf(debug_fsink.f, "num_samples = %u;\n", SRSLTE_NPSS_CORR_FILTER_LEN + input_len - 1); + fprintf(debug_fsink.f, "num_samples = %u;\n", SRSRAN_NPSS_CORR_FILTER_LEN + input_len - 1); fprintf(debug_fsink.f, "sig = read_real('npss_find_conv_output_abs.bin', num_samples);\n"); fprintf(debug_fsink.f, "t=1:num_samples;\n"); fprintf(debug_fsink.f, "\n\n"); @@ -207,6 +206,6 @@ void write_to_file() fprintf(debug_fsink.f, "ylabel('Correlation magnitude');\n"); fprintf(debug_fsink.f, "\n\n"); - srslte_filesink_free(&debug_fsink); + srsran_filesink_free(&debug_fsink); printf("data written to %s\n", OUTPUT_FILENAME); } diff --git a/lib/src/phy/sync/test/npss_usrp.c b/lib/src/phy/sync/test/npss_usrp.c index 604e99392..5d8a21770 100644 --- a/lib/src/phy/sync/test/npss_usrp.c +++ b/lib/src/phy/sync/test/npss_usrp.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -20,9 +20,9 @@ #include #include -#include "srslte/phy/rf/rf.h" -#include "srslte/phy/sync/npss.h" -#include "srslte/srslte.h" +#include "srsran/phy/rf/rf.h" +#include "srsran/phy/sync/npss.h" +#include "srsran/srsran.h" #ifndef DISABLE_GRAPHICS void init_plots(); @@ -39,8 +39,8 @@ bool save_frame_to_file = false; float cfo_fixed = 0.0; bool has_cfo_corr = true; -srslte_nbiot_cell_t cell = { - .base = {.nof_prb = 1, .cp = SRSLTE_CP_NORM, .nof_ports = 1, .id = 0}, +srsran_nbiot_cell_t cell = { + .base = {.nof_prb = 1, .cp = SRSRAN_CP_NORM, .nof_ports = 1, .id = 0}, .nbiot_prb = 0, .n_id_ncell = 0, }; @@ -60,7 +60,7 @@ void usage(char* prog) #else printf("\t plots are disabled. Graphics library not available\n"); #endif - printf("\t-v srslte_verbose\n"); + printf("\t-v srsran_verbose\n"); } void parse_args(int argc, char** argv) @@ -100,7 +100,7 @@ void parse_args(int argc, char** argv) disable_plots = true; break; case 'v': - srslte_verbose++; + srsran_verbose++; break; default: usage(argv[0]); @@ -128,9 +128,9 @@ int main(int argc, char** argv) { cf_t* buffer; int frame_cnt, n; - srslte_rf_t rf; - srslte_cfo_t cfocorr; - srslte_npss_synch_t npss; + srsran_rf_t rf; + srsran_cfo_t cfocorr; + srsran_npss_synch_t npss; int32_t flen; int peak_idx; float peak_value; @@ -156,36 +156,36 @@ int main(int argc, char** argv) printf("Manually compensating %.0f Hz CFO offset\n", cfo_fixed); } - if (srslte_cfo_init(&cfocorr, flen)) { + if (srsran_cfo_init(&cfocorr, flen)) { fprintf(stderr, "Error initiating CFO\n"); exit(-1); } - srslte_cfo_set_tol(&cfocorr, 50.0 / (15000.0 * fft_size)); + srsran_cfo_set_tol(&cfocorr, 50.0 / (15000.0 * fft_size)); printf("Opening RF device...\n"); - if (srslte_rf_open(&rf, rf_args)) { + if (srsran_rf_open(&rf, rf_args)) { fprintf(stderr, "Error opening rf\n"); exit(-1); } - srslte_rf_set_rx_gain(&rf, rf_gain); - printf("Set RX rate: %.2f MHz\n", srslte_rf_set_rx_srate(&rf, srate) / 1000000); - printf("Set RX gain: %.1f dB\n", srslte_rf_get_rx_gain(&rf)); - printf("Set RX freq: %.2f MHz\n", srslte_rf_set_rx_freq(&rf, 0, rf_freq) / 1000000); + srsran_rf_set_rx_gain(&rf, rf_gain); + printf("Set RX rate: %.2f MHz\n", srsran_rf_set_rx_srate(&rf, srate) / 1000000); + printf("Set RX gain: %.1f dB\n", srsran_rf_get_rx_gain(&rf)); + printf("Set RX freq: %.2f MHz\n", srsran_rf_set_rx_freq(&rf, 0, rf_freq) / 1000000); - buffer = srslte_vec_cf_malloc(flen * 2); + buffer = srsran_vec_cf_malloc(flen * 2); if (!buffer) { perror("malloc"); exit(-1); } - srslte_vec_cf_zero(buffer, flen * 2); + srsran_vec_cf_zero(buffer, flen * 2); - if (srslte_npss_synch_init(&npss, flen, fft_size)) { + if (srsran_npss_synch_init(&npss, flen, fft_size)) { fprintf(stderr, "Error initializing NPSS object\n"); exit(-1); } - srslte_rf_start_rx_stream(&rf, false); + srsran_rf_start_rx_stream(&rf, false); nof_det = nof_nodet = nof_nopeak = nof_nopeakdet = 0; frame_cnt = 0; @@ -195,7 +195,7 @@ int main(int argc, char** argv) bool save_and_exit = false; while ((frame_cnt < nof_frames || nof_frames == -1) && !go_exit) { - n = srslte_rf_recv(&rf, buffer, flen - peak_offset, 1); + n = srsran_rf_recv(&rf, buffer, flen - peak_offset, 1); if (n < 0) { fprintf(stderr, "Error receiving samples\n"); exit(-1); @@ -206,22 +206,22 @@ int main(int argc, char** argv) if (save_frame_to_file && save_and_exit) { char* filename = "frame_hyp.bin"; printf("Saving entire frame to %s\n", filename); - srslte_vec_save_file(filename, buffer, flen * sizeof(cf_t)); + srsran_vec_save_file(filename, buffer, flen * sizeof(cf_t)); go_exit = true; } // perform CFO correction if (has_cfo_corr) { - srslte_cfo_correct(&cfocorr, buffer, buffer, -cfo_fixed / (15000 * fft_size)); + srsran_cfo_correct(&cfocorr, buffer, buffer, -cfo_fixed / (15000 * fft_size)); } - peak_idx = srslte_npss_sync_find(&npss, buffer, &peak_value); + peak_idx = srsran_npss_sync_find(&npss, buffer, &peak_value); if (peak_idx < 0) { fprintf(stderr, "Error finding NPSS peak\n"); exit(-1); } - mean_peak = SRSLTE_VEC_CMA(peak_value, mean_peak, frame_cnt); + mean_peak = SRSRAN_VEC_CMA(peak_value, mean_peak, frame_cnt); if (peak_value >= threshold) { nof_det++; @@ -230,7 +230,7 @@ int main(int argc, char** argv) if (save_frame_to_file && !save_and_exit) { cf_t dummy[flen]; // full frame printf("Peak_idx at %d\n", peak_idx); - int num_drop = peak_idx - SRSLTE_NPSS_CORR_OFFSET + flen / 2; + int num_drop = peak_idx - SRSRAN_NPSS_CORR_OFFSET + flen / 2; printf("Dropping %d samples!\n", num_drop); if (num_drop > flen) { @@ -238,7 +238,7 @@ int main(int argc, char** argv) num_drop = num_drop % flen; } - srslte_rf_recv(&rf, dummy, num_drop, 1); + srsran_rf_recv(&rf, dummy, num_drop, 1); save_and_exit = true; } } else { @@ -247,19 +247,19 @@ int main(int argc, char** argv) printf("[%5d]: Pos: %5d, PSR: %4.1f (~%4.1f) Pdet: %4.2f, " "FA: %4.2f\r", frame_cnt, - (peak_value > threshold) ? (peak_idx - SRSLTE_NPSS_CORR_OFFSET - flen / 10 / 2) : 0, + (peak_value > threshold) ? (peak_idx - SRSRAN_NPSS_CORR_OFFSET - flen / 10 / 2) : 0, peak_value, mean_peak, (float)nof_det / frame_cnt, (float)nof_nopeakdet / frame_cnt); - if (SRSLTE_VERBOSE_ISINFO()) { + if (SRSRAN_VERBOSE_ISINFO()) { printf("\n"); } #ifndef DISABLE_GRAPHICS if (!disable_plots) { - int len = SRSLTE_NPSS_CORR_FILTER_LEN + npss.frame_size - 1; + int len = SRSRAN_NPSS_CORR_FILTER_LEN + npss.frame_size - 1; do_plots_npss(npss.conv_output_avg, npss.conv_output_avg[peak_idx], len); } #endif @@ -267,10 +267,10 @@ int main(int argc, char** argv) printf("NPSS detected #%d\n", nof_det); - srslte_npss_synch_free(&npss); - srslte_cfo_free(&cfocorr); + srsran_npss_synch_free(&npss); + srsran_cfo_free(&cfocorr); free(buffer); - srslte_rf_close(&rf); + srsran_rf_close(&rf); printf("Ok\n"); exit(0); @@ -298,7 +298,7 @@ void init_plots() void do_plots_npss(float* corr, float peak, uint32_t size) { - srslte_vec_sc_prod_fff(corr, 1. / peak, tmp, size); + srsran_vec_sc_prod_fff(corr, 1. / peak, tmp, size); plot_real_setNewData(&pssout, tmp, size); } diff --git a/lib/src/phy/sync/test/nsss_test.c b/lib/src/phy/sync/test/nsss_test.c index 85f86fcca..ca8ba98dd 100644 --- a/lib/src/phy/sync/test/nsss_test.c +++ b/lib/src/phy/sync/test/nsss_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -20,14 +20,14 @@ #include #include -#include "srslte/phy/sync/nsss.h" -#include "srslte/srslte.h" +#include "srsran/phy/sync/nsss.h" +#include "srsran/srsran.h" #define OUTPUT_FILENAME "nsss_test.m" void write_to_file(); int sfn = 0; -uint32_t n_id_ncell = SRSLTE_CELL_ID_UNKNOWN; +uint32_t n_id_ncell = SRSRAN_CELL_ID_UNKNOWN; char* input_file_name; int max_num_sf = 20; @@ -36,7 +36,7 @@ int max_num_sf = 20; #define DUMP_SIGNALS 0 #define MAX_CORR_LEN 10000 -#define SFLEN (1 * SRSLTE_SF_LEN(SRSLTE_NBIOT_FFT_SIZE)) +#define SFLEN (1 * SRSRAN_SF_LEN(SRSRAN_NBIOT_FFT_SIZE)) void usage(char* prog) { @@ -45,7 +45,7 @@ void usage(char* prog) printf("\t-c cell ID\n"); printf("\t-n SFN\n"); printf("\t-r Maximum number of subframes to read from file [default: %d]\n", max_num_sf); - printf("\t-v srslte_verbose\n"); + printf("\t-v srsran_verbose\n"); } void parse_args(int argc, char** argv) @@ -66,7 +66,7 @@ void parse_args(int argc, char** argv) max_num_sf = (int)strtol(argv[optind], NULL, 10); break; case 'v': - srslte_verbose = SRSLTE_VERBOSE_DEBUG; + srsran_verbose = SRSRAN_VERBOSE_DEBUG; break; default: usage(argv[0]); @@ -79,45 +79,45 @@ int main(int argc, char** argv) { cf_t* fft_buffer = NULL; cf_t* buffer = NULL; - srslte_nsss_synch_t syncobj = {}; - srslte_ofdm_t ifft = {}; + srsran_nsss_synch_t syncobj = {}; + srsran_ofdm_t ifft = {}; int fft_size = 0; float peak_value = 0.0; int num_sf = 1; - int ret = SRSLTE_ERROR; + int ret = SRSRAN_ERROR; parse_args(argc, argv); - buffer = srslte_vec_cf_malloc(SFLEN * max_num_sf); + buffer = srsran_vec_cf_malloc(SFLEN * max_num_sf); if (!buffer) { perror("malloc"); return ret; } memset(buffer, 0, sizeof(cf_t) * SFLEN * max_num_sf); - fft_size = srslte_symbol_sz(NOF_PRB); + fft_size = srsran_symbol_sz(NOF_PRB); if (fft_size < 0) { fprintf(stderr, "Invalid nof_prb=%d\n", NOF_PRB); goto exit; } printf("SFLEN is %d samples\n", SFLEN); - fft_buffer = srslte_vec_cf_malloc(SFLEN * max_num_sf); + fft_buffer = srsran_vec_cf_malloc(SFLEN * max_num_sf); if (!fft_buffer) { perror("malloc"); goto exit; } memset(fft_buffer, 0, sizeof(cf_t) * SFLEN * max_num_sf); - if (srslte_ofdm_tx_init(&ifft, SRSLTE_CP_NORM, buffer, fft_buffer, NOF_PRB)) { + if (srsran_ofdm_tx_init(&ifft, SRSRAN_CP_NORM, buffer, fft_buffer, NOF_PRB)) { fprintf(stderr, "Error creating iFFT object\n"); goto exit; } if (input_file_name != NULL) { - srslte_filesource_t fsrc; + srsran_filesource_t fsrc; printf("Opening file %s\n", input_file_name); - if (srslte_filesource_init(&fsrc, input_file_name, SRSLTE_COMPLEX_FLOAT_BIN)) { + if (srsran_filesource_init(&fsrc, input_file_name, SRSRAN_COMPLEX_FLOAT_BIN)) { fprintf(stderr, "Error opening file %s\n", input_file_name); goto exit; } @@ -125,11 +125,11 @@ int main(int argc, char** argv) // offset file int file_offset = 0; - srslte_filesource_read(&fsrc, buffer, file_offset); + srsran_filesource_read(&fsrc, buffer, file_offset); // now read while (num_sf < max_num_sf) { - int n = srslte_filesource_read(&fsrc, &fft_buffer[num_sf * SFLEN], SFLEN); + int n = srsran_filesource_read(&fsrc, &fft_buffer[num_sf * SFLEN], SFLEN); if (n < 0) { fprintf(stderr, "Error reading samples\n"); goto exit; @@ -140,13 +140,13 @@ int main(int argc, char** argv) } num_sf++; } - srslte_filesource_free(&fsrc); + srsran_filesource_free(&fsrc); printf("Read %d sumbframes from file.\n", num_sf); } // initialize NSSS object with actual input length printf("Initializing NSSS synch with %dx%d samples.\n", num_sf, SFLEN); - if (srslte_nsss_synch_init(&syncobj, num_sf * SFLEN, fft_size)) { + if (srsran_nsss_synch_init(&syncobj, num_sf * SFLEN, fft_size)) { fprintf(stderr, "Error initializing NSSS object\n"); goto exit; } @@ -155,29 +155,29 @@ int main(int argc, char** argv) if (!input_file_name) { // generate NPSS/NSSS signals printf("Generating NSSS sequence for n_id_ncell=%d\n", n_id_ncell); - cf_t nsss_signals[SRSLTE_NSSS_TOT_LEN] = {}; - srslte_nsss_generate(nsss_signals, n_id_ncell == SRSLTE_CELL_ID_UNKNOWN ? 0 : n_id_ncell); + cf_t nsss_signals[SRSRAN_NSSS_TOT_LEN] = {}; + srsran_nsss_generate(nsss_signals, n_id_ncell == SRSRAN_CELL_ID_UNKNOWN ? 0 : n_id_ncell); #if DUMP_SIGNALS - srslte_vec_save_file("nsss_signal_freq.bin", nsss_signals, SRSLTE_NSSS_LEN * sizeof(cf_t)); + srsran_vec_save_file("nsss_signal_freq.bin", nsss_signals, SRSRAN_NSSS_LEN * sizeof(cf_t)); #endif - srslte_nsss_put_subframe( - &syncobj, nsss_signals, buffer, sfn, SRSLTE_NBIOT_DEFAULT_NUM_PRB_BASECELL, SRSLTE_NBIOT_DEFAULT_PRB_OFFSET); + srsran_nsss_put_subframe( + &syncobj, nsss_signals, buffer, sfn, SRSRAN_NBIOT_DEFAULT_NUM_PRB_BASECELL, SRSRAN_NBIOT_DEFAULT_PRB_OFFSET); // Transform to OFDM symbols - srslte_ofdm_tx_sf(&ifft); + srsran_ofdm_tx_sf(&ifft); } // look for NSSS signal - uint32_t n_id_ncell_detected = SRSLTE_CELL_ID_UNKNOWN; + uint32_t n_id_ncell_detected = SRSRAN_CELL_ID_UNKNOWN; uint32_t sfn_partial = 0; - srslte_nsss_sync_find(&syncobj, fft_buffer, &peak_value, &n_id_ncell_detected, &sfn_partial); + srsran_nsss_sync_find(&syncobj, fft_buffer, &peak_value, &n_id_ncell_detected, &sfn_partial); printf("NSSS with peak=%f, n_id_ncell: %d, partial SFN: %x\n", peak_value, n_id_ncell_detected, sfn_partial); - if (n_id_ncell_detected == (n_id_ncell == SRSLTE_CELL_ID_UNKNOWN ? 0 : n_id_ncell)) { + if (n_id_ncell_detected == (n_id_ncell == SRSRAN_CELL_ID_UNKNOWN ? 0 : n_id_ncell)) { printf("Ok\n"); - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } else { printf("Failed\n"); } @@ -188,17 +188,17 @@ int main(int argc, char** argv) char fname[MAX_FNAME_LEN] = {}; snprintf(fname, MAX_FNAME_LEN, "nsss_find_input.bin"); printf("Saving entire sub-frame to %s\n", fname); - srslte_vec_save_file(fname, fft_buffer, num_sf * SFLEN * sizeof(cf_t)); - srslte_vec_save_file("nsss_corr_seq_time.bin", - syncobj.nsss_signal_time[n_id_ncell == SRSLTE_CELL_ID_UNKNOWN ? 0 : n_id_ncell], - SRSLTE_NSSS_CORR_FILTER_LEN * sizeof(cf_t)); - if (n_id_ncell_detected != SRSLTE_CELL_ID_UNKNOWN) { + srsran_vec_save_file(fname, fft_buffer, num_sf * SFLEN * sizeof(cf_t)); + srsran_vec_save_file("nsss_corr_seq_time.bin", + syncobj.nsss_signal_time[n_id_ncell == SRSRAN_CELL_ID_UNKNOWN ? 0 : n_id_ncell], + SRSRAN_NSSS_CORR_FILTER_LEN * sizeof(cf_t)); + if (n_id_ncell_detected != SRSRAN_CELL_ID_UNKNOWN) { // run correlation again with found cell to populate conv_output_abs - srslte_nsss_sync_find(&syncobj, fft_buffer, &peak_value, &n_id_ncell_detected, &sfn_partial); + srsran_nsss_sync_find(&syncobj, fft_buffer, &peak_value, &n_id_ncell_detected, &sfn_partial); } - srslte_vec_save_file("nsss_find_conv_output_abs.bin", + srsran_vec_save_file("nsss_find_conv_output_abs.bin", syncobj.conv_output_abs, - (SRSLTE_NSSS_CORR_FILTER_LEN + num_sf * SFLEN) * sizeof(float)); + (SRSRAN_NSSS_CORR_FILTER_LEN + num_sf * SFLEN) * sizeof(float)); // write Octave script write_to_file(); @@ -206,8 +206,8 @@ int main(int argc, char** argv) // cleanup exit: - srslte_nsss_synch_free(&syncobj); - srslte_ofdm_tx_free(&ifft); + srsran_nsss_synch_free(&syncobj); + srsran_ofdm_tx_free(&ifft); if (buffer) { free(buffer); } @@ -221,9 +221,9 @@ exit: void write_to_file() { - srslte_filesink_t debug_fsink; + srsran_filesink_t debug_fsink; char fname[] = OUTPUT_FILENAME; - if (srslte_filesink_init(&debug_fsink, fname, SRSLTE_TEXT)) { + if (srsran_filesink_init(&debug_fsink, fname, SRSRAN_TEXT)) { fprintf(stderr, "Error opening file %s\n", fname); exit(-1); } @@ -253,10 +253,10 @@ void write_to_file() fprintf(debug_fsink.f, "\n\n"); // the correlation output - fprintf(debug_fsink.f, "corr_srslte = read_real('nsss_find_conv_output_abs.bin', max_len);\n"); - fprintf(debug_fsink.f, "t=1:length(corr_srslte);\n"); + fprintf(debug_fsink.f, "corr_srsran = read_real('nsss_find_conv_output_abs.bin', max_len);\n"); + fprintf(debug_fsink.f, "t=1:length(corr_srsran);\n"); fprintf(debug_fsink.f, "figure;\n"); - fprintf(debug_fsink.f, "plot(t,corr_srslte);\n"); + fprintf(debug_fsink.f, "plot(t,corr_srsran);\n"); fprintf(debug_fsink.f, "xlabel('sample index');\n"); fprintf(debug_fsink.f, "title('Convolution output absolute');\n"); fprintf(debug_fsink.f, "ylabel('Auto-correlation magnitude');\n"); @@ -271,6 +271,6 @@ void write_to_file() fprintf(debug_fsink.f, "ylabel('Correlation magnitude');\n"); fprintf(debug_fsink.f, "\n\n"); - srslte_filesink_free(&debug_fsink); + srsran_filesink_free(&debug_fsink); printf("data written to %s\n", OUTPUT_FILENAME); } diff --git a/lib/src/phy/sync/test/nsss_usrp.c b/lib/src/phy/sync/test/nsss_usrp.c index 56564ca71..cae618129 100644 --- a/lib/src/phy/sync/test/nsss_usrp.c +++ b/lib/src/phy/sync/test/nsss_usrp.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -20,13 +20,13 @@ #include #include -#include "srslte/phy/io/filesink.h" -#include "srslte/phy/io/filesource.h" -#include "srslte/phy/rf/rf.h" -#include "srslte/phy/sync/cfo.h" -#include "srslte/phy/sync/nsss.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/io/filesink.h" +#include "srsran/phy/io/filesource.h" +#include "srsran/phy/rf/rf.h" +#include "srsran/phy/sync/cfo.h" +#include "srsran/phy/sync/nsss.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" char* rf_args = ""; float rf_gain = 40.0, rf_freq = -1.0; @@ -36,8 +36,8 @@ float threshold = 0.4; bool has_cfo_corr = true; float cfo_fixed = 0.0; -srslte_nbiot_cell_t cell = { - .base = {.nof_prb = 1, .cp = SRSLTE_CP_NORM, .nof_ports = 1, .id = 0}, +srsran_nbiot_cell_t cell = { + .base = {.nof_prb = 1, .cp = SRSRAN_CP_NORM, .nof_ports = 1, .id = 0}, .nbiot_prb = 0, .n_id_ncell = 0, }; @@ -51,7 +51,7 @@ void usage(char* prog) printf("\t-c Manual CFO offset [Default %.0f Hz]\n", cfo_fixed); printf("\t-n nof_frames [Default %d]\n", nof_frames); printf("\t-t threshold [Default %.2f]\n", threshold); - printf("\t-v srslte_verbose\n"); + printf("\t-v srsran_verbose\n"); } void parse_args(int argc, char** argv) @@ -84,7 +84,7 @@ void parse_args(int argc, char** argv) nof_frames = (int)strtol(argv[optind], NULL, 10); break; case 'v': - srslte_verbose++; + srsran_verbose++; break; default: usage(argv[0]); @@ -110,8 +110,8 @@ int main(int argc, char** argv) { cf_t* buffer; int n; - srslte_rf_t rf; - srslte_nsss_synch_t nsss; + srsran_rf_t rf; + srsran_nsss_synch_t nsss; float nsss_peak_value; parse_args(argc, argv); @@ -123,56 +123,56 @@ int main(int argc, char** argv) printf("Input length %d samples\n", input_len); printf("Opening RF device...\n"); - if (srslte_rf_open(&rf, rf_args)) { + if (srsran_rf_open(&rf, rf_args)) { fprintf(stderr, "Error opening rf\n"); exit(-1); } - srslte_rf_set_rx_gain(&rf, rf_gain); - printf("Set RX rate: %.2f MHz\n", srslte_rf_set_rx_srate(&rf, srate) / 1000000); - printf("Set RX gain: %.1f dB\n", srslte_rf_get_rx_gain(&rf)); - printf("Set RX freq: %.2f MHz\n", srslte_rf_set_rx_freq(&rf, 0, rf_freq) / 1000000); + srsran_rf_set_rx_gain(&rf, rf_gain); + printf("Set RX rate: %.2f MHz\n", srsran_rf_set_rx_srate(&rf, srate) / 1000000); + printf("Set RX gain: %.1f dB\n", srsran_rf_get_rx_gain(&rf)); + printf("Set RX freq: %.2f MHz\n", srsran_rf_set_rx_freq(&rf, 0, rf_freq) / 1000000); - buffer = srslte_vec_cf_malloc(input_len * 2); + buffer = srsran_vec_cf_malloc(input_len * 2); if (!buffer) { perror("malloc"); exit(-1); } - if (srslte_nsss_synch_init(&nsss, input_len, fft_size)) { + if (srsran_nsss_synch_init(&nsss, input_len, fft_size)) { fprintf(stderr, "Error initializing NSSS object\n"); exit(-1); } - srslte_rf_start_rx_stream(&rf, false); + srsran_rf_start_rx_stream(&rf, false); printf("Receiving two full frames ..\n"); - n = srslte_rf_recv(&rf, buffer, input_len, 1); + n = srsran_rf_recv(&rf, buffer, input_len, 1); if (n != input_len) { fprintf(stderr, "Error receiving samples\n"); exit(-1); } - srslte_rf_close(&rf); + srsran_rf_close(&rf); // perform CFO correction if (has_cfo_corr) { - srslte_cfo_t cfocorr; - if (srslte_cfo_init(&cfocorr, input_len)) { + srsran_cfo_t cfocorr; + if (srsran_cfo_init(&cfocorr, input_len)) { fprintf(stderr, "Error initiating CFO\n"); exit(-1); } - srslte_cfo_set_tol(&cfocorr, 50.0 / (15000.0 * fft_size)); - srslte_cfo_correct(&cfocorr, buffer, buffer, -cfo_fixed / (15000 * fft_size)); - srslte_cfo_free(&cfocorr); + srsran_cfo_set_tol(&cfocorr, 50.0 / (15000.0 * fft_size)); + srsran_cfo_correct(&cfocorr, buffer, buffer, -cfo_fixed / (15000 * fft_size)); + srsran_cfo_free(&cfocorr); } // try to find NSSS printf("Detecting cell id ..\n"); - uint32_t cell_id = SRSLTE_CELL_ID_UNKNOWN; + uint32_t cell_id = SRSRAN_CELL_ID_UNKNOWN; uint32_t sfn_partial; - srslte_nsss_sync_find(&nsss, buffer, &nsss_peak_value, &cell_id, &sfn_partial); + srsran_nsss_sync_find(&nsss, buffer, &nsss_peak_value, &cell_id, &sfn_partial); printf("Cell id: %d, peak_value=%f\n", cell_id, nsss_peak_value); - srslte_nsss_synch_free(&nsss); + srsran_nsss_synch_free(&nsss); free(buffer); printf("Ok\n"); diff --git a/lib/src/phy/sync/test/pss_file.c b/lib/src/phy/sync/test/pss_file.c index d17dff5f6..207f63910 100644 --- a/lib/src/phy/sync/test/pss_file.c +++ b/lib/src/phy/sync/test/pss_file.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -20,11 +20,11 @@ #include -#include "srslte/srslte.h" +#include "srsran/srsran.h" #ifdef ENABLE_GUI void init_plots(); -void do_plots(float* corr, float energy, uint32_t size, cf_t ce[SRSLTE_PSS_LEN]); +void do_plots(float* corr, float energy, uint32_t size, cf_t ce[SRSRAN_PSS_LEN]); void do_plots_sss(float* corr_m0, float* corr_m1); void destroy_plots(); #endif /* ENABLE_GUI */ @@ -36,7 +36,7 @@ int nof_frames = -1; uint32_t fft_size = 64; float threshold = 0.4; int N_id_2_sync = -1; -srslte_cp_t cp = SRSLTE_CP_NORM; +srsran_cp_t cp = SRSRAN_CP_NORM; int file_offset = 0; void usage(char* prog) @@ -53,7 +53,7 @@ void usage(char* prog) #else /* ENABLE_GUI */ printf("\t plots are disabled. Graphics library not available\n"); #endif /* ENABLE_GUI */ - printf("\t-v srslte_verbose\n"); + printf("\t-v srsran_verbose\n"); } void parse_args(int argc, char** argv) @@ -68,7 +68,7 @@ void parse_args(int argc, char** argv) threshold = strtof(argv[optind], NULL); break; case 'e': - cp = SRSLTE_CP_EXT; + cp = SRSRAN_CP_EXT; break; case 'i': cell_id = (int)strtol(argv[optind], NULL, 10); @@ -89,7 +89,7 @@ void parse_args(int argc, char** argv) disable_plots = true; break; case 'v': - srslte_verbose++; + srsran_verbose++; break; default: usage(argv[0]); @@ -105,18 +105,18 @@ float m0_value, m1_value; int main(int argc, char** argv) { - srslte_filesource_t fsrc; + srsran_filesource_t fsrc; cf_t* buffer; int frame_cnt, n; - srslte_pss_t pss; - srslte_cfo_t cfocorr, cfocorr64; - srslte_sss_t sss; + srsran_pss_t pss; + srsran_cfo_t cfocorr, cfocorr64; + srsran_sss_t sss; int32_t flen; int peak_idx, last_peak; float peak_value; float mean_peak; uint32_t nof_det, nof_nodet, nof_nopeak, nof_nopeakdet; - cf_t ce[SRSLTE_PSS_LEN]; + cf_t ce[SRSRAN_PSS_LEN]; parse_args(argc, argv); @@ -133,34 +133,34 @@ int main(int argc, char** argv) flen = fft_size * 15 * 5; - buffer = srslte_vec_cf_malloc(flen * 2); + buffer = srsran_vec_cf_malloc(flen * 2); if (!buffer) { perror("malloc"); exit(-1); } - if (srslte_pss_init_fft(&pss, flen, fft_size)) { + if (srsran_pss_init_fft(&pss, flen, fft_size)) { ERROR("Error initiating PSS"); exit(-1); } - if (srslte_pss_set_N_id_2(&pss, N_id_2_sync)) { + if (srsran_pss_set_N_id_2(&pss, N_id_2_sync)) { ERROR("Error setting N_id_2=%d", N_id_2_sync); exit(-1); } - srslte_cfo_init(&cfocorr, flen); - srslte_cfo_init(&cfocorr64, flen); + srsran_cfo_init(&cfocorr, flen); + srsran_cfo_init(&cfocorr64, flen); - if (srslte_sss_init(&sss, fft_size)) { + if (srsran_sss_init(&sss, fft_size)) { ERROR("Error initializing SSS object"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - srslte_sss_set_N_id_2(&sss, N_id_2); + srsran_sss_set_N_id_2(&sss, N_id_2); printf("Opening file...\n"); - if (srslte_filesource_init(&fsrc, input_file_name, SRSLTE_COMPLEX_FLOAT_BIN)) { + if (srsran_filesource_init(&fsrc, input_file_name, SRSRAN_COMPLEX_FLOAT_BIN)) { ERROR("Error opening file %s", input_file_name); exit(-1); } @@ -180,14 +180,14 @@ int main(int argc, char** argv) uint32_t sss_error1 = 0, sss_error2 = 0, sss_error3 = 0; uint32_t cp_is_norm = 0; - srslte_sync_t ssync; - bzero(&ssync, sizeof(srslte_sync_t)); + srsran_sync_t ssync; + bzero(&ssync, sizeof(srsran_sync_t)); ssync.fft_size = fft_size; - n = srslte_filesource_read(&fsrc, buffer, file_offset); + n = srsran_filesource_read(&fsrc, buffer, file_offset); while (frame_cnt < nof_frames || nof_frames == -1) { - n = srslte_filesource_read(&fsrc, buffer, flen - peak_offset); + n = srsran_filesource_read(&fsrc, buffer, flen - peak_offset); if (n < 0) { ERROR("Error reading samples"); exit(-1); @@ -197,58 +197,58 @@ int main(int argc, char** argv) break; } - peak_idx = srslte_pss_find_pss(&pss, buffer, &peak_value); + peak_idx = srsran_pss_find_pss(&pss, buffer, &peak_value); if (peak_idx < 0) { ERROR("Error finding PSS peak"); exit(-1); } - mean_peak = SRSLTE_VEC_CMA(peak_value, mean_peak, frame_cnt); + mean_peak = SRSRAN_VEC_CMA(peak_value, mean_peak, frame_cnt); if (peak_value >= threshold) { nof_det++; if (peak_idx >= fft_size) { // Estimate CFO - cfo = srslte_pss_cfo_compute(&pss, &buffer[peak_idx - fft_size]); - mean_cfo = SRSLTE_VEC_CMA(cfo, mean_cfo, frame_cnt); + cfo = srsran_pss_cfo_compute(&pss, &buffer[peak_idx - fft_size]); + mean_cfo = SRSRAN_VEC_CMA(cfo, mean_cfo, frame_cnt); // Correct CFO - srslte_cfo_correct(&cfocorr, buffer, buffer, -mean_cfo / fft_size); + srsran_cfo_correct(&cfocorr, buffer, buffer, -mean_cfo / fft_size); // Estimate channel - if (srslte_pss_chest(&pss, &buffer[peak_idx - fft_size], ce)) { + if (srsran_pss_chest(&pss, &buffer[peak_idx - fft_size], ce)) { ERROR("Error computing channel estimation"); exit(-1); } // Find SSS int sss_idx = peak_idx - 2 * fft_size - - (SRSLTE_CP_ISNORM(cp) ? SRSLTE_CP_LEN(fft_size, SRSLTE_CP_NORM_LEN) - : SRSLTE_CP_LEN(fft_size, SRSLTE_CP_EXT_LEN)); + (SRSRAN_CP_ISNORM(cp) ? SRSRAN_CP_LEN(fft_size, SRSRAN_CP_NORM_LEN) + : SRSRAN_CP_LEN(fft_size, SRSRAN_CP_EXT_LEN)); if (sss_idx >= 0 && sss_idx < flen - fft_size) { - srslte_sss_m0m1_partial(&sss, &buffer[sss_idx], 3, NULL, &m0, &m0_value, &m1, &m1_value); - if (srslte_sss_N_id_1(&sss, m0, m1, m1_value + m0_value) != N_id_1) { + srsran_sss_m0m1_partial(&sss, &buffer[sss_idx], 3, NULL, &m0, &m0_value, &m1, &m1_value); + if (srsran_sss_N_id_1(&sss, m0, m1, m1_value + m0_value) != N_id_1) { sss_error2++; } - INFO("sf_idx = %d", srslte_sss_subframe(m0, m1)); - INFO("Partial N_id_1: %d", srslte_sss_N_id_1(&sss, m0, m1, m1_value + m0_value)); - srslte_sss_m0m1_diff(&sss, &buffer[sss_idx], &m0, &m0_value, &m1, &m1_value); - if (srslte_sss_N_id_1(&sss, m0, m1, m1_value + m0_value) != N_id_1) { + INFO("sf_idx = %d", srsran_sss_subframe(m0, m1)); + INFO("Partial N_id_1: %d", srsran_sss_N_id_1(&sss, m0, m1, m1_value + m0_value)); + srsran_sss_m0m1_diff(&sss, &buffer[sss_idx], &m0, &m0_value, &m1, &m1_value); + if (srsran_sss_N_id_1(&sss, m0, m1, m1_value + m0_value) != N_id_1) { sss_error3++; } - INFO("Diff N_id_1: %d", srslte_sss_N_id_1(&sss, m0, m1, m1_value + m0_value)); - srslte_sss_m0m1_partial(&sss, &buffer[sss_idx], 1, NULL, &m0, &m0_value, &m1, &m1_value); - if (srslte_sss_N_id_1(&sss, m0, m1, m1_value + m0_value) != N_id_1) { + INFO("Diff N_id_1: %d", srsran_sss_N_id_1(&sss, m0, m1, m1_value + m0_value)); + srsran_sss_m0m1_partial(&sss, &buffer[sss_idx], 1, NULL, &m0, &m0_value, &m1, &m1_value); + if (srsran_sss_N_id_1(&sss, m0, m1, m1_value + m0_value) != N_id_1) { sss_error1++; } - INFO("Full N_id_1: %d", srslte_sss_N_id_1(&sss, m0, m1, m1_value + m0_value)); + INFO("Full N_id_1: %d", srsran_sss_N_id_1(&sss, m0, m1, m1_value + m0_value)); } // Estimate CP - if (peak_idx > 2 * (fft_size + SRSLTE_CP_LEN_EXT(fft_size))) { - srslte_cp_t cp = srslte_sync_detect_cp(&ssync, buffer, peak_idx); - if (SRSLTE_CP_ISNORM(cp)) { + if (peak_idx > 2 * (fft_size + SRSRAN_CP_LEN_EXT(fft_size))) { + srsran_cp_t cp = srsran_sync_detect_cp(&ssync, buffer, peak_idx); + if (SRSRAN_CP_ISNORM(cp)) { cp_is_norm++; } } @@ -257,7 +257,7 @@ int main(int argc, char** argv) INFO("No space for CFO computation. Frame starts at "); } - if (srslte_sss_subframe(m0, m1) == 0) { + if (srsran_sss_subframe(m0, m1) == 0) { #ifdef ENABLE_GUI if (!disable_plots) do_plots_sss(sss.corr_output_m0, sss.corr_output_m1); @@ -293,7 +293,7 @@ int main(int argc, char** argv) (float)sss_error3 / nof_det, (float)cp_is_norm / nof_det * 100); - if (SRSLTE_VERBOSE_ISINFO()) { + if (SRSRAN_VERBOSE_ISINFO()) { printf("\n"); } @@ -307,9 +307,9 @@ int main(int argc, char** argv) last_peak = peak_idx; } - srslte_pss_free(&pss); + srsran_pss_free(&pss); free(buffer); - srslte_filesource_free(&fsrc); + srsran_filesource_free(&fsrc); #ifdef ENABLE_GUI if (!disable_plots) destroy_plots(); @@ -333,7 +333,7 @@ plot_real_t pssout; plot_real_t psss1; //, psss2; float tmp[1000000]; -cf_t tmpce[SRSLTE_PSS_LEN]; +cf_t tmpce[SRSRAN_PSS_LEN]; void init_plots() { @@ -365,26 +365,26 @@ void init_plots() */ } -void do_plots(float* corr, float energy, uint32_t size, cf_t ce[SRSLTE_PSS_LEN]) +void do_plots(float* corr, float energy, uint32_t size, cf_t ce[SRSRAN_PSS_LEN]) { - srslte_vec_sc_prod_fff(corr, 1. / energy, tmp, size); + srsran_vec_sc_prod_fff(corr, 1. / energy, tmp, size); plot_real_setNewData(&pssout, tmp, size); - // float norm = srslte_vec_avg_power_cf(ce, SRSLTE_PSS_LEN); - // srslte_vec_sc_prod_cfc(ce, 1.0/sqrt(norm), tmpce, SRSLTE_PSS_LEN); + // float norm = srsran_vec_avg_power_cf(ce, SRSRAN_PSS_LEN); + // srsran_vec_sc_prod_cfc(ce, 1.0/sqrt(norm), tmpce, SRSRAN_PSS_LEN); - // plot_complex_setNewData(&pce, tmpce, SRSLTE_PSS_LEN); + // plot_complex_setNewData(&pce, tmpce, SRSRAN_PSS_LEN); } void do_plots_sss(float* corr_m0, float* corr_m1) { if (m0_value > 0) - srslte_vec_sc_prod_fff(corr_m0, 1. / m0_value, corr_m0, SRSLTE_SSS_N); - plot_real_setNewData(&psss1, corr_m0, SRSLTE_SSS_N); + srsran_vec_sc_prod_fff(corr_m0, 1. / m0_value, corr_m0, SRSRAN_SSS_N); + plot_real_setNewData(&psss1, corr_m0, SRSRAN_SSS_N); // if (m1_value > 0) - // srslte_vec_sc_prod_fff(corr_m1,1./m1_value,corr_m1, SRSLTE_SSS_N); - // plot_real_setNewData(&psss2, corr_m1, SRSLTE_SSS_N); + // srsran_vec_sc_prod_fff(corr_m1,1./m1_value,corr_m1, SRSRAN_SSS_N); + // plot_real_setNewData(&psss2, corr_m1, SRSRAN_SSS_N); } void destroy_plots() diff --git a/lib/src/phy/sync/test/pss_usrp.c b/lib/src/phy/sync/test/pss_usrp.c index d0f0f33e8..cef871189 100644 --- a/lib/src/phy/sync/test/pss_usrp.c +++ b/lib/src/phy/sync/test/pss_usrp.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -20,8 +20,8 @@ #include -#include "srslte/phy/rf/rf.h" -#include "srslte/srslte.h" +#include "srsran/phy/rf/rf.h" +#include "srsran/srsran.h" #ifdef ENABLE_GUI void init_plots(); @@ -38,7 +38,7 @@ int nof_frames = -1; uint32_t fft_size = 64; float threshold = 0.4; int N_id_2_sync = -1; -srslte_cp_t cp = SRSLTE_CP_NORM; +srsran_cp_t cp = SRSRAN_CP_NORM; void usage(char* prog) { @@ -56,7 +56,7 @@ void usage(char* prog) #else printf("\t plots are disabled. Graphics library not available\n"); #endif - printf("\t-v srslte_verbose\n"); + printf("\t-v srsran_verbose\n"); } void parse_args(int argc, char** argv) @@ -77,7 +77,7 @@ void parse_args(int argc, char** argv) threshold = strtof(argv[optind], NULL); break; case 'e': - cp = SRSLTE_CP_EXT; + cp = SRSRAN_CP_EXT; break; case 'i': cell_id = (int)strtol(argv[optind], NULL, 10); @@ -98,7 +98,7 @@ void parse_args(int argc, char** argv) disable_plots = true; break; case 'v': - srslte_verbose++; + srsran_verbose++; break; default: usage(argv[0]); @@ -116,16 +116,16 @@ int main(int argc, char** argv) { cf_t* buffer; int frame_cnt, n; - srslte_rf_t rf; - srslte_pss_t pss; - srslte_cfo_t cfocorr, cfocorr64; - srslte_sss_t sss; + srsran_rf_t rf; + srsran_pss_t pss; + srsran_cfo_t cfocorr, cfocorr64; + srsran_sss_t sss; int32_t flen; int peak_idx, last_peak; float peak_value; float mean_peak; uint32_t nof_det, nof_nodet, nof_nopeak, nof_nopeakdet; - cf_t ce[SRSLTE_PSS_LEN]; + cf_t ce[SRSRAN_PSS_LEN]; float sfo = 0; parse_args(argc, argv); @@ -146,44 +146,44 @@ int main(int argc, char** argv) flen = srate * 5 / 1000; printf("Opening RF device...\n"); - if (srslte_rf_open(&rf, rf_args)) { + if (srsran_rf_open(&rf, rf_args)) { ERROR("Error opening rf"); exit(-1); } - srslte_rf_set_rx_gain(&rf, rf_gain); - printf("Set RX rate: %.2f MHz\n", srslte_rf_set_rx_srate(&rf, srate) / 1000000); - printf("Set RX gain: %.1f dB\n", srslte_rf_get_rx_gain(&rf)); - printf("Set RX freq: %.2f MHz\n", srslte_rf_set_rx_freq(&rf, 0, rf_freq) / 1000000); + srsran_rf_set_rx_gain(&rf, rf_gain); + printf("Set RX rate: %.2f MHz\n", srsran_rf_set_rx_srate(&rf, srate) / 1000000); + printf("Set RX gain: %.1f dB\n", srsran_rf_get_rx_gain(&rf)); + printf("Set RX freq: %.2f MHz\n", srsran_rf_set_rx_freq(&rf, 0, rf_freq) / 1000000); - buffer = srslte_vec_cf_malloc(flen * 2); + buffer = srsran_vec_cf_malloc(flen * 2); if (!buffer) { perror("malloc"); exit(-1); } - if (srslte_pss_init_fft(&pss, flen, fft_size)) { + if (srsran_pss_init_fft(&pss, flen, fft_size)) { ERROR("Error initiating PSS"); exit(-1); } - if (srslte_pss_set_N_id_2(&pss, N_id_2_sync)) { + if (srsran_pss_set_N_id_2(&pss, N_id_2_sync)) { ERROR("Error setting N_id_2=%d", N_id_2_sync); exit(-1); } - srslte_cfo_init(&cfocorr, flen); - srslte_cfo_init(&cfocorr64, flen); + srsran_cfo_init(&cfocorr, flen); + srsran_cfo_init(&cfocorr64, flen); - if (srslte_sss_init(&sss, fft_size)) { + if (srsran_sss_init(&sss, fft_size)) { ERROR("Error initializing SSS object"); exit(-1); } - srslte_sss_set_N_id_2(&sss, N_id_2); + srsran_sss_set_N_id_2(&sss, N_id_2); printf("N_id_2: %d\n", N_id_2); - srslte_rf_start_rx_stream(&rf, false); + srsran_rf_start_rx_stream(&rf, false); printf("Frame length %d samples\n", flen); printf("PSS detection threshold: %.2f\n", threshold); @@ -199,8 +199,8 @@ int main(int argc, char** argv) uint32_t sss_error1 = 0, sss_error2 = 0, sss_error3 = 0; uint32_t cp_is_norm = 0; - srslte_sync_t ssync; - bzero(&ssync, sizeof(srslte_sync_t)); + srsran_sync_t ssync; + bzero(&ssync, sizeof(srsran_sync_t)); ssync.fft_size = fft_size; uint32_t max_peak = 0; @@ -211,33 +211,33 @@ int main(int argc, char** argv) pss.filter_pss_enable = true; while (frame_cnt < nof_frames || nof_frames == -1) { - n = srslte_rf_recv(&rf, buffer, flen - peak_offset, 1); + n = srsran_rf_recv(&rf, buffer, flen - peak_offset, 1); if (n < 0) { ERROR("Error receiving samples"); exit(-1); } - peak_idx = srslte_pss_find_pss(&pss, buffer, &peak_value); + peak_idx = srsran_pss_find_pss(&pss, buffer, &peak_value); if (peak_idx < 0) { ERROR("Error finding PSS peak"); exit(-1); } - mean_peak = SRSLTE_VEC_CMA(peak_value, mean_peak, frame_cnt); + mean_peak = SRSRAN_VEC_CMA(peak_value, mean_peak, frame_cnt); if (peak_value >= threshold) { nof_det++; if (peak_idx >= fft_size) { // Estimate CFO - cfo = srslte_pss_cfo_compute(&pss, &buffer[peak_idx - fft_size]); - mean_cfo = SRSLTE_VEC_CMA(cfo, mean_cfo, frame_cnt); + cfo = srsran_pss_cfo_compute(&pss, &buffer[peak_idx - fft_size]); + mean_cfo = SRSRAN_VEC_CMA(cfo, mean_cfo, frame_cnt); // Correct CFO - srslte_cfo_correct(&cfocorr, buffer, buffer, -mean_cfo / fft_size); + srsran_cfo_correct(&cfocorr, buffer, buffer, -mean_cfo / fft_size); // Estimate channel - if (srslte_pss_chest(&pss, &buffer[peak_idx - fft_size], ce)) { + if (srsran_pss_chest(&pss, &buffer[peak_idx - fft_size], ce)) { ERROR("Error computing channel estimation"); exit(-1); } @@ -246,38 +246,38 @@ int main(int argc, char** argv) int sss_idx; if (!tdd_mode) { sss_idx = peak_idx - 2 * fft_size - - (SRSLTE_CP_ISNORM(cp) ? SRSLTE_CP_LEN(fft_size, SRSLTE_CP_NORM_LEN) - : SRSLTE_CP_LEN(fft_size, SRSLTE_CP_EXT_LEN)); + (SRSRAN_CP_ISNORM(cp) ? SRSRAN_CP_LEN(fft_size, SRSRAN_CP_NORM_LEN) + : SRSRAN_CP_LEN(fft_size, SRSRAN_CP_EXT_LEN)); } else { sss_idx = peak_idx - 4 * fft_size - - 3 * (SRSLTE_CP_ISNORM(cp) ? SRSLTE_CP_LEN(fft_size, SRSLTE_CP_NORM_LEN) - : SRSLTE_CP_LEN(fft_size, SRSLTE_CP_EXT_LEN)); + 3 * (SRSRAN_CP_ISNORM(cp) ? SRSRAN_CP_LEN(fft_size, SRSRAN_CP_NORM_LEN) + : SRSRAN_CP_LEN(fft_size, SRSRAN_CP_EXT_LEN)); } if (sss_idx >= 0 && sss_idx < flen - fft_size) { // Filter SSS - srslte_pss_filter(&pss, &buffer[sss_idx], &buffer[sss_idx]); + srsran_pss_filter(&pss, &buffer[sss_idx], &buffer[sss_idx]); - INFO("Full N_id_1: %d", srslte_sss_N_id_1(&sss, m0, m1, m1_value + m0_value)); - srslte_sss_m0m1_partial(&sss, &buffer[sss_idx], 1, ce, &m0, &m0_value, &m1, &m1_value); - if (srslte_sss_N_id_1(&sss, m0, m1, m1_value + m0_value) != N_id_1) { + INFO("Full N_id_1: %d", srsran_sss_N_id_1(&sss, m0, m1, m1_value + m0_value)); + srsran_sss_m0m1_partial(&sss, &buffer[sss_idx], 1, ce, &m0, &m0_value, &m1, &m1_value); + if (srsran_sss_N_id_1(&sss, m0, m1, m1_value + m0_value) != N_id_1) { sss_error2++; } - INFO("Partial N_id_1: %d", srslte_sss_N_id_1(&sss, m0, m1, m1_value + m0_value)); - srslte_sss_m0m1_diff_coh(&sss, &buffer[sss_idx], ce, &m0, &m0_value, &m1, &m1_value); - if (srslte_sss_N_id_1(&sss, m0, m1, m1_value + m0_value) != N_id_1) { + INFO("Partial N_id_1: %d", srsran_sss_N_id_1(&sss, m0, m1, m1_value + m0_value)); + srsran_sss_m0m1_diff_coh(&sss, &buffer[sss_idx], ce, &m0, &m0_value, &m1, &m1_value); + if (srsran_sss_N_id_1(&sss, m0, m1, m1_value + m0_value) != N_id_1) { sss_error3++; } - INFO("Diff N_id_1: %d", srslte_sss_N_id_1(&sss, m0, m1, m1_value + m0_value)); + INFO("Diff N_id_1: %d", srsran_sss_N_id_1(&sss, m0, m1, m1_value + m0_value)); } - srslte_sss_m0m1_partial(&sss, &buffer[sss_idx], 1, NULL, &m0, &m0_value, &m1, &m1_value); - if (srslte_sss_N_id_1(&sss, m0, m1, m1_value + m0_value) != N_id_1) { + srsran_sss_m0m1_partial(&sss, &buffer[sss_idx], 1, NULL, &m0, &m0_value, &m1, &m1_value); + if (srsran_sss_N_id_1(&sss, m0, m1, m1_value + m0_value) != N_id_1) { sss_error1++; } // Estimate CP - if (peak_idx > 2 * (fft_size + SRSLTE_CP_LEN_EXT(fft_size))) { - srslte_cp_t cp = srslte_sync_detect_cp(&ssync, buffer, peak_idx); - if (SRSLTE_CP_ISNORM(cp)) { + if (peak_idx > 2 * (fft_size + SRSRAN_CP_LEN_EXT(fft_size))) { + srsran_cp_t cp = srsran_sync_detect_cp(&ssync, buffer, peak_idx); + if (SRSRAN_CP_ISNORM(cp)) { cp_is_norm++; } } @@ -286,7 +286,7 @@ int main(int argc, char** argv) INFO("No space for CFO computation. Frame starts at "); } - if (srslte_sss_subframe(m0, m1) == 0) { + if (srsran_sss_subframe(m0, m1) == 0) { #ifdef ENABLE_GUI if (!disable_plots) do_plots_sss(sss.corr_output_m0, sss.corr_output_m1); @@ -322,7 +322,7 @@ int main(int argc, char** argv) nof_nopeak++; } - sfo = SRSLTE_VEC_CMA((peak_idx - last_peak) / 5e-3, sfo, frame_cnt); + sfo = SRSRAN_VEC_CMA((peak_idx - last_peak) / 5e-3, sfo, frame_cnt); int frame_idx = frame_cnt % 200; uint32_t peak_offset_symbol = peak_idx % fft_size; @@ -342,7 +342,7 @@ int main(int argc, char** argv) frame_cnt++; - if (SRSLTE_VERBOSE_ISINFO()) { + if (SRSRAN_VERBOSE_ISINFO()) { printf("\n"); } @@ -355,10 +355,10 @@ int main(int argc, char** argv) last_peak = peak_idx; } - srslte_sss_free(&sss); - srslte_pss_free(&pss); + srsran_sss_free(&sss); + srsran_pss_free(&pss); free(buffer); - srslte_rf_close(&rf); + srsran_rf_close(&rf); printf("Ok\n"); exit(0); @@ -378,7 +378,7 @@ plot_real_t pssout; plot_real_t psss1; float tmp[1000000]; -cf_t tmpce[SRSLTE_PSS_LEN]; +cf_t tmpce[SRSRAN_PSS_LEN]; void init_plots() { @@ -405,15 +405,15 @@ void init_plots() void do_plots_pss(float* corr, float peak, uint32_t size) { - srslte_vec_sc_prod_fff(corr, 1. / peak, tmp, size); + srsran_vec_sc_prod_fff(corr, 1. / peak, tmp, size); plot_real_setNewData(&pssout, tmp, size); } void do_plots_sss(float* corr_m0, float* corr_m1) { if (m0_value > 0) - srslte_vec_sc_prod_fff(corr_m0, 1. / m0_value, corr_m0, SRSLTE_SSS_N); - plot_real_setNewData(&psss1, corr_m0, SRSLTE_SSS_N); + srsran_vec_sc_prod_fff(corr_m0, 1. / m0_value, corr_m0, SRSRAN_SSS_N); + plot_real_setNewData(&psss1, corr_m0, SRSRAN_SSS_N); } #endif /* ENABLE_GUI */ diff --git a/lib/src/phy/sync/test/psss_file_test.c b/lib/src/phy/sync/test/psss_file_test.c index cf050d320..2c29ee9fd 100644 --- a/lib/src/phy/sync/test/psss_file_test.c +++ b/lib/src/phy/sync/test/psss_file_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -20,20 +20,20 @@ #include -#include "srslte/phy/sync/psss.h" -#include "srslte/phy/sync/ssss.h" -#include "srslte/srslte.h" +#include "srsran/phy/sync/psss.h" +#include "srsran/phy/sync/ssss.h" +#include "srsran/srsran.h" char* input_file_name; float frequency_offset = 0.0; float snr = 100.0; -srslte_cp_t cp = SRSLTE_CP_NORM; +srsran_cp_t cp = SRSRAN_CP_NORM; uint32_t nof_prb = 6; bool use_standard_lte_rates = false; -srslte_sl_tm_t tm = SRSLTE_SIDELINK_TM2; +srsran_sl_tm_t tm = SRSRAN_SIDELINK_TM2; uint32_t max_subframes = 10; -srslte_filesource_t fsrc; +srsran_filesource_t fsrc; void usage(char* prog) { @@ -44,7 +44,7 @@ void usage(char* prog) printf("\t-m max_subframes [Default %d]\n", max_subframes); printf("\t-t Sidelink transmission mode {1,2,3,4} [Default %d]\n", (tm + 1)); printf("\t-d use_standard_lte_rates [Default %i]\n", use_standard_lte_rates); - printf("\t-v srslte_verbose\n"); + printf("\t-v srsran_verbose\n"); } void parse_args(int argc, char** argv) @@ -70,16 +70,16 @@ void parse_args(int argc, char** argv) case 't': switch (strtol(argv[optind], NULL, 10)) { case 1: - tm = SRSLTE_SIDELINK_TM1; + tm = SRSRAN_SIDELINK_TM1; break; case 2: - tm = SRSLTE_SIDELINK_TM2; + tm = SRSRAN_SIDELINK_TM2; break; case 3: - tm = SRSLTE_SIDELINK_TM3; + tm = SRSRAN_SIDELINK_TM3; break; case 4: - tm = SRSLTE_SIDELINK_TM4; + tm = SRSRAN_SIDELINK_TM4; break; default: usage(argv[0]); @@ -87,7 +87,7 @@ void parse_args(int argc, char** argv) } break; case 'v': - srslte_verbose++; + srsran_verbose++; break; default: usage(argv[0]); @@ -99,26 +99,26 @@ void parse_args(int argc, char** argv) int main(int argc, char** argv) { parse_args(argc, argv); - srslte_use_standard_symbol_size(use_standard_lte_rates); + srsran_use_standard_symbol_size(use_standard_lte_rates); - if (!input_file_name || srslte_filesource_init(&fsrc, input_file_name, SRSLTE_COMPLEX_FLOAT_BIN)) { + if (!input_file_name || srsran_filesource_init(&fsrc, input_file_name, SRSRAN_COMPLEX_FLOAT_BIN)) { printf("Error opening file %s\n", input_file_name); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // alloc memory - uint32_t sf_n_samples = SRSLTE_SF_LEN_PRB(nof_prb); + uint32_t sf_n_samples = SRSRAN_SF_LEN_PRB(nof_prb); printf("I/Q samples per subframe=%d\n", sf_n_samples); - uint32_t sf_n_re = SRSLTE_CP_NSYMB(SRSLTE_CP_NORM) * SRSLTE_NRE * 2 * nof_prb; - cf_t* sf_buffer = srslte_vec_cf_malloc(sf_n_re); + uint32_t sf_n_re = SRSRAN_CP_NSYMB(SRSRAN_CP_NORM) * SRSRAN_NRE * 2 * nof_prb; + cf_t* sf_buffer = srsran_vec_cf_malloc(sf_n_re); - cf_t* input_buffer = srslte_vec_cf_malloc(sf_n_samples); - cf_t* input_buffer_temp = srslte_vec_cf_malloc(sf_n_samples); + cf_t* input_buffer = srsran_vec_cf_malloc(sf_n_samples); + cf_t* input_buffer_temp = srsran_vec_cf_malloc(sf_n_samples); // init PSSS - srslte_psss_t psss = {}; - srslte_psss_init(&psss, nof_prb, cp); + srsran_psss_t psss = {}; + srsran_psss_init(&psss, nof_prb, cp); struct timeval t[3]; gettimeofday(&t[1], NULL); @@ -129,17 +129,17 @@ int main(int argc, char** argv) do { // Read and normalize samples from file - samples_read = srslte_filesource_read(&fsrc, input_buffer, sf_n_samples); + samples_read = srsran_filesource_read(&fsrc, input_buffer, sf_n_samples); if (samples_read == 0) { // read entire file break; } else if (samples_read != sf_n_samples) { printf("Could only read %d of %d requested samples\n", samples_read, sf_n_samples); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Find PSSS signal - if (srslte_psss_find(&psss, input_buffer, nof_prb, cp) == SRSLTE_SUCCESS) { + if (srsran_psss_find(&psss, input_buffer, nof_prb, cp) == SRSRAN_SUCCESS) { printf("PSSS correlation peak pos: %d value: %f N_id_2: %d\n", psss.corr_peak_pos, psss.corr_peak_value, @@ -149,11 +149,11 @@ int main(int argc, char** argv) num_subframes++; } while (samples_read == sf_n_samples && num_subframes < max_subframes); - srslte_filesource_free(&fsrc); - srslte_psss_free(&psss); + srsran_filesource_free(&fsrc); + srsran_psss_free(&psss); free(input_buffer); free(input_buffer_temp); free(sf_buffer); - return (sync == SRSLTE_SUCCESS); + return (sync == SRSRAN_SUCCESS); } diff --git a/lib/src/phy/sync/test/sync_nbiot_test.c b/lib/src/phy/sync/test/sync_nbiot_test.c index 7202971c2..41cda5c7f 100644 --- a/lib/src/phy/sync/test/sync_nbiot_test.c +++ b/lib/src/phy/sync/test/sync_nbiot_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -21,8 +21,8 @@ #include -#include "srslte/phy/sync/sync_nbiot.h" -#include "srslte/srslte.h" +#include "srsran/phy/sync/sync_nbiot.h" +#include "srsran/srsran.h" int offset = 0; float cfo = 0.0; @@ -34,7 +34,7 @@ char* input_file_name; #define DUMP_SIGNALS 1 #define MAX_CORR_LEN 10000 -#define SFLEN (10 * SRSLTE_SF_LEN(128)) +#define SFLEN (10 * SRSRAN_SF_LEN(128)) void usage(char* prog) { @@ -42,7 +42,7 @@ void usage(char* prog) printf("\t-c add CFO [Default %f]\n", cfo); printf("\t-g add AWGN with target SNR [Default off]\n"); printf("\t-o offset [Default %d]\n", offset); - printf("\t-v srslte_verbose\n"); + printf("\t-v srsran_verbose\n"); } void parse_args(int argc, char** argv) @@ -63,7 +63,7 @@ void parse_args(int argc, char** argv) offset = (int)strtol(argv[optind], NULL, 10); break; case 'v': - srslte_verbose = SRSLTE_VERBOSE_DEBUG; + srsran_verbose = SRSRAN_VERBOSE_DEBUG; break; default: usage(argv[0]); @@ -74,16 +74,16 @@ void parse_args(int argc, char** argv) int main(int argc, char** argv) { - int ret = SRSLTE_ERROR; + int ret = SRSRAN_ERROR; int sf_idx = 0; cf_t* fft_buffer = NULL; _Complex float buffer[SFLEN]; // FLEN + fft_size - srslte_filesource_t fsrc = {}; + srsran_filesource_t fsrc = {}; uint32_t find_idx = 0; - srslte_sync_nbiot_t syncobj = {}; - srslte_ofdm_t ifft = {}; - srslte_cfo_t cfocorr = {}; + srsran_sync_nbiot_t syncobj = {}; + srsran_ofdm_t ifft = {}; + srsran_cfo_t cfocorr = {}; int fft_size = 0; input_file_name = NULL; @@ -92,20 +92,20 @@ int main(int argc, char** argv) if (input_file_name != NULL) { printf("Opening file...\n"); - if (srslte_filesource_init(&fsrc, input_file_name, SRSLTE_COMPLEX_FLOAT_BIN)) { + if (srsran_filesource_init(&fsrc, input_file_name, SRSRAN_COMPLEX_FLOAT_BIN)) { fprintf(stderr, "Error opening file %s\n", input_file_name); goto exit; } } - fft_size = srslte_symbol_sz(SRSLTE_NBIOT_DEFAULT_NUM_PRB_BASECELL); + fft_size = srsran_symbol_sz(SRSRAN_NBIOT_DEFAULT_NUM_PRB_BASECELL); if (fft_size < 0) { - fprintf(stderr, "Invalid nof_prb=%d\n", SRSLTE_NBIOT_DEFAULT_NUM_PRB_BASECELL); + fprintf(stderr, "Invalid nof_prb=%d\n", SRSRAN_NBIOT_DEFAULT_NUM_PRB_BASECELL); exit(-1); } printf("SFLEN is %d samples\n", SFLEN); - fft_buffer = srslte_vec_cf_malloc(SFLEN * 2); + fft_buffer = srsran_vec_cf_malloc(SFLEN * 2); if (!fft_buffer) { perror("malloc"); goto exit; @@ -113,45 +113,45 @@ int main(int argc, char** argv) memset(buffer, 0, sizeof(cf_t) * SFLEN); - if (srslte_cfo_init(&cfocorr, SFLEN)) { + if (srsran_cfo_init(&cfocorr, SFLEN)) { fprintf(stderr, "Error initiating CFO\n"); goto exit; } // Set a CFO tolerance of approx 100 Hz - srslte_cfo_set_tol(&cfocorr, 100.0 / (15000.0 * fft_size)); + srsran_cfo_set_tol(&cfocorr, 100.0 / (15000.0 * fft_size)); // init synch object for a maximum SFLEN samples - if (srslte_sync_nbiot_init(&syncobj, SFLEN, SFLEN, fft_size)) { + if (srsran_sync_nbiot_init(&syncobj, SFLEN, SFLEN, fft_size)) { fprintf(stderr, "Error initiating NPSS/NSSS\n"); goto exit; } - srslte_sync_nbiot_set_cfo_enable(&syncobj, true); + srsran_sync_nbiot_set_cfo_enable(&syncobj, true); if (input_file_name == NULL) { // generating test sequence - if (srslte_ofdm_tx_init( - &ifft, SRSLTE_CP_NORM, buffer, &fft_buffer[offset], SRSLTE_NBIOT_DEFAULT_NUM_PRB_BASECELL)) { + if (srsran_ofdm_tx_init( + &ifft, SRSRAN_CP_NORM, buffer, &fft_buffer[offset], SRSRAN_NBIOT_DEFAULT_NUM_PRB_BASECELL)) { fprintf(stderr, "Error creating iFFT object\n"); goto exit; } - srslte_ofdm_set_normalize(&ifft, true); - srslte_ofdm_set_freq_shift(&ifft, -SRSLTE_NBIOT_FREQ_SHIFT_FACTOR); + srsran_ofdm_set_normalize(&ifft, true); + srsran_ofdm_set_freq_shift(&ifft, -SRSRAN_NBIOT_FREQ_SHIFT_FACTOR); // generate NPSS/NSSS signals - cf_t npss_signal[SRSLTE_NPSS_TOT_LEN]; - srslte_npss_generate(npss_signal); - srslte_npss_put_subframe( - &syncobj.npss, npss_signal, buffer, SRSLTE_NBIOT_DEFAULT_NUM_PRB_BASECELL, SRSLTE_NBIOT_DEFAULT_PRB_OFFSET); + cf_t npss_signal[SRSRAN_NPSS_TOT_LEN]; + srsran_npss_generate(npss_signal); + srsran_npss_put_subframe( + &syncobj.npss, npss_signal, buffer, SRSRAN_NBIOT_DEFAULT_NUM_PRB_BASECELL, SRSRAN_NBIOT_DEFAULT_PRB_OFFSET); // Transform to OFDM symbols memset(fft_buffer, 0, sizeof(cf_t) * SFLEN * 2); - srslte_ofdm_tx_sf(&ifft); + srsran_ofdm_tx_sf(&ifft); - srslte_ofdm_tx_free(&ifft); + srsran_ofdm_tx_free(&ifft); } else { // read samples from file printf("Reading %d samples from file.\n", SFLEN); - int n = srslte_filesource_read(&fsrc, fft_buffer, SFLEN); + int n = srsran_filesource_read(&fsrc, fft_buffer, SFLEN); if (n < 0) { fprintf(stderr, "Error reading samples\n"); goto exit; @@ -159,29 +159,29 @@ int main(int argc, char** argv) } #ifdef DUMP_SIGNALS - srslte_vec_save_file( - "npss_corr_seq_time.bin", syncobj.npss.npss_signal_time, SRSLTE_NPSS_CORR_FILTER_LEN * sizeof(cf_t)); - srslte_vec_save_file("npss_sf_time.bin", fft_buffer, SFLEN * sizeof(cf_t)); + srsran_vec_save_file( + "npss_corr_seq_time.bin", syncobj.npss.npss_signal_time, SRSRAN_NPSS_CORR_FILTER_LEN * sizeof(cf_t)); + srsran_vec_save_file("npss_sf_time.bin", fft_buffer, SFLEN * sizeof(cf_t)); #endif if (cfo > 0.0) { - float delta_freq = cfo / 15000 / SRSLTE_NBIOT_FFT_SIZE; + float delta_freq = cfo / 15000 / SRSRAN_NBIOT_FFT_SIZE; printf("Adding CFO with target: %.4f\n", delta_freq); printf("WARNING: not working at the moment!\n"); - srslte_cfo_correct(&cfocorr, fft_buffer, fft_buffer, delta_freq); + srsran_cfo_correct(&cfocorr, fft_buffer, fft_buffer, delta_freq); } // add some noise to the signal if (snr != -1.0) { snr -= 10.0; printf("Adding AWGN with target SNR: %.2fdB\n", snr); - float nstd = srslte_convert_dB_to_amplitude(-snr); - srslte_ch_awgn_c(fft_buffer, fft_buffer, nstd, SFLEN); + float nstd = srsran_convert_dB_to_amplitude(-snr); + srsran_ch_awgn_c(fft_buffer, fft_buffer, nstd, SFLEN); } // look for NPSS signal - if (srslte_sync_nbiot_find(&syncobj, fft_buffer, 0, &find_idx) < 0) { - fprintf(stderr, "Error running srslte_sync_nbiot_find()\n"); + if (srsran_sync_nbiot_find(&syncobj, fft_buffer, 0, &find_idx) < 0) { + fprintf(stderr, "Error running srsran_sync_nbiot_find()\n"); exit(-1); } @@ -191,22 +191,22 @@ int main(int argc, char** argv) write_to_file(); #ifdef DUMP_SIGNALS - srslte_vec_save_file("npss_find_conv_output_abs.bin", + srsran_vec_save_file("npss_find_conv_output_abs.bin", syncobj.npss.conv_output_abs, - (SFLEN + SRSLTE_NPSS_CORR_FILTER_LEN - 1) * sizeof(float)); + (SFLEN + SRSRAN_NPSS_CORR_FILTER_LEN - 1) * sizeof(float)); #endif printf("Ok\n"); - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; // cleanup exit: if (input_file_name != NULL) { - srslte_filesource_free(&fsrc); + srsran_filesource_free(&fsrc); } - srslte_sync_nbiot_free(&syncobj); - srslte_cfo_free(&cfocorr); + srsran_sync_nbiot_free(&syncobj); + srsran_cfo_free(&cfocorr); if (fft_buffer) { free(fft_buffer); @@ -217,9 +217,9 @@ exit: void write_to_file() { - srslte_filesink_t debug_fsink; + srsran_filesink_t debug_fsink; char fname[] = OUTPUT_FILENAME; - if (srslte_filesink_init(&debug_fsink, fname, SRSLTE_TEXT)) { + if (srsran_filesink_init(&debug_fsink, fname, SRSRAN_TEXT)) { fprintf(stderr, "Error opening file %s\n", fname); exit(-1); } @@ -230,7 +230,7 @@ void write_to_file() fprintf(debug_fsink.f, "set(0,'DefaultFigureWindowStyle','docked');\n\n"); // the correlation sequence - fprintf(debug_fsink.f, "len = %u;\n", SRSLTE_NPSS_CORR_FILTER_LEN); + fprintf(debug_fsink.f, "len = %u;\n", SRSRAN_NPSS_CORR_FILTER_LEN); fprintf(debug_fsink.f, "sig1=read_complex('npss_corr_seq_time.bin', len);\n"); fprintf(debug_fsink.f, "figure;\n"); fprintf(debug_fsink.f, "t=1:len;\n"); @@ -250,7 +250,7 @@ void write_to_file() fprintf(debug_fsink.f, "\n\n"); // the correlation output - fprintf(debug_fsink.f, "num_samples = %u;\n", SRSLTE_NPSS_CORR_FILTER_LEN + SFLEN - 1); + fprintf(debug_fsink.f, "num_samples = %u;\n", SRSRAN_NPSS_CORR_FILTER_LEN + SFLEN - 1); fprintf(debug_fsink.f, "sig = read_real('npss_find_conv_output_abs.bin', num_samples);\n"); fprintf(debug_fsink.f, "t=1:num_samples;\n"); fprintf(debug_fsink.f, "\n\n"); @@ -261,6 +261,6 @@ void write_to_file() fprintf(debug_fsink.f, "ylabel('Auto-correlation magnitude');\n"); fprintf(debug_fsink.f, "\n\n"); - srslte_filesink_free(&debug_fsink); + srsran_filesink_free(&debug_fsink); printf("data written to %s\n", OUTPUT_FILENAME); } diff --git a/lib/src/phy/sync/test/sync_sl_test.c b/lib/src/phy/sync/test/sync_sl_test.c index 5cac32b6a..131b12c46 100644 --- a/lib/src/phy/sync/test/sync_sl_test.c +++ b/lib/src/phy/sync/test/sync_sl_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -20,21 +20,21 @@ #include -#include "srslte/phy/sync/psss.h" -#include "srslte/phy/sync/ssss.h" -#include "srslte/srslte.h" +#include "srsran/phy/sync/psss.h" +#include "srsran/phy/sync/ssss.h" +#include "srsran/srsran.h" char* input_file_name; int32_t N_sl_id = 168; uint32_t offset = 0; float frequency_offset = 0.0; float snr = 100.0; -srslte_cp_t cp = SRSLTE_CP_NORM; +srsran_cp_t cp = SRSRAN_CP_NORM; uint32_t nof_prb = 6; bool use_standard_lte_rates = false; -srslte_sl_tm_t tm = SRSLTE_SIDELINK_TM2; +srsran_sl_tm_t tm = SRSRAN_SIDELINK_TM2; -srslte_filesource_t fsrc; +srsran_filesource_t fsrc; void usage(char* prog) { @@ -44,7 +44,7 @@ void usage(char* prog) printf("\t-o offset [Default %d]\n", offset); printf("\t-e extended CP [Default normal]\n"); printf("\t-d use_standard_lte_rates [Default %i]\n", use_standard_lte_rates); - printf("\t-v srslte_verbose\n"); + printf("\t-v srsran_verbose\n"); printf("\nSelf-tests only:\n"); printf("\t-c N_sl_id [Default %d]\n", N_sl_id); printf("\t-t Sidelink transmission mode {1,2,3,4} [Default %d]\n", (tm + 1)); @@ -64,7 +64,7 @@ void parse_args(int argc, char** argv) use_standard_lte_rates = true; break; case 'e': - cp = SRSLTE_CP_EXT; + cp = SRSRAN_CP_EXT; break; case 'f': frequency_offset = strtof(argv[optind], NULL); @@ -84,16 +84,16 @@ void parse_args(int argc, char** argv) case 't': switch (strtol(argv[optind], NULL, 10)) { case 1: - tm = SRSLTE_SIDELINK_TM1; + tm = SRSRAN_SIDELINK_TM1; break; case 2: - tm = SRSLTE_SIDELINK_TM2; + tm = SRSRAN_SIDELINK_TM2; break; case 3: - tm = SRSLTE_SIDELINK_TM3; + tm = SRSRAN_SIDELINK_TM3; break; case 4: - tm = SRSLTE_SIDELINK_TM4; + tm = SRSRAN_SIDELINK_TM4; break; default: usage(argv[0]); @@ -101,7 +101,7 @@ void parse_args(int argc, char** argv) } break; case 'v': - srslte_verbose++; + srsran_verbose++; break; default: usage(argv[0]); @@ -113,61 +113,61 @@ void parse_args(int argc, char** argv) int main(int argc, char** argv) { parse_args(argc, argv); - srslte_use_standard_symbol_size(use_standard_lte_rates); + srsran_use_standard_symbol_size(use_standard_lte_rates); - int32_t symbol_sz = srslte_symbol_sz(nof_prb); + int32_t symbol_sz = srsran_symbol_sz(nof_prb); printf("Symbol SZ: %i\n", symbol_sz); - uint32_t sf_n_samples = srslte_symbol_sz(nof_prb) * 15; + uint32_t sf_n_samples = srsran_symbol_sz(nof_prb) * 15; printf("sf_n_samples: %i\n", sf_n_samples); - uint32_t sf_n_re = SRSLTE_CP_NSYMB(SRSLTE_CP_NORM) * SRSLTE_NRE * 2 * nof_prb; - cf_t* sf_buffer = srslte_vec_cf_malloc(sf_n_re); + uint32_t sf_n_re = SRSRAN_CP_NSYMB(SRSRAN_CP_NORM) * SRSRAN_NRE * 2 * nof_prb; + cf_t* sf_buffer = srsran_vec_cf_malloc(sf_n_re); - cf_t* input_buffer = srslte_vec_cf_malloc(sf_n_samples); - cf_t* input_buffer_temp = srslte_vec_cf_malloc(sf_n_samples); + cf_t* input_buffer = srsran_vec_cf_malloc(sf_n_samples); + cf_t* input_buffer_temp = srsran_vec_cf_malloc(sf_n_samples); uint32_t output_buffer_len = 0; - cf_t* output_buffer = srslte_vec_cf_malloc(sf_n_samples); + cf_t* output_buffer = srsran_vec_cf_malloc(sf_n_samples); - srslte_ofdm_t ifft; - if (srslte_ofdm_tx_init(&ifft, cp, sf_buffer, output_buffer, nof_prb)) { + srsran_ofdm_t ifft; + if (srsran_ofdm_tx_init(&ifft, cp, sf_buffer, output_buffer, nof_prb)) { ERROR("Error creating IFFT object"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - srslte_ofdm_set_normalize(&ifft, true); - srslte_ofdm_set_freq_shift(&ifft, 0.5); + srsran_ofdm_set_normalize(&ifft, true); + srsran_ofdm_set_freq_shift(&ifft, 0.5); - srslte_psss_t psss; - srslte_psss_init(&psss, nof_prb, cp); + srsran_psss_t psss; + srsran_psss_init(&psss, nof_prb, cp); - srslte_ssss_t ssss; - srslte_ssss_init(&ssss, nof_prb, cp, tm); + srsran_ssss_t ssss; + srsran_ssss_init(&ssss, nof_prb, cp, tm); if (input_file_name) { - if (srslte_filesource_init(&fsrc, input_file_name, SRSLTE_COMPLEX_FLOAT_BIN)) { + if (srsran_filesource_init(&fsrc, input_file_name, SRSRAN_COMPLEX_FLOAT_BIN)) { printf("Error opening file %s\n", input_file_name); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } else { // Self-test with a single subframe (but can be extended to a radio frame or a PSCCH Period) - srslte_vec_cf_zero(sf_buffer, sf_n_re); + srsran_vec_cf_zero(sf_buffer, sf_n_re); - srslte_psss_put_sf_buffer(psss.psss_signal[((N_sl_id < 168) ? 0 : 1)], sf_buffer, nof_prb, cp); - srslte_ssss_put_sf_buffer(ssss.ssss_signal[N_sl_id], sf_buffer, nof_prb, cp); + srsran_psss_put_sf_buffer(psss.psss_signal[((N_sl_id < 168) ? 0 : 1)], sf_buffer, nof_prb, cp); + srsran_ssss_put_sf_buffer(ssss.ssss_signal[N_sl_id], sf_buffer, nof_prb, cp); // TS 36.211 Section 9.3.2: The last SC-FDMA symbol in a sidelink subframe serves as a guard period and shall // not be used for sidelink transmission. - srslte_vec_cf_zero(&sf_buffer[SRSLTE_NRE * nof_prb * (SRSLTE_CP_NSYMB(cp) * 2 - 1)], SRSLTE_NRE * nof_prb); - srslte_ofdm_tx_sf(&ifft); + srsran_vec_cf_zero(&sf_buffer[SRSRAN_NRE * nof_prb * (SRSRAN_CP_NSYMB(cp) * 2 - 1)], SRSRAN_NRE * nof_prb); + srsran_ofdm_tx_sf(&ifft); output_buffer_len = sf_n_samples; // ADD CHANNEL NOISE if (snr < 50) { float std_dev = powf(10.0f, -(snr + 3.0f) / 20.0f); - srslte_ch_awgn_c(output_buffer, output_buffer, std_dev, output_buffer_len); + srsran_ch_awgn_c(output_buffer, output_buffer, std_dev, output_buffer_len); } // ADD FREQUENCY OFFSET @@ -178,7 +178,7 @@ int main(int argc, char** argv) } } - int search_window_size = sf_n_samples - (2 * (symbol_sz + SRSLTE_CP_SZ(symbol_sz, cp))); + int search_window_size = sf_n_samples - (2 * (symbol_sz + SRSRAN_CP_SZ(symbol_sz, cp))); int32_t samples_read = 0; uint32_t samples_to_read; @@ -194,14 +194,14 @@ int main(int argc, char** argv) samples_to_read = sf_n_samples - offset_pos; if (offset < samples_to_read) { - srslte_vec_cf_zero(input_buffer, offset); + srsran_vec_cf_zero(input_buffer, offset); samples_to_read = sf_n_samples - offset_pos - offset; if (input_file_name) { // Read and normalize samples from file - samples_read = srslte_filesource_read(&fsrc, &input_buffer[offset + offset_pos], samples_to_read); + samples_read = srsran_filesource_read(&fsrc, &input_buffer[offset + offset_pos], samples_to_read); // Normalization factor for third party input files - srslte_vec_sc_prod_cfc( + srsran_vec_sc_prod_cfc( &input_buffer[offset + offset_pos], sqrtf(symbol_sz), &input_buffer[offset + offset_pos], samples_read); } else { // Self-test @@ -218,7 +218,7 @@ int main(int argc, char** argv) } else { samples_read = samples_to_read; offset = offset - samples_read; - srslte_vec_cf_zero(input_buffer, samples_read); + srsran_vec_cf_zero(input_buffer, samples_read); } if (samples_read != samples_to_read) { @@ -227,7 +227,7 @@ int main(int argc, char** argv) } // Find sync signals - if (srslte_psss_find(&psss, input_buffer, nof_prb, cp) == SRSLTE_SUCCESS) { + if (srsran_psss_find(&psss, input_buffer, nof_prb, cp) == SRSRAN_SUCCESS) { printf("PSSS correlation peak pos: %d value: %f N_id_2: %d\n", psss.corr_peak_pos, psss.corr_peak_value, @@ -235,7 +235,7 @@ int main(int argc, char** argv) if (psss.corr_peak_pos - sf_n_samples == 0) { // Find SSSS - if (srslte_ssss_find(&ssss, input_buffer, nof_prb, psss.N_id_2, cp) == SRSLTE_SUCCESS) { + if (srsran_ssss_find(&ssss, input_buffer, nof_prb, psss.N_id_2, cp) == SRSRAN_SUCCESS) { printf("SSSS correlation peak pos: %d value: %f N_sl_id: %d \n", ssss.corr_peak_pos, ssss.corr_peak_value, @@ -264,18 +264,18 @@ int main(int argc, char** argv) } clean_exit: - srslte_filesource_free(&fsrc); - srslte_ofdm_tx_free(&ifft); - srslte_ssss_free(&ssss); - srslte_psss_free(&psss); + srsran_filesource_free(&fsrc); + srsran_ofdm_tx_free(&ifft); + srsran_ssss_free(&ssss); + srsran_psss_free(&psss); free(input_buffer); free(input_buffer_temp); free(sf_buffer); free(output_buffer); if (sync) { - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } - return SRSLTE_ERROR; + return SRSRAN_ERROR; } diff --git a/lib/src/phy/sync/test/sync_test.c b/lib/src/phy/sync/test/sync_test.c index 8b5ab9f3c..377d0ae12 100644 --- a/lib/src/phy/sync/test/sync_test.c +++ b/lib/src/phy/sync/test/sync_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -20,13 +20,13 @@ #include -#include "srslte/srslte.h" +#include "srsran/srsran.h" int cell_id = -1, offset = 0; -srslte_cp_t cp = SRSLTE_CP_NORM; +srsran_cp_t cp = SRSRAN_CP_NORM; uint32_t nof_prb = 6; -#define FLEN SRSLTE_SF_LEN(fft_size) +#define FLEN SRSRAN_SF_LEN(fft_size) void usage(char* prog) { @@ -35,7 +35,7 @@ void usage(char* prog) printf("\t-p nof_prb [Default %d]\n", nof_prb); printf("\t-o offset [Default %d]\n", offset); printf("\t-e extended CP [Default normal]\n"); - printf("\t-v srslte_verbose\n"); + printf("\t-v srsran_verbose\n"); } void parse_args(int argc, char** argv) @@ -53,10 +53,10 @@ void parse_args(int argc, char** argv) offset = (int)strtol(argv[optind], NULL, 10); break; case 'e': - cp = SRSLTE_CP_EXT; + cp = SRSRAN_CP_EXT; break; case 'v': - srslte_verbose++; + srsran_verbose++; break; default: usage(argv[0]); @@ -69,50 +69,50 @@ int main(int argc, char** argv) { int N_id_2, sf_idx, find_sf; cf_t * buffer, *fft_buffer; - cf_t pss_signal[SRSLTE_PSS_LEN]; - float sss_signal0[SRSLTE_SSS_LEN]; // for subframe 0 - float sss_signal5[SRSLTE_SSS_LEN]; // for subframe 5 + cf_t pss_signal[SRSRAN_PSS_LEN]; + float sss_signal0[SRSRAN_SSS_LEN]; // for subframe 0 + float sss_signal5[SRSRAN_SSS_LEN]; // for subframe 5 int cid, max_cid; uint32_t find_idx; - srslte_sync_t syncobj; - srslte_ofdm_t ifft; + srsran_sync_t syncobj; + srsran_ofdm_t ifft; int fft_size; parse_args(argc, argv); - fft_size = srslte_symbol_sz(nof_prb); + fft_size = srsran_symbol_sz(nof_prb); if (fft_size < 0) { ERROR("Invalid nof_prb=%d", nof_prb); exit(-1); } - buffer = srslte_vec_cf_malloc(FLEN); + buffer = srsran_vec_cf_malloc(FLEN); if (!buffer) { perror("malloc"); exit(-1); } - fft_buffer = srslte_vec_cf_malloc(FLEN * 2); + fft_buffer = srsran_vec_cf_malloc(FLEN * 2); if (!fft_buffer) { perror("malloc"); exit(-1); } - if (srslte_ofdm_tx_init(&ifft, cp, buffer, fft_buffer, nof_prb)) { + if (srsran_ofdm_tx_init(&ifft, cp, buffer, fft_buffer, nof_prb)) { ERROR("Error creating iFFT object"); exit(-1); } - if (srslte_sync_init(&syncobj, FLEN, FLEN, fft_size)) { + if (srsran_sync_init(&syncobj, FLEN, FLEN, fft_size)) { ERROR("Error initiating PSS/SSS"); return -1; } - srslte_sync_set_cp(&syncobj, cp); + srsran_sync_set_cp(&syncobj, cp); /* Set a very high threshold to make sure the correlation is ok */ - srslte_sync_set_threshold(&syncobj, 5.0); - srslte_sync_set_sss_algorithm(&syncobj, SSS_PARTIAL_3); + srsran_sync_set_threshold(&syncobj, 5.0); + srsran_sync_set_sss_algorithm(&syncobj, SSS_PARTIAL_3); if (cell_id == -1) { cid = 0; @@ -125,32 +125,32 @@ int main(int argc, char** argv) N_id_2 = cid % 3; /* Generate PSS/SSS signals */ - srslte_pss_generate(pss_signal, N_id_2); - srslte_sss_generate(sss_signal0, sss_signal5, cid); + srsran_pss_generate(pss_signal, N_id_2); + srsran_sss_generate(sss_signal0, sss_signal5, cid); - srslte_sync_set_N_id_2(&syncobj, N_id_2); + srsran_sync_set_N_id_2(&syncobj, N_id_2); // SF1 is SF5 for (sf_idx = 0; sf_idx < 2; sf_idx++) { memset(buffer, 0, sizeof(cf_t) * FLEN); - srslte_pss_put_slot(pss_signal, buffer, nof_prb, cp); - srslte_sss_put_slot(sf_idx ? sss_signal5 : sss_signal0, buffer, nof_prb, cp); + srsran_pss_put_slot(pss_signal, buffer, nof_prb, cp); + srsran_sss_put_slot(sf_idx ? sss_signal5 : sss_signal0, buffer, nof_prb, cp); /* Transform to OFDM symbols */ memset(fft_buffer, 0, sizeof(cf_t) * FLEN); - srslte_ofdm_tx_sf(&ifft); + srsran_ofdm_tx_sf(&ifft); /* Apply sample offset */ for (int i = 0; i < FLEN; i++) { fft_buffer[FLEN - i - 1 + offset] = fft_buffer[FLEN - i - 1]; } - srslte_vec_cf_zero(fft_buffer, offset); + srsran_vec_cf_zero(fft_buffer, offset); - if (srslte_sync_find(&syncobj, fft_buffer, 0, &find_idx) < 0) { - ERROR("Error running srslte_sync_find"); + if (srsran_sync_find(&syncobj, fft_buffer, 0, &find_idx) < 0) { + ERROR("Error running srsran_sync_find"); exit(-1); } - find_sf = srslte_sync_get_sf_idx(&syncobj); + find_sf = srsran_sync_get_sf_idx(&syncobj); printf("cell_id: %d find: %d, offset: %d, ns=%d find_ns=%d\n", cid, find_idx, offset, sf_idx, find_sf); if (find_idx != offset + FLEN / 2) { printf("offset != find_offset: %d != %d\n", find_idx, offset + FLEN / 2); @@ -160,8 +160,8 @@ int main(int argc, char** argv) printf("ns != find_ns\n"); exit(-1); } - if (srslte_sync_get_cp(&syncobj) != cp) { - printf("Detected CP should be %s\n", SRSLTE_CP_ISNORM(cp) ? "Normal" : "Extended"); + if (srsran_sync_get_cp(&syncobj) != cp) { + printf("Detected CP should be %s\n", SRSRAN_CP_ISNORM(cp) ? "Normal" : "Extended"); exit(-1); } } @@ -171,8 +171,8 @@ int main(int argc, char** argv) free(fft_buffer); free(buffer); - srslte_sync_free(&syncobj); - srslte_ofdm_tx_free(&ifft); + srsran_sync_free(&syncobj); + srsran_ofdm_tx_free(&ifft); printf("Ok\n"); exit(0); diff --git a/lib/src/phy/ue/CMakeLists.txt b/lib/src/phy/ue/CMakeLists.txt index 9832cb99f..9d0287d1e 100644 --- a/lib/src/phy/ue/CMakeLists.txt +++ b/lib/src/phy/ue/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -7,6 +7,6 @@ # file(GLOB SOURCES "*.c") -add_library(srslte_ue OBJECT ${SOURCES}) +add_library(srsran_ue OBJECT ${SOURCES}) add_subdirectory(test) \ No newline at end of file diff --git a/lib/src/phy/ue/test/CMakeLists.txt b/lib/src/phy/ue/test/CMakeLists.txt index bf423ce3f..67aa58bba 100644 --- a/lib/src/phy/ue/test/CMakeLists.txt +++ b/lib/src/phy/ue/test/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -11,23 +11,23 @@ ######################################################################## add_executable(gen_ack_test gen_ack_test.c) -target_link_libraries(gen_ack_test srslte_phy) +target_link_libraries(gen_ack_test srsran_phy) add_test(gen_ack_test gen_ack_test) add_executable(pucch_resource_test pucch_resource_test.c) -target_link_libraries(pucch_resource_test srslte_phy) +target_link_libraries(pucch_resource_test srsran_phy) add_test(pucch_resource_test pucch_resource_test) add_executable(ue_dl_nbiot_test ue_dl_nbiot_test.c) -target_link_libraries(ue_dl_nbiot_test srslte_phy pthread) +target_link_libraries(ue_dl_nbiot_test srsran_phy pthread) add_test(ue_dl_nbiot_test ue_dl_nbiot_test) if(RF_FOUND) add_executable(ue_mib_sync_test_nbiot_usrp ue_mib_sync_test_nbiot_usrp.c) - target_link_libraries(ue_mib_sync_test_nbiot_usrp srslte_phy srslte_rf pthread) + target_link_libraries(ue_mib_sync_test_nbiot_usrp srsran_phy srsran_rf pthread) add_executable(ue_sync_test_nbiot_usrp ue_sync_test_nbiot_usrp.c) - target_link_libraries(ue_sync_test_nbiot_usrp srslte_rf srslte_phy pthread) + target_link_libraries(ue_sync_test_nbiot_usrp srsran_rf srsran_phy pthread) if(SRSGUI_FOUND) include_directories(${SRSGUI_INCLUDE_DIRS}) target_link_libraries(ue_sync_test_nbiot_usrp ${SRSGUI_LIBRARIES}) diff --git a/lib/src/phy/ue/test/gen_ack_test.c b/lib/src/phy/ue/test/gen_ack_test.c index 87d0b90b4..6d8d6ec7b 100644 --- a/lib/src/phy/ue/test/gen_ack_test.c +++ b/lib/src/phy/ue/test/gen_ack_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -17,7 +17,7 @@ #include #include -#include "srslte/srslte.h" +#include "srsran/srsran.h" #define TESTASSERT(cond) \ do { \ @@ -29,24 +29,24 @@ int fdd_tests(uint32_t max_cc) { - srslte_ue_dl_t ue_dl = {}; - srslte_dl_sf_cfg_t sf_cfg_dl = {}; // This is used for TDD only + srsran_ue_dl_t ue_dl = {}; + srsran_dl_sf_cfg_t sf_cfg_dl = {}; // This is used for TDD only uint32_t test_cnt = 0; // Force FDD - ue_dl.cell.frame_type = SRSLTE_FDD; + ue_dl.cell.frame_type = SRSRAN_FDD; for (uint32_t nof_cc = 1; nof_cc <= max_cc; nof_cc++) { - for (uint32_t nof_tb = 1; nof_tb <= SRSLTE_MAX_CODEWORDS; nof_tb++) { + for (uint32_t nof_tb = 1; nof_tb <= SRSRAN_MAX_CODEWORDS; nof_tb++) { for (uint32_t nof_active_cc = 1; nof_active_cc <= nof_cc; nof_active_cc++) { for (uint32_t nof_active_tb = 1; nof_active_tb <= nof_tb; nof_active_tb++) { - srslte_pdsch_ack_t ack_info = {}; + srsran_pdsch_ack_t ack_info = {}; ack_info.nof_cc = nof_cc; - ack_info.transmission_mode = nof_tb == 1 ? SRSLTE_TM1 : SRSLTE_TM4; + ack_info.transmission_mode = nof_tb == 1 ? SRSRAN_TM1 : SRSRAN_TM4; // Check different modes? - ack_info.ack_nack_feedback_mode = SRSLTE_PUCCH_ACK_NACK_FEEDBACK_MODE_CS; + ack_info.ack_nack_feedback_mode = SRSRAN_PUCCH_ACK_NACK_FEEDBACK_MODE_CS; for (uint32_t cc_idx = 0; cc_idx < nof_cc; cc_idx++) { ack_info.cc[cc_idx].M = 1; // always 1 in FDD @@ -57,7 +57,7 @@ int fdd_tests(uint32_t max_cc) ack_info.cc[cc_idx].m[0].value[j] = j < nof_active_tb ? 1 : 2; } } else { - memset(ack_info.cc[cc_idx].m[0].value, 2, SRSLTE_MAX_CODEWORDS); + memset(ack_info.cc[cc_idx].m[0].value, 2, SRSRAN_MAX_CODEWORDS); } } @@ -65,13 +65,13 @@ int fdd_tests(uint32_t max_cc) for (uint8_t cqi_enabled = 0; cqi_enabled < 2; cqi_enabled++) { for (uint8_t simul_cqi_ack = 0; simul_cqi_ack < cqi_enabled + 1; simul_cqi_ack++) { for (uint8_t pusch_enabled = 0; pusch_enabled < 2; pusch_enabled++) { - srslte_uci_data_t uci_data = {}; + srsran_uci_data_t uci_data = {}; ack_info.is_pusch_available = (pusch_enabled > 0); ack_info.simul_cqi_ack = (simul_cqi_ack > 0); // Generate ACK/NACK bits - srslte_uci_data_reset(&uci_data); + srsran_uci_data_reset(&uci_data); uci_data.value.scheduling_request = (sr_enabled > 0); uci_data.cfg.cqi.data_enable = (cqi_enabled > 0); @@ -87,7 +87,7 @@ int fdd_tests(uint32_t max_cc) simul_cqi_ack ? "yes" : "no", pusch_enabled ? "yes" : "no"); - srslte_ue_dl_gen_ack(&ue_dl.cell, &sf_cfg_dl, &ack_info, &uci_data); + srsran_ue_dl_gen_ack(&ue_dl.cell, &sf_cfg_dl, &ack_info, &uci_data); // Check output if (nof_cc == 1) { @@ -128,7 +128,7 @@ int fdd_tests(uint32_t max_cc) TESTASSERT(uci_data.value.ack.ack_value[k++]); } } - TESTASSERT(k == srslte_uci_cfg_total_ack(&uci_data.cfg)); + TESTASSERT(k == srsran_uci_cfg_total_ack(&uci_data.cfg)); TESTASSERT(uci_data.value.ack.ack_value[k] == 2); } } diff --git a/lib/src/phy/ue/test/pucch_resource_test.c b/lib/src/phy/ue/test/pucch_resource_test.c index 82dd8433f..6af2e0f10 100644 --- a/lib/src/phy/ue/test/pucch_resource_test.c +++ b/lib/src/phy/ue/test/pucch_resource_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -17,7 +17,7 @@ #include #include -#include "srslte/srslte.h" +#include "srsran/srsran.h" #define TESTASSERT(cond) \ { \ @@ -29,15 +29,15 @@ int fdd_tests() { - srslte_cell_t cell; - srslte_pucch_cfg_t pucch_cfg; - srslte_uci_cfg_t uci_cfg; - srslte_uci_value_t uci_value; - uint8_t b[SRSLTE_UCI_MAX_ACK_BITS] = {}; + srsran_cell_t cell; + srsran_pucch_cfg_t pucch_cfg; + srsran_uci_cfg_t uci_cfg; + srsran_uci_value_t uci_value; + uint8_t b[SRSRAN_UCI_MAX_ACK_BITS] = {}; ZERO_OBJECT(cell); - cell.cp = SRSLTE_CP_NORM; - cell.frame_type = SRSLTE_FDD; + cell.cp = SRSRAN_CP_NORM; + cell.frame_type = SRSRAN_FDD; cell.nof_prb = 50; ZERO_OBJECT(pucch_cfg); @@ -53,8 +53,8 @@ int fdd_tests() // Format 1 ZERO_OBJECT(uci_cfg); uci_value.scheduling_request = true; - srslte_ue_ul_pucch_resource_selection(&cell, &pucch_cfg, &uci_cfg, &uci_value, b); - TESTASSERT(pucch_cfg.format == SRSLTE_PUCCH_FORMAT_1); + srsran_ue_ul_pucch_resource_selection(&cell, &pucch_cfg, &uci_cfg, &uci_value, b); + TESTASSERT(pucch_cfg.format == SRSRAN_PUCCH_FORMAT_1); TESTASSERT(pucch_cfg.n_pucch == pucch_cfg.n_pucch_sr); // Format 1A with and without SR @@ -63,8 +63,8 @@ int fdd_tests() ZERO_OBJECT(uci_cfg); uci_cfg.ack[0].nof_acks = 1; uci_cfg.ack[0].ncce[0] = 13; - srslte_ue_ul_pucch_resource_selection(&cell, &pucch_cfg, &uci_cfg, &uci_value, b); - TESTASSERT(pucch_cfg.format == SRSLTE_PUCCH_FORMAT_1A); + srsran_ue_ul_pucch_resource_selection(&cell, &pucch_cfg, &uci_cfg, &uci_value, b); + TESTASSERT(pucch_cfg.format == SRSRAN_PUCCH_FORMAT_1A); if (i == 0) { TESTASSERT(pucch_cfg.n_pucch == pucch_cfg.n_pucch_sr); } else { @@ -73,7 +73,7 @@ int fdd_tests() } // Format 1B with and without SR, MIMO - pucch_cfg.ack_nack_feedback_mode = SRSLTE_PUCCH_ACK_NACK_FEEDBACK_MODE_NORMAL; + pucch_cfg.ack_nack_feedback_mode = SRSRAN_PUCCH_ACK_NACK_FEEDBACK_MODE_NORMAL; for (int i = 0; i < 2; i++) { uci_value.scheduling_request = i == 0; uci_value.ack.ack_value[0] = 1; // To force a different resource than n_pucch_0 in case of CS incorrectly selected @@ -81,8 +81,8 @@ int fdd_tests() ZERO_OBJECT(uci_cfg); uci_cfg.ack[0].nof_acks = 2; uci_cfg.ack[0].ncce[0] = 13; - srslte_ue_ul_pucch_resource_selection(&cell, &pucch_cfg, &uci_cfg, &uci_value, b); - TESTASSERT(pucch_cfg.format == SRSLTE_PUCCH_FORMAT_1B); + srsran_ue_ul_pucch_resource_selection(&cell, &pucch_cfg, &uci_cfg, &uci_value, b); + TESTASSERT(pucch_cfg.format == SRSRAN_PUCCH_FORMAT_1B); if (i == 0) { TESTASSERT(pucch_cfg.n_pucch == pucch_cfg.n_pucch_sr); } else { @@ -93,7 +93,7 @@ int fdd_tests() // Format 1B-CS, no SR, 2 CA SISO uci_value.scheduling_request = 0; ZERO_OBJECT(uci_cfg); - pucch_cfg.ack_nack_feedback_mode = SRSLTE_PUCCH_ACK_NACK_FEEDBACK_MODE_CS; + pucch_cfg.ack_nack_feedback_mode = SRSRAN_PUCCH_ACK_NACK_FEEDBACK_MODE_CS; uci_cfg.ack[0].nof_acks = 1; uci_cfg.ack[1].nof_acks = 1; uci_cfg.ack[0].ncce[0] = 13; @@ -104,15 +104,15 @@ int fdd_tests() // ACK/ACK, n_pucch = n_pucch_1 uci_value.ack.ack_value[0] = 1; uci_value.ack.ack_value[1] = 1; - srslte_ue_ul_pucch_resource_selection(&cell, &pucch_cfg, &uci_cfg, &uci_value, b); - TESTASSERT(pucch_cfg.format == SRSLTE_PUCCH_FORMAT_1B); + srsran_ue_ul_pucch_resource_selection(&cell, &pucch_cfg, &uci_cfg, &uci_value, b); + TESTASSERT(pucch_cfg.format == SRSRAN_PUCCH_FORMAT_1B); TESTASSERT(pucch_cfg.n_pucch == uci_cfg.ack[1].ncce[0] + pucch_cfg.N_pucch_1); // ACK/DTX, n_pucch = n_pucch_0 uci_value.ack.ack_value[0] = 1; uci_value.ack.ack_value[1] = 2; - srslte_ue_ul_pucch_resource_selection(&cell, &pucch_cfg, &uci_cfg, &uci_value, b); - TESTASSERT(pucch_cfg.format == SRSLTE_PUCCH_FORMAT_1B); + srsran_ue_ul_pucch_resource_selection(&cell, &pucch_cfg, &uci_cfg, &uci_value, b); + TESTASSERT(pucch_cfg.format == SRSRAN_PUCCH_FORMAT_1B); TESTASSERT(pucch_cfg.n_pucch == uci_cfg.ack[0].ncce[0] + pucch_cfg.N_pucch_1); // Each on its serving cell, n_pucch_1 is explicit @@ -120,8 +120,8 @@ int fdd_tests() uci_cfg.ack[1].tpc_for_pucch = 3; uci_value.ack.ack_value[0] = 1; uci_value.ack.ack_value[1] = 1; - srslte_ue_ul_pucch_resource_selection(&cell, &pucch_cfg, &uci_cfg, &uci_value, b); - TESTASSERT(pucch_cfg.format == SRSLTE_PUCCH_FORMAT_1B); + srsran_ue_ul_pucch_resource_selection(&cell, &pucch_cfg, &uci_cfg, &uci_value, b); + TESTASSERT(pucch_cfg.format == SRSRAN_PUCCH_FORMAT_1B); TESTASSERT(pucch_cfg.n_pucch == pucch_cfg.n1_pucch_an_cs[uci_cfg.ack[1].tpc_for_pucch][0]); // PCell scheduled on Scell @@ -129,8 +129,8 @@ int fdd_tests() uci_cfg.ack[0].tpc_for_pucch = 2; uci_value.ack.ack_value[0] = 1; uci_value.ack.ack_value[1] = 2; - srslte_ue_ul_pucch_resource_selection(&cell, &pucch_cfg, &uci_cfg, &uci_value, b); - TESTASSERT(pucch_cfg.format == SRSLTE_PUCCH_FORMAT_1B); + srsran_ue_ul_pucch_resource_selection(&cell, &pucch_cfg, &uci_cfg, &uci_value, b); + TESTASSERT(pucch_cfg.format == SRSRAN_PUCCH_FORMAT_1B); TESTASSERT(pucch_cfg.n_pucch == pucch_cfg.n1_pucch_an_cs[uci_cfg.ack[0].tpc_for_pucch][0]); // MIMO has the same logic of resource selection, no need to test for now @@ -140,8 +140,8 @@ int fdd_tests() uci_value.scheduling_request = true; uci_cfg.ack[0].nof_acks = 1; uci_cfg.ack[1].nof_acks = 1; - srslte_ue_ul_pucch_resource_selection(&cell, &pucch_cfg, &uci_cfg, &uci_value, b); - TESTASSERT(pucch_cfg.format == SRSLTE_PUCCH_FORMAT_1B); + srsran_ue_ul_pucch_resource_selection(&cell, &pucch_cfg, &uci_cfg, &uci_value, b); + TESTASSERT(pucch_cfg.format == SRSRAN_PUCCH_FORMAT_1B); return 0; } diff --git a/lib/src/phy/ue/test/ue_dl_nbiot_test.c b/lib/src/phy/ue/test/ue_dl_nbiot_test.c index bafd10210..6c89eda29 100644 --- a/lib/src/phy/ue/test/ue_dl_nbiot_test.c +++ b/lib/src/phy/ue/test/ue_dl_nbiot_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -15,10 +15,10 @@ #include #include -#include "srslte/phy/ue/ue_dl_nbiot.h" +#include "srsran/phy/ue/ue_dl_nbiot.h" -srslte_nbiot_cell_t cell = { - .base = {.nof_prb = 1, .nof_ports = 1, .cp = SRSLTE_CP_NORM, .id = 0}, +srsran_nbiot_cell_t cell = { + .base = {.nof_prb = 1, .nof_ports = 1, .cp = SRSRAN_CP_NORM, .id = 0}, .nbiot_prb = 0, .nof_ports = 1, .n_id_ncell = 0, @@ -28,7 +28,7 @@ void usage(char* prog) { printf("Usage: %s [v]\n", prog); printf("\t-l n_id_ncell to sync [Default %d]\n", cell.n_id_ncell); - printf("\t-v srslte_verbose\n"); + printf("\t-v srsran_verbose\n"); } void parse_args(int argc, char** argv) @@ -40,7 +40,7 @@ void parse_args(int argc, char** argv) cell.n_id_ncell = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'v': - srslte_verbose++; + srsran_verbose++; break; default: usage(argv[0]); @@ -51,84 +51,84 @@ void parse_args(int argc, char** argv) int dl_grant_with_sib1_test() { - int ret = SRSLTE_ERROR; - cf_t rx_buff[SRSLTE_SF_LEN_PRB_NBIOT]; - cf_t* buff_ptrs[SRSLTE_MAX_PORTS] = {rx_buff, NULL, NULL, NULL}; + int ret = SRSRAN_ERROR; + cf_t rx_buff[SRSRAN_SF_LEN_PRB_NBIOT]; + cf_t* buff_ptrs[SRSRAN_MAX_PORTS] = {rx_buff, NULL, NULL, NULL}; - srslte_nbiot_ue_dl_t ue_dl; - srslte_nbiot_ue_dl_init(&ue_dl, buff_ptrs, SRSLTE_NBIOT_MAX_PRB, SRSLTE_NBIOT_NUM_RX_ANTENNAS); - if (srslte_nbiot_ue_dl_set_cell(&ue_dl, cell)) { + srsran_nbiot_ue_dl_t ue_dl; + srsran_nbiot_ue_dl_init(&ue_dl, buff_ptrs, SRSRAN_NBIOT_MAX_PRB, SRSRAN_NBIOT_NUM_RX_ANTENNAS); + if (srsran_nbiot_ue_dl_set_cell(&ue_dl, cell)) { fprintf(stderr, "Setting cell in UE DL\n"); return ret; } // pass MIB to compute SIB1 parameters - srslte_mib_nb_t mib = {}; + srsran_mib_nb_t mib = {}; mib.sched_info_sib1 = 3; - // srslte_mib_nb_printf(stdout, cell, &mib); - srslte_nbiot_ue_dl_set_mib(&ue_dl, mib); + // srsran_mib_nb_printf(stdout, cell, &mib); + srsran_nbiot_ue_dl_set_mib(&ue_dl, mib); // setup grant who's start collides with a SIB1 transmission - srslte_ra_nbiot_dl_grant_t grant; - srslte_nbiot_ue_dl_get_sib1_grant(&ue_dl, 0, &grant); + srsran_ra_nbiot_dl_grant_t grant; + srsran_nbiot_ue_dl_get_sib1_grant(&ue_dl, 0, &grant); // call helper to fix grant - srslte_nbiot_ue_dl_check_grant(&ue_dl, &grant); + srsran_nbiot_ue_dl_check_grant(&ue_dl, &grant); // grant must not start on sf_idx 4 if (grant.start_sfidx != 4) { - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } - srslte_nbiot_ue_dl_free(&ue_dl); + srsran_nbiot_ue_dl_free(&ue_dl); return ret; } int dl_grant_with_sib2_test() { - int ret = SRSLTE_ERROR; - cf_t rx_buff[SRSLTE_SF_LEN_PRB_NBIOT]; - cf_t* buff_ptrs[SRSLTE_MAX_PORTS] = {rx_buff, NULL, NULL, NULL}; + int ret = SRSRAN_ERROR; + cf_t rx_buff[SRSRAN_SF_LEN_PRB_NBIOT]; + cf_t* buff_ptrs[SRSRAN_MAX_PORTS] = {rx_buff, NULL, NULL, NULL}; - srslte_nbiot_ue_dl_t ue_dl; - srslte_nbiot_ue_dl_init(&ue_dl, buff_ptrs, SRSLTE_NBIOT_MAX_PRB, SRSLTE_NBIOT_NUM_RX_ANTENNAS); - if (srslte_nbiot_ue_dl_set_cell(&ue_dl, cell)) { + srsran_nbiot_ue_dl_t ue_dl; + srsran_nbiot_ue_dl_init(&ue_dl, buff_ptrs, SRSRAN_NBIOT_MAX_PRB, SRSRAN_NBIOT_NUM_RX_ANTENNAS); + if (srsran_nbiot_ue_dl_set_cell(&ue_dl, cell)) { fprintf(stderr, "Setting cell in UE DL\n"); return ret; } // pass MIB to compute SIB1 parameters - srslte_mib_nb_t mib = {}; + srsran_mib_nb_t mib = {}; mib.sched_info_sib1 = 3; - srslte_nbiot_ue_dl_set_mib(&ue_dl, mib); + srsran_nbiot_ue_dl_set_mib(&ue_dl, mib); // configure SIB2-NB parameters - srslte_nbiot_si_params_t sib2_params; + srsran_nbiot_si_params_t sib2_params; sib2_params.n = 1; sib2_params.si_periodicity = 128; sib2_params.si_radio_frame_offset = 0; sib2_params.si_repetition_pattern = 2; // Every 2nd radio frame sib2_params.si_tb = 208; sib2_params.si_window_length = 160; - srslte_nbiot_ue_dl_set_si_params(&ue_dl, SRSLTE_NBIOT_SI_TYPE_SIB2, sib2_params); + srsran_nbiot_ue_dl_set_si_params(&ue_dl, SRSRAN_NBIOT_SI_TYPE_SIB2, sib2_params); int dummy_tti = 0; - srslte_nbiot_ue_dl_decode_sib(&ue_dl, dummy_tti, dummy_tti, SRSLTE_NBIOT_SI_TYPE_SIB2, sib2_params); + srsran_nbiot_ue_dl_decode_sib(&ue_dl, dummy_tti, dummy_tti, SRSRAN_NBIOT_SI_TYPE_SIB2, sib2_params); // setup grant who's start collides with the above configured SI transmission - srslte_ra_nbiot_dl_grant_t grant; + srsran_ra_nbiot_dl_grant_t grant; grant.start_sfn = 898; grant.start_sfidx = 1; // UE DL object should automatically fix the grant - srslte_nbiot_ue_dl_check_grant(&ue_dl, &grant); + srsran_nbiot_ue_dl_check_grant(&ue_dl, &grant); if (grant.start_sfn == 899 && grant.start_sfidx == 3) { - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } - srslte_nbiot_ue_dl_free(&ue_dl); + srsran_nbiot_ue_dl_free(&ue_dl); return ret; } @@ -139,13 +139,13 @@ int main(int argc, char** argv) if (dl_grant_with_sib1_test()) { printf("DL grant with SIB1 test failed\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (dl_grant_with_sib2_test()) { printf("DL grant with SIB2 test failed\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } diff --git a/lib/src/phy/ue/test/ue_mib_sync_test_nbiot_usrp.c b/lib/src/phy/ue/test/ue_mib_sync_test_nbiot_usrp.c index 4e95d4038..cc58ccfd1 100644 --- a/lib/src/phy/ue/test/ue_mib_sync_test_nbiot_usrp.c +++ b/lib/src/phy/ue/test/ue_mib_sync_test_nbiot_usrp.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -20,19 +20,19 @@ #include #include -#include "srslte/phy/phch/npbch.h" -#include "srslte/phy/rf/rf.h" -#include "srslte/phy/sync/sync_nbiot.h" -#include "srslte/phy/ue/ue_mib_nbiot.h" -#include "srslte/phy/utils/debug.h" +#include "srsran/phy/phch/npbch.h" +#include "srsran/phy/rf/rf.h" +#include "srsran/phy/sync/sync_nbiot.h" +#include "srsran/phy/ue/ue_mib_nbiot.h" +#include "srsran/phy/utils/debug.h" char* rf_args = ""; float rf_gain = 70.0, rf_freq = -1.0; int nof_frames = -1; uint32_t fft_size = 128; float threshold = 20.0; -srslte_cp_t cp = SRSLTE_CP_NORM; -srslte_nbiot_cell_t cell = {}; +srsran_cp_t cp = SRSRAN_CP_NORM; +srsran_nbiot_cell_t cell = {}; void usage(char* prog) { @@ -44,7 +44,7 @@ void usage(char* prog) printf("\t-R Is R14 cell [Default %s]\n", cell.is_r14 ? "Yes" : "No"); printf("\t-s symbol_sz [Default %d]\n", fft_size); printf("\t-t threshold [Default %.2f]\n", threshold); - printf("\t-v srslte_verbose\n"); + printf("\t-v srsran_verbose\n"); } void parse_args(int argc, char** argv) @@ -77,7 +77,7 @@ void parse_args(int argc, char** argv) nof_frames = (int)strtol(argv[optind], NULL, 10); break; case 'v': - srslte_verbose++; + srsran_verbose++; break; default: usage(argv[0]); @@ -99,14 +99,14 @@ void sig_int_handler(int signo) } } -int srslte_rf_recv_wrapper(void* h, cf_t* data[SRSLTE_MAX_PORTS], uint32_t nsamples, srslte_timestamp_t* t) +int srsran_rf_recv_wrapper(void* h, cf_t* data[SRSRAN_MAX_PORTS], uint32_t nsamples, srsran_timestamp_t* t) { DEBUG(" ---- Receive %d samples ---- ", nsamples); - void* ptr[SRSLTE_MAX_PORTS]; - for (int i = 0; i < SRSLTE_MAX_PORTS; i++) { + void* ptr[SRSRAN_MAX_PORTS]; + for (int i = 0; i < SRSRAN_MAX_PORTS; i++) { ptr[i] = data[i]; } - return srslte_rf_recv_with_time_multi(h, ptr, nsamples, true, NULL, NULL); + return srsran_rf_recv_with_time_multi(h, ptr, nsamples, true, NULL, NULL); } int main(int argc, char** argv) @@ -124,48 +124,48 @@ int main(int argc, char** argv) printf("Frame length %d samples\n", flen); printf("Opening RF device...\n"); - srslte_rf_t rf_device; - if (srslte_rf_open(&rf_device, rf_args)) { + srsran_rf_t rf_device; + if (srsran_rf_open(&rf_device, rf_args)) { fprintf(stderr, "Error opening rf\n"); exit(-1); } - srslte_rf_set_rx_gain(&rf_device, rf_gain); - printf("Set RX rate: %.2f MHz\n", srslte_rf_set_rx_srate(&rf_device, srate) / 1000000); - printf("Set RX gain: %.1f dB\n", srslte_rf_get_rx_gain(&rf_device)); - printf("Set RX freq: %.2f MHz\n", srslte_rf_set_rx_freq(&rf_device, 0, rf_freq) / 1000000); + srsran_rf_set_rx_gain(&rf_device, rf_gain); + printf("Set RX rate: %.2f MHz\n", srsran_rf_set_rx_srate(&rf_device, srate) / 1000000); + printf("Set RX gain: %.1f dB\n", srsran_rf_get_rx_gain(&rf_device)); + printf("Set RX freq: %.2f MHz\n", srsran_rf_set_rx_freq(&rf_device, 0, rf_freq) / 1000000); - srslte_ue_mib_sync_nbiot_t mib_sync; - if (srslte_ue_mib_sync_nbiot_init_multi( - &mib_sync, srslte_rf_recv_wrapper, SRSLTE_NBIOT_NUM_RX_ANTENNAS, (void*)&rf_device)) { + srsran_ue_mib_sync_nbiot_t mib_sync; + if (srsran_ue_mib_sync_nbiot_init_multi( + &mib_sync, srsran_rf_recv_wrapper, SRSRAN_NBIOT_NUM_RX_ANTENNAS, (void*)&rf_device)) { fprintf(stderr, "Error initializing MIB sync object\n"); exit(-1); } - if (srslte_ue_mib_sync_nbiot_set_cell(&mib_sync, cell) != SRSLTE_SUCCESS) { + if (srsran_ue_mib_sync_nbiot_set_cell(&mib_sync, cell) != SRSRAN_SUCCESS) { fprintf(stderr, "Error setting cell for MIB sync object\n"); exit(-1); } - srslte_rf_start_rx_stream(&rf_device, false); + srsran_rf_start_rx_stream(&rf_device, false); - int max_frames = 2 * SRSLTE_NPBCH_NUM_FRAMES; + int max_frames = 2 * SRSRAN_NPBCH_NUM_FRAMES; printf("Trying to receive MIB-NB for n_id_ncell=%d for at most %d frames\n", cell.n_id_ncell, nof_frames); int sfn_offset = 0; - uint8_t bch_payload_rx[SRSLTE_MIB_NB_LEN] = {}; - int ret = srslte_ue_mib_sync_nbiot_decode(&mib_sync, max_frames, bch_payload_rx, &cell.nof_ports, &sfn_offset); - if (ret == SRSLTE_UE_MIB_NBIOT_FOUND) { - srslte_mib_nb_t mib_nb; - srslte_npbch_mib_unpack(bch_payload_rx, &mib_nb); - srslte_mib_nb_printf(stdout, cell, &mib_nb); - printf("CFO: %+6.2f kHz\n", srslte_ue_sync_nbiot_get_cfo(&mib_sync.ue_sync) / 1000); + uint8_t bch_payload_rx[SRSRAN_MIB_NB_LEN] = {}; + int ret = srsran_ue_mib_sync_nbiot_decode(&mib_sync, max_frames, bch_payload_rx, &cell.nof_ports, &sfn_offset); + if (ret == SRSRAN_UE_MIB_NBIOT_FOUND) { + srsran_mib_nb_t mib_nb; + srsran_npbch_mib_unpack(bch_payload_rx, &mib_nb); + srsran_mib_nb_printf(stdout, cell, &mib_nb); + printf("CFO: %+6.2f kHz\n", srsran_ue_sync_nbiot_get_cfo(&mib_sync.ue_sync) / 1000); } else { printf("Failed!\n"); } - srslte_ue_mib_sync_nbiot_free(&mib_sync); - srslte_rf_close(&rf_device); + srsran_ue_mib_sync_nbiot_free(&mib_sync); + srsran_rf_close(&rf_device); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } diff --git a/lib/src/phy/ue/test/ue_sync_test_nbiot_usrp.c b/lib/src/phy/ue/test/ue_sync_test_nbiot_usrp.c index 9556bc587..8c721b3e7 100644 --- a/lib/src/phy/ue/test/ue_sync_test_nbiot_usrp.c +++ b/lib/src/phy/ue/test/ue_sync_test_nbiot_usrp.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,10 +10,10 @@ * */ -#include "srslte/phy/rf/rf.h" -#include "srslte/phy/sync/sync_nbiot.h" -#include "srslte/phy/ue/ue_sync_nbiot.h" -#include "srslte/srslte.h" +#include "srsran/phy/rf/rf.h" +#include "srsran/phy/sync/sync_nbiot.h" +#include "srsran/phy/ue/ue_sync_nbiot.h" +#include "srsran/srsran.h" #include #include #include @@ -38,10 +38,10 @@ float threshold = 20.0; int N_id_2_sync = -1; float cfo_ema = 0.2; float do_cfo_corr = true; -srslte_cp_t cp = SRSLTE_CP_NORM; +srsran_cp_t cp = SRSRAN_CP_NORM; -srslte_nbiot_cell_t cell = { - .base = {.nof_prb = 1, .nof_ports = 1, .cp = SRSLTE_CP_NORM, .id = 0}, +srsran_nbiot_cell_t cell = { + .base = {.nof_prb = 1, .nof_ports = 1, .cp = SRSRAN_CP_NORM, .id = 0}, .nbiot_prb = 0, }; @@ -60,7 +60,7 @@ void usage(char* prog) #else printf("\t plots are disabled. Graphics library not available\n"); #endif - printf("\t-v srslte_verbose\n"); + printf("\t-v srsran_verbose\n"); } void parse_args(int argc, char** argv) @@ -96,7 +96,7 @@ void parse_args(int argc, char** argv) disable_plots = true; break; case 'v': - srslte_verbose++; + srsran_verbose++; break; default: usage(argv[0]); @@ -118,10 +118,10 @@ void sig_int_handler(int signo) } } -int srslte_rf_recv_wrapper_cs(void* h, void* data, uint32_t nsamples, srslte_timestamp_t* t) +int srsran_rf_recv_wrapper_cs(void* h, void* data, uint32_t nsamples, srsran_timestamp_t* t) { DEBUG(" ---- Receive %d samples ---- ", nsamples); - return srslte_rf_recv(h, data, nsamples, 1); + return srsran_rf_recv(h, data, nsamples, 1); } int main(int argc, char** argv) @@ -146,56 +146,56 @@ int main(int argc, char** argv) printf("Frame length %d samples\n", flen); printf("Opening RF device...\n"); - srslte_rf_t rf; - if (srslte_rf_open(&rf, rf_args)) { + srsran_rf_t rf; + if (srsran_rf_open(&rf, rf_args)) { fprintf(stderr, "Error opening rf\n"); exit(-1); } - srslte_rf_set_rx_gain(&rf, rf_gain); - printf("Set RX rate: %.2f MHz\n", srslte_rf_set_rx_srate(&rf, srate) / 1000000); - printf("Set RX gain: %.1f dB\n", srslte_rf_get_rx_gain(&rf)); - printf("Set RX freq: %.2f MHz\n", srslte_rf_set_rx_freq(&rf, 0, rf_freq) / 1000000); + srsran_rf_set_rx_gain(&rf, rf_gain); + printf("Set RX rate: %.2f MHz\n", srsran_rf_set_rx_srate(&rf, srate) / 1000000); + printf("Set RX gain: %.1f dB\n", srsran_rf_get_rx_gain(&rf)); + printf("Set RX freq: %.2f MHz\n", srsran_rf_set_rx_freq(&rf, 0, rf_freq) / 1000000); // Allocate memory for rx'ing samples (1 full frame) - cf_t* rx_buffer[SRSLTE_MAX_PORTS] = {NULL, NULL, NULL, NULL}; - for (uint32_t i = 0; i < SRSLTE_NBIOT_NUM_RX_ANTENNAS; i++) { - rx_buffer[i] = srslte_vec_cf_malloc(SRSLTE_NOF_SF_X_FRAME * SRSLTE_SF_LEN_PRB_NBIOT); + cf_t* rx_buffer[SRSRAN_MAX_PORTS] = {NULL, NULL, NULL, NULL}; + for (uint32_t i = 0; i < SRSRAN_NBIOT_NUM_RX_ANTENNAS; i++) { + rx_buffer[i] = srsran_vec_cf_malloc(SRSRAN_NOF_SF_X_FRAME * SRSRAN_SF_LEN_PRB_NBIOT); if (!rx_buffer[i]) { perror("malloc"); goto clean_exit; } } - srslte_nbiot_ue_sync_t ue_sync = {}; - if (srslte_ue_sync_nbiot_init(&ue_sync, cell, srslte_rf_recv_wrapper_cs, (void*)&rf)) { + srsran_nbiot_ue_sync_t ue_sync = {}; + if (srsran_ue_sync_nbiot_init(&ue_sync, cell, srsran_rf_recv_wrapper_cs, (void*)&rf)) { fprintf(stderr, "Error initiating ue_sync\n"); exit(-1); } - srslte_ue_sync_nbiot_set_cfo_enable(&ue_sync, do_cfo_corr); - srslte_ue_sync_nbiot_set_cfo_ema(&ue_sync, cfo_ema); + srsran_ue_sync_nbiot_set_cfo_enable(&ue_sync, do_cfo_corr); + srsran_ue_sync_nbiot_set_cfo_ema(&ue_sync, cfo_ema); - srslte_rf_start_rx_stream(&rf, false); + srsran_rf_start_rx_stream(&rf, false); int frame_cnt = 0; printf("Trying to keep syncronized to cell for %d frames\n", nof_frames); while ((frame_cnt < nof_frames || nof_frames == -1) && !go_exit) { - if (srslte_ue_sync_nbiot_zerocopy_multi(&ue_sync, rx_buffer) < 0) { - fprintf(stderr, "Error calling srslte_nbiot_ue_sync_work()\n"); + if (srsran_ue_sync_nbiot_zerocopy_multi(&ue_sync, rx_buffer) < 0) { + fprintf(stderr, "Error calling srsran_nbiot_ue_sync_work()\n"); break; } - if (srslte_ue_sync_nbiot_get_sfidx(&ue_sync) == 0) { - printf("CFO: %+6.2f kHz\r", srslte_ue_sync_nbiot_get_cfo(&ue_sync) / 1000); + if (srsran_ue_sync_nbiot_get_sfidx(&ue_sync) == 0) { + printf("CFO: %+6.2f kHz\r", srsran_ue_sync_nbiot_get_cfo(&ue_sync) / 1000); frame_cnt++; } #ifndef DISABLE_GRAPHICS if (!disable_plots) { // get current CFO estimate - cfo_table[cfo_table_index++] = srslte_ue_sync_nbiot_get_cfo(&ue_sync) / 1000; + cfo_table[cfo_table_index++] = srsran_ue_sync_nbiot_get_cfo(&ue_sync) / 1000; if (cfo_table_index == cfo_num_plot) { do_plots_cfo(cfo_table, cfo_num_plot); cfo_table_index = 0; @@ -203,19 +203,19 @@ int main(int argc, char** argv) } if (!disable_plots) { - srslte_npss_synch_t* pss_obj = ue_sync.state == SF_FIND ? &ue_sync.sfind.npss : &ue_sync.strack.npss; - int len = SRSLTE_NPSS_CORR_FILTER_LEN + pss_obj->frame_size - 1; - int max = srslte_vec_max_fi(pss_obj->conv_output_avg, pss_obj->frame_size + pss_obj->fft_size - 1); + srsran_npss_synch_t* pss_obj = ue_sync.state == SF_FIND ? &ue_sync.sfind.npss : &ue_sync.strack.npss; + int len = SRSRAN_NPSS_CORR_FILTER_LEN + pss_obj->frame_size - 1; + int max = srsran_vec_max_fi(pss_obj->conv_output_avg, pss_obj->frame_size + pss_obj->fft_size - 1); do_plots_npss(pss_obj->conv_output_avg, pss_obj->conv_output_avg[max], len); } #endif } clean_exit: - srslte_ue_sync_nbiot_free(&ue_sync); - srslte_rf_close(&rf); + srsran_ue_sync_nbiot_free(&ue_sync); + srsran_rf_close(&rf); - for (uint32_t i = 0; i < SRSLTE_MAX_PORTS; i++) { + for (uint32_t i = 0; i < SRSRAN_MAX_PORTS; i++) { if (rx_buffer[i] != NULL) { free(rx_buffer[i]); } @@ -255,7 +255,7 @@ void init_plots() void do_plots_npss(float* corr, float peak, uint32_t size) { - srslte_vec_sc_prod_fff(corr, 1. / peak, tmp, size); + srsran_vec_sc_prod_fff(corr, 1. / peak, tmp, size); plot_real_setNewData(&npss_plot, tmp, size); } diff --git a/lib/src/phy/ue/ue_cell_search.c b/lib/src/phy/ue/ue_cell_search.c index 35f25fbb6..13ee51cf7 100644 --- a/lib/src/phy/ue/ue_cell_search.c +++ b/lib/src/phy/ue/ue_cell_search.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,54 +10,54 @@ * */ -#include "srslte/srslte.h" +#include "srsran/srsran.h" #include #include #include #include #include -#include "srslte/phy/ue/ue_cell_search.h" +#include "srsran/phy/ue/ue_cell_search.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" -#define CELL_SEARCH_BUFFER_MAX_SAMPLES (3 * SRSLTE_SF_LEN_MAX) +#define CELL_SEARCH_BUFFER_MAX_SAMPLES (3 * SRSRAN_SF_LEN_MAX) -int srslte_ue_cellsearch_init(srslte_ue_cellsearch_t* q, +int srsran_ue_cellsearch_init(srsran_ue_cellsearch_t* q, uint32_t max_frames, - int(recv_callback)(void*, void*, uint32_t, srslte_timestamp_t*), + int(recv_callback)(void*, void*, uint32_t, srsran_timestamp_t*), void* stream_handler) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL) { - ret = SRSLTE_ERROR; - srslte_cell_t cell; + ret = SRSRAN_ERROR; + srsran_cell_t cell; - bzero(q, sizeof(srslte_ue_cellsearch_t)); + bzero(q, sizeof(srsran_ue_cellsearch_t)); - bzero(&cell, sizeof(srslte_cell_t)); - cell.id = SRSLTE_CELL_ID_UNKNOWN; - cell.nof_prb = SRSLTE_CS_NOF_PRB; + bzero(&cell, sizeof(srsran_cell_t)); + cell.id = SRSRAN_CELL_ID_UNKNOWN; + cell.nof_prb = SRSRAN_CS_NOF_PRB; - if (srslte_ue_sync_init(&q->ue_sync, cell.nof_prb, true, recv_callback, stream_handler)) { + if (srsran_ue_sync_init(&q->ue_sync, cell.nof_prb, true, recv_callback, stream_handler)) { ERROR("Error initiating ue_sync"); goto clean_exit; } - if (srslte_ue_sync_set_cell(&q->ue_sync, cell)) { + if (srsran_ue_sync_set_cell(&q->ue_sync, cell)) { ERROR("Error initiating ue_sync"); goto clean_exit; } - for (int p = 0; p < SRSLTE_MAX_CHANNELS; p++) { + for (int p = 0; p < SRSRAN_MAX_CHANNELS; p++) { q->sf_buffer[p] = NULL; } - q->sf_buffer[0] = srslte_vec_cf_malloc(CELL_SEARCH_BUFFER_MAX_SAMPLES); + q->sf_buffer[0] = srsran_vec_cf_malloc(CELL_SEARCH_BUFFER_MAX_SAMPLES); q->nof_rx_antennas = 1; - q->candidates = calloc(sizeof(srslte_ue_cellsearch_result_t), max_frames); + q->candidates = calloc(sizeof(srsran_ue_cellsearch_result_t), max_frames); if (!q->candidates) { perror("malloc"); goto clean_exit; @@ -76,50 +76,50 @@ int srslte_ue_cellsearch_init(srslte_ue_cellsearch_t* q, q->max_frames = max_frames; q->nof_valid_frames = max_frames; - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } clean_exit: - if (ret == SRSLTE_ERROR) { - srslte_ue_cellsearch_free(q); + if (ret == SRSRAN_ERROR) { + srsran_ue_cellsearch_free(q); } return ret; } -int srslte_ue_cellsearch_init_multi( - srslte_ue_cellsearch_t* q, +int srsran_ue_cellsearch_init_multi( + srsran_ue_cellsearch_t* q, uint32_t max_frames, - int(recv_callback)(void*, cf_t* [SRSLTE_MAX_CHANNELS], uint32_t, srslte_timestamp_t*), + int(recv_callback)(void*, cf_t* [SRSRAN_MAX_CHANNELS], uint32_t, srsran_timestamp_t*), uint32_t nof_rx_antennas, void* stream_handler) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; - if (q != NULL && nof_rx_antennas < SRSLTE_MAX_CHANNELS) { - ret = SRSLTE_ERROR; - srslte_cell_t cell; + if (q != NULL && nof_rx_antennas < SRSRAN_MAX_CHANNELS) { + ret = SRSRAN_ERROR; + srsran_cell_t cell; - bzero(q, sizeof(srslte_ue_cellsearch_t)); + bzero(q, sizeof(srsran_ue_cellsearch_t)); - bzero(&cell, sizeof(srslte_cell_t)); - cell.id = SRSLTE_CELL_ID_UNKNOWN; - cell.nof_prb = SRSLTE_CS_NOF_PRB; + bzero(&cell, sizeof(srsran_cell_t)); + cell.id = SRSRAN_CELL_ID_UNKNOWN; + cell.nof_prb = SRSRAN_CS_NOF_PRB; - if (srslte_ue_sync_init_multi(&q->ue_sync, cell.nof_prb, true, recv_callback, nof_rx_antennas, stream_handler)) { + if (srsran_ue_sync_init_multi(&q->ue_sync, cell.nof_prb, true, recv_callback, nof_rx_antennas, stream_handler)) { fprintf(stderr, "Error initiating ue_sync\n"); goto clean_exit; } - if (srslte_ue_sync_set_cell(&q->ue_sync, cell)) { + if (srsran_ue_sync_set_cell(&q->ue_sync, cell)) { ERROR("Error setting cell in ue_sync"); goto clean_exit; } for (int i = 0; i < nof_rx_antennas; i++) { - q->sf_buffer[i] = srslte_vec_cf_malloc(CELL_SEARCH_BUFFER_MAX_SAMPLES); + q->sf_buffer[i] = srsran_vec_cf_malloc(CELL_SEARCH_BUFFER_MAX_SAMPLES); } q->nof_rx_antennas = nof_rx_antennas; - q->candidates = calloc(sizeof(srslte_ue_cellsearch_result_t), max_frames); + q->candidates = calloc(sizeof(srsran_ue_cellsearch_result_t), max_frames); if (!q->candidates) { perror("malloc"); goto clean_exit; @@ -138,17 +138,17 @@ int srslte_ue_cellsearch_init_multi( q->max_frames = max_frames; q->nof_valid_frames = max_frames; - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } clean_exit: - if (ret == SRSLTE_ERROR) { - srslte_ue_cellsearch_free(q); + if (ret == SRSRAN_ERROR) { + srsran_ue_cellsearch_free(q); } return ret; } -void srslte_ue_cellsearch_free(srslte_ue_cellsearch_t* q) +void srsran_ue_cellsearch_free(srsran_ue_cellsearch_t* q) { for (int i = 0; i < q->nof_rx_antennas; i++) { if (q->sf_buffer[i]) { @@ -164,23 +164,23 @@ void srslte_ue_cellsearch_free(srslte_ue_cellsearch_t* q) if (q->mode_ntimes) { free(q->mode_ntimes); } - srslte_ue_sync_free(&q->ue_sync); + srsran_ue_sync_free(&q->ue_sync); - bzero(q, sizeof(srslte_ue_cellsearch_t)); + bzero(q, sizeof(srsran_ue_cellsearch_t)); } -int srslte_ue_cellsearch_set_nof_valid_frames(srslte_ue_cellsearch_t* q, uint32_t nof_frames) +int srsran_ue_cellsearch_set_nof_valid_frames(srsran_ue_cellsearch_t* q, uint32_t nof_frames) { if (nof_frames <= q->max_frames) { q->nof_valid_frames = nof_frames; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } else { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } /* Decide the most likely cell based on the mode */ -static void get_cell(srslte_ue_cellsearch_t* q, uint32_t nof_detected_frames, srslte_ue_cellsearch_result_t* found_cell) +static void get_cell(srsran_ue_cellsearch_t* q, uint32_t nof_detected_frames, srsran_ue_cellsearch_result_t* found_cell) { uint32_t i, j; @@ -212,10 +212,10 @@ static void get_cell(srslte_ue_cellsearch_t* q, uint32_t nof_detected_frames, sr found_cell->peak = 0; for (i = 0; i < nof_detected_frames; i++) { if (q->candidates[i].cell_id == found_cell->cell_id) { - if (SRSLTE_CP_ISNORM(q->candidates[i].cp)) { + if (SRSRAN_CP_ISNORM(q->candidates[i].cp)) { nof_normal++; } - if (q->candidates[i].frame_type == SRSLTE_FDD) { + if (q->candidates[i].frame_type == SRSRAN_FDD) { nof_fdd++; } } @@ -225,14 +225,14 @@ static void get_cell(srslte_ue_cellsearch_t* q, uint32_t nof_detected_frames, sr found_cell->peak /= nof_detected_frames; if (nof_normal > q->mode_ntimes[mode_pos] / 2) { - found_cell->cp = SRSLTE_CP_NORM; + found_cell->cp = SRSRAN_CP_NORM; } else { - found_cell->cp = SRSLTE_CP_EXT; + found_cell->cp = SRSRAN_CP_EXT; } if (nof_fdd > q->mode_ntimes[mode_pos] / 2) { - found_cell->frame_type = SRSLTE_FDD; + found_cell->frame_type = SRSRAN_FDD; } else { - found_cell->frame_type = SRSLTE_TDD; + found_cell->frame_type = SRSRAN_TDD; } found_cell->mode = (float)q->mode_ntimes[mode_pos] / nof_detected_frames; @@ -248,8 +248,8 @@ static void get_cell(srslte_ue_cellsearch_t* q, uint32_t nof_detected_frames, sr * Saves in the pointer max_N_id_2 the N_id_2 index of the cell with the highest PSR * Returns the number of found cells or a negative number if error */ -int srslte_ue_cellsearch_scan(srslte_ue_cellsearch_t* q, - srslte_ue_cellsearch_result_t found_cells[3], +int srsran_ue_cellsearch_scan(srsran_ue_cellsearch_t* q, + srsran_ue_cellsearch_result_t found_cells[3], uint32_t* max_N_id_2) { int ret = 0; @@ -258,7 +258,7 @@ int srslte_ue_cellsearch_scan(srslte_ue_cellsearch_t* q, for (uint32_t N_id_2 = 0; N_id_2 < 3; N_id_2++) { INFO("CELL SEARCH: Starting scan for N_id_2=%d", N_id_2); - ret = srslte_ue_cellsearch_scan_N_id_2(q, N_id_2, &found_cells[N_id_2]); + ret = srsran_ue_cellsearch_scan_N_id_2(q, N_id_2, &found_cells[N_id_2]); if (ret < 0) { ERROR("Error searching cell"); return ret; @@ -277,49 +277,49 @@ int srslte_ue_cellsearch_scan(srslte_ue_cellsearch_t* q, /** Finds a cell for a given N_id_2 and stores ID and CP in the structure pointed by found_cell. * Returns 1 if the cell is found, 0 if not or -1 on error */ -int srslte_ue_cellsearch_scan_N_id_2(srslte_ue_cellsearch_t* q, +int srsran_ue_cellsearch_scan_N_id_2(srsran_ue_cellsearch_t* q, uint32_t N_id_2, - srslte_ue_cellsearch_result_t* found_cell) + srsran_ue_cellsearch_result_t* found_cell) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; uint32_t nof_detected_frames = 0; uint32_t nof_scanned_frames = 0; if (q != NULL) { - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; - bzero(q->candidates, sizeof(srslte_ue_cellsearch_result_t) * q->max_frames); + bzero(q->candidates, sizeof(srsran_ue_cellsearch_result_t) * q->max_frames); bzero(q->mode_ntimes, sizeof(uint32_t) * q->max_frames); bzero(q->mode_counted, sizeof(uint8_t) * q->max_frames); - srslte_ue_sync_set_N_id_2(&q->ue_sync, N_id_2); - srslte_ue_sync_reset(&q->ue_sync); - srslte_ue_sync_cfo_reset(&q->ue_sync, 0.0f); - srslte_ue_sync_set_nof_find_frames(&q->ue_sync, q->max_frames); + srsran_ue_sync_set_N_id_2(&q->ue_sync, N_id_2); + srsran_ue_sync_reset(&q->ue_sync); + srsran_ue_sync_cfo_reset(&q->ue_sync, 0.0f); + srsran_ue_sync_set_nof_find_frames(&q->ue_sync, q->max_frames); do { - ret = srslte_ue_sync_zerocopy(&q->ue_sync, q->sf_buffer, CELL_SEARCH_BUFFER_MAX_SAMPLES); + ret = srsran_ue_sync_zerocopy(&q->ue_sync, q->sf_buffer, CELL_SEARCH_BUFFER_MAX_SAMPLES); if (ret < 0) { - ERROR("Error calling srslte_ue_sync_work()"); + ERROR("Error calling srsran_ue_sync_work()"); return -1; } else if (ret == 1) { /* This means a peak was found in find state */ - ret = srslte_sync_get_cell_id(&q->ue_sync.sfind); + ret = srsran_sync_get_cell_id(&q->ue_sync.sfind); if (ret >= 0) { /* Save cell id, cp and peak */ q->candidates[nof_detected_frames].cell_id = (uint32_t)ret; - q->candidates[nof_detected_frames].cp = srslte_sync_get_cp(&q->ue_sync.sfind); + q->candidates[nof_detected_frames].cp = srsran_sync_get_cp(&q->ue_sync.sfind); q->candidates[nof_detected_frames].peak = q->ue_sync.sfind.pss.peak_value; - q->candidates[nof_detected_frames].psr = srslte_sync_get_peak_value(&q->ue_sync.sfind); - q->candidates[nof_detected_frames].cfo = 15000 * srslte_sync_get_cfo(&q->ue_sync.sfind); - q->candidates[nof_detected_frames].frame_type = srslte_ue_sync_get_frame_type(&q->ue_sync); + q->candidates[nof_detected_frames].psr = srsran_sync_get_peak_value(&q->ue_sync.sfind); + q->candidates[nof_detected_frames].cfo = 15000 * srsran_sync_get_cfo(&q->ue_sync.sfind); + q->candidates[nof_detected_frames].frame_type = srsran_ue_sync_get_frame_type(&q->ue_sync); INFO("CELL SEARCH: [%d/%d/%d]: Found peak PSR=%.3f, Cell_id: %d CP: %s, CFO=%.1f KHz", nof_detected_frames, nof_scanned_frames, q->nof_valid_frames, q->candidates[nof_detected_frames].psr, q->candidates[nof_detected_frames].cell_id, - srslte_cp_string(q->candidates[nof_detected_frames].cp), + srsran_cp_string(q->candidates[nof_detected_frames].cp), q->candidates[nof_detected_frames].cfo / 1000); nof_detected_frames++; diff --git a/lib/src/phy/ue/ue_cell_search_nbiot.c b/lib/src/phy/ue/ue_cell_search_nbiot.c index 832e897eb..71f176c62 100644 --- a/lib/src/phy/ue/ue_cell_search_nbiot.c +++ b/lib/src/phy/ue/ue_cell_search_nbiot.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -16,35 +16,35 @@ #include #include -#include "srslte/phy/ue/ue_cell_search_nbiot.h" +#include "srsran/phy/ue/ue_cell_search_nbiot.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" -int srslte_ue_cellsearch_nbiot_init(srslte_ue_cellsearch_nbiot_t* q, +int srsran_ue_cellsearch_nbiot_init(srsran_ue_cellsearch_nbiot_t* q, uint32_t max_frames_total, - int(recv_callback)(void*, cf_t* [SRSLTE_MAX_PORTS], uint32_t, srslte_timestamp_t*), + int(recv_callback)(void*, cf_t* [SRSRAN_MAX_PORTS], uint32_t, srsran_timestamp_t*), void* stream_handler) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL) { - ret = SRSLTE_ERROR; - bzero(q, sizeof(srslte_ue_cellsearch_nbiot_t)); + ret = SRSRAN_ERROR; + bzero(q, sizeof(srsran_ue_cellsearch_nbiot_t)); - q->sf_len = SRSLTE_SF_LEN_PRB_NBIOT; + q->sf_len = SRSRAN_SF_LEN_PRB_NBIOT; if (q->sf_len < 0) { return ret; } - if (srslte_ue_sync_nbiot_init_multi( - &q->ue_sync, SRSLTE_NBIOT_MAX_PRB, recv_callback, SRSLTE_NBIOT_NUM_RX_ANTENNAS, stream_handler)) { + if (srsran_ue_sync_nbiot_init_multi( + &q->ue_sync, SRSRAN_NBIOT_MAX_PRB, recv_callback, SRSRAN_NBIOT_NUM_RX_ANTENNAS, stream_handler)) { fprintf(stderr, "Error initiating ue_sync\n"); goto clean_exit; } - for (uint32_t i = 0; i < SRSLTE_NBIOT_NUM_RX_ANTENNAS; i++) { - q->rx_buffer[i] = srslte_vec_cf_malloc(SRSLTE_NOF_SF_X_FRAME * q->sf_len); + for (uint32_t i = 0; i < SRSRAN_NBIOT_NUM_RX_ANTENNAS; i++) { + q->rx_buffer[i] = srsran_vec_cf_malloc(SRSRAN_NOF_SF_X_FRAME * q->sf_len); if (!q->rx_buffer[i]) { perror("malloc"); goto clean_exit; @@ -52,7 +52,7 @@ int srslte_ue_cellsearch_nbiot_init(srslte_ue_cellsearch_nbiot_t* q, } // buffer to hold subframes for NSSS detection - q->nsss_buffer = srslte_vec_cf_malloc(SRSLTE_NSSS_NUM_SF_DETECT * q->sf_len); + q->nsss_buffer = srsran_vec_cf_malloc(SRSRAN_NSSS_NUM_SF_DETECT * q->sf_len); if (!q->nsss_buffer) { perror("malloc"); goto clean_exit; @@ -61,67 +61,67 @@ int srslte_ue_cellsearch_nbiot_init(srslte_ue_cellsearch_nbiot_t* q, q->max_frames = max_frames_total; q->nof_valid_frames = max_frames_total; - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } clean_exit: - if (ret == SRSLTE_ERROR) { - srslte_ue_cellsearch_nbiot_free(q); + if (ret == SRSRAN_ERROR) { + srsran_ue_cellsearch_nbiot_free(q); } return ret; } -void srslte_ue_cellsearch_nbiot_free(srslte_ue_cellsearch_nbiot_t* q) +void srsran_ue_cellsearch_nbiot_free(srsran_ue_cellsearch_nbiot_t* q) { - for (uint32_t i = 0; i < SRSLTE_NBIOT_NUM_RX_ANTENNAS; i++) { + for (uint32_t i = 0; i < SRSRAN_NBIOT_NUM_RX_ANTENNAS; i++) { if (q->rx_buffer[i] != NULL) { free(q->rx_buffer[i]); } } - srslte_ue_sync_nbiot_free(&q->ue_sync); - bzero(q, sizeof(srslte_ue_cellsearch_nbiot_t)); + srsran_ue_sync_nbiot_free(&q->ue_sync); + bzero(q, sizeof(srsran_ue_cellsearch_nbiot_t)); } -int srslte_ue_cellsearch_nbiot_set_nof_valid_frames(srslte_ue_cellsearch_nbiot_t* q, uint32_t nof_frames) +int srsran_ue_cellsearch_nbiot_set_nof_valid_frames(srsran_ue_cellsearch_nbiot_t* q, uint32_t nof_frames) { if (nof_frames <= q->max_frames) { q->nof_valid_frames = nof_frames; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } else { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } /** This function tries to receive one valid NSSS subframe for cell id detection. * It stores subframe 9 of two consecutive frames in a buffer and returns. */ -int srslte_ue_cellsearch_nbiot_scan(srslte_ue_cellsearch_nbiot_t* q) +int srsran_ue_cellsearch_nbiot_scan(srsran_ue_cellsearch_nbiot_t* q) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; uint32_t nof_detected_frames = 0; uint32_t nof_scanned_frames = 0; if (q != NULL) { - ret = SRSLTE_ERROR; - srslte_ue_sync_nbiot_reset(&q->ue_sync); + ret = SRSRAN_ERROR; + srsran_ue_sync_nbiot_reset(&q->ue_sync); q->nsss_sf_counter = 0; do { - ret = srslte_ue_sync_nbiot_zerocopy_multi(&q->ue_sync, q->rx_buffer); + ret = srsran_ue_sync_nbiot_zerocopy_multi(&q->ue_sync, q->rx_buffer); if (ret < 0) { - fprintf(stderr, "Error calling srslte_nbiot_ue_sync_get_buffer()\n"); + fprintf(stderr, "Error calling srsran_nbiot_ue_sync_get_buffer()\n"); break; } else if (ret == 1) { // we are in sync, wait until we have received two full frames, store subframe 9 for both - DEBUG("In tracking state sf_idx=%d", srslte_ue_sync_nbiot_get_sfidx(&q->ue_sync)); - if (srslte_ue_sync_nbiot_get_sfidx(&q->ue_sync) == 9) { + DEBUG("In tracking state sf_idx=%d", srsran_ue_sync_nbiot_get_sfidx(&q->ue_sync)); + if (srsran_ue_sync_nbiot_get_sfidx(&q->ue_sync) == 9) { // accumulate NSSS subframes for cell id detection - srslte_vec_cf_copy(&q->nsss_buffer[q->nsss_sf_counter * q->sf_len], q->rx_buffer[0], q->sf_len); + srsran_vec_cf_copy(&q->nsss_buffer[q->nsss_sf_counter * q->sf_len], q->rx_buffer[0], q->sf_len); q->nsss_sf_counter++; - if (q->nsss_sf_counter == SRSLTE_NSSS_NUM_SF_DETECT) { + if (q->nsss_sf_counter == SRSRAN_NSSS_NUM_SF_DETECT) { DEBUG("Captured %d subframes for NSSS detection.", q->nsss_sf_counter); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } } } else if (ret == 0) { @@ -131,20 +131,20 @@ int srslte_ue_cellsearch_nbiot_scan(srslte_ue_cellsearch_nbiot_t* q) } } while (nof_scanned_frames < q->max_frames && nof_detected_frames < q->nof_valid_frames); } - return SRSLTE_ERROR; + return SRSRAN_ERROR; } -int srslte_ue_cellsearch_nbiot_detect(srslte_ue_cellsearch_nbiot_t* q, srslte_nbiot_ue_cellsearch_result_t* found_cells) +int srsran_ue_cellsearch_nbiot_detect(srsran_ue_cellsearch_nbiot_t* q, srsran_nbiot_ue_cellsearch_result_t* found_cells) { - int ret = srslte_sync_nbiot_find_cell_id(&q->ue_sync.strack, q->nsss_buffer); - if (ret == SRSLTE_SUCCESS) { - int cell_id = srslte_sync_nbiot_get_cell_id(&q->ue_sync.strack); - if (srslte_cellid_isvalid(cell_id)) { + int ret = srsran_sync_nbiot_find_cell_id(&q->ue_sync.strack, q->nsss_buffer); + if (ret == SRSRAN_SUCCESS) { + int cell_id = srsran_sync_nbiot_get_cell_id(&q->ue_sync.strack); + if (srsran_cellid_isvalid(cell_id)) { // save cell, CP and peak found_cells[0].n_id_ncell = (uint32_t)cell_id; found_cells[0].peak = q->ue_sync.strack.npss.peak_value; - found_cells[0].psr = srslte_sync_nbiot_get_peak_value(&q->ue_sync.strack); - found_cells[0].cfo = srslte_ue_sync_nbiot_get_cfo(&q->ue_sync); + found_cells[0].psr = srsran_sync_nbiot_get_peak_value(&q->ue_sync.strack); + found_cells[0].cfo = srsran_ue_sync_nbiot_get_cfo(&q->ue_sync); INFO("CELL SEARCH: Found peak PSR=%.3f, Cell_id: %d", found_cells[0].psr, found_cells[0].n_id_ncell); } } diff --git a/lib/src/phy/ue/ue_dl.c b/lib/src/phy/ue/ue_dl.c index c133fb2a5..8159e4267 100644 --- a/lib/src/phy/ue/ue_dl.c +++ b/lib/src/phy/ue/ue_dl.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,28 +10,28 @@ * */ -#include "srslte/phy/ue/ue_dl.h" +#include "srsran/phy/ue/ue_dl.h" -#include "srslte/srslte.h" +#include "srsran/srsran.h" #include -#define CURRENT_FFTSIZE srslte_symbol_sz(q->cell.nof_prb) -#define CURRENT_SFLEN_RE SRSLTE_NOF_RE(q->cell) -#define MAX_SFLEN_RE SRSLTE_SF_LEN_RE(max_prb, q->cell.cp) +#define CURRENT_FFTSIZE srsran_symbol_sz(q->cell.nof_prb) +#define CURRENT_SFLEN_RE SRSRAN_NOF_RE(q->cell) +#define MAX_SFLEN_RE SRSRAN_SF_LEN_RE(max_prb, q->cell.cp) -const static srslte_dci_format_t ue_dci_formats[8][2] = { - /* Mode 1 */ {SRSLTE_DCI_FORMAT1A, SRSLTE_DCI_FORMAT1}, - /* Mode 2 */ {SRSLTE_DCI_FORMAT1A, SRSLTE_DCI_FORMAT1}, - /* Mode 3 */ {SRSLTE_DCI_FORMAT1A, SRSLTE_DCI_FORMAT2A}, - /* Mode 4 */ {SRSLTE_DCI_FORMAT1A, SRSLTE_DCI_FORMAT2}, - /* Mode 5 */ {SRSLTE_DCI_FORMAT1A, SRSLTE_DCI_FORMAT1D}, - /* Mode 6 */ {SRSLTE_DCI_FORMAT1A, SRSLTE_DCI_FORMAT1B}, - /* Mode 7 */ {SRSLTE_DCI_FORMAT1A, SRSLTE_DCI_FORMAT1}, - /* Mode 8 */ {SRSLTE_DCI_FORMAT1A, SRSLTE_DCI_FORMAT2B}}; +const static srsran_dci_format_t ue_dci_formats[8][2] = { + /* Mode 1 */ {SRSRAN_DCI_FORMAT1A, SRSRAN_DCI_FORMAT1}, + /* Mode 2 */ {SRSRAN_DCI_FORMAT1A, SRSRAN_DCI_FORMAT1}, + /* Mode 3 */ {SRSRAN_DCI_FORMAT1A, SRSRAN_DCI_FORMAT2A}, + /* Mode 4 */ {SRSRAN_DCI_FORMAT1A, SRSRAN_DCI_FORMAT2}, + /* Mode 5 */ {SRSRAN_DCI_FORMAT1A, SRSRAN_DCI_FORMAT1D}, + /* Mode 6 */ {SRSRAN_DCI_FORMAT1A, SRSRAN_DCI_FORMAT1B}, + /* Mode 7 */ {SRSRAN_DCI_FORMAT1A, SRSRAN_DCI_FORMAT1}, + /* Mode 8 */ {SRSRAN_DCI_FORMAT1A, SRSRAN_DCI_FORMAT2B}}; const uint32_t nof_ue_dci_formats = 2; -static srslte_dci_format_t common_formats[] = {SRSLTE_DCI_FORMAT1A, SRSLTE_DCI_FORMAT1C}; +static srsran_dci_format_t common_formats[] = {SRSRAN_DCI_FORMAT1A, SRSRAN_DCI_FORMAT1C}; const uint32_t nof_common_formats = 2; // mi value as in table 6.9-1 36.213 for regs vector. For FDD, uses only 1st @@ -47,46 +47,46 @@ const static uint32_t mi_tdd_table[7][10] = {{2, 1, 0, 0, 0, 2, 1, 0, 0, 0}, // {0, 0, 0, 0, 0, 0, 0, 0, 1, 0}, // ul/dl 5 {1, 1, 0, 0, 0, 1, 1, 0, 0, 1}}; // ul/dl 6 -#define MI_VALUE(sf_idx) ((q->cell.frame_type == SRSLTE_FDD) ? 1 : mi_tdd_table[sf->tdd_config.sf_config][sf_idx]) +#define MI_VALUE(sf_idx) ((q->cell.frame_type == SRSRAN_FDD) ? 1 : mi_tdd_table[sf->tdd_config.sf_config][sf_idx]) #define MI_IDX(sf_idx) \ (mi_reg_idx_inv[MI_VALUE(sf_idx)] + \ - ((q->cell.frame_type == SRSLTE_TDD && q->cell.phich_length == SRSLTE_PHICH_EXT && (sf_idx == 1 || sf_idx == 6)) \ + ((q->cell.frame_type == SRSRAN_TDD && q->cell.phich_length == SRSRAN_PHICH_EXT && (sf_idx == 1 || sf_idx == 6)) \ ? 3 \ : 0)) -int srslte_ue_dl_init(srslte_ue_dl_t* q, cf_t* in_buffer[SRSLTE_MAX_PORTS], uint32_t max_prb, uint32_t nof_rx_antennas) +int srsran_ue_dl_init(srsran_ue_dl_t* q, cf_t* in_buffer[SRSRAN_MAX_PORTS], uint32_t max_prb, uint32_t nof_rx_antennas) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; - if (q != NULL && nof_rx_antennas <= SRSLTE_MAX_PORTS) { - ret = SRSLTE_ERROR; + if (q != NULL && nof_rx_antennas <= SRSRAN_MAX_PORTS) { + ret = SRSRAN_ERROR; - bzero(q, sizeof(srslte_ue_dl_t)); + bzero(q, sizeof(srsran_ue_dl_t)); q->pending_ul_dci_count = 0; q->nof_rx_antennas = nof_rx_antennas; q->mi_auto = true; q->mi_manual_index = 0; - for (int j = 0; j < SRSLTE_MAX_PORTS; j++) { - q->sf_symbols[j] = srslte_vec_cf_malloc(MAX_SFLEN_RE); + for (int j = 0; j < SRSRAN_MAX_PORTS; j++) { + q->sf_symbols[j] = srsran_vec_cf_malloc(MAX_SFLEN_RE); if (!q->sf_symbols[j]) { perror("malloc"); goto clean_exit; } } - srslte_ofdm_cfg_t ofdm_cfg = {}; + srsran_ofdm_cfg_t ofdm_cfg = {}; ofdm_cfg.nof_prb = max_prb; - ofdm_cfg.cp = SRSLTE_CP_NORM; + ofdm_cfg.cp = SRSRAN_CP_NORM; ofdm_cfg.rx_window_offset = 0.0f; ofdm_cfg.normalize = false; for (int i = 0; i < nof_rx_antennas; i++) { ofdm_cfg.in_buffer = in_buffer[i]; ofdm_cfg.out_buffer = q->sf_symbols[i]; - ofdm_cfg.sf_type = SRSLTE_SF_NORM; + ofdm_cfg.sf_type = SRSRAN_SF_NORM; - if (srslte_ofdm_rx_init_cfg(&q->fft[i], &ofdm_cfg)) { + if (srsran_ofdm_rx_init_cfg(&q->fft[i], &ofdm_cfg)) { ERROR("Error initiating FFT"); goto clean_exit; } @@ -94,169 +94,169 @@ int srslte_ue_dl_init(srslte_ue_dl_t* q, cf_t* in_buffer[SRSLTE_MAX_PORTS], uint ofdm_cfg.in_buffer = in_buffer[0]; ofdm_cfg.out_buffer = q->sf_symbols[0]; - ofdm_cfg.sf_type = SRSLTE_SF_MBSFN; - if (srslte_ofdm_rx_init_cfg(&q->fft_mbsfn, &ofdm_cfg)) { + ofdm_cfg.sf_type = SRSRAN_SF_MBSFN; + if (srsran_ofdm_rx_init_cfg(&q->fft_mbsfn, &ofdm_cfg)) { ERROR("Error initiating FFT for MBSFN subframes "); goto clean_exit; } - srslte_ofdm_set_non_mbsfn_region(&q->fft_mbsfn, 2); // Set a default to init + srsran_ofdm_set_non_mbsfn_region(&q->fft_mbsfn, 2); // Set a default to init - if (srslte_chest_dl_init(&q->chest, max_prb, nof_rx_antennas)) { + if (srsran_chest_dl_init(&q->chest, max_prb, nof_rx_antennas)) { ERROR("Error initiating channel estimator"); goto clean_exit; } - if (srslte_chest_dl_res_init(&q->chest_res, max_prb)) { + if (srsran_chest_dl_res_init(&q->chest_res, max_prb)) { ERROR("Error initiating channel estimator"); goto clean_exit; } - if (srslte_pcfich_init(&q->pcfich, nof_rx_antennas)) { + if (srsran_pcfich_init(&q->pcfich, nof_rx_antennas)) { ERROR("Error creating PCFICH object"); goto clean_exit; } - if (srslte_phich_init(&q->phich, nof_rx_antennas)) { + if (srsran_phich_init(&q->phich, nof_rx_antennas)) { ERROR("Error creating PHICH object"); goto clean_exit; } - if (srslte_pdcch_init_ue(&q->pdcch, max_prb, nof_rx_antennas)) { + if (srsran_pdcch_init_ue(&q->pdcch, max_prb, nof_rx_antennas)) { ERROR("Error creating PDCCH object"); goto clean_exit; } - if (srslte_pdsch_init_ue(&q->pdsch, max_prb, nof_rx_antennas)) { + if (srsran_pdsch_init_ue(&q->pdsch, max_prb, nof_rx_antennas)) { ERROR("Error creating PDSCH object"); goto clean_exit; } - if (srslte_pmch_init(&q->pmch, max_prb, nof_rx_antennas)) { + if (srsran_pmch_init(&q->pmch, max_prb, nof_rx_antennas)) { ERROR("Error creating PMCH object"); goto clean_exit; } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } else { ERROR("Invalid parameters"); } clean_exit: - if (ret == SRSLTE_ERROR) { - srslte_ue_dl_free(q); + if (ret == SRSRAN_ERROR) { + srsran_ue_dl_free(q); } return ret; } -void srslte_ue_dl_free(srslte_ue_dl_t* q) +void srsran_ue_dl_free(srsran_ue_dl_t* q) { if (q) { - for (int port = 0; port < SRSLTE_MAX_PORTS; port++) { - srslte_ofdm_rx_free(&q->fft[port]); + for (int port = 0; port < SRSRAN_MAX_PORTS; port++) { + srsran_ofdm_rx_free(&q->fft[port]); } - srslte_ofdm_rx_free(&q->fft_mbsfn); - srslte_chest_dl_free(&q->chest); - srslte_chest_dl_res_free(&q->chest_res); - for (int i = 0; i < SRSLTE_MI_NOF_REGS; i++) { - srslte_regs_free(&q->regs[i]); + srsran_ofdm_rx_free(&q->fft_mbsfn); + srsran_chest_dl_free(&q->chest); + srsran_chest_dl_res_free(&q->chest_res); + for (int i = 0; i < SRSRAN_MI_NOF_REGS; i++) { + srsran_regs_free(&q->regs[i]); } - srslte_pcfich_free(&q->pcfich); - srslte_phich_free(&q->phich); - srslte_pdcch_free(&q->pdcch); - srslte_pdsch_free(&q->pdsch); - srslte_pmch_free(&q->pmch); - for (int j = 0; j < SRSLTE_MAX_PORTS; j++) { + srsran_pcfich_free(&q->pcfich); + srsran_phich_free(&q->phich); + srsran_pdcch_free(&q->pdcch); + srsran_pdsch_free(&q->pdsch); + srsran_pmch_free(&q->pmch); + for (int j = 0; j < SRSRAN_MAX_PORTS; j++) { if (q->sf_symbols[j]) { free(q->sf_symbols[j]); } } - bzero(q, sizeof(srslte_ue_dl_t)); + bzero(q, sizeof(srsran_ue_dl_t)); } } -int srslte_ue_dl_set_cell(srslte_ue_dl_t* q, srslte_cell_t cell) +int srsran_ue_dl_set_cell(srsran_ue_dl_t* q, srsran_cell_t cell) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; - if (q != NULL && srslte_cell_isvalid(&cell)) { + if (q != NULL && srsran_cell_isvalid(&cell)) { q->pending_ul_dci_count = 0; if (q->cell.id != cell.id || q->cell.nof_prb == 0) { if (q->cell.nof_prb != 0) { - for (int i = 0; i < SRSLTE_MI_NOF_REGS; i++) { - srslte_regs_free(&q->regs[i]); + for (int i = 0; i < SRSRAN_MI_NOF_REGS; i++) { + srsran_regs_free(&q->regs[i]); } } q->cell = cell; - for (int i = 0; i < SRSLTE_MI_NOF_REGS; i++) { - if (srslte_regs_init_opts(&q->regs[i], q->cell, mi_reg_idx[i % 3], i > 2)) { + for (int i = 0; i < SRSRAN_MI_NOF_REGS; i++) { + if (srsran_regs_init_opts(&q->regs[i], q->cell, mi_reg_idx[i % 3], i > 2)) { ERROR("Error resizing REGs"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } for (int port = 0; port < q->nof_rx_antennas; port++) { - if (srslte_ofdm_rx_set_prb(&q->fft[port], q->cell.cp, q->cell.nof_prb)) { + if (srsran_ofdm_rx_set_prb(&q->fft[port], q->cell.cp, q->cell.nof_prb)) { ERROR("Error resizing FFT"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } // In TDD, initialize PDCCH and PHICH for the worst case: max ncces and phich groupds respectively uint32_t pdcch_init_reg = 0; uint32_t phich_init_reg = 0; - if (q->cell.frame_type == SRSLTE_TDD) { + if (q->cell.frame_type == SRSRAN_TDD) { pdcch_init_reg = 1; // mi=0 phich_init_reg = 2; // mi=2 } - if (srslte_ofdm_rx_set_prb(&q->fft_mbsfn, SRSLTE_CP_EXT, q->cell.nof_prb)) { + if (srsran_ofdm_rx_set_prb(&q->fft_mbsfn, SRSRAN_CP_EXT, q->cell.nof_prb)) { ERROR("Error resizing MBSFN FFT"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_chest_dl_set_cell(&q->chest, q->cell)) { + if (srsran_chest_dl_set_cell(&q->chest, q->cell)) { ERROR("Error resizing channel estimator"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_pcfich_set_cell(&q->pcfich, &q->regs[0], q->cell)) { + if (srsran_pcfich_set_cell(&q->pcfich, &q->regs[0], q->cell)) { ERROR("Error resizing PCFICH object"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_phich_set_cell(&q->phich, &q->regs[phich_init_reg], q->cell)) { + if (srsran_phich_set_cell(&q->phich, &q->regs[phich_init_reg], q->cell)) { ERROR("Error resizing PHICH object"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_pdcch_set_cell(&q->pdcch, &q->regs[pdcch_init_reg], q->cell)) { + if (srsran_pdcch_set_cell(&q->pdcch, &q->regs[pdcch_init_reg], q->cell)) { ERROR("Error resizing PDCCH object"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_pdsch_set_cell(&q->pdsch, q->cell)) { + if (srsran_pdsch_set_cell(&q->pdsch, q->cell)) { ERROR("Error resizing PDSCH object"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_pmch_set_cell(&q->pmch, q->cell)) { + if (srsran_pmch_set_cell(&q->pmch, q->cell)) { ERROR("Error resizing PMCH object"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } else { ERROR("Invalid cell properties ue_dl: Id=%d, Ports=%d, PRBs=%d", cell.id, cell.nof_ports, cell.nof_prb); } return ret; } -void srslte_ue_dl_set_non_mbsfn_region(srslte_ue_dl_t* q, uint8_t non_mbsfn_region_length) +void srsran_ue_dl_set_non_mbsfn_region(srsran_ue_dl_t* q, uint8_t non_mbsfn_region_length) { - srslte_ofdm_set_non_mbsfn_region(&q->fft_mbsfn, non_mbsfn_region_length); + srsran_ofdm_set_non_mbsfn_region(&q->fft_mbsfn, non_mbsfn_region_length); } -void srslte_ue_dl_set_mi_auto(srslte_ue_dl_t* q) +void srsran_ue_dl_set_mi_auto(srsran_ue_dl_t* q) { q->mi_auto = true; } -void srslte_ue_dl_set_mi_manual(srslte_ue_dl_t* q, uint32_t mi_idx) +void srsran_ue_dl_set_mi_manual(srsran_ue_dl_t* q, uint32_t mi_idx) { q->mi_auto = false; q->mi_manual_index = mi_idx; @@ -265,45 +265,45 @@ void srslte_ue_dl_set_mi_manual(srslte_ue_dl_t* q, uint32_t mi_idx) /* Set the area ID on pmch and chest_dl to generate scrambling sequence and reference * signals. */ -int srslte_ue_dl_set_mbsfn_area_id(srslte_ue_dl_t* q, uint16_t mbsfn_area_id) +int srsran_ue_dl_set_mbsfn_area_id(srsran_ue_dl_t* q, uint16_t mbsfn_area_id) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL) { - ret = SRSLTE_ERROR; - if (srslte_chest_dl_set_mbsfn_area_id(&q->chest, mbsfn_area_id)) { + ret = SRSRAN_ERROR; + if (srsran_chest_dl_set_mbsfn_area_id(&q->chest, mbsfn_area_id)) { ERROR("Error setting MBSFN area ID "); return ret; } - if (srslte_pmch_set_area_id(&q->pmch, mbsfn_area_id)) { + if (srsran_pmch_set_area_id(&q->pmch, mbsfn_area_id)) { ERROR("Error setting MBSFN area ID "); return ret; } q->current_mbsfn_area_id = mbsfn_area_id; - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } -static void set_mi_value(srslte_ue_dl_t* q, srslte_dl_sf_cfg_t* sf, srslte_ue_dl_cfg_t* cfg) +static void set_mi_value(srsran_ue_dl_t* q, srsran_dl_sf_cfg_t* sf, srsran_ue_dl_cfg_t* cfg) { uint32_t sf_idx = sf->tti % 10; // Set mi value in pdcch region if (q->mi_auto) { INFO("Setting PHICH mi value auto. sf_idx=%d, mi=%d, idx=%d", sf_idx, MI_VALUE(sf_idx), MI_IDX(sf_idx)); - srslte_phich_set_regs(&q->phich, &q->regs[MI_IDX(sf_idx)]); - srslte_pdcch_set_regs(&q->pdcch, &q->regs[MI_IDX(sf_idx)]); + srsran_phich_set_regs(&q->phich, &q->regs[MI_IDX(sf_idx)]); + srsran_pdcch_set_regs(&q->pdcch, &q->regs[MI_IDX(sf_idx)]); } else { // No subframe 1 or 6 so no need to consider it INFO("Setting PHICH mi value manual. sf_idx=%d, mi=%d, idx=%d", sf_idx, q->mi_manual_index, mi_reg_idx_inv[q->mi_manual_index]); - srslte_phich_set_regs(&q->phich, &q->regs[mi_reg_idx_inv[q->mi_manual_index]]); - srslte_pdcch_set_regs(&q->pdcch, &q->regs[mi_reg_idx_inv[q->mi_manual_index]]); + srsran_phich_set_regs(&q->phich, &q->regs[mi_reg_idx_inv[q->mi_manual_index]]); + srsran_pdcch_set_regs(&q->pdcch, &q->regs[mi_reg_idx_inv[q->mi_manual_index]]); } } -static int estimate_pdcch_pcfich(srslte_ue_dl_t* q, srslte_dl_sf_cfg_t* sf, srslte_ue_dl_cfg_t* cfg) +static int estimate_pdcch_pcfich(srsran_ue_dl_t* q, srsran_dl_sf_cfg_t* sf, srsran_ue_dl_cfg_t* cfg) { if (q) { float cfi_corr = 0; @@ -311,70 +311,70 @@ static int estimate_pdcch_pcfich(srslte_ue_dl_t* q, srslte_dl_sf_cfg_t* sf, srsl set_mi_value(q, sf, cfg); /* Get channel estimates for each port */ - srslte_chest_dl_estimate_cfg(&q->chest, sf, &cfg->chest_cfg, q->sf_symbols, &q->chest_res); + srsran_chest_dl_estimate_cfg(&q->chest, sf, &cfg->chest_cfg, q->sf_symbols, &q->chest_res); /* First decode PCFICH and obtain CFI */ - if (srslte_pcfich_decode(&q->pcfich, sf, &q->chest_res, q->sf_symbols, &cfi_corr) < 0) { + if (srsran_pcfich_decode(&q->pcfich, sf, &q->chest_res, q->sf_symbols, &cfi_corr) < 0) { ERROR("Error decoding PCFICH"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (q->cell.frame_type == SRSLTE_TDD && ((sf->tti % 10) == 1 || (sf->tti % 10) == 6) && sf->cfi == 3) { + if (q->cell.frame_type == SRSRAN_TDD && ((sf->tti % 10) == 1 || (sf->tti % 10) == 6) && sf->cfi == 3) { sf->cfi = 2; INFO("Received CFI=3 in subframe 1 or 6 and TDD. Setting to 2"); } - if (srslte_pdcch_extract_llr(&q->pdcch, sf, &q->chest_res, q->sf_symbols)) { + if (srsran_pdcch_extract_llr(&q->pdcch, sf, &q->chest_res, q->sf_symbols)) { ERROR("Extracting PDCCH LLR"); return false; } INFO("Decoded CFI=%d with correlation %.2f, sf_idx=%d", sf->cfi, cfi_corr, sf->tti % 10); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } else { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } } -int srslte_ue_dl_decode_fft_estimate(srslte_ue_dl_t* q, srslte_dl_sf_cfg_t* sf, srslte_ue_dl_cfg_t* cfg) +int srsran_ue_dl_decode_fft_estimate(srsran_ue_dl_t* q, srsran_dl_sf_cfg_t* sf, srsran_ue_dl_cfg_t* cfg) { if (q) { /* Run FFT for all subframe data */ for (int j = 0; j < q->nof_rx_antennas; j++) { - if (sf->sf_type == SRSLTE_SF_MBSFN) { - srslte_ofdm_rx_sf(&q->fft_mbsfn); + if (sf->sf_type == SRSRAN_SF_MBSFN) { + srsran_ofdm_rx_sf(&q->fft_mbsfn); } else { - srslte_ofdm_rx_sf(&q->fft[j]); + srsran_ofdm_rx_sf(&q->fft[j]); } } return estimate_pdcch_pcfich(q, sf, cfg); } else { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } } -int srslte_ue_dl_decode_fft_estimate_noguru(srslte_ue_dl_t* q, - srslte_dl_sf_cfg_t* sf, - srslte_ue_dl_cfg_t* cfg, - cf_t* input[SRSLTE_MAX_PORTS]) +int srsran_ue_dl_decode_fft_estimate_noguru(srsran_ue_dl_t* q, + srsran_dl_sf_cfg_t* sf, + srsran_ue_dl_cfg_t* cfg, + cf_t* input[SRSRAN_MAX_PORTS]) { if (q && input) { /* Run FFT for all subframe data */ for (int j = 0; j < q->nof_rx_antennas; j++) { - if (sf->sf_type == SRSLTE_SF_MBSFN) { - srslte_ofdm_rx_sf_ng(&q->fft_mbsfn, input[j], q->sf_symbols[j]); + if (sf->sf_type == SRSRAN_SF_MBSFN) { + srsran_ofdm_rx_sf_ng(&q->fft_mbsfn, input[j], q->sf_symbols[j]); } else { - srslte_ofdm_rx_sf_ng(&q->fft[j], input[j], q->sf_symbols[j]); + srsran_ofdm_rx_sf_ng(&q->fft[j], input[j], q->sf_symbols[j]); } } return estimate_pdcch_pcfich(q, sf, cfg); } else { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } } -static bool find_dci(srslte_dci_msg_t* dci_msg, uint32_t nof_dci_msg, srslte_dci_msg_t* match) +static bool find_dci(srsran_dci_msg_t* dci_msg, uint32_t nof_dci_msg, srsran_dci_msg_t* match) { bool found = false; uint32_t nof_bits = match->nof_bits; @@ -390,7 +390,7 @@ static bool find_dci(srslte_dci_msg_t* dci_msg, uint32_t nof_dci_msg, srslte_dci return found; } -static bool dci_location_is_allocated(srslte_ue_dl_t* q, srslte_dci_location_t new_loc) +static bool dci_location_is_allocated(srsran_ue_dl_t* q, srsran_dci_location_t new_loc) { for (uint32_t i = 0; i < q->nof_allocated_locations; i++) { uint32_t L = q->allocated_locations[i].L; @@ -404,18 +404,18 @@ static bool dci_location_is_allocated(srslte_ue_dl_t* q, srslte_dci_location_t n return false; } -static int dci_blind_search(srslte_ue_dl_t* q, - srslte_dl_sf_cfg_t* sf, +static int dci_blind_search(srsran_ue_dl_t* q, + srsran_dl_sf_cfg_t* sf, uint16_t rnti, dci_blind_search_t* search_space, - srslte_dci_cfg_t* dci_cfg, - srslte_dci_msg_t dci_msg[SRSLTE_MAX_DCI_MSG], + srsran_dci_cfg_t* dci_cfg, + srsran_dci_msg_t dci_msg[SRSRAN_MAX_DCI_MSG], bool search_in_common) { uint32_t nof_dci = 0; if (rnti) { for (int l = 0; l < search_space->nof_locations; l++) { - if (nof_dci >= SRSLTE_MAX_DCI_MSG) { + if (nof_dci >= SRSRAN_MAX_DCI_MSG) { ERROR("Can't store more DCIs in buffer"); return nof_dci; } @@ -425,7 +425,7 @@ static int dci_blind_search(srslte_ue_dl_t* q, } for (uint32_t f = 0; f < search_space->nof_formats; f++) { INFO("Searching format %s in %d,%d (%d/%d)", - srslte_dci_format_string(search_space->formats[f]), + srsran_dci_format_string(search_space->formats[f]), search_space->loc[l].ncce, search_space->loc[l].L, l, @@ -435,9 +435,9 @@ static int dci_blind_search(srslte_ue_dl_t* q, dci_msg[nof_dci].location = search_space->loc[l]; dci_msg[nof_dci].format = search_space->formats[f]; dci_msg[nof_dci].rnti = 0; - if (srslte_pdcch_decode_msg(&q->pdcch, sf, dci_cfg, &dci_msg[nof_dci])) { + if (srsran_pdcch_decode_msg(&q->pdcch, sf, dci_cfg, &dci_msg[nof_dci])) { ERROR("Error decoding DCI msg"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if ((dci_msg[nof_dci].rnti == rnti) && (dci_msg[nof_dci].nof_bits > 0)) { @@ -452,31 +452,31 @@ static int dci_blind_search(srslte_ue_dl_t* q, * that only the PDCCH in the common search space is transmitted by the primary cell. */ // Find a matching ncce in the common SS - if (srslte_location_find_ncce( + if (srsran_location_find_ncce( q->current_ss_common.loc, q->current_ss_common.nof_locations, dci_msg[nof_dci].location.ncce)) { - srslte_dci_cfg_t cfg = *dci_cfg; - srslte_dci_cfg_set_common_ss(&cfg); + srsran_dci_cfg_t cfg = *dci_cfg; + srsran_dci_cfg_set_common_ss(&cfg); // if the payload size is the same that it would have in the common SS (only Format0/1A is allowed there) - if (dci_msg[nof_dci].nof_bits == srslte_dci_format_sizeof(&q->cell, sf, &cfg, SRSLTE_DCI_FORMAT1A)) { + if (dci_msg[nof_dci].nof_bits == srsran_dci_format_sizeof(&q->cell, sf, &cfg, SRSRAN_DCI_FORMAT1A)) { // assume that only the PDDCH is transmitted, therefore update the format to 0/1A dci_msg[nof_dci].format = dci_msg[nof_dci].payload[0] - ? SRSLTE_DCI_FORMAT1A - : SRSLTE_DCI_FORMAT0; // Format0/1A bit indicator is the MSB + ? SRSRAN_DCI_FORMAT1A + : SRSRAN_DCI_FORMAT0; // Format0/1A bit indicator is the MSB INFO("DCI msg found in location L=%d, ncce=%d, size=%d belongs to the common SS and is format %s", dci_msg[nof_dci].location.L, dci_msg[nof_dci].location.ncce, dci_msg[nof_dci].nof_bits, - srslte_dci_format_string_short(dci_msg[nof_dci].format)); + srsran_dci_format_string_short(dci_msg[nof_dci].format)); } } } // If found a Format0, save it for later - if (dci_msg[nof_dci].format == SRSLTE_DCI_FORMAT0) { + if (dci_msg[nof_dci].format == SRSRAN_DCI_FORMAT0) { // If there is space for accumulate another UL DCI dci and it was not detected before, then store it - if (q->pending_ul_dci_count < SRSLTE_MAX_DCI_MSG && + if (q->pending_ul_dci_count < SRSRAN_MAX_DCI_MSG && !find_dci(q->pending_ul_dci_msg, q->pending_ul_dci_count, &dci_msg[nof_dci])) { - srslte_dci_msg_t* pending_ul_dci_msg = &q->pending_ul_dci_msg[q->pending_ul_dci_count]; + srsran_dci_msg_t* pending_ul_dci_msg = &q->pending_ul_dci_msg[q->pending_ul_dci_count]; *pending_ul_dci_msg = dci_msg[nof_dci]; q->pending_ul_dci_count++; } @@ -484,7 +484,7 @@ static int dci_blind_search(srslte_ue_dl_t* q, } else if (!find_dci(dci_msg, (uint32_t)nof_dci, &dci_msg[nof_dci]) && !find_dci(q->pending_ul_dci_msg, q->pending_ul_dci_count, &dci_msg[nof_dci])) { // Save message and continue with next location - if (q->nof_allocated_locations < SRSLTE_MAX_DCI_MSG) { + if (q->nof_allocated_locations < SRSRAN_MAX_DCI_MSG) { q->allocated_locations[q->nof_allocated_locations] = dci_msg[nof_dci].location; q->nof_allocated_locations++; } @@ -502,42 +502,42 @@ static int dci_blind_search(srslte_ue_dl_t* q, return nof_dci; } -static int find_dci_ss(srslte_ue_dl_t* q, - srslte_dl_sf_cfg_t* sf, - srslte_ue_dl_cfg_t* cfg, +static int find_dci_ss(srsran_ue_dl_t* q, + srsran_dl_sf_cfg_t* sf, + srsran_ue_dl_cfg_t* cfg, uint16_t rnti, - srslte_dci_msg_t* dci_msg, - const srslte_dci_format_t* formats, + srsran_dci_msg_t* dci_msg, + const srsran_dci_format_t* formats, uint32_t nof_formats, bool is_ue) { dci_blind_search_t search_space = {}; uint32_t cfi = sf->cfi; - srslte_dci_cfg_t dci_cfg = cfg->cfg.dci; + srsran_dci_cfg_t dci_cfg = cfg->cfg.dci; - if (!SRSLTE_CFI_ISVALID(cfi)) { + if (!SRSRAN_CFI_ISVALID(cfi)) { ERROR("Invalid CFI=%d", cfi); - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } // Generate Common Search space q->current_ss_common.nof_locations = - srslte_pdcch_common_locations(&q->pdcch, q->current_ss_common.loc, SRSLTE_MAX_CANDIDATES_COM, cfi); + srsran_pdcch_common_locations(&q->pdcch, q->current_ss_common.loc, SRSRAN_MAX_CANDIDATES_COM, cfi); // Generate Search Space if (is_ue) { search_space.nof_locations = - srslte_pdcch_ue_locations(&q->pdcch, sf, search_space.loc, SRSLTE_MAX_CANDIDATES_UE, rnti); + srsran_pdcch_ue_locations(&q->pdcch, sf, search_space.loc, SRSRAN_MAX_CANDIDATES_UE, rnti); } else { // Disable extended CSI request and SRS request in common SS - srslte_dci_cfg_set_common_ss(&dci_cfg); + srsran_dci_cfg_set_common_ss(&dci_cfg); search_space = q->current_ss_common; } // Search for DCI in the SS search_space.nof_formats = nof_formats; - memcpy(search_space.formats, formats, nof_formats * sizeof(srslte_dci_format_t)); + memcpy(search_space.formats, formats, nof_formats * sizeof(srsran_dci_format_t)); INFO("Searching %d formats in %d locations in %s SS, csi=%d", nof_formats, @@ -550,29 +550,29 @@ static int find_dci_ss(srslte_ue_dl_t* q, /* * Note: This function does not perform a DCI search. It just copies the Format0 messages from the - * pending_ul_dci_msg buffer found during a call to srslte_ue_dl_find_dl_dci(). - * It is assumed that the user called srslte_ue_dl_find_dl_dci() prior to calling this function. + * pending_ul_dci_msg buffer found during a call to srsran_ue_dl_find_dl_dci(). + * It is assumed that the user called srsran_ue_dl_find_dl_dci() prior to calling this function. */ -int srslte_ue_dl_find_ul_dci(srslte_ue_dl_t* q, - srslte_dl_sf_cfg_t* sf, - srslte_ue_dl_cfg_t* dl_cfg, +int srsran_ue_dl_find_ul_dci(srsran_ue_dl_t* q, + srsran_dl_sf_cfg_t* sf, + srsran_ue_dl_cfg_t* dl_cfg, uint16_t rnti, - srslte_dci_ul_t dci_ul[SRSLTE_MAX_DCI_MSG]) + srsran_dci_ul_t dci_ul[SRSRAN_MAX_DCI_MSG]) { - srslte_dci_msg_t dci_msg[SRSLTE_MAX_DCI_MSG]; + srsran_dci_msg_t dci_msg[SRSRAN_MAX_DCI_MSG]; uint32_t nof_msg = 0; if (rnti) { - // Copy the messages found in the last call to srslte_ue_dl_find_dl_dci() - nof_msg = SRSLTE_MIN(SRSLTE_MAX_DCI_MSG, q->pending_ul_dci_count); - memcpy(dci_msg, q->pending_ul_dci_msg, sizeof(srslte_dci_msg_t) * nof_msg); + // Copy the messages found in the last call to srsran_ue_dl_find_dl_dci() + nof_msg = SRSRAN_MIN(SRSRAN_MAX_DCI_MSG, q->pending_ul_dci_count); + memcpy(dci_msg, q->pending_ul_dci_msg, sizeof(srsran_dci_msg_t) * nof_msg); q->pending_ul_dci_count = 0; // Unpack DCI messages for (uint32_t i = 0; i < nof_msg; i++) { - if (srslte_dci_msg_unpack_pusch(&q->cell, sf, &dl_cfg->cfg.dci, &dci_msg[i], &dci_ul[i])) { + if (srsran_dci_msg_unpack_pusch(&q->cell, sf, &dl_cfg->cfg.dci, &dci_msg[i], &dci_ul[i])) { ERROR("Unpacking UL DCI"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } @@ -584,27 +584,27 @@ int srslte_ue_dl_find_ul_dci(srslte_ue_dl_t* q, } // Blind search for SI/P/RA-RNTI -static int find_dl_dci_type_siprarnti(srslte_ue_dl_t* q, - srslte_dl_sf_cfg_t* sf, - srslte_ue_dl_cfg_t* dl_cfg, +static int find_dl_dci_type_siprarnti(srsran_ue_dl_t* q, + srsran_dl_sf_cfg_t* sf, + srsran_ue_dl_cfg_t* dl_cfg, uint16_t rnti, - srslte_dci_msg_t dci_msg[SRSLTE_MAX_DCI_MSG]) + srsran_dci_msg_t dci_msg[SRSRAN_MAX_DCI_MSG]) { return find_dci_ss(q, sf, dl_cfg, rnti, dci_msg, common_formats, nof_common_formats, false); } // Blind search for C-RNTI -static int find_dl_ul_dci_type_crnti(srslte_ue_dl_t* q, - srslte_dl_sf_cfg_t* sf, - srslte_ue_dl_cfg_t* dl_cfg, +static int find_dl_ul_dci_type_crnti(srsran_ue_dl_t* q, + srsran_dl_sf_cfg_t* sf, + srsran_ue_dl_cfg_t* dl_cfg, uint16_t rnti, - srslte_dci_msg_t* dci_msg) + srsran_dci_msg_t* dci_msg) { - int ret = SRSLTE_SUCCESS; + int ret = SRSRAN_SUCCESS; - if (dl_cfg->cfg.tm > SRSLTE_TM8) { + if (dl_cfg->cfg.tm > SRSRAN_TM8) { ERROR("Searching DL CRNTI: Invalid TM=%d", dl_cfg->cfg.tm + 1); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } int nof_dci_msg = 0; @@ -622,7 +622,7 @@ static int find_dl_ul_dci_type_crnti(srslte_ue_dl_t* q, // Search common SS if (dl_cfg->cfg.dci_common_ss) { - // Search only for SRSLTE_DCI_FORMAT1A (1st in common_formats) when looking for C-RNTI + // Search only for SRSRAN_DCI_FORMAT1A (1st in common_formats) when looking for C-RNTI ret = 0; if ((ret = find_dci_ss(q, sf, dl_cfg, rnti, &dci_msg[nof_dci_msg], common_formats, 1, false)) < 0) { return ret; @@ -633,15 +633,15 @@ static int find_dl_ul_dci_type_crnti(srslte_ue_dl_t* q, return nof_dci_msg; } -int srslte_ue_dl_find_dl_dci(srslte_ue_dl_t* q, - srslte_dl_sf_cfg_t* sf, - srslte_ue_dl_cfg_t* dl_cfg, +int srsran_ue_dl_find_dl_dci(srsran_ue_dl_t* q, + srsran_dl_sf_cfg_t* sf, + srsran_ue_dl_cfg_t* dl_cfg, uint16_t rnti, - srslte_dci_dl_t dci_dl[SRSLTE_MAX_DCI_MSG]) + srsran_dci_dl_t dci_dl[SRSRAN_MAX_DCI_MSG]) { set_mi_value(q, sf, dl_cfg); - srslte_dci_msg_t dci_msg[SRSLTE_MAX_DCI_MSG] = {}; + srsran_dci_msg_t dci_msg[SRSRAN_MAX_DCI_MSG] = {}; // Reset pending UL grants on each call q->pending_ul_dci_count = 0; @@ -650,7 +650,7 @@ int srslte_ue_dl_find_dl_dci(srslte_ue_dl_t* q, q->nof_allocated_locations = 0; int nof_msg = 0; - if (rnti == SRSLTE_SIRNTI || rnti == SRSLTE_PRNTI || SRSLTE_RNTI_ISRAR(rnti)) { + if (rnti == SRSRAN_SIRNTI || rnti == SRSRAN_PRNTI || SRSRAN_RNTI_ISRAR(rnti)) { nof_msg = find_dl_dci_type_siprarnti(q, sf, dl_cfg, rnti, dci_msg); } else { nof_msg = find_dl_ul_dci_type_crnti(q, sf, dl_cfg, rnti, dci_msg); @@ -658,57 +658,57 @@ int srslte_ue_dl_find_dl_dci(srslte_ue_dl_t* q, if (nof_msg < 0) { ERROR("Invalid number of DCI messages"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Unpack DCI messages for (uint32_t i = 0; i < nof_msg; i++) { - if (srslte_dci_msg_unpack_pdsch(&q->cell, sf, &dl_cfg->cfg.dci, &dci_msg[i], &dci_dl[i])) { + if (srsran_dci_msg_unpack_pdsch(&q->cell, sf, &dl_cfg->cfg.dci, &dci_msg[i], &dci_dl[i])) { ERROR("Unpacking DL DCI"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } return nof_msg; } -int srslte_ue_dl_dci_to_pdsch_grant(srslte_ue_dl_t* q, - srslte_dl_sf_cfg_t* sf, - srslte_ue_dl_cfg_t* cfg, - srslte_dci_dl_t* dci, - srslte_pdsch_grant_t* grant) +int srsran_ue_dl_dci_to_pdsch_grant(srsran_ue_dl_t* q, + srsran_dl_sf_cfg_t* sf, + srsran_ue_dl_cfg_t* cfg, + srsran_dci_dl_t* dci, + srsran_pdsch_grant_t* grant) { - return srslte_ra_dl_dci_to_grant(&q->cell, sf, cfg->cfg.tm, cfg->cfg.pdsch.use_tbs_index_alt, dci, grant); + return srsran_ra_dl_dci_to_grant(&q->cell, sf, cfg->cfg.tm, cfg->cfg.pdsch.use_tbs_index_alt, dci, grant); } -int srslte_ue_dl_decode_pdsch(srslte_ue_dl_t* q, - srslte_dl_sf_cfg_t* sf, - srslte_pdsch_cfg_t* pdsch_cfg, - srslte_pdsch_res_t data[SRSLTE_MAX_CODEWORDS]) +int srsran_ue_dl_decode_pdsch(srsran_ue_dl_t* q, + srsran_dl_sf_cfg_t* sf, + srsran_pdsch_cfg_t* pdsch_cfg, + srsran_pdsch_res_t data[SRSRAN_MAX_CODEWORDS]) { - return srslte_pdsch_decode(&q->pdsch, sf, pdsch_cfg, &q->chest_res, q->sf_symbols, data); + return srsran_pdsch_decode(&q->pdsch, sf, pdsch_cfg, &q->chest_res, q->sf_symbols, data); } -int srslte_ue_dl_decode_pmch(srslte_ue_dl_t* q, - srslte_dl_sf_cfg_t* sf, - srslte_pmch_cfg_t* pmch_cfg, - srslte_pdsch_res_t data[SRSLTE_MAX_CODEWORDS]) +int srsran_ue_dl_decode_pmch(srsran_ue_dl_t* q, + srsran_dl_sf_cfg_t* sf, + srsran_pmch_cfg_t* pmch_cfg, + srsran_pdsch_res_t data[SRSRAN_MAX_CODEWORDS]) { - return srslte_pmch_decode(&q->pmch, sf, pmch_cfg, &q->chest_res, q->sf_symbols, &data[0]); + return srsran_pmch_decode(&q->pmch, sf, pmch_cfg, &q->chest_res, q->sf_symbols, &data[0]); } -int srslte_ue_dl_decode_phich(srslte_ue_dl_t* q, - srslte_dl_sf_cfg_t* sf, - srslte_ue_dl_cfg_t* cfg, - srslte_phich_grant_t* grant, - srslte_phich_res_t* result) +int srsran_ue_dl_decode_phich(srsran_ue_dl_t* q, + srsran_dl_sf_cfg_t* sf, + srsran_ue_dl_cfg_t* cfg, + srsran_phich_grant_t* grant, + srsran_phich_res_t* result) { - srslte_phich_resource_t n_phich; + srsran_phich_resource_t n_phich; uint32_t sf_idx = sf->tti % 10; set_mi_value(q, sf, cfg); - srslte_phich_calc(&q->phich, grant, &n_phich); + srsran_phich_calc(&q->phich, grant, &n_phich); INFO("Decoding PHICH sf_idx=%d, n_prb_lowest=%d, n_dmrs=%d, I_phich=%d, n_group=%d, n_seq=%d, Ngroups=%d, Nsf=%d", sf_idx, grant->n_prb_lowest, @@ -716,10 +716,10 @@ int srslte_ue_dl_decode_phich(srslte_ue_dl_t* q, grant->I_phich, n_phich.ngroup, n_phich.nseq, - srslte_phich_ngroups(&q->phich), - srslte_phich_nsf(&q->phich)); + srsran_phich_ngroups(&q->phich), + srsran_phich_nsf(&q->phich)); - if (!srslte_phich_decode(&q->phich, sf, &q->chest_res, n_phich, q->sf_symbols, result)) { + if (!srsran_phich_decode(&q->phich, sf, &q->chest_res, n_phich, q->sf_symbols, result)) { INFO("Decoded PHICH %d with distance %f", result->ack_value, result->distance); return 0; } else { @@ -730,18 +730,18 @@ int srslte_ue_dl_decode_phich(srslte_ue_dl_t* q, /* Compute the Rank Indicator (RI) and Precoder Matrix Indicator (PMI) by computing the Signal to Interference plus * Noise Ratio (SINR), valid for TM4 */ -static int select_pmi(srslte_ue_dl_t* q, uint32_t ri, uint32_t* pmi, float* sinr_db) +static int select_pmi(srsran_ue_dl_t* q, uint32_t ri, uint32_t* pmi, float* sinr_db) { uint32_t best_pmi = 0; - float sinr_list[SRSLTE_MAX_CODEBOOKS]; + float sinr_list[SRSRAN_MAX_CODEBOOKS]; if (q->cell.nof_ports < 2) { /* Do nothing */ - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } else { - if (srslte_pdsch_select_pmi(&q->pdsch, &q->chest_res, ri + 1, &best_pmi, sinr_list)) { + if (srsran_pdsch_select_pmi(&q->pdsch, &q->chest_res, ri + 1, &best_pmi, sinr_list)) { DEBUG("SINR calculation error"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } /* Set PMI */ @@ -751,22 +751,22 @@ static int select_pmi(srslte_ue_dl_t* q, uint32_t ri, uint32_t* pmi, float* sinr /* Set PMI */ if (sinr_db != NULL) { - *sinr_db = srslte_convert_power_to_dB(sinr_list[best_pmi % SRSLTE_MAX_CODEBOOKS]); + *sinr_db = srsran_convert_power_to_dB(sinr_list[best_pmi % SRSRAN_MAX_CODEBOOKS]); } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -static int select_ri_pmi(srslte_ue_dl_t* q, uint32_t* ri, uint32_t* pmi, float* sinr_db) +static int select_ri_pmi(srsran_ue_dl_t* q, uint32_t* ri, uint32_t* pmi, float* sinr_db) { float best_sinr_db = -INFINITY; uint32_t best_pmi = 0, best_ri = 0; - uint32_t max_ri = SRSLTE_MIN(q->nof_rx_antennas, q->cell.nof_ports); + uint32_t max_ri = SRSRAN_MIN(q->nof_rx_antennas, q->cell.nof_ports); if (q->cell.nof_ports < 2) { /* Do nothing */ - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } else { /* Select the best Rank indicator (RI) and Precoding Matrix Indicator (PMI) */ for (uint32_t this_ri = 0; this_ri < max_ri; this_ri++) { @@ -774,7 +774,7 @@ static int select_ri_pmi(srslte_ue_dl_t* q, uint32_t* ri, uint32_t* pmi, float* float this_sinr_db = 0.0f; if (select_pmi(q, this_ri, &this_pmi, &this_sinr_db)) { DEBUG("SINR calculation error"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } /* Find best SINR, force maximum number of layers if SNR is higher than 30 dB */ @@ -801,16 +801,16 @@ static int select_ri_pmi(srslte_ue_dl_t* q, uint32_t* ri, uint32_t* pmi, float* *sinr_db = best_sinr_db; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } /* Compute the Rank Indicator (RI) by computing the condition number, valid for TM3 */ -int srslte_ue_dl_select_ri(srslte_ue_dl_t* q, uint32_t* ri, float* cn) +int srsran_ue_dl_select_ri(srsran_ue_dl_t* q, uint32_t* ri, float* cn) { float _cn = INFINITY; - int ret = srslte_pdsch_compute_cn(&q->pdsch, &q->chest_res, &_cn); + int ret = srsran_pdsch_compute_cn(&q->pdsch, &q->chest_res, &_cn); - if (ret == SRSLTE_SUCCESS) { + if (ret == SRSRAN_SUCCESS) { /* Set Condition number */ if (cn) { *cn = _cn; @@ -825,18 +825,18 @@ int srslte_ue_dl_select_ri(srslte_ue_dl_t* q, uint32_t* ri, float* cn) return ret; } -void srslte_ue_dl_gen_cqi_periodic(srslte_ue_dl_t* q, - srslte_ue_dl_cfg_t* cfg, +void srsran_ue_dl_gen_cqi_periodic(srsran_ue_dl_t* q, + srsran_ue_dl_cfg_t* cfg, uint32_t wideband_value, uint32_t tti, - srslte_uci_data_t* uci_data) + srsran_uci_data_t* uci_data) { - if (srslte_cqi_periodic_ri_send(&cfg->cfg.cqi_report, tti, q->cell.frame_type)) { + if (srsran_cqi_periodic_ri_send(&cfg->cfg.cqi_report, tti, q->cell.frame_type)) { /* Compute RI, PMI and SINR */ if (q->nof_rx_antennas > 1) { - if (cfg->cfg.tm == SRSLTE_TM3) { - srslte_ue_dl_select_ri(q, &cfg->last_ri, NULL); - } else if (cfg->cfg.tm == SRSLTE_TM4) { + if (cfg->cfg.tm == SRSRAN_TM3) { + srsran_ue_dl_select_ri(q, &cfg->last_ri, NULL); + } else if (cfg->cfg.tm == SRSRAN_TM4) { select_ri_pmi(q, &cfg->last_ri, NULL, NULL); } } else { @@ -844,16 +844,16 @@ void srslte_ue_dl_gen_cqi_periodic(srslte_ue_dl_t* q, } uci_data->cfg.cqi.ri_len = 1; uci_data->value.ri = cfg->last_ri; - } else if (srslte_cqi_periodic_send(&cfg->cfg.cqi_report, tti, q->cell.frame_type)) { + } else if (srsran_cqi_periodic_send(&cfg->cfg.cqi_report, tti, q->cell.frame_type)) { if (cfg->cfg.cqi_report.format_is_subband) { // TODO: Implement subband periodic reports - uci_data->cfg.cqi.type = SRSLTE_CQI_TYPE_SUBBAND; + uci_data->cfg.cqi.type = SRSRAN_CQI_TYPE_SUBBAND; uci_data->value.cqi.subband.subband_cqi = wideband_value; uci_data->value.cqi.subband.subband_label = 0; } else { - uci_data->cfg.cqi.type = SRSLTE_CQI_TYPE_WIDEBAND; + uci_data->cfg.cqi.type = SRSRAN_CQI_TYPE_WIDEBAND; uci_data->value.cqi.wideband.wideband_cqi = wideband_value; - if (cfg->cfg.tm == SRSLTE_TM4) { + if (cfg->cfg.tm == SRSRAN_TM4) { uint32_t pmi = 0; select_pmi(q, cfg->last_ri, &pmi, NULL); @@ -868,16 +868,16 @@ void srslte_ue_dl_gen_cqi_periodic(srslte_ue_dl_t* q, } } -void srslte_ue_dl_gen_cqi_aperiodic(srslte_ue_dl_t* q, - srslte_ue_dl_cfg_t* cfg, +void srsran_ue_dl_gen_cqi_aperiodic(srsran_ue_dl_t* q, + srsran_ue_dl_cfg_t* cfg, uint32_t wideband_value, - srslte_uci_data_t* uci_data) + srsran_uci_data_t* uci_data) { uint32_t pmi = 0; float sinr_db = 0.0f; switch (cfg->cfg.cqi_report.aperiodic_mode) { - case SRSLTE_CQI_MODE_30: + case SRSRAN_CQI_MODE_30: /* only Higher Layer-configured subband feedback support right now, according to TS36.213 section 7.2.1 - A UE shall report a wideband CQI value which is calculated assuming transmission on set S subbands - The UE shall also report one subband CQI value for each set S subband. The subband CQI @@ -888,18 +888,18 @@ void srslte_ue_dl_gen_cqi_aperiodic(srslte_ue_dl_t* q, reported RI. For other transmission modes they are reported conditioned on rank 1. */ - uci_data->cfg.cqi.type = SRSLTE_CQI_TYPE_SUBBAND_HL; + uci_data->cfg.cqi.type = SRSRAN_CQI_TYPE_SUBBAND_HL; uci_data->value.cqi.subband_hl.wideband_cqi_cw0 = wideband_value; // TODO: implement subband CQI properly uci_data->value.cqi.subband_hl.subband_diff_cqi_cw0 = 0; // Always report zero offset on all subbands - uci_data->cfg.cqi.N = (q->cell.nof_prb > 7) ? (uint32_t)srslte_cqi_hl_get_no_subbands(q->cell.nof_prb) : 0; + uci_data->cfg.cqi.N = (q->cell.nof_prb > 7) ? (uint32_t)srsran_cqi_hl_get_no_subbands(q->cell.nof_prb) : 0; uci_data->cfg.cqi.data_enable = true; /* Set RI = 1 */ - if (cfg->cfg.tm == SRSLTE_TM3 || cfg->cfg.tm == SRSLTE_TM4) { + if (cfg->cfg.tm == SRSRAN_TM3 || cfg->cfg.tm == SRSRAN_TM4) { if (q->nof_rx_antennas > 1) { - srslte_ue_dl_select_ri(q, &cfg->last_ri, NULL); + srsran_ue_dl_select_ri(q, &cfg->last_ri, NULL); uci_data->value.ri = (uint8_t)cfg->last_ri; uci_data->cfg.cqi.ri_len = 1; } else { @@ -910,7 +910,7 @@ void srslte_ue_dl_gen_cqi_aperiodic(srslte_ue_dl_t* q, } break; - case SRSLTE_CQI_MODE_31: + case SRSRAN_CQI_MODE_31: /* only Higher Layer-configured subband feedback support right now, according to TS36.213 section 7.2.1 - A single precoding matrix is selected from the codebook subset assuming transmission on set S subbands - A UE shall report one subband CQI value per codeword for each set S subband which are calculated assuming @@ -928,21 +928,21 @@ void srslte_ue_dl_gen_cqi_aperiodic(srslte_ue_dl_t* q, select_ri_pmi(q, &cfg->last_ri, &pmi, &sinr_db); /* Fill CQI Report */ - uci_data->cfg.cqi.type = SRSLTE_CQI_TYPE_SUBBAND_HL; + uci_data->cfg.cqi.type = SRSRAN_CQI_TYPE_SUBBAND_HL; - uci_data->value.cqi.subband_hl.wideband_cqi_cw0 = srslte_cqi_from_snr(sinr_db + cfg->snr_to_cqi_offset); + uci_data->value.cqi.subband_hl.wideband_cqi_cw0 = srsran_cqi_from_snr(sinr_db + cfg->snr_to_cqi_offset); uci_data->value.cqi.subband_hl.subband_diff_cqi_cw0 = 0; // Always report zero offset on all subbands if (cfg->last_ri > 0) { uci_data->cfg.cqi.rank_is_not_one = true; - uci_data->value.cqi.subband_hl.wideband_cqi_cw1 = srslte_cqi_from_snr(sinr_db + cfg->snr_to_cqi_offset); + uci_data->value.cqi.subband_hl.wideband_cqi_cw1 = srsran_cqi_from_snr(sinr_db + cfg->snr_to_cqi_offset); uci_data->value.cqi.subband_hl.subband_diff_cqi_cw1 = 0; // Always report zero offset on all subbands } uci_data->value.cqi.subband_hl.pmi = pmi; uci_data->cfg.cqi.pmi_present = true; uci_data->cfg.cqi.four_antenna_ports = (q->cell.nof_ports == 4); - uci_data->cfg.cqi.N = (uint32_t)((q->cell.nof_prb > 7) ? srslte_cqi_hl_get_no_subbands(q->cell.nof_prb) : 0); + uci_data->cfg.cqi.N = (uint32_t)((q->cell.nof_prb > 7) ? srsran_cqi_hl_get_no_subbands(q->cell.nof_prb) : 0); uci_data->cfg.cqi.data_enable = true; uci_data->cfg.cqi.ri_len = 1; @@ -955,7 +955,7 @@ void srslte_ue_dl_gen_cqi_aperiodic(srslte_ue_dl_t* q, } } -static void ue_dl_gen_ack_fdd_none(const srslte_pdsch_ack_t* ack_info, srslte_uci_data_t* uci_data) +static void ue_dl_gen_ack_fdd_none(const srsran_pdsch_ack_t* ack_info, srsran_uci_data_t* uci_data) { // Set all carriers number of ACKs to 0 for (uint32_t i = 0; i < ack_info->nof_cc; i++) { @@ -964,7 +964,7 @@ static void ue_dl_gen_ack_fdd_none(const srslte_pdsch_ack_t* ack_info, srslte_uc } static void -ue_dl_gen_ack_fdd_pcell_skip_drx(const srslte_pdsch_ack_t* ack_info, srslte_uci_data_t* uci_data, uint32_t nof_tb) +ue_dl_gen_ack_fdd_pcell_skip_drx(const srsran_pdsch_ack_t* ack_info, srsran_uci_data_t* uci_data, uint32_t nof_tb) { uint32_t ack_idx = 0; @@ -988,7 +988,7 @@ ue_dl_gen_ack_fdd_pcell_skip_drx(const srslte_pdsch_ack_t* ack_info, srslte_uci_ } static void -ue_dl_gen_ack_fdd_all_keep_drx(const srslte_pdsch_ack_t* ack_info, srslte_uci_data_t* uci_data, uint32_t nof_tb) +ue_dl_gen_ack_fdd_all_keep_drx(const srsran_pdsch_ack_t* ack_info, srsran_uci_data_t* uci_data, uint32_t nof_tb) { for (uint32_t cc_idx = 0; cc_idx < ack_info->nof_cc; cc_idx++) { // Find ACK/NACK @@ -1006,7 +1006,7 @@ ue_dl_gen_ack_fdd_all_keep_drx(const srslte_pdsch_ack_t* ack_info, srslte_uci_da } static void -ue_dl_gen_ack_fdd_all_spatial_bundling(const srslte_pdsch_ack_t* ack_info, srslte_uci_data_t* uci_data, uint32_t nof_tb) +ue_dl_gen_ack_fdd_all_spatial_bundling(const srsran_pdsch_ack_t* ack_info, srsran_uci_data_t* uci_data, uint32_t nof_tb) { uint32_t nof_ack = 0; @@ -1025,19 +1025,19 @@ ue_dl_gen_ack_fdd_all_spatial_bundling(const srslte_pdsch_ack_t* ack_info, srslt } // If no ACK is counted, set all zero, bundle otherwise - for (uint32_t i = 0; i < SRSLTE_PUCCH_CS_MAX_CARRIERS; i++) { + for (uint32_t i = 0; i < SRSRAN_PUCCH_CS_MAX_CARRIERS; i++) { uci_data->cfg.ack[i].nof_acks = (nof_ack == 0) ? 0 : 1; } } /* UE downlink procedure for reporting HARQ-ACK bits in FDD, Section 7.3 36.213 */ -static void gen_ack_fdd(const srslte_pdsch_ack_t* ack_info, srslte_uci_data_t* uci_data) +static void gen_ack_fdd(const srsran_pdsch_ack_t* ack_info, srsran_uci_data_t* uci_data) { // Number of transport blocks for the current Transmission Mode uint32_t nof_tb = 1; - if (ack_info->transmission_mode > SRSLTE_TM2) { - nof_tb = SRSLTE_MAX_CODEWORDS; + if (ack_info->transmission_mode > SRSRAN_TM2) { + nof_tb = SRSRAN_MAX_CODEWORDS; } // Count number of transmissions @@ -1064,7 +1064,7 @@ static void gen_ack_fdd(const srslte_pdsch_ack_t* ack_info, srslte_uci_data_t* u // Count total of Uplink Control Bits uint32_t total_uci_bits = - tb_count + srslte_cqi_size(&uci_data->cfg.cqi) + (uci_data->value.scheduling_request ? 1 : 0); + tb_count + srsran_cqi_size(&uci_data->cfg.cqi) + (uci_data->value.scheduling_request ? 1 : 0); // Does CSI report need to be transmitted? bool csi_report = uci_data->cfg.cqi.data_enable || uci_data->cfg.cqi.ri_len; @@ -1103,11 +1103,11 @@ static void gen_ack_fdd(const srslte_pdsch_ack_t* ack_info, srslte_uci_data_t* u // For each HARQ ACK/NACK feedback mode switch (ack_info->ack_nack_feedback_mode) { - case SRSLTE_PUCCH_ACK_NACK_FEEDBACK_MODE_NORMAL: + case SRSRAN_PUCCH_ACK_NACK_FEEDBACK_MODE_NORMAL: // Get ACK from PCell only, skipping DRX ue_dl_gen_ack_fdd_pcell_skip_drx(ack_info, uci_data, nof_tb); break; - case SRSLTE_PUCCH_ACK_NACK_FEEDBACK_MODE_CS: + case SRSRAN_PUCCH_ACK_NACK_FEEDBACK_MODE_CS: // Configured with more than serving cell and PUCCH Format 1b with channel selection if (ack_info->nof_cc == 1) { ue_dl_gen_ack_fdd_pcell_skip_drx(ack_info, uci_data, nof_tb); @@ -1132,7 +1132,7 @@ static void gen_ack_fdd(const srslte_pdsch_ack_t* ack_info, srslte_uci_data_t* u ue_dl_gen_ack_fdd_all_keep_drx(ack_info, uci_data, nof_tb); } break; - case SRSLTE_PUCCH_ACK_NACK_FEEDBACK_MODE_PUCCH3: + case SRSRAN_PUCCH_ACK_NACK_FEEDBACK_MODE_PUCCH3: // According to 3GPP 36.213 Section 10.1.2.2.2 PUCCH format 3 HARQ-ACK procedure // For FDD with PUCCH format 3, the UE shall use PUCCH resource n_pucch_3 or n_pucch_1 for transmission of // HARQ-ACK in subframe n where @@ -1151,7 +1151,7 @@ static void gen_ack_fdd(const srslte_pdsch_ack_t* ack_info, srslte_uci_data_t* u ue_dl_gen_ack_fdd_all_keep_drx(ack_info, uci_data, nof_tb); } break; - case SRSLTE_PUCCH_ACK_NACK_FEEDBACK_MODE_ERROR: + case SRSRAN_PUCCH_ACK_NACK_FEEDBACK_MODE_ERROR: default:; // Do nothing break; } @@ -1170,13 +1170,13 @@ static const uint32_t multiple_acknack[10][2] = /* UE downlink procedure for reporting HARQ-ACK bits in TDD, Section 7.3 36.213 */ -static void gen_ack_tdd(bool is_tdd_mode16, const srslte_pdsch_ack_t* ack_info, srslte_uci_data_t* uci_data) +static void gen_ack_tdd(bool is_tdd_mode16, const srsran_pdsch_ack_t* ack_info, srsran_uci_data_t* uci_data) { uint32_t V_dai_dl = 0; uint32_t nof_tb = 1; - if (ack_info->transmission_mode > SRSLTE_TM2) { - nof_tb = SRSLTE_MAX_CODEWORDS; + if (ack_info->transmission_mode > SRSRAN_TM2) { + nof_tb = SRSRAN_MAX_CODEWORDS; } if (ack_info->nof_cc > 1) { @@ -1184,8 +1184,8 @@ static void gen_ack_tdd(bool is_tdd_mode16, const srslte_pdsch_ack_t* ack_info, } // Arrange bits for FDD or TDD Bundling or Multiplexing. - const srslte_pdsch_ack_cc_t* ack_value = &ack_info->cc[0]; - srslte_uci_cfg_ack_t* ack_cfg = &uci_data->cfg.ack[0]; + const srsran_pdsch_ack_cc_t* ack_value = &ack_info->cc[0]; + srsran_uci_cfg_ack_t* ack_cfg = &uci_data->cfg.ack[0]; uint32_t min_k = 10; @@ -1363,7 +1363,7 @@ static void gen_ack_tdd(bool is_tdd_mode16, const srslte_pdsch_ack_t* ack_info, uci_data->value.ack.ack_value[0] = 0; uci_data->value.ack.ack_value[1] = 0; } else { - nof_pos_acks = SRSLTE_MIN(9, nof_pos_acks); + nof_pos_acks = SRSRAN_MIN(9, nof_pos_acks); uci_data->value.ack.ack_value[0] = multiple_acknack[nof_pos_acks][0]; uci_data->value.ack.ack_value[1] = multiple_acknack[nof_pos_acks][1]; } @@ -1373,13 +1373,13 @@ static void gen_ack_tdd(bool is_tdd_mode16, const srslte_pdsch_ack_t* ack_info, /* UE downlink procedure for reporting ACK/NACK, Section 7.3 36.213 */ -void srslte_ue_dl_gen_ack(const srslte_cell_t* cell, - const srslte_dl_sf_cfg_t* sf, - const srslte_pdsch_ack_t* ack_info, - srslte_uci_data_t* uci_data) +void srsran_ue_dl_gen_ack(const srsran_cell_t* cell, + const srsran_dl_sf_cfg_t* sf, + const srsran_pdsch_ack_t* ack_info, + srsran_uci_data_t* uci_data) { uci_data->value.ack.valid = true; //< Always true for UE transmitter - if (cell->frame_type == SRSLTE_FDD) { + if (cell->frame_type == SRSRAN_FDD) { gen_ack_fdd(ack_info, uci_data); } else { bool is_tdd_mode16 = sf->tdd_config.sf_config >= 1 && sf->tdd_config.sf_config <= 6; @@ -1387,24 +1387,24 @@ void srslte_ue_dl_gen_ack(const srslte_cell_t* cell, } } -int srslte_ue_dl_find_and_decode(srslte_ue_dl_t* q, - srslte_dl_sf_cfg_t* sf, - srslte_ue_dl_cfg_t* cfg, - srslte_pdsch_cfg_t* pdsch_cfg, - uint8_t* data[SRSLTE_MAX_CODEWORDS], - bool acks[SRSLTE_MAX_CODEWORDS]) +int srsran_ue_dl_find_and_decode(srsran_ue_dl_t* q, + srsran_dl_sf_cfg_t* sf, + srsran_ue_dl_cfg_t* cfg, + srsran_pdsch_cfg_t* pdsch_cfg, + uint8_t* data[SRSRAN_MAX_CODEWORDS], + bool acks[SRSRAN_MAX_CODEWORDS]) { - int ret = SRSLTE_ERROR; + int ret = SRSRAN_ERROR; - srslte_dci_dl_t dci_dl[SRSLTE_MAX_DCI_MSG] = {}; - srslte_pmch_cfg_t pmch_cfg; - srslte_pdsch_res_t pdsch_res[SRSLTE_MAX_CODEWORDS]; + srsran_dci_dl_t dci_dl[SRSRAN_MAX_DCI_MSG] = {}; + srsran_pmch_cfg_t pmch_cfg; + srsran_pdsch_res_t pdsch_res[SRSRAN_MAX_CODEWORDS]; // Use default values for PDSCH decoder ZERO_OBJECT(pmch_cfg); uint32_t mi_set_len; - if (q->cell.frame_type == SRSLTE_TDD && !sf->tdd_config.configured) { + if (q->cell.frame_type == SRSRAN_TDD && !sf->tdd_config.configured) { mi_set_len = 3; } else { mi_set_len = 1; @@ -1414,56 +1414,56 @@ int srslte_ue_dl_find_and_decode(srslte_ue_dl_t* q, ret = 0; for (uint32_t i = 0; i < mi_set_len && !ret; i++) { if (mi_set_len == 1) { - srslte_ue_dl_set_mi_auto(q); + srsran_ue_dl_set_mi_auto(q); } else { - srslte_ue_dl_set_mi_manual(q, i); + srsran_ue_dl_set_mi_manual(q, i); } - if ((ret = srslte_ue_dl_decode_fft_estimate(q, sf, cfg)) < 0) { + if ((ret = srsran_ue_dl_decode_fft_estimate(q, sf, cfg)) < 0) { return ret; } - ret = srslte_ue_dl_find_dl_dci(q, sf, cfg, pdsch_cfg->rnti, dci_dl); + ret = srsran_ue_dl_find_dl_dci(q, sf, cfg, pdsch_cfg->rnti, dci_dl); } if (ret == 1) { // Logging - if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_INFO) { + if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_INFO) { char str[512]; - srslte_dci_dl_info(&dci_dl[0], str, 512); + srsran_dci_dl_info(&dci_dl[0], str, 512); INFO("PDCCH: %s, snr=%.1f dB", str, q->chest_res.snr_db); } // Force known MBSFN grant - if (sf->sf_type == SRSLTE_SF_MBSFN) { - dci_dl[0].rnti = SRSLTE_MRNTI; - dci_dl[0].alloc_type = SRSLTE_RA_ALLOC_TYPE0; + if (sf->sf_type == SRSRAN_SF_MBSFN) { + dci_dl[0].rnti = SRSRAN_MRNTI; + dci_dl[0].alloc_type = SRSRAN_RA_ALLOC_TYPE0; dci_dl[0].type0_alloc.rbg_bitmask = 0xffffffff; dci_dl[0].tb[0].rv = 0; dci_dl[0].tb[0].mcs_idx = 2; - dci_dl[0].format = SRSLTE_DCI_FORMAT1; + dci_dl[0].format = SRSRAN_DCI_FORMAT1; } // Convert DCI message to DL grant - if (srslte_ue_dl_dci_to_pdsch_grant(q, sf, cfg, &dci_dl[0], &pdsch_cfg->grant)) { + if (srsran_ue_dl_dci_to_pdsch_grant(q, sf, cfg, &dci_dl[0], &pdsch_cfg->grant)) { ERROR("Error unpacking DCI"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Calculate RV if not provided in the grant and reset softbuffer - for (int i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { + for (int i = 0; i < SRSRAN_MAX_CODEWORDS; i++) { if (pdsch_cfg->grant.tb[i].enabled) { if (pdsch_cfg->grant.tb[i].rv < 0) { uint32_t sfn = sf->tti / 10; uint32_t k = (sfn / 2) % 4; pdsch_cfg->grant.tb[i].rv = ((uint32_t)ceilf((float)1.5 * k)) % 4; } - srslte_softbuffer_rx_reset_tbs(pdsch_cfg->softbuffers.rx[i], (uint32_t)pdsch_cfg->grant.tb[i].tbs); + srsran_softbuffer_rx_reset_tbs(pdsch_cfg->softbuffers.rx[i], (uint32_t)pdsch_cfg->grant.tb[i].tbs); } } bool decode_enable = false; - for (uint32_t tb = 0; tb < SRSLTE_MAX_CODEWORDS; tb++) { + for (uint32_t tb = 0; tb < SRSRAN_MAX_CODEWORDS; tb++) { if (pdsch_cfg->grant.tb[tb].enabled) { decode_enable = true; pdsch_res[tb].payload = data[tb]; @@ -1472,21 +1472,21 @@ int srslte_ue_dl_find_and_decode(srslte_ue_dl_t* q, } if (decode_enable) { - if (sf->sf_type == SRSLTE_SF_NORM) { - if (srslte_ue_dl_decode_pdsch(q, sf, pdsch_cfg, pdsch_res)) { + if (sf->sf_type == SRSRAN_SF_NORM) { + if (srsran_ue_dl_decode_pdsch(q, sf, pdsch_cfg, pdsch_res)) { ERROR("ERROR: Decoding PDSCH"); ret = -1; } } else { pmch_cfg.pdsch_cfg = *pdsch_cfg; - if (srslte_ue_dl_decode_pmch(q, sf, &pmch_cfg, pdsch_res)) { + if (srsran_ue_dl_decode_pmch(q, sf, &pmch_cfg, pdsch_res)) { ERROR("Decoding PMCH"); ret = -1; } } } - for (uint32_t tb = 0; tb < SRSLTE_MAX_CODEWORDS; tb++) { + for (uint32_t tb = 0; tb < SRSRAN_MAX_CODEWORDS; tb++) { if (pdsch_cfg->grant.tb[tb].enabled) { acks[tb] = pdsch_res[tb].crc; } @@ -1495,31 +1495,31 @@ int srslte_ue_dl_find_and_decode(srslte_ue_dl_t* q, return ret; } -void srslte_ue_dl_save_signal(srslte_ue_dl_t* q, srslte_dl_sf_cfg_t* sf, srslte_pdsch_cfg_t* pdsch_cfg) +void srsran_ue_dl_save_signal(srsran_ue_dl_t* q, srsran_dl_sf_cfg_t* sf, srsran_pdsch_cfg_t* pdsch_cfg) { uint32_t cfi = sf->cfi; uint32_t tti = sf->tti % 10; - srslte_vec_save_file("sf_symbols", q->sf_symbols, SRSLTE_NOF_RE(q->cell) * sizeof(cf_t)); - printf("%d samples\n", SRSLTE_NOF_RE(q->cell)); - srslte_vec_save_file("ce0", q->chest_res.ce[0], SRSLTE_NOF_RE(q->cell) * sizeof(cf_t)); + srsran_vec_save_file("sf_symbols", q->sf_symbols, SRSRAN_NOF_RE(q->cell) * sizeof(cf_t)); + printf("%d samples\n", SRSRAN_NOF_RE(q->cell)); + srsran_vec_save_file("ce0", q->chest_res.ce[0], SRSRAN_NOF_RE(q->cell) * sizeof(cf_t)); if (q->cell.nof_ports > 1) { - srslte_vec_save_file("ce1", q->chest_res.ce[1], SRSLTE_NOF_RE(q->cell) * sizeof(cf_t)); + srsran_vec_save_file("ce1", q->chest_res.ce[1], SRSRAN_NOF_RE(q->cell) * sizeof(cf_t)); } - srslte_vec_save_file("pcfich_ce0", q->pcfich.ce[0], q->pcfich.nof_symbols * sizeof(cf_t)); - srslte_vec_save_file("pcfich_ce1", q->pcfich.ce[1], q->pcfich.nof_symbols * sizeof(cf_t)); - srslte_vec_save_file("pcfich_symbols", q->pcfich.symbols[0], q->pcfich.nof_symbols * sizeof(cf_t)); - srslte_vec_save_file("pcfich_eq_symbols", q->pcfich.d, q->pcfich.nof_symbols * sizeof(cf_t)); - srslte_vec_save_file("pcfich_llr", q->pcfich.data_f, PCFICH_CFI_LEN * sizeof(float)); - - srslte_vec_save_file("pdcch_ce0", q->pdcch.ce[0], q->pdcch.nof_cce[cfi - 1] * 36 * sizeof(cf_t)); - srslte_vec_save_file("pdcch_ce1", q->pdcch.ce[1], q->pdcch.nof_cce[cfi - 1] * 36 * sizeof(cf_t)); - srslte_vec_save_file("pdcch_symbols", q->pdcch.symbols[0], q->pdcch.nof_cce[cfi - 1] * 36 * sizeof(cf_t)); - srslte_vec_save_file("pdcch_eq_symbols", q->pdcch.d, q->pdcch.nof_cce[cfi - 1] * 36 * sizeof(cf_t)); - srslte_vec_save_file("pdcch_llr", q->pdcch.llr, q->pdcch.nof_cce[cfi - 1] * 72 * sizeof(float)); - - srslte_vec_save_file("pdsch_symbols", q->pdsch.d[0], pdsch_cfg->grant.nof_re * sizeof(cf_t)); - srslte_vec_save_file("llr", q->pdsch.e[0], pdsch_cfg->grant.tb[0].nof_bits * sizeof(cf_t)); + srsran_vec_save_file("pcfich_ce0", q->pcfich.ce[0], q->pcfich.nof_symbols * sizeof(cf_t)); + srsran_vec_save_file("pcfich_ce1", q->pcfich.ce[1], q->pcfich.nof_symbols * sizeof(cf_t)); + srsran_vec_save_file("pcfich_symbols", q->pcfich.symbols[0], q->pcfich.nof_symbols * sizeof(cf_t)); + srsran_vec_save_file("pcfich_eq_symbols", q->pcfich.d, q->pcfich.nof_symbols * sizeof(cf_t)); + srsran_vec_save_file("pcfich_llr", q->pcfich.data_f, PCFICH_CFI_LEN * sizeof(float)); + + srsran_vec_save_file("pdcch_ce0", q->pdcch.ce[0], q->pdcch.nof_cce[cfi - 1] * 36 * sizeof(cf_t)); + srsran_vec_save_file("pdcch_ce1", q->pdcch.ce[1], q->pdcch.nof_cce[cfi - 1] * 36 * sizeof(cf_t)); + srsran_vec_save_file("pdcch_symbols", q->pdcch.symbols[0], q->pdcch.nof_cce[cfi - 1] * 36 * sizeof(cf_t)); + srsran_vec_save_file("pdcch_eq_symbols", q->pdcch.d, q->pdcch.nof_cce[cfi - 1] * 36 * sizeof(cf_t)); + srsran_vec_save_file("pdcch_llr", q->pdcch.llr, q->pdcch.nof_cce[cfi - 1] * 72 * sizeof(float)); + + srsran_vec_save_file("pdsch_symbols", q->pdsch.d[0], pdsch_cfg->grant.nof_re * sizeof(cf_t)); + srsran_vec_save_file("llr", q->pdsch.e[0], pdsch_cfg->grant.tb[0].nof_bits * sizeof(cf_t)); printf("Saved files for tti=%d, sf=%d, cfi=%d, tbs=%d, rv=%d\n", tti, tti % 10, diff --git a/lib/src/phy/ue/ue_dl_nbiot.c b/lib/src/phy/ue/ue_dl_nbiot.c index 8b47b3821..774cdd556 100644 --- a/lib/src/phy/ue/ue_dl_nbiot.c +++ b/lib/src/phy/ue/ue_dl_nbiot.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,7 +10,7 @@ * */ -#include "srslte/phy/ue/ue_dl_nbiot.h" +#include "srsran/phy/ue/ue_dl_nbiot.h" #include #include @@ -19,23 +19,23 @@ #define DUMP_SIGNALS 0 -static srslte_dci_format_t nb_ue_formats[] = {SRSLTE_DCI_FORMATN0, SRSLTE_DCI_FORMATN1}; +static srsran_dci_format_t nb_ue_formats[] = {SRSRAN_DCI_FORMATN0, SRSRAN_DCI_FORMATN1}; const uint32_t nof_nb_ue_formats = 2; -static srslte_dci_format_t nb_common_formats[] = {SRSLTE_DCI_FORMATN1, SRSLTE_DCI_FORMATN2}; +static srsran_dci_format_t nb_common_formats[] = {SRSRAN_DCI_FORMATN1, SRSRAN_DCI_FORMATN2}; const uint32_t nb_nof_common_formats = 2; -int srslte_nbiot_ue_dl_init(srslte_nbiot_ue_dl_t* q, - cf_t* in_buffer[SRSLTE_MAX_PORTS], +int srsran_nbiot_ue_dl_init(srsran_nbiot_ue_dl_t* q, + cf_t* in_buffer[SRSRAN_MAX_PORTS], uint32_t max_prb, uint32_t nof_rx_antennas) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL) { - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; - bzero(q, sizeof(srslte_nbiot_ue_dl_t)); + bzero(q, sizeof(srsran_nbiot_ue_dl_t)); q->pkt_errors = 0; q->pkts_total = 0; @@ -43,18 +43,18 @@ int srslte_nbiot_ue_dl_init(srslte_nbiot_ue_dl_t* q, q->bits_total = 0; q->sample_offset = 0; q->mib_set = false; - q->nof_re = SRSLTE_SF_LEN_RE(SRSLTE_NBIOT_MAX_PRB, SRSLTE_CP_NORM); + q->nof_re = SRSRAN_SF_LEN_RE(SRSRAN_NBIOT_MAX_PRB, SRSRAN_CP_NORM); // for transmissions using only single subframe - q->sf_symbols = srslte_vec_cf_malloc(q->nof_re); + q->sf_symbols = srsran_vec_cf_malloc(q->nof_re); if (!q->sf_symbols) { perror("malloc"); goto clean_exit; } - srslte_vec_cf_zero(q->sf_symbols, q->nof_re); + srsran_vec_cf_zero(q->sf_symbols, q->nof_re); - for (uint32_t i = 0; i < SRSLTE_MAX_PORTS; i++) { - q->ce[i] = srslte_vec_cf_malloc(q->nof_re); + for (uint32_t i = 0; i < SRSRAN_MAX_PORTS; i++) { + q->ce[i] = srsran_vec_cf_malloc(q->nof_re); if (!q->ce[i]) { perror("malloc"); goto clean_exit; @@ -66,88 +66,88 @@ int srslte_nbiot_ue_dl_init(srslte_nbiot_ue_dl_t* q, // allocate memory for symbols and estimates for tx spanning multiple subframes // TODO: only buffer softbits rather than raw samples - q->sf_buffer = srslte_vec_cf_malloc(q->nof_re * SRSLTE_NPDSCH_MAX_NOF_SF); + q->sf_buffer = srsran_vec_cf_malloc(q->nof_re * SRSRAN_NPDSCH_MAX_NOF_SF); if (!q->sf_buffer) { perror("malloc"); goto clean_exit; } - srslte_vec_cf_zero(q->sf_buffer, q->nof_re * SRSLTE_NPDSCH_MAX_NOF_SF); + srsran_vec_cf_zero(q->sf_buffer, q->nof_re * SRSRAN_NPDSCH_MAX_NOF_SF); - for (uint32_t i = 0; i < SRSLTE_MAX_PORTS; i++) { - q->ce_buffer[i] = srslte_vec_cf_malloc(q->nof_re * SRSLTE_NPDSCH_MAX_NOF_SF); + for (uint32_t i = 0; i < SRSRAN_MAX_PORTS; i++) { + q->ce_buffer[i] = srsran_vec_cf_malloc(q->nof_re * SRSRAN_NPDSCH_MAX_NOF_SF); if (!q->ce_buffer[i]) { perror("malloc"); goto clean_exit; } - for (int k = 0; k < (q->nof_re * SRSLTE_NPDSCH_MAX_NOF_SF); k++) { + for (int k = 0; k < (q->nof_re * SRSRAN_NPDSCH_MAX_NOF_SF); k++) { q->ce_buffer[i][k] = 1; } } // allocate memory for soft-bits - q->llr = srslte_vec_f_malloc(q->nof_re * SRSLTE_NPDSCH_MAX_NOF_SF * 2); + q->llr = srsran_vec_f_malloc(q->nof_re * SRSRAN_NPDSCH_MAX_NOF_SF * 2); if (!q->llr) { goto clean_exit; } - srslte_vec_f_zero(q->llr, q->nof_re * SRSLTE_NPDSCH_MAX_NOF_SF * 2); + srsran_vec_f_zero(q->llr, q->nof_re * SRSRAN_NPDSCH_MAX_NOF_SF * 2); // initialize memory - if (srslte_ofdm_rx_init(&q->fft, SRSLTE_CP_NORM, in_buffer[0], q->sf_symbols, max_prb)) { + if (srsran_ofdm_rx_init(&q->fft, SRSRAN_CP_NORM, in_buffer[0], q->sf_symbols, max_prb)) { fprintf(stderr, "Error initiating FFT\n"); goto clean_exit; } - srslte_ofdm_set_freq_shift(&q->fft, SRSLTE_NBIOT_FREQ_SHIFT_FACTOR); - // srslte_ofdm_set_normalize(&q->fft, true); + srsran_ofdm_set_freq_shift(&q->fft, SRSRAN_NBIOT_FREQ_SHIFT_FACTOR); + // srsran_ofdm_set_normalize(&q->fft, true); - if (srslte_chest_dl_nbiot_init(&q->chest, max_prb)) { + if (srsran_chest_dl_nbiot_init(&q->chest, max_prb)) { fprintf(stderr, "Error initiating channel estimator\n"); goto clean_exit; } - if (srslte_npdcch_init(&q->npdcch)) { + if (srsran_npdcch_init(&q->npdcch)) { fprintf(stderr, "Error creating PDCCH object\n"); goto clean_exit; } - if (srslte_npdsch_init(&q->npdsch)) { + if (srsran_npdsch_init(&q->npdsch)) { fprintf(stderr, "Error creating PDSCH object\n"); goto clean_exit; } - if (srslte_softbuffer_rx_init(&q->softbuffer, max_prb)) { + if (srsran_softbuffer_rx_init(&q->softbuffer, max_prb)) { fprintf(stderr, "Error initiating soft buffer\n"); goto clean_exit; } - if (srslte_cfo_init(&q->sfo_correct, max_prb * SRSLTE_NRE)) { + if (srsran_cfo_init(&q->sfo_correct, max_prb * SRSRAN_NRE)) { fprintf(stderr, "Error initiating SFO correct\n"); goto clean_exit; } - srslte_cfo_set_tol(&q->sfo_correct, 1e-5 / q->fft.cfg.symbol_sz); + srsran_cfo_set_tol(&q->sfo_correct, 1e-5 / q->fft.cfg.symbol_sz); - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } else { fprintf(stderr, "Invalid UE DL object\n"); } clean_exit: - if (ret == SRSLTE_ERROR) { - srslte_nbiot_ue_dl_free(q); + if (ret == SRSRAN_ERROR) { + srsran_nbiot_ue_dl_free(q); } return ret; } -void srslte_nbiot_ue_dl_free(srslte_nbiot_ue_dl_t* q) +void srsran_nbiot_ue_dl_free(srsran_nbiot_ue_dl_t* q) { if (q) { - srslte_ofdm_rx_free(&q->fft); - srslte_chest_dl_nbiot_free(&q->chest); - srslte_npdcch_free(&q->npdcch); - srslte_npdsch_free(&q->npdsch); - srslte_cfo_free(&q->sfo_correct); - srslte_softbuffer_rx_free(&q->softbuffer); + srsran_ofdm_rx_free(&q->fft); + srsran_chest_dl_nbiot_free(&q->chest); + srsran_npdcch_free(&q->npdcch); + srsran_npdsch_free(&q->npdsch); + srsran_cfo_free(&q->sfo_correct); + srsran_softbuffer_rx_free(&q->softbuffer); if (q->sf_symbols) { free(q->sf_symbols); } - for (uint32_t i = 0; i < SRSLTE_MAX_PORTS; i++) { + for (uint32_t i = 0; i < SRSRAN_MAX_PORTS; i++) { if (q->ce[i]) { free(q->ce[i]); } @@ -155,7 +155,7 @@ void srslte_nbiot_ue_dl_free(srslte_nbiot_ue_dl_t* q) if (q->sf_buffer) { free(q->sf_buffer); } - for (uint32_t i = 0; i < SRSLTE_MAX_PORTS; i++) { + for (uint32_t i = 0; i < SRSRAN_MAX_PORTS; i++) { if (q->ce_buffer[i]) { free(q->ce_buffer[i]); } @@ -163,15 +163,15 @@ void srslte_nbiot_ue_dl_free(srslte_nbiot_ue_dl_t* q) if (q->llr) { free(q->llr); } - bzero(q, sizeof(srslte_nbiot_ue_dl_t)); + bzero(q, sizeof(srsran_nbiot_ue_dl_t)); } } -int srslte_nbiot_ue_dl_set_cell(srslte_nbiot_ue_dl_t* q, srslte_nbiot_cell_t cell) +int srsran_nbiot_ue_dl_set_cell(srsran_nbiot_ue_dl_t* q, srsran_nbiot_cell_t cell) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; - if (q != NULL && srslte_nbiot_cell_isvalid(&cell)) { + if (q != NULL && srsran_nbiot_cell_isvalid(&cell)) { q->pkt_errors = 0; q->pkts_total = 0; q->sample_offset = 0; @@ -179,23 +179,23 @@ int srslte_nbiot_ue_dl_set_cell(srslte_nbiot_ue_dl_t* q, srslte_nbiot_cell_t cel if (q->cell.n_id_ncell != cell.n_id_ncell || q->cell.base.nof_prb == 0) { q->cell = cell; - if (srslte_chest_dl_nbiot_set_cell(&q->chest, q->cell)) { + if (srsran_chest_dl_nbiot_set_cell(&q->chest, q->cell)) { fprintf(stderr, "Error setting channel estimator's cell configuration\n"); return -1; } - if (srslte_npdcch_set_cell(&q->npdcch, q->cell)) { + if (srsran_npdcch_set_cell(&q->npdcch, q->cell)) { fprintf(stderr, "Error resizing NPDCCH object\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_npdsch_set_cell(&q->npdsch, q->cell)) { + if (srsran_npdsch_set_cell(&q->npdsch, q->cell)) { fprintf(stderr, "Error creating NPDSCH object\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } q->current_rnti = 0; } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } else { fprintf(stderr, "Invalid cell properties: n_id_ncell=%d, Ports=%d, base cell's PRBs=%d\n", @@ -207,11 +207,11 @@ int srslte_nbiot_ue_dl_set_cell(srslte_nbiot_ue_dl_t* q, srslte_nbiot_cell_t cel } // Section 5.2.1.2a in 3GPP 36.331 -void srslte_nbiot_ue_dl_set_mib(srslte_nbiot_ue_dl_t* q, srslte_mib_nb_t mib) +void srsran_nbiot_ue_dl_set_mib(srsran_nbiot_ue_dl_t* q, srsran_mib_nb_t mib) { // compute frames that contain SIB1-NB transmissions (there are 4 SIB1 cycles before SFN counter wraps) - uint32_t num_rep = srslte_ra_n_rep_sib1_nb(&mib); - uint32_t sib1_start = srslte_ra_nbiot_get_starting_sib1_frame(q->cell.n_id_ncell, &mib); + uint32_t num_rep = srsran_ra_n_rep_sib1_nb(&mib); + uint32_t sib1_start = srsran_ra_nbiot_get_starting_sib1_frame(q->cell.n_id_ncell, &mib); uint32_t idx = 0; for (int k = 0; k < 4; k++) { @@ -223,9 +223,9 @@ void srslte_nbiot_ue_dl_set_mib(srslte_nbiot_ue_dl_t* q, srslte_mib_nb_t mib) } assert(idx <= 4 * SIB1_NB_MAX_REP && idx == 4 * num_rep); - if (SRSLTE_VERBOSE_ISINFO()) { + if (SRSRAN_VERBOSE_ISINFO()) { INFO("%d DL SIB1-NB SFNs: ", 4 * num_rep); - srslte_vec_fprint_i(stdout, (int*)q->sib1_sfn, num_rep * 4); + srsran_vec_fprint_i(stdout, (int*)q->sib1_sfn, num_rep * 4); } // compute _all_ SIB1 subframes and store them in lookup table @@ -242,11 +242,11 @@ void srslte_nbiot_ue_dl_set_mib(srslte_nbiot_ue_dl_t* q, srslte_mib_nb_t mib) q->mib_set = true; } -void srslte_nbiot_ue_dl_set_si_params(srslte_nbiot_ue_dl_t* q, - srslte_nbiot_si_type_t type, - srslte_nbiot_si_params_t params) +void srsran_nbiot_ue_dl_set_si_params(srsran_nbiot_ue_dl_t* q, + srsran_nbiot_si_type_t type, + srsran_nbiot_si_params_t params) { - if (type < SRSLTE_NBIOT_SI_TYPE_NITEMS) { + if (type < SRSRAN_NBIOT_SI_TYPE_NITEMS) { if (params.n != 0) { // calculate TTIs for this SI int x = (params.n - 1) * params.si_window_length; @@ -266,8 +266,8 @@ void srslte_nbiot_ue_dl_set_si_params(srslte_nbiot_ue_dl_t* q, int si_tti = si_start_tti; while (num_sf > 0) { // only add if it's a valid DL SF and is not used for SIB1 - if (srslte_ra_nbiot_is_valid_dl_sf(si_tti) && - !srslte_nbiot_ue_dl_is_sib1_sf(q, si_tti / 10, si_tti % 10)) { + if (srsran_ra_nbiot_is_valid_dl_sf(si_tti) && + !srsran_nbiot_ue_dl_is_sib1_sf(q, si_tti / 10, si_tti % 10)) { q->si_tti[si_tti] = true; num_sf--; } @@ -285,7 +285,7 @@ void srslte_nbiot_ue_dl_set_si_params(srslte_nbiot_ue_dl_t* q, } } -bool srslte_nbiot_ue_dl_is_sib1_sf(srslte_nbiot_ue_dl_t* q, uint32_t sfn, uint32_t sf_idx) +bool srsran_nbiot_ue_dl_is_sib1_sf(srsran_nbiot_ue_dl_t* q, uint32_t sfn, uint32_t sf_idx) { bool ret = false; if (sf_idx != 4) @@ -295,7 +295,7 @@ bool srslte_nbiot_ue_dl_is_sib1_sf(srslte_nbiot_ue_dl_t* q, uint32_t sfn, uint32 // TODO: replace linear search for (int i = 0; i < SIB1_NB_MAX_REP * 4; i++) { // every second frame within the next 16 SFN starting at q->sib1_sfn[i] are valid - uint32_t valid_si_sfn = sfn + srslte_ra_nbiot_sib1_start(q->cell.n_id_ncell, &q->mib); + uint32_t valid_si_sfn = sfn + srsran_ra_nbiot_sib1_start(q->cell.n_id_ncell, &q->mib); if ((sfn >= q->sib1_sfn[i]) && (sfn < q->sib1_sfn[i] + 16) && (valid_si_sfn % 2 == 0)) { ret = true; break; @@ -307,15 +307,15 @@ bool srslte_nbiot_ue_dl_is_sib1_sf(srslte_nbiot_ue_dl_t* q, uint32_t sfn, uint32 return ret; } -bool srslte_nbiot_ue_dl_is_si_tti(srslte_nbiot_ue_dl_t* q, uint32_t sfn, uint32_t sf_idx) +bool srsran_nbiot_ue_dl_is_si_tti(srsran_nbiot_ue_dl_t* q, uint32_t sfn, uint32_t sf_idx) { return q->si_tti[sfn * 10 + sf_idx]; } -uint32_t srslte_nbiot_ue_dl_get_next_sib1_start(srslte_nbiot_ue_dl_t* q, uint32_t current_sfn) +uint32_t srsran_nbiot_ue_dl_get_next_sib1_start(srsran_nbiot_ue_dl_t* q, uint32_t current_sfn) { if (q->mib_set) { - uint32_t offset = srslte_ra_nbiot_get_starting_sib1_frame(q->cell.n_id_ncell, &q->mib); + uint32_t offset = srsran_ra_nbiot_get_starting_sib1_frame(q->cell.n_id_ncell, &q->mib); for (int k = 0; k < 4; k++) { uint32_t period = k * SIB1_NB_TTI + offset; if (period > current_sfn) @@ -325,26 +325,26 @@ uint32_t srslte_nbiot_ue_dl_get_next_sib1_start(srslte_nbiot_ue_dl_t* q, uint32_ } else { fprintf(stderr, "Can't compute SIB1 start because MIB-NB not set.\n"); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -void srslte_nbiot_ue_dl_get_sib1_grant(srslte_nbiot_ue_dl_t* q, uint32_t sfn, srslte_ra_nbiot_dl_grant_t* grant) +void srsran_nbiot_ue_dl_get_sib1_grant(srsran_nbiot_ue_dl_t* q, uint32_t sfn, srsran_ra_nbiot_dl_grant_t* grant) { // compute parameter for SIB1 transmissions - srslte_ra_nbiot_dl_dci_t ra_dl_sib1; - bzero(&ra_dl_sib1, sizeof(srslte_ra_nbiot_dl_dci_t)); + srsran_ra_nbiot_dl_dci_t ra_dl_sib1; + bzero(&ra_dl_sib1, sizeof(srsran_ra_nbiot_dl_dci_t)); ra_dl_sib1.alloc.has_sib1 = true; ra_dl_sib1.alloc.sched_info_sib1 = q->mib.sched_info_sib1; - srslte_ra_nbiot_dl_dci_to_grant( - &ra_dl_sib1, grant, srslte_nbiot_ue_dl_get_next_sib1_start(q, sfn), 4, DUMMY_R_MAX, true, q->cell.mode); + srsran_ra_nbiot_dl_dci_to_grant( + &ra_dl_sib1, grant, srsran_nbiot_ue_dl_get_next_sib1_start(q, sfn), 4, DUMMY_R_MAX, true, q->cell.mode); grant->has_sib1 = true; } // Calculate next SIB window as in 5.2.3a in TS 36.331 // TODO: get rid of this brute-force calculation -void srslte_nbiot_ue_dl_get_next_si_sfn(uint32_t current_hfn, +void srsran_nbiot_ue_dl_get_next_si_sfn(uint32_t current_hfn, uint32_t current_sfn, - srslte_nbiot_si_params_t params, + srsran_nbiot_si_params_t params, uint32_t* si_hfn, uint32_t* si_sfn) { @@ -363,14 +363,14 @@ void srslte_nbiot_ue_dl_get_next_si_sfn(uint32_t current_hfn, } } -void srslte_nbiot_ue_dl_get_sib_grant(srslte_nbiot_ue_dl_t* q, +void srsran_nbiot_ue_dl_get_sib_grant(srsran_nbiot_ue_dl_t* q, uint32_t hfn, uint32_t sfn, - srslte_nbiot_si_params_t params, - srslte_ra_nbiot_dl_grant_t* grant) + srsran_nbiot_si_params_t params, + srsran_ra_nbiot_dl_grant_t* grant) { - srslte_ra_nbiot_dl_dci_t si_dci; - bzero(&si_dci, sizeof(srslte_ra_nbiot_dl_dci_t)); + srsran_ra_nbiot_dl_dci_t si_dci; + bzero(&si_dci, sizeof(srsran_ra_nbiot_dl_dci_t)); si_dci.alloc.has_sib1 = false; si_dci.alloc.is_ra = false; @@ -380,39 +380,39 @@ void srslte_nbiot_ue_dl_get_sib_grant(srslte_nbiot_ue_dl_t* q, si_dci.alloc.harq_ack = 1; si_dci.alloc.i_n_start = 0; - srslte_ra_nbiot_dl_dci_to_grant(&si_dci, grant, sfn, sfn % 2, DUMMY_R_MAX, true, q->cell.mode); + srsran_ra_nbiot_dl_dci_to_grant(&si_dci, grant, sfn, sfn % 2, DUMMY_R_MAX, true, q->cell.mode); grant->mcs[0].tbs = params.si_tb; // The TBS is given by SI parameters set in SIB1 - srslte_nbiot_ue_dl_get_next_si_sfn(hfn, sfn, params, &grant->start_hfn, &grant->start_sfn); + srsran_nbiot_ue_dl_get_next_si_sfn(hfn, sfn, params, &grant->start_hfn, &grant->start_sfn); grant->start_sfidx = 1; } -void srslte_nbiot_ue_dl_decode_sib1(srslte_nbiot_ue_dl_t* q, uint32_t current_sfn) +void srsran_nbiot_ue_dl_decode_sib1(srsran_nbiot_ue_dl_t* q, uint32_t current_sfn) { // activate SIB1 grant and configure NPDSCH INFO( - "%d.x: Activated SIB1 decoding in sfn=%d\n", current_sfn, srslte_nbiot_ue_dl_get_next_sib1_start(q, current_sfn)); - srslte_ra_nbiot_dl_grant_t grant; - srslte_nbiot_ue_dl_get_sib1_grant(q, current_sfn, &grant); - srslte_nbiot_ue_dl_set_grant(q, &grant); + "%d.x: Activated SIB1 decoding in sfn=%d\n", current_sfn, srsran_nbiot_ue_dl_get_next_sib1_start(q, current_sfn)); + srsran_ra_nbiot_dl_grant_t grant; + srsran_nbiot_ue_dl_get_sib1_grant(q, current_sfn, &grant); + srsran_nbiot_ue_dl_set_grant(q, &grant); } -void srslte_nbiot_ue_dl_decode_sib(srslte_nbiot_ue_dl_t* q, +void srsran_nbiot_ue_dl_decode_sib(srsran_nbiot_ue_dl_t* q, uint32_t hfn, uint32_t sfn, - srslte_nbiot_si_type_t type, - srslte_nbiot_si_params_t params) + srsran_nbiot_si_type_t type, + srsran_nbiot_si_params_t params) { if (q->has_dl_grant) { INFO("Already processing grant, skipping this."); return; } - if (type == SRSLTE_NBIOT_SI_TYPE_SIB2) { + if (type == SRSRAN_NBIOT_SI_TYPE_SIB2) { assert(params.n == 1); // calculate SIB2 params - srslte_ra_nbiot_dl_grant_t grant; - srslte_nbiot_ue_dl_get_sib_grant(q, hfn, sfn, params, &grant); - srslte_nbiot_ue_dl_set_grant(q, &grant); + srsran_ra_nbiot_dl_grant_t grant; + srsran_nbiot_ue_dl_get_sib_grant(q, hfn, sfn, params, &grant); + srsran_nbiot_ue_dl_set_grant(q, &grant); INFO("%d.x: Activated SIB2 reception in hfn=%d, sfn=%d", sfn, q->npdsch_cfg.grant.start_hfn, @@ -422,20 +422,20 @@ void srslte_nbiot_ue_dl_decode_sib(srslte_nbiot_ue_dl_t* q, } } -void srslte_nbiot_ue_dl_set_grant(srslte_nbiot_ue_dl_t* q, srslte_ra_nbiot_dl_grant_t* grant) +void srsran_nbiot_ue_dl_set_grant(srsran_nbiot_ue_dl_t* q, srsran_ra_nbiot_dl_grant_t* grant) { // configure NPDSCH object - srslte_npdsch_cfg(&q->npdsch_cfg, q->cell, grant, grant->start_sfidx); + srsran_npdsch_cfg(&q->npdsch_cfg, q->cell, grant, grant->start_sfidx); q->has_dl_grant = true; } -void srslte_nbiot_ue_dl_flush_grant(srslte_nbiot_ue_dl_t* q) +void srsran_nbiot_ue_dl_flush_grant(srsran_nbiot_ue_dl_t* q) { - bzero(&q->npdsch_cfg, sizeof(srslte_npdsch_cfg_t)); + bzero(&q->npdsch_cfg, sizeof(srsran_npdsch_cfg_t)); q->has_dl_grant = false; } -bool srslte_nbiot_ue_dl_has_grant(srslte_nbiot_ue_dl_t* q) +bool srsran_nbiot_ue_dl_has_grant(srsran_nbiot_ue_dl_t* q) { return q->has_dl_grant; } @@ -447,11 +447,11 @@ bool srslte_nbiot_ue_dl_has_grant(srslte_nbiot_ue_dl_t* q) * \param q pointer to the UE DL object * \param grant the DL grant to check */ -void srslte_nbiot_ue_dl_check_grant(srslte_nbiot_ue_dl_t* q, srslte_ra_nbiot_dl_grant_t* grant) +void srsran_nbiot_ue_dl_check_grant(srsran_nbiot_ue_dl_t* q, srsran_ra_nbiot_dl_grant_t* grant) { // make sure NPDSCH start is not on a SI subframe - while (srslte_nbiot_ue_dl_is_si_tti(q, grant->start_sfn, grant->start_sfidx) || - !srslte_ra_nbiot_is_valid_dl_sf(grant->start_sfn * 10 + grant->start_sfidx)) { + while (srsran_nbiot_ue_dl_is_si_tti(q, grant->start_sfn, grant->start_sfidx) || + !srsran_ra_nbiot_is_valid_dl_sf(grant->start_sfn * 10 + grant->start_sfidx)) { grant->start_sfidx++; if (grant->start_sfidx == 10) { grant->start_sfidx = 0; @@ -463,39 +463,39 @@ void srslte_nbiot_ue_dl_check_grant(srslte_nbiot_ue_dl_t* q, srslte_ra_nbiot_dl_ /* Precalculate the NPDSCH scramble sequences for a given RNTI. This function takes a while * to execute, so shall be called once the final C-RNTI has been allocated for the session. */ -void srslte_nbiot_ue_dl_set_rnti(srslte_nbiot_ue_dl_t* q, uint16_t rnti) +void srsran_nbiot_ue_dl_set_rnti(srsran_nbiot_ue_dl_t* q, uint16_t rnti) { - srslte_npdsch_set_rnti(&q->npdsch, rnti); + srsran_npdsch_set_rnti(&q->npdsch, rnti); q->current_rnti = rnti; } -void srslte_nbiot_ue_dl_reset(srslte_nbiot_ue_dl_t* q) +void srsran_nbiot_ue_dl_reset(srsran_nbiot_ue_dl_t* q) { - srslte_softbuffer_rx_reset(&q->softbuffer); - bzero(&q->npdsch_cfg, sizeof(srslte_npdsch_cfg_t)); + srsran_softbuffer_rx_reset(&q->softbuffer); + bzero(&q->npdsch_cfg, sizeof(srsran_npdsch_cfg_t)); } -void srslte_nbiot_ue_dl_set_sample_offset(srslte_nbiot_ue_dl_t* q, float sample_offset) +void srsran_nbiot_ue_dl_set_sample_offset(srsran_nbiot_ue_dl_t* q, float sample_offset) { q->sample_offset = sample_offset; } -int srslte_nbiot_ue_dl_decode_fft_estimate(srslte_nbiot_ue_dl_t* q, uint32_t sf_idx, bool is_dl_sf) +int srsran_nbiot_ue_dl_decode_fft_estimate(srsran_nbiot_ue_dl_t* q, uint32_t sf_idx, bool is_dl_sf) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; - if (q != NULL && sf_idx < SRSLTE_NOF_SF_X_FRAME) { - ret = SRSLTE_ERROR; + if (q != NULL && sf_idx < SRSRAN_NOF_SF_X_FRAME) { + ret = SRSRAN_ERROR; // Run FFT for all subframe data - srslte_ofdm_rx_sf(&q->fft); + srsran_ofdm_rx_sf(&q->fft); // Correct SFO multiplying by complex exponential in the time domain if (q->sample_offset) { - for (int i = 0; i < 2 * SRSLTE_CP_NSYMB(q->cell.base.cp); i++) { - srslte_cfo_correct(&q->sfo_correct, - &q->sf_symbols[i * q->cell.base.nof_prb * SRSLTE_NRE], - &q->sf_symbols[i * q->cell.base.nof_prb * SRSLTE_NRE], + for (int i = 0; i < 2 * SRSRAN_CP_NSYMB(q->cell.base.cp); i++) { + srsran_cfo_correct(&q->sfo_correct, + &q->sf_symbols[i * q->cell.base.nof_prb * SRSRAN_NRE], + &q->sf_symbols[i * q->cell.base.nof_prb * SRSRAN_NRE], q->sample_offset / q->fft.cfg.symbol_sz); } } @@ -503,59 +503,59 @@ int srslte_nbiot_ue_dl_decode_fft_estimate(srslte_nbiot_ue_dl_t* q, uint32_t sf_ bool sf_has_nrs = false; if (q->cell.nof_ports == 0) { - sf_has_nrs = srslte_ra_nbiot_dl_has_ref_signal(sf_idx); - } else if (q->cell.mode == SRSLTE_NBIOT_MODE_STANDALONE || q->cell.mode == SRSLTE_NBIOT_MODE_GUARDBAND) { + sf_has_nrs = srsran_ra_nbiot_dl_has_ref_signal(sf_idx); + } else if (q->cell.mode == SRSRAN_NBIOT_MODE_STANDALONE || q->cell.mode == SRSRAN_NBIOT_MODE_GUARDBAND) { // TODO: differentiate between before and after SIB reception - sf_has_nrs = srslte_ra_nbiot_dl_has_ref_signal_standalone(sf_idx); + sf_has_nrs = srsran_ra_nbiot_dl_has_ref_signal_standalone(sf_idx); } else { - sf_has_nrs = srslte_ra_nbiot_dl_has_ref_signal_inband(sf_idx); + sf_has_nrs = srsran_ra_nbiot_dl_has_ref_signal_inband(sf_idx); } if (sf_has_nrs || is_dl_sf) { assert(sf_idx != 5); - ret = srslte_nbiot_ue_dl_decode_estimate(q, sf_idx); + ret = srsran_nbiot_ue_dl_decode_estimate(q, sf_idx); } else { - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } } return ret; } -int srslte_nbiot_ue_dl_decode_estimate(srslte_nbiot_ue_dl_t* q, uint32_t sf_idx) +int srsran_nbiot_ue_dl_decode_estimate(srsran_nbiot_ue_dl_t* q, uint32_t sf_idx) { - if (q && sf_idx < SRSLTE_NOF_SF_X_FRAME) { + if (q && sf_idx < SRSRAN_NOF_SF_X_FRAME) { // Get channel estimates for each port - srslte_chest_dl_nbiot_estimate(&q->chest, q->sf_symbols, q->ce, sf_idx); - return SRSLTE_SUCCESS; + srsran_chest_dl_nbiot_estimate(&q->chest, q->sf_symbols, q->ce, sf_idx); + return SRSRAN_SUCCESS; } else { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } } -int srslte_nbiot_ue_dl_decode_rnti_packet(srslte_nbiot_ue_dl_t* q, - srslte_ra_nbiot_dl_grant_t* grant, +int srsran_nbiot_ue_dl_decode_rnti_packet(srsran_nbiot_ue_dl_t* q, + srsran_ra_nbiot_dl_grant_t* grant, uint8_t* data, uint32_t sfn, uint32_t sf_idx, uint16_t rnti, cf_t* symbols, - cf_t* ce[SRSLTE_MAX_PORTS], + cf_t* ce[SRSRAN_MAX_PORTS], uint32_t rep_counter) { // Uncomment next line to do ZF by default // float noise_estimate = 0; - float noise_estimate = srslte_chest_dl_nbiot_get_noise_estimate(&q->chest); - return srslte_npdsch_decode_rnti( + float noise_estimate = srsran_chest_dl_nbiot_get_noise_estimate(&q->chest); + return srsran_npdsch_decode_rnti( &q->npdsch, &q->npdsch_cfg, &q->softbuffer, symbols, ce, noise_estimate, rnti, sfn, data, rep_counter); } -void srslte_nbiot_ue_dl_tb_decoded(srslte_nbiot_ue_dl_t* q, uint8_t* data) +void srsran_nbiot_ue_dl_tb_decoded(srsran_nbiot_ue_dl_t* q, uint8_t* data) { // print decoded message - if (SRSLTE_VERBOSE_ISINFO()) { + if (SRSRAN_VERBOSE_ISINFO()) { INFO("Decoded Message: "); - srslte_vec_fprint_byte(stdout, data, q->npdsch_cfg.grant.mcs[0].tbs / 8); + srsran_vec_fprint_byte(stdout, data, q->npdsch_cfg.grant.mcs[0].tbs / 8); } // do book-keeping q->pkts_ok++; @@ -565,43 +565,43 @@ void srslte_nbiot_ue_dl_tb_decoded(srslte_nbiot_ue_dl_t* q, uint8_t* data) q->has_dl_grant = false; } -uint32_t srslte_nbiot_ue_dl_get_ncce(srslte_nbiot_ue_dl_t* q) +uint32_t srsran_nbiot_ue_dl_get_ncce(srsran_nbiot_ue_dl_t* q) { return q->last_n_cce; } -#define SRSLTE_MAX_CANDIDATES_UE 3 // From 36.213 Table 16.6-1 NPDCCH Format0 and NPDCCH Format1 -#define SRSLTE_MAX_CANDIDATES_COM \ +#define SRSRAN_MAX_CANDIDATES_UE 3 // From 36.213 Table 16.6-1 NPDCCH Format0 and NPDCCH Format1 +#define SRSRAN_MAX_CANDIDATES_COM \ 1 // From 36.213 Table 16.6-2 and Table 16.6-3, only AL2 is defined here which uses NPDCCH Format1 -#define SRSLTE_MAX_CANDIDATES (SRSLTE_MAX_CANDIDATES_UE + SRSLTE_MAX_CANDIDATES_COM) +#define SRSRAN_MAX_CANDIDATES (SRSRAN_MAX_CANDIDATES_UE + SRSRAN_MAX_CANDIDATES_COM) typedef struct { - srslte_dci_format_t format; - srslte_dci_location_t loc[SRSLTE_MAX_CANDIDATES]; + srsran_dci_format_t format; + srsran_dci_location_t loc[SRSRAN_MAX_CANDIDATES]; uint32_t nof_locations; } dci_blind_search_t; static int -dci_blind_search(srslte_nbiot_ue_dl_t* q, dci_blind_search_t* search_space, uint16_t rnti, srslte_dci_msg_t* dci_msg) +dci_blind_search(srsran_nbiot_ue_dl_t* q, dci_blind_search_t* search_space, uint16_t rnti, srsran_dci_msg_t* dci_msg) { - int ret = SRSLTE_ERROR; + int ret = SRSRAN_ERROR; uint16_t crc_rem = 0; if (rnti) { ret = 0; int i = 0; while (!ret && i < search_space->nof_locations) { DEBUG("Searching format %s in %d,%d", - srslte_dci_format_string(search_space->format), + srsran_dci_format_string(search_space->format), search_space->loc[i].ncce, search_space->loc[i].L); - if (srslte_npdcch_decode_msg(&q->npdcch, dci_msg, &search_space->loc[i], search_space->format, &crc_rem)) { + if (srsran_npdcch_decode_msg(&q->npdcch, dci_msg, &search_space->loc[i], search_space->format, &crc_rem)) { fprintf(stderr, "Error decoding DCI msg\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (crc_rem == rnti) { if (dci_msg->format == search_space->format) { ret = 1; - memcpy(&q->last_location, &search_space->loc[i], sizeof(srslte_dci_location_t)); + memcpy(&q->last_location, &search_space->loc[i], sizeof(srsran_dci_location_t)); } } i++; @@ -612,23 +612,23 @@ dci_blind_search(srslte_nbiot_ue_dl_t* q, dci_blind_search_t* search_space, uint return ret; } -int srslte_nbiot_ue_dl_find_dl_dci(srslte_nbiot_ue_dl_t* q, uint32_t sf_idx, uint16_t rnti, srslte_dci_msg_t* dci_msg) +int srsran_nbiot_ue_dl_find_dl_dci(srsran_nbiot_ue_dl_t* q, uint32_t sf_idx, uint16_t rnti, srsran_dci_msg_t* dci_msg) { - if (rnti == SRSLTE_SIRNTI || rnti == SRSLTE_PRNTI || SRSLTE_RNTI_ISRAR(rnti)) { - return srslte_nbiot_ue_dl_find_dl_dci_type_siprarnti(q, rnti, dci_msg); + if (rnti == SRSRAN_SIRNTI || rnti == SRSRAN_PRNTI || SRSRAN_RNTI_ISRAR(rnti)) { + return srsran_nbiot_ue_dl_find_dl_dci_type_siprarnti(q, rnti, dci_msg); } else { - return srslte_nbiot_ue_dl_find_dl_dci_type_crnti(q, sf_idx, rnti, dci_msg); + return srsran_nbiot_ue_dl_find_dl_dci_type_crnti(q, sf_idx, rnti, dci_msg); } } // Blind search for SI/P/RA-RNTI -int srslte_nbiot_ue_dl_find_dl_dci_type_siprarnti(srslte_nbiot_ue_dl_t* q, uint16_t rnti, srslte_dci_msg_t* dci_msg) +int srsran_nbiot_ue_dl_find_dl_dci_type_siprarnti(srsran_nbiot_ue_dl_t* q, uint16_t rnti, srsran_dci_msg_t* dci_msg) { - int ret = SRSLTE_SUCCESS; + int ret = SRSRAN_SUCCESS; // Configure and run DCI blind search dci_blind_search_t search_space; - search_space.nof_locations = srslte_npdcch_common_locations(search_space.loc, SRSLTE_MAX_CANDIDATES_COM); + search_space.nof_locations = srsran_npdcch_common_locations(search_space.loc, SRSRAN_MAX_CANDIDATES_COM); DEBUG("Searching SI/P/RA-RNTI in %d common locations, %d formats", search_space.nof_locations, nb_nof_common_formats); // Search for RNTI only if there is room for the common search space if (search_space.nof_locations > 0) { @@ -639,20 +639,20 @@ int srslte_nbiot_ue_dl_find_dl_dci_type_siprarnti(srslte_nbiot_ue_dl_t* q, uint1 } } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Blind search for C-RNTI -int srslte_nbiot_ue_dl_find_dl_dci_type_crnti(srslte_nbiot_ue_dl_t* q, +int srsran_nbiot_ue_dl_find_dl_dci_type_crnti(srsran_nbiot_ue_dl_t* q, uint32_t sf_idx, uint16_t rnti, - srslte_dci_msg_t* dci_msg) + srsran_dci_msg_t* dci_msg) { - int ret = SRSLTE_SUCCESS; + int ret = SRSRAN_SUCCESS; // Search UE-specific search space dci_blind_search_t search_space; - search_space.nof_locations = srslte_npdcch_ue_locations(search_space.loc, SRSLTE_MAX_CANDIDATES_UE); + search_space.nof_locations = srsran_npdcch_ue_locations(search_space.loc, SRSRAN_MAX_CANDIDATES_UE); DEBUG("x.%d: Searching DL C-RNTI=0x%x in %d locations, %d formats", sf_idx, rnti, @@ -670,33 +670,33 @@ int srslte_nbiot_ue_dl_find_dl_dci_type_crnti(srslte_nbiot_ue_dl_t* q, /** Attempts to decode NPDSCH with pre-configured grant * - It does not decode SIBs if no explicit grant is present */ -int srslte_nbiot_ue_dl_decode_npdsch(srslte_nbiot_ue_dl_t* q, +int srsran_nbiot_ue_dl_decode_npdsch(srsran_nbiot_ue_dl_t* q, cf_t* input, uint8_t* data, uint32_t sfn, uint32_t sf_idx, uint16_t rnti) { - int ret = SRSLTE_ERROR; + int ret = SRSRAN_ERROR; // skip subframe without grant and if it's not a valid downlink subframe - if (q->has_dl_grant == false || srslte_ra_nbiot_is_valid_dl_sf(sfn * 10 + sf_idx) == false) { + if (q->has_dl_grant == false || srsran_ra_nbiot_is_valid_dl_sf(sfn * 10 + sf_idx) == false) { DEBUG("%d.%d: Skipping NPDSCH processing.", sfn, sf_idx); - return SRSLTE_NBIOT_UE_DL_SKIP_SF; + return SRSRAN_NBIOT_UE_DL_SKIP_SF; } // run FFT and estimate channel DEBUG("%d.%d: Estimating channel.", sfn, sf_idx); - if ((srslte_nbiot_ue_dl_decode_fft_estimate(q, sf_idx, true)) < 0) { + if ((srsran_nbiot_ue_dl_decode_fft_estimate(q, sf_idx, true)) < 0) { return ret; } // skip SIB1 sub-frames - if (srslte_nbiot_ue_dl_is_sib1_sf(q, sfn, sf_idx) && q->has_dl_grant) { + if (srsran_nbiot_ue_dl_is_sib1_sf(q, sfn, sf_idx) && q->has_dl_grant) { if (q->npdsch_cfg.grant.has_sib1 == false) { // skip SIB1 decoding if grant is being processed DEBUG("%d.%d: Skipping SIB1 due to ongoing DL reception.", sfn, sf_idx); - return SRSLTE_NBIOT_EXPECT_MORE_SF; + return SRSRAN_NBIOT_EXPECT_MORE_SF; } } @@ -709,13 +709,13 @@ int srslte_nbiot_ue_dl_decode_npdsch(srslte_nbiot_ue_dl_t* q, // handle actual reception if (q->npdsch_cfg.has_bcch) { - ret = srslte_nbiot_ue_dl_decode_npdsch_bcch(q, data, sfn * 10 + sf_idx); + ret = srsran_nbiot_ue_dl_decode_npdsch_bcch(q, data, sfn * 10 + sf_idx); } else { - ret = srslte_nbiot_ue_dl_decode_npdsch_no_bcch(q, data, sfn * 10 + sf_idx, rnti); + ret = srsran_nbiot_ue_dl_decode_npdsch_no_bcch(q, data, sfn * 10 + sf_idx, rnti); } } else { DEBUG("%d.%d: WARNING: DL grant still active. Possibly needs to be deactivated.", sfn, sf_idx); - ret = SRSLTE_NBIOT_UE_DL_SKIP_SF; + ret = SRSRAN_NBIOT_UE_DL_SKIP_SF; } return ret; @@ -724,11 +724,11 @@ int srslte_nbiot_ue_dl_decode_npdsch(srslte_nbiot_ue_dl_t* q, /** Handles subframe reception of a NPDSCH which doesn't carry the BCCH * - In this NPDSCH config, up to four repetitons are transmitted one after another */ -int srslte_nbiot_ue_dl_decode_npdsch_no_bcch(srslte_nbiot_ue_dl_t* q, uint8_t* data, uint32_t tti, uint16_t rnti) +int srsran_nbiot_ue_dl_decode_npdsch_no_bcch(srsran_nbiot_ue_dl_t* q, uint8_t* data, uint32_t tti, uint16_t rnti) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; - if (q->npdsch_cfg.sf_idx >= SRSLTE_NPDSCH_MAX_NOF_SF) { + if (q->npdsch_cfg.sf_idx >= SRSRAN_NPDSCH_MAX_NOF_SF) { ERROR("Invalid npdsch_cfg.sf_idx=%d", q->npdsch_cfg.sf_idx); return ret; } @@ -745,36 +745,36 @@ int srslte_nbiot_ue_dl_decode_npdsch_no_bcch(srslte_nbiot_ue_dl_t* q, uint8_t* d if (q->npdsch_cfg.num_sf % q->npdsch_cfg.grant.nof_rep == 0) { // copy data and ce symbols for first repetition of each subframe - srslte_vec_cf_copy(&q->sf_buffer[q->npdsch_cfg.sf_idx * q->nof_re], q->sf_symbols, q->nof_re); + srsran_vec_cf_copy(&q->sf_buffer[q->npdsch_cfg.sf_idx * q->nof_re], q->sf_symbols, q->nof_re); for (int i = 0; i < q->cell.nof_ports; i++) { - srslte_vec_cf_copy(&q->ce_buffer[i][q->npdsch_cfg.sf_idx * q->nof_re], q->ce[i], q->nof_re); + srsran_vec_cf_copy(&q->ce_buffer[i][q->npdsch_cfg.sf_idx * q->nof_re], q->ce[i], q->nof_re); } } else { // accumulate subframe samples and channel estimates - srslte_vec_sum_ccc(&q->sf_buffer[q->npdsch_cfg.sf_idx * q->nof_re], + srsran_vec_sum_ccc(&q->sf_buffer[q->npdsch_cfg.sf_idx * q->nof_re], q->sf_symbols, &q->sf_buffer[q->npdsch_cfg.sf_idx * q->nof_re], q->nof_re); for (int i = 0; i < q->cell.nof_ports; i++) { - srslte_vec_sum_ccc(&q->ce_buffer[i][q->npdsch_cfg.sf_idx * q->nof_re], + srsran_vec_sum_ccc(&q->ce_buffer[i][q->npdsch_cfg.sf_idx * q->nof_re], q->ce[i], &q->ce_buffer[i][q->npdsch_cfg.sf_idx * q->nof_re], q->nof_re); } } q->npdsch_cfg.num_sf++; - // srslte_nbiot_ue_dl_save_signal(q, input, sfn, sf_idx); + // srsran_nbiot_ue_dl_save_signal(q, input, sfn, sf_idx); q->npdsch_cfg.rep_idx++; - int m = SRSLTE_MIN(q->npdsch_cfg.grant.nof_rep, 4); + int m = SRSRAN_MIN(q->npdsch_cfg.grant.nof_rep, 4); if (q->npdsch_cfg.rep_idx % m == 0) { // average accumulated samples - srslte_vec_sc_prod_ccc(&q->sf_buffer[q->npdsch_cfg.sf_idx * q->nof_re], + srsran_vec_sc_prod_ccc(&q->sf_buffer[q->npdsch_cfg.sf_idx * q->nof_re], 1.0 / m, &q->sf_buffer[q->npdsch_cfg.sf_idx * q->nof_re], q->nof_re); for (int i = 0; i < q->cell.nof_ports; i++) { - srslte_vec_sc_prod_ccc(&q->ce_buffer[i][q->npdsch_cfg.sf_idx * q->nof_re], + srsran_vec_sc_prod_ccc(&q->ce_buffer[i][q->npdsch_cfg.sf_idx * q->nof_re], 1.0 / m, &q->ce_buffer[i][q->npdsch_cfg.sf_idx * q->nof_re], q->nof_re); @@ -791,7 +791,7 @@ int srslte_nbiot_ue_dl_decode_npdsch_no_bcch(srslte_nbiot_ue_dl_t* q, uint8_t* d if (q->npdsch_cfg.num_sf == q->npdsch_cfg.grant.nof_sf * q->npdsch_cfg.grant.nof_rep) { // try to decode NPDSCH INFO("%d.%d: Trying to decode NPDSCH with %d subframe(s).", tti / 10, tti % 10, q->npdsch_cfg.grant.nof_sf); - if (srslte_nbiot_ue_dl_decode_rnti_packet(q, + if (srsran_nbiot_ue_dl_decode_rnti_packet(q, &q->npdsch_cfg.grant, data, tti / 10, @@ -799,22 +799,22 @@ int srslte_nbiot_ue_dl_decode_npdsch_no_bcch(srslte_nbiot_ue_dl_t* q, uint8_t* d rnti, q->sf_buffer, q->ce_buffer, - q->npdsch_cfg.rep_idx) != SRSLTE_SUCCESS) { + q->npdsch_cfg.rep_idx) != SRSRAN_SUCCESS) { // decoding failed INFO("%d.%d: Error decoding NPDSCH with %d repetitions.", tti / 10, tti % 10, q->npdsch_cfg.rep_idx); q->pkt_errors++; q->has_dl_grant = false; - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } else { - srslte_nbiot_ue_dl_tb_decoded(q, data); - ret = SRSLTE_SUCCESS; + srsran_nbiot_ue_dl_tb_decoded(q, data); + ret = SRSRAN_SUCCESS; } } else { DEBUG("%d.%d: Waiting for %d more subframes.", tti / 10, tti % 10, q->npdsch_cfg.grant.nof_sf * q->npdsch_cfg.grant.nof_rep - q->npdsch_cfg.num_sf); - ret = SRSLTE_NBIOT_EXPECT_MORE_SF; + ret = SRSRAN_NBIOT_EXPECT_MORE_SF; } return ret; } @@ -823,14 +823,14 @@ int srslte_nbiot_ue_dl_decode_npdsch_no_bcch(srslte_nbiot_ue_dl_t* q, uint8_t* d * - According to TS36.211 Section 10.2.3.4 for NPDSCH carrying BCCH, all SF are * transmitted in sequence before repetions are transmitted */ -int srslte_nbiot_ue_dl_decode_npdsch_bcch(srslte_nbiot_ue_dl_t* q, uint8_t* data, uint32_t tti) +int srsran_nbiot_ue_dl_decode_npdsch_bcch(srsran_nbiot_ue_dl_t* q, uint8_t* data, uint32_t tti) { - int ret = SRSLTE_NBIOT_EXPECT_MORE_SF; + int ret = SRSRAN_NBIOT_EXPECT_MORE_SF; // TODO: this only captures SIB1, not other SIBs // only subframe 4 of every second frame is an SIB1 // make sure we also look on odd SFNs (if n_rep=16 and n_id_ncell%2=1) - uint32_t valid_si_sfn = tti / 10 + srslte_ra_nbiot_sib1_start(q->cell.n_id_ncell, &q->mib); + uint32_t valid_si_sfn = tti / 10 + srsran_ra_nbiot_sib1_start(q->cell.n_id_ncell, &q->mib); if (valid_si_sfn % 2 == 0 && tti % 10 == 4) { INFO("%d.%d: NPDSCH processing sf_idx=%d/%d rep=%d/%d tot=%d/%d", tti / 10, @@ -843,9 +843,9 @@ int srslte_nbiot_ue_dl_decode_npdsch_bcch(srslte_nbiot_ue_dl_t* q, uint8_t* data q->npdsch_cfg.grant.nof_sf * q->npdsch_cfg.grant.nof_rep); // copy data and ce symbols - srslte_vec_cf_copy(&q->sf_buffer[q->npdsch_cfg.sf_idx * q->nof_re], q->sf_symbols, q->nof_re); + srsran_vec_cf_copy(&q->sf_buffer[q->npdsch_cfg.sf_idx * q->nof_re], q->sf_symbols, q->nof_re); for (int i = 0; i < q->cell.nof_ports; i++) { - srslte_vec_cf_copy(&q->ce_buffer[i][q->npdsch_cfg.sf_idx * q->nof_re], q->ce[i], q->nof_re); + srsran_vec_cf_copy(&q->ce_buffer[i][q->npdsch_cfg.sf_idx * q->nof_re], q->ce[i], q->nof_re); } q->npdsch_cfg.num_sf++; q->npdsch_cfg.sf_idx++; @@ -854,22 +854,22 @@ int srslte_nbiot_ue_dl_decode_npdsch_bcch(srslte_nbiot_ue_dl_t* q, uint8_t* data if (q->npdsch_cfg.num_sf % q->npdsch_cfg.grant.nof_sf == 0) { // try to decode NPDSCH INFO("%d.%d: Trying to decode NPDSCH with %d subframe(s).", tti / 10, tti % 10, q->npdsch_cfg.grant.nof_sf); - if (srslte_nbiot_ue_dl_decode_rnti_packet(q, + if (srsran_nbiot_ue_dl_decode_rnti_packet(q, &q->npdsch_cfg.grant, data, tti / 10, tti % 10, - SRSLTE_SIRNTI, + SRSRAN_SIRNTI, q->sf_buffer, q->ce_buffer, - q->npdsch_cfg.rep_idx) != SRSLTE_SUCCESS) { + q->npdsch_cfg.rep_idx) != SRSRAN_SUCCESS) { // decoding failed, check for possible repetitions if (q->npdsch_cfg.rep_idx == 0) { // store soft-bits of first repetition - srslte_vec_f_copy(q->llr, q->npdsch.llr, q->npdsch_cfg.grant.nof_sf * q->npdsch_cfg.nbits.nof_bits); + srsran_vec_f_copy(q->llr, q->npdsch.llr, q->npdsch_cfg.grant.nof_sf * q->npdsch_cfg.nbits.nof_bits); } else { INFO("Soft-combining NPDSCH repetition %d", q->npdsch_cfg.rep_idx); - srslte_vec_sum_fff(q->llr, q->npdsch.llr, q->llr, q->npdsch_cfg.grant.nof_sf * q->npdsch_cfg.nbits.nof_bits); + srsran_vec_sum_fff(q->llr, q->npdsch.llr, q->llr, q->npdsch_cfg.grant.nof_sf * q->npdsch_cfg.nbits.nof_bits); // try to decode combined soft-bits INFO("%d.%d: Trying to decode NPDSCH with %d subframe(s) after %d repetitions.", @@ -878,13 +878,13 @@ int srslte_nbiot_ue_dl_decode_npdsch_bcch(srslte_nbiot_ue_dl_t* q, uint8_t* data q->npdsch_cfg.grant.nof_sf, q->npdsch_cfg.rep_idx); - if (srslte_npdsch_rm_and_decode(&q->npdsch, &q->npdsch_cfg, q->llr, data) == SRSLTE_SUCCESS) { + if (srsran_npdsch_rm_and_decode(&q->npdsch, &q->npdsch_cfg, q->llr, data) == SRSRAN_SUCCESS) { // frame decoded ok after one or more repetitions - srslte_nbiot_ue_dl_tb_decoded(q, data); + srsran_nbiot_ue_dl_tb_decoded(q, data); q->has_dl_grant = false; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } else { - ret = SRSLTE_NBIOT_EXPECT_MORE_SF; + ret = SRSRAN_NBIOT_EXPECT_MORE_SF; } } @@ -894,21 +894,21 @@ int srslte_nbiot_ue_dl_decode_npdsch_bcch(srslte_nbiot_ue_dl_t* q, uint8_t* data if (q->npdsch_cfg.rep_idx < q->npdsch_cfg.grant.nof_rep) { DEBUG("%d.%d: Couldn't decode NPDSCH, waiting for next repetition", tti / 10, tti % 10); - ret = SRSLTE_NBIOT_EXPECT_MORE_SF; + ret = SRSRAN_NBIOT_EXPECT_MORE_SF; } else { INFO("%d.%d: Error decoding NPDSCH with %d repetitions.", tti / 10, tti % 10, q->npdsch_cfg.rep_idx); - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; q->pkt_errors++; // count as error after all repetitons failed q->has_dl_grant = false; } } else { // frame decoded ok after first transmission - srslte_nbiot_ue_dl_tb_decoded(q, data); - return SRSLTE_SUCCESS; + srsran_nbiot_ue_dl_tb_decoded(q, data); + return SRSRAN_SUCCESS; } } else { DEBUG("%d.%d: Waiting for more subframes.", tti / 10, tti % 10); - ret = SRSLTE_NBIOT_EXPECT_MORE_SF; + ret = SRSRAN_NBIOT_EXPECT_MORE_SF; } } return ret; @@ -919,52 +919,52 @@ int srslte_nbiot_ue_dl_decode_npdsch_bcch(srslte_nbiot_ue_dl_t* q, uint8_t* data * - Channel estimation (only for subframes containing NRS) * - NPDCCH decoding: Find DCI for RNTI given by rnti paramter */ -int srslte_nbiot_ue_dl_decode_npdcch(srslte_nbiot_ue_dl_t* q, +int srsran_nbiot_ue_dl_decode_npdcch(srsran_nbiot_ue_dl_t* q, cf_t* input, uint32_t sfn, uint32_t sf_idx, uint16_t rnti, - srslte_dci_msg_t* dci_msg) + srsran_dci_msg_t* dci_msg) { - int ret = SRSLTE_ERROR; + int ret = SRSRAN_ERROR; // skip subframe with grant and if it's not a valid downlink subframe - if (q->has_dl_grant || srslte_ra_nbiot_is_valid_dl_sf(sfn * 10 + sf_idx) == false) { + if (q->has_dl_grant || srsran_ra_nbiot_is_valid_dl_sf(sfn * 10 + sf_idx) == false) { DEBUG("%d.%d: Skipping NPDCCH processing.", sfn, sf_idx); return ret; } // run FFT and estimate channel DEBUG("%d.%d: Estimating channel.", sfn, sf_idx); - if ((srslte_nbiot_ue_dl_decode_fft_estimate(q, sf_idx, true)) < 0) { + if ((srsran_nbiot_ue_dl_decode_fft_estimate(q, sf_idx, true)) < 0) { return ret; } // handle SI sub-frames - if (srslte_nbiot_ue_dl_is_si_tti(q, sfn, sf_idx) && q->has_dl_grant) { + if (srsran_nbiot_ue_dl_is_si_tti(q, sfn, sf_idx) && q->has_dl_grant) { if (q->npdsch_cfg.grant.has_sib1 == false) { // skip SI decoding if grant is being processed DEBUG("%d.%d: Skipping SI SF due to ongoing DL reception.", sfn, sf_idx); - return SRSLTE_NBIOT_EXPECT_MORE_SF; + return SRSRAN_NBIOT_EXPECT_MORE_SF; } } // If no grant is present, try to decode NPDCCH - float noise_est = srslte_chest_dl_nbiot_get_noise_estimate(&q->chest); - if (srslte_npdcch_extract_llr(&q->npdcch, q->sf_symbols, q->ce, noise_est, sf_idx)) { + float noise_est = srsran_chest_dl_nbiot_get_noise_estimate(&q->chest); + if (srsran_npdcch_extract_llr(&q->npdcch, q->sf_symbols, q->ce, noise_est, sf_idx)) { fprintf(stderr, "Error extracting LLRs\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } DEBUG("%d.%d: Looking for DCI for RNTI=0x%x.", sfn, sf_idx, rnti); - if (srslte_nbiot_ue_dl_find_dl_dci(q, sf_idx, rnti, dci_msg) == 1) { + if (srsran_nbiot_ue_dl_find_dl_dci(q, sf_idx, rnti, dci_msg) == 1) { // a DCI was found INFO("%d.%d: Found DCI for RNTI=0x%x.", sfn, sf_idx, rnti); q->nof_detected++; - ret = SRSLTE_NBIOT_UE_DL_FOUND_DCI; + ret = SRSRAN_NBIOT_UE_DL_FOUND_DCI; } #if DUMP_SIGNALS - srslte_nbiot_ue_dl_save_signal(q, input, sfn, sf_idx); + srsran_nbiot_ue_dl_save_signal(q, input, sfn, sf_idx); #endif return ret; @@ -972,14 +972,14 @@ int srslte_nbiot_ue_dl_decode_npdcch(srslte_nbiot_ue_dl_t* q, // This funtion searches for UL DCI's, i.e., Format N0, for a given RNTI // assuming that the equalized subframe symbols are already stored in the DL object, -// i.e. srslte_nbiot_ue_dl_decode_npdcch() needs to be called before -int srslte_nbiot_ue_dl_find_ul_dci(srslte_nbiot_ue_dl_t* q, uint32_t tti, uint32_t rnti, srslte_dci_msg_t* dci_msg) +// i.e. srsran_nbiot_ue_dl_decode_npdcch() needs to be called before +int srsran_nbiot_ue_dl_find_ul_dci(srsran_nbiot_ue_dl_t* q, uint32_t tti, uint32_t rnti, srsran_dci_msg_t* dci_msg) { DEBUG("%d.%d: Looking for UL DCI for RNTI=0x%x.", tti / 10, tti % 10, rnti); // Search UE-specific search space dci_blind_search_t search_space; - search_space.nof_locations = srslte_npdcch_ue_locations(search_space.loc, SRSLTE_MAX_CANDIDATES_UE); + search_space.nof_locations = srsran_npdcch_ue_locations(search_space.loc, SRSRAN_MAX_CANDIDATES_UE); DEBUG("x.%d: Searching UL C-RNTI=0x%x in %d locations, %d formats", tti % 10, rnti, @@ -989,51 +989,51 @@ int srslte_nbiot_ue_dl_find_ul_dci(srslte_nbiot_ue_dl_t* q, uint32_t tti, uint32 search_space.format = nb_ue_formats[f]; if ((dci_blind_search(q, &search_space, rnti, dci_msg)) == 1) { q->nof_detected++; - return SRSLTE_NBIOT_UE_DL_FOUND_DCI; + return SRSRAN_NBIOT_UE_DL_FOUND_DCI; } } - return SRSLTE_ERROR; + return SRSRAN_ERROR; } -void srslte_nbiot_ue_dl_save_signal(srslte_nbiot_ue_dl_t* q, cf_t* input, uint32_t sfn, uint32_t sf_idx) +void srsran_nbiot_ue_dl_save_signal(srsran_nbiot_ue_dl_t* q, cf_t* input, uint32_t sfn, uint32_t sf_idx) { - uint32_t num_symbols = SRSLTE_SF_LEN(SRSLTE_NBIOT_FFT_SIZE); + uint32_t num_symbols = SRSRAN_SF_LEN(SRSRAN_NBIOT_FFT_SIZE); #define MAX_FNAME_LEN 50 char fname[MAX_FNAME_LEN]; // RAW samples snprintf(fname, MAX_FNAME_LEN, "nb_ue_dl_sfn%d_sf%d_raw_samples.bin", sfn, sf_idx); DEBUG("SAVED FILE %s: rx'ed samples", fname); - srslte_vec_save_file(fname, input, num_symbols * sizeof(cf_t)); + srsran_vec_save_file(fname, input, num_symbols * sizeof(cf_t)); // NPDCCH num_symbols = q->npdcch.num_decoded_symbols; snprintf(fname, MAX_FNAME_LEN, "nb_ue_dl_sfn%d_sf%d_npdcch_symbols.bin", sfn, sf_idx); DEBUG("SAVED FILE %s: rx'ed downlink symbols", fname); - srslte_vec_save_file(fname, q->npdcch.symbols[0], num_symbols * sizeof(cf_t)); + srsran_vec_save_file(fname, q->npdcch.symbols[0], num_symbols * sizeof(cf_t)); snprintf(fname, MAX_FNAME_LEN, "nb_ue_dl_sfn%d_sf%d_npdcch_symbols_eq.bin", sfn, sf_idx); DEBUG("SAVED FILE %s: eq rx'ed downlink symbols", fname); - srslte_vec_save_file(fname, q->npdcch.d, num_symbols * sizeof(cf_t)); + srsran_vec_save_file(fname, q->npdcch.d, num_symbols * sizeof(cf_t)); // NPDSCH num_symbols = q->npdsch_cfg.nbits.nof_re * q->npdsch_cfg.grant.nof_sf; snprintf(fname, MAX_FNAME_LEN, "nb_ue_dl_sfn%d_sf%d_npdsch_symbols.bin", sfn, sf_idx); DEBUG("SAVED FILE %s: rx'ed downlink symbols", fname); - srslte_vec_save_file(fname, q->npdsch.symbols[0], num_symbols * sizeof(cf_t)); + srsran_vec_save_file(fname, q->npdsch.symbols[0], num_symbols * sizeof(cf_t)); snprintf(fname, MAX_FNAME_LEN, "nb_ue_dl_sfn%d_sf%d_npdsch_symbols_eq.bin", sfn, sf_idx); DEBUG("SAVED FILE %s: eq rx'ed downlink symbols", fname); - srslte_vec_save_file(fname, q->npdsch.d, num_symbols * sizeof(cf_t)); + srsran_vec_save_file(fname, q->npdsch.d, num_symbols * sizeof(cf_t)); // CE snprintf(fname, MAX_FNAME_LEN, "nb_ue_dl_sfn%d_sf%d_ce0.bin", sfn, sf_idx); DEBUG("SAVED FILE %s: downlink channel estimates port 0", fname); - srslte_vec_save_file(fname, q->ce_buffer[0], num_symbols * sizeof(cf_t)); + srsran_vec_save_file(fname, q->ce_buffer[0], num_symbols * sizeof(cf_t)); if (q->cell.nof_ports > 1) { snprintf(fname, MAX_FNAME_LEN, "nb_ue_dl_sfn%d_sf%d_ce1.bin", sfn, sf_idx); DEBUG("SAVED FILE %s: downlink channel estimates port 1", fname); - srslte_vec_save_file(fname, q->ce_buffer[1], num_symbols * sizeof(cf_t)); + srsran_vec_save_file(fname, q->ce_buffer[1], num_symbols * sizeof(cf_t)); } } diff --git a/lib/src/phy/ue/ue_dl_nr.c b/lib/src/phy/ue/ue_dl_nr.c index 27d8964ce..a2254a896 100644 --- a/lib/src/phy/ue/ue_dl_nr.c +++ b/lib/src/phy/ue/ue_dl_nr.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,20 +10,20 @@ * */ -#include "srslte/phy/ue/ue_dl_nr.h" +#include "srsran/phy/ue/ue_dl_nr.h" #include #define UE_DL_NR_PDCCH_CORR_DEFAULT_THR 0.5f #define UE_DL_NR_PDCCH_EPRE_DEFAULT_THR -10.0f -static int ue_dl_nr_alloc_prb(srslte_ue_dl_nr_t* q, uint32_t new_nof_prb) +static int ue_dl_nr_alloc_prb(srsran_ue_dl_nr_t* q, uint32_t new_nof_prb) { if (q->max_prb < new_nof_prb) { q->max_prb = new_nof_prb; - srslte_chest_dl_res_free(&q->chest); - if (srslte_chest_dl_res_init(&q->chest, q->max_prb) < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + srsran_chest_dl_res_free(&q->chest); + if (srsran_chest_dl_res_init(&q->chest, q->max_prb) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } for (uint32_t i = 0; i < q->nof_rx_antennas; i++) { @@ -31,26 +31,26 @@ static int ue_dl_nr_alloc_prb(srslte_ue_dl_nr_t* q, uint32_t new_nof_prb) free(q->sf_symbols[i]); } - q->sf_symbols[i] = srslte_vec_cf_malloc(SRSLTE_SLOT_LEN_RE_NR(q->max_prb)); + q->sf_symbols[i] = srsran_vec_cf_malloc(SRSRAN_SLOT_LEN_RE_NR(q->max_prb)); if (q->sf_symbols[i] == NULL) { ERROR("Malloc"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_ue_dl_nr_init(srslte_ue_dl_nr_t* q, cf_t* input[SRSLTE_MAX_PORTS], const srslte_ue_dl_nr_args_t* args) +int srsran_ue_dl_nr_init(srsran_ue_dl_nr_t* q, cf_t* input[SRSRAN_MAX_PORTS], const srsran_ue_dl_nr_args_t* args) { if (!q || !input || !args) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } if (args->nof_rx_antennas == 0) { ERROR("Error invalid number of antennas (%d)", args->nof_rx_antennas); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } q->nof_rx_antennas = args->nof_rx_antennas; @@ -65,128 +65,128 @@ int srslte_ue_dl_nr_init(srslte_ue_dl_nr_t* q, cf_t* input[SRSLTE_MAX_PORTS], co q->pdcch_dmrs_epre_thr = UE_DL_NR_PDCCH_EPRE_DEFAULT_THR; } - if (srslte_pdsch_nr_init_ue(&q->pdsch, &args->pdsch) < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (srsran_pdsch_nr_init_ue(&q->pdsch, &args->pdsch) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } - if (srslte_pdcch_nr_init_rx(&q->pdcch, &args->pdcch)) { - return SRSLTE_ERROR; + if (srsran_pdcch_nr_init_rx(&q->pdcch, &args->pdcch)) { + return SRSRAN_ERROR; } if (ue_dl_nr_alloc_prb(q, args->nof_max_prb)) { ERROR("Error allocating"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - srslte_ofdm_cfg_t fft_cfg = {}; + srsran_ofdm_cfg_t fft_cfg = {}; fft_cfg.nof_prb = args->nof_max_prb; - fft_cfg.symbol_sz = srslte_symbol_sz(args->nof_max_prb); + fft_cfg.symbol_sz = srsran_symbol_sz(args->nof_max_prb); fft_cfg.keep_dc = true; for (uint32_t i = 0; i < q->nof_rx_antennas; i++) { fft_cfg.in_buffer = input[i]; fft_cfg.out_buffer = q->sf_symbols[i]; - srslte_ofdm_rx_init_cfg(&q->fft[i], &fft_cfg); + srsran_ofdm_rx_init_cfg(&q->fft[i], &fft_cfg); } - if (srslte_dmrs_sch_init(&q->dmrs_pdsch, true) < SRSLTE_SUCCESS) { + if (srsran_dmrs_sch_init(&q->dmrs_pdsch, true) < SRSRAN_SUCCESS) { ERROR("Error DMRS"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - q->pdcch_ce = SRSLTE_MEM_ALLOC(srslte_dmrs_pdcch_ce_t, 1); + q->pdcch_ce = SRSRAN_MEM_ALLOC(srsran_dmrs_pdcch_ce_t, 1); if (q->pdcch_ce == NULL) { ERROR("Error alloc"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -void srslte_ue_dl_nr_free(srslte_ue_dl_nr_t* q) +void srsran_ue_dl_nr_free(srsran_ue_dl_nr_t* q) { if (q == NULL) { return; } - for (uint32_t i = 0; i < SRSLTE_MAX_PORTS; i++) { - srslte_ofdm_rx_free(&q->fft[i]); + for (uint32_t i = 0; i < SRSRAN_MAX_PORTS; i++) { + srsran_ofdm_rx_free(&q->fft[i]); if (q->sf_symbols[i] != NULL) { free(q->sf_symbols[i]); } } - srslte_chest_dl_res_free(&q->chest); - srslte_pdsch_nr_free(&q->pdsch); - srslte_dmrs_sch_free(&q->dmrs_pdsch); + srsran_chest_dl_res_free(&q->chest); + srsran_pdsch_nr_free(&q->pdsch); + srsran_dmrs_sch_free(&q->dmrs_pdsch); - for (uint32_t i = 0; i < SRSLTE_UE_DL_NR_MAX_NOF_CORESET; i++) { - srslte_dmrs_pdcch_estimator_free(&q->dmrs_pdcch[i]); + for (uint32_t i = 0; i < SRSRAN_UE_DL_NR_MAX_NOF_CORESET; i++) { + srsran_dmrs_pdcch_estimator_free(&q->dmrs_pdcch[i]); } - srslte_pdcch_nr_free(&q->pdcch); + srsran_pdcch_nr_free(&q->pdcch); if (q->pdcch_ce) { free(q->pdcch_ce); } - SRSLTE_MEM_ZERO(q, srslte_ue_dl_nr_t, 1); + SRSRAN_MEM_ZERO(q, srsran_ue_dl_nr_t, 1); } -int srslte_ue_dl_nr_set_carrier(srslte_ue_dl_nr_t* q, const srslte_carrier_nr_t* carrier) +int srsran_ue_dl_nr_set_carrier(srsran_ue_dl_nr_t* q, const srsran_carrier_nr_t* carrier) { - if (srslte_pdsch_nr_set_carrier(&q->pdsch, carrier) < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (srsran_pdsch_nr_set_carrier(&q->pdsch, carrier) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } - if (srslte_dmrs_sch_set_carrier(&q->dmrs_pdsch, carrier) < SRSLTE_SUCCESS) { + if (srsran_dmrs_sch_set_carrier(&q->dmrs_pdsch, carrier) < SRSRAN_SUCCESS) { ERROR("Error DMRS"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (ue_dl_nr_alloc_prb(q, carrier->nof_prb)) { ERROR("Error allocating"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (carrier->nof_prb != q->carrier.nof_prb) { for (uint32_t i = 0; i < q->nof_rx_antennas; i++) { - srslte_ofdm_cfg_t cfg = {}; + srsran_ofdm_cfg_t cfg = {}; cfg.nof_prb = carrier->nof_prb; - cfg.symbol_sz = srslte_min_symbol_sz_rb(carrier->nof_prb); - cfg.cp = SRSLTE_CP_NORM; + cfg.symbol_sz = srsran_min_symbol_sz_rb(carrier->nof_prb); + cfg.cp = SRSRAN_CP_NORM; cfg.keep_dc = true; - srslte_ofdm_rx_init_cfg(&q->fft[i], &cfg); + srsran_ofdm_rx_init_cfg(&q->fft[i], &cfg); } } q->carrier = *carrier; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_ue_dl_nr_set_pdcch_config(srslte_ue_dl_nr_t* q, const srslte_ue_dl_nr_pdcch_cfg_t* cfg) +int srsran_ue_dl_nr_set_pdcch_config(srsran_ue_dl_nr_t* q, const srsran_ue_dl_nr_pdcch_cfg_t* cfg) { if (q == NULL || cfg == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } // Copy new configuration q->cfg = *cfg; // iterate over all possible CORESET and initialise/update the present ones - for (uint32_t i = 0; i < SRSLTE_UE_DL_NR_MAX_NOF_CORESET; i++) { + for (uint32_t i = 0; i < SRSRAN_UE_DL_NR_MAX_NOF_CORESET; i++) { if (cfg->coreset_present[i]) { - if (srslte_dmrs_pdcch_estimator_init(&q->dmrs_pdcch[i], &q->carrier, &cfg->coreset[i]) < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (srsran_dmrs_pdcch_estimator_init(&q->dmrs_pdcch[i], &q->carrier, &cfg->coreset[i]) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -void srslte_ue_dl_nr_estimate_fft(srslte_ue_dl_nr_t* q, const srslte_slot_cfg_t* slot_cfg) +void srsran_ue_dl_nr_estimate_fft(srsran_ue_dl_nr_t* q, const srsran_slot_cfg_t* slot_cfg) { if (q == NULL || slot_cfg == NULL) { return; @@ -194,47 +194,47 @@ void srslte_ue_dl_nr_estimate_fft(srslte_ue_dl_nr_t* q, const srslte_slot_cfg_t* // OFDM demodulation for (uint32_t i = 0; i < q->nof_rx_antennas; i++) { - srslte_ofdm_rx_sf(&q->fft[i]); + srsran_ofdm_rx_sf(&q->fft[i]); } // Estimate PDCCH channel for every configured CORESET - for (uint32_t i = 0; i < SRSLTE_UE_DL_NR_MAX_NOF_CORESET; i++) { + for (uint32_t i = 0; i < SRSRAN_UE_DL_NR_MAX_NOF_CORESET; i++) { if (q->cfg.coreset_present[i]) { - srslte_dmrs_pdcch_estimate(&q->dmrs_pdcch[i], slot_cfg, q->sf_symbols[0]); + srsran_dmrs_pdcch_estimate(&q->dmrs_pdcch[i], slot_cfg, q->sf_symbols[0]); } } } -static int ue_dl_nr_find_dci_ncce(srslte_ue_dl_nr_t* q, - srslte_dci_msg_nr_t* dci_msg, - srslte_pdcch_nr_res_t* pdcch_res, +static int ue_dl_nr_find_dci_ncce(srsran_ue_dl_nr_t* q, + srsran_dci_msg_nr_t* dci_msg, + srsran_pdcch_nr_res_t* pdcch_res, uint32_t coreset_id) { // Select debug information - srslte_ue_dl_nr_pdcch_info_t* pdcch_info = NULL; - if (q->pdcch_info_count < SRSLTE_MAX_NOF_CANDIDATES_SLOT_NR) { + srsran_ue_dl_nr_pdcch_info_t* pdcch_info = NULL; + if (q->pdcch_info_count < SRSRAN_MAX_NOF_CANDIDATES_SLOT_NR) { pdcch_info = &q->pdcch_info[q->pdcch_info_count]; q->pdcch_info_count++; } else { - ERROR("The UE does not expect more than %d candidates in this serving cell", SRSLTE_MAX_NOF_CANDIDATES_SLOT_NR); - return SRSLTE_ERROR; + ERROR("The UE does not expect more than %d candidates in this serving cell", SRSRAN_MAX_NOF_CANDIDATES_SLOT_NR); + return SRSRAN_ERROR; } - SRSLTE_MEM_ZERO(pdcch_info, srslte_ue_dl_nr_pdcch_info_t, 1); + SRSRAN_MEM_ZERO(pdcch_info, srsran_ue_dl_nr_pdcch_info_t, 1); pdcch_info->coreset_id = dci_msg->coreset_id; pdcch_info->ss_id = dci_msg->search_space; pdcch_info->location = dci_msg->location; - srslte_dmrs_pdcch_measure_t* m = &pdcch_info->measure; + srsran_dmrs_pdcch_measure_t* m = &pdcch_info->measure; // Measures the PDCCH transmission DMRS - if (srslte_dmrs_pdcch_get_measure(&q->dmrs_pdcch[coreset_id], &dci_msg->location, m) < SRSLTE_SUCCESS) { + if (srsran_dmrs_pdcch_get_measure(&q->dmrs_pdcch[coreset_id], &dci_msg->location, m) < SRSRAN_SUCCESS) { ERROR("Error getting measure location L=%d, ncce=%d", dci_msg->location.L, dci_msg->location.ncce); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // If measured correlation is invalid, early return if (!isnormal(m->norm_corr)) { INFO("Discarded PDCCH candidate L=%d;ncce=%d; Invalid measurement;", dci_msg->location.L, dci_msg->location.ncce); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Compare EPRE with threshold @@ -244,7 +244,7 @@ static int ue_dl_nr_find_dci_ncce(srslte_ue_dl_nr_t* q, dci_msg->location.ncce, m->epre_dBfs, q->pdcch_dmrs_epre_thr); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Compare DMRS correlation with threshold @@ -256,28 +256,28 @@ static int ue_dl_nr_find_dci_ncce(srslte_ue_dl_nr_t* q, q->pdcch_dmrs_corr_thr, m->epre_dBfs, m->rsrp_dBfs); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Extract PDCCH channel estimates - if (srslte_dmrs_pdcch_get_ce(&q->dmrs_pdcch[coreset_id], &dci_msg->location, q->pdcch_ce) < SRSLTE_SUCCESS) { + if (srsran_dmrs_pdcch_get_ce(&q->dmrs_pdcch[coreset_id], &dci_msg->location, q->pdcch_ce) < SRSRAN_SUCCESS) { ERROR("Error extracting PDCCH DMRS"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Decode PDCCH - if (srslte_pdcch_nr_decode(&q->pdcch, q->sf_symbols[0], q->pdcch_ce, dci_msg, pdcch_res) < SRSLTE_SUCCESS) { + if (srsran_pdcch_nr_decode(&q->pdcch, q->sf_symbols[0], q->pdcch_ce, dci_msg, pdcch_res) < SRSRAN_SUCCESS) { ERROR("Error decoding PDCCH"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Save information pdcch_info->result = *pdcch_res; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -static bool find_dci_msg(srslte_dci_msg_nr_t* dci_msg, uint32_t nof_dci_msg, srslte_dci_msg_nr_t* match) +static bool find_dci_msg(srsran_dci_msg_nr_t* dci_msg, uint32_t nof_dci_msg, srsran_dci_msg_nr_t* match) { bool found = false; uint32_t nof_bits = match->nof_bits; @@ -293,52 +293,52 @@ static bool find_dci_msg(srslte_dci_msg_nr_t* dci_msg, uint32_t nof_dci_msg, srs return found; } -static int ue_dl_nr_find_dl_dci_ss(srslte_ue_dl_nr_t* q, - const srslte_slot_cfg_t* slot_cfg, - const srslte_search_space_t* search_space, +static int ue_dl_nr_find_dl_dci_ss(srsran_ue_dl_nr_t* q, + const srsran_slot_cfg_t* slot_cfg, + const srsran_search_space_t* search_space, uint16_t rnti, - srslte_rnti_type_t rnti_type) + srsran_rnti_type_t rnti_type) { // Select CORESET uint32_t coreset_id = search_space->coreset_id; - if (coreset_id >= SRSLTE_UE_DL_NR_MAX_NOF_CORESET || !q->cfg.coreset_present[coreset_id]) { + if (coreset_id >= SRSRAN_UE_DL_NR_MAX_NOF_CORESET || !q->cfg.coreset_present[coreset_id]) { ERROR("CORESET %d is not present in search space %d", search_space->coreset_id, search_space->id); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - srslte_coreset_t* coreset = &q->cfg.coreset[search_space->coreset_id]; + srsran_coreset_t* coreset = &q->cfg.coreset[search_space->coreset_id]; // Set CORESET in PDCCH decoder - if (srslte_pdcch_nr_set_carrier(&q->pdcch, &q->carrier, coreset) < SRSLTE_SUCCESS) { + if (srsran_pdcch_nr_set_carrier(&q->pdcch, &q->carrier, coreset) < SRSRAN_SUCCESS) { ERROR("Setting carrier and CORESETºn"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Hard-coded values - srslte_dci_format_nr_t dci_format = srslte_dci_format_nr_1_0; + srsran_dci_format_nr_t dci_format = srsran_dci_format_nr_1_0; // Calculate number of DCI bits - int dci_nof_bits = srslte_dci_nr_format_1_0_sizeof(&q->carrier, coreset, rnti_type); - if (dci_nof_bits <= SRSLTE_SUCCESS) { + int dci_nof_bits = srsran_dci_nr_format_1_0_sizeof(&q->carrier, coreset, rnti_type); + if (dci_nof_bits <= SRSRAN_SUCCESS) { ERROR("Error DCI size"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Iterate all possible aggregation levels - for (uint32_t L = 0; L < SRSLTE_SEARCH_SPACE_NOF_AGGREGATION_LEVELS_NR && q->dci_msg_count < SRSLTE_MAX_DCI_MSG_NR; + for (uint32_t L = 0; L < SRSRAN_SEARCH_SPACE_NOF_AGGREGATION_LEVELS_NR && q->dci_msg_count < SRSRAN_MAX_DCI_MSG_NR; L++) { // Calculate possible PDCCH DCI candidates - uint32_t candidates[SRSLTE_SEARCH_SPACE_MAX_NOF_CANDIDATES_NR] = {}; - int nof_candidates = srslte_pdcch_nr_locations_coreset( - coreset, search_space, rnti, L, SRSLTE_SLOT_NR_MOD(q->carrier.numerology, slot_cfg->idx), candidates); - if (nof_candidates < SRSLTE_SUCCESS) { + uint32_t candidates[SRSRAN_SEARCH_SPACE_MAX_NOF_CANDIDATES_NR] = {}; + int nof_candidates = srsran_pdcch_nr_locations_coreset( + coreset, search_space, rnti, L, SRSRAN_SLOT_NR_MOD(q->carrier.numerology, slot_cfg->idx), candidates); + if (nof_candidates < SRSRAN_SUCCESS) { ERROR("Error calculating DCI candidate location"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Iterate over the candidates - for (int ncce_idx = 0; ncce_idx < nof_candidates && q->dci_msg_count < SRSLTE_MAX_DCI_MSG_NR; ncce_idx++) { + for (int ncce_idx = 0; ncce_idx < nof_candidates && q->dci_msg_count < SRSRAN_MAX_DCI_MSG_NR; ncce_idx++) { // Set DCI context - srslte_dci_msg_nr_t dci_msg = {}; + srsran_dci_msg_nr_t dci_msg = {}; dci_msg.location.L = L; dci_msg.location.ncce = candidates[ncce_idx]; dci_msg.search_space = search_space->type; @@ -349,9 +349,9 @@ static int ue_dl_nr_find_dl_dci_ss(srslte_ue_dl_nr_t* q, dci_msg.nof_bits = (uint32_t)dci_nof_bits; // Find and decode PDCCH transmission in the given ncce - srslte_pdcch_nr_res_t res = {}; - if (ue_dl_nr_find_dci_ncce(q, &dci_msg, &res, coreset_id) < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + srsran_pdcch_nr_res_t res = {}; + if (ue_dl_nr_find_dci_ncce(q, &dci_msg, &res, coreset_id) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } // If the CRC was not match, move to next candidate @@ -360,12 +360,12 @@ static int ue_dl_nr_find_dl_dci_ss(srslte_ue_dl_nr_t* q, } // Detect if the DCI was a format 0_0 - if (!srslte_dci_nr_format_1_0_valid(&dci_msg)) { + if (!srsran_dci_nr_format_1_0_valid(&dci_msg)) { // Change grant format to 0_0 - dci_msg.format = srslte_dci_format_nr_0_0; + dci_msg.format = srsran_dci_format_nr_0_0; // If the pending UL grant list is full or has the dci message, keep moving - if (q->pending_ul_dci_count >= SRSLTE_MAX_DCI_MSG_NR || + if (q->pending_ul_dci_count >= SRSRAN_MAX_DCI_MSG_NR || find_dci_msg(q->pending_ul_dci_msg, q->pending_ul_dci_count, &dci_msg)) { continue; } @@ -391,39 +391,39 @@ static int ue_dl_nr_find_dl_dci_ss(srslte_ue_dl_nr_t* q, } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_ue_dl_nr_find_dl_dci(srslte_ue_dl_nr_t* q, - const srslte_slot_cfg_t* slot_cfg, +int srsran_ue_dl_nr_find_dl_dci(srsran_ue_dl_nr_t* q, + const srsran_slot_cfg_t* slot_cfg, uint16_t rnti, - srslte_rnti_type_t rnti_type, - srslte_dci_dl_nr_t* dci_dl_list, + srsran_rnti_type_t rnti_type, + srsran_dci_dl_nr_t* dci_dl_list, uint32_t nof_dci_msg) { // Check inputs if (q == NULL || slot_cfg == NULL || dci_dl_list == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } // Limit maximum number of DCI messages to find - nof_dci_msg = SRSLTE_MIN(nof_dci_msg, SRSLTE_MAX_DCI_MSG_NR); + nof_dci_msg = SRSRAN_MIN(nof_dci_msg, SRSRAN_MAX_DCI_MSG_NR); // Reset grant and blind search information counters q->dci_msg_count = 0; q->pdcch_info_count = 0; // If the UE looks for a RAR and RA search space is provided, search for it - if (q->cfg.ra_search_space_present && rnti_type == srslte_rnti_type_ra) { + if (q->cfg.ra_search_space_present && rnti_type == srsran_rnti_type_ra) { // Find DCIs in the RA search space int ret = ue_dl_nr_find_dl_dci_ss(q, slot_cfg, &q->cfg.ra_search_space, rnti, rnti_type); - if (ret < SRSLTE_SUCCESS) { + if (ret < SRSRAN_SUCCESS) { ERROR("Error searching RAR DCI"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } else { // Iterate all possible common and UE search spaces - for (uint32_t i = 0; i < SRSLTE_UE_DL_NR_MAX_NOF_SEARCH_SPACE && q->dci_msg_count < nof_dci_msg; i++) { + for (uint32_t i = 0; i < SRSRAN_UE_DL_NR_MAX_NOF_SEARCH_SPACE && q->dci_msg_count < nof_dci_msg; i++) { // Skip search space if not present if (!q->cfg.search_space_present[i]) { continue; @@ -431,47 +431,47 @@ int srslte_ue_dl_nr_find_dl_dci(srslte_ue_dl_nr_t* q, // Find DCIs in the selected search space int ret = ue_dl_nr_find_dl_dci_ss(q, slot_cfg, &q->cfg.search_space[i], rnti, rnti_type); - if (ret < SRSLTE_SUCCESS) { + if (ret < SRSRAN_SUCCESS) { ERROR("Error searching DCI"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } } // Convert found DCI messages into DL grants - uint32_t dci_msg_count = SRSLTE_MIN(nof_dci_msg, q->dci_msg_count); + uint32_t dci_msg_count = SRSRAN_MIN(nof_dci_msg, q->dci_msg_count); for (uint32_t i = 0; i < dci_msg_count; i++) { - const srslte_coreset_t* coreset = &q->cfg.coreset[q->dci_msg[i].coreset_id]; - srslte_dci_nr_format_1_0_unpack(&q->carrier, coreset, &q->dci_msg[i], &dci_dl_list[i]); + const srsran_coreset_t* coreset = &q->cfg.coreset[q->dci_msg[i].coreset_id]; + srsran_dci_nr_format_1_0_unpack(&q->carrier, coreset, &q->dci_msg[i], &dci_dl_list[i]); } return (int)dci_msg_count; } -int srslte_ue_dl_nr_find_ul_dci(srslte_ue_dl_nr_t* q, - const srslte_slot_cfg_t* slot_cfg, +int srsran_ue_dl_nr_find_ul_dci(srsran_ue_dl_nr_t* q, + const srsran_slot_cfg_t* slot_cfg, uint16_t rnti, - srslte_rnti_type_t rnti_type, - srslte_dci_ul_nr_t* dci_ul_list, + srsran_rnti_type_t rnti_type, + srsran_dci_ul_nr_t* dci_ul_list, uint32_t nof_dci_msg) { int count = 0; // Check inputs if (q == NULL || slot_cfg == NULL || dci_ul_list == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } // Get DCI messages from the pending list for (uint32_t i = 0; i < q->pending_ul_dci_count && count < nof_dci_msg; i++) { - srslte_dci_msg_nr_t* dci_msg = &q->pending_ul_dci_msg[i]; + srsran_dci_msg_nr_t* dci_msg = &q->pending_ul_dci_msg[i]; if (dci_msg->rnti_type != rnti_type || dci_msg->rnti != rnti) { continue; } - const srslte_coreset_t* coreset = &q->cfg.coreset[dci_msg->coreset_id]; - if (srslte_dci_nr_format_0_0_unpack(&q->carrier, coreset, dci_msg, &dci_ul_list[count]) < SRSLTE_SUCCESS) { + const srsran_coreset_t* coreset = &q->cfg.coreset[dci_msg->coreset_id]; + if (srsran_dci_nr_format_0_0_unpack(&q->carrier, coreset, dci_msg, &dci_ul_list[count]) < SRSRAN_SUCCESS) { ERROR("Unpacking DCI 0_0"); continue; } @@ -484,41 +484,41 @@ int srslte_ue_dl_nr_find_ul_dci(srslte_ue_dl_nr_t* q, return count; } -int srslte_ue_dl_nr_decode_pdsch(srslte_ue_dl_nr_t* q, - const srslte_slot_cfg_t* slot, - const srslte_sch_cfg_nr_t* cfg, - srslte_pdsch_res_nr_t* res) +int srsran_ue_dl_nr_decode_pdsch(srsran_ue_dl_nr_t* q, + const srsran_slot_cfg_t* slot, + const srsran_sch_cfg_nr_t* cfg, + srsran_pdsch_res_nr_t* res) { - if (srslte_dmrs_sch_estimate(&q->dmrs_pdsch, slot, cfg, &cfg->grant, q->sf_symbols[0], &q->chest) < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (srsran_dmrs_sch_estimate(&q->dmrs_pdsch, slot, cfg, &cfg->grant, q->sf_symbols[0], &q->chest) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } - if (srslte_pdsch_nr_decode(&q->pdsch, cfg, &cfg->grant, &q->chest, q->sf_symbols, res) < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (srsran_pdsch_nr_decode(&q->pdsch, cfg, &cfg->grant, &q->chest, q->sf_symbols, res) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } - if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_INFO && !handler_registered) { + if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_INFO && !handler_registered) { char str[512]; - srslte_ue_dl_nr_pdsch_info(q, cfg, res, str, sizeof(str)); + srsran_ue_dl_nr_pdsch_info(q, cfg, res, str, sizeof(str)); INFO("PDSCH: %s", str); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_ue_dl_nr_pdsch_info(const srslte_ue_dl_nr_t* q, - const srslte_sch_cfg_nr_t* cfg, - const srslte_pdsch_res_nr_t* res, +int srsran_ue_dl_nr_pdsch_info(const srsran_ue_dl_nr_t* q, + const srsran_sch_cfg_nr_t* cfg, + const srsran_pdsch_res_nr_t* res, char* str, uint32_t str_len) { int len = 0; // Append PDSCH info - len += srslte_pdsch_nr_rx_info(&q->pdsch, cfg, &cfg->grant, res, &str[len], str_len - len); + len += srsran_pdsch_nr_rx_info(&q->pdsch, cfg, &cfg->grant, res, &str[len], str_len - len); // Append channel estimator info - len = srslte_print_check(str, str_len, len, ",SNR=%+.1f", q->chest.snr_db); + len = srsran_print_check(str, str_len, len, ",SNR=%+.1f", q->chest.snr_db); return len; } @@ -530,9 +530,9 @@ static uint32_t ue_dl_nr_V_DL_DAI(uint32_t dai) return dai + 1; } -static int ue_dl_nr_gen_ack_type2(const srslte_ue_dl_nr_harq_ack_cfg_t* cfg, - const srslte_pdsch_ack_nr_t* ack_info, - srslte_uci_data_nr_t* uci_data) +static int ue_dl_nr_gen_ack_type2(const srsran_ue_dl_nr_harq_ack_cfg_t* cfg, + const srsran_pdsch_ack_nr_t* ack_info, + srsran_uci_data_nr_t* uci_data) { bool harq_ack_spatial_bundling = ack_info->use_pusch ? cfg->harq_ack_spatial_bundling_pusch : cfg->harq_ack_spatial_bundling_pucch; @@ -547,11 +547,11 @@ static int ue_dl_nr_gen_ack_type2(const srslte_ue_dl_nr_harq_ack_cfg_t* cfg, uint32_t N_DL_cells = ack_info->nof_cc; // number of serving cells configured by higher layers for the UE // The following code follows the exact pseudo-code provided in TS 38.213 9.1.3.1 Type-2 HARQ-ACK codebook ... - while (m < SRSLTE_UCI_NR_MAX_M) { + while (m < SRSRAN_UCI_NR_MAX_M) { uint32_t c = 0; // serving cell index: lower indexes correspond to lower RRC indexes of corresponding cell while (c < N_DL_cells) { // Get ACK information of serving cell c for the PDCH monitoring occasion m - const srslte_pdsch_ack_m_nr_t* ack = &ack_info->cc[c].m[m]; + const srsran_pdsch_ack_m_nr_t* ack = &ack_info->cc[c].m[m]; // Get DAI counter value uint32_t V_DL_CDAI = ue_dl_nr_V_DL_DAI(ack->resource.v_dai_dl); @@ -632,73 +632,73 @@ static int ue_dl_nr_gen_ack_type2(const srslte_ue_dl_nr_harq_ack_cfg_t* cfg, // Implement here SPS PDSCH reception // ... - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int ue_dl_nr_pdsch_k1(const srslte_ue_dl_nr_harq_ack_cfg_t* cfg, const srslte_dci_dl_nr_t* dci_dl) +int ue_dl_nr_pdsch_k1(const srsran_ue_dl_nr_harq_ack_cfg_t* cfg, const srsran_dci_dl_nr_t* dci_dl) { // For DCI format 1_0, the PDSCH-to-HARQ_feedback timing indicator field values map to {1, 2, 3, 4, 5, 6, 7, 8} - if (dci_dl->format == srslte_dci_format_nr_1_0) { + if (dci_dl->format == srsran_dci_format_nr_1_0) { return (int)dci_dl->harq_feedback + 1; } // For DCI format 1_1, if present, the PDSCH-to-HARQ_feedback timing indicator field values map to values for a set of // number of slots provided by dl-DataToUL-ACK as defined in Table 9.2.3-1. - if (dci_dl->harq_feedback >= SRSLTE_MAX_NOF_DL_DATA_TO_UL || dci_dl->harq_feedback >= cfg->nof_dl_data_to_ul_ack) { + if (dci_dl->harq_feedback >= SRSRAN_MAX_NOF_DL_DATA_TO_UL || dci_dl->harq_feedback >= cfg->nof_dl_data_to_ul_ack) { ERROR("Out-of-range PDSCH-to-HARQ feedback index (%d, max %d)", dci_dl->harq_feedback, cfg->nof_dl_data_to_ul_ack); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } return (int)cfg->dl_data_to_ul_ack[dci_dl->harq_feedback]; } -int srslte_ue_dl_nr_pdsch_ack_resource(const srslte_ue_dl_nr_harq_ack_cfg_t* cfg, - const srslte_dci_dl_nr_t* dci_dl, - srslte_pdsch_ack_resource_nr_t* pdsch_ack_resource) +int srsran_ue_dl_nr_pdsch_ack_resource(const srsran_ue_dl_nr_harq_ack_cfg_t* cfg, + const srsran_dci_dl_nr_t* dci_dl, + srsran_pdsch_ack_resource_nr_t* pdsch_ack_resource) { if (cfg == NULL || dci_dl == NULL || pdsch_ack_resource == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } // Calculate Data to UL ACK timing k1 int k1 = ue_dl_nr_pdsch_k1(cfg, dci_dl); - if (k1 < SRSLTE_ERROR) { + if (k1 < SRSRAN_ERROR) { ERROR("Error calculating K1"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Fill PDSCH resource - pdsch_ack_resource->dci_format_1_1 = (dci_dl->format == srslte_dci_format_nr_1_1); + pdsch_ack_resource->dci_format_1_1 = (dci_dl->format == srsran_dci_format_nr_1_1); pdsch_ack_resource->k1 = k1; pdsch_ack_resource->v_dai_dl = dci_dl->dai; pdsch_ack_resource->rnti = dci_dl->rnti; pdsch_ack_resource->pucch_resource_id = dci_dl->pucch_resource; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_ue_dl_nr_gen_ack(const srslte_ue_dl_nr_harq_ack_cfg_t* cfg, - const srslte_pdsch_ack_nr_t* ack_info, - srslte_uci_data_nr_t* uci_data) +int srsran_ue_dl_nr_gen_ack(const srsran_ue_dl_nr_harq_ack_cfg_t* cfg, + const srsran_pdsch_ack_nr_t* ack_info, + srsran_uci_data_nr_t* uci_data) { // Check inputs if (cfg == NULL || ack_info == NULL || uci_data == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } // According TS 38.213 9.1.2 Type-1 HARQ-ACK codebook determination - if (cfg->pdsch_harq_ack_codebook == srslte_pdsch_harq_ack_codebook_semi_static) { + if (cfg->pdsch_harq_ack_codebook == srsran_pdsch_harq_ack_codebook_semi_static) { // This clause applies if the UE is configured with pdsch-HARQ-ACK-Codebook = semi-static. ERROR("Type-1 HARQ-ACK codebook determination is NOT implemented"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // According TS 38.213 9.1.3 Type-2 HARQ-ACK codebook determination - if (cfg->pdsch_harq_ack_codebook == srslte_pdsch_harq_ack_codebook_dynamic) { + if (cfg->pdsch_harq_ack_codebook == srsran_pdsch_harq_ack_codebook_dynamic) { // This clause applies if the UE is configured with pdsch-HARQ-ACK-Codebook = dynamic. return ue_dl_nr_gen_ack_type2(cfg, ack_info, uci_data); } ERROR("No HARQ-ACK codebook determination is NOT implemented"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } diff --git a/lib/src/phy/ue/ue_mib.c b/lib/src/phy/ue/ue_mib.c index 9a0fb451d..8abf73eb5 100644 --- a/lib/src/phy/ue/ue_mib.c +++ b/lib/src/phy/ue/ue_mib.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,151 +10,151 @@ * */ -#include "srslte/srslte.h" +#include "srsran/srsran.h" #include #include #include #include #include -#include "srslte/phy/ue/ue_mib.h" +#include "srsran/phy/ue/ue_mib.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" -#define MIB_BUFFER_MAX_SAMPLES (3 * SRSLTE_SF_LEN_PRB(SRSLTE_UE_MIB_NOF_PRB)) +#define MIB_BUFFER_MAX_SAMPLES (3 * SRSRAN_SF_LEN_PRB(SRSRAN_UE_MIB_NOF_PRB)) -int srslte_ue_mib_init(srslte_ue_mib_t* q, cf_t* in_buffer, uint32_t max_prb) +int srsran_ue_mib_init(srsran_ue_mib_t* q, cf_t* in_buffer, uint32_t max_prb) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL) { - ret = SRSLTE_ERROR; - bzero(q, sizeof(srslte_ue_mib_t)); + ret = SRSRAN_ERROR; + bzero(q, sizeof(srsran_ue_mib_t)); - if (srslte_pbch_init(&q->pbch)) { + if (srsran_pbch_init(&q->pbch)) { ERROR("Error initiating PBCH"); goto clean_exit; } - q->sf_symbols = srslte_vec_cf_malloc(SRSLTE_SF_LEN_RE(max_prb, SRSLTE_CP_NORM)); + q->sf_symbols = srsran_vec_cf_malloc(SRSRAN_SF_LEN_RE(max_prb, SRSRAN_CP_NORM)); if (!q->sf_symbols) { perror("malloc"); goto clean_exit; } - if (srslte_ofdm_rx_init(&q->fft, SRSLTE_CP_NORM, in_buffer, q->sf_symbols, max_prb)) { + if (srsran_ofdm_rx_init(&q->fft, SRSRAN_CP_NORM, in_buffer, q->sf_symbols, max_prb)) { ERROR("Error initializing FFT"); goto clean_exit; } - if (srslte_chest_dl_init(&q->chest, max_prb, 1)) { + if (srsran_chest_dl_init(&q->chest, max_prb, 1)) { ERROR("Error initializing reference signal"); goto clean_exit; } - if (srslte_chest_dl_res_init(&q->chest_res, max_prb)) { + if (srsran_chest_dl_res_init(&q->chest_res, max_prb)) { ERROR("Error initializing reference signal"); goto clean_exit; } - srslte_ue_mib_reset(q); + srsran_ue_mib_reset(q); - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } clean_exit: - if (ret == SRSLTE_ERROR) { - srslte_ue_mib_free(q); + if (ret == SRSRAN_ERROR) { + srsran_ue_mib_free(q); } return ret; } -void srslte_ue_mib_free(srslte_ue_mib_t* q) +void srsran_ue_mib_free(srsran_ue_mib_t* q) { if (q->sf_symbols) { free(q->sf_symbols); } - srslte_sync_free(&q->sfind); - srslte_chest_dl_res_free(&q->chest_res); - srslte_chest_dl_free(&q->chest); - srslte_pbch_free(&q->pbch); - srslte_ofdm_rx_free(&q->fft); + srsran_sync_free(&q->sfind); + srsran_chest_dl_res_free(&q->chest_res); + srsran_chest_dl_free(&q->chest); + srsran_pbch_free(&q->pbch); + srsran_ofdm_rx_free(&q->fft); - bzero(q, sizeof(srslte_ue_mib_t)); + bzero(q, sizeof(srsran_ue_mib_t)); } -int srslte_ue_mib_set_cell(srslte_ue_mib_t* q, srslte_cell_t cell) +int srsran_ue_mib_set_cell(srsran_ue_mib_t* q, srsran_cell_t cell) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; - if (q != NULL && cell.nof_ports <= SRSLTE_MAX_PORTS) { - if (srslte_pbch_set_cell(&q->pbch, cell)) { + if (q != NULL && cell.nof_ports <= SRSRAN_MAX_PORTS) { + if (srsran_pbch_set_cell(&q->pbch, cell)) { ERROR("Error initiating PBCH"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_ofdm_rx_set_prb(&q->fft, cell.cp, cell.nof_prb)) { + if (srsran_ofdm_rx_set_prb(&q->fft, cell.cp, cell.nof_prb)) { ERROR("Error initializing FFT"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (cell.nof_ports == 0) { - cell.nof_ports = SRSLTE_MAX_PORTS; + cell.nof_ports = SRSRAN_MAX_PORTS; } - if (srslte_chest_dl_set_cell(&q->chest, cell)) { + if (srsran_chest_dl_set_cell(&q->chest, cell)) { ERROR("Error initializing reference signal"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - srslte_ue_mib_reset(q); + srsran_ue_mib_reset(q); - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } -void srslte_ue_mib_reset(srslte_ue_mib_t* q) +void srsran_ue_mib_reset(srsran_ue_mib_t* q) { q->frame_cnt = 0; - srslte_pbch_decode_reset(&q->pbch); + srsran_pbch_decode_reset(&q->pbch); } -int srslte_ue_mib_decode(srslte_ue_mib_t* q, - uint8_t bch_payload[SRSLTE_BCH_PAYLOAD_LEN], +int srsran_ue_mib_decode(srsran_ue_mib_t* q, + uint8_t bch_payload[SRSRAN_BCH_PAYLOAD_LEN], uint32_t* nof_tx_ports, int* sfn_offset) { - int ret = SRSLTE_SUCCESS; + int ret = SRSRAN_SUCCESS; /* Run FFT for the slot symbols */ - srslte_ofdm_rx_sf(&q->fft); + srsran_ofdm_rx_sf(&q->fft); // sf_idx is always 0 in MIB - srslte_dl_sf_cfg_t sf_cfg; + srsran_dl_sf_cfg_t sf_cfg; ZERO_OBJECT(sf_cfg); // Current MIB decoder implementation uses a single antenna - cf_t* sf_buffer[SRSLTE_MAX_PORTS] = {}; + cf_t* sf_buffer[SRSRAN_MAX_PORTS] = {}; sf_buffer[0] = q->sf_symbols; /* Get channel estimates of sf idx #0 for each port */ - ret = srslte_chest_dl_estimate(&q->chest, &sf_cfg, sf_buffer, &q->chest_res); + ret = srsran_chest_dl_estimate(&q->chest, &sf_cfg, sf_buffer, &q->chest_res); if (ret < 0) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } /* Reset decoder if we missed a frame */ if (q->frame_cnt > 8) { INFO("Resetting PBCH decoder after %d frames", q->frame_cnt); - srslte_ue_mib_reset(q); + srsran_ue_mib_reset(q); } /* Decode PBCH */ - ret = srslte_pbch_decode(&q->pbch, &q->chest_res, sf_buffer, bch_payload, nof_tx_ports, sfn_offset); + ret = srsran_pbch_decode(&q->pbch, &q->chest_res, sf_buffer, bch_payload, nof_tx_ports, sfn_offset); if (ret < 0) { ERROR("Error decoding PBCH (%d)", ret); } else if (ret == 1) { INFO("MIB decoded: %u, snr=%.1f dB", q->frame_cnt, q->chest_res.snr_db); - srslte_ue_mib_reset(q); - ret = SRSLTE_UE_MIB_FOUND; + srsran_ue_mib_reset(q); + ret = SRSRAN_UE_MIB_FOUND; } else { - ret = SRSLTE_UE_MIB_NOTFOUND; + ret = SRSRAN_UE_MIB_NOTFOUND; INFO("MIB not decoded: %u, snr=%.1f dB", q->frame_cnt, q->chest_res.snr_db); q->frame_cnt++; } @@ -162,102 +162,102 @@ int srslte_ue_mib_decode(srslte_ue_mib_t* q, return ret; } -int srslte_ue_mib_sync_init_multi(srslte_ue_mib_sync_t* q, - int(recv_callback)(void*, cf_t* [SRSLTE_MAX_CHANNELS], uint32_t, srslte_timestamp_t*), +int srsran_ue_mib_sync_init_multi(srsran_ue_mib_sync_t* q, + int(recv_callback)(void*, cf_t* [SRSRAN_MAX_CHANNELS], uint32_t, srsran_timestamp_t*), uint32_t nof_rx_channels, void* stream_handler) { for (int i = 0; i < nof_rx_channels; i++) { - q->sf_buffer[i] = srslte_vec_cf_malloc(MIB_BUFFER_MAX_SAMPLES); + q->sf_buffer[i] = srsran_vec_cf_malloc(MIB_BUFFER_MAX_SAMPLES); } q->nof_rx_channels = nof_rx_channels; // Use 1st RF channel only to receive MIB - if (srslte_ue_mib_init(&q->ue_mib, q->sf_buffer[0], SRSLTE_UE_MIB_NOF_PRB)) { + if (srsran_ue_mib_init(&q->ue_mib, q->sf_buffer[0], SRSRAN_UE_MIB_NOF_PRB)) { ERROR("Error initiating ue_mib"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Configure ue_sync to receive all channels - if (srslte_ue_sync_init_multi( - &q->ue_sync, SRSLTE_UE_MIB_NOF_PRB, false, recv_callback, nof_rx_channels, stream_handler)) { + if (srsran_ue_sync_init_multi( + &q->ue_sync, SRSRAN_UE_MIB_NOF_PRB, false, recv_callback, nof_rx_channels, stream_handler)) { fprintf(stderr, "Error initiating ue_sync\n"); - srslte_ue_mib_free(&q->ue_mib); - return SRSLTE_ERROR; + srsran_ue_mib_free(&q->ue_mib); + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_ue_mib_sync_set_cell(srslte_ue_mib_sync_t* q, srslte_cell_t cell) +int srsran_ue_mib_sync_set_cell(srsran_ue_mib_sync_t* q, srsran_cell_t cell) { // If the ports are set to 0, ue_mib goes through 1, 2 and 4 ports to blindly detect nof_ports cell.nof_ports = 0; // MIB search is done at 6 PRB - cell.nof_prb = SRSLTE_UE_MIB_NOF_PRB; + cell.nof_prb = SRSRAN_UE_MIB_NOF_PRB; - if (srslte_ue_mib_set_cell(&q->ue_mib, cell)) { + if (srsran_ue_mib_set_cell(&q->ue_mib, cell)) { ERROR("Error initiating ue_mib"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_ue_sync_set_cell(&q->ue_sync, cell)) { + if (srsran_ue_sync_set_cell(&q->ue_sync, cell)) { ERROR("Error initiating ue_sync"); - srslte_ue_mib_free(&q->ue_mib); - return SRSLTE_ERROR; + srsran_ue_mib_free(&q->ue_mib); + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -void srslte_ue_mib_sync_free(srslte_ue_mib_sync_t* q) +void srsran_ue_mib_sync_free(srsran_ue_mib_sync_t* q) { for (int i = 0; i < q->nof_rx_channels; i++) { if (q->sf_buffer[i]) { free(q->sf_buffer[i]); } } - srslte_ue_mib_free(&q->ue_mib); - srslte_ue_sync_free(&q->ue_sync); + srsran_ue_mib_free(&q->ue_mib); + srsran_ue_sync_free(&q->ue_sync); } -void srslte_ue_mib_sync_reset(srslte_ue_mib_sync_t* q) +void srsran_ue_mib_sync_reset(srsran_ue_mib_sync_t* q) { - srslte_ue_mib_reset(&q->ue_mib); - srslte_ue_sync_reset(&q->ue_sync); + srsran_ue_mib_reset(&q->ue_mib); + srsran_ue_sync_reset(&q->ue_sync); } -int srslte_ue_mib_sync_decode(srslte_ue_mib_sync_t* q, +int srsran_ue_mib_sync_decode(srsran_ue_mib_sync_t* q, uint32_t max_frames_timeout, - uint8_t bch_payload[SRSLTE_BCH_PAYLOAD_LEN], + uint8_t bch_payload[SRSRAN_BCH_PAYLOAD_LEN], uint32_t* nof_tx_ports, int* sfn_offset) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; uint32_t nof_frames = 0; - int mib_ret = SRSLTE_UE_MIB_NOTFOUND; + int mib_ret = SRSRAN_UE_MIB_NOTFOUND; if (q == NULL) { return ret; } - srslte_ue_mib_sync_reset(q); + srsran_ue_mib_sync_reset(q); do { - mib_ret = SRSLTE_UE_MIB_NOTFOUND; - ret = srslte_ue_sync_zerocopy(&q->ue_sync, q->sf_buffer, MIB_BUFFER_MAX_SAMPLES); + mib_ret = SRSRAN_UE_MIB_NOTFOUND; + ret = srsran_ue_sync_zerocopy(&q->ue_sync, q->sf_buffer, MIB_BUFFER_MAX_SAMPLES); if (ret < 0) { - ERROR("Error calling srslte_ue_sync_work()"); + ERROR("Error calling srsran_ue_sync_work()"); return -1; } - if (srslte_ue_sync_get_sfidx(&q->ue_sync) == 0) { + if (srsran_ue_sync_get_sfidx(&q->ue_sync) == 0) { if (ret == 1) { - mib_ret = srslte_ue_mib_decode(&q->ue_mib, bch_payload, nof_tx_ports, sfn_offset); + mib_ret = srsran_ue_mib_decode(&q->ue_mib, bch_payload, nof_tx_ports, sfn_offset); } else { DEBUG("Resetting PBCH decoder after %d frames", q->ue_mib.frame_cnt); - srslte_ue_mib_reset(&q->ue_mib); + srsran_ue_mib_reset(&q->ue_mib); } nof_frames++; } - } while (mib_ret == SRSLTE_UE_MIB_NOTFOUND && nof_frames < max_frames_timeout); + } while (mib_ret == SRSRAN_UE_MIB_NOTFOUND && nof_frames < max_frames_timeout); return mib_ret; } diff --git a/lib/src/phy/ue/ue_mib_nbiot.c b/lib/src/phy/ue/ue_mib_nbiot.c index 2756c40ea..28d784707 100644 --- a/lib/src/phy/ue/ue_mib_nbiot.c +++ b/lib/src/phy/ue/ue_mib_nbiot.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,150 +10,150 @@ * */ -#include "srslte/phy/ue/ue_mib_nbiot.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/ue/ue_mib_nbiot.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" #include #include #include -int srslte_ue_mib_nbiot_init(srslte_ue_mib_nbiot_t* q, cf_t** in_buffer, uint32_t max_prb) +int srsran_ue_mib_nbiot_init(srsran_ue_mib_nbiot_t* q, cf_t** in_buffer, uint32_t max_prb) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL) { - ret = SRSLTE_ERROR; - bzero(q, sizeof(srslte_ue_mib_nbiot_t)); + ret = SRSRAN_ERROR; + bzero(q, sizeof(srsran_ue_mib_nbiot_t)); - if (srslte_npbch_init(&q->npbch)) { + if (srsran_npbch_init(&q->npbch)) { fprintf(stderr, "Error initiating NPBCH\n"); goto clean_exit; } - q->sf_symbols = srslte_vec_cf_malloc(SRSLTE_SF_LEN_RE(max_prb, SRSLTE_CP_NORM)); + q->sf_symbols = srsran_vec_cf_malloc(SRSRAN_SF_LEN_RE(max_prb, SRSRAN_CP_NORM)); if (!q->sf_symbols) { perror("malloc"); goto clean_exit; } - for (uint32_t i = 0; i < SRSLTE_MAX_PORTS; i++) { - q->ce[i] = srslte_vec_cf_malloc(SRSLTE_SF_LEN_RE(max_prb, SRSLTE_CP_NORM)); + for (uint32_t i = 0; i < SRSRAN_MAX_PORTS; i++) { + q->ce[i] = srsran_vec_cf_malloc(SRSRAN_SF_LEN_RE(max_prb, SRSRAN_CP_NORM)); if (!q->ce[i]) { perror("malloc"); goto clean_exit; } } - if (srslte_ofdm_rx_init(&q->fft, SRSLTE_CP_NORM, in_buffer[0], q->sf_symbols, max_prb)) { + if (srsran_ofdm_rx_init(&q->fft, SRSRAN_CP_NORM, in_buffer[0], q->sf_symbols, max_prb)) { fprintf(stderr, "Error initializing FFT\n"); goto clean_exit; } - srslte_ofdm_set_freq_shift(&q->fft, SRSLTE_NBIOT_FREQ_SHIFT_FACTOR); + srsran_ofdm_set_freq_shift(&q->fft, SRSRAN_NBIOT_FREQ_SHIFT_FACTOR); - if (srslte_chest_dl_nbiot_init(&q->chest, max_prb)) { + if (srsran_chest_dl_nbiot_init(&q->chest, max_prb)) { fprintf(stderr, "Error initializing reference signal\n"); goto clean_exit; } - srslte_ue_mib_nbiot_reset(q); + srsran_ue_mib_nbiot_reset(q); - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } clean_exit: - if (ret == SRSLTE_ERROR) { - srslte_ue_mib_nbiot_free(q); + if (ret == SRSRAN_ERROR) { + srsran_ue_mib_nbiot_free(q); } return ret; } -void srslte_ue_mib_nbiot_free(srslte_ue_mib_nbiot_t* q) +void srsran_ue_mib_nbiot_free(srsran_ue_mib_nbiot_t* q) { if (q->sf_symbols) { free(q->sf_symbols); } - for (int i = 0; i < SRSLTE_MAX_PORTS; i++) { + for (int i = 0; i < SRSRAN_MAX_PORTS; i++) { if (q->ce[i]) { free(q->ce[i]); } } - srslte_sync_nbiot_free(&q->sfind); - srslte_chest_dl_nbiot_free(&q->chest); - srslte_npbch_free(&q->npbch); - srslte_ofdm_rx_free(&q->fft); + srsran_sync_nbiot_free(&q->sfind); + srsran_chest_dl_nbiot_free(&q->chest); + srsran_npbch_free(&q->npbch); + srsran_ofdm_rx_free(&q->fft); - bzero(q, sizeof(srslte_ue_mib_nbiot_t)); + bzero(q, sizeof(srsran_ue_mib_nbiot_t)); } -int srslte_ue_mib_nbiot_set_cell(srslte_ue_mib_nbiot_t* q, srslte_nbiot_cell_t cell) +int srsran_ue_mib_nbiot_set_cell(srsran_ue_mib_nbiot_t* q, srsran_nbiot_cell_t cell) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; - if (q != NULL && cell.nof_ports <= SRSLTE_NBIOT_MAX_PORTS) { - ret = SRSLTE_ERROR; + if (q != NULL && cell.nof_ports <= SRSRAN_NBIOT_MAX_PORTS) { + ret = SRSRAN_ERROR; - if (srslte_npbch_set_cell(&q->npbch, cell)) { + if (srsran_npbch_set_cell(&q->npbch, cell)) { fprintf(stderr, "Error setting cell in NPBCH\n"); goto clean_exit; } if (cell.nof_ports == 0) { - cell.nof_ports = SRSLTE_NBIOT_MAX_PORTS; + cell.nof_ports = SRSRAN_NBIOT_MAX_PORTS; } - if (srslte_chest_dl_nbiot_set_cell(&q->chest, cell)) { + if (srsran_chest_dl_nbiot_set_cell(&q->chest, cell)) { fprintf(stderr, "Error initializing reference signal\n"); goto clean_exit; } - srslte_ue_mib_nbiot_reset(q); + srsran_ue_mib_nbiot_reset(q); - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } clean_exit: - if (ret == SRSLTE_ERROR) { - srslte_ue_mib_nbiot_free(q); + if (ret == SRSRAN_ERROR) { + srsran_ue_mib_nbiot_free(q); } return ret; } -void srslte_ue_mib_nbiot_reset(srslte_ue_mib_nbiot_t* q) +void srsran_ue_mib_nbiot_reset(srsran_ue_mib_nbiot_t* q) { q->frame_cnt = 0; - srslte_npbch_decode_reset(&q->npbch); + srsran_npbch_decode_reset(&q->npbch); } -int srslte_ue_mib_nbiot_decode(srslte_ue_mib_nbiot_t* q, +int srsran_ue_mib_nbiot_decode(srsran_ue_mib_nbiot_t* q, cf_t* input, uint8_t* bch_payload, uint32_t* nof_tx_ports, int* sfn_offset) { // Run FFT for the symbols - srslte_ofdm_rx_sf(&q->fft); + srsran_ofdm_rx_sf(&q->fft); // Get channel estimates of sf idx #0 for each port - if (srslte_chest_dl_nbiot_estimate(&q->chest, q->sf_symbols, q->ce, 0) < 0) { - return SRSLTE_ERROR; + if (srsran_chest_dl_nbiot_estimate(&q->chest, q->sf_symbols, q->ce, 0) < 0) { + return SRSRAN_ERROR; } // Reset decoder if we missed a NPBCH TTI - if (q->frame_cnt > SRSLTE_NPBCH_NUM_FRAMES) { + if (q->frame_cnt > SRSRAN_NPBCH_NUM_FRAMES) { INFO("Resetting NPBCH decoder after %d frames", q->frame_cnt); - srslte_ue_mib_nbiot_reset(q); - return SRSLTE_UE_MIB_NBIOT_NOTFOUND; + srsran_ue_mib_nbiot_reset(q); + return SRSRAN_UE_MIB_NBIOT_NOTFOUND; } // Decode NPBCH - if (SRSLTE_SUCCESS == srslte_npbch_decode_nf(&q->npbch, + if (SRSRAN_SUCCESS == srsran_npbch_decode_nf(&q->npbch, q->sf_symbols, q->ce, - srslte_chest_dl_nbiot_get_noise_estimate(&q->chest), + srsran_chest_dl_nbiot_get_noise_estimate(&q->chest), bch_payload, nof_tx_ports, sfn_offset, 0)) { DEBUG("BCH decoded ok with offset %d", *sfn_offset); - if (memcmp(bch_payload, q->last_bch_payload, SRSLTE_MIB_NB_LEN) == 0) { + if (memcmp(bch_payload, q->last_bch_payload, SRSRAN_MIB_NB_LEN) == 0) { DEBUG("BCH content equals last BCH, new counter %d", q->frame_cnt); } else { // new BCH transmitted @@ -162,104 +162,104 @@ int srslte_ue_mib_nbiot_decode(srslte_ue_mib_nbiot_t* q, if (*sfn_offset != 0) { INFO("New BCH was decoded at block offset %d. SFN may be corrupted.", *sfn_offset); } - srslte_ue_mib_nbiot_reset(q); - return SRSLTE_UE_MIB_NBIOT_FOUND; + srsran_ue_mib_nbiot_reset(q); + return SRSRAN_UE_MIB_NBIOT_FOUND; } else { // store new BCH DEBUG("New BCH transmitted after %d frames", q->frame_cnt); - memcpy(q->last_bch_payload, bch_payload, SRSLTE_MIB_NB_LEN); + memcpy(q->last_bch_payload, bch_payload, SRSRAN_MIB_NB_LEN); } } q->frame_cnt++; } - return SRSLTE_UE_MIB_NBIOT_NOTFOUND; + return SRSRAN_UE_MIB_NBIOT_NOTFOUND; } -int srslte_ue_mib_sync_nbiot_init_multi( - srslte_ue_mib_sync_nbiot_t* q, - int(recv_callback)(void*, cf_t* [SRSLTE_MAX_PORTS], uint32_t, srslte_timestamp_t*), +int srsran_ue_mib_sync_nbiot_init_multi( + srsran_ue_mib_sync_nbiot_t* q, + int(recv_callback)(void*, cf_t* [SRSRAN_MAX_PORTS], uint32_t, srsran_timestamp_t*), uint32_t nof_rx_antennas, void* stream_handler) { // Allocate memory for time re-alignment and MIB detection - for (int i = 0; i < SRSLTE_MAX_PORTS; i++) { + for (int i = 0; i < SRSRAN_MAX_PORTS; i++) { q->sf_buffer[i] = NULL; } for (int i = 0; i < nof_rx_antennas; i++) { - q->sf_buffer[i] = srslte_vec_cf_malloc(SRSLTE_SF_LEN_PRB_NBIOT * SRSLTE_NOF_SF_X_FRAME); + q->sf_buffer[i] = srsran_vec_cf_malloc(SRSRAN_SF_LEN_PRB_NBIOT * SRSRAN_NOF_SF_X_FRAME); } q->nof_rx_antennas = nof_rx_antennas; - if (srslte_ue_mib_nbiot_init(&q->ue_mib, q->sf_buffer, SRSLTE_NBIOT_MAX_PRB)) { + if (srsran_ue_mib_nbiot_init(&q->ue_mib, q->sf_buffer, SRSRAN_NBIOT_MAX_PRB)) { fprintf(stderr, "Error initiating ue_mib\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_ue_sync_nbiot_init_multi( - &q->ue_sync, SRSLTE_NBIOT_MAX_PRB, recv_callback, q->nof_rx_antennas, stream_handler)) { + if (srsran_ue_sync_nbiot_init_multi( + &q->ue_sync, SRSRAN_NBIOT_MAX_PRB, recv_callback, q->nof_rx_antennas, stream_handler)) { fprintf(stderr, "Error initiating ue_sync\n"); - srslte_ue_mib_nbiot_free(&q->ue_mib); - return SRSLTE_ERROR; + srsran_ue_mib_nbiot_free(&q->ue_mib); + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_ue_mib_sync_nbiot_set_cell(srslte_ue_mib_sync_nbiot_t* q, srslte_nbiot_cell_t cell) +int srsran_ue_mib_sync_nbiot_set_cell(srsran_ue_mib_sync_nbiot_t* q, srsran_nbiot_cell_t cell) { - if (srslte_ue_mib_nbiot_set_cell(&q->ue_mib, cell)) { + if (srsran_ue_mib_nbiot_set_cell(&q->ue_mib, cell)) { fprintf(stderr, "Error initiating ue_mib\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_ue_sync_nbiot_set_cell(&q->ue_sync, cell)) { + if (srsran_ue_sync_nbiot_set_cell(&q->ue_sync, cell)) { fprintf(stderr, "Error initiating ue_sync\n"); - srslte_ue_mib_nbiot_free(&q->ue_mib); - return SRSLTE_ERROR; + srsran_ue_mib_nbiot_free(&q->ue_mib); + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -void srslte_ue_mib_sync_nbiot_free(srslte_ue_mib_sync_nbiot_t* q) +void srsran_ue_mib_sync_nbiot_free(srsran_ue_mib_sync_nbiot_t* q) { - srslte_ue_mib_nbiot_free(&q->ue_mib); - srslte_ue_sync_nbiot_free(&q->ue_sync); + srsran_ue_mib_nbiot_free(&q->ue_mib); + srsran_ue_sync_nbiot_free(&q->ue_sync); } -void srslte_ue_mib_sync_nbiot_reset(srslte_ue_mib_sync_nbiot_t* q) +void srsran_ue_mib_sync_nbiot_reset(srsran_ue_mib_sync_nbiot_t* q) { - srslte_ue_mib_nbiot_reset(&q->ue_mib); - srslte_ue_sync_nbiot_reset(&q->ue_sync); + srsran_ue_mib_nbiot_reset(&q->ue_mib); + srsran_ue_sync_nbiot_reset(&q->ue_sync); } -int srslte_ue_mib_sync_nbiot_decode(srslte_ue_mib_sync_nbiot_t* q, +int srsran_ue_mib_sync_nbiot_decode(srsran_ue_mib_sync_nbiot_t* q, uint32_t max_frames_timeout, uint8_t* bch_payload, uint32_t* nof_tx_ports, int* sfn_offset) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; uint32_t nof_frames = 0; - int mib_ret = SRSLTE_UE_MIB_NBIOT_NOTFOUND; + int mib_ret = SRSRAN_UE_MIB_NBIOT_NOTFOUND; if (q == NULL) { return ret; } do { - mib_ret = SRSLTE_UE_MIB_NBIOT_NOTFOUND; - ret = srslte_ue_sync_nbiot_zerocopy_multi(&q->ue_sync, q->sf_buffer); + mib_ret = SRSRAN_UE_MIB_NBIOT_NOTFOUND; + ret = srsran_ue_sync_nbiot_zerocopy_multi(&q->ue_sync, q->sf_buffer); if (ret < 0) { - fprintf(stderr, "Error calling srslte_ue_sync_nbiot_zerocopy_multi()\n"); + fprintf(stderr, "Error calling srsran_ue_sync_nbiot_zerocopy_multi()\n"); break; } - if (srslte_ue_sync_nbiot_get_sfidx(&q->ue_sync) == 0) { - mib_ret = srslte_ue_mib_nbiot_decode(&q->ue_mib, NULL, bch_payload, nof_tx_ports, sfn_offset); + if (srsran_ue_sync_nbiot_get_sfidx(&q->ue_sync) == 0) { + mib_ret = srsran_ue_mib_nbiot_decode(&q->ue_mib, NULL, bch_payload, nof_tx_ports, sfn_offset); if (mib_ret < 0) { DEBUG("Resetting NPBCH decoder after %d frames", q->ue_mib.frame_cnt); - srslte_ue_mib_nbiot_reset(&q->ue_mib); + srsran_ue_mib_nbiot_reset(&q->ue_mib); } nof_frames++; } - } while (mib_ret == SRSLTE_UE_MIB_NBIOT_NOTFOUND && nof_frames < max_frames_timeout); + } while (mib_ret == SRSRAN_UE_MIB_NBIOT_NOTFOUND && nof_frames < max_frames_timeout); return mib_ret; } diff --git a/lib/src/phy/ue/ue_mib_sl.c b/lib/src/phy/ue/ue_mib_sl.c index 1721afeda..c6b08b564 100644 --- a/lib/src/phy/ue/ue_mib_sl.c +++ b/lib/src/phy/ue/ue_mib_sl.c @@ -2,30 +2,30 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of * the distribution. * */ -#include -#include -#include +#include +#include +#include #include #include -#include -#include +#include +#include -int srslte_ue_mib_sl_set(srslte_ue_mib_sl_t* q, - uint32_t nof_prb, - uint32_t tdd_config, - uint32_t direct_frame_number, - uint32_t direct_subframe_number, - bool in_coverage) +int srsran_ue_mib_sl_set(srsran_ue_mib_sl_t* q, + uint32_t nof_prb, + uint32_t tdd_config, + uint32_t direct_frame_number, + uint32_t direct_subframe_number, + bool in_coverage) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL) { switch (nof_prb) { @@ -49,41 +49,41 @@ int srslte_ue_mib_sl_set(srslte_ue_mib_sl_t* q, break; default: printf("Invalid bandwidth\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } q->tdd_config_sl_r12 = tdd_config; q->direct_frame_number_r12 = direct_frame_number; q->direct_subframe_number_r12 = direct_subframe_number; q->in_coverage_r12 = in_coverage; - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } -void srslte_ue_mib_sl_pack(srslte_ue_mib_sl_t *q, uint8_t *msg) +void srsran_ue_mib_sl_pack(srsran_ue_mib_sl_t* q, uint8_t* msg) { - bzero(msg, sizeof(uint8_t) * SRSLTE_MIB_SL_MAX_LEN); - srslte_bit_unpack(q->sl_bandwidth_r12, &msg, 3); - srslte_bit_unpack(q->tdd_config_sl_r12, &msg, 3); - srslte_bit_unpack(q->direct_frame_number_r12, &msg, 10); - srslte_bit_unpack(q->direct_subframe_number_r12, &msg, 4); - srslte_bit_unpack((uint32_t)q->in_coverage_r12, &msg, 1); + bzero(msg, sizeof(uint8_t) * SRSRAN_MIB_SL_MAX_LEN); + srsran_bit_unpack(q->sl_bandwidth_r12, &msg, 3); + srsran_bit_unpack(q->tdd_config_sl_r12, &msg, 3); + srsran_bit_unpack(q->direct_frame_number_r12, &msg, 10); + srsran_bit_unpack(q->direct_subframe_number_r12, &msg, 4); + srsran_bit_unpack((uint32_t)q->in_coverage_r12, &msg, 1); } -void srlste_ue_mib_sl_unpack(srslte_ue_mib_sl_t *q, uint8_t *msg) +void srlste_ue_mib_sl_unpack(srsran_ue_mib_sl_t* q, uint8_t* msg) { - q->sl_bandwidth_r12 = srslte_bit_pack(&msg, 3); - q->tdd_config_sl_r12 = srslte_bit_pack(&msg, 3); - q->direct_frame_number_r12 = srslte_bit_pack(&msg, 10); - q->direct_subframe_number_r12 = srslte_bit_pack(&msg, 4); - q->in_coverage_r12 = (bool)srslte_bit_pack(&msg, 1); + q->sl_bandwidth_r12 = srsran_bit_pack(&msg, 3); + q->tdd_config_sl_r12 = srsran_bit_pack(&msg, 3); + q->direct_frame_number_r12 = srsran_bit_pack(&msg, 10); + q->direct_subframe_number_r12 = srsran_bit_pack(&msg, 4); + q->in_coverage_r12 = (bool)srsran_bit_pack(&msg, 1); } -void srslte_ue_mib_sl_free(srslte_ue_mib_sl_t* q) +void srsran_ue_mib_sl_free(srsran_ue_mib_sl_t* q) { if (q != NULL) { - bzero(q, sizeof(srslte_ue_mib_sl_t)); + bzero(q, sizeof(srsran_ue_mib_sl_t)); } } \ No newline at end of file diff --git a/lib/src/phy/ue/ue_sync.c b/lib/src/phy/ue/ue_sync.c index 43d2543d1..7868881d7 100644 --- a/lib/src/phy/ue/ue_sync.c +++ b/lib/src/phy/ue/ue_sync.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,7 +10,7 @@ * */ -#include "srslte/srslte.h" +#include "srsran/srsran.h" #include #include #include @@ -18,11 +18,11 @@ #include #include -#include "srslte/phy/ue/ue_sync.h" +#include "srsran/phy/ue/ue_sync.h" -#include "srslte/phy/io/filesource.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/io/filesource.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" #define MAX_TIME_OFFSET 128 @@ -31,53 +31,53 @@ #define FIND_NOF_AVG_FRAMES 4 #define PSS_OFFSET \ - (q->sf_len / 2 + ((q->cell.frame_type == SRSLTE_FDD) \ + (q->sf_len / 2 + ((q->cell.frame_type == SRSRAN_FDD) \ ? 0 \ - : ((SRSLTE_CP_NSYMB(q->cell.cp) - 3) * SRSLTE_SYMBOL_SZ(q->fft_size, q->cell.cp)))) + : ((SRSRAN_CP_NSYMB(q->cell.cp) - 3) * SRSRAN_SYMBOL_SZ(q->fft_size, q->cell.cp)))) #define DUMMY_BUFFER_NUM_SAMPLES (15 * 2048 / 2) static cf_t dummy_buffer0[DUMMY_BUFFER_NUM_SAMPLES]; static cf_t dummy_buffer1[DUMMY_BUFFER_NUM_SAMPLES]; -static cf_t* dummy_offset_buffer[SRSLTE_MAX_CHANNELS] = {dummy_buffer0, dummy_buffer1, dummy_buffer1, dummy_buffer1}; +static cf_t* dummy_offset_buffer[SRSRAN_MAX_CHANNELS] = {dummy_buffer0, dummy_buffer1, dummy_buffer1, dummy_buffer1}; -int srslte_ue_sync_init_file(srslte_ue_sync_t* q, uint32_t nof_prb, char* file_name, int offset_time, float offset_freq) +int srsran_ue_sync_init_file(srsran_ue_sync_t* q, uint32_t nof_prb, char* file_name, int offset_time, float offset_freq) { - return srslte_ue_sync_init_file_multi(q, nof_prb, file_name, offset_time, offset_freq, 1); + return srsran_ue_sync_init_file_multi(q, nof_prb, file_name, offset_time, offset_freq, 1); } -void srslte_ue_sync_file_wrap(srslte_ue_sync_t* q, bool enable) +void srsran_ue_sync_file_wrap(srsran_ue_sync_t* q, bool enable) { q->file_wrap_enable = enable; } -int srslte_ue_sync_init_file_multi(srslte_ue_sync_t* q, +int srsran_ue_sync_init_file_multi(srsran_ue_sync_t* q, uint32_t nof_prb, char* file_name, int offset_time, float offset_freq, uint32_t nof_rx_ant) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; - if (q != NULL && file_name != NULL && srslte_nofprb_isvalid(nof_prb)) { - ret = SRSLTE_ERROR; - bzero(q, sizeof(srslte_ue_sync_t)); + if (q != NULL && file_name != NULL && srsran_nofprb_isvalid(nof_prb)) { + ret = SRSRAN_ERROR; + bzero(q, sizeof(srsran_ue_sync_t)); q->file_mode = true; q->file_wrap_enable = true; - q->sf_len = SRSLTE_SF_LEN(srslte_symbol_sz(nof_prb)); + q->sf_len = SRSRAN_SF_LEN(srsran_symbol_sz(nof_prb)); q->file_cfo = -offset_freq; - q->fft_size = srslte_symbol_sz(nof_prb); + q->fft_size = srsran_symbol_sz(nof_prb); q->nof_rx_antennas = nof_rx_ant; q->cfo_correct_enable_find = false; q->cfo_correct_enable_track = true; - if (srslte_cfo_init(&q->file_cfo_correct, 2 * q->sf_len)) { + if (srsran_cfo_init(&q->file_cfo_correct, 2 * q->sf_len)) { ERROR("Error initiating CFO"); goto clean_exit; } - if (srslte_filesource_init(&q->file_source, file_name, SRSLTE_COMPLEX_FLOAT_BIN)) { + if (srsran_filesource_init(&q->file_source, file_name, SRSRAN_COMPLEX_FLOAT_BIN)) { ERROR("Error opening file %s", file_name); goto clean_exit; } @@ -85,40 +85,40 @@ int srslte_ue_sync_init_file_multi(srslte_ue_sync_t* q, INFO("Offseting input file by %d samples and %.1f kHz", offset_time, offset_freq / 1000); if (offset_time) { - cf_t* file_offset_buffer = srslte_vec_cf_malloc(offset_time * nof_rx_ant); + cf_t* file_offset_buffer = srsran_vec_cf_malloc(offset_time * nof_rx_ant); if (!file_offset_buffer) { perror("malloc"); goto clean_exit; } - srslte_filesource_read(&q->file_source, file_offset_buffer, offset_time * nof_rx_ant); + srsran_filesource_read(&q->file_source, file_offset_buffer, offset_time * nof_rx_ant); free(file_offset_buffer); } - srslte_ue_sync_cfo_reset(q, 0.0f); - srslte_ue_sync_reset(q); + srsran_ue_sync_cfo_reset(q, 0.0f); + srsran_ue_sync_reset(q); - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } clean_exit: - if (ret == SRSLTE_ERROR) { - srslte_ue_sync_free(q); + if (ret == SRSRAN_ERROR) { + srsran_ue_sync_free(q); } return ret; } -void srslte_ue_sync_cfo_reset(srslte_ue_sync_t* q, float init_cfo_hz) +void srsran_ue_sync_cfo_reset(srsran_ue_sync_t* q, float init_cfo_hz) { q->cfo_is_copied = false; q->cfo_current_value = init_cfo_hz / 15e3f; - srslte_sync_cfo_reset(&q->strack, init_cfo_hz); - srslte_sync_cfo_reset(&q->sfind, init_cfo_hz); + srsran_sync_cfo_reset(&q->strack, init_cfo_hz); + srsran_sync_cfo_reset(&q->sfind, init_cfo_hz); } -void srslte_ue_sync_reset(srslte_ue_sync_t* q) +void srsran_ue_sync_reset(srsran_ue_sync_t* q) { if (!q->file_mode && q->mode == SYNC_MODE_PSS) { - srslte_sync_reset(&q->sfind); - srslte_sync_reset(&q->strack); + srsran_sync_reset(&q->sfind); + srsran_sync_reset(&q->strack); } else { q->sf_idx = 9; } @@ -132,87 +132,87 @@ void srslte_ue_sync_reset(srslte_ue_sync_t* q) q->frame_find_cnt = 0; } -int srslte_ue_sync_start_agc(srslte_ue_sync_t* q, - SRSLTE_AGC_CALLBACK(set_gain_callback), +int srsran_ue_sync_start_agc(srsran_ue_sync_t* q, + SRSRAN_AGC_CALLBACK(set_gain_callback), float min_gain_db, float max_gain_db, float init_gain_value_db) { - int n = srslte_agc_init_uhd(&q->agc, SRSLTE_AGC_MODE_PEAK_AMPLITUDE, 0, set_gain_callback, q->stream); + int n = srsran_agc_init_uhd(&q->agc, SRSRAN_AGC_MODE_PEAK_AMPLITUDE, 0, set_gain_callback, q->stream); q->do_agc = n == 0 ? true : false; if (q->do_agc) { - srslte_agc_set_gain_range(&q->agc, min_gain_db, max_gain_db); - srslte_agc_set_gain(&q->agc, init_gain_value_db); - srslte_ue_sync_set_agc_period(q, 4); + srsran_agc_set_gain_range(&q->agc, min_gain_db, max_gain_db); + srsran_agc_set_gain(&q->agc, init_gain_value_db); + srsran_ue_sync_set_agc_period(q, 4); } return n; } -int recv_callback_multi_to_single(void* h, cf_t* x[SRSLTE_MAX_CHANNELS], uint32_t nsamples, srslte_timestamp_t* t) +int recv_callback_multi_to_single(void* h, cf_t* x[SRSRAN_MAX_CHANNELS], uint32_t nsamples, srsran_timestamp_t* t) { - srslte_ue_sync_t* q = (srslte_ue_sync_t*)h; + srsran_ue_sync_t* q = (srsran_ue_sync_t*)h; return q->recv_callback_single(q->stream_single, (void*)x[0], nsamples, t); } -int srslte_ue_sync_init(srslte_ue_sync_t* q, +int srsran_ue_sync_init(srsran_ue_sync_t* q, uint32_t max_prb, bool search_cell, - int(recv_callback)(void*, void*, uint32_t, srslte_timestamp_t*), + int(recv_callback)(void*, void*, uint32_t, srsran_timestamp_t*), void* stream_handler) { - int ret = srslte_ue_sync_init_multi(q, max_prb, search_cell, recv_callback_multi_to_single, 1, (void*)q); + int ret = srsran_ue_sync_init_multi(q, max_prb, search_cell, recv_callback_multi_to_single, 1, (void*)q); q->recv_callback_single = recv_callback; q->stream_single = stream_handler; return ret; } -int srslte_ue_sync_init_multi(srslte_ue_sync_t* q, +int srsran_ue_sync_init_multi(srsran_ue_sync_t* q, uint32_t max_prb, bool search_cell, - int(recv_callback)(void*, cf_t* [SRSLTE_MAX_CHANNELS], uint32_t, srslte_timestamp_t*), + int(recv_callback)(void*, cf_t* [SRSRAN_MAX_CHANNELS], uint32_t, srsran_timestamp_t*), uint32_t nof_rx_antennas, void* stream_handler) { - return srslte_ue_sync_init_multi_decim(q, max_prb, search_cell, recv_callback, nof_rx_antennas, stream_handler, 1); + return srsran_ue_sync_init_multi_decim(q, max_prb, search_cell, recv_callback, nof_rx_antennas, stream_handler, 1); } -int srslte_ue_sync_init_multi_decim( - srslte_ue_sync_t* q, +int srsran_ue_sync_init_multi_decim( + srsran_ue_sync_t* q, uint32_t max_prb, bool search_cell, - int(recv_callback)(void*, cf_t* [SRSLTE_MAX_CHANNELS], uint32_t, srslte_timestamp_t*), + int(recv_callback)(void*, cf_t* [SRSRAN_MAX_CHANNELS], uint32_t, srsran_timestamp_t*), uint32_t nof_rx_antennas, void* stream_handler, int decimate) { - return srslte_ue_sync_init_multi_decim_mode( + return srsran_ue_sync_init_multi_decim_mode( q, max_prb, search_cell, recv_callback, nof_rx_antennas, stream_handler, 1, SYNC_MODE_PSS); } -int srslte_ue_sync_init_multi_decim_mode( - srslte_ue_sync_t* q, +int srsran_ue_sync_init_multi_decim_mode( + srsran_ue_sync_t* q, uint32_t max_prb, bool search_cell, - int(recv_callback)(void*, cf_t* [SRSLTE_MAX_CHANNELS], uint32_t, srslte_timestamp_t*), + int(recv_callback)(void*, cf_t* [SRSRAN_MAX_CHANNELS], uint32_t, srsran_timestamp_t*), uint32_t nof_rx_antennas, void* stream_handler, int decimate, - srslte_ue_sync_mode_t mode) + srsran_ue_sync_mode_t mode) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; - if (q != NULL && stream_handler != NULL && nof_rx_antennas <= SRSLTE_MAX_CHANNELS && recv_callback != NULL) { - ret = SRSLTE_ERROR; + if (q != NULL && stream_handler != NULL && nof_rx_antennas <= SRSRAN_MAX_CHANNELS && recv_callback != NULL) { + ret = SRSRAN_ERROR; // int decimate = q->decimate; - bzero(q, sizeof(srslte_ue_sync_t)); + bzero(q, sizeof(srsran_ue_sync_t)); q->decimate = decimate; q->mode = mode; q->stream = stream_handler; q->recv_callback = recv_callback; q->nof_rx_antennas = nof_rx_antennas; - q->fft_size = srslte_symbol_sz(max_prb); - q->sf_len = SRSLTE_SF_LEN(q->fft_size); + q->fft_size = srsran_symbol_sz(max_prb); + q->sf_len = SRSRAN_SF_LEN(q->fft_size); q->file_mode = false; q->agc_period = 0; q->sample_offset_correct_period = DEFAULT_SAMPLE_OFFSET_CORRECT_PERIOD; @@ -248,19 +248,19 @@ int srslte_ue_sync_init_multi_decim_mode( } if (q->mode == SYNC_MODE_PSS) { - if (srslte_sync_init_decim(&q->sfind, q->frame_len, q->frame_len, q->fft_size, q->decimate)) { + if (srsran_sync_init_decim(&q->sfind, q->frame_len, q->frame_len, q->fft_size, q->decimate)) { ERROR("Error initiating sync find"); goto clean_exit; } if (search_cell) { - if (srslte_sync_init(&q->strack, q->frame_len, TRACK_FRAME_SIZE, q->fft_size)) { + if (srsran_sync_init(&q->strack, q->frame_len, TRACK_FRAME_SIZE, q->fft_size)) { ERROR("Error initiating sync track"); goto clean_exit; } } else { - if (srslte_sync_init(&q->strack, + if (srsran_sync_init(&q->strack, q->frame_len, - SRSLTE_MAX(TRACK_FRAME_SIZE, SRSLTE_CP_LEN_NORM(1, q->fft_size)), + SRSRAN_MAX(TRACK_FRAME_SIZE, SRSRAN_CP_LEN_NORM(1, q->fft_size)), q->fft_size)) { ERROR("Error initiating sync track"); goto clean_exit; @@ -268,68 +268,68 @@ int srslte_ue_sync_init_multi_decim_mode( } // Configure FIND and TRACK sync objects behaviour (this configuration is always the same) - srslte_sync_set_cfo_i_enable(&q->sfind, false); - srslte_sync_set_cfo_pss_enable(&q->sfind, true); - srslte_sync_set_pss_filt_enable(&q->sfind, true); - srslte_sync_set_sss_eq_enable(&q->sfind, false); + srsran_sync_set_cfo_i_enable(&q->sfind, false); + srsran_sync_set_cfo_pss_enable(&q->sfind, true); + srsran_sync_set_pss_filt_enable(&q->sfind, true); + srsran_sync_set_sss_eq_enable(&q->sfind, false); // During track, we do CFO correction outside the sync object - srslte_sync_set_cfo_i_enable(&q->strack, false); - srslte_sync_set_cfo_pss_enable(&q->strack, true); - srslte_sync_set_pss_filt_enable(&q->strack, true); - srslte_sync_set_sss_eq_enable(&q->strack, false); + srsran_sync_set_cfo_i_enable(&q->strack, false); + srsran_sync_set_cfo_pss_enable(&q->strack, true); + srsran_sync_set_pss_filt_enable(&q->strack, true); + srsran_sync_set_sss_eq_enable(&q->strack, false); // TODO: CP detection not working very well. Not supporting Extended CP right now - srslte_sync_cp_en(&q->strack, false); - srslte_sync_cp_en(&q->sfind, false); + srsran_sync_cp_en(&q->strack, false); + srsran_sync_cp_en(&q->sfind, false); // Enable SSS on find and disable in track - srslte_sync_sss_en(&q->sfind, true); - srslte_sync_sss_en(&q->strack, false); + srsran_sync_sss_en(&q->sfind, true); + srsran_sync_sss_en(&q->strack, false); } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } clean_exit: - if (ret == SRSLTE_ERROR) { - srslte_ue_sync_free(q); + if (ret == SRSRAN_ERROR) { + srsran_ue_sync_free(q); } return ret; } -uint32_t srslte_ue_sync_sf_len(srslte_ue_sync_t* q) +uint32_t srsran_ue_sync_sf_len(srsran_ue_sync_t* q) { return q->frame_len; } -void srslte_ue_sync_free(srslte_ue_sync_t* q) +void srsran_ue_sync_free(srsran_ue_sync_t* q) { if (q->do_agc) { - srslte_agc_free(&q->agc); + srsran_agc_free(&q->agc); } if (!q->file_mode && q->mode == SYNC_MODE_PSS) { - srslte_sync_free(&q->sfind); - srslte_sync_free(&q->strack); + srsran_sync_free(&q->sfind); + srsran_sync_free(&q->strack); } else { - srslte_filesource_free(&q->file_source); + srsran_filesource_free(&q->file_source); } - bzero(q, sizeof(srslte_ue_sync_t)); + bzero(q, sizeof(srsran_ue_sync_t)); } -int srslte_ue_sync_set_cell(srslte_ue_sync_t* q, srslte_cell_t cell) +int srsran_ue_sync_set_cell(srsran_ue_sync_t* q, srsran_cell_t cell) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; - if (q != NULL && srslte_nofprb_isvalid(cell.nof_prb)) { + if (q != NULL && srsran_nofprb_isvalid(cell.nof_prb)) { if (cell.nof_prb > q->max_prb) { ERROR("Error in ue_sync_set_cell(): cell.nof_prb must be lower than initialized"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } q->cell = cell; - q->fft_size = srslte_symbol_sz(q->cell.nof_prb); - q->sf_len = SRSLTE_SF_LEN(q->fft_size); + q->fft_size = srsran_symbol_sz(q->cell.nof_prb); + q->sf_len = SRSRAN_SF_LEN(q->fft_size); if (cell.id == 1000) { /* If the cell is unkown, we search PSS/SSS in 5 ms */ @@ -347,22 +347,22 @@ int srslte_ue_sync_set_cell(srslte_ue_sync_t* q, srslte_cell_t cell) q->decimate = 1; } - if (srslte_sync_resize(&q->sfind, q->frame_len, q->frame_len, q->fft_size)) { + if (srsran_sync_resize(&q->sfind, q->frame_len, q->frame_len, q->fft_size)) { ERROR("Error setting cell sync find"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (cell.id == 1000) { - if (srslte_sync_resize(&q->strack, q->frame_len, TRACK_FRAME_SIZE, q->fft_size)) { + if (srsran_sync_resize(&q->strack, q->frame_len, TRACK_FRAME_SIZE, q->fft_size)) { ERROR("Error setting cell sync track"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } else { - if (srslte_sync_resize(&q->strack, + if (srsran_sync_resize(&q->strack, q->frame_len, - SRSLTE_MAX(TRACK_FRAME_SIZE, SRSLTE_CP_LEN_NORM(1, q->fft_size)), + SRSRAN_MAX(TRACK_FRAME_SIZE, SRSRAN_CP_LEN_NORM(1, q->fft_size)), q->fft_size)) { ERROR("Error setting cell sync track"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } @@ -371,79 +371,79 @@ int srslte_ue_sync_set_cell(srslte_ue_sync_t* q, srslte_cell_t cell) if (cell.id == 1000) { q->nof_avg_find_frames = FIND_NOF_AVG_FRAMES; - srslte_sync_set_cfo_ema_alpha(&q->sfind, 0.8); - srslte_sync_set_cfo_ema_alpha(&q->strack, 0.1); + srsran_sync_set_cfo_ema_alpha(&q->sfind, 0.8); + srsran_sync_set_cfo_ema_alpha(&q->strack, 0.1); - srslte_sync_set_em_alpha(&q->sfind, 1); + srsran_sync_set_em_alpha(&q->sfind, 1); - srslte_sync_set_threshold(&q->sfind, 2.0); - srslte_sync_set_threshold(&q->strack, 1.2); + srsran_sync_set_threshold(&q->sfind, 2.0); + srsran_sync_set_threshold(&q->strack, 1.2); - srslte_sync_set_cfo_ema_alpha(&q->sfind, 0.1); - srslte_sync_set_cfo_ema_alpha(&q->strack, 0.1); + srsran_sync_set_cfo_ema_alpha(&q->sfind, 0.1); + srsran_sync_set_cfo_ema_alpha(&q->strack, 0.1); } else { q->sfind.cp = cell.cp; q->strack.cp = cell.cp; - srslte_sync_set_frame_type(&q->sfind, cell.frame_type); - srslte_sync_set_frame_type(&q->strack, cell.frame_type); + srsran_sync_set_frame_type(&q->sfind, cell.frame_type); + srsran_sync_set_frame_type(&q->strack, cell.frame_type); - srslte_sync_set_N_id_2(&q->sfind, cell.id % 3); - srslte_sync_set_N_id_2(&q->strack, cell.id % 3); + srsran_sync_set_N_id_2(&q->sfind, cell.id % 3); + srsran_sync_set_N_id_2(&q->strack, cell.id % 3); - srslte_sync_set_N_id_1(&q->sfind, cell.id / 3); + srsran_sync_set_N_id_1(&q->sfind, cell.id / 3); // track does not correlate SSS so no need to generate sequences - srslte_sync_set_cfo_ema_alpha(&q->sfind, 0.1); - srslte_sync_set_cfo_ema_alpha(&q->strack, DEFAULT_CFO_EMA_TRACK); + srsran_sync_set_cfo_ema_alpha(&q->sfind, 0.1); + srsran_sync_set_cfo_ema_alpha(&q->strack, DEFAULT_CFO_EMA_TRACK); /* In find phase and if the cell is known, do not average pss correlation * because we only capture 1 subframe and do not know where the peak is. */ q->nof_avg_find_frames = 1; - srslte_sync_set_em_alpha(&q->sfind, 1); - srslte_sync_set_threshold(&q->sfind, 3.0); + srsran_sync_set_em_alpha(&q->sfind, 1); + srsran_sync_set_threshold(&q->sfind, 3.0); - srslte_sync_set_em_alpha(&q->strack, 0.0); - srslte_sync_set_threshold(&q->strack, 1.5); + srsran_sync_set_em_alpha(&q->strack, 0.0); + srsran_sync_set_threshold(&q->strack, 1.5); } // When cell is unknown, do CP CFO correction - srslte_sync_set_cfo_cp_enable(&q->sfind, true, q->frame_len < 10000 ? 14 : 3); + srsran_sync_set_cfo_cp_enable(&q->sfind, true, q->frame_len < 10000 ? 14 : 3); q->cfo_correct_enable_find = false; } - srslte_ue_sync_reset(q); + srsran_ue_sync_reset(q); - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } -void srslte_ue_sync_set_nof_find_frames(srslte_ue_sync_t* q, uint32_t nof_frames) +void srsran_ue_sync_set_nof_find_frames(srsran_ue_sync_t* q, uint32_t nof_frames) { q->nof_avg_find_frames = nof_frames; } -void srslte_ue_sync_set_frame_type(srslte_ue_sync_t* q, srslte_frame_type_t frame_type) +void srsran_ue_sync_set_frame_type(srsran_ue_sync_t* q, srsran_frame_type_t frame_type) { - srslte_sync_set_frame_type(&q->strack, frame_type); - srslte_sync_set_frame_type(&q->sfind, frame_type); + srsran_sync_set_frame_type(&q->strack, frame_type); + srsran_sync_set_frame_type(&q->sfind, frame_type); } -srslte_frame_type_t srslte_ue_sync_get_frame_type(srslte_ue_sync_t* q) +srsran_frame_type_t srsran_ue_sync_get_frame_type(srsran_ue_sync_t* q) { return q->sfind.frame_type; } -void srslte_ue_sync_get_last_timestamp(srslte_ue_sync_t* q, srslte_timestamp_t* timestamp) +void srsran_ue_sync_get_last_timestamp(srsran_ue_sync_t* q, srsran_timestamp_t* timestamp) { *timestamp = q->last_timestamp; } -void srslte_ue_sync_set_cfo_loop_bw(srslte_ue_sync_t* q, +void srsran_ue_sync_set_cfo_loop_bw(srsran_ue_sync_t* q, float bw_pss, float bw_ref, float pss_tol, @@ -459,12 +459,12 @@ void srslte_ue_sync_set_cfo_loop_bw(srslte_ue_sync_t* q, q->pss_stable_timeout = pss_stable_conv_time; } -void srslte_ue_sync_set_cfo_ema(srslte_ue_sync_t* q, float ema) +void srsran_ue_sync_set_cfo_ema(srsran_ue_sync_t* q, float ema) { - srslte_sync_set_cfo_ema_alpha(&q->strack, ema); + srsran_sync_set_cfo_ema_alpha(&q->strack, ema); } -void srslte_ue_sync_set_cfo_ref(srslte_ue_sync_t* q, float ref_cfo) +void srsran_ue_sync_set_cfo_ref(srsran_ue_sync_t* q, float ref_cfo) { // Accept REF-based CFO adjustments only after PSS CFO is stable if (q->pss_is_stable) { @@ -477,89 +477,89 @@ void srslte_ue_sync_set_cfo_ref(srslte_ue_sync_t* q, float ref_cfo) } } -uint32_t srslte_ue_sync_get_sfn(srslte_ue_sync_t* q) +uint32_t srsran_ue_sync_get_sfn(srsran_ue_sync_t* q) { return q->frame_number; } -uint32_t srslte_ue_sync_get_sfidx(srslte_ue_sync_t* q) +uint32_t srsran_ue_sync_get_sfidx(srsran_ue_sync_t* q) { return q->sf_idx; } -void srslte_ue_sync_set_cfo_i_enable(srslte_ue_sync_t* q, bool enable) +void srsran_ue_sync_set_cfo_i_enable(srsran_ue_sync_t* q, bool enable) { printf("Warning: Setting integer CFO detection/correction. This is experimental!\n"); - srslte_sync_set_cfo_i_enable(&q->strack, enable); - srslte_sync_set_cfo_i_enable(&q->sfind, enable); + srsran_sync_set_cfo_i_enable(&q->strack, enable); + srsran_sync_set_cfo_i_enable(&q->sfind, enable); } -float srslte_ue_sync_get_cfo(srslte_ue_sync_t* q) +float srsran_ue_sync_get_cfo(srsran_ue_sync_t* q) { return 15000 * q->cfo_current_value; } -void srslte_ue_sync_copy_cfo(srslte_ue_sync_t* q, srslte_ue_sync_t* src_obj) +void srsran_ue_sync_copy_cfo(srsran_ue_sync_t* q, srsran_ue_sync_t* src_obj) { // Copy find object internal CFO averages - srslte_sync_copy_cfo(&q->sfind, &src_obj->sfind); + srsran_sync_copy_cfo(&q->sfind, &src_obj->sfind); // Current CFO is tracking-phase CFO of previous object q->cfo_current_value = src_obj->cfo_current_value; q->cfo_is_copied = true; } -void srslte_ue_sync_set_cfo_tol(srslte_ue_sync_t* q, float cfo_tol) +void srsran_ue_sync_set_cfo_tol(srsran_ue_sync_t* q, float cfo_tol) { - srslte_sync_set_cfo_tol(&q->strack, cfo_tol); - srslte_sync_set_cfo_tol(&q->sfind, cfo_tol); + srsran_sync_set_cfo_tol(&q->strack, cfo_tol); + srsran_sync_set_cfo_tol(&q->sfind, cfo_tol); } -float srslte_ue_sync_get_sfo(srslte_ue_sync_t* q) +float srsran_ue_sync_get_sfo(srsran_ue_sync_t* q) { return q->mean_sample_offset / 5e-3; } -int srslte_ue_sync_get_last_sample_offset(srslte_ue_sync_t* q) +int srsran_ue_sync_get_last_sample_offset(srsran_ue_sync_t* q) { return q->last_sample_offset; } -void srslte_ue_sync_set_sfo_correct_period(srslte_ue_sync_t* q, uint32_t nof_subframes) +void srsran_ue_sync_set_sfo_correct_period(srsran_ue_sync_t* q, uint32_t nof_subframes) { q->sample_offset_correct_period = nof_subframes; } -void srslte_ue_sync_set_sfo_ema(srslte_ue_sync_t* q, float ema_coefficient) +void srsran_ue_sync_set_sfo_ema(srsran_ue_sync_t* q, float ema_coefficient) { q->sfo_ema = ema_coefficient; } -void srslte_ue_sync_set_N_id_2(srslte_ue_sync_t* q, uint32_t N_id_2) +void srsran_ue_sync_set_N_id_2(srsran_ue_sync_t* q, uint32_t N_id_2) { if (!q->file_mode) { - srslte_ue_sync_reset(q); - srslte_sync_set_N_id_2(&q->strack, N_id_2); - srslte_sync_set_N_id_2(&q->sfind, N_id_2); + srsran_ue_sync_reset(q); + srsran_sync_set_N_id_2(&q->strack, N_id_2); + srsran_sync_set_N_id_2(&q->sfind, N_id_2); } } -void srslte_ue_sync_set_agc_period(srslte_ue_sync_t* q, uint32_t period) +void srsran_ue_sync_set_agc_period(srsran_ue_sync_t* q, uint32_t period) { q->agc_period = period; } -static int find_peak_ok(srslte_ue_sync_t* q, cf_t* input_buffer[SRSLTE_MAX_CHANNELS]) +static int find_peak_ok(srsran_ue_sync_t* q, cf_t* input_buffer[SRSRAN_MAX_CHANNELS]) { - if (srslte_sync_sss_detected(&q->sfind)) { + if (srsran_sync_sss_detected(&q->sfind)) { /* Get the subframe index (0 or 5) */ - q->sf_idx = (srslte_sync_get_sf_idx(&q->sfind) + q->nof_recv_sf) % 10; - } else if (srslte_sync_sss_available(&q->sfind)) { + q->sf_idx = (srsran_sync_get_sf_idx(&q->sfind) + q->nof_recv_sf) % 10; + } else if (srsran_sync_sss_available(&q->sfind)) { INFO("Found peak at %d, SSS not detected", q->peak_idx); return 0; } else { INFO("Found peak at %d, No space for SSS. Realigning frame, reading %d samples", q->peak_idx, q->peak_idx); if (q->recv_callback(q->stream, input_buffer, q->peak_idx, &q->last_timestamp) < 0) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } return 0; } @@ -568,16 +568,16 @@ static int find_peak_ok(srslte_ue_sync_t* q, cf_t* input_buffer[SRSLTE_MAX_CHANN DEBUG("Found peak %d at %d, value %.3f, Cell_id: %d CP: %s", q->frame_find_cnt, q->peak_idx, - srslte_sync_get_peak_value(&q->sfind), + srsran_sync_get_peak_value(&q->sfind), q->cell.id, - srslte_cp_string(q->cell.cp)); + srsran_cp_string(q->cell.cp)); if (q->frame_find_cnt >= q->nof_avg_find_frames || q->peak_idx < 2 * q->fft_size) { // Receive read_len samples until the start of the next subframe (different for FDD and TDD) uint32_t read_len = q->peak_idx + PSS_OFFSET; INFO("Realigning frame, reading %d samples", read_len); if (q->recv_callback(q->stream, input_buffer, read_len, &q->last_timestamp) < 0) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } /* Reset variables */ @@ -594,9 +594,9 @@ static int find_peak_ok(srslte_ue_sync_t* q, cf_t* input_buffer[SRSLTE_MAX_CHANN /* Set CFO values. Since we correct before track, the initial track state is CFO=0 Hz */ if (!q->cfo_is_copied) { - q->cfo_current_value = srslte_sync_get_cfo(&q->sfind); + q->cfo_current_value = srsran_sync_get_cfo(&q->sfind); } - srslte_sync_cfo_reset(&q->strack, 0.0f); + srsran_sync_cfo_reset(&q->strack, 0.0f); } if (q->cell.id < 1000) { @@ -606,7 +606,7 @@ static int find_peak_ok(srslte_ue_sync_t* q, cf_t* input_buffer[SRSLTE_MAX_CHANN } } -static int track_peak_ok(srslte_ue_sync_t* q, uint32_t track_idx) +static int track_peak_ok(srsran_ue_sync_t* q, uint32_t track_idx) { // Get sampling time offset q->last_sample_offset = ((int)track_idx - (int)q->strack.max_offset / 2 - (int)q->strack.fft_size); @@ -615,7 +615,7 @@ static int track_peak_ok(srslte_ue_sync_t* q, uint32_t track_idx) uint32_t frame_idx = 0; if (q->sample_offset_correct_period) { frame_idx = q->frame_ok_cnt % q->sample_offset_correct_period; - q->mean_sample_offset = SRSLTE_VEC_EMA((float)q->last_sample_offset, q->mean_sample_offset, q->sfo_ema); + q->mean_sample_offset = SRSRAN_VEC_EMA((float)q->last_sample_offset, q->mean_sample_offset, q->sfo_ema); } else { q->mean_sample_offset = q->last_sample_offset; } @@ -623,9 +623,9 @@ static int track_peak_ok(srslte_ue_sync_t* q, uint32_t track_idx) /* Adjust current CFO estimation with PSS * Since sync track has enabled only PSS-based correlation, get_cfo() returns that value only, already filtered. */ - DEBUG("TRACK: cfo_current=%f, cfo_strack=%f", 15000 * q->cfo_current_value, 15000 * srslte_sync_get_cfo(&q->strack)); - if (15000 * fabsf(srslte_sync_get_cfo(&q->strack)) > q->cfo_pss_min) { - q->cfo_current_value += srslte_sync_get_cfo(&q->strack) * q->cfo_loop_bw_pss; + DEBUG("TRACK: cfo_current=%f, cfo_strack=%f", 15000 * q->cfo_current_value, 15000 * srsran_sync_get_cfo(&q->strack)); + if (15000 * fabsf(srsran_sync_get_cfo(&q->strack)) > q->cfo_pss_min) { + q->cfo_current_value += srsran_sync_get_cfo(&q->strack) * q->cfo_loop_bw_pss; q->pss_stable_cnt = 0; q->pss_is_stable = false; } else { @@ -646,7 +646,7 @@ static int track_peak_ok(srslte_ue_sync_t* q, uint32_t track_idx) INFO("Time offset adjustment: %d samples (%.2f), mean SFO: %.2f Hz, ema=%f, length=%d", q->next_rf_sample_offset, q->mean_sample_offset, - srslte_ue_sync_get_sfo(q), + srsran_ue_sync_get_sfo(q), q->sfo_ema, q->sample_offset_correct_period); } @@ -659,7 +659,7 @@ static int track_peak_ok(srslte_ue_sync_t* q, uint32_t track_idx) DEBUG("Positive time offset %d samples.", q->next_rf_sample_offset); if (q->recv_callback(q->stream, dummy_offset_buffer, (uint32_t)q->next_rf_sample_offset, NULL) < 0) { ERROR("Error receiving from USRP"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } q->next_rf_sample_offset = 0; } @@ -671,7 +671,7 @@ static int track_peak_ok(srslte_ue_sync_t* q, uint32_t track_idx) return 1; } -static int track_peak_no(srslte_ue_sync_t* q) +static int track_peak_no(srsran_ue_sync_t* q) { /* if we missed too many PSS go back to FIND and consider this frame unsynchronized */ q->frame_no_cnt++; @@ -680,12 +680,12 @@ static int track_peak_no(srslte_ue_sync_t* q) q->state = SF_FIND; return 0; } else { - INFO("Tracking peak not found. Peak %.3f, %d lost", srslte_sync_get_peak_value(&q->strack), (int)q->frame_no_cnt); + INFO("Tracking peak not found. Peak %.3f, %d lost", srsran_sync_get_peak_value(&q->strack), (int)q->frame_no_cnt); return 1; } } -static int receive_samples(srslte_ue_sync_t* q, cf_t* input_buffer[SRSLTE_MAX_CHANNELS], const uint32_t max_num_samples) +static int receive_samples(srsran_ue_sync_t* q, cf_t* input_buffer[SRSRAN_MAX_CHANNELS], const uint32_t max_num_samples) { ///< A negative time offset means there are samples in our buffer for the next subframe bc we are sampling too fast if (q->next_rf_sample_offset < 0) { @@ -695,54 +695,54 @@ static int receive_samples(srslte_ue_sync_t* q, cf_t* input_buffer[SRSLTE_MAX_CH ///< Make sure receive buffer is big enough if (q->frame_len - q->next_rf_sample_offset > max_num_samples) { fprintf(stderr, "Receive buffer too small (%d < %d)\n", max_num_samples, q->frame_len - q->next_rf_sample_offset); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } ///< Get N subframes from the USRP getting more samples and keeping the previous samples, if any - cf_t* ptr[SRSLTE_MAX_CHANNELS] = {NULL}; + cf_t* ptr[SRSRAN_MAX_CHANNELS] = {NULL}; for (int i = 0; i < q->nof_rx_antennas; i++) { ptr[i] = &input_buffer[i][q->next_rf_sample_offset]; } if (q->recv_callback(q->stream, ptr, q->frame_len - q->next_rf_sample_offset, &q->last_timestamp) < 0) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } ///< reset time offset q->next_rf_sample_offset = 0; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } /* Returns 1 if the subframe is synchronized in time, 0 otherwise */ -int srslte_ue_sync_zerocopy(srslte_ue_sync_t* q, - cf_t* input_buffer[SRSLTE_MAX_CHANNELS], +int srsran_ue_sync_zerocopy(srsran_ue_sync_t* q, + cf_t* input_buffer[SRSRAN_MAX_CHANNELS], const uint32_t max_num_samples) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL && input_buffer != NULL) { if (q->file_mode) { - int n = srslte_filesource_read_multi(&q->file_source, (void**)input_buffer, q->sf_len, q->nof_rx_antennas); + int n = srsran_filesource_read_multi(&q->file_source, (void**)input_buffer, q->sf_len, q->nof_rx_antennas); if (n < 0) { ERROR("Error reading input file"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (n == 0) { if (q->file_wrap_enable) { - srslte_filesource_seek(&q->file_source, 0); + srsran_filesource_seek(&q->file_source, 0); q->sf_idx = 9; - n = srslte_filesource_read_multi(&q->file_source, (void**)input_buffer, q->sf_len, q->nof_rx_antennas); + n = srsran_filesource_read_multi(&q->file_source, (void**)input_buffer, q->sf_len, q->nof_rx_antennas); if (n < 0) { ERROR("Error reading input file"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } else { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } if (q->cfo_correct_enable_track) { for (int i = 0; i < q->nof_rx_antennas; i++) { - srslte_cfo_correct(&q->file_cfo_correct, input_buffer[i], input_buffer[i], q->file_cfo / 15000 / q->fft_size); + srsran_cfo_correct(&q->file_cfo_correct, input_buffer[i], input_buffer[i], q->file_cfo / 15000 / q->fft_size); } } q->sf_idx++; @@ -754,7 +754,7 @@ int srslte_ue_sync_zerocopy(srslte_ue_sync_t* q, } else { if (receive_samples(q, input_buffer, max_num_samples)) { ERROR("Error receiving samples"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } switch (q->state) { @@ -763,7 +763,7 @@ int srslte_ue_sync_zerocopy(srslte_ue_sync_t* q, if (q->cfo_correct_enable_find) { for (int i = 0; i < q->nof_rx_antennas; i++) { if (input_buffer[i]) { - srslte_cfo_correct( + srsran_cfo_correct( &q->strack.cfo_corr_frame, input_buffer[i], input_buffer[i], -q->cfo_current_value / q->fft_size); } } @@ -771,13 +771,13 @@ int srslte_ue_sync_zerocopy(srslte_ue_sync_t* q, // Run mode-specific find operation if (q->mode == SYNC_MODE_PSS) { - ret = srslte_ue_sync_run_find_pss_mode(q, input_buffer); + ret = srsran_ue_sync_run_find_pss_mode(q, input_buffer); } else if (q->mode == SYNC_MODE_GNSS) { - ret = srslte_ue_sync_run_find_gnss_mode(q, input_buffer, max_num_samples); + ret = srsran_ue_sync_run_find_gnss_mode(q, input_buffer, max_num_samples); } if (q->do_agc) { - srslte_agc_process(&q->agc, input_buffer[0], q->sf_len); + srsran_agc_process(&q->agc, input_buffer[0], q->sf_len); } break; @@ -795,16 +795,16 @@ int srslte_ue_sync_zerocopy(srslte_ue_sync_t* q, if (q->cfo_correct_enable_track) { for (int i = 0; i < q->nof_rx_antennas; i++) { if (input_buffer[i]) { - srslte_cfo_correct( + srsran_cfo_correct( &q->strack.cfo_corr_frame, input_buffer[i], input_buffer[i], -q->cfo_current_value / q->fft_size); } } } if (q->mode == SYNC_MODE_PSS) { - srslte_ue_sync_run_track_pss_mode(q, input_buffer); + srsran_ue_sync_run_track_pss_mode(q, input_buffer); } else { - srslte_ue_sync_run_track_gnss_mode(q, input_buffer); + srsran_ue_sync_run_track_gnss_mode(q, input_buffer); } break; default: @@ -815,27 +815,27 @@ int srslte_ue_sync_zerocopy(srslte_ue_sync_t* q, return ret; } -int srslte_ue_sync_run_find_pss_mode(srslte_ue_sync_t* q, cf_t* input_buffer[SRSLTE_MAX_CHANNELS]) +int srsran_ue_sync_run_find_pss_mode(srsran_ue_sync_t* q, cf_t* input_buffer[SRSRAN_MAX_CHANNELS]) { - int ret = SRSLTE_ERROR; - int n = srslte_sync_find(&q->sfind, input_buffer[0], 0, &q->peak_idx); + int ret = SRSRAN_ERROR; + int n = srsran_sync_find(&q->sfind, input_buffer[0], 0, &q->peak_idx); switch (n) { - case SRSLTE_SYNC_ERROR: + case SRSRAN_SYNC_ERROR: ERROR("Error finding correlation peak (%d)", ret); return ret; - case SRSLTE_SYNC_FOUND: + case SRSRAN_SYNC_FOUND: ret = find_peak_ok(q, input_buffer); break; - case SRSLTE_SYNC_FOUND_NOSPACE: + case SRSRAN_SYNC_FOUND_NOSPACE: /* If a peak was found but there is not enough space for SSS/CP detection, discard a few samples */ INFO("No space for SSS/CP detection. Realigning frame..."); q->recv_callback(q->stream, dummy_offset_buffer, q->frame_len / 2, NULL); - srslte_sync_reset(&q->sfind); - ret = SRSLTE_SUCCESS; + srsran_sync_reset(&q->sfind); + ret = SRSRAN_SUCCESS; break; default: - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; break; } @@ -847,21 +847,21 @@ int srslte_ue_sync_run_find_pss_mode(srslte_ue_sync_t* q, cf_t* input_buffer[SRS q->sfind.peak_value, q->sfind.cfo_cp_mean, q->sfind.cfo_pss_mean, - 15 * srslte_sync_get_cfo(&q->sfind)); + 15 * srsran_sync_get_cfo(&q->sfind)); return ret; }; -int srslte_ue_sync_run_track_pss_mode(srslte_ue_sync_t* q, cf_t* input_buffer[SRSLTE_MAX_CHANNELS]) +int srsran_ue_sync_run_track_pss_mode(srsran_ue_sync_t* q, cf_t* input_buffer[SRSRAN_MAX_CHANNELS]) { - int ret = SRSLTE_ERROR; + int ret = SRSRAN_ERROR; uint32_t track_idx = 0; /* Every SF idx 0 and 5, find peak around known position q->peak_idx */ - if ((q->sfind.frame_type == SRSLTE_FDD && (q->sf_idx == 0 || q->sf_idx == 5)) || - (q->sfind.frame_type == SRSLTE_TDD && (q->sf_idx == 1 || q->sf_idx == 6))) { + if ((q->sfind.frame_type == SRSRAN_FDD && (q->sf_idx == 0 || q->sf_idx == 5)) || + (q->sfind.frame_type == SRSRAN_TDD && (q->sf_idx == 1 || q->sf_idx == 6))) { // Process AGC every period if (q->do_agc && (q->agc_period == 0 || (q->agc_period && (q->frame_total_cnt % q->agc_period) == 0))) { - srslte_agc_process(&q->agc, input_buffer[0], q->sf_len); + srsran_agc_process(&q->agc, input_buffer[0], q->sf_len); } /* Track PSS around the expected PSS position @@ -871,29 +871,29 @@ int srslte_ue_sync_run_track_pss_mode(srslte_ue_sync_t* q, cf_t* input_buffer[SR // Expected PSS position is different for FDD and TDD uint32_t pss_idx = q->frame_len - PSS_OFFSET - q->fft_size - q->strack.max_offset / 2; - int n = srslte_sync_find(&q->strack, input_buffer[0], pss_idx, &track_idx); + int n = srsran_sync_find(&q->strack, input_buffer[0], pss_idx, &track_idx); switch (n) { - case SRSLTE_SYNC_ERROR: + case SRSRAN_SYNC_ERROR: ERROR("Error tracking correlation peak"); - return SRSLTE_ERROR; - case SRSLTE_SYNC_FOUND: + return SRSRAN_ERROR; + case SRSRAN_SYNC_FOUND: ret = track_peak_ok(q, track_idx); break; - case SRSLTE_SYNC_FOUND_NOSPACE: + case SRSRAN_SYNC_FOUND_NOSPACE: // It's very very unlikely that we fall here because this event should happen at FIND phase only ret = 0; q->state = SF_FIND; INFO("Warning: No space for SSS/CP while in tracking phase"); break; - case SRSLTE_SYNC_NOFOUND: + case SRSRAN_SYNC_NOFOUND: ret = track_peak_no(q); break; } - if (ret == SRSLTE_ERROR) { + if (ret == SRSRAN_ERROR) { ERROR("Error processing tracking peak"); q->state = SF_FIND; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } q->frame_total_cnt++; @@ -906,7 +906,7 @@ int srslte_ue_sync_run_track_pss_mode(srslte_ue_sync_t* q, cf_t* input_buffer[SR q->strack.peak_value, q->strack.cfo_cp_mean, q->strack.cfo_pss_mean, - 15 * srslte_sync_get_cfo(&q->strack)); + 15 * srsran_sync_get_cfo(&q->strack)); } else { INFO("SYNC TRACK: sf_idx=%d, ret=%d, next_state=%d", q->sf_idx, ret, q->state); } @@ -914,25 +914,25 @@ int srslte_ue_sync_run_track_pss_mode(srslte_ue_sync_t* q, cf_t* input_buffer[SR return 1; ///< 1 means subframe in sync } -int srslte_ue_sync_run_find_gnss_mode(srslte_ue_sync_t* q, - cf_t* input_buffer[SRSLTE_MAX_CHANNELS], +int srsran_ue_sync_run_find_gnss_mode(srsran_ue_sync_t* q, + cf_t* input_buffer[SRSRAN_MAX_CHANNELS], const uint32_t max_num_samples) { INFO("Calibration samples received start at %ld + %f", q->last_timestamp.full_secs, q->last_timestamp.frac_secs); // round to nearest second - srslte_timestamp_t ts_next_rx; - srslte_timestamp_copy(&ts_next_rx, &q->last_timestamp); + srsran_timestamp_t ts_next_rx; + srsran_timestamp_copy(&ts_next_rx, &q->last_timestamp); ts_next_rx.full_secs++; ts_next_rx.frac_secs = 0.0; INFO("Next desired recv at %ld + %f", ts_next_rx.full_secs, ts_next_rx.frac_secs); // get difference in time between second rx and now - srslte_timestamp_sub(&ts_next_rx, q->last_timestamp.full_secs, q->last_timestamp.frac_secs); - srslte_timestamp_sub(&ts_next_rx, 0, 0.001); ///< account for samples that have already been rx'ed + srsran_timestamp_sub(&ts_next_rx, q->last_timestamp.full_secs, q->last_timestamp.frac_secs); + srsran_timestamp_sub(&ts_next_rx, 0, 0.001); ///< account for samples that have already been rx'ed - uint64_t align_len = srslte_timestamp_uint64(&ts_next_rx, q->sf_len * 1000); + uint64_t align_len = srsran_timestamp_uint64(&ts_next_rx, q->sf_len * 1000); DEBUG("Difference between first recv is %ld + %f, realigning %" PRIu64 " samples", ts_next_rx.full_secs, @@ -942,8 +942,8 @@ int srslte_ue_sync_run_find_gnss_mode(srslte_ue_sync_t* q, // receive align_len samples into dummy_buffer, make sure to not exceed buffer len uint32_t sample_count = 0; while (sample_count < align_len) { - uint32_t actual_rx_len = SRSLTE_MIN(align_len, DUMMY_BUFFER_NUM_SAMPLES); - actual_rx_len = SRSLTE_MIN(align_len - sample_count, actual_rx_len); + uint32_t actual_rx_len = SRSRAN_MIN(align_len, DUMMY_BUFFER_NUM_SAMPLES); + actual_rx_len = SRSRAN_MIN(align_len - sample_count, actual_rx_len); q->recv_callback(q->stream, dummy_offset_buffer, actual_rx_len, &q->last_timestamp); sample_count += actual_rx_len; } @@ -953,7 +953,7 @@ int srslte_ue_sync_run_find_gnss_mode(srslte_ue_sync_t* q, // do one normal receive, the first time-aligned subframe if (receive_samples(q, input_buffer, max_num_samples)) { ERROR("Error receiving samples"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } INFO("First aligned samples received start at %ld + %f", q->last_timestamp.full_secs, q->last_timestamp.frac_secs); @@ -962,9 +962,9 @@ int srslte_ue_sync_run_find_gnss_mode(srslte_ue_sync_t* q, q->state = SF_TRACK; // calculate system timing - if (srslte_ue_sync_set_tti_from_timestamp(q, &q->last_timestamp)) { + if (srsran_ue_sync_set_tti_from_timestamp(q, &q->last_timestamp)) { ERROR("Error deriving timing from received samples"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } INFO("SYNC FIND: sfn=%d, sf_idx=%d next_state=%d", q->frame_number, q->sf_idx, q->state); @@ -973,7 +973,7 @@ int srslte_ue_sync_run_find_gnss_mode(srslte_ue_sync_t* q, } ///< The track function in GNSS mode only needs to increment the system frame number -int srslte_ue_sync_run_track_gnss_mode(srslte_ue_sync_t* q, cf_t* input_buffer[SRSLTE_MAX_CHANNELS]) +int srsran_ue_sync_run_track_gnss_mode(srsran_ue_sync_t* q, cf_t* input_buffer[SRSRAN_MAX_CHANNELS]) { INFO("TRACK samples received at %ld + %.4f", q->last_timestamp.full_secs, q->last_timestamp.frac_secs); @@ -991,7 +991,7 @@ int srslte_ue_sync_run_track_gnss_mode(srslte_ue_sync_t* q, cf_t* input_buffer[S } // update SF index - q->sf_idx = ((int)round(q->last_timestamp.frac_secs * 1e3)) % SRSLTE_NOF_SF_X_FRAME; + q->sf_idx = ((int)round(q->last_timestamp.frac_secs * 1e3)) % SRSRAN_NOF_SF_X_FRAME; INFO("SYNC TRACK: sfn=%d, sf_idx=%d, next_state=%d", q->frame_number, q->sf_idx, q->state); @@ -1002,9 +1002,9 @@ int srslte_ue_sync_run_track_gnss_mode(srslte_ue_sync_t* q, cf_t* input_buffer[S * * @param q Pointer to current object * @param rx_timestamp Pointer to receive timestamp - * @return SRSLTE_SUCCESS on success + * @return SRSRAN_SUCCESS on success */ -int srslte_ue_sync_set_tti_from_timestamp(srslte_ue_sync_t* q, srslte_timestamp_t* rx_timestamp) +int srsran_ue_sync_set_tti_from_timestamp(srsran_ue_sync_t* q, srsran_timestamp_t* rx_timestamp) { // calculate time_t of Rx time time_t t_cur = rx_timestamp->full_secs; @@ -1031,7 +1031,7 @@ int srslte_ue_sync_set_tti_from_timestamp(srslte_ue_sync_t* q, srslte_timestamp_ if (time_diff_secs < 0) { fprintf(stderr, "Time diff between Rx timestamp and reference UTC is negative. Is the timestamp correct?\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } DEBUG("time diff in s %f", time_diff_secs); @@ -1044,5 +1044,5 @@ int srslte_ue_sync_set_tti_from_timestamp(srslte_ue_sync_t* q, srslte_timestamp_ q->frame_number = ((uint32_t)floor(0.1 * (time_diff_msecs - q->sfn_offset))) % 1024; q->sf_idx = ((uint32_t)floor(time_diff_msecs - q->sfn_offset)) % 10; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } diff --git a/lib/src/phy/ue/ue_sync_nbiot.c b/lib/src/phy/ue/ue_sync_nbiot.c index 55b0f1ef5..fa6828fa4 100644 --- a/lib/src/phy/ue/ue_sync_nbiot.c +++ b/lib/src/phy/ue/ue_sync_nbiot.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,12 +10,12 @@ * */ -#include "srslte/phy/ue/ue_sync_nbiot.h" -#include "srslte/phy/io/filesource.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/ue/ue_sync_nbiot.h" +#include "srsran/phy/io/filesource.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" #include -#include +#include #include #include #include @@ -32,38 +32,38 @@ static cf_t dummy_buffer_nbiot0[15 * 2048 / 2]; static cf_t dummy_buffer_nbiot1[15 * 2048 / 2]; -static cf_t* dummy_offset_buffer_nbiot[SRSLTE_MAX_PORTS] = {dummy_buffer_nbiot0, dummy_buffer_nbiot1, NULL, NULL}; +static cf_t* dummy_offset_buffer_nbiot[SRSRAN_MAX_PORTS] = {dummy_buffer_nbiot0, dummy_buffer_nbiot1, NULL, NULL}; ///< This is a list of CFO candidates that the sync object uses to pre-compensate the received signal static const float cfo_cands[] = {0.0, 1000.0, -1000.0, 2000.0, -2000.0, 3000.0, -3000.0, 4000.0, -4000.0, 5000.0, -5000.0}; -int srslte_ue_sync_nbiot_init_file(srslte_nbiot_ue_sync_t* q, - srslte_nbiot_cell_t cell, +int srsran_ue_sync_nbiot_init_file(srsran_nbiot_ue_sync_t* q, + srsran_nbiot_cell_t cell, char* file_name, int offset_time, float offset_freq) { - return srslte_ue_sync_nbiot_init_file_multi(q, cell, file_name, offset_time, offset_freq, 1); + return srsran_ue_sync_nbiot_init_file_multi(q, cell, file_name, offset_time, offset_freq, 1); } -int srslte_ue_sync_nbiot_init_file_multi(srslte_nbiot_ue_sync_t* q, - srslte_nbiot_cell_t cell, +int srsran_ue_sync_nbiot_init_file_multi(srsran_nbiot_ue_sync_t* q, + srsran_nbiot_cell_t cell, char* file_name, int offset_time, float offset_freq, uint32_t nof_rx_ant) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; - if (q != NULL && file_name != NULL && srslte_nofprb_isvalid(cell.base.nof_prb)) { - ret = SRSLTE_ERROR; - bzero(q, sizeof(srslte_nbiot_ue_sync_t)); + if (q != NULL && file_name != NULL && srsran_nofprb_isvalid(cell.base.nof_prb)) { + ret = SRSRAN_ERROR; + bzero(q, sizeof(srsran_nbiot_ue_sync_t)); q->file_mode = true; - q->sf_len = SRSLTE_SF_LEN(srslte_symbol_sz(cell.base.nof_prb)); + q->sf_len = SRSRAN_SF_LEN(srsran_symbol_sz(cell.base.nof_prb)); q->file_cfo = -offset_freq; q->correct_cfo = true; - q->fft_size = srslte_symbol_sz(cell.base.nof_prb); + q->fft_size = srsran_symbol_sz(cell.base.nof_prb); if (nof_rx_ant != 1) { fprintf(stderr, "With file input, only single Rx antenna is supported.\n"); @@ -71,23 +71,23 @@ int srslte_ue_sync_nbiot_init_file_multi(srslte_nbiot_ue_sync_t* q, } q->nof_rx_antennas = nof_rx_ant; - if (srslte_cfo_init(&q->file_cfo_correct, 2 * q->sf_len)) { + if (srsran_cfo_init(&q->file_cfo_correct, 2 * q->sf_len)) { fprintf(stderr, "Error initiating CFO\n"); goto clean_exit; } - if (srslte_filesource_init(&q->file_source, file_name, SRSLTE_COMPLEX_FLOAT_BIN)) { + if (srsran_filesource_init(&q->file_source, file_name, SRSRAN_COMPLEX_FLOAT_BIN)) { fprintf(stderr, "Error opening file %s\n", file_name); goto clean_exit; } #if TIME_ALIGN_FROM_FILE - q->frame_len = SRSLTE_NOF_SF_X_FRAME * q->sf_len; - if (srslte_sync_nbiot_init(&q->sfind, q->frame_len, q->frame_len, q->fft_size)) { + q->frame_len = SRSRAN_NOF_SF_X_FRAME * q->sf_len; + if (srsran_sync_nbiot_init(&q->sfind, q->frame_len, q->frame_len, q->fft_size)) { fprintf(stderr, "Error initiating sync find\n"); goto clean_exit; } - int n = srslte_filesource_read(&q->file_source, dummy_buffer_nbiot0, q->frame_len); + int n = srsran_filesource_read(&q->file_source, dummy_buffer_nbiot0, q->frame_len); if (n != q->frame_len) { fprintf(stderr, "Error reading frame from file.\n"); exit(-1); @@ -95,79 +95,79 @@ int srslte_ue_sync_nbiot_init_file_multi(srslte_nbiot_ue_sync_t* q, // find NPSS and set offset time parameter to beginning of next frame uint32_t peak_idx; - if (srslte_sync_nbiot_find(&q->sfind, dummy_buffer_nbiot0, 0, &peak_idx) == SRSLTE_SYNC_ERROR) { + if (srsran_sync_nbiot_find(&q->sfind, dummy_buffer_nbiot0, 0, &peak_idx) == SRSRAN_SYNC_ERROR) { fprintf(stderr, "Error finding NPSS peak\n"); exit(-1); } - offset_time = (peak_idx - SRSLTE_NPSS_CORR_OFFSET + q->frame_len / 2) % q->frame_len; - srslte_sync_nbiot_free(&q->sfind); + offset_time = (peak_idx - SRSRAN_NPSS_CORR_OFFSET + q->frame_len / 2) % q->frame_len; + srsran_sync_nbiot_free(&q->sfind); #endif INFO("Offseting input file by %d samples and %.1f kHz", offset_time, offset_freq / 1000); - srslte_filesource_read(&q->file_source, dummy_buffer_nbiot0, offset_time); - srslte_ue_sync_nbiot_reset(q); + srsran_filesource_read(&q->file_source, dummy_buffer_nbiot0, offset_time); + srsran_ue_sync_nbiot_reset(q); - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } clean_exit: - if (ret == SRSLTE_ERROR) { - srslte_ue_sync_nbiot_free(q); + if (ret == SRSRAN_ERROR) { + srsran_ue_sync_nbiot_free(q); } return ret; } -int srslte_ue_sync_nbiot_start_agc(srslte_nbiot_ue_sync_t* q, - SRSLTE_AGC_CALLBACK(set_gain_callback), +int srsran_ue_sync_nbiot_start_agc(srsran_nbiot_ue_sync_t* q, + SRSRAN_AGC_CALLBACK(set_gain_callback), float init_gain_value) { uint32_t nframes = 0; if (q->nof_recv_sf == 1) { nframes = 10; } - int n = srslte_agc_init_uhd(&q->agc, SRSLTE_AGC_MODE_PEAK_AMPLITUDE, nframes, set_gain_callback, q->stream); + int n = srsran_agc_init_uhd(&q->agc, SRSRAN_AGC_MODE_PEAK_AMPLITUDE, nframes, set_gain_callback, q->stream); q->do_agc = n == 0 ? true : false; if (q->do_agc) { - srslte_agc_set_gain(&q->agc, init_gain_value); + srsran_agc_set_gain(&q->agc, init_gain_value); } return n; } -int recv_callback_nbiot_multi_to_single(void* h, cf_t* x[SRSLTE_MAX_PORTS], uint32_t nsamples, srslte_timestamp_t* t) +int recv_callback_nbiot_multi_to_single(void* h, cf_t* x[SRSRAN_MAX_PORTS], uint32_t nsamples, srsran_timestamp_t* t) { - srslte_nbiot_ue_sync_t* q = (srslte_nbiot_ue_sync_t*)h; + srsran_nbiot_ue_sync_t* q = (srsran_nbiot_ue_sync_t*)h; return q->recv_callback_single(q->stream_single, (void*)x[0], nsamples, t); } -int srslte_ue_sync_nbiot_init(srslte_nbiot_ue_sync_t* q, - srslte_nbiot_cell_t cell, - int(recv_callback)(void*, void*, uint32_t, srslte_timestamp_t*), +int srsran_ue_sync_nbiot_init(srsran_nbiot_ue_sync_t* q, + srsran_nbiot_cell_t cell, + int(recv_callback)(void*, void*, uint32_t, srsran_timestamp_t*), void* stream_handler) { - int ret = srslte_ue_sync_nbiot_init_multi( - q, SRSLTE_NBIOT_MAX_PRB, recv_callback_nbiot_multi_to_single, SRSLTE_NBIOT_NUM_RX_ANTENNAS, (void*)q); + int ret = srsran_ue_sync_nbiot_init_multi( + q, SRSRAN_NBIOT_MAX_PRB, recv_callback_nbiot_multi_to_single, SRSRAN_NBIOT_NUM_RX_ANTENNAS, (void*)q); q->recv_callback_single = recv_callback; q->stream_single = stream_handler; return ret; } -int srslte_ue_sync_nbiot_init_multi(srslte_nbiot_ue_sync_t* q, +int srsran_ue_sync_nbiot_init_multi(srsran_nbiot_ue_sync_t* q, uint32_t max_prb, - int(recv_callback)(void*, cf_t* [SRSLTE_MAX_PORTS], uint32_t, srslte_timestamp_t*), + int(recv_callback)(void*, cf_t* [SRSRAN_MAX_PORTS], uint32_t, srsran_timestamp_t*), uint32_t nof_rx_antennas, void* stream_handler) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; - if (q != NULL && stream_handler != NULL && srslte_nofprb_isvalid(max_prb) && recv_callback != NULL) { - ret = SRSLTE_ERROR; + if (q != NULL && stream_handler != NULL && srsran_nofprb_isvalid(max_prb) && recv_callback != NULL) { + ret = SRSRAN_ERROR; - bzero(q, sizeof(srslte_nbiot_ue_sync_t)); + bzero(q, sizeof(srsran_nbiot_ue_sync_t)); q->stream = stream_handler; q->recv_callback = recv_callback; - q->fft_size = srslte_symbol_sz(max_prb); - q->sf_len = SRSLTE_SF_LEN(q->fft_size); + q->fft_size = srsran_symbol_sz(max_prb); + q->sf_len = SRSRAN_SF_LEN(q->fft_size); q->file_mode = false; q->correct_cfo = true; q->nof_rx_antennas = nof_rx_antennas; @@ -180,162 +180,162 @@ int srslte_ue_sync_nbiot_init_multi(srslte_nbiot_ue_sync_t* q, q->nof_recv_sf = 10; q->frame_len = q->nof_recv_sf * q->sf_len; - if (srslte_sync_nbiot_init(&q->sfind, q->frame_len, q->frame_len, q->fft_size)) { + if (srsran_sync_nbiot_init(&q->sfind, q->frame_len, q->frame_len, q->fft_size)) { fprintf(stderr, "Error initiating sync find\n"); goto clean_exit; } // in tracking phase we only sample for one subframe but still use the entire // subframe to run the correlation (TODO: use only one symbol?) - if (srslte_sync_nbiot_init(&q->strack, q->sf_len, q->sf_len, q->fft_size)) { + if (srsran_sync_nbiot_init(&q->strack, q->sf_len, q->sf_len, q->fft_size)) { fprintf(stderr, "Error initiating sync track\n"); goto clean_exit; } - srslte_ue_sync_nbiot_reset(q); + srsran_ue_sync_nbiot_reset(q); - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } clean_exit: - if (ret == SRSLTE_ERROR) { - srslte_ue_sync_nbiot_free(q); + if (ret == SRSRAN_ERROR) { + srsran_ue_sync_nbiot_free(q); } return ret; } -uint32_t srslte_ue_sync_nbiot_sf_len(srslte_nbiot_ue_sync_t* q) +uint32_t srsran_ue_sync_nbiot_sf_len(srsran_nbiot_ue_sync_t* q) { return q->frame_len; } -void srslte_ue_sync_nbiot_free(srslte_nbiot_ue_sync_t* q) +void srsran_ue_sync_nbiot_free(srsran_nbiot_ue_sync_t* q) { if (q->do_agc) { - srslte_agc_free(&q->agc); + srsran_agc_free(&q->agc); } if (!q->file_mode) { - srslte_sync_nbiot_free(&q->sfind); - srslte_sync_nbiot_free(&q->strack); + srsran_sync_nbiot_free(&q->sfind); + srsran_sync_nbiot_free(&q->strack); } else { - srslte_filesource_free(&q->file_source); + srsran_filesource_free(&q->file_source); } - bzero(q, sizeof(srslte_nbiot_ue_sync_t)); + bzero(q, sizeof(srsran_nbiot_ue_sync_t)); } -int srslte_ue_sync_nbiot_set_cell(srslte_nbiot_ue_sync_t* q, srslte_nbiot_cell_t cell) +int srsran_ue_sync_nbiot_set_cell(srsran_nbiot_ue_sync_t* q, srsran_nbiot_cell_t cell) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; - if (q != NULL && srslte_nofprb_isvalid(cell.base.nof_prb)) { - ret = SRSLTE_ERROR; + if (q != NULL && srsran_nofprb_isvalid(cell.base.nof_prb)) { + ret = SRSRAN_ERROR; if (cell.base.nof_prb > q->max_prb) { fprintf(stderr, "Error in nbiot_ue_sync_set_cell(): cell.base.nof_prb must be lower than initialized\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } q->cell = cell; - q->fft_size = srslte_symbol_sz(q->cell.base.nof_prb); - q->sf_len = SRSLTE_SF_LEN(q->fft_size); + q->fft_size = srsran_symbol_sz(q->cell.base.nof_prb); + q->sf_len = SRSRAN_SF_LEN(q->fft_size); q->agc_period = 0; // we search for NPSS/NSSS in a full frame - q->nof_recv_sf = SRSLTE_NOF_SF_X_FRAME; + q->nof_recv_sf = SRSRAN_NOF_SF_X_FRAME; q->frame_len = q->nof_recv_sf * q->sf_len; - if (srslte_sync_nbiot_resize(&q->sfind, q->frame_len, q->frame_len, q->fft_size)) { + if (srsran_sync_nbiot_resize(&q->sfind, q->frame_len, q->frame_len, q->fft_size)) { fprintf(stderr, "Error resizing sync find\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_sync_nbiot_resize(&q->strack, q->sf_len, q->sf_len, q->fft_size)) { + if (srsran_sync_nbiot_resize(&q->strack, q->sf_len, q->sf_len, q->fft_size)) { fprintf(stderr, "Error resizing sync find\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - srslte_ue_sync_nbiot_reset(q); + srsran_ue_sync_nbiot_reset(q); - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } -void srslte_ue_sync_nbiot_get_last_timestamp(srslte_nbiot_ue_sync_t* q, srslte_timestamp_t* timestamp) +void srsran_ue_sync_nbiot_get_last_timestamp(srsran_nbiot_ue_sync_t* q, srsran_timestamp_t* timestamp) { - memcpy(timestamp, &q->last_timestamp, sizeof(srslte_timestamp_t)); + memcpy(timestamp, &q->last_timestamp, sizeof(srsran_timestamp_t)); } -uint32_t srslte_ue_sync_nbiot_peak_idx(srslte_nbiot_ue_sync_t* q) +uint32_t srsran_ue_sync_nbiot_peak_idx(srsran_nbiot_ue_sync_t* q) { return q->peak_idx; } -srslte_nbiot_ue_sync_state_t srslte_ue_sync_nbiot_get_state(srslte_nbiot_ue_sync_t* q) +srsran_nbiot_ue_sync_state_t srsran_ue_sync_nbiot_get_state(srsran_nbiot_ue_sync_t* q) { return q->state; } -uint32_t srslte_ue_sync_nbiot_get_sfidx(srslte_nbiot_ue_sync_t* q) +uint32_t srsran_ue_sync_nbiot_get_sfidx(srsran_nbiot_ue_sync_t* q) { return q->sf_idx; } -void srslte_ue_sync_nbiot_set_cfo_enable(srslte_nbiot_ue_sync_t* q, bool enable) +void srsran_ue_sync_nbiot_set_cfo_enable(srsran_nbiot_ue_sync_t* q, bool enable) { - srslte_sync_nbiot_set_cfo_enable(&q->sfind, enable); - srslte_sync_nbiot_set_cfo_enable(&q->strack, enable); + srsran_sync_nbiot_set_cfo_enable(&q->sfind, enable); + srsran_sync_nbiot_set_cfo_enable(&q->strack, enable); } -float srslte_ue_sync_nbiot_get_cfo(srslte_nbiot_ue_sync_t* q) +float srsran_ue_sync_nbiot_get_cfo(srsran_nbiot_ue_sync_t* q) { - return 15000 * (q->state == SF_TRACK ? srslte_sync_nbiot_get_cfo(&q->strack) : srslte_sync_nbiot_get_cfo(&q->sfind)); + return 15000 * (q->state == SF_TRACK ? srsran_sync_nbiot_get_cfo(&q->strack) : srsran_sync_nbiot_get_cfo(&q->sfind)); } -void srslte_ue_sync_nbiot_set_cfo(srslte_nbiot_ue_sync_t* q, float cfo) +void srsran_ue_sync_nbiot_set_cfo(srsran_nbiot_ue_sync_t* q, float cfo) { - srslte_sync_nbiot_set_cfo(&q->sfind, cfo / 15000); - srslte_sync_nbiot_set_cfo(&q->strack, cfo / 15000); + srsran_sync_nbiot_set_cfo(&q->sfind, cfo / 15000); + srsran_sync_nbiot_set_cfo(&q->strack, cfo / 15000); } -float srslte_ue_sync_nbiot_get_sfo(srslte_nbiot_ue_sync_t* q) +float srsran_ue_sync_nbiot_get_sfo(srsran_nbiot_ue_sync_t* q) { return q->mean_sfo / 5e-3; } -int srslte_ue_sync_nbiot_get_last_sample_offset(srslte_nbiot_ue_sync_t* q) +int srsran_ue_sync_nbiot_get_last_sample_offset(srsran_nbiot_ue_sync_t* q) { return q->last_sample_offset; } -void srslte_ue_sync_nbiot_set_sample_offset_correct_period(srslte_nbiot_ue_sync_t* q, uint32_t nof_subframes) +void srsran_ue_sync_nbiot_set_sample_offset_correct_period(srsran_nbiot_ue_sync_t* q, uint32_t nof_subframes) { q->sample_offset_correct_period = nof_subframes; } -void srslte_ue_sync_nbiot_set_cfo_ema(srslte_nbiot_ue_sync_t* q, float ema) +void srsran_ue_sync_nbiot_set_cfo_ema(srsran_nbiot_ue_sync_t* q, float ema) { - srslte_sync_nbiot_set_cfo_ema_alpha(&q->sfind, ema); - srslte_sync_nbiot_set_cfo_ema_alpha(&q->strack, ema); + srsran_sync_nbiot_set_cfo_ema_alpha(&q->sfind, ema); + srsran_sync_nbiot_set_cfo_ema_alpha(&q->strack, ema); } -void srslte_ue_sync_nbiot_set_cfo_tol(srslte_nbiot_ue_sync_t* q, float cfo_tol) +void srsran_ue_sync_nbiot_set_cfo_tol(srsran_nbiot_ue_sync_t* q, float cfo_tol) { - srslte_sync_nbiot_set_cfo_tol(&q->sfind, cfo_tol); - srslte_sync_nbiot_set_cfo_tol(&q->strack, cfo_tol); + srsran_sync_nbiot_set_cfo_tol(&q->sfind, cfo_tol); + srsran_sync_nbiot_set_cfo_tol(&q->strack, cfo_tol); } -void srslte_ue_sync_nbiot_set_sfo_ema(srslte_nbiot_ue_sync_t* q, float ema_coefficient) +void srsran_ue_sync_nbiot_set_sfo_ema(srsran_nbiot_ue_sync_t* q, float ema_coefficient) { q->sfo_ema = ema_coefficient; } -void srslte_ue_sync_nbiot_set_agc_period(srslte_nbiot_ue_sync_t* q, uint32_t period) +void srsran_ue_sync_nbiot_set_agc_period(srsran_nbiot_ue_sync_t* q, uint32_t period) { q->agc_period = period; } -static int find_peak_ok(srslte_nbiot_ue_sync_t* q, cf_t* input_buffer[SRSLTE_MAX_PORTS]) +static int find_peak_ok(srsran_nbiot_ue_sync_t* q, cf_t* input_buffer[SRSRAN_MAX_PORTS]) { // set subframe idx to NPSS position q->sf_idx = 5; @@ -343,15 +343,15 @@ static int find_peak_ok(srslte_nbiot_ue_sync_t* q, cf_t* input_buffer[SRSLTE_MAX DEBUG("Found peak %d at %d, value %.3f, n_id_ncell: %d", q->frame_find_cnt, q->peak_idx, - srslte_sync_nbiot_get_peak_value(&q->sfind), + srsran_sync_nbiot_get_peak_value(&q->sfind), q->cell.n_id_ncell); if (q->frame_find_cnt >= q->nof_avg_find_frames || q->peak_idx < 2 * q->fft_size) { - int num_drop = (q->peak_idx - SRSLTE_NPSS_CORR_OFFSET + q->frame_len / 2) % q->frame_len; + int num_drop = (q->peak_idx - SRSRAN_NPSS_CORR_OFFSET + q->frame_len / 2) % q->frame_len; INFO("Realigning frame, reading %d samples", num_drop); /* Receive the rest of the subframe so that we are subframe aligned */ if (q->recv_callback(q->stream, input_buffer, num_drop, &q->last_timestamp) < 0) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } ///< reset variables @@ -377,10 +377,10 @@ static int find_peak_ok(srslte_nbiot_ue_sync_t* q, cf_t* input_buffer[SRSLTE_MAX return 0; } -static int track_peak_ok(srslte_nbiot_ue_sync_t* q, uint32_t track_idx) +static int track_peak_ok(srsran_nbiot_ue_sync_t* q, uint32_t track_idx) { // Get sampling time offset - q->last_sample_offset = ((int)track_idx - SRSLTE_NPSS_CORR_OFFSET); + q->last_sample_offset = ((int)track_idx - SRSRAN_NPSS_CORR_OFFSET); // Adjust sampling time every q->sample_offset_correct_period subframes uint32_t frame_idx = 0; @@ -398,20 +398,20 @@ static int track_peak_ok(srslte_nbiot_ue_sync_t* q, uint32_t track_idx) // Reset PSS averaging if correcting every a period longer than 1 if (q->sample_offset_correct_period > 1) { - srslte_sync_nbiot_reset(&q->strack); + srsran_sync_nbiot_reset(&q->strack); } // Compute SFO based on mean sample offset if (q->sample_offset_correct_period) { q->mean_sample_offset /= q->sample_offset_correct_period; } - q->mean_sfo = SRSLTE_VEC_EMA(q->mean_sample_offset, q->mean_sfo, q->sfo_ema); + q->mean_sfo = SRSRAN_VEC_EMA(q->mean_sample_offset, q->mean_sfo, q->sfo_ema); if (q->next_rf_sample_offset) { INFO("Time offset adjustment: %d samples (%.2f), mean SFO: %.2f Hz, %.5f samples/10-sf, ema=%f, length=%d", q->next_rf_sample_offset, q->mean_sample_offset, - srslte_ue_sync_nbiot_get_sfo(q), + srsran_ue_sync_nbiot_get_sfo(q), q->mean_sfo, q->sfo_ema, q->sample_offset_correct_period); @@ -425,7 +425,7 @@ static int track_peak_ok(srslte_nbiot_ue_sync_t* q, uint32_t track_idx) if (q->recv_callback( q->stream, &dummy_offset_buffer_nbiot[0], (uint32_t)q->next_rf_sample_offset, &q->last_timestamp) < 0) { fprintf(stderr, "Error receiving from USRP\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } q->next_rf_sample_offset = 0; } @@ -436,7 +436,7 @@ static int track_peak_ok(srslte_nbiot_ue_sync_t* q, uint32_t track_idx) return 1; } -static int track_peak_no(srslte_nbiot_ue_sync_t* q) +static int track_peak_no(srsran_nbiot_ue_sync_t* q) { ///< if we missed too many NPSS, we go back to FIND and consider this frame unsynchronized q->frame_no_cnt++; @@ -448,19 +448,19 @@ static int track_peak_no(srslte_nbiot_ue_sync_t* q) return 0; } else { INFO("Tracking peak not found. Peak %.3f, %d lost", - srslte_sync_nbiot_get_peak_value(&q->strack), + srsran_sync_nbiot_get_peak_value(&q->strack), (int)q->frame_no_cnt); /* - printf("Saving files: pss_corr (%d), input (%d)\n", q->strack.pss.frame_size, SRSLTE_SF_LEN_PRB(q->cell.nof_prb)); - srslte_vec_save_file("pss_corr", q->strack.pss.conv_output_avg, q->strack.pss.frame_size*sizeof(float)); - srslte_vec_save_file("input", q->input_buffer, SRSLTE_SF_LEN_PRB(q->cell.nof_prb)*sizeof(cf_t)); + printf("Saving files: pss_corr (%d), input (%d)\n", q->strack.pss.frame_size, SRSRAN_SF_LEN_PRB(q->cell.nof_prb)); + srsran_vec_save_file("pss_corr", q->strack.pss.conv_output_avg, q->strack.pss.frame_size*sizeof(float)); + srsran_vec_save_file("input", q->input_buffer, SRSRAN_SF_LEN_PRB(q->cell.nof_prb)*sizeof(cf_t)); exit(-1); */ return 1; } } -static int receive_samples(srslte_nbiot_ue_sync_t* q, cf_t* input_buffer[SRSLTE_MAX_PORTS]) +static int receive_samples(srsran_nbiot_ue_sync_t* q, cf_t* input_buffer[SRSRAN_MAX_PORTS]) { ///< A negative time offset means there are samples in our buffer for the next subframe, because we are sampling too ///< fast @@ -469,49 +469,49 @@ static int receive_samples(srslte_nbiot_ue_sync_t* q, cf_t* input_buffer[SRSLTE_ } ///< Get N subframes from the USRP getting more samples and keeping the previous samples, if any - cf_t* ptr[SRSLTE_MAX_PORTS] = {NULL, NULL, NULL, NULL}; + cf_t* ptr[SRSRAN_MAX_PORTS] = {NULL, NULL, NULL, NULL}; for (int i = 0; i < q->nof_rx_antennas; i++) { ptr[i] = &input_buffer[i][q->next_rf_sample_offset]; } // assure next_rf_sample_offset isn't larger than frame_len - q->next_rf_sample_offset = SRSLTE_MIN(q->next_rf_sample_offset, q->frame_len); + q->next_rf_sample_offset = SRSRAN_MIN(q->next_rf_sample_offset, q->frame_len); if (q->recv_callback(q->stream, ptr, q->frame_len - q->next_rf_sample_offset, &q->last_timestamp) < 0) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } ///< reset time offset q->next_rf_sample_offset = 0; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_ue_sync_nbiot_zerocopy(srslte_nbiot_ue_sync_t* q, cf_t* input_buffer) +int srsran_ue_sync_nbiot_zerocopy(srsran_nbiot_ue_sync_t* q, cf_t* input_buffer) { - cf_t* _input_buffer[SRSLTE_MAX_PORTS] = {NULL}; + cf_t* _input_buffer[SRSRAN_MAX_PORTS] = {NULL}; _input_buffer[0] = input_buffer; - return srslte_ue_sync_nbiot_zerocopy_multi(q, _input_buffer); + return srsran_ue_sync_nbiot_zerocopy_multi(q, _input_buffer); } /* Returns 1 if the subframe is synchronized in time, 0 otherwise */ -int srslte_ue_sync_nbiot_zerocopy_multi(srslte_nbiot_ue_sync_t* q, cf_t** input_buffer) +int srsran_ue_sync_nbiot_zerocopy_multi(srsran_nbiot_ue_sync_t* q, cf_t** input_buffer) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL) { if (q->file_mode) { - int n = srslte_filesource_read(&q->file_source, input_buffer[0], q->sf_len); + int n = srsran_filesource_read(&q->file_source, input_buffer[0], q->sf_len); if (n < q->sf_len) { fprintf(stderr, "Error reading input file, read %d bytes\n", n); #if REPEAT_FROM_FILE - srslte_filesource_seek(&q->file_source, 0); + srsran_filesource_seek(&q->file_source, 0); #else - return SRSLTE_ERROR; + return SRSRAN_ERROR; #endif } if (q->correct_cfo) { for (int i = 0; i < q->nof_rx_antennas; i++) { - srslte_cfo_correct(&q->file_cfo_correct, input_buffer[i], input_buffer[i], q->file_cfo / 15000 / q->fft_size); + srsran_cfo_correct(&q->file_cfo_correct, input_buffer[i], input_buffer[i], q->file_cfo / 15000 / q->fft_size); } } q->sf_idx++; @@ -523,42 +523,42 @@ int srslte_ue_sync_nbiot_zerocopy_multi(srslte_nbiot_ue_sync_t* q, cf_t** input_ } else { if (receive_samples(q, input_buffer)) { fprintf(stderr, "Error receiving samples\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } switch (q->state) { case SF_FIND: - switch (srslte_sync_nbiot_find(&q->sfind, input_buffer[0], 0, &q->peak_idx)) { - case SRSLTE_SYNC_ERROR: - ret = SRSLTE_ERROR; + switch (srsran_sync_nbiot_find(&q->sfind, input_buffer[0], 0, &q->peak_idx)) { + case SRSRAN_SYNC_ERROR: + ret = SRSRAN_ERROR; fprintf(stderr, "Error finding correlation peak (%d)\n", ret); - return SRSLTE_ERROR; - case SRSLTE_SYNC_FOUND: + return SRSRAN_ERROR; + case SRSRAN_SYNC_FOUND: ret = find_peak_ok(q, input_buffer); break; - case SRSLTE_SYNC_FOUND_NOSPACE: + case SRSRAN_SYNC_FOUND_NOSPACE: /* If a peak was found but there is not enough space for SSS/CP detection, discard a few samples */ printf("No space for SSS/CP detection. Realigning frame...\n"); q->recv_callback(q->stream, dummy_offset_buffer_nbiot, q->frame_len / 2, NULL); - srslte_sync_nbiot_reset(&q->sfind); - ret = SRSLTE_SUCCESS; + srsran_sync_nbiot_reset(&q->sfind); + ret = SRSRAN_SUCCESS; break; default: - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; break; } if (q->do_agc) { - srslte_agc_process(&q->agc, input_buffer[0], q->sf_len); + srsran_agc_process(&q->agc, input_buffer[0], q->sf_len); } break; case SF_TRACK: ret = 1; - q->sf_idx = (q->sf_idx + q->nof_recv_sf) % SRSLTE_NOF_SF_X_FRAME; + q->sf_idx = (q->sf_idx + q->nof_recv_sf) % SRSRAN_NOF_SF_X_FRAME; ///< Every SF idx 5, find peak around known position q->peak_idx if (q->sf_idx == 5) { if (q->do_agc && (q->agc_period == 0 || (q->agc_period && (q->frame_total_cnt % q->agc_period) == 0))) { - srslte_agc_process(&q->agc, input_buffer[0], q->sf_len); + srsran_agc_process(&q->agc, input_buffer[0], q->sf_len); } #ifdef MEASURE_EXEC_TIME @@ -569,21 +569,21 @@ int srslte_ue_sync_nbiot_zerocopy_multi(srslte_nbiot_ue_sync_t* q, cf_t** input_ // Track NPSS around the expected position uint32_t find_offset = q->frame_len / 2 - q->strack.max_offset / 2; - switch (srslte_sync_nbiot_find(&q->strack, input_buffer[0], find_offset, &track_idx)) { - case SRSLTE_SYNC_ERROR: - ret = SRSLTE_ERROR; + switch (srsran_sync_nbiot_find(&q->strack, input_buffer[0], find_offset, &track_idx)) { + case SRSRAN_SYNC_ERROR: + ret = SRSRAN_ERROR; fprintf(stderr, "Error tracking correlation peak\n"); - return SRSLTE_ERROR; - case SRSLTE_SYNC_FOUND: + return SRSRAN_ERROR; + case SRSRAN_SYNC_FOUND: ret = track_peak_ok(q, track_idx); break; - case SRSLTE_SYNC_FOUND_NOSPACE: + case SRSRAN_SYNC_FOUND_NOSPACE: // It's very very unlikely that we fall here because this event should happen at FIND phase only ret = 0; q->state = SF_FIND; printf("Warning: No space for SSS/CP while in tracking phase\n"); break; - case SRSLTE_SYNC_NOFOUND: + case SRSRAN_SYNC_NOFOUND: ret = track_peak_no(q); break; } @@ -591,23 +591,23 @@ int srslte_ue_sync_nbiot_zerocopy_multi(srslte_nbiot_ue_sync_t* q, cf_t** input_ #ifdef MEASURE_EXEC_TIME gettimeofday(&t[2], NULL); get_time_interval(t); - q->mean_exec_time = (float)SRSLTE_VEC_CMA((float)t[0].tv_usec, q->mean_exec_time, q->frame_total_cnt); + q->mean_exec_time = (float)SRSRAN_VEC_CMA((float)t[0].tv_usec, q->mean_exec_time, q->frame_total_cnt); #endif - if (ret == SRSLTE_ERROR) { + if (ret == SRSRAN_ERROR) { fprintf(stderr, "Error processing tracking peak\n"); q->state = SF_FIND; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } q->frame_total_cnt++; } else { if (q->correct_cfo) { for (int i = 0; i < q->nof_rx_antennas; i++) { - srslte_cfo_correct(&q->strack.cfocorr, + srsran_cfo_correct(&q->strack.cfocorr, input_buffer[i], input_buffer[i], - -srslte_sync_nbiot_get_cfo(&q->strack) / q->fft_size); + -srsran_sync_nbiot_get_cfo(&q->strack) / q->fft_size); } } } @@ -618,30 +618,30 @@ int srslte_ue_sync_nbiot_zerocopy_multi(srslte_nbiot_ue_sync_t* q, cf_t** input_ return ret; } -void srslte_ue_sync_nbiot_reset(srslte_nbiot_ue_sync_t* q) +void srsran_ue_sync_nbiot_reset(srsran_nbiot_ue_sync_t* q) { ///< Set default params - srslte_sync_nbiot_set_cfo_enable(&q->sfind, true); - srslte_sync_nbiot_set_cfo_enable(&q->strack, true); + srsran_sync_nbiot_set_cfo_enable(&q->sfind, true); + srsran_sync_nbiot_set_cfo_enable(&q->strack, true); - srslte_sync_nbiot_set_cfo_ema_alpha(&q->sfind, 0.15); - srslte_sync_nbiot_set_cfo_ema_alpha(&q->strack, 0.01); + srsran_sync_nbiot_set_cfo_ema_alpha(&q->sfind, 0.15); + srsran_sync_nbiot_set_cfo_ema_alpha(&q->strack, 0.01); ///< In find phase and if the cell is known, do not average NPSS correlation because we only capture 1 subframe and ///< do not know where the peak is. q->nof_avg_find_frames = 1; - srslte_sync_nbiot_set_npss_ema_alpha(&q->sfind, 1.0); - srslte_sync_nbiot_set_threshold(&q->sfind, 2.5); + srsran_sync_nbiot_set_npss_ema_alpha(&q->sfind, 1.0); + srsran_sync_nbiot_set_threshold(&q->sfind, 2.5); - srslte_sync_nbiot_set_cfo_cand(&q->sfind, cfo_cands, sizeof(cfo_cands) / sizeof(float)); - srslte_sync_nbiot_set_cfo_cand_test_enable(&q->sfind, true); + srsran_sync_nbiot_set_cfo_cand(&q->sfind, cfo_cands, sizeof(cfo_cands) / sizeof(float)); + srsran_sync_nbiot_set_cfo_cand_test_enable(&q->sfind, true); - srslte_sync_nbiot_set_npss_ema_alpha(&q->strack, 0.1); - srslte_sync_nbiot_set_threshold(&q->strack, 1.2); + srsran_sync_nbiot_set_npss_ema_alpha(&q->strack, 0.1); + srsran_sync_nbiot_set_threshold(&q->strack, 1.2); if (!q->file_mode) { - srslte_sync_nbiot_reset(&q->sfind); - srslte_sync_nbiot_reset(&q->strack); + srsran_sync_nbiot_reset(&q->sfind); + srsran_sync_nbiot_reset(&q->strack); } else { q->sf_idx = 9; } diff --git a/lib/src/phy/ue/ue_ul.c b/lib/src/phy/ue/ue_ul.c index ae103be46..ea821a6f2 100644 --- a/lib/src/phy/ue/ue_ul.c +++ b/lib/src/phy/ue/ue_ul.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,98 +10,98 @@ * */ -#include "srslte/srslte.h" +#include "srsran/srsran.h" #include #include #include -#include "srslte/phy/ue/ue_ul.h" +#include "srsran/phy/ue/ue_ul.h" -#define CURRENT_FFTSIZE srslte_symbol_sz(q->cell.nof_prb) -#define CURRENT_SFLEN SRSLTE_SF_LEN(CURRENT_FFTSIZE) +#define CURRENT_FFTSIZE srsran_symbol_sz(q->cell.nof_prb) +#define CURRENT_SFLEN SRSRAN_SF_LEN(CURRENT_FFTSIZE) -#define CURRENT_SLOTLEN_RE SRSLTE_SLOT_LEN_RE(q->cell.nof_prb, q->cell.cp) -#define CURRENT_SFLEN_RE SRSLTE_NOF_RE(q->cell) +#define CURRENT_SLOTLEN_RE SRSRAN_SLOT_LEN_RE(q->cell.nof_prb, q->cell.cp) +#define CURRENT_SFLEN_RE SRSRAN_NOF_RE(q->cell) -#define MAX_SFLEN SRSLTE_SF_LEN(srslte_symbol_sz(max_prb)) +#define MAX_SFLEN SRSRAN_SF_LEN(srsran_symbol_sz(max_prb)) #define DEFAULT_CFO_TOL 1.0 // Hz -static bool srs_tx_enabled(srslte_refsignal_srs_cfg_t* srs_cfg, uint32_t tti); +static bool srs_tx_enabled(srsran_refsignal_srs_cfg_t* srs_cfg, uint32_t tti); -int srslte_ue_ul_init(srslte_ue_ul_t* q, cf_t* out_buffer, uint32_t max_prb) +int srsran_ue_ul_init(srsran_ue_ul_t* q, cf_t* out_buffer, uint32_t max_prb) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL) { - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; - bzero(q, sizeof(srslte_ue_ul_t)); + bzero(q, sizeof(srsran_ue_ul_t)); - q->sf_symbols = srslte_vec_cf_malloc(SRSLTE_SF_LEN_PRB(max_prb)); + q->sf_symbols = srsran_vec_cf_malloc(SRSRAN_SF_LEN_PRB(max_prb)); if (!q->sf_symbols) { perror("malloc"); goto clean_exit; } - srslte_ofdm_cfg_t ofdm_cfg = {}; + srsran_ofdm_cfg_t ofdm_cfg = {}; ofdm_cfg.nof_prb = max_prb; ofdm_cfg.in_buffer = q->sf_symbols; ofdm_cfg.out_buffer = out_buffer; - ofdm_cfg.cp = SRSLTE_CP_NORM; + ofdm_cfg.cp = SRSRAN_CP_NORM; ofdm_cfg.freq_shift_f = 0.5f; ofdm_cfg.normalize = true; - if (srslte_ofdm_tx_init_cfg(&q->fft, &ofdm_cfg)) { + if (srsran_ofdm_tx_init_cfg(&q->fft, &ofdm_cfg)) { ERROR("Error initiating FFT"); goto clean_exit; } - if (srslte_cfo_init(&q->cfo, MAX_SFLEN)) { + if (srsran_cfo_init(&q->cfo, MAX_SFLEN)) { ERROR("Error creating CFO object"); goto clean_exit; } - if (srslte_pusch_init_ue(&q->pusch, max_prb)) { + if (srsran_pusch_init_ue(&q->pusch, max_prb)) { ERROR("Error creating PUSCH object"); goto clean_exit; } - if (srslte_pucch_init_ue(&q->pucch)) { + if (srsran_pucch_init_ue(&q->pucch)) { ERROR("Error creating PUSCH object"); goto clean_exit; } - q->refsignal = srslte_vec_cf_malloc(2 * SRSLTE_NRE * max_prb); + q->refsignal = srsran_vec_cf_malloc(2 * SRSRAN_NRE * max_prb); if (!q->refsignal) { perror("malloc"); goto clean_exit; } - q->srs_signal = srslte_vec_cf_malloc(SRSLTE_NRE * max_prb); + q->srs_signal = srsran_vec_cf_malloc(SRSRAN_NRE * max_prb); if (!q->srs_signal) { perror("malloc"); goto clean_exit; } q->out_buffer = out_buffer; q->signals_pregenerated = false; - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } else { ERROR("Invalid parameters"); } clean_exit: - if (ret == SRSLTE_ERROR) { - srslte_ue_ul_free(q); + if (ret == SRSRAN_ERROR) { + srsran_ue_ul_free(q); } return ret; } -void srslte_ue_ul_free(srslte_ue_ul_t* q) +void srsran_ue_ul_free(srsran_ue_ul_t* q) { if (q) { - srslte_ofdm_tx_free(&q->fft); - srslte_pusch_free(&q->pusch); - srslte_pucch_free(&q->pucch); + srsran_ofdm_tx_free(&q->fft); + srsran_pusch_free(&q->pusch); + srsran_pucch_free(&q->pucch); - srslte_cfo_free(&q->cfo); + srsran_cfo_free(&q->cfo); if (q->sf_symbols) { free(q->sf_symbols); @@ -113,111 +113,111 @@ void srslte_ue_ul_free(srslte_ue_ul_t* q) free(q->srs_signal); } if (q->signals_pregenerated) { - srslte_refsignal_dmrs_pusch_pregen_free(&q->signals, &q->pregen_dmrs); - srslte_refsignal_srs_pregen_free(&q->signals, &q->pregen_srs); + srsran_refsignal_dmrs_pusch_pregen_free(&q->signals, &q->pregen_dmrs); + srsran_refsignal_srs_pregen_free(&q->signals, &q->pregen_srs); } - srslte_ra_ul_pusch_hopping_free(&q->hopping); + srsran_ra_ul_pusch_hopping_free(&q->hopping); - bzero(q, sizeof(srslte_ue_ul_t)); + bzero(q, sizeof(srsran_ue_ul_t)); } } -int srslte_ue_ul_set_cell(srslte_ue_ul_t* q, srslte_cell_t cell) +int srsran_ue_ul_set_cell(srsran_ue_ul_t* q, srsran_cell_t cell) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; - if (q != NULL && srslte_cell_isvalid(&cell)) { + if (q != NULL && srsran_cell_isvalid(&cell)) { if (q->cell.id != cell.id || q->cell.nof_prb == 0) { q->cell = cell; - if (srslte_ofdm_tx_set_prb(&q->fft, q->cell.cp, q->cell.nof_prb)) { + if (srsran_ofdm_tx_set_prb(&q->fft, q->cell.cp, q->cell.nof_prb)) { ERROR("Error resizing FFT"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_cfo_resize(&q->cfo, SRSLTE_SF_LEN_PRB(q->cell.nof_prb))) { + if (srsran_cfo_resize(&q->cfo, SRSRAN_SF_LEN_PRB(q->cell.nof_prb))) { ERROR("Error resizing CFO object"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_pusch_set_cell(&q->pusch, q->cell)) { + if (srsran_pusch_set_cell(&q->pusch, q->cell)) { ERROR("Error resizing PUSCH object"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_pucch_set_cell(&q->pucch, q->cell)) { + if (srsran_pucch_set_cell(&q->pucch, q->cell)) { ERROR("Error resizing PUSCH object"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_refsignal_ul_set_cell(&q->signals, q->cell)) { - ERROR("Error resizing srslte_refsignal_ul"); - return SRSLTE_ERROR; + if (srsran_refsignal_ul_set_cell(&q->signals, q->cell)) { + ERROR("Error resizing srsran_refsignal_ul"); + return SRSRAN_ERROR; } - if (srslte_ra_ul_pusch_hopping_init(&q->hopping, q->cell)) { + if (srsran_ra_ul_pusch_hopping_init(&q->hopping, q->cell)) { ERROR("Error setting hopping procedure cell"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } q->signals_pregenerated = false; } - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } else { ERROR("Invalid cell properties ue_ul: Id=%d, Ports=%d, PRBs=%d", cell.id, cell.nof_ports, cell.nof_prb); } return ret; } -int srslte_ue_ul_pregen_signals(srslte_ue_ul_t* q, srslte_ue_ul_cfg_t* cfg) +int srsran_ue_ul_pregen_signals(srsran_ue_ul_t* q, srsran_ue_ul_cfg_t* cfg) { if (q->signals_pregenerated) { - srslte_refsignal_dmrs_pusch_pregen_free(&q->signals, &q->pregen_dmrs); - srslte_refsignal_srs_pregen_free(&q->signals, &q->pregen_srs); + srsran_refsignal_dmrs_pusch_pregen_free(&q->signals, &q->pregen_dmrs); + srsran_refsignal_srs_pregen_free(&q->signals, &q->pregen_srs); } - if (srslte_refsignal_dmrs_pusch_pregen(&q->signals, &q->pregen_dmrs, &cfg->ul_cfg.dmrs)) { - return SRSLTE_ERROR; + if (srsran_refsignal_dmrs_pusch_pregen(&q->signals, &q->pregen_dmrs, &cfg->ul_cfg.dmrs)) { + return SRSRAN_ERROR; } - if (srslte_refsignal_srs_pregen(&q->signals, &q->pregen_srs, &cfg->ul_cfg.srs, &cfg->ul_cfg.dmrs)) { - return SRSLTE_ERROR; + if (srsran_refsignal_srs_pregen(&q->signals, &q->pregen_srs, &cfg->ul_cfg.srs, &cfg->ul_cfg.dmrs)) { + return SRSRAN_ERROR; } q->signals_pregenerated = true; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_ue_ul_dci_to_pusch_grant(srslte_ue_ul_t* q, - srslte_ul_sf_cfg_t* sf, - srslte_ue_ul_cfg_t* cfg, - srslte_dci_ul_t* dci, - srslte_pusch_grant_t* grant) +int srsran_ue_ul_dci_to_pusch_grant(srsran_ue_ul_t* q, + srsran_ul_sf_cfg_t* sf, + srsran_ue_ul_cfg_t* cfg, + srsran_dci_ul_t* dci, + srsran_pusch_grant_t* grant) { // Convert DCI to Grant - if (srslte_ra_ul_dci_to_grant(&q->cell, sf, &cfg->ul_cfg.hopping, dci, grant)) { - return SRSLTE_ERROR; + if (srsran_ra_ul_dci_to_grant(&q->cell, sf, &cfg->ul_cfg.hopping, dci, grant)) { + return SRSRAN_ERROR; } // Update shortened before computing grant - srslte_refsignal_srs_pusch_shortened(&q->signals, sf, &cfg->ul_cfg.srs, &cfg->ul_cfg.pusch); + srsran_refsignal_srs_pusch_shortened(&q->signals, sf, &cfg->ul_cfg.srs, &cfg->ul_cfg.pusch); // Update RE assuming if shortened is true if (sf->shortened) { - srslte_ra_ul_compute_nof_re(grant, q->cell.cp, true); + srsran_ra_ul_compute_nof_re(grant, q->cell.cp, true); } // Assert Grant is valid - return srslte_pusch_assert_grant(grant); + return srsran_pusch_assert_grant(grant); } -void srslte_ue_ul_pusch_hopping(srslte_ue_ul_t* q, - srslte_ul_sf_cfg_t* sf, - srslte_ue_ul_cfg_t* cfg, - srslte_pusch_grant_t* grant) +void srsran_ue_ul_pusch_hopping(srsran_ue_ul_t* q, + srsran_ul_sf_cfg_t* sf, + srsran_ue_ul_cfg_t* cfg, + srsran_pusch_grant_t* grant) { if (cfg->ul_cfg.srs.configured && cfg->ul_cfg.hopping.hopping_enabled) { ERROR("UL SRS and frequency hopping not currently supported"); } - return srslte_ra_ul_pusch_hopping(&q->hopping, sf, &cfg->ul_cfg.hopping, grant); + return srsran_ra_ul_pusch_hopping(&q->hopping, sf, &cfg->ul_cfg.hopping, grant); } -static float limit_norm_factor(srslte_ue_ul_t* q, float norm_factor, cf_t* output_signal) +static float limit_norm_factor(srsran_ue_ul_t* q, float norm_factor, cf_t* output_signal) { - uint32_t p = srslte_vec_max_abs_fi((float*)output_signal, 2 * SRSLTE_SF_LEN_PRB(q->cell.nof_prb)); + uint32_t p = srsran_vec_max_abs_fi((float*)output_signal, 2 * SRSRAN_SF_LEN_PRB(q->cell.nof_prb)); float amp = fabsf(*((float*)output_signal + p)); if (amp * norm_factor > 0.95) { @@ -229,34 +229,34 @@ static float limit_norm_factor(srslte_ue_ul_t* q, float norm_factor, cf_t* outpu return norm_factor; } -static void apply_cfo(srslte_ue_ul_t* q, srslte_ue_ul_cfg_t* cfg) +static void apply_cfo(srsran_ue_ul_t* q, srsran_ue_ul_cfg_t* cfg) { if (cfg->cfo_en) { - srslte_cfo_set_tol(&q->cfo, cfg->cfo_tol / (15000.0 * srslte_symbol_sz(q->cell.nof_prb))); - srslte_cfo_correct(&q->cfo, q->out_buffer, q->out_buffer, cfg->cfo_value / srslte_symbol_sz(q->cell.nof_prb)); + srsran_cfo_set_tol(&q->cfo, cfg->cfo_tol / (15000.0 * srsran_symbol_sz(q->cell.nof_prb))); + srsran_cfo_correct(&q->cfo, q->out_buffer, q->out_buffer, cfg->cfo_value / srsran_symbol_sz(q->cell.nof_prb)); } } -static void apply_norm(srslte_ue_ul_t* q, srslte_ue_ul_cfg_t* cfg, float norm_factor) +static void apply_norm(srsran_ue_ul_t* q, srsran_ue_ul_cfg_t* cfg, float norm_factor) { - uint32_t sf_len = SRSLTE_SF_LEN_PRB(q->cell.nof_prb); + uint32_t sf_len = SRSRAN_SF_LEN_PRB(q->cell.nof_prb); float* buf = NULL; float force_peak_amplitude = cfg->force_peak_amplitude > 0 ? cfg->force_peak_amplitude : 1.0f; switch (cfg->normalize_mode) { - case SRSLTE_UE_UL_NORMALIZE_MODE_AUTO: + case SRSRAN_UE_UL_NORMALIZE_MODE_AUTO: default: // Automatic normalization (default) norm_factor = limit_norm_factor(q, norm_factor, q->out_buffer); - srslte_vec_sc_prod_cfc(q->out_buffer, norm_factor, q->out_buffer, sf_len); + srsran_vec_sc_prod_cfc(q->out_buffer, norm_factor, q->out_buffer, sf_len); break; - case SRSLTE_UE_UL_NORMALIZE_MODE_FORCE_AMPLITUDE: + case SRSRAN_UE_UL_NORMALIZE_MODE_FORCE_AMPLITUDE: // Force amplitude // Typecast buffer buf = (float*)q->out_buffer; // Get index of maximum absolute sample - uint32_t idx = srslte_vec_max_abs_fi(buf, sf_len * 2); + uint32_t idx = srsran_vec_max_abs_fi(buf, sf_len * 2); // Get maximum value float scale = fabsf(buf[idx]); @@ -264,40 +264,40 @@ static void apply_norm(srslte_ue_ul_t* q, srslte_ue_ul_cfg_t* cfg, float norm_fa // Avoid zero division if (scale != 0.0f && scale != INFINITY) { // Apply maximum peak amplitude - srslte_vec_sc_prod_cfc(q->out_buffer, force_peak_amplitude / scale, q->out_buffer, sf_len); + srsran_vec_sc_prod_cfc(q->out_buffer, force_peak_amplitude / scale, q->out_buffer, sf_len); } break; } } -static void add_srs(srslte_ue_ul_t* q, srslte_ue_ul_cfg_t* cfg, uint32_t tti) +static void add_srs(srsran_ue_ul_t* q, srsran_ue_ul_cfg_t* cfg, uint32_t tti) { if (srs_tx_enabled(&cfg->ul_cfg.srs, tti)) { if (q->signals_pregenerated) { - srslte_refsignal_srs_pregen_put(&q->signals, &q->pregen_srs, &cfg->ul_cfg.srs, tti, q->sf_symbols); + srsran_refsignal_srs_pregen_put(&q->signals, &q->pregen_srs, &cfg->ul_cfg.srs, tti, q->sf_symbols); } else { - srslte_refsignal_srs_gen(&q->signals, &cfg->ul_cfg.srs, &cfg->ul_cfg.dmrs, tti % 10, q->srs_signal); - srslte_refsignal_srs_put(&q->signals, &cfg->ul_cfg.srs, tti, q->srs_signal, q->sf_symbols); + srsran_refsignal_srs_gen(&q->signals, &cfg->ul_cfg.srs, &cfg->ul_cfg.dmrs, tti % 10, q->srs_signal); + srsran_refsignal_srs_put(&q->signals, &cfg->ul_cfg.srs, tti, q->srs_signal, q->sf_symbols); } } } -static int pusch_encode(srslte_ue_ul_t* q, srslte_ul_sf_cfg_t* sf, srslte_ue_ul_cfg_t* cfg, srslte_pusch_data_t* data) +static int pusch_encode(srsran_ue_ul_t* q, srsran_ul_sf_cfg_t* sf, srsran_ue_ul_cfg_t* cfg, srsran_pusch_data_t* data) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL) { - srslte_vec_cf_zero(q->sf_symbols, SRSLTE_NOF_RE(q->cell)); + srsran_vec_cf_zero(q->sf_symbols, SRSRAN_NOF_RE(q->cell)); - if (srslte_pusch_encode(&q->pusch, sf, &cfg->ul_cfg.pusch, data, q->sf_symbols)) { + if (srsran_pusch_encode(&q->pusch, sf, &cfg->ul_cfg.pusch, data, q->sf_symbols)) { ERROR("Error encoding PUSCH"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (q->signals_pregenerated) { - srslte_refsignal_dmrs_pusch_pregen_put(&q->signals, sf, &q->pregen_dmrs, &cfg->ul_cfg.pusch, q->sf_symbols); + srsran_refsignal_dmrs_pusch_pregen_put(&q->signals, sf, &q->pregen_dmrs, &cfg->ul_cfg.pusch, q->sf_symbols); } else { - if (srslte_refsignal_dmrs_pusch_gen(&q->signals, + if (srsran_refsignal_dmrs_pusch_gen(&q->signals, &cfg->ul_cfg.dmrs, cfg->ul_cfg.pusch.grant.L_prb, sf->tti % 10, @@ -306,24 +306,24 @@ static int pusch_encode(srslte_ue_ul_t* q, srslte_ul_sf_cfg_t* sf, srslte_ue_ul_ ERROR("Error generating PUSCH DMRS signals"); return ret; } - srslte_refsignal_dmrs_pusch_put(&q->signals, &cfg->ul_cfg.pusch, q->refsignal, q->sf_symbols); + srsran_refsignal_dmrs_pusch_put(&q->signals, &cfg->ul_cfg.pusch, q->refsignal, q->sf_symbols); } add_srs(q, cfg, sf->tti); - srslte_ofdm_tx_sf(&q->fft); + srsran_ofdm_tx_sf(&q->fft); apply_cfo(q, cfg); apply_norm(q, cfg, q->cell.nof_prb / 15 / sqrtf(cfg->ul_cfg.pusch.grant.L_prb) / 2); - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } /* Returns the transmission power for PUSCH for this subframe as defined in Section 5.1.1 of 36.213 */ -float srslte_ue_ul_pusch_power(srslte_ue_ul_t* q, srslte_ue_ul_cfg_t* cfg, float PL, float p0_preamble) +float srsran_ue_ul_pusch_power(srsran_ue_ul_t* q, srsran_ue_ul_cfg_t* cfg, float PL, float p0_preamble) { float p0_pusch, alpha; if (p0_preamble) { @@ -339,7 +339,7 @@ float srslte_ue_ul_pusch_power(srslte_ue_ul_t* q, srslte_ue_ul_cfg_t* cfg, float float beta_offset_pusch = 1; float MPR = q->pusch.cb_segm.K1 * q->pusch_cfg.cb_segm.C1 + q->pusch_cfg.cb_segm.K2 * q->pusch_cfg.cb_segm.C2; if (q->pusch.dci.cw.tbs == 0) { - beta_offset_pusch = srslte_sch_beta_cqi(q->pusch.uci_offset.I_offset_cqi); + beta_offset_pusch = srsran_sch_beta_cqi(q->pusch.uci_offset.I_offset_cqi); MPR = q->pusch_cfg.last_O_cqi; } MPR /= q->pusch.dci.nof_re; @@ -358,13 +358,13 @@ float srslte_ue_ul_pusch_power(srslte_ue_ul_t* q, srslte_ue_ul_cfg_t* cfg, float p0_pusch, alpha, PL); - return SRSLTE_MIN(SRSLTE_PC_MAX, pusch_power); + return SRSRAN_MIN(SRSRAN_PC_MAX, pusch_power); } /* Returns the transmission power for PUCCH for this subframe as defined in Section 5.1.2 of 36.213 */ -float srslte_ue_ul_pucch_power(srslte_ue_ul_t* q, srslte_ue_ul_cfg_t* cfg, srslte_uci_cfg_t* uci_cfg, float PL) +float srsran_ue_ul_pucch_power(srsran_ue_ul_t* q, srsran_ue_ul_cfg_t* cfg, srsran_uci_cfg_t* uci_cfg, float PL) { - srslte_pucch_format_t format = cfg->ul_cfg.pucch.format; + srsran_pucch_format_t format = cfg->ul_cfg.pucch.format; float p0_pucch = cfg->ul_cfg.power_ctrl.p0_nominal_pucch + cfg->ul_cfg.power_ctrl.p0_ue_pucch; @@ -373,13 +373,13 @@ float srslte_ue_ul_pucch_power(srslte_ue_ul_t* q, srslte_ue_ul_cfg_t* cfg, srslt float delta_f = cfg->ul_cfg.power_ctrl.delta_f_pucch[format_idx]; float h; - int n_cqi = srslte_cqi_size(&uci_cfg->cqi); - int n_harq = srslte_uci_cfg_total_ack(uci_cfg); + int n_cqi = srsran_cqi_size(&uci_cfg->cqi); + int n_harq = srsran_uci_cfg_total_ack(uci_cfg); - if (format <= SRSLTE_PUCCH_FORMAT_1B) { + if (format <= SRSRAN_PUCCH_FORMAT_1B) { h = 0; } else { - if (SRSLTE_CP_ISNORM(q->cell.cp)) { + if (SRSRAN_CP_ISNORM(q->cell.cp)) { if (n_cqi >= 4) { h = 10.0f * log10f(n_cqi / 4.0f); } else { @@ -404,29 +404,29 @@ float srslte_ue_ul_pucch_power(srslte_ue_ul_t* q, srslte_ue_ul_cfg_t* cfg, srslt return 0; } -static int srs_encode(srslte_ue_ul_t* q, uint32_t tti, srslte_ue_ul_cfg_t* cfg) +static int srs_encode(srsran_ue_ul_t* q, uint32_t tti, srsran_ue_ul_cfg_t* cfg) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q && cfg) { - srslte_vec_cf_zero(q->sf_symbols, SRSLTE_NOF_RE(q->cell)); + srsran_vec_cf_zero(q->sf_symbols, SRSRAN_NOF_RE(q->cell)); add_srs(q, cfg, tti); - srslte_ofdm_tx_sf(&q->fft); + srsran_ofdm_tx_sf(&q->fft); apply_cfo(q, cfg); - apply_norm(q, cfg, (float)q->cell.nof_prb / 15 / sqrtf(srslte_refsignal_srs_M_sc(&q->signals, &cfg->ul_cfg.srs))); + apply_norm(q, cfg, (float)q->cell.nof_prb / 15 / sqrtf(srsran_refsignal_srs_M_sc(&q->signals, &cfg->ul_cfg.srs))); - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } -static bool srs_tx_enabled(srslte_refsignal_srs_cfg_t* srs_cfg, uint32_t tti) +static bool srs_tx_enabled(srsran_refsignal_srs_cfg_t* srs_cfg, uint32_t tti) { if (srs_cfg->configured) { - if (srslte_refsignal_srs_send_cs(srs_cfg->subframe_config, tti % 10) == 1 && - srslte_refsignal_srs_send_ue(srs_cfg->I_srs, tti) == 1) { + if (srsran_refsignal_srs_send_cs(srs_cfg->subframe_config, tti % 10) == 1 && + srsran_refsignal_srs_send_ue(srs_cfg->I_srs, tti) == 1) { return true; } } @@ -434,7 +434,7 @@ static bool srs_tx_enabled(srslte_refsignal_srs_cfg_t* srs_cfg, uint32_t tti) } /* Returns the transmission power for SRS for this subframe as defined in Section 5.1.3 of 36.213 */ -float srs_power(srslte_ue_ul_t* q, srslte_ue_ul_cfg_t* cfg, float PL) +float srs_power(srsran_ue_ul_t* q, srsran_ue_ul_cfg_t* cfg, float PL) { float alpha = cfg->ul_cfg.power_ctrl.alpha; float p0_pusch = cfg->ul_cfg.power_ctrl.p0_nominal_pusch + cfg->ul_cfg.power_ctrl.p0_ue_pusch; @@ -442,7 +442,7 @@ float srs_power(srslte_ue_ul_t* q, srslte_ue_ul_cfg_t* cfg, float PL) // TODO: This implements closed-loop power control float f = 0; - uint32_t M_sc = srslte_refsignal_srs_M_sc(&q->signals, &cfg->ul_cfg.srs); + uint32_t M_sc = srsran_refsignal_srs_M_sc(&q->signals, &cfg->ul_cfg.srs); float p_srs_offset; if (cfg->ul_cfg.power_ctrl.delta_mcs_based) { @@ -466,74 +466,74 @@ float srs_power(srslte_ue_ul_t* q, srslte_ue_ul_cfg_t* cfg, float PL) } /* Procedure for determining PUCCH assignment 10.1 36.213 */ -void srslte_ue_ul_pucch_resource_selection(const srslte_cell_t* cell, - srslte_pucch_cfg_t* cfg, - const srslte_uci_cfg_t* uci_cfg, - const srslte_uci_value_t* uci_value, - uint8_t b[SRSLTE_UCI_MAX_ACK_BITS]) +void srsran_ue_ul_pucch_resource_selection(const srsran_cell_t* cell, + srsran_pucch_cfg_t* cfg, + const srsran_uci_cfg_t* uci_cfg, + const srsran_uci_value_t* uci_value, + uint8_t b[SRSRAN_UCI_MAX_ACK_BITS]) { // Get PUCCH Resources - cfg->format = srslte_pucch_proc_select_format(cell, cfg, uci_cfg, uci_value); - cfg->n_pucch = srslte_pucch_proc_get_npucch(cell, cfg, uci_cfg, uci_value, b); + cfg->format = srsran_pucch_proc_select_format(cell, cfg, uci_cfg, uci_value); + cfg->n_pucch = srsran_pucch_proc_get_npucch(cell, cfg, uci_cfg, uci_value, b); } /* Choose PUCCH format as in Sec 10.1 of 36.213 and generate PUCCH signal */ static int -pucch_encode(srslte_ue_ul_t* q, srslte_ul_sf_cfg_t* sf, srslte_ue_ul_cfg_t* cfg, srslte_uci_value_t* uci_data) +pucch_encode(srsran_ue_ul_t* q, srsran_ul_sf_cfg_t* sf, srsran_ue_ul_cfg_t* cfg, srsran_uci_value_t* uci_data) { - int ret = SRSLTE_ERROR_INVALID_INPUTS; + int ret = SRSRAN_ERROR_INVALID_INPUTS; if (q != NULL && cfg != NULL) { - srslte_uci_value_t uci_value2 = *uci_data; ///< Make copy of UCI Data, so the original input does not get altered - ret = SRSLTE_ERROR; + srsran_uci_value_t uci_value2 = *uci_data; ///< Make copy of UCI Data, so the original input does not get altered + ret = SRSRAN_ERROR; - if (!srslte_pucch_cfg_isvalid(&cfg->ul_cfg.pucch, q->cell.nof_prb)) { + if (!srsran_pucch_cfg_isvalid(&cfg->ul_cfg.pucch, q->cell.nof_prb)) { ERROR("Invalid PUCCH configuration"); return ret; } - srslte_vec_cf_zero(q->sf_symbols, SRSLTE_NOF_RE(q->cell)); + srsran_vec_cf_zero(q->sf_symbols, SRSRAN_NOF_RE(q->cell)); // Prepare configuration - srslte_ue_ul_pucch_resource_selection( + srsran_ue_ul_pucch_resource_selection( &q->cell, &cfg->ul_cfg.pucch, &cfg->ul_cfg.pucch.uci_cfg, uci_data, uci_value2.ack.ack_value); - srslte_refsignal_srs_pucch_shortened(&q->signals, sf, &cfg->ul_cfg.srs, &cfg->ul_cfg.pucch); + srsran_refsignal_srs_pucch_shortened(&q->signals, sf, &cfg->ul_cfg.srs, &cfg->ul_cfg.pucch); - if (srslte_pucch_encode(&q->pucch, sf, &cfg->ul_cfg.pucch, &uci_value2, q->sf_symbols)) { + if (srsran_pucch_encode(&q->pucch, sf, &cfg->ul_cfg.pucch, &uci_value2, q->sf_symbols)) { ERROR("Error encoding TB"); return ret; } - if (srslte_refsignal_dmrs_pucch_gen(&q->signals, sf, &cfg->ul_cfg.pucch, q->refsignal)) { + if (srsran_refsignal_dmrs_pucch_gen(&q->signals, sf, &cfg->ul_cfg.pucch, q->refsignal)) { ERROR("Error generating PUSCH DMRS signals"); return ret; } - srslte_refsignal_dmrs_pucch_put(&q->signals, &cfg->ul_cfg.pucch, q->refsignal, q->sf_symbols); + srsran_refsignal_dmrs_pucch_put(&q->signals, &cfg->ul_cfg.pucch, q->refsignal, q->sf_symbols); add_srs(q, cfg, sf->tti); - srslte_ofdm_tx_sf(&q->fft); + srsran_ofdm_tx_sf(&q->fft); apply_cfo(q, cfg); apply_norm(q, cfg, (float)q->cell.nof_prb / 15 / 10); char txt[256]; - srslte_pucch_tx_info(&cfg->ul_cfg.pucch, uci_data, txt, sizeof(txt)); + srsran_pucch_tx_info(&cfg->ul_cfg.pucch, uci_data, txt, sizeof(txt)); INFO("[PUCCH] Encoded %s", txt); - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; } /* Returns 1 if a SR needs to be sent at current_tti given I_sr, as defined in Section 10.1 of 36.213 */ -int srslte_ue_ul_sr_send_tti(const srslte_pucch_cfg_t* cfg, uint32_t current_tti) +int srsran_ue_ul_sr_send_tti(const srsran_pucch_cfg_t* cfg, uint32_t current_tti) { if (!cfg->sr_configured) { - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } uint32_t sr_periodicity; uint32_t sr_N_offset; @@ -561,20 +561,20 @@ int srslte_ue_ul_sr_send_tti(const srslte_pucch_cfg_t* cfg, uint32_t current_tti sr_periodicity = 1; sr_N_offset = I_sr - 157; } else { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (current_tti >= sr_N_offset) { if ((current_tti - sr_N_offset) % sr_periodicity == 0) { return 1; } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -bool srslte_ue_ul_gen_sr(srslte_ue_ul_cfg_t* cfg, srslte_ul_sf_cfg_t* sf, srslte_uci_data_t* uci_data, bool sr_request) +bool srsran_ue_ul_gen_sr(srsran_ue_ul_cfg_t* cfg, srsran_ul_sf_cfg_t* sf, srsran_uci_data_t* uci_data, bool sr_request) { uci_data->value.scheduling_request = false; - if (srslte_ue_ul_sr_send_tti(&cfg->ul_cfg.pucch, sf->tti)) { + if (srsran_ue_ul_sr_send_tti(&cfg->ul_cfg.pucch, sf->tti)) { if (sr_request) { // Get I_sr parameter uci_data->value.scheduling_request = true; @@ -585,16 +585,16 @@ bool srslte_ue_ul_gen_sr(srslte_ue_ul_cfg_t* cfg, srslte_ul_sf_cfg_t* sf, srslte return false; } -#define uci_pending(cfg) (srslte_uci_cfg_total_ack(&cfg) > 0 || cfg.cqi.data_enable || cfg.cqi.ri_len > 0) +#define uci_pending(cfg) (srsran_uci_cfg_total_ack(&cfg) > 0 || cfg.cqi.data_enable || cfg.cqi.ri_len > 0) -int srslte_ue_ul_encode(srslte_ue_ul_t* q, srslte_ul_sf_cfg_t* sf, srslte_ue_ul_cfg_t* cfg, srslte_pusch_data_t* data) +int srsran_ue_ul_encode(srsran_ue_ul_t* q, srsran_ul_sf_cfg_t* sf, srsran_ue_ul_cfg_t* cfg, srsran_pusch_data_t* data) { - int ret = SRSLTE_SUCCESS; + int ret = SRSRAN_SUCCESS; /* Convert DTX to NACK in channel-selection mode (Release 10 only)*/ - if (cfg->ul_cfg.pucch.ack_nack_feedback_mode != SRSLTE_PUCCH_ACK_NACK_FEEDBACK_MODE_NORMAL) { + if (cfg->ul_cfg.pucch.ack_nack_feedback_mode != SRSRAN_PUCCH_ACK_NACK_FEEDBACK_MODE_NORMAL) { uint32_t dtx_count = 0; - for (uint32_t a = 0; a < srslte_uci_cfg_total_ack(&cfg->ul_cfg.pusch.uci_cfg); a++) { + for (uint32_t a = 0; a < srsran_uci_cfg_total_ack(&cfg->ul_cfg.pusch.uci_cfg); a++) { if (data->uci.ack.ack_value[a] == 2) { data->uci.ack.ack_value[a] = 0; dtx_count++; @@ -602,8 +602,8 @@ int srslte_ue_ul_encode(srslte_ue_ul_t* q, srslte_ul_sf_cfg_t* sf, srslte_ue_ul_ } /* If all bits are DTX, do not transmit HARQ */ - if (dtx_count == srslte_uci_cfg_total_ack(&cfg->ul_cfg.pusch.uci_cfg)) { - for (int i = 0; i < SRSLTE_MAX_CARRIERS; i++) { + if (dtx_count == srsran_uci_cfg_total_ack(&cfg->ul_cfg.pusch.uci_cfg)) { + for (int i = 0; i < SRSRAN_MAX_CARRIERS; i++) { cfg->ul_cfg.pusch.uci_cfg.ack[i].nof_acks = 0; } } @@ -615,7 +615,7 @@ int srslte_ue_ul_encode(srslte_ue_ul_t* q, srslte_ul_sf_cfg_t* sf, srslte_ue_ul_ cfg->cc_idx == 0) { // Send PUCCH over PCell only if (!cfg->ul_cfg.pucch.rnti) { ERROR("Encoding PUCCH: rnti not set in ul_cfg\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } ret = pucch_encode(q, sf, cfg, &data->uci) ? -1 : 1; } else if (srs_tx_enabled(&cfg->ul_cfg.srs, sf->tti)) { @@ -623,16 +623,16 @@ int srslte_ue_ul_encode(srslte_ue_ul_t* q, srslte_ul_sf_cfg_t* sf, srslte_ue_ul_ } else { // Set Zero output buffer if no UL transmission is required so the buffer does not keep previous transmission data if (q->cell.nof_prb) { - srslte_vec_cf_zero(q->out_buffer, SRSLTE_SF_LEN_PRB(q->cell.nof_prb)); + srsran_vec_cf_zero(q->out_buffer, SRSRAN_SF_LEN_PRB(q->cell.nof_prb)); } } return ret; } -bool srslte_ue_ul_info(srslte_ue_ul_cfg_t* cfg, - srslte_ul_sf_cfg_t* sf, - srslte_uci_value_t* uci_data, +bool srsran_ue_ul_info(srsran_ue_ul_cfg_t* cfg, + srsran_ul_sf_cfg_t* sf, + srsran_uci_value_t* uci_data, char* str, uint32_t str_len) { @@ -641,12 +641,12 @@ bool srslte_ue_ul_info(srslte_ue_ul_cfg_t* cfg, if (cfg->grant_available) { n = snprintf(str, str_len, "PUSCH: cc=%d, tti_tx=%d, %s", cfg->cc_idx, sf->tti, sf->shortened ? "shortened, " : ""); - srslte_pusch_tx_info(&cfg->ul_cfg.pusch, uci_data, &str[n], str_len - n); + srsran_pusch_tx_info(&cfg->ul_cfg.pusch, uci_data, &str[n], str_len - n); ret = true; } else if ((uci_pending(cfg->ul_cfg.pucch.uci_cfg) || uci_data->scheduling_request) && cfg->cc_idx == 0) { // Send PUCCH over PCell only n = sprintf(str, "PUCCH: cc=0, tti_tx=%d, %s", sf->tti, sf->shortened ? "shortened, " : ""); - srslte_pucch_tx_info(&cfg->ul_cfg.pucch, uci_data, &str[n], str_len - n); + srsran_pucch_tx_info(&cfg->ul_cfg.pucch, uci_data, &str[n], str_len - n); ret = true; } else if (srs_tx_enabled(&cfg->ul_cfg.srs, sf->tti)) { n = sprintf(str, "SRS: tx_tti=%d", sf->tti); diff --git a/lib/src/phy/ue/ue_ul_nr.c b/lib/src/phy/ue/ue_ul_nr.c index 6c64b9a2b..146b297c0 100644 --- a/lib/src/phy/ue/ue_ul_nr.c +++ b/lib/src/phy/ue/ue_ul_nr.c @@ -2,148 +2,148 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of * the distribution. * */ -#include "srslte/phy/ue/ue_ul_nr.h" -#include "srslte/phy/ch_estimation/dmrs_pucch.h" -#include "srslte/phy/utils/debug.h" +#include "srsran/phy/ue/ue_ul_nr.h" +#include "srsran/phy/ch_estimation/dmrs_pucch.h" +#include "srsran/phy/utils/debug.h" #include -int srslte_ue_ul_nr_init(srslte_ue_ul_nr_t* q, cf_t* output, const srslte_ue_ul_nr_args_t* args) +int srsran_ue_ul_nr_init(srsran_ue_ul_nr_t* q, cf_t* output, const srsran_ue_ul_nr_args_t* args) { if (q == NULL || output == NULL || args == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } // Initialise memory - SRSLTE_MEM_ZERO(q, srslte_ue_ul_nr_t, 1); + SRSRAN_MEM_ZERO(q, srsran_ue_ul_nr_t, 1); q->max_prb = args->nof_max_prb; - q->sf_symbols[0] = srslte_vec_cf_malloc(SRSLTE_SLOT_LEN_RE_NR(q->max_prb)); + q->sf_symbols[0] = srsran_vec_cf_malloc(SRSRAN_SLOT_LEN_RE_NR(q->max_prb)); if (q->sf_symbols[0] == NULL) { ERROR("Malloc"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_pusch_nr_init_ue(&q->pusch, &args->pusch) < SRSLTE_SUCCESS) { + if (srsran_pusch_nr_init_ue(&q->pusch, &args->pusch) < SRSRAN_SUCCESS) { ERROR("Initiating PUSCH"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - srslte_ofdm_cfg_t fft_cfg = {}; + srsran_ofdm_cfg_t fft_cfg = {}; fft_cfg.nof_prb = args->nof_max_prb; - fft_cfg.symbol_sz = srslte_min_symbol_sz_rb(args->nof_max_prb); + fft_cfg.symbol_sz = srsran_min_symbol_sz_rb(args->nof_max_prb); fft_cfg.keep_dc = true; fft_cfg.in_buffer = q->sf_symbols[0]; fft_cfg.out_buffer = output; - if (srslte_ofdm_tx_init_cfg(&q->ifft, &fft_cfg) < SRSLTE_SUCCESS) { + if (srsran_ofdm_tx_init_cfg(&q->ifft, &fft_cfg) < SRSRAN_SUCCESS) { ERROR("Initiating OFDM"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_dmrs_sch_init(&q->dmrs, false) < SRSLTE_SUCCESS) { + if (srsran_dmrs_sch_init(&q->dmrs, false) < SRSRAN_SUCCESS) { ERROR("Error DMRS"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_pucch_nr_init(&q->pucch, &args->pucch) < SRSLTE_SUCCESS) { + if (srsran_pucch_nr_init(&q->pucch, &args->pucch) < SRSRAN_SUCCESS) { ERROR("Error UCI\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_ue_ul_nr_set_carrier(srslte_ue_ul_nr_t* q, const srslte_carrier_nr_t* carrier) +int srsran_ue_ul_nr_set_carrier(srsran_ue_ul_nr_t* q, const srsran_carrier_nr_t* carrier) { if (q == NULL || carrier == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } q->carrier = *carrier; - srslte_ofdm_cfg_t fft_cfg = {}; + srsran_ofdm_cfg_t fft_cfg = {}; fft_cfg.nof_prb = carrier->nof_prb; - fft_cfg.symbol_sz = srslte_min_symbol_sz_rb(carrier->nof_prb); + fft_cfg.symbol_sz = srsran_min_symbol_sz_rb(carrier->nof_prb); fft_cfg.keep_dc = true; - if (srslte_ofdm_tx_init_cfg(&q->ifft, &fft_cfg) < SRSLTE_SUCCESS) { + if (srsran_ofdm_tx_init_cfg(&q->ifft, &fft_cfg) < SRSRAN_SUCCESS) { ERROR("Initiating OFDM"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_pusch_nr_set_carrier(&q->pusch, carrier) < SRSLTE_SUCCESS) { + if (srsran_pusch_nr_set_carrier(&q->pusch, carrier) < SRSRAN_SUCCESS) { ERROR("Setting PUSCH carrier"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_pucch_nr_set_carrier(&q->pucch, carrier) < SRSLTE_SUCCESS) { + if (srsran_pucch_nr_set_carrier(&q->pucch, carrier) < SRSRAN_SUCCESS) { ERROR("Setting PUSCH carrier"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_dmrs_sch_set_carrier(&q->dmrs, carrier)) { + if (srsran_dmrs_sch_set_carrier(&q->dmrs, carrier)) { ERROR("Setting DMRS carrier"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_ue_ul_nr_encode_pusch(srslte_ue_ul_nr_t* q, - const srslte_slot_cfg_t* slot_cfg, - const srslte_sch_cfg_nr_t* pusch_cfg, - const srslte_pusch_data_nr_t* data) +int srsran_ue_ul_nr_encode_pusch(srsran_ue_ul_nr_t* q, + const srsran_slot_cfg_t* slot_cfg, + const srsran_sch_cfg_nr_t* pusch_cfg, + const srsran_pusch_data_nr_t* data) { // Check inputs if (q == NULL || pusch_cfg == NULL || data == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } // Fill with zeros the whole resource grid - srslte_vec_cf_zero(q->sf_symbols[0], SRSLTE_SLOT_LEN_RE_NR(q->carrier.nof_prb)); + srsran_vec_cf_zero(q->sf_symbols[0], SRSRAN_SLOT_LEN_RE_NR(q->carrier.nof_prb)); // Encode PUSCH - if (srslte_pusch_nr_encode(&q->pusch, pusch_cfg, &pusch_cfg->grant, data, q->sf_symbols) < SRSLTE_SUCCESS) { + if (srsran_pusch_nr_encode(&q->pusch, pusch_cfg, &pusch_cfg->grant, data, q->sf_symbols) < SRSRAN_SUCCESS) { ERROR("Encoding PUSCH"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Put DMRS - if (srslte_dmrs_sch_put_sf(&q->dmrs, slot_cfg, pusch_cfg, &pusch_cfg->grant, q->sf_symbols[0])) { + if (srsran_dmrs_sch_put_sf(&q->dmrs, slot_cfg, pusch_cfg, &pusch_cfg->grant, q->sf_symbols[0])) { ERROR("Putting DMRS"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Generate signal - srslte_ofdm_tx_sf(&q->ifft); + srsran_ofdm_tx_sf(&q->ifft); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -static int ue_ul_nr_encode_pucch_format0(srslte_ue_ul_nr_t* q, - const srslte_pucch_nr_resource_t* resource, - const srslte_uci_data_nr_t* uci_data) +static int ue_ul_nr_encode_pucch_format0(srsran_ue_ul_nr_t* q, + const srsran_pucch_nr_resource_t* resource, + const srsran_uci_data_nr_t* uci_data) { ERROR("Not implemented"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } -static int ue_ul_nr_encode_pucch_format1(srslte_ue_ul_nr_t* q, - const srslte_slot_cfg_t* slot, - const srslte_pucch_nr_common_cfg_t* cfg, - const srslte_pucch_nr_resource_t* resource, - const srslte_uci_data_nr_t* uci_data) +static int ue_ul_nr_encode_pucch_format1(srsran_ue_ul_nr_t* q, + const srsran_slot_cfg_t* slot, + const srsran_pucch_nr_common_cfg_t* cfg, + const srsran_pucch_nr_resource_t* resource, + const srsran_uci_data_nr_t* uci_data) { - uint8_t b[SRSLTE_PUCCH_NR_FORMAT1_MAX_NOF_BITS] = {}; + uint8_t b[SRSRAN_PUCCH_NR_FORMAT1_MAX_NOF_BITS] = {}; // Set ACK bits - uint32_t nof_bits = SRSLTE_MIN(SRSLTE_PUCCH_NR_FORMAT1_MAX_NOF_BITS, uci_data->cfg.o_ack); + uint32_t nof_bits = SRSRAN_MIN(SRSRAN_PUCCH_NR_FORMAT1_MAX_NOF_BITS, uci_data->cfg.o_ack); for (uint32_t i = 0; i < nof_bits; i++) { b[i] = uci_data->value.ack[i]; } @@ -156,121 +156,121 @@ static int ue_ul_nr_encode_pucch_format1(srslte_ue_ul_nr_t* q, nof_bits = 1; } - if (srslte_dmrs_pucch_format1_put(&q->pucch, &q->carrier, cfg, slot, resource, q->sf_symbols[0])) { - return SRSLTE_ERROR; + if (srsran_dmrs_pucch_format1_put(&q->pucch, &q->carrier, cfg, slot, resource, q->sf_symbols[0])) { + return SRSRAN_ERROR; } - return srslte_pucch_nr_format1_encode(&q->pucch, cfg, slot, resource, b, nof_bits, q->sf_symbols[0]); + return srsran_pucch_nr_format1_encode(&q->pucch, cfg, slot, resource, b, nof_bits, q->sf_symbols[0]); } -int srslte_ue_ul_nr_encode_pucch(srslte_ue_ul_nr_t* q, - const srslte_slot_cfg_t* slot_cfg, - const srslte_pucch_nr_common_cfg_t* cfg, - const srslte_pucch_nr_resource_t* resource, - const srslte_uci_data_nr_t* uci_data) +int srsran_ue_ul_nr_encode_pucch(srsran_ue_ul_nr_t* q, + const srsran_slot_cfg_t* slot_cfg, + const srsran_pucch_nr_common_cfg_t* cfg, + const srsran_pucch_nr_resource_t* resource, + const srsran_uci_data_nr_t* uci_data) { // Check inputs if (q == NULL || slot_cfg == NULL || resource == NULL || uci_data == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } // Fill with zeros the whole resource grid - srslte_vec_cf_zero(q->sf_symbols[0], SRSLTE_SLOT_LEN_RE_NR(q->carrier.nof_prb)); + srsran_vec_cf_zero(q->sf_symbols[0], SRSRAN_SLOT_LEN_RE_NR(q->carrier.nof_prb)); // Actual PUCCH encoding switch (resource->format) { - case SRSLTE_PUCCH_NR_FORMAT_0: - if (ue_ul_nr_encode_pucch_format0(q, resource, uci_data) < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + case SRSRAN_PUCCH_NR_FORMAT_0: + if (ue_ul_nr_encode_pucch_format0(q, resource, uci_data) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } break; - case SRSLTE_PUCCH_NR_FORMAT_1: - if (ue_ul_nr_encode_pucch_format1(q, slot_cfg, cfg, resource, uci_data) < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + case SRSRAN_PUCCH_NR_FORMAT_1: + if (ue_ul_nr_encode_pucch_format1(q, slot_cfg, cfg, resource, uci_data) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } break; - case SRSLTE_PUCCH_NR_FORMAT_2: - if (srslte_dmrs_pucch_format2_put(&q->pucch, &q->carrier, cfg, slot_cfg, resource, q->sf_symbols[0])) { - return SRSLTE_ERROR; + case SRSRAN_PUCCH_NR_FORMAT_2: + if (srsran_dmrs_pucch_format2_put(&q->pucch, &q->carrier, cfg, slot_cfg, resource, q->sf_symbols[0])) { + return SRSRAN_ERROR; } - if (srslte_pucch_nr_format_2_3_4_encode( + if (srsran_pucch_nr_format_2_3_4_encode( &q->pucch, cfg, slot_cfg, resource, &uci_data->cfg, &uci_data->value, q->sf_symbols[0]) < - SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } break; - case SRSLTE_PUCCH_NR_FORMAT_3: - case SRSLTE_PUCCH_NR_FORMAT_4: + case SRSRAN_PUCCH_NR_FORMAT_3: + case SRSRAN_PUCCH_NR_FORMAT_4: ERROR("PUCCH format %d NOT implemented", (int)resource->format); break; - case SRSLTE_PUCCH_NR_FORMAT_ERROR: + case SRSRAN_PUCCH_NR_FORMAT_ERROR: default: ERROR("Invalid case"); break; } // Generate signal - srslte_ofdm_tx_sf(&q->ifft); + srsran_ofdm_tx_sf(&q->ifft); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -void srslte_ue_ul_nr_free(srslte_ue_ul_nr_t* q) +void srsran_ue_ul_nr_free(srsran_ue_ul_nr_t* q) { if (q == NULL) { return; } - srslte_ofdm_tx_free(&q->ifft); + srsran_ofdm_tx_free(&q->ifft); if (q->sf_symbols[0] != NULL) { free(q->sf_symbols[0]); } - srslte_pusch_nr_free(&q->pusch); - srslte_dmrs_sch_free(&q->dmrs); + srsran_pusch_nr_free(&q->pusch); + srsran_dmrs_sch_free(&q->dmrs); - SRSLTE_MEM_ZERO(q, srslte_ue_ul_nr_t, 1); + SRSRAN_MEM_ZERO(q, srsran_ue_ul_nr_t, 1); } -int srslte_ue_ul_nr_pusch_info(const srslte_ue_ul_nr_t* q, - const srslte_sch_cfg_nr_t* cfg, - const srslte_uci_value_nr_t* uci_value, +int srsran_ue_ul_nr_pusch_info(const srsran_ue_ul_nr_t* q, + const srsran_sch_cfg_nr_t* cfg, + const srsran_uci_value_nr_t* uci_value, char* str, uint32_t str_len) { int len = 0; // Append PDSCH info - len += srslte_pusch_nr_tx_info(&q->pusch, cfg, &cfg->grant, uci_value, &str[len], str_len - len); + len += srsran_pusch_nr_tx_info(&q->pusch, cfg, &cfg->grant, uci_value, &str[len], str_len - len); return len; } -int srslte_ue_ul_nr_pucch_info(const srslte_pucch_nr_resource_t* resource, - const srslte_uci_data_nr_t* uci_data, +int srsran_ue_ul_nr_pucch_info(const srsran_pucch_nr_resource_t* resource, + const srsran_uci_data_nr_t* uci_data, char* str, uint32_t str_len) { int len = 0; // Append PDSCH info - len += srslte_pucch_nr_tx_info(resource, uci_data, &str[len], str_len - len); + len += srsran_pucch_nr_tx_info(resource, uci_data, &str[len], str_len - len); return len; } -int srslte_ue_ul_nr_sr_send_slot(const srslte_pucch_nr_sr_resource_t sr_resources[SRSLTE_PUCCH_MAX_NOF_SR_RESOURCES], +int srsran_ue_ul_nr_sr_send_slot(const srsran_pucch_nr_sr_resource_t sr_resources[SRSRAN_PUCCH_MAX_NOF_SR_RESOURCES], uint32_t slot_idx, - uint32_t sr_resource_id[SRSLTE_PUCCH_MAX_NOF_SR_RESOURCES]) + uint32_t sr_resource_id[SRSRAN_PUCCH_MAX_NOF_SR_RESOURCES]) { int count = 0; // Check inputs if (sr_resources == NULL) { - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } // Iterate over all SR resources - for (uint32_t i = 0; i < SRSLTE_PUCCH_MAX_NOF_SR_RESOURCES; i++) { - const srslte_pucch_nr_sr_resource_t* res = &sr_resources[i]; + for (uint32_t i = 0; i < SRSRAN_PUCCH_MAX_NOF_SR_RESOURCES; i++) { + const srsran_pucch_nr_sr_resource_t* res = &sr_resources[i]; // Skip if resource is not provided if (!res->configured) { diff --git a/lib/src/phy/utils/CMakeLists.txt b/lib/src/phy/utils/CMakeLists.txt index 8ce1ed8c6..e995f28d8 100644 --- a/lib/src/phy/utils/CMakeLists.txt +++ b/lib/src/phy/utils/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -7,10 +7,10 @@ # file(GLOB SOURCES "*.c" "*.cpp") -add_library(srslte_utils OBJECT ${SOURCES}) +add_library(srsran_utils OBJECT ${SOURCES}) if(VOLK_FOUND) - set_target_properties(srslte_utils PROPERTIES COMPILE_DEFINITIONS "${VOLK_DEFINITIONS}") + set_target_properties(srsran_utils PROPERTIES COMPILE_DEFINITIONS "${VOLK_DEFINITIONS}") endif(VOLK_FOUND) add_subdirectory(test) diff --git a/lib/src/phy/utils/bit.c b/lib/src/phy/utils/bit.c index 584fc8584..c9e676e24 100644 --- a/lib/src/phy/utils/bit.c +++ b/lib/src/phy/utils/bit.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -23,18 +23,18 @@ #endif /* LV_HAVE_SSE */ -#include "srslte/phy/utils/bit.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/utils/bit.h" +#include "srsran/phy/utils/vector.h" -void srslte_bit_interleaver_init(srslte_bit_interleaver_t* q, uint16_t* interleaver, uint32_t nof_bits) +void srsran_bit_interleaver_init(srsran_bit_interleaver_t* q, uint16_t* interleaver, uint32_t nof_bits) { static const uint8_t mask[] = {0x80, 0x40, 0x20, 0x10, 0x8, 0x4, 0x2, 0x1}; - bzero(q, sizeof(srslte_bit_interleaver_t)); + bzero(q, sizeof(srsran_bit_interleaver_t)); - q->interleaver = srslte_vec_u16_malloc(nof_bits); - q->byte_idx = srslte_vec_u16_malloc(nof_bits); - q->bit_mask = srslte_vec_u8_malloc(nof_bits); + q->interleaver = srsran_vec_u16_malloc(nof_bits); + q->byte_idx = srsran_vec_u16_malloc(nof_bits); + q->bit_mask = srsran_vec_u8_malloc(nof_bits); q->nof_bits = nof_bits; for (int i = 0; i < nof_bits; i++) { @@ -45,7 +45,7 @@ void srslte_bit_interleaver_init(srslte_bit_interleaver_t* q, uint16_t* interlea } } -void srslte_bit_interleaver_free(srslte_bit_interleaver_t* q) +void srsran_bit_interleaver_free(srsran_bit_interleaver_t* q) { if (q->interleaver) { free(q->interleaver); @@ -59,10 +59,10 @@ void srslte_bit_interleaver_free(srslte_bit_interleaver_t* q) free(q->bit_mask); } - bzero(q, sizeof(srslte_bit_interleaver_t)); + bzero(q, sizeof(srsran_bit_interleaver_t)); } -void srslte_bit_interleaver_run(srslte_bit_interleaver_t* q, uint8_t* input, uint8_t* output, uint16_t w_offset) +void srsran_bit_interleaver_run(srsran_bit_interleaver_t* q, uint8_t* input, uint8_t* output, uint16_t w_offset) { static const uint8_t mask[] = {0x80, 0x40, 0x20, 0x10, 0x8, 0x4, 0x2, 0x1}; uint16_t* byte_idx = q->byte_idx; @@ -190,12 +190,12 @@ void srslte_bit_interleaver_run(srslte_bit_interleaver_t* q, uint8_t* input, uin #endif } -void srslte_bit_interleave_i(uint8_t* input, uint8_t* output, uint32_t* interleaver, uint32_t nof_bits) +void srsran_bit_interleave_i(uint8_t* input, uint8_t* output, uint32_t* interleaver, uint32_t nof_bits) { - srslte_bit_interleave_i_w_offset(input, output, interleaver, nof_bits, 0); + srsran_bit_interleave_i_w_offset(input, output, interleaver, nof_bits, 0); } -void srslte_bit_interleave_i_w_offset(uint8_t* input, +void srsran_bit_interleave_i_w_offset(uint8_t* input, uint8_t* output, uint32_t* interleaver, uint32_t nof_bits, @@ -350,12 +350,12 @@ void srslte_bit_interleave_i_w_offset(uint8_t* input, } } -void srslte_bit_interleave(uint8_t* input, uint8_t* output, uint16_t* interleaver, uint32_t nof_bits) +void srsran_bit_interleave(uint8_t* input, uint8_t* output, uint16_t* interleaver, uint32_t nof_bits) { - srslte_bit_interleave_w_offset(input, output, interleaver, nof_bits, 0); + srsran_bit_interleave_w_offset(input, output, interleaver, nof_bits, 0); } -void srslte_bit_interleave_w_offset(uint8_t* input, +void srsran_bit_interleave_w_offset(uint8_t* input, uint8_t* output, uint16_t* interleaver, uint32_t nof_bits, @@ -673,7 +673,7 @@ bitarray_copy(const unsigned char* src_org, int src_offset, int src_len, unsigne * @param src_offset Input array read offset in bits * @param nof_bits Number of bits to copy */ -void srslte_bit_copy(uint8_t* dst, uint32_t dst_offset, uint8_t* src, uint32_t src_offset, uint32_t nof_bits) +void srsran_bit_copy(uint8_t* dst, uint32_t dst_offset, uint8_t* src, uint32_t src_offset, uint32_t nof_bits) { static const uint8_t mask_dst[] = {0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff}; if ((dst_offset % 8) == 0 && (src_offset % 8) == 0) { @@ -688,19 +688,19 @@ void srslte_bit_copy(uint8_t* dst, uint32_t dst_offset, uint8_t* src, uint32_t s } } -void srslte_bit_unpack_vector(const uint8_t* packed, uint8_t* unpacked, int nof_bits) +void srsran_bit_unpack_vector(const uint8_t* packed, uint8_t* unpacked, int nof_bits) { uint32_t i, nbytes; nbytes = nof_bits / 8; for (i = 0; i < nbytes; i++) { - srslte_bit_unpack(packed[i], &unpacked, 8); + srsran_bit_unpack(packed[i], &unpacked, 8); } if (nof_bits % 8) { - srslte_bit_unpack(packed[i] >> (8 - nof_bits % 8), &unpacked, nof_bits % 8); + srsran_bit_unpack(packed[i] >> (8 - nof_bits % 8), &unpacked, nof_bits % 8); } } -void srslte_bit_unpack_l(uint64_t value, uint8_t** bits, int nof_bits) +void srsran_bit_unpack_l(uint64_t value, uint8_t** bits, int nof_bits) { int i; @@ -717,7 +717,7 @@ void srslte_bit_unpack_l(uint64_t value, uint8_t** bits, int nof_bits) * @param[in] nof_bits Number of bits to unpack * @param[out] bits Points to buffer pointer. The buffer pointer will be advanced by nof_bits */ -void srslte_bit_unpack(uint32_t value, uint8_t** bits, int nof_bits) +void srsran_bit_unpack(uint32_t value, uint8_t** bits, int nof_bits) { int i; @@ -727,7 +727,7 @@ void srslte_bit_unpack(uint32_t value, uint8_t** bits, int nof_bits) *bits += nof_bits; } -void srslte_bit_pack_vector(uint8_t* unpacked, uint8_t* packed, int nof_bits) +void srsran_bit_pack_vector(uint8_t* unpacked, uint8_t* packed, int nof_bits) { uint32_t i, nbytes; nbytes = nof_bits / 8; @@ -746,17 +746,17 @@ void srslte_bit_pack_vector(uint8_t* unpacked, uint8_t* packed, int nof_bits) } #else /* LV_HAVE_SSE */ for (i = 0; i < nbytes; i++) { - packed[i] = srslte_bit_pack(&unpacked, 8); + packed[i] = srsran_bit_pack(&unpacked, 8); } #endif /* LV_HAVE_SSE */ if (nof_bits % 8) { - packed[i] = srslte_bit_pack(&unpacked, nof_bits % 8); + packed[i] = srsran_bit_pack(&unpacked, nof_bits % 8); packed[i] <<= 8 - (nof_bits % 8); } } -uint32_t srslte_bit_pack(uint8_t** bits, int nof_bits) +uint32_t srsran_bit_pack(uint8_t** bits, int nof_bits) { int i; uint32_t value = 0; @@ -768,7 +768,7 @@ uint32_t srslte_bit_pack(uint8_t** bits, int nof_bits) return value; } -uint64_t srslte_bit_pack_l(uint8_t** bits, int nof_bits) +uint64_t srsran_bit_pack_l(uint8_t** bits, int nof_bits) { int i; uint64_t value = 0; @@ -780,7 +780,7 @@ uint64_t srslte_bit_pack_l(uint8_t** bits, int nof_bits) return value; } -void srslte_bit_fprint(FILE* stream, uint8_t* bits, int nof_bits) +void srsran_bit_fprint(FILE* stream, uint8_t* bits, int nof_bits) { int i; @@ -791,7 +791,7 @@ void srslte_bit_fprint(FILE* stream, uint8_t* bits, int nof_bits) fprintf(stream, "%d]\n", bits[i]); } -uint32_t srslte_bit_diff(const uint8_t* x, const uint8_t* y, int nbits) +uint32_t srsran_bit_diff(const uint8_t* x, const uint8_t* y, int nbits) { uint32_t errors = 0; for (int i = 0; i < nbits; i++) { @@ -803,7 +803,7 @@ uint32_t srslte_bit_diff(const uint8_t* x, const uint8_t* y, int nbits) } // Counts the number of ones in a word. K&R book exercise 2.9 -uint32_t srslte_bit_count(uint32_t n) +uint32_t srsran_bit_count(uint32_t n) { int c; for (c = 0; n; c++) diff --git a/lib/src/phy/utils/cexptab.c b/lib/src/phy/utils/cexptab.c index 907478f0b..b76adf4f3 100644 --- a/lib/src/phy/utils/cexptab.c +++ b/lib/src/phy/utils/cexptab.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -16,35 +16,35 @@ #include #include -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/utils/cexptab.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/utils/cexptab.h" +#include "srsran/phy/utils/vector.h" -int srslte_cexptab_init(srslte_cexptab_t* h, uint32_t size) +int srsran_cexptab_init(srsran_cexptab_t* h, uint32_t size) { uint32_t i; h->size = size; - h->tab = srslte_vec_cf_malloc((1 + size)); + h->tab = srsran_vec_cf_malloc((1 + size)); if (h->tab) { for (i = 0; i < size; i++) { h->tab[i] = cexpf(_Complex_I * 2 * M_PI * (float)i / size); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } else { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } -void srslte_cexptab_free(srslte_cexptab_t* h) +void srsran_cexptab_free(srsran_cexptab_t* h) { if (h->tab) { free(h->tab); } - bzero(h, sizeof(srslte_cexptab_t)); + bzero(h, sizeof(srsran_cexptab_t)); } -void srslte_cexptab_gen(srslte_cexptab_t* h, cf_t* x, float freq, uint32_t len) +void srsran_cexptab_gen(srsran_cexptab_t* h, cf_t* x, float freq, uint32_t len) { uint32_t i; uint32_t idx; @@ -64,7 +64,7 @@ void srslte_cexptab_gen(srslte_cexptab_t* h, cf_t* x, float freq, uint32_t len) } } -void srslte_cexptab_gen_direct(cf_t* x, float freq, uint32_t len) +void srsran_cexptab_gen_direct(cf_t* x, float freq, uint32_t len) { uint32_t i; for (i = 0; i < len; i++) { @@ -72,12 +72,12 @@ void srslte_cexptab_gen_direct(cf_t* x, float freq, uint32_t len) } } -void srslte_cexptab_gen_sf(cf_t* x, float freq, uint32_t fft_size) +void srsran_cexptab_gen_sf(cf_t* x, float freq, uint32_t fft_size) { cf_t* ptr = x; for (uint32_t n = 0; n < 2; n++) { for (uint32_t i = 0; i < 7; i++) { - uint32_t cplen = SRSLTE_CP_LEN_NORM(i, fft_size); + uint32_t cplen = SRSRAN_CP_LEN_NORM(i, fft_size); for (uint32_t t = 0; t < fft_size + cplen; t++) { ptr[t] = cexpf(I * 2 * M_PI * ((float)t - (float)cplen) * freq / fft_size); } diff --git a/lib/src/phy/utils/convolution.c b/lib/src/phy/utils/convolution.c index 766f024df..bc8ecb8ca 100644 --- a/lib/src/phy/utils/convolution.c +++ b/lib/src/phy/utils/convolution.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,47 +13,47 @@ #include #include -#include "srslte/phy/dft/dft.h" -#include "srslte/phy/utils/convolution.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/dft/dft.h" +#include "srsran/phy/utils/convolution.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" -int srslte_conv_fft_cc_init(srslte_conv_fft_cc_t* q, uint32_t input_len, uint32_t filter_len) +int srsran_conv_fft_cc_init(srsran_conv_fft_cc_t* q, uint32_t input_len, uint32_t filter_len) { - bzero(q, sizeof(srslte_conv_fft_cc_t)); + bzero(q, sizeof(srsran_conv_fft_cc_t)); q->input_len = input_len; q->filter_len = filter_len; q->output_len = input_len + filter_len; q->max_filter_len = filter_len; q->max_input_len = input_len; - q->input_fft = srslte_vec_cf_malloc(q->output_len); - q->filter_fft = srslte_vec_cf_malloc(q->output_len); - q->output_fft = srslte_vec_cf_malloc(q->output_len); + q->input_fft = srsran_vec_cf_malloc(q->output_len); + q->filter_fft = srsran_vec_cf_malloc(q->output_len); + q->output_fft = srsran_vec_cf_malloc(q->output_len); if (!q->input_fft || !q->filter_fft || !q->output_fft) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_dft_plan(&q->input_plan, q->output_len, SRSLTE_DFT_FORWARD, SRSLTE_DFT_COMPLEX)) { + if (srsran_dft_plan(&q->input_plan, q->output_len, SRSRAN_DFT_FORWARD, SRSRAN_DFT_COMPLEX)) { ERROR("Error initiating input plan"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_dft_plan(&q->filter_plan, q->output_len, SRSLTE_DFT_FORWARD, SRSLTE_DFT_COMPLEX)) { + if (srsran_dft_plan(&q->filter_plan, q->output_len, SRSRAN_DFT_FORWARD, SRSRAN_DFT_COMPLEX)) { ERROR("Error initiating filter plan"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_dft_plan(&q->output_plan, q->output_len, SRSLTE_DFT_BACKWARD, SRSLTE_DFT_COMPLEX)) { + if (srsran_dft_plan(&q->output_plan, q->output_len, SRSRAN_DFT_BACKWARD, SRSRAN_DFT_COMPLEX)) { ERROR("Error initiating output plan"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - srslte_dft_plan_set_norm(&q->input_plan, true); - srslte_dft_plan_set_norm(&q->filter_plan, true); - srslte_dft_plan_set_norm(&q->output_plan, false); + srsran_dft_plan_set_norm(&q->input_plan, true); + srsran_dft_plan_set_norm(&q->filter_plan, true); + srsran_dft_plan_set_norm(&q->output_plan, false); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_conv_fft_cc_replan(srslte_conv_fft_cc_t* q, uint32_t input_len, uint32_t filter_len) +int srsran_conv_fft_cc_replan(srsran_conv_fft_cc_t* q, uint32_t input_len, uint32_t filter_len) { if (input_len > q->max_input_len || filter_len > q->max_filter_len) { ERROR("Error in conv_fft_cc_replan(): input_len and filter_len must be lower than initialized"); @@ -65,24 +65,24 @@ int srslte_conv_fft_cc_replan(srslte_conv_fft_cc_t* q, uint32_t input_len, uint3 q->output_len = input_len + filter_len; if (!q->input_fft || !q->filter_fft || !q->output_fft) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_dft_replan(&q->input_plan, q->output_len)) { + if (srsran_dft_replan(&q->input_plan, q->output_len)) { ERROR("Error initiating input plan"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_dft_replan(&q->filter_plan, q->output_len)) { + if (srsran_dft_replan(&q->filter_plan, q->output_len)) { ERROR("Error initiating filter plan"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_dft_replan(&q->output_plan, q->output_len)) { + if (srsran_dft_replan(&q->output_plan, q->output_len)) { ERROR("Error initiating output plan"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -void srslte_conv_fft_cc_free(srslte_conv_fft_cc_t* q) +void srsran_conv_fft_cc_free(srsran_conv_fft_cc_t* q) { if (q->input_fft) { free(q->input_fft); @@ -94,54 +94,54 @@ void srslte_conv_fft_cc_free(srslte_conv_fft_cc_t* q) free(q->output_fft); } - srslte_dft_plan_free(&q->input_plan); - srslte_dft_plan_free(&q->filter_plan); - srslte_dft_plan_free(&q->output_plan); + srsran_dft_plan_free(&q->input_plan); + srsran_dft_plan_free(&q->filter_plan); + srsran_dft_plan_free(&q->output_plan); - bzero(q, sizeof(srslte_conv_fft_cc_t)); + bzero(q, sizeof(srsran_conv_fft_cc_t)); } -uint32_t srslte_conv_fft_cc_run_opt(srslte_conv_fft_cc_t* q, const cf_t* input, const cf_t* filter_freq, cf_t* output) +uint32_t srsran_conv_fft_cc_run_opt(srsran_conv_fft_cc_t* q, const cf_t* input, const cf_t* filter_freq, cf_t* output) { - srslte_dft_run_c(&q->input_plan, input, q->input_fft); - srslte_vec_prod_ccc(q->input_fft, filter_freq, q->output_fft, q->output_len); - srslte_dft_run_c(&q->output_plan, q->output_fft, output); + srsran_dft_run_c(&q->input_plan, input, q->input_fft); + srsran_vec_prod_ccc(q->input_fft, filter_freq, q->output_fft, q->output_len); + srsran_dft_run_c(&q->output_plan, q->output_fft, output); return (q->output_len - 1); // divide output length by dec factor } -uint32_t srslte_conv_fft_cc_run(srslte_conv_fft_cc_t* q, const cf_t* input, const cf_t* filter, cf_t* output) +uint32_t srsran_conv_fft_cc_run(srsran_conv_fft_cc_t* q, const cf_t* input, const cf_t* filter, cf_t* output) { - srslte_dft_run_c(&q->filter_plan, filter, q->filter_fft); + srsran_dft_run_c(&q->filter_plan, filter, q->filter_fft); - return srslte_conv_fft_cc_run_opt(q, input, q->filter_fft, output); + return srsran_conv_fft_cc_run_opt(q, input, q->filter_fft, output); } -uint32_t srslte_corr_fft_cc_run_opt(srslte_conv_fft_cc_t* q, cf_t* input, cf_t* filter, cf_t* output) +uint32_t srsran_corr_fft_cc_run_opt(srsran_conv_fft_cc_t* q, cf_t* input, cf_t* filter, cf_t* output) { - srslte_dft_run_c(&q->input_plan, input, q->input_fft); - srslte_vec_prod_conj_ccc(q->input_fft, q->filter_fft, q->output_fft, q->output_len); - srslte_dft_run_c(&q->output_plan, q->output_fft, output); + srsran_dft_run_c(&q->input_plan, input, q->input_fft); + srsran_vec_prod_conj_ccc(q->input_fft, q->filter_fft, q->output_fft, q->output_len); + srsran_dft_run_c(&q->output_plan, q->output_fft, output); return (q->output_len - 1); } -uint32_t srslte_corr_fft_cc_run(srslte_conv_fft_cc_t* q, cf_t* input, cf_t* filter, cf_t* output) +uint32_t srsran_corr_fft_cc_run(srsran_conv_fft_cc_t* q, cf_t* input, cf_t* filter, cf_t* output) { - srslte_dft_run_c(&q->filter_plan, filter, q->filter_fft); - return srslte_corr_fft_cc_run_opt(q, input, q->filter_fft, output); + srsran_dft_run_c(&q->filter_plan, filter, q->filter_fft); + return srsran_corr_fft_cc_run_opt(q, input, q->filter_fft, output); } -uint32_t srslte_conv_cc(const cf_t* input, const cf_t* filter, cf_t* output, uint32_t input_len, uint32_t filter_len) +uint32_t srsran_conv_cc(const cf_t* input, const cf_t* filter, cf_t* output, uint32_t input_len, uint32_t filter_len) { uint32_t i; uint32_t M = filter_len; uint32_t N = input_len; for (i = 0; i < M; i++) { - output[i] = srslte_vec_dot_prod_ccc(&input[i], &filter[i], i); + output[i] = srsran_vec_dot_prod_ccc(&input[i], &filter[i], i); } for (; i < M + N - 1; i++) { - output[i] = srslte_vec_dot_prod_ccc(&input[i - M], filter, M); + output[i] = srsran_vec_dot_prod_ccc(&input[i - M], filter, M); } return M + N - 1; } @@ -149,20 +149,20 @@ uint32_t srslte_conv_cc(const cf_t* input, const cf_t* filter, cf_t* output, uin /* Centered convolution. Returns the same number of input elements. Equivalent to conv(x,h,'same') in matlab. * y(n)=sum_i x(n+i-M/2)*h(i) for n=1..N with N input samples and M filter len */ -uint32_t srslte_conv_same_cc(cf_t* input, cf_t* filter, cf_t* output, uint32_t input_len, uint32_t filter_len) +uint32_t srsran_conv_same_cc(cf_t* input, cf_t* filter, cf_t* output, uint32_t input_len, uint32_t filter_len) { uint32_t i; uint32_t M = filter_len; uint32_t N = input_len; for (i = 0; i < M / 2; i++) { - output[i] = srslte_vec_dot_prod_ccc(&input[i], &filter[M / 2 - i], M - M / 2 + i); + output[i] = srsran_vec_dot_prod_ccc(&input[i], &filter[M / 2 - i], M - M / 2 + i); } for (; i < N - M / 2; i++) { - output[i] = srslte_vec_dot_prod_ccc(&input[i - M / 2], filter, M); + output[i] = srsran_vec_dot_prod_ccc(&input[i - M / 2], filter, M); } for (; i < N; i++) { - output[i] = srslte_vec_dot_prod_ccc(&input[i - M / 2], filter, N - i + M / 2); + output[i] = srsran_vec_dot_prod_ccc(&input[i - M / 2], filter, N - i + M / 2); } return N; } @@ -170,7 +170,7 @@ uint32_t srslte_conv_same_cc(cf_t* input, cf_t* filter, cf_t* output, uint32_t i #define conv_same_extrapolates_extremes #ifdef conv_same_extrapolates_extremes -uint32_t srslte_conv_same_cf(cf_t* input, float* filter, cf_t* output, uint32_t input_len, uint32_t filter_len) +uint32_t srsran_conv_same_cf(cf_t* input, float* filter, cf_t* output, uint32_t input_len, uint32_t filter_len) { uint32_t i; uint32_t M = filter_len; @@ -195,34 +195,34 @@ uint32_t srslte_conv_same_cf(cf_t* input, float* filter, cf_t* output, uint32_t } for (i = 0; i < M / 2; i++) { - output[i] = srslte_vec_dot_prod_cfc(&first[i], filter, M); + output[i] = srsran_vec_dot_prod_cfc(&first[i], filter, M); } for (; i < N - M / 2; i++) { - output[i] = srslte_vec_dot_prod_cfc(&input[i - M / 2], filter, M); + output[i] = srsran_vec_dot_prod_cfc(&input[i - M / 2], filter, M); } int j = 0; for (; i < N; i++) { - output[i] = srslte_vec_dot_prod_cfc(&last[j++], filter, M); + output[i] = srsran_vec_dot_prod_cfc(&last[j++], filter, M); } return N; } #else -uint32_t srslte_conv_same_cf(cf_t* input, float* filter, cf_t* output, uint32_t input_len, uint32_t filter_len) +uint32_t srsran_conv_same_cf(cf_t* input, float* filter, cf_t* output, uint32_t input_len, uint32_t filter_len) { uint32_t i; uint32_t M = filter_len; uint32_t N = input_len; for (i = 0; i < M / 2; i++) { - output[i] = srslte_vec_dot_prod_cfc(&input[i], &filter[M / 2 - i], M - M / 2 + i); + output[i] = srsran_vec_dot_prod_cfc(&input[i], &filter[M / 2 - i], M - M / 2 + i); } for (; i < N - M / 2; i++) { - output[i] = srslte_vec_dot_prod_cfc(&input[i - M / 2], filter, M); + output[i] = srsran_vec_dot_prod_cfc(&input[i - M / 2], filter, M); } for (; i < N; i++) { - output[i] = srslte_vec_dot_prod_cfc(&input[i - M / 2], filter, N - i + M / 2); + output[i] = srsran_vec_dot_prod_cfc(&input[i - M / 2], filter, N - i + M / 2); } return N; } diff --git a/lib/src/phy/utils/debug.c b/lib/src/phy/utils/debug.c index 45f140e0b..671c9eecd 100644 --- a/lib/src/phy/utils/debug.c +++ b/lib/src/phy/utils/debug.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,10 +10,10 @@ * */ -#include "srslte/phy/utils/debug.h" +#include "srsran/phy/utils/debug.h" #include -int srslte_verbose = 0; +int srsran_verbose = 0; int handler_registered = 0; void get_time_interval(struct timeval* tdata) diff --git a/lib/src/phy/utils/filter.c b/lib/src/phy/utils/filter.c index c627c39bb..21f6dc7f5 100644 --- a/lib/src/phy/utils/filter.c +++ b/lib/src/phy/utils/filter.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,12 +10,12 @@ * */ -#include "srslte/phy/utils/filter.h" -#define SRSLTE_NUM_FILTERS 8 -#define SRSLTE_MAX_FILTER_SIZE 11 +#include "srsran/phy/utils/filter.h" +#define SRSRAN_NUM_FILTERS 8 +#define SRSRAN_MAX_FILTER_SIZE 11 // clang-format off -float srslte_filt_decim2[SRSLTE_NUM_FILTERS][SRSLTE_MAX_FILTER_SIZE] = +float srsran_filt_decim2[SRSRAN_NUM_FILTERS][SRSRAN_MAX_FILTER_SIZE] = { {0.0167364016736, 0.48326359832636, 0.48326359832636, 0.01673640167364,0,0,0,0,0,0,0}, {0.000000000000000, 0.203712369200737, 0.592575261598526, 0.203712369200737, 0.000000000000000,0,0,0,0,0,0}, @@ -27,7 +27,7 @@ float srslte_filt_decim2[SRSLTE_NUM_FILTERS][SRSLTE_MAX_FILTER_SIZE] = {0.005060317124845, -0.000000000000000, -0.041942879431345, 0.000000000000000, 0.288484826302638, 0.496795472007725, 0.288484826302638, 0.000000000000000, -0.041942879431345, -0.000000000000000, 0.005060317124845} }; -float srslte_filt_decim3[SRSLTE_NUM_FILTERS][SRSLTE_MAX_FILTER_SIZE] = +float srsran_filt_decim3[SRSRAN_NUM_FILTERS][SRSRAN_MAX_FILTER_SIZE] = { {0.032388663967611, 0.467611336032389, 0.467611336032389, 0.032388663967611,0,0,0,0,0,0,0}, {0.016883339167609, 0.227925078762723, 0.510383164139335, 0.227925078762723, 0.016883339167609,0,0,0,0,0,0}, @@ -40,7 +40,7 @@ float srslte_filt_decim3[SRSLTE_NUM_FILTERS][SRSLTE_MAX_FILTER_SIZE] = }; -float srslte_filt_decim4[SRSLTE_NUM_FILTERS][SRSLTE_MAX_FILTER_SIZE] = +float srsran_filt_decim4[SRSRAN_NUM_FILTERS][SRSRAN_MAX_FILTER_SIZE] = { { 0.038579006748772, 0.461420993251228, 0.461420993251228, 0.038579006748772,0,0,0,0,0,0,0}, {0.024553834015017, 0.234389464237986, 0.482113403493995, 0.234389464237986, 0.024553834015017,0,0,0,0,0,0}, @@ -53,25 +53,25 @@ float srslte_filt_decim4[SRSLTE_NUM_FILTERS][SRSLTE_MAX_FILTER_SIZE] = }; // clang-format on -void srslte_filt_decim_cc_init(srslte_filt_cc_t* q, int factor, int order) +void srsran_filt_decim_cc_init(srsran_filt_cc_t* q, int factor, int order) { q->factor = factor; q->num_taps = order + 1; q->is_decimator = true; - q->taps = srslte_vec_f_malloc(q->num_taps); + q->taps = srsran_vec_f_malloc(q->num_taps); switch (q->factor) { case 2: for (int i = 0; i < (q->num_taps); i++) - q->taps[i] = srslte_filt_decim2[(q->num_taps) - 4][i]; + q->taps[i] = srsran_filt_decim2[(q->num_taps) - 4][i]; break; case 3: for (int i = 0; i < (q->num_taps); i++) - q->taps[i] = srslte_filt_decim3[(q->num_taps) - 4][i]; + q->taps[i] = srsran_filt_decim3[(q->num_taps) - 4][i]; break; case 4: for (int i = 0; i < (q->num_taps); i++) - q->taps[i] = srslte_filt_decim4[(q->num_taps) - 4][i]; + q->taps[i] = srsran_filt_decim4[(q->num_taps) - 4][i]; break; default: @@ -83,23 +83,23 @@ void srslte_filt_decim_cc_init(srslte_filt_cc_t* q, int factor, int order) } } -void srslte_filt_decim_cc_free(srslte_filt_cc_t* q) +void srsran_filt_decim_cc_free(srsran_filt_cc_t* q) { free(q->taps); } -void srslte_filt_decim_cc_execute(srslte_filt_cc_t* q, cf_t* input, cf_t* downsampled_input, cf_t* output, int size) +void srsran_filt_decim_cc_execute(srsran_filt_cc_t* q, cf_t* input, cf_t* downsampled_input, cf_t* output, int size) { // we assume that "downsampled_input" made size (input/2 + order) so as to have prepended zeros // - srslte_downsample_cc(input, downsampled_input + (q->num_taps - 1), q->factor, size); + srsran_downsample_cc(input, downsampled_input + (q->num_taps - 1), q->factor, size); for (int i = 0; i < size / q->factor; i++) { - output[i] = srslte_vec_dot_prod_cfc(&(downsampled_input[i]), q->taps, q->num_taps); + output[i] = srsran_vec_dot_prod_cfc(&(downsampled_input[i]), q->taps, q->num_taps); } } /* Performs integer linear downsamling by a factor of M */ -void srslte_downsample_cc(cf_t* input, cf_t* output, int M, int size) +void srsran_downsample_cc(cf_t* input, cf_t* output, int M, int size) { int i; for (i = 0; i < size / M; i++) { diff --git a/lib/src/phy/utils/mat.c b/lib/src/phy/utils/mat.c index 97085f606..660523063 100644 --- a/lib/src/phy/utils/mat.c +++ b/lib/src/phy/utils/mat.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,28 +13,28 @@ #include #include #include -#include -#include +#include +#include #include -#include "srslte/phy/utils/mat.h" +#include "srsran/phy/utils/mat.h" /* Generic implementation for complex reciprocal */ -inline cf_t srslte_mat_cf_recip_gen(cf_t a) +inline cf_t srsran_mat_cf_recip_gen(cf_t a) { return conjf(a) / (crealf(a) * crealf(a) + cimagf(a) * cimagf(a)); } /* Generic implementation for 2x2 determinant */ -inline cf_t srslte_mat_2x2_det_gen(cf_t a00, cf_t a01, cf_t a10, cf_t a11) +inline cf_t srsran_mat_2x2_det_gen(cf_t a00, cf_t a01, cf_t a10, cf_t a11) { return a00 * a11 - a01 * a10; } /* 2x2 Matrix inversion, generic implementation */ -inline void srslte_mat_2x2_inv_gen(cf_t a00, cf_t a01, cf_t a10, cf_t a11, cf_t* r00, cf_t* r01, cf_t* r10, cf_t* r11) +inline void srsran_mat_2x2_inv_gen(cf_t a00, cf_t a01, cf_t a10, cf_t a11, cf_t* r00, cf_t* r01, cf_t* r10, cf_t* r11) { - cf_t div = srslte_mat_cf_recip_gen(srslte_mat_2x2_det_gen(a00, a01, a10, a11)); + cf_t div = srsran_mat_cf_recip_gen(srsran_mat_2x2_det_gen(a00, a01, a10, a11)); *r00 = a11 * div; *r01 = -a01 * div; *r10 = -a10 * div; @@ -43,15 +43,15 @@ inline void srslte_mat_2x2_inv_gen(cf_t a00, cf_t a01, cf_t a10, cf_t a11, cf_t* /* Generic implementation for Zero Forcing (ZF) solver */ inline void -srslte_mat_2x2_zf_gen(cf_t y0, cf_t y1, cf_t h00, cf_t h01, cf_t h10, cf_t h11, cf_t* x0, cf_t* x1, float norm) +srsran_mat_2x2_zf_gen(cf_t y0, cf_t y1, cf_t h00, cf_t h01, cf_t h10, cf_t h11, cf_t* x0, cf_t* x1, float norm) { - cf_t _norm = srslte_mat_cf_recip_gen(srslte_mat_2x2_det_gen(h00, h01, h10, h11)) * norm; + cf_t _norm = srsran_mat_cf_recip_gen(srsran_mat_2x2_det_gen(h00, h01, h10, h11)) * norm; *x0 = (y0 * h11 - h01 * y1) * _norm; *x1 = (y1 * h00 - h10 * y0) * _norm; } /* Generic implementation for Minimum Mean Squared Error (MMSE) solver */ -inline void srslte_mat_2x2_mmse_csi_gen(cf_t y0, +inline void srsran_mat_2x2_mmse_csi_gen(cf_t y0, cf_t y1, cf_t h00, cf_t h01, @@ -75,7 +75,7 @@ inline void srslte_mat_2x2_mmse_csi_gen(cf_t y0, cf_t a01 = _h00 * h01 + _h10 * h11; cf_t a10 = _h01 * h00 + _h11 * h10; cf_t a11 = _h01 * h01 + _h11 * h11 + noise_estimate; - cf_t a_det_rcp = srslte_mat_cf_recip_gen(srslte_mat_2x2_det_gen(a00, a01, a10, a11)); + cf_t a_det_rcp = srsran_mat_cf_recip_gen(srsran_mat_2x2_det_gen(a00, a01, a10, a11)); /* 2. B = inv(H' x H + No) = inv(A) */ cf_t _norm = norm * a_det_rcp; @@ -100,7 +100,7 @@ inline void srslte_mat_2x2_mmse_csi_gen(cf_t y0, } /* Generic implementation for Minimum Mean Squared Error (MMSE) solver */ -void srslte_mat_2x2_mmse_gen(cf_t y0, +void srsran_mat_2x2_mmse_gen(cf_t y0, cf_t y1, cf_t h00, cf_t h01, @@ -112,10 +112,10 @@ void srslte_mat_2x2_mmse_gen(cf_t y0, float norm) { float csi0, csi1; - srslte_mat_2x2_mmse_csi_gen(y0, y1, h00, h01, h10, h11, x0, x1, &csi0, &csi1, noise_estimate, norm); + srsran_mat_2x2_mmse_csi_gen(y0, y1, h00, h01, h10, h11, x0, x1, &csi0, &csi1, noise_estimate, norm); } -int srslte_mat_2x2_cn(cf_t h00, cf_t h01, cf_t h10, cf_t h11, float* cn) +int srsran_mat_2x2_cn(cf_t h00, cf_t h01, cf_t h10, cf_t h11, float* cn) { // 1. A = H * H' (A = A') float a00 = @@ -135,25 +135,25 @@ int srslte_mat_2x2_cn(cf_t h00, cf_t h01, cf_t h10, cf_t h11, float* cn) // 4. Make sure NAN or INF are not propagated if (isnan(xmin) || isinf(xmin) || isnan(xmax) || isinf(xmax)) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // 5. Bound xmin and xmax - xmin = SRSLTE_MAX(xmin, 1e-9f); - xmax = SRSLTE_MIN(xmax, 1e+9f); + xmin = SRSRAN_MAX(xmin, 1e-9f); + xmax = SRSRAN_MIN(xmax, 1e+9f); // 6. κ = sqrt(λ_max / λ_min) if (cn != NULL) { *cn = 10.0f * log10f(xmax / xmin); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } #ifdef LV_HAVE_SSE #include /* SSE implementation for complex reciprocal */ -inline __m128 srslte_mat_cf_recip_sse(__m128 a) +inline __m128 srsran_mat_cf_recip_sse(__m128 a) { __m128 conj = _MM_CONJ_PS(a); __m128 sqabs = _mm_mul_ps(a, a); @@ -165,13 +165,13 @@ inline __m128 srslte_mat_cf_recip_sse(__m128 a) } /* SSE implementation for 2x2 determinant */ -inline __m128 srslte_mat_2x2_det_sse(__m128 a00, __m128 a01, __m128 a10, __m128 a11) +inline __m128 srsran_mat_2x2_det_sse(__m128 a00, __m128 a01, __m128 a10, __m128 a11) { return _mm_sub_ps(_MM_PROD_PS(a00, a11), _MM_PROD_PS(a01, a10)); } /* SSE implementation for Zero Forcing (ZF) solver */ -inline void srslte_mat_2x2_zf_sse(__m128 y0, +inline void srsran_mat_2x2_zf_sse(__m128 y0, __m128 y1, __m128 h00, __m128 h01, @@ -185,14 +185,14 @@ inline void srslte_mat_2x2_zf_sse(__m128 y0, __m128 detmult2 = _MM_PROD_PS(h01, h10); __m128 det = _mm_sub_ps(detmult1, detmult2); - __m128 detrec = _mm_mul_ps(srslte_mat_cf_recip_sse(det), _mm_set1_ps(norm)); + __m128 detrec = _mm_mul_ps(srsran_mat_cf_recip_sse(det), _mm_set1_ps(norm)); *x0 = _MM_PROD_PS(_mm_sub_ps(_MM_PROD_PS(h11, y0), _MM_PROD_PS(h01, y1)), detrec); *x1 = _MM_PROD_PS(_mm_sub_ps(_MM_PROD_PS(h00, y1), _MM_PROD_PS(h10, y0)), detrec); } /* SSE implementation for Minimum Mean Squared Error (MMSE) solver */ -inline void srslte_mat_2x2_mmse_sse(__m128 y0, +inline void srsran_mat_2x2_mmse_sse(__m128 y0, __m128 y1, __m128 h00, __m128 h01, @@ -223,7 +223,7 @@ inline void srslte_mat_2x2_mmse_sse(__m128 y0, __m128 b01 = _mm_xor_ps(a01, _mm_set1_ps(-0.0f)); __m128 b10 = _mm_xor_ps(a10, _mm_set1_ps(-0.0f)); __m128 b11 = a00; - _norm = _mm_mul_ps(_norm, srslte_mat_cf_recip_sse(srslte_mat_2x2_det_sse(a00, a01, a10, a11))); + _norm = _mm_mul_ps(_norm, srsran_mat_cf_recip_sse(srsran_mat_2x2_det_sse(a00, a01, a10, a11))); /* 3. W = inv(H' x H + No) x H' = B x H' */ __m128 w00 = _mm_add_ps(_MM_PROD_PS(b00, _h00), _MM_PROD_PS(b01, _h01)); @@ -240,10 +240,10 @@ inline void srslte_mat_2x2_mmse_sse(__m128 y0, #ifdef LV_HAVE_AVX #include -#include +#include /* AVX implementation for complex reciprocal */ -inline __m256 srslte_mat_cf_recip_avx(__m256 a) +inline __m256 srsran_mat_cf_recip_avx(__m256 a) { __m256 conj = _MM256_CONJ_PS(a); __m256 sqabs = _mm256_mul_ps(a, a); @@ -255,7 +255,7 @@ inline __m256 srslte_mat_cf_recip_avx(__m256 a) } /* AVX implementation for 2x2 determinant */ -inline __m256 srslte_mat_2x2_det_avx(__m256 a00, __m256 a01, __m256 a10, __m256 a11) +inline __m256 srsran_mat_2x2_det_avx(__m256 a00, __m256 a01, __m256 a10, __m256 a11) { #ifdef LV_HAVE_FMA return _MM256_PROD_SUB_PS(a00, a11, _MM256_PROD_PS(a01, a10)); @@ -265,7 +265,7 @@ inline __m256 srslte_mat_2x2_det_avx(__m256 a00, __m256 a01, __m256 a10, __m256 } /* AVX implementation for Zero Forcing (ZF) solver */ -inline void srslte_mat_2x2_zf_avx(__m256 y0, +inline void srsran_mat_2x2_zf_avx(__m256 y0, __m256 y1, __m256 h00, __m256 h01, @@ -275,9 +275,8 @@ inline void srslte_mat_2x2_zf_avx(__m256 y0, __m256* x1, float norm) { - - __m256 det = srslte_mat_2x2_det_avx(h00, h01, h10, h11); - __m256 detrec = _mm256_mul_ps(srslte_mat_cf_recip_avx(det), _mm256_set1_ps(norm)); + __m256 det = srsran_mat_2x2_det_avx(h00, h01, h10, h11); + __m256 detrec = _mm256_mul_ps(srsran_mat_cf_recip_avx(det), _mm256_set1_ps(norm)); #ifdef LV_HAVE_FMA *x0 = _MM256_PROD_PS(_MM256_PROD_SUB_PS(h11, y0, _MM256_PROD_PS(h01, y1)), detrec); @@ -289,7 +288,7 @@ inline void srslte_mat_2x2_zf_avx(__m256 y0, } /* AVX implementation for Minimum Mean Squared Error (MMSE) solver */ -inline void srslte_mat_2x2_mmse_avx(__m256 y0, +inline void srsran_mat_2x2_mmse_avx(__m256 y0, __m256 y1, __m256 h00, __m256 h01, @@ -328,7 +327,7 @@ inline void srslte_mat_2x2_mmse_avx(__m256 y0, __m256 b01 = _mm256_xor_ps(a01, _mm256_set1_ps(-0.0f)); __m256 b10 = _mm256_xor_ps(a10, _mm256_set1_ps(-0.0f)); __m256 b11 = a00; - _norm = _mm256_mul_ps(_norm, srslte_mat_cf_recip_avx(srslte_mat_2x2_det_avx(a00, a01, a10, a11))); + _norm = _mm256_mul_ps(_norm, srsran_mat_cf_recip_avx(srsran_mat_2x2_det_avx(a00, a01, a10, a11))); /* 3. W = inv(H' x H + No) x H' = B x H' */ #ifdef LV_HAVE_FMA @@ -355,27 +354,27 @@ inline void srslte_mat_2x2_mmse_avx(__m256 y0, #endif /* LV_HAVE_AVX */ -int srslte_matrix_NxN_inv_init(srslte_matrix_NxN_inv_t* q, uint32_t N) +int srsran_matrix_NxN_inv_init(srsran_matrix_NxN_inv_t* q, uint32_t N) { - int ret = SRSLTE_SUCCESS; + int ret = SRSRAN_SUCCESS; if (q && N) { // Set all to zero - bzero(q, sizeof(srslte_matrix_NxN_inv_t)); + bzero(q, sizeof(srsran_matrix_NxN_inv_t)); q->N = N; - q->row_buffer = srslte_vec_cf_malloc(N * 2); + q->row_buffer = srsran_vec_cf_malloc(N * 2); if (!q->row_buffer) { perror("malloc"); - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } if (!ret) { - q->matrix = srslte_vec_cf_malloc(N * N * 2); + q->matrix = srsran_vec_cf_malloc(N * N * 2); if (!q->matrix) { perror("malloc"); - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } } } @@ -383,26 +382,26 @@ int srslte_matrix_NxN_inv_init(srslte_matrix_NxN_inv_t* q, uint32_t N) return ret; } -static inline void srslte_vec_sc_prod_ccc_simd_inline(const cf_t* x, const cf_t h, cf_t* z, const int len) +static inline void srsran_vec_sc_prod_ccc_simd_inline(const cf_t* x, const cf_t h, cf_t* z, const int len) { int i = 0; -#if SRSLTE_SIMD_F_SIZE +#if SRSRAN_SIMD_F_SIZE #ifdef HAVE_NEON - i = srslte_vec_sc_prod_ccc_simd2(x, h, z, len); + i = srsran_vec_sc_prod_ccc_simd2(x, h, z, len); #else - const simd_f_t hre = srslte_simd_f_set1(__real__ h); - const simd_f_t him = srslte_simd_f_set1(__imag__ h); + const simd_f_t hre = srsran_simd_f_set1(__real__ h); + const simd_f_t him = srsran_simd_f_set1(__imag__ h); - for (; i < len - SRSLTE_SIMD_F_SIZE / 2 + 1; i += SRSLTE_SIMD_F_SIZE / 2) { - simd_f_t temp = srslte_simd_f_load((float*)&x[i]); + for (; i < len - SRSRAN_SIMD_F_SIZE / 2 + 1; i += SRSRAN_SIMD_F_SIZE / 2) { + simd_f_t temp = srsran_simd_f_load((float*)&x[i]); - simd_f_t m1 = srslte_simd_f_mul(hre, temp); - simd_f_t sw = srslte_simd_f_swap(temp); - simd_f_t m2 = srslte_simd_f_mul(him, sw); - simd_f_t r = srslte_simd_f_addsub(m1, m2); - srslte_simd_f_store((float*)&z[i], r); + simd_f_t m1 = srsran_simd_f_mul(hre, temp); + simd_f_t sw = srsran_simd_f_swap(temp); + simd_f_t m2 = srsran_simd_f_mul(him, sw); + simd_f_t r = srsran_simd_f_addsub(m1, m2); + srsran_simd_f_store((float*)&z[i], r); } #endif @@ -413,19 +412,19 @@ static inline void srslte_vec_sc_prod_ccc_simd_inline(const cf_t* x, const cf_t } } -static inline void srslte_vec_sub_fff_simd_inline(const float* x, const float* y, float* z, const int len) +static inline void srsran_vec_sub_fff_simd_inline(const float* x, const float* y, float* z, const int len) { int i = 0; -#if SRSLTE_SIMD_F_SIZE +#if SRSRAN_SIMD_F_SIZE - for (; i < len - SRSLTE_SIMD_F_SIZE + 1; i += SRSLTE_SIMD_F_SIZE) { - simd_f_t a = srslte_simd_f_loadu(&x[i]); - simd_f_t b = srslte_simd_f_loadu(&y[i]); + for (; i < len - SRSRAN_SIMD_F_SIZE + 1; i += SRSRAN_SIMD_F_SIZE) { + simd_f_t a = srsran_simd_f_loadu(&x[i]); + simd_f_t b = srsran_simd_f_loadu(&y[i]); - simd_f_t r = srslte_simd_f_sub(a, b); + simd_f_t r = srsran_simd_f_sub(a, b); - srslte_simd_f_storeu(&z[i], r); + srsran_simd_f_storeu(&z[i], r); } #endif @@ -434,9 +433,9 @@ static inline void srslte_vec_sub_fff_simd_inline(const float* x, const float* y } } -static inline void srslte_vec_sub_ccc_simd_inline(const cf_t* x, const cf_t* y, cf_t* z, const int len) +static inline void srsran_vec_sub_ccc_simd_inline(const cf_t* x, const cf_t* y, cf_t* z, const int len) { - srslte_vec_sub_fff_simd_inline((float*)x, (float*)y, (float*)z, 2 * len); + srsran_vec_sub_fff_simd_inline((float*)x, (float*)y, (float*)z, 2 * len); } static inline cf_t reciprocal(cf_t x) @@ -457,7 +456,7 @@ static inline float _cabs2(cf_t x) return __real__ x * __real__ x + __imag__ x * __imag__ x; } -void srslte_matrix_NxN_inv_run(srslte_matrix_NxN_inv_t* q, cf_t* in, cf_t* out) +void srsran_matrix_NxN_inv_run(srsran_matrix_NxN_inv_t* q, cf_t* in, cf_t* out) { if (q && in && out) { int N = q->N; @@ -504,35 +503,35 @@ void srslte_matrix_NxN_inv_run(srslte_matrix_NxN_inv_t* q, cf_t* in, cf_t* out) tmp_src_ptr = &q->matrix[N * 2 * row_i]; // Select row cf_t b = tmp_src_ptr[col_i]; - srslte_vec_sc_prod_ccc_simd_inline(tmp_src_ptr, reciprocal(b), tmp_src_ptr, 2 * N); + srsran_vec_sc_prod_ccc_simd_inline(tmp_src_ptr, reciprocal(b), tmp_src_ptr, 2 * N); for (int j = 0; j < N - i - 1; j++) { cf_t a = q->matrix[N * (2 * j + 1) - 1 - i]; if (a != 0.0f && b != 0.0f) { tmp_dst_ptr = &q->matrix[N * 2 * j]; - srslte_vec_sc_prod_ccc_simd_inline(tmp_dst_ptr, reciprocal(a), tmp_dst_ptr, 2 * N); - srslte_vec_sub_ccc_simd_inline(tmp_dst_ptr, tmp_src_ptr, tmp_dst_ptr, 2 * N); + srsran_vec_sc_prod_ccc_simd_inline(tmp_dst_ptr, reciprocal(a), tmp_dst_ptr, 2 * N); + srsran_vec_sub_ccc_simd_inline(tmp_dst_ptr, tmp_src_ptr, tmp_dst_ptr, 2 * N); } } } - srslte_vec_sc_prod_ccc_simd_inline(q->matrix, reciprocal(q->matrix[0]), q->matrix, 2 * N); + srsran_vec_sc_prod_ccc_simd_inline(q->matrix, reciprocal(q->matrix[0]), q->matrix, 2 * N); // 2) Backward elimination for (int i = 0; i < N - 1; i++) { tmp_src_ptr = &q->matrix[N * 2 * i]; cf_t b = tmp_src_ptr[i]; - srslte_vec_sc_prod_ccc_simd_inline(tmp_src_ptr, reciprocal(b), tmp_src_ptr, 2 * N); + srsran_vec_sc_prod_ccc_simd_inline(tmp_src_ptr, reciprocal(b), tmp_src_ptr, 2 * N); for (int j = N - 1; j > i; j--) { cf_t a = q->matrix[N * 2 * j + i]; tmp_dst_ptr = &q->matrix[N * 2 * j]; - srslte_vec_sc_prod_ccc_simd_inline(tmp_dst_ptr, reciprocal(a), tmp_dst_ptr, 2 * N); - srslte_vec_sub_ccc_simd_inline(tmp_dst_ptr, tmp_src_ptr, tmp_dst_ptr, 2 * N); + srsran_vec_sc_prod_ccc_simd_inline(tmp_dst_ptr, reciprocal(a), tmp_dst_ptr, 2 * N); + srsran_vec_sub_ccc_simd_inline(tmp_dst_ptr, tmp_src_ptr, tmp_dst_ptr, 2 * N); } } - srslte_vec_sc_prod_ccc_simd_inline(&q->matrix[2 * N * (N - 1)], + srsran_vec_sc_prod_ccc_simd_inline(&q->matrix[2 * N * (N - 1)], reciprocal(q->matrix[2 * N * (N - 1) + N - 1]), &q->matrix[2 * N * (N - 1)], 2 * N); @@ -580,7 +579,7 @@ void srslte_matrix_NxN_inv_run(srslte_matrix_NxN_inv_t* q, cf_t* in, cf_t* out) } } -void srslte_matrix_NxN_inv_free(srslte_matrix_NxN_inv_t* q) +void srsran_matrix_NxN_inv_free(srsran_matrix_NxN_inv_t* q) { if (q) { @@ -593,6 +592,6 @@ void srslte_matrix_NxN_inv_free(srslte_matrix_NxN_inv_t* q) } // Default all to zero - bzero(q, sizeof(srslte_matrix_NxN_inv_t)); + bzero(q, sizeof(srsran_matrix_NxN_inv_t)); } } diff --git a/lib/src/phy/utils/phy_logger.c b/lib/src/phy/utils/phy_logger.c index 6738d4efd..49c668887 100644 --- a/lib/src/phy/utils/phy_logger.c +++ b/lib/src/phy/utils/phy_logger.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,8 +10,8 @@ * */ -#include "srslte/phy/utils/phy_logger.h" -#include "srslte/srslte.h" +#include "srsran/phy/utils/phy_logger.h" +#include "srsran/srsran.h" #include #include #include @@ -25,14 +25,14 @@ static phy_log_handler_t phy_log_handler; static void* callback_ctx = NULL; -void srslte_phy_log_register_handler(void* ctx, phy_log_handler_t handler) +void srsran_phy_log_register_handler(void* ctx, phy_log_handler_t handler) { phy_log_handler = handler; callback_ctx = ctx; handler_registered++; } -void srslte_phy_log_print(phy_logger_level_t log_level, const char* format, ...) +void srsran_phy_log_print(phy_logger_level_t log_level, const char* format, ...) { char tmp[256]; va_list args; diff --git a/lib/src/phy/utils/primes.c b/lib/src/phy/utils/primes.c index c5a84c223..6be0ed4ff 100644 --- a/lib/src/phy/utils/primes.c +++ b/lib/src/phy/utils/primes.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,7 +10,7 @@ * */ -#include "srslte/phy/utils/primes.h" +#include "srsran/phy/utils/primes.h" #define NOF_PRIME_NUMBERS 463 @@ -41,7 +41,7 @@ static const uint32_t prime_numbers[NOF_PRIME_NUMBERS] = { 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299}; -int srslte_prime_greater_than(uint32_t n) +int srsran_prime_greater_than(uint32_t n) { for (uint32_t i = 0; i < NOF_PRIME_NUMBERS; i++) { if (prime_numbers[i] > n) { @@ -49,14 +49,14 @@ int srslte_prime_greater_than(uint32_t n) } } - return SRSLTE_ERROR_OUT_OF_BOUNDS; + return SRSRAN_ERROR_OUT_OF_BOUNDS; } -int srslte_prime_lower_than(uint32_t n) +int srsran_prime_lower_than(uint32_t n) { if (n > prime_numbers[NOF_PRIME_NUMBERS - 1]) { - return SRSLTE_ERROR_OUT_OF_BOUNDS; + return SRSRAN_ERROR_OUT_OF_BOUNDS; } for (uint32_t i = NOF_PRIME_NUMBERS - 1; i > 0; i--) { diff --git a/lib/src/phy/utils/random.cpp b/lib/src/phy/utils/random.cpp index f84a63bb8..4b192bcf9 100644 --- a/lib/src/phy/utils/random.cpp +++ b/lib/src/phy/utils/random.cpp @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,7 +10,7 @@ * */ -#include "srslte/phy/utils/random.h" +#include "srsran/phy/utils/random.h" #include #include @@ -45,12 +45,12 @@ public: extern "C" { -srslte_random_t srslte_random_init(uint32_t seed) +srsran_random_t srsran_random_init(uint32_t seed) { - return (srslte_random_t)(new random_wrap(seed)); + return (srsran_random_t)(new random_wrap(seed)); } -int srslte_random_uniform_int_dist(srslte_random_t q, int min, int max) +int srsran_random_uniform_int_dist(srsran_random_t q, int min, int max) { int ret = 0; @@ -62,7 +62,7 @@ int srslte_random_uniform_int_dist(srslte_random_t q, int min, int max) return ret; } -float srslte_random_uniform_real_dist(srslte_random_t q, float min, float max) +float srsran_random_uniform_real_dist(srsran_random_t q, float min, float max) { float ret = NAN; @@ -76,7 +76,7 @@ float srslte_random_uniform_real_dist(srslte_random_t q, float min, float max) return ret; } -cf_t srslte_random_uniform_complex_dist(srslte_random_t q, float min, float max) +cf_t srsran_random_uniform_complex_dist(srsran_random_t q, float min, float max) { cf_t ret = NAN; @@ -89,14 +89,14 @@ cf_t srslte_random_uniform_complex_dist(srslte_random_t q, float min, float max) return ret; } -void srslte_random_uniform_complex_dist_vector(srslte_random_t q, cf_t* vector, uint32_t nsamples, float min, float max) +void srsran_random_uniform_complex_dist_vector(srsran_random_t q, cf_t* vector, uint32_t nsamples, float min, float max) { for (uint32_t i = 0; i < nsamples; i++) { - vector[i] = srslte_random_uniform_complex_dist(q, min, max); + vector[i] = srsran_random_uniform_complex_dist(q, min, max); } } -float srslte_random_gauss_dist(srslte_random_t q, float std_dev) +float srsran_random_gauss_dist(srsran_random_t q, float std_dev) { float ret = NAN; @@ -108,12 +108,12 @@ float srslte_random_gauss_dist(srslte_random_t q, float std_dev) return ret; } -bool srslte_random_bool(srslte_random_t q, float prob_true) +bool srsran_random_bool(srsran_random_t q, float prob_true) { - return srslte_random_uniform_real_dist(q, 0, 1) < prob_true; + return srsran_random_uniform_real_dist(q, 0, 1) < prob_true; } -void srslte_random_free(srslte_random_t q) +void srsran_random_free(srsran_random_t q) { if (q) { delete (random_wrap*)q; diff --git a/lib/src/phy/utils/ringbuffer.c b/lib/src/phy/utils/ringbuffer.c index 7519afe9c..53359c356 100644 --- a/lib/src/phy/utils/ringbuffer.c +++ b/lib/src/phy/utils/ringbuffer.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,30 +13,30 @@ #include #include -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/ringbuffer.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/ringbuffer.h" +#include "srsran/phy/utils/vector.h" -int srslte_ringbuffer_init(srslte_ringbuffer_t* q, int capacity) +int srsran_ringbuffer_init(srsran_ringbuffer_t* q, int capacity) { - q->buffer = srslte_vec_malloc(capacity); + q->buffer = srsran_vec_malloc(capacity); if (!q->buffer) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } q->active = true; q->capacity = capacity; pthread_mutex_init(&q->mutex, NULL); pthread_cond_init(&q->write_cvar, NULL); pthread_cond_init(&q->read_cvar, NULL); - srslte_ringbuffer_reset(q); + srsran_ringbuffer_reset(q); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -void srslte_ringbuffer_free(srslte_ringbuffer_t* q) +void srsran_ringbuffer_free(srsran_ringbuffer_t* q) { if (q) { - srslte_ringbuffer_stop(q); + srsran_ringbuffer_stop(q); if (q->buffer) { free(q->buffer); q->buffer = NULL; @@ -47,7 +47,7 @@ void srslte_ringbuffer_free(srslte_ringbuffer_t* q) } } -void srslte_ringbuffer_reset(srslte_ringbuffer_t* q) +void srsran_ringbuffer_reset(srsran_ringbuffer_t* q) { // Check first if it is initiated if (q->capacity != 0) { @@ -59,51 +59,51 @@ void srslte_ringbuffer_reset(srslte_ringbuffer_t* q) } } -int srslte_ringbuffer_resize(srslte_ringbuffer_t* q, int capacity) +int srsran_ringbuffer_resize(srsran_ringbuffer_t* q, int capacity) { if (q->buffer) { free(q->buffer); q->buffer = NULL; } - srslte_ringbuffer_reset(q); - q->buffer = srslte_vec_malloc(capacity); + srsran_ringbuffer_reset(q); + q->buffer = srsran_vec_malloc(capacity); if (!q->buffer) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } q->active = true; q->capacity = capacity; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int srslte_ringbuffer_status(srslte_ringbuffer_t* q) +int srsran_ringbuffer_status(srsran_ringbuffer_t* q) { return q->count; } -int srslte_ringbuffer_space(srslte_ringbuffer_t* q) +int srsran_ringbuffer_space(srsran_ringbuffer_t* q) { return q->capacity - q->count; } -int srslte_ringbuffer_write(srslte_ringbuffer_t* q, void* ptr, int nof_bytes) +int srsran_ringbuffer_write(srsran_ringbuffer_t* q, void* ptr, int nof_bytes) { - return srslte_ringbuffer_write_timed_block(q, ptr, nof_bytes, 0); + return srsran_ringbuffer_write_timed_block(q, ptr, nof_bytes, 0); } -int srslte_ringbuffer_write_timed(srslte_ringbuffer_t* q, void* ptr, int nof_bytes, int32_t timeout_ms) +int srsran_ringbuffer_write_timed(srsran_ringbuffer_t* q, void* ptr, int nof_bytes, int32_t timeout_ms) { - return srslte_ringbuffer_write_timed_block(q, ptr, nof_bytes, timeout_ms); + return srsran_ringbuffer_write_timed_block(q, ptr, nof_bytes, timeout_ms); } -int srslte_ringbuffer_write_block(srslte_ringbuffer_t* q, void* ptr, int nof_bytes) +int srsran_ringbuffer_write_block(srsran_ringbuffer_t* q, void* ptr, int nof_bytes) { - return srslte_ringbuffer_write_timed_block(q, ptr, nof_bytes, -1); + return srsran_ringbuffer_write_timed_block(q, ptr, nof_bytes, -1); } -int srslte_ringbuffer_write_timed_block(srslte_ringbuffer_t* q, void* p, int nof_bytes, int32_t timeout_ms) +int srsran_ringbuffer_write_timed_block(srsran_ringbuffer_t* q, void* p, int nof_bytes, int32_t timeout_ms) { - int ret = SRSLTE_SUCCESS; + int ret = SRSRAN_SUCCESS; uint8_t* ptr = (uint8_t*)p; int w_bytes = nof_bytes; struct timespec towait; @@ -111,7 +111,7 @@ int srslte_ringbuffer_write_timed_block(srslte_ringbuffer_t* q, void* p, int nof if (q == NULL || q->buffer == NULL) { ERROR("Invalid inputs"); - return SRSLTE_ERROR_INVALID_INPUTS; + return SRSRAN_ERROR_INVALID_INPUTS; } // Get current time and update timeout @@ -123,7 +123,7 @@ int srslte_ringbuffer_write_timed_block(srslte_ringbuffer_t* q, void* p, int nof pthread_mutex_lock(&q->mutex); // Wait to have enough space in the buffer - while (q->count + w_bytes > q->capacity && q->active && ret == SRSLTE_SUCCESS) { + while (q->count + w_bytes > q->capacity && q->active && ret == SRSRAN_SUCCESS) { if (timeout_ms > 0) { ret = pthread_cond_timedwait(&q->read_cvar, &q->mutex, &towait); } else if (timeout_ms < 0) { @@ -134,10 +134,10 @@ int srslte_ringbuffer_write_timed_block(srslte_ringbuffer_t* q, void* p, int nof } } if (ret == ETIMEDOUT) { - ret = SRSLTE_ERROR_TIMEOUT; + ret = SRSRAN_ERROR_TIMEOUT; } else if (!q->active) { - ret = SRSLTE_SUCCESS; - } else if (ret == SRSLTE_SUCCESS) { + ret = SRSRAN_SUCCESS; + } else if (ret == SRSRAN_SUCCESS) { if (ptr != NULL) { if (w_bytes > q->capacity - q->wpm) { int x = q->capacity - q->wpm; @@ -162,26 +162,26 @@ int srslte_ringbuffer_write_timed_block(srslte_ringbuffer_t* q, void* p, int nof q->count += w_bytes; ret = w_bytes; } else { - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } pthread_cond_broadcast(&q->write_cvar); pthread_mutex_unlock(&q->mutex); return ret; } -int srslte_ringbuffer_read(srslte_ringbuffer_t* q, void* p, int nof_bytes) +int srsran_ringbuffer_read(srsran_ringbuffer_t* q, void* p, int nof_bytes) { - return srslte_ringbuffer_read_timed_block(q, p, nof_bytes, -1); + return srsran_ringbuffer_read_timed_block(q, p, nof_bytes, -1); } -int srslte_ringbuffer_read_timed(srslte_ringbuffer_t* q, void* p, int nof_bytes, int32_t timeout_ms) +int srsran_ringbuffer_read_timed(srsran_ringbuffer_t* q, void* p, int nof_bytes, int32_t timeout_ms) { - return srslte_ringbuffer_read_timed_block(q, p, nof_bytes, timeout_ms); + return srsran_ringbuffer_read_timed_block(q, p, nof_bytes, timeout_ms); } -int srslte_ringbuffer_read_timed_block(srslte_ringbuffer_t* q, void* p, int nof_bytes, int32_t timeout_ms) +int srsran_ringbuffer_read_timed_block(srsran_ringbuffer_t* q, void* p, int nof_bytes, int32_t timeout_ms) { - int ret = SRSLTE_SUCCESS; + int ret = SRSRAN_SUCCESS; uint8_t* ptr = (uint8_t*)p; struct timespec towait = {}; @@ -201,7 +201,7 @@ int srslte_ringbuffer_read_timed_block(srslte_ringbuffer_t* q, void* p, int nof_ pthread_mutex_lock(&q->mutex); // Wait for having enough samples - while (q->count < nof_bytes && q->active && ret == SRSLTE_SUCCESS) { + while (q->count < nof_bytes && q->active && ret == SRSRAN_SUCCESS) { if (timeout_ms > 0) { ret = pthread_cond_timedwait(&q->write_cvar, &q->mutex, &towait); } else { @@ -210,10 +210,10 @@ int srslte_ringbuffer_read_timed_block(srslte_ringbuffer_t* q, void* p, int nof_ } if (ret == ETIMEDOUT) { - ret = SRSLTE_ERROR_TIMEOUT; + ret = SRSRAN_ERROR_TIMEOUT; } else if (!q->active) { - ret = SRSLTE_SUCCESS; - } else if (ret == SRSLTE_SUCCESS) { + ret = SRSRAN_SUCCESS; + } else if (ret == SRSRAN_SUCCESS) { if (nof_bytes + q->rpm > q->capacity) { int x = q->capacity - q->rpm; memcpy(ptr, &q->buffer[q->rpm], x); @@ -229,10 +229,10 @@ int srslte_ringbuffer_read_timed_block(srslte_ringbuffer_t* q, void* p, int nof_ ret = nof_bytes; } else if (ret == EINVAL) { fprintf(stderr, "Error: pthread_cond_timedwait() returned EINVAL, timeout value corrupted.\n"); - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } else { printf("ret=%d %s\n", ret, strerror(ret)); - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } // Unlock mutex @@ -242,7 +242,7 @@ int srslte_ringbuffer_read_timed_block(srslte_ringbuffer_t* q, void* p, int nof_ return ret; } -void srslte_ringbuffer_stop(srslte_ringbuffer_t* q) +void srsran_ringbuffer_stop(srsran_ringbuffer_t* q) { pthread_mutex_lock(&q->mutex); q->active = false; @@ -252,7 +252,7 @@ void srslte_ringbuffer_stop(srslte_ringbuffer_t* q) } // Converts SC16 to cf_t -int srslte_ringbuffer_read_convert_conj(srslte_ringbuffer_t* q, cf_t* dst_ptr, float norm, int nof_samples) +int srsran_ringbuffer_read_convert_conj(srsran_ringbuffer_t* q, cf_t* dst_ptr, float norm, int nof_samples) { uint32_t nof_bytes = nof_samples * 4; @@ -262,7 +262,7 @@ int srslte_ringbuffer_read_convert_conj(srslte_ringbuffer_t* q, cf_t* dst_ptr, f } if (!q->active) { pthread_mutex_unlock(&q->mutex); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } int16_t* src = (int16_t*)&q->buffer[q->rpm]; @@ -270,12 +270,12 @@ int srslte_ringbuffer_read_convert_conj(srslte_ringbuffer_t* q, cf_t* dst_ptr, f if (nof_bytes + q->rpm > q->capacity) { int x = (q->capacity - q->rpm); - srslte_vec_convert_if(src, norm, dst, x / 2); - srslte_vec_convert_if((int16_t*)q->buffer, norm, &dst[x / 2], 2 * nof_samples - x / 2); + srsran_vec_convert_if(src, norm, dst, x / 2); + srsran_vec_convert_if((int16_t*)q->buffer, norm, &dst[x / 2], 2 * nof_samples - x / 2); } else { - srslte_vec_convert_if(src, norm, dst, 2 * nof_samples); + srsran_vec_convert_if(src, norm, dst, 2 * nof_samples); } - srslte_vec_conj_cc(dst_ptr, dst_ptr, nof_samples); + srsran_vec_conj_cc(dst_ptr, dst_ptr, nof_samples); q->rpm += nof_bytes; if (q->rpm >= q->capacity) { q->rpm -= q->capacity; @@ -287,9 +287,9 @@ int srslte_ringbuffer_read_convert_conj(srslte_ringbuffer_t* q, cf_t* dst_ptr, f } /* For this function, the ring buffer capacity must be multiple of block size */ -int srslte_ringbuffer_read_block(srslte_ringbuffer_t* q, void** p, int nof_bytes, int32_t timeout_ms) +int srsran_ringbuffer_read_block(srsran_ringbuffer_t* q, void** p, int nof_bytes, int32_t timeout_ms) { - int ret = SRSLTE_SUCCESS; + int ret = SRSRAN_SUCCESS; struct timespec towait = {}; // Get current time and update timeout @@ -307,7 +307,7 @@ int srslte_ringbuffer_read_block(srslte_ringbuffer_t* q, void** p, int nof_bytes pthread_mutex_lock(&q->mutex); // Wait for having enough samples - while (q->count < nof_bytes && q->active && ret == SRSLTE_SUCCESS) { + while (q->count < nof_bytes && q->active && ret == SRSRAN_SUCCESS) { if (timeout_ms > 0) { ret = pthread_cond_timedwait(&q->write_cvar, &q->mutex, &towait); } else { @@ -316,10 +316,10 @@ int srslte_ringbuffer_read_block(srslte_ringbuffer_t* q, void** p, int nof_bytes } if (ret == ETIMEDOUT) { - ret = SRSLTE_ERROR_TIMEOUT; + ret = SRSRAN_ERROR_TIMEOUT; } else if (!q->active) { ret = 0; - } else if (ret == SRSLTE_SUCCESS) { + } else if (ret == SRSRAN_SUCCESS) { *p = &q->buffer[q->rpm]; q->count -= nof_bytes; @@ -331,10 +331,10 @@ int srslte_ringbuffer_read_block(srslte_ringbuffer_t* q, void** p, int nof_bytes ret = nof_bytes; } else if (ret == EINVAL) { fprintf(stderr, "Error: pthread_cond_timedwait() returned EINVAL, timeout value corrupted.\n"); - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } else { printf("ret=%d %s\n", ret, strerror(ret)); - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } pthread_cond_broadcast(&q->read_cvar); pthread_mutex_unlock(&q->mutex); diff --git a/lib/src/phy/utils/test/CMakeLists.txt b/lib/src/phy/utils/test/CMakeLists.txt index 39b115b03..4a5f062f4 100644 --- a/lib/src/phy/utils/test/CMakeLists.txt +++ b/lib/src/phy/utils/test/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -11,7 +11,7 @@ ######################################################################## add_executable(dft_test dft_test.c) -target_link_libraries(dft_test srslte_phy) +target_link_libraries(dft_test srsran_phy) add_test(dft_test dft_test) add_test(dft_reverse dft_test -b) # Backwards first @@ -26,20 +26,20 @@ add_test(dft_odd_dc dft_test -N 255 -b -d) # Odd-length, backwards first, handle ######################################################################## add_executable(algebra_test mat_test.c) -target_link_libraries(algebra_test srslte_phy) +target_link_libraries(algebra_test srsran_phy) add_test(algebra_2x2_zf_solver_test algebra_test -z) add_test(algebra_2x2_mmse_solver_test algebra_test -m) add_executable(vector_test vector_test.c) -target_link_libraries(vector_test srslte_phy) +target_link_libraries(vector_test srsran_phy) add_test(vector_test vector_test) ######################################################################## add_executable(ringbuffer_test ring_buffer_test.c) -target_link_libraries(ringbuffer_test srslte_phy) +target_link_libraries(ringbuffer_test srsran_phy) add_test(ringbuffer_tester ringbuffer_test) ######################################################################## diff --git a/lib/src/phy/utils/test/dft_test.c b/lib/src/phy/utils/test/dft_test.c index adb168743..8d15ad910 100644 --- a/lib/src/phy/utils/test/dft_test.c +++ b/lib/src/phy/utils/test/dft_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -18,8 +18,8 @@ #include #include -#include "srslte/phy/dft/dft.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/dft/dft.h" +#include "srsran/phy/utils/vector.h" uint32_t N = 256; bool forward = true; @@ -78,36 +78,36 @@ int test_dft(cf_t* in) { int res = 0; - srslte_dft_plan_t plan; + srsran_dft_plan_t plan; if (forward) { - srslte_dft_plan(&plan, N, SRSLTE_DFT_FORWARD, SRSLTE_DFT_COMPLEX); + srsran_dft_plan(&plan, N, SRSRAN_DFT_FORWARD, SRSRAN_DFT_COMPLEX); } else { - srslte_dft_plan(&plan, N, SRSLTE_DFT_BACKWARD, SRSLTE_DFT_COMPLEX); + srsran_dft_plan(&plan, N, SRSRAN_DFT_BACKWARD, SRSRAN_DFT_COMPLEX); } - srslte_dft_plan_set_mirror(&plan, mirror); - srslte_dft_plan_set_norm(&plan, norm); - srslte_dft_plan_set_dc(&plan, dc); + srsran_dft_plan_set_mirror(&plan, mirror); + srsran_dft_plan_set_norm(&plan, norm); + srsran_dft_plan_set_dc(&plan, dc); - cf_t* out1 = srslte_vec_cf_malloc(N); - cf_t* out2 = srslte_vec_cf_malloc(N); - srslte_vec_cf_zero(out1, N); - srslte_vec_cf_zero(out2, N); + cf_t* out1 = srsran_vec_cf_malloc(N); + cf_t* out2 = srsran_vec_cf_malloc(N); + srsran_vec_cf_zero(out1, N); + srsran_vec_cf_zero(out2, N); print(in, N); - srslte_dft_run(&plan, in, out1); + srsran_dft_run(&plan, in, out1); print(out1, N); - srslte_dft_plan_t plan_rev; + srsran_dft_plan_t plan_rev; if (!forward) { - srslte_dft_plan(&plan_rev, N, SRSLTE_DFT_FORWARD, SRSLTE_DFT_COMPLEX); + srsran_dft_plan(&plan_rev, N, SRSRAN_DFT_FORWARD, SRSRAN_DFT_COMPLEX); } else { - srslte_dft_plan(&plan_rev, N, SRSLTE_DFT_BACKWARD, SRSLTE_DFT_COMPLEX); + srsran_dft_plan(&plan_rev, N, SRSRAN_DFT_BACKWARD, SRSRAN_DFT_COMPLEX); } - srslte_dft_plan_set_mirror(&plan_rev, mirror); - srslte_dft_plan_set_norm(&plan_rev, norm); - srslte_dft_plan_set_dc(&plan_rev, dc); + srsran_dft_plan_set_mirror(&plan_rev, mirror); + srsran_dft_plan_set_norm(&plan_rev, norm); + srsran_dft_plan_set_dc(&plan_rev, dc); - srslte_dft_run(&plan_rev, out1, out2); + srsran_dft_run(&plan_rev, out1, out2); print(out2, N); if (!norm) { @@ -122,8 +122,8 @@ int test_dft(cf_t* in) res = -1; } - srslte_dft_plan_free(&plan); - srslte_dft_plan_free(&plan_rev); + srsran_dft_plan_free(&plan); + srsran_dft_plan_free(&plan_rev); free(out1); free(out2); @@ -133,8 +133,8 @@ int test_dft(cf_t* in) int main(int argc, char** argv) { parse_args(argc, argv); - cf_t* in = srslte_vec_cf_malloc(N); - srslte_vec_cf_zero(in, N); + cf_t* in = srsran_vec_cf_malloc(N); + srsran_vec_cf_zero(in, N); for (int i = 1; i < N - 1; i++) { float re = 100 * rand() / (float)RAND_MAX; float im = 100 * rand() / (float)RAND_MAX; diff --git a/lib/src/phy/utils/test/mat_test.c b/lib/src/phy/utils/test/mat_test.c index ce7b6c315..e05b4bcdd 100644 --- a/lib/src/phy/utils/test/mat_test.c +++ b/lib/src/phy/utils/test/mat_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,25 +11,25 @@ */ #include -#include +#include #include #include #include #include #include -#include "srslte/phy/utils/mat.h" -#include "srslte/phy/utils/vector.h" -#include "srslte/phy/utils/vector_simd.h" +#include "srsran/phy/utils/mat.h" +#include "srsran/phy/utils/vector.h" +#include "srsran/phy/utils/vector_simd.h" static bool inverter = false; static bool zf_solver = false; static bool mmse_solver = false; static bool verbose = false; -static srslte_random_t random_gen = NULL; +static srsran_random_t random_gen = NULL; #define MAXIMUM_ERROR (1e-6f) -#define RANDOM_F() srslte_random_uniform_real_dist(random_gen, -1.0f, +1.0f) -#define RANDOM_CF() srslte_random_uniform_complex_dist(random_gen, -1.0f, +1.0f) +#define RANDOM_F() srsran_random_uniform_real_dist(random_gen, -1.0f, +1.0f) +#define RANDOM_CF() srsran_random_uniform_complex_dist(random_gen, -1.0f, +1.0f) double elapsed_us(struct timeval* ts_start, struct timeval* ts_end) { @@ -109,7 +109,7 @@ static bool test_zf_solver_gen(void) cf_t y0 = x0_gold * h00 + x1_gold * h01; cf_t y1 = x0_gold * h10 + x1_gold * h11; - srslte_mat_2x2_zf_gen(y0, y1, h00, h01, h10, h11, &x0, &x1, 1.0f); + srsran_mat_2x2_zf_gen(y0, y1, h00, h01, h10, h11, &x0, &x1, 1.0f); cf_error0 = x0 - x0_gold; cf_error1 = x1 - x1_gold; @@ -133,7 +133,7 @@ static bool test_mmse_solver_gen(void) cf_t y0 = x0_gold * h00 + x1_gold * h01; cf_t y1 = x0_gold * h10 + x1_gold * h11; - srslte_mat_2x2_mmse_gen(y0, y1, h00, h01, h10, h11, &x0, &x1, 0.0f, 1.0f); + srsran_mat_2x2_mmse_gen(y0, y1, h00, h01, h10, h11, &x0, &x1, 0.0f, 1.0f); cf_error0 = x0 - x0_gold; cf_error1 = x1 - x1_gold; @@ -143,7 +143,7 @@ static bool test_mmse_solver_gen(void) return (error < MAXIMUM_ERROR); } -#if SRSLTE_SIMD_CF_SIZE != 0 +#if SRSRAN_SIMD_CF_SIZE != 0 static bool test_zf_solver_simd(void) { @@ -159,23 +159,23 @@ static bool test_zf_solver_simd(void) cf_t y0_1 = x0_gold_1 * h00_1 + x1_gold_1 * h01_1; cf_t y1_1 = x0_gold_1 * h10_1 + x1_gold_1 * h11_1; - simd_cf_t _y0 = srslte_simd_cf_set1(y0_1); - simd_cf_t _y1 = srslte_simd_cf_set1(y1_1); + simd_cf_t _y0 = srsran_simd_cf_set1(y0_1); + simd_cf_t _y1 = srsran_simd_cf_set1(y1_1); - simd_cf_t _h00 = srslte_simd_cf_set1(h00_1); - simd_cf_t _h01 = srslte_simd_cf_set1(h01_1); - simd_cf_t _h10 = srslte_simd_cf_set1(h10_1); - simd_cf_t _h11 = srslte_simd_cf_set1(h11_1); + simd_cf_t _h00 = srsran_simd_cf_set1(h00_1); + simd_cf_t _h01 = srsran_simd_cf_set1(h01_1); + simd_cf_t _h10 = srsran_simd_cf_set1(h10_1); + simd_cf_t _h11 = srsran_simd_cf_set1(h11_1); simd_cf_t _x0, _x1; - srslte_mat_2x2_zf_simd(_y0, _y1, _h00, _h01, _h10, _h11, &_x0, &_x1, 1.0f); + srsran_mat_2x2_zf_simd(_y0, _y1, _h00, _h01, _h10, _h11, &_x0, &_x1, 1.0f); - srslte_simd_aligned cf_t x0[SRSLTE_SIMD_CF_SIZE]; - srslte_simd_aligned cf_t x1[SRSLTE_SIMD_CF_SIZE]; + srsran_simd_aligned cf_t x0[SRSRAN_SIMD_CF_SIZE]; + srsran_simd_aligned cf_t x1[SRSRAN_SIMD_CF_SIZE]; - srslte_simd_cfi_store(x0, _x0); - srslte_simd_cfi_store(x1, _x1); + srsran_simd_cfi_store(x0, _x0); + srsran_simd_cfi_store(x1, _x1); cf_error0 = x0[1] - x0_gold_1; cf_error1 = x1[1] - x1_gold_1; @@ -190,16 +190,16 @@ static bool test_mmse_solver_simd(void) cf_t cf_error0, cf_error1; float error = 0.0f; - cf_t x0_gold[SRSLTE_SIMD_CF_SIZE]; - cf_t x1_gold[SRSLTE_SIMD_CF_SIZE]; - cf_t h00[SRSLTE_SIMD_CF_SIZE]; - cf_t h01[SRSLTE_SIMD_CF_SIZE]; - cf_t h10[SRSLTE_SIMD_CF_SIZE]; - cf_t h11[SRSLTE_SIMD_CF_SIZE]; - cf_t y0[SRSLTE_SIMD_CF_SIZE]; - cf_t y1[SRSLTE_SIMD_CF_SIZE]; + cf_t x0_gold[SRSRAN_SIMD_CF_SIZE]; + cf_t x1_gold[SRSRAN_SIMD_CF_SIZE]; + cf_t h00[SRSRAN_SIMD_CF_SIZE]; + cf_t h01[SRSRAN_SIMD_CF_SIZE]; + cf_t h10[SRSRAN_SIMD_CF_SIZE]; + cf_t h11[SRSRAN_SIMD_CF_SIZE]; + cf_t y0[SRSRAN_SIMD_CF_SIZE]; + cf_t y1[SRSRAN_SIMD_CF_SIZE]; - for (int i = 0; i < SRSLTE_SIMD_CF_SIZE; i++) { + for (int i = 0; i < SRSRAN_SIMD_CF_SIZE; i++) { x0_gold[i] = RANDOM_CF(); x1_gold[i] = RANDOM_CF(); h00[i] = RANDOM_CF(); @@ -210,23 +210,23 @@ static bool test_mmse_solver_simd(void) y1[i] = x0_gold[i] * h10[i] + x1_gold[i] * h11[i]; } - simd_cf_t _y0 = srslte_simd_cfi_loadu(y0); - simd_cf_t _y1 = srslte_simd_cfi_loadu(y1); + simd_cf_t _y0 = srsran_simd_cfi_loadu(y0); + simd_cf_t _y1 = srsran_simd_cfi_loadu(y1); - simd_cf_t _h00 = srslte_simd_cfi_loadu(h00); - simd_cf_t _h01 = srslte_simd_cfi_loadu(h01); - simd_cf_t _h10 = srslte_simd_cfi_loadu(h10); - simd_cf_t _h11 = srslte_simd_cfi_loadu(h11); + simd_cf_t _h00 = srsran_simd_cfi_loadu(h00); + simd_cf_t _h01 = srsran_simd_cfi_loadu(h01); + simd_cf_t _h10 = srsran_simd_cfi_loadu(h10); + simd_cf_t _h11 = srsran_simd_cfi_loadu(h11); simd_cf_t _x0, _x1; - srslte_mat_2x2_mmse_simd(_y0, _y1, _h00, _h01, _h10, _h11, &_x0, &_x1, 0.0f, 1.0f); + srsran_mat_2x2_mmse_simd(_y0, _y1, _h00, _h01, _h10, _h11, &_x0, &_x1, 0.0f, 1.0f); - srslte_simd_aligned cf_t x0[SRSLTE_SIMD_CF_SIZE]; - srslte_simd_aligned cf_t x1[SRSLTE_SIMD_CF_SIZE]; + srsran_simd_aligned cf_t x0[SRSRAN_SIMD_CF_SIZE]; + srsran_simd_aligned cf_t x1[SRSRAN_SIMD_CF_SIZE]; - srslte_simd_cfi_store(x0, _x0); - srslte_simd_cfi_store(x1, _x1); + srsran_simd_cfi_store(x0, _x0); + srsran_simd_cfi_store(x1, _x1); cf_error0 = x0[1] - x0_gold[1]; cf_error1 = x1[1] - x1_gold[1]; @@ -239,7 +239,7 @@ static bool test_mmse_solver_simd(void) return (error < MAXIMUM_ERROR); } -#endif /* SRSLTE_SIMD_CF_SIZE != 0 */ +#endif /* SRSRAN_SIMD_CF_SIZE != 0 */ static bool test_vec_dot_prod_ccc(void) { @@ -252,7 +252,7 @@ static bool test_vec_dot_prod_ccc(void) b[i] = RANDOM_CF(); } - res = srslte_vec_dot_prod_ccc(a, b, 14); + res = srsran_vec_dot_prod_ccc(a, b, 14); for (int i = 0; i < 14; i++) { gold += a[i] * b[i]; @@ -267,19 +267,19 @@ bool test_matrix_inv(void) __attribute__((aligned(256))) cf_t x[N * N]; __attribute__((aligned(256))) cf_t y[N * N]; - srslte_matrix_NxN_inv_t matrix_nxn_inv = {}; + srsran_matrix_NxN_inv_t matrix_nxn_inv = {}; - srslte_matrix_NxN_inv_init(&matrix_nxn_inv, N); + srsran_matrix_NxN_inv_init(&matrix_nxn_inv, N); for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { - x[i * N + j] = srslte_random_uniform_complex_dist(random_gen, -1.0f, +1.0f); + x[i * N + j] = srsran_random_uniform_complex_dist(random_gen, -1.0f, +1.0f); } } - srslte_matrix_NxN_inv_run(&matrix_nxn_inv, x, y); + srsran_matrix_NxN_inv_run(&matrix_nxn_inv, x, y); - srslte_matrix_NxN_inv_free(&matrix_nxn_inv); + srsran_matrix_NxN_inv_free(&matrix_nxn_inv); return true; } @@ -287,26 +287,26 @@ bool test_matrix_inv(void) int main(int argc, char** argv) { bool passed = true; - int ret = SRSLTE_SUCCESS; + int ret = SRSRAN_SUCCESS; parse_args(argc, argv); - random_gen = srslte_random_init(0); + random_gen = srsran_random_init(0); if (zf_solver) { RUN_TEST(test_zf_solver_gen); -#if SRSLTE_SIMD_CF_SIZE != 0 +#if SRSRAN_SIMD_CF_SIZE != 0 RUN_TEST(test_zf_solver_simd); -#endif /* SRSLTE_SIMD_CF_SIZE != 0*/ +#endif /* SRSRAN_SIMD_CF_SIZE != 0*/ } if (mmse_solver) { RUN_TEST(test_mmse_solver_gen); -#if SRSLTE_SIMD_CF_SIZE != 0 +#if SRSRAN_SIMD_CF_SIZE != 0 RUN_TEST(test_mmse_solver_simd); -#endif /* SRSLTE_SIMD_CF_SIZE != 0*/ +#endif /* SRSRAN_SIMD_CF_SIZE != 0*/ } if (inverter) { @@ -317,10 +317,10 @@ int main(int argc, char** argv) printf("%s!\n", (passed) ? "Ok" : "Failed"); - srslte_random_free(random_gen); + srsran_random_free(random_gen); if (!passed) { - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } return ret; diff --git a/lib/src/phy/utils/test/ring_buffer_test.c b/lib/src/phy/utils/test/ring_buffer_test.c index 6ea5a388d..8410d5033 100644 --- a/lib/src/phy/utils/test/ring_buffer_test.c +++ b/lib/src/phy/utils/test/ring_buffer_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,7 +10,7 @@ * */ -#include "srslte/common/test_common.h" +#include "srsran/common/test_common.h" #include #include #include @@ -21,14 +21,14 @@ #include #include -#include "srslte/phy/utils/ringbuffer.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/utils/ringbuffer.h" +#include "srsran/phy/utils/vector.h" struct thread_args_t { int len; uint8_t* in; uint8_t* out; - srslte_ringbuffer_t* buf; + srsran_ringbuffer_t* buf; int res; }; @@ -60,23 +60,23 @@ void parse_args(int argc, char** argv) } } -int test_normal_read_write(srslte_ringbuffer_t* q, uint8_t* in, uint8_t* out, int len) +int test_normal_read_write(srsran_ringbuffer_t* q, uint8_t* in, uint8_t* out, int len) { - srslte_ringbuffer_write(q, in, len / 2); - srslte_ringbuffer_write(q, &in[len / 2], len / 2); + srsran_ringbuffer_write(q, in, len / 2); + srsran_ringbuffer_write(q, &in[len / 2], len / 2); for (int i = 0; i < 4; i++) { - srslte_ringbuffer_read(q, &out[(len / 4) * i], len / 4); + srsran_ringbuffer_read(q, &out[(len / 4) * i], len / 4); } TESTASSERT(!memcmp(in, out, len)); return 0; } -int test_overflow_write(srslte_ringbuffer_t* q, uint8_t* in, uint8_t* out, int len) +int test_overflow_write(srsran_ringbuffer_t* q, uint8_t* in, uint8_t* out, int len) { - int ret = srslte_ringbuffer_write(q, in, len / 2); - ret = srslte_ringbuffer_write(q, &in[len / 2], len / 2 + 2); + int ret = srsran_ringbuffer_write(q, in, len / 2); + ret = srsran_ringbuffer_write(q, &in[len / 2], len / 2 + 2); if (ret != (len / 2 + 2)) { ret = -1; } @@ -88,7 +88,7 @@ void* write_thread(void* args_) int res = 0; struct thread_args_t* args = (struct thread_args_t*)args_; for (int i = 0; i < M; i++) { - res = srslte_ringbuffer_write_block(args->buf, args->in, args->len); + res = srsran_ringbuffer_write_block(args->buf, args->in, args->len); } if (res < 0) { args->res = res; @@ -101,7 +101,7 @@ void* read_thread(void* args_) int res = 0; struct thread_args_t* args = (struct thread_args_t*)args_; for (int i = 0; i < M; i++) { - res = srslte_ringbuffer_read(args->buf, &args->out[args->len * i], args->len); + res = srsran_ringbuffer_read(args->buf, &args->out[args->len * i], args->len); } if (res < 0) { args->res = res; @@ -115,18 +115,18 @@ int threaded_blocking_test(struct thread_args_t* args) pthread_t threads[2]; if (pthread_create(&threads[0], NULL, write_thread, args)) { fprintf(stderr, "Error creating thread\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } usleep(10000); if (pthread_create(&threads[1], NULL, read_thread, args)) { fprintf(stderr, "Error creating thread\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } for (int i = 0; i < 2; i++) { if (pthread_join(threads[i], NULL)) { fprintf(stderr, "Error joining thread\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } @@ -136,22 +136,22 @@ int threaded_blocking_test(struct thread_args_t* args) } if (args->res < 0) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int main(int argc, char** argv) { - int ret = SRSLTE_SUCCESS; + int ret = SRSRAN_SUCCESS; parse_args(argc, argv); struct thread_args_t thread_in; - uint8_t* in = srslte_vec_u8_malloc(N * 2); - uint8_t* out = srslte_vec_u8_malloc(N * 10); - srslte_ringbuffer_t ring_buf; - srslte_ringbuffer_init(&ring_buf, N); + uint8_t* in = srsran_vec_u8_malloc(N * 2); + uint8_t* out = srsran_vec_u8_malloc(N * 10); + srsran_ringbuffer_t ring_buf; + srsran_ringbuffer_init(&ring_buf, N); thread_in.in = in; thread_in.out = out; @@ -165,24 +165,24 @@ int main(int argc, char** argv) if (test_normal_read_write(&ring_buf, in, out, N) < 0) { printf("Normal read write test failed\n"); - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } bzero(out, N * 10); - srslte_ringbuffer_reset(&ring_buf); + srsran_ringbuffer_reset(&ring_buf); if (test_overflow_write(&ring_buf, in, out, N) != -1) { printf("Overflow detection not working correctly\n"); - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } bzero(out, N * 10); - srslte_ringbuffer_reset(&ring_buf); + srsran_ringbuffer_reset(&ring_buf); if (threaded_blocking_test((void*)&thread_in)) { printf("Error in multithreaded blocking ringbuffer test\n"); - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } - srslte_ringbuffer_stop(&ring_buf); - srslte_ringbuffer_free(&ring_buf); + srsran_ringbuffer_stop(&ring_buf); + srsran_ringbuffer_free(&ring_buf); free(in); free(out); printf("Done\n"); diff --git a/lib/src/phy/utils/test/vector_test.c b/lib/src/phy/utils/test/vector_test.c index 77b58f3d2..0d184e1b3 100644 --- a/lib/src/phy/utils/test/vector_test.c +++ b/lib/src/phy/utils/test/vector_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,8 +10,8 @@ * */ -#include "srslte/srslte.h" -#include +#include "srsran/srsran.h" +#include bool zf_solver = false; bool mmse_solver = false; @@ -23,11 +23,11 @@ static uint32_t nof_repetitions = 1; #define MAX_FUNCTIONS (64) #define MAX_BLOCKS (16) -static srslte_random_t random_h = NULL; -#define RANDOM_F() srslte_random_uniform_real_dist(random_h, -1.0f, +1.0f) -#define RANDOM_S() ((int16_t)srslte_random_uniform_int_dist(random_h, -255, +255)) -#define RANDOM_B() ((int8_t)srslte_random_uniform_int_dist(random_h, -127, +127)) -#define RANDOM_CF() srslte_random_uniform_complex_dist(random_h, -1.0f, +1.0f) +static srsran_random_t random_h = NULL; +#define RANDOM_F() srsran_random_uniform_real_dist(random_h, -1.0f, +1.0f) +#define RANDOM_S() ((int16_t)srsran_random_uniform_int_dist(random_h, -255, +255)) +#define RANDOM_B() ((int8_t)srsran_random_uniform_int_dist(random_h, -127, +127)) +#define RANDOM_CF() srsran_random_uniform_complex_dist(random_h, -1.0f, +1.0f) #define TEST_CALL(TEST_CODE) \ gettimeofday(&start, NULL); \ @@ -57,7 +57,7 @@ static srslte_random_t random_h = NULL; return passed; \ } -#define MALLOC(TYPE, NAME) TYPE* NAME = srslte_vec_malloc(sizeof(TYPE) * block_size) +#define MALLOC(TYPE, NAME) TYPE* NAME = srsran_vec_malloc(sizeof(TYPE) * block_size) static double elapsed_us(struct timeval* ts_start, struct timeval* ts_end) { @@ -78,7 +78,7 @@ float squared_error(cf_t a, cf_t b) } TEST( - srslte_vec_xor_bbb, MALLOC(uint8_t, x); MALLOC(uint8_t, y); MALLOC(uint8_t, z); + srsran_vec_xor_bbb, MALLOC(uint8_t, x); MALLOC(uint8_t, y); MALLOC(uint8_t, z); cf_t gold = 0.0f; for (int i = 0; i < block_size; i++) { @@ -86,7 +86,7 @@ TEST( y[i] = RANDOM_B(); } - TEST_CALL(srslte_vec_xor_bbb(x, y, z, block_size)) + TEST_CALL(srsran_vec_xor_bbb(x, y, z, block_size)) for (int i = 0; i < block_size; i++) { gold = x[i] ^ y[i]; @@ -97,21 +97,22 @@ TEST( free(y); free(z);) -TEST(srslte_vec_acc_ff, MALLOC(float, x); float z = 0; +TEST( + srsran_vec_acc_ff, MALLOC(float, x); float z = 0; - cf_t gold = 0.0f; - for (int i = 0; i < block_size; i++) { x[i] = RANDOM_F(); } + cf_t gold = 0.0f; + for (int i = 0; i < block_size; i++) { x[i] = RANDOM_F(); } - TEST_CALL(z = srslte_vec_acc_ff(x, block_size)) + TEST_CALL(z = srsran_vec_acc_ff(x, block_size)) - for (int i = 0; i < block_size; i++) { gold += x[i]; } + for (int i = 0; i < block_size; i++) { gold += x[i]; } - mse += cabsf(gold - z) / gold; + mse += cabsf(gold - z) / gold; - free(x);) + free(x);) TEST( - srslte_vec_dot_prod_sss, MALLOC(int16_t, x); MALLOC(int16_t, y); int16_t z = 0; + srsran_vec_dot_prod_sss, MALLOC(int16_t, x); MALLOC(int16_t, y); int16_t z = 0; int16_t gold = 0.0f; for (int i = 0; i < block_size; i++) { @@ -119,7 +120,7 @@ TEST( y[i] = RANDOM_S(); } - TEST_CALL(z = srslte_vec_dot_prod_sss(x, y, block_size)) + TEST_CALL(z = srsran_vec_dot_prod_sss(x, y, block_size)) for (int i = 0; i < block_size; i++) { gold += x[i] * y[i]; } @@ -129,7 +130,7 @@ TEST( free(y);) TEST( - srslte_vec_sum_sss, MALLOC(int16_t, x); MALLOC(int16_t, y); MALLOC(int16_t, z); + srsran_vec_sum_sss, MALLOC(int16_t, x); MALLOC(int16_t, y); MALLOC(int16_t, z); int16_t gold = 0; for (int i = 0; i < block_size; i++) { @@ -137,7 +138,7 @@ TEST( y[i] = RANDOM_S(); } - TEST_CALL(srslte_vec_sum_sss(x, y, z, block_size)) + TEST_CALL(srsran_vec_sum_sss(x, y, z, block_size)) for (int i = 0; i < block_size; i++) { gold = x[i] + y[i]; @@ -149,7 +150,7 @@ TEST( free(z);) TEST( - srslte_vec_sub_sss, MALLOC(int16_t, x); MALLOC(int16_t, y); MALLOC(int16_t, z); + srsran_vec_sub_sss, MALLOC(int16_t, x); MALLOC(int16_t, y); MALLOC(int16_t, z); int16_t gold = 0.0f; for (int i = 0; i < block_size; i++) { @@ -157,7 +158,7 @@ TEST( y[i] = RANDOM_S(); } - TEST_CALL(srslte_vec_sub_sss(x, y, z, block_size)) + TEST_CALL(srsran_vec_sub_sss(x, y, z, block_size)) for (int i = 0; i < block_size; i++) { gold = x[i] - y[i]; @@ -169,7 +170,7 @@ TEST( free(z);) TEST( - srslte_vec_prod_sss, MALLOC(int16_t, x); MALLOC(int16_t, y); MALLOC(int16_t, z); + srsran_vec_prod_sss, MALLOC(int16_t, x); MALLOC(int16_t, y); MALLOC(int16_t, z); int16_t gold = 0.0f; for (int i = 0; i < block_size; i++) { @@ -177,7 +178,7 @@ TEST( y[i] = RANDOM_S(); } - TEST_CALL(srslte_vec_prod_sss(x, y, z, block_size)) + TEST_CALL(srsran_vec_prod_sss(x, y, z, block_size)) for (int i = 0; i < block_size; i++) { gold = x[i] * y[i]; @@ -189,7 +190,7 @@ TEST( free(z);) TEST( - srslte_vec_neg_sss, MALLOC(int16_t, x); MALLOC(int16_t, y); MALLOC(int16_t, z); + srsran_vec_neg_sss, MALLOC(int16_t, x); MALLOC(int16_t, y); MALLOC(int16_t, z); int16_t gold = 0.0f; for (int i = 0; i < block_size; i++) { @@ -199,7 +200,7 @@ TEST( } while (!y[i]); } - TEST_CALL(srslte_vec_neg_sss(x, y, z, block_size)) + TEST_CALL(srsran_vec_neg_sss(x, y, z, block_size)) for (int i = 0; i < block_size; i++) { gold = y[i] < 0 ? -x[i] : x[i]; @@ -210,21 +211,22 @@ TEST( free(y); free(z);) -TEST(srslte_vec_acc_cc, MALLOC(cf_t, x); cf_t z = 0.0f; +TEST( + srsran_vec_acc_cc, MALLOC(cf_t, x); cf_t z = 0.0f; - cf_t gold = 0.0f; - for (int i = 0; i < block_size; i++) { x[i] = RANDOM_F(); } + cf_t gold = 0.0f; + for (int i = 0; i < block_size; i++) { x[i] = RANDOM_F(); } - TEST_CALL(z = srslte_vec_acc_cc(x, block_size)) + TEST_CALL(z = srsran_vec_acc_cc(x, block_size)) - for (int i = 0; i < block_size; i++) { gold += x[i]; } + for (int i = 0; i < block_size; i++) { gold += x[i]; } - mse += cabsf(gold - z) / cabsf(gold); + mse += cabsf(gold - z) / cabsf(gold); - free(x);) + free(x);) TEST( - srslte_vec_sum_fff, MALLOC(float, x); MALLOC(float, y); MALLOC(float, z); + srsran_vec_sum_fff, MALLOC(float, x); MALLOC(float, y); MALLOC(float, z); cf_t gold = 0.0f; for (int i = 0; i < block_size; i++) { @@ -232,7 +234,7 @@ TEST( y[i] = RANDOM_F(); } - TEST_CALL(srslte_vec_sum_fff(x, y, z, block_size)) + TEST_CALL(srsran_vec_sum_fff(x, y, z, block_size)) for (int i = 0; i < block_size; i++) { gold = x[i] + y[i]; @@ -244,7 +246,7 @@ TEST( free(z);) TEST( - srslte_vec_sub_fff, MALLOC(float, x); MALLOC(float, y); MALLOC(float, z); + srsran_vec_sub_fff, MALLOC(float, x); MALLOC(float, y); MALLOC(float, z); cf_t gold = 0.0f; for (int i = 0; i < block_size; i++) { @@ -252,7 +254,7 @@ TEST( y[i] = RANDOM_F(); } - TEST_CALL(srslte_vec_sub_fff(x, y, z, block_size)) + TEST_CALL(srsran_vec_sub_fff(x, y, z, block_size)) for (int i = 0; i < block_size; i++) { gold = x[i] - y[i]; @@ -264,7 +266,7 @@ TEST( free(z);) TEST( - srslte_vec_dot_prod_ccc, MALLOC(cf_t, x); MALLOC(cf_t, y); cf_t z = 0.0f; + srsran_vec_dot_prod_ccc, MALLOC(cf_t, x); MALLOC(cf_t, y); cf_t z = 0.0f; cf_t gold = 0.0f; for (int i = 0; i < block_size; i++) { @@ -272,7 +274,7 @@ TEST( y[i] = RANDOM_CF(); } - TEST_CALL(z = srslte_vec_dot_prod_ccc(x, y, block_size)) + TEST_CALL(z = srsran_vec_dot_prod_ccc(x, y, block_size)) for (int i = 0; i < block_size; i++) { gold += x[i] * y[i]; } @@ -282,7 +284,7 @@ TEST( free(y);) TEST( - srslte_vec_dot_prod_conj_ccc, MALLOC(cf_t, x); MALLOC(cf_t, y); cf_t z = 0.0f; + srsran_vec_dot_prod_conj_ccc, MALLOC(cf_t, x); MALLOC(cf_t, y); cf_t z = 0.0f; cf_t gold = 0.0f; for (int i = 0; i < block_size; i++) { @@ -290,7 +292,7 @@ TEST( y[i] = RANDOM_CF(); } - TEST_CALL(z = srslte_vec_dot_prod_conj_ccc(x, y, block_size)) + TEST_CALL(z = srsran_vec_dot_prod_conj_ccc(x, y, block_size)) for (int i = 0; i < block_size; i++) { gold += x[i] * conjf(y[i]); } @@ -300,7 +302,7 @@ TEST( free(y);) TEST( - srslte_vec_prod_ccc, MALLOC(cf_t, x); MALLOC(cf_t, y); MALLOC(cf_t, z); + srsran_vec_prod_ccc, MALLOC(cf_t, x); MALLOC(cf_t, y); MALLOC(cf_t, z); cf_t gold; for (int i = 0; i < block_size; i++) { @@ -308,7 +310,7 @@ TEST( y[i] = RANDOM_CF(); } - TEST_CALL(srslte_vec_prod_ccc(x, y, z, block_size)) + TEST_CALL(srsran_vec_prod_ccc(x, y, z, block_size)) for (int i = 0; i < block_size; i++) { gold = x[i] * y[i]; @@ -320,7 +322,7 @@ TEST( free(z);) TEST( - srslte_vec_prod_ccc_split, MALLOC(float, x_re); MALLOC(float, x_im); MALLOC(float, y_re); MALLOC(float, y_im); + srsran_vec_prod_ccc_split, MALLOC(float, x_re); MALLOC(float, x_im); MALLOC(float, y_re); MALLOC(float, y_im); MALLOC(float, z_re); MALLOC(float, z_im); @@ -332,7 +334,7 @@ TEST( y_im[i] = RANDOM_F(); } - TEST_CALL(srslte_vec_prod_ccc_split(x_re, x_im, y_re, y_im, z_re, z_im, block_size)) + TEST_CALL(srsran_vec_prod_ccc_split(x_re, x_im, y_re, y_im, z_re, z_im, block_size)) for (int i = 0; i < block_size; i++) { gold = (x_re[i] + I * x_im[i]) * (y_re[i] + I * y_im[i]); @@ -347,7 +349,7 @@ TEST( free(z_im);) TEST( - srslte_vec_prod_conj_ccc, MALLOC(cf_t, x); MALLOC(cf_t, y); MALLOC(cf_t, z); + srsran_vec_prod_conj_ccc, MALLOC(cf_t, x); MALLOC(cf_t, y); MALLOC(cf_t, z); cf_t gold; for (int i = 0; i < block_size; i++) { @@ -355,7 +357,7 @@ TEST( y[i] = RANDOM_CF(); } - TEST_CALL(srslte_vec_prod_conj_ccc(x, y, z, block_size)) + TEST_CALL(srsran_vec_prod_conj_ccc(x, y, z, block_size)) for (int i = 0; i < block_size; i++) { gold = x[i] * conjf(y[i]); @@ -366,48 +368,50 @@ TEST( free(y); free(z);) -TEST(srslte_vec_sc_prod_ccc, MALLOC(cf_t, x); MALLOC(cf_t, z); cf_t y = RANDOM_CF(); +TEST( + srsran_vec_sc_prod_ccc, MALLOC(cf_t, x); MALLOC(cf_t, z); cf_t y = RANDOM_CF(); - cf_t gold; - for (int i = 0; i < block_size; i++) { x[i] = RANDOM_CF(); } + cf_t gold; + for (int i = 0; i < block_size; i++) { x[i] = RANDOM_CF(); } - TEST_CALL(srslte_vec_sc_prod_ccc(x, y, z, block_size)) + TEST_CALL(srsran_vec_sc_prod_ccc(x, y, z, block_size)) - for (int i = 0; i < block_size; i++) { - gold = x[i] * y; - mse += cabsf(gold - z[i]); - } + for (int i = 0; i < block_size; i++) { + gold = x[i] * y; + mse += cabsf(gold - z[i]); + } - free(x); - free(z);) + free(x); + free(z);) -TEST(srslte_vec_convert_fi, MALLOC(float, x); MALLOC(short, z); float scale = 1000.0f; +TEST( + srsran_vec_convert_fi, MALLOC(float, x); MALLOC(short, z); float scale = 1000.0f; - short gold; - for (int i = 0; i < block_size; i++) { x[i] = (float)RANDOM_F(); } + short gold; + for (int i = 0; i < block_size; i++) { x[i] = (float)RANDOM_F(); } - TEST_CALL(srslte_vec_convert_fi(x, scale, z, block_size)) + TEST_CALL(srsran_vec_convert_fi(x, scale, z, block_size)) - for (int i = 0; i < block_size; i++) { - gold = (short)((x[i] * scale)); - double err = fabsf((float)gold - (float)z[i]); - if (err > mse) { - mse = err; - } - } + for (int i = 0; i < block_size; i++) { + gold = (short)((x[i] * scale)); + double err = fabsf((float)gold - (float)z[i]); + if (err > mse) { + mse = err; + } + } - free(x); - free(z);) + free(x); + free(z);) TEST( - srslte_vec_convert_conj_cs, MALLOC(cf_t, x); int16_t* z = srslte_vec_i16_malloc(block_size * 2); + srsran_vec_convert_conj_cs, MALLOC(cf_t, x); int16_t* z = srsran_vec_i16_malloc(block_size * 2); float scale = 1000.0f; short gold_re; short gold_im; for (int i = 0; i < block_size; i++) { x[i] = RANDOM_CF(); } - TEST_CALL(srslte_vec_convert_conj_cs(x, scale, z, block_size)) + TEST_CALL(srsran_vec_convert_conj_cs(x, scale, z, block_size)) for (int i = 0; i < block_size; i++) { gold_re = (short)(crealf(x[i]) * scale); @@ -423,27 +427,28 @@ TEST( free(x); free(z);) -TEST(srslte_vec_convert_if, MALLOC(int16_t, x); MALLOC(float, z); float scale = 1000.0f; +TEST( + srsran_vec_convert_if, MALLOC(int16_t, x); MALLOC(float, z); float scale = 1000.0f; - float gold; - float k = 1.0f / scale; - for (int i = 0; i < block_size; i++) { x[i] = (int16_t)RANDOM_S(); } + float gold; + float k = 1.0f / scale; + for (int i = 0; i < block_size; i++) { x[i] = (int16_t)RANDOM_S(); } - TEST_CALL(srslte_vec_convert_if(x, scale, z, block_size)) + TEST_CALL(srsran_vec_convert_if(x, scale, z, block_size)) - for (int i = 0; i < block_size; i++) { - gold = ((float)x[i]) * k; - double err = fabsf((float)gold - (float)z[i]); - if (err > mse) { - mse = err; - } - } + for (int i = 0; i < block_size; i++) { + gold = ((float)x[i]) * k; + double err = fabsf((float)gold - (float)z[i]); + if (err > mse) { + mse = err; + } + } - free(x); - free(z);) + free(x); + free(z);) TEST( - srslte_vec_prod_fff, MALLOC(float, x); MALLOC(float, y); MALLOC(float, z); + srsran_vec_prod_fff, MALLOC(float, x); MALLOC(float, y); MALLOC(float, z); float gold; for (int i = 0; i < block_size; i++) { @@ -454,7 +459,7 @@ TEST( } } - TEST_CALL(srslte_vec_prod_fff(x, y, z, block_size)) + TEST_CALL(srsran_vec_prod_fff(x, y, z, block_size)) for (int i = 0; i < block_size; i++) { gold = x[i] * y[i]; @@ -469,7 +474,7 @@ TEST( free(z);) TEST( - srslte_vec_prod_cfc, MALLOC(cf_t, x); MALLOC(float, y); MALLOC(cf_t, z); + srsran_vec_prod_cfc, MALLOC(cf_t, x); MALLOC(float, y); MALLOC(cf_t, z); cf_t gold; for (int i = 0; i < block_size; i++) { @@ -477,7 +482,7 @@ TEST( y[i] = RANDOM_F(); } - TEST_CALL(srslte_vec_prod_cfc(x, y, z, block_size)) + TEST_CALL(srsran_vec_prod_cfc(x, y, z, block_size)) for (int i = 0; i < block_size; i++) { gold = x[i] * y[i]; @@ -488,27 +493,28 @@ TEST( free(y); free(z);) -TEST(srslte_vec_sc_prod_fff, MALLOC(float, x); MALLOC(float, z); float y = RANDOM_F(); +TEST( + srsran_vec_sc_prod_fff, MALLOC(float, x); MALLOC(float, z); float y = RANDOM_F(); - float gold; - for (int i = 0; i < block_size; i++) { x[i] = RANDOM_CF(); } + float gold; + for (int i = 0; i < block_size; i++) { x[i] = RANDOM_CF(); } - TEST_CALL(srslte_vec_sc_prod_fff(x, y, z, block_size)) + TEST_CALL(srsran_vec_sc_prod_fff(x, y, z, block_size)) - for (int i = 0; i < block_size; i++) { - gold = x[i] * y; - mse += fabsf(gold - z[i]); - } + for (int i = 0; i < block_size; i++) { + gold = x[i] * y; + mse += fabsf(gold - z[i]); + } - free(x); - free(z);) + free(x); + free(z);) TEST( - srslte_vec_abs_cf, MALLOC(cf_t, x); MALLOC(float, z); float gold; + srsran_vec_abs_cf, MALLOC(cf_t, x); MALLOC(float, z); float gold; for (int i = 0; i < block_size; i++) { x[i] = RANDOM_CF(); } x[0] = 0.0f; - TEST_CALL(srslte_vec_abs_cf(x, z, block_size)) + TEST_CALL(srsran_vec_abs_cf(x, z, block_size)) for (int i = 0; i < block_size; i++) { gold = sqrtf(crealf(x[i]) * crealf(x[i]) + cimagf(x[i]) * cimagf(x[i])); @@ -518,50 +524,53 @@ TEST( free(x); free(z);) -TEST(srslte_vec_abs_square_cf, MALLOC(cf_t, x); MALLOC(float, z); float gold; +TEST( + srsran_vec_abs_square_cf, MALLOC(cf_t, x); MALLOC(float, z); float gold; - for (int i = 0; i < block_size; i++) { x[i] = RANDOM_CF(); } + for (int i = 0; i < block_size; i++) { x[i] = RANDOM_CF(); } - TEST_CALL(srslte_vec_abs_square_cf(x, z, block_size)) + TEST_CALL(srsran_vec_abs_square_cf(x, z, block_size)) - for (int i = 0; i < block_size; i++) { - gold = crealf(x[i]) * crealf(x[i]) + cimagf(x[i]) * cimagf(x[i]); - mse += fabsf(gold - z[i]); - } + for (int i = 0; i < block_size; i++) { + gold = crealf(x[i]) * crealf(x[i]) + cimagf(x[i]) * cimagf(x[i]); + mse += fabsf(gold - z[i]); + } - free(x); - free(z);) + free(x); + free(z);) -TEST(srslte_vec_sc_prod_cfc, MALLOC(cf_t, x); MALLOC(cf_t, z); cf_t gold; float h = RANDOM_F(); +TEST( + srsran_vec_sc_prod_cfc, MALLOC(cf_t, x); MALLOC(cf_t, z); cf_t gold; float h = RANDOM_F(); - for (int i = 0; i < block_size; i++) { x[i] = RANDOM_CF(); } + for (int i = 0; i < block_size; i++) { x[i] = RANDOM_CF(); } - TEST_CALL(srslte_vec_sc_prod_cfc(x, h, z, block_size)) + TEST_CALL(srsran_vec_sc_prod_cfc(x, h, z, block_size)) - for (int i = 0; i < block_size; i++) { - gold = x[i] * h; - mse += cabsf(gold - z[i]); - } + for (int i = 0; i < block_size; i++) { + gold = x[i] * h; + mse += cabsf(gold - z[i]); + } - free(x); - free(z);) + free(x); + free(z);) -TEST(srslte_vec_sc_prod_fcc, MALLOC(float, x); MALLOC(cf_t, z); cf_t gold; float h = RANDOM_CF(); +TEST( + srsran_vec_sc_prod_fcc, MALLOC(float, x); MALLOC(cf_t, z); cf_t gold; float h = RANDOM_CF(); - for (int i = 0; i < block_size; i++) { x[i] = RANDOM_CF(); } + for (int i = 0; i < block_size; i++) { x[i] = RANDOM_CF(); } - TEST_CALL(srslte_vec_sc_prod_fcc(x, h, z, block_size)) + TEST_CALL(srsran_vec_sc_prod_fcc(x, h, z, block_size)) - for (int i = 0; i < block_size; i++) { - gold = x[i] * h; - mse += cabsf(gold - z[i]); - } + for (int i = 0; i < block_size; i++) { + gold = x[i] * h; + mse += cabsf(gold - z[i]); + } - free(x); - free(z);) + free(x); + free(z);) TEST( - srslte_vec_div_ccc, MALLOC(cf_t, x); MALLOC(cf_t, y); MALLOC(cf_t, z); + srsran_vec_div_ccc, MALLOC(cf_t, x); MALLOC(cf_t, y); MALLOC(cf_t, z); cf_t gold; for (int i = 0; i < block_size; i++) { @@ -569,7 +578,7 @@ TEST( y[i] = RANDOM_CF(); } - TEST_CALL(srslte_vec_div_ccc(x, y, z, block_size)) + TEST_CALL(srsran_vec_div_ccc(x, y, z, block_size)) for (int i = 0; i < block_size; i++) { gold = x[i] / y[i]; @@ -581,7 +590,7 @@ TEST( free(z);) TEST( - srslte_vec_div_cfc, MALLOC(cf_t, x); MALLOC(float, y); MALLOC(cf_t, z); + srsran_vec_div_cfc, MALLOC(cf_t, x); MALLOC(float, y); MALLOC(cf_t, z); cf_t gold; for (int i = 0; i < block_size; i++) { @@ -589,7 +598,7 @@ TEST( y[i] = RANDOM_F() + 0.0001f; } - TEST_CALL(srslte_vec_div_cfc(x, y, z, block_size)) + TEST_CALL(srsran_vec_div_cfc(x, y, z, block_size)) for (int i = 0; i < block_size; i++) { gold = x[i] / y[i]; @@ -601,7 +610,7 @@ TEST( free(z);) TEST( - srslte_vec_div_fff, MALLOC(float, x); MALLOC(float, y); MALLOC(float, z); + srsran_vec_div_fff, MALLOC(float, x); MALLOC(float, y); MALLOC(float, z); cf_t gold; for (int i = 0; i < block_size; i++) { @@ -609,7 +618,7 @@ TEST( y[i] = RANDOM_F() + 0.0001f; } - TEST_CALL(srslte_vec_div_fff(x, y, z, block_size)) + TEST_CALL(srsran_vec_div_fff(x, y, z, block_size)) for (int i = 0; i < block_size; i++) { gold = x[i] / y[i]; @@ -621,12 +630,12 @@ TEST( free(z);) TEST( - srslte_vec_conj_cc, MALLOC(cf_t, x); MALLOC(cf_t, z); + srsran_vec_conj_cc, MALLOC(cf_t, x); MALLOC(cf_t, z); cf_t gold; for (int i = 0; i < block_size; i++) { x[i] = RANDOM_CF(); } - TEST_CALL(srslte_vec_conj_cc(x, z, block_size)) + TEST_CALL(srsran_vec_conj_cc(x, z, block_size)) for (int i = 0; i < block_size; i++) { gold = conjf(x[i]); @@ -637,12 +646,12 @@ TEST( free(z);) TEST( - srslte_vec_max_fi, MALLOC(float, x); + srsran_vec_max_fi, MALLOC(float, x); for (int i = 0; i < block_size; i++) { x[i] = RANDOM_F(); } uint32_t max_index = 0; - TEST_CALL(max_index = srslte_vec_max_fi(x, block_size);) + TEST_CALL(max_index = srsran_vec_max_fi(x, block_size);) float gold_value = -INFINITY; uint32_t gold_index = 0; @@ -656,12 +665,12 @@ TEST( free(x);) TEST( - srslte_vec_max_abs_fi, MALLOC(float, x); + srsran_vec_max_abs_fi, MALLOC(float, x); for (int i = 0; i < block_size; i++) { x[i] = RANDOM_F(); } uint32_t max_index = 0; - TEST_CALL(max_index = srslte_vec_max_abs_fi(x, block_size);) + TEST_CALL(max_index = srsran_vec_max_abs_fi(x, block_size);) float gold_value = -INFINITY; uint32_t gold_index = 0; @@ -675,12 +684,12 @@ TEST( free(x);) TEST( - srslte_vec_max_abs_ci, MALLOC(cf_t, x); + srsran_vec_max_abs_ci, MALLOC(cf_t, x); for (int i = 0; i < block_size; i++) { x[i] = RANDOM_CF(); } uint32_t max_index = 0; - TEST_CALL(max_index = srslte_vec_max_abs_ci(x, block_size);) + TEST_CALL(max_index = srsran_vec_max_abs_ci(x, block_size);) float gold_value = -INFINITY; uint32_t gold_index = 0; @@ -695,30 +704,31 @@ TEST( free(x);) -TEST(srslte_vec_apply_cfo, MALLOC(cf_t, x); MALLOC(cf_t, z); +TEST( + srsran_vec_apply_cfo, MALLOC(cf_t, x); MALLOC(cf_t, z); - const float cfo = 0.1f; - cf_t gold; - for (int i = 0; i < block_size; i++) { x[i] = RANDOM_CF(); } + const float cfo = 0.1f; + cf_t gold; + for (int i = 0; i < block_size; i++) { x[i] = RANDOM_CF(); } - TEST_CALL(srslte_vec_apply_cfo(x, cfo, z, block_size)) + TEST_CALL(srsran_vec_apply_cfo(x, cfo, z, block_size)) - for (int i = 0; i < block_size; i++) { - gold = x[i] * cexpf(_Complex_I * 2.0f * (float)M_PI * i * cfo); - mse += cabsf(gold - z[i]) / cabsf(gold); - } mse /= block_size; + for (int i = 0; i < block_size; i++) { + gold = x[i] * cexpf(_Complex_I * 2.0f * (float)M_PI * i * cfo); + mse += cabsf(gold - z[i]) / cabsf(gold); + } mse /= block_size; - free(x); - free(z);) + free(x); + free(z);) TEST( - srslte_vec_gen_sine, MALLOC(cf_t, z); + srsran_vec_gen_sine, MALLOC(cf_t, z); const float freq = 0.1f; cf_t gold; cf_t x = RANDOM_CF(); - TEST_CALL(srslte_vec_gen_sine(x, freq, z, block_size)) + TEST_CALL(srsran_vec_gen_sine(x, freq, z, block_size)) for (int i = 0; i < block_size; i++) { gold = x * cexpf(_Complex_I * 2.0f * (float)M_PI * i * freq); @@ -727,55 +737,58 @@ TEST( free(z);) -TEST(srslte_vec_estimate_frequency, MALLOC(cf_t, x); float freq_gold = 0.1f; float freq = 0.1f; +TEST( + srsran_vec_estimate_frequency, MALLOC(cf_t, x); float freq_gold = 0.1f; float freq = 0.1f; - for (int i = 0; i < block_size; i++) { x[i] = cexpf(-I * 2.0f * M_PI * (float)i * freq_gold); } + for (int i = 0; i < block_size; i++) { x[i] = cexpf(-I * 2.0f * M_PI * (float)i * freq_gold); } - TEST_CALL(freq = srslte_vec_estimate_frequency(x, block_size);) if (block_size < 6) { mse = 0.0f; } else { - mse = fabsf(freq - freq_gold); - } + TEST_CALL(freq = srsran_vec_estimate_frequency(x, block_size);) if (block_size < 6) { mse = 0.0f; } else { + mse = fabsf(freq - freq_gold); + } - free(x);) + free(x);) -TEST(srslte_cfo_correct, srslte_cfo_t srslte_cfo; bzero(&srslte_cfo, sizeof(srslte_cfo)); MALLOC(cf_t, x); - MALLOC(cf_t, z); +TEST( + srsran_cfo_correct, srsran_cfo_t srsran_cfo; bzero(&srsran_cfo, sizeof(srsran_cfo)); MALLOC(cf_t, x); + MALLOC(cf_t, z); - const float cfo = 0.1f; - cf_t gold; - for (int i = 0; i < block_size; i++) { x[i] = RANDOM_CF(); } + const float cfo = 0.1f; + cf_t gold; + for (int i = 0; i < block_size; i++) { x[i] = RANDOM_CF(); } - srslte_cfo_init(&srslte_cfo, block_size); + srsran_cfo_init(&srsran_cfo, block_size); - TEST_CALL(srslte_cfo_correct(&srslte_cfo, x, z, cfo)) + TEST_CALL(srsran_cfo_correct(&srsran_cfo, x, z, cfo)) - for (int i = 0; i < block_size; i++) { - gold = x[i] * cexpf(_Complex_I * 2.0f * (float)M_PI * i * cfo); - mse += cabsf(gold - z[i]) / cabsf(gold); - } mse /= block_size; + for (int i = 0; i < block_size; i++) { + gold = x[i] * cexpf(_Complex_I * 2.0f * (float)M_PI * i * cfo); + mse += cabsf(gold - z[i]) / cabsf(gold); + } mse /= block_size; - free(x); - free(z); - srslte_cfo_free(&srslte_cfo);) + free(x); + free(z); + srsran_cfo_free(&srsran_cfo);) -TEST(srslte_cfo_correct_change, srslte_cfo_t srslte_cfo; bzero(&srslte_cfo, sizeof(srslte_cfo)); MALLOC(cf_t, x); - MALLOC(cf_t, z); +TEST( + srsran_cfo_correct_change, srsran_cfo_t srsran_cfo; bzero(&srsran_cfo, sizeof(srsran_cfo)); MALLOC(cf_t, x); + MALLOC(cf_t, z); - float cfo = 0.1f; - cf_t gold; - for (int i = 0; i < block_size; i++) { x[i] = RANDOM_CF(); } + float cfo = 0.1f; + cf_t gold; + for (int i = 0; i < block_size; i++) { x[i] = RANDOM_CF(); } - srslte_cfo_init(&srslte_cfo, block_size); + srsran_cfo_init(&srsran_cfo, block_size); - TEST_CALL(cfo = (i % 2) ? 0.1 : -0.1; srslte_cfo_correct(&srslte_cfo, x, z, cfo)) + TEST_CALL(cfo = (i % 2) ? 0.1 : -0.1; srsran_cfo_correct(&srsran_cfo, x, z, cfo)) - for (int i = 0; i < block_size; i++) { - gold = x[i] * cexpf(_Complex_I * 2.0f * (float)M_PI * i * cfo); - mse += cabsf(gold - z[i]) / cabsf(gold); - } mse /= block_size; + for (int i = 0; i < block_size; i++) { + gold = x[i] * cexpf(_Complex_I * 2.0f * (float)M_PI * i * cfo); + mse += cabsf(gold - z[i]) / cabsf(gold); + } mse /= block_size; - free(x); - free(z); - srslte_cfo_free(&srslte_cfo);) + free(x); + free(z); + srsran_cfo_free(&srsran_cfo);) int main(int argc, char** argv) { @@ -786,7 +799,7 @@ int main(int argc, char** argv) uint32_t func_count = 0; bool passed[MAX_FUNCTIONS][MAX_BLOCKS]; bool all_passed = true; - random_h = srslte_random_init(0x1234); + random_h = srsran_random_init(0x1234); if (argc > 1) { nof_repetitions = (uint32_t)strtol(argv[1], NULL, 10); @@ -796,155 +809,155 @@ int main(int argc, char** argv) func_count = 0; passed[func_count][size_count] = - test_srslte_vec_xor_bbb(func_names[func_count], &timmings[func_count][size_count], block_size); + test_srsran_vec_xor_bbb(func_names[func_count], &timmings[func_count][size_count], block_size); func_count++; passed[func_count][size_count] = - test_srslte_vec_acc_ff(func_names[func_count], &timmings[func_count][size_count], block_size); + test_srsran_vec_acc_ff(func_names[func_count], &timmings[func_count][size_count], block_size); func_count++; passed[func_count][size_count] = - test_srslte_vec_dot_prod_sss(func_names[func_count], &timmings[func_count][size_count], block_size); + test_srsran_vec_dot_prod_sss(func_names[func_count], &timmings[func_count][size_count], block_size); func_count++; passed[func_count][size_count] = - test_srslte_vec_sum_sss(func_names[func_count], &timmings[func_count][size_count], block_size); + test_srsran_vec_sum_sss(func_names[func_count], &timmings[func_count][size_count], block_size); func_count++; passed[func_count][size_count] = - test_srslte_vec_sub_sss(func_names[func_count], &timmings[func_count][size_count], block_size); + test_srsran_vec_sub_sss(func_names[func_count], &timmings[func_count][size_count], block_size); func_count++; passed[func_count][size_count] = - test_srslte_vec_prod_sss(func_names[func_count], &timmings[func_count][size_count], block_size); + test_srsran_vec_prod_sss(func_names[func_count], &timmings[func_count][size_count], block_size); func_count++; passed[func_count][size_count] = - test_srslte_vec_neg_sss(func_names[func_count], &timmings[func_count][size_count], block_size); + test_srsran_vec_neg_sss(func_names[func_count], &timmings[func_count][size_count], block_size); func_count++; passed[func_count][size_count] = - test_srslte_vec_acc_cc(func_names[func_count], &timmings[func_count][size_count], block_size); + test_srsran_vec_acc_cc(func_names[func_count], &timmings[func_count][size_count], block_size); func_count++; passed[func_count][size_count] = - test_srslte_vec_sum_fff(func_names[func_count], &timmings[func_count][size_count], block_size); + test_srsran_vec_sum_fff(func_names[func_count], &timmings[func_count][size_count], block_size); func_count++; passed[func_count][size_count] = - test_srslte_vec_sub_fff(func_names[func_count], &timmings[func_count][size_count], block_size); + test_srsran_vec_sub_fff(func_names[func_count], &timmings[func_count][size_count], block_size); func_count++; passed[func_count][size_count] = - test_srslte_vec_dot_prod_ccc(func_names[func_count], &timmings[func_count][size_count], block_size); + test_srsran_vec_dot_prod_ccc(func_names[func_count], &timmings[func_count][size_count], block_size); func_count++; passed[func_count][size_count] = - test_srslte_vec_dot_prod_conj_ccc(func_names[func_count], &timmings[func_count][size_count], block_size); + test_srsran_vec_dot_prod_conj_ccc(func_names[func_count], &timmings[func_count][size_count], block_size); func_count++; passed[func_count][size_count] = - test_srslte_vec_convert_fi(func_names[func_count], &timmings[func_count][size_count], block_size); + test_srsran_vec_convert_fi(func_names[func_count], &timmings[func_count][size_count], block_size); func_count++; passed[func_count][size_count] = - test_srslte_vec_convert_conj_cs(func_names[func_count], &timmings[func_count][size_count], block_size); + test_srsran_vec_convert_conj_cs(func_names[func_count], &timmings[func_count][size_count], block_size); func_count++; passed[func_count][size_count] = - test_srslte_vec_convert_if(func_names[func_count], &timmings[func_count][size_count], block_size); + test_srsran_vec_convert_if(func_names[func_count], &timmings[func_count][size_count], block_size); func_count++; passed[func_count][size_count] = - test_srslte_vec_prod_fff(func_names[func_count], &timmings[func_count][size_count], block_size); + test_srsran_vec_prod_fff(func_names[func_count], &timmings[func_count][size_count], block_size); func_count++; passed[func_count][size_count] = - test_srslte_vec_prod_cfc(func_names[func_count], &timmings[func_count][size_count], block_size); + test_srsran_vec_prod_cfc(func_names[func_count], &timmings[func_count][size_count], block_size); func_count++; passed[func_count][size_count] = - test_srslte_vec_prod_ccc(func_names[func_count], &timmings[func_count][size_count], block_size); + test_srsran_vec_prod_ccc(func_names[func_count], &timmings[func_count][size_count], block_size); func_count++; passed[func_count][size_count] = - test_srslte_vec_prod_ccc_split(func_names[func_count], &timmings[func_count][size_count], block_size); + test_srsran_vec_prod_ccc_split(func_names[func_count], &timmings[func_count][size_count], block_size); func_count++; passed[func_count][size_count] = - test_srslte_vec_prod_conj_ccc(func_names[func_count], &timmings[func_count][size_count], block_size); + test_srsran_vec_prod_conj_ccc(func_names[func_count], &timmings[func_count][size_count], block_size); func_count++; passed[func_count][size_count] = - test_srslte_vec_sc_prod_ccc(func_names[func_count], &timmings[func_count][size_count], block_size); + test_srsran_vec_sc_prod_ccc(func_names[func_count], &timmings[func_count][size_count], block_size); func_count++; passed[func_count][size_count] = - test_srslte_vec_sc_prod_fff(func_names[func_count], &timmings[func_count][size_count], block_size); + test_srsran_vec_sc_prod_fff(func_names[func_count], &timmings[func_count][size_count], block_size); func_count++; passed[func_count][size_count] = - test_srslte_vec_abs_cf(func_names[func_count], &timmings[func_count][size_count], block_size); + test_srsran_vec_abs_cf(func_names[func_count], &timmings[func_count][size_count], block_size); func_count++; passed[func_count][size_count] = - test_srslte_vec_abs_square_cf(func_names[func_count], &timmings[func_count][size_count], block_size); + test_srsran_vec_abs_square_cf(func_names[func_count], &timmings[func_count][size_count], block_size); func_count++; passed[func_count][size_count] = - test_srslte_vec_sc_prod_cfc(func_names[func_count], &timmings[func_count][size_count], block_size); + test_srsran_vec_sc_prod_cfc(func_names[func_count], &timmings[func_count][size_count], block_size); func_count++; passed[func_count][size_count] = - test_srslte_vec_sc_prod_fcc(func_names[func_count], &timmings[func_count][size_count], block_size); + test_srsran_vec_sc_prod_fcc(func_names[func_count], &timmings[func_count][size_count], block_size); func_count++; passed[func_count][size_count] = - test_srslte_vec_div_ccc(func_names[func_count], &timmings[func_count][size_count], block_size); + test_srsran_vec_div_ccc(func_names[func_count], &timmings[func_count][size_count], block_size); func_count++; passed[func_count][size_count] = - test_srslte_vec_div_cfc(func_names[func_count], &timmings[func_count][size_count], block_size); + test_srsran_vec_div_cfc(func_names[func_count], &timmings[func_count][size_count], block_size); func_count++; passed[func_count][size_count] = - test_srslte_vec_div_fff(func_names[func_count], &timmings[func_count][size_count], block_size); + test_srsran_vec_div_fff(func_names[func_count], &timmings[func_count][size_count], block_size); func_count++; passed[func_count][size_count] = - test_srslte_vec_conj_cc(func_names[func_count], &timmings[func_count][size_count], block_size); + test_srsran_vec_conj_cc(func_names[func_count], &timmings[func_count][size_count], block_size); func_count++; passed[func_count][size_count] = - test_srslte_vec_max_fi(func_names[func_count], &timmings[func_count][size_count], block_size); + test_srsran_vec_max_fi(func_names[func_count], &timmings[func_count][size_count], block_size); func_count++; passed[func_count][size_count] = - test_srslte_vec_max_abs_fi(func_names[func_count], &timmings[func_count][size_count], block_size); + test_srsran_vec_max_abs_fi(func_names[func_count], &timmings[func_count][size_count], block_size); func_count++; passed[func_count][size_count] = - test_srslte_vec_max_abs_ci(func_names[func_count], &timmings[func_count][size_count], block_size); + test_srsran_vec_max_abs_ci(func_names[func_count], &timmings[func_count][size_count], block_size); func_count++; passed[func_count][size_count] = - test_srslte_vec_apply_cfo(func_names[func_count], &timmings[func_count][size_count], block_size); + test_srsran_vec_apply_cfo(func_names[func_count], &timmings[func_count][size_count], block_size); func_count++; passed[func_count][size_count] = - test_srslte_vec_gen_sine(func_names[func_count], &timmings[func_count][size_count], block_size); + test_srsran_vec_gen_sine(func_names[func_count], &timmings[func_count][size_count], block_size); func_count++; passed[func_count][size_count] = - test_srslte_vec_estimate_frequency(func_names[func_count], &timmings[func_count][size_count], block_size); + test_srsran_vec_estimate_frequency(func_names[func_count], &timmings[func_count][size_count], block_size); func_count++; passed[func_count][size_count] = - test_srslte_cfo_correct(func_names[func_count], &timmings[func_count][size_count], block_size); + test_srsran_cfo_correct(func_names[func_count], &timmings[func_count][size_count], block_size); func_count++; passed[func_count][size_count] = - test_srslte_cfo_correct_change(func_names[func_count], &timmings[func_count][size_count], block_size); + test_srsran_cfo_correct_change(func_names[func_count], &timmings[func_count][size_count], block_size); func_count++; sizes[size_count] = block_size; @@ -1007,7 +1020,7 @@ int main(int argc, char** argv) if (f) fclose(f); - srslte_random_free(random_h); + srsran_random_free(random_h); - return (all_passed) ? SRSLTE_SUCCESS : SRSLTE_ERROR; + return (all_passed) ? SRSRAN_SUCCESS : SRSRAN_ERROR; } diff --git a/lib/src/phy/utils/vector.c b/lib/src/phy/utils/vector.c index aedb36d5b..8128ed537 100644 --- a/lib/src/phy/utils/vector.c +++ b/lib/src/phy/utils/vector.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -16,248 +16,248 @@ #include #include -#include "srslte/phy/utils/bit.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/simd.h" -#include "srslte/phy/utils/vector.h" -#include "srslte/phy/utils/vector_simd.h" +#include "srsran/phy/utils/bit.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/simd.h" +#include "srsran/phy/utils/vector.h" +#include "srsran/phy/utils/vector_simd.h" -void srslte_vec_xor_bbb(const uint8_t* x, const uint8_t* y, uint8_t* z, const uint32_t len) +void srsran_vec_xor_bbb(const uint8_t* x, const uint8_t* y, uint8_t* z, const uint32_t len) { - srslte_vec_xor_bbb_simd(x, y, z, len); + srsran_vec_xor_bbb_simd(x, y, z, len); } // Used in PRACH detector, AGC and chest_dl for noise averaging -float srslte_vec_acc_ff(const float* x, const uint32_t len) +float srsran_vec_acc_ff(const float* x, const uint32_t len) { - return srslte_vec_acc_ff_simd(x, len); + return srsran_vec_acc_ff_simd(x, len); } -cf_t srslte_vec_acc_cc(const cf_t* x, const uint32_t len) +cf_t srsran_vec_acc_cc(const cf_t* x, const uint32_t len) { - return srslte_vec_acc_cc_simd(x, len); + return srsran_vec_acc_cc_simd(x, len); } -void srslte_vec_sub_fff(const float* x, const float* y, float* z, const uint32_t len) +void srsran_vec_sub_fff(const float* x, const float* y, float* z, const uint32_t len) { - srslte_vec_sub_fff_simd(x, y, z, len); + srsran_vec_sub_fff_simd(x, y, z, len); } -void srslte_vec_sub_sss(const int16_t* x, const int16_t* y, int16_t* z, const uint32_t len) +void srsran_vec_sub_sss(const int16_t* x, const int16_t* y, int16_t* z, const uint32_t len) { - srslte_vec_sub_sss_simd(x, y, z, len); + srsran_vec_sub_sss_simd(x, y, z, len); } -void srslte_vec_sub_bbb(const int8_t* x, const int8_t* y, int8_t* z, const uint32_t len) +void srsran_vec_sub_bbb(const int8_t* x, const int8_t* y, int8_t* z, const uint32_t len) { - srslte_vec_sub_bbb_simd(x, y, z, len); + srsran_vec_sub_bbb_simd(x, y, z, len); } // Noise estimation in chest_dl, interpolation -void srslte_vec_sub_ccc(const cf_t* x, const cf_t* y, cf_t* z, const uint32_t len) +void srsran_vec_sub_ccc(const cf_t* x, const cf_t* y, cf_t* z, const uint32_t len) { - return srslte_vec_sub_fff((const float*)x, (const float*)y, (float*)z, 2 * len); + return srsran_vec_sub_fff((const float*)x, (const float*)y, (float*)z, 2 * len); } // Used in PSS/SSS and sum_ccc -void srslte_vec_sum_fff(const float* x, const float* y, float* z, const uint32_t len) +void srsran_vec_sum_fff(const float* x, const float* y, float* z, const uint32_t len) { - srslte_vec_add_fff_simd(x, y, z, len); + srsran_vec_add_fff_simd(x, y, z, len); } -void srslte_vec_sum_sss(const int16_t* x, const int16_t* y, int16_t* z, const uint32_t len) +void srsran_vec_sum_sss(const int16_t* x, const int16_t* y, int16_t* z, const uint32_t len) { - srslte_vec_sum_sss_simd(x, y, z, len); + srsran_vec_sum_sss_simd(x, y, z, len); } -void srslte_vec_sum_ccc(const cf_t* x, const cf_t* y, cf_t* z, const uint32_t len) +void srsran_vec_sum_ccc(const cf_t* x, const cf_t* y, cf_t* z, const uint32_t len) { - srslte_vec_sum_fff((float*)x, (float*)y, (float*)z, 2 * len); + srsran_vec_sum_fff((float*)x, (float*)y, (float*)z, 2 * len); } // PSS, PBCH, DEMOD, FFTW, etc. -void srslte_vec_sc_prod_fff(const float* x, const float h, float* z, const uint32_t len) +void srsran_vec_sc_prod_fff(const float* x, const float h, float* z, const uint32_t len) { - srslte_vec_sc_prod_fff_simd(x, h, z, len); + srsran_vec_sc_prod_fff_simd(x, h, z, len); } // Used throughout -void srslte_vec_sc_prod_cfc(const cf_t* x, const float h, cf_t* z, const uint32_t len) +void srsran_vec_sc_prod_cfc(const cf_t* x, const float h, cf_t* z, const uint32_t len) { - srslte_vec_sc_prod_cfc_simd(x, h, z, len); + srsran_vec_sc_prod_cfc_simd(x, h, z, len); } -void srslte_vec_sc_prod_fcc(const float* x, const cf_t h, cf_t* z, const uint32_t len) +void srsran_vec_sc_prod_fcc(const float* x, const cf_t h, cf_t* z, const uint32_t len) { - srslte_vec_sc_prod_fcc_simd(x, h, z, len); + srsran_vec_sc_prod_fcc_simd(x, h, z, len); } // Chest UL -void srslte_vec_sc_prod_ccc(const cf_t* x, const cf_t h, cf_t* z, const uint32_t len) +void srsran_vec_sc_prod_ccc(const cf_t* x, const cf_t h, cf_t* z, const uint32_t len) { - srslte_vec_sc_prod_ccc_simd(x, h, z, len); + srsran_vec_sc_prod_ccc_simd(x, h, z, len); } // Used in turbo decoder -void srslte_vec_convert_if(const int16_t* x, const float scale, float* z, const uint32_t len) +void srsran_vec_convert_if(const int16_t* x, const float scale, float* z, const uint32_t len) { - srslte_vec_convert_if_simd(x, z, scale, len); + srsran_vec_convert_if_simd(x, z, scale, len); } -void srslte_vec_convert_fi(const float* x, const float scale, int16_t* z, const uint32_t len) +void srsran_vec_convert_fi(const float* x, const float scale, int16_t* z, const uint32_t len) { - srslte_vec_convert_fi_simd(x, z, scale, len); + srsran_vec_convert_fi_simd(x, z, scale, len); } -void srslte_vec_convert_conj_cs(const cf_t* x, const float scale, int16_t* z, const uint32_t len) +void srsran_vec_convert_conj_cs(const cf_t* x, const float scale, int16_t* z, const uint32_t len) { - srslte_vec_convert_conj_cs_simd(x, z, scale, len); + srsran_vec_convert_conj_cs_simd(x, z, scale, len); } -void srslte_vec_convert_fb(const float* x, const float scale, int8_t* z, const uint32_t len) +void srsran_vec_convert_fb(const float* x, const float scale, int8_t* z, const uint32_t len) { - srslte_vec_convert_fb_simd(x, z, scale, len); + srsran_vec_convert_fb_simd(x, z, scale, len); } -void srslte_vec_lut_sss(const short* x, const unsigned short* lut, short* y, const uint32_t len) +void srsran_vec_lut_sss(const short* x, const unsigned short* lut, short* y, const uint32_t len) { - srslte_vec_lut_sss_simd(x, lut, y, len); + srsran_vec_lut_sss_simd(x, lut, y, len); } -void srslte_vec_lut_bbb(const int8_t* x, const unsigned short* lut, int8_t* y, const uint32_t len) +void srsran_vec_lut_bbb(const int8_t* x, const unsigned short* lut, int8_t* y, const uint32_t len) { - srslte_vec_lut_bbb_simd(x, lut, y, len); + srsran_vec_lut_bbb_simd(x, lut, y, len); } -void srslte_vec_lut_sis(const short* x, const unsigned int* lut, short* y, const uint32_t len) +void srsran_vec_lut_sis(const short* x, const unsigned int* lut, short* y, const uint32_t len) { for (int i = 0; i < len; i++) { y[lut[i]] = x[i]; } } -void* srslte_vec_malloc(uint32_t size) +void* srsran_vec_malloc(uint32_t size) { void* ptr; - if (posix_memalign(&ptr, SRSLTE_SIMD_BIT_ALIGN, size)) { + if (posix_memalign(&ptr, SRSRAN_SIMD_BIT_ALIGN, size)) { return NULL; } else { return ptr; } } -cf_t* srslte_vec_cf_malloc(uint32_t nsamples) +cf_t* srsran_vec_cf_malloc(uint32_t nsamples) { - return SRSLTE_MEM_ALLOC(cf_t, nsamples); + return SRSRAN_MEM_ALLOC(cf_t, nsamples); } -float* srslte_vec_f_malloc(uint32_t nsamples) +float* srsran_vec_f_malloc(uint32_t nsamples) { - return SRSLTE_MEM_ALLOC(float, nsamples); + return SRSRAN_MEM_ALLOC(float, nsamples); } -int32_t* srslte_vec_i32_malloc(uint32_t nsamples) +int32_t* srsran_vec_i32_malloc(uint32_t nsamples) { - return SRSLTE_MEM_ALLOC(int32_t, nsamples); + return SRSRAN_MEM_ALLOC(int32_t, nsamples); } -uint32_t* srslte_vec_u32_malloc(uint32_t nsamples) +uint32_t* srsran_vec_u32_malloc(uint32_t nsamples) { - return SRSLTE_MEM_ALLOC(uint32_t, nsamples); + return SRSRAN_MEM_ALLOC(uint32_t, nsamples); } -int16_t* srslte_vec_i16_malloc(uint32_t nsamples) +int16_t* srsran_vec_i16_malloc(uint32_t nsamples) { - return SRSLTE_MEM_ALLOC(int16_t, nsamples); + return SRSRAN_MEM_ALLOC(int16_t, nsamples); } -uint16_t* srslte_vec_u16_malloc(uint32_t nsamples) +uint16_t* srsran_vec_u16_malloc(uint32_t nsamples) { - return SRSLTE_MEM_ALLOC(uint16_t, nsamples); + return SRSRAN_MEM_ALLOC(uint16_t, nsamples); } -int8_t* srslte_vec_i8_malloc(uint32_t nsamples) +int8_t* srsran_vec_i8_malloc(uint32_t nsamples) { - return SRSLTE_MEM_ALLOC(int8_t, nsamples); + return SRSRAN_MEM_ALLOC(int8_t, nsamples); } -uint8_t* srslte_vec_u8_malloc(uint32_t nsamples) +uint8_t* srsran_vec_u8_malloc(uint32_t nsamples) { - return SRSLTE_MEM_ALLOC(uint8_t, nsamples); + return SRSRAN_MEM_ALLOC(uint8_t, nsamples); } -void srslte_vec_zero(void* ptr, uint32_t nbytes) +void srsran_vec_zero(void* ptr, uint32_t nbytes) { memset(ptr, 0, nbytes); } -void srslte_vec_u8_zero(uint8_t* ptr, uint32_t nsamples) +void srsran_vec_u8_zero(uint8_t* ptr, uint32_t nsamples) { - SRSLTE_MEM_ZERO(ptr, uint8_t, nsamples); + SRSRAN_MEM_ZERO(ptr, uint8_t, nsamples); } -void srslte_vec_i8_zero(int8_t* ptr, uint32_t nsamples) +void srsran_vec_i8_zero(int8_t* ptr, uint32_t nsamples) { - SRSLTE_MEM_ZERO(ptr, int8_t, nsamples); + SRSRAN_MEM_ZERO(ptr, int8_t, nsamples); } -void srslte_vec_i16_zero(int16_t* ptr, uint32_t nsamples) +void srsran_vec_i16_zero(int16_t* ptr, uint32_t nsamples) { - SRSLTE_MEM_ZERO(ptr, int16_t, nsamples); + SRSRAN_MEM_ZERO(ptr, int16_t, nsamples); } -void srslte_vec_u32_zero(uint32_t* ptr, uint32_t nsamples) +void srsran_vec_u32_zero(uint32_t* ptr, uint32_t nsamples) { - SRSLTE_MEM_ZERO(ptr, uint32_t, nsamples); + SRSRAN_MEM_ZERO(ptr, uint32_t, nsamples); } -void srslte_vec_cf_zero(cf_t* ptr, uint32_t nsamples) +void srsran_vec_cf_zero(cf_t* ptr, uint32_t nsamples) { - SRSLTE_MEM_ZERO(ptr, cf_t, nsamples); + SRSRAN_MEM_ZERO(ptr, cf_t, nsamples); } -void srslte_vec_f_zero(float* ptr, uint32_t nsamples) +void srsran_vec_f_zero(float* ptr, uint32_t nsamples) { - SRSLTE_MEM_ZERO(ptr, float, nsamples); + SRSRAN_MEM_ZERO(ptr, float, nsamples); } -void srslte_vec_cf_copy(cf_t* dst, const cf_t* src, uint32_t len) +void srsran_vec_cf_copy(cf_t* dst, const cf_t* src, uint32_t len) { memcpy(dst, src, sizeof(cf_t) * len); } -void srslte_vec_f_copy(float* dst, const float* src, uint32_t len) +void srsran_vec_f_copy(float* dst, const float* src, uint32_t len) { memcpy(dst, src, sizeof(float) * len); } -void srslte_vec_u8_copy(uint8_t* dst, const uint8_t* src, uint32_t len) +void srsran_vec_u8_copy(uint8_t* dst, const uint8_t* src, uint32_t len) { memcpy(dst, src, sizeof(uint8_t) * len); } -void srslte_vec_i8_copy(int8_t* dst, const int8_t* src, uint32_t len) +void srsran_vec_i8_copy(int8_t* dst, const int8_t* src, uint32_t len) { memcpy(dst, src, sizeof(int8_t) * len); } -void srslte_vec_i16_copy(int16_t* dst, const int16_t* src, uint32_t len) +void srsran_vec_i16_copy(int16_t* dst, const int16_t* src, uint32_t len) { memcpy(dst, src, sizeof(int16_t) * len); } -void srslte_vec_u16_copy(uint16_t* dst, const uint16_t* src, uint32_t len) +void srsran_vec_u16_copy(uint16_t* dst, const uint16_t* src, uint32_t len) { memcpy(dst, src, sizeof(uint16_t) * len); } -void* srslte_vec_realloc(void* ptr, uint32_t old_size, uint32_t new_size) +void* srsran_vec_realloc(void* ptr, uint32_t old_size, uint32_t new_size) { #ifndef LV_HAVE_SSE return realloc(ptr, new_size); #else void* new_ptr; - if (posix_memalign(&new_ptr, SRSLTE_SIMD_BIT_ALIGN, new_size)) { + if (posix_memalign(&new_ptr, SRSRAN_SIMD_BIT_ALIGN, new_size)) { return NULL; } else { memcpy(new_ptr, ptr, old_size); @@ -267,7 +267,7 @@ void* srslte_vec_realloc(void* ptr, uint32_t old_size, uint32_t new_size) #endif } -void srslte_vec_fprint_c(FILE* stream, const cf_t* x, const uint32_t len) +void srsran_vec_fprint_c(FILE* stream, const cf_t* x, const uint32_t len) { int i; fprintf(stream, "["); @@ -277,7 +277,7 @@ void srslte_vec_fprint_c(FILE* stream, const cf_t* x, const uint32_t len) fprintf(stream, "];\n"); } -void srslte_vec_fprint_f(FILE* stream, const float* x, const uint32_t len) +void srsran_vec_fprint_f(FILE* stream, const float* x, const uint32_t len) { int i; fprintf(stream, "["); @@ -287,7 +287,7 @@ void srslte_vec_fprint_f(FILE* stream, const float* x, const uint32_t len) fprintf(stream, "];\n"); } -void srslte_vec_fprint_b(FILE* stream, const uint8_t* x, const uint32_t len) +void srsran_vec_fprint_b(FILE* stream, const uint8_t* x, const uint32_t len) { int i; fprintf(stream, "["); @@ -297,7 +297,7 @@ void srslte_vec_fprint_b(FILE* stream, const uint8_t* x, const uint32_t len) fprintf(stream, "];\n"); } -void srslte_vec_fprint_bs(FILE* stream, const int8_t* x, const uint32_t len) +void srsran_vec_fprint_bs(FILE* stream, const int8_t* x, const uint32_t len) { int i; fprintf(stream, "["); @@ -307,7 +307,7 @@ void srslte_vec_fprint_bs(FILE* stream, const int8_t* x, const uint32_t len) fprintf(stream, "];\n"); } -void srslte_vec_fprint_byte(FILE* stream, const uint8_t* x, const uint32_t len) +void srsran_vec_fprint_byte(FILE* stream, const uint8_t* x, const uint32_t len) { int i; fprintf(stream, "["); @@ -317,7 +317,7 @@ void srslte_vec_fprint_byte(FILE* stream, const uint8_t* x, const uint32_t len) fprintf(stream, "];\n"); } -void srslte_vec_fprint_i(FILE* stream, const int* x, const uint32_t len) +void srsran_vec_fprint_i(FILE* stream, const int* x, const uint32_t len) { int i; fprintf(stream, "["); @@ -327,7 +327,7 @@ void srslte_vec_fprint_i(FILE* stream, const int* x, const uint32_t len) fprintf(stream, "];\n"); } -void srslte_vec_fprint_s(FILE* stream, const int16_t* x, const uint32_t len) +void srsran_vec_fprint_s(FILE* stream, const int16_t* x, const uint32_t len) { int i; fprintf(stream, "["); @@ -337,24 +337,24 @@ void srslte_vec_fprint_s(FILE* stream, const int16_t* x, const uint32_t len) fprintf(stream, "];\n"); } -void srslte_vec_fprint_hex(FILE* stream, uint8_t* x, const uint32_t len) +void srsran_vec_fprint_hex(FILE* stream, uint8_t* x, const uint32_t len) { uint32_t i, nbytes; uint8_t byte; nbytes = len / 8; fprintf(stream, "["); for (i = 0; i < nbytes; i++) { - byte = (uint8_t)srslte_bit_pack(&x, 8); + byte = (uint8_t)srsran_bit_pack(&x, 8); fprintf(stream, "%02x ", byte); } if (len % 8) { - byte = (uint8_t)srslte_bit_pack(&x, len % 8) << (8 - (len % 8)); + byte = (uint8_t)srsran_bit_pack(&x, len % 8) << (8 - (len % 8)); fprintf(stream, "%02x ", byte); } fprintf(stream, "];\n"); } -void srslte_vec_sprint_hex(char* str, const uint32_t max_str_len, uint8_t* x, const uint32_t len) +void srsran_vec_sprint_hex(char* str, const uint32_t max_str_len, uint8_t* x, const uint32_t len) { uint32_t i, nbytes; uint8_t byte; @@ -368,21 +368,21 @@ void srslte_vec_sprint_hex(char* str, const uint32_t max_str_len, uint8_t* x, co int n = 0; n += sprintf(&str[n], "["); for (i = 0; i < nbytes; i++) { - byte = (uint8_t)srslte_bit_pack(&x, 8); + byte = (uint8_t)srsran_bit_pack(&x, 8); n += sprintf(&str[n], "%02x ", byte); } if (len % 8) { - byte = (uint8_t)srslte_bit_pack(&x, len % 8) << (8 - (len % 8)); + byte = (uint8_t)srsran_bit_pack(&x, len % 8) << (8 - (len % 8)); n += sprintf(&str[n], "%02x ", byte); } n += sprintf(&str[n], "]"); str[max_str_len - 1] = 0; } -void srslte_vec_sprint_bin(char* str, const uint32_t max_str_len, const uint8_t* x, const uint32_t len) +void srsran_vec_sprint_bin(char* str, const uint32_t max_str_len, const uint8_t* x, const uint32_t len) { // Trim maximum size - uint32_t N = SRSLTE_MIN(max_str_len - 1, len); + uint32_t N = SRSRAN_MIN(max_str_len - 1, len); // If the number of bits does not fit in the string, leave space for "..." if possible if (N < len) { @@ -409,7 +409,7 @@ void srslte_vec_sprint_bin(char* str, const uint32_t max_str_len, const uint8_t* } } -void srslte_vec_save_file(char* filename, const void* buffer, const uint32_t len) +void srsran_vec_save_file(char* filename, const void* buffer, const uint32_t len) { FILE* f; f = fopen(filename, "w"); @@ -421,7 +421,7 @@ void srslte_vec_save_file(char* filename, const void* buffer, const uint32_t len } } -void srslte_vec_load_file(char* filename, void* buffer, const uint32_t len) +void srsran_vec_load_file(char* filename, void* buffer, const uint32_t len) { FILE* f; f = fopen(filename, "r"); @@ -434,7 +434,7 @@ void srslte_vec_load_file(char* filename, void* buffer, const uint32_t len) } // Used in PSS -void srslte_vec_conj_cc(const cf_t* x, cf_t* y, const uint32_t len) +void srsran_vec_conj_cc(const cf_t* x, cf_t* y, const uint32_t len) { /* This function is used in initialisation only, then no optimisation is required */ int i; @@ -444,39 +444,39 @@ void srslte_vec_conj_cc(const cf_t* x, cf_t* y, const uint32_t len) } // Used in scrambling complex -void srslte_vec_prod_cfc(const cf_t* x, const float* y, cf_t* z, const uint32_t len) +void srsran_vec_prod_cfc(const cf_t* x, const float* y, cf_t* z, const uint32_t len) { - srslte_vec_prod_cfc_simd(x, y, z, len); + srsran_vec_prod_cfc_simd(x, y, z, len); } // Used in scrambling float -void srslte_vec_prod_fff(const float* x, const float* y, float* z, const uint32_t len) +void srsran_vec_prod_fff(const float* x, const float* y, float* z, const uint32_t len) { - srslte_vec_prod_fff_simd(x, y, z, len); + srsran_vec_prod_fff_simd(x, y, z, len); } -void srslte_vec_prod_sss(const int16_t* x, const int16_t* y, int16_t* z, const uint32_t len) +void srsran_vec_prod_sss(const int16_t* x, const int16_t* y, int16_t* z, const uint32_t len) { - srslte_vec_prod_sss_simd(x, y, z, len); + srsran_vec_prod_sss_simd(x, y, z, len); } // Scrambling -void srslte_vec_neg_sss(const int16_t* x, const int16_t* y, int16_t* z, const uint32_t len) +void srsran_vec_neg_sss(const int16_t* x, const int16_t* y, int16_t* z, const uint32_t len) { - srslte_vec_neg_sss_simd(x, y, z, len); + srsran_vec_neg_sss_simd(x, y, z, len); } -void srslte_vec_neg_bbb(const int8_t* x, const int8_t* y, int8_t* z, const uint32_t len) +void srsran_vec_neg_bbb(const int8_t* x, const int8_t* y, int8_t* z, const uint32_t len) { - srslte_vec_neg_bbb_simd(x, y, z, len); + srsran_vec_neg_bbb_simd(x, y, z, len); } // CFO and OFDM processing -void srslte_vec_prod_ccc(const cf_t* x, const cf_t* y, cf_t* z, const uint32_t len) +void srsran_vec_prod_ccc(const cf_t* x, const cf_t* y, cf_t* z, const uint32_t len) { - srslte_vec_prod_ccc_simd(x, y, z, len); + srsran_vec_prod_ccc_simd(x, y, z, len); } -void srslte_vec_prod_ccc_split(const float* x_re, +void srsran_vec_prod_ccc_split(const float* x_re, const float* x_im, const float* y_re, const float* y_im, @@ -484,42 +484,42 @@ void srslte_vec_prod_ccc_split(const float* x_re, float* z_im, const uint32_t len) { - srslte_vec_prod_ccc_split_simd(x_re, x_im, y_re, y_im, z_re, z_im, len); + srsran_vec_prod_ccc_split_simd(x_re, x_im, y_re, y_im, z_re, z_im, len); } // PRACH, CHEST UL, etc. -void srslte_vec_prod_conj_ccc(const cf_t* x, const cf_t* y, cf_t* z, const uint32_t len) +void srsran_vec_prod_conj_ccc(const cf_t* x, const cf_t* y, cf_t* z, const uint32_t len) { - srslte_vec_prod_conj_ccc_simd(x, y, z, len); + srsran_vec_prod_conj_ccc_simd(x, y, z, len); } //#define DIV_USE_VEC // Used in SSS -void srslte_vec_div_ccc(const cf_t* x, const cf_t* y, cf_t* z, const uint32_t len) +void srsran_vec_div_ccc(const cf_t* x, const cf_t* y, cf_t* z, const uint32_t len) { - srslte_vec_div_ccc_simd(x, y, z, len); + srsran_vec_div_ccc_simd(x, y, z, len); } /* Complex division by float z=x/y */ -void srslte_vec_div_cfc(const cf_t* x, const float* y, cf_t* z, const uint32_t len) +void srsran_vec_div_cfc(const cf_t* x, const float* y, cf_t* z, const uint32_t len) { - srslte_vec_div_cfc_simd(x, y, z, len); + srsran_vec_div_cfc_simd(x, y, z, len); } -void srslte_vec_div_fff(const float* x, const float* y, float* z, const uint32_t len) +void srsran_vec_div_fff(const float* x, const float* y, float* z, const uint32_t len) { - srslte_vec_div_fff_simd(x, y, z, len); + srsran_vec_div_fff_simd(x, y, z, len); } // PSS. convolution -cf_t srslte_vec_dot_prod_ccc(const cf_t* x, const cf_t* y, const uint32_t len) +cf_t srsran_vec_dot_prod_ccc(const cf_t* x, const cf_t* y, const uint32_t len) { - return srslte_vec_dot_prod_ccc_simd(x, y, len); + return srsran_vec_dot_prod_ccc_simd(x, y, len); } // Convolution filter and in SSS search -cf_t srslte_vec_dot_prod_cfc(const cf_t* x, const float* y, const uint32_t len) +cf_t srsran_vec_dot_prod_cfc(const cf_t* x, const float* y, const uint32_t len) { uint32_t i; cf_t res = 0; @@ -530,13 +530,13 @@ cf_t srslte_vec_dot_prod_cfc(const cf_t* x, const float* y, const uint32_t len) } // SYNC -cf_t srslte_vec_dot_prod_conj_ccc(const cf_t* x, const cf_t* y, const uint32_t len) +cf_t srsran_vec_dot_prod_conj_ccc(const cf_t* x, const cf_t* y, const uint32_t len) { - return srslte_vec_dot_prod_conj_ccc_simd(x, y, len); + return srsran_vec_dot_prod_conj_ccc_simd(x, y, len); } // PHICH -float srslte_vec_dot_prod_fff(const float* x, const float* y, const uint32_t len) +float srsran_vec_dot_prod_fff(const float* x, const float* y, const uint32_t len) { uint32_t i; float res = 0; @@ -546,17 +546,17 @@ float srslte_vec_dot_prod_fff(const float* x, const float* y, const uint32_t len return res; } -int32_t srslte_vec_dot_prod_sss(const int16_t* x, const int16_t* y, const uint32_t len) +int32_t srsran_vec_dot_prod_sss(const int16_t* x, const int16_t* y, const uint32_t len) { - return srslte_vec_dot_prod_sss_simd(x, y, len); + return srsran_vec_dot_prod_sss_simd(x, y, len); } -float srslte_vec_avg_power_cf(const cf_t* x, const uint32_t len) +float srsran_vec_avg_power_cf(const cf_t* x, const uint32_t len) { - return crealf(srslte_vec_dot_prod_conj_ccc(x, x, len)) / len; + return crealf(srsran_vec_dot_prod_conj_ccc(x, x, len)) / len; } -float srslte_vec_avg_power_sf(const int16_t* x, const uint32_t len) +float srsran_vec_avg_power_sf(const int16_t* x, const uint32_t len) { // Accumulator float acc = 0.0f; @@ -578,7 +578,7 @@ float srslte_vec_avg_power_sf(const int16_t* x, const uint32_t len) return acc; } -float srslte_vec_avg_power_bf(const int8_t* x, const uint32_t len) +float srsran_vec_avg_power_bf(const int8_t* x, const uint32_t len) { // Accumulator float acc = 0.0f; @@ -601,32 +601,32 @@ float srslte_vec_avg_power_bf(const int8_t* x, const uint32_t len) } // Correlation assumes zero-mean x and y -float srslte_vec_corr_ccc(const cf_t* x, cf_t* y, const uint32_t len) +float srsran_vec_corr_ccc(const cf_t* x, cf_t* y, const uint32_t len) { - // return crealf(srslte_vec_dot_prod_conj_ccc(x,y,len)) / len; - float s_x = crealf(srslte_vec_dot_prod_conj_ccc(x, x, len)) / len; - float s_y = crealf(srslte_vec_dot_prod_conj_ccc(y, y, len)) / len; - float cov = crealf(srslte_vec_dot_prod_conj_ccc(x, y, len)) / len; + // return crealf(srsran_vec_dot_prod_conj_ccc(x,y,len)) / len; + float s_x = crealf(srsran_vec_dot_prod_conj_ccc(x, x, len)) / len; + float s_y = crealf(srsran_vec_dot_prod_conj_ccc(y, y, len)) / len; + float cov = crealf(srsran_vec_dot_prod_conj_ccc(x, y, len)) / len; return cov / (sqrtf(s_x * s_y)); } // PSS (disabled and using abs_square ) -void srslte_vec_abs_cf(const cf_t* x, float* abs, const uint32_t len) +void srsran_vec_abs_cf(const cf_t* x, float* abs, const uint32_t len) { - srslte_vec_abs_cf_simd(x, abs, len); + srsran_vec_abs_cf_simd(x, abs, len); } -void srslte_vec_abs_dB_cf(const cf_t* x, float default_value, float* abs, const uint32_t len) +void srsran_vec_abs_dB_cf(const cf_t* x, float default_value, float* abs, const uint32_t len) { // Convert complex input to absplute value - srslte_vec_abs_cf(x, abs, len); + srsran_vec_abs_cf(x, abs, len); // Convert absolute value to dB for (int i = 0; i < len; i++) { // Check boundaries if (isnormal(abs[i])) { // Avoid infinites and zeros - abs[i] = srslte_convert_amplitude_to_dB(abs[i]); + abs[i] = srsran_convert_amplitude_to_dB(abs[i]); } else { // Set to default value instead abs[i] = default_value; @@ -634,7 +634,7 @@ void srslte_vec_abs_dB_cf(const cf_t* x, float default_value, float* abs, const } } -void srslte_vec_arg_deg_cf(const cf_t* x, float default_value, float* arg, const uint32_t len) +void srsran_vec_arg_deg_cf(const cf_t* x, float default_value, float* arg, const uint32_t len) { for (int i = 0; i < len; i++) { // Convert complex value to argument in degrees @@ -649,28 +649,28 @@ void srslte_vec_arg_deg_cf(const cf_t* x, float default_value, float* arg, const } // PRACH -void srslte_vec_abs_square_cf(const cf_t* x, float* abs_square, const uint32_t len) +void srsran_vec_abs_square_cf(const cf_t* x, float* abs_square, const uint32_t len) { - srslte_vec_abs_square_cf_simd(x, abs_square, len); + srsran_vec_abs_square_cf_simd(x, abs_square, len); } -uint32_t srslte_vec_max_fi(const float* x, const uint32_t len) +uint32_t srsran_vec_max_fi(const float* x, const uint32_t len) { - return srslte_vec_max_fi_simd(x, len); + return srsran_vec_max_fi_simd(x, len); } -uint32_t srslte_vec_max_abs_fi(const float* x, const uint32_t len) +uint32_t srsran_vec_max_abs_fi(const float* x, const uint32_t len) { - return srslte_vec_max_abs_fi_simd(x, len); + return srsran_vec_max_abs_fi_simd(x, len); } // CP autocorr -uint32_t srslte_vec_max_abs_ci(const cf_t* x, const uint32_t len) +uint32_t srsran_vec_max_abs_ci(const cf_t* x, const uint32_t len) { - return srslte_vec_max_ci_simd(x, len); + return srsran_vec_max_ci_simd(x, len); } -void srslte_vec_quant_fs(const float* in, +void srsran_vec_quant_fs(const float* in, int16_t* out, const float gain, const float offset, @@ -699,7 +699,7 @@ void srslte_vec_quant_fs(const float* in, } } -void srslte_vec_quant_fc(const float* in, +void srsran_vec_quant_fc(const float* in, int8_t* out, const float gain, const float offset, @@ -726,7 +726,7 @@ void srslte_vec_quant_fc(const float* in, } } -void srslte_vec_quant_fus(const float* in, +void srsran_vec_quant_fus(const float* in, uint16_t* out, const float gain, const float offset, @@ -735,13 +735,13 @@ void srslte_vec_quant_fus(const float* in, { for (uint32_t i = 0; i < len; i++) { int32_t tmp = (int32_t)(offset + gain * in[i]); - tmp = SRSLTE_MAX(tmp, 0); - tmp = SRSLTE_MIN(tmp, (int32_t)clip); + tmp = SRSRAN_MAX(tmp, 0); + tmp = SRSRAN_MIN(tmp, (int32_t)clip); out[i] = (uint16_t)tmp; } } -void srslte_vec_quant_fuc(const float* in, +void srsran_vec_quant_fuc(const float* in, uint8_t* out, const float gain, const float offset, @@ -750,13 +750,13 @@ void srslte_vec_quant_fuc(const float* in, { for (uint32_t i = 0; i < len; i++) { int32_t tmp = (int32_t)(offset + gain * in[i]); - tmp = SRSLTE_MAX(tmp, 0); - tmp = SRSLTE_MIN(tmp, (int32_t)clip); + tmp = SRSRAN_MAX(tmp, 0); + tmp = SRSRAN_MIN(tmp, (int32_t)clip); out[i] = (uint8_t)tmp; } } -void srslte_vec_quant_suc(const int16_t* in, +void srsran_vec_quant_suc(const int16_t* in, uint8_t* out, const float gain, const float offset, @@ -765,13 +765,13 @@ void srslte_vec_quant_suc(const int16_t* in, { for (uint32_t i = 0; i < len; i++) { int32_t tmp = (int32_t)(offset + (float)in[i] * gain); - tmp = SRSLTE_MAX(tmp, 0); - tmp = SRSLTE_MIN(tmp, (int32_t)clip); + tmp = SRSRAN_MAX(tmp, 0); + tmp = SRSRAN_MIN(tmp, (int32_t)clip); out[i] = (uint8_t)tmp; } } -void srslte_vec_quant_sus(const int16_t* in, +void srsran_vec_quant_sus(const int16_t* in, uint16_t* out, const float gain, const float offset, @@ -780,33 +780,33 @@ void srslte_vec_quant_sus(const int16_t* in, { for (uint32_t i = 0; i < len; i++) { int32_t tmp = (int32_t)(offset + gain * (float)in[i]); - tmp = SRSLTE_MAX(tmp, 0); - tmp = SRSLTE_MIN(tmp, (int32_t)clip); + tmp = SRSRAN_MAX(tmp, 0); + tmp = SRSRAN_MIN(tmp, (int32_t)clip); out[i] = (uint16_t)tmp; } } -void srslte_vec_interleave(const cf_t* x, const cf_t* y, cf_t* z, const int len) +void srsran_vec_interleave(const cf_t* x, const cf_t* y, cf_t* z, const int len) { - srslte_vec_interleave_simd(x, y, z, len); + srsran_vec_interleave_simd(x, y, z, len); } -void srslte_vec_interleave_add(const cf_t* x, const cf_t* y, cf_t* z, const int len) +void srsran_vec_interleave_add(const cf_t* x, const cf_t* y, cf_t* z, const int len) { - srslte_vec_interleave_add_simd(x, y, z, len); + srsran_vec_interleave_add_simd(x, y, z, len); } -void srslte_vec_gen_sine(cf_t amplitude, float freq, cf_t* z, int len) +void srsran_vec_gen_sine(cf_t amplitude, float freq, cf_t* z, int len) { - srslte_vec_gen_sine_simd(amplitude, freq, z, len); + srsran_vec_gen_sine_simd(amplitude, freq, z, len); } -void srslte_vec_apply_cfo(const cf_t* x, float cfo, cf_t* z, int len) +void srsran_vec_apply_cfo(const cf_t* x, float cfo, cf_t* z, int len) { - srslte_vec_apply_cfo_simd(x, cfo, z, len); + srsran_vec_apply_cfo_simd(x, cfo, z, len); } -float srslte_vec_estimate_frequency(const cf_t* x, int len) +float srsran_vec_estimate_frequency(const cf_t* x, int len) { - return srslte_vec_estimate_frequency_simd(x, len); + return srsran_vec_estimate_frequency_simd(x, len); } diff --git a/lib/src/phy/utils/vector_simd.c b/lib/src/phy/utils/vector_simd.c index 690e0299a..043c91908 100644 --- a/lib/src/phy/utils/vector_simd.c +++ b/lib/src/phy/utils/vector_simd.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -18,70 +18,70 @@ #include #include -#include "srslte/phy/utils/simd.h" -#include "srslte/phy/utils/vector_simd.h" +#include "srsran/phy/utils/simd.h" +#include "srsran/phy/utils/vector_simd.h" -void srslte_vec_xor_bbb_simd(const uint8_t* x, const uint8_t* y, uint8_t* z, const int len) +void srsran_vec_xor_bbb_simd(const uint8_t* x, const uint8_t* y, uint8_t* z, const int len) { int i = 0; -#if SRSLTE_SIMD_B_SIZE - if (SRSLTE_IS_ALIGNED(x) && SRSLTE_IS_ALIGNED(y) && SRSLTE_IS_ALIGNED(z)) { - for (; i < len - SRSLTE_SIMD_B_SIZE + 1; i += SRSLTE_SIMD_B_SIZE) { - simd_b_t a = srslte_simd_b_load((int8_t*)&x[i]); - simd_b_t b = srslte_simd_b_load((int8_t*)&y[i]); +#if SRSRAN_SIMD_B_SIZE + if (SRSRAN_IS_ALIGNED(x) && SRSRAN_IS_ALIGNED(y) && SRSRAN_IS_ALIGNED(z)) { + for (; i < len - SRSRAN_SIMD_B_SIZE + 1; i += SRSRAN_SIMD_B_SIZE) { + simd_b_t a = srsran_simd_b_load((int8_t*)&x[i]); + simd_b_t b = srsran_simd_b_load((int8_t*)&y[i]); - simd_b_t r = srslte_simd_b_xor(a, b); + simd_b_t r = srsran_simd_b_xor(a, b); - srslte_simd_b_store((int8_t*)&z[i], r); + srsran_simd_b_store((int8_t*)&z[i], r); } } else { - for (; i < len - SRSLTE_SIMD_B_SIZE + 1; i += SRSLTE_SIMD_B_SIZE) { - simd_b_t a = srslte_simd_b_loadu((int8_t*)&x[i]); - simd_b_t b = srslte_simd_b_loadu((int8_t*)&y[i]); + for (; i < len - SRSRAN_SIMD_B_SIZE + 1; i += SRSRAN_SIMD_B_SIZE) { + simd_b_t a = srsran_simd_b_loadu((int8_t*)&x[i]); + simd_b_t b = srsran_simd_b_loadu((int8_t*)&y[i]); - simd_b_t r = srslte_simd_b_xor(a, b); + simd_b_t r = srsran_simd_b_xor(a, b); - srslte_simd_b_storeu((int8_t*)&z[i], r); + srsran_simd_b_storeu((int8_t*)&z[i], r); } } -#endif /* SRSLTE_SIMD_B_SIZE */ +#endif /* SRSRAN_SIMD_B_SIZE */ for (; i < len; i++) { z[i] = x[i] ^ y[i]; } } -int srslte_vec_dot_prod_sss_simd(const int16_t* x, const int16_t* y, const int len) +int srsran_vec_dot_prod_sss_simd(const int16_t* x, const int16_t* y, const int len) { int i = 0; int result = 0; -#if SRSLTE_SIMD_S_SIZE - simd_s_t simd_dotProdVal = srslte_simd_s_zero(); - if (SRSLTE_IS_ALIGNED(x) && SRSLTE_IS_ALIGNED(y)) { - for (; i < len - SRSLTE_SIMD_S_SIZE + 1; i += SRSLTE_SIMD_S_SIZE) { - simd_s_t a = srslte_simd_s_load(&x[i]); - simd_s_t b = srslte_simd_s_load(&y[i]); +#if SRSRAN_SIMD_S_SIZE + simd_s_t simd_dotProdVal = srsran_simd_s_zero(); + if (SRSRAN_IS_ALIGNED(x) && SRSRAN_IS_ALIGNED(y)) { + for (; i < len - SRSRAN_SIMD_S_SIZE + 1; i += SRSRAN_SIMD_S_SIZE) { + simd_s_t a = srsran_simd_s_load(&x[i]); + simd_s_t b = srsran_simd_s_load(&y[i]); - simd_s_t z = srslte_simd_s_mul(a, b); + simd_s_t z = srsran_simd_s_mul(a, b); - simd_dotProdVal = srslte_simd_s_add(simd_dotProdVal, z); + simd_dotProdVal = srsran_simd_s_add(simd_dotProdVal, z); } } else { - for (; i < len - SRSLTE_SIMD_S_SIZE + 1; i += SRSLTE_SIMD_S_SIZE) { - simd_s_t a = srslte_simd_s_loadu(&x[i]); - simd_s_t b = srslte_simd_s_loadu(&y[i]); + for (; i < len - SRSRAN_SIMD_S_SIZE + 1; i += SRSRAN_SIMD_S_SIZE) { + simd_s_t a = srsran_simd_s_loadu(&x[i]); + simd_s_t b = srsran_simd_s_loadu(&y[i]); - simd_s_t z = srslte_simd_s_mul(a, b); + simd_s_t z = srsran_simd_s_mul(a, b); - simd_dotProdVal = srslte_simd_s_add(simd_dotProdVal, z); + simd_dotProdVal = srsran_simd_s_add(simd_dotProdVal, z); } } - srslte_simd_aligned short dotProdVector[SRSLTE_SIMD_S_SIZE]; - srslte_simd_s_store(dotProdVector, simd_dotProdVal); - for (int k = 0; k < SRSLTE_SIMD_S_SIZE; k++) { + srsran_simd_aligned short dotProdVector[SRSRAN_SIMD_S_SIZE]; + srsran_simd_s_store(dotProdVector, simd_dotProdVal); + for (int k = 0; k < SRSRAN_SIMD_S_SIZE; k++) { result += dotProdVector[k]; } -#endif /* SRSLTE_SIMD_S_SIZE */ +#endif /* SRSRAN_SIMD_S_SIZE */ for (; i < len; i++) { result += (x[i] * y[i]); @@ -90,182 +90,182 @@ int srslte_vec_dot_prod_sss_simd(const int16_t* x, const int16_t* y, const int l return result; } -void srslte_vec_sum_sss_simd(const int16_t* x, const int16_t* y, int16_t* z, const int len) +void srsran_vec_sum_sss_simd(const int16_t* x, const int16_t* y, int16_t* z, const int len) { int i = 0; -#if SRSLTE_SIMD_S_SIZE - if (SRSLTE_IS_ALIGNED(x) && SRSLTE_IS_ALIGNED(y) && SRSLTE_IS_ALIGNED(z)) { - for (; i < len - SRSLTE_SIMD_S_SIZE + 1; i += SRSLTE_SIMD_S_SIZE) { - simd_s_t a = srslte_simd_s_load(&x[i]); - simd_s_t b = srslte_simd_s_load(&y[i]); +#if SRSRAN_SIMD_S_SIZE + if (SRSRAN_IS_ALIGNED(x) && SRSRAN_IS_ALIGNED(y) && SRSRAN_IS_ALIGNED(z)) { + for (; i < len - SRSRAN_SIMD_S_SIZE + 1; i += SRSRAN_SIMD_S_SIZE) { + simd_s_t a = srsran_simd_s_load(&x[i]); + simd_s_t b = srsran_simd_s_load(&y[i]); - simd_s_t r = srslte_simd_s_add(a, b); + simd_s_t r = srsran_simd_s_add(a, b); - srslte_simd_s_store(&z[i], r); + srsran_simd_s_store(&z[i], r); } } else { - for (; i < len - SRSLTE_SIMD_S_SIZE + 1; i += SRSLTE_SIMD_S_SIZE) { - simd_s_t a = srslte_simd_s_loadu(&x[i]); - simd_s_t b = srslte_simd_s_loadu(&y[i]); + for (; i < len - SRSRAN_SIMD_S_SIZE + 1; i += SRSRAN_SIMD_S_SIZE) { + simd_s_t a = srsran_simd_s_loadu(&x[i]); + simd_s_t b = srsran_simd_s_loadu(&y[i]); - simd_s_t r = srslte_simd_s_add(a, b); + simd_s_t r = srsran_simd_s_add(a, b); - srslte_simd_s_storeu(&z[i], r); + srsran_simd_s_storeu(&z[i], r); } } -#endif /* SRSLTE_SIMD_S_SIZE */ +#endif /* SRSRAN_SIMD_S_SIZE */ for (; i < len; i++) { z[i] = x[i] + y[i]; } } -void srslte_vec_sub_sss_simd(const int16_t* x, const int16_t* y, int16_t* z, const int len) +void srsran_vec_sub_sss_simd(const int16_t* x, const int16_t* y, int16_t* z, const int len) { int i = 0; -#if SRSLTE_SIMD_S_SIZE - if (SRSLTE_IS_ALIGNED(x) && SRSLTE_IS_ALIGNED(y) && SRSLTE_IS_ALIGNED(z)) { - for (; i < len - SRSLTE_SIMD_S_SIZE + 1; i += SRSLTE_SIMD_S_SIZE) { - simd_s_t a = srslte_simd_s_load(&x[i]); - simd_s_t b = srslte_simd_s_load(&y[i]); +#if SRSRAN_SIMD_S_SIZE + if (SRSRAN_IS_ALIGNED(x) && SRSRAN_IS_ALIGNED(y) && SRSRAN_IS_ALIGNED(z)) { + for (; i < len - SRSRAN_SIMD_S_SIZE + 1; i += SRSRAN_SIMD_S_SIZE) { + simd_s_t a = srsran_simd_s_load(&x[i]); + simd_s_t b = srsran_simd_s_load(&y[i]); - simd_s_t r = srslte_simd_s_sub(a, b); + simd_s_t r = srsran_simd_s_sub(a, b); - srslte_simd_s_store(&z[i], r); + srsran_simd_s_store(&z[i], r); } } else { - for (; i < len - SRSLTE_SIMD_S_SIZE + 1; i += SRSLTE_SIMD_S_SIZE) { - simd_s_t a = srslte_simd_s_loadu(&x[i]); - simd_s_t b = srslte_simd_s_loadu(&y[i]); + for (; i < len - SRSRAN_SIMD_S_SIZE + 1; i += SRSRAN_SIMD_S_SIZE) { + simd_s_t a = srsran_simd_s_loadu(&x[i]); + simd_s_t b = srsran_simd_s_loadu(&y[i]); - simd_s_t r = srslte_simd_s_sub(a, b); + simd_s_t r = srsran_simd_s_sub(a, b); - srslte_simd_s_storeu(&z[i], r); + srsran_simd_s_storeu(&z[i], r); } } -#endif /* SRSLTE_SIMD_S_SIZE */ +#endif /* SRSRAN_SIMD_S_SIZE */ for (; i < len; i++) { z[i] = x[i] - y[i]; } } -void srslte_vec_sub_bbb_simd(const int8_t* x, const int8_t* y, int8_t* z, const int len) +void srsran_vec_sub_bbb_simd(const int8_t* x, const int8_t* y, int8_t* z, const int len) { int i = 0; -#if SRSLTE_SIMD_B_SIZE - if (SRSLTE_IS_ALIGNED(x) && SRSLTE_IS_ALIGNED(y) && SRSLTE_IS_ALIGNED(z)) { - for (; i < len - SRSLTE_SIMD_B_SIZE + 1; i += SRSLTE_SIMD_B_SIZE) { - simd_b_t a = srslte_simd_b_load(&x[i]); - simd_b_t b = srslte_simd_b_load(&y[i]); +#if SRSRAN_SIMD_B_SIZE + if (SRSRAN_IS_ALIGNED(x) && SRSRAN_IS_ALIGNED(y) && SRSRAN_IS_ALIGNED(z)) { + for (; i < len - SRSRAN_SIMD_B_SIZE + 1; i += SRSRAN_SIMD_B_SIZE) { + simd_b_t a = srsran_simd_b_load(&x[i]); + simd_b_t b = srsran_simd_b_load(&y[i]); - simd_b_t r = srslte_simd_b_sub(a, b); + simd_b_t r = srsran_simd_b_sub(a, b); - srslte_simd_b_store(&z[i], r); + srsran_simd_b_store(&z[i], r); } } else { - for (; i < len - SRSLTE_SIMD_S_SIZE + 1; i += SRSLTE_SIMD_S_SIZE) { - simd_b_t a = srslte_simd_b_loadu(&x[i]); - simd_b_t b = srslte_simd_b_loadu(&y[i]); + for (; i < len - SRSRAN_SIMD_S_SIZE + 1; i += SRSRAN_SIMD_S_SIZE) { + simd_b_t a = srsran_simd_b_loadu(&x[i]); + simd_b_t b = srsran_simd_b_loadu(&y[i]); - simd_b_t r = srslte_simd_b_sub(a, b); + simd_b_t r = srsran_simd_b_sub(a, b); - srslte_simd_b_storeu(&z[i], r); + srsran_simd_b_storeu(&z[i], r); } } -#endif /* SRSLTE_SIMD_S_SIZE */ +#endif /* SRSRAN_SIMD_S_SIZE */ for (; i < len; i++) { z[i] = x[i] - y[i]; } } -void srslte_vec_prod_sss_simd(const int16_t* x, const int16_t* y, int16_t* z, const int len) +void srsran_vec_prod_sss_simd(const int16_t* x, const int16_t* y, int16_t* z, const int len) { int i = 0; -#if SRSLTE_SIMD_S_SIZE - if (SRSLTE_IS_ALIGNED(x) && SRSLTE_IS_ALIGNED(y) && SRSLTE_IS_ALIGNED(z)) { - for (; i < len - SRSLTE_SIMD_S_SIZE + 1; i += SRSLTE_SIMD_S_SIZE) { - simd_s_t a = srslte_simd_s_load(&x[i]); - simd_s_t b = srslte_simd_s_load(&y[i]); +#if SRSRAN_SIMD_S_SIZE + if (SRSRAN_IS_ALIGNED(x) && SRSRAN_IS_ALIGNED(y) && SRSRAN_IS_ALIGNED(z)) { + for (; i < len - SRSRAN_SIMD_S_SIZE + 1; i += SRSRAN_SIMD_S_SIZE) { + simd_s_t a = srsran_simd_s_load(&x[i]); + simd_s_t b = srsran_simd_s_load(&y[i]); - simd_s_t r = srslte_simd_s_mul(a, b); + simd_s_t r = srsran_simd_s_mul(a, b); - srslte_simd_s_store(&z[i], r); + srsran_simd_s_store(&z[i], r); } } else { - for (; i < len - SRSLTE_SIMD_S_SIZE + 1; i += SRSLTE_SIMD_S_SIZE) { - simd_s_t a = srslte_simd_s_loadu(&x[i]); - simd_s_t b = srslte_simd_s_loadu(&y[i]); + for (; i < len - SRSRAN_SIMD_S_SIZE + 1; i += SRSRAN_SIMD_S_SIZE) { + simd_s_t a = srsran_simd_s_loadu(&x[i]); + simd_s_t b = srsran_simd_s_loadu(&y[i]); - simd_s_t r = srslte_simd_s_mul(a, b); + simd_s_t r = srsran_simd_s_mul(a, b); - srslte_simd_s_storeu(&z[i], r); + srsran_simd_s_storeu(&z[i], r); } } -#endif /* SRSLTE_SIMD_S_SIZE */ +#endif /* SRSRAN_SIMD_S_SIZE */ for (; i < len; i++) { z[i] = x[i] * y[i]; } } -void srslte_vec_neg_sss_simd(const int16_t* x, const int16_t* y, int16_t* z, const int len) +void srsran_vec_neg_sss_simd(const int16_t* x, const int16_t* y, int16_t* z, const int len) { int i = 0; -#if SRSLTE_SIMD_S_SIZE - if (SRSLTE_IS_ALIGNED(x) && SRSLTE_IS_ALIGNED(y) && SRSLTE_IS_ALIGNED(z)) { - for (; i < len - SRSLTE_SIMD_S_SIZE + 1; i += SRSLTE_SIMD_S_SIZE) { - simd_s_t a = srslte_simd_s_load(&x[i]); - simd_s_t b = srslte_simd_s_load(&y[i]); +#if SRSRAN_SIMD_S_SIZE + if (SRSRAN_IS_ALIGNED(x) && SRSRAN_IS_ALIGNED(y) && SRSRAN_IS_ALIGNED(z)) { + for (; i < len - SRSRAN_SIMD_S_SIZE + 1; i += SRSRAN_SIMD_S_SIZE) { + simd_s_t a = srsran_simd_s_load(&x[i]); + simd_s_t b = srsran_simd_s_load(&y[i]); - simd_s_t r = srslte_simd_s_neg(a, b); + simd_s_t r = srsran_simd_s_neg(a, b); - srslte_simd_s_store(&z[i], r); + srsran_simd_s_store(&z[i], r); } } else { - for (; i < len - SRSLTE_SIMD_S_SIZE + 1; i += SRSLTE_SIMD_S_SIZE) { - simd_s_t a = srslte_simd_s_loadu(&x[i]); - simd_s_t b = srslte_simd_s_loadu(&y[i]); + for (; i < len - SRSRAN_SIMD_S_SIZE + 1; i += SRSRAN_SIMD_S_SIZE) { + simd_s_t a = srsran_simd_s_loadu(&x[i]); + simd_s_t b = srsran_simd_s_loadu(&y[i]); - simd_s_t r = srslte_simd_s_neg(a, b); + simd_s_t r = srsran_simd_s_neg(a, b); - srslte_simd_s_storeu(&z[i], r); + srsran_simd_s_storeu(&z[i], r); } } -#endif /* SRSLTE_SIMD_S_SIZE */ +#endif /* SRSRAN_SIMD_S_SIZE */ for (; i < len; i++) { z[i] = y[i] < 0 ? -x[i] : x[i]; } } -void srslte_vec_neg_bbb_simd(const int8_t* x, const int8_t* y, int8_t* z, const int len) +void srsran_vec_neg_bbb_simd(const int8_t* x, const int8_t* y, int8_t* z, const int len) { int i = 0; -#if SRSLTE_SIMD_B_SIZE - if (SRSLTE_IS_ALIGNED(x) && SRSLTE_IS_ALIGNED(y) && SRSLTE_IS_ALIGNED(z)) { - for (; i < len - SRSLTE_SIMD_B_SIZE + 1; i += SRSLTE_SIMD_B_SIZE) { - simd_b_t a = srslte_simd_b_load(&x[i]); - simd_b_t b = srslte_simd_b_load(&y[i]); +#if SRSRAN_SIMD_B_SIZE + if (SRSRAN_IS_ALIGNED(x) && SRSRAN_IS_ALIGNED(y) && SRSRAN_IS_ALIGNED(z)) { + for (; i < len - SRSRAN_SIMD_B_SIZE + 1; i += SRSRAN_SIMD_B_SIZE) { + simd_b_t a = srsran_simd_b_load(&x[i]); + simd_b_t b = srsran_simd_b_load(&y[i]); - simd_b_t r = srslte_simd_b_neg(a, b); + simd_b_t r = srsran_simd_b_neg(a, b); - srslte_simd_b_store(&z[i], r); + srsran_simd_b_store(&z[i], r); } } else { - for (; i < len - SRSLTE_SIMD_B_SIZE + 1; i += SRSLTE_SIMD_B_SIZE) { - simd_b_t a = srslte_simd_b_loadu(&x[i]); - simd_b_t b = srslte_simd_b_loadu(&y[i]); + for (; i < len - SRSRAN_SIMD_B_SIZE + 1; i += SRSRAN_SIMD_B_SIZE) { + simd_b_t a = srsran_simd_b_loadu(&x[i]); + simd_b_t b = srsran_simd_b_loadu(&y[i]); - simd_b_t r = srslte_simd_b_neg(a, b); + simd_b_t r = srsran_simd_b_neg(a, b); - srslte_simd_b_storeu(&z[i], r); + srsran_simd_b_storeu(&z[i], r); } } -#endif /* SRSLTE_SIMD_S_SIZE */ +#endif /* SRSRAN_SIMD_S_SIZE */ for (; i < len; i++) { z[i] = y[i] < 0 ? -x[i] : x[i]; } @@ -279,11 +279,11 @@ void srslte_vec_neg_bbb_simd(const int8_t* x, const int8_t* y, int8_t* z, const } while (false) /* No improvement with AVX */ -void srslte_vec_lut_sss_simd(const short* x, const unsigned short* lut, short* y, const int len) +void srsran_vec_lut_sss_simd(const short* x, const unsigned short* lut, short* y, const int len) { int i = 0; #ifdef LV_HAVE_SSE - if (SRSLTE_IS_ALIGNED(x) && SRSLTE_IS_ALIGNED(lut)) { + if (SRSRAN_IS_ALIGNED(x) && SRSRAN_IS_ALIGNED(lut)) { for (; i < len - 7; i += 8) { __m128i xVal = _mm_load_si128((__m128i*)&x[i]); __m128i lutVal = _mm_load_si128((__m128i*)&lut[i]); @@ -333,11 +333,11 @@ void srslte_vec_lut_sss_simd(const short* x, const unsigned short* lut, short* y y[idx] = (char)temp; \ } while (false) -void srslte_vec_lut_bbb_simd(const int8_t* x, const unsigned short* lut, int8_t* y, const int len) +void srsran_vec_lut_bbb_simd(const int8_t* x, const unsigned short* lut, int8_t* y, const int len) { int i = 0; #ifdef LV_HAVE_SSE - if (SRSLTE_IS_ALIGNED(x) && SRSLTE_IS_ALIGNED(lut)) { + if (SRSRAN_IS_ALIGNED(x) && SRSRAN_IS_ALIGNED(lut)) { for (; i < len - 15; i += 16) { __m128i xVal = _mm_load_si128((__m128i*)&x[i]); __m128i lutVal1 = _mm_load_si128((__m128i*)&lut[i]); @@ -393,14 +393,14 @@ void srslte_vec_lut_bbb_simd(const int8_t* x, const unsigned short* lut, int8_t* } } -void srslte_vec_convert_if_simd(const int16_t* x, float* z, const float scale, const int len) +void srsran_vec_convert_if_simd(const int16_t* x, float* z, const float scale, const int len) { int i = 0; const float gain = 1.0f / scale; #ifdef LV_HAVE_SSE __m128 s = _mm_set1_ps(gain); - if (SRSLTE_IS_ALIGNED(z)) { + if (SRSRAN_IS_ALIGNED(z)) { for (; i < len - 3; i += 4) { __m64* ptr = (__m64*)&x[i]; __m128 fl = _mm_cvtpi16_ps(*ptr); @@ -424,84 +424,84 @@ void srslte_vec_convert_if_simd(const int16_t* x, float* z, const float scale, c } } -void srslte_vec_convert_fi_simd(const float* x, int16_t* z, const float scale, const int len) +void srsran_vec_convert_fi_simd(const float* x, int16_t* z, const float scale, const int len) { int i = 0; -#if SRSLTE_SIMD_F_SIZE && SRSLTE_SIMD_S_SIZE - simd_f_t s = srslte_simd_f_set1(scale); - if (SRSLTE_IS_ALIGNED(x) && SRSLTE_IS_ALIGNED(z)) { - for (; i < len - SRSLTE_SIMD_S_SIZE + 1; i += SRSLTE_SIMD_S_SIZE) { - simd_f_t a = srslte_simd_f_load(&x[i]); - simd_f_t b = srslte_simd_f_load(&x[i + SRSLTE_SIMD_F_SIZE]); +#if SRSRAN_SIMD_F_SIZE && SRSRAN_SIMD_S_SIZE + simd_f_t s = srsran_simd_f_set1(scale); + if (SRSRAN_IS_ALIGNED(x) && SRSRAN_IS_ALIGNED(z)) { + for (; i < len - SRSRAN_SIMD_S_SIZE + 1; i += SRSRAN_SIMD_S_SIZE) { + simd_f_t a = srsran_simd_f_load(&x[i]); + simd_f_t b = srsran_simd_f_load(&x[i + SRSRAN_SIMD_F_SIZE]); - simd_f_t sa = srslte_simd_f_mul(a, s); - simd_f_t sb = srslte_simd_f_mul(b, s); + simd_f_t sa = srsran_simd_f_mul(a, s); + simd_f_t sb = srsran_simd_f_mul(b, s); - simd_s_t i16 = srslte_simd_convert_2f_s(sa, sb); + simd_s_t i16 = srsran_simd_convert_2f_s(sa, sb); - srslte_simd_s_store(&z[i], i16); + srsran_simd_s_store(&z[i], i16); } } else { - for (; i < len - SRSLTE_SIMD_S_SIZE + 1; i += SRSLTE_SIMD_S_SIZE) { - simd_f_t a = srslte_simd_f_loadu(&x[i]); - simd_f_t b = srslte_simd_f_loadu(&x[i + SRSLTE_SIMD_F_SIZE]); + for (; i < len - SRSRAN_SIMD_S_SIZE + 1; i += SRSRAN_SIMD_S_SIZE) { + simd_f_t a = srsran_simd_f_loadu(&x[i]); + simd_f_t b = srsran_simd_f_loadu(&x[i + SRSRAN_SIMD_F_SIZE]); - simd_f_t sa = srslte_simd_f_mul(a, s); - simd_f_t sb = srslte_simd_f_mul(b, s); + simd_f_t sa = srsran_simd_f_mul(a, s); + simd_f_t sb = srsran_simd_f_mul(b, s); - simd_s_t i16 = srslte_simd_convert_2f_s(sa, sb); + simd_s_t i16 = srsran_simd_convert_2f_s(sa, sb); - srslte_simd_s_storeu(&z[i], i16); + srsran_simd_s_storeu(&z[i], i16); } } -#endif /* SRSLTE_SIMD_F_SIZE && SRSLTE_SIMD_S_SIZE */ +#endif /* SRSRAN_SIMD_F_SIZE && SRSRAN_SIMD_S_SIZE */ for (; i < len; i++) { z[i] = (int16_t)(x[i] * scale); } } -void srslte_vec_convert_conj_cs_simd(const cf_t* x_, int16_t* z, const float scale, const int len_) +void srsran_vec_convert_conj_cs_simd(const cf_t* x_, int16_t* z, const float scale, const int len_) { int i = 0; const float* x = (float*)x_; const int len = len_ * 2; -#if SRSLTE_SIMD_F_SIZE && SRSLTE_SIMD_S_SIZE - srslte_simd_aligned float scale_v[SRSLTE_SIMD_F_SIZE]; - for (uint32_t j = 0; j < SRSLTE_SIMD_F_SIZE; j++) { +#if SRSRAN_SIMD_F_SIZE && SRSRAN_SIMD_S_SIZE + srsran_simd_aligned float scale_v[SRSRAN_SIMD_F_SIZE]; + for (uint32_t j = 0; j < SRSRAN_SIMD_F_SIZE; j++) { scale_v[j] = (j % 2 == 0) ? +scale : -scale; } - simd_f_t s = srslte_simd_f_load(scale_v); - if (SRSLTE_IS_ALIGNED(x) && SRSLTE_IS_ALIGNED(z)) { - for (; i < len - SRSLTE_SIMD_S_SIZE + 1; i += SRSLTE_SIMD_S_SIZE) { - simd_f_t a = srslte_simd_f_load(&x[i]); - simd_f_t b = srslte_simd_f_load(&x[i + SRSLTE_SIMD_F_SIZE]); + simd_f_t s = srsran_simd_f_load(scale_v); + if (SRSRAN_IS_ALIGNED(x) && SRSRAN_IS_ALIGNED(z)) { + for (; i < len - SRSRAN_SIMD_S_SIZE + 1; i += SRSRAN_SIMD_S_SIZE) { + simd_f_t a = srsran_simd_f_load(&x[i]); + simd_f_t b = srsran_simd_f_load(&x[i + SRSRAN_SIMD_F_SIZE]); - simd_f_t sa = srslte_simd_f_mul(a, s); - simd_f_t sb = srslte_simd_f_mul(b, s); + simd_f_t sa = srsran_simd_f_mul(a, s); + simd_f_t sb = srsran_simd_f_mul(b, s); - simd_s_t i16 = srslte_simd_convert_2f_s(sa, sb); + simd_s_t i16 = srsran_simd_convert_2f_s(sa, sb); - srslte_simd_s_store(&z[i], i16); + srsran_simd_s_store(&z[i], i16); } } else { - for (; i < len - SRSLTE_SIMD_S_SIZE + 1; i += SRSLTE_SIMD_S_SIZE) { - simd_f_t a = srslte_simd_f_loadu(&x[i]); - simd_f_t b = srslte_simd_f_loadu(&x[i + SRSLTE_SIMD_F_SIZE]); + for (; i < len - SRSRAN_SIMD_S_SIZE + 1; i += SRSRAN_SIMD_S_SIZE) { + simd_f_t a = srsran_simd_f_loadu(&x[i]); + simd_f_t b = srsran_simd_f_loadu(&x[i + SRSRAN_SIMD_F_SIZE]); - simd_f_t sa = srslte_simd_f_mul(a, s); - simd_f_t sb = srslte_simd_f_mul(b, s); + simd_f_t sa = srsran_simd_f_mul(a, s); + simd_f_t sb = srsran_simd_f_mul(b, s); - simd_s_t i16 = srslte_simd_convert_2f_s(sa, sb); + simd_s_t i16 = srsran_simd_convert_2f_s(sa, sb); - srslte_simd_s_storeu(&z[i], i16); + srsran_simd_s_storeu(&z[i], i16); } } -#endif /* SRSLTE_SIMD_F_SIZE && SRSLTE_SIMD_S_SIZE */ +#endif /* SRSRAN_SIMD_F_SIZE && SRSRAN_SIMD_S_SIZE */ for (; i < len; i++) { z[i] = (int16_t)(x[i] * scale); @@ -510,9 +510,9 @@ void srslte_vec_convert_conj_cs_simd(const cf_t* x_, int16_t* z, const float sca } } -#define SRSLTE_IS_ALIGNED_SSE(PTR) (((size_t)(PTR)&0x0F) == 0) +#define SRSRAN_IS_ALIGNED_SSE(PTR) (((size_t)(PTR)&0x0F) == 0) -void srslte_vec_convert_fb_simd(const float* x, int8_t* z, const float scale, const int len) +void srsran_vec_convert_fb_simd(const float* x, int8_t* z, const float scale, const int len) { int i = 0; @@ -521,7 +521,7 @@ void srslte_vec_convert_fb_simd(const float* x, int8_t* z, const float scale, co #ifdef LV_HAVE_SSE __m128 s = _mm_set1_ps(scale); - if (SRSLTE_IS_ALIGNED_SSE(x) && SRSLTE_IS_ALIGNED_SSE(z)) { + if (SRSRAN_IS_ALIGNED_SSE(x) && SRSRAN_IS_ALIGNED_SSE(z)) { for (; i < len - 16 + 1; i += 16) { __m128 a = _mm_load_ps(&x[i]); __m128 b = _mm_load_ps(&x[i + 1 * 4]); @@ -571,7 +571,7 @@ void srslte_vec_convert_fb_simd(const float* x, int8_t* z, const float scale, co #endif #ifdef HAVE_NEON -#pragma message "srslte_vec_convert_fb_simd not implemented in neon" +#pragma message "srsran_vec_convert_fb_simd not implemented in neon" #endif /* HAVE_NEON */ for (; i < len; i++) { @@ -579,31 +579,31 @@ void srslte_vec_convert_fb_simd(const float* x, int8_t* z, const float scale, co } } -float srslte_vec_acc_ff_simd(const float* x, const int len) +float srsran_vec_acc_ff_simd(const float* x, const int len) { int i = 0; float acc_sum = 0.0f; -#if SRSLTE_SIMD_F_SIZE - simd_f_t simd_sum = srslte_simd_f_zero(); +#if SRSRAN_SIMD_F_SIZE + simd_f_t simd_sum = srsran_simd_f_zero(); - if (SRSLTE_IS_ALIGNED(x)) { - for (; i < len - SRSLTE_SIMD_F_SIZE + 1; i += SRSLTE_SIMD_F_SIZE) { - simd_f_t a = srslte_simd_f_load(&x[i]); + if (SRSRAN_IS_ALIGNED(x)) { + for (; i < len - SRSRAN_SIMD_F_SIZE + 1; i += SRSRAN_SIMD_F_SIZE) { + simd_f_t a = srsran_simd_f_load(&x[i]); - simd_sum = srslte_simd_f_add(simd_sum, a); + simd_sum = srsran_simd_f_add(simd_sum, a); } } else { - for (; i < len - SRSLTE_SIMD_F_SIZE + 1; i += SRSLTE_SIMD_F_SIZE) { - simd_f_t a = srslte_simd_f_loadu(&x[i]); + for (; i < len - SRSRAN_SIMD_F_SIZE + 1; i += SRSRAN_SIMD_F_SIZE) { + simd_f_t a = srsran_simd_f_loadu(&x[i]); - simd_sum = srslte_simd_f_add(simd_sum, a); + simd_sum = srsran_simd_f_add(simd_sum, a); } } - srslte_simd_aligned float sum[SRSLTE_SIMD_F_SIZE]; - srslte_simd_f_store(sum, simd_sum); - for (int k = 0; k < SRSLTE_SIMD_F_SIZE; k++) { + srsran_simd_aligned float sum[SRSRAN_SIMD_F_SIZE]; + srsran_simd_f_store(sum, simd_sum); + for (int k = 0; k < SRSRAN_SIMD_F_SIZE; k++) { acc_sum += sum[k]; } #endif @@ -615,31 +615,31 @@ float srslte_vec_acc_ff_simd(const float* x, const int len) return acc_sum; } -cf_t srslte_vec_acc_cc_simd(const cf_t* x, const int len) +cf_t srsran_vec_acc_cc_simd(const cf_t* x, const int len) { int i = 0; cf_t acc_sum = 0.0f; -#if SRSLTE_SIMD_F_SIZE - simd_f_t simd_sum = srslte_simd_f_zero(); +#if SRSRAN_SIMD_F_SIZE + simd_f_t simd_sum = srsran_simd_f_zero(); - if (SRSLTE_IS_ALIGNED(x)) { - for (; i < len - SRSLTE_SIMD_F_SIZE / 2 + 1; i += SRSLTE_SIMD_F_SIZE / 2) { - simd_f_t a = srslte_simd_f_load((float*)&x[i]); + if (SRSRAN_IS_ALIGNED(x)) { + for (; i < len - SRSRAN_SIMD_F_SIZE / 2 + 1; i += SRSRAN_SIMD_F_SIZE / 2) { + simd_f_t a = srsran_simd_f_load((float*)&x[i]); - simd_sum = srslte_simd_f_add(simd_sum, a); + simd_sum = srsran_simd_f_add(simd_sum, a); } } else { - for (; i < len - SRSLTE_SIMD_F_SIZE / 2 + 1; i += SRSLTE_SIMD_F_SIZE / 2) { - simd_f_t a = srslte_simd_f_loadu((float*)&x[i]); + for (; i < len - SRSRAN_SIMD_F_SIZE / 2 + 1; i += SRSRAN_SIMD_F_SIZE / 2) { + simd_f_t a = srsran_simd_f_loadu((float*)&x[i]); - simd_sum = srslte_simd_f_add(simd_sum, a); + simd_sum = srsran_simd_f_add(simd_sum, a); } } - __attribute__((aligned(64))) cf_t sum[SRSLTE_SIMD_F_SIZE / 2]; - srslte_simd_f_store((float*)&sum, simd_sum); - for (int k = 0; k < SRSLTE_SIMD_F_SIZE / 2; k++) { + __attribute__((aligned(64))) cf_t sum[SRSRAN_SIMD_F_SIZE / 2]; + srsran_simd_f_store((float*)&sum, simd_sum); + for (int k = 0; k < SRSRAN_SIMD_F_SIZE / 2; k++) { acc_sum += sum[k]; } #endif @@ -650,28 +650,28 @@ cf_t srslte_vec_acc_cc_simd(const cf_t* x, const int len) return acc_sum; } -void srslte_vec_add_fff_simd(const float* x, const float* y, float* z, const int len) +void srsran_vec_add_fff_simd(const float* x, const float* y, float* z, const int len) { int i = 0; -#if SRSLTE_SIMD_F_SIZE - if (SRSLTE_IS_ALIGNED(x) && SRSLTE_IS_ALIGNED(y) && SRSLTE_IS_ALIGNED(z)) { - for (; i < len - SRSLTE_SIMD_F_SIZE + 1; i += SRSLTE_SIMD_F_SIZE) { - simd_f_t a = srslte_simd_f_load(&x[i]); - simd_f_t b = srslte_simd_f_load(&y[i]); +#if SRSRAN_SIMD_F_SIZE + if (SRSRAN_IS_ALIGNED(x) && SRSRAN_IS_ALIGNED(y) && SRSRAN_IS_ALIGNED(z)) { + for (; i < len - SRSRAN_SIMD_F_SIZE + 1; i += SRSRAN_SIMD_F_SIZE) { + simd_f_t a = srsran_simd_f_load(&x[i]); + simd_f_t b = srsran_simd_f_load(&y[i]); - simd_f_t r = srslte_simd_f_add(a, b); + simd_f_t r = srsran_simd_f_add(a, b); - srslte_simd_f_store(&z[i], r); + srsran_simd_f_store(&z[i], r); } } else { - for (; i < len - SRSLTE_SIMD_F_SIZE + 1; i += SRSLTE_SIMD_F_SIZE) { - simd_f_t a = srslte_simd_f_loadu(&x[i]); - simd_f_t b = srslte_simd_f_loadu(&y[i]); + for (; i < len - SRSRAN_SIMD_F_SIZE + 1; i += SRSRAN_SIMD_F_SIZE) { + simd_f_t a = srsran_simd_f_loadu(&x[i]); + simd_f_t b = srsran_simd_f_loadu(&y[i]); - simd_f_t r = srslte_simd_f_add(a, b); + simd_f_t r = srsran_simd_f_add(a, b); - srslte_simd_f_storeu(&z[i], r); + srsran_simd_f_storeu(&z[i], r); } } #endif @@ -681,28 +681,28 @@ void srslte_vec_add_fff_simd(const float* x, const float* y, float* z, const int } } -void srslte_vec_sub_fff_simd(const float* x, const float* y, float* z, const int len) +void srsran_vec_sub_fff_simd(const float* x, const float* y, float* z, const int len) { int i = 0; -#if SRSLTE_SIMD_F_SIZE - if (SRSLTE_IS_ALIGNED(x) && SRSLTE_IS_ALIGNED(y) && SRSLTE_IS_ALIGNED(z)) { - for (; i < len - SRSLTE_SIMD_F_SIZE + 1; i += SRSLTE_SIMD_F_SIZE) { - simd_f_t a = srslte_simd_f_load(&x[i]); - simd_f_t b = srslte_simd_f_load(&y[i]); +#if SRSRAN_SIMD_F_SIZE + if (SRSRAN_IS_ALIGNED(x) && SRSRAN_IS_ALIGNED(y) && SRSRAN_IS_ALIGNED(z)) { + for (; i < len - SRSRAN_SIMD_F_SIZE + 1; i += SRSRAN_SIMD_F_SIZE) { + simd_f_t a = srsran_simd_f_load(&x[i]); + simd_f_t b = srsran_simd_f_load(&y[i]); - simd_f_t r = srslte_simd_f_sub(a, b); + simd_f_t r = srsran_simd_f_sub(a, b); - srslte_simd_f_store(&z[i], r); + srsran_simd_f_store(&z[i], r); } } else { - for (; i < len - SRSLTE_SIMD_F_SIZE + 1; i += SRSLTE_SIMD_F_SIZE) { - simd_f_t a = srslte_simd_f_loadu(&x[i]); - simd_f_t b = srslte_simd_f_loadu(&y[i]); + for (; i < len - SRSRAN_SIMD_F_SIZE + 1; i += SRSRAN_SIMD_F_SIZE) { + simd_f_t a = srsran_simd_f_loadu(&x[i]); + simd_f_t b = srsran_simd_f_loadu(&y[i]); - simd_f_t r = srslte_simd_f_sub(a, b); + simd_f_t r = srsran_simd_f_sub(a, b); - srslte_simd_f_storeu(&z[i], r); + srsran_simd_f_storeu(&z[i], r); } } #endif @@ -712,39 +712,39 @@ void srslte_vec_sub_fff_simd(const float* x, const float* y, float* z, const int } } -cf_t srslte_vec_dot_prod_ccc_simd(const cf_t* x, const cf_t* y, const int len) +cf_t srsran_vec_dot_prod_ccc_simd(const cf_t* x, const cf_t* y, const int len) { int i = 0; cf_t result = 0; -#if SRSLTE_SIMD_CF_SIZE - if (len >= SRSLTE_SIMD_CF_SIZE) { - simd_cf_t avx_result = srslte_simd_cf_zero(); - if (SRSLTE_IS_ALIGNED(x) && SRSLTE_IS_ALIGNED(y)) { - for (; i < len - SRSLTE_SIMD_CF_SIZE + 1; i += SRSLTE_SIMD_CF_SIZE) { - simd_cf_t xVal = srslte_simd_cfi_load(&x[i]); - simd_cf_t yVal = srslte_simd_cfi_load(&y[i]); +#if SRSRAN_SIMD_CF_SIZE + if (len >= SRSRAN_SIMD_CF_SIZE) { + simd_cf_t avx_result = srsran_simd_cf_zero(); + if (SRSRAN_IS_ALIGNED(x) && SRSRAN_IS_ALIGNED(y)) { + for (; i < len - SRSRAN_SIMD_CF_SIZE + 1; i += SRSRAN_SIMD_CF_SIZE) { + simd_cf_t xVal = srsran_simd_cfi_load(&x[i]); + simd_cf_t yVal = srsran_simd_cfi_load(&y[i]); - avx_result = srslte_simd_cf_add(srslte_simd_cf_prod(xVal, yVal), avx_result); + avx_result = srsran_simd_cf_add(srsran_simd_cf_prod(xVal, yVal), avx_result); } } else { - for (; i < len - SRSLTE_SIMD_CF_SIZE + 1; i += SRSLTE_SIMD_CF_SIZE) { - simd_cf_t xVal = srslte_simd_cfi_loadu(&x[i]); - simd_cf_t yVal = srslte_simd_cfi_loadu(&y[i]); + for (; i < len - SRSRAN_SIMD_CF_SIZE + 1; i += SRSRAN_SIMD_CF_SIZE) { + simd_cf_t xVal = srsran_simd_cfi_loadu(&x[i]); + simd_cf_t yVal = srsran_simd_cfi_loadu(&y[i]); - avx_result = srslte_simd_cf_add(srslte_simd_cf_prod(xVal, yVal), avx_result); + avx_result = srsran_simd_cf_add(srsran_simd_cf_prod(xVal, yVal), avx_result); } } - __attribute__((aligned(64))) float simd_dotProdVector[SRSLTE_SIMD_CF_SIZE]; - simd_f_t acc_re = srslte_simd_cf_re(avx_result); - simd_f_t acc_im = srslte_simd_cf_im(avx_result); + __attribute__((aligned(64))) float simd_dotProdVector[SRSRAN_SIMD_CF_SIZE]; + simd_f_t acc_re = srsran_simd_cf_re(avx_result); + simd_f_t acc_im = srsran_simd_cf_im(avx_result); - simd_f_t acc = srslte_simd_f_hadd(acc_re, acc_im); - for (int j = 2; j < SRSLTE_SIMD_F_SIZE; j *= 2) { - acc = srslte_simd_f_hadd(acc, acc); + simd_f_t acc = srsran_simd_f_hadd(acc_re, acc_im); + for (int j = 2; j < SRSRAN_SIMD_F_SIZE; j *= 2) { + acc = srsran_simd_f_hadd(acc, acc); } - srslte_simd_f_store(simd_dotProdVector, acc); + srsran_simd_f_store(simd_dotProdVector, acc); __real__ result = simd_dotProdVector[0]; __imag__ result = simd_dotProdVector[1]; } @@ -758,23 +758,23 @@ cf_t srslte_vec_dot_prod_ccc_simd(const cf_t* x, const cf_t* y, const int len) } #ifdef ENABLE_C16 -c16_t srslte_vec_dot_prod_ccc_c16i_simd(const c16_t* x, const c16_t* y, const int len) +c16_t srsran_vec_dot_prod_ccc_c16i_simd(const c16_t* x, const c16_t* y, const int len) { int i = 0; c16_t result = 0; -#if SRSLTE_SIMD_C16_SIZE - simd_c16_t avx_result = srslte_simd_c16_zero(); +#if SRSRAN_SIMD_C16_SIZE + simd_c16_t avx_result = srsran_simd_c16_zero(); - for (; i < len - SRSLTE_SIMD_C16_SIZE + 1; i += SRSLTE_SIMD_C16_SIZE) { - simd_c16_t xVal = srslte_simd_c16i_load(&x[i]); - simd_c16_t yVal = srslte_simd_c16i_load(&y[i]); + for (; i < len - SRSRAN_SIMD_C16_SIZE + 1; i += SRSRAN_SIMD_C16_SIZE) { + simd_c16_t xVal = srsran_simd_c16i_load(&x[i]); + simd_c16_t yVal = srsran_simd_c16i_load(&y[i]); - avx_result = srslte_simd_c16_add(srslte_simd_c16_prod(xVal, yVal), avx_result); + avx_result = srsran_simd_c16_add(srsran_simd_c16_prod(xVal, yVal), avx_result); } __attribute__((aligned(256))) c16_t avx_dotProdVector[16] = {0}; - srslte_simd_c16i_store(avx_dotProdVector, avx_result); + srsran_simd_c16i_store(avx_dotProdVector, avx_result); for (int k = 0; k < 16; k++) { result += avx_dotProdVector[k]; } @@ -788,39 +788,39 @@ c16_t srslte_vec_dot_prod_ccc_c16i_simd(const c16_t* x, const c16_t* y, const in } #endif /* ENABLE_C16 */ -cf_t srslte_vec_dot_prod_conj_ccc_simd(const cf_t* x, const cf_t* y, const int len) +cf_t srsran_vec_dot_prod_conj_ccc_simd(const cf_t* x, const cf_t* y, const int len) { int i = 0; cf_t result = 0; -#if SRSLTE_SIMD_CF_SIZE - if (len >= SRSLTE_SIMD_CF_SIZE) { - simd_cf_t avx_result = srslte_simd_cf_zero(); - if (SRSLTE_IS_ALIGNED(x) && SRSLTE_IS_ALIGNED(y)) { - for (; i < len - SRSLTE_SIMD_CF_SIZE + 1; i += SRSLTE_SIMD_CF_SIZE) { - simd_cf_t xVal = srslte_simd_cfi_load(&x[i]); - simd_cf_t yVal = srslte_simd_cfi_load(&y[i]); +#if SRSRAN_SIMD_CF_SIZE + if (len >= SRSRAN_SIMD_CF_SIZE) { + simd_cf_t avx_result = srsran_simd_cf_zero(); + if (SRSRAN_IS_ALIGNED(x) && SRSRAN_IS_ALIGNED(y)) { + for (; i < len - SRSRAN_SIMD_CF_SIZE + 1; i += SRSRAN_SIMD_CF_SIZE) { + simd_cf_t xVal = srsran_simd_cfi_load(&x[i]); + simd_cf_t yVal = srsran_simd_cfi_load(&y[i]); - avx_result = srslte_simd_cf_add(srslte_simd_cf_conjprod(xVal, yVal), avx_result); + avx_result = srsran_simd_cf_add(srsran_simd_cf_conjprod(xVal, yVal), avx_result); } } else { - for (; i < len - SRSLTE_SIMD_CF_SIZE + 1; i += SRSLTE_SIMD_CF_SIZE) { - simd_cf_t xVal = srslte_simd_cfi_loadu(&x[i]); - simd_cf_t yVal = srslte_simd_cfi_loadu(&y[i]); + for (; i < len - SRSRAN_SIMD_CF_SIZE + 1; i += SRSRAN_SIMD_CF_SIZE) { + simd_cf_t xVal = srsran_simd_cfi_loadu(&x[i]); + simd_cf_t yVal = srsran_simd_cfi_loadu(&y[i]); - avx_result = srslte_simd_cf_add(srslte_simd_cf_conjprod(xVal, yVal), avx_result); + avx_result = srsran_simd_cf_add(srsran_simd_cf_conjprod(xVal, yVal), avx_result); } } - __attribute__((aligned(64))) float simd_dotProdVector[SRSLTE_SIMD_CF_SIZE]; - simd_f_t acc_re = srslte_simd_cf_re(avx_result); - simd_f_t acc_im = srslte_simd_cf_im(avx_result); + __attribute__((aligned(64))) float simd_dotProdVector[SRSRAN_SIMD_CF_SIZE]; + simd_f_t acc_re = srsran_simd_cf_re(avx_result); + simd_f_t acc_im = srsran_simd_cf_im(avx_result); - simd_f_t acc = srslte_simd_f_hadd(acc_re, acc_im); - for (int j = 2; j < SRSLTE_SIMD_F_SIZE; j *= 2) { - acc = srslte_simd_f_hadd(acc, acc); + simd_f_t acc = srsran_simd_f_hadd(acc_re, acc_im); + for (int j = 2; j < SRSRAN_SIMD_F_SIZE; j *= 2) { + acc = srsran_simd_f_hadd(acc, acc); } - srslte_simd_f_store(simd_dotProdVector, acc); + srsran_simd_f_store(simd_dotProdVector, acc); __real__ result = simd_dotProdVector[0]; __imag__ result = simd_dotProdVector[1]; } @@ -833,26 +833,26 @@ cf_t srslte_vec_dot_prod_conj_ccc_simd(const cf_t* x, const cf_t* y, const int l return result; } -void srslte_vec_prod_cfc_simd(const cf_t* x, const float* y, cf_t* z, const int len) +void srsran_vec_prod_cfc_simd(const cf_t* x, const float* y, cf_t* z, const int len) { int i = 0; -#if SRSLTE_SIMD_CF_SIZE - if (SRSLTE_IS_ALIGNED(x) && SRSLTE_IS_ALIGNED(y) && SRSLTE_IS_ALIGNED(z)) { - for (; i < len - SRSLTE_SIMD_CF_SIZE + 1; i += SRSLTE_SIMD_CF_SIZE) { - simd_f_t s = srslte_simd_f_load(&y[i]); +#if SRSRAN_SIMD_CF_SIZE + if (SRSRAN_IS_ALIGNED(x) && SRSRAN_IS_ALIGNED(y) && SRSRAN_IS_ALIGNED(z)) { + for (; i < len - SRSRAN_SIMD_CF_SIZE + 1; i += SRSRAN_SIMD_CF_SIZE) { + simd_f_t s = srsran_simd_f_load(&y[i]); - simd_cf_t a = srslte_simd_cfi_load(&x[i]); - simd_cf_t r = srslte_simd_cf_mul(a, s); - srslte_simd_cfi_store(&z[i], r); + simd_cf_t a = srsran_simd_cfi_load(&x[i]); + simd_cf_t r = srsran_simd_cf_mul(a, s); + srsran_simd_cfi_store(&z[i], r); } } else { - for (; i < len - SRSLTE_SIMD_F_SIZE + 1; i += SRSLTE_SIMD_F_SIZE) { - simd_f_t s = srslte_simd_f_loadu(&y[i]); + for (; i < len - SRSRAN_SIMD_F_SIZE + 1; i += SRSRAN_SIMD_F_SIZE) { + simd_f_t s = srsran_simd_f_loadu(&y[i]); - simd_cf_t a = srslte_simd_cfi_loadu(&x[i]); - simd_cf_t r = srslte_simd_cf_mul(a, s); - srslte_simd_cfi_storeu(&z[i], r); + simd_cf_t a = srsran_simd_cfi_loadu(&x[i]); + simd_cf_t r = srsran_simd_cf_mul(a, s); + srsran_simd_cfi_storeu(&z[i], r); } } #endif @@ -862,28 +862,28 @@ void srslte_vec_prod_cfc_simd(const cf_t* x, const float* y, cf_t* z, const int } } -void srslte_vec_prod_fff_simd(const float* x, const float* y, float* z, const int len) +void srsran_vec_prod_fff_simd(const float* x, const float* y, float* z, const int len) { int i = 0; -#if SRSLTE_SIMD_F_SIZE - if (SRSLTE_IS_ALIGNED(x) && SRSLTE_IS_ALIGNED(y) && SRSLTE_IS_ALIGNED(z)) { - for (; i < len - SRSLTE_SIMD_F_SIZE + 1; i += SRSLTE_SIMD_F_SIZE) { - simd_f_t a = srslte_simd_f_load(&x[i]); - simd_f_t b = srslte_simd_f_load(&y[i]); +#if SRSRAN_SIMD_F_SIZE + if (SRSRAN_IS_ALIGNED(x) && SRSRAN_IS_ALIGNED(y) && SRSRAN_IS_ALIGNED(z)) { + for (; i < len - SRSRAN_SIMD_F_SIZE + 1; i += SRSRAN_SIMD_F_SIZE) { + simd_f_t a = srsran_simd_f_load(&x[i]); + simd_f_t b = srsran_simd_f_load(&y[i]); - simd_f_t r = srslte_simd_f_mul(a, b); + simd_f_t r = srsran_simd_f_mul(a, b); - srslte_simd_f_store(&z[i], r); + srsran_simd_f_store(&z[i], r); } } else { - for (; i < len - SRSLTE_SIMD_F_SIZE + 1; i += SRSLTE_SIMD_F_SIZE) { - simd_f_t a = srslte_simd_f_loadu(&x[i]); - simd_f_t b = srslte_simd_f_loadu(&y[i]); + for (; i < len - SRSRAN_SIMD_F_SIZE + 1; i += SRSRAN_SIMD_F_SIZE) { + simd_f_t a = srsran_simd_f_loadu(&x[i]); + simd_f_t b = srsran_simd_f_loadu(&y[i]); - simd_f_t r = srslte_simd_f_mul(a, b); + simd_f_t r = srsran_simd_f_mul(a, b); - srslte_simd_f_storeu(&z[i], r); + srsran_simd_f_storeu(&z[i], r); } } #endif @@ -893,28 +893,28 @@ void srslte_vec_prod_fff_simd(const float* x, const float* y, float* z, const in } } -void srslte_vec_prod_ccc_simd(const cf_t* x, const cf_t* y, cf_t* z, const int len) +void srsran_vec_prod_ccc_simd(const cf_t* x, const cf_t* y, cf_t* z, const int len) { int i = 0; -#if SRSLTE_SIMD_CF_SIZE - if (SRSLTE_IS_ALIGNED(x) && SRSLTE_IS_ALIGNED(y) && SRSLTE_IS_ALIGNED(z)) { - for (; i < len - SRSLTE_SIMD_CF_SIZE + 1; i += SRSLTE_SIMD_CF_SIZE) { - simd_cf_t a = srslte_simd_cfi_load(&x[i]); - simd_cf_t b = srslte_simd_cfi_load(&y[i]); +#if SRSRAN_SIMD_CF_SIZE + if (SRSRAN_IS_ALIGNED(x) && SRSRAN_IS_ALIGNED(y) && SRSRAN_IS_ALIGNED(z)) { + for (; i < len - SRSRAN_SIMD_CF_SIZE + 1; i += SRSRAN_SIMD_CF_SIZE) { + simd_cf_t a = srsran_simd_cfi_load(&x[i]); + simd_cf_t b = srsran_simd_cfi_load(&y[i]); - simd_cf_t r = srslte_simd_cf_prod(a, b); + simd_cf_t r = srsran_simd_cf_prod(a, b); - srslte_simd_cfi_store(&z[i], r); + srsran_simd_cfi_store(&z[i], r); } } else { - for (; i < len - SRSLTE_SIMD_CF_SIZE + 1; i += SRSLTE_SIMD_CF_SIZE) { - simd_cf_t a = srslte_simd_cfi_loadu(&x[i]); - simd_cf_t b = srslte_simd_cfi_loadu(&y[i]); + for (; i < len - SRSRAN_SIMD_CF_SIZE + 1; i += SRSRAN_SIMD_CF_SIZE) { + simd_cf_t a = srsran_simd_cfi_loadu(&x[i]); + simd_cf_t b = srsran_simd_cfi_loadu(&y[i]); - simd_cf_t r = srslte_simd_cf_prod(a, b); + simd_cf_t r = srsran_simd_cf_prod(a, b); - srslte_simd_cfi_storeu(&z[i], r); + srsran_simd_cfi_storeu(&z[i], r); } } #endif @@ -924,7 +924,7 @@ void srslte_vec_prod_ccc_simd(const cf_t* x, const cf_t* y, cf_t* z, const int l } } -void srslte_vec_prod_ccc_split_simd(const float* a_re, +void srsran_vec_prod_ccc_split_simd(const float* a_re, const float* a_im, const float* b_re, const float* b_im, @@ -934,25 +934,25 @@ void srslte_vec_prod_ccc_split_simd(const float* a_re, { int i = 0; -#if SRSLTE_SIMD_F_SIZE - if (SRSLTE_IS_ALIGNED(a_re) && SRSLTE_IS_ALIGNED(a_im) && SRSLTE_IS_ALIGNED(b_re) && SRSLTE_IS_ALIGNED(b_im) && - SRSLTE_IS_ALIGNED(r_re) && SRSLTE_IS_ALIGNED(r_im)) { - for (; i < len - SRSLTE_SIMD_CF_SIZE + 1; i += SRSLTE_SIMD_CF_SIZE) { - simd_cf_t a = srslte_simd_cf_load(&a_re[i], &a_im[i]); - simd_cf_t b = srslte_simd_cf_load(&b_re[i], &b_im[i]); +#if SRSRAN_SIMD_F_SIZE + if (SRSRAN_IS_ALIGNED(a_re) && SRSRAN_IS_ALIGNED(a_im) && SRSRAN_IS_ALIGNED(b_re) && SRSRAN_IS_ALIGNED(b_im) && + SRSRAN_IS_ALIGNED(r_re) && SRSRAN_IS_ALIGNED(r_im)) { + for (; i < len - SRSRAN_SIMD_CF_SIZE + 1; i += SRSRAN_SIMD_CF_SIZE) { + simd_cf_t a = srsran_simd_cf_load(&a_re[i], &a_im[i]); + simd_cf_t b = srsran_simd_cf_load(&b_re[i], &b_im[i]); - simd_cf_t r = srslte_simd_cf_prod(a, b); + simd_cf_t r = srsran_simd_cf_prod(a, b); - srslte_simd_cf_store(&r_re[i], &r_im[i], r); + srsran_simd_cf_store(&r_re[i], &r_im[i], r); } } else { - for (; i < len - SRSLTE_SIMD_CF_SIZE + 1; i += SRSLTE_SIMD_CF_SIZE) { - simd_cf_t a = srslte_simd_cf_loadu(&a_re[i], &a_im[i]); - simd_cf_t b = srslte_simd_cf_loadu(&b_re[i], &b_im[i]); + for (; i < len - SRSRAN_SIMD_CF_SIZE + 1; i += SRSRAN_SIMD_CF_SIZE) { + simd_cf_t a = srsran_simd_cf_loadu(&a_re[i], &a_im[i]); + simd_cf_t b = srsran_simd_cf_loadu(&b_re[i], &b_im[i]); - simd_cf_t r = srslte_simd_cf_prod(a, b); + simd_cf_t r = srsran_simd_cf_prod(a, b); - srslte_simd_cf_storeu(&r_re[i], &r_im[i], r); + srsran_simd_cf_storeu(&r_re[i], &r_im[i], r); } } #endif @@ -964,7 +964,7 @@ void srslte_vec_prod_ccc_split_simd(const float* a_re, } #ifdef ENABLE_C16 -void srslte_vec_prod_ccc_c16_simd(const int16_t* a_re, +void srsran_vec_prod_ccc_c16_simd(const int16_t* a_re, const int16_t* a_im, const int16_t* b_re, const int16_t* b_im, @@ -974,25 +974,25 @@ void srslte_vec_prod_ccc_c16_simd(const int16_t* a_re, { int i = 0; -#if SRSLTE_SIMD_C16_SIZE - if (SRSLTE_IS_ALIGNED(a_re) && SRSLTE_IS_ALIGNED(a_im) && SRSLTE_IS_ALIGNED(b_re) && SRSLTE_IS_ALIGNED(b_im) && - SRSLTE_IS_ALIGNED(r_re) && SRSLTE_IS_ALIGNED(r_im)) { - for (; i < len - SRSLTE_SIMD_C16_SIZE + 1; i += SRSLTE_SIMD_C16_SIZE) { - simd_c16_t a = srslte_simd_c16_load(&a_re[i], &a_im[i]); - simd_c16_t b = srslte_simd_c16_load(&b_re[i], &b_im[i]); +#if SRSRAN_SIMD_C16_SIZE + if (SRSRAN_IS_ALIGNED(a_re) && SRSRAN_IS_ALIGNED(a_im) && SRSRAN_IS_ALIGNED(b_re) && SRSRAN_IS_ALIGNED(b_im) && + SRSRAN_IS_ALIGNED(r_re) && SRSRAN_IS_ALIGNED(r_im)) { + for (; i < len - SRSRAN_SIMD_C16_SIZE + 1; i += SRSRAN_SIMD_C16_SIZE) { + simd_c16_t a = srsran_simd_c16_load(&a_re[i], &a_im[i]); + simd_c16_t b = srsran_simd_c16_load(&b_re[i], &b_im[i]); - simd_c16_t r = srslte_simd_c16_prod(a, b); + simd_c16_t r = srsran_simd_c16_prod(a, b); - srslte_simd_c16_store(&r_re[i], &r_im[i], r); + srsran_simd_c16_store(&r_re[i], &r_im[i], r); } } else { - for (; i < len - SRSLTE_SIMD_C16_SIZE + 1; i += SRSLTE_SIMD_C16_SIZE) { - simd_c16_t a = srslte_simd_c16_loadu(&a_re[i], &a_im[i]); - simd_c16_t b = srslte_simd_c16_loadu(&b_re[i], &b_im[i]); + for (; i < len - SRSRAN_SIMD_C16_SIZE + 1; i += SRSRAN_SIMD_C16_SIZE) { + simd_c16_t a = srsran_simd_c16_loadu(&a_re[i], &a_im[i]); + simd_c16_t b = srsran_simd_c16_loadu(&b_re[i], &b_im[i]); - simd_c16_t r = srslte_simd_c16_prod(a, b); + simd_c16_t r = srsran_simd_c16_prod(a, b); - srslte_simd_c16_storeu(&r_re[i], &r_im[i], r); + srsran_simd_c16_storeu(&r_re[i], &r_im[i], r); } } #endif @@ -1004,28 +1004,28 @@ void srslte_vec_prod_ccc_c16_simd(const int16_t* a_re, } #endif /* ENABLE_C16 */ -void srslte_vec_prod_conj_ccc_simd(const cf_t* x, const cf_t* y, cf_t* z, const int len) +void srsran_vec_prod_conj_ccc_simd(const cf_t* x, const cf_t* y, cf_t* z, const int len) { int i = 0; -#if SRSLTE_SIMD_CF_SIZE - if (SRSLTE_IS_ALIGNED(x) && SRSLTE_IS_ALIGNED(y) && SRSLTE_IS_ALIGNED(z)) { - for (; i < len - SRSLTE_SIMD_CF_SIZE + 1; i += SRSLTE_SIMD_CF_SIZE) { - simd_cf_t a = srslte_simd_cfi_load(&x[i]); - simd_cf_t b = srslte_simd_cfi_load(&y[i]); +#if SRSRAN_SIMD_CF_SIZE + if (SRSRAN_IS_ALIGNED(x) && SRSRAN_IS_ALIGNED(y) && SRSRAN_IS_ALIGNED(z)) { + for (; i < len - SRSRAN_SIMD_CF_SIZE + 1; i += SRSRAN_SIMD_CF_SIZE) { + simd_cf_t a = srsran_simd_cfi_load(&x[i]); + simd_cf_t b = srsran_simd_cfi_load(&y[i]); - simd_cf_t r = srslte_simd_cf_conjprod(a, b); + simd_cf_t r = srsran_simd_cf_conjprod(a, b); - srslte_simd_cfi_store(&z[i], r); + srsran_simd_cfi_store(&z[i], r); } } else { - for (; i < len - SRSLTE_SIMD_CF_SIZE + 1; i += SRSLTE_SIMD_CF_SIZE) { - simd_cf_t a = srslte_simd_cfi_loadu(&x[i]); - simd_cf_t b = srslte_simd_cfi_loadu(&y[i]); + for (; i < len - SRSRAN_SIMD_CF_SIZE + 1; i += SRSRAN_SIMD_CF_SIZE) { + simd_cf_t a = srsran_simd_cfi_loadu(&x[i]); + simd_cf_t b = srsran_simd_cfi_loadu(&y[i]); - simd_cf_t r = srslte_simd_cf_conjprod(a, b); + simd_cf_t r = srsran_simd_cf_conjprod(a, b); - srslte_simd_cfi_storeu(&z[i], r); + srsran_simd_cfi_storeu(&z[i], r); } } #endif @@ -1035,30 +1035,30 @@ void srslte_vec_prod_conj_ccc_simd(const cf_t* x, const cf_t* y, cf_t* z, const } } -void srslte_vec_div_ccc_simd(const cf_t* x, const cf_t* y, cf_t* z, const int len) +void srsran_vec_div_ccc_simd(const cf_t* x, const cf_t* y, cf_t* z, const int len) { int i = 0; -#if SRSLTE_SIMD_CF_SIZE - if (SRSLTE_IS_ALIGNED(x) && SRSLTE_IS_ALIGNED(y) && SRSLTE_IS_ALIGNED(z)) { - for (; i < len - SRSLTE_SIMD_CF_SIZE + 1; i += SRSLTE_SIMD_CF_SIZE) { - simd_cf_t a = srslte_simd_cfi_load(&x[i]); - simd_cf_t b = srslte_simd_cfi_load(&y[i]); +#if SRSRAN_SIMD_CF_SIZE + if (SRSRAN_IS_ALIGNED(x) && SRSRAN_IS_ALIGNED(y) && SRSRAN_IS_ALIGNED(z)) { + for (; i < len - SRSRAN_SIMD_CF_SIZE + 1; i += SRSRAN_SIMD_CF_SIZE) { + simd_cf_t a = srsran_simd_cfi_load(&x[i]); + simd_cf_t b = srsran_simd_cfi_load(&y[i]); - simd_cf_t rcpb = srslte_simd_cf_rcp(b); - simd_cf_t r = srslte_simd_cf_prod(a, rcpb); + simd_cf_t rcpb = srsran_simd_cf_rcp(b); + simd_cf_t r = srsran_simd_cf_prod(a, rcpb); - srslte_simd_cfi_store(&z[i], r); + srsran_simd_cfi_store(&z[i], r); } } else { - for (; i < len - SRSLTE_SIMD_CF_SIZE + 1; i += SRSLTE_SIMD_CF_SIZE) { - simd_cf_t a = srslte_simd_cfi_loadu(&x[i]); - simd_cf_t b = srslte_simd_cfi_loadu(&y[i]); + for (; i < len - SRSRAN_SIMD_CF_SIZE + 1; i += SRSRAN_SIMD_CF_SIZE) { + simd_cf_t a = srsran_simd_cfi_loadu(&x[i]); + simd_cf_t b = srsran_simd_cfi_loadu(&y[i]); - simd_cf_t rcpb = srslte_simd_cf_rcp(b); - simd_cf_t r = srslte_simd_cf_prod(a, rcpb); + simd_cf_t rcpb = srsran_simd_cf_rcp(b); + simd_cf_t r = srsran_simd_cf_prod(a, rcpb); - srslte_simd_cfi_storeu(&z[i], r); + srsran_simd_cfi_storeu(&z[i], r); } } #endif @@ -1068,30 +1068,30 @@ void srslte_vec_div_ccc_simd(const cf_t* x, const cf_t* y, cf_t* z, const int le } } -void srslte_vec_div_cfc_simd(const cf_t* x, const float* y, cf_t* z, const int len) +void srsran_vec_div_cfc_simd(const cf_t* x, const float* y, cf_t* z, const int len) { int i = 0; -#if SRSLTE_SIMD_CF_SIZE && SRSLTE_SIMD_CF_SIZE == SRSLTE_SIMD_F_SIZE - if (SRSLTE_IS_ALIGNED(x) && SRSLTE_IS_ALIGNED(y) && SRSLTE_IS_ALIGNED(z)) { - for (; i < len - SRSLTE_SIMD_CF_SIZE + 1; i += SRSLTE_SIMD_CF_SIZE) { - simd_cf_t a = srslte_simd_cfi_load(&x[i]); - simd_f_t b = srslte_simd_f_load(&y[i]); +#if SRSRAN_SIMD_CF_SIZE && SRSRAN_SIMD_CF_SIZE == SRSRAN_SIMD_F_SIZE + if (SRSRAN_IS_ALIGNED(x) && SRSRAN_IS_ALIGNED(y) && SRSRAN_IS_ALIGNED(z)) { + for (; i < len - SRSRAN_SIMD_CF_SIZE + 1; i += SRSRAN_SIMD_CF_SIZE) { + simd_cf_t a = srsran_simd_cfi_load(&x[i]); + simd_f_t b = srsran_simd_f_load(&y[i]); - simd_f_t rcpb = srslte_simd_f_rcp(b); - simd_cf_t r = srslte_simd_cf_mul(a, rcpb); + simd_f_t rcpb = srsran_simd_f_rcp(b); + simd_cf_t r = srsran_simd_cf_mul(a, rcpb); - srslte_simd_cfi_store(&z[i], r); + srsran_simd_cfi_store(&z[i], r); } } else { - for (; i < len - SRSLTE_SIMD_CF_SIZE + 1; i += SRSLTE_SIMD_CF_SIZE) { - simd_cf_t a = srslte_simd_cfi_loadu(&x[i]); - simd_f_t b = srslte_simd_f_loadu(&y[i]); + for (; i < len - SRSRAN_SIMD_CF_SIZE + 1; i += SRSRAN_SIMD_CF_SIZE) { + simd_cf_t a = srsran_simd_cfi_loadu(&x[i]); + simd_f_t b = srsran_simd_f_loadu(&y[i]); - simd_f_t rcpb = srslte_simd_f_rcp(b); - simd_cf_t r = srslte_simd_cf_mul(a, rcpb); + simd_f_t rcpb = srsran_simd_f_rcp(b); + simd_cf_t r = srsran_simd_cf_mul(a, rcpb); - srslte_simd_cfi_storeu(&z[i], r); + srsran_simd_cfi_storeu(&z[i], r); } } #endif @@ -1101,30 +1101,30 @@ void srslte_vec_div_cfc_simd(const cf_t* x, const float* y, cf_t* z, const int l } } -void srslte_vec_div_fff_simd(const float* x, const float* y, float* z, const int len) +void srsran_vec_div_fff_simd(const float* x, const float* y, float* z, const int len) { int i = 0; -#if SRSLTE_SIMD_F_SIZE - if (SRSLTE_IS_ALIGNED(x) && SRSLTE_IS_ALIGNED(y) && SRSLTE_IS_ALIGNED(z)) { - for (; i < len - SRSLTE_SIMD_F_SIZE + 1; i += SRSLTE_SIMD_F_SIZE) { - simd_f_t a = srslte_simd_f_load(&x[i]); - simd_f_t b = srslte_simd_f_load(&y[i]); +#if SRSRAN_SIMD_F_SIZE + if (SRSRAN_IS_ALIGNED(x) && SRSRAN_IS_ALIGNED(y) && SRSRAN_IS_ALIGNED(z)) { + for (; i < len - SRSRAN_SIMD_F_SIZE + 1; i += SRSRAN_SIMD_F_SIZE) { + simd_f_t a = srsran_simd_f_load(&x[i]); + simd_f_t b = srsran_simd_f_load(&y[i]); - simd_f_t rcpb = srslte_simd_f_rcp(b); - simd_f_t r = srslte_simd_f_mul(a, rcpb); + simd_f_t rcpb = srsran_simd_f_rcp(b); + simd_f_t r = srsran_simd_f_mul(a, rcpb); - srslte_simd_f_store(&z[i], r); + srsran_simd_f_store(&z[i], r); } } else { - for (; i < len - SRSLTE_SIMD_F_SIZE + 1; i += SRSLTE_SIMD_F_SIZE) { - simd_f_t a = srslte_simd_f_loadu(&x[i]); - simd_f_t b = srslte_simd_f_loadu(&y[i]); + for (; i < len - SRSRAN_SIMD_F_SIZE + 1; i += SRSRAN_SIMD_F_SIZE) { + simd_f_t a = srsran_simd_f_loadu(&x[i]); + simd_f_t b = srsran_simd_f_loadu(&y[i]); - simd_f_t rcpb = srslte_simd_f_rcp(b); - simd_f_t r = srslte_simd_f_mul(a, rcpb); + simd_f_t rcpb = srsran_simd_f_rcp(b); + simd_f_t r = srsran_simd_f_mul(a, rcpb); - srslte_simd_f_storeu(&z[i], r); + srsran_simd_f_storeu(&z[i], r); } } #endif @@ -1134,19 +1134,18 @@ void srslte_vec_div_fff_simd(const float* x, const float* y, float* z, const int } } -int srslte_vec_sc_prod_ccc_simd2(const cf_t* x, const cf_t h, cf_t* z, const int len) +int srsran_vec_sc_prod_ccc_simd2(const cf_t* x, const cf_t h, cf_t* z, const int len) { int i = 0; const unsigned int loops = len / 4; #ifdef HAVE_NEON simd_cf_t h_vec; - h_vec.val[0] = srslte_simd_f_set1(__real__ h); - h_vec.val[1] = srslte_simd_f_set1(__imag__ h); + h_vec.val[0] = srsran_simd_f_set1(__real__ h); + h_vec.val[1] = srsran_simd_f_set1(__imag__ h); for (; i < loops; i++) { - - simd_cf_t in = srslte_simd_cfi_load(&x[i * 4]); - simd_cf_t temp = srslte_simd_cf_prod(in, h_vec); - srslte_simd_cfi_store(&z[i * 4], temp); + simd_cf_t in = srsran_simd_cfi_load(&x[i * 4]); + simd_cf_t temp = srsran_simd_cf_prod(in, h_vec); + srsran_simd_cfi_store(&z[i * 4], temp); } #endif @@ -1154,38 +1153,38 @@ int srslte_vec_sc_prod_ccc_simd2(const cf_t* x, const cf_t h, cf_t* z, const int return i; } -void srslte_vec_sc_prod_ccc_simd(const cf_t* x, const cf_t h, cf_t* z, const int len) +void srsran_vec_sc_prod_ccc_simd(const cf_t* x, const cf_t h, cf_t* z, const int len) { int i = 0; -#if SRSLTE_SIMD_F_SIZE +#if SRSRAN_SIMD_F_SIZE #ifdef HAVE_NEON - i = srslte_vec_sc_prod_ccc_simd2(x, h, z, len); + i = srsran_vec_sc_prod_ccc_simd2(x, h, z, len); #else - const simd_f_t hre = srslte_simd_f_set1(__real__ h); - const simd_f_t him = srslte_simd_f_set1(__imag__ h); + const simd_f_t hre = srsran_simd_f_set1(__real__ h); + const simd_f_t him = srsran_simd_f_set1(__imag__ h); - if (SRSLTE_IS_ALIGNED(x) && SRSLTE_IS_ALIGNED(z)) { - for (; i < len - SRSLTE_SIMD_F_SIZE / 2 + 1; i += SRSLTE_SIMD_F_SIZE / 2) { - simd_f_t temp = srslte_simd_f_load((float*)&x[i]); + if (SRSRAN_IS_ALIGNED(x) && SRSRAN_IS_ALIGNED(z)) { + for (; i < len - SRSRAN_SIMD_F_SIZE / 2 + 1; i += SRSRAN_SIMD_F_SIZE / 2) { + simd_f_t temp = srsran_simd_f_load((float*)&x[i]); - simd_f_t m1 = srslte_simd_f_mul(hre, temp); - simd_f_t sw = srslte_simd_f_swap(temp); - simd_f_t m2 = srslte_simd_f_mul(him, sw); - simd_f_t r = srslte_simd_f_addsub(m1, m2); - srslte_simd_f_store((float*)&z[i], r); + simd_f_t m1 = srsran_simd_f_mul(hre, temp); + simd_f_t sw = srsran_simd_f_swap(temp); + simd_f_t m2 = srsran_simd_f_mul(him, sw); + simd_f_t r = srsran_simd_f_addsub(m1, m2); + srsran_simd_f_store((float*)&z[i], r); } } else { - for (; i < len - SRSLTE_SIMD_F_SIZE / 2 + 1; i += SRSLTE_SIMD_F_SIZE / 2) { - simd_f_t temp = srslte_simd_f_loadu((float*)&x[i]); + for (; i < len - SRSRAN_SIMD_F_SIZE / 2 + 1; i += SRSRAN_SIMD_F_SIZE / 2) { + simd_f_t temp = srsran_simd_f_loadu((float*)&x[i]); - simd_f_t m1 = srslte_simd_f_mul(hre, temp); - simd_f_t sw = srslte_simd_f_swap(temp); - simd_f_t m2 = srslte_simd_f_mul(him, sw); - simd_f_t r = srslte_simd_f_addsub(m1, m2); + simd_f_t m1 = srsran_simd_f_mul(hre, temp); + simd_f_t sw = srsran_simd_f_swap(temp); + simd_f_t m2 = srsran_simd_f_mul(him, sw); + simd_f_t r = srsran_simd_f_addsub(m1, m2); - srslte_simd_f_storeu((float*)&z[i], r); + srsran_simd_f_storeu((float*)&z[i], r); } } #endif @@ -1195,27 +1194,27 @@ void srslte_vec_sc_prod_ccc_simd(const cf_t* x, const cf_t h, cf_t* z, const int } } -void srslte_vec_sc_prod_fff_simd(const float* x, const float h, float* z, const int len) +void srsran_vec_sc_prod_fff_simd(const float* x, const float h, float* z, const int len) { int i = 0; -#if SRSLTE_SIMD_F_SIZE - const simd_f_t hh = srslte_simd_f_set1(h); - if (SRSLTE_IS_ALIGNED(x) && SRSLTE_IS_ALIGNED(z)) { - for (; i < len - SRSLTE_SIMD_F_SIZE + 1; i += SRSLTE_SIMD_F_SIZE) { - simd_f_t xx = srslte_simd_f_load(&x[i]); +#if SRSRAN_SIMD_F_SIZE + const simd_f_t hh = srsran_simd_f_set1(h); + if (SRSRAN_IS_ALIGNED(x) && SRSRAN_IS_ALIGNED(z)) { + for (; i < len - SRSRAN_SIMD_F_SIZE + 1; i += SRSRAN_SIMD_F_SIZE) { + simd_f_t xx = srsran_simd_f_load(&x[i]); - simd_f_t zz = srslte_simd_f_mul(xx, hh); + simd_f_t zz = srsran_simd_f_mul(xx, hh); - srslte_simd_f_store(&z[i], zz); + srsran_simd_f_store(&z[i], zz); } } else { - for (; i < len - SRSLTE_SIMD_F_SIZE + 1; i += SRSLTE_SIMD_F_SIZE) { - simd_f_t xx = srslte_simd_f_loadu(&x[i]); + for (; i < len - SRSRAN_SIMD_F_SIZE + 1; i += SRSRAN_SIMD_F_SIZE) { + simd_f_t xx = srsran_simd_f_loadu(&x[i]); - simd_f_t zz = srslte_simd_f_mul(xx, hh); + simd_f_t zz = srsran_simd_f_mul(xx, hh); - srslte_simd_f_storeu(&z[i], zz); + srsran_simd_f_storeu(&z[i], zz); } } #endif @@ -1225,35 +1224,35 @@ void srslte_vec_sc_prod_fff_simd(const float* x, const float h, float* z, const } } -void srslte_vec_abs_cf_simd(const cf_t* x, float* z, const int len) +void srsran_vec_abs_cf_simd(const cf_t* x, float* z, const int len) { int i = 0; -#if SRSLTE_SIMD_F_SIZE - if (SRSLTE_IS_ALIGNED(x) && SRSLTE_IS_ALIGNED(z)) { - for (; i < len - SRSLTE_SIMD_F_SIZE + 1; i += SRSLTE_SIMD_F_SIZE) { - simd_f_t x1 = srslte_simd_f_load((float*)&x[i]); - simd_f_t x2 = srslte_simd_f_load((float*)&x[i + SRSLTE_SIMD_F_SIZE / 2]); +#if SRSRAN_SIMD_F_SIZE + if (SRSRAN_IS_ALIGNED(x) && SRSRAN_IS_ALIGNED(z)) { + for (; i < len - SRSRAN_SIMD_F_SIZE + 1; i += SRSRAN_SIMD_F_SIZE) { + simd_f_t x1 = srsran_simd_f_load((float*)&x[i]); + simd_f_t x2 = srsran_simd_f_load((float*)&x[i + SRSRAN_SIMD_F_SIZE / 2]); - simd_f_t mul1 = srslte_simd_f_mul(x1, x1); - simd_f_t mul2 = srslte_simd_f_mul(x2, x2); + simd_f_t mul1 = srsran_simd_f_mul(x1, x1); + simd_f_t mul2 = srsran_simd_f_mul(x2, x2); - simd_f_t z1 = srslte_simd_f_hadd(mul1, mul2); - z1 = srslte_simd_f_sqrt(z1); - srslte_simd_f_store(&z[i], z1); + simd_f_t z1 = srsran_simd_f_hadd(mul1, mul2); + z1 = srsran_simd_f_sqrt(z1); + srsran_simd_f_store(&z[i], z1); } } else { - for (; i < len - SRSLTE_SIMD_F_SIZE + 1; i += SRSLTE_SIMD_F_SIZE) { - simd_f_t x1 = srslte_simd_f_loadu((float*)&x[i]); - simd_f_t x2 = srslte_simd_f_loadu((float*)&x[i + SRSLTE_SIMD_F_SIZE / 2]); + for (; i < len - SRSRAN_SIMD_F_SIZE + 1; i += SRSRAN_SIMD_F_SIZE) { + simd_f_t x1 = srsran_simd_f_loadu((float*)&x[i]); + simd_f_t x2 = srsran_simd_f_loadu((float*)&x[i + SRSRAN_SIMD_F_SIZE / 2]); - simd_f_t mul1 = srslte_simd_f_mul(x1, x1); - simd_f_t mul2 = srslte_simd_f_mul(x2, x2); + simd_f_t mul1 = srsran_simd_f_mul(x1, x1); + simd_f_t mul2 = srsran_simd_f_mul(x2, x2); - simd_f_t z1 = srslte_simd_f_hadd(mul1, mul2); - z1 = srslte_simd_f_sqrt(z1); + simd_f_t z1 = srsran_simd_f_hadd(mul1, mul2); + z1 = srsran_simd_f_sqrt(z1); - srslte_simd_f_storeu(&z[i], z1); + srsran_simd_f_storeu(&z[i], z1); } } #endif @@ -1263,34 +1262,34 @@ void srslte_vec_abs_cf_simd(const cf_t* x, float* z, const int len) } } -void srslte_vec_abs_square_cf_simd(const cf_t* x, float* z, const int len) +void srsran_vec_abs_square_cf_simd(const cf_t* x, float* z, const int len) { int i = 0; -#if SRSLTE_SIMD_F_SIZE - if (SRSLTE_IS_ALIGNED(x) && SRSLTE_IS_ALIGNED(z)) { - for (; i < len - SRSLTE_SIMD_F_SIZE + 1; i += SRSLTE_SIMD_F_SIZE) { - simd_f_t x1 = srslte_simd_f_load((float*)&x[i]); - simd_f_t x2 = srslte_simd_f_load((float*)&x[i + SRSLTE_SIMD_F_SIZE / 2]); +#if SRSRAN_SIMD_F_SIZE + if (SRSRAN_IS_ALIGNED(x) && SRSRAN_IS_ALIGNED(z)) { + for (; i < len - SRSRAN_SIMD_F_SIZE + 1; i += SRSRAN_SIMD_F_SIZE) { + simd_f_t x1 = srsran_simd_f_load((float*)&x[i]); + simd_f_t x2 = srsran_simd_f_load((float*)&x[i + SRSRAN_SIMD_F_SIZE / 2]); - simd_f_t mul1 = srslte_simd_f_mul(x1, x1); - simd_f_t mul2 = srslte_simd_f_mul(x2, x2); + simd_f_t mul1 = srsran_simd_f_mul(x1, x1); + simd_f_t mul2 = srsran_simd_f_mul(x2, x2); - simd_f_t z1 = srslte_simd_f_hadd(mul1, mul2); + simd_f_t z1 = srsran_simd_f_hadd(mul1, mul2); - srslte_simd_f_store(&z[i], z1); + srsran_simd_f_store(&z[i], z1); } } else { - for (; i < len - SRSLTE_SIMD_F_SIZE + 1; i += SRSLTE_SIMD_F_SIZE) { - simd_f_t x1 = srslte_simd_f_loadu((float*)&x[i]); - simd_f_t x2 = srslte_simd_f_loadu((float*)&x[i + SRSLTE_SIMD_F_SIZE / 2]); + for (; i < len - SRSRAN_SIMD_F_SIZE + 1; i += SRSRAN_SIMD_F_SIZE) { + simd_f_t x1 = srsran_simd_f_loadu((float*)&x[i]); + simd_f_t x2 = srsran_simd_f_loadu((float*)&x[i + SRSRAN_SIMD_F_SIZE / 2]); - simd_f_t mul1 = srslte_simd_f_mul(x1, x1); - simd_f_t mul2 = srslte_simd_f_mul(x2, x2); + simd_f_t mul1 = srsran_simd_f_mul(x1, x1); + simd_f_t mul2 = srsran_simd_f_mul(x2, x2); - simd_f_t z1 = srslte_simd_f_hadd(mul1, mul2); + simd_f_t z1 = srsran_simd_f_hadd(mul1, mul2); - srslte_simd_f_storeu(&z[i], z1); + srsran_simd_f_storeu(&z[i], z1); } } #endif @@ -1300,28 +1299,28 @@ void srslte_vec_abs_square_cf_simd(const cf_t* x, float* z, const int len) } } -void srslte_vec_sc_prod_cfc_simd(const cf_t* x, const float h, cf_t* z, const int len) +void srsran_vec_sc_prod_cfc_simd(const cf_t* x, const float h, cf_t* z, const int len) { int i = 0; -#if SRSLTE_SIMD_F_SIZE - const simd_f_t tap = srslte_simd_f_set1(h); +#if SRSRAN_SIMD_F_SIZE + const simd_f_t tap = srsran_simd_f_set1(h); - if (SRSLTE_IS_ALIGNED(x) && SRSLTE_IS_ALIGNED(z)) { - for (; i < len - SRSLTE_SIMD_F_SIZE / 2 + 1; i += SRSLTE_SIMD_F_SIZE / 2) { - simd_f_t temp = srslte_simd_f_load((float*)&x[i]); + if (SRSRAN_IS_ALIGNED(x) && SRSRAN_IS_ALIGNED(z)) { + for (; i < len - SRSRAN_SIMD_F_SIZE / 2 + 1; i += SRSRAN_SIMD_F_SIZE / 2) { + simd_f_t temp = srsran_simd_f_load((float*)&x[i]); - temp = srslte_simd_f_mul(tap, temp); + temp = srsran_simd_f_mul(tap, temp); - srslte_simd_f_store((float*)&z[i], temp); + srsran_simd_f_store((float*)&z[i], temp); } } else { - for (; i < len - SRSLTE_SIMD_F_SIZE / 2 + 1; i += SRSLTE_SIMD_F_SIZE / 2) { - simd_f_t temp = srslte_simd_f_loadu((float*)&x[i]); + for (; i < len - SRSRAN_SIMD_F_SIZE / 2 + 1; i += SRSRAN_SIMD_F_SIZE / 2) { + simd_f_t temp = srsran_simd_f_loadu((float*)&x[i]); - temp = srslte_simd_f_mul(tap, temp); + temp = srsran_simd_f_mul(tap, temp); - srslte_simd_f_storeu((float*)&z[i], temp); + srsran_simd_f_storeu((float*)&z[i], temp); } } #endif @@ -1331,20 +1330,20 @@ void srslte_vec_sc_prod_cfc_simd(const cf_t* x, const float h, cf_t* z, const in } } -void srslte_vec_sc_prod_fcc_simd(const float* x, const cf_t h, cf_t* z, const int len) +void srsran_vec_sc_prod_fcc_simd(const float* x, const cf_t h, cf_t* z, const int len) { int i = 0; -#if SRSLTE_SIMD_F_SIZE - const simd_cf_t tap = srslte_simd_cf_set1(h); +#if SRSRAN_SIMD_F_SIZE + const simd_cf_t tap = srsran_simd_cf_set1(h); - if (SRSLTE_IS_ALIGNED(x) && SRSLTE_IS_ALIGNED(z)) { - for (; i < len - SRSLTE_SIMD_F_SIZE + 1; i += SRSLTE_SIMD_F_SIZE) { - srslte_simd_cfi_store(&z[i], srslte_simd_cf_mul(tap, srslte_simd_f_load(&x[i]))); + if (SRSRAN_IS_ALIGNED(x) && SRSRAN_IS_ALIGNED(z)) { + for (; i < len - SRSRAN_SIMD_F_SIZE + 1; i += SRSRAN_SIMD_F_SIZE) { + srsran_simd_cfi_store(&z[i], srsran_simd_cf_mul(tap, srsran_simd_f_load(&x[i]))); } } else { - for (; i < len - SRSLTE_SIMD_F_SIZE + 1; i += SRSLTE_SIMD_F_SIZE) { - srslte_simd_cfi_storeu(&z[i], srslte_simd_cf_mul(tap, srslte_simd_f_loadu(&x[i]))); + for (; i < len - SRSRAN_SIMD_F_SIZE + 1; i += SRSRAN_SIMD_F_SIZE) { + srsran_simd_cfi_storeu(&z[i], srsran_simd_cf_mul(tap, srsran_simd_f_loadu(&x[i]))); } } #endif @@ -1354,53 +1353,53 @@ void srslte_vec_sc_prod_fcc_simd(const float* x, const cf_t h, cf_t* z, const in } } -uint32_t srslte_vec_max_fi_simd(const float* x, const int len) +uint32_t srsran_vec_max_fi_simd(const float* x, const int len) { int i = 0; float max_value = -INFINITY; uint32_t max_index = 0; -#if SRSLTE_SIMD_I_SIZE - srslte_simd_aligned int indexes_buffer[SRSLTE_SIMD_I_SIZE] = {0}; - srslte_simd_aligned float values_buffer[SRSLTE_SIMD_I_SIZE] = {0}; +#if SRSRAN_SIMD_I_SIZE + srsran_simd_aligned int indexes_buffer[SRSRAN_SIMD_I_SIZE] = {0}; + srsran_simd_aligned float values_buffer[SRSRAN_SIMD_I_SIZE] = {0}; - for (int k = 0; k < SRSLTE_SIMD_I_SIZE; k++) + for (int k = 0; k < SRSRAN_SIMD_I_SIZE; k++) indexes_buffer[k] = k; - simd_i_t simd_inc = srslte_simd_i_set1(SRSLTE_SIMD_I_SIZE); - simd_i_t simd_indexes = srslte_simd_i_load(indexes_buffer); - simd_i_t simd_max_indexes = srslte_simd_i_set1(0); + simd_i_t simd_inc = srsran_simd_i_set1(SRSRAN_SIMD_I_SIZE); + simd_i_t simd_indexes = srsran_simd_i_load(indexes_buffer); + simd_i_t simd_max_indexes = srsran_simd_i_set1(0); - simd_f_t simd_max_values = srslte_simd_f_set1(-INFINITY); + simd_f_t simd_max_values = srsran_simd_f_set1(-INFINITY); - if (SRSLTE_IS_ALIGNED(x)) { - for (; i < len - SRSLTE_SIMD_I_SIZE + 1; i += SRSLTE_SIMD_I_SIZE) { - simd_f_t a = srslte_simd_f_load(&x[i]); - simd_sel_t res = srslte_simd_f_max(a, simd_max_values); - simd_max_indexes = srslte_simd_i_select(simd_max_indexes, simd_indexes, res); - simd_max_values = (simd_f_t)srslte_simd_i_select((simd_i_t)simd_max_values, (simd_i_t)a, res); - simd_indexes = srslte_simd_i_add(simd_indexes, simd_inc); + if (SRSRAN_IS_ALIGNED(x)) { + for (; i < len - SRSRAN_SIMD_I_SIZE + 1; i += SRSRAN_SIMD_I_SIZE) { + simd_f_t a = srsran_simd_f_load(&x[i]); + simd_sel_t res = srsran_simd_f_max(a, simd_max_values); + simd_max_indexes = srsran_simd_i_select(simd_max_indexes, simd_indexes, res); + simd_max_values = (simd_f_t)srsran_simd_i_select((simd_i_t)simd_max_values, (simd_i_t)a, res); + simd_indexes = srsran_simd_i_add(simd_indexes, simd_inc); } } else { - for (; i < len - SRSLTE_SIMD_I_SIZE + 1; i += SRSLTE_SIMD_I_SIZE) { - simd_f_t a = srslte_simd_f_loadu(&x[i]); - simd_sel_t res = srslte_simd_f_max(a, simd_max_values); - simd_max_indexes = srslte_simd_i_select(simd_max_indexes, simd_indexes, res); - simd_max_values = (simd_f_t)srslte_simd_i_select((simd_i_t)simd_max_values, (simd_i_t)a, res); - simd_indexes = srslte_simd_i_add(simd_indexes, simd_inc); + for (; i < len - SRSRAN_SIMD_I_SIZE + 1; i += SRSRAN_SIMD_I_SIZE) { + simd_f_t a = srsran_simd_f_loadu(&x[i]); + simd_sel_t res = srsran_simd_f_max(a, simd_max_values); + simd_max_indexes = srsran_simd_i_select(simd_max_indexes, simd_indexes, res); + simd_max_values = (simd_f_t)srsran_simd_i_select((simd_i_t)simd_max_values, (simd_i_t)a, res); + simd_indexes = srsran_simd_i_add(simd_indexes, simd_inc); } } - srslte_simd_i_store(indexes_buffer, simd_max_indexes); - srslte_simd_f_store(values_buffer, simd_max_values); + srsran_simd_i_store(indexes_buffer, simd_max_indexes); + srsran_simd_f_store(values_buffer, simd_max_values); - for (int k = 0; k < SRSLTE_SIMD_I_SIZE; k++) { + for (int k = 0; k < SRSRAN_SIMD_I_SIZE; k++) { if (values_buffer[k] > max_value) { max_value = values_buffer[k]; max_index = (uint32_t)indexes_buffer[k]; } } -#endif /* SRSLTE_SIMD_I_SIZE */ +#endif /* SRSRAN_SIMD_I_SIZE */ for (; i < len; i++) { if (x[i] > max_value) { @@ -1412,53 +1411,53 @@ uint32_t srslte_vec_max_fi_simd(const float* x, const int len) return max_index; } -uint32_t srslte_vec_max_abs_fi_simd(const float* x, const int len) +uint32_t srsran_vec_max_abs_fi_simd(const float* x, const int len) { int i = 0; float max_value = -INFINITY; uint32_t max_index = 0; -#if SRSLTE_SIMD_I_SIZE - srslte_simd_aligned int indexes_buffer[SRSLTE_SIMD_I_SIZE] = {0}; - srslte_simd_aligned float values_buffer[SRSLTE_SIMD_I_SIZE] = {0}; +#if SRSRAN_SIMD_I_SIZE + srsran_simd_aligned int indexes_buffer[SRSRAN_SIMD_I_SIZE] = {0}; + srsran_simd_aligned float values_buffer[SRSRAN_SIMD_I_SIZE] = {0}; - for (int k = 0; k < SRSLTE_SIMD_I_SIZE; k++) + for (int k = 0; k < SRSRAN_SIMD_I_SIZE; k++) indexes_buffer[k] = k; - simd_i_t simd_inc = srslte_simd_i_set1(SRSLTE_SIMD_I_SIZE); - simd_i_t simd_indexes = srslte_simd_i_load(indexes_buffer); - simd_i_t simd_max_indexes = srslte_simd_i_set1(0); + simd_i_t simd_inc = srsran_simd_i_set1(SRSRAN_SIMD_I_SIZE); + simd_i_t simd_indexes = srsran_simd_i_load(indexes_buffer); + simd_i_t simd_max_indexes = srsran_simd_i_set1(0); - simd_f_t simd_max_values = srslte_simd_f_set1(-INFINITY); + simd_f_t simd_max_values = srsran_simd_f_set1(-INFINITY); - if (SRSLTE_IS_ALIGNED(x)) { - for (; i < len - SRSLTE_SIMD_I_SIZE + 1; i += SRSLTE_SIMD_I_SIZE) { - simd_f_t a = srslte_simd_f_abs(srslte_simd_f_load(&x[i])); - simd_sel_t res = srslte_simd_f_max(a, simd_max_values); - simd_max_indexes = srslte_simd_i_select(simd_max_indexes, simd_indexes, res); - simd_max_values = (simd_f_t)srslte_simd_i_select((simd_i_t)simd_max_values, (simd_i_t)a, res); - simd_indexes = srslte_simd_i_add(simd_indexes, simd_inc); + if (SRSRAN_IS_ALIGNED(x)) { + for (; i < len - SRSRAN_SIMD_I_SIZE + 1; i += SRSRAN_SIMD_I_SIZE) { + simd_f_t a = srsran_simd_f_abs(srsran_simd_f_load(&x[i])); + simd_sel_t res = srsran_simd_f_max(a, simd_max_values); + simd_max_indexes = srsran_simd_i_select(simd_max_indexes, simd_indexes, res); + simd_max_values = (simd_f_t)srsran_simd_i_select((simd_i_t)simd_max_values, (simd_i_t)a, res); + simd_indexes = srsran_simd_i_add(simd_indexes, simd_inc); } } else { - for (; i < len - SRSLTE_SIMD_I_SIZE + 1; i += SRSLTE_SIMD_I_SIZE) { - simd_f_t a = srslte_simd_f_abs(srslte_simd_f_loadu(&x[i])); - simd_sel_t res = srslte_simd_f_max(a, simd_max_values); - simd_max_indexes = srslte_simd_i_select(simd_max_indexes, simd_indexes, res); - simd_max_values = (simd_f_t)srslte_simd_i_select((simd_i_t)simd_max_values, (simd_i_t)a, res); - simd_indexes = srslte_simd_i_add(simd_indexes, simd_inc); + for (; i < len - SRSRAN_SIMD_I_SIZE + 1; i += SRSRAN_SIMD_I_SIZE) { + simd_f_t a = srsran_simd_f_abs(srsran_simd_f_loadu(&x[i])); + simd_sel_t res = srsran_simd_f_max(a, simd_max_values); + simd_max_indexes = srsran_simd_i_select(simd_max_indexes, simd_indexes, res); + simd_max_values = (simd_f_t)srsran_simd_i_select((simd_i_t)simd_max_values, (simd_i_t)a, res); + simd_indexes = srsran_simd_i_add(simd_indexes, simd_inc); } } - srslte_simd_i_store(indexes_buffer, simd_max_indexes); - srslte_simd_f_store(values_buffer, simd_max_values); + srsran_simd_i_store(indexes_buffer, simd_max_indexes); + srsran_simd_f_store(values_buffer, simd_max_values); - for (int k = 0; k < SRSLTE_SIMD_I_SIZE; k++) { + for (int k = 0; k < SRSRAN_SIMD_I_SIZE; k++) { if (values_buffer[k] > max_value) { max_value = values_buffer[k]; max_index = (uint32_t)indexes_buffer[k]; } } -#endif /* SRSLTE_SIMD_I_SIZE */ +#endif /* SRSRAN_SIMD_I_SIZE */ for (; i < len; i++) { float a = fabsf(x[i]); @@ -1471,69 +1470,69 @@ uint32_t srslte_vec_max_abs_fi_simd(const float* x, const int len) return max_index; } -uint32_t srslte_vec_max_ci_simd(const cf_t* x, const int len) +uint32_t srsran_vec_max_ci_simd(const cf_t* x, const int len) { int i = 0; float max_value = -INFINITY; uint32_t max_index = 0; -#if SRSLTE_SIMD_I_SIZE - srslte_simd_aligned int indexes_buffer[SRSLTE_SIMD_I_SIZE] = {0}; - srslte_simd_aligned float values_buffer[SRSLTE_SIMD_I_SIZE] = {0}; +#if SRSRAN_SIMD_I_SIZE + srsran_simd_aligned int indexes_buffer[SRSRAN_SIMD_I_SIZE] = {0}; + srsran_simd_aligned float values_buffer[SRSRAN_SIMD_I_SIZE] = {0}; - for (int k = 0; k < SRSLTE_SIMD_I_SIZE; k++) + for (int k = 0; k < SRSRAN_SIMD_I_SIZE; k++) indexes_buffer[k] = k; - simd_i_t simd_inc = srslte_simd_i_set1(SRSLTE_SIMD_I_SIZE); - simd_i_t simd_indexes = srslte_simd_i_load(indexes_buffer); - simd_i_t simd_max_indexes = srslte_simd_i_set1(0); + simd_i_t simd_inc = srsran_simd_i_set1(SRSRAN_SIMD_I_SIZE); + simd_i_t simd_indexes = srsran_simd_i_load(indexes_buffer); + simd_i_t simd_max_indexes = srsran_simd_i_set1(0); - simd_f_t simd_max_values = srslte_simd_f_set1(-INFINITY); + simd_f_t simd_max_values = srsran_simd_f_set1(-INFINITY); - if (SRSLTE_IS_ALIGNED(x)) { - for (; i < len - SRSLTE_SIMD_I_SIZE + 1; i += SRSLTE_SIMD_I_SIZE) { - simd_f_t x1 = srslte_simd_f_load((float*)&x[i]); - simd_f_t x2 = srslte_simd_f_load((float*)&x[i + SRSLTE_SIMD_F_SIZE / 2]); + if (SRSRAN_IS_ALIGNED(x)) { + for (; i < len - SRSRAN_SIMD_I_SIZE + 1; i += SRSRAN_SIMD_I_SIZE) { + simd_f_t x1 = srsran_simd_f_load((float*)&x[i]); + simd_f_t x2 = srsran_simd_f_load((float*)&x[i + SRSRAN_SIMD_F_SIZE / 2]); - simd_f_t mul1 = srslte_simd_f_mul(x1, x1); - simd_f_t mul2 = srslte_simd_f_mul(x2, x2); + simd_f_t mul1 = srsran_simd_f_mul(x1, x1); + simd_f_t mul2 = srsran_simd_f_mul(x2, x2); - simd_f_t z1 = srslte_simd_f_hadd(mul1, mul2); + simd_f_t z1 = srsran_simd_f_hadd(mul1, mul2); - simd_sel_t res = srslte_simd_f_max(z1, simd_max_values); + simd_sel_t res = srsran_simd_f_max(z1, simd_max_values); - simd_max_indexes = srslte_simd_i_select(simd_max_indexes, simd_indexes, res); - simd_max_values = (simd_f_t)srslte_simd_i_select((simd_i_t)simd_max_values, (simd_i_t)z1, res); - simd_indexes = srslte_simd_i_add(simd_indexes, simd_inc); + simd_max_indexes = srsran_simd_i_select(simd_max_indexes, simd_indexes, res); + simd_max_values = (simd_f_t)srsran_simd_i_select((simd_i_t)simd_max_values, (simd_i_t)z1, res); + simd_indexes = srsran_simd_i_add(simd_indexes, simd_inc); } } else { - for (; i < len - SRSLTE_SIMD_I_SIZE + 1; i += SRSLTE_SIMD_I_SIZE) { - simd_f_t x1 = srslte_simd_f_loadu((float*)&x[i]); - simd_f_t x2 = srslte_simd_f_loadu((float*)&x[i + SRSLTE_SIMD_F_SIZE / 2]); + for (; i < len - SRSRAN_SIMD_I_SIZE + 1; i += SRSRAN_SIMD_I_SIZE) { + simd_f_t x1 = srsran_simd_f_loadu((float*)&x[i]); + simd_f_t x2 = srsran_simd_f_loadu((float*)&x[i + SRSRAN_SIMD_F_SIZE / 2]); - simd_f_t mul1 = srslte_simd_f_mul(x1, x1); - simd_f_t mul2 = srslte_simd_f_mul(x2, x2); + simd_f_t mul1 = srsran_simd_f_mul(x1, x1); + simd_f_t mul2 = srsran_simd_f_mul(x2, x2); - simd_f_t z1 = srslte_simd_f_hadd(mul1, mul2); + simd_f_t z1 = srsran_simd_f_hadd(mul1, mul2); - simd_sel_t res = srslte_simd_f_max(z1, simd_max_values); + simd_sel_t res = srsran_simd_f_max(z1, simd_max_values); - simd_max_indexes = srslte_simd_i_select(simd_max_indexes, simd_indexes, res); - simd_max_values = (simd_f_t)srslte_simd_i_select((simd_i_t)simd_max_values, (simd_i_t)z1, res); - simd_indexes = srslte_simd_i_add(simd_indexes, simd_inc); + simd_max_indexes = srsran_simd_i_select(simd_max_indexes, simd_indexes, res); + simd_max_values = (simd_f_t)srsran_simd_i_select((simd_i_t)simd_max_values, (simd_i_t)z1, res); + simd_indexes = srsran_simd_i_add(simd_indexes, simd_inc); } } - srslte_simd_i_store(indexes_buffer, simd_max_indexes); - srslte_simd_f_store(values_buffer, simd_max_values); + srsran_simd_i_store(indexes_buffer, simd_max_indexes); + srsran_simd_f_store(values_buffer, simd_max_values); - for (int k = 0; k < SRSLTE_SIMD_I_SIZE; k++) { + for (int k = 0; k < SRSRAN_SIMD_I_SIZE; k++) { if (values_buffer[k] > max_value) { max_value = values_buffer[k]; max_index = (uint32_t)indexes_buffer[k]; } } -#endif /* SRSLTE_SIMD_I_SIZE */ +#endif /* SRSRAN_SIMD_I_SIZE */ for (; i < len; i++) { cf_t a = x[i]; @@ -1547,12 +1546,12 @@ uint32_t srslte_vec_max_ci_simd(const cf_t* x, const int len) return max_index; } -void srslte_vec_interleave_simd(const cf_t* x, const cf_t* y, cf_t* z, const int len) +void srsran_vec_interleave_simd(const cf_t* x, const cf_t* y, cf_t* z, const int len) { uint32_t i = 0, k = 0; #ifdef LV_HAVE_SSE - if (SRSLTE_IS_ALIGNED(x) && SRSLTE_IS_ALIGNED(y) && SRSLTE_IS_ALIGNED(z)) { + if (SRSRAN_IS_ALIGNED(x) && SRSRAN_IS_ALIGNED(y) && SRSRAN_IS_ALIGNED(z)) { for (; i < len - 2 + 1; i += 2) { __m128i a = _mm_load_si128((__m128i*)&x[i]); __m128i b = _mm_load_si128((__m128i*)&y[i]); @@ -1587,12 +1586,12 @@ void srslte_vec_interleave_simd(const cf_t* x, const cf_t* y, cf_t* z, const int } } -void srslte_vec_interleave_add_simd(const cf_t* x, const cf_t* y, cf_t* z, const int len) +void srsran_vec_interleave_add_simd(const cf_t* x, const cf_t* y, cf_t* z, const int len) { uint32_t i = 0, k = 0; #ifdef LV_HAVE_SSE - if (SRSLTE_IS_ALIGNED(x) && SRSLTE_IS_ALIGNED(y) && SRSLTE_IS_ALIGNED(z)) { + if (SRSRAN_IS_ALIGNED(x) && SRSRAN_IS_ALIGNED(y) && SRSRAN_IS_ALIGNED(z)) { for (; i < len - 2 + 1; i += 2) { __m128i a = _mm_load_si128((__m128i*)&x[i]); __m128i b = _mm_load_si128((__m128i*)&y[i]); @@ -1635,44 +1634,44 @@ void srslte_vec_interleave_add_simd(const cf_t* x, const cf_t* y, cf_t* z, const } } -void srslte_vec_gen_sine_simd(cf_t amplitude, float freq, cf_t* z, int len) +void srsran_vec_gen_sine_simd(cf_t amplitude, float freq, cf_t* z, int len) { const float TWOPI = 2.0f * (float)M_PI; cf_t osc = cexpf(_Complex_I * TWOPI * freq); cf_t phase = 1.0f; int i = 0; -#if SRSLTE_SIMD_CF_SIZE - __attribute__((aligned(64))) cf_t _phase[SRSLTE_SIMD_CF_SIZE]; +#if SRSRAN_SIMD_CF_SIZE + __attribute__((aligned(64))) cf_t _phase[SRSRAN_SIMD_CF_SIZE]; _phase[0] = phase; - if (i < len - SRSLTE_SIMD_CF_SIZE + 1) { - for (int k = 1; k < SRSLTE_SIMD_CF_SIZE; k++) { + if (i < len - SRSRAN_SIMD_CF_SIZE + 1) { + for (int k = 1; k < SRSRAN_SIMD_CF_SIZE; k++) { _phase[k] = _phase[k - 1] * osc; } } - simd_cf_t _simd_osc = srslte_simd_cf_set1(cexpf(_Complex_I * TWOPI * freq * SRSLTE_SIMD_CF_SIZE)); - simd_cf_t _simd_phase = srslte_simd_cfi_load(_phase); - simd_cf_t a = srslte_simd_cf_set1(amplitude); + simd_cf_t _simd_osc = srsran_simd_cf_set1(cexpf(_Complex_I * TWOPI * freq * SRSRAN_SIMD_CF_SIZE)); + simd_cf_t _simd_phase = srsran_simd_cfi_load(_phase); + simd_cf_t a = srsran_simd_cf_set1(amplitude); - if (SRSLTE_IS_ALIGNED(z)) { - for (; i < len - SRSLTE_SIMD_CF_SIZE + 1; i += SRSLTE_SIMD_CF_SIZE) { - simd_cf_t r = srslte_simd_cf_prod(a, _simd_phase); - srslte_simd_cfi_store(&z[i], r); - _simd_phase = srslte_simd_cf_prod(_simd_phase, _simd_osc); + if (SRSRAN_IS_ALIGNED(z)) { + for (; i < len - SRSRAN_SIMD_CF_SIZE + 1; i += SRSRAN_SIMD_CF_SIZE) { + simd_cf_t r = srsran_simd_cf_prod(a, _simd_phase); + srsran_simd_cfi_store(&z[i], r); + _simd_phase = srsran_simd_cf_prod(_simd_phase, _simd_osc); } } else { - for (; i < len - SRSLTE_SIMD_CF_SIZE + 1; i += SRSLTE_SIMD_CF_SIZE) { - simd_cf_t r = srslte_simd_cf_prod(a, _simd_phase); - srslte_simd_cfi_storeu(&z[i], r); - _simd_phase = srslte_simd_cf_prod(_simd_phase, _simd_osc); + for (; i < len - SRSRAN_SIMD_CF_SIZE + 1; i += SRSRAN_SIMD_CF_SIZE) { + simd_cf_t r = srsran_simd_cf_prod(a, _simd_phase); + srsran_simd_cfi_storeu(&z[i], r); + _simd_phase = srsran_simd_cf_prod(_simd_phase, _simd_osc); } } // Store pahse and get last phase - srslte_simd_cfi_store(_phase, _simd_phase); + srsran_simd_cfi_store(_phase, _simd_phase); phase = _phase[0]; -#endif /* SRSLTE_SIMD_CF_SIZE */ +#endif /* SRSRAN_SIMD_CF_SIZE */ for (; i < len; i++) { z[i] = amplitude * phase; @@ -1681,43 +1680,43 @@ void srslte_vec_gen_sine_simd(cf_t amplitude, float freq, cf_t* z, int len) } } -void srslte_vec_apply_cfo_simd(const cf_t* x, float cfo, cf_t* z, int len) +void srsran_vec_apply_cfo_simd(const cf_t* x, float cfo, cf_t* z, int len) { const float TWOPI = 2.0f * (float)M_PI; int i = 0; -#if SRSLTE_SIMD_CF_SIZE - srslte_simd_aligned cf_t _osc[SRSLTE_SIMD_CF_SIZE]; - srslte_simd_aligned cf_t _phase[SRSLTE_SIMD_CF_SIZE]; +#if SRSRAN_SIMD_CF_SIZE + srsran_simd_aligned cf_t _osc[SRSRAN_SIMD_CF_SIZE]; + srsran_simd_aligned cf_t _phase[SRSRAN_SIMD_CF_SIZE]; - if (i < len - SRSLTE_SIMD_CF_SIZE + 1) { - for (int k = 0; k < SRSLTE_SIMD_CF_SIZE; k++) { - _osc[k] = cexpf(_Complex_I * TWOPI * cfo * SRSLTE_SIMD_CF_SIZE); + if (i < len - SRSRAN_SIMD_CF_SIZE + 1) { + for (int k = 0; k < SRSRAN_SIMD_CF_SIZE; k++) { + _osc[k] = cexpf(_Complex_I * TWOPI * cfo * SRSRAN_SIMD_CF_SIZE); _phase[k] = cexpf(_Complex_I * TWOPI * cfo * k); } } - simd_cf_t _simd_osc = srslte_simd_cfi_load(_osc); - simd_cf_t _simd_phase = srslte_simd_cfi_load(_phase); + simd_cf_t _simd_osc = srsran_simd_cfi_load(_osc); + simd_cf_t _simd_phase = srsran_simd_cfi_load(_phase); - if (SRSLTE_IS_ALIGNED(x) && SRSLTE_IS_ALIGNED(z)) { - for (; i < len - SRSLTE_SIMD_CF_SIZE + 1; i += SRSLTE_SIMD_CF_SIZE) { - simd_cf_t a = srslte_simd_cfi_load(&x[i]); + if (SRSRAN_IS_ALIGNED(x) && SRSRAN_IS_ALIGNED(z)) { + for (; i < len - SRSRAN_SIMD_CF_SIZE + 1; i += SRSRAN_SIMD_CF_SIZE) { + simd_cf_t a = srsran_simd_cfi_load(&x[i]); - simd_cf_t r = srslte_simd_cf_prod(a, _simd_phase); + simd_cf_t r = srsran_simd_cf_prod(a, _simd_phase); - srslte_simd_cfi_store(&z[i], r); + srsran_simd_cfi_store(&z[i], r); - _simd_phase = srslte_simd_cf_prod(_simd_phase, _simd_osc); + _simd_phase = srsran_simd_cf_prod(_simd_phase, _simd_osc); } } else { - for (; i < len - SRSLTE_SIMD_F_SIZE + 1; i += SRSLTE_SIMD_F_SIZE) { - for (; i < len - SRSLTE_SIMD_CF_SIZE + 1; i += SRSLTE_SIMD_CF_SIZE) { - simd_cf_t a = srslte_simd_cfi_loadu(&x[i]); + for (; i < len - SRSRAN_SIMD_F_SIZE + 1; i += SRSRAN_SIMD_F_SIZE) { + for (; i < len - SRSRAN_SIMD_CF_SIZE + 1; i += SRSRAN_SIMD_CF_SIZE) { + simd_cf_t a = srsran_simd_cfi_loadu(&x[i]); - simd_cf_t r = srslte_simd_cf_prod(a, _simd_phase); - _simd_phase = srslte_simd_cf_prod(_simd_phase, _simd_osc); + simd_cf_t r = srsran_simd_cf_prod(a, _simd_phase); + _simd_phase = srsran_simd_cf_prod(_simd_phase, _simd_osc); - srslte_simd_cfi_storeu(&z[i], r); + srsran_simd_cfi_storeu(&z[i], r); } } } @@ -1731,7 +1730,7 @@ void srslte_vec_apply_cfo_simd(const cf_t* x, float cfo, cf_t* z, int len) } } -float srslte_vec_estimate_frequency_simd(const cf_t* x, int len) +float srsran_vec_estimate_frequency_simd(const cf_t* x, int len) { cf_t sum = 0.0f; @@ -1740,33 +1739,33 @@ float srslte_vec_estimate_frequency_simd(const cf_t* x, int len) int i = 1; -#if SRSLTE_SIMD_CF_SIZE - if (len > SRSLTE_SIMD_CF_SIZE) { - simd_cf_t _sum = srslte_simd_cf_zero(); +#if SRSRAN_SIMD_CF_SIZE + if (len > SRSRAN_SIMD_CF_SIZE) { + simd_cf_t _sum = srsran_simd_cf_zero(); - for (; i < len - SRSLTE_SIMD_CF_SIZE + 1; i += SRSLTE_SIMD_CF_SIZE) { - simd_cf_t a1 = srslte_simd_cfi_loadu(&x[i]); - simd_cf_t a2 = srslte_simd_cfi_loadu(&x[i - 1]); + for (; i < len - SRSRAN_SIMD_CF_SIZE + 1; i += SRSRAN_SIMD_CF_SIZE) { + simd_cf_t a1 = srsran_simd_cfi_loadu(&x[i]); + simd_cf_t a2 = srsran_simd_cfi_loadu(&x[i - 1]); // Multiply by conjugate and accumulate - _sum = srslte_simd_cf_add(srslte_simd_cf_conjprod(a1, a2), _sum); + _sum = srsran_simd_cf_add(srsran_simd_cf_conjprod(a1, a2), _sum); } // Accumulate using horizontal addition - simd_f_t _sum_re = srslte_simd_cf_re(_sum); - simd_f_t _sum_im = srslte_simd_cf_im(_sum); - simd_f_t _sum_re_im = srslte_simd_f_hadd(_sum_re, _sum_im); - for (int j = 2; j < SRSLTE_SIMD_F_SIZE; j *= 2) { - _sum_re_im = srslte_simd_f_hadd(_sum_re_im, _sum_re_im); + simd_f_t _sum_re = srsran_simd_cf_re(_sum); + simd_f_t _sum_im = srsran_simd_cf_im(_sum); + simd_f_t _sum_re_im = srsran_simd_f_hadd(_sum_re, _sum_im); + for (int j = 2; j < SRSRAN_SIMD_F_SIZE; j *= 2) { + _sum_re_im = srsran_simd_f_hadd(_sum_re_im, _sum_re_im); } // Get accumulator - srslte_simd_aligned float _sum_v[SRSLTE_SIMD_CF_SIZE]; - srslte_simd_f_store(_sum_v, _sum_re_im); + srsran_simd_aligned float _sum_v[SRSRAN_SIMD_CF_SIZE]; + srsran_simd_f_store(_sum_v, _sum_re_im); __real__ sum = _sum_v[0]; __imag__ sum = _sum_v[1]; } -#endif /* SRSLTE_SIMD_CF_SIZE */ +#endif /* SRSRAN_SIMD_CF_SIZE */ for (; i < len; i++) { sum += x[i] * conjf(x[i - 1]); diff --git a/lib/src/radio/CMakeLists.txt b/lib/src/radio/CMakeLists.txt index 9d2012ade..515e0a9cf 100644 --- a/lib/src/radio/CMakeLists.txt +++ b/lib/src/radio/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -7,9 +7,9 @@ # if(RF_FOUND) - add_library(srslte_radio STATIC radio.cc channel_mapping.cc) - target_link_libraries(srslte_radio srslte_rf srslte_common) - INSTALL(TARGETS srslte_radio DESTINATION ${LIBRARY_DIR}) + add_library(srsran_radio STATIC radio.cc channel_mapping.cc) + target_link_libraries(srsran_radio srsran_rf srsran_common) + INSTALL(TARGETS srsran_radio DESTINATION ${LIBRARY_DIR}) endif(RF_FOUND) add_subdirectory(test) diff --git a/lib/src/radio/channel_mapping.cc b/lib/src/radio/channel_mapping.cc index fd0af7b46..c393c37a7 100644 --- a/lib/src/radio/channel_mapping.cc +++ b/lib/src/radio/channel_mapping.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,11 +10,11 @@ * */ -#include "srslte/radio/channel_mapping.h" -#include "srslte/phy/utils/debug.h" +#include "srsran/radio/channel_mapping.h" +#include "srsran/phy/utils/debug.h" #include -namespace srslte { +namespace srsran { void channel_mapping::set_config(const uint32_t& nof_channels_x_dev_, const uint32_t& nof_antennas_) { @@ -90,4 +90,4 @@ std::string channel_mapping::to_string() const return ss.str(); } -} // namespace srslte \ No newline at end of file +} // namespace srsran \ No newline at end of file diff --git a/lib/src/radio/radio.cc b/lib/src/radio/radio.cc index aef1a0ab9..831635c52 100644 --- a/lib/src/radio/radio.cc +++ b/lib/src/radio/radio.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,23 +10,23 @@ * */ -#include "srslte/radio/radio.h" -#include "srslte/common/standard_streams.h" -#include "srslte/common/string_helpers.h" -#include "srslte/config.h" +#include "srsran/radio/radio.h" +#include "srsran/common/standard_streams.h" +#include "srsran/common/string_helpers.h" +#include "srsran/config.h" #include #include #include -namespace srslte { +namespace srsran { radio::radio() : zeros(nullptr) { - zeros = srslte_vec_cf_malloc(SRSLTE_SF_LEN_MAX); - srslte_vec_cf_zero(zeros, SRSLTE_SF_LEN_MAX); - for (uint32_t i = 0; i < SRSLTE_MAX_CHANNELS; i++) { - dummy_buffers[i] = srslte_vec_cf_malloc(SRSLTE_SF_LEN_MAX * SRSLTE_NOF_SF_X_FRAME); - srslte_vec_cf_zero(dummy_buffers[i], SRSLTE_SF_LEN_MAX * SRSLTE_NOF_SF_X_FRAME); + zeros = srsran_vec_cf_malloc(SRSRAN_SF_LEN_MAX); + srsran_vec_cf_zero(zeros, SRSRAN_SF_LEN_MAX); + for (uint32_t i = 0; i < SRSRAN_MAX_CHANNELS; i++) { + dummy_buffers[i] = srsran_vec_cf_malloc(SRSRAN_SF_LEN_MAX * SRSRAN_NOF_SF_X_FRAME); + srsran_vec_cf_zero(dummy_buffers[i], SRSRAN_SF_LEN_MAX * SRSRAN_NOF_SF_X_FRAME); } } @@ -37,18 +37,18 @@ radio::~radio() zeros = nullptr; } - for (uint32_t i = 0; i < SRSLTE_MAX_CHANNELS; i++) { + for (uint32_t i = 0; i < SRSRAN_MAX_CHANNELS; i++) { if (dummy_buffers[i]) { free(dummy_buffers[i]); } } - for (srslte_resampler_fft_t& q : interpolators) { - srslte_resampler_fft_free(&q); + for (srsran_resampler_fft_t& q : interpolators) { + srsran_resampler_fft_free(&q); } - for (srslte_resampler_fft_t& q : decimators) { - srslte_resampler_fft_free(&q); + for (srsran_resampler_fft_t& q : decimators) { + srsran_resampler_fft_free(&q); } } @@ -59,19 +59,19 @@ int radio::init(const rf_args_t& args, phy_interface_radio* phy_) // Init log logger.set_level(srslog::str_to_basic_level(args.log_level)); - if (args.nof_antennas > SRSLTE_MAX_PORTS) { - logger.error("Maximum number of antennas exceeded (%d > %d)", args.nof_antennas, SRSLTE_MAX_PORTS); - return SRSLTE_ERROR; + if (args.nof_antennas > SRSRAN_MAX_PORTS) { + logger.error("Maximum number of antennas exceeded (%d > %d)", args.nof_antennas, SRSRAN_MAX_PORTS); + return SRSRAN_ERROR; } - if (args.nof_carriers > SRSLTE_MAX_CARRIERS) { - logger.error("Maximum number of carriers exceeded (%d > %d)", args.nof_carriers, SRSLTE_MAX_CARRIERS); - return SRSLTE_ERROR; + if (args.nof_carriers > SRSRAN_MAX_CARRIERS) { + logger.error("Maximum number of carriers exceeded (%d > %d)", args.nof_carriers, SRSRAN_MAX_CARRIERS); + return SRSRAN_ERROR; } if (!config_rf_channels(args)) { - srslte::console("Error configuring RF channels\n"); - return SRSLTE_ERROR; + srsran::console("Error configuring RF channels\n"); + return SRSRAN_ERROR; } nof_channels = args.nof_antennas * args.nof_carriers; @@ -98,11 +98,11 @@ int radio::init(const rf_args_t& args, phy_interface_radio* phy_) // Makes sure it is possible to have the same number of RF channels in each RF device if (nof_channels % device_args_list.size() != 0) { - srslte::console( + srsran::console( "Error: The number of required RF channels (%d) is not divisible between the number of RF devices (%zd).\n", nof_channels, device_args_list.size()); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } nof_channels_x_dev = nof_channels / device_args_list.size(); @@ -118,7 +118,7 @@ int radio::init(const rf_args_t& args, phy_interface_radio* phy_) for (uint32_t device_idx = 0; device_idx < (uint32_t)device_args_list.size(); device_idx++) { if (not open_dev(device_idx, args.device_name, device_args_list[device_idx])) { logger.error("Error opening RF device %d", device_idx); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } @@ -149,7 +149,7 @@ int radio::init(const rf_args_t& args, phy_interface_radio* phy_) } else { // Set same gain than for RX until power control sets a gain set_tx_gain(args.rx_gain); - srslte::console("\nWarning: TX gain was not set. Using open-loop power control (not working properly)\n\n"); + srsran::console("\nWarning: TX gain was not set. Using open-loop power control (not working properly)\n\n"); } // Set individual gains @@ -164,7 +164,7 @@ int radio::init(const rf_args_t& args, phy_interface_radio* phy_) logger.info( "Setting individual tx_gain=%.1f on dev=%d ch=%d", args.tx_gain_ch[i], rf_device_idx, rf_channel_idx); - if (srslte_rf_set_tx_gain_ch(&rf_devices[rf_device_idx], rf_channel_idx, args.tx_gain_ch[i]) < 0) { + if (srsran_rf_set_tx_gain_ch(&rf_devices[rf_device_idx], rf_channel_idx, args.tx_gain_ch[i]) < 0) { logger.error( "Setting channel tx_gain=%.1f on dev=%d ch=%d", args.tx_gain_ch[i], rf_device_idx, rf_channel_idx); } @@ -184,7 +184,7 @@ int radio::init(const rf_args_t& args, phy_interface_radio* phy_) logger.info( "Setting individual rx_gain=%.1f on dev=%d ch=%d", args.rx_gain_ch[i], rf_device_idx, rf_channel_idx); - if (srslte_rf_set_rx_gain_ch(&rf_devices[rf_device_idx], rf_channel_idx, args.rx_gain_ch[i]) < 0) { + if (srsran_rf_set_rx_gain_ch(&rf_devices[rf_device_idx], rf_channel_idx, args.rx_gain_ch[i]) < 0) { logger.error( "Setting channel rx_gain=%.1f on dev=%d ch=%d", args.rx_gain_ch[i], rf_device_idx, rf_channel_idx); } @@ -206,7 +206,7 @@ int radio::init(const rf_args_t& args, phy_interface_radio* phy_) // Frequency offset freq_offset = args.freq_offset; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } bool radio::is_init() @@ -218,8 +218,8 @@ void radio::stop() { // Stop Rx streams as soon as possible to avoid Overflows if (radio_is_streaming) { - for (srslte_rf_t& rf_device : rf_devices) { - srslte_rf_stop_rx_stream(&rf_device); + for (srsran_rf_t& rf_device : rf_devices) { + srsran_rf_stop_rx_stream(&rf_device); } } if (zeros) { @@ -227,16 +227,16 @@ void radio::stop() zeros = NULL; } if (is_initialized) { - for (srslte_rf_t& rf_device : rf_devices) { - srslte_rf_close(&rf_device); + for (srsran_rf_t& rf_device : rf_devices) { + srsran_rf_close(&rf_device); } } } void radio::reset() { - for (srslte_rf_t& rf_device : rf_devices) { - srslte_rf_stop_rx_stream(&rf_device); + for (srsran_rf_t& rf_device : rf_devices) { + srsran_rf_stop_rx_stream(&rf_device); } radio_is_streaming = false; usleep(100000); @@ -266,8 +266,8 @@ bool radio::start_agc(bool tx_gain_same_rx) if (!is_initialized) { return false; } - for (srslte_rf_t& rf_device : rf_devices) { - if (srslte_rf_start_gain_thread(&rf_device, tx_gain_same_rx)) { + for (srsran_rf_t& rf_device : rf_devices) { + if (srsran_rf_start_gain_thread(&rf_device, tx_gain_same_rx)) { ERROR("Error starting AGC Thread RF device"); return false; } @@ -319,15 +319,15 @@ bool radio::rx_now(rf_buffer_interface& buffer, rf_timestamp_interface& rxd_time } if (not radio_is_streaming) { - for (srslte_rf_t& rf_device : rf_devices) { - srslte_rf_start_rx_stream(&rf_device, false); + for (srsran_rf_t& rf_device : rf_devices) { + srsran_rf_start_rx_stream(&rf_device, false); } radio_is_streaming = true; // Flush buffers to compensate settling time if (rf_devices.size() > 1) { - for (srslte_rf_t& rf_device : rf_devices) { - srslte_rf_flush_buffer(&rf_device); + for (srsran_rf_t& rf_device : rf_devices) { + srsran_rf_flush_buffer(&rf_device); } } } @@ -340,7 +340,7 @@ bool radio::rx_now(rf_buffer_interface& buffer, rf_timestamp_interface& rxd_time if (ratio > 1) { for (uint32_t ch = 0; ch < nof_channels; ch++) { if (buffer.get(ch) and buffer_rx.get(ch)) { - srslte_resampler_fft_run(&decimators[ch], buffer_rx.get(ch), buffer.get(ch), buffer_rx.get_nof_samples()); + srsran_resampler_fft_run(&decimators[ch], buffer_rx.get(ch), buffer.get(ch), buffer_rx.get_nof_samples()); } } } @@ -348,7 +348,7 @@ bool radio::rx_now(rf_buffer_interface& buffer, rf_timestamp_interface& rxd_time return ret; } -bool radio::rx_dev(const uint32_t& device_idx, const rf_buffer_interface& buffer, srslte_timestamp_t* rxd_time) +bool radio::rx_dev(const uint32_t& device_idx, const rf_buffer_interface& buffer, srsran_timestamp_t* rxd_time) { if (!is_initialized) { return false; @@ -357,10 +357,10 @@ bool radio::rx_dev(const uint32_t& device_idx, const rf_buffer_interface& buffer time_t* full_secs = rxd_time ? &rxd_time->full_secs : nullptr; double* frac_secs = rxd_time ? &rxd_time->frac_secs : nullptr; - void* radio_buffers[SRSLTE_MAX_CHANNELS] = {}; + void* radio_buffers[SRSRAN_MAX_CHANNELS] = {}; // Discard channels not allocated, need to point to valid buffer - for (uint32_t i = 0; i < SRSLTE_MAX_CHANNELS; i++) { + for (uint32_t i = 0; i < SRSRAN_MAX_CHANNELS; i++) { radio_buffers[i] = dummy_buffers[i]; } @@ -379,14 +379,14 @@ bool radio::rx_dev(const uint32_t& device_idx, const rf_buffer_interface& buffer nof_samples = 0; } else { // Limit the number of samples to a maximum of 2 times the requested number of samples - nof_samples = SRSLTE_MIN(nof_samples + nof_samples_offset, 2 * nof_samples); + nof_samples = SRSRAN_MIN(nof_samples + nof_samples_offset, 2 * nof_samples); } // Subtract number of offset samples rx_offset_n.at(device_idx) = nof_samples_offset - ((int)nof_samples - (int)buffer.get_nof_samples()); int ret = - srslte_rf_recv_with_time_multi(&rf_devices[device_idx], radio_buffers, nof_samples, true, full_secs, frac_secs); + srsran_rf_recv_with_time_multi(&rf_devices[device_idx], radio_buffers, nof_samples, true, full_secs, frac_secs); // If the number of received samples filled the buffer, there is nothing else to do if (buffer.get_nof_samples() <= nof_samples) { @@ -398,7 +398,7 @@ bool radio::rx_dev(const uint32_t& device_idx, const rf_buffer_interface& buffer for (auto& b : radio_buffers) { if (b != nullptr) { cf_t* ptr = (cf_t*)b; - srslte_vec_cf_zero(&ptr[nof_samples], nof_zeros); + srsran_vec_cf_zero(&ptr[nof_samples], nof_zeros); } } @@ -434,7 +434,7 @@ bool radio::tx(rf_buffer_interface& buffer, const rf_timestamp_interface& tx_tim if (interpolators[0].ratio > 1) { for (uint32_t ch = 0; ch < nof_channels; ch++) { // Perform actual interpolation - srslte_resampler_fft_run(&interpolators[ch], buffer.get(ch), tx_buffer[ch].data(), nof_samples); + srsran_resampler_fft_run(&interpolators[ch], buffer.get(ch), tx_buffer[ch].data(), nof_samples); // Set the buffer pointer buffer.set(ch, tx_buffer[ch].data()); @@ -455,7 +455,7 @@ bool radio::tx(rf_buffer_interface& buffer, const rf_timestamp_interface& tx_tim bool radio::open_dev(const uint32_t& device_idx, const std::string& device_name, const std::string& devive_args) { - srslte_rf_t* rf_device = &rf_devices[device_idx]; + srsran_rf_t* rf_device = &rf_devices[device_idx]; char* dev_args = nullptr; if (devive_args != "auto") { @@ -467,33 +467,33 @@ bool radio::open_dev(const uint32_t& device_idx, const std::string& device_name, dev_name = (char*)device_name.c_str(); } - srslte::console("Opening %d channels in RF device=%s with args=%s\n", + srsran::console("Opening %d channels in RF device=%s with args=%s\n", nof_channels_x_dev, dev_name ? dev_name : "default", dev_args ? dev_args : "default"); - if (srslte_rf_open_devname(rf_device, dev_name, dev_args, nof_channels_x_dev)) { + if (srsran_rf_open_devname(rf_device, dev_name, dev_args, nof_channels_x_dev)) { logger.error("Error opening RF device"); return false; } // Suppress radio stdout - srslte_rf_suppress_stdout(rf_device); + srsran_rf_suppress_stdout(rf_device); // Register handler for processing O/U/L - srslte_rf_register_error_handler(rf_device, rf_msg_callback, this); + srsran_rf_register_error_handler(rf_device, rf_msg_callback, this); // Get device info - rf_info[device_idx] = *srslte_rf_get_info(rf_device); + rf_info[device_idx] = *srsran_rf_get_info(rf_device); return true; } -bool radio::tx_dev(const uint32_t& device_idx, rf_buffer_interface& buffer, const srslte_timestamp_t& tx_time_) +bool radio::tx_dev(const uint32_t& device_idx, rf_buffer_interface& buffer, const srsran_timestamp_t& tx_time_) { uint32_t nof_samples = buffer.get_nof_samples(); uint32_t sample_offset = 0; - srslte_rf_t* rf_device = &rf_devices[device_idx]; + srsran_rf_t* rf_device = &rf_devices[device_idx]; // Return instantly if the radio module is not initialised if (!is_initialized) { @@ -501,19 +501,19 @@ bool radio::tx_dev(const uint32_t& device_idx, rf_buffer_interface& buffer, cons } // Copy timestamp and add Tx time offset calibration - srslte_timestamp_t tx_time = tx_time_; + srsran_timestamp_t tx_time = tx_time_; if (!tx_adv_negative) { - srslte_timestamp_sub(&tx_time, 0, tx_adv_sec); + srsran_timestamp_sub(&tx_time, 0, tx_adv_sec); } else { - srslte_timestamp_add(&tx_time, 0, tx_adv_sec); + srsran_timestamp_add(&tx_time, 0, tx_adv_sec); } // Calculates transmission time overlap with previous transmission - srslte_timestamp_t ts_overlap = end_of_burst_time[device_idx]; - srslte_timestamp_sub(&ts_overlap, tx_time.full_secs, tx_time.frac_secs); + srsran_timestamp_t ts_overlap = end_of_burst_time[device_idx]; + srsran_timestamp_sub(&ts_overlap, tx_time.full_secs, tx_time.frac_secs); // Calculates number of overlap samples with previous transmission - int32_t past_nsamples = (int32_t)round(cur_tx_srate * srslte_timestamp_real(&ts_overlap)); + int32_t past_nsamples = (int32_t)round(cur_tx_srate * srsran_timestamp_real(&ts_overlap)); // if past_nsamples is positive, the current transmission overlaps with the previous transmission. If it is negative // there is a gap between the previous transmission and the current transmission. @@ -531,32 +531,32 @@ bool radio::tx_dev(const uint32_t& device_idx, rf_buffer_interface& buffer, cons // Prints discarded samples logger.debug("Detected RF overlap of %.1f us. Discarding %d samples. Power=%+.1f dBfs", - srslte_timestamp_real(&ts_overlap) * 1.0e6, + srsran_timestamp_real(&ts_overlap) * 1.0e6, past_nsamples, - srslte_convert_power_to_dB(srslte_vec_avg_power_cf(&buffer.get(0)[nof_samples], past_nsamples))); + srsran_convert_power_to_dB(srsran_vec_avg_power_cf(&buffer.get(0)[nof_samples], past_nsamples))); } else if (past_nsamples < 0 and not is_start_of_burst) { // if the gap is bigger than TX_MAX_GAP_ZEROS, stop burst - if (fabs(srslte_timestamp_real(&ts_overlap)) > tx_max_gap_zeros) { - logger.info("Detected RF gap of %.1f us. Sending end-of-burst.", srslte_timestamp_real(&ts_overlap) * 1.0e6); + if (fabs(srsran_timestamp_real(&ts_overlap)) > tx_max_gap_zeros) { + logger.info("Detected RF gap of %.1f us. Sending end-of-burst.", srsran_timestamp_real(&ts_overlap) * 1.0e6); tx_end(); } else { - logger.debug("Detected RF gap of %.1f us. Tx'ing zeroes.", srslte_timestamp_real(&ts_overlap) * 1.0e6); + logger.debug("Detected RF gap of %.1f us. Tx'ing zeroes.", srsran_timestamp_real(&ts_overlap) * 1.0e6); // Otherwise, transmit zeros uint32_t gap_nsamples = abs(past_nsamples); while (gap_nsamples > 0) { - // Transmission cannot exceed SRSLTE_SF_LEN_MAX (zeros buffer size limitation) - uint32_t nzeros = SRSLTE_MIN(gap_nsamples, SRSLTE_SF_LEN_MAX); + // Transmission cannot exceed SRSRAN_SF_LEN_MAX (zeros buffer size limitation) + uint32_t nzeros = SRSRAN_MIN(gap_nsamples, SRSRAN_SF_LEN_MAX); // Zeros transmission - int ret = srslte_rf_send_timed2(rf_device, + int ret = srsran_rf_send_timed2(rf_device, zeros, nzeros, end_of_burst_time[device_idx].full_secs, end_of_burst_time[device_idx].frac_secs, false, false); - if (ret < SRSLTE_SUCCESS) { + if (ret < SRSRAN_SUCCESS) { return false; } @@ -564,19 +564,19 @@ bool radio::tx_dev(const uint32_t& device_idx, rf_buffer_interface& buffer, cons gap_nsamples -= nzeros; // Increase timestamp - srslte_timestamp_add(&end_of_burst_time[device_idx], 0, (double)nzeros / cur_tx_srate); + srsran_timestamp_add(&end_of_burst_time[device_idx], 0, (double)nzeros / cur_tx_srate); } } } // Save possible end of burst time - srslte_timestamp_copy(&end_of_burst_time[device_idx], &tx_time); - srslte_timestamp_add(&end_of_burst_time[device_idx], 0, (double)nof_samples / cur_tx_srate); + srsran_timestamp_copy(&end_of_burst_time[device_idx], &tx_time); + srsran_timestamp_add(&end_of_burst_time[device_idx], 0, (double)nof_samples / cur_tx_srate); - void* radio_buffers[SRSLTE_MAX_CHANNELS] = {}; + void* radio_buffers[SRSRAN_MAX_CHANNELS] = {}; // Discard channels not allocated, need to point to valid buffer - for (uint32_t i = 0; i < SRSLTE_MAX_CHANNELS; i++) { + for (uint32_t i = 0; i < SRSRAN_MAX_CHANNELS; i++) { radio_buffers[i] = zeros; } @@ -585,10 +585,10 @@ bool radio::tx_dev(const uint32_t& device_idx, rf_buffer_interface& buffer, cons return false; } - int ret = srslte_rf_send_timed_multi( + int ret = srsran_rf_send_timed_multi( rf_device, radio_buffers, nof_samples, tx_time.full_secs, tx_time.frac_secs, true, is_start_of_burst, false); - return ret > SRSLTE_SUCCESS; + return ret > SRSRAN_SUCCESS; } void radio::tx_end() @@ -598,7 +598,7 @@ void radio::tx_end() } if (!is_start_of_burst) { for (uint32_t i = 0; i < (uint32_t)rf_devices.size(); i++) { - srslte_rf_send_timed2( + srsran_rf_send_timed2( &rf_devices[i], zeros, 0, end_of_burst_time[i].full_secs, end_of_burst_time[i].frac_secs, false, true); } is_start_of_burst = true; @@ -639,7 +639,7 @@ void radio::set_rx_freq(const uint32_t& carrier_idx, const double& freq) cur_rx_freqs[device_mapping.carrier_idx] = freq; for (uint32_t i = 0; i < nof_antennas; i++) { channel_mapping::device_mapping_t dm = rx_channel_mapping.get_device_mapping(carrier_idx, i); - srslte_rf_set_rx_freq(&rf_devices[dm.device_idx], dm.channel_idx, freq + freq_offset); + srsran_rf_set_rx_freq(&rf_devices[dm.device_idx], dm.channel_idx, freq + freq_offset); } } else { logger.error("set_rx_freq: physical_channel_idx=%d for %d antennas exceeds maximum channels (%d)", @@ -660,8 +660,8 @@ void radio::set_rx_gain(const float& gain) if (!is_initialized) { return; } - for (srslte_rf_t& rf_device : rf_devices) { - srslte_rf_set_rx_gain(&rf_device, gain); + for (srsran_rf_t& rf_device : rf_devices) { + srsran_rf_set_rx_gain(&rf_device, gain); } } @@ -670,8 +670,8 @@ void radio::set_rx_gain_th(const float& gain) if (!is_initialized) { return; } - for (srslte_rf_t& rf_device : rf_devices) { - srslte_rf_set_rx_gain_th(&rf_device, gain); + for (srsran_rf_t& rf_device : rf_devices) { + srsran_rf_set_rx_gain_th(&rf_device, gain); } } @@ -687,21 +687,21 @@ void radio::set_rx_srate(const double& srate) // If the sampling rate was not set, set it if (not std::isnormal(cur_rx_srate)) { - for (srslte_rf_t& rf_device : rf_devices) { - cur_rx_srate = srslte_rf_set_rx_srate(&rf_device, fix_srate_hz); + for (srsran_rf_t& rf_device : rf_devices) { + cur_rx_srate = srsran_rf_set_rx_srate(&rf_device, fix_srate_hz); } } // Update decimators uint32_t ratio = (uint32_t)ceil(cur_rx_srate / srate); for (uint32_t ch = 0; ch < nof_channels; ch++) { - srslte_resampler_fft_init(&decimators[ch], SRSLTE_RESAMPLER_MODE_DECIMATE, ratio); + srsran_resampler_fft_init(&decimators[ch], SRSRAN_RESAMPLER_MODE_DECIMATE, ratio); } decimator_busy = false; } else { - for (srslte_rf_t& rf_device : rf_devices) { - cur_rx_srate = srslte_rf_set_rx_srate(&rf_device, srate); + for (srsran_rf_t& rf_device : rf_devices) { + cur_rx_srate = srsran_rf_set_rx_srate(&rf_device, srate); } } } @@ -758,7 +758,7 @@ void radio::set_tx_freq(const uint32_t& carrier_idx, const double& freq) for (uint32_t i = 0; i < nof_antennas; i++) { device_mapping = tx_channel_mapping.get_device_mapping(carrier_idx, i); - srslte_rf_set_tx_freq(&rf_devices[device_mapping.device_idx], device_mapping.channel_idx, freq + freq_offset); + srsran_rf_set_tx_freq(&rf_devices[device_mapping.device_idx], device_mapping.channel_idx, freq + freq_offset); } } else { logger.error("set_tx_freq: physical_channel_idx=%d for %d antennas exceeds maximum channels (%d)", @@ -779,8 +779,8 @@ void radio::set_tx_gain(const float& gain) if (!is_initialized) { return; } - for (srslte_rf_t& rf_device : rf_devices) { - srslte_rf_set_tx_gain(&rf_device, gain); + for (srsran_rf_t& rf_device : rf_devices) { + srsran_rf_set_tx_gain(&rf_device, gain); } } @@ -794,7 +794,7 @@ float radio::get_rx_gain() if (!is_initialized) { return 0.0f; } - return (float)srslte_rf_get_rx_gain(&rf_devices[0]); + return (float)srsran_rf_get_rx_gain(&rf_devices[0]); } double radio::get_dev_cal_tx_adv_sec(const std::string& device_name) @@ -802,7 +802,7 @@ double radio::get_dev_cal_tx_adv_sec(const std::string& device_name) int nsamples = 0; /* Set time advance for each known device if in auto mode */ if (tx_adv_auto) { - /* This values have been calibrated using the prach_test_usrp tool in srsLTE */ + /* This values have been calibrated using the prach_test_usrp tool in srsRAN */ if (device_name == "uhd_b200") { double srate_khz = round(cur_tx_srate / 1e3); @@ -826,7 +826,7 @@ double radio::get_dev_cal_tx_adv_sec(const std::string& device_name) nsamples = 160; } else { /* Interpolate from known values */ - srslte::console( + srsran::console( "\nWarning TX/RX time offset for sampling rate %.0f KHz not calibrated. Using interpolated value\n\n", cur_tx_srate); nsamples = uhd_default_tx_adv_samples + (int)(cur_tx_srate * uhd_default_tx_adv_offset_sec); @@ -848,7 +848,7 @@ double radio::get_dev_cal_tx_adv_sec(const std::string& device_name) nsamples = 80; // to calc } else { /* Interpolate from known values */ - srslte::console( + srsran::console( "\nWarning TX/RX time offset for sampling rate %.0f KHz not calibrated. Using interpolated value\n\n", cur_tx_srate); nsamples = uhd_default_tx_adv_samples + (int)(cur_tx_srate * uhd_default_tx_adv_offset_sec); @@ -870,7 +870,7 @@ double radio::get_dev_cal_tx_adv_sec(const std::string& device_name) nsamples = 102; } else { /* Interpolate from known values */ - srslte::console( + srsran::console( "\nWarning TX/RX time offset for sampling rate %.0f KHz not calibrated. Using interpolated value\n\n", cur_tx_srate); nsamples = lime_default_tx_adv_samples + (int)(cur_tx_srate * lime_default_tx_adv_offset_sec); @@ -895,7 +895,7 @@ double radio::get_dev_cal_tx_adv_sec(const std::string& device_name) nsamples = 21; } else { /* Interpolate from known values */ - srslte::console( + srsran::console( "\nWarning TX/RX time offset for sampling rate %.0f KHz not calibrated. Using interpolated value\n\n", cur_tx_srate); nsamples = blade_default_tx_adv_samples + (int)(blade_default_tx_adv_offset_sec * cur_tx_srate); @@ -905,7 +905,7 @@ double radio::get_dev_cal_tx_adv_sec(const std::string& device_name) } } else { nsamples = tx_adv_nsamples; - srslte::console("Setting manual TX/RX offset to %d samples\n", nsamples); + srsran::console("Setting manual TX/RX offset to %d samples\n", nsamples); } // Calculate TX advance in seconds from samples and sampling rate @@ -923,24 +923,24 @@ void radio::set_tx_srate(const double& srate) if (std::isnormal(fix_srate_hz)) { // If the sampling rate was not set, set it if (not std::isnormal(cur_tx_srate)) { - for (srslte_rf_t& rf_device : rf_devices) { - cur_tx_srate = srslte_rf_set_tx_srate(&rf_device, fix_srate_hz); + for (srsran_rf_t& rf_device : rf_devices) { + cur_tx_srate = srsran_rf_set_tx_srate(&rf_device, fix_srate_hz); } } // Update interpolators uint32_t ratio = (uint32_t)ceil(cur_tx_srate / srate); for (uint32_t ch = 0; ch < nof_channels; ch++) { - srslte_resampler_fft_init(&interpolators[ch], SRSLTE_RESAMPLER_MODE_INTERPOLATE, ratio); + srsran_resampler_fft_init(&interpolators[ch], SRSRAN_RESAMPLER_MODE_INTERPOLATE, ratio); } } else { - for (srslte_rf_t& rf_device : rf_devices) { - cur_tx_srate = srslte_rf_set_tx_srate(&rf_device, srate); + for (srsran_rf_t& rf_device : rf_devices) { + cur_tx_srate = srsran_rf_set_tx_srate(&rf_device, srate); } } // Get calibrated advanced - tx_adv_sec = get_dev_cal_tx_adv_sec(std::string(srslte_rf_name(&rf_devices[0]))); + tx_adv_sec = get_dev_cal_tx_adv_sec(std::string(srsran_rf_name(&rf_devices[0]))); if (tx_adv_sec < 0) { tx_adv_sec *= -1; @@ -948,12 +948,12 @@ void radio::set_tx_srate(const double& srate) } } -srslte_rf_info_t* radio::get_info() +srsran_rf_info_t* radio::get_info() { if (!is_initialized) { return nullptr; } - return srslte_rf_get_info(&rf_devices[0]); + return srsran_rf_get_info(&rf_devices[0]); } bool radio::get_metrics(rf_metrics_t* metrics) @@ -963,30 +963,30 @@ bool radio::get_metrics(rf_metrics_t* metrics) return true; } -void radio::handle_rf_msg(srslte_rf_error_t error) +void radio::handle_rf_msg(srsran_rf_error_t error) { if (!is_initialized) { return; } - if (error.type == srslte_rf_error_t::SRSLTE_RF_ERROR_OVERFLOW) { + if (error.type == srsran_rf_error_t::SRSRAN_RF_ERROR_OVERFLOW) { rf_metrics.rf_o++; rf_metrics.rf_error = true; logger.info("Overflow"); // inform PHY about overflow phy->radio_overflow(); - } else if (error.type == srslte_rf_error_t::SRSLTE_RF_ERROR_UNDERFLOW) { + } else if (error.type == srsran_rf_error_t::SRSRAN_RF_ERROR_UNDERFLOW) { rf_metrics.rf_u++; rf_metrics.rf_error = true; logger.info("Underflow"); - } else if (error.type == srslte_rf_error_t::SRSLTE_RF_ERROR_LATE) { + } else if (error.type == srsran_rf_error_t::SRSRAN_RF_ERROR_LATE) { rf_metrics.rf_l++; rf_metrics.rf_error = true; logger.info("Late (detected in %s)", error.opt ? "rx call" : "asynchronous thread"); - } else if (error.type == srslte_rf_error_t::SRSLTE_RF_ERROR_RX) { + } else if (error.type == srsran_rf_error_t::SRSRAN_RF_ERROR_RX) { logger.error("Fatal radio error occured."); phy->radio_failure(); - } else if (error.type == srslte_rf_error_t::SRSLTE_RF_ERROR_OTHER) { + } else if (error.type == srsran_rf_error_t::SRSRAN_RF_ERROR_OTHER) { std::string str(error.msg); str.erase(std::remove(str.begin(), str.end(), '\n'), str.end()); str.erase(std::remove(str.begin(), str.end(), '\r'), str.end()); @@ -994,7 +994,7 @@ void radio::handle_rf_msg(srslte_rf_error_t error) } } -void radio::rf_msg_callback(void* arg, srslte_rf_error_t error) +void radio::rf_msg_callback(void* arg, srsran_rf_error_t error) { radio* h = (radio*)arg; if (arg != nullptr) { @@ -1006,10 +1006,10 @@ bool radio::map_channels(const channel_mapping& map, uint32_t device_idx, uint32_t sample_offset, const rf_buffer_interface& buffer, - void* radio_buffers[SRSLTE_MAX_CHANNELS]) + void* radio_buffers[SRSRAN_MAX_CHANNELS]) { // Conversion from safe C++ std::array to the unsafe C interface. We must ensure that the RF driver implementation - // accepts up to SRSLTE_MAX_CHANNELS buffers + // accepts up to SRSRAN_MAX_CHANNELS buffers for (uint32_t i = 0; i < nof_carriers; i++) { // Skip if not allocated if (not map.is_allocated(i)) { @@ -1074,4 +1074,4 @@ bool radio::config_rf_channels(const rf_args_t& args) return true; } -} // namespace srslte +} // namespace srsran diff --git a/lib/src/radio/test/CMakeLists.txt b/lib/src/radio/test/CMakeLists.txt index fa3d79bca..e4eedbcbc 100644 --- a/lib/src/radio/test/CMakeLists.txt +++ b/lib/src/radio/test/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -8,7 +8,7 @@ if(RF_FOUND) add_executable(benchmark_radio benchmark_radio.cc) - target_link_libraries(benchmark_radio srslte_common srslte_phy srslte_radio) + target_link_libraries(benchmark_radio srsran_common srsran_phy srsran_radio) if(SRSGUI_FOUND) include_directories(${SRSGUI_INCLUDE_DIRS}) target_link_libraries(benchmark_radio ${SRSGUI_LIBRARIES}) diff --git a/lib/src/radio/test/benchmark_radio.cc b/lib/src/radio/test/benchmark_radio.cc index dfd939238..26c9f3f23 100644 --- a/lib/src/radio/test/benchmark_radio.cc +++ b/lib/src/radio/test/benchmark_radio.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -18,21 +18,21 @@ extern "C" { #endif -#include "srslte/phy/common/timestamp.h" +#include "srsran/phy/common/timestamp.h" #ifdef __cplusplus } //#undef I // Fix complex.h #define I nastiness when using C++ #endif -#include "srslte/phy/utils/debug.h" -#include "srslte/radio/radio.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/radio/radio.h" -using namespace srslte; +using namespace srsran; -#define SRSLTE_MAX_RADIOS 3 +#define SRSRAN_MAX_RADIOS 3 -static std::array radios_args = {}; +static std::array radios_args = {}; static char radio_device[64]; static std::string file_pattern = "radio%d.dat"; @@ -41,7 +41,7 @@ static uint32_t nof_radios = 1; static uint32_t nof_ports = 1; static double srate = 1.92e6; /* Hz */ static double duration = 0.01; /* in seconds, 10 ms by default */ -static cf_t* buffers[SRSLTE_MAX_RADIOS][SRSLTE_MAX_PORTS]; +static cf_t* buffers[SRSRAN_MAX_RADIOS][SRSRAN_MAX_PORTS]; static bool tx_enable = false; static bool sim_rate_change = false; static bool measure_delay = false; @@ -57,11 +57,11 @@ static pthread_t radio_thread; static pthread_t plot_thread; static sem_t plot_sem; static uint32_t plot_sf_idx = 0; -static plot_real_t fft_plot[SRSLTE_MAX_RADIOS] = {}; -static cf_t* fft_plot_buffer[SRSLTE_MAX_CHANNELS] = {}; +static plot_real_t fft_plot[SRSRAN_MAX_RADIOS] = {}; +static cf_t* fft_plot_buffer[SRSRAN_MAX_CHANNELS] = {}; static float* fft_plot_temp = nullptr; static uint32_t fft_plot_buffer_size; -srslte_dft_plan_t dft_spectrum = {}; +srsran_dft_plan_t dft_spectrum = {}; #endif /* ENABLE_GUI */ static bool fft_plot_enable = false; @@ -75,8 +75,8 @@ void usage(char* prog) printf("\t-b Arguments for second radio [Default %s]\n", radios_args[1].c_str()); printf("\t-c Arguments for third radio [Default %s]\n", radios_args[2].c_str()); printf("\t-d Radio device [Default %s]\n", radio_device); - printf("\t-r number of radios 1-%d [Default %d]\n", SRSLTE_MAX_RADIOS, nof_radios); - printf("\t-p number of ports 1-%d [Default %d]\n", SRSLTE_MAX_PORTS, nof_ports); + printf("\t-r number of radios 1-%d [Default %d]\n", SRSRAN_MAX_RADIOS, nof_radios); + printf("\t-p number of ports 1-%d [Default %d]\n", SRSRAN_MAX_PORTS, nof_ports); printf("\t-s sampling rate [Default %.0f]\n", srate); printf("\t-t duration in seconds [Default %.3f]\n", duration); printf("\t-m measure delay [Default %s]\n", (measure_delay) ? "enabled" : "disabled"); @@ -85,7 +85,7 @@ void usage(char* prog) printf("\t-w capture [Default %s]\n", (capture) ? "enabled" : "disabled"); printf("\t-o Output file pattern [Default %s]\n", file_pattern.c_str()); printf("\t-F Display spectrum [Default %s]\n", (fft_plot_enable) ? "enabled" : "disabled"); - printf("\t-v Set srslte_verbose to info (v) or debug (vv) [Default none]\n"); + printf("\t-v Set srsran_verbose to info (v) or debug (vv) [Default none]\n"); printf("\t-h show this message\n"); } @@ -145,7 +145,7 @@ void parse_args(int argc, char** argv) fft_plot_enable ^= true; break; case 'v': - srslte_verbose++; + srsran_verbose++; break; case 'h': default: @@ -155,7 +155,7 @@ void parse_args(int argc, char** argv) } } -static SRSLTE_AGC_CALLBACK(set_gain_callback) +static SRSRAN_AGC_CALLBACK(set_gain_callback) { auto r = (radio*)h; r->set_rx_gain_th(gain_db); @@ -189,10 +189,10 @@ static void* plot_thread_run(void* arg) for (uint32_t p = 0; p < nof_ports; p++) { uint32_t plot_idx = r * nof_ports + p; - srslte_vec_abs_square_cf(fft_plot_buffer[plot_idx], fft_plot_temp, fft_plot_buffer_size); + srsran_vec_abs_square_cf(fft_plot_buffer[plot_idx], fft_plot_temp, fft_plot_buffer_size); for (uint32_t j = 0; j < fft_plot_buffer_size; j++) { - fft_plot_temp[j] = srslte_convert_power_to_dB(fft_plot_temp[j]); + fft_plot_temp[j] = srsran_convert_power_to_dB(fft_plot_temp[j]); } plot_real_setNewData(&fft_plot[plot_idx], fft_plot_temp, fft_plot_buffer_size); @@ -214,26 +214,26 @@ static int init_plots(uint32_t frame_size) for (uint32_t r = 0; r < nof_radios; r++) { for (uint32_t p = 0; p < nof_ports; p++) { uint32_t plot_idx = r * nof_ports + p; - fft_plot_buffer[plot_idx] = srslte_vec_cf_malloc(frame_size); + fft_plot_buffer[plot_idx] = srsran_vec_cf_malloc(frame_size); if (!fft_plot_buffer[plot_idx]) { ERROR("Error: Allocating buffer"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } } - fft_plot_temp = srslte_vec_f_malloc(frame_size); + fft_plot_temp = srsran_vec_f_malloc(frame_size); if (!fft_plot_temp) { ERROR("Error: Allocating buffer"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_dft_plan_c(&dft_spectrum, frame_size, SRSLTE_DFT_FORWARD)) { + if (srsran_dft_plan_c(&dft_spectrum, frame_size, SRSRAN_DFT_FORWARD)) { ERROR("Creating DFT spectrum plan"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - srslte_dft_plan_set_mirror(&dft_spectrum, true); + srsran_dft_plan_set_mirror(&dft_spectrum, true); fft_plot_buffer_size = frame_size; pthread_attr_t attr; @@ -247,7 +247,7 @@ static int init_plots(uint32_t frame_size) exit(-1); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } #endif /* ENABLE_GUI */ @@ -263,23 +263,23 @@ private: uint32_t num_failures = 0; }; -static int ret = SRSLTE_ERROR; +static int ret = SRSRAN_ERROR; static void* radio_thread_run(void* arg) { - radio* radio_h[SRSLTE_MAX_RADIOS] = {nullptr}; - srslte::rf_timestamp_t ts_prev[SRSLTE_MAX_RADIOS], ts_rx[SRSLTE_MAX_RADIOS], ts_tx; + radio* radio_h[SRSRAN_MAX_RADIOS] = {nullptr}; + srsran::rf_timestamp_t ts_prev[SRSRAN_MAX_RADIOS], ts_rx[SRSRAN_MAX_RADIOS], ts_tx; uint32_t nof_gaps = 0; char filename[256] = {}; - srslte_filesink_t filesink[SRSLTE_MAX_RADIOS] = {}; - srslte_dft_plan_t dft_plan = {}, idft_plan = {}; - srslte_agc_t agc[SRSLTE_MAX_RADIOS] = {}; + srsran_filesink_t filesink[SRSRAN_MAX_RADIOS] = {}; + srsran_dft_plan_t dft_plan = {}, idft_plan = {}; + srsran_agc_t agc[SRSRAN_MAX_RADIOS] = {}; phy_dummy phy; - srslte::rf_metrics_t rf_metrics = {}; + srsran::rf_metrics_t rf_metrics = {}; - rf_buffer_t rf_buffers[SRSLTE_MAX_RADIOS] = {}; + rf_buffer_t rf_buffers[SRSRAN_MAX_RADIOS] = {}; - float delay_idx[SRSLTE_MAX_RADIOS] = {0}; + float delay_idx[SRSRAN_MAX_RADIOS] = {0}; uint32_t delay_count = 0; double current_rate = srate; @@ -297,14 +297,14 @@ static void* radio_thread_run(void* arg) goto clean_exit; } - for (uint32_t p = 0; p < SRSLTE_MAX_PORTS; p++) { + for (uint32_t p = 0; p < SRSRAN_MAX_PORTS; p++) { buffers[r][p] = NULL; } } for (uint32_t r = 0; r < nof_radios; r++) { for (uint32_t p = 0; p < nof_ports; p++) { - buffers[r][p] = srslte_vec_cf_malloc(frame_size); + buffers[r][p] = srsran_vec_cf_malloc(frame_size); if (!buffers[r][p]) { ERROR("Error: Allocating buffer (%d,%d)", r, p); goto clean_exit; @@ -335,7 +335,7 @@ static void* radio_thread_run(void* arg) radio_args.tx_gain = agc_enable ? -1 : rf_gain; radio_args.device_name = radio_device; - if (radio_h[r]->init(radio_args, &phy) != SRSLTE_SUCCESS) { + if (radio_h[r]->init(radio_args, &phy) != SRSRAN_SUCCESS) { fprintf(stderr, "Error: Calling radio_multi constructor\n"); goto clean_exit; } @@ -344,7 +344,7 @@ static void* radio_thread_run(void* arg) // enable and init agc if (agc_enable) { - if (srslte_agc_init_uhd(&agc[r], SRSLTE_AGC_MODE_PEAK_AMPLITUDE, 0, set_gain_callback, radio_h[r])) { + if (srsran_agc_init_uhd(&agc[r], SRSRAN_AGC_MODE_PEAK_AMPLITUDE, 0, set_gain_callback, radio_h[r])) { fprintf(stderr, "Error: Initiating AGC %d\n", r); goto clean_exit; } @@ -362,7 +362,7 @@ static void* radio_thread_run(void* arg) for (uint32_t r = 0; r < nof_radios; r++) { snprintf(filename, 256, file_pattern.c_str(), r); INFO("Opening filesink %s for radio %d", filename, r); - if (srslte_filesink_init(&filesink[r], filename, SRSLTE_COMPLEX_FLOAT_BIN)) { + if (srsran_filesink_init(&filesink[r], filename, SRSRAN_COMPLEX_FLOAT_BIN)) { ERROR("Initiating filesink for radio %d", r); goto clean_exit; } @@ -372,11 +372,11 @@ static void* radio_thread_run(void* arg) /* If measure delay between radios */ if (measure_delay) { if (nof_radios > 1) { - if (srslte_dft_plan_c(&dft_plan, frame_size, SRSLTE_DFT_FORWARD)) { + if (srsran_dft_plan_c(&dft_plan, frame_size, SRSRAN_DFT_FORWARD)) { ERROR("Creating DFT plan"); goto clean_exit; } - if (srslte_dft_plan_c(&idft_plan, frame_size, SRSLTE_DFT_BACKWARD)) { + if (srsran_dft_plan_c(&idft_plan, frame_size, SRSRAN_DFT_BACKWARD)) { ERROR("Creating IDFT plan"); goto clean_exit; } @@ -396,8 +396,8 @@ static void* radio_thread_run(void* arg) printf( "Start capturing %d sub-frames of %d samples (approx. %ds) ...\n", nof_frames, frame_size, (nof_frames / 1000)); - for (int i = 0; i < SRSLTE_MAX_RADIOS; i++) { - for (int j = 0; j < SRSLTE_MAX_PORTS; j++) { + for (int i = 0; i < SRSRAN_MAX_RADIOS; i++) { + for (int j = 0; j < SRSRAN_MAX_PORTS; j++) { rf_buffers[i].set(j, buffers[i][j]); } } @@ -422,7 +422,7 @@ static void* radio_thread_run(void* arg) frame_size = (uint32_t)(current_rate / 1000.0); /* 1 ms at srate */ int gap = 0; - frame_size = SRSLTE_MIN(frame_size, nof_samples); + frame_size = SRSRAN_MIN(frame_size, nof_samples); // receive each radio for (uint32_t r = 0; r < nof_radios; r++) { @@ -433,7 +433,7 @@ static void* radio_thread_run(void* arg) // run agc if (agc_enable) { for (uint32_t r = 0; r < nof_radios; r++) { - srslte_agc_process(&agc[r], buffers[r][0], frame_size); + srsran_agc_process(&agc[r], buffers[r][0], frame_size); } } @@ -450,7 +450,7 @@ static void* radio_thread_run(void* arg) /* Store baseband in file */ if (capture) { for (uint32_t r = 0; r < nof_radios; r++) { - srslte_filesink_write_multi(&filesink[r], (void**)buffers[r], frame_size, nof_ports); + srsran_filesink_write_multi(&filesink[r], (void**)buffers[r], frame_size, nof_ports); } } @@ -461,7 +461,7 @@ static void* radio_thread_run(void* arg) for (uint32_t r = 0; r < nof_radios; r++) { for (uint32_t p = 0; p < nof_ports; p++) { uint32_t plot_idx = r * nof_ports + p; - srslte_dft_run(&dft_spectrum, buffers[r][p], fft_plot_buffer[plot_idx]); + srsran_dft_run(&dft_spectrum, buffers[r][p], fft_plot_buffer[plot_idx]); } } } else { @@ -474,15 +474,15 @@ static void* radio_thread_run(void* arg) /* Compute delay between radios */ if (measure_delay && frame_size != nof_samples) { for (uint32_t r = 0; r < nof_radios; r++) { - srslte_dft_run_c(&dft_plan, buffers[r][0], buffers[r][0]); + srsran_dft_run_c(&dft_plan, buffers[r][0], buffers[r][0]); } for (uint32_t r = 1; r < nof_radios; r++) { int relative_delay = 0; - srslte_vec_prod_conj_ccc(buffers[0][0], buffers[r][0], buffers[r][0], frame_size); - srslte_dft_run_c(&idft_plan, buffers[r][0], buffers[r][0]); - relative_delay = srslte_vec_max_abs_ci(buffers[r][0], frame_size); + srsran_vec_prod_conj_ccc(buffers[0][0], buffers[r][0], buffers[r][0], frame_size); + srsran_dft_run_c(&idft_plan, buffers[r][0], buffers[r][0]); + relative_delay = srsran_vec_max_abs_ci(buffers[r][0], frame_size); if (relative_delay > (int)frame_size / 2) { relative_delay -= frame_size; @@ -502,20 +502,20 @@ static void* radio_thread_run(void* arg) /* Check sample gaps */ if (i != 0) { for (uint32_t r = 0; r < nof_radios; r++) { - srslte_timestamp_t ts_diff; + srsran_timestamp_t ts_diff; - srslte_timestamp_copy(&ts_diff, ts_rx[r].get_ptr(0)); - srslte_timestamp_sub(&ts_diff, ts_prev[r].get_ptr(0)->full_secs, ts_prev[r].get_ptr(0)->frac_secs); - gap = (int32_t)round(srslte_timestamp_real(&ts_diff) * current_rate) - (int32_t)frame_size; + srsran_timestamp_copy(&ts_diff, ts_rx[r].get_ptr(0)); + srsran_timestamp_sub(&ts_diff, ts_prev[r].get_ptr(0)->full_secs, ts_prev[r].get_ptr(0)->frac_secs); + gap = (int32_t)round(srsran_timestamp_real(&ts_diff) * current_rate) - (int32_t)frame_size; if (gap != 0) { INFO("Timestamp gap (%d samples) detected! Frame %d/%d. ts=%.9f+%.9f=%.9f", gap, i + 1, nof_frames, - srslte_timestamp_real(ts_prev[r].get_ptr(0)), - srslte_timestamp_real(&ts_diff), - srslte_timestamp_real(ts_rx[r].get_ptr(0))); + srsran_timestamp_real(ts_prev[r].get_ptr(0)), + srsran_timestamp_real(&ts_diff), + srsran_timestamp_real(ts_rx[r].get_ptr(0))); nof_gaps++; } } @@ -538,7 +538,7 @@ static void* radio_thread_run(void* arg) rf_metrics.rf_u); if (nof_gaps == 0 && rf_metrics.rf_l == 0 && rf_metrics.rf_o == 0 && rf_metrics.rf_u == 0) { - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } if (measure_delay && delay_count > 0) { @@ -565,16 +565,16 @@ clean_exit: } if (capture) { - srslte_filesink_free(&filesink[r]); + srsran_filesink_free(&filesink[r]); } } - srslte_dft_plan_free(&dft_plan); - srslte_dft_plan_free(&idft_plan); + srsran_dft_plan_free(&dft_plan); + srsran_dft_plan_free(&idft_plan); #ifdef ENABLE_GUI pthread_join(plot_thread, NULL); - srslte_dft_plan_free(&dft_spectrum); + srsran_dft_plan_free(&dft_spectrum); for (uint32_t r = 0; r < nof_radios; r++) { for (uint32_t p = 0; p < nof_ports; p++) { uint32_t plot_idx = r * nof_ports + p; diff --git a/lib/src/srslog/CMakeLists.txt b/lib/src/srslog/CMakeLists.txt index 76ca5934b..7800e8c3a 100644 --- a/lib/src/srslog/CMakeLists.txt +++ b/lib/src/srslog/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of diff --git a/lib/src/srslog/backend_worker.cpp b/lib/src/srslog/backend_worker.cpp index 1ca65af51..50692fdd0 100644 --- a/lib/src/srslog/backend_worker.cpp +++ b/lib/src/srslog/backend_worker.cpp @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,7 +11,7 @@ */ #include "backend_worker.h" -#include "srslte/srslog/sink.h" +#include "srsran/srslog/sink.h" using namespace srslog; diff --git a/lib/src/srslog/backend_worker.h b/lib/src/srslog/backend_worker.h index 1dae40a90..92612b77b 100644 --- a/lib/src/srslog/backend_worker.h +++ b/lib/src/srslog/backend_worker.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,9 +13,9 @@ #ifndef SRSLOG_BACKEND_WORKER_H #define SRSLOG_BACKEND_WORKER_H -#include "srslte/srslog/detail/log_entry.h" -#include "srslte/srslog/detail/support/work_queue.h" -#include "srslte/srslog/shared_types.h" +#include "srsran/srslog/detail/log_entry.h" +#include "srsran/srslog/detail/support/work_queue.h" +#include "srsran/srslog/shared_types.h" #include #include diff --git a/lib/src/srslog/bundled/fmt/CMakeLists.txt b/lib/src/srslog/bundled/fmt/CMakeLists.txt index 84e7e4cee..e1a92ee3a 100644 --- a/lib/src/srslog/bundled/fmt/CMakeLists.txt +++ b/lib/src/srslog/bundled/fmt/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -11,4 +11,4 @@ set(SOURCES os.cc) add_library(fmt STATIC ${SOURCES}) -target_include_directories(fmt PUBLIC ../../../../include/srslte/srslog/bundled) +target_include_directories(fmt PUBLIC ../../../../include/srsran/srslog/bundled) diff --git a/lib/src/srslog/event_trace.cpp b/lib/src/srslog/event_trace.cpp index 924492e79..7d84f018c 100644 --- a/lib/src/srslog/event_trace.cpp +++ b/lib/src/srslog/event_trace.cpp @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,9 +10,9 @@ * */ -#include "srslte/srslog/event_trace.h" +#include "srsran/srslog/event_trace.h" #include "sinks/buffered_file_sink.h" -#include "srslte/srslog/srslog.h" +#include "srsran/srslog/srslog.h" #include #undef trace_duration_begin diff --git a/lib/src/srslog/formatters/CMakeLists.txt b/lib/src/srslog/formatters/CMakeLists.txt index 20bc911e0..7d35370d2 100644 --- a/lib/src/srslog/formatters/CMakeLists.txt +++ b/lib/src/srslog/formatters/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of diff --git a/lib/src/srslog/formatters/json_formatter.cpp b/lib/src/srslog/formatters/json_formatter.cpp index 8923107cb..499703a1d 100644 --- a/lib/src/srslog/formatters/json_formatter.cpp +++ b/lib/src/srslog/formatters/json_formatter.cpp @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,7 +11,7 @@ */ #include "json_formatter.h" -#include "srslte/srslog/detail/log_entry_metadata.h" +#include "srsran/srslog/detail/log_entry_metadata.h" using namespace srslog; diff --git a/lib/src/srslog/formatters/json_formatter.h b/lib/src/srslog/formatters/json_formatter.h index d7c886999..4c7391835 100644 --- a/lib/src/srslog/formatters/json_formatter.h +++ b/lib/src/srslog/formatters/json_formatter.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,7 +13,7 @@ #ifndef SRSLOG_JSON_FORMATTER_H #define SRSLOG_JSON_FORMATTER_H -#include "srslte/srslog/formatter.h" +#include "srsran/srslog/formatter.h" namespace srslog { diff --git a/lib/src/srslog/formatters/text_formatter.cpp b/lib/src/srslog/formatters/text_formatter.cpp index 82d74e0ea..7e620f2a7 100644 --- a/lib/src/srslog/formatters/text_formatter.cpp +++ b/lib/src/srslog/formatters/text_formatter.cpp @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,8 +11,8 @@ */ #include "text_formatter.h" -#include "srslte/srslog/bundled/fmt/chrono.h" -#include "srslte/srslog/detail/log_entry_metadata.h" +#include "srsran/srslog/bundled/fmt/chrono.h" +#include "srsran/srslog/detail/log_entry_metadata.h" using namespace srslog; diff --git a/lib/src/srslog/formatters/text_formatter.h b/lib/src/srslog/formatters/text_formatter.h index 336ad326a..4dc1d8407 100644 --- a/lib/src/srslog/formatters/text_formatter.h +++ b/lib/src/srslog/formatters/text_formatter.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,7 +13,7 @@ #ifndef SRSLOG_TEXT_FORMATTER_H #define SRSLOG_TEXT_FORMATTER_H -#include "srslte/srslog/formatter.h" +#include "srsran/srslog/formatter.h" namespace srslog { diff --git a/lib/src/srslog/log_backend_impl.h b/lib/src/srslog/log_backend_impl.h index 0d8a47f26..02b9548ad 100644 --- a/lib/src/srslog/log_backend_impl.h +++ b/lib/src/srslog/log_backend_impl.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -14,7 +14,7 @@ #define SRSLOG_LOG_BACKEND_IMPL_H #include "backend_worker.h" -#include "srslte/srslog/detail/log_backend.h" +#include "srsran/srslog/detail/log_backend.h" namespace srslog { diff --git a/lib/src/srslog/object_repository.h b/lib/src/srslog/object_repository.h index a16769bc2..a10097ae3 100644 --- a/lib/src/srslog/object_repository.h +++ b/lib/src/srslog/object_repository.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,7 +13,7 @@ #ifndef SRSLOG_OBJECT_REPOSITORY_H #define SRSLOG_OBJECT_REPOSITORY_H -#include "srslte/srslog/detail/support/thread_utils.h" +#include "srsran/srslog/detail/support/thread_utils.h" #include #include diff --git a/lib/src/srslog/sinks/buffered_file_sink.h b/lib/src/srslog/sinks/buffered_file_sink.h index e2908d38c..310b5596f 100644 --- a/lib/src/srslog/sinks/buffered_file_sink.h +++ b/lib/src/srslog/sinks/buffered_file_sink.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -14,7 +14,7 @@ #define SRSLOG_BUFFERED_FILE_SINK_H #include "file_utils.h" -#include "srslte/srslog/sink.h" +#include "srsran/srslog/sink.h" namespace srslog { diff --git a/lib/src/srslog/sinks/file_sink.h b/lib/src/srslog/sinks/file_sink.h index fe61e09eb..c4dcaf77c 100644 --- a/lib/src/srslog/sinks/file_sink.h +++ b/lib/src/srslog/sinks/file_sink.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -14,7 +14,7 @@ #define SRSLOG_FILE_SINK_H #include "file_utils.h" -#include "srslte/srslog/sink.h" +#include "srsran/srslog/sink.h" namespace srslog { diff --git a/lib/src/srslog/sinks/file_utils.h b/lib/src/srslog/sinks/file_utils.h index 4499568ec..b46f06b9f 100644 --- a/lib/src/srslog/sinks/file_utils.h +++ b/lib/src/srslog/sinks/file_utils.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,9 +13,9 @@ #ifndef SRSLOG_FILE_UTILS_H #define SRSLOG_FILE_UTILS_H -#include "srslte/srslog/bundled/fmt/format.h" -#include "srslte/srslog/detail/support/error_string.h" -#include "srslte/srslog/detail/support/memory_buffer.h" +#include "srsran/srslog/bundled/fmt/format.h" +#include "srsran/srslog/detail/support/error_string.h" +#include "srsran/srslog/detail/support/memory_buffer.h" namespace srslog { diff --git a/lib/src/srslog/sinks/stream_sink.h b/lib/src/srslog/sinks/stream_sink.h index 7404a17db..ef129fa9b 100644 --- a/lib/src/srslog/sinks/stream_sink.h +++ b/lib/src/srslog/sinks/stream_sink.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,7 +13,7 @@ #ifndef SRSLOG_STREAM_SINK_H #define SRSLOG_STREAM_SINK_H -#include "srslte/srslog/sink.h" +#include "srsran/srslog/sink.h" namespace srslog { diff --git a/lib/src/srslog/srslog.cpp b/lib/src/srslog/srslog.cpp index a87164bc4..9026a63f8 100644 --- a/lib/src/srslog/srslog.cpp +++ b/lib/src/srslog/srslog.cpp @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,7 +10,7 @@ * */ -#include "srslte/srslog/srslog.h" +#include "srsran/srslog/srslog.h" #include "formatters/json_formatter.h" #include "sinks/file_sink.h" #include "srslog_instance.h" diff --git a/lib/src/srslog/srslog_c.cpp b/lib/src/srslog/srslog_c.cpp index f178d4f94..26d483795 100644 --- a/lib/src/srslog/srslog_c.cpp +++ b/lib/src/srslog/srslog_c.cpp @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,8 +10,8 @@ * */ -#include "srslte/srslog/srslog_c.h" -#include "srslte/srslog/srslog.h" +#include "srsran/srslog/srslog_c.h" +#include "srsran/srslog/srslog.h" #include using namespace srslog; diff --git a/lib/src/srslog/srslog_instance.h b/lib/src/srslog/srslog_instance.h index bdc1fac93..1a55a5391 100644 --- a/lib/src/srslog/srslog_instance.h +++ b/lib/src/srslog/srslog_instance.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -17,7 +17,7 @@ #include "log_backend_impl.h" #include "object_repository.h" #include "sinks/stream_sink.h" -#include "srslte/srslog/log_channel.h" +#include "srsran/srslog/log_channel.h" namespace srslog { diff --git a/lib/src/system/sys_metrics_processor.cc b/lib/src/system/sys_metrics_processor.cc index 8e11ebbe0..89e52835d 100644 --- a/lib/src/system/sys_metrics_processor.cc +++ b/lib/src/system/sys_metrics_processor.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,13 +10,13 @@ * */ -#include "srslte/system/sys_metrics_processor.h" +#include "srsran/system/sys_metrics_processor.h" #include #include #include #include -using namespace srslte; +using namespace srsran; sys_metrics_processor::proc_stats_info::proc_stats_info() { diff --git a/lib/src/upper/CMakeLists.txt b/lib/src/upper/CMakeLists.txt index f3398b63a..df43f663e 100644 --- a/lib/src/upper/CMakeLists.txt +++ b/lib/src/upper/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -20,6 +20,6 @@ set(SOURCES gtpu.cc rlc_um_nr.cc rlc_am_nr.cc) -add_library(srslte_upper STATIC ${SOURCES}) -target_link_libraries(srslte_upper srslte_common srslte_asn1) -INSTALL(TARGETS srslte_upper DESTINATION ${LIBRARY_DIR}) \ No newline at end of file +add_library(srsran_upper STATIC ${SOURCES}) +target_link_libraries(srsran_upper srsran_common srsran_asn1) +INSTALL(TARGETS srsran_upper DESTINATION ${LIBRARY_DIR}) \ No newline at end of file diff --git a/lib/src/upper/gtpu.cc b/lib/src/upper/gtpu.cc index 2b22923ea..aa616c411 100644 --- a/lib/src/upper/gtpu.cc +++ b/lib/src/upper/gtpu.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,12 +10,12 @@ * */ -#include "srslte/upper/gtpu.h" -#include "srslte/common/int_helpers.h" +#include "srsran/upper/gtpu.h" +#include "srsran/common/int_helpers.h" #include #include -namespace srslte { +namespace srsran { const static size_t HEADER_PDCP_PDU_NUMBER_SIZE = 4; @@ -23,7 +23,7 @@ const static size_t HEADER_PDCP_PDU_NUMBER_SIZE = 4; * Header pack/unpack helper functions * Ref: 3GPP TS 29.281 v10.1.0 Section 5 ***************************************************************************/ -bool gtpu_write_header(gtpu_header_t* header, srslte::byte_buffer_t* pdu, srslog::basic_logger& logger) +bool gtpu_write_header(gtpu_header_t* header, srsran::byte_buffer_t* pdu, srslog::basic_logger& logger) { // flags if (!gtpu_supported_flags_check(header, logger)) { @@ -103,7 +103,7 @@ bool gtpu_write_header(gtpu_header_t* header, srslte::byte_buffer_t* pdu, srslog return true; } -bool gtpu_read_ext_header(srslte::byte_buffer_t* pdu, +bool gtpu_read_ext_header(srsran::byte_buffer_t* pdu, uint8_t** ptr, gtpu_header_t* header, srslog::basic_logger& logger) @@ -127,7 +127,7 @@ bool gtpu_read_ext_header(srslte::byte_buffer_t* pdu, return true; } -bool gtpu_read_header(srslte::byte_buffer_t* pdu, gtpu_header_t* header, srslog::basic_logger& logger) +bool gtpu_read_header(srsran::byte_buffer_t* pdu, gtpu_header_t* header, srslog::basic_logger& logger) { uint8_t* ptr = pdu->msg; @@ -192,4 +192,4 @@ void gtpu_ntoa(fmt::memory_buffer& buffer, uint32_t addr) } } -} // namespace srslte +} // namespace srsran diff --git a/lib/src/upper/pdcp.cc b/lib/src/upper/pdcp.cc index faee2cd09..6b387bbf8 100644 --- a/lib/src/upper/pdcp.cc +++ b/lib/src/upper/pdcp.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,12 +10,12 @@ * */ -#include "srslte/upper/pdcp.h" -#include "srslte/upper/pdcp_entity_nr.h" +#include "srsran/upper/pdcp.h" +#include "srsran/upper/pdcp_entity_nr.h" -namespace srslte { +namespace srsran { -pdcp::pdcp(srslte::task_sched_handle task_sched_, const char* logname) : +pdcp::pdcp(srsran::task_sched_handle task_sched_, const char* logname) : task_sched(task_sched_), logger(srslog::fetch_basic_logger(logname)) {} @@ -188,21 +188,21 @@ void pdcp::config_security_all(as_security_config_t sec_cfg) } } -void pdcp::enable_integrity(uint32_t lcid, srslte_direction_t direction) +void pdcp::enable_integrity(uint32_t lcid, srsran_direction_t direction) { if (valid_lcid(lcid)) { pdcp_array.at(lcid)->enable_integrity(direction); } } -void pdcp::enable_encryption(uint32_t lcid, srslte_direction_t direction) +void pdcp::enable_encryption(uint32_t lcid, srsran_direction_t direction) { if (valid_lcid(lcid)) { pdcp_array.at(lcid)->enable_encryption(direction); } } -void pdcp::enable_security_timed(uint32_t lcid, srslte_direction_t direction, uint32_t sn) +void pdcp::enable_security_timed(uint32_t lcid, srsran_direction_t direction, uint32_t sn) { if (valid_lcid(lcid)) { pdcp_array.at(lcid)->enable_security_timed(direction, sn); @@ -223,7 +223,7 @@ void pdcp::send_status_report(uint32_t lcid) } } -bool pdcp::get_bearer_state(uint32_t lcid, srslte::pdcp_lte_state_t* state) +bool pdcp::get_bearer_state(uint32_t lcid, srsran::pdcp_lte_state_t* state) { if (not valid_lcid(lcid)) { return false; @@ -232,7 +232,7 @@ bool pdcp::get_bearer_state(uint32_t lcid, srslte::pdcp_lte_state_t* state) return true; } -bool pdcp::set_bearer_state(uint32_t lcid, const srslte::pdcp_lte_state_t& state) +bool pdcp::set_bearer_state(uint32_t lcid, const srsran::pdcp_lte_state_t& state) { if (not valid_lcid(lcid)) { return false; @@ -241,7 +241,7 @@ bool pdcp::set_bearer_state(uint32_t lcid, const srslte::pdcp_lte_state_t& state return true; } -std::map pdcp::get_buffered_pdus(uint32_t lcid) +std::map pdcp::get_buffered_pdus(uint32_t lcid) { if (not valid_lcid(lcid)) { return {}; @@ -294,7 +294,7 @@ void pdcp::notify_delivery(uint32_t lcid, const pdcp_sn_vector_t& pdcp_sns) } } -void pdcp::notify_failure(uint32_t lcid, const srslte::pdcp_sn_vector_t& pdcp_sns) +void pdcp::notify_failure(uint32_t lcid, const srsran::pdcp_sn_vector_t& pdcp_sns) { if (valid_lcid(lcid)) { pdcp_array.at(lcid)->notify_failure(pdcp_sns); @@ -305,8 +305,8 @@ void pdcp::notify_failure(uint32_t lcid, const srslte::pdcp_sn_vector_t& pdcp_sn bool pdcp::valid_lcid(uint32_t lcid) { - if (lcid >= SRSLTE_N_RADIO_BEARERS) { - logger.error("Radio bearer id must be in [0:%d] - %d", SRSLTE_N_RADIO_BEARERS, lcid); + if (lcid >= SRSRAN_N_RADIO_BEARERS) { + logger.error("Radio bearer id must be in [0:%d] - %d", SRSRAN_N_RADIO_BEARERS, lcid); return false; } @@ -315,8 +315,8 @@ bool pdcp::valid_lcid(uint32_t lcid) bool pdcp::valid_mch_lcid(uint32_t lcid) { - if (lcid >= SRSLTE_N_MCH_LCIDS) { - logger.error("Radio bearer id must be in [0:%d] - %d", SRSLTE_N_RADIO_BEARERS, lcid); + if (lcid >= SRSRAN_N_MCH_LCIDS) { + logger.error("Radio bearer id must be in [0:%d] - %d", SRSRAN_N_RADIO_BEARERS, lcid); return false; } @@ -359,4 +359,4 @@ void pdcp::reset_metrics() metrics_tp = std::chrono::high_resolution_clock::now(); } -} // namespace srslte +} // namespace srsran diff --git a/lib/src/upper/pdcp_entity_base.cc b/lib/src/upper/pdcp_entity_base.cc index c8520dceb..e3706c962 100644 --- a/lib/src/upper/pdcp_entity_base.cc +++ b/lib/src/upper/pdcp_entity_base.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,12 +10,12 @@ * */ -#include "srslte/upper/pdcp_entity_base.h" -#include "srslte/common/int_helpers.h" -#include "srslte/common/security.h" +#include "srsran/upper/pdcp_entity_base.h" +#include "srsran/common/int_helpers.h" +#include "srsran/common/security.h" #include -namespace srslte { +namespace srsran { pdcp_entity_base::pdcp_entity_base(task_sched_handle task_sched_, srslog::basic_logger& logger) : logger(logger), task_sched(task_sched_) @@ -243,11 +243,11 @@ uint32_t pdcp_entity_base::read_data_header(const unique_byte_buffer_t& pdu) rcvd_sn_32 = SN(pdu->msg[0]); break; case PDCP_SN_LEN_12: - srslte::uint8_to_uint16(pdu->msg, &rcvd_sn_16); + srsran::uint8_to_uint16(pdu->msg, &rcvd_sn_16); rcvd_sn_32 = SN(rcvd_sn_16); break; case PDCP_SN_LEN_18: - srslte::uint8_to_uint24(pdu->msg, &rcvd_sn_32); + srsran::uint8_to_uint24(pdu->msg, &rcvd_sn_32); rcvd_sn_32 = SN(rcvd_sn_32); break; default: @@ -263,7 +263,7 @@ void pdcp_entity_base::discard_data_header(const unique_byte_buffer_t& pdu) pdu->N_bytes -= cfg.hdr_len_bytes; } -void pdcp_entity_base::write_data_header(const srslte::unique_byte_buffer_t& sdu, uint32_t count) +void pdcp_entity_base::write_data_header(const srsran::unique_byte_buffer_t& sdu, uint32_t count) { // Add room for header if (cfg.hdr_len_bytes > sdu->get_headroom()) { @@ -285,13 +285,13 @@ void pdcp_entity_base::write_data_header(const srslte::unique_byte_buffer_t& sdu } break; case PDCP_SN_LEN_12: - srslte::uint16_to_uint8(SN(count), sdu->msg); + srsran::uint16_to_uint8(SN(count), sdu->msg); if (is_drb()) { sdu->msg[0] |= 0x80; // On Data PDUs for DRBs we must set the D flag. } break; case PDCP_SN_LEN_18: - srslte::uint24_to_uint8(SN(count), sdu->msg); + srsran::uint24_to_uint8(SN(count), sdu->msg); sdu->msg[0] |= 0x80; // Data PDU and SN LEN 18 implies DRB, D flag must be present break; default: @@ -324,4 +324,4 @@ void pdcp_entity_base::append_mac(const unique_byte_buffer_t& sdu, uint8_t* mac) memcpy(&sdu->msg[sdu->N_bytes], mac, 4); sdu->N_bytes += 4; } -} // namespace srslte +} // namespace srsran diff --git a/lib/src/upper/pdcp_entity_lte.cc b/lib/src/upper/pdcp_entity_lte.cc index 4b6d98965..132d3bc9e 100644 --- a/lib/src/upper/pdcp_entity_lte.cc +++ b/lib/src/upper/pdcp_entity_lte.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,15 +10,15 @@ * */ -#include "srslte/upper/pdcp_entity_lte.h" -#include "srslte/common/int_helpers.h" -#include "srslte/common/security.h" -#include "srslte/common/standard_streams.h" -#include "srslte/interfaces/ue_gw_interfaces.h" -#include "srslte/interfaces/ue_rlc_interfaces.h" +#include "srsran/upper/pdcp_entity_lte.h" +#include "srsran/common/int_helpers.h" +#include "srsran/common/security.h" +#include "srsran/common/standard_streams.h" +#include "srsran/interfaces/ue_gw_interfaces.h" +#include "srsran/interfaces/ue_rlc_interfaces.h" #include -namespace srslte { +namespace srsran { /**************************************************************************** * PDCP Entity LTE class @@ -27,7 +27,7 @@ namespace srslte { pdcp_entity_lte::pdcp_entity_lte(srsue::rlc_interface_pdcp* rlc_, srsue::rrc_interface_pdcp* rrc_, srsue::gw_interface_pdcp* gw_, - srslte::task_sched_handle task_sched_, + srsran::task_sched_handle task_sched_, srslog::basic_logger& logger, uint32_t lcid_, pdcp_config_t cfg_) : @@ -79,7 +79,7 @@ pdcp_entity_lte::pdcp_entity_lte(srsue::rlc_interface_pdcp* rlc_, // Check supported config if (!check_valid_config()) { - srslte::console("Warning: Invalid PDCP config.\n"); + srsran::console("Warning: Invalid PDCP config.\n"); } } @@ -179,8 +179,8 @@ void pdcp_entity_lte::write_sdu(unique_byte_buffer_t sdu, int upper_sn) "TX %s PDU, SN=%d, integrity=%s, encryption=%s", rrc->get_rb_name(lcid).c_str(), used_sn, - srslte_direction_text[integrity_direction], - srslte_direction_text[encryption_direction]); + srsran_direction_text[integrity_direction], + srsran_direction_text[encryption_direction]); // Set SDU metadata for RLC AM sdu->md.pdcp_sn = used_sn; @@ -232,8 +232,8 @@ void pdcp_entity_lte::write_pdu(unique_byte_buffer_t pdu) rrc->get_rb_name(lcid).c_str(), sn, pdu->N_bytes, - srslte_direction_text[integrity_direction], - srslte_direction_text[encryption_direction]); + srsran_direction_text[integrity_direction], + srsran_direction_text[encryption_direction]); // Update metrics metrics.num_rx_pdus++; @@ -269,7 +269,7 @@ void pdcp_entity_lte::handle_control_pdu(unique_byte_buffer_t pdu) * Ref: 3GPP TS 36.323 v10.1.0 Section 5.1.2 ***************************************************************************/ // SRBs (5.1.2.2) -void pdcp_entity_lte::handle_srb_pdu(srslte::unique_byte_buffer_t pdu) +void pdcp_entity_lte::handle_srb_pdu(srsran::unique_byte_buffer_t pdu) { // Read SN from header uint32_t sn = read_data_header(pdu); @@ -322,7 +322,7 @@ void pdcp_entity_lte::handle_srb_pdu(srslte::unique_byte_buffer_t pdu) } // DRBs mapped on RLC UM (5.1.2.1.3) -void pdcp_entity_lte::handle_um_drb_pdu(srslte::unique_byte_buffer_t pdu) +void pdcp_entity_lte::handle_um_drb_pdu(srsran::unique_byte_buffer_t pdu) { uint32_t sn = read_data_header(pdu); discard_data_header(pdu); @@ -349,7 +349,7 @@ void pdcp_entity_lte::handle_um_drb_pdu(srslte::unique_byte_buffer_t pdu) } // DRBs mapped on RLC AM, without re-ordering (5.1.2.1.2) -void pdcp_entity_lte::handle_am_drb_pdu(srslte::unique_byte_buffer_t pdu) +void pdcp_entity_lte::handle_am_drb_pdu(srsran::unique_byte_buffer_t pdu) { uint32_t sn = read_data_header(pdu); discard_data_header(pdu); @@ -794,11 +794,11 @@ void pdcp_entity_lte::set_bearer_state(const pdcp_lte_state_t& state, bool set_f } } -std::map pdcp_entity_lte::get_buffered_pdus() +std::map pdcp_entity_lte::get_buffered_pdus() { if (undelivered_sdus == nullptr) { logger.error("Buffered PDUs being requested for non-AM DRB"); - return std::map{}; + return std::map{}; } logger.info("Buffered PDUs requested, buffer_size=%zu", undelivered_sdus->size()); return undelivered_sdus->get_buffered_sdus(); @@ -827,7 +827,7 @@ void pdcp_entity_lte::reset_metrics() /**************************************************************************** * Undelivered SDUs queue helpers ***************************************************************************/ -undelivered_sdus_queue::undelivered_sdus_queue(srslte::task_sched_handle task_sched) +undelivered_sdus_queue::undelivered_sdus_queue(srsran::task_sched_handle task_sched) { for (auto& e : sdus) { e.discard_timer = task_sched.get_unique_timer(); @@ -835,9 +835,9 @@ undelivered_sdus_queue::undelivered_sdus_queue(srslte::task_sched_handle task_sc } bool undelivered_sdus_queue::add_sdu(uint32_t sn, - const srslte::unique_byte_buffer_t& sdu, + const srsran::unique_byte_buffer_t& sdu, uint32_t discard_timeout, - srslte::move_callback callback) + srsran::move_callback callback) { assert(not has_sdu(sn) && "Cannot add repeated SNs"); @@ -857,7 +857,7 @@ bool undelivered_sdus_queue::add_sdu(uint32_t sn, } // Allocate buffer and exit on error - srslte::unique_byte_buffer_t tmp = make_byte_buffer(); + srsran::unique_byte_buffer_t tmp = make_byte_buffer(); if (tmp == nullptr) { return false; } @@ -951,13 +951,13 @@ void undelivered_sdus_queue::update_lms(uint32_t sn) } } -std::map undelivered_sdus_queue::get_buffered_sdus() +std::map undelivered_sdus_queue::get_buffered_sdus() { - std::map fwd_sdus; + std::map fwd_sdus; for (auto& sdu : sdus) { if (sdu.sdu != nullptr) { // TODO: Find ways to avoid deep copy - srslte::unique_byte_buffer_t fwd_sdu = make_byte_buffer(); + srsran::unique_byte_buffer_t fwd_sdu = make_byte_buffer(); *fwd_sdu = *sdu.sdu; fwd_sdus.emplace(sdu.sdu->md.pdcp_sn, std::move(fwd_sdu)); } @@ -965,4 +965,4 @@ std::map undelivered_sdus_queue::get_buf return fwd_sdus; } -} // namespace srslte +} // namespace srsran diff --git a/lib/src/upper/pdcp_entity_nr.cc b/lib/src/upper/pdcp_entity_nr.cc index 610163c04..6ec5ba512 100644 --- a/lib/src/upper/pdcp_entity_nr.cc +++ b/lib/src/upper/pdcp_entity_nr.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,15 +10,15 @@ * */ -#include "srslte/upper/pdcp_entity_nr.h" -#include "srslte/common/security.h" +#include "srsran/upper/pdcp_entity_nr.h" +#include "srsran/common/security.h" -namespace srslte { +namespace srsran { pdcp_entity_nr::pdcp_entity_nr(srsue::rlc_interface_pdcp* rlc_, srsue::rrc_interface_pdcp* rrc_, srsue::gw_interface_pdcp* gw_, - srslte::task_sched_handle task_sched_, + srsran::task_sched_handle task_sched_, srslog::basic_logger& logger, uint32_t lcid_, pdcp_config_t cfg_) : @@ -69,8 +69,8 @@ void pdcp_entity_nr::write_sdu(unique_byte_buffer_t sdu, int sn) sdu->N_bytes, "TX %s SDU, integrity=%s, encryption=%s", rrc->get_rb_name(lcid).c_str(), - srslte_direction_text[integrity_direction], - srslte_direction_text[encryption_direction]); + srsran_direction_text[integrity_direction], + srsran_direction_text[encryption_direction]); // Check for COUNT overflow if (tx_overflow) { @@ -126,8 +126,8 @@ void pdcp_entity_nr::write_pdu(unique_byte_buffer_t pdu) "RX %s PDU (%d B), integrity=%s, encryption=%s", rrc->get_rb_name(lcid).c_str(), pdu->N_bytes, - srslte_direction_text[integrity_direction], - srslte_direction_text[encryption_direction]); + srsran_direction_text[integrity_direction], + srsran_direction_text[encryption_direction]); // Sanity check if (pdu->N_bytes <= cfg.hdr_len_bytes) { @@ -302,4 +302,4 @@ void pdcp_entity_nr::reset_metrics() metrics = {}; } -} // namespace srslte +} // namespace srsran diff --git a/lib/src/upper/rlc.cc b/lib/src/upper/rlc.cc index dd0d40ef1..807cf46ef 100644 --- a/lib/src/upper/rlc.cc +++ b/lib/src/upper/rlc.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,14 +10,14 @@ * */ -#include "srslte/upper/rlc.h" -#include "srslte/common/rwlock_guard.h" -#include "srslte/upper/rlc_am_lte.h" -#include "srslte/upper/rlc_tm.h" -#include "srslte/upper/rlc_um_lte.h" -#include "srslte/upper/rlc_um_nr.h" +#include "srsran/upper/rlc.h" +#include "srsran/common/rwlock_guard.h" +#include "srsran/upper/rlc_am_lte.h" +#include "srsran/upper/rlc_tm.h" +#include "srsran/upper/rlc_um_lte.h" +#include "srsran/upper/rlc_um_nr.h" -namespace srslte { +namespace srsran { rlc::rlc(const char* logname) : logger(srslog::fetch_basic_logger(logname)) { @@ -47,7 +47,7 @@ rlc::~rlc() void rlc::init(srsue::pdcp_interface_rlc* pdcp_, srsue::rrc_interface_rlc* rrc_, - srslte::timer_handler* timers_, + srsran::timer_handler* timers_, uint32_t lcid_) { pdcp = pdcp_; @@ -63,7 +63,7 @@ void rlc::init(srsue::pdcp_interface_rlc* pdcp_, void rlc::init(srsue::pdcp_interface_rlc* pdcp_, srsue::rrc_interface_rlc* rrc_, - srslte::timer_handler* timers_, + srsran::timer_handler* timers_, uint32_t lcid_, bsr_callback_t bsr_callback_) { @@ -324,7 +324,7 @@ void rlc::write_pdu(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes) } // Pass directly to PDCP, no DL througput counting done -void rlc::write_pdu_bcch_bch(srslte::unique_byte_buffer_t pdu) +void rlc::write_pdu_bcch_bch(srsran::unique_byte_buffer_t pdu) { logger.info(pdu->msg, pdu->N_bytes, "BCCH BCH message received."); pdcp->write_pdu_bcch_bch(std::move(pdu)); @@ -346,7 +346,7 @@ void rlc::write_pdu_bcch_dlsch(uint8_t* payload, uint32_t nof_bytes) } // Pass directly to PDCP, no DL througput counting done -void rlc::write_pdu_pcch(srslte::unique_byte_buffer_t pdu) +void rlc::write_pdu_pcch(srsran::unique_byte_buffer_t pdu) { logger.info(pdu->msg, pdu->N_bytes, "PCCH message received."); pdcp->write_pdu_pcch(std::move(pdu)); @@ -399,7 +399,7 @@ void rlc::add_bearer(uint32_t lcid, const rlc_config_t& cnfg) } if (not valid_lcid(lcid)) { - if (cnfg.rat == srslte_rat_t::lte) { + if (cnfg.rat == srsran_rat_t::lte) { switch (cnfg.rlc_mode) { case rlc_mode_t::tm: rlc_entity = new rlc_tm(logger, lcid, pdcp, rrc); @@ -417,7 +417,7 @@ void rlc::add_bearer(uint32_t lcid, const rlc_config_t& cnfg) if (rlc_entity != nullptr) { rlc_entity->set_bsr_callback(bsr_callback); } - } else if (cnfg.rat == srslte_rat_t::nr) { + } else if (cnfg.rat == srsran_rat_t::nr) { switch (cnfg.rlc_mode) { case rlc_mode_t::tm: rlc_entity = new rlc_tm(logger, lcid, pdcp, rrc); @@ -586,8 +586,8 @@ bool rlc::has_bearer(uint32_t lcid) *******************************************************************************/ bool rlc::valid_lcid(uint32_t lcid) { - if (lcid >= SRSLTE_N_RADIO_BEARERS) { - logger.error("Radio bearer id must be in [0:%d] - %d", SRSLTE_N_RADIO_BEARERS, lcid); + if (lcid >= SRSRAN_N_RADIO_BEARERS) { + logger.error("Radio bearer id must be in [0:%d] - %d", SRSRAN_N_RADIO_BEARERS, lcid); return false; } @@ -600,8 +600,8 @@ bool rlc::valid_lcid(uint32_t lcid) bool rlc::valid_lcid_mrb(uint32_t lcid) { - if (lcid >= SRSLTE_N_MCH_LCIDS) { - logger.error("Radio bearer id must be in [0:%d] - %d", SRSLTE_N_RADIO_BEARERS, lcid); + if (lcid >= SRSRAN_N_MCH_LCIDS) { + logger.error("Radio bearer id must be in [0:%d] - %d", SRSRAN_N_RADIO_BEARERS, lcid); return false; } @@ -644,4 +644,4 @@ void rlc_bearer_metrics_print(const rlc_bearer_metrics_t& metrics) std::cout << "num_lost_sdus=" << metrics.num_lost_sdus << "\n"; } -} // namespace srslte +} // namespace srsran diff --git a/lib/src/upper/rlc_am_base.cc b/lib/src/upper/rlc_am_base.cc index 0bca7992f..b8bff63ea 100644 --- a/lib/src/upper/rlc_am_base.cc +++ b/lib/src/upper/rlc_am_base.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,10 +10,10 @@ * */ -#include "srslte/upper/rlc_am_base.h" +#include "srsran/upper/rlc_am_base.h" #include -namespace srslte { +namespace srsran { bool rlc_am_is_control_pdu(uint8_t* payload) { @@ -25,4 +25,4 @@ bool rlc_am_is_control_pdu(byte_buffer_t* pdu) return rlc_am_is_control_pdu(pdu->msg); } -} // namespace srslte +} // namespace srsran diff --git a/lib/src/upper/rlc_am_lte.cc b/lib/src/upper/rlc_am_lte.cc index 98df5c952..06476b0c2 100644 --- a/lib/src/upper/rlc_am_lte.cc +++ b/lib/src/upper/rlc_am_lte.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,11 +10,11 @@ * */ -#include "srslte/upper/rlc_am_lte.h" -#include "srslte/common/string_helpers.h" -#include "srslte/interfaces/ue_pdcp_interfaces.h" -#include "srslte/interfaces/ue_rrc_interfaces.h" -#include "srslte/srslog/event_trace.h" +#include "srsran/upper/rlc_am_lte.h" +#include "srsran/common/string_helpers.h" +#include "srsran/interfaces/ue_pdcp_interfaces.h" +#include "srsran/interfaces/ue_rrc_interfaces.h" +#include "srsran/srslog/event_trace.h" #include #define MOD 1024 @@ -23,7 +23,7 @@ #define LCID (parent->lcid) #define RB_NAME (parent->rb_name.c_str()) -namespace srslte { +namespace srsran { /******************************* * Helper methods @@ -65,7 +65,7 @@ rlc_am_lte::rlc_am_lte(srslog::basic_logger& logger, uint32_t lcid_, srsue::pdcp_interface_rlc* pdcp_, srsue::rrc_interface_rlc* rrc_, - srslte::timer_handler* timers_) : + srsran::timer_handler* timers_) : logger(logger), rrc(rrc_), pdcp(pdcp_), timers(timers_), lcid(lcid_), tx(this), rx(this) {} @@ -154,7 +154,7 @@ void rlc_am_lte::reset_metrics() void rlc_am_lte::write_sdu(unique_byte_buffer_t sdu) { - if (tx.write_sdu(std::move(sdu)) == SRSLTE_SUCCESS) { + if (tx.write_sdu(std::move(sdu)) == SRSRAN_SUCCESS) { metrics.num_tx_sdus++; } } @@ -411,12 +411,12 @@ int rlc_am_lte::rlc_am_lte_tx::write_sdu(unique_byte_buffer_t sdu) std::lock_guard lock(mutex); if (!tx_enabled) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (sdu.get() == nullptr) { logger.warning("NULL SDU pointer in write_sdu()"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Get SDU info @@ -425,7 +425,7 @@ int rlc_am_lte::rlc_am_lte_tx::write_sdu(unique_byte_buffer_t sdu) // Store SDU uint8_t* msg_ptr = sdu->msg; uint32_t nof_bytes = sdu->N_bytes; - srslte::error_type ret = tx_sdu_queue.try_write(std::move(sdu)); + srsran::error_type ret = tx_sdu_queue.try_write(std::move(sdu)); if (ret) { logger.info(msg_ptr, nof_bytes, "%s Tx SDU (%d B, tx_sdu_queue_len=%d)", RB_NAME, nof_bytes, tx_sdu_queue.size()); } else { @@ -436,19 +436,19 @@ int rlc_am_lte::rlc_am_lte_tx::write_sdu(unique_byte_buffer_t sdu) RB_NAME, ret.error()->N_bytes, tx_sdu_queue.size()); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (undelivered_sdu_info_queue.has_pdcp_sn(sdu_pdcp_sn)) { logger.warning("PDCP_SN=%d already marked as undelivered", sdu_pdcp_sn); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Store SDU info logger.debug("Marking PDCP_SN=%d as undelivered (queue_len=%ld)", sdu_pdcp_sn, undelivered_sdu_info_queue.nof_sdus()); undelivered_sdu_info_queue.add_pdcp_sdu(sdu_pdcp_sn); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } void rlc_am_lte::rlc_am_lte_tx::discard_sdu(uint32_t discard_sn) @@ -885,16 +885,16 @@ int rlc_am_lte::rlc_am_lte_tx::build_data_pdu(uint8_t* payload, uint32_t nof_byt return 0; } - unique_byte_buffer_t pdu = srslte::make_byte_buffer(); + unique_byte_buffer_t pdu = srsran::make_byte_buffer(); if (pdu == NULL) { #ifdef RLC_AM_BUFFER_DEBUG - srslte::console("Fatal Error: Could not allocate PDU in build_data_pdu()\n"); - srslte::console("tx_window size: %zd PDUs\n", tx_window.size()); - srslte::console("vt_a = %d, vt_ms = %d, vt_s = %d, poll_sn = %d\n", vt_a, vt_ms, vt_s, poll_sn); - srslte::console("retx_queue size: %zd PDUs\n", retx_queue.size()); + srsran::console("Fatal Error: Could not allocate PDU in build_data_pdu()\n"); + srsran::console("tx_window size: %zd PDUs\n", tx_window.size()); + srsran::console("vt_a = %d, vt_ms = %d, vt_s = %d, poll_sn = %d\n", vt_a, vt_ms, vt_s, poll_sn); + srsran::console("retx_queue size: %zd PDUs\n", retx_queue.size()); std::map::iterator txit; for (txit = tx_window.begin(); txit != tx_window.end(); txit++) { - srslte::console("tx_window - SN=%d\n", txit->first); + srsran::console("tx_window - SN=%d\n", txit->first); } exit(-1); #else @@ -915,7 +915,7 @@ int rlc_am_lte::rlc_am_lte_tx::build_data_pdu(uint8_t* payload, uint32_t nof_byt uint32_t head_len = rlc_am_packed_length(&header); uint32_t to_move = 0; uint32_t last_li = 0; - uint32_t pdu_space = SRSLTE_MIN(nof_bytes, pdu->get_tailroom()); + uint32_t pdu_space = SRSRAN_MIN(nof_bytes, pdu->get_tailroom()); uint8_t* pdu_ptr = pdu->msg; logger.debug("%s Building PDU - pdu_space: %d, head_len: %d ", RB_NAME, pdu_space, head_len); @@ -950,7 +950,7 @@ int rlc_am_lte::rlc_am_lte_tx::build_data_pdu(uint8_t* payload, uint32_t nof_byt tx_sdu.reset(); } if (pdu_space > to_move) { - pdu_space -= SRSLTE_MIN(to_move, pdu->get_tailroom()); + pdu_space -= SRSRAN_MIN(to_move, pdu->get_tailroom()); } else { pdu_space = 0; } @@ -1417,10 +1417,10 @@ void rlc_am_lte::rlc_am_lte_rx::handle_data_pdu(uint8_t* payload, uint32_t nof_b // Write to rx window rlc_amd_rx_pdu_t& pdu = rx_window.add_pdu(header.sn); - pdu.buf = srslte::make_byte_buffer(); + pdu.buf = srsran::make_byte_buffer(); if (pdu.buf == NULL) { #ifdef RLC_AM_BUFFER_DEBUG - srslte::console("Fatal Error: Couldn't allocate PDU in handle_data_pdu().\n"); + srsran::console("Fatal Error: Couldn't allocate PDU in handle_data_pdu().\n"); exit(-1); #else logger.error("Fatal Error: Couldn't allocate PDU in handle_data_pdu()."); @@ -1522,10 +1522,10 @@ void rlc_am_lte::rlc_am_lte_rx::handle_data_pdu_segment(uint8_t* pa } rlc_amd_rx_pdu_t segment; - segment.buf = srslte::make_byte_buffer(); + segment.buf = srsran::make_byte_buffer(); if (segment.buf == NULL) { #ifdef RLC_AM_BUFFER_DEBUG - srslte::console("Fatal Error: Couldn't allocate PDU in handle_data_pdu_segment().\n"); + srsran::console("Fatal Error: Couldn't allocate PDU in handle_data_pdu_segment().\n"); exit(-1); #else logger.error("Fatal Error: Couldn't allocate PDU in handle_data_pdu_segment()."); @@ -1589,10 +1589,10 @@ void rlc_am_lte::rlc_am_lte_rx::reassemble_rx_sdus() { uint32_t len = 0; if (rx_sdu == NULL) { - rx_sdu = srslte::make_byte_buffer(); + rx_sdu = srsran::make_byte_buffer(); if (rx_sdu == NULL) { #ifdef RLC_AM_BUFFER_DEBUG - srslte::console("Fatal Error: Could not allocate PDU in reassemble_rx_sdus() (1)\n"); + srsran::console("Fatal Error: Could not allocate PDU in reassemble_rx_sdus() (1)\n"); exit(-1); #else logger.error("Fatal Error: Could not allocate PDU in reassemble_rx_sdus() (1)"); @@ -1621,7 +1621,7 @@ void rlc_am_lte::rlc_am_lte_rx::reassemble_rx_sdus() } if (rx_sdu->get_tailroom() >= len) { - if ((rx_window[vr_r].buf->msg - rx_window[vr_r].buf->buffer) + len < SRSLTE_MAX_BUFFER_SIZE_BYTES) { + if ((rx_window[vr_r].buf->msg - rx_window[vr_r].buf->buffer) + len < SRSRAN_MAX_BUFFER_SIZE_BYTES) { if (rx_window[vr_r].buf->N_bytes < len) { logger.error("Dropping corrupted SN=%d", vr_r); rx_sdu.reset(); @@ -1644,10 +1644,10 @@ void rlc_am_lte::rlc_am_lte_rx::reassemble_rx_sdus() parent->pdcp->write_pdu(parent->lcid, std::move(rx_sdu)); parent->metrics.num_rx_sdus++; - rx_sdu = srslte::make_byte_buffer(); + rx_sdu = srsran::make_byte_buffer(); if (rx_sdu == nullptr) { #ifdef RLC_AM_BUFFER_DEBUG - srslte::console("Fatal Error: Could not allocate PDU in reassemble_rx_sdus() (2)\n"); + srsran::console("Fatal Error: Could not allocate PDU in reassemble_rx_sdus() (2)\n"); exit(-1); #else logger.error("Fatal Error: Could not allocate PDU in reassemble_rx_sdus() (2)"); @@ -1694,10 +1694,10 @@ void rlc_am_lte::rlc_am_lte_rx::reassemble_rx_sdus() parent->pdcp->write_pdu(parent->lcid, std::move(rx_sdu)); parent->metrics.num_rx_sdus++; - rx_sdu = srslte::make_byte_buffer(); + rx_sdu = srsran::make_byte_buffer(); if (rx_sdu == NULL) { #ifdef RLC_AM_BUFFER_DEBUG - srslte::console("Fatal Error: Could not allocate PDU in reassemble_rx_sdus() (3)\n"); + srsran::console("Fatal Error: Could not allocate PDU in reassemble_rx_sdus() (3)\n"); exit(-1); #else logger.error("Fatal Error: Could not allocate PDU in reassemble_rx_sdus() (3)"); @@ -1931,7 +1931,7 @@ bool rlc_am_lte::rlc_am_lte_rx::add_segment_and_check(rlc_amd_rx_pdu_segments_t* it = pdu->segments.erase(it); // Returns next iterator } else { // Update segment offset it shall not go backwards - so = SRSLTE_MAX(so, it->header.so + it->buf->N_bytes); + so = SRSRAN_MAX(so, it->header.so + it->buf->N_bytes); it++; // Increments iterator } } @@ -2035,10 +2035,10 @@ bool rlc_am_lte::rlc_am_lte_rx::add_segment_and_check(rlc_amd_rx_pdu_segments_t* logger.debug("Finished header reconstruction of %zd segments", pdu->segments.size()); // Copy data - unique_byte_buffer_t full_pdu = srslte::make_byte_buffer(); + unique_byte_buffer_t full_pdu = srsran::make_byte_buffer(); if (full_pdu == NULL) { #ifdef RLC_AM_BUFFER_DEBUG - srslte::console("Fatal Error: Could not allocate PDU in add_segment_and_check()\n"); + srsran::console("Fatal Error: Could not allocate PDU in add_segment_and_check()\n"); exit(-1); #else logger.error("Fatal Error: Could not allocate PDU in add_segment_and_check()"); @@ -2245,25 +2245,25 @@ void rlc_am_read_status_pdu(uint8_t* payload, uint32_t nof_bytes, rlc_status_pdu bit_buffer_t tmp; uint8_t* ptr = tmp.msg; - srslte_bit_unpack_vector(payload, tmp.msg, nof_bytes * 8); + srsran_bit_unpack_vector(payload, tmp.msg, nof_bytes * 8); tmp.N_bits = nof_bytes * 8; - rlc_dc_field_t dc = static_cast(srslte_bit_pack(&ptr, 1)); + rlc_dc_field_t dc = static_cast(srsran_bit_pack(&ptr, 1)); if (RLC_DC_FIELD_CONTROL_PDU == dc) { - uint8_t cpt = srslte_bit_pack(&ptr, 3); // 3-bit Control PDU Type (0 == status) + uint8_t cpt = srsran_bit_pack(&ptr, 3); // 3-bit Control PDU Type (0 == status) if (0 == cpt) { - status->ack_sn = srslte_bit_pack(&ptr, 10); // 10 bits ACK_SN - ext1 = srslte_bit_pack(&ptr, 1); // 1 bits E1 + status->ack_sn = srsran_bit_pack(&ptr, 10); // 10 bits ACK_SN + ext1 = srsran_bit_pack(&ptr, 1); // 1 bits E1 status->N_nack = 0; while (ext1) { - status->nacks[status->N_nack].nack_sn = srslte_bit_pack(&ptr, 10); - ext1 = srslte_bit_pack(&ptr, 1); // 1 bits E1 - ext2 = srslte_bit_pack(&ptr, 1); // 1 bits E2 + status->nacks[status->N_nack].nack_sn = srsran_bit_pack(&ptr, 10); + ext1 = srsran_bit_pack(&ptr, 1); // 1 bits E1 + ext2 = srsran_bit_pack(&ptr, 1); // 1 bits E2 if (ext2) { status->nacks[status->N_nack].has_so = true; - status->nacks[status->N_nack].so_start = srslte_bit_pack(&ptr, 15); - status->nacks[status->N_nack].so_end = srslte_bit_pack(&ptr, 15); + status->nacks[status->N_nack].so_start = srsran_bit_pack(&ptr, 15); + status->nacks[status->N_nack].so_end = srsran_bit_pack(&ptr, 15); } status->N_nack++; } @@ -2283,32 +2283,32 @@ int rlc_am_write_status_pdu(rlc_status_pdu_t* status, uint8_t* payload) bit_buffer_t tmp; uint8_t* ptr = tmp.msg; - srslte_bit_unpack(RLC_DC_FIELD_CONTROL_PDU, &ptr, 1); // D/C - srslte_bit_unpack(0, &ptr, 3); // CPT (0 == STATUS) - srslte_bit_unpack(status->ack_sn, &ptr, 10); // 10 bit ACK_SN + srsran_bit_unpack(RLC_DC_FIELD_CONTROL_PDU, &ptr, 1); // D/C + srsran_bit_unpack(0, &ptr, 3); // CPT (0 == STATUS) + srsran_bit_unpack(status->ack_sn, &ptr, 10); // 10 bit ACK_SN ext1 = (status->N_nack == 0) ? 0 : 1; - srslte_bit_unpack(ext1, &ptr, 1); // E1 + srsran_bit_unpack(ext1, &ptr, 1); // E1 for (i = 0; i < status->N_nack; i++) { - srslte_bit_unpack(status->nacks[i].nack_sn, &ptr, 10); // 10 bit NACK_SN + srsran_bit_unpack(status->nacks[i].nack_sn, &ptr, 10); // 10 bit NACK_SN ext1 = ((status->N_nack - 1) == i) ? 0 : 1; - srslte_bit_unpack(ext1, &ptr, 1); // E1 + srsran_bit_unpack(ext1, &ptr, 1); // E1 if (status->nacks[i].has_so) { - srslte_bit_unpack(1, &ptr, 1); // E2 - srslte_bit_unpack(status->nacks[i].so_start, &ptr, 15); - srslte_bit_unpack(status->nacks[i].so_end, &ptr, 15); + srsran_bit_unpack(1, &ptr, 1); // E2 + srsran_bit_unpack(status->nacks[i].so_start, &ptr, 15); + srsran_bit_unpack(status->nacks[i].so_end, &ptr, 15); } else { - srslte_bit_unpack(0, &ptr, 1); // E2 + srsran_bit_unpack(0, &ptr, 1); // E2 } } // Pad tmp.N_bits = ptr - tmp.msg; uint8_t n_pad = 8 - (tmp.N_bits % 8); - srslte_bit_unpack(0, &ptr, n_pad); + srsran_bit_unpack(0, &ptr, n_pad); tmp.N_bits = ptr - tmp.msg; // Pack bits - srslte_bit_pack_vector(tmp.msg, payload, tmp.N_bits); + srsran_bit_pack_vector(tmp.msg, payload, tmp.N_bits); return tmp.N_bits / 8; } @@ -2426,4 +2426,4 @@ bool rlc_am_not_start_aligned(const uint8_t fi) return (fi == RLC_FI_FIELD_NOT_START_ALIGNED || fi == RLC_FI_FIELD_NOT_START_OR_END_ALIGNED); } -} // namespace srslte +} // namespace srsran diff --git a/lib/src/upper/rlc_am_nr.cc b/lib/src/upper/rlc_am_nr.cc index 86d30abd3..cb94d7bb4 100644 --- a/lib/src/upper/rlc_am_nr.cc +++ b/lib/src/upper/rlc_am_nr.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,10 +10,10 @@ * */ -#include "srslte/upper/rlc_am_nr.h" +#include "srsran/upper/rlc_am_nr.h" #include -namespace srslte { +namespace srsran { /**************************************************************************** * Header pack/unpack helper functions @@ -194,14 +194,14 @@ uint32_t rlc_am_nr_read_status_pdu(const uint8_t* payload, } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } /** * Write a RLC AM NR status PDU to a PDU buffer and eets the length of the generate PDU accordingly * @param status_pdu The status PDU * @param pdu A pointer to a unique bytebuffer - * @return SRSLTE_SUCCESS if PDU was written, SRSLTE_ERROR otherwise + * @return SRSRAN_SUCCESS if PDU was written, SRSRAN_ERROR otherwise */ int32_t rlc_am_nr_write_status_pdu(const rlc_am_nr_status_pdu_t& status_pdu, const rlc_am_nr_sn_size_t sn_size, @@ -244,7 +244,7 @@ int32_t rlc_am_nr_write_status_pdu(const rlc_am_nr_status_pdu_t& status_pdu, pdu->N_bytes = ptr - pdu->msg; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -} // namespace srslte +} // namespace srsran diff --git a/lib/src/upper/rlc_tm.cc b/lib/src/upper/rlc_tm.cc index 455a76ad2..3b9acddc5 100644 --- a/lib/src/upper/rlc_tm.cc +++ b/lib/src/upper/rlc_tm.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,11 +10,11 @@ * */ -#include "srslte/upper/rlc_tm.h" -#include "srslte/interfaces/ue_pdcp_interfaces.h" -#include "srslte/interfaces/ue_rrc_interfaces.h" +#include "srsran/upper/rlc_tm.h" +#include "srsran/interfaces/ue_pdcp_interfaces.h" +#include "srsran/interfaces/ue_rrc_interfaces.h" -namespace srslte { +namespace srsran { rlc_tm::rlc_tm(srslog::basic_logger& logger, uint32_t lcid_, @@ -77,7 +77,7 @@ void rlc_tm::write_sdu(unique_byte_buffer_t sdu) if (sdu != nullptr) { uint8_t* msg_ptr = sdu->msg; uint32_t nof_bytes = sdu->N_bytes; - srslte::error_type ret = ul_queue.try_write(std::move(sdu)); + srsran::error_type ret = ul_queue.try_write(std::move(sdu)); if (ret) { logger.info(msg_ptr, nof_bytes, @@ -152,7 +152,7 @@ int rlc_tm::read_pdu(uint8_t* payload, uint32_t nof_bytes) pdu_size, "%s Tx %s PDU, queue size=%d, bytes=%d", rrc->get_rb_name(lcid).c_str(), - srslte::to_string(rlc_mode_t::tm).c_str(), + srsran::to_string(rlc_mode_t::tm).c_str(), ul_queue.size(), ul_queue.size_bytes()); @@ -187,4 +187,4 @@ void rlc_tm::write_pdu(uint8_t* payload, uint32_t nof_bytes) } } -} // namespace srslte +} // namespace srsran diff --git a/lib/src/upper/rlc_um_base.cc b/lib/src/upper/rlc_um_base.cc index f6082a963..5155ca31e 100644 --- a/lib/src/upper/rlc_um_base.cc +++ b/lib/src/upper/rlc_um_base.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,17 +10,17 @@ * */ -#include "srslte/upper/rlc_um_base.h" -#include "srslte/interfaces/ue_rrc_interfaces.h" +#include "srsran/upper/rlc_um_base.h" +#include "srsran/interfaces/ue_rrc_interfaces.h" #include -namespace srslte { +namespace srsran { rlc_um_base::rlc_um_base(srslog::basic_logger& logger, uint32_t lcid_, srsue::pdcp_interface_rlc* pdcp_, srsue::rrc_interface_rlc* rrc_, - srslte::timer_handler* timers_) : + srsran::timer_handler* timers_) : logger(logger), lcid(lcid_), pdcp(pdcp_), rrc(rrc_), timers(timers_), pool(byte_buffer_pool::get_instance()) {} @@ -87,7 +87,7 @@ void rlc_um_base::write_sdu(unique_byte_buffer_t sdu) } int sdu_bytes = sdu->N_bytes; //< Store SDU length for book-keeping - if (tx->try_write_sdu(std::move(sdu)) == SRSLTE_SUCCESS) { + if (tx->try_write_sdu(std::move(sdu)) == SRSRAN_SUCCESS) { metrics.num_tx_sdus++; metrics.num_tx_sdu_bytes += sdu_bytes; } else { @@ -254,11 +254,11 @@ int rlc_um_base::rlc_um_base_tx::try_write_sdu(unique_byte_buffer_t sdu) if (sdu) { uint8_t* msg_ptr = sdu->msg; uint32_t nof_bytes = sdu->N_bytes; - srslte::error_type ret = tx_sdu_queue.try_write(std::move(sdu)); + srsran::error_type ret = tx_sdu_queue.try_write(std::move(sdu)); if (ret) { logger.info( msg_ptr, nof_bytes, "%s Tx SDU (%d B, tx_sdu_queue_len=%d)", rb_name.c_str(), nof_bytes, tx_sdu_queue.size()); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } else { logger.warning(ret.error()->msg, ret.error()->N_bytes, @@ -270,7 +270,7 @@ int rlc_um_base::rlc_um_base_tx::try_write_sdu(unique_byte_buffer_t sdu) } else { logger.warning("NULL SDU pointer in write_sdu()"); } - return SRSLTE_ERROR; + return SRSRAN_ERROR; } void rlc_um_base::rlc_um_base_tx::discard_sdu(uint32_t discard_sn) @@ -304,4 +304,4 @@ int rlc_um_base::rlc_um_base_tx::build_data_pdu(uint8_t* payload, uint32_t nof_b return build_data_pdu(std::move(pdu), payload, nof_bytes); } -} // namespace srslte +} // namespace srsran diff --git a/lib/src/upper/rlc_um_lte.cc b/lib/src/upper/rlc_um_lte.cc index 4f87e53ff..f90ffd387 100644 --- a/lib/src/upper/rlc_um_lte.cc +++ b/lib/src/upper/rlc_um_lte.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,19 +10,19 @@ * */ -#include "srslte/upper/rlc_um_lte.h" -#include "srslte/interfaces/ue_pdcp_interfaces.h" +#include "srsran/upper/rlc_um_lte.h" +#include "srsran/interfaces/ue_pdcp_interfaces.h" #include #define RX_MOD_BASE(x) (((x)-vr_uh - cfg.um.rx_window_size) % cfg.um.rx_mod) -namespace srslte { +namespace srsran { rlc_um_lte::rlc_um_lte(srslog::basic_logger& logger, uint32_t lcid_, srsue::pdcp_interface_rlc* pdcp_, srsue::rrc_interface_rlc* rrc_, - srslte::timer_handler* timers_) : + srsran::timer_handler* timers_) : rlc_um_base(logger, lcid_, pdcp_, rrc_, timers_) {} @@ -52,10 +52,10 @@ bool rlc_um_lte::configure(const rlc_config_t& cnfg_) logger.info("%s configured in %s: t_reordering=%d ms, rx_sn_field_length=%u bits, tx_sn_field_length=%u bits", rb_name.c_str(), - srslte::to_string(cnfg_.rlc_mode).c_str(), + srsran::to_string(cnfg_.rlc_mode).c_str(), cfg.um.t_reordering, - srslte::to_number(cfg.um.rx_sn_field_length), - srslte::to_number(cfg.um.tx_sn_field_length)); + srsran::to_number(cfg.um.rx_sn_field_length), + srsran::to_number(cfg.um.tx_sn_field_length)); rx_enabled = true; tx_enabled = true; @@ -123,7 +123,7 @@ int rlc_um_lte::rlc_um_lte_tx::build_data_pdu(unique_byte_buffer_t pdu, uint8_t* uint8_t* pdu_ptr = pdu->msg; int head_len = rlc_um_packed_length(&header); - int pdu_space = SRSLTE_MIN(nof_bytes, pdu->get_tailroom()); + int pdu_space = SRSRAN_MIN(nof_bytes, pdu->get_tailroom()); if (pdu_space <= head_len + 1) { logger.info("%s Cannot build a PDU - %d bytes available, %d bytes required for header", @@ -158,7 +158,7 @@ int rlc_um_lte::rlc_um_lte_tx::build_data_pdu(unique_byte_buffer_t pdu, uint8_t* #endif tx_sdu.reset(); } - pdu_space -= SRSLTE_MIN(to_move, pdu->get_tailroom()); + pdu_space -= SRSRAN_MIN(to_move, pdu->get_tailroom()); header.fi |= RLC_FI_FIELD_NOT_START_ALIGNED; // First byte does not correspond to first byte of SDU } @@ -593,9 +593,9 @@ void rlc_um_lte::rlc_um_lte_rx::reassemble_rx_sdus() goto clean_up_rx_window; } - if (rx_sdu->N_bytes < SRSLTE_MAX_BUFFER_SIZE_BYTES && - rx_window[vr_ur].buf->N_bytes < SRSLTE_MAX_BUFFER_SIZE_BYTES && - rx_window[vr_ur].buf->N_bytes + rx_sdu->N_bytes < SRSLTE_MAX_BUFFER_SIZE_BYTES) { + if (rx_sdu->N_bytes < SRSRAN_MAX_BUFFER_SIZE_BYTES && + rx_window[vr_ur].buf->N_bytes < SRSRAN_MAX_BUFFER_SIZE_BYTES && + rx_window[vr_ur].buf->N_bytes + rx_sdu->N_bytes < SRSRAN_MAX_BUFFER_SIZE_BYTES) { logger.info(rx_window[vr_ur].buf->msg, rx_window[vr_ur].buf->N_bytes, "Writing last segment in SDU buffer. Updating vr_ur=%d, vr_ur_in_rx_sdu=%d, Buffer size=%d, " @@ -838,4 +838,4 @@ bool rlc_um_end_aligned(uint8_t fi) return (fi == RLC_FI_FIELD_START_AND_END_ALIGNED || fi == RLC_FI_FIELD_NOT_START_ALIGNED); } -} // namespace srslte +} // namespace srsran diff --git a/lib/src/upper/rlc_um_nr.cc b/lib/src/upper/rlc_um_nr.cc index 85dc1a9bd..cd653efc0 100644 --- a/lib/src/upper/rlc_um_nr.cc +++ b/lib/src/upper/rlc_um_nr.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,19 +10,19 @@ * */ -#include "srslte/upper/rlc_um_nr.h" -#include "srslte/interfaces/ue_pdcp_interfaces.h" +#include "srsran/upper/rlc_um_nr.h" +#include "srsran/interfaces/ue_pdcp_interfaces.h" #include #define RX_MOD_NR_BASE(x) (((x)-RX_Next_Highest - cfg.um_nr.UM_Window_Size) % cfg.um_nr.mod) -namespace srslte { +namespace srsran { rlc_um_nr::rlc_um_nr(srslog::basic_logger& logger, uint32_t lcid_, srsue::pdcp_interface_rlc* pdcp_, srsue::rrc_interface_rlc* rrc_, - srslte::timer_handler* timers_) : + srsran::timer_handler* timers_) : rlc_um_base(logger, lcid_, pdcp_, rrc_, timers_) {} @@ -51,8 +51,8 @@ bool rlc_um_nr::configure(const rlc_config_t& cnfg_) logger.info("%s configured in %s: sn_field_length=%u bits", rb_name.c_str(), - srslte::to_string(cnfg_.rlc_mode).c_str(), - srslte::to_number(cfg.um_nr.sn_field_length)); + srsran::to_string(cnfg_.rlc_mode).c_str(), + srsran::to_number(cfg.um_nr.sn_field_length)); rx_enabled = true; tx_enabled = true; @@ -118,7 +118,7 @@ int rlc_um_nr::rlc_um_nr_tx::build_data_pdu(unique_byte_buffer_t pdu, uint8_t* p uint8_t* pdu_ptr = pdu->msg; int head_len = rlc_um_nr_packed_length(header); - int pdu_space = SRSLTE_MIN(nof_bytes, pdu->get_tailroom()); + int pdu_space = SRSRAN_MIN(nof_bytes, pdu->get_tailroom()); if (pdu_space <= head_len + 1) { logger.warning("%s Cannot build a PDU - %d bytes available, %d bytes required for header", @@ -147,7 +147,7 @@ int rlc_um_nr::rlc_um_nr_tx::build_data_pdu(unique_byte_buffer_t pdu, uint8_t* p } else { header.si = rlc_nr_si_field_t::neither_first_nor_last_segment; } - pdu_space -= SRSLTE_MIN(to_move, pdu->get_tailroom()); + pdu_space -= SRSRAN_MIN(to_move, pdu->get_tailroom()); header.so = next_so; } else { // Pull SDU from queue @@ -687,4 +687,4 @@ uint32_t rlc_um_nr_write_data_pdu_header(const rlc_um_nr_pdu_header_t& header, b return len; } -} // namespace srslte +} // namespace srsran diff --git a/lib/test/CMakeLists.txt b/lib/test/CMakeLists.txt index 2409ce8a3..3b230ca0e 100644 --- a/lib/test/CMakeLists.txt +++ b/lib/test/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of diff --git a/lib/test/adt/CMakeLists.txt b/lib/test/adt/CMakeLists.txt index 0ccf53d06..fb2276200 100644 --- a/lib/test/adt/CMakeLists.txt +++ b/lib/test/adt/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -11,37 +11,37 @@ ####################################################################### add_executable(scope_exit_test scope_exit_test.cc) -target_link_libraries(scope_exit_test srslte_common) +target_link_libraries(scope_exit_test srsran_common) add_test(scope_exit_test scope_exit_test) add_executable(expected_test expected_test.cc) -target_link_libraries(expected_test srslte_common) +target_link_libraries(expected_test srsran_common) add_test(expected_test expected_test) add_executable(bounded_bitset_test bounded_bitset_test.cc) -target_link_libraries(bounded_bitset_test srslte_common) +target_link_libraries(bounded_bitset_test srsran_common) add_test(bounded_bitset_test bounded_bitset_test) add_executable(span_test span_test.cc) -target_link_libraries(span_test srslte_common) +target_link_libraries(span_test srsran_common) add_test(span_test span_test) add_executable(interval_test interval_test.cc) -target_link_libraries(interval_test srslte_common) +target_link_libraries(interval_test srsran_common) add_test(interval_test interval_test) add_executable(observer_test observer_test.cc) -target_link_libraries(observer_test srslte_common) +target_link_libraries(observer_test srsran_common) add_test(observer_test observer_test) add_executable(bounded_vector_test bounded_vector_test.cc) -target_link_libraries(bounded_vector_test srslte_common) +target_link_libraries(bounded_vector_test srsran_common) add_test(bounded_vector_test bounded_vector_test) add_executable(mem_pool_test mem_pool_test.cc) -target_link_libraries(mem_pool_test srslte_common) +target_link_libraries(mem_pool_test srsran_common) add_test(mem_pool_test mem_pool_test) add_executable(circular_buffer_test circular_buffer_test.cc) -target_link_libraries(circular_buffer_test srslte_common) +target_link_libraries(circular_buffer_test srsran_common) add_test(circular_buffer_test circular_buffer_test) diff --git a/lib/test/adt/bounded_bitset_test.cc b/lib/test/adt/bounded_bitset_test.cc index 40f4f7279..fbc7f3437 100644 --- a/lib/test/adt/bounded_bitset_test.cc +++ b/lib/test/adt/bounded_bitset_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,13 +10,13 @@ * */ -#include "srslte/adt/bounded_bitset.h" -#include "srslte/common/test_common.h" +#include "srsran/adt/bounded_bitset.h" +#include "srsran/common/test_common.h" int test_zero_bitset() { - srslte::bounded_bitset<25> mask; - srslte::bounded_bitset<25> mask2{23}; + srsran::bounded_bitset<25> mask; + srsran::bounded_bitset<25> mask2{23}; TESTASSERT(mask.max_size() == 25); TESTASSERT(mask.size() == 0); @@ -36,12 +36,12 @@ int test_zero_bitset() mask = mask2; TESTASSERT(mask == mask2); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_ones_bitset() { - srslte::bounded_bitset<25> mask; + srsran::bounded_bitset<25> mask; // Flipping empty bitset is noop TESTASSERT(mask.none() and mask.all() and not mask.any()); @@ -54,12 +54,12 @@ int test_ones_bitset() mask.flip(); TESTASSERT(not mask.none() and mask.all() and mask.any()); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_bitset_set() { - srslte::bounded_bitset<25> mask{23}; + srsran::bounded_bitset<25> mask{23}; mask.set(10); TESTASSERT(mask.any()); @@ -70,13 +70,13 @@ int test_bitset_set() TESTASSERT(not mask.test(10)); TESTASSERT(mask.test(0)); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_bitset_bitwise_oper() { - srslte::bounded_bitset<25> mask{23}; - srslte::bounded_bitset<25> mask2{23}; + srsran::bounded_bitset<25> mask{23}; + srsran::bounded_bitset<25> mask2{23}; mask.set(10); TESTASSERT(mask != mask2); @@ -93,20 +93,20 @@ int test_bitset_bitwise_oper() mask2.resize(24); try { mask2 |= mask; - } catch (srslte::bad_type_access& c) { + } catch (srsran::bad_type_access& c) { printf("Received exception \"%s\" (as expected)\n", c.what()); caught = true; } TESTASSERT(caught); #endif - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_bitset_print() { { - srslte::bounded_bitset<100> bitset(100); + srsran::bounded_bitset<100> bitset(100); bitset.set(0); bitset.set(5); @@ -121,7 +121,7 @@ int test_bitset_print() } { - srslte::bounded_bitset<100> bitset(25); + srsran::bounded_bitset<100> bitset(25); bitset.set(0); bitset.set(4); @@ -133,13 +133,13 @@ int test_bitset_print() TESTASSERT(fmt::format("{:b}", bitset) == "1000000000000000000010001"); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_bitset_resize() { { - srslte::bounded_bitset<100> bitset; + srsran::bounded_bitset<100> bitset; TESTASSERT(bitset.none() and bitset.size() == 0); bitset.resize(100); @@ -157,7 +157,7 @@ int test_bitset_resize() { // TEST: Reverse case - srslte::bounded_bitset<100, true> bitset; + srsran::bounded_bitset<100, true> bitset; TESTASSERT(bitset.none() and bitset.size() == 0); bitset.resize(100); @@ -173,17 +173,17 @@ int test_bitset_resize() TESTASSERT(bitset.count() == 25 and bitset.size() == 100); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int main() { - TESTASSERT(test_zero_bitset() == SRSLTE_SUCCESS); - TESTASSERT(test_ones_bitset() == SRSLTE_SUCCESS); - TESTASSERT(test_bitset_set() == SRSLTE_SUCCESS); - TESTASSERT(test_bitset_bitwise_oper() == SRSLTE_SUCCESS); - TESTASSERT(test_bitset_print() == SRSLTE_SUCCESS); - TESTASSERT(test_bitset_resize() == SRSLTE_SUCCESS); + TESTASSERT(test_zero_bitset() == SRSRAN_SUCCESS); + TESTASSERT(test_ones_bitset() == SRSRAN_SUCCESS); + TESTASSERT(test_bitset_set() == SRSRAN_SUCCESS); + TESTASSERT(test_bitset_bitwise_oper() == SRSRAN_SUCCESS); + TESTASSERT(test_bitset_print() == SRSRAN_SUCCESS); + TESTASSERT(test_bitset_resize() == SRSRAN_SUCCESS); printf("Success\n"); return 0; } diff --git a/lib/test/adt/bounded_vector_test.cc b/lib/test/adt/bounded_vector_test.cc index 34102813a..edc471bd5 100644 --- a/lib/test/adt/bounded_vector_test.cc +++ b/lib/test/adt/bounded_vector_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,10 +10,10 @@ * */ -#include "srslte/adt/bounded_vector.h" -#include "srslte/common/test_common.h" +#include "srsran/adt/bounded_vector.h" +#include "srsran/common/test_common.h" -namespace srslte { +namespace srsran { struct C { static int nof_copy_ctor; @@ -89,7 +89,7 @@ int test_ctor() TESTASSERT(a6.size() == 7); TESTASSERT(a5.size() == 0); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_obj_add_rem() @@ -135,7 +135,7 @@ int test_obj_add_rem() // TEST: erase a.erase(a.begin() + 1); - srslte::bounded_vector test = {1, 3, 3}; + srsran::bounded_vector test = {1, 3, 3}; TESTASSERT(a == test); // TEST: clear @@ -155,7 +155,7 @@ int test_obj_add_rem() a = std::move(a2); TESTASSERT(a.empty() and a2.empty()); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_move_only_type() @@ -176,23 +176,23 @@ int test_move_only_type() a2.push_back(moveonly()); TESTASSERT(a2.size() == 7); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int assert_dtor_consistency() { TESTASSERT(C::nof_dtor == C::nof_copy_ctor + C::nof_value_ctor + C::nof_move_ctor); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -} // namespace srslte +} // namespace srsran int main() { - TESTASSERT(srslte::test_ctor() == SRSLTE_SUCCESS); - TESTASSERT(srslte::test_obj_add_rem() == SRSLTE_SUCCESS); - TESTASSERT(srslte::test_move_only_type() == SRSLTE_SUCCESS); - TESTASSERT(srslte::assert_dtor_consistency() == SRSLTE_SUCCESS); + TESTASSERT(srsran::test_ctor() == SRSRAN_SUCCESS); + TESTASSERT(srsran::test_obj_add_rem() == SRSRAN_SUCCESS); + TESTASSERT(srsran::test_move_only_type() == SRSRAN_SUCCESS); + TESTASSERT(srsran::assert_dtor_consistency() == SRSRAN_SUCCESS); printf("Success\n"); return 0; } \ No newline at end of file diff --git a/lib/test/adt/circular_buffer_test.cc b/lib/test/adt/circular_buffer_test.cc index a2a7e1387..97db4b267 100644 --- a/lib/test/adt/circular_buffer_test.cc +++ b/lib/test/adt/circular_buffer_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,10 +10,10 @@ * */ -#include "srslte/adt/circular_buffer.h" -#include "srslte/common/test_common.h" +#include "srsran/adt/circular_buffer.h" +#include "srsran/common/test_common.h" -namespace srslte { +namespace srsran { int test_static_circular_buffer() { @@ -61,7 +61,7 @@ int test_static_circular_buffer() count++; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_queue_block_api() @@ -86,7 +86,7 @@ int test_queue_block_api() queue.stop(); t.join(); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_queue_block_api_2() @@ -110,16 +110,16 @@ int test_queue_block_api_2() } t.join(); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -} // namespace srslte +} // namespace srsran int main() { - TESTASSERT(srslte::test_static_circular_buffer() == SRSLTE_SUCCESS); - TESTASSERT(srslte::test_queue_block_api() == SRSLTE_SUCCESS); - TESTASSERT(srslte::test_queue_block_api_2() == SRSLTE_SUCCESS); - srslte::console("Success\n"); - return SRSLTE_SUCCESS; + TESTASSERT(srsran::test_static_circular_buffer() == SRSRAN_SUCCESS); + TESTASSERT(srsran::test_queue_block_api() == SRSRAN_SUCCESS); + TESTASSERT(srsran::test_queue_block_api_2() == SRSRAN_SUCCESS); + srsran::console("Success\n"); + return SRSRAN_SUCCESS; } \ No newline at end of file diff --git a/lib/test/adt/expected_test.cc b/lib/test/adt/expected_test.cc index 6607cb16c..99fd8dfe8 100644 --- a/lib/test/adt/expected_test.cc +++ b/lib/test/adt/expected_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,12 +10,12 @@ * */ -#include "srslte/adt/expected.h" -#include "srslte/common/test_common.h" +#include "srsran/adt/expected.h" +#include "srsran/common/test_common.h" int test_expected_trivial() { - srslte::expected exp; + srsran::expected exp; TESTASSERT(exp.has_value()); TESTASSERT(exp); @@ -24,7 +24,7 @@ int test_expected_trivial() TESTASSERT(exp.value() == 5); TESTASSERT(exp); - exp.set_error(srslte::default_error_t{}); + exp.set_error(srsran::default_error_t{}); TESTASSERT(not exp.has_value()); TESTASSERT(not exp); @@ -38,9 +38,9 @@ int test_expected_trivial() exp = 3; { - srslte::expected exp2 = exp; + srsran::expected exp2 = exp; TESTASSERT(exp2 and exp2.value() == 3); - srslte::expected exp3; + srsran::expected exp3; exp3 = exp2; TESTASSERT(exp3 and exp3.value() == 3); } @@ -48,14 +48,14 @@ int test_expected_trivial() exp.set_error(); { - srslte::expected exp2{exp}; + srsran::expected exp2{exp}; TESTASSERT(not exp2); - srslte::expected exp3; + srsran::expected exp3; exp3 = exp; TESTASSERT(not exp3); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } struct C { @@ -91,7 +91,7 @@ uint32_t C::count = 0; int test_expected_struct() { - srslte::expected exp; + srsran::expected exp; exp = C{5}; TESTASSERT(exp and exp.value().val == 5); TESTASSERT(C::count == 1); @@ -113,12 +113,12 @@ int test_expected_struct() exp.set_error(2); TESTASSERT(not exp and exp.error() == 2); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_unique_ptr() { - srslte::expected > exp; + srsran::expected > exp; TESTASSERT(exp); exp.value().reset(new C{2}); TESTASSERT(exp.value()->val == 2); @@ -129,12 +129,12 @@ int test_unique_ptr() TESTASSERT(exp2 and exp2.value()->val == 2); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int main() { - TESTASSERT(test_expected_trivial() == SRSLTE_SUCCESS); - TESTASSERT(test_expected_struct() == SRSLTE_SUCCESS); - TESTASSERT(test_unique_ptr() == SRSLTE_SUCCESS); + TESTASSERT(test_expected_trivial() == SRSRAN_SUCCESS); + TESTASSERT(test_expected_struct() == SRSRAN_SUCCESS); + TESTASSERT(test_unique_ptr() == SRSRAN_SUCCESS); } diff --git a/lib/test/adt/interval_test.cc b/lib/test/adt/interval_test.cc index 371f662a3..30ad0f43b 100644 --- a/lib/test/adt/interval_test.cc +++ b/lib/test/adt/interval_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,23 +10,23 @@ * */ -#include "srslte/adt/interval.h" -#include "srslte/common/test_common.h" +#include "srsran/adt/interval.h" +#include "srsran/common/test_common.h" int test_interval_init() { - srslte::interval I{}, I2{12, 15}, I3{12, 12}; + srsran::interval I{}, I2{12, 15}, I3{12, 12}; TESTASSERT(I.empty() and I.start() == 0 and I.stop() == 0); TESTASSERT(not I2.empty() and I2.start() == 12 and I2.stop() == 15); TESTASSERT(I3.empty() and I3.start() == 12 and I3.stop() == 12); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_interval_overlaps() { - srslte::interval I{10, 15}, I2{9, 11}, I3{11, 14}, I4{9, 16}, I5{14, 16}, I6{4, 10}, I7{15, 17}; + srsran::interval I{10, 15}, I2{9, 11}, I3{11, 14}, I4{9, 16}, I5{14, 16}, I6{4, 10}, I7{15, 17}; TESTASSERT(I.overlaps(I2)); TESTASSERT(I.overlaps(I3)); @@ -35,12 +35,12 @@ int test_interval_overlaps() TESTASSERT(not I.overlaps(I6)); TESTASSERT(not I.overlaps(I7)); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_interval_contains() { - srslte::interval I{5, 10}; + srsran::interval I{5, 10}; TESTASSERT(I.contains(5)); TESTASSERT(I.contains(6)); @@ -49,26 +49,26 @@ int test_interval_contains() TESTASSERT(not I.contains(11)); TESTASSERT(not I.contains(4)); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_interval_intersect() { - srslte::interval I{5, 10}, I2{3, 6}, I3{9, 12}, I4{10, 13}; + srsran::interval I{5, 10}, I2{3, 6}, I3{9, 12}, I4{10, 13}; - TESTASSERT(srslte::make_intersection(I, I2) == (I & I2)); - TESTASSERT((I & I2) == srslte::interval(5, 6)); - TESTASSERT((I & I3) == srslte::interval(9, 10)); + TESTASSERT(srsran::make_intersection(I, I2) == (I & I2)); + TESTASSERT((I & I2) == srsran::interval(5, 6)); + TESTASSERT((I & I3) == srsran::interval(9, 10)); TESTASSERT(not(I & I3).empty()); TESTASSERT((I & I4).empty()); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_interval_expand() { - srslte::interval I{}; - srslte::interval I2{}; + srsran::interval I{}; + srsran::interval I2{}; I.resize_by(5); TESTASSERT(I.length() == 5); @@ -79,15 +79,15 @@ int test_interval_expand() TESTASSERT(I2.length() == 3); // I2.expand_by(-4); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int main() { - TESTASSERT(test_interval_init() == SRSLTE_SUCCESS); - TESTASSERT(test_interval_overlaps() == SRSLTE_SUCCESS); - TESTASSERT(test_interval_contains() == SRSLTE_SUCCESS); - TESTASSERT(test_interval_intersect() == SRSLTE_SUCCESS); - TESTASSERT(test_interval_expand() == SRSLTE_SUCCESS); + TESTASSERT(test_interval_init() == SRSRAN_SUCCESS); + TESTASSERT(test_interval_overlaps() == SRSRAN_SUCCESS); + TESTASSERT(test_interval_contains() == SRSRAN_SUCCESS); + TESTASSERT(test_interval_intersect() == SRSRAN_SUCCESS); + TESTASSERT(test_interval_expand() == SRSRAN_SUCCESS); return 0; } diff --git a/lib/test/adt/mem_pool_test.cc b/lib/test/adt/mem_pool_test.cc index 63acd5fe4..f0c1f28b8 100644 --- a/lib/test/adt/mem_pool_test.cc +++ b/lib/test/adt/mem_pool_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,8 +10,8 @@ * */ -#include "srslte/adt/mem_pool.h" -#include "srslte/common/test_common.h" +#include "srsran/adt/mem_pool.h" +#include "srsran/common/test_common.h" class C { @@ -28,7 +28,7 @@ public: int C::default_ctor_counter = 0; int C::dtor_counter = 0; -srslte::big_obj_pool pool; +srsran::big_obj_pool pool; void* C::operator new(size_t sz) { @@ -72,12 +72,12 @@ int test_nontrivial_obj_pool() TESTASSERT(C::default_ctor_counter == 1); TESTASSERT(C::dtor_counter == 1); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int main() { - TESTASSERT(test_nontrivial_obj_pool() == SRSLTE_SUCCESS); - srslte::console("Success\n"); + TESTASSERT(test_nontrivial_obj_pool() == SRSRAN_SUCCESS); + srsran::console("Success\n"); return 0; } \ No newline at end of file diff --git a/lib/test/adt/observer_test.cc b/lib/test/adt/observer_test.cc index 239ec9579..9b0e59600 100644 --- a/lib/test/adt/observer_test.cc +++ b/lib/test/adt/observer_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,11 +10,11 @@ * */ -#include "srslte/adt/observer.h" -#include "srslte/common/test_common.h" +#include "srsran/adt/observer.h" +#include "srsran/common/test_common.h" -static_assert(srslte::is_observer >::value, "is_observer<> meta-function failed"); -static_assert(not srslte::is_observer >::value, "is_observer<> meta-function failed"); +static_assert(srsran::is_observer >::value, "is_observer<> meta-function failed"); +static_assert(not srsran::is_observer >::value, "is_observer<> meta-function failed"); struct M { M() = default; @@ -67,14 +67,14 @@ int observable_test() // TEST l-value arguments passed by value { M val; - srslte::observable subject; + srsran::observable subject; TESTASSERT(subject.nof_observers() == 0); - srslte::observer_id id1 = subject.subscribe([&val](M v) { val = std::move(v); }); + srsran::observer_id id1 = subject.subscribe([&val](M v) { val = std::move(v); }); lval_observer_tester observer{}, observer2{}; - srslte::observer_id id2 = subject.subscribe(observer); - srslte::observer_id id3 = subject.subscribe(observer2, &lval_observer_tester::foo); + srsran::observer_id id2 = subject.subscribe(observer); + srsran::observer_id id3 = subject.subscribe(observer2, &lval_observer_tester::foo); TESTASSERT(subject.nof_observers() == 3); TESTASSERT(val.val == 0); @@ -94,7 +94,7 @@ int observable_test() // Test l-value arguments passed by const ref { M val; - srslte::observable subject; + srsran::observable subject; TESTASSERT(subject.nof_observers() == 0); subject.subscribe([&val](const M& v) { val.val = v.val; }); @@ -113,7 +113,7 @@ int observable_test() // Test l-value arguments passed by ref { M val; - srslte::observable subject; + srsran::observable subject; TESTASSERT(subject.nof_observers() == 0); subject.subscribe([&val](M& v) { val = std::move(v); }); @@ -132,14 +132,14 @@ int observable_test() // Test r-value arguments { M val; - srslte::observable subject; + srsran::observable subject; TESTASSERT(subject.nof_observers() == 0); - srslte::observer_id id1 = subject.subscribe([&val](M&& v) { val = std::move(v); }); + srsran::observer_id id1 = subject.subscribe([&val](M&& v) { val = std::move(v); }); rref_observer_tester observer{}, observer2{}; - srslte::observer_id id2 = subject.subscribe(observer); - srslte::observer_id id3 = subject.subscribe(observer2, &rref_observer_tester::foo); + srsran::observer_id id2 = subject.subscribe(observer); + srsran::observer_id id3 = subject.subscribe(observer2, &rref_observer_tester::foo); subject.dispatch(M{3}); TESTASSERT(val.val == 3); @@ -152,12 +152,12 @@ int observable_test() TESTASSERT(subject.nof_observers() == 0); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int event_dispatcher_test() { - srslte::event_dispatcher signaller; + srsran::event_dispatcher signaller; M val; signaller.subscribe([&val](const M& ev) { val.val = ev.val; }); @@ -182,12 +182,12 @@ int event_dispatcher_test() TESTASSERT(observer.v.val == 2); TESTASSERT(observer2.v.val == 3); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int event_queue_test() { - srslte::event_queue signaller; + srsran::event_queue signaller; M val; signaller.subscribe([&val](const M& ev) { val.val = ev.val; }); @@ -207,42 +207,42 @@ int event_queue_test() TESTASSERT(observer.v.val == 2); TESTASSERT(observer2.v.val == 3); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int unique_subscribe_test() { { - srslte::event_dispatcher signaller; + srsran::event_dispatcher signaller; cref_observer_tester observer; TESTASSERT(signaller.nof_observers() == 0); { - srslte::unique_observer_id obs{signaller, observer}; + srsran::unique_observer_id obs{signaller, observer}; TESTASSERT(signaller.nof_observers() == 1); } TESTASSERT(signaller.nof_observers() == 0); } { - srslte::event_queue signaller; + srsran::event_queue signaller; cref_observer_tester observer; TESTASSERT(signaller.nof_observers() == 0); { - srslte::unique_observer_id obs{signaller, observer}; + srsran::unique_observer_id obs{signaller, observer}; TESTASSERT(signaller.nof_observers() == 1); } TESTASSERT(signaller.nof_observers() == 0); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int main() { - TESTASSERT(observable_test() == SRSLTE_SUCCESS); - TESTASSERT(event_dispatcher_test() == SRSLTE_SUCCESS); - TESTASSERT(event_queue_test() == SRSLTE_SUCCESS); - TESTASSERT(unique_subscribe_test() == SRSLTE_SUCCESS); + TESTASSERT(observable_test() == SRSRAN_SUCCESS); + TESTASSERT(event_dispatcher_test() == SRSRAN_SUCCESS); + TESTASSERT(event_queue_test() == SRSRAN_SUCCESS); + TESTASSERT(unique_subscribe_test() == SRSRAN_SUCCESS); printf("Success\n"); diff --git a/lib/test/adt/scope_exit_test.cc b/lib/test/adt/scope_exit_test.cc index 8e3bca022..69952182c 100644 --- a/lib/test/adt/scope_exit_test.cc +++ b/lib/test/adt/scope_exit_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,20 +10,20 @@ * */ -#include "srslte/adt/scope_exit.h" -#include "srslte/common/test_common.h" +#include "srsran/adt/scope_exit.h" +#include "srsran/common/test_common.h" int test_scope_exit(int* value) { - auto test_exit = srslte::make_scope_exit([value]() { - *value = SRSLTE_SUCCESS; + auto test_exit = srsran::make_scope_exit([value]() { + *value = SRSRAN_SUCCESS; printf("Finished successfully\n"); }); // TEST: simple scope_exit call int nof_calls = 0; { - auto scope_exit = srslte::make_scope_exit([&]() { + auto scope_exit = srsran::make_scope_exit([&]() { nof_calls++; printf("TEST1: Exited first scope\n"); }); @@ -34,7 +34,7 @@ int test_scope_exit(int* value) // TEST: Cancelling scope_exit call via release() nof_calls = 0; { - auto scope_exit = srslte::make_scope_exit([&]() { + auto scope_exit = srsran::make_scope_exit([&]() { nof_calls++; printf("TEST2: This should not be called\n"); }); @@ -47,7 +47,7 @@ int test_scope_exit(int* value) nof_calls = 0; { printf("TEST3: Entered third scope\n"); - auto scope_exit = srslte::make_scope_exit([&]() { nof_calls++; }); + auto scope_exit = srsran::make_scope_exit([&]() { nof_calls++; }); auto scope_exit2{std::move(scope_exit)}; } TESTASSERT(nof_calls == 1); @@ -56,16 +56,16 @@ int test_scope_exit(int* value) { nof_calls = 0; auto task = [&nof_calls]() { nof_calls += 2; }; - auto scope_exit = srslte::make_scope_exit(task); + auto scope_exit = srsran::make_scope_exit(task); } TESTASSERT(nof_calls == 2); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int main() { - int ret = SRSLTE_ERROR; - TESTASSERT(test_scope_exit(&ret) == SRSLTE_SUCCESS); - TESTASSERT(ret == SRSLTE_SUCCESS); + int ret = SRSRAN_ERROR; + TESTASSERT(test_scope_exit(&ret) == SRSRAN_SUCCESS); + TESTASSERT(ret == SRSRAN_SUCCESS); } \ No newline at end of file diff --git a/lib/test/adt/span_test.cc b/lib/test/adt/span_test.cc index 8d43947ff..c48eb7b3d 100644 --- a/lib/test/adt/span_test.cc +++ b/lib/test/adt/span_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,16 +10,16 @@ * */ -#include "srslte/adt/span.h" -#include "srslte/common/byte_buffer.h" -#include "srslte/common/test_common.h" +#include "srsran/adt/span.h" +#include "srsran/common/byte_buffer.h" +#include "srsran/common/test_common.h" int test_span_access() { std::array values{1, 2, 3, 4, 5, 6, 7}; { - srslte::span view = values; + srsran::span view = values; // access operators TESTASSERT(view.size() == 7); @@ -38,7 +38,7 @@ int test_span_access() } TESTASSERT(values.size() == 7); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_span_conversion() @@ -48,7 +48,7 @@ int test_span_conversion() { // TEST: changing individual values - srslte::span v = values, v2 = values2; + srsran::span v = values, v2 = values2; TESTASSERT(v == v2); v[0] = 3; @@ -60,7 +60,7 @@ int test_span_conversion() { // TEST: const context - const srslte::span v = values, v2 = values2; + const srsran::span v = values, v2 = values2; TESTASSERT(v != v2); TESTASSERT(v[0] == 3); TESTASSERT(v2[0] == 2); @@ -71,19 +71,19 @@ int test_span_conversion() { // TEST: raw arrays int carray[] = {2, 3, 4, 5, 6, 7, 8}; - srslte::span v = values, v2 = carray; + srsran::span v = values, v2 = carray; TESTASSERT(v == v2); TESTASSERT(v2.size() == v.size()); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_byte_buffer_conversion() { - auto foo = [](srslte::byte_span buffer) { return buffer.size() == 5 and buffer[4] == 4; }; - auto cfoo = [](const srslte::byte_span buffer) { return buffer.size() == 5 and buffer[4] == 4; }; - srslte::byte_buffer_t pdu; + auto foo = [](srsran::byte_span buffer) { return buffer.size() == 5 and buffer[4] == 4; }; + auto cfoo = [](const srsran::byte_span buffer) { return buffer.size() == 5 and buffer[4] == 4; }; + srsran::byte_buffer_t pdu; pdu.N_bytes = 5; pdu.msg[0] = 0; pdu.msg[1] = 1; @@ -92,33 +92,33 @@ int test_byte_buffer_conversion() pdu.msg[4] = 4; { - auto v = srslte::make_span(pdu); + auto v = srsran::make_span(pdu); TESTASSERT(v.size() == 5); TESTASSERT(v[0] == 0); TESTASSERT(v[2] == 2); TESTASSERT(v[4] == 4); } - const srslte::byte_buffer_t& pdu2 = pdu; + const srsran::byte_buffer_t& pdu2 = pdu; { - const auto v = srslte::make_span(pdu2); + const auto v = srsran::make_span(pdu2); TESTASSERT(v.size() == 5); TESTASSERT(v[0] == 0); TESTASSERT(v[2] == 2); TESTASSERT(v[4] == 4); } - TESTASSERT(foo(srslte::make_span(pdu))); - TESTASSERT(cfoo(srslte::make_span(pdu))); + TESTASSERT(foo(srsran::make_span(pdu))); + TESTASSERT(cfoo(srsran::make_span(pdu))); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int main() { - TESTASSERT(test_span_access() == SRSLTE_SUCCESS); - TESTASSERT(test_span_conversion() == SRSLTE_SUCCESS); - TESTASSERT(test_byte_buffer_conversion() == SRSLTE_SUCCESS); + TESTASSERT(test_span_access() == SRSRAN_SUCCESS); + TESTASSERT(test_span_conversion() == SRSRAN_SUCCESS); + TESTASSERT(test_byte_buffer_conversion() == SRSRAN_SUCCESS); printf("Success\n"); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } diff --git a/lib/test/asn1/CMakeLists.txt b/lib/test/asn1/CMakeLists.txt index 99c9d17f2..eb8e6bc3a 100644 --- a/lib/test/asn1/CMakeLists.txt +++ b/lib/test/asn1/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -7,55 +7,55 @@ # add_executable(s1ap_asn1_test s1ap_test.cc) -target_link_libraries(s1ap_asn1_test srslte_common srslte_asn1 s1ap_asn1) +target_link_libraries(s1ap_asn1_test srsran_common srsran_asn1 s1ap_asn1) add_test(s1ap_asn1_test s1ap_asn1_test) -add_executable(srslte_asn1_rrc_mcch_test srslte_asn1_rrc_mcch_test.cc) -target_link_libraries(srslte_asn1_rrc_mcch_test rrc_asn1 srslte_common) -add_test(srslte_asn1_rrc_mcch_test srslte_asn1_rrc_mcch_test) +add_executable(srsran_asn1_rrc_mcch_test srsran_asn1_rrc_mcch_test.cc) +target_link_libraries(srsran_asn1_rrc_mcch_test rrc_asn1 srsran_common) +add_test(srsran_asn1_rrc_mcch_test srsran_asn1_rrc_mcch_test) -add_executable(srslte_asn1_rrc_meas_test srslte_asn1_rrc_meas_test.cc) -target_link_libraries(srslte_asn1_rrc_meas_test rrc_asn1 rrc_nr_asn1 srslte_common) -add_test(srslte_asn1_rrc_meas_test srslte_asn1_rrc_meas_test) +add_executable(srsran_asn1_rrc_meas_test srsran_asn1_rrc_meas_test.cc) +target_link_libraries(srsran_asn1_rrc_meas_test rrc_asn1 rrc_nr_asn1 srsran_common) +add_test(srsran_asn1_rrc_meas_test srsran_asn1_rrc_meas_test) -add_executable(srslte_asn1_rrc_ul_dcch_test srslte_asn1_rrc_ul_dcch_test.cc) -target_link_libraries(srslte_asn1_rrc_ul_dcch_test rrc_asn1 srslte_common) -add_test(srslte_asn1_rrc_ul_dcch_test srslte_asn1_rrc_ul_dcch_test) +add_executable(srsran_asn1_rrc_ul_dcch_test srsran_asn1_rrc_ul_dcch_test.cc) +target_link_libraries(srsran_asn1_rrc_ul_dcch_test rrc_asn1 srsran_common) +add_test(srsran_asn1_rrc_ul_dcch_test srsran_asn1_rrc_ul_dcch_test) -add_executable(srslte_asn1_rrc_dl_ccch_test srslte_asn1_rrc_dl_ccch_test.cc) -target_link_libraries(srslte_asn1_rrc_dl_ccch_test rrc_asn1 srslte_common) -add_test(srslte_asn1_rrc_dl_ccch_test srslte_asn1_rrc_dl_ccch_test) +add_executable(srsran_asn1_rrc_dl_ccch_test srsran_asn1_rrc_dl_ccch_test.cc) +target_link_libraries(srsran_asn1_rrc_dl_ccch_test rrc_asn1 srsran_common) +add_test(srsran_asn1_rrc_dl_ccch_test srsran_asn1_rrc_dl_ccch_test) -add_executable(srslte_asn1_rrc_dl_dcch_test srslte_asn1_rrc_dl_dcch_test.cc) -target_link_libraries(srslte_asn1_rrc_dl_dcch_test rrc_asn1 srslte_common) -add_test(srslte_asn1_rrc_dl_dcch_test srslte_asn1_rrc_dl_dcch_test) +add_executable(srsran_asn1_rrc_dl_dcch_test srsran_asn1_rrc_dl_dcch_test.cc) +target_link_libraries(srsran_asn1_rrc_dl_dcch_test rrc_asn1 srsran_common) +add_test(srsran_asn1_rrc_dl_dcch_test srsran_asn1_rrc_dl_dcch_test) -add_executable(srslte_asn1_nas_test srslte_asn1_nas_test.cc) -target_link_libraries(srslte_asn1_nas_test srslte_common srslte_phy srslte_asn1) -add_test(srslte_asn1_nas_test srslte_asn1_nas_test) +add_executable(srsran_asn1_nas_test srsran_asn1_nas_test.cc) +target_link_libraries(srsran_asn1_nas_test srsran_common srsran_phy srsran_asn1) +add_test(srsran_asn1_nas_test srsran_asn1_nas_test) add_executable(asn1_utils_test asn1_utils_test.cc) -target_link_libraries(asn1_utils_test asn1_utils srslte_common) +target_link_libraries(asn1_utils_test asn1_utils srsran_common) add_test(asn1_utils_test asn1_utils_test) add_executable(rrc_asn1_test rrc_test.cc) -target_link_libraries(rrc_asn1_test rrc_asn1 asn1_utils srslte_common) +target_link_libraries(rrc_asn1_test rrc_asn1 asn1_utils srsran_common) add_test(rrc_asn1_test rrc_asn1_test) -add_executable(srslte_asn1_rrc_nr_test srslte_asn1_rrc_nr_test.cc) -target_link_libraries(srslte_asn1_rrc_nr_test rrc_nr_asn1 asn1_utils srslte_common) -add_test(srslte_asn1_rrc_nr_test srslte_asn1_rrc_nr_test) +add_executable(srsran_asn1_rrc_nr_test srsran_asn1_rrc_nr_test.cc) +target_link_libraries(srsran_asn1_rrc_nr_test rrc_nr_asn1 asn1_utils srsran_common) +add_test(srsran_asn1_rrc_nr_test srsran_asn1_rrc_nr_test) add_executable(ngap_asn1_test ngap_test.cc) -target_link_libraries(ngap_asn1_test ngap_nr_asn1 srslte_common) +target_link_libraries(ngap_asn1_test ngap_nr_asn1 srsran_common) add_test(ngap_asn1_test ngap_asn1_test) add_executable(rrc_nr_utils_test rrc_nr_utils_test.cc) -target_link_libraries(rrc_nr_utils_test ngap_nr_asn1 srslte_common rrc_nr_asn1) +target_link_libraries(rrc_nr_utils_test ngap_nr_asn1 srsran_common rrc_nr_asn1) add_test(rrc_nr_utils_test rrc_nr_utils_test) add_executable(rrc_asn1_decoder rrc_asn1_decoder.cc) target_link_libraries(rrc_asn1_decoder rrc_asn1) add_executable(nas_decoder nas_decoder.cc) -target_link_libraries(nas_decoder srslte_asn1) +target_link_libraries(nas_decoder srsran_asn1) diff --git a/lib/test/asn1/asn1_utils_test.cc b/lib/test/asn1/asn1_utils_test.cc index a3084d360..797a5f182 100644 --- a/lib/test/asn1/asn1_utils_test.cc +++ b/lib/test/asn1/asn1_utils_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,8 +10,8 @@ * */ -#include "srslte/asn1/asn1_utils.h" -#include "srslte/common/test_common.h" +#include "srsran/asn1/asn1_utils.h" +#include "srsran/common/test_common.h" #include #include #include @@ -22,7 +22,7 @@ using namespace asn1; std::random_device rd; std::mt19937 g(rd()); -srslte::log_sink_spy* test_spy = nullptr; +srsran::log_sink_spy* test_spy = nullptr; int test_arrays() { @@ -369,7 +369,7 @@ int test_bitstring() // printf("%s==%s\n", dyn_bstr1.to_string().c_str(), dyn_bstr2.to_string().c_str()); // disable temporarily the prints to check failures - // srslte::nullsink_log null_log("NULL"); + // srsran::nullsink_log null_log("NULL"); // bit_ref bref3(&buffer[0], sizeof(buffer)); // TESTASSERT(dyn_bstr1.pack(bref3, false, 5, 10)==SRSASN_ERROR_ENCODE_FAIL); @@ -648,13 +648,13 @@ int main() { // Setup the log spy to intercept error and warning log entries. if (!srslog::install_custom_sink( - srslte::log_sink_spy::name(), - std::unique_ptr(new srslte::log_sink_spy(srslog::get_default_log_formatter())))) { - return SRSLTE_ERROR; + srsran::log_sink_spy::name(), + std::unique_ptr(new srsran::log_sink_spy(srslog::get_default_log_formatter())))) { + return SRSRAN_ERROR; } - test_spy = static_cast(srslog::find_sink(srslte::log_sink_spy::name())); + test_spy = static_cast(srslog::find_sink(srsran::log_sink_spy::name())); if (!test_spy) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } auto& asn1_logger = srslog::fetch_basic_logger("ASN1", *test_spy, false); diff --git a/lib/test/asn1/nas_decoder.cc b/lib/test/asn1/nas_decoder.cc index 4af0ecaf2..c007d9095 100644 --- a/lib/test/asn1/nas_decoder.cc +++ b/lib/test/asn1/nas_decoder.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,9 +10,9 @@ * */ -#include "srslte/asn1/liblte_mme.h" -#include "srslte/common/common.h" -#include "srslte/phy/common/phy_common.h" +#include "srsran/asn1/liblte_mme.h" +#include "srsran/common/common.h" +#include "srsran/phy/common/phy_common.h" #include #include diff --git a/lib/test/asn1/ngap_test.cc b/lib/test/asn1/ngap_test.cc index 20403d99a..33fdc610b 100644 --- a/lib/test/asn1/ngap_test.cc +++ b/lib/test/asn1/ngap_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,8 +10,8 @@ * */ -#include "srslte/asn1/ngap.h" -#include "srslte/common/test_common.h" +#include "srsran/asn1/ngap.h" +#include "srsran/common/test_common.h" using namespace asn1; using namespace asn1::ngap_nr; diff --git a/lib/test/asn1/rrc_asn1_decoder.cc b/lib/test/asn1/rrc_asn1_decoder.cc index 564247f15..51c501baa 100644 --- a/lib/test/asn1/rrc_asn1_decoder.cc +++ b/lib/test/asn1/rrc_asn1_decoder.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,8 +13,8 @@ #include #include -#include "srslte/asn1/asn1_utils.h" -#include "srslte/asn1/rrc.h" +#include "srsran/asn1/asn1_utils.h" +#include "srsran/asn1/rrc.h" using namespace std; diff --git a/lib/test/asn1/rrc_nr_utils_test.cc b/lib/test/asn1/rrc_nr_utils_test.cc index d5420f4a5..59e41ce24 100644 --- a/lib/test/asn1/rrc_nr_utils_test.cc +++ b/lib/test/asn1/rrc_nr_utils_test.cc @@ -13,12 +13,12 @@ #include #include -#include "srslte/asn1/rrc_nr.h" -#include "srslte/asn1/rrc_nr_utils.h" -#include "srslte/common/common.h" -#include "srslte/common/test_common.h" +#include "srsran/asn1/rrc_nr.h" +#include "srsran/asn1/rrc_nr_utils.h" +#include "srsran/common/common.h" +#include "srsran/common/test_common.h" -using namespace srslte; +using namespace srsran; int test_rlc_config() { @@ -34,10 +34,10 @@ int test_rlc_config() srslog::fetch_basic_logger("RRC").info("RLC NR Config: \n %s", jw.to_string().c_str()); rlc_config_t rlc_cfg = make_rlc_config_t(rlc_cfg_asn1); - TESTASSERT(rlc_cfg.rat == srslte_rat_t::nr); + TESTASSERT(rlc_cfg.rat == srsran_rat_t::nr); TESTASSERT(rlc_cfg.um_nr.sn_field_length == rlc_um_nr_sn_size_t::size12bits); TESTASSERT(rlc_cfg.um_nr.UM_Window_Size == 2048); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_mac_rach_common_config() @@ -63,7 +63,7 @@ int test_mac_rach_common_config() TESTASSERT(rach_nr_cfg.PreambleReceivedTargetPower == -110); TESTASSERT(rach_nr_cfg.preambleTransMax == 7); TESTASSERT(rach_nr_cfg.powerRampingStep == 4); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int main() @@ -78,8 +78,8 @@ int main() // Start the log backend. srslog::init(); - TESTASSERT(test_rlc_config() == SRSLTE_SUCCESS); - TESTASSERT(test_mac_rach_common_config() == SRSLTE_SUCCESS); + TESTASSERT(test_rlc_config() == SRSRAN_SUCCESS); + TESTASSERT(test_mac_rach_common_config() == SRSRAN_SUCCESS); srslog::flush(); diff --git a/lib/test/asn1/rrc_test.cc b/lib/test/asn1/rrc_test.cc index 5997aa45c..425aea731 100644 --- a/lib/test/asn1/rrc_test.cc +++ b/lib/test/asn1/rrc_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,8 +10,8 @@ * */ -#include "srslte/asn1/rrc.h" -#include "srslte/common/test_common.h" +#include "srsran/asn1/rrc.h" +#include "srsran/common/test_common.h" #include using namespace asn1; @@ -114,7 +114,7 @@ int test_compare_eq() drb1 = drb2; TESTASSERT(drb1 == drb2); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_mib_msg() diff --git a/lib/test/asn1/s1ap_test.cc b/lib/test/asn1/s1ap_test.cc index 0e34bd3ed..933546831 100644 --- a/lib/test/asn1/s1ap_test.cc +++ b/lib/test/asn1/s1ap_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,8 +10,8 @@ * */ -#include "srslte/asn1/s1ap.h" -#include "srslte/common/test_common.h" +#include "srsran/asn1/s1ap.h" +#include "srsran/common/test_common.h" #include #include @@ -84,7 +84,7 @@ int test_init_ctxt_setup_req() TESTASSERT(test_pack_unpack_consistency(pdu) == SRSASN_SUCCESS); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_ue_ctxt_release_req() @@ -107,7 +107,7 @@ int test_ue_ctxt_release_req() TESTASSERT(test_pack_unpack_consistency(pdu) == SRSASN_SUCCESS); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } template @@ -116,7 +116,7 @@ bool is_same_type(U& u) return std::is_same::value; } -int test_proc_id_consistency(srslte::log_sink_spy& spy) +int test_proc_id_consistency(srsran::log_sink_spy& spy) { s1ap_pdu_c pdu; @@ -150,7 +150,7 @@ int test_proc_id_consistency(srslte::log_sink_spy& spy) TESTASSERT(unsuc.crit.value == crit_opts::reject); TESTASSERT(is_same_type(unsuc.value.init_context_setup_fail())); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_ho_request() @@ -186,7 +186,7 @@ int test_ho_request() TESTASSERT(test_pack_unpack_consistency(pdu) == SRSASN_SUCCESS); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_enb_status_transfer() @@ -231,7 +231,7 @@ int test_enb_status_transfer() TESTASSERT(test_pack_unpack_consistency(pdu) == SRSASN_SUCCESS); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int unpack_test_served_gummeis_with_multiple_plmns() @@ -246,7 +246,7 @@ int unpack_test_served_gummeis_with_multiple_plmns() TESTASSERT(input_pdu.unpack(bref) == SRSASN_SUCCESS); TESTASSERT(asn1::test_pack_unpack_consistency(input_pdu) == SRSASN_SUCCESS); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_load_info_obj() @@ -257,7 +257,7 @@ int test_load_info_obj() TESTASSERT(container.erab_failed_to_setup_list_ctxt_su_res.value[0].id == ASN1_S1AP_ID_ERAB_ITEM); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_initial_ctxt_setup_response() @@ -287,12 +287,12 @@ int test_initial_ctxt_setup_response() uint8_t buffer[1024]; asn1::bit_ref bref(buffer, sizeof(buffer)); - TESTASSERT(tx_pdu.pack(bref) == SRSLTE_SUCCESS); + TESTASSERT(tx_pdu.pack(bref) == SRSRAN_SUCCESS); srslog::fetch_basic_logger("TEST").info( buffer, bref.distance_bytes(), "message (nof bytes = %d):", bref.distance_bytes()); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_eci_pack() @@ -334,7 +334,7 @@ int test_eci_pack() srslog::fetch_basic_logger("TEST").info(buffer, bref.distance_bytes(), "Packed cell id:"); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_paging() @@ -350,21 +350,21 @@ int test_paging() TESTASSERT(input_pdu.unpack(bref) == SRSASN_SUCCESS); TESTASSERT(asn1::test_pack_unpack_consistency(input_pdu) == SRSASN_SUCCESS); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int main() { // Setup the log spy to intercept error and warning log entries. if (!srslog::install_custom_sink( - srslte::log_sink_spy::name(), - std::unique_ptr(new srslte::log_sink_spy(srslog::get_default_log_formatter())))) { - return SRSLTE_ERROR; + srsran::log_sink_spy::name(), + std::unique_ptr(new srsran::log_sink_spy(srslog::get_default_log_formatter())))) { + return SRSRAN_ERROR; } - auto* spy = static_cast(srslog::find_sink(srslte::log_sink_spy::name())); + auto* spy = static_cast(srslog::find_sink(srsran::log_sink_spy::name())); if (!spy) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } auto& asn1_logger = srslog::fetch_basic_logger("ASN1", *spy, false); diff --git a/lib/test/asn1/srslte_asn1_nas_test.cc b/lib/test/asn1/srsran_asn1_nas_test.cc similarity index 92% rename from lib/test/asn1/srslte_asn1_nas_test.cc rename to lib/test/asn1/srsran_asn1_nas_test.cc index 1831b2231..a975aa885 100644 --- a/lib/test/asn1/srslte_asn1_nas_test.cc +++ b/lib/test/asn1/srsran_asn1_nas_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,11 +10,11 @@ * */ -#include "srslte/asn1/liblte_mme.h" -#include "srslte/srslog/srslog.h" +#include "srsran/asn1/liblte_mme.h" +#include "srsran/srslog/srslog.h" #include -#include -#include +#include +#include #define TESTASSERT(cond) \ { \ @@ -30,9 +30,9 @@ int nas_dedicated_eps_bearer_context_setup_request_test() nas_logger.set_level(srslog::basic_levels::debug); nas_logger.set_hex_dump_max_size(128); - srslte::unique_byte_buffer_t tst_msg, out_msg; - tst_msg = srslte::make_byte_buffer(); - out_msg = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t tst_msg, out_msg; + tst_msg = srsran::make_byte_buffer(); + out_msg = srsran::make_byte_buffer(); LIBLTE_MME_ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_MSG_STRUCT ded_bearer_req; @@ -80,7 +80,7 @@ int nas_dedicated_eps_bearer_context_setup_request_test() LIBLTE_MME_TFT_PACKET_FILTER_COMPONENT_TYPE_ID_SINGLE_LOCAL_PORT_TYPE); uint16_t port; - srslte::uint8_to_uint16(&ded_bearer_req.tft.packet_filter_list[0].filter[1], &port); + srsran::uint8_to_uint16(&ded_bearer_req.tft.packet_filter_list[0].filter[1], &port); TESTASSERT(port == 2222); // Linked Transaction Identifier diff --git a/lib/test/asn1/srslte_asn1_rrc_dl_ccch_test.cc b/lib/test/asn1/srsran_asn1_rrc_dl_ccch_test.cc similarity index 96% rename from lib/test/asn1/srslte_asn1_rrc_dl_ccch_test.cc rename to lib/test/asn1/srsran_asn1_rrc_dl_ccch_test.cc index 6bdbeb827..b20e77a55 100644 --- a/lib/test/asn1/srslte_asn1_rrc_dl_ccch_test.cc +++ b/lib/test/asn1/srsran_asn1_rrc_dl_ccch_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,8 +10,8 @@ * */ -#include "srslte/asn1/rrc/dl_ccch_msg.h" -#include "srslte/common/bcd_helpers.h" +#include "srsran/asn1/rrc/dl_ccch_msg.h" +#include "srsran/common/bcd_helpers.h" #include using namespace asn1; diff --git a/lib/test/asn1/srslte_asn1_rrc_dl_dcch_test.cc b/lib/test/asn1/srsran_asn1_rrc_dl_dcch_test.cc similarity index 95% rename from lib/test/asn1/srslte_asn1_rrc_dl_dcch_test.cc rename to lib/test/asn1/srsran_asn1_rrc_dl_dcch_test.cc index c9daea4ed..74dd117a7 100644 --- a/lib/test/asn1/srslte_asn1_rrc_dl_dcch_test.cc +++ b/lib/test/asn1/srsran_asn1_rrc_dl_dcch_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,8 +10,8 @@ * */ -#include "srslte/asn1/rrc/dl_dcch_msg.h" -#include "srslte/common/bcd_helpers.h" +#include "srsran/asn1/rrc/dl_dcch_msg.h" +#include "srsran/common/bcd_helpers.h" #include using namespace asn1; diff --git a/lib/test/asn1/srslte_asn1_rrc_mcch_test.cc b/lib/test/asn1/srsran_asn1_rrc_mcch_test.cc similarity index 95% rename from lib/test/asn1/srslte_asn1_rrc_mcch_test.cc rename to lib/test/asn1/srsran_asn1_rrc_mcch_test.cc index b111a92b6..697d70cb2 100644 --- a/lib/test/asn1/srslte_asn1_rrc_mcch_test.cc +++ b/lib/test/asn1/srsran_asn1_rrc_mcch_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,10 +10,10 @@ * */ -#include "srslte/asn1/rrc.h" -#include "srslte/asn1/rrc_utils.h" -#include "srslte/common/bcd_helpers.h" -#include "srslte/interfaces/rrc_interface_types.h" +#include "srsran/asn1/rrc.h" +#include "srsran/asn1/rrc_utils.h" +#include "srsran/common/bcd_helpers.h" +#include "srsran/interfaces/rrc_interface_types.h" #include using namespace asn1::rrc; @@ -71,7 +71,7 @@ int meas_obj_test() .mbms_session_info_list_r9[0] .tmgi_r9.plmn_id_r9.explicit_value_r9() .mcc_present); - srslte::plmn_id_t plmn = srslte::make_plmn_id_t( + srsran::plmn_id_t plmn = srsran::make_plmn_id_t( area_cfg_r9->pmch_info_list_r9[0].mbms_session_info_list_r9[0].tmgi_r9.plmn_id_r9.explicit_value_r9()); TESTASSERT(plmn.to_string() == "987654"); TESTASSERT(area_cfg_r9->pmch_info_list_r9[0].mbms_session_info_list_r9[0].tmgi_r9.service_id_r9.to_string() == @@ -94,7 +94,7 @@ int meas_obj_test() .mbms_session_info_list_r9[0] .tmgi_r9.plmn_id_r9.explicit_value_r9() .mcc_present); - plmn = srslte::make_plmn_id_t( + plmn = srsran::make_plmn_id_t( area_cfg_r9->pmch_info_list_r9[0].mbms_session_info_list_r9[0].tmgi_r9.plmn_id_r9.explicit_value_r9()); TESTASSERT(plmn.to_string() == "987654"); TESTASSERT(area_cfg_r9->pmch_info_list_r9[1].mbms_session_info_list_r9[0].tmgi_r9.service_id_r9.to_string() == diff --git a/lib/test/asn1/srslte_asn1_rrc_meas_test.cc b/lib/test/asn1/srsran_asn1_rrc_meas_test.cc similarity index 93% rename from lib/test/asn1/srslte_asn1_rrc_meas_test.cc rename to lib/test/asn1/srsran_asn1_rrc_meas_test.cc index 242054270..898d714fc 100644 --- a/lib/test/asn1/srslte_asn1_rrc_meas_test.cc +++ b/lib/test/asn1/srsran_asn1_rrc_meas_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,10 +10,10 @@ * */ -#include "srslte/asn1/rrc/ul_dcch_msg.h" -#include "srslte/asn1/rrc_utils.h" -#include "srslte/common/bcd_helpers.h" -#include "srslte/interfaces/rrc_interface_types.h" +#include "srsran/asn1/rrc/ul_dcch_msg.h" +#include "srsran/asn1/rrc_utils.h" +#include "srsran/common/bcd_helpers.h" +#include "srsran/interfaces/rrc_interface_types.h" #include #define TESTASSERT(cond) \ @@ -61,7 +61,7 @@ int meas_obj_test() TESTASSERT(meas_list[0].cgi_info_present); TESTASSERT(meas_list[0].cgi_info.plmn_id_list_present); TESTASSERT(meas_list[0].cgi_info.cell_global_id.plmn_id.mcc_present); - srslte::plmn_id_t plmn = srslte::make_plmn_id_t(meas_list[0].cgi_info.cell_global_id.plmn_id); + srsran::plmn_id_t plmn = srsran::make_plmn_id_t(meas_list[0].cgi_info.cell_global_id.plmn_id); TESTASSERT(plmn.to_string() == "89878"); TESTASSERT(meas_list[0].cgi_info.cell_global_id.cell_id.to_number() == 0x1084104); TESTASSERT(meas_list[0].cgi_info.tac.to_number() == 0x1042); diff --git a/lib/test/asn1/srslte_asn1_rrc_nr_test.cc b/lib/test/asn1/srsran_asn1_rrc_nr_test.cc similarity index 96% rename from lib/test/asn1/srslte_asn1_rrc_nr_test.cc rename to lib/test/asn1/srsran_asn1_rrc_nr_test.cc index 57f1da08b..ed135bfa5 100644 --- a/lib/test/asn1/srslte_asn1_rrc_nr_test.cc +++ b/lib/test/asn1/srsran_asn1_rrc_nr_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,8 +10,8 @@ * */ -#include "srslte/asn1/rrc_nr.h" -#include "srslte/common/test_common.h" +#include "srsran/asn1/rrc_nr.h" +#include "srsran/common/test_common.h" #include using namespace asn1; @@ -122,7 +122,7 @@ int test_eutra_nr_capabilities() srslog::fetch_basic_logger("RRC").info( buffer, bref.distance_bytes(), "Packed cap struct (%d bytes):", bref.distance_bytes()); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_ue_mrdc_capabilities() @@ -139,7 +139,7 @@ int test_ue_mrdc_capabilities() TESTASSERT(test_pack_unpack_consistency(mrdc_cap) == SRSASN_SUCCESS); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_ue_rrc_reconfiguration() @@ -195,7 +195,7 @@ int test_ue_rrc_reconfiguration() TESTASSERT(cell_group_cfg.mac_cell_group_cfg_present == true); TESTASSERT(cell_group_cfg.phys_cell_group_cfg_present == true); TESTASSERT(cell_group_cfg.sp_cell_cfg_present == true); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_radio_bearer_config() @@ -213,7 +213,7 @@ int test_radio_bearer_config() TESTASSERT(radio_bearer_cfg.security_cfg_present == true); TESTASSERT(radio_bearer_cfg.security_cfg.security_algorithm_cfg_present == true); TESTASSERT(radio_bearer_cfg.security_cfg.key_to_use_present == true); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_cell_group_config() @@ -294,7 +294,7 @@ int test_cell_group_config() // asn1::json_writer json_writer; // cell_group_cfg.to_json(json_writer); // srslog::fetch_basic_logger("RRC").info("RRC Secondary Cell Group: Content: %s\n", json_writer.to_string().c_str()); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int main() @@ -309,11 +309,11 @@ int main() // Start the log backend. srslog::init(); - TESTASSERT(test_eutra_nr_capabilities() == SRSLTE_SUCCESS); - TESTASSERT(test_ue_mrdc_capabilities() == SRSLTE_SUCCESS); - TESTASSERT(test_ue_rrc_reconfiguration() == SRSLTE_SUCCESS); - TESTASSERT(test_radio_bearer_config() == SRSLTE_SUCCESS); - TESTASSERT(test_cell_group_config() == SRSLTE_SUCCESS); + TESTASSERT(test_eutra_nr_capabilities() == SRSRAN_SUCCESS); + TESTASSERT(test_ue_mrdc_capabilities() == SRSRAN_SUCCESS); + TESTASSERT(test_ue_rrc_reconfiguration() == SRSRAN_SUCCESS); + TESTASSERT(test_radio_bearer_config() == SRSRAN_SUCCESS); + TESTASSERT(test_cell_group_config() == SRSRAN_SUCCESS); srslog::flush(); printf("Success\n"); diff --git a/lib/test/asn1/srslte_asn1_rrc_ul_dcch_test.cc b/lib/test/asn1/srsran_asn1_rrc_ul_dcch_test.cc similarity index 96% rename from lib/test/asn1/srslte_asn1_rrc_ul_dcch_test.cc rename to lib/test/asn1/srsran_asn1_rrc_ul_dcch_test.cc index 46e33935e..1e9c3dedc 100644 --- a/lib/test/asn1/srslte_asn1_rrc_ul_dcch_test.cc +++ b/lib/test/asn1/srsran_asn1_rrc_ul_dcch_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,8 +11,8 @@ */ #include "../../../srsue/hdr/stack/rrc/rrc.h" // for rrc_args_t -#include "srslte/asn1/rrc/ul_dcch_msg.h" -#include "srslte/common/mac_pcap.h" +#include "srsran/asn1/rrc/ul_dcch_msg.h" +#include "srsran/common/mac_pcap.h" #include using namespace asn1::rrc; @@ -27,7 +27,7 @@ using namespace asn1::rrc; } \ } -int rrc_ue_cap_info_test(srslte::mac_pcap* pcap) +int rrc_ue_cap_info_test(srsran::mac_pcap* pcap) { auto& rrc_logger = srslog::fetch_basic_logger("RRC", false); rrc_logger.set_level(srslog::basic_levels::debug); @@ -156,7 +156,7 @@ int main(int argc, char** argv) srslog::init(); #if PCAP - srslte::mac_pcap pcap; + srsran::mac_pcap pcap; pcap.open("ul_dcch.pcap"); TESTASSERT(rrc_ue_cap_info_test(&pcap) == 0); #else diff --git a/lib/test/common/CMakeLists.txt b/lib/test/common/CMakeLists.txt index 0eab93aeb..e8ae1c280 100644 --- a/lib/test/common/CMakeLists.txt +++ b/lib/test/common/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -12,75 +12,75 @@ find_package(SCTP REQUIRED) # COMMON TESTS ####################################################################### add_executable(byte_buffer_queue_test byte_buffer_queue_test.cc) -target_link_libraries(byte_buffer_queue_test srslte_phy srslte_common ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES}) +target_link_libraries(byte_buffer_queue_test srsran_phy srsran_common ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES}) add_test(byte_buffer_queue_test byte_buffer_queue_test) add_executable(test_eia1 test_eia1.cc) -target_link_libraries(test_eia1 srslte_common srslte_phy ${CMAKE_THREAD_LIBS_INIT}) +target_link_libraries(test_eia1 srsran_common srsran_phy ${CMAKE_THREAD_LIBS_INIT}) add_test(test_eia1 test_eia1) add_executable(test_eia3 test_eia3.cc) -target_link_libraries(test_eia3 srslte_common) +target_link_libraries(test_eia3 srsran_common) add_test(test_eia3 test_eia3) add_executable(test_eea1 test_eea1.cc) -target_link_libraries(test_eea1 srslte_common srslte_phy ${CMAKE_THREAD_LIBS_INIT}) +target_link_libraries(test_eea1 srsran_common srsran_phy ${CMAKE_THREAD_LIBS_INIT}) add_test(test_eea1 test_eea1) add_executable(test_eea2 test_eea2.cc) -target_link_libraries(test_eea2 srslte_common srslte_phy ${CMAKE_THREAD_LIBS_INIT}) +target_link_libraries(test_eea2 srsran_common srsran_phy ${CMAKE_THREAD_LIBS_INIT}) add_test(test_eea2 test_eea2) add_executable(test_eea3 test_eea3.cc) -target_link_libraries(test_eea3 srslte_common srslte_phy ${CMAKE_THREAD_LIBS_INIT}) +target_link_libraries(test_eea3 srsran_common srsran_phy ${CMAKE_THREAD_LIBS_INIT}) add_test(test_eea3 test_eea3) add_executable(test_f12345 test_f12345.cc) -target_link_libraries(test_f12345 srslte_common ${CMAKE_THREAD_LIBS_INIT}) +target_link_libraries(test_f12345 srsran_common ${CMAKE_THREAD_LIBS_INIT}) add_test(test_f12345 test_f12345) add_executable(timeout_test timeout_test.cc) -target_link_libraries(timeout_test srslte_phy ${CMAKE_THREAD_LIBS_INIT}) +target_link_libraries(timeout_test srsran_phy ${CMAKE_THREAD_LIBS_INIT}) add_executable(bcd_helpers_test bcd_helpers_test.cc) -target_link_libraries(bcd_helpers_test srslte_common) +target_link_libraries(bcd_helpers_test srsran_common) add_executable(stack_procedure_test stack_procedure_test.cc) add_test(stack_procedure_test stack_procedure_test) add_executable(queue_test multiqueue_test.cc) -target_link_libraries(queue_test srslte_common ${CMAKE_THREAD_LIBS_INIT}) +target_link_libraries(queue_test srsran_common ${CMAKE_THREAD_LIBS_INIT}) add_test(queue_test queue_test) add_executable(timer_test timer_test.cc) -target_link_libraries(timer_test srslte_common) +target_link_libraries(timer_test srsran_common) add_test(timer_test timer_test) add_executable(network_utils_test network_utils_test.cc) -target_link_libraries(network_utils_test srslte_common ${SCTP_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) +target_link_libraries(network_utils_test srsran_common ${SCTP_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) add_test(network_utils_test network_utils_test) add_executable(tti_point_test tti_point_test.cc) -target_link_libraries(tti_point_test srslte_common) +target_link_libraries(tti_point_test srsran_common) add_test(tti_point_test tti_point_test) add_executable(fsm_test fsm_test.cc) -target_link_libraries(fsm_test srslte_common) +target_link_libraries(fsm_test srsran_common) add_test(fsm_test fsm_test) add_executable(choice_type_test choice_type_test.cc) -target_link_libraries(choice_type_test srslte_common) +target_link_libraries(choice_type_test srsran_common) add_test(choice_type_test choice_type_test) add_executable(task_scheduler_test task_scheduler_test.cc) -target_link_libraries(task_scheduler_test srslte_common) +target_link_libraries(task_scheduler_test srsran_common) add_test(task_scheduler_test task_scheduler_test) add_executable(pnf_dummy pnf_dummy.cc) -target_link_libraries(pnf_dummy srslte_common ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES}) +target_link_libraries(pnf_dummy srsran_common ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES}) add_executable(pnf_bridge pnf_bridge.cc) -target_link_libraries(pnf_bridge srslte_common ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES}) +target_link_libraries(pnf_bridge srsran_common ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES}) add_executable(mac_pcap_net_test mac_pcap_net_test.cc) -target_link_libraries(mac_pcap_net_test srslte_common ${SCTP_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) +target_link_libraries(mac_pcap_net_test srsran_common ${SCTP_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) diff --git a/lib/test/common/bcd_helpers_test.cc b/lib/test/common/bcd_helpers_test.cc index 206c1b46f..a2480acce 100644 --- a/lib/test/common/bcd_helpers_test.cc +++ b/lib/test/common/bcd_helpers_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,10 +10,10 @@ * */ -#include "srslte/common/bcd_helpers.h" -#include "srslte/common/test_common.h" +#include "srsran/common/bcd_helpers.h" +#include "srsran/common/test_common.h" -using namespace srslte; +using namespace srsran; int main(int argc, char** argv) { @@ -50,5 +50,5 @@ int main(int argc, char** argv) mnc = 0xFF01; TESTASSERT(mnc_to_string(mnc, &mnc_str)); TESTASSERT(mnc_str.compare("01") == 0); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } diff --git a/lib/test/common/byte_buffer_queue_test.cc b/lib/test/common/byte_buffer_queue_test.cc index 7b1b0099f..0371860a9 100644 --- a/lib/test/common/byte_buffer_queue_test.cc +++ b/lib/test/common/byte_buffer_queue_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -12,11 +12,11 @@ #define NMSGS 1000000 -#include "srslte/common/buffer_pool.h" -#include "srslte/upper/byte_buffer_queue.h" +#include "srsran/common/buffer_pool.h" +#include "srsran/upper/byte_buffer_queue.h" #include -using namespace srslte; +using namespace srsran; typedef struct { byte_buffer_queue* q; @@ -26,7 +26,7 @@ void* write_thread(void* a) { args_t* args = (args_t*)a; for (uint32_t i = 0; i < NMSGS; i++) { - unique_byte_buffer_t b = srslte::make_byte_buffer(); + unique_byte_buffer_t b = srsran::make_byte_buffer(); memcpy(b->msg, &i, 4); b->N_bytes = 4; args->q->write(std::move(b)); diff --git a/lib/test/common/choice_type_test.cc b/lib/test/common/choice_type_test.cc index 7fa87922c..5b46e24cc 100644 --- a/lib/test/common/choice_type_test.cc +++ b/lib/test/common/choice_type_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,9 +10,9 @@ * */ -#include "srslte/adt/choice_type.h" -#include "srslte/common/buffer_pool.h" -#include "srslte/common/test_common.h" +#include "srsran/adt/choice_type.h" +#include "srsran/common/buffer_pool.h" +#include "srsran/common/test_common.h" struct C { static int counter; @@ -50,7 +50,7 @@ struct D { }; int D::counter = 0; -namespace srslte { +namespace srsran { namespace choice_details { static_assert(static_max<1, 2>::value == 2, "StaticMax not working"); @@ -74,11 +74,11 @@ static_assert(std::is_same::disable_if_can_hold u; u.construct_unsafe(5); TESTASSERT(u.is()); @@ -91,12 +91,12 @@ int test_tagged_union() u.destroy_unsafe(); TESTASSERT(C::counter == 0); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_choice() { - using srslte::choice_t; + using srsran::choice_t; TESTASSERT(C::counter == 0); TESTASSERT(D::counter == 0); @@ -107,38 +107,38 @@ int test_choice() // TEST: correct construction, holding the right type and value choice_t c, c2{i}, c3{c0}; TESTASSERT(c.is()); - TESTASSERT(c2.is() and srslte::get(c2) == i and *srslte::get_if(c2) == i); - TESTASSERT(srslte::get<1>(c2) == srslte::get(c2)); + TESTASSERT(c2.is() and srsran::get(c2) == i and *srsran::get_if(c2) == i); + TESTASSERT(srsran::get<1>(c2) == srsran::get(c2)); TESTASSERT(c3.is()); TESTASSERT(C::counter == 2); // TEST: Invalid member access. get<>() should throw - TESTASSERT(srslte::get_if(c2) == nullptr); + TESTASSERT(srsran::get_if(c2) == nullptr); // TEST: simple emplace after construction c2 = 'c'; - TESTASSERT(c2.is() and srslte::get(c2) == 'c'); + TESTASSERT(c2.is() and srsran::get(c2) == 'c'); // TEST: copy ctor test. choice_t c5{c3}; TESTASSERT(C::counter == 3); TESTASSERT(c5.is()); - TESTASSERT(srslte::get_if(c5) == &srslte::get(c5)); + TESTASSERT(srsran::get_if(c5) == &srsran::get(c5)); // TEST: copy assignment c = c5; TESTASSERT(C::counter == 4); - TESTASSERT(c.is() and srslte::get_if(c) != srslte::get_if(c5)); + TESTASSERT(c.is() and srsran::get_if(c) != srsran::get_if(c5)); c = c2; TESTASSERT(C::counter == 3); - TESTASSERT(c2.is() and srslte::get(c) == 'c'); + TESTASSERT(c2.is() and srsran::get(c) == 'c'); } TESTASSERT(C::counter == 0); TESTASSERT(D::counter == 0); { choice_t c, c2{5.0}, c3{C{}}, c4{D{}}; TESTASSERT(c.is()); - TESTASSERT(c2.is() and srslte::get(c2) == 5.0 and *srslte::get_if(c2) == 5.0); + TESTASSERT(c2.is() and srsran::get(c2) == 5.0 and *srsran::get_if(c2) == 5.0); TESTASSERT(c3.is()); TESTASSERT(c4.is()); TESTASSERT(C::counter == 1); @@ -162,17 +162,17 @@ int test_choice() TESTASSERT(D::counter == 3); c = std::move(c2); TESTASSERT(c.is() and c2.is() and c.holds_same_type(c2)); - TESTASSERT(srslte::get(c) == srslte::get(c2)); + TESTASSERT(srsran::get(c) == srsran::get(c2)); TESTASSERT(C::counter == 2 and D::counter == 2); } TESTASSERT(C::counter == 0); TESTASSERT(D::counter == 0); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } struct E { - srslte::unique_byte_buffer_t pdu = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t pdu = srsran::make_byte_buffer(); }; struct EVisitor { @@ -182,45 +182,45 @@ struct EVisitor { // do nothing } void operator()(E& e) { pdu = std::move(e.pdu); } - srslte::unique_byte_buffer_t pdu; + srsran::unique_byte_buffer_t pdu; }; int test_visit() { - using srslte::choice_t; + using srsran::choice_t; choice_t c{5}; // TEST: visitor hits integer type which is noop EVisitor v; - srslte::visit(v, c); - TESTASSERT(c.is() and srslte::get(c) == 5); + srsran::visit(v, c); + TESTASSERT(c.is() and srsran::get(c) == 5); TESTASSERT(v.pdu == nullptr); // TEST: visitor hits type E and steals pdu E e; - e.pdu = srslte::make_byte_buffer(); + e.pdu = srsran::make_byte_buffer(); c = std::move(e); - TESTASSERT(c.is() and srslte::get(c).pdu != nullptr); - srslte::visit(v, c); + TESTASSERT(c.is() and srsran::get(c).pdu != nullptr); + srsran::visit(v, c); TESTASSERT(v.pdu != nullptr); - TESTASSERT(c.is() and srslte::get(c).pdu == nullptr); + TESTASSERT(c.is() and srsran::get(c).pdu == nullptr); // TEST: visitor hits type E and steals pdu. Second type called there is no pdu to steal. v.pdu = nullptr; - e.pdu = srslte::make_byte_buffer(); + e.pdu = srsran::make_byte_buffer(); c = std::move(e); - srslte::visit(v, c); + srsran::visit(v, c); TESTASSERT(v.pdu != nullptr); - srslte::visit(v, c); + srsran::visit(v, c); TESTASSERT(v.pdu == nullptr); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int main() { - TESTASSERT(test_tagged_union() == SRSLTE_SUCCESS); - TESTASSERT(test_choice() == SRSLTE_SUCCESS); - TESTASSERT(test_visit() == SRSLTE_SUCCESS); + TESTASSERT(test_tagged_union() == SRSRAN_SUCCESS); + TESTASSERT(test_choice() == SRSRAN_SUCCESS); + TESTASSERT(test_visit() == SRSRAN_SUCCESS); } diff --git a/lib/test/common/fsm_test.cc b/lib/test/common/fsm_test.cc index df5d23af2..e407ee402 100644 --- a/lib/test/common/fsm_test.cc +++ b/lib/test/common/fsm_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,8 +10,8 @@ * */ -#include "srslte/common/fsm.h" -#include "srslte/common/test_common.h" +#include "srsran/common/fsm.h" +#include "srsran/common/test_common.h" ///////////////////////////// @@ -24,12 +24,12 @@ std::vector calls; template void call_log_helper(State* state, srslog::basic_logger& logger, const char* type) { - std::string callname = srslte::get_type_name() + "::" + type; + std::string callname = srsran::get_type_name() + "::" + type; logger.info("%s custom called", callname.c_str()); calls.push_back(callname); } -class fsm1 : public srslte::fsm_t +class fsm1 : public srsran::fsm_t { public: uint32_t idle_enter_counter = 0, state1_enter_counter = 0, inner_enter_counter = 0; @@ -46,7 +46,7 @@ public: void exit(fsm1* f); }; - explicit fsm1(srslog::basic_logger& logger) : srslte::fsm_t(logger) {} + explicit fsm1(srslog::basic_logger& logger) : srsran::fsm_t(logger) {} // this state is another FSM class fsm2 : public subfsm_t @@ -170,7 +170,7 @@ void fsm1::action3(state1& s, const ev2& ev) // Static Checks -namespace srslte { +namespace srsran { namespace fsm_details { static_assert(is_fsm::value, "invalid metafunction"); @@ -185,7 +185,7 @@ static_assert(std::is_same, void>::valu static_assert(std::is_same, void>::value, "get state list failed"); } // namespace fsm_details -} // namespace srslte +} // namespace srsran // Runtime checks @@ -251,21 +251,21 @@ int test_hsm() TESTASSERT(f.get_if_current_state()->current_state_name() == "state_inner"); // Ensure correct call order - TESTASSERT(calls[0] == srslte::get_type_name() + "::enter"); // enter for init state called - TESTASSERT(calls[1] == srslte::get_type_name() + "::action1"); - TESTASSERT(calls[2] == srslte::get_type_name() + "::enter"); - TESTASSERT(calls[3] == srslte::get_type_name() + "::action2"); - TESTASSERT(calls[4] == srslte::get_type_name() + "::exit"); - TESTASSERT(calls[5] == srslte::get_type_name() + "::enter"); // entry is recursive - TESTASSERT(calls[6] == srslte::get_type_name() + "::enter"); - TESTASSERT(calls[7] == srslte::get_type_name() + "::inner_action1"); - TESTASSERT(calls[8] == srslte::get_type_name() + "::inner_action2"); - TESTASSERT(calls[9] == srslte::get_type_name() + "::enter"); - TESTASSERT(calls[10] == srslte::get_type_name() + "::exit"); - TESTASSERT(calls[11] == srslte::get_type_name() + "::exit"); // exit is recursive - TESTASSERT(calls[12] == srslte::get_type_name() + "::enter2"); // differentiates different entry funcs - - return SRSLTE_SUCCESS; + TESTASSERT(calls[0] == srsran::get_type_name() + "::enter"); // enter for init state called + TESTASSERT(calls[1] == srsran::get_type_name() + "::action1"); + TESTASSERT(calls[2] == srsran::get_type_name() + "::enter"); + TESTASSERT(calls[3] == srsran::get_type_name() + "::action2"); + TESTASSERT(calls[4] == srsran::get_type_name() + "::exit"); + TESTASSERT(calls[5] == srsran::get_type_name() + "::enter"); // entry is recursive + TESTASSERT(calls[6] == srsran::get_type_name() + "::enter"); + TESTASSERT(calls[7] == srsran::get_type_name() + "::inner_action1"); + TESTASSERT(calls[8] == srsran::get_type_name() + "::inner_action2"); + TESTASSERT(calls[9] == srsran::get_type_name() + "::enter"); + TESTASSERT(calls[10] == srsran::get_type_name() + "::exit"); + TESTASSERT(calls[11] == srsran::get_type_name() + "::exit"); // exit is recursive + TESTASSERT(calls[12] == srsran::get_type_name() + "::enter2"); // differentiates different entry funcs + + return SRSRAN_SUCCESS; } ///////////////////////////// @@ -274,10 +274,10 @@ struct procevent1 { bool is_success; }; -struct proc1 : public srslte::proc_fsm_t { +struct proc1 : public srsran::proc_fsm_t { public: struct procstate1 { - void enter(proc1* f, const srslte::proc_launch_ev& ev); + void enter(proc1* f, const srsran::proc_launch_ev& ev); }; explicit proc1(srslog::basic_logger& logger) : base_t(logger) {} @@ -322,11 +322,11 @@ void proc1::handle_failure(procstate1& s, const procevent1& ev) trigger(complete_ev{3}); } -struct proc_listener_fsm : public srslte::fsm_t { +struct proc_listener_fsm : public srsran::fsm_t { public: struct st1 {}; struct st2 {}; - using proc1_st = srslte::proc_wait_st; + using proc1_st = srsran::proc_wait_st; proc_listener_fsm(srslog::basic_logger& logger, proc1* proc_ptr_) : base_t(logger), states(this, st1{}, st2{}, proc1_st{proc_ptr_}) @@ -357,16 +357,16 @@ int test_fsm_proc() int v = 2; TESTASSERT(proc.current_state_name() == "idle_st"); - proc.trigger(srslte::proc_launch_ev{v}); + proc.trigger(srsran::proc_launch_ev{v}); TESTASSERT(proc.current_state_name() == "procstate1"); - proc.trigger(srslte::proc_launch_ev{v}); + proc.trigger(srsran::proc_launch_ev{v}); TESTASSERT(proc.current_state_name() == "procstate1"); - proc.trigger(srslte::proc_launch_ev{5}); + proc.trigger(srsran::proc_launch_ev{5}); TESTASSERT(proc.current_state_name() == "procstate1"); proc.trigger(procevent1{true}); TESTASSERT(proc.current_state_name() == "idle_st"); TESTASSERT(proc.get_result() == 5); - proc.trigger(srslte::proc_launch_ev{v}); + proc.trigger(srsran::proc_launch_ev{v}); TESTASSERT(proc.current_state_name() == "procstate1"); proc.trigger(procevent1{false}); TESTASSERT(proc.current_state_name() == "idle_st"); @@ -386,19 +386,19 @@ int test_fsm_proc() { proc_listener_fsm outer_fsm{srslog::fetch_basic_logger("TEST"), &proc}; TESTASSERT(outer_fsm.is_in_state()); - proc.trigger(srslte::proc_launch_ev{v}); + proc.trigger(srsran::proc_launch_ev{v}); TESTASSERT(proc.is_running()); outer_fsm.trigger(7); TESTASSERT(outer_fsm.is_in_state()); TESTASSERT(proc.is_running()); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } /////////////////////////// -class nas_fsm : public srslte::fsm_t +class nas_fsm : public srsran::fsm_t { public: // states @@ -526,10 +526,10 @@ int test_nas_fsm() fsm.trigger(nas_fsm::power_off_ev{}); TESTASSERT(fsm.is_in_state()); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -struct fsm3 : public srslte::fsm_t { +struct fsm3 : public srsran::fsm_t { struct st1 {}; struct st2 { int counter = 0; @@ -587,7 +587,7 @@ int test_fsm_self_trigger() TESTASSERT(fsm.events[4] == "st2"); TESTASSERT(fsm.events[5] == "st2::action"); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int main() @@ -596,14 +596,14 @@ int main() logger.set_level(srslog::basic_levels::info); srslog::init(); - TESTASSERT(test_hsm() == SRSLTE_SUCCESS); + TESTASSERT(test_hsm() == SRSRAN_SUCCESS); logger.info("TEST \"hsm\" finished successfully\n"); - TESTASSERT(test_fsm_proc() == SRSLTE_SUCCESS); + TESTASSERT(test_fsm_proc() == SRSRAN_SUCCESS); logger.info("TEST \"proc\" finished successfully\n"); - TESTASSERT(test_nas_fsm() == SRSLTE_SUCCESS); + TESTASSERT(test_nas_fsm() == SRSRAN_SUCCESS); logger.info("TEST \"nas fsm\" finished successfully\n"); - TESTASSERT(test_fsm_self_trigger() == SRSLTE_SUCCESS); + TESTASSERT(test_fsm_self_trigger() == SRSRAN_SUCCESS); logger.info("TEST \"fsm self trigger\" finished successfully\n"); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } diff --git a/lib/test/common/mac_pcap_net_test.cc b/lib/test/common/mac_pcap_net_test.cc index 94d11caf7..97bb4f1b8 100644 --- a/lib/test/common/mac_pcap_net_test.cc +++ b/lib/test/common/mac_pcap_net_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,14 +10,14 @@ * */ -#include "srslte/common/common.h" -#include "srslte/common/mac_pcap_net.h" -#include "srslte/common/test_common.h" +#include "srsran/common/common.h" +#include "srsran/common/mac_pcap_net.h" +#include "srsran/common/test_common.h" #include #include // Write #num_pdus UL MAC PDUs using PCAP handle -void write_pcap_eutra_thread_function(srslte::mac_pcap_net* pcap_handle, +void write_pcap_eutra_thread_function(srsran::mac_pcap_net* pcap_handle, const std::array& pdu, uint32_t num_pdus) { @@ -29,7 +29,7 @@ void write_pcap_eutra_thread_function(srslte::mac_pcap_net* pcap_handl } // Write #num_pdus DL MAC NR PDUs using PCAP handle -void write_pcap_nr_thread_function(srslte::mac_pcap_net* pcap_handle, +void write_pcap_nr_thread_function(srsran::mac_pcap_net* pcap_handle, const std::array& pdu, uint32_t num_pdus) { @@ -55,9 +55,9 @@ int lte_mac_pcap_net_test() uint32_t num_threads = 10; uint32_t num_pdus_per_thread = 100; - std::unique_ptr pcap_handle = std::unique_ptr(new srslte::mac_pcap_net()); - TESTASSERT(pcap_handle->open("127.0.0.1") == SRSLTE_SUCCESS); - TESTASSERT(pcap_handle->open("127.0.0.1") != SRSLTE_SUCCESS); // open again will fail + std::unique_ptr pcap_handle = std::unique_ptr(new srsran::mac_pcap_net()); + TESTASSERT(pcap_handle->open("127.0.0.1") == SRSRAN_SUCCESS); + TESTASSERT(pcap_handle->open("127.0.0.1") != SRSRAN_SUCCESS); // open again will fail std::vector writer_threads; @@ -69,10 +69,10 @@ int lte_mac_pcap_net_test() for (std::thread& thread : writer_threads) { thread.join(); } - TESTASSERT(pcap_handle->close() == SRSLTE_SUCCESS); - TESTASSERT(pcap_handle->close() != SRSLTE_SUCCESS); // closing twice will fail + TESTASSERT(pcap_handle->close() == SRSRAN_SUCCESS); + TESTASSERT(pcap_handle->close() != SRSRAN_SUCCESS); // closing twice will fail - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int nr_mac_pcap_net_test() @@ -82,9 +82,9 @@ int nr_mac_pcap_net_test() uint32_t num_threads = 10; uint32_t num_pdus_per_thread = 100; - std::unique_ptr pcap_handle = std::unique_ptr(new srslte::mac_pcap_net()); - TESTASSERT(pcap_handle->open("127.0.0.1") == SRSLTE_SUCCESS); - TESTASSERT(pcap_handle->open("127.0.0.1") != SRSLTE_SUCCESS); // open again will fail + std::unique_ptr pcap_handle = std::unique_ptr(new srsran::mac_pcap_net()); + TESTASSERT(pcap_handle->open("127.0.0.1") == SRSRAN_SUCCESS); + TESTASSERT(pcap_handle->open("127.0.0.1") != SRSRAN_SUCCESS); // open again will fail std::vector writer_threads; @@ -97,10 +97,10 @@ int nr_mac_pcap_net_test() thread.join(); } - TESTASSERT(pcap_handle->close() == SRSLTE_SUCCESS); - TESTASSERT(pcap_handle->close() != SRSLTE_SUCCESS); // closing twice will fail + TESTASSERT(pcap_handle->close() == SRSRAN_SUCCESS); + TESTASSERT(pcap_handle->close() != SRSRAN_SUCCESS); // closing twice will fail - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int main(int argc, char** argv) @@ -110,6 +110,6 @@ int main(int argc, char** argv) mac_logger.set_hex_dump_max_size(-1); srslog::init(); - TESTASSERT(lte_mac_pcap_net_test() == SRSLTE_SUCCESS); - TESTASSERT(nr_mac_pcap_net_test() == SRSLTE_SUCCESS); + TESTASSERT(lte_mac_pcap_net_test() == SRSRAN_SUCCESS); + TESTASSERT(nr_mac_pcap_net_test() == SRSRAN_SUCCESS); } \ No newline at end of file diff --git a/lib/test/common/multiqueue_test.cc b/lib/test/common/multiqueue_test.cc index 05a489dac..cfd6cf6d5 100644 --- a/lib/test/common/multiqueue_test.cc +++ b/lib/test/common/multiqueue_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,9 +10,9 @@ * */ -#include "srslte/adt/move_callback.h" -#include "srslte/common/multiqueue.h" -#include "srslte/common/thread_pool.h" +#include "srsran/adt/move_callback.h" +#include "srsran/common/multiqueue.h" +#include "srsran/common/thread_pool.h" #include #include #include @@ -26,7 +26,7 @@ } \ } -using namespace srslte; +using namespace srsran; int test_multiqueue() { @@ -348,8 +348,8 @@ int test_inplace_task() auto l0 = [&v]() { v = 1; }; - srslte::move_callback t{l0}; - srslte::move_callback t2{[v]() mutable { v = 2; }}; + srsran::move_callback t{l0}; + srsran::move_callback t2{[v]() mutable { v = 2; }}; // sanity static checks static_assert(task_details::is_move_callback::type>::value, "failed check\n"); static_assert( @@ -365,7 +365,7 @@ int test_inplace_task() TESTASSERT(v == 1); C c; - srslte::move_callback t4{std::bind([&v](C& c) { v = *c.val; }, std::move(c))}; + srsran::move_callback t4{std::bind([&v](C& c) { v = *c.val; }, std::move(c))}; { decltype(t4) t5; t5 = std::move(t4); @@ -374,9 +374,9 @@ int test_inplace_task() } D d; - srslte::move_callback t6 = [&v, d]() { v = d.big_val[0]; }; + srsran::move_callback t6 = [&v, d]() { v = d.big_val[0]; }; { - srslte::move_callback t7; + srsran::move_callback t7; t6(); TESTASSERT(v == 6); v = 0; @@ -405,7 +405,7 @@ int test_inplace_task() // TEST: task works in const contexts t = l2; - auto l3 = [](const srslte::move_callback& task) { task(); }; + auto l3 = [](const srsran::move_callback& task) { task(); }; v = 0; l3(t); TESTASSERT(v == 6); diff --git a/lib/test/common/network_utils_test.cc b/lib/test/common/network_utils_test.cc index f47057b69..647ca9bb0 100644 --- a/lib/test/common/network_utils_test.cc +++ b/lib/test/common/network_utils_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,7 +10,7 @@ * */ -#include "srslte/common/network_utils.h" +#include "srsran/common/network_utils.h" #include #define TESTASSERT(cond) \ @@ -27,11 +27,11 @@ int test_socket_handler() int counter = 0; - srslte::socket_handler_t server_socket, client_socket, client_socket2; - srslte::rx_multisocket_handler sockhandler("RXSOCKETS", logger); + srsran::socket_handler_t server_socket, client_socket, client_socket2; + srsran::rx_multisocket_handler sockhandler("RXSOCKETS", logger); int server_port = 36412; const char* server_addr = "127.0.100.1"; - using namespace srslte::net_utils; + using namespace srsran::net_utils; TESTASSERT(sctp_init_server(&server_socket, socket_type::seqpacket, server_addr, server_port)); logger.info("Listening from fd=%d", server_socket.fd()); @@ -44,7 +44,7 @@ int test_socket_handler() // register server Rx handler auto pdu_handler = [&logger, - &counter](srslte::unique_byte_buffer_t pdu, const sockaddr_in& from, const sctp_sndrcvinfo& sri, int flags) { + &counter](srsran::unique_byte_buffer_t pdu, const sockaddr_in& from, const sctp_sndrcvinfo& sri, int flags) { if (pdu->N_bytes > 0) { logger.info(pdu->msg, pdu->N_bytes, "Received msg from %s:", get_ip(from).c_str()); counter++; @@ -60,7 +60,7 @@ int test_socket_handler() for (int32_t i = 0; i < nof_counts; ++i) { buf[i] = i; // Round-robin between clients - srslte::socket_handler_t* chosen = &client_socket; + srsran::socket_handler_t* chosen = &client_socket; if (i % 2 == 1) { chosen = &client_socket2; } diff --git a/lib/test/common/pnf_bridge.cc b/lib/test/common/pnf_bridge.cc index 83d856ee1..60dd56b48 100644 --- a/lib/test/common/pnf_bridge.cc +++ b/lib/test/common/pnf_bridge.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -18,7 +18,7 @@ #include #include -#include "srslte/common/basic_pnf.h" +#include "srsran/common/basic_pnf.h" using namespace std; namespace bpo = boost::program_options; @@ -87,8 +87,8 @@ int main(int argc, char** argv) pnf_args_t args; parse_args(&args, argc, argv); - srslte::srslte_basic_pnf ue_pnf("ue", args.ue_vnf_addr, args.ue_vnf_port, args.sf_interval, args.num_sf, args.tb_len); - srslte::srslte_basic_pnf gnb_pnf( + srsran::srsran_basic_pnf ue_pnf("ue", args.ue_vnf_addr, args.ue_vnf_port, args.sf_interval, args.num_sf, args.tb_len); + srsran::srsran_basic_pnf gnb_pnf( "gnb", args.gnb_vnf_addr, args.gnb_vnf_port, args.sf_interval, args.num_sf, args.tb_len); gnb_pnf.connect_out_rf_queue(ue_pnf.get_in_rf_queue()); @@ -98,7 +98,7 @@ int main(int argc, char** argv) while (running) { for (uint32_t i = 0; i < 2; ++i) { - srslte::pnf_metrics_t metrics = (i == 0) ? ue_pnf.get_metrics() : gnb_pnf.get_metrics(); + srsran::pnf_metrics_t metrics = (i == 0) ? ue_pnf.get_metrics() : gnb_pnf.get_metrics(); printf("%s: RTT=%d, #Error=%d, #PDUs=%d, Total TB size=%d, Rate=%.2f Mbit/s\n", i == 0 ? "UE" : "gNB", metrics.avg_rtt_us, diff --git a/lib/test/common/pnf_dummy.cc b/lib/test/common/pnf_dummy.cc index 6c7b45bd1..f61d26b2d 100644 --- a/lib/test/common/pnf_dummy.cc +++ b/lib/test/common/pnf_dummy.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -18,7 +18,7 @@ #include #include -#include "srslte/common/basic_pnf.h" +#include "srsran/common/basic_pnf.h" using namespace std; namespace bpo = boost::program_options; @@ -86,12 +86,12 @@ int main(int argc, char** argv) pnf_args_t args; parse_args(&args, argc, argv); - srslte::srslte_basic_pnf pnf(args.type, args.vnf_addr, args.vnf_port, args.sf_interval, args.num_sf, args.tb_len); + srsran::srsran_basic_pnf pnf(args.type, args.vnf_addr, args.vnf_port, args.sf_interval, args.num_sf, args.tb_len); pnf.start(); while (running) { - srslte::pnf_metrics_t metrics = pnf.get_metrics(); + srsran::pnf_metrics_t metrics = pnf.get_metrics(); printf("RTT=%d, #Error=%d, #PDUs=%d, Total TB size=%d, Rate=%.2f Mbit/s\n", metrics.avg_rtt_us, metrics.num_timing_errors, diff --git a/lib/test/common/stack_procedure_test.cc b/lib/test/common/stack_procedure_test.cc index c7754b870..b6e356706 100644 --- a/lib/test/common/stack_procedure_test.cc +++ b/lib/test/common/stack_procedure_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,7 +10,7 @@ * */ -#include "srslte/common/stack_procedure.h" +#include "srsran/common/stack_procedure.h" #include #define TESTASSERT(cond) \ @@ -21,7 +21,7 @@ } \ } -using srslte::proc_outcome_t; +using srsran::proc_outcome_t; enum class obj_state_t { default_ctor, move_ctor, copy_ctor, from_move_ctor, from_move_assign }; @@ -142,7 +142,7 @@ public: } return proc_outcome_t::yield; } - void then(const srslte::proc_result_t& result) const + void then(const srsran::proc_result_t& result) const { printf("TestObj %d then() was called\n", obj.id); obj.counters.then_counter++; @@ -199,9 +199,9 @@ public: int counter = 0; }; -static_assert(std::is_same::result_type, int>::value, +static_assert(std::is_same::result_type, int>::value, "Failed derivation of result type"); -static_assert(std::is_same::result_type, std::string>::value, +static_assert(std::is_same::result_type, std::string>::value, "Failed derivation of result type"); int test_local_1() @@ -211,7 +211,7 @@ int test_local_1() */ new_test(); printf("\n--- Test %s ---\n", __func__); - srslte::proc_t proc; + srsran::proc_t proc; TESTASSERT(proc.is_idle() and not proc.is_busy()) proc.launch(1); @@ -246,14 +246,14 @@ int test_callback_1() */ new_test(); printf("\n--- Test %s ---\n", __func__); - srslte::proc_manager_list_t callbacks; - srslte::proc_t proc; + srsran::proc_manager_list_t callbacks; + srsran::proc_t proc; TESTASSERT(not proc.is_busy() and proc.is_idle()) TESTASSERT(proc.launch(2)) callbacks.add_proc(proc); // We have to call pop() explicitly to take the result TESTASSERT(callbacks.size() == 1) - srslte::proc_future_t proc_fut = proc.get_future(); + srsran::proc_future_t proc_fut = proc.get_future(); while (callbacks.size() > 0) { TESTASSERT(not proc_fut.is_complete()) @@ -266,7 +266,7 @@ int test_callback_1() TESTASSERT(proc.get()->obj.counters.then_counter == 1) TESTASSERT(proc.get()->reset_called) // Proc is ready to be reused - srslte::proc_future_t proc_fut2 = proc.get_future(); + srsran::proc_future_t proc_fut2 = proc.get_future(); TESTASSERT(not proc_fut2.is_complete() and proc_fut.is_complete()) printf("EXIT\n"); @@ -284,10 +284,10 @@ int test_callback_2() */ new_test(); printf("\n--- Test %s ---\n", __func__); - srslte::proc_manager_list_t callbacks; - srslte::proc_t proc; + srsran::proc_manager_list_t callbacks; + srsran::proc_t proc; TESTASSERT(not proc.is_busy()); - srslte::proc_future_t fut = proc.get_future(); + srsran::proc_future_t fut = proc.get_future(); TESTASSERT(fut.is_empty()); TESTASSERT(proc.launch(&fut, 3)); @@ -316,7 +316,7 @@ int test_callback_3() */ new_test(); printf("\n--- Test %s ---\n", __func__); - srslte::proc_manager_list_t callbacks; + srsran::proc_manager_list_t callbacks; int* counter = new int(5); { @@ -346,8 +346,8 @@ int test_callback_4() */ new_test(); printf("\n--- Test %s ---\n", __func__); - srslte::proc_manager_list_t callbacks; - srslte::proc_t proc; + srsran::proc_manager_list_t callbacks; + srsran::proc_t proc; TESTASSERT(proc.launch(5)); while (proc.run()) { TESTASSERT(proc.is_busy()); @@ -367,11 +367,11 @@ int test_complete_callback_1() * Description: Test if then() callbacks are correctly called */ printf("\n--- Test %s ---\n", __func__); - srslte::proc_manager_list_t callbacks; - srslte::proc_t proc; + srsran::proc_manager_list_t callbacks; + srsran::proc_t proc; std::string run_result; - auto continuation_task = [&run_result](const srslte::proc_result_t& e) { + auto continuation_task = [&run_result](const srsran::proc_result_t& e) { run_result = e.is_success() ? "SUCCESS" : "FAILURE"; }; const std::string results[] = {"", "SUCCESS", "", "SUCCESS", "SUCCESS", "SUCCESS"}; @@ -383,7 +383,7 @@ int test_complete_callback_1() TESTASSERT(proc.then_always(continuation_task) == 0) } - srslte::proc_future_t fut; + srsran::proc_future_t fut; TESTASSERT(proc.launch(&fut)); TESTASSERT(proc.get()->exit_val == "init") while (proc.run()) { @@ -404,8 +404,8 @@ int test_event_handler_1() * Description: Test if event handler calls trigger for multiple procedures */ printf("\n--- Test %s ---\n", __func__); - srslte::proc_t proc, proc2; - srslte::event_handler_t ev_handler; + srsran::proc_t proc, proc2; + srsran::event_handler_t ev_handler; TESTASSERT(proc.launch()) TESTASSERT(proc2.launch()) diff --git a/lib/test/common/task_scheduler_test.cc b/lib/test/common/task_scheduler_test.cc index dcbb04df4..c986c20a8 100644 --- a/lib/test/common/task_scheduler_test.cc +++ b/lib/test/common/task_scheduler_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,14 +10,14 @@ * */ -#include "srslte/common/task_scheduler.h" -#include "srslte/common/test_common.h" +#include "srsran/common/task_scheduler.h" +#include "srsran/common/test_common.h" enum class task_result { null, internal, external, timer }; int test_task_scheduler_no_pool() { - srslte::task_scheduler task_sched{5, 0}; + srsran::task_scheduler task_sched{5, 0}; task_result state = task_result::null; // TEST: deferring task does not run the task until the next tic @@ -39,33 +39,33 @@ int test_task_scheduler_no_pool() // TEST: background task is run, despite there are no pool workers state = task_result::null; - srslte::get_background_workers().push_task([&task_sched, &state]() { + srsran::get_background_workers().push_task([&task_sched, &state]() { task_sched.notify_background_task_result([&state]() { state = task_result::external; }); }); TESTASSERT(state == task_result::null); task_sched.run_next_task(); // runs notification TESTASSERT(state == task_result::external); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_task_scheduler_with_pool() { - srslte::task_scheduler task_sched{5, 2}; + srsran::task_scheduler task_sched{5, 2}; task_result state = task_result::null; - srslte::get_background_workers().push_task([&task_sched, &state]() { + srsran::get_background_workers().push_task([&task_sched, &state]() { task_sched.notify_background_task_result([&state]() { state = task_result::external; }); }); TESTASSERT(state == task_result::null); task_sched.run_next_task(); // waits and runs notification TESTASSERT(state == task_result::external); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int main() { - TESTASSERT(test_task_scheduler_no_pool() == SRSLTE_SUCCESS); - TESTASSERT(test_task_scheduler_with_pool() == SRSLTE_SUCCESS); + TESTASSERT(test_task_scheduler_no_pool() == SRSRAN_SUCCESS); + TESTASSERT(test_task_scheduler_with_pool() == SRSRAN_SUCCESS); } diff --git a/lib/test/common/test_eea1.cc b/lib/test/common/test_eea1.cc index 34a171901..38b6e46a8 100644 --- a/lib/test/common/test_eea1.cc +++ b/lib/test/common/test_eea1.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -14,9 +14,9 @@ #include #include -#include "srslte/common/liblte_security.h" -#include "srslte/common/test_common.h" -#include "srslte/srslte.h" +#include "srsran/common/liblte_security.h" +#include "srsran/common/test_common.h" +#include "srsran/srsran.h" /* * Prototypes @@ -76,7 +76,7 @@ int test_set_1() TESTASSERT(err_cmp == 0); free(out); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_set_2() @@ -121,7 +121,7 @@ int test_set_2() TESTASSERT(err_cmp == 0); free(out); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_set_3() @@ -160,7 +160,7 @@ int test_set_3() TESTASSERT(err_cmp == 0); free(out); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_set_4() @@ -209,7 +209,7 @@ int test_set_4() TESTASSERT(err_cmp == 0); free(out); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_set_5() @@ -262,7 +262,7 @@ int test_set_5() TESTASSERT(err_cmp == 0); free(out); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_set_6() @@ -361,7 +361,7 @@ int test_set_6() TESTASSERT(err_cmp == 0); free(out); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // set len_bitsgth to multiple of 8 respectively 128 @@ -399,7 +399,7 @@ int test_set_1_block_size() TESTASSERT(err_cmp == 0); free(out); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // inserted bit flip in msg[0] @@ -437,7 +437,7 @@ int test_set_1_invalid() TESTASSERT(err_cmp != 0); free(out); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } /* @@ -446,13 +446,13 @@ int test_set_1_invalid() int main(int argc, char* argv[]) { - TESTASSERT(test_set_1() == SRSLTE_SUCCESS); - TESTASSERT(test_set_2() == SRSLTE_SUCCESS); - TESTASSERT(test_set_3() == SRSLTE_SUCCESS); - TESTASSERT(test_set_4() == SRSLTE_SUCCESS); - TESTASSERT(test_set_5() == SRSLTE_SUCCESS); - TESTASSERT(test_set_6() == SRSLTE_SUCCESS); - TESTASSERT(test_set_1_block_size() == SRSLTE_SUCCESS); - TESTASSERT(test_set_1_invalid() == SRSLTE_SUCCESS); - return SRSLTE_SUCCESS; + TESTASSERT(test_set_1() == SRSRAN_SUCCESS); + TESTASSERT(test_set_2() == SRSRAN_SUCCESS); + TESTASSERT(test_set_3() == SRSRAN_SUCCESS); + TESTASSERT(test_set_4() == SRSRAN_SUCCESS); + TESTASSERT(test_set_5() == SRSRAN_SUCCESS); + TESTASSERT(test_set_6() == SRSRAN_SUCCESS); + TESTASSERT(test_set_1_block_size() == SRSRAN_SUCCESS); + TESTASSERT(test_set_1_invalid() == SRSRAN_SUCCESS); + return SRSRAN_SUCCESS; } diff --git a/lib/test/common/test_eea2.cc b/lib/test/common/test_eea2.cc index 3e55c2023..3283cedd2 100644 --- a/lib/test/common/test_eea2.cc +++ b/lib/test/common/test_eea2.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -14,9 +14,9 @@ #include #include -#include "srslte/common/liblte_security.h" -#include "srslte/common/test_common.h" -#include "srslte/srslte.h" +#include "srsran/common/liblte_security.h" +#include "srsran/common/test_common.h" +#include "srsran/srsran.h" /* * Prototypes @@ -74,7 +74,7 @@ int test_set_1() TESTASSERT(err_cmp == 0); free(out); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_set_2() @@ -119,7 +119,7 @@ int test_set_2() TESTASSERT(err_cmp == 0); free(out); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_set_3() @@ -158,7 +158,7 @@ int test_set_3() TESTASSERT(err_cmp == 0); free(out); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_set_4() @@ -207,7 +207,7 @@ int test_set_4() TESTASSERT(err_cmp == 0); free(out); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_set_5() @@ -260,7 +260,7 @@ int test_set_5() TESTASSERT(err_cmp == 0); free(out); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_set_6() @@ -367,7 +367,7 @@ int test_set_6() TESTASSERT(err_cmp == 0); free(out); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // set len_bitsgth to multiple of 8 respectively 128 @@ -405,7 +405,7 @@ int test_set_1_block_size() TESTASSERT(err_cmp == 0); free(out); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // inserted bit flip in msg[0] @@ -443,7 +443,7 @@ int test_set_1_invalid() TESTASSERT(err_cmp != 0); free(out); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } /* @@ -452,12 +452,12 @@ int test_set_1_invalid() int main(int argc, char* argv[]) { - TESTASSERT(test_set_1() == SRSLTE_SUCCESS); - TESTASSERT(test_set_2() == SRSLTE_SUCCESS); - TESTASSERT(test_set_3() == SRSLTE_SUCCESS); - TESTASSERT(test_set_4() == SRSLTE_SUCCESS); - TESTASSERT(test_set_5() == SRSLTE_SUCCESS); - TESTASSERT(test_set_6() == SRSLTE_SUCCESS); - TESTASSERT(test_set_1_block_size() == SRSLTE_SUCCESS); - TESTASSERT(test_set_1_invalid() == SRSLTE_SUCCESS); + TESTASSERT(test_set_1() == SRSRAN_SUCCESS); + TESTASSERT(test_set_2() == SRSRAN_SUCCESS); + TESTASSERT(test_set_3() == SRSRAN_SUCCESS); + TESTASSERT(test_set_4() == SRSRAN_SUCCESS); + TESTASSERT(test_set_5() == SRSRAN_SUCCESS); + TESTASSERT(test_set_6() == SRSRAN_SUCCESS); + TESTASSERT(test_set_1_block_size() == SRSRAN_SUCCESS); + TESTASSERT(test_set_1_invalid() == SRSRAN_SUCCESS); } diff --git a/lib/test/common/test_eea3.cc b/lib/test/common/test_eea3.cc index 8cfb62066..f7bd2ad9f 100644 --- a/lib/test/common/test_eea3.cc +++ b/lib/test/common/test_eea3.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,9 +13,9 @@ #include #include -#include "srslte/common/liblte_security.h" -#include "srslte/common/test_common.h" -#include "srslte/srslte.h" +#include "srsran/common/liblte_security.h" +#include "srsran/common/test_common.h" +#include "srsran/srsran.h" int32 arrcmp(uint8_t const* const a, uint8_t const* const b, uint32 len) { @@ -87,7 +87,7 @@ int test_set_1() } free(out); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_set_2() @@ -147,7 +147,7 @@ int test_set_2() } free(out); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_set_3() @@ -220,7 +220,7 @@ int test_set_3() } free(out); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_set_4() @@ -309,7 +309,7 @@ int test_set_4() } free(out); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_set_5() @@ -414,14 +414,14 @@ int test_set_5() } free(out); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int main(int argc, char* argv[]) { - TESTASSERT(test_set_1() == SRSLTE_SUCCESS); - TESTASSERT(test_set_2() == SRSLTE_SUCCESS); - TESTASSERT(test_set_3() == SRSLTE_SUCCESS); - TESTASSERT(test_set_4() == SRSLTE_SUCCESS); - TESTASSERT(test_set_5() == SRSLTE_SUCCESS); + TESTASSERT(test_set_1() == SRSRAN_SUCCESS); + TESTASSERT(test_set_2() == SRSRAN_SUCCESS); + TESTASSERT(test_set_3() == SRSRAN_SUCCESS); + TESTASSERT(test_set_4() == SRSRAN_SUCCESS); + TESTASSERT(test_set_5() == SRSRAN_SUCCESS); } diff --git a/lib/test/common/test_eia1.cc b/lib/test/common/test_eia1.cc index 85045aa59..1f7b5b1d7 100644 --- a/lib/test/common/test_eia1.cc +++ b/lib/test/common/test_eia1.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -15,9 +15,9 @@ #include #include -#include "srslte/common/security.h" -#include "srslte/common/test_common.h" -#include "srslte/srslte.h" +#include "srsran/common/security.h" +#include "srsran/common/test_common.h" +#include "srsran/srsran.h" /* * Tests @@ -39,12 +39,12 @@ int test_set_1() uint8_t mac[4]; // gen mac - srslte::security_128_eia1(key, count, bearer, direction, msg, len_bytes, mac); + srsran::security_128_eia1(key, count, bearer, direction, msg, len_bytes, mac); for (int i = 0; i < 4; i++) { TESTASSERT(mac[i] == mt[i]); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_set_4() @@ -65,12 +65,12 @@ int test_set_4() uint8_t mac[4]; // gen mac - srslte::security_128_eia1(key, count, bearer, direction, msg, len_bytes, mac); + srsran::security_128_eia1(key, count, bearer, direction, msg, len_bytes, mac); for (int i = 0; i < 4; i++) { TESTASSERT(mac[i] == mt[i]); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_set_7() @@ -197,12 +197,12 @@ int test_set_7() uint8_t mac[4]; // gen mac - srslte::security_128_eia1(key, count, bearer, direction, msg, len_bytes, mac); + srsran::security_128_eia1(key, count, bearer, direction, msg, len_bytes, mac); for (int i = 0; i < 4; i++) { TESTASSERT(mac[i] == mt[i]); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } /* * Functions @@ -210,8 +210,8 @@ int test_set_7() int main(int argc, char* argv[]) { - TESTASSERT(test_set_1() == SRSLTE_SUCCESS); - TESTASSERT(test_set_4() == SRSLTE_SUCCESS); - TESTASSERT(test_set_7() == SRSLTE_SUCCESS); - return SRSLTE_SUCCESS; + TESTASSERT(test_set_1() == SRSRAN_SUCCESS); + TESTASSERT(test_set_4() == SRSRAN_SUCCESS); + TESTASSERT(test_set_7() == SRSRAN_SUCCESS); + return SRSRAN_SUCCESS; } diff --git a/lib/test/common/test_eia3.cc b/lib/test/common/test_eia3.cc index 0d864e9b9..80a1344c7 100644 --- a/lib/test/common/test_eia3.cc +++ b/lib/test/common/test_eia3.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -14,10 +14,10 @@ #include #include -#include "srslte/common/liblte_security.h" -#include "srslte/common/security.h" -#include "srslte/common/test_common.h" -#include "srslte/srslte.h" +#include "srsran/common/liblte_security.h" +#include "srsran/common/security.h" +#include "srsran/common/test_common.h" +#include "srsran/srsran.h" /* * Tests @@ -55,7 +55,7 @@ int test_set_1() } else { printf("Test Set 1: Success\n"); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_set_2() @@ -86,7 +86,7 @@ int test_set_2() } else { printf("Test Set 2: Success\n"); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_set_3() @@ -121,7 +121,7 @@ int test_set_3() } else { printf("Test Set 3: Success\n"); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_set_4() @@ -166,7 +166,7 @@ int test_set_4() } else { printf("Test Set 4: Success\n"); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_set_5() @@ -236,15 +236,15 @@ int test_set_5() } else { printf("Test Set 5: Success\n"); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int main(int argc, char* argv[]) { - TESTASSERT(test_set_1() == SRSLTE_SUCCESS); - TESTASSERT(test_set_2() == SRSLTE_SUCCESS); - TESTASSERT(test_set_3() == SRSLTE_SUCCESS); - TESTASSERT(test_set_4() == SRSLTE_SUCCESS); - TESTASSERT(test_set_5() == SRSLTE_SUCCESS); - return SRSLTE_SUCCESS; + TESTASSERT(test_set_1() == SRSRAN_SUCCESS); + TESTASSERT(test_set_2() == SRSRAN_SUCCESS); + TESTASSERT(test_set_3() == SRSRAN_SUCCESS); + TESTASSERT(test_set_4() == SRSRAN_SUCCESS); + TESTASSERT(test_set_5() == SRSRAN_SUCCESS); + return SRSRAN_SUCCESS; } \ No newline at end of file diff --git a/lib/test/common/test_f12345.cc b/lib/test/common/test_f12345.cc index 4a51211e8..f37734877 100644 --- a/lib/test/common/test_f12345.cc +++ b/lib/test/common/test_f12345.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,8 +13,8 @@ #include #include -#include "srslte/common/liblte_security.h" -#include "srslte/common/test_common.h" +#include "srsran/common/liblte_security.h" +#include "srsran/common/test_common.h" /* * Prototypes */ @@ -149,7 +149,7 @@ int test_set_2() uint8_t ak_star[] = {0x45, 0x1e, 0x8b, 0xec, 0xa4, 0x3b}; err_cmp = arrcmp(ak_star_o, ak_star, sizeof(ak_star)); TESTASSERT(err_cmp == 0); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; ; } @@ -169,7 +169,7 @@ int test_set_ksg() 0x12, 0xe9, 0x98, 0xa1, 0x15, 0xec, 0x4e, 0x0c, 0xe9, 0x03, 0xba, 0x89, 0x36, 0x7e, 0x26, 0x28}; err_cmp = arrcmp(sk_gnb_o, sk_gnb, sizeof(sk_gnb)); TESTASSERT(err_cmp == 0); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_set_nr_rrc_up() @@ -217,7 +217,7 @@ int test_set_nr_rrc_up() err_cmp = arrcmp(k_up_enc_o, k_up_enc, sizeof(k_up_enc_o)); TESTASSERT(err_cmp == 0); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } /* @@ -227,8 +227,8 @@ int test_set_nr_rrc_up() int main(int argc, char* argv[]) { - TESTASSERT(test_set_2() == SRSLTE_SUCCESS); - TESTASSERT(test_set_ksg() == SRSLTE_SUCCESS); - TESTASSERT(test_set_nr_rrc_up() == SRSLTE_SUCCESS); - return SRSLTE_SUCCESS; + TESTASSERT(test_set_2() == SRSRAN_SUCCESS); + TESTASSERT(test_set_ksg() == SRSRAN_SUCCESS); + TESTASSERT(test_set_nr_rrc_up() == SRSRAN_SUCCESS); + return SRSRAN_SUCCESS; } diff --git a/lib/test/common/timeout_test.cc b/lib/test/common/timeout_test.cc index d11970081..fd4379a29 100644 --- a/lib/test/common/timeout_test.cc +++ b/lib/test/common/timeout_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,13 +11,13 @@ */ extern "C" { -#include "srslte/common/timeout.h" -#include "srslte/config.h" +#include "srsran/common/timeout.h" +#include "srsran/config.h" } #include #include -using namespace srslte; +using namespace srsran; class callback : public timeout_callback { diff --git a/lib/test/common/timer_test.cc b/lib/test/common/timer_test.cc index 0fef98b66..05a8985f4 100644 --- a/lib/test/common/timer_test.cc +++ b/lib/test/common/timer_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,10 +10,10 @@ * */ -#include "srslte/common/timers.h" +#include "srsran/common/timers.h" #include #include -#include +#include #include #define TESTASSERT(cond) \ @@ -24,7 +24,7 @@ } \ } while (0) -using namespace srslte; +using namespace srsran; int timers_test1() { @@ -118,7 +118,7 @@ int timers_test1() // TEST: timer dtor is called and removes "timer" from "timers" TESTASSERT(timers.nof_timers() == 0); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int timers_test2() @@ -153,7 +153,7 @@ int timers_test2() utimer2.stop(); TESTASSERT(utimer2.is_expired()); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int timers_test3() @@ -184,13 +184,13 @@ int timers_test3() timers.step_all(); TESTASSERT(not utimer.is_running()); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } struct timers_test4_ctxt { std::vector timers; - srslte::tti_sync_cv tti_sync1; - srslte::tti_sync_cv tti_sync2; + srsran::tti_sync_cv tti_sync1; + srsran::tti_sync_cv tti_sync2; const uint32_t duration = 1000; }; @@ -293,7 +293,7 @@ int timers_test4() delete ctx; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } /** @@ -355,7 +355,7 @@ int timers_test5() TESTASSERT(vals.size() == 3); TESTASSERT(vals[2] == 3); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } /** @@ -400,17 +400,17 @@ int timers_test6() timers.step_all(); TESTASSERT(vals.size() == 1 and vals[0] == 3); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int main() { - TESTASSERT(timers_test1() == SRSLTE_SUCCESS); - TESTASSERT(timers_test2() == SRSLTE_SUCCESS); - TESTASSERT(timers_test3() == SRSLTE_SUCCESS); - TESTASSERT(timers_test4() == SRSLTE_SUCCESS); - TESTASSERT(timers_test5() == SRSLTE_SUCCESS); - TESTASSERT(timers_test6() == SRSLTE_SUCCESS); + TESTASSERT(timers_test1() == SRSRAN_SUCCESS); + TESTASSERT(timers_test2() == SRSRAN_SUCCESS); + TESTASSERT(timers_test3() == SRSRAN_SUCCESS); + TESTASSERT(timers_test4() == SRSRAN_SUCCESS); + TESTASSERT(timers_test5() == SRSRAN_SUCCESS); + TESTASSERT(timers_test6() == SRSRAN_SUCCESS); printf("Success\n"); return 0; } diff --git a/lib/test/common/tti_point_test.cc b/lib/test/common/tti_point_test.cc index 4e671e57c..654da476e 100644 --- a/lib/test/common/tti_point_test.cc +++ b/lib/test/common/tti_point_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,10 +10,10 @@ * */ -#include "srslte/common/test_common.h" -#include "srslte/common/tti_point.h" +#include "srsran/common/test_common.h" +#include "srsran/common/tti_point.h" -using srslte::tti_point; +using srsran::tti_point; int test_tti_type() { @@ -63,12 +63,12 @@ int test_tti_type() TESTASSERT(tti_point{1u - 100u} == tti_point{10141}); TESTASSERT(tti_point{10239u + 3u} == tti_point{2}); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int main() { srslog::init(); - TESTASSERT(test_tti_type() == SRSLTE_SUCCESS); + TESTASSERT(test_tti_type() == SRSRAN_SUCCESS); return 0; } diff --git a/lib/test/mac/CMakeLists.txt b/lib/test/mac/CMakeLists.txt index 6ee3364b3..089ab7c77 100644 --- a/lib/test/mac/CMakeLists.txt +++ b/lib/test/mac/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -7,14 +7,14 @@ # add_executable(pdu_test pdu_test.cc) -target_link_libraries(pdu_test srslte_phy srslte_common srslte_mac ${CMAKE_THREAD_LIBS_INIT}) +target_link_libraries(pdu_test srsran_phy srsran_common srsran_mac ${CMAKE_THREAD_LIBS_INIT}) add_test(pdu_test pdu_test) add_executable(mac_pcap_test mac_pcap_test.cc) -target_link_libraries(mac_pcap_test srslte_common srslte_mac ${SCTP_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) +target_link_libraries(mac_pcap_test srsran_common srsran_mac ${SCTP_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) add_test(mac_pcap_test mac_pcap_test) add_executable(mac_pdu_nr_test mac_pdu_nr_test.cc) -target_link_libraries(mac_pdu_nr_test srslte_mac srslte_common ${CMAKE_THREAD_LIBS_INIT}) +target_link_libraries(mac_pdu_nr_test srsran_mac srsran_common ${CMAKE_THREAD_LIBS_INIT}) add_test(mac_pdu_nr_test mac_pdu_nr_test) diff --git a/lib/test/mac/mac_pcap_test.cc b/lib/test/mac/mac_pcap_test.cc index 627adc412..45a44d8e7 100644 --- a/lib/test/mac/mac_pcap_test.cc +++ b/lib/test/mac/mac_pcap_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,14 +10,14 @@ * */ -#include "srslte/common/common.h" -#include "srslte/common/mac_pcap.h" -#include "srslte/common/test_common.h" +#include "srsran/common/common.h" +#include "srsran/common/mac_pcap.h" +#include "srsran/common/test_common.h" #include #include // Write #num_pdus UL MAC PDUs using PCAP handle -void write_pcap_eutra_thread_function(srslte::mac_pcap* pcap_handle, +void write_pcap_eutra_thread_function(srsran::mac_pcap* pcap_handle, const std::array& pdu, uint32_t num_pdus) { @@ -29,7 +29,7 @@ void write_pcap_eutra_thread_function(srslte::mac_pcap* pcap_handl } // Write #num_pdus DL MAC NR PDUs using PCAP handle -void write_pcap_nr_thread_function(srslte::mac_pcap* pcap_handle, const std::array& pdu, uint32_t num_pdus) +void write_pcap_nr_thread_function(srsran::mac_pcap* pcap_handle, const std::array& pdu, uint32_t num_pdus) { for (uint32_t i = 0; i < num_pdus; i++) { pcap_handle->write_dl_crnti_nr(const_cast(pdu.data()), pdu.size(), 0x1001, 0, 1); @@ -55,9 +55,9 @@ int mac_pcap_eutra_test() uint32_t num_threads = 10; uint32_t num_pdus_per_thread = 100; - std::unique_ptr pcap_handle = std::unique_ptr(new srslte::mac_pcap()); - TESTASSERT(pcap_handle->open("mac_pcap_test.pcap") == SRSLTE_SUCCESS); - TESTASSERT(pcap_handle->open("mac_pcap_test.pcap") != SRSLTE_SUCCESS); // open again will fail + std::unique_ptr pcap_handle = std::unique_ptr(new srsran::mac_pcap()); + TESTASSERT(pcap_handle->open("mac_pcap_test.pcap") == SRSRAN_SUCCESS); + TESTASSERT(pcap_handle->open("mac_pcap_test.pcap") != SRSRAN_SUCCESS); // open again will fail std::vector writer_threads; pcap_logger.info("Start writer_threads"); @@ -71,10 +71,10 @@ int mac_pcap_eutra_test() thread.join(); } pcap_logger.info("Close PCAP handle"); - TESTASSERT(pcap_handle->close() == SRSLTE_SUCCESS); + TESTASSERT(pcap_handle->close() == SRSRAN_SUCCESS); TESTASSERT(pcap_handle->close() != 0); // closing twice will fail - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int mac_pcap_nr_test() @@ -86,9 +86,9 @@ int mac_pcap_nr_test() uint32_t num_threads = 10; uint32_t num_pdus_per_thread = 100; - std::unique_ptr pcap_handle = std::unique_ptr(new srslte::mac_pcap()); - TESTASSERT(pcap_handle->open("mac_pcap_nr_test.pcap") == SRSLTE_SUCCESS); - TESTASSERT(pcap_handle->open("mac_pcap_nr_test.pcap") != SRSLTE_SUCCESS); // open again will fail + std::unique_ptr pcap_handle = std::unique_ptr(new srsran::mac_pcap()); + TESTASSERT(pcap_handle->open("mac_pcap_nr_test.pcap") == SRSRAN_SUCCESS); + TESTASSERT(pcap_handle->open("mac_pcap_nr_test.pcap") != SRSRAN_SUCCESS); // open again will fail std::vector writer_threads; pcap_logger.info("Start writer_threads"); @@ -104,10 +104,10 @@ int mac_pcap_nr_test() } pcap_logger.info("Close PCAP handle"); - TESTASSERT(pcap_handle->close() == SRSLTE_SUCCESS); + TESTASSERT(pcap_handle->close() == SRSRAN_SUCCESS); TESTASSERT(pcap_handle->close() != 0); // closing twice will fail - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int main() @@ -124,9 +124,9 @@ int main() pcap_logger.set_hex_dump_max_size(-1); pcap_logger.info("Start mac_pcap_eutra_test"); - TESTASSERT(mac_pcap_eutra_test() == SRSLTE_SUCCESS); + TESTASSERT(mac_pcap_eutra_test() == SRSRAN_SUCCESS); pcap_logger.info("Start mac_pcap_nr_test"); - TESTASSERT(mac_pcap_nr_test() == SRSLTE_SUCCESS); + TESTASSERT(mac_pcap_nr_test() == SRSRAN_SUCCESS); srslog::flush(); } diff --git a/lib/test/mac/mac_pdu_nr_test.cc b/lib/test/mac/mac_pdu_nr_test.cc index 080339cef..40557fb38 100644 --- a/lib/test/mac/mac_pdu_nr_test.cc +++ b/lib/test/mac/mac_pdu_nr_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,11 +10,11 @@ * */ -#include "srslte/common/mac_pcap.h" -#include "srslte/common/test_common.h" -#include "srslte/config.h" -#include "srslte/mac/mac_rar_pdu_nr.h" -#include "srslte/mac/mac_sch_pdu_nr.h" +#include "srsran/common/mac_pcap.h" +#include "srsran/common/test_common.h" +#include "srsran/config.h" +#include "srsran/mac/mac_rar_pdu_nr.h" +#include "srsran/mac/mac_sch_pdu_nr.h" #include #include @@ -25,9 +25,9 @@ #define PCAP_CRNTI (0x1001) #define PCAP_TTI (666) -using namespace srslte; +using namespace srsran; -static std::unique_ptr pcap_handle = nullptr; +static std::unique_ptr pcap_handle = nullptr; int mac_dl_sch_pdu_unpack_and_pack_test1() { @@ -44,7 +44,7 @@ int mac_dl_sch_pdu_unpack_and_pack_test1() pcap_handle->write_dl_crnti_nr(mac_dl_sch_pdu_1, sizeof(mac_dl_sch_pdu_1), PCAP_CRNTI, true, PCAP_TTI); } - srslte::mac_sch_pdu_nr pdu; + srsran::mac_sch_pdu_nr pdu; pdu.unpack(mac_dl_sch_pdu_1, sizeof(mac_dl_sch_pdu_1)); TESTASSERT(pdu.get_num_subpdus() == 1); @@ -56,7 +56,7 @@ int mac_dl_sch_pdu_unpack_and_pack_test1() // pack PDU again byte_buffer_t tx_buffer; - srslte::mac_sch_pdu_nr tx_pdu; + srsran::mac_sch_pdu_nr tx_pdu; tx_pdu.init_tx(&tx_buffer, sizeof(mac_dl_sch_pdu_1)); // Add SDU part of TV from above @@ -73,7 +73,7 @@ int mac_dl_sch_pdu_unpack_and_pack_test1() auto& mac_logger = srslog::fetch_basic_logger("MAC"); mac_logger.info(tx_buffer.msg, tx_buffer.N_bytes, "Generated MAC PDU (%d B)", tx_buffer.N_bytes); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int mac_dl_sch_pdu_unpack_test2() @@ -94,7 +94,7 @@ int mac_dl_sch_pdu_unpack_test2() pcap_handle->write_dl_crnti_nr(mac_dl_sch_pdu_2, sizeof(mac_dl_sch_pdu_2), PCAP_CRNTI, true, PCAP_TTI); } - srslte::mac_sch_pdu_nr pdu; + srsran::mac_sch_pdu_nr pdu; pdu.unpack(mac_dl_sch_pdu_2, sizeof(mac_dl_sch_pdu_2)); TESTASSERT(pdu.get_num_subpdus() == 1); mac_sch_subpdu_nr subpdu = pdu.get_subpdu(0); @@ -102,7 +102,7 @@ int mac_dl_sch_pdu_unpack_test2() TESTASSERT(subpdu.get_sdu_length() == 8); TESTASSERT(subpdu.get_lcid() == 2); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int mac_dl_sch_pdu_pack_test3() @@ -124,7 +124,7 @@ int mac_dl_sch_pdu_pack_test3() // pack buffer byte_buffer_t tx_buffer; - srslte::mac_sch_pdu_nr tx_pdu; + srsran::mac_sch_pdu_nr tx_pdu; tx_pdu.init_tx(&tx_buffer, 1024); // Add SDU @@ -140,7 +140,7 @@ int mac_dl_sch_pdu_pack_test3() auto& mac_logger = srslog::fetch_basic_logger("MAC"); mac_logger.info(tx_buffer.msg, tx_buffer.N_bytes, "Generated MAC PDU (%d B)", tx_buffer.N_bytes); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int mac_dl_sch_pdu_pack_test4() @@ -160,7 +160,7 @@ int mac_dl_sch_pdu_pack_test4() // modify buffer (to be nulled during PDU packing tx_buffer.msg[4] = 0xaa; - srslte::mac_sch_pdu_nr tx_pdu; + srsran::mac_sch_pdu_nr tx_pdu; tx_pdu.init_tx(&tx_buffer, pdu_size); TESTASSERT(tx_pdu.get_remaing_len() == pdu_size); @@ -177,7 +177,7 @@ int mac_dl_sch_pdu_pack_test4() auto& mac_logger = srslog::fetch_basic_logger("MAC"); mac_logger.info(tx_buffer.msg, tx_buffer.N_bytes, "Generated MAC PDU (%d B)", tx_buffer.N_bytes); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int mac_dl_sch_pdu_pack_test5() @@ -198,7 +198,7 @@ int mac_dl_sch_pdu_pack_test5() byte_buffer_t tx_buffer; tx_buffer.clear(); - srslte::mac_sch_pdu_nr tx_pdu; + srsran::mac_sch_pdu_nr tx_pdu; tx_pdu.init_tx(&tx_buffer, pdu_size); // Add SDU part of TV from above @@ -220,7 +220,7 @@ int mac_dl_sch_pdu_pack_test5() auto& mac_logger = srslog::fetch_basic_logger("MAC"); mac_logger.info(tx_buffer.msg, tx_buffer.N_bytes, "Generated MAC PDU (%d B)", tx_buffer.N_bytes); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int mac_dl_sch_pdu_unpack_test6() @@ -238,11 +238,11 @@ int mac_dl_sch_pdu_unpack_test6() pcap_handle->write_dl_crnti_nr(mac_dl_sch_pdu_2, sizeof(mac_dl_sch_pdu_2), PCAP_CRNTI, true, PCAP_TTI); } - srslte::mac_sch_pdu_nr pdu; + srsran::mac_sch_pdu_nr pdu; pdu.unpack(mac_dl_sch_pdu_2, sizeof(mac_dl_sch_pdu_2)); TESTASSERT(pdu.get_num_subpdus() == 0); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int mac_rar_pdu_unpack_test7() @@ -276,7 +276,7 @@ int mac_rar_pdu_unpack_test7() pcap_handle->write_dl_ra_rnti_nr(mac_dl_rar_pdu, sizeof(mac_dl_rar_pdu), 0x0016, true, PCAP_TTI); } - srslte::mac_rar_pdu_nr pdu; + srsran::mac_rar_pdu_nr pdu; TESTASSERT(pdu.unpack(mac_dl_rar_pdu, sizeof(mac_dl_rar_pdu)) == true); std::cout << pdu.to_string() << std::endl; @@ -293,7 +293,7 @@ int mac_rar_pdu_unpack_test7() std::array msg3_grant = subpdu.get_ul_grant(); TESTASSERT(memcmp(msg3_grant.data(), tv_msg3_grant, msg3_grant.size()) == 0); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int mac_rar_pdu_unpack_test8() @@ -311,7 +311,7 @@ int mac_rar_pdu_unpack_test8() } // unpacking should fail - srslte::mac_rar_pdu_nr pdu; + srsran::mac_rar_pdu_nr pdu; TESTASSERT(pdu.unpack(mac_dl_rar_pdu, sizeof(mac_dl_rar_pdu)) == false); TESTASSERT(pdu.get_num_subpdus() == 0); @@ -323,7 +323,7 @@ int mac_rar_pdu_unpack_test8() TESTASSERT(pdu.unpack(mac_dl_rar_pdu2, sizeof(mac_dl_rar_pdu2)) == false); TESTASSERT(pdu.get_num_subpdus() == 0); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int mac_ul_sch_pdu_unpack_test1() @@ -348,7 +348,7 @@ int mac_ul_sch_pdu_unpack_test1() pcap_handle->write_ul_crnti_nr(mac_ul_sch_pdu_1, sizeof(mac_ul_sch_pdu_1), PCAP_CRNTI, true, PCAP_TTI); } - srslte::mac_sch_pdu_nr pdu(true); + srsran::mac_sch_pdu_nr pdu(true); pdu.unpack(mac_ul_sch_pdu_1, sizeof(mac_ul_sch_pdu_1)); TESTASSERT(pdu.get_num_subpdus() == 2); @@ -365,7 +365,7 @@ int mac_ul_sch_pdu_unpack_test1() TESTASSERT(subpdu1.get_sdu_length() == 4); TESTASSERT(subpdu1.get_lcid() == 3); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int mac_ul_sch_pdu_unpack_and_pack_test2() @@ -382,7 +382,7 @@ int mac_ul_sch_pdu_unpack_and_pack_test2() pcap_handle->write_ul_crnti_nr(mac_ul_sch_pdu_1, sizeof(mac_ul_sch_pdu_1), PCAP_CRNTI, true, PCAP_TTI); } - srslte::mac_sch_pdu_nr pdu(true); + srsran::mac_sch_pdu_nr pdu(true); pdu.unpack(mac_ul_sch_pdu_1, sizeof(mac_ul_sch_pdu_1)); TESTASSERT(pdu.get_num_subpdus() == 1); @@ -394,7 +394,7 @@ int mac_ul_sch_pdu_unpack_and_pack_test2() // pack PDU again byte_buffer_t tx_buffer; - srslte::mac_sch_pdu_nr tx_pdu; + srsran::mac_sch_pdu_nr tx_pdu; tx_pdu.init_tx(&tx_buffer, sizeof(mac_ul_sch_pdu_1), true); // Add SDU part of TV from above @@ -411,7 +411,7 @@ int mac_ul_sch_pdu_unpack_and_pack_test2() auto& mac_logger = srslog::fetch_basic_logger("MAC"); mac_logger.info(tx_buffer.msg, tx_buffer.N_bytes, "Generated MAC PDU (%d B)", tx_buffer.N_bytes); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int mac_ul_sch_pdu_unpack_and_pack_test3() @@ -429,7 +429,7 @@ int mac_ul_sch_pdu_unpack_and_pack_test3() pcap_handle->write_ul_crnti_nr(mac_ul_sch_pdu_1, sizeof(mac_ul_sch_pdu_1), PCAP_CRNTI, true, PCAP_TTI); } - srslte::mac_sch_pdu_nr pdu(true); + srsran::mac_sch_pdu_nr pdu(true); pdu.unpack(mac_ul_sch_pdu_1, sizeof(mac_ul_sch_pdu_1)); TESTASSERT(pdu.get_num_subpdus() == 1); @@ -441,7 +441,7 @@ int mac_ul_sch_pdu_unpack_and_pack_test3() // pack PDU again byte_buffer_t tx_buffer; - srslte::mac_sch_pdu_nr tx_pdu; + srsran::mac_sch_pdu_nr tx_pdu; tx_pdu.init_tx(&tx_buffer, sizeof(mac_ul_sch_pdu_1), true); // Add SDU part of TV from above @@ -458,7 +458,7 @@ int mac_ul_sch_pdu_unpack_and_pack_test3() auto& mac_logger = srslog::fetch_basic_logger("MAC"); mac_logger.info(tx_buffer.msg, tx_buffer.N_bytes, "Generated MAC PDU (%d B)", tx_buffer.N_bytes); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int mac_ul_sch_pdu_pack_test4() @@ -480,7 +480,7 @@ int mac_ul_sch_pdu_pack_test4() // pack PDU again byte_buffer_t tx_buffer; - srslte::mac_sch_pdu_nr tx_pdu; + srsran::mac_sch_pdu_nr tx_pdu; tx_pdu.init_tx(&tx_buffer, sizeof(sdu) + 3, true); // Add SDU part of TV from above @@ -496,7 +496,7 @@ int mac_ul_sch_pdu_pack_test4() auto& mac_logger = srslog::fetch_basic_logger("MAC"); mac_logger.info(tx_buffer.msg, tx_buffer.N_bytes, "Generated MAC PDU (%d B)", tx_buffer.N_bytes); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int mac_ul_sch_pdu_unpack_test5() @@ -514,11 +514,11 @@ int mac_ul_sch_pdu_unpack_test5() pcap_handle->write_ul_crnti_nr(mac_ul_sch_pdu_1, sizeof(mac_ul_sch_pdu_1), PCAP_CRNTI, true, PCAP_TTI); } - srslte::mac_sch_pdu_nr pdu(true); + srsran::mac_sch_pdu_nr pdu(true); pdu.unpack(mac_ul_sch_pdu_1, sizeof(mac_ul_sch_pdu_1)); TESTASSERT(pdu.get_num_subpdus() == 0); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int mac_dl_sch_pdu_unpack_and_pack_test6() @@ -540,7 +540,7 @@ int mac_dl_sch_pdu_unpack_and_pack_test6() // Unpack TV { - srslte::mac_sch_pdu_nr pdu_rx(true); + srsran::mac_sch_pdu_nr pdu_rx(true); pdu_rx.unpack(tv, sizeof(tv)); TESTASSERT(pdu_rx.get_num_subpdus() == 4); @@ -572,21 +572,21 @@ int mac_dl_sch_pdu_unpack_and_pack_test6() // Let's pack the entire PDU again { byte_buffer_t tx_buffer; - srslte::mac_sch_pdu_nr pdu_tx(true); + srsran::mac_sch_pdu_nr pdu_tx(true); pdu_tx.init_tx(&tx_buffer, sizeof(tv), true); // same size as TV TESTASSERT(pdu_tx.get_remaing_len() == 9); - TESTASSERT(pdu_tx.add_crnti_ce(TV_CRNTI) == SRSLTE_SUCCESS); + TESTASSERT(pdu_tx.add_crnti_ce(TV_CRNTI) == SRSRAN_SUCCESS); TESTASSERT(pdu_tx.get_remaing_len() == 6); - TESTASSERT(pdu_tx.add_se_phr_ce(TV_PHR, TV_PC) == SRSLTE_SUCCESS); + TESTASSERT(pdu_tx.add_se_phr_ce(TV_PHR, TV_PC) == SRSRAN_SUCCESS); TESTASSERT(pdu_tx.get_remaing_len() == 3); mac_sch_subpdu_nr::lcg_bsr_t sbsr = {}; sbsr.lcg_id = TV_LCG; sbsr.buffer_size = TV_BUFF_SIZE; - TESTASSERT(pdu_tx.add_sbsr_ce(sbsr) == SRSLTE_SUCCESS); + TESTASSERT(pdu_tx.add_sbsr_ce(sbsr) == SRSRAN_SUCCESS); TESTASSERT(pdu_tx.get_remaing_len() == 1); // finish PDU packing @@ -601,13 +601,13 @@ int mac_dl_sch_pdu_unpack_and_pack_test6() } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int main(int argc, char** argv) { #if PCAP - pcap_handle = std::unique_ptr(new srslte::mac_pcap()); + pcap_handle = std::unique_ptr(new srsran::mac_pcap()); pcap_handle->open("mac_nr_pdu_test.pcap"); #endif @@ -619,77 +619,77 @@ int main(int argc, char** argv) if (mac_dl_sch_pdu_unpack_and_pack_test1()) { fprintf(stderr, "mac_dl_sch_pdu_unpack_and_pack_test1() failed.\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (mac_dl_sch_pdu_unpack_test2()) { fprintf(stderr, "mac_dl_sch_pdu_unpack_test2() failed.\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (mac_dl_sch_pdu_pack_test3()) { fprintf(stderr, "mac_dl_sch_pdu_pack_test3() failed.\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (mac_dl_sch_pdu_pack_test4()) { fprintf(stderr, "mac_dl_sch_pdu_pack_test4() failed.\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (mac_dl_sch_pdu_pack_test5()) { fprintf(stderr, "mac_dl_sch_pdu_pack_test5() failed.\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (mac_dl_sch_pdu_unpack_test6()) { fprintf(stderr, "mac_dl_sch_pdu_unpack_test6() failed.\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (mac_rar_pdu_unpack_test7()) { fprintf(stderr, "mac_rar_pdu_unpack_test7() failed.\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (mac_rar_pdu_unpack_test8()) { fprintf(stderr, "mac_rar_pdu_unpack_test8() failed.\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (mac_ul_sch_pdu_unpack_test1()) { fprintf(stderr, "mac_ul_sch_pdu_unpack_test1() failed.\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (mac_ul_sch_pdu_unpack_and_pack_test2()) { fprintf(stderr, "mac_ul_sch_pdu_unpack_and_pack_test2() failed.\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (mac_ul_sch_pdu_unpack_and_pack_test3()) { fprintf(stderr, "mac_ul_sch_pdu_unpack_and_pack_test3() failed.\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (mac_ul_sch_pdu_pack_test4()) { fprintf(stderr, "mac_ul_sch_pdu_pack_test4() failed.\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (mac_ul_sch_pdu_unpack_test5()) { fprintf(stderr, "mac_ul_sch_pdu_unpack_test5() failed.\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (mac_dl_sch_pdu_unpack_and_pack_test6()) { fprintf(stderr, "mac_dl_sch_pdu_unpack_and_pack_test6() failed.\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (pcap_handle) { pcap_handle->close(); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } diff --git a/lib/test/mac/pdu_test.cc b/lib/test/mac/pdu_test.cc index 1c61005de..13296205b 100644 --- a/lib/test/mac/pdu_test.cc +++ b/lib/test/mac/pdu_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,14 +10,14 @@ * */ -#include "srslte/common/common.h" -#include "srslte/common/interfaces_common.h" -#include "srslte/common/mac_pcap.h" -#include "srslte/common/test_common.h" -#include "srslte/mac/pdu.h" +#include "srsran/common/common.h" +#include "srsran/common/interfaces_common.h" +#include "srsran/common/mac_pcap.h" +#include "srsran/common/test_common.h" +#include "srsran/mac/pdu.h" extern "C" { -#include "srslte/phy/phch/dci.h" +#include "srsran/phy/phch/dci.h" } #include @@ -31,9 +31,9 @@ std::random_device rd; std::mt19937 rand_gen(rd()); std::uniform_int_distribution uniform_dist_u8(0, 255); -static std::unique_ptr pcap_handle = nullptr; +static std::unique_ptr pcap_handle = nullptr; -using namespace srslte; +using namespace srsran; #define CRNTI (0x1001) @@ -50,7 +50,7 @@ uint8_t rar_pdu_tv2[] = {0x82, 0x56, 0x00, 0x00, 0x00, 0x0c, 0x10, 0x01}; int mac_rar_pdu_unpack_test1() { - srslte::rar_pdu rar_pdu_msg; + srsran::rar_pdu rar_pdu_msg; rar_pdu_msg.init_rx(sizeof(rar_pdu_tv1)); rar_pdu_msg.parse_packet(rar_pdu_tv1); fmt::memory_buffer buffer; @@ -65,12 +65,12 @@ int mac_rar_pdu_unpack_test1() TESTASSERT(rar_pdu_msg.get()->get_temp_crnti() == CRNTI); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int mac_rar_pdu_unpack_test2() { - srslte::rar_pdu rar_pdu_msg; + srsran::rar_pdu rar_pdu_msg; rar_pdu_msg.init_rx(sizeof(rar_pdu_tv2)); rar_pdu_msg.parse_packet(rar_pdu_tv2); fmt::memory_buffer buffer; @@ -88,7 +88,7 @@ int mac_rar_pdu_unpack_test2() } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Malformed RAR PDU with two RAPIDs but incomplete content @@ -99,28 +99,28 @@ int mac_rar_pdu_unpack_test3() uint8_t rar_pdu[] = {0xd5, 0x4e, 0x02, 0x80, 0x1a, 0x0c, 0x00, 0x47, 0x00, 0x00, 0x1a, 0xff, 0xff, 0xff}; uint8_t rar_pdu_len = 11; - srslte::rar_pdu rar_pdu_msg; + srsran::rar_pdu rar_pdu_msg; rar_pdu_msg.init_rx(rar_pdu_len); // only pass the 11 valid bytes - TESTASSERT(rar_pdu_msg.parse_packet(rar_pdu) != SRSLTE_SUCCESS); + TESTASSERT(rar_pdu_msg.parse_packet(rar_pdu) != SRSRAN_SUCCESS); TESTASSERT(rar_pdu_msg.nof_subh() == 0); fmt::memory_buffer buffer; rar_pdu_msg.to_string(buffer); std::cout << fmt::to_string(buffer) << std::endl; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int mac_rar_pdu_pack_test1() { // Prepare RAR grant uint8_t grant_buffer[64] = {}; - srslte_dci_rar_grant_t rar_grant = {}; + srsran_dci_rar_grant_t rar_grant = {}; rar_grant.tpc_pusch = 3; - srslte_dci_rar_pack(&rar_grant, grant_buffer); + srsran_dci_rar_pack(&rar_grant, grant_buffer); // Create MAC PDU and add RAR subheader - srslte::rar_pdu rar_pdu; + srsran::rar_pdu rar_pdu; byte_buffer_t tx_buffer; rar_pdu.init_tx(&tx_buffer, 64); @@ -135,19 +135,19 @@ int mac_rar_pdu_pack_test1() // compare with TV1 TESTASSERT(memcmp(tx_buffer.msg, rar_pdu_tv1, sizeof(rar_pdu_tv1)) == 0); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int mac_rar_pdu_pack_test2() { // Prepare RAR grant uint8_t grant_buffer[64] = {}; - srslte_dci_rar_grant_t rar_grant = {}; + srsran_dci_rar_grant_t rar_grant = {}; rar_grant.tpc_pusch = 3; - srslte_dci_rar_pack(&rar_grant, grant_buffer); + srsran_dci_rar_pack(&rar_grant, grant_buffer); // Create MAC PDU and add RAR subheader - srslte::rar_pdu rar_pdu; + srsran::rar_pdu rar_pdu; byte_buffer_t tx_buffer; rar_pdu.init_tx(&tx_buffer, 64); rar_pdu.set_backoff(BACKOFF_IND_TV2); @@ -162,11 +162,11 @@ int mac_rar_pdu_pack_test2() // compare with TV2 TESTASSERT(memcmp(tx_buffer.msg, rar_pdu_tv2, sizeof(rar_pdu_tv2)) == 0); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Helper class to provide read_pdu_interface -class rlc_dummy : public srslte::read_pdu_interface +class rlc_dummy : public srsran::read_pdu_interface { public: int read_pdu(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes) @@ -206,7 +206,7 @@ int mac_sch_pdu_pack_test1() rlc.write_sdu(2, sdu_len); const uint32_t pdu_size = 25; - srslte::sch_pdu pdu(10, mac_logger); + srsran::sch_pdu pdu(10, mac_logger); byte_buffer_t buffer; pdu.init_tx(&buffer, pdu_size, true); @@ -242,7 +242,7 @@ int mac_sch_pdu_pack_test1() // compare with TV TESTASSERT(memcmp(buffer.msg, tv, sizeof(tv)) == 0); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Basic test to pack a MAC PDU with a two SDUs of short length (i.e < 128B for short length header) and 2x single-byte @@ -263,7 +263,7 @@ int mac_sch_pdu_pack_test2() const uint32_t pdu_size = 21; - srslte::sch_pdu pdu(10, mac_logger); + srsran::sch_pdu pdu(10, mac_logger); byte_buffer_t buffer; pdu.init_tx(&buffer, pdu_size, true); @@ -298,7 +298,7 @@ int mac_sch_pdu_pack_test2() // compare with TV TESTASSERT(memcmp(buffer.msg, tv, sizeof(tv)) == 0); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Basic test to pack a MAC PDU with one short and one long SDU (i.e >= 128 B for 16bit length header) @@ -324,7 +324,7 @@ int mac_sch_pdu_pack_test3() rlc.write_sdu(2, 130); const uint32_t pdu_size = 150; - srslte::sch_pdu pdu(10, mac_logger); + srsran::sch_pdu pdu(10, mac_logger); byte_buffer_t buffer; pdu.init_tx(&buffer, pdu_size, true); @@ -359,7 +359,7 @@ int mac_sch_pdu_pack_test3() // compare with TV TESTASSERT(memcmp(buffer.msg, tv, sizeof(tv)) == 0); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Test for padding-only MAC PDU @@ -372,7 +372,7 @@ int mac_sch_pdu_pack_test4() rlc_dummy rlc; const uint32_t pdu_size = 10; - srslte::sch_pdu pdu(10, mac_logger); + srsran::sch_pdu pdu(10, mac_logger); byte_buffer_t buffer; pdu.init_tx(&buffer, pdu_size, true); @@ -405,7 +405,7 @@ int mac_sch_pdu_pack_test4() // compare with TV TESTASSERT(memcmp(buffer.msg, tv, sizeof(tv)) == 0); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Test for max. TBS MAC PDU @@ -418,8 +418,8 @@ int mac_sch_pdu_pack_test5() // write big SDU rlc.write_sdu(2, 20000); - const uint32_t pdu_size = SRSLTE_MAX_TBSIZE_BITS / 8; // Max. DL allocation for a single TB using 256 QAM - srslte::sch_pdu pdu(10, mac_logger); + const uint32_t pdu_size = SRSRAN_MAX_TBSIZE_BITS / 8; // Max. DL allocation for a single TB using 256 QAM + srsran::sch_pdu pdu(10, mac_logger); byte_buffer_t buffer; pdu.init_tx(&buffer, pdu_size, true); @@ -446,7 +446,7 @@ int mac_sch_pdu_pack_test5() pcap_handle->write_ul_crnti(buffer.msg, buffer.N_bytes, 0x1001, true, 1, 0); #endif - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Test for Long BSR CE @@ -455,7 +455,7 @@ int mac_sch_pdu_pack_test6() auto& mac_logger = srslog::fetch_basic_logger("MAC"); const uint32_t pdu_size = 8; - srslte::sch_pdu pdu(10, mac_logger); + srsran::sch_pdu pdu(10, mac_logger); uint8_t tv[pdu_size] = {0x3e, 0x1f, 0x86, 0x18, 0x61, 0x00, 0x00, 0x00}; // upper edge case uint8_t tv2[pdu_size] = {0x3e, 0x1f, 0x04, 0x10, 0x41, 0x00, 0x00, 0x00}; // lower edge case @@ -475,7 +475,7 @@ int mac_sch_pdu_pack_test6() // the bit-pattern reported for each LCG uint32_t buff_size_tx[4] = {1552, 1552, 1552, 1552}; TESTASSERT(pdu.new_subh()); - TESTASSERT(pdu.get()->set_bsr(buff_size_tx, srslte::ul_sch_lcid::LONG_BSR)); + TESTASSERT(pdu.get()->set_bsr(buff_size_tx, srsran::ul_sch_lcid::LONG_BSR)); // write PDU pdu.write_packet(mac_logger); @@ -492,7 +492,7 @@ int mac_sch_pdu_pack_test6() uint32_t buff_size_rx[4] = {}; while (pdu.next()) { - if (!pdu.get()->is_sdu() && pdu.get()->ul_sch_ce_type() == srslte::ul_sch_lcid::LONG_BSR) { + if (!pdu.get()->is_sdu() && pdu.get()->ul_sch_ce_type() == srsran::ul_sch_lcid::LONG_BSR) { uint32_t buff_size_idx[4] = {}; uint32_t nonzero_lcg = pdu.get()->get_bsr(buff_size_idx, buff_size_rx); for (uint32_t i = 0; i < 4; i++) { @@ -532,7 +532,7 @@ int mac_sch_pdu_pack_test6() uint32_t buff_size_tx_low_edge[4] = {1, 1, 1, 1}; uint32_t buff_size_rx_expected_low_edge[4] = {10, 10, 10, 10}; TESTASSERT(pdu.new_subh()); - TESTASSERT(pdu.get()->set_bsr(buff_size_tx_low_edge, srslte::ul_sch_lcid::LONG_BSR)); + TESTASSERT(pdu.get()->set_bsr(buff_size_tx_low_edge, srsran::ul_sch_lcid::LONG_BSR)); // write PDU pdu.write_packet(mac_logger); @@ -559,7 +559,7 @@ int mac_sch_pdu_pack_test6() uint32_t buff_size_rx_low_edge[4] = {}; while (pdu.next()) { - if (!pdu.get()->is_sdu() && pdu.get()->ul_sch_ce_type() == srslte::ul_sch_lcid::LONG_BSR) { + if (!pdu.get()->is_sdu() && pdu.get()->ul_sch_ce_type() == srsran::ul_sch_lcid::LONG_BSR) { uint32_t buff_size_idx[4] = {}; uint32_t nonzero_lcg = pdu.get()->get_bsr(buff_size_idx, buff_size_rx_low_edge); for (uint32_t i = 0; i < 4; i++) { @@ -587,7 +587,7 @@ int mac_sch_pdu_pack_test6() uint32_t buff_size_rx_expected_max_idx[4] = {60, 61, 62, 63}; uint32_t buff_size_rx_expected_max_value[4] = {109439, 128125, 150000, 150000}; TESTASSERT(pdu.new_subh()); - TESTASSERT(pdu.get()->set_bsr(buff_size_max_idx, srslte::ul_sch_lcid::LONG_BSR)); + TESTASSERT(pdu.get()->set_bsr(buff_size_max_idx, srsran::ul_sch_lcid::LONG_BSR)); // write PDU pdu.write_packet(mac_logger); @@ -614,7 +614,7 @@ int mac_sch_pdu_pack_test6() uint32_t buff_size_rx_max_idx[4] = {}; while (pdu.next()) { - if (!pdu.get()->is_sdu() && pdu.get()->ul_sch_ce_type() == srslte::ul_sch_lcid::LONG_BSR) { + if (!pdu.get()->is_sdu() && pdu.get()->ul_sch_ce_type() == srsran::ul_sch_lcid::LONG_BSR) { uint32_t buff_size[4] = {}; uint32_t nonzero_lcg = pdu.get()->get_bsr(buff_size_rx_max_idx, buff_size); for (uint32_t i = 0; i < 4; i++) { @@ -628,7 +628,7 @@ int mac_sch_pdu_pack_test6() TESTASSERT(buff_size_rx_max_idx[i] == buff_size_rx_expected_max_idx[i]); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Test for short MAC PDU containing padding only @@ -640,7 +640,7 @@ int mac_sch_pdu_pack_test7() rlc.write_sdu(1, 8); const uint32_t pdu_size = 2; - srslte::sch_pdu pdu(10, mac_logger); + srsran::sch_pdu pdu(10, mac_logger); uint8_t tv[pdu_size] = {0x1f, 0x1f}; @@ -656,7 +656,7 @@ int mac_sch_pdu_pack_test7() TESTASSERT(pdu.new_subh()); // adding SDU fails - TESTASSERT(pdu.get()->set_sdu(2, 8, &rlc) == SRSLTE_ERROR); + TESTASSERT(pdu.get()->set_sdu(2, 8, &rlc) == SRSRAN_ERROR); // remove subheader again pdu.del_subh(); @@ -674,7 +674,7 @@ int mac_sch_pdu_pack_test7() pcap_handle->write_ul_crnti(buffer.msg, buffer.N_bytes, 0x1001, true, 1, 0); #endif - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Test Packing of SCell Activation CE command @@ -683,7 +683,7 @@ int mac_sch_pdu_pack_test8() auto& mac_logger = srslog::fetch_basic_logger("MAC"); const uint32_t pdu_size = 2; - srslte::sch_pdu pdu(10, mac_logger); + srsran::sch_pdu pdu(10, mac_logger); std::bitset<8> cc_mask(uniform_dist_u8(rand_gen)); // subheader: R|F2|E|LCID = 0|0|0|11011 @@ -691,7 +691,7 @@ int mac_sch_pdu_pack_test8() // ensure reserved bit tv[1] &= ~(0x1u); // limit to max carriers - tv[1] &= ((1u << (uint32_t)SRSLTE_MAX_CARRIERS) - 1u); + tv[1] &= ((1u << (uint32_t)SRSRAN_MAX_CARRIERS) - 1u); byte_buffer_t buffer; pdu.init_tx(&buffer, pdu_size, true); @@ -703,8 +703,8 @@ int mac_sch_pdu_pack_test8() // Try SCell activation CE TESTASSERT(pdu.new_subh()); - std::array cc_activ_list = {}; - for (uint8_t i = 1; i < SRSLTE_MAX_CARRIERS; ++i) { + std::array cc_activ_list = {}; + for (uint8_t i = 1; i < SRSRAN_MAX_CARRIERS; ++i) { cc_activ_list[i] = cc_mask.test(i); } TESTASSERT(pdu.get()->set_scell_activation_cmd(cc_activ_list)); @@ -723,7 +723,7 @@ int mac_sch_pdu_pack_test8() pcap_handle->write_dl_crnti(tv, sizeof(tv), 0x1001, true, 1, 0); #endif - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Test for Short BSR CE @@ -732,7 +732,7 @@ int mac_sch_pdu_pack_test9() auto& mac_logger = srslog::fetch_basic_logger("MAC"); const uint32_t pdu_size = 3; - srslte::sch_pdu pdu(10, mac_logger); + srsran::sch_pdu pdu(10, mac_logger); uint8_t tv[pdu_size] = {0x3f, 0x1d, 0x09}; @@ -747,7 +747,7 @@ int mac_sch_pdu_pack_test9() // Try to add short BSR CE uint32_t buff_size[4] = {36, 0, 0, 0}; TESTASSERT(pdu.new_subh()); - TESTASSERT(pdu.get()->set_bsr(buff_size, srslte::ul_sch_lcid::SHORT_BSR)); + TESTASSERT(pdu.get()->set_bsr(buff_size, srsran::ul_sch_lcid::SHORT_BSR)); TESTASSERT(pdu.new_subh() == false); // write PDU @@ -763,7 +763,7 @@ int mac_sch_pdu_pack_test9() pcap_handle->write_ul_crnti(buffer.msg, buffer.N_bytes, 0x1001, true, 1, 0); #endif - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Test for Short BSR CE + PHR CE @@ -772,7 +772,7 @@ int mac_sch_pdu_pack_test10() auto& mac_logger = srslog::fetch_basic_logger("MAC"); const uint32_t pdu_size = 4; - srslte::sch_pdu pdu(10, mac_logger); + srsran::sch_pdu pdu(10, mac_logger); uint8_t tv[pdu_size] = {0x3d, 0x1a, 0x1f, 0x21}; @@ -787,7 +787,7 @@ int mac_sch_pdu_pack_test10() // Try to add short BSR CE uint32_t buff_size[4] = {1132, 0, 0, 0}; TESTASSERT(pdu.new_subh()); - TESTASSERT(pdu.get()->set_bsr(buff_size, srslte::ul_sch_lcid::SHORT_BSR)); + TESTASSERT(pdu.get()->set_bsr(buff_size, srsran::ul_sch_lcid::SHORT_BSR)); // Try to add PHR CE TESTASSERT(pdu.new_subh()); @@ -806,7 +806,7 @@ int mac_sch_pdu_pack_test10() pcap_handle->write_ul_crnti(buffer.msg, buffer.N_bytes, 0x1001, true, 1, 0); #endif - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Pack test for short MAC PDU, trying to add long BSR but no space left @@ -815,7 +815,7 @@ int mac_sch_pdu_pack_test11() auto& mac_logger = srslog::fetch_basic_logger("MAC"); const uint32_t pdu_size = 3; - srslte::sch_pdu pdu(10, mac_logger); + srsran::sch_pdu pdu(10, mac_logger); uint8_t tv[pdu_size] = {0x1f, 0x00, 0x00}; @@ -830,7 +830,7 @@ int mac_sch_pdu_pack_test11() // Try to Long BSR CE uint32_t buff_size[4] = {0, 1000, 5000, 19200000}; TESTASSERT(pdu.new_subh()); - TESTASSERT(pdu.get()->set_bsr(buff_size, srslte::ul_sch_lcid::LONG_BSR) == false); + TESTASSERT(pdu.get()->set_bsr(buff_size, srsran::ul_sch_lcid::LONG_BSR) == false); // Adding BSR failed, remove subheader again pdu.del_subh(); @@ -848,7 +848,7 @@ int mac_sch_pdu_pack_test11() pcap_handle->write_ul_crnti(buffer.msg, buffer.N_bytes, 0x1001, true, 1, 0); #endif - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Test for checking error cases @@ -861,7 +861,7 @@ int mac_sch_pdu_pack_error_test() rlc.write_sdu(1, 8); const uint32_t pdu_size = 150; - srslte::sch_pdu pdu(10, mac_logger); + srsran::sch_pdu pdu(10, mac_logger); byte_buffer_t buffer; pdu.init_tx(&buffer, pdu_size, true); @@ -879,7 +879,7 @@ int mac_sch_pdu_pack_error_test() TESTASSERT(pdu.new_subh()); // adding SDU fails - TESTASSERT(pdu.get()->set_sdu(1, 8, &rlc) == SRSLTE_ERROR); + TESTASSERT(pdu.get()->set_sdu(1, 8, &rlc) == SRSRAN_ERROR); // writing PDU fails TESTASSERT(pdu.write_packet(mac_logger) == nullptr); @@ -901,7 +901,7 @@ int mac_sch_pdu_pack_error_test() pcap_handle->write_ul_crnti(buffer.msg, buffer.N_bytes, 0x1001, true, 1, 0); #endif - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int mac_mch_pdu_pack_test1() @@ -912,7 +912,7 @@ int mac_mch_pdu_pack_test1() auto& mac_logger = srslog::fetch_basic_logger("MAC"); const uint32_t pdu_size = 30; - srslte::mch_pdu mch_pdu(10, mac_logger); + srsran::mch_pdu mch_pdu(10, mac_logger); byte_buffer_t buffer; mch_pdu.init_tx(&buffer, pdu_size, true); @@ -950,7 +950,7 @@ int mac_mch_pdu_pack_test1() pcap_handle->write_ul_crnti(tv, sizeof(tv), 0x1001, true, 1, 0); #endif - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Parsing a corrupted MAC PDU and making sure the PDU is reset and not further processed @@ -958,7 +958,7 @@ int mac_sch_pdu_unpack_test1() { static uint8_t tv[] = {0x3f, 0x3f, 0x21, 0x3f, 0x03, 0x00, 0x04, 0x00, 0x04}; - srslte::sch_pdu pdu(10, srslog::fetch_basic_logger("MAC")); + srsran::sch_pdu pdu(10, srslog::fetch_basic_logger("MAC")); pdu.init_rx(sizeof(tv), false); pdu.parse_packet(tv); @@ -970,7 +970,7 @@ int mac_sch_pdu_unpack_test1() pcap_handle->write_ul_crnti(tv, sizeof(tv), 0x1001, true, 1, 0); #endif - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Parsing a (corrupted) MAC PDU that only contains padding @@ -978,7 +978,7 @@ int mac_sch_pdu_unpack_test2() { static uint8_t tv[] = {0x3f, 0x3f}; - srslte::sch_pdu pdu(20, srslog::fetch_basic_logger("MAC")); + srsran::sch_pdu pdu(20, srslog::fetch_basic_logger("MAC")); pdu.init_rx(sizeof(tv), false); pdu.parse_packet(tv); @@ -990,7 +990,7 @@ int mac_sch_pdu_unpack_test2() pcap_handle->write_ul_crnti(tv, sizeof(tv), 0x1001, true, 1, 0); #endif - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Unpacking of PDU containing Timing Advance (TA) CE @@ -998,13 +998,13 @@ int mac_sch_pdu_unpack_test3() { static uint8_t tv[] = {0x3d, 0x1f, 0x1f, 0x00}; - srslte::sch_pdu pdu(20, srslog::fetch_basic_logger("MAC")); + srsran::sch_pdu pdu(20, srslog::fetch_basic_logger("MAC")); pdu.init_rx(sizeof(tv), false); pdu.parse_packet(tv); TESTASSERT(pdu.nof_subh() == 2); while (pdu.next()) { - if (!pdu.get()->is_sdu() && pdu.get()->dl_sch_ce_type() == srslte::dl_sch_lcid::TA_CMD) { + if (!pdu.get()->is_sdu() && pdu.get()->dl_sch_ce_type() == srsran::dl_sch_lcid::TA_CMD) { TESTASSERT(pdu.get()->get_ta_cmd() == 31); } } @@ -1017,7 +1017,7 @@ int mac_sch_pdu_unpack_test3() pcap_handle->write_dl_crnti(tv, sizeof(tv), 0x1001, true, 1, 0); #endif - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int mac_slsch_pdu_unpack_test1() @@ -1033,13 +1033,13 @@ int mac_slsch_pdu_unpack_test1() pcap_handle->write_sl_crnti(tv, sizeof(tv), CRNTI, true, 1, 0); #endif - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int main(int argc, char** argv) { #if HAVE_PCAP - pcap_handle = std::unique_ptr(new srslte::mac_pcap()); + pcap_handle = std::unique_ptr(new srsran::mac_pcap()); pcap_handle->open("mac_pdu_test.pcap"); #endif auto& mac_logger = srslog::fetch_basic_logger("MAC", false); @@ -1051,33 +1051,33 @@ int main(int argc, char** argv) srslog::init(); - TESTASSERT(mac_rar_pdu_unpack_test1() == SRSLTE_SUCCESS); - TESTASSERT(mac_rar_pdu_unpack_test2() == SRSLTE_SUCCESS); - TESTASSERT(mac_rar_pdu_unpack_test3() == SRSLTE_SUCCESS); - TESTASSERT(mac_rar_pdu_pack_test1() == SRSLTE_SUCCESS); - TESTASSERT(mac_rar_pdu_pack_test2() == SRSLTE_SUCCESS); + TESTASSERT(mac_rar_pdu_unpack_test1() == SRSRAN_SUCCESS); + TESTASSERT(mac_rar_pdu_unpack_test2() == SRSRAN_SUCCESS); + TESTASSERT(mac_rar_pdu_unpack_test3() == SRSRAN_SUCCESS); + TESTASSERT(mac_rar_pdu_pack_test1() == SRSRAN_SUCCESS); + TESTASSERT(mac_rar_pdu_pack_test2() == SRSRAN_SUCCESS); - TESTASSERT(mac_sch_pdu_pack_test1() == SRSLTE_SUCCESS); - TESTASSERT(mac_sch_pdu_pack_test2() == SRSLTE_SUCCESS); - TESTASSERT(mac_sch_pdu_pack_test3() == SRSLTE_SUCCESS); - TESTASSERT(mac_sch_pdu_pack_test4() == SRSLTE_SUCCESS); - TESTASSERT(mac_sch_pdu_pack_test5() == SRSLTE_SUCCESS); - TESTASSERT(mac_sch_pdu_pack_test6() == SRSLTE_SUCCESS); - TESTASSERT(mac_sch_pdu_pack_test7() == SRSLTE_SUCCESS); - TESTASSERT(mac_sch_pdu_pack_test8() == SRSLTE_SUCCESS); - TESTASSERT(mac_sch_pdu_pack_test9() == SRSLTE_SUCCESS); - TESTASSERT(mac_sch_pdu_pack_test10() == SRSLTE_SUCCESS); - TESTASSERT(mac_sch_pdu_pack_test11() == SRSLTE_SUCCESS); + TESTASSERT(mac_sch_pdu_pack_test1() == SRSRAN_SUCCESS); + TESTASSERT(mac_sch_pdu_pack_test2() == SRSRAN_SUCCESS); + TESTASSERT(mac_sch_pdu_pack_test3() == SRSRAN_SUCCESS); + TESTASSERT(mac_sch_pdu_pack_test4() == SRSRAN_SUCCESS); + TESTASSERT(mac_sch_pdu_pack_test5() == SRSRAN_SUCCESS); + TESTASSERT(mac_sch_pdu_pack_test6() == SRSRAN_SUCCESS); + TESTASSERT(mac_sch_pdu_pack_test7() == SRSRAN_SUCCESS); + TESTASSERT(mac_sch_pdu_pack_test8() == SRSRAN_SUCCESS); + TESTASSERT(mac_sch_pdu_pack_test9() == SRSRAN_SUCCESS); + TESTASSERT(mac_sch_pdu_pack_test10() == SRSRAN_SUCCESS); + TESTASSERT(mac_sch_pdu_pack_test11() == SRSRAN_SUCCESS); - TESTASSERT(mac_sch_pdu_pack_error_test() == SRSLTE_SUCCESS); + TESTASSERT(mac_sch_pdu_pack_error_test() == SRSRAN_SUCCESS); - TESTASSERT(mac_mch_pdu_pack_test1() == SRSLTE_SUCCESS); + TESTASSERT(mac_mch_pdu_pack_test1() == SRSRAN_SUCCESS); - TESTASSERT(mac_sch_pdu_unpack_test1() == SRSLTE_SUCCESS); - TESTASSERT(mac_sch_pdu_unpack_test2() == SRSLTE_SUCCESS); - TESTASSERT(mac_sch_pdu_unpack_test3() == SRSLTE_SUCCESS); + TESTASSERT(mac_sch_pdu_unpack_test1() == SRSRAN_SUCCESS); + TESTASSERT(mac_sch_pdu_unpack_test2() == SRSRAN_SUCCESS); + TESTASSERT(mac_sch_pdu_unpack_test3() == SRSRAN_SUCCESS); - TESTASSERT(mac_slsch_pdu_unpack_test1() == SRSLTE_SUCCESS); + TESTASSERT(mac_slsch_pdu_unpack_test1() == SRSRAN_SUCCESS); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } diff --git a/lib/test/phy/CMakeLists.txt b/lib/test/phy/CMakeLists.txt index bd4872614..e280225cb 100644 --- a/lib/test/phy/CMakeLists.txt +++ b/lib/test/phy/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -12,7 +12,7 @@ set(CTEST_LABELS "lib;phy") add_executable(phy_dl_test phy_dl_test.c) -target_link_libraries(phy_dl_test srslte_phy srslte_common srslte_phy ${SEC_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) +target_link_libraries(phy_dl_test srsran_phy srsran_common srsran_phy ${SEC_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) # All valid number of PRBs for PUSCH set(ue_dl_min_mcs 0) @@ -47,9 +47,9 @@ foreach (cell_n_prb 6 15 25 50 75 100) endforeach (cell_n_prb) add_executable(pucch_ca_test pucch_ca_test.c) -target_link_libraries(pucch_ca_test srslte_phy srslte_common srslte_phy ${SEC_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) +target_link_libraries(pucch_ca_test srsran_phy srsran_common srsran_phy ${SEC_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) add_lte_test(pucch_ca_test pucch_ca_test) add_executable(phy_dl_nr_test phy_dl_nr_test.c) -target_link_libraries(phy_dl_nr_test srslte_phy srslte_common srslte_phy ${SEC_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) +target_link_libraries(phy_dl_nr_test srsran_phy srsran_common srsran_phy ${SEC_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) add_nr_test(phy_dl_nr_test phy_dl_nr_test -p 100 -m 28) \ No newline at end of file diff --git a/lib/test/phy/phy_dl_nr_test.c b/lib/test/phy/phy_dl_nr_test.c index f4e8cef58..10898dc08 100644 --- a/lib/test/phy/phy_dl_nr_test.c +++ b/lib/test/phy/phy_dl_nr_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,16 +10,16 @@ * */ -#include "srslte/phy/enb/enb_dl_nr.h" -#include "srslte/phy/phch/ra_dl_nr.h" -#include "srslte/phy/phch/ra_nr.h" -#include "srslte/phy/ue/ue_dl_nr.h" -#include "srslte/phy/utils/debug.h" -#include "srslte/phy/utils/random.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/enb/enb_dl_nr.h" +#include "srsran/phy/phch/ra_dl_nr.h" +#include "srsran/phy/phch/ra_nr.h" +#include "srsran/phy/ue/ue_dl_nr.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/random.h" +#include "srsran/phy/utils/vector.h" #include -static srslte_carrier_nr_t carrier = { +static srsran_carrier_nr_t carrier = { 0, // cell_id 0, // numerology 100, // nof_prb @@ -30,8 +30,8 @@ static srslte_carrier_nr_t carrier = { static uint32_t n_prb = 0; // Set to 0 for steering static uint32_t mcs = 30; // Set to 30 for steering -static srslte_sch_cfg_nr_t pdsch_cfg = {}; -static srslte_sch_grant_nr_t pdsch_grant = {}; +static srsran_sch_cfg_nr_t pdsch_cfg = {}; +static srsran_sch_grant_nr_t pdsch_grant = {}; static uint16_t rnti = 0x1234; static uint32_t nof_slots = 10; @@ -43,9 +43,9 @@ static void usage(char* prog) printf("\t-n Number of slots to simulate [Default %d]\n", nof_slots); printf("\t-m MCS PRB, set to >28 for steering [Default %d]\n", mcs); printf("\t-T Provide MCS table (64qam, 256qam, 64qamLowSE) [Default %s]\n", - srslte_mcs_table_to_str(pdsch_cfg.sch_cfg.mcs_table)); + srsran_mcs_table_to_str(pdsch_cfg.sch_cfg.mcs_table)); printf("\t-L Provide number of layers [Default %d]\n", carrier.max_mimo_layers); - printf("\t-v [set srslte_verbose to debug, default none]\n"); + printf("\t-v [set srsran_verbose to debug, default none]\n"); } static int parse_args(int argc, char** argv) @@ -66,109 +66,109 @@ static int parse_args(int argc, char** argv) mcs = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'T': - pdsch_cfg.sch_cfg.mcs_table = srslte_mcs_table_from_str(argv[optind]); + pdsch_cfg.sch_cfg.mcs_table = srsran_mcs_table_from_str(argv[optind]); break; case 'L': carrier.max_mimo_layers = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'v': - srslte_verbose++; + srsran_verbose++; break; default: usage(argv[0]); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -static int work_gnb_dl(srslte_enb_dl_nr_t* enb_dl, - srslte_slot_cfg_t* slot, - srslte_search_space_t* search_space, - srslte_dci_dl_nr_t* dci_dl, - srslte_dci_location_t* dci_location, +static int work_gnb_dl(srsran_enb_dl_nr_t* enb_dl, + srsran_slot_cfg_t* slot, + srsran_search_space_t* search_space, + srsran_dci_dl_nr_t* dci_dl, + srsran_dci_location_t* dci_location, uint8_t** data_tx) { - if (srslte_enb_dl_nr_base_zero(enb_dl) < SRSLTE_SUCCESS) { + if (srsran_enb_dl_nr_base_zero(enb_dl) < SRSRAN_SUCCESS) { ERROR("Error setting base to zero"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Hard-coded values - dci_dl->format = srslte_dci_format_nr_1_0; - dci_dl->rnti_type = srslte_rnti_type_c; + dci_dl->format = srsran_dci_format_nr_1_0; + dci_dl->rnti_type = srsran_rnti_type_c; dci_dl->location = *dci_location; dci_dl->search_space = search_space->type; dci_dl->rnti = rnti; // Put actual DCI - if (srslte_enb_dl_nr_pdcch_put(enb_dl, slot, dci_dl) < SRSLTE_SUCCESS) { + if (srsran_enb_dl_nr_pdcch_put(enb_dl, slot, dci_dl) < SRSRAN_SUCCESS) { ERROR("Error putting PDCCH"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Put PDSCH transmission pdsch_cfg.grant = pdsch_grant; - if (srslte_enb_dl_nr_pdsch_put(enb_dl, slot, &pdsch_cfg, data_tx) < SRSLTE_SUCCESS) { + if (srsran_enb_dl_nr_pdsch_put(enb_dl, slot, &pdsch_cfg, data_tx) < SRSRAN_SUCCESS) { ERROR("Error putting PDSCH"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - srslte_enb_dl_nr_gen_signal(enb_dl); + srsran_enb_dl_nr_gen_signal(enb_dl); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -static int work_ue_dl(srslte_ue_dl_nr_t* ue_dl, srslte_slot_cfg_t* slot, srslte_pdsch_res_nr_t* pdsch_res) +static int work_ue_dl(srsran_ue_dl_nr_t* ue_dl, srsran_slot_cfg_t* slot, srsran_pdsch_res_nr_t* pdsch_res) { - srslte_ue_dl_nr_estimate_fft(ue_dl, slot); + srsran_ue_dl_nr_estimate_fft(ue_dl, slot); - srslte_dci_dl_nr_t dci_dl_rx = {}; - int nof_found_dci = srslte_ue_dl_nr_find_dl_dci(ue_dl, slot, rnti, srslte_rnti_type_c, &dci_dl_rx, 1); - if (nof_found_dci < SRSLTE_SUCCESS) { + srsran_dci_dl_nr_t dci_dl_rx = {}; + int nof_found_dci = srsran_ue_dl_nr_find_dl_dci(ue_dl, slot, rnti, srsran_rnti_type_c, &dci_dl_rx, 1); + if (nof_found_dci < SRSRAN_SUCCESS) { ERROR("Error decoding"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (nof_found_dci < 1) { ERROR("Error DCI not found"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } pdsch_cfg.grant = pdsch_grant; - if (srslte_ue_dl_nr_decode_pdsch(ue_dl, slot, &pdsch_cfg, pdsch_res) < SRSLTE_SUCCESS) { + if (srsran_ue_dl_nr_decode_pdsch(ue_dl, slot, &pdsch_cfg, pdsch_res) < SRSRAN_SUCCESS) { ERROR("Error decoding"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int main(int argc, char** argv) { - int ret = SRSLTE_ERROR; - srslte_enb_dl_nr_t enb_dl = {}; - srslte_ue_dl_nr_t ue_dl = {}; - srslte_pdsch_res_nr_t pdsch_res[SRSLTE_MAX_TB] = {}; - srslte_random_t rand_gen = srslte_random_init(1234); - srslte_slot_cfg_t slot = {}; + int ret = SRSRAN_ERROR; + srsran_enb_dl_nr_t enb_dl = {}; + srsran_ue_dl_nr_t ue_dl = {}; + srsran_pdsch_res_nr_t pdsch_res[SRSRAN_MAX_TB] = {}; + srsran_random_t rand_gen = srsran_random_init(1234); + srsran_slot_cfg_t slot = {}; struct timeval t[3] = {}; uint64_t pdsch_encode_us = 0; uint64_t pdsch_decode_us = 0; uint64_t nof_bits = 0; - uint8_t* data_tx[SRSLTE_MAX_TB] = {}; - uint8_t* data_rx[SRSLTE_MAX_CODEWORDS] = {}; + uint8_t* data_tx[SRSRAN_MAX_TB] = {}; + uint8_t* data_rx[SRSRAN_MAX_CODEWORDS] = {}; cf_t* buffer = NULL; - buffer = srslte_vec_cf_malloc(SRSLTE_SF_LEN_PRB(carrier.nof_prb)); + buffer = srsran_vec_cf_malloc(SRSRAN_SF_LEN_PRB(carrier.nof_prb)); if (buffer == NULL) { ERROR("Error malloc"); goto clean_exit; } - srslte_ue_dl_nr_args_t ue_dl_args = {}; + srsran_ue_dl_nr_args_t ue_dl_args = {}; ue_dl_args.nof_rx_antennas = 1; ue_dl_args.pdsch.sch.disable_simd = false; ue_dl_args.pdsch.sch.decoder_use_flooded = false; @@ -177,69 +177,69 @@ int main(int argc, char** argv) ue_dl_args.pdcch.measure_evm = true; ue_dl_args.nof_max_prb = carrier.nof_prb; - srslte_enb_dl_nr_args_t enb_dl_args = {}; + srsran_enb_dl_nr_args_t enb_dl_args = {}; enb_dl_args.nof_tx_antennas = 1; enb_dl_args.pdsch.sch.disable_simd = false; enb_dl_args.pdcch.disable_simd = false; enb_dl_args.nof_max_prb = carrier.nof_prb; // Set default PDSCH configuration - pdsch_cfg.sch_cfg.mcs_table = srslte_mcs_table_64qam; - if (parse_args(argc, argv) < SRSLTE_SUCCESS) { + pdsch_cfg.sch_cfg.mcs_table = srsran_mcs_table_64qam; + if (parse_args(argc, argv) < SRSRAN_SUCCESS) { goto clean_exit; } - srslte_ue_dl_nr_pdcch_cfg_t pdcch_cfg = {}; + srsran_ue_dl_nr_pdcch_cfg_t pdcch_cfg = {}; // Configure CORESET - srslte_coreset_t* coreset = &pdcch_cfg.coreset[0]; + srsran_coreset_t* coreset = &pdcch_cfg.coreset[0]; pdcch_cfg.coreset_present[0] = true; coreset->duration = 2; - for (uint32_t i = 0; i < SRSLTE_CORESET_FREQ_DOMAIN_RES_SIZE; i++) { + for (uint32_t i = 0; i < SRSRAN_CORESET_FREQ_DOMAIN_RES_SIZE; i++) { coreset->freq_resources[i] = i < carrier.nof_prb / 6; } // Configure Search Space - srslte_search_space_t* search_space = &pdcch_cfg.search_space[0]; + srsran_search_space_t* search_space = &pdcch_cfg.search_space[0]; pdcch_cfg.search_space_present[0] = true; - search_space->type = srslte_search_space_type_ue; - for (uint32_t L = 0; L < SRSLTE_SEARCH_SPACE_NOF_AGGREGATION_LEVELS_NR; L++) { - search_space->nof_candidates[L] = srslte_pdcch_nr_max_candidates_coreset(coreset, L); + search_space->type = srsran_search_space_type_ue; + for (uint32_t L = 0; L < SRSRAN_SEARCH_SPACE_NOF_AGGREGATION_LEVELS_NR; L++) { + search_space->nof_candidates[L] = srsran_pdcch_nr_max_candidates_coreset(coreset, L); } - if (srslte_ue_dl_nr_init(&ue_dl, &buffer, &ue_dl_args)) { + if (srsran_ue_dl_nr_init(&ue_dl, &buffer, &ue_dl_args)) { ERROR("Error UE DL"); goto clean_exit; } - if (srslte_enb_dl_nr_init(&enb_dl, &buffer, &enb_dl_args)) { + if (srsran_enb_dl_nr_init(&enb_dl, &buffer, &enb_dl_args)) { ERROR("Error UE DL"); goto clean_exit; } - if (srslte_ue_dl_nr_set_carrier(&ue_dl, &carrier)) { + if (srsran_ue_dl_nr_set_carrier(&ue_dl, &carrier)) { ERROR("Error setting SCH NR carrier"); goto clean_exit; } - if (srslte_ue_dl_nr_set_pdcch_config(&ue_dl, &pdcch_cfg)) { + if (srsran_ue_dl_nr_set_pdcch_config(&ue_dl, &pdcch_cfg)) { ERROR("Error setting CORESET"); goto clean_exit; } - if (srslte_enb_dl_nr_set_carrier(&enb_dl, &carrier)) { + if (srsran_enb_dl_nr_set_carrier(&enb_dl, &carrier)) { ERROR("Error setting SCH NR carrier"); goto clean_exit; } - if (srslte_enb_dl_nr_set_coreset(&enb_dl, coreset)) { + if (srsran_enb_dl_nr_set_coreset(&enb_dl, coreset)) { ERROR("Error setting CORESET"); goto clean_exit; } for (uint32_t i = 0; i < 1; i++) { - data_tx[i] = srslte_vec_u8_malloc(SRSLTE_SLOT_MAX_NOF_BITS_NR); - data_rx[i] = srslte_vec_u8_malloc(SRSLTE_SLOT_MAX_NOF_BITS_NR); + data_tx[i] = srsran_vec_u8_malloc(SRSRAN_SLOT_MAX_NOF_BITS_NR); + data_rx[i] = srsran_vec_u8_malloc(SRSRAN_SLOT_MAX_NOF_BITS_NR); if (data_tx[i] == NULL || data_rx[i] == NULL) { ERROR("Error malloc"); goto clean_exit; @@ -248,89 +248,89 @@ int main(int argc, char** argv) pdsch_res[i].payload = data_rx[i]; } - srslte_softbuffer_tx_t softbuffer_tx = {}; - srslte_softbuffer_rx_t softbuffer_rx = {}; + srsran_softbuffer_tx_t softbuffer_tx = {}; + srsran_softbuffer_rx_t softbuffer_rx = {}; - if (srslte_softbuffer_tx_init_guru(&softbuffer_tx, SRSLTE_SCH_NR_MAX_NOF_CB_LDPC, SRSLTE_LDPC_MAX_LEN_ENCODED_CB) < - SRSLTE_SUCCESS) { + if (srsran_softbuffer_tx_init_guru(&softbuffer_tx, SRSRAN_SCH_NR_MAX_NOF_CB_LDPC, SRSRAN_LDPC_MAX_LEN_ENCODED_CB) < + SRSRAN_SUCCESS) { ERROR("Error init soft-buffer"); goto clean_exit; } - if (srslte_softbuffer_rx_init_guru(&softbuffer_rx, SRSLTE_SCH_NR_MAX_NOF_CB_LDPC, SRSLTE_LDPC_MAX_LEN_ENCODED_CB) < - SRSLTE_SUCCESS) { + if (srsran_softbuffer_rx_init_guru(&softbuffer_rx, SRSRAN_SCH_NR_MAX_NOF_CB_LDPC, SRSRAN_LDPC_MAX_LEN_ENCODED_CB) < + SRSRAN_SUCCESS) { ERROR("Error init soft-buffer"); goto clean_exit; } // Use grant default A time resources with m=0 - if (srslte_ra_dl_nr_time_default_A(0, pdsch_cfg.dmrs.typeA_pos, &pdsch_grant) < SRSLTE_SUCCESS) { + if (srsran_ra_dl_nr_time_default_A(0, pdsch_cfg.dmrs.typeA_pos, &pdsch_grant) < SRSRAN_SUCCESS) { ERROR("Error loading default grant"); goto clean_exit; } pdsch_grant.nof_layers = carrier.max_mimo_layers; - pdsch_grant.dci_format = srslte_dci_format_nr_1_0; + pdsch_grant.dci_format = srsran_dci_format_nr_1_0; pdsch_grant.nof_dmrs_cdm_groups_without_data = 1; uint32_t n_prb_start = 1; uint32_t n_prb_end = carrier.nof_prb + 1; if (n_prb > 0) { - n_prb_start = SRSLTE_MIN(n_prb, n_prb_end - 1); - n_prb_end = SRSLTE_MIN(n_prb + 1, n_prb_end); + n_prb_start = SRSRAN_MIN(n_prb, n_prb_end - 1); + n_prb_end = SRSRAN_MIN(n_prb + 1, n_prb_end); } uint32_t mcs_start = 0; - uint32_t mcs_end = pdsch_cfg.sch_cfg.mcs_table == srslte_mcs_table_256qam ? 28 : 29; + uint32_t mcs_end = pdsch_cfg.sch_cfg.mcs_table == srsran_mcs_table_256qam ? 28 : 29; if (mcs < mcs_end) { - mcs_start = SRSLTE_MIN(mcs, mcs_end - 1); - mcs_end = SRSLTE_MIN(mcs + 1, mcs_end); + mcs_start = SRSRAN_MIN(mcs, mcs_end - 1); + mcs_end = SRSRAN_MIN(mcs + 1, mcs_end); } uint64_t slot_count = 0; for (slot.idx = 0; slot.idx < nof_slots; slot.idx++) { for (n_prb = n_prb_start; n_prb < n_prb_end; n_prb++) { for (mcs = mcs_start; mcs < mcs_end; mcs++, slot_count++) { - for (uint32_t n = 0; n < SRSLTE_MAX_PRB_NR; n++) { + for (uint32_t n = 0; n < SRSRAN_MAX_PRB_NR; n++) { pdsch_grant.prb_idx[n] = (n < n_prb); } - if (srslte_ra_nr_fill_tb(&pdsch_cfg, &pdsch_grant, mcs, &pdsch_grant.tb[0]) < SRSLTE_SUCCESS) { + if (srsran_ra_nr_fill_tb(&pdsch_cfg, &pdsch_grant, mcs, &pdsch_grant.tb[0]) < SRSRAN_SUCCESS) { ERROR("Error filing tb"); goto clean_exit; } - for (uint32_t tb = 0; tb < SRSLTE_MAX_TB; tb++) { + for (uint32_t tb = 0; tb < SRSRAN_MAX_TB; tb++) { // Skip TB if no allocated if (data_tx[tb] == NULL) { continue; } for (uint32_t i = 0; i < pdsch_grant.tb[tb].tbs; i++) { - data_tx[tb][i] = (uint8_t)srslte_random_uniform_int_dist(rand_gen, 0, UINT8_MAX); + data_tx[tb][i] = (uint8_t)srsran_random_uniform_int_dist(rand_gen, 0, UINT8_MAX); } pdsch_grant.tb[tb].softbuffer.tx = &softbuffer_tx; } // Compute PDCCH candidate locations uint32_t L = 0; - uint32_t ncce_candidates[SRSLTE_SEARCH_SPACE_MAX_NOF_CANDIDATES_NR] = {}; + uint32_t ncce_candidates[SRSRAN_SEARCH_SPACE_MAX_NOF_CANDIDATES_NR] = {}; int nof_candidates = - srslte_pdcch_nr_locations_coreset(coreset, search_space, rnti, L, slot.idx, ncce_candidates); - if (nof_candidates < SRSLTE_SUCCESS) { + srsran_pdcch_nr_locations_coreset(coreset, search_space, rnti, L, slot.idx, ncce_candidates); + if (nof_candidates < SRSRAN_SUCCESS) { ERROR("Error getting PDCCH candidates"); goto clean_exit; } // Setup DCI location - srslte_dci_location_t dci_location = {}; + srsran_dci_location_t dci_location = {}; dci_location.ncce = ncce_candidates[0]; dci_location.L = L; // Setup DCI - srslte_dci_dl_nr_t dci_dl = {}; + srsran_dci_dl_nr_t dci_dl = {}; gettimeofday(&t[1], NULL); - if (work_gnb_dl(&enb_dl, &slot, search_space, &dci_dl, &dci_location, data_tx) < SRSLTE_ERROR) { + if (work_gnb_dl(&enb_dl, &slot, search_space, &dci_dl, &dci_location, data_tx) < SRSRAN_ERROR) { ERROR("Error running eNb DL"); goto clean_exit; } @@ -338,13 +338,13 @@ int main(int argc, char** argv) get_time_interval(t); pdsch_encode_us += (size_t)(t[0].tv_sec * 1e6 + t[0].tv_usec); - for (uint32_t tb = 0; tb < SRSLTE_MAX_TB; tb++) { + for (uint32_t tb = 0; tb < SRSRAN_MAX_TB; tb++) { pdsch_grant.tb[tb].softbuffer.rx = &softbuffer_rx; - srslte_softbuffer_rx_reset(pdsch_grant.tb[tb].softbuffer.rx); + srsran_softbuffer_rx_reset(pdsch_grant.tb[tb].softbuffer.rx); } gettimeofday(&t[1], NULL); - if (work_ue_dl(&ue_dl, &slot, pdsch_res) < SRSLTE_SUCCESS) { + if (work_ue_dl(&ue_dl, &slot, pdsch_res) < SRSRAN_SUCCESS) { ERROR("Error running UE DL"); goto clean_exit; } @@ -365,9 +365,9 @@ int main(int argc, char** argv) if (memcmp(data_tx[0], data_rx[0], pdsch_grant.tb[0].tbs / 8) != 0) { ERROR("Failed to match Tx/Rx data; n_prb=%d; mcs=%d; TBS=%d;", n_prb, mcs, pdsch_grant.tb[0].tbs); printf("Tx data: "); - srslte_vec_fprint_byte(stdout, data_tx[0], pdsch_grant.tb[0].tbs / 8); + srsran_vec_fprint_byte(stdout, data_tx[0], pdsch_grant.tb[0].tbs / 8); printf("Rx data: "); - srslte_vec_fprint_byte(stdout, data_rx[0], pdsch_grant.tb[0].tbs / 8); + srsran_vec_fprint_byte(stdout, data_rx[0], pdsch_grant.tb[0].tbs / 8); goto clean_exit; } @@ -387,13 +387,13 @@ int main(int argc, char** argv) (double)nof_bits / (double)slot_count / 1000.0f, (double)nof_bits / pdsch_decode_us); - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; clean_exit: - srslte_random_free(rand_gen); - srslte_enb_dl_nr_free(&enb_dl); - srslte_ue_dl_nr_free(&ue_dl); - for (uint32_t i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { + srsran_random_free(rand_gen); + srsran_enb_dl_nr_free(&enb_dl); + srsran_ue_dl_nr_free(&ue_dl); + for (uint32_t i = 0; i < SRSRAN_MAX_CODEWORDS; i++) { if (data_tx[i]) { free(data_tx[i]); } @@ -404,8 +404,8 @@ clean_exit: if (buffer) { free(buffer); } - srslte_softbuffer_tx_free(&softbuffer_tx); - srslte_softbuffer_rx_free(&softbuffer_rx); + srsran_softbuffer_tx_free(&softbuffer_tx); + srsran_softbuffer_rx_free(&softbuffer_rx); return ret; } diff --git a/lib/test/phy/phy_dl_test.c b/lib/test/phy/phy_dl_test.c index d2e9b2ee8..3c8f7e6ee 100644 --- a/lib/test/phy/phy_dl_test.c +++ b/lib/test/phy/phy_dl_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,21 +10,21 @@ * */ -#include +#include #include #include #include -#include "srslte/srslte.h" +#include "srsran/srsran.h" #define MAX_DATABUFFER_SIZE (6144 * 16 * 3 / 8) -srslte_cell_t cell = {.nof_prb = 100, +srsran_cell_t cell = {.nof_prb = 100, .nof_ports = 1, .id = 1, - .cp = SRSLTE_CP_NORM, - .phich_resources = SRSLTE_PHICH_R_1, - .phich_length = SRSLTE_PHICH_NORM}; + .cp = SRSRAN_CP_NORM, + .phich_resources = SRSRAN_PHICH_R_1, + .phich_length = SRSRAN_PHICH_NORM}; static uint32_t transmission_mode = 1; static uint32_t cfi = 1; @@ -52,17 +52,17 @@ void usage(char* prog) } else { printf("\t\t-a carrier-indicator [Default none]\n"); } - printf("\t-v [set srslte_verbose to debug, default none]\n"); + printf("\t-v [set srsran_verbose to debug, default none]\n"); printf("\t-q Enable/Disable 256QAM modulation (default %s)\n", enable_256qam ? "enabled" : "disabled"); } void parse_extensive_param(char* param, char* arg) { - int ext_code = SRSLTE_SUCCESS; + int ext_code = SRSRAN_SUCCESS; if (!strcmp(param, "carrier-indicator")) { cross_carrier_indicator = (uint32_t)strtol(arg, NULL, 10); } else { - ext_code = SRSLTE_ERROR; + ext_code = SRSRAN_ERROR; } if (ext_code) { @@ -119,7 +119,7 @@ void parse_args(int argc, char** argv) optind++; break; case 'v': - srslte_verbose++; + srsran_verbose++; break; case 'q': enable_256qam = (enable_256qam) ? false : true; @@ -131,127 +131,127 @@ void parse_args(int argc, char** argv) } } -int work_enb(srslte_enb_dl_t* enb_dl, - srslte_dl_sf_cfg_t* dl_sf, - srslte_dci_cfg_t* dci_cfg, - srslte_dci_dl_t* dci, - srslte_softbuffer_tx_t** softbuffer_tx, +int work_enb(srsran_enb_dl_t* enb_dl, + srsran_dl_sf_cfg_t* dl_sf, + srsran_dci_cfg_t* dci_cfg, + srsran_dci_dl_t* dci, + srsran_softbuffer_tx_t** softbuffer_tx, uint8_t** data_tx) { - int ret = SRSLTE_ERROR; + int ret = SRSRAN_ERROR; - srslte_enb_dl_put_base(enb_dl, dl_sf); - if (srslte_enb_dl_put_pdcch_dl(enb_dl, dci_cfg, dci)) { + srsran_enb_dl_put_base(enb_dl, dl_sf); + if (srsran_enb_dl_put_pdcch_dl(enb_dl, dci_cfg, dci)) { ERROR("Error putting PDCCH sf_idx=%d", dl_sf->tti); goto quit; } // Create pdsch config - srslte_pdsch_cfg_t pdsch_cfg; - if (srslte_ra_dl_dci_to_grant(&cell, dl_sf, transmission_mode, enable_256qam, dci, &pdsch_cfg.grant)) { + srsran_pdsch_cfg_t pdsch_cfg; + if (srsran_ra_dl_dci_to_grant(&cell, dl_sf, transmission_mode, enable_256qam, dci, &pdsch_cfg.grant)) { ERROR("Computing DL grant sf_idx=%d", dl_sf->tti); goto quit; } char str[512]; - srslte_dci_dl_info(dci, str, 512); + srsran_dci_dl_info(dci, str, 512); INFO("eNb PDCCH: rnti=0x%x, %s", rnti, str); - for (uint32_t i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { + for (uint32_t i = 0; i < SRSRAN_MAX_CODEWORDS; i++) { pdsch_cfg.softbuffers.tx[i] = softbuffer_tx[i]; } // Enable power allocation pdsch_cfg.power_scale = true; pdsch_cfg.p_a = 0.0f; // 0 dB - pdsch_cfg.p_b = (transmission_mode > SRSLTE_TM1) ? 1 : 0; // 0 dB + pdsch_cfg.p_b = (transmission_mode > SRSRAN_TM1) ? 1 : 0; // 0 dB pdsch_cfg.rnti = rnti; pdsch_cfg.meas_time_en = false; - if (srslte_enb_dl_put_pdsch(enb_dl, &pdsch_cfg, data_tx) < 0) { + if (srsran_enb_dl_put_pdsch(enb_dl, &pdsch_cfg, data_tx) < 0) { ERROR("Error putting PDSCH sf_idx=%d", dl_sf->tti); goto quit; } - srslte_pdsch_tx_info(&pdsch_cfg, str, 512); + srsran_pdsch_tx_info(&pdsch_cfg, str, 512); INFO("eNb PDSCH: rnti=0x%x, %s", rnti, str); - srslte_enb_dl_gen_signal(enb_dl); + srsran_enb_dl_gen_signal(enb_dl); - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; quit: return ret; } -int work_ue(srslte_ue_dl_t* ue_dl, - srslte_dl_sf_cfg_t* sf_cfg_dl, - srslte_ue_dl_cfg_t* ue_dl_cfg, - srslte_dci_dl_t* dci_dl, +int work_ue(srsran_ue_dl_t* ue_dl, + srsran_dl_sf_cfg_t* sf_cfg_dl, + srsran_ue_dl_cfg_t* ue_dl_cfg, + srsran_dci_dl_t* dci_dl, uint32_t sf_idx, - srslte_pdsch_res_t pdsch_res[SRSLTE_MAX_CODEWORDS]) + srsran_pdsch_res_t pdsch_res[SRSRAN_MAX_CODEWORDS]) { - if (srslte_ue_dl_decode_fft_estimate(ue_dl, sf_cfg_dl, ue_dl_cfg) < 0) { + if (srsran_ue_dl_decode_fft_estimate(ue_dl, sf_cfg_dl, ue_dl_cfg) < 0) { ERROR("Getting PDCCH FFT estimate sf_idx=%d", sf_idx); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - int nof_grants = srslte_ue_dl_find_dl_dci(ue_dl, sf_cfg_dl, ue_dl_cfg, rnti, dci_dl); + int nof_grants = srsran_ue_dl_find_dl_dci(ue_dl, sf_cfg_dl, ue_dl_cfg, rnti, dci_dl); if (nof_grants < 0) { ERROR("Looking for DL grants sf_idx=%d", sf_idx); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } else if (nof_grants == 0) { ERROR("Failed to find DCI in sf_idx=%d", sf_idx); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Enable power allocation ue_dl_cfg->cfg.pdsch.power_scale = true; ue_dl_cfg->cfg.pdsch.p_a = 0.0f; // 0 dB - ue_dl_cfg->cfg.pdsch.p_b = (transmission_mode > SRSLTE_TM1) ? 1 : 0; // 0 dB + ue_dl_cfg->cfg.pdsch.p_b = (transmission_mode > SRSRAN_TM1) ? 1 : 0; // 0 dB ue_dl_cfg->cfg.pdsch.rnti = dci_dl->rnti; ue_dl_cfg->cfg.pdsch.csi_enable = false; ue_dl_cfg->cfg.pdsch.meas_evm_en = false; - if (srslte_verbose >= SRSLTE_VERBOSE_INFO) { + if (srsran_verbose >= SRSRAN_VERBOSE_INFO) { char str[512]; - srslte_dci_dl_info(&dci_dl[0], str, 512); + srsran_dci_dl_info(&dci_dl[0], str, 512); INFO("UE PDCCH: rnti=0x%x, %s", rnti, str); } - if (srslte_ra_dl_dci_to_grant( + if (srsran_ra_dl_dci_to_grant( &cell, sf_cfg_dl, transmission_mode, enable_256qam, &dci_dl[0], &ue_dl_cfg->cfg.pdsch.grant)) { ERROR("Computing DL grant sf_idx=%d", sf_idx); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Reset softbuffer - for (int i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { + for (int i = 0; i < SRSRAN_MAX_CODEWORDS; i++) { if (ue_dl_cfg->cfg.pdsch.grant.tb[i].enabled) { - srslte_softbuffer_rx_reset(ue_dl_cfg->cfg.pdsch.softbuffers.rx[i]); + srsran_softbuffer_rx_reset(ue_dl_cfg->cfg.pdsch.softbuffers.rx[i]); } } - if (srslte_ue_dl_decode_pdsch(ue_dl, sf_cfg_dl, &ue_dl_cfg->cfg.pdsch, pdsch_res)) { + if (srsran_ue_dl_decode_pdsch(ue_dl, sf_cfg_dl, &ue_dl_cfg->cfg.pdsch, pdsch_res)) { ERROR("ERROR: Decoding PDSCH sf_idx=%d", sf_idx); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - if (srslte_verbose >= SRSLTE_VERBOSE_INFO) { + if (srsran_verbose >= SRSRAN_VERBOSE_INFO) { char str[512]; - srslte_pdsch_rx_info(&ue_dl_cfg->cfg.pdsch, pdsch_res, str, 512); + srsran_pdsch_rx_info(&ue_dl_cfg->cfg.pdsch, pdsch_res, str, 512); INFO("eNb PDSCH: rnti=0x%x, %s", rnti, str); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } static int -check_softbits(srslte_enb_dl_t* enb_dl, srslte_ue_dl_t* ue_dl, srslte_ue_dl_cfg_t* ue_dl_cfg, uint32_t sf_idx, int tb) +check_softbits(srsran_enb_dl_t* enb_dl, srsran_ue_dl_t* ue_dl, srsran_ue_dl_cfg_t* ue_dl_cfg, uint32_t sf_idx, int tb) { - int ret = SRSLTE_SUCCESS; + int ret = SRSRAN_SUCCESS; // Scramble if (ue_dl->pdsch.llr_is_8bit) { - srslte_sequence_pdsch_apply_c(ue_dl->pdsch.e[tb], + srsran_sequence_pdsch_apply_c(ue_dl->pdsch.e[tb], ue_dl->pdsch.e[tb], rnti, ue_dl_cfg->cfg.pdsch.grant.tb[tb].cw_idx, @@ -259,7 +259,7 @@ check_softbits(srslte_enb_dl_t* enb_dl, srslte_ue_dl_t* ue_dl, srslte_ue_dl_cfg_ cell.id, ue_dl_cfg->cfg.pdsch.grant.tb[tb].nof_bits); } else { - srslte_sequence_pdsch_apply_s(ue_dl->pdsch.e[tb], + srsran_sequence_pdsch_apply_s(ue_dl->pdsch.e[tb], ue_dl->pdsch.e[tb], rnti, ue_dl_cfg->cfg.pdsch.grant.tb[tb].cw_idx, @@ -277,22 +277,22 @@ check_softbits(srslte_enb_dl_t* enb_dl, srslte_ue_dl_t* ue_dl, srslte_ue_dl_cfg_ rx_bytes[i] = w; } if (memcmp(ue_dl->pdsch.e[tb], enb_dl->pdsch.e[tb], ue_dl_cfg->cfg.pdsch.grant.tb[tb].nof_bits / 8) != 0) { - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } return ret; } -static int check_evm(srslte_enb_dl_t* enb_dl, srslte_ue_dl_t* ue_dl, srslte_ue_dl_cfg_t* ue_dl_cfg, int tb) +static int check_evm(srsran_enb_dl_t* enb_dl, srsran_ue_dl_t* ue_dl, srsran_ue_dl_cfg_t* ue_dl_cfg, int tb) { - int ret = SRSLTE_SUCCESS; - srslte_vec_sub_ccc(enb_dl->pdsch.d[tb], ue_dl->pdsch.d[tb], enb_dl->pdsch.d[tb], ue_dl_cfg->cfg.pdsch.grant.nof_re); - uint32_t evm_max_i = srslte_vec_max_abs_ci(enb_dl->pdsch.d[tb], ue_dl_cfg->cfg.pdsch.grant.nof_re); + int ret = SRSRAN_SUCCESS; + srsran_vec_sub_ccc(enb_dl->pdsch.d[tb], ue_dl->pdsch.d[tb], enb_dl->pdsch.d[tb], ue_dl_cfg->cfg.pdsch.grant.nof_re); + uint32_t evm_max_i = srsran_vec_max_abs_ci(enb_dl->pdsch.d[tb], ue_dl_cfg->cfg.pdsch.grant.nof_re); float evm = cabsf(enb_dl->pdsch.d[tb][evm_max_i]); if (evm > 0.1f) { printf("TB%d Constellation EVM (%.3f) is too high\n", tb, evm); - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } return ret; @@ -300,15 +300,15 @@ static int check_evm(srslte_enb_dl_t* enb_dl, srslte_ue_dl_t* ue_dl, srslte_ue_d int main(int argc, char** argv) { - srslte_enb_dl_t* enb_dl = srslte_vec_malloc(sizeof(srslte_enb_dl_t)); - srslte_ue_dl_t* ue_dl = srslte_vec_malloc(sizeof(srslte_ue_dl_t)); - srslte_random_t random = srslte_random_init(0); + srsran_enb_dl_t* enb_dl = srsran_vec_malloc(sizeof(srsran_enb_dl_t)); + srsran_ue_dl_t* ue_dl = srsran_vec_malloc(sizeof(srsran_ue_dl_t)); + srsran_random_t random = srsran_random_init(0); struct timeval t[3] = {}; size_t tx_nof_bits = 0, rx_nof_bits = 0; - srslte_softbuffer_tx_t* softbuffer_tx[SRSLTE_MAX_TB] = {}; - srslte_softbuffer_rx_t* softbuffer_rx[SRSLTE_MAX_TB] = {}; - uint8_t* data_tx[SRSLTE_MAX_TB] = {}; - uint8_t* data_rx[SRSLTE_MAX_TB] = {}; + srsran_softbuffer_tx_t* softbuffer_tx[SRSRAN_MAX_TB] = {}; + srsran_softbuffer_rx_t* softbuffer_rx[SRSRAN_MAX_TB] = {}; + uint8_t* data_tx[SRSRAN_MAX_TB] = {}; + uint8_t* data_rx[SRSRAN_MAX_TB] = {}; uint32_t count_failures = 0, count_tbs = 0; size_t pdsch_decode_us = 0; size_t pdsch_encode_us = 0; @@ -317,49 +317,49 @@ int main(int argc, char** argv) parse_args(argc, argv); - cf_t* signal_buffer[SRSLTE_MAX_PORTS] = {NULL}; + cf_t* signal_buffer[SRSRAN_MAX_PORTS] = {NULL}; /* * Allocate Memory */ for (int i = 0; i < cell.nof_ports; i++) { - signal_buffer[i] = srslte_vec_cf_malloc(SRSLTE_SF_LEN_PRB(cell.nof_prb)); + signal_buffer[i] = srsran_vec_cf_malloc(SRSRAN_SF_LEN_PRB(cell.nof_prb)); if (!signal_buffer[i]) { ERROR("Error allocating buffer"); goto quit; } } - for (int i = 0; i < SRSLTE_MAX_TB; i++) { - softbuffer_tx[i] = (srslte_softbuffer_tx_t*)calloc(sizeof(srslte_softbuffer_tx_t), 1); + for (int i = 0; i < SRSRAN_MAX_TB; i++) { + softbuffer_tx[i] = (srsran_softbuffer_tx_t*)calloc(sizeof(srsran_softbuffer_tx_t), 1); if (!softbuffer_tx[i]) { ERROR("Error allocating softbuffer_tx"); goto quit; } - if (srslte_softbuffer_tx_init(softbuffer_tx[i], cell.nof_prb)) { + if (srsran_softbuffer_tx_init(softbuffer_tx[i], cell.nof_prb)) { ERROR("Error initiating softbuffer_tx"); goto quit; } - softbuffer_rx[i] = (srslte_softbuffer_rx_t*)calloc(sizeof(srslte_softbuffer_rx_t), 1); + softbuffer_rx[i] = (srsran_softbuffer_rx_t*)calloc(sizeof(srsran_softbuffer_rx_t), 1); if (!softbuffer_rx[i]) { ERROR("Error allocating softbuffer_rx"); goto quit; } - if (srslte_softbuffer_rx_init(softbuffer_rx[i], cell.nof_prb)) { + if (srsran_softbuffer_rx_init(softbuffer_rx[i], cell.nof_prb)) { ERROR("Error initiating softbuffer_rx"); goto quit; } - data_tx[i] = srslte_vec_u8_malloc(MAX_DATABUFFER_SIZE); + data_tx[i] = srsran_vec_u8_malloc(MAX_DATABUFFER_SIZE); if (!data_tx[i]) { ERROR("Error allocating data tx"); goto quit; } - data_rx[i] = srslte_vec_u8_malloc(MAX_DATABUFFER_SIZE); + data_rx[i] = srsran_vec_u8_malloc(MAX_DATABUFFER_SIZE); if (!data_rx[i]) { ERROR("Error allocating data tx"); goto quit; @@ -369,12 +369,12 @@ int main(int argc, char** argv) /* * Initialise eNb */ - if (srslte_enb_dl_init(enb_dl, signal_buffer, cell.nof_prb)) { + if (srsran_enb_dl_init(enb_dl, signal_buffer, cell.nof_prb)) { ERROR("Error initiating eNb downlink"); goto quit; } - if (srslte_enb_dl_set_cell(enb_dl, cell)) { + if (srsran_enb_dl_set_cell(enb_dl, cell)) { ERROR("Error setting eNb DL cell"); goto quit; } @@ -382,12 +382,12 @@ int main(int argc, char** argv) /* * Initialise UE */ - if (srslte_ue_dl_init(ue_dl, signal_buffer, cell.nof_prb, nof_rx_ant)) { + if (srsran_ue_dl_init(ue_dl, signal_buffer, cell.nof_prb, nof_rx_ant)) { ERROR("Error initiating UE downlink"); goto quit; } - if (srslte_ue_dl_set_cell(ue_dl, cell)) { + if (srsran_ue_dl_set_cell(ue_dl, cell)) { ERROR("Error setting UE downlink cell"); goto quit; } @@ -395,18 +395,18 @@ int main(int argc, char** argv) /* * Create PDCCH Allocations */ - uint32_t nof_locations[SRSLTE_NOF_SF_X_FRAME]; - srslte_dci_location_t dci_locations[SRSLTE_NOF_SF_X_FRAME][SRSLTE_MAX_CANDIDATES_UE]; + uint32_t nof_locations[SRSRAN_NOF_SF_X_FRAME]; + srsran_dci_location_t dci_locations[SRSRAN_NOF_SF_X_FRAME][SRSRAN_MAX_CANDIDATES_UE]; uint32_t location_counter = 0; - for (uint32_t i = 0; i < SRSLTE_NOF_SF_X_FRAME; i++) { - srslte_dl_sf_cfg_t sf_cfg_dl; + for (uint32_t i = 0; i < SRSRAN_NOF_SF_X_FRAME; i++) { + srsran_dl_sf_cfg_t sf_cfg_dl; ZERO_OBJECT(sf_cfg_dl); sf_cfg_dl.tti = i; sf_cfg_dl.cfi = cfi; - sf_cfg_dl.sf_type = SRSLTE_SF_NORM; + sf_cfg_dl.sf_type = SRSRAN_SF_NORM; nof_locations[i] = - srslte_pdcch_ue_locations(&enb_dl->pdcch, &sf_cfg_dl, dci_locations[i], SRSLTE_MAX_CANDIDATES_UE, rnti); + srsran_pdcch_ue_locations(&enb_dl->pdcch, &sf_cfg_dl, dci_locations[i], SRSRAN_MAX_CANDIDATES_UE, rnti); location_counter += nof_locations[i]; } @@ -417,8 +417,8 @@ int main(int argc, char** argv) /* * DCI Configuration */ - srslte_dci_dl_t dci = {}; - srslte_dci_cfg_t dci_cfg = {}; + srsran_dci_dl_t dci = {}; + srsran_dci_cfg_t dci_cfg = {}; dci_cfg.srs_request_enabled = false; dci_cfg.ra_format_enabled = false; dci_cfg.multiple_csi_request_enabled = false; @@ -451,36 +451,36 @@ int main(int argc, char** argv) // Set PRB Allocation type #if 0 - dci.alloc_type = SRSLTE_RA_ALLOC_TYPE2; + dci.alloc_type = SRSRAN_RA_ALLOC_TYPE2; uint32_t n_prb = 1; ///< Number of PRB uint32_t s_prb = 0; ///< Start - dci.type2_alloc.riv = srslte_ra_type2_to_riv(n_prb, s_prb, cell.nof_prb); + dci.type2_alloc.riv = srsran_ra_type2_to_riv(n_prb, s_prb, cell.nof_prb); #else - dci.alloc_type = SRSLTE_RA_ALLOC_TYPE0; + dci.alloc_type = SRSRAN_RA_ALLOC_TYPE0; dci.type0_alloc.rbg_bitmask = 0xffffffff; // All PRB #endif // Set TB - if (transmission_mode < SRSLTE_TM3) { - dci.format = (dci.alloc_type == SRSLTE_RA_ALLOC_TYPE2) ? SRSLTE_DCI_FORMAT1A : SRSLTE_DCI_FORMAT1; + if (transmission_mode < SRSRAN_TM3) { + dci.format = (dci.alloc_type == SRSRAN_RA_ALLOC_TYPE2) ? SRSRAN_DCI_FORMAT1A : SRSRAN_DCI_FORMAT1; dci.tb[0].mcs_idx = mcs; dci.tb[0].rv = 0; dci.tb[0].ndi = 0; dci.tb[0].cw_idx = 0; dci.tb[1].mcs_idx = 0; dci.tb[1].rv = 1; - } else if (transmission_mode == SRSLTE_TM3) { - dci.format = SRSLTE_DCI_FORMAT2A; - for (uint32_t i = 0; i < SRSLTE_MAX_TB; i++) { + } else if (transmission_mode == SRSRAN_TM3) { + dci.format = SRSRAN_DCI_FORMAT2A; + for (uint32_t i = 0; i < SRSRAN_MAX_TB; i++) { dci.tb[i].mcs_idx = mcs; dci.tb[i].rv = 0; dci.tb[i].ndi = 0; dci.tb[i].cw_idx = i; } - } else if (transmission_mode == SRSLTE_TM4) { - dci.format = SRSLTE_DCI_FORMAT2; + } else if (transmission_mode == SRSRAN_TM4) { + dci.format = SRSRAN_DCI_FORMAT2; dci.pinfo = 0; - for (uint32_t i = 0; i < SRSLTE_MAX_TB; i++) { + for (uint32_t i = 0; i < SRSRAN_MAX_TB; i++) { dci.tb[i].mcs_idx = mcs; dci.tb[i].rv = 0; dci.tb[i].ndi = 0; @@ -496,29 +496,29 @@ int main(int argc, char** argv) INFO("--- Starting test ---"); for (uint32_t sf_idx = 0; sf_idx < nof_subframes; sf_idx++) { /* Generate random data */ - for (int j = 0; j < SRSLTE_MAX_TB; j++) { + for (int j = 0; j < SRSRAN_MAX_TB; j++) { for (int i = 0; i < MAX_DATABUFFER_SIZE; i++) { - data_tx[j][i] = (uint8_t)srslte_random_uniform_int_dist(random, 0, 255); + data_tx[j][i] = (uint8_t)srsran_random_uniform_int_dist(random, 0, 255); } } /* * Run eNodeB */ - srslte_dl_sf_cfg_t sf_cfg_dl = {}; + srsran_dl_sf_cfg_t sf_cfg_dl = {}; sf_cfg_dl.tti = sf_idx % 10; sf_cfg_dl.cfi = cfi; - sf_cfg_dl.sf_type = SRSLTE_SF_NORM; + sf_cfg_dl.sf_type = SRSRAN_SF_NORM; // Set DCI Location dci.location = dci_locations[sf_idx % 10][(sf_idx / 10) % nof_locations[sf_idx % 10]]; if (cell.nof_prb == 6) { - for (int i = 0; i < SRSLTE_MAX_TB; i++) { + for (int i = 0; i < SRSRAN_MAX_TB; i++) { dci.tb[i].mcs_idx = (sf_idx % 5 == 0) ? 0 : mcs; } } else if (cell.nof_prb == 15) { - for (int i = 0; i < SRSLTE_MAX_TB; i++) { - dci.tb[i].mcs_idx = (sf_idx % 5 == 0) ? SRSLTE_MIN(mcs, 27) : mcs; + for (int i = 0; i < SRSRAN_MAX_TB; i++) { + dci.tb[i].mcs_idx = (sf_idx % 5 == 0) ? SRSRAN_MIN(mcs, 27) : mcs; } } INFO("--- Process eNb ---"); @@ -533,7 +533,7 @@ int main(int argc, char** argv) // MIMO perfect crossed channel if (transmission_mode > 1) { - for (int i = 0; i < SRSLTE_SF_LEN_PRB(cell.nof_prb); i++) { + for (int i = 0; i < SRSRAN_SF_LEN_PRB(cell.nof_prb); i++) { cf_t x0 = signal_buffer[0][i]; cf_t x1 = signal_buffer[1][i]; @@ -551,30 +551,30 @@ int main(int argc, char** argv) INFO("--- Process UE ---"); gettimeofday(&t[1], NULL); - srslte_ue_dl_cfg_t ue_dl_cfg = {}; - srslte_dci_dl_t dci_dl[SRSLTE_MAX_DCI_MSG] = {}; + srsran_ue_dl_cfg_t ue_dl_cfg = {}; + srsran_dci_dl_t dci_dl[SRSRAN_MAX_DCI_MSG] = {}; ue_dl_cfg.cfg.tm = transmission_mode; ue_dl_cfg.cfg.pdsch.p_a = 0.0; ue_dl_cfg.cfg.pdsch.power_scale = false; - ue_dl_cfg.cfg.pdsch.decoder_type = SRSLTE_MIMO_DECODER_MMSE; + ue_dl_cfg.cfg.pdsch.decoder_type = SRSRAN_MIMO_DECODER_MMSE; ue_dl_cfg.cfg.pdsch.max_nof_iterations = 10; ue_dl_cfg.cfg.pdsch.meas_time_en = false; ue_dl_cfg.chest_cfg.filter_coef[0] = 4; ue_dl_cfg.chest_cfg.filter_coef[1] = 1; - ue_dl_cfg.chest_cfg.filter_type = SRSLTE_CHEST_FILTER_GAUSS; - ue_dl_cfg.chest_cfg.noise_alg = SRSLTE_NOISE_ALG_REFS; + ue_dl_cfg.chest_cfg.filter_type = SRSRAN_CHEST_FILTER_GAUSS; + ue_dl_cfg.chest_cfg.noise_alg = SRSRAN_NOISE_ALG_REFS; ue_dl_cfg.chest_cfg.rsrp_neighbour = false; - ue_dl_cfg.chest_cfg.estimator_alg = SRSLTE_ESTIMATOR_ALG_AVERAGE; + ue_dl_cfg.chest_cfg.estimator_alg = SRSRAN_ESTIMATOR_ALG_AVERAGE; ue_dl_cfg.chest_cfg.cfo_estimate_enable = false; ue_dl_cfg.chest_cfg.cfo_estimate_sf_mask = false; ue_dl_cfg.chest_cfg.sync_error_enable = false; ue_dl_cfg.cfg.dci = dci_cfg; ue_dl_cfg.cfg.pdsch.use_tbs_index_alt = enable_256qam; - srslte_pdsch_res_t pdsch_res[SRSLTE_MAX_CODEWORDS]; - for (int i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { + srsran_pdsch_res_t pdsch_res[SRSRAN_MAX_CODEWORDS]; + for (int i = 0; i < SRSRAN_MAX_CODEWORDS; i++) { pdsch_res[i].payload = data_rx[i]; pdsch_res[i].avg_iterations_block = 0.0f; pdsch_res[i].crc = false; @@ -588,23 +588,23 @@ int main(int argc, char** argv) get_time_interval(t); pdsch_decode_us += (size_t)(t[0].tv_sec * 1e6 + t[0].tv_usec); - for (int i = 0; i < SRSLTE_MAX_TB; i++) { + for (int i = 0; i < SRSRAN_MAX_TB; i++) { if (ue_dl_cfg.cfg.pdsch.grant.tb[i].enabled) { if (check_evm(enb_dl, ue_dl, &ue_dl_cfg, i)) { count_failures++; - } else if (check_softbits(enb_dl, ue_dl, &ue_dl_cfg, sf_idx, i) != SRSLTE_SUCCESS) { + } else if (check_softbits(enb_dl, ue_dl, &ue_dl_cfg, sf_idx, i) != SRSRAN_SUCCESS) { printf("TB%d: The received softbits in subframe %d DO NOT match the encoded bits (crc=%d)\n", i, sf_idx, pdsch_res[i].crc); - srslte_vec_fprint_byte(stdout, (uint8_t*)enb_dl->pdsch.e[i], ue_dl_cfg.cfg.pdsch.grant.tb[i].nof_bits / 8); - srslte_vec_fprint_byte(stdout, (uint8_t*)ue_dl->pdsch.e[i], ue_dl_cfg.cfg.pdsch.grant.tb[i].nof_bits / 8); + srsran_vec_fprint_byte(stdout, (uint8_t*)enb_dl->pdsch.e[i], ue_dl_cfg.cfg.pdsch.grant.tb[i].nof_bits / 8); + srsran_vec_fprint_byte(stdout, (uint8_t*)ue_dl->pdsch.e[i], ue_dl_cfg.cfg.pdsch.grant.tb[i].nof_bits / 8); count_failures++; } else if (!pdsch_res[i].crc || memcmp(data_tx[i], data_rx[i], (uint32_t)ue_dl_cfg.cfg.pdsch.grant.tb[i].tbs / 8) != 0) { printf("UE Failed decoding tb %d in subframe %d. crc=%d; Bytes:\n", i, sf_idx, pdsch_res[i].crc); - srslte_vec_fprint_byte(stdout, data_tx[i], (uint32_t)ue_dl_cfg.cfg.pdsch.grant.tb[i].tbs / 8); - srslte_vec_fprint_byte(stdout, data_rx[i], (uint32_t)ue_dl_cfg.cfg.pdsch.grant.tb[i].tbs / 8); + srsran_vec_fprint_byte(stdout, data_tx[i], (uint32_t)ue_dl_cfg.cfg.pdsch.grant.tb[i].tbs / 8); + srsran_vec_fprint_byte(stdout, data_rx[i], (uint32_t)ue_dl_cfg.cfg.pdsch.grant.tb[i].tbs / 8); count_failures++; } else { // Decoded Ok @@ -618,7 +618,7 @@ int main(int argc, char** argv) printf("Finished! The UE failed decoding %d of %d transport blocks.\n", count_failures, count_tbs); if (!count_failures) { - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } printf("%zd were transmitted, %zd bits were received.\n", tx_nof_bits, rx_nof_bits); @@ -633,9 +633,9 @@ int main(int argc, char** argv) printf("BLER: %5.1f%%\n", (float)count_failures / (float)count_tbs * 100.0f); quit: - srslte_enb_dl_free(enb_dl); - srslte_ue_dl_free(ue_dl); - srslte_random_free(random); + srsran_enb_dl_free(enb_dl); + srsran_ue_dl_free(ue_dl); + srsran_random_free(random); for (int i = 0; i < cell.nof_ports; i++) { if (signal_buffer[i]) { @@ -643,14 +643,14 @@ quit: } } - for (int i = 0; i < SRSLTE_MAX_TB; i++) { + for (int i = 0; i < SRSRAN_MAX_TB; i++) { if (softbuffer_tx[i]) { - srslte_softbuffer_tx_free(softbuffer_tx[i]); + srsran_softbuffer_tx_free(softbuffer_tx[i]); free(softbuffer_tx[i]); } if (softbuffer_rx[i]) { - srslte_softbuffer_rx_free(softbuffer_rx[i]); + srsran_softbuffer_rx_free(softbuffer_rx[i]); free(softbuffer_rx[i]); } diff --git a/lib/test/phy/pucch_ca_test.c b/lib/test/phy/pucch_ca_test.c index 6d28cd2b0..a9b94c0d6 100644 --- a/lib/test/phy/pucch_ca_test.c +++ b/lib/test/phy/pucch_ca_test.c @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,8 +10,8 @@ * */ -#include -#include +#include +#include #include #include #include @@ -19,33 +19,33 @@ #include #include -#include "srslte/srslte.h" +#include "srsran/srsran.h" -static int test_pucch_ca(srslte_ack_nack_feedback_mode_t ack_nack_feedback_mode, +static int test_pucch_ca(srsran_ack_nack_feedback_mode_t ack_nack_feedback_mode, uint32_t nof_prb, const uint32_t* nof_tb, uint16_t nof_carriers) { - srslte_pucch_cfg_t pucch_cfg = {}; + srsran_pucch_cfg_t pucch_cfg = {}; uint16_t rnti = 0x1234; - srslte_cell_t cell = { + srsran_cell_t cell = { nof_prb, // nof_prb 1, // nof_ports 1, // cell_id - SRSLTE_CP_NORM, // cyclic prefix - SRSLTE_PHICH_NORM, // PHICH length - SRSLTE_PHICH_R_1_6, // PHICH resources - SRSLTE_FDD, + SRSRAN_CP_NORM, // cyclic prefix + SRSRAN_PHICH_NORM, // PHICH length + SRSRAN_PHICH_R_1_6, // PHICH resources + SRSRAN_FDD, }; cf_t* buffer = NULL; - srslte_refsignal_dmrs_pusch_cfg_t dmrs_pusch_cfg = {}; // Use default - srslte_ue_ul_t ue_ul = {}; - srslte_ue_ul_cfg_t ue_ul_cfg = {}; - srslte_enb_ul_t enb_ul = {}; - srslte_ul_sf_cfg_t ul_sf = {}; - srslte_pucch_res_t pucch_res = {}; - srslte_pusch_data_t pusch_data = {}; + srsran_refsignal_dmrs_pusch_cfg_t dmrs_pusch_cfg = {}; // Use default + srsran_ue_ul_t ue_ul = {}; + srsran_ue_ul_cfg_t ue_ul_cfg = {}; + srsran_enb_ul_t enb_ul = {}; + srsran_ul_sf_cfg_t ul_sf = {}; + srsran_pucch_res_t pucch_res = {}; + srsran_pusch_data_t pusch_data = {}; // Basic default args pucch_cfg.delta_pucch_shift = 1; // 1, 2, 3 @@ -55,8 +55,8 @@ static int test_pucch_ca(srslte_ack_nack_feedback_mode_t ack_nack_feedback_mode, pucch_cfg.ack_nack_feedback_mode = ack_nack_feedback_mode; // Normal, CS, PUCCH3 // Set Channel Selection resources - for (uint32_t i = 0, k = 6; i < SRSLTE_PUCCH_SIZE_AN_CS; i++) { - for (uint32_t j = 0; j < SRSLTE_PUCCH_NOF_AN_CS; j++, k++) { + for (uint32_t i = 0, k = 6; i < SRSRAN_PUCCH_SIZE_AN_CS; i++) { + for (uint32_t j = 0; j < SRSRAN_PUCCH_NOF_AN_CS; j++, k++) { pucch_cfg.n1_pucch_an_cs[i][j] = k; } } @@ -72,16 +72,16 @@ static int test_pucch_ca(srslte_ack_nack_feedback_mode_t ack_nack_feedback_mode, pucch_cfg.rnti = rnti; // Init buffers - buffer = srslte_vec_cf_malloc(SRSLTE_SF_LEN_PRB(cell.nof_prb)); + buffer = srsran_vec_cf_malloc(SRSRAN_SF_LEN_PRB(cell.nof_prb)); TESTASSERT(buffer); // Init UE - TESTASSERT(!srslte_ue_ul_init(&ue_ul, buffer, cell.nof_prb)); - TESTASSERT(!srslte_ue_ul_set_cell(&ue_ul, cell)); + TESTASSERT(!srsran_ue_ul_init(&ue_ul, buffer, cell.nof_prb)); + TESTASSERT(!srsran_ue_ul_set_cell(&ue_ul, cell)); // Init eNb - TESTASSERT(!srslte_enb_ul_init(&enb_ul, buffer, cell.nof_prb)); - TESTASSERT(!srslte_enb_ul_set_cell(&enb_ul, cell, &dmrs_pusch_cfg, NULL)); + TESTASSERT(!srsran_enb_ul_init(&enb_ul, buffer, cell.nof_prb)); + TESTASSERT(!srsran_enb_ul_set_cell(&enb_ul, cell, &dmrs_pusch_cfg, NULL)); // The test itself starts here for (ul_sf.tti = 0; ul_sf.tti < (1U << (nof_carriers * 2U)); ul_sf.tti++) { @@ -97,12 +97,12 @@ static int test_pucch_ca(srslte_ack_nack_feedback_mode_t ack_nack_feedback_mode, ue_ul_cfg.ul_cfg.pucch = pucch_cfg; // Generate UL Signal - TESTASSERT(srslte_ue_ul_encode(&ue_ul, &ul_sf, &ue_ul_cfg, &pusch_data) >= SRSLTE_SUCCESS); + TESTASSERT(srsran_ue_ul_encode(&ue_ul, &ul_sf, &ue_ul_cfg, &pusch_data) >= SRSRAN_SUCCESS); // Process UL signal - srslte_enb_ul_fft(&enb_ul); + srsran_enb_ul_fft(&enb_ul); - TESTASSERT(!srslte_enb_ul_get_pucch(&enb_ul, &ul_sf, &pucch_cfg, &pucch_res)); + TESTASSERT(!srsran_enb_ul_get_pucch(&enb_ul, &ul_sf, &pucch_cfg, &pucch_res)); TESTASSERT(pucch_res.detected); TESTASSERT(pucch_res.uci_data.ack.valid); @@ -121,41 +121,41 @@ static int test_pucch_ca(srslte_ack_nack_feedback_mode_t ack_nack_feedback_mode, } // Free all - srslte_ue_ul_free(&ue_ul); - srslte_enb_ul_free(&enb_ul); + srsran_ue_ul_free(&ue_ul); + srsran_enb_ul_free(&enb_ul); free(buffer); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int main(int argc, char** argv) { // Set PHY lib verbose to INFO - srslte_verbose = SRSLTE_VERBOSE_INFO; + srsran_verbose = SRSRAN_VERBOSE_INFO; - uint32_t nof_tb_1[SRSLTE_MAX_CARRIERS] = {1, 1, 1, 1, 1}; - uint32_t nof_tb_2[SRSLTE_MAX_CARRIERS] = {2, 1, 1, 1, 1}; - uint32_t nof_tb_3[SRSLTE_MAX_CARRIERS] = {2, 2, 2, 2, 2}; + uint32_t nof_tb_1[SRSRAN_MAX_CARRIERS] = {1, 1, 1, 1, 1}; + uint32_t nof_tb_2[SRSRAN_MAX_CARRIERS] = {2, 1, 1, 1, 1}; + uint32_t nof_tb_3[SRSRAN_MAX_CARRIERS] = {2, 2, 2, 2, 2}; - TESTASSERT(!test_pucch_ca(SRSLTE_PUCCH_ACK_NACK_FEEDBACK_MODE_CS, 6, nof_tb_1, 2)); - TESTASSERT(!test_pucch_ca(SRSLTE_PUCCH_ACK_NACK_FEEDBACK_MODE_CS, 6, nof_tb_2, 2)); - TESTASSERT(!test_pucch_ca(SRSLTE_PUCCH_ACK_NACK_FEEDBACK_MODE_CS, 6, nof_tb_3, 2)); + TESTASSERT(!test_pucch_ca(SRSRAN_PUCCH_ACK_NACK_FEEDBACK_MODE_CS, 6, nof_tb_1, 2)); + TESTASSERT(!test_pucch_ca(SRSRAN_PUCCH_ACK_NACK_FEEDBACK_MODE_CS, 6, nof_tb_2, 2)); + TESTASSERT(!test_pucch_ca(SRSRAN_PUCCH_ACK_NACK_FEEDBACK_MODE_CS, 6, nof_tb_3, 2)); - TESTASSERT(!test_pucch_ca(SRSLTE_PUCCH_ACK_NACK_FEEDBACK_MODE_CS, 100, nof_tb_1, 2)); - TESTASSERT(!test_pucch_ca(SRSLTE_PUCCH_ACK_NACK_FEEDBACK_MODE_CS, 100, nof_tb_2, 2)); - TESTASSERT(!test_pucch_ca(SRSLTE_PUCCH_ACK_NACK_FEEDBACK_MODE_CS, 100, nof_tb_3, 2)); + TESTASSERT(!test_pucch_ca(SRSRAN_PUCCH_ACK_NACK_FEEDBACK_MODE_CS, 100, nof_tb_1, 2)); + TESTASSERT(!test_pucch_ca(SRSRAN_PUCCH_ACK_NACK_FEEDBACK_MODE_CS, 100, nof_tb_2, 2)); + TESTASSERT(!test_pucch_ca(SRSRAN_PUCCH_ACK_NACK_FEEDBACK_MODE_CS, 100, nof_tb_3, 2)); - for (uint32_t i = 2; i < SRSLTE_PUCCH_FORMAT3_MAX_CARRIERS; i++) { - TESTASSERT(!test_pucch_ca(SRSLTE_PUCCH_ACK_NACK_FEEDBACK_MODE_PUCCH3, 6, nof_tb_1, i)); - TESTASSERT(!test_pucch_ca(SRSLTE_PUCCH_ACK_NACK_FEEDBACK_MODE_PUCCH3, 6, nof_tb_2, i)); - TESTASSERT(!test_pucch_ca(SRSLTE_PUCCH_ACK_NACK_FEEDBACK_MODE_PUCCH3, 6, nof_tb_3, i)); + for (uint32_t i = 2; i < SRSRAN_PUCCH_FORMAT3_MAX_CARRIERS; i++) { + TESTASSERT(!test_pucch_ca(SRSRAN_PUCCH_ACK_NACK_FEEDBACK_MODE_PUCCH3, 6, nof_tb_1, i)); + TESTASSERT(!test_pucch_ca(SRSRAN_PUCCH_ACK_NACK_FEEDBACK_MODE_PUCCH3, 6, nof_tb_2, i)); + TESTASSERT(!test_pucch_ca(SRSRAN_PUCCH_ACK_NACK_FEEDBACK_MODE_PUCCH3, 6, nof_tb_3, i)); - TESTASSERT(!test_pucch_ca(SRSLTE_PUCCH_ACK_NACK_FEEDBACK_MODE_PUCCH3, 100, nof_tb_1, i)); - TESTASSERT(!test_pucch_ca(SRSLTE_PUCCH_ACK_NACK_FEEDBACK_MODE_PUCCH3, 100, nof_tb_2, i)); - TESTASSERT(!test_pucch_ca(SRSLTE_PUCCH_ACK_NACK_FEEDBACK_MODE_PUCCH3, 100, nof_tb_3, i)); + TESTASSERT(!test_pucch_ca(SRSRAN_PUCCH_ACK_NACK_FEEDBACK_MODE_PUCCH3, 100, nof_tb_1, i)); + TESTASSERT(!test_pucch_ca(SRSRAN_PUCCH_ACK_NACK_FEEDBACK_MODE_PUCCH3, 100, nof_tb_2, i)); + TESTASSERT(!test_pucch_ca(SRSRAN_PUCCH_ACK_NACK_FEEDBACK_MODE_PUCCH3, 100, nof_tb_3, i)); } printf("Ok\n"); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } diff --git a/lib/test/srslog/CMakeLists.txt b/lib/test/srslog/CMakeLists.txt index b87eb04aa..7859d3d23 100644 --- a/lib/test/srslog/CMakeLists.txt +++ b/lib/test/srslog/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of diff --git a/lib/test/srslog/any_test.cpp b/lib/test/srslog/any_test.cpp index 671855975..5a2cf40b8 100644 --- a/lib/test/srslog/any_test.cpp +++ b/lib/test/srslog/any_test.cpp @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,7 +10,7 @@ * */ -#include "srslte/srslog/detail/support/any.h" +#include "srsran/srslog/detail/support/any.h" #include "testing_helpers.h" using namespace srslog; diff --git a/lib/test/srslog/context_test.cpp b/lib/test/srslog/context_test.cpp index 096c5f1fd..2305b4122 100644 --- a/lib/test/srslog/context_test.cpp +++ b/lib/test/srslog/context_test.cpp @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,7 +10,7 @@ * */ -#include "srslte/srslog/context.h" +#include "srsran/srslog/context.h" #include "testing_helpers.h" #include diff --git a/lib/test/srslog/event_trace_test.cpp b/lib/test/srslog/event_trace_test.cpp index a8363a5ee..94d8b063b 100644 --- a/lib/test/srslog/event_trace_test.cpp +++ b/lib/test/srslog/event_trace_test.cpp @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,8 +10,8 @@ * */ -#include "srslte/srslog/event_trace.h" -#include "srslte/srslog/log_channel.h" +#include "srsran/srslog/event_trace.h" +#include "srsran/srslog/log_channel.h" #include "test_dummies.h" #include "testing_helpers.h" diff --git a/lib/test/srslog/file_sink_test.cpp b/lib/test/srslog/file_sink_test.cpp index f17b2a6fa..509229cdc 100644 --- a/lib/test/srslog/file_sink_test.cpp +++ b/lib/test/srslog/file_sink_test.cpp @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/lib/test/srslog/file_test_utils.h b/lib/test/srslog/file_test_utils.h index 4164ed68a..fccd19dff 100644 --- a/lib/test/srslog/file_test_utils.h +++ b/lib/test/srslog/file_test_utils.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/lib/test/srslog/file_utils_test.cpp b/lib/test/srslog/file_utils_test.cpp index 9aaeb7bcd..f32ff6ff1 100644 --- a/lib/test/srslog/file_utils_test.cpp +++ b/lib/test/srslog/file_utils_test.cpp @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/lib/test/srslog/json_formatter_test.cpp b/lib/test/srslog/json_formatter_test.cpp index a5fa1974b..a1f8b1e3a 100644 --- a/lib/test/srslog/json_formatter_test.cpp +++ b/lib/test/srslog/json_formatter_test.cpp @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,7 +11,7 @@ */ #include "src/srslog/formatters/json_formatter.h" -#include "srslte/srslog/detail/log_entry_metadata.h" +#include "srsran/srslog/detail/log_entry_metadata.h" #include "testing_helpers.h" #include diff --git a/lib/test/srslog/log_backend_test.cpp b/lib/test/srslog/log_backend_test.cpp index 695bfa967..1ef1b56ca 100644 --- a/lib/test/srslog/log_backend_test.cpp +++ b/lib/test/srslog/log_backend_test.cpp @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/lib/test/srslog/log_channel_test.cpp b/lib/test/srslog/log_channel_test.cpp index 84adf8293..eb425bdc9 100644 --- a/lib/test/srslog/log_channel_test.cpp +++ b/lib/test/srslog/log_channel_test.cpp @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,7 +10,7 @@ * */ -#include "srslte/srslog/log_channel.h" +#include "srsran/srslog/log_channel.h" #include "test_dummies.h" #include "testing_helpers.h" diff --git a/lib/test/srslog/logger_test.cpp b/lib/test/srslog/logger_test.cpp index 3712e9feb..c1d4c46dc 100644 --- a/lib/test/srslog/logger_test.cpp +++ b/lib/test/srslog/logger_test.cpp @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,7 +10,7 @@ * */ -#include "srslte/srslog/logger.h" +#include "srsran/srslog/logger.h" #include "test_dummies.h" #include "testing_helpers.h" diff --git a/lib/test/srslog/srslog_test.cpp b/lib/test/srslog/srslog_test.cpp index 35e274c6b..a7047029d 100644 --- a/lib/test/srslog/srslog_test.cpp +++ b/lib/test/srslog/srslog_test.cpp @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,7 +10,7 @@ * */ -#include "srslte/srslog/srslog.h" +#include "srsran/srslog/srslog.h" #include "test_dummies.h" #include "testing_helpers.h" diff --git a/lib/test/srslog/test_dummies.h b/lib/test/srslog/test_dummies.h index 72ab5864e..8d78ef5d1 100644 --- a/lib/test/srslog/test_dummies.h +++ b/lib/test/srslog/test_dummies.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,8 +13,8 @@ #ifndef TEST_DUMMIES #define TEST_DUMMIES -#include "srslte/srslog/detail/log_backend.h" -#include "srslte/srslog/sink.h" +#include "srsran/srslog/detail/log_backend.h" +#include "srsran/srslog/sink.h" namespace test_dummies { diff --git a/lib/test/srslog/testing_helpers.h b/lib/test/srslog/testing_helpers.h index f6ff392d1..bc5e99240 100644 --- a/lib/test/srslog/testing_helpers.h +++ b/lib/test/srslog/testing_helpers.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/lib/test/srslog/text_formatter_test.cpp b/lib/test/srslog/text_formatter_test.cpp index 4aee4e840..429f06ed1 100644 --- a/lib/test/srslog/text_formatter_test.cpp +++ b/lib/test/srslog/text_formatter_test.cpp @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,7 +11,7 @@ */ #include "src/srslog/formatters/text_formatter.h" -#include "srslte/srslog/detail/log_entry_metadata.h" +#include "srsran/srslog/detail/log_entry_metadata.h" #include "testing_helpers.h" #include diff --git a/lib/test/upper/CMakeLists.txt b/lib/test/upper/CMakeLists.txt index e51e88624..c4ca7780a 100644 --- a/lib/test/upper/CMakeLists.txt +++ b/lib/test/upper/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -9,23 +9,23 @@ set(CTEST_LABELS "lib;upper") add_executable(rlc_am_data_test rlc_am_data_test.cc) -target_link_libraries(rlc_am_data_test srslte_upper srslte_phy srslte_common) +target_link_libraries(rlc_am_data_test srsran_upper srsran_phy srsran_common) add_lte_test(rlc_am_data_test rlc_am_data_test) add_executable(rlc_am_control_test rlc_am_control_test.cc) -target_link_libraries(rlc_am_control_test srslte_upper srslte_phy) +target_link_libraries(rlc_am_control_test srsran_upper srsran_phy) add_lte_test(rlc_am_control_test rlc_am_control_test) add_executable(rlc_am_test rlc_am_test.cc) -target_link_libraries(rlc_am_test srslte_upper srslte_phy srslte_common) +target_link_libraries(rlc_am_test srsran_upper srsran_phy srsran_common) add_lte_test(rlc_am_test rlc_am_test) add_executable(rlc_am_nr_pdu_test rlc_am_nr_pdu_test.cc) -target_link_libraries(rlc_am_nr_pdu_test srslte_upper srslte_phy) +target_link_libraries(rlc_am_nr_pdu_test srsran_upper srsran_phy) add_nr_test(rlc_am_nr_pdu_test rlc_am_nr_pdu_test) add_executable(rlc_stress_test rlc_stress_test.cc) -target_link_libraries(rlc_stress_test srslte_upper srslte_mac srslte_phy srslte_common ${Boost_LIBRARIES}) +target_link_libraries(rlc_stress_test srsran_upper srsran_mac srsran_phy srsran_common ${Boost_LIBRARIES}) add_lte_test(rlc_am_stress_test rlc_stress_test --mode=AM --loglevel 1 --sdu_gen_delay 250) add_lte_test(rlc_um_stress_test rlc_stress_test --mode=UM --loglevel 1) add_lte_test(rlc_tm_stress_test rlc_stress_test --mode=TM --loglevel 1 --random_opp=false) @@ -33,47 +33,47 @@ add_lte_test(rlc_tm_stress_test rlc_stress_test --mode=TM --loglevel 1 --random_ add_nr_test(rlc_um_nr_stress_test rlc_stress_test --rat NR --mode=UM --loglevel 1) add_executable(rlc_um_data_test rlc_um_data_test.cc) -target_link_libraries(rlc_um_data_test srslte_upper srslte_phy srslte_common) +target_link_libraries(rlc_um_data_test srsran_upper srsran_phy srsran_common) add_test(rlc_um_data_test rlc_um_data_test) add_executable(rlc_um_test rlc_um_test.cc) -target_link_libraries(rlc_um_test srslte_upper srslte_phy) +target_link_libraries(rlc_um_test srsran_upper srsran_phy) add_test(rlc_um_test rlc_um_test) add_executable(rlc_common_test rlc_common_test.cc) -target_link_libraries(rlc_common_test srslte_upper srslte_phy) +target_link_libraries(rlc_common_test srsran_upper srsran_phy) add_test(rlc_common_test rlc_common_test) add_executable(rlc_um_nr_pdu_test rlc_um_nr_pdu_test.cc) -target_link_libraries(rlc_um_nr_pdu_test srslte_upper srslte_mac srslte_phy) +target_link_libraries(rlc_um_nr_pdu_test srsran_upper srsran_mac srsran_phy) add_nr_test(rlc_um_nr_pdu_test rlc_um_nr_pdu_test) add_executable(rlc_um_nr_test rlc_um_nr_test.cc) -target_link_libraries(rlc_um_nr_test srslte_upper srslte_phy) +target_link_libraries(rlc_um_nr_test srsran_upper srsran_phy) add_nr_test(rlc_um_nr_test rlc_um_nr_test) add_executable(pdcp_nr_test_tx pdcp_nr_test_tx.cc) -target_link_libraries(pdcp_nr_test_tx srslte_upper srslte_common) +target_link_libraries(pdcp_nr_test_tx srsran_upper srsran_common) add_nr_test(pdcp_nr_test_tx pdcp_nr_test_tx) add_executable(pdcp_nr_test_rx pdcp_nr_test_rx.cc) -target_link_libraries(pdcp_nr_test_rx srslte_upper srslte_common) +target_link_libraries(pdcp_nr_test_rx srsran_upper srsran_common) add_nr_test(pdcp_nr_test_rx pdcp_nr_test_rx) add_executable(pdcp_nr_test_discard_sdu pdcp_nr_test_discard_sdu.cc) -target_link_libraries(pdcp_nr_test_discard_sdu srslte_upper srslte_common) +target_link_libraries(pdcp_nr_test_discard_sdu srsran_upper srsran_common) add_nr_test(pdcp_nr_test_discard_sdu pdcp_nr_test_discard_sdu) add_executable(pdcp_lte_test_rx pdcp_lte_test_rx.cc) -target_link_libraries(pdcp_lte_test_rx srslte_upper srslte_common) +target_link_libraries(pdcp_lte_test_rx srsran_upper srsran_common) add_test(pdcp_lte_test_rx pdcp_lte_test_rx) add_executable(pdcp_lte_test_discard_sdu pdcp_lte_test_discard_sdu.cc) -target_link_libraries(pdcp_lte_test_discard_sdu srslte_upper srslte_common) +target_link_libraries(pdcp_lte_test_discard_sdu srsran_upper srsran_common) add_test(pdcp_lte_test_discard_sdu pdcp_lte_test_discard_sdu) add_executable(pdcp_lte_test_status_report pdcp_lte_test_status_report.cc) -target_link_libraries(pdcp_lte_test_status_report srslte_upper srslte_common) +target_link_libraries(pdcp_lte_test_status_report srsran_upper srsran_common) add_test(pdcp_lte_test_status_report pdcp_lte_test_status_report) ######################################################################## diff --git a/lib/test/upper/pdcp_base_test.h b/lib/test/upper/pdcp_base_test.h index 815f6ad81..83af20cd0 100644 --- a/lib/test/upper/pdcp_base_test.h +++ b/lib/test/upper/pdcp_base_test.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,19 +10,19 @@ * */ -#ifndef SRSLTE_PDCP_BASE_TEST_H -#define SRSLTE_PDCP_BASE_TEST_H +#ifndef SRSRAN_PDCP_BASE_TEST_H +#define SRSRAN_PDCP_BASE_TEST_H -#include "srslte/common/buffer_pool.h" -#include "srslte/common/security.h" -#include "srslte/common/test_common.h" -#include "srslte/interfaces/pdcp_interface_types.h" -#include "srslte/interfaces/ue_gw_interfaces.h" -#include "srslte/interfaces/ue_interfaces.h" -#include "srslte/interfaces/ue_rlc_interfaces.h" +#include "srsran/common/buffer_pool.h" +#include "srsran/common/security.h" +#include "srsran/common/test_common.h" +#include "srsran/interfaces/pdcp_interface_types.h" +#include "srsran/interfaces/ue_gw_interfaces.h" +#include "srsran/interfaces/ue_interfaces.h" +#include "srsran/interfaces/ue_rlc_interfaces.h" #include -int compare_two_packets(const srslte::unique_byte_buffer_t& msg1, const srslte::unique_byte_buffer_t& msg2) +int compare_two_packets(const srsran::unique_byte_buffer_t& msg1, const srsran::unique_byte_buffer_t& msg2) { TESTASSERT(msg1->N_bytes == msg2->N_bytes); TESTASSERT(memcmp(msg1->msg, msg2->msg, msg1->N_bytes) == 0); @@ -37,12 +37,12 @@ class rlc_dummy : public srsue::rlc_interface_pdcp public: explicit rlc_dummy(srslog::basic_logger& logger) : logger(logger) {} - void get_last_sdu(const srslte::unique_byte_buffer_t& pdu) + void get_last_sdu(const srsran::unique_byte_buffer_t& pdu) { memcpy(pdu->msg, last_pdcp_pdu->msg, last_pdcp_pdu->N_bytes); pdu->N_bytes = last_pdcp_pdu->N_bytes; } - void write_sdu(uint32_t lcid, srslte::unique_byte_buffer_t sdu) + void write_sdu(uint32_t lcid, srsran::unique_byte_buffer_t sdu) { logger.info(sdu->msg, sdu->N_bytes, "RLC SDU"); last_pdcp_pdu.swap(sdu); @@ -60,7 +60,7 @@ public: private: srslog::basic_logger& logger; - srslte::unique_byte_buffer_t last_pdcp_pdu; + srsran::unique_byte_buffer_t last_pdcp_pdu; bool rb_is_um(uint32_t lcid) { return false; } bool sdu_queue_is_full(uint32_t lcid) { return false; }; @@ -71,10 +71,10 @@ class rrc_dummy : public srsue::rrc_interface_pdcp public: explicit rrc_dummy(srslog::basic_logger& logger) : logger(logger) {} - void write_pdu_bcch_bch(srslte::unique_byte_buffer_t pdu) {} - void write_pdu_bcch_dlsch(srslte::unique_byte_buffer_t pdu) {} - void write_pdu_pcch(srslte::unique_byte_buffer_t pdu) {} - void write_pdu_mch(uint32_t lcid, srslte::unique_byte_buffer_t pdu) {} + void write_pdu_bcch_bch(srsran::unique_byte_buffer_t pdu) {} + void write_pdu_bcch_dlsch(srsran::unique_byte_buffer_t pdu) {} + void write_pdu_pcch(srsran::unique_byte_buffer_t pdu) {} + void write_pdu_mch(uint32_t lcid, srsran::unique_byte_buffer_t pdu) {} std::string get_rb_name(uint32_t lcid) { return "None"; } @@ -82,16 +82,16 @@ public: // Members for testing uint32_t rx_count = 0; - srslte::unique_byte_buffer_t last_pdu; + srsran::unique_byte_buffer_t last_pdu; // Methods for testing - void get_last_pdu(const srslte::unique_byte_buffer_t& pdu) + void get_last_pdu(const srsran::unique_byte_buffer_t& pdu) { memcpy(pdu->msg, last_pdu->msg, last_pdu->N_bytes); pdu->N_bytes = last_pdu->N_bytes; } - void write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t pdu) + void write_pdu(uint32_t lcid, srsran::unique_byte_buffer_t pdu) { logger.info(pdu->msg, pdu->N_bytes, "RRC PDU"); rx_count++; @@ -104,15 +104,15 @@ class gw_dummy : public srsue::gw_interface_pdcp public: explicit gw_dummy(srslog::basic_logger& logger) : logger(logger) {} - void write_pdu_mch(uint32_t lcid, srslte::unique_byte_buffer_t pdu) {} + void write_pdu_mch(uint32_t lcid, srsran::unique_byte_buffer_t pdu) {} uint32_t rx_count = 0; - void get_last_pdu(const srslte::unique_byte_buffer_t& pdu) + void get_last_pdu(const srsran::unique_byte_buffer_t& pdu) { memcpy(pdu->msg, last_pdu->msg, last_pdu->N_bytes); pdu->N_bytes = last_pdu->N_bytes; } - void write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t pdu) + void write_pdu(uint32_t lcid, srsran::unique_byte_buffer_t pdu) { logger.info(pdu->msg, pdu->N_bytes, "GW PDU"); rx_count++; @@ -121,11 +121,11 @@ public: private: srslog::basic_logger& logger; - srslte::unique_byte_buffer_t last_pdu; + srsran::unique_byte_buffer_t last_pdu; }; // Helper to print packets -void print_packet_array(const srslte::unique_byte_buffer_t& msg) +void print_packet_array(const srsran::unique_byte_buffer_t& msg) { printf("uint8_t msg[] = {\n"); for (uint64_t i = 0; i < msg->N_bytes; ++i) { @@ -133,4 +133,4 @@ void print_packet_array(const srslte::unique_byte_buffer_t& msg) } printf("\n};\n"); } -#endif // SRSLTE_PDCP_BASE_TEST_H +#endif // SRSRAN_PDCP_BASE_TEST_H diff --git a/lib/test/upper/pdcp_lte_test.h b/lib/test/upper/pdcp_lte_test.h index df40b4ba7..6275a2558 100644 --- a/lib/test/upper/pdcp_lte_test.h +++ b/lib/test/upper/pdcp_lte_test.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,17 +10,17 @@ * */ -#ifndef SRSLTE_PDCP_LTE_TEST_H -#define SRSLTE_PDCP_LTE_TEST_H +#ifndef SRSRAN_PDCP_LTE_TEST_H +#define SRSRAN_PDCP_LTE_TEST_H #include "pdcp_base_test.h" -#include "srslte/test/ue_test_interfaces.h" -#include "srslte/upper/pdcp_entity_lte.h" +#include "srsran/test/ue_test_interfaces.h" +#include "srsran/upper/pdcp_entity_lte.h" // Helper struct to hold a packet and the number of clock // ticks to run after writing the packet to test timeouts. struct pdcp_test_event_t { - srslte::unique_byte_buffer_t pkt; + srsran::unique_byte_buffer_t pkt; uint32_t ticks = 0; }; @@ -36,13 +36,13 @@ std::array k_enc = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x30, 0x31}; // Security Configuration, common to all tests. -srslte::as_security_config_t sec_cfg = { +srsran::as_security_config_t sec_cfg = { k_int, k_enc, k_int, k_enc, - srslte::INTEGRITY_ALGORITHM_ID_128_EIA2, - srslte::CIPHERING_ALGORITHM_ID_128_EEA2, + srsran::INTEGRITY_ALGORITHM_ID_128_EIA2, + srsran::CIPHERING_ALGORITHM_ID_128_EEA2, }; // Test SDUs for tx @@ -50,7 +50,7 @@ uint8_t sdu1[] = {0x18, 0xe2}; uint8_t sdu2[] = {0xde, 0xad}; // This is the normal initial state. All state variables are set to zero -srslte::pdcp_lte_state_t normal_init_state = {}; +srsran::pdcp_lte_state_t normal_init_state = {}; /* * Helper classes to reduce copy / pasting in setting up tests @@ -59,64 +59,64 @@ srslte::pdcp_lte_state_t normal_init_state = {}; class pdcp_lte_test_helper { public: - pdcp_lte_test_helper(srslte::pdcp_config_t cfg, srslte::as_security_config_t sec_cfg_, srslog::basic_logger& logger) : + pdcp_lte_test_helper(srsran::pdcp_config_t cfg, srsran::as_security_config_t sec_cfg_, srslog::basic_logger& logger) : rlc(logger), rrc(logger), gw(logger), pdcp(&rlc, &rrc, &gw, &stack.task_sched, logger, 0, cfg) { pdcp.config_security(sec_cfg_); - pdcp.enable_integrity(srslte::DIRECTION_TXRX); - pdcp.enable_encryption(srslte::DIRECTION_TXRX); + pdcp.enable_integrity(srsran::DIRECTION_TXRX); + pdcp.enable_encryption(srsran::DIRECTION_TXRX); } - void set_pdcp_initial_state(const srslte::pdcp_lte_state_t& init_state) { pdcp.set_bearer_state(init_state, false); } + void set_pdcp_initial_state(const srsran::pdcp_lte_state_t& init_state) { pdcp.set_bearer_state(init_state, false); } rlc_dummy rlc; rrc_dummy rrc; gw_dummy gw; srsue::stack_test_dummy stack; - srslte::pdcp_entity_lte pdcp; + srsran::pdcp_entity_lte pdcp; }; // Helper function to generate PDUs -srslte::unique_byte_buffer_t gen_expected_pdu(const srslte::unique_byte_buffer_t& in_sdu, +srsran::unique_byte_buffer_t gen_expected_pdu(const srsran::unique_byte_buffer_t& in_sdu, uint32_t count, uint8_t pdcp_sn_len, - srslte::pdcp_rb_type_t rb_type, - srslte::as_security_config_t sec_cfg, + srsran::pdcp_rb_type_t rb_type, + srsran::as_security_config_t sec_cfg, srslog::basic_logger& logger) { - srslte::pdcp_config_t cfg = {1, + srsran::pdcp_config_t cfg = {1, rb_type, - srslte::SECURITY_DIRECTION_UPLINK, - srslte::SECURITY_DIRECTION_DOWNLINK, + srsran::SECURITY_DIRECTION_UPLINK, + srsran::SECURITY_DIRECTION_DOWNLINK, pdcp_sn_len, - srslte::pdcp_t_reordering_t::ms500, - srslte::pdcp_discard_timer_t::infinity, + srsran::pdcp_t_reordering_t::ms500, + srsran::pdcp_discard_timer_t::infinity, false}; pdcp_lte_test_helper pdcp_hlp(cfg, sec_cfg, logger); - srslte::pdcp_entity_lte* pdcp = &pdcp_hlp.pdcp; + srsran::pdcp_entity_lte* pdcp = &pdcp_hlp.pdcp; rlc_dummy* rlc = &pdcp_hlp.rlc; - srslte::pdcp_lte_state_t init_state = {}; + srsran::pdcp_lte_state_t init_state = {}; init_state.tx_hfn = pdcp->HFN(count); init_state.next_pdcp_tx_sn = pdcp->SN(count); pdcp_hlp.set_pdcp_initial_state(init_state); - srslte::unique_byte_buffer_t sdu = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t sdu = srsran::make_byte_buffer(); *sdu = *in_sdu; pdcp->write_sdu(std::move(sdu)); - srslte::unique_byte_buffer_t out_pdu = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t out_pdu = srsran::make_byte_buffer(); rlc->get_last_sdu(out_pdu); return out_pdu; } // Helper function to generate vector of PDU from a vector of TX_NEXTs for generating expected pdus -std::vector gen_expected_pdus_vector(const srslte::unique_byte_buffer_t& in_sdu, +std::vector gen_expected_pdus_vector(const srsran::unique_byte_buffer_t& in_sdu, const std::vector& tx_nexts, uint8_t pdcp_sn_len, - srslte::pdcp_rb_type_t rb_type, - srslte::as_security_config_t sec_cfg_, + srsran::pdcp_rb_type_t rb_type, + srsran::as_security_config_t sec_cfg_, srslog::basic_logger& logger) { std::vector pdu_vec; @@ -129,4 +129,4 @@ std::vector gen_expected_pdus_vector(const srslte::unique_byt return pdu_vec; } -#endif // SRSLTE_PDCP_NR_TEST_H +#endif // SRSRAN_PDCP_NR_TEST_H diff --git a/lib/test/upper/pdcp_lte_test_discard_sdu.cc b/lib/test/upper/pdcp_lte_test_discard_sdu.cc index 5b700e39c..50ba809eb 100644 --- a/lib/test/upper/pdcp_lte_test_discard_sdu.cc +++ b/lib/test/upper/pdcp_lte_test_discard_sdu.cc @@ -15,37 +15,37 @@ /* * Test of imediate notification from RLC */ -int test_tx_sdu_notify(const srslte::pdcp_lte_state_t& init_state, - srslte::pdcp_discard_timer_t discard_timeout, +int test_tx_sdu_notify(const srsran::pdcp_lte_state_t& init_state, + srsran::pdcp_discard_timer_t discard_timeout, srslog::basic_logger& logger) { - srslte::pdcp_config_t cfg = {1, - srslte::PDCP_RB_IS_DRB, - srslte::SECURITY_DIRECTION_UPLINK, - srslte::SECURITY_DIRECTION_DOWNLINK, - srslte::PDCP_SN_LEN_12, - srslte::pdcp_t_reordering_t::ms500, + srsran::pdcp_config_t cfg = {1, + srsran::PDCP_RB_IS_DRB, + srsran::SECURITY_DIRECTION_UPLINK, + srsran::SECURITY_DIRECTION_DOWNLINK, + srsran::PDCP_SN_LEN_12, + srsran::pdcp_t_reordering_t::ms500, discard_timeout, false}; pdcp_lte_test_helper pdcp_hlp(cfg, sec_cfg, logger); - srslte::pdcp_entity_lte* pdcp = &pdcp_hlp.pdcp; + srsran::pdcp_entity_lte* pdcp = &pdcp_hlp.pdcp; rlc_dummy* rlc = &pdcp_hlp.rlc; srsue::stack_test_dummy* stack = &pdcp_hlp.stack; pdcp_hlp.set_pdcp_initial_state(init_state); // Write test SDU - srslte::unique_byte_buffer_t sdu = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t sdu = srsran::make_byte_buffer(); sdu->append_bytes(sdu1, sizeof(sdu1)); pdcp->write_sdu(std::move(sdu)); - srslte::unique_byte_buffer_t out_pdu = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t out_pdu = srsran::make_byte_buffer(); rlc->get_last_sdu(out_pdu); TESTASSERT(out_pdu->N_bytes == 4); TESTASSERT(pdcp->nof_discard_timers() == 1); // One timer should be running - srslte::pdcp_sn_vector_t sns_notified; + srsran::pdcp_sn_vector_t sns_notified; sns_notified.push_back(0); pdcp->notify_delivery(sns_notified); TESTASSERT(pdcp->nof_discard_timers() == 0); // Timer should have been difused after @@ -62,32 +62,32 @@ int test_tx_sdu_notify(const srslte::pdcp_lte_state_t& init_state, /* * Test discard timer expiry */ -int test_tx_sdu_discard(const srslte::pdcp_lte_state_t& init_state, - srslte::pdcp_discard_timer_t discard_timeout, +int test_tx_sdu_discard(const srsran::pdcp_lte_state_t& init_state, + srsran::pdcp_discard_timer_t discard_timeout, srslog::basic_logger& logger) { - srslte::pdcp_config_t cfg = {1, - srslte::PDCP_RB_IS_DRB, - srslte::SECURITY_DIRECTION_UPLINK, - srslte::SECURITY_DIRECTION_DOWNLINK, - srslte::PDCP_SN_LEN_12, - srslte::pdcp_t_reordering_t::ms500, + srsran::pdcp_config_t cfg = {1, + srsran::PDCP_RB_IS_DRB, + srsran::SECURITY_DIRECTION_UPLINK, + srsran::SECURITY_DIRECTION_DOWNLINK, + srsran::PDCP_SN_LEN_12, + srsran::pdcp_t_reordering_t::ms500, discard_timeout, false}; pdcp_lte_test_helper pdcp_hlp(cfg, sec_cfg, logger); - srslte::pdcp_entity_lte* pdcp = &pdcp_hlp.pdcp; + srsran::pdcp_entity_lte* pdcp = &pdcp_hlp.pdcp; rlc_dummy* rlc = &pdcp_hlp.rlc; srsue::stack_test_dummy* stack = &pdcp_hlp.stack; pdcp_hlp.set_pdcp_initial_state(init_state); // Write test SDU - srslte::unique_byte_buffer_t sdu = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t sdu = srsran::make_byte_buffer(); sdu->append_bytes(sdu1, sizeof(sdu1)); pdcp->write_sdu(std::move(sdu)); - srslte::unique_byte_buffer_t out_pdu = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t out_pdu = srsran::make_byte_buffer(); rlc->get_last_sdu(out_pdu); TESTASSERT(out_pdu->N_bytes == 4); @@ -104,7 +104,7 @@ int test_tx_sdu_discard(const srslte::pdcp_lte_state_t& init_state, TESTASSERT(pdcp->nof_discard_timers() == 0); // Timer should have been difused after expiry TESTASSERT(rlc->discard_count == 1); // RLC should be notified of discard - srslte::pdcp_sn_vector_t sns_notified; + srsran::pdcp_sn_vector_t sns_notified; sns_notified.push_back(0); pdcp->notify_delivery(sns_notified); // PDCP should not find PDU to notify. return 0; @@ -119,13 +119,13 @@ int test_tx_discard_all(srslog::basic_logger& logger) * TX Test 1: PDCP Entity with SN LEN = 12 * Test TX PDU discard. */ - TESTASSERT(test_tx_sdu_notify(normal_init_state, srslte::pdcp_discard_timer_t::ms50, logger) == 0); + TESTASSERT(test_tx_sdu_notify(normal_init_state, srsran::pdcp_discard_timer_t::ms50, logger) == 0); /* * TX Test 2: PDCP Entity with SN LEN = 12 * Test TX PDU discard. */ - TESTASSERT(test_tx_sdu_discard(normal_init_state, srslte::pdcp_discard_timer_t::ms50, logger) == 0); + TESTASSERT(test_tx_sdu_discard(normal_init_state, srsran::pdcp_discard_timer_t::ms50, logger) == 0); return 0; } @@ -145,10 +145,10 @@ int main() { srslog::init(); - if (run_all_tests() != SRSLTE_SUCCESS) { + if (run_all_tests() != SRSRAN_SUCCESS) { fprintf(stderr, "pdcp_lte_tests() failed\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } diff --git a/lib/test/upper/pdcp_lte_test_rx.cc b/lib/test/upper/pdcp_lte_test_rx.cc index 271a72e4d..98fd28a4f 100644 --- a/lib/test/upper/pdcp_lte_test_rx.cc +++ b/lib/test/upper/pdcp_lte_test_rx.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -16,25 +16,25 @@ * Genric function to test reception of in-sequence packets */ int test_rx(std::vector events, - const srslte::pdcp_lte_state_t& init_state, + const srsran::pdcp_lte_state_t& init_state, uint8_t pdcp_sn_len, - srslte::pdcp_rb_type_t rb_type, + srsran::pdcp_rb_type_t rb_type, uint32_t n_sdus_exp, - const srslte::unique_byte_buffer_t& sdu_exp, + const srsran::unique_byte_buffer_t& sdu_exp, srslog::basic_logger& logger) { - srslte::pdcp_config_t cfg_rx = {1, + srsran::pdcp_config_t cfg_rx = {1, rb_type, - srslte::SECURITY_DIRECTION_DOWNLINK, - srslte::SECURITY_DIRECTION_UPLINK, + srsran::SECURITY_DIRECTION_DOWNLINK, + srsran::SECURITY_DIRECTION_UPLINK, pdcp_sn_len, - srslte::pdcp_t_reordering_t::ms500, - srslte::pdcp_discard_timer_t::infinity, + srsran::pdcp_t_reordering_t::ms500, + srsran::pdcp_discard_timer_t::infinity, false}; pdcp_lte_test_helper pdcp_hlp_rx(cfg_rx, sec_cfg, logger); - srslte::pdcp_entity_lte* pdcp_rx = &pdcp_hlp_rx.pdcp; + srsran::pdcp_entity_lte* pdcp_rx = &pdcp_hlp_rx.pdcp; gw_dummy* gw_rx = &pdcp_hlp_rx.gw; rrc_dummy* rrc_rx = &pdcp_hlp_rx.rrc; srsue::stack_test_dummy* stack = &pdcp_hlp_rx.stack; @@ -50,10 +50,10 @@ int test_rx(std::vector events, } // Test if the number of RX packets - if (rb_type == srslte::PDCP_RB_IS_DRB) { + if (rb_type == srsran::PDCP_RB_IS_DRB) { TESTASSERT(gw_rx->rx_count == n_sdus_exp); if (n_sdus_exp > 0) { - srslte::unique_byte_buffer_t sdu_act = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t sdu_act = srsran::make_byte_buffer(); gw_rx->get_last_pdu(sdu_act); TESTASSERT(compare_two_packets(sdu_exp, sdu_act) == 0); } @@ -61,7 +61,7 @@ int test_rx(std::vector events, } else { TESTASSERT(rrc_rx->rx_count == n_sdus_exp); if (n_sdus_exp > 0) { - srslte::unique_byte_buffer_t sdu_act = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t sdu_act = srsran::make_byte_buffer(); rrc_rx->get_last_pdu(sdu_act); TESTASSERT(compare_two_packets(sdu_exp, sdu_act) == 0); } @@ -76,9 +76,9 @@ int test_rx(std::vector events, int test_rx_all(srslog::basic_logger& logger) { // Test SDUs - srslte::unique_byte_buffer_t tst_sdu1 = srslte::make_byte_buffer(); // SDU 1 + srsran::unique_byte_buffer_t tst_sdu1 = srsran::make_byte_buffer(); // SDU 1 tst_sdu1->append_bytes(sdu1, sizeof(sdu1)); - srslte::unique_byte_buffer_t tst_sdu2 = srslte::make_byte_buffer(); // SDU 2 + srsran::unique_byte_buffer_t tst_sdu2 = srsran::make_byte_buffer(); // SDU 2 tst_sdu2->append_bytes(sdu2, sizeof(sdu2)); /* @@ -90,13 +90,13 @@ int test_rx_all(srslog::basic_logger& logger) std::vector test1_counts(2); // Test two packets std::iota(test1_counts.begin(), test1_counts.end(), 31); // Starting at COUNT 31 std::vector test1_pdus = gen_expected_pdus_vector( - tst_sdu1, test1_counts, srslte::PDCP_SN_LEN_5, srslte::PDCP_RB_IS_SRB, sec_cfg, logger); - srslte::pdcp_lte_state_t test1_init_state = { + tst_sdu1, test1_counts, srsran::PDCP_SN_LEN_5, srsran::PDCP_RB_IS_SRB, sec_cfg, logger); + srsran::pdcp_lte_state_t test1_init_state = { .next_pdcp_tx_sn = 0, .tx_hfn = 0, .rx_hfn = 0, .next_pdcp_rx_sn = 31, .last_submitted_pdcp_rx_sn = 30}; TESTASSERT(test_rx(std::move(test1_pdus), test1_init_state, - srslte::PDCP_SN_LEN_5, - srslte::PDCP_RB_IS_SRB, + srsran::PDCP_SN_LEN_5, + srsran::PDCP_RB_IS_SRB, 2, tst_sdu1, logger) == 0); @@ -111,13 +111,13 @@ int test_rx_all(srslog::basic_logger& logger) std::vector test_counts(2); // Test two packets std::iota(test_counts.begin(), test_counts.end(), 4095); // Starting at COUNT 4095 std::vector test_pdus = gen_expected_pdus_vector( - tst_sdu1, test_counts, srslte::PDCP_SN_LEN_12, srslte::PDCP_RB_IS_DRB, sec_cfg, logger); - srslte::pdcp_lte_state_t test_init_state = { + tst_sdu1, test_counts, srsran::PDCP_SN_LEN_12, srsran::PDCP_RB_IS_DRB, sec_cfg, logger); + srsran::pdcp_lte_state_t test_init_state = { .next_pdcp_tx_sn = 0, .tx_hfn = 0, .rx_hfn = 0, .next_pdcp_rx_sn = 4095, .last_submitted_pdcp_rx_sn = 4094}; TESTASSERT(test_rx(std::move(test_pdus), test_init_state, - srslte::PDCP_SN_LEN_12, - srslte::PDCP_RB_IS_DRB, + srsran::PDCP_SN_LEN_12, + srsran::PDCP_RB_IS_DRB, 2, tst_sdu1, logger) == 0); @@ -131,19 +131,19 @@ int test_rx_all(srslog::basic_logger& logger) std::vector test_counts(2); // Test two packets std::iota(test_counts.begin(), test_counts.end(), 31); // Starting at COUNT 31 std::vector test_pdus = gen_expected_pdus_vector( - tst_sdu1, test_counts, srslte::PDCP_SN_LEN_12, srslte::PDCP_RB_IS_DRB, sec_cfg, logger); - srslte::pdcp_lte_state_t test_init_state = { + tst_sdu1, test_counts, srsran::PDCP_SN_LEN_12, srsran::PDCP_RB_IS_DRB, sec_cfg, logger); + srsran::pdcp_lte_state_t test_init_state = { .next_pdcp_tx_sn = 0, .tx_hfn = 0, .rx_hfn = 0, .next_pdcp_rx_sn = 32, .last_submitted_pdcp_rx_sn = 31}; TESTASSERT(test_rx(std::move(test_pdus), test_init_state, - srslte::PDCP_SN_LEN_12, - srslte::PDCP_RB_IS_DRB, + srsran::PDCP_SN_LEN_12, + srsran::PDCP_RB_IS_DRB, test_counts.size() - 1, tst_sdu1, logger) == 0); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Basic test to verify the correct handling of PDCP status PDUs on DRBs @@ -155,21 +155,21 @@ int test_rx_control_pdu(srslog::basic_logger& logger) std::vector pdu_vec; pdcp_test_event_t event; - event.pkt = srslte::make_byte_buffer(); + event.pkt = srsran::make_byte_buffer(); memcpy(event.pkt->msg, pdcp_status_report_long, sizeof(pdcp_status_report_long)); event.pkt->N_bytes = sizeof(pdcp_status_report_long); pdu_vec.push_back(std::move(event)); - srslte::unique_byte_buffer_t tst_sdu1 = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t tst_sdu1 = srsran::make_byte_buffer(); - srslte::pdcp_lte_state_t test_init_state = { + srsran::pdcp_lte_state_t test_init_state = { .next_pdcp_tx_sn = 0, .tx_hfn = 0, .rx_hfn = 0, .next_pdcp_rx_sn = 32, .last_submitted_pdcp_rx_sn = 31}; TESTASSERT( test_rx( - std::move(pdu_vec), test_init_state, srslte::PDCP_SN_LEN_12, srslte::PDCP_RB_IS_DRB, 0, tst_sdu1, logger) == + std::move(pdu_vec), test_init_state, srsran::PDCP_SN_LEN_12, srsran::PDCP_RB_IS_DRB, 0, tst_sdu1, logger) == 0); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Setup all tests @@ -190,10 +190,10 @@ int main() { srslog::init(); - if (run_all_tests() != SRSLTE_SUCCESS) { + if (run_all_tests() != SRSRAN_SUCCESS) { fprintf(stderr, "pdcp_nr_tests_rx() failed\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } diff --git a/lib/test/upper/pdcp_lte_test_status_report.cc b/lib/test/upper/pdcp_lte_test_status_report.cc index 7bb1c2c2b..69586d3d3 100644 --- a/lib/test/upper/pdcp_lte_test_status_report.cc +++ b/lib/test/upper/pdcp_lte_test_status_report.cc @@ -15,47 +15,47 @@ /* * Test correct transmission of FMS and Bitmap in status report */ -int test_tx_status_report(const srslte::pdcp_lte_state_t& init_state, srslog::basic_logger& logger) +int test_tx_status_report(const srsran::pdcp_lte_state_t& init_state, srslog::basic_logger& logger) { - srslte::pdcp_config_t cfg_tx = {1, - srslte::PDCP_RB_IS_DRB, - srslte::SECURITY_DIRECTION_UPLINK, - srslte::SECURITY_DIRECTION_DOWNLINK, - srslte::PDCP_SN_LEN_12, - srslte::pdcp_t_reordering_t::ms500, - srslte::pdcp_discard_timer_t::ms500, + srsran::pdcp_config_t cfg_tx = {1, + srsran::PDCP_RB_IS_DRB, + srsran::SECURITY_DIRECTION_UPLINK, + srsran::SECURITY_DIRECTION_DOWNLINK, + srsran::PDCP_SN_LEN_12, + srsran::pdcp_t_reordering_t::ms500, + srsran::pdcp_discard_timer_t::ms500, true}; - srslte::pdcp_config_t cfg_rx = {1, - srslte::PDCP_RB_IS_DRB, - srslte::SECURITY_DIRECTION_DOWNLINK, - srslte::SECURITY_DIRECTION_UPLINK, - srslte::PDCP_SN_LEN_12, - srslte::pdcp_t_reordering_t::ms500, - srslte::pdcp_discard_timer_t::ms500, + srsran::pdcp_config_t cfg_rx = {1, + srsran::PDCP_RB_IS_DRB, + srsran::SECURITY_DIRECTION_DOWNLINK, + srsran::SECURITY_DIRECTION_UPLINK, + srsran::PDCP_SN_LEN_12, + srsran::pdcp_t_reordering_t::ms500, + srsran::pdcp_discard_timer_t::ms500, true}; // Setup TX pdcp_lte_test_helper pdcp_hlp_tx(cfg_tx, sec_cfg, logger); - srslte::pdcp_entity_lte* pdcp_tx = &pdcp_hlp_tx.pdcp; + srsran::pdcp_entity_lte* pdcp_tx = &pdcp_hlp_tx.pdcp; rlc_dummy* rlc_tx = &pdcp_hlp_tx.rlc; srsue::stack_test_dummy* stack_tx = &pdcp_hlp_tx.stack; pdcp_hlp_tx.set_pdcp_initial_state(init_state); // Setup RX pdcp_lte_test_helper pdcp_hlp_rx(cfg_tx, sec_cfg, logger); - srslte::pdcp_entity_lte* pdcp_rx = &pdcp_hlp_tx.pdcp; + srsran::pdcp_entity_lte* pdcp_rx = &pdcp_hlp_tx.pdcp; rlc_dummy* rlc_rx = &pdcp_hlp_tx.rlc; srsue::stack_test_dummy* stack_rx = &pdcp_hlp_tx.stack; pdcp_hlp_rx.set_pdcp_initial_state(init_state); // Tmp variable to hold the PDCP PDU - srslte::unique_byte_buffer_t out_pdu = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t out_pdu = srsran::make_byte_buffer(); // Write 256 SDUs and notify imediatly -> FMS 0001 0000 0001 for (uint32_t i = 0; i < 257; i++) { - srslte::unique_byte_buffer_t sdu = srslte::make_byte_buffer(); - srslte::unique_byte_buffer_t pdu = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t sdu = srsran::make_byte_buffer(); + srsran::unique_byte_buffer_t pdu = srsran::make_byte_buffer(); sdu->append_bytes(sdu1, sizeof(sdu1)); pdcp_tx->write_sdu(std::move(sdu)); pdcp_tx->notify_delivery({i}); @@ -82,8 +82,8 @@ int test_tx_status_report(const srslte::pdcp_lte_state_t& init_state, srslog::ba // Write another 16 SDUs but don't notify SN=257, SN=258, SN=271 and SN=272 for (uint32_t i = 257; i < 273; i++) { - srslte::unique_byte_buffer_t sdu = srslte::make_byte_buffer(); - srslte::unique_byte_buffer_t pdu = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t sdu = srsran::make_byte_buffer(); + srsran::unique_byte_buffer_t pdu = srsran::make_byte_buffer(); sdu->append_bytes(sdu1, sizeof(sdu1)); pdcp_tx->write_sdu(std::move(sdu)); if (i != 257 && i != 258 && i != 271 && i != 272) { @@ -119,49 +119,49 @@ int test_tx_status_report(const srslte::pdcp_lte_state_t& init_state, srslog::ba /* * Test correct transmission of FMS and Bitmap in status report */ -int test_tx_wraparound_status_report(const srslte::pdcp_lte_state_t& init_state, srslog::basic_logger& logger) +int test_tx_wraparound_status_report(const srsran::pdcp_lte_state_t& init_state, srslog::basic_logger& logger) { - srslte::pdcp_config_t cfg_tx = {1, - srslte::PDCP_RB_IS_DRB, - srslte::SECURITY_DIRECTION_UPLINK, - srslte::SECURITY_DIRECTION_DOWNLINK, - srslte::PDCP_SN_LEN_12, - srslte::pdcp_t_reordering_t::ms500, - srslte::pdcp_discard_timer_t::ms500, + srsran::pdcp_config_t cfg_tx = {1, + srsran::PDCP_RB_IS_DRB, + srsran::SECURITY_DIRECTION_UPLINK, + srsran::SECURITY_DIRECTION_DOWNLINK, + srsran::PDCP_SN_LEN_12, + srsran::pdcp_t_reordering_t::ms500, + srsran::pdcp_discard_timer_t::ms500, true}; - srslte::pdcp_config_t cfg_rx = {1, - srslte::PDCP_RB_IS_DRB, - srslte::SECURITY_DIRECTION_DOWNLINK, - srslte::SECURITY_DIRECTION_UPLINK, - srslte::PDCP_SN_LEN_12, - srslte::pdcp_t_reordering_t::ms500, - srslte::pdcp_discard_timer_t::ms500, + srsran::pdcp_config_t cfg_rx = {1, + srsran::PDCP_RB_IS_DRB, + srsran::SECURITY_DIRECTION_DOWNLINK, + srsran::SECURITY_DIRECTION_UPLINK, + srsran::PDCP_SN_LEN_12, + srsran::pdcp_t_reordering_t::ms500, + srsran::pdcp_discard_timer_t::ms500, true}; // Setup TX pdcp_lte_test_helper pdcp_hlp_tx(cfg_tx, sec_cfg, logger); - srslte::pdcp_entity_lte* pdcp_tx = &pdcp_hlp_tx.pdcp; + srsran::pdcp_entity_lte* pdcp_tx = &pdcp_hlp_tx.pdcp; rlc_dummy* rlc_tx = &pdcp_hlp_tx.rlc; srsue::stack_test_dummy* stack_tx = &pdcp_hlp_tx.stack; pdcp_hlp_tx.set_pdcp_initial_state(init_state); // Setup RX pdcp_lte_test_helper pdcp_hlp_rx(cfg_tx, sec_cfg, logger); - srslte::pdcp_entity_lte* pdcp_rx = &pdcp_hlp_tx.pdcp; + srsran::pdcp_entity_lte* pdcp_rx = &pdcp_hlp_tx.pdcp; rlc_dummy* rlc_rx = &pdcp_hlp_tx.rlc; srsue::stack_test_dummy* stack_rx = &pdcp_hlp_tx.stack; pdcp_hlp_rx.set_pdcp_initial_state(init_state); - srslte::unique_byte_buffer_t out_pdu = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t out_pdu = srsran::make_byte_buffer(); // Write 256 SDUs and notify imediatly -> FMS 1111 1111 0000 for (uint32_t i = 0; i < 4080; i++) { - srslte::unique_byte_buffer_t sdu = srslte::make_byte_buffer(); - srslte::unique_byte_buffer_t pdu = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t sdu = srsran::make_byte_buffer(); + srsran::unique_byte_buffer_t pdu = srsran::make_byte_buffer(); if (sdu == nullptr or pdu == nullptr) { logger.error("Could not allocate byte buffer"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } sdu->append_bytes(sdu1, sizeof(sdu1)); pdcp_tx->write_sdu(std::move(sdu)); @@ -189,11 +189,11 @@ int test_tx_wraparound_status_report(const srslte::pdcp_lte_state_t& init_state, // Write another 32 SDUs but don't notify SN=4080, SN=4081, SN=14 and SN=15 for (uint32_t i = 4080; i < 4112; i++) { - srslte::unique_byte_buffer_t sdu = srslte::make_byte_buffer(); - srslte::unique_byte_buffer_t pdu = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t sdu = srsran::make_byte_buffer(); + srsran::unique_byte_buffer_t pdu = srsran::make_byte_buffer(); if (sdu == nullptr or pdu == nullptr) { logger.error("Could not allocate byte buffer"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } sdu->append_bytes(sdu1, sizeof(sdu1)); pdcp_tx->write_sdu(std::move(sdu)); @@ -231,29 +231,29 @@ int test_tx_wraparound_status_report(const srslte::pdcp_lte_state_t& init_state, /* * Test reception of status report */ -int test_rx_status_report(const srslte::pdcp_lte_state_t& init_state, srslog::basic_logger& logger) +int test_rx_status_report(const srsran::pdcp_lte_state_t& init_state, srslog::basic_logger& logger) { - srslte::pdcp_config_t cfg = {1, - srslte::PDCP_RB_IS_DRB, - srslte::SECURITY_DIRECTION_UPLINK, - srslte::SECURITY_DIRECTION_DOWNLINK, - srslte::PDCP_SN_LEN_12, - srslte::pdcp_t_reordering_t::ms500, - srslte::pdcp_discard_timer_t::ms500, + srsran::pdcp_config_t cfg = {1, + srsran::PDCP_RB_IS_DRB, + srsran::SECURITY_DIRECTION_UPLINK, + srsran::SECURITY_DIRECTION_DOWNLINK, + srsran::PDCP_SN_LEN_12, + srsran::pdcp_t_reordering_t::ms500, + srsran::pdcp_discard_timer_t::ms500, true}; pdcp_lte_test_helper pdcp_hlp(cfg, sec_cfg, logger); - srslte::pdcp_entity_lte* pdcp = &pdcp_hlp.pdcp; + srsran::pdcp_entity_lte* pdcp = &pdcp_hlp.pdcp; rlc_dummy* rlc = &pdcp_hlp.rlc; srsue::stack_test_dummy* stack = &pdcp_hlp.stack; pdcp_hlp.set_pdcp_initial_state(init_state); - srslte::unique_byte_buffer_t status_pdu = srslte::make_byte_buffer(); - srslte::unique_byte_buffer_t out_pdu = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t status_pdu = srsran::make_byte_buffer(); + srsran::unique_byte_buffer_t out_pdu = srsran::make_byte_buffer(); // Write 256 SDUs and notify imediatly -> FMS 0001 0000 0001 for (uint32_t i = 0; i < 257; i++) { - srslte::unique_byte_buffer_t sdu = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t sdu = srsran::make_byte_buffer(); sdu->append_bytes(sdu1, sizeof(sdu1)); pdcp->write_sdu(std::move(sdu)); pdcp->notify_delivery({i}); @@ -261,7 +261,7 @@ int test_rx_status_report(const srslte::pdcp_lte_state_t& init_state, srslog::ba // Write another 16 SDUs but don't notify SN=257, SN=258, SN=271 and SN=272 for (uint32_t i = 257; i < 273; i++) { - srslte::unique_byte_buffer_t sdu = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t sdu = srsran::make_byte_buffer(); sdu->append_bytes(sdu1, sizeof(sdu1)); pdcp->write_sdu(std::move(sdu)); if (i != 257 && i != 258 && i != 271 && i != 272) { @@ -300,7 +300,7 @@ int run_all_tests() logger.set_hex_dump_max_size(128); // This is the normal initial state. All state variables are set to zero - srslte::pdcp_lte_state_t normal_init_state = {}; + srsran::pdcp_lte_state_t normal_init_state = {}; normal_init_state.last_submitted_pdcp_rx_sn = 4095; TESTASSERT(test_tx_status_report(normal_init_state, logger) == 0); @@ -313,10 +313,10 @@ int main() { srslog::init(); - if (run_all_tests() != SRSLTE_SUCCESS) { + if (run_all_tests() != SRSRAN_SUCCESS) { fprintf(stderr, "pdcp_lte_tests() failed\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } diff --git a/lib/test/upper/pdcp_nr_test.h b/lib/test/upper/pdcp_nr_test.h index 4d50221c7..9ce8738af 100644 --- a/lib/test/upper/pdcp_nr_test.h +++ b/lib/test/upper/pdcp_nr_test.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,12 +10,12 @@ * */ -#ifndef SRSLTE_PDCP_NR_TEST_H -#define SRSLTE_PDCP_NR_TEST_H +#ifndef SRSRAN_PDCP_NR_TEST_H +#define SRSRAN_PDCP_NR_TEST_H #include "pdcp_base_test.h" -#include "srslte/test/ue_test_interfaces.h" -#include "srslte/upper/pdcp_entity_nr.h" +#include "srsran/test/ue_test_interfaces.h" +#include "srsran/upper/pdcp_entity_nr.h" struct pdcp_initial_state { uint32_t tx_next; @@ -27,7 +27,7 @@ struct pdcp_initial_state { // Helper struct to hold a packet and the number of clock // ticks to run after writing the packet to test timeouts. struct pdcp_test_event_t { - srslte::unique_byte_buffer_t pkt; + srsran::unique_byte_buffer_t pkt; uint32_t ticks = 0; }; @@ -43,13 +43,13 @@ std::array k_enc = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x30, 0x31}; // Security Configuration, common to all tests. -srslte::as_security_config_t sec_cfg = { +srsran::as_security_config_t sec_cfg = { k_int, k_enc, k_int, k_enc, - srslte::INTEGRITY_ALGORITHM_ID_128_EIA2, - srslte::CIPHERING_ALGORITHM_ID_128_EEA2, + srsran::INTEGRITY_ALGORITHM_ID_128_EIA2, + srsran::CIPHERING_ALGORITHM_ID_128_EEA2, }; // Test SDUs for tx @@ -87,12 +87,12 @@ pdcp_initial_state near_wraparound_init_state = {.tx_next = 4294967295, class pdcp_nr_test_helper { public: - pdcp_nr_test_helper(srslte::pdcp_config_t cfg, srslte::as_security_config_t sec_cfg_, srslog::basic_logger& logger) : + pdcp_nr_test_helper(srsran::pdcp_config_t cfg, srsran::as_security_config_t sec_cfg_, srslog::basic_logger& logger) : rlc(logger), rrc(logger), gw(logger), pdcp(&rlc, &rrc, &gw, &stack.task_sched, logger, 0, cfg) { pdcp.config_security(sec_cfg_); - pdcp.enable_integrity(srslte::DIRECTION_TXRX); - pdcp.enable_encryption(srslte::DIRECTION_TXRX); + pdcp.enable_integrity(srsran::DIRECTION_TXRX); + pdcp.enable_encryption(srsran::DIRECTION_TXRX); } void set_pdcp_initial_state(pdcp_initial_state init_state) @@ -107,47 +107,47 @@ public: rrc_dummy rrc; gw_dummy gw; srsue::stack_test_dummy stack; - srslte::pdcp_entity_nr pdcp; + srsran::pdcp_entity_nr pdcp; }; // Helper function to generate PDUs -srslte::unique_byte_buffer_t gen_expected_pdu(const srslte::unique_byte_buffer_t& in_sdu, +srsran::unique_byte_buffer_t gen_expected_pdu(const srsran::unique_byte_buffer_t& in_sdu, uint32_t count, uint8_t pdcp_sn_len, - srslte::as_security_config_t sec_cfg, + srsran::as_security_config_t sec_cfg, srslog::basic_logger& logger) { - srslte::pdcp_config_t cfg = {1, - srslte::PDCP_RB_IS_DRB, - srslte::SECURITY_DIRECTION_UPLINK, - srslte::SECURITY_DIRECTION_DOWNLINK, + srsran::pdcp_config_t cfg = {1, + srsran::PDCP_RB_IS_DRB, + srsran::SECURITY_DIRECTION_UPLINK, + srsran::SECURITY_DIRECTION_DOWNLINK, pdcp_sn_len, - srslte::pdcp_t_reordering_t::ms500, - srslte::pdcp_discard_timer_t::infinity, + srsran::pdcp_t_reordering_t::ms500, + srsran::pdcp_discard_timer_t::infinity, false}; pdcp_nr_test_helper pdcp_hlp(cfg, sec_cfg, logger); - srslte::pdcp_entity_nr* pdcp = &pdcp_hlp.pdcp; + srsran::pdcp_entity_nr* pdcp = &pdcp_hlp.pdcp; rlc_dummy* rlc = &pdcp_hlp.rlc; pdcp_initial_state init_state = {}; init_state.tx_next = count; pdcp_hlp.set_pdcp_initial_state(init_state); - srslte::unique_byte_buffer_t sdu = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t sdu = srsran::make_byte_buffer(); *sdu = *in_sdu; pdcp->write_sdu(std::move(sdu)); - srslte::unique_byte_buffer_t out_pdu = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t out_pdu = srsran::make_byte_buffer(); rlc->get_last_sdu(out_pdu); return out_pdu; } // Helper function to generate vector of PDU from a vector of TX_NEXTs for generating expected pdus -std::vector gen_expected_pdus_vector(const srslte::unique_byte_buffer_t& in_sdu, +std::vector gen_expected_pdus_vector(const srsran::unique_byte_buffer_t& in_sdu, const std::vector& tx_nexts, uint8_t pdcp_sn_len, - srslte::as_security_config_t sec_cfg_, + srsran::as_security_config_t sec_cfg_, srslog::basic_logger& logger) { std::vector pdu_vec; @@ -160,4 +160,4 @@ std::vector gen_expected_pdus_vector(const srslte::unique_byt return pdu_vec; } -#endif // SRSLTE_PDCP_NR_TEST_H +#endif // SRSRAN_PDCP_NR_TEST_H diff --git a/lib/test/upper/pdcp_nr_test_discard_sdu.cc b/lib/test/upper/pdcp_nr_test_discard_sdu.cc index 54ffeb63e..6b3da0944 100644 --- a/lib/test/upper/pdcp_nr_test_discard_sdu.cc +++ b/lib/test/upper/pdcp_nr_test_discard_sdu.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -16,28 +16,28 @@ * Genric function to test transmission of in-sequence packets */ int test_tx_sdu_discard(const pdcp_initial_state& init_state, - srslte::pdcp_discard_timer_t discard_timeout, + srsran::pdcp_discard_timer_t discard_timeout, bool imediate_notify, srslog::basic_logger& logger) { - srslte::pdcp_config_t cfg = {1, - srslte::PDCP_RB_IS_DRB, - srslte::SECURITY_DIRECTION_UPLINK, - srslte::SECURITY_DIRECTION_DOWNLINK, - srslte::PDCP_SN_LEN_12, - srslte::pdcp_t_reordering_t::ms500, + srsran::pdcp_config_t cfg = {1, + srsran::PDCP_RB_IS_DRB, + srsran::SECURITY_DIRECTION_UPLINK, + srsran::SECURITY_DIRECTION_DOWNLINK, + srsran::PDCP_SN_LEN_12, + srsran::pdcp_t_reordering_t::ms500, discard_timeout, false}; pdcp_nr_test_helper pdcp_hlp(cfg, sec_cfg, logger); - srslte::pdcp_entity_nr* pdcp = &pdcp_hlp.pdcp; + srsran::pdcp_entity_nr* pdcp = &pdcp_hlp.pdcp; rlc_dummy* rlc = &pdcp_hlp.rlc; srsue::stack_test_dummy* stack = &pdcp_hlp.stack; pdcp_hlp.set_pdcp_initial_state(init_state); // Test SDU - srslte::unique_byte_buffer_t sdu = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t sdu = srsran::make_byte_buffer(); sdu->append_bytes(sdu1, sizeof(sdu1)); pdcp->write_sdu(std::move(sdu)); @@ -79,13 +79,13 @@ int test_tx_discard_all(srslog::basic_logger& logger) * TX Test 1: PDCP Entity with SN LEN = 12 * Test TX PDU discard. */ - TESTASSERT(test_tx_sdu_discard(normal_init_state, srslte::pdcp_discard_timer_t::ms50, false, logger) == 0); + TESTASSERT(test_tx_sdu_discard(normal_init_state, srsran::pdcp_discard_timer_t::ms50, false, logger) == 0); /* * TX Test 2: PDCP Entity with SN LEN = 12 * Test TX PDU discard. */ - // TESTASSERT(test_tx_sdu_discard(normal_init_state, srslte::pdcp_discard_timer_t::ms50, true, logger) == 0); + // TESTASSERT(test_tx_sdu_discard(normal_init_state, srsran::pdcp_discard_timer_t::ms50, true, logger) == 0); return 0; } @@ -105,10 +105,10 @@ int main() { srslog::init(); - if (run_all_tests() != SRSLTE_SUCCESS) { + if (run_all_tests() != SRSRAN_SUCCESS) { fprintf(stderr, "pdcp_nr_tests() failed\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } diff --git a/lib/test/upper/pdcp_nr_test_rx.cc b/lib/test/upper/pdcp_nr_test_rx.cc index 5c5bc2226..414009891 100644 --- a/lib/test/upper/pdcp_nr_test_rx.cc +++ b/lib/test/upper/pdcp_nr_test_rx.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -19,21 +19,21 @@ int test_rx(std::vector events, const pdcp_initial_state& init_state, uint8_t pdcp_sn_len, uint32_t n_sdus_exp, - const srslte::unique_byte_buffer_t& sdu_exp, + const srsran::unique_byte_buffer_t& sdu_exp, srslog::basic_logger& logger) { - srslte::pdcp_config_t cfg_rx = {1, - srslte::PDCP_RB_IS_DRB, - srslte::SECURITY_DIRECTION_DOWNLINK, - srslte::SECURITY_DIRECTION_UPLINK, + srsran::pdcp_config_t cfg_rx = {1, + srsran::PDCP_RB_IS_DRB, + srsran::SECURITY_DIRECTION_DOWNLINK, + srsran::SECURITY_DIRECTION_UPLINK, pdcp_sn_len, - srslte::pdcp_t_reordering_t::ms500, - srslte::pdcp_discard_timer_t::infinity, + srsran::pdcp_t_reordering_t::ms500, + srsran::pdcp_discard_timer_t::infinity, false}; pdcp_nr_test_helper pdcp_hlp_rx(cfg_rx, sec_cfg, logger); - srslte::pdcp_entity_nr* pdcp_rx = &pdcp_hlp_rx.pdcp; + srsran::pdcp_entity_nr* pdcp_rx = &pdcp_hlp_rx.pdcp; gw_dummy* gw_rx = &pdcp_hlp_rx.gw; srsue::stack_test_dummy* stack = &pdcp_hlp_rx.stack; pdcp_hlp_rx.set_pdcp_initial_state(init_state); @@ -49,7 +49,7 @@ int test_rx(std::vector events, // Test if the number of RX packets TESTASSERT(gw_rx->rx_count == n_sdus_exp); - srslte::unique_byte_buffer_t sdu_act = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t sdu_act = srsran::make_byte_buffer(); gw_rx->get_last_pdu(sdu_act); TESTASSERT(compare_two_packets(sdu_exp, sdu_act) == 0); return 0; @@ -62,9 +62,9 @@ int test_rx(std::vector events, int test_rx_all(srslog::basic_logger& logger) { // Test SDUs - srslte::unique_byte_buffer_t tst_sdu1 = srslte::make_byte_buffer(); // SDU 1 + srsran::unique_byte_buffer_t tst_sdu1 = srsran::make_byte_buffer(); // SDU 1 tst_sdu1->append_bytes(sdu1, sizeof(sdu1)); - srslte::unique_byte_buffer_t tst_sdu2 = srslte::make_byte_buffer(); // SDU 2 + srsran::unique_byte_buffer_t tst_sdu2 = srsran::make_byte_buffer(); // SDU 2 tst_sdu2->append_bytes(sdu2, sizeof(sdu2)); /* @@ -76,9 +76,9 @@ int test_rx_all(srslog::basic_logger& logger) std::vector test1_counts(2); // Test two packets std::iota(test1_counts.begin(), test1_counts.end(), 4095); // Starting at COUNT 4095 std::vector test1_pdus = - gen_expected_pdus_vector(tst_sdu1, test1_counts, srslte::PDCP_SN_LEN_12, sec_cfg, logger); + gen_expected_pdus_vector(tst_sdu1, test1_counts, srsran::PDCP_SN_LEN_12, sec_cfg, logger); pdcp_initial_state test1_init_state = {.tx_next = 4095, .rx_next = 4095, .rx_deliv = 4095, .rx_reord = 0}; - TESTASSERT(test_rx(std::move(test1_pdus), test1_init_state, srslte::PDCP_SN_LEN_12, 2, tst_sdu1, logger) == 0); + TESTASSERT(test_rx(std::move(test1_pdus), test1_init_state, srsran::PDCP_SN_LEN_12, 2, tst_sdu1, logger) == 0); } /* * RX Test 2: PDCP Entity with SN LEN = 12 @@ -90,10 +90,10 @@ int test_rx_all(srslog::basic_logger& logger) std::vector test2_counts(2); // Test two packets std::iota(test2_counts.begin(), test2_counts.end(), 4294967295); // Starting at COUNT 4294967295 std::vector test2_pdus = - gen_expected_pdus_vector(tst_sdu1, test2_counts, srslte::PDCP_SN_LEN_12, sec_cfg, logger); + gen_expected_pdus_vector(tst_sdu1, test2_counts, srsran::PDCP_SN_LEN_12, sec_cfg, logger); pdcp_initial_state test2_init_state = { .tx_next = 4294967295, .rx_next = 4294967295, .rx_deliv = 4294967295, .rx_reord = 0}; - TESTASSERT(test_rx(std::move(test2_pdus), test2_init_state, srslte::PDCP_SN_LEN_12, 1, tst_sdu1, logger) == 0); + TESTASSERT(test_rx(std::move(test2_pdus), test2_init_state, srsran::PDCP_SN_LEN_12, 1, tst_sdu1, logger) == 0); } /* * RX Test 3: PDCP Entity with SN LEN = 18 @@ -104,9 +104,9 @@ int test_rx_all(srslog::basic_logger& logger) std::vector test3_counts(2); // Test two packets std::iota(test3_counts.begin(), test3_counts.end(), 262144); // Starting at COUNT 262144 std::vector test3_pdus = - gen_expected_pdus_vector(tst_sdu1, test3_counts, srslte::PDCP_SN_LEN_18, sec_cfg, logger); + gen_expected_pdus_vector(tst_sdu1, test3_counts, srsran::PDCP_SN_LEN_18, sec_cfg, logger); pdcp_initial_state test3_init_state = {.tx_next = 262144, .rx_next = 262144, .rx_deliv = 262144, .rx_reord = 0}; - TESTASSERT(test_rx(std::move(test3_pdus), test3_init_state, srslte::PDCP_SN_LEN_18, 2, tst_sdu1, logger) == 0); + TESTASSERT(test_rx(std::move(test3_pdus), test3_init_state, srsran::PDCP_SN_LEN_18, 2, tst_sdu1, logger) == 0); } /* @@ -118,10 +118,10 @@ int test_rx_all(srslog::basic_logger& logger) std::vector test4_counts(2); // Test two packets std::iota(test4_counts.begin(), test4_counts.end(), 4294967295); // Starting at COUNT 4294967295 std::vector test4_pdus = - gen_expected_pdus_vector(tst_sdu1, test4_counts, srslte::PDCP_SN_LEN_18, sec_cfg, logger); + gen_expected_pdus_vector(tst_sdu1, test4_counts, srsran::PDCP_SN_LEN_18, sec_cfg, logger); pdcp_initial_state test4_init_state = { .tx_next = 4294967295, .rx_next = 4294967295, .rx_deliv = 4294967295, .rx_reord = 0}; - TESTASSERT(test_rx(std::move(test4_pdus), test4_init_state, srslte::PDCP_SN_LEN_18, 1, tst_sdu1, logger) == 0); + TESTASSERT(test_rx(std::move(test4_pdus), test4_init_state, srsran::PDCP_SN_LEN_18, 1, tst_sdu1, logger) == 0); } /* @@ -134,18 +134,18 @@ int test_rx_all(srslog::basic_logger& logger) // First PDU pdcp_test_event_t event_pdu1; - event_pdu1.pkt = srslte::make_byte_buffer(); + event_pdu1.pkt = srsran::make_byte_buffer(); event_pdu1.pkt->append_bytes(pdu1_count0_snlen12, sizeof(pdu1_count0_snlen12)); // Second PDU pdcp_test_event_t event_pdu2; - event_pdu2.pkt = srslte::make_byte_buffer(); + event_pdu2.pkt = srsran::make_byte_buffer(); event_pdu2.pkt->append_bytes(pdu2_count1_snlen12, sizeof(pdu2_count1_snlen12)); // Write PDUs out of order (first the pdu with COUNT 1 and COUNT 0 after) test5_pdus.push_back(std::move(event_pdu2)); test5_pdus.push_back(std::move(event_pdu1)); - TESTASSERT(test_rx(std::move(test5_pdus), test5_init_state, srslte::PDCP_SN_LEN_12, 2, tst_sdu2, logger) == 0); + TESTASSERT(test_rx(std::move(test5_pdus), test5_init_state, srsran::PDCP_SN_LEN_12, 2, tst_sdu2, logger) == 0); } /* @@ -158,18 +158,18 @@ int test_rx_all(srslog::basic_logger& logger) // First PDU pdcp_test_event_t event_pdu1; - event_pdu1.pkt = srslte::make_byte_buffer(); + event_pdu1.pkt = srsran::make_byte_buffer(); event_pdu1.pkt->append_bytes(pdu1_count0_snlen18, sizeof(pdu1_count0_snlen18)); // Second PDU pdcp_test_event_t event_pdu2; - event_pdu2.pkt = srslte::make_byte_buffer(); + event_pdu2.pkt = srsran::make_byte_buffer(); event_pdu2.pkt->append_bytes(pdu2_count1_snlen18, sizeof(pdu2_count1_snlen18)); // Write PDUs out of order (first the pdu with COUNT 1 and COUNT 0 after) test6_pdus.push_back(std::move(event_pdu2)); test6_pdus.push_back(std::move(event_pdu1)); - TESTASSERT(test_rx(std::move(test6_pdus), test6_init_state, srslte::PDCP_SN_LEN_18, 2, tst_sdu2, logger) == 0); + TESTASSERT(test_rx(std::move(test6_pdus), test6_init_state, srsran::PDCP_SN_LEN_18, 2, tst_sdu2, logger) == 0); } /* @@ -182,13 +182,13 @@ int test_rx_all(srslog::basic_logger& logger) // First PDU pdcp_test_event_t event_pdu1; - event_pdu1.pkt = srslte::make_byte_buffer(); + event_pdu1.pkt = srsran::make_byte_buffer(); event_pdu1.pkt->append_bytes(pdu2_count1_snlen12, sizeof(pdu2_count1_snlen12)); event_pdu1.ticks = 500; // Write PDUs out of order (first the pdu with COUNT 1 and COUNT 0 after) test7_pdus.push_back(std::move(event_pdu1)); - TESTASSERT(test_rx(std::move(test7_pdus), test7_init_state, srslte::PDCP_SN_LEN_12, 1, tst_sdu2, logger) == 0); + TESTASSERT(test_rx(std::move(test7_pdus), test7_init_state, srsran::PDCP_SN_LEN_12, 1, tst_sdu2, logger) == 0); } /* @@ -201,18 +201,18 @@ int test_rx_all(srslog::basic_logger& logger) // First PDU pdcp_test_event_t event_pdu1; - event_pdu1.pkt = srslte::make_byte_buffer(); + event_pdu1.pkt = srsran::make_byte_buffer(); event_pdu1.pkt->append_bytes(pdu1_count0_snlen12, sizeof(pdu1_count0_snlen12)); // Second PDU pdcp_test_event_t event_pdu2; - event_pdu2.pkt = srslte::make_byte_buffer(); + event_pdu2.pkt = srsran::make_byte_buffer(); event_pdu2.pkt->append_bytes(pdu1_count0_snlen12, sizeof(pdu1_count0_snlen12)); // Write PDUs out of order (first the pdu with COUNT 1 and COUNT 0 after) test8_pdus.push_back(std::move(event_pdu1)); test8_pdus.push_back(std::move(event_pdu2)); - TESTASSERT(test_rx(std::move(test8_pdus), test8_init_state, srslte::PDCP_SN_LEN_12, 1, tst_sdu1, logger) == 0); + TESTASSERT(test_rx(std::move(test8_pdus), test8_init_state, srsran::PDCP_SN_LEN_12, 1, tst_sdu1, logger) == 0); } return 0; } @@ -233,9 +233,9 @@ int main() { srslog::init(); - if (run_all_tests() != SRSLTE_SUCCESS) { + if (run_all_tests() != SRSRAN_SUCCESS) { fprintf(stderr, "pdcp_nr_tests_rx() failed\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } diff --git a/lib/test/upper/pdcp_nr_test_tx.cc b/lib/test/upper/pdcp_nr_test_tx.cc index 0aca92524..acdfc7b19 100644 --- a/lib/test/upper/pdcp_nr_test_tx.cc +++ b/lib/test/upper/pdcp_nr_test_tx.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -19,20 +19,20 @@ int test_tx(uint32_t n_packets, const pdcp_initial_state& init_state, uint8_t pdcp_sn_len, uint64_t n_pdus_exp, - srslte::unique_byte_buffer_t pdu_exp, + srsran::unique_byte_buffer_t pdu_exp, srslog::basic_logger& logger) { - srslte::pdcp_config_t cfg = {1, - srslte::PDCP_RB_IS_DRB, - srslte::SECURITY_DIRECTION_UPLINK, - srslte::SECURITY_DIRECTION_DOWNLINK, + srsran::pdcp_config_t cfg = {1, + srsran::PDCP_RB_IS_DRB, + srsran::SECURITY_DIRECTION_UPLINK, + srsran::SECURITY_DIRECTION_DOWNLINK, pdcp_sn_len, - srslte::pdcp_t_reordering_t::ms500, - srslte::pdcp_discard_timer_t::infinity, + srsran::pdcp_t_reordering_t::ms500, + srsran::pdcp_discard_timer_t::infinity, false}; pdcp_nr_test_helper pdcp_hlp(cfg, sec_cfg, logger); - srslte::pdcp_entity_nr* pdcp = &pdcp_hlp.pdcp; + srsran::pdcp_entity_nr* pdcp = &pdcp_hlp.pdcp; rlc_dummy* rlc = &pdcp_hlp.rlc; pdcp_hlp.set_pdcp_initial_state(init_state); @@ -40,12 +40,12 @@ int test_tx(uint32_t n_packets, // Run test for (uint32_t i = 0; i < n_packets; ++i) { // Test SDU - srslte::unique_byte_buffer_t sdu = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t sdu = srsran::make_byte_buffer(); sdu->append_bytes(sdu1, sizeof(sdu1)); pdcp->write_sdu(std::move(sdu)); } - srslte::unique_byte_buffer_t pdu_act = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t pdu_act = srsran::make_byte_buffer(); rlc->get_last_sdu(pdu_act); TESTASSERT(rlc->rx_count == n_pdus_exp); @@ -67,11 +67,11 @@ int test_tx_all(srslog::basic_logger& logger) * Output: PDCP Header {0x80, 0x00}, Ciphered Text {0x8f, 0xe3}, MAC-I {0xe0, 0xdf, 0x82, 0x92} */ n_packets = 1; - srslte::unique_byte_buffer_t pdu_exp_count0_len12 = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t pdu_exp_count0_len12 = srsran::make_byte_buffer(); pdu_exp_count0_len12->append_bytes(pdu1_count0_snlen12, sizeof(pdu1_count0_snlen12)); TESTASSERT( test_tx( - n_packets, normal_init_state, srslte::PDCP_SN_LEN_12, n_packets, std::move(pdu_exp_count0_len12), logger) == + n_packets, normal_init_state, srsran::PDCP_SN_LEN_12, n_packets, std::move(pdu_exp_count0_len12), logger) == 0); /* @@ -81,11 +81,11 @@ int test_tx_all(srslog::basic_logger& logger) * Output: PDCP Header {0x88, 0x00}, Ciphered Text {0x8d, 0x2c}, MAC-I {0x47, 0x5e, 0xb1, 0x5b} */ n_packets = 2049; - srslte::unique_byte_buffer_t pdu_exp_count2048_len12 = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t pdu_exp_count2048_len12 = srsran::make_byte_buffer(); pdu_exp_count2048_len12->append_bytes(pdu1_count2048_snlen12, sizeof(pdu1_count2048_snlen12)); TESTASSERT(test_tx(n_packets, normal_init_state, - srslte::PDCP_SN_LEN_12, + srsran::PDCP_SN_LEN_12, n_packets, std::move(pdu_exp_count2048_len12), logger) == 0); @@ -97,11 +97,11 @@ int test_tx_all(srslog::basic_logger& logger) * Output: PDCP Header {0x80,0x00}, Ciphered Text {0x97, 0xbe}, MAC-I {0xa3, 0x32, 0xfa, 0x61} */ n_packets = 4097; - srslte::unique_byte_buffer_t pdu_exp_count4096_len12 = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t pdu_exp_count4096_len12 = srsran::make_byte_buffer(); pdu_exp_count4096_len12->append_bytes(pdu1_count4096_snlen12, sizeof(pdu1_count4096_snlen12)); TESTASSERT(test_tx(n_packets, normal_init_state, - srslte::PDCP_SN_LEN_12, + srsran::PDCP_SN_LEN_12, n_packets, std::move(pdu_exp_count4096_len12), logger) == 0); @@ -113,11 +113,11 @@ int test_tx_all(srslog::basic_logger& logger) * Output: PDCP Header {0x80, 0x80, 0x00}, Ciphered Text {0x8f, 0xe3}, MAC-I {0xe0, 0xdf, 0x82, 0x92} */ n_packets = 1; - srslte::unique_byte_buffer_t pdu_exp_count0_len18 = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t pdu_exp_count0_len18 = srsran::make_byte_buffer(); pdu_exp_count0_len18->append_bytes(pdu1_count0_snlen18, sizeof(pdu1_count0_snlen18)); TESTASSERT( test_tx( - n_packets, normal_init_state, srslte::PDCP_SN_LEN_18, n_packets, std::move(pdu_exp_count0_len18), logger) == + n_packets, normal_init_state, srsran::PDCP_SN_LEN_18, n_packets, std::move(pdu_exp_count0_len18), logger) == 0); /* @@ -127,11 +127,11 @@ int test_tx_all(srslog::basic_logger& logger) * Output: PDCP Header {0x82, 0x00, 0x00}, Ciphered Text {0x15, 0x01}, MAC-I {0xf4, 0xb0, 0xfc, 0xc5} */ n_packets = 131073; - srslte::unique_byte_buffer_t pdu_exp_sn131072_len18 = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t pdu_exp_sn131072_len18 = srsran::make_byte_buffer(); pdu_exp_sn131072_len18->append_bytes(pdu1_count131072_snlen18, sizeof(pdu1_count131072_snlen18)); TESTASSERT( test_tx( - n_packets, normal_init_state, srslte::PDCP_SN_LEN_18, n_packets, std::move(pdu_exp_sn131072_len18), logger) == + n_packets, normal_init_state, srsran::PDCP_SN_LEN_18, n_packets, std::move(pdu_exp_sn131072_len18), logger) == 0); /* @@ -141,11 +141,11 @@ int test_tx_all(srslog::basic_logger& logger) * Output: PDCP Header {0x80, 0x00, 0x00}, Ciphered Text {0xc2, 0x47}, MAC-I {0xa8, 0xdd, 0xc0, 0x73} */ n_packets = 262145; - srslte::unique_byte_buffer_t pdu_exp_count262144_len18 = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t pdu_exp_count262144_len18 = srsran::make_byte_buffer(); pdu_exp_count262144_len18->append_bytes(pdu1_count262144_snlen18, sizeof(pdu1_count262144_snlen18)); TESTASSERT(test_tx(n_packets, normal_init_state, - srslte::PDCP_SN_LEN_18, + srsran::PDCP_SN_LEN_18, n_packets, std::move(pdu_exp_count262144_len18), logger) == 0); @@ -156,11 +156,11 @@ int test_tx_all(srslog::basic_logger& logger) * Should print a warning and drop all packets after wraparound. */ n_packets = 5; - srslte::unique_byte_buffer_t pdu_exp_count4294967295_len12 = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t pdu_exp_count4294967295_len12 = srsran::make_byte_buffer(); pdu_exp_count4294967295_len12->append_bytes(pdu1_count4294967295_snlen12, sizeof(pdu1_count4294967295_snlen12)); TESTASSERT(test_tx(n_packets, near_wraparound_init_state, - srslte::PDCP_SN_LEN_12, + srsran::PDCP_SN_LEN_12, 1, std::move(pdu_exp_count4294967295_len12), logger) == 0); @@ -171,11 +171,11 @@ int test_tx_all(srslog::basic_logger& logger) * Should print a warning and drop all packets after wraparound. */ n_packets = 5; - srslte::unique_byte_buffer_t pdu_exp_count4294967295_len18 = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t pdu_exp_count4294967295_len18 = srsran::make_byte_buffer(); pdu_exp_count4294967295_len18->append_bytes(pdu1_count4294967295_snlen18, sizeof(pdu1_count4294967295_snlen18)); TESTASSERT(test_tx(n_packets, near_wraparound_init_state, - srslte::PDCP_SN_LEN_18, + srsran::PDCP_SN_LEN_18, 1, std::move(pdu_exp_count4294967295_len18), logger) == 0); @@ -198,9 +198,9 @@ int main() { srslog::init(); - if (run_all_tests() != SRSLTE_SUCCESS) { + if (run_all_tests() != SRSRAN_SUCCESS) { fprintf(stderr, "pdcp_nr_tests_tx() failed\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } diff --git a/lib/test/upper/rlc_am_control_test.cc b/lib/test/upper/rlc_am_control_test.cc index 867a33340..9ebc56c31 100644 --- a/lib/test/upper/rlc_am_control_test.cc +++ b/lib/test/upper/rlc_am_control_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,8 +10,8 @@ * */ -#include "srslte/common/test_common.h" -#include "srslte/upper/rlc_am_lte.h" +#include "srsran/common/test_common.h" +#include "srsran/upper/rlc_am_lte.h" #include // Simple status PDU @@ -20,8 +20,8 @@ int simple_status_pdu_test1() uint8_t pdu1[] = {0x00, 0x78}; uint32_t PDU1_LEN = 2; - srslte::rlc_status_pdu_t s1; - srslte::byte_buffer_t b1, b2; + srsran::rlc_status_pdu_t s1; + srsran::byte_buffer_t b1, b2; memcpy(b1.msg, &pdu1[0], PDU1_LEN); b1.N_bytes = PDU1_LEN; @@ -34,7 +34,7 @@ int simple_status_pdu_test1() TESTASSERT(b2.msg[i] == b1.msg[i]); } TESTASSERT(rlc_am_is_valid_status_pdu(s1)); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Status PDU with 4 NACKs @@ -43,8 +43,8 @@ int status_pdu_with_nacks_test1() uint8_t pdu2[] = {0x00, 0x22, 0x00, 0x40, 0x0C, 0x01, 0xC0, 0x20}; uint32_t PDU2_LEN = 8; - srslte::rlc_status_pdu_t s2; - srslte::byte_buffer_t b1, b2; + srsran::rlc_status_pdu_t s2; + srsran::byte_buffer_t b1, b2; memcpy(b1.msg, &pdu2[0], PDU2_LEN); b1.N_bytes = PDU2_LEN; @@ -62,30 +62,30 @@ int status_pdu_with_nacks_test1() } TESTASSERT(rlc_am_is_valid_status_pdu(s2)); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int malformed_status_pdu_test() { uint8_t pdu[] = {0x0b, 0x77, 0x6d, 0xd6, 0xe5, 0x6f, 0x56, 0xf8}; - srslte::rlc_status_pdu_t s1; - srslte::byte_buffer_t b1, b2; + srsran::rlc_status_pdu_t s1; + srsran::byte_buffer_t b1, b2; memcpy(b1.msg, pdu, sizeof(pdu)); b1.N_bytes = sizeof(pdu); rlc_am_read_status_pdu(&b1, &s1); TESTASSERT(rlc_am_is_valid_status_pdu(s1) == false); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int main(int argc, char** argv) { srslog::init(); - TESTASSERT(simple_status_pdu_test1() == SRSLTE_SUCCESS); - TESTASSERT(status_pdu_with_nacks_test1() == SRSLTE_SUCCESS); - TESTASSERT(malformed_status_pdu_test() == SRSLTE_SUCCESS); + TESTASSERT(simple_status_pdu_test1() == SRSRAN_SUCCESS); + TESTASSERT(status_pdu_with_nacks_test1() == SRSRAN_SUCCESS); + TESTASSERT(malformed_status_pdu_test() == SRSRAN_SUCCESS); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } diff --git a/lib/test/upper/rlc_am_data_test.cc b/lib/test/upper/rlc_am_data_test.cc index 134cd07ad..a5c706e67 100644 --- a/lib/test/upper/rlc_am_data_test.cc +++ b/lib/test/upper/rlc_am_data_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,8 +10,8 @@ * */ -#include "srslte/common/test_common.h" -#include "srslte/upper/rlc_am_lte.h" +#include "srsran/common/test_common.h" +#include "srsran/upper/rlc_am_lte.h" #include // Fixed header only @@ -40,12 +40,12 @@ uint32_t PDU3_LEN = 7; uint8_t pdu4[] = {0x9C, 0x02, 0xD3, 0xE5, 0xDC}; uint32_t PDU4_LEN = 5; -using namespace srslte; +using namespace srsran; int test1() { - srslte::rlc_amd_pdu_header_t h; - srslte::byte_buffer_t b1, b2; + srsran::rlc_amd_pdu_header_t h; + srsran::byte_buffer_t b1, b2; memcpy(b1.msg, &pdu1[0], PDU1_LEN); b1.N_bytes = PDU1_LEN; @@ -62,13 +62,13 @@ int test1() TESTASSERT(b2.N_bytes == PDU1_LEN); for (uint32_t i = 0; i < b2.N_bytes; i++) TESTASSERT(b2.msg[i] == b1.msg[i]); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test2() { - srslte::rlc_amd_pdu_header_t h; - srslte::byte_buffer_t b1, b2; + srsran::rlc_amd_pdu_header_t h; + srsran::byte_buffer_t b1, b2; memcpy(b1.msg, &pdu2[0], PDU2_LEN); b1.N_bytes = PDU2_LEN; @@ -87,13 +87,13 @@ int test2() TESTASSERT(b2.N_bytes == PDU2_LEN); for (uint32_t i = 0; i < b2.N_bytes; i++) TESTASSERT(b2.msg[i] == b1.msg[i]); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test3() { - srslte::rlc_amd_pdu_header_t h; - srslte::byte_buffer_t b1, b2; + srsran::rlc_amd_pdu_header_t h; + srsran::byte_buffer_t b1, b2; memcpy(b1.msg, &pdu3[0], PDU3_LEN); b1.N_bytes = PDU3_LEN; @@ -113,13 +113,13 @@ int test3() TESTASSERT(b2.N_bytes == PDU3_LEN); for (uint32_t i = 0; i < b2.N_bytes; i++) TESTASSERT(b2.msg[i] == b1.msg[i]); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test4() { - srslte::rlc_amd_pdu_header_t h; - srslte::byte_buffer_t b1, b2; + srsran::rlc_amd_pdu_header_t h; + srsran::byte_buffer_t b1, b2; memcpy(b1.msg, &pdu4[0], PDU4_LEN); b1.N_bytes = PDU4_LEN; @@ -138,17 +138,17 @@ int test4() TESTASSERT(b2.N_bytes == PDU4_LEN); for (uint32_t i = 0; i < b2.N_bytes; i++) TESTASSERT(b2.msg[i] == b1.msg[i]); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int main(int argc, char** argv) { srslog::init(); - TESTASSERT(test1() == SRSLTE_SUCCESS); - TESTASSERT(test2() == SRSLTE_SUCCESS); - TESTASSERT(test3() == SRSLTE_SUCCESS); - TESTASSERT(test4() == SRSLTE_SUCCESS); + TESTASSERT(test1() == SRSRAN_SUCCESS); + TESTASSERT(test2() == SRSRAN_SUCCESS); + TESTASSERT(test3() == SRSRAN_SUCCESS); + TESTASSERT(test4() == SRSRAN_SUCCESS); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } diff --git a/lib/test/upper/rlc_am_nr_pdu_test.cc b/lib/test/upper/rlc_am_nr_pdu_test.cc index f3c6e828e..b31136fcf 100644 --- a/lib/test/upper/rlc_am_nr_pdu_test.cc +++ b/lib/test/upper/rlc_am_nr_pdu_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,9 +10,9 @@ * */ -#include "srslte/config.h" -#include "srslte/upper/rlc.h" -#include "srslte/upper/rlc_am_nr.h" +#include "srsran/config.h" +#include "srsran/upper/rlc.h" +#include "srsran/upper/rlc_am_nr.h" #include #include @@ -31,12 +31,12 @@ #define PCAP_CRNTI (0x1001) #define PCAP_TTI (666) -using namespace srslte; +using namespace srsran; #if PCAP -#include "srslte/common/mac_nr_pcap.h" -#include "srslte/mac/mac_nr_pdu.h" -static std::unique_ptr pcap_handle = nullptr; +#include "srsran/common/mac_nr_pcap.h" +#include "srsran/mac/mac_nr_pdu.h" +static std::unique_ptr pcap_handle = nullptr; #endif int write_pdu_to_pcap(const uint32_t lcid, const uint8_t* payload, const uint32_t len) @@ -44,28 +44,28 @@ int write_pdu_to_pcap(const uint32_t lcid, const uint8_t* payload, const uint32_ #if PCAP if (pcap_handle) { byte_buffer_t tx_buffer; - srslte::mac_nr_sch_pdu tx_pdu; + srsran::mac_nr_sch_pdu tx_pdu; tx_pdu.init_tx(&tx_buffer, len + 10); tx_pdu.add_sdu(lcid, payload, len); tx_pdu.pack(); pcap_handle->write_dl_crnti(tx_buffer.msg, tx_buffer.N_bytes, PCAP_CRNTI, true, PCAP_TTI); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } #endif - return SRSLTE_ERROR; + return SRSRAN_ERROR; } template -srslte::byte_buffer_t make_pdu_and_log(const std::array& tv) +srsran::byte_buffer_t make_pdu_and_log(const std::array& tv) { - srslte::byte_buffer_t pdu; + srsran::byte_buffer_t pdu; memcpy(pdu.msg, tv.data(), tv.size()); pdu.N_bytes = tv.size(); write_pdu_to_pcap(4, tv.data(), tv.size()); return pdu; } -void corrupt_pdu_header(srslte::byte_buffer_t& pdu, const uint32_t header_len, const uint32_t payload_len) +void corrupt_pdu_header(srsran::byte_buffer_t& pdu, const uint32_t header_len, const uint32_t payload_len) { // clear header only for (uint32_t i = 0; i < header_len; i++) { @@ -80,11 +80,11 @@ int rlc_am_nr_pdu_test1() { const int header_len = 2, payload_len = 4; std::array tv = {0x80, 0x00, 0x11, 0x22, 0x33, 0x44}; - srslte::byte_buffer_t pdu = make_pdu_and_log(tv); + srsran::byte_buffer_t pdu = make_pdu_and_log(tv); // unpack PDU rlc_am_nr_pdu_header_t header = {}; - TESTASSERT(rlc_am_nr_read_data_pdu_header(&pdu, srslte::rlc_am_nr_sn_size_t::size12bits, &header) != 0); + TESTASSERT(rlc_am_nr_read_data_pdu_header(&pdu, srsran::rlc_am_nr_sn_size_t::size12bits, &header) != 0); TESTASSERT(header.si == rlc_nr_si_field_t::full_sdu); // clear header @@ -95,7 +95,7 @@ int rlc_am_nr_pdu_test1() TESTASSERT(pdu.N_bytes == tv.size()); TESTASSERT(memcmp(pdu.msg, tv.data(), pdu.N_bytes) == 0); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // RLC AM PDU 12bit first segment of SDU with P flag and SN 511 @@ -103,11 +103,11 @@ int rlc_am_nr_pdu_test2() { const int header_len = 2, payload_len = 4; std::array tv = {0xd1, 0xff, 0x11, 0x22, 0x33, 0x44}; - srslte::byte_buffer_t pdu = make_pdu_and_log(tv); + srsran::byte_buffer_t pdu = make_pdu_and_log(tv); // unpack PDU rlc_am_nr_pdu_header_t header = {}; - TESTASSERT(rlc_am_nr_read_data_pdu_header(&pdu, srslte::rlc_am_nr_sn_size_t::size12bits, &header) != 0); + TESTASSERT(rlc_am_nr_read_data_pdu_header(&pdu, srsran::rlc_am_nr_sn_size_t::size12bits, &header) != 0); TESTASSERT(header.si == rlc_nr_si_field_t::first_segment); TESTASSERT(header.sn == 511); TESTASSERT(header.so == 0); @@ -123,7 +123,7 @@ int rlc_am_nr_pdu_test2() TESTASSERT(memcmp(pdu.msg, tv.data(), pdu.N_bytes) == 0); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // RLC AM PDU 12bit last segment of SDU without P flag and SN 0x0404 and SO 0x0404 (1028) @@ -131,11 +131,11 @@ int rlc_am_nr_pdu_test3() { const int header_len = 4, payload_len = 4; std::array tv = {0xa4, 0x04, 0x04, 0x04, 0x11, 0x22, 0x33, 0x44}; - srslte::byte_buffer_t pdu = make_pdu_and_log(tv); + srsran::byte_buffer_t pdu = make_pdu_and_log(tv); // unpack PDU rlc_am_nr_pdu_header_t header = {}; - TESTASSERT(rlc_am_nr_read_data_pdu_header(&pdu, srslte::rlc_am_nr_sn_size_t::size12bits, &header) != 0); + TESTASSERT(rlc_am_nr_read_data_pdu_header(&pdu, srsran::rlc_am_nr_sn_size_t::size12bits, &header) != 0); TESTASSERT(header.si == rlc_nr_si_field_t::last_segment); TESTASSERT(header.sn == 1028); TESTASSERT(header.so == 1028); @@ -151,7 +151,7 @@ int rlc_am_nr_pdu_test3() TESTASSERT(memcmp(pdu.msg, tv.data(), pdu.N_bytes) == 0); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // RLC AM PDU 18bit full SDU with P flag and SN 0x100000001000000010 (131586) @@ -159,11 +159,11 @@ int rlc_am_nr_pdu_test4() { const int header_len = 3, payload_len = 4; std::array tv = {0xc2, 0x02, 0x02, 0x11, 0x22, 0x33, 0x44}; - srslte::byte_buffer_t pdu = make_pdu_and_log(tv); + srsran::byte_buffer_t pdu = make_pdu_and_log(tv); // unpack PDU rlc_am_nr_pdu_header_t header = {}; - TESTASSERT(rlc_am_nr_read_data_pdu_header(&pdu, srslte::rlc_am_nr_sn_size_t::size18bits, &header) != 0); + TESTASSERT(rlc_am_nr_read_data_pdu_header(&pdu, srsran::rlc_am_nr_sn_size_t::size18bits, &header) != 0); TESTASSERT(header.si == rlc_nr_si_field_t::full_sdu); TESTASSERT(header.sn == 131586); TESTASSERT(header.so == 0); @@ -179,7 +179,7 @@ int rlc_am_nr_pdu_test4() TESTASSERT(memcmp(pdu.msg, tv.data(), pdu.N_bytes) == 0); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // RLC AM PDU 18bit middle part of SDU (SO 514) without P flag and SN 131327 @@ -187,11 +187,11 @@ int rlc_am_nr_pdu_test5() { const int header_len = 5, payload_len = 4; std::array tv = {0xb2, 0x00, 0xff, 0x02, 0x02, 0x11, 0x22, 0x33, 0x44}; - srslte::byte_buffer_t pdu = make_pdu_and_log(tv); + srsran::byte_buffer_t pdu = make_pdu_and_log(tv); // unpack PDU rlc_am_nr_pdu_header_t header = {}; - TESTASSERT(rlc_am_nr_read_data_pdu_header(&pdu, srslte::rlc_am_nr_sn_size_t::size18bits, &header) != 0); + TESTASSERT(rlc_am_nr_read_data_pdu_header(&pdu, srsran::rlc_am_nr_sn_size_t::size18bits, &header) != 0); TESTASSERT(header.si == rlc_nr_si_field_t::neither_first_nor_last_segment); TESTASSERT(header.sn == 131327); TESTASSERT(header.so == 514); @@ -207,7 +207,7 @@ int rlc_am_nr_pdu_test5() TESTASSERT(memcmp(pdu.msg, tv.data(), pdu.N_bytes) == 0); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Malformed RLC AM PDU 18bit with reserved bits set @@ -215,14 +215,14 @@ int rlc_am_nr_pdu_test6() { const int header_len = 5, payload_len = 4; std::array tv = {0xb7, 0x00, 0xff, 0x02, 0x02, 0x11, 0x22, 0x33, 0x44}; - srslte::byte_buffer_t pdu = make_pdu_and_log(tv); + srsran::byte_buffer_t pdu = make_pdu_and_log(tv); // unpack PDU rlc_am_nr_pdu_header_t header = {}; - TESTASSERT(rlc_am_nr_read_data_pdu_header(&pdu, srslte::rlc_am_nr_sn_size_t::size18bits, &header) == 0); + TESTASSERT(rlc_am_nr_read_data_pdu_header(&pdu, srsran::rlc_am_nr_sn_size_t::size18bits, &header) == 0); TESTASSERT(header.sn == 0); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } ///< Control PDU tests @@ -231,13 +231,13 @@ int rlc_am_nr_control_pdu_test1() { const int len = 3; std::array tv = {0x08, 0x11, 0x00}; - srslte::byte_buffer_t pdu = make_pdu_and_log(tv); + srsran::byte_buffer_t pdu = make_pdu_and_log(tv); TESTASSERT(rlc_am_is_control_pdu(pdu.msg) == true); // unpack PDU rlc_am_nr_status_pdu_t status_pdu = {}; - TESTASSERT(rlc_am_nr_read_status_pdu(&pdu, srslte::rlc_am_nr_sn_size_t::size12bits, &status_pdu) == SRSLTE_SUCCESS); + TESTASSERT(rlc_am_nr_read_status_pdu(&pdu, srsran::rlc_am_nr_sn_size_t::size12bits, &status_pdu) == SRSRAN_SUCCESS); TESTASSERT(status_pdu.ack_sn == 2065); TESTASSERT(status_pdu.N_nack == 0); @@ -245,14 +245,14 @@ int rlc_am_nr_control_pdu_test1() pdu.clear(); // pack again - TESTASSERT(rlc_am_nr_write_status_pdu(status_pdu, srslte::rlc_am_nr_sn_size_t::size12bits, &pdu) == SRSLTE_SUCCESS); + TESTASSERT(rlc_am_nr_write_status_pdu(status_pdu, srsran::rlc_am_nr_sn_size_t::size12bits, &pdu) == SRSRAN_SUCCESS); TESTASSERT(pdu.N_bytes == tv.size()); write_pdu_to_pcap(4, pdu.msg, pdu.N_bytes); TESTASSERT(memcmp(pdu.msg, tv.data(), pdu.N_bytes) == 0); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Status PDU for 12bit SN with ACK_SN=2065 and NACK_SN=273 (E1 bit set) @@ -260,13 +260,13 @@ int rlc_am_nr_control_pdu_test2() { const int len = 5; std::array tv = {0x08, 0x11, 0x80, 0x11, 0x10}; - srslte::byte_buffer_t pdu = make_pdu_and_log(tv); + srsran::byte_buffer_t pdu = make_pdu_and_log(tv); TESTASSERT(rlc_am_is_control_pdu(pdu.msg) == true); // unpack PDU rlc_am_nr_status_pdu_t status_pdu = {}; - TESTASSERT(rlc_am_nr_read_status_pdu(&pdu, srslte::rlc_am_nr_sn_size_t::size12bits, &status_pdu) == SRSLTE_SUCCESS); + TESTASSERT(rlc_am_nr_read_status_pdu(&pdu, srsran::rlc_am_nr_sn_size_t::size12bits, &status_pdu) == SRSRAN_SUCCESS); TESTASSERT(status_pdu.ack_sn == 2065); TESTASSERT(status_pdu.N_nack == 1); TESTASSERT(status_pdu.nacks[0].nack_sn == 273); @@ -275,20 +275,20 @@ int rlc_am_nr_control_pdu_test2() pdu.clear(); // pack again - TESTASSERT(rlc_am_nr_write_status_pdu(status_pdu, srslte::rlc_am_nr_sn_size_t::size12bits, &pdu) == SRSLTE_SUCCESS); + TESTASSERT(rlc_am_nr_write_status_pdu(status_pdu, srsran::rlc_am_nr_sn_size_t::size12bits, &pdu) == SRSRAN_SUCCESS); // TESTASSERT(pdu.N_bytes == tv.size()); write_pdu_to_pcap(4, pdu.msg, pdu.N_bytes); TESTASSERT(memcmp(pdu.msg, tv.data(), pdu.N_bytes) == 0); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int main(int argc, char** argv) { #if PCAP - pcap_handle = std::unique_ptr(new srslte::mac_nr_pcap()); + pcap_handle = std::unique_ptr(new srsran::mac_nr_pcap()); pcap_handle->open("rlc_am_nr_pdu_test.pcap"); #endif @@ -296,43 +296,43 @@ int main(int argc, char** argv) if (rlc_am_nr_pdu_test1()) { fprintf(stderr, "rlc_am_nr_pdu_test1() failed.\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (rlc_am_nr_pdu_test2()) { fprintf(stderr, "rlc_am_nr_pdu_test2() failed.\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (rlc_am_nr_pdu_test3()) { fprintf(stderr, "rlc_am_nr_pdu_test3() failed.\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (rlc_am_nr_pdu_test4()) { fprintf(stderr, "rlc_am_nr_pdu_test4() failed.\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (rlc_am_nr_pdu_test5()) { fprintf(stderr, "rlc_am_nr_pdu_test5() failed.\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (rlc_am_nr_pdu_test6()) { fprintf(stderr, "rlc_am_nr_pdu_test6() failed.\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (rlc_am_nr_control_pdu_test1()) { fprintf(stderr, "rlc_am_nr_control_pdu_test1() failed.\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (rlc_am_nr_control_pdu_test2()) { fprintf(stderr, "rlc_am_nr_control_pdu_test2() failed.\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } diff --git a/lib/test/upper/rlc_am_test.cc b/lib/test/upper/rlc_am_test.cc index 35bc611e2..649cde13e 100644 --- a/lib/test/upper/rlc_am_test.cc +++ b/lib/test/upper/rlc_am_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,20 +10,20 @@ * */ -#include "srslte/common/buffer_pool.h" -#include "srslte/common/rlc_pcap.h" -#include "srslte/common/test_common.h" -#include "srslte/common/threads.h" -#include "srslte/interfaces/ue_pdcp_interfaces.h" -#include "srslte/interfaces/ue_rrc_interfaces.h" -#include "srslte/upper/rlc_am_lte.h" +#include "srsran/common/buffer_pool.h" +#include "srsran/common/rlc_pcap.h" +#include "srsran/common/test_common.h" +#include "srsran/common/threads.h" +#include "srsran/interfaces/ue_pdcp_interfaces.h" +#include "srsran/interfaces/ue_rrc_interfaces.h" +#include "srsran/upper/rlc_am_lte.h" #define NBUFS 5 #define HAVE_PCAP 0 #define SDU_SIZE 500 using namespace srsue; -using namespace srslte; +using namespace srsran; bool rx_is_tx(const rlc_bearer_metrics_t& rlc1_metrics, const rlc_bearer_metrics_t& rlc2_metrics) { @@ -51,8 +51,8 @@ public: void write_pdu_bcch_bch(unique_byte_buffer_t sdu) {} void write_pdu_bcch_dlsch(unique_byte_buffer_t sdu) {} void write_pdu_pcch(unique_byte_buffer_t sdu) {} - void write_pdu_mch(uint32_t lcid, srslte::unique_byte_buffer_t pdu) {} - void notify_delivery(uint32_t lcid, const srslte::pdcp_sn_vector_t& pdcp_sn_vec) + void write_pdu_mch(uint32_t lcid, srsran::unique_byte_buffer_t pdu) {} + void notify_delivery(uint32_t lcid, const srsran::pdcp_sn_vector_t& pdcp_sn_vec) { assert(lcid == 1); for (uint32_t pdcp_sn : pdcp_sn_vec) { @@ -62,7 +62,7 @@ public: notified_counts[pdcp_sn] += 1; } } - void notify_failure(uint32_t lcid, const srslte::pdcp_sn_vector_t& pdcp_sn_vec) + void notify_failure(uint32_t lcid, const srsran::pdcp_sn_vector_t& pdcp_sn_vec) { assert(lcid == 1); // TODO @@ -102,7 +102,7 @@ private: int sn = 0; running = true; while (running) { - unique_byte_buffer_t pdu = srslte::make_byte_buffer(); + unique_byte_buffer_t pdu = srsran::make_byte_buffer(); if (!pdu) { printf("Error: Could not allocate PDU in rlc_tester::run_thread\n\n\n"); // backoff for a bit @@ -128,7 +128,7 @@ int basic_test_tx(rlc_am_lte* rlc, byte_buffer_t pdu_bufs[NBUFS]) // Push 5 SDUs into RLC1 unique_byte_buffer_t sdu_bufs[NBUFS]; for (int i = 0; i < NBUFS; i++) { - sdu_bufs[i] = srslte::make_byte_buffer(); + sdu_bufs[i] = srsran::make_byte_buffer(); sdu_bufs[i]->msg[0] = i; // Write the index into the buffer sdu_bufs[i]->N_bytes = 1; // Give each buffer a size of 1 byte sdu_bufs[i]->md.pdcp_sn = i; // PDCP SN for notifications @@ -145,7 +145,7 @@ int basic_test_tx(rlc_am_lte* rlc, byte_buffer_t pdu_bufs[NBUFS]) } TESTASSERT(0 == rlc->get_buffer_state()); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int basic_test() @@ -203,13 +203,13 @@ int basic_test() // Check statistics TESTASSERT(rx_is_tx(rlc1.get_metrics(), rlc2.get_metrics())); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int concat_test() { rlc_am_tester tester; - srslte::timer_handler timers(8); + srsran::timer_handler timers(8); rlc_am_lte rlc1(srslog::fetch_basic_logger("RLC_AM_1"), 1, &tester, &tester, &timers); rlc_am_lte rlc2(srslog::fetch_basic_logger("RLC_AM_2"), 1, &tester, &tester, &timers); @@ -225,7 +225,7 @@ int concat_test() // Push 5 SDUs into RLC1 unique_byte_buffer_t sdu_bufs[NBUFS]; for (int i = 0; i < NBUFS; i++) { - sdu_bufs[i] = srslte::make_byte_buffer(); + sdu_bufs[i] = srsran::make_byte_buffer(); sdu_bufs[i]->msg[0] = i; // Write the index into the buffer sdu_bufs[i]->N_bytes = 1; // Give each buffer a size of 1 byte sdu_bufs[i]->md.pdcp_sn = i; // PDCP SN for notifications @@ -277,13 +277,13 @@ int concat_test() // Check statistics TESTASSERT(rx_is_tx(rlc1.get_metrics(), rlc2.get_metrics())); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int segment_test(bool in_seq_rx) { rlc_am_tester tester; - srslte::timer_handler timers(8); + srsran::timer_handler timers(8); int len = 0; rlc_am_lte rlc1(srslog::fetch_basic_logger("RLC_AM_1"), 1, &tester, &tester, &timers); @@ -300,7 +300,7 @@ int segment_test(bool in_seq_rx) // Push 5 SDUs into RLC1 unique_byte_buffer_t sdu_bufs[NBUFS]; for (int i = 0; i < NBUFS; i++) { - sdu_bufs[i] = srslte::make_byte_buffer(); + sdu_bufs[i] = srsran::make_byte_buffer(); for (int j = 0; j < 10; j++) sdu_bufs[i]->msg[j] = j; sdu_bufs[i]->N_bytes = 10; // Give each buffer a size of 10 bytes @@ -372,7 +372,7 @@ int segment_test(bool in_seq_rx) // Check statistics TESTASSERT(rx_is_tx(rlc1.get_metrics(), rlc2.get_metrics())); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int retx_test() @@ -395,7 +395,7 @@ int retx_test() // Push 5 SDUs into RLC1 unique_byte_buffer_t sdu_bufs[NBUFS]; for (int i = 0; i < NBUFS; i++) { - sdu_bufs[i] = srslte::make_byte_buffer(); + sdu_bufs[i] = srsran::make_byte_buffer(); sdu_bufs[i]->msg[0] = i; // Write the index into the buffer sdu_bufs[i]->N_bytes = 1; // Give each buffer a size of 1 byte sdu_bufs[i]->md.pdcp_sn = i; // PDCP SN for notifications @@ -528,7 +528,7 @@ int max_retx_test() const uint32_t n_sdus = 2; unique_byte_buffer_t sdu_bufs[n_sdus]; for (uint32_t i = 0; i < n_sdus; i++) { - sdu_bufs[i] = srslte::make_byte_buffer(); + sdu_bufs[i] = srsran::make_byte_buffer(); sdu_bufs[i]->msg[0] = i; // Write the index into the buffer sdu_bufs[i]->N_bytes = 1; // Give each buffer a size of 1 byte sdu_bufs[i]->md.pdcp_sn = i; // PDCP SN for notifications @@ -570,7 +570,7 @@ int max_retx_test() // Now maxRetx should have been triggered TESTASSERT(tester.max_retx_triggered == true); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Purpose: test correct retx of lost segment and pollRetx timer expiration @@ -596,7 +596,7 @@ int segment_retx_test() unique_byte_buffer_t sdu_bufs[nof_sdus]; for (uint32_t i = 0; i < nof_sdus; i++) { - sdu_bufs[i] = srslte::make_byte_buffer(); + sdu_bufs[i] = srsran::make_byte_buffer(); sdu_bufs[i]->N_bytes = 10; // Give each buffer a size of 10 bytes std::fill(sdu_bufs[i]->msg, sdu_bufs[i]->msg + sdu_bufs[i]->N_bytes, 0); sdu_bufs[i]->msg[0] = i; // Write the index into the buffer @@ -684,14 +684,14 @@ int segment_retx_test() TESTASSERT(tester.sdus.size() == nof_sdus); for (uint32_t i = 0; i < tester.sdus.size(); i++) { if (tester.sdus[i]->N_bytes != 10) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (*(tester.sdus[i]->msg) != i) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int resegment_test_1() @@ -718,7 +718,7 @@ int resegment_test_1() // Push 5 SDUs into RLC1 unique_byte_buffer_t sdu_bufs[NBUFS]; for (int i = 0; i < NBUFS; i++) { - sdu_bufs[i] = srslte::make_byte_buffer(); + sdu_bufs[i] = srsran::make_byte_buffer(); for (int j = 0; j < 10; j++) sdu_bufs[i]->msg[j] = j; sdu_bufs[i]->N_bytes = 10; // Give each buffer a size of 10 bytes @@ -875,7 +875,7 @@ int resegment_test_2() // Push 5 SDUs into RLC1 unique_byte_buffer_t sdu_bufs[NBUFS]; for (int i = 0; i < NBUFS; i++) { - sdu_bufs[i] = srslte::make_byte_buffer(); + sdu_bufs[i] = srsran::make_byte_buffer(); for (int j = 0; j < 10; j++) sdu_bufs[i]->msg[j] = j; sdu_bufs[i]->N_bytes = 10; // Give each buffer a size of 10 bytes @@ -991,7 +991,7 @@ int resegment_test_3() // Retx PDU segments: | 10 | 10 | rlc_am_tester tester; - srslte::timer_handler timers(8); + srsran::timer_handler timers(8); rlc_am_lte rlc1(srslog::fetch_basic_logger("RLC_AM_1"), 1, &tester, &tester, &timers); rlc_am_lte rlc2(srslog::fetch_basic_logger("RLC_AM_2"), 1, &tester, &tester, &timers); @@ -1007,7 +1007,7 @@ int resegment_test_3() // Push 5 SDUs into RLC1 unique_byte_buffer_t sdu_bufs[NBUFS]; for (int i = 0; i < NBUFS; i++) { - sdu_bufs[i] = srslte::make_byte_buffer(); + sdu_bufs[i] = srsran::make_byte_buffer(); for (int j = 0; j < 10; j++) sdu_bufs[i]->msg[j] = j; sdu_bufs[i]->N_bytes = 10; // Give each buffer a size of 10 bytes @@ -1121,7 +1121,7 @@ int resegment_test_4() // Retx PDU segments: | 15 | 15 | rlc_am_tester tester; - srslte::timer_handler timers(8); + srsran::timer_handler timers(8); rlc_am_lte rlc1(srslog::fetch_basic_logger("RLC_AM_1"), 1, &tester, &tester, &timers); rlc_am_lte rlc2(srslog::fetch_basic_logger("RLC_AM_2"), 1, &tester, &tester, &timers); @@ -1137,7 +1137,7 @@ int resegment_test_4() // Push 5 SDUs into RLC1 unique_byte_buffer_t sdu_bufs[NBUFS]; for (int i = 0; i < NBUFS; i++) { - sdu_bufs[i] = srslte::make_byte_buffer(); + sdu_bufs[i] = srsran::make_byte_buffer(); for (int j = 0; j < 10; j++) sdu_bufs[i]->msg[j] = j; sdu_bufs[i]->N_bytes = 10; // Give each buffer a size of 10 bytes @@ -1253,7 +1253,7 @@ int resegment_test_5() // Retx PDU segments: | 20 | 20 | rlc_am_tester tester; - srslte::timer_handler timers(8); + srsran::timer_handler timers(8); rlc_am_lte rlc1(srslog::fetch_basic_logger("RLC_AM_1"), 1, &tester, &tester, &timers); rlc_am_lte rlc2(srslog::fetch_basic_logger("RLC_AM_2"), 1, &tester, &tester, &timers); @@ -1269,7 +1269,7 @@ int resegment_test_5() // Push 5 SDUs into RLC1 unique_byte_buffer_t sdu_bufs[NBUFS]; for (int i = 0; i < NBUFS; i++) { - sdu_bufs[i] = srslte::make_byte_buffer(); + sdu_bufs[i] = srsran::make_byte_buffer(); for (int j = 0; j < 10; j++) { sdu_bufs[i]->msg[j] = i; } @@ -1379,7 +1379,7 @@ int resegment_test_6() // Retx PDU segments: | 120 | 150 | rlc_am_tester tester; - srslte::timer_handler timers(8); + srsran::timer_handler timers(8); int len = 0; rlc_am_lte rlc1(srslog::fetch_basic_logger("RLC_AM_1"), 1, &tester, &tester, &timers); @@ -1396,7 +1396,7 @@ int resegment_test_6() // Push SDUs into RLC1 unique_byte_buffer_t sdu_bufs[9]; for (int i = 0; i < 3; i++) { - sdu_bufs[i] = srslte::make_byte_buffer(); + sdu_bufs[i] = srsran::make_byte_buffer(); for (int j = 0; j < 10; j++) sdu_bufs[i]->msg[j] = j; sdu_bufs[i]->N_bytes = 10; // Give each buffer a size of 10 bytes @@ -1404,7 +1404,7 @@ int resegment_test_6() rlc1.write_sdu(std::move(sdu_bufs[i])); } for (int i = 3; i < 9; i++) { - sdu_bufs[i] = srslte::make_byte_buffer(); + sdu_bufs[i] = srsran::make_byte_buffer(); for (int j = 0; j < 54; j++) sdu_bufs[i]->msg[j] = j; sdu_bufs[i]->N_bytes = 54; @@ -1495,7 +1495,7 @@ int resegment_test_6() } for (uint32_t i = 3; i < 9; i++) { if (i >= tester.sdus.size()) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } TESTASSERT(tester.sdus[i]->N_bytes == 54); for (int j = 0; j < 54; j++) { @@ -1549,7 +1549,7 @@ int resegment_test_7() #else rlc_am_tester tester(NULL); #endif - srslte::timer_handler timers(8); + srsran::timer_handler timers(8); rlc_am_lte rlc1(srslog::fetch_basic_logger("RLC_AM_1"), 1, &tester, &tester, &timers); rlc_am_lte rlc2(srslog::fetch_basic_logger("RLC_AM_2"), 1, &tester, &tester, &timers); @@ -1565,7 +1565,7 @@ int resegment_test_7() // Push 2 SDUs into RLC1 unique_byte_buffer_t sdu_bufs[N_SDU_BUFS]; for (uint32_t i = 0; i < N_SDU_BUFS; i++) { - sdu_bufs[i] = srslte::make_byte_buffer(); + sdu_bufs[i] = srsran::make_byte_buffer(); for (uint32_t j = 0; j < sdu_size; j++) { sdu_bufs[i]->msg[j] = i; } @@ -1734,7 +1734,7 @@ int resegment_test_8() #else rlc_am_tester tester(NULL); #endif - srslte::timer_handler timers(8); + srsran::timer_handler timers(8); rlc_am_lte rlc1(srslog::fetch_basic_logger("RLC_AM_1"), 1, &tester, &tester, &timers); rlc_am_lte rlc2(srslog::fetch_basic_logger("RLC_AM_2"), 1, &tester, &tester, &timers); @@ -1750,7 +1750,7 @@ int resegment_test_8() // Push 2 SDUs into RLC1 unique_byte_buffer_t sdu_bufs[N_SDU_BUFS]; for (uint32_t i = 0; i < N_SDU_BUFS; i++) { - sdu_bufs[i] = srslte::make_byte_buffer(); + sdu_bufs[i] = srsran::make_byte_buffer(); for (uint32_t j = 0; j < sdu_size; j++) { sdu_bufs[i]->msg[j] = i; } @@ -1886,24 +1886,24 @@ int resegment_test_9() #else rlc_am_tester tester(NULL); #endif - srslte::timer_handler timers(8); + srsran::timer_handler timers(8); rlc_am_lte rlc1(srslog::fetch_basic_logger("RLC_AM_1"), 1, &tester, &tester, &timers); rlc_am_lte rlc2(srslog::fetch_basic_logger("RLC_AM_2"), 1, &tester, &tester, &timers); if (not rlc1.configure(config)) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (not rlc2.configure(config)) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Push 3 SDUs into RLC1 const uint32_t n_bufs = 3; unique_byte_buffer_t sdu_bufs[n_bufs]; for (uint32_t i = 0; i < n_bufs; i++) { - sdu_bufs[i] = srslte::make_byte_buffer(); + sdu_bufs[i] = srsran::make_byte_buffer(); for (uint32_t j = 0; j < 10; j++) { sdu_bufs[i]->msg[j] = i; } @@ -2028,24 +2028,24 @@ int resegment_test_10() #else rlc_am_tester tester(NULL); #endif - srslte::timer_handler timers(8); + srsran::timer_handler timers(8); rlc_am_lte rlc1(srslog::fetch_basic_logger("RLC_AM_1"), 1, &tester, &tester, &timers); rlc_am_lte rlc2(srslog::fetch_basic_logger("RLC_AM_2"), 1, &tester, &tester, &timers); if (not rlc1.configure(config)) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (not rlc2.configure(config)) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Push 3 SDUs into RLC1 const uint32_t n_sdus = 4; unique_byte_buffer_t sdu_bufs[n_sdus]; for (uint32_t i = 0; i < n_sdus; i++) { - sdu_bufs[i] = srslte::make_byte_buffer(); + sdu_bufs[i] = srsran::make_byte_buffer(); for (uint32_t j = 0; j < 10; j++) { sdu_bufs[i]->msg[j] = i; } @@ -2134,7 +2134,7 @@ int resegment_test_10() TESTASSERT(it != tester.notified_counts.end() && tester.notified_counts[i] == 1); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Custom resegmentation test of a orignal PDU with N_li=2 @@ -2177,24 +2177,24 @@ int resegment_test_11() #else rlc_am_tester tester(NULL); #endif - srslte::timer_handler timers(8); + srsran::timer_handler timers(8); rlc_am_lte rlc1(srslog::fetch_basic_logger("RLC_AM_1"), 1, &tester, &tester, &timers); rlc_am_lte rlc2(srslog::fetch_basic_logger("RLC_AM_2"), 1, &tester, &tester, &timers); if (not rlc1.configure(config)) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (not rlc2.configure(config)) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Push 4 SDUs into RLC1 const uint32_t n_sdus = 4; unique_byte_buffer_t sdu_bufs[n_sdus]; for (uint32_t i = 0; i < n_sdus; i++) { - sdu_bufs[i] = srslte::make_byte_buffer(); + sdu_bufs[i] = srsran::make_byte_buffer(); for (uint32_t j = 0; j < 10; j++) { sdu_bufs[i]->msg[j] = i; } @@ -2288,7 +2288,7 @@ int resegment_test_11() pcap.close(); #endif - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Custom resegmentation test of a orignal PDU with N_li=2 @@ -2335,24 +2335,24 @@ int resegment_test_12() #else rlc_am_tester tester(NULL); #endif - srslte::timer_handler timers(8); + srsran::timer_handler timers(8); rlc_am_lte rlc1(srslog::fetch_basic_logger("RLC_AM_1"), 1, &tester, &tester, &timers); rlc_am_lte rlc2(srslog::fetch_basic_logger("RLC_AM_2"), 1, &tester, &tester, &timers); if (not rlc1.configure(config)) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (not rlc2.configure(config)) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Push 4 SDUs into RLC1 const uint32_t n_sdus = 4; unique_byte_buffer_t sdu_bufs[n_sdus]; for (uint32_t i = 0; i < n_sdus; i++) { - sdu_bufs[i] = srslte::make_byte_buffer(); + sdu_bufs[i] = srsran::make_byte_buffer(); for (uint32_t j = 0; j < 10; j++) { sdu_bufs[i]->msg[j] = i; } @@ -2444,12 +2444,12 @@ int resegment_test_12() pcap.close(); #endif - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Series of header reconstruction tests that all used canned TV generated with the rlc_stress_test // In this particular case, check correct reconstruction of headers after 2 segment retx -int header_reconstruction_test(srslte::log_sink_message_spy& spy) +int header_reconstruction_test(srsran::log_sink_message_spy& spy) { /// Original SN=277 with 3 segments, including full SDU with 24 /// 13:35:16.337011 [RLC_1] [I] DRB1 Tx PDU SN=277 (20 B) @@ -2479,7 +2479,7 @@ int header_reconstruction_test(srslte::log_sink_message_spy& spy) #else rlc_am_tester tester(NULL); #endif - srslte::timer_handler timers(8); + srsran::timer_handler timers(8); rlc_am_lte rlc1(srslog::fetch_basic_logger("RLC_AM_1"), 1, &tester, &tester, &timers); @@ -2506,7 +2506,7 @@ int header_reconstruction_test(srslte::log_sink_message_spy& spy) } // Check correct reconstruction of headers after 3 segment retx -int header_reconstruction_test2(srslte::log_sink_message_spy& spy) +int header_reconstruction_test2(srsran::log_sink_message_spy& spy) { /// Original SN=199 with 3 segments, including full SDU with d4 /// 15:19:19.148272 [RLC_1] [I] DRB1 Tx PDU SN=199 (19 B) @@ -2542,7 +2542,7 @@ int header_reconstruction_test2(srslte::log_sink_message_spy& spy) #else rlc_am_tester tester(NULL); #endif - srslte::timer_handler timers(8); + srsran::timer_handler timers(8); rlc_am_lte rlc1(srslog::fetch_basic_logger("RLC_AM_1"), 1, &tester, &tester, &timers); if (not rlc1.configure(rlc_config_t::default_rlc_am_config())) { @@ -2566,11 +2566,11 @@ int header_reconstruction_test2(srslte::log_sink_message_spy& spy) pcap.close(); #endif - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // TC with 3 segment retx -int header_reconstruction_test3(srslte::log_sink_message_spy& spy) +int header_reconstruction_test3(srsran::log_sink_message_spy& spy) { // Original PDU // 11:13:25.994566 [RLC_1] [I] DRB1 Tx PDU SN=206 (18 B) @@ -2605,7 +2605,7 @@ int header_reconstruction_test3(srslte::log_sink_message_spy& spy) #else rlc_am_tester tester(NULL); #endif - srslte::timer_handler timers(8); + srsran::timer_handler timers(8); // configure RLC rlc_am_lte rlc1(srslog::fetch_basic_logger("RLC_AM_1"), 1, &tester, &tester, &timers); @@ -2628,10 +2628,10 @@ int header_reconstruction_test3(srslte::log_sink_message_spy& spy) pcap.close(); #endif - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int header_reconstruction_test4(srslte::log_sink_message_spy& spy) +int header_reconstruction_test4(srsran::log_sink_message_spy& spy) { // Original PDU // 15:32:20.667043 [RLC_1] [I] DRB1 Tx PDU SN=172 (22 B) @@ -2691,7 +2691,7 @@ int header_reconstruction_test4(srslte::log_sink_message_spy& spy) #else rlc_am_tester tester(NULL); #endif - srslte::timer_handler timers(8); + srsran::timer_handler timers(8); // configure RLC rlc_am_lte rlc1(srslog::fetch_basic_logger("RLC_AM_1"), 1, &tester, &tester, &timers); @@ -2718,10 +2718,10 @@ int header_reconstruction_test4(srslte::log_sink_message_spy& spy) pcap.close(); #endif - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int header_reconstruction_test5(srslte::log_sink_message_spy& spy) +int header_reconstruction_test5(srsran::log_sink_message_spy& spy) { // Original PDU: // 18:46:22.372858 [RLC_1] [I] DRB1 Tx PDU SN=222 (22 B) @@ -2768,7 +2768,7 @@ int header_reconstruction_test5(srslte::log_sink_message_spy& spy) #else rlc_am_tester tester(NULL); #endif - srslte::timer_handler timers(8); + srsran::timer_handler timers(8); // configure RLC rlc_am_lte rlc1(srslog::fetch_basic_logger("RLC_AM_1"), 1, &tester, &tester, &timers); @@ -2794,10 +2794,10 @@ int header_reconstruction_test5(srslte::log_sink_message_spy& spy) pcap.close(); #endif - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int header_reconstruction_test6(srslte::log_sink_message_spy& spy) +int header_reconstruction_test6(srsran::log_sink_message_spy& spy) { // Original PDU: // 21:50:12.709646 [RLC_1] [I] DRB1 Tx PDU SN=509 (20 B) @@ -2847,7 +2847,7 @@ int header_reconstruction_test6(srslte::log_sink_message_spy& spy) #else rlc_am_tester tester(NULL); #endif - srslte::timer_handler timers(8); + srsran::timer_handler timers(8); // configure RLC rlc_am_lte rlc1(srslog::fetch_basic_logger("RLC_AM_1"), 1, &tester, &tester, &timers); @@ -2873,10 +2873,10 @@ int header_reconstruction_test6(srslte::log_sink_message_spy& spy) pcap.close(); #endif - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int header_reconstruction_test7(srslte::log_sink_message_spy& spy) +int header_reconstruction_test7(srsran::log_sink_message_spy& spy) { // Original PDU: // 22:14:54.646530 [RLC_1] [I] DRB1 Tx PDU SN=282 (19 B) @@ -2946,7 +2946,7 @@ int header_reconstruction_test7(srslte::log_sink_message_spy& spy) #else rlc_am_tester tester(NULL); #endif - srslte::timer_handler timers(8); + srsran::timer_handler timers(8); // configure RLC rlc_am_lte rlc1(srslog::fetch_basic_logger("RLC_AM_1"), 1, &tester, &tester, &timers); @@ -2976,10 +2976,10 @@ int header_reconstruction_test7(srslte::log_sink_message_spy& spy) pcap.close(); #endif - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int header_reconstruction_test8(srslte::log_sink_message_spy& spy) +int header_reconstruction_test8(srsran::log_sink_message_spy& spy) { // Original PDU: // 21:23:34.407718 [RLC_1] [I] DRB1 Tx PDU SN=423 (40 B) @@ -3048,7 +3048,7 @@ int header_reconstruction_test8(srslte::log_sink_message_spy& spy) #else rlc_am_tester tester(NULL); #endif - srslte::timer_handler timers(8); + srsran::timer_handler timers(8); // configure RLC rlc_am_lte rlc1(srslog::fetch_basic_logger("RLC_AM_1"), 1, &tester, &tester, &timers); @@ -3073,13 +3073,13 @@ int header_reconstruction_test8(srslte::log_sink_message_spy& spy) // Check RLC re-assembled message header TESTASSERT(spy.has_message("[Data PDU, RF=0, P=1, FI=1, SN=423, LSF=0, SO=0, N_li=3 (3, 10, 10)]")); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } bool reset_test() { rlc_am_tester tester; - srslte::timer_handler timers(8); + srsran::timer_handler timers(8); int len = 0; rlc_am_lte rlc1(srslog::fetch_basic_logger("RLC_AM_1"), 1, &tester, &tester, &timers); @@ -3089,7 +3089,7 @@ bool reset_test() } // Push 1 SDU of size 10 into RLC1 - unique_byte_buffer_t sdu_buf = srslte::make_byte_buffer(); + unique_byte_buffer_t sdu_buf = srsran::make_byte_buffer(); sdu_buf->N_bytes = 100; std::fill(sdu_buf->msg, sdu_buf->msg + sdu_buf->N_bytes, 0); sdu_buf->msg[0] = 1; // Write the index into the buffer @@ -3121,7 +3121,7 @@ bool reset_test() bool resume_test() { rlc_am_tester tester; - srslte::timer_handler timers(8); + srsran::timer_handler timers(8); int len = 0; rlc_am_lte rlc1(srslog::fetch_basic_logger("RLC_AM_1"), 1, &tester, &tester, &timers); @@ -3131,7 +3131,7 @@ bool resume_test() } // Push 1 SDU of size 10 into RLC1 - unique_byte_buffer_t sdu_buf = srslte::make_byte_buffer(); + unique_byte_buffer_t sdu_buf = srsran::make_byte_buffer(); sdu_buf->N_bytes = 100; std::fill(sdu_buf->msg, sdu_buf->msg + sdu_buf->N_bytes, 0); sdu_buf->msg[0] = 1; // Write the index into the buffer @@ -3163,7 +3163,7 @@ bool resume_test() bool stop_test() { rlc_am_tester tester; - srslte::timer_handler timers(8); + srsran::timer_handler timers(8); rlc_am_lte rlc1(srslog::fetch_basic_logger("RLC_AM_1"), 1, &tester, &tester, &timers); @@ -3189,7 +3189,7 @@ bool stop_test() bool status_pdu_test() { rlc_am_tester tester; - srslte::timer_handler timers(8); + srsran::timer_handler timers(8); int len = 0; rlc_am_lte rlc1(srslog::fetch_basic_logger("RLC_AM_1"), 1, &tester, &tester, &timers); @@ -3207,7 +3207,7 @@ bool status_pdu_test() const uint32_t n_sdus = 10; unique_byte_buffer_t sdu_bufs[n_sdus]; for (uint32_t i = 0; i < n_sdus; i++) { - sdu_bufs[i] = srslte::make_byte_buffer(); + sdu_bufs[i] = srsran::make_byte_buffer(); sdu_bufs[i]->N_bytes = 1; // Give each buffer a size of 1 byte sdu_bufs[i]->msg[0] = i; // Write the index into the buffer rlc1.write_sdu(std::move(sdu_bufs[i])); @@ -3289,7 +3289,7 @@ bool status_pdu_test() TESTASSERT(tester.sdus[i]->N_bytes == 1); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // This test checks the correct functioning of RLC reestablishment @@ -3305,7 +3305,7 @@ bool reestablish_test() rlc_am_tester tester(NULL); #endif - srslte::timer_handler timers(8); + srsran::timer_handler timers(8); rlc_am_lte rlc1(srslog::fetch_basic_logger("RLC_AM_1"), 1, &tester, &tester, &timers); rlc_am_lte rlc2(srslog::fetch_basic_logger("RLC_AM_2"), 1, &tester, &tester, &timers); @@ -3331,7 +3331,7 @@ bool reestablish_test() // Create a few SDUs and write to RLC1 to make sure buffers aren't empty after tx one PDU for (uint32_t i = num_tx_pdus; i < 5; ++i) { // Write SDU - unique_byte_buffer_t sdu = srslte::make_byte_buffer(); + unique_byte_buffer_t sdu = srsran::make_byte_buffer(); TESTASSERT(sdu != nullptr); sdu->N_bytes = 5; // Give each buffer a size of 1 byte for (uint32_t k = 0; k < sdu->N_bytes; ++k) { @@ -3343,7 +3343,7 @@ bool reestablish_test() for (uint32_t i = num_tx_pdus; i < total_num_tx_pdus; i++) { // Write SDU - unique_byte_buffer_t sdu = srslte::make_byte_buffer(); + unique_byte_buffer_t sdu = srsran::make_byte_buffer(); TESTASSERT(sdu != nullptr); sdu->N_bytes = 5; // Give each buffer a size of 1 byte for (uint32_t k = 0; k < sdu->N_bytes; ++k) { @@ -3353,7 +3353,7 @@ bool reestablish_test() rlc1.write_sdu(std::move(sdu)); // Read PDU - unique_byte_buffer_t pdu = srslte::make_byte_buffer(); + unique_byte_buffer_t pdu = srsran::make_byte_buffer(); pdu->N_bytes = rlc1.read_pdu(pdu->msg, 7); // 2 byte header + 5 byte payload; // Find SN=0 PDU @@ -3410,21 +3410,21 @@ bool reestablish_test() pcap.close(); #endif - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int main(int argc, char** argv) { // Setup the log message spy to intercept error and warning log entries from RLC - if (!srslog::install_custom_sink(srslte::log_sink_message_spy::name(), - std::unique_ptr( - new srslte::log_sink_message_spy(srslog::get_default_log_formatter())))) { - return SRSLTE_ERROR; + if (!srslog::install_custom_sink(srsran::log_sink_message_spy::name(), + std::unique_ptr( + new srsran::log_sink_message_spy(srslog::get_default_log_formatter())))) { + return SRSRAN_ERROR; } - auto* spy = static_cast(srslog::find_sink(srslte::log_sink_message_spy::name())); + auto* spy = static_cast(srslog::find_sink(srsran::log_sink_message_spy::name())); if (!spy) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } srslog::set_default_sink(*spy); @@ -3603,5 +3603,5 @@ int main(int argc, char** argv) exit(-1); }; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } diff --git a/lib/test/upper/rlc_common_test.cc b/lib/test/upper/rlc_common_test.cc index 86d2313f8..a4184dd1e 100644 --- a/lib/test/upper/rlc_common_test.cc +++ b/lib/test/upper/rlc_common_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,7 +10,7 @@ * */ -#include "srslte/upper/rlc.h" +#include "srsran/upper/rlc.h" #include #define TESTASSERT(cond) \ @@ -24,7 +24,7 @@ #define MAX_NBUFS 100 #define NBUFS 5 -using namespace srslte; +using namespace srsran; class rlc_tester : public srsue::pdcp_interface_rlc, public srsue::rrc_interface_rlc { @@ -45,12 +45,12 @@ public: } sdus[n_sdus++] = std::move(sdu); } - void notify_delivery(uint32_t lcid, const srslte::pdcp_sn_vector_t& pdcp_sn) {} - void notify_failure(uint32_t lcid, const srslte::pdcp_sn_vector_t& pdcp_sn) {} + void notify_delivery(uint32_t lcid, const srsran::pdcp_sn_vector_t& pdcp_sn) {} + void notify_failure(uint32_t lcid, const srsran::pdcp_sn_vector_t& pdcp_sn) {} void write_pdu_bcch_bch(unique_byte_buffer_t sdu) {} void write_pdu_bcch_dlsch(unique_byte_buffer_t sdu) {} void write_pdu_pcch(unique_byte_buffer_t sdu) {} - void write_pdu_mch(uint32_t lcid, srslte::unique_byte_buffer_t sdu) { sdus[n_sdus++] = std::move(sdu); } + void write_pdu_mch(uint32_t lcid, srsran::unique_byte_buffer_t sdu) { sdus[n_sdus++] = std::move(sdu); } // RRC interface void max_retx_attempted() {} @@ -72,7 +72,7 @@ int meas_obj_test() logger_rlc2.set_hex_dump_max_size(-1); rlc_tester tester; - srslte::timer_handler timers(1); + srsran::timer_handler timers(1); int len = 0; @@ -102,7 +102,7 @@ int meas_obj_test() // Push 5 SDUs into RLC1 for (int i = 0; i < NBUFS; i++) { - sdu_bufs[i] = srslte::make_byte_buffer(); + sdu_bufs[i] = srsran::make_byte_buffer(); *sdu_bufs[i]->msg = i; // Write the index into the buffer sdu_bufs[i]->N_bytes = 1; // Give each buffer a size of 1 byte rlc1.write_sdu(lcid, std::move(sdu_bufs[i])); @@ -117,7 +117,7 @@ int meas_obj_test() // Push again 5 SDUs, SN should start from 0 for (int i = 0; i < NBUFS; i++) { - sdu_bufs[i] = srslte::make_byte_buffer(); + sdu_bufs[i] = srsran::make_byte_buffer(); *sdu_bufs[i]->msg = i; // Write the index into the buffer sdu_bufs[i]->N_bytes = 1; // Give each buffer a size of 1 byte rlc1.write_sdu(lcid, std::move(sdu_bufs[i])); diff --git a/lib/test/upper/rlc_stress_test.cc b/lib/test/upper/rlc_stress_test.cc index cf1e882a5..21512a8cd 100644 --- a/lib/test/upper/rlc_stress_test.cc +++ b/lib/test/upper/rlc_stress_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,12 +10,12 @@ * */ -#include "srslte/common/block_queue.h" -#include "srslte/common/crash_handler.h" -#include "srslte/common/rlc_pcap.h" -#include "srslte/common/test_common.h" -#include "srslte/common/threads.h" -#include "srslte/upper/rlc.h" +#include "srsran/common/block_queue.h" +#include "srsran/common/crash_handler.h" +#include "srsran/common/rlc_pcap.h" +#include "srsran/common/test_common.h" +#include "srsran/common/threads.h" +#include "srsran/upper/rlc.h" #include #include #include @@ -29,15 +29,15 @@ #define PCAP_CRNTI (0x1001) #define PCAP_TTI (666) -#include "srslte/common/mac_pcap.h" -#include "srslte/mac/mac_sch_pdu_nr.h" -static std::unique_ptr pcap_handle = nullptr; +#include "srsran/common/mac_pcap.h" +#include "srsran/mac/mac_sch_pdu_nr.h" +static std::unique_ptr pcap_handle = nullptr; int write_pdu_to_pcap(const bool is_dl, const uint32_t lcid, const uint8_t* payload, const uint32_t len) { if (pcap_handle) { - srslte::byte_buffer_t tx_buffer; - srslte::mac_sch_pdu_nr tx_pdu; + srsran::byte_buffer_t tx_buffer; + srsran::mac_sch_pdu_nr tx_pdu; tx_pdu.init_tx(&tx_buffer, len + 10); tx_pdu.add_sdu(lcid, payload, len); tx_pdu.pack(); @@ -47,14 +47,14 @@ int write_pdu_to_pcap(const bool is_dl, const uint32_t lcid, const uint8_t* payl pcap_handle->write_ul_crnti_nr(tx_buffer.msg, tx_buffer.N_bytes, PCAP_CRNTI, true, PCAP_TTI); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } - return SRSLTE_ERROR; + return SRSRAN_ERROR; } using namespace std; using namespace srsue; -using namespace srslte; +using namespace srsran; namespace bpo = boost::program_options; #define MIN_SDU_SIZE (5) @@ -140,7 +140,7 @@ void parse_args(stress_test_args_t* args, int argc, char* argv[]) } } -class mac_dummy : public srslte::thread +class mac_dummy : public srsran::thread { public: mac_dummy(rlc_interface_mac* rlc1_, @@ -172,7 +172,7 @@ public: wait_thread_finish(); } - void enqueue_task(srslte::move_task_t task) { pending_tasks.push(std::move(task)); } + void enqueue_task(srsran::move_task_t task) { pending_tasks.push(std::move(task)); } private: void run_tx_tti(rlc_interface_mac* tx_rlc, rlc_interface_mac* rx_rlc, std::vector& pdu_list) @@ -180,7 +180,7 @@ private: // Generate A number of MAC PDUs for (uint32_t i = 0; i < args.nof_pdu_tti; i++) { // Create PDU unique buffer - unique_byte_buffer_t pdu = srslte::make_byte_buffer(); + unique_byte_buffer_t pdu = srsran::make_byte_buffer(); if (!pdu) { printf("Fatal Error: Could not allocate PDU in mac_reader::run_thread\n"); exit(-1); @@ -276,7 +276,7 @@ private: void run_thread() override { - srslte::move_task_t task; + srsran::move_task_t task; while (run_enable) { // Downlink direction first (RLC1->RLC2) run_tti(rlc1, rlc2, true); @@ -304,15 +304,15 @@ private: rlc_pcap* pcap = nullptr; uint32_t lcid = 0; srslog::basic_logger& logger; - srslte::timer_handler* timers = nullptr; + srsran::timer_handler* timers = nullptr; - srslte::block_queue pending_tasks; + srsran::block_queue pending_tasks; std::mt19937 mt19937; std::uniform_real_distribution real_dist; }; -class rlc_tester : public pdcp_interface_rlc, public rrc_interface_rlc, public srslte::thread +class rlc_tester : public pdcp_interface_rlc, public rrc_interface_rlc, public srsran::thread { public: rlc_tester(rlc_interface_pdcp* rlc_pdcp_, @@ -368,9 +368,9 @@ public: void write_pdu_bcch_bch(unique_byte_buffer_t sdu) {} void write_pdu_bcch_dlsch(unique_byte_buffer_t sdu) {} void write_pdu_pcch(unique_byte_buffer_t sdu) {} - void write_pdu_mch(uint32_t lcid_, srslte::unique_byte_buffer_t sdu) {} - void notify_delivery(uint32_t lcid_, const srslte::pdcp_sn_vector_t& pdcp_sns) {} - void notify_failure(uint32_t lcid_, const srslte::pdcp_sn_vector_t& pdcp_sns) {} + void write_pdu_mch(uint32_t lcid_, srsran::unique_byte_buffer_t sdu) {} + void notify_delivery(uint32_t lcid_, const srsran::pdcp_sn_vector_t& pdcp_sns) {} + void notify_failure(uint32_t lcid_, const srsran::pdcp_sn_vector_t& pdcp_sns) {} // RRC interface void max_retx_attempted() @@ -397,7 +397,7 @@ private: continue; } - unique_byte_buffer_t pdu = srslte::make_byte_buffer(); + unique_byte_buffer_t pdu = srsran::make_byte_buffer(); if (pdu == NULL) { printf("Error: Could not allocate PDU in rlc_tester::run_thread\n\n\n"); // backoff for a bit @@ -485,7 +485,7 @@ void stress_test(stress_test_args_t args) } if (args.write_pcap) { - pcap_handle = std::unique_ptr(new srslte::mac_pcap()); + pcap_handle = std::unique_ptr(new srsran::mac_pcap()); pcap_handle->open("rlc_stress_test_nr.pcap"); } } else { @@ -500,7 +500,7 @@ void stress_test(stress_test_args_t args) seed = rd(); } - srslte::timer_handler timers(8); + srsran::timer_handler timers(8); rlc rlc1(log1.id().c_str()); rlc rlc2(log2.id().c_str()); @@ -573,7 +573,7 @@ void stress_test(stress_test_args_t args) int main(int argc, char** argv) { - srslte_debug_handle_crash(argc, argv); + srsran_debug_handle_crash(argc, argv); stress_test_args_t args = {}; parse_args(&args, argc, argv); diff --git a/lib/test/upper/rlc_test_common.h b/lib/test/upper/rlc_test_common.h index 6bf75d5a3..d43ea0cd4 100644 --- a/lib/test/upper/rlc_test_common.h +++ b/lib/test/upper/rlc_test_common.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,15 +10,15 @@ * */ -#ifndef SRSLTE_RLC_TEST_COMMON_H -#define SRSLTE_RLC_TEST_COMMON_H +#ifndef SRSRAN_RLC_TEST_COMMON_H +#define SRSRAN_RLC_TEST_COMMON_H -#include "srslte/common/byte_buffer.h" -#include "srslte/interfaces/ue_pdcp_interfaces.h" -#include "srslte/interfaces/ue_rrc_interfaces.h" +#include "srsran/common/byte_buffer.h" +#include "srsran/interfaces/ue_pdcp_interfaces.h" +#include "srsran/interfaces/ue_rrc_interfaces.h" #include -namespace srslte { +namespace srsran { class rlc_um_tester : public srsue::pdcp_interface_rlc, public srsue::rrc_interface_rlc { @@ -39,20 +39,20 @@ public: for (uint32_t i = 0; i < sdu->N_bytes; i++) { if (sdu->msg[i] != first_byte) { printf("Received corrupted SDU with size %d. Exiting.\n", sdu->N_bytes); - srslte_vec_fprint_byte(stdout, sdu->msg, sdu->N_bytes); + srsran_vec_fprint_byte(stdout, sdu->msg, sdu->N_bytes); exit(-1); } } - // srslte_vec_fprint_byte(stdout, sdu->msg, sdu->N_bytes); + // srsran_vec_fprint_byte(stdout, sdu->msg, sdu->N_bytes); sdus.push_back(std::move(sdu)); } void write_pdu_bcch_bch(unique_byte_buffer_t sdu) {} void write_pdu_bcch_dlsch(unique_byte_buffer_t sdu) {} void write_pdu_pcch(unique_byte_buffer_t sdu) {} - void write_pdu_mch(uint32_t lcid, srslte::unique_byte_buffer_t sdu) { sdus.push_back(std::move(sdu)); } - void notify_delivery(uint32_t lcid, const srslte::pdcp_sn_vector_t& pdcp_sns) {} - void notify_failure(uint32_t lcid, const srslte::pdcp_sn_vector_t& pdcp_sns) {} + void write_pdu_mch(uint32_t lcid, srsran::unique_byte_buffer_t sdu) { sdus.push_back(std::move(sdu)); } + void notify_delivery(uint32_t lcid, const srsran::pdcp_sn_vector_t& pdcp_sns) {} + void notify_failure(uint32_t lcid, const srsran::pdcp_sn_vector_t& pdcp_sns) {} // RRC interface void max_retx_attempted() {} @@ -66,6 +66,6 @@ public: uint32_t expected_sdu_len = 0; }; -} // namespace srslte +} // namespace srsran -#endif // SRSLTE_RLC_TEST_COMMON_H +#endif // SRSRAN_RLC_TEST_COMMON_H diff --git a/lib/test/upper/rlc_um_data_test.cc b/lib/test/upper/rlc_um_data_test.cc index c68c3fbe1..1f69e9c7e 100644 --- a/lib/test/upper/rlc_um_data_test.cc +++ b/lib/test/upper/rlc_um_data_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,8 +10,8 @@ * */ -#include "srslte/common/test_common.h" -#include "srslte/upper/rlc_um_lte.h" +#include "srsran/common/test_common.h" +#include "srsran/upper/rlc_um_lte.h" #include // Fixed header only @@ -26,12 +26,12 @@ int main(int argc, char** argv) { srslog::init(); - srslte::rlc_umd_pdu_header_t h; - srslte::byte_buffer_t b1, b2; + srsran::rlc_umd_pdu_header_t h; + srsran::byte_buffer_t b1, b2; memcpy(b1.msg, &pdu1[0], PDU1_LEN); b1.N_bytes = PDU1_LEN; - rlc_um_read_data_pdu_header(&b1, srslte::rlc_umd_sn_size_t::size10bits, &h); + rlc_um_read_data_pdu_header(&b1, srsran::rlc_umd_sn_size_t::size10bits, &h); TESTASSERT(0x03 == h.fi); TESTASSERT(0 == h.N_li); TESTASSERT(226 == h.sn); @@ -42,11 +42,11 @@ int main(int argc, char** argv) b1.clear(); b2.clear(); - memset(&h, 0, sizeof(srslte::rlc_umd_pdu_header_t)); + memset(&h, 0, sizeof(srsran::rlc_umd_pdu_header_t)); memcpy(b1.msg, &pdu2[0], PDU2_LEN); b1.N_bytes = PDU2_LEN; - rlc_um_read_data_pdu_header(&b1, srslte::rlc_umd_sn_size_t::size10bits, &h); + rlc_um_read_data_pdu_header(&b1, srsran::rlc_umd_sn_size_t::size10bits, &h); TESTASSERT(0x03 == h.fi); TESTASSERT(225 == h.sn); TESTASSERT(1 == h.N_li); diff --git a/lib/test/upper/rlc_um_nr_pdu_test.cc b/lib/test/upper/rlc_um_nr_pdu_test.cc index c8e6ec037..96a491a68 100644 --- a/lib/test/upper/rlc_um_nr_pdu_test.cc +++ b/lib/test/upper/rlc_um_nr_pdu_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,9 +10,9 @@ * */ -#include "srslte/config.h" -#include "srslte/upper/rlc.h" -#include "srslte/upper/rlc_um_nr.h" +#include "srsran/config.h" +#include "srsran/upper/rlc.h" +#include "srsran/upper/rlc_um_nr.h" #include #include @@ -31,12 +31,12 @@ #define PCAP_CRNTI (0x1001) #define PCAP_TTI (666) -using namespace srslte; +using namespace srsran; #if PCAP -#include "srslte/common/mac_pcap.h" -#include "srslte/mac/mac_sch_pdu_nr.h" -static std::unique_ptr pcap_handle = nullptr; +#include "srsran/common/mac_pcap.h" +#include "srsran/mac/mac_sch_pdu_nr.h" +static std::unique_ptr pcap_handle = nullptr; #endif int write_pdu_to_pcap(const uint32_t lcid, const uint8_t* payload, const uint32_t len) @@ -44,28 +44,28 @@ int write_pdu_to_pcap(const uint32_t lcid, const uint8_t* payload, const uint32_ #if PCAP if (pcap_handle) { byte_buffer_t tx_buffer; - srslte::mac_sch_pdu_nr tx_pdu; + srsran::mac_sch_pdu_nr tx_pdu; tx_pdu.init_tx(&tx_buffer, len + 10); tx_pdu.add_sdu(lcid, payload, len); tx_pdu.pack(); pcap_handle->write_dl_crnti_nr(tx_buffer.msg, tx_buffer.N_bytes, PCAP_CRNTI, true, PCAP_TTI); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } #endif - return SRSLTE_ERROR; + return SRSRAN_ERROR; } template -srslte::byte_buffer_t make_pdu_and_log(const std::array& tv) +srsran::byte_buffer_t make_pdu_and_log(const std::array& tv) { - srslte::byte_buffer_t pdu; + srsran::byte_buffer_t pdu; memcpy(pdu.msg, tv.data(), tv.size()); pdu.N_bytes = tv.size(); write_pdu_to_pcap(4, tv.data(), tv.size()); return pdu; } -void corrupt_pdu_header(srslte::byte_buffer_t& pdu, const uint32_t header_len, const uint32_t payload_len) +void corrupt_pdu_header(srsran::byte_buffer_t& pdu, const uint32_t header_len, const uint32_t payload_len) { // clear header only for (uint32_t i = 0; i < header_len; i++) { @@ -80,11 +80,11 @@ int rlc_um_nr_pdu_test1() { const int header_len = 1, payload_len = 4; std::array tv = {0x00, 0x11, 0x22, 0x33, 0x44}; - srslte::byte_buffer_t pdu = make_pdu_and_log(tv); + srsran::byte_buffer_t pdu = make_pdu_and_log(tv); // unpack PDU rlc_um_nr_pdu_header_t header = {}; - TESTASSERT(rlc_um_nr_read_data_pdu_header(&pdu, srslte::rlc_um_nr_sn_size_t::size6bits, &header) != 0); + TESTASSERT(rlc_um_nr_read_data_pdu_header(&pdu, srsran::rlc_um_nr_sn_size_t::size6bits, &header) != 0); TESTASSERT(header.si == rlc_nr_si_field_t::full_sdu); // clear header @@ -95,7 +95,7 @@ int rlc_um_nr_pdu_test1() TESTASSERT(pdu.N_bytes == tv.size()); TESTASSERT(memcmp(pdu.msg, tv.data(), pdu.N_bytes) == 0); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // RLC UM PDU with 6 Bit SN carrying the last segment of an SDU @@ -104,16 +104,16 @@ int rlc_um_nr_pdu_test2() // SN = 1 const int header_len = 3, payload_len = 4; const std::array tv = {0x81, 0x01, 0x02, 0x11, 0x22, 0x33, 0x44}; - srslte::byte_buffer_t pdu = make_pdu_and_log(tv); + srsran::byte_buffer_t pdu = make_pdu_and_log(tv); // unpack PDU rlc_um_nr_pdu_header_t header = {}; - TESTASSERT(rlc_um_nr_read_data_pdu_header(&pdu, srslte::rlc_um_nr_sn_size_t::size6bits, &header) != 0); + TESTASSERT(rlc_um_nr_read_data_pdu_header(&pdu, srsran::rlc_um_nr_sn_size_t::size6bits, &header) != 0); TESTASSERT(header.si == rlc_nr_si_field_t::last_segment); TESTASSERT(header.sn == 1); TESTASSERT(header.so == 258); - TESTASSERT(header.sn_size == srslte::rlc_um_nr_sn_size_t::size6bits); + TESTASSERT(header.sn_size == srsran::rlc_um_nr_sn_size_t::size6bits); // clear header corrupt_pdu_header(pdu, header_len, payload_len); @@ -123,7 +123,7 @@ int rlc_um_nr_pdu_test2() TESTASSERT(pdu.N_bytes == tv.size()); TESTASSERT(memcmp(pdu.msg, tv.data(), pdu.N_bytes) == 0); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // RLC UM PDU with 6 Bit SN carrying a middle segment of an SDU @@ -132,16 +132,16 @@ int rlc_um_nr_pdu_test3() // SN = 3 const int header_len = 3, payload_len = 4; const std::array tv = {0xc3, 0x01, 0x02, 0x11, 0x22, 0x33, 0x44}; - srslte::byte_buffer_t pdu = make_pdu_and_log(tv); + srsran::byte_buffer_t pdu = make_pdu_and_log(tv); // unpack PDU rlc_um_nr_pdu_header_t header = {}; - TESTASSERT(rlc_um_nr_read_data_pdu_header(&pdu, srslte::rlc_um_nr_sn_size_t::size6bits, &header) != 0); + TESTASSERT(rlc_um_nr_read_data_pdu_header(&pdu, srsran::rlc_um_nr_sn_size_t::size6bits, &header) != 0); TESTASSERT(header.si == rlc_nr_si_field_t::neither_first_nor_last_segment); TESTASSERT(header.so == 258); TESTASSERT(header.sn == 3); - TESTASSERT(header.sn_size == srslte::rlc_um_nr_sn_size_t::size6bits); + TESTASSERT(header.sn_size == srsran::rlc_um_nr_sn_size_t::size6bits); // clear header corrupt_pdu_header(pdu, header_len, payload_len); @@ -151,7 +151,7 @@ int rlc_um_nr_pdu_test3() TESTASSERT(pdu.N_bytes == tv.size()); TESTASSERT(memcmp(pdu.msg, tv.data(), pdu.N_bytes) == 0); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // RLC UM PDU with 6 Bit SN carrying a first segment of an SDU @@ -160,16 +160,16 @@ int rlc_um_nr_pdu_test4() // SN = 31 const int header_len = 1, payload_len = 4; std::array tv = {0x5f, 0x11, 0x22, 0x33, 0x44}; - srslte::byte_buffer_t pdu = make_pdu_and_log(tv); + srsran::byte_buffer_t pdu = make_pdu_and_log(tv); // unpack PDU rlc_um_nr_pdu_header_t header = {}; - TESTASSERT(rlc_um_nr_read_data_pdu_header(&pdu, srslte::rlc_um_nr_sn_size_t::size6bits, &header) != 0); + TESTASSERT(rlc_um_nr_read_data_pdu_header(&pdu, srsran::rlc_um_nr_sn_size_t::size6bits, &header) != 0); TESTASSERT(header.si == rlc_nr_si_field_t::first_segment); TESTASSERT(header.so == 0); TESTASSERT(header.sn == 31); - TESTASSERT(header.sn_size == srslte::rlc_um_nr_sn_size_t::size6bits); + TESTASSERT(header.sn_size == srsran::rlc_um_nr_sn_size_t::size6bits); // clear header corrupt_pdu_header(pdu, header_len, payload_len); @@ -179,20 +179,20 @@ int rlc_um_nr_pdu_test4() TESTASSERT(pdu.N_bytes == tv.size()); TESTASSERT(memcmp(pdu.msg, tv.data(), pdu.N_bytes) == 0); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // This should fail unpacking because the PDU has reserved bits set int rlc_um_nr_pdu_unpack_test5() { std::array tv = {0x33, 0x01, 0x02, 0x11, 0x22, 0x33, 0x44}; - srslte::byte_buffer_t pdu = make_pdu_and_log(tv); + srsran::byte_buffer_t pdu = make_pdu_and_log(tv); // unpack PDU rlc_um_nr_pdu_header_t header = {}; - TESTASSERT(rlc_um_nr_read_data_pdu_header(&pdu, srslte::rlc_um_nr_sn_size_t::size6bits, &header) == 0); + TESTASSERT(rlc_um_nr_read_data_pdu_header(&pdu, srsran::rlc_um_nr_sn_size_t::size6bits, &header) == 0); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Unpack RLC UM 12bit SN PDU with PDCP and ICMP @@ -204,11 +204,11 @@ int rlc_um_nr_pdu_unpack_test6() 0x00, 0x00, 0x00, 0x00, 0x3e, 0xb6, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37}; - srslte::byte_buffer_t pdu = make_pdu_and_log(tv); + srsran::byte_buffer_t pdu = make_pdu_and_log(tv); // unpack PDU rlc_um_nr_pdu_header_t header = {}; - TESTASSERT(rlc_um_nr_read_data_pdu_header(&pdu, srslte::rlc_um_nr_sn_size_t::size12bits, &header) != 0); + TESTASSERT(rlc_um_nr_read_data_pdu_header(&pdu, srsran::rlc_um_nr_sn_size_t::size12bits, &header) != 0); TESTASSERT(header.si == rlc_nr_si_field_t::full_sdu); TESTASSERT(header.so == 0); @@ -216,13 +216,13 @@ int rlc_um_nr_pdu_unpack_test6() TESTASSERT(rlc_um_nr_packed_length(header) == 1); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int main(int argc, char** argv) { #if PCAP - pcap_handle = std::unique_ptr(new srslte::mac_pcap()); + pcap_handle = std::unique_ptr(new srsran::mac_pcap()); pcap_handle->open("rlc_um_nr_pdu_test.pcap"); #endif @@ -230,37 +230,37 @@ int main(int argc, char** argv) if (rlc_um_nr_pdu_test1()) { fprintf(stderr, "rlc_um_nr_pdu_test1() failed.\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (rlc_um_nr_pdu_test2()) { fprintf(stderr, "rlc_um_nr_pdu_test2() failed.\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (rlc_um_nr_pdu_test3()) { fprintf(stderr, "rlc_um_nr_pdu_test3() failed.\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (rlc_um_nr_pdu_test4()) { fprintf(stderr, "rlc_um_nr_pdu_test4() failed.\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (rlc_um_nr_pdu_unpack_test5()) { fprintf(stderr, "rlc_um_nr_pdu_unpack_test5() failed.\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (rlc_um_nr_pdu_unpack_test6()) { fprintf(stderr, "rlc_um_nr_pdu_unpack_test6() failed.\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } #if PCAP pcap_handle->close(); #endif - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } diff --git a/lib/test/upper/rlc_um_nr_test.cc b/lib/test/upper/rlc_um_nr_test.cc index efd5d540e..2f0e014a5 100644 --- a/lib/test/upper/rlc_um_nr_test.cc +++ b/lib/test/upper/rlc_um_nr_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,10 +11,10 @@ */ #include "rlc_test_common.h" -#include "srslte/config.h" -#include "srslte/interfaces/ue_pdcp_interfaces.h" -#include "srslte/upper/rlc.h" -#include "srslte/upper/rlc_um_nr.h" +#include "srsran/config.h" +#include "srsran/interfaces/ue_pdcp_interfaces.h" +#include "srsran/upper/rlc.h" +#include "srsran/upper/rlc_um_nr.h" #include #include @@ -32,12 +32,12 @@ #define PCAP_CRNTI (0x1001) #define PCAP_TTI (666) -using namespace srslte; +using namespace srsran; #if PCAP -#include "srslte/common/mac_nr_pcap.h" -#include "srslte/mac/mac_nr_pdu.h" -static std::unique_ptr pcap_handle = nullptr; +#include "srsran/common/mac_nr_pcap.h" +#include "srsran/mac/mac_nr_pdu.h" +static std::unique_ptr pcap_handle = nullptr; #endif int write_pdu_to_pcap(const uint32_t lcid, const uint8_t* payload, const uint32_t len) @@ -45,21 +45,21 @@ int write_pdu_to_pcap(const uint32_t lcid, const uint8_t* payload, const uint32_ #if PCAP if (pcap_handle) { byte_buffer_t tx_buffer; - srslte::mac_nr_sch_pdu tx_pdu; + srsran::mac_nr_sch_pdu tx_pdu; tx_pdu.init_tx(&tx_buffer, len + 10); tx_pdu.add_sdu(lcid, payload, len); tx_pdu.pack(); pcap_handle->write_dl_crnti(tx_buffer.msg, tx_buffer.N_bytes, PCAP_CRNTI, true, PCAP_TTI); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } #endif - return SRSLTE_ERROR; + return SRSRAN_ERROR; } template -srslte::byte_buffer_t make_pdu_and_log(const std::array& tv) +srsran::byte_buffer_t make_pdu_and_log(const std::array& tv) { - srslte::byte_buffer_t pdu; + srsran::byte_buffer_t pdu; memcpy(pdu.msg, tv.data(), tv.size()); pdu.N_bytes = tv.size(); write_pdu_to_pcap(4, tv.data(), tv.size()); @@ -97,7 +97,7 @@ public: srslog::basic_logger& logger1; srslog::basic_logger& logger2; - srslte::timer_handler timers; + srsran::timer_handler timers; rlc_um_tester tester; rlc_um_nr rlc1, rlc2; }; @@ -113,7 +113,7 @@ int rlc_um_nr_test1() byte_buffer_pool* pool = byte_buffer_pool::get_instance(); unique_byte_buffer_t sdu_bufs[num_sdus]; for (uint32_t i = 0; i < num_sdus; i++) { - sdu_bufs[i] = srslte::make_byte_buffer(); + sdu_bufs[i] = srsran::make_byte_buffer(); *sdu_bufs[i]->msg = i; // Write the index into the buffer sdu_bufs[i]->N_bytes = 1; // Give each buffer a size of 1 byte ctxt.rlc1.write_sdu(std::move(sdu_bufs[i])); @@ -124,7 +124,7 @@ int rlc_um_nr_test1() // Read 5 PDUs from RLC1 (1 byte each) unique_byte_buffer_t pdu_bufs[num_pdus]; for (uint32_t i = 0; i < num_pdus; i++) { - pdu_bufs[i] = srslte::make_byte_buffer(); + pdu_bufs[i] = srsran::make_byte_buffer(); int len = ctxt.rlc1.read_pdu(pdu_bufs[i]->msg, 4); // 3 bytes for header + payload pdu_bufs[i]->N_bytes = len; @@ -147,7 +147,7 @@ int rlc_um_nr_test1() TESTASSERT(*(ctxt.tester.sdus[i]->msg) == i); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Basic test for SDU segmentation @@ -164,7 +164,7 @@ int rlc_um_nr_test2(bool reverse_rx = false) byte_buffer_pool* pool = byte_buffer_pool::get_instance(); unique_byte_buffer_t sdu_bufs[num_sdus]; for (uint32_t i = 0; i < num_sdus; i++) { - sdu_bufs[i] = srslte::make_byte_buffer(); + sdu_bufs[i] = srsran::make_byte_buffer(); // Write the index into the buffer for (uint32_t k = 0; k < sdu_size; ++k) { sdu_bufs[i]->msg[k] = i; @@ -182,7 +182,7 @@ int rlc_um_nr_test2(bool reverse_rx = false) unique_byte_buffer_t pdu_bufs[max_num_pdus]; while (ctxt.rlc1.get_buffer_state() != 0 && num_pdus < max_num_pdus) { - pdu_bufs[num_pdus] = srslte::make_byte_buffer(); + pdu_bufs[num_pdus] = srsran::make_byte_buffer(); int len = ctxt.rlc1.read_pdu(pdu_bufs[num_pdus]->msg, 25); // 3 bytes for header + payload pdu_bufs[num_pdus]->N_bytes = len; @@ -215,7 +215,7 @@ int rlc_um_nr_test2(bool reverse_rx = false) TESTASSERT(*(ctxt.tester.sdus[i]->msg) == i); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Test reception of segmented RLC PDUs (two different SDUs with same PDU segmentation) @@ -232,7 +232,7 @@ int rlc_um_nr_test4() byte_buffer_pool* pool = byte_buffer_pool::get_instance(); unique_byte_buffer_t sdu_bufs[num_sdus]; for (uint32_t i = 0; i < num_sdus; i++) { - sdu_bufs[i] = srslte::make_byte_buffer(); + sdu_bufs[i] = srsran::make_byte_buffer(); // Write the index into the buffer for (uint32_t k = 0; k < sdu_size; ++k) { sdu_bufs[i]->msg[k] = i; @@ -251,7 +251,7 @@ int rlc_um_nr_test4() unique_byte_buffer_t pdu_bufs[max_num_pdus]; while (ctxt.rlc1.get_buffer_state() != 0 && num_pdus < max_num_pdus) { - pdu_bufs[num_pdus] = srslte::make_byte_buffer(); + pdu_bufs[num_pdus] = srsran::make_byte_buffer(); int len = ctxt.rlc1.read_pdu(pdu_bufs[num_pdus]->msg, 25); // 3 bytes for header + payload pdu_bufs[num_pdus]->N_bytes = len; num_pdus++; @@ -291,7 +291,7 @@ int rlc_um_nr_test4() } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Handling of re-transmitted segments (e.g. after PHY retransmission) @@ -308,7 +308,7 @@ int rlc_um_nr_test5(const uint32_t last_sn) byte_buffer_pool* pool = byte_buffer_pool::get_instance(); unique_byte_buffer_t sdu_bufs[num_sdus]; for (uint32_t i = 0; i < num_sdus; i++) { - sdu_bufs[i] = srslte::make_byte_buffer(); + sdu_bufs[i] = srsran::make_byte_buffer(); // Write the index into the buffer for (uint32_t k = 0; k < sdu_size; ++k) { sdu_bufs[i]->msg[k] = i; @@ -326,7 +326,7 @@ int rlc_um_nr_test5(const uint32_t last_sn) unique_byte_buffer_t pdu_bufs[max_num_pdus]; while (ctxt.rlc1.get_buffer_state() != 0 && num_pdus < max_num_pdus) { - pdu_bufs[num_pdus] = srslte::make_byte_buffer(); + pdu_bufs[num_pdus] = srsran::make_byte_buffer(); int len = ctxt.rlc1.read_pdu(pdu_bufs[num_pdus]->msg, 25); // 3 bytes for header + payload pdu_bufs[num_pdus]->N_bytes = len; @@ -358,7 +358,7 @@ int rlc_um_nr_test5(const uint32_t last_sn) TESTASSERT(*(ctxt.tester.sdus[i]->msg) == i); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Test of wrap-around of reassembly window @@ -375,7 +375,7 @@ int rlc_um_nr_test6() byte_buffer_pool* pool = byte_buffer_pool::get_instance(); unique_byte_buffer_t sdu_bufs[num_sdus]; for (uint32_t i = 0; i < num_sdus; i++) { - sdu_bufs[i] = srslte::make_byte_buffer(); + sdu_bufs[i] = srsran::make_byte_buffer(); // Write the index into the buffer for (uint32_t k = 0; k < sdu_size; ++k) { sdu_bufs[i]->msg[k] = i; @@ -393,7 +393,7 @@ int rlc_um_nr_test6() unique_byte_buffer_t pdu_bufs[max_num_pdus]; while (ctxt.rlc1.get_buffer_state() != 0 && num_pdus < max_num_pdus) { - pdu_bufs[num_pdus] = srslte::make_byte_buffer(); + pdu_bufs[num_pdus] = srsran::make_byte_buffer(); int len = ctxt.rlc1.read_pdu(pdu_bufs[num_pdus]->msg, 8); // 3 bytes for header + payload pdu_bufs[num_pdus]->N_bytes = len; @@ -418,7 +418,7 @@ int rlc_um_nr_test6() TESTASSERT(*(ctxt.tester.sdus[i]->msg) == i); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Segment loss received too many new PDUs (lost PDU outside of reassembly window) @@ -435,7 +435,7 @@ int rlc_um_nr_test7() byte_buffer_pool* pool = byte_buffer_pool::get_instance(); unique_byte_buffer_t sdu_bufs[num_sdus]; for (uint32_t i = 0; i < num_sdus; i++) { - sdu_bufs[i] = srslte::make_byte_buffer(); + sdu_bufs[i] = srsran::make_byte_buffer(); // Write the index into the buffer for (uint32_t k = 0; k < sdu_size; ++k) { sdu_bufs[i]->msg[k] = i; @@ -453,7 +453,7 @@ int rlc_um_nr_test7() unique_byte_buffer_t pdu_bufs[max_num_pdus]; while (ctxt.rlc1.get_buffer_state() != 0 && num_pdus < max_num_pdus) { - pdu_bufs[num_pdus] = srslte::make_byte_buffer(); + pdu_bufs[num_pdus] = srsran::make_byte_buffer(); int len = ctxt.rlc1.read_pdu(pdu_bufs[num_pdus]->msg, 8); // 3 bytes for header + payload pdu_bufs[num_pdus]->N_bytes = len; @@ -482,7 +482,7 @@ int rlc_um_nr_test7() rlc_bearer_metrics_t rlc2_metrics = ctxt.rlc2.get_metrics(); TESTASSERT(rlc2_metrics.num_lost_pdus == 1); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Segment loss and expiry of reassembly timer @@ -499,7 +499,7 @@ int rlc_um_nr_test8() byte_buffer_pool* pool = byte_buffer_pool::get_instance(); unique_byte_buffer_t sdu_bufs[num_sdus]; for (uint32_t i = 0; i < num_sdus; i++) { - sdu_bufs[i] = srslte::make_byte_buffer(); + sdu_bufs[i] = srsran::make_byte_buffer(); // Write the index into the buffer for (uint32_t k = 0; k < sdu_size; ++k) { sdu_bufs[i]->msg[k] = i; @@ -517,7 +517,7 @@ int rlc_um_nr_test8() unique_byte_buffer_t pdu_bufs[max_num_pdus]; while (ctxt.rlc1.get_buffer_state() != 0 && num_pdus < max_num_pdus) { - pdu_bufs[num_pdus] = srslte::make_byte_buffer(); + pdu_bufs[num_pdus] = srsran::make_byte_buffer(); int len = ctxt.rlc1.read_pdu(pdu_bufs[num_pdus]->msg, 8); // 3 bytes for header + payload pdu_bufs[num_pdus]->N_bytes = len; @@ -551,13 +551,13 @@ int rlc_um_nr_test8() rlc_bearer_metrics_t rlc2_metrics = ctxt.rlc2.get_metrics(); TESTASSERT(rlc2_metrics.num_lost_pdus == 1); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int main(int argc, char** argv) { #if PCAP - pcap_handle = std::unique_ptr(new srslte::mac_nr_pcap()); + pcap_handle = std::unique_ptr(new srsran::mac_nr_pcap()); pcap_handle->open("rlc_um_nr_test.pcap"); #endif @@ -565,46 +565,46 @@ int main(int argc, char** argv) if (rlc_um_nr_test1()) { fprintf(stderr, "rlc_um_nr_test1() failed.\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (rlc_um_nr_test2()) { fprintf(stderr, "rlc_um_nr_test2() failed.\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // same like above but PDUs delivered in reverse order if (rlc_um_nr_test2(true)) { fprintf(stderr, "rlc_um_nr_test2(true) failed.\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (rlc_um_nr_test4()) { fprintf(stderr, "rlc_um_nr_test4() failed.\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } for (uint32_t i = 0; i < 5; ++i) { if (rlc_um_nr_test5(i)) { fprintf(stderr, "rlc_um_nr_test5() for i=%d failed.\n", i); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } if (rlc_um_nr_test6()) { fprintf(stderr, "rlc_um_nr_test6() failed.\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (rlc_um_nr_test7()) { fprintf(stderr, "rlc_um_nr_test7() failed.\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (rlc_um_nr_test8()) { fprintf(stderr, "rlc_um_nr_test8() failed.\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } diff --git a/lib/test/upper/rlc_um_test.cc b/lib/test/upper/rlc_um_test.cc index 10a3a490f..6edbf86b1 100644 --- a/lib/test/upper/rlc_um_test.cc +++ b/lib/test/upper/rlc_um_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,7 +11,7 @@ */ #include "rlc_test_common.h" -#include "srslte/upper/rlc_um_lte.h" +#include "srsran/upper/rlc_um_lte.h" #include #define TESTASSERT(cond) \ @@ -25,7 +25,7 @@ #define MAX_NBUFS 100 #define NBUFS 5 -using namespace srslte; +using namespace srsran; using namespace srsue; // Helper class to create two pre-configured RLC instances @@ -59,7 +59,7 @@ public: srslog::basic_logger& logger1; srslog::basic_logger& logger2; - srslte::timer_handler timers; + srsran::timer_handler timers; rlc_um_tester tester; rlc_um_lte rlc1, rlc2; }; @@ -71,7 +71,7 @@ int meas_obj_test() // Push 5 SDUs into RLC1 unique_byte_buffer_t sdu_bufs[NBUFS]; for (int i = 0; i < NBUFS; i++) { - sdu_bufs[i] = srslte::make_byte_buffer(); + sdu_bufs[i] = srsran::make_byte_buffer(); *sdu_bufs[i]->msg = i; // Write the index into the buffer sdu_bufs[i]->N_bytes = 1; // Give each buffer a size of 1 byte ctxt.rlc1.write_sdu(std::move(sdu_bufs[i])); @@ -111,7 +111,7 @@ int loss_test() // Push 5 SDUs into RLC1 unique_byte_buffer_t sdu_bufs[NBUFS]; for (int i = 0; i < NBUFS; i++) { - sdu_bufs[i] = srslte::make_byte_buffer(); + sdu_bufs[i] = srsran::make_byte_buffer(); sdu_bufs[i]->msg[0] = i; // Write the index into the buffer sdu_bufs[i]->N_bytes = 1; // Give each buffer a size of 1 byte ctxt.rlc1.write_sdu(std::move(sdu_bufs[i])); @@ -156,7 +156,7 @@ int basic_mbsfn_test() // Push 5 SDUs into RLC1 unique_byte_buffer_t sdu_bufs[NBUFS * 2]; for (int i = 0; i < NBUFS; i++) { - sdu_bufs[i] = srslte::make_byte_buffer(); + sdu_bufs[i] = srsran::make_byte_buffer(); sdu_bufs[i]->msg[0] = i; // Write the index into the buffer sdu_bufs[i]->N_bytes = 1; // Give each buffer a size of 1 byte ctxt.rlc1.write_sdu(std::move(sdu_bufs[i])); @@ -218,7 +218,7 @@ int reassmble_test() unique_byte_buffer_t sdu_bufs[n_sdus]; for (int i = 0; i < n_sdu_first_batch; i++) { - sdu_bufs[i] = srslte::make_byte_buffer(); + sdu_bufs[i] = srsran::make_byte_buffer(); for (int k = 0; k < sdu_len; ++k) { sdu_bufs[i]->msg[k] = i; } @@ -231,7 +231,7 @@ int reassmble_test() int n_pdus = 0; std::unique_ptr pdu_bufs[max_n_pdus]; for (int i = 0; i < max_n_pdus; i++) { - pdu_bufs[i] = srslte::make_byte_buffer(); + pdu_bufs[i] = srsran::make_byte_buffer(); int len = ctxt.rlc1.read_pdu(pdu_bufs[i]->msg, (i == 0) ? sdu_len * 3 / 4 : sdu_len * 1.25); pdu_bufs[i]->N_bytes = len; if (len) { @@ -246,7 +246,7 @@ int reassmble_test() // push second batch of SDUs for (int i = n_sdu_first_batch; i < n_sdus; ++i) { - sdu_bufs[i] = srslte::make_byte_buffer(); + sdu_bufs[i] = srsran::make_byte_buffer(); for (int k = 0; k < sdu_len; ++k) { sdu_bufs[i]->msg[k] = i; } @@ -256,7 +256,7 @@ int reassmble_test() // Read second batch of PDUs (use large grants) for (int i = n_pdus; i < max_n_pdus; i++) { - pdu_bufs[i] = srslte::make_byte_buffer(); + pdu_bufs[i] = srsran::make_byte_buffer(); int len = ctxt.rlc1.read_pdu(pdu_bufs[i]->msg, sdu_len * 1.25); pdu_bufs[i]->N_bytes = len; if (len) { @@ -310,7 +310,7 @@ int reassmble_test2() const int n_sdu_first_batch = 17; unique_byte_buffer_t sdu_bufs[n_sdus]; for (int i = 0; i < n_sdu_first_batch; i++) { - sdu_bufs[i] = srslte::make_byte_buffer(); + sdu_bufs[i] = srsran::make_byte_buffer(); for (int k = 0; k < sdu_len; ++k) { sdu_bufs[i]->msg[k] = i; } @@ -320,9 +320,9 @@ int reassmble_test2() const int max_n_pdus = 100; int n_pdus = 0; - srslte::unique_byte_buffer_t pdu_bufs[max_n_pdus]; + srsran::unique_byte_buffer_t pdu_bufs[max_n_pdus]; for (int i = 0; i < max_n_pdus; i++) { - pdu_bufs[i] = srslte::make_byte_buffer(); + pdu_bufs[i] = srsran::make_byte_buffer(); int len = ctxt.rlc1.read_pdu(pdu_bufs[i]->msg, (i == 0) ? sdu_len * .75 : sdu_len * .25); pdu_bufs[i]->N_bytes = len; if (len) { @@ -337,7 +337,7 @@ int reassmble_test2() // push second batch of SDUs for (int i = n_sdu_first_batch; i < n_sdus; ++i) { - sdu_bufs[i] = srslte::make_byte_buffer(); + sdu_bufs[i] = srsran::make_byte_buffer(); for (int k = 0; k < sdu_len; ++k) { sdu_bufs[i]->msg[k] = i; } @@ -347,7 +347,7 @@ int reassmble_test2() // Read second batch of PDUs for (int i = n_pdus; i < max_n_pdus; i++) { - pdu_bufs[i] = srslte::make_byte_buffer(); + pdu_bufs[i] = srsran::make_byte_buffer(); int len = ctxt.rlc1.read_pdu(pdu_bufs[i]->msg, sdu_len * 1.25); pdu_bufs[i]->N_bytes = len; if (len) { @@ -389,7 +389,7 @@ int pdu_pack_no_space_test() // Push 2 SDUs into RLC1 unique_byte_buffer_t sdu_bufs[num_sdus]; for (int i = 0; i < num_sdus; i++) { - sdu_bufs[i] = srslte::make_byte_buffer(); + sdu_bufs[i] = srsran::make_byte_buffer(); *sdu_bufs[i]->msg = i; // Write the index into the buffer sdu_bufs[i]->N_bytes = 10; // Give each buffer a size of 1 byte ctxt.rlc1.write_sdu(std::move(sdu_bufs[i])); @@ -406,8 +406,8 @@ int pdu_pack_no_space_test() // this PDU contains a full SDU { - srslte::rlc_umd_pdu_header_t h; - rlc_um_read_data_pdu_header(&pdu_bufs[0], srslte::rlc_umd_sn_size_t::size10bits, &h); + srsran::rlc_umd_pdu_header_t h; + rlc_um_read_data_pdu_header(&pdu_bufs[0], srsran::rlc_umd_sn_size_t::size10bits, &h); TESTASSERT(h.fi == RLC_FI_FIELD_START_AND_END_ALIGNED); } @@ -416,12 +416,12 @@ int pdu_pack_no_space_test() pdu_bufs[1].N_bytes = len; { - srslte::rlc_umd_pdu_header_t h; - rlc_um_read_data_pdu_header(&pdu_bufs[1], srslte::rlc_umd_sn_size_t::size10bits, &h); + srsran::rlc_umd_pdu_header_t h; + rlc_um_read_data_pdu_header(&pdu_bufs[1], srsran::rlc_umd_sn_size_t::size10bits, &h); TESTASSERT(h.fi == RLC_FI_FIELD_START_AND_END_ALIGNED); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int main(int argc, char** argv) diff --git a/run-clang-format-diff.sh b/run-clang-format-diff.sh index 3da5ee74c..755cc7bad 100755 --- a/run-clang-format-diff.sh +++ b/run-clang-format-diff.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of diff --git a/srsenb/CMakeLists.txt b/srsenb/CMakeLists.txt index fff7aaa8f..2a65533f0 100644 --- a/srsenb/CMakeLists.txt +++ b/srsenb/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of diff --git a/srsenb/hdr/cfg_parser.h b/srsenb/hdr/cfg_parser.h index 054529c01..6100d9924 100644 --- a/srsenb/hdr/cfg_parser.h +++ b/srsenb/hdr/cfg_parser.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/srsenb/hdr/enb.h b/srsenb/hdr/enb.h index 02f57a7e0..04476d651 100644 --- a/srsenb/hdr/enb.h +++ b/srsenb/hdr/enb.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -25,23 +25,23 @@ #include "phy/phy.h" -#include "srslte/radio/radio.h" +#include "srsran/radio/radio.h" #include "srsenb/hdr/phy/enb_phy_base.h" #include "srsenb/hdr/stack/enb_stack_base.h" #include "srsenb/hdr/stack/rrc/rrc_config.h" -#include "srslte/common/bcd_helpers.h" -#include "srslte/common/buffer_pool.h" -#include "srslte/common/interfaces_common.h" -#include "srslte/common/mac_pcap.h" -#include "srslte/common/security.h" -#include "srslte/interfaces/enb_command_interface.h" -#include "srslte/interfaces/enb_metrics_interface.h" -#include "srslte/interfaces/sched_interface.h" -#include "srslte/interfaces/ue_interfaces.h" -#include "srslte/srslog/srslog.h" -#include "srslte/system/sys_metrics_processor.h" +#include "srsran/common/bcd_helpers.h" +#include "srsran/common/buffer_pool.h" +#include "srsran/common/interfaces_common.h" +#include "srsran/common/mac_pcap.h" +#include "srsran/common/security.h" +#include "srsran/interfaces/enb_command_interface.h" +#include "srsran/interfaces/enb_metrics_interface.h" +#include "srsran/interfaces/sched_interface.h" +#include "srsran/interfaces/ue_interfaces.h" +#include "srsran/srslog/srslog.h" +#include "srsran/system/sys_metrics_processor.h" namespace srsenb { @@ -98,7 +98,7 @@ struct general_args_t { struct all_args_t { enb_args_t enb; enb_files_t enb_files; - srslte::rf_args_t rf; + srsran::rf_args_t rf; log_args_t log; gui_args_t gui; general_args_t general; @@ -149,11 +149,11 @@ private: // eNB components std::unique_ptr stack = nullptr; - std::unique_ptr radio = nullptr; + std::unique_ptr radio = nullptr; std::unique_ptr phy = nullptr; // System metrics processor. - srslte::sys_metrics_processor sys_proc; + srsran::sys_metrics_processor sys_proc; std::string get_build_mode(); std::string get_build_info(); diff --git a/srsenb/hdr/metrics_csv.h b/srsenb/hdr/metrics_csv.h index aeedf2e01..4cda5927d 100644 --- a/srsenb/hdr/metrics_csv.h +++ b/srsenb/hdr/metrics_csv.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -24,12 +24,12 @@ #include #include -#include "srslte/common/metrics_hub.h" -#include "srslte/interfaces/enb_metrics_interface.h" +#include "srsran/common/metrics_hub.h" +#include "srsran/interfaces/enb_metrics_interface.h" namespace srsenb { -class metrics_csv : public srslte::metrics_listener +class metrics_csv : public srsran::metrics_listener { public: metrics_csv(std::string filename); diff --git a/srsenb/hdr/metrics_json.h b/srsenb/hdr/metrics_json.h index 20efe6d7f..4692de03b 100644 --- a/srsenb/hdr/metrics_json.h +++ b/srsenb/hdr/metrics_json.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -18,12 +18,12 @@ #ifndef SRSENB_METRICS_JSON_H #define SRSENB_METRICS_JSON_H -#include "srslte/interfaces/enb_metrics_interface.h" -#include "srslte/srslog/log_channel.h" +#include "srsran/interfaces/enb_metrics_interface.h" +#include "srsran/srslog/log_channel.h" namespace srsenb { -class metrics_json : public srslte::metrics_listener +class metrics_json : public srsran::metrics_listener { public: metrics_json(srslog::log_channel& c) : log_c(c) {} diff --git a/srsenb/hdr/metrics_stdout.h b/srsenb/hdr/metrics_stdout.h index 3c5b5eb0e..494dcc08c 100644 --- a/srsenb/hdr/metrics_stdout.h +++ b/srsenb/hdr/metrics_stdout.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -22,11 +22,11 @@ #include #include -#include "srslte/interfaces/enb_metrics_interface.h" +#include "srsran/interfaces/enb_metrics_interface.h" namespace srsenb { -class metrics_stdout : public srslte::metrics_listener +class metrics_stdout : public srsran::metrics_listener { public: metrics_stdout(); diff --git a/srsenb/hdr/parser.h b/srsenb/hdr/parser.h index cb9e43563..35b14395c 100644 --- a/srsenb/hdr/parser.h +++ b/srsenb/hdr/parser.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,7 +13,7 @@ #ifndef SRSENB_PARSER_H #define SRSENB_PARSER_H -#include "srslte/asn1/asn1_utils.h" +#include "srsran/asn1/asn1_utils.h" #include #include #include diff --git a/srsenb/hdr/phy/enb_phy_base.h b/srsenb/hdr/phy/enb_phy_base.h index 7d1b758ac..5d4ee4af8 100644 --- a/srsenb/hdr/phy/enb_phy_base.h +++ b/srsenb/hdr/phy/enb_phy_base.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/srsenb/hdr/phy/lte/cc_worker.h b/srsenb/hdr/phy/lte/cc_worker.h index 5a9e8d163..d04b0b269 100644 --- a/srsenb/hdr/phy/lte/cc_worker.h +++ b/srsenb/hdr/phy/lte/cc_worker.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -16,7 +16,7 @@ #include #include "../phy_common.h" -#include "srslte/srslog/srslog.h" +#include "srsran/srslog/srslog.h" #define LOG_EXECTIME @@ -46,11 +46,11 @@ public: int read_pucch_d(cf_t* pusch_d); void start_plot(); - void work_ul(const srslte_ul_sf_cfg_t& ul_sf, stack_interface_phy_lte::ul_sched_t& ul_grants); - void work_dl(const srslte_dl_sf_cfg_t& dl_sf_cfg, + void work_ul(const srsran_ul_sf_cfg_t& ul_sf, stack_interface_phy_lte::ul_sched_t& ul_grants); + void work_dl(const srsran_dl_sf_cfg_t& dl_sf_cfg, stack_interface_phy_lte::dl_sched_t& dl_grants, stack_interface_phy_lte::ul_sched_t& ul_grants, - srslte_mbsfn_cfg_t* mbsfn_cfg); + srsran_mbsfn_cfg_t* mbsfn_cfg); uint32_t get_metrics(std::vector& metrics); @@ -59,10 +59,10 @@ private: constexpr static float PUCCH_RL_CORR_TH = 0.15f; int encode_pdsch(stack_interface_phy_lte::dl_sched_grant_t* grants, uint32_t nof_grants); - int encode_pmch(stack_interface_phy_lte::dl_sched_grant_t* grant, srslte_mbsfn_cfg_t* mbsfn_cfg); + int encode_pmch(stack_interface_phy_lte::dl_sched_grant_t* grant, srsran_mbsfn_cfg_t* mbsfn_cfg); void decode_pusch_rnti(stack_interface_phy_lte::ul_sched_grant_t& ul_grant, - srslte_ul_cfg_t& ul_cfg, - srslte_pusch_res_t& pusch_res); + srsran_ul_cfg_t& ul_cfg, + srsran_pusch_res_t& pusch_res); void decode_pusch(stack_interface_phy_lte::ul_sched_grant_t* grants, uint32_t nof_pusch); int encode_phich(stack_interface_phy_lte::ul_sched_ack_t* acks, uint32_t nof_acks); int encode_pdcch_dl(stack_interface_phy_lte::dl_sched_grant_t* grants, uint32_t nof_grants); @@ -74,17 +74,17 @@ private: phy_common* phy = nullptr; bool initiated = false; - cf_t* signal_buffer_rx[SRSLTE_MAX_PORTS] = {}; - cf_t* signal_buffer_tx[SRSLTE_MAX_PORTS] = {}; + cf_t* signal_buffer_rx[SRSRAN_MAX_PORTS] = {}; + cf_t* signal_buffer_tx[SRSRAN_MAX_PORTS] = {}; uint32_t tti_rx = 0, tti_tx_dl = 0, tti_tx_ul = 0; - srslte_enb_dl_t enb_dl = {}; - srslte_enb_ul_t enb_ul = {}; + srsran_enb_dl_t enb_dl = {}; + srsran_enb_ul_t enb_ul = {}; - srslte_dl_sf_cfg_t dl_sf = {}; - srslte_ul_sf_cfg_t ul_sf = {}; + srsran_dl_sf_cfg_t dl_sf = {}; + srsran_ul_sf_cfg_t ul_sf = {}; - srslte_softbuffer_tx_t temp_mbsfn_softbuffer = {}; + srsran_softbuffer_tx_t temp_mbsfn_softbuffer = {}; // Class to store user information class ue @@ -95,7 +95,7 @@ private: // Do nothing } - srslte_phich_grant_t phich_grant = {}; + srsran_phich_grant_t phich_grant = {}; void metrics_read(phy_metrics_t* metrics); void metrics_dl(uint32_t mcs); diff --git a/srsenb/hdr/phy/lte/sf_worker.h b/srsenb/hdr/phy/lte/sf_worker.h index 35031ba3a..4830fea55 100644 --- a/srsenb/hdr/phy/lte/sf_worker.h +++ b/srsenb/hdr/phy/lte/sf_worker.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -18,13 +18,13 @@ #include "../phy_common.h" #include "cc_worker.h" -#include "srslte/srslog/srslog.h" -#include "srslte/srslte.h" +#include "srsran/srslog/srslog.h" +#include "srsran/srsran.h" namespace srsenb { namespace lte { -class sf_worker : public srslte::thread_pool::worker +class sf_worker : public srsran::thread_pool::worker { public: sf_worker(srslog::basic_logger& logger) : logger(logger) {} @@ -32,7 +32,7 @@ public: void init(phy_common* phy); cf_t* get_buffer_rx(uint32_t cc_idx, uint32_t antenna_idx); - void set_time(uint32_t tti_, uint32_t tx_worker_cnt_, const srslte::rf_timestamp_t& tx_time_); + void set_time(uint32_t tti_, uint32_t tx_worker_cnt_, const srsran::rf_timestamp_t& tx_time_); int add_rnti(uint16_t rnti, uint32_t cc_idx); void rem_rnti(uint16_t rnti); @@ -62,11 +62,11 @@ private: uint32_t tti_rx = 0, tti_tx_dl = 0, tti_tx_ul = 0; uint32_t t_rx = 0, t_tx_dl = 0, t_tx_ul = 0; uint32_t tx_worker_cnt = 0; - srslte::rf_timestamp_t tx_time = {}; + srsran::rf_timestamp_t tx_time = {}; std::vector > cc_workers; - srslte_softbuffer_tx_t temp_mbsfn_softbuffer = {}; + srsran_softbuffer_tx_t temp_mbsfn_softbuffer = {}; }; } // namespace lte diff --git a/srsenb/hdr/phy/lte/worker_pool.h b/srsenb/hdr/phy/lte/worker_pool.h index de93114d0..30ff8761c 100644 --- a/srsenb/hdr/phy/lte/worker_pool.h +++ b/srsenb/hdr/phy/lte/worker_pool.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -14,14 +14,14 @@ #define SRSENB_LTE_WORKER_POOL_H #include "sf_worker.h" -#include "srslte/common/thread_pool.h" +#include "srsran/common/thread_pool.h" namespace srsenb { namespace lte { class worker_pool { - srslte::thread_pool pool; + srsran::thread_pool pool; std::vector > workers; public: diff --git a/srsenb/hdr/phy/nr/cc_worker.h b/srsenb/hdr/phy/nr/cc_worker.h index 2e42a2ec1..b61a84651 100644 --- a/srsenb/hdr/phy/nr/cc_worker.h +++ b/srsenb/hdr/phy/nr/cc_worker.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,9 +13,9 @@ #ifndef SRSENB_NR_CC_WORKER_H #define SRSENB_NR_CC_WORKER_H -#include "srslte/interfaces/gnb_interfaces.h" -#include "srslte/phy/enb/enb_dl_nr.h" -#include "srslte/srslog/srslog.h" +#include "srsran/interfaces/gnb_interfaces.h" +#include "srsran/phy/enb/enb_dl_nr.h" +#include "srsran/srslog/srslog.h" #include #include @@ -24,11 +24,11 @@ namespace nr { typedef struct { uint32_t nof_carriers; - srslte_enb_dl_nr_args_t dl; + srsran_enb_dl_nr_args_t dl; } phy_nr_args_t; typedef struct { - srslte_sch_hl_cfg_nr_t pdsch; + srsran_sch_hl_cfg_nr_t pdsch; } phy_nr_cfg_t; class phy_nr_state @@ -45,7 +45,7 @@ public: args.dl.pdsch.measure_evm = true; args.dl.pdsch.measure_time = true; args.dl.pdsch.sch.disable_simd = true; - cfg.pdsch.sch_cfg.mcs_table = srslte_mcs_table_256qam; + cfg.pdsch.sch_cfg.mcs_table = srsran_mcs_table_256qam; } }; @@ -55,26 +55,26 @@ public: cc_worker(uint32_t cc_idx, srslog::basic_logger& logger, phy_nr_state* phy_state_); ~cc_worker(); - bool set_carrier(const srslte_carrier_nr_t* carrier); + bool set_carrier(const srsran_carrier_nr_t* carrier); void set_tti(uint32_t tti); cf_t* get_tx_buffer(uint32_t antenna_idx); cf_t* get_rx_buffer(uint32_t antenna_idx); uint32_t get_buffer_len(); - bool work_dl(const srslte_slot_cfg_t& dl_slot_cfg, stack_interface_phy_nr::dl_sched_t& dl_grants); + bool work_dl(const srsran_slot_cfg_t& dl_slot_cfg, stack_interface_phy_nr::dl_sched_t& dl_grants); private: int encode_pdsch(stack_interface_phy_nr::dl_sched_grant_t* grants, uint32_t nof_grants); int encode_pdcch_dl(stack_interface_phy_nr::dl_sched_grant_t* grants, uint32_t nof_grants); - srslte_slot_cfg_t dl_slot_cfg = {}; + srsran_slot_cfg_t dl_slot_cfg = {}; uint32_t cc_idx = 0; - std::array tx_buffer = {}; - std::array rx_buffer = {}; + std::array tx_buffer = {}; + std::array rx_buffer = {}; uint32_t buffer_sz = 0; phy_nr_state* phy_state; - srslte_enb_dl_nr_t enb_dl = {}; + srsran_enb_dl_nr_t enb_dl = {}; srslog::basic_logger& logger; }; diff --git a/srsenb/hdr/phy/nr/sf_worker.h b/srsenb/hdr/phy/nr/sf_worker.h index a56d038f4..bf15ccc1d 100644 --- a/srsenb/hdr/phy/nr/sf_worker.h +++ b/srsenb/hdr/phy/nr/sf_worker.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -15,8 +15,8 @@ #include "cc_worker.h" #include "srsenb/hdr/phy/phy_common.h" -#include "srslte/common/thread_pool.h" -#include "srslte/srslog/srslog.h" +#include "srsran/common/thread_pool.h" +#include "srsran/srslog/srslog.h" namespace srsenb { namespace nr { @@ -29,13 +29,13 @@ namespace nr { * A sf_worker object is executed by a thread within the thread_pool. */ -class sf_worker final : public srslte::thread_pool::worker +class sf_worker final : public srsran::thread_pool::worker { public: sf_worker(phy_common* phy_, phy_nr_state* phy_state_, srslog::basic_logger& logger); ~sf_worker(); - bool set_carrier_unlocked(uint32_t cc_idx, const srslte_carrier_nr_t* carrier_); + bool set_carrier_unlocked(uint32_t cc_idx, const srsran_carrier_nr_t* carrier_); /* Functions used by main PHY thread */ cf_t* get_buffer_rx(uint32_t cc_idx, uint32_t antenna_idx); @@ -54,7 +54,7 @@ private: srslog::basic_logger& logger; // Temporal attributes - srslte_softbuffer_tx_t softbuffer_tx = {}; + srsran_softbuffer_tx_t softbuffer_tx = {}; std::vector data; }; diff --git a/srsenb/hdr/phy/nr/worker_pool.h b/srsenb/hdr/phy/nr/worker_pool.h index 3cfbfbcb2..ebe00b378 100644 --- a/srsenb/hdr/phy/nr/worker_pool.h +++ b/srsenb/hdr/phy/nr/worker_pool.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -14,14 +14,14 @@ #define SRSUE_NR_WORKER_POOL_H #include "sf_worker.h" -#include "srslte/common/thread_pool.h" +#include "srsran/common/thread_pool.h" namespace srsenb { namespace nr { class worker_pool { - srslte::thread_pool pool; + srsran::thread_pool pool; std::vector > workers; phy_nr_state phy_state; diff --git a/srsenb/hdr/phy/phy.h b/srsenb/hdr/phy/phy.h index a29072eb3..5a46315bd 100644 --- a/srsenb/hdr/phy/phy.h +++ b/srsenb/hdr/phy/phy.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -16,16 +16,16 @@ #include "lte/sf_worker.h" #include "phy_common.h" #include "srsenb/hdr/phy/enb_phy_base.h" -#include "srslte/common/trace.h" -#include "srslte/interfaces/enb_metrics_interface.h" -#include "srslte/interfaces/radio_interfaces.h" -#include "srslte/radio/radio.h" -#include "srslte/srslog/srslog.h" +#include "srsran/common/trace.h" +#include "srsran/interfaces/enb_metrics_interface.h" +#include "srsran/interfaces/radio_interfaces.h" +#include "srsran/radio/radio.h" +#include "srsran/srslog/srslog.h" #include "txrx.h" namespace srsenb { -class phy final : public enb_phy_base, public phy_interface_stack_lte, public srslte::phy_interface_radio +class phy final : public enb_phy_base, public phy_interface_stack_lte, public srsran::phy_interface_radio { public: phy(srslog::sink& log_sink); @@ -33,7 +33,7 @@ public: int init(const phy_args_t& args, const phy_cfg_t& cfg, - srslte::radio_interface_phy* radio_, + srsran::radio_interface_phy* radio_, stack_interface_phy_lte* stack_); void stop() override; @@ -43,10 +43,10 @@ public: void rem_rnti(uint16_t rnti) final; void set_mch_period_stop(uint32_t stop) final; void set_activation_deactivation_scell(uint16_t rnti, - const std::array& activation) override; + const std::array& activation) override; /*RRC-PHY interface*/ - void configure_mbsfn(srslte::sib2_mbms_t* sib2, srslte::sib13_t* sib13, const srslte::mcch_msg_t& mcch) override; + void configure_mbsfn(srsran::sib2_mbms_t* sib2, srsran::sib13_t* sib13, const srsran::mcch_msg_t& mcch) override; void start_plot() override; void set_config(uint16_t rnti, const phy_rrc_cfg_list_t& phy_cfg_list) override; @@ -59,10 +59,10 @@ public: void radio_overflow() override{}; void radio_failure() override{}; - void srslte_phy_logger(phy_logger_level_t log_level, char* str); + void srsran_phy_logger(phy_logger_level_t log_level, char* str); private: - srslte::phy_cfg_mbsfn_t mbsfn_config = {}; + srsran::phy_cfg_mbsfn_t mbsfn_config = {}; uint32_t nof_workers = 0; const static int MAX_WORKERS = 4; @@ -71,7 +71,7 @@ private: const static int SF_RECV_THREAD_PRIO = 1; const static int WORKERS_THREAD_PRIO = 2; - srslte::radio_interface_phy* radio = nullptr; + srsran::radio_interface_phy* radio = nullptr; srslog::sink& log_sink; srslog::basic_logger& phy_log; @@ -85,7 +85,7 @@ private: bool initialized = false; - srslte_prach_cfg_t prach_cfg = {}; + srsran_prach_cfg_t prach_cfg = {}; void parse_common_config(const phy_cfg_t& cfg); }; diff --git a/srsenb/hdr/phy/phy_common.h b/srsenb/hdr/phy/phy_common.h index 4e85a404a..7ff216ca1 100644 --- a/srsenb/hdr/phy/phy_common.h +++ b/srsenb/hdr/phy/phy_common.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -15,18 +15,18 @@ #include "phy_interfaces.h" #include "srsenb/hdr/phy/phy_ue_db.h" -#include "srslte/common/gen_mch_tables.h" -#include "srslte/common/interfaces_common.h" -#include "srslte/common/standard_streams.h" -#include "srslte/common/thread_pool.h" -#include "srslte/common/threads.h" -#include "srslte/interfaces/enb_metrics_interface.h" -#include "srslte/interfaces/radio_interfaces.h" -#include "srslte/phy/channel/channel.h" -#include "srslte/radio/radio.h" +#include "srsran/common/gen_mch_tables.h" +#include "srsran/common/interfaces_common.h" +#include "srsran/common/standard_streams.h" +#include "srsran/common/thread_pool.h" +#include "srsran/common/threads.h" +#include "srsran/interfaces/enb_metrics_interface.h" +#include "srsran/interfaces/radio_interfaces.h" +#include "srsran/phy/channel/channel.h" +#include "srsran/radio/radio.h" #include -#include +#include #include namespace srsenb { @@ -38,7 +38,7 @@ public: bool init(const phy_cell_cfg_list_t& cell_list_, const phy_cell_cfg_list_nr_t& cell_list_nr_, - srslte::radio_interface_phy* radio_handler, + srsran::radio_interface_phy* radio_handler, stack_interface_phy_lte* mac); void reset(); void stop(); @@ -46,7 +46,7 @@ public: /** * TTI transmission semaphore, used for ensuring that PHY workers transmit following start order */ - srslte::tti_semaphore semaphore; + srsran::tti_semaphore semaphore; /** * Performs common end worker transmission tasks such as transmission and stack TTI execution @@ -56,7 +56,7 @@ public: * @param tx_time timestamp to transmit samples * @param is_nr flag is true if it is called from NR */ - void worker_end(void* tx_sem_id, srslte::rf_buffer_t& buffer, srslte::rf_timestamp_t& tx_time, bool is_nr = false); + void worker_end(void* tx_sem_id, srsran::rf_buffer_t& buffer, srsran::rf_timestamp_t& tx_time, bool is_nr = false); // Common objects phy_args_t params = {}; @@ -143,17 +143,17 @@ public: return ret; }; - srslte_cell_t get_cell(uint32_t cc_idx) + srsran_cell_t get_cell(uint32_t cc_idx) { - srslte_cell_t c = {}; + srsran_cell_t c = {}; if (cc_idx < cell_list_lte.size()) { c = cell_list_lte[cc_idx].cell; } return c; }; - srslte_carrier_nr_t get_cell_nr(uint32_t cc_idx) + srsran_carrier_nr_t get_cell_nr(uint32_t cc_idx) { - srslte_carrier_nr_t c = {}; + srsran_carrier_nr_t c = {}; if (cc_idx < cell_list_nr.size()) { c = cell_list_nr[cc_idx].carrier; } @@ -183,7 +183,7 @@ public: return; } - srslte::console("cell ID %d not found\n", cell_id); + srsran::console("cell ID %d not found\n", cell_id); } float get_cell_gain(uint32_t cc_idx) @@ -201,21 +201,21 @@ public: } // Common Physical Uplink DMRS configuration - srslte_refsignal_dmrs_pusch_cfg_t dmrs_pusch_cfg = {}; + srsran_refsignal_dmrs_pusch_cfg_t dmrs_pusch_cfg = {}; - srslte::radio_interface_phy* radio = nullptr; + srsran::radio_interface_phy* radio = nullptr; stack_interface_phy_lte* stack = nullptr; - srslte::channel_ptr dl_channel = nullptr; + srsran::channel_ptr dl_channel = nullptr; /** * UE Database object, direct public access, all PHY threads should be able to access this attribute directly */ phy_ue_db ue_db; - void configure_mbsfn(srslte::phy_cfg_mbsfn_t* cfg); + void configure_mbsfn(srsran::phy_cfg_mbsfn_t* cfg); void build_mch_table(); void build_mcch_table(); - bool is_mbsfn_sf(srslte_mbsfn_cfg_t* cfg, uint32_t phy_tti); + bool is_mbsfn_sf(srsran_mbsfn_cfg_t* cfg, uint32_t phy_tti); void set_mch_period_stop(uint32_t stop); // Getters and setters for ul grants which need to be shared between workers @@ -225,7 +225,7 @@ public: private: // Common objects for scheduling grants - srslte::circular_array ul_grants = {}; + srsran::circular_array ul_grants = {}; std::mutex grant_mutex = {}; phy_cell_cfg_list_t cell_list_lte; @@ -234,15 +234,15 @@ private: bool have_mtch_stop = false; pthread_mutex_t mtch_mutex = {}; pthread_cond_t mtch_cvar = {}; - srslte::phy_cfg_mbsfn_t mbsfn = {}; + srsran::phy_cfg_mbsfn_t mbsfn = {}; bool sib13_configured = false; bool mcch_configured = false; uint8_t mch_table[40] = {}; uint8_t mcch_table[10] = {}; uint32_t mch_period_stop = 0; - bool is_mch_subframe(srslte_mbsfn_cfg_t* cfg, uint32_t phy_tti); - bool is_mcch_subframe(srslte_mbsfn_cfg_t* cfg, uint32_t phy_tti); - srslte::rf_buffer_t nr_tx_buffer; + bool is_mch_subframe(srsran_mbsfn_cfg_t* cfg, uint32_t phy_tti); + bool is_mcch_subframe(srsran_mbsfn_cfg_t* cfg, uint32_t phy_tti); + srsran::rf_buffer_t nr_tx_buffer; bool nr_tx_buffer_ready = false; }; diff --git a/srsenb/hdr/phy/phy_interfaces.h b/srsenb/hdr/phy/phy_interfaces.h index 5f9661875..026c9d403 100644 --- a/srsenb/hdr/phy/phy_interfaces.h +++ b/srsenb/hdr/phy/phy_interfaces.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,17 +13,17 @@ #ifndef SRSENB_PHY_INTERFACES_H_ #define SRSENB_PHY_INTERFACES_H_ -#include "srslte/asn1/rrc/rr_common.h" -#include "srslte/common/interfaces_common.h" -#include "srslte/phy/channel/channel.h" -#include "srslte/phy/common/phy_common_nr.h" +#include "srsran/asn1/rrc/rr_common.h" +#include "srsran/common/interfaces_common.h" +#include "srsran/phy/channel/channel.h" +#include "srsran/phy/common/phy_common_nr.h" #include #include namespace srsenb { struct phy_cell_cfg_t { - srslte_cell_t cell; + srsran_cell_t cell; uint32_t rf_port; uint32_t cell_id; double dl_freq_hz; @@ -34,7 +34,7 @@ struct phy_cell_cfg_t { }; struct phy_cell_cfg_nr_t { - srslte_carrier_nr_t carrier; + srsran_carrier_nr_t carrier; uint32_t rf_port; uint32_t cell_id; double dl_freq_hz; @@ -49,7 +49,7 @@ typedef std::vector phy_cell_cfg_list_nr_t; struct phy_args_t { std::string type; - srslte::phy_log_args_t log; + srsran::phy_log_args_t log; float max_prach_offset_us = 10; int pusch_max_its = 10; @@ -64,10 +64,10 @@ struct phy_args_t { bool pucch_meas_ta = true; uint32_t nof_prach_threads = 1; - srslte::channel::args_t dl_channel_args; - srslte::channel::args_t ul_channel_args; + srsran::channel::args_t dl_channel_args; + srsran::channel::args_t ul_channel_args; - srslte::vnf_args_t vnf_args; + srsran::vnf_args_t vnf_args; }; struct phy_cfg_t { diff --git a/srsenb/hdr/phy/phy_metrics.h b/srsenb/hdr/phy/phy_metrics.h index 592cf1729..2207de864 100644 --- a/srsenb/hdr/phy/phy_metrics.h +++ b/srsenb/hdr/phy/phy_metrics.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/srsenb/hdr/phy/phy_ue_db.h b/srsenb/hdr/phy/phy_ue_db.h index 1be9aa9bb..d1a477f29 100644 --- a/srsenb/hdr/phy/phy_ue_db.h +++ b/srsenb/hdr/phy/phy_ue_db.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -14,11 +14,11 @@ #define SRSENB_PHY_UE_DB_H_ #include "phy_interfaces.h" -#include "srslte/interfaces/enb_mac_interfaces.h" -#include "srslte/interfaces/enb_phy_interfaces.h" +#include "srsran/interfaces/enb_mac_interfaces.h" +#include "srsran/interfaces/enb_phy_interfaces.h" #include #include -#include +#include namespace srsenb { @@ -78,11 +78,11 @@ private: cell_state_t state = cell_state_none; ///< Configuration state uint32_t enb_cc_idx = 0; ///< Corresponding eNb cell/carrier index uint8_t last_ri = 0; ///< Last reported rank indicator - srslte::circular_array last_tb = + srsran::circular_array last_tb = {}; ///< Stores last PUSCH Resource allocation bool stash_use_tbs_index_alt = false; - srslte::phy_cfg_t phy_cfg; ///< Configuration, it has a default constructor - srslte::circular_array is_grant_available; ///< Indicates whether there is an available grant + srsran::phy_cfg_t phy_cfg; ///< Configuration, it has a default constructor + srsran::circular_array is_grant_available; ///< Indicates whether there is an available grant } cell_info_t; /** @@ -90,8 +90,8 @@ private: */ struct common_ue { bool stashed_multiple_csi_request_enabled = false; - srslte::circular_array pdsch_ack = {}; ///< Pending acknowledgements for this Cell - std::array cell_info = {}; ///< Cell information, indexed by ue_cell_idx + srsran::circular_array pdsch_ack = {}; ///< Pending acknowledgements for this Cell + std::array cell_info = {}; ///< Cell information, indexed by ue_cell_idx }; /** @@ -141,11 +141,11 @@ private: * @param rnti identifier of the UE (requires assertion prior to call) * @param phy_cfg points to the PHY configuration for a given cell/carrier */ - inline void _set_common_config_rnti(uint16_t rnti, srslte::phy_cfg_t& phy_cfg) const; + inline void _set_common_config_rnti(uint16_t rnti, srsran::phy_cfg_t& phy_cfg) const; /** * Gets the SCell index for a given RNTI and a eNb cell/carrier. It returns the SCell index (0 if PCell) if the cc_idx - * is found among the configured cells/carriers. Otherwise, it returns SRSLTE_MAX_CARRIERS. + * is found among the configured cells/carriers. Otherwise, it returns SRSRAN_MAX_CARRIERS. * * @param rnti identifier of the UE (requires assertion prior to call) * @param enb_cc_idx the eNb cell/carrier index to look for in the RNTI. @@ -168,7 +168,7 @@ private: /** * Checks if a given RNTI exists in the database * @param rnti provides UE identifier - * @return SRSLTE_SUCCESS if the indicated RNTI exists, otherwise it returns SRSLTE_ERROR + * @return SRSRAN_SUCCESS if the indicated RNTI exists, otherwise it returns SRSRAN_ERROR */ inline int _assert_rnti(uint16_t rnti) const; @@ -176,7 +176,7 @@ private: * Checks if an RNTI is configured to use an specified eNb cell/carrier as PCell or SCell * @param rnti provides UE identifier * @param enb_cc_idx provides eNb cell/carrier - * @return SRSLTE_SUCCESS if the indicated RNTI exists, otherwise it returns SRSLTE_ERROR + * @return SRSRAN_SUCCESS if the indicated RNTI exists, otherwise it returns SRSRAN_ERROR */ inline int _assert_enb_cc(uint16_t rnti, uint32_t enb_cc_idx) const; @@ -184,7 +184,7 @@ private: * Checks if an RNTI uses a given eNb cell/carrier as PCell * @param rnti provides UE identifier * @param enb_cc_idx provides eNb cell/carrier index - * @return SRSLTE_SUCCESS if the indicated eNb cell/carrier of the RNTI is a PCell, otherwise it returns SRSLTE_ERROR + * @return SRSRAN_SUCCESS if the indicated eNb cell/carrier of the RNTI is a PCell, otherwise it returns SRSRAN_ERROR */ inline int _assert_enb_pcell(uint16_t rnti, uint32_t enb_cc_idx) const; @@ -192,7 +192,7 @@ private: * Checks if an RNTI is configured to use an specified UE cell/carrier as PCell or SCell * @param rnti provides UE identifier * @param ue_cc_idx UE cell/carrier index that is asserted - * @return SRSLTE_SUCCESS if the indicated cell/carrier index is valid, otherwise it returns SRSLTE_ERROR + * @return SRSRAN_SUCCESS if the indicated cell/carrier index is valid, otherwise it returns SRSRAN_ERROR */ inline int _assert_ue_cc(uint16_t rnti, uint32_t ue_cc_idx) const; @@ -200,19 +200,19 @@ private: * Checks if an RNTI is configured to use an specified eNb cell/carrier as PCell or SCell and it is active * @param rnti provides UE identifier * @param enb_cc_idx UE cell/carrier index that is asserted - * @return SRSLTE_SUCCESS if the indicated eNb cell/carrier is active, otherwise it returns SRSLTE_ERROR + * @return SRSRAN_SUCCESS if the indicated eNb cell/carrier is active, otherwise it returns SRSRAN_ERROR */ inline int _assert_active_enb_cc(uint16_t rnti, uint32_t enb_cc_idx) const; /** * Internal eNb stack assertion - * @return SRSLTE_SUCCESS if available, otherwise it returns SRSLTE_ERROR + * @return SRSRAN_SUCCESS if available, otherwise it returns SRSRAN_ERROR */ inline int _assert_stack() const; /** * Internal eNb Cell list assertion - * @return SRSLTE_SUCCESS if available, otherwise it returns SRSLTE_ERROR + * @return SRSRAN_SUCCESS if available, otherwise it returns SRSRAN_ERROR */ inline int _assert_cell_list_cfg() const; @@ -223,7 +223,7 @@ private: * @param enb_cc_idx eNb cell index * @return The PHY configuration of the indicated UE for the indicated eNb carrier/call index. */ - inline srslte::phy_cfg_t _get_rnti_config(uint16_t rnti, uint32_t enb_cc_idx) const; + inline srsran::phy_cfg_t _get_rnti_config(uint16_t rnti, uint32_t enb_cc_idx) const; /** * Count number of configured secondary serving cells @@ -297,7 +297,7 @@ public: * @param rnti identifier of the UE * @param cc_idx the eNb cell/carrier identifier */ - srslte_dl_cfg_t get_dl_config(uint16_t rnti, uint32_t enb_cc_idx) const; + srsran_dl_cfg_t get_dl_config(uint16_t rnti, uint32_t enb_cc_idx) const; /** * Get the current DCI configuration for PDSCH physical layer configuration for an RNTI and an eNb cell/carrier @@ -305,7 +305,7 @@ public: * @param rnti identifier of the UE * @param cc_idx the eNb cell/carrier identifier */ - srslte_dci_cfg_t get_dci_dl_config(uint16_t rnti, uint32_t enb_cc_idx) const; + srsran_dci_cfg_t get_dci_dl_config(uint16_t rnti, uint32_t enb_cc_idx) const; /** * Get the current PUCCH physical layer configuration for an RNTI and an eNb cell/carrier. @@ -313,7 +313,7 @@ public: * @param rnti identifier of the UE * @param cc_idx the eNb cell/carrier identifier */ - srslte_ul_cfg_t get_ul_config(uint16_t rnti, uint32_t enb_cc_idx) const; + srsran_ul_cfg_t get_ul_config(uint16_t rnti, uint32_t enb_cc_idx) const; /** * Get the current DCI configuration for PUSCH physical layer configuration for an RNTI and an eNb cell/carrier @@ -321,7 +321,7 @@ public: * @param rnti identifier of the UE * @param cc_idx the eNb cell/carrier identifier */ - srslte_dci_cfg_t get_dci_ul_config(uint16_t rnti, uint32_t enb_cc_idx) const; + srsran_dci_cfg_t get_dci_ul_config(uint16_t rnti, uint32_t enb_cc_idx) const; /** * Removes all the pending ACKs of all the RNTIs for a given TTI @@ -338,7 +338,7 @@ public: * @param dci carries the Transport Block and required scheduling information * */ - bool set_ack_pending(uint32_t tti, uint32_t enb_cc_idx, const srslte_dci_dl_t& dci); + bool set_ack_pending(uint32_t tti, uint32_t enb_cc_idx, const srsran_dci_dl_t& dci); /** * Fills the Uplink Control Information (UCI) configuration and returns true/false idicating if UCI bits are required. @@ -354,7 +354,7 @@ public: uint16_t rnti, bool aperiodic_cqi_request, bool is_pusch_available, - srslte_uci_cfg_t& uci_cfg); + srsran_uci_cfg_t& uci_cfg); /** * Sends the decoded Uplink Control Information by PUCCH or PUSCH to MAC @@ -366,8 +366,8 @@ public: void send_uci_data(uint32_t tti, uint16_t rnti, uint32_t enb_cc_idx, - const srslte_uci_cfg_t& uci_cfg, - const srslte_uci_value_t& uci_value); + const srsran_uci_cfg_t& uci_cfg, + const srsran_uci_value_t& uci_value); /** * Set the latest UL Transport Block resource allocation for a given RNTI, eNb cell/carrier and UL HARQ process @@ -378,7 +378,7 @@ public: * @param pid HARQ process identifier * @param tb the Resource Allocation for the PUSCH transport block */ - void set_last_ul_tb(uint16_t rnti, uint32_t enb_cc_idx, uint32_t pid, srslte_ra_tb_t tb); + void set_last_ul_tb(uint16_t rnti, uint32_t enb_cc_idx, uint32_t pid, srsran_ra_tb_t tb); /** * Get the latest UL Transport Block resource allocation for a given RNTI, eNb cell/carrier and UL HARQ process @@ -390,7 +390,7 @@ public: * @param pid HARQ process identifier * @return the Resource Allocation for the PUSCH transport block */ - srslte_ra_tb_t get_last_ul_tb(uint16_t rnti, uint32_t enb_cc_idx, uint32_t pid) const; + srsran_ra_tb_t get_last_ul_tb(uint16_t rnti, uint32_t enb_cc_idx, uint32_t pid) const; /** * Flags to true the UL grant available for a given TTI, RNTI and eNb cell/carrier index diff --git a/srsenb/hdr/phy/prach_worker.h b/srsenb/hdr/phy/prach_worker.h index 7d503bf13..558a74aa0 100644 --- a/srsenb/hdr/phy/prach_worker.h +++ b/srsenb/hdr/phy/prach_worker.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,11 +13,11 @@ #ifndef SRSENB_PRACH_WORKER_H #define SRSENB_PRACH_WORKER_H -#include "srslte/common/block_queue.h" -#include "srslte/common/buffer_pool.h" -#include "srslte/common/threads.h" -#include "srslte/interfaces/enb_phy_interfaces.h" -#include "srslte/srslog/srslog.h" +#include "srsran/common/block_queue.h" +#include "srsran/common/buffer_pool.h" +#include "srsran/common/threads.h" +#include "srsran/interfaces/enb_phy_interfaces.h" +#include "srsran/srslog/srslog.h" // Setting ENABLE_PRACH_GUI to non zero enables a GUI showing signal received in the PRACH window. #define ENABLE_PRACH_GUI 0 @@ -30,7 +30,7 @@ namespace srsenb { class stack_interface_phy_lte; -class prach_worker : srslte::thread +class prach_worker : srsran::thread { public: prach_worker(uint32_t cc_idx_, srslog::basic_logger& logger) : buffer_pool(8), thread("PRACH_WORKER"), logger(logger) @@ -38,8 +38,8 @@ public: cc_idx = cc_idx_; } - int init(const srslte_cell_t& cell_, - const srslte_prach_cfg_t& prach_cfg_, + int init(const srsran_cell_t& cell_, + const srsran_prach_cfg_t& prach_cfg_, stack_interface_phy_lte* mac, int priority, uint32_t nof_workers); @@ -54,13 +54,13 @@ private: float prach_offsets[165] = {}; float prach_p2avg[165] = {}; - srslte_cell_t cell = {}; - srslte_prach_cfg_t prach_cfg = {}; - srslte_prach_t prach = {}; + srsran_cell_t cell = {}; + srsran_prach_cfg_t prach_cfg = {}; + srsran_prach_t prach = {}; #if defined(ENABLE_GUI) and ENABLE_PRACH_GUI plot_real_t plot_real; - std::array plot_buffer; + std::array plot_buffer; #endif // defined(ENABLE_GUI) and ENABLE_PRACH_GUI const static int sf_buffer_sz = 128 * 1024; @@ -76,12 +76,12 @@ private: cf_t samples[sf_buffer_sz] = {}; uint32_t nof_samples = 0; uint32_t tti = 0; -#ifdef SRSLTE_BUFFER_POOL_LOG_ENABLED - char debug_name[SRSLTE_BUFFER_POOL_LOG_NAME_LEN]; -#endif /* SRSLTE_BUFFER_POOL_LOG_ENABLED */ +#ifdef SRSRAN_BUFFER_POOL_LOG_ENABLED + char debug_name[SRSRAN_BUFFER_POOL_LOG_NAME_LEN]; +#endif /* SRSRAN_BUFFER_POOL_LOG_ENABLED */ }; - srslte::buffer_pool buffer_pool; - srslte::block_queue pending_buffers; + srsran::buffer_pool buffer_pool; + srsran::block_queue pending_buffers; srslog::basic_logger& logger; sf_buffer* current_buffer = nullptr; @@ -107,8 +107,8 @@ public: ~prach_worker_pool() = default; void init(uint32_t cc_idx, - const srslte_cell_t& cell_, - const srslte_prach_cfg_t& prach_cfg_, + const srsran_cell_t& cell_, + const srsran_prach_cfg_t& prach_cfg_, stack_interface_phy_lte* mac, srslog::basic_logger& logger, int priority, @@ -138,7 +138,7 @@ public: int new_tti(uint32_t cc_idx, uint32_t tti, cf_t* buffer) { - int ret = SRSLTE_ERROR; + int ret = SRSRAN_ERROR; if (cc_idx < prach_vec.size()) { ret = prach_vec[cc_idx]->new_tti(tti, buffer); } diff --git a/srsenb/hdr/phy/txrx.h b/srsenb/hdr/phy/txrx.h index 761ea2f57..0d5aa7332 100644 --- a/srsenb/hdr/phy/txrx.h +++ b/srsenb/hdr/phy/txrx.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -17,18 +17,18 @@ #include "prach_worker.h" #include "srsenb/hdr/phy/lte/worker_pool.h" #include "srsenb/hdr/phy/nr/worker_pool.h" -#include "srslte/config.h" -#include "srslte/phy/channel/channel.h" -#include "srslte/radio/radio.h" +#include "srsran/config.h" +#include "srsran/phy/channel/channel.h" +#include "srsran/radio/radio.h" namespace srsenb { -class txrx final : public srslte::thread +class txrx final : public srsran::thread { public: txrx(srslog::basic_logger& logger); bool init(stack_interface_phy_lte* stack_, - srslte::radio_interface_phy* radio_handler, + srsran::radio_interface_phy* radio_handler, lte::worker_pool* lte_workers_, nr::worker_pool* nr_workers_, phy_common* worker_com, @@ -40,13 +40,13 @@ private: void run_thread() override; stack_interface_phy_lte* stack = nullptr; - srslte::radio_interface_phy* radio_h = nullptr; + srsran::radio_interface_phy* radio_h = nullptr; srslog::basic_logger& logger; lte::worker_pool* lte_workers = nullptr; nr::worker_pool* nr_workers = nullptr; prach_worker_pool* prach = nullptr; phy_common* worker_com = nullptr; - srslte::channel_ptr ul_channel = nullptr; + srsran::channel_ptr ul_channel = nullptr; // Main system TTI counter uint32_t tti = 0; diff --git a/srsenb/hdr/phy/vnf_phy_nr.h b/srsenb/hdr/phy/vnf_phy_nr.h index 664828b21..1be7633b8 100644 --- a/srsenb/hdr/phy/vnf_phy_nr.h +++ b/srsenb/hdr/phy/vnf_phy_nr.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -15,10 +15,10 @@ #include "srsenb/hdr/phy/enb_phy_base.h" #include "srsenb/hdr/phy/phy_common.h" -#include "srslte/common/basic_vnf.h" -#include "srslte/interfaces/enb_metrics_interface.h" -#include "srslte/interfaces/gnb_interfaces.h" -#include "srslte/interfaces/radio_interfaces.h" +#include "srsran/common/basic_vnf.h" +#include "srsran/interfaces/enb_metrics_interface.h" +#include "srsran/interfaces/gnb_interfaces.h" +#include "srsran/interfaces/radio_interfaces.h" namespace srsenb { @@ -51,7 +51,7 @@ public: } private: - std::unique_ptr vnf = nullptr; + std::unique_ptr vnf = nullptr; bool initialized = false; diff --git a/srsenb/hdr/stack/enb_stack_base.h b/srsenb/hdr/stack/enb_stack_base.h index 20427f712..a8d9b5b2a 100644 --- a/srsenb/hdr/stack/enb_stack_base.h +++ b/srsenb/hdr/stack/enb_stack_base.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,12 +10,12 @@ * */ -#ifndef SRSLTE_ENB_STACK_BASE_H -#define SRSLTE_ENB_STACK_BASE_H +#ifndef SRSRAN_ENB_STACK_BASE_H +#define SRSRAN_ENB_STACK_BASE_H -#include "srslte/interfaces/enb_interfaces.h" -#include "srslte/interfaces/enb_mac_interfaces.h" -#include "srslte/interfaces/enb_s1ap_interfaces.h" +#include "srsran/interfaces/enb_interfaces.h" +#include "srsran/interfaces/enb_mac_interfaces.h" +#include "srsran/interfaces/enb_s1ap_interfaces.h" #include "srsue/hdr/stack/upper/gw.h" #include @@ -97,4 +97,4 @@ public: } // namespace srsenb -#endif // SRSLTE_ENB_STACK_BASE_H +#endif // SRSRAN_ENB_STACK_BASE_H diff --git a/srsenb/hdr/stack/enb_stack_lte.h b/srsenb/hdr/stack/enb_stack_lte.h index 0aec62c8d..2c954383b 100644 --- a/srsenb/hdr/stack/enb_stack_lte.h +++ b/srsenb/hdr/stack/enb_stack_lte.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -15,21 +15,21 @@ * Description: L2/L3 LTE eNB stack class. *****************************************************************************/ -#ifndef SRSLTE_ENB_STACK_LTE_H -#define SRSLTE_ENB_STACK_LTE_H +#ifndef SRSRAN_ENB_STACK_LTE_H +#define SRSRAN_ENB_STACK_LTE_H #include "mac/mac.h" #include "rrc/rrc.h" -#include "srslte/common/task_scheduler.h" +#include "srsran/common/task_scheduler.h" #include "upper/gtpu.h" #include "upper/pdcp.h" #include "upper/rlc.h" #include "upper/s1ap.h" #include "enb_stack_base.h" -#include "srslte/common/mac_pcap_net.h" -#include "srslte/interfaces/enb_interfaces.h" -#include "srslte/srslog/srslog.h" +#include "srsran/common/mac_pcap_net.h" +#include "srsran/interfaces/enb_interfaces.h" +#include "srsran/srslog/srslog.h" namespace srsenb { @@ -37,7 +37,7 @@ class enb_stack_lte final : public enb_stack_base, public stack_interface_phy_lte, public stack_interface_s1ap_lte, public stack_interface_gtpu_lte, - public srslte::thread + public srsran::thread { public: enb_stack_lte(srslog::sink& log_sink); @@ -109,7 +109,7 @@ private: void run_thread() override; void stop_impl(); void tti_clock_impl(); - void handle_mme_rx_packet(srslte::unique_byte_buffer_t pdu, + void handle_mme_rx_packet(srsran::unique_byte_buffer_t pdu, const sockaddr_in& from, const sctp_sndrcvinfo& sri, int flags); @@ -127,16 +127,16 @@ private: srslog::basic_logger& stack_logger; // PCAP and trace option - srslte::mac_pcap mac_pcap; - srslte::mac_pcap_net mac_pcap_net; - srslte::s1ap_pcap s1ap_pcap; + srsran::mac_pcap mac_pcap; + srsran::mac_pcap_net mac_pcap_net; + srsran::s1ap_pcap s1ap_pcap; // task handling - srslte::task_scheduler task_sched; - srslte::task_queue_handle enb_task_queue, gtpu_task_queue, mme_task_queue, sync_task_queue; + srsran::task_scheduler task_sched; + srsran::task_queue_handle enb_task_queue, gtpu_task_queue, mme_task_queue, sync_task_queue; // components that layers depend on (need to be destroyed after layers) - std::unique_ptr rx_sockets; + std::unique_ptr rx_sockets; srsenb::mac mac; srsenb::rlc rlc; @@ -151,9 +151,9 @@ private: // state bool started = false; - srslte::dyn_blocking_queue pending_stack_metrics; + srsran::dyn_blocking_queue pending_stack_metrics; }; } // namespace srsenb -#endif // SRSLTE_ENB_STACK_LTE_H +#endif // SRSRAN_ENB_STACK_LTE_H diff --git a/srsenb/hdr/stack/gnb_stack_nr.h b/srsenb/hdr/stack/gnb_stack_nr.h index 55accca04..d107f16a9 100644 --- a/srsenb/hdr/stack/gnb_stack_nr.h +++ b/srsenb/hdr/stack/gnb_stack_nr.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -15,8 +15,8 @@ * Description: L2/L3 gNB stack class. *****************************************************************************/ -#ifndef SRSLTE_GNB_STACK_NR_H -#define SRSLTE_GNB_STACK_NR_H +#ifndef SRSRAN_GNB_STACK_NR_H +#define SRSRAN_GNB_STACK_NR_H #include "srsenb/hdr/stack/mac/mac_nr.h" #include "srsenb/hdr/stack/rrc/rrc_nr.h" @@ -28,10 +28,10 @@ #include "enb_stack_base.h" #include "srsenb/hdr/enb.h" -#include "srslte/interfaces/gnb_interfaces.h" +#include "srsran/interfaces/gnb_interfaces.h" // This is needed for GW -#include "srslte/interfaces/ue_interfaces.h" +#include "srsran/interfaces/ue_interfaces.h" #include "srsue/hdr/stack/upper/gw.h" namespace srsenb { @@ -40,7 +40,7 @@ class gnb_stack_nr final : public srsenb::enb_stack_base, public stack_interface_phy_nr, public stack_interface_mac, public srsue::stack_interface_gw, - public srslte::thread + public srsran::thread { public: explicit gnb_stack_nr(); @@ -63,7 +63,7 @@ public: int rx_data_indication(rx_data_ind_t& grant); // Temporary GW interface - void write_sdu(uint32_t lcid, srslte::unique_byte_buffer_t sdu); + void write_sdu(uint32_t lcid, srsran::unique_byte_buffer_t sdu); bool is_lcid_enabled(uint32_t lcid); bool switch_on(); void run_tti(uint32_t tti); @@ -83,8 +83,8 @@ private: // task scheduling static const int STACK_MAIN_THREAD_PRIO = 4; - srslte::task_scheduler task_sched; - srslte::task_multiqueue::queue_handle sync_task_queue, ue_task_queue, gw_task_queue, mac_task_queue; + srsran::task_scheduler task_sched; + srsran::task_multiqueue::queue_handle sync_task_queue, ue_task_queue, gw_task_queue, mac_task_queue; // derived std::unique_ptr m_mac; @@ -103,4 +103,4 @@ private: } // namespace srsenb -#endif // SRSLTE_GNB_STACK_NR_H +#endif // SRSRAN_GNB_STACK_NR_H diff --git a/srsenb/hdr/stack/mac/mac.h b/srsenb/hdr/stack/mac/mac.h index 16a95cee5..cb0061341 100644 --- a/srsenb/hdr/stack/mac/mac.h +++ b/srsenb/hdr/stack/mac/mac.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -15,16 +15,16 @@ #include "sched.h" #include "srsenb/hdr/stack/mac/schedulers/sched_time_rr.h" -#include "srslte/common/mac_pcap.h" -#include "srslte/common/mac_pcap_net.h" -#include "srslte/common/task_scheduler.h" -#include "srslte/common/threads.h" -#include "srslte/common/tti_sync_cv.h" -#include "srslte/interfaces/enb_mac_interfaces.h" -#include "srslte/interfaces/enb_metrics_interface.h" -#include "srslte/interfaces/enb_rrc_interface_types.h" -#include "srslte/interfaces/sched_interface.h" -#include "srslte/srslog/srslog.h" +#include "srsran/common/mac_pcap.h" +#include "srsran/common/mac_pcap_net.h" +#include "srsran/common/task_scheduler.h" +#include "srsran/common/threads.h" +#include "srsran/common/tti_sync_cv.h" +#include "srsran/interfaces/enb_mac_interfaces.h" +#include "srsran/interfaces/enb_metrics_interface.h" +#include "srsran/interfaces/enb_rrc_interface_types.h" +#include "srsran/interfaces/sched_interface.h" +#include "srsran/srslog/srslog.h" #include "ta.h" #include "ue.h" #include @@ -34,7 +34,7 @@ namespace srsenb { class mac final : public mac_interface_phy_lte, public mac_interface_rlc, public mac_interface_rrc { public: - mac(srslte::ext_task_sched_handle task_sched_, srslog::basic_logger& logger); + mac(srsran::ext_task_sched_handle task_sched_, srslog::basic_logger& logger); ~mac(); bool init(const mac_args_t& args_, const cell_list_t& cells_, @@ -43,8 +43,8 @@ public: rrc_interface_mac* rrc); void stop(); - void start_pcap(srslte::mac_pcap* pcap_); - void start_pcap_net(srslte::mac_pcap_net* pcap_net_); + void start_pcap(srsran::mac_pcap* pcap_); + void start_pcap_net(srsran::mac_pcap_net* pcap_net_); /******** Interface from PHY (PHY -> MAC) ****************/ int sr_detected(uint32_t tti, uint16_t rnti) final; @@ -92,9 +92,9 @@ public: bool process_pdus(); void get_metrics(mac_metrics_t& metrics); - void write_mcch(const srslte::sib2_mbms_t* sib2_, - const srslte::sib13_t* sib13_, - const srslte::mcch_msg_t* mcch_, + void write_mcch(const srsran::sib2_mbms_t* sib2_, + const srsran::sib13_t* sib13_, + const srsran::mcch_msg_t* mcch_, const uint8_t* mcch_payload, const uint8_t mcch_payload_length) override; @@ -117,13 +117,13 @@ private: phy_interface_stack_lte* phy_h = nullptr; rlc_interface_mac* rlc_h = nullptr; rrc_interface_mac* rrc_h = nullptr; - srslte::ext_task_sched_handle task_sched; + srsran::ext_task_sched_handle task_sched; cell_list_t cells = {}; mac_args_t args = {}; // derived from args - srslte::task_multiqueue::queue_handle stack_task_queue; + srsran::task_multiqueue::queue_handle stack_task_queue; bool started = false; @@ -137,7 +137,7 @@ private: std::map > ue_db, ues_to_rem; uint16_t last_rnti = 70; - srslte::static_blocking_queue, 32> ue_pool; ///< Pool of pre-allocated UE objects + srsran::static_blocking_queue, 32> ue_pool; ///< Pool of pre-allocated UE objects void prealloc_ue(uint32_t nof_ue); uint8_t* assemble_rar(sched_interface::dl_sched_rar_grant_t* grants, @@ -148,17 +148,17 @@ private: uint32_t tti); const static int rar_payload_len = 128; - std::array rar_pdu_msg; - srslte::byte_buffer_t rar_payload[SRSLTE_MAX_CARRIERS][sched_interface::MAX_RAR_LIST]; + std::array rar_pdu_msg; + srsran::byte_buffer_t rar_payload[SRSRAN_MAX_CARRIERS][sched_interface::MAX_RAR_LIST]; const static int NOF_BCCH_DLSCH_MSG = sched_interface::MAX_SIBS; const static int pcch_payload_buffer_len = 1024; typedef struct { uint8_t pcch_payload_buffer[pcch_payload_buffer_len] = {}; - srslte_softbuffer_tx_t bcch_softbuffer_tx[NOF_BCCH_DLSCH_MSG] = {}; - srslte_softbuffer_tx_t pcch_softbuffer_tx = {}; - srslte_softbuffer_tx_t rar_softbuffer_tx = {}; + srsran_softbuffer_tx_t bcch_softbuffer_tx[NOF_BCCH_DLSCH_MSG] = {}; + srsran_softbuffer_tx_t pcch_softbuffer_tx = {}; + srsran_softbuffer_tx_t rar_softbuffer_tx = {}; } common_buffers_t; std::vector common_buffers; @@ -166,15 +166,15 @@ private: const static int mcch_payload_len = 3000; // TODO FIND OUT MAX LENGTH int current_mcch_length = 0; uint8_t mcch_payload_buffer[mcch_payload_len] = {}; - srslte::mcch_msg_t mcch; - srslte::sib2_mbms_t sib2; - srslte::sib13_t sib13; + srsran::mcch_msg_t mcch; + srsran::sib2_mbms_t sib2; + srsran::sib13_t sib13; const static int mtch_payload_len = 10000; uint8_t mtch_payload_buffer[mtch_payload_len] = {}; // pointer to MAC PCAP object - srslte::mac_pcap* pcap = nullptr; - srslte::mac_pcap_net* pcap_net = nullptr; + srsran::mac_pcap* pcap = nullptr; + srsran::mac_pcap_net* pcap_net = nullptr; // Number of rach preambles detected for a cc. std::vector detected_rachs; diff --git a/srsenb/hdr/stack/mac/mac_metrics.h b/srsenb/hdr/stack/mac/mac_metrics.h index b055acd1b..cf8352ec4 100644 --- a/srsenb/hdr/stack/mac/mac_metrics.h +++ b/srsenb/hdr/stack/mac/mac_metrics.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/srsenb/hdr/stack/mac/mac_nr.h b/srsenb/hdr/stack/mac/mac_nr.h index 858199488..ae557544b 100644 --- a/srsenb/hdr/stack/mac/mac_nr.h +++ b/srsenb/hdr/stack/mac/mac_nr.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,13 +13,13 @@ #ifndef SRSENB_MAC_NR_H #define SRSENB_MAC_NR_H -#include "srslte/common/block_queue.h" -#include "srslte/common/mac_pcap.h" -#include "srslte/mac/mac_sch_pdu_nr.h" +#include "srsran/common/block_queue.h" +#include "srsran/common/mac_pcap.h" +#include "srsran/mac/mac_sch_pdu_nr.h" #include "srsenb/hdr/stack/enb_stack_base.h" -#include "srslte/interfaces/enb_metrics_interface.h" -#include "srslte/interfaces/gnb_interfaces.h" +#include "srsran/interfaces/enb_metrics_interface.h" +#include "srsran/interfaces/gnb_interfaces.h" namespace srsenb { @@ -72,7 +72,7 @@ private: phy_interface_stack_nr::tx_request_t& tx_request); // PDU processing - int handle_pdu(srslte::unique_byte_buffer_t pdu); + int handle_pdu(srsran::unique_byte_buffer_t pdu); // Interaction with other components phy_interface_stack_nr* phy_h = nullptr; @@ -80,7 +80,7 @@ private: rlc_interface_mac_nr* rlc_h = nullptr; rrc_interface_mac_nr* rrc_h = nullptr; - std::unique_ptr pcap = nullptr; + std::unique_ptr pcap = nullptr; mac_nr_args_t args = {}; srslog::basic_logger& logger; @@ -92,20 +92,20 @@ private: struct sib_info_t { uint32_t index; uint32_t periodicity; - srslte::unique_byte_buffer_t payload; + srsran::unique_byte_buffer_t payload; }; std::vector bcch_dlsch_payload; - srslte::unique_byte_buffer_t bcch_bch_payload = nullptr; + srsran::unique_byte_buffer_t bcch_bch_payload = nullptr; // UE-specific buffer - srslte::mac_sch_pdu_nr ue_tx_pdu; - std::vector ue_tx_buffer; - srslte::block_queue + srsran::mac_sch_pdu_nr ue_tx_pdu; + std::vector ue_tx_buffer; + srsran::block_queue ue_rx_pdu_queue; ///< currently only DCH PDUs supported (add BCH, PCH, etc) - srslte::unique_byte_buffer_t ue_rlc_buffer; + srsran::unique_byte_buffer_t ue_rlc_buffer; - srslte::mac_sch_pdu_nr ue_rx_pdu; + srsran::mac_sch_pdu_nr ue_rx_pdu; }; } // namespace srsenb diff --git a/srsenb/hdr/stack/mac/sched.h b/srsenb/hdr/stack/mac/sched.h index 3a8e68f33..0014e707c 100644 --- a/srsenb/hdr/stack/mac/sched.h +++ b/srsenb/hdr/stack/mac/sched.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -15,7 +15,7 @@ #include "sched_grid.h" #include "sched_ue.h" -#include "srslte/interfaces/sched_interface.h" +#include "srsran/interfaces/sched_interface.h" #include #include #include @@ -73,15 +73,15 @@ public: /* Custom functions */ void set_dl_tti_mask(uint8_t* tti_mask, uint32_t nof_sfs) final; - std::array get_enb_ue_cc_map(uint16_t rnti) final; - std::array get_scell_activation_mask(uint16_t rnti) final; + std::array get_enb_ue_cc_map(uint16_t rnti) final; + std::array get_scell_activation_mask(uint16_t rnti) final; int ul_buffer_add(uint16_t rnti, uint32_t lcid, uint32_t bytes) final; class carrier_sched; protected: - void new_tti(srslte::tti_point tti_rx); - bool is_generated(srslte::tti_point, uint32_t enb_cc_idx) const; + void new_tti(srsran::tti_point tti_rx); + bool is_generated(srsran::tti_point, uint32_t enb_cc_idx) const; // Helper methods template int ue_db_access_locked(uint16_t rnti, Func&& f, const char* func_name = nullptr); @@ -99,7 +99,7 @@ protected: // Storage of past scheduling results sched_result_ringbuffer sched_results; - srslte::tti_point last_tti; + srsran::tti_point last_tti; std::mutex sched_mutex; bool configured; }; diff --git a/srsenb/hdr/stack/mac/sched_carrier.h b/srsenb/hdr/stack/mac/sched_carrier.h index d1b4071c5..229892ca9 100644 --- a/srsenb/hdr/stack/mac/sched_carrier.h +++ b/srsenb/hdr/stack/mac/sched_carrier.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,12 +10,12 @@ * */ -#ifndef SRSLTE_SCHED_CARRIER_H -#define SRSLTE_SCHED_CARRIER_H +#ifndef SRSRAN_SCHED_CARRIER_H +#define SRSRAN_SCHED_CARRIER_H #include "sched.h" #include "schedulers/sched_base.h" -#include "srslte/srslog/srslog.h" +#include "srsran/srslog/srslog.h" namespace srsenb { @@ -33,7 +33,7 @@ public: void reset(); void carrier_cfg(const sched_cell_params_t& sched_params_); void set_dl_tti_mask(uint8_t* tti_mask, uint32_t nof_sfs); - const cc_sched_result& generate_tti_result(srslte::tti_point tti_rx); + const cc_sched_result& generate_tti_result(srsran::tti_point tti_rx); int dl_rach_info(dl_sched_rar_info_t rar_info); // getters @@ -47,7 +47,7 @@ private: //! Compute UL scheduler result for given TTI int alloc_ul_users(sf_sched* tti_sched); //! Get sf_sched for a given TTI - sf_sched* get_sf_sched(srslte::tti_point tti_rx); + sf_sched* get_sf_sched(srsran::tti_point tti_rx); // args const sched_cell_params_t* cc_cfg = nullptr; @@ -57,7 +57,7 @@ private: const uint32_t enb_cc_idx; // Subframe scheduling logic - srslte::circular_array sf_scheds; + srsran::circular_array sf_scheds; // scheduling results sched_result_ringbuffer* prev_sched_results; @@ -129,4 +129,4 @@ private: } // namespace srsenb -#endif // SRSLTE_SCHED_CARRIER_H +#endif // SRSRAN_SCHED_CARRIER_H diff --git a/srsenb/hdr/stack/mac/sched_common.h b/srsenb/hdr/stack/mac/sched_common.h index f9db0070c..ebd211a84 100644 --- a/srsenb/hdr/stack/mac/sched_common.h +++ b/srsenb/hdr/stack/mac/sched_common.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,12 +10,12 @@ * */ -#ifndef SRSLTE_SCHED_COMMON_H -#define SRSLTE_SCHED_COMMON_H +#ifndef SRSRAN_SCHED_COMMON_H +#define SRSRAN_SCHED_COMMON_H -#include "srslte/adt/bounded_bitset.h" -#include "srslte/common/tti_point.h" -#include "srslte/interfaces/sched_interface.h" +#include "srsran/adt/bounded_bitset.h" +#include "srsran/common/tti_point.h" +#include "srsran/interfaces/sched_interface.h" namespace srsenb { @@ -31,22 +31,22 @@ constexpr uint32_t NOF_AGGR_LEVEL = 4; **********************/ /// List of CCE start positions in PDCCH -using cce_position_list = srslte::bounded_vector; +using cce_position_list = srsran::bounded_vector; /// Map {L} -> list of CCE positions using cce_cfi_position_table = std::array; /// Map {cfi, L} -> list of CCE positions -using cce_sf_position_table = std::array, SRSLTE_NOF_CFI>; +using cce_sf_position_table = std::array, SRSRAN_NOF_CFI>; /// Map {sf, cfi, L} -> list of CCE positions -using cce_frame_position_table = std::array; +using cce_frame_position_table = std::array; /// structs to bundle together all the sched arguments, and share them with all the sched sub-components class sched_cell_params_t { struct regs_deleter { - void operator()(srslte_regs_t* p); + void operator()(srsran_regs_t* p); }; public: @@ -54,26 +54,26 @@ public: const sched_interface::cell_cfg_t& cfg_, const sched_interface::sched_args_t& sched_args); // convenience getters - uint32_t nof_prbs_to_rbgs(uint32_t nof_prbs) const { return srslte::ceil_div(nof_prbs, P); } + uint32_t nof_prbs_to_rbgs(uint32_t nof_prbs) const { return srsran::ceil_div(nof_prbs, P); } uint32_t nof_prb() const { return cfg.cell.nof_prb; } uint32_t get_dl_lb_nof_re(tti_point tti_tx_dl, uint32_t nof_prbs_alloc) const; - uint32_t get_dl_nof_res(srslte::tti_point tti_tx_dl, const srslte_dci_dl_t& dci, uint32_t cfi) const; + uint32_t get_dl_nof_res(srsran::tti_point tti_tx_dl, const srsran_dci_dl_t& dci, uint32_t cfi) const; uint32_t enb_cc_idx = 0; sched_interface::cell_cfg_t cfg = {}; - srslte_pucch_cfg_t pucch_cfg_common = {}; + srsran_pucch_cfg_t pucch_cfg_common = {}; const sched_interface::sched_args_t* sched_cfg = nullptr; - std::unique_ptr regs; + std::unique_ptr regs; cce_sf_position_table common_locations = {}; cce_frame_position_table rar_locations = {}; - std::array nof_cce_table = {}; ///< map cfix -> nof cces in PDCCH + std::array nof_cce_table = {}; ///< map cfix -> nof cces in PDCCH uint32_t P = 0; uint32_t nof_rbgs = 0; - using dl_nof_re_table = srslte::bounded_vector< - std::array, SRSLTE_NOF_SLOTS_PER_SF>, SRSLTE_NOF_SF_X_FRAME>, - SRSLTE_MAX_PRB>; - using dl_lb_nof_re_table = std::array, SRSLTE_NOF_SF_X_FRAME>; + using dl_nof_re_table = srsran::bounded_vector< + std::array, SRSRAN_NOF_SLOTS_PER_SF>, SRSRAN_NOF_SF_X_FRAME>, + SRSRAN_MAX_PRB>; + using dl_lb_nof_re_table = std::array, SRSRAN_NOF_SF_X_FRAME>; /// Table of nof REs dl_nof_re_table nof_re_table; @@ -82,23 +82,23 @@ public: }; //! Bitmask used for CCE allocations -using pdcch_mask_t = srslte::bounded_bitset; +using pdcch_mask_t = srsran::bounded_bitset; //! Bitmask that stores the allocared DL RBGs -using rbgmask_t = srslte::bounded_bitset<25, true>; +using rbgmask_t = srsran::bounded_bitset<25, true>; //! Bitmask that stores the allocated UL PRBs -using prbmask_t = srslte::bounded_bitset<100, true>; +using prbmask_t = srsran::bounded_bitset<100, true>; //! Struct to express a {min,...,max} range of RBGs struct prb_interval; -struct rbg_interval : public srslte::interval { +struct rbg_interval : public srsran::interval { using interval::interval; static rbg_interval rbgmask_to_rbgs(const rbgmask_t& mask); }; /// Struct to express a {min,...,max} range of PRBs -struct prb_interval : public srslte::interval { +struct prb_interval : public srsran::interval { using interval::interval; static prb_interval rbgs_to_prbs(const rbg_interval& rbgs, uint32_t cell_nof_prb); static prb_interval riv_to_prbs(uint32_t riv, uint32_t nof_prbs, int nof_vrbs = -1); @@ -116,10 +116,10 @@ inline bool is_dl_ctrl_alloc(alloc_type_t a) namespace fmt { template <> -struct formatter : public formatter > {}; +struct formatter : public formatter > {}; template <> -struct formatter : public formatter > {}; +struct formatter : public formatter > {}; } // namespace fmt -#endif // SRSLTE_SCHED_COMMON_H +#endif // SRSRAN_SCHED_COMMON_H diff --git a/srsenb/hdr/stack/mac/sched_grid.h b/srsenb/hdr/stack/mac/sched_grid.h index 2e55ef2c1..a7b3e9434 100644 --- a/srsenb/hdr/stack/mac/sched_grid.h +++ b/srsenb/hdr/stack/mac/sched_grid.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,16 +10,16 @@ * */ -#ifndef SRSLTE_SCHED_GRID_H -#define SRSLTE_SCHED_GRID_H +#ifndef SRSRAN_SCHED_GRID_H +#define SRSRAN_SCHED_GRID_H -#include "lib/include/srslte/interfaces/sched_interface.h" +#include "lib/include/srsran/interfaces/sched_interface.h" #include "sched_phy_ch/sched_result.h" #include "sched_phy_ch/sf_cch_allocator.h" #include "sched_ue.h" -#include "srslte/adt/bounded_bitset.h" -#include "srslte/adt/circular_array.h" -#include "srslte/srslog/srslog.h" +#include "srsran/adt/bounded_bitset.h" +#include "srsran/adt/circular_array.h" +#include "srsran/srslog/srslog.h" #include namespace srsenb { @@ -64,27 +64,27 @@ struct sf_sched_result { struct sched_result_ringbuffer { public: void set_nof_carriers(uint32_t nof_carriers); - void new_tti(srslte::tti_point tti_rx); - bool has_sf(srslte::tti_point tti_rx) const { return results[tti_rx.to_uint()].tti_rx == tti_rx; } - sf_sched_result* get_sf(srslte::tti_point tti_rx) + void new_tti(srsran::tti_point tti_rx); + bool has_sf(srsran::tti_point tti_rx) const { return results[tti_rx.to_uint()].tti_rx == tti_rx; } + sf_sched_result* get_sf(srsran::tti_point tti_rx) { assert(has_sf(tti_rx)); return &results[tti_rx.to_uint()]; } - const sf_sched_result* get_sf(srslte::tti_point tti_rx) const + const sf_sched_result* get_sf(srsran::tti_point tti_rx) const { assert(has_sf(tti_rx)); return &results[tti_rx.to_uint()]; } - const cc_sched_result* get_cc(srslte::tti_point tti_rx, uint32_t enb_cc_idx) const + const cc_sched_result* get_cc(srsran::tti_point tti_rx, uint32_t enb_cc_idx) const { return get_sf(tti_rx)->get_cc(enb_cc_idx); } - cc_sched_result* get_cc(srslte::tti_point tti_rx, uint32_t enb_cc_idx) { return get_sf(tti_rx)->get_cc(enb_cc_idx); } + cc_sched_result* get_cc(srsran::tti_point tti_rx, uint32_t enb_cc_idx) { return get_sf(tti_rx)->get_cc(enb_cc_idx); } private: uint32_t nof_carriers = 1; - srslte::circular_array results; + srsran::circular_array results; }; /// manages a subframe grid resources, namely CCE and DL/UL RB allocations @@ -181,7 +181,7 @@ public: // Control/Configuration Methods sf_sched(); void init(const sched_cell_params_t& cell_params_); - void new_tti(srslte::tti_point tti_rx_, sf_sched_result* cc_results); + void new_tti(srsran::tti_point tti_rx_, sf_sched_result* cc_results); // DL alloc methods alloc_result alloc_sib(uint32_t aggr_lvl, uint32_t sib_idx, uint32_t sib_ntx, rbg_interval rbgs); @@ -209,7 +209,7 @@ public: alloc_result alloc_ul_user(sched_ue* user, prb_interval alloc); const prbmask_t& get_ul_mask() const { return tti_alloc.get_ul_mask(); } tti_point get_tti_tx_ul() const { return to_tx_ul(tti_rx); } - srslte::const_span get_allocated_rars() const { return rar_allocs; } + srsran::const_span get_allocated_rars() const { return rar_allocs; } // getters tti_point get_tti_rx() const { return tti_rx; } @@ -234,10 +234,10 @@ private: // internal state sf_grid_t tti_alloc; - srslte::bounded_vector bc_allocs; - srslte::bounded_vector rar_allocs; - srslte::bounded_vector data_allocs; - srslte::bounded_vector ul_data_allocs; + srsran::bounded_vector bc_allocs; + srsran::bounded_vector rar_allocs; + srsran::bounded_vector data_allocs; + srsran::bounded_vector ul_data_allocs; uint32_t last_msg3_prb = 0, max_msg3_prb = 0; // Next TTI state @@ -246,4 +246,4 @@ private: } // namespace srsenb -#endif // SRSLTE_SCHED_GRID_H +#endif // SRSRAN_SCHED_GRID_H diff --git a/srsenb/hdr/stack/mac/sched_helpers.h b/srsenb/hdr/stack/mac/sched_helpers.h index a2424ca56..8ae44a80b 100644 --- a/srsenb/hdr/stack/mac/sched_helpers.h +++ b/srsenb/hdr/stack/mac/sched_helpers.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,12 +10,12 @@ * */ -#ifndef SRSLTE_SCHED_HELPERS_H -#define SRSLTE_SCHED_HELPERS_H +#ifndef SRSRAN_SCHED_HELPERS_H +#define SRSRAN_SCHED_HELPERS_H #include "srsenb/hdr/stack/mac/sched_common.h" -#include "srslte/interfaces/sched_interface.h" -#include "srslte/srslog/srslog.h" +#include "srsran/interfaces/sched_interface.h" +#include "srsran/srslog/srslog.h" namespace srsenb { @@ -92,7 +92,7 @@ inline uint32_t cell_nof_rbg_to_prb(uint32_t nof_rbgs) inline uint32_t count_prb_per_tb(const rbgmask_t& bitmask) { uint32_t Nprb = cell_nof_rbg_to_prb(bitmask.size()); - uint32_t P = srslte_ra_type0_P(Nprb); + uint32_t P = srsran_ra_type0_P(Nprb); uint32_t nof_prb = P * bitmask.count(); if (bitmask.test(bitmask.size() - 1)) { nof_prb -= bitmask.size() * P - Nprb; @@ -102,7 +102,7 @@ inline uint32_t count_prb_per_tb(const rbgmask_t& bitmask) inline uint32_t count_prb_per_tb_approx(uint32_t nof_rbgs, uint32_t cell_nof_prb) { - uint32_t P = srslte_ra_type0_P(cell_nof_prb); + uint32_t P = srsran_ra_type0_P(cell_nof_prb); return std::min(nof_rbgs * P, cell_nof_prb); } @@ -116,20 +116,20 @@ cce_frame_position_table generate_cce_location_table(uint16_t rnti, const sched_ * @param sf_idx subframe index specific to the tx TTI (relevant only for data and RAR transmissions) * @param rnti identity of the user (invalid RNTI for RAR and BC transmissions) */ -void generate_cce_location(srslte_regs_t* regs, +void generate_cce_location(srsran_regs_t* regs, cce_cfi_position_table& locations, uint32_t cfi, uint32_t sf_idx = 0, - uint16_t rnti = SRSLTE_INVALID_RNTI); + uint16_t rnti = SRSRAN_INVALID_RNTI); /// Obtains TB size *in bytes* for a given MCS and nof allocated prbs inline uint32_t get_tbs_bytes(uint32_t mcs, uint32_t nof_alloc_prb, bool use_tbs_index_alt, bool is_ul) { - int tbs_idx = srslte_ra_tbs_idx_from_mcs(mcs, use_tbs_index_alt, is_ul); - assert(tbs_idx != SRSLTE_ERROR); + int tbs_idx = srsran_ra_tbs_idx_from_mcs(mcs, use_tbs_index_alt, is_ul); + assert(tbs_idx != SRSRAN_ERROR); - int tbs = srslte_ra_tbs_from_idx((uint32_t)tbs_idx, nof_alloc_prb); - assert(tbs != SRSLTE_ERROR); + int tbs = srsran_ra_tbs_from_idx((uint32_t)tbs_idx, nof_alloc_prb); + assert(tbs != SRSRAN_ERROR); return (uint32_t)tbs / 8U; } @@ -173,4 +173,4 @@ const char* to_string(sched_interface::ue_bearer_cfg_t::direction_t dir); } // namespace srsenb -#endif // SRSLTE_SCHED_HELPERS_H +#endif // SRSRAN_SCHED_HELPERS_H diff --git a/srsenb/hdr/stack/mac/sched_phy_ch/sched_dci.h b/srsenb/hdr/stack/mac/sched_phy_ch/sched_dci.h index 9874b1634..6c1609794 100644 --- a/srsenb/hdr/stack/mac/sched_phy_ch/sched_dci.h +++ b/srsenb/hdr/stack/mac/sched_phy_ch/sched_dci.h @@ -1,20 +1,20 @@ /** * - * \section copyright + * \section COPYRIGHT * - * copyright 2013-2020 software radio systems limited + * Copyright 2013-2021 Software Radio Systems Limited * - * by using this file, you agree to the terms and conditions set - * forth in the license file which can be found at the top level of + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of * the distribution. * */ -#ifndef SRSLTE_SCHED_DCI_H -#define SRSLTE_SCHED_DCI_H +#ifndef SRSRAN_SCHED_DCI_H +#define SRSRAN_SCHED_DCI_H #include "../sched_common.h" -#include "srslte/adt/bounded_vector.h" +#include "srsran/adt/bounded_vector.h" namespace srsenb { @@ -63,7 +63,7 @@ tbs_info compute_min_mcs_and_tbs_from_required_bytes(uint32_t nof_prb, struct pending_rar_t { uint16_t ra_rnti = 0; tti_point prach_tti{}; - srslte::bounded_vector msg3_grant = {}; + srsran::bounded_vector msg3_grant = {}; }; bool generate_sib_dci(sched_interface::dl_sched_bc_t& bc, @@ -102,4 +102,4 @@ void log_rar_allocation(const sched_interface::dl_sched_rar_t& rar, rbg_interval } // namespace srsenb -#endif // SRSLTE_SCHED_DCI_H +#endif // SRSRAN_SCHED_DCI_H diff --git a/srsenb/hdr/stack/mac/sched_phy_ch/sched_result.h b/srsenb/hdr/stack/mac/sched_phy_ch/sched_result.h index fb41598ef..39db99e9a 100644 --- a/srsenb/hdr/stack/mac/sched_phy_ch/sched_result.h +++ b/srsenb/hdr/stack/mac/sched_phy_ch/sched_result.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,8 +10,8 @@ * */ -#ifndef SRSLTE_SCHED_RESULT_H -#define SRSLTE_SCHED_RESULT_H +#ifndef SRSRAN_SCHED_RESULT_H +#define SRSRAN_SCHED_RESULT_H #include "../sched_common.h" @@ -38,4 +38,4 @@ struct cc_sched_result { } // namespace srsenb -#endif // SRSLTE_SCHED_RESULT_H +#endif // SRSRAN_SCHED_RESULT_H diff --git a/srsenb/hdr/stack/mac/sched_phy_ch/sf_cch_allocator.h b/srsenb/hdr/stack/mac/sched_phy_ch/sf_cch_allocator.h index f68dfd88b..7ae640923 100644 --- a/srsenb/hdr/stack/mac/sched_phy_ch/sf_cch_allocator.h +++ b/srsenb/hdr/stack/mac/sched_phy_ch/sf_cch_allocator.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,8 +13,8 @@ #include "../sched_common.h" #include "sched_result.h" -#ifndef SRSLTE_PDCCH_SCHED_H -#define SRSLTE_PDCCH_SCHED_H +#ifndef SRSRAN_PDCCH_SCHED_H +#define SRSRAN_PDCCH_SCHED_H namespace srsenb { @@ -27,15 +27,15 @@ public: const static uint32_t MAX_CFI = 3; struct tree_node { int8_t pucch_n_prb = -1; ///< this PUCCH resource identifier - uint16_t rnti = SRSLTE_INVALID_RNTI; + uint16_t rnti = SRSRAN_INVALID_RNTI; uint32_t record_idx = 0; uint32_t dci_pos_idx = 0; - srslte_dci_location_t dci_pos = {0, 0}; + srsran_dci_location_t dci_pos = {0, 0}; /// Accumulation of all PDCCH masks for the current solution (DFS path) pdcch_mask_t total_mask, current_mask; prbmask_t total_pucch_mask; }; - using alloc_result_t = srslte::bounded_vector; + using alloc_result_t = srsran::bounded_vector; sf_cch_allocator() : logger(srslog::fetch_basic_logger("MAC")) {} @@ -77,7 +77,7 @@ private: // consts const sched_cell_params_t* cc_cfg = nullptr; srslog::basic_logger& logger; - srslte_pucch_cfg_t pucch_cfg_common = {}; + srsran_pucch_cfg_t pucch_cfg_common = {}; // tti vars tti_point tti_rx; @@ -88,8 +88,8 @@ private: }; // Helper methods -bool is_pucch_sr_collision(const srslte_pucch_cfg_t& ue_pucch_cfg, tti_point tti_tx_dl_ack, uint32_t n1_pucch); +bool is_pucch_sr_collision(const srsran_pucch_cfg_t& ue_pucch_cfg, tti_point tti_tx_dl_ack, uint32_t n1_pucch); } // namespace srsenb -#endif // SRSLTE_PDCCH_SCHED_H +#endif // SRSRAN_PDCCH_SCHED_H diff --git a/srsenb/hdr/stack/mac/sched_ue.h b/srsenb/hdr/stack/mac/sched_ue.h index dbe259e6a..3297a1c98 100644 --- a/srsenb/hdr/stack/mac/sched_ue.h +++ b/srsenb/hdr/stack/mac/sched_ue.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -14,7 +14,7 @@ #define SRSENB_SCHEDULER_UE_H #include "sched_common.h" -#include "srslte/srslog/srslog.h" +#include "srsran/srslog/srslog.h" #include #include @@ -82,7 +82,7 @@ public: uint32_t get_required_prb_ul(uint32_t enb_cc_idx, uint32_t req_bytes); rbg_interval get_required_dl_rbgs(uint32_t enb_cc_idx); - srslte::interval get_requested_dl_bytes(uint32_t enb_cc_idx); + srsran::interval get_requested_dl_bytes(uint32_t enb_cc_idx); uint32_t get_pending_dl_rlc_data() const; uint32_t get_expected_dl_bitrate(uint32_t enb_cc_idx, int nof_rbgs = -1) const; @@ -120,16 +120,16 @@ public: uint32_t enb_cc_idx, prb_interval alloc, bool needs_pdcch, - srslte_dci_location_t cce_range, + srsran_dci_location_t cce_range, int explicit_mcs = -1, uci_pusch_t uci_type = UCI_PUSCH_NONE); - srslte_dci_format_t get_dci_format(); + srsran_dci_format_t get_dci_format(); const cce_cfi_position_table* get_locations(uint32_t enb_cc_idx, uint32_t current_cfi, uint32_t sf_idx) const; sched_ue_cell* find_ue_carrier(uint32_t enb_cc_idx); size_t nof_carriers_configured() const { return cfg.supported_cc_list.size(); } - std::bitset scell_activation_mask() const; + std::bitset scell_activation_mask() const; int enb_to_ue_cc_idx(uint32_t enb_cc_idx) const; uint32_t get_max_retx(); @@ -152,7 +152,7 @@ private: tti_point tti_tx_dl, uint32_t nof_alloc_prbs, uint32_t cfi, - const srslte_dci_dl_t& dci); + const srsran_dci_dl_t& dci); bool needs_cqi(uint32_t tti, uint32_t enb_cc_idx, bool will_send = false); @@ -189,7 +189,7 @@ private: /* Args */ ue_cfg_t cfg = {}; - srslte_cell_t cell = {}; + srsran_cell_t cell = {}; srslog::basic_logger& logger; const sched_cell_params_t* main_cc_params = nullptr; diff --git a/srsenb/hdr/stack/mac/sched_ue_ctrl/sched_harq.h b/srsenb/hdr/stack/mac/sched_ue_ctrl/sched_harq.h index 42b9a8ea6..5a89510fa 100644 --- a/srsenb/hdr/stack/mac/sched_ue_ctrl/sched_harq.h +++ b/srsenb/hdr/stack/mac/sched_ue_ctrl/sched_harq.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,10 +13,10 @@ #ifndef SRSENB_SCHEDULER_HARQ_H #define SRSENB_SCHEDULER_HARQ_H -#include "srslte/adt/bounded_bitset.h" -#include "srslte/common/tti_point.h" -#include "srslte/interfaces/sched_interface.h" -#include "srslte/srslog/srslog.h" +#include "srsran/adt/bounded_bitset.h" +#include "srsran/common/tti_point.h" +#include "srsran/interfaces/sched_interface.h" +#include "srsran/srslog/srslog.h" namespace srsenb { @@ -32,13 +32,13 @@ public: uint32_t nof_tx(uint32_t tb_idx) const; uint32_t nof_retx(uint32_t tb_idx) const; - srslte::tti_point get_tti() const; + srsran::tti_point get_tti() const; bool get_ndi(uint32_t tb_idx) const; uint32_t max_nof_retx() const; protected: - void new_tx_common(uint32_t tb_idx, srslte::tti_point tti, int mcs, int tbs, uint32_t max_retx_); - void new_retx_common(uint32_t tb_idx, srslte::tti_point tti, int* mcs, int* tbs); + void new_tx_common(uint32_t tb_idx, srsran::tti_point tti, int mcs, int tbs, uint32_t max_retx_); + void new_retx_common(uint32_t tb_idx, srsran::tti_point tti, int* mcs, int* tbs); bool has_pending_retx_common(uint32_t tb_idx) const; int set_ack_common(uint32_t tb_idx, bool ack); void reset_pending_data_common(); @@ -46,16 +46,16 @@ protected: enum ack_t { NACK, ACK }; srslog::basic_logger* logger; - bool ack_state[SRSLTE_MAX_TB]; - bool active[SRSLTE_MAX_TB]; - std::array ndi = {}; + bool ack_state[SRSRAN_MAX_TB]; + bool active[SRSRAN_MAX_TB]; + std::array ndi = {}; uint32_t id; uint32_t max_retx = 5; - uint32_t n_rtx[SRSLTE_MAX_TB]; - uint32_t tx_cnt[SRSLTE_MAX_TB]; - srslte::tti_point tti; - int last_mcs[SRSLTE_MAX_TB]; - int last_tbs[SRSLTE_MAX_TB]; + uint32_t n_rtx[SRSRAN_MAX_TB]; + uint32_t tx_cnt[SRSRAN_MAX_TB]; + srsran::tti_point tti; + int last_mcs[SRSRAN_MAX_TB]; + int last_tbs[SRSRAN_MAX_TB]; }; class dl_harq_proc : public harq_proc @@ -86,10 +86,10 @@ private: class ul_harq_proc : public harq_proc { public: - void new_tx(srslte::tti_point tti, int mcs, int tbs, prb_interval alloc, uint32_t max_retx_, bool is_msg3); - void new_retx(srslte::tti_point tti_, int* mcs, int* tbs, prb_interval alloc); + void new_tx(srsran::tti_point tti, int mcs, int tbs, prb_interval alloc, uint32_t max_retx_, bool is_msg3); + void new_retx(srsran::tti_point tti_, int* mcs, int* tbs, prb_interval alloc); bool set_ack(uint32_t tb_idx, bool ack); - bool retx_requires_pdcch(srslte::tti_point tti_, prb_interval alloc) const; + bool retx_requires_pdcch(srsran::tti_point tti_, prb_interval alloc) const; prb_interval get_alloc() const; bool has_pending_retx() const; @@ -151,15 +151,15 @@ public: /** * Set ACK state for UL Harq Proc */ - int set_ul_crc(srslte::tti_point tti_tx_ul, uint32_t tb_idx, bool ack_); + int set_ul_crc(srsran::tti_point tti_tx_ul, uint32_t tb_idx, bool ack_); //! Resets pending harq ACKs and cleans UL Harqs with maxretx == 0 - void reset_pending_data(srslte::tti_point tti_rx); + void reset_pending_data(srsran::tti_point tti_rx); private: dl_harq_proc* get_oldest_dl_harq(tti_point tti_tx_dl); - std::array last_ttis; + std::array last_ttis; std::vector dl_harqs; std::vector ul_harqs; diff --git a/srsenb/hdr/stack/mac/sched_ue_ctrl/sched_lch.h b/srsenb/hdr/stack/mac/sched_ue_ctrl/sched_lch.h index 75fb0942a..2eff87c9f 100644 --- a/srsenb/hdr/stack/mac/sched_ue_ctrl/sched_lch.h +++ b/srsenb/hdr/stack/mac/sched_ue_ctrl/sched_lch.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,12 +10,12 @@ * */ -#ifndef SRSLTE_SCHED_LCH_H -#define SRSLTE_SCHED_LCH_H +#ifndef SRSRAN_SCHED_LCH_H +#define SRSRAN_SCHED_LCH_H -#include "srslte/interfaces/sched_interface.h" -#include "srslte/mac/pdu.h" -#include "srslte/srslog/srslog.h" +#include "srsran/interfaces/sched_interface.h" +#include "srsran/mac/pdu.h" +#include "srsran/srslog/srslog.h" #include namespace srsenb { @@ -58,7 +58,7 @@ public: const std::array& get_bsr_state() const; // Control Element Command queue - using ce_cmd = srslte::dl_sch_lcid; + using ce_cmd = srsran::dl_sch_lcid; std::deque pending_ces; private: @@ -101,4 +101,4 @@ uint32_t allocate_mac_ces(sched_interface::dl_sched_data_t* data, lch_ue_manager } // namespace srsenb -#endif // SRSLTE_SCHED_LCH_H +#endif // SRSRAN_SCHED_LCH_H diff --git a/srsenb/hdr/stack/mac/sched_ue_ctrl/sched_ue_cell.h b/srsenb/hdr/stack/mac/sched_ue_ctrl/sched_ue_cell.h index d2533f78f..cd1dc74f3 100644 --- a/srsenb/hdr/stack/mac/sched_ue_ctrl/sched_ue_cell.h +++ b/srsenb/hdr/stack/mac/sched_ue_ctrl/sched_ue_cell.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,8 +10,8 @@ * */ -#ifndef SRSLTE_SCHED_UE_CELL_H -#define SRSLTE_SCHED_UE_CELL_H +#ifndef SRSRAN_SCHED_UE_CELL_H +#define SRSRAN_SCHED_UE_CELL_H #include "../sched_common.h" #include "sched_harq.h" @@ -90,17 +90,17 @@ private: tbs_info cqi_to_tbs_dl(const sched_ue_cell& cell, uint32_t nof_prb, uint32_t nof_re, - srslte_dci_format_t dci_format, + srsran_dci_format_t dci_format, int req_bytes = -1); tbs_info cqi_to_tbs_ul(const sched_ue_cell& cell, uint32_t nof_prb, uint32_t nof_re, int req_bytes = -1, int explicit_mcs = -1); int get_required_prb_dl(const sched_ue_cell& cell, tti_point tti_tx_dl, - srslte_dci_format_t dci_format, + srsran_dci_format_t dci_format, uint32_t req_bytes); uint32_t get_required_prb_ul(const sched_ue_cell& cell, uint32_t req_bytes); } // namespace srsenb -#endif // SRSLTE_SCHED_UE_CELL_H +#endif // SRSRAN_SCHED_UE_CELL_H diff --git a/srsenb/hdr/stack/mac/sched_ue_ctrl/tpc.h b/srsenb/hdr/stack/mac/sched_ue_ctrl/tpc.h index adfc42434..ed2c5b6d7 100644 --- a/srsenb/hdr/stack/mac/sched_ue_ctrl/tpc.h +++ b/srsenb/hdr/stack/mac/sched_ue_ctrl/tpc.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,12 +10,12 @@ * */ -#ifndef SRSLTE_TPC_H -#define SRSLTE_TPC_H +#ifndef SRSRAN_TPC_H +#define SRSRAN_TPC_H -#include "srslte/adt/accumulators.h" -#include "srslte/common/common.h" -#include "srslte/srslog/srslog.h" +#include "srsran/adt/accumulators.h" +#include "srsran/common/common.h" +#include "srsran/srslog/srslog.h" namespace srsenb { @@ -170,12 +170,12 @@ private: // flag used in undefined target SINR case bool phr_flag = false; // pending new snr sample - float pending_snr = srslte::null_sliding_average::null_value(); + float pending_snr = srsran::null_sliding_average::null_value(); // SNR average estimation with irregular sample spacing uint32_t last_snr_sample_count = 1; // jump in spacing - srslte::exp_average_irreg_sampling snr_avg; + srsran::exp_average_irreg_sampling snr_avg; // Accumulation of past TPC commands - srslte::sliding_sum win_tpc_values; + srsran::sliding_sum win_tpc_values; int pending_delta = 0; int acc_tpc_values = 0; @@ -188,4 +188,4 @@ private: } // namespace srsenb -#endif // SRSLTE_TPC_H +#endif // SRSRAN_TPC_H diff --git a/srsenb/hdr/stack/mac/schedulers/sched_base.h b/srsenb/hdr/stack/mac/schedulers/sched_base.h index 5d763b6f6..e984739ae 100644 --- a/srsenb/hdr/stack/mac/schedulers/sched_base.h +++ b/srsenb/hdr/stack/mac/schedulers/sched_base.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,8 +10,8 @@ * */ -#ifndef SRSLTE_SCHED_BASE_H -#define SRSLTE_SCHED_BASE_H +#ifndef SRSRAN_SCHED_BASE_H +#define SRSRAN_SCHED_BASE_H #include "srsenb/hdr/stack/mac/sched_grid.h" @@ -66,4 +66,4 @@ alloc_result try_ul_retx_alloc(sf_sched& tti_sched, sched_ue& ue, const ul_harq_ } // namespace srsenb -#endif // SRSLTE_SCHED_BASE_H +#endif // SRSRAN_SCHED_BASE_H diff --git a/srsenb/hdr/stack/mac/schedulers/sched_time_pf.h b/srsenb/hdr/stack/mac/schedulers/sched_time_pf.h index a1af77309..f11b59147 100644 --- a/srsenb/hdr/stack/mac/schedulers/sched_time_pf.h +++ b/srsenb/hdr/stack/mac/schedulers/sched_time_pf.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,8 +10,8 @@ * */ -#ifndef SRSLTE_SCHED_TIME_PF_H -#define SRSLTE_SCHED_TIME_PF_H +#ifndef SRSRAN_SCHED_TIME_PF_H +#define SRSRAN_SCHED_TIME_PF_H #include "sched_base.h" #include @@ -33,7 +33,7 @@ private: const sched_cell_params_t* cc_cfg = nullptr; float fairness_coeff = 1; - srslte::tti_point current_tti_rx; + srsran::tti_point current_tti_rx; struct ue_ctxt { ue_ctxt(uint16_t rnti_, float fairness_coeff_) : rnti(rnti_), fairness_coeff(fairness_coeff_) {} @@ -77,4 +77,4 @@ private: } // namespace srsenb -#endif // SRSLTE_SCHED_TIME_PF_H \ No newline at end of file +#endif // SRSRAN_SCHED_TIME_PF_H \ No newline at end of file diff --git a/srsenb/hdr/stack/mac/schedulers/sched_time_rr.h b/srsenb/hdr/stack/mac/schedulers/sched_time_rr.h index 831ef60f4..eead66821 100644 --- a/srsenb/hdr/stack/mac/schedulers/sched_time_rr.h +++ b/srsenb/hdr/stack/mac/schedulers/sched_time_rr.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/srsenb/hdr/stack/mac/ta.h b/srsenb/hdr/stack/mac/ta.h index 0eb1cc3bb..068bb9227 100644 --- a/srsenb/hdr/stack/mac/ta.h +++ b/srsenb/hdr/stack/mac/ta.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,8 +13,8 @@ #ifndef SRSENB_TA_H #define SRSENB_TA_H -#include "srslte/config.h" -#include "srslte/phy/common/phy_common.h" +#include "srsran/config.h" +#include "srsran/phy/common/phy_common.h" #include #include @@ -109,7 +109,7 @@ private: } // Return the n_ta value - return static_cast(std::roundf(ta_us * 1e-6f / SRSLTE_LTE_TS / 16.0f)); + return static_cast(std::roundf(ta_us * 1e-6f / SRSRAN_LTE_TS / 16.0f)); } /** diff --git a/srsenb/hdr/stack/mac/ue.h b/srsenb/hdr/stack/mac/ue.h index f073d0ac1..8768be210 100644 --- a/srsenb/hdr/stack/mac/ue.h +++ b/srsenb/hdr/stack/mac/ue.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -14,15 +14,15 @@ #define SRSENB_UE_H #include "mac_metrics.h" -#include "srslte/adt/circular_array.h" -#include "srslte/common/block_queue.h" -#include "srslte/common/mac_pcap.h" -#include "srslte/common/mac_pcap_net.h" -#include "srslte/common/tti_point.h" -#include "srslte/interfaces/sched_interface.h" -#include "srslte/mac/pdu.h" -#include "srslte/mac/pdu_queue.h" -#include "srslte/srslog/srslog.h" +#include "srsran/adt/circular_array.h" +#include "srsran/common/block_queue.h" +#include "srsran/common/mac_pcap.h" +#include "srsran/common/mac_pcap_net.h" +#include "srsran/common/tti_point.h" +#include "srsran/interfaces/sched_interface.h" +#include "srsran/mac/pdu.h" +#include "srsran/mac/pdu_queue.h" +#include "srsran/srslog/srslog.h" #include "ta.h" #include @@ -37,7 +37,7 @@ class phy_interface_stack_lte; class cc_used_buffers_map { public: - explicit cc_used_buffers_map(srslte::pdu_queue& shared_pdu_queue_); + explicit cc_used_buffers_map(srsran::pdu_queue& shared_pdu_queue_); uint8_t* request_pdu(tti_point tti, uint32_t len); @@ -57,20 +57,20 @@ private: void remove_pdu(tti_point tti); srslog::basic_logger* logger; - srslte::pdu_queue* shared_pdu_queue; + srsran::pdu_queue* shared_pdu_queue; - srslte::circular_array, SRSLTE_FDD_NOF_HARQ * 8> pdu_map; + srsran::circular_array, SRSRAN_FDD_NOF_HARQ * 8> pdu_map; }; class cc_buffer_handler { public: // List of Tx softbuffers for all HARQ processes of one carrier - using cc_softbuffer_tx_list_t = std::vector; + using cc_softbuffer_tx_list_t = std::vector; // List of Rx softbuffers for all HARQ processes of one carrier - using cc_softbuffer_rx_list_t = std::vector; + using cc_softbuffer_rx_list_t = std::vector; - explicit cc_buffer_handler(srslte::pdu_queue& shared_pdu_queue_); + explicit cc_buffer_handler(srsran::pdu_queue& shared_pdu_queue_); ~cc_buffer_handler(); void reset(); @@ -78,12 +78,12 @@ public: void deallocate_cc(); bool empty() const { return softbuffer_tx_list.empty() and softbuffer_rx_list.empty(); } - srslte_softbuffer_tx_t& get_tx_softbuffer(uint32_t pid, uint32_t tb_idx) + srsran_softbuffer_tx_t& get_tx_softbuffer(uint32_t pid, uint32_t tb_idx) { - return softbuffer_tx_list.at(pid * SRSLTE_MAX_TB + tb_idx); + return softbuffer_tx_list.at(pid * SRSRAN_MAX_TB + tb_idx); } - srslte_softbuffer_rx_t& get_rx_softbuffer(uint32_t tti) { return softbuffer_rx_list.at(tti % nof_rx_harq_proc); } - srslte::byte_buffer_t* get_tx_payload_buffer(size_t harq_pid, size_t tb) + srsran_softbuffer_rx_t& get_rx_softbuffer(uint32_t tti) { return softbuffer_rx_list.at(tti % nof_rx_harq_proc); } + srsran::byte_buffer_t* get_tx_payload_buffer(size_t harq_pid, size_t tb) { return tx_payload_buffer[harq_pid][tb].get(); } @@ -101,10 +101,10 @@ private: cc_used_buffers_map rx_used_buffers; // One buffer per TB per HARQ process and per carrier is needed for each UE. - std::array, SRSLTE_FDD_NOF_HARQ> tx_payload_buffer; + std::array, SRSRAN_FDD_NOF_HARQ> tx_payload_buffer; }; -class ue : public srslte::read_pdu_interface, public srslte::pdu_queue::process_callback, public mac_ta_ue_interface +class ue : public srsran::read_pdu_interface, public srsran::pdu_queue::process_callback, public mac_ta_ue_interface { public: ue(uint16_t rnti, @@ -115,13 +115,13 @@ public: phy_interface_stack_lte* phy_, srslog::basic_logger& logger, uint32_t nof_cells_, - uint32_t nof_rx_harq_proc = SRSLTE_FDD_NOF_HARQ, - uint32_t nof_tx_harq_proc = SRSLTE_FDD_NOF_HARQ); + uint32_t nof_rx_harq_proc = SRSRAN_FDD_NOF_HARQ, + uint32_t nof_tx_harq_proc = SRSRAN_FDD_NOF_HARQ); virtual ~ue(); void reset(); - void start_pcap(srslte::mac_pcap* pcap_); - void start_pcap_net(srslte::mac_pcap_net* pcap_net_); + void start_pcap(srsran::mac_pcap* pcap_); + void start_pcap_net(srsran::mac_pcap_net* pcap_net_); void set_tti(uint32_t tti); uint16_t get_rnti() { return rnti; } uint32_t set_ta(int ta) override; @@ -138,13 +138,13 @@ public: uint8_t* generate_mch_pdu(uint32_t harq_pid, sched_interface::dl_pdu_mch_t sched, uint32_t nof_pdu_elems, uint32_t grant_size); - srslte_softbuffer_tx_t* + srsran_softbuffer_tx_t* get_tx_softbuffer(const uint32_t ue_cc_idx, const uint32_t harq_process, const uint32_t tb_idx); - srslte_softbuffer_rx_t* get_rx_softbuffer(const uint32_t ue_cc_idx, const uint32_t tti); + srsran_softbuffer_rx_t* get_rx_softbuffer(const uint32_t ue_cc_idx, const uint32_t tti); bool process_pdus(); uint8_t* request_buffer(uint32_t tti, uint32_t ue_cc_idx, const uint32_t len); - void process_pdu(uint8_t* pdu, uint32_t nof_bytes, srslte::pdu_queue::channel_t channel) override; + void process_pdu(uint8_t* pdu, uint32_t nof_bytes, srsran::pdu_queue::channel_t channel) override; void push_pdu(uint32_t tti, uint32_t ue_cc_idx, uint32_t len); void deallocate_pdu(uint32_t tti, uint32_t ue_cc_idx); void clear_old_buffers(uint32_t tti); @@ -161,9 +161,9 @@ public: int read_pdu(uint32_t lcid, uint8_t* payload, uint32_t requested_bytes) final; private: - void allocate_sdu(srslte::sch_pdu* pdu, uint32_t lcid, uint32_t sdu_len); - bool process_ce(srslte::sch_subh* subh); - void allocate_ce(srslte::sch_pdu* pdu, uint32_t lcid); + void allocate_sdu(srsran::sch_pdu* pdu, uint32_t lcid, uint32_t sdu_len); + bool process_ce(srsran::sch_subh* subh); + void allocate_ce(srsran::sch_pdu* pdu, uint32_t lcid); uint32_t phr_counter = 0; uint32_t dl_cqi_counter = 0; @@ -171,8 +171,8 @@ private: uint32_t dl_pmi_counter = 0; mac_ue_metrics_t ue_metrics = {}; - srslte::mac_pcap* pcap = nullptr; - srslte::mac_pcap_net* pcap_net = nullptr; + srsran::mac_pcap* pcap = nullptr; + srsran::mac_pcap_net* pcap_net = nullptr; uint64_t conres_id = 0; uint16_t rnti = 0; uint32_t nof_prb = 0; @@ -181,17 +181,17 @@ private: int nof_rx_harq_proc = 0; int nof_tx_harq_proc = 0; - srslte::bounded_vector cc_buffers; + srsran::bounded_vector cc_buffers; std::mutex rx_buffers_mutex; - srslte::block_queue pending_ta_commands; + srsran::block_queue pending_ta_commands; ta ta_fsm; // For UL there are multiple buffers per PID and are managed by pdu_queue - srslte::pdu_queue pdus; - srslte::sch_pdu mac_msg_dl, mac_msg_ul; - srslte::mch_pdu mch_mac_msg_dl; + srsran::pdu_queue pdus; + srsran::sch_pdu mac_msg_dl, mac_msg_ul; + srsran::mch_pdu mch_mac_msg_dl; rlc_interface_mac* rlc = nullptr; rrc_interface_mac* rrc = nullptr; diff --git a/srsenb/hdr/stack/rrc/mac_controller.h b/srsenb/hdr/stack/rrc/mac_controller.h index e226e0002..5c9042bc7 100644 --- a/srsenb/hdr/stack/rrc/mac_controller.h +++ b/srsenb/hdr/stack/rrc/mac_controller.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,13 +10,13 @@ * */ -#ifndef SRSLTE_MAC_CONTROLLER_H -#define SRSLTE_MAC_CONTROLLER_H +#ifndef SRSRAN_MAC_CONTROLLER_H +#define SRSRAN_MAC_CONTROLLER_H #include "rrc_bearer_cfg.h" #include "rrc_cell_cfg.h" -#include "srslte/interfaces/rrc_interface_types.h" -#include "srslte/interfaces/sched_interface.h" +#include "srsran/interfaces/rrc_interface_types.h" +#include "srsran/interfaces/sched_interface.h" #include namespace srsenb { @@ -46,13 +46,13 @@ public: void handle_con_reest_complete(); void handle_con_reconf(const asn1::rrc::rrc_conn_recfg_r8_ies_s& conn_recfg, - const srslte::rrc_ue_capabilities_t& uecaps); + const srsran::rrc_ue_capabilities_t& uecaps); void handle_con_reconf_complete(); void handle_target_enb_ho_cmd(const asn1::rrc::rrc_conn_recfg_r8_ies_s& conn_recfg, - const srslte::rrc_ue_capabilities_t& uecaps); + const srsran::rrc_ue_capabilities_t& uecaps); void handle_intraenb_ho_cmd(const asn1::rrc::rrc_conn_recfg_r8_ies_s& conn_recfg, - const srslte::rrc_ue_capabilities_t& uecaps); + const srsran::rrc_ue_capabilities_t& uecaps); void handle_ho_prep(const asn1::rrc::ho_prep_info_r8_ies_s& ho_prep); void handle_max_retx(); @@ -60,7 +60,7 @@ public: const ue_cfg_t& get_ue_sched_cfg() const { return current_sched_ue_cfg; } bool is_crnti_set() const { return crnti_set; } - void set_scell_activation(const std::bitset& scell_mask); + void set_scell_activation(const std::bitset& scell_mask); void set_drb_activation(bool active); enum proc_stage_t : int8_t { config_tx, config_complete, other }; @@ -87,4 +87,4 @@ private: } // namespace srsenb -#endif // SRSLTE_MAC_CONTROLLER_H +#endif // SRSRAN_MAC_CONTROLLER_H diff --git a/srsenb/hdr/stack/rrc/rrc.h b/srsenb/hdr/stack/rrc/rrc.h index 713f8f41a..184ec5a10 100644 --- a/srsenb/hdr/stack/rrc/rrc.h +++ b/srsenb/hdr/stack/rrc/rrc.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -17,14 +17,14 @@ #include "rrc_cell_cfg.h" #include "rrc_metrics.h" #include "srsenb/hdr/stack/upper/common_enb.h" -#include "srslte/adt/circular_buffer.h" -#include "srslte/common/buffer_pool.h" -#include "srslte/common/common.h" -#include "srslte/common/stack_procedure.h" -#include "srslte/common/task_scheduler.h" -#include "srslte/common/timeout.h" -#include "srslte/interfaces/enb_rrc_interfaces.h" -#include "srslte/srslog/srslog.h" +#include "srsran/adt/circular_buffer.h" +#include "srsran/common/buffer_pool.h" +#include "srsran/common/common.h" +#include "srsran/common/stack_procedure.h" +#include "srsran/common/task_scheduler.h" +#include "srsran/common/timeout.h" +#include "srsran/interfaces/enb_rrc_interfaces.h" +#include "srsran/srslog/srslog.h" #include namespace srsenb { @@ -49,7 +49,7 @@ class rrc final : public rrc_interface_pdcp, public rrc_interface_s1ap { public: - explicit rrc(srslte::task_sched_handle task_sched_); + explicit rrc(srsran::task_sched_handle task_sched_); ~rrc(); void init(const rrc_cfg_t& cfg_, @@ -76,7 +76,7 @@ public: void max_retx_attempted(uint16_t rnti) override; // rrc_interface_s1ap - void write_dl_info(uint16_t rnti, srslte::unique_byte_buffer_t sdu) override; + void write_dl_info(uint16_t rnti, srsran::unique_byte_buffer_t sdu) override; void release_complete(uint16_t rnti) override; bool setup_ue_ctxt(uint16_t rnti, const asn1::s1ap::init_context_setup_request_s& msg) override; bool modify_ue_ctxt(uint16_t rnti, const asn1::s1ap::ue_context_mod_request_s& msg) override; @@ -98,14 +98,14 @@ public: void ho_preparation_complete(uint16_t rnti, bool is_success, const asn1::s1ap::ho_cmd_s& msg, - srslte::unique_byte_buffer_t rrc_container) override; + srsran::unique_byte_buffer_t rrc_container) override; uint16_t start_ho_ue_resource_alloc(const asn1::s1ap::ho_request_s& msg, const asn1::s1ap::sourceenb_to_targetenb_transparent_container_s& container) override; void set_erab_status(uint16_t rnti, const asn1::s1ap::bearers_subject_to_status_transfer_list_l& erabs) override; // rrc_interface_pdcp - void write_pdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t pdu) override; + void write_pdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t pdu) override; uint32_t get_nof_users(); @@ -114,16 +114,16 @@ public: template void log_rrc_message(const std::string& source, const direction_t dir, - const srslte::byte_buffer_t* pdu, + const srsran::byte_buffer_t* pdu, const T& msg, const std::string& msg_type) { - log_rrc_message(source, dir, srslte::make_span(*pdu), msg, msg_type); + log_rrc_message(source, dir, srsran::make_span(*pdu), msg, msg_type); } template void log_rrc_message(const std::string& source, const direction_t dir, - srslte::const_byte_span pdu, + srsran::const_byte_span pdu, const T& msg, const std::string& msg_type) { @@ -142,7 +142,7 @@ public: private: class ue; // args - srslte::task_sched_handle task_sched; + srsran::task_sched_handle task_sched; phy_interface_rrc_lte* phy = nullptr; mac_interface_rrc* mac = nullptr; rlc_interface_rrc* rlc = nullptr; @@ -166,19 +166,19 @@ private: int pack_mcch(); void config_mac(); - void parse_ul_dcch(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t pdu); - void parse_ul_ccch(uint16_t rnti, srslte::unique_byte_buffer_t pdu); + void parse_ul_dcch(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t pdu); + void parse_ul_ccch(uint16_t rnti, srsran::unique_byte_buffer_t pdu); void send_rrc_connection_reject(uint16_t rnti); uint32_t paging_tti = INVALID_TTI; - srslte::byte_buffer_t byte_buf_paging; + srsran::byte_buffer_t byte_buf_paging; const static int mcch_payload_len = 3000; int current_mcch_length = 0; uint8_t mcch_payload_buffer[mcch_payload_len] = {}; typedef struct { uint16_t rnti; uint32_t lcid; - srslte::unique_byte_buffer_t pdu; + srsran::unique_byte_buffer_t pdu; } rrc_pdu; const static uint32_t LCID_EXIT = 0xffff0000; @@ -188,7 +188,7 @@ private: const static uint32_t LCID_RTX_USER = 0xffff0005; bool running = false; - srslte::dyn_blocking_queue rx_pdu_queue; + srsran::dyn_blocking_queue rx_pdu_queue; asn1::rrc::mcch_msg_s mcch; bool enable_mbms = false; diff --git a/srsenb/hdr/stack/rrc/rrc_bearer_cfg.h b/srsenb/hdr/stack/rrc/rrc_bearer_cfg.h index 1ed8fc16a..a7d9d87b2 100644 --- a/srsenb/hdr/stack/rrc/rrc_bearer_cfg.h +++ b/srsenb/hdr/stack/rrc/rrc_bearer_cfg.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,15 +10,15 @@ * */ -#ifndef SRSLTE_RRC_BEARER_CFG_H -#define SRSLTE_RRC_BEARER_CFG_H +#ifndef SRSRAN_RRC_BEARER_CFG_H +#define SRSRAN_RRC_BEARER_CFG_H #include "srsenb/hdr/stack/rrc/rrc_config.h" -#include "srslte/asn1/s1ap.h" -#include "srslte/interfaces/enb_gtpu_interfaces.h" -#include "srslte/interfaces/enb_interfaces.h" -#include "srslte/interfaces/enb_rrc_interface_types.h" -#include "srslte/srslog/srslog.h" +#include "srsran/asn1/s1ap.h" +#include "srsran/interfaces/enb_gtpu_interfaces.h" +#include "srsran/interfaces/enb_interfaces.h" +#include "srsran/interfaces/enb_rrc_interface_types.h" +#include "srsran/srslog/srslog.h" namespace srsenb { @@ -42,7 +42,7 @@ public: void set_ncc(uint8_t ncc_) { ncc = ncc_; } asn1::rrc::security_algorithm_cfg_s get_security_algorithm_cfg(); - const srslte::as_security_config_t& get_as_sec_cfg() const { return sec_cfg; } + const srsran::as_security_config_t& get_as_sec_cfg() const { return sec_cfg; } uint8_t get_ncc() const { return ncc; } bool is_as_sec_cfg_valid() const { return k_enb_present; } @@ -56,7 +56,7 @@ private: bool k_enb_present = false; asn1::s1ap::ue_security_cap_s security_capabilities = {}; uint8_t k_enb[32] = {}; // Provided by MME - srslte::as_security_config_t sec_cfg = {}; + srsran::as_security_config_t sec_cfg = {}; uint8_t ncc = 0; }; @@ -117,4 +117,4 @@ private: } // namespace srsenb -#endif // SRSLTE_RRC_BEARER_CFG_H +#endif // SRSRAN_RRC_BEARER_CFG_H diff --git a/srsenb/hdr/stack/rrc/rrc_cell_cfg.h b/srsenb/hdr/stack/rrc/rrc_cell_cfg.h index baea1e199..ba6ecede3 100644 --- a/srsenb/hdr/stack/rrc/rrc_cell_cfg.h +++ b/srsenb/hdr/stack/rrc/rrc_cell_cfg.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,12 +10,12 @@ * */ -#ifndef SRSLTE_RRC_CELL_CFG_H -#define SRSLTE_RRC_CELL_CFG_H +#ifndef SRSRAN_RRC_CELL_CFG_H +#define SRSRAN_RRC_CELL_CFG_H #include "rrc_config.h" -#include "srslte/common/byte_buffer.h" -#include "srslte/srslog/srslog.h" +#include "srsran/common/byte_buffer.h" +#include "srsran/srslog/srslog.h" namespace srsenb { @@ -26,7 +26,7 @@ struct enb_cell_common { asn1::rrc::sib_type1_s sib1; asn1::rrc::sib_type2_s sib2; const cell_cfg_t& cell_cfg; - std::vector sib_buffer; ///< Packed SIBs for given CC + std::vector sib_buffer; ///< Packed SIBs for given CC std::vector scells; enb_cell_common(uint32_t idx_, const cell_cfg_t& cfg) : enb_cc_idx(idx_), cell_cfg(cfg) {} @@ -71,7 +71,7 @@ public: }; const static uint32_t N_PUCCH_MAX_PRB = 4; // Maximum number of PRB to use for PUCCH ACK/NACK in CS mode - const static uint32_t N_PUCCH_MAX_RES = 3 * SRSLTE_NRE * N_PUCCH_MAX_PRB; + const static uint32_t N_PUCCH_MAX_RES = 3 * SRSRAN_NRE * N_PUCCH_MAX_PRB; uint32_t next_measgap_offset = 0; pucch_idx_sched_t sr_sched = {}; @@ -185,4 +185,4 @@ private: } // namespace srsenb -#endif // SRSLTE_RRC_CELL_CFG_H +#endif // SRSRAN_RRC_CELL_CFG_H diff --git a/srsenb/hdr/stack/rrc/rrc_config.h b/srsenb/hdr/stack/rrc/rrc_config.h index a179fccd2..5ce1562e2 100644 --- a/srsenb/hdr/stack/rrc/rrc_config.h +++ b/srsenb/hdr/stack/rrc/rrc_config.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,14 +10,14 @@ * */ -#ifndef SRSLTE_RRC_CONFIG_H -#define SRSLTE_RRC_CONFIG_H +#ifndef SRSRAN_RRC_CONFIG_H +#define SRSRAN_RRC_CONFIG_H #include "rrc_config_common.h" -#include "srslte/asn1/rrc.h" -#include "srslte/common/security.h" -#include "srslte/interfaces/enb_rrc_interface_types.h" -#include "srslte/phy/common/phy_common.h" +#include "srsran/asn1/rrc.h" +#include "srsran/common/security.h" +#include "srsran/interfaces/enb_rrc_interface_types.h" +#include "srsran/phy/common/phy_common.h" #include namespace srsenb { @@ -53,10 +53,10 @@ struct rrc_cfg_t { bool enable_mbsfn; uint16_t mbms_mcs; uint32_t inactivity_timeout_ms; - std::array eea_preference_list; - std::array eia_preference_list; + std::array eea_preference_list; + std::array eia_preference_list; bool meas_cfg_present = false; - srslte_cell_t cell; + srsran_cell_t cell; cell_list_t cell_list; cell_list_t cell_list_nr; }; @@ -71,4 +71,4 @@ struct ue_var_cfg_t { } // namespace srsenb -#endif // SRSLTE_RRC_CONFIG_H +#endif // SRSRAN_RRC_CONFIG_H diff --git a/srsenb/hdr/stack/rrc/rrc_config_common.h b/srsenb/hdr/stack/rrc/rrc_config_common.h index a308d07c5..5c15df744 100644 --- a/srsenb/hdr/stack/rrc/rrc_config_common.h +++ b/srsenb/hdr/stack/rrc/rrc_config_common.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,8 +10,8 @@ * */ -#ifndef SRSLTE_RRC_CONFIG_COMMON_H -#define SRSLTE_RRC_CONFIG_COMMON_H +#ifndef SRSRAN_RRC_CONFIG_COMMON_H +#define SRSRAN_RRC_CONFIG_COMMON_H #include @@ -37,4 +37,4 @@ struct rrc_cfg_cqi_t { } // namespace srsenb -#endif // SRSLTE_RRC_CONFIG_COMMON_H +#endif // SRSRAN_RRC_CONFIG_COMMON_H diff --git a/srsenb/hdr/stack/rrc/rrc_metrics.h b/srsenb/hdr/stack/rrc/rrc_metrics.h index bccb219b6..033bd37fa 100644 --- a/srsenb/hdr/stack/rrc/rrc_metrics.h +++ b/srsenb/hdr/stack/rrc/rrc_metrics.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/srsenb/hdr/stack/rrc/rrc_mobility.h b/srsenb/hdr/stack/rrc/rrc_mobility.h index 78d73cfac..8656f3386 100644 --- a/srsenb/hdr/stack/rrc/rrc_mobility.h +++ b/srsenb/hdr/stack/rrc/rrc_mobility.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -15,14 +15,14 @@ #include "rrc.h" #include "rrc_ue.h" -#include "srslte/common/fsm.h" +#include "srsran/common/fsm.h" #include namespace srsenb { enum class ho_interface_t { S1, X2, intra_enb }; -class rrc::ue::rrc_mobility : public srslte::fsm_t +class rrc::ue::rrc_mobility : public srsran::fsm_t { public: // public events @@ -35,10 +35,10 @@ public: rrc_mobility(srsenb::rrc::ue* outer_ue); bool fill_conn_recfg_no_ho_cmd(asn1::rrc::rrc_conn_recfg_r8_ies_s* conn_recfg); - void handle_ue_meas_report(const asn1::rrc::meas_report_s& msg, srslte::unique_byte_buffer_t pdu); + void handle_ue_meas_report(const asn1::rrc::meas_report_s& msg, srsran::unique_byte_buffer_t pdu); void handle_ho_preparation_complete(bool is_success, const asn1::s1ap::ho_cmd_s& msg, - srslte::unique_byte_buffer_t container); + srsran::unique_byte_buffer_t container); bool is_ho_running() const { return not is_in_state(); } // S1-Handover @@ -91,7 +91,7 @@ private: struct intraenb_ho_st { const enb_cell_common* target_cell = nullptr; const enb_cell_common* source_cell = nullptr; - uint16_t last_temp_crnti = SRSLTE_INVALID_RNTI; + uint16_t last_temp_crnti = SRSRAN_INVALID_RNTI; void enter(rrc_mobility* f, const ho_meas_report_ev& meas_report); }; @@ -129,7 +129,7 @@ private: using transitions = transition_table< // Start Target Event Action Guard // +-------------------+------------------+---------------------+-----------------------+---------------------+ - to_state< idle_st, srslte::failure_ev >, + to_state< idle_st, srsran::failure_ev >, to_state< idle_st, ho_cancel_ev, &fsm::handle_ho_cancel >, row< wait_ho_cmd, status_transfer_st, ho_cmd_msg, &fsm::handle_ho_cmd > // +-------------------+------------------+---------------------+-----------------------+---------------------+ diff --git a/srsenb/hdr/stack/rrc/rrc_nr.h b/srsenb/hdr/stack/rrc/rrc_nr.h index 086277886..d21933406 100644 --- a/srsenb/hdr/stack/rrc/rrc_nr.h +++ b/srsenb/hdr/stack/rrc/rrc_nr.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -16,14 +16,14 @@ #include "rrc_config_common.h" #include "rrc_metrics.h" #include "srsenb/hdr/stack/enb_stack_base.h" -#include "srslte/asn1/rrc_nr.h" -#include "srslte/common/block_queue.h" -#include "srslte/common/buffer_pool.h" -#include "srslte/common/common.h" -#include "srslte/common/task_scheduler.h" -#include "srslte/common/threads.h" -#include "srslte/common/timeout.h" -#include "srslte/interfaces/gnb_interfaces.h" +#include "srsran/asn1/rrc_nr.h" +#include "srsran/common/block_queue.h" +#include "srsran/common/buffer_pool.h" +#include "srsran/common/common.h" +#include "srsran/common/task_scheduler.h" +#include "srsran/common/threads.h" +#include "srsran/common/timeout.h" +#include "srsran/interfaces/gnb_interfaces.h" #include #include @@ -47,7 +47,7 @@ struct rrc_nr_cfg_t { uint32_t nof_sibs; rrc_nr_cfg_sr_t sr_cfg; rrc_cfg_cqi_t cqi_cfg; - srslte_cell_t cell; + srsran_cell_t cell; std::string log_level; uint32_t log_hex_limit; @@ -61,7 +61,7 @@ class rrc_nr final : public rrc_interface_pdcp_nr, public rrc_interface_ngap_nr { public: - explicit rrc_nr(srslte::timer_handler* timers_); + explicit rrc_nr(srsran::timer_handler* timers_); void init(const rrc_nr_cfg_t& cfg, phy_interface_stack_nr* phy, @@ -79,8 +79,8 @@ public: void add_user(uint16_t rnti); void config_mac(); uint32_t generate_sibs(); - int read_pdu_bcch_bch(const uint32_t tti, srslte::unique_byte_buffer_t& buffer) final; - int read_pdu_bcch_dlsch(uint32_t sib_index, srslte::unique_byte_buffer_t& buffer) final; + int read_pdu_bcch_bch(const uint32_t tti, srsran::unique_byte_buffer_t& buffer) final; + int read_pdu_bcch_dlsch(uint32_t sib_index, srsran::unique_byte_buffer_t& buffer) final; // RLC interface // TODO @@ -88,7 +88,7 @@ public: void max_retx_attempted(uint16_t rnti) {} // PDCP interface - void write_pdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t pdu) final; + void write_pdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t pdu) final; class ue { @@ -112,7 +112,7 @@ public: // state rrc_nr_state_t state = rrc_nr_state_t::RRC_IDLE; uint8_t transaction_id = 0; - srslte::timer_handler::unique_timer rrc_setup_periodic_timer; + srsran::timer_handler::unique_timer rrc_setup_periodic_timer; }; private: @@ -127,7 +127,7 @@ private: ngap_interface_rrc_nr* ngap = nullptr; // args - srslte::timer_handler* timers = nullptr; + srsran::timer_handler* timers = nullptr; // derived uint32_t slot_dur_ms = 0; @@ -136,18 +136,18 @@ private: // vars std::map > users; bool running = false; - std::vector sib_buffer; - srslte::unique_byte_buffer_t mib_buffer = nullptr; + std::vector sib_buffer; + srsran::unique_byte_buffer_t mib_buffer = nullptr; uint32_t nof_si_messages = 0; // Private Methods - void handle_pdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t pdu); + void handle_pdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t pdu); // logging typedef enum { Rx = 0, Tx } direction_t; template - void log_rrc_message(const std::string& source, direction_t dir, const srslte::byte_buffer_t* pdu, const T& msg); + void log_rrc_message(const std::string& source, direction_t dir, const srsran::byte_buffer_t* pdu, const T& msg); }; } // namespace srsenb diff --git a/srsenb/hdr/stack/rrc/rrc_ue.h b/srsenb/hdr/stack/rrc/rrc_ue.h index fab63a10f..821a20969 100644 --- a/srsenb/hdr/stack/rrc/rrc_ue.h +++ b/srsenb/hdr/stack/rrc/rrc_ue.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,14 +10,14 @@ * */ -#ifndef SRSLTE_RRC_UE_H -#define SRSLTE_RRC_UE_H +#ifndef SRSRAN_RRC_UE_H +#define SRSRAN_RRC_UE_H #include "mac_controller.h" #include "rrc.h" -#include "srslte/adt/mem_pool.h" -#include "srslte/interfaces/enb_phy_interfaces.h" -#include "srslte/interfaces/pdcp_interface_types.h" +#include "srsran/adt/mem_pool.h" +#include "srsran/interfaces/enb_phy_interfaces.h" +#include "srsran/interfaces/pdcp_interface_types.h" namespace srsenb { @@ -55,14 +55,14 @@ public: void send_connection_reject(); void send_connection_release(); void send_connection_reest_rej(); - void send_connection_reconf(srslte::unique_byte_buffer_t sdu = {}, + void send_connection_reconf(srsran::unique_byte_buffer_t sdu = {}, bool phy_cfg_updated = true, const asn1::unbounded_octstring* nas_pdu = nullptr); void send_security_mode_command(); void send_ue_cap_enquiry(); void send_ue_info_req(); - void parse_ul_dcch(uint32_t lcid, srslte::unique_byte_buffer_t pdu); + void parse_ul_dcch(uint32_t lcid, srsran::unique_byte_buffer_t pdu); /// List of results for a connection request. enum class conn_request_result_t { success, error_mme_not_connected, error_unknown_rnti }; @@ -71,16 +71,16 @@ public: enum class rrc_idle_transition_cause { release, timeout }; void handle_rrc_con_req(asn1::rrc::rrc_conn_request_s* msg); - void handle_rrc_con_setup_complete(asn1::rrc::rrc_conn_setup_complete_s* msg, srslte::unique_byte_buffer_t pdu); + void handle_rrc_con_setup_complete(asn1::rrc::rrc_conn_setup_complete_s* msg, srsran::unique_byte_buffer_t pdu); void handle_rrc_con_reest_req(asn1::rrc::rrc_conn_reest_request_s* msg); - void handle_rrc_con_reest_complete(asn1::rrc::rrc_conn_reest_complete_s* msg, srslte::unique_byte_buffer_t pdu); - void handle_rrc_reconf_complete(asn1::rrc::rrc_conn_recfg_complete_s* msg, srslte::unique_byte_buffer_t pdu); + void handle_rrc_con_reest_complete(asn1::rrc::rrc_conn_reest_complete_s* msg, srsran::unique_byte_buffer_t pdu); + void handle_rrc_reconf_complete(asn1::rrc::rrc_conn_recfg_complete_s* msg, srsran::unique_byte_buffer_t pdu); void handle_security_mode_complete(asn1::rrc::security_mode_complete_s* msg); void handle_security_mode_failure(asn1::rrc::security_mode_fail_s* msg); bool handle_ue_cap_info(asn1::rrc::ue_cap_info_s* msg); void handle_ue_init_ctxt_setup_req(const asn1::s1ap::init_context_setup_request_s& msg); bool handle_ue_ctxt_mod_req(const asn1::s1ap::ue_context_mod_request_s& msg); - void handle_ue_info_resp(const asn1::rrc::ue_info_resp_r9_s& msg, srslte::unique_byte_buffer_t pdu); + void handle_ue_info_resp(const asn1::rrc::ue_info_resp_r9_s& msg, srsran::unique_byte_buffer_t pdu); void set_bitrates(const asn1::s1ap::ue_aggregate_maximum_bitrate_s& rates); @@ -103,9 +103,9 @@ public: void send_dl_ccch(asn1::rrc::dl_ccch_msg_s* dl_ccch_msg); bool send_dl_dcch(const asn1::rrc::dl_dcch_msg_s* dl_dcch_msg, - srslte::unique_byte_buffer_t pdu = srslte::unique_byte_buffer_t()); + srsran::unique_byte_buffer_t pdu = srsran::unique_byte_buffer_t()); - void save_ul_message(srslte::unique_byte_buffer_t pdu) { last_ul_msg = std::move(pdu); } + void save_ul_message(srsran::unique_byte_buffer_t pdu) { last_ul_msg = std::move(pdu); } uint16_t rnti = 0; rrc* parent = nullptr; @@ -120,12 +120,12 @@ public: void operator delete(void* ptr)noexcept; void operator delete[](void* ptr) = delete; - using ue_pool_t = srslte::background_allocator_obj_pool; + using ue_pool_t = srsran::background_allocator_obj_pool; static ue_pool_t* get_ue_pool(); private: // args - srslte::timer_handler::unique_timer activity_timer; + srsran::timer_handler::unique_timer activity_timer; /// cached ASN1 fields for RRC config update checking, and ease of context transfer during HO ue_var_cfg_t current_ue_cfg; @@ -141,14 +141,14 @@ private: uint32_t rlf_cnt = 0; uint8_t transaction_id = 0; rrc_state_t state = RRC_STATE_IDLE; - uint16_t old_reest_rnti = SRSLTE_INVALID_RNTI; - std::map old_reest_pdcp_state = {}; + uint16_t old_reest_rnti = SRSRAN_INVALID_RNTI; + std::map old_reest_pdcp_state = {}; bool rlf_info_pending = false; asn1::s1ap::ue_aggregate_maximum_bitrate_s bitrates; bool eutra_capabilities_unpacked = false; asn1::rrc::ue_eutra_cap_s eutra_capabilities; - srslte::rrc_ue_capabilities_t ue_capabilities; + srsran::rrc_ue_capabilities_t ue_capabilities; const static uint32_t UE_PCELL_CC_IDX = 0; @@ -157,7 +157,7 @@ private: security_cfg_handler ue_security_cfg; /// Cached message of the last uplinl message. - srslte::unique_byte_buffer_t last_ul_msg; + srsran::unique_byte_buffer_t last_ul_msg; // controllers mac_controller mac_ctrl; @@ -204,4 +204,4 @@ private: } // namespace srsenb -#endif // SRSLTE_RRC_UE_H +#endif // SRSRAN_RRC_UE_H diff --git a/srsenb/hdr/stack/rrc/ue_meas_cfg.h b/srsenb/hdr/stack/rrc/ue_meas_cfg.h index d30f28210..08fca186c 100644 --- a/srsenb/hdr/stack/rrc/ue_meas_cfg.h +++ b/srsenb/hdr/stack/rrc/ue_meas_cfg.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,10 +10,10 @@ * */ -#ifndef SRSLTE_UE_MEAS_CFG_H -#define SRSLTE_UE_MEAS_CFG_H +#ifndef SRSRAN_UE_MEAS_CFG_H +#define SRSRAN_UE_MEAS_CFG_H -#include "srslte/asn1/rrc/meascfg.h" +#include "srsran/asn1/rrc/meascfg.h" namespace srsenb { @@ -75,4 +75,4 @@ bool apply_meascfg_updates(asn1::rrc::meas_cfg_s& diff_meascfg, } // namespace srsenb -#endif // SRSLTE_UE_MEAS_CFG_H +#endif // SRSRAN_UE_MEAS_CFG_H diff --git a/srsenb/hdr/stack/rrc/ue_rr_cfg.h b/srsenb/hdr/stack/rrc/ue_rr_cfg.h index 7a95e214f..54e57d78a 100644 --- a/srsenb/hdr/stack/rrc/ue_rr_cfg.h +++ b/srsenb/hdr/stack/rrc/ue_rr_cfg.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -34,8 +34,8 @@ #ifndef SRSENB_UE_RR_CFG_H #define SRSENB_UE_RR_CFG_H -#include "srslte/asn1/rrc.h" -#include "srslte/interfaces/rrc_interface_types.h" +#include "srsran/asn1/rrc.h" +#include "srsran/interfaces/rrc_interface_types.h" namespace srsenb { @@ -55,7 +55,7 @@ void apply_reconf_updates(asn1::rrc::rrc_conn_recfg_r8_ies_s& recfg_r8, const rrc_cfg_t& enb_cfg, const ue_cell_ded_list& ue_cell_list, bearer_cfg_handler& bearers, - const srslte::rrc_ue_capabilities_t& ue_caps, + const srsran::rrc_ue_capabilities_t& ue_caps, bool phy_cfg_updated); /// Apply radioResourceConfigDedicated updates to the current UE RRC configuration diff --git a/srsenb/hdr/stack/upper/common_enb.h b/srsenb/hdr/stack/upper/common_enb.h index 554937d61..e0b0a0efa 100644 --- a/srsenb/hdr/stack/upper/common_enb.h +++ b/srsenb/hdr/stack/upper/common_enb.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/srsenb/hdr/stack/upper/gtpu.h b/srsenb/hdr/stack/upper/gtpu.h index 1fe5df36a..e1afc7805 100644 --- a/srsenb/hdr/stack/upper/gtpu.h +++ b/srsenb/hdr/stack/upper/gtpu.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -15,12 +15,12 @@ #include #include "common_enb.h" -#include "srslte/common/buffer_pool.h" -#include "srslte/common/task_scheduler.h" -#include "srslte/common/threads.h" -#include "srslte/interfaces/enb_gtpu_interfaces.h" -#include "srslte/phy/common/phy_common.h" -#include "srslte/srslog/srslog.h" +#include "srsran/common/buffer_pool.h" +#include "srsran/common/task_scheduler.h" +#include "srsran/common/threads.h" +#include "srsran/interfaces/enb_gtpu_interfaces.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/srslog/srslog.h" #include @@ -35,7 +35,7 @@ class stack_interface_gtpu_lte; class gtpu final : public gtpu_interface_rrc, public gtpu_interface_pdcp { public: - explicit gtpu(srslte::task_sched_handle task_sched_, srslog::basic_logger& logger); + explicit gtpu(srsran::task_sched_handle task_sched_, srslog::basic_logger& logger); int init(std::string gtp_bind_addr_, std::string mme_addr_, @@ -58,11 +58,11 @@ public: void rem_user(uint16_t rnti) override; // gtpu_interface_pdcp - void write_pdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t pdu) override; + void write_pdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t pdu) override; // stack interface - void handle_gtpu_s1u_rx_packet(srslte::unique_byte_buffer_t pdu, const sockaddr_in& addr); - void handle_gtpu_m1u_rx_packet(srslte::unique_byte_buffer_t pdu, const sockaddr_in& addr); + void handle_gtpu_s1u_rx_packet(srsran::unique_byte_buffer_t pdu, const sockaddr_in& addr); + void handle_gtpu_m1u_rx_packet(srsran::unique_byte_buffer_t pdu, const sockaddr_in& addr); private: static const int GTPU_PORT = 2152; @@ -76,7 +76,7 @@ private: std::string mme_addr; srsenb::pdcp_interface_gtpu* pdcp = nullptr; srslog::basic_logger& logger; - srslte::task_sched_handle task_sched; + srsran::task_sched_handle task_sched; // Class to create class m1u_handler @@ -89,7 +89,7 @@ private: m1u_handler& operator=(const m1u_handler&) = delete; m1u_handler& operator=(m1u_handler&&) = delete; bool init(std::string m1u_multiaddr_, std::string m1u_if_addr_); - void handle_rx_packet(srslte::unique_byte_buffer_t pdu, const sockaddr_in& addr); + void handle_rx_packet(srsran::unique_byte_buffer_t pdu, const sockaddr_in& addr); private: gtpu* parent = nullptr; @@ -109,15 +109,15 @@ private: bool dl_enabled = true; bool fwd_teid_in_present = false; bool prior_teid_in_present = false; - uint16_t rnti = SRSLTE_INVALID_RNTI; + uint16_t rnti = SRSRAN_INVALID_RNTI; uint32_t lcid = SRSENB_N_RADIO_BEARERS; uint32_t teid_in = 0; uint32_t teid_out = 0; uint32_t spgw_addr = 0; uint32_t fwd_teid_in = 0; ///< forward Rx SDUs to this TEID uint32_t prior_teid_in = 0; ///< buffer bearer SDUs until this TEID receives an End Marker - srslte::unique_timer rx_timer; - std::multimap buffer; + srsran::unique_timer rx_timer; + std::multimap buffer; }; std::unordered_map tunnels; std::map, SRSENB_N_RADIO_BEARERS> > ue_teidin_db; @@ -128,7 +128,7 @@ private: // Socket file descriptor int fd = -1; - void send_pdu_to_tunnel(tunnel& tx_tun, srslte::unique_byte_buffer_t pdu, int pdcp_sn = -1); + void send_pdu_to_tunnel(tunnel& tx_tun, srsran::unique_byte_buffer_t pdu, int pdcp_sn = -1); void echo_response(in_addr_t addr, in_port_t port, uint16_t seq); void error_indication(in_addr_t addr, in_port_t port, uint32_t err_teid); @@ -144,9 +144,9 @@ private: uint32_t next_teid_in = 0; tunnel* get_tunnel(uint32_t teidin); - srslte::span get_lcid_teids(uint16_t rnti, uint32_t lcid); + srsran::span get_lcid_teids(uint16_t rnti, uint32_t lcid); - void log_message(tunnel& tun, bool is_rx, srslte::span pdu, int pdcp_sn = -1); + void log_message(tunnel& tun, bool is_rx, srsran::span pdu, int pdcp_sn = -1); }; } // namespace srsenb diff --git a/srsenb/hdr/stack/upper/pdcp.h b/srsenb/hdr/stack/upper/pdcp.h index 2f9d4dfe7..1d5c3c21a 100644 --- a/srsenb/hdr/stack/upper/pdcp.h +++ b/srsenb/hdr/stack/upper/pdcp.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,13 +10,13 @@ * */ -#include "srslte/common/timers.h" -#include "srslte/interfaces/enb_metrics_interface.h" -#include "srslte/interfaces/enb_pdcp_interfaces.h" -#include "srslte/interfaces/ue_gw_interfaces.h" -#include "srslte/interfaces/ue_rlc_interfaces.h" -#include "srslte/srslog/srslog.h" -#include "srslte/upper/pdcp.h" +#include "srsran/common/timers.h" +#include "srsran/interfaces/enb_metrics_interface.h" +#include "srsran/interfaces/enb_pdcp_interfaces.h" +#include "srsran/interfaces/ue_gw_interfaces.h" +#include "srsran/interfaces/ue_rlc_interfaces.h" +#include "srsran/srslog/srslog.h" +#include "srsran/upper/pdcp.h" #include #ifndef SRSENB_PDCP_H @@ -31,35 +31,35 @@ class gtpu_interface_pdcp; class pdcp : public pdcp_interface_rlc, public pdcp_interface_gtpu, public pdcp_interface_rrc { public: - pdcp(srslte::task_sched_handle task_sched_, srslog::basic_logger& logger); + pdcp(srsran::task_sched_handle task_sched_, srslog::basic_logger& logger); virtual ~pdcp() {} void init(rlc_interface_pdcp* rlc_, rrc_interface_pdcp* rrc_, gtpu_interface_pdcp* gtpu_); void stop(); // pdcp_interface_rlc - void write_pdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t sdu) override; - void notify_delivery(uint16_t rnti, uint32_t lcid, const srslte::pdcp_sn_vector_t& pdcp_sn) override; - void notify_failure(uint16_t rnti, uint32_t lcid, const srslte::pdcp_sn_vector_t& pdcp_sn) override; - void write_pdu_mch(uint32_t lcid, srslte::unique_byte_buffer_t sdu) {} + void write_pdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t sdu) override; + void notify_delivery(uint16_t rnti, uint32_t lcid, const srsran::pdcp_sn_vector_t& pdcp_sn) override; + void notify_failure(uint16_t rnti, uint32_t lcid, const srsran::pdcp_sn_vector_t& pdcp_sn) override; + void write_pdu_mch(uint32_t lcid, srsran::unique_byte_buffer_t sdu) {} // pdcp_interface_rrc void reset(uint16_t rnti) override; void add_user(uint16_t rnti) override; void rem_user(uint16_t rnti) override; - void write_sdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t sdu, int pdcp_sn = -1) override; - void add_bearer(uint16_t rnti, uint32_t lcid, srslte::pdcp_config_t cnfg) override; + void write_sdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t sdu, int pdcp_sn = -1) override; + void add_bearer(uint16_t rnti, uint32_t lcid, srsran::pdcp_config_t cnfg) override; void del_bearer(uint16_t rnti, uint32_t lcid) override; - void config_security(uint16_t rnti, uint32_t lcid, srslte::as_security_config_t cfg_sec) override; + void config_security(uint16_t rnti, uint32_t lcid, srsran::as_security_config_t cfg_sec) override; void enable_integrity(uint16_t rnti, uint32_t lcid) override; void enable_encryption(uint16_t rnti, uint32_t lcid) override; - bool get_bearer_state(uint16_t rnti, uint32_t lcid, srslte::pdcp_lte_state_t* state) override; - bool set_bearer_state(uint16_t rnti, uint32_t lcid, const srslte::pdcp_lte_state_t& state) override; + bool get_bearer_state(uint16_t rnti, uint32_t lcid, srsran::pdcp_lte_state_t* state) override; + bool set_bearer_state(uint16_t rnti, uint32_t lcid, const srsran::pdcp_lte_state_t& state) override; void send_status_report(uint16_t rnti) override; void send_status_report(uint16_t rnti, uint32_t lcid) override; void reestablish(uint16_t rnti) override; // pdcp_interface_gtpu - std::map get_buffered_pdus(uint16_t rnti, uint32_t lcid) override; + std::map get_buffered_pdus(uint16_t rnti, uint32_t lcid) override; // Metrics void get_metrics(pdcp_metrics_t& m, const uint32_t nof_tti); @@ -71,7 +71,7 @@ private: uint16_t rnti; srsenb::rlc_interface_pdcp* rlc; // rlc_interface_pdcp - void write_sdu(uint32_t lcid, srslte::unique_byte_buffer_t sdu); + void write_sdu(uint32_t lcid, srsran::unique_byte_buffer_t sdu); void discard_sdu(uint32_t lcid, uint32_t discard_sn); bool rb_is_um(uint32_t lcid); bool sdu_queue_is_full(uint32_t lcid); @@ -83,8 +83,8 @@ private: uint16_t rnti; srsenb::gtpu_interface_pdcp* gtpu; // gw_interface_pdcp - void write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t pdu); - void write_pdu_mch(uint32_t lcid, srslte::unique_byte_buffer_t sdu) {} + void write_pdu(uint32_t lcid, srsran::unique_byte_buffer_t pdu); + void write_pdu_mch(uint32_t lcid, srsran::unique_byte_buffer_t sdu) {} }; class user_interface_rrc : public srsue::rrc_interface_pdcp @@ -93,11 +93,11 @@ private: uint16_t rnti; srsenb::rrc_interface_pdcp* rrc; // rrc_interface_pdcp - void write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t pdu); - void write_pdu_bcch_bch(srslte::unique_byte_buffer_t pdu); - void write_pdu_bcch_dlsch(srslte::unique_byte_buffer_t pdu); - void write_pdu_pcch(srslte::unique_byte_buffer_t pdu); - void write_pdu_mch(uint32_t lcid, srslte::unique_byte_buffer_t pdu) {} + void write_pdu(uint32_t lcid, srsran::unique_byte_buffer_t pdu); + void write_pdu_bcch_bch(srsran::unique_byte_buffer_t pdu); + void write_pdu_bcch_dlsch(srsran::unique_byte_buffer_t pdu); + void write_pdu_pcch(srsran::unique_byte_buffer_t pdu); + void write_pdu_mch(uint32_t lcid, srsran::unique_byte_buffer_t pdu) {} std::string get_rb_name(uint32_t lcid); }; @@ -107,7 +107,7 @@ private: user_interface_rlc rlc_itf; user_interface_gtpu gtpu_itf; user_interface_rrc rrc_itf; - srslte::pdcp* pdcp; + srsran::pdcp* pdcp; }; void clear_user(user_interface* ue); @@ -117,7 +117,7 @@ private: rlc_interface_pdcp* rlc; rrc_interface_pdcp* rrc; gtpu_interface_pdcp* gtpu; - srslte::task_sched_handle task_sched; + srsran::task_sched_handle task_sched; srslog::basic_logger& logger; }; diff --git a/srsenb/hdr/stack/upper/pdcp_nr.h b/srsenb/hdr/stack/upper/pdcp_nr.h index 223d42141..20402ad11 100644 --- a/srsenb/hdr/stack/upper/pdcp_nr.h +++ b/srsenb/hdr/stack/upper/pdcp_nr.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,10 +10,10 @@ * */ -#include "srslte/interfaces/gnb_interfaces.h" -#include "srslte/interfaces/ue_gw_interfaces.h" -#include "srslte/interfaces/ue_rlc_interfaces.h" -#include "srslte/upper/pdcp.h" +#include "srsran/interfaces/gnb_interfaces.h" +#include "srsran/interfaces/ue_gw_interfaces.h" +#include "srsran/interfaces/ue_rlc_interfaces.h" +#include "srsran/upper/pdcp.h" #include #ifndef SRSENB_PDCP_NR_H @@ -29,7 +29,7 @@ struct pdcp_nr_args_t { class pdcp_nr : public pdcp_interface_rlc_nr, public pdcp_interface_sdap_nr, public pdcp_interface_rrc_nr { public: - explicit pdcp_nr(srslte::task_sched_handle task_sched_, const char* logname); + explicit pdcp_nr(srsran::task_sched_handle task_sched_, const char* logname); virtual ~pdcp_nr() = default; void init(const pdcp_nr_args_t& args_, rlc_interface_pdcp_nr* rlc_, @@ -38,18 +38,18 @@ public: void stop(); // pdcp_interface_rlc_nr - void write_pdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t sdu); - void notify_delivery(uint16_t rnti, uint32_t lcid, const srslte::pdcp_sn_vector_t& pdcp_sn); - void notify_failure(uint16_t rnti, uint32_t lcid, const srslte::pdcp_sn_vector_t& pdcp_sn); - void write_pdu_mch(uint32_t lcid, srslte::unique_byte_buffer_t sdu) {} + void write_pdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t sdu); + void notify_delivery(uint16_t rnti, uint32_t lcid, const srsran::pdcp_sn_vector_t& pdcp_sn); + void notify_failure(uint16_t rnti, uint32_t lcid, const srsran::pdcp_sn_vector_t& pdcp_sn); + void write_pdu_mch(uint32_t lcid, srsran::unique_byte_buffer_t sdu) {} // pdcp_interface_rrc_nr void reset(uint16_t rnti) final; void add_user(uint16_t rnti) final; void rem_user(uint16_t rnti) final; - void write_sdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t sdu) final; - void add_bearer(uint16_t rnti, uint32_t lcid, srslte::pdcp_config_t cnfg) final; - void config_security(uint16_t rnti, uint32_t lcid, srslte::as_security_config_t sec_cfg) final; + void write_sdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t sdu) final; + void add_bearer(uint16_t rnti, uint32_t lcid, srsran::pdcp_config_t cnfg) final; + void config_security(uint16_t rnti, uint32_t lcid, srsran::as_security_config_t sec_cfg) final; void enable_integrity(uint16_t rnti, uint32_t lcid) final; void enable_encryption(uint16_t rnti, uint32_t lcid) final; @@ -60,7 +60,7 @@ private: uint16_t rnti; srsenb::rlc_interface_pdcp_nr* rlc; // rlc_interface_pdcp_nr - void write_sdu(uint32_t lcid, srslte::unique_byte_buffer_t sdu) final; + void write_sdu(uint32_t lcid, srsran::unique_byte_buffer_t sdu) final; void discard_sdu(uint32_t lcid, uint32_t discard_sn) final; bool rb_is_um(uint32_t lcid) final; bool sdu_queue_is_full(uint32_t lcid) final; @@ -72,8 +72,8 @@ private: uint16_t rnti; srsenb::sdap_interface_pdcp_nr* sdap; // gw_interface_pdcp - void write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t pdu) final; - void write_pdu_mch(uint32_t lcid, srslte::unique_byte_buffer_t sdu) final {} + void write_pdu(uint32_t lcid, srsran::unique_byte_buffer_t pdu) final; + void write_pdu_mch(uint32_t lcid, srsran::unique_byte_buffer_t sdu) final {} }; class user_interface_rrc : public srsue::rrc_interface_pdcp @@ -82,11 +82,11 @@ private: uint16_t rnti; srsenb::rrc_interface_pdcp_nr* rrc; // rrc_interface_pdcp_nr - void write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t pdu) final; - void write_pdu_bcch_bch(srslte::unique_byte_buffer_t pdu) final; - void write_pdu_bcch_dlsch(srslte::unique_byte_buffer_t pdu) final; - void write_pdu_pcch(srslte::unique_byte_buffer_t pdu) final; - void write_pdu_mch(uint32_t lcid, srslte::unique_byte_buffer_t pdu) final {} + void write_pdu(uint32_t lcid, srsran::unique_byte_buffer_t pdu) final; + void write_pdu_bcch_bch(srsran::unique_byte_buffer_t pdu) final; + void write_pdu_bcch_dlsch(srsran::unique_byte_buffer_t pdu) final; + void write_pdu_pcch(srsran::unique_byte_buffer_t pdu) final; + void write_pdu_mch(uint32_t lcid, srsran::unique_byte_buffer_t pdu) final {} std::string get_rb_name(uint32_t lcid) final; }; @@ -96,7 +96,7 @@ private: user_interface_rlc rlc_itf; user_interface_sdap sdap_itf; user_interface_rrc rrc_itf; - std::unique_ptr pdcp; + std::unique_ptr pdcp; }; // args @@ -107,7 +107,7 @@ private: std::map users; - srslte::task_sched_handle task_sched; + srsran::task_sched_handle task_sched; srslog::basic_logger& logger; }; diff --git a/srsenb/hdr/stack/upper/rlc.h b/srsenb/hdr/stack/upper/rlc.h index a555b7763..58c5f5a33 100644 --- a/srsenb/hdr/stack/upper/rlc.h +++ b/srsenb/hdr/stack/upper/rlc.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,11 +10,11 @@ * */ -#include "srslte/interfaces/enb_metrics_interface.h" -#include "srslte/interfaces/enb_rlc_interfaces.h" -#include "srslte/interfaces/ue_interfaces.h" -#include "srslte/srslog/srslog.h" -#include "srslte/upper/rlc.h" +#include "srsran/interfaces/enb_metrics_interface.h" +#include "srsran/interfaces/enb_rlc_interfaces.h" +#include "srsran/interfaces/ue_interfaces.h" +#include "srsran/srslog/srslog.h" +#include "srsran/upper/rlc.h" #include #ifndef SRSENB_RLC_H @@ -38,7 +38,7 @@ class rlc : public rlc_interface_mac, public rlc_interface_rrc, public rlc_inter public: explicit rlc(srslog::basic_logger& logger) : logger(logger) {} void - init(pdcp_interface_rlc* pdcp_, rrc_interface_rlc* rrc_, mac_interface_rlc* mac_, srslte::timer_handler* timers_); + init(pdcp_interface_rlc* pdcp_, rrc_interface_rlc* rrc_, mac_interface_rlc* mac_, srsran::timer_handler* timers_); void stop(); void get_metrics(rlc_metrics_t& m, const uint32_t nof_tti); @@ -46,7 +46,7 @@ public: void clear_buffer(uint16_t rnti); void add_user(uint16_t rnti); void rem_user(uint16_t rnti); - void add_bearer(uint16_t rnti, uint32_t lcid, srslte::rlc_config_t cnfg); + void add_bearer(uint16_t rnti, uint32_t lcid, srsran::rlc_config_t cnfg); void add_bearer_mrb(uint16_t rnti, uint32_t lcid); void del_bearer(uint16_t rnti, uint32_t lcid); bool has_bearer(uint16_t rnti, uint32_t lcid); @@ -55,7 +55,7 @@ public: void reestablish(uint16_t rnti) final; // rlc_interface_pdcp - void write_sdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t sdu); + void write_sdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t sdu); void discard_sdu(uint16_t rnti, uint32_t lcid, uint32_t discard_sn); bool rb_is_um(uint16_t rnti, uint32_t lcid); std::string get_rb_name(uint32_t lcid); @@ -70,20 +70,20 @@ private: class user_interface : public srsue::pdcp_interface_rlc, public srsue::rrc_interface_rlc { public: - void write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t sdu); - void notify_delivery(uint32_t lcid, const srslte::pdcp_sn_vector_t& pdcp_sn); - void notify_failure(uint32_t lcid, const srslte::pdcp_sn_vector_t& pdcp_sn); - void write_pdu_bcch_bch(srslte::unique_byte_buffer_t sdu); - void write_pdu_bcch_dlsch(srslte::unique_byte_buffer_t sdu); - void write_pdu_pcch(srslte::unique_byte_buffer_t sdu); - void write_pdu_mch(uint32_t lcid, srslte::unique_byte_buffer_t sdu) {} + void write_pdu(uint32_t lcid, srsran::unique_byte_buffer_t sdu); + void notify_delivery(uint32_t lcid, const srsran::pdcp_sn_vector_t& pdcp_sn); + void notify_failure(uint32_t lcid, const srsran::pdcp_sn_vector_t& pdcp_sn); + void write_pdu_bcch_bch(srsran::unique_byte_buffer_t sdu); + void write_pdu_bcch_dlsch(srsran::unique_byte_buffer_t sdu); + void write_pdu_pcch(srsran::unique_byte_buffer_t sdu); + void write_pdu_mch(uint32_t lcid, srsran::unique_byte_buffer_t sdu) {} void max_retx_attempted(); std::string get_rb_name(uint32_t lcid); uint16_t rnti; srsenb::pdcp_interface_rlc* pdcp; srsenb::rrc_interface_rlc* rrc; - std::unique_ptr rlc; + std::unique_ptr rlc; srsenb::rlc* parent; }; @@ -98,7 +98,7 @@ private: pdcp_interface_rlc* pdcp; rrc_interface_rlc* rrc; srslog::basic_logger& logger; - srslte::timer_handler* timers; + srsran::timer_handler* timers; }; } // namespace srsenb diff --git a/srsenb/hdr/stack/upper/rlc_nr.h b/srsenb/hdr/stack/upper/rlc_nr.h index 9514c86c9..7b3b95764 100644 --- a/srsenb/hdr/stack/upper/rlc_nr.h +++ b/srsenb/hdr/stack/upper/rlc_nr.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,8 +13,8 @@ #ifndef SRSENB_RLC_NR_H #define SRSENB_RLC_NR_H -#include "srslte/interfaces/gnb_interfaces.h" -#include "srslte/upper/rlc.h" +#include "srsran/interfaces/gnb_interfaces.h" +#include "srsran/upper/rlc.h" #include namespace srsenb { @@ -33,18 +33,18 @@ public: void init(pdcp_interface_rlc_nr* pdcp_, rrc_interface_rlc_nr* rrc_, mac_interface_rlc_nr* mac_, - srslte::timer_handler* timers_); + srsran::timer_handler* timers_); void stop(); // rlc_interface_rrc_nr void clear_buffer(uint16_t rnti); void add_user(uint16_t rnti); void rem_user(uint16_t rnti); - void add_bearer(uint16_t rnti, uint32_t lcid, srslte::rlc_config_t cnfg); + void add_bearer(uint16_t rnti, uint32_t lcid, srsran::rlc_config_t cnfg); void add_bearer_mrb(uint16_t rnti, uint32_t lcid); // rlc_interface_pdcp_nr - void write_sdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t sdu); + void write_sdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t sdu); bool rb_is_um(uint16_t rnti, uint32_t lcid); bool sdu_queue_is_full(uint16_t rnti, uint32_t lcid); std::string get_rb_name(uint32_t lcid); @@ -59,25 +59,25 @@ private: class user_interface : public srsue::pdcp_interface_rlc, public srsue::rrc_interface_rlc { public: - void write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t sdu); - void notify_delivery(uint32_t lcid, const srslte::pdcp_sn_vector_t& pdcp_sns); - void notify_failure(uint32_t lcid, const srslte::pdcp_sn_vector_t& pdcp_sns); - void write_pdu_bcch_bch(srslte::unique_byte_buffer_t sdu); - void write_pdu_bcch_dlsch(srslte::unique_byte_buffer_t sdu); - void write_pdu_pcch(srslte::unique_byte_buffer_t sdu); - void write_pdu_mch(uint32_t lcid, srslte::unique_byte_buffer_t sdu) {} + void write_pdu(uint32_t lcid, srsran::unique_byte_buffer_t sdu); + void notify_delivery(uint32_t lcid, const srsran::pdcp_sn_vector_t& pdcp_sns); + void notify_failure(uint32_t lcid, const srsran::pdcp_sn_vector_t& pdcp_sns); + void write_pdu_bcch_bch(srsran::unique_byte_buffer_t sdu); + void write_pdu_bcch_dlsch(srsran::unique_byte_buffer_t sdu); + void write_pdu_pcch(srsran::unique_byte_buffer_t sdu); + void write_pdu_mch(uint32_t lcid, srsran::unique_byte_buffer_t sdu) {} void max_retx_attempted() final; std::string get_rb_name(uint32_t lcid) final; uint16_t rnti; srsenb::pdcp_interface_rlc_nr* m_pdcp = nullptr; srsenb::rrc_interface_rlc_nr* m_rrc = nullptr; - std::unique_ptr m_rlc; + std::unique_ptr m_rlc; rlc_nr* parent = nullptr; }; // args - srslte::timer_handler* timers = nullptr; + srsran::timer_handler* timers = nullptr; mac_interface_rlc_nr* m_mac = nullptr; pdcp_interface_rlc_nr* m_pdcp = nullptr; rrc_interface_rlc_nr* m_rrc = nullptr; diff --git a/srsenb/hdr/stack/upper/s1ap.h b/srsenb/hdr/stack/upper/s1ap.h index acc1674cd..db1604a72 100644 --- a/srsenb/hdr/stack/upper/s1ap.h +++ b/srsenb/hdr/stack/upper/s1ap.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -16,19 +16,19 @@ #include #include "common_enb.h" -#include "srslte/common/buffer_pool.h" -#include "srslte/common/common.h" -#include "srslte/common/s1ap_pcap.h" -#include "srslte/common/threads.h" -#include "srslte/interfaces/enb_interfaces.h" -#include "srslte/interfaces/enb_s1ap_interfaces.h" +#include "srsran/common/buffer_pool.h" +#include "srsran/common/common.h" +#include "srsran/common/s1ap_pcap.h" +#include "srsran/common/threads.h" +#include "srsran/interfaces/enb_interfaces.h" +#include "srsran/interfaces/enb_s1ap_interfaces.h" #include "s1ap_metrics.h" -#include "srslte/asn1/s1ap.h" -#include "srslte/common/network_utils.h" -#include "srslte/common/stack_procedure.h" -#include "srslte/common/task_scheduler.h" -#include "srslte/srslog/srslog.h" +#include "srsran/asn1/s1ap.h" +#include "srsran/common/network_utils.h" +#include "srsran/common/stack_procedure.h" +#include "srsran/common/task_scheduler.h" +#include "srsran/srslog/srslog.h" #include namespace srsenb { @@ -39,7 +39,7 @@ struct ue_ctxt_t { static const uint32_t invalid_enb_id = std::numeric_limits::max(); bool mme_ue_s1ap_id_present = false; - uint16_t rnti = SRSLTE_INVALID_RNTI; + uint16_t rnti = SRSRAN_INVALID_RNTI; uint32_t enb_ue_s1ap_id = invalid_enb_id; uint32_t mme_ue_s1ap_id = 0; uint32_t enb_cc_idx = 0; @@ -52,7 +52,7 @@ public: static const uint32_t ts1_reloc_prep_timeout_ms = 10000; static const uint32_t ts1_reloc_overall_timeout_ms = 10000; - s1ap(srslte::task_sched_handle task_sched_, srslog::basic_logger& logger); + s1ap(srsran::task_sched_handle task_sched_, srslog::basic_logger& logger); int init(s1ap_args_t args_, rrc_interface_s1ap* rrc_, srsenb::stack_interface_s1ap_lte* stack_); void stop(); void get_metrics(s1ap_metrics_t& m); @@ -61,14 +61,14 @@ public: void initial_ue(uint16_t rnti, uint32_t enb_cc_idx, asn1::s1ap::rrc_establishment_cause_e cause, - srslte::unique_byte_buffer_t pdu) override; + srsran::unique_byte_buffer_t pdu) override; void initial_ue(uint16_t rnti, uint32_t enb_cc_idx, asn1::s1ap::rrc_establishment_cause_e cause, - srslte::unique_byte_buffer_t pdu, + srsran::unique_byte_buffer_t pdu, uint32_t m_tmsi, uint8_t mmec) override; - void write_pdu(uint16_t rnti, srslte::unique_byte_buffer_t pdu) override; + void write_pdu(uint16_t rnti, srsran::unique_byte_buffer_t pdu) override; bool user_exists(uint16_t rnti) override; void user_mod(uint16_t old_rnti, uint16_t new_rnti) override; bool user_release(uint16_t rnti, asn1::s1ap::cause_radio_network_e cause_radio) override; @@ -77,26 +77,26 @@ public: bool is_mme_connected() override; bool send_ho_required(uint16_t rnti, uint32_t target_eci, - srslte::plmn_id_t target_plmn, - srslte::span fwd_erabs, - srslte::unique_byte_buffer_t rrc_container) override; + srsran::plmn_id_t target_plmn, + srsran::span fwd_erabs, + srsran::unique_byte_buffer_t rrc_container) override; bool send_enb_status_transfer_proc(uint16_t rnti, std::vector& bearer_status_list) override; bool send_ho_failure(uint32_t mme_ue_s1ap_id); bool send_ho_req_ack(const asn1::s1ap::ho_request_s& msg, uint16_t rnti, uint32_t enb_cc_idx, - srslte::unique_byte_buffer_t ho_cmd, - srslte::span admitted_bearers) override; + srsran::unique_byte_buffer_t ho_cmd, + srsran::span admitted_bearers) override; void send_ho_notify(uint16_t rnti, uint64_t target_eci) override; void send_ho_cancel(uint16_t rnti) override; bool release_erabs(uint16_t rnti, const std::vector& erabs_successfully_released) override; bool send_error_indication(uint16_t rnti, const asn1::s1ap::cause_c& cause); - bool send_ue_cap_info_indication(uint16_t rnti, srslte::unique_byte_buffer_t ue_radio_cap) override; + bool send_ue_cap_info_indication(uint16_t rnti, srsran::unique_byte_buffer_t ue_radio_cap) override; // Stack interface bool - handle_mme_rx_msg(srslte::unique_byte_buffer_t pdu, const sockaddr_in& from, const sctp_sndrcvinfo& sri, int flags); - void start_pcap(srslte::s1ap_pcap* pcap_); + handle_mme_rx_msg(srsran::unique_byte_buffer_t pdu, const sockaddr_in& from, const sctp_sndrcvinfo& sri, int flags); + void start_pcap(srsran::s1ap_pcap* pcap_); private: static const int MME_PORT = 36412; @@ -111,22 +111,22 @@ private: s1ap_args_t args; srslog::basic_logger& logger; srsenb::stack_interface_s1ap_lte* stack = nullptr; - srslte::task_sched_handle task_sched; + srsran::task_sched_handle task_sched; - srslte::socket_handler_t s1ap_socket; + srsran::socket_handler_t s1ap_socket; struct sockaddr_in mme_addr = {}; // MME address bool mme_connected = false; bool running = false; uint32_t next_enb_ue_s1ap_id = 1; // Next ENB-side UE identifier uint16_t next_ue_stream_id = 1; // Next UE SCTP stream identifier - srslte::unique_timer mme_connect_timer, s1setup_timeout; + srsran::unique_timer mme_connect_timer, s1setup_timeout; // Protocol IEs sent with every UL S1AP message asn1::s1ap::tai_s tai; asn1::s1ap::eutran_cgi_s eutran_cgi; // PCAP - srslte::s1ap_pcap* pcap = nullptr; + srsran::s1ap_pcap* pcap = nullptr; asn1::s1ap::s1_setup_resp_s s1setupresponse; @@ -135,7 +135,7 @@ private: bool setup_s1(); bool sctp_send_s1ap_pdu(const asn1::s1ap::s1ap_pdu_c& tx_pdu, uint32_t rnti, const char* procedure_name); - bool handle_s1ap_rx_pdu(srslte::byte_buffer_t* pdu); + bool handle_s1ap_rx_pdu(srsran::byte_buffer_t* pdu); bool handle_initiatingmessage(const asn1::s1ap::init_msg_s& msg); bool handle_successfuloutcome(const asn1::s1ap::successful_outcome_s& msg); bool handle_unsuccessfuloutcome(const asn1::s1ap::unsuccessful_outcome_s& msg); @@ -195,15 +195,15 @@ private: public: struct ts1_reloc_prep_expired {}; ho_prep_proc_t(s1ap::ue* ue_); - srslte::proc_outcome_t init(uint32_t target_eci_, - srslte::plmn_id_t target_plmn_, - srslte::span fwd_erabs, - srslte::unique_byte_buffer_t rrc_container); - srslte::proc_outcome_t step() { return srslte::proc_outcome_t::yield; } - srslte::proc_outcome_t react(ts1_reloc_prep_expired e); - srslte::proc_outcome_t react(const asn1::s1ap::ho_prep_fail_s& msg); - srslte::proc_outcome_t react(const asn1::s1ap::ho_cmd_s& msg); - void then(const srslte::proc_state_t& result); + srsran::proc_outcome_t init(uint32_t target_eci_, + srsran::plmn_id_t target_plmn_, + srsran::span fwd_erabs, + srsran::unique_byte_buffer_t rrc_container); + srsran::proc_outcome_t step() { return srsran::proc_outcome_t::yield; } + srsran::proc_outcome_t react(ts1_reloc_prep_expired e); + srsran::proc_outcome_t react(const asn1::s1ap::ho_prep_fail_s& msg); + srsran::proc_outcome_t react(const asn1::s1ap::ho_cmd_s& msg); + void then(const srsran::proc_state_t& result); const char* name() { return "HandoverPreparation"; } private: @@ -211,21 +211,21 @@ private: s1ap* s1ap_ptr = nullptr; uint32_t target_eci = 0; - srslte::plmn_id_t target_plmn; - srslte::unique_byte_buffer_t rrc_container; + srsran::plmn_id_t target_plmn; + srsran::unique_byte_buffer_t rrc_container; const asn1::s1ap::ho_cmd_s* ho_cmd_msg = nullptr; }; explicit ue(s1ap* s1ap_ptr_); bool send_enb_status_transfer_proc(std::vector& bearer_status_list); - bool send_ulnastransport(srslte::unique_byte_buffer_t pdu); + bool send_ulnastransport(srsran::unique_byte_buffer_t pdu); bool send_uectxtreleaserequest(const asn1::s1ap::cause_c& cause); bool send_uectxtmodifyfailure(const asn1::s1ap::cause_c& cause); bool send_uectxtmodifyresp(); bool send_uectxtreleasecomplete(); bool send_initialuemessage(asn1::s1ap::rrc_establishment_cause_e cause, - srslte::unique_byte_buffer_t pdu, + srsran::unique_byte_buffer_t pdu, bool has_tmsi, uint32_t m_tmsi = 0, uint8_t mmec = 0); @@ -237,7 +237,7 @@ private: bool send_erab_modify_response(const std::vector& erabs_successfully_released, const std::vector& erabs_failed_to_release); bool send_erab_release_indication(const std::vector& erabs_successfully_released); - bool send_ue_cap_info_indication(srslte::unique_byte_buffer_t ue_radio_cap); + bool send_ue_cap_info_indication(srsran::unique_byte_buffer_t ue_radio_cap); bool was_uectxtrelease_requested() const { return release_requested; } @@ -246,9 +246,9 @@ private: private: bool send_ho_required(uint32_t target_eci_, - srslte::plmn_id_t target_plmn_, - srslte::span fwd_erabs, - srslte::unique_byte_buffer_t rrc_container); + srsran::plmn_id_t target_plmn_, + srsran::span fwd_erabs, + srsran::unique_byte_buffer_t rrc_container); //! TS 36.413, Section 8.4.6 - eNB Status Transfer procedure // args @@ -257,12 +257,12 @@ private: // state bool release_requested = false; - srslte::unique_timer ts1_reloc_prep; ///< TS1_{RELOCprep} - max time for HO preparation - srslte::unique_timer ts1_reloc_overall; ///< TS1_{RELOCOverall} + srsran::unique_timer ts1_reloc_prep; ///< TS1_{RELOCprep} - max time for HO preparation + srsran::unique_timer ts1_reloc_overall; ///< TS1_{RELOCOverall} public: // user procedures - srslte::proc_t ho_prep_proc; + srsran::proc_t ho_prep_proc; }; class user_list @@ -299,23 +299,23 @@ private: }; explicit s1_setup_proc_t(s1ap* s1ap_) : s1ap_ptr(s1ap_) {} - srslte::proc_outcome_t init(); - srslte::proc_outcome_t step() { return srslte::proc_outcome_t::yield; } - srslte::proc_outcome_t react(const s1setupresult& event); - void then(const srslte::proc_state_t& result) const; + srsran::proc_outcome_t init(); + srsran::proc_outcome_t step() { return srsran::proc_outcome_t::yield; } + srsran::proc_outcome_t react(const s1setupresult& event); + void then(const srsran::proc_state_t& result) const; const char* name() const { return "MME Connection"; } private: - srslte::proc_outcome_t start_mme_connection(); + srsran::proc_outcome_t start_mme_connection(); s1ap* s1ap_ptr = nullptr; }; ue* find_s1apmsg_user(uint32_t enb_id, uint32_t mme_id); std::string get_cause(const asn1::s1ap::cause_c& c); - void log_s1ap_msg(const asn1::s1ap::s1ap_pdu_c& msg, srslte::const_span sdu, bool is_rx); + void log_s1ap_msg(const asn1::s1ap::s1ap_pdu_c& msg, srsran::const_span sdu, bool is_rx); - srslte::proc_t s1setup_proc; + srsran::proc_t s1setup_proc; }; } // namespace srsenb diff --git a/srsenb/hdr/stack/upper/s1ap_metrics.h b/srsenb/hdr/stack/upper/s1ap_metrics.h index 7f679d50b..7966a0710 100644 --- a/srsenb/hdr/stack/upper/s1ap_metrics.h +++ b/srsenb/hdr/stack/upper/s1ap_metrics.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/srsenb/hdr/stack/upper/sdap.h b/srsenb/hdr/stack/upper/sdap.h index a7e600028..1da42de20 100644 --- a/srsenb/hdr/stack/upper/sdap.h +++ b/srsenb/hdr/stack/upper/sdap.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,10 +13,10 @@ #ifndef SRSENB_SDAP_H #define SRSENB_SDAP_H -#include "srslte/common/buffer_pool.h" -#include "srslte/common/common.h" -#include "srslte/interfaces/gnb_interfaces.h" -#include "srslte/interfaces/ue_gw_interfaces.h" +#include "srsran/common/buffer_pool.h" +#include "srsran/common/common.h" +#include "srsran/interfaces/gnb_interfaces.h" +#include "srsran/interfaces/ue_gw_interfaces.h" namespace srsenb { @@ -28,10 +28,10 @@ public: void stop(); // Interface for PDCP - void write_pdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t pdu) final; + void write_pdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t pdu) final; // Interface for GTPU - void write_sdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t pdu) final; + void write_sdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t pdu) final; private: gtpu_interface_sdap_nr* m_gtpu = nullptr; diff --git a/srsenb/src/CMakeLists.txt b/srsenb/src/CMakeLists.txt index 137204a21..ebd6f19ea 100644 --- a/srsenb/src/CMakeLists.txt +++ b/srsenb/src/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -26,13 +26,13 @@ target_link_libraries(enb_cfg_parser ${LIBCONFIGPP_LIBRARIES}) add_executable(srsenb main.cc enb.cc metrics_stdout.cc metrics_csv.cc metrics_json.cc) set(SRSENB_SOURCES srsenb_phy srsenb_stack srsenb_upper srsenb_mac srsenb_rrc srslog system) -set(SRSLTE_SOURCES srslte_common srslte_mac srslte_phy srslte_upper srslte_radio rrc_asn1 s1ap_asn1 enb_cfg_parser srslog system) +set(SRSRAN_SOURCES srsran_common srsran_mac srsran_phy srsran_upper srsran_radio rrc_asn1 s1ap_asn1 enb_cfg_parser srslog system) set(SRSENB_SOURCES ${SRSENB_SOURCES} srsgnb_phy srsgnb_stack srsgnb_upper srsgnb_mac srsgnb_rrc) -set(SRSLTE_SOURCES ${SRSLTE_SOURCES} rrc_nr_asn1 ngap_nr_asn1) +set(SRSRAN_SOURCES ${SRSRAN_SOURCES} rrc_nr_asn1 ngap_nr_asn1) target_link_libraries(srsenb ${SRSENB_SOURCES} - ${SRSLTE_SOURCES} + ${SRSRAN_SOURCES} ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} ${SEC_LIBRARIES} diff --git a/srsenb/src/enb.cc b/srsenb/src/enb.cc index 1b47f6917..b16cac867 100644 --- a/srsenb/src/enb.cc +++ b/srsenb/src/enb.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -15,9 +15,9 @@ #include "srsenb/hdr/stack/enb_stack_lte.h" #include "srsenb/hdr/stack/gnb_stack_nr.h" #include "srsenb/src/enb_cfg_parser.h" -#include "srslte/build_info.h" -#include "srslte/common/enb_events.h" -#include "srslte/radio/radio_null.h" +#include "srsran/build_info.h" +#include "srsran/common/enb_events.h" +#include "srsran/radio/radio_null.h" #include namespace srsenb { @@ -36,7 +36,7 @@ enb::~enb() int enb::init(const all_args_t& args_) { - int ret = SRSLTE_SUCCESS; + int ret = SRSRAN_SUCCESS; // Init eNB log enb_log.set_level(srslog::basic_levels::info); @@ -44,51 +44,51 @@ int enb::init(const all_args_t& args_) // Validate arguments if (parse_args(args_, rrc_cfg)) { - srslte::console("Error processing arguments.\n"); - return SRSLTE_ERROR; + srsran::console("Error processing arguments.\n"); + return SRSRAN_ERROR; } - srslte::byte_buffer_pool::get_instance()->enable_logger(true); + srsran::byte_buffer_pool::get_instance()->enable_logger(true); // Create layers if (args.stack.type == "lte") { std::unique_ptr lte_stack(new enb_stack_lte(log_sink)); if (!lte_stack) { - srslte::console("Error creating eNB stack.\n"); - return SRSLTE_ERROR; + srsran::console("Error creating eNB stack.\n"); + return SRSRAN_ERROR; } - std::unique_ptr lte_radio = std::unique_ptr(new srslte::radio); + std::unique_ptr lte_radio = std::unique_ptr(new srsran::radio); if (!lte_radio) { - srslte::console("Error creating radio multi instance.\n"); - return SRSLTE_ERROR; + srsran::console("Error creating radio multi instance.\n"); + return SRSRAN_ERROR; } std::unique_ptr lte_phy = std::unique_ptr(new srsenb::phy(log_sink)); if (!lte_phy) { - srslte::console("Error creating LTE PHY instance.\n"); - return SRSLTE_ERROR; + srsran::console("Error creating LTE PHY instance.\n"); + return SRSRAN_ERROR; } // Init Radio if (lte_radio->init(args.rf, lte_phy.get())) { - srslte::console("Error initializing radio.\n"); - return SRSLTE_ERROR; + srsran::console("Error initializing radio.\n"); + return SRSRAN_ERROR; } // Only Init PHY if radio couldn't be initialized - if (ret == SRSLTE_SUCCESS) { + if (ret == SRSRAN_SUCCESS) { if (lte_phy->init(args.phy, phy_cfg, lte_radio.get(), lte_stack.get())) { - srslte::console("Error initializing PHY.\n"); - ret = SRSLTE_ERROR; + srsran::console("Error initializing PHY.\n"); + ret = SRSRAN_ERROR; } } // Only init Stack if both radio and PHY could be initialized - if (ret == SRSLTE_SUCCESS) { - if (lte_stack->init(args.stack, rrc_cfg, lte_phy.get()) != SRSLTE_SUCCESS) { - srslte::console("Error initializing stack.\n"); - ret = SRSLTE_ERROR; + if (ret == SRSRAN_SUCCESS) { + if (lte_stack->init(args.stack, rrc_cfg, lte_phy.get()) != SRSRAN_SUCCESS) { + srsran::console("Error initializing stack.\n"); + ret = SRSRAN_ERROR; } } @@ -98,13 +98,13 @@ int enb::init(const all_args_t& args_) } else if (args.stack.type == "nr") { std::unique_ptr nr_stack(new srsenb::gnb_stack_nr); - std::unique_ptr nr_radio(new srslte::radio_null); + std::unique_ptr nr_radio(new srsran::radio_null); std::unique_ptr nr_phy(new srsenb::vnf_phy_nr); // Init layers if (nr_radio->init(args.rf, nullptr)) { - srslte::console("Error initializing radio.\n"); - return SRSLTE_ERROR; + srsran::console("Error initializing radio.\n"); + return SRSRAN_ERROR; } // TODO: where do we put this? @@ -114,8 +114,8 @@ int enb::init(const all_args_t& args_) args.phy.vnf_args.log_level = args.phy.log.phy_level; args.phy.vnf_args.log_hex_limit = args.phy.log.phy_hex_limit; if (nr_phy->init(args.phy, nr_phy_cfg, nr_stack.get())) { - srslte::console("Error initializing PHY.\n"); - return SRSLTE_ERROR; + srsran::console("Error initializing PHY.\n"); + return SRSRAN_ERROR; } // Same here, where do we put this? @@ -123,8 +123,8 @@ int enb::init(const all_args_t& args_) rrc_nr_cfg.coreless = args.stack.coreless; if (nr_stack->init(args.stack, rrc_nr_cfg, nr_phy.get())) { - srslte::console("Error initializing stack.\n"); - return SRSLTE_ERROR; + srsran::console("Error initializing stack.\n"); + return SRSRAN_ERROR; } stack = std::move(nr_stack); @@ -139,9 +139,9 @@ int enb::init(const all_args_t& args_) event_logger::get().log_sector_start(i, rrc_cfg.cell_list[i].pci, rrc_cfg.cell_list[i].cell_id); } - if (ret == SRSLTE_SUCCESS) { - srslte::console("\n==== eNodeB started ===\n"); - srslte::console("Type to view trace\n"); + if (ret == SRSRAN_SUCCESS) { + srsran::console("\n==== eNodeB started ===\n"); + srsran::console("Type to view trace\n"); } else { // if any of the layers failed to start, make sure the rest is stopped in a controlled manner stop(); @@ -189,7 +189,7 @@ void enb::start_plot() void enb::print_pool() { - srslte::byte_buffer_pool::get_instance()->print_all_buffers(); + srsran::byte_buffer_pool::get_instance()->print_all_buffers(); } bool enb::get_metrics(enb_metrics_t* m) @@ -209,15 +209,15 @@ void enb::cmd_cell_gain(uint32_t cell_id, float gain) std::string enb::get_build_mode() { - return std::string(srslte_get_build_mode()); + return std::string(srsran_get_build_mode()); } std::string enb::get_build_info() { - if (std::string(srslte_get_build_info()).find(" ") != std::string::npos) { - return std::string(srslte_get_version()); + if (std::string(srsran_get_build_info()).find(" ") != std::string::npos) { + return std::string(srsran_get_version()); } - return std::string(srslte_get_build_info()); + return std::string(srsran_get_build_info()); } std::string enb::get_build_string() diff --git a/srsenb/src/enb_cfg_parser.cc b/srsenb/src/enb_cfg_parser.cc index b3c84198f..a704c3a93 100644 --- a/srsenb/src/enb_cfg_parser.cc +++ b/srsenb/src/enb_cfg_parser.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -12,9 +12,9 @@ #include "enb_cfg_parser.h" #include "srsenb/hdr/enb.h" -#include "srslte/asn1/rrc_utils.h" -#include "srslte/common/multiqueue.h" -#include "srslte/phy/common/phy_common.h" +#include "srsran/asn1/rrc_utils.h" +#include "srsran/common/multiqueue.h" +#include "srsran/phy/common/phy_common.h" #include #define HANDLEPARSERCODE(cond) \ @@ -549,19 +549,19 @@ int parse_rr(all_args_t* args_, rrc_cfg_t* rrc_cfg_) /* Transmission mode config section */ if (args_->enb.transmission_mode < 1 || args_->enb.transmission_mode > 4) { ERROR("Invalid transmission mode (%d). Only indexes 1-4 are implemented.", args_->enb.transmission_mode); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (args_->enb.transmission_mode == 1 && args_->enb.nof_ports > 1) { ERROR("Invalid number of ports (%d) for transmission mode (%d). Only one antenna port is allowed.", args_->enb.nof_ports, args_->enb.transmission_mode); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (args_->enb.transmission_mode > 1 && args_->enb.nof_ports != 2) { ERROR("The selected number of ports (%d) are insufficient for the selected transmission mode (%d).", args_->enb.nof_ports, args_->enb.transmission_mode); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } rrc_cfg_->antenna_info.tx_mode = (ant_info_ded_s::tx_mode_e_::options)(args_->enb.transmission_mode - 1); @@ -589,13 +589,13 @@ int parse_rr(all_args_t* args_, rrc_cfg_t* rrc_cfg_) break; default: ERROR("Unsupported transmission mode %d", rrc_cfg_->antenna_info.tx_mode.to_number()); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } /* Parse power allocation */ if (not asn1::number_to_enum(rrc_cfg_->pdsch_cfg, args_->enb.p_a)) { ERROR("Invalid p_a value (%f) only -6, -4.77, -3, -1.77, 0, 1, 2, 3 values allowed.", args_->enb.p_a); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } /* MAC config section */ @@ -668,7 +668,7 @@ static int parse_meas_cell_list(rrc_meas_cfg_t* meas_cfg, Setting& root) meas_cfg->meas_cells.resize(root.getLength()); for (uint32_t i = 0; i < meas_cfg->meas_cells.size(); ++i) { meas_cfg->meas_cells[i].earfcn = root[i]["dl_earfcn"]; - meas_cfg->meas_cells[i].pci = (unsigned int)root[i]["pci"] % SRSLTE_NUM_PCI; + meas_cfg->meas_cells[i].pci = (unsigned int)root[i]["pci"] % SRSRAN_NUM_PCI; meas_cfg->meas_cells[i].eci = (unsigned int)root[i]["eci"]; meas_cfg->meas_cells[i].q_offset = 0; // LIBLTE_RRC_Q_OFFSET_RANGE_DB_0; // TODO // // TODO: TEMP @@ -705,7 +705,7 @@ static int parse_meas_report_desc(rrc_meas_cfg_t* meas_cfg, Setting& root) HANDLEPARSERCODE( asn1_parsers::opt_number_to_enum(quant.filt_coef_rsrq, quant.filt_coef_rsrq_present, root, "rsrq_config")); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } static int parse_scell_list(cell_cfg_t& cell_cfg, Setting& cellroot) @@ -722,7 +722,7 @@ static int parse_scell_list(cell_cfg_t& cell_cfg, Setting& cellroot) scell.ul_allowed = (bool)scellroot["ul_allowed"]; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } static int parse_cell_list(all_args_t* args, rrc_cfg_t* rrc_cfg, Setting& root) @@ -735,7 +735,7 @@ static int parse_cell_list(all_args_t* args, rrc_cfg_t* rrc_cfg, Setting& root) HANDLEPARSERCODE(parse_required_field(cell_cfg.cell_id, cellroot, "cell_id")); HANDLEPARSERCODE(parse_required_field(cell_cfg.tac, cellroot, "tac")); HANDLEPARSERCODE(parse_required_field(cell_cfg.pci, cellroot, "pci")); - cell_cfg.pci = cell_cfg.pci % SRSLTE_NUM_PCI; + cell_cfg.pci = cell_cfg.pci % SRSRAN_NUM_PCI; HANDLEPARSERCODE(parse_required_field(cell_cfg.dl_earfcn, cellroot, "dl_earfcn")); parse_default_field(cell_cfg.ul_earfcn, cellroot, "ul_earfcn", 0u); // will be derived from DL EARFCN If not set parse_default_field( @@ -782,7 +782,7 @@ static int parse_cell_list(all_args_t* args, rrc_cfg_t* rrc_cfg, Setting& root) } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int cell_list_section::parse(libconfig::Setting& root) @@ -795,10 +795,10 @@ int cell_list_section::parse(libconfig::Setting& root) namespace enb_conf_sections { -int parse_cell_cfg(all_args_t* args_, srslte_cell_t* cell) +int parse_cell_cfg(all_args_t* args_, srsran_cell_t* cell) { - cell->frame_type = SRSLTE_FDD; - cell->cp = SRSLTE_CP_NORM; + cell->frame_type = SRSRAN_FDD; + cell->cp = SRSRAN_CP_NORM; cell->nof_ports = args_->enb.nof_ports; cell->nof_prb = args_->enb.n_prb; // PCI not configured yet @@ -811,88 +811,88 @@ int parse_cell_cfg(all_args_t* args_, srslte_cell_t* cell) phich_cnfg.add_field(make_asn1_enum_number_str_parser("resources", &phichcfg.phich_res)); parser::parse_section(args_->enb_files.rr_config, &phy_cnfg); - cell->phich_length = (srslte_phich_length_t)(int)phichcfg.phich_dur; - cell->phich_resources = (srslte_phich_r_t)(int)phichcfg.phich_res; + cell->phich_length = (srsran_phich_length_t)(int)phichcfg.phich_dur; + cell->phich_resources = (srsran_phich_r_t)(int)phichcfg.phich_res; - if (!srslte_cell_isvalid(cell)) { + if (!srsran_cell_isvalid(cell)) { fprintf(stderr, "Invalid cell parameters: nof_prb=%d, nof_ports=%d, cell_id=%d\n", cell->nof_prb, cell->nof_ports, cell->id); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int parse_cfg_files(all_args_t* args_, rrc_cfg_t* rrc_cfg_, phy_cfg_t* phy_cfg_) { // Parse config files - srslte_cell_t cell_common_cfg = {}; + srsran_cell_t cell_common_cfg = {}; try { - if (enb_conf_sections::parse_cell_cfg(args_, &cell_common_cfg) != SRSLTE_SUCCESS) { + if (enb_conf_sections::parse_cell_cfg(args_, &cell_common_cfg) != SRSRAN_SUCCESS) { fprintf(stderr, "Error parsing Cell configuration\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } catch (const SettingTypeException& stex) { fprintf(stderr, "Error parsing Cell configuration: %s\n", stex.getPath()); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } catch (const ConfigException& cex) { fprintf(stderr, "Error parsing Cell configuration\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } try { - if (sib_sections::parse_sibs(args_, rrc_cfg_, phy_cfg_) != SRSLTE_SUCCESS) { + if (sib_sections::parse_sibs(args_, rrc_cfg_, phy_cfg_) != SRSRAN_SUCCESS) { fprintf(stderr, "Error parsing SIB configuration\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } catch (const SettingTypeException& stex) { fprintf(stderr, "Error parsing SIB configuration: %s\n", stex.getPath()); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } catch (const ConfigException& cex) { fprintf(stderr, "Error parsing SIB configurationn\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } try { - if (rr_sections::parse_rr(args_, rrc_cfg_) != SRSLTE_SUCCESS) { + if (rr_sections::parse_rr(args_, rrc_cfg_) != SRSRAN_SUCCESS) { fprintf(stderr, "Error parsing Radio Resources configuration\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } catch (const SettingTypeException& stex) { fprintf(stderr, "Error parsing Radio Resources configuration: %s\n", stex.getPath()); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } catch (const ConfigException& cex) { fprintf(stderr, "Error parsing Radio Resources configuration\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } try { - if (drb_sections::parse_drb(args_, rrc_cfg_) != SRSLTE_SUCCESS) { + if (drb_sections::parse_drb(args_, rrc_cfg_) != SRSRAN_SUCCESS) { fprintf(stderr, "Error parsing DRB configuration\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } catch (const SettingTypeException& stex) { fprintf(stderr, "Error parsing DRB configuration: %s\n", stex.getPath()); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } catch (const ConfigException& cex) { fprintf(stderr, "Error parsing DRB configuration\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Set fields derived from others, and check for correctness of the parsed configuration return enb_conf_sections::set_derived_args(args_, rrc_cfg_, phy_cfg_, cell_common_cfg); } -int set_derived_args(all_args_t* args_, rrc_cfg_t* rrc_cfg_, phy_cfg_t* phy_cfg_, const srslte_cell_t& cell_cfg_) +int set_derived_args(all_args_t* args_, rrc_cfg_t* rrc_cfg_, phy_cfg_t* phy_cfg_, const srsran_cell_t& cell_cfg_) { // Sanity check if (rrc_cfg_->cell_list.empty()) { ERROR("No cell specified in RR config."); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Check for a forced DL EARFCN or frequency (only valid for a single cell config (Xico's favorite feature)) @@ -940,16 +940,16 @@ int set_derived_args(all_args_t* args_, rrc_cfg_t* rrc_cfg_, phy_cfg_t* phy_cfg_ if (cfg.dl_freq_hz > 0) { phy_cell_cfg.dl_freq_hz = cfg.dl_freq_hz; } else { - phy_cell_cfg.dl_freq_hz = 1e6 * srslte_band_fd(cfg.dl_earfcn); + phy_cell_cfg.dl_freq_hz = 1e6 * srsran_band_fd(cfg.dl_earfcn); } if (cfg.ul_freq_hz > 0) { phy_cell_cfg.ul_freq_hz = cfg.ul_freq_hz; } else { if (cfg.ul_earfcn == 0) { - cfg.ul_earfcn = srslte_band_ul_earfcn(cfg.dl_earfcn); + cfg.ul_earfcn = srsran_band_ul_earfcn(cfg.dl_earfcn); } - phy_cell_cfg.ul_freq_hz = 1e6 * srslte_band_fu(cfg.ul_earfcn); + phy_cell_cfg.ul_freq_hz = 1e6 * srsran_band_fu(cfg.ul_earfcn); } for (auto scell_it = cfg.scell_list.begin(); scell_it != cfg.scell_list.end();) { @@ -961,7 +961,7 @@ int set_derived_args(all_args_t* args_, rrc_cfg_t* rrc_cfg_, phy_cfg_t* phy_cfg_ scell_it = cfg.scell_list.erase(scell_it); } else if (cell_it->cell_id == cfg.cell_id) { ERROR("A cell cannot have an scell with the same cell_id=0x%x", cfg.cell_id); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } else { scell_it++; } @@ -998,16 +998,16 @@ int set_derived_args(all_args_t* args_, rrc_cfg_t* rrc_cfg_, phy_cfg_t* phy_cfg_ if (cfg.dl_freq_hz > 0) { phy_cell_cfg.dl_freq_hz = cfg.dl_freq_hz; } else { - phy_cell_cfg.dl_freq_hz = 1e6 * srslte_band_fd(cfg.dl_earfcn); + phy_cell_cfg.dl_freq_hz = 1e6 * srsran_band_fd(cfg.dl_earfcn); } if (cfg.ul_freq_hz > 0) { phy_cell_cfg.ul_freq_hz = cfg.ul_freq_hz; } else { if (cfg.ul_earfcn == 0) { - cfg.ul_earfcn = srslte_band_ul_earfcn(cfg.dl_earfcn); + cfg.ul_earfcn = srsran_band_ul_earfcn(cfg.dl_earfcn); } - phy_cell_cfg.ul_freq_hz = 1e6 * srslte_band_fu(cfg.ul_earfcn); + phy_cell_cfg.ul_freq_hz = 1e6 * srsran_band_fu(cfg.ul_earfcn); } phy_cfg_->phy_cell_cfg_nr.push_back(phy_cell_cfg); @@ -1045,23 +1045,23 @@ int set_derived_args(all_args_t* args_, rrc_cfg_t* rrc_cfg_, phy_cfg_t* phy_cfg_ std::vector eea_pref_list; boost::split(eea_pref_list, args_->general.eea_pref_list, boost::is_any_of(",")); int i = 0; - for (auto it = eea_pref_list.begin(); it != eea_pref_list.end() && i < srslte::CIPHERING_ALGORITHM_ID_N_ITEMS; it++) { + for (auto it = eea_pref_list.begin(); it != eea_pref_list.end() && i < srsran::CIPHERING_ALGORITHM_ID_N_ITEMS; it++) { boost::trim_left(*it); if ((*it) == "EEA0") { - rrc_cfg_->eea_preference_list[i] = srslte::CIPHERING_ALGORITHM_ID_EEA0; + rrc_cfg_->eea_preference_list[i] = srsran::CIPHERING_ALGORITHM_ID_EEA0; i++; } else if ((*it) == "EEA1") { - rrc_cfg_->eea_preference_list[i] = srslte::CIPHERING_ALGORITHM_ID_128_EEA1; + rrc_cfg_->eea_preference_list[i] = srsran::CIPHERING_ALGORITHM_ID_128_EEA1; i++; } else if ((*it) == "EEA2") { - rrc_cfg_->eea_preference_list[i] = srslte::CIPHERING_ALGORITHM_ID_128_EEA2; + rrc_cfg_->eea_preference_list[i] = srsran::CIPHERING_ALGORITHM_ID_128_EEA2; i++; } else if ((*it) == "EEA3") { - rrc_cfg_->eea_preference_list[i] = srslte::CIPHERING_ALGORITHM_ID_128_EEA3; + rrc_cfg_->eea_preference_list[i] = srsran::CIPHERING_ALGORITHM_ID_128_EEA3; i++; } else { fprintf(stderr, "Failed to parse EEA prefence list %s \n", args_->general.eea_pref_list.c_str()); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } @@ -1069,23 +1069,23 @@ int set_derived_args(all_args_t* args_, rrc_cfg_t* rrc_cfg_, phy_cfg_t* phy_cfg_ std::vector eia_pref_list; boost::split(eia_pref_list, args_->general.eia_pref_list, boost::is_any_of(",")); i = 0; - for (auto it = eia_pref_list.begin(); it != eia_pref_list.end() && i < srslte::INTEGRITY_ALGORITHM_ID_N_ITEMS; it++) { + for (auto it = eia_pref_list.begin(); it != eia_pref_list.end() && i < srsran::INTEGRITY_ALGORITHM_ID_N_ITEMS; it++) { boost::trim_left(*it); if ((*it) == "EIA0") { - rrc_cfg_->eia_preference_list[i] = srslte::INTEGRITY_ALGORITHM_ID_EIA0; + rrc_cfg_->eia_preference_list[i] = srsran::INTEGRITY_ALGORITHM_ID_EIA0; i++; } else if ((*it) == "EIA1") { - rrc_cfg_->eia_preference_list[i] = srslte::INTEGRITY_ALGORITHM_ID_128_EIA1; + rrc_cfg_->eia_preference_list[i] = srsran::INTEGRITY_ALGORITHM_ID_128_EIA1; i++; } else if ((*it) == "EIA2") { - rrc_cfg_->eia_preference_list[i] = srslte::INTEGRITY_ALGORITHM_ID_128_EIA2; + rrc_cfg_->eia_preference_list[i] = srsran::INTEGRITY_ALGORITHM_ID_128_EIA2; i++; } else if ((*it) == "EIA3") { - rrc_cfg_->eia_preference_list[i] = srslte::INTEGRITY_ALGORITHM_ID_128_EIA3; + rrc_cfg_->eia_preference_list[i] = srsran::INTEGRITY_ALGORITHM_ID_128_EIA3; i++; } else { fprintf(stderr, "Failed to parse EIA prefence list %s \n", args_->general.eia_pref_list.c_str()); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } @@ -1103,7 +1103,7 @@ int set_derived_args(all_args_t* args_, rrc_cfg_t* rrc_cfg_, phy_cfg_t* phy_cfg_ " Consider changing \"prach_freq_offset\" in sib.conf to a value between %d and %d.\n", lower_bound, upper_bound); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } else { // 6 PRB case if (prach_freq_offset + 6 > args_->enb.n_prb) { @@ -1140,7 +1140,7 @@ int set_derived_args(all_args_t* args_, rrc_cfg_t* rrc_cfg_, phy_cfg_t* phy_cfg_ args_->stack.sync_queue_size = MULTIQUEUE_DEFAULT_CAPACITY; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } } // namespace enb_conf_sections @@ -1473,7 +1473,7 @@ int parse_sib9(std::string filename, sib_type9_s* data) if (!parser::parse_section(std::move(filename), &sib9)) { data->hnb_name_present = true; if (name_enabled) { - data->hnb_name.resize(SRSLTE_MIN((uint32_t)hnb_name.size(), 48)); + data->hnb_name.resize(SRSRAN_MIN((uint32_t)hnb_name.size(), 48)); memcpy(data->hnb_name.data(), hnb_name.c_str(), data->hnb_name.size()); } else if (hex_enabled) { if (hex_value.size() > 48) { @@ -1523,35 +1523,35 @@ int parse_sibs(all_args_t* args_, rrc_cfg_t* rrc_cfg_, srsenb::phy_cfg_t* phy_co sib_type13_r9_s* sib13 = &rrc_cfg_->sibs[12].set_sib13_v920(); sib_type1_s* sib1 = &rrc_cfg_->sib1; - if (sib_sections::parse_sib1(args_->enb_files.sib_config, sib1) != SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (sib_sections::parse_sib1(args_->enb_files.sib_config, sib1) != SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } // Fill rest of data from enb config std::string mnc_str; - if (not srslte::mnc_to_string(args_->stack.s1ap.mnc, &mnc_str)) { + if (not srsran::mnc_to_string(args_->stack.s1ap.mnc, &mnc_str)) { ERROR("The provided mnc=%d is not valid", args_->stack.s1ap.mnc); return -1; } std::string mcc_str; - if (not srslte::mcc_to_string(args_->stack.s1ap.mcc, &mcc_str)) { + if (not srsran::mcc_to_string(args_->stack.s1ap.mcc, &mcc_str)) { ERROR("The provided mnc=%d is not valid", args_->stack.s1ap.mcc); return -1; } sib_type1_s::cell_access_related_info_s_* cell_access = &sib1->cell_access_related_info; cell_access->plmn_id_list.resize(1); - srslte::plmn_id_t plmn; - if (plmn.from_string(mcc_str + mnc_str) == SRSLTE_ERROR) { + srsran::plmn_id_t plmn; + if (plmn.from_string(mcc_str + mnc_str) == SRSRAN_ERROR) { ERROR("Could not convert %s to a plmn_id", (mcc_str + mnc_str).c_str()); return -1; } - srslte::to_asn1(&cell_access->plmn_id_list[0].plmn_id, plmn); + srsran::to_asn1(&cell_access->plmn_id_list[0].plmn_id, plmn); cell_access->plmn_id_list[0].cell_reserved_for_oper = plmn_id_info_s::cell_reserved_for_oper_e_::not_reserved; sib1->cell_sel_info.q_rx_lev_min_offset = 0; // Generate SIB2 - if (sib_sections::parse_sib2(args_->enb_files.sib_config, sib2) != SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (sib_sections::parse_sib2(args_->enb_files.sib_config, sib2) != SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } // SRS not yet supported @@ -1575,35 +1575,35 @@ int parse_sibs(all_args_t* args_, rrc_cfg_t* rrc_cfg_, srsenb::phy_cfg_t* phy_co // Generate SIB3 if defined in mapping info if (sib_is_present(sib1->sched_info_list, sib_type_e::sib_type3)) { - if (sib_sections::parse_sib3(args_->enb_files.sib_config, sib3) != SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (sib_sections::parse_sib3(args_->enb_files.sib_config, sib3) != SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } } // Generate SIB4 if defined in mapping info if (sib_is_present(sib1->sched_info_list, sib_type_e::sib_type4)) { - if (sib_sections::parse_sib4(args_->enb_files.sib_config, sib4) != SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (sib_sections::parse_sib4(args_->enb_files.sib_config, sib4) != SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } } // Generate SIB7 if defined in mapping info if (sib_is_present(sib1->sched_info_list, sib_type_e::sib_type7)) { - if (sib_sections::parse_sib7(args_->enb_files.sib_config, sib7) != SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (sib_sections::parse_sib7(args_->enb_files.sib_config, sib7) != SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } } // Generate SIB9 if defined in mapping info if (sib_is_present(sib1->sched_info_list, sib_type_e::sib_type9)) { - if (sib_sections::parse_sib9(args_->enb_files.sib_config, sib9) != SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (sib_sections::parse_sib9(args_->enb_files.sib_config, sib9) != SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } } if (sib_is_present(sib1->sched_info_list, sib_type_e::sib_type13_v920)) { - if (sib_sections::parse_sib13(args_->enb_files.sib_config, sib13) != SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (sib_sections::parse_sib13(args_->enb_files.sib_config, sib13) != SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } } diff --git a/srsenb/src/enb_cfg_parser.h b/srsenb/src/enb_cfg_parser.h index 68df21431..70c724aa0 100644 --- a/srsenb/src/enb_cfg_parser.h +++ b/srsenb/src/enb_cfg_parser.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -22,7 +22,7 @@ #include #include "srsenb/hdr/stack/rrc/rrc.h" -#include "srslte/asn1/asn1_utils.h" +#include "srsran/asn1/asn1_utils.h" namespace srsenb { @@ -36,9 +36,9 @@ bool sib_is_present(const asn1::rrc::sched_info_list_l& l, asn1::rrc::sib_type_e // enb.conf parsing namespace enb_conf_sections { -int parse_cell_cfg(all_args_t* args_, srslte_cell_t* cell); +int parse_cell_cfg(all_args_t* args_, srsran_cell_t* cell); int parse_cfg_files(all_args_t* args_, rrc_cfg_t* rrc_cfg_, phy_cfg_t* phy_cfg_); -int set_derived_args(all_args_t* args_, rrc_cfg_t* rrc_cfg_, phy_cfg_t* phy_cfg_, const srslte_cell_t& cell_cfg_); +int set_derived_args(all_args_t* args_, rrc_cfg_t* rrc_cfg_, phy_cfg_t* phy_cfg_, const srsran_cell_t& cell_cfg_); } // namespace enb_conf_sections diff --git a/srsenb/src/main.cc b/srsenb/src/main.cc index 24ebf7414..4f699cbb2 100644 --- a/srsenb/src/main.cc +++ b/srsenb/src/main.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -16,25 +16,25 @@ #include #include -#include "srslte/common/common_helper.h" -#include "srslte/common/config_file.h" -#include "srslte/common/crash_handler.h" -#include "srslte/common/signal_handler.h" -#include "srslte/srslog/event_trace.h" -#include "srslte/srslog/srslog.h" +#include "srsran/common/common_helper.h" +#include "srsran/common/config_file.h" +#include "srsran/common/crash_handler.h" +#include "srsran/common/signal_handler.h" +#include "srsran/srslog/event_trace.h" +#include "srsran/srslog/srslog.h" #include #include #include #include -#include +#include #include #include "srsenb/hdr/enb.h" #include "srsenb/hdr/metrics_csv.h" #include "srsenb/hdr/metrics_json.h" #include "srsenb/hdr/metrics_stdout.h" -#include "srslte/common/enb_events.h" +#include "srsran/common/enb_events.h" using namespace std; using namespace srsenb; @@ -271,8 +271,8 @@ void parse_args(all_args_t* args, int argc, char* argv[]) // print version number and exit if (vm.count("version")) { - cout << "Version " << srslte_get_version_major() << "." << srslte_get_version_minor() << "." - << srslte_get_version_patch() << endl; + cout << "Version " << srsran_get_version_major() << "." << srsran_get_version_minor() << "." + << srsran_get_version_patch() << endl; exit(0); } @@ -301,10 +301,10 @@ void parse_args(all_args_t* args, int argc, char* argv[]) } // Convert MCC/MNC strings - if (!srslte::string_to_mcc(mcc, &args->stack.s1ap.mcc)) { + if (!srsran::string_to_mcc(mcc, &args->stack.s1ap.mcc)) { cout << "Error parsing enb.mcc:" << mcc << " - must be a 3-digit string." << endl; } - if (!srslte::string_to_mnc(mnc, &args->stack.s1ap.mnc)) { + if (!srsran::string_to_mnc(mnc, &args->stack.s1ap.mnc)) { cout << "Error parsing enb.mnc:" << mnc << " - must be a 2 or 3-digit string." << endl; } @@ -417,7 +417,7 @@ void parse_args(all_args_t* args, int argc, char* argv[]) exit(1); } - srslte_use_standard_symbol_size(use_standard_lte_rates); + srsran_use_standard_symbol_size(use_standard_lte_rates); } static bool do_metrics = false; @@ -436,7 +436,7 @@ static void* input_loop(metrics_stdout* metrics, srsenb::enb_command_interface* break; } else if (not input_line.empty()) { vector cmd; - srslte::string_parse_list(input_line, ' ', cmd); + srsran::string_parse_list(input_line, ' ', cmd); if (cmd[0] == "t") { do_metrics = !do_metrics; if (do_metrics) { @@ -454,8 +454,8 @@ static void* input_loop(metrics_stdout* metrics, srsenb::enb_command_interface* } // Parse command arguments - uint32_t cell_id = srslte::string_cast(cmd[1]); - float gain_db = srslte::string_cast(cmd[2]); + uint32_t cell_id = srsran::string_cast(cmd[1]); + float gain_db = srsran::string_cast(cmd[2]); // Set cell gain control->cmd_cell_gain(cell_id, gain_db); @@ -480,14 +480,14 @@ static size_t fixup_log_file_maxsize(int x) int main(int argc, char* argv[]) { - srslte_register_signal_handler(); + srsran_register_signal_handler(); all_args_t args = {}; - srslte::metrics_hub metricshub; + srsran::metrics_hub metricshub; metrics_stdout metrics_screen; cout << "--- Software Radio Systems LTE eNodeB ---" << endl << endl; - srslte_debug_handle_crash(argc, argv); + srsran_debug_handle_crash(argc, argv); parse_args(&args, argc, argv); // Setup the default log sink. @@ -504,7 +504,7 @@ int main(int argc, char* argv[]) #ifdef ENABLE_SRSLOG_EVENT_TRACE if (args.general.tracing_enable) { if (!srslog::event_trace_init(args.general.tracing_filename, args.general.tracing_buffcapacity)) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } #endif @@ -513,9 +513,9 @@ int main(int argc, char* argv[]) srslog::init(); srslog::fetch_basic_logger("COMMON").set_level(srslog::basic_levels::info); - srslte::log_args(argc, argv, "ENB"); + srsran::log_args(argc, argv, "ENB"); - srslte::check_scaling_governor(args.rf.device_name); + srsran::check_scaling_governor(args.rf.device_name); // Set up the JSON log channel used by metrics and events. srslog::sink& json_sink = @@ -530,9 +530,9 @@ int main(int argc, char* argv[]) // Create eNB unique_ptr enb{new srsenb::enb(srslog::get_default_sink())}; - if (enb->init(args) != SRSLTE_SUCCESS) { + if (enb->init(args) != SRSRAN_SUCCESS) { enb->stop(); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Set metrics @@ -576,5 +576,5 @@ int main(int argc, char* argv[]) enb->stop(); cout << "--- exiting ---" << endl; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } diff --git a/srsenb/src/metrics_csv.cc b/srsenb/src/metrics_csv.cc index e8427aa46..f2a0b7ca1 100644 --- a/srsenb/src/metrics_csv.cc +++ b/srsenb/src/metrics_csv.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,7 +11,7 @@ */ #include "srsenb/hdr/metrics_csv.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/utils/vector.h" #include #include @@ -74,20 +74,20 @@ void metrics_csv::set_metrics(const enb_metrics_t& metrics, const uint32_t perio // DL rate if (dl_rate_sum > 0) { - file << float_to_string(SRSLTE_MAX(0.1, (float)dl_rate_sum), 2); + file << float_to_string(SRSRAN_MAX(0.1, (float)dl_rate_sum), 2); } else { file << float_to_string(0, 2); } // UL rate if (ul_rate_sum > 0) { - file << float_to_string(SRSLTE_MAX(0.1, (float)ul_rate_sum), 2); + file << float_to_string(SRSRAN_MAX(0.1, (float)ul_rate_sum), 2); } else { file << float_to_string(0, 2); } // Write system metrics. - const srslte::sys_metrics_t& m = metrics.sys; + const srsran::sys_metrics_t& m = metrics.sys; file << float_to_string(m.process_realmem, 2); file << std::to_string(m.process_realmem_kB) << ";"; file << float_to_string(m.process_virtualmem, 2); diff --git a/srsenb/src/metrics_json.cc b/srsenb/src/metrics_json.cc index 10ed726fd..eb97a7f4f 100644 --- a/srsenb/src/metrics_json.cc +++ b/srsenb/src/metrics_json.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,7 +11,7 @@ */ #include "srsenb/hdr/metrics_json.h" -#include "srslte/srslog/context.h" +#include "srsran/srslog/context.h" using namespace srsenb; @@ -125,7 +125,7 @@ static void fill_ue_metrics(mset_ue_container& ue, const enb_metrics_t& m, unsig bearer_container.write(drb.first); bearer_container.write(drb.second); // RLC bearer metrics. - if (drb.first >= SRSLTE_N_RADIO_BEARERS) { + if (drb.first >= SRSRAN_N_RADIO_BEARERS) { continue; } const auto& rlc_bearer = m.stack.rlc.ues[i].bearer; diff --git a/srsenb/src/metrics_stdout.cc b/srsenb/src/metrics_stdout.cc index cf44bde1b..2291a79fe 100644 --- a/srsenb/src/metrics_stdout.cc +++ b/srsenb/src/metrics_stdout.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,7 +11,7 @@ */ #include "srsenb/hdr/metrics_stdout.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/utils/vector.h" #include #include @@ -101,16 +101,16 @@ void metrics_stdout::set_metrics(const enb_metrics_t& metrics, const uint32_t pe } cout << int_to_hex_string(metrics.stack.mac.ues[i].rnti, 4) << " "; - cout << float_to_string(SRSLTE_MAX(0.1, metrics.stack.mac.ues[i].dl_cqi), 1, 3); + cout << float_to_string(SRSRAN_MAX(0.1, metrics.stack.mac.ues[i].dl_cqi), 1, 3); cout << float_to_string(metrics.stack.mac.ues[i].dl_ri, 1, 4); if (not isnan(metrics.phy[i].dl.mcs)) { - cout << float_to_string(SRSLTE_MAX(0.1, metrics.phy[i].dl.mcs), 1, 4); + cout << float_to_string(SRSRAN_MAX(0.1, metrics.phy[i].dl.mcs), 1, 4); } else { cout << float_to_string(0, 2, 4); } if (metrics.stack.mac.ues[i].tx_brate > 0) { cout << float_to_eng_string( - SRSLTE_MAX(0.1, (float)metrics.stack.mac.ues[i].tx_brate / (metrics.stack.mac.ues[i].nof_tti * 1e-3)), 1); + SRSRAN_MAX(0.1, (float)metrics.stack.mac.ues[i].tx_brate / (metrics.stack.mac.ues[i].nof_tti * 1e-3)), 1); } else { cout << float_to_string(0, 1, 6) << ""; } @@ -118,7 +118,7 @@ void metrics_stdout::set_metrics(const enb_metrics_t& metrics, const uint32_t pe cout << std::setw(5) << metrics.stack.mac.ues[i].tx_errors; if (metrics.stack.mac.ues[i].tx_pkts > 0 && metrics.stack.mac.ues[i].tx_errors) { cout << float_to_string( - SRSLTE_MAX(0.1, (float)100 * metrics.stack.mac.ues[i].tx_errors / metrics.stack.mac.ues[i].tx_pkts), 1, 4) + SRSRAN_MAX(0.1, (float)100 * metrics.stack.mac.ues[i].tx_errors / metrics.stack.mac.ues[i].tx_pkts), 1, 4) << "%"; } else { cout << float_to_string(0, 1, 4) << "%"; @@ -126,13 +126,13 @@ void metrics_stdout::set_metrics(const enb_metrics_t& metrics, const uint32_t pe cout << " "; if (not isnan(metrics.phy[i].ul.pusch_sinr)) { - cout << float_to_string(SRSLTE_MAX(0.1, metrics.phy[i].ul.pusch_sinr), 2, 5); + cout << float_to_string(SRSRAN_MAX(0.1, metrics.phy[i].ul.pusch_sinr), 2, 5); } else { cout << float_to_string(0, 2, 5); } if (not isnan(metrics.phy[i].ul.pucch_sinr)) { - cout << float_to_string(SRSLTE_MAX(0.1, metrics.phy[i].ul.pucch_sinr), 2, 5); + cout << float_to_string(SRSRAN_MAX(0.1, metrics.phy[i].ul.pucch_sinr), 2, 5); } else { cout << float_to_string(0, 2, 5); } @@ -140,13 +140,13 @@ void metrics_stdout::set_metrics(const enb_metrics_t& metrics, const uint32_t pe cout << float_to_string(metrics.stack.mac.ues[i].phr, 2, 5); if (not isnan(metrics.phy[i].ul.mcs)) { - cout << float_to_string(SRSLTE_MAX(0.1, metrics.phy[i].ul.mcs), 1, 4); + cout << float_to_string(SRSRAN_MAX(0.1, metrics.phy[i].ul.mcs), 1, 4); } else { cout << float_to_string(0, 1, 4); } if (metrics.stack.mac.ues[i].rx_brate > 0) { cout << float_to_eng_string( - SRSLTE_MAX(0.1, (float)metrics.stack.mac.ues[i].rx_brate / (metrics.stack.mac.ues[i].nof_tti * 1e-3)), 1); + SRSRAN_MAX(0.1, (float)metrics.stack.mac.ues[i].rx_brate / (metrics.stack.mac.ues[i].nof_tti * 1e-3)), 1); } else { cout << float_to_string(0, 1) << ""; } @@ -155,7 +155,7 @@ void metrics_stdout::set_metrics(const enb_metrics_t& metrics, const uint32_t pe if (metrics.stack.mac.ues[i].rx_pkts > 0 && metrics.stack.mac.ues[i].rx_errors > 0) { cout << float_to_string( - SRSLTE_MAX(0.1, (float)100 * metrics.stack.mac.ues[i].rx_errors / metrics.stack.mac.ues[i].rx_pkts), 1, 4) + SRSRAN_MAX(0.1, (float)100 * metrics.stack.mac.ues[i].rx_errors / metrics.stack.mac.ues[i].rx_pkts), 1, 4) << "%"; } else { cout << float_to_string(0, 1, 4) << "%"; diff --git a/srsenb/src/parser.cc b/srsenb/src/parser.cc index 7062b7885..ab593c564 100644 --- a/srsenb/src/parser.cc +++ b/srsenb/src/parser.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/srsenb/src/phy/CMakeLists.txt b/srsenb/src/phy/CMakeLists.txt index d3cce72dc..8371549b2 100644 --- a/srsenb/src/phy/CMakeLists.txt +++ b/srsenb/src/phy/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of diff --git a/srsenb/src/phy/lte/cc_worker.cc b/srsenb/src/phy/lte/cc_worker.cc index 99f80f107..9341eb34f 100644 --- a/srsenb/src/phy/lte/cc_worker.cc +++ b/srsenb/src/phy/lte/cc_worker.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,22 +10,22 @@ * */ -#include "srslte/common/threads.h" -#include "srslte/srslte.h" +#include "srsran/common/threads.h" +#include "srsran/srsran.h" #include "srsenb/hdr/phy/lte/cc_worker.h" #define Error(fmt, ...) \ - if (SRSLTE_DEBUG_ENABLED) \ + if (SRSRAN_DEBUG_ENABLED) \ logger.error(fmt, ##__VA_ARGS__) #define Warning(fmt, ...) \ - if (SRSLTE_DEBUG_ENABLED) \ + if (SRSRAN_DEBUG_ENABLED) \ logger.warning(fmt, ##__VA_ARGS__) #define Info(fmt, ...) \ - if (SRSLTE_DEBUG_ENABLED) \ + if (SRSRAN_DEBUG_ENABLED) \ logger.info(fmt, ##__VA_ARGS__) #define Debug(fmt, ...) \ - if (SRSLTE_DEBUG_ENABLED) \ + if (SRSRAN_DEBUG_ENABLED) \ logger.debug(fmt, ##__VA_ARGS__) using namespace std; @@ -52,11 +52,11 @@ cc_worker::cc_worker(srslog::basic_logger& logger) : logger(logger) cc_worker::~cc_worker() { - srslte_softbuffer_tx_free(&temp_mbsfn_softbuffer); - srslte_enb_dl_free(&enb_dl); - srslte_enb_ul_free(&enb_ul); + srsran_softbuffer_tx_free(&temp_mbsfn_softbuffer); + srsran_enb_dl_free(&enb_dl); + srsran_enb_ul_free(&enb_ul); - for (int p = 0; p < SRSLTE_MAX_PORTS; p++) { + for (int p = 0; p < SRSRAN_MAX_PORTS; p++) { if (signal_buffer_rx[p]) { free(signal_buffer_rx[p]); } @@ -79,60 +79,60 @@ void cc_worker::init(phy_common* phy_, uint32_t cc_idx_) { phy = phy_; cc_idx = cc_idx_; - srslte_cell_t cell = phy_->get_cell(cc_idx); + srsran_cell_t cell = phy_->get_cell(cc_idx); uint32_t nof_prb = phy_->get_nof_prb(cc_idx); - uint32_t sf_len = SRSLTE_SF_LEN_PRB(nof_prb); + uint32_t sf_len = SRSRAN_SF_LEN_PRB(nof_prb); // Init cell here for (uint32_t p = 0; p < phy->get_nof_ports(cc_idx); p++) { - signal_buffer_rx[p] = srslte_vec_cf_malloc(2 * sf_len); + signal_buffer_rx[p] = srsran_vec_cf_malloc(2 * sf_len); if (!signal_buffer_rx[p]) { ERROR("Error allocating memory"); return; } - srslte_vec_cf_zero(signal_buffer_rx[p], 2 * sf_len); - signal_buffer_tx[p] = srslte_vec_cf_malloc(2 * sf_len); + srsran_vec_cf_zero(signal_buffer_rx[p], 2 * sf_len); + signal_buffer_tx[p] = srsran_vec_cf_malloc(2 * sf_len); if (!signal_buffer_tx[p]) { ERROR("Error allocating memory"); return; } - srslte_vec_cf_zero(signal_buffer_tx[p], 2 * sf_len); + srsran_vec_cf_zero(signal_buffer_tx[p], 2 * sf_len); } - if (srslte_enb_dl_init(&enb_dl, signal_buffer_tx, nof_prb)) { + if (srsran_enb_dl_init(&enb_dl, signal_buffer_tx, nof_prb)) { ERROR("Error initiating ENB DL (cc=%d)", cc_idx); return; } - if (srslte_enb_dl_set_cell(&enb_dl, cell)) { + if (srsran_enb_dl_set_cell(&enb_dl, cell)) { ERROR("Error initiating ENB DL (cc=%d)", cc_idx); return; } - if (srslte_enb_ul_init(&enb_ul, signal_buffer_rx[0], nof_prb)) { + if (srsran_enb_ul_init(&enb_ul, signal_buffer_rx[0], nof_prb)) { ERROR("Error initiating ENB UL"); return; } - if (srslte_enb_ul_set_cell(&enb_ul, cell, &phy->dmrs_pusch_cfg, nullptr)) { + if (srsran_enb_ul_set_cell(&enb_ul, cell, &phy->dmrs_pusch_cfg, nullptr)) { ERROR("Error initiating ENB UL"); return; } /* Setup SI-RNTI in PHY */ - add_rnti(SRSLTE_SIRNTI); + add_rnti(SRSRAN_SIRNTI); /* Setup P-RNTI in PHY */ - add_rnti(SRSLTE_PRNTI); + add_rnti(SRSRAN_PRNTI); /* Setup RA-RNTI in PHY */ - for (int i = SRSLTE_RARNTI_START; i <= SRSLTE_RARNTI_END; i++) { + for (int i = SRSRAN_RARNTI_START; i <= SRSRAN_RARNTI_END; i++) { add_rnti(i); } - if (srslte_softbuffer_tx_init(&temp_mbsfn_softbuffer, nof_prb)) { + if (srsran_softbuffer_tx_init(&temp_mbsfn_softbuffer, nof_prb)) { ERROR("Error initiating soft buffer"); exit(-1); } - srslte_softbuffer_tx_reset(&temp_mbsfn_softbuffer); + srsran_softbuffer_tx_reset(&temp_mbsfn_softbuffer); Info("Component Carrier Worker %d configured cell %d PRB", cc_idx, nof_prb); @@ -178,7 +178,7 @@ int cc_worker::add_rnti(uint16_t rnti) if (ue_db.count(rnti) == 0) { ue_db[rnti] = new ue(rnti); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } void cc_worker::rem_rnti(uint16_t rnti) @@ -198,14 +198,14 @@ uint32_t cc_worker::get_nof_rnti() return ue_db.size(); } -void cc_worker::work_ul(const srslte_ul_sf_cfg_t& ul_sf_cfg, stack_interface_phy_lte::ul_sched_t& ul_grants) +void cc_worker::work_ul(const srsran_ul_sf_cfg_t& ul_sf_cfg, stack_interface_phy_lte::ul_sched_t& ul_grants) { std::lock_guard lock(mutex); ul_sf = ul_sf_cfg; logger.set_context(ul_sf.tti); // Process UL signal - srslte_enb_ul_fft(&enb_ul); + srsran_enb_ul_fft(&enb_ul); // Decode pending UL grants for the tti they were scheduled decode_pusch(ul_grants.pusch, ul_grants.nof_grants); @@ -214,19 +214,19 @@ void cc_worker::work_ul(const srslte_ul_sf_cfg_t& ul_sf_cfg, stack_interface_phy decode_pucch(); } -void cc_worker::work_dl(const srslte_dl_sf_cfg_t& dl_sf_cfg, +void cc_worker::work_dl(const srsran_dl_sf_cfg_t& dl_sf_cfg, stack_interface_phy_lte::dl_sched_t& dl_grants, stack_interface_phy_lte::ul_sched_t& ul_grants, - srslte_mbsfn_cfg_t* mbsfn_cfg) + srsran_mbsfn_cfg_t* mbsfn_cfg) { std::lock_guard lock(mutex); dl_sf = dl_sf_cfg; // Put base signals (references, PBCH, PCFICH and PSS/SSS) into the resource grid - srslte_enb_dl_put_base(&enb_dl, &dl_sf); + srsran_enb_dl_put_base(&enb_dl, &dl_sf); // Put DL grants to resource grid. PDSCH data will be encoded as well. - if (dl_sf_cfg.sf_type == SRSLTE_SF_NORM) { + if (dl_sf_cfg.sf_type == SRSRAN_SF_NORM) { encode_pdcch_dl(dl_grants.pdsch, dl_grants.nof_grants); encode_pdsch(dl_grants.pdsch, dl_grants.nof_grants); } else { @@ -242,22 +242,22 @@ void cc_worker::work_dl(const srslte_dl_sf_cfg_t& dl_sf_cfg, encode_phich(ul_grants.phich, ul_grants.nof_phich); // Generate signal and transmit - srslte_enb_dl_gen_signal(&enb_dl); + srsran_enb_dl_gen_signal(&enb_dl); // Scale if cell gain is set float cell_gain_db = phy->get_cell_gain(cc_idx); if (std::isnormal(cell_gain_db)) { - float scale = srslte_convert_dB_to_amplitude(cell_gain_db); - uint32_t sf_len = SRSLTE_SF_LEN_PRB(enb_dl.cell.nof_prb); + float scale = srsran_convert_dB_to_amplitude(cell_gain_db); + uint32_t sf_len = SRSRAN_SF_LEN_PRB(enb_dl.cell.nof_prb); for (uint32_t i = 0; i < enb_dl.cell.nof_ports; i++) { - srslte_vec_sc_prod_cfc(signal_buffer_tx[i], scale, signal_buffer_tx[i], sf_len); + srsran_vec_sc_prod_cfc(signal_buffer_tx[i], scale, signal_buffer_tx[i], sf_len); } } } void cc_worker::decode_pusch_rnti(stack_interface_phy_lte::ul_sched_grant_t& ul_grant, - srslte_ul_cfg_t& ul_cfg, - srslte_pusch_res_t& pusch_res) + srsran_ul_cfg_t& ul_cfg, + srsran_pusch_res_t& pusch_res) { uint16_t rnti = ul_grant.dci.rnti; @@ -279,8 +279,8 @@ void cc_worker::decode_pusch_rnti(stack_interface_phy_lte::ul_sched_grant_t& ul_ phy->ue_db.fill_uci_cfg(tti_rx, cc_idx, rnti, ul_grant.dci.cqi_request, true, ul_cfg.pusch.uci_cfg); // Compute UL grant - srslte_pusch_grant_t& grant = ul_cfg.pusch.grant; - if (srslte_ra_ul_dci_to_grant(&enb_ul.cell, &ul_sf, &ul_cfg.hopping, &ul_grant.dci, &grant)) { + srsran_pusch_grant_t& grant = ul_cfg.pusch.grant; + if (srsran_ra_ul_dci_to_grant(&enb_ul.cell, &ul_sf, &ul_cfg.hopping, &ul_grant.dci, &grant)) { Error("Computing PUSCH dci for RNTI %x", rnti); return; } @@ -304,7 +304,7 @@ void cc_worker::decode_pusch_rnti(stack_interface_phy_lte::ul_sched_grant_t& ul_ ul_cfg.pusch.softbuffers.rx = ul_grant.softbuffer_rx; pusch_res.data = ul_grant.data; if (pusch_res.data) { - if (srslte_enb_ul_get_pusch(&enb_ul, &ul_sf, &ul_cfg.pusch, &pusch_res)) { + if (srsran_enb_ul_get_pusch(&enb_ul, &ul_sf, &ul_cfg.pusch, &pusch_res)) { Error("Decoding PUSCH for RNTI %x", rnti); return; } @@ -346,8 +346,8 @@ void cc_worker::decode_pusch(stack_interface_phy_lte::ul_sched_grant_t* grants, stack_interface_phy_lte::ul_sched_grant_t& ul_grant = grants[i]; uint16_t rnti = ul_grant.dci.rnti; - srslte_pusch_res_t pusch_res = {}; - srslte_ul_cfg_t ul_cfg = {}; + srsran_pusch_res_t pusch_res = {}; + srsran_ul_cfg_t ul_cfg = {}; // Decodes PUSCH for the given grant decode_pusch_rnti(ul_grant, ul_cfg, pusch_res); @@ -361,7 +361,7 @@ void cc_worker::decode_pusch(stack_interface_phy_lte::ul_sched_grant_t* grants, // Logging if (logger.info.enabled()) { char str[512]; - srslte_pusch_rx_info(&ul_cfg.pusch, &pusch_res, &enb_ul.chest_res, str, sizeof(str)); + srsran_pusch_rx_info(&ul_cfg.pusch, &pusch_res, &enb_ul.chest_res, str, sizeof(str)); logger.info("PUSCH: cc=%d, %s", cc_idx, str); } } @@ -370,21 +370,21 @@ void cc_worker::decode_pusch(stack_interface_phy_lte::ul_sched_grant_t* grants, int cc_worker::decode_pucch() { - srslte_pucch_res_t pucch_res = {}; + srsran_pucch_res_t pucch_res = {}; for (auto& iter : ue_db) { uint16_t rnti = iter.first; // If it's a User RNTI and doesn't have PUSCH grant in this TTI - if (SRSLTE_RNTI_ISUSER(rnti) and phy->ue_db.is_pcell(rnti, cc_idx)) { - srslte_ul_cfg_t ul_cfg = phy->ue_db.get_ul_config(rnti, cc_idx); + if (SRSRAN_RNTI_ISUSER(rnti) and phy->ue_db.is_pcell(rnti, cc_idx)) { + srsran_ul_cfg_t ul_cfg = phy->ue_db.get_ul_config(rnti, cc_idx); // Check if user needs to receive PUCCH if (phy->ue_db.fill_uci_cfg(tti_rx, cc_idx, rnti, false, false, ul_cfg.pucch.uci_cfg)) { // Decode PUCCH - if (srslte_enb_ul_get_pucch(&enb_ul, &ul_sf, &ul_cfg.pucch, &pucch_res)) { + if (srsran_enb_ul_get_pucch(&enb_ul, &ul_sf, &ul_cfg.pucch, &pucch_res)) { ERROR("Error getting PUCCH"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Send UCI data to MAC @@ -398,7 +398,7 @@ int cc_worker::decode_pucch() // Logging if (logger.info.enabled()) { char str[512]; - srslte_pucch_rx_info(&ul_cfg.pucch, &pucch_res, str, sizeof(str)); + srsran_pucch_rx_info(&ul_cfg.pucch, &pucch_res, str, sizeof(str)); logger.info("PUCCH: cc=%d; %s", cc_idx, str); } @@ -414,7 +414,7 @@ int cc_worker::encode_phich(stack_interface_phy_lte::ul_sched_ack_t* acks, uint3 { for (uint32_t i = 0; i < nof_acks; i++) { if (acks[i].rnti && ue_db.count(acks[i].rnti)) { - srslte_enb_dl_put_phich(&enb_dl, &ue_db[acks[i].rnti]->phich_grant, acks[i].ack); + srsran_enb_dl_put_phich(&enb_dl, &ue_db[acks[i].rnti]->phich_grant, acks[i].ack); Info("PHICH: rnti=0x%x, hi=%d, I_lowest=%d, n_dmrs=%d, tti_tx_dl=%d", acks[i].rnti, @@ -424,37 +424,37 @@ int cc_worker::encode_phich(stack_interface_phy_lte::ul_sched_ack_t* acks, uint3 tti_tx_dl); } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int cc_worker::encode_pdcch_ul(stack_interface_phy_lte::ul_sched_grant_t* grants, uint32_t nof_grants) { for (uint32_t i = 0; i < nof_grants; i++) { if (grants[i].needs_pdcch) { - srslte_dci_cfg_t dci_cfg = phy->ue_db.get_dci_ul_config(grants[i].dci.rnti, cc_idx); + srsran_dci_cfg_t dci_cfg = phy->ue_db.get_dci_ul_config(grants[i].dci.rnti, cc_idx); - if (SRSLTE_RNTI_ISUSER(grants[i].dci.rnti)) { - if (srslte_enb_dl_location_is_common_ncce(&enb_dl, grants[i].dci.location.ncce) && + if (SRSRAN_RNTI_ISUSER(grants[i].dci.rnti)) { + if (srsran_enb_dl_location_is_common_ncce(&enb_dl, grants[i].dci.location.ncce) && phy->ue_db.is_pcell(grants[i].dci.rnti, cc_idx)) { // Disable extended CSI request and SRS request in common SS - srslte_dci_cfg_set_common_ss(&dci_cfg); + srsran_dci_cfg_set_common_ss(&dci_cfg); } } - if (srslte_enb_dl_put_pdcch_ul(&enb_dl, &dci_cfg, &grants[i].dci)) { + if (srsran_enb_dl_put_pdcch_ul(&enb_dl, &dci_cfg, &grants[i].dci)) { ERROR("Error putting PUSCH %d", i); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Logging if (logger.info.enabled()) { char str[512]; - srslte_dci_ul_info(&grants[i].dci, str, 512); + srsran_dci_ul_info(&grants[i].dci, str, 512); logger.info("PDCCH: cc=%d, %s, tti_tx_dl=%d", cc_idx, str, tti_tx_dl); } } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int cc_worker::encode_pdcch_dl(stack_interface_phy_lte::dl_sched_grant_t* grants, uint32_t nof_grants) @@ -462,24 +462,24 @@ int cc_worker::encode_pdcch_dl(stack_interface_phy_lte::dl_sched_grant_t* grants for (uint32_t i = 0; i < nof_grants; i++) { uint16_t rnti = grants[i].dci.rnti; if (rnti) { - srslte_dci_cfg_t dci_cfg = phy->ue_db.get_dci_dl_config(grants[i].dci.rnti, cc_idx); + srsran_dci_cfg_t dci_cfg = phy->ue_db.get_dci_dl_config(grants[i].dci.rnti, cc_idx); - if (SRSLTE_RNTI_ISUSER(grants[i].dci.rnti) && grants[i].dci.format == SRSLTE_DCI_FORMAT1A) { - if (srslte_enb_dl_location_is_common_ncce(&enb_dl, grants[i].dci.location.ncce) && + if (SRSRAN_RNTI_ISUSER(grants[i].dci.rnti) && grants[i].dci.format == SRSRAN_DCI_FORMAT1A) { + if (srsran_enb_dl_location_is_common_ncce(&enb_dl, grants[i].dci.location.ncce) && phy->ue_db.is_pcell(grants[i].dci.rnti, cc_idx)) { - srslte_dci_cfg_set_common_ss(&dci_cfg); + srsran_dci_cfg_set_common_ss(&dci_cfg); } } - if (srslte_enb_dl_put_pdcch_dl(&enb_dl, &dci_cfg, &grants[i].dci)) { + if (srsran_enb_dl_put_pdcch_dl(&enb_dl, &dci_cfg, &grants[i].dci)) { ERROR("Error putting PDCCH %d", i); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (LOG_THIS(rnti) and logger.info.enabled()) { // Logging char str[512]; - srslte_dci_dl_info(&grants[i].dci, str, 512); + srsran_dci_dl_info(&grants[i].dci, str, 512); logger.info("PDCCH: cc=%d, %s, tti_tx_dl=%d", cc_idx, str, tti_tx_dl); } } @@ -487,65 +487,65 @@ int cc_worker::encode_pdcch_dl(stack_interface_phy_lte::dl_sched_grant_t* grants return 0; } -int cc_worker::encode_pmch(stack_interface_phy_lte::dl_sched_grant_t* grant, srslte_mbsfn_cfg_t* mbsfn_cfg) +int cc_worker::encode_pmch(stack_interface_phy_lte::dl_sched_grant_t* grant, srsran_mbsfn_cfg_t* mbsfn_cfg) { - srslte_pmch_cfg_t pmch_cfg; + srsran_pmch_cfg_t pmch_cfg; ZERO_OBJECT(pmch_cfg); - srslte_configure_pmch(&pmch_cfg, &enb_dl.cell, mbsfn_cfg); - srslte_ra_dl_compute_nof_re(&enb_dl.cell, &dl_sf, &pmch_cfg.pdsch_cfg.grant); + srsran_configure_pmch(&pmch_cfg, &enb_dl.cell, mbsfn_cfg); + srsran_ra_dl_compute_nof_re(&enb_dl.cell, &dl_sf, &pmch_cfg.pdsch_cfg.grant); // Set soft buffer pmch_cfg.pdsch_cfg.softbuffers.tx[0] = &temp_mbsfn_softbuffer; // Encode PMCH - if (srslte_enb_dl_put_pmch(&enb_dl, &pmch_cfg, grant->data[0])) { + if (srsran_enb_dl_put_pmch(&enb_dl, &pmch_cfg, grant->data[0])) { Error("Error putting PMCH"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Logging if (logger.info.enabled()) { char str[512]; - srslte_pdsch_tx_info(&pmch_cfg.pdsch_cfg, str, 512); + srsran_pdsch_tx_info(&pmch_cfg.pdsch_cfg, str, 512); logger.info("PMCH: %s", str); } // Save metrics stats - if (ue_db.count(SRSLTE_MRNTI)) { - ue_db[SRSLTE_MRNTI]->metrics_dl(mbsfn_cfg->mbsfn_mcs); + if (ue_db.count(SRSRAN_MRNTI)) { + ue_db[SRSRAN_MRNTI]->metrics_dl(mbsfn_cfg->mbsfn_mcs); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int cc_worker::encode_pdsch(stack_interface_phy_lte::dl_sched_grant_t* grants, uint32_t nof_grants) { /* Scales the Resources Elements affected by the power allocation (p_b) */ - // srslte_enb_dl_prepare_power_allocation(&enb_dl); + // srsran_enb_dl_prepare_power_allocation(&enb_dl); for (uint32_t i = 0; i < nof_grants; i++) { uint16_t rnti = grants[i].dci.rnti; if (rnti && ue_db.count(rnti)) { - srslte_dl_cfg_t dl_cfg = phy->ue_db.get_dl_config(rnti, cc_idx); + srsran_dl_cfg_t dl_cfg = phy->ue_db.get_dl_config(rnti, cc_idx); // Compute DL grant - if (srslte_ra_dl_dci_to_grant( + if (srsran_ra_dl_dci_to_grant( &enb_dl.cell, &dl_sf, dl_cfg.tm, dl_cfg.pdsch.use_tbs_index_alt, &grants[i].dci, &dl_cfg.pdsch.grant)) { Error("Computing DL grant"); } // Set soft buffer - for (uint32_t j = 0; j < SRSLTE_MAX_CODEWORDS; j++) { + for (uint32_t j = 0; j < SRSRAN_MAX_CODEWORDS; j++) { dl_cfg.pdsch.softbuffers.tx[j] = grants[i].softbuffer_tx[j]; } // Encode PDSCH - if (srslte_enb_dl_put_pdsch(&enb_dl, &dl_cfg.pdsch, grants[i].data)) { + if (srsran_enb_dl_put_pdsch(&enb_dl, &dl_cfg.pdsch, grants[i].data)) { Error("Error putting PDSCH %d", i); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Save pending ACK - if (SRSLTE_RNTI_ISUSER(rnti)) { + if (SRSRAN_RNTI_ISUSER(rnti)) { // Push whole DCI phy->ue_db.set_ack_pending(tti_tx_ul, cc_idx, grants[i].dci); } @@ -553,7 +553,7 @@ int cc_worker::encode_pdsch(stack_interface_phy_lte::dl_sched_grant_t* grants, u if (LOG_THIS(rnti) and logger.info.enabled()) { // Logging char str[512]; - srslte_pdsch_tx_info(&dl_cfg.pdsch, str, 512); + srsran_pdsch_tx_info(&dl_cfg.pdsch, str, 512); logger.info("PDSCH: cc=%d, %s, tti_tx_dl=%d", cc_idx, str, tti_tx_dl); } @@ -564,9 +564,9 @@ int cc_worker::encode_pdsch(stack_interface_phy_lte::dl_sched_grant_t* grants, u } } - // srslte_enb_dl_apply_power_allocation(&enb_dl); + // srsran_enb_dl_apply_power_allocation(&enb_dl); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } /************ METRICS interface ********************/ @@ -576,7 +576,7 @@ uint32_t cc_worker::get_metrics(std::vector& metrics) uint32_t cnt = 0; metrics.resize(ue_db.size()); for (auto& ue : ue_db) { - if ((SRSLTE_RNTI_ISUSER(ue.first) || ue.first == SRSLTE_MRNTI)) { + if ((SRSRAN_RNTI_ISUSER(ue.first) || ue.first == SRSRAN_MRNTI)) { ue.second->metrics_read(&metrics[cnt++]); } } @@ -594,40 +594,40 @@ void cc_worker::ue::metrics_read(phy_metrics_t* metrics_) void cc_worker::ue::metrics_dl(uint32_t mcs) { - metrics.dl.mcs = SRSLTE_VEC_CMA(mcs, metrics.dl.mcs, metrics.dl.n_samples); + metrics.dl.mcs = SRSRAN_VEC_CMA(mcs, metrics.dl.mcs, metrics.dl.n_samples); metrics.dl.n_samples++; } void cc_worker::ue::metrics_ul(uint32_t mcs, float rssi, float sinr, float turbo_iters) { - metrics.ul.mcs = SRSLTE_VEC_CMA((float)mcs, metrics.ul.mcs, metrics.ul.n_samples); - metrics.ul.pusch_sinr = SRSLTE_VEC_CMA((float)sinr, metrics.ul.pusch_sinr, metrics.ul.n_samples); - metrics.ul.rssi = SRSLTE_VEC_CMA((float)rssi, metrics.ul.rssi, metrics.ul.n_samples); - metrics.ul.turbo_iters = SRSLTE_VEC_CMA((float)turbo_iters, metrics.ul.turbo_iters, metrics.ul.n_samples); + metrics.ul.mcs = SRSRAN_VEC_CMA((float)mcs, metrics.ul.mcs, metrics.ul.n_samples); + metrics.ul.pusch_sinr = SRSRAN_VEC_CMA((float)sinr, metrics.ul.pusch_sinr, metrics.ul.n_samples); + metrics.ul.rssi = SRSRAN_VEC_CMA((float)rssi, metrics.ul.rssi, metrics.ul.n_samples); + metrics.ul.turbo_iters = SRSRAN_VEC_CMA((float)turbo_iters, metrics.ul.turbo_iters, metrics.ul.n_samples); metrics.ul.n_samples++; } void cc_worker::ue::metrics_ul_pucch(float sinr) { - metrics.ul.pucch_sinr = SRSLTE_VEC_CMA((float)sinr, metrics.ul.pucch_sinr, metrics.ul.n_samples_pucch); + metrics.ul.pucch_sinr = SRSRAN_VEC_CMA((float)sinr, metrics.ul.pucch_sinr, metrics.ul.n_samples_pucch); metrics.ul.n_samples_pucch++; } int cc_worker::read_ce_abs(float* ce_abs) { - int sz = srslte_symbol_sz(phy->get_nof_prb(cc_idx)); - srslte_vec_f_zero(ce_abs, sz); - int g = (sz - SRSLTE_NRE * phy->get_nof_prb(cc_idx)) / 2; - srslte_vec_abs_dB_cf(enb_ul.chest_res.ce, -80.0f, &ce_abs[g], SRSLTE_NRE * phy->get_nof_prb(cc_idx)); + int sz = srsran_symbol_sz(phy->get_nof_prb(cc_idx)); + srsran_vec_f_zero(ce_abs, sz); + int g = (sz - SRSRAN_NRE * phy->get_nof_prb(cc_idx)) / 2; + srsran_vec_abs_dB_cf(enb_ul.chest_res.ce, -80.0f, &ce_abs[g], SRSRAN_NRE * phy->get_nof_prb(cc_idx)); return sz; } int cc_worker::read_ce_arg(float* ce_arg) { - int sz = srslte_symbol_sz(phy->get_nof_prb(cc_idx)); - srslte_vec_f_zero(ce_arg, sz); - int g = (sz - SRSLTE_NRE * phy->get_nof_prb(cc_idx)) / 2; - srslte_vec_arg_deg_cf(enb_ul.chest_res.ce, -80.0f, &ce_arg[g], SRSLTE_NRE * phy->get_nof_prb(cc_idx)); + int sz = srsran_symbol_sz(phy->get_nof_prb(cc_idx)); + srsran_vec_f_zero(ce_arg, sz); + int g = (sz - SRSRAN_NRE * phy->get_nof_prb(cc_idx)) / 2; + srsran_vec_arg_deg_cf(enb_ul.chest_res.ce, -80.0f, &ce_arg[g], SRSRAN_NRE * phy->get_nof_prb(cc_idx)); return sz; } @@ -640,7 +640,7 @@ int cc_worker::read_pusch_d(cf_t* pdsch_d) int cc_worker::read_pucch_d(cf_t* pdsch_d) { - int nof_re = SRSLTE_PUCCH_MAX_BITS / 2; + int nof_re = SRSRAN_PUCCH_MAX_BITS / 2; memcpy(pdsch_d, enb_ul.pucch.z_tmp, nof_re * sizeof(cf_t)); return nof_re; } diff --git a/srsenb/src/phy/lte/sf_worker.cc b/srsenb/src/phy/lte/sf_worker.cc index 33708ea3d..aae91b8a7 100644 --- a/srsenb/src/phy/lte/sf_worker.cc +++ b/srsenb/src/phy/lte/sf_worker.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,22 +10,22 @@ * */ -#include "srslte/common/threads.h" -#include "srslte/srslte.h" +#include "srsran/common/threads.h" +#include "srsran/srsran.h" #include "srsenb/hdr/phy/lte/sf_worker.h" #define Error(fmt, ...) \ - if (SRSLTE_DEBUG_ENABLED) \ + if (SRSRAN_DEBUG_ENABLED) \ logger.error(fmt, ##__VA_ARGS__) #define Warning(fmt, ...) \ - if (SRSLTE_DEBUG_ENABLED) \ + if (SRSRAN_DEBUG_ENABLED) \ logger.warning(fmt, ##__VA_ARGS__) #define Info(fmt, ...) \ - if (SRSLTE_DEBUG_ENABLED) \ + if (SRSRAN_DEBUG_ENABLED) \ logger.info(fmt, ##__VA_ARGS__) #define Debug(fmt, ...) \ - if (SRSLTE_DEBUG_ENABLED) \ + if (SRSRAN_DEBUG_ENABLED) \ logger.debug(fmt, ##__VA_ARGS__) using namespace std; @@ -41,7 +41,7 @@ using namespace std; #include "srsgui/srsgui.h" #include -#include "srslte/srslte.h" +#include "srsran/srsran.h" void init_plots(srsenb::lte::sf_worker* worker); pthread_t plot_thread; @@ -79,12 +79,12 @@ void sf_worker::init(phy_common* phy_) cc_workers.push_back(std::unique_ptr(q)); } - if (srslte_softbuffer_tx_init(&temp_mbsfn_softbuffer, phy->get_nof_prb(0))) { + if (srsran_softbuffer_tx_init(&temp_mbsfn_softbuffer, phy->get_nof_prb(0))) { ERROR("Error initiating soft buffer"); exit(-1); } - srslte_softbuffer_tx_reset(&temp_mbsfn_softbuffer); + srsran_softbuffer_tx_reset(&temp_mbsfn_softbuffer); Info("Worker %d configured cell %d PRB", get_id(), phy->get_nof_prb(0)); @@ -101,7 +101,7 @@ cf_t* sf_worker::get_buffer_rx(uint32_t cc_idx, uint32_t antenna_idx) return cc_workers[cc_idx]->get_buffer_rx(antenna_idx); } -void sf_worker::set_time(uint32_t tti_, uint32_t tx_worker_cnt_, const srslte::rf_timestamp_t& tx_time_) +void sf_worker::set_time(uint32_t tti_, uint32_t tx_worker_cnt_, const srsran::rf_timestamp_t& tx_time_) { tti_rx = tti_; tti_tx_dl = TTI_ADD(tti_rx, FDD_HARQ_DELAY_UL_MS); @@ -121,11 +121,11 @@ void sf_worker::set_time(uint32_t tti_, uint32_t tx_worker_cnt_, const srslte::r int sf_worker::add_rnti(uint16_t rnti, uint32_t cc_idx) { - int ret = SRSLTE_ERROR; + int ret = SRSRAN_ERROR; if (cc_idx < cc_workers.size()) { cc_workers[cc_idx]->add_rnti(rnti); - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } return ret; @@ -147,11 +147,11 @@ void sf_worker::work_imp() { std::lock_guard lock(work_mutex); - srslte_ul_sf_cfg_t ul_sf = {}; - srslte_dl_sf_cfg_t dl_sf = {}; + srsran_ul_sf_cfg_t ul_sf = {}; + srsran_dl_sf_cfg_t dl_sf = {}; // Get Transmission buffers - srslte::rf_buffer_t tx_buffer = {}; + srsran::rf_buffer_t tx_buffer = {}; for (uint32_t cc = 0; cc < phy->get_nof_carriers_lte(); cc++) { for (uint32_t ant = 0; ant < phy->get_nof_ports(0); ant++) { tx_buffer.set(cc, ant, phy->get_nof_ports(0), cc_workers[cc]->get_buffer_tx(ant)); @@ -163,8 +163,8 @@ void sf_worker::work_imp() return; } - srslte_mbsfn_cfg_t mbsfn_cfg; - srslte_sf_t sf_type = phy->is_mbsfn_sf(&mbsfn_cfg, tti_tx_dl) ? SRSLTE_SF_MBSFN : SRSLTE_SF_NORM; + srsran_mbsfn_cfg_t mbsfn_cfg; + srsran_sf_t sf_type = phy->is_mbsfn_sf(&mbsfn_cfg, tti_tx_dl) ? SRSRAN_SF_MBSFN : SRSRAN_SF_NORM; // Uplink grants to receive this TTI stack_interface_phy_lte::ul_sched_list_t ul_grants = phy->get_ul_grants(t_rx); @@ -192,7 +192,7 @@ void sf_worker::work_imp() } // Get DL scheduling for the TX TTI from MAC - if (sf_type == SRSLTE_SF_NORM) { + if (sf_type == SRSRAN_SF_NORM) { if (stack->get_dl_sched(tti_tx_dl, dl_grants) < 0) { Error("Getting DL scheduling from MAC"); phy->worker_end(this, tx_buffer, tx_time); @@ -208,8 +208,8 @@ void sf_worker::work_imp() } // Make sure CFI is in the right range - dl_grants[0].cfi = SRSLTE_MAX(dl_grants[0].cfi, 1); - dl_grants[0].cfi = SRSLTE_MIN(dl_grants[0].cfi, 3); + dl_grants[0].cfi = SRSRAN_MAX(dl_grants[0].cfi, 1); + dl_grants[0].cfi = SRSRAN_MIN(dl_grants[0].cfi, 3); // Get UL scheduling for the TX TTI from MAC if (stack->get_ul_sched(tti_tx_ul, ul_grants_tx) < 0) { @@ -237,11 +237,11 @@ void sf_worker::work_imp() phy->set_ul_grants(t_rx, ul_grants); Debug("Sending to radio"); - tx_buffer.set_nof_samples(SRSLTE_SF_LEN_PRB(phy->get_nof_prb(0))); + tx_buffer.set_nof_samples(SRSRAN_SF_LEN_PRB(phy->get_nof_prb(0))); phy->worker_end(this, tx_buffer, tx_time); #ifdef DEBUG_WRITE_FILE - fwrite(signal_buffer_tx, SRSLTE_SF_LEN_PRB(phy->cell.nof_prb) * sizeof(cf_t), 1, f); + fwrite(signal_buffer_tx, SRSRAN_SF_LEN_PRB(phy->cell.nof_prb) * sizeof(cf_t), 1, f); #endif #ifdef DEBUG_WRITE_FILE @@ -270,15 +270,15 @@ uint32_t sf_worker::get_metrics(std::vector& metrics) for (uint32_t r = 0; r < cnt; r++) { phy_metrics_t* m = &metrics[r]; phy_metrics_t* m_ = &metrics_[r]; - m->dl.mcs = SRSLTE_VEC_PMA(m->dl.mcs, m->dl.n_samples, m_->dl.mcs, m_->dl.n_samples); + m->dl.mcs = SRSRAN_VEC_PMA(m->dl.mcs, m->dl.n_samples, m_->dl.mcs, m_->dl.n_samples); m->dl.n_samples += m_->dl.n_samples; - m->ul.n = SRSLTE_VEC_PMA(m->ul.n, m->ul.n_samples, m_->ul.n, m_->ul.n_samples); - m->ul.pusch_sinr = SRSLTE_VEC_PMA(m->ul.pusch_sinr, m->ul.n_samples, m_->ul.pusch_sinr, m_->ul.n_samples); + m->ul.n = SRSRAN_VEC_PMA(m->ul.n, m->ul.n_samples, m_->ul.n, m_->ul.n_samples); + m->ul.pusch_sinr = SRSRAN_VEC_PMA(m->ul.pusch_sinr, m->ul.n_samples, m_->ul.pusch_sinr, m_->ul.n_samples); m->ul.pucch_sinr = - SRSLTE_VEC_PMA(m->ul.pucch_sinr, m->ul.n_samples_pucch, m_->ul.pucch_sinr, m_->ul.n_samples_pucch); - m->ul.mcs = SRSLTE_VEC_PMA(m->ul.mcs, m->ul.n_samples, m_->ul.mcs, m_->ul.n_samples); - m->ul.rssi = SRSLTE_VEC_PMA(m->ul.rssi, m->ul.n_samples, m_->ul.rssi, m_->ul.n_samples); - m->ul.turbo_iters = SRSLTE_VEC_PMA(m->ul.turbo_iters, m->ul.n_samples, m_->ul.turbo_iters, m_->ul.n_samples); + SRSRAN_VEC_PMA(m->ul.pucch_sinr, m->ul.n_samples_pucch, m_->ul.pucch_sinr, m_->ul.n_samples_pucch); + m->ul.mcs = SRSRAN_VEC_PMA(m->ul.mcs, m->ul.n_samples, m_->ul.mcs, m_->ul.n_samples); + m->ul.rssi = SRSRAN_VEC_PMA(m->ul.rssi, m->ul.n_samples, m_->ul.rssi, m_->ul.n_samples); + m->ul.turbo_iters = SRSRAN_VEC_PMA(m->ul.turbo_iters, m->ul.n_samples, m_->ul.turbo_iters, m_->ul.n_samples); m->ul.n_samples += m_->ul.n_samples; m->ul.n_samples_pucch += m_->ul.n_samples_pucch; } @@ -291,13 +291,13 @@ void sf_worker::start_plot() #ifdef ENABLE_GUI if (plot_worker_id == -1) { plot_worker_id = get_id(); - srslte::console("Starting plot for worker_id=%d\n", plot_worker_id); + srsran::console("Starting plot for worker_id=%d\n", plot_worker_id); init_plots(this); } else { - srslte::console("Trying to start a plot but already started by worker_id=%d\n", plot_worker_id); + srsran::console("Trying to start a plot but already started by worker_id=%d\n", plot_worker_id); } #else - srslte::console("Trying to start a plot but plots are disabled (ENABLE_GUI constant in sf_worker.cc)\n"); + srsran::console("Trying to start a plot but plots are disabled (ENABLE_GUI constant in sf_worker.cc)\n"); #endif } @@ -331,7 +331,7 @@ int sf_worker::read_pucch_d(uint32_t cc_idx, cf_t* pdsch_d) sf_worker::~sf_worker() { - srslte_softbuffer_tx_free(&temp_mbsfn_softbuffer); + srsran_softbuffer_tx_free(&temp_mbsfn_softbuffer); } } // namespace lte @@ -350,11 +350,11 @@ struct plot_cc_s { plot_scatter_t pconst2; }; static std::map plots; -#define SCATTER_PUSCH_BUFFER_LEN (20 * 6 * SRSLTE_SF_LEN_RE(SRSLTE_MAX_PRB, SRSLTE_CP_NORM)) +#define SCATTER_PUSCH_BUFFER_LEN (20 * 6 * SRSRAN_SF_LEN_RE(SRSRAN_MAX_PRB, SRSRAN_CP_NORM)) static float tmp_plot[SCATTER_PUSCH_BUFFER_LEN]; static float tmp_plot_arg[SCATTER_PUSCH_BUFFER_LEN]; -static cf_t tmp_plot2[SRSLTE_SF_LEN_RE(SRSLTE_MAX_PRB, SRSLTE_CP_NORM)]; -static cf_t tmp_pucch_plot[SRSLTE_PUCCH_MAX_BITS / 2]; +static cf_t tmp_plot2[SRSRAN_SF_LEN_RE(SRSRAN_MAX_PRB, SRSRAN_CP_NORM)]; +static cf_t tmp_pucch_plot[SRSRAN_PUCCH_MAX_BITS / 2]; void* plot_thread_run(void* arg) { diff --git a/srsenb/src/phy/lte/worker_pool.cc b/srsenb/src/phy/lte/worker_pool.cc index 4e1458641..25c0d847c 100644 --- a/srsenb/src/phy/lte/worker_pool.cc +++ b/srsenb/src/phy/lte/worker_pool.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/srsenb/src/phy/nr/cc_worker.cc b/srsenb/src/phy/nr/cc_worker.cc index 6e2d5a154..aaaa2b52b 100644 --- a/srsenb/src/phy/nr/cc_worker.cc +++ b/srsenb/src/phy/nr/cc_worker.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,24 +11,24 @@ */ #include "srsenb/hdr/phy/nr/cc_worker.h" -#include "srslte/srslte.h" +#include "srsran/srsran.h" namespace srsenb { namespace nr { cc_worker::cc_worker(uint32_t cc_idx_, srslog::basic_logger& log, phy_nr_state* phy_state_) : cc_idx(cc_idx_), phy_state(phy_state_), logger(log) { - cf_t* buffer_c[SRSLTE_MAX_PORTS] = {}; + cf_t* buffer_c[SRSRAN_MAX_PORTS] = {}; // Allocate buffers - buffer_sz = SRSLTE_SF_LEN_PRB(phy_state->args.dl.nof_max_prb); + buffer_sz = SRSRAN_SF_LEN_PRB(phy_state->args.dl.nof_max_prb); for (uint32_t i = 0; i < phy_state_->args.dl.nof_tx_antennas; i++) { - tx_buffer[i] = srslte_vec_cf_malloc(buffer_sz); - rx_buffer[i] = srslte_vec_cf_malloc(buffer_sz); + tx_buffer[i] = srsran_vec_cf_malloc(buffer_sz); + rx_buffer[i] = srsran_vec_cf_malloc(buffer_sz); buffer_c[i] = tx_buffer[i]; } - if (srslte_enb_dl_nr_init(&enb_dl, buffer_c, &phy_state_->args.dl)) { + if (srsran_enb_dl_nr_init(&enb_dl, buffer_c, &phy_state_->args.dl)) { ERROR("Error initiating UE DL NR"); return; } @@ -36,7 +36,7 @@ cc_worker::cc_worker(uint32_t cc_idx_, srslog::basic_logger& log, phy_nr_state* cc_worker::~cc_worker() { - srslte_enb_dl_nr_free(&enb_dl); + srsran_enb_dl_nr_free(&enb_dl); for (cf_t* p : rx_buffer) { if (p != nullptr) { free(p); @@ -49,18 +49,18 @@ cc_worker::~cc_worker() } } -bool cc_worker::set_carrier(const srslte_carrier_nr_t* carrier) +bool cc_worker::set_carrier(const srsran_carrier_nr_t* carrier) { - if (srslte_enb_dl_nr_set_carrier(&enb_dl, carrier) < SRSLTE_SUCCESS) { + if (srsran_enb_dl_nr_set_carrier(&enb_dl, carrier) < SRSRAN_SUCCESS) { ERROR("Error setting carrier"); return false; } - srslte_coreset_t coreset = {}; + srsran_coreset_t coreset = {}; coreset.freq_resources[0] = true; // Enable the bottom 6 PRB for PDCCH coreset.duration = 2; - if (srslte_enb_dl_nr_set_coreset(&enb_dl, &coreset) < SRSLTE_SUCCESS) { + if (srsran_enb_dl_nr_set_coreset(&enb_dl, &coreset) < SRSRAN_SUCCESS) { ERROR("Error setting coreset"); return false; } @@ -103,9 +103,9 @@ int cc_worker::encode_pdcch_dl(stack_interface_phy_nr::dl_sched_grant_t* grants, // ... // Put actual DCI - if (srslte_enb_dl_nr_pdcch_put(&enb_dl, &dl_slot_cfg, &grants[i].dci) < SRSLTE_SUCCESS) { + if (srsran_enb_dl_nr_pdcch_put(&enb_dl, &dl_slot_cfg, &grants[i].dci) < SRSRAN_SUCCESS) { ERROR("Error putting PDCCH"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (logger.info.enabled()) { @@ -113,7 +113,7 @@ int cc_worker::encode_pdcch_dl(stack_interface_phy_nr::dl_sched_grant_t* grants, } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int cc_worker::encode_pdsch(stack_interface_phy_nr::dl_sched_grant_t* grants, uint32_t nof_grants) @@ -121,20 +121,20 @@ int cc_worker::encode_pdsch(stack_interface_phy_nr::dl_sched_grant_t* grants, ui for (uint32_t i = 0; i < nof_grants; i++) { // Get PHY config for UE // ... - srslte_sch_hl_cfg_nr_t pdsch_hl_cfg = {}; - srslte_sch_cfg_nr_t pdsch_cfg = {}; + srsran_sch_hl_cfg_nr_t pdsch_hl_cfg = {}; + srsran_sch_cfg_nr_t pdsch_cfg = {}; // Compute DL grant - if (srslte_ra_dl_dci_to_grant_nr(&enb_dl.carrier, &pdsch_hl_cfg, &grants[i].dci, &pdsch_cfg, &pdsch_cfg.grant)) { + if (srsran_ra_dl_dci_to_grant_nr(&enb_dl.carrier, &pdsch_hl_cfg, &grants[i].dci, &pdsch_cfg, &pdsch_cfg.grant)) { ERROR("Computing DL grant"); } // Set soft buffer - for (uint32_t j = 0; j < SRSLTE_MAX_CODEWORDS; j++) { + for (uint32_t j = 0; j < SRSRAN_MAX_CODEWORDS; j++) { pdsch_cfg.grant.tb[j].softbuffer.tx = grants[i].softbuffer_tx[j]; } - if (srslte_enb_dl_nr_pdsch_put(&enb_dl, &dl_slot_cfg, &pdsch_cfg, grants[i].data) < SRSLTE_SUCCESS) { + if (srsran_enb_dl_nr_pdsch_put(&enb_dl, &dl_slot_cfg, &pdsch_cfg, grants[i].data) < SRSRAN_SUCCESS) { ERROR("Error putting PDSCH"); return false; } @@ -142,20 +142,20 @@ int cc_worker::encode_pdsch(stack_interface_phy_nr::dl_sched_grant_t* grants, ui // Logging if (logger.info.enabled()) { char str[512]; - srslte_enb_dl_nr_pdsch_info(&enb_dl, &pdsch_cfg, str, sizeof(str)); + srsran_enb_dl_nr_pdsch_info(&enb_dl, &pdsch_cfg, str, sizeof(str)); logger.info("PDSCH: cc=%d, %s", cc_idx, str); } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -bool cc_worker::work_dl(const srslte_slot_cfg_t& dl_sf_cfg, stack_interface_phy_nr::dl_sched_t& dl_grants) +bool cc_worker::work_dl(const srsran_slot_cfg_t& dl_sf_cfg, stack_interface_phy_nr::dl_sched_t& dl_grants) { // Reset resource grid - if (srslte_enb_dl_nr_base_zero(&enb_dl) < SRSLTE_SUCCESS) { + if (srsran_enb_dl_nr_base_zero(&enb_dl) < SRSRAN_SUCCESS) { ERROR("Error setting base to zero"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Put DL grants to resource grid. PDSCH data will be encoded as well. @@ -163,7 +163,7 @@ bool cc_worker::work_dl(const srslte_slot_cfg_t& dl_sf_cfg, stack_interface_phy_ encode_pdsch(dl_grants.pdsch, dl_grants.nof_grants); // Generate signal - srslte_enb_dl_nr_gen_signal(&enb_dl); + srsran_enb_dl_nr_gen_signal(&enb_dl); return true; } diff --git a/srsenb/src/phy/nr/sf_worker.cc b/srsenb/src/phy/nr/sf_worker.cc index 8a7b85cb8..a2723ed7b 100644 --- a/srsenb/src/phy/nr/sf_worker.cc +++ b/srsenb/src/phy/nr/sf_worker.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -22,22 +22,22 @@ sf_worker::sf_worker(phy_common* phy_, phy_nr_state* phy_state_, srslog::basic_l cc_workers.push_back(std::unique_ptr(w)); } - if (srslte_softbuffer_tx_init_guru(&softbuffer_tx, SRSLTE_SCH_NR_MAX_NOF_CB_LDPC, SRSLTE_LDPC_MAX_LEN_ENCODED_CB) < - SRSLTE_SUCCESS) { + if (srsran_softbuffer_tx_init_guru(&softbuffer_tx, SRSRAN_SCH_NR_MAX_NOF_CB_LDPC, SRSRAN_LDPC_MAX_LEN_ENCODED_CB) < + SRSRAN_SUCCESS) { ERROR("Error init soft-buffer"); return; } - data.resize(SRSLTE_SCH_NR_MAX_NOF_CB_LDPC * SRSLTE_LDPC_MAX_LEN_ENCODED_CB / 8); - srslte_vec_u8_zero(data.data(), SRSLTE_SCH_NR_MAX_NOF_CB_LDPC * SRSLTE_LDPC_MAX_LEN_ENCODED_CB / 8); - snprintf((char*)data.data(), SRSLTE_SCH_NR_MAX_NOF_CB_LDPC * SRSLTE_LDPC_MAX_LEN_ENCODED_CB / 8, "hello world!"); + data.resize(SRSRAN_SCH_NR_MAX_NOF_CB_LDPC * SRSRAN_LDPC_MAX_LEN_ENCODED_CB / 8); + srsran_vec_u8_zero(data.data(), SRSRAN_SCH_NR_MAX_NOF_CB_LDPC * SRSRAN_LDPC_MAX_LEN_ENCODED_CB / 8); + snprintf((char*)data.data(), SRSRAN_SCH_NR_MAX_NOF_CB_LDPC * SRSRAN_LDPC_MAX_LEN_ENCODED_CB / 8, "hello world!"); } sf_worker::~sf_worker() { - srslte_softbuffer_tx_free(&softbuffer_tx); + srsran_softbuffer_tx_free(&softbuffer_tx); } -bool sf_worker::set_carrier_unlocked(uint32_t cc_idx, const srslte_carrier_nr_t* carrier_) +bool sf_worker::set_carrier_unlocked(uint32_t cc_idx, const srsran_carrier_nr_t* carrier_) { if (cc_idx >= cc_workers.size()) { return false; @@ -80,8 +80,8 @@ void sf_worker::set_tti(uint32_t tti) void sf_worker::work_imp() { // Get Transmission buffers - srslte::rf_buffer_t tx_buffer = {}; - srslte::rf_timestamp_t dummy_ts = {}; + srsran::rf_buffer_t tx_buffer = {}; + srsran::rf_timestamp_t dummy_ts = {}; for (uint32_t cc = 0; cc < phy->get_nof_carriers_nr(); cc++) { for (uint32_t ant = 0; ant < phy->get_nof_ports(0); ant++) { tx_buffer.set(cc, ant, phy->get_nof_ports(0), cc_workers[cc]->get_tx_buffer(ant)); @@ -92,22 +92,22 @@ void sf_worker::work_imp() phy_state->cfg.pdsch.rbg_size_cfg_1 = false; // Fill grant (this comes from the scheduler) - srslte_slot_cfg_t dl_cfg = {}; + srsran_slot_cfg_t dl_cfg = {}; stack_interface_phy_nr::dl_sched_t grants = {}; grants.nof_grants = 1; grants.pdsch[0].data[0] = data.data(); grants.pdsch[0].softbuffer_tx[0] = &softbuffer_tx; - srslte_softbuffer_tx_reset(&softbuffer_tx); + srsran_softbuffer_tx_reset(&softbuffer_tx); grants.pdsch[0].dci.rnti = 0x1234; - grants.pdsch[0].dci.format = srslte_dci_format_nr_1_0; + grants.pdsch[0].dci.format = srsran_dci_format_nr_1_0; grants.pdsch[0].dci.freq_domain_assigment = 0x1FFF; grants.pdsch[0].dci.time_domain_assigment = 0; grants.pdsch[0].dci.mcs = 27; - grants.pdsch[0].dci.search_space = srslte_search_space_type_ue; + grants.pdsch[0].dci.search_space = srsran_search_space_type_ue; grants.pdsch[0].dci.coreset_id = 1; grants.pdsch[0].dci.location.L = 0; grants.pdsch[0].dci.location.ncce = 0; diff --git a/srsenb/src/phy/nr/worker_pool.cc b/srsenb/src/phy/nr/worker_pool.cc index 771560d36..438de0b0b 100644 --- a/srsenb/src/phy/nr/worker_pool.cc +++ b/srsenb/src/phy/nr/worker_pool.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -29,7 +29,7 @@ bool worker_pool::init(const phy_args_t& args, phy_common* common, srslog::sink& pool.init_worker(i, w, prio); workers.push_back(std::unique_ptr(w)); - srslte_carrier_nr_t c = common->get_cell_nr(0); + srsran_carrier_nr_t c = common->get_cell_nr(0); w->set_carrier_unlocked(0, &c); } diff --git a/srsenb/src/phy/phy.cc b/srsenb/src/phy/phy.cc index 006347110..1a2487475 100644 --- a/srsenb/src/phy/phy.cc +++ b/srsenb/src/phy/phy.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -19,19 +19,19 @@ #include #include "srsenb/hdr/phy/phy.h" -#include "srslte/common/threads.h" +#include "srsran/common/threads.h" #define Error(fmt, ...) \ - if (SRSLTE_DEBUG_ENABLED) \ + if (SRSRAN_DEBUG_ENABLED) \ phy_log.error(fmt, ##__VA_ARGS__) #define Warning(fmt, ...) \ - if (SRSLTE_DEBUG_ENABLED) \ + if (SRSRAN_DEBUG_ENABLED) \ phy_log.warning(fmt, ##__VA_ARGS__) #define Info(fmt, ...) \ - if (SRSLTE_DEBUG_ENABLED) \ + if (SRSRAN_DEBUG_ENABLED) \ phy_log.info(fmt, ##__VA_ARGS__) #define Debug(fmt, ...) \ - if (SRSLTE_DEBUG_ENABLED) \ + if (SRSRAN_DEBUG_ENABLED) \ phy_log.debug(fmt, ##__VA_ARGS__) using namespace std; @@ -39,13 +39,13 @@ using namespace asn1::rrc; namespace srsenb { -static void srslte_phy_handler(phy_logger_level_t log_level, void* ctx, char* str) +static void srsran_phy_handler(phy_logger_level_t log_level, void* ctx, char* str) { phy* r = (phy*)ctx; - r->srslte_phy_logger(log_level, str); + r->srsran_phy_logger(log_level, str); } -void phy::srslte_phy_logger(phy_logger_level_t log_level, char* str) +void phy::srsran_phy_logger(phy_logger_level_t log_level, char* str) { switch (log_level) { case LOG_LEVEL_INFO_S: @@ -96,7 +96,7 @@ void phy::parse_common_config(const phy_cfg_t& cfg) int phy::init(const phy_args_t& args, const phy_cfg_t& cfg, - srslte::radio_interface_phy* radio_, + srsran::radio_interface_phy* radio_, stack_interface_phy_lte* stack_) { mlockall((uint32_t)MCL_CURRENT | (uint32_t)MCL_FUTURE); @@ -107,7 +107,7 @@ int phy::init(const phy_args_t& args, phy_lib_log.set_level(log_lvl); phy_lib_log.set_hex_dump_max_size(args.log.phy_hex_limit); if (log_lvl != srslog::basic_levels::none) { - srslte_phy_log_register_handler(this, srslte_phy_handler); + srsran_phy_log_register_handler(this, srsran_phy_handler); } // Create default log. @@ -140,7 +140,7 @@ int phy::init(const phy_args_t& args, initialized = true; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } void phy::stop() @@ -168,7 +168,7 @@ void phy::rem_rnti(uint16_t rnti) w->release(); } } - if (SRSLTE_RNTI_ISUSER(rnti)) { + if (SRSRAN_RNTI_ISUSER(rnti)) { workers_common.ue_db.rem_rnti(rnti); workers_common.clear_grants(rnti); } @@ -179,10 +179,10 @@ void phy::set_mch_period_stop(uint32_t stop) workers_common.set_mch_period_stop(stop); } -void phy::set_activation_deactivation_scell(uint16_t rnti, const std::array& activation) +void phy::set_activation_deactivation_scell(uint16_t rnti, const std::array& activation) { // Iterate all elements except 0 that is reserved for primary cell - for (uint32_t scell_idx = 1; scell_idx < SRSLTE_MAX_CARRIERS; scell_idx++) { + for (uint32_t scell_idx = 1; scell_idx < SRSRAN_MAX_CARRIERS; scell_idx++) { workers_common.ue_db.activate_deactivate_scell(rnti, scell_idx, activation[scell_idx]); } } @@ -251,7 +251,7 @@ void phy::complete_config(uint16_t rnti) workers_common.ue_db.complete_config(rnti); } -void phy::configure_mbsfn(srslte::sib2_mbms_t* sib2, srslte::sib13_t* sib13, const srslte::mcch_msg_t& mcch) +void phy::configure_mbsfn(srsran::sib2_mbms_t* sib2, srsran::sib13_t* sib13, const srsran::mcch_msg_t& mcch) { if (sib2->mbsfn_sf_cfg_list_present) { if (sib2->nof_mbsfn_sf_cfg == 0) { diff --git a/srsenb/src/phy/phy_common.cc b/srsenb/src/phy/phy_common.cc index 35750830f..ca76d4dc8 100644 --- a/srsenb/src/phy/phy_common.cc +++ b/srsenb/src/phy/phy_common.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,8 +11,8 @@ */ #include "srsenb/hdr/phy/txrx.h" -#include "srslte/common/threads.h" -#include "srslte/phy/channel/channel.h" +#include "srsran/common/threads.h" +#include "srsran/phy/channel/channel.h" #include #include @@ -33,7 +33,7 @@ void phy_common::reset() bool phy_common::init(const phy_cell_cfg_list_t& cell_list_, const phy_cell_cfg_list_nr_t& cell_list_nr_, - srslte::radio_interface_phy* radio_h_, + srsran::radio_interface_phy* radio_h_, stack_interface_phy_lte* stack_) { radio = radio_h_; @@ -46,10 +46,10 @@ bool phy_common::init(const phy_cell_cfg_list_t& cell_list_, // Instantiate DL channel emulator if (params.dl_channel_args.enable) { - dl_channel = srslte::channel_ptr( - new srslte::channel(params.dl_channel_args, get_nof_rf_channels(), srslog::fetch_basic_logger("PHY"))); - dl_channel->set_srate((uint32_t)srslte_sampling_freq_hz(cell_list_lte[0].cell.nof_prb)); - dl_channel->set_signal_power_dBfs(srslte_enb_dl_get_maximum_signal_power_dBfs(cell_list_lte[0].cell.nof_prb)); + dl_channel = srsran::channel_ptr( + new srsran::channel(params.dl_channel_args, get_nof_rf_channels(), srslog::fetch_basic_logger("PHY"))); + dl_channel->set_srate((uint32_t)srsran_sampling_freq_hz(cell_list_lte[0].cell.nof_prb)); + dl_channel->set_signal_power_dBfs(srsran_enb_dl_get_maximum_signal_power_dBfs(cell_list_lte[0].cell.nof_prb)); } // Create grants @@ -104,7 +104,7 @@ void phy_common::set_ul_grants(uint32_t tti, const stack_interface_phy_lte::ul_s * Each worker uses this function to indicate that all processing is done and data is ready for transmission or * there is no transmission at all (tx_enable). In that case, the end of burst message will be sent to the radio */ -void phy_common::worker_end(void* tx_sem_id, srslte::rf_buffer_t& buffer, srslte::rf_timestamp_t& tx_time, bool is_nr) +void phy_common::worker_end(void* tx_sem_id, srsran::rf_buffer_t& buffer, srsran::rf_timestamp_t& tx_time, bool is_nr) { // Wait for the green light to transmit in the current TTI semaphore.wait(tx_sem_id); @@ -120,7 +120,7 @@ void phy_common::worker_end(void* tx_sem_id, srslte::rf_buffer_t& buffer, srslte // ... otherwise, append NR base-band from saved buffer if available if (nr_tx_buffer_ready) { uint32_t j = 0; - for (uint32_t i = 0; i < SRSLTE_MAX_CHANNELS; i++) { + for (uint32_t i = 0; i < SRSRAN_MAX_CHANNELS; i++) { if (buffer.get(i) == nullptr) { buffer.set(i, nr_tx_buffer.get(j)); j++; @@ -150,7 +150,7 @@ void phy_common::set_mch_period_stop(uint32_t stop) pthread_mutex_unlock(&mtch_mutex); } -void phy_common::configure_mbsfn(srslte::phy_cfg_mbsfn_t* cfg) +void phy_common::configure_mbsfn(srsran::phy_cfg_mbsfn_t* cfg) { mbsfn = *cfg; @@ -167,10 +167,10 @@ void phy_common::build_mch_table() // 40 element table represents 4 frames (40 subframes) uint32_t nof_sfs = 0; - if (mbsfn.mbsfn_subfr_cnfg.nof_alloc_subfrs == srslte::mbsfn_sf_cfg_t::sf_alloc_type_t::one_frame) { + if (mbsfn.mbsfn_subfr_cnfg.nof_alloc_subfrs == srsran::mbsfn_sf_cfg_t::sf_alloc_type_t::one_frame) { generate_mch_table(&mch_table[0], (uint32_t)mbsfn.mbsfn_subfr_cnfg.sf_alloc, 1); nof_sfs = 10; - } else if (mbsfn.mbsfn_subfr_cnfg.nof_alloc_subfrs == srslte::mbsfn_sf_cfg_t::sf_alloc_type_t::four_frames) { + } else if (mbsfn.mbsfn_subfr_cnfg.nof_alloc_subfrs == srsran::mbsfn_sf_cfg_t::sf_alloc_type_t::four_frames) { generate_mch_table(&mch_table[0], (uint32_t)mbsfn.mbsfn_subfr_cnfg.sf_alloc, 4); nof_sfs = 40; } else { @@ -199,7 +199,7 @@ void phy_common::build_mcch_table() } } -bool phy_common::is_mcch_subframe(srslte_mbsfn_cfg_t* cfg, uint32_t phy_tti) +bool phy_common::is_mcch_subframe(srsran_mbsfn_cfg_t* cfg, uint32_t phy_tti) { uint32_t sfn; // System Frame Number uint8_t sf; // Subframe @@ -211,7 +211,7 @@ bool phy_common::is_mcch_subframe(srslte_mbsfn_cfg_t* cfg, uint32_t phy_tti) if (sib13_configured) { // mbsfn_area_info_r9_s* area_info = &mbsfn.mbsfn_area_info; - srslte::mbsfn_area_info_t* area_info = &mbsfn.mbsfn_area_info; + srsran::mbsfn_area_info_t* area_info = &mbsfn.mbsfn_area_info; offset = area_info->mcch_cfg.mcch_offset; period = enum_to_number(area_info->mcch_cfg.mcch_repeat_period); @@ -228,7 +228,7 @@ bool phy_common::is_mcch_subframe(srslte_mbsfn_cfg_t* cfg, uint32_t phy_tti) return false; } -bool phy_common::is_mch_subframe(srslte_mbsfn_cfg_t* cfg, uint32_t phy_tti) +bool phy_common::is_mch_subframe(srsran_mbsfn_cfg_t* cfg, uint32_t phy_tti) { uint32_t sfn; // System Frame Number uint8_t sf; // Subframe @@ -253,13 +253,13 @@ bool phy_common::is_mch_subframe(srslte_mbsfn_cfg_t* cfg, uint32_t phy_tti) } // Not MCCH, check for MCH - srslte::mbsfn_sf_cfg_t* subfr_cnfg = &mbsfn.mbsfn_subfr_cnfg; - srslte::mbsfn_area_info_t* area_info = &mbsfn.mbsfn_area_info; + srsran::mbsfn_sf_cfg_t* subfr_cnfg = &mbsfn.mbsfn_subfr_cnfg; + srsran::mbsfn_area_info_t* area_info = &mbsfn.mbsfn_area_info; offset = subfr_cnfg->radioframe_alloc_offset; period = enum_to_number(subfr_cnfg->radioframe_alloc_period); - if (subfr_cnfg->nof_alloc_subfrs == srslte::mbsfn_sf_cfg_t::sf_alloc_type_t::one_frame) { + if (subfr_cnfg->nof_alloc_subfrs == srsran::mbsfn_sf_cfg_t::sf_alloc_type_t::one_frame) { if ((sfn % period == offset) && (mch_table[sf] > 0)) { if (sib13_configured) { cfg->mbsfn_area_id = area_info->mbsfn_area_id; @@ -283,7 +283,7 @@ bool phy_common::is_mch_subframe(srslte_mbsfn_cfg_t* cfg, uint32_t phy_tti) } return true; } - } else if (subfr_cnfg->nof_alloc_subfrs == srslte::mbsfn_sf_cfg_t::sf_alloc_type_t::four_frames) { + } else if (subfr_cnfg->nof_alloc_subfrs == srsran::mbsfn_sf_cfg_t::sf_alloc_type_t::four_frames) { uint8_t idx = sfn % period; if ((idx >= offset) && (idx < offset + 4)) { if (mch_table[(idx * 10) + sf] > 0) { @@ -300,7 +300,7 @@ bool phy_common::is_mch_subframe(srslte_mbsfn_cfg_t* cfg, uint32_t phy_tti) return false; } -bool phy_common::is_mbsfn_sf(srslte_mbsfn_cfg_t* cfg, uint32_t phy_tti) +bool phy_common::is_mbsfn_sf(srsran_mbsfn_cfg_t* cfg, uint32_t phy_tti) { return is_mch_subframe(cfg, phy_tti); } diff --git a/srsenb/src/phy/phy_ue_db.cc b/srsenb/src/phy/phy_ue_db.cc index 42521f2d5..82f243c30 100644 --- a/srsenb/src/phy/phy_ue_db.cc +++ b/srsenb/src/phy/phy_ue_db.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -60,7 +60,7 @@ inline void phy_ue_db::_clear_tti_pending_rnti(uint32_t tti, uint16_t rnti) // Get UE common_ue& ue = ue_db[rnti]; - srslte_pdsch_ack_t& pdsch_ack = ue.pdsch_ack[tti]; + srsran_pdsch_ack_t& pdsch_ack = ue.pdsch_ack[tti]; // Reset ACK information pdsch_ack = {}; @@ -79,7 +79,7 @@ inline void phy_ue_db::_clear_tti_pending_rnti(uint32_t tti, uint16_t rnti) pdsch_ack.simul_cqi_ack = ue.cell_info[0].phy_cfg.ul_cfg.pucch.simul_cqi_ack; } -inline void phy_ue_db::_set_common_config_rnti(uint16_t rnti, srslte::phy_cfg_t& phy_cfg) const +inline void phy_ue_db::_set_common_config_rnti(uint16_t rnti, srsran::phy_cfg_t& phy_cfg) const { // Set common parameters phy_cfg.dl_cfg.pdsch.rnti = rnti; @@ -90,11 +90,11 @@ inline void phy_ue_db::_set_common_config_rnti(uint16_t rnti, srslte::phy_cfg_t& phy_cfg.ul_cfg.pusch.meas_ta_en = phy_args->pusch_meas_ta; phy_cfg.ul_cfg.pusch.meas_evm_en = phy_args->pusch_meas_evm; phy_cfg.ul_cfg.pusch.max_nof_iterations = phy_args->pusch_max_its; - phy_cfg.ul_cfg.pucch.threshold_format1 = SRSLTE_PUCCH_DEFAULT_THRESHOLD_FORMAT1; - phy_cfg.ul_cfg.pucch.threshold_data_valid_format1a = SRSLTE_PUCCH_DEFAULT_THRESHOLD_FORMAT1A; - phy_cfg.ul_cfg.pucch.threshold_data_valid_format2 = SRSLTE_PUCCH_DEFAULT_THRESHOLD_FORMAT2; - phy_cfg.ul_cfg.pucch.threshold_data_valid_format3 = SRSLTE_PUCCH_DEFAULT_THRESHOLD_FORMAT3; - phy_cfg.ul_cfg.pucch.threshold_dmrs_detection = SRSLTE_PUCCH_DEFAULT_THRESHOLD_DMRS; + phy_cfg.ul_cfg.pucch.threshold_format1 = SRSRAN_PUCCH_DEFAULT_THRESHOLD_FORMAT1; + phy_cfg.ul_cfg.pucch.threshold_data_valid_format1a = SRSRAN_PUCCH_DEFAULT_THRESHOLD_FORMAT1A; + phy_cfg.ul_cfg.pucch.threshold_data_valid_format2 = SRSRAN_PUCCH_DEFAULT_THRESHOLD_FORMAT2; + phy_cfg.ul_cfg.pucch.threshold_data_valid_format3 = SRSRAN_PUCCH_DEFAULT_THRESHOLD_FORMAT3; + phy_cfg.ul_cfg.pucch.threshold_dmrs_detection = SRSRAN_PUCCH_DEFAULT_THRESHOLD_DMRS; phy_cfg.ul_cfg.pucch.meas_ta_en = phy_args->pucch_meas_ta; } @@ -103,7 +103,7 @@ inline uint32_t phy_ue_db::_get_ue_cc_idx(uint16_t rnti, uint32_t enb_cc_idx) co uint32_t ue_cc_idx = 0; const common_ue& ue = ue_db.at(rnti); - for (; ue_cc_idx < SRSLTE_MAX_CARRIERS; ue_cc_idx++) { + for (; ue_cc_idx < SRSRAN_MAX_CARRIERS; ue_cc_idx++) { const cell_info_t& scell_info = ue.cell_info[ue_cc_idx]; if (scell_info.enb_cc_idx == enb_cc_idx and (scell_info.state == cell_state_primary or scell_info.state == cell_state_secondary_active)) { @@ -130,109 +130,109 @@ inline int phy_ue_db::_assert_rnti(uint16_t rnti) const { if (not ue_db.count(rnti)) { ERROR("Trying to access RNTI 0x%X, it does not exist.", rnti); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } inline int phy_ue_db::_assert_enb_cc(uint16_t rnti, uint32_t enb_cc_idx) const { // Assert RNTI exist - if (_assert_rnti(rnti) != SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (_assert_rnti(rnti) != SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } // Check Component Carrier is part of UE SCell map - if (_get_ue_cc_idx(rnti, enb_cc_idx) == SRSLTE_MAX_CARRIERS) { - return SRSLTE_ERROR; + if (_get_ue_cc_idx(rnti, enb_cc_idx) == SRSRAN_MAX_CARRIERS) { + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } inline int phy_ue_db::_assert_enb_pcell(uint16_t rnti, uint32_t enb_cc_idx) const { - if (_assert_enb_cc(rnti, enb_cc_idx) != SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (_assert_enb_cc(rnti, enb_cc_idx) != SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } // Check cell is PCell const cell_info_t& cell_info = ue_db.at(rnti).cell_info[_get_ue_cc_idx(rnti, enb_cc_idx)]; if (cell_info.state != cell_state_primary) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } inline int phy_ue_db::_assert_ue_cc(uint16_t rnti, uint32_t ue_cc_idx) const { - if (_assert_rnti(rnti) != SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (_assert_rnti(rnti) != SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } // Check the cell index is in range - if (ue_cc_idx >= SRSLTE_MAX_CARRIERS) { - return SRSLTE_ERROR; + if (ue_cc_idx >= SRSRAN_MAX_CARRIERS) { + return SRSRAN_ERROR; } const cell_info_t& cell_info = ue_db.at(rnti).cell_info.at(ue_cc_idx); if (cell_info.state == cell_state_none) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } inline int phy_ue_db::_assert_active_enb_cc(uint16_t rnti, uint32_t enb_cc_idx) const { - if (_assert_enb_cc(rnti, enb_cc_idx) != SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (_assert_enb_cc(rnti, enb_cc_idx) != SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } // Check SCell is active, ignore PCell state const cell_info_t& cell_info = ue_db.at(rnti).cell_info[_get_ue_cc_idx(rnti, enb_cc_idx)]; if (cell_info.state != cell_state_primary and cell_info.state != cell_state_secondary_active) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } inline int phy_ue_db::_assert_stack() const { if (stack == nullptr) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } inline int phy_ue_db::_assert_cell_list_cfg() const { if (cell_cfg_list == nullptr) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -inline srslte::phy_cfg_t phy_ue_db::_get_rnti_config(uint16_t rnti, uint32_t enb_cc_idx) const +inline srsran::phy_cfg_t phy_ue_db::_get_rnti_config(uint16_t rnti, uint32_t enb_cc_idx) const { - srslte::phy_cfg_t default_cfg = {}; + srsran::phy_cfg_t default_cfg = {}; default_cfg.set_defaults(); default_cfg.dl_cfg.pdsch.rnti = rnti; default_cfg.ul_cfg.pucch.rnti = rnti; default_cfg.ul_cfg.pusch.rnti = rnti; // Use default configuration for non-user C-RNTI - if (not SRSLTE_RNTI_ISUSER(rnti)) { + if (not SRSRAN_RNTI_ISUSER(rnti)) { return default_cfg; } // Make sure the C-RNTI exists and the cell/carrier is configured - if (_assert_enb_cc(rnti, enb_cc_idx) != SRSLTE_SUCCESS) { + if (_assert_enb_cc(rnti, enb_cc_idx) != SRSRAN_SUCCESS) { ERROR("Trying to access cell/carrier %d in RNTI 0x%X. It is not active.", enb_cc_idx, rnti); return default_cfg; } @@ -275,12 +275,12 @@ void phy_ue_db::addmod_rnti(uint16_t rnti, const phy_interface_rrc_lte::phy_rrc_ // Store the current values for CSI and extended TBS in temporary variables ue.stashed_multiple_csi_request_enabled = (_count_nof_configured_scell(rnti) > 0); - for (uint32_t i = 0; i < SRSLTE_MAX_CARRIERS; i++) { + for (uint32_t i = 0; i < SRSRAN_MAX_CARRIERS; i++) { ue.cell_info[i].stash_use_tbs_index_alt = ue.cell_info[i].phy_cfg.dl_cfg.pdsch.use_tbs_index_alt; } // Iterate PHY RRC configuration for each UE cell/carrier - uint32_t nof_cc = SRSLTE_MIN(phy_cfg_list.size(), SRSLTE_MAX_CARRIERS); + uint32_t nof_cc = SRSRAN_MIN(phy_cfg_list.size(), SRSRAN_MAX_CARRIERS); for (uint32_t ue_cc_idx = 0; ue_cc_idx < nof_cc; ue_cc_idx++) { const phy_interface_rrc_lte::phy_rrc_cfg_t& phy_rrc_dedicated = phy_cfg_list[ue_cc_idx]; @@ -319,7 +319,7 @@ void phy_ue_db::addmod_rnti(uint16_t rnti, const phy_interface_rrc_lte::phy_rrc_ } // Disable the rest of potential serving cells - for (uint32_t i = nof_cc; i < SRSLTE_MAX_CARRIERS; i++) { + for (uint32_t i = nof_cc; i < SRSRAN_MAX_CARRIERS; i++) { ue.cell_info[i].state = cell_state_none; } @@ -341,7 +341,7 @@ void phy_ue_db::rem_rnti(uint16_t rnti) uint32_t phy_ue_db::_count_nof_configured_scell(uint16_t rnti) { uint32_t nof_configured_scell = 0; - for (uint32_t ue_cc_idx = 0; ue_cc_idx < SRSLTE_MAX_CARRIERS; ue_cc_idx++) { + for (uint32_t ue_cc_idx = 0; ue_cc_idx < SRSRAN_MAX_CARRIERS; ue_cc_idx++) { if (ue_db[rnti].cell_info[ue_cc_idx].state == cell_state_t::cell_state_secondary_inactive || ue_db[rnti].cell_info[ue_cc_idx].state == cell_state_t::cell_state_secondary_active) { nof_configured_scell++; @@ -355,7 +355,7 @@ void phy_ue_db::complete_config(uint16_t rnti) std::lock_guard lock(mutex); // Makes sure the RNTI exists - if (_assert_rnti(rnti) != SRSLTE_SUCCESS) { + if (_assert_rnti(rnti) != SRSRAN_SUCCESS) { return; } @@ -364,7 +364,7 @@ void phy_ue_db::complete_config(uint16_t rnti) // Update temporary multiple CSI DCI field with the new value ue_db[rnti].stashed_multiple_csi_request_enabled = (_count_nof_configured_scell(rnti) > 0); // Update temporary alternate TBS value with the new one - for (uint32_t ue_cc_idx = 0; ue_cc_idx < SRSLTE_MAX_CARRIERS; ue_cc_idx++) { + for (uint32_t ue_cc_idx = 0; ue_cc_idx < SRSRAN_MAX_CARRIERS; ue_cc_idx++) { ue_db[rnti].cell_info[ue_cc_idx].stash_use_tbs_index_alt = ue_db[rnti].cell_info[ue_cc_idx].phy_cfg.dl_cfg.pdsch.use_tbs_index_alt; } @@ -375,7 +375,7 @@ void phy_ue_db::activate_deactivate_scell(uint16_t rnti, uint32_t ue_cc_idx, boo std::lock_guard lock(mutex); // Assert RNTI and SCell are valid - if (_assert_ue_cc(rnti, ue_cc_idx) != SRSLTE_SUCCESS) { + if (_assert_ue_cc(rnti, ue_cc_idx) != SRSRAN_SUCCESS) { return; } @@ -392,23 +392,23 @@ void phy_ue_db::activate_deactivate_scell(uint16_t rnti, uint32_t ue_cc_idx, boo bool phy_ue_db::ue_has_cell(uint16_t rnti, uint32_t enb_cc_idx) const { - return _assert_enb_cc(rnti, enb_cc_idx) == SRSLTE_SUCCESS; + return _assert_enb_cc(rnti, enb_cc_idx) == SRSRAN_SUCCESS; } bool phy_ue_db::is_pcell(uint16_t rnti, uint32_t enb_cc_idx) const { std::lock_guard lock(mutex); - return _assert_enb_pcell(rnti, enb_cc_idx) == SRSLTE_SUCCESS; + return _assert_enb_pcell(rnti, enb_cc_idx) == SRSRAN_SUCCESS; } -srslte_dl_cfg_t phy_ue_db::get_dl_config(uint16_t rnti, uint32_t enb_cc_idx) const +srsran_dl_cfg_t phy_ue_db::get_dl_config(uint16_t rnti, uint32_t enb_cc_idx) const { std::lock_guard lock(mutex); - srslte_dl_cfg_t ret = _get_rnti_config(rnti, enb_cc_idx).dl_cfg; + srsran_dl_cfg_t ret = _get_rnti_config(rnti, enb_cc_idx).dl_cfg; // The DL configuration must overwrite the use_tbs_index_alt value (for 256QAM) with the temporary value // in case we are in the middle of a reconfiguration - if (ue_db.count(rnti) && SRSLTE_RNTI_ISUSER(rnti)) { + if (ue_db.count(rnti) && SRSRAN_RNTI_ISUSER(rnti)) { uint32_t ue_cc_idx = _get_ue_cc_idx(rnti, enb_cc_idx); if (ue_cc_idx == 0) { ret.pdsch.use_tbs_index_alt = ue_db.at(rnti).cell_info[ue_cc_idx].stash_use_tbs_index_alt; @@ -417,14 +417,14 @@ srslte_dl_cfg_t phy_ue_db::get_dl_config(uint16_t rnti, uint32_t enb_cc_idx) con return ret; } -srslte_dci_cfg_t phy_ue_db::get_dci_dl_config(uint16_t rnti, uint32_t enb_cc_idx) const +srsran_dci_cfg_t phy_ue_db::get_dci_dl_config(uint16_t rnti, uint32_t enb_cc_idx) const { std::lock_guard lock(mutex); - srslte_dci_cfg_t ret = _get_rnti_config(rnti, enb_cc_idx).dl_cfg.dci; + srsran_dci_cfg_t ret = _get_rnti_config(rnti, enb_cc_idx).dl_cfg.dci; // The DCI configuration used for DL grants must overwrite the multiple_csi_request_enabled value with the temporary // value in case we are in the middle of a reconfiguration - if (ue_db.count(rnti) && SRSLTE_RNTI_ISUSER(rnti)) { + if (ue_db.count(rnti) && SRSRAN_RNTI_ISUSER(rnti)) { uint32_t ue_cc_idx = _get_ue_cc_idx(rnti, enb_cc_idx); if (ue_cc_idx == 0) { ret.multiple_csi_request_enabled = ue_db.at(rnti).stashed_multiple_csi_request_enabled; @@ -433,35 +433,35 @@ srslte_dci_cfg_t phy_ue_db::get_dci_dl_config(uint16_t rnti, uint32_t enb_cc_idx return ret; } -srslte_ul_cfg_t phy_ue_db::get_ul_config(uint16_t rnti, uint32_t enb_cc_idx) const +srsran_ul_cfg_t phy_ue_db::get_ul_config(uint16_t rnti, uint32_t enb_cc_idx) const { std::lock_guard lock(mutex); return _get_rnti_config(rnti, enb_cc_idx).ul_cfg; } -srslte_dci_cfg_t phy_ue_db::get_dci_ul_config(uint16_t rnti, uint32_t enb_cc_idx) const +srsran_dci_cfg_t phy_ue_db::get_dci_ul_config(uint16_t rnti, uint32_t enb_cc_idx) const { std::lock_guard lock(mutex); return _get_rnti_config(rnti, enb_cc_idx).dl_cfg.dci; } -bool phy_ue_db::set_ack_pending(uint32_t tti, uint32_t enb_cc_idx, const srslte_dci_dl_t& dci) +bool phy_ue_db::set_ack_pending(uint32_t tti, uint32_t enb_cc_idx, const srsran_dci_dl_t& dci) { std::lock_guard lock(mutex); // Assert rnti and cell exits and it is active - if (_assert_active_enb_cc(dci.rnti, enb_cc_idx) != SRSLTE_SUCCESS) { + if (_assert_active_enb_cc(dci.rnti, enb_cc_idx) != SRSRAN_SUCCESS) { return false; } common_ue& ue = ue_db.at(dci.rnti); uint32_t ue_cc_idx = _get_ue_cc_idx(dci.rnti, enb_cc_idx); - srslte_pdsch_ack_cc_t& pdsch_ack_cc = ue.pdsch_ack[tti].cc[ue_cc_idx]; + srsran_pdsch_ack_cc_t& pdsch_ack_cc = ue.pdsch_ack[tti].cc[ue_cc_idx]; pdsch_ack_cc.M = 1; ///< Hardcoded for FDD // Fill PDSCH ACK information - srslte_pdsch_ack_m_t& pdsch_ack_m = pdsch_ack_cc.m[0]; ///< Assume FDD only + srsran_pdsch_ack_m_t& pdsch_ack_m = pdsch_ack_cc.m[0]; ///< Assume FDD only pdsch_ack_m.present = true; pdsch_ack_m.resource.grant_cc_idx = ue_cc_idx; ///< Assumes no cross-carrier scheduling pdsch_ack_m.resource.v_dai_dl = 0; ///< Ignore for FDD @@ -469,9 +469,9 @@ bool phy_ue_db::set_ack_pending(uint32_t tti, uint32_t enb_cc_idx, const srslte_ pdsch_ack_m.resource.tpc_for_pucch = dci.tpc_pucch; // Set TB info - for (uint32_t tb_idx = 0; tb_idx < SRSLTE_MAX_CODEWORDS; tb_idx++) { + for (uint32_t tb_idx = 0; tb_idx < SRSRAN_MAX_CODEWORDS; tb_idx++) { // Count only if the TB is enabled and the TB index is valid for the DCI format - if (SRSLTE_DCI_IS_TB_EN(dci.tb[tb_idx]) and tb_idx < srslte_dci_format_max_tb(dci.format)) { + if (SRSRAN_DCI_IS_TB_EN(dci.tb[tb_idx]) and tb_idx < srsran_dci_format_max_tb(dci.format)) { pdsch_ack_m.value[tb_idx] = 1; pdsch_ack_m.k++; } else { @@ -486,7 +486,7 @@ int phy_ue_db::fill_uci_cfg(uint32_t tti, uint16_t rnti, bool aperiodic_cqi_request, bool is_pusch_available, - srslte_uci_cfg_t& uci_cfg) + srsran_uci_cfg_t& uci_cfg) { std::lock_guard lock(mutex); @@ -494,12 +494,12 @@ int phy_ue_db::fill_uci_cfg(uint32_t tti, uci_cfg = {}; // Assert Cell List configuration - if (_assert_cell_list_cfg() != SRSLTE_SUCCESS) { + if (_assert_cell_list_cfg() != SRSRAN_SUCCESS) { return -1; } // Assert eNb Cell/Carrier for the given RNTI - if (_assert_active_enb_cc(rnti, enb_cc_idx) != SRSLTE_SUCCESS) { + if (_assert_active_enb_cc(rnti, enb_cc_idx) != SRSRAN_SUCCESS) { return -1; } @@ -523,29 +523,29 @@ int phy_ue_db::fill_uci_cfg(uint32_t tti, } common_ue& ue = ue_db.at(rnti); - const srslte::phy_cfg_t& pcell_cfg = ue.cell_info[0].phy_cfg; + const srsran::phy_cfg_t& pcell_cfg = ue.cell_info[0].phy_cfg; bool uci_required = false; const cell_info_t& pcell_info = ue.cell_info[0]; - const srslte_cell_t& pcell = cell_cfg_list->at(pcell_info.enb_cc_idx).cell; + const srsran_cell_t& pcell = cell_cfg_list->at(pcell_info.enb_cc_idx).cell; // Check if SR opportunity (will only be used in PUCCH) - uci_cfg.is_scheduling_request_tti = (srslte_ue_ul_sr_send_tti(&pcell_cfg.ul_cfg.pucch, tti) == 1); + uci_cfg.is_scheduling_request_tti = (srsran_ue_ul_sr_send_tti(&pcell_cfg.ul_cfg.pucch, tti) == 1); uci_required |= uci_cfg.is_scheduling_request_tti; // Get pending CQI reports for this TTI, stops at first CC reporting bool periodic_cqi_required = false; - for (uint32_t cell_idx = 0; cell_idx < SRSLTE_MAX_CARRIERS and not periodic_cqi_required; cell_idx++) { + for (uint32_t cell_idx = 0; cell_idx < SRSRAN_MAX_CARRIERS and not periodic_cqi_required; cell_idx++) { const cell_info_t& cell_info = ue.cell_info[cell_idx]; - const srslte_dl_cfg_t& dl_cfg = cell_info.phy_cfg.dl_cfg; + const srsran_dl_cfg_t& dl_cfg = cell_info.phy_cfg.dl_cfg; // According 3GPP 36.213 R10 section 7.2 UE procedure for reporting Channel State Information (CSI) // If the UE is configured with more than one serving cell, it transmits CSI for activated serving cell(s) only. if (cell_info.state == cell_state_primary or cell_info.state == cell_state_secondary_active) { - const srslte_cell_t& cell = cell_cfg_list->at(cell_info.enb_cc_idx).cell; + const srsran_cell_t& cell = cell_cfg_list->at(cell_info.enb_cc_idx).cell; // Check if CQI report is required - periodic_cqi_required = srslte_enb_dl_gen_cqi_periodic(&cell, &dl_cfg, tti, cell_info.last_ri, &uci_cfg.cqi); + periodic_cqi_required = srsran_enb_dl_gen_cqi_periodic(&cell, &dl_cfg, tti, cell_info.last_ri, &uci_cfg.cqi); // Save SCell index for using it after uci_cfg.cqi.scell_index = cell_idx; @@ -556,18 +556,18 @@ int phy_ue_db::fill_uci_cfg(uint32_t tti, // If no periodic CQI report required, check aperiodic reporting if ((not periodic_cqi_required) and aperiodic_cqi_request) { // Aperiodic only supported for PCell - const srslte_dl_cfg_t& dl_cfg = pcell_info.phy_cfg.dl_cfg; + const srsran_dl_cfg_t& dl_cfg = pcell_info.phy_cfg.dl_cfg; - uci_required = srslte_enb_dl_gen_cqi_aperiodic(&pcell, &dl_cfg, pcell_info.last_ri, &uci_cfg.cqi); + uci_required = srsran_enb_dl_gen_cqi_aperiodic(&pcell, &dl_cfg, pcell_info.last_ri, &uci_cfg.cqi); } // Get pending ACKs from PDSCH - srslte_dl_sf_cfg_t dl_sf_cfg = {}; + srsran_dl_sf_cfg_t dl_sf_cfg = {}; dl_sf_cfg.tti = tti; - srslte_pdsch_ack_t& pdsch_ack = ue.pdsch_ack[tti]; + srsran_pdsch_ack_t& pdsch_ack = ue.pdsch_ack[tti]; pdsch_ack.is_pusch_available = is_pusch_available; - srslte_enb_dl_gen_ack(&pcell, &dl_sf_cfg, &pdsch_ack, &uci_cfg); - uci_required |= (srslte_uci_cfg_total_ack(&uci_cfg) > 0); + srsran_enb_dl_gen_ack(&pcell, &dl_sf_cfg, &pdsch_ack, &uci_cfg); + uci_required |= (srsran_uci_cfg_total_ack(&uci_cfg) > 0); // Return whether UCI needs to be decoded return uci_required ? 1 : 0; @@ -576,18 +576,18 @@ int phy_ue_db::fill_uci_cfg(uint32_t tti, void phy_ue_db::send_uci_data(uint32_t tti, uint16_t rnti, uint32_t enb_cc_idx, - const srslte_uci_cfg_t& uci_cfg, - const srslte_uci_value_t& uci_value) + const srsran_uci_cfg_t& uci_cfg, + const srsran_uci_value_t& uci_value) { std::lock_guard lock(mutex); // Assert UE RNTI database entry and eNb cell/carrier must be active - if (_assert_active_enb_cc(rnti, enb_cc_idx) != SRSLTE_SUCCESS) { + if (_assert_active_enb_cc(rnti, enb_cc_idx) != SRSRAN_SUCCESS) { return; } // Assert Stack - if (_assert_stack() != SRSLTE_SUCCESS) { + if (_assert_stack() != SRSRAN_SUCCESS) { return; } @@ -600,15 +600,15 @@ void phy_ue_db::send_uci_data(uint32_t tti, common_ue& ue = ue_db.at(rnti); // Get ACK info - srslte_pdsch_ack_t& pdsch_ack = ue.pdsch_ack[tti]; - srslte_enb_dl_get_ack(&cell_cfg_list->at(ue.cell_info[0].enb_cc_idx).cell, &uci_cfg, &uci_value, &pdsch_ack); + srsran_pdsch_ack_t& pdsch_ack = ue.pdsch_ack[tti]; + srsran_enb_dl_get_ack(&cell_cfg_list->at(ue.cell_info[0].enb_cc_idx).cell, &uci_cfg, &uci_value, &pdsch_ack); // Iterate over the ACK information - for (uint32_t ue_cc_idx = 0; ue_cc_idx < SRSLTE_MAX_CARRIERS; ue_cc_idx++) { - const srslte_pdsch_ack_cc_t& pdsch_ack_cc = pdsch_ack.cc[ue_cc_idx]; + for (uint32_t ue_cc_idx = 0; ue_cc_idx < SRSRAN_MAX_CARRIERS; ue_cc_idx++) { + const srsran_pdsch_ack_cc_t& pdsch_ack_cc = pdsch_ack.cc[ue_cc_idx]; for (uint32_t m = 0; m < pdsch_ack_cc.M; m++) { if (pdsch_ack_cc.m[m].present) { - for (uint32_t tb = 0; tb < SRSLTE_MAX_CODEWORDS; tb++) { + for (uint32_t tb = 0; tb < SRSRAN_MAX_CODEWORDS; tb++) { if (pdsch_ack_cc.m[m].value[tb] != 2) { stack->ack_info(tti, rnti, ue.cell_info[ue_cc_idx].enb_cc_idx, tb, pdsch_ack_cc.m[m].value[tb] == 1); } @@ -618,7 +618,7 @@ void phy_ue_db::send_uci_data(uint32_t tti, } // Assert the SCell exists and it is active - if (_assert_ue_cc(rnti, uci_cfg.cqi.scell_index) != SRSLTE_SUCCESS) { + if (_assert_ue_cc(rnti, uci_cfg.cqi.scell_index) != SRSRAN_SUCCESS) { return; } @@ -632,16 +632,16 @@ void phy_ue_db::send_uci_data(uint32_t tti, if (uci_cfg.cqi.data_enable) { uint8_t cqi_value = 0; switch (uci_cfg.cqi.type) { - case SRSLTE_CQI_TYPE_WIDEBAND: + case SRSRAN_CQI_TYPE_WIDEBAND: cqi_value = uci_value.cqi.wideband.wideband_cqi; break; - case SRSLTE_CQI_TYPE_SUBBAND: + case SRSRAN_CQI_TYPE_SUBBAND: cqi_value = uci_value.cqi.subband.subband_cqi; break; - case SRSLTE_CQI_TYPE_SUBBAND_HL: + case SRSRAN_CQI_TYPE_SUBBAND_HL: cqi_value = uci_value.cqi.subband_hl.wideband_cqi_cw0; break; - case SRSLTE_CQI_TYPE_SUBBAND_UE: + case SRSRAN_CQI_TYPE_SUBBAND_UE: cqi_value = uci_value.cqi.subband_ue.wideband_cqi; break; } @@ -652,10 +652,10 @@ void phy_ue_db::send_uci_data(uint32_t tti, if (uci_cfg.cqi.pmi_present) { uint8_t pmi_value = 0; switch (uci_cfg.cqi.type) { - case SRSLTE_CQI_TYPE_WIDEBAND: + case SRSRAN_CQI_TYPE_WIDEBAND: pmi_value = uci_value.cqi.wideband.pmi; break; - case SRSLTE_CQI_TYPE_SUBBAND_HL: + case SRSRAN_CQI_TYPE_SUBBAND_HL: pmi_value = uci_value.cqi.subband_hl.pmi; break; default: @@ -673,12 +673,12 @@ void phy_ue_db::send_uci_data(uint32_t tti, } } -void phy_ue_db::set_last_ul_tb(uint16_t rnti, uint32_t enb_cc_idx, uint32_t pid, srslte_ra_tb_t tb) +void phy_ue_db::set_last_ul_tb(uint16_t rnti, uint32_t enb_cc_idx, uint32_t pid, srsran_ra_tb_t tb) { std::lock_guard lock(mutex); // Assert UE DB entry - if (_assert_active_enb_cc(rnti, enb_cc_idx) != SRSLTE_SUCCESS) { + if (_assert_active_enb_cc(rnti, enb_cc_idx) != SRSRAN_SUCCESS) { return; } @@ -686,12 +686,12 @@ void phy_ue_db::set_last_ul_tb(uint16_t rnti, uint32_t enb_cc_idx, uint32_t pid, ue_db.at(rnti).cell_info[_get_ue_cc_idx(rnti, enb_cc_idx)].last_tb[pid] = tb; } -srslte_ra_tb_t phy_ue_db::get_last_ul_tb(uint16_t rnti, uint32_t enb_cc_idx, uint32_t pid) const +srsran_ra_tb_t phy_ue_db::get_last_ul_tb(uint16_t rnti, uint32_t enb_cc_idx, uint32_t pid) const { std::lock_guard lock(mutex); // Assert UE DB entry - if (_assert_active_enb_cc(rnti, enb_cc_idx) != SRSLTE_SUCCESS) { + if (_assert_active_enb_cc(rnti, enb_cc_idx) != SRSRAN_SUCCESS) { return {}; } @@ -717,7 +717,7 @@ void phy_ue_db::set_ul_grant_available(uint32_t tti, const stack_interface_phy_l const stack_interface_phy_lte::ul_sched_grant_t& ul_sched_grant = ul_sched.pusch[i]; uint16_t rnti = ul_sched_grant.dci.rnti; // Check that eNb Cell/Carrier is active for the given RNTI - if (_assert_active_enb_cc(rnti, enb_cc_idx) == SRSLTE_SUCCESS) { + if (_assert_active_enb_cc(rnti, enb_cc_idx) == SRSRAN_SUCCESS) { // Rise Grant available flag ue_db[rnti].cell_info[_get_ue_cc_idx(rnti, enb_cc_idx)].is_grant_available[tti] = true; } diff --git a/srsenb/src/phy/prach_worker.cc b/srsenb/src/phy/prach_worker.cc index 77deb1a41..e39a02106 100644 --- a/srsenb/src/phy/prach_worker.cc +++ b/srsenb/src/phy/prach_worker.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,13 +11,13 @@ */ #include "srsenb/hdr/phy/prach_worker.h" -#include "srslte/interfaces/enb_mac_interfaces.h" -#include "srslte/srslte.h" +#include "srsran/interfaces/enb_mac_interfaces.h" +#include "srsran/srsran.h" namespace srsenb { -int prach_worker::init(const srslte_cell_t& cell_, - const srslte_prach_cfg_t& prach_cfg_, +int prach_worker::init(const srsran_cell_t& cell_, + const srsran_prach_cfg_t& prach_cfg_, stack_interface_phy_lte* stack_, int priority, uint32_t nof_workers_) @@ -29,16 +29,16 @@ int prach_worker::init(const srslte_cell_t& cell_, max_prach_offset_us = 50; - if (srslte_prach_init(&prach, srslte_symbol_sz(cell.nof_prb))) { + if (srsran_prach_init(&prach, srsran_symbol_sz(cell.nof_prb))) { return -1; } - if (srslte_prach_set_cfg(&prach, &prach_cfg, cell.nof_prb)) { + if (srsran_prach_set_cfg(&prach, &prach_cfg, cell.nof_prb)) { ERROR("Error initiating PRACH"); return -1; } - srslte_prach_set_detect_factor(&prach, 60); + srsran_prach_set_detect_factor(&prach, 60); nof_sf = (uint32_t)ceilf(prach.T_tot * 1000); @@ -75,7 +75,7 @@ void prach_worker::stop() wait_thread_finish(); } - srslte_prach_free(&prach); + srsran_prach_free(&prach); } void prach_worker::set_max_prach_offset_us(float delay_us) @@ -86,7 +86,7 @@ void prach_worker::set_max_prach_offset_us(float delay_us) int prach_worker::new_tti(uint32_t tti_rx, cf_t* buffer_rx) { // Save buffer only if it's a PRACH TTI - if (srslte_prach_tti_opportunity(&prach, tti_rx, -1) || sf_cnt) { + if (srsran_prach_tti_opportunity(&prach, tti_rx, -1) || sf_cnt) { if (sf_cnt == 0) { current_buffer = buffer_pool.allocate(); if (!current_buffer) { @@ -98,11 +98,11 @@ int prach_worker::new_tti(uint32_t tti_rx, cf_t* buffer_rx) logger.error("PRACH: Expected available current_buffer"); return -1; } - if (current_buffer->nof_samples + SRSLTE_SF_LEN_PRB(cell.nof_prb) < sf_buffer_sz) { - memcpy(¤t_buffer->samples[sf_cnt * SRSLTE_SF_LEN_PRB(cell.nof_prb)], + if (current_buffer->nof_samples + SRSRAN_SF_LEN_PRB(cell.nof_prb) < sf_buffer_sz) { + memcpy(¤t_buffer->samples[sf_cnt * SRSRAN_SF_LEN_PRB(cell.nof_prb)], buffer_rx, - sizeof(cf_t) * SRSLTE_SF_LEN_PRB(cell.nof_prb)); - current_buffer->nof_samples += SRSLTE_SF_LEN_PRB(cell.nof_prb); + sizeof(cf_t) * SRSRAN_SF_LEN_PRB(cell.nof_prb)); + current_buffer->nof_samples += SRSRAN_SF_LEN_PRB(cell.nof_prb); if (sf_cnt == 0) { current_buffer->tti = tti_rx; } @@ -128,18 +128,18 @@ int prach_worker::new_tti(uint32_t tti_rx, cf_t* buffer_rx) int prach_worker::run_tti(sf_buffer* b) { uint32_t prach_nof_det = 0; - if (srslte_prach_tti_opportunity(&prach, b->tti, -1)) { + if (srsran_prach_tti_opportunity(&prach, b->tti, -1)) { // Detect possible PRACHs - if (srslte_prach_detect_offset(&prach, + if (srsran_prach_detect_offset(&prach, prach_cfg.freq_offset, &b->samples[prach.N_cp], - nof_sf * SRSLTE_SF_LEN_PRB(cell.nof_prb) - prach.N_cp, + nof_sf * SRSRAN_SF_LEN_PRB(cell.nof_prb) - prach.N_cp, prach_indices, prach_offsets, prach_p2avg, &prach_nof_det)) { logger.error("Error detecting PRACH"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (prach_nof_det) { @@ -155,13 +155,13 @@ int prach_worker::run_tti(sf_buffer* b) if (prach_offsets[i] * 1e6 < max_prach_offset_us) { // Convert time offset to Time Alignment command - uint32_t n_ta = (uint32_t)(prach_offsets[i] / (16 * SRSLTE_LTE_TS)); + uint32_t n_ta = (uint32_t)(prach_offsets[i] / (16 * SRSRAN_LTE_TS)); stack->rach_detected(b->tti, cc_idx, prach_indices[i], n_ta); #if defined(ENABLE_GUI) and ENABLE_PRACH_GUI - uint32_t nof_samples = SRSLTE_MIN(nof_sf * SRSLTE_SF_LEN_PRB(cell.nof_prb), 3 * SRSLTE_SF_LEN_MAX); - srslte_vec_abs_cf(b->samples, plot_buffer.data(), nof_samples); + uint32_t nof_samples = SRSRAN_MIN(nof_sf * SRSRAN_SF_LEN_PRB(cell.nof_prb), 3 * SRSRAN_SF_LEN_MAX); + srsran_vec_abs_cf(b->samples, plot_buffer.data(), nof_samples); plot_real_setNewData(&plot_real, plot_buffer.data(), nof_samples); #endif // defined(ENABLE_GUI) and ENABLE_PRACH_GUI } diff --git a/srsenb/src/phy/txrx.cc b/srsenb/src/phy/txrx.cc index 1c48f2b56..4ce1afa53 100644 --- a/srsenb/src/phy/txrx.cc +++ b/srsenb/src/phy/txrx.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -12,22 +12,22 @@ #include -#include "srslte/common/threads.h" -#include "srslte/srslte.h" +#include "srsran/common/threads.h" +#include "srsran/srsran.h" #include "srsenb/hdr/phy/txrx.h" #define Error(fmt, ...) \ - if (SRSLTE_DEBUG_ENABLED) \ + if (SRSRAN_DEBUG_ENABLED) \ logger.error(fmt, ##__VA_ARGS__) #define Warning(fmt, ...) \ - if (SRSLTE_DEBUG_ENABLED) \ + if (SRSRAN_DEBUG_ENABLED) \ logger.warning(fmt, ##__VA_ARGS__) #define Info(fmt, ...) \ - if (SRSLTE_DEBUG_ENABLED) \ + if (SRSRAN_DEBUG_ENABLED) \ logger.info(fmt, ##__VA_ARGS__) #define Debug(fmt, ...) \ - if (SRSLTE_DEBUG_ENABLED) \ + if (SRSRAN_DEBUG_ENABLED) \ logger.debug(fmt, ##__VA_ARGS__) using namespace std; @@ -40,7 +40,7 @@ txrx::txrx(srslog::basic_logger& logger) : thread("TXRX"), logger(logger) } bool txrx::init(stack_interface_phy_lte* stack_, - srslte::radio_interface_phy* radio_h_, + srsran::radio_interface_phy* radio_h_, lte::worker_pool* lte_workers_, nr::worker_pool* nr_workers_, phy_common* worker_com_, @@ -60,8 +60,8 @@ bool txrx::init(stack_interface_phy_lte* stack_, // Instantiate UL channel emulator if (worker_com->params.ul_channel_args.enable) { - ul_channel = srslte::channel_ptr( - new srslte::channel(worker_com->params.ul_channel_args, worker_com->get_nof_rf_channels(), logger)); + ul_channel = srsran::channel_ptr( + new srsran::channel(worker_com->params.ul_channel_args, worker_com->get_nof_rf_channels(), logger)); } start(prio_); @@ -78,11 +78,11 @@ void txrx::stop() void txrx::run_thread() { - srslte::rf_buffer_t buffer = {}; - srslte::rf_timestamp_t timestamp = {}; - uint32_t sf_len = SRSLTE_SF_LEN_PRB(worker_com->get_nof_prb(0)); + srsran::rf_buffer_t buffer = {}; + srsran::rf_timestamp_t timestamp = {}; + uint32_t sf_len = SRSRAN_SF_LEN_PRB(worker_com->get_nof_prb(0)); - float samp_rate = srslte_sampling_freq_hz(worker_com->get_nof_prb(0)); + float samp_rate = srsran_sampling_freq_hz(worker_com->get_nof_prb(0)); // Configure radio radio_h->set_rx_srate(samp_rate); @@ -93,7 +93,7 @@ void txrx::run_thread() double tx_freq_hz = worker_com->get_dl_freq_hz(cc_idx); double rx_freq_hz = worker_com->get_ul_freq_hz(cc_idx); uint32_t rf_port = worker_com->get_rf_port(cc_idx); - srslte::console("Setting frequency: DL=%.1f Mhz, UL=%.1f MHz for cc_idx=%d nof_prb=%d\n", + srsran::console("Setting frequency: DL=%.1f Mhz, UL=%.1f MHz for cc_idx=%d nof_prb=%d\n", tx_freq_hz / 1e6f, rx_freq_hz / 1e6f, cc_idx, diff --git a/srsenb/src/phy/vnf_phy_nr.cc b/srsenb/src/phy/vnf_phy_nr.cc index e64a8dcba..5d5a3f608 100644 --- a/srsenb/src/phy/vnf_phy_nr.cc +++ b/srsenb/src/phy/vnf_phy_nr.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -14,7 +14,7 @@ #include #include "srsenb/hdr/phy/vnf_phy_nr.h" -#include "srslte/common/basic_vnf_api.h" +#include "srsran/common/basic_vnf_api.h" using namespace std; @@ -32,11 +32,11 @@ int vnf_phy_nr::init(const srsenb::phy_args_t& args, const nr_phy_cfg_t& cfg, sr mlockall(MCL_CURRENT | MCL_FUTURE); // create VNF - vnf = std::unique_ptr(new srslte::srslte_basic_vnf(args.vnf_args, stack_)); + vnf = std::unique_ptr(new srsran::srsran_basic_vnf(args.vnf_args, stack_)); initialized = true; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } void vnf_phy_nr::stop() diff --git a/srsenb/src/stack/CMakeLists.txt b/srsenb/src/stack/CMakeLists.txt index 48f42528c..3af94e230 100644 --- a/srsenb/src/stack/CMakeLists.txt +++ b/srsenb/src/stack/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of diff --git a/srsenb/src/stack/enb_stack_lte.cc b/srsenb/src/stack/enb_stack_lte.cc index 67dce11a6..83321b375 100644 --- a/srsenb/src/stack/enb_stack_lte.cc +++ b/srsenb/src/stack/enb_stack_lte.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -12,11 +12,11 @@ #include "srsenb/hdr/stack/enb_stack_lte.h" #include "srsenb/hdr/enb.h" -#include "srslte/common/network_utils.h" -#include "srslte/interfaces/enb_metrics_interface.h" -#include "srslte/srslog/event_trace.h" +#include "srsran/common/network_utils.h" +#include "srsran/interfaces/enb_metrics_interface.h" +#include "srsran/srslog/event_trace.h" -using namespace srslte; +using namespace srsran; namespace srsenb { @@ -60,10 +60,10 @@ int enb_stack_lte::init(const stack_args_t& args_, const rrc_cfg_t& rrc_cfg_, ph { phy = phy_; if (init(args_, rrc_cfg_)) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int enb_stack_lte::init(const stack_args_t& args_, const rrc_cfg_t& rrc_cfg_) @@ -110,7 +110,7 @@ int enb_stack_lte::init(const stack_args_t& args_, const rrc_cfg_t& rrc_cfg_) } // Init Rx socket handler - rx_sockets.reset(new srslte::rx_multisocket_handler("ENBSOCKETS", stack_logger)); + rx_sockets.reset(new srsran::rx_multisocket_handler("ENBSOCKETS", stack_logger)); // add sync queue sync_task_queue = task_sched.make_task_queue(args.sync_queue_size); @@ -118,14 +118,14 @@ int enb_stack_lte::init(const stack_args_t& args_, const rrc_cfg_t& rrc_cfg_) // Init all layers if (!mac.init(args.mac, rrc_cfg.cell_list, phy, &rlc, &rrc)) { stack_logger.error("Couldn't initialize MAC"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } rlc.init(&pdcp, &rrc, &mac, task_sched.get_timer_handler()); pdcp.init(&rlc, &rrc, >pu); rrc.init(rrc_cfg, phy, &mac, &rlc, &pdcp, &s1ap, >pu); - if (s1ap.init(args.s1ap, &rrc, this) != SRSLTE_SUCCESS) { + if (s1ap.init(args.s1ap, &rrc, this) != SRSRAN_SUCCESS) { stack_logger.error("Couldn't initialize S1AP"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (gtpu.init(args.s1ap.gtp_bind_addr, args.s1ap.mme_addr, @@ -135,13 +135,13 @@ int enb_stack_lte::init(const stack_args_t& args_, const rrc_cfg_t& rrc_cfg_) this, args.embms.enable)) { stack_logger.error("Couldn't initialize GTPU"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } started = true; start(STACK_MAIN_THREAD_PRIO); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } void enb_stack_lte::tti_clock() @@ -225,13 +225,13 @@ void enb_stack_lte::run_thread() } } -void enb_stack_lte::handle_mme_rx_packet(srslte::unique_byte_buffer_t pdu, +void enb_stack_lte::handle_mme_rx_packet(srsran::unique_byte_buffer_t pdu, const sockaddr_in& from, const sctp_sndrcvinfo& sri, int flags) { // Defer the handling of MME packet to eNB stack main thread - auto task_handler = [this, from, sri, flags](srslte::unique_byte_buffer_t& t) { + auto task_handler = [this, from, sri, flags](srsran::unique_byte_buffer_t& t) { s1ap.handle_mme_rx_msg(std::move(t), from, sri, flags); }; // Defer the handling of MME packet to main stack thread @@ -242,7 +242,7 @@ void enb_stack_lte::add_mme_socket(int fd) { // Pass MME Rx packet handler functor to socket handler to run in socket thread auto mme_rx_handler = - [this](srslte::unique_byte_buffer_t pdu, const sockaddr_in& from, const sctp_sndrcvinfo& sri, int flags) { + [this](srsran::unique_byte_buffer_t pdu, const sockaddr_in& from, const sctp_sndrcvinfo& sri, int flags) { handle_mme_rx_packet(std::move(pdu), from, sri, flags); }; rx_sockets->add_socket_sctp_pdu_handler(fd, mme_rx_handler); @@ -255,8 +255,8 @@ void enb_stack_lte::remove_mme_socket(int fd) void enb_stack_lte::add_gtpu_s1u_socket_handler(int fd) { - auto gtpu_s1u_handler = [this](srslte::unique_byte_buffer_t pdu, const sockaddr_in& from) { - auto task_handler = [this, from](srslte::unique_byte_buffer_t& t) { + auto gtpu_s1u_handler = [this](srsran::unique_byte_buffer_t pdu, const sockaddr_in& from) { + auto task_handler = [this, from](srsran::unique_byte_buffer_t& t) { gtpu.handle_gtpu_s1u_rx_packet(std::move(t), from); }; gtpu_task_queue.push(std::bind(task_handler, std::move(pdu))); @@ -266,8 +266,8 @@ void enb_stack_lte::add_gtpu_s1u_socket_handler(int fd) void enb_stack_lte::add_gtpu_m1u_socket_handler(int fd) { - auto gtpu_m1u_handler = [this](srslte::unique_byte_buffer_t pdu, const sockaddr_in& from) { - auto task_handler = [this, from](srslte::unique_byte_buffer_t& t) { + auto gtpu_m1u_handler = [this](srsran::unique_byte_buffer_t pdu, const sockaddr_in& from) { + auto task_handler = [this, from](srsran::unique_byte_buffer_t& t) { gtpu.handle_gtpu_m1u_rx_packet(std::move(t), from); }; gtpu_task_queue.push(std::bind(task_handler, std::move(pdu))); diff --git a/srsenb/src/stack/gnb_stack_nr.cc b/srsenb/src/stack/gnb_stack_nr.cc index f4fa1ae72..74f07bdb2 100644 --- a/srsenb/src/stack/gnb_stack_nr.cc +++ b/srsenb/src/stack/gnb_stack_nr.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,8 +11,8 @@ */ #include "srsenb/hdr/stack/gnb_stack_nr.h" -#include "srslte/srslte.h" -#include +#include "srsran/srsran.h" +#include namespace srsenb { @@ -46,9 +46,9 @@ int gnb_stack_nr::init(const srsenb::stack_args_t& args_, const rrc_nr_cfg_t& rr { phy = phy_; if (init(args_, rrc_cfg_)) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int gnb_stack_nr::init(const srsenb::stack_args_t& args_, const rrc_nr_cfg_t& rrc_cfg_) @@ -103,7 +103,7 @@ int gnb_stack_nr::init(const srsenb::stack_args_t& args_, const rrc_nr_cfg_t& rr start(STACK_MAIN_THREAD_PRIO); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } void gnb_stack_nr::stop() @@ -115,7 +115,7 @@ void gnb_stack_nr::stop() m_pdcp->stop(); m_mac->stop(); - srslte::get_background_workers().stop(); + srsran::get_background_workers().stop(); running = false; } } @@ -174,7 +174,7 @@ int gnb_stack_nr::rx_data_indication(rx_data_ind_t& grant) } // Temporary GW interface -void gnb_stack_nr::write_sdu(uint32_t lcid, srslte::unique_byte_buffer_t sdu) +void gnb_stack_nr::write_sdu(uint32_t lcid, srsran::unique_byte_buffer_t sdu) { m_pdcp->write_sdu(args.coreless.rnti, lcid, std::move(sdu)); } diff --git a/srsenb/src/stack/mac/CMakeLists.txt b/srsenb/src/stack/mac/CMakeLists.txt index ea391a19e..3c18027f7 100644 --- a/srsenb/src/stack/mac/CMakeLists.txt +++ b/srsenb/src/stack/mac/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of diff --git a/srsenb/src/stack/mac/mac.cc b/srsenb/src/stack/mac/mac.cc index e1a2a5745..7e48a6fdd 100644 --- a/srsenb/src/stack/mac/mac.cc +++ b/srsenb/src/stack/mac/mac.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -14,21 +14,21 @@ #include #include "srsenb/hdr/stack/mac/mac.h" -#include "srslte/common/rwlock_guard.h" -#include "srslte/common/standard_streams.h" -#include "srslte/common/time_prof.h" -#include "srslte/interfaces/enb_phy_interfaces.h" -#include "srslte/interfaces/enb_rlc_interfaces.h" -#include "srslte/interfaces/enb_rrc_interfaces.h" -#include "srslte/srslog/event_trace.h" +#include "srsran/common/rwlock_guard.h" +#include "srsran/common/standard_streams.h" +#include "srsran/common/time_prof.h" +#include "srsran/interfaces/enb_phy_interfaces.h" +#include "srsran/interfaces/enb_rlc_interfaces.h" +#include "srsran/interfaces/enb_rrc_interfaces.h" +#include "srsran/srslog/event_trace.h" // #define WRITE_SIB_PCAP using namespace asn1::rrc; namespace srsenb { -mac::mac(srslte::ext_task_sched_handle task_sched_, srslog::basic_logger& logger) : - logger(logger), rar_payload(), common_buffers(SRSLTE_MAX_CARRIERS), task_sched(task_sched_) +mac::mac(srsran::ext_task_sched_handle task_sched_, srslog::basic_logger& logger) : + logger(logger), rar_payload(), common_buffers(SRSRAN_MAX_CARRIERS), task_sched(task_sched_) { pthread_rwlock_init(&rwlock, nullptr); } @@ -63,13 +63,13 @@ bool mac::init(const mac_args_t& args_, common_buffers.resize(cells.size()); for (auto& cc : common_buffers) { for (int i = 0; i < NOF_BCCH_DLSCH_MSG; i++) { - srslte_softbuffer_tx_init(&cc.bcch_softbuffer_tx[i], args.nof_prb); + srsran_softbuffer_tx_init(&cc.bcch_softbuffer_tx[i], args.nof_prb); } // Init softbuffer for PCCH - srslte_softbuffer_tx_init(&cc.pcch_softbuffer_tx, args.nof_prb); + srsran_softbuffer_tx_init(&cc.pcch_softbuffer_tx, args.nof_prb); // Init softbuffer for RAR - srslte_softbuffer_tx_init(&cc.rar_softbuffer_tx, args.nof_prb); + srsran_softbuffer_tx_init(&cc.rar_softbuffer_tx, args.nof_prb); } reset(); @@ -87,15 +87,15 @@ bool mac::init(const mac_args_t& args_, void mac::stop() { - srslte::rwlock_write_guard lock(rwlock); + srsran::rwlock_write_guard lock(rwlock); if (started) { ue_db.clear(); for (auto& cc : common_buffers) { for (int i = 0; i < NOF_BCCH_DLSCH_MSG; i++) { - srslte_softbuffer_tx_free(&cc.bcch_softbuffer_tx[i]); + srsran_softbuffer_tx_free(&cc.bcch_softbuffer_tx[i]); } - srslte_softbuffer_tx_free(&cc.pcch_softbuffer_tx); - srslte_softbuffer_tx_free(&cc.rar_softbuffer_tx); + srsran_softbuffer_tx_free(&cc.pcch_softbuffer_tx); + srsran_softbuffer_tx_free(&cc.rar_softbuffer_tx); started = false; } } @@ -112,7 +112,7 @@ void mac::reset() scheduler.reset(); } -void mac::start_pcap(srslte::mac_pcap* pcap_) +void mac::start_pcap(srsran::mac_pcap* pcap_) { pcap = pcap_; // Set pcap in all UEs for UL messages @@ -121,7 +121,7 @@ void mac::start_pcap(srslte::mac_pcap* pcap_) } } -void mac::start_pcap_net(srslte::mac_pcap_net* pcap_net_) +void mac::start_pcap_net(srsran::mac_pcap_net* pcap_net_) { pcap_net = pcap_net_; // Set pcap in all UEs for UL messages @@ -137,10 +137,10 @@ void mac::start_pcap_net(srslte::mac_pcap_net* pcap_net_) *******************************************************/ int mac::rlc_buffer_state(uint16_t rnti, uint32_t lc_id, uint32_t tx_queue, uint32_t retx_queue) { - srslte::rwlock_read_guard lock(rwlock); + srsran::rwlock_read_guard lock(rwlock); int ret = -1; if (ue_db.count(rnti)) { - if (rnti != SRSLTE_MRNTI) { + if (rnti != SRSRAN_MRNTI) { ret = scheduler.dl_rlc_buffer_state(rnti, lc_id, tx_queue, retx_queue); } else { for (uint32_t i = 0; i < mch.num_mtch_sched; i++) { @@ -159,7 +159,7 @@ int mac::rlc_buffer_state(uint16_t rnti, uint32_t lc_id, uint32_t tx_queue, uint int mac::bearer_ue_cfg(uint16_t rnti, uint32_t lc_id, sched_interface::ue_bearer_cfg_t* cfg) { int ret = -1; - srslte::rwlock_read_guard lock(rwlock); + srsran::rwlock_read_guard lock(rwlock); if (ue_db.count(rnti)) { ret = scheduler.bearer_ue_cfg(rnti, lc_id, *cfg); } else { @@ -170,7 +170,7 @@ int mac::bearer_ue_cfg(uint16_t rnti, uint32_t lc_id, sched_interface::ue_bearer int mac::bearer_ue_rem(uint16_t rnti, uint32_t lc_id) { - srslte::rwlock_read_guard lock(rwlock); + srsran::rwlock_read_guard lock(rwlock); int ret = -1; if (ue_db.count(rnti)) { ret = scheduler.bearer_ue_rem(rnti, lc_id); @@ -188,13 +188,13 @@ void mac::phy_config_enabled(uint16_t rnti, bool enabled) // Update UE configuration int mac::ue_cfg(uint16_t rnti, sched_interface::ue_cfg_t* cfg) { - srslte::rwlock_read_guard lock(rwlock); + srsran::rwlock_read_guard lock(rwlock); auto it = ue_db.find(rnti); ue* ue_ptr = nullptr; if (it == ue_db.end()) { logger.error("User rnti=0x%x not found", rnti); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } ue_ptr = it->second.get(); @@ -202,11 +202,11 @@ int mac::ue_cfg(uint16_t rnti, sched_interface::ue_cfg_t* cfg) ue_ptr->start_ta(); // Update Scheduler configuration - if (cfg != nullptr and scheduler.ue_cfg(rnti, *cfg) == SRSLTE_ERROR) { + if (cfg != nullptr and scheduler.ue_cfg(rnti, *cfg) == SRSRAN_ERROR) { logger.error("Registering new UE rnti=0x%x to SCHED", rnti); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Removes UE from DB @@ -214,13 +214,13 @@ int mac::ue_rem(uint16_t rnti) { // Remove UE from the perspective of L2/L3 { - srslte::rwlock_write_guard lock(rwlock); + srsran::rwlock_write_guard lock(rwlock); if (ue_db.count(rnti)) { ues_to_rem[rnti] = std::move(ue_db[rnti]); ue_db.erase(rnti); } else { logger.error("User rnti=0x%x not found", rnti); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } scheduler.ue_rem(rnti); @@ -232,22 +232,22 @@ int mac::ue_rem(uint16_t rnti) ues_to_rem.erase(rnti); logger.info("User rnti=0x%x removed from MAC/PHY", rnti); }); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Called after Msg3 int mac::ue_set_crnti(uint16_t temp_crnti, uint16_t crnti, sched_interface::ue_cfg_t* cfg) { - srslte::rwlock_read_guard lock(rwlock); + srsran::rwlock_read_guard lock(rwlock); if (temp_crnti != crnti) { // if C-RNTI is changed, it corresponds to older user. Handover scenario. ue_db[crnti]->reset(); } else { // Schedule ConRes Msg4 - scheduler.dl_mac_buffer_state(crnti, (uint32_t)srslte::dl_sch_lcid::CON_RES_ID); + scheduler.dl_mac_buffer_state(crnti, (uint32_t)srsran::dl_sch_lcid::CON_RES_ID); } int ret = ue_cfg(crnti, cfg); - if (ret != SRSLTE_SUCCESS) { + if (ret != SRSRAN_SUCCESS) { return ret; } return ret; @@ -261,7 +261,7 @@ int mac::cell_cfg(const std::vector& cell_cfg_) void mac::get_metrics(mac_metrics_t& metrics) { - srslte::rwlock_read_guard lock(rwlock); + srsran::rwlock_read_guard lock(rwlock); int cnt = 0; metrics.ues.resize(ue_db.size()); for (auto& u : ue_db) { @@ -280,10 +280,10 @@ void mac::get_metrics(mac_metrics_t& metrics) int mac::ack_info(uint32_t tti_rx, uint16_t rnti, uint32_t enb_cc_idx, uint32_t tb_idx, bool ack) { logger.set_context(tti_rx); - srslte::rwlock_read_guard lock(rwlock); + srsran::rwlock_read_guard lock(rwlock); if (not check_ue_exists(rnti)) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } int nof_bytes = scheduler.dl_ack_info(tti_rx, rnti, enb_cc_idx, tb_idx, ack); @@ -295,16 +295,16 @@ int mac::ack_info(uint32_t tti_rx, uint16_t rnti, uint32_t enb_cc_idx, uint32_t logger.info("DL activity rnti=0x%x, n_bytes=%d", rnti, nof_bytes); } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int mac::crc_info(uint32_t tti_rx, uint16_t rnti, uint32_t enb_cc_idx, uint32_t nof_bytes, bool crc) { logger.set_context(tti_rx); - srslte::rwlock_read_guard lock(rwlock); + srsran::rwlock_read_guard lock(rwlock); if (not check_ue_exists(rnti)) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } ue_db[rnti]->set_tti(tti_rx); @@ -316,16 +316,16 @@ int mac::crc_info(uint32_t tti_rx, uint16_t rnti, uint32_t enb_cc_idx, uint32_t int mac::push_pdu(uint32_t tti_rx, uint16_t rnti, uint32_t enb_cc_idx, uint32_t nof_bytes, bool crc) { - srslte::rwlock_read_guard lock(rwlock); + srsran::rwlock_read_guard lock(rwlock); if (not check_ue_exists(rnti)) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - std::array enb_ue_cc_map = scheduler.get_enb_ue_cc_map(rnti); + std::array enb_ue_cc_map = scheduler.get_enb_ue_cc_map(rnti); if (enb_ue_cc_map[enb_cc_idx] < 0) { logger.error("User rnti=0x%x is not activated for carrier %d", rnti, enb_cc_idx); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } uint32_t ue_cc_idx = enb_ue_cc_map[enb_cc_idx]; @@ -338,61 +338,61 @@ int mac::push_pdu(uint32_t tti_rx, uint16_t rnti, uint32_t enb_cc_idx, uint32_t logger.debug("Discarting PDU rnti=0x%x, tti_rx=%d, nof_bytes=%d", rnti, tti_rx, nof_bytes); ue_db[rnti]->deallocate_pdu(tti_rx, ue_cc_idx); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int mac::ri_info(uint32_t tti, uint16_t rnti, uint32_t enb_cc_idx, uint32_t ri_value) { logger.set_context(tti); - srslte::rwlock_read_guard lock(rwlock); + srsran::rwlock_read_guard lock(rwlock); if (not check_ue_exists(rnti)) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } scheduler.dl_ri_info(tti, rnti, enb_cc_idx, ri_value); ue_db[rnti]->metrics_dl_ri(ri_value); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int mac::pmi_info(uint32_t tti, uint16_t rnti, uint32_t enb_cc_idx, uint32_t pmi_value) { logger.set_context(tti); - srslte::rwlock_read_guard lock(rwlock); + srsran::rwlock_read_guard lock(rwlock); if (not check_ue_exists(rnti)) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } scheduler.dl_pmi_info(tti, rnti, enb_cc_idx, pmi_value); ue_db[rnti]->metrics_dl_pmi(pmi_value); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int mac::cqi_info(uint32_t tti, uint16_t rnti, uint32_t enb_cc_idx, uint32_t cqi_value) { logger.set_context(tti); - srslte::rwlock_read_guard lock(rwlock); + srsran::rwlock_read_guard lock(rwlock); if (not check_ue_exists(rnti)) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } scheduler.dl_cqi_info(tti, rnti, enb_cc_idx, cqi_value); ue_db[rnti]->metrics_dl_cqi(cqi_value); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int mac::snr_info(uint32_t tti_rx, uint16_t rnti, uint32_t enb_cc_idx, float snr, ul_channel_t ch) { logger.set_context(tti_rx); - srslte::rwlock_read_guard lock(rwlock); + srsran::rwlock_read_guard lock(rwlock); if (not check_ue_exists(rnti)) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } return scheduler.ul_snr_info(tti_rx, rnti, enb_cc_idx, snr, (uint32_t)ch); @@ -400,26 +400,26 @@ int mac::snr_info(uint32_t tti_rx, uint16_t rnti, uint32_t enb_cc_idx, float snr int mac::ta_info(uint32_t tti, uint16_t rnti, float ta_us) { - srslte::rwlock_read_guard lock(rwlock); + srsran::rwlock_read_guard lock(rwlock); if (not check_ue_exists(rnti)) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } uint32_t nof_ta_count = ue_db[rnti]->set_ta_us(ta_us); if (nof_ta_count) { - scheduler.dl_mac_buffer_state(rnti, (uint32_t)srslte::dl_sch_lcid::TA_CMD, nof_ta_count); + scheduler.dl_mac_buffer_state(rnti, (uint32_t)srsran::dl_sch_lcid::TA_CMD, nof_ta_count); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int mac::sr_detected(uint32_t tti, uint16_t rnti) { logger.set_context(tti); - srslte::rwlock_read_guard lock(rwlock); + srsran::rwlock_read_guard lock(rwlock); if (not check_ue_exists(rnti)) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } return scheduler.ul_sr_info(tti, rnti); @@ -441,17 +441,17 @@ uint16_t mac::allocate_rnti() uint16_t mac::allocate_ue() { { - srslte::rwlock_read_guard lock(rwlock); + srsran::rwlock_read_guard lock(rwlock); if (ue_db.size() >= args.max_nof_ues) { logger.warning("Maximum number of connected UEs %d reached. Ignoring PRACH", args.max_nof_ues); - return SRSLTE_INVALID_RNTI; + return SRSRAN_INVALID_RNTI; } } // Get pre-allocated UE object if (ue_pool.empty()) { logger.error("Ignoring RACH attempt. UE pool empty."); - return SRSLTE_INVALID_RNTI; + return SRSRAN_INVALID_RNTI; } std::unique_ptr ue_ptr = ue_pool.pop_blocking(); uint16_t rnti = ue_ptr->get_rnti(); @@ -466,26 +466,26 @@ uint16_t mac::allocate_ue() } { - srslte::rwlock_write_guard lock(rwlock); + srsran::rwlock_write_guard lock(rwlock); ue_db[rnti] = std::move(ue_ptr); } // Allocate one new UE object in advance - srslte::get_background_workers().push_task([this]() { prealloc_ue(1); }); + srsran::get_background_workers().push_task([this]() { prealloc_ue(1); }); return rnti; } uint16_t mac::reserve_new_crnti(const sched_interface::ue_cfg_t& ue_cfg) { uint16_t rnti = allocate_ue(); - if (rnti == SRSLTE_INVALID_RNTI) { + if (rnti == SRSRAN_INVALID_RNTI) { return rnti; } // Add new user to the scheduler so that it can RX/TX SRB0 - if (scheduler.ue_cfg(rnti, ue_cfg) != SRSLTE_SUCCESS) { + if (scheduler.ue_cfg(rnti, ue_cfg) != SRSRAN_SUCCESS) { logger.error("Registering new user rnti=0x%x to SCHED", rnti); - return SRSLTE_INVALID_RNTI; + return SRSRAN_INVALID_RNTI; } return rnti; @@ -493,12 +493,12 @@ uint16_t mac::reserve_new_crnti(const sched_interface::ue_cfg_t& ue_cfg) void mac::rach_detected(uint32_t tti, uint32_t enb_cc_idx, uint32_t preamble_idx, uint32_t time_adv) { - static srslte::mutexed_tprof rach_tprof("rach_tprof", "MAC", 1); + static srsran::mutexed_tprof rach_tprof("rach_tprof", "MAC", 1); logger.set_context(tti); auto rach_tprof_meas = rach_tprof.start(); uint16_t rnti = allocate_ue(); - if (rnti == SRSLTE_INVALID_RNTI) { + if (rnti == SRSRAN_INVALID_RNTI) { return; } @@ -521,15 +521,15 @@ void mac::rach_detected(uint32_t tti, uint32_t enb_cc_idx, uint32_t preamble_idx ue_cfg.supported_cc_list.back().active = true; ue_cfg.supported_cc_list.back().enb_cc_idx = enb_cc_idx; ue_cfg.ue_bearers[0].direction = srsenb::sched_interface::ue_bearer_cfg_t::BOTH; - ue_cfg.supported_cc_list[0].dl_cfg.tm = SRSLTE_TM1; - if (scheduler.ue_cfg(rnti, ue_cfg) != SRSLTE_SUCCESS) { + ue_cfg.supported_cc_list[0].dl_cfg.tm = SRSRAN_TM1; + if (scheduler.ue_cfg(rnti, ue_cfg) != SRSRAN_SUCCESS) { logger.error("Registering new user rnti=0x%x to SCHED", rnti); ue_rem(rnti); return; } // Register new user in RRC - if (rrc_h->add_user(rnti, ue_cfg) == SRSLTE_ERROR) { + if (rrc_h->add_user(rnti, ue_cfg) == SRSRAN_ERROR) { ue_rem(rnti); return; } @@ -539,7 +539,7 @@ void mac::rach_detected(uint32_t tti, uint32_t enb_cc_idx, uint32_t preamble_idx logger.info( "RACH: tti=%d, cc=%d, preamble=%d, offset=%d, temp_crnti=0x%x", tti, enb_cc_idx, preamble_idx, time_adv, rnti); - srslte::console("RACH: tti=%d, cc=%d, preamble=%d, offset=%d, temp_crnti=0x%x\n", + srsran::console("RACH: tti=%d, cc=%d, preamble=%d, offset=%d, temp_crnti=0x%x\n", tti, enb_cc_idx, preamble_idx, @@ -574,14 +574,14 @@ int mac::get_dl_sched(uint32_t tti_tx_dl, dl_sched_list_t& dl_sched_res_list) sched_interface::dl_sched_res_t sched_result = {}; if (scheduler.dl_sched(tti_tx_dl, enb_cc_idx, sched_result) < 0) { logger.error("Running scheduler"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } int n = 0; dl_sched_t* dl_sched_res = &dl_sched_res_list[enb_cc_idx]; { - srslte::rwlock_read_guard lock(rwlock); + srsran::rwlock_read_guard lock(rwlock); // Copy data grants for (uint32_t i = 0; i < sched_result.data.size(); i++) { @@ -594,7 +594,7 @@ int mac::get_dl_sched(uint32_t tti_tx_dl, dl_sched_list_t& dl_sched_res_list) // Copy dci info dl_sched_res->pdsch[n].dci = sched_result.data[i].dci; - for (uint32_t tb = 0; tb < SRSLTE_MAX_TB; tb++) { + for (uint32_t tb = 0; tb < SRSRAN_MAX_TB; tb++) { dl_sched_res->pdsch[n].softbuffer_tx[tb] = ue_db[rnti]->get_tx_softbuffer(sched_result.data[i].dci.ue_cc_idx, sched_result.data[i].dci.pid, tb); @@ -722,13 +722,13 @@ int mac::get_dl_sched(uint32_t tti_tx_dl, dl_sched_list_t& dl_sched_res_list) // Count number of TTIs for all active users { - srslte::rwlock_read_guard lock(rwlock); + srsran::rwlock_read_guard lock(rwlock); for (auto& u : ue_db) { u.second->metrics_cnt(); } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } void mac::build_mch_sched(uint32_t tbs) @@ -768,12 +768,12 @@ int mac::get_mch_sched(uint32_t tti, bool is_mcch, dl_sched_list_t& dl_sched_res { dl_sched_t* dl_sched_res = &dl_sched_res_list[0]; logger.set_context(tti); - srslte_ra_tb_t mcs = {}; - srslte_ra_tb_t mcs_data = {}; + srsran_ra_tb_t mcs = {}; + srsran_ra_tb_t mcs_data = {}; mcs.mcs_idx = enum_to_number(this->sib13.mbsfn_area_info_list[0].mcch_cfg.sig_mcs); mcs_data.mcs_idx = this->mcch.pmch_info_list[0].data_mcs; - srslte_dl_fill_ra_mcs(&mcs, 0, cell_config[0].cell.nof_prb, false); - srslte_dl_fill_ra_mcs(&mcs_data, 0, cell_config[0].cell.nof_prb, false); + srsran_dl_fill_ra_mcs(&mcs, 0, cell_config[0].cell.nof_prb, false); + srsran_dl_fill_ra_mcs(&mcs_data, 0, cell_config[0].cell.nof_prb, false); if (is_mcch) { build_mch_sched(mcs_data.tbs); mch.mcch_payload = mcch_payload_buffer; @@ -784,18 +784,18 @@ int mac::get_mch_sched(uint32_t tti, bool is_mcch, dl_sched_list_t& dl_sched_res tti); phy_h->set_mch_period_stop(mch.mtch_sched[mch.num_mtch_sched - 1].stop); for (uint32_t i = 0; i < mch.num_mtch_sched; i++) { - mch.pdu[i].lcid = (uint32_t)srslte::mch_lcid::MCH_SCHED_INFO; + mch.pdu[i].lcid = (uint32_t)srsran::mch_lcid::MCH_SCHED_INFO; // m1u.mtch_sched[i].lcid = 1+i; } mch.pdu[mch.num_mtch_sched].lcid = 0; mch.pdu[mch.num_mtch_sched].nbytes = current_mcch_length; - dl_sched_res->pdsch[0].dci.rnti = SRSLTE_MRNTI; + dl_sched_res->pdsch[0].dci.rnti = SRSRAN_MRNTI; // we use TTI % HARQ to make sure we use different buffers for consecutive TTIs to avoid races between PHY workers - ue_db[SRSLTE_MRNTI]->metrics_tx(true, mcs.tbs); + ue_db[SRSRAN_MRNTI]->metrics_tx(true, mcs.tbs); dl_sched_res->pdsch[0].data[0] = - ue_db[SRSLTE_MRNTI]->generate_mch_pdu(tti % SRSLTE_FDD_NOF_HARQ, mch, mch.num_mtch_sched + 1, mcs.tbs / 8); + ue_db[SRSRAN_MRNTI]->generate_mch_pdu(tti % SRSRAN_FDD_NOF_HARQ, mch, mch.num_mtch_sched + 1, mcs.tbs / 8); } else { uint32_t current_lcid = 1; @@ -813,15 +813,15 @@ int mac::get_mch_sched(uint32_t tti, bool is_mcch, dl_sched_list_t& dl_sched_res int requested_bytes = (mcs_data.tbs / 8 > (int)mch.mtch_sched[mtch_index].lcid_buffer_size) ? (mch.mtch_sched[mtch_index].lcid_buffer_size) : ((mcs_data.tbs / 8) - 2); - int bytes_received = ue_db[SRSLTE_MRNTI]->read_pdu(current_lcid, mtch_payload_buffer, requested_bytes); + int bytes_received = ue_db[SRSRAN_MRNTI]->read_pdu(current_lcid, mtch_payload_buffer, requested_bytes); mch.pdu[0].lcid = current_lcid; mch.pdu[0].nbytes = bytes_received; mch.mtch_sched[0].mtch_payload = mtch_payload_buffer; - dl_sched_res->pdsch[0].dci.rnti = SRSLTE_MRNTI; + dl_sched_res->pdsch[0].dci.rnti = SRSRAN_MRNTI; if (bytes_received) { - ue_db[SRSLTE_MRNTI]->metrics_tx(true, mcs.tbs); + ue_db[SRSRAN_MRNTI]->metrics_tx(true, mcs.tbs); dl_sched_res->pdsch[0].data[0] = - ue_db[SRSLTE_MRNTI]->generate_mch_pdu(tti % SRSLTE_FDD_NOF_HARQ, mch, 1, mcs_data.tbs / 8); + ue_db[SRSRAN_MRNTI]->generate_mch_pdu(tti % SRSRAN_FDD_NOF_HARQ, mch, 1, mcs_data.tbs / 8); } } else { dl_sched_res->pdsch[0].dci.rnti = 0; @@ -834,7 +834,7 @@ int mac::get_mch_sched(uint32_t tti, bool is_mcch, dl_sched_list_t& dl_sched_res for (auto& u : ue_db) { u.second->metrics_cnt(); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } uint8_t* mac::assemble_rar(sched_interface::dl_sched_rar_grant_t* grants, @@ -846,11 +846,11 @@ uint8_t* mac::assemble_rar(sched_interface::dl_sched_rar_grant_t* grants, { uint8_t grant_buffer[64] = {}; if (pdu_len < rar_payload_len && rar_idx < rar_pdu_msg.size()) { - srslte::rar_pdu* pdu = &rar_pdu_msg[rar_idx]; + srsran::rar_pdu* pdu = &rar_pdu_msg[rar_idx]; rar_payload[enb_cc_idx][rar_idx].clear(); pdu->init_tx(&rar_payload[enb_cc_idx][rar_idx], pdu_len); for (uint32_t i = 0; i < nof_grants; i++) { - srslte_dci_rar_pack(&grants[i].grant, grant_buffer); + srsran_dci_rar_pack(&grants[i].grant, grant_buffer); if (pdu->new_subh()) { pdu->get()->set_rapid(grants[i].data.preamble_idx); pdu->get()->set_ta_cmd(grants[i].data.ta_cmd); @@ -874,7 +874,7 @@ uint8_t* mac::assemble_rar(sched_interface::dl_sched_rar_grant_t* grants, int mac::get_ul_sched(uint32_t tti_tx_ul, ul_sched_list_t& ul_sched_res_list) { if (!started) { - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } logger.set_context(TTI_SUB(tti_tx_ul, FDD_HARQ_DELAY_UL_MS + FDD_HARQ_DELAY_DL_MS)); @@ -891,11 +891,11 @@ int mac::get_ul_sched(uint32_t tti_tx_ul, ul_sched_list_t& ul_sched_res_list) sched_interface::ul_sched_res_t sched_result = {}; if (scheduler.ul_sched(tti_tx_ul, enb_cc_idx, sched_result) < 0) { logger.error("Running scheduler"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } { - srslte::rwlock_read_guard lock(rwlock); + srsran::rwlock_read_guard lock(rwlock); // Copy DCI grants phy_ul_sched_res->nof_grants = 0; @@ -908,7 +908,7 @@ int mac::get_ul_sched(uint32_t tti_tx_ul, ul_sched_list_t& ul_sched_res_list) if (ue_db.count(rnti)) { // Copy grant info phy_ul_sched_res->pusch[n].current_tx_nb = sched_result.pusch[i].current_tx_nb; - phy_ul_sched_res->pusch[n].pid = TTI_RX(tti_tx_ul) % SRSLTE_FDD_NOF_HARQ; + phy_ul_sched_res->pusch[n].pid = TTI_RX(tti_tx_ul) % SRSRAN_FDD_NOF_HARQ; phy_ul_sched_res->pusch[n].needs_pdcch = sched_result.pusch[i].needs_pdcch; phy_ul_sched_res->pusch[n].dci = sched_result.pusch[i].dci; phy_ul_sched_res->pusch[n].softbuffer_rx = @@ -920,7 +920,7 @@ int mac::get_ul_sched(uint32_t tti_tx_ul, ul_sched_list_t& ul_sched_res_list) } if (sched_result.pusch[n].current_tx_nb == 0) { - srslte_softbuffer_rx_reset_tbs(phy_ul_sched_res->pusch[n].softbuffer_rx, sched_result.pusch[i].tbs * 8); + srsran_softbuffer_rx_reset_tbs(phy_ul_sched_res->pusch[n].softbuffer_rx, sched_result.pusch[i].tbs * 8); } phy_ul_sched_res->pusch[n].data = ue_db[rnti]->request_buffer(tti_tx_ul, sched_result.pusch[i].dci.ue_cc_idx, sched_result.pusch[i].tbs); @@ -953,12 +953,12 @@ int mac::get_ul_sched(uint32_t tti_tx_ul, ul_sched_list_t& ul_sched_res_list) for (auto& u : ue_db) { u.second->clear_old_buffers(tti_tx_ul); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } bool mac::process_pdus() { - srslte::rwlock_read_guard lock(rwlock); + srsran::rwlock_read_guard lock(rwlock); bool ret = false; for (auto& u : ue_db) { ret |= u.second->process_pdus(); @@ -966,9 +966,9 @@ bool mac::process_pdus() return ret; } -void mac::write_mcch(const srslte::sib2_mbms_t* sib2_, - const srslte::sib13_t* sib13_, - const srslte::mcch_msg_t* mcch_, +void mac::write_mcch(const srsran::sib2_mbms_t* sib2_, + const srsran::sib13_t* sib13_, + const srsran::mcch_msg_t* mcch_, const uint8_t* mcch_payload, const uint8_t mcch_payload_length) { @@ -981,10 +981,10 @@ void mac::write_mcch(const srslte::sib2_mbms_t* sib2_, sib13 = *sib13_; memcpy(mcch_payload_buffer, mcch_payload, mcch_payload_length * sizeof(uint8_t)); current_mcch_length = mcch_payload_length; - ue_db[SRSLTE_MRNTI] = - std::unique_ptr{new ue(SRSLTE_MRNTI, args.nof_prb, &scheduler, rrc_h, rlc_h, phy_h, logger, cells.size())}; + ue_db[SRSRAN_MRNTI] = + std::unique_ptr{new ue(SRSRAN_MRNTI, args.nof_prb, &scheduler, rrc_h, rlc_h, phy_h, logger, cells.size())}; - rrc_h->add_user(SRSLTE_MRNTI, {}); + rrc_h->add_user(SRSRAN_MRNTI, {}); } bool mac::check_ue_exists(uint16_t rnti) diff --git a/srsenb/src/stack/mac/mac_nr.cc b/srsenb/src/stack/mac/mac_nr.cc index 85fcfec0a..c55ed530a 100644 --- a/srsenb/src/stack/mac/mac_nr.cc +++ b/srsenb/src/stack/mac/mac_nr.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,8 +11,8 @@ */ #include "srsenb/hdr/stack/mac/mac_nr.h" -#include "srslte/common/buffer_pool.h" -#include "srslte/common/log_helper.h" +#include "srsran/common/buffer_pool.h" +#include "srsran/common/log_helper.h" #include #include #include @@ -22,14 +22,14 @@ namespace srsenb { mac_nr::mac_nr() : logger(srslog::fetch_basic_logger("MAC")) { - bcch_bch_payload = srslte::make_byte_buffer(); + bcch_bch_payload = srsran::make_byte_buffer(); // allocate 8 tx buffers for UE (TODO: as we don't handle softbuffers why do we need so many buffers) - for (int i = 0; i < SRSLTE_FDD_NOF_HARQ; i++) { - ue_tx_buffer.emplace_back(srslte::make_byte_buffer()); + for (int i = 0; i < SRSRAN_FDD_NOF_HARQ; i++) { + ue_tx_buffer.emplace_back(srsran::make_byte_buffer()); } - ue_rlc_buffer = srslte::make_byte_buffer(); + ue_rlc_buffer = srsran::make_byte_buffer(); } mac_nr::~mac_nr() @@ -54,7 +54,7 @@ int mac_nr::init(const mac_nr_args_t& args_, logger.set_hex_dump_max_size(args.log_hex_limit); if (args.pcap.enable) { - pcap = std::unique_ptr(new srslte::mac_pcap()); + pcap = std::unique_ptr(new srsran::mac_pcap()); pcap->open(args.pcap.filename); } @@ -62,7 +62,7 @@ int mac_nr::init(const mac_nr_args_t& args_, started = true; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } void mac_nr::stop() @@ -86,7 +86,7 @@ void mac_nr::get_dl_config(const uint32_t tti, // send MIB over BCH every 80ms if (tti % 80 == 0) { // try to read BCH PDU from RRC - if (rrc_h->read_pdu_bcch_bch(tti, bcch_bch_payload) == SRSLTE_SUCCESS) { + if (rrc_h->read_pdu_bcch_bch(tti, bcch_bch_payload) == SRSRAN_SUCCESS) { logger.info("Adding BCH in TTI=%d", tti); tx_request.pdus[tx_request.nof_pdus].pbch.mib_present = true; tx_request.pdus[tx_request.nof_pdus].data[0] = bcch_bch_payload->msg; @@ -123,7 +123,7 @@ void mac_nr::get_dl_config(const uint32_t tti, // Add MAC padding if TTI is empty if (tx_request.nof_pdus == 0) { - uint32_t buffer_index = tti % SRSLTE_FDD_NOF_HARQ; + uint32_t buffer_index = tti % SRSRAN_FDD_NOF_HARQ; ue_tx_buffer.at(buffer_index)->clear(); ue_tx_pdu.init_tx(ue_tx_buffer.at(buffer_index).get(), args.tb_size); @@ -183,7 +183,7 @@ int mac_nr::sf_indication(const uint32_t tti) // send TX.request phy_h->tx_request(tx_request); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int mac_nr::rx_data_indication(stack_interface_phy_nr::rx_data_ind_t& rx_data) @@ -199,7 +199,7 @@ int mac_nr::rx_data_indication(stack_interface_phy_nr::rx_data_ind_t& rx_data) // inform stack that new PDUs may have been received stack_h->process_pdus(); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } /** @@ -208,13 +208,13 @@ int mac_nr::rx_data_indication(stack_interface_phy_nr::rx_data_ind_t& rx_data) void mac_nr::process_pdus() { while (started and not ue_rx_pdu_queue.empty()) { - srslte::unique_byte_buffer_t pdu = ue_rx_pdu_queue.wait_pop(); + srsran::unique_byte_buffer_t pdu = ue_rx_pdu_queue.wait_pop(); /// TODO; delegate to demux class handle_pdu(std::move(pdu)); } } -int mac_nr::handle_pdu(srslte::unique_byte_buffer_t pdu) +int mac_nr::handle_pdu(srsran::unique_byte_buffer_t pdu) { logger.info(pdu->msg, pdu->N_bytes, "Handling MAC PDU (%d B)", pdu->N_bytes); @@ -222,7 +222,7 @@ int mac_nr::handle_pdu(srslte::unique_byte_buffer_t pdu) ue_rx_pdu.unpack(pdu->msg, pdu->N_bytes); for (uint32_t i = 0; i < ue_rx_pdu.get_num_subpdus(); ++i) { - srslte::mac_sch_subpdu_nr subpdu = ue_rx_pdu.get_subpdu(i); + srsran::mac_sch_subpdu_nr subpdu = ue_rx_pdu.get_subpdu(i); logger.info("Handling subPDU %d/%d: lcid=%d, sdu_len=%d", i, ue_rx_pdu.get_num_subpdus(), @@ -231,7 +231,7 @@ int mac_nr::handle_pdu(srslte::unique_byte_buffer_t pdu) // rlc_h->write_pdu(args.rnti, subpdu.get_lcid(), subpdu.get_sdu(), subpdu.get_sdu_length()); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int mac_nr::cell_cfg(srsenb::sched_interface::cell_cfg_t* cell_cfg) @@ -244,8 +244,8 @@ int mac_nr::cell_cfg(srsenb::sched_interface::cell_cfg_t* cell_cfg) sib_info_t sib = {}; sib.index = i; sib.periodicity = cell_cfg->sibs->period_rf; - sib.payload = srslte::make_byte_buffer(); - if (rrc_h->read_pdu_bcch_dlsch(sib.index, sib.payload) != SRSLTE_SUCCESS) { + sib.payload = srsran::make_byte_buffer(); + if (rrc_h->read_pdu_bcch_dlsch(sib.index, sib.payload) != SRSRAN_SUCCESS) { logger.error("Couldn't read SIB %d from RRC", sib.index); } @@ -254,7 +254,7 @@ int mac_nr::cell_cfg(srsenb::sched_interface::cell_cfg_t* cell_cfg) } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } } // namespace srsenb diff --git a/srsenb/src/stack/mac/sched.cc b/srsenb/src/stack/mac/sched.cc index 75e1e54dc..ba52e0ba8 100644 --- a/srsenb/src/stack/mac/sched.cc +++ b/srsenb/src/stack/mac/sched.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -16,12 +16,12 @@ #include "srsenb/hdr/stack/mac/sched.h" #include "srsenb/hdr/stack/mac/sched_carrier.h" #include "srsenb/hdr/stack/mac/sched_helpers.h" -#include "srslte/srslog/srslog.h" +#include "srsran/srslog/srslog.h" -#define Console(fmt, ...) srslte::console(fmt, ##__VA_ARGS__) +#define Console(fmt, ...) srsran::console(fmt, ##__VA_ARGS__) #define Error(fmt, ...) srslog::fetch_basic_logger("MAC").error(fmt, ##__VA_ARGS__) -using srslte::tti_point; +using srsran::tti_point; namespace srsenb { @@ -64,7 +64,7 @@ int sched::cell_cfg(const std::vector& cell_cfg) sched_cell_params.resize(cell_cfg.size()); for (uint32_t cc_idx = 0; cc_idx < cell_cfg.size(); ++cc_idx) { if (not sched_cell_params[cc_idx].set_cfg(cc_idx, cell_cfg[cc_idx], sched_cfg)) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } @@ -100,7 +100,7 @@ int sched::ue_cfg(uint16_t rnti, const sched_interface::ue_cfg_t& ue_cfg) auto it = ue_db.find(rnti); if (it != ue_db.end()) { it->second->set_cfg(ue_cfg); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } } @@ -108,7 +108,7 @@ int sched::ue_cfg(uint16_t rnti, const sched_interface::ue_cfg_t& ue_cfg) std::unique_ptr ue{new sched_ue(rnti, sched_cell_params, ue_cfg)}; std::lock_guard lock(sched_mutex); ue_db.insert(std::make_pair(rnti, std::move(ue))); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int sched::ue_rem(uint16_t rnti) @@ -118,9 +118,9 @@ int sched::ue_rem(uint16_t rnti) ue_db.erase(rnti); } else { Error("User rnti=0x%x not found", rnti); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } bool sched::ue_exists(uint16_t rnti) @@ -147,7 +147,7 @@ int sched::bearer_ue_rem(uint16_t rnti, uint32_t lc_id) uint32_t sched::get_dl_buffer(uint16_t rnti) { - uint32_t ret = SRSLTE_ERROR; + uint32_t ret = SRSRAN_ERROR; ue_db_access_locked( rnti, [&ret](sched_ue& ue) { ret = ue.get_pending_dl_rlc_data(); }, __PRETTY_FUNCTION__); return ret; @@ -156,7 +156,7 @@ uint32_t sched::get_dl_buffer(uint16_t rnti) uint32_t sched::get_ul_buffer(uint16_t rnti) { // TODO: Check if correct use of last_tti - uint32_t ret = SRSLTE_ERROR; + uint32_t ret = SRSRAN_ERROR; ue_db_access_locked( rnti, [this, &ret](sched_ue& ue) { ret = ue.get_pending_ul_new_data(to_tx_ul(last_tti), -1); }, @@ -248,9 +248,9 @@ void sched::set_dl_tti_mask(uint8_t* tti_mask, uint32_t nof_sfs) carrier_schedulers[0]->set_dl_tti_mask(tti_mask, nof_sfs); } -std::array sched::get_enb_ue_cc_map(uint16_t rnti) +std::array sched::get_enb_ue_cc_map(uint16_t rnti) { - std::array ret{}; + std::array ret{}; ret.fill(-1); // -1 for inactive & non-existent carriers ue_db_access_locked( rnti, @@ -266,10 +266,10 @@ std::array sched::get_enb_ue_cc_map(uint16_t rnti) return ret; } -std::array sched::get_scell_activation_mask(uint16_t rnti) +std::array sched::get_scell_activation_mask(uint16_t rnti) { - std::array enb_ue_cc_map = get_enb_ue_cc_map(rnti); - std::array scell_mask = {}; + std::array enb_ue_cc_map = get_enb_ue_cc_map(rnti); + std::array scell_mask = {}; for (int ue_cc : enb_ue_cc_map) { if (ue_cc <= 0) { // inactive or PCell @@ -324,7 +324,7 @@ int sched::ul_sched(uint32_t tti, uint32_t enb_cc_idx, srsenb::sched_interface:: // copy result sched_result = sched_results.get_sf(tti_rx)->get_cc(enb_cc_idx)->ul_sched_result; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } /// Generate scheduling decision for tti_rx, if it wasn't already generated @@ -344,7 +344,7 @@ void sched::new_tti(tti_point tti_rx) } /// Check if TTI result is generated -bool sched::is_generated(srslte::tti_point tti_rx, uint32_t enb_cc_idx) const +bool sched::is_generated(srsran::tti_point tti_rx, uint32_t enb_cc_idx) const { return sched_results.has_sf(tti_rx) and sched_results.get_sf(tti_rx)->is_generated(enb_cc_idx); } @@ -363,9 +363,9 @@ int sched::ue_db_access_locked(uint16_t rnti, Func&& f, const char* func_name) } else { Error("User rnti=0x%x not found.", rnti); } - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } } // namespace srsenb diff --git a/srsenb/src/stack/mac/sched_carrier.cc b/srsenb/src/stack/mac/sched_carrier.cc index 7f43795d6..f4b79efa6 100644 --- a/srsenb/src/stack/mac/sched_carrier.cc +++ b/srsenb/src/stack/mac/sched_carrier.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -14,13 +14,13 @@ #include "srsenb/hdr/stack/mac/sched_helpers.h" #include "srsenb/hdr/stack/mac/schedulers/sched_time_pf.h" #include "srsenb/hdr/stack/mac/schedulers/sched_time_rr.h" -#include "srslte/common/standard_streams.h" -#include "srslte/common/string_helpers.h" -#include "srslte/interfaces/enb_rrc_interfaces.h" +#include "srsran/common/standard_streams.h" +#include "srsran/common/string_helpers.h" +#include "srsran/interfaces/enb_rrc_interfaces.h" namespace srsenb { -using srslte::tti_point; +using srsran::tti_point; /******************************************************* * Broadcast (SIB+Paging) scheduling @@ -99,7 +99,7 @@ void bc_sched::alloc_sibs(sf_sched* tti_sched) } // Check if subframe index is the correct one for SIB transmission - uint32_t nof_tx = (sib_idx > 0) ? SRSLTE_MIN(srslte::ceil_div(cc_cfg->cfg.si_window_ms, 10), 4) : 4; + uint32_t nof_tx = (sib_idx > 0) ? SRSRAN_MIN(srsran::ceil_div(cc_cfg->cfg.si_window_ms, 10), 4) : 4; uint32_t n_sf = (tti_sched->get_tti_tx_dl() - pending_sibs[sib_idx].window_start); bool sib1_flag = (sib_idx == 0) and (current_sfn % 2) == 0 and current_sf_idx == 5; bool other_sibs_flag = (sib_idx > 0) and @@ -211,7 +211,7 @@ void ra_sched::dl_sched(sf_sched* tti_sched) // In case of RAR outside RAR window: // - if window has passed, discard RAR // - if window hasn't started, stop loop, as RARs are ordered by TTI - srslte::tti_interval rar_window{rar.prach_tti + PRACH_RAR_OFFSET, + srsran::tti_interval rar_window{rar.prach_tti + PRACH_RAR_OFFSET, rar.prach_tti + PRACH_RAR_OFFSET + cc_cfg->cfg.prach_rar_window}; if (not rar_window.contains(tti_tx_dl)) { if (tti_tx_dl >= rar_window.stop()) { @@ -221,8 +221,8 @@ void ra_sched::dl_sched(sf_sched* tti_sched) rar.prach_tti, rar_window, tti_tx_dl); - srslte::console("%s\n", srslte::to_c_str(str_buffer)); - logger.warning("%s", srslte::to_c_str(str_buffer)); + srsran::console("%s\n", srsran::to_c_str(str_buffer)); + logger.warning("%s", srsran::to_c_str(str_buffer)); it = pending_rars.erase(it); continue; } @@ -275,10 +275,10 @@ int ra_sched::dl_rach_info(dl_sched_rar_info_t rar_info) if (r.prach_tti.to_uint() == rar_info.prach_tti and ra_rnti == r.ra_rnti) { if (r.msg3_grant.size() >= sched_interface::MAX_RAR_LIST) { logger.warning("PRACH ignored, as the the maximum number of RAR grants per tti has been reached"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } r.msg3_grant.push_back(rar_info); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } } @@ -289,13 +289,13 @@ int ra_sched::dl_rach_info(dl_sched_rar_info_t rar_info) p.msg3_grant.push_back(rar_info); pending_rars.push_back(p); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } //! Schedule Msg3 grants in UL based on allocated RARs void ra_sched::ul_sched(sf_sched* sf_dl_sched, sf_sched* sf_msg3_sched) { - srslte::const_span alloc_rars = sf_dl_sched->get_allocated_rars(); + srsran::const_span alloc_rars = sf_dl_sched->get_allocated_rars(); for (const auto& rar : alloc_rars) { for (const auto& msg3grant : rar.rar_grant.msg3_grant) { @@ -439,7 +439,7 @@ void sched::carrier_sched::alloc_dl_users(sf_sched* tti_result) // NOTE: In case of 6 PRBs, do not transmit if there is going to be a PRACH in the UL to avoid collisions if (cc_cfg->nof_prb() == 6) { tti_point tti_rx_ack = to_tx_dl_ack(tti_result->get_tti_rx()); - if (srslte_prach_tti_opportunity_config_fdd(cc_cfg->cfg.prach_config, tti_rx_ack.to_uint(), -1)) { + if (srsran_prach_tti_opportunity_config_fdd(cc_cfg->cfg.prach_config, tti_rx_ack.to_uint(), -1)) { tti_result->reserve_dl_rbgs(0, cc_cfg->nof_rbgs); } } @@ -453,7 +453,7 @@ int sched::carrier_sched::alloc_ul_users(sf_sched* tti_sched) /* Call scheduler for UL data */ sched_algo->sched_ul_users(*ue_db, tti_sched); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } sf_sched* sched::carrier_sched::get_sf_sched(tti_point tti_rx) diff --git a/srsenb/src/stack/mac/sched_grid.cc b/srsenb/src/stack/mac/sched_grid.cc index d4d983c60..b66002eda 100644 --- a/srsenb/src/stack/mac/sched_grid.cc +++ b/srsenb/src/stack/mac/sched_grid.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -12,7 +12,7 @@ #include "srsenb/hdr/stack/mac/sched_grid.h" #include "srsenb/hdr/stack/mac/sched_helpers.h" -#include "srslte/common/string_helpers.h" +#include "srsran/common/string_helpers.h" namespace srsenb { @@ -83,7 +83,7 @@ void sched_result_ringbuffer::set_nof_carriers(uint32_t nof_carriers_) } } -void sched_result_ringbuffer::new_tti(srslte::tti_point tti_rx) +void sched_result_ringbuffer::new_tti(srsran::tti_point tti_rx) { sf_sched_result* res = &results[tti_rx.to_uint()]; res->new_tti(tti_rx); @@ -106,9 +106,9 @@ void sf_grid_t::init(const sched_cell_params_t& cell_params_) // Compute reserved PRBs for CQI, SR and HARQ-ACK, and store it in a bitmask pucch_mask.resize(cc_cfg->nof_prb()); pucch_nrb = (cc_cfg->cfg.nrb_pucch > 0) ? (uint32_t)cc_cfg->cfg.nrb_pucch : 0; - srslte_pucch_cfg_t pucch_cfg = cell_params_.pucch_cfg_common; - pucch_cfg.n_pucch = cc_cfg->nof_cce_table[SRSLTE_NOF_CFI - 1] - 1 + cc_cfg->cfg.n1pucch_an; - pucch_nrb = std::max(pucch_nrb, srslte_pucch_m(&pucch_cfg, cc_cfg->cfg.cell.cp) / 2 + 1); + srsran_pucch_cfg_t pucch_cfg = cell_params_.pucch_cfg_common; + pucch_cfg.n_pucch = cc_cfg->nof_cce_table[SRSRAN_NOF_CFI - 1] - 1 + cc_cfg->cfg.n1pucch_an; + pucch_nrb = std::max(pucch_nrb, srsran_pucch_m(&pucch_cfg, cc_cfg->cfg.cell.cp) / 2 + 1); if (pucch_nrb > 0) { pucch_mask.fill(0, pucch_nrb); pucch_mask.fill(cc_cfg->nof_prb() - pucch_nrb, cc_cfg->nof_prb()); @@ -126,14 +126,14 @@ void sf_grid_t::new_tti(tti_point tti_rx_) ul_mask |= pucch_mask; // Reserve PRBs for PRACH - if (srslte_prach_tti_opportunity_config_fdd(cc_cfg->cfg.prach_config, to_tx_ul(tti_rx).to_uint(), -1)) { + if (srsran_prach_tti_opportunity_config_fdd(cc_cfg->cfg.prach_config, to_tx_ul(tti_rx).to_uint(), -1)) { prbmask_t prach_mask{cc_cfg->nof_prb()}; prach_mask.fill(cc_cfg->cfg.prach_freq_offset, cc_cfg->cfg.prach_freq_offset + 6); reserve_ul_prbs(prach_mask, false); // TODO: set to true once test sib.conf files are updated if (logger.debug.enabled()) { fmt::memory_buffer buffer; fmt::format_to(buffer, "SCHED: Allocated PRACH RBs mask={:x} for tti_tx_ul={}", prach_mask, to_tx_ul(tti_rx)); - logger.debug("%s", srslte::to_c_str(buffer)); + logger.debug("%s", srsran::to_c_str(buffer)); } } @@ -197,8 +197,8 @@ alloc_result sf_grid_t::alloc_dl_ctrl(uint32_t aggr_idx, rbg_interval rbg_range, //! Allocates CCEs and RBs for a user DL data alloc. alloc_result sf_grid_t::alloc_dl_data(sched_ue* user, const rbgmask_t& user_mask, bool has_pusch_grant) { - srslte_dci_format_t dci_format = user->get_dci_format(); - uint32_t nof_bits = srslte_dci_format_sizeof(&cc_cfg->cfg.cell, nullptr, nullptr, dci_format); + srsran_dci_format_t dci_format = user->get_dci_format(); + uint32_t nof_bits = srsran_dci_format_sizeof(&cc_cfg->cfg.cell, nullptr, nullptr, dci_format); uint32_t aggr_idx = user->get_aggr_level(cc_cfg->enb_cc_idx, nof_bits); alloc_result ret = alloc_dl(aggr_idx, alloc_type_t::DL_DATA, user_mask, user, has_pusch_grant); @@ -220,7 +220,7 @@ alloc_result sf_grid_t::alloc_ul_data(sched_ue* user, prb_interval alloc, bool n // Generate PDCCH except for RAR and non-adaptive retx if (needs_pdcch) { - uint32_t nof_bits = srslte_dci_format_sizeof(&cc_cfg->cfg.cell, nullptr, nullptr, SRSLTE_DCI_FORMAT0); + uint32_t nof_bits = srsran_dci_format_sizeof(&cc_cfg->cfg.cell, nullptr, nullptr, SRSRAN_DCI_FORMAT0); uint32_t aggr_idx = user->get_aggr_level(cc_cfg->enb_cc_idx, nof_bits); if (not pdcch_alloc.alloc_dci(alloc_type_t::UL_DATA, aggr_idx, user)) { if (logger.debug.enabled()) { @@ -275,7 +275,7 @@ alloc_result sf_grid_t::reserve_ul_prbs(const prbmask_t& prbmask, bool strict) fmt::memory_buffer tmp_buffer; fmt::format_to( tmp_buffer, "There was a collision in the UL. Current mask=0x{:x}, new mask=0x{:x}", ul_mask, prbmask); - logger.info("%s", srslte::to_c_str(tmp_buffer)); + logger.info("%s", srsran::to_c_str(tmp_buffer)); ret = alloc_result::sch_collision; } } @@ -312,7 +312,7 @@ bool sf_grid_t::find_ul_alloc(uint32_t L, prb_interval* alloc) const } // Make sure L is allowed by SC-FDMA modulation - while (!srslte_dft_precoding_valid_prb(alloc->length())) { + while (!srsran_dft_precoding_valid_prb(alloc->length())) { alloc->resize_by(-1); } return alloc->length() == L; @@ -346,7 +346,7 @@ void sf_sched::new_tti(tti_point tti_rx_, sf_sched_result* cc_results_) // setup first prb to be used for msg3 alloc. Account for potential PRACH alloc last_msg3_prb = tti_alloc.get_pucch_width(); tti_point tti_msg3_alloc = to_tx_ul(tti_rx) + MSG3_DELAY_MS; - if (srslte_prach_tti_opportunity_config_fdd(cc_cfg->cfg.prach_config, tti_msg3_alloc.to_uint(), -1)) { + if (srsran_prach_tti_opportunity_config_fdd(cc_cfg->cfg.prach_config, tti_msg3_alloc.to_uint(), -1)) { last_msg3_prb = std::max(last_msg3_prb, cc_cfg->cfg.prach_freq_offset + 6); } } @@ -467,7 +467,7 @@ bool is_periodic_cqi_expected(const sched_interface::ue_cfg_t& ue_cfg, tti_point { for (const sched_interface::ue_cfg_t::cc_cfg_t& cc : ue_cfg.supported_cc_list) { if (cc.dl_cfg.cqi_report.periodic_configured) { - if (srslte_cqi_periodic_send(&cc.dl_cfg.cqi_report, tti_tx_ul.to_uint(), SRSLTE_FDD)) { + if (srsran_cqi_periodic_send(&cc.dl_cfg.cqi_report, tti_tx_ul.to_uint(), SRSRAN_FDD)) { return true; } } @@ -491,7 +491,7 @@ alloc_result sf_sched::alloc_dl_user(sched_ue* user, const rbgmask_t& user_mask, if (cc == nullptr or cc->cc_state() != cc_st::active) { return alloc_result::no_rnti_opportunity; } - if (not user->pdsch_enabled(srslte::tti_point{get_tti_rx()}, cc_cfg->enb_cc_idx)) { + if (not user->pdsch_enabled(srsran::tti_point{get_tti_rx()}, cc_cfg->enb_cc_idx)) { return alloc_result::no_rnti_opportunity; } @@ -506,8 +506,8 @@ alloc_result sf_sched::alloc_dl_user(sched_ue* user, const rbgmask_t& user_mask, } } - srslte_dci_format_t dci_format = user->get_dci_format(); - if (dci_format == SRSLTE_DCI_FORMAT1A and not is_contiguous(user_mask)) { + srsran_dci_format_t dci_format = user->get_dci_format(); + if (dci_format == SRSRAN_DCI_FORMAT1A and not is_contiguous(user_mask)) { logger.warning("SCHED: Can't use distributed RBGs for DCI format 1A"); return alloc_result::invalid_grant_params; } @@ -516,14 +516,14 @@ alloc_result sf_sched::alloc_dl_user(sched_ue* user, const rbgmask_t& user_mask, // Check if there is space in the PUCCH for HARQ ACKs const sched_interface::ue_cfg_t& ue_cfg = user->get_ue_cfg(); - std::bitset scells = user->scell_activation_mask(); + std::bitset scells = user->scell_activation_mask(); uint32_t ue_cc_idx = cc->get_ue_cc_idx(); if (user->nof_carriers_configured() > 1 and (ue_cc_idx == 0 or scells[ue_cc_idx]) and is_periodic_cqi_expected(ue_cfg, get_tti_tx_ul()) and not has_pusch_grant and user->get_ul_harq(get_tti_tx_ul(), get_enb_cc_idx())->is_empty()) { // Try to allocate small PUSCH grant, if there are no allocated PUSCH grants for this TTI yet prb_interval alloc = {}; - uint32_t L = user->get_required_prb_ul(cc_cfg->enb_cc_idx, srslte::ceil_div(SRSLTE_UCI_CQI_CODED_PUCCH_B + 2, 8)); + uint32_t L = user->get_required_prb_ul(cc_cfg->enb_cc_idx, srsran::ceil_div(SRSRAN_UCI_CQI_CODED_PUCCH_B + 2, 8)); tti_alloc.find_ul_alloc(L, &alloc); has_pusch_grant = alloc.length() > 0 and alloc_ul_user(user, alloc) == alloc_result::success; if (ue_cc_idx != 0 and not has_pusch_grant) { @@ -538,7 +538,7 @@ alloc_result sf_sched::alloc_dl_user(sched_ue* user, const rbgmask_t& user_mask, if (ret == alloc_result::no_cch_space and not has_pusch_grant and not data_allocs.empty() and user->get_ul_harq(get_tti_tx_ul(), get_enb_cc_idx())->is_empty()) { // PUCCH may be too full. Attempt small UL grant allocation for UCI-PUSCH - uint32_t L = user->get_required_prb_ul(cc_cfg->enb_cc_idx, srslte::ceil_div(SRSLTE_UCI_CQI_CODED_PUCCH_B + 2, 8)); + uint32_t L = user->get_required_prb_ul(cc_cfg->enb_cc_idx, srsran::ceil_div(SRSRAN_UCI_CQI_CODED_PUCCH_B + 2, 8)); prb_interval alloc = {}; tti_alloc.find_ul_alloc(L, &alloc); has_pusch_grant = alloc.length() > 0 and alloc_ul_user(user, alloc) == alloc_result::success; @@ -679,7 +679,7 @@ void sf_sched::set_dl_data_sched_result(const sf_cch_allocator::alloc_result_t& data_alloc.user_mask, tbs, user->get_requested_dl_bytes(cc_cfg->enb_cc_idx).stop()); - logger.warning("%s", srslte::to_c_str(str_buffer)); + logger.warning("%s", srsran::to_c_str(str_buffer)); continue; } @@ -698,7 +698,7 @@ void sf_sched::set_dl_data_sched_result(const sf_cch_allocator::alloc_result_t& tbs, data_before, user->get_requested_dl_bytes(cc_cfg->enb_cc_idx).stop()); - logger.info("%s", srslte::to_c_str(str_buffer)); + logger.info("%s", srsran::to_c_str(str_buffer)); } } @@ -725,8 +725,8 @@ uci_pusch_t is_uci_included(const sf_sched* sf_sched, uint32_t ueccidx = p.second; // Check if CQI is pending for this CC - const srslte_cqi_report_cfg_t& cqi_report = ue_cfg.supported_cc_list[ueccidx].dl_cfg.cqi_report; - if (srslte_cqi_periodic_send(&cqi_report, sf_sched->get_tti_tx_ul().to_uint(), SRSLTE_FDD)) { + const srsran_cqi_report_cfg_t& cqi_report = ue_cfg.supported_cc_list[ueccidx].dl_cfg.cqi_report; + if (srsran_cqi_periodic_send(&cqi_report, sf_sched->get_tti_tx_ul().to_uint(), SRSRAN_FDD)) { if (uci_alloc == UCI_PUSCH_ACK) { uci_alloc = UCI_PUSCH_ACK_CQI; } else { @@ -800,7 +800,7 @@ void sf_sched::set_ul_sched_result(const sf_cch_allocator::alloc_result_t& dci_r } sched_ue* user = ue_it->second.get(); - srslte_dci_location_t cce_range = {0, 0}; + srsran_dci_location_t cce_range = {0, 0}; if (ul_alloc.needs_pdcch()) { cce_range = dci_result[ul_alloc.dci_idx]->dci_pos; } @@ -836,7 +836,7 @@ void sf_sched::set_ul_sched_result(const sf_cch_allocator::alloc_result_t& dci_r pusch.dci.location.ncce, ul_alloc.alloc, new_pending_bytes); - logger.warning("%s", srslte::to_c_str(str_buffer)); + logger.warning("%s", srsran::to_c_str(str_buffer)); ul_result->pusch.pop_back(); continue; } @@ -860,7 +860,7 @@ void sf_sched::set_ul_sched_result(const sf_cch_allocator::alloc_result_t& dci_r new_pending_bytes, total_data_before, old_pending_bytes); - logger.info("%s", srslte::to_c_str(str_buffer)); + logger.info("%s", srsran::to_c_str(str_buffer)); } pusch.current_tx_nb = h->nof_retx(0); @@ -876,7 +876,7 @@ alloc_result sf_sched::alloc_msg3(sched_ue* user, const sched_interface::dl_sche if (ret != alloc_result::success) { fmt::memory_buffer str_buffer; fmt::format_to(str_buffer, "{}", msg3_alloc); - logger.warning("SCHED: Could not allocate msg3 within %s.", srslte::to_c_str(str_buffer)); + logger.warning("SCHED: Could not allocate msg3 within %s.", srsran::to_c_str(str_buffer)); } return ret; } diff --git a/srsenb/src/stack/mac/sched_helpers.cc b/srsenb/src/stack/mac/sched_helpers.cc index 975053ce5..5c7e003c4 100644 --- a/srsenb/src/stack/mac/sched_helpers.cc +++ b/srsenb/src/stack/mac/sched_helpers.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,9 +11,9 @@ */ #include "srsenb/hdr/stack/mac/sched_helpers.h" -#include "srslte/common/standard_streams.h" -#include "srslte/mac/pdu.h" -#include "srslte/srslog/bundled/fmt/format.h" +#include "srsran/common/standard_streams.h" +#include "srsran/mac/pdu.h" +#include "srsran/srslog/bundled/fmt/format.h" #include @@ -34,22 +34,22 @@ static srslog::basic_logger& get_mac_logger() return mac_logger; } -const char* to_string_short(srslte_dci_format_t dcifmt) +const char* to_string_short(srsran_dci_format_t dcifmt) { switch (dcifmt) { - case SRSLTE_DCI_FORMAT0: + case SRSRAN_DCI_FORMAT0: return "0"; - case SRSLTE_DCI_FORMAT1: + case SRSRAN_DCI_FORMAT1: return "1"; - case SRSLTE_DCI_FORMAT1A: + case SRSRAN_DCI_FORMAT1A: return "1A"; - case SRSLTE_DCI_FORMAT1B: + case SRSRAN_DCI_FORMAT1B: return "1B"; - case SRSLTE_DCI_FORMAT2: + case SRSRAN_DCI_FORMAT2: return "2"; - case SRSLTE_DCI_FORMAT2A: + case SRSRAN_DCI_FORMAT2A: return "2A"; - case SRSLTE_DCI_FORMAT2B: + case SRSRAN_DCI_FORMAT2B: return "2B"; default: return "unknown"; @@ -60,7 +60,7 @@ void fill_dl_cc_result_info(custom_mem_buffer& strbuf, const dl_sched_data_t& da { uint32_t first_ce = sched_interface::MAX_RLC_PDU_LIST; for (uint32_t i = 0; i < data.nof_pdu_elems[0]; ++i) { - if (srslte::is_mac_ce(static_cast(data.pdu[i]->lcid))) { + if (srsran::is_mac_ce(static_cast(data.pdu[i]->lcid))) { first_ce = i; break; } @@ -74,9 +74,9 @@ void fill_dl_cc_result_info(custom_mem_buffer& strbuf, const dl_sched_data_t& da for (uint32_t i = 0; i < data.nof_pdu_elems[0]; ++i) { const auto& pdu = data.pdu[0][i]; prefix = (ces_found) ? " | " : ""; - srslte::dl_sch_lcid lcid = static_cast(pdu.lcid); - if (srslte::is_mac_ce(lcid)) { - fmt::format_to(strbuf, "{}CE \"{}\"", prefix, srslte::to_string_short(lcid)); + srsran::dl_sch_lcid lcid = static_cast(pdu.lcid); + if (srsran::is_mac_ce(lcid)) { + fmt::format_to(strbuf, "{}CE \"{}\"", prefix, srsran::to_string_short(lcid)); ces_found = true; } } @@ -94,13 +94,13 @@ void fill_dl_cc_result_debug(custom_mem_buffer& strbuf, const dl_sched_data_t& d data.tbs[0], to_string_short(data.dci.format), data.dci.tb[0].mcs_idx); - for (uint32_t tb = 0; tb < SRSLTE_MAX_TB; ++tb) { + for (uint32_t tb = 0; tb < SRSRAN_MAX_TB; ++tb) { for (uint32_t i = 0; i < data.nof_pdu_elems[tb]; ++i) { const auto& pdu = data.pdu[tb][i]; const char* prefix = (i == 0) ? "" : " | "; - srslte::dl_sch_lcid lcid = static_cast(pdu.lcid); - if (srslte::is_mac_ce(lcid)) { - fmt::format_to(strbuf, "{}CE \"{}\"", prefix, srslte::to_string_short(lcid)); + srsran::dl_sch_lcid lcid = static_cast(pdu.lcid); + if (srsran::is_mac_ce(lcid)) { + fmt::format_to(strbuf, "{}CE \"{}\"", prefix, srsran::to_string_short(lcid)); } else { fmt::format_to(strbuf, "{}SDU lcid={}, tb={}, len={} B", prefix, pdu.lcid, tb, pdu.nbytes); } @@ -154,7 +154,7 @@ void log_phich_cc_results(srslog::basic_logger& logger, prb_interval prb_interval::rbgs_to_prbs(const rbg_interval& rbgs, uint32_t cell_nof_prb) { - uint32_t P = srslte_ra_type0_P(cell_nof_prb); + uint32_t P = srsran_ra_type0_P(cell_nof_prb); return prb_interval{rbgs.start() * P, std::min(rbgs.stop() * P, cell_nof_prb)}; } @@ -185,7 +185,7 @@ prb_interval prb_interval::riv_to_prbs(uint32_t riv, uint32_t nof_prbs, int nof_ nof_vrbs = nof_prbs; } uint32_t rb_start, l_crb; - srslte_ra_type2_from_riv(riv, &l_crb, &rb_start, nof_prbs, (uint32_t)nof_vrbs); + srsran_ra_type2_from_riv(riv, &l_crb, &rb_start, nof_prbs, (uint32_t)nof_vrbs); return {rb_start, rb_start + l_crb}; } @@ -198,19 +198,19 @@ bool is_contiguous(const rbgmask_t& mask) * Sched Params *******************************************************/ -sched_cell_params_t::dl_nof_re_table generate_nof_re_table(const srslte_cell_t& cell) +sched_cell_params_t::dl_nof_re_table generate_nof_re_table(const srsran_cell_t& cell) { sched_cell_params_t::dl_nof_re_table table(cell.nof_prb); - srslte_dl_sf_cfg_t dl_sf = {}; - dl_sf.sf_type = SRSLTE_SF_NORM; + srsran_dl_sf_cfg_t dl_sf = {}; + dl_sf.sf_type = SRSRAN_SF_NORM; dl_sf.tdd_config.configured = false; - for (uint32_t cfi = 0; cfi < SRSLTE_NOF_CFI; ++cfi) { + for (uint32_t cfi = 0; cfi < SRSRAN_NOF_CFI; ++cfi) { dl_sf.cfi = cfi + 1; - for (uint32_t sf_idx = 0; sf_idx < SRSLTE_NOF_SF_X_FRAME; ++sf_idx) { + for (uint32_t sf_idx = 0; sf_idx < SRSRAN_NOF_SF_X_FRAME; ++sf_idx) { dl_sf.tti = sf_idx; - for (uint32_t s = 0; s < SRSLTE_NOF_SLOTS_PER_SF; ++s) { + for (uint32_t s = 0; s < SRSRAN_NOF_SLOTS_PER_SF; ++s) { for (uint32_t n = 0; n < cell.nof_prb; ++n) { table[n][sf_idx][s][cfi] = ra_re_x_prb(&cell, &dl_sf, s, n); } @@ -223,17 +223,17 @@ sched_cell_params_t::dl_nof_re_table generate_nof_re_table(const srslte_cell_t& sched_cell_params_t::dl_lb_nof_re_table get_lb_nof_re_x_prb(const sched_cell_params_t::dl_nof_re_table& table) { sched_cell_params_t::dl_lb_nof_re_table ret; - for (uint32_t sf_idx = 0; sf_idx < SRSLTE_NOF_SF_X_FRAME; ++sf_idx) { + for (uint32_t sf_idx = 0; sf_idx < SRSRAN_NOF_SF_X_FRAME; ++sf_idx) { ret[sf_idx].resize(table.size()); - srslte::bounded_vector re_prb_vec(table.size()); + srsran::bounded_vector re_prb_vec(table.size()); for (uint32_t p = 0; p < table.size(); ++p) { - for (uint32_t s = 0; s < SRSLTE_NOF_SLOTS_PER_SF; ++s) { + for (uint32_t s = 0; s < SRSRAN_NOF_SLOTS_PER_SF; ++s) { // assume max CFI to compute lower bound - re_prb_vec[p] += table[p][sf_idx][s][SRSLTE_NOF_CFI - 1]; + re_prb_vec[p] += table[p][sf_idx][s][SRSRAN_NOF_CFI - 1]; } } - srslte::bounded_vector re_prb_vec2(re_prb_vec.size()); + srsran::bounded_vector re_prb_vec2(re_prb_vec.size()); std::copy(re_prb_vec.begin(), re_prb_vec.end(), re_prb_vec2.begin()); // pick intervals of PRBs with the lowest sum of REs ret[sf_idx][0] = *std::min_element(re_prb_vec2.begin(), re_prb_vec2.end()); @@ -250,10 +250,10 @@ sched_cell_params_t::dl_lb_nof_re_table get_lb_nof_re_x_prb(const sched_cell_par return ret; } -void sched_cell_params_t::regs_deleter::operator()(srslte_regs_t* p) +void sched_cell_params_t::regs_deleter::operator()(srsran_regs_t* p) { if (p != nullptr) { - srslte_regs_free(p); + srsran_regs_free(p); delete p; } } @@ -276,7 +276,7 @@ bool sched_cell_params_t::set_cfg(uint32_t enb_cc_id if (cfg.cell.nof_prb == 6) { // PUCCH has to allow space for Msg3 if (cfg.nrb_pucch > 1) { - srslte::console("Invalid PUCCH configuration: nrb_pucch=%d does not allow space for Msg3 transmission..\n", + srsran::console("Invalid PUCCH configuration: nrb_pucch=%d does not allow space for Msg3 transmission..\n", cfg.nrb_pucch); return false; } @@ -289,7 +289,7 @@ bool sched_cell_params_t::set_cfg(uint32_t enb_cc_id } if (invalid_prach) { Error("Invalid PRACH configuration: frequency offset=%d outside bandwidth limits", cfg.prach_freq_offset); - srslte::console("Invalid PRACH configuration: frequency offset=%d outside bandwidth limits\n", + srsran::console("Invalid PRACH configuration: frequency offset=%d outside bandwidth limits\n", cfg.prach_freq_offset); return false; } @@ -297,35 +297,35 @@ bool sched_cell_params_t::set_cfg(uint32_t enb_cc_id // Set derived sched parameters // init regs - regs.reset(new srslte_regs_t{}); - if (srslte_regs_init(regs.get(), cfg.cell) != SRSLTE_SUCCESS) { + regs.reset(new srsran_regs_t{}); + if (srsran_regs_init(regs.get(), cfg.cell) != SRSRAN_SUCCESS) { Error("Getting DCI locations"); return false; } // Compute Common locations for DCI for each CFI - for (uint32_t cfix = 0; cfix < SRSLTE_NOF_CFI; cfix++) { + for (uint32_t cfix = 0; cfix < SRSRAN_NOF_CFI; cfix++) { generate_cce_location(regs.get(), common_locations[cfix], cfix + 1); } if (common_locations[sched_cfg->max_nof_ctrl_symbols - 1][2].empty()) { Error("SCHED: Current cfi=%d is not valid for broadcast (check scheduler.max_nof_ctrl_symbols in conf file).", sched_cfg->max_nof_ctrl_symbols); - srslte::console( + srsran::console( "SCHED: Current cfi=%d is not valid for broadcast (check scheduler.max_nof_ctrl_symbols in conf file).\n", sched_cfg->max_nof_ctrl_symbols); return false; } // Compute UE locations for RA-RNTI - for (uint32_t cfi = 0; cfi < SRSLTE_NOF_CFI; cfi++) { - for (uint32_t sf_idx = 0; sf_idx < SRSLTE_NOF_SF_X_FRAME; sf_idx++) { + for (uint32_t cfi = 0; cfi < SRSRAN_NOF_CFI; cfi++) { + for (uint32_t sf_idx = 0; sf_idx < SRSRAN_NOF_SF_X_FRAME; sf_idx++) { generate_cce_location(regs.get(), rar_locations[sf_idx][cfi], cfi + 1, sf_idx); } } // precompute nof cces in PDCCH for each CFI for (uint32_t cfix = 0; cfix < nof_cce_table.size(); ++cfix) { - int ret = srslte_regs_pdcch_ncce(regs.get(), cfix + 1); + int ret = srsran_regs_pdcch_ncce(regs.get(), cfix + 1); if (ret < 0) { Error("SCHED: Failed to calculate the number of CCEs in the PDCCH"); return false; @@ -334,14 +334,14 @@ bool sched_cell_params_t::set_cfg(uint32_t enb_cc_id } // PUCCH config struct for PUCCH position derivation - pucch_cfg_common.format = SRSLTE_PUCCH_FORMAT_1; + pucch_cfg_common.format = SRSRAN_PUCCH_FORMAT_1; pucch_cfg_common.delta_pucch_shift = cfg.delta_pucch_shift; pucch_cfg_common.n_rb_2 = cfg.nrb_cqi; pucch_cfg_common.N_cs = cfg.ncs_an; pucch_cfg_common.N_pucch_1 = cfg.n1pucch_an; - P = srslte_ra_type0_P(cfg.cell.nof_prb); - nof_rbgs = srslte::ceil_div(cfg.cell.nof_prb, P); + P = srsran_ra_type0_P(cfg.cell.nof_prb); + nof_rbgs = srsran::ceil_div(cfg.cell.nof_prb, P); nof_re_table = generate_nof_re_table(cfg.cell); nof_re_lb_table = get_lb_nof_re_x_prb(nof_re_table); @@ -359,23 +359,23 @@ uint32_t sched_cell_params_t::get_dl_lb_nof_re(tti_point tti_tx_dl, uint32_t nof uint32_t nof_re = nof_re_lb_table[sf_idx][nof_prbs_alloc - 1]; // sanity check - assert(nof_re <= srslte_ra_dl_approx_nof_re(&cfg.cell, nof_prbs_alloc, SRSLTE_NOF_CFI)); + assert(nof_re <= srsran_ra_dl_approx_nof_re(&cfg.cell, nof_prbs_alloc, SRSRAN_NOF_CFI)); return nof_re; } uint32_t -sched_cell_params_t::get_dl_nof_res(srslte::tti_point tti_tx_dl, const srslte_dci_dl_t& dci, uint32_t cfi) const +sched_cell_params_t::get_dl_nof_res(srsran::tti_point tti_tx_dl, const srsran_dci_dl_t& dci, uint32_t cfi) const { assert(cfi > 0 && "CFI has to be within (1..3)"); - srslte_pdsch_grant_t grant = {}; - srslte_dl_sf_cfg_t dl_sf = {}; + srsran_pdsch_grant_t grant = {}; + srsran_dl_sf_cfg_t dl_sf = {}; dl_sf.cfi = cfi; dl_sf.tti = tti_tx_dl.to_uint(); - srslte_ra_dl_grant_to_grant_prb_allocation(&dci, &grant, nof_prb()); + srsran_ra_dl_grant_to_grant_prb_allocation(&dci, &grant, nof_prb()); uint32_t nof_re = 0; for (uint32_t p = 0; p < nof_prb(); ++p) { - for (uint32_t s = 0; s < SRSLTE_NOF_SLOTS_PER_SF; ++s) { + for (uint32_t s = 0; s < SRSRAN_NOF_SLOTS_PER_SF; ++s) { if (grant.prb_idx[s][p]) { nof_re += nof_re_table[p][tti_tx_dl.sf_idx()][s][cfi - 1]; } @@ -389,15 +389,15 @@ cce_frame_position_table generate_cce_location_table(uint16_t rnti, const sched_ { cce_frame_position_table dci_locations = {}; // Generate allowed CCE locations - for (int cfi = 0; cfi < SRSLTE_NOF_CFI; cfi++) { - for (int sf_idx = 0; sf_idx < SRSLTE_NOF_SF_X_FRAME; sf_idx++) { + for (int cfi = 0; cfi < SRSRAN_NOF_CFI; cfi++) { + for (int sf_idx = 0; sf_idx < SRSRAN_NOF_SF_X_FRAME; sf_idx++) { generate_cce_location(cell_cfg.regs.get(), dci_locations[sf_idx][cfi], cfi + 1, sf_idx, rnti); } } return dci_locations; } -void generate_cce_location(srslte_regs_t* regs_, +void generate_cce_location(srsran_regs_t* regs_, cce_cfi_position_table& locations, uint32_t cfi, uint32_t sf_idx, @@ -405,12 +405,12 @@ void generate_cce_location(srslte_regs_t* regs_, { locations = {}; - srslte_dci_location_t loc[64]; + srsran_dci_location_t loc[64]; uint32_t nloc = 0; if (rnti == 0) { - nloc = srslte_pdcch_common_locations_ncce(srslte_regs_pdcch_ncce(regs_, cfi), loc, 64); + nloc = srsran_pdcch_common_locations_ncce(srsran_regs_pdcch_ncce(regs_, cfi), loc, 64); } else { - nloc = srslte_pdcch_ue_locations_ncce(srslte_regs_pdcch_ncce(regs_, cfi), loc, 64, sf_idx, rnti); + nloc = srsran_pdcch_ue_locations_ncce(srsran_regs_pdcch_ncce(regs_, cfi), loc, 64, sf_idx, rnti); } // Save to different format @@ -428,7 +428,7 @@ uint32_t get_aggr_level(uint32_t nof_bits, uint32_t dl_cqi, uint32_t max_aggr_lvl, uint32_t cell_nof_prb, bool use_tbs_index_alt) { uint32_t l = 0; - float max_coderate = srslte_cqi_to_coderate(dl_cqi, use_tbs_index_alt); + float max_coderate = srsran_cqi_to_coderate(dl_cqi, use_tbs_index_alt); float coderate; float factor = 1.5; uint32_t l_max = 3; @@ -436,10 +436,10 @@ get_aggr_level(uint32_t nof_bits, uint32_t dl_cqi, uint32_t max_aggr_lvl, uint32 factor = 1.0; l_max = 2; } - l_max = SRSLTE_MIN(max_aggr_lvl, l_max); + l_max = SRSRAN_MIN(max_aggr_lvl, l_max); do { - coderate = srslte_pdcch_coderate(nof_bits, l); + coderate = srsran_pdcch_coderate(nof_bits, l); l++; } while (l < l_max && factor * coderate > max_coderate); @@ -462,7 +462,7 @@ int check_ue_cfg_correctness(const sched_interface::ue_cfg_t& ue_cfg) using cc_t = sched_interface::ue_cfg_t::cc_cfg_t; const auto& cc_list = ue_cfg.supported_cc_list; bool has_scells = std::count_if(cc_list.begin(), cc_list.end(), [](const cc_t& c) { return c.active; }) > 1; - int ret = SRSLTE_SUCCESS; + int ret = SRSRAN_SUCCESS; if (has_scells) { // In case of CA, CQI configs must exist and cannot collide in the PUCCH @@ -473,13 +473,13 @@ int check_ue_cfg_correctness(const sched_interface::ue_cfg_t& ue_cfg) } if (not cc1.dl_cfg.cqi_report.periodic_configured and not cc1.dl_cfg.cqi_report.aperiodic_configured) { Warning("SCHED: No CQI configuration was provided for UE scell index=%d", i); - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } else if (cc1.dl_cfg.cqi_report.periodic_configured) { for (uint32_t j = i + 1; j < cc_list.size(); ++j) { if (cc_list[j].active and cc_list[j].dl_cfg.cqi_report.periodic_configured and cc_list[j].dl_cfg.cqi_report.pmi_idx == cc1.dl_cfg.cqi_report.pmi_idx) { Warning("SCHED: The provided CQI configurations for UE scells %d and %d collide in time resources.", i, j); - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } } } diff --git a/srsenb/src/stack/mac/sched_phy_ch/sched_dci.cc b/srsenb/src/stack/mac/sched_phy_ch/sched_dci.cc index 51b636cd1..c1b821d77 100644 --- a/srsenb/src/stack/mac/sched_phy_ch/sched_dci.cc +++ b/srsenb/src/stack/mac/sched_phy_ch/sched_dci.cc @@ -1,11 +1,11 @@ /** * - * \section copyright + * \section COPYRIGHT * - * copyright 2013-2020 software radio systems limited + * Copyright 2013-2021 Software Radio Systems Limited * - * by using this file, you agree to the terms and conditions set - * forth in the license file which can be found at the top level of + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of * the distribution. * */ @@ -13,7 +13,7 @@ #include "srsenb/hdr/stack/mac/sched_phy_ch/sched_dci.h" #include "srsenb/hdr/stack/mac/sched_common.h" #include "srsenb/hdr/stack/mac/sched_helpers.h" -#include "srslte/common/string_helpers.h" +#include "srsran/common/string_helpers.h" #include #include @@ -45,9 +45,9 @@ int compute_mcs_from_max_tbs(uint32_t nof_prb, // Compute I_TBS based on max TBS uint32_t max_tbs_idx = (use_tbs_index_alt) ? 33 : 26; - tbs_idx = srslte_ra_tbs_to_table_idx(max_tbs, nof_prb, max_tbs_idx); + tbs_idx = srsran_ra_tbs_to_table_idx(max_tbs, nof_prb, max_tbs_idx); if (tbs_idx <= 0) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } --tbs_idx; // get TBS index lower bound if (use_tbs_index_alt and @@ -57,17 +57,17 @@ int compute_mcs_from_max_tbs(uint32_t nof_prb, } // Compute I_mcs based on I_TBS. Reverse of TS 36.213 - Table 7.1.7.1-1/1A - mcs = srslte_ra_mcs_from_tbs_idx(tbs_idx, use_tbs_index_alt, is_ul); + mcs = srsran_ra_mcs_from_tbs_idx(tbs_idx, use_tbs_index_alt, is_ul); if (mcs < 0) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (mcs > (int)max_mcs) { // bound mcs mcs = max_mcs; - tbs_idx = srslte_ra_tbs_idx_from_mcs(mcs, use_tbs_index_alt, is_ul); + tbs_idx = srsran_ra_tbs_idx_from_mcs(mcs, use_tbs_index_alt, is_ul); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } tbs_info compute_mcs_and_tbs(uint32_t nof_prb, @@ -81,7 +81,7 @@ tbs_info compute_mcs_and_tbs(uint32_t nof_prb, assert((not is_ul or not use_tbs_index_alt) && "UL cannot use Alt CQI Table"); assert((is_ul or not ulqam64_enabled) && "DL cannot use UL-QAM64 enable flag"); - float max_coderate = srslte_cqi_to_coderate(std::min(cqi + 1U, 15U), use_tbs_index_alt); + float max_coderate = srsran_cqi_to_coderate(std::min(cqi + 1U, 15U), use_tbs_index_alt); uint32_t max_Qm = (is_ul) ? (ulqam64_enabled ? 6 : 4) : (use_tbs_index_alt ? 8 : 6); max_coderate = std::min(max_coderate, 0.932F * max_Qm); @@ -96,7 +96,7 @@ tbs_info compute_mcs_and_tbs(uint32_t nof_prb, // Compute max {MCS,I_TBS} based on given max_tbs, nof_prb int tbs_idx = 0; - if (compute_mcs_from_max_tbs(nof_prb, max_tbs, max_mcs, is_ul, use_tbs_index_alt, mcs, tbs_idx) != SRSLTE_SUCCESS) { + if (compute_mcs_from_max_tbs(nof_prb, max_tbs, max_mcs, is_ul, use_tbs_index_alt, mcs, tbs_idx) != SRSRAN_SUCCESS) { return tbs_info{}; } @@ -107,12 +107,12 @@ tbs_info compute_mcs_and_tbs(uint32_t nof_prb, } // compute real TBS and coderate based on maximum achievable MCS - int tbs = srslte_ra_tbs_from_idx(tbs_idx, nof_prb); - float coderate = srslte_coderate(tbs, nof_re); + int tbs = srsran_ra_tbs_from_idx(tbs_idx, nof_prb); + float coderate = srsran_coderate(tbs, nof_re); // update max coderate based on mcs - srslte_mod_t mod = (is_ul) ? srslte_ra_ul_mod_from_mcs(mcs) : srslte_ra_dl_mod_from_mcs(mcs, use_tbs_index_alt); - uint32_t Qm = srslte_mod_bits_x_symbol(mod); + srsran_mod_t mod = (is_ul) ? srsran_ra_ul_mod_from_mcs(mcs) : srsran_ra_dl_mod_from_mcs(mcs, use_tbs_index_alt); + uint32_t Qm = srsran_mod_bits_x_symbol(mod); max_coderate = std::min(0.932F * Qm, max_coderate); if (coderate <= max_coderate) { @@ -152,7 +152,7 @@ tbs_info compute_min_mcs_and_tbs_from_required_bytes(uint32_t nof_prb, // Note: we subtract -1 to required data to get an exclusive lower bound for maximum MCS. This works ok because // req_bytes * 8 is always even if (compute_mcs_from_max_tbs(nof_prb, req_bytes * 8U - 1, max_mcs, is_ul, use_tbs_index_alt, mcs_min, tbs_idx_min) != - SRSLTE_SUCCESS) { + SRSRAN_SUCCESS) { // Failed to compute maximum MCS that leads to TBS < req bytes. MCS=0 is likely a valid solution tbs_info tb2 = compute_mcs_and_tbs(nof_prb, nof_re, cqi, 0, is_ul, ulqam64_enabled, use_tbs_index_alt); if (tb2.tbs_bytes >= (int)req_bytes) { @@ -171,7 +171,7 @@ tbs_info compute_min_mcs_and_tbs_from_required_bytes(uint32_t nof_prb, return tb_max; } -int generate_ra_bc_dci_format1a_common(srslte_dci_dl_t& dci, +int generate_ra_bc_dci_format1a_common(srsran_dci_dl_t& dci, uint16_t rnti, tti_point tti_tx_dl, uint32_t req_bytes, @@ -180,22 +180,22 @@ int generate_ra_bc_dci_format1a_common(srslte_dci_dl_t& dci, uint32_t current_cfi) { static const uint32_t Qm = 2, bc_rar_cqi = 4; - static const float max_ctrl_coderate = std::min(srslte_cqi_to_coderate(bc_rar_cqi + 1, false), 0.932F * Qm); + static const float max_ctrl_coderate = std::min(srsran_cqi_to_coderate(bc_rar_cqi + 1, false), 0.932F * Qm); // Calculate I_tbs for this TBS int tbs = static_cast(req_bytes) * 8; int mcs = -1; for (uint32_t i = 0; i < 27; i++) { - if (srslte_ra_tbs_from_idx(i, 2) >= tbs) { - dci.type2_alloc.n_prb1a = srslte_ra_type2_t::SRSLTE_RA_TYPE2_NPRB1A_2; + if (srsran_ra_tbs_from_idx(i, 2) >= tbs) { + dci.type2_alloc.n_prb1a = srsran_ra_type2_t::SRSRAN_RA_TYPE2_NPRB1A_2; mcs = i; - tbs = srslte_ra_tbs_from_idx(i, 2); + tbs = srsran_ra_tbs_from_idx(i, 2); break; } - if (srslte_ra_tbs_from_idx(i, 3) >= tbs) { - dci.type2_alloc.n_prb1a = srslte_ra_type2_t::SRSLTE_RA_TYPE2_NPRB1A_3; + if (srsran_ra_tbs_from_idx(i, 3) >= tbs) { + dci.type2_alloc.n_prb1a = srsran_ra_type2_t::SRSRAN_RA_TYPE2_NPRB1A_3; mcs = i; - tbs = srslte_ra_tbs_from_idx(i, 3); + tbs = srsran_ra_tbs_from_idx(i, 3); break; } } @@ -205,26 +205,26 @@ int generate_ra_bc_dci_format1a_common(srslte_dci_dl_t& dci, } // Generate remaining DCI Format1A content - dci.alloc_type = SRSLTE_RA_ALLOC_TYPE2; - dci.type2_alloc.mode = srslte_ra_type2_t::SRSLTE_RA_TYPE2_LOC; + dci.alloc_type = SRSRAN_RA_ALLOC_TYPE2; + dci.type2_alloc.mode = srsran_ra_type2_t::SRSRAN_RA_TYPE2_LOC; prb_interval prb_range = prb_interval::rbgs_to_prbs(rbg_range, cell_params.nof_prb()); - dci.type2_alloc.riv = srslte_ra_type2_to_riv(prb_range.length(), prb_range.start(), cell_params.nof_prb()); + dci.type2_alloc.riv = srsran_ra_type2_to_riv(prb_range.length(), prb_range.start(), cell_params.nof_prb()); dci.pid = 0; dci.tb[0].mcs_idx = mcs; dci.tb[0].rv = 0; // used for SIBs - dci.format = SRSLTE_DCI_FORMAT1A; + dci.format = SRSRAN_DCI_FORMAT1A; dci.rnti = rnti; dci.ue_cc_idx = std::numeric_limits::max(); // Compute effective code rate and verify it doesn't exceed max code rate uint32_t nof_re = cell_params.get_dl_nof_res(tti_tx_dl, dci, current_cfi); - if (srslte_coderate(tbs, nof_re) >= max_ctrl_coderate) { + if (srsran_coderate(tbs, nof_re) >= max_ctrl_coderate) { return -1; } get_mac_logger().debug("ra_tbs=%d/%d, tbs_bytes=%d, tbs=%d, mcs=%d", - srslte_ra_tbs_from_idx(mcs, 2), - srslte_ra_tbs_from_idx(mcs, 3), + srsran_ra_tbs_from_idx(mcs, 2), + srsran_ra_tbs_from_idx(mcs, 3), req_bytes, tbs, mcs); @@ -242,7 +242,7 @@ bool generate_sib_dci(sched_interface::dl_sched_bc_t& bc, { bc = {}; int tbs_bits = generate_ra_bc_dci_format1a_common( - bc.dci, SRSLTE_SIRNTI, tti_tx_dl, cell_params.cfg.sibs[sib_idx].len, rbg_range, cell_params, current_cfi); + bc.dci, SRSRAN_SIRNTI, tti_tx_dl, cell_params.cfg.sibs[sib_idx].len, rbg_range, cell_params, current_cfi); if (tbs_bits < 0) { return false; } @@ -266,7 +266,7 @@ bool generate_paging_dci(sched_interface::dl_sched_bc_t& bc, { bc = {}; int tbs_bits = generate_ra_bc_dci_format1a_common( - bc.dci, SRSLTE_PRNTI, tti_tx_dl, req_bytes, rbg_range, cell_params, current_cfi); + bc.dci, SRSRAN_PRNTI, tti_tx_dl, req_bytes, rbg_range, cell_params, current_cfi); if (tbs_bits < 0) { return false; } @@ -302,7 +302,7 @@ bool generate_rar_dci(sched_interface::dl_sched_rar_t& rar, rar.msg3_grant[i].data = pending_rar.msg3_grant[i]; rar.msg3_grant[i].grant.tpc_pusch = 3; rar.msg3_grant[i].grant.trunc_mcs = 0; - rar.msg3_grant[i].grant.rba = srslte_ra_type2_to_riv(msg3_Lcrb, start_msg3_prb, cell_params.nof_prb()); + rar.msg3_grant[i].grant.rba = srsran_ra_type2_to_riv(msg3_Lcrb, start_msg3_prb, cell_params.nof_prb()); start_msg3_prb += msg3_Lcrb; } @@ -338,7 +338,7 @@ void log_broadcast_allocation(const sched_interface::dl_sched_bc_t& bc, } else { get_mac_logger().info("SCHED: PCH, cc=%d, rbgs=%s, dci=(%d,%d), tbs=%d, mcs=%d", cell_params.enb_cc_idx, - srslte::to_c_str(str_buffer), + srsran::to_c_str(str_buffer), bc.dci.location.L, bc.dci.location.ncce, bc.tbs, @@ -367,10 +367,10 @@ void log_rar_allocation(const sched_interface::dl_sched_rar_t& rar, rbg_interval get_mac_logger().info("SCHED: RAR, ra-rnti=%d, rbgs=%s, dci=(%d,%d), msg3 grants=[%s]", rar.dci.rnti, - srslte::to_c_str(str_buffer), + srsran::to_c_str(str_buffer), rar.dci.location.L, rar.dci.location.ncce, - srslte::to_c_str(str_buffer2)); + srsran::to_c_str(str_buffer2)); } } // namespace srsenb diff --git a/srsenb/src/stack/mac/sched_phy_ch/sf_cch_allocator.cc b/srsenb/src/stack/mac/sched_phy_ch/sf_cch_allocator.cc index 264d43fb3..727479b95 100644 --- a/srsenb/src/stack/mac/sched_phy_ch/sf_cch_allocator.cc +++ b/srsenb/src/stack/mac/sched_phy_ch/sf_cch_allocator.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -12,13 +12,13 @@ #include "srsenb/hdr/stack/mac/sched_phy_ch/sf_cch_allocator.h" #include "srsenb/hdr/stack/mac/sched_grid.h" -#include "srslte/srslog/bundled/fmt/format.h" +#include "srsran/srslog/bundled/fmt/format.h" namespace srsenb { -bool is_pucch_sr_collision(const srslte_pucch_cfg_t& ue_pucch_cfg, tti_point tti_tx_dl_ack, uint32_t n1_pucch) +bool is_pucch_sr_collision(const srsran_pucch_cfg_t& ue_pucch_cfg, tti_point tti_tx_dl_ack, uint32_t n1_pucch) { - if (ue_pucch_cfg.sr_configured && srslte_ue_ul_sr_send_tti(&ue_pucch_cfg, tti_tx_dl_ack.to_uint())) { + if (ue_pucch_cfg.sr_configured && srsran_ue_ul_sr_send_tti(&ue_pucch_cfg, tti_tx_dl_ack.to_uint())) { return n1_pucch == ue_pucch_cfg.n_pucch_sr; } return false; @@ -150,7 +150,7 @@ bool sf_cch_allocator::alloc_dfs_node(const alloc_record& record, uint32_t start tree_node node; node.dci_pos_idx = start_dci_idx; node.dci_pos.L = record.aggr_idx; - node.rnti = record.user != nullptr ? record.user->get_rnti() : SRSLTE_INVALID_RNTI; + node.rnti = record.user != nullptr ? record.user->get_rnti() : SRSRAN_INVALID_RNTI; node.current_mask.resize(nof_cces()); // get cumulative pdcch & pucch masks if (not last_dci_dfs.empty()) { @@ -173,7 +173,7 @@ bool sf_cch_allocator::alloc_dfs_node(const alloc_record& record, uint32_t start continue; } - node.pucch_n_prb = srslte_pucch_n_prb(&cc_cfg->cfg.cell, &pucch_cfg_common, 0); + node.pucch_n_prb = srsran_pucch_n_prb(&cc_cfg->cfg.cell, &pucch_cfg_common, 0); if (not cc_cfg->sched_cfg->pucch_mux_enabled and node.total_pucch_mask.test(node.pucch_n_prb)) { // PUCCH allocation would collide with other PUCCH/PUSCH grants. Try another CCE position continue; diff --git a/srsenb/src/stack/mac/sched_ue.cc b/srsenb/src/stack/mac/sched_ue.cc index 8b8bc765c..b4da8e730 100644 --- a/srsenb/src/stack/mac/sched_ue.cc +++ b/srsenb/src/stack/mac/sched_ue.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -15,10 +15,10 @@ #include "srsenb/hdr/stack/mac/sched.h" #include "srsenb/hdr/stack/mac/sched_helpers.h" #include "srsenb/hdr/stack/mac/sched_ue.h" -#include "srslte/common/string_helpers.h" -#include "srslte/srslog/bundled/fmt/ranges.h" +#include "srsran/common/string_helpers.h" +#include "srsran/srslog/bundled/fmt/ranges.h" -using srslte::tti_interval; +using srsran::tti_interval; namespace srsenb { @@ -81,7 +81,7 @@ void sched_ue::set_cfg(const ue_cfg_t& cfg_) logger.info("SCHED: rnti=0x%x PCell is now enb_cc_idx=%d", rnti, cfg.supported_cc_list[0].enb_cc_idx); } if (scell_activation_state_changed) { - lch_handler.pending_ces.emplace_back(srslte::dl_sch_lcid::SCELL_ACTIVATION); + lch_handler.pending_ces.emplace_back(srsran::dl_sch_lcid::SCELL_ACTIVATION); logger.info("SCHED: Enqueueing SCell Activation CMD for rnti=0x%x", rnti); } @@ -193,7 +193,7 @@ tti_point nearest_meas_gap(tti_point tti, uint32_t period, uint32_t offset) offset}; } -bool sched_ue::pdsch_enabled(srslte::tti_point tti_rx, uint32_t enb_cc_idx) const +bool sched_ue::pdsch_enabled(srsran::tti_point tti_rx, uint32_t enb_cc_idx) const { if (cfg.supported_cc_list[0].enb_cc_idx != enb_cc_idx) { return true; @@ -300,7 +300,7 @@ void sched_ue::set_ul_snr(tti_point tti_rx, uint32_t enb_cc_idx, float snr, uint { if (cells[enb_cc_idx].cc_state() != cc_st::idle) { cells[enb_cc_idx].tpc_fsm.set_snr(snr, ul_ch_code); - cells[enb_cc_idx].ul_cqi = srslte_cqi_from_snr(snr); + cells[enb_cc_idx].ul_cqi = srsran_cqi_from_snr(snr); cells[enb_cc_idx].ul_cqi_tti_rx = tti_rx; } else { logger.warning("Received SNR info for invalid cell index %d", enb_cc_idx); @@ -325,7 +325,7 @@ tbs_info sched_ue::allocate_new_dl_mac_pdu(sched::dl_sched_data_t* data, uint32_t cfi, uint32_t tb) { - srslte_dci_dl_t* dci = &data->dci; + srsran_dci_dl_t* dci = &data->dci; uint32_t nof_prb = count_prb_per_tb(user_mask); tbs_info tb_info = compute_mcs_and_tbs(enb_cc_idx, tti_tx_dl, nof_prb, cfi, *dci); @@ -367,27 +367,27 @@ int sched_ue::generate_dl_dci_format(uint32_t pid, uint32_t cfi, const rbgmask_t& user_mask) { - srslte_dci_format_t dci_format = get_dci_format(); + srsran_dci_format_t dci_format = get_dci_format(); int tbs_bytes = 0; // Set common DCI fields - srslte_dci_dl_t* dci = &data->dci; + srsran_dci_dl_t* dci = &data->dci; dci->rnti = rnti; dci->pid = pid; dci->ue_cc_idx = cells[enb_cc_idx].get_ue_cc_idx(); dci->format = dci_format; switch (dci_format) { - case SRSLTE_DCI_FORMAT1A: + case SRSRAN_DCI_FORMAT1A: tbs_bytes = generate_format1a(pid, data, tti_tx_dl, enb_cc_idx, cfi, user_mask); break; - case SRSLTE_DCI_FORMAT1: + case SRSRAN_DCI_FORMAT1: tbs_bytes = generate_format1(pid, data, tti_tx_dl, enb_cc_idx, cfi, user_mask); break; - case SRSLTE_DCI_FORMAT2: + case SRSRAN_DCI_FORMAT2: tbs_bytes = generate_format2(pid, data, tti_tx_dl, enb_cc_idx, cfi, user_mask); break; - case SRSLTE_DCI_FORMAT2A: + case SRSRAN_DCI_FORMAT2A: tbs_bytes = generate_format2a(pid, data, tti_tx_dl, enb_cc_idx, cfi, user_mask); break; default: @@ -409,15 +409,15 @@ int sched_ue::generate_format1a(uint32_t pid, uint32_t cfi, const rbgmask_t& user_mask) { - srslte_dci_dl_t* dci = &data->dci; + srsran_dci_dl_t* dci = &data->dci; - dci->alloc_type = SRSLTE_RA_ALLOC_TYPE2; - dci->type2_alloc.mode = srslte_ra_type2_t::SRSLTE_RA_TYPE2_LOC; + dci->alloc_type = SRSRAN_RA_ALLOC_TYPE2; + dci->type2_alloc.mode = srsran_ra_type2_t::SRSRAN_RA_TYPE2_LOC; rbg_interval rbg_int = rbg_interval::rbgmask_to_rbgs(user_mask); prb_interval prb_int = prb_interval::rbgs_to_prbs(rbg_int, cell.nof_prb); uint32_t L_crb = prb_int.length(); uint32_t RB_start = prb_int.start(); - dci->type2_alloc.riv = srslte_ra_type2_to_riv(L_crb, RB_start, cell.nof_prb); + dci->type2_alloc.riv = srsran_ra_type2_to_riv(L_crb, RB_start, cell.nof_prb); if (L_crb != count_prb_per_tb(user_mask)) { // This happens if Type0 was using distributed allocation logger.warning("SCHED: Can't use distributed RA due to DCI size ambiguity"); @@ -434,7 +434,7 @@ int sched_ue::generate_format1_common(uint32_t pid, const rbgmask_t& user_mask) { dl_harq_proc* h = &cells[enb_cc_idx].harq_ent.dl_harq_procs()[pid]; - srslte_dci_dl_t* dci = &data->dci; + srsran_dci_dl_t* dci = &data->dci; tbs_info tbinfo; if (h->is_empty(0)) { @@ -462,9 +462,9 @@ int sched_ue::generate_format1(uint32_t pid, uint32_t cfi, const rbgmask_t& user_mask) { - srslte_dci_dl_t* dci = &data->dci; + srsran_dci_dl_t* dci = &data->dci; - dci->alloc_type = SRSLTE_RA_ALLOC_TYPE0; + dci->alloc_type = SRSRAN_RA_ALLOC_TYPE0; dci->type0_alloc.rbg_bitmask = (uint32_t)user_mask.to_uint64(); return generate_format1_common(pid, data, tti_tx_dl, enb_cc_idx, cfi, user_mask); @@ -483,10 +483,10 @@ tbs_info sched_ue::compute_mcs_and_tbs(uint32_t enb_cc_idx, tti_point tti_tx_dl, uint32_t nof_alloc_prbs, uint32_t cfi, - const srslte_dci_dl_t& dci) + const srsran_dci_dl_t& dci) { assert(cells[enb_cc_idx].configured()); - srslte::interval req_bytes = get_requested_dl_bytes(enb_cc_idx); + srsran::interval req_bytes = get_requested_dl_bytes(enb_cc_idx); // Calculate exact number of RE for this PRB allocation uint32_t nof_re = cells[enb_cc_idx].cell_cfg->get_dl_nof_res(tti_tx_dl, dci, cfi); @@ -511,10 +511,10 @@ int sched_ue::generate_format2a(uint32_t pid, const rbgmask_t& user_mask) { dl_harq_proc* h = &cells[enb_cc_idx].harq_ent.dl_harq_procs()[pid]; - bool tb_en[SRSLTE_MAX_TB] = {false}; + bool tb_en[SRSRAN_MAX_TB] = {false}; - srslte_dci_dl_t* dci = &data->dci; - dci->alloc_type = SRSLTE_RA_ALLOC_TYPE0; + srsran_dci_dl_t* dci = &data->dci; + dci->alloc_type = SRSRAN_RA_ALLOC_TYPE0; dci->type0_alloc.rbg_bitmask = (uint32_t)user_mask.to_uint64(); bool no_retx = true; @@ -529,7 +529,7 @@ int sched_ue::generate_format2a(uint32_t pid, } } else { /* Two layers, retransmit what TBs that have not been Acknowledged */ - for (uint32_t tb = 0; tb < SRSLTE_MAX_TB; tb++) { + for (uint32_t tb = 0; tb < SRSRAN_MAX_TB; tb++) { if (!h->is_empty(tb)) { tb_en[tb] = true; no_retx = false; @@ -542,7 +542,7 @@ int sched_ue::generate_format2a(uint32_t pid, } } - for (uint32_t tb = 0; tb < SRSLTE_MAX_TB; tb++) { + for (uint32_t tb = 0; tb < SRSRAN_MAX_TB; tb++) { tbs_info tbinfo; if (!h->is_empty(tb)) { @@ -555,14 +555,14 @@ int sched_ue::generate_format2a(uint32_t pid, if (tbinfo.tbs_bytes > 0 && tb_en[tb]) { dci->tb[tb].mcs_idx = (uint32_t)tbinfo.mcs; dci->tb[tb].rv = get_rvidx(h->nof_retx(tb)); - if (!SRSLTE_DCI_IS_TB_EN(dci->tb[tb])) { + if (!SRSRAN_DCI_IS_TB_EN(dci->tb[tb])) { dci->tb[tb].rv = 2; } dci->tb[tb].ndi = h->get_ndi(tb); dci->tb[tb].cw_idx = tb; data->tbs[tb] = (uint32_t)tbinfo.tbs_bytes; } else { - SRSLTE_DCI_TB_DISABLE(dci->tb[tb]); + SRSRAN_DCI_TB_DISABLE(dci->tb[tb]); data->tbs[tb] = 0; } } @@ -583,7 +583,7 @@ int sched_ue::generate_format2(uint32_t pid, int ret = generate_format2a(pid, data, tti_tx_dl, enb_cc_idx, cfi, user_mask); /* Compute precoding information */ - if ((SRSLTE_DCI_IS_TB_EN(data->dci.tb[0]) + SRSLTE_DCI_IS_TB_EN(data->dci.tb[1])) == 1) { + if ((SRSRAN_DCI_IS_TB_EN(data->dci.tb[0]) + SRSRAN_DCI_IS_TB_EN(data->dci.tb[1])) == 1) { data->dci.pinfo = (uint8_t)(cells[enb_cc_idx].dl_pmi + 1) % (uint8_t)5; } else { data->dci.pinfo = (uint8_t)(cells[enb_cc_idx].dl_pmi & 1u); @@ -597,12 +597,12 @@ int sched_ue::generate_format0(sched_interface::ul_sched_data_t* data, uint32_t enb_cc_idx, prb_interval alloc, bool needs_pdcch, - srslte_dci_location_t dci_pos, + srsran_dci_location_t dci_pos, int explicit_mcs, uci_pusch_t uci_type) { ul_harq_proc* h = get_ul_harq(tti_tx_ul, enb_cc_idx); - srslte_dci_ul_t* dci = &data->dci; + srsran_dci_ul_t* dci = &data->dci; bool cqi_request = needs_cqi(tti_tx_ul.to_uint(), enb_cc_idx, true); @@ -622,8 +622,8 @@ int sched_ue::generate_format0(sched_interface::ul_sched_data_t* data, // dynamic mcs uint32_t req_bytes = get_pending_ul_new_data(tti_tx_ul, enb_cc_idx); uint32_t N_srs = 0; - uint32_t nof_symb = 2 * (SRSLTE_CP_NSYMB(cell.cp) - 1) - N_srs; - uint32_t nof_re = nof_symb * alloc.length() * SRSLTE_NRE; + uint32_t nof_symb = 2 * (SRSRAN_CP_NSYMB(cell.cp) - 1) - N_srs; + uint32_t nof_re = nof_symb * alloc.length() * SRSRAN_NRE; tbinfo = cqi_to_tbs_ul(cells[enb_cc_idx], alloc.length(), nof_re, req_bytes); // Reduce MCS to fit UCI if transmitted in this grant @@ -632,14 +632,14 @@ int sched_ue::generate_format0(sched_interface::ul_sched_data_t* data, uint32_t nof_uci_re = 0; // Add the RE for ACK if (uci_type == UCI_PUSCH_ACK || uci_type == UCI_PUSCH_ACK_CQI) { - float beta = srslte_sch_beta_ack(cfg.uci_offset.I_offset_ack); + float beta = srsran_sch_beta_ack(cfg.uci_offset.I_offset_ack); nof_uci_re += - srslte_qprime_ack_ext(alloc.length(), nof_symb, 8 * tbinfo.tbs_bytes, cfg.supported_cc_list.size(), beta); + srsran_qprime_ack_ext(alloc.length(), nof_symb, 8 * tbinfo.tbs_bytes, cfg.supported_cc_list.size(), beta); } // Add the RE for CQI report (RI reports are transmitted on CQI slots. We do a conservative estimate here) if (uci_type == UCI_PUSCH_CQI || uci_type == UCI_PUSCH_ACK_CQI || cqi_request) { - float beta = srslte_sch_beta_cqi(cfg.uci_offset.I_offset_cqi); - nof_uci_re += srslte_qprime_cqi_ext(alloc.length(), nof_symb, 8 * tbinfo.tbs_bytes, beta); + float beta = srsran_sch_beta_cqi(cfg.uci_offset.I_offset_cqi); + nof_uci_re += srsran_qprime_cqi_ext(alloc.length(), nof_symb, 8 * tbinfo.tbs_bytes, beta); } // Recompute again the MCS and TBS with the new spectral efficiency (based on the available RE for data) if (nof_re >= nof_uci_re) { @@ -665,14 +665,14 @@ int sched_ue::generate_format0(sched_interface::ul_sched_data_t* data, data->tbs = tbinfo.tbs_bytes; data->current_tx_nb = h->nof_retx(0); dci->rnti = rnti; - dci->format = SRSLTE_DCI_FORMAT0; + dci->format = SRSRAN_DCI_FORMAT0; dci->ue_cc_idx = cells[enb_cc_idx].get_ue_cc_idx(); dci->tb.ndi = h->get_ndi(0); dci->cqi_request = cqi_request; - dci->freq_hop_fl = srslte_dci_ul_t::SRSLTE_RA_PUSCH_HOP_DISABLED; + dci->freq_hop_fl = srsran_dci_ul_t::SRSRAN_RA_PUSCH_HOP_DISABLED; dci->tpc_pusch = cells[enb_cc_idx].tpc_fsm.encode_pusch_tpc(); - dci->type2_alloc.riv = srslte_ra_type2_to_riv(alloc.length(), alloc.start(), cell.nof_prb); + dci->type2_alloc.riv = srsran_ra_type2_to_riv(alloc.length(), alloc.start(), cell.nof_prb); // If there are no RE available for ULSCH but there is UCI to transmit, allocate PUSCH becuase // resources have been reserved already and in CA it will be used to ACK other carriers @@ -720,10 +720,10 @@ bool sched_ue::needs_cqi(uint32_t tti, uint32_t enb_cc_idx, bool will_send) bool ret = false; if (phy_config_dedicated_enabled && cfg.supported_cc_list[0].aperiodic_cqi_period && lch_handler.has_pending_dl_txs()) { - uint32_t interval = srslte_tti_interval(tti, cells[enb_cc_idx].dl_cqi_tti_rx.to_uint()); + uint32_t interval = srsran_tti_interval(tti, cells[enb_cc_idx].dl_cqi_tti_rx.to_uint()); bool needscqi = interval >= cfg.supported_cc_list[0].aperiodic_cqi_period; if (needscqi) { - uint32_t interval_sent = srslte_tti_interval(tti, cqi_request_tti); + uint32_t interval_sent = srsran_tti_interval(tti, cqi_request_tti); if (interval_sent >= 16) { if (will_send) { cqi_request_tti = tti; @@ -745,8 +745,8 @@ rbg_interval sched_ue::get_required_dl_rbgs(uint32_t enb_cc_idx) { assert(cells[enb_cc_idx].configured()); const auto* cellparams = cells[enb_cc_idx].cell_cfg; - srslte::interval req_bytes = get_requested_dl_bytes(enb_cc_idx); - if (req_bytes == srslte::interval{0, 0}) { + srsran::interval req_bytes = get_requested_dl_bytes(enb_cc_idx); + if (req_bytes == srsran::interval{0, 0}) { return {0, 0}; } int pending_prbs = get_required_prb_dl(cells[enb_cc_idx], to_tx_dl(current_tti), get_dci_format(), req_bytes.start()); @@ -780,7 +780,7 @@ rbg_interval sched_ue::get_required_dl_rbgs(uint32_t enb_cc_idx) * @enb_cc_idx carrier where allocation is being made * @return */ -srslte::interval sched_ue::get_requested_dl_bytes(uint32_t enb_cc_idx) +srsran::interval sched_ue::get_requested_dl_bytes(uint32_t enb_cc_idx) { assert(cells.at(enb_cc_idx).configured()); @@ -796,12 +796,12 @@ srslte::interval sched_ue::get_requested_dl_bytes(uint32_t enb_cc_idx) // Add pending CEs if (cells[enb_cc_idx].is_pcell()) { if (srb0_data == 0 and not lch_handler.pending_ces.empty() and - lch_handler.pending_ces.front() == srslte::dl_sch_lcid::CON_RES_ID) { + lch_handler.pending_ces.front() == srsran::dl_sch_lcid::CON_RES_ID) { // Wait for SRB0 data to be available for Msg4 before scheduling the ConRes CE return {}; } for (const lch_ue_manager::ce_cmd& ce : lch_handler.pending_ces) { - sum_ce_data += srslte::ce_total_size(ce); + sum_ce_data += srsran::ce_total_size(ce); } } // Add pending data in remaining RLC buffers @@ -813,11 +813,11 @@ srslte::interval sched_ue::get_requested_dl_bytes(uint32_t enb_cc_idx) /* Set Minimum boundary */ min_data = srb0_data; if (not lch_handler.pending_ces.empty() and lch_handler.pending_ces.front() == lch_ue_manager::ce_cmd::CON_RES_ID) { - min_data += srslte::ce_total_size(lch_handler.pending_ces.front()); + min_data += srsran::ce_total_size(lch_handler.pending_ces.front()); } if (min_data == 0) { if (sum_ce_data > 0) { - min_data = srslte::ce_total_size(lch_handler.pending_ces.front()); + min_data = srsran::ce_total_size(lch_handler.pending_ces.front()); } else if (rb_data > 0) { min_data = MAC_MIN_ALLOC_SIZE; } @@ -837,9 +837,9 @@ uint32_t sched_ue::get_expected_dl_bitrate(uint32_t enb_cc_idx, int nof_rbgs) co auto& cc = cells[enb_cc_idx]; uint32_t nof_re = cc.cell_cfg->get_dl_lb_nof_re(to_tx_dl(current_tti), count_prb_per_tb_approx(nof_rbgs, cc.cell_cfg->nof_prb())); - float max_coderate = srslte_cqi_to_coderate(std::min(cc.dl_cqi + 1u, 15u), cfg.use_tbs_index_alt); + float max_coderate = srsran_cqi_to_coderate(std::min(cc.dl_cqi + 1u, 15u), cfg.use_tbs_index_alt); - // Inverse of srslte_coderate(tbs, nof_re) + // Inverse of srsran_coderate(tbs, nof_re) uint32_t tbs = max_coderate * nof_re - 24; return tbs / tti_duration_ms; } @@ -849,11 +849,11 @@ uint32_t sched_ue::get_expected_ul_bitrate(uint32_t enb_cc_idx, int nof_prbs) co uint32_t nof_prbs_alloc = nof_prbs < 0 ? cell.nof_prb : nof_prbs; uint32_t N_srs = 0; - uint32_t nof_symb = 2 * (SRSLTE_CP_NSYMB(cell.cp) - 1) - N_srs; - uint32_t nof_re = nof_symb * nof_prbs_alloc * SRSLTE_NRE; - float max_coderate = srslte_cqi_to_coderate(std::min(cells[enb_cc_idx].ul_cqi + 1u, 15u), false); + uint32_t nof_symb = 2 * (SRSRAN_CP_NSYMB(cell.cp) - 1) - N_srs; + uint32_t nof_re = nof_symb * nof_prbs_alloc * SRSRAN_NRE; + float max_coderate = srsran_cqi_to_coderate(std::min(cells[enb_cc_idx].ul_cqi + 1u, 15u), false); - // Inverse of srslte_coderate(tbs, nof_re) + // Inverse of srsran_coderate(tbs, nof_re) uint32_t tbs = max_coderate * nof_re - 24; return tbs / tti_duration_ms; } @@ -942,7 +942,7 @@ uint32_t sched_ue::get_pending_ul_new_data(tti_point tti_tx_ul, int this_enb_cc_ logger.debug("SCHED: pending_data=%d, in_harq_data=%d, bsr=%s", pending_data, pending_ul_data, - srslte::to_c_str(str_buffer)); + srsran::to_c_str(str_buffer)); } } return pending_data; @@ -1008,9 +1008,9 @@ void sched_ue::finish_tti(tti_point tti_rx, uint32_t enb_cc_idx) cells[enb_cc_idx].finish_tti(tti_rx); } -srslte_dci_format_t sched_ue::get_dci_format() +srsran_dci_format_t sched_ue::get_dci_format() { - srslte_dci_format_t ret = SRSLTE_DCI_FORMAT1A; + srsran_dci_format_t ret = SRSRAN_DCI_FORMAT1A; if (phy_config_dedicated_enabled) { /* TODO: Assumes UE-Specific Search Space (Not common) */ @@ -1020,14 +1020,14 @@ srslte_dci_format_t sched_ue::get_dci_format() // If the size of Format1 and Format1A is ambiguous in the common SS, use Format1A since the UE assumes // Common SS when spaces collide if (not(cell.nof_prb == 15 && cells.size() > 1)) { - ret = SRSLTE_DCI_FORMAT1; + ret = SRSRAN_DCI_FORMAT1; } break; case sched_interface::ant_info_ded_t::tx_mode_t::tm3: - ret = SRSLTE_DCI_FORMAT2A; + ret = SRSRAN_DCI_FORMAT2A; break; case sched_interface::ant_info_ded_t::tx_mode_t::tm4: - ret = SRSLTE_DCI_FORMAT2; + ret = SRSRAN_DCI_FORMAT2; break; case sched_interface::ant_info_ded_t::tx_mode_t::tm5: case sched_interface::ant_info_ded_t::tx_mode_t::tm6: @@ -1057,9 +1057,9 @@ sched_ue_cell* sched_ue::find_ue_carrier(uint32_t enb_cc_idx) return cells[enb_cc_idx].configured() ? &cells[enb_cc_idx] : nullptr; } -std::bitset sched_ue::scell_activation_mask() const +std::bitset sched_ue::scell_activation_mask() const { - std::bitset ret{0}; + std::bitset ret{0}; for (size_t i = 0; i < cells.size(); ++i) { if (cells[i].cc_state() == cc_st::active and cells[i].is_scell()) { ret[cells[i].get_ue_cc_idx()] = true; diff --git a/srsenb/src/stack/mac/sched_ue_ctrl/sched_harq.cc b/srsenb/src/stack/mac/sched_ue_ctrl/sched_harq.cc index e7050ae60..1b7d8f8de 100644 --- a/srsenb/src/stack/mac/sched_ue_ctrl/sched_harq.cc +++ b/srsenb/src/stack/mac/sched_ue_ctrl/sched_harq.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,10 +13,10 @@ #include #include "srsenb/hdr/stack/mac/sched.h" -#include "srslte/common/log_helper.h" -#include "srslte/mac/pdu.h" +#include "srsran/common/log_helper.h" +#include "srsran/mac/pdu.h" -using srslte::tti_point; +using srsran::tti_point; namespace srsenb { @@ -52,7 +52,7 @@ uint32_t harq_proc::get_id() const bool harq_proc::is_empty() const { - for (uint32_t i = 0; i < SRSLTE_MAX_TB; ++i) { + for (uint32_t i = 0; i < SRSRAN_MAX_TB; ++i) { if (not is_empty(i)) { return false; } @@ -79,7 +79,7 @@ int harq_proc::set_ack_common(uint32_t tb_idx, bool ack_) { if (is_empty(tb_idx)) { logger->warning("Received ACK for inactive harq"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } ack_state[tb_idx] = ack_; logger->debug("ACK=%d received pid=%d, tb_idx=%d, n_rtx=%d, max_retx=%d", ack_, id, tb_idx, n_rtx[tb_idx], max_retx); @@ -93,7 +93,7 @@ int harq_proc::set_ack_common(uint32_t tb_idx, bool ack_) } else if (ack_) { active[tb_idx] = false; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } void harq_proc::new_tx_common(uint32_t tb_idx, tti_point tti_, int mcs, int tbs, uint32_t max_retx_) @@ -252,7 +252,7 @@ void ul_harq_proc::new_retx(tti_point tti_, int* mcs, int* tbs, prb_interval all pending_phich = true; } -bool ul_harq_proc::retx_requires_pdcch(srslte::tti_point tti_, prb_interval alloc) const +bool ul_harq_proc::retx_requires_pdcch(srsran::tti_point tti_, prb_interval alloc) const { return alloc != allocation or tti_ != to_tx_ul(tti); } @@ -315,12 +315,12 @@ harq_entity::harq_entity(size_t nof_dl_harqs, size_t nof_ul_harqs) : dl_harqs(no void harq_entity::reset() { for (auto& h : dl_harqs) { - for (uint32_t tb = 0; tb < SRSLTE_MAX_TB; tb++) { + for (uint32_t tb = 0; tb < SRSRAN_MAX_TB; tb++) { h.reset(tb); } } for (auto& h : ul_harqs) { - for (uint32_t tb = 0; tb < SRSLTE_MAX_TB; tb++) { + for (uint32_t tb = 0; tb < SRSRAN_MAX_TB; tb++) { h.reset(tb); } } @@ -355,7 +355,7 @@ std::pair harq_entity::set_ack_info(tti_point tti_rx, uint32_t tb { for (auto& h : dl_harqs) { if (h.get_tti() + FDD_HARQ_DELAY_DL_MS == tti_rx) { - if (h.set_ack(tb_idx, ack) == SRSLTE_SUCCESS) { + if (h.set_ack(tb_idx, ack) == SRSRAN_SUCCESS) { return {h.get_id(), h.get_tbs(tb_idx)}; } return {h.get_id(), -1}; diff --git a/srsenb/src/stack/mac/sched_ue_ctrl/sched_lch.cc b/srsenb/src/stack/mac/sched_ue_ctrl/sched_lch.cc index c49d39cee..88b7452d4 100644 --- a/srsenb/src/stack/mac/sched_ue_ctrl/sched_lch.cc +++ b/srsenb/src/stack/mac/sched_ue_ctrl/sched_lch.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -12,8 +12,8 @@ #include "srsenb/hdr/stack/mac/sched_ue_ctrl/sched_lch.h" #include "srsenb/hdr/stack/mac/sched_helpers.h" -#include "srslte/common/string_helpers.h" -#include "srslte/srslog/bundled/fmt/ranges.h" +#include "srsran/common/string_helpers.h" +#include "srsran/srslog/bundled/fmt/ranges.h" namespace srsenb { @@ -114,7 +114,7 @@ void lch_ue_manager::ul_bsr(uint8_t lcg_id, uint32_t bsr) if (logger.debug.enabled()) { fmt::memory_buffer str_buffer; fmt::format_to(str_buffer, "{}", get_bsr_state()); - logger.debug("SCHED: bsr=%d, lcg_id=%d, bsr=%s", bsr, lcg_id, srslte::to_c_str(str_buffer)); + logger.debug("SCHED: bsr=%d, lcg_id=%d, bsr=%s", bsr, lcg_id, srsran::to_c_str(str_buffer)); } } @@ -129,7 +129,7 @@ void lch_ue_manager::ul_buffer_add(uint8_t lcid, uint32_t bytes) fmt::memory_buffer str_buffer; fmt::format_to(str_buffer, "{}", get_bsr_state()); logger.debug( - "SCHED: UL buffer update=%d, lcg_id=%d, bsr=%s", bytes, lch[lcid].cfg.group, srslte::to_c_str(str_buffer)); + "SCHED: UL buffer update=%d, lcg_id=%d, bsr=%s", bytes, lch[lcid].cfg.group, srsran::to_c_str(str_buffer)); } } @@ -362,7 +362,7 @@ uint32_t allocate_mac_ces(sched_interface::dl_sched_data_t* data, lch_ue_manager { int rem_tbs = total_tbs; while (not lch_handler.pending_ces.empty() and data->nof_pdu_elems[0] < sched_interface::MAX_RLC_PDU_LIST) { - int toalloc = srslte::ce_total_size(lch_handler.pending_ces.front()); + int toalloc = srsran::ce_total_size(lch_handler.pending_ces.front()); if (rem_tbs < toalloc) { break; } diff --git a/srsenb/src/stack/mac/sched_ue_ctrl/sched_ue_cell.cc b/srsenb/src/stack/mac/sched_ue_ctrl/sched_ue_cell.cc index 874bb7cdd..fba4cb40d 100644 --- a/srsenb/src/stack/mac/sched_ue_ctrl/sched_ue_cell.cc +++ b/srsenb/src/stack/mac/sched_ue_ctrl/sched_ue_cell.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -223,10 +223,10 @@ std::tuple false_position_method(int x1, int x2, YType y tbs_info cqi_to_tbs_dl(const sched_ue_cell& cell, uint32_t nof_prb, uint32_t nof_re, - srslte_dci_format_t dci_format, + srsran_dci_format_t dci_format, int req_bytes) { - bool use_tbs_index_alt = cell.get_ue_cfg()->use_tbs_index_alt and dci_format != SRSLTE_DCI_FORMAT1A; + bool use_tbs_index_alt = cell.get_ue_cfg()->use_tbs_index_alt and dci_format != SRSRAN_DCI_FORMAT1A; tbs_info ret; if (cell.fixed_mcs_dl < 0 or not cell.dl_cqi_rx) { @@ -234,7 +234,7 @@ tbs_info cqi_to_tbs_dl(const sched_ue_cell& cell, ret = compute_min_mcs_and_tbs_from_required_bytes( nof_prb, nof_re, cell.dl_cqi, cell.max_mcs_dl, req_bytes, false, false, use_tbs_index_alt); - // If coderate > SRSLTE_MIN(max_coderate, 0.932 * Qm) we should set TBS=0. We don't because it's not correctly + // If coderate > SRSRAN_MIN(max_coderate, 0.932 * Qm) we should set TBS=0. We don't because it's not correctly // handled by the scheduler, but we might be scheduling undecodable codewords at very low SNR if (ret.tbs_bytes < 0) { ret.mcs = 0; @@ -260,7 +260,7 @@ tbs_info cqi_to_tbs_ul(const sched_ue_cell& cell, uint32_t nof_prb, uint32_t nof ret = compute_min_mcs_and_tbs_from_required_bytes( nof_prb, nof_re, cell.ul_cqi, cell.max_mcs_ul, req_bytes, true, ulqam64_enabled, false); - // If coderate > SRSLTE_MIN(max_coderate, 0.932 * Qm) we should set TBS=0. We don't because it's not correctly + // If coderate > SRSRAN_MIN(max_coderate, 0.932 * Qm) we should set TBS=0. We don't because it's not correctly // handled by the scheduler, but we might be scheduling undecodable codewords at very low SNR if (ret.tbs_bytes < 0) { ret.mcs = 0; @@ -277,7 +277,7 @@ tbs_info cqi_to_tbs_ul(const sched_ue_cell& cell, uint32_t nof_prb, uint32_t nof int get_required_prb_dl(const sched_ue_cell& cell, tti_point tti_tx_dl, - srslte_dci_format_t dci_format, + srsran_dci_format_t dci_format, uint32_t req_bytes) { auto compute_tbs_approx = [tti_tx_dl, &cell, dci_format](uint32_t nof_prb) { @@ -287,7 +287,7 @@ int get_required_prb_dl(const sched_ue_cell& cell, }; std::tuple ret = false_position_method( - 1U, cell.cell_cfg->nof_prb(), (int)req_bytes, compute_tbs_approx, [](int y) { return y == SRSLTE_ERROR; }); + 1U, cell.cell_cfg->nof_prb(), (int)req_bytes, compute_tbs_approx, [](int y) { return y == SRSRAN_ERROR; }); int upper_tbs = std::get<3>(ret); uint32_t upper_nprb = std::get<2>(ret); return (upper_tbs < 0) ? 0 : ((upper_tbs < (int)req_bytes) ? -1 : static_cast(upper_nprb)); @@ -300,7 +300,7 @@ uint32_t get_required_prb_ul(const sched_ue_cell& cell, uint32_t req_bytes) } auto compute_tbs_approx = [&cell](uint32_t nof_prb) { const uint32_t N_srs = 0; - uint32_t nof_re = (2 * (SRSLTE_CP_NSYMB(cell.cell_cfg->cfg.cell.cp) - 1) - N_srs) * nof_prb * SRSLTE_NRE; + uint32_t nof_re = (2 * (SRSRAN_CP_NSYMB(cell.cell_cfg->cfg.cell.cp) - 1) - N_srs) * nof_prb * SRSRAN_NRE; return cqi_to_tbs_ul(cell, nof_prb, nof_re, -1).tbs_bytes; }; @@ -308,9 +308,9 @@ uint32_t get_required_prb_ul(const sched_ue_cell& cell, uint32_t req_bytes) int target_tbs = static_cast(req_bytes) + 4; uint32_t max_prbs = std::min(cell.tpc_fsm.max_ul_prbs(), cell.cell_cfg->nof_prb()); std::tuple ret = - false_position_method(1U, max_prbs, target_tbs, compute_tbs_approx, [](int y) { return y == SRSLTE_ERROR; }); + false_position_method(1U, max_prbs, target_tbs, compute_tbs_approx, [](int y) { return y == SRSRAN_ERROR; }); uint32_t req_prbs = std::get<2>(ret); - while (!srslte_dft_precoding_valid_prb(req_prbs) && req_prbs < cell.cell_cfg->nof_prb()) { + while (!srsran_dft_precoding_valid_prb(req_prbs) && req_prbs < cell.cell_cfg->nof_prb()) { req_prbs++; } return req_prbs; diff --git a/srsenb/src/stack/mac/schedulers/CMakeLists.txt b/srsenb/src/stack/mac/schedulers/CMakeLists.txt index d3d9d7378..8b8514622 100644 --- a/srsenb/src/stack/mac/schedulers/CMakeLists.txt +++ b/srsenb/src/stack/mac/schedulers/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of diff --git a/srsenb/src/stack/mac/schedulers/sched_base.cc b/srsenb/src/stack/mac/schedulers/sched_base.cc index 2454871eb..96edc0014 100644 --- a/srsenb/src/stack/mac/schedulers/sched_base.cc +++ b/srsenb/src/stack/mac/schedulers/sched_base.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -123,7 +123,7 @@ alloc_result try_dl_retx_alloc(sf_sched& tti_sched, sched_ue& ue, const dl_harq_ // If previous mask does not fit, find another with exact same number of rbgs size_t nof_rbg = retx_mask.count(); - bool is_contiguous_alloc = ue.get_dci_format() == SRSLTE_DCI_FORMAT1A; + bool is_contiguous_alloc = ue.get_dci_format() == SRSRAN_DCI_FORMAT1A; retx_mask = compute_rbgmask_greedy(nof_rbg, is_contiguous_alloc, tti_sched.get_dl_mask()); if (retx_mask.count() == nof_rbg) { return tti_sched.alloc_dl_user(&ue, retx_mask, h.get_id()); @@ -150,7 +150,7 @@ alloc_result try_dl_newtx_alloc_greedy(sf_sched& tti_sched, sched_ue& ue, const } // Find RBG mask that accommodates pending data - bool is_contiguous_alloc = ue.get_dci_format() == SRSLTE_DCI_FORMAT1A; + bool is_contiguous_alloc = ue.get_dci_format() == SRSRAN_DCI_FORMAT1A; rbgmask_t newtxmask = compute_rbgmask_greedy(req_rbgs.stop(), is_contiguous_alloc, current_mask); if (newtxmask.none() or newtxmask.count() < req_rbgs.start()) { return alloc_result::no_sch_space; @@ -177,15 +177,15 @@ prb_interval find_contiguous_ul_prbs(uint32_t L, const prbmask_t& current_mask) // Make sure L is allowed by SC-FDMA modulation prb_interval prb_interv2 = prb_interv; - while (not srslte_dft_precoding_valid_prb(prb_interv.length()) and prb_interv.stop() < current_mask.size() and + while (not srsran_dft_precoding_valid_prb(prb_interv.length()) and prb_interv.stop() < current_mask.size() and not current_mask.test(prb_interv.stop())) { prb_interv.resize_by(1); } - if (not srslte_dft_precoding_valid_prb(prb_interv.length())) { + if (not srsran_dft_precoding_valid_prb(prb_interv.length())) { // if length increase failed, try to decrease prb_interv = prb_interv2; prb_interv.resize_by(-1); - while (not srslte_dft_precoding_valid_prb(prb_interv.length()) and not prb_interv.empty()) { + while (not srsran_dft_precoding_valid_prb(prb_interv.length()) and not prb_interv.empty()) { prb_interv.resize_by(-1); } } diff --git a/srsenb/src/stack/mac/schedulers/sched_time_pf.cc b/srsenb/src/stack/mac/schedulers/sched_time_pf.cc index d4ce4fb50..0bef003ea 100644 --- a/srsenb/src/stack/mac/schedulers/sched_time_pf.cc +++ b/srsenb/src/stack/mac/schedulers/sched_time_pf.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -14,7 +14,7 @@ namespace srsenb { -using srslte::tti_point; +using srsran::tti_point; sched_time_pf::sched_time_pf(const sched_cell_params_t& cell_params_, const sched_interface::sched_args_t& sched_args) { @@ -57,7 +57,7 @@ void sched_time_pf::new_tti(sched_ue_list& ue_db, sf_sched* tti_sched) void sched_time_pf::sched_dl_users(sched_ue_list& ue_db, sf_sched* tti_sched) { - srslte::tti_point tti_rx{tti_sched->get_tti_rx()}; + srsran::tti_point tti_rx{tti_sched->get_tti_rx()}; if (current_tti_rx != tti_rx) { new_tti(ue_db, tti_sched); } @@ -96,7 +96,7 @@ uint32_t sched_time_pf::try_dl_alloc(ue_ctxt& ue_ctxt, sched_ue& ue, sf_sched* t void sched_time_pf::sched_ul_users(sched_ue_list& ue_db, sf_sched* tti_sched) { - srslte::tti_point tti_rx{tti_sched->get_tti_rx()}; + srsran::tti_point tti_rx{tti_sched->get_tti_rx()}; if (current_tti_rx != tti_rx) { new_tti(ue_db, tti_sched); } diff --git a/srsenb/src/stack/mac/schedulers/sched_time_rr.cc b/srsenb/src/stack/mac/schedulers/sched_time_rr.cc index b9c3c6531..3465c558e 100644 --- a/srsenb/src/stack/mac/schedulers/sched_time_rr.cc +++ b/srsenb/src/stack/mac/schedulers/sched_time_rr.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/srsenb/src/stack/mac/ue.cc b/srsenb/src/stack/mac/ue.cc index e4a3a45ff..06b7036df 100644 --- a/srsenb/src/stack/mac/ue.cc +++ b/srsenb/src/stack/mac/ue.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -16,14 +16,14 @@ #include #include "srsenb/hdr/stack/mac/ue.h" -#include "srslte/common/string_helpers.h" -#include "srslte/interfaces/enb_phy_interfaces.h" -#include "srslte/interfaces/enb_rlc_interfaces.h" -#include "srslte/interfaces/enb_rrc_interfaces.h" +#include "srsran/common/string_helpers.h" +#include "srsran/interfaces/enb_phy_interfaces.h" +#include "srsran/interfaces/enb_rlc_interfaces.h" +#include "srsran/interfaces/enb_rrc_interfaces.h" namespace srsenb { -cc_used_buffers_map::cc_used_buffers_map(srslte::pdu_queue& shared_pdu_queue_) : +cc_used_buffers_map::cc_used_buffers_map(srsran::pdu_queue& shared_pdu_queue_) : pdu_map(), shared_pdu_queue(&shared_pdu_queue_), logger(&srslog::fetch_basic_logger("MAC")) {} @@ -65,7 +65,7 @@ uint8_t* cc_used_buffers_map::request_pdu(tti_point tti, uint32_t len) void cc_used_buffers_map::clear_old_pdus(tti_point current_tti) { - static const uint32_t old_tti_threshold = SRSLTE_FDD_NOF_HARQ + 4; + static const uint32_t old_tti_threshold = SRSRAN_FDD_NOF_HARQ + 4; tti_point max_tti{current_tti - old_tti_threshold}; for (auto& pdu_pair : pdu_map) { @@ -118,11 +118,11 @@ bool cc_used_buffers_map::has_tti(tti_point tti) const //////////////// -cc_buffer_handler::cc_buffer_handler(srslte::pdu_queue& shared_pdu_queue_) : rx_used_buffers(shared_pdu_queue_) +cc_buffer_handler::cc_buffer_handler(srsran::pdu_queue& shared_pdu_queue_) : rx_used_buffers(shared_pdu_queue_) { for (auto& harq_buffers : tx_payload_buffer) { - for (srslte::unique_byte_buffer_t& tb_buffer : harq_buffers) { - tb_buffer = srslte::make_byte_buffer(); + for (srsran::unique_byte_buffer_t& tb_buffer : harq_buffers) { + tb_buffer = srsran::make_byte_buffer(); if (tb_buffer == nullptr) { srslog::fetch_basic_logger("MAC").error("Failed to allocate HARQ buffers for UE"); return; @@ -152,26 +152,26 @@ void cc_buffer_handler::allocate_cc(uint32_t nof_prb_, uint32_t nof_rx_harq_proc // Create and init Rx buffers softbuffer_rx_list.resize(nof_rx_harq_proc); - for (srslte_softbuffer_rx_t& buffer : softbuffer_rx_list) { - srslte_softbuffer_rx_init(&buffer, nof_prb); + for (srsran_softbuffer_rx_t& buffer : softbuffer_rx_list) { + srsran_softbuffer_rx_init(&buffer, nof_prb); } // Create and init Tx buffers - softbuffer_tx_list.resize(nof_tx_harq_proc * SRSLTE_MAX_TB); + softbuffer_tx_list.resize(nof_tx_harq_proc * SRSRAN_MAX_TB); for (auto& buffer : softbuffer_tx_list) { - srslte_softbuffer_tx_init(&buffer, nof_prb); + srsran_softbuffer_tx_init(&buffer, nof_prb); } } void cc_buffer_handler::deallocate_cc() { for (auto& buffer : softbuffer_rx_list) { - srslte_softbuffer_rx_free(&buffer); + srsran_softbuffer_rx_free(&buffer); } softbuffer_rx_list.clear(); for (auto& buffer : softbuffer_tx_list) { - srslte_softbuffer_tx_free(&buffer); + srsran_softbuffer_tx_free(&buffer); } softbuffer_tx_list.clear(); } @@ -179,10 +179,10 @@ void cc_buffer_handler::deallocate_cc() void cc_buffer_handler::reset() { for (auto& buffer : softbuffer_rx_list) { - srslte_softbuffer_rx_reset(&buffer); + srsran_softbuffer_rx_reset(&buffer); } for (auto& buffer : softbuffer_tx_list) { - srslte_softbuffer_tx_reset(&buffer); + srsran_softbuffer_tx_reset(&buffer); } } @@ -238,17 +238,17 @@ void ue::reset() } } -void ue::start_pcap_net(srslte::mac_pcap_net* pcap_net_) +void ue::start_pcap_net(srsran::mac_pcap_net* pcap_net_) { pcap_net = pcap_net_; } -void ue::start_pcap(srslte::mac_pcap* pcap_) +void ue::start_pcap(srsran::mac_pcap* pcap_) { pcap = pcap_; } -srslte_softbuffer_rx_t* ue::get_rx_softbuffer(const uint32_t ue_cc_idx, const uint32_t tti) +srsran_softbuffer_rx_t* ue::get_rx_softbuffer(const uint32_t ue_cc_idx, const uint32_t tti) { if ((size_t)ue_cc_idx >= cc_buffers.size()) { ERROR("UE CC Index (%d/%zd) out-of-range", ue_cc_idx, cc_buffers.size()); @@ -258,7 +258,7 @@ srslte_softbuffer_rx_t* ue::get_rx_softbuffer(const uint32_t ue_cc_idx, const ui return &cc_buffers[ue_cc_idx].get_rx_softbuffer(tti % nof_rx_harq_proc); } -srslte_softbuffer_tx_t* +srsran_softbuffer_tx_t* ue::get_tx_softbuffer(const uint32_t ue_cc_idx, const uint32_t harq_process, const uint32_t tb_idx) { if ((size_t)ue_cc_idx >= cc_buffers.size()) { @@ -307,7 +307,7 @@ uint32_t ue::set_ta(int ta_) uint32_t nof_cmd = 0; int ta_value = 0; do { - ta_value = SRSLTE_MAX(-31, SRSLTE_MIN(32, ta)); + ta_value = SRSRAN_MAX(-31, SRSRAN_MIN(32, ta)); ta -= ta_value; uint32_t ta_cmd = (uint32_t)(ta_value + 31); pending_ta_commands.try_push(ta_cmd); @@ -317,7 +317,7 @@ uint32_t ue::set_ta(int ta_) return nof_cmd; } -void ue::process_pdu(uint8_t* pdu, uint32_t nof_bytes, srslte::pdu_queue::channel_t channel) +void ue::process_pdu(uint8_t* pdu, uint32_t nof_bytes, srsran::pdu_queue::channel_t channel) { // Unpack ULSCH MAC PDU mac_msg_ul.init_rx(nof_bytes, true); @@ -326,7 +326,7 @@ void ue::process_pdu(uint8_t* pdu, uint32_t nof_bytes, srslte::pdu_queue::channe if (logger.info.enabled()) { fmt::memory_buffer str_buffer; mac_msg_ul.to_string(str_buffer); - logger.info("0x%x %s", rnti, srslte::to_c_str(str_buffer)); + logger.info("0x%x %s", rnti, srsran::to_c_str(str_buffer)); } if (pcap) { @@ -384,7 +384,7 @@ void ue::process_pdu(uint8_t* pdu, uint32_t nof_bytes, srslte::pdu_queue::channe // Save contention resolution if lcid == 0 if (mac_msg_ul.get()->get_sdu_lcid() == 0 && route_pdu) { - int nbytes = srslte::sch_subh::MAC_CE_CONTRES_LEN; + int nbytes = srsran::sch_subh::MAC_CE_CONTRES_LEN; if (mac_msg_ul.get()->get_payload_size() >= (uint32_t)nbytes) { uint8_t* ue_cri_ptr = (uint8_t*)&conres_id; uint8_t* pkt_ptr = mac_msg_ul.get()->get_sdu_ptr(); // Warning here: we want to include the @@ -439,7 +439,7 @@ void ue::push_pdu(uint32_t tti, uint32_t ue_cc_idx, uint32_t len) } } -bool ue::process_ce(srslte::sch_subh* subh) +bool ue::process_ce(srsran::sch_subh* subh) { uint32_t buff_size_idx[4] = {}; uint32_t buff_size_bytes[4] = {}; @@ -448,12 +448,12 @@ bool ue::process_ce(srslte::sch_subh* subh) uint16_t old_rnti = 0; bool is_bsr = false; switch (subh->ul_sch_ce_type()) { - case srslte::ul_sch_lcid::PHR_REPORT: + case srsran::ul_sch_lcid::PHR_REPORT: phr = subh->get_phr(); sched->ul_phr(rnti, (int)phr); metrics_phr(phr); break; - case srslte::ul_sch_lcid::CRNTI: + case srsran::ul_sch_lcid::CRNTI: old_rnti = subh->get_c_rnti(); if (sched->ue_exists(old_rnti)) { rrc->upd_user(rnti, old_rnti); @@ -462,8 +462,8 @@ bool ue::process_ce(srslte::sch_subh* subh) logger.error("Updating user C-RNTI: rnti=0x%x already released", old_rnti); } break; - case srslte::ul_sch_lcid::TRUNC_BSR: - case srslte::ul_sch_lcid::SHORT_BSR: + case srsran::ul_sch_lcid::TRUNC_BSR: + case srsran::ul_sch_lcid::SHORT_BSR: idx = subh->get_bsr(buff_size_idx, buff_size_bytes); if (idx == -1) { logger.error("Invalid Index Passed to lc groups"); @@ -473,14 +473,14 @@ bool ue::process_ce(srslte::sch_subh* subh) sched->ul_bsr(rnti, idx, buff_size_bytes[idx]); is_bsr = true; break; - case srslte::ul_sch_lcid::LONG_BSR: + case srsran::ul_sch_lcid::LONG_BSR: subh->get_bsr(buff_size_idx, buff_size_bytes); for (idx = 0; idx < sched_interface::MAX_LC_GROUP; ++idx) { sched->ul_bsr(rnti, idx, buff_size_bytes[idx]); } is_bsr = true; break; - case srslte::ul_sch_lcid::PADDING: + case srsran::ul_sch_lcid::PADDING: break; default: logger.error("CE: Invalid lcid=0x%x", (int)subh->ul_sch_ce_type()); @@ -494,12 +494,12 @@ int ue::read_pdu(uint32_t lcid, uint8_t* payload, uint32_t requested_bytes) return rlc->read_pdu(rnti, lcid, payload, requested_bytes); } -void ue::allocate_sdu(srslte::sch_pdu* pdu, uint32_t lcid, uint32_t total_sdu_len) +void ue::allocate_sdu(srsran::sch_pdu* pdu, uint32_t lcid, uint32_t total_sdu_len) { const int min_sdu_len = lcid == 0 ? 1 : 2; int sdu_space = pdu->get_sdu_space(); if (sdu_space > 0) { - int sdu_len = SRSLTE_MIN(total_sdu_len, (uint32_t)sdu_space); + int sdu_len = SRSRAN_MIN(total_sdu_len, (uint32_t)sdu_space); int n = 1; while (sdu_len >= min_sdu_len && n > 0) { // minimum size is a single RLC AM status PDU (2 Byte) if (pdu->new_subh()) { // there is space for a new subheader @@ -519,10 +519,10 @@ void ue::allocate_sdu(srslte::sch_pdu* pdu, uint32_t lcid, uint32_t total_sdu_le } } -void ue::allocate_ce(srslte::sch_pdu* pdu, uint32_t lcid) +void ue::allocate_ce(srsran::sch_pdu* pdu, uint32_t lcid) { - switch ((srslte::dl_sch_lcid)lcid) { - case srslte::dl_sch_lcid::TA_CMD: + switch ((srsran::dl_sch_lcid)lcid) { + case srsran::dl_sch_lcid::TA_CMD: if (pdu->new_subh()) { uint32_t ta_cmd = 31; pending_ta_commands.try_pop(&ta_cmd); @@ -533,7 +533,7 @@ void ue::allocate_ce(srslte::sch_pdu* pdu, uint32_t lcid) logger.error("CE: Setting TA CMD CE. No space for a subheader"); } break; - case srslte::dl_sch_lcid::CON_RES_ID: + case srsran::dl_sch_lcid::CON_RES_ID: if (pdu->new_subh()) { if (!pdu->get()->set_con_res_id(conres_id)) { logger.error("CE: Setting Contention Resolution ID CE"); @@ -542,9 +542,9 @@ void ue::allocate_ce(srslte::sch_pdu* pdu, uint32_t lcid) logger.error("CE: Setting Contention Resolution ID CE. No space for a subheader"); } break; - case srslte::dl_sch_lcid::SCELL_ACTIVATION: + case srsran::dl_sch_lcid::SCELL_ACTIVATION: if (pdu->new_subh()) { - std::array active_scell_list = sched->get_scell_activation_mask(rnti); + std::array active_scell_list = sched->get_scell_activation_mask(rnti); if (pdu->get()->set_scell_activation_cmd(active_scell_list)) { phy->set_activation_deactivation_scell(rnti, active_scell_list); // Allocate and initialize Rx/Tx softbuffers for new carriers (exclude PCell) @@ -576,12 +576,12 @@ uint8_t* ue::generate_pdu(uint32_t ue_cc_idx, std::lock_guard lock(mutex); uint8_t* ret = nullptr; if (rlc) { - if (ue_cc_idx < SRSLTE_MAX_CARRIERS && harq_pid < SRSLTE_FDD_NOF_HARQ && tb_idx < SRSLTE_MAX_TB) { - srslte::byte_buffer_t* buffer = cc_buffers[ue_cc_idx].get_tx_payload_buffer(harq_pid, tb_idx); + if (ue_cc_idx < SRSRAN_MAX_CARRIERS && harq_pid < SRSRAN_FDD_NOF_HARQ && tb_idx < SRSRAN_MAX_TB) { + srsran::byte_buffer_t* buffer = cc_buffers[ue_cc_idx].get_tx_payload_buffer(harq_pid, tb_idx); buffer->clear(); mac_msg_dl.init_tx(buffer, grant_size, false); for (uint32_t i = 0; i < nof_pdu_elems; i++) { - if (pdu[i].lcid <= (uint32_t)srslte::ul_sch_lcid::PHR_REPORT) { + if (pdu[i].lcid <= (uint32_t)srsran::ul_sch_lcid::PHR_REPORT) { allocate_sdu(&mac_msg_dl, pdu[i].lcid, pdu[i].nbytes); } else { allocate_ce(&mac_msg_dl, pdu[i].lcid); @@ -591,7 +591,7 @@ uint8_t* ue::generate_pdu(uint32_t ue_cc_idx, if (logger.info.enabled()) { fmt::memory_buffer str_buffer; mac_msg_dl.to_string(str_buffer); - logger.info("0x%x %s", rnti, srslte::to_c_str(str_buffer)); + logger.info("0x%x %s", rnti, srsran::to_c_str(str_buffer)); } } else { logger.error( @@ -610,18 +610,18 @@ uint8_t* ue::generate_mch_pdu(uint32_t harq_pid, { std::lock_guard lock(mutex); uint8_t* ret = nullptr; - srslte::byte_buffer_t* buffer = cc_buffers[0].get_tx_payload_buffer(harq_pid, 0); + srsran::byte_buffer_t* buffer = cc_buffers[0].get_tx_payload_buffer(harq_pid, 0); buffer->clear(); mch_mac_msg_dl.init_tx(buffer, grant_size); for (uint32_t i = 0; i < nof_pdu_elems; i++) { - if (sched_.pdu[i].lcid == (uint32_t)srslte::mch_lcid::MCH_SCHED_INFO) { + if (sched_.pdu[i].lcid == (uint32_t)srsran::mch_lcid::MCH_SCHED_INFO) { mch_mac_msg_dl.new_subh(); mch_mac_msg_dl.get()->set_next_mch_sched_info(sched_.mtch_sched[i].lcid, sched_.mtch_sched[i].stop); } else if (sched_.pdu[i].lcid == 0) { mch_mac_msg_dl.new_subh(); mch_mac_msg_dl.get()->set_sdu(0, sched_.pdu[i].nbytes, sched_.mcch_payload); - } else if (sched_.pdu[i].lcid <= (uint32_t)srslte::mch_lcid::MTCH_MAX_LCID) { + } else if (sched_.pdu[i].lcid <= (uint32_t)srsran::mch_lcid::MTCH_MAX_LCID) { mch_mac_msg_dl.new_subh(); mch_mac_msg_dl.get()->set_sdu(sched_.pdu[i].lcid, sched_.pdu[i].nbytes, sched_.mtch_sched[i].mtch_payload); } @@ -639,7 +639,7 @@ void ue::metrics_read(mac_ue_metrics_t* metrics_) ue_metrics.dl_buffer = sched->get_dl_buffer(rnti); // set PCell sector id - std::array cc_list = sched->get_enb_ue_cc_map(rnti); + std::array cc_list = sched->get_enb_ue_cc_map(rnti); auto it = std::find(cc_list.begin(), cc_list.end(), 0); ue_metrics.cc_idx = std::distance(cc_list.begin(), it); @@ -652,7 +652,7 @@ void ue::metrics_read(mac_ue_metrics_t* metrics_) void ue::metrics_phr(float phr) { - ue_metrics.phr = SRSLTE_VEC_CMA(phr, ue_metrics.phr, phr_counter); + ue_metrics.phr = SRSRAN_VEC_CMA(phr, ue_metrics.phr, phr_counter); phr_counter++; } @@ -661,20 +661,20 @@ void ue::metrics_dl_ri(uint32_t dl_ri) if (ue_metrics.dl_ri == 0.0f) { ue_metrics.dl_ri = (float)dl_ri + 1.0f; } else { - ue_metrics.dl_ri = SRSLTE_VEC_EMA((float)dl_ri + 1.0f, ue_metrics.dl_ri, 0.5f); + ue_metrics.dl_ri = SRSRAN_VEC_EMA((float)dl_ri + 1.0f, ue_metrics.dl_ri, 0.5f); } dl_ri_counter++; } void ue::metrics_dl_pmi(uint32_t dl_ri) { - ue_metrics.dl_pmi = SRSLTE_VEC_CMA((float)dl_ri, ue_metrics.dl_pmi, dl_pmi_counter); + ue_metrics.dl_pmi = SRSRAN_VEC_CMA((float)dl_ri, ue_metrics.dl_pmi, dl_pmi_counter); dl_pmi_counter++; } void ue::metrics_dl_cqi(uint32_t dl_cqi) { - ue_metrics.dl_cqi = SRSLTE_VEC_CMA((float)dl_cqi, ue_metrics.dl_cqi, dl_cqi_counter); + ue_metrics.dl_cqi = SRSRAN_VEC_CMA((float)dl_cqi, ue_metrics.dl_cqi, dl_cqi_counter); dl_cqi_counter++; } @@ -708,7 +708,7 @@ void ue::tic() // Check for pending TA commands uint32_t nof_ta_count = ta_fsm.tick(); if (nof_ta_count) { - sched->dl_mac_buffer_state(rnti, (uint32_t)srslte::dl_sch_lcid::TA_CMD, nof_ta_count); + sched->dl_mac_buffer_state(rnti, (uint32_t)srsran::dl_sch_lcid::TA_CMD, nof_ta_count); } } diff --git a/srsenb/src/stack/rrc/CMakeLists.txt b/srsenb/src/stack/rrc/CMakeLists.txt index d6ba7f7f5..b6e415f0d 100644 --- a/srsenb/src/stack/rrc/CMakeLists.txt +++ b/srsenb/src/stack/rrc/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of diff --git a/srsenb/src/stack/rrc/mac_controller.cc b/srsenb/src/stack/rrc/mac_controller.cc index 8d763321c..456b85f73 100644 --- a/srsenb/src/stack/rrc/mac_controller.cc +++ b/srsenb/src/stack/rrc/mac_controller.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -12,8 +12,8 @@ #include "srsenb/hdr/stack/rrc/mac_controller.h" #include "srsenb/hdr/stack/upper/common_enb.h" -#include "srslte/asn1/rrc_utils.h" -#include "srslte/interfaces/enb_mac_interfaces.h" +#include "srsran/asn1/rrc_utils.h" +#include "srsran/interfaces/enb_mac_interfaces.h" namespace srsenb { @@ -70,7 +70,7 @@ void ue_cfg_apply_phy_cfg_ded(ue_cfg_t& ue_cfg, const asn1::rrc::phys_cfg_ded_s& */ void ue_cfg_apply_conn_reconf(ue_cfg_t& ue_cfg, const rrc_conn_recfg_r8_ies_s& conn_recfg, const rrc_cfg_t& rrc_cfg); -void ue_cfg_apply_capabilities(ue_cfg_t& ue_cfg, const rrc_cfg_t& rrc_cfg, const srslte::rrc_ue_capabilities_t& uecaps); +void ue_cfg_apply_capabilities(ue_cfg_t& ue_cfg, const rrc_cfg_t& rrc_cfg, const srsran::rrc_ue_capabilities_t& uecaps); /*************************** * MAC Controller class @@ -161,7 +161,7 @@ int mac_controller::apply_basic_conn_cfg(const asn1::rrc::rr_cfg_ded_s& rr_cfg) current_sched_ue_cfg.ue_bearers[1] = get_bearer_default_srb1_config(); // Set default configuration - current_sched_ue_cfg.supported_cc_list[0].dl_cfg.tm = SRSLTE_TM1; + current_sched_ue_cfg.supported_cc_list[0].dl_cfg.tm = SRSRAN_TM1; current_sched_ue_cfg.use_tbs_index_alt = false; // Apply common PhyConfig updates (e.g. SR/CQI resources, antenna cfg) @@ -201,7 +201,7 @@ void mac_controller::handle_con_reest_complete() } void mac_controller::handle_con_reconf(const asn1::rrc::rrc_conn_recfg_r8_ies_s& conn_recfg, - const srslte::rrc_ue_capabilities_t& uecaps) + const srsran::rrc_ue_capabilities_t& uecaps) { ue_cfg_apply_conn_reconf(current_sched_ue_cfg, conn_recfg, *rrc_cfg); @@ -248,7 +248,7 @@ void mac_controller::apply_current_bearers_cfg() } void mac_controller::handle_target_enb_ho_cmd(const asn1::rrc::rrc_conn_recfg_r8_ies_s& conn_recfg, - const srslte::rrc_ue_capabilities_t& uecaps) + const srsran::rrc_ue_capabilities_t& uecaps) { ue_cfg_apply_conn_reconf(current_sched_ue_cfg, conn_recfg, *rrc_cfg); @@ -265,7 +265,7 @@ void mac_controller::handle_target_enb_ho_cmd(const asn1::rrc::rrc_conn_recfg_r8 } void mac_controller::handle_intraenb_ho_cmd(const asn1::rrc::rrc_conn_recfg_r8_ies_s& conn_recfg, - const srslte::rrc_ue_capabilities_t& uecaps) + const srsran::rrc_ue_capabilities_t& uecaps) { next_sched_ue_cfg = current_sched_ue_cfg; next_sched_ue_cfg.supported_cc_list.resize(1); @@ -304,7 +304,7 @@ void mac_controller::handle_max_retx() set_drb_activation(false); } -void mac_controller::set_scell_activation(const std::bitset& scell_mask) +void mac_controller::set_scell_activation(const std::bitset& scell_mask) { for (uint32_t i = 1; i < current_sched_ue_cfg.supported_cc_list.size(); ++i) { current_sched_ue_cfg.supported_cc_list[i].active = scell_mask[i]; @@ -355,10 +355,10 @@ void ue_cfg_apply_phy_cfg_ded(ue_cfg_t& ue_cfg, const asn1::rrc::phys_cfg_ded_s& // Apply Antenna Configuration if (phy_cfg.ant_info_present) { if (phy_cfg.ant_info.type().value == phys_cfg_ded_s::ant_info_c_::types_opts::explicit_value) { - ue_cfg.dl_ant_info = srslte::make_ant_info_ded(phy_cfg.ant_info.explicit_value()); + ue_cfg.dl_ant_info = srsran::make_ant_info_ded(phy_cfg.ant_info.explicit_value()); } else { srslog::fetch_basic_logger("RRC").warning("No antenna configuration provided"); - pcell_cfg.dl_cfg.tm = SRSLTE_TM1; + pcell_cfg.dl_cfg.tm = SRSRAN_TM1; ue_cfg.dl_ant_info.tx_mode = sched_interface::ant_info_ded_t::tx_mode_t::tm1; } } @@ -502,7 +502,7 @@ void ue_cfg_apply_conn_reconf(ue_cfg_t& ue_cfg, const rrc_conn_recfg_r8_ies_s& c } } -void ue_cfg_apply_capabilities(ue_cfg_t& ue_cfg, const rrc_cfg_t& rrc_cfg, const srslte::rrc_ue_capabilities_t& uecaps) +void ue_cfg_apply_capabilities(ue_cfg_t& ue_cfg, const rrc_cfg_t& rrc_cfg, const srsran::rrc_ue_capabilities_t& uecaps) { bool enb_enable64qam = rrc_cfg.sibs[1].sib2().rr_cfg_common.pusch_cfg_common.pusch_cfg_basic.enable64_qam; ue_cfg.support_ul64qam = ue_cfg_t::ul64qam_cap::undefined; diff --git a/srsenb/src/stack/rrc/rrc.cc b/srsenb/src/stack/rrc/rrc.cc index 36840741c..e969f8b64 100644 --- a/srsenb/src/stack/rrc/rrc.cc +++ b/srsenb/src/stack/rrc/rrc.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,25 +13,25 @@ #include "srsenb/hdr/stack/rrc/rrc.h" #include "srsenb/hdr/stack/rrc/rrc_cell_cfg.h" #include "srsenb/hdr/stack/rrc/rrc_mobility.h" -#include "srslte/asn1/asn1_utils.h" -#include "srslte/asn1/rrc_utils.h" -#include "srslte/common/bcd_helpers.h" -#include "srslte/common/int_helpers.h" -#include "srslte/common/standard_streams.h" -#include "srslte/interfaces/enb_mac_interfaces.h" -#include "srslte/interfaces/enb_pdcp_interfaces.h" -#include "srslte/interfaces/enb_rlc_interfaces.h" -#include "srslte/interfaces/sched_interface.h" - -using srslte::byte_buffer_t; -using srslte::uint32_to_uint8; -using srslte::uint8_to_uint32; +#include "srsran/asn1/asn1_utils.h" +#include "srsran/asn1/rrc_utils.h" +#include "srsran/common/bcd_helpers.h" +#include "srsran/common/int_helpers.h" +#include "srsran/common/standard_streams.h" +#include "srsran/interfaces/enb_mac_interfaces.h" +#include "srsran/interfaces/enb_pdcp_interfaces.h" +#include "srsran/interfaces/enb_rlc_interfaces.h" +#include "srsran/interfaces/sched_interface.h" + +using srsran::byte_buffer_t; +using srsran::uint32_to_uint8; +using srsran::uint8_to_uint32; using namespace asn1::rrc; namespace srsenb { -rrc::rrc(srslte::task_sched_handle task_sched_) : +rrc::rrc(srsran::task_sched_handle task_sched_) : logger(srslog::fetch_basic_logger("RRC")), task_sched(task_sched_), rx_pdu_queue(64) { pending_paging.clear(); @@ -76,7 +76,7 @@ void rrc::init(const rrc_cfg_t& cfg_, uint32_t n310 = cfg.sibs[1].sib2().ue_timers_and_consts.n310.to_number(); logger.info("T310 %d, T311 %d, N310 %d", t310, t311, n310); if (cfg.inactivity_timeout_ms < t310 + t311 + n310) { - srslte::console("\nWarning: Inactivity timeout is smaller than the sum of t310, t311 and n310.\n" + srsran::console("\nWarning: Inactivity timeout is smaller than the sum of t310, t311 and n310.\n" "This may break the UE's re-establishment procedure.\n"); logger.warning("Inactivity timeout is smaller than the sum of t310, t311 and n310. This may break the UE's " "re-establishment procedure."); @@ -160,12 +160,12 @@ int rrc::add_user(uint16_t rnti, const sched_interface::ue_cfg_t& sched_ue_cfg) { auto user_it = users.find(rnti); if (user_it == users.end()) { - if (rnti != SRSLTE_MRNTI) { + if (rnti != SRSRAN_MRNTI) { // only non-eMBMS RNTIs are present in user map std::unique_ptr u{new ue(this, rnti, sched_ue_cfg)}; - if (u->init() != SRSLTE_SUCCESS) { + if (u->init() != SRSRAN_SUCCESS) { logger.error("Adding user rnti=0x%x - Failed to allocate user resources", rnti); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } users.insert(std::make_pair(rnti, std::move(u))); } @@ -176,19 +176,19 @@ int rrc::add_user(uint16_t rnti, const sched_interface::ue_cfg_t& sched_ue_cfg) logger.error("Adding user rnti=0x%x (already exists)", rnti); } - if (rnti == SRSLTE_MRNTI) { + if (rnti == SRSRAN_MRNTI) { uint32_t teid_in = 1; for (auto& mbms_item : mcch.msg.c1().mbsfn_area_cfg_r9().pmch_info_list_r9[0].mbms_session_info_list_r9) { uint32_t lcid = mbms_item.lc_ch_id_r9; // adding UE object to MAC for MRNTI without scheduling configuration (broadcast not part of regular scheduling) - mac->ue_cfg(SRSLTE_MRNTI, NULL); - rlc->add_bearer_mrb(SRSLTE_MRNTI, lcid); - pdcp->add_bearer(SRSLTE_MRNTI, lcid, srslte::make_drb_pdcp_config_t(1, false)); - teid_in = gtpu->add_bearer(SRSLTE_MRNTI, lcid, 1, 1); + mac->ue_cfg(SRSRAN_MRNTI, NULL); + rlc->add_bearer_mrb(SRSRAN_MRNTI, lcid); + pdcp->add_bearer(SRSRAN_MRNTI, lcid, srsran::make_drb_pdcp_config_t(1, false)); + teid_in = gtpu->add_bearer(SRSRAN_MRNTI, lcid, 1, 1); } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } /* Function called by MAC after the reception of a C-RNTI CE indicating that the UE still has a @@ -225,7 +225,7 @@ void rrc::send_rrc_connection_reject(uint16_t rnti) dl_ccch_msg.msg.set_c1().set_rrc_conn_reject().crit_exts.set_c1().set_rrc_conn_reject_r8().wait_time = 10; // Allocate a new PDU buffer, pack the message and send to PDCP - srslte::unique_byte_buffer_t pdu = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t pdu = srsran::make_byte_buffer(); if (pdu == nullptr) { logger.error("Allocating pdu"); return; @@ -246,7 +246,7 @@ void rrc::send_rrc_connection_reject(uint16_t rnti) /******************************************************************************* PDCP interface *******************************************************************************/ -void rrc::write_pdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t pdu) +void rrc::write_pdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t pdu) { rrc_pdu p = {rnti, lcid, std::move(pdu)}; if (not rx_pdu_queue.try_push(std::move(p))) { @@ -257,7 +257,7 @@ void rrc::write_pdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t p /******************************************************************************* S1AP interface *******************************************************************************/ -void rrc::write_dl_info(uint16_t rnti, srslte::unique_byte_buffer_t sdu) +void rrc::write_dl_info(uint16_t rnti, srsran::unique_byte_buffer_t sdu) { dl_dcch_msg_s dl_dcch_msg; dl_dcch_msg.msg.set_c1(); @@ -452,7 +452,7 @@ void rrc::add_paging_id(uint32_t ueid, const asn1::s1ap::ue_paging_id_c& ue_pagi paging_elem.ue_id.set_imsi(); paging_elem.ue_id.imsi().resize(ue_paging_id.imsi().size()); memcpy(paging_elem.ue_id.imsi().data(), ue_paging_id.imsi().data(), ue_paging_id.imsi().size()); - srslte::console("Warning IMSI paging not tested\n"); + srsran::console("Warning IMSI paging not tested\n"); } else { paging_elem.ue_id.set_s_tmsi(); paging_elem.ue_id.s_tmsi().mmec.from_number(ue_paging_id.s_tmsi().mmec[0]); @@ -576,7 +576,7 @@ void rrc::read_pdu_pcch(uint8_t* payload, uint32_t buffer_size) void rrc::ho_preparation_complete(uint16_t rnti, bool is_success, const asn1::s1ap::ho_cmd_s& msg, - srslte::unique_byte_buffer_t rrc_container) + srsran::unique_byte_buffer_t rrc_container) { users.at(rnti)->mobility_handler->handle_ho_preparation_complete(is_success, msg, std::move(rrc_container)); } @@ -597,7 +597,7 @@ void rrc::set_erab_status(uint16_t rnti, const asn1::s1ap::bearers_subject_to_st from either a public function or the internal thread *******************************************************************************/ -void rrc::parse_ul_ccch(uint16_t rnti, srslte::unique_byte_buffer_t pdu) +void rrc::parse_ul_ccch(uint16_t rnti, srsran::unique_byte_buffer_t pdu) { if (pdu) { ul_ccch_msg_s ul_ccch_msg; @@ -636,7 +636,7 @@ void rrc::parse_ul_ccch(uint16_t rnti, srslte::unique_byte_buffer_t pdu) } ///< User mutex must be hold by caller -void rrc::parse_ul_dcch(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t pdu) +void rrc::parse_ul_dcch(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t pdu) { if (pdu) { auto user_it = users.find(rnti); @@ -673,7 +673,7 @@ void rrc::rem_user(uint16_t rnti) { auto user_it = users.find(rnti); if (user_it != users.end()) { - srslte::console("Disconnecting rnti=0x%x.\n", rnti); + srsran::console("Disconnecting rnti=0x%x.\n", rnti); logger.info("Disconnecting rnti=0x%x.", rnti); /* First remove MAC and GTPU to stop processing DL/UL traffic for this user @@ -728,7 +728,7 @@ void rrc::config_mac() item.n1pucch_an = cfg.sibs[1].sib2().rr_cfg_common.pucch_cfg_common.n1_pucch_an; item.nrb_cqi = cfg.sibs[1].sib2().rr_cfg_common.pucch_cfg_common.nrb_cqi; - item.nrb_pucch = SRSLTE_MAX(cfg.sr_cfg.nof_prb, cfg.cqi_cfg.nof_prb); + item.nrb_pucch = SRSRAN_MAX(cfg.sr_cfg.nof_prb, cfg.cqi_cfg.nof_prb); logger.info("Allocating %d PRBs for PUCCH", item.nrb_pucch); // Copy base cell configuration @@ -808,7 +808,7 @@ uint32_t rrc::generate_sibs() // Pack payload for all messages for (uint32_t msg_index = 0; msg_index < nof_messages; msg_index++) { - srslte::unique_byte_buffer_t sib_buffer = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t sib_buffer = srsran::make_byte_buffer(); asn1::bit_ref bref(sib_buffer->msg, sib_buffer->get_tailroom()); if (msg[msg_index].pack(bref) == asn1::SRSASN_ERROR_ENCODE_FAIL) { logger.error("Failed to pack SIB message %d", msg_index); @@ -833,48 +833,48 @@ uint32_t rrc::generate_sibs() void rrc::configure_mbsfn_sibs() { // populate struct with sib2 values needed in PHY/MAC - srslte::sib2_mbms_t sibs2; + srsran::sib2_mbms_t sibs2; sibs2.mbsfn_sf_cfg_list_present = cfg.sibs[1].sib2().mbsfn_sf_cfg_list_present; sibs2.nof_mbsfn_sf_cfg = cfg.sibs[1].sib2().mbsfn_sf_cfg_list.size(); for (int i = 0; i < sibs2.nof_mbsfn_sf_cfg; i++) { - sibs2.mbsfn_sf_cfg_list[i].nof_alloc_subfrs = srslte::mbsfn_sf_cfg_t::sf_alloc_type_t::one_frame; + sibs2.mbsfn_sf_cfg_list[i].nof_alloc_subfrs = srsran::mbsfn_sf_cfg_t::sf_alloc_type_t::one_frame; sibs2.mbsfn_sf_cfg_list[i].radioframe_alloc_offset = cfg.sibs[1].sib2().mbsfn_sf_cfg_list[i].radioframe_alloc_offset; sibs2.mbsfn_sf_cfg_list[i].radioframe_alloc_period = - (srslte::mbsfn_sf_cfg_t::alloc_period_t)cfg.sibs[1].sib2().mbsfn_sf_cfg_list[i].radioframe_alloc_period.value; + (srsran::mbsfn_sf_cfg_t::alloc_period_t)cfg.sibs[1].sib2().mbsfn_sf_cfg_list[i].radioframe_alloc_period.value; sibs2.mbsfn_sf_cfg_list[i].sf_alloc = (uint32_t)cfg.sibs[1].sib2().mbsfn_sf_cfg_list[i].sf_alloc.one_frame().to_number(); } // populate struct with sib13 values needed for PHY/MAC - srslte::sib13_t sibs13; + srsran::sib13_t sibs13; sibs13.notif_cfg.notif_offset = cfg.sibs[12].sib13_v920().notif_cfg_r9.notif_offset_r9; sibs13.notif_cfg.notif_repeat_coeff = - (srslte::mbms_notif_cfg_t::coeff_t)cfg.sibs[12].sib13_v920().notif_cfg_r9.notif_repeat_coeff_r9.value; + (srsran::mbms_notif_cfg_t::coeff_t)cfg.sibs[12].sib13_v920().notif_cfg_r9.notif_repeat_coeff_r9.value; sibs13.notif_cfg.notif_sf_idx = cfg.sibs[12].sib13_v920().notif_cfg_r9.notif_sf_idx_r9; sibs13.nof_mbsfn_area_info = cfg.sibs[12].sib13_v920().mbsfn_area_info_list_r9.size(); for (uint32_t i = 0; i < sibs13.nof_mbsfn_area_info; i++) { sibs13.mbsfn_area_info_list[i].mbsfn_area_id = cfg.sibs[12].sib13_v920().mbsfn_area_info_list_r9[i].mbsfn_area_id_r9; sibs13.mbsfn_area_info_list[i].notif_ind = cfg.sibs[12].sib13_v920().mbsfn_area_info_list_r9[i].notif_ind_r9; - sibs13.mbsfn_area_info_list[i].mcch_cfg.sig_mcs = (srslte::mbsfn_area_info_t::mcch_cfg_t::sig_mcs_t)cfg.sibs[12] + sibs13.mbsfn_area_info_list[i].mcch_cfg.sig_mcs = (srsran::mbsfn_area_info_t::mcch_cfg_t::sig_mcs_t)cfg.sibs[12] .sib13_v920() .mbsfn_area_info_list_r9[i] .mcch_cfg_r9.sig_mcs_r9.value; sibs13.mbsfn_area_info_list[i].mcch_cfg.sf_alloc_info = cfg.sibs[12].sib13_v920().mbsfn_area_info_list_r9[i].mcch_cfg_r9.sf_alloc_info_r9.to_number(); sibs13.mbsfn_area_info_list[i].mcch_cfg.mcch_repeat_period = - (srslte::mbsfn_area_info_t::mcch_cfg_t::repeat_period_t)cfg.sibs[12] + (srsran::mbsfn_area_info_t::mcch_cfg_t::repeat_period_t)cfg.sibs[12] .sib13_v920() .mbsfn_area_info_list_r9[i] .mcch_cfg_r9.mcch_repeat_period_r9.value; sibs13.mbsfn_area_info_list[i].mcch_cfg.mcch_offset = cfg.sibs[12].sib13_v920().mbsfn_area_info_list_r9[i].mcch_cfg_r9.mcch_offset_r9; sibs13.mbsfn_area_info_list[i].mcch_cfg.mcch_mod_period = - (srslte::mbsfn_area_info_t::mcch_cfg_t::mod_period_t)cfg.sibs[12] + (srsran::mbsfn_area_info_t::mcch_cfg_t::mod_period_t)cfg.sibs[12] .sib13_v920() .mbsfn_area_info_list_r9[i] .mcch_cfg_r9.mcch_mod_period_r9.value; - sibs13.mbsfn_area_info_list[i].non_mbsfn_region_len = (srslte::mbsfn_area_info_t::region_len_t)cfg.sibs[12] + sibs13.mbsfn_area_info_list[i].non_mbsfn_region_len = (srsran::mbsfn_area_info_t::region_len_t)cfg.sibs[12] .sib13_v920() .mbsfn_area_info_list_r9[i] .non_mbsfn_region_len.value; @@ -883,15 +883,15 @@ void rrc::configure_mbsfn_sibs() // pack MCCH for transmission and pass relevant MCCH values to PHY/MAC pack_mcch(); - srslte::mcch_msg_t mcch_t; - mcch_t.common_sf_alloc_period = srslte::mcch_msg_t::common_sf_alloc_period_t::rf64; + srsran::mcch_msg_t mcch_t; + mcch_t.common_sf_alloc_period = srsran::mcch_msg_t::common_sf_alloc_period_t::rf64; mcch_t.nof_common_sf_alloc = 1; - srslte::mbsfn_sf_cfg_t sf_alloc_item = mcch_t.common_sf_alloc[0]; + srsran::mbsfn_sf_cfg_t sf_alloc_item = mcch_t.common_sf_alloc[0]; sf_alloc_item.radioframe_alloc_offset = 0; - sf_alloc_item.radioframe_alloc_period = srslte::mbsfn_sf_cfg_t::alloc_period_t::n1; + sf_alloc_item.radioframe_alloc_period = srsran::mbsfn_sf_cfg_t::alloc_period_t::n1; sf_alloc_item.sf_alloc = 63; mcch_t.nof_pmch_info = 1; - srslte::pmch_info_t* pmch_item = &mcch_t.pmch_info_list[0]; + srsran::pmch_info_t* pmch_item = &mcch_t.pmch_info_list[0]; pmch_item->nof_mbms_session_info = 1; pmch_item->mbms_session_info_list[0].lc_ch_id = 1; @@ -905,7 +905,7 @@ void rrc::configure_mbsfn_sibs() } logger.debug("PMCH data MCS=%d", mbms_mcs); pmch_item->data_mcs = mbms_mcs; - pmch_item->mch_sched_period = srslte::pmch_info_t::mch_sched_period_t::rf64; + pmch_item->mch_sched_period = srsran::pmch_info_t::mch_sched_period_t::rf64; pmch_item->sf_alloc_end = 64 * 6; phy->configure_mbsfn(&sibs2, &sibs13, mcch_t); mac->write_mcch(&sibs2, &sibs13, &mcch_t, mcch_payload_buffer, current_mcch_length); @@ -930,9 +930,9 @@ int rrc::pack_mcch() pmch_item->mbms_session_info_list_r9[0].session_id_r9_present = true; pmch_item->mbms_session_info_list_r9[0].session_id_r9[0] = 0; pmch_item->mbms_session_info_list_r9[0].tmgi_r9.plmn_id_r9.set_explicit_value_r9(); - srslte::plmn_id_t plmn_obj; + srsran::plmn_id_t plmn_obj; plmn_obj.from_string("00003"); - srslte::to_asn1(&pmch_item->mbms_session_info_list_r9[0].tmgi_r9.plmn_id_r9.explicit_value_r9(), plmn_obj); + srsran::to_asn1(&pmch_item->mbms_session_info_list_r9[0].tmgi_r9.plmn_id_r9.explicit_value_r9(), plmn_obj); uint8_t byte[] = {0x0, 0x0, 0x0}; memcpy(&pmch_item->mbms_session_info_list_r9[0].tmgi_r9.service_id_r9[0], &byte[0], 3); diff --git a/srsenb/src/stack/rrc/rrc_bearer_cfg.cc b/srsenb/src/stack/rrc/rrc_bearer_cfg.cc index b7873fbe8..d9a6f3b89 100644 --- a/srsenb/src/stack/rrc/rrc_bearer_cfg.cc +++ b/srsenb/src/stack/rrc/rrc_bearer_cfg.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -12,8 +12,8 @@ #include "srsenb/hdr/stack/rrc/rrc_bearer_cfg.h" #include "srsenb/hdr/stack/upper/common_enb.h" -#include "srslte/asn1/rrc_utils.h" -#include "srslte/rrc/rrc_cfg_utils.h" +#include "srsran/asn1/rrc_utils.h" +#include "srsran/rrc/rrc_cfg_utils.h" namespace srsenb { @@ -49,18 +49,18 @@ bool security_cfg_handler::set_security_capabilities(const asn1::s1ap::ue_securi for (auto& cipher_item : cfg->eea_preference_list) { auto& v = security_capabilities.encryption_algorithms; switch (cipher_item) { - case srslte::CIPHERING_ALGORITHM_ID_EEA0: + case srsran::CIPHERING_ALGORITHM_ID_EEA0: // “all bits equal to 0” – UE supports no other algorithm than EEA0, // specification does not cover the case in which EEA0 is supported with other algorithms // just assume that EEA0 is always supported even this can not be explicity signaled by S1AP - sec_cfg.cipher_algo = srslte::CIPHERING_ALGORITHM_ID_EEA0; + sec_cfg.cipher_algo = srsran::CIPHERING_ALGORITHM_ID_EEA0; enc_algo_found = true; logger.info("Selected EEA0 as RRC encryption algorithm"); break; - case srslte::CIPHERING_ALGORITHM_ID_128_EEA1: + case srsran::CIPHERING_ALGORITHM_ID_128_EEA1: // “first bit” – 128-EEA1, - if (v.get(v.length() - srslte::CIPHERING_ALGORITHM_ID_128_EEA1)) { - sec_cfg.cipher_algo = srslte::CIPHERING_ALGORITHM_ID_128_EEA1; + if (v.get(v.length() - srsran::CIPHERING_ALGORITHM_ID_128_EEA1)) { + sec_cfg.cipher_algo = srsran::CIPHERING_ALGORITHM_ID_128_EEA1; enc_algo_found = true; logger.info("Selected EEA1 as RRC encryption algorithm"); break; @@ -68,10 +68,10 @@ bool security_cfg_handler::set_security_capabilities(const asn1::s1ap::ue_securi logger.info("Failed to selected EEA1 as RRC encryption algorithm, due to unsupported algorithm"); } break; - case srslte::CIPHERING_ALGORITHM_ID_128_EEA2: + case srsran::CIPHERING_ALGORITHM_ID_128_EEA2: // “second bit” – 128-EEA2, - if (v.get(v.length() - srslte::CIPHERING_ALGORITHM_ID_128_EEA2)) { - sec_cfg.cipher_algo = srslte::CIPHERING_ALGORITHM_ID_128_EEA2; + if (v.get(v.length() - srsran::CIPHERING_ALGORITHM_ID_128_EEA2)) { + sec_cfg.cipher_algo = srsran::CIPHERING_ALGORITHM_ID_128_EEA2; enc_algo_found = true; logger.info("Selected EEA2 as RRC encryption algorithm"); break; @@ -79,10 +79,10 @@ bool security_cfg_handler::set_security_capabilities(const asn1::s1ap::ue_securi logger.info("Failed to selected EEA2 as RRC encryption algorithm, due to unsupported algorithm"); } break; - case srslte::CIPHERING_ALGORITHM_ID_128_EEA3: + case srsran::CIPHERING_ALGORITHM_ID_128_EEA3: // “third bit” – 128-EEA3, - if (v.get(v.length() - srslte::CIPHERING_ALGORITHM_ID_128_EEA3)) { - sec_cfg.cipher_algo = srslte::CIPHERING_ALGORITHM_ID_128_EEA3; + if (v.get(v.length() - srsran::CIPHERING_ALGORITHM_ID_128_EEA3)) { + sec_cfg.cipher_algo = srsran::CIPHERING_ALGORITHM_ID_128_EEA3; enc_algo_found = true; logger.info("Selected EEA3 as RRC encryption algorithm"); break; @@ -102,34 +102,34 @@ bool security_cfg_handler::set_security_capabilities(const asn1::s1ap::ue_securi for (auto& eia_enum : cfg->eia_preference_list) { auto& v = security_capabilities.integrity_protection_algorithms; switch (eia_enum) { - case srslte::INTEGRITY_ALGORITHM_ID_EIA0: + case srsran::INTEGRITY_ALGORITHM_ID_EIA0: // Null integrity is not supported logger.info("Skipping EIA0 as RRC integrity algorithm. Null integrity is not supported."); break; - case srslte::INTEGRITY_ALGORITHM_ID_128_EIA1: + case srsran::INTEGRITY_ALGORITHM_ID_128_EIA1: // “first bit” – 128-EIA1, - if (v.get(v.length() - srslte::INTEGRITY_ALGORITHM_ID_128_EIA1)) { - sec_cfg.integ_algo = srslte::INTEGRITY_ALGORITHM_ID_128_EIA1; + if (v.get(v.length() - srsran::INTEGRITY_ALGORITHM_ID_128_EIA1)) { + sec_cfg.integ_algo = srsran::INTEGRITY_ALGORITHM_ID_128_EIA1; integ_algo_found = true; logger.info("Selected EIA1 as RRC integrity algorithm."); } else { logger.info("Failed to selected EIA1 as RRC encryption algorithm, due to unsupported algorithm"); } break; - case srslte::INTEGRITY_ALGORITHM_ID_128_EIA2: + case srsran::INTEGRITY_ALGORITHM_ID_128_EIA2: // “second bit” – 128-EIA2, - if (v.get(v.length() - srslte::INTEGRITY_ALGORITHM_ID_128_EIA2)) { - sec_cfg.integ_algo = srslte::INTEGRITY_ALGORITHM_ID_128_EIA2; + if (v.get(v.length() - srsran::INTEGRITY_ALGORITHM_ID_128_EIA2)) { + sec_cfg.integ_algo = srsran::INTEGRITY_ALGORITHM_ID_128_EIA2; integ_algo_found = true; logger.info("Selected EIA2 as RRC integrity algorithm."); } else { logger.info("Failed to selected EIA2 as RRC encryption algorithm, due to unsupported algorithm"); } break; - case srslte::INTEGRITY_ALGORITHM_ID_128_EIA3: + case srsran::INTEGRITY_ALGORITHM_ID_128_EIA3: // “third bit” – 128-EIA3, - if (v.get(v.length() - srslte::INTEGRITY_ALGORITHM_ID_128_EIA3)) { - sec_cfg.integ_algo = srslte::INTEGRITY_ALGORITHM_ID_128_EIA3; + if (v.get(v.length() - srsran::INTEGRITY_ALGORITHM_ID_128_EIA3)) { + sec_cfg.integ_algo = srsran::INTEGRITY_ALGORITHM_ID_128_EIA3; integ_algo_found = true; logger.info("Selected EIA3 as RRC integrity algorithm."); } else { @@ -169,7 +169,7 @@ void security_cfg_handler::set_security_key(const asn1::fixed_bitstring<256, fal void security_cfg_handler::generate_as_keys() { // Generate K_rrc_enc and K_rrc_int - srslte::security_generate_k_rrc( + srsran::security_generate_k_rrc( k_enb, sec_cfg.cipher_algo, sec_cfg.integ_algo, sec_cfg.k_rrc_enc.data(), sec_cfg.k_rrc_int.data()); // Generate K_up_enc and K_up_int @@ -188,7 +188,7 @@ void security_cfg_handler::regenerate_keys_handover(uint32_t new_pci, uint32_t n logger.info(k_enb, 32, "Old K_eNB (k_enb)"); // Generate K_enb* uint8_t k_enb_star[32]; - srslte::security_generate_k_enb_star(k_enb, new_pci, new_dl_earfcn, k_enb_star); + srsran::security_generate_k_enb_star(k_enb, new_pci, new_dl_earfcn, k_enb_star); // K_enb becomes K_enb* memcpy(k_enb, k_enb_star, 32); @@ -212,7 +212,7 @@ int bearer_cfg_handler::add_erab(uint8_t { if (erab_id < 5) { logger->error("ERAB id=%d is invalid", erab_id); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } uint8_t lcid = erab_id - 2; // Map e.g. E-RAB 5 to LCID 3 (==DRB1) uint8_t drbid = erab_id - 4; @@ -220,11 +220,11 @@ int bearer_cfg_handler::add_erab(uint8_t auto qci_it = cfg->qci_cfg.find(qos.qci); if (qci_it == cfg->qci_cfg.end() or not qci_it->second.configured) { logger->error("QCI=%d not configured", qos.qci); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (lcid < 3 or lcid > 10) { logger->error("DRB logical channel ids must be within 3 and 10"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } const rrc_cfg_qci_t& qci_cfg = qci_it->second; @@ -235,7 +235,7 @@ int bearer_cfg_handler::add_erab(uint8_t if (addr.length() > 32) { logger->error("Only addresses with length <= 32 are supported"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (nas_pdu != nullptr and nas_pdu->size() > 0) { @@ -245,7 +245,7 @@ int bearer_cfg_handler::add_erab(uint8_t } // Set DRBtoAddMod - auto drb_it = srslte::add_rrc_obj_id(current_drbs, drbid); + auto drb_it = srsran::add_rrc_obj_id(current_drbs, drbid); drb_it->lc_ch_id_present = true; drb_it->lc_ch_id = (uint8_t)lcid; drb_it->eps_bearer_id_present = true; @@ -259,7 +259,7 @@ int bearer_cfg_handler::add_erab(uint8_t drb_it->rlc_cfg_present = true; drb_it->rlc_cfg = qci_cfg.rlc_cfg; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } bool bearer_cfg_handler::release_erab(uint8_t erab_id) @@ -272,7 +272,7 @@ bool bearer_cfg_handler::release_erab(uint8_t erab_id) uint8_t drb_id = erab_id - 4; - srslte::rem_rrc_obj_id(current_drbs, drb_id); + srsran::rem_rrc_obj_id(current_drbs, drb_id); erabs.erase(it); erab_info_list.erase(erab_id); diff --git a/srsenb/src/stack/rrc/rrc_cell_cfg.cc b/srsenb/src/stack/rrc/rrc_cell_cfg.cc index 9ee7fd276..770942d4d 100644 --- a/srsenb/src/stack/rrc/rrc_cell_cfg.cc +++ b/srsenb/src/stack/rrc/rrc_cell_cfg.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,7 +11,7 @@ */ #include "srsenb/hdr/stack/rrc/rrc_cell_cfg.h" -#include "srslte/phy/utils/vector.h" +#include "srsran/phy/utils/vector.h" using namespace asn1::rrc; @@ -42,7 +42,7 @@ enb_cell_common_list::enb_cell_common_list(const rrc_cfg_t& cfg_) : cfg(cfg_) cell_access->cell_id.from_number((cfg.enb_id << 8u) + new_cell->cell_cfg.cell_id); cell_access->tac.from_number(new_cell->cell_cfg.tac); // Update DL EARFCN - new_cell->sib1.freq_band_ind = (uint8_t)srslte_band_get_band(new_cell->cell_cfg.dl_earfcn); + new_cell->sib1.freq_band_ind = (uint8_t)srsran_band_get_band(new_cell->cell_cfg.dl_earfcn); // Set Cell SIB2 // update PRACH root seq index for this cell @@ -333,9 +333,9 @@ bool ue_cell_ded_list::alloc_cqi_resources(uint32_t ue_cc_idx, uint32_t period) } const auto& pcell_pucch_cfg = get_ue_cc_idx(UE_PCELL_CC_IDX)->cell_common->sib2.rr_cfg_common.pucch_cfg_common; - uint32_t c = SRSLTE_CP_ISNORM(cfg.cell.cp) ? 3 : 2; + uint32_t c = SRSRAN_CP_ISNORM(cfg.cell.cp) ? 3 : 2; uint32_t delta_pucch_shift = pcell_pucch_cfg.delta_pucch_shift.to_number(); - delta_pucch_shift = SRSLTE_MAX(1, delta_pucch_shift); + delta_pucch_shift = SRSRAN_MAX(1, delta_pucch_shift); uint32_t max_users = 12 * c / delta_pucch_shift; // Allocate all CQI resources for all carriers now @@ -438,9 +438,9 @@ bool ue_cell_ded_list::alloc_sr_resources(uint32_t period) return false; } - uint32_t c = SRSLTE_CP_ISNORM(cfg.cell.cp) ? 3 : 2; + uint32_t c = SRSRAN_CP_ISNORM(cfg.cell.cp) ? 3 : 2; uint32_t delta_pucch_shift = cell->cell_common->sib2.rr_cfg_common.pucch_cfg_common.delta_pucch_shift.to_number(); - delta_pucch_shift = SRSLTE_MAX(1, delta_pucch_shift); // prevent div by zero + delta_pucch_shift = SRSRAN_MAX(1, delta_pucch_shift); // prevent div by zero uint32_t max_users = 12 * c / delta_pucch_shift; // Find freq-time resources with least number of users diff --git a/srsenb/src/stack/rrc/rrc_mobility.cc b/srsenb/src/stack/rrc/rrc_mobility.cc index afe7f6b46..f96704c64 100644 --- a/srsenb/src/stack/rrc/rrc_mobility.cc +++ b/srsenb/src/stack/rrc/rrc_mobility.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -15,17 +15,17 @@ #include "srsenb/hdr/stack/rrc/rrc_cell_cfg.h" #include "srsenb/hdr/stack/rrc/ue_meas_cfg.h" #include "srsenb/hdr/stack/rrc/ue_rr_cfg.h" -#include "srslte/asn1/rrc_utils.h" -#include "srslte/common/bcd_helpers.h" -#include "srslte/common/common.h" -#include "srslte/common/enb_events.h" -#include "srslte/common/int_helpers.h" -#include "srslte/common/standard_streams.h" -#include "srslte/interfaces/enb_mac_interfaces.h" -#include "srslte/interfaces/enb_pdcp_interfaces.h" -#include "srslte/interfaces/enb_rlc_interfaces.h" -#include "srslte/interfaces/enb_s1ap_interfaces.h" -#include "srslte/rrc/rrc_cfg_utils.h" +#include "srsran/asn1/rrc_utils.h" +#include "srsran/common/bcd_helpers.h" +#include "srsran/common/common.h" +#include "srsran/common/enb_events.h" +#include "srsran/common/int_helpers.h" +#include "srsran/common/standard_streams.h" +#include "srsran/interfaces/enb_mac_interfaces.h" +#include "srsran/interfaces/enb_pdcp_interfaces.h" +#include "srsran/interfaces/enb_rlc_interfaces.h" +#include "srsran/interfaces/enb_s1ap_interfaces.h" +#include "srsran/rrc/rrc_cfg_utils.h" #include #include @@ -63,7 +63,7 @@ uint32_t eci_to_enbid(uint32_t eci) uint16_t compute_mac_i(uint16_t crnti, uint32_t cellid, uint16_t pci, - srslte::INTEGRITY_ALGORITHM_ID_ENUM integ_algo, + srsran::INTEGRITY_ALGORITHM_ID_ENUM integ_algo, const uint8_t* k_rrc_int) { static srslog::basic_logger& logger = srslog::fetch_basic_logger("RRC"); @@ -87,8 +87,8 @@ uint16_t compute_mac_i(uint16_t crnti, // Compute MAC-I switch (integ_algo) { - case srslte::INTEGRITY_ALGORITHM_ID_128_EIA1: - srslte::security_128_eia1(&k_rrc_int[16], + case srsran::INTEGRITY_ALGORITHM_ID_128_EIA1: + srsran::security_128_eia1(&k_rrc_int[16], 0xffffffff, // 32-bit all to ones 0x1f, // 5-bit all to ones 1, // 1-bit to one @@ -96,8 +96,8 @@ uint16_t compute_mac_i(uint16_t crnti, N_bytes, mac_key); break; - case srslte::INTEGRITY_ALGORITHM_ID_128_EIA2: - srslte::security_128_eia2(&k_rrc_int[16], + case srsran::INTEGRITY_ALGORITHM_ID_128_EIA2: + srsran::security_128_eia2(&k_rrc_int[16], 0xffffffff, // 32-bit all to ones 0x1f, // 5-bit all to ones 1, // 1-bit to one @@ -147,7 +147,7 @@ uint16_t rrc::start_ho_ue_resource_alloc(const asn1::s1ap::ho_request_s& const enb_cell_common* target_cell = cell_common_list->get_cell_id(rrc_details::eci_to_cellid(target_eci)); if (target_cell == nullptr) { logger.error("The S1-handover target cell_id=0x%x does not exist", rrc_details::eci_to_cellid(target_eci)); - return SRSLTE_INVALID_RNTI; + return SRSRAN_INVALID_RNTI; } /* Create new User */ @@ -158,11 +158,11 @@ uint16_t rrc::start_ho_ue_resource_alloc(const asn1::s1ap::ho_request_s& ue_cfg.supported_cc_list[0].active = true; ue_cfg.supported_cc_list[0].enb_cc_idx = target_cell->enb_cc_idx; ue_cfg.ue_bearers[0].direction = sched_interface::ue_bearer_cfg_t::BOTH; - ue_cfg.supported_cc_list[0].dl_cfg.tm = SRSLTE_TM1; + ue_cfg.supported_cc_list[0].dl_cfg.tm = SRSRAN_TM1; uint16_t rnti = mac->reserve_new_crnti(ue_cfg); - if (rnti == SRSLTE_INVALID_RNTI) { + if (rnti == SRSRAN_INVALID_RNTI) { logger.error("Failed to allocate C-RNTI resources"); - return SRSLTE_INVALID_RNTI; + return SRSRAN_INVALID_RNTI; } // Register new user in RRC @@ -180,7 +180,7 @@ uint16_t rrc::start_ho_ue_resource_alloc(const asn1::s1ap::ho_request_s& // TODO: KeNB derivations if (not ue_ptr->mobility_handler->start_s1_tenb_ho(msg, container)) { rem_user_thread(rnti); - return SRSLTE_INVALID_RNTI; + return SRSRAN_INVALID_RNTI; } return rnti; } @@ -209,7 +209,7 @@ bool rrc::ue::rrc_mobility::fill_conn_recfg_no_ho_cmd(asn1::rrc::rrc_conn_recfg_ } //! Method called whenever the eNB receives a MeasReport from the UE. In normal situations, an HO procedure is started -void rrc::ue::rrc_mobility::handle_ue_meas_report(const meas_report_s& msg, srslte::unique_byte_buffer_t pdu) +void rrc::ue::rrc_mobility::handle_ue_meas_report(const meas_report_s& msg, srsran::unique_byte_buffer_t pdu) { if (not is_in_state()) { Info("Received a MeasReport while UE is performing Handover. Ignoring..."); @@ -228,7 +228,7 @@ void rrc::ue::rrc_mobility::handle_ue_meas_report(const meas_report_s& msg, srsl } const meas_id_list& measid_list = rrc_ue->current_ue_cfg.meas_cfg.meas_id_to_add_mod_list; const meas_obj_list& measobj_list = rrc_ue->current_ue_cfg.meas_cfg.meas_obj_to_add_mod_list; - auto measid_it = srslte::find_rrc_obj_id(measid_list, meas_res.meas_id); + auto measid_it = srsran::find_rrc_obj_id(measid_list, meas_res.meas_id); if (measid_it == measid_list.end()) { Warning("The measurement ID %d provided by the UE does not exist.", meas_res.meas_id); return; @@ -237,7 +237,7 @@ void rrc::ue::rrc_mobility::handle_ue_meas_report(const meas_report_s& msg, srsl // Find respective ReportCfg and MeasObj ho_meas_report_ev meas_ev{}; - auto obj_it = srslte::find_rrc_obj_id(measobj_list, measid_it->meas_obj_id); + auto obj_it = srsran::find_rrc_obj_id(measobj_list, measid_it->meas_obj_id); meas_ev.meas_obj = &(*obj_it); // iterate from strongest to weakest cell @@ -284,8 +284,8 @@ bool rrc::ue::rrc_mobility::start_ho_preparation(uint32_t target_eci, return false; } - srslte::plmn_id_t target_plmn = - srslte::make_plmn_id_t(rrc_enb->cfg.sib1.cell_access_related_info.plmn_id_list[0].plmn_id); + srsran::plmn_id_t target_plmn = + srsran::make_plmn_id_t(rrc_enb->cfg.sib1.cell_access_related_info.plmn_id_list[0].plmn_id); const ue_cell_ded* src_cell_ded = rrc_ue->ue_cell_list.get_ue_cc_idx(UE_PCELL_CC_IDX); const enb_cell_common* src_cell_cfg = src_cell_ded->cell_common; @@ -328,7 +328,7 @@ bool rrc::ue::rrc_mobility::start_ho_preparation(uint32_t target_eci, hoprep_r8.ue_radio_access_cap_info.resize(1); hoprep_r8.ue_radio_access_cap_info[0].rat_type = asn1::rrc::rat_type_e::eutra; - srslte::unique_byte_buffer_t buffer = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t buffer = srsran::make_byte_buffer(); asn1::bit_ref bref(buffer->msg, buffer->get_tailroom()); if (rrc_ue->eutra_capabilities.pack(bref) == asn1::SRSASN_ERROR_ENCODE_FAIL) { logger.error("Failed to pack UE EUTRA Capability"); @@ -367,7 +367,7 @@ bool rrc::ue::rrc_mobility::start_ho_preparation(uint32_t target_eci, rrc_ue->ue_security_cfg.get_as_sec_cfg().k_rrc_int.data())); /*** pack HO Preparation Info into an RRC container buffer ***/ - srslte::unique_byte_buffer_t buffer = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t buffer = srsran::make_byte_buffer(); asn1::bit_ref bref(buffer->msg, buffer->get_tailroom()); if (hoprep.pack(bref) == asn1::SRSASN_ERROR_ENCODE_FAIL) { Error("Failed to pack HO preparation msg"); @@ -395,11 +395,11 @@ bool rrc::ue::rrc_mobility::start_ho_preparation(uint32_t target_eci, */ void rrc::ue::rrc_mobility::handle_ho_preparation_complete(bool is_success, const asn1::s1ap::ho_cmd_s& msg, - srslte::unique_byte_buffer_t container) + srsran::unique_byte_buffer_t container) { if (not is_success) { logger.info("Received S1AP HandoverFailure. Aborting Handover..."); - trigger(srslte::failure_ev{}); + trigger(srsran::failure_ev{}); return; } /* unpack RRC HOCmd struct and perform sanity checks */ @@ -539,7 +539,7 @@ bool rrc::ue::rrc_mobility::s1_source_ho_st::start_enb_status_transfer(const asn s1ap_interface_rrc::bearer_status_info b = {}; uint8_t lcid = erab_pair.second.id - 2u; b.erab_id = erab_pair.second.id; - srslte::pdcp_lte_state_t pdcp_state = {}; + srsran::pdcp_lte_state_t pdcp_state = {}; if (not rrc_enb->pdcp->get_bearer_state(rrc_ue->rnti, lcid, &pdcp_state)) { Error("PDCP bearer lcid=%d for rnti=0x%x was not found", lcid, rrc_ue->rnti); return false; @@ -585,12 +585,12 @@ bool rrc::ue::rrc_mobility::s1_source_ho_st::start_enb_status_transfer(const asn void rrc::ue::rrc_mobility::s1_source_ho_st::enter(rrc_mobility* f, const ho_meas_report_ev& ev) { - srslte::console("Starting S1 Handover of rnti=0x%x to cellid=0x%x.\n", rrc_ue->rnti, ev.target_eci); + srsran::console("Starting S1 Handover of rnti=0x%x to cellid=0x%x.\n", rrc_ue->rnti, ev.target_eci); logger.info("Starting S1 Handover of rnti=0x%x to cellid=0x%x.", rrc_ue->rnti, ev.target_eci); report = ev; if (not parent_fsm()->start_ho_preparation(report.target_eci, report.meas_obj->meas_obj_id, false)) { - trigger(srslte::failure_ev{}); + trigger(srsran::failure_ev{}); } } @@ -670,13 +670,13 @@ void rrc::ue::rrc_mobility::handle_ho_requested(idle_st& s, const ho_req_rx_ev& asn1::rrc::ho_prep_info_s hoprep; if (hoprep.unpack(bref) != asn1::SRSASN_SUCCESS) { rrc_enb->logger.error("Failed to decode HandoverPreparationinformation in S1AP SourceENBToTargetENBContainer"); - trigger(srslte::failure_ev{}); + trigger(srsran::failure_ev{}); return; } if (hoprep.crit_exts.type().value != c1_or_crit_ext_opts::c1 or hoprep.crit_exts.c1().type().value != ho_prep_info_s::crit_exts_c_::c1_c_::types_opts::ho_prep_info_r8) { rrc_enb->logger.error("Only release 8 supported"); - trigger(srslte::failure_ev{}); + trigger(srsran::failure_ev{}); return; } rrc_enb->log_rrc_message("HandoverPreparation", direction_t::fromS1AP, rrc_container, hoprep, "HandoverPreparation"); @@ -710,11 +710,11 @@ void rrc::ue::rrc_mobility::handle_ho_requested(idle_st& s, const ho_req_rx_ev& ho_req.ho_req_msg->protocol_ies.security_context.value.next_hop_chaining_count; /* Prepare Handover Command to be sent via S1AP */ - srslte::unique_byte_buffer_t ho_cmd_pdu = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t ho_cmd_pdu = srsran::make_byte_buffer(); asn1::bit_ref bref2{ho_cmd_pdu->msg, ho_cmd_pdu->get_tailroom()}; if (dl_dcch_msg.pack(bref2) != asn1::SRSASN_SUCCESS) { logger.error("Failed to pack HandoverCommand"); - trigger(srslte::failure_ev{}); + trigger(srsran::failure_ev{}); return; } ho_cmd_pdu->N_bytes = bref2.distance_bytes(); @@ -727,7 +727,7 @@ void rrc::ue::rrc_mobility::handle_ho_requested(idle_st& s, const ho_req_rx_ev& bref2 = {ho_cmd_pdu->msg, ho_cmd_pdu->get_tailroom()}; if (ho_cmd.pack(bref2) != asn1::SRSASN_SUCCESS) { logger.error("Failed to pack HandoverCommand"); - trigger(srslte::failure_ev{}); + trigger(srsran::failure_ev{}); return; } ho_cmd_pdu->N_bytes = bref2.distance_bytes(); @@ -749,7 +749,7 @@ void rrc::ue::rrc_mobility::handle_ho_requested(idle_st& s, const ho_req_rx_ev& admitted_erabs.emplace_back(); asn1::s1ap::erab_admitted_item_s& admitted_erab = admitted_erabs.back(); admitted_erab.erab_id = erab.second.id; - srslte::uint32_to_uint8(erab.second.teid_in, admitted_erab.gtp_teid.data()); + srsran::uint32_to_uint8(erab.second.teid_in, admitted_erab.gtp_teid.data()); // Establish GTPU Forwarding Paths if (ho_req.transparent_container->erab_info_list_present) { @@ -774,7 +774,7 @@ void rrc::ue::rrc_mobility::handle_ho_requested(idle_st& s, const ho_req_rx_ev& uint32_t dl_teid_in = rrc_ue->bearer_list.add_gtpu_bearer( erab.second.id, erab.second.teid_out, erab.second.address.to_number(), &props); fwd_tunnels.push_back(dl_teid_in); - srslte::uint32_to_uint8(dl_teid_in, admitted_erabs.back().dl_g_tp_teid.data()); + srsran::uint32_to_uint8(dl_teid_in, admitted_erabs.back().dl_g_tp_teid.data()); } } } @@ -785,7 +785,7 @@ void rrc::ue::rrc_mobility::handle_ho_requested(idle_st& s, const ho_req_rx_ev& rrc_ue->ue_cell_list.get_ue_cc_idx(UE_PCELL_CC_IDX)->cell_common->enb_cc_idx, std::move(ho_cmd_pdu), admitted_erabs)) { - trigger(srslte::failure_ev{}); + trigger(srsran::failure_ev{}); return; } } @@ -804,7 +804,7 @@ bool rrc::ue::rrc_mobility::apply_ho_prep_cfg(const ho_prep_info_r8_ies_s& ho } if (erab.transport_layer_address.length() > 32) { get_logger().error("IPv6 addresses not currently supported"); - trigger(srslte::failure_ev{}); + trigger(srsran::failure_ev{}); return false; } @@ -816,7 +816,7 @@ bool rrc::ue::rrc_mobility::apply_ho_prep_cfg(const ho_prep_info_r8_ies_s& ho // Create E-RAB and associated main GTPU tunnel uint32_t teid_out; - srslte::uint8_to_uint32(erab.gtp_teid.data(), &teid_out); + srsran::uint8_to_uint32(erab.gtp_teid.data(), &teid_out); rrc_ue->bearer_list.add_erab( erab.erab_id, erab.erab_level_qos_params, erab.transport_layer_address, teid_out, nullptr); rrc_ue->bearer_list.add_gtpu_bearer(erab.erab_id); @@ -842,7 +842,7 @@ bool rrc::ue::rrc_mobility::apply_ho_prep_cfg(const ho_prep_info_r8_ies_s& ho rrc_ue->eutra_capabilities.to_json(js); logger.debug("New rnti=0x%x EUTRA capabilities: %s", rrc_ue->rnti, js.to_string().c_str()); } - rrc_ue->ue_capabilities = srslte::make_rrc_ue_capabilities(rrc_ue->eutra_capabilities); + rrc_ue->ue_capabilities = srsran::make_rrc_ue_capabilities(rrc_ue->eutra_capabilities); rrc_ue->eutra_capabilities_unpacked = true; } } @@ -894,12 +894,12 @@ void rrc::ue::rrc_mobility::handle_status_transfer(s1_target_ho_st& s, const sta logger.warning("The DRB id=%d does not exist", erab_item.erab_id - 4); } - srslte::pdcp_lte_state_t drb_state{}; + srsran::pdcp_lte_state_t drb_state{}; drb_state.tx_hfn = erab_item.dl_coun_tvalue.hfn; drb_state.next_pdcp_tx_sn = erab_item.dl_coun_tvalue.pdcp_sn; drb_state.rx_hfn = erab_item.ul_coun_tvalue.hfn; drb_state.next_pdcp_rx_sn = erab_item.ul_coun_tvalue.pdcp_sn; - uint8_t sn_len = srslte::get_pdcp_drb_sn_len(drb_it->pdcp_cfg); + uint8_t sn_len = srsran::get_pdcp_drb_sn_len(drb_it->pdcp_cfg); uint32_t maximum_pdcp_sn = (1u << sn_len) - 1u; drb_state.last_submitted_pdcp_rx_sn = std::min(erab_item.ul_coun_tvalue.pdcp_sn - 1u, maximum_pdcp_sn); logger.info("Setting lcid=%d PDCP state to {Tx SN: %d, Rx SN: %d}", @@ -937,21 +937,21 @@ void rrc::ue::rrc_mobility::intraenb_ho_st::enter(rrc_mobility* f, const ho_meas source_cell = f->rrc_ue->ue_cell_list.get_ue_cc_idx(UE_PCELL_CC_IDX)->cell_common; if (target_cell == nullptr) { f->logger.error("The target cell_id=0x%x was not found in the list of eNB cells", cell_id); - f->trigger(srslte::failure_ev{}); + f->trigger(srsran::failure_ev{}); return; } f->logger.info("Starting intraeNB Handover of rnti=0x%x to 0x%x.", f->rrc_ue->rnti, meas_report.target_eci); if (target_cell == nullptr) { - f->trigger(srslte::failure_ev{}); + f->trigger(srsran::failure_ev{}); return; } - last_temp_crnti = SRSLTE_INVALID_RNTI; + last_temp_crnti = SRSRAN_INVALID_RNTI; /* Allocate Resources in Target Cell */ if (not f->rrc_ue->ue_cell_list.set_cells({target_cell->enb_cc_idx})) { - f->trigger(srslte::failure_ev{}); + f->trigger(srsran::failure_ev{}); return; } f->rrc_ue->update_scells(); @@ -969,7 +969,7 @@ void rrc::ue::rrc_mobility::intraenb_ho_st::enter(rrc_mobility* f, const ho_meas // Send DL-DCCH Message via current PCell if (not f->rrc_ue->send_dl_dcch(&dl_dcch_msg)) { - f->trigger(srslte::failure_ev{}); + f->trigger(srsran::failure_ev{}); return; } } @@ -977,7 +977,7 @@ void rrc::ue::rrc_mobility::intraenb_ho_st::enter(rrc_mobility* f, const ho_meas void rrc::ue::rrc_mobility::handle_crnti_ce(intraenb_ho_st& s, const user_crnti_upd_ev& ev) { logger.info("UE performing handover updated its temp-crnti=0x%x to rnti=0x%x", ev.temp_crnti, ev.crnti); - bool is_first_crnti_ce = s.last_temp_crnti == SRSLTE_INVALID_RNTI; + bool is_first_crnti_ce = s.last_temp_crnti == SRSRAN_INVALID_RNTI; s.last_temp_crnti = ev.temp_crnti; if (is_first_crnti_ce) { diff --git a/srsenb/src/stack/rrc/rrc_nr.cc b/srsenb/src/stack/rrc/rrc_nr.cc index 2a6895c8f..996144d7f 100644 --- a/srsenb/src/stack/rrc/rrc_nr.cc +++ b/srsenb/src/stack/rrc/rrc_nr.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -12,14 +12,14 @@ #include "srsenb/hdr/stack/rrc/rrc_nr.h" #include "srsenb/hdr/stack/upper/common_enb.h" -#include "srslte/asn1/rrc_nr_utils.h" -#include "srslte/interfaces/nr_common_interface_types.h" +#include "srsran/asn1/rrc_nr_utils.h" +#include "srsran/interfaces/nr_common_interface_types.h" using namespace asn1::rrc_nr; namespace srsenb { -rrc_nr::rrc_nr(srslte::timer_handler* timers_) : logger(srslog::fetch_basic_logger("RRC")), timers(timers_) {} +rrc_nr::rrc_nr(srsran::timer_handler* timers_) : logger(srslog::fetch_basic_logger("RRC")), timers(timers_) {} void rrc_nr::init(const rrc_nr_cfg_t& cfg_, phy_interface_stack_nr* phy_, @@ -52,15 +52,15 @@ void rrc_nr::init(const rrc_nr_cfg_t& cfg_, // add dummy user logger.info("Creating dummy DRB for RNTI=%d on LCID=%d", cfg.coreless.rnti, cfg.coreless.drb_lcid); add_user(cfg.coreless.rnti); - srslte::rlc_config_t rlc_cnfg = srslte::rlc_config_t::default_rlc_um_nr_config(6); + srsran::rlc_config_t rlc_cnfg = srsran::rlc_config_t::default_rlc_um_nr_config(6); rlc->add_bearer(cfg.coreless.rnti, cfg.coreless.drb_lcid, rlc_cnfg); - srslte::pdcp_config_t pdcp_cnfg{cfg.coreless.drb_lcid, - srslte::PDCP_RB_IS_DRB, - srslte::SECURITY_DIRECTION_DOWNLINK, - srslte::SECURITY_DIRECTION_UPLINK, - srslte::PDCP_SN_LEN_18, - srslte::pdcp_t_reordering_t::ms500, - srslte::pdcp_discard_timer_t::infinity, + srsran::pdcp_config_t pdcp_cnfg{cfg.coreless.drb_lcid, + srsran::PDCP_RB_IS_DRB, + srsran::SECURITY_DIRECTION_DOWNLINK, + srsran::SECURITY_DIRECTION_UPLINK, + srsran::PDCP_SN_LEN_18, + srsran::pdcp_t_reordering_t::ms500, + srsran::pdcp_discard_timer_t::infinity, false}; pdcp->add_bearer(cfg.coreless.rnti, cfg.coreless.drb_lcid, pdcp_cnfg); @@ -80,7 +80,7 @@ void rrc_nr::stop() template void rrc_nr::log_rrc_message(const std::string& source, const direction_t dir, - const srslte::byte_buffer_t* pdu, + const srsran::byte_buffer_t* pdu, const T& msg) { if (logger.debug.enabled()) { @@ -121,17 +121,17 @@ rrc_nr_cfg_t rrc_nr::update_default_cfg(const rrc_nr_cfg_t& current) cfg_default.cell.nof_prb = 25; cfg_default.cell.nof_ports = 1; cfg_default.cell.id = 0; - cfg_default.cell.cp = SRSLTE_CP_NORM; - cfg_default.cell.frame_type = SRSLTE_FDD; - cfg_default.cell.phich_length = SRSLTE_PHICH_NORM; - cfg_default.cell.phich_resources = SRSLTE_PHICH_R_1; + cfg_default.cell.cp = SRSRAN_CP_NORM; + cfg_default.cell.frame_type = SRSRAN_FDD; + cfg_default.cell.phich_length = SRSRAN_PHICH_NORM; + cfg_default.cell.phich_resources = SRSRAN_PHICH_R_1; // Fill SIB1 cfg_default.sib1.cell_access_related_info.plmn_id_list.resize(1); cfg_default.sib1.cell_access_related_info.plmn_id_list[0].plmn_id_list.resize(1); - srslte::plmn_id_t plmn; + srsran::plmn_id_t plmn; plmn.from_string("90170"); - srslte::to_asn1(&cfg_default.sib1.cell_access_related_info.plmn_id_list[0].plmn_id_list[0], plmn); + srsran::to_asn1(&cfg_default.sib1.cell_access_related_info.plmn_id_list[0].plmn_id_list[0], plmn); cfg_default.sib1.cell_access_related_info.plmn_id_list[0].cell_id.from_number(1); cfg_default.sib1.cell_access_related_info.plmn_id_list[0].cell_reserved_for_oper.value = plmn_id_info_s::cell_reserved_for_oper_opts::not_reserved; @@ -188,7 +188,7 @@ void rrc_nr::config_mac() } // PUCCH width - sched_cfg.nrb_pucch = SRSLTE_MAX(cfg.sr_cfg.nof_prb, cfg.cqi_cfg.nof_prb); + sched_cfg.nrb_pucch = SRSRAN_MAX(cfg.sr_cfg.nof_prb, cfg.cqi_cfg.nof_prb); logger.info("Allocating %d PRBs for PUCCH", sched_cfg.nrb_pucch); // Copy Cell configuration @@ -205,7 +205,7 @@ uint32_t rrc_nr::generate_sibs() mib_s& mib = mib_msg.msg.set_mib(); mib = cfg.mib; { - srslte::unique_byte_buffer_t mib_buf = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t mib_buf = srsran::make_byte_buffer(); asn1::bit_ref bref(mib_buf->msg, mib_buf->get_tailroom()); mib_msg.pack(bref); mib_buf->N_bytes = bref.distance_bytes(); @@ -239,7 +239,7 @@ uint32_t rrc_nr::generate_sibs() // Pack payload for all messages for (uint32_t msg_index = 0; msg_index < nof_messages + 1; msg_index++) { - srslte::unique_byte_buffer_t sib = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t sib = srsran::make_byte_buffer(); asn1::bit_ref bref(sib->msg, sib->get_tailroom()); msg[msg_index].pack(bref); sib->N_bytes = bref.distance_bytes(); @@ -256,21 +256,21 @@ uint32_t rrc_nr::generate_sibs() MAC interface *******************************************************************************/ -int rrc_nr::read_pdu_bcch_bch(const uint32_t tti, srslte::unique_byte_buffer_t& buffer) +int rrc_nr::read_pdu_bcch_bch(const uint32_t tti, srsran::unique_byte_buffer_t& buffer) { if (mib_buffer == nullptr || buffer->get_tailroom() < mib_buffer->N_bytes) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } memcpy(buffer->msg, mib_buffer->msg, mib_buffer->N_bytes); buffer->N_bytes = mib_buffer->N_bytes; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int rrc_nr::read_pdu_bcch_dlsch(uint32_t sib_index, srslte::unique_byte_buffer_t& buffer) +int rrc_nr::read_pdu_bcch_dlsch(uint32_t sib_index, srsran::unique_byte_buffer_t& buffer) { if (sib_index >= sib_buffer.size()) { logger.error("SIB %d is not a configured SIB.", sib_index); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (buffer->get_tailroom() < sib_buffer[sib_index]->N_bytes) { @@ -278,13 +278,13 @@ int rrc_nr::read_pdu_bcch_dlsch(uint32_t sib_index, srslte::unique_byte_buffer_t sib_index, buffer->get_tailroom(), sib_buffer[sib_index]->N_bytes); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } memcpy(buffer->msg, sib_buffer[sib_index]->msg, sib_buffer[sib_index]->N_bytes); buffer->N_bytes = sib_buffer[sib_index]->N_bytes; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } void rrc_nr::get_metrics(srsenb::rrc_metrics_t& m) @@ -292,10 +292,10 @@ void rrc_nr::get_metrics(srsenb::rrc_metrics_t& m) // return metrics } -void rrc_nr::handle_pdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t pdu) +void rrc_nr::handle_pdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t pdu) { if (pdu) { - logger.info(pdu->msg, pdu->N_bytes, "Rx %s PDU", srslte::to_string(static_cast(lcid))); + logger.info(pdu->msg, pdu->N_bytes, "Rx %s PDU", srsran::to_string(static_cast(lcid))); } if (users.count(rnti) == 1) { @@ -319,7 +319,7 @@ void rrc_nr::handle_pdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer /******************************************************************************* PDCP interface *******************************************************************************/ -void rrc_nr::write_pdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t pdu) +void rrc_nr::write_pdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t pdu) { handle_pdu(rnti, lcid, std::move(pdu)); } @@ -367,7 +367,7 @@ void rrc_nr::ue::send_connection_setup() void rrc_nr::ue::send_dl_ccch(dl_ccch_msg_s* dl_ccch_msg) { // Allocate a new PDU buffer, pack the message and send to PDCP - srslte::unique_byte_buffer_t pdu = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t pdu = srsran::make_byte_buffer(); if (pdu == nullptr) { parent->logger.error("Allocating pdu"); } diff --git a/srsenb/src/stack/rrc/rrc_ue.cc b/srsenb/src/stack/rrc/rrc_ue.cc index 02a9f147c..63aa5d618 100644 --- a/srsenb/src/stack/rrc/rrc_ue.cc +++ b/srsenb/src/stack/rrc/rrc_ue.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -14,14 +14,14 @@ #include "srsenb/hdr/stack/rrc/mac_controller.h" #include "srsenb/hdr/stack/rrc/rrc_mobility.h" #include "srsenb/hdr/stack/rrc/ue_rr_cfg.h" -#include "srslte/adt/mem_pool.h" -#include "srslte/asn1/rrc_utils.h" -#include "srslte/common/enb_events.h" -#include "srslte/common/int_helpers.h" -#include "srslte/common/standard_streams.h" -#include "srslte/interfaces/enb_pdcp_interfaces.h" -#include "srslte/interfaces/enb_rlc_interfaces.h" -#include "srslte/interfaces/enb_s1ap_interfaces.h" +#include "srsran/adt/mem_pool.h" +#include "srsran/asn1/rrc_utils.h" +#include "srsran/common/enb_events.h" +#include "srsran/common/int_helpers.h" +#include "srsran/common/standard_streams.h" +#include "srsran/interfaces/enb_pdcp_interfaces.h" +#include "srsran/interfaces/enb_rlc_interfaces.h" +#include "srsran/interfaces/enb_s1ap_interfaces.h" using namespace asn1::rrc; @@ -50,7 +50,7 @@ int rrc::ue::init() { // Allocate cell and PUCCH resources if (ue_cell_list.add_cell(mac_ctrl.get_ue_sched_cfg().supported_cc_list[0].enb_cc_idx) == nullptr) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Configure @@ -60,10 +60,10 @@ int rrc::ue::init() set_activity_timeout(MSG3_RX_TIMEOUT); // next UE response is Msg3 mobility_handler.reset(new rrc_mobility(this)); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -srslte::background_allocator_obj_pool* rrc::ue::get_ue_pool() +srsran::background_allocator_obj_pool* rrc::ue::get_ue_pool() { // Note: batch allocation is going to be explicitly called in enb class construction. The pool object, therefore, // will only be initialized if we instantiate an eNB @@ -120,7 +120,7 @@ void rrc::ue::activity_timer_expired() static_cast(rrc_idle_transition_cause::timeout), rnti); } else { - if (rnti != SRSLTE_MRNTI) { + if (rnti != SRSRAN_MRNTI) { parent->rem_user_thread(rnti); } } @@ -184,7 +184,7 @@ bool rrc::ue::is_idle() return state == RRC_STATE_IDLE; } -void rrc::ue::parse_ul_dcch(uint32_t lcid, srslte::unique_byte_buffer_t pdu) +void rrc::ue::parse_ul_dcch(uint32_t lcid, srsran::unique_byte_buffer_t pdu) { set_activity(); @@ -199,8 +199,8 @@ void rrc::ue::parse_ul_dcch(uint32_t lcid, srslte::unique_byte_buffer_t pdu) parent->log_rrc_message( srsenb::to_string((rb_id_t)lcid), Rx, pdu.get(), ul_dcch_msg, ul_dcch_msg.msg.c1().type().to_string()); - srslte::unique_byte_buffer_t original_pdu = std::move(pdu); - pdu = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t original_pdu = std::move(pdu); + pdu = srsran::make_byte_buffer(); transaction_id = 0; @@ -230,7 +230,7 @@ void rrc::ue::parse_ul_dcch(uint32_t lcid, srslte::unique_byte_buffer_t pdu) break; case ul_dcch_msg_type_c::c1_c_::types::rrc_conn_recfg_complete: handle_rrc_reconf_complete(&ul_dcch_msg.msg.c1().rrc_conn_recfg_complete(), std::move(pdu)); - srslte::console("User 0x%x connected\n", rnti); + srsran::console("User 0x%x connected\n", rnti); state = RRC_STATE_REGISTERED; set_activity_timeout(UE_INACTIVITY_TIMEOUT); break; @@ -271,7 +271,7 @@ void rrc::ue::parse_ul_dcch(uint32_t lcid, srslte::unique_byte_buffer_t pdu) std::string rrc::ue::to_string(const activity_timeout_type_t& type) { constexpr static const char* options[] = {"Msg3 reception", "UE inactivity", "UE reestablishment"}; - return srslte::enum_to_text(options, (uint32_t)activity_timeout_type_t::nulltype, (uint32_t)type); + return srsran::enum_to_text(options, (uint32_t)activity_timeout_type_t::nulltype, (uint32_t)type); } /* @@ -332,7 +332,7 @@ void rrc::ue::send_connection_setup() apply_rr_cfg_ded_diff(current_ue_cfg.rr_cfg, rr_cfg); } -void rrc::ue::handle_rrc_con_setup_complete(rrc_conn_setup_complete_s* msg, srslte::unique_byte_buffer_t pdu) +void rrc::ue::handle_rrc_con_setup_complete(rrc_conn_setup_complete_s* msg, srsran::unique_byte_buffer_t pdu) { // Inform PHY about the configuration completion parent->phy->complete_config(rnti); @@ -499,7 +499,7 @@ void rrc::ue::send_connection_reest(uint8_t ncc) apply_rr_cfg_ded_diff(current_ue_cfg.rr_cfg, rr_cfg); } -void rrc::ue::handle_rrc_con_reest_complete(rrc_conn_reest_complete_s* msg, srslte::unique_byte_buffer_t pdu) +void rrc::ue::handle_rrc_con_reest_complete(rrc_conn_reest_complete_s* msg, srsran::unique_byte_buffer_t pdu) { // Inform PHY about the configuration completion parent->phy->complete_config(rnti); @@ -557,7 +557,7 @@ void rrc::ue::send_connection_reest_rej() /* * Connection Reconfiguration */ -void rrc::ue::send_connection_reconf(srslte::unique_byte_buffer_t pdu, +void rrc::ue::send_connection_reconf(srsran::unique_byte_buffer_t pdu, bool phy_cfg_updated, const asn1::unbounded_octstring* nas_pdu) { @@ -620,7 +620,7 @@ void rrc::ue::send_connection_reconf(srslte::unique_byte_buffer_t pdu, state = RRC_STATE_WAIT_FOR_CON_RECONF_COMPLETE; } -void rrc::ue::handle_rrc_reconf_complete(rrc_conn_recfg_complete_s* msg, srslte::unique_byte_buffer_t pdu) +void rrc::ue::handle_rrc_reconf_complete(rrc_conn_recfg_complete_s* msg, srsran::unique_byte_buffer_t pdu) { // Inform PHY about the configuration completion parent->phy->complete_config(rnti); @@ -658,7 +658,7 @@ void rrc::ue::send_ue_info_req() send_dl_dcch(&msg); } -void rrc::ue::handle_ue_info_resp(const asn1::rrc::ue_info_resp_r9_s& msg, srslte::unique_byte_buffer_t pdu) +void rrc::ue::handle_ue_info_resp(const asn1::rrc::ue_info_resp_r9_s& msg, srsran::unique_byte_buffer_t pdu) { auto& resp_r9 = msg.crit_exts.c1().ue_info_resp_r9(); if (resp_r9.rlf_report_r9_present) { @@ -741,13 +741,13 @@ bool rrc::ue::handle_ue_cap_info(ue_cap_info_s* msg) parent->logger.debug("rnti=0x%x EUTRA capabilities: %s", rnti, js.to_string().c_str()); } eutra_capabilities_unpacked = true; - ue_capabilities = srslte::make_rrc_ue_capabilities(eutra_capabilities); + ue_capabilities = srsran::make_rrc_ue_capabilities(eutra_capabilities); parent->logger.info("UE rnti: 0x%x category: %d", rnti, eutra_capabilities.ue_category); } if (eutra_capabilities_unpacked) { - srslte::unique_byte_buffer_t pdu = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t pdu = srsran::make_byte_buffer(); asn1::bit_ref bref2{pdu->msg, pdu->get_tailroom()}; msg->pack(bref2); asn1::rrc::ue_radio_access_cap_info_s ue_rat_caps; @@ -903,7 +903,7 @@ void rrc::ue::notify_s1ap_ue_ctxt_setup_complete() res.protocol_ies.erab_setup_list_ctxt_su_res.value[i].load_info_obj(ASN1_S1AP_ID_ERAB_SETUP_ITEM_CTXT_SU_RES); auto& item = res.protocol_ies.erab_setup_list_ctxt_su_res.value[i].value.erab_setup_item_ctxt_su_res(); item.erab_id = erab.second.id; - srslte::uint32_to_uint8(erab.second.teid_in, item.gtp_teid.data()); + srsran::uint32_to_uint8(erab.second.teid_in, item.gtp_teid.data()); i++; } @@ -931,7 +931,7 @@ bool rrc::ue::setup_erabs(const asn1::s1ap::erab_to_be_setup_list_ctxt_su_req_l& } uint32_t teid_out; - srslte::uint8_to_uint32(erab.gtp_teid.data(), &teid_out); + srsran::uint8_to_uint32(erab.gtp_teid.data(), &teid_out); const asn1::unbounded_octstring* nas_pdu = erab.nas_pdu_present ? &erab.nas_pdu : nullptr; bearer_list.add_erab(erab.erab_id, erab.erab_level_qos_params, erab.transport_layer_address, teid_out, nas_pdu); bearer_list.add_gtpu_bearer(erab.erab_id); @@ -955,7 +955,7 @@ bool rrc::ue::setup_erabs(const asn1::s1ap::erab_to_be_setup_list_bearer_su_req_ } uint32_t teid_out; - srslte::uint8_to_uint32(erab.gtp_teid.data(), &teid_out); + srsran::uint8_to_uint32(erab.gtp_teid.data(), &teid_out); bearer_list.add_erab( erab.erab_id, erab.erab_level_qos_params, erab.transport_layer_address, teid_out, &erab.nas_pdu); bearer_list.add_gtpu_bearer(erab.erab_id); @@ -1002,7 +1002,7 @@ void rrc::ue::notify_s1ap_ue_erab_setup_response(const asn1::s1ap::erab_to_be_se auto& item = res.protocol_ies.erab_setup_list_bearer_su_res.value.back(); item.load_info_obj(ASN1_S1AP_ID_ERAB_SETUP_ITEM_BEARER_SU_RES); item.value.erab_setup_item_bearer_su_res().erab_id = id; - srslte::uint32_to_uint8(bearer_list.get_erabs().at(id).teid_in, + srsran::uint32_to_uint8(bearer_list.get_erabs().at(id).teid_in, &item.value.erab_setup_item_bearer_su_res().gtp_teid[0]); } else { res.protocol_ies.erab_failed_to_setup_list_bearer_su_res_present = true; @@ -1060,7 +1060,7 @@ void rrc::ue::update_scells() void rrc::ue::send_dl_ccch(dl_ccch_msg_s* dl_ccch_msg) { // Allocate a new PDU buffer, pack the message and send to PDCP - srslte::unique_byte_buffer_t pdu = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t pdu = srsran::make_byte_buffer(); if (pdu) { asn1::bit_ref bref(pdu->msg, pdu->get_tailroom()); if (dl_ccch_msg->pack(bref) != asn1::SRSASN_SUCCESS) { @@ -1078,10 +1078,10 @@ void rrc::ue::send_dl_ccch(dl_ccch_msg_s* dl_ccch_msg) } } -bool rrc::ue::send_dl_dcch(const dl_dcch_msg_s* dl_dcch_msg, srslte::unique_byte_buffer_t pdu) +bool rrc::ue::send_dl_dcch(const dl_dcch_msg_s* dl_dcch_msg, srsran::unique_byte_buffer_t pdu) { if (!pdu) { - pdu = srslte::make_byte_buffer(); + pdu = srsran::make_byte_buffer(); } if (pdu) { asn1::bit_ref bref(pdu->msg, pdu->get_tailroom()); @@ -1143,7 +1143,7 @@ void rrc::ue::apply_setup_phy_config_dedicated(const asn1::rrc::phys_cfg_ded_s& } // Load PCell dedicated configuration - srslte::set_phy_cfg_t_dedicated_cfg(&phy_rrc_dedicated_list[0].phy_cfg, phys_cfg_ded); + srsran::set_phy_cfg_t_dedicated_cfg(&phy_rrc_dedicated_list[0].phy_cfg, phys_cfg_ded); // Deactivates eNb/Cells for this UE for (uint32_t cc = 1; cc < phy_rrc_dedicated_list.size(); cc++) { @@ -1168,8 +1168,8 @@ void rrc::ue::apply_reconf_phy_config(const rrc_conn_recfg_r8_ies_s& reconfig_r8 auto& rr_cfg_ded = reconfig_r8.rr_cfg_ded; if (rr_cfg_ded.phys_cfg_ded_present) { auto& phys_cfg_ded = rr_cfg_ded.phys_cfg_ded; - srslte::set_phy_cfg_t_dedicated_cfg(&phy_rrc_dedicated_list[0].phy_cfg, phys_cfg_ded); - srslte::set_phy_cfg_t_enable_64qam( + srsran::set_phy_cfg_t_dedicated_cfg(&phy_rrc_dedicated_list[0].phy_cfg, phys_cfg_ded); + srsran::set_phy_cfg_t_enable_64qam( &phy_rrc_dedicated_list[0].phy_cfg, ue_capabilities.support_ul_64qam and parent->cfg.sibs[1].sib2().rr_cfg_common.pusch_cfg_common.pusch_cfg_basic.enable64_qam); @@ -1192,7 +1192,7 @@ void rrc::ue::apply_reconf_phy_config(const rrc_conn_recfg_r8_ies_s& reconfig_r8 ue_cell_ded* ue_cc = ue_cell_list.get_ue_cc_idx(scell.scell_idx_r10); // Create new PHY configuration structure for this SCell phy_interface_rrc_lte::phy_rrc_cfg_t scell_phy_rrc_ded = {}; - srslte::set_phy_cfg_t_scell_config(&scell_phy_rrc_ded.phy_cfg, scell); + srsran::set_phy_cfg_t_scell_config(&scell_phy_rrc_ded.phy_cfg, scell); scell_phy_rrc_ded.configured = true; // Set PUSCH dedicated configuration following 3GPP TS 36.331 R 10 Section 6.3.2 Radio resource control @@ -1207,7 +1207,7 @@ void rrc::ue::apply_reconf_phy_config(const rrc_conn_recfg_r8_ies_s& reconfig_r8 // Append to PHY RRC config dedicated which will be applied further down phy_rrc_dedicated_list[scell.scell_idx_r10] = scell_phy_rrc_ded; - srslte::set_phy_cfg_t_enable_64qam( + srsran::set_phy_cfg_t_enable_64qam( &phy_rrc_dedicated_list[scell.scell_idx_r10].phy_cfg, ue_capabilities.support_ul_64qam and parent->cfg.sibs[1].sib2().rr_cfg_common.pusch_cfg_common.pusch_cfg_basic.enable64_qam); @@ -1226,7 +1226,7 @@ void rrc::ue::apply_reconf_phy_config(const rrc_conn_recfg_r8_ies_s& reconfig_r8 void rrc::ue::apply_pdcp_srb_updates(const rr_cfg_ded_s& pending_rr_cfg) { for (const srb_to_add_mod_s& srb : pending_rr_cfg.srb_to_add_mod_list) { - parent->pdcp->add_bearer(rnti, srb.srb_id, srslte::make_srb_pdcp_config_t(srb.srb_id, false)); + parent->pdcp->add_bearer(rnti, srb.srb_id, srsran::make_srb_pdcp_config_t(srb.srb_id, false)); // enable security config if (ue_security_cfg.is_as_sec_cfg_valid()) { @@ -1245,10 +1245,10 @@ void rrc::ue::apply_pdcp_drb_updates(const rr_cfg_ded_s& pending_rr_cfg) for (const drb_to_add_mod_s& drb : pending_rr_cfg.drb_to_add_mod_list) { // Configure DRB1 in PDCP if (drb.pdcp_cfg_present) { - srslte::pdcp_config_t pdcp_cnfg_drb = srslte::make_drb_pdcp_config_t(drb.drb_id, false, drb.pdcp_cfg); + srsran::pdcp_config_t pdcp_cnfg_drb = srsran::make_drb_pdcp_config_t(drb.drb_id, false, drb.pdcp_cfg); parent->pdcp->add_bearer(rnti, drb.lc_ch_id, pdcp_cnfg_drb); } else { - srslte::pdcp_config_t pdcp_cnfg_drb = srslte::make_drb_pdcp_config_t(drb.drb_id, false); + srsran::pdcp_config_t pdcp_cnfg_drb = srsran::make_drb_pdcp_config_t(drb.drb_id, false); parent->pdcp->add_bearer(rnti, drb.lc_ch_id, pdcp_cnfg_drb); } @@ -1286,7 +1286,7 @@ void rrc::ue::apply_pdcp_drb_updates(const rr_cfg_ded_s& pending_rr_cfg) void rrc::ue::apply_rlc_rb_updates(const rr_cfg_ded_s& pending_rr_cfg) { for (const srb_to_add_mod_s& srb : pending_rr_cfg.srb_to_add_mod_list) { - parent->rlc->add_bearer(rnti, srb.srb_id, srslte::rlc_config_t::srb_config(srb.srb_id)); + parent->rlc->add_bearer(rnti, srb.srb_id, srsran::rlc_config_t::srb_config(srb.srb_id)); } if (pending_rr_cfg.drb_to_release_list.size() > 0) { for (uint8_t drb_id : pending_rr_cfg.drb_to_release_list) { @@ -1297,7 +1297,7 @@ void rrc::ue::apply_rlc_rb_updates(const rr_cfg_ded_s& pending_rr_cfg) if (not drb.rlc_cfg_present) { parent->logger.warning("Default RLC DRB config not supported"); } - parent->rlc->add_bearer(rnti, drb.lc_ch_id, srslte::make_rlc_config_t(drb.rlc_cfg)); + parent->rlc->add_bearer(rnti, drb.lc_ch_id, srsran::make_rlc_config_t(drb.rlc_cfg)); } } @@ -1307,10 +1307,10 @@ int rrc::ue::get_cqi(uint16_t* pmi_idx, uint16_t* n_pucch, uint32_t ue_cc_idx) if (c != nullptr and c->cqi_res_present) { *pmi_idx = c->cqi_res.pmi_idx; *n_pucch = c->cqi_res.pucch_res; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } else { parent->logger.error("CQI resources for ue_cc_idx=%d have not been allocated", ue_cc_idx); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } @@ -1321,7 +1321,7 @@ bool rrc::ue::is_allocated() const int rrc::ue::get_ri(uint32_t m_ri, uint16_t* ri_idx) { - int32_t ret = SRSLTE_SUCCESS; + int32_t ret = SRSRAN_SUCCESS; uint32_t I_ri = 0; int32_t N_offset_ri = 0; // Naivest approach: overlap RI with PMI diff --git a/srsenb/src/stack/rrc/ue_meas_cfg.cc b/srsenb/src/stack/rrc/ue_meas_cfg.cc index 18571ac10..d3cbfb4e7 100644 --- a/srsenb/src/stack/rrc/ue_meas_cfg.cc +++ b/srsenb/src/stack/rrc/ue_meas_cfg.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -12,7 +12,7 @@ #include "srsenb/hdr/stack/rrc/ue_meas_cfg.h" #include "srsenb/hdr/stack/rrc/rrc_cell_cfg.h" -#include "srslte/rrc/rrc_cfg_utils.h" +#include "srsran/rrc/rrc_cfg_utils.h" using namespace asn1::rrc; @@ -24,20 +24,20 @@ namespace srsenb { bool is_same_earfcn(const meas_obj_t& lhs, const meas_obj_t& rhs) { - int freq1 = srslte::get_carrier_freq(lhs); - int freq2 = srslte::get_carrier_freq(rhs); + int freq1 = srsran::get_carrier_freq(lhs); + int freq2 = srsran::get_carrier_freq(rhs); return freq1 != -1 and freq1 == freq2; } meas_obj_t* find_meas_obj(meas_obj_to_add_mod_list_l& l, uint32_t earfcn) { - auto same_earfcn = [earfcn](const meas_obj_t& obj) { return (int)earfcn == srslte::get_carrier_freq(obj); }; + auto same_earfcn = [earfcn](const meas_obj_t& obj) { return (int)earfcn == srsran::get_carrier_freq(obj); }; auto it = std::find_if(l.begin(), l.end(), same_earfcn); return it == l.end() ? nullptr : &(*it); } const meas_obj_t* find_meas_obj(const meas_obj_to_add_mod_list_l& l, uint32_t earfcn) { - auto same_earfcn = [earfcn](const meas_obj_t& obj) { return (int)earfcn == srslte::get_carrier_freq(obj); }; + auto same_earfcn = [earfcn](const meas_obj_t& obj) { return (int)earfcn == srsran::get_carrier_freq(obj); }; auto it = std::find_if(l.begin(), l.end(), same_earfcn); return it == l.end() ? nullptr : &(*it); } @@ -67,13 +67,13 @@ std::pair add_meas_obj(meas_obj_list& list, uint32_t dl_earfc } meas_obj_t new_obj; - new_obj.meas_obj_id = srslte::find_rrc_obj_id_gap(list); + new_obj.meas_obj_id = srsran::find_rrc_obj_id_gap(list); asn1::rrc::meas_obj_eutra_s& eutra = new_obj.meas_obj.set_meas_obj_eutra(); eutra.carrier_freq = dl_earfcn; eutra.allowed_meas_bw.value = asn1::rrc::allowed_meas_bw_e::mbw6; // TODO: What value to add here? eutra.neigh_cell_cfg.from_number(1); // No MBSFN subframes present in neighbors eutra.offset_freq_present = false; // no offset - obj = srslte::add_rrc_obj(list, new_obj); + obj = srsran::add_rrc_obj(list, new_obj); return {true, obj}; } @@ -103,8 +103,8 @@ std::tuple add_cell_enb_cfg(meas_obj_lis } else { auto& eutra_obj = ret.first->meas_obj.meas_obj_eutra(); // pci not found. create new cell - new_cell.cell_idx = srslte::find_rrc_obj_id_gap(eutra_obj.cells_to_add_mod_list); - ret.second = srslte::add_rrc_obj(eutra_obj.cells_to_add_mod_list, new_cell); + new_cell.cell_idx = srsran::find_rrc_obj_id_gap(eutra_obj.cells_to_add_mod_list); + ret.second = srsran::add_rrc_obj(eutra_obj.cells_to_add_mod_list, new_cell); eutra_obj.cells_to_add_mod_list_present = true; } } else { @@ -131,7 +131,7 @@ meas_obj_to_add_mod_s* meascfg_add_meas_obj(meas_cfg_s* meas_cfg, const meas_obj meas_cfg->meas_obj_to_add_mod_list_present = true; // search for meas_obj by obj_id to ensure uniqueness (assume sorted) - auto meas_obj_it = srslte::add_rrc_obj_id(meas_cfg->meas_obj_to_add_mod_list, meas_obj.meas_obj_id); + auto meas_obj_it = srsran::add_rrc_obj_id(meas_cfg->meas_obj_to_add_mod_list, meas_obj.meas_obj_id); // TODO: Assert dl_earfcn is the same auto& target_eutra = meas_obj_it->meas_obj.set_meas_obj_eutra(); @@ -153,7 +153,7 @@ void compute_diff_cells(const meas_obj_eutra_s& src_it, meas_obj_to_add_mod_s* added_obj) { meas_obj_eutra_s* eutra_obj = &added_obj->meas_obj.meas_obj_eutra(); - srslte::compute_cfg_diff(src_it.cells_to_add_mod_list, + srsran::compute_cfg_diff(src_it.cells_to_add_mod_list, target_it.cells_to_add_mod_list, eutra_obj->cells_to_add_mod_list, eutra_obj->cells_to_rem_list); @@ -177,7 +177,7 @@ void compute_diff_meas_objs(const meas_cfg_s& prev_cfg, const meas_cfg_s& target compute_diff_cells(src_it->meas_obj.meas_obj_eutra(), target_it->meas_obj.meas_obj_eutra(), added_obj); } }; - srslte::compute_cfg_diff( + srsran::compute_cfg_diff( prev_cfg.meas_obj_to_add_mod_list, target_cfg.meas_obj_to_add_mod_list, rem_func, add_func, mod_func); meas_cfg.meas_obj_to_add_mod_list_present = meas_cfg.meas_obj_to_add_mod_list.size() > 0; meas_cfg.meas_obj_to_rem_list_present = meas_cfg.meas_obj_to_rem_list.size() > 0; @@ -191,10 +191,10 @@ void compute_diff_meas_objs(const meas_cfg_s& prev_cfg, const meas_cfg_s& target report_cfg_to_add_mod_s* add_report_cfg(report_cfg_list& list, const report_cfg_eutra_s& reportcfg) { report_cfg_to_add_mod_s new_rep; - new_rep.report_cfg_id = srslte::find_rrc_obj_id_gap(list); + new_rep.report_cfg_id = srsran::find_rrc_obj_id_gap(list); new_rep.report_cfg.set_report_cfg_eutra() = reportcfg; - return srslte::add_rrc_obj(list, new_rep); + return srsran::add_rrc_obj(list, new_rep); } /** @@ -202,7 +202,7 @@ report_cfg_to_add_mod_s* add_report_cfg(report_cfg_list& list, const report_cfg_ */ void compute_diff_report_cfgs(const meas_cfg_s& src_cfg, const meas_cfg_s& target_cfg, meas_cfg_s& meas_cfg) { - srslte::compute_cfg_diff(src_cfg.report_cfg_to_add_mod_list, + srsran::compute_cfg_diff(src_cfg.report_cfg_to_add_mod_list, target_cfg.report_cfg_to_add_mod_list, meas_cfg.report_cfg_to_add_mod_list, meas_cfg.report_cfg_to_rem_list); @@ -215,13 +215,13 @@ meas_id_to_add_mod_s* add_measid_cfg(meas_id_to_add_mod_list_l& meas_id_list, ui meas_id_to_add_mod_s new_measid; new_measid.report_cfg_id = measrepid; new_measid.meas_obj_id = measobjid; - new_measid.meas_id = srslte::find_rrc_obj_id_gap(meas_id_list); - return srslte::add_rrc_obj(meas_id_list, new_measid); + new_measid.meas_id = srsran::find_rrc_obj_id_gap(meas_id_list); + return srsran::add_rrc_obj(meas_id_list, new_measid); } void compute_diff_meas_ids(const meas_cfg_s& src_cfg, const meas_cfg_s& target_cfg, meas_cfg_s& meas_cfg) { - srslte::compute_cfg_diff(src_cfg.meas_id_to_add_mod_list, + srsran::compute_cfg_diff(src_cfg.meas_id_to_add_mod_list, target_cfg.meas_id_to_add_mod_list, meas_cfg.meas_id_to_add_mod_list, meas_cfg.meas_id_to_rem_list); diff --git a/srsenb/src/stack/rrc/ue_rr_cfg.cc b/srsenb/src/stack/rrc/ue_rr_cfg.cc index daeb6947e..ec93d917e 100644 --- a/srsenb/src/stack/rrc/ue_rr_cfg.cc +++ b/srsenb/src/stack/rrc/ue_rr_cfg.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -14,8 +14,8 @@ #include "srsenb/hdr/stack/rrc/rrc_bearer_cfg.h" #include "srsenb/hdr/stack/rrc/rrc_cell_cfg.h" #include "srsenb/hdr/stack/rrc/rrc_config.h" -#include "srslte/asn1/rrc_utils.h" -#include "srslte/rrc/rrc_cfg_utils.h" +#include "srsran/asn1/rrc_utils.h" +#include "srsran/rrc/rrc_cfg_utils.h" #define SET_OPT_FIELD(fieldname, out, in) \ if (in.fieldname##_present) { \ @@ -41,7 +41,7 @@ srb_to_add_mod_s* add_srb(srb_to_add_mod_list_l& srbs, uint8_t srb_id) } // Set SRBtoAddMod - auto srb_it = srslte::add_rrc_obj_id(srbs, srb_id); + auto srb_it = srsran::add_rrc_obj_id(srbs, srb_id); srb_it->lc_ch_cfg_present = true; srb_it->lc_ch_cfg.set(srb_to_add_mod_s::lc_ch_cfg_c_::types_opts::default_value); srb_it->rlc_cfg_present = true; @@ -53,11 +53,11 @@ srb_to_add_mod_s* add_srb(srb_to_add_mod_list_l& srbs, uint8_t srb_id) void fill_srbs_reconf(srb_to_add_mod_list_l& srbs, const srb_to_add_mod_list_l& current_srbs) { // NOTE: In case of Handover, the Reconf includes SRB1 - if (srslte::find_rrc_obj_id(current_srbs, 1) == current_srbs.end()) { + if (srsran::find_rrc_obj_id(current_srbs, 1) == current_srbs.end()) { add_srb(srbs, 1); } - if (srslte::find_rrc_obj_id(current_srbs, 2) == current_srbs.end()) { + if (srsran::find_rrc_obj_id(current_srbs, 2) == current_srbs.end()) { add_srb(srbs, 2); } } @@ -136,20 +136,20 @@ int fill_cqi_report_setup(cqi_report_cfg_s& cqi_rep, const rrc_cfg_t& enb_cfg, c const ue_cell_ded* pcell = ue_cell_list.get_ue_cc_idx(UE_PCELL_CC_IDX); if (pcell == nullptr or not pcell->cqi_res_present) { srslog::fetch_basic_logger("RRC").warning("PCell CQI resources haven\'t been allocated yet"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } auto& cqi_periodic = cqi_rep.cqi_report_periodic.setup(); cqi_periodic.cqi_pmi_cfg_idx = pcell->cqi_res.pmi_idx; cqi_periodic.cqi_pucch_res_idx = pcell->cqi_res.pucch_res; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } void fill_cqi_report_reconf(cqi_report_cfg_s& cqi_rep, const rrc_cfg_t& enb_cfg, const ue_cell_ded_list& ue_cell_list) { // Get RRC setup CQI config - if (fill_cqi_report_setup(cqi_rep, enb_cfg, ue_cell_list) == SRSLTE_ERROR) { + if (fill_cqi_report_setup(cqi_rep, enb_cfg, ue_cell_list) == SRSRAN_ERROR) { return; } @@ -241,7 +241,7 @@ void fill_phy_cfg_ded_setup(phys_cfg_ded_s& phy_cfg, const rrc_cfg_t& enb_cfg, c void fill_phy_cfg_ded_reconf(phys_cfg_ded_s& phy_cfg, const rrc_cfg_t& enb_cfg, const ue_cell_ded_list& ue_cell_list, - const srslte::rrc_ue_capabilities_t& ue_caps) + const srsran::rrc_ue_capabilities_t& ue_caps) { // Use RRCSetup as starting point fill_phy_cfg_ded_setup(phy_cfg, enb_cfg, ue_cell_list); @@ -311,7 +311,7 @@ void fill_rr_cfg_ded_reconf(asn1::rrc::rr_cfg_ded_s& rr_cfg, const rrc_cfg_t& enb_cfg, const ue_cell_ded_list& ue_cell_list, const bearer_cfg_handler& bearers, - const srslte::rrc_ue_capabilities_t& ue_caps, + const srsran::rrc_ue_capabilities_t& ue_caps, bool phy_cfg_updated) { // (Re)establish SRBs @@ -319,7 +319,7 @@ void fill_rr_cfg_ded_reconf(asn1::rrc::rr_cfg_ded_s& rr_cfg, rr_cfg.srb_to_add_mod_list_present = rr_cfg.srb_to_add_mod_list.size() > 0; // Update DRBs if required - srslte::compute_cfg_diff(current_rr_cfg.drb_to_add_mod_list, + srsran::compute_cfg_diff(current_rr_cfg.drb_to_add_mod_list, bearers.get_established_drbs(), rr_cfg.drb_to_add_mod_list, rr_cfg.drb_to_release_list); @@ -344,14 +344,14 @@ void apply_rr_cfg_ded_diff(rr_cfg_ded_s& current_rr_cfg_ded, const rr_cfg_ded_s& // 5.3.10.1 - SRB addition/Modification if (pending_rr_cfg_ded.srb_to_add_mod_list_present) { current_rr_cfg_ded.srb_to_add_mod_list_present = true; - srslte::apply_addmodlist_diff(current_rr_cfg_ded.srb_to_add_mod_list, + srsran::apply_addmodlist_diff(current_rr_cfg_ded.srb_to_add_mod_list, pending_rr_cfg_ded.srb_to_add_mod_list, current_rr_cfg_ded.srb_to_add_mod_list); } // 5.3.10.(2/3) - DRB release/addition/Modification if (pending_rr_cfg_ded.drb_to_add_mod_list_present or pending_rr_cfg_ded.drb_to_release_list_present) { - srslte::apply_addmodremlist_diff(current_rr_cfg_ded.drb_to_add_mod_list, + srsran::apply_addmodremlist_diff(current_rr_cfg_ded.drb_to_add_mod_list, pending_rr_cfg_ded.drb_to_add_mod_list, pending_rr_cfg_ded.drb_to_release_list, current_rr_cfg_ded.drb_to_add_mod_list); @@ -384,7 +384,7 @@ void fill_scells_reconf(asn1::rrc::rrc_conn_recfg_r8_ies_s& recfg_r8, const scell_to_add_mod_list_r10_l& current_scells, const rrc_cfg_t& enb_cfg, const ue_cell_ded_list& ue_cell_list, - const srslte::rrc_ue_capabilities_t& ue_caps) + const srsran::rrc_ue_capabilities_t& ue_caps) { // check whether there has been scell updates // TODO: check scell modifications and released as well @@ -506,7 +506,7 @@ void fill_scells_reconf(asn1::rrc::rrc_conn_recfg_r8_ies_s& recfg_r8, recfg_r8.non_crit_ext.non_crit_ext.non_crit_ext_present = true; recfg_r8.non_crit_ext.non_crit_ext.non_crit_ext.scell_to_add_mod_list_r10_present = true; auto& recfg_v1020 = recfg_r8.non_crit_ext.non_crit_ext.non_crit_ext; - srslte::compute_cfg_diff( + srsran::compute_cfg_diff( current_scells, target_scells, recfg_v1020.scell_to_add_mod_list_r10, recfg_v1020.scell_to_release_list_r10); // Set DL HARQ Feedback mode @@ -544,7 +544,7 @@ void apply_scells_to_add_diff(asn1::rrc::scell_to_add_mod_list_r10_l& current_sc if (recfg_r8.non_crit_ext_present or recfg_r8.non_crit_ext.non_crit_ext_present or recfg_r8.non_crit_ext.non_crit_ext.non_crit_ext_present) { const rrc_conn_recfg_v1020_ies_s& recfg_v1020 = recfg_r8.non_crit_ext.non_crit_ext.non_crit_ext; - srslte::apply_addmodremlist_diff( + srsran::apply_addmodremlist_diff( current_scells, recfg_v1020.scell_to_add_mod_list_r10, recfg_v1020.scell_to_release_list_r10, current_scells); } } @@ -559,7 +559,7 @@ void apply_reconf_updates(asn1::rrc::rrc_conn_recfg_r8_ies_s& recfg_r8, const rrc_cfg_t& enb_cfg, const ue_cell_ded_list& ue_cell_list, bearer_cfg_handler& bearers, - const srslte::rrc_ue_capabilities_t& ue_caps, + const srsran::rrc_ue_capabilities_t& ue_caps, bool phy_cfg_updated) { // Compute pending updates and fill reconf msg diff --git a/srsenb/src/stack/upper/CMakeLists.txt b/srsenb/src/stack/upper/CMakeLists.txt index 6e478ad0e..226bd4eb1 100644 --- a/srsenb/src/stack/upper/CMakeLists.txt +++ b/srsenb/src/stack/upper/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of diff --git a/srsenb/src/stack/upper/gtpu.cc b/srsenb/src/stack/upper/gtpu.cc index 74fb72c31..3eb9494ea 100644 --- a/srsenb/src/stack/upper/gtpu.cc +++ b/srsenb/src/stack/upper/gtpu.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,13 +10,13 @@ * */ -#include "srslte/upper/gtpu.h" +#include "srsran/upper/gtpu.h" #include "srsenb/hdr/stack/upper/gtpu.h" -#include "srslte/common/network_utils.h" -#include "srslte/common/standard_streams.h" -#include "srslte/common/string_helpers.h" -#include "srslte/interfaces/enb_interfaces.h" -#include "srslte/interfaces/enb_pdcp_interfaces.h" +#include "srsran/common/network_utils.h" +#include "srsran/common/standard_streams.h" +#include "srsran/common/string_helpers.h" +#include "srsran/interfaces/enb_interfaces.h" +#include "srsran/interfaces/enb_pdcp_interfaces.h" #include #include @@ -24,10 +24,10 @@ #include #include -using namespace srslte; +using namespace srsran; namespace srsenb { -gtpu::gtpu(srslte::task_sched_handle task_sched_, srslog::basic_logger& logger) : +gtpu::gtpu(srsran::task_sched_handle task_sched_, srslog::basic_logger& logger) : m1u(this), task_sched(task_sched_), logger(logger) {} @@ -50,7 +50,7 @@ int gtpu::init(std::string gtp_bind_addr_, fd = socket(AF_INET, SOCK_DGRAM, 0); if (fd < 0) { logger.error("Failed to create socket"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } int enable = 1; #if defined(SO_REUSEADDR) @@ -71,8 +71,8 @@ int gtpu::init(std::string gtp_bind_addr_, if (bind(fd, (struct sockaddr*)&bindaddr, sizeof(struct sockaddr_in))) { snprintf(errbuf, sizeof(errbuf), "%s", strerror(errno)); logger.error("Failed to bind on address %s, port %d: %s", gtp_bind_addr.c_str(), int(GTPU_PORT), errbuf); - srslte::console("Failed to bind on address %s, port %d: %s\n", gtp_bind_addr.c_str(), int(GTPU_PORT), errbuf); - return SRSLTE_ERROR; + srsran::console("Failed to bind on address %s, port %d: %s\n", gtp_bind_addr.c_str(), int(GTPU_PORT), errbuf); + return SRSRAN_ERROR; } stack->add_gtpu_s1u_socket_handler(fd); @@ -81,10 +81,10 @@ int gtpu::init(std::string gtp_bind_addr_, enable_mbsfn = enable_mbsfn_; if (enable_mbsfn) { if (not m1u.init(m1u_multiaddr_, m1u_if_addr_)) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } void gtpu::stop() @@ -95,18 +95,18 @@ void gtpu::stop() } // gtpu_interface_pdcp -void gtpu::write_pdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t pdu) +void gtpu::write_pdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t pdu) { - srslte::span teids = get_lcid_teids(rnti, lcid); + srsran::span teids = get_lcid_teids(rnti, lcid); if (teids.empty()) { return; } tunnel& tx_tun = tunnels[teids[0]]; - log_message(tx_tun, false, srslte::make_span(pdu)); + log_message(tx_tun, false, srsran::make_span(pdu)); send_pdu_to_tunnel(tx_tun, std::move(pdu)); } -void gtpu::send_pdu_to_tunnel(tunnel& tx_tun, srslte::unique_byte_buffer_t pdu, int pdcp_sn) +void gtpu::send_pdu_to_tunnel(tunnel& tx_tun, srsran::unique_byte_buffer_t pdu, int pdcp_sn) { // Check valid IP version struct iphdr* ip_pkt = (struct iphdr*)pdu->msg; @@ -160,13 +160,13 @@ uint32_t gtpu::add_bearer(uint16_t rnti, uint32_t lcid, uint32_t addr, uint32_t ue_teidin_db[rnti][lcid].push_back(teid_in); fmt::memory_buffer str_buffer; - srslte::gtpu_ntoa(str_buffer, htonl(addr)); + srsran::gtpu_ntoa(str_buffer, htonl(addr)); logger.info("New tunnel teid_in=0x%x, teid_out=0x%x, rnti=0x%x, lcid=%d, addr=%s", teid_in, teid_out, rnti, lcid, - srslte::to_c_str(str_buffer)); + srsran::to_c_str(str_buffer)); if (props != nullptr) { if (props->flush_before_teidin_present) { @@ -201,7 +201,7 @@ uint32_t gtpu::add_bearer(uint16_t rnti, uint32_t lcid, uint32_t addr, uint32_t // Connect tunnels if forwarding is activated if (props->forward_from_teidin_present) { - if (create_dl_fwd_tunnel(props->forward_from_teidin, teid_in) != SRSLTE_SUCCESS) { + if (create_dl_fwd_tunnel(props->forward_from_teidin, teid_in) != SRSRAN_SUCCESS) { rem_tunnel(teid_in); return 0; } @@ -342,7 +342,7 @@ void gtpu::handle_end_marker(tunnel& rx_tunnel) } } -void gtpu::handle_gtpu_s1u_rx_packet(srslte::unique_byte_buffer_t pdu, const sockaddr_in& addr) +void gtpu::handle_gtpu_s1u_rx_packet(srsran::unique_byte_buffer_t pdu, const sockaddr_in& addr) { logger.debug("Received %d bytes from S1-U interface", pdu->N_bytes); pdu->set_timestamp(); @@ -378,7 +378,7 @@ void gtpu::handle_gtpu_s1u_rx_packet(srslte::unique_byte_buffer_t pdu, const soc uint16_t rnti = rx_tun.rnti; uint16_t lcid = rx_tun.lcid; - log_message(rx_tun, true, srslte::make_span(pdu)); + log_message(rx_tun, true, srsran::make_span(pdu)); if (lcid < SRSENB_N_SRB || lcid >= SRSENB_N_RADIO_BEARERS) { logger.error("Invalid LCID for DL PDU: %d - dropping packet", lcid); @@ -413,7 +413,7 @@ void gtpu::handle_gtpu_s1u_rx_packet(srslte::unique_byte_buffer_t pdu, const soc } } -void gtpu::handle_gtpu_m1u_rx_packet(srslte::unique_byte_buffer_t pdu, const sockaddr_in& addr) +void gtpu::handle_gtpu_m1u_rx_packet(srsran::unique_byte_buffer_t pdu, const sockaddr_in& addr) { m1u.handle_rx_packet(std::move(pdu), addr); } @@ -425,7 +425,7 @@ int gtpu::create_dl_fwd_tunnel(uint32_t rx_teid_in, uint32_t tx_teid_in) auto tx_tun_pair = tunnels.find(tx_teid_in); if (rx_tun_pair == tunnels.end() or tx_tun_pair == tunnels.end()) { logger.error("Failed to create forwarding tunnel between teids 0x%x and 0x%x", rx_teid_in, tx_teid_in); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } tunnel &rx_tun = rx_tun_pair->second, &tx_tun = tx_tun_pair->second; @@ -440,13 +440,13 @@ int gtpu::create_dl_fwd_tunnel(uint32_t rx_teid_in, uint32_t tx_teid_in) tx_tun.spgw_addr); // Get all buffered PDCP PDUs, and forward them through tx tunnel - std::map pdus = pdcp->get_buffered_pdus(rx_tun.rnti, rx_tun.lcid); + std::map pdus = pdcp->get_buffered_pdus(rx_tun.rnti, rx_tun.lcid); for (auto& pdu_pair : pdus) { - log_message(tx_tun, false, srslte::make_span(pdu_pair.second), pdu_pair.first); + log_message(tx_tun, false, srsran::make_span(pdu_pair.second), pdu_pair.first); send_pdu_to_tunnel(tx_tun, std::move(pdu_pair.second), pdu_pair.first); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } /**************************************************************************** @@ -559,7 +559,7 @@ gtpu::tunnel* gtpu::get_tunnel(uint32_t teidin) return &it->second; } -srslte::span gtpu::get_lcid_teids(uint16_t rnti, uint32_t lcid) +srsran::span gtpu::get_lcid_teids(uint16_t rnti, uint32_t lcid) { auto ue_it = ue_teidin_db.find(rnti); if (ue_it == ue_teidin_db.end() or lcid < SRSENB_N_SRB or lcid >= SRSENB_N_RADIO_BEARERS or @@ -570,7 +570,7 @@ srslte::span gtpu::get_lcid_teids(uint16_t rnti, uint32_t lcid) return ue_it->second[lcid]; } -void gtpu::log_message(tunnel& tun, bool is_rx, srslte::span pdu, int pdcp_sn) +void gtpu::log_message(tunnel& tun, bool is_rx, srsran::span pdu, int pdcp_sn) { struct iphdr* ip_pkt = (struct iphdr*)pdu.data(); if (ip_pkt->version != 4 && ip_pkt->version != 6) { @@ -584,17 +584,17 @@ void gtpu::log_message(tunnel& tun, bool is_rx, srslte::span pdu, int p fmt::basic_memory_buffer strbuf; const char* dir = "Tx"; fmt::memory_buffer strbuf2, addrbuf; - srslte::gtpu_ntoa(addrbuf, htonl(tun.spgw_addr)); + srsran::gtpu_ntoa(addrbuf, htonl(tun.spgw_addr)); if (is_rx) { dir = "Rx"; - fmt::format_to(strbuf2, "{}:0x{:0x} > ", srslte::to_c_str(addrbuf), tun.teid_in); + fmt::format_to(strbuf2, "{}:0x{:0x} > ", srsran::to_c_str(addrbuf), tun.teid_in); if (not tun.dl_enabled) { fmt::format_to(strbuf2, "DL (buffered), "); } else if (tun.fwd_teid_in_present) { tunnel& tx_tun = tunnels.at(tun.fwd_teid_in); addrbuf.clear(); - srslte::gtpu_ntoa(addrbuf, htonl(tx_tun.spgw_addr)); - fmt::format_to(strbuf2, "{}:0x{:0x} (forwarded), ", srslte::to_c_str(addrbuf), tx_tun.teid_in); + srsran::gtpu_ntoa(addrbuf, htonl(tx_tun.spgw_addr)); + fmt::format_to(strbuf2, "{}:0x{:0x} (forwarded), ", srsran::to_c_str(addrbuf), tx_tun.teid_in); } else { fmt::format_to(strbuf2, "DL, "); } @@ -604,7 +604,7 @@ void gtpu::log_message(tunnel& tun, bool is_rx, srslte::span pdu, int p } else { fmt::format_to(strbuf2, "UL "); } - fmt::format_to(strbuf2, "> {}:0x{:0x}, ", srslte::to_c_str(addrbuf), tun.teid_in); + fmt::format_to(strbuf2, "> {}:0x{:0x}, ", srsran::to_c_str(addrbuf), tun.teid_in); } fmt::format_to(strbuf, "{} S1-U SDU, {}rnti=0x{:0x}, lcid={}, n_bytes={}, IPv{}", @@ -617,14 +617,14 @@ void gtpu::log_message(tunnel& tun, bool is_rx, srslte::span pdu, int p if (ip_pkt->version == 4) { addrbuf.clear(); strbuf2.clear(); - srslte::gtpu_ntoa(addrbuf, ip_pkt->saddr); - srslte::gtpu_ntoa(strbuf2, ip_pkt->daddr); - fmt::format_to(strbuf, " {} > {}", srslte::to_c_str(addrbuf), srslte::to_c_str(strbuf2)); + srsran::gtpu_ntoa(addrbuf, ip_pkt->saddr); + srsran::gtpu_ntoa(strbuf2, ip_pkt->daddr); + fmt::format_to(strbuf, " {} > {}", srsran::to_c_str(addrbuf), srsran::to_c_str(strbuf2)); if (ntohs(ip_pkt->tot_len) != pdu.size()) { logger.error("IP Len and PDU N_bytes mismatch"); } } - logger.info(pdu.data(), pdu.size(), "%s", srslte::to_c_str(strbuf)); + logger.info(pdu.data(), pdu.size(), "%s", srsran::to_c_str(strbuf)); } /**************************************************************************** @@ -682,13 +682,13 @@ bool gtpu::m1u_handler::init(std::string m1u_multiaddr_, std::string m1u_if_addr return true; } -void gtpu::m1u_handler::handle_rx_packet(srslte::unique_byte_buffer_t pdu, const sockaddr_in& addr) +void gtpu::m1u_handler::handle_rx_packet(srsran::unique_byte_buffer_t pdu, const sockaddr_in& addr) { logger.debug("Received %d bytes from M1-U interface", pdu->N_bytes); gtpu_header_t header; gtpu_read_header(pdu.get(), &header, logger); - pdcp->write_sdu(SRSLTE_MRNTI, lcid_counter, std::move(pdu)); + pdcp->write_sdu(SRSRAN_MRNTI, lcid_counter, std::move(pdu)); } } // namespace srsenb diff --git a/srsenb/src/stack/upper/pdcp.cc b/srsenb/src/stack/upper/pdcp.cc index d323ed42e..f62ac1897 100644 --- a/srsenb/src/stack/upper/pdcp.cc +++ b/srsenb/src/stack/upper/pdcp.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -12,13 +12,13 @@ #include "srsenb/hdr/stack/upper/pdcp.h" #include "srsenb/hdr/stack/upper/common_enb.h" -#include "srslte/interfaces/enb_gtpu_interfaces.h" -#include "srslte/interfaces/enb_rlc_interfaces.h" -#include "srslte/interfaces/enb_rrc_interfaces.h" +#include "srsran/interfaces/enb_gtpu_interfaces.h" +#include "srsran/interfaces/enb_rlc_interfaces.h" +#include "srsran/interfaces/enb_rrc_interfaces.h" namespace srsenb { -pdcp::pdcp(srslte::task_sched_handle task_sched_, srslog::basic_logger& logger_) : +pdcp::pdcp(srsran::task_sched_handle task_sched_, srslog::basic_logger& logger_) : task_sched(task_sched_), logger(logger_) {} @@ -40,7 +40,7 @@ void pdcp::stop() void pdcp::add_user(uint16_t rnti) { if (users.count(rnti) == 0) { - srslte::pdcp* obj = new srslte::pdcp(task_sched, logger.id().c_str()); + srsran::pdcp* obj = new srsran::pdcp(task_sched, logger.id().c_str()); obj->init(&users[rnti].rlc_itf, &users[rnti].rrc_itf, &users[rnti].gtpu_itf); users[rnti].rlc_itf.rnti = rnti; users[rnti].gtpu_itf.rnti = rnti; @@ -69,10 +69,10 @@ void pdcp::rem_user(uint16_t rnti) } } -void pdcp::add_bearer(uint16_t rnti, uint32_t lcid, srslte::pdcp_config_t cfg) +void pdcp::add_bearer(uint16_t rnti, uint32_t lcid, srsran::pdcp_config_t cfg) { if (users.count(rnti)) { - if (rnti != SRSLTE_MRNTI) { + if (rnti != SRSRAN_MRNTI) { users[rnti].pdcp->add_bearer(lcid, cfg); } else { users[rnti].pdcp->add_bearer_mrb(lcid, cfg); @@ -94,7 +94,7 @@ void pdcp::reset(uint16_t rnti) } } -void pdcp::config_security(uint16_t rnti, uint32_t lcid, srslte::as_security_config_t sec_cfg) +void pdcp::config_security(uint16_t rnti, uint32_t lcid, srsran::as_security_config_t sec_cfg) { if (users.count(rnti)) { users[rnti].pdcp->config_security(lcid, sec_cfg); @@ -103,15 +103,15 @@ void pdcp::config_security(uint16_t rnti, uint32_t lcid, srslte::as_security_con void pdcp::enable_integrity(uint16_t rnti, uint32_t lcid) { - users[rnti].pdcp->enable_integrity(lcid, srslte::DIRECTION_TXRX); + users[rnti].pdcp->enable_integrity(lcid, srsran::DIRECTION_TXRX); } void pdcp::enable_encryption(uint16_t rnti, uint32_t lcid) { - users[rnti].pdcp->enable_encryption(lcid, srslte::DIRECTION_TXRX); + users[rnti].pdcp->enable_encryption(lcid, srsran::DIRECTION_TXRX); } -bool pdcp::get_bearer_state(uint16_t rnti, uint32_t lcid, srslte::pdcp_lte_state_t* state) +bool pdcp::get_bearer_state(uint16_t rnti, uint32_t lcid, srsran::pdcp_lte_state_t* state) { if (users.count(rnti) == 0) { return false; @@ -119,7 +119,7 @@ bool pdcp::get_bearer_state(uint16_t rnti, uint32_t lcid, srslte::pdcp_lte_state return users[rnti].pdcp->get_bearer_state(lcid, state); } -bool pdcp::set_bearer_state(uint16_t rnti, uint32_t lcid, const srslte::pdcp_lte_state_t& state) +bool pdcp::set_bearer_state(uint16_t rnti, uint32_t lcid, const srsran::pdcp_lte_state_t& state) { if (users.count(rnti) == 0) { return false; @@ -143,24 +143,24 @@ void pdcp::send_status_report(uint16_t rnti) users[rnti].pdcp->send_status_report(); } -void pdcp::notify_delivery(uint16_t rnti, uint32_t lcid, const srslte::pdcp_sn_vector_t& pdcp_sns) +void pdcp::notify_delivery(uint16_t rnti, uint32_t lcid, const srsran::pdcp_sn_vector_t& pdcp_sns) { if (users.count(rnti)) { users[rnti].pdcp->notify_delivery(lcid, pdcp_sns); } } -void pdcp::notify_failure(uint16_t rnti, uint32_t lcid, const srslte::pdcp_sn_vector_t& pdcp_sns) +void pdcp::notify_failure(uint16_t rnti, uint32_t lcid, const srsran::pdcp_sn_vector_t& pdcp_sns) { if (users.count(rnti)) { users[rnti].pdcp->notify_failure(lcid, pdcp_sns); } } -void pdcp::write_sdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t sdu, int pdcp_sn) +void pdcp::write_sdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t sdu, int pdcp_sn) { if (users.count(rnti)) { - if (rnti != SRSLTE_MRNTI) { + if (rnti != SRSRAN_MRNTI) { // TODO: Handle PDCP SN coming from GTPU users[rnti].pdcp->write_sdu(lcid, std::move(sdu), pdcp_sn); } else { @@ -176,7 +176,7 @@ void pdcp::send_status_report(uint16_t rnti, uint32_t lcid) } } -std::map pdcp::get_buffered_pdus(uint16_t rnti, uint32_t lcid) +std::map pdcp::get_buffered_pdus(uint16_t rnti, uint32_t lcid) { if (users.count(rnti)) { return users[rnti].pdcp->get_buffered_pdus(lcid); @@ -184,19 +184,19 @@ std::map pdcp::get_buffered_pdus(uint16_ return {}; } -void pdcp::write_pdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t sdu) +void pdcp::write_pdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t sdu) { if (users.count(rnti)) { users[rnti].pdcp->write_pdu(lcid, std::move(sdu)); } } -void pdcp::user_interface_gtpu::write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t pdu) +void pdcp::user_interface_gtpu::write_pdu(uint32_t lcid, srsran::unique_byte_buffer_t pdu) { gtpu->write_pdu(rnti, lcid, std::move(pdu)); } -void pdcp::user_interface_rlc::write_sdu(uint32_t lcid, srslte::unique_byte_buffer_t sdu) +void pdcp::user_interface_rlc::write_sdu(uint32_t lcid, srsran::unique_byte_buffer_t sdu) { rlc->write_sdu(rnti, lcid, std::move(sdu)); } @@ -216,22 +216,22 @@ bool pdcp::user_interface_rlc::sdu_queue_is_full(uint32_t lcid) return rlc->sdu_queue_is_full(rnti, lcid); } -void pdcp::user_interface_rrc::write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t pdu) +void pdcp::user_interface_rrc::write_pdu(uint32_t lcid, srsran::unique_byte_buffer_t pdu) { rrc->write_pdu(rnti, lcid, std::move(pdu)); } -void pdcp::user_interface_rrc::write_pdu_bcch_bch(srslte::unique_byte_buffer_t pdu) +void pdcp::user_interface_rrc::write_pdu_bcch_bch(srsran::unique_byte_buffer_t pdu) { ERROR("Error: Received BCCH from ue=%d", rnti); } -void pdcp::user_interface_rrc::write_pdu_bcch_dlsch(srslte::unique_byte_buffer_t pdu) +void pdcp::user_interface_rrc::write_pdu_bcch_dlsch(srsran::unique_byte_buffer_t pdu) { ERROR("Error: Received BCCH from ue=%d", rnti); } -void pdcp::user_interface_rrc::write_pdu_pcch(srslte::unique_byte_buffer_t pdu) +void pdcp::user_interface_rrc::write_pdu_pcch(srsran::unique_byte_buffer_t pdu) { ERROR("Error: Received PCCH from ue=%d", rnti); } diff --git a/srsenb/src/stack/upper/pdcp_nr.cc b/srsenb/src/stack/upper/pdcp_nr.cc index 19ae3e1f8..81bd74f0b 100644 --- a/srsenb/src/stack/upper/pdcp_nr.cc +++ b/srsenb/src/stack/upper/pdcp_nr.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,11 +11,11 @@ */ #include "srsenb/hdr/stack/upper/pdcp_nr.h" -#include "lib/include/srslte/interfaces/nr_common_interface_types.h" +#include "lib/include/srsran/interfaces/nr_common_interface_types.h" namespace srsenb { -pdcp_nr::pdcp_nr(srslte::task_sched_handle task_sched_, const char* logname) : +pdcp_nr::pdcp_nr(srsran::task_sched_handle task_sched_, const char* logname) : task_sched(task_sched_), logger(srslog::fetch_basic_logger(logname)) {} @@ -44,7 +44,7 @@ void pdcp_nr::stop() void pdcp_nr::add_user(uint16_t rnti) { if (users.count(rnti) == 0) { - users[rnti].pdcp.reset(new srslte::pdcp(task_sched, "PDCP")); + users[rnti].pdcp.reset(new srsran::pdcp(task_sched, "PDCP")); users[rnti].rlc_itf.rnti = rnti; users[rnti].sdap_itf.rnti = rnti; users[rnti].rrc_itf.rnti = rnti; @@ -60,7 +60,7 @@ void pdcp_nr::rem_user(uint16_t rnti) users.erase(rnti); } -void pdcp_nr::add_bearer(uint16_t rnti, uint32_t lcid, srslte::pdcp_config_t cfg) +void pdcp_nr::add_bearer(uint16_t rnti, uint32_t lcid, srsran::pdcp_config_t cfg) { if (users.count(rnti)) { users[rnti].pdcp->add_bearer(lcid, cfg); @@ -74,7 +74,7 @@ void pdcp_nr::reset(uint16_t rnti) } } -void pdcp_nr::config_security(uint16_t rnti, uint32_t lcid, srslte::as_security_config_t sec_cfg) +void pdcp_nr::config_security(uint16_t rnti, uint32_t lcid, srsran::as_security_config_t sec_cfg) { if (users.count(rnti)) { users[rnti].pdcp->config_security(lcid, sec_cfg); @@ -83,15 +83,15 @@ void pdcp_nr::config_security(uint16_t rnti, uint32_t lcid, srslte::as_security_ void pdcp_nr::enable_integrity(uint16_t rnti, uint32_t lcid) { - users[rnti].pdcp->enable_integrity(lcid, srslte::DIRECTION_TXRX); + users[rnti].pdcp->enable_integrity(lcid, srsran::DIRECTION_TXRX); } void pdcp_nr::enable_encryption(uint16_t rnti, uint32_t lcid) { - users[rnti].pdcp->enable_encryption(lcid, srslte::DIRECTION_TXRX); + users[rnti].pdcp->enable_encryption(lcid, srsran::DIRECTION_TXRX); } -void pdcp_nr::write_pdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t sdu) +void pdcp_nr::write_pdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t sdu) { if (users.count(rnti)) { users[rnti].pdcp->write_pdu(lcid, std::move(sdu)); @@ -100,7 +100,7 @@ void pdcp_nr::write_pdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer } } -void pdcp_nr::notify_delivery(uint16_t rnti, uint32_t lcid, const srslte::pdcp_sn_vector_t& pdcp_sns) +void pdcp_nr::notify_delivery(uint16_t rnti, uint32_t lcid, const srsran::pdcp_sn_vector_t& pdcp_sns) { if (users.count(rnti)) { users[rnti].pdcp->notify_delivery(lcid, pdcp_sns); @@ -109,7 +109,7 @@ void pdcp_nr::notify_delivery(uint16_t rnti, uint32_t lcid, const srslte::pdcp_s } } -void pdcp_nr::notify_failure(uint16_t rnti, uint32_t lcid, const srslte::pdcp_sn_vector_t& pdcp_sns) +void pdcp_nr::notify_failure(uint16_t rnti, uint32_t lcid, const srsran::pdcp_sn_vector_t& pdcp_sns) { if (users.count(rnti)) { users[rnti].pdcp->notify_failure(lcid, pdcp_sns); @@ -118,7 +118,7 @@ void pdcp_nr::notify_failure(uint16_t rnti, uint32_t lcid, const srslte::pdcp_sn } } -void pdcp_nr::write_sdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t sdu) +void pdcp_nr::write_sdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t sdu) { if (users.count(rnti)) { users[rnti].pdcp->write_sdu(lcid, std::move(sdu)); @@ -127,12 +127,12 @@ void pdcp_nr::write_sdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer } } -void pdcp_nr::user_interface_sdap::write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t pdu) +void pdcp_nr::user_interface_sdap::write_pdu(uint32_t lcid, srsran::unique_byte_buffer_t pdu) { sdap->write_pdu(rnti, lcid, std::move(pdu)); } -void pdcp_nr::user_interface_rlc::write_sdu(uint32_t lcid, srslte::unique_byte_buffer_t sdu) +void pdcp_nr::user_interface_rlc::write_sdu(uint32_t lcid, srsran::unique_byte_buffer_t sdu) { rlc->write_sdu(rnti, lcid, std::move(sdu)); } @@ -152,29 +152,29 @@ bool pdcp_nr::user_interface_rlc::sdu_queue_is_full(uint32_t lcid) return rlc->sdu_queue_is_full(rnti, lcid); } -void pdcp_nr::user_interface_rrc::write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t pdu) +void pdcp_nr::user_interface_rrc::write_pdu(uint32_t lcid, srsran::unique_byte_buffer_t pdu) { rrc->write_pdu(rnti, lcid, std::move(pdu)); } -void pdcp_nr::user_interface_rrc::write_pdu_bcch_bch(srslte::unique_byte_buffer_t pdu) +void pdcp_nr::user_interface_rrc::write_pdu_bcch_bch(srsran::unique_byte_buffer_t pdu) { ERROR("Error: Received BCCH from ue=%d", rnti); } -void pdcp_nr::user_interface_rrc::write_pdu_bcch_dlsch(srslte::unique_byte_buffer_t pdu) +void pdcp_nr::user_interface_rrc::write_pdu_bcch_dlsch(srsran::unique_byte_buffer_t pdu) { ERROR("Error: Received BCCH from ue=%d", rnti); } -void pdcp_nr::user_interface_rrc::write_pdu_pcch(srslte::unique_byte_buffer_t pdu) +void pdcp_nr::user_interface_rrc::write_pdu_pcch(srsran::unique_byte_buffer_t pdu) { ERROR("Error: Received PCCH from ue=%d", rnti); } std::string pdcp_nr::user_interface_rrc::get_rb_name(uint32_t lcid) { - return srslte::to_string(static_cast(lcid)); + return srsran::to_string(static_cast(lcid)); } } // namespace srsenb diff --git a/srsenb/src/stack/upper/rlc.cc b/srsenb/src/stack/upper/rlc.cc index f439d83c2..d9daa2902 100644 --- a/srsenb/src/stack/upper/rlc.cc +++ b/srsenb/src/stack/upper/rlc.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -12,16 +12,16 @@ #include "srsenb/hdr/stack/upper/rlc.h" #include "srsenb/hdr/stack/upper/common_enb.h" -#include "srslte/interfaces/enb_mac_interfaces.h" -#include "srslte/interfaces/enb_pdcp_interfaces.h" -#include "srslte/interfaces/enb_rrc_interfaces.h" +#include "srsran/interfaces/enb_mac_interfaces.h" +#include "srsran/interfaces/enb_pdcp_interfaces.h" +#include "srsran/interfaces/enb_rrc_interfaces.h" namespace srsenb { void rlc::init(pdcp_interface_rlc* pdcp_, rrc_interface_rlc* rrc_, mac_interface_rlc* mac_, - srslte::timer_handler* timers_) + srsran::timer_handler* timers_) { pdcp = pdcp_; rrc = rrc_; @@ -56,7 +56,7 @@ void rlc::add_user(uint16_t rnti) { pthread_rwlock_rdlock(&rwlock); if (users.count(rnti) == 0) { - std::unique_ptr obj(new srslte::rlc(logger.id().c_str())); + std::unique_ptr obj(new srsran::rlc(logger.id().c_str())); obj->init(&users[rnti], &users[rnti], timers, @@ -90,7 +90,7 @@ void rlc::clear_buffer(uint16_t rnti) pthread_rwlock_rdlock(&rwlock); if (users.count(rnti)) { users[rnti].rlc->empty_queue(); - for (int i = 0; i < SRSLTE_N_RADIO_BEARERS; i++) { + for (int i = 0; i < SRSRAN_N_RADIO_BEARERS; i++) { if (users[rnti].rlc->has_bearer(i)) { mac->rlc_buffer_state(rnti, i, 0, 0); } @@ -100,7 +100,7 @@ void rlc::clear_buffer(uint16_t rnti) pthread_rwlock_unlock(&rwlock); } -void rlc::add_bearer(uint16_t rnti, uint32_t lcid, srslte::rlc_config_t cnfg) +void rlc::add_bearer(uint16_t rnti, uint32_t lcid, srsran::rlc_config_t cnfg) { pthread_rwlock_rdlock(&rwlock); if (users.count(rnti)) { @@ -190,13 +190,13 @@ int rlc::read_pdu(uint16_t rnti, uint32_t lcid, uint8_t* payload, uint32_t nof_b pthread_rwlock_rdlock(&rwlock); if (users.count(rnti)) { - if (rnti != SRSLTE_MRNTI) { + if (rnti != SRSRAN_MRNTI) { ret = users[rnti].rlc->read_pdu(lcid, payload, nof_bytes); } else { ret = users[rnti].rlc->read_pdu_mch(lcid, payload, nof_bytes); } } else { - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } pthread_rwlock_unlock(&rwlock); return ret; @@ -211,11 +211,11 @@ void rlc::write_pdu(uint16_t rnti, uint32_t lcid, uint8_t* payload, uint32_t nof pthread_rwlock_unlock(&rwlock); } -void rlc::write_sdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t sdu) +void rlc::write_sdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t sdu) { pthread_rwlock_rdlock(&rwlock); if (users.count(rnti)) { - if (rnti != SRSLTE_MRNTI) { + if (rnti != SRSRAN_MRNTI) { users[rnti].rlc->write_sdu(lcid, std::move(sdu)); } else { users[rnti].rlc->write_sdu_mch(lcid, std::move(sdu)); @@ -260,7 +260,7 @@ void rlc::user_interface::max_retx_attempted() rrc->max_retx_attempted(rnti); } -void rlc::user_interface::write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t sdu) +void rlc::user_interface::write_pdu(uint32_t lcid, srsran::unique_byte_buffer_t sdu) { if (lcid == RB_ID_SRB0) { rrc->write_pdu(rnti, lcid, std::move(sdu)); @@ -269,27 +269,27 @@ void rlc::user_interface::write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t } } -void rlc::user_interface::notify_delivery(uint32_t lcid, const srslte::pdcp_sn_vector_t& pdcp_sns) +void rlc::user_interface::notify_delivery(uint32_t lcid, const srsran::pdcp_sn_vector_t& pdcp_sns) { pdcp->notify_delivery(rnti, lcid, pdcp_sns); } -void rlc::user_interface::notify_failure(uint32_t lcid, const srslte::pdcp_sn_vector_t& pdcp_sns) +void rlc::user_interface::notify_failure(uint32_t lcid, const srsran::pdcp_sn_vector_t& pdcp_sns) { pdcp->notify_failure(rnti, lcid, pdcp_sns); } -void rlc::user_interface::write_pdu_bcch_bch(srslte::unique_byte_buffer_t sdu) +void rlc::user_interface::write_pdu_bcch_bch(srsran::unique_byte_buffer_t sdu) { ERROR("Error: Received BCCH from ue=%d", rnti); } -void rlc::user_interface::write_pdu_bcch_dlsch(srslte::unique_byte_buffer_t sdu) +void rlc::user_interface::write_pdu_bcch_dlsch(srsran::unique_byte_buffer_t sdu) { ERROR("Error: Received BCCH from ue=%d", rnti); } -void rlc::user_interface::write_pdu_pcch(srslte::unique_byte_buffer_t sdu) +void rlc::user_interface::write_pdu_pcch(srsran::unique_byte_buffer_t sdu) { ERROR("Error: Received PCCH from ue=%d", rnti); } diff --git a/srsenb/src/stack/upper/rlc_nr.cc b/srsenb/src/stack/upper/rlc_nr.cc index db1b2130a..3992e2053 100644 --- a/srsenb/src/stack/upper/rlc_nr.cc +++ b/srsenb/src/stack/upper/rlc_nr.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,7 +11,7 @@ */ #include "srsenb/hdr/stack/upper/rlc_nr.h" -#include "srslte/interfaces/nr_common_interface_types.h" +#include "srsran/interfaces/nr_common_interface_types.h" namespace srsenb { @@ -20,7 +20,7 @@ rlc_nr::rlc_nr(const char* logname) : logger(srslog::fetch_basic_logger(logname) void rlc_nr::init(pdcp_interface_rlc_nr* pdcp_, rrc_interface_rlc_nr* rrc_, mac_interface_rlc_nr* mac_, - srslte::timer_handler* timers_) + srsran::timer_handler* timers_) { m_pdcp = pdcp_; m_rrc = rrc_; @@ -44,9 +44,9 @@ void rlc_nr::add_user(uint16_t rnti) user_itf.m_pdcp = m_pdcp; user_itf.m_rrc = m_rrc; user_itf.parent = this; - user_itf.m_rlc.reset(new srslte::rlc(logger.id().c_str())); + user_itf.m_rlc.reset(new srsran::rlc(logger.id().c_str())); users[rnti] = std::move(user_itf); - users[rnti].m_rlc->init(&users[rnti], &users[rnti], timers, (int)srslte::rb_id_nr_t::NR_SRB0); + users[rnti].m_rlc->init(&users[rnti], &users[rnti], timers, (int)srsran::rb_id_nr_t::NR_SRB0); } } @@ -64,14 +64,14 @@ void rlc_nr::clear_buffer(uint16_t rnti) { if (users.count(rnti)) { users[rnti].m_rlc->empty_queue(); - for (int i = 0; i < SRSLTE_N_RADIO_BEARERS; i++) { + for (int i = 0; i < SRSRAN_N_RADIO_BEARERS; i++) { m_mac->rlc_buffer_state(rnti, i, 0, 0); } logger.info("Cleared buffer rnti=0x%x", rnti); } } -void rlc_nr::add_bearer(uint16_t rnti, uint32_t lcid, srslte::rlc_config_t cnfg) +void rlc_nr::add_bearer(uint16_t rnti, uint32_t lcid, srsran::rlc_config_t cnfg) { if (users.count(rnti)) { users[rnti].m_rlc->add_bearer(lcid, cnfg); @@ -96,7 +96,7 @@ int rlc_nr::read_pdu(uint16_t rnti, uint32_t lcid, uint8_t* payload, uint32_t no uint32_t tx_queue; if (users.count(rnti)) { - if (rnti != SRSLTE_MRNTI) { + if (rnti != SRSRAN_MRNTI) { ret = users[rnti].m_rlc->read_pdu(lcid, payload, nof_bytes); tx_queue = users[rnti].m_rlc->get_buffer_state(lcid); } else { @@ -110,7 +110,7 @@ int rlc_nr::read_pdu(uint16_t rnti, uint32_t lcid, uint8_t* payload, uint32_t no logger.debug("Buffer state PDCP: rnti=0x%x, lcid=%d, tx_queue=%d", rnti, lcid, tx_queue); m_mac->rlc_buffer_state(rnti, lcid, tx_queue, retx_queue); } else { - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } return ret; } @@ -135,12 +135,12 @@ void rlc_nr::write_pdu(uint16_t rnti, uint32_t lcid, uint8_t* payload, uint32_t // m_rrc->read_pdu_bcch_dlsch(sib_index, payload); //} -void rlc_nr::write_sdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t sdu) +void rlc_nr::write_sdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t sdu) { uint32_t tx_queue; if (users.count(rnti)) { - if (rnti != SRSLTE_MRNTI) { + if (rnti != SRSRAN_MRNTI) { users[rnti].m_rlc->write_sdu(lcid, std::move(sdu)); tx_queue = users[rnti].m_rlc->get_buffer_state(lcid); } else { @@ -178,41 +178,41 @@ void rlc_nr::user_interface::max_retx_attempted() m_rrc->max_retx_attempted(rnti); } -void rlc_nr::user_interface::write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t sdu) +void rlc_nr::user_interface::write_pdu(uint32_t lcid, srsran::unique_byte_buffer_t sdu) { - if (lcid == (int)srslte::rb_id_nr_t::NR_SRB0) { + if (lcid == (int)srsran::rb_id_nr_t::NR_SRB0) { m_rrc->write_pdu(rnti, lcid, std::move(sdu)); } else { m_pdcp->write_pdu(rnti, lcid, std::move(sdu)); } } -void rlc_nr::user_interface::write_pdu_bcch_bch(srslte::unique_byte_buffer_t sdu) +void rlc_nr::user_interface::write_pdu_bcch_bch(srsran::unique_byte_buffer_t sdu) { ERROR("Error: Received BCCH from ue=%d", rnti); } -void rlc_nr::user_interface::write_pdu_bcch_dlsch(srslte::unique_byte_buffer_t sdu) +void rlc_nr::user_interface::write_pdu_bcch_dlsch(srsran::unique_byte_buffer_t sdu) { ERROR("Error: Received BCCH from ue=%d", rnti); } -void rlc_nr::user_interface::write_pdu_pcch(srslte::unique_byte_buffer_t sdu) +void rlc_nr::user_interface::write_pdu_pcch(srsran::unique_byte_buffer_t sdu) { ERROR("Error: Received PCCH from ue=%d", rnti); } std::string rlc_nr::user_interface::get_rb_name(uint32_t lcid) { - return srslte::to_string(static_cast(lcid)); + return srsran::to_string(static_cast(lcid)); } -void rlc_nr::user_interface::notify_delivery(uint32_t lcid, const srslte::pdcp_sn_vector_t& pdcp_sns) +void rlc_nr::user_interface::notify_delivery(uint32_t lcid, const srsran::pdcp_sn_vector_t& pdcp_sns) { m_pdcp->notify_delivery(rnti, lcid, pdcp_sns); } -void rlc_nr::user_interface::notify_failure(uint32_t lcid, const srslte::pdcp_sn_vector_t& pdcp_sns) +void rlc_nr::user_interface::notify_failure(uint32_t lcid, const srsran::pdcp_sn_vector_t& pdcp_sns) { m_pdcp->notify_failure(rnti, lcid, pdcp_sns); } diff --git a/srsenb/src/stack/upper/s1ap.cc b/srsenb/src/stack/upper/s1ap.cc index 9b5f296af..a13de8400 100644 --- a/srsenb/src/stack/upper/s1ap.cc +++ b/srsenb/src/stack/upper/s1ap.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -12,12 +12,12 @@ #include "srsenb/hdr/stack/upper/s1ap.h" #include "srsenb/hdr/stack/upper/common_enb.h" -#include "srslte/adt/scope_exit.h" -#include "srslte/common/bcd_helpers.h" -#include "srslte/common/enb_events.h" -#include "srslte/common/int_helpers.h" -#include "srslte/common/standard_streams.h" -#include "srslte/interfaces/enb_rrc_interfaces.h" +#include "srsran/adt/scope_exit.h" +#include "srsran/common/bcd_helpers.h" +#include "srsran/common/enb_events.h" +#include "srsran/common/int_helpers.h" +#include "srsran/common/standard_streams.h" +#include "srsran/interfaces/enb_rrc_interfaces.h" #include //for inet_ntop() #include @@ -29,8 +29,8 @@ #include #include //for close(), sleep() -using srslte::s1ap_mccmnc_to_plmn; -using srslte::uint32_to_uint8; +using srsran::s1ap_mccmnc_to_plmn; +using srsran::uint32_to_uint8; #define procError(fmt, ...) s1ap_ptr->logger.error("Proc \"%s\" - " fmt, name(), ##__VA_ARGS__) #define procWarning(fmt, ...) s1ap_ptr->logger.warning("Proc \"%s\" - " fmt, name(), ##__VA_ARGS__) @@ -56,10 +56,10 @@ asn1::bounded_bitstring<1, 160, true, true> addr_to_asn1(const char* addr_str) *********************************************************/ s1ap::ue::ho_prep_proc_t::ho_prep_proc_t(s1ap::ue* ue_) : ue_ptr(ue_), s1ap_ptr(ue_->s1ap_ptr) {} -srslte::proc_outcome_t s1ap::ue::ho_prep_proc_t::init(uint32_t target_eci_, - srslte::plmn_id_t target_plmn_, - srslte::span fwd_erabs, - srslte::unique_byte_buffer_t rrc_container_) +srsran::proc_outcome_t s1ap::ue::ho_prep_proc_t::init(uint32_t target_eci_, + srsran::plmn_id_t target_plmn_, + srsran::span fwd_erabs, + srsran::unique_byte_buffer_t rrc_container_) { ho_cmd_msg = nullptr; target_eci = target_eci_; @@ -68,36 +68,36 @@ srslte::proc_outcome_t s1ap::ue::ho_prep_proc_t::init(uint32_t procInfo("Sending HandoverRequired to MME id=%d", ue_ptr->ctxt.mme_ue_s1ap_id); if (not ue_ptr->send_ho_required(target_eci, target_plmn, fwd_erabs, std::move(rrc_container_))) { procError("Failed to send HORequired to cell 0x%x", target_eci); - return srslte::proc_outcome_t::error; + return srsran::proc_outcome_t::error; } // Start HO preparation timer ue_ptr->ts1_reloc_prep.run(); - return srslte::proc_outcome_t::yield; + return srsran::proc_outcome_t::yield; } -srslte::proc_outcome_t s1ap::ue::ho_prep_proc_t::react(ts1_reloc_prep_expired e) +srsran::proc_outcome_t s1ap::ue::ho_prep_proc_t::react(ts1_reloc_prep_expired e) { // do nothing for now procError("timer TS1Relocprep has expired."); - return srslte::proc_outcome_t::error; + return srsran::proc_outcome_t::error; } -srslte::proc_outcome_t s1ap::ue::ho_prep_proc_t::react(const ho_prep_fail_s& msg) +srsran::proc_outcome_t s1ap::ue::ho_prep_proc_t::react(const ho_prep_fail_s& msg) { ue_ptr->ts1_reloc_prep.stop(); std::string cause = s1ap_ptr->get_cause(msg.protocol_ies.cause.value); procError("HO preparation Failure. Cause: %s", cause.c_str()); - srslte::console("HO preparation Failure. Cause: %s\n", cause.c_str()); + srsran::console("HO preparation Failure. Cause: %s\n", cause.c_str()); - return srslte::proc_outcome_t::error; + return srsran::proc_outcome_t::error; } /** * TS 36.413 - Section 8.4.1.2 - HandoverPreparation Successful Operation * Description: MME returns back an HandoverCommand to the SeNB */ -srslte::proc_outcome_t s1ap::ue::ho_prep_proc_t::react(const asn1::s1ap::ho_cmd_s& msg) +srsran::proc_outcome_t s1ap::ue::ho_prep_proc_t::react(const asn1::s1ap::ho_cmd_s& msg) { // update timers ue_ptr->ts1_reloc_prep.stop(); @@ -123,26 +123,26 @@ srslte::proc_outcome_t s1ap::ue::ho_prep_proc_t::react(const asn1::s1ap::ho_cmd_ asn1::s1ap::targetenb_to_sourceenb_transparent_container_s container; if (container.unpack(bref) != asn1::SRSASN_SUCCESS) { procError("Failed to decode TargeteNBToSourceeNBTransparentContainer"); - return srslte::proc_outcome_t::error; + return srsran::proc_outcome_t::error; } if (container.ie_exts_present or container.ext) { procWarning("Not handling extensions"); } // Create a unique buffer out of transparent container to pass to RRC - rrc_container = srslte::make_byte_buffer(); + rrc_container = srsran::make_byte_buffer(); if (rrc_container == nullptr) { procError("Fatal Error: Couldn't allocate buffer."); - return srslte::proc_outcome_t::error; + return srsran::proc_outcome_t::error; } memcpy(rrc_container->msg, container.rrc_container.data(), container.rrc_container.size()); rrc_container->N_bytes = container.rrc_container.size(); ho_cmd_msg = &msg; - return srslte::proc_outcome_t::success; + return srsran::proc_outcome_t::success; } -void s1ap::ue::ho_prep_proc_t::then(const srslte::proc_state_t& result) +void s1ap::ue::ho_prep_proc_t::then(const srsran::proc_state_t& result) { if (result.is_error()) { s1ap_ptr->rrc->ho_preparation_complete(ue_ptr->ctxt.rnti, false, *ho_cmd_msg, {}); @@ -156,60 +156,60 @@ void s1ap::ue::ho_prep_proc_t::then(const srslte::proc_state_t& result) * MME Connection *********************************************************/ -srslte::proc_outcome_t s1ap::s1_setup_proc_t::init() +srsran::proc_outcome_t s1ap::s1_setup_proc_t::init() { procInfo("Starting new MME connection."); return start_mme_connection(); } -srslte::proc_outcome_t s1ap::s1_setup_proc_t::start_mme_connection() +srsran::proc_outcome_t s1ap::s1_setup_proc_t::start_mme_connection() { if (not s1ap_ptr->running) { procInfo("S1AP is not running anymore."); - return srslte::proc_outcome_t::error; + return srsran::proc_outcome_t::error; } if (s1ap_ptr->mme_connected) { procInfo("eNB S1AP is already connected to MME"); - return srslte::proc_outcome_t::success; + return srsran::proc_outcome_t::success; } if (not s1ap_ptr->connect_mme()) { procInfo("Could not connect to MME"); - return srslte::proc_outcome_t::error; + return srsran::proc_outcome_t::error; } if (not s1ap_ptr->setup_s1()) { procError("S1 setup failed. Exiting..."); - srslte::console("S1 setup failed\n"); + srsran::console("S1 setup failed\n"); s1ap_ptr->running = false; - return srslte::proc_outcome_t::error; + return srsran::proc_outcome_t::error; } s1ap_ptr->s1setup_timeout.run(); procInfo("S1SetupRequest sent. Waiting for response..."); - return srslte::proc_outcome_t::yield; + return srsran::proc_outcome_t::yield; } -srslte::proc_outcome_t s1ap::s1_setup_proc_t::react(const srsenb::s1ap::s1_setup_proc_t::s1setupresult& event) +srsran::proc_outcome_t s1ap::s1_setup_proc_t::react(const srsenb::s1ap::s1_setup_proc_t::s1setupresult& event) { if (s1ap_ptr->s1setup_timeout.is_running()) { s1ap_ptr->s1setup_timeout.stop(); } if (event.success) { procInfo("S1Setup procedure completed successfully"); - return srslte::proc_outcome_t::success; + return srsran::proc_outcome_t::success; } procError("S1Setup failed."); - srslte::console("S1setup failed\n"); - return srslte::proc_outcome_t::error; + srsran::console("S1setup failed\n"); + return srsran::proc_outcome_t::error; } -void s1ap::s1_setup_proc_t::then(const srslte::proc_state_t& result) const +void s1ap::s1_setup_proc_t::then(const srsran::proc_state_t& result) const { if (result.is_error()) { procInfo("Failed to initiate S1 connection. Attempting reconnection in %d seconds", s1ap_ptr->mme_connect_timer.duration() / 1000); - srslte::console("Failed to initiate S1 connection. Attempting reconnection in %d seconds\n", + srsran::console("Failed to initiate S1 connection. Attempting reconnection in %d seconds\n", s1ap_ptr->mme_connect_timer.duration() / 1000); s1ap_ptr->mme_connect_timer.run(); s1ap_ptr->stack->remove_mme_socket(s1ap_ptr->s1ap_socket.get_socket()); @@ -223,7 +223,7 @@ void s1ap::s1_setup_proc_t::then(const srslte::proc_state_t& result) const * S1AP class *********************************************************/ -s1ap::s1ap(srslte::task_sched_handle task_sched_, srslog::basic_logger& logger) : +s1ap::s1ap(srsran::task_sched_handle task_sched_, srslog::basic_logger& logger) : s1setup_proc(this), logger(logger), task_sched(task_sched_) {} @@ -259,7 +259,7 @@ int s1ap::init(s1ap_args_t args_, rrc_interface_s1ap* rrc_, srsenb::stack_interf logger.error("Failed to initiate S1Setup procedure."); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } void s1ap::stop() @@ -304,7 +304,7 @@ void s1ap::build_tai_cgi() void s1ap::initial_ue(uint16_t rnti, uint32_t enb_cc_idx, asn1::s1ap::rrc_establishment_cause_e cause, - srslte::unique_byte_buffer_t pdu) + srsran::unique_byte_buffer_t pdu) { std::unique_ptr ue_ptr{new ue{this}}; ue_ptr->ctxt.rnti = rnti; @@ -320,7 +320,7 @@ void s1ap::initial_ue(uint16_t rnti, void s1ap::initial_ue(uint16_t rnti, uint32_t enb_cc_idx, asn1::s1ap::rrc_establishment_cause_e cause, - srslte::unique_byte_buffer_t pdu, + srsran::unique_byte_buffer_t pdu, uint32_t m_tmsi, uint8_t mmec) { @@ -335,7 +335,7 @@ void s1ap::initial_ue(uint16_t rnti, u->send_initialuemessage(cause, std::move(pdu), true, m_tmsi, mmec); } -void s1ap::write_pdu(uint16_t rnti, srslte::unique_byte_buffer_t pdu) +void s1ap::write_pdu(uint16_t rnti, srsran::unique_byte_buffer_t pdu) { logger.info(pdu->msg, pdu->N_bytes, "Received RRC SDU"); @@ -428,8 +428,8 @@ bool s1ap::connect_mme() logger.info("Connecting to MME %s:%d", args.mme_addr.c_str(), int(MME_PORT)); // Init SCTP socket and bind it - if (not srslte::net_utils::sctp_init_client( - &s1ap_socket, srslte::net_utils::socket_type::seqpacket, args.s1c_bind_addr.c_str())) { + if (not srsran::net_utils::sctp_init_client( + &s1ap_socket, srsran::net_utils::socket_type::seqpacket, args.s1c_bind_addr.c_str())) { return false; } logger.info("SCTP socket opened. fd=%d", s1ap_socket.fd()); @@ -487,7 +487,7 @@ bool s1ap::setup_s1() /* S1AP message handlers ********************************************************************************/ -bool s1ap::handle_mme_rx_msg(srslte::unique_byte_buffer_t pdu, +bool s1ap::handle_mme_rx_msg(srsran::unique_byte_buffer_t pdu, const sockaddr_in& from, const sctp_sndrcvinfo& sri, int flags) @@ -499,13 +499,13 @@ bool s1ap::handle_mme_rx_msg(srslte::unique_byte_buffer_t pdu, logger.debug("SCTP Notification %d", notification->sn_header.sn_type); if (notification->sn_header.sn_type == SCTP_SHUTDOWN_EVENT) { logger.info("SCTP Association Shutdown. Association: %d", sri.sinfo_assoc_id); - srslte::console("SCTP Association Shutdown. Association: %d\n", sri.sinfo_assoc_id); + srsran::console("SCTP Association Shutdown. Association: %d\n", sri.sinfo_assoc_id); stack->remove_mme_socket(s1ap_socket.get_socket()); s1ap_socket.reset(); } else if (notification->sn_header.sn_type == SCTP_PEER_ADDR_CHANGE && notification->sn_paddr_change.spc_state == SCTP_ADDR_UNREACHABLE) { logger.info("SCTP peer addres unreachable. Association: %d", sri.sinfo_assoc_id); - srslte::console("SCTP peer address unreachable. Association: %d\n", sri.sinfo_assoc_id); + srsran::console("SCTP peer address unreachable. Association: %d\n", sri.sinfo_assoc_id); stack->remove_mme_socket(s1ap_socket.get_socket()); s1ap_socket.reset(); } @@ -527,7 +527,7 @@ bool s1ap::handle_mme_rx_msg(srslte::unique_byte_buffer_t pdu, return true; } -bool s1ap::handle_s1ap_rx_pdu(srslte::byte_buffer_t* pdu) +bool s1ap::handle_s1ap_rx_pdu(srsran::byte_buffer_t* pdu) { // Save message to PCAP if (pcap != nullptr) { @@ -541,10 +541,10 @@ bool s1ap::handle_s1ap_rx_pdu(srslte::byte_buffer_t* pdu) logger.error(pdu->msg, pdu->N_bytes, "Failed to unpack received PDU"); cause_c cause; cause.set_protocol().value = cause_protocol_opts::transfer_syntax_error; - send_error_indication(SRSLTE_INVALID_RNTI, cause); + send_error_indication(SRSRAN_INVALID_RNTI, cause); return false; } - log_s1ap_msg(rx_pdu, srslte::make_span(*pdu), true); + log_s1ap_msg(rx_pdu, srsran::make_span(*pdu), true); switch (rx_pdu.type().value) { case s1ap_pdu_c::types_opts::init_msg: @@ -645,7 +645,7 @@ bool s1ap::handle_dlnastransport(const dl_nas_transport_s& msg) logger.warning("Not handling SubscriberProfileIDforRFP"); } - srslte::unique_byte_buffer_t pdu = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t pdu = srsran::make_byte_buffer(); if (pdu == nullptr) { logger.error("Fatal Error: Couldn't allocate buffer in s1ap::run_thread()."); return false; @@ -842,7 +842,7 @@ bool s1ap::handle_s1setupfailure(const asn1::s1ap::s1_setup_fail_s& msg) { std::string cause = get_cause(msg.protocol_ies.cause.value); logger.error("S1 Setup Failure. Cause: %s", cause.c_str()); - srslte::console("S1 Setup Failure. Cause: %s\n", cause.c_str()); + srsran::console("S1 Setup Failure. Cause: %s\n", cause.c_str()); return true; } @@ -872,11 +872,11 @@ bool s1ap::handle_handover_command(const asn1::s1ap::ho_cmd_s& msg) bool s1ap::handle_handover_request(const asn1::s1ap::ho_request_s& msg) { - uint16_t rnti = SRSLTE_INVALID_RNTI; + uint16_t rnti = SRSRAN_INVALID_RNTI; - auto on_scope_exit = srslte::make_scope_exit([this, &rnti, msg]() { + auto on_scope_exit = srsran::make_scope_exit([this, &rnti, msg]() { // If rnti is not allocated successfully, remove from s1ap and send handover failure - if (rnti == SRSLTE_INVALID_RNTI) { + if (rnti == SRSRAN_INVALID_RNTI) { send_ho_failure(msg.protocol_ies.mme_ue_s1ap_id.value.value); } }); @@ -913,7 +913,7 @@ bool s1ap::handle_handover_request(const asn1::s1ap::ho_request_s& msg) // Handle Handover Resource Allocation rnti = rrc->start_ho_ue_resource_alloc(msg, container); - return rnti != SRSLTE_INVALID_RNTI; + return rnti != SRSRAN_INVALID_RNTI; } bool s1ap::send_ho_failure(uint32_t mme_ue_s1ap_id) @@ -932,14 +932,14 @@ bool s1ap::send_ho_failure(uint32_t mme_ue_s1ap_id) // TODO: Setup cause container.cause.value.set_radio_network().value = cause_radio_network_opts::ho_target_not_allowed; - return sctp_send_s1ap_pdu(tx_pdu, SRSLTE_INVALID_RNTI, "HandoverFailure"); + return sctp_send_s1ap_pdu(tx_pdu, SRSRAN_INVALID_RNTI, "HandoverFailure"); } bool s1ap::send_ho_req_ack(const asn1::s1ap::ho_request_s& msg, uint16_t rnti, uint32_t enb_cc_idx, - srslte::unique_byte_buffer_t ho_cmd, - srslte::span admitted_bearers) + srsran::unique_byte_buffer_t ho_cmd, + srsran::span admitted_bearers) { s1ap_pdu_c tx_pdu; tx_pdu.set_successful_outcome().load_info_obj(ASN1_S1AP_ID_HO_RES_ALLOC); @@ -1051,7 +1051,7 @@ bool s1ap::release_erabs(uint16_t rnti, const std::vector& erabs_succe return user_ptr->send_erab_release_indication(erabs_successfully_released); } -bool s1ap::send_ue_cap_info_indication(uint16_t rnti, srslte::unique_byte_buffer_t ue_radio_cap) +bool s1ap::send_ue_cap_info_indication(uint16_t rnti, srsran::unique_byte_buffer_t ue_radio_cap) { ue* user_ptr = users.find_ue_rnti(rnti); if (user_ptr == nullptr) { @@ -1070,7 +1070,7 @@ bool s1ap::send_error_indication(uint16_t rnti, const asn1::s1ap::cause_c& cause tx_pdu.set_init_msg().load_info_obj(ASN1_S1AP_ID_ERROR_IND); auto& container = tx_pdu.init_msg().value.error_ind().protocol_ies; - if (rnti != SRSLTE_INVALID_RNTI) { + if (rnti != SRSRAN_INVALID_RNTI) { ue* user_ptr = users.find_ue_rnti(rnti); if (user_ptr == nullptr) { return false; @@ -1096,7 +1096,7 @@ bool s1ap::send_error_indication(uint16_t rnti, const asn1::s1ap::cause_c& cause ********************************************************************************/ bool s1ap::ue::send_initialuemessage(asn1::s1ap::rrc_establishment_cause_e cause, - srslte::unique_byte_buffer_t pdu, + srsran::unique_byte_buffer_t pdu, bool has_tmsi, uint32_t m_tmsi, uint8_t mmec) @@ -1135,7 +1135,7 @@ bool s1ap::ue::send_initialuemessage(asn1::s1ap::rrc_establishment_cause_e cause return s1ap_ptr->sctp_send_s1ap_pdu(tx_pdu, ctxt.rnti, "InitialUEMessage"); } -bool s1ap::ue::send_ulnastransport(srslte::unique_byte_buffer_t pdu) +bool s1ap::ue::send_ulnastransport(srsran::unique_byte_buffer_t pdu) { if (not s1ap_ptr->mme_connected) { return false; @@ -1436,7 +1436,7 @@ bool s1ap::ue::send_erab_release_indication(const std::vector& erabs_s return s1ap_ptr->sctp_send_s1ap_pdu(tx_pdu, ctxt.rnti, "E-RABReleaseIndication"); } -bool s1ap::ue::send_ue_cap_info_indication(srslte::unique_byte_buffer_t ue_radio_cap) +bool s1ap::ue::send_ue_cap_info_indication(srsran::unique_byte_buffer_t ue_radio_cap) { if (not s1ap_ptr->mme_connected) { return false; @@ -1461,9 +1461,9 @@ bool s1ap::ue::send_ue_cap_info_indication(srslte::unique_byte_buffer_t ue_radio bool s1ap::send_ho_required(uint16_t rnti, uint32_t target_eci, - srslte::plmn_id_t target_plmn, - srslte::span fwd_erabs, - srslte::unique_byte_buffer_t rrc_container) + srsran::plmn_id_t target_plmn, + srsran::span fwd_erabs, + srsran::unique_byte_buffer_t rrc_container) { if (!mme_connected) { return false; @@ -1500,7 +1500,7 @@ bool s1ap::send_enb_status_transfer_proc(uint16_t rnti, std::vectorwrite_s1ap(buf->msg, buf->N_bytes); } - if (rnti != SRSLTE_INVALID_RNTI) { + if (rnti != SRSRAN_INVALID_RNTI) { logger.info(buf->msg, buf->N_bytes, "Sending %s for rnti=0x%x", procedure_name, rnti); } else { logger.info(buf->msg, buf->N_bytes, "Sending %s to MME", procedure_name); } - uint16_t streamid = rnti == SRSLTE_INVALID_RNTI ? NONUE_STREAM_ID : users.find_ue_rnti(rnti)->stream_id; + uint16_t streamid = rnti == SRSRAN_INVALID_RNTI ? NONUE_STREAM_ID : users.find_ue_rnti(rnti)->stream_id; ssize_t n_sent = sctp_sendmsg(s1ap_socket.fd(), buf->msg, @@ -1633,7 +1633,7 @@ s1ap::ue* s1ap::find_s1apmsg_user(uint32_t enb_id, uint32_t mme_id) ? cause_radio_network_opts::unknown_enb_ue_s1ap_id : cause_radio_network_opts::unknown_pair_ue_s1ap_id; } - send_error_indication(SRSLTE_INVALID_RNTI, cause); + send_error_indication(SRSRAN_INVALID_RNTI, cause); return nullptr; } @@ -1664,7 +1664,7 @@ std::string s1ap::get_cause(const cause_c& c) return cause; } -void s1ap::start_pcap(srslte::s1ap_pcap* pcap_) +void s1ap::start_pcap(srsran::s1ap_pcap* pcap_) { pcap = pcap_; } @@ -1688,9 +1688,9 @@ s1ap::ue::ue(s1ap* s1ap_ptr_) : s1ap_ptr(s1ap_ptr_), ho_prep_proc(this), logger( } bool s1ap::ue::send_ho_required(uint32_t target_eci, - srslte::plmn_id_t target_plmn, - srslte::span fwd_erabs, - srslte::unique_byte_buffer_t rrc_container) + srsran::plmn_id_t target_plmn, + srsran::span fwd_erabs, + srsran::unique_byte_buffer_t rrc_container) { /*** Setup S1AP PDU as HandoverRequired ***/ s1ap_pdu_c tx_pdu; @@ -1758,7 +1758,7 @@ bool s1ap::ue::send_ho_required(uint32_t target_eci, memcpy(transparent_cntr.rrc_container.data(), rrc_container->msg, rrc_container->N_bytes); // pack Transparent Container into HORequired message - srslte::unique_byte_buffer_t buffer = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t buffer = srsran::make_byte_buffer(); if (buffer == nullptr) { logger.error("Failed to allocate buffer for HORequired message packing"); return false; @@ -1811,7 +1811,7 @@ bool s1ap::ue::send_enb_status_transfer_proc(std::vector& be return s1ap_ptr->sctp_send_s1ap_pdu(tx_pdu, ctxt.rnti, "ENBStatusTransfer"); } -void s1ap::log_s1ap_msg(const asn1::s1ap::s1ap_pdu_c& msg, srslte::const_span sdu, bool is_rx) +void s1ap::log_s1ap_msg(const asn1::s1ap::s1ap_pdu_c& msg, srsran::const_span sdu, bool is_rx) { std::string msg_type; diff --git a/srsenb/src/stack/upper/sdap.cc b/srsenb/src/stack/upper/sdap.cc index 7fdab1071..64935aae3 100644 --- a/srsenb/src/stack/upper/sdap.cc +++ b/srsenb/src/stack/upper/sdap.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -33,7 +33,7 @@ void sdap::stop() } } -void sdap::write_pdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t pdu) +void sdap::write_pdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t pdu) { // for now just forwards it if (m_gw) { @@ -43,7 +43,7 @@ void sdap::write_pdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t } } -void sdap::write_sdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t pdu) +void sdap::write_sdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t pdu) { m_pdcp->write_sdu(rnti, lcid, std::move(pdu)); } diff --git a/srsenb/test/CMakeLists.txt b/srsenb/test/CMakeLists.txt index 65148fe02..9d898374e 100644 --- a/srsenb/test/CMakeLists.txt +++ b/srsenb/test/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -12,5 +12,5 @@ add_subdirectory(upper) add_subdirectory(rrc) add_executable(enb_metrics_test enb_metrics_test.cc ../src/metrics_stdout.cc ../src/metrics_csv.cc) -target_link_libraries(enb_metrics_test srslte_phy srslte_common) +target_link_libraries(enb_metrics_test srsran_phy srsran_common) add_test(enb_metrics_test enb_metrics_test -o ${CMAKE_CURRENT_BINARY_DIR}/enb_metrics.csv) diff --git a/srsenb/test/common/dummy_classes.h b/srsenb/test/common/dummy_classes.h index ecee71b2a..400790bf5 100644 --- a/srsenb/test/common/dummy_classes.h +++ b/srsenb/test/common/dummy_classes.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,13 +13,13 @@ #ifndef SRSENB_DUMMY_CLASSES_H #define SRSENB_DUMMY_CLASSES_H -#include "srslte/interfaces/enb_interfaces.h" -#include "srslte/interfaces/enb_mac_interfaces.h" -#include "srslte/interfaces/enb_pdcp_interfaces.h" -#include "srslte/interfaces/enb_phy_interfaces.h" -#include "srslte/interfaces/enb_rlc_interfaces.h" -#include "srslte/interfaces/enb_rrc_interfaces.h" -#include "srslte/interfaces/enb_s1ap_interfaces.h" +#include "srsran/interfaces/enb_interfaces.h" +#include "srsran/interfaces/enb_mac_interfaces.h" +#include "srsran/interfaces/enb_pdcp_interfaces.h" +#include "srsran/interfaces/enb_phy_interfaces.h" +#include "srsran/interfaces/enb_rlc_interfaces.h" +#include "srsran/interfaces/enb_rrc_interfaces.h" +#include "srsran/interfaces/enb_s1ap_interfaces.h" namespace srsenb { @@ -34,9 +34,9 @@ public: int bearer_ue_cfg(uint16_t rnti, uint32_t lc_id, sched_interface::ue_bearer_cfg_t* cfg) override { return 0; } int bearer_ue_rem(uint16_t rnti, uint32_t lc_id) override { return 0; } void phy_config_enabled(uint16_t rnti, bool enabled) override {} - void write_mcch(const srslte::sib2_mbms_t* sib2_, - const srslte::sib13_t* sib13_, - const srslte::mcch_msg_t* mcch_, + void write_mcch(const srsran::sib2_mbms_t* sib2_, + const srsran::sib13_t* sib13_, + const srsran::mcch_msg_t* mcch_, const uint8_t* mcch_payload, const uint8_t mcch_payload_length) override {} @@ -51,10 +51,10 @@ public: void clear_buffer(uint16_t rnti) override {} void add_user(uint16_t rnti) override {} void rem_user(uint16_t rnti) override {} - void add_bearer(uint16_t rnti, uint32_t lcid, srslte::rlc_config_t cnfg) override {} + void add_bearer(uint16_t rnti, uint32_t lcid, srsran::rlc_config_t cnfg) override {} void add_bearer_mrb(uint16_t rnti, uint32_t lcid) override {} void del_bearer(uint16_t rnti, uint32_t lcid) override {} - void write_sdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t sdu) override {} + void write_sdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t sdu) override {} bool has_bearer(uint16_t rnti, uint32_t lcid) override { return false; } bool suspend_bearer(uint16_t rnti, uint32_t lcid) override { return true; } bool resume_bearer(uint16_t rnti, uint32_t lcid) override { return true; } @@ -67,18 +67,18 @@ public: void reset(uint16_t rnti) override {} void add_user(uint16_t rnti) override {} void rem_user(uint16_t rnti) override {} - void write_sdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t sdu, int pdcp_sn) override {} - void add_bearer(uint16_t rnti, uint32_t lcid, srslte::pdcp_config_t cnfg) override {} + void write_sdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t sdu, int pdcp_sn) override {} + void add_bearer(uint16_t rnti, uint32_t lcid, srsran::pdcp_config_t cnfg) override {} void del_bearer(uint16_t rnti, uint32_t lcid) override {} - void config_security(uint16_t rnti, uint32_t lcid, srslte::as_security_config_t sec_cfg_) override {} + void config_security(uint16_t rnti, uint32_t lcid, srsran::as_security_config_t sec_cfg_) override {} void enable_integrity(uint16_t rnti, uint32_t lcid) override {} void enable_encryption(uint16_t rnti, uint32_t lcid) override {} - bool get_bearer_state(uint16_t rnti, uint32_t lcid, srslte::pdcp_lte_state_t* state) override { return true; } - bool set_bearer_state(uint16_t rnti, uint32_t lcid, const srslte::pdcp_lte_state_t& state) override { return true; } + bool get_bearer_state(uint16_t rnti, uint32_t lcid, srsran::pdcp_lte_state_t* state) override { return true; } + bool set_bearer_state(uint16_t rnti, uint32_t lcid, const srsran::pdcp_lte_state_t& state) override { return true; } void reestablish(uint16_t rnti) override {} void send_status_report(uint16_t rnti) override {} void send_status_report(uint16_t rnti, uint32_t lcid) override {} - std::map get_buffered_pdus(uint16_t rnti, uint32_t lcid) override + std::map get_buffered_pdus(uint16_t rnti, uint32_t lcid) override { return {}; } @@ -90,17 +90,17 @@ public: void initial_ue(uint16_t rnti, uint32_t enb_cc_idx, asn1::s1ap::rrc_establishment_cause_e cause, - srslte::unique_byte_buffer_t pdu) override + srsran::unique_byte_buffer_t pdu) override {} void initial_ue(uint16_t rnti, uint32_t enb_cc_idx, asn1::s1ap::rrc_establishment_cause_e cause, - srslte::unique_byte_buffer_t pdu, + srsran::unique_byte_buffer_t pdu, uint32_t m_tmsi, uint8_t mmec) override {} - void write_pdu(uint16_t rnti, srslte::unique_byte_buffer_t pdu) override {} + void write_pdu(uint16_t rnti, srsran::unique_byte_buffer_t pdu) override {} bool user_exists(uint16_t rnti) override { return true; } bool user_release(uint16_t rnti, asn1::s1ap::cause_radio_network_e cause_radio) override { return true; } void ue_ctxt_setup_complete(uint16_t rnti, const asn1::s1ap::init_context_setup_resp_s& res) override {} @@ -108,9 +108,9 @@ public: bool is_mme_connected() override { return true; } bool send_ho_required(uint16_t rnti, uint32_t target_eci, - srslte::plmn_id_t target_plmn, - srslte::span fwd_erabs, - srslte::unique_byte_buffer_t rrc_container) override + srsran::plmn_id_t target_plmn, + srsran::span fwd_erabs, + srsran::unique_byte_buffer_t rrc_container) override { return true; } @@ -121,8 +121,8 @@ public: bool send_ho_req_ack(const asn1::s1ap::ho_request_s& msg, uint16_t rnti, uint32_t enb_cc_idx, - srslte::unique_byte_buffer_t ho_cmd, - srslte::span admitted_bearers) override + srsran::unique_byte_buffer_t ho_cmd, + srsran::span admitted_bearers) override { return true; } @@ -131,7 +131,7 @@ public: void send_ho_cancel(uint16_t rnti) override {} bool release_erabs(uint16_t rnti, const std::vector& erabs_successfully_released) override { return true; } - bool send_ue_cap_info_indication(uint16_t rnti, const srslte::unique_byte_buffer_t ue_radio_cap) override + bool send_ue_cap_info_indication(uint16_t rnti, const srsran::unique_byte_buffer_t ue_radio_cap) override { return true; } @@ -140,7 +140,7 @@ public: class phy_dummy : public phy_interface_rrc_lte { public: - void configure_mbsfn(srslte::sib2_mbms_t* sib2, srslte::sib13_t* sib13, const srslte::mcch_msg_t& mcch) override {} + void configure_mbsfn(srsran::sib2_mbms_t* sib2, srsran::sib13_t* sib13, const srsran::mcch_msg_t& mcch) override {} void set_config(uint16_t rnti, const phy_rrc_cfg_list_t& dedicated_list) override {} void complete_config(uint16_t rnti) override{}; }; diff --git a/srsenb/test/common/dummy_nr_classes.h b/srsenb/test/common/dummy_nr_classes.h index 4b30ed8e9..2939c9f18 100644 --- a/srsenb/test/common/dummy_nr_classes.h +++ b/srsenb/test/common/dummy_nr_classes.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,10 +10,10 @@ * */ -#ifndef SRSLTE_DUMMY_NR_CLASSES_H -#define SRSLTE_DUMMY_NR_CLASSES_H +#ifndef SRSRAN_DUMMY_NR_CLASSES_H +#define SRSRAN_DUMMY_NR_CLASSES_H -#include "srslte/interfaces/gnb_interfaces.h" +#include "srsran/interfaces/gnb_interfaces.h" namespace srsenb { @@ -23,7 +23,7 @@ public: int cell_cfg(srsenb::sched_interface::cell_cfg_t* cell_cfg_) { cellcfgobj = *cell_cfg_; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } srsenb::sched_interface::cell_cfg_t cellcfgobj; @@ -35,11 +35,11 @@ public: void clear_buffer(uint16_t rnti) override {} void add_user(uint16_t rnti) override {} void rem_user(uint16_t rnti) override {} - void add_bearer(uint16_t rnti, uint32_t lcid, srslte::rlc_config_t cnfg) override {} + void add_bearer(uint16_t rnti, uint32_t lcid, srsran::rlc_config_t cnfg) override {} void add_bearer_mrb(uint16_t rnti, uint32_t lcid) override {} - void write_sdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t sdu) override { last_sdu = std::move(sdu); } + void write_sdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t sdu) override { last_sdu = std::move(sdu); } - srslte::unique_byte_buffer_t last_sdu; + srsran::unique_byte_buffer_t last_sdu; }; class pdcp_dummy : public pdcp_interface_rrc_nr @@ -48,13 +48,13 @@ public: void reset(uint16_t rnti) override {} void add_user(uint16_t rnti) override {} void rem_user(uint16_t rnti) override {} - void write_sdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t sdu) override {} - void add_bearer(uint16_t rnti, uint32_t lcid, srslte::pdcp_config_t cnfg) override {} - void config_security(uint16_t rnti, uint32_t lcid, srslte::as_security_config_t sec_cfg) override {} + void write_sdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t sdu) override {} + void add_bearer(uint16_t rnti, uint32_t lcid, srsran::pdcp_config_t cnfg) override {} + void config_security(uint16_t rnti, uint32_t lcid, srsran::as_security_config_t sec_cfg) override {} void enable_integrity(uint16_t rnti, uint32_t lcid) override {} void enable_encryption(uint16_t rnti, uint32_t lcid) override {} }; } // namespace srsenb -#endif // SRSLTE_DUMMY_NR_CLASSES_H +#endif // SRSRAN_DUMMY_NR_CLASSES_H diff --git a/srsenb/test/enb_metrics_test.cc b/srsenb/test/enb_metrics_test.cc index f3e8d8f52..8d3c12ccc 100644 --- a/srsenb/test/enb_metrics_test.cc +++ b/srsenb/test/enb_metrics_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -12,9 +12,9 @@ #include "srsenb/hdr/metrics_csv.h" #include "srsenb/hdr/metrics_stdout.h" -#include "srslte/common/metrics_hub.h" -#include "srslte/interfaces/enb_metrics_interface.h" -#include "srslte/srslte.h" +#include "srsran/common/metrics_hub.h" +#include "srsran/interfaces/enb_metrics_interface.h" +#include "srsran/srsran.h" #include #include #include @@ -185,7 +185,7 @@ int main(int argc, char** argv) metrics_file.set_handle(&enb); // create metrics hub and register metrics for stdout - srslte::metrics_hub metricshub; + srsran::metrics_hub metricshub; metricshub.init(&enb, period); metricshub.add_listener(&metrics_screen); metricshub.add_listener(&metrics_file); diff --git a/srsenb/test/mac/CMakeLists.txt b/srsenb/test/mac/CMakeLists.txt index bca676e40..c7f8e184c 100644 --- a/srsenb/test/mac/CMakeLists.txt +++ b/srsenb/test/mac/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -8,14 +8,14 @@ add_library(sched_test_common STATIC sched_test_common.cc sched_common_test_suite.cc sched_ue_ded_test_suite.cc sched_sim_ue.cc sched_sim_ue.cc) -target_link_libraries(sched_test_common srslte_common srslte_mac srsenb_mac) +target_link_libraries(sched_test_common srsran_common srsran_mac srsenb_mac) # Scheduler subcomponent testing add_executable(sched_grid_test sched_grid_test.cc) target_link_libraries(sched_grid_test srsenb_mac srsenb_phy - srslte_common - srslte_mac + srsran_common + srsran_mac sched_test_common ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES}) @@ -25,10 +25,10 @@ add_test(sched_grid_test sched_grid_test) add_executable(sched_test_rand sched_test_rand.cc) target_link_libraries(sched_test_rand srsenb_mac srsenb_phy - srslte_common - srslte_mac + srsran_common + srsran_mac sched_test_common - srslte_phy + srsran_phy rrc_asn1 ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES}) @@ -38,9 +38,9 @@ add_test(sched_test_rand sched_test_rand) add_executable(sched_ca_test sched_ca_test.cc) target_link_libraries(sched_ca_test srsenb_mac srsenb_phy - srslte_common - srslte_mac - srslte_phy + srsran_common + srsran_mac + srsran_phy sched_test_common rrc_asn1 ${CMAKE_THREAD_LIBS_INIT} @@ -48,17 +48,17 @@ target_link_libraries(sched_ca_test srsenb_mac add_test(sched_ca_test sched_ca_test) add_executable(sched_lc_ch_test sched_lc_ch_test.cc) -target_link_libraries(sched_lc_ch_test srslte_common srsenb_mac srslte_mac sched_test_common) +target_link_libraries(sched_lc_ch_test srsran_common srsenb_mac srsran_mac sched_test_common) add_test(sched_lc_ch_test sched_lc_ch_test) add_executable(sched_tpc_test sched_tpc_test.cc) -target_link_libraries(sched_tpc_test srslte_common srslte_mac sched_test_common) +target_link_libraries(sched_tpc_test srsran_common srsran_mac sched_test_common) add_test(sched_tpc_test sched_tpc_test) add_executable(sched_dci_test sched_dci_test.cc) -target_link_libraries(sched_dci_test srslte_common srsenb_mac srslte_mac sched_test_common) +target_link_libraries(sched_dci_test srsran_common srsenb_mac srsran_mac sched_test_common) add_test(sched_dci_test sched_dci_test) add_executable(sched_benchmark_test sched_benchmark.cc) -target_link_libraries(sched_benchmark_test srslte_common srsenb_mac srslte_mac sched_test_common) +target_link_libraries(sched_benchmark_test srsran_common srsenb_mac srsran_mac sched_test_common) add_test(sched_benchmark_test sched_benchmark_test) diff --git a/srsenb/test/mac/sched_benchmark.cc b/srsenb/test/mac/sched_benchmark.cc index d61b270c4..a16defbac 100644 --- a/srsenb/test/mac/sched_benchmark.cc +++ b/srsenb/test/mac/sched_benchmark.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -12,7 +12,7 @@ #include "sched_test_common.h" #include "srsenb/hdr/stack/mac/sched.h" -#include "srslte/adt/accumulators.h" +#include "srsran/adt/accumulators.h" #include namespace srsenb { @@ -50,7 +50,7 @@ struct run_params_range { class sched_tester : public sched_sim_base { - static std::vector get_cell_cfg(srslte::span cell_params) + static std::vector get_cell_cfg(srsran::span cell_params) { std::vector cell_cfg_list; for (const auto& c : cell_params) { @@ -79,8 +79,8 @@ public: std::vector ul_result; struct throughput_stats { - srslte::rolling_average mean_dl_tbs, mean_ul_tbs, avg_dl_mcs, avg_ul_mcs; - srslte::rolling_average avg_latency; + srsran::rolling_average mean_dl_tbs, mean_ul_tbs, avg_dl_mcs, avg_ul_mcs; + srsran::rolling_average avg_latency; }; throughput_stats total_stats; @@ -92,8 +92,8 @@ public: for (uint32_t cc = 0; cc < get_cell_params().size(); ++cc) { std::chrono::time_point tp = std::chrono::steady_clock::now(); - TESTASSERT(sched_ptr->dl_sched(to_tx_dl(tti_rx).to_uint(), cc, dl_result[cc]) == SRSLTE_SUCCESS); - TESTASSERT(sched_ptr->ul_sched(to_tx_ul(tti_rx).to_uint(), cc, ul_result[cc]) == SRSLTE_SUCCESS); + TESTASSERT(sched_ptr->dl_sched(to_tx_dl(tti_rx).to_uint(), cc, dl_result[cc]) == SRSRAN_SUCCESS); + TESTASSERT(sched_ptr->ul_sched(to_tx_ul(tti_rx).to_uint(), cc, ul_result[cc]) == SRSRAN_SUCCESS); std::chrono::time_point tp2 = std::chrono::steady_clock::now(); std::chrono::nanoseconds tdur = std::chrono::duration_cast(tp2 - tp); total_stats.avg_latency.push(tdur.count()); @@ -103,7 +103,7 @@ public: update(sf_out); process_stats(sf_out); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } void set_external_tti_events(const sim_ue_ctxt_t& ue_ctxt, ue_tti_events& pending_events) override @@ -174,14 +174,14 @@ int run_benchmark_scenario(run_params params, std::vector& run_results for (uint32_t ue_idx = 0; ue_idx < params.nof_ues; ++ue_idx) { uint16_t rnti = 0x46 + ue_idx; // Add user (first need to advance to a PRACH TTI) - while (not srslte_prach_tti_opportunity_config_fdd( + while (not srsran_prach_tti_opportunity_config_fdd( tester.get_cell_params()[ue_cfg_default.supported_cc_list[0].enb_cc_idx].cfg.prach_config, tester.get_tti_rx().to_uint(), -1)) { - TESTASSERT(tester.advance_tti() == SRSLTE_SUCCESS); + TESTASSERT(tester.advance_tti() == SRSRAN_SUCCESS); } - TESTASSERT(tester.add_user(rnti, ue_cfg_default, 16) == SRSLTE_SUCCESS); - TESTASSERT(tester.advance_tti() == SRSLTE_SUCCESS); + TESTASSERT(tester.add_user(rnti, ue_cfg_default, 16) == SRSRAN_SUCCESS); + TESTASSERT(tester.advance_tti() == SRSRAN_SUCCESS); } // Ignore stats of the first TTIs until all UEs DRB1 are created @@ -208,20 +208,20 @@ int run_benchmark_scenario(run_params params, std::vector& run_results run_result.avg_latency = std::chrono::microseconds(static_cast(tester.total_stats.avg_latency.value() / 1000)); run_results.push_back(run_result); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } run_data expected_run_result(run_params params) { assert(params.cqi == 15 && "only cqi=15 supported for now"); run_data ret{}; - int tbs_idx = srslte_ra_tbs_idx_from_mcs(28, false, false); - int tbs = srslte_ra_tbs_from_idx(tbs_idx, params.nof_prbs); + int tbs_idx = srsran_ra_tbs_idx_from_mcs(28, false, false); + int tbs = srsran_ra_tbs_from_idx(tbs_idx, params.nof_prbs); ret.avg_dl_throughput = static_cast(tbs) * 1e3F; // bps - tbs_idx = srslte_ra_tbs_idx_from_mcs(24, false, true); + tbs_idx = srsran_ra_tbs_idx_from_mcs(24, false, true); uint32_t nof_pusch_prbs = params.nof_prbs - (params.nof_prbs == 6 ? 2 : 4); - tbs = srslte_ra_tbs_from_idx(tbs_idx, nof_pusch_prbs); + tbs = srsran_ra_tbs_from_idx(tbs_idx, nof_pusch_prbs); ret.avg_ul_throughput = static_cast(tbs) * 1e3F; // bps ret.avg_dl_mcs = 27; @@ -254,12 +254,12 @@ void print_benchmark_results(const std::vector& run_results) for (uint32_t i = 0; i < run_results.size(); ++i) { const run_data& r = run_results[i]; - int tbs_idx = srslte_ra_tbs_idx_from_mcs(28, false, false); - int tbs = srslte_ra_tbs_from_idx(tbs_idx, r.params.nof_prbs); + int tbs_idx = srsran_ra_tbs_idx_from_mcs(28, false, false); + int tbs = srsran_ra_tbs_from_idx(tbs_idx, r.params.nof_prbs); float dl_rate_overhead = 1.0F - r.avg_dl_throughput / (static_cast(tbs) * 1e3F); - tbs_idx = srslte_ra_tbs_idx_from_mcs(24, false, true); + tbs_idx = srsran_ra_tbs_idx_from_mcs(24, false, true); uint32_t nof_pusch_prbs = r.params.nof_prbs - (r.params.nof_prbs == 6 ? 2 : 4); - tbs = srslte_ra_tbs_from_idx(tbs_idx, nof_pusch_prbs); + tbs = srsran_ra_tbs_from_idx(tbs_idx, nof_pusch_prbs); float ul_rate_overhead = 1.0F - r.avg_ul_throughput / (static_cast(tbs) * 1e3F); fmt::print("{:>3d}{:>6d}{:>6d}{:>12}{:>6d}{:>9.2}/{:>4.2}{:>9.1f}/{:>4.1f}{:9.1f}/{:>4.1f}{:12d}\n", @@ -294,7 +294,7 @@ int run_rate_test() run_params runparams = run_param_list.get_params(r); mac_logger.info("\n=== New run {} ===\n", r); - TESTASSERT(run_benchmark_scenario(runparams, run_results) == SRSLTE_SUCCESS); + TESTASSERT(run_benchmark_scenario(runparams, run_results) == SRSRAN_SUCCESS); } print_benchmark_results(run_results); @@ -327,7 +327,7 @@ int run_rate_test() success = false; } } - return success ? SRSLTE_SUCCESS : SRSLTE_ERROR; + return success ? SRSRAN_SUCCESS : SRSRAN_ERROR; } int run_all() @@ -342,12 +342,12 @@ int run_all() run_params runparams = run_param_list.get_params(r); mac_logger.info("\n### New run {} ###\n", r); - TESTASSERT(run_benchmark_scenario(runparams, run_results) == SRSLTE_SUCCESS); + TESTASSERT(run_benchmark_scenario(runparams, run_results) == SRSRAN_SUCCESS); } print_benchmark_results(run_results); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int run_benchmark() @@ -368,12 +368,12 @@ int run_benchmark() run_params runparams = run_param_list.get_params(r); mac_logger.info("\n### New run {} ###\n", r); - TESTASSERT(run_benchmark_scenario(runparams, run_results) == SRSLTE_SUCCESS); + TESTASSERT(run_benchmark_scenario(runparams, run_results) == SRSRAN_SUCCESS); } print_benchmark_results(run_results); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } } // namespace srsenb @@ -382,14 +382,14 @@ int main(int argc, char* argv[]) { // Setup the log spy to intercept error and warning log entries. if (!srslog::install_custom_sink( - srslte::log_sink_spy::name(), - std::unique_ptr(new srslte::log_sink_spy(srslog::get_default_log_formatter())))) { - return SRSLTE_ERROR; + srsran::log_sink_spy::name(), + std::unique_ptr(new srsran::log_sink_spy(srslog::get_default_log_formatter())))) { + return SRSRAN_ERROR; } - auto* spy = static_cast(srslog::find_sink(srslte::log_sink_spy::name())); + auto* spy = static_cast(srslog::find_sink(srsran::log_sink_spy::name())); if (spy == nullptr) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } auto& mac_log = srslog::fetch_basic_logger("MAC"); @@ -403,11 +403,11 @@ int main(int argc, char* argv[]) bool run_benchmark = false; if (argc == 1 or strcmp(argv[1], "test") == 0) { - TESTASSERT(srsenb::run_rate_test() == SRSLTE_SUCCESS); + TESTASSERT(srsenb::run_rate_test() == SRSRAN_SUCCESS); } else if (strcmp(argv[1], "benchmark") == 0) { - TESTASSERT(srsenb::run_benchmark() == SRSLTE_SUCCESS); + TESTASSERT(srsenb::run_benchmark() == SRSRAN_SUCCESS); } else { - TESTASSERT(srsenb::run_all() == SRSLTE_SUCCESS); + TESTASSERT(srsenb::run_all() == SRSRAN_SUCCESS); } return 0; diff --git a/srsenb/test/mac/sched_ca_test.cc b/srsenb/test/mac/sched_ca_test.cc index 5d22dfd79..d2df2d2c7 100644 --- a/srsenb/test/mac/sched_ca_test.cc +++ b/srsenb/test/mac/sched_ca_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,7 +13,7 @@ #include "sched_test_common.h" #include "sched_test_utils.h" #include "srsenb/hdr/stack/mac/sched.h" -#include "srslte/mac/pdu.h" +#include "srsran/mac/pdu.h" using namespace srsenb; @@ -27,7 +27,7 @@ uint32_t seed = std::chrono::system_clock::now().time_since_epoch().count(); class sched_diagnostic_printer { public: - explicit sched_diagnostic_printer(srslte::log_sink_spy& s) : s(s) {} + explicit sched_diagnostic_printer(srsran::log_sink_spy& s) : s(s) {} ~sched_diagnostic_printer() { @@ -39,7 +39,7 @@ public: } private: - srslte::log_sink_spy& s; + srsran::log_sink_spy& s; }; /****************************** @@ -157,7 +157,7 @@ int test_scell_activation(uint32_t sim_number, test_scell_activation_params para } }; generate_data(20, 1.0, P_ul_sr, randf()); - TESTASSERT(tester.test_next_ttis(generator.tti_events) == SRSLTE_SUCCESS); + TESTASSERT(tester.test_next_ttis(generator.tti_events) == SRSRAN_SUCCESS); // Event: Reconf Complete. Activate SCells. Check if CE correctly transmitted generator.step_tti(); @@ -169,7 +169,7 @@ int test_scell_activation(uint32_t sim_number, test_scell_activation_params para user->ue_sim_cfg->ue_cfg.supported_cc_list[i].active = true; user->ue_sim_cfg->ue_cfg.supported_cc_list[i].enb_cc_idx = cc_idxs[i]; } - TESTASSERT(tester.test_next_ttis(generator.tti_events) == SRSLTE_SUCCESS); + TESTASSERT(tester.test_next_ttis(generator.tti_events) == SRSRAN_SUCCESS); auto activ_list = tester.get_enb_ue_cc_map(rnti1); for (uint32_t i = 0; i < cc_idxs.size(); ++i) { TESTASSERT(activ_list[i] >= 0); @@ -182,12 +182,12 @@ int test_scell_activation(uint32_t sim_number, test_scell_activation_params para if (tester.tti_info.dl_sched_result[params.pcell_idx].data[0].nof_pdu_elems[0] > 0) { // it is a new DL tx TESTASSERT(tester.tti_info.dl_sched_result[params.pcell_idx].data[0].pdu[0][0].lcid == - (uint32_t)srslte::dl_sch_lcid::SCELL_ACTIVATION); + (uint32_t)srsran::dl_sch_lcid::SCELL_ACTIVATION); break; } } generator.step_tti(); - TESTASSERT(tester.test_next_ttis(generator.tti_events) == SRSLTE_SUCCESS); + TESTASSERT(tester.test_next_ttis(generator.tti_events) == SRSRAN_SUCCESS); } // Event: Wait for UE to receive and ack CE. Send cqi==0, which should not activate the SCell @@ -198,12 +198,12 @@ int test_scell_activation(uint32_t sim_number, test_scell_activation_params para generator.step_tti(); } } - TESTASSERT(tester.test_next_ttis(generator.tti_events) == SRSLTE_SUCCESS); + TESTASSERT(tester.test_next_ttis(generator.tti_events) == SRSRAN_SUCCESS); // The UE should now have received the CE // Event: Generate a bit more data, it should *not* go through SCells until we send a CQI generate_data(5, P_dl, P_ul_sr, randf()); - TESTASSERT(tester.test_next_ttis(generator.tti_events) == SRSLTE_SUCCESS); + TESTASSERT(tester.test_next_ttis(generator.tti_events) == SRSRAN_SUCCESS); TESTASSERT(tester.sched_stats->users[rnti1].tot_dl_sched_data[params.pcell_idx] > 0); TESTASSERT(tester.sched_stats->users[rnti1].tot_ul_sched_data[params.pcell_idx] > 0); for (uint32_t i = 1; i < cc_idxs.size(); ++i) { @@ -217,7 +217,7 @@ int test_scell_activation(uint32_t sim_number, test_scell_activation_params para tester.dl_cqi_info(tester.tti_rx.to_uint(), rnti1, cc_idxs[i], cqi); } generate_data(10, 1.0, 1.0, 1.0); - TESTASSERT(tester.test_next_ttis(generator.tti_events) == SRSLTE_SUCCESS); + TESTASSERT(tester.test_next_ttis(generator.tti_events) == SRSRAN_SUCCESS); uint64_t tot_dl_sched_data = 0; uint64_t tot_ul_sched_data = 0; for (const auto& c : cc_idxs) { @@ -230,7 +230,7 @@ int test_scell_activation(uint32_t sim_number, test_scell_activation_params para srslog::flush(); printf("[TESTER] Sim%d finished successfully\n\n", sim_number); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int main() @@ -240,14 +240,14 @@ int main() // Setup the log spy to intercept error and warning log entries. if (!srslog::install_custom_sink( - srslte::log_sink_spy::name(), - std::unique_ptr(new srslte::log_sink_spy(srslog::get_default_log_formatter())))) { - return SRSLTE_ERROR; + srsran::log_sink_spy::name(), + std::unique_ptr(new srsran::log_sink_spy(srslog::get_default_log_formatter())))) { + return SRSRAN_ERROR; } - auto* spy = static_cast(srslog::find_sink(srslte::log_sink_spy::name())); + auto* spy = static_cast(srslog::find_sink(srsran::log_sink_spy::name())); if (!spy) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } auto& mac_log = srslog::fetch_basic_logger("MAC"); @@ -267,11 +267,11 @@ int main() test_scell_activation_params p = {}; p.pcell_idx = 0; - TESTASSERT(test_scell_activation(n * 2, p) == SRSLTE_SUCCESS); + TESTASSERT(test_scell_activation(n * 2, p) == SRSRAN_SUCCESS); p = {}; p.pcell_idx = 1; - TESTASSERT(test_scell_activation(n * 2 + 1, p) == SRSLTE_SUCCESS); + TESTASSERT(test_scell_activation(n * 2 + 1, p) == SRSRAN_SUCCESS); } srslog::flush(); diff --git a/srsenb/test/mac/sched_common_test_suite.cc b/srsenb/test/mac/sched_common_test_suite.cc index dd96b2388..3926c5ba2 100644 --- a/srsenb/test/mac/sched_common_test_suite.cc +++ b/srsenb/test/mac/sched_common_test_suite.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,10 +11,10 @@ */ #include "sched_common_test_suite.h" -#include "srslte/common/test_common.h" +#include "srsran/common/test_common.h" #include -using srslte::tti_point; +using srsran::tti_point; namespace srsenb { @@ -35,12 +35,12 @@ int test_pusch_collisions(const sf_output_res_t& sf_out, uint32_t enb_cc_idx, co fmt::format("{:x}", ul_allocs).c_str()); } ul_allocs.fill(alloc.start(), alloc.stop(), true); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; }; /* TEST: Check if there is space for PRACH */ bool is_prach_tti_tx_ul = - srslte_prach_tti_opportunity_config_fdd(cell_params.cfg.prach_config, to_tx_ul(sf_out.tti_rx).to_uint(), -1); + srsran_prach_tti_opportunity_config_fdd(cell_params.cfg.prach_config, to_tx_ul(sf_out.tti_rx).to_uint(), -1); if (is_prach_tti_tx_ul) { try_ul_fill({cell_params.cfg.prach_freq_offset, cell_params.cfg.prach_freq_offset + 6}, "PRACH"); } @@ -48,16 +48,16 @@ int test_pusch_collisions(const sf_output_res_t& sf_out, uint32_t enb_cc_idx, co /* TEST: check collisions in PUCCH */ bool strict = nof_prb != 6 or (not is_prach_tti_tx_ul); // and not tti_data.ul_pending_msg3_present); uint32_t pucch_nrb = (cell_params.cfg.nrb_pucch > 0) ? (uint32_t)cell_params.cfg.nrb_pucch : 0; - srslte_pucch_cfg_t pucch_cfg = cell_params.pucch_cfg_common; - pucch_cfg.n_pucch = cell_params.nof_cce_table[SRSLTE_NOF_CFI - 1] - 1 + cell_params.cfg.n1pucch_an; - pucch_nrb = std::max(pucch_nrb, srslte_pucch_m(&pucch_cfg, cell_params.cfg.cell.cp) / 2 + 1); + srsran_pucch_cfg_t pucch_cfg = cell_params.pucch_cfg_common; + pucch_cfg.n_pucch = cell_params.nof_cce_table[SRSRAN_NOF_CFI - 1] - 1 + cell_params.cfg.n1pucch_an; + pucch_nrb = std::max(pucch_nrb, srsran_pucch_m(&pucch_cfg, cell_params.cfg.cell.cp) / 2 + 1); try_ul_fill({0, pucch_nrb}, "PUCCH", strict); try_ul_fill({cell_params.cfg.cell.nof_prb - pucch_nrb, (uint32_t)cell_params.cfg.cell.nof_prb}, "PUCCH", strict); /* TEST: check collisions in the UL PUSCH */ for (uint32_t i = 0; i < ul_result.pusch.size(); ++i) { uint32_t L, RBstart; - srslte_ra_type2_from_riv(ul_result.pusch[i].dci.type2_alloc.riv, &L, &RBstart, nof_prb, nof_prb); + srsran_ra_type2_from_riv(ul_result.pusch[i].dci.type2_alloc.riv, &L, &RBstart, nof_prb, nof_prb); strict = ul_result.pusch[i].needs_pdcch or nof_prb != 6; // Msg3 may collide with PUCCH at PRB==6 try_ul_fill({RBstart, RBstart + L}, "PUSCH", strict); } @@ -67,39 +67,39 @@ int test_pusch_collisions(const sf_output_res_t& sf_out, uint32_t enb_cc_idx, co fmt::format("{}", ul_allocs).c_str(), fmt::format("{}", *expected_ul_mask).c_str()); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int extract_dl_prbmask(const srslte_cell_t& cell, - const srslte_dci_dl_t& dci, - srslte::bounded_bitset<100, true>& alloc_mask) +int extract_dl_prbmask(const srsran_cell_t& cell, + const srsran_dci_dl_t& dci, + srsran::bounded_bitset<100, true>& alloc_mask) { - srslte_pdsch_grant_t grant; - srslte_dl_sf_cfg_t dl_sf = {}; + srsran_pdsch_grant_t grant; + srsran_dl_sf_cfg_t dl_sf = {}; alloc_mask.resize(cell.nof_prb); alloc_mask.reset(); - CONDERROR(srslte_ra_dl_dci_to_grant(&cell, &dl_sf, SRSLTE_TM1, false, &dci, &grant) == SRSLTE_ERROR, + CONDERROR(srsran_ra_dl_dci_to_grant(&cell, &dl_sf, SRSRAN_TM1, false, &dci, &grant) == SRSRAN_ERROR, "Failed to decode PDSCH grant"); for (uint32_t j = 0; j < alloc_mask.size(); ++j) { if (grant.prb_idx[0][j]) { alloc_mask.set(j); } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_pdsch_collisions(const sf_output_res_t& sf_out, uint32_t enb_cc_idx, const rbgmask_t* expected_rbgmask) { auto& cell_params = sf_out.cc_params[enb_cc_idx]; auto& dl_result = sf_out.dl_cc_result[enb_cc_idx]; - srslte::bounded_bitset<100, true> dl_allocs(cell_params.nof_prb()), alloc_mask(cell_params.nof_prb()); + srsran::bounded_bitset<100, true> dl_allocs(cell_params.nof_prb()), alloc_mask(cell_params.nof_prb()); rbgmask_t rbgmask{cell_params.nof_rbgs}; - auto try_dl_mask_fill = [&](const srslte_dci_dl_t& dci, const char* channel) { - if (extract_dl_prbmask(cell_params.cfg.cell, dci, alloc_mask) != SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + auto try_dl_mask_fill = [&](const srsran_dci_dl_t& dci, const char* channel) { + if (extract_dl_prbmask(cell_params.cfg.cell, dci, alloc_mask) != SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } CONDERROR(alloc_mask.none(), "DL allocation must occupy at least one RBG."); if ((dl_allocs & alloc_mask).any()) { @@ -109,22 +109,22 @@ int test_pdsch_collisions(const sf_output_res_t& sf_out, uint32_t enb_cc_idx, co fmt::format("{}", alloc_mask).c_str()); } dl_allocs |= alloc_mask; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; }; // Decode BC allocations, check collisions, and fill cumulative mask for (uint32_t i = 0; i < dl_result.bc.size(); ++i) { - TESTASSERT(try_dl_mask_fill(dl_result.bc[i].dci, "BC") == SRSLTE_SUCCESS); + TESTASSERT(try_dl_mask_fill(dl_result.bc[i].dci, "BC") == SRSRAN_SUCCESS); } // Decode RAR allocations, check collisions, and fill cumulative mask for (uint32_t i = 0; i < dl_result.rar.size(); ++i) { - TESTASSERT(try_dl_mask_fill(dl_result.rar[i].dci, "RAR") == SRSLTE_SUCCESS); + TESTASSERT(try_dl_mask_fill(dl_result.rar[i].dci, "RAR") == SRSRAN_SUCCESS); } // forbid Data in DL if its ACKs conflict with PRACH for PRB==6 if (cell_params.nof_prb() == 6) { - if (srslte_prach_tti_opportunity_config_fdd( + if (srsran_prach_tti_opportunity_config_fdd( cell_params.cfg.prach_config, to_tx_dl_ack(sf_out.tti_rx).to_uint(), -1)) { dl_allocs.fill(0, dl_allocs.size()); } @@ -132,15 +132,15 @@ int test_pdsch_collisions(const sf_output_res_t& sf_out, uint32_t enb_cc_idx, co // Decode Data allocations, check collisions and fill cumulative mask for (uint32_t i = 0; i < dl_result.data.size(); ++i) { - TESTASSERT(try_dl_mask_fill(dl_result.data[i].dci, "data") == SRSLTE_SUCCESS); + TESTASSERT(try_dl_mask_fill(dl_result.data[i].dci, "data") == SRSRAN_SUCCESS); } // TEST: check for holes in the PRB mask (RBGs not fully filled) rbgmask.resize(cell_params.nof_rbgs); rbgmask.reset(); - srslte::bounded_bitset<100, true> rev_alloc = ~dl_allocs; + srsran::bounded_bitset<100, true> rev_alloc = ~dl_allocs; for (uint32_t i = 0; i < cell_params.nof_rbgs; ++i) { - uint32_t lim = SRSLTE_MIN((i + 1) * cell_params.P, dl_allocs.size()); + uint32_t lim = SRSRAN_MIN((i + 1) * cell_params.P, dl_allocs.size()); bool val = dl_allocs.any(i * cell_params.P, lim); CONDERROR(rev_alloc.any(i * cell_params.P, lim) and val, "No holes can be left in an RBG"); if (val) { @@ -153,7 +153,7 @@ int test_pdsch_collisions(const sf_output_res_t& sf_out, uint32_t enb_cc_idx, co fmt::format("{}", rbgmask).c_str(), fmt::format("{}", *expected_rbgmask).c_str()); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } /** @@ -189,7 +189,7 @@ int test_sib_scheduling(const sf_output_res_t& sf_out, uint32_t enb_cc_idx) bc->tbs, cell_params.cfg.sibs[bc->index].len); CONDERROR(bc->dci.rnti != 0xffff, "Invalid rnti=0x%x for SIB%d", bc->dci.rnti, bc->index); - CONDERROR(bc->dci.format != SRSLTE_DCI_FORMAT1A, "Invalid DCI format for SIB%d", bc->index); + CONDERROR(bc->dci.format != SRSRAN_DCI_FORMAT1A, "Invalid DCI format for SIB%d", bc->index); uint32_t x = (bc->index - 1) * cell_params.cfg.si_window_ms; uint32_t sf = x % 10; @@ -197,27 +197,27 @@ int test_sib_scheduling(const sf_output_res_t& sf_out, uint32_t enb_cc_idx) while ((sfn_start % cell_params.cfg.sibs[bc->index].period_rf) != x / 10) { sfn_start--; } - srslte::tti_point win_start{sfn_start * 10 + sf}; - srslte::tti_interval window{win_start, win_start + cell_params.cfg.si_window_ms}; + srsran::tti_point win_start{sfn_start * 10 + sf}; + srsran::tti_interval window{win_start, win_start + cell_params.cfg.si_window_ms}; CONDERROR(not window.contains(to_tx_dl(sf_out.tti_rx)), "Scheduled SIB is outside of its SIB window"); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_pdcch_collisions(const sf_output_res_t& sf_out, uint32_t enb_cc_idx, - const srslte::bounded_bitset<128, true>* expected_cce_mask) + const srsran::bounded_bitset<128, true>* expected_cce_mask) { const auto& cell_params = sf_out.cc_params[enb_cc_idx]; const auto& dl_result = sf_out.dl_cc_result[enb_cc_idx]; const auto& ul_result = sf_out.ul_cc_result[enb_cc_idx]; - int ret = srslte_regs_pdcch_ncce(cell_params.regs.get(), dl_result.cfi); + int ret = srsran_regs_pdcch_ncce(cell_params.regs.get(), dl_result.cfi); TESTASSERT(ret > 0); uint32_t ncce = ret; - srslte::bounded_bitset<128, true> used_cce{ncce}; + srsran::bounded_bitset<128, true> used_cce{ncce}; // Helper Function: checks if there is any collision. If not, fills the PDCCH mask - auto try_cce_fill = [&](const srslte_dci_location_t& dci_loc, const char* ch) { + auto try_cce_fill = [&](const srsran_dci_location_t& dci_loc, const char* ch) { uint32_t cce_start = dci_loc.ncce, cce_stop = dci_loc.ncce + (1u << dci_loc.L); CONDERROR(dci_loc.L == 0, "The aggregation level %d is not valid", dci_loc.L); CONDERROR( @@ -225,7 +225,7 @@ int test_pdcch_collisions(const sf_output_res_t& sf_out, CONDERROR( used_cce.any(cce_start, cce_stop), "%s DCI collision between CCE positions (%u, %u)", ch, cce_start, cce_stop); used_cce.fill(cce_start, cce_stop); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; }; /* TEST: verify there are no dci collisions for UL, DL data, BC, RAR */ @@ -252,7 +252,7 @@ int test_pdcch_collisions(const sf_output_res_t& sf_out, fmt::format("{}", used_cce).c_str(), fmt::format("{}", *expected_cce_mask).c_str()); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_dci_content_common(const sf_output_res_t& sf_out, uint32_t enb_cc_idx) @@ -275,7 +275,7 @@ int test_dci_content_common(const sf_output_res_t& sf_out, uint32_t enb_cc_idx) } if (pusch.dci.tb.rv == 0) { // newTx - CONDERROR(pusch.dci.format != SRSLTE_DCI_FORMAT0, "Incorrect UL DCI format"); + CONDERROR(pusch.dci.format != SRSRAN_DCI_FORMAT0, "Incorrect UL DCI format"); CONDERROR(pusch.dci.tb.mcs_idx > 28, "Incorrect UL MCS index"); } } @@ -307,18 +307,18 @@ int test_dci_content_common(const sf_output_res_t& sf_out, uint32_t enb_cc_idx) } // TEST: max coderate is not exceeded for RA and Broadcast - srslte_dl_sf_cfg_t dl_sf = {}; + srsran_dl_sf_cfg_t dl_sf = {}; dl_sf.cfi = sf_out.dl_cc_result[enb_cc_idx].cfi; dl_sf.tti = to_tx_dl(sf_out.tti_rx).to_uint(); - auto test_ra_bc_coderate = [&dl_sf, &cell_params](uint32_t tbs, const srslte_dci_dl_t& dci) { - srslte_pdsch_grant_t grant = {}; - srslte_ra_dl_grant_to_grant_prb_allocation(&dci, &grant, cell_params.cfg.cell.nof_prb); - uint32_t nof_re = srslte_ra_dl_grant_nof_re(&cell_params.cfg.cell, &dl_sf, &grant); - float coderate = srslte_coderate(tbs * 8, nof_re); + auto test_ra_bc_coderate = [&dl_sf, &cell_params](uint32_t tbs, const srsran_dci_dl_t& dci) { + srsran_pdsch_grant_t grant = {}; + srsran_ra_dl_grant_to_grant_prb_allocation(&dci, &grant, cell_params.cfg.cell.nof_prb); + uint32_t nof_re = srsran_ra_dl_grant_nof_re(&cell_params.cfg.cell, &dl_sf, &grant); + float coderate = srsran_coderate(tbs * 8, nof_re); const uint32_t Qm = 2; CONDERROR( - coderate > 0.932f * Qm, "Max coderate was exceeded from %s DCI", dci.rnti == SRSLTE_SIRNTI ? "SIB" : "RAR"); - return SRSLTE_SUCCESS; + coderate > 0.932f * Qm, "Max coderate was exceeded from %s DCI", dci.rnti == SRSRAN_SIRNTI ? "SIB" : "RAR"); + return SRSRAN_SUCCESS; }; for (uint32_t i = 0; i < dl_result.bc.size(); ++i) { @@ -334,7 +334,7 @@ int test_dci_content_common(const sf_output_res_t& sf_out, uint32_t enb_cc_idx) TESTERROR("Invalid broadcast process id=%d", (int)bc.type); } - TESTASSERT(test_ra_bc_coderate(bc.tbs, bc.dci) == SRSLTE_SUCCESS); + TESTASSERT(test_ra_bc_coderate(bc.tbs, bc.dci) == SRSRAN_SUCCESS); } for (uint32_t i = 0; i < dl_result.rar.size(); ++i) { @@ -342,22 +342,22 @@ int test_dci_content_common(const sf_output_res_t& sf_out, uint32_t enb_cc_idx) CONDERROR(rar.tbs == 0, "Allocated RAR process with invalid TBS=%d", rar.tbs); // TEST: max coderate is not exceeded - TESTASSERT(test_ra_bc_coderate(rar.tbs, rar.dci) == SRSLTE_SUCCESS); + TESTASSERT(test_ra_bc_coderate(rar.tbs, rar.dci) == SRSRAN_SUCCESS); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_all_common(const sf_output_res_t& sf_out) { for (uint32_t i = 0; i < sf_out.cc_params.size(); ++i) { - TESTASSERT(test_pusch_collisions(sf_out, i, nullptr) == SRSLTE_SUCCESS); - TESTASSERT(test_pdsch_collisions(sf_out, i, nullptr) == SRSLTE_SUCCESS); - TESTASSERT(test_sib_scheduling(sf_out, i) == SRSLTE_SUCCESS); - TESTASSERT(test_pdcch_collisions(sf_out, i, nullptr) == SRSLTE_SUCCESS); - TESTASSERT(test_dci_content_common(sf_out, i) == SRSLTE_SUCCESS); + TESTASSERT(test_pusch_collisions(sf_out, i, nullptr) == SRSRAN_SUCCESS); + TESTASSERT(test_pdsch_collisions(sf_out, i, nullptr) == SRSRAN_SUCCESS); + TESTASSERT(test_sib_scheduling(sf_out, i) == SRSRAN_SUCCESS); + TESTASSERT(test_pdcch_collisions(sf_out, i, nullptr) == SRSRAN_SUCCESS); + TESTASSERT(test_dci_content_common(sf_out, i) == SRSRAN_SUCCESS); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } } // namespace srsenb diff --git a/srsenb/test/mac/sched_common_test_suite.h b/srsenb/test/mac/sched_common_test_suite.h index 0a87b266d..2e1ecac56 100644 --- a/srsenb/test/mac/sched_common_test_suite.h +++ b/srsenb/test/mac/sched_common_test_suite.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,21 +10,21 @@ * */ -#ifndef SRSLTE_SCHED_COMMON_TEST_SUITE_H -#define SRSLTE_SCHED_COMMON_TEST_SUITE_H +#ifndef SRSRAN_SCHED_COMMON_TEST_SUITE_H +#define SRSRAN_SCHED_COMMON_TEST_SUITE_H #include "srsenb/hdr/stack/mac/sched_common.h" -#include "srslte/adt/bounded_bitset.h" -#include "srslte/common/tti_point.h" -#include "srslte/interfaces/sched_interface.h" +#include "srsran/adt/bounded_bitset.h" +#include "srsran/common/tti_point.h" +#include "srsran/interfaces/sched_interface.h" namespace srsenb { struct sf_output_res_t { - srslte::span cc_params; - srslte::tti_point tti_rx; - srslte::span ul_cc_result; - srslte::span dl_cc_result; + srsran::span cc_params; + srsran::tti_point tti_rx; + srsran::span ul_cc_result; + srsran::span dl_cc_result; }; /** @@ -73,7 +73,7 @@ int test_sib_scheduling(const sf_output_res_t& sf_out, uint32_t enb_cc_idx); */ int test_pdcch_collisions(const sf_output_res_t& sf_out, uint32_t enb_cc_idx, - const srslte::bounded_bitset<128, true>* expected_cce_mask); + const srsran::bounded_bitset<128, true>* expected_cce_mask); /** * verifies correctness of DCI content for params that are independent of the UE configuration. @@ -91,10 +91,10 @@ int test_dci_content_common(const sf_output_res_t& sf_out, uint32_t enb_cc_idx); int test_all_common(const sf_output_res_t& sf_out); /// Helper function to get DL PRBs from DCI -int extract_dl_prbmask(const srslte_cell_t& cell, - const srslte_dci_dl_t& dci, - srslte::bounded_bitset<100, true>& alloc_mask); +int extract_dl_prbmask(const srsran_cell_t& cell, + const srsran_dci_dl_t& dci, + srsran::bounded_bitset<100, true>& alloc_mask); } // namespace srsenb -#endif // SRSLTE_SCHED_COMMON_TEST_SUITE_H +#endif // SRSRAN_SCHED_COMMON_TEST_SUITE_H diff --git a/srsenb/test/mac/sched_dci_test.cc b/srsenb/test/mac/sched_dci_test.cc index 06ea2b5c0..0975ee9c3 100644 --- a/srsenb/test/mac/sched_dci_test.cc +++ b/srsenb/test/mac/sched_dci_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,7 +13,7 @@ #include "sched_test_utils.h" #include "srsenb/hdr/stack/mac/sched_common.h" #include "srsenb/hdr/stack/mac/sched_phy_ch/sched_dci.h" -#include "srslte/common/test_common.h" +#include "srsran/common/test_common.h" namespace srsenb { @@ -38,46 +38,46 @@ struct tbs_test_args { float get_max_coderate() const { if (is_ul) { - return srslte_cqi_to_coderate(std::min(cqi + 1u, 15u), false); + return srsran_cqi_to_coderate(std::min(cqi + 1u, 15u), false); } - return srslte_cqi_to_coderate(std::min(cqi + 1u, 15u), use_tbs_index_alt); + return srsran_cqi_to_coderate(std::min(cqi + 1u, 15u), use_tbs_index_alt); } }; bool lower_coderate(tbs_info tb, uint32_t nof_re, const tbs_test_args& args) { - float max_coderate = srslte_cqi_to_coderate(std::min(args.cqi + 1u, 15u), args.use_tbs_index_alt); - float coderate = srslte_coderate(tb.tbs_bytes * 8, nof_re); + float max_coderate = srsran_cqi_to_coderate(std::min(args.cqi + 1u, 15u), args.use_tbs_index_alt); + float coderate = srsran_coderate(tb.tbs_bytes * 8, nof_re); if (coderate > max_coderate) { return false; } - srslte_mod_t mod = - (args.is_ul) ? srslte_ra_ul_mod_from_mcs(tb.mcs) : srslte_ra_dl_mod_from_mcs(tb.mcs, args.use_tbs_index_alt); - float Qm = std::min(args.get_max_Qm(), srslte_mod_bits_x_symbol(mod)); + srsran_mod_t mod = + (args.is_ul) ? srsran_ra_ul_mod_from_mcs(tb.mcs) : srsran_ra_dl_mod_from_mcs(tb.mcs, args.use_tbs_index_alt); + float Qm = std::min(args.get_max_Qm(), srsran_mod_bits_x_symbol(mod)); return coderate <= 0.932f * Qm; } int test_mcs_tbs_dl_helper(const sched_cell_params_t& cell_params, const tbs_test_args& args, tbs_info* result) { - srslte_dci_dl_t dci; - dci.format = SRSLTE_DCI_FORMAT1; - dci.alloc_type = SRSLTE_RA_ALLOC_TYPE0; + srsran_dci_dl_t dci; + dci.format = SRSRAN_DCI_FORMAT1; + dci.alloc_type = SRSRAN_RA_ALLOC_TYPE0; rbgmask_t rbgmask(cell_params.nof_rbgs); rbgmask.fill(0, cell_params.nof_prbs_to_rbgs(args.prb_grant_size)); dci.type0_alloc.rbg_bitmask = (uint32_t)rbgmask.to_uint64(); uint32_t nof_re = cell_params.get_dl_nof_res(args.tti_tx_dl, dci, 1); float max_coderate = args.get_max_coderate(); - if (srslte_coderate(16, nof_re) > max_coderate) { + if (srsran_coderate(16, nof_re) > max_coderate) { // no solution is possible - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Verify MCS, TBS tbs_info ret = compute_mcs_and_tbs( args.prb_grant_size, nof_re, args.cqi, args.max_mcs, args.is_ul, args.ul64qam_enabled, args.use_tbs_index_alt); if (ret.tbs_bytes < 0) { - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } if (result != nullptr) { *result = ret; @@ -85,8 +85,8 @@ int test_mcs_tbs_dl_helper(const sched_cell_params_t& cell_params, const tbs_tes CONDERROR(ret.mcs > (int)args.max_mcs, "Result mcs=%d is higher than stipulated max_mcs=%d", ret.mcs, args.max_mcs); // Verify TBS is a valid value in TS tables - uint32_t tbs_idx = srslte_ra_tbs_idx_from_mcs(ret.mcs, args.use_tbs_index_alt, args.is_ul); - int expected_tbs = srslte_ra_tbs_from_idx(tbs_idx, args.prb_grant_size); + uint32_t tbs_idx = srsran_ra_tbs_idx_from_mcs(ret.mcs, args.use_tbs_index_alt, args.is_ul); + int expected_tbs = srsran_ra_tbs_from_idx(tbs_idx, args.prb_grant_size); CONDERROR(expected_tbs != ret.tbs_bytes * 8, "The tbs=%d is not valid. For {mcs=%d,tbs_idx=%d,nof_re=%d,nof_prb=%d}, it should have been tbs=%d", ret.tbs_bytes * 8, @@ -102,8 +102,8 @@ int test_mcs_tbs_dl_helper(const sched_cell_params_t& cell_params, const tbs_tes // Verify there were no better {mcs,tbs} solutions tbs_info tb2; for (tb2.mcs = ret.mcs + 1; tb2.mcs <= (int)args.max_mcs; ++tb2.mcs) { - int tbs_idx2 = srslte_ra_tbs_idx_from_mcs(tb2.mcs, args.use_tbs_index_alt, args.is_ul); - tb2.tbs_bytes = srslte_ra_tbs_from_idx(tbs_idx2, args.prb_grant_size) / 8U; + int tbs_idx2 = srsran_ra_tbs_idx_from_mcs(tb2.mcs, args.use_tbs_index_alt, args.is_ul); + tb2.tbs_bytes = srsran_ra_tbs_from_idx(tbs_idx2, args.prb_grant_size) / 8U; TESTASSERT(not lower_coderate(tb2, nof_re, args) or (args.prb_grant_size == 1 and tb2.mcs == 6)); } @@ -119,7 +119,7 @@ int test_mcs_tbs_dl_helper(const sched_cell_params_t& cell_params, const tbs_tes tbs_idx); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int assert_mcs_tbs_result(uint32_t cell_nof_prb, @@ -143,7 +143,7 @@ int assert_mcs_tbs_result(uint32_t cell_nof_prb, } tbs_info expected_result; - TESTASSERT(test_mcs_tbs_dl_helper(cell_params, args, &expected_result) == SRSLTE_SUCCESS); + TESTASSERT(test_mcs_tbs_dl_helper(cell_params, args, &expected_result) == SRSRAN_SUCCESS); CONDERROR(expected_result != tbs_info(tbs / 8, mcs), "TBS computation failure. {%d, %d}!={%d, %d}", expected_result.tbs_bytes * 8, @@ -151,28 +151,28 @@ int assert_mcs_tbs_result(uint32_t cell_nof_prb, tbs, mcs); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_mcs_lookup_specific() { /* TEST CASE: DL, no 256-QAM */ // cqi=5,Nprb=1 -> {mcs=3, tbs_idx=3, tbs=40} - TESTASSERT(assert_mcs_tbs_result(6, 5, 1, 40, 3) == SRSLTE_SUCCESS); - TESTASSERT(assert_mcs_tbs_result(6, 5, 4, 256, 4) == SRSLTE_SUCCESS); + TESTASSERT(assert_mcs_tbs_result(6, 5, 1, 40, 3) == SRSRAN_SUCCESS); + TESTASSERT(assert_mcs_tbs_result(6, 5, 4, 256, 4) == SRSRAN_SUCCESS); - TESTASSERT(assert_mcs_tbs_result(100, 9, 1, 712, 28) == SRSLTE_SUCCESS); - TESTASSERT(assert_mcs_tbs_result(100, 10, 10, 5736, 25) == SRSLTE_SUCCESS); + TESTASSERT(assert_mcs_tbs_result(100, 9, 1, 712, 28) == SRSRAN_SUCCESS); + TESTASSERT(assert_mcs_tbs_result(100, 10, 10, 5736, 25) == SRSRAN_SUCCESS); // cqi=15 - TESTASSERT(assert_mcs_tbs_result(6, 15, 1, 336, 19) == SRSLTE_SUCCESS); // I_tbs=17 - TESTASSERT(assert_mcs_tbs_result(6, 15, 6, 2152, 19) == SRSLTE_SUCCESS); // I_tbs=17 - TESTASSERT(assert_mcs_tbs_result(100, 15, 1, 712, 28) == SRSLTE_SUCCESS); // I_tbs=26 - TESTASSERT(assert_mcs_tbs_result(100, 15, 2, 1480, 28) == SRSLTE_SUCCESS); // I_tbs=26 - TESTASSERT(assert_mcs_tbs_result(100, 15, 10, 7480, 28) == SRSLTE_SUCCESS); // I_tbs=26 - TESTASSERT(assert_mcs_tbs_result(100, 15, 1, 968, 27, true) == SRSLTE_SUCCESS); - - return SRSLTE_SUCCESS; + TESTASSERT(assert_mcs_tbs_result(6, 15, 1, 336, 19) == SRSRAN_SUCCESS); // I_tbs=17 + TESTASSERT(assert_mcs_tbs_result(6, 15, 6, 2152, 19) == SRSRAN_SUCCESS); // I_tbs=17 + TESTASSERT(assert_mcs_tbs_result(100, 15, 1, 712, 28) == SRSRAN_SUCCESS); // I_tbs=26 + TESTASSERT(assert_mcs_tbs_result(100, 15, 2, 1480, 28) == SRSRAN_SUCCESS); // I_tbs=26 + TESTASSERT(assert_mcs_tbs_result(100, 15, 10, 7480, 28) == SRSRAN_SUCCESS); // I_tbs=26 + TESTASSERT(assert_mcs_tbs_result(100, 15, 1, 968, 27, true) == SRSRAN_SUCCESS); + + return SRSRAN_SUCCESS; } /// Verify consistency of MCS,TBS computation for different permutations of banwidths, grant sizes, cqi, max_mcs @@ -193,12 +193,12 @@ int test_mcs_tbs_consistency_all() args.prb_grant_size = prb_grant; args.cqi = cqi; args.max_mcs = max_mcs; - TESTASSERT(test_mcs_tbs_dl_helper(cell_params, args, nullptr) == SRSLTE_SUCCESS); + TESTASSERT(test_mcs_tbs_dl_helper(cell_params, args, nullptr) == SRSRAN_SUCCESS); } } } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } /** @@ -216,7 +216,7 @@ int test_min_mcs_tbs_dl_helper(const sched_cell_params_t& cell_params, const tbs args.ul64qam_enabled, args.use_tbs_index_alt); tbs_info tb_max; - TESTASSERT(test_mcs_tbs_dl_helper(cell_params, args, &tb_max) == SRSLTE_SUCCESS); + TESTASSERT(test_mcs_tbs_dl_helper(cell_params, args, &tb_max) == SRSRAN_SUCCESS); CONDERROR(tb_max.mcs < result->mcs or tb_max.tbs_bytes < result->tbs_bytes, "Invalid min MCS calculation"); if (args.verbose) { @@ -228,7 +228,7 @@ int test_min_mcs_tbs_dl_helper(const sched_cell_params_t& cell_params, const tbs args.req_bytes * 8); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } /// Test search for minimum MCS/TBS in TS 36.213 table 7.1.7.2.1-1 that fulfills a TBS >= required bytes @@ -246,29 +246,29 @@ int test_min_mcs_tbs_specific() args.cqi = 10; args.prb_grant_size = 5; args.req_bytes = 10; - TESTASSERT(test_min_mcs_tbs_dl_helper(cell_params, args, &result) == SRSLTE_SUCCESS); + TESTASSERT(test_min_mcs_tbs_dl_helper(cell_params, args, &result) == SRSRAN_SUCCESS); CONDERROR(result.tbs_bytes < (int)args.req_bytes, "Invalid MCS calculation"); CONDERROR(result.tbs_bytes * 8 != 120, "Invalid min TBS calculation"); args.req_bytes = 50; - TESTASSERT(test_min_mcs_tbs_dl_helper(cell_params, args, &result) == SRSLTE_SUCCESS); + TESTASSERT(test_min_mcs_tbs_dl_helper(cell_params, args, &result) == SRSRAN_SUCCESS); CONDERROR(result.tbs_bytes < (int)args.req_bytes, "Invalid MCS calculation"); CONDERROR(result.tbs_bytes * 8 != 424, "Invalid min TBS calculation"); args.cqi = 15; args.prb_grant_size = 10; args.req_bytes = 100; - TESTASSERT(test_min_mcs_tbs_dl_helper(cell_params, args, &result) == SRSLTE_SUCCESS); + TESTASSERT(test_min_mcs_tbs_dl_helper(cell_params, args, &result) == SRSRAN_SUCCESS); CONDERROR(result.tbs_bytes < (int)args.req_bytes, "Invalid MCS calculation"); CONDERROR(result.tbs_bytes * 8 != 872, "Invalid min TBS calculation"); // Check equality case args.req_bytes = 109; - TESTASSERT(test_min_mcs_tbs_dl_helper(cell_params, args, &result) == SRSLTE_SUCCESS); + TESTASSERT(test_min_mcs_tbs_dl_helper(cell_params, args, &result) == SRSRAN_SUCCESS); CONDERROR(result.tbs_bytes < (int)args.req_bytes, "Invalid MCS calculation"); CONDERROR(result.tbs_bytes * 8 != 872, "Invalid min TBS calculation"); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } } // namespace srsenb @@ -283,9 +283,9 @@ int main() // Start the log backend. srslog::init(); - TESTASSERT(srsenb::test_mcs_lookup_specific() == SRSLTE_SUCCESS); - TESTASSERT(srsenb::test_mcs_tbs_consistency_all() == SRSLTE_SUCCESS); - TESTASSERT(srsenb::test_min_mcs_tbs_specific() == SRSLTE_SUCCESS); + TESTASSERT(srsenb::test_mcs_lookup_specific() == SRSRAN_SUCCESS); + TESTASSERT(srsenb::test_mcs_tbs_consistency_all() == SRSRAN_SUCCESS); + TESTASSERT(srsenb::test_min_mcs_tbs_specific() == SRSRAN_SUCCESS); printf("Success\n"); return 0; diff --git a/srsenb/test/mac/sched_grid_test.cc b/srsenb/test/mac/sched_grid_test.cc index d4732ceee..1f75ce411 100644 --- a/srsenb/test/mac/sched_grid_test.cc +++ b/srsenb/test/mac/sched_grid_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -12,7 +12,7 @@ #include "sched_test_common.h" #include "srsenb/hdr/stack/mac/sched_grid.h" -#include "srslte/common/test_common.h" +#include "srsran/common/test_common.h" using namespace srsenb; const uint32_t seed = std::chrono::system_clock::now().time_since_epoch().count(); @@ -22,8 +22,8 @@ const std::array prb_list = {6, 15, 25, 50, 75, 100}; uint32_t get_aggr_level(sched_ue& sched_ue, uint32_t enb_cc_idx, const std::vector& cell_params) { - srslte_dci_format_t dci_format = sched_ue.get_dci_format(); - uint32_t nof_dci_bits = srslte_dci_format_sizeof(&cell_params[enb_cc_idx].cfg.cell, nullptr, nullptr, dci_format); + srsran_dci_format_t dci_format = sched_ue.get_dci_format(); + uint32_t nof_dci_bits = srsran_dci_format_sizeof(&cell_params[enb_cc_idx].cfg.cell, nullptr, nullptr, dci_format); uint32_t aggr_level = sched_ue.get_aggr_level(enb_cc_idx, nof_dci_bits); return aggr_level; } @@ -35,7 +35,7 @@ int test_pdcch_one_ue() // Params uint32_t nof_prb = prb_list[rand_uint{0, 5}(get_rand_gen())]; uint16_t rnti = rand_uint{70, 120}(get_rand_gen()); - srslte::tti_point start_tti{rand_uint{0, 10240}(get_rand_gen())}; + srsran::tti_point start_tti{rand_uint{0, 10240}(get_rand_gen())}; uint32_t nof_ttis = 100; // Derived @@ -127,7 +127,7 @@ int test_pdcch_one_ue() } TESTASSERT(tti_counter == nof_ttis); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_pdcch_ue_and_sibs() @@ -178,7 +178,7 @@ int test_pdcch_ue_and_sibs() return dci_result[1]->dci_pos.ncce == val; })); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_6prbs() @@ -239,7 +239,7 @@ int test_6prbs() TESTASSERT(dci_result[0]->dci_pos.ncce == rnti_dci_locs3[0]); TESTASSERT(dci_result[1]->dci_pos.ncce == rnti_dci_locs4[0]); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int main() @@ -253,9 +253,9 @@ int main() // Start the log backend. srslog::init(); - TESTASSERT(test_pdcch_one_ue() == SRSLTE_SUCCESS); - TESTASSERT(test_pdcch_ue_and_sibs() == SRSLTE_SUCCESS); - TESTASSERT(test_6prbs() == SRSLTE_SUCCESS); + TESTASSERT(test_pdcch_one_ue() == SRSRAN_SUCCESS); + TESTASSERT(test_pdcch_ue_and_sibs() == SRSRAN_SUCCESS); + TESTASSERT(test_6prbs() == SRSRAN_SUCCESS); srslog::flush(); diff --git a/srsenb/test/mac/sched_lc_ch_test.cc b/srsenb/test/mac/sched_lc_ch_test.cc index 61d7d1d96..ea75b7aba 100644 --- a/srsenb/test/mac/sched_lc_ch_test.cc +++ b/srsenb/test/mac/sched_lc_ch_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,7 +13,7 @@ #include "sched_test_common.h" #include "sched_test_utils.h" #include "srsenb/hdr/stack/mac/sched_ue.h" -#include "srslte/common/test_common.h" +#include "srsran/common/test_common.h" using namespace srsenb; const uint32_t seed = std::chrono::system_clock::now().time_since_epoch().count(); @@ -39,7 +39,7 @@ int test_pdu_alloc_successful(srsenb::lch_ue_manager& lch_handler, TESTASSERT(lch_handler.alloc_rlc_pdu(&pdu, mac_sdu_size) == (int)mac_sdu_size); TESTASSERT(pdu.lcid == (uint32_t)lcid); TESTASSERT(pdu.nbytes == mac_sdu_size); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_retx_until_empty(srsenb::lch_ue_manager& lch_handler, int lcid, uint32_t rlc_payload_size) @@ -51,7 +51,7 @@ int test_retx_until_empty(srsenb::lch_ue_manager& lch_handler, int lcid, uint32_ sched_interface::dl_sched_pdu_t pdu; for (int i = 0; i < nof_pdus; ++i) { uint32_t expected_payload_size = std::min(rlc_payload_size, (uint32_t)rem_rlc_bytes); - TESTASSERT(test_pdu_alloc_successful(lch_handler, pdu, lcid, expected_payload_size) == SRSLTE_SUCCESS); + TESTASSERT(test_pdu_alloc_successful(lch_handler, pdu, lcid, expected_payload_size) == SRSRAN_SUCCESS); rem_rlc_bytes -= expected_payload_size; TESTASSERT(lch_handler.get_dl_retx(lcid) == rem_rlc_bytes); } @@ -67,7 +67,7 @@ int test_newtx_until_empty(srsenb::lch_ue_manager& lch_handler, int lcid, uint32 sched_interface::dl_sched_pdu_t pdu; for (int i = 0; i < nof_pdus; ++i) { uint32_t expected_payload_size = std::min(rlc_payload_size, (uint32_t)rem_rlc_bytes); - TESTASSERT(test_pdu_alloc_successful(lch_handler, pdu, lcid, expected_payload_size) == SRSLTE_SUCCESS); + TESTASSERT(test_pdu_alloc_successful(lch_handler, pdu, lcid, expected_payload_size) == SRSRAN_SUCCESS); rem_rlc_bytes -= expected_payload_size; TESTASSERT(lch_handler.get_dl_tx(lcid) == (int)rem_rlc_bytes); } @@ -120,7 +120,7 @@ int test_lc_ch_pbr_infinity() nof_pending_bytes = lch_handler.get_dl_tx(srsenb::RB_ID_DRB1); TESTASSERT(test_newtx_until_empty(lch_handler, srsenb::RB_ID_DRB1, 500) == nof_pending_bytes); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_lc_ch_pbr_finite() @@ -166,32 +166,32 @@ int test_lc_ch_pbr_finite() TESTASSERT(test_newtx_until_empty(lch_handler, srsenb::RB_ID_SRB1, 500) == nof_pending_bytes); // TEST4 - DRB2 has higher priority so it gets allocated until Bj <= 0 - TESTASSERT(test_pdu_alloc_successful(lch_handler, pdu, srsenb::RB_ID_DRB2, 200) == SRSLTE_SUCCESS); + TESTASSERT(test_pdu_alloc_successful(lch_handler, pdu, srsenb::RB_ID_DRB2, 200) == SRSRAN_SUCCESS); // Bj={0, infinity, 0, 12800, 200} - TESTASSERT(test_pdu_alloc_successful(lch_handler, pdu, srsenb::RB_ID_DRB2, 600) == SRSLTE_SUCCESS); + TESTASSERT(test_pdu_alloc_successful(lch_handler, pdu, srsenb::RB_ID_DRB2, 600) == SRSRAN_SUCCESS); // Bj={0, infinity, 0, 256000, -400} // TEST5 - DRB1 has lower prio, but DRB2 Bj <= 0. for (uint32_t i = 0; i < 50; ++i) { lch_handler.new_tti(); - TESTASSERT(test_pdu_alloc_successful(lch_handler, pdu, srsenb::RB_ID_DRB1, 50) == SRSLTE_SUCCESS); + TESTASSERT(test_pdu_alloc_successful(lch_handler, pdu, srsenb::RB_ID_DRB1, 50) == SRSRAN_SUCCESS); } // TEST6 - new tti restores DRB2 Bj>=0, and DRB2 gets allocated lch_handler.new_tti(); // Bj={0, infinity, 0, 256000, 8} - TESTASSERT(test_pdu_alloc_successful(lch_handler, pdu, srsenb::RB_ID_DRB2, 50) == SRSLTE_SUCCESS); + TESTASSERT(test_pdu_alloc_successful(lch_handler, pdu, srsenb::RB_ID_DRB2, 50) == SRSRAN_SUCCESS); // Bj={0, infinity, 0, 256000, -42} lch_handler.new_tti(); - TESTASSERT(test_pdu_alloc_successful(lch_handler, pdu, srsenb::RB_ID_DRB1, 50) == SRSLTE_SUCCESS); + TESTASSERT(test_pdu_alloc_successful(lch_handler, pdu, srsenb::RB_ID_DRB1, 50) == SRSRAN_SUCCESS); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int main() { srsenb::set_randseed(seed); - srslte::console("This is the chosen seed: %u\n", seed); + srsran::console("This is the chosen seed: %u\n", seed); auto& test_log = srslog::fetch_basic_logger("TEST", false); test_log.set_level(srslog::basic_levels::info); @@ -199,10 +199,10 @@ int main() // Start the log backend. srslog::init(); - TESTASSERT(test_lc_ch_pbr_infinity() == SRSLTE_SUCCESS); - TESTASSERT(test_lc_ch_pbr_finite() == SRSLTE_SUCCESS); + TESTASSERT(test_lc_ch_pbr_infinity() == SRSRAN_SUCCESS); + TESTASSERT(test_lc_ch_pbr_finite() == SRSRAN_SUCCESS); srslog::flush(); - srslte::console("Success\n"); + srsran::console("Success\n"); } diff --git a/srsenb/test/mac/sched_sim_ue.cc b/srsenb/test/mac/sched_sim_ue.cc index f06213b4c..981952ea6 100644 --- a/srsenb/test/mac/sched_sim_ue.cc +++ b/srsenb/test/mac/sched_sim_ue.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,7 +11,7 @@ */ #include "sched_sim_ue.h" -#include "lib/include/srslte/mac/pdu.h" +#include "lib/include/srsran/mac/pdu.h" #include "sched_test_utils.h" namespace srsenb { @@ -39,7 +39,7 @@ bool sim_ue_ctxt_t::is_last_dl_retx(uint32_t ue_cc_idx, uint32_t pid) const ue_sim::ue_sim(uint16_t rnti_, const sched_interface::ue_cfg_t& ue_cfg_, - srslte::tti_point prach_tti_rx_, + srsran::tti_point prach_tti_rx_, uint32_t preamble_idx) : logger(srslog::fetch_basic_logger("MAC")) { @@ -72,7 +72,7 @@ int ue_sim::update(const sf_output_res_t& sf_out) update_dl_harqs(sf_out); update_ul_harqs(sf_out); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } void ue_sim::update_dl_harqs(const sf_output_res_t& sf_out) @@ -163,12 +163,12 @@ void ue_sim::update_conn_state(const sf_output_res_t& sf_out) uint32_t cc = ctxt.ue_cfg.supported_cc_list[0].enb_cc_idx; const auto& dl_cc_result = sf_out.dl_cc_result[cc]; const auto& ul_cc_result = sf_out.ul_cc_result[cc]; - srslte::tti_point tti_tx_dl = to_tx_dl(sf_out.tti_rx); + srsran::tti_point tti_tx_dl = to_tx_dl(sf_out.tti_rx); if (not ctxt.rar_tti_rx.is_valid()) { // RAR not yet found uint32_t rar_win_size = sf_out.cc_params[cc].cfg.prach_rar_window; - srslte::tti_interval rar_window{ctxt.prach_tti_rx + 3, ctxt.prach_tti_rx + 3 + rar_win_size}; + srsran::tti_interval rar_window{ctxt.prach_tti_rx + 3, ctxt.prach_tti_rx + 3 + rar_win_size}; if (rar_window.contains(tti_tx_dl)) { for (uint32_t i = 0; i < dl_cc_result.rar.size(); ++i) { @@ -185,7 +185,7 @@ void ue_sim::update_conn_state(const sf_output_res_t& sf_out) if (ctxt.rar_tti_rx.is_valid() and not ctxt.msg3_tti_rx.is_valid()) { // RAR scheduled, Msg3 not yet scheduled - srslte::tti_point expected_msg3_tti_rx = ctxt.rar_tti_rx + MSG3_DELAY_MS; + srsran::tti_point expected_msg3_tti_rx = ctxt.rar_tti_rx + MSG3_DELAY_MS; if (expected_msg3_tti_rx == sf_out.tti_rx) { // Msg3 should exist for (uint32_t i = 0; i < ul_cc_result.pusch.size(); ++i) { @@ -201,7 +201,7 @@ void ue_sim::update_conn_state(const sf_output_res_t& sf_out) for (uint32_t i = 0; i < dl_cc_result.data.size(); ++i) { if (dl_cc_result.data[i].dci.rnti == ctxt.rnti) { for (uint32_t j = 0; j < dl_cc_result.data[i].nof_pdu_elems[0]; ++j) { - if (dl_cc_result.data[i].pdu[0][j].lcid == (uint32_t)srslte::dl_sch_lcid::CON_RES_ID) { + if (dl_cc_result.data[i].pdu[0][j].lcid == (uint32_t)srsran::dl_sch_lcid::CON_RES_ID) { // ConRes found ctxt.msg4_tti_rx = sf_out.tti_rx; } @@ -224,7 +224,7 @@ sched_sim_base::sched_sim_base(sched_interface* s int sched_sim_base::add_user(uint16_t rnti, const sched_interface::ue_cfg_t& ue_cfg_, uint32_t preamble_idx) { - CONDERROR(!srslte_prach_tti_opportunity_config_fdd( + CONDERROR(!srsran_prach_tti_opportunity_config_fdd( cell_params[ue_cfg_.supported_cc_list[0].enb_cc_idx].cfg.prach_config, current_tti_rx.to_uint(), -1), "New user added in a non-PRACH TTI"); TESTASSERT(ue_db.count(rnti) == 0); @@ -233,7 +233,7 @@ int sched_sim_base::add_user(uint16_t rnti, const sched_interface::ue_cfg_t& ue_ auto rach_cfg = generate_rach_ue_cfg(ue_cfg_); ue_db.insert(std::make_pair(rnti, ue_sim(rnti, rach_cfg, current_tti_rx, preamble_idx))); - CONDERROR(sched_ptr->ue_cfg(rnti, rach_cfg) != SRSLTE_SUCCESS, "Configuring new user rnti=0x%x to sched", rnti); + CONDERROR(sched_ptr->ue_cfg(rnti, rach_cfg) != SRSRAN_SUCCESS, "Configuring new user rnti=0x%x to sched", rnti); sched_interface::dl_sched_rar_info_t rar_info = {}; rar_info.prach_tti = current_tti_rx.to_uint(); @@ -241,18 +241,18 @@ int sched_sim_base::add_user(uint16_t rnti, const sched_interface::ue_cfg_t& ue_ rar_info.msg3_size = 7; rar_info.preamble_idx = preamble_idx; uint32_t pcell_idx = ue_cfg_.supported_cc_list[0].enb_cc_idx; - TESTASSERT(sched_ptr->dl_rach_info(pcell_idx, rar_info) == SRSLTE_SUCCESS); + TESTASSERT(sched_ptr->dl_rach_info(pcell_idx, rar_info) == SRSRAN_SUCCESS); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int sched_sim_base::ue_recfg(uint16_t rnti, const sched_interface::ue_cfg_t& ue_cfg_) { CONDERROR(ue_db.count(rnti) == 0, "User must already exist to be configured"); ue_db.at(rnti).set_cfg(ue_cfg_); - CONDERROR(sched_ptr->ue_cfg(rnti, ue_cfg_) != SRSLTE_SUCCESS, "Configuring new user rnti=0x%x to sched", rnti); + CONDERROR(sched_ptr->ue_cfg(rnti, ue_cfg_) != SRSRAN_SUCCESS, "Configuring new user rnti=0x%x to sched", rnti); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int sched_sim_base::bearer_cfg(uint16_t rnti, uint32_t lc_id, const sched_interface::ue_bearer_cfg_t& cfg) @@ -300,7 +300,7 @@ int sched_sim_base::set_default_tti_events(const sim_ue_ctxt_t& ue_ctxt, ue_tti_ cc_feedback.configured = true; cc_feedback.ue_cc_idx = ue_ctxt.enb_to_ue_cc_idx(enb_cc_idx); - for (uint32_t pid = 0; pid < SRSLTE_FDD_NOF_HARQ; ++pid) { + for (uint32_t pid = 0; pid < SRSRAN_FDD_NOF_HARQ; ++pid) { auto& dl_h = ue_ctxt.cc_list[cc_feedback.ue_cc_idx].dl_harqs[pid]; auto& ul_h = ue_ctxt.cc_list[cc_feedback.ue_cc_idx].ul_harqs[pid]; @@ -317,9 +317,9 @@ int sched_sim_base::set_default_tti_events(const sim_ue_ctxt_t& ue_ctxt, ue_tti_ } // Set default DL CQI - if (srslte_cqi_periodic_send(&ue_ctxt.ue_cfg.supported_cc_list[cc_feedback.ue_cc_idx].dl_cfg.cqi_report, + if (srsran_cqi_periodic_send(&ue_ctxt.ue_cfg.supported_cc_list[cc_feedback.ue_cc_idx].dl_cfg.cqi_report, current_tti_rx.to_uint(), - SRSLTE_FDD)) { + SRSRAN_FDD)) { cc_feedback.dl_cqi = 28; } @@ -327,7 +327,7 @@ int sched_sim_base::set_default_tti_events(const sim_ue_ctxt_t& ue_ctxt, ue_tti_ } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int sched_sim_base::apply_tti_events(sim_ue_ctxt_t& ue_ctxt, const ue_tti_events& events) @@ -394,26 +394,26 @@ int sched_sim_base::apply_tti_events(sim_ue_ctxt_t& ue_ctxt, const ue_tti_events // Schedule Msg4 when Msg3 is received if (cc_feedback.ul_pid >= 0 and cc_feedback.ul_ack) { sched_interface::ue_cfg_t ue_cfg = generate_setup_ue_cfg(final_ue_cfg[ue_ctxt.rnti]); - TESTASSERT(ue_recfg(ue_ctxt.rnti, ue_cfg) == SRSLTE_SUCCESS); + TESTASSERT(ue_recfg(ue_ctxt.rnti, ue_cfg) == SRSRAN_SUCCESS); uint32_t lcid = RB_ID_SRB0; // Use SRB0 to schedule Msg4 - TESTASSERT(sched_ptr->dl_rlc_buffer_state(ue_ctxt.rnti, lcid, 50, 0) == SRSLTE_SUCCESS); - TESTASSERT(sched_ptr->dl_mac_buffer_state(ue_ctxt.rnti, (uint32_t)srslte::dl_sch_lcid::CON_RES_ID, 1) == - SRSLTE_SUCCESS); + TESTASSERT(sched_ptr->dl_rlc_buffer_state(ue_ctxt.rnti, lcid, 50, 0) == SRSRAN_SUCCESS); + TESTASSERT(sched_ptr->dl_mac_buffer_state(ue_ctxt.rnti, (uint32_t)srsran::dl_sch_lcid::CON_RES_ID, 1) == + SRSRAN_SUCCESS); } // Perform DRB config when Msg4 is received if (cc_feedback.dl_pid >= 0 and cc_feedback.dl_ack) { ue_ctxt.conres_rx = true; - TESTASSERT(ue_recfg(ue_ctxt.rnti, final_ue_cfg[ue_ctxt.rnti]) == SRSLTE_SUCCESS); + TESTASSERT(ue_recfg(ue_ctxt.rnti, final_ue_cfg[ue_ctxt.rnti]) == SRSRAN_SUCCESS); } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -void sched_sim_base::new_tti(srslte::tti_point tti_rx) +void sched_sim_base::new_tti(srsran::tti_point tti_rx) { current_tti_rx = tti_rx; for (auto& ue : ue_db) { diff --git a/srsenb/test/mac/sched_sim_ue.h b/srsenb/test/mac/sched_sim_ue.h index c00bab9f4..34a84b88f 100644 --- a/srsenb/test/mac/sched_sim_ue.h +++ b/srsenb/test/mac/sched_sim_ue.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,12 +10,12 @@ * */ -#ifndef SRSLTE_SCHED_SIM_UE_H -#define SRSLTE_SCHED_SIM_UE_H +#ifndef SRSRAN_SCHED_SIM_UE_H +#define SRSRAN_SCHED_SIM_UE_H #include "sched_common_test_suite.h" -#include "srslte/interfaces/sched_interface.h" -#include "srslte/srslog/srslog.h" +#include "srsran/interfaces/sched_interface.h" +#include "srsran/srslog/srslog.h" #include #include @@ -28,19 +28,19 @@ struct ue_harq_ctxt_t { uint32_t nof_txs = 0; uint32_t nof_retxs = 0; uint32_t riv = 0; - srslte_dci_location_t dci_loc = {}; + srsran_dci_location_t dci_loc = {}; uint32_t tbs = 0; - srslte::tti_point last_tti_rx, first_tti_rx; + srsran::tti_point last_tti_rx, first_tti_rx; }; struct ue_cc_ctxt_t { - std::array dl_harqs; - std::array ul_harqs; + std::array dl_harqs; + std::array ul_harqs; }; struct sim_ue_ctxt_t { bool conres_rx = false; uint16_t rnti; uint32_t preamble_idx, msg3_riv; - srslte::tti_point prach_tti_rx, rar_tti_rx, msg3_tti_rx, msg4_tti_rx; + srsran::tti_point prach_tti_rx, rar_tti_rx, msg3_tti_rx, msg4_tti_rx; sched_interface::ue_cfg_t ue_cfg; std::vector cc_list; @@ -52,7 +52,7 @@ struct sim_ue_ctxt_t { }; struct sim_enb_ctxt_t { - srslte::span cell_params; + srsran::span cell_params; std::map ue_db; }; struct ue_tti_events { @@ -67,7 +67,7 @@ struct ue_tti_events { int dl_cqi = -1; int ul_snr = -1; }; - srslte::tti_point tti_rx; + srsran::tti_point tti_rx; std::vector cc_list; }; @@ -76,7 +76,7 @@ class ue_sim public: ue_sim(uint16_t rnti_, const sched_interface::ue_cfg_t& ue_cfg_, - srslte::tti_point prach_tti_rx, + srsran::tti_point prach_tti_rx, uint32_t preamble_idx); void set_cfg(const sched_interface::ue_cfg_t& ue_cfg_); @@ -109,7 +109,7 @@ public: int bearer_cfg(uint16_t rnti, uint32_t lc_id, const sched_interface::ue_bearer_cfg_t& cfg); int rem_user(uint16_t rnti); - void new_tti(srslte::tti_point tti_rx); + void new_tti(srsran::tti_point tti_rx); void update(const sf_output_res_t& sf_out); sim_enb_ctxt_t get_enb_ctxt() const; @@ -132,7 +132,7 @@ public: return ret == nullptr ? nullptr : &ret->get_ctxt().ue_cfg; } sched_interface* get_sched() { return sched_ptr; } - srslte::const_span get_cell_params() { return cell_params; } + srsran::const_span get_cell_params() { return cell_params; } tti_point get_tti_rx() const { return current_tti_rx; } std::map::iterator begin() { return ue_db.begin(); } @@ -149,7 +149,7 @@ private: sched_interface* sched_ptr; std::vector cell_params; - srslte::tti_point current_tti_rx; + srsran::tti_point current_tti_rx; std::map ue_db; std::map final_ue_cfg; uint32_t error_counter = 0; @@ -157,4 +157,4 @@ private: } // namespace srsenb -#endif // SRSLTE_SCHED_SIM_UE_H +#endif // SRSRAN_SCHED_SIM_UE_H diff --git a/srsenb/test/mac/sched_test_common.cc b/srsenb/test/mac/sched_test_common.cc index 0d0271068..37c6a06fe 100644 --- a/srsenb/test/mac/sched_test_common.cc +++ b/srsenb/test/mac/sched_test_common.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -16,7 +16,7 @@ #include "sched_common_test_suite.h" #include "sched_ue_ded_test_suite.h" -#include "srslte/common/test_common.h" +#include "srsran/common/test_common.h" using namespace srsenb; @@ -134,7 +134,7 @@ int common_sched_tester::sim_cfg(sim_sched_args args) sched_sim.reset(new sched_sim_random{this, sim_args0.sched_args, sim_args0.cell_cfg}); sched_stats.reset(new sched_result_stats{sim_args0.cell_cfg}); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int common_sched_tester::add_user(uint16_t rnti, const ue_ctxt_test_cfg& ue_cfg_) @@ -159,7 +159,7 @@ int common_sched_tester::rem_user(uint16_t rnti) void common_sched_tester::new_test_tti() { if (not tti_rx.is_valid()) { - tti_rx = srslte::tti_point{sim_args0.start_tti}; + tti_rx = srsran::tti_point{sim_args0.start_tti}; } else { tti_rx++; } @@ -177,23 +177,23 @@ int common_sched_tester::run_ue_ded_tests_and_update_ctxt(const sf_output_res_t& { // Perform UE-dedicated sched result tests sim_enb_ctxt_t enb_ctxt = sched_sim->get_enb_ctxt(); - TESTASSERT(test_all_ues(enb_ctxt, sf_out) == SRSLTE_SUCCESS); + TESTASSERT(test_all_ues(enb_ctxt, sf_out) == SRSRAN_SUCCESS); // Update Simulated UEs state sched_sim->update(sf_out); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int common_sched_tester::process_results() { // Perform common eNB result tests sf_output_res_t sf_out{sched_cell_params, tti_rx, tti_info.ul_sched_result, tti_info.dl_sched_result}; - TESTASSERT(test_all_common(sf_out) == SRSLTE_SUCCESS); - TESTASSERT(run_ue_ded_tests_and_update_ctxt(sf_out) == SRSLTE_SUCCESS); + TESTASSERT(test_all_common(sf_out) == SRSRAN_SUCCESS); + TESTASSERT(run_ue_ded_tests_and_update_ctxt(sf_out) == SRSRAN_SUCCESS); sched_stats->process_results(tti_rx, tti_info.dl_sched_result, tti_info.ul_sched_result); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int common_sched_tester::process_tti_events(const tti_ev& tti_ev) @@ -203,23 +203,23 @@ int common_sched_tester::process_tti_events(const tti_ev& tti_ev) if (ue_ev.ue_sim_cfg != nullptr) { if (not sched_sim->user_exists(ue_ev.rnti)) { // new user - TESTASSERT(add_user(ue_ev.rnti, *ue_ev.ue_sim_cfg) == SRSLTE_SUCCESS); + TESTASSERT(add_user(ue_ev.rnti, *ue_ev.ue_sim_cfg) == SRSRAN_SUCCESS); } else { // reconfiguration - TESTASSERT(reconf_user(ue_ev.rnti, ue_ev.ue_sim_cfg->ue_cfg) == SRSLTE_SUCCESS); + TESTASSERT(reconf_user(ue_ev.rnti, ue_ev.ue_sim_cfg->ue_cfg) == SRSRAN_SUCCESS); } } // There is a user to remove if (ue_ev.rem_user) { - TESTASSERT(rem_user(ue_ev.rnti) == SRSLTE_SUCCESS); + TESTASSERT(rem_user(ue_ev.rnti) == SRSRAN_SUCCESS); } // configure bearers if (ue_ev.bearer_cfg != nullptr) { CONDERROR(not sched_sim->user_exists(ue_ev.rnti), "User rnti=0x%x does not exist", ue_ev.rnti); // TODO: Instantiate more bearers - TESTASSERT(sched_sim->bearer_cfg(ue_ev.rnti, 0, *ue_ev.bearer_cfg) == SRSLTE_SUCCESS); + TESTASSERT(sched_sim->bearer_cfg(ue_ev.rnti, 0, *ue_ev.bearer_cfg) == SRSRAN_SUCCESS); } const ue_sim* user = sched_sim->find_rnti(ue_ev.rnti); @@ -245,7 +245,7 @@ int common_sched_tester::process_tti_events(const tti_ev& tti_ev) } } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int common_sched_tester::run_tti(const tti_ev& tti_events) @@ -267,15 +267,15 @@ int common_sched_tester::run_tti(const tti_ev& tti_events) ul_sched(to_tx_ul(tti_rx).to_uint(), i, tti_info.ul_sched_result[i]); } - TESTASSERT(process_results() == SRSLTE_SUCCESS); + TESTASSERT(process_results() == SRSRAN_SUCCESS); tti_count++; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int common_sched_tester::test_next_ttis(const std::vector& tti_events) { while (tti_count < tti_events.size()) { - TESTASSERT(run_tti(tti_events[tti_count]) == SRSLTE_SUCCESS); + TESTASSERT(run_tti(tti_events[tti_count]) == SRSRAN_SUCCESS); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } diff --git a/srsenb/test/mac/sched_test_common.h b/srsenb/test/mac/sched_test_common.h index 4b61f63b1..b855b0389 100644 --- a/srsenb/test/mac/sched_test_common.h +++ b/srsenb/test/mac/sched_test_common.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,14 +10,14 @@ * */ -#ifndef SRSLTE_SCHED_TEST_COMMON_H -#define SRSLTE_SCHED_TEST_COMMON_H +#ifndef SRSRAN_SCHED_TEST_COMMON_H +#define SRSRAN_SCHED_TEST_COMMON_H #include "sched_sim_ue.h" #include "sched_test_utils.h" #include "srsenb/hdr/stack/mac/sched.h" -#include "srslte/interfaces/enb_rrc_interfaces.h" -#include "srslte/srslog/srslog.h" +#include "srsran/interfaces/enb_rrc_interfaces.h" +#include "srsran/srslog/srslog.h" #include namespace srsenb { @@ -32,7 +32,7 @@ std::default_random_engine& get_rand_gen(); struct rrc_dummy : public rrc_interface_mac { public: - int add_user(uint16_t rnti, const sched_interface::ue_cfg_t& init_ue_cfg) { return SRSLTE_SUCCESS; } + int add_user(uint16_t rnti, const sched_interface::ue_cfg_t& init_ue_cfg) { return SRSRAN_SUCCESS; } void upd_user(uint16_t new_rnti, uint16_t old_rnti) {} void set_activity_user(uint16_t rnti) {} bool is_paging_opportunity(uint32_t tti, uint32_t* payload_len) { return false; } @@ -130,4 +130,4 @@ protected: } // namespace srsenb -#endif // SRSLTE_SCHED_TEST_COMMON_H +#endif // SRSRAN_SCHED_TEST_COMMON_H diff --git a/srsenb/test/mac/sched_test_rand.cc b/srsenb/test/mac/sched_test_rand.cc index 266a470d4..a09ec74e0 100644 --- a/srsenb/test/mac/sched_test_rand.cc +++ b/srsenb/test/mac/sched_test_rand.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -19,15 +19,15 @@ #include #include -#include "srslte/interfaces/sched_interface.h" -#include "srslte/phy/utils/debug.h" +#include "srsran/interfaces/sched_interface.h" +#include "srsran/phy/utils/debug.h" #include "sched_common_test_suite.h" #include "sched_test_common.h" #include "sched_test_utils.h" -#include "srslte/common/test_common.h" +#include "srsran/common/test_common.h" -using srslte::tti_point; +using srsran::tti_point; uint32_t seed = std::chrono::system_clock::now().time_since_epoch().count(); @@ -49,7 +49,7 @@ ue_stats_t ue_tot_stats; class sched_diagnostic_printer { public: - explicit sched_diagnostic_printer(srslte::log_sink_spy& s) : s(s) {} + explicit sched_diagnostic_printer(srsran::log_sink_spy& s) : s(s) {} ~sched_diagnostic_printer() { @@ -75,7 +75,7 @@ public: } private: - srslte::log_sink_spy& s; + srsran::log_sink_spy& s; }; /******************* @@ -141,18 +141,18 @@ int sched_tester::process_results() srsenb::sf_output_res_t sf_out{sched_cell_params, tti_rx, tti_info.ul_sched_result, tti_info.dl_sched_result}; // Common tests - TESTASSERT(test_pdcch_collisions(sf_out, CARRIER_IDX, &cc_result->pdcch_mask) == SRSLTE_SUCCESS); - TESTASSERT(test_dci_content_common(sf_out, CARRIER_IDX) == SRSLTE_SUCCESS); - TESTASSERT(test_sib_scheduling(sf_out, CARRIER_IDX) == SRSLTE_SUCCESS); - TESTASSERT(test_pusch_collisions(sf_out, CARRIER_IDX, &cc_result->ul_mask) == SRSLTE_SUCCESS); - TESTASSERT(test_pdsch_collisions(sf_out, CARRIER_IDX, &cc_result->dl_mask) == SRSLTE_SUCCESS); + TESTASSERT(test_pdcch_collisions(sf_out, CARRIER_IDX, &cc_result->pdcch_mask) == SRSRAN_SUCCESS); + TESTASSERT(test_dci_content_common(sf_out, CARRIER_IDX) == SRSRAN_SUCCESS); + TESTASSERT(test_sib_scheduling(sf_out, CARRIER_IDX) == SRSRAN_SUCCESS); + TESTASSERT(test_pusch_collisions(sf_out, CARRIER_IDX, &cc_result->ul_mask) == SRSRAN_SUCCESS); + TESTASSERT(test_pdsch_collisions(sf_out, CARRIER_IDX, &cc_result->dl_mask) == SRSRAN_SUCCESS); // UE dedicated tests - TESTASSERT(run_ue_ded_tests_and_update_ctxt(sf_out) == SRSLTE_SUCCESS); - TESTASSERT(test_harqs() == SRSLTE_SUCCESS); - TESTASSERT(update_ue_stats() == SRSLTE_SUCCESS); + TESTASSERT(run_ue_ded_tests_and_update_ctxt(sf_out) == SRSRAN_SUCCESS); + TESTASSERT(test_harqs() == SRSRAN_SUCCESS); + TESTASSERT(update_ue_stats() == SRSRAN_SUCCESS); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int sched_tester::test_harqs() @@ -192,7 +192,7 @@ int sched_tester::test_harqs() } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int sched_tester::update_ue_stats() @@ -201,7 +201,7 @@ int sched_tester::update_ue_stats() for (uint32_t i = 0; i < tti_info.ul_sched_result[CARRIER_IDX].pusch.size(); ++i) { const auto& pusch = tti_info.ul_sched_result[CARRIER_IDX].pusch[i]; uint32_t L, RBstart; - srslte_ra_type2_from_riv(pusch.dci.type2_alloc.riv, + srsran_ra_type2_from_riv(pusch.dci.type2_alloc.riv, &L, &RBstart, sched_cell_params[CARRIER_IDX].cfg.cell.nof_prb, @@ -213,12 +213,12 @@ int sched_tester::update_ue_stats() } // update ue stats with number of DL RB allocations - srslte::bounded_bitset<100, true> alloc_mask(sched_cell_params[CARRIER_IDX].cfg.cell.nof_prb); + srsran::bounded_bitset<100, true> alloc_mask(sched_cell_params[CARRIER_IDX].cfg.cell.nof_prb); for (uint32_t i = 0; i < tti_info.dl_sched_result[CARRIER_IDX].data.size(); ++i) { auto& data = tti_info.dl_sched_result[CARRIER_IDX].data[i]; TESTASSERT(srsenb::extract_dl_prbmask(sched_cell_params[CARRIER_IDX].cfg.cell, tti_info.dl_sched_result[CARRIER_IDX].data[i].dci, - alloc_mask) == SRSLTE_SUCCESS); + alloc_mask) == SRSRAN_SUCCESS); ue_stats[data.dci.rnti].nof_dl_rbs += alloc_mask.count(); ue_stats[data.dci.rnti].nof_dl_bytes += data.tbs[0] + data.tbs[1]; ue_tot_stats.nof_dl_rbs += alloc_mask.count(); @@ -230,7 +230,7 @@ int sched_tester::update_ue_stats() } ue_tot_stats.nof_ttis++; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_scheduler_rand(sched_sim_events sim) @@ -241,8 +241,8 @@ int test_scheduler_rand(sched_sim_events sim) tester.sim_cfg(std::move(sim.sim_args)); - TESTASSERT(tester.test_next_ttis(sim.tti_events) == SRSLTE_SUCCESS); - return SRSLTE_SUCCESS; + TESTASSERT(tester.test_next_ttis(sim.tti_events) == SRSRAN_SUCCESS); + return SRSRAN_SUCCESS; } template @@ -310,7 +310,7 @@ sched_sim_events rand_sim_params(uint32_t nof_ttis) // may add new user (For now, we only support one UE per PRACH) bool is_prach_tti = - srslte_prach_tti_opportunity_config_fdd(sim_gen.sim_args.cell_cfg[CARRIER_IDX].prach_config, tti, -1); + srsran_prach_tti_opportunity_config_fdd(sim_gen.sim_args.cell_cfg[CARRIER_IDX].prach_config, tti, -1); if (is_prach_tti and generator.current_users.size() < max_nof_users and srsenb::randf() < P_prach) { generator.add_new_default_user(connection_dur_dist(srsenb::get_rand_gen()), sim_gen.sim_args.default_ue_sim_cfg); } @@ -330,14 +330,14 @@ int main() // Setup the log spy to intercept error and warning log entries. if (!srslog::install_custom_sink( - srslte::log_sink_spy::name(), - std::unique_ptr(new srslte::log_sink_spy(srslog::get_default_log_formatter())))) { - return SRSLTE_ERROR; + srsran::log_sink_spy::name(), + std::unique_ptr(new srsran::log_sink_spy(srslog::get_default_log_formatter())))) { + return SRSRAN_ERROR; } - auto* spy = static_cast(srslog::find_sink(srslte::log_sink_spy::name())); + auto* spy = static_cast(srslog::find_sink(srsran::log_sink_spy::name())); if (!spy) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } auto& mac_log = srslog::fetch_basic_logger("MAC"); @@ -354,7 +354,7 @@ int main() for (uint32_t n = 0; n < N_runs; ++n) { printf("Sim run number: %u\n", n + 1); sched_sim_events sim = rand_sim_params(nof_ttis); - TESTASSERT(test_scheduler_rand(std::move(sim)) == SRSLTE_SUCCESS); + TESTASSERT(test_scheduler_rand(std::move(sim)) == SRSRAN_SUCCESS); } return 0; diff --git a/srsenb/test/mac/sched_test_utils.h b/srsenb/test/mac/sched_test_utils.h index e9162a87c..6f812e7c4 100644 --- a/srsenb/test/mac/sched_test_utils.h +++ b/srsenb/test/mac/sched_test_utils.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,13 +10,13 @@ * */ -#ifndef SRSLTE_SCHED_TEST_UTILS_H -#define SRSLTE_SCHED_TEST_UTILS_H +#ifndef SRSRAN_SCHED_TEST_UTILS_H +#define SRSRAN_SCHED_TEST_UTILS_H #include "srsenb/hdr/stack/mac/sched.h" #include "srsenb/hdr/stack/upper/common_enb.h" -#include "srslte/common/test_common.h" -#include "srslte/interfaces/sched_interface.h" +#include "srsran/common/test_common.h" +#include "srsran/interfaces/sched_interface.h" #include #include #include @@ -28,15 +28,15 @@ inline srsenb::sched_interface::cell_cfg_t generate_default_cell_cfg(uint32_t nof_prb) { srsenb::sched_interface::cell_cfg_t cell_cfg = {}; - srslte_cell_t& cell_cfg_phy = cell_cfg.cell; + srsran_cell_t& cell_cfg_phy = cell_cfg.cell; /* Set PHY cell configuration */ cell_cfg_phy.id = 1; - cell_cfg_phy.cp = SRSLTE_CP_NORM; + cell_cfg_phy.cp = SRSRAN_CP_NORM; cell_cfg_phy.nof_ports = 1; cell_cfg_phy.nof_prb = nof_prb; - cell_cfg_phy.phich_length = SRSLTE_PHICH_NORM; - cell_cfg_phy.phich_resources = SRSLTE_PHICH_R_1; + cell_cfg_phy.phich_length = SRSRAN_PHICH_NORM; + cell_cfg_phy.phich_resources = SRSRAN_PHICH_R_1; cell_cfg.sibs[0].len = 18; cell_cfg.sibs[0].period_rf = 8; @@ -66,7 +66,7 @@ inline srsenb::sched_interface::ue_cfg_t generate_default_ue_cfg() ue_cfg.supported_cc_list[0].aperiodic_cqi_period = 40; ue_cfg.supported_cc_list[0].enb_cc_idx = 0; ue_cfg.supported_cc_list[0].active = true; - ue_cfg.supported_cc_list[0].dl_cfg.tm = SRSLTE_TM1; + ue_cfg.supported_cc_list[0].dl_cfg.tm = SRSRAN_TM1; ue_cfg.ue_bearers[srsenb::RB_ID_SRB0].direction = srsenb::sched_interface::ue_bearer_cfg_t::BOTH; ue_cfg.ue_bearers[srsenb::RB_ID_SRB1].direction = srsenb::sched_interface::ue_bearer_cfg_t::BOTH; ue_cfg.ue_bearers[srsenb::RB_ID_SRB2].direction = srsenb::sched_interface::ue_bearer_cfg_t::BOTH; @@ -108,7 +108,7 @@ inline srsenb::sched_interface::ue_cfg_t generate_setup_ue_cfg(const srsenb::sch cfg.maxharq_tx = final_cfg.maxharq_tx; cfg.ue_bearers[srsenb::RB_ID_SRB1].direction = srsenb::sched_interface::ue_bearer_cfg_t::BOTH; - cfg.supported_cc_list[0].dl_cfg.tm = SRSLTE_TM1; + cfg.supported_cc_list[0].dl_cfg.tm = SRSRAN_TM1; cfg.continuous_pusch = final_cfg.continuous_pusch; cfg.supported_cc_list[0].dl_cfg.cqi_report = final_cfg.supported_cc_list[0].dl_cfg.cqi_report; @@ -231,7 +231,7 @@ struct sched_sim_event_generator { user->buffer_ev.reset(new tti_ev::user_buffer_ev{}); } user->buffer_ev->dl_data = new_data; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int add_ul_data(uint16_t rnti, uint32_t new_data) @@ -242,7 +242,7 @@ struct sched_sim_event_generator { user->buffer_ev.reset(new tti_ev::user_buffer_ev{}); } user->buffer_ev->sr_data = new_data; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } tti_ev::user_cfg_ev* user_reconf(uint16_t rnti) @@ -302,4 +302,4 @@ private: } }; -#endif // SRSLTE_SCHED_TEST_UTILS_H +#endif // SRSRAN_SCHED_TEST_UTILS_H diff --git a/srsenb/test/mac/sched_tpc_test.cc b/srsenb/test/mac/sched_tpc_test.cc index b9114918c..014b5e863 100644 --- a/srsenb/test/mac/sched_tpc_test.cc +++ b/srsenb/test/mac/sched_tpc_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,7 +11,7 @@ */ #include "srsenb/hdr/stack/mac/sched_ue_ctrl/tpc.h" -#include "srslte/common/test_common.h" +#include "srsran/common/test_common.h" namespace srsenb { @@ -66,7 +66,7 @@ int test_finite_target_snr() TESTASSERT(sum_pucch > 0 and sum_pucch <= -snr_diff); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_undefined_target_snr() @@ -138,7 +138,7 @@ int test_undefined_target_snr() TESTASSERT(sum_pusch <= 0 and sum_pusch >= -1); TESTASSERT(sum_pucch <= 0 and sum_pucch >= -1); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } } // namespace srsenb diff --git a/srsenb/test/mac/sched_ue_ded_test_suite.cc b/srsenb/test/mac/sched_ue_ded_test_suite.cc index 571d038e6..526a73ec3 100644 --- a/srsenb/test/mac/sched_ue_ded_test_suite.cc +++ b/srsenb/test/mac/sched_ue_ded_test_suite.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,10 +11,10 @@ */ #include "sched_ue_ded_test_suite.h" -#include "lib/include/srslte/mac/pdu.h" +#include "lib/include/srsran/mac/pdu.h" #include "srsenb/hdr/stack/mac/sched_helpers.h" #include "srsenb/hdr/stack/mac/sched_phy_ch/sf_cch_allocator.h" -#include "srslte/common/test_common.h" +#include "srsran/common/test_common.h" namespace srsenb { @@ -94,16 +94,16 @@ int test_pdsch_grant(const sim_enb_ctxt_t& enb_ctxt, // TEST: max coderate is not exceeded if (h.nof_txs == 0 or h.ndi != pdsch.dci.tb[0].ndi) { // it is newtx - srslte_pdsch_grant_t grant = {}; - srslte_dl_sf_cfg_t dl_sf = {}; + srsran_pdsch_grant_t grant = {}; + srsran_dl_sf_cfg_t dl_sf = {}; dl_sf.cfi = sf_out.dl_cc_result[enb_cc_idx].cfi; dl_sf.tti = to_tx_dl(tti_rx).to_uint(); - srslte_ra_dl_grant_to_grant_prb_allocation(&pdsch.dci, &grant, cell_params.nof_prb()); - uint32_t nof_re = srslte_ra_dl_grant_nof_re(&cell_params.cfg.cell, &dl_sf, &grant); - float coderate = srslte_coderate(pdsch.tbs[0] * 8, nof_re); - srslte_mod_t mod = srslte_ra_dl_mod_from_mcs(pdsch.dci.tb[0].mcs_idx, ue_ctxt.ue_cfg.use_tbs_index_alt); + srsran_ra_dl_grant_to_grant_prb_allocation(&pdsch.dci, &grant, cell_params.nof_prb()); + uint32_t nof_re = srsran_ra_dl_grant_nof_re(&cell_params.cfg.cell, &dl_sf, &grant); + float coderate = srsran_coderate(pdsch.tbs[0] * 8, nof_re); + srsran_mod_t mod = srsran_ra_dl_mod_from_mcs(pdsch.dci.tb[0].mcs_idx, ue_ctxt.ue_cfg.use_tbs_index_alt); uint32_t max_Qm = ue_ctxt.ue_cfg.use_tbs_index_alt ? 8 : 6; - uint32_t Qm = std::min(max_Qm, srslte_mod_bits_x_symbol(mod)); + uint32_t Qm = std::min(max_Qm, srsran_mod_bits_x_symbol(mod)); CONDERROR(coderate > 0.932f * Qm, "Max coderate was exceeded"); } @@ -113,7 +113,7 @@ int test_pdsch_grant(const sim_enb_ctxt_t& enb_ctxt, pdsch.dci.location.ncce + cell_params.cfg.n1pucch_an), "Collision detected between UE PUCCH-ACK and SR"); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_dl_sched_result(const sim_enb_ctxt_t& enb_ctxt, const sf_output_res_t& sf_out) @@ -123,10 +123,10 @@ int test_dl_sched_result(const sim_enb_ctxt_t& enb_ctxt, const sf_output_res_t& const sched_interface::dl_sched_data_t& data = sf_out.dl_cc_result[cc].data[i]; CONDERROR( enb_ctxt.ue_db.count(data.dci.rnti) == 0, "Allocated DL grant for non-existent rnti=0x%x", data.dci.rnti); - TESTASSERT(test_pdsch_grant(enb_ctxt, sf_out, cc, data) == SRSLTE_SUCCESS); + TESTASSERT(test_pdsch_grant(enb_ctxt, sf_out, cc, data) == SRSRAN_SUCCESS); } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_ul_sched_result(const sim_enb_ctxt_t& enb_ctxt, const sf_output_res_t& sf_out) @@ -221,7 +221,7 @@ int test_ul_sched_result(const sim_enb_ctxt_t& enb_ctxt, const sf_output_res_t& } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_ra(const sim_enb_ctxt_t& enb_ctxt, const sf_output_res_t& sf_out) @@ -241,8 +241,8 @@ int test_ra(const sim_enb_ctxt_t& enb_ctxt, const sf_output_res_t& sf_out) // TEST: RAR allocation uint32_t rar_win_size = enb_ctxt.cell_params[cc].cfg.prach_rar_window; - srslte::tti_interval rar_window{ue.prach_tti_rx + 3, ue.prach_tti_rx + 3 + rar_win_size}; - srslte::tti_point tti_tx_dl = to_tx_dl(sf_out.tti_rx); + srsran::tti_interval rar_window{ue.prach_tti_rx + 3, ue.prach_tti_rx + 3 + rar_win_size}; + srsran::tti_point tti_tx_dl = to_tx_dl(sf_out.tti_rx); if (not rar_window.contains(tti_tx_dl)) { CONDERROR(not ue.rar_tti_rx.is_valid() and tti_tx_dl > rar_window.stop(), @@ -270,7 +270,7 @@ int test_ra(const sim_enb_ctxt_t& enb_ctxt, const sf_output_res_t& sf_out) // TEST: Msg3 was allocated if (ue.rar_tti_rx.is_valid() and not ue.msg3_tti_rx.is_valid()) { // RAR scheduled, Msg3 not yet scheduled - srslte::tti_point expected_msg3_tti_rx = ue.rar_tti_rx + MSG3_DELAY_MS; + srsran::tti_point expected_msg3_tti_rx = ue.rar_tti_rx + MSG3_DELAY_MS; CONDERROR(expected_msg3_tti_rx < sf_out.tti_rx, "No UL msg3 alloc was made"); if (expected_msg3_tti_rx == sf_out.tti_rx) { @@ -298,10 +298,10 @@ int test_ra(const sim_enb_ctxt_t& enb_ctxt, const sf_output_res_t& sf_out) CONDERROR(to_tx_dl(sf_out.tti_rx) < to_tx_ul(ue.msg3_tti_rx), "Msg4 cannot be scheduled without Msg3 being tx"); for (uint32_t j = 0; j < dl_cc_res.data[i].nof_pdu_elems[0]; ++j) { - if (dl_cc_res.data[i].pdu[0][j].lcid == (uint32_t)srslte::dl_sch_lcid::CON_RES_ID) { + if (dl_cc_res.data[i].pdu[0][j].lcid == (uint32_t)srsran::dl_sch_lcid::CON_RES_ID) { // ConRes found - CONDERROR(dl_cc_res.data[i].dci.format != SRSLTE_DCI_FORMAT1 and - dl_cc_res.data[i].dci.format != SRSLTE_DCI_FORMAT1A, + CONDERROR(dl_cc_res.data[i].dci.format != SRSRAN_DCI_FORMAT1 and + dl_cc_res.data[i].dci.format != SRSRAN_DCI_FORMAT1A, "ConRes must be format1/1a"); msg4_count++; } @@ -317,7 +317,7 @@ int test_ra(const sim_enb_ctxt_t& enb_ctxt, const sf_output_res_t& sf_out) for (uint32_t i = 0; i < ul_cc_res.pusch.size(); ++i) { if (ul_cc_res.pusch[i].dci.rnti == rnti) { CONDERROR(not ue.rar_tti_rx.is_valid(), "No UL allocs before RAR allowed"); - srslte::tti_point expected_msg3_tti = ue.rar_tti_rx + MSG3_DELAY_MS; + srsran::tti_point expected_msg3_tti = ue.rar_tti_rx + MSG3_DELAY_MS; CONDERROR(expected_msg3_tti > sf_out.tti_rx, "No UL allocs before Msg3 is scheduled"); if (expected_msg3_tti < sf_out.tti_rx) { bool msg3_retx = @@ -352,10 +352,10 @@ int test_ra(const sim_enb_ctxt_t& enb_ctxt, const sf_output_res_t& sf_out) } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -bool is_in_measgap(srslte::tti_point tti, uint32_t period, uint32_t offset) +bool is_in_measgap(srsran::tti_point tti, uint32_t period, uint32_t offset) { uint32_t T = period / 10; return (tti.sfn() % T == offset / 10) and (tti.sf_idx() == offset % 10); @@ -370,7 +370,7 @@ int test_meas_gaps(const sim_enb_ctxt_t& enb_ctxt, const sf_output_res_t& sf_out const auto& ue = *ue_pair.second; uint16_t rnti = ue.rnti; uint32_t ue_cc_idx = ue.enb_to_ue_cc_idx(cc); - srslte::tti_point tti_tx_ul = to_tx_ul(sf_out.tti_rx), tti_tx_dl = to_tx_dl(sf_out.tti_rx), + srsran::tti_point tti_tx_ul = to_tx_ul(sf_out.tti_rx), tti_tx_dl = to_tx_dl(sf_out.tti_rx), tti_tx_dl_ack = to_tx_dl_ack(sf_out.tti_rx), tti_tx_phich = to_tx_ul_ack(sf_out.tti_rx); if (ue_cc_idx != 0 or ue.ue_cfg.measgap_period == 0) { @@ -389,20 +389,20 @@ int test_meas_gaps(const sim_enb_ctxt_t& enb_ctxt, const sf_output_res_t& sf_out } } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_all_ues(const sim_enb_ctxt_t& enb_ctxt, const sf_output_res_t& sf_out) { - TESTASSERT(test_dl_sched_result(enb_ctxt, sf_out) == SRSLTE_SUCCESS); + TESTASSERT(test_dl_sched_result(enb_ctxt, sf_out) == SRSRAN_SUCCESS); - TESTASSERT(test_ul_sched_result(enb_ctxt, sf_out) == SRSLTE_SUCCESS); + TESTASSERT(test_ul_sched_result(enb_ctxt, sf_out) == SRSRAN_SUCCESS); - TESTASSERT(test_ra(enb_ctxt, sf_out) == SRSLTE_SUCCESS); + TESTASSERT(test_ra(enb_ctxt, sf_out) == SRSRAN_SUCCESS); - TESTASSERT(test_meas_gaps(enb_ctxt, sf_out) == SRSLTE_SUCCESS); + TESTASSERT(test_meas_gaps(enb_ctxt, sf_out) == SRSRAN_SUCCESS); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } } // namespace srsenb diff --git a/srsenb/test/mac/sched_ue_ded_test_suite.h b/srsenb/test/mac/sched_ue_ded_test_suite.h index 3fd7dac4a..758ba0d54 100644 --- a/srsenb/test/mac/sched_ue_ded_test_suite.h +++ b/srsenb/test/mac/sched_ue_ded_test_suite.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,8 +10,8 @@ * */ -#ifndef SRSLTE_SCHED_UE_DED_TEST_SUITE_H -#define SRSLTE_SCHED_UE_DED_TEST_SUITE_H +#ifndef SRSRAN_SCHED_UE_DED_TEST_SUITE_H +#define SRSRAN_SCHED_UE_DED_TEST_SUITE_H #include "sched_common_test_suite.h" #include "sched_sim_ue.h" @@ -67,4 +67,4 @@ int test_all_ues(const sim_enb_ctxt_t& enb_ctxt, const sf_output_res_t& sf_out); } // namespace srsenb -#endif // SRSLTE_SCHED_UE_DED_TEST_SUITE_H +#endif // SRSRAN_SCHED_UE_DED_TEST_SUITE_H diff --git a/srsenb/test/phy/CMakeLists.txt b/srsenb/test/phy/CMakeLists.txt index e106f9312..383a9e00f 100644 --- a/srsenb/test/phy/CMakeLists.txt +++ b/srsenb/test/phy/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -11,7 +11,7 @@ set(CTEST_LABELS "srsenb;phy") add_executable(enb_phy_test enb_phy_test.cc) target_link_libraries(enb_phy_test srsenb_phy - srslte_phy + srsran_phy rrc_asn1 ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES}) diff --git a/srsenb/test/phy/enb_phy_test.cc b/srsenb/test/phy/enb_phy_test.cc index 156d66e43..75a6b8366 100644 --- a/srsenb/test/phy/enb_phy_test.cc +++ b/srsenb/test/phy/enb_phy_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,23 +10,23 @@ * */ -#include "srslte/common/threads.h" -#include "srslte/phy/common/phy_common.h" -#include "srslte/phy/utils/random.h" -#include "srslte/srslog/srslog.h" +#include "srsran/common/threads.h" +#include "srsran/phy/common/phy_common.h" +#include "srsran/phy/utils/random.h" +#include "srsran/srslog/srslog.h" #include #include #include #include #include #include -#include -#include -#include +#include +#include +#include static inline bool dl_ack_value(uint32_t ue_cc_idx, uint32_t tti) { - return (tti % SRSLTE_MAX_CARRIERS) != ue_cc_idx; + return (tti % SRSRAN_MAX_CARRIERS) != ue_cc_idx; } #define CALLBACK(NAME) \ @@ -64,15 +64,15 @@ private: received_##NAME = true; \ } -class dummy_radio final : public srslte::radio_interface_phy +class dummy_radio final : public srsran::radio_interface_phy { private: std::mutex mutex; std::condition_variable cvar; srslog::basic_logger& logger; - std::vector ringbuffers_tx; - std::vector ringbuffers_rx; - srslte::rf_timestamp_t ts_rx = {}; + std::vector ringbuffers_tx; + std::vector ringbuffers_rx; + srsran::rf_timestamp_t ts_rx = {}; double rx_srate = 0.0; bool running = true; @@ -107,12 +107,12 @@ public: // Allocate receive ring buffer for (uint32_t i = 0; i < nof_channels; i++) { - auto* rb = (srslte_ringbuffer_t*)srslte_vec_malloc(sizeof(srslte_ringbuffer_t)); + auto* rb = (srsran_ringbuffer_t*)srsran_vec_malloc(sizeof(srsran_ringbuffer_t)); if (not rb) { ERROR("Allocating ring buffer"); } - if (srslte_ringbuffer_init(rb, SRSLTE_SF_LEN_PRB(nof_prb) * SRSLTE_NOF_SF_X_FRAME * (uint32_t)sizeof(cf_t))) { + if (srsran_ringbuffer_init(rb, SRSRAN_SF_LEN_PRB(nof_prb) * SRSRAN_NOF_SF_X_FRAME * (uint32_t)sizeof(cf_t))) { ERROR("Initiating ring buffer"); } @@ -121,12 +121,12 @@ public: // Allocate transmit ring buffer for (uint32_t i = 0; i < nof_channels; i++) { - auto* rb = (srslte_ringbuffer_t*)srslte_vec_malloc(sizeof(srslte_ringbuffer_t)); + auto* rb = (srsran_ringbuffer_t*)srsran_vec_malloc(sizeof(srsran_ringbuffer_t)); if (not rb) { ERROR("Allocating ring buffer"); } - if (srslte_ringbuffer_init(rb, SRSLTE_SF_LEN_PRB(nof_prb) * SRSLTE_NOF_SF_X_FRAME * (uint32_t)sizeof(cf_t))) { + if (srsran_ringbuffer_init(rb, SRSRAN_SF_LEN_PRB(nof_prb) * SRSRAN_NOF_SF_X_FRAME * (uint32_t)sizeof(cf_t))) { ERROR("Initiating ring buffer"); } @@ -138,13 +138,13 @@ public: { for (auto& rb : ringbuffers_tx) { if (rb) { - srslte_ringbuffer_free(rb); + srsran_ringbuffer_free(rb); free(rb); } } for (auto& rb : ringbuffers_rx) { if (rb) { - srslte_ringbuffer_free(rb); + srsran_ringbuffer_free(rb); free(rb); } } @@ -154,15 +154,15 @@ public: int read_tx(std::vector& buffers, uint32_t nof_samples) { - int err = SRSLTE_SUCCESS; + int err = SRSRAN_SUCCESS; uint32_t nbytes = static_cast(sizeof(cf_t)) * nof_samples; logger.debug("read_tx %d", nof_samples); for (uint32_t i = 0; i < ringbuffers_tx.size() and i < buffers.size(); i++) { do { - err = srslte_ringbuffer_read_timed(ringbuffers_tx[i], buffers[i], nbytes, 1000); - } while (err < SRSLTE_SUCCESS and running); + err = srsran_ringbuffer_read_timed(ringbuffers_tx[i], buffers[i], nbytes, 1000); + } while (err < SRSRAN_SUCCESS and running); } return err; @@ -175,13 +175,13 @@ public: logger.debug("write_rx %d", nof_samples); for (uint32_t i = 0; i < ringbuffers_rx.size() and i < buffers.size(); i++) { - srslte_ringbuffer_write(ringbuffers_rx[i], buffers[i], nbytes); + srsran_ringbuffer_write(ringbuffers_rx[i], buffers[i], nbytes); } } - bool tx(srslte::rf_buffer_interface& buffer, const srslte::rf_timestamp_interface& tx_time) override + bool tx(srsran::rf_buffer_interface& buffer, const srsran::rf_timestamp_interface& tx_time) override { - int err = SRSLTE_SUCCESS; + int err = SRSRAN_SUCCESS; if (not running) { return true; @@ -193,24 +193,24 @@ public: logger.debug("tx %d", buffer.get_nof_samples()); // Write ring buffer - for (uint32_t i = 0; i < ringbuffers_tx.size() and err >= SRSLTE_SUCCESS; i++) { - err = srslte_ringbuffer_write(ringbuffers_tx[i], buffer.get(i), nbytes); + for (uint32_t i = 0; i < ringbuffers_tx.size() and err >= SRSRAN_SUCCESS; i++) { + err = srsran_ringbuffer_write(ringbuffers_tx[i], buffer.get(i), nbytes); } // Notify call notify_tx(); - // Return True if err >= SRSLTE_SUCCESS - return err >= SRSLTE_SUCCESS; + // Return True if err >= SRSRAN_SUCCESS + return err >= SRSRAN_SUCCESS; } void tx_end() override {} - bool rx_now(srslte::rf_buffer_interface& buffer, srslte::rf_timestamp_interface& rxd_time) override + bool rx_now(srsran::rf_buffer_interface& buffer, srsran::rf_timestamp_interface& rxd_time) override { - int err = SRSLTE_SUCCESS; + int err = SRSRAN_SUCCESS; if (not running) { for (uint32_t i = 0; i < buffer.size(); i++) { - srslte_vec_cf_zero(buffer.get(i), buffer.get_nof_samples()); + srsran_vec_cf_zero(buffer.get(i), buffer.get_nof_samples()); } return true; } @@ -221,10 +221,10 @@ public: uint32_t nbytes = static_cast(sizeof(cf_t)) * buffer.get_nof_samples(); // Write ring buffer - for (uint32_t i = 0; i < ringbuffers_rx.size() and err >= SRSLTE_SUCCESS; i++) { + for (uint32_t i = 0; i < ringbuffers_rx.size() and err >= SRSRAN_SUCCESS; i++) { do { - err = srslte_ringbuffer_read_timed(ringbuffers_rx[i], buffer.get(i), nbytes, 1000); - } while (err < SRSLTE_SUCCESS and running); + err = srsran_ringbuffer_read_timed(ringbuffers_rx[i], buffer.get(i), nbytes, 1000); + } while (err < SRSRAN_SUCCESS and running); } // Copy new timestamp @@ -238,8 +238,8 @@ public: // Notify Rx notify_rx_now(); - // Return True if err >= SRSLTE_SUCCESS - return err >= SRSLTE_SUCCESS; + // Return True if err >= SRSRAN_SUCCESS + return err >= SRSRAN_SUCCESS; } void release_freq(const uint32_t& carrier_idx) override{}; void set_tx_freq(const uint32_t& channel_idx, const double& freq) override {} @@ -256,7 +256,7 @@ public: bool get_is_start_of_burst() override { return false; } bool is_init() override { return false; } void reset() override {} - srslte_rf_info_t* get_info() override { return nullptr; } + srsran_rf_info_t* get_info() override { return nullptr; } }; typedef std::unique_ptr unique_dummy_radio_t; @@ -273,11 +273,11 @@ private: std::mutex mutex; std::condition_variable cvar; srslog::basic_logger& logger; - srslte_softbuffer_tx_t softbuffer_tx = {}; - srslte_softbuffer_rx_t softbuffer_rx[SRSLTE_MAX_CARRIERS][SRSLTE_FDD_NOF_HARQ] = {}; + srsran_softbuffer_tx_t softbuffer_tx = {}; + srsran_softbuffer_rx_t softbuffer_rx[SRSRAN_MAX_CARRIERS][SRSRAN_FDD_NOF_HARQ] = {}; uint8_t* data = nullptr; uint16_t ue_rnti = 0; - srslte_random_t random_gen = nullptr; + srsran_random_t random_gen = nullptr; CALLBACK(sr_detected); CALLBACK(rach_detected); @@ -326,8 +326,8 @@ private: std::queue tti_cqi_info_queue; std::vector active_cell_list; - uint32_t nof_locations[SRSLTE_NOF_SF_X_FRAME] = {}; - srslte_dci_location_t dci_locations[SRSLTE_NOF_SF_X_FRAME][SRSLTE_MAX_CANDIDATES_UE] = {}; + uint32_t nof_locations[SRSRAN_NOF_SF_X_FRAME] = {}; + srsran_dci_location_t dci_locations[SRSRAN_NOF_SF_X_FRAME][SRSRAN_MAX_CANDIDATES_UE] = {}; uint32_t ul_riv = 0; public: @@ -337,72 +337,72 @@ public: uint16_t rnti_) : logger(srslog::fetch_basic_logger("STACK", false)), ue_rnti(rnti_), - random_gen(srslte_random_init(rnti_)), + random_gen(srsran_random_init(rnti_)), phy_cell_cfg(phy_cfg_.phy_cell_cfg), phy_rrc(phy_rrc_) { logger.set_level(srslog::str_to_basic_level(log_level)); - srslte_softbuffer_tx_init(&softbuffer_tx, SRSLTE_MAX_PRB); + srsran_softbuffer_tx_init(&softbuffer_tx, SRSRAN_MAX_PRB); for (uint32_t i = 0; i < phy_rrc.size(); i++) { for (auto& sb : softbuffer_rx[i]) { - srslte_softbuffer_rx_init(&sb, SRSLTE_MAX_PRB); + srsran_softbuffer_rx_init(&sb, SRSRAN_MAX_PRB); } } - srslte_pdcch_t pdcch = {}; - srslte_regs_t regs = {}; - srslte_regs_init(®s, phy_cell_cfg[0].cell); - srslte_pdcch_init_enb(&pdcch, phy_cell_cfg[0].cell.nof_prb); - srslte_pdcch_set_cell(&pdcch, ®s, phy_cell_cfg[0].cell); - for (uint32_t i = 0; i < SRSLTE_NOF_SF_X_FRAME; i++) { - srslte_dl_sf_cfg_t sf_cfg_dl; + srsran_pdcch_t pdcch = {}; + srsran_regs_t regs = {}; + srsran_regs_init(®s, phy_cell_cfg[0].cell); + srsran_pdcch_init_enb(&pdcch, phy_cell_cfg[0].cell.nof_prb); + srsran_pdcch_set_cell(&pdcch, ®s, phy_cell_cfg[0].cell); + for (uint32_t i = 0; i < SRSRAN_NOF_SF_X_FRAME; i++) { + srsran_dl_sf_cfg_t sf_cfg_dl; ZERO_OBJECT(sf_cfg_dl); sf_cfg_dl.tti = i; sf_cfg_dl.cfi = cfi; - sf_cfg_dl.sf_type = SRSLTE_SF_NORM; + sf_cfg_dl.sf_type = SRSRAN_SF_NORM; uint32_t _nof_locations = {}; - srslte_dci_location_t _dci_locations[SRSLTE_MAX_CANDIDATES_UE] = {}; - _nof_locations = srslte_pdcch_ue_locations(&pdcch, &sf_cfg_dl, _dci_locations, SRSLTE_MAX_CANDIDATES_UE, ue_rnti); + srsran_dci_location_t _dci_locations[SRSRAN_MAX_CANDIDATES_UE] = {}; + _nof_locations = srsran_pdcch_ue_locations(&pdcch, &sf_cfg_dl, _dci_locations, SRSRAN_MAX_CANDIDATES_UE, ue_rnti); // Take L == 0 aggregation levels - for (uint32_t j = 0; j < _nof_locations && nof_locations[i] < SRSLTE_MAX_CANDIDATES_UE; j++) { + for (uint32_t j = 0; j < _nof_locations && nof_locations[i] < SRSRAN_MAX_CANDIDATES_UE; j++) { if (_dci_locations[j].L == 0) { dci_locations[i][nof_locations[i]] = _dci_locations[j]; nof_locations[i]++; } } } - srslte_pdcch_free(&pdcch); - srslte_regs_free(®s); + srsran_pdcch_free(&pdcch); + srsran_regs_free(®s); // Find a valid UL DCI RIV uint32_t L_prb = phy_cell_cfg[0].cell.nof_prb - 2; do { - if (srslte_dft_precoding_valid_prb(L_prb)) { - ul_riv = srslte_ra_type2_to_riv(L_prb, 1, phy_cell_cfg[0].cell.nof_prb); + if (srsran_dft_precoding_valid_prb(L_prb)) { + ul_riv = srsran_ra_type2_to_riv(L_prb, 1, phy_cell_cfg[0].cell.nof_prb); } else { L_prb--; } } while (ul_riv == 0); - data = srslte_vec_u8_malloc(150000); + data = srsran_vec_u8_malloc(150000); memset(data, 0, 150000); } ~dummy_stack() { - srslte_softbuffer_tx_free(&softbuffer_tx); + srsran_softbuffer_tx_free(&softbuffer_tx); for (auto& v : softbuffer_rx) { for (auto& sb : v) { - srslte_softbuffer_rx_free(&sb); + srsran_softbuffer_rx_free(&sb); } } if (data) { free(data); } - srslte_random_free(random_gen); + srsran_random_free(random_gen); } void set_active_cell_list(std::vector& active_cell_list_) { active_cell_list = active_cell_list_; } @@ -417,7 +417,7 @@ public: logger.info("Received SR tti=%d; rnti=0x%x", tti, rnti); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } void rach_detected(uint32_t tti, uint32_t primary_cc_idx, uint32_t preamble_idx, uint32_t time_adv) override { @@ -451,7 +451,7 @@ public: logger.info("Received CQI tti=%d; rnti=0x%x; cc_idx=%d; cqi=%d;", tti, rnti, cc_idx, cqi_value); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int snr_info(uint32_t tti, uint16_t rnti, uint32_t cc_idx, float snr_db, ul_channel_t ch) override { @@ -516,13 +516,13 @@ public: dl_sched.cfi = cfi; // Default TB scheduling - bool sched_tb[SRSLTE_MAX_TB] = {}; + bool sched_tb[SRSRAN_MAX_TB] = {}; - sched_tb[0] = srslte_random_bool(random_gen, prob_dl_grant); + sched_tb[0] = srsran_random_bool(random_gen, prob_dl_grant); // Schedule second TB for TM3 or TM4 - if (phy_rrc[ue_cc_idx].phy_cfg.dl_cfg.tm == SRSLTE_TM3 or phy_rrc[ue_cc_idx].phy_cfg.dl_cfg.tm == SRSLTE_TM4) { - sched_tb[1] = srslte_random_bool(random_gen, prob_dl_grant); + if (phy_rrc[ue_cc_idx].phy_cfg.dl_cfg.tm == SRSRAN_TM3 or phy_rrc[ue_cc_idx].phy_cfg.dl_cfg.tm == SRSRAN_TM4) { + sched_tb[1] = srsran_random_bool(random_gen, prob_dl_grant); } // Random decision on whether transmit or not @@ -532,12 +532,12 @@ public: sched &= (ue_rnti != 0); // Number of locations needs to be more than 2 - sched &= (nof_locations[tti % SRSLTE_NOF_SF_X_FRAME] > 1); + sched &= (nof_locations[tti % SRSRAN_NOF_SF_X_FRAME] > 1); // Schedule grant if (sched) { - uint32_t location_idx = tti % nof_locations[tti % SRSLTE_NOF_SF_X_FRAME]; - srslte_dci_location_t location = dci_locations[tti % SRSLTE_NOF_SF_X_FRAME][location_idx]; + uint32_t location_idx = tti % nof_locations[tti % SRSRAN_NOF_SF_X_FRAME]; + srsran_dci_location_t location = dci_locations[tti % SRSRAN_NOF_SF_X_FRAME][location_idx]; dl_sched.nof_grants = 1; dl_sched.pdsch[0].softbuffer_tx[0] = &softbuffer_tx; @@ -545,23 +545,23 @@ public: dl_sched.pdsch[0].dci.location = location; dl_sched.pdsch[0].dci.type0_alloc.rbg_bitmask = 0xffffffff; dl_sched.pdsch[0].dci.rnti = ue_rnti; - dl_sched.pdsch[0].dci.alloc_type = SRSLTE_RA_ALLOC_TYPE0; + dl_sched.pdsch[0].dci.alloc_type = SRSRAN_RA_ALLOC_TYPE0; dl_sched.pdsch[0].data[0] = data; dl_sched.pdsch[0].data[1] = data; - dl_sched.pdsch[0].dci.tpc_pucch = (location.ncce) % SRSLTE_PUCCH_SIZE_AN_CS; + dl_sched.pdsch[0].dci.tpc_pucch = (location.ncce) % SRSRAN_PUCCH_SIZE_AN_CS; // Set DCI format depending on the transmission mode switch (phy_rrc[0].phy_cfg.dl_cfg.tm) { default: - case SRSLTE_TM1: - case SRSLTE_TM2: - dl_sched.pdsch[0].dci.format = SRSLTE_DCI_FORMAT1; + case SRSRAN_TM1: + case SRSRAN_TM2: + dl_sched.pdsch[0].dci.format = SRSRAN_DCI_FORMAT1; break; - case SRSLTE_TM3: - dl_sched.pdsch[0].dci.format = SRSLTE_DCI_FORMAT2A; + case SRSRAN_TM3: + dl_sched.pdsch[0].dci.format = SRSRAN_DCI_FORMAT2A; break; - case SRSLTE_TM4: - dl_sched.pdsch[0].dci.format = SRSLTE_DCI_FORMAT2; + case SRSRAN_TM4: + dl_sched.pdsch[0].dci.format = SRSRAN_DCI_FORMAT2; break; } @@ -574,7 +574,7 @@ public: // Schedule TB uint32_t cw_count = 0; - for (uint32_t tb = 0; tb < SRSLTE_MAX_TB; tb++) { + for (uint32_t tb = 0; tb < SRSRAN_MAX_TB; tb++) { if (sched_tb[tb]) { logger.debug("Transmitted DL grant tti=%d; rnti=0x%x; cc=%d; tb=%d;", tti, ue_rnti, cc_idx, tb); @@ -627,7 +627,7 @@ public: } // Random decision on whether transmit or not - bool sched = srslte_random_bool(random_gen, prob_ul_grant); + bool sched = srsran_random_bool(random_gen, prob_ul_grant); sched &= (scell_idx < active_cell_list.size()); @@ -635,7 +635,7 @@ public: sched &= (ue_rnti != 0); // Number of locations needs to be more than 2 - sched &= (nof_locations[tti % SRSLTE_NOF_SF_X_FRAME] > 1); + sched &= (nof_locations[tti % SRSRAN_NOF_SF_X_FRAME] > 1); // Avoid giving grants when SR is expected sched &= (tti % 20 != 0); @@ -643,19 +643,19 @@ public: // Schedule grant if (sched) { uint32_t tti_pdcch = TTI_SUB(tti, FDD_HARQ_DELAY_DL_MS); - uint32_t location_idx = (tti_pdcch + 1) % nof_locations[tti_pdcch % SRSLTE_NOF_SF_X_FRAME]; - srslte_dci_location_t location = dci_locations[tti_pdcch % SRSLTE_NOF_SF_X_FRAME][location_idx]; + uint32_t location_idx = (tti_pdcch + 1) % nof_locations[tti_pdcch % SRSRAN_NOF_SF_X_FRAME]; + srsran_dci_location_t location = dci_locations[tti_pdcch % SRSRAN_NOF_SF_X_FRAME][location_idx]; ul_sched.nof_grants = 1; ul_sched.pusch[0] = {}; ul_sched.pusch[0].dci.rnti = ue_rnti; - ul_sched.pusch[0].dci.format = SRSLTE_DCI_FORMAT0; + ul_sched.pusch[0].dci.format = SRSRAN_DCI_FORMAT0; ul_sched.pusch[0].dci.location = location; ul_sched.pusch[0].dci.type2_alloc.riv = ul_riv; - ul_sched.pusch[0].dci.type2_alloc.n_prb1a = srslte_ra_type2_t::SRSLTE_RA_TYPE2_NPRB1A_2; - ul_sched.pusch[0].dci.type2_alloc.n_gap = srslte_ra_type2_t::SRSLTE_RA_TYPE2_NG1; - ul_sched.pusch[0].dci.type2_alloc.mode = srslte_ra_type2_t::SRSLTE_RA_TYPE2_LOC; - ul_sched.pusch[0].dci.freq_hop_fl = srslte_dci_ul_t::SRSLTE_RA_PUSCH_HOP_DISABLED; + ul_sched.pusch[0].dci.type2_alloc.n_prb1a = srsran_ra_type2_t::SRSRAN_RA_TYPE2_NPRB1A_2; + ul_sched.pusch[0].dci.type2_alloc.n_gap = srsran_ra_type2_t::SRSRAN_RA_TYPE2_NG1; + ul_sched.pusch[0].dci.type2_alloc.mode = srsran_ra_type2_t::SRSRAN_RA_TYPE2_LOC; + ul_sched.pusch[0].dci.freq_hop_fl = srsran_dci_ul_t::SRSRAN_RA_PUSCH_HOP_DISABLED; ul_sched.pusch[0].dci.tb.mcs_idx = 20; // Can't set it too high for grants with CQI and long ACK/NACK ul_sched.pusch[0].dci.tb.rv = 0; ul_sched.pusch[0].dci.tb.ndi = false; @@ -665,10 +665,10 @@ public: ul_sched.pusch[0].data = data; ul_sched.pusch[0].needs_pdcch = true; - ul_sched.pusch[0].softbuffer_rx = &softbuffer_rx[scell_idx][tti % SRSLTE_FDD_NOF_HARQ]; + ul_sched.pusch[0].softbuffer_rx = &softbuffer_rx[scell_idx][tti % SRSRAN_FDD_NOF_HARQ]; // Reset Rx softbuffer - srslte_softbuffer_rx_reset(ul_sched.pusch[0].softbuffer_rx); + srsran_softbuffer_rx_reset(ul_sched.pusch[0].softbuffer_rx); // Push grant info in queue tti_ul_info_t tti_ul_info = {}; @@ -683,7 +683,7 @@ public: } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } void set_sched_dl_tti_mask(uint8_t* tti_mask, uint32_t nof_sfs) override { notify_set_sched_dl_tti_mask(); } void tti_clock() override { notify_tti_clock(); } @@ -751,7 +751,7 @@ public: } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } }; @@ -760,16 +760,16 @@ typedef std::unique_ptr unique_dummy_stack_t; class dummy_ue { private: - std::vector ue_dl_v = {}; - std::vector ue_ul_v = {}; + std::vector ue_dl_v = {}; + std::vector ue_ul_v = {}; std::vector buffers = {}; dummy_radio* radio = nullptr; uint32_t sf_len = 0; uint32_t nof_ports = 0; uint16_t rnti = 0; - srslte_dl_sf_cfg_t sf_dl_cfg = {}; - srslte_ul_sf_cfg_t sf_ul_cfg = {}; - srslte_softbuffer_tx_t softbuffer_tx = {}; + srsran_dl_sf_cfg_t sf_dl_cfg = {}; + srsran_ul_sf_cfg_t sf_ul_cfg = {}; + srsran_softbuffer_tx_t softbuffer_tx = {}; uint8_t* tx_data = nullptr; srsenb::phy_interface_rrc_lte::phy_rrc_cfg_list_t phy_rrc_cfg = {}; srslog::basic_logger& logger; @@ -781,7 +781,7 @@ public: { // Calculate subframe length nof_ports = cell_list[0].cell.nof_ports; - sf_len = static_cast(SRSLTE_SF_LEN_PRB(cell_list[0].cell.nof_prb)); + sf_len = static_cast(SRSRAN_SF_LEN_PRB(cell_list[0].cell.nof_prb)); rnti = rnti_; logger.set_level(srslog::str_to_basic_level(log_level)); @@ -789,62 +789,62 @@ public: // Initialise one buffer per eNb for (uint32_t i = 0; i < cell_list.size() * nof_ports; i++) { // Allocate buffers - cf_t* buffer = srslte_vec_cf_malloc(sf_len); + cf_t* buffer = srsran_vec_cf_malloc(sf_len); if (not buffer) { ERROR("Allocating UE DL buffer"); } buffers.push_back(buffer); // Set buffer to zero - srslte_vec_cf_zero(buffer, sf_len); + srsran_vec_cf_zero(buffer, sf_len); } // Iterate over all cells for (uint32_t cc_idx = 0; cc_idx < (uint32_t)cell_list.size(); cc_idx++) { - const srslte_cell_t& cell = cell_list[cc_idx].cell; + const srsran_cell_t& cell = cell_list[cc_idx].cell; // Allocate UE DL - auto* ue_dl = (srslte_ue_dl_t*)srslte_vec_malloc(sizeof(srslte_ue_dl_t)); + auto* ue_dl = (srsran_ue_dl_t*)srsran_vec_malloc(sizeof(srsran_ue_dl_t)); if (not ue_dl) { ERROR("Allocatin UE DL"); } ue_dl_v.push_back(ue_dl); // Initialise UE DL - if (srslte_ue_dl_init(ue_dl, &buffers[cc_idx * nof_ports], cell.nof_prb, cell.nof_ports)) { + if (srsran_ue_dl_init(ue_dl, &buffers[cc_idx * nof_ports], cell.nof_prb, cell.nof_ports)) { ERROR("Initiating UE DL"); } // Set Cell - if (srslte_ue_dl_set_cell(ue_dl, cell)) { + if (srsran_ue_dl_set_cell(ue_dl, cell)) { ERROR("Setting UE DL cell"); } // Allocate UE UL - auto* ue_ul = (srslte_ue_ul_t*)srslte_vec_malloc(sizeof(srslte_ue_ul_t)); + auto* ue_ul = (srsran_ue_ul_t*)srsran_vec_malloc(sizeof(srsran_ue_ul_t)); if (not ue_ul) { ERROR("Allocatin UE UL"); } ue_ul_v.push_back(ue_ul); // Initialise UE UL - if (srslte_ue_ul_init(ue_ul, buffers[cc_idx * nof_ports], cell.nof_prb)) { + if (srsran_ue_ul_init(ue_ul, buffers[cc_idx * nof_ports], cell.nof_prb)) { ERROR("Setting UE UL cell"); } // Set cell - if (srslte_ue_ul_set_cell(ue_ul, cell)) { + if (srsran_ue_ul_set_cell(ue_ul, cell)) { ERROR("Setting UE DL cell"); } } // Initialise softbuffer - if (srslte_softbuffer_tx_init(&softbuffer_tx, cell_list[0].cell.nof_prb)) { + if (srsran_softbuffer_tx_init(&softbuffer_tx, cell_list[0].cell.nof_prb)) { ERROR("Initialising Tx softbuffer"); } // Initialise dummy tx data - tx_data = srslte_vec_u8_malloc(SRSENB_MAX_BUFFER_SIZE_BYTES); + tx_data = srsran_vec_u8_malloc(SRSENB_MAX_BUFFER_SIZE_BYTES); if (not tx_data) { ERROR("Allocating Tx data"); } @@ -867,13 +867,13 @@ public: { for (auto& ue_dl : ue_dl_v) { if (ue_dl) { - srslte_ue_dl_free(ue_dl); + srsran_ue_dl_free(ue_dl); free(ue_dl); } } for (auto& ue_ul : ue_ul_v) { if (ue_ul) { - srslte_ue_ul_free(ue_ul); + srsran_ue_ul_free(ue_ul); free(ue_ul); } } @@ -885,7 +885,7 @@ public: if (tx_data) { free(tx_data); } - srslte_softbuffer_tx_free(&softbuffer_tx); + srsran_softbuffer_tx_free(&softbuffer_tx); } void reconfigure(const srsenb::phy_interface_rrc_lte::phy_rrc_cfg_list_t& phy_rrc_cfg_) @@ -899,15 +899,15 @@ public: } } - int work_dl(srslte_pdsch_ack_t& pdsch_ack, srslte_uci_data_t& uci_data) + int work_dl(srsran_pdsch_ack_t& pdsch_ack, srsran_uci_data_t& uci_data) { // Read DL - TESTASSERT(radio->read_tx(buffers, sf_len) >= SRSLTE_SUCCESS); + TESTASSERT(radio->read_tx(buffers, sf_len) >= SRSRAN_SUCCESS); // Get grants DL/UL, we do not care about Decoding PDSCH for (uint32_t ue_cc_idx = 0; ue_cc_idx < phy_rrc_cfg.size(); ue_cc_idx++) { uint32_t cc_idx = phy_rrc_cfg[ue_cc_idx].enb_cc_idx; - srslte::phy_cfg_t& dedicated = phy_rrc_cfg[ue_cc_idx].phy_cfg; + srsran::phy_cfg_t& dedicated = phy_rrc_cfg[ue_cc_idx].phy_cfg; /// Set UCI configuration from PCell only if (ue_cc_idx == 0) { @@ -919,10 +919,10 @@ public: pdsch_ack.simul_cqi_ack = dedicated.ul_cfg.pucch.simul_cqi_ack; } - srslte_dci_dl_t dci_dl[SRSLTE_MAX_DCI_MSG] = {}; - srslte_ue_dl_cfg_t ue_dl_cfg = {}; + srsran_dci_dl_t dci_dl[SRSRAN_MAX_DCI_MSG] = {}; + srsran_ue_dl_cfg_t ue_dl_cfg = {}; ue_dl_cfg.cfg = dedicated.dl_cfg; - ue_dl_cfg.cfg.cqi_report.periodic_mode = SRSLTE_CQI_MODE_12; + ue_dl_cfg.cfg.cqi_report.periodic_mode = SRSRAN_CQI_MODE_12; ue_dl_cfg.cfg.pdsch.rnti = rnti; int report_ri_cc_idx = -1; @@ -930,25 +930,25 @@ public: ue_dl_cfg.last_ri = last_ri[ue_cc_idx]; } - srslte_ue_dl_decode_fft_estimate(ue_dl_v[cc_idx], &sf_dl_cfg, &ue_dl_cfg); + srsran_ue_dl_decode_fft_estimate(ue_dl_v[cc_idx], &sf_dl_cfg, &ue_dl_cfg); // Get DL Grants - int nof_dl_grants = srslte_ue_dl_find_dl_dci(ue_dl_v[cc_idx], &sf_dl_cfg, &ue_dl_cfg, rnti, dci_dl); - TESTASSERT(nof_dl_grants >= SRSLTE_SUCCESS); + int nof_dl_grants = srsran_ue_dl_find_dl_dci(ue_dl_v[cc_idx], &sf_dl_cfg, &ue_dl_cfg, rnti, dci_dl); + TESTASSERT(nof_dl_grants >= SRSRAN_SUCCESS); // Generate ACKs if (nof_dl_grants) { char str[256] = {}; - srslte_dci_dl_info(dci_dl, str, sizeof(str)); + srsran_dci_dl_info(dci_dl, str, sizeof(str)); logger.info("[DL DCI] %s", str); - if (srslte_ue_dl_dci_to_pdsch_grant( + if (srsran_ue_dl_dci_to_pdsch_grant( ue_dl_v[cc_idx], &sf_dl_cfg, &ue_dl_cfg, dci_dl, &ue_dl_cfg.cfg.pdsch.grant)) { logger.error("Converting DCI message to DL dci"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - srslte_pdsch_tx_info(&ue_dl_cfg.cfg.pdsch, str, 512); + srsran_pdsch_tx_info(&ue_dl_cfg.cfg.pdsch, str, 512); logger.info("[DL PDSCH %d] cc=%d, %s", sf_dl_cfg.tti, cc_idx, str); @@ -959,7 +959,7 @@ public: pdsch_ack.cc[ue_cc_idx].m[0].resource.grant_cc_idx = ue_cc_idx; pdsch_ack.cc[ue_cc_idx].m[0].resource.tpc_for_pucch = dci_dl->tpc_pucch; - for (uint32_t tb_idx = 0; tb_idx < SRSLTE_MAX_TB; tb_idx++) { + for (uint32_t tb_idx = 0; tb_idx < SRSRAN_MAX_TB; tb_idx++) { if (ue_dl_cfg.cfg.pdsch.grant.tb[tb_idx].enabled) { pdsch_ack.cc[ue_cc_idx].m[0].value[tb_idx] = dl_ack_value(ue_cc_idx, sf_dl_cfg.tti); } else { @@ -972,28 +972,28 @@ public: } // Generate CQI periodic if required - srslte_ue_dl_gen_cqi_periodic(ue_dl_v[cc_idx], &ue_dl_cfg, 0x0f, sf_ul_cfg.tti, &uci_data); + srsran_ue_dl_gen_cqi_periodic(ue_dl_v[cc_idx], &ue_dl_cfg, 0x0f, sf_ul_cfg.tti, &uci_data); - if (srslte_cqi_periodic_ri_send(&ue_dl_cfg.cfg.cqi_report, sf_ul_cfg.tti, ue_dl_v[cc_idx]->cell.frame_type) && + if (srsran_cqi_periodic_ri_send(&ue_dl_cfg.cfg.cqi_report, sf_ul_cfg.tti, ue_dl_v[cc_idx]->cell.frame_type) && uci_data.cfg.cqi.ri_len) { uci_data.cfg.cqi.scell_index = ue_cc_idx; } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } void fill_uci(uint32_t cc_idx, - srslte_ue_ul_cfg_t& ue_ul_cfg, - srslte_uci_data_t& uci_data, - srslte_pdsch_ack_t& pdsch_ack, - srslte_pusch_data_t& pusch_data) + srsran_ue_ul_cfg_t& ue_ul_cfg, + srsran_uci_data_t& uci_data, + srsran_pdsch_ack_t& pdsch_ack, + srsran_pusch_data_t& pusch_data) { // Generate scheduling request - srslte_ue_ul_gen_sr(&ue_ul_cfg, &sf_ul_cfg, &uci_data, (bool)(sf_ul_cfg.tti % 20 == 0)); + srsran_ue_ul_gen_sr(&ue_ul_cfg, &sf_ul_cfg, &uci_data, (bool)(sf_ul_cfg.tti % 20 == 0)); // Generate Acknowledgements - srslte_ue_dl_gen_ack(&ue_dl_v[cc_idx]->cell, &sf_dl_cfg, &pdsch_ack, &uci_data); + srsran_ue_dl_gen_ack(&ue_dl_v[cc_idx]->cell, &sf_dl_cfg, &pdsch_ack, &uci_data); if (uci_data.cfg.cqi.ri_len) { last_ri[uci_data.cfg.cqi.scell_index] = uci_data.value.ri; @@ -1005,45 +1005,45 @@ public: ue_ul_cfg.ul_cfg.pucch.uci_cfg = uci_data.cfg; } - int work_ul(srslte_pdsch_ack_t& pdsch_ack, srslte_uci_data_t& uci_data) + int work_ul(srsran_pdsch_ack_t& pdsch_ack, srsran_uci_data_t& uci_data) { bool first_pusch = true; // Zero all IQ UL buffers for (auto& buffer : buffers) { - srslte_vec_cf_zero(buffer, SRSLTE_SF_LEN_PRB(ue_ul_v[0]->cell.nof_prb)); + srsran_vec_cf_zero(buffer, SRSRAN_SF_LEN_PRB(ue_ul_v[0]->cell.nof_prb)); } for (uint32_t i = 0; i < phy_rrc_cfg.size(); i++) { - srslte_dci_ul_t dci_ul[SRSLTE_MAX_DCI_MSG] = {}; - srslte::phy_cfg_t& dedicated = phy_rrc_cfg[i].phy_cfg; + srsran_dci_ul_t dci_ul[SRSRAN_MAX_DCI_MSG] = {}; + srsran::phy_cfg_t& dedicated = phy_rrc_cfg[i].phy_cfg; uint32_t cc_idx = phy_rrc_cfg[i].enb_cc_idx; - srslte_ue_ul_cfg_t ue_ul_cfg = {}; + srsran_ue_ul_cfg_t ue_ul_cfg = {}; ue_ul_cfg.ul_cfg = dedicated.ul_cfg; ue_ul_cfg.ul_cfg.pusch.softbuffers.tx = &softbuffer_tx; ue_ul_cfg.ul_cfg.pusch.rnti = rnti; ue_ul_cfg.ul_cfg.pucch.rnti = rnti; ue_ul_cfg.cc_idx = i; // SCell index - srslte_ue_dl_cfg_t ue_dl_cfg = {}; + srsran_ue_dl_cfg_t ue_dl_cfg = {}; ue_dl_cfg.cfg = dedicated.dl_cfg; - ue_dl_cfg.cfg.cqi_report.periodic_mode = SRSLTE_CQI_MODE_12; + ue_dl_cfg.cfg.cqi_report.periodic_mode = SRSRAN_CQI_MODE_12; ue_dl_cfg.cfg.pdsch.rnti = rnti; // Get UL grants - int nof_ul_grants = srslte_ue_dl_find_ul_dci(ue_dl_v[cc_idx], &sf_dl_cfg, &ue_dl_cfg, rnti, dci_ul); - TESTASSERT(nof_ul_grants >= SRSLTE_SUCCESS); + int nof_ul_grants = srsran_ue_dl_find_ul_dci(ue_dl_v[cc_idx], &sf_dl_cfg, &ue_dl_cfg, rnti, dci_ul); + TESTASSERT(nof_ul_grants >= SRSRAN_SUCCESS); - srslte_pusch_data_t pusch_data = {}; + srsran_pusch_data_t pusch_data = {}; pusch_data.ptr = tx_data; - if (nof_ul_grants > SRSLTE_SUCCESS) { - TESTASSERT(srslte_ue_ul_dci_to_pusch_grant( + if (nof_ul_grants > SRSRAN_SUCCESS) { + TESTASSERT(srsran_ue_ul_dci_to_pusch_grant( ue_ul_v[cc_idx], &sf_ul_cfg, &ue_ul_cfg, dci_ul, &ue_ul_cfg.ul_cfg.pusch.grant) >= - SRSLTE_SUCCESS); + SRSRAN_SUCCESS); - srslte_softbuffer_tx_reset(&softbuffer_tx); + srsran_softbuffer_tx_reset(&softbuffer_tx); ue_ul_cfg.ul_cfg.pusch.softbuffers.tx = &softbuffer_tx; ue_ul_cfg.grant_available = true; @@ -1058,10 +1058,10 @@ public: } // Work UL - TESTASSERT(srslte_ue_ul_encode(ue_ul_v[cc_idx], &sf_ul_cfg, &ue_ul_cfg, &pusch_data) >= SRSLTE_SUCCESS); + TESTASSERT(srsran_ue_ul_encode(ue_ul_v[cc_idx], &sf_ul_cfg, &ue_ul_cfg, &pusch_data) >= SRSRAN_SUCCESS); char str[256] = {}; - srslte_ue_ul_info(&ue_ul_cfg, &sf_ul_cfg, &pusch_data.uci, str, sizeof(str)); + srsran_ue_ul_info(&ue_ul_cfg, &sf_ul_cfg, &pusch_data.uci, str, sizeof(str)); if (str[0]) { logger.info("[UL INFO %d] %s", i, str); } @@ -1070,23 +1070,23 @@ public: // If no PUSCH, send PUCCH if (first_pusch) { uint32_t cc_idx = phy_rrc_cfg[0].enb_cc_idx; - srslte::phy_cfg_t& dedicated = phy_rrc_cfg[0].phy_cfg; + srsran::phy_cfg_t& dedicated = phy_rrc_cfg[0].phy_cfg; - srslte_ue_ul_cfg_t ue_ul_cfg = {}; + srsran_ue_ul_cfg_t ue_ul_cfg = {}; ue_ul_cfg.ul_cfg = dedicated.ul_cfg; ue_ul_cfg.ul_cfg.pusch.softbuffers.tx = &softbuffer_tx; ue_ul_cfg.ul_cfg.pucch.rnti = rnti; ue_ul_cfg.cc_idx = 0; // SCell index - srslte_pusch_data_t pusch_data = {}; + srsran_pusch_data_t pusch_data = {}; fill_uci(cc_idx, ue_ul_cfg, uci_data, pdsch_ack, pusch_data); // Work UL PUCCH - TESTASSERT(srslte_ue_ul_encode(ue_ul_v[cc_idx], &sf_ul_cfg, &ue_ul_cfg, &pusch_data) >= SRSLTE_SUCCESS); + TESTASSERT(srsran_ue_ul_encode(ue_ul_v[cc_idx], &sf_ul_cfg, &ue_ul_cfg, &pusch_data) >= SRSRAN_SUCCESS); char str[256] = {}; - srslte_ue_ul_info(&ue_ul_cfg, &sf_ul_cfg, &pusch_data.uci, str, sizeof(str)); + srsran_ue_ul_info(&ue_ul_cfg, &sf_ul_cfg, &pusch_data.uci, str, sizeof(str)); if (str[0]) { logger.info("[UL INFO %d] %s", 0, str); } @@ -1095,28 +1095,28 @@ public: // Write eNb Rx radio->write_rx(buffers, sf_len); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int run_tti() { - srslte_uci_data_t uci_data = {}; - srslte_pdsch_ack_t pdsch_ack = {}; + srsran_uci_data_t uci_data = {}; + srsran_pdsch_ack_t pdsch_ack = {}; // Set logging TTI logger.set_context(sf_dl_cfg.tti); // Work DL - TESTASSERT(work_dl(pdsch_ack, uci_data) == SRSLTE_SUCCESS); + TESTASSERT(work_dl(pdsch_ack, uci_data) == SRSRAN_SUCCESS); // Work UL - TESTASSERT(work_ul(pdsch_ack, uci_data) == SRSLTE_SUCCESS); + TESTASSERT(work_ul(pdsch_ack, uci_data) == SRSRAN_SUCCESS); // Increment TTI sf_dl_cfg.tti = TTI_ADD(sf_dl_cfg.tti, 1); sf_ul_cfg.tti = TTI_ADD(sf_ul_cfg.tti, 1); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } }; @@ -1131,14 +1131,14 @@ public: uint16_t rnti = 0x1234; uint32_t duration = 10240; uint32_t nof_enb_cells = 1; - srslte_cell_t cell = {}; + srsran_cell_t cell = {}; std::string ue_cell_list_str = "0"; ///< First indicates PCell std::vector ue_cell_list = {0}; std::string ack_mode = "normal"; std::string log_level = "none"; uint32_t tm_u32 = 1; uint32_t period_pcell_rotate = 0; - srslte_tm_t tm = SRSLTE_TM1; + srsran_tm_t tm = SRSRAN_TM1; args_t() { cell.nof_prb = 6; @@ -1151,20 +1151,20 @@ public: switch (tm_u32) { case 2: cell.nof_ports = 2; - tm = SRSLTE_TM2; + tm = SRSRAN_TM2; break; case 3: cell.nof_ports = 2; - tm = SRSLTE_TM3; + tm = SRSRAN_TM3; break; case 4: cell.nof_ports = 2; - tm = SRSLTE_TM4; + tm = SRSRAN_TM4; break; case 1: default: cell.nof_ports = 1; - tm = SRSLTE_TM1; + tm = SRSRAN_TM1; } } }; @@ -1229,7 +1229,7 @@ public: phy_cfg.prach_cnfg.prach_cfg_info.zero_correlation_zone_cfg = 5; // Create base UE dedicated configuration - srslte::phy_cfg_t dedicated = {}; + srsran::phy_cfg_t dedicated = {}; // Configure DL dedicated.dl_cfg.tm = args.tm; @@ -1237,15 +1237,15 @@ public: // Configure reporting dedicated.dl_cfg.cqi_report.periodic_configured = true; dedicated.dl_cfg.cqi_report.pmi_idx = 25; - dedicated.dl_cfg.cqi_report.periodic_mode = SRSLTE_CQI_MODE_20; + dedicated.dl_cfg.cqi_report.periodic_mode = SRSRAN_CQI_MODE_20; - if (args.tm == SRSLTE_TM3 or args.tm == SRSLTE_TM4) { + if (args.tm == SRSRAN_TM3 or args.tm == SRSRAN_TM4) { dedicated.dl_cfg.cqi_report.ri_idx_present = true; dedicated.dl_cfg.cqi_report.ri_idx = 483; // Every 8 CQI/PMI report, schedule an RI report } // Configure UL Resources - dedicated.ul_cfg.pucch.ack_nack_feedback_mode = srslte_string_ack_nack_feedback_mode(args.ack_mode.c_str()); + dedicated.ul_cfg.pucch.ack_nack_feedback_mode = srsran_string_ack_nack_feedback_mode(args.ack_mode.c_str()); dedicated.ul_cfg.pucch.delta_pucch_shift = delta_pucch; dedicated.ul_cfg.pucch.n_rb_2 = 2; dedicated.ul_cfg.pucch.N_cs = 0; @@ -1268,7 +1268,7 @@ public: dedicated.ul_cfg.pusch.uci_offset.I_offset_cqi = 7; // Configure UE PHY - std::array activation = {}; ///< Activation/Deactivation vector + std::array activation = {}; ///< Activation/Deactivation vector phy_rrc_cfg.resize(args.ue_cell_list.size()); for (uint32_t i = 0; i < args.ue_cell_list.size(); i++) { phy_rrc_cfg[i].enb_cc_idx = args.ue_cell_list[i]; ///< First element is PCell @@ -1319,10 +1319,10 @@ public: int run_tti() { - int ret = SRSLTE_SUCCESS; + int ret = SRSRAN_SUCCESS; - TESTASSERT(ue_phy->run_tti() >= SRSLTE_SUCCESS); - TESTASSERT(stack->run_tti(change_state == change_state_assert) >= SRSLTE_SUCCESS); + TESTASSERT(ue_phy->run_tti() >= SRSRAN_SUCCESS); + TESTASSERT(stack->run_tti(change_state == change_state_assert) >= SRSRAN_SUCCESS); // Change state FSM switch (change_state) { @@ -1341,7 +1341,7 @@ public: if (tti_counter >= 2 * FDD_HARQ_DELAY_DL_MS + FDD_HARQ_DELAY_UL_MS) { logger.warning("******* Cell rotation: Reconfigure *******"); - std::array activation = {}; ///< Activation/Deactivation vector + std::array activation = {}; ///< Activation/Deactivation vector // Rotate primary cells for (auto& q : phy_rrc_cfg) { @@ -1395,7 +1395,7 @@ namespace bpo = boost::program_options; int parse_args(int argc, char** argv, phy_test_bench::args_t& args) { - int ret = SRSLTE_SUCCESS; + int ret = SRSRAN_SUCCESS; bpo::options_description options; bpo::options_description common("Common execution options"); @@ -1422,21 +1422,21 @@ int parse_args(int argc, char** argv, phy_test_bench::args_t& args) bpo::notify(vm); } catch (bpo::error& e) { std::cerr << e.what() << std::endl; - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } // populate UE Active cell list if (not args.ue_cell_list_str.empty()) { - srslte::string_parse_list(args.ue_cell_list_str, ',', args.ue_cell_list); + srsran::string_parse_list(args.ue_cell_list_str, ',', args.ue_cell_list); } else { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // help option was given or error - print usage and exit if (vm.count("help") || ret) { std::cout << "Usage: " << argv[0] << " [OPTIONS] config_file" << std::endl << std::endl; std::cout << options << std::endl << std::endl; - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } return ret; @@ -1447,7 +1447,7 @@ int main(int argc, char** argv) phy_test_bench::args_t test_args; // Parse arguments - TESTASSERT(parse_args(argc, argv, test_args) == SRSLTE_SUCCESS); + TESTASSERT(parse_args(argc, argv, test_args) == SRSRAN_SUCCESS); // Initialize secondary parameters test_args.init(); @@ -1460,7 +1460,7 @@ int main(int argc, char** argv) // Run Simulation for (uint32_t i = 0; i < test_args.duration; i++) { - TESTASSERT(test_bench->run_tti() >= SRSLTE_SUCCESS); + TESTASSERT(test_bench->run_tti() >= SRSRAN_SUCCESS); } test_bench->stop(); @@ -1469,5 +1469,5 @@ int main(int argc, char** argv) std::cout << "Passed" << std::endl; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } diff --git a/srsenb/test/rrc/CMakeLists.txt b/srsenb/test/rrc/CMakeLists.txt index 9e4f07e5f..800e2d088 100644 --- a/srsenb/test/rrc/CMakeLists.txt +++ b/srsenb/test/rrc/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -7,6 +7,6 @@ # add_executable(rrc_nr_test rrc_nr_test.cc) -target_link_libraries(rrc_nr_test srsgnb_rrc srslte_common rrc_nr_asn1) +target_link_libraries(rrc_nr_test srsgnb_rrc srsran_common rrc_nr_asn1) add_test(rrc_nr_test rrc_nr_test) diff --git a/srsenb/test/rrc/rrc_nr_test.cc b/srsenb/test/rrc/rrc_nr_test.cc index e1fd4f75b..77e00d6c6 100644 --- a/srsenb/test/rrc/rrc_nr_test.cc +++ b/srsenb/test/rrc/rrc_nr_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -12,7 +12,7 @@ #include "srsenb/hdr/stack/rrc/rrc_nr.h" #include "srsenb/test/common/dummy_nr_classes.h" -#include "srslte/common/test_common.h" +#include "srsran/common/test_common.h" #include using namespace asn1::rrc_nr; @@ -26,7 +26,7 @@ int test_cell_cfg(const srsenb::sched_interface::cell_cfg_t& cellcfg) TESTASSERT(cellcfg.sibs[0].period_rf == 16); TESTASSERT(cellcfg.si_window_ms > 0); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } /* @@ -35,7 +35,7 @@ int test_cell_cfg(const srsenb::sched_interface::cell_cfg_t& cellcfg) */ int test_sib_generation() { - srslte::timer_handler timers_db(128); + srsran::timer_handler timers_db(128); mac_dummy mac_obj; rlc_dummy rlc_obj; @@ -49,7 +49,7 @@ int test_sib_generation() rrc_obj.init(rrc_cfg, nullptr, &mac_obj, &rlc_obj, &pdcp_obj, nullptr, nullptr); - TESTASSERT(test_cell_cfg(mac_obj.cellcfgobj) == SRSLTE_SUCCESS); + TESTASSERT(test_cell_cfg(mac_obj.cellcfgobj) == SRSRAN_SUCCESS); // TEMP tests TESTASSERT(mac_obj.cellcfgobj.sibs[1].len > 0); TESTASSERT(mac_obj.cellcfgobj.sibs[1].period_rf == sched_elem.si_periodicity.to_number()); @@ -58,12 +58,12 @@ int test_sib_generation() } TESTASSERT(mac_obj.cellcfgobj.cell.nof_prb == 25); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_rrc_setup() { - srslte::timer_handler timers_db(128); + srsran::timer_handler timers_db(128); mac_dummy mac_obj; rlc_dummy rlc_obj; @@ -82,15 +82,15 @@ int test_rrc_setup() } TESTASSERT(rlc_obj.last_sdu != nullptr); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } } // namespace srsenb int main() { - TESTASSERT(srsenb::test_sib_generation() == SRSLTE_SUCCESS); - TESTASSERT(srsenb::test_rrc_setup() == SRSLTE_SUCCESS); + TESTASSERT(srsenb::test_sib_generation() == SRSRAN_SUCCESS); + TESTASSERT(srsenb::test_rrc_setup() == SRSRAN_SUCCESS); return 0; } diff --git a/srsenb/test/upper/CMakeLists.txt b/srsenb/test/upper/CMakeLists.txt index c83d58f68..b4d846201 100644 --- a/srsenb/test/upper/CMakeLists.txt +++ b/srsenb/test/upper/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -7,23 +7,23 @@ # add_library(test_helpers test_helpers.cc) -target_link_libraries(test_helpers srsenb_rrc rrc_asn1 s1ap_asn1 srslte_common enb_cfg_parser ${LIBCONFIGPP_LIBRARIES}) +target_link_libraries(test_helpers srsenb_rrc rrc_asn1 s1ap_asn1 srsran_common enb_cfg_parser ${LIBCONFIGPP_LIBRARIES}) # Simple PLMN -> MCC/MNC test add_executable(plmn_test plmn_test.cc) target_link_libraries(plmn_test rrc_asn1) add_executable(rrc_mobility_test rrc_mobility_test.cc) -target_link_libraries(rrc_mobility_test srslte_asn1 test_helpers) +target_link_libraries(rrc_mobility_test srsran_asn1 test_helpers) add_executable(erab_setup_test erab_setup_test.cc) -target_link_libraries(erab_setup_test srsenb_rrc rrc_asn1 s1ap_asn1 srslte_common srslte_asn1 enb_cfg_parser test_helpers ${LIBCONFIGPP_LIBRARIES}) +target_link_libraries(erab_setup_test srsenb_rrc rrc_asn1 s1ap_asn1 srsran_common srsran_asn1 enb_cfg_parser test_helpers ${LIBCONFIGPP_LIBRARIES}) add_executable(rrc_meascfg_test rrc_meascfg_test.cc) target_link_libraries(rrc_meascfg_test test_helpers) add_executable(gtpu_test gtpu_test.cc) -target_link_libraries(gtpu_test srslte_common s1ap_asn1 srsenb_upper srslte_upper ${SCTP_LIBRARIES}) +target_link_libraries(gtpu_test srsran_common s1ap_asn1 srsenb_upper srsran_upper ${SCTP_LIBRARIES}) add_test(rrc_mobility_test rrc_mobility_test -i ${CMAKE_CURRENT_SOURCE_DIR}/../..) add_test(erab_setup_test erab_setup_test -i ${CMAKE_CURRENT_SOURCE_DIR}/../..) diff --git a/srsenb/test/upper/erab_setup_test.cc b/srsenb/test/upper/erab_setup_test.cc index b706ba03b..26d623480 100644 --- a/srsenb/test/upper/erab_setup_test.cc +++ b/srsenb/test/upper/erab_setup_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -12,21 +12,21 @@ #include "srsenb/hdr/enb.h" #include "srsenb/src/enb_cfg_parser.h" -#include "srslte/asn1/rrc_utils.h" -#include "srslte/common/test_common.h" +#include "srsran/asn1/rrc_utils.h" +#include "srsran/common/test_common.h" #include "test_helpers.h" #include -int test_erab_setup(srslte::log_sink_spy& spy, bool qci_exists) +int test_erab_setup(srsran::log_sink_spy& spy, bool qci_exists) { printf("\n===== TEST: test_erab_setup() =====\n"); - srslte::task_scheduler task_sched; - srslte::unique_byte_buffer_t pdu; + srsran::task_scheduler task_sched; + srsran::unique_byte_buffer_t pdu; srsenb::all_args_t args; rrc_cfg_t cfg; - TESTASSERT(test_helpers::parse_default_cfg(&cfg, args) == SRSLTE_SUCCESS); + TESTASSERT(test_helpers::parse_default_cfg(&cfg, args) == SRSRAN_SUCCESS); spy.reset_counters(); auto& logger = srslog::fetch_basic_logger("RRC", false); @@ -77,7 +77,7 @@ int test_erab_setup(srslte::log_sink_spy& spy, bool qci_exists) 0x81, 0x06, 0x08, 0x08, 0x08, 0x08, 0x00, 0x0d, 0x04, 0x08, 0x08, 0x08, 0x08}; asn1::s1ap::s1ap_pdu_c s1ap_pdu; - srslte::byte_buffer_t byte_buf; + srsran::byte_buffer_t byte_buf; if (qci_exists) { byte_buf.N_bytes = sizeof(drb2_erab_setup_request_ok); memcpy(byte_buf.msg, drb2_erab_setup_request_ok, byte_buf.N_bytes); @@ -99,21 +99,21 @@ int test_erab_setup(srslte::log_sink_spy& spy, bool qci_exists) TESTASSERT(spy.get_error_counter() > 0); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int main(int argc, char** argv) { // Setup the log spy to intercept error and warning log entries. if (!srslog::install_custom_sink( - srslte::log_sink_spy::name(), - std::unique_ptr(new srslte::log_sink_spy(srslog::get_default_log_formatter())))) { - return SRSLTE_ERROR; + srsran::log_sink_spy::name(), + std::unique_ptr(new srsran::log_sink_spy(srslog::get_default_log_formatter())))) { + return SRSRAN_ERROR; } - auto* spy = static_cast(srslog::find_sink(srslte::log_sink_spy::name())); + auto* spy = static_cast(srslog::find_sink(srsran::log_sink_spy::name())); if (!spy) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } srslog::set_default_sink(*spy); @@ -125,12 +125,12 @@ int main(int argc, char** argv) return -1; } argparse::parse_args(argc, argv); - TESTASSERT(test_erab_setup(*spy, true) == SRSLTE_SUCCESS); - TESTASSERT(test_erab_setup(*spy, false) == SRSLTE_SUCCESS); + TESTASSERT(test_erab_setup(*spy, true) == SRSRAN_SUCCESS); + TESTASSERT(test_erab_setup(*spy, false) == SRSRAN_SUCCESS); srslog::flush(); printf("\nSuccess\n"); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } diff --git a/srsenb/test/upper/gtpu_test.cc b/srsenb/test/upper/gtpu_test.cc index 37ecb7ba4..5c2e08e4e 100644 --- a/srsenb/test/upper/gtpu_test.cc +++ b/srsenb/test/upper/gtpu_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,16 +10,16 @@ * */ -#include "srslte/asn1/s1ap.h" +#include "srsran/asn1/s1ap.h" #include #include #include #include "srsenb/hdr/stack/upper/gtpu.h" #include "srsenb/test/common/dummy_classes.h" -#include "srslte/common/network_utils.h" -#include "srslte/common/test_common.h" -#include "srslte/upper/gtpu.h" +#include "srsran/common/network_utils.h" +#include "srsran/common/test_common.h" +#include "srsran/upper/gtpu.h" namespace srsenb { @@ -36,45 +36,45 @@ public: class pdcp_tester : public pdcp_dummy { public: - void write_sdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t sdu, int pdcp_sn) override + void write_sdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t sdu, int pdcp_sn) override { last_sdu = std::move(sdu); last_pdcp_sn = pdcp_sn; last_rnti = rnti; last_lcid = lcid; } - std::map get_buffered_pdus(uint16_t rnti, uint32_t lcid) override + std::map get_buffered_pdus(uint16_t rnti, uint32_t lcid) override { return std::move(buffered_pdus); } void send_status_report(uint16_t rnti) override {} void send_status_report(uint16_t rnti, uint32_t lcid) override {} - void push_buffered_pdu(uint32_t sn, srslte::unique_byte_buffer_t pdu) { buffered_pdus[sn] = std::move(pdu); } + void push_buffered_pdu(uint32_t sn, srsran::unique_byte_buffer_t pdu) { buffered_pdus[sn] = std::move(pdu); } void clear() { last_sdu = nullptr; last_pdcp_sn = -1; last_lcid = 0; - last_rnti = SRSLTE_INVALID_RNTI; + last_rnti = SRSRAN_INVALID_RNTI; } - std::map buffered_pdus; - srslte::unique_byte_buffer_t last_sdu; + std::map buffered_pdus; + srsran::unique_byte_buffer_t last_sdu; int last_pdcp_sn = -1; - uint16_t last_rnti = SRSLTE_INVALID_RNTI; + uint16_t last_rnti = SRSRAN_INVALID_RNTI; uint32_t last_lcid = 0; }; int GTPU_PORT = 2152; -srslte::unique_byte_buffer_t encode_ipv4_packet(srslte::span data, +srsran::unique_byte_buffer_t encode_ipv4_packet(srsran::span data, uint32_t teid, const struct sockaddr_in& src_sockaddr_in, const struct sockaddr_in& dest_sockaddr_in) { - srslte::unique_byte_buffer_t pdu = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t pdu = srsran::make_byte_buffer(); struct iphdr ip_pkt = {}; ip_pkt.version = 4; @@ -87,15 +87,15 @@ srslte::unique_byte_buffer_t encode_ipv4_packet(srslte::span data, return pdu; } -srslte::unique_byte_buffer_t encode_gtpu_packet(srslte::span data, +srsran::unique_byte_buffer_t encode_gtpu_packet(srsran::span data, uint32_t teid, const struct sockaddr_in& src_sockaddr_in, const struct sockaddr_in& dest_sockaddr_in) { - srslte::unique_byte_buffer_t pdu = encode_ipv4_packet(data, teid, src_sockaddr_in, dest_sockaddr_in); + srsran::unique_byte_buffer_t pdu = encode_ipv4_packet(data, teid, src_sockaddr_in, dest_sockaddr_in); // header - srslte::gtpu_header_t header = {}; + srsran::gtpu_header_t header = {}; header.flags = GTPU_FLAGS_VERSION_V1 | GTPU_FLAGS_GTP_PROTOCOL; header.message_type = GTPU_MSG_DATA_PDU; header.length = pdu->N_bytes; @@ -105,12 +105,12 @@ srslte::unique_byte_buffer_t encode_gtpu_packet(srslte::span data, return pdu; } -srslte::unique_byte_buffer_t encode_end_marker(uint32_t teid) +srsran::unique_byte_buffer_t encode_end_marker(uint32_t teid) { - srslte::unique_byte_buffer_t pdu = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t pdu = srsran::make_byte_buffer(); // header - srslte::gtpu_header_t header = {}; + srsran::gtpu_header_t header = {}; header.flags = GTPU_FLAGS_VERSION_V1 | GTPU_FLAGS_GTP_PROTOCOL; header.message_type = GTPU_MSG_END_MARKER; header.length = 0; @@ -120,9 +120,9 @@ srslte::unique_byte_buffer_t encode_end_marker(uint32_t teid) return pdu; } -srslte::unique_byte_buffer_t read_socket(int fd) +srsran::unique_byte_buffer_t read_socket(int fd) { - srslte::unique_byte_buffer_t pdu = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t pdu = srsran::make_byte_buffer(); pdu->N_bytes = read(fd, pdu->msg, pdu->get_tailroom()); return pdu; } @@ -134,21 +134,21 @@ int test_gtpu_direct_tunneling() uint32_t sgw_teidout1 = 1, sgw_teidout2 = 2; const char * sgw_addr_str = "127.0.0.1", *senb_addr_str = "127.0.1.1", *tenb_addr_str = "127.0.1.2"; struct sockaddr_in senb_sockaddr = {}, sgw_sockaddr = {}, tenb_sockaddr = {}; - srslte::net_utils::set_sockaddr(&senb_sockaddr, senb_addr_str, GTPU_PORT); - srslte::net_utils::set_sockaddr(&sgw_sockaddr, sgw_addr_str, GTPU_PORT); - srslte::net_utils::set_sockaddr(&tenb_sockaddr, tenb_addr_str, GTPU_PORT); + srsran::net_utils::set_sockaddr(&senb_sockaddr, senb_addr_str, GTPU_PORT); + srsran::net_utils::set_sockaddr(&sgw_sockaddr, sgw_addr_str, GTPU_PORT); + srsran::net_utils::set_sockaddr(&tenb_sockaddr, tenb_addr_str, GTPU_PORT); uint32_t tenb_addr = ntohl(tenb_sockaddr.sin_addr.s_addr); uint32_t senb_addr = ntohl(senb_sockaddr.sin_addr.s_addr); uint32_t sgw_addr = ntohl(sgw_sockaddr.sin_addr.s_addr); - srslte::unique_byte_buffer_t pdu; + srsran::unique_byte_buffer_t pdu; // Initiate layers srslog::basic_logger& logger1 = srslog::fetch_basic_logger("GTPU1"); logger1.set_hex_dump_max_size(2048); srslog::basic_logger& logger2 = srslog::fetch_basic_logger("GTPU2"); logger2.set_hex_dump_max_size(2048); - srslte::task_scheduler task_sched; + srsran::task_scheduler task_sched; srsenb::gtpu senb_gtpu(&task_sched, logger1), tenb_gtpu(&task_sched, logger2); stack_tester senb_stack, tenb_stack; pdcp_tester senb_pdcp, tenb_pdcp; @@ -181,7 +181,7 @@ int test_gtpu_direct_tunneling() std::vector data_vec(10); std::iota(data_vec.begin(), data_vec.end(), 0); std::vector encoded_data; - srslte::span pdu_view{}; + srsran::span pdu_view{}; // TEST: GTPU buffers incoming PDCP buffered SNs until the TEID is explicitly activated tenb_gtpu.handle_gtpu_s1u_rx_packet(read_socket(tenb_stack.s1u_fd), senb_sockaddr); @@ -189,7 +189,7 @@ int test_gtpu_direct_tunneling() tenb_gtpu.handle_gtpu_s1u_rx_packet(read_socket(tenb_stack.s1u_fd), senb_sockaddr); TESTASSERT(tenb_pdcp.last_sdu == nullptr); tenb_gtpu.set_tunnel_status(dl_tenb_teid_in, true); - pdu_view = srslte::make_span(tenb_pdcp.last_sdu); + pdu_view = srsran::make_span(tenb_pdcp.last_sdu); TESTASSERT(std::count(pdu_view.begin() + PDU_HEADER_SIZE, pdu_view.end(), 7) == 10); TESTASSERT(tenb_pdcp.last_rnti == rnti2); TESTASSERT(tenb_pdcp.last_lcid == drb1); @@ -198,7 +198,7 @@ int test_gtpu_direct_tunneling() // TEST: verify that PDCP buffered SNs have been forwarded through SeNB->TeNB tunnel for (size_t sn = 8; sn < 10; ++sn) { tenb_gtpu.handle_gtpu_s1u_rx_packet(read_socket(tenb_stack.s1u_fd), senb_sockaddr); - pdu_view = srslte::make_span(tenb_pdcp.last_sdu); + pdu_view = srsran::make_span(tenb_pdcp.last_sdu); TESTASSERT(std::count(pdu_view.begin() + PDU_HEADER_SIZE, pdu_view.end(), sn) == 10); TESTASSERT(tenb_pdcp.last_rnti == rnti2); TESTASSERT(tenb_pdcp.last_lcid == drb1); @@ -211,7 +211,7 @@ int test_gtpu_direct_tunneling() encoded_data.assign(pdu->msg + 8u, pdu->msg + pdu->N_bytes); senb_gtpu.handle_gtpu_s1u_rx_packet(std::move(pdu), sgw_sockaddr); tenb_gtpu.handle_gtpu_s1u_rx_packet(read_socket(tenb_stack.s1u_fd), senb_sockaddr); - pdu_view = srslte::make_span(tenb_pdcp.last_sdu); + pdu_view = srsran::make_span(tenb_pdcp.last_sdu); TESTASSERT(pdu_view.size() == encoded_data.size() and std::equal(pdu_view.begin(), pdu_view.end(), encoded_data.begin())); TESTASSERT(tenb_pdcp.last_rnti == rnti2 and tenb_pdcp.last_lcid == drb1); @@ -240,10 +240,10 @@ int test_gtpu_direct_tunneling() pdu = encode_end_marker(senb_teid_in); senb_gtpu.handle_gtpu_s1u_rx_packet(std::move(pdu), sgw_sockaddr); tenb_gtpu.handle_gtpu_s1u_rx_packet(read_socket(tenb_stack.s1u_fd), senb_sockaddr); - srslte::span encoded_data2{tenb_pdcp.last_sdu->msg + 20u, tenb_pdcp.last_sdu->msg + 30u}; + srsran::span encoded_data2{tenb_pdcp.last_sdu->msg + 20u, tenb_pdcp.last_sdu->msg + 30u}; TESTASSERT(std::all_of(encoded_data2.begin(), encoded_data2.end(), [N_pdus](uint8_t b) { return b == N_pdus - 1; })); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } } // namespace srsenb @@ -258,9 +258,9 @@ int main() // Start the log backend. srslog::init(); - TESTASSERT(srsenb::test_gtpu_direct_tunneling() == SRSLTE_SUCCESS); + TESTASSERT(srsenb::test_gtpu_direct_tunneling() == SRSRAN_SUCCESS); srslog::flush(); - srslte::console("Success"); + srsran::console("Success"); } diff --git a/srsenb/test/upper/plmn_test.cc b/srsenb/test/upper/plmn_test.cc index 5d589f175..35ba2d311 100644 --- a/srsenb/test/upper/plmn_test.cc +++ b/srsenb/test/upper/plmn_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,10 +11,10 @@ */ #include "srsenb/hdr/stack/upper/common_enb.h" -#include "srslte/asn1/rrc/common.h" -#include "srslte/asn1/rrc_utils.h" -#include "srslte/common/bcd_helpers.h" -#include "srslte/interfaces/rrc_interface_types.h" +#include "srsran/asn1/rrc/common.h" +#include "srsran/asn1/rrc_utils.h" +#include "srsran/common/bcd_helpers.h" +#include "srsran/interfaces/rrc_interface_types.h" #include //for inet_ntop() #include @@ -41,21 +41,21 @@ int rrc_plmn_test() TESTASSERT(plmn_out.mcc_present); uint16_t mcc, mnc; - srslte::bytes_to_mcc(&plmn_out.mcc[0], &mcc); - srslte::bytes_to_mnc(&plmn_out.mnc[0], &mnc, plmn_out.mnc.size()); + srsran::bytes_to_mcc(&plmn_out.mcc[0], &mcc); + srsran::bytes_to_mnc(&plmn_out.mnc[0], &mnc, plmn_out.mnc.size()); TESTASSERT(mcc == 0xF123); TESTASSERT(mnc == 0xFF45); // Test MCC/MNC --> vector plmn_in.mcc_present = plmn_out.mcc_present; - TESTASSERT(srslte::mcc_to_bytes(mcc, &plmn_in.mcc[0])); - TESTASSERT(srslte::mnc_to_bytes(mnc, plmn_in.mnc)); + TESTASSERT(srsran::mcc_to_bytes(mcc, &plmn_in.mcc[0])); + TESTASSERT(srsran::mnc_to_bytes(mnc, plmn_in.mnc)); TESTASSERT(plmn_in.mcc_present == plmn_out.mcc_present); TESTASSERT(plmn_in.mcc == plmn_out.mcc); TESTASSERT(plmn_in.mnc == plmn_out.mnc); // Test plmn --> string - srslte::plmn_id_t srsplmn_out = srslte::make_plmn_id_t(plmn_out); + srsran::plmn_id_t srsplmn_out = srsran::make_plmn_id_t(plmn_out); TESTASSERT(srsplmn_out.to_string() == "12345"); asn1::bit_ref bref_in(&byte_buf[0], sizeof(byte_buf)); @@ -66,7 +66,7 @@ int rrc_plmn_test() TESTASSERT(memcmp(&ref[0], &byte_buf[0], sizeof(ref)) == 0); // 3-digit MNC test - TESTASSERT(srslte::mnc_to_bytes(0xF456, plmn_in.mnc)); + TESTASSERT(srsran::mnc_to_bytes(0xF456, plmn_in.mnc)); bref_in = asn1::bit_ref(&byte_buf[0], sizeof(byte_buf)); plmn_in.pack(bref_in); uint8_t ref2[4] = {0x89, 0x1D, 0x15, 0x80}; @@ -87,43 +87,43 @@ int s1ap_plmn_test() uint16_t mcc = 0xF123; uint16_t mnc = 0xFF45; uint32_t plmn; - srslte::plmn_id_t srslte_plmn, srslte_plmn2; + srsran::plmn_id_t srsran_plmn, srsran_plmn2; asn1::fixed_octstring<3, true> s1ap_plmn{}; // 2-digit MNC test - srslte::s1ap_mccmnc_to_plmn(mcc, mnc, &plmn); + srsran::s1ap_mccmnc_to_plmn(mcc, mnc, &plmn); TESTASSERT(plmn == 0x21F354); - srslte::s1ap_plmn_to_mccmnc(plmn, &mcc, &mnc); + srsran::s1ap_plmn_to_mccmnc(plmn, &mcc, &mnc); TESTASSERT(mcc == 0xF123); TESTASSERT(mnc == 0xFF45); // Test MCC/MNC --> S1AP - srslte_plmn.from_number(mcc, mnc); - TESTASSERT(srslte_plmn.to_string() == "12345"); - srslte::to_asn1(&s1ap_plmn, srslte_plmn); + srsran_plmn.from_number(mcc, mnc); + TESTASSERT(srsran_plmn.to_string() == "12345"); + srsran::to_asn1(&s1ap_plmn, srsran_plmn); TESTASSERT(s1ap_plmn[0] == ((uint8_t*)&plmn)[2]); TESTASSERT(s1ap_plmn[1] == ((uint8_t*)&plmn)[1]); TESTASSERT(s1ap_plmn[2] == ((uint8_t*)&plmn)[0]); - srslte_plmn2 = srslte::make_plmn_id_t(s1ap_plmn); - TESTASSERT(srslte_plmn2 == srslte_plmn); + srsran_plmn2 = srsran::make_plmn_id_t(s1ap_plmn); + TESTASSERT(srsran_plmn2 == srsran_plmn); // 3-digit MNC test mnc = 0xF456; - srslte::s1ap_mccmnc_to_plmn(mcc, mnc, &plmn); + srsran::s1ap_mccmnc_to_plmn(mcc, mnc, &plmn); TESTASSERT(plmn == 0x214365); - srslte::s1ap_plmn_to_mccmnc(plmn, &mcc, &mnc); + srsran::s1ap_plmn_to_mccmnc(plmn, &mcc, &mnc); TESTASSERT(mcc == 0xF123); TESTASSERT(mnc == 0xF456); // Test MCC/MNC --> S1AP - srslte_plmn.from_number(mcc, mnc); - TESTASSERT(srslte_plmn.to_string() == "123456"); - srslte::to_asn1(&s1ap_plmn, srslte_plmn); + srsran_plmn.from_number(mcc, mnc); + TESTASSERT(srsran_plmn.to_string() == "123456"); + srsran::to_asn1(&s1ap_plmn, srsran_plmn); TESTASSERT(s1ap_plmn[0] == ((uint8_t*)&plmn)[2]); TESTASSERT(s1ap_plmn[1] == ((uint8_t*)&plmn)[1]); TESTASSERT(s1ap_plmn[2] == ((uint8_t*)&plmn)[0]); - srslte_plmn2 = srslte::make_plmn_id_t(s1ap_plmn); - TESTASSERT(srslte_plmn2 == srslte_plmn); + srsran_plmn2 = srsran::make_plmn_id_t(s1ap_plmn); + TESTASSERT(srsran_plmn2 == srsran_plmn); return 0; } diff --git a/srsenb/test/upper/rrc_meascfg_test.cc b/srsenb/test/upper/rrc_meascfg_test.cc index 309acc84d..69f9b0cb5 100644 --- a/srsenb/test/upper/rrc_meascfg_test.cc +++ b/srsenb/test/upper/rrc_meascfg_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -12,10 +12,10 @@ #include "srsenb/hdr/enb.h" #include "srsenb/hdr/stack/rrc/ue_meas_cfg.h" -#include "srslte/asn1/rrc_utils.h" -#include "srslte/common/test_common.h" -#include "srslte/interfaces/enb_rrc_interface_types.h" -#include "srslte/rrc/rrc_cfg_utils.h" +#include "srsran/asn1/rrc_utils.h" +#include "srsran/common/test_common.h" +#include "srsran/interfaces/enb_rrc_interface_types.h" +#include "srsran/rrc/rrc_cfg_utils.h" #include "test_helpers.h" using namespace asn1::rrc; @@ -214,7 +214,7 @@ int test_correct_meascfg_calculation() // TEST: creation of a meas_cfg using the srsenb::rrc_cfg_t rrc_cfg_t cfg; srsenb::all_args_t all_args; - TESTASSERT(test_helpers::parse_default_cfg(&cfg, all_args) == SRSLTE_SUCCESS); + TESTASSERT(test_helpers::parse_default_cfg(&cfg, all_args) == SRSRAN_SUCCESS); cfg.enb_id = 0x19B; cfg.cell.nof_prb = 6; cfg.meas_cfg_present = true; @@ -269,14 +269,14 @@ int test_correct_meascfg_calculation() TESTASSERT(not measobjs2[0].meas_obj.meas_obj_eutra().cells_to_add_mod_list_present); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_minimize_meascfg_reordering() { rrc_cfg_t default_cfg, cfg1; srsenb::all_args_t all_args; - TESTASSERT(test_helpers::parse_default_cfg(&default_cfg, all_args) == SRSLTE_SUCCESS); + TESTASSERT(test_helpers::parse_default_cfg(&default_cfg, all_args) == SRSRAN_SUCCESS); cfg1 = default_cfg; cfg1.enb_id = 0x19B; cfg1.cell.nof_prb = 6; @@ -310,16 +310,16 @@ int test_minimize_meascfg_reordering() // TEST1: Ensure consistent order of measObjects based on DL-EARFCN TESTASSERT(mcfg1.meas_obj_to_add_mod_list_present and mcfg2.meas_obj_to_add_mod_list_present); TESTASSERT(mcfg1.meas_obj_to_add_mod_list.size() == mcfg2.meas_obj_to_add_mod_list.size()); - TESTASSERT(srslte::get_carrier_freq(mcfg1.meas_obj_to_add_mod_list[0]) == - srslte::get_carrier_freq(mcfg2.meas_obj_to_add_mod_list[0])); - TESTASSERT(srslte::get_carrier_freq(mcfg1.meas_obj_to_add_mod_list[1]) == - srslte::get_carrier_freq(mcfg2.meas_obj_to_add_mod_list[1])); + TESTASSERT(srsran::get_carrier_freq(mcfg1.meas_obj_to_add_mod_list[0]) == + srsran::get_carrier_freq(mcfg2.meas_obj_to_add_mod_list[0])); + TESTASSERT(srsran::get_carrier_freq(mcfg1.meas_obj_to_add_mod_list[1]) == + srsran::get_carrier_freq(mcfg2.meas_obj_to_add_mod_list[1])); TESTASSERT(std::is_sorted( - mcfg1.meas_obj_to_add_mod_list.begin(), mcfg1.meas_obj_to_add_mod_list.end(), srslte::rrc_obj_id_cmp{})); + mcfg1.meas_obj_to_add_mod_list.begin(), mcfg1.meas_obj_to_add_mod_list.end(), srsran::rrc_obj_id_cmp{})); TESTASSERT(std::is_sorted( - mcfg2.meas_obj_to_add_mod_list.begin(), mcfg2.meas_obj_to_add_mod_list.end(), srslte::rrc_obj_id_cmp{})); + mcfg2.meas_obj_to_add_mod_list.begin(), mcfg2.meas_obj_to_add_mod_list.end(), srsran::rrc_obj_id_cmp{})); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } } // namespace srsenb @@ -342,7 +342,7 @@ int main(int argc, char** argv) srslog::flush(); - srslte::console("Success\n"); + srsran::console("Success\n"); return 0; } diff --git a/srsenb/test/upper/rrc_mobility_test.cc b/srsenb/test/upper/rrc_mobility_test.cc index ce785d1d9..d04312ca9 100644 --- a/srsenb/test/upper/rrc_mobility_test.cc +++ b/srsenb/test/upper/rrc_mobility_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,8 +13,8 @@ #include "srsenb/hdr/enb.h" #include "srsenb/hdr/stack/rrc/rrc_mobility.h" #include "srsenb/test/common/dummy_classes.h" -#include "srslte/asn1/rrc_utils.h" -#include "srslte/common/test_common.h" +#include "srsran/asn1/rrc_utils.h" +#include "srsran/common/test_common.h" #include "test_helpers.h" #include @@ -74,12 +74,12 @@ struct mobility_tester { // Do all the handshaking until the first RRC Connection Reconf test_helpers::bring_rrc_to_reconf_state(rrc, *task_sched.get_timer_handler(), rnti); logger.set_level(srslog::basic_levels::info); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } mobility_test_params args; srslog::basic_logger& logger; - srslte::task_scheduler task_sched; + srsran::task_scheduler task_sched; rrc_cfg_t cfg; srsenb::rrc rrc; @@ -103,19 +103,19 @@ protected: int generate_rrc_cfg_common() { srsenb::all_args_t all_args; - TESTASSERT(test_helpers::parse_default_cfg(&cfg, all_args) == SRSLTE_SUCCESS); + TESTASSERT(test_helpers::parse_default_cfg(&cfg, all_args) == SRSRAN_SUCCESS); cfg.meas_cfg_present = true; report_cfg_eutra_s rep = generate_rep1(); cfg.cell_list[0].meas_cfg.meas_reports.push_back(rep); cfg.cell_list[0].meas_cfg.meas_cells.resize(1); cfg.cell_list[0].meas_cfg.meas_cells[0] = generate_cell1(); cfg.cell_list[0].meas_cfg.meas_cells[0].pci = 2; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int setup_rrc_common() { rrc.init(cfg, &phy, &mac, &rlc, &pdcp, &s1ap, >pu); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } }; @@ -123,11 +123,11 @@ struct s1ap_mobility_tester : public mobility_tester { explicit s1ap_mobility_tester(const mobility_test_params& args_) : mobility_tester(args_) {} int generate_rrc_cfg() final { - TESTASSERT(generate_rrc_cfg_common() == SRSLTE_SUCCESS); + TESTASSERT(generate_rrc_cfg_common() == SRSRAN_SUCCESS); cfg.cell_list[0].meas_cfg.meas_cells[0].eci = 0x19C02; cfg.cell_list[0].meas_cfg.meas_cells[0].earfcn = 2850; cfg.cell_list[0].meas_cfg.meas_gap_period = 40; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } }; @@ -135,7 +135,7 @@ struct intraenb_mobility_tester : public mobility_tester { explicit intraenb_mobility_tester(const mobility_test_params& args_) : mobility_tester(args_) {} int generate_rrc_cfg() final { - TESTASSERT(generate_rrc_cfg_common() == SRSLTE_SUCCESS); + TESTASSERT(generate_rrc_cfg_common() == SRSRAN_SUCCESS); cfg.cell_list[0].meas_cfg.meas_cells[0].eci = 0x19B02; cfg.cell_list[0].meas_cfg.meas_gap_period = 40; cfg.cell_list[0].meas_cfg.meas_cells[0].earfcn = 2850; @@ -150,25 +150,25 @@ struct intraenb_mobility_tester : public mobility_tester { cell2.meas_cfg.meas_gap_period = 80; cfg.cell_list.push_back(cell2); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } }; -int test_s1ap_mobility(srslte::log_sink_spy& spy, mobility_test_params test_params) +int test_s1ap_mobility(srsran::log_sink_spy& spy, mobility_test_params test_params) { printf("\n===== TEST: test_s1ap_mobility() for event %s =====\n", test_params.to_string()); s1ap_mobility_tester tester{test_params}; spy.reset_counters(); - srslte::unique_byte_buffer_t pdu; + srsran::unique_byte_buffer_t pdu; - TESTASSERT(tester.generate_rrc_cfg() == SRSLTE_SUCCESS); - TESTASSERT(tester.setup_rrc() == SRSLTE_SUCCESS); - TESTASSERT(tester.run_preamble() == SRSLTE_SUCCESS); + TESTASSERT(tester.generate_rrc_cfg() == SRSRAN_SUCCESS); + TESTASSERT(tester.setup_rrc() == SRSRAN_SUCCESS); + TESTASSERT(tester.run_preamble() == SRSRAN_SUCCESS); test_dummies::s1ap_mobility_dummy& s1ap = tester.s1ap; /* Receive correct measConfig */ dl_dcch_msg_s dl_dcch_msg; - TESTASSERT(test_helpers::unpack_asn1(dl_dcch_msg, srslte::make_span(tester.pdcp.last_sdu.sdu))); + TESTASSERT(test_helpers::unpack_asn1(dl_dcch_msg, srsran::make_span(tester.pdcp.last_sdu.sdu))); rrc_conn_recfg_r8_ies_s& recfg_r8 = dl_dcch_msg.msg.c1().rrc_conn_recfg().crit_exts.c1().rrc_conn_recfg_r8(); TESTASSERT(recfg_r8.meas_cfg_present and recfg_r8.meas_cfg.meas_gap_cfg_present); TESTASSERT(recfg_r8.meas_cfg.meas_gap_cfg.type().value == setup_opts::setup); @@ -190,7 +190,7 @@ int test_s1ap_mobility(srslte::log_sink_spy& spy, mobility_test_params test_para if (test_params.fail_at == mobility_test_params::test_event::wrong_measreport) { TESTASSERT(s1ap.last_ho_required.rrc_container == nullptr); TESTASSERT(spy.get_warning_counter() == 1); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } TESTASSERT(s1ap.last_ho_required.rrc_container != nullptr); @@ -202,7 +202,7 @@ int test_s1ap_mobility(srslte::log_sink_spy& spy, mobility_test_params test_para tester.rrc.write_pdu(tester.rnti, 1, std::move(pdu)); tester.tic(); TESTASSERT(s1ap.last_ho_required.rrc_container == nullptr); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } /* Test Case: Check HO Required was sent to S1AP */ @@ -228,7 +228,7 @@ int test_s1ap_mobility(srslte::log_sink_spy& spy, mobility_test_params test_para tester.rrc.ho_preparation_complete(tester.rnti, false, {}, nullptr); // TESTASSERT(spy.get_error_counter() == 1); TESTASSERT(not s1ap.last_enb_status.status_present); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } /* MME returns back an HandoverCommand, S1AP unwraps the RRC container */ @@ -242,26 +242,26 @@ int test_s1ap_mobility(srslte::log_sink_spy& spy, mobility_test_params test_para TESTASSERT(s1ap.last_enb_status.status_present); TESTASSERT(spy.get_error_counter() == 0); asn1::rrc::dl_dcch_msg_s ho_cmd; - TESTASSERT(test_helpers::unpack_asn1(ho_cmd, srslte::make_span(tester.pdcp.last_sdu.sdu))); + TESTASSERT(test_helpers::unpack_asn1(ho_cmd, srsran::make_span(tester.pdcp.last_sdu.sdu))); recfg_r8 = ho_cmd.msg.c1().rrc_conn_recfg().crit_exts.c1().rrc_conn_recfg_r8(); TESTASSERT(recfg_r8.mob_ctrl_info_present); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_s1ap_tenb_mobility(mobility_test_params test_params) { printf("\n===== TEST: test_s1ap_tenb_mobility() for event %s =====\n", test_params.to_string()); s1ap_mobility_tester tester{test_params}; - srslte::unique_byte_buffer_t pdu; + srsran::unique_byte_buffer_t pdu; - TESTASSERT(tester.generate_rrc_cfg() == SRSLTE_SUCCESS); + TESTASSERT(tester.generate_rrc_cfg() == SRSRAN_SUCCESS); tester.cfg.cell_list[0].meas_cfg.meas_cells[0].eci = 0x19B01; tester.cfg.enb_id = 0x19C; tester.cfg.cell.id = 0x02; tester.cfg.cell_list[0].cell_id = 0x02; tester.cfg.cell_list[0].pci = 2; - TESTASSERT(tester.setup_rrc() == SRSLTE_SUCCESS); + TESTASSERT(tester.setup_rrc() == SRSRAN_SUCCESS); security_cfg_handler sec_cfg{tester.cfg}; /* TeNB receives S1AP Handover Request */ @@ -306,7 +306,7 @@ int test_s1ap_tenb_mobility(mobility_test_params test_params) sec_cfg.set_security_capabilities(ho_req.protocol_ies.ue_security_cap.value); sec_cfg.set_security_key(ho_req.protocol_ies.security_context.value.next_hop_param); sec_cfg.regenerate_keys_handover(tester.cfg.cell_list[0].pci, tester.cfg.cell_list[0].dl_earfcn); - srslte::as_security_config_t as_sec_cfg = sec_cfg.get_as_sec_cfg(); + srsran::as_security_config_t as_sec_cfg = sec_cfg.get_as_sec_cfg(); TESTASSERT(tester.pdcp.bearers[0x46][rb_id_t::RB_ID_SRB1].sec_cfg.k_rrc_int == as_sec_cfg.k_rrc_int); TESTASSERT(tester.pdcp.bearers[0x46][rb_id_t::RB_ID_SRB1].sec_cfg.k_rrc_enc == as_sec_cfg.k_rrc_enc); TESTASSERT(tester.pdcp.bearers[0x46][rb_id_t::RB_ID_SRB1].sec_cfg.k_up_int == as_sec_cfg.k_up_int); @@ -364,23 +364,23 @@ int test_s1ap_tenb_mobility(mobility_test_params test_params) TESTASSERT(mac_ue.pucch_cfg.n_pucch_sr == recfg_r8.rr_cfg_ded.phys_cfg_ded.sched_request_cfg.setup().sr_pucch_res_idx); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int test_intraenb_mobility(srslte::log_sink_spy& spy, mobility_test_params test_params) +int test_intraenb_mobility(srsran::log_sink_spy& spy, mobility_test_params test_params) { printf("\n===== TEST: test_intraenb_mobility() for event %s =====\n", test_params.to_string()); intraenb_mobility_tester tester{test_params}; spy.reset_counters(); - srslte::unique_byte_buffer_t pdu; + srsran::unique_byte_buffer_t pdu; - TESTASSERT(tester.generate_rrc_cfg() == SRSLTE_SUCCESS); - TESTASSERT(tester.setup_rrc() == SRSLTE_SUCCESS); - TESTASSERT(tester.run_preamble() == SRSLTE_SUCCESS); + TESTASSERT(tester.generate_rrc_cfg() == SRSRAN_SUCCESS); + TESTASSERT(tester.setup_rrc() == SRSRAN_SUCCESS); + TESTASSERT(tester.run_preamble() == SRSRAN_SUCCESS); /* Receive correct measConfig */ dl_dcch_msg_s dl_dcch_msg; - TESTASSERT(test_helpers::unpack_asn1(dl_dcch_msg, srslte::make_span(tester.pdcp.last_sdu.sdu))); + TESTASSERT(test_helpers::unpack_asn1(dl_dcch_msg, srsran::make_span(tester.pdcp.last_sdu.sdu))); rrc_conn_recfg_r8_ies_s& recfg_r8 = dl_dcch_msg.msg.c1().rrc_conn_recfg().crit_exts.c1().rrc_conn_recfg_r8(); TESTASSERT(recfg_r8.meas_cfg_present and recfg_r8.meas_cfg.meas_gap_cfg_present); TESTASSERT(recfg_r8.meas_cfg.meas_gap_cfg.type().value == setup_opts::setup); @@ -407,7 +407,7 @@ int test_intraenb_mobility(srslte::log_sink_spy& spy, mobility_test_params test_ if (test_params.fail_at == mobility_test_params::test_event::wrong_measreport) { TESTASSERT(spy.get_warning_counter() == 1); TESTASSERT(tester.pdcp.last_sdu.sdu == nullptr); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } TESTASSERT(tester.pdcp.last_sdu.sdu != nullptr); TESTASSERT(tester.s1ap.last_ho_required.rrc_container == nullptr); @@ -421,7 +421,7 @@ int test_intraenb_mobility(srslte::log_sink_spy& spy, mobility_test_params test_ tester.rrc.write_pdu(tester.rnti, 1, std::move(pdu)); tester.tic(); TESTASSERT(tester.pdcp.last_sdu.sdu == nullptr); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } /* Test Case: the HandoverCommand was sent to the lower layers */ @@ -429,7 +429,7 @@ int test_intraenb_mobility(srslte::log_sink_spy& spy, mobility_test_params test_ TESTASSERT(tester.pdcp.last_sdu.rnti == tester.rnti); TESTASSERT(tester.pdcp.last_sdu.lcid == 1); // SRB1 asn1::rrc::dl_dcch_msg_s ho_cmd; - TESTASSERT(test_helpers::unpack_asn1(ho_cmd, srslte::make_span(tester.pdcp.last_sdu.sdu))); + TESTASSERT(test_helpers::unpack_asn1(ho_cmd, srsran::make_span(tester.pdcp.last_sdu.sdu))); recfg_r8 = ho_cmd.msg.c1().rrc_conn_recfg().crit_exts.c1().rrc_conn_recfg_r8(); TESTASSERT(recfg_r8.mob_ctrl_info_present); TESTASSERT(recfg_r8.mob_ctrl_info.new_ue_id.to_number() == tester.rnti); @@ -487,27 +487,27 @@ int test_intraenb_mobility(srslte::log_sink_spy& spy, mobility_test_params test_ TESTASSERT(tester.pdcp.last_sdu.sdu != nullptr); TESTASSERT(tester.s1ap.last_ho_required.rrc_container == nullptr); TESTASSERT(not tester.s1ap.last_enb_status.status_present); - TESTASSERT(test_helpers::unpack_asn1(ho_cmd, srslte::make_span(tester.pdcp.last_sdu.sdu))); + TESTASSERT(test_helpers::unpack_asn1(ho_cmd, srsran::make_span(tester.pdcp.last_sdu.sdu))); recfg_r8 = ho_cmd.msg.c1().rrc_conn_recfg().crit_exts.c1().rrc_conn_recfg_r8(); TESTASSERT(recfg_r8.mob_ctrl_info_present); TESTASSERT(recfg_r8.mob_ctrl_info.new_ue_id.to_number() == tester.rnti); TESTASSERT(recfg_r8.mob_ctrl_info.target_pci == 1); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int main(int argc, char** argv) { // Setup the log spy to intercept error and warning log entries. if (!srslog::install_custom_sink( - srslte::log_sink_spy::name(), - std::unique_ptr(new srslte::log_sink_spy(srslog::get_default_log_formatter())))) { - return SRSLTE_ERROR; + srsran::log_sink_spy::name(), + std::unique_ptr(new srsran::log_sink_spy(srslog::get_default_log_formatter())))) { + return SRSRAN_ERROR; } - auto* spy = static_cast(srslog::find_sink(srslte::log_sink_spy::name())); + auto* spy = static_cast(srslog::find_sink(srsran::log_sink_spy::name())); if (!spy) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } srslog::set_default_sink(*spy); @@ -543,5 +543,5 @@ int main(int argc, char** argv) printf("\nSuccess\n"); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } diff --git a/srsenb/test/upper/test_helpers.cc b/srsenb/test/upper/test_helpers.cc index 4839906c4..3b6c21921 100644 --- a/srsenb/test/upper/test_helpers.cc +++ b/srsenb/test/upper/test_helpers.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -12,7 +12,7 @@ #include "test_helpers.h" #include "srsenb/hdr/enb.h" -#include "srslte/common/test_common.h" +#include "srsran/common/test_common.h" namespace argparse { @@ -32,8 +32,8 @@ int parse_default_cfg_phy(rrc_cfg_t* rrc_cfg, phy_cfg_t* phy_cfg, srsenb::all_ar srslog::fetch_basic_logger("TEST").debug("sib file path=%s", args.enb_files.sib_config.c_str()); args.enb.enb_id = 0x19B; - TESTASSERT(srslte::string_to_mcc("001", &args.stack.s1ap.mcc)); - TESTASSERT(srslte::string_to_mnc("01", &args.stack.s1ap.mnc)); + TESTASSERT(srsran::string_to_mcc("001", &args.stack.s1ap.mcc)); + TESTASSERT(srsran::string_to_mnc("01", &args.stack.s1ap.mnc)); args.general.eia_pref_list = "EIA2, EIA1, EIA0"; args.general.eea_pref_list = "EEA0, EEA2, EEA1"; @@ -54,8 +54,8 @@ int parse_default_cfg(rrc_cfg_t* rrc_cfg, srsenb::all_args_t& args) args.enb.enb_id = 0x19B; args.enb.dl_earfcn = 3400; args.enb.n_prb = 50; - TESTASSERT(srslte::string_to_mcc("001", &args.stack.s1ap.mcc)); - TESTASSERT(srslte::string_to_mnc("01", &args.stack.s1ap.mnc)); + TESTASSERT(srsran::string_to_mcc("001", &args.stack.s1ap.mcc)); + TESTASSERT(srsran::string_to_mnc("01", &args.stack.s1ap.mnc)); args.enb.transmission_mode = 1; args.enb.nof_ports = 1; args.general.eia_pref_list = "EIA2, EIA1, EIA0"; @@ -68,9 +68,9 @@ int parse_default_cfg(rrc_cfg_t* rrc_cfg, srsenb::all_args_t& args) return enb_conf_sections::parse_cfg_files(&args, rrc_cfg, &phy_cfg); } -int bring_rrc_to_reconf_state(srsenb::rrc& rrc, srslte::timer_handler& timers, uint16_t rnti) +int bring_rrc_to_reconf_state(srsenb::rrc& rrc, srsran::timer_handler& timers, uint16_t rnti) { - srslte::unique_byte_buffer_t pdu; + srsran::unique_byte_buffer_t pdu; // Send RRCConnectionRequest uint8_t rrc_conn_request[] = {0x40, 0x12, 0xf6, 0xfb, 0xe2, 0xc6}; @@ -102,7 +102,7 @@ int bring_rrc_to_reconf_state(srsenb::rrc& rrc, srslte::timer_handler& timers, u 0x45, 0x25, 0xe4, 0x9a, 0x77, 0xc8, 0xd5, 0xcf, 0x26, 0x33, 0x63, 0xeb, 0x5b, 0xb9, 0xc3, 0x43, 0x9b, 0x9e, 0xb3, 0x86, 0x1f, 0xa8, 0xa7, 0xcf, 0x43, 0x54, 0x07, 0xae, 0x42, 0x2b, 0x63, 0xb9}; asn1::s1ap::s1ap_pdu_c s1ap_pdu; - srslte::byte_buffer_t byte_buf; + srsran::byte_buffer_t byte_buf; byte_buf.N_bytes = sizeof(s1ap_init_ctxt_setup_req); memcpy(byte_buf.msg, s1ap_init_ctxt_setup_req, byte_buf.N_bytes); asn1::cbit_ref bref(byte_buf.msg, byte_buf.N_bytes); @@ -133,7 +133,7 @@ int bring_rrc_to_reconf_state(srsenb::rrc& rrc, srslte::timer_handler& timers, u timers.step_all(); rrc.tti_clock(); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } } // namespace test_helpers diff --git a/srsenb/test/upper/test_helpers.h b/srsenb/test/upper/test_helpers.h index a05a46be4..afa0ca4b0 100644 --- a/srsenb/test/upper/test_helpers.h +++ b/srsenb/test/upper/test_helpers.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -15,7 +15,7 @@ #include "srsenb/src/enb_cfg_parser.h" #include "srsenb/test/common/dummy_classes.h" -#include "srslte/adt/span.h" +#include "srsran/adt/span.h" using namespace srsenb; using namespace asn1::rrc; @@ -28,7 +28,7 @@ extern srslog::basic_levels log_level; inline void usage(char* prog) { printf("Usage: %s [v] -i repository_dir\n", prog); - printf("\t-v [set srslte_verbose to debug, default none]\n"); + printf("\t-v [set srsran_verbose to debug, default none]\n"); } inline void parse_args(int argc, char** argv) @@ -64,8 +64,8 @@ public: struct ho_req_data { uint16_t rnti; uint32_t target_eci; - srslte::plmn_id_t target_plmn; - srslte::unique_byte_buffer_t rrc_container; + srsran::plmn_id_t target_plmn; + srsran::unique_byte_buffer_t rrc_container; } last_ho_required = {}; struct enb_status_transfer_info { bool status_present; @@ -75,15 +75,15 @@ public: std::vector added_erab_ids; struct ho_req_ack { uint16_t rnti; - srslte::unique_byte_buffer_t ho_cmd_pdu; + srsran::unique_byte_buffer_t ho_cmd_pdu; std::vector admitted_bearers; } last_ho_req_ack; bool send_ho_required(uint16_t rnti, uint32_t target_eci, - srslte::plmn_id_t target_plmn, - srslte::span fwd_erabs, - srslte::unique_byte_buffer_t rrc_container) final + srsran::plmn_id_t target_plmn, + srsran::span fwd_erabs, + srsran::unique_byte_buffer_t rrc_container) final { last_ho_required = ho_req_data{rnti, target_eci, target_plmn, std::move(rrc_container)}; return true; @@ -96,8 +96,8 @@ public: bool send_ho_req_ack(const asn1::s1ap::ho_request_s& msg, uint16_t rnti, uint32_t enb_cc_idx, - srslte::unique_byte_buffer_t ho_cmd, - srslte::span admitted_bearers) override + srsran::unique_byte_buffer_t ho_cmd, + srsran::span admitted_bearers) override { last_ho_req_ack.rnti = rnti; last_ho_req_ack.ho_cmd_pdu = std::move(ho_cmd); @@ -121,30 +121,30 @@ public: struct last_sdu_t { uint16_t rnti; uint32_t lcid; - srslte::unique_byte_buffer_t sdu; + srsran::unique_byte_buffer_t sdu; } last_sdu; struct lcid_cfg_t { bool enable_integrity = false; bool enable_encryption = false; - srslte::pdcp_lte_state_t state{}; - srslte::as_security_config_t sec_cfg{}; + srsran::pdcp_lte_state_t state{}; + srsran::as_security_config_t sec_cfg{}; }; std::map > bearers; - void write_sdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t sdu, int pdcp_sn) override + void write_sdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t sdu, int pdcp_sn) override { last_sdu.rnti = rnti; last_sdu.lcid = lcid; last_sdu.sdu = std::move(sdu); } - bool set_bearer_state(uint16_t rnti, uint32_t lcid, const srslte::pdcp_lte_state_t& state) override + bool set_bearer_state(uint16_t rnti, uint32_t lcid, const srsran::pdcp_lte_state_t& state) override { bearers[rnti][lcid].state = state; return true; } void enable_integrity(uint16_t rnti, uint32_t lcid) override { bearers[rnti][lcid].enable_integrity = true; } void enable_encryption(uint16_t rnti, uint32_t lcid) override { bearers[rnti][lcid].enable_encryption = true; } - void config_security(uint16_t rnti, uint32_t lcid, srslte::as_security_config_t sec_cfg_) override + void config_security(uint16_t rnti, uint32_t lcid, srsran::as_security_config_t sec_cfg_) override { bearers[rnti][lcid].sec_cfg = sec_cfg_; } @@ -156,7 +156,7 @@ public: struct ue_ctxt { int nof_pdcp_sdus = 0, reest_sdu_counter = 0; uint32_t last_lcid = 0; - srslte::unique_byte_buffer_t last_sdu; + srsran::unique_byte_buffer_t last_sdu; }; std::map ue_db; @@ -167,7 +167,7 @@ public: } } - void write_sdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t sdu) override + void write_sdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t sdu) override { ue_db[rnti].nof_pdcp_sdus++; ue_db[rnti].reest_sdu_counter++; @@ -213,7 +213,7 @@ int parse_default_cfg(rrc_cfg_t* rrc_cfg, srsenb::all_args_t& args); int parse_default_cfg_phy(rrc_cfg_t* rrc_cfg, phy_cfg_t* phy_cfg, srsenb::all_args_t& args); template -bool unpack_asn1(ASN1Type& asn1obj, srslte::const_byte_span pdu) +bool unpack_asn1(ASN1Type& asn1obj, srsran::const_byte_span pdu) { asn1::cbit_ref bref{pdu.data(), (uint32_t)pdu.size()}; if (asn1obj.unpack(bref) != asn1::SRSASN_SUCCESS) { @@ -223,14 +223,14 @@ bool unpack_asn1(ASN1Type& asn1obj, srslte::const_byte_span pdu) return true; } -inline void copy_msg_to_buffer(srslte::unique_byte_buffer_t& pdu, srslte::const_byte_span msg) +inline void copy_msg_to_buffer(srsran::unique_byte_buffer_t& pdu, srsran::const_byte_span msg) { - pdu = srslte::make_byte_buffer(); + pdu = srsran::make_byte_buffer(); memcpy(pdu->msg, msg.data(), msg.size()); pdu->N_bytes = msg.size(); } -int bring_rrc_to_reconf_state(srsenb::rrc& rrc, srslte::timer_handler& timers, uint16_t rnti); +int bring_rrc_to_reconf_state(srsenb::rrc& rrc, srsran::timer_handler& timers, uint16_t rnti); } // namespace test_helpers diff --git a/srsepc/CMakeLists.txt b/srsepc/CMakeLists.txt index ea0c4f295..b6e9df336 100644 --- a/srsepc/CMakeLists.txt +++ b/srsepc/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of diff --git a/srsepc/hdr/hss/hss.h b/srsepc/hdr/hss/hss.h index 685ab00f9..953eb2941 100644 --- a/srsepc/hdr/hss/hss.h +++ b/srsepc/hdr/hss/hss.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -19,10 +19,10 @@ #ifndef SRSEPC_HSS_H #define SRSEPC_HSS_H -#include "srslte/common/buffer_pool.h" -#include "srslte/common/standard_streams.h" -#include "srslte/interfaces/epc_interfaces.h" -#include "srslte/srslog/srslog.h" +#include "srsran/common/buffer_pool.h" +#include "srsran/common/standard_streams.h" +#include "srsran/interfaces/epc_interfaces.h" +#include "srsran/srslog/srslog.h" #include #include #include diff --git a/srsepc/hdr/mbms-gw/mbms-gw.h b/srsepc/hdr/mbms-gw/mbms-gw.h index 58ec5cf8a..76acccc75 100644 --- a/srsepc/hdr/mbms-gw/mbms-gw.h +++ b/srsepc/hdr/mbms-gw/mbms-gw.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -19,11 +19,11 @@ #ifndef MBMS_GW_H #define MBMS_GW_H -#include "srslte/asn1/gtpc.h" -#include "srslte/common/buffer_pool.h" -#include "srslte/common/threads.h" -#include "srslte/srslog/srslog.h" -#include "srslte/srslte.h" +#include "srsran/asn1/gtpc.h" +#include "srsran/common/buffer_pool.h" +#include "srsran/common/threads.h" +#include "srsran/srslog/srslog.h" +#include "srsran/srsran.h" #include namespace srsepc { @@ -48,7 +48,7 @@ struct pseudo_hdr { uint16_t udp_len; }; -class mbms_gw : public srslte::thread +class mbms_gw : public srsran::thread { public: static mbms_gw* get_instance(void); @@ -65,7 +65,7 @@ private: int init_sgi_mb_if(mbms_gw_args_t* args); int init_m1_u(mbms_gw_args_t* args); - void handle_sgi_md_pdu(srslte::byte_buffer_t* msg); + void handle_sgi_md_pdu(srsran::byte_buffer_t* msg); uint16_t in_cksum(uint16_t* iphdr, int count); /* Members */ diff --git a/srsepc/hdr/mme/mme.h b/srsepc/hdr/mme/mme.h index 185b7dcf0..ca75f134d 100644 --- a/srsepc/hdr/mme/mme.h +++ b/srsepc/hdr/mme/mme.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -20,9 +20,9 @@ #define SRSEPC_MME_H #include "s1ap.h" -#include "srslte/common/buffer_pool.h" -#include "srslte/common/standard_streams.h" -#include "srslte/common/threads.h" +#include "srsran/common/buffer_pool.h" +#include "srsran/common/standard_streams.h" +#include "srsran/common/threads.h" #include namespace srsepc { @@ -39,7 +39,7 @@ typedef struct { enum nas_timer_type type; } mme_timer_t; -class mme : public srslte::thread, public mme_interface_nas +class mme : public srsran::thread, public mme_interface_nas { public: static mme* get_instance(void); diff --git a/srsepc/hdr/mme/mme_gtpc.h b/srsepc/hdr/mme/mme_gtpc.h index 9239a608f..a76109590 100644 --- a/srsepc/hdr/mme/mme_gtpc.h +++ b/srsepc/hdr/mme/mme_gtpc.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,8 +13,8 @@ #define SRSEPC_MME_GTPC_H #include "nas.h" -#include "srslte/asn1/gtpc.h" -#include "srslte/common/buffer_pool.h" +#include "srsran/asn1/gtpc.h" +#include "srsran/common/buffer_pool.h" #include #include @@ -27,8 +27,8 @@ class mme_gtpc : public gtpc_interface_nas { public: typedef struct gtpc_ctx { - srslte::gtp_fteid_t mme_ctr_fteid; - srslte::gtp_fteid_t sgw_ctr_fteid; + srsran::gtp_fteid_t mme_ctr_fteid; + srsran::gtp_fteid_t sgw_ctr_fteid; } gtpc_ctx_t; virtual ~mme_gtpc() = default; @@ -36,18 +36,18 @@ public: static mme_gtpc* get_instance(); bool init(); - bool send_s11_pdu(const srslte::gtpc_pdu& pdu); - void handle_s11_pdu(srslte::byte_buffer_t* msg); + bool send_s11_pdu(const srsran::gtpc_pdu& pdu); + void handle_s11_pdu(srsran::byte_buffer_t* msg); virtual bool send_create_session_request(uint64_t imsi); - bool handle_create_session_response(srslte::gtpc_pdu* cs_resp_pdu); - virtual bool send_modify_bearer_request(uint64_t imsi, uint16_t erab_to_modify, srslte::gtp_fteid_t* enb_fteid); - void handle_modify_bearer_response(srslte::gtpc_pdu* mb_resp_pdu); + bool handle_create_session_response(srsran::gtpc_pdu* cs_resp_pdu); + virtual bool send_modify_bearer_request(uint64_t imsi, uint16_t erab_to_modify, srsran::gtp_fteid_t* enb_fteid); + void handle_modify_bearer_response(srsran::gtpc_pdu* mb_resp_pdu); void send_release_access_bearers_request(uint64_t imsi); virtual bool send_delete_session_request(uint64_t imsi); - bool handle_downlink_data_notification(srslte::gtpc_pdu* dl_not_pdu); - void send_downlink_data_notification_acknowledge(uint64_t imsi, enum srslte::gtpc_cause_value cause); - virtual bool send_downlink_data_notification_failure_indication(uint64_t imsi, enum srslte::gtpc_cause_value cause); + bool handle_downlink_data_notification(srsran::gtpc_pdu* dl_not_pdu); + void send_downlink_data_notification_acknowledge(uint64_t imsi, enum srsran::gtpc_cause_value cause); + virtual bool send_downlink_data_notification_failure_indication(uint64_t imsi, enum srsran::gtpc_cause_value cause); int get_s11(); diff --git a/srsepc/hdr/mme/nas.h b/srsepc/hdr/mme/nas.h index 7f11b462a..30b742d0b 100644 --- a/srsepc/hdr/mme/nas.h +++ b/srsepc/hdr/mme/nas.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,12 +13,12 @@ #ifndef SRSEPC_NAS_H #define SRSEPC_NAS_H -#include "srslte/asn1/gtpc_ies.h" -#include "srslte/asn1/liblte_mme.h" -#include "srslte/common/buffer_pool.h" -#include "srslte/common/security.h" -#include "srslte/interfaces/epc_interfaces.h" -#include "srslte/srslog/srslog.h" +#include "srsran/asn1/gtpc_ies.h" +#include "srsran/asn1/liblte_mme.h" +#include "srsran/common/buffer_pool.h" +#include "srsran/common/security.h" +#include "srsran/interfaces/epc_interfaces.h" +#include "srsran/srslog/srslog.h" #include namespace srsepc { @@ -77,7 +77,7 @@ typedef struct { uint8_t procedure_transaction_id; uint8_t attach_type; struct in_addr ue_ip; - srslte::gtpc_f_teid_ie sgw_ctrl_fteid; + srsran::gtpc_f_teid_ie sgw_ctrl_fteid; } emm_ctx_t; typedef struct { @@ -92,9 +92,9 @@ typedef struct { uint8_t erab_id; esm_state_t state; uint8_t qci; - srslte::gtpc_f_teid_ie enb_fteid; - srslte::gtpc_f_teid_ie sgw_s1u_fteid; - srslte::gtpc_pdn_address_allocation_ie pdn_addr_alloc; + srsran::gtpc_f_teid_ie enb_fteid; + srsran::gtpc_f_teid_ie sgw_s1u_fteid; + srsran::gtpc_pdn_address_allocation_ie pdn_addr_alloc; } esm_ctx_t; typedef struct { @@ -105,8 +105,8 @@ typedef struct { uint8_t xres[16]; // minimum 6, maximum 16 uint32_t dl_nas_count; uint32_t ul_nas_count; - srslte::CIPHERING_ALGORITHM_ID_ENUM cipher_algo; - srslte::INTEGRITY_ALGORITHM_ID_ENUM integ_algo; + srsran::CIPHERING_ALGORITHM_ID_ENUM cipher_algo; + srsran::INTEGRITY_ALGORITHM_ID_ENUM integ_algo; uint8_t k_nas_enc[32]; uint8_t k_nas_int[32]; uint8_t k_enb[32]; @@ -128,8 +128,8 @@ typedef struct { uint16_t paging_timer; std::string apn; std::string dns; - srslte::CIPHERING_ALGORITHM_ID_ENUM cipher_algo; - srslte::INTEGRITY_ALGORITHM_ID_ENUM integ_algo; + srsran::CIPHERING_ALGORITHM_ID_ENUM cipher_algo; + srsran::INTEGRITY_ALGORITHM_ID_ENUM integ_algo; } nas_init_t; typedef struct { @@ -151,7 +151,7 @@ public: // Attach request messages static bool handle_attach_request(uint32_t enb_ue_s1ap_id, struct sctp_sndrcvinfo* enb_sri, - srslte::byte_buffer_t* nas_rx, + srsran::byte_buffer_t* nas_rx, const nas_init_t& args, const nas_if_t& itf); @@ -167,7 +167,7 @@ public: struct sctp_sndrcvinfo* enb_sri, const LIBLTE_MME_ATTACH_REQUEST_MSG_STRUCT& attach_req, const LIBLTE_MME_PDN_CONNECTIVITY_REQUEST_MSG_STRUCT& pdn_con_req, - srslte::byte_buffer_t* nas_rx, + srsran::byte_buffer_t* nas_rx, const nas_init_t& args, const nas_if_t& itf); @@ -183,7 +183,7 @@ public: struct sctp_sndrcvinfo* enb_sri, const LIBLTE_MME_ATTACH_REQUEST_MSG_STRUCT& attach_req, const LIBLTE_MME_PDN_CONNECTIVITY_REQUEST_MSG_STRUCT& pdn_con_req, - srslte::byte_buffer_t* nas_rx, + srsran::byte_buffer_t* nas_rx, const nas_init_t& args, const nas_if_t& itf); @@ -191,7 +191,7 @@ public: static bool handle_service_request(uint32_t m_tmsi, uint32_t enb_ue_s1ap_id, struct sctp_sndrcvinfo* enb_sri, - srslte::byte_buffer_t* nas_rx, + srsran::byte_buffer_t* nas_rx, const nas_init_t& args, const nas_if_t& itf); @@ -199,7 +199,7 @@ public: static bool handle_detach_request(uint32_t m_tmsi, uint32_t enb_ue_s1ap_id, struct sctp_sndrcvinfo* enb_sri, - srslte::byte_buffer_t* nas_rx, + srsran::byte_buffer_t* nas_rx, const nas_init_t& args, const nas_if_t& itf); @@ -207,38 +207,38 @@ public: static bool handle_tracking_area_update_request(uint32_t m_tmsi, uint32_t enb_ue_s1ap_id, struct sctp_sndrcvinfo* enb_sri, - srslte::byte_buffer_t* nas_rx, + srsran::byte_buffer_t* nas_rx, const nas_init_t& args, const nas_if_t& itf); /* Uplink NAS messages handling */ - bool handle_attach_request(srslte::byte_buffer_t* nas_rx); - bool handle_authentication_response(srslte::byte_buffer_t* nas_rx); - bool handle_security_mode_complete(srslte::byte_buffer_t* nas_rx); - bool handle_attach_complete(srslte::byte_buffer_t* nas_rx); - bool handle_esm_information_response(srslte::byte_buffer_t* nas_rx); - bool handle_identity_response(srslte::byte_buffer_t* nas_rx); - bool handle_tracking_area_update_request(srslte::byte_buffer_t* nas_rx); - bool handle_authentication_failure(srslte::byte_buffer_t* nas_rx); - bool handle_detach_request(srslte::byte_buffer_t* nas_rx); + bool handle_attach_request(srsran::byte_buffer_t* nas_rx); + bool handle_authentication_response(srsran::byte_buffer_t* nas_rx); + bool handle_security_mode_complete(srsran::byte_buffer_t* nas_rx); + bool handle_attach_complete(srsran::byte_buffer_t* nas_rx); + bool handle_esm_information_response(srsran::byte_buffer_t* nas_rx); + bool handle_identity_response(srsran::byte_buffer_t* nas_rx); + bool handle_tracking_area_update_request(srsran::byte_buffer_t* nas_rx); + bool handle_authentication_failure(srsran::byte_buffer_t* nas_rx); + bool handle_detach_request(srsran::byte_buffer_t* nas_rx); /* Downlink NAS messages packing */ - bool pack_authentication_request(srslte::byte_buffer_t* nas_buffer); - bool pack_authentication_reject(srslte::byte_buffer_t* nas_buffer); - bool pack_security_mode_command(srslte::byte_buffer_t* nas_buffer); - bool pack_esm_information_request(srslte::byte_buffer_t* nas_buffer); - bool pack_identity_request(srslte::byte_buffer_t* nas_buffer); - bool pack_emm_information(srslte::byte_buffer_t* nas_buffer); - bool pack_service_reject(srslte::byte_buffer_t* nas_buffer, uint8_t emm_cause); - bool pack_tracking_area_update_reject(srslte::byte_buffer_t* nas_buffer, uint8_t emm_cause); - bool pack_attach_accept(srslte::byte_buffer_t* nas_buffer); + bool pack_authentication_request(srsran::byte_buffer_t* nas_buffer); + bool pack_authentication_reject(srsran::byte_buffer_t* nas_buffer); + bool pack_security_mode_command(srsran::byte_buffer_t* nas_buffer); + bool pack_esm_information_request(srsran::byte_buffer_t* nas_buffer); + bool pack_identity_request(srsran::byte_buffer_t* nas_buffer); + bool pack_emm_information(srsran::byte_buffer_t* nas_buffer); + bool pack_service_reject(srsran::byte_buffer_t* nas_buffer, uint8_t emm_cause); + bool pack_tracking_area_update_reject(srsran::byte_buffer_t* nas_buffer, uint8_t emm_cause); + bool pack_attach_accept(srsran::byte_buffer_t* nas_buffer); /* Security functions */ - bool integrity_check(srslte::byte_buffer_t* pdu); - bool short_integrity_check(srslte::byte_buffer_t* pdu); - void integrity_generate(srslte::byte_buffer_t* pdu, uint8_t* mac); - void cipher_decrypt(srslte::byte_buffer_t* pdu); - void cipher_encrypt(srslte::byte_buffer_t* pdu); + bool integrity_check(srsran::byte_buffer_t* pdu); + bool short_integrity_check(srsran::byte_buffer_t* pdu); + void integrity_generate(srsran::byte_buffer_t* pdu, uint8_t* mac); + void cipher_decrypt(srsran::byte_buffer_t* pdu); + void cipher_encrypt(srsran::byte_buffer_t* pdu); /*Timer functions*/ bool start_timer(enum nas_timer_type type); diff --git a/srsepc/hdr/mme/s1ap.h b/srsepc/hdr/mme/s1ap.h index d70d39c65..2cbd125b3 100644 --- a/srsepc/hdr/mme/s1ap.h +++ b/srsepc/hdr/mme/s1ap.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -20,14 +20,14 @@ #include "s1ap_nas_transport.h" #include "s1ap_paging.h" #include "srsepc/hdr/hss/hss.h" -#include "srslte/asn1/gtpc.h" -#include "srslte/asn1/liblte_mme.h" -#include "srslte/asn1/s1ap.h" -#include "srslte/common/common.h" -#include "srslte/common/s1ap_pcap.h" -#include "srslte/common/standard_streams.h" -#include "srslte/interfaces/epc_interfaces.h" -#include "srslte/srslog/srslog.h" +#include "srsran/asn1/gtpc.h" +#include "srsran/asn1/liblte_mme.h" +#include "srsran/asn1/s1ap.h" +#include "srsran/common/common.h" +#include "srsran/common/s1ap_pcap.h" +#include "srsran/common/standard_streams.h" +#include "srsran/interfaces/epc_interfaces.h" +#include "srsran/srslog/srslog.h" #include #include #include @@ -58,7 +58,7 @@ public: void delete_enb_ctx(int32_t assoc_id); bool s1ap_tx_pdu(const s1ap_pdu_t& pdu, struct sctp_sndrcvinfo* enb_sri); - void handle_s1ap_rx_pdu(srslte::byte_buffer_t* pdu, struct sctp_sndrcvinfo* enb_sri); + void handle_s1ap_rx_pdu(srsran::byte_buffer_t* pdu, struct sctp_sndrcvinfo* enb_sri); void handle_initiating_message(const asn1::s1ap::init_msg_s& msg, struct sctp_sndrcvinfo* enb_sri); void handle_successful_outcome(const asn1::s1ap::successful_outcome_s& msg); @@ -109,11 +109,11 @@ public: virtual bool send_erab_modify_request(uint32_t enb_ue_s1ap_id, uint32_t mme_ue_s1ap_id, std::map erabs_to_be_modified, - srslte::byte_buffer_t* nas_msg, + srsran::byte_buffer_t* nas_msg, struct sctp_sndrcvinfo enb_sri); virtual bool send_downlink_nas_transport(uint32_t enb_ue_s1ap_id, uint32_t mme_ue_s1ap_id, - srslte::byte_buffer_t* nas_msg, + srsran::byte_buffer_t* nas_msg, struct sctp_sndrcvinfo enb_sri); virtual bool send_paging(uint64_t imsi, uint16_t erab_to_setup); @@ -143,7 +143,7 @@ private: // PCAP bool m_pcap_enable; - srslte::s1ap_pcap m_pcap; + srsran::s1ap_pcap m_pcap; }; inline uint32_t s1ap::get_plmn() diff --git a/srsepc/hdr/mme/s1ap_common.h b/srsepc/hdr/mme/s1ap_common.h index a133cc4cf..dfd1bec1e 100644 --- a/srsepc/hdr/mme/s1ap_common.h +++ b/srsepc/hdr/mme/s1ap_common.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,10 +13,10 @@ #ifndef SRSEPC_S1AP_COMMON_H #define SRSEPC_S1AP_COMMON_H -#include "srslte/asn1/gtpc_ies.h" -#include "srslte/asn1/liblte_mme.h" -#include "srslte/asn1/s1ap.h" -#include "srslte/common/security.h" +#include "srsran/asn1/gtpc_ies.h" +#include "srsran/asn1/liblte_mme.h" +#include "srsran/asn1/s1ap.h" +#include "srsran/common/security.h" #include #include @@ -38,8 +38,8 @@ typedef struct { std::string mme_apn; bool pcap_enable; std::string pcap_filename; - srslte::CIPHERING_ALGORITHM_ID_ENUM encryption_algo; - srslte::INTEGRITY_ALGORITHM_ID_ENUM integrity_algo; + srsran::CIPHERING_ALGORITHM_ID_ENUM encryption_algo; + srsran::INTEGRITY_ALGORITHM_ID_ENUM integrity_algo; } s1ap_args_t; typedef struct { diff --git a/srsepc/hdr/mme/s1ap_ctx_mngmt_proc.h b/srsepc/hdr/mme/s1ap_ctx_mngmt_proc.h index ad227d1fc..bb046847e 100644 --- a/srsepc/hdr/mme/s1ap_ctx_mngmt_proc.h +++ b/srsepc/hdr/mme/s1ap_ctx_mngmt_proc.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -14,9 +14,9 @@ #include "mme_gtpc.h" #include "s1ap_common.h" -#include "srslte/asn1/s1ap.h" -#include "srslte/common/buffer_pool.h" -#include "srslte/common/common.h" +#include "srsran/asn1/s1ap.h" +#include "srsran/common/buffer_pool.h" +#include "srsran/common/common.h" namespace srsepc { diff --git a/srsepc/hdr/mme/s1ap_erab_mngmt_proc.h b/srsepc/hdr/mme/s1ap_erab_mngmt_proc.h index 9e5dd6ce7..f5edc3f65 100644 --- a/srsepc/hdr/mme/s1ap_erab_mngmt_proc.h +++ b/srsepc/hdr/mme/s1ap_erab_mngmt_proc.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -14,9 +14,9 @@ #include "mme_gtpc.h" #include "s1ap_common.h" -#include "srslte/asn1/s1ap.h" -#include "srslte/common/buffer_pool.h" -#include "srslte/common/common.h" +#include "srsran/asn1/s1ap.h" +#include "srsran/common/buffer_pool.h" +#include "srsran/common/common.h" #include namespace srsepc { @@ -39,7 +39,7 @@ public: bool send_erab_modify_request(uint32_t enb_ue_s1ap_id, uint32_t mme_ue_s1ap_id, std::map erabs_to_modify, - srslte::byte_buffer_t* nas_msg, + srsran::byte_buffer_t* nas_msg, struct sctp_sndrcvinfo enb_sri); bool handle_erab_release_response(const asn1::s1ap::init_context_setup_resp_s& in_ctxt_resp); diff --git a/srsepc/hdr/mme/s1ap_mngmt_proc.h b/srsepc/hdr/mme/s1ap_mngmt_proc.h index 7f5936fe2..05d2b3b5a 100644 --- a/srsepc/hdr/mme/s1ap_mngmt_proc.h +++ b/srsepc/hdr/mme/s1ap_mngmt_proc.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,9 +13,9 @@ #define SRSEPC_S1AP_MNGMT_PROC_H #include "s1ap_common.h" -#include "srslte/asn1/s1ap.h" -#include "srslte/common/common.h" -#include "srslte/srslog/srslog.h" +#include "srsran/asn1/s1ap.h" +#include "srsran/common/common.h" +#include "srsran/srslog/srslog.h" namespace srsepc { diff --git a/srsepc/hdr/mme/s1ap_nas_transport.h b/srsepc/hdr/mme/s1ap_nas_transport.h index 5d71c0242..44057b747 100644 --- a/srsepc/hdr/mme/s1ap_nas_transport.h +++ b/srsepc/hdr/mme/s1ap_nas_transport.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -15,9 +15,9 @@ #include "mme_gtpc.h" #include "s1ap_common.h" #include "srsepc/hdr/hss/hss.h" -#include "srslte/asn1/gtpc.h" -#include "srslte/asn1/s1ap.h" -#include "srslte/common/buffer_pool.h" +#include "srsran/asn1/gtpc.h" +#include "srsran/asn1/s1ap.h" +#include "srsran/common/buffer_pool.h" namespace srsepc { @@ -33,7 +33,7 @@ public: bool handle_uplink_nas_transport(const asn1::s1ap::ul_nas_transport_s& ul_xport, struct sctp_sndrcvinfo* enb_sri); bool send_downlink_nas_transport(uint32_t enb_ue_s1ap_id, uint32_t mme_ue_s1ap_id, - srslte::byte_buffer_t* nas_msg, + srsran::byte_buffer_t* nas_msg, struct sctp_sndrcvinfo enb_sri); private: diff --git a/srsepc/hdr/mme/s1ap_paging.h b/srsepc/hdr/mme/s1ap_paging.h index bfdfb32f5..bb13ce053 100644 --- a/srsepc/hdr/mme/s1ap_paging.h +++ b/srsepc/hdr/mme/s1ap_paging.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,9 +13,9 @@ #define SRSEPC_S1AP_PAGING_H #include "s1ap_common.h" -#include "srslte/common/buffer_pool.h" -#include "srslte/common/common.h" -#include "srslte/srslog/srslog.h" +#include "srsran/common/buffer_pool.h" +#include "srsran/common/common.h" +#include "srsran/srslog/srslog.h" namespace srsepc { diff --git a/srsepc/hdr/spgw/gtpc.h b/srsepc/hdr/spgw/gtpc.h index f79ea9b8b..ff04f4179 100644 --- a/srsepc/hdr/spgw/gtpc.h +++ b/srsepc/hdr/spgw/gtpc.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,10 +13,10 @@ #define SRSEPC_GTPC_H #include "srsepc/hdr/spgw/spgw.h" -#include "srslte/asn1/gtpc.h" -#include "srslte/common/standard_streams.h" -#include "srslte/interfaces/epc_interfaces.h" -#include "srslte/srslog/srslog.h" +#include "srsran/asn1/gtpc.h" +#include "srsran/common/standard_streams.h" +#include "srsran/interfaces/epc_interfaces.h" +#include "srsran/srslog/srslog.h" #include #include @@ -40,27 +40,27 @@ public: uint64_t get_new_user_teid(); in_addr_t get_new_ue_ipv4(uint64_t imsi); - void handle_s11_pdu(srslte::byte_buffer_t* msg); - bool send_s11_pdu(const srslte::gtpc_pdu& pdu); + void handle_s11_pdu(srsran::byte_buffer_t* msg); + bool send_s11_pdu(const srsran::gtpc_pdu& pdu); - void handle_create_session_request(const srslte::gtpc_create_session_request& cs_req); - void handle_modify_bearer_request(const srslte::gtpc_header& mb_req_hdr, - const srslte::gtpc_modify_bearer_request& mb_req); - void handle_delete_session_request(const srslte::gtpc_header& header, - const srslte::gtpc_delete_session_request& del_req); - void handle_release_access_bearers_request(const srslte::gtpc_header& header, - const srslte::gtpc_release_access_bearers_request& rel_req); + void handle_create_session_request(const srsran::gtpc_create_session_request& cs_req); + void handle_modify_bearer_request(const srsran::gtpc_header& mb_req_hdr, + const srsran::gtpc_modify_bearer_request& mb_req); + void handle_delete_session_request(const srsran::gtpc_header& header, + const srsran::gtpc_delete_session_request& del_req); + void handle_release_access_bearers_request(const srsran::gtpc_header& header, + const srsran::gtpc_release_access_bearers_request& rel_req); void - handle_downlink_data_notification_acknowledge(const srslte::gtpc_header& header, - const srslte::gtpc_downlink_data_notification_acknowledge& not_ack); + handle_downlink_data_notification_acknowledge(const srsran::gtpc_header& header, + const srsran::gtpc_downlink_data_notification_acknowledge& not_ack); void handle_downlink_data_notification_failure_indication( - const srslte::gtpc_header& header, - const srslte::gtpc_downlink_data_notification_failure_indication& not_fail); + const srsran::gtpc_header& header, + const srsran::gtpc_downlink_data_notification_failure_indication& not_fail); - virtual bool queue_downlink_packet(uint32_t spgw_ctr_teid, srslte::unique_byte_buffer_t msg) override; + virtual bool queue_downlink_packet(uint32_t spgw_ctr_teid, srsran::unique_byte_buffer_t msg) override; virtual bool send_downlink_data_notification(uint32_t spgw_ctr_teid) override; - spgw_tunnel_ctx_t* create_gtpc_ctx(const srslte::gtpc_create_session_request& cs_req); + spgw_tunnel_ctx_t* create_gtpc_ctx(const srsran::gtpc_create_session_request& cs_req); bool delete_gtpc_ctx(uint32_t ctrl_teid); bool free_all_queued_packets(spgw_tunnel_ctx_t* tunnel_ctx); diff --git a/srsepc/hdr/spgw/gtpu.h b/srsepc/hdr/spgw/gtpu.h index 9bfd2fa16..7a7f0d1f2 100644 --- a/srsepc/hdr/spgw/gtpu.h +++ b/srsepc/hdr/spgw/gtpu.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -14,11 +14,11 @@ #define SRSEPC_GTPU_H #include "srsepc/hdr/spgw/spgw.h" -#include "srslte/asn1/gtpc.h" -#include "srslte/common/buffer_pool.h" -#include "srslte/common/standard_streams.h" -#include "srslte/interfaces/epc_interfaces.h" -#include "srslte/srslog/srslog.h" +#include "srsran/asn1/gtpc.h" +#include "srsran/common/buffer_pool.h" +#include "srsran/common/standard_streams.h" +#include "srsran/interfaces/epc_interfaces.h" +#include "srsran/srslog/srslog.h" #include #include @@ -37,17 +37,17 @@ public: int get_sgi(); int get_s1u(); - void handle_sgi_pdu(srslte::unique_byte_buffer_t msg); - void handle_s1u_pdu(srslte::byte_buffer_t* msg); - void send_s1u_pdu(srslte::gtp_fteid_t enb_fteid, srslte::byte_buffer_t* msg); + void handle_sgi_pdu(srsran::unique_byte_buffer_t msg); + void handle_s1u_pdu(srsran::byte_buffer_t* msg); + void send_s1u_pdu(srsran::gtp_fteid_t enb_fteid, srsran::byte_buffer_t* msg); virtual in_addr_t get_s1u_addr(); - virtual bool modify_gtpu_tunnel(in_addr_t ue_ipv4, srslte::gtp_fteid_t dw_user_fteid, uint32_t up_ctr_fteid); + virtual bool modify_gtpu_tunnel(in_addr_t ue_ipv4, srsran::gtp_fteid_t dw_user_fteid, uint32_t up_ctr_fteid); virtual bool delete_gtpu_tunnel(in_addr_t ue_ipv4); virtual bool delete_gtpc_tunnel(in_addr_t ue_ipv4); - virtual void send_all_queued_packets(srslte::gtp_fteid_t dw_user_fteid, - std::queue& pkt_queue); + virtual void send_all_queued_packets(srsran::gtp_fteid_t dw_user_fteid, + std::queue& pkt_queue); spgw* m_spgw; gtpc_interface_gtpu* m_gtpc; @@ -59,7 +59,7 @@ public: int m_s1u; sockaddr_in m_s1u_addr; - std::map m_ip_to_usr_teid; // Map IP to User-plane TEID for downlink traffic + std::map m_ip_to_usr_teid; // Map IP to User-plane TEID for downlink traffic std::map m_ip_to_ctr_teid; // IP to control TEID map. Important to check if // UE is attached without an active user-plane // for downlink notifications. diff --git a/srsepc/hdr/spgw/spgw.h b/srsepc/hdr/spgw/spgw.h index 5a1138bb3..609237f0c 100644 --- a/srsepc/hdr/spgw/spgw.h +++ b/srsepc/hdr/spgw/spgw.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -19,10 +19,10 @@ #ifndef SRSEPC_SPGW_H #define SRSEPC_SPGW_H -#include "srslte/asn1/gtpc.h" -#include "srslte/common/buffer_pool.h" -#include "srslte/common/threads.h" -#include "srslte/srslog/srslog.h" +#include "srsran/asn1/gtpc.h" +#include "srsran/common/buffer_pool.h" +#include "srsran/common/threads.h" +#include "srsran/srslog/srslog.h" #include #include @@ -43,15 +43,15 @@ typedef struct spgw_tunnel_ctx { uint64_t imsi; in_addr_t ue_ipv4; uint8_t ebi; - srslte::gtp_fteid_t up_ctrl_fteid; - srslte::gtp_fteid_t up_user_fteid; - srslte::gtp_fteid_t dw_ctrl_fteid; - srslte::gtp_fteid_t dw_user_fteid; + srsran::gtp_fteid_t up_ctrl_fteid; + srsran::gtp_fteid_t up_user_fteid; + srsran::gtp_fteid_t dw_ctrl_fteid; + srsran::gtp_fteid_t dw_user_fteid; bool paging_pending; - std::queue paging_queue; + std::queue paging_queue; } spgw_tunnel_ctx_t; -class spgw : public srslte::thread +class spgw : public srsran::thread { class gtpc; class gtpu; @@ -68,7 +68,7 @@ private: virtual ~spgw(); static spgw* m_instance; - spgw_tunnel_ctx_t* create_gtp_ctx(struct srslte::gtpc_create_session_request* cs_req); + spgw_tunnel_ctx_t* create_gtp_ctx(struct srsran::gtpc_create_session_request* cs_req); bool delete_gtp_ctx(uint32_t ctrl_teid); bool m_running; diff --git a/srsepc/src/CMakeLists.txt b/srsepc/src/CMakeLists.txt index ddd5195a5..07c15e79f 100644 --- a/srsepc/src/CMakeLists.txt +++ b/srsepc/src/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -27,8 +27,8 @@ target_link_libraries( srsepc srsepc_mme srsepc_hss srsepc_sgw s1ap_asn1 - srslte_upper - srslte_common + srsran_upper + srsran_common srslog ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} @@ -38,8 +38,8 @@ target_link_libraries( srsepc srsepc_mme add_executable(srsmbms mbms-gw/main.cc ) target_link_libraries(srsmbms srsepc_mbms_gw - srslte_upper - srslte_common + srsran_upper + srsran_common srslog ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} diff --git a/srsepc/src/hss/CMakeLists.txt b/srsepc/src/hss/CMakeLists.txt index 3a5eb89c6..7c7e9dd63 100644 --- a/srsepc/src/hss/CMakeLists.txt +++ b/srsepc/src/hss/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of diff --git a/srsepc/src/hss/hss.cc b/srsepc/src/hss/hss.cc index 8c6558c3a..ceae22418 100644 --- a/srsepc/src/hss/hss.cc +++ b/srsepc/src/hss/hss.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,7 +10,7 @@ * */ #include "srsepc/hdr/hss/hss.h" -#include "srslte/common/security.h" +#include "srsran/common/security.h" #include #include // for printing uint64_t #include @@ -60,7 +60,7 @@ int hss::init(hss_args_t* hss_args) /*Read user information from DB*/ if (read_db_file(hss_args->db_file) == false) { - srslte::console("Error reading user database file %s\n", hss_args->db_file.c_str()); + srsran::console("Error reading user database file %s\n", hss_args->db_file.c_str()); return -1; } @@ -70,7 +70,7 @@ int hss::init(hss_args_t* hss_args) db_file = hss_args->db_file; m_logger.info("HSS Initialized. DB file %s, MCC: %d, MNC: %d", hss_args->db_file.c_str(), mcc, mnc); - srslte::console("HSS Initialized.\n"); + srsran::console("HSS Initialized.\n"); return 0; } @@ -99,9 +99,9 @@ bool hss::read_db_file(std::string db_filename) m_logger.error("Error parsing UE database. Wrong number of columns in .csv"); m_logger.error("Columns: %zd, Expected %d.", split.size(), column_size); - srslte::console("\nError parsing UE database. Wrong number of columns in user database CSV.\n"); - srslte::console("Perhaps you are using an old user_db.csv?\n"); - srslte::console("See 'srsepc/user_db.csv.example' for an example.\n\n"); + srsran::console("\nError parsing UE database. Wrong number of columns in user database CSV.\n"); + srsran::console("Perhaps you are using an old user_db.csv?\n"); + srsran::console("See 'srsepc/user_db.csv.example' for an example.\n\n"); return false; } std::unique_ptr ue_ctx = std::unique_ptr(new hss_ue_ctx_t); @@ -119,7 +119,7 @@ bool hss::read_db_file(std::string db_filename) if (split[4] == std::string("op")) { ue_ctx->op_configured = true; get_uint_vec_from_hex_str(split[5], ue_ctx->op, 16); - srslte::compute_opc(ue_ctx->key, ue_ctx->op, ue_ctx->opc); + srsran::compute_opc(ue_ctx->key, ue_ctx->op, ue_ctx->opc); } else if (split[4] == std::string("opc")) { ue_ctx->op_configured = false; get_uint_vec_from_hex_str(split[5], ue_ctx->opc, 16); @@ -250,7 +250,7 @@ bool hss::gen_auth_info_answer(uint64_t imsi, uint8_t* k_asme, uint8_t* autn, ui m_logger.debug("Generating AUTH info answer"); hss_ue_ctx_t* ue_ctx = get_ue_ctx(imsi); if (ue_ctx == nullptr) { - srslte::console("User not found at HSS. IMSI: %015" PRIu64 "\n", imsi); + srsran::console("User not found at HSS. IMSI: %015" PRIu64 "\n", imsi); m_logger.error("User not found at HSS. IMSI: %015" PRIu64 "", imsi); return false; } @@ -287,7 +287,7 @@ void hss::gen_auth_info_answer_milenage(hss_ue_ctx_t* ue_ctx, gen_rand(rand); - srslte::security_milenage_f2345(k, opc, rand, xres, ck, ik, ak); + srsran::security_milenage_f2345(k, opc, rand, xres, ck, ik, ak); m_logger.debug(k, 16, "User Key : "); m_logger.debug(opc, 16, "User OPc : "); @@ -297,13 +297,13 @@ void hss::gen_auth_info_answer_milenage(hss_ue_ctx_t* ue_ctx, m_logger.debug(ik, 16, "User IK: "); m_logger.debug(ak, 6, "User AK: "); - srslte::security_milenage_f1(k, opc, rand, sqn, amf, mac); + srsran::security_milenage_f1(k, opc, rand, sqn, amf, mac); m_logger.debug(sqn, 6, "User SQN : "); m_logger.debug(mac, 8, "User MAC : "); // Generate K_asme - srslte::security_generate_k_asme(ck, ik, ak, sqn, mcc, mnc, k_asme); + srsran::security_generate_k_asme(ck, ik, ak, sqn, mcc, mnc, k_asme); m_logger.debug("User MCC : %x MNC : %x ", mcc, mnc); m_logger.debug(k_asme, 32, "User k_asme : "); @@ -397,7 +397,7 @@ void hss::gen_auth_info_answer_xor(hss_ue_ctx_t* ue_ctx, uint8_t* k_asme, uint8_ } // Generate K_asme - srslte::security_generate_k_asme(ck, ik, ak, sqn, mcc, mnc, k_asme); + srsran::security_generate_k_asme(ck, ik, ak, sqn, mcc, mnc, k_asme); m_logger.debug("User MCC : %x MNC : %x ", mcc, mnc); m_logger.debug(k_asme, 32, "User k_asme : "); @@ -425,7 +425,7 @@ bool hss::gen_update_loc_answer(uint64_t imsi, uint8_t* qci) std::map >::iterator ue_ctx_it = m_imsi_to_ue_ctx.find(imsi); if (ue_ctx_it == m_imsi_to_ue_ctx.end()) { m_logger.info("User not found. IMSI: %015" PRIu64 "", imsi); - srslte::console("User not found at HSS. IMSI: %015" PRIu64 "\n", imsi); + srsran::console("User not found at HSS. IMSI: %015" PRIu64 "\n", imsi); return false; } const std::unique_ptr& ue_ctx = ue_ctx_it->second; @@ -439,7 +439,7 @@ bool hss::resync_sqn(uint64_t imsi, uint8_t* auts) m_logger.debug("Re-syncing SQN"); hss_ue_ctx_t* ue_ctx = get_ue_ctx(imsi); if (ue_ctx == nullptr) { - srslte::console("User not found at HSS. IMSI: %015" PRIu64 "\n", imsi); + srsran::console("User not found at HSS. IMSI: %015" PRIu64 "\n", imsi); m_logger.error("User not found at HSS. IMSI: %015" PRIu64 "", imsi); return false; } @@ -460,7 +460,7 @@ bool hss::resync_sqn(uint64_t imsi, uint8_t* auts) void hss::resync_sqn_xor(hss_ue_ctx_t* ue_ctx, uint8_t* auts) { m_logger.error("XOR SQN synchronization not supported yet"); - srslte::console("XOR SQNs synchronization not supported yet\n"); + srsran::console("XOR SQNs synchronization not supported yet\n"); return; } @@ -496,7 +496,7 @@ void hss::resync_sqn_milenage(hss_ue_ctx_t* ue_ctx, uint8_t* auts) m_logger.debug(sqn_ms_xor_ak, 6, "SQN xor AK : "); m_logger.debug(mac_s, 8, "MAC : "); - srslte::security_milenage_f5_star(k, opc, last_rand, ak); + srsran::security_milenage_f5_star(k, opc, last_rand, ak); m_logger.debug(ak, 6, "Resynch AK : "); uint8_t sqn_ms[6]; @@ -510,7 +510,7 @@ void hss::resync_sqn_milenage(hss_ue_ctx_t* ue_ctx, uint8_t* auts) uint8_t dummy_amf[2] = {}; - srslte::security_milenage_f1_star(k, opc, last_rand, sqn_ms, dummy_amf, mac_s_tmp); + srsran::security_milenage_f1_star(k, opc, last_rand, sqn_ms, dummy_amf, mac_s_tmp); m_logger.debug(mac_s_tmp, 8, "MAC calc : "); ue_ctx->set_sqn(sqn_ms); diff --git a/srsepc/src/main.cc b/srsepc/src/main.cc index 38731a628..07db711d9 100644 --- a/srsepc/src/main.cc +++ b/srsepc/src/main.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,14 +13,14 @@ #include "srsepc/hdr/hss/hss.h" #include "srsepc/hdr/mme/mme.h" #include "srsepc/hdr/spgw/spgw.h" -#include "srslte/build_info.h" -#include "srslte/common/bcd_helpers.h" -#include "srslte/common/common_helper.h" -#include "srslte/common/config_file.h" -#include "srslte/common/crash_handler.h" -#include "srslte/common/signal_handler.h" -#include "srslte/srslog/srslog.h" -#include "srslte/srslte.h" +#include "srsran/build_info.h" +#include "srsran/common/bcd_helpers.h" +#include "srsran/common/common_helper.h" +#include "srsran/common/config_file.h" +#include "srsran/common/crash_handler.h" +#include "srsran/common/signal_handler.h" +#include "srsran/srslog/srslog.h" +#include "srsran/srsran.h" #include #include @@ -210,49 +210,49 @@ void parse_args(all_args_t* args, int argc, char* argv[]) } // Convert MCC/MNC strings - if (!srslte::string_to_mcc(mcc, &args->mme_args.s1ap_args.mcc)) { + if (!srsran::string_to_mcc(mcc, &args->mme_args.s1ap_args.mcc)) { cout << "Error parsing mme.mcc:" << mcc << " - must be a 3-digit string." << endl; } - if (!srslte::string_to_mnc(mnc, &args->mme_args.s1ap_args.mnc)) { + if (!srsran::string_to_mnc(mnc, &args->mme_args.s1ap_args.mnc)) { cout << "Error parsing mme.mnc:" << mnc << " - must be a 2 or 3-digit string." << endl; } // Convert MCC/MNC strings - if (!srslte::string_to_mcc(mcc, &args->hss_args.mcc)) { + if (!srsran::string_to_mcc(mcc, &args->hss_args.mcc)) { cout << "Error parsing mme.mcc:" << mcc << " - must be a 3-digit string." << endl; } - if (!srslte::string_to_mnc(mnc, &args->hss_args.mnc)) { + if (!srsran::string_to_mnc(mnc, &args->hss_args.mnc)) { cout << "Error parsing mme.mnc:" << mnc << " - must be a 2 or 3-digit string." << endl; } std::transform(encryption_algo.begin(), encryption_algo.end(), encryption_algo.begin(), ::tolower); if (encryption_algo == "eea0") { - args->mme_args.s1ap_args.encryption_algo = srslte::CIPHERING_ALGORITHM_ID_EEA0; + args->mme_args.s1ap_args.encryption_algo = srsran::CIPHERING_ALGORITHM_ID_EEA0; } else if (encryption_algo == "eea1") { - args->mme_args.s1ap_args.encryption_algo = srslte::CIPHERING_ALGORITHM_ID_128_EEA1; + args->mme_args.s1ap_args.encryption_algo = srsran::CIPHERING_ALGORITHM_ID_128_EEA1; } else if (encryption_algo == "eea2") { - args->mme_args.s1ap_args.encryption_algo = srslte::CIPHERING_ALGORITHM_ID_128_EEA2; + args->mme_args.s1ap_args.encryption_algo = srsran::CIPHERING_ALGORITHM_ID_128_EEA2; } else if (encryption_algo == "eea3") { - args->mme_args.s1ap_args.encryption_algo = srslte::CIPHERING_ALGORITHM_ID_128_EEA3; + args->mme_args.s1ap_args.encryption_algo = srsran::CIPHERING_ALGORITHM_ID_128_EEA3; } else { - args->mme_args.s1ap_args.encryption_algo = srslte::CIPHERING_ALGORITHM_ID_EEA0; + args->mme_args.s1ap_args.encryption_algo = srsran::CIPHERING_ALGORITHM_ID_EEA0; cout << "Error parsing mme.encryption_algo:" << encryption_algo << " - must be EEA0, EEA1, EEA2 or EEA3." << endl; cout << "Using default mme.encryption_algo: EEA0" << endl; } std::transform(integrity_algo.begin(), integrity_algo.end(), integrity_algo.begin(), ::tolower); if (integrity_algo == "eia0") { - args->mme_args.s1ap_args.integrity_algo = srslte::INTEGRITY_ALGORITHM_ID_EIA0; + args->mme_args.s1ap_args.integrity_algo = srsran::INTEGRITY_ALGORITHM_ID_EIA0; cout << "Warning parsing mme.integrity_algo:" << encryption_algo << " - EIA0 will not supported by UEs use EIA1 or EIA2" << endl; } else if (integrity_algo == "eia1") { - args->mme_args.s1ap_args.integrity_algo = srslte::INTEGRITY_ALGORITHM_ID_128_EIA1; + args->mme_args.s1ap_args.integrity_algo = srsran::INTEGRITY_ALGORITHM_ID_128_EIA1; } else if (integrity_algo == "eia2") { - args->mme_args.s1ap_args.integrity_algo = srslte::INTEGRITY_ALGORITHM_ID_128_EIA2; + args->mme_args.s1ap_args.integrity_algo = srsran::INTEGRITY_ALGORITHM_ID_128_EIA2; } else if (integrity_algo == "eia3") { - args->mme_args.s1ap_args.integrity_algo = srslte::INTEGRITY_ALGORITHM_ID_128_EIA3; + args->mme_args.s1ap_args.integrity_algo = srsran::INTEGRITY_ALGORITHM_ID_128_EIA3; } else { - args->mme_args.s1ap_args.integrity_algo = srslte::INTEGRITY_ALGORITHM_ID_128_EIA1; + args->mme_args.s1ap_args.integrity_algo = srsran::INTEGRITY_ALGORITHM_ID_128_EIA1; cout << "Error parsing mme.integrity_algo:" << encryption_algo << " - must be EIA0, EIA1, EIA2 or EIA3." << endl; cout << "Using default mme.integrity_algo: EIA1" << endl; } @@ -329,15 +329,15 @@ void parse_args(all_args_t* args, int argc, char* argv[]) std::string get_build_mode() { - return std::string(srslte_get_build_mode()); + return std::string(srsran_get_build_mode()); } std::string get_build_info() { - if (std::string(srslte_get_build_info()).find(" ") != std::string::npos) { - return std::string(srslte_get_version()); + if (std::string(srsran_get_build_info()).find(" ") != std::string::npos) { + return std::string(srsran_get_version()); } - return std::string(srslte_get_build_info()); + return std::string(srsran_get_build_info()); } std::string get_build_string() @@ -349,13 +349,13 @@ std::string get_build_string() int main(int argc, char* argv[]) { - srslte_register_signal_handler(); + srsran_register_signal_handler(); // print build info cout << endl << get_build_string() << endl; cout << endl << "--- Software Radio Systems EPC ---" << endl << endl; - srslte_debug_handle_crash(argc, argv); + srsran_debug_handle_crash(argc, argv); all_args_t args; parse_args(&args, argc, argv); @@ -364,11 +364,11 @@ int main(int argc, char* argv[]) log_sink = (args.log_args.filename == "stdout") ? srslog::create_stdout_sink() : srslog::create_file_sink(args.log_args.filename); if (!log_sink) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } srslog::log_channel* chan = srslog::create_log_channel("main_channel", *log_sink); if (!chan) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } srslog::set_default_sink(*log_sink); @@ -380,7 +380,7 @@ int main(int argc, char* argv[]) epc_logger.info("\n\n%s\n--- Software Radio Systems EPC log ---\n\n", get_build_string().c_str()); } - srslte::log_args(argc, argv, "EPC"); + srsran::log_args(argc, argv, "EPC"); srslog::basic_logger& nas_logger = srslog::fetch_basic_logger("NAS", false); nas_logger.set_level(srslog::str_to_basic_level(args.log_args.nas_level)); diff --git a/srsepc/src/mbms-gw/CMakeLists.txt b/srsepc/src/mbms-gw/CMakeLists.txt index 69f934000..8b7c5af95 100644 --- a/srsepc/src/mbms-gw/CMakeLists.txt +++ b/srsepc/src/mbms-gw/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of diff --git a/srsepc/src/mbms-gw/main.cc b/srsepc/src/mbms-gw/main.cc index 69e8575d1..a4c42c656 100644 --- a/srsepc/src/mbms-gw/main.cc +++ b/srsepc/src/mbms-gw/main.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,8 +11,8 @@ */ #include "srsepc/hdr/mbms-gw/mbms-gw.h" -#include "srslte/common/config_file.h" -#include "srslte/srslog/srslog.h" +#include "srsran/common/config_file.h" +#include "srsran/srslog/srslog.h" #include #include #include @@ -169,11 +169,11 @@ int main(int argc, char* argv[]) srslog::sink* log_sink = (args.log_args.filename == "stdout") ? srslog::create_stdout_sink() : srslog::create_file_sink(args.log_args.filename); if (!log_sink) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } srslog::log_channel* chan = srslog::create_log_channel("main_channel", *log_sink); if (!chan) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } srslog::set_default_sink(*log_sink); diff --git a/srsepc/src/mbms-gw/mbms-gw.cc b/srsepc/src/mbms-gw/mbms-gw.cc index 89592e4df..ee618f2e1 100644 --- a/srsepc/src/mbms-gw/mbms-gw.cc +++ b/srsepc/src/mbms-gw/mbms-gw.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,8 +11,8 @@ */ #include "srsepc/hdr/mbms-gw/mbms-gw.h" -#include "srslte/common/standard_streams.h" -#include "srslte/upper/gtpu.h" +#include "srsran/common/standard_streams.h" +#include "srsran/upper/gtpu.h" #include #include #include @@ -66,20 +66,20 @@ int mbms_gw::init(mbms_gw_args_t* args) int err; err = init_sgi_mb_if(args); - if (err != SRSLTE_SUCCESS) { - srslte::console("Error initializing SGi-MB.\n"); + if (err != SRSRAN_SUCCESS) { + srsran::console("Error initializing SGi-MB.\n"); m_logger.error("Error initializing SGi-MB."); - return SRSLTE_ERROR_CANT_START; + return SRSRAN_ERROR_CANT_START; } err = init_m1_u(args); - if (err != SRSLTE_SUCCESS) { - srslte::console("Error initializing SGi-MB.\n"); + if (err != SRSRAN_SUCCESS) { + srsran::console("Error initializing SGi-MB.\n"); m_logger.error("Error initializing SGi-MB."); - return SRSLTE_ERROR_CANT_START; + return SRSRAN_ERROR_CANT_START; } m_logger.info("MBMS GW Initiated"); - srslte::console("MBMS GW Initiated\n"); - return SRSLTE_SUCCESS; + srsran::console("MBMS GW Initiated\n"); + return SRSRAN_SUCCESS; } void mbms_gw::stop() @@ -101,7 +101,7 @@ int mbms_gw::init_sgi_mb_if(mbms_gw_args_t* args) struct ifreq ifr; if (m_sgi_mb_up) { - return SRSLTE_ERROR_ALREADY_STARTED; + return SRSRAN_ERROR_ALREADY_STARTED; } // Construct the TUN device @@ -109,7 +109,7 @@ int mbms_gw::init_sgi_mb_if(mbms_gw_args_t* args) m_logger.info("TUN file descriptor = %d", m_sgi_mb_if); if (m_sgi_mb_if < 0) { m_logger.error("Failed to open TUN device: %s", strerror(errno)); - return SRSLTE_ERROR_CANT_START; + return SRSRAN_ERROR_CANT_START; } memset(&ifr, 0, sizeof(ifr)); @@ -122,7 +122,7 @@ int mbms_gw::init_sgi_mb_if(mbms_gw_args_t* args) if (ioctl(m_sgi_mb_if, TUNSETIFF, &ifr) < 0) { m_logger.error("Failed to set TUN device name: %s", strerror(errno)); close(m_sgi_mb_if); - return SRSLTE_ERROR_CANT_START; + return SRSRAN_ERROR_CANT_START; } else { m_logger.debug("Set TUN device name: %s", args->sgi_mb_if_name.c_str()); } @@ -132,14 +132,14 @@ int mbms_gw::init_sgi_mb_if(mbms_gw_args_t* args) if (sgi_mb_sock < 0) { m_logger.error("Failed to bring up socket: %s", strerror(errno)); close(m_sgi_mb_if); - return SRSLTE_ERROR_CANT_START; + return SRSRAN_ERROR_CANT_START; } if (ioctl(sgi_mb_sock, SIOCGIFFLAGS, &ifr) < 0) { m_logger.error("Failed to bring up interface: %s", strerror(errno)); close(m_sgi_mb_if); close(sgi_mb_sock); - return SRSLTE_ERROR_CANT_START; + return SRSRAN_ERROR_CANT_START; } ifr.ifr_flags |= IFF_UP | IFF_RUNNING; @@ -147,7 +147,7 @@ int mbms_gw::init_sgi_mb_if(mbms_gw_args_t* args) m_logger.error("Failed to set socket flags: %s", strerror(errno)); close(sgi_mb_sock); close(m_sgi_mb_if); - return SRSLTE_ERROR_CANT_START; + return SRSRAN_ERROR_CANT_START; } // Set IP of the interface @@ -161,7 +161,7 @@ int mbms_gw::init_sgi_mb_if(mbms_gw_args_t* args) "Failed to set TUN interface IP. Address: %s, Error: %s", args->sgi_mb_if_addr.c_str(), strerror(errno)); close(m_sgi_mb_if); close(sgi_mb_sock); - return SRSLTE_ERROR_CANT_START; + return SRSRAN_ERROR_CANT_START; } ifr.ifr_netmask.sa_family = AF_INET; @@ -170,12 +170,12 @@ int mbms_gw::init_sgi_mb_if(mbms_gw_args_t* args) m_logger.error("Failed to set TUN interface Netmask. Error: %s", strerror(errno)); close(m_sgi_mb_if); close(sgi_mb_sock); - return SRSLTE_ERROR_CANT_START; + return SRSRAN_ERROR_CANT_START; } m_sgi_mb_up = true; close(sgi_mb_sock); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int mbms_gw::init_m1_u(mbms_gw_args_t* args) @@ -185,7 +185,7 @@ int mbms_gw::init_m1_u(mbms_gw_args_t* args) m_m1u = socket(AF_INET, SOCK_DGRAM, 0); if (m_m1u < 0) { m_logger.error("Failed to open socket: %s", strerror(errno)); - return SRSLTE_ERROR_CANT_START; + return SRSRAN_ERROR_CANT_START; } m_m1u_up = true; @@ -193,7 +193,7 @@ int mbms_gw::init_m1_u(mbms_gw_args_t* args) char loopch = 0; if (setsockopt(m_m1u, IPPROTO_IP, IP_MULTICAST_LOOP, (char*)&loopch, sizeof(char)) < 0) { m_logger.error("Failed to disable loopback: %s", strerror(errno)); - return SRSLTE_ERROR_CANT_START; + return SRSRAN_ERROR_CANT_START; } else { m_logger.debug("Loopback disabled"); } @@ -204,7 +204,7 @@ int mbms_gw::init_m1_u(mbms_gw_args_t* args) local_if.s_addr = inet_addr(args->m1u_multi_if.c_str()); if (setsockopt(m_m1u, IPPROTO_IP, IP_MULTICAST_IF, (char*)&local_if, sizeof(struct in_addr)) < 0) { m_logger.error("Error %s setting multicast interface %s.", strerror(errno), args->m1u_multi_if.c_str()); - return SRSLTE_ERROR_CANT_START; + return SRSRAN_ERROR_CANT_START; } else { printf("Multicast interface specified. Address: %s\n", args->m1u_multi_if.c_str()); } @@ -212,7 +212,7 @@ int mbms_gw::init_m1_u(mbms_gw_args_t* args) /*Set Multicast TTL*/ if (setsockopt(m_m1u, IPPROTO_IP, IP_MULTICAST_TTL, &args->m1u_multi_ttl, sizeof(args->m1u_multi_ttl)) < 0) { perror("Error setting multicast ttl.\n"); - return SRSLTE_ERROR_CANT_START; + return SRSRAN_ERROR_CANT_START; } bzero(&m_m1u_multi_addr, sizeof(m_m1u_multi_addr)); @@ -221,21 +221,21 @@ int mbms_gw::init_m1_u(mbms_gw_args_t* args) m_m1u_multi_addr.sin_addr.s_addr = inet_addr(args->m1u_multi_addr.c_str()); m_logger.info("Initialized M1-U"); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } void mbms_gw::run_thread() { // Mark the thread as running m_running = true; - srslte::unique_byte_buffer_t msg = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t msg = srsran::make_byte_buffer(); uint8_t seq = 0; while (m_running) { msg->clear(); int n; do { - n = read(m_sgi_mb_if, msg->msg, SRSLTE_MAX_BUFFER_SIZE_BYTES); + n = read(m_sgi_mb_if, msg->msg, SRSRAN_MAX_BUFFER_SIZE_BYTES); } while (n == -1 && errno == EAGAIN); if (n < 0) { @@ -248,10 +248,10 @@ void mbms_gw::run_thread() return; } -void mbms_gw::handle_sgi_md_pdu(srslte::byte_buffer_t* msg) +void mbms_gw::handle_sgi_md_pdu(srsran::byte_buffer_t* msg) { uint8_t version; - srslte::gtpu_header_t header; + srsran::gtpu_header_t header; // Setup GTP-U header header.flags = GTPU_FLAGS_VERSION_V1 | GTPU_FLAGS_GTP_PROTOCOL; @@ -273,13 +273,13 @@ void mbms_gw::handle_sgi_md_pdu(srslte::byte_buffer_t* msg) } // Write GTP-U header into packet - if (!srslte::gtpu_write_header(&header, msg, m_logger)) { - srslte::console("Error writing GTP-U header on PDU\n"); + if (!srsran::gtpu_write_header(&header, msg, m_logger)) { + srsran::console("Error writing GTP-U header on PDU\n"); } int n = sendto(m_m1u, msg->msg, msg->N_bytes, 0, (sockaddr*)&m_m1u_multi_addr, sizeof(struct sockaddr)); if (n < 0) { - srslte::console("Error writing to M1-U socket.\n"); + srsran::console("Error writing to M1-U socket.\n"); } else { m_logger.debug("Sent %d Bytes", msg->N_bytes); } diff --git a/srsepc/src/mme/CMakeLists.txt b/srsepc/src/mme/CMakeLists.txt index 0a1c1b0aa..e6498e5bd 100644 --- a/srsepc/src/mme/CMakeLists.txt +++ b/srsepc/src/mme/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of diff --git a/srsepc/src/mme/mme.cc b/srsepc/src/mme/mme.cc index 119dd5147..752a26536 100644 --- a/srsepc/src/mme/mme.cc +++ b/srsepc/src/mme/mme.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -64,13 +64,13 @@ int mme::init(mme_args_t* args) /*Init GTP-C*/ m_mme_gtpc = mme_gtpc::get_instance(); if (!m_mme_gtpc->init()) { - srslte::console("Error initializing GTP-C\n"); + srsran::console("Error initializing GTP-C\n"); exit(-1); } /*Log successful initialization*/ m_s1ap_logger.info("MME Initialized. MCC: 0x%x, MNC: 0x%x", args->s1ap_args.mcc, args->s1ap_args.mnc); - srslte::console("MME Initialized. MCC: 0x%x, MNC: 0x%x\n", args->s1ap_args.mcc, args->s1ap_args.mnc); + srsran::console("MME Initialized. MCC: 0x%x, MNC: 0x%x\n", args->s1ap_args.mcc, args->s1ap_args.mnc); return 0; } @@ -88,8 +88,8 @@ void mme::stop() void mme::run_thread() { - srslte::unique_byte_buffer_t pdu = srslte::make_byte_buffer("mme::run_thread"); - uint32_t sz = SRSLTE_MAX_BUFFER_SIZE_BYTES - SRSLTE_BUFFER_HEADER_OFFSET; + srsran::unique_byte_buffer_t pdu = srsran::make_byte_buffer("mme::run_thread"); + uint32_t sz = SRSRAN_MAX_BUFFER_SIZE_BYTES - SRSRAN_BUFFER_HEADER_OFFSET; struct sockaddr_in enb_addr; struct sctp_sndrcvinfo sri; @@ -139,7 +139,7 @@ void mme::run_thread() m_s1ap_logger.debug("SCTP Notification %d", notification->sn_header.sn_type); if (notification->sn_header.sn_type == SCTP_SHUTDOWN_EVENT) { m_s1ap_logger.info("SCTP Association Shutdown. Association: %d", sri.sinfo_assoc_id); - srslte::console("SCTP Association Shutdown. Association: %d\n", sri.sinfo_assoc_id); + srsran::console("SCTP Association Shutdown. Association: %d\n", sri.sinfo_assoc_id); m_s1ap->delete_enb_ctx(sri.sinfo_assoc_id); } } else { diff --git a/srsepc/src/mme/mme_gtpc.cc b/srsepc/src/mme/mme_gtpc.cc index 6d87f2bbd..e5157f474 100644 --- a/srsepc/src/mme/mme_gtpc.cc +++ b/srsepc/src/mme/mme_gtpc.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,7 +13,7 @@ #include "srsepc/hdr/mme/mme_gtpc.h" #include "srsepc/hdr/mme/s1ap.h" #include "srsepc/hdr/spgw/spgw.h" -#include "srslte/asn1/gtpc.h" +#include "srsran/asn1/gtpc.h" #include // for printing uint64_t namespace srsepc { @@ -36,7 +36,7 @@ bool mme_gtpc::init() } m_logger.info("MME GTP-C Initialized"); - srslte::console("MME GTP-C Initialized\n"); + srsran::console("MME GTP-C Initialized\n"); return true; } @@ -76,11 +76,11 @@ bool mme_gtpc::init_s11() m_spgw_addr.sun_path[0] = '\0'; m_logger.info("MME S11 Initialized"); - srslte::console("MME S11 Initialized\n"); + srsran::console("MME S11 Initialized\n"); return true; } -bool mme_gtpc::send_s11_pdu(const srslte::gtpc_pdu& pdu) +bool mme_gtpc::send_s11_pdu(const srsran::gtpc_pdu& pdu) { int n; m_logger.debug("Sending S-11 GTP-C PDU"); @@ -90,7 +90,7 @@ bool mme_gtpc::send_s11_pdu(const srslte::gtpc_pdu& pdu) n = sendto(m_s11, &pdu, sizeof(pdu), 0, (const sockaddr*)&m_spgw_addr, sizeof(m_spgw_addr)); if (n < 0) { m_logger.error("Error sending to socket. Error %s", strerror(errno)); - srslte::console("Error sending to socket. Error %s\n", strerror(errno)); + srsran::console("Error sending to socket. Error %s\n", strerror(errno)); return false; } else { m_logger.debug("MME S11 Sent %d Bytes.", n); @@ -98,21 +98,21 @@ bool mme_gtpc::send_s11_pdu(const srslte::gtpc_pdu& pdu) return true; } -void mme_gtpc::handle_s11_pdu(srslte::byte_buffer_t* msg) +void mme_gtpc::handle_s11_pdu(srsran::byte_buffer_t* msg) { m_logger.debug("Received S11 message"); - srslte::gtpc_pdu* pdu; - pdu = (srslte::gtpc_pdu*)msg->msg; - m_logger.debug("MME Received GTP-C PDU. Message type %s", srslte::gtpc_msg_type_to_str(pdu->header.type)); + srsran::gtpc_pdu* pdu; + pdu = (srsran::gtpc_pdu*)msg->msg; + m_logger.debug("MME Received GTP-C PDU. Message type %s", srsran::gtpc_msg_type_to_str(pdu->header.type)); switch (pdu->header.type) { - case srslte::GTPC_MSG_TYPE_CREATE_SESSION_RESPONSE: + case srsran::GTPC_MSG_TYPE_CREATE_SESSION_RESPONSE: handle_create_session_response(pdu); break; - case srslte::GTPC_MSG_TYPE_MODIFY_BEARER_RESPONSE: + case srsran::GTPC_MSG_TYPE_MODIFY_BEARER_RESPONSE: handle_modify_bearer_response(pdu); break; - case srslte::GTPC_MSG_TYPE_DOWNLINK_DATA_NOTIFICATION: + case srsran::GTPC_MSG_TYPE_DOWNLINK_DATA_NOTIFICATION: handle_downlink_data_notification(pdu); break; default: @@ -124,18 +124,18 @@ void mme_gtpc::handle_s11_pdu(srslte::byte_buffer_t* msg) bool mme_gtpc::send_create_session_request(uint64_t imsi) { m_logger.info("Sending Create Session Request."); - srslte::console("Sending Create Session Request.\n"); - struct srslte::gtpc_pdu cs_req_pdu; + srsran::console("Sending Create Session Request.\n"); + struct srsran::gtpc_pdu cs_req_pdu; // Initialize GTP-C message to zero std::memset(&cs_req_pdu, 0, sizeof(cs_req_pdu)); - struct srslte::gtpc_create_session_request* cs_req = &cs_req_pdu.choice.create_session_request; + struct srsran::gtpc_create_session_request* cs_req = &cs_req_pdu.choice.create_session_request; // Setup GTP-C Header. TODO: Length, sequence and other fields need to be added. cs_req_pdu.header.piggyback = false; cs_req_pdu.header.teid_present = true; cs_req_pdu.header.teid = 0; // Send create session request to the butler TEID - cs_req_pdu.header.type = srslte::GTPC_MSG_TYPE_CREATE_SESSION_REQUEST; + cs_req_pdu.header.type = srsran::GTPC_MSG_TYPE_CREATE_SESSION_REQUEST; // Setup GTP-C Create Session Request IEs cs_req->imsi = imsi; @@ -144,15 +144,15 @@ bool mme_gtpc::send_create_session_request(uint64_t imsi) m_logger.info("Next MME control TEID: %d", m_next_ctrl_teid); m_logger.info("Allocated MME control TEID: %d", cs_req->sender_f_teid.teid); - srslte::console("Creating Session Response -- IMSI: %" PRIu64 "\n", imsi); - srslte::console("Creating Session Response -- MME control TEID: %d\n", cs_req->sender_f_teid.teid); + srsran::console("Creating Session Response -- IMSI: %" PRIu64 "\n", imsi); + srsran::console("Creating Session Response -- MME control TEID: %d\n", cs_req->sender_f_teid.teid); // APN strncpy(cs_req->apn, m_s1ap->m_s1ap_args.mme_apn.c_str(), sizeof(cs_req->apn) - 1); cs_req->apn[sizeof(cs_req->apn) - 1] = 0; // RAT Type - // cs_req->rat_type = srslte::GTPC_RAT_TYPE::EUTRAN; + // cs_req->rat_type = srsran::GTPC_RAT_TYPE::EUTRAN; // Bearer QoS cs_req->eps_bearer_context_created.ebi = 5; @@ -187,17 +187,17 @@ bool mme_gtpc::send_create_session_request(uint64_t imsi) return true; } -bool mme_gtpc::handle_create_session_response(srslte::gtpc_pdu* cs_resp_pdu) +bool mme_gtpc::handle_create_session_response(srsran::gtpc_pdu* cs_resp_pdu) { - struct srslte::gtpc_create_session_response* cs_resp = &cs_resp_pdu->choice.create_session_response; + struct srsran::gtpc_create_session_response* cs_resp = &cs_resp_pdu->choice.create_session_response; m_logger.info("Received Create Session Response"); - srslte::console("Received Create Session Response\n"); - if (cs_resp_pdu->header.type != srslte::GTPC_MSG_TYPE_CREATE_SESSION_RESPONSE) { + srsran::console("Received Create Session Response\n"); + if (cs_resp_pdu->header.type != srsran::GTPC_MSG_TYPE_CREATE_SESSION_RESPONSE) { m_logger.warning("Could not create GTPC session. Not a create session response"); // TODO Handle error return false; } - if (cs_resp->cause.cause_value != srslte::GTPC_CAUSE_VALUE_REQUEST_ACCEPTED) { + if (cs_resp->cause.cause_value != srsran::GTPC_CAUSE_VALUE_REQUEST_ACCEPTED) { m_logger.warning("Could not create GTPC session. Create Session Request not accepted"); // TODO Handle error return false; @@ -214,7 +214,7 @@ bool mme_gtpc::handle_create_session_response(srslte::gtpc_pdu* cs_resp_pdu) m_logger.info("MME GTPC Ctrl TEID %" PRIu64 ", IMSI %" PRIu64 "", cs_resp_pdu->header.teid, imsi); // Get S-GW Control F-TEID - srslte::gtp_fteid_t sgw_ctr_fteid = {}; + srsran::gtp_fteid_t sgw_ctr_fteid = {}; sgw_ctr_fteid.teid = cs_resp_pdu->header.teid; sgw_ctr_fteid.ipv4 = 0; // TODO This is not used for now. In the future it will be obtained from the socket addr_info @@ -223,11 +223,11 @@ bool mme_gtpc::handle_create_session_response(srslte::gtpc_pdu* cs_resp_pdu) m_logger.error("Did not receive SGW S1-U F-TEID in create session response"); return false; } - srslte::console("Create Session Response -- SPGW control TEID %d\n", sgw_ctr_fteid.teid); + srsran::console("Create Session Response -- SPGW control TEID %d\n", sgw_ctr_fteid.teid); m_logger.info("Create Session Response -- SPGW control TEID %d", sgw_ctr_fteid.teid); in_addr s1u_addr; s1u_addr.s_addr = cs_resp->eps_bearer_context_created.s1_u_sgw_f_teid.ipv4; - srslte::console("Create Session Response -- SPGW S1-U Address: %s\n", inet_ntoa(s1u_addr)); + srsran::console("Create Session Response -- SPGW S1-U Address: %s\n", inet_ntoa(s1u_addr)); m_logger.info("Create Session Response -- SPGW S1-U Address: %s", inet_ntoa(s1u_addr)); // Check UE Ipv4 address was allocated @@ -235,7 +235,7 @@ bool mme_gtpc::handle_create_session_response(srslte::gtpc_pdu* cs_resp_pdu) m_logger.error("PDN Adress Allocation not present"); return false; } - if (cs_resp->paa.pdn_type != srslte::GTPC_PDN_TYPE_IPV4) { + if (cs_resp->paa.pdn_type != srsran::GTPC_PDN_TYPE_IPV4) { m_logger.error("IPv6 not supported yet"); return false; } @@ -251,7 +251,7 @@ bool mme_gtpc::handle_create_session_response(srslte::gtpc_pdu* cs_resp_pdu) // Save UE IP to nas ctxt emm_ctx->ue_ip.s_addr = cs_resp->paa.ipv4; - srslte::console("SPGW Allocated IP %s to IMSI %015" PRIu64 "\n", inet_ntoa(emm_ctx->ue_ip), emm_ctx->imsi); + srsran::console("SPGW Allocated IP %s to IMSI %015" PRIu64 "\n", inet_ntoa(emm_ctx->ue_ip), emm_ctx->imsi); // Save SGW ctrl F-TEID in GTP-C context std::map::iterator it_g = m_imsi_to_gtpc_ctx.find(imsi); @@ -273,10 +273,10 @@ bool mme_gtpc::handle_create_session_response(srslte::gtpc_pdu* cs_resp_pdu) return true; } -bool mme_gtpc::send_modify_bearer_request(uint64_t imsi, uint16_t erab_to_modify, srslte::gtp_fteid_t* enb_fteid) +bool mme_gtpc::send_modify_bearer_request(uint64_t imsi, uint16_t erab_to_modify, srsran::gtp_fteid_t* enb_fteid) { m_logger.info("Sending GTP-C Modify bearer request"); - srslte::gtpc_pdu mb_req_pdu; + srsran::gtpc_pdu mb_req_pdu; std::memset(&mb_req_pdu, 0, sizeof(mb_req_pdu)); std::map::iterator it = m_imsi_to_gtpc_ctx.find(imsi); @@ -284,14 +284,14 @@ bool mme_gtpc::send_modify_bearer_request(uint64_t imsi, uint16_t erab_to_modify m_logger.error("Modify bearer request for UE without GTP-C connection"); return false; } - srslte::gtp_fteid_t sgw_ctr_fteid = it->second.sgw_ctr_fteid; + srsran::gtp_fteid_t sgw_ctr_fteid = it->second.sgw_ctr_fteid; - srslte::gtpc_header* header = &mb_req_pdu.header; + srsran::gtpc_header* header = &mb_req_pdu.header; header->teid_present = true; header->teid = sgw_ctr_fteid.teid; - header->type = srslte::GTPC_MSG_TYPE_MODIFY_BEARER_REQUEST; + header->type = srsran::GTPC_MSG_TYPE_MODIFY_BEARER_REQUEST; - srslte::gtpc_modify_bearer_request* mb_req = &mb_req_pdu.choice.modify_bearer_request; + srsran::gtpc_modify_bearer_request* mb_req = &mb_req_pdu.choice.modify_bearer_request; mb_req->eps_bearer_context_to_modify.ebi = erab_to_modify; mb_req->eps_bearer_context_to_modify.s1_u_enb_f_teid.ipv4 = enb_fteid->ipv4; mb_req->eps_bearer_context_to_modify.s1_u_enb_f_teid.teid = enb_fteid->teid; @@ -306,7 +306,7 @@ bool mme_gtpc::send_modify_bearer_request(uint64_t imsi, uint16_t erab_to_modify return true; } -void mme_gtpc::handle_modify_bearer_response(srslte::gtpc_pdu* mb_resp_pdu) +void mme_gtpc::handle_modify_bearer_response(srsran::gtpc_pdu* mb_resp_pdu) { uint32_t mme_ctrl_teid = mb_resp_pdu->header.teid; std::map::iterator imsi_it = m_mme_ctr_teid_to_imsi.find(mme_ctrl_teid); @@ -325,10 +325,10 @@ void mme_gtpc::handle_modify_bearer_response(srslte::gtpc_pdu* mb_resp_pdu) bool mme_gtpc::send_delete_session_request(uint64_t imsi) { m_logger.info("Sending GTP-C Delete Session Request request. IMSI %" PRIu64 "", imsi); - srslte::gtpc_pdu del_req_pdu; + srsran::gtpc_pdu del_req_pdu; std::memset(&del_req_pdu, 0, sizeof(del_req_pdu)); - srslte::gtp_fteid_t sgw_ctr_fteid; - srslte::gtp_fteid_t mme_ctr_fteid; + srsran::gtp_fteid_t sgw_ctr_fteid; + srsran::gtp_fteid_t mme_ctr_fteid; // Get S-GW Ctr TEID std::map::iterator it_ctx = m_imsi_to_gtpc_ctx.find(imsi); @@ -339,13 +339,13 @@ bool mme_gtpc::send_delete_session_request(uint64_t imsi) sgw_ctr_fteid = it_ctx->second.sgw_ctr_fteid; mme_ctr_fteid = it_ctx->second.mme_ctr_fteid; - srslte::gtpc_header* header = &del_req_pdu.header; + srsran::gtpc_header* header = &del_req_pdu.header; header->teid_present = true; header->teid = sgw_ctr_fteid.teid; - header->type = srslte::GTPC_MSG_TYPE_DELETE_SESSION_REQUEST; + header->type = srsran::GTPC_MSG_TYPE_DELETE_SESSION_REQUEST; - srslte::gtpc_delete_session_request* del_req = &del_req_pdu.choice.delete_session_request; - del_req->cause.cause_value = srslte::GTPC_CAUSE_VALUE_ISR_DEACTIVATION; + srsran::gtpc_delete_session_request* del_req = &del_req_pdu.choice.delete_session_request; + del_req->cause.cause_value = srsran::GTPC_CAUSE_VALUE_ISR_DEACTIVATION; m_logger.info("GTP-C Delete Session Request -- S-GW Control TEID %d", sgw_ctr_fteid.teid); // Send msg to SPGW @@ -366,9 +366,9 @@ void mme_gtpc::send_release_access_bearers_request(uint64_t imsi) { // The GTP-C connection will not be torn down, just the user plane bearers. m_logger.info("Sending GTP-C Release Access Bearers Request"); - srslte::gtpc_pdu rel_req_pdu; + srsran::gtpc_pdu rel_req_pdu; std::memset(&rel_req_pdu, 0, sizeof(rel_req_pdu)); - srslte::gtp_fteid_t sgw_ctr_fteid; + srsran::gtp_fteid_t sgw_ctr_fteid; // Get S-GW Ctr TEID std::map::iterator it_ctx = m_imsi_to_gtpc_ctx.find(imsi); @@ -379,12 +379,12 @@ void mme_gtpc::send_release_access_bearers_request(uint64_t imsi) sgw_ctr_fteid = it_ctx->second.sgw_ctr_fteid; // Set GTP-C header - srslte::gtpc_header* header = &rel_req_pdu.header; + srsran::gtpc_header* header = &rel_req_pdu.header; header->teid_present = true; header->teid = sgw_ctr_fteid.teid; - header->type = srslte::GTPC_MSG_TYPE_RELEASE_ACCESS_BEARERS_REQUEST; + header->type = srsran::GTPC_MSG_TYPE_RELEASE_ACCESS_BEARERS_REQUEST; - srslte::gtpc_release_access_bearers_request* rel_req = &rel_req_pdu.choice.release_access_bearers_request; + srsran::gtpc_release_access_bearers_request* rel_req = &rel_req_pdu.choice.release_access_bearers_request; m_logger.info("GTP-C Release Access Berarers Request -- S-GW Control TEID %d", sgw_ctr_fteid.teid); // Send msg to SPGW @@ -393,10 +393,10 @@ void mme_gtpc::send_release_access_bearers_request(uint64_t imsi) return; } -bool mme_gtpc::handle_downlink_data_notification(srslte::gtpc_pdu* dl_not_pdu) +bool mme_gtpc::handle_downlink_data_notification(srsran::gtpc_pdu* dl_not_pdu) { uint32_t mme_ctrl_teid = dl_not_pdu->header.teid; - srslte::gtpc_downlink_data_notification* dl_not = &dl_not_pdu->choice.downlink_data_notification; + srsran::gtpc_downlink_data_notification* dl_not = &dl_not_pdu->choice.downlink_data_notification; std::map::iterator imsi_it = m_mme_ctr_teid_to_imsi.find(mme_ctrl_teid); if (imsi_it == m_mme_ctr_teid_to_imsi.end()) { m_logger.error("Could not find IMSI from control TEID"); @@ -414,11 +414,11 @@ bool mme_gtpc::handle_downlink_data_notification(srslte::gtpc_pdu* dl_not_pdu) return true; } -void mme_gtpc::send_downlink_data_notification_acknowledge(uint64_t imsi, enum srslte::gtpc_cause_value cause) +void mme_gtpc::send_downlink_data_notification_acknowledge(uint64_t imsi, enum srsran::gtpc_cause_value cause) { m_logger.debug("Sending GTP-C Data Notification Acknowledge. Cause %d", cause); - srslte::gtpc_pdu not_ack_pdu; - srslte::gtp_fteid_t sgw_ctr_fteid; + srsran::gtpc_pdu not_ack_pdu; + srsran::gtp_fteid_t sgw_ctr_fteid; std::memset(¬_ack_pdu, 0, sizeof(not_ack_pdu)); // get s-gw ctr teid @@ -430,12 +430,12 @@ void mme_gtpc::send_downlink_data_notification_acknowledge(uint64_t imsi, enum s sgw_ctr_fteid = it_ctx->second.sgw_ctr_fteid; // set gtp-c header - srslte::gtpc_header* header = ¬_ack_pdu.header; + srsran::gtpc_header* header = ¬_ack_pdu.header; header->teid_present = true; header->teid = sgw_ctr_fteid.teid; - header->type = srslte::GTPC_MSG_TYPE_DOWNLINK_DATA_NOTIFICATION_ACKNOWLEDGE; + header->type = srsran::GTPC_MSG_TYPE_DOWNLINK_DATA_NOTIFICATION_ACKNOWLEDGE; - srslte::gtpc_downlink_data_notification_acknowledge* not_ack = + srsran::gtpc_downlink_data_notification_acknowledge* not_ack = ¬_ack_pdu.choice.downlink_data_notification_acknowledge; m_logger.info("gtp-c downlink data notification acknowledge -- s-gw control teid %d", sgw_ctr_fteid.teid); @@ -444,11 +444,11 @@ void mme_gtpc::send_downlink_data_notification_acknowledge(uint64_t imsi, enum s return; } -bool mme_gtpc::send_downlink_data_notification_failure_indication(uint64_t imsi, enum srslte::gtpc_cause_value cause) +bool mme_gtpc::send_downlink_data_notification_failure_indication(uint64_t imsi, enum srsran::gtpc_cause_value cause) { m_logger.debug("Sending GTP-C Data Notification Failure Indication. Cause %d", cause); - srslte::gtpc_pdu not_fail_pdu; - srslte::gtp_fteid_t sgw_ctr_fteid; + srsran::gtpc_pdu not_fail_pdu; + srsran::gtp_fteid_t sgw_ctr_fteid; std::memset(¬_fail_pdu, 0, sizeof(not_fail_pdu)); // get s-gw ctr teid @@ -460,12 +460,12 @@ bool mme_gtpc::send_downlink_data_notification_failure_indication(uint64_t imsi, sgw_ctr_fteid = it_ctx->second.sgw_ctr_fteid; // set gtp-c header - srslte::gtpc_header* header = ¬_fail_pdu.header; + srsran::gtpc_header* header = ¬_fail_pdu.header; header->teid_present = true; header->teid = sgw_ctr_fteid.teid; - header->type = srslte::GTPC_MSG_TYPE_DOWNLINK_DATA_NOTIFICATION_FAILURE_INDICATION; + header->type = srsran::GTPC_MSG_TYPE_DOWNLINK_DATA_NOTIFICATION_FAILURE_INDICATION; - srslte::gtpc_downlink_data_notification_failure_indication* not_fail = + srsran::gtpc_downlink_data_notification_failure_indication* not_fail = ¬_fail_pdu.choice.downlink_data_notification_failure_indication; not_fail->cause.cause_value = cause; m_logger.info("Downlink Data Notification Failure Indication -- SP-GW control teid %d", sgw_ctr_fteid.teid); diff --git a/srsepc/src/mme/nas.cc b/srsepc/src/mme/nas.cc index f4ca1725c..9d233da67 100644 --- a/srsepc/src/mme/nas.cc +++ b/srsepc/src/mme/nas.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -12,8 +12,8 @@ #include "srsepc/hdr/mme/s1ap.h" #include "srsepc/hdr/mme/s1ap_nas_transport.h" -#include "srslte/common/liblte_security.h" -#include "srslte/common/security.h" +#include "srsran/common/liblte_security.h" +#include "srsran/common/security.h" #include #include // for printing uint64_t #include @@ -49,8 +49,8 @@ void nas::reset() m_esm_ctx[i] = {}; } - srslte::INTEGRITY_ALGORITHM_ID_ENUM integ_algo = m_sec_ctx.integ_algo; - srslte::CIPHERING_ALGORITHM_ID_ENUM cipher_algo = m_sec_ctx.cipher_algo; + srsran::INTEGRITY_ALGORITHM_ID_ENUM integ_algo = m_sec_ctx.integ_algo; + srsran::CIPHERING_ALGORITHM_ID_ENUM cipher_algo = m_sec_ctx.cipher_algo; m_sec_ctx = {}; m_sec_ctx.integ_algo = integ_algo; m_sec_ctx.cipher_algo = cipher_algo; @@ -63,7 +63,7 @@ void nas::reset() ********************************/ bool nas::handle_attach_request(uint32_t enb_ue_s1ap_id, struct sctp_sndrcvinfo* enb_sri, - srslte::byte_buffer_t* nas_rx, + srsran::byte_buffer_t* nas_rx, const nas_init_t& args, const nas_if_t& itf) { @@ -96,12 +96,12 @@ bool nas::handle_attach_request(uint32_t enb_ue_s1ap_id, for (int i = 0; i <= 14; i++) { imsi += attach_req.eps_mobile_id.imsi[i] * std::pow(10, 14 - i); } - srslte::console("Attach request -- IMSI: %015" PRIu64 "\n", imsi); + srsran::console("Attach request -- IMSI: %015" PRIu64 "\n", imsi); nas_logger.info("Attach request -- IMSI: %015" PRIu64 "", imsi); } else if (attach_req.eps_mobile_id.type_of_id == LIBLTE_MME_EPS_MOBILE_ID_TYPE_GUTI) { m_tmsi = attach_req.eps_mobile_id.guti.m_tmsi; imsi = s1ap->find_imsi_from_m_tmsi(m_tmsi); - srslte::console("Attach request -- M-TMSI: 0x%x\n", m_tmsi); + srsran::console("Attach request -- M-TMSI: 0x%x\n", m_tmsi); nas_logger.info("Attach request -- M-TMSI: 0x%x", m_tmsi); } else { nas_logger.error("Unhandled Mobile Id type in attach request"); @@ -109,11 +109,11 @@ bool nas::handle_attach_request(uint32_t enb_ue_s1ap_id, } // Log Attach Request Information - srslte::console("Attach request -- eNB-UE S1AP Id: %d\n", enb_ue_s1ap_id); + srsran::console("Attach request -- eNB-UE S1AP Id: %d\n", enb_ue_s1ap_id); nas_logger.info("Attach request -- eNB-UE S1AP Id: %d", enb_ue_s1ap_id); - srslte::console("Attach request -- Attach type: %d\n", attach_req.eps_attach_type); + srsran::console("Attach request -- Attach type: %d\n", attach_req.eps_attach_type); nas_logger.info("Attach request -- Attach type: %d", attach_req.eps_attach_type); - srslte::console("Attach Request -- UE Network Capabilities EEA: %d%d%d%d%d%d%d%d\n", + srsran::console("Attach Request -- UE Network Capabilities EEA: %d%d%d%d%d%d%d%d\n", attach_req.ue_network_cap.eea[0], attach_req.ue_network_cap.eea[1], attach_req.ue_network_cap.eea[2], @@ -131,7 +131,7 @@ bool nas::handle_attach_request(uint32_t enb_ue_s1ap_id, attach_req.ue_network_cap.eea[5], attach_req.ue_network_cap.eea[6], attach_req.ue_network_cap.eea[7]); - srslte::console("Attach Request -- UE Network Capabilities EIA: %d%d%d%d%d%d%d%d\n", + srsran::console("Attach Request -- UE Network Capabilities EIA: %d%d%d%d%d%d%d%d\n", attach_req.ue_network_cap.eia[0], attach_req.ue_network_cap.eia[1], attach_req.ue_network_cap.eia[2], @@ -149,15 +149,15 @@ bool nas::handle_attach_request(uint32_t enb_ue_s1ap_id, attach_req.ue_network_cap.eia[5], attach_req.ue_network_cap.eia[6], attach_req.ue_network_cap.eia[7]); - srslte::console("Attach Request -- MS Network Capabilities Present: %s\n", + srsran::console("Attach Request -- MS Network Capabilities Present: %s\n", attach_req.ms_network_cap_present ? "true" : "false"); nas_logger.info("Attach Request -- MS Network Capabilities Present: %s", attach_req.ms_network_cap_present ? "true" : "false"); - srslte::console("PDN Connectivity Request -- EPS Bearer Identity requested: %d\n", pdn_con_req.eps_bearer_id); + srsran::console("PDN Connectivity Request -- EPS Bearer Identity requested: %d\n", pdn_con_req.eps_bearer_id); nas_logger.info("PDN Connectivity Request -- EPS Bearer Identity requested: %d", pdn_con_req.eps_bearer_id); - srslte::console("PDN Connectivity Request -- Procedure Transaction Id: %d\n", pdn_con_req.proc_transaction_id); + srsran::console("PDN Connectivity Request -- Procedure Transaction Id: %d\n", pdn_con_req.proc_transaction_id); nas_logger.info("PDN Connectivity Request -- Procedure Transaction Id: %d", pdn_con_req.proc_transaction_id); - srslte::console("PDN Connectivity Request -- ESM Information Transfer requested: %s\n", + srsran::console("PDN Connectivity Request -- ESM Information Transfer requested: %s\n", pdn_con_req.esm_info_transfer_flag_present ? "true" : "false"); nas_logger.info("PDN Connectivity Request -- ESM Information Transfer requested: %s", pdn_con_req.esm_info_transfer_flag_present ? "true" : "false"); @@ -175,7 +175,7 @@ bool nas::handle_attach_request(uint32_t enb_ue_s1ap_id, } } else { nas_logger.info("Attach Request -- Found previously attached UE."); - srslte::console("Attach Request -- Found previously attach UE.\n"); + srsran::console("Attach Request -- Found previously attach UE.\n"); if (attach_req.eps_mobile_id.type_of_id == LIBLTE_MME_EPS_MOBILE_ID_TYPE_IMSI) { nas::handle_imsi_attach_request_known_ue( nas_ctx, enb_ue_s1ap_id, enb_sri, attach_req, pdn_con_req, nas_rx, args, itf); @@ -197,7 +197,7 @@ bool nas::handle_imsi_attach_request_unknown_ue(uint32_t const nas_if_t& itf) { nas* nas_ctx; - srslte::unique_byte_buffer_t nas_tx; + srsran::unique_byte_buffer_t nas_tx; auto& nas_logger = srslog::fetch_basic_logger("NAS"); // Interfaces @@ -258,7 +258,7 @@ bool nas::handle_imsi_attach_request_unknown_ue(uint32_t nas_ctx->m_sec_ctx.autn, nas_ctx->m_sec_ctx.rand, nas_ctx->m_sec_ctx.xres)) { - srslte::console("User not found. IMSI %015" PRIu64 "\n", nas_ctx->m_emm_ctx.imsi); + srsran::console("User not found. IMSI %015" PRIu64 "\n", nas_ctx->m_emm_ctx.imsi); nas_logger.info("User not found. IMSI %015" PRIu64 "", nas_ctx->m_emm_ctx.imsi); return false; } @@ -273,7 +273,7 @@ bool nas::handle_imsi_attach_request_unknown_ue(uint32_t s1ap->add_ue_to_enb_set(enb_sri->sinfo_assoc_id, nas_ctx->m_ecm_ctx.mme_ue_s1ap_id); // Pack NAS Authentication Request in Downlink NAS Transport msg - nas_tx = srslte::make_byte_buffer(); + nas_tx = srsran::make_byte_buffer(); nas_ctx->pack_authentication_request(nas_tx.get()); // Send reply to eNB @@ -281,7 +281,7 @@ bool nas::handle_imsi_attach_request_unknown_ue(uint32_t nas_ctx->m_ecm_ctx.enb_ue_s1ap_id, nas_ctx->m_ecm_ctx.mme_ue_s1ap_id, nas_tx.get(), nas_ctx->m_ecm_ctx.enb_sri); nas_logger.info("Downlink NAS: Sending Authentication Request"); - srslte::console("Downlink NAS: Sending Authentication Request\n"); + srsran::console("Downlink NAS: Sending Authentication Request\n"); return true; } @@ -290,7 +290,7 @@ bool nas::handle_imsi_attach_request_known_ue(nas* struct sctp_sndrcvinfo* enb_sri, const LIBLTE_MME_ATTACH_REQUEST_MSG_STRUCT& attach_req, const LIBLTE_MME_PDN_CONNECTIVITY_REQUEST_MSG_STRUCT& pdn_con_req, - srslte::byte_buffer_t* nas_rx, + srsran::byte_buffer_t* nas_rx, const nas_init_t& args, const nas_if_t& itf) { @@ -326,7 +326,7 @@ bool nas::handle_guti_attach_request_unknown_ue(uint32_t { nas* nas_ctx; - srslte::unique_byte_buffer_t nas_tx; + srsran::unique_byte_buffer_t nas_tx; // Interfaces s1ap_interface_nas* s1ap = itf.s1ap; @@ -382,7 +382,7 @@ bool nas::handle_guti_attach_request_unknown_ue(uint32_t s1ap->add_ue_to_enb_set(enb_sri->sinfo_assoc_id, nas_ctx->m_ecm_ctx.mme_ue_s1ap_id); // Send Identity Request - nas_tx = srslte::make_byte_buffer(); + nas_tx = srsran::make_byte_buffer(); nas_ctx->pack_identity_request(nas_tx.get()); s1ap->send_downlink_nas_transport( nas_ctx->m_ecm_ctx.enb_ue_s1ap_id, nas_ctx->m_ecm_ctx.mme_ue_s1ap_id, nas_tx.get(), nas_ctx->m_ecm_ctx.enb_sri); @@ -395,12 +395,12 @@ bool nas::handle_guti_attach_request_known_ue(nas* struct sctp_sndrcvinfo* enb_sri, const LIBLTE_MME_ATTACH_REQUEST_MSG_STRUCT& attach_req, const LIBLTE_MME_PDN_CONNECTIVITY_REQUEST_MSG_STRUCT& pdn_con_req, - srslte::byte_buffer_t* nas_rx, + srsran::byte_buffer_t* nas_rx, const nas_init_t& args, const nas_if_t& itf) { bool msg_valid = false; - srslte::unique_byte_buffer_t nas_tx; + srsran::unique_byte_buffer_t nas_tx; auto& nas_logger = srslog::fetch_basic_logger("NAS"); emm_ctx_t* emm_ctx = &nas_ctx->m_emm_ctx; @@ -412,7 +412,7 @@ bool nas::handle_guti_attach_request_known_ue(nas* hss_interface_nas* hss = itf.hss; gtpc_interface_nas* gtpc = itf.gtpc; - srslte::console("Found UE context. IMSI: %015" PRIu64 ", old eNB UE S1ap Id %d, old MME UE S1AP Id %d\n", + srsran::console("Found UE context. IMSI: %015" PRIu64 ", old eNB UE S1ap Id %d, old MME UE S1AP Id %d\n", emm_ctx->imsi, ecm_ctx->enb_ue_s1ap_id, ecm_ctx->mme_ue_s1ap_id); @@ -420,7 +420,7 @@ bool nas::handle_guti_attach_request_known_ue(nas* // Check NAS integrity msg_valid = nas_ctx->integrity_check(nas_rx); if (msg_valid == true && emm_ctx->state == EMM_STATE_DEREGISTERED) { - srslte::console( + srsran::console( "GUTI Attach -- NAS Integrity OK. UL count %d, DL count %d\n", sec_ctx->ul_nas_count, sec_ctx->dl_nas_count); nas_logger.info( "GUTI Attach -- NAS Integrity OK. UL count %d, DL count %d", sec_ctx->ul_nas_count, sec_ctx->dl_nas_count); @@ -452,15 +452,15 @@ bool nas::handle_guti_attach_request_known_ue(nas* s1ap->add_ue_to_enb_set(enb_sri->sinfo_assoc_id, ecm_ctx->mme_ue_s1ap_id); // Re-generate K_eNB - srslte::security_generate_k_enb(sec_ctx->k_asme, sec_ctx->ul_nas_count, sec_ctx->k_enb); + srsran::security_generate_k_enb(sec_ctx->k_asme, sec_ctx->ul_nas_count, sec_ctx->k_enb); nas_logger.info("Generating KeNB with UL NAS COUNT: %d", sec_ctx->ul_nas_count); - srslte::console("Generating KeNB with UL NAS COUNT: %d\n", sec_ctx->ul_nas_count); + srsran::console("Generating KeNB with UL NAS COUNT: %d\n", sec_ctx->ul_nas_count); nas_logger.info(sec_ctx->k_enb, 32, "Key eNodeB (k_enb)"); // Send reply - nas_tx = srslte::make_byte_buffer(); + nas_tx = srsran::make_byte_buffer(); if (ecm_ctx->eit) { - srslte::console("Secure ESM information transfer requested.\n"); + srsran::console("Secure ESM information transfer requested.\n"); nas_logger.info("Secure ESM information transfer requested."); nas_ctx->pack_esm_information_request(nas_tx.get()); s1ap->send_downlink_nas_transport(ecm_ctx->enb_ue_s1ap_id, ecm_ctx->mme_ue_s1ap_id, nas_tx.get(), *enb_sri); @@ -469,7 +469,7 @@ bool nas::handle_guti_attach_request_known_ue(nas* uint8_t default_bearer = 5; hss->gen_update_loc_answer(emm_ctx->imsi, &nas_ctx->m_esm_ctx[default_bearer].qci); nas_logger.debug("Getting subscription information -- QCI %d", nas_ctx->m_esm_ctx[default_bearer].qci); - srslte::console("Getting subscription information -- QCI %d\n", nas_ctx->m_esm_ctx[default_bearer].qci); + srsran::console("Getting subscription information -- QCI %d\n", nas_ctx->m_esm_ctx[default_bearer].qci); gtpc->send_create_session_request(emm_ctx->imsi); } sec_ctx->ul_nas_count++; @@ -477,7 +477,7 @@ bool nas::handle_guti_attach_request_known_ue(nas* } else { if (emm_ctx->state != EMM_STATE_DEREGISTERED) { nas_logger.error("Received GUTI-Attach Request from attached user."); - srslte::console("Received GUTI-Attach Request from attached user.\n"); + srsran::console("Received GUTI-Attach Request from attached user.\n"); // Delete previous Ctx, restart authentication // Detaching previoulsy attached UE. @@ -519,25 +519,25 @@ bool nas::handle_guti_attach_request_known_ue(nas* s1ap->add_ue_to_enb_set(enb_sri->sinfo_assoc_id, ecm_ctx->mme_ue_s1ap_id); // NAS integrity failed. Re-start authentication process. - srslte::console("GUTI Attach request NAS integrity failed.\n"); - srslte::console("RE-starting authentication procedure.\n"); + srsran::console("GUTI Attach request NAS integrity failed.\n"); + srsran::console("RE-starting authentication procedure.\n"); // Get Authentication Vectors from HSS if (!hss->gen_auth_info_answer(emm_ctx->imsi, sec_ctx->k_asme, sec_ctx->autn, sec_ctx->rand, sec_ctx->xres)) { - srslte::console("User not found. IMSI %015" PRIu64 "\n", emm_ctx->imsi); + srsran::console("User not found. IMSI %015" PRIu64 "\n", emm_ctx->imsi); nas_logger.info("User not found. IMSI %015" PRIu64 "", emm_ctx->imsi); return false; } // Restarting security context. Reseting eKSI to 0. sec_ctx->eksi = 0; - nas_tx = srslte::unique_byte_buffer_t(); + nas_tx = srsran::unique_byte_buffer_t(); nas_ctx->pack_authentication_request(nas_tx.get()); // Send reply to eNB s1ap->send_downlink_nas_transport(ecm_ctx->enb_ue_s1ap_id, ecm_ctx->mme_ue_s1ap_id, nas_tx.get(), *enb_sri); nas_logger.info("Downlink NAS: Sent Authentication Request"); - srslte::console("Downlink NAS: Sent Authentication Request\n"); + srsran::console("Downlink NAS: Sent Authentication Request\n"); return true; } } @@ -546,16 +546,16 @@ bool nas::handle_guti_attach_request_known_ue(nas* bool nas::handle_service_request(uint32_t m_tmsi, uint32_t enb_ue_s1ap_id, struct sctp_sndrcvinfo* enb_sri, - srslte::byte_buffer_t* nas_rx, + srsran::byte_buffer_t* nas_rx, const nas_init_t& args, const nas_if_t& itf) { auto& nas_logger = srslog::fetch_basic_logger("NAS"); nas_logger.info("Service request -- S-TMSI 0x%x", m_tmsi); - srslte::console("Service request -- S-TMSI 0x%x\n", m_tmsi); + srsran::console("Service request -- S-TMSI 0x%x\n", m_tmsi); nas_logger.info("Service request -- eNB UE S1AP Id %d", enb_ue_s1ap_id); - srslte::console("Service request -- eNB UE S1AP Id %d\n", enb_ue_s1ap_id); + srsran::console("Service request -- eNB UE S1AP Id %d\n", enb_ue_s1ap_id); bool mac_valid = false; LIBLTE_MME_SERVICE_REQUEST_MSG_STRUCT service_req; @@ -574,13 +574,13 @@ bool nas::handle_service_request(uint32_t m_tmsi, uint64_t imsi = s1ap->find_imsi_from_m_tmsi(m_tmsi); if (imsi == 0) { - srslte::console("Could not find IMSI from M-TMSI. M-TMSI 0x%x\n", m_tmsi); + srsran::console("Could not find IMSI from M-TMSI. M-TMSI 0x%x\n", m_tmsi); nas_logger.error("Could not find IMSI from M-TMSI. M-TMSI 0x%x", m_tmsi); nas nas_tmp(args, itf); nas_tmp.m_ecm_ctx.enb_ue_s1ap_id = enb_ue_s1ap_id; nas_tmp.m_ecm_ctx.mme_ue_s1ap_id = s1ap->get_next_mme_ue_s1ap_id(); - srslte::unique_byte_buffer_t nas_tx = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t nas_tx = srsran::make_byte_buffer(); nas_tmp.pack_service_reject(nas_tx.get(), LIBLTE_MME_EMM_CAUSE_IMPLICITLY_DETACHED); s1ap->send_downlink_nas_transport(enb_ue_s1ap_id, nas_tmp.m_ecm_ctx.mme_ue_s1ap_id, nas_tx.get(), *enb_sri); return true; @@ -588,13 +588,13 @@ bool nas::handle_service_request(uint32_t m_tmsi, nas* nas_ctx = s1ap->find_nas_ctx_from_imsi(imsi); if (nas_ctx == NULL || nas_ctx->m_emm_ctx.state != EMM_STATE_REGISTERED) { - srslte::console("UE is not EMM-Registered.\n"); + srsran::console("UE is not EMM-Registered.\n"); nas_logger.error("UE is not EMM-Registered."); nas nas_tmp(args, itf); nas_tmp.m_ecm_ctx.enb_ue_s1ap_id = enb_ue_s1ap_id; nas_tmp.m_ecm_ctx.mme_ue_s1ap_id = s1ap->get_next_mme_ue_s1ap_id(); - srslte::unique_byte_buffer_t nas_tx = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t nas_tx = srsran::make_byte_buffer(); nas_tmp.pack_service_reject(nas_tx.get(), LIBLTE_MME_EMM_CAUSE_IMPLICITLY_DETACHED); s1ap->send_downlink_nas_transport(enb_ue_s1ap_id, nas_tmp.m_ecm_ctx.mme_ue_s1ap_id, nas_tx.get(), *enb_sri); return true; @@ -605,7 +605,7 @@ bool nas::handle_service_request(uint32_t m_tmsi, mac_valid = nas_ctx->short_integrity_check(nas_rx); if (mac_valid) { - srslte::console("Service Request -- Short MAC valid\n"); + srsran::console("Service Request -- Short MAC valid\n"); nas_logger.info("Service Request -- Short MAC valid"); if (ecm_ctx->state == ECM_STATE_CONNECTED) { nas_logger.error("Service Request -- User is ECM CONNECTED"); @@ -621,7 +621,7 @@ bool nas::handle_service_request(uint32_t m_tmsi, ecm_ctx->enb_ue_s1ap_id = enb_ue_s1ap_id; // UE not connect. Connect normally. - srslte::console("Service Request -- User is ECM DISCONNECTED\n"); + srsran::console("Service Request -- User is ECM DISCONNECTED\n"); nas_logger.info("Service Request -- User is ECM DISCONNECTED"); // Create ECM context @@ -639,14 +639,14 @@ bool nas::handle_service_request(uint32_t m_tmsi, nas_logger.error("UE has no valid IP assigned upon reception of service request"); } - srslte::console("UE previously assigned IP: %s\n", inet_ntoa(emm_ctx->ue_ip)); + srsran::console("UE previously assigned IP: %s\n", inet_ntoa(emm_ctx->ue_ip)); // Re-generate K_eNB - srslte::security_generate_k_enb(sec_ctx->k_asme, sec_ctx->ul_nas_count, sec_ctx->k_enb); + srsran::security_generate_k_enb(sec_ctx->k_asme, sec_ctx->ul_nas_count, sec_ctx->k_enb); nas_logger.info("Generating KeNB with UL NAS COUNT: %d", sec_ctx->ul_nas_count); - srslte::console("Generating KeNB with UL NAS COUNT: %d\n", sec_ctx->ul_nas_count); + srsran::console("Generating KeNB with UL NAS COUNT: %d\n", sec_ctx->ul_nas_count); nas_logger.info(sec_ctx->k_enb, 32, "Key eNodeB (k_enb)"); - srslte::console("UE Ctr TEID %d\n", emm_ctx->sgw_ctrl_fteid.teid); + srsran::console("UE Ctr TEID %d\n", emm_ctx->sgw_ctrl_fteid.teid); // Stop T3413 if running if (mme->is_nas_timer_running(T_3413, emm_ctx->imsi)) { @@ -658,7 +658,7 @@ bool nas::handle_service_request(uint32_t m_tmsi, s1ap->send_initial_context_setup_request(imsi, 5); sec_ctx->ul_nas_count++; } else { - srslte::console("Service Request -- Short MAC invalid\n"); + srsran::console("Service Request -- Short MAC invalid\n"); nas_logger.info("Service Request -- Short MAC invalid"); if (ecm_ctx->state == ECM_STATE_CONNECTED) { nas_logger.error("Service Request -- User is ECM CONNECTED"); @@ -678,11 +678,11 @@ bool nas::handle_service_request(uint32_t m_tmsi, ecm_ctx->mme_ue_s1ap_id = s1ap->get_next_mme_ue_s1ap_id(); s1ap->add_nas_ctx_to_mme_ue_s1ap_id_map(nas_ctx); s1ap->add_ue_to_enb_set(enb_sri->sinfo_assoc_id, nas_ctx->m_ecm_ctx.mme_ue_s1ap_id); - srslte::unique_byte_buffer_t nas_tx = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t nas_tx = srsran::make_byte_buffer(); nas_ctx->pack_service_reject(nas_tx.get(), LIBLTE_MME_EMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK); s1ap->send_downlink_nas_transport(ecm_ctx->enb_ue_s1ap_id, ecm_ctx->mme_ue_s1ap_id, nas_tx.get(), *enb_sri); - srslte::console("Service Request -- Short MAC invalid. Sending service reject.\n"); + srsran::console("Service Request -- Short MAC invalid. Sending service reject.\n"); nas_logger.warning("Service Request -- Short MAC invalid. Sending service reject."); nas_logger.info("Service Reject -- eNB_UE_S1AP_ID %d MME_UE_S1AP_ID %d.", enb_ue_s1ap_id, ecm_ctx->mme_ue_s1ap_id); } @@ -692,16 +692,16 @@ bool nas::handle_service_request(uint32_t m_tmsi, bool nas::handle_detach_request(uint32_t m_tmsi, uint32_t enb_ue_s1ap_id, struct sctp_sndrcvinfo* enb_sri, - srslte::byte_buffer_t* nas_rx, + srsran::byte_buffer_t* nas_rx, const nas_init_t& args, const nas_if_t& itf) { auto& nas_logger = srslog::fetch_basic_logger("NAS"); nas_logger.info("Detach Request -- S-TMSI 0x%x", m_tmsi); - srslte::console("Detach Request -- S-TMSI 0x%x\n", m_tmsi); + srsran::console("Detach Request -- S-TMSI 0x%x\n", m_tmsi); nas_logger.info("Detach Request -- eNB UE S1AP Id %d", enb_ue_s1ap_id); - srslte::console("Detach Request -- eNB UE S1AP Id %d\n", enb_ue_s1ap_id); + srsran::console("Detach Request -- eNB UE S1AP Id %d\n", enb_ue_s1ap_id); bool mac_valid = false; LIBLTE_MME_DETACH_REQUEST_MSG_STRUCT detach_req; @@ -719,14 +719,14 @@ bool nas::handle_detach_request(uint32_t m_tmsi, uint64_t imsi = s1ap->find_imsi_from_m_tmsi(m_tmsi); if (imsi == 0) { - srslte::console("Could not find IMSI from M-TMSI. M-TMSI 0x%x\n", m_tmsi); + srsran::console("Could not find IMSI from M-TMSI. M-TMSI 0x%x\n", m_tmsi); nas_logger.error("Could not find IMSI from M-TMSI. M-TMSI 0x%x", m_tmsi); return true; } nas* nas_ctx = s1ap->find_nas_ctx_from_imsi(imsi); if (nas_ctx == NULL) { - srslte::console("Could not find UE context from IMSI\n"); + srsran::console("Could not find UE context from IMSI\n"); nas_logger.error("Could not find UE context from IMSI"); return true; } @@ -744,7 +744,7 @@ bool nas::handle_detach_request(uint32_t m_tmsi, esm_ctx.state = ERAB_DEACTIVATED; } - srslte::console("Received. M-TMSI 0x%x\n", m_tmsi); + srsran::console("Received. M-TMSI 0x%x\n", m_tmsi); // Received detach request as an initial UE message // eNB created new ECM context to send the detach request; this needs to be cleared. ecm_ctx->mme_ue_s1ap_id = s1ap->get_next_mme_ue_s1ap_id(); @@ -756,18 +756,18 @@ bool nas::handle_detach_request(uint32_t m_tmsi, bool nas::handle_tracking_area_update_request(uint32_t m_tmsi, uint32_t enb_ue_s1ap_id, struct sctp_sndrcvinfo* enb_sri, - srslte::byte_buffer_t* nas_rx, + srsran::byte_buffer_t* nas_rx, const nas_init_t& args, const nas_if_t& itf) { auto& nas_logger = srslog::fetch_basic_logger("NAS"); nas_logger.info("Tracking Area Update Request -- S-TMSI 0x%x", m_tmsi); - srslte::console("Tracking Area Update Request -- S-TMSI 0x%x\n", m_tmsi); + srsran::console("Tracking Area Update Request -- S-TMSI 0x%x\n", m_tmsi); nas_logger.info("Tracking Area Update Request -- eNB UE S1AP Id %d", enb_ue_s1ap_id); - srslte::console("Tracking Area Update Request -- eNB UE S1AP Id %d\n", enb_ue_s1ap_id); + srsran::console("Tracking Area Update Request -- eNB UE S1AP Id %d\n", enb_ue_s1ap_id); - srslte::console("Warning: Tracking area update requests are not handled yet.\n"); + srsran::console("Warning: Tracking area update requests are not handled yet.\n"); nas_logger.warning("Tracking area update requests are not handled yet."); // Interfaces @@ -782,7 +782,7 @@ bool nas::handle_tracking_area_update_request(uint32_t m_tmsi, nas_tmp.m_ecm_ctx.enb_ue_s1ap_id = enb_ue_s1ap_id; nas_tmp.m_ecm_ctx.mme_ue_s1ap_id = s1ap->get_next_mme_ue_s1ap_id(); - srslte::unique_byte_buffer_t nas_tx = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t nas_tx = srsran::make_byte_buffer(); nas_tmp.pack_tracking_area_update_reject(nas_tx.get(), LIBLTE_MME_EMM_CAUSE_IMPLICITLY_DETACHED); s1ap->send_downlink_nas_transport(enb_ue_s1ap_id, nas_tmp.m_ecm_ctx.mme_ue_s1ap_id, nas_tx.get(), *enb_sri); return true; @@ -793,7 +793,7 @@ bool nas::handle_tracking_area_update_request(uint32_t m_tmsi, * Handle Uplink NAS Transport messages * ***************************************/ -bool nas::handle_attach_request(srslte::byte_buffer_t* nas_rx) +bool nas::handle_attach_request(srsran::byte_buffer_t* nas_rx) { uint32_t m_tmsi = 0; uint64_t imsi = 0; @@ -818,12 +818,12 @@ bool nas::handle_attach_request(srslte::byte_buffer_t* nas_rx) for (int i = 0; i <= 14; i++) { imsi += attach_req.eps_mobile_id.imsi[i] * std::pow(10, 14 - i); } - srslte::console("Attach request -- IMSI: %015" PRIu64 "\n", imsi); + srsran::console("Attach request -- IMSI: %015" PRIu64 "\n", imsi); m_logger.info("Attach request -- IMSI: %015" PRIu64 "", imsi); } else if (attach_req.eps_mobile_id.type_of_id == LIBLTE_MME_EPS_MOBILE_ID_TYPE_GUTI) { m_tmsi = attach_req.eps_mobile_id.guti.m_tmsi; imsi = m_s1ap->find_imsi_from_m_tmsi(m_tmsi); - srslte::console("Attach request -- M-TMSI: 0x%x\n", m_tmsi); + srsran::console("Attach request -- M-TMSI: 0x%x\n", m_tmsi); m_logger.info("Attach request -- M-TMSI: 0x%x", m_tmsi); } else { m_logger.error("Unhandled Mobile Id type in attach request"); @@ -872,7 +872,7 @@ bool nas::handle_attach_request(srslte::byte_buffer_t* nas_rx) // Get Authentication Vectors from HSS if (!m_hss->gen_auth_info_answer( m_emm_ctx.imsi, m_sec_ctx.k_asme, m_sec_ctx.autn, m_sec_ctx.rand, m_sec_ctx.xres)) { - srslte::console("User not found. IMSI %015" PRIu64 "\n", m_emm_ctx.imsi); + srsran::console("User not found. IMSI %015" PRIu64 "\n", m_emm_ctx.imsi); m_logger.info("User not found. IMSI %015" PRIu64 "", m_emm_ctx.imsi); return false; } @@ -885,7 +885,7 @@ bool nas::handle_attach_request(srslte::byte_buffer_t* nas_rx) m_s1ap->add_nas_ctx_to_imsi_map(this); // Pack NAS Authentication Request in Downlink NAS Transport msg - srslte::unique_byte_buffer_t nas_tx = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t nas_tx = srsran::make_byte_buffer(); pack_authentication_request(nas_tx.get()); // Send reply to eNB @@ -893,7 +893,7 @@ bool nas::handle_attach_request(srslte::byte_buffer_t* nas_rx) m_ecm_ctx.enb_ue_s1ap_id, m_ecm_ctx.mme_ue_s1ap_id, nas_tx.get(), m_ecm_ctx.enb_sri); m_logger.info("Downlink NAS: Sending Authentication Request"); - srslte::console("Downlink NAS: Sending Authentication Request\n"); + srsran::console("Downlink NAS: Sending Authentication Request\n"); return true; } else { m_logger.error("Attach request from known UE"); @@ -901,9 +901,9 @@ bool nas::handle_attach_request(srslte::byte_buffer_t* nas_rx) return true; } -bool nas::handle_authentication_response(srslte::byte_buffer_t* nas_rx) +bool nas::handle_authentication_response(srsran::byte_buffer_t* nas_rx) { - srslte::unique_byte_buffer_t nas_tx; + srsran::unique_byte_buffer_t nas_tx; LIBLTE_MME_AUTHENTICATION_RESPONSE_MSG_STRUCT auth_resp; bool ue_valid = true; @@ -915,7 +915,7 @@ bool nas::handle_authentication_response(srslte::byte_buffer_t* nas_rx) } // Log received authentication response - srslte::console("Authentication Response -- IMSI %015" PRIu64 "\n", m_emm_ctx.imsi); + srsran::console("Authentication Response -- IMSI %015" PRIu64 "\n", m_emm_ctx.imsi); m_logger.info("Authentication Response -- IMSI %015" PRIu64 "", m_emm_ctx.imsi); m_logger.info(auth_resp.res, 8, "Authentication response -- RES"); m_logger.info(m_sec_ctx.xres, 8, "Authentication response -- XRES"); @@ -927,10 +927,10 @@ bool nas::handle_authentication_response(srslte::byte_buffer_t* nas_rx) } } - nas_tx = srslte::make_byte_buffer(); + nas_tx = srsran::make_byte_buffer(); if (!ue_valid) { // Authentication rejected - srslte::console("UE Authentication Rejected.\n"); + srsran::console("UE Authentication Rejected.\n"); m_logger.warning("UE Authentication Rejected."); // Send back Athentication Reject @@ -938,13 +938,13 @@ bool nas::handle_authentication_response(srslte::byte_buffer_t* nas_rx) m_logger.info("Downlink NAS: Sending Authentication Reject."); } else { // Authentication accepted - srslte::console("UE Authentication Accepted.\n"); + srsran::console("UE Authentication Accepted.\n"); m_logger.info("UE Authentication Accepted."); // Send Security Mode Command m_sec_ctx.ul_nas_count = 0; // Reset the NAS uplink counter for the right key k_enb derivation pack_security_mode_command(nas_tx.get()); - srslte::console("Downlink NAS: Sending NAS Security Mode Command.\n"); + srsran::console("Downlink NAS: Sending NAS Security Mode Command.\n"); } // Send reply @@ -953,9 +953,9 @@ bool nas::handle_authentication_response(srslte::byte_buffer_t* nas_rx) return true; } -bool nas::handle_security_mode_complete(srslte::byte_buffer_t* nas_rx) +bool nas::handle_security_mode_complete(srsran::byte_buffer_t* nas_rx) { - srslte::unique_byte_buffer_t nas_tx; + srsran::unique_byte_buffer_t nas_tx; LIBLTE_MME_SECURITY_MODE_COMPLETE_MSG_STRUCT sm_comp; // Get NAS security mode complete @@ -967,13 +967,13 @@ bool nas::handle_security_mode_complete(srslte::byte_buffer_t* nas_rx) // Log security mode complete m_logger.info("Security Mode Command Complete -- IMSI: %015" PRIu64 "", m_emm_ctx.imsi); - srslte::console("Security Mode Command Complete -- IMSI: %015" PRIu64 "\n", m_emm_ctx.imsi); + srsran::console("Security Mode Command Complete -- IMSI: %015" PRIu64 "\n", m_emm_ctx.imsi); // Check wether secure ESM information transfer is required - nas_tx = srslte::make_byte_buffer(); + nas_tx = srsran::make_byte_buffer(); if (m_ecm_ctx.eit == true) { // Secure ESM information transfer is required - srslte::console("Sending ESM information request\n"); + srsran::console("Sending ESM information request\n"); m_logger.info("Sending ESM information request"); // Packing ESM information request @@ -986,18 +986,18 @@ bool nas::handle_security_mode_complete(srslte::byte_buffer_t* nas_rx) uint8_t default_bearer = 5; m_hss->gen_update_loc_answer(m_emm_ctx.imsi, &m_esm_ctx[default_bearer].qci); m_logger.debug("Getting subscription information -- QCI %d", m_esm_ctx[default_bearer].qci); - srslte::console("Getting subscription information -- QCI %d\n", m_esm_ctx[default_bearer].qci); + srsran::console("Getting subscription information -- QCI %d\n", m_esm_ctx[default_bearer].qci); m_gtpc->send_create_session_request(m_emm_ctx.imsi); } return true; } -bool nas::handle_attach_complete(srslte::byte_buffer_t* nas_rx) +bool nas::handle_attach_complete(srsran::byte_buffer_t* nas_rx) { LIBLTE_MME_ATTACH_COMPLETE_MSG_STRUCT attach_comp; uint8_t pd, msg_type; LIBLTE_MME_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_ACCEPT_MSG_STRUCT act_bearer; - srslte::unique_byte_buffer_t nas_tx; + srsran::unique_byte_buffer_t nas_tx; // Get NAS authentication response std::memset(&attach_comp, 0, sizeof(attach_comp)); @@ -1014,8 +1014,8 @@ bool nas::handle_attach_complete(srslte::byte_buffer_t* nas_rx) return false; } - srslte::console("Unpacked Attached Complete Message. IMSI %" PRIu64 "\n", m_emm_ctx.imsi); - srslte::console("Unpacked Activate Default EPS Bearer message. EPS Bearer id %d\n", act_bearer.eps_bearer_id); + srsran::console("Unpacked Attached Complete Message. IMSI %" PRIu64 "\n", m_emm_ctx.imsi); + srsran::console("Unpacked Activate Default EPS Bearer message. EPS Bearer id %d\n", act_bearer.eps_bearer_id); if (act_bearer.eps_bearer_id < 5 || act_bearer.eps_bearer_id > 15) { m_logger.error("EPS Bearer ID out of range"); @@ -1027,26 +1027,26 @@ bool nas::handle_attach_complete(srslte::byte_buffer_t* nas_rx) m_emm_ctx.imsi, act_bearer.eps_bearer_id, &m_esm_ctx[act_bearer.eps_bearer_id].enb_fteid); // Send reply to EMM Info to UE - nas_tx = srslte::make_byte_buffer(); + nas_tx = srsran::make_byte_buffer(); pack_emm_information(nas_tx.get()); m_s1ap->send_downlink_nas_transport( m_ecm_ctx.enb_ue_s1ap_id, m_ecm_ctx.mme_ue_s1ap_id, nas_tx.get(), m_ecm_ctx.enb_sri); - srslte::console("Sending EMM Information\n"); + srsran::console("Sending EMM Information\n"); m_logger.info("Sending EMM Information"); } m_emm_ctx.state = EMM_STATE_REGISTERED; return true; } -bool nas::handle_esm_information_response(srslte::byte_buffer_t* nas_rx) +bool nas::handle_esm_information_response(srsran::byte_buffer_t* nas_rx) { LIBLTE_MME_ESM_INFORMATION_RESPONSE_MSG_STRUCT esm_info_resp; // Get NAS authentication response LIBLTE_ERROR_ENUM err = - srslte_mme_unpack_esm_information_response_msg((LIBLTE_BYTE_MSG_STRUCT*)nas_rx, &esm_info_resp); + srsran_mme_unpack_esm_information_response_msg((LIBLTE_BYTE_MSG_STRUCT*)nas_rx, &esm_info_resp); if (err != LIBLTE_SUCCESS) { m_logger.error("Error unpacking NAS authentication response. Error: %s", liblte_error_text[err]); return false; @@ -1055,18 +1055,18 @@ bool nas::handle_esm_information_response(srslte::byte_buffer_t* nas_rx) m_logger.info("ESM Info: EPS bearer id %d", esm_info_resp.eps_bearer_id); if (esm_info_resp.apn_present) { m_logger.info("ESM Info: APN %s", esm_info_resp.apn.apn); - srslte::console("ESM Info: APN %s\n", esm_info_resp.apn.apn); + srsran::console("ESM Info: APN %s\n", esm_info_resp.apn.apn); } if (esm_info_resp.protocol_cnfg_opts_present) { m_logger.info("ESM Info: %d Protocol Configuration Options", esm_info_resp.protocol_cnfg_opts.N_opts); - srslte::console("ESM Info: %d Protocol Configuration Options\n", esm_info_resp.protocol_cnfg_opts.N_opts); + srsran::console("ESM Info: %d Protocol Configuration Options\n", esm_info_resp.protocol_cnfg_opts.N_opts); } // Get subscriber info from HSS uint8_t default_bearer = 5; m_hss->gen_update_loc_answer(m_emm_ctx.imsi, &m_esm_ctx[default_bearer].qci); m_logger.debug("Getting subscription information -- QCI %d", m_esm_ctx[default_bearer].qci); - srslte::console("Getting subscription information -- QCI %d\n", m_esm_ctx[default_bearer].qci); + srsran::console("Getting subscription information -- QCI %d\n", m_esm_ctx[default_bearer].qci); // TODO The packging of GTP-C messages is not ready. // This means that GTP-U tunnels are created with function calls, as opposed to GTP-C. @@ -1074,9 +1074,9 @@ bool nas::handle_esm_information_response(srslte::byte_buffer_t* nas_rx) return true; } -bool nas::handle_identity_response(srslte::byte_buffer_t* nas_rx) +bool nas::handle_identity_response(srsran::byte_buffer_t* nas_rx) { - srslte::unique_byte_buffer_t nas_tx; + srsran::unique_byte_buffer_t nas_tx; LIBLTE_MME_ID_RESPONSE_MSG_STRUCT id_resp; LIBLTE_ERROR_ENUM err = liblte_mme_unpack_identity_response_msg((LIBLTE_BYTE_MSG_STRUCT*)nas_rx, &id_resp); @@ -1091,14 +1091,14 @@ bool nas::handle_identity_response(srslte::byte_buffer_t* nas_rx) } m_logger.info("ID response -- IMSI: %015" PRIu64 "", imsi); - srslte::console("ID Response -- IMSI: %015" PRIu64 "\n", imsi); + srsran::console("ID Response -- IMSI: %015" PRIu64 "\n", imsi); // Set UE's IMSI m_emm_ctx.imsi = imsi; // Get Authentication Vectors from HSS if (!m_hss->gen_auth_info_answer(imsi, m_sec_ctx.k_asme, m_sec_ctx.autn, m_sec_ctx.rand, m_sec_ctx.xres)) { - srslte::console("User not found. IMSI %015" PRIu64 "\n", imsi); + srsran::console("User not found. IMSI %015" PRIu64 "\n", imsi); m_logger.info("User not found. IMSI %015" PRIu64 "", imsi); return false; } @@ -1116,7 +1116,7 @@ bool nas::handle_identity_response(srslte::byte_buffer_t* nas_rx) m_s1ap->add_nas_ctx_to_imsi_map(this); // Pack NAS Authentication Request in Downlink NAS Transport msg - nas_tx = srslte::make_byte_buffer(); + nas_tx = srsran::make_byte_buffer(); pack_authentication_request(nas_tx.get()); // Send reply to eNB @@ -1124,20 +1124,20 @@ bool nas::handle_identity_response(srslte::byte_buffer_t* nas_rx) m_ecm_ctx.enb_ue_s1ap_id, m_ecm_ctx.mme_ue_s1ap_id, nas_tx.get(), m_ecm_ctx.enb_sri); m_logger.info("Downlink NAS: Sent Authentication Request"); - srslte::console("Downlink NAS: Sent Authentication Request\n"); + srsran::console("Downlink NAS: Sent Authentication Request\n"); return true; } -bool nas::handle_tracking_area_update_request(srslte::byte_buffer_t* nas_rx) +bool nas::handle_tracking_area_update_request(srsran::byte_buffer_t* nas_rx) { - srslte::console("Warning: Tracking Area Update Request messages not handled yet.\n"); + srsran::console("Warning: Tracking Area Update Request messages not handled yet.\n"); m_logger.warning("Warning: Tracking Area Update Request messages not handled yet."); - srslte::unique_byte_buffer_t nas_tx; + srsran::unique_byte_buffer_t nas_tx; /* TAU handling unsupported, therefore send TAU reject with cause IMPLICITLY DETACHED. * this will trigger full re-attach by the UE, instead of going to a TAU request loop */ - nas_tx = srslte::make_byte_buffer(); + nas_tx = srsran::make_byte_buffer(); // TODO we could enable integrity protection in some cases, but UE should comply anyway pack_tracking_area_update_reject(nas_tx.get(), LIBLTE_MME_EMM_CAUSE_IMPLICITLY_DETACHED); // Send reply @@ -1147,11 +1147,11 @@ bool nas::handle_tracking_area_update_request(srslte::byte_buffer_t* nas_rx) return true; } -bool nas::handle_authentication_failure(srslte::byte_buffer_t* nas_rx) +bool nas::handle_authentication_failure(srsran::byte_buffer_t* nas_rx) { m_logger.info("Received Authentication Failure"); - srslte::unique_byte_buffer_t nas_tx; + srsran::unique_byte_buffer_t nas_tx; LIBLTE_MME_AUTHENTICATION_FAILURE_MSG_STRUCT auth_fail; LIBLTE_ERROR_ENUM err; @@ -1163,29 +1163,29 @@ bool nas::handle_authentication_failure(srslte::byte_buffer_t* nas_rx) switch (auth_fail.emm_cause) { case 20: - srslte::console("MAC code failure\n"); + srsran::console("MAC code failure\n"); m_logger.info("MAC code failure"); break; case 26: - srslte::console("Non-EPS authentication unacceptable\n"); + srsran::console("Non-EPS authentication unacceptable\n"); m_logger.info("Non-EPS authentication unacceptable"); break; case 21: - srslte::console("Authentication Failure -- Synchronization Failure\n"); + srsran::console("Authentication Failure -- Synchronization Failure\n"); m_logger.info("Authentication Failure -- Synchronization Failure"); if (auth_fail.auth_fail_param_present == false) { m_logger.error("Missing fail parameter"); return false; } if (!m_hss->resync_sqn(m_emm_ctx.imsi, auth_fail.auth_fail_param)) { - srslte::console("Resynchronization failed. IMSI %015" PRIu64 "\n", m_emm_ctx.imsi); + srsran::console("Resynchronization failed. IMSI %015" PRIu64 "\n", m_emm_ctx.imsi); m_logger.info("Resynchronization failed. IMSI %015" PRIu64 "", m_emm_ctx.imsi); return false; } // Get Authentication Vectors from HSS if (!m_hss->gen_auth_info_answer( m_emm_ctx.imsi, m_sec_ctx.k_asme, m_sec_ctx.autn, m_sec_ctx.rand, m_sec_ctx.xres)) { - srslte::console("User not found. IMSI %015" PRIu64 "\n", m_emm_ctx.imsi); + srsran::console("User not found. IMSI %015" PRIu64 "\n", m_emm_ctx.imsi); m_logger.info("User not found. IMSI %015" PRIu64 "", m_emm_ctx.imsi); return false; } @@ -1194,7 +1194,7 @@ bool nas::handle_authentication_failure(srslte::byte_buffer_t* nas_rx) m_sec_ctx.eksi = (m_sec_ctx.eksi + 1) % 6; // Pack NAS Authentication Request in Downlink NAS Transport msg - nas_tx = srslte::make_byte_buffer(); + nas_tx = srsran::make_byte_buffer(); pack_authentication_request(nas_tx.get()); // Send reply to eNB @@ -1202,16 +1202,16 @@ bool nas::handle_authentication_failure(srslte::byte_buffer_t* nas_rx) m_ecm_ctx.enb_ue_s1ap_id, m_ecm_ctx.mme_ue_s1ap_id, nas_tx.get(), m_ecm_ctx.enb_sri); m_logger.info("Downlink NAS: Sent Authentication Request"); - srslte::console("Downlink NAS: Sent Authentication Request\n"); + srsran::console("Downlink NAS: Sent Authentication Request\n"); // TODO Start T3460 Timer! break; } return true; } -bool nas::handle_detach_request(srslte::byte_buffer_t* nas_msg) +bool nas::handle_detach_request(srsran::byte_buffer_t* nas_msg) { - srslte::console("Detach request -- IMSI %015" PRIu64 "\n", m_emm_ctx.imsi); + srsran::console("Detach request -- IMSI %015" PRIu64 "\n", m_emm_ctx.imsi); m_logger.info("Detach request -- IMSI %015" PRIu64 "", m_emm_ctx.imsi); LIBLTE_MME_DETACH_REQUEST_MSG_STRUCT detach_req; @@ -1236,7 +1236,7 @@ bool nas::handle_detach_request(srslte::byte_buffer_t* nas_msg) } /*Packing/Unpacking helper functions*/ -bool nas::pack_authentication_request(srslte::byte_buffer_t* nas_buffer) +bool nas::pack_authentication_request(srsran::byte_buffer_t* nas_buffer) { m_logger.info("Packing Authentication Request"); @@ -1250,13 +1250,13 @@ bool nas::pack_authentication_request(srslte::byte_buffer_t* nas_buffer) LIBLTE_ERROR_ENUM err = liblte_mme_pack_authentication_request_msg(&auth_req, (LIBLTE_BYTE_MSG_STRUCT*)nas_buffer); if (err != LIBLTE_SUCCESS) { m_logger.error("Error packing Authentication Request"); - srslte::console("Error packing Authentication Request\n"); + srsran::console("Error packing Authentication Request\n"); return false; } return true; } -bool nas::pack_authentication_reject(srslte::byte_buffer_t* nas_buffer) +bool nas::pack_authentication_reject(srsran::byte_buffer_t* nas_buffer) { m_logger.info("Packing Authentication Reject"); @@ -1264,13 +1264,13 @@ bool nas::pack_authentication_reject(srslte::byte_buffer_t* nas_buffer) LIBLTE_ERROR_ENUM err = liblte_mme_pack_authentication_reject_msg(&auth_rej, (LIBLTE_BYTE_MSG_STRUCT*)nas_buffer); if (err != LIBLTE_SUCCESS) { m_logger.error("Error packing Authentication Reject"); - srslte::console("Error packing Authentication Reject\n"); + srsran::console("Error packing Authentication Reject\n"); return false; } return true; } -bool nas::pack_security_mode_command(srslte::byte_buffer_t* nas_buffer) +bool nas::pack_security_mode_command(srsran::byte_buffer_t* nas_buffer) { m_logger.info("Packing Security Mode Command"); @@ -1304,21 +1304,21 @@ bool nas::pack_security_mode_command(srslte::byte_buffer_t* nas_buffer) LIBLTE_ERROR_ENUM err = liblte_mme_pack_security_mode_command_msg( &sm_cmd, sec_hdr_type, m_sec_ctx.dl_nas_count, (LIBLTE_BYTE_MSG_STRUCT*)nas_buffer); if (err != LIBLTE_SUCCESS) { - srslte::console("Error packing Authentication Request\n"); + srsran::console("Error packing Authentication Request\n"); return false; } // Generate EPS security context - srslte::security_generate_k_nas( + srsran::security_generate_k_nas( m_sec_ctx.k_asme, m_sec_ctx.cipher_algo, m_sec_ctx.integ_algo, m_sec_ctx.k_nas_enc, m_sec_ctx.k_nas_int); m_logger.info(m_sec_ctx.k_nas_enc, 32, "Key NAS Encryption (k_nas_enc)"); m_logger.info(m_sec_ctx.k_nas_int, 32, "Key NAS Integrity (k_nas_int)"); uint8_t key_enb[32]; - srslte::security_generate_k_enb(m_sec_ctx.k_asme, m_sec_ctx.ul_nas_count, m_sec_ctx.k_enb); + srsran::security_generate_k_enb(m_sec_ctx.k_asme, m_sec_ctx.ul_nas_count, m_sec_ctx.k_enb); m_logger.info("Generating KeNB with UL NAS COUNT: %d", m_sec_ctx.ul_nas_count); - srslte::console("Generating KeNB with UL NAS COUNT: %d\n", m_sec_ctx.ul_nas_count); + srsran::console("Generating KeNB with UL NAS COUNT: %d\n", m_sec_ctx.ul_nas_count); m_logger.info(m_sec_ctx.k_enb, 32, "Key eNodeB (k_enb)"); // Generate MAC for integrity protection @@ -1328,7 +1328,7 @@ bool nas::pack_security_mode_command(srslte::byte_buffer_t* nas_buffer) return true; } -bool nas::pack_esm_information_request(srslte::byte_buffer_t* nas_buffer) +bool nas::pack_esm_information_request(srsran::byte_buffer_t* nas_buffer) { m_logger.info("Packing ESM Information request"); @@ -1339,11 +1339,11 @@ bool nas::pack_esm_information_request(srslte::byte_buffer_t* nas_buffer) uint8_t sec_hdr_type = LIBLTE_MME_SECURITY_HDR_TYPE_INTEGRITY_AND_CIPHERED; m_sec_ctx.dl_nas_count++; - LIBLTE_ERROR_ENUM err = srslte_mme_pack_esm_information_request_msg( + LIBLTE_ERROR_ENUM err = srsran_mme_pack_esm_information_request_msg( &esm_info_req, sec_hdr_type, m_sec_ctx.dl_nas_count, (LIBLTE_BYTE_MSG_STRUCT*)nas_buffer); if (err != LIBLTE_SUCCESS) { m_logger.error("Error packing ESM information request"); - srslte::console("Error packing ESM information request\n"); + srsran::console("Error packing ESM information request\n"); return false; } @@ -1355,7 +1355,7 @@ bool nas::pack_esm_information_request(srslte::byte_buffer_t* nas_buffer) return true; } -bool nas::pack_attach_accept(srslte::byte_buffer_t* nas_buffer) +bool nas::pack_attach_accept(srsran::byte_buffer_t* nas_buffer) { m_logger.info("Packing Attach Accept"); @@ -1486,7 +1486,7 @@ bool nas::pack_attach_accept(srslte::byte_buffer_t* nas_buffer) return true; } -bool nas::pack_identity_request(srslte::byte_buffer_t* nas_buffer) +bool nas::pack_identity_request(srsran::byte_buffer_t* nas_buffer) { m_logger.info("Packing Identity Request"); @@ -1495,13 +1495,13 @@ bool nas::pack_identity_request(srslte::byte_buffer_t* nas_buffer) LIBLTE_ERROR_ENUM err = liblte_mme_pack_identity_request_msg(&id_req, (LIBLTE_BYTE_MSG_STRUCT*)nas_buffer); if (err != LIBLTE_SUCCESS) { m_logger.error("Error packing Identity Request"); - srslte::console("Error packing Identity Request\n"); + srsran::console("Error packing Identity Request\n"); return false; } return true; } -bool nas::pack_emm_information(srslte::byte_buffer_t* nas_buffer) +bool nas::pack_emm_information(srsran::byte_buffer_t* nas_buffer) { m_logger.info("Packing EMM Information"); @@ -1510,7 +1510,7 @@ bool nas::pack_emm_information(srslte::byte_buffer_t* nas_buffer) strncpy(emm_info.full_net_name.name, "Software Radio Systems LTE", LIBLTE_STRING_LEN); emm_info.full_net_name.add_ci = LIBLTE_MME_ADD_CI_DONT_ADD; emm_info.short_net_name_present = true; - strncpy(emm_info.short_net_name.name, "srsLTE", LIBLTE_STRING_LEN); + strncpy(emm_info.short_net_name.name, "srsRAN", LIBLTE_STRING_LEN); emm_info.short_net_name.add_ci = LIBLTE_MME_ADD_CI_DONT_ADD; emm_info.local_time_zone_present = false; @@ -1538,7 +1538,7 @@ bool nas::pack_emm_information(srslte::byte_buffer_t* nas_buffer) &emm_info, sec_hdr_type, m_sec_ctx.dl_nas_count, (LIBLTE_BYTE_MSG_STRUCT*)nas_buffer); if (err != LIBLTE_SUCCESS) { m_logger.error("Error packing EMM Information"); - srslte::console("Error packing EMM Information\n"); + srsran::console("Error packing EMM Information\n"); return false; } @@ -1554,7 +1554,7 @@ bool nas::pack_emm_information(srslte::byte_buffer_t* nas_buffer) return true; } -bool nas::pack_service_reject(srslte::byte_buffer_t* nas_buffer, uint8_t emm_cause) +bool nas::pack_service_reject(srsran::byte_buffer_t* nas_buffer, uint8_t emm_cause) { LIBLTE_MME_SERVICE_REJECT_MSG_STRUCT service_rej; service_rej.t3442_present = true; @@ -1568,13 +1568,13 @@ bool nas::pack_service_reject(srslte::byte_buffer_t* nas_buffer, uint8_t emm_cau &service_rej, LIBLTE_MME_SECURITY_HDR_TYPE_PLAIN_NAS, 0, (LIBLTE_BYTE_MSG_STRUCT*)nas_buffer); if (err != LIBLTE_SUCCESS) { m_logger.error("Error packing Service Reject"); - srslte::console("Error packing Service Reject\n"); + srsran::console("Error packing Service Reject\n"); return false; } return true; } -bool nas::pack_tracking_area_update_reject(srslte::byte_buffer_t* nas_buffer, uint8_t emm_cause) +bool nas::pack_tracking_area_update_reject(srsran::byte_buffer_t* nas_buffer, uint8_t emm_cause) { LIBLTE_MME_TRACKING_AREA_UPDATE_REJECT_MSG_STRUCT tau_rej; tau_rej.t3446_present = false; @@ -1590,7 +1590,7 @@ bool nas::pack_tracking_area_update_reject(srslte::byte_buffer_t* nas_buffer, ui &tau_rej, LIBLTE_MME_SECURITY_HDR_TYPE_PLAIN_NAS, 0, (LIBLTE_BYTE_MSG_STRUCT*)nas_buffer); if (err != LIBLTE_SUCCESS) { m_logger.error("Error packing Tracking Area Update Reject"); - srslte::console("Error packing Tracking Area Update Reject\n"); + srsran::console("Error packing Tracking Area Update Reject\n"); return false; } return true; @@ -1601,7 +1601,7 @@ bool nas::pack_tracking_area_update_reject(srslte::byte_buffer_t* nas_buffer, ui * Security Functions * ************************/ -bool nas::short_integrity_check(srslte::byte_buffer_t* pdu) +bool nas::short_integrity_check(srsran::byte_buffer_t* pdu) { uint8_t exp_mac[4] = {0x00, 0x00, 0x00, 0x00}; uint8_t* mac = &pdu->msg[2]; @@ -1613,31 +1613,31 @@ bool nas::short_integrity_check(srslte::byte_buffer_t* pdu) } switch (m_sec_ctx.integ_algo) { - case srslte::INTEGRITY_ALGORITHM_ID_EIA0: + case srsran::INTEGRITY_ALGORITHM_ID_EIA0: break; - case srslte::INTEGRITY_ALGORITHM_ID_128_EIA1: - srslte::security_128_eia1(&m_sec_ctx.k_nas_int[16], + case srsran::INTEGRITY_ALGORITHM_ID_128_EIA1: + srsran::security_128_eia1(&m_sec_ctx.k_nas_int[16], m_sec_ctx.ul_nas_count, 0, - srslte::SECURITY_DIRECTION_UPLINK, + srsran::SECURITY_DIRECTION_UPLINK, &pdu->msg[0], 2, &exp_mac[0]); break; - case srslte::INTEGRITY_ALGORITHM_ID_128_EIA2: - srslte::security_128_eia2(&m_sec_ctx.k_nas_int[16], + case srsran::INTEGRITY_ALGORITHM_ID_128_EIA2: + srsran::security_128_eia2(&m_sec_ctx.k_nas_int[16], m_sec_ctx.ul_nas_count, 0, - srslte::SECURITY_DIRECTION_UPLINK, + srsran::SECURITY_DIRECTION_UPLINK, &pdu->msg[0], 2, &exp_mac[0]); break; - case srslte::INTEGRITY_ALGORITHM_ID_128_EIA3: - srslte::security_128_eia3(&m_sec_ctx.k_nas_int[16], + case srsran::INTEGRITY_ALGORITHM_ID_128_EIA3: + srsran::security_128_eia3(&m_sec_ctx.k_nas_int[16], m_sec_ctx.ul_nas_count, 0, - srslte::SECURITY_DIRECTION_UPLINK, + srsran::SECURITY_DIRECTION_UPLINK, &pdu->msg[0], 2, &exp_mac[0]); @@ -1665,7 +1665,7 @@ bool nas::short_integrity_check(srslte::byte_buffer_t* pdu) return true; } -bool nas::integrity_check(srslte::byte_buffer_t* pdu) +bool nas::integrity_check(srsran::byte_buffer_t* pdu) { uint8_t exp_mac[4] = {}; const uint8_t* mac = &pdu->msg[1]; @@ -1673,31 +1673,31 @@ bool nas::integrity_check(srslte::byte_buffer_t* pdu) uint32_t estimated_count = (m_sec_ctx.ul_nas_count & 0xffffff00) | (pdu->msg[5] & 0xff); switch (m_sec_ctx.integ_algo) { - case srslte::INTEGRITY_ALGORITHM_ID_EIA0: + case srsran::INTEGRITY_ALGORITHM_ID_EIA0: break; - case srslte::INTEGRITY_ALGORITHM_ID_128_EIA1: - srslte::security_128_eia1(&m_sec_ctx.k_nas_int[16], + case srsran::INTEGRITY_ALGORITHM_ID_128_EIA1: + srsran::security_128_eia1(&m_sec_ctx.k_nas_int[16], estimated_count, 0, - srslte::SECURITY_DIRECTION_UPLINK, + srsran::SECURITY_DIRECTION_UPLINK, &pdu->msg[5], pdu->N_bytes - 5, &exp_mac[0]); break; - case srslte::INTEGRITY_ALGORITHM_ID_128_EIA2: - srslte::security_128_eia2(&m_sec_ctx.k_nas_int[16], + case srsran::INTEGRITY_ALGORITHM_ID_128_EIA2: + srsran::security_128_eia2(&m_sec_ctx.k_nas_int[16], estimated_count, 0, - srslte::SECURITY_DIRECTION_UPLINK, + srsran::SECURITY_DIRECTION_UPLINK, &pdu->msg[5], pdu->N_bytes - 5, &exp_mac[0]); break; - case srslte::INTEGRITY_ALGORITHM_ID_128_EIA3: - srslte::security_128_eia3(&m_sec_ctx.k_nas_int[16], + case srsran::INTEGRITY_ALGORITHM_ID_128_EIA3: + srsran::security_128_eia3(&m_sec_ctx.k_nas_int[16], estimated_count, 0, - srslte::SECURITY_DIRECTION_UPLINK, + srsran::SECURITY_DIRECTION_UPLINK, &pdu->msg[5], pdu->N_bytes - 5, &exp_mac[0]); @@ -1731,34 +1731,34 @@ bool nas::integrity_check(srslte::byte_buffer_t* pdu) return true; } -void nas::integrity_generate(srslte::byte_buffer_t* pdu, uint8_t* mac) +void nas::integrity_generate(srsran::byte_buffer_t* pdu, uint8_t* mac) { switch (m_sec_ctx.integ_algo) { - case srslte::INTEGRITY_ALGORITHM_ID_EIA0: + case srsran::INTEGRITY_ALGORITHM_ID_EIA0: break; - case srslte::INTEGRITY_ALGORITHM_ID_128_EIA1: - srslte::security_128_eia1(&m_sec_ctx.k_nas_int[16], + case srsran::INTEGRITY_ALGORITHM_ID_128_EIA1: + srsran::security_128_eia1(&m_sec_ctx.k_nas_int[16], m_sec_ctx.dl_nas_count, 0, // Bearer always 0 for NAS - srslte::SECURITY_DIRECTION_DOWNLINK, + srsran::SECURITY_DIRECTION_DOWNLINK, &pdu->msg[5], pdu->N_bytes - 5, mac); break; - case srslte::INTEGRITY_ALGORITHM_ID_128_EIA2: - srslte::security_128_eia2(&m_sec_ctx.k_nas_int[16], + case srsran::INTEGRITY_ALGORITHM_ID_128_EIA2: + srsran::security_128_eia2(&m_sec_ctx.k_nas_int[16], m_sec_ctx.dl_nas_count, 0, // Bearer always 0 for NAS - srslte::SECURITY_DIRECTION_DOWNLINK, + srsran::SECURITY_DIRECTION_DOWNLINK, &pdu->msg[5], pdu->N_bytes - 5, mac); break; - case srslte::INTEGRITY_ALGORITHM_ID_128_EIA3: - srslte::security_128_eia3(&m_sec_ctx.k_nas_int[16], + case srsran::INTEGRITY_ALGORITHM_ID_128_EIA3: + srsran::security_128_eia3(&m_sec_ctx.k_nas_int[16], m_sec_ctx.dl_nas_count, 0, // Bearer always 0 for NAS - srslte::SECURITY_DIRECTION_DOWNLINK, + srsran::SECURITY_DIRECTION_DOWNLINK, &pdu->msg[5], pdu->N_bytes - 5, mac); @@ -1767,43 +1767,43 @@ void nas::integrity_generate(srslte::byte_buffer_t* pdu, uint8_t* mac) break; } m_logger.debug("Generating MAC with inputs: Algorithm %s, DL COUNT %d", - srslte::integrity_algorithm_id_text[m_sec_ctx.integ_algo], + srsran::integrity_algorithm_id_text[m_sec_ctx.integ_algo], m_sec_ctx.dl_nas_count); } -void nas::cipher_decrypt(srslte::byte_buffer_t* pdu) +void nas::cipher_decrypt(srsran::byte_buffer_t* pdu) { - srslte::byte_buffer_t tmp_pdu; + srsran::byte_buffer_t tmp_pdu; switch (m_sec_ctx.cipher_algo) { - case srslte::CIPHERING_ALGORITHM_ID_EEA0: + case srsran::CIPHERING_ALGORITHM_ID_EEA0: break; - case srslte::CIPHERING_ALGORITHM_ID_128_EEA1: - srslte::security_128_eea1(&m_sec_ctx.k_nas_enc[16], + case srsran::CIPHERING_ALGORITHM_ID_128_EEA1: + srsran::security_128_eea1(&m_sec_ctx.k_nas_enc[16], pdu->msg[5], 0, // Bearer always 0 for NAS - srslte::SECURITY_DIRECTION_UPLINK, + srsran::SECURITY_DIRECTION_UPLINK, &pdu->msg[6], pdu->N_bytes - 6, &tmp_pdu.msg[6]); memcpy(&pdu->msg[6], &tmp_pdu.msg[6], pdu->N_bytes - 6); m_logger.debug(tmp_pdu.msg, pdu->N_bytes, "Decrypted"); break; - case srslte::CIPHERING_ALGORITHM_ID_128_EEA2: - srslte::security_128_eea2(&m_sec_ctx.k_nas_enc[16], + case srsran::CIPHERING_ALGORITHM_ID_128_EEA2: + srsran::security_128_eea2(&m_sec_ctx.k_nas_enc[16], pdu->msg[5], 0, // Bearer always 0 for NAS - srslte::SECURITY_DIRECTION_UPLINK, + srsran::SECURITY_DIRECTION_UPLINK, &pdu->msg[6], pdu->N_bytes - 6, &tmp_pdu.msg[6]); m_logger.debug(tmp_pdu.msg, pdu->N_bytes, "Decrypted"); memcpy(&pdu->msg[6], &tmp_pdu.msg[6], pdu->N_bytes - 6); break; - case srslte::CIPHERING_ALGORITHM_ID_128_EEA3: - srslte::security_128_eea3(&m_sec_ctx.k_nas_enc[16], + case srsran::CIPHERING_ALGORITHM_ID_128_EEA3: + srsran::security_128_eea3(&m_sec_ctx.k_nas_enc[16], pdu->msg[5], 0, // Bearer always 0 for NAS - srslte::SECURITY_DIRECTION_UPLINK, + srsran::SECURITY_DIRECTION_UPLINK, &pdu->msg[6], pdu->N_bytes - 6, &tmp_pdu.msg[6]); @@ -1816,39 +1816,39 @@ void nas::cipher_decrypt(srslte::byte_buffer_t* pdu) } } -void nas::cipher_encrypt(srslte::byte_buffer_t* pdu) +void nas::cipher_encrypt(srsran::byte_buffer_t* pdu) { - srslte::byte_buffer_t pdu_tmp; + srsran::byte_buffer_t pdu_tmp; switch (m_sec_ctx.cipher_algo) { - case srslte::CIPHERING_ALGORITHM_ID_EEA0: + case srsran::CIPHERING_ALGORITHM_ID_EEA0: break; - case srslte::CIPHERING_ALGORITHM_ID_128_EEA1: - srslte::security_128_eea1(&m_sec_ctx.k_nas_enc[16], + case srsran::CIPHERING_ALGORITHM_ID_128_EEA1: + srsran::security_128_eea1(&m_sec_ctx.k_nas_enc[16], pdu->msg[5], 0, // Bearer always 0 for NAS - srslte::SECURITY_DIRECTION_DOWNLINK, + srsran::SECURITY_DIRECTION_DOWNLINK, &pdu->msg[6], pdu->N_bytes - 6, &pdu_tmp.msg[6]); memcpy(&pdu->msg[6], &pdu_tmp.msg[6], pdu->N_bytes - 6); m_logger.debug(pdu_tmp.msg, pdu->N_bytes, "Encrypted"); break; - case srslte::CIPHERING_ALGORITHM_ID_128_EEA2: - srslte::security_128_eea2(&m_sec_ctx.k_nas_enc[16], + case srsran::CIPHERING_ALGORITHM_ID_128_EEA2: + srsran::security_128_eea2(&m_sec_ctx.k_nas_enc[16], pdu->msg[5], 0, // Bearer always 0 for NAS - srslte::SECURITY_DIRECTION_DOWNLINK, + srsran::SECURITY_DIRECTION_DOWNLINK, &pdu->msg[6], pdu->N_bytes - 6, &pdu_tmp.msg[6]); memcpy(&pdu->msg[6], &pdu_tmp.msg[6], pdu->N_bytes - 6); m_logger.debug(pdu_tmp.msg, pdu->N_bytes, "Encrypted"); break; - case srslte::CIPHERING_ALGORITHM_ID_128_EEA3: - srslte::security_128_eea3(&m_sec_ctx.k_nas_enc[16], + case srsran::CIPHERING_ALGORITHM_ID_128_EEA3: + srsran::security_128_eea3(&m_sec_ctx.k_nas_enc[16], pdu->msg[5], 0, // Bearer always 0 for NAS - srslte::SECURITY_DIRECTION_DOWNLINK, + srsran::SECURITY_DIRECTION_DOWNLINK, &pdu->msg[6], pdu->N_bytes - 6, &pdu_tmp.msg[6]); @@ -1927,14 +1927,14 @@ bool nas::start_t3413() bool nas::expire_t3413() { m_logger.info("T3413 expired -- Could not page the ue."); - srslte::console("T3413 expired -- Could not page the ue.\n"); + srsran::console("T3413 expired -- Could not page the ue.\n"); if (m_emm_ctx.state != EMM_STATE_REGISTERED) { m_logger.error("EMM invalid status upon T3413 expiration"); return false; } // Send Paging Failure to the SPGW m_gtpc->send_downlink_data_notification_failure_indication(m_emm_ctx.imsi, - srslte::GTPC_CAUSE_VALUE_UE_NOT_RESPONDING); + srsran::GTPC_CAUSE_VALUE_UE_NOT_RESPONDING); return true; } diff --git a/srsepc/src/mme/s1ap.cc b/srsepc/src/mme/s1ap.cc index 8b6155bec..385d6ca80 100644 --- a/srsepc/src/mme/s1ap.cc +++ b/srsepc/src/mme/s1ap.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,9 +11,9 @@ */ #include "srsepc/hdr/mme/s1ap.h" -#include "srslte/asn1/gtpc.h" -#include "srslte/common/bcd_helpers.h" -#include "srslte/common/liblte_security.h" +#include "srsran/asn1/gtpc.h" +#include "srsran/common/bcd_helpers.h" +#include "srsran/common/liblte_security.h" #include #include // for printing uint64_t @@ -52,7 +52,7 @@ void s1ap::cleanup(void) int s1ap::init(s1ap_args_t s1ap_args) { m_s1ap_args = s1ap_args; - srslte::s1ap_mccmnc_to_plmn(s1ap_args.mcc, s1ap_args.mnc, &m_plmn); + srsran::s1ap_mccmnc_to_plmn(s1ap_args.mcc, s1ap_args.mnc, &m_plmn); m_next_m_tmsi = rand(); // Get pointer to the HSS @@ -92,7 +92,7 @@ void s1ap::stop() std::map::iterator enb_it = m_active_enbs.begin(); while (enb_it != m_active_enbs.end()) { m_logger.info("Deleting eNB context. eNB Id: 0x%x", enb_it->second->enb_id); - srslte::console("Deleting eNB context. eNB Id: 0x%x\n", enb_it->second->enb_id); + srsran::console("Deleting eNB context. eNB Id: 0x%x\n", enb_it->second->enb_id); delete enb_it->second; m_active_enbs.erase(enb_it++); } @@ -100,7 +100,7 @@ void s1ap::stop() std::map::iterator ue_it = m_imsi_to_nas_ctx.begin(); while (ue_it != m_imsi_to_nas_ctx.end()) { m_logger.info("Deleting UE EMM context. IMSI: %015" PRIu64 "", ue_it->first); - srslte::console("Deleting UE EMM context. IMSI: %015" PRIu64 "\n", ue_it->first); + srsran::console("Deleting UE EMM context. IMSI: %015" PRIu64 "\n", ue_it->first); delete ue_it->second; m_imsi_to_nas_ctx.erase(ue_it++); } @@ -137,7 +137,7 @@ int s1ap::enb_listen() m_logger.info("S1-MME Initializing"); sock_fd = socket(AF_INET, SOCK_SEQPACKET, IPPROTO_SCTP); if (sock_fd == -1) { - srslte::console("Could not create SCTP socket\n"); + srsran::console("Could not create SCTP socket\n"); return -1; } @@ -148,7 +148,7 @@ int s1ap::enb_listen() evnts.sctp_shutdown_event = 1; if (setsockopt(sock_fd, IPPROTO_SCTP, SCTP_EVENTS, &evnts, sizeof(evnts))) { close(sock_fd); - srslte::console("Subscribing to sctp_data_io_events failed\n"); + srsran::console("Subscribing to sctp_data_io_events failed\n"); return -1; } @@ -161,7 +161,7 @@ int s1ap::enb_listen() if (err != 0) { close(sock_fd); m_logger.error("Error binding SCTP socket"); - srslte::console("Error binding SCTP socket\n"); + srsran::console("Error binding SCTP socket\n"); return -1; } @@ -170,7 +170,7 @@ int s1ap::enb_listen() if (err != 0) { close(sock_fd); m_logger.error("Error in SCTP socket listen"); - srslte::console("Error in SCTP socket listen\n"); + srsran::console("Error in SCTP socket listen\n"); return -1; } @@ -181,7 +181,7 @@ bool s1ap::s1ap_tx_pdu(const asn1::s1ap::s1ap_pdu_c& pdu, struct sctp_sndrcvinfo { m_logger.debug("Transmitting S1AP PDU. eNB SCTP association Id: %d", enb_sri->sinfo_assoc_id); - srslte::unique_byte_buffer_t buf = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t buf = srsran::make_byte_buffer(); if (buf == nullptr) { m_logger.error("Fatal Error: Couldn't allocate buffer for S1AP PDU."); return false; @@ -195,7 +195,7 @@ bool s1ap::s1ap_tx_pdu(const asn1::s1ap::s1ap_pdu_c& pdu, struct sctp_sndrcvinfo ssize_t n_sent = sctp_send(m_s1mme, buf->msg, buf->N_bytes, enb_sri, MSG_NOSIGNAL); if (n_sent == -1) { - srslte::console("Failed to send S1AP PDU. Error: %s\n", strerror(errno)); + srsran::console("Failed to send S1AP PDU. Error: %s\n", strerror(errno)); m_logger.error("Failed to send S1AP PDU. Error: %s ", strerror(errno)); return false; } @@ -207,7 +207,7 @@ bool s1ap::s1ap_tx_pdu(const asn1::s1ap::s1ap_pdu_c& pdu, struct sctp_sndrcvinfo return true; } -void s1ap::handle_s1ap_rx_pdu(srslte::byte_buffer_t* pdu, struct sctp_sndrcvinfo* enb_sri) +void s1ap::handle_s1ap_rx_pdu(srsran::byte_buffer_t* pdu, struct sctp_sndrcvinfo* enb_sri) { // Save PCAP if (m_pcap_enable) { @@ -266,7 +266,7 @@ void s1ap::handle_initiating_message(const asn1::s1ap::init_msg_s& msg, struct s break; default: m_logger.error("Unhandled S1AP initiating message: %s", msg.value.type().to_string().c_str()); - srslte::console("Unhandled S1APinitiating message: %s\n", msg.value.type().to_string().c_str()); + srsran::console("Unhandled S1APinitiating message: %s\n", msg.value.type().to_string().c_str()); } } @@ -322,7 +322,7 @@ void s1ap::delete_enb_ctx(int32_t assoc_id) } m_logger.info("Deleting eNB context. eNB Id: 0x%x", enb_id); - srslte::console("Deleting eNB context. eNB Id: 0x%x\n", enb_id); + srsran::console("Deleting eNB context. eNB Id: 0x%x\n", enb_id); // Delete connected UEs ctx release_ues_ecm_ctx_in_enb(assoc_id); @@ -416,11 +416,11 @@ nas* s1ap::find_nas_ctx_from_imsi(uint64_t imsi) void s1ap::release_ues_ecm_ctx_in_enb(int32_t enb_assoc) { - srslte::console("Releasing UEs context\n"); + srsran::console("Releasing UEs context\n"); std::map >::iterator ues_in_enb = m_enb_assoc_to_ue_ids.find(enb_assoc); std::set::iterator ue_id = ues_in_enb->second.begin(); if (ue_id == ues_in_enb->second.end()) { - srslte::console("No UEs to be released\n"); + srsran::console("No UEs to be released\n"); } else { while (ue_id != ues_in_enb->second.end()) { std::map::iterator nas_ctx = m_mme_ue_s1ap_id_to_nas_ctx.find(*ue_id); @@ -433,7 +433,7 @@ void s1ap::release_ues_ecm_ctx_in_enb(int32_t enb_assoc) m_mme_gtpc->send_delete_session_request(emm_ctx->imsi); emm_ctx->state = EMM_STATE_DEREGISTERED; } - srslte::console("Releasing UE ECM context. UE-MME S1AP Id: %d\n", ecm_ctx->mme_ue_s1ap_id); + srsran::console("Releasing UE ECM context. UE-MME S1AP Id: %d\n", ecm_ctx->mme_ue_s1ap_id); ecm_ctx->state = ECM_STATE_IDLE; ecm_ctx->mme_ue_s1ap_id = 0; ecm_ctx->enb_ue_s1ap_id = 0; @@ -519,7 +519,7 @@ void s1ap::activate_eps_bearer(uint64_t imsi, uint8_t ebi) mme_ue_s1ap_id, ebi, esm_ctx->state); - srslte::console( + srsran::console( "Could not be activate EPS Bearer, bearer in wrong state: MME S1AP Id %d, EPS Bearer id %d, state %d\n", mme_ue_s1ap_id, ebi, @@ -560,23 +560,23 @@ void s1ap::print_enb_ctx_info(const std::string& prefix, const enb_ctx_t& enb_ct std::string mnc_str, mcc_str; if (enb_ctx.enb_name_present) { - srslte::console("%s - eNB Name: %s, eNB id: 0x%x\n", prefix.c_str(), enb_ctx.enb_name.c_str(), enb_ctx.enb_id); + srsran::console("%s - eNB Name: %s, eNB id: 0x%x\n", prefix.c_str(), enb_ctx.enb_name.c_str(), enb_ctx.enb_id); m_logger.info("%s - eNB Name: %s, eNB id: 0x%x", prefix.c_str(), enb_ctx.enb_name.c_str(), enb_ctx.enb_id); } else { - srslte::console("%s - eNB Id 0x%x\n", prefix.c_str(), enb_ctx.enb_id); + srsran::console("%s - eNB Id 0x%x\n", prefix.c_str(), enb_ctx.enb_id); m_logger.info("%s - eNB Id 0x%x", prefix.c_str(), enb_ctx.enb_id); } - srslte::mcc_to_string(enb_ctx.mcc, &mcc_str); - srslte::mnc_to_string(enb_ctx.mnc, &mnc_str); + srsran::mcc_to_string(enb_ctx.mcc, &mcc_str); + srsran::mnc_to_string(enb_ctx.mnc, &mnc_str); m_logger.info("%s - MCC:%s, MNC:%s, PLMN: %d", prefix.c_str(), mcc_str.c_str(), mnc_str.c_str(), enb_ctx.plmn); - srslte::console("%s - MCC:%s, MNC:%s\n", prefix.c_str(), mcc_str.c_str(), mnc_str.c_str()); + srsran::console("%s - MCC:%s, MNC:%s\n", prefix.c_str(), mcc_str.c_str(), mnc_str.c_str()); for (int i = 0; i < enb_ctx.nof_supported_ta; i++) { for (int j = 0; i < enb_ctx.nof_supported_ta; i++) { m_logger.info("%s - TAC %d, B-PLMN 0x%x", prefix.c_str(), enb_ctx.tacs[i], enb_ctx.bplmns[i][j]); - srslte::console("%s - TAC %d, B-PLMN 0x%x\n", prefix.c_str(), enb_ctx.tacs[i], enb_ctx.bplmns[i][j]); + srsran::console("%s - TAC %d, B-PLMN 0x%x\n", prefix.c_str(), enb_ctx.tacs[i], enb_ctx.bplmns[i][j]); } } - srslte::console("%s - Paging DRX %s\n", prefix.c_str(), enb_ctx.drx.to_string().c_str()); + srsran::console("%s - Paging DRX %s\n", prefix.c_str(), enb_ctx.drx.to_string().c_str()); return; } @@ -627,7 +627,7 @@ bool s1ap::send_erab_release_command(uint32_t enb_ue_s1ap_id, bool s1ap::send_erab_modify_request(uint32_t enb_ue_s1ap_id, uint32_t mme_ue_s1ap_id, std::map erabs_to_be_modified, - srslte::byte_buffer_t* nas_msg, + srsran::byte_buffer_t* nas_msg, struct sctp_sndrcvinfo enb_sri) { return m_s1ap_erab_mngmt_proc->send_erab_modify_request( @@ -636,7 +636,7 @@ bool s1ap::send_erab_modify_request(uint32_t enb_ue_s1ap_id, bool s1ap::send_downlink_nas_transport(uint32_t enb_ue_s1ap_id, uint32_t mme_ue_s1ap_id, - srslte::byte_buffer_t* nas_msg, + srsran::byte_buffer_t* nas_msg, struct sctp_sndrcvinfo enb_sri) { return m_s1ap_nas_transport->send_downlink_nas_transport(enb_ue_s1ap_id, mme_ue_s1ap_id, nas_msg, enb_sri); diff --git a/srsepc/src/mme/s1ap_ctx_mngmt_proc.cc b/srsepc/src/mme/s1ap_ctx_mngmt_proc.cc index 73a2beebc..f8099ac39 100644 --- a/srsepc/src/mme/s1ap_ctx_mngmt_proc.cc +++ b/srsepc/src/mme/s1ap_ctx_mngmt_proc.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -12,10 +12,10 @@ #include "srsepc/hdr/mme/s1ap_ctx_mngmt_proc.h" #include "srsepc/hdr/mme/s1ap.h" -#include "srslte/common/bcd_helpers.h" -#include "srslte/common/buffer_pool.h" -#include "srslte/common/int_helpers.h" -#include "srslte/common/liblte_security.h" +#include "srsran/common/bcd_helpers.h" +#include "srsran/common/buffer_pool.h" +#include "srsran/common/int_helpers.h" +#include "srsran/common/liblte_security.h" #include namespace srsepc { @@ -130,10 +130,10 @@ bool s1ap_ctx_mngmt_proc::send_initial_context_setup_request(nas* nas_ctx, uint1 } m_logger.info(sec_ctx->k_enb, 32, "Initial Context Setup Request -- Key eNB (k_enb)"); - srslte::unique_byte_buffer_t nas_buffer = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t nas_buffer = srsran::make_byte_buffer(); if (emm_ctx->state == EMM_STATE_DEREGISTERED) { // Attach procedure initiated from an attach request - srslte::console("Adding attach accept to Initial Context Setup Request\n"); + srsran::console("Adding attach accept to Initial Context Setup Request\n"); m_logger.info("Adding attach accept to Initial Context Setup Request"); nas_ctx->pack_attach_accept(nas_buffer.get()); @@ -153,7 +153,7 @@ bool s1ap_ctx_mngmt_proc::send_initial_context_setup_request(nas* nas_ctx, uint1 struct in_addr addr; addr.s_addr = htonl(erab_ctx_req.transport_layer_address.to_number()); - srslte::console("Sent Initial Context Setup Request. E-RAB id %d \n", erab_ctx_req.erab_id); + srsran::console("Sent Initial Context Setup Request. E-RAB id %d \n", erab_ctx_req.erab_id); m_logger.info( "Initial Context -- S1-U TEID 0x%" PRIx64 ". IP %s ", erab_ctx_req.gtp_teid.to_number(), inet_ntoa(addr)); m_logger.info("Initial Context Setup Request -- eNB UE S1AP Id %d, MME UE S1AP Id %" PRIu64 "", @@ -183,7 +183,7 @@ bool s1ap_ctx_mngmt_proc::handle_initial_context_setup_response( emm_ctx_t* emm_ctx = &nas_ctx->m_emm_ctx; ecm_ctx_t* ecm_ctx = &nas_ctx->m_ecm_ctx; - srslte::console("Received Initial Context Setup Response\n"); + srsran::console("Received Initial Context Setup Response\n"); // Setup E-RABs for (const asn1::s1ap::protocol_ie_single_container_s& ie_container : @@ -217,13 +217,13 @@ bool s1ap_ctx_mngmt_proc::handle_initial_context_setup_response( m_logger.info("E-RAB Context Setup. E-RAB id %d", esm_ctx->erab_id); m_logger.info("E-RAB Context -- eNB TEID 0x%x, eNB Address %s", esm_ctx->enb_fteid.teid, enb_addr_str); - srslte::console("E-RAB Context Setup. E-RAB id %d\n", esm_ctx->erab_id); - srslte::console("E-RAB Context -- eNB TEID 0x%x; eNB GTP-U Address %s\n", esm_ctx->enb_fteid.teid, enb_addr_str); + srsran::console("E-RAB Context Setup. E-RAB id %d\n", esm_ctx->erab_id); + srsran::console("E-RAB Context -- eNB TEID 0x%x; eNB GTP-U Address %s\n", esm_ctx->enb_fteid.teid, enb_addr_str); } if (emm_ctx->state == EMM_STATE_REGISTERED) { - srslte::console("Initial Context Setup Response triggered from Service Request.\n"); - srslte::console("Sending Modify Bearer Request.\n"); + srsran::console("Initial Context Setup Response triggered from Service Request.\n"); + srsran::console("Sending Modify Bearer Request.\n"); m_mme_gtpc->send_modify_bearer_request(emm_ctx->imsi, 5, &nas_ctx->m_esm_ctx[5].enb_fteid); } return true; @@ -234,12 +234,12 @@ bool s1ap_ctx_mngmt_proc::handle_ue_context_release_request(const asn1::s1ap::ue { uint32_t mme_ue_s1ap_id = ue_rel.protocol_ies.mme_ue_s1ap_id.value.value; m_logger.info("Received UE Context Release Request. MME-UE S1AP Id: %d", mme_ue_s1ap_id); - srslte::console("Received UE Context Release Request. MME-UE S1AP Id %d\n", mme_ue_s1ap_id); + srsran::console("Received UE Context Release Request. MME-UE S1AP Id %d\n", mme_ue_s1ap_id); nas* nas_ctx = m_s1ap->find_nas_ctx_from_mme_ue_s1ap_id(mme_ue_s1ap_id); if (nas_ctx == nullptr) { m_logger.info("No UE context to release found. MME-UE S1AP Id: %d", mme_ue_s1ap_id); - srslte::console("No UE context to release found. MME-UE S1AP Id: %d\n", mme_ue_s1ap_id); + srsran::console("No UE context to release found. MME-UE S1AP Id: %d\n", mme_ue_s1ap_id); return false; } @@ -286,7 +286,7 @@ bool s1ap_ctx_mngmt_proc::send_ue_context_release_command(nas* nas_ctx) // the SPGW. In such cases, there is no need to send the GTP-C Release Access Bearers Request. if (active_erabs) { // There are active E-RABs, send release access mearers request - srslte::console("There are active E-RABs, send release access bearers request\n"); + srsran::console("There are active E-RABs, send release access bearers request\n"); m_logger.info("There are active E-RABs, send release access bearers request"); // The handle_release_access_bearers_response function will make sure to mark E-RABS DEACTIVATED @@ -326,19 +326,19 @@ bool s1ap_ctx_mngmt_proc::handle_ue_context_release_complete(const asn1::s1ap::u { uint32_t mme_ue_s1ap_id = rel_comp.protocol_ies.mme_ue_s1ap_id.value.value; m_logger.info("Received UE Context Release Complete. MME-UE S1AP Id: %d", mme_ue_s1ap_id); - srslte::console("Received UE Context Release Complete. MME-UE S1AP Id %d\n", mme_ue_s1ap_id); + srsran::console("Received UE Context Release Complete. MME-UE S1AP Id %d\n", mme_ue_s1ap_id); nas* nas_ctx = m_s1ap->find_nas_ctx_from_mme_ue_s1ap_id(mme_ue_s1ap_id); if (nas_ctx == nullptr) { m_logger.info("No UE context to release found. MME-UE S1AP Id: %d", mme_ue_s1ap_id); - srslte::console("No UE context to release found. MME-UE S1AP Id: %d\n", mme_ue_s1ap_id); + srsran::console("No UE context to release found. MME-UE S1AP Id: %d\n", mme_ue_s1ap_id); return false; } // Delete UE context m_s1ap->release_ue_ecm_ctx(nas_ctx->m_ecm_ctx.mme_ue_s1ap_id); m_logger.info("UE Context Release Completed."); - srslte::console("UE Context Release Completed.\n"); + srsran::console("UE Context Release Completed.\n"); return true; } } // namespace srsepc diff --git a/srsepc/src/mme/s1ap_erab_mngmt_proc.cc b/srsepc/src/mme/s1ap_erab_mngmt_proc.cc index 723962558..25d962b20 100644 --- a/srsepc/src/mme/s1ap_erab_mngmt_proc.cc +++ b/srsepc/src/mme/s1ap_erab_mngmt_proc.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -12,10 +12,10 @@ #include "srsepc/hdr/mme/s1ap_erab_mngmt_proc.h" #include "srsepc/hdr/mme/s1ap.h" -#include "srslte/common/bcd_helpers.h" -#include "srslte/common/buffer_pool.h" -#include "srslte/common/int_helpers.h" -#include "srslte/common/liblte_security.h" +#include "srsran/common/bcd_helpers.h" +#include "srsran/common/buffer_pool.h" +#include "srsran/common/int_helpers.h" +#include "srsran/common/liblte_security.h" #include namespace srsepc { @@ -97,7 +97,7 @@ bool s1ap_erab_mngmt_proc::send_erab_release_command(uint32_t enb_ bool s1ap_erab_mngmt_proc::send_erab_modify_request(uint32_t enb_ue_s1ap_id, uint32_t mme_ue_s1ap_id, std::map erabs_to_modify, - srslte::byte_buffer_t* nas_msg, + srsran::byte_buffer_t* nas_msg, struct sctp_sndrcvinfo enb_sri) { m_logger.info("Preparing to send E-RAB Modify Command"); diff --git a/srsepc/src/mme/s1ap_mngmt_proc.cc b/srsepc/src/mme/s1ap_mngmt_proc.cc index 5a9d56ef5..b0097235c 100644 --- a/srsepc/src/mme/s1ap_mngmt_proc.cc +++ b/srsepc/src/mme/s1ap_mngmt_proc.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -12,7 +12,7 @@ #include "srsepc/hdr/mme/s1ap_mngmt_proc.h" #include "srsepc/hdr/mme/s1ap.h" -#include "srslte/common/bcd_helpers.h" +#include "srsran/common/bcd_helpers.h" namespace srsepc { @@ -59,7 +59,7 @@ void s1ap_mngmt_proc::init(void) bool s1ap_mngmt_proc::handle_s1_setup_request(const asn1::s1ap::s1_setup_request_s& msg, struct sctp_sndrcvinfo* enb_sri) { - srslte::console("Received S1 Setup Request.\n"); + srsran::console("Received S1 Setup Request.\n"); m_logger.info("Received S1 Setup Request."); enb_ctx_t enb_ctx = {}; @@ -87,11 +87,11 @@ bool s1ap_mngmt_proc::handle_s1_setup_request(const asn1::s1ap::s1_setup_request // Check matching PLMNs if (enb_ctx.plmn != m_s1ap->get_plmn()) { - srslte::console("Sending S1 Setup Failure - Unknown PLMN\n"); + srsran::console("Sending S1 Setup Failure - Unknown PLMN\n"); m_logger.warning("Sending S1 Setup Failure - Unknown PLMN"); send_s1_setup_failure(asn1::s1ap::cause_misc_opts::unknown_plmn, enb_sri); } else if (!tac_match) { - srslte::console("Sending S1 Setup Failure - No matching TAC\n"); + srsran::console("Sending S1 Setup Failure - No matching TAC\n"); m_logger.warning("Sending S1 Setup Failure - No matching TAC"); send_s1_setup_failure(asn1::s1ap::cause_misc_opts::unspecified, enb_sri); } else { @@ -106,7 +106,7 @@ bool s1ap_mngmt_proc::handle_s1_setup_request(const asn1::s1ap::s1_setup_request } send_s1_setup_response(m_s1ap_args, enb_sri); - srslte::console("Sending S1 Setup Response\n"); + srsran::console("Sending S1 Setup Response\n"); m_logger.info("Sending S1 Setup Response"); } return true; @@ -141,7 +141,7 @@ bool s1ap_mngmt_proc::unpack_s1_setup_request(const asn1::s1ap::s1_setup_request ((uint8_t*)&plmn)[3] = s1_req.global_enb_id.value.plm_nid[2]; enb_ctx->plmn = ntohl(plmn); - srslte::s1ap_plmn_to_mccmnc(enb_ctx->plmn, &enb_ctx->mcc, &enb_ctx->mnc); + srsran::s1ap_plmn_to_mccmnc(enb_ctx->plmn, &enb_ctx->mcc, &enb_ctx->mnc); // SupportedTAs enb_ctx->nof_supported_ta = s1_req.supported_tas.value.size(); @@ -199,7 +199,7 @@ bool s1ap_mngmt_proc::send_s1_setup_response(s1ap_args_t s1ap_args, struct sctp_ s1_resp.served_gummeis.value.resize(1); // TODO Only one served GUMMEI supported uint32_t plmn = 0; - srslte::s1ap_mccmnc_to_plmn(s1ap_args.mcc, s1ap_args.mnc, &plmn); + srsran::s1ap_mccmnc_to_plmn(s1ap_args.mcc, s1ap_args.mnc, &plmn); plmn = htonl(plmn); asn1::s1ap::served_gummeis_item_s& serv_gummei = s1_resp.served_gummeis.value[0]; diff --git a/srsepc/src/mme/s1ap_nas_transport.cc b/srsepc/src/mme/s1ap_nas_transport.cc index ae751b0b0..f20a8d3ea 100644 --- a/srsepc/src/mme/s1ap_nas_transport.cc +++ b/srsepc/src/mme/s1ap_nas_transport.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,9 +13,9 @@ #include "srsepc/hdr/mme/s1ap_nas_transport.h" #include "srsepc/hdr/mme/mme.h" #include "srsepc/hdr/mme/s1ap.h" -#include "srslte/common/int_helpers.h" -#include "srslte/common/liblte_security.h" -#include "srslte/common/security.h" +#include "srsran/common/int_helpers.h" +#include "srsran/common/liblte_security.h" +#include "srsran/common/security.h" #include #include // for printing uint64_t @@ -82,7 +82,7 @@ bool s1ap_nas_transport::handle_initial_ue_message(const asn1::s1ap::init_ue_msg { bool err, mac_valid; uint8_t pd, msg_type, sec_hdr_type; - srslte::unique_byte_buffer_t nas_msg = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t nas_msg = srsran::make_byte_buffer(); memcpy(nas_msg->msg, init_ue.protocol_ies.nas_pdu.value.data(), init_ue.protocol_ies.nas_pdu.value.size()); nas_msg->N_bytes = init_ue.protocol_ies.nas_pdu.value.size(); @@ -91,38 +91,38 @@ bool s1ap_nas_transport::handle_initial_ue_message(const asn1::s1ap::init_ue_msg uint32_t enb_ue_s1ap_id = init_ue.protocol_ies.enb_ue_s1ap_id.value.value; liblte_mme_parse_msg_header((LIBLTE_BYTE_MSG_STRUCT*)nas_msg.get(), &pd, &msg_type); - srslte::console("Initial UE message: %s\n", liblte_nas_msg_type_to_string(msg_type)); + srsran::console("Initial UE message: %s\n", liblte_nas_msg_type_to_string(msg_type)); m_logger.info("Initial UE message: %s", liblte_nas_msg_type_to_string(msg_type)); if (init_ue.protocol_ies.s_tmsi_present) { - srslte::uint8_to_uint32(init_ue.protocol_ies.s_tmsi.value.m_tmsi.data(), &m_tmsi); + srsran::uint8_to_uint32(init_ue.protocol_ies.s_tmsi.value.m_tmsi.data(), &m_tmsi); } switch (msg_type) { case LIBLTE_MME_MSG_TYPE_ATTACH_REQUEST: - srslte::console("Received Initial UE message -- Attach Request\n"); + srsran::console("Received Initial UE message -- Attach Request\n"); m_logger.info("Received Initial UE message -- Attach Request"); err = nas::handle_attach_request(enb_ue_s1ap_id, enb_sri, nas_msg.get(), m_nas_init, m_nas_if); break; case LIBLTE_MME_SECURITY_HDR_TYPE_SERVICE_REQUEST: - srslte::console("Received Initial UE message -- Service Request\n"); + srsran::console("Received Initial UE message -- Service Request\n"); m_logger.info("Received Initial UE message -- Service Request"); err = nas::handle_service_request(m_tmsi, enb_ue_s1ap_id, enb_sri, nas_msg.get(), m_nas_init, m_nas_if); break; case LIBLTE_MME_MSG_TYPE_DETACH_REQUEST: - srslte::console("Received Initial UE message -- Detach Request\n"); + srsran::console("Received Initial UE message -- Detach Request\n"); m_logger.info("Received Initial UE message -- Detach Request"); err = nas::handle_detach_request(m_tmsi, enb_ue_s1ap_id, enb_sri, nas_msg.get(), m_nas_init, m_nas_if); break; case LIBLTE_MME_MSG_TYPE_TRACKING_AREA_UPDATE_REQUEST: - srslte::console("Received Initial UE message -- Tracking Area Update Request\n"); + srsran::console("Received Initial UE message -- Tracking Area Update Request\n"); m_logger.info("Received Initial UE message -- Tracking Area Update Request"); err = nas::handle_tracking_area_update_request( m_tmsi, enb_ue_s1ap_id, enb_sri, nas_msg.get(), m_nas_init, m_nas_if); break; default: m_logger.info("Unhandled Initial UE Message 0x%x ", msg_type); - srslte::console("Unhandled Initial UE Message 0x%x \n", msg_type); + srsran::console("Unhandled Initial UE Message 0x%x \n", msg_type); err = false; } return err; @@ -150,7 +150,7 @@ bool s1ap_nas_transport::handle_uplink_nas_transport(const asn1::s1ap::ul_nas_tr sec_ctx_t* sec_ctx = &nas_ctx->m_sec_ctx; // Parse NAS message header - srslte::unique_byte_buffer_t nas_msg = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t nas_msg = srsran::make_byte_buffer(); memcpy(nas_msg->msg, ul_xport.protocol_ies.nas_pdu.value.data(), ul_xport.protocol_ies.nas_pdu.value.size()); nas_msg->N_bytes = ul_xport.protocol_ies.nas_pdu.value.size(); bool msg_encrypted = false; @@ -228,17 +228,17 @@ bool s1ap_nas_transport::handle_uplink_nas_transport(const asn1::s1ap::ul_nas_tr switch (msg_type) { case LIBLTE_MME_MSG_TYPE_ATTACH_REQUEST: m_logger.info("UL NAS: Attach Request"); - srslte::console("UL NAS: Attach Resquest\n"); + srsran::console("UL NAS: Attach Resquest\n"); nas_ctx->handle_attach_request(nas_msg.get()); break; case LIBLTE_MME_MSG_TYPE_IDENTITY_RESPONSE: m_logger.info("UL NAS: Received Identity Response"); - srslte::console("UL NAS: Received Identity Response\n"); + srsran::console("UL NAS: Received Identity Response\n"); nas_ctx->handle_identity_response(nas_msg.get()); break; case LIBLTE_MME_MSG_TYPE_AUTHENTICATION_RESPONSE: m_logger.info("UL NAS: Received Authentication Response"); - srslte::console("UL NAS: Received Authentication Response\n"); + srsran::console("UL NAS: Received Authentication Response\n"); nas_ctx->handle_authentication_response(nas_msg.get()); // In case of a successful authentication response, security mode command follows. // Reset counter for incoming security mode complete @@ -249,25 +249,25 @@ bool s1ap_nas_transport::handle_uplink_nas_transport(const asn1::s1ap::ul_nas_tr // Authentication failure with the option sync failure can be sent not integrity protected case LIBLTE_MME_MSG_TYPE_AUTHENTICATION_FAILURE: m_logger.info("UL NAS: Authentication Failure"); - srslte::console("UL NAS: Authentication Failure\n"); + srsran::console("UL NAS: Authentication Failure\n"); nas_ctx->handle_authentication_failure(nas_msg.get()); break; // Detach request can be sent not integrity protected when "power off" option is used case LIBLTE_MME_MSG_TYPE_DETACH_REQUEST: m_logger.info("UL NAS: Detach Request"); - srslte::console("UL NAS: Detach Request\n"); + srsran::console("UL NAS: Detach Request\n"); // TODO: check integrity protection in detach request nas_ctx->handle_detach_request(nas_msg.get()); break; case LIBLTE_MME_MSG_TYPE_SECURITY_MODE_COMPLETE: m_logger.info("UL NAS: Received Security Mode Complete"); - srslte::console("UL NAS: Received Security Mode Complete\n"); + srsran::console("UL NAS: Received Security Mode Complete\n"); if (sec_hdr_type == LIBLTE_MME_SECURITY_HDR_TYPE_INTEGRITY_AND_CIPHERED_WITH_NEW_EPS_SECURITY_CONTEXT && mac_valid == true) { nas_ctx->handle_security_mode_complete(nas_msg.get()); } else { // Security Mode Complete was not integrity protected - srslte::console("Security Mode Complete %s. Discard message.\n", + srsran::console("Security Mode Complete %s. Discard message.\n", (mac_valid ? "not integrity protected" : "invalid integrity")); m_logger.warning("Security Mode Complete %s. Discard message.", (mac_valid ? "not integrity protected" : "invalid integrity")); @@ -276,24 +276,24 @@ bool s1ap_nas_transport::handle_uplink_nas_transport(const asn1::s1ap::ul_nas_tr break; case LIBLTE_MME_MSG_TYPE_ATTACH_COMPLETE: m_logger.info("UL NAS: Received Attach Complete"); - srslte::console("UL NAS: Received Attach Complete\n"); + srsran::console("UL NAS: Received Attach Complete\n"); if (sec_hdr_type == LIBLTE_MME_SECURITY_HDR_TYPE_INTEGRITY_AND_CIPHERED && mac_valid == true) { nas_ctx->handle_attach_complete(nas_msg.get()); } else { // Attach Complete was not integrity protected - srslte::console("Attach Complete not integrity protected. Discard message.\n"); + srsran::console("Attach Complete not integrity protected. Discard message.\n"); m_logger.warning("Attach Complete not integrity protected. Discard message."); increase_ul_nas_cnt = false; } break; case LIBLTE_MME_MSG_TYPE_ESM_INFORMATION_RESPONSE: m_logger.info("UL NAS: Received ESM Information Response"); - srslte::console("UL NAS: Received ESM Information Response\n"); + srsran::console("UL NAS: Received ESM Information Response\n"); if (sec_hdr_type == LIBLTE_MME_SECURITY_HDR_TYPE_INTEGRITY_AND_CIPHERED && mac_valid == true) { nas_ctx->handle_esm_information_response(nas_msg.get()); } else { // Attach Complete was not integrity protected - srslte::console("ESM Information Response %s. Discard message.\n", + srsran::console("ESM Information Response %s. Discard message.\n", (mac_valid ? "not integrity protected" : "invalid integrity")); m_logger.warning("ESM Information Response %s. Discard message.", (mac_valid ? "not integrity protected" : "invalid integrity")); @@ -302,12 +302,12 @@ bool s1ap_nas_transport::handle_uplink_nas_transport(const asn1::s1ap::ul_nas_tr break; case LIBLTE_MME_MSG_TYPE_TRACKING_AREA_UPDATE_REQUEST: m_logger.info("UL NAS: Tracking Area Update Request"); - srslte::console("UL NAS: Tracking Area Update Request\n"); + srsran::console("UL NAS: Tracking Area Update Request\n"); nas_ctx->handle_tracking_area_update_request(nas_msg.get()); break; default: m_logger.warning("Unhandled NAS integrity protected message %s", liblte_nas_msg_type_to_string(msg_type)); - srslte::console("Unhandled NAS integrity protected message %s\n", liblte_nas_msg_type_to_string(msg_type)); + srsran::console("Unhandled NAS integrity protected message %s\n", liblte_nas_msg_type_to_string(msg_type)); return false; } @@ -321,7 +321,7 @@ bool s1ap_nas_transport::handle_uplink_nas_transport(const asn1::s1ap::ul_nas_tr bool s1ap_nas_transport::send_downlink_nas_transport(uint32_t enb_ue_s1ap_id, uint32_t mme_ue_s1ap_id, - srslte::byte_buffer_t* nas_msg, + srsran::byte_buffer_t* nas_msg, struct sctp_sndrcvinfo enb_sri) { m_logger.debug("Sending message to eNB with SCTP association %d. MME UE S1AP ID %d, eNB UE S1AP ID %d", diff --git a/srsepc/src/mme/s1ap_paging.cc b/srsepc/src/mme/s1ap_paging.cc index e7a29b8b2..713171b26 100644 --- a/srsepc/src/mme/s1ap_paging.cc +++ b/srsepc/src/mme/s1ap_paging.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -12,8 +12,8 @@ #include "srsepc/hdr/mme/s1ap_paging.h" #include "srsepc/hdr/mme/mme.h" #include "srsepc/hdr/mme/s1ap.h" -#include "srslte/common/bcd_helpers.h" -#include "srslte/common/int_helpers.h" +#include "srsran/common/bcd_helpers.h" +#include "srsran/common/int_helpers.h" #include // for printing uint64_t namespace srsepc { diff --git a/srsepc/src/spgw/CMakeLists.txt b/srsepc/src/spgw/CMakeLists.txt index 7c52a1ed2..f118d5656 100644 --- a/srsepc/src/spgw/CMakeLists.txt +++ b/srsepc/src/spgw/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of diff --git a/srsepc/src/spgw/gtpc.cc b/srsepc/src/spgw/gtpc.cc index 9fc18805a..113054308 100644 --- a/srsepc/src/spgw/gtpc.cc +++ b/srsepc/src/spgw/gtpc.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -55,15 +55,15 @@ int spgw::gtpc::init(spgw_args_t* args, // Init S11 interface err = init_s11(args); - if (err != SRSLTE_SUCCESS) { - srslte::console("Could not initialize the S11 interface.\n"); + if (err != SRSRAN_SUCCESS) { + srsran::console("Could not initialize the S11 interface.\n"); return err; } // Init IP pool err = init_ue_ip(args, ip_to_imsi); - if (err != SRSLTE_SUCCESS) { - srslte::console("Could not initialize the IP pool.\n"); + if (err != SRSRAN_SUCCESS) { + srsran::console("Could not initialize the IP pool.\n"); return err; } @@ -71,7 +71,7 @@ int spgw::gtpc::init(spgw_args_t* args, m_max_paging_queue = args->max_paging_queue; m_logger.info("SPGW S11 Initialized."); - srslte::console("SPGW S11 Initialized.\n"); + srsran::console("SPGW S11 Initialized.\n"); return 0; } @@ -80,7 +80,7 @@ void spgw::gtpc::stop() std::map::iterator it = m_teid_to_tunnel_ctx.begin(); while (it != m_teid_to_tunnel_ctx.end()) { m_logger.info("Deleting SP-GW GTP-C Tunnel. IMSI: %015" PRIu64 "", it->second->imsi); - srslte::console("Deleting SP-GW GTP-C Tunnel. IMSI: %015" PRIu64 "\n", it->second->imsi); + srsran::console("Deleting SP-GW GTP-C Tunnel. IMSI: %015" PRIu64 "\n", it->second->imsi); delete it->second; m_teid_to_tunnel_ctx.erase(it++); } @@ -100,7 +100,7 @@ int spgw::gtpc::init_s11(spgw_args_t* args) m_s11 = socket(AF_UNIX, SOCK_DGRAM, 0); if (m_s11 < 0) { m_logger.error("Error opening UNIX socket. Error %s", strerror(errno)); - return SRSLTE_ERROR_CANT_START; + return SRSRAN_ERROR_CANT_START; } // Set MME Address @@ -118,12 +118,12 @@ int spgw::gtpc::init_s11(spgw_args_t* args) // Bind socket to address if (bind(m_s11, (const struct sockaddr*)&m_spgw_addr, sizeof(m_spgw_addr)) == -1) { m_logger.error("Error binding UNIX socket. Error %s", strerror(errno)); - return SRSLTE_ERROR_CANT_START; + return SRSRAN_ERROR_CANT_START; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -bool spgw::gtpc::send_s11_pdu(const srslte::gtpc_pdu& pdu) +bool spgw::gtpc::send_s11_pdu(const srsran::gtpc_pdu& pdu) { m_logger.debug("SPGW Sending S11 PDU! N_Bytes: %zd", sizeof(pdu)); @@ -139,29 +139,29 @@ bool spgw::gtpc::send_s11_pdu(const srslte::gtpc_pdu& pdu) return true; } -void spgw::gtpc::handle_s11_pdu(srslte::byte_buffer_t* msg) +void spgw::gtpc::handle_s11_pdu(srsran::byte_buffer_t* msg) { // TODO add deserialization code here - srslte::gtpc_pdu* pdu = (srslte::gtpc_pdu*)msg->msg; - srslte::console("Received GTP-C PDU. Message type: %s\n", srslte::gtpc_msg_type_to_str(pdu->header.type)); - m_logger.debug("Received GTP-C PDU. Message type: %s", srslte::gtpc_msg_type_to_str(pdu->header.type)); + srsran::gtpc_pdu* pdu = (srsran::gtpc_pdu*)msg->msg; + srsran::console("Received GTP-C PDU. Message type: %s\n", srsran::gtpc_msg_type_to_str(pdu->header.type)); + m_logger.debug("Received GTP-C PDU. Message type: %s", srsran::gtpc_msg_type_to_str(pdu->header.type)); switch (pdu->header.type) { - case srslte::GTPC_MSG_TYPE_CREATE_SESSION_REQUEST: + case srsran::GTPC_MSG_TYPE_CREATE_SESSION_REQUEST: handle_create_session_request(pdu->choice.create_session_request); break; - case srslte::GTPC_MSG_TYPE_MODIFY_BEARER_REQUEST: + case srsran::GTPC_MSG_TYPE_MODIFY_BEARER_REQUEST: handle_modify_bearer_request(pdu->header, pdu->choice.modify_bearer_request); break; - case srslte::GTPC_MSG_TYPE_DELETE_SESSION_REQUEST: + case srsran::GTPC_MSG_TYPE_DELETE_SESSION_REQUEST: handle_delete_session_request(pdu->header, pdu->choice.delete_session_request); break; - case srslte::GTPC_MSG_TYPE_RELEASE_ACCESS_BEARERS_REQUEST: + case srsran::GTPC_MSG_TYPE_RELEASE_ACCESS_BEARERS_REQUEST: handle_release_access_bearers_request(pdu->header, pdu->choice.release_access_bearers_request); break; - case srslte::GTPC_MSG_TYPE_DOWNLINK_DATA_NOTIFICATION_ACKNOWLEDGE: + case srsran::GTPC_MSG_TYPE_DOWNLINK_DATA_NOTIFICATION_ACKNOWLEDGE: handle_downlink_data_notification_acknowledge(pdu->header, pdu->choice.downlink_data_notification_acknowledge); break; - case srslte::GTPC_MSG_TYPE_DOWNLINK_DATA_NOTIFICATION_FAILURE_INDICATION: + case srsran::GTPC_MSG_TYPE_DOWNLINK_DATA_NOTIFICATION_FAILURE_INDICATION: handle_downlink_data_notification_failure_indication(pdu->header, pdu->choice.downlink_data_notification_failure_indication); break; @@ -171,7 +171,7 @@ void spgw::gtpc::handle_s11_pdu(srslte::byte_buffer_t* msg) return; } -void spgw::gtpc::handle_create_session_request(const struct srslte::gtpc_create_session_request& cs_req) +void spgw::gtpc::handle_create_session_request(const struct srsran::gtpc_create_session_request& cs_req) { m_logger.info("SPGW Received Create Session Request"); spgw_tunnel_ctx_t* tunnel_ctx; @@ -179,43 +179,43 @@ void spgw::gtpc::handle_create_session_request(const struct srslte::gtpc_create_ // Check if IMSI has active GTP-C and/or GTP-U bool gtpc_present = m_imsi_to_ctr_teid.count(cs_req.imsi); if (gtpc_present) { - srslte::console("SPGW: GTP-C context for IMSI %015" PRIu64 " already exists.\n", cs_req.imsi); + srsran::console("SPGW: GTP-C context for IMSI %015" PRIu64 " already exists.\n", cs_req.imsi); delete_gtpc_ctx(m_imsi_to_ctr_teid[cs_req.imsi]); - srslte::console("SPGW: Deleted previous context.\n"); + srsran::console("SPGW: Deleted previous context.\n"); } m_logger.info("Creating new GTP-C context"); tunnel_ctx = create_gtpc_ctx(cs_req); // Create session response message - srslte::gtpc_pdu cs_resp_pdu; + srsran::gtpc_pdu cs_resp_pdu; std::memset(&cs_resp_pdu, 0, sizeof(cs_resp_pdu)); - srslte::gtpc_header* header = &cs_resp_pdu.header; - srslte::gtpc_create_session_response* cs_resp = &cs_resp_pdu.choice.create_session_response; + srsran::gtpc_header* header = &cs_resp_pdu.header; + srsran::gtpc_create_session_response* cs_resp = &cs_resp_pdu.choice.create_session_response; // Setup GTP-C header header->piggyback = false; header->teid_present = true; header->teid = tunnel_ctx->dw_ctrl_fteid.teid; // Send create session response to the UE's MME Ctrl TEID - header->type = srslte::GTPC_MSG_TYPE_CREATE_SESSION_RESPONSE; + header->type = srsran::GTPC_MSG_TYPE_CREATE_SESSION_RESPONSE; // Initialize to zero - std::memset(cs_resp, 0, sizeof(struct srslte::gtpc_create_session_response)); + std::memset(cs_resp, 0, sizeof(struct srsran::gtpc_create_session_response)); // Setup Cause - cs_resp->cause.cause_value = srslte::GTPC_CAUSE_VALUE_REQUEST_ACCEPTED; + cs_resp->cause.cause_value = srsran::GTPC_CAUSE_VALUE_REQUEST_ACCEPTED; // Setup sender F-TEID (ctrl) cs_resp->sender_f_teid.ipv4_present = true; cs_resp->sender_f_teid = tunnel_ctx->up_ctrl_fteid; // Bearer context created cs_resp->eps_bearer_context_created.ebi = default_bearer_id; - cs_resp->eps_bearer_context_created.cause.cause_value = srslte::GTPC_CAUSE_VALUE_REQUEST_ACCEPTED; + cs_resp->eps_bearer_context_created.cause.cause_value = srsran::GTPC_CAUSE_VALUE_REQUEST_ACCEPTED; cs_resp->eps_bearer_context_created.s1_u_sgw_f_teid_present = true; cs_resp->eps_bearer_context_created.s1_u_sgw_f_teid = tunnel_ctx->up_user_fteid; // Fill in the PAA cs_resp->paa_present = true; - cs_resp->paa.pdn_type = srslte::GTPC_PDN_TYPE_IPV4; + cs_resp->paa.pdn_type = srsran::GTPC_PDN_TYPE_IPV4; cs_resp->paa.ipv4_present = true; cs_resp->paa.ipv4 = tunnel_ctx->ue_ipv4; m_logger.info("Sending Create Session Response"); @@ -225,8 +225,8 @@ void spgw::gtpc::handle_create_session_request(const struct srslte::gtpc_create_ return; } -void spgw::gtpc::handle_modify_bearer_request(const struct srslte::gtpc_header& mb_req_hdr, - const struct srslte::gtpc_modify_bearer_request& mb_req) +void spgw::gtpc::handle_modify_bearer_request(const struct srsran::gtpc_header& mb_req_hdr, + const struct srsran::gtpc_modify_bearer_request& mb_req) { m_logger.info("Received Modified Bearer Request"); @@ -266,33 +266,33 @@ void spgw::gtpc::handle_modify_bearer_request(const struct srslte::gtpc_header& if (tunnel_ctx->paging_pending == true) { tunnel_ctx->paging_pending = false; m_logger.debug("Modify Bearer Request received after Downling Data Notification was sent"); - srslte::console("Modify Bearer Request received after Downling Data Notification was sent\n"); + srsran::console("Modify Bearer Request received after Downling Data Notification was sent\n"); m_gtpu->send_all_queued_packets(tunnel_ctx->dw_user_fteid, tunnel_ctx->paging_queue); } // Setting up Modify bearer response PDU // Header - srslte::gtpc_pdu mb_resp_pdu; + srsran::gtpc_pdu mb_resp_pdu; std::memset(&mb_resp_pdu, 0, sizeof(mb_resp_pdu)); - srslte::gtpc_header* header = &mb_resp_pdu.header; + srsran::gtpc_header* header = &mb_resp_pdu.header; header->piggyback = false; header->teid_present = true; header->teid = tunnel_ctx->dw_ctrl_fteid.teid; - header->type = srslte::GTPC_MSG_TYPE_MODIFY_BEARER_RESPONSE; + header->type = srsran::GTPC_MSG_TYPE_MODIFY_BEARER_RESPONSE; // PDU - srslte::gtpc_modify_bearer_response* mb_resp = &mb_resp_pdu.choice.modify_bearer_response; - mb_resp->cause.cause_value = srslte::GTPC_CAUSE_VALUE_REQUEST_ACCEPTED; + srsran::gtpc_modify_bearer_response* mb_resp = &mb_resp_pdu.choice.modify_bearer_response; + mb_resp->cause.cause_value = srsran::GTPC_CAUSE_VALUE_REQUEST_ACCEPTED; mb_resp->eps_bearer_context_modified.ebi = tunnel_ctx->ebi; - mb_resp->eps_bearer_context_modified.cause.cause_value = srslte::GTPC_CAUSE_VALUE_REQUEST_ACCEPTED; + mb_resp->eps_bearer_context_modified.cause.cause_value = srsran::GTPC_CAUSE_VALUE_REQUEST_ACCEPTED; // Send Modify Bearer Response PDU send_s11_pdu(mb_resp_pdu); return; } -void spgw::gtpc::handle_delete_session_request(const srslte::gtpc_header& header, - const srslte::gtpc_delete_session_request& del_req_pdu) +void spgw::gtpc::handle_delete_session_request(const srsran::gtpc_header& header, + const srsran::gtpc_delete_session_request& del_req_pdu) { uint32_t ctrl_teid = header.teid; std::map::iterator tunnel_it = m_teid_to_tunnel_ctx.find(ctrl_teid); @@ -307,8 +307,8 @@ void spgw::gtpc::handle_delete_session_request(const srslte::gtpc_header& return; } -void spgw::gtpc::handle_release_access_bearers_request(const srslte::gtpc_header& header, - const srslte::gtpc_release_access_bearers_request& rel_req) +void spgw::gtpc::handle_release_access_bearers_request(const srsran::gtpc_header& header, + const srsran::gtpc_release_access_bearers_request& rel_req) { // Find tunel ctxt uint32_t ctrl_teid = header.teid; @@ -329,10 +329,10 @@ bool spgw::gtpc::send_downlink_data_notification(uint32_t spgw_ctr_teid) { m_logger.debug("Sending Downlink Notification Request"); - struct srslte::gtpc_pdu dl_not_pdu; + struct srsran::gtpc_pdu dl_not_pdu; std::memset(&dl_not_pdu, 0, sizeof(dl_not_pdu)); - struct srslte::gtpc_header* header = &dl_not_pdu.header; - struct srslte::gtpc_downlink_data_notification* dl_not = &dl_not_pdu.choice.downlink_data_notification; + struct srsran::gtpc_header* header = &dl_not_pdu.header; + struct srsran::gtpc_downlink_data_notification* dl_not = &dl_not_pdu.choice.downlink_data_notification; // Find MME Ctrl TEID std::map::iterator tunnel_it = m_teid_to_tunnel_ctx.find(spgw_ctr_teid); @@ -349,14 +349,14 @@ bool spgw::gtpc::send_downlink_data_notification(uint32_t spgw_ctr_teid) } tunnel_ctx->paging_pending = true; - srslte::console("Found UE for Downlink Notification \n"); - srslte::console("MME Ctr TEID 0x%x, IMSI: %015" PRIu64 "\n", tunnel_ctx->dw_ctrl_fteid.teid, tunnel_ctx->imsi); + srsran::console("Found UE for Downlink Notification \n"); + srsran::console("MME Ctr TEID 0x%x, IMSI: %015" PRIu64 "\n", tunnel_ctx->dw_ctrl_fteid.teid, tunnel_ctx->imsi); // Setup GTP-C header header->piggyback = false; header->teid_present = true; header->teid = tunnel_ctx->dw_ctrl_fteid.teid; // Send downlink data notification to the UE's MME Ctrl TEID - header->type = srslte::GTPC_MSG_TYPE_DOWNLINK_DATA_NOTIFICATION; + header->type = srsran::GTPC_MSG_TYPE_DOWNLINK_DATA_NOTIFICATION; dl_not->eps_bearer_id_present = true; dl_not->eps_bearer_id = 5; // Only default bearer supported. @@ -367,8 +367,8 @@ bool spgw::gtpc::send_downlink_data_notification(uint32_t spgw_ctr_teid) } void spgw::gtpc::handle_downlink_data_notification_acknowledge( - const srslte::gtpc_header& header, - const srslte::gtpc_downlink_data_notification_acknowledge& not_ack) + const srsran::gtpc_header& header, + const srsran::gtpc_downlink_data_notification_acknowledge& not_ack) { m_logger.debug("Handling downlink data notification acknowledge"); @@ -380,14 +380,14 @@ void spgw::gtpc::handle_downlink_data_notification_acknowledge( return; } spgw_tunnel_ctx_t* tunnel_ctx = tunnel_it->second; - if (not_ack.cause.cause_value == srslte::GTPC_CAUSE_VALUE_CONTEXT_NOT_FOUND || - not_ack.cause.cause_value == srslte::GTPC_CAUSE_VALUE_UE_ALREADY_RE_ATTACHED || - not_ack.cause.cause_value == srslte::GTPC_CAUSE_VALUE_UNABLE_TO_PAGE_UE || - not_ack.cause.cause_value == srslte::GTPC_CAUSE_VALUE_UNABLE_TO_PAGE_UE_DUE_TO_SUSPENSION) { + if (not_ack.cause.cause_value == srsran::GTPC_CAUSE_VALUE_CONTEXT_NOT_FOUND || + not_ack.cause.cause_value == srsran::GTPC_CAUSE_VALUE_UE_ALREADY_RE_ATTACHED || + not_ack.cause.cause_value == srsran::GTPC_CAUSE_VALUE_UNABLE_TO_PAGE_UE || + not_ack.cause.cause_value == srsran::GTPC_CAUSE_VALUE_UNABLE_TO_PAGE_UE_DUE_TO_SUSPENSION) { m_logger.warning("Downlink Data Notification Acknowledge indicates failure."); free_all_queued_packets(tunnel_ctx); tunnel_ctx->paging_pending = false; - } else if (not_ack.cause.cause_value != srslte::GTPC_CAUSE_VALUE_REQUEST_ACCEPTED) { + } else if (not_ack.cause.cause_value != srsran::GTPC_CAUSE_VALUE_REQUEST_ACCEPTED) { m_logger.warning("Invalid cause in Downlink Data Notification Acknowledge."); free_all_queued_packets(tunnel_ctx); tunnel_ctx->paging_pending = false; @@ -396,8 +396,8 @@ void spgw::gtpc::handle_downlink_data_notification_acknowledge( } void spgw::gtpc::handle_downlink_data_notification_failure_indication( - const srslte::gtpc_header& header, - const srslte::gtpc_downlink_data_notification_failure_indication& not_fail) + const srsran::gtpc_header& header, + const srsran::gtpc_downlink_data_notification_failure_indication& not_fail) { m_logger.debug("Handling downlink data notification failure indication"); // Find tunel ctxt @@ -409,9 +409,9 @@ void spgw::gtpc::handle_downlink_data_notification_failure_indication( } spgw_tunnel_ctx_t* tunnel_ctx = tunnel_it->second; - if (not_fail.cause.cause_value == srslte::GTPC_CAUSE_VALUE_UE_NOT_RESPONDING || - not_fail.cause.cause_value == srslte::GTPC_CAUSE_VALUE_SERVICE_DENIED || - not_fail.cause.cause_value == srslte::GTPC_CAUSE_VALUE_UE_ALREADY_RE_ATTACHED) { + if (not_fail.cause.cause_value == srsran::GTPC_CAUSE_VALUE_UE_NOT_RESPONDING || + not_fail.cause.cause_value == srsran::GTPC_CAUSE_VALUE_SERVICE_DENIED || + not_fail.cause.cause_value == srsran::GTPC_CAUSE_VALUE_UE_ALREADY_RE_ATTACHED) { m_logger.debug("Downlink Data Notification failure indication cause: %d.", not_fail.cause.cause_value); } else { m_logger.warning("Invalid cause in Downlink Data Notification Failure Indication %d", not_fail.cause.cause_value); @@ -424,7 +424,7 @@ void spgw::gtpc::handle_downlink_data_notification_failure_indication( /* * Context management functions */ -spgw_tunnel_ctx_t* spgw::gtpc::create_gtpc_ctx(const struct srslte::gtpc_create_session_request& cs_req) +spgw_tunnel_ctx_t* spgw::gtpc::create_gtpc_ctx(const struct srsran::gtpc_create_session_request& cs_req) { // Setup uplink control TEID uint64_t spgw_uplink_ctrl_teid = get_new_ctrl_teid(); @@ -435,11 +435,11 @@ spgw_tunnel_ctx_t* spgw::gtpc::create_gtpc_ctx(const struct srslte::gtpc_create_ uint8_t default_bearer_id = 5; - srslte::console("SPGW: Allocated Ctrl TEID %" PRIu64 "\n", spgw_uplink_ctrl_teid); - srslte::console("SPGW: Allocated User TEID %" PRIu64 "\n", spgw_uplink_user_teid); + srsran::console("SPGW: Allocated Ctrl TEID %" PRIu64 "\n", spgw_uplink_ctrl_teid); + srsran::console("SPGW: Allocated User TEID %" PRIu64 "\n", spgw_uplink_user_teid); struct in_addr ue_ip_; ue_ip_.s_addr = ue_ip; - srslte::console("SPGW: Allocate UE IP %s\n", inet_ntoa(ue_ip_)); + srsran::console("SPGW: Allocate UE IP %s\n", inet_ntoa(ue_ip_)); // Save the UE IP to User TEID map spgw_tunnel_ctx_t* tunnel_ctx = new spgw_tunnel_ctx_t{}; @@ -453,7 +453,7 @@ spgw_tunnel_ctx_t* spgw::gtpc::create_gtpc_ctx(const struct srslte::gtpc_create_ tunnel_ctx->up_user_fteid.ipv4 = m_gtpu->get_s1u_addr(); tunnel_ctx->dw_ctrl_fteid.teid = cs_req.sender_f_teid.teid; tunnel_ctx->dw_ctrl_fteid.ipv4 = cs_req.sender_f_teid.ipv4; - std::memset(&tunnel_ctx->dw_user_fteid, 0, sizeof(srslte::gtp_fteid_t)); + std::memset(&tunnel_ctx->dw_user_fteid, 0, sizeof(srsran::gtp_fteid_t)); m_teid_to_tunnel_ctx.insert(std::pair(spgw_uplink_ctrl_teid, tunnel_ctx)); m_imsi_to_ctr_teid.insert(std::pair(cs_req.imsi, spgw_uplink_ctrl_teid)); @@ -484,7 +484,7 @@ bool spgw::gtpc::delete_gtpc_ctx(uint32_t ctrl_teid) /* * Queueing functions */ -bool spgw::gtpc::queue_downlink_packet(uint32_t ctrl_teid, srslte::unique_byte_buffer_t msg) +bool spgw::gtpc::queue_downlink_packet(uint32_t ctrl_teid, srsran::unique_byte_buffer_t msg) { spgw_tunnel_ctx_t* tunnel_ctx; if (!m_teid_to_tunnel_ctx.count(ctrl_teid)) { @@ -519,7 +519,7 @@ bool spgw::gtpc::free_all_queued_packets(spgw_tunnel_ctx_t* tunnel_ctx) } while (!tunnel_ctx->paging_queue.empty()) { - srslte::unique_byte_buffer_t pkt = std::move(tunnel_ctx->paging_queue.front()); + srsran::unique_byte_buffer_t pkt = std::move(tunnel_ctx->paging_queue.front()); m_logger.debug("Dropping packet. Bytes %d", pkt->N_bytes); tunnel_ctx->paging_queue.pop(); } @@ -535,7 +535,7 @@ int spgw::gtpc::init_ue_ip(spgw_args_t* args, const std::mapfirst.c_str(), iter->second); - return SRSLTE_ERROR_OUT_OF_BOUNDS; + return SRSRAN_ERROR_OUT_OF_BOUNDS; } // load our imsi to ip lookup table @@ -545,7 +545,7 @@ int spgw::gtpc::init_ue_ip(spgw_args_t* args, const std::mapsecond, in_addr)).second) { m_logger.error( "SPGW: duplicate imsi %015" PRIu64 " for static ip address %s.", iter->second, iter->first.c_str()); - return SRSLTE_ERROR_OUT_OF_BOUNDS; + return SRSRAN_ERROR_OUT_OF_BOUNDS; } } @@ -565,7 +565,7 @@ int spgw::gtpc::init_ue_ip(spgw_args_t* args, const std::map #include #include @@ -54,21 +54,21 @@ int spgw::gtpu::init(spgw_args_t* args, spgw* spgw, gtpc_interface_gtpu* gtpc) // Init SGi interface err = init_sgi(args); - if (err != SRSLTE_SUCCESS) { - srslte::console("Could not initialize the SGi interface.\n"); + if (err != SRSRAN_SUCCESS) { + srsran::console("Could not initialize the SGi interface.\n"); return err; } // Init S1-U err = init_s1u(args); - if (err != SRSLTE_SUCCESS) { - srslte::console("Could not initialize the S1-U interface.\n"); + if (err != SRSRAN_SUCCESS) { + srsran::console("Could not initialize the S1-U interface.\n"); return err; } m_logger.info("SPGW GTP-U Initialized."); - srslte::console("SPGW GTP-U Initialized.\n"); - return SRSLTE_SUCCESS; + srsran::console("SPGW GTP-U Initialized.\n"); + return SRSRAN_SUCCESS; } void spgw::gtpu::stop() @@ -89,7 +89,7 @@ int spgw::gtpu::init_sgi(spgw_args_t* args) int sgi_sock; if (m_sgi_up) { - return SRSLTE_ERROR_ALREADY_STARTED; + return SRSRAN_ERROR_ALREADY_STARTED; } // Construct the TUN device @@ -97,7 +97,7 @@ int spgw::gtpu::init_sgi(spgw_args_t* args) m_logger.info("TUN file descriptor = %d", m_sgi); if (m_sgi < 0) { m_logger.error("Failed to open TUN device: %s", strerror(errno)); - return SRSLTE_ERROR_CANT_START; + return SRSRAN_ERROR_CANT_START; } memset(&ifr, 0, sizeof(ifr)); @@ -109,7 +109,7 @@ int spgw::gtpu::init_sgi(spgw_args_t* args) if (ioctl(m_sgi, TUNSETIFF, &ifr) < 0) { m_logger.error("Failed to set TUN device name: %s", strerror(errno)); close(m_sgi); - return SRSLTE_ERROR_CANT_START; + return SRSRAN_ERROR_CANT_START; } // Bring up the interface @@ -118,7 +118,7 @@ int spgw::gtpu::init_sgi(spgw_args_t* args) m_logger.error("Failed to bring up socket: %s", strerror(errno)); close(sgi_sock); close(m_sgi); - return SRSLTE_ERROR_CANT_START; + return SRSRAN_ERROR_CANT_START; } ifr.ifr_flags |= IFF_UP | IFF_RUNNING; @@ -126,7 +126,7 @@ int spgw::gtpu::init_sgi(spgw_args_t* args) m_logger.error("Failed to set socket flags: %s", strerror(errno)); close(sgi_sock); close(m_sgi); - return SRSLTE_ERROR_CANT_START; + return SRSRAN_ERROR_CANT_START; } // Set IP of the interface @@ -140,7 +140,7 @@ int spgw::gtpu::init_sgi(spgw_args_t* args) "Failed to set TUN interface IP. Address: %s, Error: %s", args->sgi_if_addr.c_str(), strerror(errno)); close(m_sgi); close(sgi_sock); - return SRSLTE_ERROR_CANT_START; + return SRSRAN_ERROR_CANT_START; } ifr.ifr_netmask.sa_family = AF_INET; @@ -149,13 +149,13 @@ int spgw::gtpu::init_sgi(spgw_args_t* args) m_logger.error("Failed to set TUN interface Netmask. Error: %s", strerror(errno)); close(m_sgi); close(sgi_sock); - return SRSLTE_ERROR_CANT_START; + return SRSRAN_ERROR_CANT_START; } close(sgi_sock); m_sgi_up = true; m_logger.info("Initialized SGi interface"); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int spgw::gtpu::init_s1u(spgw_args_t* args) @@ -164,7 +164,7 @@ int spgw::gtpu::init_s1u(spgw_args_t* args) m_s1u = socket(AF_INET, SOCK_DGRAM, 0); if (m_s1u == -1) { m_logger.error("Failed to open socket: %s", strerror(errno)); - return SRSLTE_ERROR_CANT_START; + return SRSRAN_ERROR_CANT_START; } m_s1u_up = true; @@ -175,23 +175,23 @@ int spgw::gtpu::init_s1u(spgw_args_t* args) if (bind(m_s1u, (struct sockaddr*)&m_s1u_addr, sizeof(struct sockaddr_in))) { m_logger.error("Failed to bind socket: %s", strerror(errno)); - return SRSLTE_ERROR_CANT_START; + return SRSRAN_ERROR_CANT_START; } m_logger.info("S1-U socket = %d", m_s1u); m_logger.info("S1-U IP = %s, Port = %d ", inet_ntoa(m_s1u_addr.sin_addr), ntohs(m_s1u_addr.sin_port)); m_logger.info("Initialized S1-U interface"); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -void spgw::gtpu::handle_sgi_pdu(srslte::unique_byte_buffer_t msg) +void spgw::gtpu::handle_sgi_pdu(srsran::unique_byte_buffer_t msg) { bool usr_found = false; bool ctr_found = false; - std::map::iterator gtpu_fteid_it; + std::map::iterator gtpu_fteid_it; std::map::iterator gtpc_teid_it; - srslte::gtpc_f_teid_ie enb_fteid; + srsran::gtpc_f_teid_ie enb_fteid; uint32_t spgw_teid; struct iphdr* iph = (struct iphdr*)msg->msg; m_logger.debug("Received SGi PDU. Bytes %d", msg->N_bytes); @@ -208,11 +208,11 @@ void spgw::gtpu::handle_sgi_pdu(srslte::unique_byte_buffer_t msg) // Logging PDU info m_logger.debug("SGi PDU -- IP version %d, Total length %d", int(iph->version), ntohs(iph->tot_len)); fmt::memory_buffer buffer; - srslte::gtpu_ntoa(buffer, iph->saddr); - m_logger.debug("SGi PDU -- IP src addr %s", srslte::to_c_str(buffer)); + srsran::gtpu_ntoa(buffer, iph->saddr); + m_logger.debug("SGi PDU -- IP src addr %s", srsran::to_c_str(buffer)); buffer.clear(); - srslte::gtpu_ntoa(buffer, iph->daddr); - m_logger.debug("SGi PDU -- IP dst addr %s", srslte::to_c_str(buffer)); + srsran::gtpu_ntoa(buffer, iph->daddr); + m_logger.debug("SGi PDU -- IP dst addr %s", srsran::to_c_str(buffer)); // Find user and control tunnel gtpu_fteid_it = m_ip_to_usr_teid.find(iph->daddr); @@ -242,10 +242,10 @@ void spgw::gtpu::handle_sgi_pdu(srslte::unique_byte_buffer_t msg) } } -void spgw::gtpu::handle_s1u_pdu(srslte::byte_buffer_t* msg) +void spgw::gtpu::handle_s1u_pdu(srsran::byte_buffer_t* msg) { - srslte::gtpu_header_t header; - srslte::gtpu_read_header(msg, &header, m_logger); + srsran::gtpu_header_t header; + srsran::gtpu_read_header(msg, &header, m_logger); m_logger.debug("Received PDU from S1-U. Bytes=%d", msg->N_bytes); m_logger.debug("TEID 0x%x. Bytes=%d", header.teid, msg->N_bytes); @@ -258,7 +258,7 @@ void spgw::gtpu::handle_s1u_pdu(srslte::byte_buffer_t* msg) return; } -void spgw::gtpu::send_s1u_pdu(srslte::gtp_fteid_t enb_fteid, srslte::byte_buffer_t* msg) +void spgw::gtpu::send_s1u_pdu(srsran::gtp_fteid_t enb_fteid, srsran::byte_buffer_t* msg) { // Set eNB destination address struct sockaddr_in enb_addr; @@ -267,7 +267,7 @@ void spgw::gtpu::send_s1u_pdu(srslte::gtp_fteid_t enb_fteid, srslte::byte_buffer enb_addr.sin_addr.s_addr = enb_fteid.ipv4; // Setup GTP-U header - srslte::gtpu_header_t header; + srsran::gtpu_header_t header; header.flags = GTPU_FLAGS_VERSION_V1 | GTPU_FLAGS_GTP_PROTOCOL; header.message_type = GTPU_MSG_DATA_PDU; header.length = msg->N_bytes; @@ -278,7 +278,7 @@ void spgw::gtpu::send_s1u_pdu(srslte::gtp_fteid_t enb_fteid, srslte::byte_buffer // Write header into packet int n; - if (!srslte::gtpu_write_header(&header, msg, m_logger)) { + if (!srsran::gtpu_write_header(&header, msg, m_logger)) { m_logger.error("Error writing GTP-U header on PDU"); goto out; } @@ -296,12 +296,12 @@ out: return; } -void spgw::gtpu::send_all_queued_packets(srslte::gtp_fteid_t dw_user_fteid, - std::queue& pkt_queue) +void spgw::gtpu::send_all_queued_packets(srsran::gtp_fteid_t dw_user_fteid, + std::queue& pkt_queue) { m_logger.debug("Sending all queued packets"); while (!pkt_queue.empty()) { - srslte::unique_byte_buffer_t msg = std::move(pkt_queue.front()); + srsran::unique_byte_buffer_t msg = std::move(pkt_queue.front()); send_s1u_pdu(dw_user_fteid, msg.get()); pkt_queue.pop(); } @@ -311,15 +311,15 @@ void spgw::gtpu::send_all_queued_packets(srslte::gtp_fteid_t /* * Tunnel managment */ -bool spgw::gtpu::modify_gtpu_tunnel(in_addr_t ue_ipv4, srslte::gtpc_f_teid_ie dw_user_fteid, uint32_t up_ctrl_teid) +bool spgw::gtpu::modify_gtpu_tunnel(in_addr_t ue_ipv4, srsran::gtpc_f_teid_ie dw_user_fteid, uint32_t up_ctrl_teid) { m_logger.info("Modifying GTP-U Tunnel."); fmt::memory_buffer buffer; - srslte::gtpu_ntoa(buffer, ue_ipv4); - m_logger.info("UE IP %s", srslte::to_c_str(buffer)); + srsran::gtpu_ntoa(buffer, ue_ipv4); + m_logger.info("UE IP %s", srsran::to_c_str(buffer)); buffer.clear(); - srslte::gtpu_ntoa(buffer, dw_user_fteid.ipv4); - m_logger.info("Downlink eNB addr %s, U-TEID 0x%x", srslte::to_c_str(buffer), dw_user_fteid.teid); + srsran::gtpu_ntoa(buffer, dw_user_fteid.ipv4); + m_logger.info("Downlink eNB addr %s, U-TEID 0x%x", srsran::to_c_str(buffer), dw_user_fteid.teid); m_logger.info("Uplink C-TEID: 0x%x", up_ctrl_teid); m_ip_to_usr_teid[ue_ipv4] = dw_user_fteid; m_ip_to_ctr_teid[ue_ipv4] = up_ctrl_teid; diff --git a/srsepc/src/spgw/spgw.cc b/srsepc/src/spgw/spgw.cc index 829defaa1..35f7fb465 100644 --- a/srsepc/src/spgw/spgw.cc +++ b/srsepc/src/spgw/spgw.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -14,7 +14,7 @@ #include "srsepc/hdr/mme/mme_gtpc.h" #include "srsepc/hdr/spgw/gtpc.h" #include "srsepc/hdr/spgw/gtpu.h" -#include "srslte/upper/gtpu.h" +#include "srsran/upper/gtpu.h" #include // for printing uint64_t namespace srsepc { @@ -61,20 +61,20 @@ int spgw::init(spgw_args_t* args, const std::map& ip_to_i int err; // Init GTP-U - if (m_gtpu->init(args, this, m_gtpc) != SRSLTE_SUCCESS) { - srslte::console("Could not initialize the SPGW's GTP-U.\n"); - return SRSLTE_ERROR_CANT_START; + if (m_gtpu->init(args, this, m_gtpc) != SRSRAN_SUCCESS) { + srsran::console("Could not initialize the SPGW's GTP-U.\n"); + return SRSRAN_ERROR_CANT_START; } // Init GTP-C - if (m_gtpc->init(args, this, m_gtpu, ip_to_imsi) != SRSLTE_SUCCESS) { - srslte::console("Could not initialize the S1-U interface.\n"); - return SRSLTE_ERROR_CANT_START; + if (m_gtpc->init(args, this, m_gtpu, ip_to_imsi) != SRSRAN_SUCCESS) { + srsran::console("Could not initialize the S1-U interface.\n"); + return SRSRAN_ERROR_CANT_START; } m_logger.info("SP-GW Initialized."); - srslte::console("SP-GW Initialized.\n"); - return SRSLTE_SUCCESS; + srsran::console("SP-GW Initialized.\n"); + return SRSRAN_SUCCESS; } void spgw::stop() @@ -94,9 +94,9 @@ void spgw::run_thread() { // Mark the thread as running m_running = true; - srslte::unique_byte_buffer_t sgi_msg, s1u_msg, s11_msg; - s1u_msg = srslte::make_byte_buffer("spgw::run_thread::s1u"); - s11_msg = srslte::make_byte_buffer("spgw::run_thread::s11"); + srsran::unique_byte_buffer_t sgi_msg, s1u_msg, s11_msg; + s1u_msg = srsran::make_byte_buffer("spgw::run_thread::s1u"); + s11_msg = srsran::make_byte_buffer("spgw::run_thread::s11"); struct sockaddr_in src_addr_in; struct sockaddr_un src_addr_un; @@ -106,7 +106,7 @@ void spgw::run_thread() int s1u = m_gtpu->get_s1u(); int s11 = m_gtpc->get_s11(); - size_t buf_len = SRSLTE_MAX_BUFFER_SIZE_BYTES - SRSLTE_BUFFER_HEADER_OFFSET; + size_t buf_len = SRSRAN_MAX_BUFFER_SIZE_BYTES - SRSRAN_BUFFER_HEADER_OFFSET; fd_set set; int max_fd = std::max(s1u, sgi); @@ -134,7 +134,7 @@ void spgw::run_thread() * handle_downlink_data_notification_failure) */ m_logger.debug("Message received at SPGW: SGi Message"); - sgi_msg = srslte::make_byte_buffer("spgw::run_thread::sgi_msg"); + sgi_msg = srsran::make_byte_buffer("spgw::run_thread::sgi_msg"); sgi_msg->N_bytes = read(sgi, sgi_msg->msg, buf_len); m_gtpu->handle_sgi_pdu(std::move(sgi_msg)); } diff --git a/srsepc/srsepc_if_masq.sh b/srsepc/srsepc_if_masq.sh index 04ff00378..b6ab769c5 100755 --- a/srsepc/srsepc_if_masq.sh +++ b/srsepc/srsepc_if_masq.sh @@ -1,7 +1,7 @@ #!/bin/bash # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of diff --git a/srsue/CMakeLists.txt b/srsue/CMakeLists.txt index 015885e23..60f3376a0 100644 --- a/srsue/CMakeLists.txt +++ b/srsue/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of diff --git a/srsue/hdr/metrics_csv.h b/srsue/hdr/metrics_csv.h index ba62c1f56..d00aa5b5d 100644 --- a/srsue/hdr/metrics_csv.h +++ b/srsue/hdr/metrics_csv.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -25,12 +25,12 @@ #include #include -#include "srslte/common/metrics_hub.h" +#include "srsran/common/metrics_hub.h" #include "ue_metrics_interface.h" namespace srsue { -class metrics_csv : public srslte::metrics_listener +class metrics_csv : public srsran::metrics_listener { public: metrics_csv(std::string filename, bool append = false); diff --git a/srsue/hdr/metrics_stdout.h b/srsue/hdr/metrics_stdout.h index 6c86f53e8..085f2ddfc 100644 --- a/srsue/hdr/metrics_stdout.h +++ b/srsue/hdr/metrics_stdout.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -22,12 +22,12 @@ #include #include -#include "srslte/common/metrics_hub.h" +#include "srsran/common/metrics_hub.h" #include "ue_metrics_interface.h" namespace srsue { -class metrics_stdout : public srslte::metrics_listener +class metrics_stdout : public srsran::metrics_listener { public: metrics_stdout(){}; diff --git a/srsue/hdr/phy/lte/cc_worker.h b/srsue/hdr/phy/lte/cc_worker.h index 7d3704354..1ec1e0a8d 100644 --- a/srsue/hdr/phy/lte/cc_worker.h +++ b/srsue/hdr/phy/lte/cc_worker.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,8 +13,8 @@ #ifndef SRSUE_LTE_CC_WORKER_H #define SRSUE_LTE_CC_WORKER_H -#include "srslte/interfaces/ue_interfaces.h" -#include "srslte/srslte.h" +#include "srsran/interfaces/ue_interfaces.h" +#include "srsran/srsran.h" #include "srsue/hdr/phy/phy_common.h" namespace srsue { @@ -38,17 +38,17 @@ public: // Functions to set configuration. // Warning: all these functions are unlocked and must be called while the worker is not processing data void reset_cell_unlocked(); - bool set_cell_unlocked(srslte_cell_t cell_); - void set_tdd_config_unlocked(srslte_tdd_config_t config); - void set_config_unlocked(srslte::phy_cfg_t& phy_cfg); - void upd_config_dci_unlocked(srslte_dci_cfg_t& dci_cfg); + bool set_cell_unlocked(srsran_cell_t cell_); + void set_tdd_config_unlocked(srsran_tdd_config_t config); + void set_config_unlocked(srsran::phy_cfg_t& phy_cfg); + void upd_config_dci_unlocked(srsran_dci_cfg_t& dci_cfg); void enable_pregen_signals_unlocked(bool enabled); - void set_uci_periodic_cqi(srslte_uci_data_t* uci_data); + void set_uci_periodic_cqi(srsran_uci_data_t* uci_data); bool work_dl_regular(); - bool work_dl_mbsfn(srslte_mbsfn_cfg_t mbsfn_cfg); - bool work_ul(srslte_uci_data_t* uci_data); + bool work_dl_mbsfn(srsran_mbsfn_cfg_t mbsfn_cfg); + bool work_ul(srsran_uci_data_t* uci_data); int read_ce_abs(float* ce_abs, uint32_t tx_antenna, uint32_t rx_antenna); int read_pdsch_d(cf_t* pdsch_d); @@ -58,11 +58,11 @@ public: private: void reset(); - void dl_phy_to_mac_grant(srslte_pdsch_grant_t* phy_grant, - srslte_dci_dl_t* dl_dci, + void dl_phy_to_mac_grant(srsran_pdsch_grant_t* phy_grant, + srsran_dci_dl_t* dl_dci, mac_interface_phy_lte::mac_grant_dl_t* mac_grant); - void ul_phy_to_mac_grant(srslte_pusch_grant_t* phy_grant, - srslte_dci_ul_t* ul_dci, + void ul_phy_to_mac_grant(srsran_pusch_grant_t* phy_grant, + srsran_dci_ul_t* ul_dci, uint32_t pid, bool ul_grant_available, mac_interface_phy_lte::mac_grant_ul_t* mac_grant); @@ -72,44 +72,44 @@ private: int decode_pdcch_dl(); void decode_phich(); - int decode_pdsch(srslte_pdsch_ack_resource_t ack_resource, + int decode_pdsch(srsran_pdsch_ack_resource_t ack_resource, mac_interface_phy_lte::tb_action_dl_t* action, - bool acks[SRSLTE_MAX_CODEWORDS]); - int decode_pmch(mac_interface_phy_lte::tb_action_dl_t* action, srslte_mbsfn_cfg_t* mbsfn_cfg); + bool acks[SRSRAN_MAX_CODEWORDS]); + int decode_pmch(mac_interface_phy_lte::tb_action_dl_t* action, srsran_mbsfn_cfg_t* mbsfn_cfg); /* Methods for UL */ - bool encode_uplink(mac_interface_phy_lte::tb_action_ul_t* action, srslte_uci_data_t* uci_data); - void set_uci_sr(srslte_uci_data_t* uci_data); - void set_uci_aperiodic_cqi(srslte_uci_data_t* uci_data); - void set_uci_ack(srslte_uci_data_t* uci_data, bool is_grant_available, uint32_t dai_ul, bool is_pusch_available); + bool encode_uplink(mac_interface_phy_lte::tb_action_ul_t* action, srsran_uci_data_t* uci_data); + void set_uci_sr(srsran_uci_data_t* uci_data); + void set_uci_aperiodic_cqi(srsran_uci_data_t* uci_data); + void set_uci_ack(srsran_uci_data_t* uci_data, bool is_grant_available, uint32_t dai_ul, bool is_pusch_available); uint32_t get_wideband_cqi(); /* Common objects */ phy_common* phy = nullptr; srslog::basic_logger& logger; - srslte_cell_t cell = {}; - srslte_dl_sf_cfg_t sf_cfg_dl = {}; - srslte_ul_sf_cfg_t sf_cfg_ul = {}; + srsran_cell_t cell = {}; + srsran_dl_sf_cfg_t sf_cfg_dl = {}; + srsran_ul_sf_cfg_t sf_cfg_ul = {}; uint32_t cc_idx = 0; bool pregen_enabled = false; bool cell_initiated = false; - cf_t* signal_buffer_rx[SRSLTE_MAX_PORTS] = {}; - cf_t* signal_buffer_tx[SRSLTE_MAX_PORTS] = {}; + cf_t* signal_buffer_rx[SRSRAN_MAX_PORTS] = {}; + cf_t* signal_buffer_tx[SRSRAN_MAX_PORTS] = {}; uint32_t signal_buffer_max_samples = 0; /* Objects for DL */ - srslte_ue_dl_t ue_dl = {}; - srslte_ue_dl_cfg_t ue_dl_cfg = {}; - srslte_pmch_cfg_t pmch_cfg = {}; + srsran_ue_dl_t ue_dl = {}; + srsran_ue_dl_cfg_t ue_dl_cfg = {}; + srsran_pmch_cfg_t pmch_cfg = {}; - srslte_chest_dl_cfg_t chest_mbsfn_cfg = {}; - srslte_chest_dl_cfg_t chest_default_cfg = {}; + srsran_chest_dl_cfg_t chest_mbsfn_cfg = {}; + srsran_chest_dl_cfg_t chest_default_cfg = {}; /* Objects for UL */ - srslte_ue_ul_t ue_ul = {}; - srslte_ue_ul_cfg_t ue_ul_cfg = {}; + srsran_ue_ul_t ue_ul = {}; + srsran_ue_ul_cfg_t ue_ul_cfg = {}; }; } // namespace lte diff --git a/srsue/hdr/phy/lte/sf_worker.h b/srsue/hdr/phy/lte/sf_worker.h index 6b544f2a9..a581eab09 100644 --- a/srsue/hdr/phy/lte/sf_worker.h +++ b/srsue/hdr/phy/lte/sf_worker.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -14,8 +14,8 @@ #define SRSUE_LTE_SF_WORKER_H #include "cc_worker.h" -#include "srslte/common/thread_pool.h" -#include "srslte/srslte.h" +#include "srsran/common/thread_pool.h" +#include "srsran/srsran.h" #include "srsue/hdr/phy/phy_common.h" #include @@ -30,25 +30,25 @@ namespace lte { * A sf_worker object is executed by a thread within the thread_pool. */ -class sf_worker : public srslte::thread_pool::worker +class sf_worker : public srsran::thread_pool::worker { public: sf_worker(uint32_t max_prb, phy_common* phy_, srslog::basic_logger& logger); virtual ~sf_worker(); void reset_cell_unlocked(uint32_t cc_idx); - bool set_cell_unlocked(uint32_t cc_idx, srslte_cell_t cell_); + bool set_cell_unlocked(uint32_t cc_idx, srsran_cell_t cell_); /* Functions used by main PHY thread */ cf_t* get_buffer(uint32_t cc_idx, uint32_t antenna_idx); uint32_t get_buffer_len(); void set_tti(uint32_t tti); - void set_tx_time(const srslte::rf_timestamp_t& tx_time); + void set_tx_time(const srsran::rf_timestamp_t& tx_time); void set_prach(cf_t* prach_ptr, float prach_power); void set_cfo_unlocked(const uint32_t& cc_idx, float cfo); - void set_tdd_config_unlocked(srslte_tdd_config_t config); - void set_config_unlocked(uint32_t cc_idx, srslte::phy_cfg_t phy_cfg); + void set_tdd_config_unlocked(srsran_tdd_config_t config); + void set_config_unlocked(uint32_t cc_idx, srsran::phy_cfg_t phy_cfg); void set_crnti_unlocked(uint16_t rnti); void enable_pregen_signals_unlocked(bool enabled); @@ -73,7 +73,7 @@ private: void work_imp() final; void update_measurements(); - void reset_uci(srslte_uci_data_t* uci_data); + void reset_uci(srsran_uci_data_t* uci_data); std::vector cc_workers; @@ -81,9 +81,9 @@ private: srslog::basic_logger& logger; - srslte_cell_t cell = {}; + srsran_cell_t cell = {}; std::mutex cell_mutex; - srslte_tdd_config_t tdd_config = {}; + srsran_tdd_config_t tdd_config = {}; std::condition_variable cell_init_cond; bool cell_initiated = false; @@ -92,7 +92,7 @@ private: float prach_power = 0; uint32_t tti = 0; - srslte::rf_timestamp_t tx_time = {}; + srsran::rf_timestamp_t tx_time = {}; }; } // namespace lte diff --git a/srsue/hdr/phy/lte/worker_pool.h b/srsue/hdr/phy/lte/worker_pool.h index ad757c99c..4c3b6e312 100644 --- a/srsue/hdr/phy/lte/worker_pool.h +++ b/srsue/hdr/phy/lte/worker_pool.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -14,14 +14,14 @@ #define SRSUE_LTE_WORKER_POOL_H #include "sf_worker.h" -#include "srslte/common/thread_pool.h" +#include "srsran/common/thread_pool.h" namespace srsue { namespace lte { class worker_pool { - srslte::thread_pool pool; + srsran::thread_pool pool; std::vector > workers; public: diff --git a/srsue/hdr/phy/nr/cc_worker.h b/srsue/hdr/phy/nr/cc_worker.h index 97d2650ef..8c3820f9b 100644 --- a/srsue/hdr/phy/nr/cc_worker.h +++ b/srsue/hdr/phy/nr/cc_worker.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,8 +10,8 @@ * */ -#ifndef SRSLTE_NR_CC_WORKER_H -#define SRSLTE_NR_CC_WORKER_H +#ifndef SRSRAN_NR_CC_WORKER_H +#define SRSRAN_NR_CC_WORKER_H #include "srsue/hdr/phy/phy_common.h" #include "state.h" @@ -25,7 +25,7 @@ public: cc_worker(uint32_t cc_idx, srslog::basic_logger& log, state* phy_state_); ~cc_worker(); - bool set_carrier(const srslte_carrier_nr_t* carrier); + bool set_carrier(const srsran_carrier_nr_t* carrier); void set_tti(uint32_t tti); cf_t* get_rx_buffer(uint32_t antenna_idx); @@ -38,19 +38,19 @@ public: int read_pdsch_d(cf_t* pdsch_d); private: - srslte_slot_cfg_t dl_slot_cfg = {}; - srslte_slot_cfg_t ul_slot_cfg = {}; + srsran_slot_cfg_t dl_slot_cfg = {}; + srsran_slot_cfg_t ul_slot_cfg = {}; uint32_t cc_idx = 0; - std::array rx_buffer = {}; - std::array tx_buffer = {}; + std::array rx_buffer = {}; + std::array tx_buffer = {}; uint32_t buffer_sz = 0; state* phy = nullptr; - srslte_ue_dl_nr_t ue_dl = {}; - srslte_ue_ul_nr_t ue_ul = {}; + srsran_ue_dl_nr_t ue_dl = {}; + srsran_ue_ul_nr_t ue_ul = {}; srslog::basic_logger& logger; // Temporal attributes - srslte_softbuffer_rx_t softbuffer_rx = {}; + srsran_softbuffer_rx_t softbuffer_rx = {}; // Methods for DL... void decode_pdcch_ul(); @@ -60,4 +60,4 @@ private: } // namespace nr } // namespace srsue -#endif // SRSLTE_NR_CC_WORKER_H +#endif // SRSRAN_NR_CC_WORKER_H diff --git a/srsue/hdr/phy/nr/sf_worker.h b/srsue/hdr/phy/nr/sf_worker.h index e49768756..60e6698d9 100644 --- a/srsue/hdr/phy/nr/sf_worker.h +++ b/srsue/hdr/phy/nr/sf_worker.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -15,7 +15,7 @@ #include "../phy_common.h" #include "cc_worker.h" -#include "srslte/common/thread_pool.h" +#include "srsran/common/thread_pool.h" namespace srsue { namespace nr { @@ -28,13 +28,13 @@ namespace nr { * A sf_worker object is executed by a thread within the thread_pool. */ -class sf_worker final : public srslte::thread_pool::worker +class sf_worker final : public srsran::thread_pool::worker { public: sf_worker(phy_common* phy, state* phy_state_, srslog::basic_logger& logger); ~sf_worker() = default; - bool set_carrier_unlocked(uint32_t cc_idx, const srslte_carrier_nr_t* carrier_); + bool set_carrier_unlocked(uint32_t cc_idx, const srsran_carrier_nr_t* carrier_); /* Functions used by main PHY thread */ cf_t* get_buffer(uint32_t cc_idx, uint32_t antenna_idx); diff --git a/srsue/hdr/phy/nr/state.h b/srsue/hdr/phy/nr/state.h index ff379c16d..2b0996ad5 100644 --- a/srsue/hdr/phy/nr/state.h +++ b/srsue/hdr/phy/nr/state.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,13 +10,13 @@ * */ -#ifndef SRSLTE_STATE_H -#define SRSLTE_STATE_H +#ifndef SRSRAN_STATE_H +#define SRSRAN_STATE_H -#include "srslte/adt/circular_array.h" -#include "srslte/common/common.h" -#include "srslte/interfaces/ue_nr_interfaces.h" -#include "srslte/srslte.h" +#include "srsran/adt/circular_array.h" +#include "srsran/common/common.h" +#include "srsran/interfaces/ue_nr_interfaces.h" +#include "srsran/srsran.h" #include #include #include @@ -30,38 +30,38 @@ private: struct pending_ul_grant_t { bool enable; uint32_t pid; - srslte_sch_cfg_nr_t sch_cfg; + srsran_sch_cfg_nr_t sch_cfg; }; - srslte::circular_array pending_ul_grant = {}; + srsran::circular_array pending_ul_grant = {}; mutable std::mutex pending_ul_grant_mutex; struct pending_dl_grant_t { bool enable; uint32_t pid; - srslte_sch_cfg_nr_t sch_cfg; - srslte_pdsch_ack_resource_nr_t ack_resource; + srsran_sch_cfg_nr_t sch_cfg; + srsran_pdsch_ack_resource_nr_t ack_resource; }; - srslte::circular_array pending_dl_grant = {}; + srsran::circular_array pending_dl_grant = {}; mutable std::mutex pending_dl_grant_mutex; - srslte::circular_array pending_ack = {}; + srsran::circular_array pending_ack = {}; mutable std::mutex pending_ack_mutex; /// Pending scheduling request identifiers std::set pending_sr_id; /// CSI-RS measurements - std::array csi_measurements = {}; + std::array csi_measurements = {}; public: mac_interface_phy_nr* stack = nullptr; - srslte_carrier_nr_t carrier = {}; + srsran_carrier_nr_t carrier = {}; /// Physical layer user configuration phy_args_nr_t args = {}; /// Physical layer higher layer configuration, provided by higher layers through configuration messages - srslte::phy_cfg_nr_t cfg = {}; + srsran::phy_cfg_nr_t cfg = {}; uint16_t ra_rnti = 0; uint32_t rar_grant_tti = 0; @@ -84,13 +84,13 @@ public: * @param tti_rx The TTI in which the grant was received * @param dci_ul The UL DCI message to store */ - void set_ul_pending_grant(uint32_t tti_rx, const srslte_dci_ul_nr_t& dci_ul) + void set_ul_pending_grant(uint32_t tti_rx, const srsran_dci_ul_nr_t& dci_ul) { // Convert UL DCI to grant - srslte_sch_cfg_nr_t pusch_cfg = {}; - if (srslte_ra_ul_dci_to_grant_nr(&carrier, &cfg.pusch, &dci_ul, &pusch_cfg, &pusch_cfg.grant)) { + srsran_sch_cfg_nr_t pusch_cfg = {}; + if (srsran_ra_ul_dci_to_grant_nr(&carrier, &cfg.pusch, &dci_ul, &pusch_cfg, &pusch_cfg.grant)) { std::array str; - srslte_dci_ul_nr_to_str(&dci_ul, str.data(), str.size()); + srsran_dci_ul_nr_to_str(&dci_ul, str.data(), str.size()); ERROR("Computing UL grant %s", str.data()); return; } @@ -115,7 +115,7 @@ public: * @param pid Provides the HARQ process identifier * @return true if there is a pending grant for the given TX tti, false otherwise */ - bool get_ul_pending_grant(uint32_t tti_tx, srslte_sch_cfg_nr_t& pusch_cfg, uint32_t& pid) + bool get_ul_pending_grant(uint32_t tti_tx, srsran_sch_cfg_nr_t& pusch_cfg, uint32_t& pid) { // Scope mutex to protect read/write the list std::lock_guard lock(pending_ul_grant_mutex); @@ -142,18 +142,18 @@ public: * @param tti_rx The TTI in which the grant was received * @param dci_dl The DL DCI message to store */ - void set_dl_pending_grant(uint32_t tti_rx, const srslte_dci_dl_nr_t& dci_dl) + void set_dl_pending_grant(uint32_t tti_rx, const srsran_dci_dl_nr_t& dci_dl) { // Convert DL DCI to grant - srslte_sch_cfg_nr_t pdsch_cfg = {}; - if (srslte_ra_dl_dci_to_grant_nr(&carrier, &cfg.pdsch, &dci_dl, &pdsch_cfg, &pdsch_cfg.grant)) { + srsran_sch_cfg_nr_t pdsch_cfg = {}; + if (srsran_ra_dl_dci_to_grant_nr(&carrier, &cfg.pdsch, &dci_dl, &pdsch_cfg, &pdsch_cfg.grant)) { ERROR("Computing UL grant"); return; } // Calculate DL DCI to PDSCH ACK resource - srslte_pdsch_ack_resource_nr_t ack_resource = {}; - if (srslte_ue_dl_nr_pdsch_ack_resource(&cfg.harq_ack, &dci_dl, &ack_resource) < SRSLTE_SUCCESS) { + srsran_pdsch_ack_resource_nr_t ack_resource = {}; + if (srsran_ue_dl_nr_pdsch_ack_resource(&cfg.harq_ack, &dci_dl, &ack_resource) < SRSRAN_SUCCESS) { ERROR("Computing UL ACK resource"); return; } @@ -181,8 +181,8 @@ public: * @return true if there is a pending grant for the given TX tti, false otherwise */ bool get_dl_pending_grant(uint32_t tti_rx, - srslte_sch_cfg_nr_t& pdsch_cfg, - srslte_pdsch_ack_resource_nr_t& ack_resource, + srsran_sch_cfg_nr_t& pdsch_cfg, + srsran_pdsch_ack_resource_nr_t& ack_resource, uint32_t& pid) { // Scope mutex to protect read/write the list @@ -212,7 +212,7 @@ public: * @param tti_rx The TTI in which the PDSCH transmission was received * @param dci_dl The DL DCI message to store */ - void set_pending_ack(const uint32_t& tti_rx, const srslte_pdsch_ack_resource_nr_t& ack_resource, const bool& crc_ok) + void set_pending_ack(const uint32_t& tti_rx, const srsran_pdsch_ack_resource_nr_t& ack_resource, const bool& crc_ok) { // Calculate Receive TTI uint32_t tti_tx = TTI_ADD(tti_rx, ack_resource.k1); @@ -221,12 +221,12 @@ public: std::lock_guard lock(pending_ack_mutex); // Select UL transmission time resource - srslte_pdsch_ack_nr_t& ack = pending_ack[tti_tx]; + srsran_pdsch_ack_nr_t& ack = pending_ack[tti_tx]; ack.nof_cc = 1; // Select serving cell - srslte_pdsch_ack_cc_nr_t& ack_cc = ack.cc[ack_resource.scell_idx]; - srslte_pdsch_ack_m_nr_t& ack_m = ack_cc.m[ack_cc.M]; + srsran_pdsch_ack_cc_nr_t& ack_cc = ack.cc[ack_resource.scell_idx]; + srsran_pdsch_ack_m_nr_t& ack_m = ack_cc.m[ack_cc.M]; ack_cc.M++; // Set PDSCH transmission information @@ -235,13 +235,13 @@ public: ack_m.present = true; } - bool get_pending_ack(const uint32_t& tti_tx, srslte_pdsch_ack_nr_t& pdsch_ack) + bool get_pending_ack(const uint32_t& tti_tx, srsran_pdsch_ack_nr_t& pdsch_ack) { // Scope mutex to protect read/write the list std::lock_guard lock(pending_ack_mutex); // Select UL transmission time resource - srslte_pdsch_ack_nr_t& ack = pending_ack[tti_tx]; + srsran_pdsch_ack_nr_t& ack = pending_ack[tti_tx]; // No pending grant was set if (ack.nof_cc == 0) { @@ -261,15 +261,15 @@ public: void set_pending_sr(uint32_t value) { pending_sr_id.insert(value); } - void get_pending_sr(const uint32_t& tti, srslte_uci_data_nr_t& uci_data) + void get_pending_sr(const uint32_t& tti, srsran_uci_data_nr_t& uci_data) { // Append fixed SR pending_sr_id.insert(args.fixed_sr.begin(), args.fixed_sr.end()); // Calculate all SR opportunities in the given TTI - uint32_t sr_resource_id[SRSLTE_PUCCH_MAX_NOF_SR_RESOURCES] = {}; - int n = srslte_ue_ul_nr_sr_send_slot(cfg.pucch.sr_resources, tti, sr_resource_id); - if (n < SRSLTE_SUCCESS) { + uint32_t sr_resource_id[SRSRAN_PUCCH_MAX_NOF_SR_RESOURCES] = {}; + int n = srsran_ue_ul_nr_sr_send_slot(cfg.pucch.sr_resources, tti, sr_resource_id); + if (n < SRSRAN_SUCCESS) { ERROR("Calculating SR opportunities"); return; } @@ -295,15 +295,15 @@ public: // Configure SR fields in UCI data uci_data.cfg.pucch.sr_resource_id = sr_resource_id[0]; - uci_data.cfg.o_sr = srslte_ra_ul_nr_nof_sr_bits(sr_count_all); + uci_data.cfg.o_sr = srsran_ra_ul_nr_nof_sr_bits(sr_count_all); uci_data.cfg.pucch.sr_positive_present = sr_count_positive > 0; uci_data.value.sr = sr_count_positive; } - void get_periodic_csi(const uint32_t& tti, srslte_uci_data_nr_t& uci_data) + void get_periodic_csi(const uint32_t& tti, srsran_uci_data_nr_t& uci_data) { - int n = srslte_csi_generate_reports(&cfg.csi, tti, csi_measurements.data(), uci_data.cfg.csi, uci_data.value.csi); - if (n > SRSLTE_SUCCESS) { + int n = srsran_csi_generate_reports(&cfg.csi, tti, csi_measurements.data(), uci_data.cfg.csi, uci_data.value.csi); + if (n > SRSRAN_SUCCESS) { uci_data.cfg.nof_csi = n; } @@ -313,4 +313,4 @@ public: } // namespace nr } // namespace srsue -#endif // SRSLTE_STATE_H +#endif // SRSRAN_STATE_H diff --git a/srsue/hdr/phy/nr/worker_pool.h b/srsue/hdr/phy/nr/worker_pool.h index ddb42f485..55eb3f9c3 100644 --- a/srsue/hdr/phy/nr/worker_pool.h +++ b/srsue/hdr/phy/nr/worker_pool.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -14,7 +14,7 @@ #define SRSUE_NR_WORKER_POOL_H #include "sf_worker.h" -#include "srslte/common/thread_pool.h" +#include "srsran/common/thread_pool.h" #include "srsue/hdr/phy/prach.h" namespace srsue { @@ -24,7 +24,7 @@ class worker_pool { private: srslog::basic_logger& logger; - srslte::thread_pool pool; + srsran::thread_pool pool; std::vector > workers; state phy_state; std::unique_ptr prach_buffer = nullptr; @@ -38,8 +38,8 @@ public: void start_worker(sf_worker* w); void stop(); void send_prach(uint32_t prach_occasion, uint32_t preamble_index, int preamble_received_target_power); - int set_ul_grant(std::array array, uint16_t rnti, srslte_rnti_type_t rnti_type); - bool set_config(const srslte::phy_cfg_nr_t& cfg); + int set_ul_grant(std::array array, uint16_t rnti, srsran_rnti_type_t rnti_type); + bool set_config(const srsran::phy_cfg_nr_t& cfg); void sr_send(uint32_t sr_id); }; diff --git a/srsue/hdr/phy/phy.h b/srsue/hdr/phy/phy.h index 034f996f7..a7643929d 100644 --- a/srsue/hdr/phy/phy.h +++ b/srsue/hdr/phy/phy.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -15,14 +15,14 @@ #include "phy_common.h" #include "phy_metrics.h" -#include "srslte/common/block_queue.h" -#include "srslte/common/threads.h" -#include "srslte/common/trace.h" -#include "srslte/interfaces/phy_interface_types.h" -#include "srslte/interfaces/radio_interfaces.h" -#include "srslte/radio/radio.h" -#include "srslte/srslog/srslog.h" -#include "srslte/srslte.h" +#include "srsran/common/block_queue.h" +#include "srsran/common/threads.h" +#include "srsran/common/trace.h" +#include "srsran/interfaces/phy_interface_types.h" +#include "srsran/interfaces/radio_interfaces.h" +#include "srsran/radio/radio.h" +#include "srsran/srslog/srslog.h" +#include "srsran/srsran.h" #include "srsue/hdr/phy/lte/worker_pool.h" #include "srsue/hdr/phy/nr/worker_pool.h" #include "srsue/hdr/phy/ue_lte_phy_base.h" @@ -33,7 +33,7 @@ namespace srsue { typedef _Complex float cf_t; -class phy_cmd_proc : public srslte::thread +class phy_cmd_proc : public srsran::thread { public: phy_cmd_proc() : thread("PHY_CMD") { start(); } @@ -61,10 +61,10 @@ private: } bool running = true; // Queue for commands - srslte::block_queue > cmd_queue; + srsran::block_queue > cmd_queue; }; -class phy final : public ue_lte_phy_base, public ue_nr_phy_base, public srslte::thread +class phy final : public ue_lte_phy_base, public ue_nr_phy_base, public srsran::thread { public: explicit phy() : @@ -84,7 +84,7 @@ public: int init(const phy_args_t& args_) final; // Init for LTE PHYs - int init(const phy_args_t& args_, stack_interface_phy_lte* stack_, srslte::radio_interface_phy* radio_) final; + int init(const phy_args_t& args_, stack_interface_phy_lte* stack_, srsran::radio_interface_phy* radio_) final; void stop() final; @@ -92,7 +92,7 @@ public: bool is_initiated(); void get_metrics(phy_metrics_t* m) final; - void srslte_phy_logger(phy_logger_level_t log_level, char* str); + void srsran_phy_logger(phy_logger_level_t log_level, char* str); void enable_pregen_signals(bool enable) final; @@ -107,19 +107,19 @@ public: // Sets the new PHY configuration for the given CC. The configuration is applied in the background. The notify() // function will be called when the reconfiguration is completed. Unless the PRACH configuration has changed, the // reconfiguration will not take more than 3 ms - bool set_config(srslte::phy_cfg_t config, uint32_t cc_idx) final; + bool set_config(srsran::phy_cfg_t config, uint32_t cc_idx) final; // Adds or modifies the cell configuration for a given CC. If the EARFCN has changed w.r.t. the previous value, or if // the cell is new, this function might take a few hundred ms to complete, depending on the radio - bool set_scell(srslte_cell_t cell_info, uint32_t cc_idx, uint32_t earfcn) final; + bool set_scell(srsran_cell_t cell_info, uint32_t cc_idx, uint32_t earfcn) final; // Applies a TDD configuration in the background. This function will take less than 3 ms to execute. - void set_config_tdd(srslte_tdd_config_t& tdd_config) final; + void set_config_tdd(srsran_tdd_config_t& tdd_config) final; // Todo - void set_config_mbsfn_sib2(srslte::mbsfn_sf_cfg_t* cfg_list, uint32_t nof_cfgs) final; - void set_config_mbsfn_sib13(const srslte::sib13_t& sib13) final; - void set_config_mbsfn_mcch(const srslte::mcch_msg_t& mcch) final; + void set_config_mbsfn_sib2(srsran::mbsfn_sf_cfg_t* cfg_list, uint32_t nof_cfgs) final; + void set_config_mbsfn_sib13(const srsran::sib13_t& sib13) final; + void set_config_mbsfn_mcch(const srsran::mcch_msg_t& mcch) final; // This function applies the new configuration immediately void set_cells_to_meas(uint32_t earfcn, const std::set& pci) final; @@ -148,7 +148,7 @@ public: void set_activation_deactivation_scell(uint32_t cmd, uint32_t tti) final; /* Sets RAR dci payload */ - void set_rar_grant(uint8_t grant_payload[SRSLTE_RAR_GRANT_LEN], uint16_t rnti) final; + void set_rar_grant(uint8_t grant_payload[SRSRAN_RAR_GRANT_LEN], uint16_t rnti) final; /*Set MAC->PHY MCH period stopping point*/ void set_mch_period_stop(uint32_t stop) final; @@ -165,11 +165,11 @@ public: std::string get_type() final { return "lte_soft"; } - int init(const phy_args_nr_t& args_, stack_interface_phy_nr* stack_, srslte::radio_interface_phy* radio_) final; - bool set_config(const srslte::phy_cfg_nr_t& cfg) final; - int set_ul_grant(std::array packed_ul_grant, + int init(const phy_args_nr_t& args_, stack_interface_phy_nr* stack_, srsran::radio_interface_phy* radio_) final; + bool set_config(const srsran::phy_cfg_nr_t& cfg) final; + int set_ul_grant(std::array packed_ul_grant, uint16_t rnti, - srslte_rnti_type_t rnti_type) final; + srsran_rnti_type_t rnti_type) final; void send_prach(const uint32_t prach_occasion, const int preamble_index, const float preamble_received_target_power, @@ -190,7 +190,7 @@ private: const static int SF_RECV_THREAD_PRIO = 0; const static int WORKERS_THREAD_PRIO = 2; - srslte::radio_interface_phy* radio = nullptr; + srsran::radio_interface_phy* radio = nullptr; srslog::basic_logger& logger_phy; srslog::basic_logger& logger_phy_lib; @@ -202,10 +202,10 @@ private: sync sfsync; prach prach_buffer; - srslte_prach_cfg_t prach_cfg = {}; - srslte_tdd_config_t tdd_config = {}; + srsran_prach_cfg_t prach_cfg = {}; + srsran_tdd_config_t tdd_config = {}; - srslte::phy_cfg_t config = {}; + srsran::phy_cfg_t config = {}; phy_args_t args = {}; // Since cell_search/cell_select operations take a lot of time, we use another queue to process the other commands @@ -213,7 +213,7 @@ private: phy_cmd_proc cmd_worker_cell, cmd_worker; // Tracks the current selected cell (last call to cell_select) - srslte_cell_t selected_cell = {}; + srsran_cell_t selected_cell = {}; static void set_default_args(phy_args_t& args); bool check_args(const phy_args_t& args); diff --git a/srsue/hdr/phy/phy_common.h b/srsue/hdr/phy/phy_common.h index bd5b87cd3..f319c82ed 100644 --- a/srsue/hdr/phy/phy_common.h +++ b/srsue/hdr/phy/phy_common.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -14,16 +14,16 @@ #define SRSUE_PHCH_COMMON_H #include "phy_metrics.h" -#include "srslte/adt/circular_array.h" -#include "srslte/common/gen_mch_tables.h" -#include "srslte/common/tti_sempahore.h" -#include "srslte/interfaces/phy_interface_types.h" -#include "srslte/interfaces/radio_interfaces.h" -#include "srslte/interfaces/rrc_interface_types.h" -#include "srslte/interfaces/ue_phy_interfaces.h" -#include "srslte/radio/radio.h" -#include "srslte/srslog/srslog.h" -#include "srslte/srslte.h" +#include "srsran/adt/circular_array.h" +#include "srsran/common/gen_mch_tables.h" +#include "srsran/common/tti_sempahore.h" +#include "srsran/interfaces/phy_interface_types.h" +#include "srsran/interfaces/radio_interfaces.h" +#include "srsran/interfaces/rrc_interface_types.h" +#include "srsran/interfaces/ue_phy_interfaces.h" +#include "srsran/radio/radio.h" +#include "srsran/srslog/srslog.h" +#include "srsran/srsran.h" #include "srsue/hdr/phy/scell/scell_state.h" #include "ta_control.h" #include @@ -53,18 +53,18 @@ public: phy_args_t* args = nullptr; stack_interface_phy_lte* stack = nullptr; - srslte::phy_cfg_mbsfn_t mbsfn_config = {}; + srsran::phy_cfg_mbsfn_t mbsfn_config = {}; // Secondary serving cell states scell::state cell_state; // Save last TBS for uplink (mcs >= 28) - srslte_ra_tb_t last_ul_tb[SRSLTE_MAX_HARQ_PROC][SRSLTE_MAX_CARRIERS] = {}; + srsran_ra_tb_t last_ul_tb[SRSRAN_MAX_HARQ_PROC][SRSRAN_MAX_CARRIERS] = {}; // Save last TBS for DL (Format1C) - int last_dl_tbs[SRSLTE_MAX_HARQ_PROC][SRSLTE_MAX_CARRIERS][SRSLTE_MAX_CODEWORDS] = {}; + int last_dl_tbs[SRSRAN_MAX_HARQ_PROC][SRSRAN_MAX_CARRIERS][SRSRAN_MAX_CODEWORDS] = {}; - srslte::tti_semaphore semaphore; + srsran::tti_semaphore semaphore; // Time Aligment Controller, internal thread safe ta_control ta; @@ -74,41 +74,41 @@ public: ~phy_common(); void init(phy_args_t* args, - srslte::radio_interface_phy* _radio, + srsran::radio_interface_phy* _radio, stack_interface_phy_lte* _stack, rsrp_insync_itf* rsrp_insync); - uint32_t ul_pidof(uint32_t tti, srslte_tdd_config_t* tdd_config); + uint32_t ul_pidof(uint32_t tti, srsran_tdd_config_t* tdd_config); // Set configurations for lib objects - void set_ue_dl_cfg(srslte_ue_dl_cfg_t* ue_dl_cfg); - void set_ue_ul_cfg(srslte_ue_ul_cfg_t* ue_ul_cfg); - void set_pdsch_cfg(srslte_pdsch_cfg_t* pdsch_cfg); + void set_ue_dl_cfg(srsran_ue_dl_cfg_t* ue_dl_cfg); + void set_ue_ul_cfg(srsran_ue_ul_cfg_t* ue_ul_cfg); + void set_pdsch_cfg(srsran_pdsch_cfg_t* pdsch_cfg); - void set_rar_grant(uint8_t grant_payload[SRSLTE_RAR_GRANT_LEN], uint16_t rnti, srslte_tdd_config_t tdd_config); + void set_rar_grant(uint8_t grant_payload[SRSRAN_RAR_GRANT_LEN], uint16_t rnti, srsran_tdd_config_t tdd_config); - void set_dl_pending_grant(uint32_t tti, uint32_t cc_idx, uint32_t grant_cc_idx, const srslte_dci_dl_t* dl_dci); - bool get_dl_pending_grant(uint32_t tti, uint32_t cc_idx, uint32_t* grant_cc_idx, srslte_dci_dl_t* dl_dci); + void set_dl_pending_grant(uint32_t tti, uint32_t cc_idx, uint32_t grant_cc_idx, const srsran_dci_dl_t* dl_dci); + bool get_dl_pending_grant(uint32_t tti, uint32_t cc_idx, uint32_t* grant_cc_idx, srsran_dci_dl_t* dl_dci); - void set_ul_pending_ack(srslte_ul_sf_cfg_t* sf, + void set_ul_pending_ack(srsran_ul_sf_cfg_t* sf, uint32_t cc_idx, - srslte_phich_grant_t phich_grant, - srslte_dci_ul_t* dci_ul); - bool get_ul_pending_ack(srslte_dl_sf_cfg_t* sf, + srsran_phich_grant_t phich_grant, + srsran_dci_ul_t* dci_ul); + bool get_ul_pending_ack(srsran_dl_sf_cfg_t* sf, uint32_t cc_idx, - srslte_phich_grant_t* phich_grant, - srslte_dci_ul_t* dci_ul); + srsran_phich_grant_t* phich_grant, + srsran_dci_ul_t* dci_ul); bool is_any_ul_pending_ack(); - bool get_ul_received_ack(srslte_ul_sf_cfg_t* sf, uint32_t cc_idx, bool* ack_value, srslte_dci_ul_t* dci_ul); - void set_ul_received_ack(srslte_dl_sf_cfg_t* sf, + bool get_ul_received_ack(srsran_ul_sf_cfg_t* sf, uint32_t cc_idx, bool* ack_value, srsran_dci_ul_t* dci_ul); + void set_ul_received_ack(srsran_dl_sf_cfg_t* sf, uint32_t cc_idx, bool ack_value, uint32_t I_phich, - srslte_dci_ul_t* dci_ul); + srsran_dci_ul_t* dci_ul); - void set_ul_pending_grant(srslte_dl_sf_cfg_t* sf, uint32_t cc_idx, srslte_dci_ul_t* dci); - bool get_ul_pending_grant(srslte_ul_sf_cfg_t* sf, uint32_t cc_idx, uint32_t* pid, srslte_dci_ul_t* dci); + void set_ul_pending_grant(srsran_dl_sf_cfg_t* sf, uint32_t cc_idx, srsran_dci_ul_t* dci); + bool get_ul_pending_grant(srsran_ul_sf_cfg_t* sf, uint32_t cc_idx, uint32_t* pid, srsran_dci_ul_t* dci); /** * If there is a UL Grant it returns the lowest index component carrier that has a grant, otherwise it returns 0. @@ -120,32 +120,32 @@ public: void set_rar_grant_tti(uint32_t tti); - void set_dl_pending_ack(srslte_dl_sf_cfg_t* sf, + void set_dl_pending_ack(srsran_dl_sf_cfg_t* sf, uint32_t cc_idx, - uint8_t value[SRSLTE_MAX_CODEWORDS], - srslte_pdsch_ack_resource_t resource); - bool get_dl_pending_ack(srslte_ul_sf_cfg_t* sf, uint32_t cc_idx, srslte_pdsch_ack_cc_t* ack); + uint8_t value[SRSRAN_MAX_CODEWORDS], + srsran_pdsch_ack_resource_t resource); + bool get_dl_pending_ack(srsran_ul_sf_cfg_t* sf, uint32_t cc_idx, srsran_pdsch_ack_cc_t* ack); - void worker_end(void* h, bool tx_enable, srslte::rf_buffer_t& buffer, srslte::rf_timestamp_t& tx_time, bool is_nr); + void worker_end(void* h, bool tx_enable, srsran::rf_buffer_t& buffer, srsran::rf_timestamp_t& tx_time, bool is_nr); - void set_cell(const srslte_cell_t& c); + void set_cell(const srsran_cell_t& c); bool sr_enabled = false; int sr_last_tx_tti = -1; - srslte::radio_interface_phy* get_radio(); + srsran::radio_interface_phy* get_radio(); void set_dl_metrics(uint32_t cc_idx, const dl_metrics_t& m); - void get_dl_metrics(dl_metrics_t m[SRSLTE_MAX_CARRIERS]); + void get_dl_metrics(dl_metrics_t m[SRSRAN_MAX_CARRIERS]); void set_ch_metrics(uint32_t cc_idx, const ch_metrics_t& m); - void get_ch_metrics(ch_metrics_t m[SRSLTE_MAX_CARRIERS]); + void get_ch_metrics(ch_metrics_t m[SRSRAN_MAX_CARRIERS]); void set_ul_metrics(uint32_t cc_idx, const ul_metrics_t& m); - void get_ul_metrics(ul_metrics_t m[SRSLTE_MAX_CARRIERS]); + void get_ul_metrics(ul_metrics_t m[SRSRAN_MAX_CARRIERS]); void set_sync_metrics(const uint32_t& cc_idx, const sync_metrics_t& m); - void get_sync_metrics(sync_metrics_t m[SRSLTE_MAX_CARRIERS]); + void get_sync_metrics(sync_metrics_t m[SRSRAN_MAX_CARRIERS]); void reset(); void reset_radio(); @@ -153,7 +153,7 @@ public: void build_mch_table(); void build_mcch_table(); void set_mcch(); - bool is_mbsfn_sf(srslte_mbsfn_cfg_t* cfg, uint32_t tti); + bool is_mbsfn_sf(srsran_mbsfn_cfg_t* cfg, uint32_t tti); void set_mch_period_stop(uint32_t stop); /** @@ -166,8 +166,8 @@ public: uint32_t get_ul_earfcn(uint32_t dl_earfcn); void update_measurements(uint32_t cc_idx, - srslte_chest_dl_res_t chest_res, - srslte_dl_sf_cfg_t sf_cfg_dl, + srsran_chest_dl_res_t chest_res, + srsran_dl_sf_cfg_t sf_cfg_dl, float tx_crs_power, std::vector& serving_cells, cf_t* rssi_power_buffer = nullptr); @@ -205,11 +205,11 @@ public: // Add RSRP in the linear domain and average float total_rsrp = 0; for (auto& m : meas) { - total_rsrp += srslte_convert_dB_to_power(m.rsrp); + total_rsrp += srsran_convert_dB_to_power(m.rsrp); } if (std::isnormal(total_rsrp)) { if (std::isnormal(avg_rsrp_neigh[cc_idx])) { - avg_rsrp_neigh[cc_idx] = SRSLTE_VEC_EMA(total_rsrp, avg_rsrp_neigh[cc_idx], 0.9); + avg_rsrp_neigh[cc_idx] = SRSRAN_VEC_EMA(total_rsrp, avg_rsrp_neigh[cc_idx], 0.9); } else { avg_rsrp_neigh[cc_idx] = total_rsrp; } @@ -217,7 +217,7 @@ public: } void reset_neighbour_cells() { - for (uint32_t i = 0; i < SRSLTE_MAX_CARRIERS; i++) { + for (uint32_t i = 0; i < SRSRAN_MAX_CARRIERS; i++) { avg_rsrp_neigh[i] = NAN; } } @@ -225,19 +225,19 @@ public: private: std::mutex meas_mutex; - float pathloss[SRSLTE_MAX_CARRIERS] = {}; + float pathloss[SRSRAN_MAX_CARRIERS] = {}; float cur_pathloss = 0.0f; float cur_pusch_power = 0.0f; - float avg_rsrp[SRSLTE_MAX_CARRIERS] = {}; - float avg_rsrp_dbm[SRSLTE_MAX_CARRIERS] = {}; - float avg_rsrq_db[SRSLTE_MAX_CARRIERS] = {}; - float avg_rssi_dbm[SRSLTE_MAX_CARRIERS] = {}; - float avg_cfo_hz[SRSLTE_MAX_CARRIERS] = {}; + float avg_rsrp[SRSRAN_MAX_CARRIERS] = {}; + float avg_rsrp_dbm[SRSRAN_MAX_CARRIERS] = {}; + float avg_rsrq_db[SRSRAN_MAX_CARRIERS] = {}; + float avg_rssi_dbm[SRSRAN_MAX_CARRIERS] = {}; + float avg_cfo_hz[SRSRAN_MAX_CARRIERS] = {}; float rx_gain_offset = 0.0f; - float avg_sinr_db[SRSLTE_MAX_CARRIERS] = {}; - float avg_snr_db[SRSLTE_MAX_CARRIERS] = {}; - float avg_noise[SRSLTE_MAX_CARRIERS] = {}; - float avg_rsrp_neigh[SRSLTE_MAX_CARRIERS] = {}; + float avg_sinr_db[SRSRAN_MAX_CARRIERS] = {}; + float avg_snr_db[SRSRAN_MAX_CARRIERS] = {}; + float avg_noise[SRSRAN_MAX_CARRIERS] = {}; + float avg_rsrp_neigh[SRSRAN_MAX_CARRIERS] = {}; uint32_t pcell_report_period = 0; uint32_t rssi_read_cnt = 0; @@ -250,43 +250,43 @@ private: bool is_pending_tx_end = false; - srslte::radio_interface_phy* radio_h = nullptr; + srsran::radio_interface_phy* radio_h = nullptr; srslog::basic_logger& logger; - srslte::channel_ptr ul_channel = nullptr; + srsran::channel_ptr ul_channel = nullptr; int rar_grant_tti = -1; typedef struct { bool enable; - srslte_phich_grant_t phich_grant; - srslte_dci_ul_t dci_ul; + srsran_phich_grant_t phich_grant; + srsran_dci_ul_t dci_ul; } pending_ul_ack_t; - srslte::circular_array pending_ul_ack[SRSLTE_MAX_CARRIERS][2] = {}; + srsran::circular_array pending_ul_ack[SRSRAN_MAX_CARRIERS][2] = {}; std::mutex pending_ul_ack_mutex; typedef struct { bool hi_value; bool hi_present; - srslte_dci_ul_t dci_ul; + srsran_dci_ul_t dci_ul; } received_ul_ack_t; - srslte::circular_array received_ul_ack[SRSLTE_MAX_CARRIERS] = {}; + srsran::circular_array received_ul_ack[SRSRAN_MAX_CARRIERS] = {}; std::mutex received_ul_ack_mutex; typedef struct { bool enable; uint32_t pid; - srslte_dci_ul_t dci; + srsran_dci_ul_t dci; } pending_ul_grant_t; - srslte::circular_array pending_ul_grant[SRSLTE_MAX_CARRIERS] = {}; + srsran::circular_array pending_ul_grant[SRSRAN_MAX_CARRIERS] = {}; mutable std::mutex pending_ul_grant_mutex; typedef struct { bool enable; - uint8_t value[SRSLTE_MAX_CODEWORDS]; // 0/1 or 2 for DTX - srslte_pdsch_ack_resource_t resource; + uint8_t value[SRSRAN_MAX_CODEWORDS]; // 0/1 or 2 for DTX + srsran_pdsch_ack_resource_t resource; } received_ack_t; - srslte::circular_array pending_dl_ack[SRSLTE_MAX_CARRIERS] = {}; - srslte::circular_array pending_dl_dai[SRSLTE_MAX_CARRIERS] = {}; + srsran::circular_array pending_dl_ack[SRSRAN_MAX_CARRIERS] = {}; + srsran::circular_array pending_dl_dai[SRSRAN_MAX_CARRIERS] = {}; std::mutex pending_dl_ack_mutex; std::mutex pending_dl_grant_mutex; @@ -294,22 +294,22 @@ private: typedef struct { bool enable; uint32_t grant_cc_idx; - srslte_dci_dl_t dl_dci; + srsran_dci_dl_t dl_dci; } pending_dl_grant_t; - pending_dl_grant_t pending_dl_grant[FDD_HARQ_DELAY_UL_MS][SRSLTE_MAX_CARRIERS] = {}; + pending_dl_grant_t pending_dl_grant[FDD_HARQ_DELAY_UL_MS][SRSRAN_MAX_CARRIERS] = {}; - srslte_cell_t cell = {}; + srsran_cell_t cell = {}; std::mutex metrics_mutex; - ch_metrics_t ch_metrics[SRSLTE_MAX_CARRIERS] = {}; - uint32_t ch_metrics_count[SRSLTE_MAX_CARRIERS] = {}; - dl_metrics_t dl_metrics[SRSLTE_MAX_CARRIERS] = {}; - uint32_t dl_metrics_count[SRSLTE_MAX_CARRIERS] = {}; - ul_metrics_t ul_metrics[SRSLTE_MAX_CARRIERS] = {}; - uint32_t ul_metrics_count[SRSLTE_MAX_CARRIERS] = {}; - sync_metrics_t sync_metrics[SRSLTE_MAX_CARRIERS] = {}; - uint32_t sync_metrics_count[SRSLTE_MAX_CARRIERS] = {}; + ch_metrics_t ch_metrics[SRSRAN_MAX_CARRIERS] = {}; + uint32_t ch_metrics_count[SRSRAN_MAX_CARRIERS] = {}; + dl_metrics_t dl_metrics[SRSRAN_MAX_CARRIERS] = {}; + uint32_t dl_metrics_count[SRSRAN_MAX_CARRIERS] = {}; + ul_metrics_t ul_metrics[SRSRAN_MAX_CARRIERS] = {}; + uint32_t ul_metrics_count[SRSRAN_MAX_CARRIERS] = {}; + sync_metrics_t sync_metrics[SRSRAN_MAX_CARRIERS] = {}; + uint32_t sync_metrics_count[SRSRAN_MAX_CARRIERS] = {}; // MBSFN bool sib13_configured = false; @@ -318,12 +318,12 @@ private: uint8_t mch_table[40] = {}; uint8_t mcch_table[10] = {}; - bool is_mch_subframe(srslte_mbsfn_cfg_t* cfg, uint32_t phy_tti); + bool is_mch_subframe(srsran_mbsfn_cfg_t* cfg, uint32_t phy_tti); - bool is_mcch_subframe(srslte_mbsfn_cfg_t* cfg, uint32_t phy_tti); + bool is_mcch_subframe(srsran_mbsfn_cfg_t* cfg, uint32_t phy_tti); // NR carriers buffering synchronization, LTE workers are in charge of transmitting - srslte::rf_buffer_t nr_tx_buffer; + srsran::rf_buffer_t nr_tx_buffer; bool nr_tx_buffer_ready = false; }; } // namespace srsue diff --git a/srsue/hdr/phy/phy_metrics.h b/srsue/hdr/phy/phy_metrics.h index 51dd6ff3c..152af9bcf 100644 --- a/srsue/hdr/phy/phy_metrics.h +++ b/srsue/hdr/phy/phy_metrics.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,7 +13,7 @@ #ifndef SRSUE_PHY_METRICS_H #define SRSUE_PHY_METRICS_H -#include "srslte/srslte.h" +#include "srsran/srsran.h" namespace srsue { @@ -52,11 +52,11 @@ struct ul_metrics_t { }; struct phy_metrics_t { - info_metrics_t info[SRSLTE_MAX_CARRIERS]; - sync_metrics_t sync[SRSLTE_MAX_CARRIERS]; - ch_metrics_t ch[SRSLTE_MAX_CARRIERS]; - dl_metrics_t dl[SRSLTE_MAX_CARRIERS]; - ul_metrics_t ul[SRSLTE_MAX_CARRIERS]; + info_metrics_t info[SRSRAN_MAX_CARRIERS]; + sync_metrics_t sync[SRSRAN_MAX_CARRIERS]; + ch_metrics_t ch[SRSRAN_MAX_CARRIERS]; + dl_metrics_t dl[SRSRAN_MAX_CARRIERS]; + ul_metrics_t ul[SRSRAN_MAX_CARRIERS]; uint32_t nof_active_cc; }; diff --git a/srsue/hdr/phy/prach.h b/srsue/hdr/phy/prach.h index a045e52c1..3e2941b81 100644 --- a/srsue/hdr/phy/prach.h +++ b/srsue/hdr/phy/prach.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,10 +13,10 @@ #ifndef SRSUE_PRACH_H #define SRSUE_PRACH_H -#include "srslte/interfaces/ue_phy_interfaces.h" -#include "srslte/radio/radio.h" -#include "srslte/srslog/srslog.h" -#include "srslte/srslte.h" +#include "srsran/interfaces/ue_phy_interfaces.h" +#include "srsran/radio/radio.h" +#include "srsran/srslog/srslog.h" +#include "srsran/srsran.h" #include namespace srsue { @@ -29,7 +29,7 @@ public: void init(uint32_t max_prb); void stop(); - bool set_cell(srslte_cell_t cell, srslte_prach_cfg_t prach_cfg); + bool set_cell(srsran_cell_t cell, srsran_prach_cfg_t prach_cfg); bool prepare_to_send(uint32_t preamble_idx, int allowed_subframe = -1, float target_power_dbm = -1); bool is_ready_to_send(uint32_t current_tti, uint32_t current_pci); bool is_pending() const; @@ -56,10 +56,10 @@ private: static constexpr unsigned max_preambles = 64; srslog::basic_logger& logger; - srslte_prach_t prach_obj = {}; - srslte_cell_t cell = {}; - srslte_cfo_t cfo_h = {}; - srslte_prach_cfg_t cfg = {}; + srsran_prach_t prach_obj = {}; + srsran_cell_t cell = {}; + srsran_cfo_t cfo_h = {}; + srsran_prach_cfg_t cfg = {}; std::array, max_fs> buffer = {}; cf_t* signal_buffer = nullptr; int preamble_idx = -1; diff --git a/srsue/hdr/phy/scell/intra_measure.h b/srsue/hdr/phy/scell/intra_measure.h index 96b2a6e65..cda0204fa 100644 --- a/srsue/hdr/phy/scell/intra_measure.h +++ b/srsue/hdr/phy/scell/intra_measure.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -12,9 +12,9 @@ #ifndef SRSUE_INTRA_MEASURE_H #define SRSUE_INTRA_MEASURE_H -#include -#include -#include +#include +#include +#include #include "scell_recv.h" @@ -22,7 +22,7 @@ namespace srsue { namespace scell { // Class to perform intra-frequency measurements -class intra_measure : public srslte::thread +class intra_measure : public srsran::thread { /* * The intra-cell measurment has 5 different states: @@ -81,7 +81,7 @@ public: * @param earfcn Frequency the component is receiving base-band from. Used only for reporting the EARFCN to the RRC * @param cell Actual cell configuration */ - void set_primary_cell(uint32_t earfcn, srslte_cell_t cell); + void set_primary_cell(uint32_t earfcn, srsran_cell_t cell); /** * Sets receiver gain offset to convert estimated dBFs to dBm in RSRP @@ -197,7 +197,7 @@ private: uint32_t cc_idx = 0; uint32_t current_earfcn = 0; uint32_t current_sflen = 0; - srslte_cell_t serving_cell = {}; + srsran_cell_t serving_cell = {}; std::set active_pci = {}; std::mutex active_pci_mutex = {}; uint32_t last_measure_tti = 0; @@ -207,9 +207,9 @@ private: cf_t* search_buffer = nullptr; - srslte_ringbuffer_t ring_buffer = {}; + srsran_ringbuffer_t ring_buffer = {}; - srslte_refsignal_dl_sync_t refsignal_dl_sync = {}; + srsran_refsignal_dl_sync_t refsignal_dl_sync = {}; }; } // namespace scell diff --git a/srsue/hdr/phy/scell/scell_recv.h b/srsue/hdr/phy/scell/scell_recv.h index 1c2b6a77b..4242c2360 100644 --- a/srsue/hdr/phy/scell/scell_recv.h +++ b/srsue/hdr/phy/scell/scell_recv.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -15,7 +15,7 @@ #include "srsue/hdr/phy/phy_common.h" #include -#include +#include namespace srsue { namespace scell { @@ -29,15 +29,15 @@ public: void init(uint32_t max_sf_window); void deinit(); void reset(); - std::set find_cells(const cf_t* input_buffer, const srslte_cell_t serving_cell, const uint32_t nof_sf); + std::set find_cells(const cf_t* input_buffer, const srsran_cell_t serving_cell, const uint32_t nof_sf); private: // 36.133 9.1.2.1 for band 7 constexpr static float ABSOLUTE_RSRP_THRESHOLD_DBM = -125; - cf_t* sf_buffer[SRSLTE_MAX_PORTS]; + cf_t* sf_buffer[SRSRAN_MAX_PORTS]; srslog::basic_logger& logger; - srslte_sync_t sync_find; + srsran_sync_t sync_find; uint32_t current_fft_sz; }; diff --git a/srsue/hdr/phy/scell/scell_state.h b/srsue/hdr/phy/scell/scell_state.h index cf6a2a5ac..6fe33b913 100644 --- a/srsue/hdr/phy/scell/scell_state.h +++ b/srsue/hdr/phy/scell/scell_state.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,12 +10,12 @@ * */ -#ifndef SRSLTE_SCELL_STATE_H -#define SRSLTE_SCELL_STATE_H +#ifndef SRSRAN_SCELL_STATE_H +#define SRSRAN_SCELL_STATE_H #include #include -#include +#include namespace srsue { namespace scell { @@ -47,7 +47,7 @@ private: enum { none = 0, inactive, active } status = none; }; - std::array scell_cfg; + std::array scell_cfg; enum { idle = 0, waiting, transition } activation_state = idle; uint32_t activation_cmd = 0; @@ -116,7 +116,7 @@ public: if (TTI_SUB(tti, activation_tti) >= activation_margin_tti) { // Reload cell states - for (uint32_t i = 1; i < SRSLTE_MAX_CARRIERS; i++) { + for (uint32_t i = 1; i < SRSRAN_MAX_CARRIERS; i++) { // Get Activation command value bool activate = _get_cmd_activation(i); @@ -137,7 +137,7 @@ public: { std::unique_lock lock(mutex); - if (cc_idx == 0 or cc_idx >= SRSLTE_MAX_CARRIERS) { + if (cc_idx == 0 or cc_idx >= SRSRAN_MAX_CARRIERS) { ERROR("CC IDX %d out-of-range", cc_idx); return; } @@ -154,7 +154,7 @@ public: return true; } - if (cc_idx >= SRSLTE_MAX_CARRIERS) { + if (cc_idx >= SRSRAN_MAX_CARRIERS) { return false; } @@ -176,7 +176,7 @@ public: return true; } - if (cc_idx >= SRSLTE_MAX_CARRIERS) { + if (cc_idx >= SRSRAN_MAX_CARRIERS) { return false; } @@ -202,7 +202,7 @@ public: { std::unique_lock lock(mutex); - if (cc_idx == 0 or cc_idx >= SRSLTE_MAX_CARRIERS) { + if (cc_idx == 0 or cc_idx >= SRSRAN_MAX_CARRIERS) { ERROR("CC IDX %d out-of-range", cc_idx); return 0; } @@ -214,7 +214,7 @@ public: { std::unique_lock lock(mutex); - if (cc_idx == 0 or cc_idx >= SRSLTE_MAX_CARRIERS) { + if (cc_idx == 0 or cc_idx >= SRSRAN_MAX_CARRIERS) { ERROR("CC IDX %d out-of-range", cc_idx); return 0; } @@ -224,4 +224,4 @@ public: }; } // namespace scell } // namespace srsue -#endif // SRSLTE_SCELL_STATE_H \ No newline at end of file +#endif // SRSRAN_SCELL_STATE_H \ No newline at end of file diff --git a/srsue/hdr/phy/scell/scell_sync.h b/srsue/hdr/phy/scell/scell_sync.h index f5a0ceddd..59f677c86 100644 --- a/srsue/hdr/phy/scell/scell_sync.h +++ b/srsue/hdr/phy/scell/scell_sync.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,8 +10,8 @@ * */ -#ifndef SRSLTE_SCELL_SYNC_H -#define SRSLTE_SCELL_SYNC_H +#ifndef SRSRAN_SCELL_SYNC_H +#define SRSRAN_SCELL_SYNC_H namespace srsue { namespace scell { @@ -53,10 +53,10 @@ private: state_t state = STATE_IDLE; sync_callback* callback = nullptr; uint32_t channel = 0; - srslte_sync_t find_pss = {}; + srsran_sync_t find_pss = {}; int32_t sf_len = 0; int32_t cell_id = -1; - std::array temp = {}; + std::array temp = {}; std::mutex mutex; ///< Used for avoiding reconfiguring (set_cell) while it is searching /** @@ -70,18 +70,18 @@ private: // Append new base-band if (buffer == nullptr) { - srslte_vec_cf_zero(&temp[sf_len], sf_len); + srsran_vec_cf_zero(&temp[sf_len], sf_len); } else { - srslte_vec_cf_copy(&temp[sf_len], buffer, sf_len); + srsran_vec_cf_copy(&temp[sf_len], buffer, sf_len); } // Run PSS search - switch (srslte_sync_find(&find_pss, temp.data(), 0, &peak_pos)) { - case SRSLTE_SYNC_FOUND: + switch (srsran_sync_find(&find_pss, temp.data(), 0, &peak_pos)) { + case SRSRAN_SYNC_FOUND: if (callback != nullptr) { // Calculate Sample Offset from TTI difference - int tti_mod = (int)tti % (SRSLTE_NOF_SF_X_FRAME / 2); - int tti_offset = (tti_mod < 3) ? tti_mod : (tti_mod - SRSLTE_NOF_SF_X_FRAME / 2); + int tti_mod = (int)tti % (SRSRAN_NOF_SF_X_FRAME / 2); + int tti_offset = (tti_mod < 3) ? tti_mod : (tti_mod - SRSRAN_NOF_SF_X_FRAME / 2); // Calculate sample offset from PSS correlation peak int offset = (int)(peak_pos - (3 * sf_len) / 2); @@ -91,20 +91,20 @@ private: } state = STATE_IN_SYNCH; break; - case SRSLTE_SYNC_FOUND_NOSPACE: + case SRSRAN_SYNC_FOUND_NOSPACE: ERROR("No space error"); break; - case SRSLTE_SYNC_NOFOUND: + case SRSRAN_SYNC_NOFOUND: // Ignore break; - case SRSLTE_SYNC_ERROR: + case SRSRAN_SYNC_ERROR: ERROR("Error finding PSS"); break; } // If the state has not changed, copy new data into the temp buffer if (state == STATE_SEARCH_PSS) { - srslte_vec_cf_copy(&temp[0], buffer, sf_len); + srsran_vec_cf_copy(&temp[0], buffer, sf_len); } } @@ -113,11 +113,11 @@ private: */ void resize(uint32_t new_nof_prb) { - uint32_t symbol_sz = srslte_symbol_sz(new_nof_prb); - int32_t new_sf_len = SRSLTE_SF_LEN_PRB(new_nof_prb); + uint32_t symbol_sz = srsran_symbol_sz(new_nof_prb); + int32_t new_sf_len = SRSRAN_SF_LEN_PRB(new_nof_prb); // Reset Temporal buffer - srslte_vec_cf_zero(temp.data(), BUFFER_LEN * new_sf_len); + srsran_vec_cf_zero(temp.data(), BUFFER_LEN * new_sf_len); // Skip if no BW is changed if (new_sf_len == sf_len) { @@ -128,7 +128,7 @@ private: // serving cell, the PSS may be located away from the primary serving cell PSS time. The secondary serving cell PSS // could be in the boundary between subframes, so more than a subframe is required to ensure PSS is captured. Two // subframes is a simple and conservative buffer size. - if (srslte_sync_resize(&find_pss, BUFFER_LEN * new_sf_len, BUFFER_LEN * new_sf_len, symbol_sz) != SRSLTE_SUCCESS) { + if (srsran_sync_resize(&find_pss, BUFFER_LEN * new_sf_len, BUFFER_LEN * new_sf_len, symbol_sz) != SRSRAN_SUCCESS) { ERROR("Error setting cell sync find"); } @@ -149,13 +149,13 @@ public: sync(sync_callback* _callback, uint32_t _channel) : callback(_callback), channel(_channel) { // Initialise Find PSS object - if (srslte_sync_init(&find_pss, 2 * SRSLTE_SF_LEN_MAX, 2 * SRSLTE_SF_LEN_MAX, SRSLTE_SYMBOL_SZ_MAX) != - SRSLTE_SUCCESS) { + if (srsran_sync_init(&find_pss, 2 * SRSRAN_SF_LEN_MAX, 2 * SRSRAN_SF_LEN_MAX, SRSRAN_SYMBOL_SZ_MAX) != + SRSRAN_SUCCESS) { ERROR("Initiating Synchronizer"); } } - ~sync() { srslte_sync_free(&find_pss); }; + ~sync() { srsran_sync_free(&find_pss); }; void set_bw(const uint32_t nof_prb) { @@ -172,7 +172,7 @@ public: /** * Sets the cell for the synchronizer */ - void set_cell(const srslte_cell_t& cell) + void set_cell(const srsran_cell_t& cell) { // Protect DSP objects and buffers; As it is called by asynchronous thread, it can wait to finish current processing std::unique_lock lock(mutex); @@ -183,12 +183,12 @@ public: // Configure only if the cell identifier has changed int32_t new_cell_id = cell.id; if (cell_id != new_cell_id) { - srslte_sync_set_frame_type(&find_pss, cell.frame_type); - srslte_sync_set_N_id_2(&find_pss, new_cell_id % SRSLTE_NOF_NID_2); - srslte_sync_set_N_id_1(&find_pss, new_cell_id / SRSLTE_NOF_NID_2); - srslte_sync_set_cfo_ema_alpha(&find_pss, 0.1); - srslte_sync_set_em_alpha(&find_pss, 1); - srslte_sync_set_threshold(&find_pss, 3.0); + srsran_sync_set_frame_type(&find_pss, cell.frame_type); + srsran_sync_set_N_id_2(&find_pss, new_cell_id % SRSRAN_NOF_NID_2); + srsran_sync_set_N_id_1(&find_pss, new_cell_id / SRSRAN_NOF_NID_2); + srsran_sync_set_cfo_ema_alpha(&find_pss, 0.1); + srsran_sync_set_em_alpha(&find_pss, 1); + srsran_sync_set_threshold(&find_pss, 3.0); cell_id = new_cell_id; } @@ -238,4 +238,4 @@ public: }; } // namespace scell } // namespace srsue -#endif // SRSLTE_SCELL_SYNC_H +#endif // SRSRAN_SCELL_SYNC_H diff --git a/srsue/hdr/phy/search.h b/srsue/hdr/phy/search.h index d4aec79bf..57271a938 100644 --- a/srsue/hdr/phy/search.h +++ b/srsue/hdr/phy/search.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,18 +13,18 @@ #ifndef SRSUE_SEARCH_H #define SRSUE_SEARCH_H -#include "srslte/radio/radio.h" -#include "srslte/srslog/srslog.h" -#include "srslte/srslte.h" +#include "srsran/radio/radio.h" +#include "srsran/srslog/srslog.h" +#include "srsran/srsran.h" namespace srsue { class search_callback { public: - virtual int radio_recv_fnc(srslte::rf_buffer_t&, srslte_timestamp_t* rx_time) = 0; - virtual void set_ue_sync_opts(srslte_ue_sync_t* q, float cfo) = 0; - virtual srslte::radio_interface_phy* get_radio() = 0; + virtual int radio_recv_fnc(srsran::rf_buffer_t&, srsran_timestamp_t* rx_time) = 0; + virtual void set_ue_sync_opts(srsran_ue_sync_t* q, float cfo) = 0; + virtual srsran::radio_interface_phy* get_radio() = 0; virtual void set_rx_gain(float gain) = 0; }; @@ -36,18 +36,18 @@ public: explicit search(srslog::basic_logger& logger) : logger(logger) {} ~search(); - void init(srslte::rf_buffer_t& buffer_, uint32_t nof_rx_channels, search_callback* parent); + void init(srsran::rf_buffer_t& buffer_, uint32_t nof_rx_channels, search_callback* parent); void reset(); float get_last_cfo(); void set_agc_enable(bool enable); - ret_code run(srslte_cell_t* cell, std::array& bch_payload); + ret_code run(srsran_cell_t* cell, std::array& bch_payload); private: search_callback* p = nullptr; srslog::basic_logger& logger; - srslte::rf_buffer_t buffer = {}; - srslte_ue_cellsearch_t cs = {}; - srslte_ue_mib_sync_t ue_mib_sync = {}; + srsran::rf_buffer_t buffer = {}; + srsran_ue_cellsearch_t cs = {}; + srsran_ue_mib_sync_t ue_mib_sync = {}; int force_N_id_2 = 0; }; diff --git a/srsue/hdr/phy/sfn_sync.h b/srsue/hdr/phy/sfn_sync.h index 884ccbe13..f26dc3f72 100644 --- a/srsue/hdr/phy/sfn_sync.h +++ b/srsue/hdr/phy/sfn_sync.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,9 +13,9 @@ #ifndef SRSUE_SFN_SYNC_H #define SRSUE_SFN_SYNC_H -#include "srslte/radio/radio.h" -#include "srslte/srslog/srslog.h" -#include "srslte/srslte.h" +#include "srsran/radio/radio.h" +#include "srsran/srslog/srslog.h" +#include "srsran/srsran.h" namespace srsue { @@ -28,21 +28,21 @@ public: typedef enum { IDLE, SFN_FOUND, SFX0_FOUND, SFN_NOFOUND, ERROR } ret_code; explicit sfn_sync(srslog::basic_logger& logger) : logger(logger) {} ~sfn_sync(); - void init(srslte_ue_sync_t* ue_sync, + void init(srsran_ue_sync_t* ue_sync, const phy_args_t* phy_args_, - srslte::rf_buffer_t& buffer, + srsran::rf_buffer_t& buffer, uint32_t buffer_max_samples_, uint32_t nof_subframes = SFN_SYNC_NOF_SUBFRAMES); void reset(); - bool set_cell(srslte_cell_t cell); - ret_code run_subframe(srslte_cell_t* cell, + bool set_cell(srsran_cell_t cell); + ret_code run_subframe(srsran_cell_t* cell, uint32_t* tti_cnt, - std::array& bch_payload, + std::array& bch_payload, bool sfidx_only = false); - ret_code decode_mib(srslte_cell_t* cell, + ret_code decode_mib(srsran_cell_t* cell, uint32_t* tti_cnt, - srslte::rf_buffer_t* ext_buffer, - std::array& bch_payload, + srsran::rf_buffer_t* ext_buffer, + std::array& bch_payload, bool sfidx_only = false); private: @@ -52,10 +52,10 @@ private: uint32_t cnt = 0; uint32_t timeout = 0; srslog::basic_logger& logger; - srslte_ue_sync_t* ue_sync = nullptr; - srslte::rf_buffer_t mib_buffer = {}; + srsran_ue_sync_t* ue_sync = nullptr; + srsran::rf_buffer_t mib_buffer = {}; uint32_t buffer_max_samples = 0; - srslte_ue_mib_t ue_mib = {}; + srsran_ue_mib_t ue_mib = {}; }; }; // namespace srsue diff --git a/srsue/hdr/phy/sync.h b/srsue/hdr/phy/sync.h index 7367570ab..93e2f7a1e 100644 --- a/srsue/hdr/phy/sync.h +++ b/srsue/hdr/phy/sync.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -24,12 +24,12 @@ #include "scell/scell_sync.h" #include "search.h" #include "sfn_sync.h" -#include "srslte/common/thread_pool.h" -#include "srslte/common/threads.h" -#include "srslte/common/tti_sync_cv.h" -#include "srslte/interfaces/radio_interfaces.h" -#include "srslte/phy/channel/channel.h" -#include "srslte/srslte.h" +#include "srsran/common/thread_pool.h" +#include "srsran/common/threads.h" +#include "srsran/common/tti_sync_cv.h" +#include "srsran/interfaces/radio_interfaces.h" +#include "srsran/phy/channel/channel.h" +#include "srsran/srsran.h" #include "srsue/hdr/phy/lte/worker_pool.h" #include "srsue/hdr/phy/nr/worker_pool.h" #include "sync_state.h" @@ -38,7 +38,7 @@ namespace srsue { typedef _Complex float cf_t; -class sync : public srslte::thread, +class sync : public srsran::thread, public rsrp_insync_itf, public search_callback, public scell::sync_callback, @@ -55,7 +55,7 @@ public: dummy_buffer(sync_nof_rx_subframes){}; ~sync(); - void init(srslte::radio_interface_phy* radio_, + void init(srsran::radio_interface_phy* radio_, stack_interface_phy_lte* _stack, prach* prach_buffer, lte::worker_pool* _lte_workers_pool, @@ -75,7 +75,7 @@ public: // RRC interface for controlling the neighbour cell measurement void set_cells_to_meas(uint32_t earfcn, const std::set& pci); - void set_inter_frequency_measurement(uint32_t cc_idx, uint32_t earfcn_, srslte_cell_t cell_); + void set_inter_frequency_measurement(uint32_t cc_idx, uint32_t earfcn_, srsran_cell_t cell_); void meas_stop(); // from chest_feedback_itf @@ -83,7 +83,7 @@ public: void out_of_sync() final; void set_cfo(float cfo) final; - void get_current_cell(srslte_cell_t* cell, uint32_t* earfcn = nullptr); + void get_current_cell(srsran_cell_t* cell, uint32_t* earfcn = nullptr); uint32_t get_current_tti(); // From UE configuration @@ -92,16 +92,16 @@ public: // Other functions void set_rx_gain(float gain) override; - int radio_recv_fnc(srslte::rf_buffer_t&, srslte_timestamp_t* rx_time) override; + int radio_recv_fnc(srsran::rf_buffer_t&, srsran_timestamp_t* rx_time) override; - srslte::radio_interface_phy* get_radio() override { return radio_h; } + srsran::radio_interface_phy* get_radio() override { return radio_h; } /** * Sets secondary serving cell for synchronization purposes * @param cc_idx component carrier index * @param _cell Cell information */ - void scell_sync_set(uint32_t cc_idx, const srslte_cell_t& _cell); + void scell_sync_set(uint32_t cc_idx, const srsran_cell_t& _cell); /** * Stops all secondary serving cell synchronization @@ -122,7 +122,7 @@ public: private: void reset(); void radio_error(); - void set_ue_sync_opts(srslte_ue_sync_t* q, float cfo) override; + void set_ue_sync_opts(srsran_ue_sync_t* q, float cfo) override; /** * Search for a cell in the current frequency and go to IDLE. @@ -171,7 +171,7 @@ private: * @param sync_buffer Sub-frame buffer for the current TTI */ void - run_camping_in_sync_state(lte::sf_worker* lte_worker, nr::sf_worker* nr_worker, srslte::rf_buffer_t& sync_buffer); + run_camping_in_sync_state(lte::sf_worker* lte_worker, nr::sf_worker* nr_worker, srsran::rf_buffer_t& sync_buffer); /** * Helper method, executed in a TTI basis for signaling to the stack a new TTI execution @@ -192,7 +192,7 @@ private: bool running = false; bool is_overflow = false; - srslte::rf_timestamp_t last_rx_time; + srsran::rf_timestamp_t last_rx_time; bool forced_rx_time_init = true; // Rx time sync after first receive from radio // Objects for internal use @@ -206,10 +206,10 @@ private: srslog::basic_logger& phy_lib_logger; lte::worker_pool* lte_worker_pool = nullptr; nr::worker_pool* nr_worker_pool = nullptr; - srslte::radio_interface_phy* radio_h = nullptr; + srsran::radio_interface_phy* radio_h = nullptr; phy_common* worker_com = nullptr; prach* prach_buffer = nullptr; - srslte::channel_ptr channel_emulator = nullptr; + srsran::channel_ptr channel_emulator = nullptr; // PRACH state uint32_t prach_nof_sf = 0; @@ -218,15 +218,15 @@ private: float prach_power = 0; // Object for synchronization of the primary cell - srslte_ue_sync_t ue_sync = {}; + srsran_ue_sync_t ue_sync = {}; // Object for synchronization secondary serving cells std::map > scell_sync; // Buffer for primary and secondary cell samples const static uint32_t sync_nof_rx_subframes = 5; - srslte::rf_buffer_t sf_buffer = {}; - srslte::rf_buffer_t dummy_buffer; + srsran::rf_buffer_t sf_buffer = {}; + srsran::rf_buffer_t dummy_buffer; // Sync metrics sync_metrics_t metrics = {}; @@ -253,12 +253,12 @@ private: float current_srate = 0; // This is the primary cell - srslte_cell_t cell = {}; + srsran_cell_t cell = {}; bool force_camping_sfn_sync = false; uint32_t tti = 0; - srslte_timestamp_t stack_tti_ts_new = {}; - srslte_timestamp_t stack_tti_ts = {}; - std::array mib = {}; + srsran_timestamp_t stack_tti_ts_new = {}; + srsran_timestamp_t stack_tti_ts = {}; + std::array mib = {}; uint32_t nof_rf_channels = 0; float ul_dl_factor = NAN; diff --git a/srsue/hdr/phy/sync_state.h b/srsue/hdr/phy/sync_state.h index 8df45ac6d..af9d7c0c3 100644 --- a/srsue/hdr/phy/sync_state.h +++ b/srsue/hdr/phy/sync_state.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/srsue/hdr/phy/ta_control.h b/srsue/hdr/phy/ta_control.h index 21a7b67ff..a1891bbcf 100644 --- a/srsue/hdr/phy/ta_control.h +++ b/srsue/hdr/phy/ta_control.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -15,7 +15,7 @@ #include #include -#include +#include namespace srsue { @@ -66,7 +66,7 @@ public: next_base_sec = ta_base_sec; // Update base in nta - next_base_nta = static_cast(roundf(next_base_sec / SRSLTE_LTE_TS)); + next_base_nta = static_cast(roundf(next_base_sec / SRSRAN_LTE_TS)); // Reset speed data reset_speed_data(); @@ -87,7 +87,7 @@ public: next_base_sec += ta_delta_sec; // Update base in nta - next_base_nta = static_cast(roundf(next_base_sec / SRSLTE_LTE_TS)); + next_base_nta = static_cast(roundf(next_base_sec / SRSRAN_LTE_TS)); logger.info("PHY: Set TA: ta_delta_usec: %.1f, n_ta: %d, ta_usec: %.1f", ta_delta_sec * 1e6f, @@ -105,10 +105,10 @@ public: std::lock_guard lock(mutex); // Update base nta - next_base_nta += srslte_N_ta_new_rar(ta_cmd); + next_base_nta += srsran_N_ta_new_rar(ta_cmd); // Update base in seconds - next_base_sec = static_cast(next_base_nta) * SRSLTE_LTE_TS; + next_base_sec = static_cast(next_base_nta) * SRSRAN_LTE_TS; // Reset speed data reset_speed_data(); @@ -128,10 +128,10 @@ public: float prev_base_sec = next_base_sec; // Update base nta - next_base_nta = srslte_N_ta_new(next_base_nta, ta_cmd); + next_base_nta = srsran_N_ta_new(next_base_nta, ta_cmd); // Update base in seconds - next_base_sec = static_cast(next_base_nta) * SRSLTE_LTE_TS; + next_base_sec = static_cast(next_base_nta) * SRSRAN_LTE_TS; logger.info("PHY: Set TA: ta_cmd: %d, n_ta: %d, ta_usec: %.1f", ta_cmd, next_base_nta, next_base_sec * 1e6f); diff --git a/srsue/hdr/phy/ue_lte_phy_base.h b/srsue/hdr/phy/ue_lte_phy_base.h index 5f8c63888..b31626ecc 100644 --- a/srsue/hdr/phy/ue_lte_phy_base.h +++ b/srsue/hdr/phy/ue_lte_phy_base.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -18,14 +18,14 @@ #ifndef SRSUE_UE_LTE_PHY_BASE_H #define SRSUE_UE_LTE_PHY_BASE_H -#include "srslte/interfaces/radio_interfaces.h" +#include "srsran/interfaces/radio_interfaces.h" #include "srsue/hdr/phy/ue_phy_base.h" namespace srsue { class stack_interface_phy_lte; -class ue_lte_phy_base : public ue_phy_base, public phy_interface_stack_lte, public srslte::phy_interface_radio +class ue_lte_phy_base : public ue_phy_base, public phy_interface_stack_lte, public srsran::phy_interface_radio { public: ue_lte_phy_base(){}; @@ -34,7 +34,7 @@ public: virtual std::string get_type() = 0; virtual int init(const phy_args_t& args_) = 0; - virtual int init(const phy_args_t& args_, stack_interface_phy_lte* stack_, srslte::radio_interface_phy* radio_) = 0; + virtual int init(const phy_args_t& args_, stack_interface_phy_lte* stack_, srsran::radio_interface_phy* radio_) = 0; virtual void stop() = 0; virtual void wait_initialize() = 0; diff --git a/srsue/hdr/phy/ue_nr_phy_base.h b/srsue/hdr/phy/ue_nr_phy_base.h index 37fb7ce56..aacc658bb 100644 --- a/srsue/hdr/phy/ue_nr_phy_base.h +++ b/srsue/hdr/phy/ue_nr_phy_base.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -18,8 +18,8 @@ #ifndef SRSUE_UE_NR_PHY_BASE_H #define SRSUE_UE_NR_PHY_BASE_H -#include "srslte/interfaces/radio_interfaces.h" -#include "srslte/interfaces/ue_nr_interfaces.h" +#include "srsran/interfaces/radio_interfaces.h" +#include "srsran/interfaces/ue_nr_interfaces.h" #include "srsue/hdr/phy/ue_phy_base.h" namespace srsue { @@ -33,7 +33,7 @@ public: virtual std::string get_type() = 0; virtual int init(const phy_args_t& args_) = 0; - virtual int init(const phy_args_nr_t& args_, stack_interface_phy_nr* stack_, srslte::radio_interface_phy* radio_) = 0; + virtual int init(const phy_args_nr_t& args_, stack_interface_phy_nr* stack_, srsran::radio_interface_phy* radio_) = 0; virtual void stop() = 0; virtual void set_earfcn(std::vector earfcns) = 0; diff --git a/srsue/hdr/phy/ue_phy_base.h b/srsue/hdr/phy/ue_phy_base.h index 474477263..56d0aeefc 100644 --- a/srsue/hdr/phy/ue_phy_base.h +++ b/srsue/hdr/phy/ue_phy_base.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -18,7 +18,7 @@ #ifndef SRSUE_UE_PHY_BASE_H #define SRSUE_UE_PHY_BASE_H -#include "srslte/interfaces/ue_phy_interfaces.h" +#include "srsran/interfaces/ue_phy_interfaces.h" #include "srsue/hdr/phy/phy_metrics.h" namespace srsue { diff --git a/srsue/hdr/phy/vnf_phy_nr.h b/srsue/hdr/phy/vnf_phy_nr.h index ff3638b0d..c81f667f4 100644 --- a/srsue/hdr/phy/vnf_phy_nr.h +++ b/srsue/hdr/phy/vnf_phy_nr.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -14,11 +14,11 @@ #define SRSUE_VNF_PHY_NR_H #include "srsenb/hdr/phy/phy_common.h" -#include "srslte/common/basic_vnf.h" -#include "srslte/interfaces/enb_metrics_interface.h" -#include "srslte/interfaces/radio_interfaces.h" -#include "srslte/interfaces/ue_interfaces.h" -#include "srslte/interfaces/ue_nr_interfaces.h" +#include "srsran/common/basic_vnf.h" +#include "srsran/interfaces/enb_metrics_interface.h" +#include "srsran/interfaces/radio_interfaces.h" +#include "srsran/interfaces/ue_interfaces.h" +#include "srsran/interfaces/ue_nr_interfaces.h" #include "srsue/hdr/phy/ue_nr_phy_base.h" namespace srsue { @@ -45,13 +45,13 @@ public: void start_plot() override; // RRC interface - bool set_config(const srslte::phy_cfg_nr_t& cfg) override; + bool set_config(const srsran::phy_cfg_nr_t& cfg) override; // MAC interface int tx_request(const tx_request_t& request) override; - int set_ul_grant(std::array, uint16_t rnti, srslte_rnti_type_t rnti_type) override + int set_ul_grant(std::array, uint16_t rnti, srsran_rnti_type_t rnti_type) override { - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; }; void send_prach(const uint32_t preamble_idx, const int prach_occasion, @@ -60,7 +60,7 @@ public: void sr_send(uint32_t sr_id) override; private: - std::unique_ptr vnf; + std::unique_ptr vnf; srsue::stack_interface_phy_nr* stack = nullptr; diff --git a/srsue/hdr/stack/mac/demux.h b/srsue/hdr/stack/mac/demux.h index 4e4b9f9cc..313e8d9fa 100644 --- a/srsue/hdr/stack/mac/demux.h +++ b/srsue/hdr/stack/mac/demux.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,12 +13,12 @@ #ifndef SRSUE_DEMUX_H #define SRSUE_DEMUX_H -#include "srslte/common/timers.h" -#include "srslte/interfaces/ue_mac_interfaces.h" -#include "srslte/interfaces/ue_rlc_interfaces.h" -#include "srslte/mac/pdu.h" -#include "srslte/mac/pdu_queue.h" -#include "srslte/srslog/srslog.h" +#include "srsran/common/timers.h" +#include "srsran/interfaces/ue_mac_interfaces.h" +#include "srsran/interfaces/ue_rlc_interfaces.h" +#include "srsran/mac/pdu.h" +#include "srsran/mac/pdu_queue.h" +#include "srsran/srslog/srslog.h" /* Logical Channel Demultiplexing and MAC CE dissassemble */ @@ -34,14 +34,14 @@ public: virtual bool contention_resolution_id_rcv(uint64_t id) = 0; }; -class demux : public srslte::pdu_queue::process_callback +class demux : public srsran::pdu_queue::process_callback { public: explicit demux(srslog::basic_logger& logger); void init(phy_interface_mac_common* phy_h_, rlc_interface_mac* rlc, mac_interface_demux* mac, - srslte::timer_handler::unique_timer* time_alignment_timer); + srsran::timer_handler::unique_timer* time_alignment_timer); void reset(); bool process_pdus(); @@ -56,7 +56,7 @@ public: bool get_uecrid_successful(); - void process_pdu(uint8_t* pdu, uint32_t nof_bytes, srslte::pdu_queue::channel_t channel); + void process_pdu(uint8_t* pdu, uint32_t nof_bytes, srsran::pdu_queue::channel_t channel); void mch_start_rx(uint32_t lcid); private: @@ -70,22 +70,22 @@ private: rlc_interface_mac* rlc = nullptr; mac_interface_demux* mac = nullptr; - srslte::sch_pdu mac_msg; - srslte::mch_pdu mch_mac_msg; - srslte::sch_pdu pending_mac_msg; - uint8_t mch_lcids[SRSLTE_N_MCH_LCIDS] = {}; + srsran::sch_pdu mac_msg; + srsran::mch_pdu mch_mac_msg; + srsran::sch_pdu pending_mac_msg; + uint8_t mch_lcids[SRSRAN_N_MCH_LCIDS] = {}; void process_sch_pdu_rt(uint8_t* buff, uint32_t nof_bytes, uint32_t tti); - void process_sch_pdu(srslte::sch_pdu* pdu); - void process_mch_pdu(srslte::mch_pdu* pdu); - bool process_ce(srslte::sch_subh* subheader, uint32_t tti); - void parse_ta_cmd(srslte::sch_subh* subh, uint32_t tti); + void process_sch_pdu(srsran::sch_pdu* pdu); + void process_mch_pdu(srsran::mch_pdu* pdu); + bool process_ce(srsran::sch_subh* subheader, uint32_t tti); + void parse_ta_cmd(srsran::sch_subh* subh, uint32_t tti); bool is_uecrid_successful = false; - srslte::timer_handler::unique_timer* time_alignment_timer = nullptr; + srsran::timer_handler::unique_timer* time_alignment_timer = nullptr; // Buffer of PDUs - srslte::pdu_queue pdus; + srsran::pdu_queue pdus; }; } // namespace srsue diff --git a/srsue/hdr/stack/mac/dl_harq.h b/srsue/hdr/stack/mac/dl_harq.h index fe942a632..6741d0b68 100644 --- a/srsue/hdr/stack/mac/dl_harq.h +++ b/srsue/hdr/stack/mac/dl_harq.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -15,8 +15,8 @@ #include "demux.h" #include "dl_sps.h" -#include "srslte/common/mac_pcap.h" -#include "srslte/common/timers.h" +#include "srsran/common/mac_pcap.h" +#include "srsran/common/timers.h" /* Downlink HARQ entity as defined in 5.3.2 of 36.321 */ @@ -29,11 +29,11 @@ public: bool init(mac_interface_rrc::ue_rnti_t* rntis, demux* demux_unit); void reset(); - void start_pcap(srslte::mac_pcap* pcap_); + void start_pcap(srsran::mac_pcap* pcap_); /***************** PHY->MAC interface for DL processes **************************/ void new_grant_dl(mac_interface_phy_lte::mac_grant_dl_t grant, mac_interface_phy_lte::tb_action_dl_t* action); - void tb_decoded(mac_interface_phy_lte::mac_grant_dl_t grant, bool ack[SRSLTE_MAX_CODEWORDS]); + void tb_decoded(mac_interface_phy_lte::mac_grant_dl_t grant, bool ack[SRSRAN_MAX_CODEWORDS]); void set_si_window_start(int si_window_start); @@ -49,7 +49,7 @@ private: void reset_ndi(); void new_grant_dl(mac_interface_phy_lte::mac_grant_dl_t grant, mac_interface_phy_lte::tb_action_dl_t* action); - void tb_decoded(mac_interface_phy_lte::mac_grant_dl_t grant, bool ack[SRSLTE_MAX_CODEWORDS]); + void tb_decoded(mac_interface_phy_lte::mac_grant_dl_t grant, bool ack[SRSRAN_MAX_CODEWORDS]); bool is_sps(); @@ -91,7 +91,7 @@ private: uint32_t n_retx; mac_interface_phy_lte::mac_grant_dl_t cur_grant; - srslte_softbuffer_rx_t softbuffer; + srsran_softbuffer_rx_t softbuffer; }; /* Transport blocks */ @@ -108,7 +108,7 @@ private: dl_harq_process bcch_proc; demux* demux_unit = nullptr; srslog::basic_logger& logger; - srslte::mac_pcap* pcap = nullptr; + srsran::mac_pcap* pcap = nullptr; mac_interface_rrc::ue_rnti_t* rntis = nullptr; uint16_t last_temporal_crnti = 0; int si_window_start = 0; @@ -119,7 +119,7 @@ private: }; typedef std::unique_ptr dl_harq_entity_ptr; -typedef std::array dl_harq_entity_vector; +typedef std::array dl_harq_entity_vector; } // namespace srsue diff --git a/srsue/hdr/stack/mac/dl_sps.h b/srsue/hdr/stack/mac/dl_sps.h index 0416cc147..a1ac27335 100644 --- a/srsue/hdr/stack/mac/dl_sps.h +++ b/srsue/hdr/stack/mac/dl_sps.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,7 +13,7 @@ #ifndef SRSUE_DL_SPS_H #define SRSUE_DL_SPS_H -#include "srslte/common/timers.h" +#include "srsran/common/timers.h" /* Downlink Semi-Persistent schedulign (Section 5.10.1) */ diff --git a/srsue/hdr/stack/mac/mac.h b/srsue/hdr/stack/mac/mac.h index 11a99ca26..044e5a478 100644 --- a/srsue/hdr/stack/mac/mac.h +++ b/srsue/hdr/stack/mac/mac.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -21,12 +21,12 @@ #include "proc_phr.h" #include "proc_ra.h" #include "proc_sr.h" -#include "srslte/common/mac_pcap.h" -#include "srslte/common/threads.h" -#include "srslte/common/timers.h" -#include "srslte/common/tti_sync_cv.h" -#include "srslte/interfaces/ue_rrc_interfaces.h" -#include "srslte/srslog/srslog.h" +#include "srsran/common/mac_pcap.h" +#include "srsran/common/threads.h" +#include "srsran/common/timers.h" +#include "srsran/common/tti_sync_cv.h" +#include "srsran/interfaces/ue_rrc_interfaces.h" +#include "srsran/srslog/srslog.h" #include "ul_harq.h" #include #include @@ -35,7 +35,7 @@ namespace srsue { class mac : public mac_interface_phy_lte, public mac_interface_rrc, - public srslte::timer_callback, + public srsran::timer_callback, public mac_interface_demux { public: @@ -44,14 +44,14 @@ public: bool init(phy_interface_mac_lte* phy, rlc_interface_mac* rlc, rrc_interface_mac* rrc); void stop(); - void get_metrics(mac_metrics_t m[SRSLTE_MAX_CARRIERS]); + void get_metrics(mac_metrics_t m[SRSRAN_MAX_CARRIERS]); /******** Interface from PHY (PHY -> MAC) ****************/ /* see mac_interface.h for comments */ void new_grant_ul(uint32_t cc_idx, mac_grant_ul_t grant, tb_action_ul_t* action); void new_grant_dl(uint32_t cc_idx, mac_grant_dl_t grant, tb_action_dl_t* action); - void new_mch_dl(const srslte_pdsch_grant_t& phy_grant, tb_action_dl_t* action); - void tb_decoded(uint32_t cc_idx, mac_grant_dl_t grant, bool ack[SRSLTE_MAX_CODEWORDS]); + void new_mch_dl(const srsran_pdsch_grant_t& phy_grant, tb_action_dl_t* action); + void tb_decoded(uint32_t cc_idx, mac_grant_dl_t grant, bool ack[SRSRAN_MAX_CODEWORDS]); void bch_decoded_ok(uint32_t cc_idx, uint8_t* payload, uint32_t len); uint16_t get_dl_sched_rnti(uint32_t tti); uint16_t get_ul_sched_rnti(uint32_t tti); @@ -90,7 +90,7 @@ public: /*********** interface for stack ******************/ void process_pdus(); - void start_pcap(srslte::mac_pcap* pcap); + void start_pcap(srsran::mac_pcap* pcap); // Timer callback interface void timer_expired(uint32_t timer_id); @@ -106,7 +106,7 @@ private: phy_interface_mac_lte* phy_h = nullptr; rlc_interface_mac* rlc_h = nullptr; rrc_interface_mac* rrc_h = nullptr; - srslte::ext_task_sched_handle task_sched; + srsran::ext_task_sched_handle task_sched; srslog::basic_logger& logger; mac_interface_phy_lte::mac_phy_cfg_mbsfn_t phy_mbsfn_cfg = {}; @@ -135,28 +135,28 @@ private: /* Buffers for PCH reception (not included in DL HARQ) */ const static uint32_t pch_payload_buffer_sz = 8 * 1024; - srslte_softbuffer_rx_t pch_softbuffer; + srsran_softbuffer_rx_t pch_softbuffer; uint8_t pch_payload_buffer[pch_payload_buffer_sz]; /* Buffers for MCH reception (not included in DL HARQ) */ - const static uint32_t mch_payload_buffer_sz = SRSLTE_MAX_BUFFER_SIZE_BYTES; - srslte_softbuffer_rx_t mch_softbuffer; + const static uint32_t mch_payload_buffer_sz = SRSRAN_MAX_BUFFER_SIZE_BYTES; + srsran_softbuffer_rx_t mch_softbuffer; uint8_t mch_payload_buffer[mch_payload_buffer_sz]; - srslte::mch_pdu mch_msg; + srsran::mch_pdu mch_msg; /* Functions for MAC Timers */ - srslte::timer_handler::unique_timer timer_alignment; + srsran::timer_handler::unique_timer timer_alignment; void setup_timers(int time_alignment_timer); void timer_alignment_expire(); /* Queue to dispatch stack tasks */ - srslte::task_multiqueue::queue_handle stack_task_dispatch_queue; + srsran::task_multiqueue::queue_handle stack_task_dispatch_queue; // pointer to MAC PCAP object - srslte::mac_pcap* pcap = nullptr; + srsran::mac_pcap* pcap = nullptr; bool is_first_ul_grant = false; - mac_metrics_t metrics[SRSLTE_MAX_CARRIERS] = {}; + mac_metrics_t metrics[SRSRAN_MAX_CARRIERS] = {}; bool initialized = false; diff --git a/srsue/hdr/stack/mac/mac_metrics.h b/srsue/hdr/stack/mac/mac_metrics.h index a33330160..0cfba0257 100644 --- a/srsue/hdr/stack/mac/mac_metrics.h +++ b/srsue/hdr/stack/mac/mac_metrics.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/srsue/hdr/stack/mac/mux.h b/srsue/hdr/stack/mac/mux.h index e9ef07690..fa4bc25d9 100644 --- a/srsue/hdr/stack/mac/mux.h +++ b/srsue/hdr/stack/mac/mux.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -19,10 +19,10 @@ #include "proc_bsr.h" #include "proc_phr.h" -#include "srslte/common/common.h" -#include "srslte/interfaces/mac_interface_types.h" -#include "srslte/mac/pdu.h" -#include "srslte/srslog/srslog.h" +#include "srsran/common/common.h" +#include "srsran/interfaces/mac_interface_types.h" +#include "srsran/mac/pdu.h" +#include "srsran/srslog/srslog.h" #include namespace srsue { @@ -40,8 +40,8 @@ public: bool is_pending_any_sdu(); bool is_pending_sdu(uint32_t lcid); - uint8_t* pdu_get(srslte::byte_buffer_t* payload, uint32_t pdu_sz); - uint8_t* msg3_get(srslte::byte_buffer_t* payload, uint32_t pdu_sz); + uint8_t* pdu_get(srsran::byte_buffer_t* payload, uint32_t pdu_sz); + uint8_t* msg3_get(srsran::byte_buffer_t* payload, uint32_t pdu_sz); void msg3_flush(); bool msg3_is_transmitted(); @@ -51,19 +51,19 @@ public: void append_crnti_ce_next_tx(uint16_t crnti); - void setup_lcid(const srslte::logical_channel_config_t& config); + void setup_lcid(const srsran::logical_channel_config_t& config); void print_logical_channel_state(const std::string& info); private: bool has_logical_channel(const uint32_t& lcid); bool pdu_move_to_msg3(uint32_t pdu_sz); - uint32_t allocate_sdu(uint32_t lcid, srslte::sch_pdu* pdu, int max_sdu_sz); - bool sched_sdu(srslte::logical_channel_config_t* ch, int* sdu_space, int max_sdu_sz); + uint32_t allocate_sdu(uint32_t lcid, srsran::sch_pdu* pdu, int max_sdu_sz); + bool sched_sdu(srsran::logical_channel_config_t* ch, int* sdu_space, int max_sdu_sz); const static int MAX_NOF_SUBHEADERS = 20; - std::vector logical_channels; + std::vector logical_channels; // Mutex for exclusive access std::mutex mutex; @@ -75,12 +75,12 @@ private: uint16_t pending_crnti_ce = 0; /* Msg3 Buffer */ - srslte::byte_buffer_t msg_buff; + srsran::byte_buffer_t msg_buff; /* PDU Buffer */ - srslte::sch_pdu pdu_msg; + srsran::sch_pdu pdu_msg; - srslte::byte_buffer_t msg3_buff; + srsran::byte_buffer_t msg3_buff; bool msg3_has_been_transmitted = false; bool msg3_pending = false; }; diff --git a/srsue/hdr/stack/mac/proc.h b/srsue/hdr/stack/mac/proc.h index b64407c23..b6ef56ba3 100644 --- a/srsue/hdr/stack/mac/proc.h +++ b/srsue/hdr/stack/mac/proc.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/srsue/hdr/stack/mac/proc_bsr.h b/srsue/hdr/stack/mac/proc_bsr.h index 55aa1b375..f574ad454 100644 --- a/srsue/hdr/stack/mac/proc_bsr.h +++ b/srsue/hdr/stack/mac/proc_bsr.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -17,8 +17,8 @@ #include #include "proc_sr.h" -#include "srslte/common/task_scheduler.h" -#include "srslte/srslog/srslog.h" +#include "srsran/common/task_scheduler.h" +#include "srsran/srslog/srslog.h" /* Buffer status report procedure */ @@ -47,14 +47,14 @@ public: virtual void update_bsr_tti_end(const bsr_t* bsr) = 0; }; -class bsr_proc : public srslte::timer_callback, public bsr_interface_mux +class bsr_proc : public srsran::timer_callback, public bsr_interface_mux { public: explicit bsr_proc(srslog::basic_logger& logger) : logger(logger) {} - void init(sr_proc* sr_proc, rlc_interface_mac* rlc, srslte::ext_task_sched_handle* task_sched_); + void init(sr_proc* sr_proc, rlc_interface_mac* rlc, srsran::ext_task_sched_handle* task_sched_); void step(uint32_t tti); void reset(); - void set_config(srslte::bsr_cfg_t& bsr_cfg); + void set_config(srsran::bsr_cfg_t& bsr_cfg); void setup_lcid(uint32_t lcid, uint32_t lcg, uint32_t priority); void timer_expired(uint32_t timer_id); @@ -68,12 +68,12 @@ private: std::mutex mutex; - srslte::ext_task_sched_handle* task_sched = nullptr; + srsran::ext_task_sched_handle* task_sched = nullptr; srslog::basic_logger& logger; rlc_interface_mac* rlc = nullptr; sr_proc* sr = nullptr; - srslte::bsr_cfg_t bsr_cfg; + srsran::bsr_cfg_t bsr_cfg; bool initiated = false; @@ -103,9 +103,9 @@ private: char* bsr_type_tostring(triggered_bsr_type_t type); char* bsr_format_tostring(bsr_format_t format); - srslte::timer_handler::unique_timer timer_periodic; - srslte::timer_handler::unique_timer timer_retx; - srslte::timer_handler::unique_timer timer_queue_status_print; + srsran::timer_handler::unique_timer timer_periodic; + srsran::timer_handler::unique_timer timer_retx; + srsran::timer_handler::unique_timer timer_queue_status_print; }; } // namespace srsue diff --git a/srsue/hdr/stack/mac/proc_phr.h b/srsue/hdr/stack/mac/proc_phr.h index c03625d00..792b40fe2 100644 --- a/srsue/hdr/stack/mac/proc_phr.h +++ b/srsue/hdr/stack/mac/proc_phr.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,9 +13,9 @@ #ifndef SRSUE_PROC_PHR_H #define SRSUE_PROC_PHR_H -#include "srslte/common/task_scheduler.h" -#include "srslte/interfaces/ue_mac_interfaces.h" -#include "srslte/srslog/srslog.h" +#include "srsran/common/task_scheduler.h" +#include "srsran/interfaces/ue_mac_interfaces.h" +#include "srsran/srslog/srslog.h" #include /* Power headroom report procedure */ @@ -24,12 +24,12 @@ namespace srsue { class phy_interface_mac_lte; -class phr_proc : public srslte::timer_callback +class phr_proc : public srsran::timer_callback { public: explicit phr_proc(srslog::basic_logger& logger); - void init(phy_interface_mac_lte* phy_h, srslte::ext_task_sched_handle* task_sched_); - void set_config(srslte::phr_cfg_t& cfg); + void init(phy_interface_mac_lte* phy_h, srsran::ext_task_sched_handle* task_sched_); + void set_config(srsran::phr_cfg_t& cfg); void step(); void reset(); @@ -44,14 +44,14 @@ private: srslog::basic_logger& logger; phy_interface_mac_lte* phy_h; - srslte::ext_task_sched_handle* task_sched; - srslte::phr_cfg_t phr_cfg; + srsran::ext_task_sched_handle* task_sched; + srsran::phr_cfg_t phr_cfg; bool initiated; int last_pathloss_db; bool phr_is_triggered; - srslte::timer_handler::unique_timer timer_periodic; - srslte::timer_handler::unique_timer timer_prohibit; + srsran::timer_handler::unique_timer timer_periodic; + srsran::timer_handler::unique_timer timer_prohibit; }; } // namespace srsue diff --git a/srsue/hdr/stack/mac/proc_ra.h b/srsue/hdr/stack/mac/proc_ra.h index 63d268ae6..fdfc38fcb 100644 --- a/srsue/hdr/stack/mac/proc_ra.h +++ b/srsue/hdr/stack/mac/proc_ra.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -19,15 +19,15 @@ #include "demux.h" #include "mux.h" -#include "srslte/common/mac_pcap.h" -#include "srslte/common/timers.h" -#include "srslte/mac/pdu.h" +#include "srsran/common/mac_pcap.h" +#include "srsran/common/timers.h" +#include "srsran/mac/pdu.h" /* Random access procedure as specified in Section 5.1 of 36.321 */ namespace srsue { -class ra_proc : public srslte::timer_callback +class ra_proc : public srsran::timer_callback { public: explicit ra_proc(srslog::basic_logger& logger) : rar_pdu_msg(20), logger(logger) {} @@ -37,13 +37,13 @@ public: void init(phy_interface_mac_lte* phy_h, rrc_interface_mac* rrc_, mac_interface_rrc::ue_rnti_t* rntis, - srslte::timer_handler::unique_timer* time_alignment_timer_, + srsran::timer_handler::unique_timer* time_alignment_timer_, mux* mux_unit, - srslte::ext_task_sched_handle* task_sched_); + srsran::ext_task_sched_handle* task_sched_); void reset(); - void set_config(srslte::rach_cfg_t& rach_cfg); + void set_config(srsran::rach_cfg_t& rach_cfg); void set_config_ded(uint32_t preamble_index, uint32_t prach_mask); void start_pdcch_order(); @@ -60,7 +60,7 @@ public: void tb_decoded_ok(const uint8_t cc_idx, const uint32_t tti); bool contention_resolution_id_received(uint64_t rx_contention_id); - void start_pcap(srslte::mac_pcap* pcap); + void start_pcap(srsran::mac_pcap* pcap); bool is_idle() const { return state == IDLE; } @@ -82,10 +82,10 @@ private: // Buffer to receive RAR PDU static const uint32_t MAX_RAR_PDU_LEN = 2048; uint8_t rar_pdu_buffer[MAX_RAR_PDU_LEN] = {}; - srslte::rar_pdu rar_pdu_msg; + srsran::rar_pdu rar_pdu_msg; // Random Access parameters provided by higher layers defined in 5.1.1 - srslte::rach_cfg_t rach_cfg = {}; + srsran::rach_cfg_t rach_cfg = {}; int delta_preamble_db = 0; uint32_t maskIndex = 0; @@ -104,13 +104,13 @@ private: int backoff_interval_start = 0; uint32_t backoff_interval = 0; int received_target_power_dbm = 0; - uint32_t ra_rnti = SRSLTE_INVALID_RNTI; + uint32_t ra_rnti = SRSRAN_INVALID_RNTI; uint32_t ra_tti = 0; uint32_t current_ta = 0; // The task_id is a unique number associated with each RA procedure used to track background tasks uint32_t current_task_id = 0; - srslte_softbuffer_rx_t softbuffer_rar = {}; + srsran_softbuffer_rx_t softbuffer_rar = {}; enum ra_state_t { IDLE = 0, @@ -132,13 +132,13 @@ private: phy_interface_mac_lte* phy_h = nullptr; srslog::basic_logger& logger; mux* mux_unit = nullptr; - srslte::mac_pcap* pcap = nullptr; + srsran::mac_pcap* pcap = nullptr; rrc_interface_mac* rrc = nullptr; - srslte::ext_task_sched_handle* task_sched = nullptr; - srslte::task_multiqueue::queue_handle task_queue; + srsran::ext_task_sched_handle* task_sched = nullptr; + srsran::task_multiqueue::queue_handle task_queue; - srslte::timer_handler::unique_timer* time_alignment_timer = nullptr; - srslte::timer_handler::unique_timer contention_resolution_timer; + srsran::timer_handler::unique_timer* time_alignment_timer = nullptr; + srsran::timer_handler::unique_timer contention_resolution_timer; mac_interface_rrc::ue_rnti_t* rntis = nullptr; diff --git a/srsue/hdr/stack/mac/proc_sr.h b/srsue/hdr/stack/mac/proc_sr.h index ef5f6f838..1896cdc2e 100644 --- a/srsue/hdr/stack/mac/proc_sr.h +++ b/srsue/hdr/stack/mac/proc_sr.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,8 +13,8 @@ #ifndef SRSUE_PROC_SR_H #define SRSUE_PROC_SR_H -#include "srslte/interfaces/ue_mac_interfaces.h" -#include "srslte/srslog/srslog.h" +#include "srsran/interfaces/ue_mac_interfaces.h" +#include "srsran/srslog/srslog.h" #include /* Scheduling Request procedure as defined in 5.4.4 of 36.321 */ @@ -31,7 +31,7 @@ public: explicit sr_proc(srslog::basic_logger& logger); void init(ra_proc* ra, phy_interface_mac_lte* phy_h, rrc_interface_mac* rrc); void step(uint32_t tti); - void set_config(srslte::sr_cfg_t& cfg); + void set_config(srsran::sr_cfg_t& cfg); void reset(); void start(); @@ -41,7 +41,7 @@ private: int sr_counter; bool is_pending_sr; - srslte::sr_cfg_t sr_cfg; + srsran::sr_cfg_t sr_cfg; ra_proc* ra; rrc_interface_mac* rrc; diff --git a/srsue/hdr/stack/mac/ul_harq.h b/srsue/hdr/stack/mac/ul_harq.h index 1917119dc..812fd9084 100644 --- a/srsue/hdr/stack/mac/ul_harq.h +++ b/srsue/hdr/stack/mac/ul_harq.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -15,12 +15,12 @@ #include "mux.h" #include "proc_ra.h" -#include "srslte/common/interfaces_common.h" -#include "srslte/common/mac_pcap.h" -#include "srslte/common/timers.h" +#include "srsran/common/interfaces_common.h" +#include "srsran/common/mac_pcap.h" +#include "srsran/common/timers.h" #include "ul_sps.h" -using namespace srslte; +using namespace srsran; namespace srsue { @@ -33,9 +33,9 @@ public: void reset(); void reset_ndi(); - void set_config(srslte::ul_harq_cfg_t& harq_cfg); + void set_config(srsran::ul_harq_cfg_t& harq_cfg); - void start_pcap(srslte::mac_pcap* pcap_); + void start_pcap(srsran::mac_pcap* pcap_); /***************** PHY->MAC interface for UL processes **************************/ void new_grant_ul(mac_interface_phy_lte::mac_grant_ul_t grant, mac_interface_phy_lte::tb_action_ul_t* action); @@ -77,7 +77,7 @@ private: srslog::basic_logger& logger; ul_harq_entity* harq_entity; - srslte_softbuffer_tx_t softbuffer; + srsran_softbuffer_tx_t softbuffer; const static int payload_buffer_len = 128 * 1024; std::unique_ptr payload_buffer = nullptr; @@ -93,11 +93,11 @@ private: std::vector proc; mux* mux_unit = nullptr; - srslte::mac_pcap* pcap = nullptr; + srsran::mac_pcap* pcap = nullptr; srslog::basic_logger& logger; mac_interface_rrc_common::ue_rnti_t* rntis = nullptr; - srslte::ul_harq_cfg_t harq_cfg = {}; + srsran::ul_harq_cfg_t harq_cfg = {}; float average_retx = 0.0; uint64_t nof_pkts = 0; @@ -107,7 +107,7 @@ private: }; typedef std::unique_ptr ul_harq_entity_ptr; -typedef std::array ul_harq_entity_vector; +typedef std::array ul_harq_entity_vector; } // namespace srsue diff --git a/srsue/hdr/stack/mac/ul_sps.h b/srsue/hdr/stack/mac/ul_sps.h index fcdb6a471..a7c4dfd49 100644 --- a/srsue/hdr/stack/mac/ul_sps.h +++ b/srsue/hdr/stack/mac/ul_sps.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,7 +13,7 @@ #ifndef SRSUE_UL_SPS_H #define SRSUE_UL_SPS_H -#include "srslte/common/timers.h" +#include "srsran/common/timers.h" /* Uplink Semi-Persistent schedulign (Section 5.10.2) */ diff --git a/srsue/hdr/stack/mac_nr/mac_nr.h b/srsue/hdr/stack/mac_nr/mac_nr.h index 3a3f4b626..465b923db 100644 --- a/srsue/hdr/stack/mac_nr/mac_nr.h +++ b/srsue/hdr/stack/mac_nr/mac_nr.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -15,13 +15,13 @@ #include "mac_nr_interfaces.h" #include "proc_ra_nr.h" -#include "srslte/common/block_queue.h" -#include "srslte/common/mac_pcap.h" -#include "srslte/interfaces/mac_interface_types.h" -#include "srslte/interfaces/ue_nr_interfaces.h" -#include "srslte/interfaces/ue_rlc_interfaces.h" -#include "srslte/mac/mac_sch_pdu_nr.h" -#include "srslte/srslog/srslog.h" +#include "srsran/common/block_queue.h" +#include "srsran/common/mac_pcap.h" +#include "srsran/interfaces/mac_interface_types.h" +#include "srsran/interfaces/ue_nr_interfaces.h" +#include "srsran/interfaces/ue_rlc_interfaces.h" +#include "srsran/mac/mac_sch_pdu_nr.h" +#include "srsran/srslog/srslog.h" #include "srsue/hdr/stack/mac_nr/mux_nr.h" #include "srsue/hdr/stack/ue_stack_base.h" @@ -35,7 +35,7 @@ struct mac_nr_args_t { class mac_nr final : public mac_interface_phy_nr, public mac_interface_rrc_nr, public mac_interface_proc_ra_nr { public: - mac_nr(srslte::ext_task_sched_handle task_sched_); + mac_nr(srsran::ext_task_sched_handle task_sched_); ~mac_nr(); int init(const mac_nr_args_t& args_, phy_interface_mac_nr* phy, rlc_interface_mac* rlc); @@ -44,9 +44,9 @@ public: void reset(); void run_tti(const uint32_t tti); - void start_pcap(srslte::mac_pcap* pcap_); + void start_pcap(srsran::mac_pcap* pcap_); - void bch_decoded_ok(uint32_t tti, srslte::unique_byte_buffer_t payload); + void bch_decoded_ok(uint32_t tti, srsran::unique_byte_buffer_t payload); /// Interface for PHY sched_rnti_t get_dl_sched_rnti_nr(const uint32_t tti); @@ -66,10 +66,10 @@ public: void get_metrics(mac_metrics_t* metrics); /// Interface for RRC (RRC -> MAC) - void setup_lcid(const srslte::logical_channel_config_t& config); - void set_config(const srslte::bsr_cfg_t& bsr_cfg); - void set_config(const srslte::sr_cfg_t& sr_cfg); - void set_config(const srslte::rach_nr_cfg_t& rach_cfg); + void setup_lcid(const srsran::logical_channel_config_t& config); + void set_config(const srsran::bsr_cfg_t& bsr_cfg); + void set_config(const srsran::sr_cfg_t& sr_cfg); + void set_config(const srsran::rach_nr_cfg_t& rach_cfg); void set_contention_id(const uint64_t ue_identity); bool set_crnti(const uint16_t crnti); void start_ra_procedure(); @@ -96,8 +96,8 @@ public: private: void write_pcap(const uint32_t cc_idx, mac_nr_grant_dl_t& grant); // If PCAPs are enabled for this MAC - void handle_pdu(srslte::unique_byte_buffer_t pdu); - void get_ul_data(const mac_nr_grant_ul_t& grant, srslte::byte_buffer_t* tx_pdu); + void handle_pdu(srsran::unique_byte_buffer_t pdu); + void get_ul_data(const mac_nr_grant_ul_t& grant, srsran::byte_buffer_t* tx_pdu); // temporary helper void handle_rar_pdu(mac_nr_grant_dl_t& grant); @@ -112,35 +112,35 @@ private: /// Interaction with rest of the stack phy_interface_mac_nr* phy = nullptr; rlc_interface_mac* rlc = nullptr; - srslte::ext_task_sched_handle task_sched; + srsran::ext_task_sched_handle task_sched; - srslte::mac_pcap* pcap = nullptr; + srsran::mac_pcap* pcap = nullptr; srslog::basic_logger& logger; mac_nr_args_t args = {}; bool started = false; - uint16_t c_rnti = SRSLTE_INVALID_RNTI; + uint16_t c_rnti = SRSRAN_INVALID_RNTI; uint64_t contention_id = 0; static constexpr uint32_t MIN_RLC_PDU_LEN = 5; ///< minimum bytes that need to be available in a MAC PDU for attempting to add another RLC SDU - srslte::block_queue + srsran::block_queue pdu_queue; ///< currently only DCH PDUs supported (add BCH, PCH, etc) - mac_metrics_t metrics[SRSLTE_MAX_CARRIERS] = {}; + mac_metrics_t metrics[SRSRAN_MAX_CARRIERS] = {}; /// Rx buffer - srslte::mac_sch_pdu_nr rx_pdu; + srsran::mac_sch_pdu_nr rx_pdu; /// Tx buffer - srslte::mac_sch_pdu_nr tx_pdu; - srslte::unique_byte_buffer_t tx_buffer = nullptr; - srslte::unique_byte_buffer_t rlc_buffer = nullptr; - srslte_softbuffer_tx_t softbuffer_tx = {}; /// UL HARQ (temporal) + srsran::mac_sch_pdu_nr tx_pdu; + srsran::unique_byte_buffer_t tx_buffer = nullptr; + srsran::unique_byte_buffer_t rlc_buffer = nullptr; + srsran_softbuffer_tx_t softbuffer_tx = {}; /// UL HARQ (temporal) - srslte::task_multiqueue::queue_handle stack_task_dispatch_queue; + srsran::task_multiqueue::queue_handle stack_task_dispatch_queue; // MAC Uplink-related procedures proc_ra_nr proc_ra; diff --git a/srsue/hdr/stack/mac_nr/mac_nr_interfaces.h b/srsue/hdr/stack/mac_nr/mac_nr_interfaces.h index 94d073bb6..68a3d64dd 100644 --- a/srsue/hdr/stack/mac_nr/mac_nr_interfaces.h +++ b/srsue/hdr/stack/mac_nr/mac_nr_interfaces.h @@ -13,7 +13,7 @@ #ifndef SRSUE_MAC_NR_INTERFACES_H #define SRSUE_MAC_NR_INTERFACES_H -#include "srslte/common/interfaces_common.h" +#include "srsran/common/interfaces_common.h" namespace srsue { /** diff --git a/srsue/hdr/stack/mac_nr/mux_nr.h b/srsue/hdr/stack/mac_nr/mux_nr.h index 331822732..1579a25c6 100644 --- a/srsue/hdr/stack/mac_nr/mux_nr.h +++ b/srsue/hdr/stack/mac_nr/mux_nr.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,10 +13,10 @@ #ifndef SRSUE_MUX_NR_H #define SRSUE_MUX_NR_H -#include "srslte/common/byte_buffer.h" -#include "srslte/common/common.h" -#include "srslte/srslog/srslog.h" -#include "srslte/srslte.h" +#include "srsran/common/byte_buffer.h" +#include "srsran/common/common.h" +#include "srsran/srslog/srslog.h" +#include "srsran/srsran.h" namespace srsue { class mux_nr @@ -38,7 +38,7 @@ public: private: srslog::basic_logger& logger; - srslte::unique_byte_buffer_t msg3_buff = nullptr; + srsran::unique_byte_buffer_t msg3_buff = nullptr; typedef enum { none, pending, transmitted } msg3_state_t; msg3_state_t msg3_state = none; }; diff --git a/srsue/hdr/stack/mac_nr/proc_ra_nr.h b/srsue/hdr/stack/mac_nr/proc_ra_nr.h index 6541e4aea..726313514 100644 --- a/srsue/hdr/stack/mac_nr/proc_ra_nr.h +++ b/srsue/hdr/stack/mac_nr/proc_ra_nr.h @@ -18,10 +18,10 @@ #include #include "mac_nr_interfaces.h" -#include "srslte/common/common.h" -#include "srslte/common/task_scheduler.h" -#include "srslte/interfaces/ue_nr_interfaces.h" -#include "srslte/srslog/srslog.h" +#include "srsran/common/common.h" +#include "srsran/common/task_scheduler.h" +#include "srsran/interfaces/ue_nr_interfaces.h" +#include "srsran/srslog/srslog.h" namespace srsue { @@ -31,8 +31,8 @@ public: proc_ra_nr(srslog::basic_logger& logger_); ~proc_ra_nr(){}; - void init(phy_interface_mac_nr* phy_h_, mac_interface_proc_ra_nr* mac_, srslte::ext_task_sched_handle* task_sched_); - void set_config(const srslte::rach_nr_cfg_t& rach_cfg); + void init(phy_interface_mac_nr* phy_h_, mac_interface_proc_ra_nr* mac_, srsran::ext_task_sched_handle* task_sched_); + void set_config(const srsran::rach_nr_cfg_t& rach_cfg); bool is_contention_resolution(); bool is_rar_opportunity(uint32_t tti); @@ -53,14 +53,14 @@ private: srslog::basic_logger& logger; phy_interface_mac_nr* phy = nullptr; mac_interface_proc_ra_nr* mac = nullptr; - srslte::ext_task_sched_handle* task_sched = nullptr; - srslte::task_multiqueue::queue_handle task_queue; + srsran::ext_task_sched_handle* task_sched = nullptr; + srsran::task_multiqueue::queue_handle task_queue; int ra_window_length = -1, ra_window_start = -1; - uint16_t rar_rnti = SRSLTE_INVALID_RNTI; - uint16_t temp_rnti = SRSLTE_INVALID_RNTI; + uint16_t rar_rnti = SRSRAN_INVALID_RNTI; + uint16_t temp_rnti = SRSRAN_INVALID_RNTI; - srslte::rach_nr_cfg_t rach_cfg = {}; + srsran::rach_nr_cfg_t rach_cfg = {}; bool configured = false; enum ra_state_t { @@ -77,11 +77,11 @@ private: enum initiators_t { MAC, RRC, initiators_t_NULLTYPE }; std::atomic started_by = {initiators_t_NULLTYPE}; - - srslte::timer_handler::unique_timer prach_send_timer; - srslte::timer_handler::unique_timer rar_timeout_timer; - srslte::timer_handler::unique_timer contention_resolution_timer; - + + srsran::timer_handler::unique_timer prach_send_timer; + srsran::timer_handler::unique_timer rar_timeout_timer; + srsran::timer_handler::unique_timer contention_resolution_timer; + // 38.321 5.1.1 Variables uint32_t preamble_index = 0; uint32_t preamble_transmission_counter = 0; diff --git a/srsue/hdr/stack/rrc/phy_controller.h b/srsue/hdr/stack/rrc/phy_controller.h index 4235e32f6..742bee6ba 100644 --- a/srsue/hdr/stack/rrc/phy_controller.h +++ b/srsue/hdr/stack/rrc/phy_controller.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,19 +10,19 @@ * */ -#ifndef SRSLTE_PHY_CONTROLLER_H -#define SRSLTE_PHY_CONTROLLER_H +#ifndef SRSRAN_PHY_CONTROLLER_H +#define SRSRAN_PHY_CONTROLLER_H -#include "srslte/adt/observer.h" -#include "srslte/common/fsm.h" -#include "srslte/common/task_scheduler.h" -#include "srslte/interfaces/ue_phy_interfaces.h" -#include "srslte/interfaces/ue_rrc_interfaces.h" +#include "srsran/adt/observer.h" +#include "srsran/common/fsm.h" +#include "srsran/common/task_scheduler.h" +#include "srsran/interfaces/ue_phy_interfaces.h" +#include "srsran/interfaces/ue_rrc_interfaces.h" #include namespace srsue { -class phy_controller : public srslte::fsm_t +class phy_controller : public srsran::fsm_t { using cell_search_ret_t = rrc_interface_phy_lte::cell_search_ret_t; @@ -47,17 +47,17 @@ public: struct out_sync_ev {}; explicit phy_controller(phy_interface_rrc_lte* phy_, - srslte::task_sched_handle task_sched_, + srsran::task_sched_handle task_sched_, std::function on_cell_selection = {}); // PHY procedures interfaces - bool start_cell_select(const phy_cell_t& phy_cell, srslte::event_observer observer = {}); - bool start_cell_search(srslte::event_observer observer); + bool start_cell_select(const phy_cell_t& phy_cell, srsran::event_observer observer = {}); + bool start_cell_search(srsran::event_observer observer); void cell_search_completed(cell_search_ret_t cs_ret, phy_cell_t found_cell); void cell_selection_completed(bool outcome); void in_sync(); void out_sync() { trigger(out_sync_ev{}); } - bool set_cell_config(const srslte::phy_cfg_t& config, uint32_t cc_idx = 0); + bool set_cell_config(const srsran::phy_cfg_t& config, uint32_t cc_idx = 0); void set_phy_to_default(); void set_phy_to_default_dedicated(); void set_phy_to_default_pucch_srs(); @@ -68,9 +68,9 @@ public: bool is_in_sync() const { return is_in_state(); } bool is_config_pending() const { return nof_pending_configs == 0; } - srslte::span current_cell_config() const { return current_cells_cfg; } - srslte::span current_cell_config() { return current_cells_cfg; } - const std::bitset& current_config_scells() const { return configured_scell_mask; } + srsran::span current_cell_config() const { return current_cells_cfg; } + srsran::span current_cell_config() { return current_cells_cfg; } + const std::bitset& current_config_scells() const { return configured_scell_mask; } // FSM states struct unknown_st {}; @@ -88,7 +88,7 @@ public: void enter(phy_controller* f, const cell_sel_cmd& ev); void exit(phy_controller* f); - srslte::timer_handler::unique_timer wait_in_sync_timer; + srsran::timer_handler::unique_timer wait_in_sync_timer; phy_cell_t target_cell = {}; cell_sel_res csel_res = {}; @@ -111,7 +111,7 @@ public: // +----------------+---------------+--------------+------------------+----------------------+ row< wait_in_sync, in_sync_st, in_sync_ev, &c::set_success >, row< wait_in_sync, unknown_st, timeout_ev >, - to_state< unknown_st, srslte::failure_ev > + to_state< unknown_st, srsran::failure_ev > // +----------------+---------------+--------------+------------------+----------------------+ >; // clang-format on @@ -122,15 +122,15 @@ public: private: phy_interface_rrc_lte* phy = nullptr; - srslte::task_sched_handle task_sched; - srslte::event_observer cell_selection_notifier; + srsran::task_sched_handle task_sched; + srsran::event_observer cell_selection_notifier; std::function cell_selection_always_observer; - srslte::event_dispatcher cell_search_observers; + srsran::event_dispatcher cell_search_observers; uint32_t nof_pending_configs = 0; - std::array current_cells_cfg = {}; - std::bitset configured_scell_mask = {}; + std::array current_cells_cfg = {}; + std::bitset configured_scell_mask = {}; - bool set_cell_config(const srslte::phy_cfg_t& cfg, uint32_t cc_idx, bool is_set); + bool set_cell_config(const srsran::phy_cfg_t& cfg, uint32_t cc_idx, bool is_set); protected: state_list states{this, @@ -169,4 +169,4 @@ protected: } // namespace srsue -#endif // SRSLTE_PHY_CONTROLLER_H +#endif // SRSRAN_PHY_CONTROLLER_H diff --git a/srsue/hdr/stack/rrc/rrc.h b/srsue/hdr/stack/rrc/rrc.h index 7cfe55a46..ebd5af8bf 100644 --- a/srsue/hdr/stack/rrc/rrc.h +++ b/srsue/hdr/stack/rrc/rrc.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -16,21 +16,21 @@ #include "rrc_cell.h" #include "rrc_common.h" #include "rrc_metrics.h" -#include "srslte/asn1/rrc_utils.h" -#include "srslte/common/bcd_helpers.h" -#include "srslte/common/block_queue.h" -#include "srslte/common/buffer_pool.h" -#include "srslte/common/common.h" -#include "srslte/common/security.h" -#include "srslte/common/stack_procedure.h" -#include "srslte/interfaces/ue_interfaces.h" -#include "srslte/srslog/srslog.h" +#include "srsran/asn1/rrc_utils.h" +#include "srsran/common/bcd_helpers.h" +#include "srsran/common/block_queue.h" +#include "srsran/common/buffer_pool.h" +#include "srsran/common/common.h" +#include "srsran/common/security.h" +#include "srsran/common/stack_procedure.h" +#include "srsran/interfaces/ue_interfaces.h" +#include "srsran/srslog/srslog.h" #include #include #include -#define SRSLTE_RRC_N_BANDS 43 +#define SRSRAN_RRC_N_BANDS 43 typedef struct { std::string ue_category_str; uint32_t ue_category; @@ -38,21 +38,21 @@ typedef struct { int ue_category_dl; uint32_t release; uint32_t feature_group; - std::array supported_bands; + std::array supported_bands; uint32_t nof_supported_bands; bool support_ca; int mbms_service_id; uint32_t mbms_service_port; } rrc_args_t; -#define SRSLTE_UE_CATEGORY_DEFAULT "4" -#define SRSLTE_UE_CATEGORY_MIN 1 -#define SRSLTE_UE_CATEGORY_MAX 21 -#define SRSLTE_RELEASE_DEFAULT 8 -#define SRSLTE_RELEASE_MIN 8 -#define SRSLTE_RELEASE_MAX 15 +#define SRSRAN_UE_CATEGORY_DEFAULT "4" +#define SRSRAN_UE_CATEGORY_MIN 1 +#define SRSRAN_UE_CATEGORY_MAX 21 +#define SRSRAN_RELEASE_DEFAULT 8 +#define SRSRAN_RELEASE_MIN 8 +#define SRSRAN_RELEASE_MAX 15 -using srslte::byte_buffer_t; +using srsran::byte_buffer_t; namespace srsue { @@ -70,10 +70,10 @@ class rrc : public rrc_interface_nas, public rrc_interface_pdcp, public rrc_eutra_interface_rrc_nr, public rrc_interface_rlc, - public srslte::timer_callback + public srsran::timer_callback { public: - rrc(stack_interface_rrc* stack_, srslte::task_sched_handle task_sched_); + rrc(stack_interface_rrc* stack_, srsran::task_sched_handle task_sched_); ~rrc(); void init(phy_interface_rrc_lte* phy_, @@ -92,13 +92,13 @@ public: // Timeout callback interface void timer_expired(uint32_t timeout_id) final; - void srslte_rrc_log(const char* str); + void srsran_rrc_log(const char* str); typedef enum { Rx = 0, Tx } direction_t; template void log_rrc_message(const std::string source, const direction_t dir, - const srslte::byte_buffer_t* pdu, + const srsran::byte_buffer_t* pdu, const T& msg, const std::string& msg_type); @@ -106,14 +106,14 @@ public: bool mbms_service_start(uint32_t serv, uint32_t port); // NAS interface - void write_sdu(srslte::unique_byte_buffer_t sdu); + void write_sdu(srsran::unique_byte_buffer_t sdu); void enable_capabilities(); uint16_t get_mcc(); uint16_t get_mnc(); bool plmn_search() final; - void plmn_select(srslte::plmn_id_t plmn_id); - bool connection_request(srslte::establishment_cause_t cause, srslte::unique_byte_buffer_t dedicated_info_nas); - void set_ue_identity(srslte::s_tmsi_t s_tmsi); + void plmn_select(srsran::plmn_id_t plmn_id); + bool connection_request(srsran::establishment_cause_t cause, srsran::unique_byte_buffer_t dedicated_info_nas); + void set_ue_identity(srsran::s_tmsi_t s_tmsi); void paging_completed(bool outcome) final; bool has_nr_dc(); @@ -141,11 +141,11 @@ public: bool have_drb(); // PDCP interface - void write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t pdu); - void write_pdu_bcch_bch(srslte::unique_byte_buffer_t pdu); - void write_pdu_bcch_dlsch(srslte::unique_byte_buffer_t pdu); - void write_pdu_pcch(srslte::unique_byte_buffer_t pdu); - void write_pdu_mch(uint32_t lcid, srslte::unique_byte_buffer_t pdu); + void write_pdu(uint32_t lcid, srsran::unique_byte_buffer_t pdu); + void write_pdu_bcch_bch(srsran::unique_byte_buffer_t pdu); + void write_pdu_bcch_dlsch(srsran::unique_byte_buffer_t pdu); + void write_pdu_pcch(srsran::unique_byte_buffer_t pdu); + void write_pdu_mch(uint32_t lcid, srsran::unique_byte_buffer_t pdu); bool srbs_flushed(); //< Check if data on SRBs still needs to be sent @@ -161,17 +161,17 @@ protected: private: typedef struct { enum { PCCH, RLF, RA_COMPLETE, STOP } command; - srslte::unique_byte_buffer_t pdu; + srsran::unique_byte_buffer_t pdu; uint16_t lcid; } cmd_msg_t; bool running = false; - srslte::block_queue cmd_q; + srsran::block_queue cmd_q; - void process_pcch(srslte::unique_byte_buffer_t pdu); + void process_pcch(srsran::unique_byte_buffer_t pdu); stack_interface_rrc* stack = nullptr; - srslte::task_sched_handle task_sched; + srsran::task_sched_handle task_sched; srslog::basic_logger& logger; phy_interface_rrc_lte* phy = nullptr; mac_interface_rrc* mac = nullptr; @@ -181,14 +181,14 @@ private: usim_interface_rrc* usim = nullptr; gw_interface_rrc* gw = nullptr; rrc_nr_interface_rrc* rrc_nr = nullptr; - srslte::unique_byte_buffer_t dedicated_info_nas; + srsran::unique_byte_buffer_t dedicated_info_nas; void send_ul_ccch_msg(const asn1::rrc::ul_ccch_msg_s& msg); void send_ul_dcch_msg(uint32_t lcid, const asn1::rrc::ul_dcch_msg_s& msg); rrc_state_t state = RRC_STATE_IDLE, last_state = RRC_STATE_IDLE; uint8_t transaction_id = 0; - srslte::s_tmsi_t ue_identity; + srsran::s_tmsi_t ue_identity; bool ue_identity_configured = false; bool drb_up = false; @@ -200,11 +200,11 @@ private: uint32_t cell_clean_cnt = 0; - srslte::phy_cfg_t previous_phy_cfg = {}; - srslte::mac_cfg_t current_mac_cfg, previous_mac_cfg = {}; + srsran::phy_cfg_t previous_phy_cfg = {}; + srsran::mac_cfg_t current_mac_cfg, previous_mac_cfg = {}; void generate_as_keys(); - srslte::as_security_config_t sec_cfg = {}; + srsran::as_security_config_t sec_cfg = {}; std::map srbs; std::map drbs; @@ -212,7 +212,7 @@ private: // RRC constants and timers uint32_t n310_cnt = 0, N310 = 0; uint32_t n311_cnt = 0, N311 = 0; - srslte::timer_handler::unique_timer t300, t301, t302, t310, t311, t304; + srsran::timer_handler::unique_timer t300, t301, t302, t310, t311, t304; // Radio bearers typedef enum { @@ -271,11 +271,11 @@ private: void process_cell_meas(); void process_new_cell_meas(const std::vector& meas); - srslte::block_queue > cell_meas_q; + srsran::block_queue > cell_meas_q; void process_cell_meas_nr(); void process_new_cell_meas_nr(const std::vector& meas); - srslte::block_queue > cell_meas_nr_q; + srsran::block_queue > cell_meas_nr_q; // Cell selection/reselection functions/variables typedef struct { @@ -312,26 +312,26 @@ private: class cell_reselection_proc; class connection_reest_proc; class ho_proc; - srslte::proc_t cell_searcher; - srslte::proc_t si_acquirer; - srslte::proc_t serv_cell_cfg; - srslte::proc_t cell_selector; - srslte::proc_t idle_setter; - srslte::proc_t pcch_processor; - srslte::proc_t conn_req_proc; - srslte::proc_t plmn_searcher; - srslte::proc_t cell_reselector; - srslte::proc_t connection_reest; - srslte::proc_t ho_handler; - srslte::proc_t conn_recfg_proc; - - srslte::proc_manager_list_t callback_list; + srsran::proc_t cell_searcher; + srsran::proc_t si_acquirer; + srsran::proc_t serv_cell_cfg; + srsran::proc_t cell_selector; + srsran::proc_t idle_setter; + srsran::proc_t pcch_processor; + srsran::proc_t conn_req_proc; + srsran::proc_t plmn_searcher; + srsran::proc_t cell_reselector; + srsran::proc_t connection_reest; + srsran::proc_t ho_handler; + srsran::proc_t conn_recfg_proc; + + srsran::proc_manager_list_t callback_list; bool cell_selection_criteria(float rsrp, float rsrq = 0); void cell_reselection(float rsrp, float rsrq); std::vector ue_required_sibs; - srslte::plmn_id_t selected_plmn_id = {}; + srsran::plmn_id_t selected_plmn_id = {}; bool plmn_is_selected = false; bool security_is_activated = false; @@ -340,21 +340,21 @@ private: void max_retx_attempted(); // Senders - void send_con_request(srslte::establishment_cause_t cause); + void send_con_request(srsran::establishment_cause_t cause); void send_con_restablish_request(asn1::rrc::reest_cause_e cause, uint16_t rnti, uint16_t pci, uint32_t cellid); void send_con_restablish_complete(); - void send_con_setup_complete(srslte::unique_byte_buffer_t nas_msg); - void send_ul_info_transfer(srslte::unique_byte_buffer_t nas_msg); + void send_con_setup_complete(srsran::unique_byte_buffer_t nas_msg); + void send_ul_info_transfer(srsran::unique_byte_buffer_t nas_msg); void send_security_mode_complete(); void send_rrc_con_reconfig_complete(bool contains_nr_complete = false); // Parsers - void process_pdu(uint32_t lcid, srslte::unique_byte_buffer_t pdu); - void parse_dl_ccch(srslte::unique_byte_buffer_t pdu); - void parse_dl_dcch(uint32_t lcid, srslte::unique_byte_buffer_t pdu); - void parse_dl_info_transfer(uint32_t lcid, srslte::unique_byte_buffer_t pdu); - void parse_pdu_bcch_dlsch(srslte::unique_byte_buffer_t pdu); - void parse_pdu_mch(uint32_t lcid, srslte::unique_byte_buffer_t pdu); + void process_pdu(uint32_t lcid, srsran::unique_byte_buffer_t pdu); + void parse_dl_ccch(srsran::unique_byte_buffer_t pdu); + void parse_dl_dcch(uint32_t lcid, srsran::unique_byte_buffer_t pdu); + void parse_dl_info_transfer(uint32_t lcid, srsran::unique_byte_buffer_t pdu); + void parse_pdu_bcch_dlsch(srsran::unique_byte_buffer_t pdu); + void parse_pdu_mch(uint32_t lcid, srsran::unique_byte_buffer_t pdu); // Helpers void con_reconfig_failed(); diff --git a/srsue/hdr/stack/rrc/rrc_cell.h b/srsue/hdr/stack/rrc/rrc_cell.h index c374115f9..dfed544b5 100644 --- a/srsue/hdr/stack/rrc/rrc_cell.h +++ b/srsue/hdr/stack/rrc/rrc_cell.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,16 +10,16 @@ * */ -#ifndef SRSLTE_RRC_CELL_H -#define SRSLTE_RRC_CELL_H +#ifndef SRSRAN_RRC_CELL_H +#define SRSRAN_RRC_CELL_H -#include "srslte/asn1/rrc.h" -#include "srslte/asn1/rrc_nr.h" -#include "srslte/asn1/rrc_nr_utils.h" -#include "srslte/asn1/rrc_utils.h" -#include "srslte/common/task_scheduler.h" -#include "srslte/interfaces/ue_rrc_interfaces.h" -#include "srslte/srslog/srslog.h" +#include "srsran/asn1/rrc.h" +#include "srsran/asn1/rrc_nr.h" +#include "srsran/asn1/rrc_nr_utils.h" +#include "srsran/asn1/rrc_utils.h" +#include "srsran/common/task_scheduler.h" +#include "srsran/interfaces/ue_rrc_interfaces.h" +#include "srsran/srslog/srslog.h" #include namespace srsue { @@ -36,11 +36,11 @@ class meas_cell public: const static int neighbour_timeout_ms = 5000; - explicit meas_cell(srslte::unique_timer timer); - meas_cell(const phy_cell_t& phy_cell_, srslte::unique_timer timer); + explicit meas_cell(srsran::unique_timer timer); + meas_cell(const phy_cell_t& phy_cell_, srsran::unique_timer timer); // comparison based on pci and earfcn - bool is_valid() const { return phy_cell.earfcn != 0 && srslte_cellid_isvalid(phy_cell.pci); } + bool is_valid() const { return phy_cell.earfcn != 0 && srsran_cellid_isvalid(phy_cell.pci); } bool equals(const meas_cell& x) { return equals(x.phy_cell.earfcn, x.phy_cell.pci); } bool equals(uint32_t earfcn, uint32_t pci) { return earfcn == phy_cell.earfcn && pci == phy_cell.pci; } @@ -73,7 +73,7 @@ public: bool has_sib3() const { return has_valid_sib3; } bool has_sib13() const { return has_valid_sib13; } bool has_sib(uint32_t index) const; - bool has_sibs(srslte::span indexes) const; + bool has_sibs(srsran::span indexes) const; bool is_sib_scheduled(uint32_t sib_index) const; @@ -93,7 +93,7 @@ public: float get_cfo_hz() const { return phy_cell.cfo_hz; } phy_cell_t phy_cell = {0, 0, 0}; - srslte::unique_timer timer; + srsran::unique_timer timer; protected: float rsrp = NAN; @@ -109,12 +109,12 @@ protected: class meas_cell_nr : public meas_cell { public: - explicit meas_cell_nr(srslte::unique_timer timer) : meas_cell(std::move(timer)){}; - meas_cell_nr(const phy_cell_t& phy_cell_, srslte::unique_timer timer) : meas_cell(phy_cell_, std::move(timer)){}; + explicit meas_cell_nr(srsran::unique_timer timer) : meas_cell(std::move(timer)){}; + meas_cell_nr(const phy_cell_t& phy_cell_, srsran::unique_timer timer) : meas_cell(phy_cell_, std::move(timer)){}; bool has_plmn_id(asn1::rrc_nr::plmn_id_s plmn_id) const; uint32_t nof_plmns() const { return has_sib1() ? sib1.cell_access_related_info.plmn_id_list.size() : 0; } - srslte::plmn_id_t get_plmn(uint32_t idx) const; + srsran::plmn_id_t get_plmn(uint32_t idx) const; void set_sib1(const asn1::rrc_nr::sib1_s& sib1_); void set_sib2(const asn1::rrc_nr::sib2_s& sib2_); @@ -141,12 +141,12 @@ public: class meas_cell_eutra : public meas_cell { public: - explicit meas_cell_eutra(srslte::unique_timer timer) : meas_cell(std::move(timer)){}; - meas_cell_eutra(const phy_cell_t& phy_cell_, srslte::unique_timer timer) : meas_cell(phy_cell_, std::move(timer)){}; + explicit meas_cell_eutra(srsran::unique_timer timer) : meas_cell(std::move(timer)){}; + meas_cell_eutra(const phy_cell_t& phy_cell_, srsran::unique_timer timer) : meas_cell(phy_cell_, std::move(timer)){}; bool has_plmn_id(asn1::rrc::plmn_id_s plmn_id) const; uint32_t nof_plmns() const { return has_sib1() ? sib1.cell_access_related_info.plmn_id_list.size() : 0; } - srslte::plmn_id_t get_plmn(uint32_t idx) const; + srsran::plmn_id_t get_plmn(uint32_t idx) const; uint16_t get_tac() const { return has_sib1() ? (uint16_t)sib1.cell_access_related_info.tac.to_number() : 0; } @@ -224,7 +224,7 @@ public: const static int MAX_NEIGHBOUR_CELLS = 8; typedef std::unique_ptr unique_meas_cell; - explicit meas_cell_list(srslte::task_sched_handle task_sched_); + explicit meas_cell_list(srsran::task_sched_handle task_sched_); bool add_meas_cell(const phy_meas_t& meas); bool add_meas_cell(unique_meas_cell cell); @@ -263,7 +263,7 @@ private: // args srslog::basic_logger& logger = srslog::fetch_basic_logger("RRC"); - srslte::task_sched_handle task_sched; + srsran::task_sched_handle task_sched; unique_meas_cell serv_cell; std::vector neighbour_cells; @@ -271,4 +271,4 @@ private: } // namespace srsue -#endif // SRSLTE_RRC_CELL_H +#endif // SRSRAN_RRC_CELL_H diff --git a/srsue/hdr/stack/rrc/rrc_common.h b/srsue/hdr/stack/rrc/rrc_common.h index 48785e9b9..63bf41540 100644 --- a/srsue/hdr/stack/rrc/rrc_common.h +++ b/srsue/hdr/stack/rrc/rrc_common.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/srsue/hdr/stack/rrc/rrc_meas.h b/srsue/hdr/stack/rrc/rrc_meas.h index f1be850a7..44230de8e 100644 --- a/srsue/hdr/stack/rrc/rrc_meas.h +++ b/srsue/hdr/stack/rrc/rrc_meas.h @@ -2,20 +2,20 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of * the distribution. * */ -#ifndef SRSLTE_RRC_MEAS_H_ -#define SRSLTE_RRC_MEAS_H_ +#ifndef SRSRAN_RRC_MEAS_H_ +#define SRSRAN_RRC_MEAS_H_ -#include "srslte/asn1/rrc.h" -#include "srslte/asn1/rrc_utils.h" -#include "srslte/common/common.h" -#include "srslte/interfaces/ue_interfaces.h" +#include "srsran/asn1/rrc.h" +#include "srsran/asn1/rrc_utils.h" +#include "srsran/common/common.h" +#include "srsran/interfaces/ue_interfaces.h" #include "srsue/hdr/stack/rrc/rrc.h" #include @@ -88,7 +88,7 @@ private: cell_triggered_t cell_triggered_list = {}; report_cfg_eutra_s report_cfg_eutra = {}; report_cfg_inter_rat_s report_cfg_inter = {}; - srslte::timer_handler::unique_timer periodic_timer = {}; + srsran::timer_handler::unique_timer periodic_timer = {}; }; var_meas_cfg* meas_cfg = nullptr; srslog::basic_logger& logger; @@ -202,4 +202,4 @@ private: } // namespace srsue -#endif // SRSLTE_SRSUE_HDR_STACK_RRC_RRC_MEAS_H_ +#endif // SRSRAN_SRSUE_HDR_STACK_RRC_RRC_MEAS_H_ diff --git a/srsue/hdr/stack/rrc/rrc_metrics.h b/srsue/hdr/stack/rrc/rrc_metrics.h index 214c3c5f0..34e01e486 100644 --- a/srsue/hdr/stack/rrc/rrc_metrics.h +++ b/srsue/hdr/stack/rrc/rrc_metrics.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -14,7 +14,7 @@ #define SRSUE_RRC_METRICS_H #include "rrc_common.h" -#include "srslte/interfaces/phy_interface_types.h" +#include "srsran/interfaces/phy_interface_types.h" namespace srsue { diff --git a/srsue/hdr/stack/rrc/rrc_nr.h b/srsue/hdr/stack/rrc/rrc_nr.h index bb084260a..4f99ce10a 100644 --- a/srsue/hdr/stack/rrc/rrc_nr.h +++ b/srsue/hdr/stack/rrc/rrc_nr.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,15 +13,15 @@ #ifndef SRSUE_RRC_NR_H #define SRSUE_RRC_NR_H -#include "srslte/asn1/rrc_nr.h" -#include "srslte/asn1/rrc_nr_utils.h" -#include "srslte/common/block_queue.h" -#include "srslte/common/buffer_pool.h" -#include "srslte/common/stack_procedure.h" -#include "srslte/common/task_scheduler.h" -#include "srslte/interfaces/nr_common_interface_types.h" -#include "srslte/interfaces/ue_nr_interfaces.h" -#include "srslte/interfaces/ue_rrc_interfaces.h" +#include "srsran/asn1/rrc_nr.h" +#include "srsran/asn1/rrc_nr_utils.h" +#include "srsran/common/block_queue.h" +#include "srsran/common/buffer_pool.h" +#include "srsran/common/stack_procedure.h" +#include "srsran/common/task_scheduler.h" +#include "srsran/interfaces/nr_common_interface_types.h" +#include "srsran/interfaces/ue_nr_interfaces.h" +#include "srsran/interfaces/ue_rrc_interfaces.h" #include "srsue/hdr/stack/upper/gw.h" namespace srsue { @@ -51,10 +51,10 @@ class rrc_nr final : public rrc_interface_phy_nr, public rrc_interface_pdcp, public rrc_interface_rlc, public rrc_nr_interface_rrc, - public srslte::timer_callback + public srsran::timer_callback { public: - rrc_nr(srslte::task_sched_handle task_sched_); + rrc_nr(srsran::task_sched_handle task_sched_); ~rrc_nr(); void init(phy_interface_rrc_nr* phy_, @@ -64,7 +64,7 @@ public: gw_interface_rrc* gw_, rrc_eutra_interface_rrc_nr* rrc_eutra_, usim_interface_rrc_nr* usim_, - srslte::timer_handler* timers_, + srsran::timer_handler* timers_, stack_interface_rrc* stack_, const rrc_nr_args_t& args_); @@ -75,13 +75,13 @@ public: // Timeout callback interface void timer_expired(uint32_t timeout_id) final; - void srslte_rrc_log(const char* str); + void srsran_rrc_log(const char* str); enum direction_t { Rx = 0, Tx }; template void log_rrc_message(const std::string& source, direction_t dir, - const srslte::byte_buffer_t* pdu, + const srsran::byte_buffer_t* pdu, const T& msg, const std::string& msg_type); template @@ -101,15 +101,15 @@ public: void max_retx_attempted() final; // PDCP interface - void write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t pdu) final; - void write_pdu_bcch_bch(srslte::unique_byte_buffer_t pdu) final; - void write_pdu_bcch_dlsch(srslte::unique_byte_buffer_t pdu) final; - void write_pdu_pcch(srslte::unique_byte_buffer_t pdu) final; - void write_pdu_mch(uint32_t lcid, srslte::unique_byte_buffer_t pdu) final; + void write_pdu(uint32_t lcid, srsran::unique_byte_buffer_t pdu) final; + void write_pdu_bcch_bch(srsran::unique_byte_buffer_t pdu) final; + void write_pdu_bcch_dlsch(srsran::unique_byte_buffer_t pdu) final; + void write_pdu_pcch(srsran::unique_byte_buffer_t pdu) final; + void write_pdu_mch(uint32_t lcid, srsran::unique_byte_buffer_t pdu) final; // RRC (LTE) interface - void get_eutra_nr_capabilities(srslte::byte_buffer_t* eutra_nr_caps); - void get_nr_capabilities(srslte::byte_buffer_t* eutra_nr_caps); + void get_eutra_nr_capabilities(srsran::byte_buffer_t* eutra_nr_caps); + void get_nr_capabilities(srsran::byte_buffer_t* eutra_nr_caps); void phy_meas_stop(); void phy_set_cells_to_meas(uint32_t carrier_freq_r15); bool rrc_reconfiguration(bool endc_release_and_add_r15, @@ -125,16 +125,16 @@ public: void cell_search_completed(const rrc_interface_phy_lte::cell_search_ret_t& cs_ret, const phy_cell_t& found_cell); private: - srslte::task_sched_handle task_sched; + srsran::task_sched_handle task_sched; struct cmd_msg_t { enum { PDU, PCCH, PDU_MCH, RLF, PDU_BCCH_DLSCH, STOP } command; - srslte::unique_byte_buffer_t pdu; + srsran::unique_byte_buffer_t pdu; uint16_t lcid; }; srslog::basic_logger& logger; bool running = false; - srslte::block_queue cmd_q; + srsran::block_queue cmd_q; phy_interface_rrc_nr* phy = nullptr; mac_interface_rrc_nr* mac = nullptr; @@ -146,7 +146,7 @@ private: stack_interface_rrc* stack = nullptr; uint32_t fake_measurement_carrier_freq_r15; - srslte::timer_handler::unique_timer fake_measurement_timer; + srsran::timer_handler::unique_timer fake_measurement_timer; /// RRC states (3GPP 38.331 v15.5.1 Sec 4.2.1) enum rrc_nr_state_t { @@ -162,9 +162,9 @@ private: rrc_nr_args_t args = {}; // RRC constants and timers - srslte::timer_handler* timers = nullptr; + srsran::timer_handler* timers = nullptr; - std::string get_rb_name(uint32_t lcid) final { return srslte::to_string((srslte::rb_id_nr_t)lcid); } + std::string get_rb_name(uint32_t lcid) final { return srsran::to_string((srsran::rb_id_nr_t)lcid); } typedef enum { Srb = 0, Drb } rb_type_t; typedef struct { @@ -187,22 +187,22 @@ private: bool apply_drb_add_mod(const asn1::rrc_nr::drb_to_add_mod_s& drb_cfg); bool apply_security_cfg(const asn1::rrc_nr::security_cfg_s& security_cfg); - srslte::as_security_config_t sec_cfg; + srsran::as_security_config_t sec_cfg; class connection_reconf_no_ho_proc { public: explicit connection_reconf_no_ho_proc(rrc_nr* parent_); - srslte::proc_outcome_t init(const bool endc_release_and_add_r15, + srsran::proc_outcome_t init(const bool endc_release_and_add_r15, const asn1::rrc_nr::rrc_recfg_s& rrc_recfg, const asn1::rrc_nr::cell_group_cfg_s& cell_group_cfg, bool sk_counter_r15_present, const uint32_t sk_counter_r15, const asn1::rrc_nr::radio_bearer_cfg_s& radio_bearer_cfg); - srslte::proc_outcome_t step() { return srslte::proc_outcome_t::yield; } + srsran::proc_outcome_t step() { return srsran::proc_outcome_t::yield; } static const char* name() { return "NR Connection Reconfiguration"; } - srslte::proc_outcome_t react(const bool& config_complete); - void then(const srslte::proc_state_t& result); + srsran::proc_outcome_t react(const bool& config_complete); + void then(const srsran::proc_state_t& result); private: // const @@ -212,9 +212,9 @@ private: asn1::rrc_nr::cell_group_cfg_s cell_group_cfg; }; - srslte::proc_t conn_recfg_proc; + srsran::proc_t conn_recfg_proc; - srslte::proc_manager_list_t callback_list; + srsran::proc_manager_list_t callback_list; }; } // namespace srsue diff --git a/srsue/hdr/stack/rrc/rrc_procedures.h b/srsue/hdr/stack/rrc/rrc_procedures.h index a63ed4983..71a399f9c 100644 --- a/srsue/hdr/stack/rrc/rrc_procedures.h +++ b/srsue/hdr/stack/rrc/rrc_procedures.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,14 +11,14 @@ */ #include "phy_controller.h" -#include "srslte/interfaces/ue_nas_interfaces.h" -#include "srslte/srslog/srslog.h" +#include "srsran/interfaces/ue_nas_interfaces.h" +#include "srsran/srslog/srslog.h" #include "srsue/hdr/stack/rrc/rrc.h" #include #include -#ifndef SRSLTE_RRC_PROCEDURES_H -#define SRSLTE_RRC_PROCEDURES_H +#ifndef SRSRAN_RRC_PROCEDURES_H +#define SRSRAN_RRC_PROCEDURES_H namespace srsue { @@ -32,25 +32,25 @@ public: enum class state_t { phy_cell_search, si_acquire, wait_measurement, phy_cell_select }; explicit cell_search_proc(rrc* parent_); - srslte::proc_outcome_t init(); - srslte::proc_outcome_t step(); - srslte::proc_outcome_t step_si_acquire(); - srslte::proc_outcome_t react(const phy_controller::cell_srch_res& event); - srslte::proc_outcome_t react(const bool& event); - srslte::proc_outcome_t step_wait_measurement(); + srsran::proc_outcome_t init(); + srsran::proc_outcome_t step(); + srsran::proc_outcome_t step_si_acquire(); + srsran::proc_outcome_t react(const phy_controller::cell_srch_res& event); + srsran::proc_outcome_t react(const bool& event); + srsran::proc_outcome_t step_wait_measurement(); rrc_interface_phy_lte::cell_search_ret_t get_result() const { return search_result.cs_ret; } static const char* name() { return "Cell Search"; } private: - srslte::proc_outcome_t handle_cell_found(const phy_cell_t& new_cell); + srsran::proc_outcome_t handle_cell_found(const phy_cell_t& new_cell); // conts rrc* rrc_ptr; // state vars phy_controller::cell_srch_res search_result; - srslte::proc_future_t si_acquire_fut; + srsran::proc_future_t si_acquire_fut; state_t state; }; @@ -67,12 +67,12 @@ public: struct sib_received_ev {}; explicit si_acquire_proc(rrc* parent_); - srslte::proc_outcome_t init(uint32_t sib_index_); - srslte::proc_outcome_t step() { return srslte::proc_outcome_t::yield; } + srsran::proc_outcome_t init(uint32_t sib_index_); + srsran::proc_outcome_t step() { return srsran::proc_outcome_t::yield; } static const char* name() { return "SI Acquire"; } - srslte::proc_outcome_t react(si_acq_timer_expired ev); - srslte::proc_outcome_t react(sib_received_ev ev); - void then(const srslte::proc_state_t& result); + srsran::proc_outcome_t react(si_acq_timer_expired ev); + srsran::proc_outcome_t react(sib_received_ev ev); + void then(const srsran::proc_state_t& result); private: void start_si_acquire(); @@ -82,7 +82,7 @@ private: srslog::basic_logger& logger; // state - srslte::timer_handler::unique_timer si_acq_timeout, si_acq_retry_timer; + srsran::timer_handler::unique_timer si_acq_timeout, si_acq_retry_timer; uint32_t period = 0, sched_index = 0; uint32_t sib_index = 0; }; @@ -91,46 +91,46 @@ class rrc::serving_cell_config_proc { public: explicit serving_cell_config_proc(rrc* parent_); - srslte::proc_outcome_t init(const std::vector& required_sibs_); - srslte::proc_outcome_t step(); + srsran::proc_outcome_t init(const std::vector& required_sibs_); + srsran::proc_outcome_t step(); static const char* name() { return "Serving Cell Configuration"; } private: rrc* rrc_ptr; srslog::basic_logger& logger; - srslte::proc_outcome_t launch_sib_acquire(); + srsran::proc_outcome_t launch_sib_acquire(); // proc args std::vector required_sibs; // state variables uint32_t req_idx = 0; - srslte::proc_future_t si_acquire_fut; + srsran::proc_future_t si_acquire_fut; }; class rrc::cell_selection_proc { public: - using cell_selection_complete_ev = srslte::proc_result_t; + using cell_selection_complete_ev = srsran::proc_result_t; explicit cell_selection_proc(rrc* parent_); - srslte::proc_outcome_t init(std::vector required_sibs_ = {}); - srslte::proc_outcome_t step(); + srsran::proc_outcome_t init(std::vector required_sibs_ = {}); + srsran::proc_outcome_t step(); cs_result_t get_result() const { return cs_result; } static const char* name() { return "Cell Selection"; } - srslte::proc_outcome_t react(const bool& event); - void then(const srslte::proc_result_t& proc_result) const; + srsran::proc_outcome_t react(const bool& event); + void then(const srsran::proc_result_t& proc_result) const; private: - srslte::proc_outcome_t start_next_cell_selection(); - srslte::proc_outcome_t step_cell_search(); - srslte::proc_outcome_t step_cell_config(); + srsran::proc_outcome_t start_next_cell_selection(); + srsran::proc_outcome_t step_cell_search(); + srsran::proc_outcome_t step_cell_config(); bool is_serv_cell_suitable() const; bool is_sib_acq_required() const; - srslte::proc_outcome_t set_proc_complete(); - srslte::proc_outcome_t start_phy_cell_selection(const meas_cell_eutra& cell); - srslte::proc_outcome_t start_sib_acquisition(); + srsran::proc_outcome_t set_proc_complete(); + srsran::proc_outcome_t start_phy_cell_selection(const meas_cell_eutra& cell); + srsran::proc_outcome_t start_sib_acquisition(); // consts rrc* rrc_ptr; @@ -142,8 +142,8 @@ private: search_state_t state; uint32_t neigh_index; bool serv_cell_select_attempted = false; - srslte::proc_future_t cell_search_fut; - srslte::proc_future_t serv_cell_cfg_fut; + srsran::proc_future_t cell_search_fut; + srsran::proc_future_t serv_cell_cfg_fut; bool discard_serving = false, cell_search_called = false; std::vector required_sibs = {}; phy_cell_t init_serv_cell; @@ -153,9 +153,9 @@ class rrc::plmn_search_proc { public: explicit plmn_search_proc(rrc* parent_); - srslte::proc_outcome_t init(); - srslte::proc_outcome_t step(); - void then(const srslte::proc_state_t& result) const; + srsran::proc_outcome_t init(); + srsran::proc_outcome_t step(); + void then(const srsran::proc_state_t& result) const; static const char* name() { return "PLMN Search"; } private: @@ -166,17 +166,17 @@ private: // state variables nas_interface_rrc::found_plmn_t found_plmns[nas_interface_rrc::MAX_FOUND_PLMNS]; int nof_plmns = 0; - srslte::proc_future_t cell_search_fut; + srsran::proc_future_t cell_search_fut; }; class rrc::connection_request_proc { public: explicit connection_request_proc(rrc* parent_); - srslte::proc_outcome_t init(srslte::establishment_cause_t cause_, srslte::unique_byte_buffer_t dedicated_info_nas_); - srslte::proc_outcome_t step(); - void then(const srslte::proc_state_t& result); - srslte::proc_outcome_t react(const cell_selection_proc::cell_selection_complete_ev& e); + srsran::proc_outcome_t init(srsran::establishment_cause_t cause_, srsran::unique_byte_buffer_t dedicated_info_nas_); + srsran::proc_outcome_t step(); + void then(const srsran::proc_state_t& result); + srsran::proc_outcome_t react(const cell_selection_proc::cell_selection_complete_ev& e); static const char* name() { return "Connection Request"; } private: @@ -184,24 +184,24 @@ private: rrc* rrc_ptr; srslog::basic_logger& logger; // args - srslte::establishment_cause_t cause; - srslte::unique_byte_buffer_t dedicated_info_nas; + srsran::establishment_cause_t cause; + srsran::unique_byte_buffer_t dedicated_info_nas; // state variables enum class state_t { cell_selection, config_serving_cell, wait_t300 } state; cs_result_t cs_ret; - srslte::proc_future_t serv_cfg_fut; + srsran::proc_future_t serv_cfg_fut; }; class rrc::connection_reconf_no_ho_proc { public: explicit connection_reconf_no_ho_proc(rrc* parent_); - srslte::proc_outcome_t init(const asn1::rrc::rrc_conn_recfg_s& recfg_); - srslte::proc_outcome_t step() { return srslte::proc_outcome_t::yield; } + srsran::proc_outcome_t init(const asn1::rrc::rrc_conn_recfg_s& recfg_); + srsran::proc_outcome_t step() { return srsran::proc_outcome_t::yield; } static const char* name() { return "Connection Reconfiguration"; } - srslte::proc_outcome_t react(const bool& config_complete); - void then(const srslte::proc_state_t& result); + srsran::proc_outcome_t react(const bool& config_complete); + void then(const srsran::proc_state_t& result); private: // const @@ -219,9 +219,9 @@ public: }; explicit process_pcch_proc(rrc* parent_); - srslte::proc_outcome_t init(const asn1::rrc::paging_s& paging_); - srslte::proc_outcome_t step(); - srslte::proc_outcome_t react(paging_complete e); + srsran::proc_outcome_t init(const asn1::rrc::paging_s& paging_); + srsran::proc_outcome_t step(); + srsran::proc_outcome_t react(paging_complete e); static const char* name() { return "Process PCCH"; } private: @@ -233,24 +233,24 @@ private: // vars uint32_t paging_idx = 0; enum class state_t { next_record, nas_paging, serv_cell_cfg } state; - srslte::proc_future_t serv_cfg_fut; + srsran::proc_future_t serv_cfg_fut; }; class rrc::go_idle_proc { public: explicit go_idle_proc(rrc* rrc_); - srslte::proc_outcome_t init(); - srslte::proc_outcome_t step(); - srslte::proc_outcome_t react(bool timeout); + srsran::proc_outcome_t init(); + srsran::proc_outcome_t step(); + srsran::proc_outcome_t react(bool timeout); static const char* name() { return "Go Idle"; } - void then(const srslte::proc_state_t& result); + void then(const srsran::proc_state_t& result); private: static const uint32_t rlc_flush_timeout_ms = 60; // TS 36.331 Sec 5.3.8.3 rrc* rrc_ptr; - srslte::timer_handler::unique_timer rlc_flush_timer; + srsran::timer_handler::unique_timer rlc_flush_timer; }; class rrc::cell_reselection_proc @@ -260,16 +260,16 @@ public: const static uint32_t cell_reselection_periodicity_ms = 20, cell_reselection_periodicity_long_ms = 1000; cell_reselection_proc(rrc* rrc_); - srslte::proc_outcome_t init(); - srslte::proc_outcome_t step(); + srsran::proc_outcome_t init(); + srsran::proc_outcome_t step(); static const char* name() { return "Cell Reselection"; } - void then(const srslte::proc_state_t& result); + void then(const srsran::proc_state_t& result); private: rrc* rrc_ptr; - srslte::timer_handler::unique_timer reselection_timer; - srslte::proc_future_t cell_selection_fut; + srsran::timer_handler::unique_timer reselection_timer; + srsran::proc_future_t cell_selection_fut; cs_result_t cell_sel_result = cs_result_t::no_cell; }; @@ -282,20 +282,20 @@ public: explicit connection_reest_proc(rrc* rrc_); // 5.3.7.2 - Initiation - srslte::proc_outcome_t init(asn1::rrc::reest_cause_e cause); + srsran::proc_outcome_t init(asn1::rrc::reest_cause_e cause); // 5.3.7.3 Actions following cell selection while T311 is running // && 5.3.7.4 - Actions related to transmission of RRCConnectionReestablishmentRequest message - srslte::proc_outcome_t react(const cell_selection_proc::cell_selection_complete_ev& e); + srsran::proc_outcome_t react(const cell_selection_proc::cell_selection_complete_ev& e); // 5.3.7.5 - Reception of the RRCConnectionReestablishment by the UE - srslte::proc_outcome_t react(const asn1::rrc::rrc_conn_reest_s& reest_msg); + srsran::proc_outcome_t react(const asn1::rrc::rrc_conn_reest_s& reest_msg); // 5.3.7.6 - T311 expiry - srslte::proc_outcome_t react(const t311_expiry& ev); + srsran::proc_outcome_t react(const t311_expiry& ev); // 5.3.7.7 - T301 expiry or selected cell no longer suitable - srslte::proc_outcome_t react(const t301_expiry& ev); + srsran::proc_outcome_t react(const t301_expiry& ev); // detects if cell is no longer suitable (part of 5.3.7.7) - srslte::proc_outcome_t step(); + srsran::proc_outcome_t step(); // 5.3.7.8 - Reception of RRCConnectionReestablishmentReject by the UE - srslte::proc_outcome_t react(const asn1::rrc::rrc_conn_reest_reject_s& reest_msg); + srsran::proc_outcome_t react(const asn1::rrc::rrc_conn_reest_reject_s& reest_msg); static const char* name() { return "Connection re-establishment"; } uint32_t get_source_earfcn() const { return reest_source_freq; } @@ -308,8 +308,8 @@ private: uint32_t reest_source_freq = 0, reest_cellid = 0; bool passes_cell_criteria() const; - srslte::proc_outcome_t cell_criteria(); - srslte::proc_outcome_t start_cell_selection(); + srsran::proc_outcome_t cell_criteria(); + srsran::proc_outcome_t start_cell_selection(); }; class rrc::ho_proc @@ -321,12 +321,12 @@ public: }; explicit ho_proc(rrc* rrc_); - srslte::proc_outcome_t init(const asn1::rrc::rrc_conn_recfg_s& rrc_reconf); - srslte::proc_outcome_t react(const bool& ev); - srslte::proc_outcome_t react(t304_expiry ev); - srslte::proc_outcome_t react(ra_completed_ev ev); - srslte::proc_outcome_t step() { return srslte::proc_outcome_t::yield; } - void then(const srslte::proc_state_t& result); + srsran::proc_outcome_t init(const asn1::rrc::rrc_conn_recfg_s& rrc_reconf); + srsran::proc_outcome_t react(const bool& ev); + srsran::proc_outcome_t react(t304_expiry ev); + srsran::proc_outcome_t react(ra_completed_ev ev); + srsran::proc_outcome_t step() { return srsran::proc_outcome_t::yield; } + void then(const srsran::proc_state_t& result); static const char* name() { return "Handover"; } phy_cell_t ho_src_cell; @@ -347,4 +347,4 @@ private: } // namespace srsue -#endif // SRSLTE_RRC_PROCEDURES_H +#endif // SRSRAN_RRC_PROCEDURES_H diff --git a/srsue/hdr/stack/ue_stack_base.h b/srsue/hdr/stack/ue_stack_base.h index bf449386c..d03321763 100644 --- a/srsue/hdr/stack/ue_stack_base.h +++ b/srsue/hdr/stack/ue_stack_base.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/srsue/hdr/stack/ue_stack_lte.h b/srsue/hdr/stack/ue_stack_lte.h index acc6f5611..c0778aa1f 100644 --- a/srsue/hdr/stack/ue_stack_lte.h +++ b/srsue/hdr/stack/ue_stack_lte.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -25,19 +25,19 @@ #include "mac/mac.h" #include "mac_nr/mac_nr.h" #include "rrc/rrc.h" -#include "srslte/radio/radio.h" -#include "srslte/upper/pdcp.h" -#include "srslte/upper/rlc.h" +#include "srsran/radio/radio.h" +#include "srsran/upper/pdcp.h" +#include "srsran/upper/rlc.h" #include "upper/nas.h" #include "upper/usim.h" -#include "srslte/common/buffer_pool.h" -#include "srslte/common/multiqueue.h" -#include "srslte/common/string_helpers.h" -#include "srslte/common/task_scheduler.h" -#include "srslte/common/thread_pool.h" -#include "srslte/common/time_prof.h" -#include "srslte/interfaces/ue_interfaces.h" +#include "srsran/common/buffer_pool.h" +#include "srsran/common/multiqueue.h" +#include "srsran/common/string_helpers.h" +#include "srsran/common/task_scheduler.h" +#include "srsran/common/thread_pool.h" +#include "srsran/common/time_prof.h" +#include "srsran/interfaces/ue_interfaces.h" #include "srsue/hdr/ue_metrics_interface.h" #include "ue_stack_base.h" @@ -50,7 +50,7 @@ class ue_stack_lte final : public ue_stack_base, public stack_interface_phy_nr, public stack_interface_gw, public stack_interface_rrc, - public srslte::thread + public srsran::thread { public: explicit ue_stack_lte(); @@ -101,7 +101,7 @@ public: mac.new_grant_dl(cc_idx, grant, action); } - void tb_decoded(uint32_t cc_idx, mac_grant_dl_t grant, bool ack[SRSLTE_MAX_CODEWORDS]) final + void tb_decoded(uint32_t cc_idx, mac_grant_dl_t grant, bool ack[SRSRAN_MAX_CODEWORDS]) final { mac.tb_decoded(cc_idx, grant, ack); } @@ -113,7 +113,7 @@ public: void mch_decoded(uint32_t len, bool crc) final { mac.mch_decoded(len, crc); } - void new_mch_dl(const srslte_pdsch_grant_t& phy_grant, tb_action_dl_t* action) final + void new_mch_dl(const srsran_pdsch_grant_t& phy_grant, tb_action_dl_t* action) final { mac.new_mch_dl(phy_grant, action); } @@ -123,7 +123,7 @@ public: void run_tti(uint32_t tti, uint32_t tti_jump) final; // MAC Interface for NR PHY - int sf_indication(const uint32_t tti) final { return SRSLTE_SUCCESS; } + int sf_indication(const uint32_t tti) final { return SRSRAN_SUCCESS; } void tb_decoded(const uint32_t cc_idx, mac_nr_grant_dl_t& grant) final { mac_nr.tb_decoded(cc_idx, grant); } void new_grant_ul(const uint32_t cc_idx, @@ -144,14 +144,14 @@ public: } // Interface for GW - void write_sdu(uint32_t lcid, srslte::unique_byte_buffer_t sdu) final; + void write_sdu(uint32_t lcid, srsran::unique_byte_buffer_t sdu) final; bool is_lcid_enabled(uint32_t lcid) final { return pdcp.is_lcid_enabled(lcid); } // Interface for RRC tti_point get_current_tti() final { return current_tti; } - srslte::ext_task_sched_handle get_task_sched() { return {&task_sched}; } + srsran::ext_task_sched_handle get_task_sched() { return {&task_sched}; } private: void run_thread() final; @@ -165,7 +165,7 @@ private: bool running; srsue::stack_args_t args; - srslte::tti_point current_tti; + srsran::tti_point current_tti; // UE stack logging srslog::basic_logger& stack_logger; @@ -177,9 +177,9 @@ private: srslog::basic_logger& nas_logger; // tracing - srslte::mac_pcap mac_pcap; - srslte::mac_pcap mac_nr_pcap; - srslte::nas_pcap nas_pcap; + srsran::mac_pcap mac_pcap; + srsran::mac_pcap mac_nr_pcap; + srsran::nas_pcap nas_pcap; // RAT-specific interfaces phy_interface_stack_lte* phy = nullptr; @@ -188,17 +188,17 @@ private: // Thread static const int STACK_MAIN_THREAD_PRIO = 4; // Next lower priority after PHY workers - srslte::block_queue pending_stack_metrics; + srsran::block_queue pending_stack_metrics; task_scheduler task_sched; - srslte::task_multiqueue::queue_handle sync_task_queue, ue_task_queue, gw_queue_id, cfg_task_queue; + srsran::task_multiqueue::queue_handle sync_task_queue, ue_task_queue, gw_queue_id, cfg_task_queue; // TTI stats - srslte::tprof tti_tprof; + srsran::tprof tti_tprof; // stack components srsue::mac mac; - srslte::rlc rlc; - srslte::pdcp pdcp; + srsran::rlc rlc; + srsran::pdcp pdcp; srsue::rrc rrc; srsue::mac_nr mac_nr; srsue::rrc_nr rrc_nr; diff --git a/srsue/hdr/stack/ue_stack_nr.h b/srsue/hdr/stack/ue_stack_nr.h index d2f07d91a..093f6d1cf 100644 --- a/srsue/hdr/stack/ue_stack_nr.h +++ b/srsue/hdr/stack/ue_stack_nr.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -20,17 +20,17 @@ #include "mac_nr/mac_nr.h" #include "rrc/rrc_nr.h" -#include "srslte/radio/radio.h" -#include "srslte/upper/pdcp.h" -#include "srslte/upper/rlc.h" +#include "srsran/radio/radio.h" +#include "srsran/upper/pdcp.h" +#include "srsran/upper/rlc.h" #include "upper/nas.h" #include "upper/usim.h" -#include "srslte/common/buffer_pool.h" -#include "srslte/common/mac_pcap.h" -#include "srslte/common/multiqueue.h" -#include "srslte/common/thread_pool.h" -#include "srslte/interfaces/ue_nr_interfaces.h" +#include "srsran/common/buffer_pool.h" +#include "srsran/common/mac_pcap.h" +#include "srsran/common/multiqueue.h" +#include "srsran/common/thread_pool.h" +#include "srsran/interfaces/ue_nr_interfaces.h" #include "srsue/hdr/ue_metrics_interface.h" #include "ue_stack_base.h" @@ -46,7 +46,7 @@ class ue_stack_nr final : public ue_stack_base, public stack_interface_phy_nr, public stack_interface_gw, public stack_interface_rrc, - public srslte::thread + public srsran::thread { public: ue_stack_nr(); @@ -78,7 +78,7 @@ public: int sf_indication(const uint32_t tti) { run_tti(tti); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } void tb_decoded(const uint32_t cc_idx, mac_nr_grant_dl_t& grant) final { mac->tb_decoded(cc_idx, grant); } void new_grant_ul(const uint32_t cc_idx, const mac_nr_grant_ul_t& grant, tb_action_ul_t* action) final @@ -91,11 +91,11 @@ public: } // Interface for GW - void write_sdu(uint32_t lcid, srslte::unique_byte_buffer_t sdu) final; + void write_sdu(uint32_t lcid, srsran::unique_byte_buffer_t sdu) final; bool is_lcid_enabled(uint32_t lcid) final { return pdcp->is_lcid_enabled(lcid); } // Interface for RRC - srslte::tti_point get_current_tti() { return srslte::tti_point{0}; }; + srsran::tti_point get_current_tti() { return srsran::tti_point{0}; }; private: void run_thread() final; @@ -106,8 +106,8 @@ private: srsue::stack_args_t args = {}; // task scheduler - srslte::task_scheduler task_sched; - srslte::task_multiqueue::queue_handle sync_task_queue, ue_task_queue, gw_task_queue; + srsran::task_scheduler task_sched; + srsran::task_multiqueue::queue_handle sync_task_queue, ue_task_queue, gw_task_queue; // UE stack logging srslog::basic_logger& mac_logger; @@ -117,8 +117,8 @@ private: // stack components std::unique_ptr mac; std::unique_ptr rrc; - std::unique_ptr rlc; - std::unique_ptr pdcp; + std::unique_ptr rlc; + std::unique_ptr pdcp; // RAT-specific interfaces phy_interface_stack_nr* phy = nullptr; diff --git a/srsue/hdr/stack/upper/gw.h b/srsue/hdr/stack/upper/gw.h index 9161aa36e..fe01461e3 100644 --- a/srsue/hdr/stack/upper/gw.h +++ b/srsue/hdr/stack/upper/gw.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -14,12 +14,12 @@ #define SRSUE_GW_H #include "gw_metrics.h" -#include "srslte/common/buffer_pool.h" -#include "srslte/common/common.h" -#include "srslte/common/interfaces_common.h" -#include "srslte/common/threads.h" -#include "srslte/interfaces/ue_gw_interfaces.h" -#include "srslte/srslog/srslog.h" +#include "srsran/common/buffer_pool.h" +#include "srsran/common/common.h" +#include "srsran/common/interfaces_common.h" +#include "srsran/common/threads.h" +#include "srsran/interfaces/ue_gw_interfaces.h" +#include "srsran/srslog/srslog.h" #include "tft_packet_filter.h" #include #include @@ -38,7 +38,7 @@ struct gw_args_t { std::string tun_dev_netmask; }; -class gw : public gw_interface_stack, public srslte::thread +class gw : public gw_interface_stack, public srsran::thread { public: gw(); @@ -48,8 +48,8 @@ public: void get_metrics(gw_metrics_t& m, const uint32_t nof_tti); // PDCP interface - void write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t pdu); - void write_pdu_mch(uint32_t lcid, srslte::unique_byte_buffer_t pdu); + void write_pdu(uint32_t lcid, srsran::unique_byte_buffer_t pdu); + void write_pdu_mch(uint32_t lcid, srsran::unique_byte_buffer_t pdu); // NAS interface int setup_if_addr(uint32_t eps_bearer_id, @@ -104,7 +104,7 @@ private: // MBSFN int mbsfn_sock_fd = 0; // Sink UDP socket file descriptor struct sockaddr_in mbsfn_sock_addr = {}; // Target address - uint32_t mbsfn_ports[SRSLTE_N_MCH_LCIDS] = {}; // Target ports for MBSFN data + uint32_t mbsfn_ports[SRSRAN_N_MCH_LCIDS] = {}; // Target ports for MBSFN data // TFT tft_pdu_matcher tft_matcher; diff --git a/srsue/hdr/stack/upper/gw_metrics.h b/srsue/hdr/stack/upper/gw_metrics.h index 2319adffa..e6bea6c6e 100644 --- a/srsue/hdr/stack/upper/gw_metrics.h +++ b/srsue/hdr/stack/upper/gw_metrics.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/srsue/hdr/stack/upper/nas.h b/srsue/hdr/stack/upper/nas.h index cd2ac7663..37186d57d 100644 --- a/srsue/hdr/stack/upper/nas.h +++ b/srsue/hdr/stack/upper/nas.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,20 +13,20 @@ #ifndef SRSUE_NAS_H #define SRSUE_NAS_H -#include "srslte/asn1/liblte_mme.h" -#include "srslte/common/buffer_pool.h" -#include "srslte/common/common.h" -#include "srslte/common/nas_pcap.h" -#include "srslte/common/security.h" -#include "srslte/common/stack_procedure.h" -#include "srslte/common/task_scheduler.h" -#include "srslte/interfaces/ue_nas_interfaces.h" -#include "srslte/srslog/srslog.h" +#include "srsran/asn1/liblte_mme.h" +#include "srsran/common/buffer_pool.h" +#include "srsran/common/common.h" +#include "srsran/common/nas_pcap.h" +#include "srsran/common/security.h" +#include "srsran/common/stack_procedure.h" +#include "srsran/common/task_scheduler.h" +#include "srsran/interfaces/ue_nas_interfaces.h" +#include "srsran/srslog/srslog.h" #include "srsue/hdr/stack/upper/nas_config.h" #include "srsue/hdr/stack/upper/nas_emm_state.h" #include "srsue/hdr/stack/upper/nas_metrics.h" -using srslte::byte_buffer_t; +using srsran::byte_buffer_t; namespace srsue { @@ -34,10 +34,10 @@ class usim_interface_nas; class gw_interface_nas; class rrc_interface_nas; -class nas : public nas_interface_rrc, public srslte::timer_callback +class nas : public nas_interface_rrc, public srsran::timer_callback { public: - explicit nas(srslte::task_sched_handle task_sched_); + explicit nas(srsran::task_sched_handle task_sched_); virtual ~nas(); void init(usim_interface_nas* usim_, rrc_interface_nas* rrc_, gw_interface_nas* gw_, const nas_args_t& args_); void stop(); @@ -49,9 +49,9 @@ public: // RRC interface void left_rrc_connected() override; bool connection_request_completed(bool outcome) override; - bool paging(srslte::s_tmsi_t* ue_identity) override; - void set_barring(srslte::barring_t barring) override; - void write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t pdu) override; + bool paging(srsran::s_tmsi_t* ue_identity) override; + void set_barring(srsran::barring_t barring) override; + void write_pdu(uint32_t lcid, srsran::unique_byte_buffer_t pdu) override; uint32_t get_k_enb_count() override; bool get_k_asme(uint8_t* k_asme_, uint32_t n) override; uint32_t get_ipv4_addr() override; @@ -63,7 +63,7 @@ public: bool switch_off(); bool enable_data(); bool disable_data(); - void start_service_request(srslte::establishment_cause_t cause_); + void start_service_request(srsran::establishment_cause_t cause_); // Stack+RRC interface bool is_registered() override; @@ -72,7 +72,7 @@ public: void timer_expired(uint32_t timeout_id) override; // PCAP - void start_pcap(srslte::nas_pcap* pcap_) { pcap = pcap_; } + void start_pcap(srsran::nas_pcap* pcap_) { pcap = pcap_; } private: srslog::basic_logger& logger; @@ -85,12 +85,12 @@ private: nas_args_t cfg = {}; emm_state_t state = {}; - srslte::barring_t current_barring = srslte::barring_t::none; + srsran::barring_t current_barring = srsran::barring_t::none; - srslte::plmn_id_t current_plmn; - srslte::plmn_id_t home_plmn; + srsran::plmn_id_t current_plmn; + srsran::plmn_id_t home_plmn; - std::vector known_plmns; + std::vector known_plmns; // Security context struct nas_sec_ctxt { @@ -99,8 +99,8 @@ private: uint32_t tx_count; uint32_t rx_count; uint32_t k_enb_count; - srslte::CIPHERING_ALGORITHM_ID_ENUM cipher_algo; - srslte::INTEGRITY_ALGORITHM_ID_ENUM integ_algo; + srsran::CIPHERING_ALGORITHM_ID_ENUM cipher_algo; + srsran::INTEGRITY_ALGORITHM_ID_ENUM integ_algo; LIBLTE_MME_EPS_MOBILE_ID_GUTI_STRUCT guti; }; @@ -133,12 +133,12 @@ private: uint8_t transaction_id = 0; // timers - srslte::task_sched_handle task_sched; - srslte::timer_handler::unique_timer t3402; // started when attach attempt counter reached 5 - srslte::timer_handler::unique_timer t3410; // started when attach request is sent, on expiry, start t3411 - srslte::timer_handler::unique_timer t3411; // started when attach failed - srslte::timer_handler::unique_timer t3421; // started when detach request is sent - srslte::timer_handler::unique_timer reattach_timer; // started to trigger delayed re-attach + srsran::task_sched_handle task_sched; + srsran::timer_handler::unique_timer t3402; // started when attach attempt counter reached 5 + srsran::timer_handler::unique_timer t3410; // started when attach request is sent, on expiry, start t3411 + srsran::timer_handler::unique_timer t3411; // started when attach failed + srsran::timer_handler::unique_timer t3421; // started when detach request is sent + srsran::timer_handler::unique_timer reattach_timer; // started to trigger delayed re-attach // Values according to TS 24.301 Sec 10.2 const uint32_t t3402_duration_ms = 12 * 60 * 1000; // 12m @@ -161,24 +161,24 @@ private: // Airplane mode simulation typedef enum { DISABLED = 0, ENABLED } airplane_mode_state_t; airplane_mode_state_t airplane_mode_state = {}; - srslte::timer_handler::unique_timer airplane_mode_sim_timer; + srsran::timer_handler::unique_timer airplane_mode_sim_timer; // PCAP - srslte::nas_pcap* pcap = nullptr; + srsran::nas_pcap* pcap = nullptr; // Security void integrity_generate(uint8_t* key_128, uint32_t count, uint8_t direction, uint8_t* msg, uint32_t msg_len, uint8_t* mac); - bool integrity_check(srslte::byte_buffer_t* pdu); - void cipher_encrypt(srslte::byte_buffer_t* pdu); - void cipher_decrypt(srslte::byte_buffer_t* pdu); - int apply_security_config(srslte::unique_byte_buffer_t& pdu, uint8_t sec_hdr_type); + bool integrity_check(srsran::byte_buffer_t* pdu); + void cipher_encrypt(srsran::byte_buffer_t* pdu); + void cipher_decrypt(srsran::byte_buffer_t* pdu); + int apply_security_config(srsran::unique_byte_buffer_t& pdu, uint8_t sec_hdr_type); void reset_security_context(); void set_k_enb_count(uint32_t count); bool check_cap_replay(LIBLTE_MME_UE_SECURITY_CAPABILITIES_STRUCT* caps); // NAS Connection Initiation/Termination - void start_attach_request(srslte::establishment_cause_t cause_); + void start_attach_request(srsran::establishment_cause_t cause_); bool detach_request(const bool switch_off); // PLMN Selection Helpers @@ -186,26 +186,26 @@ private: void select_plmn(); // Parsers - void parse_attach_accept(uint32_t lcid, srslte::unique_byte_buffer_t pdu); - void parse_attach_reject(uint32_t lcid, srslte::unique_byte_buffer_t pdu); - void parse_authentication_request(uint32_t lcid, srslte::unique_byte_buffer_t pdu, const uint8_t sec_hdr_type); - void parse_authentication_reject(uint32_t lcid, srslte::unique_byte_buffer_t pdu); - void parse_identity_request(srslte::unique_byte_buffer_t pdu, const uint8_t sec_hdr_type); - void parse_security_mode_command(uint32_t lcid, srslte::unique_byte_buffer_t pdu); - void parse_service_reject(uint32_t lcid, srslte::unique_byte_buffer_t pdu); - void parse_esm_information_request(uint32_t lcid, srslte::unique_byte_buffer_t pdu); - void parse_emm_information(uint32_t lcid, srslte::unique_byte_buffer_t pdu); - void parse_detach_request(uint32_t lcid, srslte::unique_byte_buffer_t pdu); - void parse_emm_status(uint32_t lcid, srslte::unique_byte_buffer_t pdu); - void parse_activate_dedicated_eps_bearer_context_request(uint32_t lcid, srslte::unique_byte_buffer_t pdu); - void parse_deactivate_eps_bearer_context_request(srslte::unique_byte_buffer_t pdu); - void parse_activate_test_mode(uint32_t lcid, srslte::unique_byte_buffer_t pdu); - void parse_close_ue_test_loop(uint32_t lcid, srslte::unique_byte_buffer_t pdu); - void parse_modify_eps_bearer_context_request(srslte::unique_byte_buffer_t pdu); + void parse_attach_accept(uint32_t lcid, srsran::unique_byte_buffer_t pdu); + void parse_attach_reject(uint32_t lcid, srsran::unique_byte_buffer_t pdu); + void parse_authentication_request(uint32_t lcid, srsran::unique_byte_buffer_t pdu, const uint8_t sec_hdr_type); + void parse_authentication_reject(uint32_t lcid, srsran::unique_byte_buffer_t pdu); + void parse_identity_request(srsran::unique_byte_buffer_t pdu, const uint8_t sec_hdr_type); + void parse_security_mode_command(uint32_t lcid, srsran::unique_byte_buffer_t pdu); + void parse_service_reject(uint32_t lcid, srsran::unique_byte_buffer_t pdu); + void parse_esm_information_request(uint32_t lcid, srsran::unique_byte_buffer_t pdu); + void parse_emm_information(uint32_t lcid, srsran::unique_byte_buffer_t pdu); + void parse_detach_request(uint32_t lcid, srsran::unique_byte_buffer_t pdu); + void parse_emm_status(uint32_t lcid, srsran::unique_byte_buffer_t pdu); + void parse_activate_dedicated_eps_bearer_context_request(uint32_t lcid, srsran::unique_byte_buffer_t pdu); + void parse_deactivate_eps_bearer_context_request(srsran::unique_byte_buffer_t pdu); + void parse_activate_test_mode(uint32_t lcid, srsran::unique_byte_buffer_t pdu); + void parse_close_ue_test_loop(uint32_t lcid, srsran::unique_byte_buffer_t pdu); + void parse_modify_eps_bearer_context_request(srsran::unique_byte_buffer_t pdu); // Packet generators - void gen_attach_request(srslte::unique_byte_buffer_t& msg); - void gen_service_request(srslte::unique_byte_buffer_t& msg); + void gen_attach_request(srsran::unique_byte_buffer_t& msg); + void gen_service_request(srsran::unique_byte_buffer_t& msg); // Senders void send_attach_complete(const uint8_t& transaction_id, const uint8_t& eps_bearer_id); @@ -291,8 +291,8 @@ private: // NAS Idle procedures class plmn_search_proc; // PLMN selection proc (fwd declared) - srslte::proc_manager_list_t callbacks; - srslte::proc_t plmn_searcher; + srsran::proc_manager_list_t callbacks; + srsran::proc_t plmn_searcher; const std::string gw_setup_failure_str = "Failed to setup/configure GW interface"; }; diff --git a/srsue/hdr/stack/upper/nas_config.h b/srsue/hdr/stack/upper/nas_config.h index 4a61a5bc8..b185c75a5 100644 --- a/srsue/hdr/stack/upper/nas_config.h +++ b/srsue/hdr/stack/upper/nas_config.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/srsue/hdr/stack/upper/nas_emm_state.h b/srsue/hdr/stack/upper/nas_emm_state.h index fefac3eaf..de53e538f 100644 --- a/srsue/hdr/stack/upper/nas_emm_state.h +++ b/srsue/hdr/stack/upper/nas_emm_state.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,7 +13,7 @@ #ifndef SRSUE_NAS_EMM_STATE_H #define SRSUE_NAS_EMM_STATE_H -#include "srslte/srslog/srslog.h" +#include "srsran/srslog/srslog.h" #include #include diff --git a/srsue/hdr/stack/upper/nas_idle_procedures.h b/srsue/hdr/stack/upper/nas_idle_procedures.h index 851022cf1..55e043502 100644 --- a/srsue/hdr/stack/upper/nas_idle_procedures.h +++ b/srsue/hdr/stack/upper/nas_idle_procedures.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -17,7 +17,7 @@ #ifndef SRSUE_NAS_IDLE_PROCEDURES_H #define SRSUE_NAS_IDLE_PROCEDURES_H -#include "srslte/common/stack_procedure.h" +#include "srsran/common/stack_procedure.h" #include "srsue/hdr/stack/upper/nas.h" namespace srsue { @@ -37,10 +37,10 @@ public: }; explicit plmn_search_proc(nas* nas_ptr_) : nas_ptr(nas_ptr_) {} - srslte::proc_outcome_t init(); - srslte::proc_outcome_t step(); - void then(const srslte::proc_state_t& result); - srslte::proc_outcome_t react(const plmn_search_complete_t& t); + srsran::proc_outcome_t init(); + srsran::proc_outcome_t step(); + void then(const srsran::proc_state_t& result); + srsran::proc_outcome_t react(const plmn_search_complete_t& t); static const char* name() { return "NAS PLMN Search"; } private: diff --git a/srsue/hdr/stack/upper/nas_metrics.h b/srsue/hdr/stack/upper/nas_metrics.h index 90809b4f0..ad26e45f6 100644 --- a/srsue/hdr/stack/upper/nas_metrics.h +++ b/srsue/hdr/stack/upper/nas_metrics.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/srsue/hdr/stack/upper/pcsc_usim.h b/srsue/hdr/stack/upper/pcsc_usim.h index 096a6e54a..bd47a5ac8 100644 --- a/srsue/hdr/stack/upper/pcsc_usim.h +++ b/srsue/hdr/stack/upper/pcsc_usim.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,8 +13,8 @@ #ifndef SRSUE_PCSC_USIM_H #define SRSUE_PCSC_USIM_H -#include "srslte/common/common.h" -#include "srslte/common/security.h" +#include "srsran/common/common.h" +#include "srsran/common/security.h" #include "srsue/hdr/stack/upper/usim.h" #include #include diff --git a/srsue/hdr/stack/upper/tft_packet_filter.h b/srsue/hdr/stack/upper/tft_packet_filter.h index 6c76f691d..b7c806096 100644 --- a/srsue/hdr/stack/upper/tft_packet_filter.h +++ b/srsue/hdr/stack/upper/tft_packet_filter.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,9 +13,9 @@ #ifndef SRSUE_PACKET_FILTER_H #define SRSUE_PACKET_FILTER_H -#include "srslte/asn1/liblte_mme.h" -#include "srslte/common/buffer_pool.h" -#include "srslte/srslog/srslog.h" +#include "srsran/asn1/liblte_mme.h" +#include "srsran/common/buffer_pool.h" +#include "srsran/srslog/srslog.h" #include namespace srsue { @@ -62,7 +62,7 @@ public: uint8_t lcid_, const LIBLTE_MME_PACKET_FILTER_STRUCT& tft_, srslog::basic_logger& logger); - bool match(const srslte::unique_byte_buffer_t& pdu); + bool match(const srsran::unique_byte_buffer_t& pdu); bool filter_contains(uint16_t filtertype); uint8_t eps_bearer_id{}; @@ -92,11 +92,11 @@ public: srslog::basic_logger& logger; - bool match_ip(const srslte::unique_byte_buffer_t& pdu); - bool match_protocol(const srslte::unique_byte_buffer_t& pdu); - bool match_type_of_service(const srslte::unique_byte_buffer_t& pdu); - bool match_flow_label(const srslte::unique_byte_buffer_t& pdu); - bool match_port(const srslte::unique_byte_buffer_t& pdu); + bool match_ip(const srsran::unique_byte_buffer_t& pdu); + bool match_protocol(const srsran::unique_byte_buffer_t& pdu); + bool match_type_of_service(const srsran::unique_byte_buffer_t& pdu); + bool match_flow_label(const srsran::unique_byte_buffer_t& pdu); + bool match_port(const srsran::unique_byte_buffer_t& pdu); }; /** @@ -109,7 +109,7 @@ public: ~tft_pdu_matcher(){}; void set_default_lcid(const uint8_t lcid); - uint8_t check_tft_filter_match(const srslte::unique_byte_buffer_t& pdu); + uint8_t check_tft_filter_match(const srsran::unique_byte_buffer_t& pdu); int apply_traffic_flow_template(const uint8_t& erab_id, const uint8_t& lcid, const LIBLTE_MME_TRAFFIC_FLOW_TEMPLATE_STRUCT* tft); diff --git a/srsue/hdr/stack/upper/usim.h b/srsue/hdr/stack/upper/usim.h index f4bf1bb0e..72982f883 100644 --- a/srsue/hdr/stack/upper/usim.h +++ b/srsue/hdr/stack/upper/usim.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,8 +13,8 @@ #ifndef SRSUE_USIM_H #define SRSUE_USIM_H -#include "srslte/common/common.h" -#include "srslte/common/security.h" +#include "srsran/common/common.h" +#include "srsran/common/security.h" #include "usim_base.h" #include diff --git a/srsue/hdr/stack/upper/usim_base.h b/srsue/hdr/stack/upper/usim_base.h index 729002966..bb26040b7 100644 --- a/srsue/hdr/stack/upper/usim_base.h +++ b/srsue/hdr/stack/upper/usim_base.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,10 +13,10 @@ #ifndef SRSUE_USIM_BASE_H #define SRSUE_USIM_BASE_H -#include "srslte/common/common.h" -#include "srslte/common/security.h" -#include "srslte/interfaces/ue_usim_interfaces.h" -#include "srslte/srslog/srslog.h" +#include "srsran/common/common.h" +#include "srsran/common/security.h" +#include "srsran/interfaces/ue_usim_interfaces.h" +#include "srsran/srslog/srslog.h" #include namespace srsue { @@ -70,7 +70,7 @@ public: bool get_imsi_vec(uint8_t* imsi_, uint32_t n) final; bool get_imei_vec(uint8_t* imei_, uint32_t n) final; - bool get_home_plmn_id(srslte::plmn_id_t* home_plmn_id) final; + bool get_home_plmn_id(srsran::plmn_id_t* home_plmn_id) final; virtual auth_result_t generate_authentication_response(uint8_t* rand, uint8_t* autn_enb, @@ -83,18 +83,18 @@ public: void generate_nas_keys(uint8_t* k_asme, uint8_t* k_nas_enc, uint8_t* k_nas_int, - srslte::CIPHERING_ALGORITHM_ID_ENUM cipher_algo, - srslte::INTEGRITY_ALGORITHM_ID_ENUM integ_algo) final; + srsran::CIPHERING_ALGORITHM_ID_ENUM cipher_algo, + srsran::INTEGRITY_ALGORITHM_ID_ENUM integ_algo) final; // RRC interface - void generate_as_keys(uint8_t* k_asme, uint32_t count_ul, srslte::as_security_config_t* sec_cfg) final; - void generate_as_keys_ho(uint32_t pci, uint32_t earfcn, int ncc, srslte::as_security_config_t* sec_cfg) final; - void store_keys_before_ho(const srslte::as_security_config_t& as_ctx) final; - void restore_keys_from_failed_ho(srslte::as_security_config_t* as_ctx) final; + void generate_as_keys(uint8_t* k_asme, uint32_t count_ul, srsran::as_security_config_t* sec_cfg) final; + void generate_as_keys_ho(uint32_t pci, uint32_t earfcn, int ncc, srsran::as_security_config_t* sec_cfg) final; + void store_keys_before_ho(const srsran::as_security_config_t& as_ctx) final; + void restore_keys_from_failed_ho(srsran::as_security_config_t* as_ctx) final; // NR RRC interface - void generate_nr_context(uint16_t sk_counter, srslte::as_security_config_t* sec_cfg) final; - void update_nr_context(srslte::as_security_config_t* sec_cfg) final; + void generate_nr_context(uint16_t sk_counter, srsran::as_security_config_t* sec_cfg) final; + void update_nr_context(srsran::as_security_config_t* sec_cfg) final; // Helpers std::string get_mcc_str(const uint8_t* imsi_vec); @@ -123,12 +123,12 @@ protected: uint8_t auts[AKA_AUTS_LEN] = {}; // Current K_eNB context (K_eNB, NH and NCC) - srslte::k_enb_context_t k_enb_ctx = {}; - srslte::k_gnb_context_t k_gnb_ctx = {}; + srsran::k_enb_context_t k_enb_ctx = {}; + srsran::k_gnb_context_t k_gnb_ctx = {}; // Helpers to restore security context if HO fails - srslte::k_enb_context_t old_k_enb_ctx = {}; - srslte::as_security_config_t old_as_ctx = {}; + srsran::k_enb_context_t old_k_enb_ctx = {}; + srsran::as_security_config_t old_as_ctx = {}; }; } // namespace srsue diff --git a/srsue/hdr/ue.h b/srsue/hdr/ue.h index 79ede96d9..3f93425bb 100644 --- a/srsue/hdr/ue.h +++ b/srsue/hdr/ue.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -24,10 +24,10 @@ #include #include "phy/ue_phy_base.h" -#include "srslte/common/buffer_pool.h" -#include "srslte/radio/radio.h" -#include "srslte/srslog/srslog.h" -#include "srslte/system/sys_metrics_processor.h" +#include "srsran/common/buffer_pool.h" +#include "srsran/radio/radio.h" +#include "srsran/srslog/srslog.h" +#include "srsran/system/sys_metrics_processor.h" #include "stack/ue_stack_base.h" #include "ue_metrics_interface.h" @@ -67,7 +67,7 @@ typedef struct { } general_args_t; typedef struct { - srslte::rf_args_t rf; + srsran::rf_args_t rf; trace_args_t trace; log_args_t log; gui_args_t gui; @@ -103,7 +103,7 @@ public: private: // UE consists of a radio, a PHY and a stack element std::unique_ptr phy; - std::unique_ptr radio; + std::unique_ptr radio; std::unique_ptr stack; std::unique_ptr gw_inst; @@ -111,7 +111,7 @@ private: srslog::basic_logger& logger; // System metrics processor. - srslte::sys_metrics_processor sys_proc; + srsran::sys_metrics_processor sys_proc; all_args_t args; diff --git a/srsue/hdr/ue_metrics_interface.h b/srsue/hdr/ue_metrics_interface.h index d5bd6f9a2..725cbcb51 100644 --- a/srsue/hdr/ue_metrics_interface.h +++ b/srsue/hdr/ue_metrics_interface.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -16,10 +16,10 @@ #include #include "phy/phy_metrics.h" -#include "srslte/common/metrics_hub.h" -#include "srslte/radio/radio_metrics.h" -#include "srslte/system/sys_metrics.h" -#include "srslte/upper/rlc_metrics.h" +#include "srsran/common/metrics_hub.h" +#include "srsran/radio/radio_metrics.h" +#include "srsran/system/sys_metrics.h" +#include "srsran/upper/rlc_metrics.h" #include "stack/mac/mac_metrics.h" #include "stack/rrc/rrc_metrics.h" #include "stack/upper/gw_metrics.h" @@ -29,22 +29,22 @@ namespace srsue { typedef struct { uint32_t ul_dropped_sdus; - mac_metrics_t mac[SRSLTE_MAX_CARRIERS]; - srslte::rlc_metrics_t rlc; + mac_metrics_t mac[SRSRAN_MAX_CARRIERS]; + srsran::rlc_metrics_t rlc; nas_metrics_t nas; rrc_metrics_t rrc; } stack_metrics_t; typedef struct { - srslte::rf_metrics_t rf; + srsran::rf_metrics_t rf; phy_metrics_t phy; gw_metrics_t gw; stack_metrics_t stack; - srslte::sys_metrics_t sys; + srsran::sys_metrics_t sys; } ue_metrics_t; // UE interface -class ue_metrics_interface : public srslte::metrics_interface +class ue_metrics_interface : public srsran::metrics_interface { public: virtual bool get_metrics(ue_metrics_t* m) = 0; diff --git a/srsue/src/CMakeLists.txt b/srsue/src/CMakeLists.txt index 6ab94f1d0..48c2c89e3 100644 --- a/srsue/src/CMakeLists.txt +++ b/srsue/src/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -21,13 +21,13 @@ endif (RPATH) add_executable(srsue main.cc ue.cc metrics_stdout.cc metrics_csv.cc) set(SRSUE_SOURCES srsue_phy srsue_stack srsue_upper srsue_mac srsue_rrc srslog system) -set(SRSLTE_SOURCES srslte_common srslte_mac srslte_phy srslte_radio srslte_upper rrc_asn1 srslog system) +set(SRSRAN_SOURCES srsran_common srsran_mac srsran_phy srsran_radio srsran_upper rrc_asn1 srslog system) set(SRSUE_SOURCES ${SRSUE_SOURCES} srsue_nr_stack srsue_rrc_nr srsue_mac_nr) -set(SRSLTE_SOURCES ${SRSLTE_SOURCES} rrc_nr_asn1 ngap_nr_asn1) +set(SRSRAN_SOURCES ${SRSRAN_SOURCES} rrc_nr_asn1 ngap_nr_asn1) target_link_libraries(srsue ${SRSUE_SOURCES} - ${SRSLTE_SOURCES} + ${SRSRAN_SOURCES} ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES}) diff --git a/srsue/src/main.cc b/srsue/src/main.cc index 24e48402c..66a44a02b 100644 --- a/srsue/src/main.cc +++ b/srsue/src/main.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,15 +10,15 @@ * */ -#include "srslte/common/common_helper.h" -#include "srslte/common/config_file.h" -#include "srslte/common/crash_handler.h" -#include "srslte/common/metrics_hub.h" -#include "srslte/common/signal_handler.h" -#include "srslte/srslog/event_trace.h" -#include "srslte/srslog/srslog.h" -#include "srslte/srslte.h" -#include "srslte/version.h" +#include "srsran/common/common_helper.h" +#include "srsran/common/config_file.h" +#include "srsran/common/crash_handler.h" +#include "srsran/common/metrics_hub.h" +#include "srsran/common/signal_handler.h" +#include "srsran/srslog/event_trace.h" +#include "srsran/srslog/srslog.h" +#include "srsran/srsran.h" +#include "srsran/version.h" #include "srsue/hdr/metrics_csv.h" #include "srsue/hdr/metrics_stdout.h" #include "srsue/hdr/ue.h" @@ -117,10 +117,10 @@ static int parse_args(all_args_t* args, int argc, char* argv[]) ("rrc.feature_group", bpo::value(&args->stack.rrc.feature_group)->default_value(0xe6041000), "Hex value of the featureGroupIndicators field in the" "UECapabilityInformation message. Default 0xe6041000") - ("rrc.ue_category", bpo::value(&args->stack.rrc.ue_category_str)->default_value(SRSLTE_UE_CATEGORY_DEFAULT), "UE Category (1 to 10)") + ("rrc.ue_category", bpo::value(&args->stack.rrc.ue_category_str)->default_value(SRSRAN_UE_CATEGORY_DEFAULT), "UE Category (1 to 10)") ("rrc.ue_category_dl", bpo::value(&args->stack.rrc.ue_category_dl)->default_value(-1), "UE Category DL v12 (valid values: 0, 4, 6, 7, 9 to 16)") ("rrc.ue_category_ul", bpo::value(&args->stack.rrc.ue_category_ul)->default_value(-1), "UE Category UL v12 (valid values: 0, 3, 5, 7, 8 and 13)") - ("rrc.release", bpo::value(&args->stack.rrc.release)->default_value(SRSLTE_RELEASE_DEFAULT), "UE Release (8 to 12)") + ("rrc.release", bpo::value(&args->stack.rrc.release)->default_value(SRSRAN_RELEASE_DEFAULT), "UE Release (8 to 12)") ("rrc.mbms_service_id", bpo::value(&args->stack.rrc.mbms_service_id)->default_value(-1), "MBMS service id for autostart (-1 means disabled)") ("rrc.mbms_service_port", bpo::value(&args->stack.rrc.mbms_service_port)->default_value(4321), "Port of the MBMS service") @@ -463,27 +463,27 @@ static int parse_args(all_args_t* args, int argc, char* argv[]) bpo::notify(vm); } catch (bpo::error& e) { cerr << e.what() << endl; - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // help option was given - print usage and exit if (vm.count("help")) { cout << "Usage: " << argv[0] << " [OPTIONS] config_file" << endl << endl; cout << common << endl << general << endl; - exit(SRSLTE_SUCCESS); + exit(SRSRAN_SUCCESS); } // print version number and exit if (vm.count("version")) { - cout << "Version " << srslte_get_version_major() << "." << srslte_get_version_minor() << "." - << srslte_get_version_patch() << endl; - exit(SRSLTE_SUCCESS); + cout << "Version " << srsran_get_version_major() << "." << srsran_get_version_minor() << "." + << srsran_get_version_patch() << endl; + exit(SRSRAN_SUCCESS); } // if no config file given, check users home path if (!vm.count("config_file")) { if (!config_exists(config_file, "ue.conf")) { cout << "Failed to read UE configuration file " << config_file << " - exiting" << endl; - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } @@ -491,7 +491,7 @@ static int parse_args(all_args_t* args, int argc, char* argv[]) ifstream conf(config_file.c_str(), ios::in); if (conf.fail()) { cout << "Failed to read configuration file " << config_file << " - exiting" << endl; - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // parse config file and handle errors gracefully @@ -500,13 +500,13 @@ static int parse_args(all_args_t* args, int argc, char* argv[]) bpo::notify(vm); } catch (const boost::program_options::error& e) { cerr << e.what() << endl; - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Check conflicting OP/OPc options and which is being used if (vm.count("usim.op") && !vm["usim.op"].defaulted() && vm.count("usim.opc") && !vm["usim.opc"].defaulted()) { cout << "Conflicting options OP and OPc. Please configure either one or the other." << endl; - return SRSLTE_ERROR; + return SRSRAN_ERROR; } else { args->stack.usim.using_op = vm.count("usim.op"); } @@ -587,9 +587,9 @@ static int parse_args(all_args_t* args, int argc, char* argv[]) args->stack.sync_queue_size = MULTIQUEUE_DEFAULT_CAPACITY; } - srslte_use_standard_symbol_size(use_standard_lte_rates); + srsran_use_standard_symbol_size(use_standard_lte_rates); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } static void* input_loop(void*) @@ -631,8 +631,8 @@ static size_t fixup_log_file_maxsize(int x) int main(int argc, char* argv[]) { - srslte_register_signal_handler(); - srslte_debug_handle_crash(argc, argv); + srsran_register_signal_handler(); + srsran_debug_handle_crash(argc, argv); all_args_t args = {}; if (int err = parse_args(&args, argc, argv)) { @@ -644,18 +644,18 @@ int main(int argc, char* argv[]) ? srslog::create_stdout_sink() : srslog::create_file_sink(args.log.filename, fixup_log_file_maxsize(args.log.file_max_size)); if (!log_sink) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } srslog::log_channel* chan = srslog::create_log_channel("main_channel", *log_sink); if (!chan) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } srslog::set_default_sink(*log_sink); #ifdef ENABLE_SRSLOG_EVENT_TRACE if (args.general.tracing_enable) { if (!srslog::event_trace_init(args.general.tracing_filename, args.general.tracing_buffcapacity)) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } #endif @@ -663,18 +663,18 @@ int main(int argc, char* argv[]) // Start the log backend. srslog::init(); - srslte::log_args(argc, argv, "UE"); + srsran::log_args(argc, argv, "UE"); - srslte::check_scaling_governor(args.rf.device_name); + srsran::check_scaling_governor(args.rf.device_name); // Create UE instance. srsue::ue ue; if (ue.init(args)) { ue.stop(); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } - srslte::metrics_hub metricshub; + srsran::metrics_hub metricshub; metrics_stdout _metrics_screen; metrics_screen = &_metrics_screen; @@ -713,5 +713,5 @@ int main(int argc, char* argv[]) ue.stop(); cout << "--- exiting ---" << endl; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } diff --git a/srsue/src/metrics_csv.cc b/srsue/src/metrics_csv.cc index 081c11a54..e0b19caf4 100644 --- a/srsue/src/metrics_csv.cc +++ b/srsue/src/metrics_csv.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -156,7 +156,7 @@ void metrics_csv::set_metrics(const ue_metrics_t& metrics, const uint32_t period file << (metrics.stack.rrc.state == RRC_STATE_CONNECTED ? "1.0" : "0.0") << ";"; // Write system metrics. - const srslte::sys_metrics_t& m = metrics.sys; + const srsran::sys_metrics_t& m = metrics.sys; file << float_to_string(m.process_realmem, 2); file << std::to_string(m.process_realmem_kB) << ";"; file << float_to_string(m.process_virtualmem, 2); diff --git a/srsue/src/metrics_stdout.cc b/srsue/src/metrics_stdout.cc index d428bf14e..953d3d066 100644 --- a/srsue/src/metrics_stdout.cc +++ b/srsue/src/metrics_stdout.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -174,7 +174,7 @@ std::string metrics_stdout::float_to_string(float f, int digits) { std::ostringstream os; const int precision = - SRSLTE_MIN((int)((f == 0.0f || f == 100.0f) ? digits - 1 : digits - log10f(fabsf(f)) - 2 * FLT_EPSILON), 3); + SRSRAN_MIN((int)((f == 0.0f || f == 100.0f) ? digits - 1 : digits - log10f(fabsf(f)) - 2 * FLT_EPSILON), 3); os << std::setw(6) << std::fixed << std::setprecision(precision) << f; return os.str(); } diff --git a/srsue/src/phy/CMakeLists.txt b/srsue/src/phy/CMakeLists.txt index 938811702..bc668bb57 100644 --- a/srsue/src/phy/CMakeLists.txt +++ b/srsue/src/phy/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of diff --git a/srsue/src/phy/lte/cc_worker.cc b/srsue/src/phy/lte/cc_worker.cc index d9aaa251e..196907de5 100644 --- a/srsue/src/phy/lte/cc_worker.cc +++ b/srsue/src/phy/lte/cc_worker.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,22 +10,22 @@ * */ -#include "srslte/srslte.h" +#include "srsran/srsran.h" -#include "srslte/common/standard_streams.h" +#include "srsran/common/standard_streams.h" #include "srsue/hdr/phy/lte/cc_worker.h" #define Error(fmt, ...) \ - if (SRSLTE_DEBUG_ENABLED) \ + if (SRSRAN_DEBUG_ENABLED) \ logger.error(fmt, ##__VA_ARGS__) #define Warning(fmt, ...) \ - if (SRSLTE_DEBUG_ENABLED) \ + if (SRSRAN_DEBUG_ENABLED) \ logger.warning(fmt, ##__VA_ARGS__) #define Info(fmt, ...) \ - if (SRSLTE_DEBUG_ENABLED) \ + if (SRSRAN_DEBUG_ENABLED) \ logger.info(fmt, ##__VA_ARGS__) #define Debug(fmt, ...) \ - if (SRSLTE_DEBUG_ENABLED) \ + if (SRSRAN_DEBUG_ENABLED) \ logger.debug(fmt, ##__VA_ARGS__) #define CURRENT_TTI (sf_cfg_dl.tti) @@ -47,27 +47,27 @@ cc_worker::cc_worker(uint32_t cc_idx_, uint32_t max_prb, srsue::phy_common* phy_ cc_idx = cc_idx_; phy = phy_; - signal_buffer_max_samples = 3 * SRSLTE_SF_LEN_PRB(max_prb); + signal_buffer_max_samples = 3 * SRSRAN_SF_LEN_PRB(max_prb); for (uint32_t i = 0; i < phy->args->nof_rx_ant; i++) { - signal_buffer_rx[i] = srslte_vec_cf_malloc(signal_buffer_max_samples); + signal_buffer_rx[i] = srsran_vec_cf_malloc(signal_buffer_max_samples); if (!signal_buffer_rx[i]) { Error("Allocating memory"); return; } - signal_buffer_tx[i] = srslte_vec_cf_malloc(signal_buffer_max_samples); + signal_buffer_tx[i] = srsran_vec_cf_malloc(signal_buffer_max_samples); if (!signal_buffer_tx[i]) { Error("Allocating memory"); return; } } - if (srslte_ue_dl_init(&ue_dl, signal_buffer_rx, max_prb, phy->args->nof_rx_ant)) { + if (srsran_ue_dl_init(&ue_dl, signal_buffer_rx, max_prb, phy->args->nof_rx_ant)) { Error("Initiating UE DL"); return; } - if (srslte_ue_ul_init(&ue_ul, signal_buffer_tx[0], max_prb)) { + if (srsran_ue_ul_init(&ue_ul, signal_buffer_tx[0], max_prb)) { Error("Initiating UE UL"); return; } @@ -78,10 +78,10 @@ cc_worker::cc_worker(uint32_t cc_idx_, uint32_t max_prb, srsue::phy_common* phy_ phy->set_pdsch_cfg(&pmch_cfg.pdsch_cfg); // set same config in PMCH decoder // Define MBSFN subframes channel estimation and save default one - chest_mbsfn_cfg.filter_type = SRSLTE_CHEST_FILTER_TRIANGLE; + chest_mbsfn_cfg.filter_type = SRSRAN_CHEST_FILTER_TRIANGLE; chest_mbsfn_cfg.filter_coef[0] = 0.1; - chest_mbsfn_cfg.estimator_alg = SRSLTE_ESTIMATOR_ALG_INTERPOLATE; - chest_mbsfn_cfg.noise_alg = SRSLTE_NOISE_ALG_PSS; + chest_mbsfn_cfg.estimator_alg = SRSRAN_ESTIMATOR_ALG_INTERPOLATE; + chest_mbsfn_cfg.noise_alg = SRSRAN_NOISE_ALG_PSS; chest_default_cfg = ue_dl_cfg.chest_cfg; @@ -104,14 +104,14 @@ cc_worker::~cc_worker() free(signal_buffer_rx[i]); } } - srslte_ue_dl_free(&ue_dl); - srslte_ue_ul_free(&ue_ul); + srsran_ue_dl_free(&ue_dl); + srsran_ue_ul_free(&ue_ul); } void cc_worker::reset() { // constructor sets defaults - srslte::phy_cfg_t empty_cfg; + srsran::phy_cfg_t empty_cfg; set_config_unlocked(empty_cfg); } @@ -120,28 +120,28 @@ void cc_worker::reset_cell_unlocked() cell_initiated = false; } -bool cc_worker::set_cell_unlocked(srslte_cell_t cell_) +bool cc_worker::set_cell_unlocked(srsran_cell_t cell_) { if (cell.id != cell_.id || !cell_initiated) { cell = cell_; - if (srslte_ue_dl_set_cell(&ue_dl, cell)) { + if (srsran_ue_dl_set_cell(&ue_dl, cell)) { Error("Setting ue_dl cell"); return false; } - if (srslte_ue_dl_set_mbsfn_area_id(&ue_dl, 1)) { + if (srsran_ue_dl_set_mbsfn_area_id(&ue_dl, 1)) { Error("Setting mbsfn id"); } - if (srslte_ue_ul_set_cell(&ue_ul, cell)) { + if (srsran_ue_ul_set_cell(&ue_ul, cell)) { Error("Initiating UE UL"); return false; } - if (cell.frame_type == SRSLTE_TDD && ue_dl_cfg.chest_cfg.estimator_alg != SRSLTE_ESTIMATOR_ALG_INTERPOLATE) { - chest_default_cfg.estimator_alg = SRSLTE_ESTIMATOR_ALG_INTERPOLATE; - srslte::console("Enabling subframe interpolation for TDD cells (recommended setting)\n"); + if (cell.frame_type == SRSRAN_TDD && ue_dl_cfg.chest_cfg.estimator_alg != SRSRAN_ESTIMATOR_ALG_INTERPOLATE) { + chest_default_cfg.estimator_alg = SRSRAN_ESTIMATOR_ALG_INTERPOLATE; + srsran::console("Enabling subframe interpolation for TDD cells (recommended setting)\n"); } cell_initiated = true; @@ -181,7 +181,7 @@ float cc_worker::get_ref_cfo() const return ue_dl.chest_res.cfo; } -void cc_worker::set_tdd_config_unlocked(srslte_tdd_config_t config) +void cc_worker::set_tdd_config_unlocked(srsran_tdd_config_t config) { sf_cfg_dl.tdd_config = config; sf_cfg_ul.tdd_config = config; @@ -200,7 +200,7 @@ void cc_worker::enable_pregen_signals_unlocked(bool enabled) bool cc_worker::work_dl_regular() { - bool dl_ack[SRSLTE_MAX_CODEWORDS] = {}; + bool dl_ack[SRSRAN_MAX_CODEWORDS] = {}; mac_interface_phy_lte::tb_action_dl_t dl_action = {}; @@ -211,7 +211,7 @@ bool cc_worker::work_dl_regular() return false; } - sf_cfg_dl.sf_type = SRSLTE_SF_NORM; + sf_cfg_dl.sf_type = SRSRAN_SF_NORM; // Set default channel estimation ue_dl_cfg.chest_cfg = chest_default_cfg; @@ -220,7 +220,7 @@ bool cc_worker::work_dl_regular() * the possible mi values */ uint32_t mi_set_len; - if (cell.frame_type == SRSLTE_TDD && !sf_cfg_dl.tdd_config.configured) { + if (cell.frame_type == SRSRAN_TDD && !sf_cfg_dl.tdd_config.configured) { mi_set_len = 3; } else { mi_set_len = 1; @@ -229,13 +229,13 @@ bool cc_worker::work_dl_regular() // Blind search PHICH mi value for (uint32_t i = 0; i < mi_set_len && !found_dl_grant; i++) { if (mi_set_len == 1) { - srslte_ue_dl_set_mi_auto(&ue_dl); + srsran_ue_dl_set_mi_auto(&ue_dl); } else { - srslte_ue_dl_set_mi_manual(&ue_dl, i); + srsran_ue_dl_set_mi_manual(&ue_dl, i); } /* Do FFT and extract PDCCH LLR, or quit if no actions are required in this subframe */ - if (srslte_ue_dl_decode_fft_estimate(&ue_dl, &sf_cfg_dl, &ue_dl_cfg) < 0) { + if (srsran_ue_dl_decode_fft_estimate(&ue_dl, &sf_cfg_dl, &ue_dl_cfg) < 0) { Error("Getting PDCCH FFT estimate"); return false; } @@ -248,24 +248,24 @@ bool cc_worker::work_dl_regular() } } - srslte_dci_dl_t dci_dl = {}; + srsran_dci_dl_t dci_dl = {}; uint32_t grant_cc_idx = 0; bool has_dl_grant = phy->get_dl_pending_grant(CURRENT_TTI, cc_idx, &grant_cc_idx, &dci_dl); // If found a dci for this carrier, generate a grant, pass it to MAC and decode the associated PDSCH if (has_dl_grant) { // Read last TB from last retx for this pid - for (uint32_t i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { + for (uint32_t i = 0; i < SRSRAN_MAX_CODEWORDS; i++) { ue_dl_cfg.cfg.pdsch.grant.last_tbs[i] = phy->last_dl_tbs[dci_dl.pid][cc_idx][i]; } // Generate PHY grant - if (srslte_ue_dl_dci_to_pdsch_grant(&ue_dl, &sf_cfg_dl, &ue_dl_cfg, &dci_dl, &ue_dl_cfg.cfg.pdsch.grant)) { + if (srsran_ue_dl_dci_to_pdsch_grant(&ue_dl, &sf_cfg_dl, &ue_dl_cfg, &dci_dl, &ue_dl_cfg.cfg.pdsch.grant)) { Info("Converting DCI message to DL dci"); return false; } // Save TB for next retx - for (uint32_t i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { + for (uint32_t i = 0; i < SRSRAN_MAX_CODEWORDS; i++) { phy->last_dl_tbs[dci_dl.pid][cc_idx][i] = ue_dl_cfg.cfg.pdsch.grant.last_tbs[i]; } @@ -277,7 +277,7 @@ bool cc_worker::work_dl_regular() dl_phy_to_mac_grant(&ue_dl_cfg.cfg.pdsch.grant, &dci_dl, &mac_grant); // Save ACK resource configuration - srslte_pdsch_ack_resource_t ack_resource = {dci_dl.dai, dci_dl.location.ncce, grant_cc_idx, dci_dl.tpc_pucch}; + srsran_pdsch_ack_resource_t ack_resource = {dci_dl.dai, dci_dl.location.ncce, grant_cc_idx, dci_dl.tpc_pucch}; // Send grant to MAC and get action for this TB, then call tb_decoded to unlock MAC phy->stack->new_grant_dl(cc_idx, mac_grant, &dl_action); @@ -295,7 +295,7 @@ bool cc_worker::work_dl_regular() return true; } -bool cc_worker::work_dl_mbsfn(srslte_mbsfn_cfg_t mbsfn_cfg) +bool cc_worker::work_dl_mbsfn(srsran_mbsfn_cfg_t mbsfn_cfg) { mac_interface_phy_lte::tb_action_dl_t dl_action = {}; @@ -305,17 +305,17 @@ bool cc_worker::work_dl_mbsfn(srslte_mbsfn_cfg_t mbsfn_cfg) } // Configure MBSFN settings - srslte_ue_dl_set_mbsfn_area_id(&ue_dl, mbsfn_cfg.mbsfn_area_id); - srslte_ue_dl_set_non_mbsfn_region(&ue_dl, mbsfn_cfg.non_mbsfn_region_length); + srsran_ue_dl_set_mbsfn_area_id(&ue_dl, mbsfn_cfg.mbsfn_area_id); + srsran_ue_dl_set_non_mbsfn_region(&ue_dl, mbsfn_cfg.non_mbsfn_region_length); - sf_cfg_dl.sf_type = SRSLTE_SF_MBSFN; + sf_cfg_dl.sf_type = SRSRAN_SF_MBSFN; // Set MBSFN channel estimation chest_mbsfn_cfg.mbsfn_area_id = mbsfn_cfg.mbsfn_area_id; ue_dl_cfg.chest_cfg = chest_mbsfn_cfg; /* Do FFT and extract PDCCH LLR, or quit if no actions are required in this subframe */ - if (srslte_ue_dl_decode_fft_estimate(&ue_dl, &sf_cfg_dl, &ue_dl_cfg) < 0) { + if (srsran_ue_dl_decode_fft_estimate(&ue_dl, &sf_cfg_dl, &ue_dl_cfg) < 0) { Error("Getting PDCCH FFT estimate"); return false; } @@ -328,8 +328,8 @@ bool cc_worker::work_dl_mbsfn(srslte_mbsfn_cfg_t mbsfn_cfg) } if (mbsfn_cfg.enable) { - srslte_configure_pmch(&pmch_cfg, &cell, &mbsfn_cfg); - srslte_ra_dl_compute_nof_re(&cell, &sf_cfg_dl, &pmch_cfg.pdsch_cfg.grant); + srsran_configure_pmch(&pmch_cfg, &cell, &mbsfn_cfg); + srsran_ra_dl_compute_nof_re(&cell, &sf_cfg_dl, &pmch_cfg.pdsch_cfg.grant); // Send grant to MAC and get action for this TB, then call tb_decoded to unlock MAC phy->stack->new_mch_dl(pmch_cfg.pdsch_cfg.grant, &dl_action); @@ -349,8 +349,8 @@ bool cc_worker::work_dl_mbsfn(srslte_mbsfn_cfg_t mbsfn_cfg) return true; } -void cc_worker::dl_phy_to_mac_grant(srslte_pdsch_grant_t* phy_grant, - srslte_dci_dl_t* dl_dci, +void cc_worker::dl_phy_to_mac_grant(srsran_pdsch_grant_t* phy_grant, + srsran_dci_dl_t* dl_dci, srsue::mac_interface_phy_lte::mac_grant_dl_t* mac_grant) { /* Fill MAC dci structure */ @@ -358,7 +358,7 @@ void cc_worker::dl_phy_to_mac_grant(srslte_pdsch_grant_t* mac_grant->rnti = dl_dci->rnti; mac_grant->tti = CURRENT_TTI; - for (int i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { + for (int i = 0; i < SRSRAN_MAX_CODEWORDS; i++) { mac_grant->tb[i].ndi = dl_dci->tb[i].ndi; mac_grant->tb[i].ndi_present = (dl_dci->tb[i].mcs_idx <= 28); mac_grant->tb[i].tbs = phy_grant->tb[i].enabled ? (phy_grant->tb[i].tbs / (uint32_t)8) : 0; @@ -366,7 +366,7 @@ void cc_worker::dl_phy_to_mac_grant(srslte_pdsch_grant_t* } // If SIB dci, use PID to signal TTI to obtain RV from higher layers - if (mac_grant->rnti == SRSLTE_SIRNTI) { + if (mac_grant->rnti == SRSRAN_SIRNTI) { mac_grant->pid = CURRENT_TTI; } } @@ -376,15 +376,15 @@ int cc_worker::decode_pdcch_dl() int nof_grants = 0; uint16_t dl_rnti = phy->stack->get_dl_sched_rnti(CURRENT_TTI); - if (dl_rnti != SRSLTE_INVALID_RNTI) { - srslte_dci_dl_t dci[SRSLTE_MAX_CARRIERS] = {}; + if (dl_rnti != SRSRAN_INVALID_RNTI) { + srsran_dci_dl_t dci[SRSRAN_MAX_CARRIERS] = {}; /* Blind search first without cross scheduling then with it if enabled */ for (int i = 0; i < (ue_dl_cfg.cfg.dci.cif_present ? 2 : 1) && !nof_grants; i++) { Debug("PDCCH looking for rnti=0x%x", dl_rnti); ue_dl_cfg.cfg.dci.cif_enabled = i > 0; ue_dl_cfg.cfg.dci_common_ss = (cc_idx == 0); - nof_grants = srslte_ue_dl_find_dl_dci(&ue_dl, &sf_cfg_dl, &ue_dl_cfg, dl_rnti, dci); + nof_grants = srsran_ue_dl_find_dl_dci(&ue_dl, &sf_cfg_dl, &ue_dl_cfg, dl_rnti, dci); if (nof_grants < 0) { Error("Looking for DL grants"); return -1; @@ -392,7 +392,7 @@ int cc_worker::decode_pdcch_dl() } // If RAR dci, save TTI - if (nof_grants > 0 && SRSLTE_RNTI_ISRAR(dl_rnti)) { + if (nof_grants > 0 && SRSRAN_RNTI_ISRAR(dl_rnti)) { phy->set_rar_grant_tti(CURRENT_TTI); } @@ -403,7 +403,7 @@ int cc_worker::decode_pdcch_dl() // Logging if (logger.info.enabled()) { char str[512]; - srslte_dci_dl_info(&dci[k], str, 512); + srsran_dci_dl_info(&dci[k], str, 512); logger.info("PDCCH: cc=%d, %s, snr=%.1f dB", cc_idx, str, ue_dl.chest_res.snr_db); } } @@ -411,16 +411,16 @@ int cc_worker::decode_pdcch_dl() return nof_grants; } -int cc_worker::decode_pdsch(srslte_pdsch_ack_resource_t ack_resource, +int cc_worker::decode_pdsch(srsran_pdsch_ack_resource_t ack_resource, mac_interface_phy_lte::tb_action_dl_t* action, - bool mac_acks[SRSLTE_MAX_CODEWORDS]) + bool mac_acks[SRSRAN_MAX_CODEWORDS]) { - srslte_pdsch_res_t pdsch_dec[SRSLTE_MAX_CODEWORDS] = {}; + srsran_pdsch_res_t pdsch_dec[SRSRAN_MAX_CODEWORDS] = {}; // See if at least 1 codeword needs to be decoded. If not need to be decode, resend ACK bool decode_enable = false; - bool tb_enable[SRSLTE_MAX_CODEWORDS] = {}; - for (uint32_t tb = 0; tb < SRSLTE_MAX_CODEWORDS; tb++) { + bool tb_enable[SRSRAN_MAX_CODEWORDS] = {}; + for (uint32_t tb = 0; tb < SRSRAN_MAX_CODEWORDS; tb++) { tb_enable[tb] = ue_dl_cfg.cfg.pdsch.grant.tb[tb].enabled; if (action->tb[tb].enabled) { decode_enable = true; @@ -440,15 +440,15 @@ int cc_worker::decode_pdsch(srslte_pdsch_ack_resource_t ack_resource, // Run PDSCH decoder if (decode_enable) { - if (srslte_ue_dl_decode_pdsch(&ue_dl, &sf_cfg_dl, &ue_dl_cfg.cfg.pdsch, pdsch_dec)) { + if (srsran_ue_dl_decode_pdsch(&ue_dl, &sf_cfg_dl, &ue_dl_cfg.cfg.pdsch, pdsch_dec)) { Error("ERROR: Decoding PDSCH"); } } // Generate ACKs for MAC and PUCCH uint32_t nof_tb = 0; - uint8_t pending_acks[SRSLTE_MAX_CODEWORDS] = {}; - for (uint32_t tb = 0; tb < SRSLTE_MAX_CODEWORDS; tb++) { + uint8_t pending_acks[SRSRAN_MAX_CODEWORDS] = {}; + for (uint32_t tb = 0; tb < SRSRAN_MAX_CODEWORDS; tb++) { // For MAC, set to true if it's a duplicate mac_acks[tb] = action->tb[tb].enabled ? pdsch_dec[tb].crc : true; @@ -479,26 +479,26 @@ int cc_worker::decode_pdsch(srslte_pdsch_ack_resource_t ack_resource, // Logging if (logger.info.enabled()) { char str[512]; - srslte_pdsch_rx_info(&ue_dl_cfg.cfg.pdsch, pdsch_dec, str, 512); + srsran_pdsch_rx_info(&ue_dl_cfg.cfg.pdsch, pdsch_dec, str, 512); logger.info("PDSCH: cc=%d, %s, snr=%.1f dB", cc_idx, str, ue_dl.chest_res.snr_db); } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int cc_worker::decode_pmch(mac_interface_phy_lte::tb_action_dl_t* action, srslte_mbsfn_cfg_t* mbsfn_cfg) +int cc_worker::decode_pmch(mac_interface_phy_lte::tb_action_dl_t* action, srsran_mbsfn_cfg_t* mbsfn_cfg) { - srslte_pdsch_res_t pmch_dec = {}; + srsran_pdsch_res_t pmch_dec = {}; pmch_cfg.area_id = mbsfn_cfg->mbsfn_area_id; pmch_cfg.pdsch_cfg.softbuffers.rx[0] = action->tb[0].softbuffer.rx; pmch_dec.payload = action->tb[0].payload; if (action->tb[0].enabled) { - srslte_softbuffer_rx_reset_tbs(pmch_cfg.pdsch_cfg.softbuffers.rx[0], pmch_cfg.pdsch_cfg.grant.tb[0].tbs); + srsran_softbuffer_rx_reset_tbs(pmch_cfg.pdsch_cfg.softbuffers.rx[0], pmch_cfg.pdsch_cfg.grant.tb[0].tbs); - if (srslte_ue_dl_decode_pmch(&ue_dl, &sf_cfg_dl, &pmch_cfg, &pmch_dec)) { + if (srsran_ue_dl_decode_pmch(&ue_dl, &sf_cfg_dl, &pmch_cfg, &pmch_dec)) { Error("Decoding PMCH"); return -1; } @@ -530,15 +530,15 @@ int cc_worker::decode_pmch(mac_interface_phy_lte::tb_action_dl_t* action, srslte void cc_worker::decode_phich() { - srslte_dci_ul_t dci_ul = {}; - srslte_phich_grant_t phich_grant = {}; - srslte_phich_res_t phich_res = {}; + srsran_dci_ul_t dci_ul = {}; + srsran_phich_grant_t phich_grant = {}; + srsran_phich_res_t phich_res = {}; // Receive PHICH, in TDD might be more than one for (uint32_t I_phich = 0; I_phich < 2; I_phich++) { phich_grant.I_phich = I_phich; if (phy->get_ul_pending_ack(&sf_cfg_dl, cc_idx, &phich_grant, &dci_ul)) { - if (srslte_ue_dl_decode_phich(&ue_dl, &sf_cfg_dl, &ue_dl_cfg, &phich_grant, &phich_res)) { + if (srsran_ue_dl_decode_phich(&ue_dl, &sf_cfg_dl, &ue_dl_cfg, &phich_grant, &phich_res)) { Error("Decoding PHICH"); } phy->set_ul_received_ack(&sf_cfg_dl, cc_idx, phich_res.ack_value, I_phich, &dci_ul); @@ -564,11 +564,11 @@ void cc_worker::update_measurements(std::vector& serving_cells, cf_t * */ -bool cc_worker::work_ul(srslte_uci_data_t* uci_data) +bool cc_worker::work_ul(srsran_uci_data_t* uci_data) { bool signal_ready; - srslte_dci_ul_t dci_ul = {}; + srsran_dci_ul_t dci_ul = {}; mac_interface_phy_lte::mac_grant_ul_t ul_mac_grant = {}; mac_interface_phy_lte::tb_action_ul_t ul_action = {}; uint32_t pid = 0; @@ -601,14 +601,14 @@ bool cc_worker::work_ul(srslte_uci_data_t* uci_data) ue_ul_cfg.ul_cfg.pusch.grant.last_tb = phy->last_ul_tb[pid][cc_idx]; // Generate PHY grant - if (srslte_ue_ul_dci_to_pusch_grant(&ue_ul, &sf_cfg_ul, &ue_ul_cfg, &dci_ul, &ue_ul_cfg.ul_cfg.pusch.grant)) { + if (srsran_ue_ul_dci_to_pusch_grant(&ue_ul, &sf_cfg_ul, &ue_ul_cfg, &dci_ul, &ue_ul_cfg.ul_cfg.pusch.grant)) { if (logger.info.enabled()) { char str[128]; - srslte_dci_ul_info(&dci_ul, str, sizeof(str)); + srsran_dci_ul_info(&dci_ul, str, sizeof(str)); Info("Converting DCI message to UL grant %s", str); } ul_grant_available = false; - } else if (ue_ul_cfg.ul_cfg.pusch.grant.tb.mod == SRSLTE_MOD_BPSK) { + } else if (ue_ul_cfg.ul_cfg.pusch.grant.tb.mod == SRSRAN_MOD_BPSK) { Error("UL retransmission without valid stored grant."); ul_grant_available = false; } else { @@ -622,7 +622,7 @@ bool cc_worker::work_ul(srslte_uci_data_t* uci_data) // Calculate PUSCH Hopping procedure ue_ul_cfg.ul_cfg.hopping.current_tx_nb = ul_action.current_tx_nb; - srslte_ue_ul_pusch_hopping(&ue_ul, &sf_cfg_ul, &ue_ul_cfg, &ue_ul_cfg.ul_cfg.pusch.grant); + srsran_ue_ul_pusch_hopping(&ue_ul, &sf_cfg_ul, &ue_ul_cfg, &ue_ul_cfg.ul_cfg.pusch.grant); } } @@ -645,9 +645,9 @@ bool cc_worker::work_ul(srslte_uci_data_t* uci_data) // Prepare to receive ACK through PHICH if (ul_action.expect_ack) { - srslte_phich_grant_t phich_grant = {}; + srsran_phich_grant_t phich_grant = {}; phich_grant.I_phich = 0; - if (cell.frame_type == SRSLTE_TDD && sf_cfg_ul.tdd_config.sf_config == 0) { + if (cell.frame_type == SRSRAN_TDD && sf_cfg_ul.tdd_config.sf_config == 0) { if ((sf_cfg_ul.tti % 10) == 4 || (sf_cfg_ul.tti % 10) == 9) { phich_grant.I_phich = 1; } @@ -661,8 +661,8 @@ bool cc_worker::work_ul(srslte_uci_data_t* uci_data) return signal_ready; } -void cc_worker::ul_phy_to_mac_grant(srslte_pusch_grant_t* phy_grant, - srslte_dci_ul_t* dci_ul, +void cc_worker::ul_phy_to_mac_grant(srsran_pusch_grant_t* phy_grant, + srsran_dci_ul_t* dci_ul, uint32_t pid, bool ul_grant_available, srsue::mac_interface_phy_lte::mac_grant_ul_t* mac_grant) @@ -677,7 +677,7 @@ void cc_worker::ul_phy_to_mac_grant(srslte_pusch_grant_t* mac_grant->tb.tbs = phy_grant->tb.tbs / (uint32_t)8; mac_grant->tb.rv = phy_grant->tb.rv; mac_grant->pid = pid; - mac_grant->is_rar = dci_ul->format == SRSLTE_DCI_FORMAT_RAR; + mac_grant->is_rar = dci_ul->format == SRSRAN_DCI_FORMAT_RAR; mac_grant->tti_tx = CURRENT_TTI_TX; } @@ -685,7 +685,7 @@ int cc_worker::decode_pdcch_ul() { int nof_grants = 0; - srslte_dci_ul_t dci[SRSLTE_MAX_CARRIERS]; + srsran_dci_ul_t dci[SRSRAN_MAX_CARRIERS]; ZERO_OBJECT(dci); uint16_t ul_rnti = phy->stack->get_ul_sched_rnti(CURRENT_TTI); @@ -695,7 +695,7 @@ int cc_worker::decode_pdcch_ul() for (int i = 0; i < (ue_dl_cfg.cfg.dci.cif_present ? 2 : 1) && !nof_grants; i++) { ue_dl_cfg.cfg.dci.cif_enabled = i > 0; ue_dl_cfg.cfg.dci_common_ss = (cc_idx == 0); - nof_grants = srslte_ue_dl_find_ul_dci(&ue_dl, &sf_cfg_dl, &ue_dl_cfg, ul_rnti, dci); + nof_grants = srsran_ue_dl_find_ul_dci(&ue_dl, &sf_cfg_dl, &ue_dl_cfg, ul_rnti, dci); if (nof_grants < 0) { Error("Looking for UL grants"); return -1; @@ -713,7 +713,7 @@ int cc_worker::decode_pdcch_ul() // Logging if (logger.info.enabled()) { char str[512]; - srslte_dci_ul_info(&dci[k], str, 512); + srsran_dci_ul_info(&dci[k], str, 512); logger.info("PDCCH: cc=%d, %s, snr=%.1f dB", cc_idx_grant, str, ue_dl.chest_res.snr_db); } } @@ -722,9 +722,9 @@ int cc_worker::decode_pdcch_ul() return nof_grants; } -bool cc_worker::encode_uplink(mac_interface_phy_lte::tb_action_ul_t* action, srslte_uci_data_t* uci_data) +bool cc_worker::encode_uplink(mac_interface_phy_lte::tb_action_ul_t* action, srsran_uci_data_t* uci_data) { - srslte_pusch_data_t data = {}; + srsran_pusch_data_t data = {}; ue_ul_cfg.cc_idx = cc_idx; // Setup input data @@ -753,7 +753,7 @@ bool cc_worker::encode_uplink(mac_interface_phy_lte::tb_action_ul_t* action, srs ue_ul_cfg.ul_cfg.pucch.rnti = phy->stack->get_ul_sched_rnti(CURRENT_TTI_TX); // Encode signal - int ret = srslte_ue_ul_encode(&ue_ul, &sf_cfg_ul, &ue_ul_cfg, &data); + int ret = srsran_ue_ul_encode(&ue_ul, &sf_cfg_ul, &ue_ul_cfg, &data); if (ret < 0) { Error("Encoding UL cc=%d", cc_idx); } @@ -769,7 +769,7 @@ bool cc_worker::encode_uplink(mac_interface_phy_lte::tb_action_ul_t* action, srs // Logging if (logger.info.enabled()) { char str[512]; - if (srslte_ue_ul_info(&ue_ul_cfg, &sf_cfg_ul, &data.uci, str, 512)) { + if (srsran_ue_ul_info(&ue_ul_cfg, &sf_cfg_ul, &data.uci, str, 512)) { logger.info("%s", str); } } @@ -777,10 +777,10 @@ bool cc_worker::encode_uplink(mac_interface_phy_lte::tb_action_ul_t* action, srs return ret > 0; } -void cc_worker::set_uci_sr(srslte_uci_data_t* uci_data) +void cc_worker::set_uci_sr(srsran_uci_data_t* uci_data) { Debug("set_uci_sr() query: sr_enabled=%d, last_tx_tti=%d", phy->sr_enabled, phy->sr_last_tx_tti); - if (srslte_ue_ul_gen_sr(&ue_ul_cfg, &sf_cfg_ul, uci_data, phy->sr_enabled)) { + if (srsran_ue_ul_gen_sr(&ue_ul_cfg, &sf_cfg_ul, uci_data, phy->sr_enabled)) { if (phy->sr_enabled) { phy->sr_last_tx_tti = CURRENT_TTI_TX; phy->sr_enabled = false; @@ -794,7 +794,7 @@ uint32_t cc_worker::get_wideband_cqi() int cqi_fixed = phy->args->cqi_fixed; int cqi_max = phy->args->cqi_max; - uint32_t wb_cqi_value = srslte_cqi_from_snr(phy->get_sinr_db(cc_idx) + ue_dl_cfg.snr_to_cqi_offset); + uint32_t wb_cqi_value = srsran_cqi_from_snr(phy->get_sinr_db(cc_idx) + ue_dl_cfg.snr_to_cqi_offset); if (cqi_fixed >= 0) { wb_cqi_value = cqi_fixed; @@ -805,29 +805,29 @@ uint32_t cc_worker::get_wideband_cqi() return wb_cqi_value; } -void cc_worker::set_uci_periodic_cqi(srslte_uci_data_t* uci_data) +void cc_worker::set_uci_periodic_cqi(srsran_uci_data_t* uci_data) { - srslte_ue_dl_gen_cqi_periodic(&ue_dl, &ue_dl_cfg, get_wideband_cqi(), CURRENT_TTI_TX, uci_data); + srsran_ue_dl_gen_cqi_periodic(&ue_dl, &ue_dl_cfg, get_wideband_cqi(), CURRENT_TTI_TX, uci_data); // Store serving cell index for logging purposes uci_data->cfg.cqi.scell_index = cc_idx; } -void cc_worker::set_uci_aperiodic_cqi(srslte_uci_data_t* uci_data) +void cc_worker::set_uci_aperiodic_cqi(srsran_uci_data_t* uci_data) { if (ue_dl_cfg.cfg.cqi_report.aperiodic_configured) { - srslte_ue_dl_gen_cqi_aperiodic(&ue_dl, &ue_dl_cfg, get_wideband_cqi(), uci_data); + srsran_ue_dl_gen_cqi_aperiodic(&ue_dl, &ue_dl_cfg, get_wideband_cqi(), uci_data); } else { Warning("Received CQI request but aperiodic mode is not configured"); } } -void cc_worker::set_uci_ack(srslte_uci_data_t* uci_data, +void cc_worker::set_uci_ack(srsran_uci_data_t* uci_data, bool is_grant_available, uint32_t V_dai_ul, bool is_pusch_available) { - srslte_pdsch_ack_t ack_info = {}; + srsran_pdsch_ack_t ack_info = {}; uint32_t nof_configured_carriers = 0; // Only PCell generates ACK for all SCell @@ -849,7 +849,7 @@ void cc_worker::set_uci_ack(srslte_uci_data_t* uci_data, ack_info.transmission_mode = ue_dl_cfg.cfg.tm; // Generate ACK/NACK bits - srslte_ue_dl_gen_ack(&ue_dl.cell, &sf_cfg_dl, &ack_info, uci_data); + srsran_ue_dl_gen_ack(&ue_dl.cell, &sf_cfg_dl, &ack_info, uci_data); } /************ @@ -860,7 +860,7 @@ void cc_worker::set_uci_ack(srslte_uci_data_t* uci_data, /* Translates RRC structs into PHY structs */ -void cc_worker::set_config_unlocked(srslte::phy_cfg_t& phy_cfg) +void cc_worker::set_config_unlocked(srsran::phy_cfg_t& phy_cfg) { // Save configuration ue_dl_cfg.cfg = phy_cfg.dl_cfg; @@ -871,22 +871,22 @@ void cc_worker::set_config_unlocked(srslte::phy_cfg_t& phy_cfg) // Update signals if (pregen_enabled) { Info("Pre-generating UL signals..."); - srslte_ue_ul_pregen_signals(&ue_ul, &ue_ul_cfg); + srsran_ue_ul_pregen_signals(&ue_ul, &ue_ul_cfg); Info("Done pre-generating signals worker..."); } } -void cc_worker::upd_config_dci_unlocked(srslte_dci_cfg_t& dci_cfg) +void cc_worker::upd_config_dci_unlocked(srsran_dci_cfg_t& dci_cfg) { ue_dl_cfg.cfg.dci = dci_cfg; } int cc_worker::read_ce_abs(float* ce_abs, uint32_t tx_antenna, uint32_t rx_antenna) { - uint32_t sz = (uint32_t)srslte_symbol_sz(cell.nof_prb); - srslte_vec_f_zero(ce_abs, sz); + uint32_t sz = (uint32_t)srsran_symbol_sz(cell.nof_prb); + srsran_vec_f_zero(ce_abs, sz); int g = (sz - 12 * cell.nof_prb) / 2; - srslte_vec_abs_dB_cf(ue_dl.chest_res.ce[tx_antenna][rx_antenna], -80, &ce_abs[g], SRSLTE_NRE * cell.nof_prb); + srsran_vec_abs_dB_cf(ue_dl.chest_res.ce[tx_antenna][rx_antenna], -80, &ce_abs[g], SRSRAN_NRE * cell.nof_prb); return sz; } diff --git a/srsue/src/phy/lte/sf_worker.cc b/srsue/src/phy/lte/sf_worker.cc index d46566d54..f4d1406c8 100644 --- a/srsue/src/phy/lte/sf_worker.cc +++ b/srsue/src/phy/lte/sf_worker.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,23 +10,23 @@ * */ -#include "srslte/srslte.h" +#include "srsran/srsran.h" -#include "srslte/common/standard_streams.h" +#include "srsran/common/standard_streams.h" #include "srsue/hdr/phy/lte/sf_worker.h" #include #define Error(fmt, ...) \ - if (SRSLTE_DEBUG_ENABLED) \ + if (SRSRAN_DEBUG_ENABLED) \ logger.error(fmt, ##__VA_ARGS__) #define Warning(fmt, ...) \ - if (SRSLTE_DEBUG_ENABLED) \ + if (SRSRAN_DEBUG_ENABLED) \ logger.warning(fmt, ##__VA_ARGS__) #define Info(fmt, ...) \ - if (SRSLTE_DEBUG_ENABLED) \ + if (SRSRAN_DEBUG_ENABLED) \ logger.info(fmt, ##__VA_ARGS__) #define Debug(fmt, ...) \ - if (SRSLTE_DEBUG_ENABLED) \ + if (SRSRAN_DEBUG_ENABLED) \ logger.debug(fmt, ##__VA_ARGS__) /* This is to visualize the channel response */ @@ -69,7 +69,7 @@ void sf_worker::reset_cell_unlocked(uint32_t cc_idx) cc_workers[cc_idx]->reset_cell_unlocked(); } -bool sf_worker::set_cell_unlocked(uint32_t cc_idx, srslte_cell_t cell_) +bool sf_worker::set_cell_unlocked(uint32_t cc_idx, srsran_cell_t cell_) { if (cc_idx < cc_workers.size()) { if (!cc_workers[cc_idx]->set_cell_unlocked(cell_)) { @@ -114,7 +114,7 @@ void sf_worker::set_tti(uint32_t tti_) logger.set_context(tti); } -void sf_worker::set_tx_time(const srslte::rf_timestamp_t& tx_time_) +void sf_worker::set_tx_time(const srsran::rf_timestamp_t& tx_time_) { tx_time.copy(tx_time_); } @@ -130,7 +130,7 @@ void sf_worker::set_cfo_unlocked(const uint32_t& cc_idx, float cfo) cc_workers[cc_idx]->set_cfo_unlocked(cfo); } -void sf_worker::set_tdd_config_unlocked(srslte_tdd_config_t config) +void sf_worker::set_tdd_config_unlocked(srsran_tdd_config_t config) { for (auto& cc_worker : cc_workers) { cc_worker->set_tdd_config_unlocked(config); @@ -145,7 +145,7 @@ void sf_worker::enable_pregen_signals_unlocked(bool enabled) } } -void sf_worker::set_config_unlocked(uint32_t cc_idx, srslte::phy_cfg_t phy_cfg) +void sf_worker::set_config_unlocked(uint32_t cc_idx, srsran::phy_cfg_t phy_cfg) { if (cc_idx < cc_workers.size()) { cc_workers[cc_idx]->set_config_unlocked(phy_cfg); @@ -160,7 +160,7 @@ void sf_worker::set_config_unlocked(uint32_t cc_idx, srslte::phy_cfg_t phy_cfg) void sf_worker::work_imp() { - srslte::rf_buffer_t tx_signal_ptr = {}; + srsran::rf_buffer_t tx_signal_ptr = {}; if (!cell_initiated) { phy->worker_end(this, false, tx_signal_ptr, tx_time, false); return; @@ -168,15 +168,15 @@ void sf_worker::work_imp() bool rx_signal_ok = false; bool tx_signal_ready = false; - uint32_t nof_samples = SRSLTE_SF_LEN_PRB(cell.nof_prb); + uint32_t nof_samples = SRSRAN_SF_LEN_PRB(cell.nof_prb); /***** Downlink Processing *******/ // Loop through all carriers. carrier_idx=0 is PCell for (uint32_t carrier_idx = 0; carrier_idx < cc_workers.size(); carrier_idx++) { // Process all DL and special subframes - if (srslte_sfidx_tdd_type(tdd_config, tti % 10) != SRSLTE_TDD_SF_U || cell.frame_type == SRSLTE_FDD) { - srslte_mbsfn_cfg_t mbsfn_cfg; + if (srsran_sfidx_tdd_type(tdd_config, tti % 10) != SRSRAN_TDD_SF_U || cell.frame_type == SRSRAN_FDD) { + srsran_mbsfn_cfg_t mbsfn_cfg; ZERO_OBJECT(mbsfn_cfg); if (carrier_idx == 0 && phy->is_mbsfn_sf(&mbsfn_cfg, tti)) { @@ -193,11 +193,11 @@ void sf_worker::work_imp() /***** Uplink Generation + Transmission *******/ /* If TTI+4 is an uplink subframe (TODO: Support short PRACH and SRS in UpPts special subframes) */ - if ((srslte_sfidx_tdd_type(tdd_config, TTI_TX(tti) % 10) == SRSLTE_TDD_SF_U) || cell.frame_type == SRSLTE_FDD) { + if ((srsran_sfidx_tdd_type(tdd_config, TTI_TX(tti) % 10) == SRSRAN_TDD_SF_U) || cell.frame_type == SRSRAN_FDD) { // Generate Uplink signal if no PRACH pending if (!prach_ptr) { // Common UCI data object for all carriers - srslte_uci_data_t uci_data; + srsran_uci_data_t uci_data; reset_uci(&uci_data); uint32_t uci_cc_idx = phy->get_ul_uci_cc(TTI_TX(tti)); @@ -249,9 +249,9 @@ void sf_worker::work_imp() /********************* Uplink common control functions ****************************/ -void sf_worker::reset_uci(srslte_uci_data_t* uci_data) +void sf_worker::reset_uci(srsran_uci_data_t* uci_data) { - srslte_uci_data_reset(uci_data); + srsran_uci_data_reset(uci_data); } /**************************** Measurements **************************/ @@ -285,13 +285,13 @@ void sf_worker::start_plot() if (plot_worker_id == -1) { plot_worker_id = get_id(); plot_nr_enable = phy->args->nof_nr_carriers > 0; - srslte::console("Starting plot for worker_id=%d\n", plot_worker_id); + srsran::console("Starting plot for worker_id=%d\n", plot_worker_id); init_plots(this); } else { - srslte::console("Trying to start a plot but already started by worker_id=%d\n", plot_worker_id); + srsran::console("Trying to start a plot but already started by worker_id=%d\n", plot_worker_id); } #else - srslte::console("Trying to start a plot but plots are disabled (ENABLE_GUI constant in sf_worker.cc)\n"); + srsran::console("Trying to start a plot but plots are disabled (ENABLE_GUI constant in sf_worker.cc)\n"); #endif } @@ -307,7 +307,7 @@ int sf_worker::read_pdsch_d(cf_t* pdsch_d) float sf_worker::get_cfo() { - sync_metrics_t sync_metrics[SRSLTE_MAX_CARRIERS] = {}; + sync_metrics_t sync_metrics[SRSRAN_MAX_CARRIERS] = {}; phy->get_sync_metrics(sync_metrics); return sync_metrics[0].cfo; } @@ -321,14 +321,14 @@ float sf_worker::get_cfo() ***********************************************************/ #ifdef ENABLE_GUI -plot_real_t pce[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS]; +plot_real_t pce[SRSRAN_MAX_PORTS][SRSRAN_MAX_PORTS]; plot_scatter_t pconst; plot_scatter_t pconst_nr; bool pconst_nr_ready = false; -#define SCATTER_PDSCH_BUFFER_LEN (20 * 6 * SRSLTE_SF_LEN_RE(SRSLTE_MAX_PRB, SRSLTE_CP_NORM)) +#define SCATTER_PDSCH_BUFFER_LEN (20 * 6 * SRSRAN_SF_LEN_RE(SRSRAN_MAX_PRB, SRSRAN_CP_NORM)) #define SCATTER_PDSCH_PLOT_LEN 4000 float tmp_plot[SCATTER_PDSCH_BUFFER_LEN]; -cf_t tmp_plot2[SRSLTE_SF_LEN_RE(SRSLTE_MAX_PRB, SRSLTE_CP_NORM)]; +cf_t tmp_plot2[SRSRAN_SF_LEN_RE(SRSRAN_MAX_PRB, SRSRAN_CP_NORM)]; bool plot_quit = false; #define CFO_PLOT_LEN 0 /* Set to non zero for enabling CFO plot */ diff --git a/srsue/src/phy/lte/worker_pool.cc b/srsue/src/phy/lte/worker_pool.cc index 547b12a25..109b0aa4b 100644 --- a/srsue/src/phy/lte/worker_pool.cc +++ b/srsue/src/phy/lte/worker_pool.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -24,7 +24,7 @@ bool worker_pool::init(phy_common* common, int prio) log.set_level(srslog::str_to_basic_level(common->args->log.phy_level)); log.set_hex_dump_max_size(common->args->log.phy_hex_limit); - auto w = std::unique_ptr(new lte::sf_worker(SRSLTE_MAX_PRB, common, log)); + auto w = std::unique_ptr(new lte::sf_worker(SRSRAN_MAX_PRB, common, log)); pool.init_worker(i, w.get(), prio, common->args->worker_cpu_mask); workers.push_back(std::move(w)); } diff --git a/srsue/src/phy/nr/cc_worker.cc b/srsue/src/phy/nr/cc_worker.cc index b55c40445..bd7f03222 100644 --- a/srsue/src/phy/nr/cc_worker.cc +++ b/srsue/src/phy/nr/cc_worker.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,36 +11,36 @@ */ #include "srsue/hdr/phy/nr/cc_worker.h" -#include "srslte/common/buffer_pool.h" -#include "srslte/srslte.h" +#include "srsran/common/buffer_pool.h" +#include "srsran/srsran.h" namespace srsue { namespace nr { cc_worker::cc_worker(uint32_t cc_idx_, srslog::basic_logger& log, state* phy_state_) : cc_idx(cc_idx_), phy(phy_state_), logger(log) { - cf_t* rx_buffer_c[SRSLTE_MAX_PORTS] = {}; + cf_t* rx_buffer_c[SRSRAN_MAX_PORTS] = {}; // Allocate buffers - buffer_sz = SRSLTE_SF_LEN_PRB(phy->args.dl.nof_max_prb) * 5; + buffer_sz = SRSRAN_SF_LEN_PRB(phy->args.dl.nof_max_prb) * 5; for (uint32_t i = 0; i < phy_state_->args.dl.nof_rx_antennas; i++) { - rx_buffer[i] = srslte_vec_cf_malloc(buffer_sz); + rx_buffer[i] = srsran_vec_cf_malloc(buffer_sz); rx_buffer_c[i] = rx_buffer[i]; - tx_buffer[i] = srslte_vec_cf_malloc(buffer_sz); + tx_buffer[i] = srsran_vec_cf_malloc(buffer_sz); } - if (srslte_ue_dl_nr_init(&ue_dl, rx_buffer.data(), &phy_state_->args.dl) < SRSLTE_SUCCESS) { + if (srsran_ue_dl_nr_init(&ue_dl, rx_buffer.data(), &phy_state_->args.dl) < SRSRAN_SUCCESS) { ERROR("Error initiating UE DL NR"); return; } - if (srslte_ue_ul_nr_init(&ue_ul, tx_buffer[0], &phy_state_->args.ul) < SRSLTE_SUCCESS) { + if (srsran_ue_ul_nr_init(&ue_ul, tx_buffer[0], &phy_state_->args.ul) < SRSRAN_SUCCESS) { ERROR("Error initiating UE DL NR"); return; } - if (srslte_softbuffer_rx_init_guru(&softbuffer_rx, SRSLTE_SCH_NR_MAX_NOF_CB_LDPC, SRSLTE_LDPC_MAX_LEN_ENCODED_CB) < - SRSLTE_SUCCESS) { + if (srsran_softbuffer_rx_init_guru(&softbuffer_rx, SRSRAN_SCH_NR_MAX_NOF_CB_LDPC, SRSRAN_LDPC_MAX_LEN_ENCODED_CB) < + SRSRAN_SUCCESS) { ERROR("Error init soft-buffer"); return; } @@ -48,9 +48,9 @@ cc_worker::cc_worker(uint32_t cc_idx_, srslog::basic_logger& log, state* phy_sta cc_worker::~cc_worker() { - srslte_ue_dl_nr_free(&ue_dl); - srslte_ue_ul_nr_free(&ue_ul); - srslte_softbuffer_rx_free(&softbuffer_rx); + srsran_ue_dl_nr_free(&ue_dl); + srsran_ue_ul_nr_free(&ue_ul); + srsran_softbuffer_rx_free(&softbuffer_rx); for (cf_t* p : rx_buffer) { if (p != nullptr) { free(p); @@ -63,19 +63,19 @@ cc_worker::~cc_worker() } } -bool cc_worker::set_carrier(const srslte_carrier_nr_t* carrier) +bool cc_worker::set_carrier(const srsran_carrier_nr_t* carrier) { - if (srslte_ue_dl_nr_set_carrier(&ue_dl, carrier) < SRSLTE_SUCCESS) { + if (srsran_ue_dl_nr_set_carrier(&ue_dl, carrier) < SRSRAN_SUCCESS) { ERROR("Error setting carrier"); return false; } - if (srslte_ue_dl_nr_set_pdcch_config(&ue_dl, &phy->cfg.pdcch) < SRSLTE_SUCCESS) { + if (srsran_ue_dl_nr_set_pdcch_config(&ue_dl, &phy->cfg.pdcch) < SRSRAN_SUCCESS) { ERROR("Error setting carrier"); return false; } - if (srslte_ue_ul_nr_set_carrier(&ue_ul, carrier) < SRSLTE_SUCCESS) { + if (srsran_ue_ul_nr_set_carrier(&ue_ul, carrier) < SRSRAN_SUCCESS) { ERROR("Error setting carrier"); return false; } @@ -117,18 +117,18 @@ uint32_t cc_worker::get_buffer_len() void cc_worker::decode_pdcch_dl() { - std::array dci_rx = {}; + std::array dci_rx = {}; srsue::mac_interface_phy_nr::sched_rnti_t rnti = phy->stack->get_dl_sched_rnti_nr(dl_slot_cfg.idx); // Skip search if no valid RNTI is given - if (rnti.id == SRSLTE_INVALID_RNTI) { + if (rnti.id == SRSRAN_INVALID_RNTI) { return; } // Search for grants int n_dl = - srslte_ue_dl_nr_find_dl_dci(&ue_dl, &dl_slot_cfg, rnti.id, rnti.type, dci_rx.data(), (uint32_t)dci_rx.size()); - if (n_dl < SRSLTE_SUCCESS) { + srsran_ue_dl_nr_find_dl_dci(&ue_dl, &dl_slot_cfg, rnti.id, rnti.type, dci_rx.data(), (uint32_t)dci_rx.size()); + if (n_dl < SRSRAN_SUCCESS) { logger.error("Error decoding DL NR-PDCCH"); return; } @@ -138,7 +138,7 @@ void cc_worker::decode_pdcch_dl() // Log found DCI if (logger.info.enabled()) { std::array str; - srslte_dci_dl_nr_to_str(&dci_rx[i], str.data(), str.size()); + srsran_dci_dl_nr_to_str(&dci_rx[i], str.data(), str.size()); logger.info("PDCCH: cc=%d, %s", cc_idx, str.data()); } @@ -148,7 +148,7 @@ void cc_worker::decode_pdcch_dl() if (logger.debug.enabled()) { for (uint32_t i = 0; i < ue_dl.pdcch_info_count; i++) { - const srslte_ue_dl_nr_pdcch_info_t* info = &ue_dl.pdcch_info[i]; + const srsran_ue_dl_nr_pdcch_info_t* info = &ue_dl.pdcch_info[i]; logger.debug("PDCCH: crst_id=%d, ss_id=%d, ncce=%d, al=%d, EPRE=%+.2f, RSRP=%+.2f, corr=%.3f; crc=%s", info->coreset_id, info->ss_id, @@ -164,18 +164,18 @@ void cc_worker::decode_pdcch_dl() void cc_worker::decode_pdcch_ul() { - std::array dci_rx = {}; + std::array dci_rx = {}; srsue::mac_interface_phy_nr::sched_rnti_t rnti = phy->stack->get_ul_sched_rnti_nr(ul_slot_cfg.idx); // Skip search if no valid RNTI is given - if (rnti.id == SRSLTE_INVALID_RNTI) { + if (rnti.id == SRSRAN_INVALID_RNTI) { return; } // Search for grants int n_dl = - srslte_ue_dl_nr_find_ul_dci(&ue_dl, &dl_slot_cfg, rnti.id, rnti.type, dci_rx.data(), (uint32_t)dci_rx.size()); - if (n_dl < SRSLTE_SUCCESS) { + srsran_ue_dl_nr_find_ul_dci(&ue_dl, &dl_slot_cfg, rnti.id, rnti.type, dci_rx.data(), (uint32_t)dci_rx.size()); + if (n_dl < SRSRAN_SUCCESS) { logger.error("Error decoding UL NR-PDCCH"); return; } @@ -185,7 +185,7 @@ void cc_worker::decode_pdcch_ul() // Log found DCI if (logger.info.enabled()) { std::array str; - srslte_dci_ul_nr_to_str(&dci_rx[i], str.data(), str.size()); + srsran_dci_ul_nr_to_str(&dci_rx[i], str.data(), str.size()); logger.info("PDCCH: cc=%d, %s", cc_idx, str.data()); } @@ -197,12 +197,12 @@ void cc_worker::decode_pdcch_ul() bool cc_worker::work_dl() { // Check if it is a DL slot, if not skip - if (!srslte_tdd_nr_is_dl(&phy->cfg.tdd, 0, dl_slot_cfg.idx)) { + if (!srsran_tdd_nr_is_dl(&phy->cfg.tdd, 0, dl_slot_cfg.idx)) { return true; } // Run FFT - srslte_ue_dl_nr_estimate_fft(&ue_dl, &dl_slot_cfg); + srsran_ue_dl_nr_estimate_fft(&ue_dl, &dl_slot_cfg); // Decode PDCCH DL first decode_pdcch_dl(); @@ -212,24 +212,24 @@ bool cc_worker::work_dl() // Get DL grant for this TTI, if available uint32_t pid = 0; - srslte_sch_cfg_nr_t pdsch_cfg = {}; - srslte_pdsch_ack_resource_nr_t ack_resource = {}; + srsran_sch_cfg_nr_t pdsch_cfg = {}; + srsran_pdsch_ack_resource_nr_t ack_resource = {}; if (phy->get_dl_pending_grant(dl_slot_cfg.idx, pdsch_cfg, ack_resource, pid)) { // Get data buffer - srslte::unique_byte_buffer_t data = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t data = srsran::make_byte_buffer(); data->N_bytes = pdsch_cfg.grant.tb[0].tbs / 8U; // Get soft-buffer from MAC // ... - srslte_softbuffer_rx_reset(&softbuffer_rx); + srsran_softbuffer_rx_reset(&softbuffer_rx); // Initialise PDSCH Result - std::array pdsch_res = {}; + std::array pdsch_res = {}; pdsch_res[0].payload = data->msg; pdsch_cfg.grant.tb[0].softbuffer.rx = &softbuffer_rx; // Decode actual PDSCH transmission - if (srslte_ue_dl_nr_decode_pdsch(&ue_dl, &dl_slot_cfg, &pdsch_cfg, pdsch_res.data()) < SRSLTE_SUCCESS) { + if (srsran_ue_dl_nr_decode_pdsch(&ue_dl, &dl_slot_cfg, &pdsch_cfg, pdsch_res.data()) < SRSRAN_SUCCESS) { ERROR("Error decoding PDSCH"); return false; } @@ -237,12 +237,12 @@ bool cc_worker::work_dl() // Logging if (logger.info.enabled()) { std::array str; - srslte_ue_dl_nr_pdsch_info(&ue_dl, &pdsch_cfg, pdsch_res.data(), str.data(), str.size()); + srsran_ue_dl_nr_pdsch_info(&ue_dl, &pdsch_cfg, pdsch_res.data(), str.data(), str.size()); logger.info(pdsch_res[0].payload, pdsch_cfg.grant.tb[0].tbs / 8, "PDSCH: cc=%d, %s", cc_idx, str.data()); } // Enqueue PDSCH ACK information only if the RNTI is type C - if (pdsch_cfg.grant.rnti_type == srslte_rnti_type_c) { + if (pdsch_cfg.grant.rnti_type == srsran_rnti_type_c) { phy->set_pending_ack(dl_slot_cfg.idx, ack_resource, pdsch_res[0].crc); } @@ -255,7 +255,7 @@ bool cc_worker::work_dl() mac_nr_grant.rnti = pdsch_cfg.grant.rnti; mac_nr_grant.tti = dl_slot_cfg.idx; - if (pdsch_cfg.grant.rnti_type == srslte_rnti_type_ra) { + if (pdsch_cfg.grant.rnti_type == srsran_rnti_type_ra) { phy->rar_grant_tti = dl_slot_cfg.idx; } @@ -270,27 +270,27 @@ bool cc_worker::work_dl() bool cc_worker::work_ul() { // Check if it is a UL slot, if not skip - if (!srslte_tdd_nr_is_ul(&phy->cfg.tdd, 0, ul_slot_cfg.idx)) { + if (!srsran_tdd_nr_is_ul(&phy->cfg.tdd, 0, ul_slot_cfg.idx)) { // No NR signal shall be transmitted - srslte_vec_cf_zero(tx_buffer[0], ue_ul.ifft.sf_sz); + srsran_vec_cf_zero(tx_buffer[0], ue_ul.ifft.sf_sz); return true; } - srslte_uci_data_nr_t uci_data = {}; + srsran_uci_data_nr_t uci_data = {}; uint32_t pid = 0; // Gather PDSCH ACK information - srslte_pdsch_ack_nr_t pdsch_ack = {}; + srsran_pdsch_ack_nr_t pdsch_ack = {}; bool has_ul_ack = phy->get_pending_ack(ul_slot_cfg.idx, pdsch_ack); // Request grant to PHY state for this transmit TTI - srslte_sch_cfg_nr_t pusch_cfg = {}; + srsran_sch_cfg_nr_t pusch_cfg = {}; bool has_pusch_grant = phy->get_ul_pending_grant(ul_slot_cfg.idx, pusch_cfg, pid); // If PDSCH UL ACK is available, load into UCI if (has_ul_ack) { pdsch_ack.use_pusch = has_pusch_grant; - if (srslte_ue_dl_nr_gen_ack(&phy->cfg.harq_ack, &pdsch_ack, &uci_data) < SRSLTE_SUCCESS) { + if (srsran_ue_dl_nr_gen_ack(&phy->cfg.harq_ack, &pdsch_ack, &uci_data) < SRSRAN_SUCCESS) { ERROR("Filling UCI ACK bits"); return false; } @@ -313,18 +313,18 @@ bool cc_worker::work_ul() phy->stack->new_grant_ul(0, mac_ul_grant, &ul_action); // Set UCI configuration following procedures - srslte_ra_ul_set_grant_uci_nr(&phy->cfg.pusch, &uci_data.cfg, &pusch_cfg); + srsran_ra_ul_set_grant_uci_nr(&phy->cfg.pusch, &uci_data.cfg, &pusch_cfg); // Assigning MAC provided values to PUSCH config structs pusch_cfg.grant.tb[0].softbuffer.tx = ul_action.tb.softbuffer; // Setup data for encoding - srslte_pusch_data_nr_t data = {}; + srsran_pusch_data_nr_t data = {}; data.payload = ul_action.tb.payload->msg; data.uci = uci_data.value; // Encode PUSCH transmission - if (srslte_ue_ul_nr_encode_pusch(&ue_ul, &ul_slot_cfg, &pusch_cfg, &data) < SRSLTE_SUCCESS) { + if (srsran_ue_ul_nr_encode_pusch(&ue_ul, &ul_slot_cfg, &pusch_cfg, &data) < SRSRAN_SUCCESS) { ERROR("Encoding PUSCH"); return false; } @@ -332,7 +332,7 @@ bool cc_worker::work_ul() // PUSCH Logging if (logger.info.enabled()) { std::array str; - srslte_ue_ul_nr_pusch_info(&ue_ul, &pusch_cfg, &data.uci, str.data(), str.size()); + srsran_ue_ul_nr_pusch_info(&ue_ul, &pusch_cfg, &data.uci, str.data(), str.size()); logger.info(ul_action.tb.payload->msg, pusch_cfg.grant.tb[0].tbs / 8, "PUSCH (NR): cc=%d, %s, tti_tx=%d", @@ -340,17 +340,17 @@ bool cc_worker::work_ul() str.data(), ul_slot_cfg.idx); } - } else if (srslte_uci_nr_total_bits(&uci_data.cfg) > 0) { + } else if (srsran_uci_nr_total_bits(&uci_data.cfg) > 0) { // Get PUCCH resource - srslte_pucch_nr_resource_t resource = {}; - if (srslte_ra_ul_nr_pucch_resource(&phy->cfg.pucch, &uci_data.cfg, &resource) < SRSLTE_SUCCESS) { + srsran_pucch_nr_resource_t resource = {}; + if (srsran_ra_ul_nr_pucch_resource(&phy->cfg.pucch, &uci_data.cfg, &resource) < SRSRAN_SUCCESS) { ERROR("Selecting PUCCH resource"); return false; } // Encode PUCCH message - if (srslte_ue_ul_nr_encode_pucch(&ue_ul, &ul_slot_cfg, &phy->cfg.pucch.common, &resource, &uci_data) < - SRSLTE_SUCCESS) { + if (srsran_ue_ul_nr_encode_pucch(&ue_ul, &ul_slot_cfg, &phy->cfg.pucch.common, &resource, &uci_data) < + SRSRAN_SUCCESS) { ERROR("Encoding PUCCH"); return false; } @@ -358,12 +358,12 @@ bool cc_worker::work_ul() // PUCCH Logging if (logger.info.enabled()) { std::array str; - srslte_ue_ul_nr_pucch_info(&resource, &uci_data, str.data(), str.size()); + srsran_ue_ul_nr_pucch_info(&resource, &uci_data, str.data(), str.size()); logger.info("PUCCH: cc=%d, %s, tti_tx=%d", cc_idx, str.data(), ul_slot_cfg.idx); } } else { // No NR signal shall be transmitted - srslte_vec_cf_zero(tx_buffer[0], ue_ul.ifft.sf_sz); + srsran_vec_cf_zero(tx_buffer[0], ue_ul.ifft.sf_sz); } return true; @@ -371,8 +371,8 @@ bool cc_worker::work_ul() int cc_worker::read_pdsch_d(cf_t* pdsch_d) { - uint32_t nof_re = ue_dl.carrier.nof_prb * SRSLTE_NRE * 12; - srslte_vec_cf_copy(pdsch_d, ue_dl.pdsch.d[0], nof_re); + uint32_t nof_re = ue_dl.carrier.nof_prb * SRSRAN_NRE * 12; + srsran_vec_cf_copy(pdsch_d, ue_dl.pdsch.d[0], nof_re); return nof_re; } diff --git a/srsue/src/phy/nr/sf_worker.cc b/srsue/src/phy/nr/sf_worker.cc index a0f764bb5..d0560096c 100644 --- a/srsue/src/phy/nr/sf_worker.cc +++ b/srsue/src/phy/nr/sf_worker.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,7 +11,7 @@ */ #include "srsue/hdr/phy/nr/sf_worker.h" -#include "srslte/common/standard_streams.h" +#include "srsran/common/standard_streams.h" #ifdef ENABLE_GUI #include "srsgui/srsgui.h" @@ -36,7 +36,7 @@ sf_worker::sf_worker(phy_common* phy_, state* phy_state_, srslog::basic_logger& } } -bool sf_worker::set_carrier_unlocked(uint32_t cc_idx, const srslte_carrier_nr_t* carrier_) +bool sf_worker::set_carrier_unlocked(uint32_t cc_idx, const srsran_carrier_nr_t* carrier_) { if (cc_idx >= cc_workers.size()) { return false; @@ -70,8 +70,8 @@ void sf_worker::set_tti(uint32_t tti) void sf_worker::work_imp() { - srslte::rf_buffer_t tx_buffer = {}; - srslte::rf_timestamp_t dummy_ts = {}; + srsran::rf_buffer_t tx_buffer = {}; + srsran::rf_timestamp_t dummy_ts = {}; // Perform DL processing for (auto& w : cc_workers) { @@ -126,13 +126,13 @@ void sf_worker::start_plot() #ifdef ENABLE_GUI if (plot_worker_id == -1) { plot_worker_id = get_id(); - srslte::console("Starting NR plot for worker_id=%d\n", plot_worker_id); + srsran::console("Starting NR plot for worker_id=%d\n", plot_worker_id); init_plots(this); } else { - srslte::console("Trying to start a plot but already started by worker_id=%d\n", plot_worker_id); + srsran::console("Trying to start a plot but already started by worker_id=%d\n", plot_worker_id); } #else - srslte::console("Trying to start a plot but plots are disabled (ENABLE_GUI constant in sf_worker.cc)\n"); + srsran::console("Trying to start a plot but plots are disabled (ENABLE_GUI constant in sf_worker.cc)\n"); #endif } @@ -149,7 +149,7 @@ void sf_worker::set_prach(cf_t* prach_ptr_, float prach_power_) extern plot_scatter_t pconst_nr; extern bool pconst_nr_ready; #define SCATTER_PDSCH_PLOT_LEN 4000 -static cf_t tmp_pconst_nr[SRSLTE_NSYMB_PER_SLOT_NR * SRSLTE_NRE * SRSLTE_MAX_PRB_NR] = {}; +static cf_t tmp_pconst_nr[SRSRAN_NSYMB_PER_SLOT_NR * SRSRAN_NRE * SRSRAN_MAX_PRB_NR] = {}; extern bool plot_quit; static void* plot_thread_run(void* arg) diff --git a/srsue/src/phy/nr/worker_pool.cc b/srsue/src/phy/nr/worker_pool.cc index 82dd95392..a821299cf 100644 --- a/srsue/src/phy/nr/worker_pool.cc +++ b/srsue/src/phy/nr/worker_pool.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -56,7 +56,7 @@ bool worker_pool::init(const phy_args_nr_t& args, phy_common* common, stack_inte prach_buffer->init(phy_state.args.dl.nof_max_prb); // Set PRACH hard-coded cell - srslte_cell_t cell = {}; + srsran_cell_t cell = {}; cell.nof_prb = 50; cell.id = phy_state.carrier.id; if (not prach_buffer->set_cell(cell, phy_state.cfg.prach)) { @@ -97,37 +97,37 @@ void worker_pool::send_prach(uint32_t prach_occasion, uint32_t preamble_index, i prach_buffer->prepare_to_send(preamble_index); } -int worker_pool::set_ul_grant(std::array packed_ul_grant, +int worker_pool::set_ul_grant(std::array packed_ul_grant, uint16_t rnti, - srslte_rnti_type_t rnti_type) + srsran_rnti_type_t rnti_type) { // Copy DCI bits and setup DCI context - srslte_dci_msg_nr_t dci_msg = {}; - dci_msg.format = srslte_dci_format_nr_0_0; // MAC RAR grant shall be unpacked as DCI 0_0 format + srsran_dci_msg_nr_t dci_msg = {}; + dci_msg.format = srsran_dci_format_nr_0_0; // MAC RAR grant shall be unpacked as DCI 0_0 format dci_msg.rnti_type = rnti_type; - dci_msg.search_space = srslte_search_space_type_rar; // This indicates it is a MAC RAR + dci_msg.search_space = srsran_search_space_type_rar; // This indicates it is a MAC RAR dci_msg.rnti = rnti; - dci_msg.nof_bits = SRSLTE_RAR_UL_GRANT_NBITS; - srslte_vec_u8_copy(dci_msg.payload, packed_ul_grant.data(), SRSLTE_RAR_UL_GRANT_NBITS); + dci_msg.nof_bits = SRSRAN_RAR_UL_GRANT_NBITS; + srsran_vec_u8_copy(dci_msg.payload, packed_ul_grant.data(), SRSRAN_RAR_UL_GRANT_NBITS); - srslte_dci_ul_nr_t dci_ul = {}; + srsran_dci_ul_nr_t dci_ul = {}; - if (srslte_dci_nr_rar_unpack(&dci_msg, &dci_ul) < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (srsran_dci_nr_rar_unpack(&dci_msg, &dci_ul) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } if (logger.info.enabled()) { std::array str; - srslte_dci_ul_nr_to_str(&dci_ul, str.data(), str.size()); + srsran_dci_ul_nr_to_str(&dci_ul, str.data(), str.size()); logger.set_context(phy_state.rar_grant_tti); logger.info("Setting RAR Grant %s", str.data()); } phy_state.set_ul_pending_grant(phy_state.rar_grant_tti, dci_ul); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -bool worker_pool::set_config(const srslte::phy_cfg_nr_t& cfg) +bool worker_pool::set_config(const srsran::phy_cfg_nr_t& cfg) { phy_state.cfg = cfg; return true; diff --git a/srsue/src/phy/phy.cc b/srsue/src/phy/phy.cc index 4e0a326f4..b5e3449cc 100644 --- a/srsue/src/phy/phy.cc +++ b/srsue/src/phy/phy.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,34 +13,34 @@ #include #include -#include "srslte/common/standard_streams.h" -#include "srslte/srslte.h" +#include "srsran/common/standard_streams.h" +#include "srsran/srsran.h" #include "srsue/hdr/phy/phy.h" #define Error(fmt, ...) \ - if (SRSLTE_DEBUG_ENABLED) \ + if (SRSRAN_DEBUG_ENABLED) \ logger_phy.error(fmt, ##__VA_ARGS__) #define Warning(fmt, ...) \ - if (SRSLTE_DEBUG_ENABLED) \ + if (SRSRAN_DEBUG_ENABLED) \ logger_phy.warning(fmt, ##__VA_ARGS__) #define Info(fmt, ...) \ - if (SRSLTE_DEBUG_ENABLED) \ + if (SRSRAN_DEBUG_ENABLED) \ logger_phy.info(fmt, ##__VA_ARGS__) #define Debug(fmt, ...) \ - if (SRSLTE_DEBUG_ENABLED) \ + if (SRSRAN_DEBUG_ENABLED) \ logger_phy.debug(fmt, ##__VA_ARGS__) using namespace std; namespace srsue { -static void srslte_phy_handler(phy_logger_level_t log_level, void* ctx, char* str) +static void srsran_phy_handler(phy_logger_level_t log_level, void* ctx, char* str) { phy* r = (phy*)ctx; - r->srslte_phy_logger(log_level, str); + r->srsran_phy_logger(log_level, str); } -void phy::srslte_phy_logger(phy_logger_level_t log_level, char* str) +void phy::srsran_phy_logger(phy_logger_level_t log_level, char* str) { switch (log_level) { case LOG_LEVEL_INFO_S: @@ -80,24 +80,24 @@ void phy::set_default_args(phy_args_t& args_) bool phy::check_args(const phy_args_t& args_) { if (args_.nof_phy_threads > MAX_WORKERS) { - srslte::console("Error in PHY args: nof_phy_threads must be 1, 2 or 3\n"); + srsran::console("Error in PHY args: nof_phy_threads must be 1, 2 or 3\n"); return false; } if (args_.snr_ema_coeff > 1.0) { - srslte::console("Error in PHY args: snr_ema_coeff must be 0<=w<=1\n"); + srsran::console("Error in PHY args: snr_ema_coeff must be 0<=w<=1\n"); return false; } return true; } -int phy::init(const phy_args_t& args_, stack_interface_phy_lte* stack_, srslte::radio_interface_phy* radio_) +int phy::init(const phy_args_t& args_, stack_interface_phy_lte* stack_, srsran::radio_interface_phy* radio_) { stack = stack_; radio = radio_; init(args_); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int phy::init(const phy_args_t& args_) @@ -117,7 +117,7 @@ int phy::init(const phy_args_t& args_) logger_phy_lib.set_level(lib_log_level); logger_phy_lib.set_hex_dump_max_size(args.log.phy_hex_limit); if (lib_log_level != srslog::basic_levels::none) { - srslte_phy_log_register_handler(this, srslte_phy_handler); + srsran_phy_log_register_handler(this, srsran_phy_handler); } // set default logger @@ -137,7 +137,7 @@ int phy::init(const phy_args_t& args_) void phy::run_thread() { std::unique_lock lock(config_mutex); - prach_buffer.init(SRSLTE_MAX_PRB); + prach_buffer.init(SRSRAN_MAX_PRB); common.init(&args, radio, stack, &sfsync); // Initialise workers @@ -187,7 +187,7 @@ void phy::stop() void phy::get_metrics(phy_metrics_t* m) { uint32_t dl_earfcn = 0; - srslte_cell_t cell = {}; + srsran_cell_t cell = {}; sfsync.get_current_cell(&cell, &dl_earfcn); m->info[0].pci = cell.id; m->info[0].dl_earfcn = dl_earfcn; @@ -260,7 +260,7 @@ void phy::set_cells_to_meas(uint32_t earfcn, const std::set& pci) // If not available and a non-configured carrier is available, configure it. if (not available and cc_empty != 0) { // Copy all attributes from serving cell - srslte_cell_t cell = selected_cell; + srsran_cell_t cell = selected_cell; // Select the first PCI in the list if (not pci.empty()) { @@ -293,7 +293,7 @@ bool phy::cell_select(phy_cell_t cell) cmd_worker_cell.add_cmd([this, cell]() { bool ret = sfsync.cell_select_start(cell); if (ret) { - srslte_cell_t sync_cell; + srsran_cell_t sync_cell; sfsync.get_current_cell(&sync_cell); selected_cell = sync_cell; } @@ -391,7 +391,7 @@ int phy::sr_last_tx_tti() return common.sr_last_tx_tti; } -void phy::set_rar_grant(uint8_t grant_payload[SRSLTE_RAR_GRANT_LEN], uint16_t rnti) +void phy::set_rar_grant(uint8_t grant_payload[SRSRAN_RAR_GRANT_LEN], uint16_t rnti) { common.set_rar_grant(grant_payload, rnti, tdd_config); } @@ -412,7 +412,7 @@ void phy::enable_pregen_signals(bool enable) } } -bool phy::set_config(srslte::phy_cfg_t config_, uint32_t cc_idx) +bool phy::set_config(srsran::phy_cfg_t config_, uint32_t cc_idx) { if (!is_initiated()) { fprintf(stderr, "Error calling set_config(): PHY not initialized\n"); @@ -421,7 +421,7 @@ bool phy::set_config(srslte::phy_cfg_t config_, uint32_t cc_idx) // Check parameters are valid if (cc_idx >= args.nof_lte_carriers) { - srslte::console("Received SCell configuration for index %d but there are not enough CC workers available\n", + srsran::console("Received SCell configuration for index %d but there are not enough CC workers available\n", cc_idx); return false; } @@ -455,7 +455,7 @@ bool phy::set_config(srslte::phy_cfg_t config_, uint32_t cc_idx) return true; } -bool phy::set_scell(srslte_cell_t cell_info, uint32_t cc_idx, uint32_t earfcn) +bool phy::set_scell(srsran_cell_t cell_info, uint32_t cc_idx, uint32_t earfcn) { if (!is_initiated()) { fprintf(stderr, "Error calling set_config(): PHY not initialized\n"); @@ -469,13 +469,13 @@ bool phy::set_scell(srslte_cell_t cell_info, uint32_t cc_idx, uint32_t earfcn) // Check parameters are valid if (cc_idx >= args.nof_lte_carriers) { - srslte::console("Received SCell configuration for index %d but there are not enough CC workers available\n", + srsran::console("Received SCell configuration for index %d but there are not enough CC workers available\n", cc_idx); return false; } // First of all check validity of parameters - if (!srslte_cell_isvalid(&cell_info)) { + if (!srsran_cell_isvalid(&cell_info)) { logger_phy.error("Received SCell configuration for an invalid cell"); return false; } @@ -508,8 +508,8 @@ bool phy::set_scell(srslte_cell_t cell_info, uint32_t cc_idx, uint32_t earfcn) // Change frequency only if the earfcn was modified if (earfcn_is_different) { - double dl_freq = srslte_band_fd(earfcn) * 1e6; - double ul_freq = srslte_band_fu(common.get_ul_earfcn(earfcn)) * 1e6; + double dl_freq = srsran_band_fd(earfcn) * 1e6; + double ul_freq = srsran_band_fu(common.get_ul_earfcn(earfcn)) * 1e6; radio->set_rx_freq(cc_idx, dl_freq); radio->set_tx_freq(cc_idx, ul_freq); } @@ -524,12 +524,12 @@ bool phy::set_scell(srslte_cell_t cell_info, uint32_t cc_idx, uint32_t earfcn) return true; } -void phy::set_config_tdd(srslte_tdd_config_t& tdd_config_) +void phy::set_config_tdd(srsran_tdd_config_t& tdd_config_) { tdd_config = tdd_config_; if (!tdd_config.configured) { - srslte::console("Setting TDD-config: %d, SS config: %d\n", tdd_config.sf_config, tdd_config.ss_config); + srsran::console("Setting TDD-config: %d, SS config: %d\n", tdd_config.sf_config, tdd_config.ss_config); } tdd_config.configured = true; @@ -546,7 +546,7 @@ void phy::set_config_tdd(srslte_tdd_config_t& tdd_config_) }); } -void phy::set_config_mbsfn_sib2(srslte::mbsfn_sf_cfg_t* cfg_list, uint32_t nof_cfgs) +void phy::set_config_mbsfn_sib2(srsran::mbsfn_sf_cfg_t* cfg_list, uint32_t nof_cfgs) { if (nof_cfgs > 1) { Warning("SIB2 has %d MBSFN subframe configs - only 1 supported", nof_cfgs); @@ -557,7 +557,7 @@ void phy::set_config_mbsfn_sib2(srslte::mbsfn_sf_cfg_t* cfg_list, uint32_t nof_c } } -void phy::set_config_mbsfn_sib13(const srslte::sib13_t& sib13) +void phy::set_config_mbsfn_sib13(const srsran::sib13_t& sib13) { common.mbsfn_config.mbsfn_notification_cnfg = sib13.notif_cfg; if (sib13.nof_mbsfn_area_info > 1) { @@ -569,7 +569,7 @@ void phy::set_config_mbsfn_sib13(const srslte::sib13_t& sib13) } } -void phy::set_config_mbsfn_mcch(const srslte::mcch_msg_t& mcch) +void phy::set_config_mbsfn_mcch(const srsran::mcch_msg_t& mcch) { common.mbsfn_config.mcch = mcch; stack->set_mbsfn_config(common.mbsfn_config.mcch.pmch_info_list[0].nof_mbms_session_info); @@ -582,18 +582,18 @@ void phy::set_mch_period_stop(uint32_t stop) common.set_mch_period_stop(stop); } -int phy::init(const phy_args_nr_t& args_, stack_interface_phy_nr* stack_, srslte::radio_interface_phy* radio_) +int phy::init(const phy_args_nr_t& args_, stack_interface_phy_nr* stack_, srsran::radio_interface_phy* radio_) { if (!nr_workers.init(args_, &common, stack_, WORKERS_THREAD_PRIO)) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -int phy::set_ul_grant(std::array packed_ul_grant, +int phy::set_ul_grant(std::array packed_ul_grant, uint16_t rnti, - srslte_rnti_type_t rnti_type) + srsran_rnti_type_t rnti_type) { return nr_workers.set_ul_grant(packed_ul_grant, rnti, rnti_type); } @@ -616,7 +616,7 @@ void phy::set_earfcn(std::vector earfcns) // Do nothing } -bool phy::set_config(const srslte::phy_cfg_nr_t& cfg) +bool phy::set_config(const srsran::phy_cfg_nr_t& cfg) { return nr_workers.set_config(cfg); } diff --git a/srsue/src/phy/phy_common.cc b/srsue/src/phy/phy_common.cc index 300f5419c..f6a03c1f7 100644 --- a/srsue/src/phy/phy_common.cc +++ b/srsue/src/phy/phy_common.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,25 +13,25 @@ #include #include -#include "srslte/srslte.h" +#include "srsran/srsran.h" #include "srsue/hdr/phy/phy_common.h" #define Error(fmt, ...) \ - if (SRSLTE_DEBUG_ENABLED) \ + if (SRSRAN_DEBUG_ENABLED) \ logger.error(fmt, ##__VA_ARGS__) #define Warning(fmt, ...) \ - if (SRSLTE_DEBUG_ENABLED) \ + if (SRSRAN_DEBUG_ENABLED) \ logger.warning(fmt, ##__VA_ARGS__) #define Info(fmt, ...) \ - if (SRSLTE_DEBUG_ENABLED) \ + if (SRSRAN_DEBUG_ENABLED) \ logger.info(fmt, ##__VA_ARGS__) #define Debug(fmt, ...) \ - if (SRSLTE_DEBUG_ENABLED) \ + if (SRSRAN_DEBUG_ENABLED) \ logger.debug(fmt, ##__VA_ARGS__) namespace srsue { -static srslte::rf_buffer_t zeros_multi(1); +static srsran::rf_buffer_t zeros_multi(1); phy_common::phy_common(srslog::basic_logger& logger) : logger(logger), ta(logger) { @@ -41,7 +41,7 @@ phy_common::phy_common(srslog::basic_logger& logger) : logger(logger), ta(logger phy_common::~phy_common() = default; void phy_common::init(phy_args_t* _args, - srslte::radio_interface_phy* _radio, + srsran::radio_interface_phy* _radio, stack_interface_phy_lte* _stack, rsrp_insync_itf* _chest_loop) { @@ -53,19 +53,19 @@ void phy_common::init(phy_args_t* _args, // Instantiate UL channel emulator if (args->ul_channel_args.enable) { - ul_channel = srslte::channel_ptr( - new srslte::channel(args->ul_channel_args, args->nof_lte_carriers * args->nof_rx_ant, logger)); + ul_channel = srsran::channel_ptr( + new srsran::channel(args->ul_channel_args, args->nof_lte_carriers * args->nof_rx_ant, logger)); } } -void phy_common::set_ue_dl_cfg(srslte_ue_dl_cfg_t* ue_dl_cfg) +void phy_common::set_ue_dl_cfg(srsran_ue_dl_cfg_t* ue_dl_cfg) { ue_dl_cfg->snr_to_cqi_offset = args->snr_to_cqi_offset; - srslte_chest_dl_cfg_t* chest_cfg = &ue_dl_cfg->chest_cfg; + srsran_chest_dl_cfg_t* chest_cfg = &ue_dl_cfg->chest_cfg; // Setup estimator filter - bzero(chest_cfg, sizeof(srslte_chest_dl_cfg_t)); + bzero(chest_cfg, sizeof(srsran_chest_dl_cfg_t)); if (args->estimator_fil_auto) { chest_cfg->filter_coef[0] = 0; @@ -73,55 +73,55 @@ void phy_common::set_ue_dl_cfg(srslte_ue_dl_cfg_t* ue_dl_cfg) chest_cfg->filter_coef[0] = args->estimator_fil_order; chest_cfg->filter_coef[1] = args->estimator_fil_stddev; } - chest_cfg->filter_type = SRSLTE_CHEST_FILTER_GAUSS; + chest_cfg->filter_type = SRSRAN_CHEST_FILTER_GAUSS; if (args->snr_estim_alg == "refs") { - chest_cfg->noise_alg = SRSLTE_NOISE_ALG_REFS; + chest_cfg->noise_alg = SRSRAN_NOISE_ALG_REFS; } else if (args->snr_estim_alg == "empty") { - chest_cfg->noise_alg = SRSLTE_NOISE_ALG_EMPTY; + chest_cfg->noise_alg = SRSRAN_NOISE_ALG_EMPTY; } else { - chest_cfg->noise_alg = SRSLTE_NOISE_ALG_PSS; + chest_cfg->noise_alg = SRSRAN_NOISE_ALG_PSS; } chest_cfg->rsrp_neighbour = false; chest_cfg->sync_error_enable = args->correct_sync_error; chest_cfg->estimator_alg = - args->interpolate_subframe_enabled ? SRSLTE_ESTIMATOR_ALG_INTERPOLATE : SRSLTE_ESTIMATOR_ALG_AVERAGE; + args->interpolate_subframe_enabled ? SRSRAN_ESTIMATOR_ALG_INTERPOLATE : SRSRAN_ESTIMATOR_ALG_AVERAGE; chest_cfg->cfo_estimate_enable = args->cfo_ref_mask != 0; chest_cfg->cfo_estimate_sf_mask = args->cfo_ref_mask; } -void phy_common::set_pdsch_cfg(srslte_pdsch_cfg_t* pdsch_cfg) +void phy_common::set_pdsch_cfg(srsran_pdsch_cfg_t* pdsch_cfg) { pdsch_cfg->csi_enable = args->pdsch_csi_enabled; pdsch_cfg->max_nof_iterations = args->pdsch_max_its; pdsch_cfg->meas_evm_en = args->meas_evm; - pdsch_cfg->decoder_type = (args->equalizer_mode == "zf") ? SRSLTE_MIMO_DECODER_ZF : SRSLTE_MIMO_DECODER_MMSE; + pdsch_cfg->decoder_type = (args->equalizer_mode == "zf") ? SRSRAN_MIMO_DECODER_ZF : SRSRAN_MIMO_DECODER_MMSE; } -void phy_common::set_ue_ul_cfg(srslte_ue_ul_cfg_t* ue_ul_cfg) +void phy_common::set_ue_ul_cfg(srsran_ue_ul_cfg_t* ue_ul_cfg) { // Setup uplink configuration - bzero(ue_ul_cfg, sizeof(srslte_ue_ul_cfg_t)); + bzero(ue_ul_cfg, sizeof(srsran_ue_ul_cfg_t)); ue_ul_cfg->cfo_en = true; if (args->force_ul_amplitude > 0.0f) { ue_ul_cfg->force_peak_amplitude = args->force_ul_amplitude; - ue_ul_cfg->normalize_mode = SRSLTE_UE_UL_NORMALIZE_MODE_FORCE_AMPLITUDE; + ue_ul_cfg->normalize_mode = SRSRAN_UE_UL_NORMALIZE_MODE_FORCE_AMPLITUDE; } else { - ue_ul_cfg->normalize_mode = SRSLTE_UE_UL_NORMALIZE_MODE_AUTO; + ue_ul_cfg->normalize_mode = SRSRAN_UE_UL_NORMALIZE_MODE_AUTO; } - ue_ul_cfg->ul_cfg.pucch.ack_nack_feedback_mode = SRSLTE_PUCCH_ACK_NACK_FEEDBACK_MODE_NORMAL; + ue_ul_cfg->ul_cfg.pucch.ack_nack_feedback_mode = SRSRAN_PUCCH_ACK_NACK_FEEDBACK_MODE_NORMAL; } -srslte::radio_interface_phy* phy_common::get_radio() +srsran::radio_interface_phy* phy_common::get_radio() { return radio_h; } // Unpack RAR dci as defined in Section 6.2 of 36.213 -void phy_common::set_rar_grant(uint8_t grant_payload[SRSLTE_RAR_GRANT_LEN], +void phy_common::set_rar_grant(uint8_t grant_payload[SRSRAN_RAR_GRANT_LEN], uint16_t rnti, - srslte_tdd_config_t tdd_config) + srsran_tdd_config_t tdd_config) { #if MSG3_DELAY_MS < 0 #error "Error MSG3_DELAY_MS can't be negative" @@ -131,16 +131,16 @@ void phy_common::set_rar_grant(uint8_t grant_payload[SRSLTE_RAR_GRAN Error("Must call set_rar_grant_tti before set_rar_grant"); } - srslte_dci_ul_t dci_ul; - srslte_dci_rar_grant_t rar_grant; - srslte_dci_rar_unpack(grant_payload, &rar_grant); + srsran_dci_ul_t dci_ul; + srsran_dci_rar_grant_t rar_grant; + srsran_dci_rar_unpack(grant_payload, &rar_grant); - if (srslte_dci_rar_to_ul_dci(&cell, &rar_grant, &dci_ul)) { + if (srsran_dci_rar_to_ul_dci(&cell, &rar_grant, &dci_ul)) { Error("Converting RAR message to UL dci"); return; } - dci_ul.format = SRSLTE_DCI_FORMAT_RAR; // Use this format to identify a RAR grant + dci_ul.format = SRSRAN_DCI_FORMAT_RAR; // Use this format to identify a RAR grant dci_ul.rnti = rnti; uint32_t msg3_tx_tti; @@ -150,8 +150,8 @@ void phy_common::set_rar_grant(uint8_t grant_payload[SRSLTE_RAR_GRAN msg3_tx_tti = (TTI_TX(rar_grant_tti) + MSG3_DELAY_MS) % 10240; } - if (cell.frame_type == SRSLTE_TDD) { - while (srslte_sfidx_tdd_type(tdd_config, msg3_tx_tti % 10) != SRSLTE_TDD_SF_U) { + if (cell.frame_type == SRSRAN_TDD) { + while (srsran_sfidx_tdd_type(tdd_config, msg3_tx_tti % 10) != SRSRAN_TDD_SF_U) { msg3_tx_tti++; } } @@ -190,7 +190,7 @@ const static uint32_t k_phich[7][10] = {{0, 0, 4, 7, 6, 0, 0, 4, 7, 6}, {0, 0, 6, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 4, 6, 6, 0, 0, 4, 7, 0}}; -uint32_t phy_common::ul_pidof(uint32_t tti, srslte_tdd_config_t* tdd_config) +uint32_t phy_common::ul_pidof(uint32_t tti, srsran_tdd_config_t* tdd_config) { if (tdd_config->configured) { /* In TDD modes 1-5, each PID is associated with a unique subframe and the number of harq processes equals the @@ -234,20 +234,20 @@ uint32_t phy_common::ul_pidof(uint32_t tti, srslte_tdd_config_t* tdd_config) Error("Invalid SF configuration %d", tdd_config->sf_config); } } else { - return tti % SRSLTE_FDD_NOF_HARQ; + return tti % SRSRAN_FDD_NOF_HARQ; } return 0; } // Computes SF->TTI at which PHICH will be received according to 9.1.2 of 36.213 #define tti_phich(sf) \ - (sf->tti + (cell.frame_type == SRSLTE_FDD ? FDD_HARQ_DELAY_UL_MS : k_phich[sf->tdd_config.sf_config][sf->tti % 10])) + (sf->tti + (cell.frame_type == SRSRAN_FDD ? FDD_HARQ_DELAY_UL_MS : k_phich[sf->tdd_config.sf_config][sf->tti % 10])) // Here SF->TTI is when PUSCH is transmitted -void phy_common::set_ul_pending_ack(srslte_ul_sf_cfg_t* sf, +void phy_common::set_ul_pending_ack(srsran_ul_sf_cfg_t* sf, uint32_t cc_idx, - srslte_phich_grant_t phich_grant, - srslte_dci_ul_t* dci_ul) + srsran_phich_grant_t phich_grant, + srsran_dci_ul_t* dci_ul) { // Use a lock here because subframe 4 and 9 of TDD config 0 accept multiple PHICH from multiple frames std::lock_guard lock(pending_ul_ack_mutex); @@ -269,10 +269,10 @@ void phy_common::set_ul_pending_ack(srslte_ul_sf_cfg_t* sf, } // Here SF->TTI is when PHICH is being transmitted so that's DL subframe -bool phy_common::get_ul_pending_ack(srslte_dl_sf_cfg_t* sf, +bool phy_common::get_ul_pending_ack(srsran_dl_sf_cfg_t* sf, uint32_t cc_idx, - srslte_phich_grant_t* phich_grant, - srslte_dci_ul_t* dci_ul) + srsran_phich_grant_t* phich_grant, + srsran_dci_ul_t* dci_ul) { std::lock_guard lock(pending_ul_ack_mutex); bool ret = false; @@ -305,17 +305,17 @@ bool phy_common::is_any_ul_pending_ack() // Computes SF->TTI at which PUSCH will be transmitted according to Section 8 of 36.213 #define tti_pusch_hi(sf) \ (sf->tti + \ - (cell.frame_type == SRSLTE_FDD ? FDD_HARQ_DELAY_UL_MS \ + (cell.frame_type == SRSRAN_FDD ? FDD_HARQ_DELAY_UL_MS \ : I_phich ? 7 : k_pusch[sf->tdd_config.sf_config][sf->tti % 10]) + \ (FDD_HARQ_DELAY_DL_MS - FDD_HARQ_DELAY_UL_MS)) #define tti_pusch_gr(sf) \ (sf->tti + \ - (cell.frame_type == SRSLTE_FDD ? FDD_HARQ_DELAY_UL_MS \ + (cell.frame_type == SRSRAN_FDD ? FDD_HARQ_DELAY_UL_MS \ : dci->ul_idx == 1 ? 7 : k_pusch[sf->tdd_config.sf_config][sf->tti % 10]) + \ (FDD_HARQ_DELAY_DL_MS - FDD_HARQ_DELAY_UL_MS)) // SF->TTI is at which Format0 dci is received -void phy_common::set_ul_pending_grant(srslte_dl_sf_cfg_t* sf, uint32_t cc_idx, srslte_dci_ul_t* dci) +void phy_common::set_ul_pending_grant(srsran_dl_sf_cfg_t* sf, uint32_t cc_idx, srsran_dci_ul_t* dci) { std::lock_guard lock(pending_ul_grant_mutex); @@ -334,7 +334,7 @@ void phy_common::set_ul_pending_grant(srslte_dl_sf_cfg_t* sf, uint32_t cc_idx, s } // SF->TTI at which PUSCH should be transmitted -bool phy_common::get_ul_pending_grant(srslte_ul_sf_cfg_t* sf, uint32_t cc_idx, uint32_t* pid, srslte_dci_ul_t* dci) +bool phy_common::get_ul_pending_grant(srsran_ul_sf_cfg_t* sf, uint32_t cc_idx, uint32_t* pid, srsran_dci_ul_t* dci) { std::lock_guard lock(pending_ul_grant_mutex); bool ret = false; @@ -368,11 +368,11 @@ uint32_t phy_common::get_ul_uci_cc(uint32_t tti_tx) const } // SF->TTI at which PHICH is received -void phy_common::set_ul_received_ack(srslte_dl_sf_cfg_t* sf, +void phy_common::set_ul_received_ack(srsran_dl_sf_cfg_t* sf, uint32_t cc_idx, bool ack_value, uint32_t I_phich, - srslte_dci_ul_t* dci_ul) + srsran_dci_ul_t* dci_ul) { std::lock_guard lock(received_ul_ack_mutex); received_ul_ack_t& received_ack = received_ul_ack[cc_idx][tti_pusch_hi(sf)]; @@ -384,7 +384,7 @@ void phy_common::set_ul_received_ack(srslte_dl_sf_cfg_t* sf, } // SF->TTI at which PUSCH will be transmitted -bool phy_common::get_ul_received_ack(srslte_ul_sf_cfg_t* sf, uint32_t cc_idx, bool* ack_value, srslte_dci_ul_t* dci_ul) +bool phy_common::get_ul_received_ack(srsran_ul_sf_cfg_t* sf, uint32_t cc_idx, bool* ack_value, srsran_dci_ul_t* dci_ul) { std::lock_guard lock(received_ul_ack_mutex); bool ret = false; @@ -406,10 +406,10 @@ bool phy_common::get_ul_received_ack(srslte_ul_sf_cfg_t* sf, uint32_t cc_idx, bo } // SF->TTI at which PDSCH is decoded and ACK generated -void phy_common::set_dl_pending_ack(srslte_dl_sf_cfg_t* sf, +void phy_common::set_dl_pending_ack(srsran_dl_sf_cfg_t* sf, uint32_t cc_idx, - uint8_t value[SRSLTE_MAX_CODEWORDS], - srslte_pdsch_ack_resource_t resource) + uint8_t value[SRSRAN_MAX_CODEWORDS], + srsran_pdsch_ack_resource_t resource) { std::lock_guard lock(pending_dl_ack_mutex); received_ack_t& pending_ack = pending_dl_ack[cc_idx][sf->tti]; @@ -417,7 +417,7 @@ void phy_common::set_dl_pending_ack(srslte_dl_sf_cfg_t* sf, if (!pending_ack.enable) { pending_ack.enable = true; pending_ack.resource = resource; - memcpy(pending_ack.value, value, SRSLTE_MAX_CODEWORDS * sizeof(uint8_t)); + memcpy(pending_ack.value, value, SRSRAN_MAX_CODEWORDS * sizeof(uint8_t)); Debug("Set dl pending ack for sf->tti=%d, value=%d, ncce=%d", sf->tti, value[0], resource.n_cce); } else { Warning("pending_dl_ack: sf->tti=%d, cc=%d already in use", sf->tti, cc_idx); @@ -432,7 +432,7 @@ void phy_common::set_rar_grant_tti(uint32_t tti) void phy_common::set_dl_pending_grant(uint32_t tti, uint32_t cc_idx, uint32_t grant_cc_idx, - const srslte_dci_dl_t* dl_dci) + const srsran_dci_dl_t* dl_dci) { std::lock_guard lock(pending_dl_grant_mutex); if (!pending_dl_grant[tti % FDD_HARQ_DELAY_UL_MS][cc_idx].enable) { @@ -444,7 +444,7 @@ void phy_common::set_dl_pending_grant(uint32_t tti, } } -bool phy_common::get_dl_pending_grant(uint32_t tti, uint32_t cc_idx, uint32_t* grant_cc_idx, srslte_dci_dl_t* dl_dci) +bool phy_common::get_dl_pending_grant(uint32_t tti, uint32_t cc_idx, uint32_t* grant_cc_idx, srsran_dci_dl_t* dl_dci) { std::lock_guard lock(pending_dl_grant_mutex); if (pending_dl_grant[tti % FDD_HARQ_DELAY_UL_MS][cc_idx].enable) { @@ -488,26 +488,26 @@ das_index_t das_table[7][10] = { {{0, {}}, {0, {}}, {1, {7}}, {1, {7}}, {1, {5}}, {0, {}}, {0, {}}, {1, {7}}, {1, {7}}, {0, {}}}}; // SF->TTI at which ACK/NACK would be transmitted -bool phy_common::get_dl_pending_ack(srslte_ul_sf_cfg_t* sf, uint32_t cc_idx, srslte_pdsch_ack_cc_t* ack) +bool phy_common::get_dl_pending_ack(srsran_ul_sf_cfg_t* sf, uint32_t cc_idx, srsran_pdsch_ack_cc_t* ack) { std::lock_guard lock(pending_dl_ack_mutex); bool ret = false; uint32_t M; - if (cell.frame_type == SRSLTE_FDD) { + if (cell.frame_type == SRSRAN_FDD) { M = 1; } else { M = das_table[sf->tdd_config.sf_config][sf->tti % 10].M; } for (uint32_t i = 0; i < M; i++) { uint32_t k = - (cell.frame_type == SRSLTE_FDD) ? FDD_HARQ_DELAY_UL_MS : das_table[sf->tdd_config.sf_config][sf->tti % 10].K[i]; + (cell.frame_type == SRSRAN_FDD) ? FDD_HARQ_DELAY_UL_MS : das_table[sf->tdd_config.sf_config][sf->tti % 10].K[i]; uint32_t pdsch_tti = TTI_SUB(sf->tti, k + (FDD_HARQ_DELAY_DL_MS - FDD_HARQ_DELAY_UL_MS)); received_ack_t& pending_ack = pending_dl_ack[cc_idx][pdsch_tti]; if (pending_ack.enable) { ack->m[i].present = true; ack->m[i].k = k; ack->m[i].resource = pending_ack.resource; - memcpy(ack->m[i].value, pending_ack.value, SRSLTE_MAX_CODEWORDS * sizeof(uint8_t)); + memcpy(ack->m[i].value, pending_ack.value, SRSRAN_MAX_CODEWORDS * sizeof(uint8_t)); Debug("Get dl pending ack for sf->tti=%d, i=%d, k=%d, pdsch_tti=%d, value=%d, ncce=%d, v_dai=%d", sf->tti, i, @@ -533,8 +533,8 @@ bool phy_common::get_dl_pending_ack(srslte_ul_sf_cfg_t* sf, uint32_t cc_idx, srs */ void phy_common::worker_end(void* tx_sem_id, bool tx_enable, - srslte::rf_buffer_t& buffer, - srslte::rf_timestamp_t& tx_time, + srsran::rf_buffer_t& buffer, + srsran::rf_timestamp_t& tx_time, bool is_nr) { // Wait for the green light to transmit in the current TTI @@ -581,7 +581,7 @@ void phy_common::worker_end(void* tx_sem_id, } else { if (!radio_h->get_is_start_of_burst()) { if (ul_channel) { - srslte_vec_cf_zero(zeros_multi.get(0), buffer.get_nof_samples()); + srsran_vec_cf_zero(zeros_multi.get(0), buffer.get_nof_samples()); ul_channel->run(zeros_multi.to_cf_t(), zeros_multi.to_cf_t(), buffer.get_nof_samples(), tx_time.get(0)); } @@ -598,12 +598,12 @@ void phy_common::worker_end(void* tx_sem_id, semaphore.release(); } -void phy_common::set_cell(const srslte_cell_t& c) +void phy_common::set_cell(const srsran_cell_t& c) { cell = c; if (ul_channel) { - ul_channel->set_srate((uint32_t)srslte_sampling_freq_hz(cell.nof_prb)); + ul_channel->set_srate((uint32_t)srsran_sampling_freq_hz(cell.nof_prb)); } } @@ -612,12 +612,12 @@ void phy_common::update_cfo_measurement(uint32_t cc_idx, float cfo_hz) std::unique_lock lock(meas_mutex); // use SNR EMA coefficient for averaging - avg_cfo_hz[cc_idx] = SRSLTE_VEC_EMA(cfo_hz, avg_cfo_hz[cc_idx], args->snr_ema_coeff); + avg_cfo_hz[cc_idx] = SRSRAN_VEC_EMA(cfo_hz, avg_cfo_hz[cc_idx], args->snr_ema_coeff); } void phy_common::update_measurements(uint32_t cc_idx, - srslte_chest_dl_res_t chest_res, - srslte_dl_sf_cfg_t sf_cfg_dl, + srsran_chest_dl_res_t chest_res, + srsran_dl_sf_cfg_t sf_cfg_dl, float tx_crs_power, std::vector& serving_cells, cf_t* rssi_power_buffer) @@ -629,8 +629,8 @@ void phy_common::update_measurements(uint32_t cc_idx, float snr_ema_coeff = args->snr_ema_coeff; // In TDD, ignore special subframes without PDSCH - if (srslte_sfidx_tdd_type(sf_cfg_dl.tdd_config, sf_cfg_dl.tti % 10) == SRSLTE_TDD_SF_S && - srslte_sfidx_tdd_nof_dw(sf_cfg_dl.tdd_config) < 4) { + if (srsran_sfidx_tdd_type(sf_cfg_dl.tdd_config, sf_cfg_dl.tti % 10) == SRSRAN_TDD_SF_S && + srsran_sfidx_tdd_nof_dw(sf_cfg_dl.tdd_config) < 4) { return; } @@ -638,13 +638,13 @@ void phy_common::update_measurements(uint32_t cc_idx, if (rssi_power_buffer) { if (!rssi_read_cnt) { // Average RSSI over all symbols in antenna port 0 (make sure SF length is non-zero) - float rssi_dbm = SRSLTE_SF_LEN_PRB(cell.nof_prb) > 0 - ? (srslte_convert_power_to_dB( - srslte_vec_avg_power_cf(rssi_power_buffer, SRSLTE_SF_LEN_PRB(cell.nof_prb))) + + float rssi_dbm = SRSRAN_SF_LEN_PRB(cell.nof_prb) > 0 + ? (srsran_convert_power_to_dB( + srsran_vec_avg_power_cf(rssi_power_buffer, SRSRAN_SF_LEN_PRB(cell.nof_prb))) + 30) : 0; if (std::isnormal(rssi_dbm)) { - avg_rssi_dbm[0] = SRSLTE_VEC_EMA(rssi_dbm, avg_rssi_dbm[0], args->snr_ema_coeff); + avg_rssi_dbm[0] = SRSRAN_VEC_EMA(rssi_dbm, avg_rssi_dbm[0], args->snr_ema_coeff); } rx_gain_offset = get_radio()->get_rx_gain() + args->rx_gain_offset; @@ -661,7 +661,7 @@ void phy_common::update_measurements(uint32_t cc_idx, if (!(sf_cfg_dl.tti % pcell_report_period) || !std::isnormal(avg_rsrq_db[cc_idx])) { avg_rsrq_db[cc_idx] = rsrq_db; } else { - avg_rsrq_db[cc_idx] = SRSLTE_VEC_CMA(rsrq_db, avg_rsrq_db[cc_idx], sf_cfg_dl.tti % pcell_report_period); + avg_rsrq_db[cc_idx] = SRSRAN_VEC_CMA(rsrq_db, avg_rsrq_db[cc_idx], sf_cfg_dl.tti % pcell_report_period); } } @@ -671,7 +671,7 @@ void phy_common::update_measurements(uint32_t cc_idx, if (!std::isnormal(avg_rsrp[cc_idx])) { avg_rsrp[cc_idx] = rsrp_lin; } else { - avg_rsrp[cc_idx] = SRSLTE_VEC_EMA(rsrp_lin, avg_rsrp[cc_idx], snr_ema_coeff); + avg_rsrp[cc_idx] = SRSRAN_VEC_EMA(rsrp_lin, avg_rsrp[cc_idx], snr_ema_coeff); } } @@ -683,7 +683,7 @@ void phy_common::update_measurements(uint32_t cc_idx, if (!(sf_cfg_dl.tti % pcell_report_period) || !std::isnormal(avg_rsrp_dbm[cc_idx])) { avg_rsrp_dbm[cc_idx] = rsrp_dbm; } else { - avg_rsrp_dbm[cc_idx] = SRSLTE_VEC_CMA(rsrp_dbm, avg_rsrp_dbm[cc_idx], sf_cfg_dl.tti % pcell_report_period); + avg_rsrp_dbm[cc_idx] = SRSRAN_VEC_CMA(rsrp_dbm, avg_rsrp_dbm[cc_idx], sf_cfg_dl.tti % pcell_report_period); } } @@ -696,20 +696,20 @@ void phy_common::update_measurements(uint32_t cc_idx, if (!std::isnormal(avg_noise[cc_idx])) { avg_noise[cc_idx] = cur_noise; } else { - avg_noise[cc_idx] = SRSLTE_VEC_EMA(cur_noise, avg_noise[cc_idx], snr_ema_coeff); + avg_noise[cc_idx] = SRSRAN_VEC_EMA(cur_noise, avg_noise[cc_idx], snr_ema_coeff); } } // Calculate SINR using CRS from neighbours if are detected float sinr_db = chest_res.snr_db; if (std::isnormal(avg_rsrp_neigh[cc_idx])) { - cur_noise /= srslte_convert_dB_to_power(rx_gain_offset - 30); + cur_noise /= srsran_convert_dB_to_power(rx_gain_offset - 30); // Normalize the measured power ot the fraction of CRS pilots per PRB. Assume all neighbours have the same // number of ports and CP length - uint32_t nof_re_x_prb = SRSLTE_NRE * (SRSLTE_CP_NSYMB(cell.cp)); - float factor = nof_re_x_prb / (srslte_refsignal_cs_nof_pilots_x_slot(cell.nof_ports)); - sinr_db = avg_rsrp_dbm[cc_idx] - srslte_convert_power_to_dB(avg_rsrp_neigh[cc_idx] / factor + cur_noise); + uint32_t nof_re_x_prb = SRSRAN_NRE * (SRSRAN_CP_NSYMB(cell.cp)); + float factor = nof_re_x_prb / (srsran_refsignal_cs_nof_pilots_x_slot(cell.nof_ports)); + sinr_db = avg_rsrp_dbm[cc_idx] - srsran_convert_power_to_dB(avg_rsrp_neigh[cc_idx] / factor + cur_noise); } // Average sinr in the log domain @@ -717,7 +717,7 @@ void phy_common::update_measurements(uint32_t cc_idx, if (!std::isnormal(avg_sinr_db[cc_idx])) { avg_sinr_db[cc_idx] = sinr_db; } else { - avg_sinr_db[cc_idx] = SRSLTE_VEC_EMA(sinr_db, avg_sinr_db[cc_idx], snr_ema_coeff); + avg_sinr_db[cc_idx] = SRSRAN_VEC_EMA(sinr_db, avg_sinr_db[cc_idx], snr_ema_coeff); } } @@ -726,7 +726,7 @@ void phy_common::update_measurements(uint32_t cc_idx, if (!std::isnormal(avg_snr_db[cc_idx])) { avg_snr_db[cc_idx] = chest_res.snr_db; } else { - avg_snr_db[cc_idx] = SRSLTE_VEC_EMA(chest_res.snr_db, avg_snr_db[cc_idx], snr_ema_coeff); + avg_snr_db[cc_idx] = SRSRAN_VEC_EMA(chest_res.snr_db, avg_snr_db[cc_idx], snr_ema_coeff); } } @@ -799,7 +799,7 @@ void phy_common::set_dl_metrics(uint32_t cc_idx, const dl_metrics_t& m) dl_metrics[cc_idx].turbo_iters + (m.turbo_iters - dl_metrics[cc_idx].turbo_iters) / dl_metrics_count[cc_idx]; } -void phy_common::get_dl_metrics(dl_metrics_t m[SRSLTE_MAX_CARRIERS]) +void phy_common::get_dl_metrics(dl_metrics_t m[SRSRAN_MAX_CARRIERS]) { std::unique_lock lock(metrics_mutex); @@ -826,7 +826,7 @@ void phy_common::set_ch_metrics(uint32_t cc_idx, const ch_metrics_t& m) ch_metrics[cc_idx].pathloss + (m.pathloss - ch_metrics[cc_idx].pathloss) / ch_metrics_count[cc_idx]; } -void phy_common::get_ch_metrics(ch_metrics_t m[SRSLTE_MAX_CARRIERS]) +void phy_common::get_ch_metrics(ch_metrics_t m[SRSRAN_MAX_CARRIERS]) { std::unique_lock lock(metrics_mutex); @@ -846,7 +846,7 @@ void phy_common::set_ul_metrics(uint32_t cc_idx, const ul_metrics_t& m) ul_metrics[cc_idx].power = ul_metrics[cc_idx].power + (m.power - ul_metrics[cc_idx].power) / ul_metrics_count[cc_idx]; } -void phy_common::get_ul_metrics(ul_metrics_t m[SRSLTE_MAX_CARRIERS]) +void phy_common::get_ul_metrics(ul_metrics_t m[SRSRAN_MAX_CARRIERS]) { std::unique_lock lock(metrics_mutex); @@ -869,7 +869,7 @@ void phy_common::set_sync_metrics(const uint32_t& cc_idx, const sync_metrics_t& sync_metrics[cc_idx].speed_kmph = m.speed_kmph; } -void phy_common::get_sync_metrics(sync_metrics_t m[SRSLTE_MAX_CARRIERS]) +void phy_common::get_sync_metrics(sync_metrics_t m[SRSRAN_MAX_CARRIERS]) { std::unique_lock lock(metrics_mutex); @@ -952,9 +952,9 @@ void phy_common::build_mch_table() bzero(&mch_table[0], sizeof(uint8_t) * 40); // 40 element table represents 4 frames (40 subframes) - if (mbsfn_config.mbsfn_subfr_cnfg.nof_alloc_subfrs == srslte::mbsfn_sf_cfg_t::sf_alloc_type_t::one_frame) { + if (mbsfn_config.mbsfn_subfr_cnfg.nof_alloc_subfrs == srsran::mbsfn_sf_cfg_t::sf_alloc_type_t::one_frame) { generate_mch_table(&mch_table[0], (uint32_t)mbsfn_config.mbsfn_subfr_cnfg.sf_alloc, 1u); - } else if (mbsfn_config.mbsfn_subfr_cnfg.nof_alloc_subfrs == srslte::mbsfn_sf_cfg_t::sf_alloc_type_t::four_frames) { + } else if (mbsfn_config.mbsfn_subfr_cnfg.nof_alloc_subfrs == srsran::mbsfn_sf_cfg_t::sf_alloc_type_t::four_frames) { generate_mch_table(&mch_table[0], (uint32_t)mbsfn_config.mbsfn_subfr_cnfg.sf_alloc, 4u); } else { logger.error("The subframe config has not been set for MBSFN"); @@ -1000,7 +1000,7 @@ void phy_common::set_mch_period_stop(uint32_t stop) uint32_t phy_common::get_ul_earfcn(uint32_t dl_earfcn) { // Set default UL-EARFCN - uint32_t ul_earfcn = srslte_band_ul_earfcn(dl_earfcn); + uint32_t ul_earfcn = srsran_band_ul_earfcn(dl_earfcn); // Try to find current DL-EARFCN in the map auto it = args->ul_earfcn_map.find(dl_earfcn); @@ -1012,7 +1012,7 @@ uint32_t phy_common::get_ul_earfcn(uint32_t dl_earfcn) return ul_earfcn; } -bool phy_common::is_mch_subframe(srslte_mbsfn_cfg_t* cfg, uint32_t phy_tti) +bool phy_common::is_mch_subframe(srsran_mbsfn_cfg_t* cfg, uint32_t phy_tti) { uint32_t sfn; // System Frame Number uint8_t sf; // Subframe @@ -1037,21 +1037,21 @@ bool phy_common::is_mch_subframe(srslte_mbsfn_cfg_t* cfg, uint32_t phy_tti) // Not MCCH, check for MCH if (sib13_configured) { - srslte::mbsfn_sf_cfg_t& subfr_cnfg = mbsfn_config.mbsfn_subfr_cnfg; - srslte::mbsfn_area_info_t& area_info = mbsfn_config.mbsfn_area_info; + srsran::mbsfn_sf_cfg_t& subfr_cnfg = mbsfn_config.mbsfn_subfr_cnfg; + srsran::mbsfn_area_info_t& area_info = mbsfn_config.mbsfn_area_info; offset = subfr_cnfg.radioframe_alloc_offset; - period = srslte::enum_to_number(subfr_cnfg.radioframe_alloc_period); + period = srsran::enum_to_number(subfr_cnfg.radioframe_alloc_period); if (period == (uint8_t)-1) { return false; } - if (subfr_cnfg.nof_alloc_subfrs == srslte::mbsfn_sf_cfg_t::sf_alloc_type_t::one_frame) { + if (subfr_cnfg.nof_alloc_subfrs == srsran::mbsfn_sf_cfg_t::sf_alloc_type_t::one_frame) { if ((sfn % period == offset) && (mch_table[sf] > 0)) { cfg->mbsfn_area_id = area_info.mbsfn_area_id; cfg->non_mbsfn_region_length = enum_to_number(area_info.non_mbsfn_region_len); if (mcch_configured) { // Iterate through PMCH configs to see which one applies in the current frame - srslte::mcch_msg_t& mcch = mbsfn_config.mcch; + srsran::mcch_msg_t& mcch = mbsfn_config.mcch; uint32_t mbsfn_per_frame = mcch.pmch_info_list[0].sf_alloc_end / enum_to_number(mcch.pmch_info_list[0].mch_sched_period); uint32_t frame_alloc_idx = sfn % enum_to_number(mcch.common_sf_alloc_period); @@ -1075,7 +1075,7 @@ bool phy_common::is_mch_subframe(srslte_mbsfn_cfg_t* cfg, uint32_t phy_tti) } return true; } - } else if (subfr_cnfg.nof_alloc_subfrs == srslte::mbsfn_sf_cfg_t::sf_alloc_type_t::four_frames) { + } else if (subfr_cnfg.nof_alloc_subfrs == srsran::mbsfn_sf_cfg_t::sf_alloc_type_t::four_frames) { uint8_t idx = sfn % period; if ((idx >= offset) && (idx < offset + 4)) { if (mch_table[(idx * 10) + sf] > 0) { @@ -1093,7 +1093,7 @@ bool phy_common::is_mch_subframe(srslte_mbsfn_cfg_t* cfg, uint32_t phy_tti) return false; } -bool phy_common::is_mcch_subframe(srslte_mbsfn_cfg_t* cfg, uint32_t phy_tti) +bool phy_common::is_mcch_subframe(srsran_mbsfn_cfg_t* cfg, uint32_t phy_tti) { uint32_t sfn; // System Frame Number uint8_t sf; // Subframe @@ -1104,7 +1104,7 @@ bool phy_common::is_mcch_subframe(srslte_mbsfn_cfg_t* cfg, uint32_t phy_tti) sf = (uint8_t)(phy_tti % 10); if (sib13_configured) { - srslte::mbsfn_area_info_t& area_info = mbsfn_config.mbsfn_area_info; + srsran::mbsfn_area_info_t& area_info = mbsfn_config.mbsfn_area_info; offset = area_info.mcch_cfg.mcch_offset; period = enum_to_number(area_info.mcch_cfg.mcch_repeat_period); @@ -1122,7 +1122,7 @@ bool phy_common::is_mcch_subframe(srslte_mbsfn_cfg_t* cfg, uint32_t phy_tti) return false; } -bool phy_common::is_mbsfn_sf(srslte_mbsfn_cfg_t* cfg, uint32_t phy_tti) +bool phy_common::is_mbsfn_sf(srsran_mbsfn_cfg_t* cfg, uint32_t phy_tti) { return is_mch_subframe(cfg, phy_tti); } diff --git a/srsue/src/phy/prach.cc b/srsue/src/phy/prach.cc index b95f629d0..3d4013bdb 100644 --- a/srsue/src/phy/prach.cc +++ b/srsue/src/phy/prach.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,21 +11,21 @@ */ #include "srsue/hdr/phy/prach.h" -#include "srslte/common/standard_streams.h" -#include "srslte/interfaces/phy_interface_types.h" -#include "srslte/srslte.h" +#include "srsran/common/standard_streams.h" +#include "srsran/interfaces/phy_interface_types.h" +#include "srsran/srsran.h" #define Error(fmt, ...) \ - if (SRSLTE_DEBUG_ENABLED) \ + if (SRSRAN_DEBUG_ENABLED) \ logger.error(fmt, ##__VA_ARGS__) #define Warning(fmt, ...) \ - if (SRSLTE_DEBUG_ENABLED) \ + if (SRSRAN_DEBUG_ENABLED) \ logger.warning(fmt, ##__VA_ARGS__) #define Info(fmt, ...) \ - if (SRSLTE_DEBUG_ENABLED) \ + if (SRSRAN_DEBUG_ENABLED) \ logger.info(fmt, ##__VA_ARGS__) #define Debug(fmt, ...) \ - if (SRSLTE_DEBUG_ENABLED) \ + if (SRSRAN_DEBUG_ENABLED) \ logger.debug(fmt, ##__VA_ARGS__) using namespace srsue; @@ -34,7 +34,7 @@ void prach::init(uint32_t max_prb) { for (auto& i : buffer) { for (auto& j : i) { - j = srslte_vec_cf_malloc(SRSLTE_PRACH_MAX_LEN); + j = srsran_vec_cf_malloc(SRSRAN_PRACH_MAX_LEN); if (!j) { perror("malloc"); return; @@ -42,20 +42,20 @@ void prach::init(uint32_t max_prb) } } - if (srslte_cfo_init(&cfo_h, SRSLTE_PRACH_MAX_LEN)) { + if (srsran_cfo_init(&cfo_h, SRSRAN_PRACH_MAX_LEN)) { ERROR("PRACH: Error initiating CFO"); return; } - srslte_cfo_set_tol(&cfo_h, 0); + srsran_cfo_set_tol(&cfo_h, 0); - signal_buffer = srslte_vec_cf_malloc(MAX_LEN_SF * 30720U); + signal_buffer = srsran_vec_cf_malloc(MAX_LEN_SF * 30720U); if (!signal_buffer) { perror("malloc"); return; } - if (srslte_prach_init(&prach_obj, srslte_symbol_sz(max_prb))) { + if (srsran_prach_init(&prach_obj, srsran_symbol_sz(max_prb))) { Error("Initiating PRACH library"); return; } @@ -76,12 +76,12 @@ void prach::stop() } free(signal_buffer); - srslte_cfo_free(&cfo_h); - srslte_prach_free(&prach_obj); + srsran_cfo_free(&cfo_h); + srsran_prach_free(&prach_obj); mem_initiated = false; } -bool prach::set_cell(srslte_cell_t cell_, srslte_prach_cfg_t prach_cfg) +bool prach::set_cell(srsran_cell_t cell_, srsran_prach_cfg_t prach_cfg) { if (!mem_initiated) { ERROR("PRACH: Error must call init() first"); @@ -97,7 +97,7 @@ bool prach::set_cell(srslte_cell_t cell_, srslte_prach_cfg_t prach_cfg) // We must not reset preamble_idx here, MAC might have already called prepare_to_send() if (6 + prach_cfg.freq_offset > cell.nof_prb) { - srslte::console("Error no space for PRACH: frequency offset=%d, N_rb_ul=%d\n", prach_cfg.freq_offset, cell.nof_prb); + srsran::console("Error no space for PRACH: frequency offset=%d, N_rb_ul=%d\n", prach_cfg.freq_offset, cell.nof_prb); logger.error("Error no space for PRACH: frequency offset=%d, N_rb_ul=%d", prach_cfg.freq_offset, cell.nof_prb); return false; } @@ -109,7 +109,7 @@ bool prach::set_cell(srslte_cell_t cell_, srslte_prach_cfg_t prach_cfg) prach_cfg.zero_corr_zone, prach_cfg.freq_offset); - if (srslte_prach_set_cfg(&prach_obj, &prach_cfg, cell.nof_prb)) { + if (srsran_prach_set_cfg(&prach_obj, &prach_cfg, cell.nof_prb)) { Error("Initiating PRACH library"); return false; } @@ -131,11 +131,11 @@ bool prach::generate_buffer(uint32_t f_idx) } uint32_t freq_offset = cfg.freq_offset; - if (cell.frame_type == SRSLTE_TDD) { - freq_offset = srslte_prach_f_ra_tdd( + if (cell.frame_type == SRSRAN_TDD) { + freq_offset = srsran_prach_f_ra_tdd( cfg.config_idx, cfg.tdd_config.sf_config, (f_idx / 6) * 10, f_idx % 6, cfg.freq_offset, cell.nof_prb); } - if (srslte_prach_gen(&prach_obj, preamble_idx, freq_offset, buffer[f_idx][preamble_idx])) { + if (srsran_prach_gen(&prach_obj, preamble_idx, freq_offset, buffer[f_idx][preamble_idx])) { Error("Generating PRACH preamble %d", preamble_idx); return false; } @@ -171,7 +171,7 @@ bool prach::is_ready_to_send(uint32_t current_tti_, uint32_t current_pci) if (is_pending() && current_pci == cell.id) { // consider the number of subframes the transmission must be anticipated uint32_t tti_tx = TTI_TX(current_tti_); - if (srslte_prach_tti_opportunity(&prach_obj, tti_tx, allowed_subframe)) { + if (srsran_prach_tti_opportunity(&prach_obj, tti_tx, allowed_subframe)) { Debug("PRACH Buffer: Ready to send at tti: %d (now is %d)", tti_tx, current_tti_); transmitted_tti = tti_tx; return true; @@ -187,9 +187,9 @@ phy_interface_mac_lte::prach_info_t prach::get_info() const info.preamble_format = prach_obj.config_idx / 16; if (transmitted_tti >= 0) { info.tti_ra = (uint32_t)transmitted_tti; - if (cell.frame_type == SRSLTE_TDD) { + if (cell.frame_type == SRSRAN_TDD) { info.f_id = - srslte_prach_f_id_tdd(prach_obj.config_idx, prach_obj.tdd_config.sf_config, prach_obj.current_prach_idx); + srsran_prach_f_id_tdd(prach_obj.config_idx, prach_obj.tdd_config.sf_config, prach_obj.current_prach_idx); } info.is_transmitted = true; } else { @@ -201,7 +201,7 @@ phy_interface_mac_lte::prach_info_t prach::get_info() const cf_t* prach::generate(float cfo, uint32_t* nof_sf, float* target_power) { if (!cell_initiated || preamble_idx < 0 || !nof_sf || unsigned(preamble_idx) >= max_preambles || - !srslte_cell_isvalid(&cell) || len >= MAX_LEN_SF * 30720 || len == 0) { + !srsran_cell_isvalid(&cell) || len >= MAX_LEN_SF * 30720 || len == 0) { Error("PRACH: Invalid parameters: cell_initiated=%d, preamble_idx=%d, cell.nof_prb=%d, len=%d", cell_initiated, preamble_idx, @@ -211,7 +211,7 @@ cf_t* prach::generate(float cfo, uint32_t* nof_sf, float* target_power) } uint32_t f_idx = 0; - if (cell.frame_type == SRSLTE_TDD) { + if (cell.frame_type == SRSRAN_TDD) { f_idx = prach_obj.current_prach_idx; // For format4, choose odd or even position if (prach_obj.config_idx >= 48) { @@ -233,11 +233,11 @@ cf_t* prach::generate(float cfo, uint32_t* nof_sf, float* target_power) } // Correct CFO before transmission - srslte_cfo_correct(&cfo_h, buffer[f_idx][preamble_idx], signal_buffer, cfo / srslte_symbol_sz(cell.nof_prb)); + srsran_cfo_correct(&cfo_h, buffer[f_idx][preamble_idx], signal_buffer, cfo / srsran_symbol_sz(cell.nof_prb)); // pad guard symbols with zeros - uint32_t nsf = (len - 1) / SRSLTE_SF_LEN_PRB(cell.nof_prb) + 1; - srslte_vec_cf_zero(&signal_buffer[len], (nsf * SRSLTE_SF_LEN_PRB(cell.nof_prb) - len)); + uint32_t nsf = (len - 1) / SRSRAN_SF_LEN_PRB(cell.nof_prb) + 1; + srsran_vec_cf_zero(&signal_buffer[len], (nsf * SRSRAN_SF_LEN_PRB(cell.nof_prb) - len)); *nof_sf = nsf; diff --git a/srsue/src/phy/scell/intra_measure.cc b/srsue/src/phy/scell/intra_measure.cc index dbc4caf77..01fa6ea99 100644 --- a/srsue/src/phy/scell/intra_measure.cc +++ b/srsue/src/phy/scell/intra_measure.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -12,16 +12,16 @@ #include "srsue/hdr/phy/scell/intra_measure.h" #define Error(fmt, ...) \ - if (SRSLTE_DEBUG_ENABLED) \ + if (SRSRAN_DEBUG_ENABLED) \ logger.error(fmt, ##__VA_ARGS__) #define Warning(fmt, ...) \ - if (SRSLTE_DEBUG_ENABLED) \ + if (SRSRAN_DEBUG_ENABLED) \ logger.warning(fmt, ##__VA_ARGS__) #define Info(fmt, ...) \ - if (SRSLTE_DEBUG_ENABLED) \ + if (SRSRAN_DEBUG_ENABLED) \ logger.info(fmt, ##__VA_ARGS__) #define Debug(fmt, ...) \ - if (SRSLTE_DEBUG_ENABLED) \ + if (SRSRAN_DEBUG_ENABLED) \ logger.debug(fmt, ##__VA_ARGS__) namespace srsue { @@ -32,7 +32,7 @@ intra_measure::intra_measure(srslog::basic_logger& logger) : scell(logger), logg intra_measure::~intra_measure() { - srslte_ringbuffer_free(&ring_buffer); + srsran_ringbuffer_free(&ring_buffer); scell.deinit(); free(search_buffer); } @@ -49,16 +49,16 @@ void intra_measure::init(uint32_t cc_idx_, phy_common* common, meas_itf* new_cel } // Initialise Reference signal measurement - srslte_refsignal_dl_sync_init(&refsignal_dl_sync); + srsran_refsignal_dl_sync_init(&refsignal_dl_sync); // Start scell scell.init(intra_freq_meas_len_ms); - search_buffer = srslte_vec_cf_malloc(intra_freq_meas_len_ms * SRSLTE_SF_LEN_PRB(SRSLTE_MAX_PRB)); + search_buffer = srsran_vec_cf_malloc(intra_freq_meas_len_ms * SRSRAN_SF_LEN_PRB(SRSRAN_MAX_PRB)); // Initialise buffer for the maximum number of PRB - uint32_t max_required_bytes = (uint32_t)sizeof(cf_t) * intra_freq_meas_len_ms * SRSLTE_SF_LEN_PRB(SRSLTE_MAX_PRB); - if (srslte_ringbuffer_init(&ring_buffer, max_required_bytes)) { + uint32_t max_required_bytes = (uint32_t)sizeof(cf_t) * intra_freq_meas_len_ms * SRSRAN_SF_LEN_PRB(SRSRAN_MAX_PRB); + if (srsran_ringbuffer_init(&ring_buffer, max_required_bytes)) { return; } @@ -75,14 +75,14 @@ void intra_measure::stop() // Wait for the asynchronous thread to finish wait_thread_finish(); - srslte_ringbuffer_stop(&ring_buffer); - srslte_refsignal_dl_sync_free(&refsignal_dl_sync); + srsran_ringbuffer_stop(&ring_buffer); + srsran_refsignal_dl_sync_free(&refsignal_dl_sync); } -void intra_measure::set_primary_cell(uint32_t earfcn, srslte_cell_t cell) +void intra_measure::set_primary_cell(uint32_t earfcn, srsran_cell_t cell) { current_earfcn = earfcn; - current_sflen = (uint32_t)SRSLTE_SF_LEN_PRB(cell.nof_prb); + current_sflen = (uint32_t)SRSRAN_SF_LEN_PRB(cell.nof_prb); serving_cell = cell; } @@ -125,22 +125,22 @@ void intra_measure::write(uint32_t tti, cf_t* data, uint32_t nsamples) if (elapsed_tti >= intra_freq_meas_period_ms) { state.set_state(internal_state::receive); last_measure_tti = tti; - srslte_ringbuffer_reset(&ring_buffer); + srsran_ringbuffer_reset(&ring_buffer); } break; case internal_state::receive: // As nbytes might not match the sub-frame size, make sure that buffer does not overflow - nbytes = SRSLTE_MIN(srslte_ringbuffer_space(&ring_buffer), nbytes); + nbytes = SRSRAN_MIN(srsran_ringbuffer_space(&ring_buffer), nbytes); // Try writing in the buffer - if (srslte_ringbuffer_write(&ring_buffer, data, nbytes) < nbytes) { + if (srsran_ringbuffer_write(&ring_buffer, data, nbytes) < nbytes) { Warning("INTRA: Error writing to ringbuffer (EARFCN=%d)", current_earfcn); // Transition to wait, so it can keep receiving without stopping the component operation state.set_state(internal_state::wait); } else { // As soon as there are enough samples in the buffer, transition to measure - if (srslte_ringbuffer_status(&ring_buffer) >= required_nbytes) { + if (srsran_ringbuffer_status(&ring_buffer) >= required_nbytes) { state.set_state(internal_state::measure); } } @@ -158,7 +158,7 @@ void intra_measure::measure_proc() active_pci_mutex.unlock(); // Read data from buffer and find cells in it - srslte_ringbuffer_read(&ring_buffer, search_buffer, (int)intra_freq_meas_len_ms * current_sflen * sizeof(cf_t)); + srsran_ringbuffer_read(&ring_buffer, search_buffer, (int)intra_freq_meas_len_ms * current_sflen * sizeof(cf_t)); // Go to receive before finishing, so new samples can be enqueued before the thread finishes if (state.get_state() == internal_state::measure) { @@ -185,11 +185,11 @@ void intra_measure::measure_proc() if (id == serving_cell.id) { continue; } - srslte_cell_t cell = serving_cell; + srsran_cell_t cell = serving_cell; cell.id = id; - srslte_refsignal_dl_sync_set_cell(&refsignal_dl_sync, cell); - srslte_refsignal_dl_sync_run(&refsignal_dl_sync, search_buffer, intra_freq_meas_len_ms * current_sflen); + srsran_refsignal_dl_sync_set_cell(&refsignal_dl_sync, cell); + srsran_refsignal_dl_sync_run(&refsignal_dl_sync, search_buffer, intra_freq_meas_len_ms * current_sflen); if (refsignal_dl_sync.found) { phy_meas_t m = {}; diff --git a/srsue/src/phy/scell/scell_recv.cc b/srsue/src/phy/scell/scell_recv.cc index e77dae142..e15a0e524 100644 --- a/srsue/src/phy/scell/scell_recv.cc +++ b/srsue/src/phy/scell/scell_recv.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -23,33 +23,33 @@ void scell_recv::init(uint32_t max_sf_window) { // and a separate ue_sync instance - uint32_t max_fft_sz = (uint32_t)srslte_symbol_sz(100); - uint32_t max_sf_size = SRSLTE_SF_LEN(max_fft_sz); + uint32_t max_fft_sz = (uint32_t)srsran_symbol_sz(100); + uint32_t max_sf_size = SRSRAN_SF_LEN(max_fft_sz); - sf_buffer[0] = srslte_vec_cf_malloc(max_sf_size); + sf_buffer[0] = srsran_vec_cf_malloc(max_sf_size); if (!sf_buffer[0]) { logger.error("Error allocating %d samples for scell", max_sf_size); return; } // do this different we don't need all this search window. - if (srslte_sync_init(&sync_find, max_sf_window * max_sf_size, 5 * max_sf_size, max_fft_sz)) { + if (srsran_sync_init(&sync_find, max_sf_window * max_sf_size, 5 * max_sf_size, max_fft_sz)) { logger.error("Error initiating sync_find"); return; } - srslte_sync_set_sss_algorithm(&sync_find, SSS_FULL); - srslte_sync_set_cfo_cp_enable(&sync_find, false, 0); - srslte_sync_cp_en(&sync_find, false); - srslte_sync_set_cfo_pss_enable(&sync_find, false); - srslte_sync_set_threshold(&sync_find, 2.0f); // The highest the best for avoiding ghost cells - srslte_sync_set_em_alpha(&sync_find, 0.3f); - srslte_sss_set_threshold(&sync_find.sss, 300.0); // A higher value will avoid false alarms but reduce detection + srsran_sync_set_sss_algorithm(&sync_find, SSS_FULL); + srsran_sync_set_cfo_cp_enable(&sync_find, false, 0); + srsran_sync_cp_en(&sync_find, false); + srsran_sync_set_cfo_pss_enable(&sync_find, false); + srsran_sync_set_threshold(&sync_find, 2.0f); // The highest the best for avoiding ghost cells + srsran_sync_set_em_alpha(&sync_find, 0.3f); + srsran_sss_set_threshold(&sync_find.sss, 300.0); // A higher value will avoid false alarms but reduce detection // Configure FIND object behaviour (this configuration is always the same) - srslte_sync_set_cfo_ema_alpha(&sync_find, 1.0); - srslte_sync_set_cfo_i_enable(&sync_find, false); - srslte_sync_set_pss_filt_enable(&sync_find, true); - srslte_sync_set_sss_eq_enable(&sync_find, true); + srsran_sync_set_cfo_ema_alpha(&sync_find, 1.0); + srsran_sync_set_cfo_i_enable(&sync_find, false); + srsran_sync_set_pss_filt_enable(&sync_find, true); + srsran_sync_set_sss_eq_enable(&sync_find, true); sync_find.pss.chest_on_filter = true; sync_find.sss_channel_equalize = false; @@ -59,7 +59,7 @@ void scell_recv::init(uint32_t max_sf_window) void scell_recv::deinit() { - srslte_sync_free(&sync_find); + srsran_sync_free(&sync_find); free(sf_buffer[0]); } @@ -69,15 +69,15 @@ void scell_recv::reset() } std::set -scell_recv::find_cells(const cf_t* input_buffer, const srslte_cell_t serving_cell, const uint32_t nof_sf) +scell_recv::find_cells(const cf_t* input_buffer, const srsran_cell_t serving_cell, const uint32_t nof_sf) { std::set found_cell_ids = {}; - uint32_t fft_sz = srslte_symbol_sz(serving_cell.nof_prb); - uint32_t sf_len = SRSLTE_SF_LEN(fft_sz); + uint32_t fft_sz = srsran_symbol_sz(serving_cell.nof_prb); + uint32_t sf_len = SRSRAN_SF_LEN(fft_sz); if (fft_sz != current_fft_sz) { - if (srslte_sync_resize(&sync_find, nof_sf * sf_len, 5 * sf_len, fft_sz)) { + if (srsran_sync_resize(&sync_find, nof_sf * sf_len, 5 * sf_len, fft_sz)) { logger.error("Error resizing sync nof_sf=%d, sf_len=%d, fft_sz=%d", nof_sf, sf_len, fft_sz); return found_cell_ids; } @@ -90,14 +90,14 @@ scell_recv::find_cells(const cf_t* input_buffer, const srslte_cell_t serving_cel for (uint32_t n_id_2 = 0; n_id_2 < 3; n_id_2++) { if (n_id_2 != (serving_cell.id % 3)) { - srslte_sync_set_N_id_2(&sync_find, n_id_2); + srsran_sync_set_N_id_2(&sync_find, n_id_2); - srslte_sync_find_ret_t sync_res; + srsran_sync_find_ret_t sync_res; - srslte_sync_reset(&sync_find); - srslte_sync_cfo_reset(&sync_find, 0.0f); + srsran_sync_reset(&sync_find); + srsran_sync_cfo_reset(&sync_find, 0.0f); - sync_res = SRSLTE_SYNC_NOFOUND; + sync_res = SRSRAN_SYNC_NOFOUND; bool sss_detected = false; cell_id = 0; float max_peak = -1; @@ -105,21 +105,20 @@ scell_recv::find_cells(const cf_t* input_buffer, const srslte_cell_t serving_cel float sss_correlation_peak_max = 0.0f; for (uint32_t sf5_cnt = 0; sf5_cnt < nof_sf / 5; sf5_cnt++) { - sync_res = srslte_sync_find(&sync_find, input_buffer, sf5_cnt * 5 * sf_len, &peak_idx); - if (sync_res == SRSLTE_SYNC_ERROR) { + sync_res = srsran_sync_find(&sync_find, input_buffer, sf5_cnt * 5 * sf_len, &peak_idx); + if (sync_res == SRSRAN_SYNC_ERROR) { logger.error("INTRA: Error calling sync_find()"); return found_cell_ids; } - if (sync_find.peak_value > max_peak && sync_res == SRSLTE_SYNC_FOUND && srslte_sync_sss_detected(&sync_find)) { - + if (sync_find.peak_value > max_peak && sync_res == SRSRAN_SYNC_FOUND && srsran_sync_sss_detected(&sync_find)) { // Uses the cell ID from the highest SSS correlation peak - if (sss_correlation_peak_max < srslte_sync_sss_correlation_peak(&sync_find)) { + if (sss_correlation_peak_max < srsran_sync_sss_correlation_peak(&sync_find)) { // Set the cell ID - cell_id = srslte_sync_get_cell_id(&sync_find); + cell_id = srsran_sync_get_cell_id(&sync_find); // Update the maximum value - sss_correlation_peak_max = srslte_sync_sss_correlation_peak(&sync_find); + sss_correlation_peak_max = srsran_sync_sss_correlation_peak(&sync_find); } sss_detected = true; } @@ -131,14 +130,14 @@ scell_recv::find_cells(const cf_t* input_buffer, const srslte_cell_t serving_cel nof_sf / 5, sync_res, cell_id, - srslte_sync_get_sf_idx(&sync_find), + srsran_sync_get_sf_idx(&sync_find), peak_idx, sync_find.peak_value, - srslte_sync_sss_detected(&sync_find)); + srsran_sync_sss_detected(&sync_find)); } // If the SSS was not detected, the serving_cell id is not reliable. So, consider no sync found - if (sync_res == SRSLTE_SYNC_FOUND && sss_detected && cell_id >= 0) { + if (sync_res == SRSRAN_SYNC_FOUND && sss_detected && cell_id >= 0) { // We have found a new cell, add to the list found_cell_ids.insert((uint32_t)cell_id); logger.debug("INTRA: Detected new cell_id=%d using PSS/SSS", cell_id); diff --git a/srsue/src/phy/search.cc b/srsue/src/phy/search.cc index 704d324b5..749d0a0f3 100644 --- a/srsue/src/phy/search.cc +++ b/srsue/src/phy/search.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,53 +11,53 @@ */ #include "srsue/hdr/phy/search.h" -#include "srslte/common/standard_streams.h" +#include "srsran/common/standard_streams.h" #define Error(fmt, ...) \ - if (SRSLTE_DEBUG_ENABLED) \ + if (SRSRAN_DEBUG_ENABLED) \ logger.error(fmt, ##__VA_ARGS__) #define Warning(fmt, ...) \ - if (SRSLTE_DEBUG_ENABLED) \ + if (SRSRAN_DEBUG_ENABLED) \ logger.warning(fmt, ##__VA_ARGS__) #define Info(fmt, ...) \ - if (SRSLTE_DEBUG_ENABLED) \ + if (SRSRAN_DEBUG_ENABLED) \ logger.info(fmt, ##__VA_ARGS__) #define Debug(fmt, ...) \ - if (SRSLTE_DEBUG_ENABLED) \ + if (SRSRAN_DEBUG_ENABLED) \ logger.debug(fmt, ##__VA_ARGS__) namespace srsue { static int -radio_recv_callback(void* obj, cf_t* data[SRSLTE_MAX_CHANNELS], uint32_t nsamples, srslte_timestamp_t* rx_time) +radio_recv_callback(void* obj, cf_t* data[SRSRAN_MAX_CHANNELS], uint32_t nsamples, srsran_timestamp_t* rx_time) { - srslte::rf_buffer_t x(data, nsamples); + srsran::rf_buffer_t x(data, nsamples); return ((search_callback*)obj)->radio_recv_fnc(x, rx_time); } -static SRSLTE_AGC_CALLBACK(callback_set_rx_gain) +static SRSRAN_AGC_CALLBACK(callback_set_rx_gain) { ((search_callback*)h)->set_rx_gain(gain_db); } search::~search() { - srslte_ue_mib_sync_free(&ue_mib_sync); - srslte_ue_cellsearch_free(&cs); + srsran_ue_mib_sync_free(&ue_mib_sync); + srsran_ue_cellsearch_free(&cs); } -void search::init(srslte::rf_buffer_t& buffer_, uint32_t nof_rx_channels, search_callback* parent) +void search::init(srsran::rf_buffer_t& buffer_, uint32_t nof_rx_channels, search_callback* parent) { p = parent; buffer = buffer_; - if (srslte_ue_cellsearch_init_multi(&cs, 8, radio_recv_callback, nof_rx_channels, parent)) { + if (srsran_ue_cellsearch_init_multi(&cs, 8, radio_recv_callback, nof_rx_channels, parent)) { Error("SYNC: Initiating UE cell search"); } - srslte_ue_cellsearch_set_nof_valid_frames(&cs, 4); + srsran_ue_cellsearch_set_nof_valid_frames(&cs, 4); - if (srslte_ue_mib_sync_init_multi(&ue_mib_sync, radio_recv_callback, nof_rx_channels, parent)) { + if (srsran_ue_mib_sync_init_multi(&ue_mib_sync, radio_recv_callback, nof_rx_channels, parent)) { Error("SYNC: Initiating UE MIB synchronization"); } @@ -69,19 +69,19 @@ void search::init(srslte::rf_buffer_t& buffer_, uint32_t nof_rx_channels, search void search::reset() { - srslte_ue_sync_reset(&ue_mib_sync.ue_sync); + srsran_ue_sync_reset(&ue_mib_sync.ue_sync); } float search::get_last_cfo() { - return srslte_ue_sync_get_cfo(&ue_mib_sync.ue_sync); + return srsran_ue_sync_get_cfo(&ue_mib_sync.ue_sync); } void search::set_agc_enable(bool enable) { if (enable) { - srslte_rf_info_t* rf_info = p->get_radio()->get_info(); - srslte_ue_sync_start_agc(&ue_mib_sync.ue_sync, + srsran_rf_info_t* rf_info = p->get_radio()->get_info(); + srsran_ue_sync_start_agc(&ue_mib_sync.ue_sync, callback_set_rx_gain, rf_info->min_rx_gain, rf_info->max_rx_gain, @@ -91,26 +91,26 @@ void search::set_agc_enable(bool enable) } } -search::ret_code search::run(srslte_cell_t* cell_, std::array& bch_payload) +search::ret_code search::run(srsran_cell_t* cell_, std::array& bch_payload) { - srslte_cell_t new_cell = {}; + srsran_cell_t new_cell = {}; - srslte_ue_cellsearch_result_t found_cells[3]; + srsran_ue_cellsearch_result_t found_cells[3]; - bzero(found_cells, 3 * sizeof(srslte_ue_cellsearch_result_t)); + bzero(found_cells, 3 * sizeof(srsran_ue_cellsearch_result_t)); /* Find a cell in the given N_id_2 or go through the 3 of them to find the strongest */ uint32_t max_peak_cell = 0; - int ret = SRSLTE_ERROR; + int ret = SRSRAN_ERROR; Info("SYNC: Searching for cell..."); - srslte::console("."); + srsran::console("."); if (force_N_id_2 >= 0 && force_N_id_2 < 3) { - ret = srslte_ue_cellsearch_scan_N_id_2(&cs, force_N_id_2, &found_cells[force_N_id_2]); + ret = srsran_ue_cellsearch_scan_N_id_2(&cs, force_N_id_2, &found_cells[force_N_id_2]); max_peak_cell = force_N_id_2; } else { - ret = srslte_ue_cellsearch_scan(&cs, found_cells, &max_peak_cell); + ret = srsran_ue_cellsearch_scan(&cs, found_cells, &max_peak_cell); } if (ret < 0) { @@ -126,14 +126,14 @@ search::ret_code search::run(srslte_cell_t* cell_, std::arrayset_ue_sync_opts(&ue_mib_sync.ue_sync, cfo); - srslte_ue_sync_reset(&ue_mib_sync.ue_sync); + srsran_ue_sync_reset(&ue_mib_sync.ue_sync); /* Find and decode MIB */ int sfn_offset; - ret = srslte_ue_mib_sync_decode(&ue_mib_sync, 40, bch_payload.data(), &new_cell.nof_ports, &sfn_offset); + ret = srsran_ue_mib_sync_decode(&ue_mib_sync, 40, bch_payload.data(), &new_cell.nof_ports, &sfn_offset); if (ret == 1) { - srslte_pbch_mib_unpack(bch_payload.data(), &new_cell, NULL); + srsran_pbch_mib_unpack(bch_payload.data(), &new_cell, NULL); // pack MIB and store inplace for PCAP dump - std::array mib_packed; - srslte_bit_pack_vector(bch_payload.data(), mib_packed.data(), SRSLTE_BCH_PAYLOAD_LEN); + std::array mib_packed; + srsran_bit_pack_vector(bch_payload.data(), mib_packed.data(), SRSRAN_BCH_PAYLOAD_LEN); std::copy(std::begin(mib_packed), std::end(mib_packed), std::begin(bch_payload)); fprintf(stdout, @@ -168,7 +168,7 @@ search::ret_code search::run(srslte_cell_t* cell_, std::array& bch_payload, + std::array& bch_payload, bool sfidx_only) { - int ret = srslte_ue_sync_zerocopy(ue_sync, mib_buffer.to_cf_t(), buffer_max_samples); + int ret = srsran_ue_sync_zerocopy(ue_sync, mib_buffer.to_cf_t(), buffer_max_samples); if (ret < 0) { Error("SYNC: Error calling ue_sync_get_buffer."); return ERROR; @@ -97,10 +97,10 @@ sfn_sync::ret_code sfn_sync::run_subframe(srslte_cell_t* return IDLE; } -sfn_sync::ret_code sfn_sync::decode_mib(srslte_cell_t* cell_, +sfn_sync::ret_code sfn_sync::decode_mib(srsran_cell_t* cell_, uint32_t* tti_cnt, - srslte::rf_buffer_t* ext_buffer, - std::array& bch_payload, + srsran::rf_buffer_t* ext_buffer, + std::array& bch_payload, bool sfidx_only) { // If external buffer provided not equal to internal buffer, copy samples from channel/port 0 @@ -108,7 +108,7 @@ sfn_sync::ret_code sfn_sync::decode_mib(srslte_cell_t* memcpy(mib_buffer.get(0), ext_buffer->get(0), sizeof(cf_t) * ue_sync->sf_len); } - if (srslte_ue_sync_get_sfidx(ue_sync) == 0) { + if (srsran_ue_sync_get_sfidx(ue_sync) == 0) { // Skip MIB decoding if we are only interested in subframe 0 if (sfidx_only) { if (tti_cnt) { @@ -118,14 +118,14 @@ sfn_sync::ret_code sfn_sync::decode_mib(srslte_cell_t* } int sfn_offset = 0; - int n = srslte_ue_mib_decode(&ue_mib, bch_payload.data(), NULL, &sfn_offset); + int n = srsran_ue_mib_decode(&ue_mib, bch_payload.data(), NULL, &sfn_offset); switch (n) { default: Error("SYNC: Error decoding MIB while synchronising SFN"); return ERROR; - case SRSLTE_UE_MIB_FOUND: + case SRSRAN_UE_MIB_FOUND: uint32_t sfn; - srslte_pbch_mib_unpack(bch_payload.data(), cell_, &sfn); + srsran_pbch_mib_unpack(bch_payload.data(), cell_, &sfn); sfn = (sfn + sfn_offset) % 1024; if (tti_cnt) { @@ -144,7 +144,7 @@ sfn_sync::ret_code sfn_sync::decode_mib(srslte_cell_t* reset(); return SFN_FOUND; - case SRSLTE_UE_MIB_NOTFOUND: + case SRSRAN_UE_MIB_NOTFOUND: Info("SYNC: Found PSS but could not decode MIB. SNR=%.1f dB (%d/%d)", ue_mib.chest_res.snr_db, cnt, timeout); return SFN_NOFOUND; } diff --git a/srsue/src/phy/sync.cc b/srsue/src/phy/sync.cc index 37afdc076..2a21a40b3 100644 --- a/srsue/src/phy/sync.cc +++ b/srsue/src/phy/sync.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,42 +11,42 @@ */ #include "srsue/hdr/phy/sync.h" -#include "srslte/common/standard_streams.h" -#include "srslte/phy/channel/channel.h" -#include "srslte/srslte.h" +#include "srsran/common/standard_streams.h" +#include "srsran/phy/channel/channel.h" +#include "srsran/srsran.h" #include "srsue/hdr/phy/lte/sf_worker.h" #include #include #define Error(fmt, ...) \ - if (SRSLTE_DEBUG_ENABLED) \ + if (SRSRAN_DEBUG_ENABLED) \ phy_logger.error(fmt, ##__VA_ARGS__) #define Warning(fmt, ...) \ - if (SRSLTE_DEBUG_ENABLED) \ + if (SRSRAN_DEBUG_ENABLED) \ phy_logger.warning(fmt, ##__VA_ARGS__) #define Info(fmt, ...) \ - if (SRSLTE_DEBUG_ENABLED) \ + if (SRSRAN_DEBUG_ENABLED) \ phy_logger.info(fmt, ##__VA_ARGS__) #define Debug(fmt, ...) \ - if (SRSLTE_DEBUG_ENABLED) \ + if (SRSRAN_DEBUG_ENABLED) \ phy_logger.debug(fmt, ##__VA_ARGS__) namespace srsue { static int -radio_recv_callback(void* obj, cf_t* data[SRSLTE_MAX_CHANNELS], uint32_t nsamples, srslte_timestamp_t* rx_time) +radio_recv_callback(void* obj, cf_t* data[SRSRAN_MAX_CHANNELS], uint32_t nsamples, srsran_timestamp_t* rx_time) { - srslte::rf_buffer_t x(data, nsamples); + srsran::rf_buffer_t x(data, nsamples); return ((sync*)obj)->radio_recv_fnc(x, rx_time); } -static SRSLTE_AGC_CALLBACK(callback_set_rx_gain) +static SRSRAN_AGC_CALLBACK(callback_set_rx_gain) { ((sync*)h)->set_rx_gain(gain_db); } -void sync::init(srslte::radio_interface_phy* _radio, +void sync::init(srsran::radio_interface_phy* _radio, stack_interface_phy_lte* _stack, prach* _prach_buffer, lte::worker_pool* _lte_workers_pool, @@ -64,20 +64,20 @@ void sync::init(srslte::radio_interface_phy* _radio, nof_rf_channels = (worker_com->args->nof_lte_carriers + worker_com->args->nof_nr_carriers) * worker_com->args->nof_rx_ant; - if (nof_rf_channels == 0 || nof_rf_channels > SRSLTE_MAX_CHANNELS) { + if (nof_rf_channels == 0 || nof_rf_channels > SRSRAN_MAX_CHANNELS) { Error("SYNC: Invalid number of RF channels (%d)", nof_rf_channels); return; } - if (srslte_ue_sync_init_multi(&ue_sync, SRSLTE_MAX_PRB, false, radio_recv_callback, nof_rf_channels, this) != - SRSLTE_SUCCESS) { + if (srsran_ue_sync_init_multi(&ue_sync, SRSRAN_MAX_PRB, false, radio_recv_callback, nof_rf_channels, this) != + SRSRAN_SUCCESS) { Error("SYNC: Initiating ue_sync"); return; } if (worker_com->args->dl_channel_args.enable) { channel_emulator = - srslte::channel_ptr(new srslte::channel(worker_com->args->dl_channel_args, nof_rf_channels, phy_logger)); + srsran::channel_ptr(new srsran::channel(worker_com->args->dl_channel_args, nof_rf_channels, phy_logger)); } // Initialize cell searcher @@ -115,7 +115,7 @@ void sync::init(srslte::radio_interface_phy* _radio, sync::~sync() { - srslte_ue_sync_free(&ue_sync); + srsran_ue_sync_free(&ue_sync); } void sync::stop() @@ -289,7 +289,7 @@ bool sync::cell_select_init(phy_cell_t new_cell) } // Move state to IDLE - if (!srslte_cellid_isvalid(new_cell.pci)) { + if (!srsran_cellid_isvalid(new_cell.pci)) { Error("Cell Select: Invalid cell_id=%d", new_cell.pci); return false; } @@ -322,7 +322,7 @@ bool sync::cell_select_start(phy_cell_t new_cell) sfn_p.reset(); search_p.reset(); - srslte_ue_sync_reset(&ue_sync); + srsran_ue_sync_reset(&ue_sync); /* Reconfigure cell if necessary */ cell.id = new_cell.pci; @@ -388,15 +388,15 @@ void sync::run_cell_search_state() void sync::run_sfn_sync_state() { - srslte_cell_t temp_cell = cell; + srsran_cell_t temp_cell = cell; switch (sfn_p.run_subframe(&temp_cell, &tti, mib)) { case sfn_sync::SFN_FOUND: - if (memcmp(&cell, &temp_cell, sizeof(srslte_cell_t)) != 0) { - srslte_cell_fprint(stdout, &cell, 0); - srslte_cell_fprint(stdout, &temp_cell, 0); + if (memcmp(&cell, &temp_cell, sizeof(srsran_cell_t)) != 0) { + srsran_cell_fprint(stdout, &cell, 0); + srsran_cell_fprint(stdout, &temp_cell, 0); phy_logger.error("Detected cell during SFN synchronization differs from configured cell. Cell reselection to " "cells with different MIB is not supported"); - srslte::console("Detected cell during SFN synchronization differs from configured cell. Cell reselection " + srsran::console("Detected cell during SFN synchronization differs from configured cell. Cell reselection " "to cells with different MIB is not supported\n"); phy_state.state_exit(false); } @@ -413,16 +413,16 @@ void sync::run_sfn_sync_state() void sync::run_camping_in_sync_state(lte::sf_worker* lte_worker, nr::sf_worker* nr_worker, - srslte::rf_buffer_t& sync_buffer) + srsran::rf_buffer_t& sync_buffer) { // Update logging TTI phy_lib_logger.set_context(tti); phy_logger.set_context(tti); // Check tti is synched with ue_sync - if (srslte_ue_sync_get_sfidx(&ue_sync) != tti % 10) { + if (srsran_ue_sync_get_sfidx(&ue_sync) != tti % 10) { uint32_t sfn = tti / 10; - tti = (sfn * 10 + srslte_ue_sync_get_sfidx(&ue_sync)) % 10240; + tti = (sfn * 10 + srsran_ue_sync_get_sfidx(&ue_sync)) % 10240; // Force SFN decode, just in case it is in the wrong frame force_camping_sfn_sync = true; @@ -442,7 +442,7 @@ void sync::run_camping_in_sync_state(lte::sf_worker* lte_worker, // Force decode MIB if required if (force_camping_sfn_sync) { uint32_t _tti = 0; - srslte_cell_t temp_cell = cell; + srsran_cell_t temp_cell = cell; sfn_sync::ret_code ret = sfn_p.decode_mib(&temp_cell, &_tti, &sync_buffer, mib); if (ret == sfn_sync::SFN_FOUND) { @@ -452,10 +452,10 @@ void sync::run_camping_in_sync_state(lte::sf_worker* lte_worker, // Disable force_camping_sfn_sync = false; - if (memcmp(&cell, &temp_cell, sizeof(srslte_cell_t)) != 0) { + if (memcmp(&cell, &temp_cell, sizeof(srsran_cell_t)) != 0) { phy_logger.error("Detected cell during SFN synchronization differs from configured cell. Cell " "reselection to cells with different MIB is not supported"); - srslte::console("Detected cell during SFN synchronization differs from configured cell. Cell " + srsran::console("Detected cell during SFN synchronization differs from configured cell. Cell " "reselection to cells with different MIB is not supported\n"); } else { phy_logger.info("SFN resynchronized successfully"); @@ -467,11 +467,9 @@ void sync::run_camping_in_sync_state(lte::sf_worker* lte_worker, Debug("SYNC: Worker %d synchronized", lte_worker->get_id()); - metrics.sfo = srslte_ue_sync_get_sfo(&ue_sync); - metrics.cfo = srslte_ue_sync_get_cfo(&ue_sync); - metrics.ta_us = worker_com->ta.get_usec(); - metrics.distance_km = worker_com->ta.get_km(); - metrics.speed_kmph = worker_com->ta.get_speed_kmph(tti); + metrics.sfo = srsran_ue_sync_get_sfo(&ue_sync); + metrics.cfo = srsran_ue_sync_get_cfo(&ue_sync); + metrics.ta_us = worker_com->ta.get_usec(); for (uint32_t i = 0; i < worker_com->args->nof_lte_carriers; i++) { worker_com->set_sync_metrics(i, metrics); } @@ -484,7 +482,7 @@ void sync::run_camping_in_sync_state(lte::sf_worker* lte_worker, } } - lte_worker->set_prach(prach_ptr ? &prach_ptr[prach_sf_cnt * SRSLTE_SF_LEN_PRB(cell.nof_prb)] : nullptr, prach_power); + lte_worker->set_prach(prach_ptr ? &prach_ptr[prach_sf_cnt * SRSRAN_SF_LEN_PRB(cell.nof_prb)] : nullptr, prach_power); // Execute Serving Cell state FSM worker_com->cell_state.run_tti(tti); @@ -492,7 +490,7 @@ void sync::run_camping_in_sync_state(lte::sf_worker* lte_worker, // Set CFO for all Carriers for (uint32_t cc = 0; cc < worker_com->args->nof_lte_carriers; cc++) { lte_worker->set_cfo_unlocked(cc, get_tx_cfo()); - worker_com->update_cfo_measurement(cc, srslte_ue_sync_get_cfo(&ue_sync)); + worker_com->update_cfo_measurement(cc, srsran_ue_sync_get_cfo(&ue_sync)); } lte_worker->set_tti(tti); @@ -525,7 +523,7 @@ void sync::run_camping_in_sync_state(lte::sf_worker* lte_worker, void sync::run_camping_state() { lte::sf_worker* lte_worker = lte_worker_pool->wait_worker(tti); - srslte::rf_buffer_t sync_buffer = {}; + srsran::rf_buffer_t sync_buffer = {}; if (lte_worker == nullptr) { // wait_worker() only returns NULL if it's being closed. Quit now to avoid unnecessary loops here @@ -556,7 +554,7 @@ void sync::run_camping_state() } // Primary Cell (PCell) Synchronization - switch (srslte_ue_sync_zerocopy(&ue_sync, sync_buffer.to_cf_t(), lte_worker->get_buffer_len())) { + switch (srsran_ue_sync_zerocopy(&ue_sync, sync_buffer.to_cf_t(), lte_worker->get_buffer_len())) { case 1: run_camping_in_sync_state(lte_worker, nr_worker, sync_buffer); break; @@ -590,10 +588,10 @@ void sync::run_idle_state() nsamples = current_srate / 1000; } Debug("Discarding %d samples", nsamples); - srslte_timestamp_t rx_time = {}; + srsran_timestamp_t rx_time = {}; dummy_buffer.set_nof_samples(nsamples); - if (radio_recv_fnc(dummy_buffer, &rx_time) == SRSLTE_SUCCESS) { - srslte::console("SYNC: Receiving from radio while in IDLE_RX\n"); + if (radio_recv_fnc(dummy_buffer, &rx_time) == SRSRAN_SUCCESS) { + srsran::console("SYNC: Receiving from radio while in IDLE_RX\n"); } // If radio is in locked state returns immediately. In that case, do a 1 ms sleep if (rx_time.frac_secs == 0 && rx_time.full_secs == 0) { @@ -682,7 +680,7 @@ void sync::out_of_sync() void sync::set_cfo(float cfo) { - srslte_ue_sync_set_cfo_ref(&ue_sync, cfo); + srsran_ue_sync_set_cfo_ref(&ue_sync, cfo); } void sync::set_agc_enable(bool enable) @@ -705,21 +703,21 @@ void sync::set_agc_enable(bool enable) } // Get radio info and check it is valid - srslte_rf_info_t* rf_info = radio_h->get_info(); + srsran_rf_info_t* rf_info = radio_h->get_info(); if (rf_info == nullptr) { Error("Error: Radio does not provide RF information"); return; } // Enable AGC - srslte_ue_sync_start_agc( + srsran_ue_sync_start_agc( &ue_sync, callback_set_rx_gain, rf_info->min_rx_gain, rf_info->max_rx_gain, radio_h->get_rx_gain()); search_p.set_agc_enable(true); } float sync::get_tx_cfo() { - float cfo = srslte_ue_sync_get_cfo(&ue_sync); + float cfo = srsran_ue_sync_get_cfo(&ue_sync); float ret = cfo * ul_dl_factor; @@ -736,15 +734,15 @@ float sync::get_tx_cfo() return ret / 15000; } -void sync::set_ue_sync_opts(srslte_ue_sync_t* q, float cfo) +void sync::set_ue_sync_opts(srsran_ue_sync_t* q, float cfo) { if (worker_com->args->cfo_integer_enabled) { - srslte_ue_sync_set_cfo_i_enable(q, true); + srsran_ue_sync_set_cfo_i_enable(q, true); } - srslte_ue_sync_set_cfo_ema(q, worker_com->args->cfo_pss_ema); - srslte_ue_sync_set_cfo_tol(q, worker_com->args->cfo_correct_tol_hz); - srslte_ue_sync_set_cfo_loop_bw(q, + srsran_ue_sync_set_cfo_ema(q, worker_com->args->cfo_pss_ema); + srsran_ue_sync_set_cfo_tol(q, worker_com->args->cfo_correct_tol_hz); + srsran_ue_sync_set_cfo_loop_bw(q, worker_com->args->cfo_loop_bw_pss, worker_com->args->cfo_loop_bw_ref, worker_com->args->cfo_loop_pss_tol, @@ -754,16 +752,16 @@ void sync::set_ue_sync_opts(srslte_ue_sync_t* q, float cfo) // Disable CP based CFO estimation during find if (std::isnormal(cfo)) { - srslte_ue_sync_cfo_reset(q, cfo); + srsran_ue_sync_cfo_reset(q, cfo); q->cfo_current_value = cfo / 15000; q->cfo_is_copied = true; q->cfo_correct_enable_find = true; - srslte_sync_set_cfo_cp_enable(&q->sfind, false, 0); + srsran_sync_set_cfo_cp_enable(&q->sfind, false, 0); } // Set SFO ema and correct period - srslte_ue_sync_set_sfo_correct_period(q, worker_com->args->sfo_correct_period); - srslte_ue_sync_set_sfo_ema(q, worker_com->args->sfo_ema); + srsran_ue_sync_set_sfo_correct_period(q, worker_com->args->sfo_correct_period); + srsran_ue_sync_set_sfo_ema(q, worker_com->args->sfo_ema); sss_alg_t sss_alg = SSS_FULL; if (!worker_com->args->sss_algorithm.compare("diff")) { @@ -775,8 +773,8 @@ void sync::set_ue_sync_opts(srslte_ue_sync_t* q, float cfo) } else { Warning("SYNC: Invalid SSS algorithm %s. Using 'full'", worker_com->args->sss_algorithm.c_str()); } - srslte_sync_set_sss_algorithm(&q->strack, (sss_alg_t)sss_alg); - srslte_sync_set_sss_algorithm(&q->sfind, (sss_alg_t)sss_alg); + srsran_sync_set_sss_algorithm(&q->strack, (sss_alg_t)sss_alg); + srsran_sync_set_sss_algorithm(&q->sfind, (sss_alg_t)sss_alg); } bool sync::set_cell(float cfo) @@ -793,13 +791,13 @@ bool sync::set_cell(float cfo) return false; } - if (!srslte_cell_isvalid(&cell)) { + if (!srsran_cell_isvalid(&cell)) { Error("SYNC: Setting cell: invalid cell (nof_prb=%d, pci=%d, ports=%d)", cell.nof_prb, cell.id, cell.nof_ports); return false; } // Set cell in all objects - if (srslte_ue_sync_set_cell(&ue_sync, cell)) { + if (srsran_ue_sync_set_cell(&ue_sync, cell)) { Error("SYNC: Setting cell: initiating ue_sync"); return false; } @@ -828,7 +826,7 @@ bool sync::set_cell(float cfo) set_ue_sync_opts(&ue_sync, cfo); // Reset ue_sync and set CFO/gain from search procedure - srslte_ue_sync_reset(&ue_sync); + srsran_ue_sync_reset(&ue_sync); return true; } @@ -848,11 +846,11 @@ bool sync::set_frequency() set_dl_freq = dl_freq; set_ul_freq = ul_freq; } else { - set_dl_freq = 1e6 * srslte_band_fd(current_earfcn); - if (srslte_band_is_tdd(srslte_band_get_band(current_earfcn))) { + set_dl_freq = 1e6 * srsran_band_fd(current_earfcn); + if (srsran_band_is_tdd(srsran_band_get_band(current_earfcn))) { set_ul_freq = set_dl_freq; } else { - set_ul_freq = 1e6 * srslte_band_fu(worker_com->get_ul_earfcn(current_earfcn)); + set_ul_freq = 1e6 * srsran_band_fu(worker_com->get_ul_earfcn(current_earfcn)); } } if (set_dl_freq > 0 && set_ul_freq > 0) { @@ -870,7 +868,7 @@ bool sync::set_frequency() ul_dl_factor = (float)(set_ul_freq / set_dl_freq); - srslte_ue_sync_reset(&ue_sync); + srsran_ue_sync_reset(&ue_sync); return true; } else { @@ -881,7 +879,7 @@ bool sync::set_frequency() void sync::set_sampling_rate() { - float new_srate = (float)srslte_sampling_freq_hz(cell.nof_prb); + float new_srate = (float)srsran_sampling_freq_hz(cell.nof_prb); if (new_srate < 0.0) { Error("Invalid sampling rate for %d PRBs. keeping same.", cell.nof_prb); return; @@ -904,7 +902,7 @@ uint32_t sync::get_current_tti() return tti; } -void sync::get_current_cell(srslte_cell_t* cell_, uint32_t* earfcn_) +void sync::get_current_cell(srsran_cell_t* cell_, uint32_t* earfcn_) { if (cell_) { *cell_ = cell; @@ -914,19 +912,19 @@ void sync::get_current_cell(srslte_cell_t* cell_, uint32_t* earfcn_) } } -int sync::radio_recv_fnc(srslte::rf_buffer_t& data, srslte_timestamp_t* rx_time) +int sync::radio_recv_fnc(srsran::rf_buffer_t& data, srsran_timestamp_t* rx_time) { // This function is designed for being called from the UE sync object which will pass a null rx_time in case // receive dummy samples. So, rf_timestamp points at dummy timestamp in case rx_time is not provided - srslte::rf_timestamp_t dummy_ts = {}; - srslte::rf_timestamp_t& rf_timestamp = (rx_time == nullptr) ? dummy_ts : last_rx_time; + srsran::rf_timestamp_t dummy_ts = {}; + srsran::rf_timestamp_t& rf_timestamp = (rx_time == nullptr) ? dummy_ts : last_rx_time; // Receive if (not radio_h->rx_now(data, rf_timestamp)) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - srslte_timestamp_t dummy_flat_ts = {}; + srsran_timestamp_t dummy_flat_ts = {}; // Load flat timestamp if (rx_time == nullptr) { @@ -950,7 +948,7 @@ int sync::radio_recv_fnc(srslte::rf_buffer_t& data, srslte_timestamp_t* rx_time) } // Save signal for Intra-frequency measurement - if (srslte_cell_isvalid(&cell)) { + if (srsran_cell_isvalid(&cell)) { for (uint32_t i = 0; (uint32_t)i < intra_freq_meas.size(); i++) { // Feed the exact number of base-band samples for avoiding an invalid buffer read intra_freq_meas[i]->write(tti, data.get(i, 0, worker_com->args->nof_rx_ant), data.get_nof_samples()); @@ -968,31 +966,31 @@ int sync::radio_recv_fnc(srslte::rf_buffer_t& data, srslte_timestamp_t* rx_time) void sync::run_stack_tti() { // check timestamp reset - if (forced_rx_time_init || srslte_timestamp_iszero(&stack_tti_ts) || - srslte_timestamp_compare(&stack_tti_ts_new, &stack_tti_ts) < 0) { - if (srslte_timestamp_compare(&stack_tti_ts_new, &stack_tti_ts) < 0) { + if (forced_rx_time_init || srsran_timestamp_iszero(&stack_tti_ts) || + srsran_timestamp_compare(&stack_tti_ts_new, &stack_tti_ts) < 0) { + if (srsran_timestamp_compare(&stack_tti_ts_new, &stack_tti_ts) < 0) { phy_logger.warning("SYNC: radio time seems to be going backwards (rx_time=%f, tti_ts=%f)", - srslte_timestamp_real(&stack_tti_ts_new), - srslte_timestamp_real(&stack_tti_ts)); + srsran_timestamp_real(&stack_tti_ts_new), + srsran_timestamp_real(&stack_tti_ts)); // time-stamp will be set to rx time below and run_tti() will be called with MIN_TTI_JUMP } // init tti_ts with last rx time - phy_logger.debug("SYNC: Setting initial TTI time to %f", srslte_timestamp_real(&stack_tti_ts_new)); - srslte_timestamp_copy(&stack_tti_ts, &stack_tti_ts_new); + phy_logger.debug("SYNC: Setting initial TTI time to %f", srsran_timestamp_real(&stack_tti_ts_new)); + srsran_timestamp_copy(&stack_tti_ts, &stack_tti_ts_new); forced_rx_time_init = false; } // Advance stack in time - if (srslte_timestamp_compare(&stack_tti_ts_new, &stack_tti_ts) >= 0) { - srslte_timestamp_t temp = {}; - srslte_timestamp_copy(&temp, &stack_tti_ts_new); - srslte_timestamp_sub(&temp, stack_tti_ts.full_secs, stack_tti_ts.frac_secs); - int32_t tti_jump = static_cast(srslte_timestamp_uint64(&temp, 1e3)); - tti_jump = SRSLTE_MAX(tti_jump, MIN_TTI_JUMP); + if (srsran_timestamp_compare(&stack_tti_ts_new, &stack_tti_ts) >= 0) { + srsran_timestamp_t temp = {}; + srsran_timestamp_copy(&temp, &stack_tti_ts_new); + srsran_timestamp_sub(&temp, stack_tti_ts.full_secs, stack_tti_ts.frac_secs); + int32_t tti_jump = static_cast(srsran_timestamp_uint64(&temp, 1e3)); + tti_jump = SRSRAN_MAX(tti_jump, MIN_TTI_JUMP); if (tti_jump > MAX_TTI_JUMP) { phy_logger.warning("SYNC: TTI jump of %d limited to %d", tti_jump, int(MAX_TTI_JUMP)); - tti_jump = SRSLTE_MIN(tti_jump, MAX_TTI_JUMP); + tti_jump = SRSRAN_MIN(tti_jump, MAX_TTI_JUMP); } // Run stack @@ -1002,7 +1000,7 @@ void sync::run_stack_tti() } // update timestamp - srslte_timestamp_copy(&stack_tti_ts, &stack_tti_ts_new); + srsran_timestamp_copy(&stack_tti_ts, &stack_tti_ts_new); } void sync::set_rx_gain(float gain) @@ -1015,7 +1013,7 @@ void sync::set_rx_gain(float gain) * */ -void sync::set_inter_frequency_measurement(uint32_t cc_idx, uint32_t earfcn_, srslte_cell_t cell_) +void sync::set_inter_frequency_measurement(uint32_t cc_idx, uint32_t earfcn_, srsran_cell_t cell_) { if (cc_idx < intra_freq_meas.size()) { intra_freq_meas[cc_idx]->set_primary_cell(earfcn_, cell_); @@ -1042,7 +1040,7 @@ void sync::meas_stop() } } -void sync::scell_sync_set(uint32_t cc_idx, const srslte_cell_t& _cell) +void sync::scell_sync_set(uint32_t cc_idx, const srsran_cell_t& _cell) { // Ignore if out of range if (scell_sync.count(cc_idx) == 0) { diff --git a/srsue/src/phy/vnf_phy_nr.cc b/srsue/src/phy/vnf_phy_nr.cc index 507699741..81ef31ea3 100644 --- a/srsue/src/phy/vnf_phy_nr.cc +++ b/srsue/src/phy/vnf_phy_nr.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -18,9 +18,9 @@ #include #include -#include "srslte/common/basic_vnf_api.h" -#include "srslte/common/test_common.h" -#include "srslte/common/threads.h" +#include "srsran/common/basic_vnf_api.h" +#include "srsran/common/test_common.h" +#include "srsran/common/threads.h" #include "srsue/hdr/phy/vnf_phy_nr.h" using namespace std; @@ -41,9 +41,9 @@ int vnf_phy_nr::init(const srsue::phy_args_t& args_, srsue::stack_interface_phy_ int vnf_phy_nr::init(const srsue::phy_args_t& args_) { // create VNF - vnf = std::unique_ptr(new srslte::srslte_basic_vnf(args_.vnf_args, stack)); + vnf = std::unique_ptr(new srsran::srsran_basic_vnf(args_.vnf_args, stack)); initialized = true; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } void vnf_phy_nr::set_earfcn(std::vector earfcns) {} @@ -68,7 +68,7 @@ int vnf_phy_nr::tx_request(const tx_request_t& request) // send Tx request over basic API return vnf->tx_request(request); } -bool vnf_phy_nr::set_config(const srslte::phy_cfg_nr_t& cfg) +bool vnf_phy_nr::set_config(const srsran::phy_cfg_nr_t& cfg) { return false; } diff --git a/srsue/src/set_net_admin_caps.cc b/srsue/src/set_net_admin_caps.cc index fb5d35387..1a41f75bf 100644 --- a/srsue/src/set_net_admin_caps.cc +++ b/srsue/src/set_net_admin_caps.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/srsue/src/stack/CMakeLists.txt b/srsue/src/stack/CMakeLists.txt index f08912efc..e158bacea 100644 --- a/srsue/src/stack/CMakeLists.txt +++ b/srsue/src/stack/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of diff --git a/srsue/src/stack/mac/CMakeLists.txt b/srsue/src/stack/mac/CMakeLists.txt index 74895d569..2d385bf9f 100644 --- a/srsue/src/stack/mac/CMakeLists.txt +++ b/srsue/src/stack/mac/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of diff --git a/srsue/src/stack/mac/demux.cc b/srsue/src/stack/mac/demux.cc index c3a4dd5d6..e601af618 100644 --- a/srsue/src/stack/mac/demux.cc +++ b/srsue/src/stack/mac/demux.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,9 +11,9 @@ */ #include "srsue/hdr/stack/mac/demux.h" -#include "srslte/common/standard_streams.h" -#include "srslte/common/string_helpers.h" -#include "srslte/interfaces/ue_phy_interfaces.h" +#include "srsran/common/standard_streams.h" +#include "srsran/common/string_helpers.h" +#include "srsran/interfaces/ue_phy_interfaces.h" #define Error(fmt, ...) logger.error(fmt, ##__VA_ARGS__) #define Warning(fmt, ...) logger.warning(fmt, ##__VA_ARGS__) @@ -29,7 +29,7 @@ demux::demux(srslog::basic_logger& logger) : void demux::init(phy_interface_mac_common* phy_, rlc_interface_mac* rlc_, mac_interface_demux* mac_, - srslte::timer_handler::unique_timer* time_alignment_timer_) + srsran::timer_handler::unique_timer* time_alignment_timer_) { phy_h = phy_; rlc = rlc_; @@ -89,13 +89,13 @@ void demux::push_pdu_temp_crnti(uint8_t* buff, uint32_t nof_bytes) is_uecrid_successful = false; while (pending_mac_msg.next()) { switch (pending_mac_msg.get()->dl_sch_ce_type()) { - case srslte::dl_sch_lcid::CON_RES_ID: + case srsran::dl_sch_lcid::CON_RES_ID: if (!is_uecrid_successful) { Debug("Found Contention Resolution ID CE"); is_uecrid_successful = mac->contention_resolution_id_rcv(pending_mac_msg.get()->get_con_res_id()); } break; - case srslte::dl_sch_lcid::TA_CMD: + case srsran::dl_sch_lcid::TA_CMD: parse_ta_cmd(pending_mac_msg.get(), 0); break; default: @@ -105,7 +105,7 @@ void demux::push_pdu_temp_crnti(uint8_t* buff, uint32_t nof_bytes) pending_mac_msg.reset(); if (is_uecrid_successful) { Debug("Saved MAC PDU with Temporal C-RNTI in buffer"); - pdus.push(buff, nof_bytes, srslte::pdu_queue::DCH); + pdus.push(buff, nof_bytes, srsran::pdu_queue::DCH); } else { pdus.deallocate(buff); } @@ -123,7 +123,7 @@ void demux::push_pdu(uint8_t* buff, uint32_t nof_bytes, uint32_t tti) // Process Real-Time PDUs process_sch_pdu_rt(buff, nof_bytes, tti); - return pdus.push(buff, nof_bytes, srslte::pdu_queue::DCH); + return pdus.push(buff, nof_bytes, srsran::pdu_queue::DCH); } /* Demultiplexing of MAC PDU associated with SI-RNTI. The PDU passes through @@ -131,14 +131,14 @@ void demux::push_pdu(uint8_t* buff, uint32_t nof_bytes, uint32_t tti) */ void demux::push_pdu_bcch(uint8_t* buff, uint32_t nof_bytes) { - pdus.push(buff, nof_bytes, srslte::pdu_queue::BCH); + pdus.push(buff, nof_bytes, srsran::pdu_queue::BCH); } void demux::push_pdu_mch(uint8_t* buff, uint32_t nof_bytes) { uint8_t* mch_buffer_ptr = request_buffer(nof_bytes); memcpy(mch_buffer_ptr, buff, nof_bytes); - pdus.push(mch_buffer_ptr, nof_bytes, srslte::pdu_queue::MCH); + pdus.push(mch_buffer_ptr, nof_bytes, srsran::pdu_queue::MCH); mch_buffer_ptr = NULL; } @@ -147,26 +147,26 @@ bool demux::process_pdus() return pdus.process_pdus(); } -void demux::process_pdu(uint8_t* mac_pdu, uint32_t nof_bytes, srslte::pdu_queue::channel_t channel) +void demux::process_pdu(uint8_t* mac_pdu, uint32_t nof_bytes, srsran::pdu_queue::channel_t channel) { Debug("Processing MAC PDU channel %d", channel); switch (channel) { - case srslte::pdu_queue::DCH: + case srsran::pdu_queue::DCH: // Unpack DLSCH MAC PDU mac_msg.init_rx(nof_bytes); mac_msg.parse_packet(mac_pdu); { fmt::memory_buffer buffer; mac_msg.to_string(buffer); - Info("%s", srslte::to_c_str(buffer)); + Info("%s", srsran::to_c_str(buffer)); } process_sch_pdu(&mac_msg); pdus.deallocate(mac_pdu); break; - case srslte::pdu_queue::BCH: + case srsran::pdu_queue::BCH: rlc->write_pdu_bcch_dlsch(mac_pdu, nof_bytes); break; - case srslte::pdu_queue::MCH: + case srsran::pdu_queue::MCH: mch_mac_msg.init_rx(nof_bytes); mch_mac_msg.parse_packet(mac_pdu); deallocate(mac_pdu); @@ -178,7 +178,7 @@ void demux::process_pdu(uint8_t* mac_pdu, uint32_t nof_bytes, srslte::pdu_queue: void demux::process_sch_pdu_rt(uint8_t* buff, uint32_t nof_bytes, uint32_t tti) { - srslte::sch_pdu mac_msg_rt(20, logger); + srsran::sch_pdu mac_msg_rt(20, logger); mac_msg_rt.init_rx(nof_bytes); mac_msg_rt.parse_packet(buff); @@ -195,7 +195,7 @@ void demux::process_sch_pdu_rt(uint8_t* buff, uint32_t nof_bytes, uint32_t tti) } } -void demux::process_sch_pdu(srslte::sch_pdu* pdu_msg) +void demux::process_sch_pdu(srsran::sch_pdu* pdu_msg) { while (pdu_msg->next()) { if (pdu_msg->get()->is_sdu()) { @@ -220,7 +220,7 @@ void demux::process_sch_pdu(srslte::sch_pdu* pdu_msg) pdu_msg->get()->get_sdu_lcid(), pdu_msg->get()->get_sdu_ptr(), pdu_msg->get()->get_payload_size()); } else { char tmp[1024]; - srslte_vec_sprint_hex(tmp, sizeof(tmp), pdu_msg->get()->get_sdu_ptr(), 32); + srsran_vec_sprint_hex(tmp, sizeof(tmp), pdu_msg->get()->get_sdu_ptr(), 32); Error("PDU size %d exceeds maximum PDU buffer size, lcid=%d, hex=[%s]", pdu_msg->get()->get_payload_size(), pdu_msg->get()->get_sdu_lcid(), @@ -232,11 +232,11 @@ void demux::process_sch_pdu(srslte::sch_pdu* pdu_msg) } } } -void demux::process_mch_pdu(srslte::mch_pdu* mch_msg) +void demux::process_mch_pdu(srsran::mch_pdu* mch_msg) { // disgarding headers that have already been processed while (mch_msg->next()) { - if (srslte::mch_lcid::MCH_SCHED_INFO == mch_msg->get()->mch_ce_type()) { + if (srsran::mch_lcid::MCH_SCHED_INFO == mch_msg->get()->mch_ce_type()) { uint16_t stop; uint8_t lcid; if (mch_msg->get()->get_next_mch_sched_info(&lcid, &stop)) { @@ -246,8 +246,8 @@ void demux::process_mch_pdu(srslte::mch_pdu* mch_msg) if (mch_msg->get()->is_sdu()) { uint32_t lcid = mch_msg->get()->get_sdu_lcid(); - if (lcid >= SRSLTE_N_MCH_LCIDS) { - Error("Radio bearer id must be in [0:%d] - %d", SRSLTE_N_MCH_LCIDS, lcid); + if (lcid >= SRSRAN_N_MCH_LCIDS) { + Error("Radio bearer id must be in [0:%d] - %d", SRSRAN_N_MCH_LCIDS, lcid); return; } Debug("Wrote MCH LCID=%d to RLC", lcid); @@ -268,23 +268,23 @@ void demux::mch_start_rx(uint32_t lcid) } } -bool demux::process_ce(srslte::sch_subh* subh, uint32_t tti) +bool demux::process_ce(srsran::sch_subh* subh, uint32_t tti) { switch (subh->dl_sch_ce_type()) { - case srslte::dl_sch_lcid::CON_RES_ID: + case srsran::dl_sch_lcid::CON_RES_ID: // Do nothing break; - case srslte::dl_sch_lcid::TA_CMD: + case srsran::dl_sch_lcid::TA_CMD: parse_ta_cmd(subh, tti); break; - case srslte::dl_sch_lcid::SCELL_ACTIVATION: { + case srsran::dl_sch_lcid::SCELL_ACTIVATION: { uint32_t cmd = (uint32_t)subh->get_activation_deactivation_cmd(); - srslte::console("SCELL Activation / Deactivation CMD: %x\n", cmd); + srsran::console("SCELL Activation / Deactivation CMD: %x\n", cmd); logger.info("SCELL Activation / Deactivation CMD: %x", cmd); phy_h->set_activation_deactivation_scell(cmd, tti); break; } - case srslte::dl_sch_lcid::PADDING: + case srsran::dl_sch_lcid::PADDING: break; default: Error("MAC CE 0x%x not supported", subh->lcid_value()); @@ -293,7 +293,7 @@ bool demux::process_ce(srslte::sch_subh* subh, uint32_t tti) return true; } -void demux::parse_ta_cmd(srslte::sch_subh* subh, uint32_t tti) +void demux::parse_ta_cmd(srsran::sch_subh* subh, uint32_t tti) { phy_h->set_timeadv(tti, subh->get_ta_cmd()); Info("Received TA=%d (%d/%d) ", diff --git a/srsue/src/stack/mac/dl_harq.cc b/srsue/src/stack/mac/dl_harq.cc index 8e988b69d..8893d2501 100644 --- a/srsue/src/stack/mac/dl_harq.cc +++ b/srsue/src/stack/mac/dl_harq.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -16,13 +16,13 @@ #define Debug(fmt, ...) logger.debug(fmt, ##__VA_ARGS__) #include "srsue/hdr/stack/mac/dl_harq.h" -#include "srslte/common/mac_pcap.h" -#include "srslte/common/timers.h" +#include "srsran/common/mac_pcap.h" +#include "srsran/common/timers.h" namespace srsue { dl_harq_entity::dl_harq_entity(uint8_t cc_idx_) : - proc(SRSLTE_MAX_HARQ_PROC), logger(srslog::fetch_basic_logger("MAC")), cc_idx(cc_idx_) + proc(SRSRAN_MAX_HARQ_PROC), logger(srslog::fetch_basic_logger("MAC")), cc_idx(cc_idx_) {} bool dl_harq_entity::init(mac_interface_rrc::ue_rnti_t* rntis_, demux* demux_unit_) @@ -30,7 +30,7 @@ bool dl_harq_entity::init(mac_interface_rrc::ue_rnti_t* rntis_, demux* demux_uni demux_unit = demux_unit_; rntis = rntis_; - for (uint32_t i = 0; i < SRSLTE_MAX_HARQ_PROC; i++) { + for (uint32_t i = 0; i < SRSRAN_MAX_HARQ_PROC; i++) { if (!proc[i].init(i, this)) { return false; } @@ -48,10 +48,10 @@ void dl_harq_entity::new_grant_dl(mac_interface_phy_lte::mac_grant_dl_t grant, if (grant.rnti != rntis->sps_rnti) { // Set BCCH PID for SI RNTI dl_harq_process* proc_ptr = NULL; - if (grant.rnti == SRSLTE_SIRNTI) { + if (grant.rnti == SRSRAN_SIRNTI) { proc_ptr = &bcch_proc; } else { - if (grant.pid >= SRSLTE_MAX_HARQ_PROC) { + if (grant.pid >= SRSRAN_MAX_HARQ_PROC) { Error("Invalid PID: %d", grant.pid); return; } @@ -69,12 +69,12 @@ void dl_harq_entity::new_grant_dl(mac_interface_phy_lte::mac_grant_dl_t grant, } } -void dl_harq_entity::tb_decoded(mac_interface_phy_lte::mac_grant_dl_t grant, bool ack[SRSLTE_MAX_CODEWORDS]) +void dl_harq_entity::tb_decoded(mac_interface_phy_lte::mac_grant_dl_t grant, bool ack[SRSRAN_MAX_CODEWORDS]) { - if (grant.rnti == SRSLTE_SIRNTI) { + if (grant.rnti == SRSRAN_SIRNTI) { bcch_proc.tb_decoded(grant, ack); } else { - if (grant.pid >= SRSLTE_MAX_HARQ_PROC) { + if (grant.pid >= SRSRAN_MAX_HARQ_PROC) { Error("Invalid PID: %d", grant.pid); return; } @@ -84,14 +84,14 @@ void dl_harq_entity::tb_decoded(mac_interface_phy_lte::mac_grant_dl_t grant, boo void dl_harq_entity::reset() { - for (uint32_t i = 0; i < SRSLTE_MAX_HARQ_PROC; i++) { + for (uint32_t i = 0; i < SRSRAN_MAX_HARQ_PROC; i++) { proc[i].reset(); } bcch_proc.reset(); dl_sps_assig.clear(); } -void dl_harq_entity::start_pcap(srslte::mac_pcap* pcap_) +void dl_harq_entity::start_pcap(srsran::mac_pcap* pcap_) { pcap = pcap_; } @@ -106,13 +106,13 @@ float dl_harq_entity::get_average_retx() return average_retx; } -dl_harq_entity::dl_harq_process::dl_harq_process() : subproc(SRSLTE_MAX_TB) {} +dl_harq_entity::dl_harq_process::dl_harq_process() : subproc(SRSRAN_MAX_TB) {} bool dl_harq_entity::dl_harq_process::init(int pid, dl_harq_entity* parent) { bool ret = true; - for (uint32_t tb = 0; tb < SRSLTE_MAX_TB; tb++) { + for (uint32_t tb = 0; tb < SRSRAN_MAX_TB; tb++) { ret &= subproc[tb].init(pid, parent, tb); } return ret; @@ -120,14 +120,14 @@ bool dl_harq_entity::dl_harq_process::init(int pid, dl_harq_entity* parent) void dl_harq_entity::dl_harq_process::reset(void) { - for (uint32_t tb = 0; tb < SRSLTE_MAX_TB; tb++) { + for (uint32_t tb = 0; tb < SRSRAN_MAX_TB; tb++) { subproc[tb].reset(); } } void dl_harq_entity::dl_harq_process::reset_ndi() { - for (uint32_t tb = 0; tb < SRSLTE_MAX_TB; tb++) { + for (uint32_t tb = 0; tb < SRSRAN_MAX_TB; tb++) { subproc[tb].reset_ndi(); } } @@ -137,7 +137,7 @@ void dl_harq_entity::dl_harq_process::new_grant_dl(mac_interface_phy_lte::mac_gr { bzero(action, sizeof(mac_interface_phy_lte::tb_action_dl_t)); /* For each subprocess... */ - for (uint32_t i = 0; i < SRSLTE_MAX_TB; i++) { + for (uint32_t i = 0; i < SRSRAN_MAX_TB; i++) { if (grant.tb[i].tbs) { subproc[i].new_grant_dl(grant, action); } @@ -145,10 +145,10 @@ void dl_harq_entity::dl_harq_process::new_grant_dl(mac_interface_phy_lte::mac_gr } void dl_harq_entity::dl_harq_process::tb_decoded(mac_interface_phy_lte::mac_grant_dl_t grant, - bool ack[SRSLTE_MAX_CODEWORDS]) + bool ack[SRSRAN_MAX_CODEWORDS]) { /* For each subprocess... */ - for (uint32_t i = 0; i < SRSLTE_MAX_TB; i++) { + for (uint32_t i = 0; i < SRSRAN_MAX_TB; i++) { subproc[i].tb_decoded(grant, &ack[i]); } } @@ -170,13 +170,13 @@ dl_harq_entity::dl_harq_process::dl_tb_process::dl_tb_process() : logger(srslog: dl_harq_entity::dl_harq_process::dl_tb_process::~dl_tb_process() { if (is_initiated) { - srslte_softbuffer_rx_free(&softbuffer); + srsran_softbuffer_rx_free(&softbuffer); } } bool dl_harq_entity::dl_harq_process::dl_tb_process::init(int pid, dl_harq_entity* parent, uint32_t tb_idx) { - if (srslte_softbuffer_rx_init(&softbuffer, 110)) { + if (srsran_softbuffer_rx_init(&softbuffer, 110)) { Error("Error initiating soft buffer"); return false; } @@ -253,7 +253,7 @@ void dl_harq_entity::dl_harq_process::dl_tb_process::new_grant_dl(mac_interface_ } ack = false; n_retx = 0; - srslte_softbuffer_rx_reset_tbs(&softbuffer, grant.tb[tid].tbs * 8); + srsran_softbuffer_rx_reset_tbs(&softbuffer, grant.tb[tid].tbs * 8); } n_retx++; @@ -331,7 +331,7 @@ void dl_harq_entity::dl_harq_process::dl_tb_process::tb_decoded(mac_interface_ph harq_entity->demux_unit->push_pdu(payload_buffer_ptr, cur_grant.tb[tid].tbs, grant.tti); // Compute average number of retransmissions per packet - harq_entity->average_retx = SRSLTE_VEC_CMA((float)n_retx, harq_entity->average_retx, harq_entity->nof_pkts++); + harq_entity->average_retx = SRSRAN_VEC_CMA((float)n_retx, harq_entity->average_retx, harq_entity->nof_pkts++); } } diff --git a/srsue/src/stack/mac/mac.cc b/srsue/src/stack/mac/mac.cc index 4ce2d54d3..4be6a1026 100644 --- a/srsue/src/stack/mac/mac.cc +++ b/srsue/src/stack/mac/mac.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -18,8 +18,8 @@ #include #include -#include "srslte/common/pcap.h" -#include "srslte/interfaces/ue_phy_interfaces.h" +#include "srsran/common/pcap.h" +#include "srsran/interfaces/ue_phy_interfaces.h" #include "srsue/hdr/stack/mac/mac.h" namespace srsue { @@ -40,8 +40,8 @@ mac::mac(const char* logname, ext_task_sched_handle task_sched_) : ul_harq.at(PCELL_CC_IDX) = ul_harq_entity_ptr(new ul_harq_entity(PCELL_CC_IDX)); dl_harq.at(PCELL_CC_IDX) = dl_harq_entity_ptr(new dl_harq_entity(PCELL_CC_IDX)); - srslte_softbuffer_rx_init(&pch_softbuffer, 100); - srslte_softbuffer_rx_init(&mch_softbuffer, 100); + srsran_softbuffer_rx_init(&pch_softbuffer, 100); + srsran_softbuffer_rx_init(&mch_softbuffer, 100); // Keep initialising members bzero(&metrics, sizeof(mac_metrics_t)); @@ -52,8 +52,8 @@ mac::~mac() { stop(); - srslte_softbuffer_rx_free(&pch_softbuffer); - srslte_softbuffer_rx_free(&mch_softbuffer); + srsran_softbuffer_rx_free(&pch_softbuffer); + srsran_softbuffer_rx_free(&mch_softbuffer); } bool mac::init(phy_interface_mac_lte* phy, rlc_interface_mac* rlc, rrc_interface_mac* rrc) @@ -97,7 +97,7 @@ void mac::stop() } } -void mac::start_pcap(srslte::mac_pcap* pcap_) +void mac::start_pcap(srsran::mac_pcap* pcap_) { pcap = pcap_; for (auto& r : dl_harq) { @@ -117,7 +117,7 @@ void mac::start_pcap(srslte::mac_pcap* pcap_) // Implement Section 5.8 void mac::reconfiguration(const uint32_t& cc_idx, const bool& enable) { - if (cc_idx < SRSLTE_MAX_CARRIERS) { + if (cc_idx < SRSRAN_MAX_CARRIERS) { if (enable and ul_harq.at(cc_idx) == nullptr) { ul_harq_entity_ptr ul = ul_harq_entity_ptr(new ul_harq_entity(cc_idx)); ul->init(&uernti, &ra_procedure, &mux_unit); @@ -201,7 +201,7 @@ void mac::run_tti(const uint32_t tti) ra_procedure.update_rar_window(ra_window_start, ra_window_length); // Count TTI for metrics - for (uint32_t i = 0; i < SRSLTE_MAX_CARRIERS; i++) { + for (uint32_t i = 0; i < SRSRAN_MAX_CARRIERS; i++) { metrics[i].nof_tti++; } } @@ -261,7 +261,7 @@ uint16_t mac::get_ul_sched_rnti(uint32_t tti) if (uernti.crnti) { return uernti.crnti; } - return SRSLTE_INVALID_RNTI; + return SRSRAN_INVALID_RNTI; } bool mac::is_in_window(uint32_t tti, int* start, int* len) @@ -269,7 +269,7 @@ bool mac::is_in_window(uint32_t tti, int* start, int* len) uint32_t st = (uint32_t)*start; uint32_t l = (uint32_t)*len; - if (srslte_tti_interval(tti, st) < l + 5) { + if (srsran_tti_interval(tti, st) < l + 5) { if (tti > st) { if (tti <= st + l) { return true; @@ -299,11 +299,11 @@ uint16_t mac::get_dl_sched_rnti(uint32_t tti) // TODO: This scheduling decision belongs to RRC if (si_window_length > 1) { // This is not a SIB1 if ((tti / 10) % 2 == 0 && (tti % 10) == 5) { // Skip subframe #5 for which SFN mod 2 = 0 - return SRSLTE_INVALID_RNTI; + return SRSRAN_INVALID_RNTI; } } Debug("SCHED: Searching SI-RNTI, tti=%d, window start=%d, length=%d", tti, si_window_start, si_window_length); - return SRSLTE_SIRNTI; + return SRSRAN_SIRNTI; } } if (uernti.rar_rnti && ra_window_start > 0 && ra_window_length > 0 && @@ -321,11 +321,11 @@ uint16_t mac::get_dl_sched_rnti(uint32_t tti) } if (p_window_start > 0) { Debug("SCHED: Searching P-RNTI"); - return SRSLTE_PRNTI; + return SRSRAN_PRNTI; } // turn off DCI search for this TTI - return SRSLTE_INVALID_RNTI; + return SRSRAN_INVALID_RNTI; } void mac::bch_decoded_ok(uint32_t cc_idx, uint8_t* payload, uint32_t len) @@ -337,7 +337,7 @@ void mac::bch_decoded_ok(uint32_t cc_idx, uint8_t* payload, uint32_t len) buf->N_bytes = len; buf->set_timestamp(); auto p = stack_task_dispatch_queue.try_push(std::bind( - [this](srslte::unique_byte_buffer_t& buf) { rlc_h->write_pdu_bcch_bch(std::move(buf)); }, std::move(buf))); + [this](srsran::unique_byte_buffer_t& buf) { rlc_h->write_pdu_bcch_bch(std::move(buf)); }, std::move(buf))); if (not p.first) { Warning("Failed to dispatch rlc::write_pdu_bcch_bch task to stack"); } @@ -358,7 +358,7 @@ void mac::mch_decoded(uint32_t len, bool crc) mch_msg.parse_packet(mch_payload_buffer); while (mch_msg.next()) { for (uint32_t i = 0; i < phy_mbsfn_cfg.nof_mbsfn_services; i++) { - if (srslte::mch_lcid::MCH_SCHED_INFO == mch_msg.get()->mch_ce_type()) { + if (srsran::mch_lcid::MCH_SCHED_INFO == mch_msg.get()->mch_ce_type()) { uint16_t stop; uint8_t lcid; if (mch_msg.get()->get_next_mch_sched_info(&lcid, &stop)) { @@ -383,22 +383,22 @@ void mac::mch_decoded(uint32_t len, bool crc) metrics[0].rx_pkts++; } -void mac::tb_decoded(uint32_t cc_idx, mac_grant_dl_t grant, bool ack[SRSLTE_MAX_CODEWORDS]) +void mac::tb_decoded(uint32_t cc_idx, mac_grant_dl_t grant, bool ack[SRSRAN_MAX_CODEWORDS]) { - if (SRSLTE_RNTI_ISRAR(grant.rnti)) { + if (SRSRAN_RNTI_ISRAR(grant.rnti)) { if (ack[0]) { ra_procedure.tb_decoded_ok(cc_idx, grant.tti); } - } else if (grant.rnti == SRSLTE_PRNTI) { + } else if (grant.rnti == SRSRAN_PRNTI) { // Send PCH payload to RLC - unique_byte_buffer_t pdu = srslte::make_byte_buffer(); + unique_byte_buffer_t pdu = srsran::make_byte_buffer(); if (pdu != nullptr) { memcpy(pdu->msg, pch_payload_buffer, grant.tb[0].tbs); pdu->N_bytes = grant.tb[0].tbs; pdu->set_timestamp(); auto ret = stack_task_dispatch_queue.try_push(std::bind( - [this](srslte::unique_byte_buffer_t& pdu) { rlc_h->write_pdu_pcch(std::move(pdu)); }, std::move(pdu))); + [this](srsran::unique_byte_buffer_t& pdu) { rlc_h->write_pdu_pcch(std::move(pdu)); }, std::move(pdu))); if (not ret.first) { Warning("Failed to dispatch rlc::write_pdu_pcch task to stack"); } @@ -419,7 +419,7 @@ void mac::tb_decoded(uint32_t cc_idx, mac_grant_dl_t grant, bool ack[SRSLTE_MAX_ dl_harq.at(cc_idx)->tb_decoded(grant, ack); process_pdus(); - for (uint32_t tb = 0; tb < SRSLTE_MAX_CODEWORDS; tb++) { + for (uint32_t tb = 0; tb < SRSRAN_MAX_CODEWORDS; tb++) { if (grant.tb[tb].tbs) { if (ack[tb]) { metrics[cc_idx].rx_brate += grant.tb[tb].tbs * 8; @@ -436,9 +436,9 @@ void mac::new_grant_dl(uint32_t cc_idx, mac_interface_phy_lte::mac_grant_dl_t grant, mac_interface_phy_lte::tb_action_dl_t* action) { - if (SRSLTE_RNTI_ISRAR(grant.rnti)) { + if (SRSRAN_RNTI_ISRAR(grant.rnti)) { ra_procedure.new_grant_dl(grant, action); - } else if (grant.rnti == SRSLTE_PRNTI) { + } else if (grant.rnti == SRSRAN_PRNTI) { bzero(action, sizeof(mac_interface_phy_lte::tb_action_dl_t)); if (grant.tb[0].tbs > pch_payload_buffer_sz) { Error("Received dci for PCH (%d bytes) exceeds buffer (%d bytes)", grant.tb[0].tbs, int(pch_payload_buffer_sz)); @@ -448,9 +448,9 @@ void mac::new_grant_dl(uint32_t cc_idx, action->tb[0].payload = pch_payload_buffer; action->tb[0].softbuffer.rx = &pch_softbuffer; action->tb[0].rv = grant.tb[0].rv; - srslte_softbuffer_rx_reset_cb(&pch_softbuffer, 1); + srsran_softbuffer_rx_reset_cb(&pch_softbuffer, 1); } - } else if (!(grant.rnti == SRSLTE_SIRNTI && cc_idx != 0)) { + } else if (!(grant.rnti == SRSRAN_SIRNTI && cc_idx != 0)) { // If PDCCH for C-RNTI and RA procedure in Contention Resolution, notify it if (grant.rnti == uernti.crnti && ra_procedure.is_contention_resolution()) { ra_procedure.pdcch_to_crnti(false); @@ -531,13 +531,13 @@ void mac::new_grant_ul(uint32_t cc_idx, } } -void mac::new_mch_dl(const srslte_pdsch_grant_t& phy_grant, tb_action_dl_t* action) +void mac::new_mch_dl(const srsran_pdsch_grant_t& phy_grant, tb_action_dl_t* action) { action->generate_ack = false; action->tb[0].enabled = true; action->tb[0].payload = mch_payload_buffer; action->tb[0].softbuffer.rx = &mch_softbuffer; - srslte_softbuffer_rx_reset_cb(&mch_softbuffer, 1); + srsran_softbuffer_rx_reset_cb(&mch_softbuffer, 1); } void mac::setup_timers(int time_alignment_timer) @@ -648,7 +648,7 @@ void mac::mch_start_rx(uint32_t lcid) demux_unit.mch_start_rx(lcid); } -void mac::get_metrics(mac_metrics_t m[SRSLTE_MAX_CARRIERS]) +void mac::get_metrics(mac_metrics_t m[SRSRAN_MAX_CARRIERS]) { int tx_pkts = 0; int tx_errors = 0; @@ -686,9 +686,9 @@ void mac::get_metrics(mac_metrics_t m[SRSLTE_MAX_CARRIERS]) ul_harq.at(PCELL_CC_IDX)->get_average_retx()); metrics[PCELL_CC_IDX].ul_buffer = (int)bsr_procedure.get_buffer_state(); - memcpy(m, metrics, sizeof(mac_metrics_t) * SRSLTE_MAX_CARRIERS); + memcpy(m, metrics, sizeof(mac_metrics_t) * SRSRAN_MAX_CARRIERS); m = metrics; - bzero(&metrics, sizeof(mac_metrics_t) * SRSLTE_MAX_CARRIERS); + bzero(&metrics, sizeof(mac_metrics_t) * SRSRAN_MAX_CARRIERS); } } // namespace srsue diff --git a/srsue/src/stack/mac/mux.cc b/srsue/src/stack/mac/mux.cc index 26e478e22..1cd4564ea 100644 --- a/srsue/src/stack/mac/mux.cc +++ b/srsue/src/stack/mac/mux.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -16,7 +16,7 @@ #define Debug(fmt, ...) logger.debug(fmt, ##__VA_ARGS__) #include "srsue/hdr/stack/mac/mux.h" -#include "srslte/common/string_helpers.h" +#include "srsran/common/string_helpers.h" #include "srsue/hdr/stack/mac/mac.h" #include @@ -55,7 +55,7 @@ void mux::step() if (channel.PBR >= 0) { channel.Bj += channel.PBR; // PBR is in kByte/s, conversion in Byte and ms not needed } - channel.Bj = SRSLTE_MIN((uint32_t)channel.Bj, channel.bucket_size); + channel.Bj = SRSRAN_MIN((uint32_t)channel.Bj, channel.bucket_size); Debug("Update Bj: lcid=%d, Bj=%d", channel.lcid, channel.Bj); } } @@ -140,21 +140,21 @@ void mux::print_logical_channel_state(const std::string& info) logger.debug("%s", logline.c_str()); } -srslte::ul_sch_lcid bsr_format_convert(bsr_proc::bsr_format_t format) +srsran::ul_sch_lcid bsr_format_convert(bsr_proc::bsr_format_t format) { switch (format) { case bsr_proc::LONG_BSR: - return srslte::ul_sch_lcid::LONG_BSR; + return srsran::ul_sch_lcid::LONG_BSR; case bsr_proc::TRUNC_BSR: - return srslte::ul_sch_lcid::TRUNC_BSR; + return srsran::ul_sch_lcid::TRUNC_BSR; case bsr_proc::SHORT_BSR: default: - return srslte::ul_sch_lcid::SHORT_BSR; + return srsran::ul_sch_lcid::SHORT_BSR; } } // Multiplexing and logical channel priorization as defined in Section 5.4.3 -uint8_t* mux::pdu_get(srslte::byte_buffer_t* payload, uint32_t pdu_sz) +uint8_t* mux::pdu_get(srsran::byte_buffer_t* payload, uint32_t pdu_sz) { std::lock_guard lock(mutex); @@ -234,7 +234,7 @@ uint8_t* mux::pdu_get(srslte::byte_buffer_t* payload, uint32_t pdu_sz) if (sched_sdu(&channel, &sdu_space, max_sdu_sz)) { channel.Bj -= channel.sched_len; // account for (possible) subheader needed for next SDU - last_sdu_subheader_len = SRSLTE_MIN((uint32_t)sdu_space, sch_pdu::size_header_sdu(channel.sched_len)); + last_sdu_subheader_len = SRSRAN_MIN((uint32_t)sdu_space, sch_pdu::size_header_sdu(channel.sched_len)); sdu_space -= last_sdu_subheader_len; } } @@ -289,7 +289,7 @@ uint8_t* mux::pdu_get(srslte::byte_buffer_t* payload, uint32_t pdu_sz) uint8_t* ret = pdu_msg.write_packet(logger); fmt::memory_buffer buffer; pdu_msg.to_string(buffer); - Info("%s", srslte::to_c_str(buffer)); + Info("%s", srsran::to_c_str(buffer)); Debug("Assembled MAC PDU msg size %d/%d bytes", pdu_msg.get_pdu_len() - pdu_msg.rem_size(), pdu_sz); return ret; @@ -325,14 +325,14 @@ bool mux::sched_sdu(logical_channel_config_t* ch, int* sdu_space, int max_sdu_sz return false; } -uint32_t mux::allocate_sdu(uint32_t lcid, srslte::sch_pdu* pdu_msg, int max_sdu_sz) +uint32_t mux::allocate_sdu(uint32_t lcid, srsran::sch_pdu* pdu_msg, int max_sdu_sz) { uint32_t total_sdu_len = 0; int32_t sdu_space = max_sdu_sz; int32_t buffer_state = rlc->get_buffer_state(lcid); while (buffer_state > 0 && sdu_space > 0) { // there is pending SDU to allocate - int requested_sdu_len = SRSLTE_MIN(buffer_state, sdu_space); + int requested_sdu_len = SRSRAN_MIN(buffer_state, sdu_space); if (pdu_msg->new_subh()) { // there is space for a new subheader int sdu_len = pdu_msg->get()->set_sdu(lcid, requested_sdu_len, rlc); @@ -406,7 +406,7 @@ bool mux::msg3_is_empty() } /* Returns a pointer to the Msg3 buffer */ -uint8_t* mux::msg3_get(srslte::byte_buffer_t* payload, uint32_t pdu_sz) +uint8_t* mux::msg3_get(srsran::byte_buffer_t* payload, uint32_t pdu_sz) { if (pdu_sz < msg3_buff.get_tailroom()) { if (msg3_is_empty()) { diff --git a/srsue/src/stack/mac/proc_bsr.cc b/srsue/src/stack/mac/proc_bsr.cc index 6b265bbe0..8d360795e 100644 --- a/srsue/src/stack/mac/proc_bsr.cc +++ b/srsue/src/stack/mac/proc_bsr.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,12 +11,12 @@ */ #include "srsue/hdr/stack/mac/proc_bsr.h" -#include "srslte/interfaces/ue_rlc_interfaces.h" +#include "srsran/interfaces/ue_rlc_interfaces.h" #include "srsue/hdr/stack/mac/mux.h" namespace srsue { -void bsr_proc::init(sr_proc* sr_, rlc_interface_mac* rlc_, srslte::ext_task_sched_handle* task_sched_) +void bsr_proc::init(sr_proc* sr_, rlc_interface_mac* rlc_, srsran::ext_task_sched_handle* task_sched_) { rlc = rlc_; sr = sr_; @@ -46,7 +46,7 @@ void bsr_proc::print_state() int n = 0; for (auto& lcg : lcgs) { for (auto& iter : lcg) { - n = srslte_print_check(str, 128, n, "%d: %d ", iter.first, iter.second.old_buffer); + n = srsran_print_check(str, 128, n, "%d: %d ", iter.first, iter.second.old_buffer); } } logger.info("BSR: triggered_bsr_type=%s, LCID QUEUE status: %s", bsr_type_tostring(triggered_bsr_type), str); @@ -71,7 +71,7 @@ void bsr_proc::reset() triggered_bsr_type = NONE; } -void bsr_proc::set_config(srslte::bsr_cfg_t& bsr_cfg_) +void bsr_proc::set_config(srsran::bsr_cfg_t& bsr_cfg_) { std::lock_guard lock(mutex); @@ -215,7 +215,7 @@ bool bsr_proc::generate_bsr(bsr_t* bsr, uint32_t pdu_space) } } - if (pdu_space >= CE_SUBHEADER_LEN + ce_size(srslte::ul_sch_lcid::LONG_BSR)) { + if (pdu_space >= CE_SUBHEADER_LEN + ce_size(srsran::ul_sch_lcid::LONG_BSR)) { // we could fit a long BSR if (triggered_bsr_type != PADDING && nof_lcg <= 1) { // for Regular and periodic BSR we still send a short BSR if only one LCG has data to send @@ -224,7 +224,7 @@ bool bsr_proc::generate_bsr(bsr_t* bsr, uint32_t pdu_space) bsr->format = LONG_BSR; } send_bsr = true; - } else if (pdu_space >= CE_SUBHEADER_LEN + ce_size(srslte::ul_sch_lcid::SHORT_BSR)) { + } else if (pdu_space >= CE_SUBHEADER_LEN + ce_size(srsran::ul_sch_lcid::SHORT_BSR)) { // we can only fit a short or truncated BSR if (nof_lcg > 1) { // send truncated BSR @@ -360,7 +360,7 @@ bool bsr_proc::generate_padding_bsr(uint32_t nof_padding_bytes, bsr_t* bsr) { std::lock_guard lock(mutex); - if (nof_padding_bytes >= CE_SUBHEADER_LEN + ce_size(srslte::ul_sch_lcid::SHORT_BSR)) { + if (nof_padding_bytes >= CE_SUBHEADER_LEN + ce_size(srsran::ul_sch_lcid::SHORT_BSR)) { // generate padding BSR set_trigger(PADDING); generate_bsr(bsr, nof_padding_bytes); diff --git a/srsue/src/stack/mac/proc_phr.cc b/srsue/src/stack/mac/proc_phr.cc index 2d2c2a24b..e604c6354 100644 --- a/srsue/src/stack/mac/proc_phr.cc +++ b/srsue/src/stack/mac/proc_phr.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -16,7 +16,7 @@ #define Debug(fmt, ...) logger.debug(fmt, ##__VA_ARGS__) #include "srsue/hdr/stack/mac/proc_phr.h" -#include "srslte/interfaces/ue_phy_interfaces.h" +#include "srsran/interfaces/ue_phy_interfaces.h" namespace srsue { @@ -27,7 +27,7 @@ phr_proc::phr_proc(srslog::basic_logger& logger) : logger(logger) phr_cfg = {}; } -void phr_proc::init(phy_interface_mac_lte* phy_h_, srslte::ext_task_sched_handle* task_sched_) +void phr_proc::init(phy_interface_mac_lte* phy_h_, srsran::ext_task_sched_handle* task_sched_) { phy_h = phy_h_; task_sched = task_sched_; @@ -46,7 +46,7 @@ void phr_proc::reset() phr_is_triggered = false; } -void phr_proc::set_config(srslte::phr_cfg_t& cfg) +void phr_proc::set_config(srsran::phr_cfg_t& cfg) { phr_cfg = cfg; diff --git a/srsue/src/stack/mac/proc_ra.cc b/srsue/src/stack/mac/proc_ra.cc index e5ca78907..4374bbe74 100644 --- a/srsue/src/stack/mac/proc_ra.cc +++ b/srsue/src/stack/mac/proc_ra.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,9 +11,9 @@ */ #include "srsue/hdr/stack/mac/proc_ra.h" -#include "srslte/common/standard_streams.h" -#include "srslte/interfaces/ue_phy_interfaces.h" -#include "srslte/interfaces/ue_rrc_interfaces.h" +#include "srsran/common/standard_streams.h" +#include "srsran/interfaces/ue_phy_interfaces.h" +#include "srsran/interfaces/ue_rrc_interfaces.h" #include "srsue/hdr/stack/mac/mux.h" #include // for printing uint64_t #include @@ -46,9 +46,9 @@ int delta_preamble_db_table[5] = {0, 0, -3, -3, 8}; void ra_proc::init(phy_interface_mac_lte* phy_h_, rrc_interface_mac* rrc_, mac_interface_rrc::ue_rnti_t* rntis_, - srslte::timer_handler::unique_timer* time_alignment_timer_, + srsran::timer_handler::unique_timer* time_alignment_timer_, mux* mux_unit_, - srslte::ext_task_sched_handle* task_sched_) + srsran::ext_task_sched_handle* task_sched_) { phy_h = phy_h_; rntis = rntis_; @@ -61,14 +61,14 @@ void ra_proc::init(phy_interface_mac_lte* phy_h_, time_alignment_timer = time_alignment_timer_; contention_resolution_timer = task_sched->get_unique_timer(); - srslte_softbuffer_rx_init(&softbuffer_rar, 10); + srsran_softbuffer_rx_init(&softbuffer_rar, 10); reset(); } ra_proc::~ra_proc() { - srslte_softbuffer_rx_free(&softbuffer_rar); + srsran_softbuffer_rx_free(&softbuffer_rar); } void ra_proc::reset() @@ -78,14 +78,14 @@ void ra_proc::reset() contention_resolution_timer.stop(); } -void ra_proc::start_pcap(srslte::mac_pcap* pcap_) +void ra_proc::start_pcap(srsran::mac_pcap* pcap_) { pcap = pcap_; } // RRC calls to set a new PRACH configuration. // The configuration is applied by initialization() function. -void ra_proc::set_config(srslte::rach_cfg_t& rach_cfg_) +void ra_proc::set_config(srsran::rach_cfg_t& rach_cfg_) { rach_cfg = rach_cfg_; } @@ -154,7 +154,7 @@ void ra_proc::state_pdcch_setup() ra_tti = info.tti_ra; ra_rnti = 1 + (ra_tti % 10) + (10 * info.f_id); rInfo("seq=%d, ra-rnti=0x%x, ra-tti=%d, f_id=%d", sel_preamble.load(), ra_rnti, info.tti_ra, info.f_id); - srslte::console( + srsran::console( "Random Access Transmission: seq=%d, tti=%d, ra-rnti=0x%x\n", sel_preamble.load(), info.tti_ra, ra_rnti); rar_window_st = ra_tti + 3; rntis->rar_rnti = ra_rnti; @@ -171,7 +171,7 @@ void ra_proc::state_response_reception(uint32_t tti) { // do nothing. Processing done in tb_decoded_ok() if (!rar_received) { - uint32_t interval = srslte_tti_interval(tti, ra_tti + 3 + rach_cfg.responseWindowSize - 1); + uint32_t interval = srsran_tti_interval(tti, ra_tti + 3 + rach_cfg.responseWindowSize - 1); if (interval > 0 && interval < 100) { logger.error("RA response not received within the response window"); response_error(); @@ -194,7 +194,7 @@ void ra_proc::state_backoff_wait(uint32_t tti) backoff_interval_start = tti; backoff_interval--; } - if (srslte_tti_interval(tti, backoff_interval_start) >= backoff_interval) { + if (srsran_tti_interval(tti, backoff_interval_start) >= backoff_interval) { backoff_interval = 0; resource_selection(); } @@ -293,7 +293,7 @@ void ra_proc::preamble_transmission() (preambleTransmissionCounter - 1) * rach_cfg.powerRampingStep; phy_h->prach_send(sel_preamble, sel_maskIndex - 1, received_target_power_dbm); - rntis->rar_rnti = SRSLTE_INVALID_RNTI; + rntis->rar_rnti = SRSRAN_INVALID_RNTI; ra_tti = 0; rar_received = false; backoff_interval_start = -1; @@ -340,7 +340,7 @@ void ra_proc::new_grant_dl(mac_interface_phy_lte::mac_grant_dl_t grant, mac_inte action->tb[0].softbuffer.rx = &softbuffer_rar; rar_grant_nbytes = grant.tb[0].tbs; if (action->tb[0].rv == 0) { - srslte_softbuffer_rx_reset(&softbuffer_rar); + srsran_softbuffer_rx_reset(&softbuffer_rar); } } else { rError("Received RAR dci exceeds buffer length (%d>%d)", grant.tb[0].tbs, int(MAX_RAR_PDU_LEN)); @@ -359,7 +359,7 @@ void ra_proc::tb_decoded_ok(const uint8_t cc_idx, const uint32_t tti) } rar_pdu_msg.init_rx(rar_grant_nbytes); - if (rar_pdu_msg.parse_packet(rar_pdu_buffer) != SRSLTE_SUCCESS) { + if (rar_pdu_msg.parse_packet(rar_pdu_buffer) != SRSRAN_SUCCESS) { rError("Error decoding RAR PDU"); } @@ -382,10 +382,10 @@ void ra_proc::tb_decoded_ok(const uint8_t cc_idx, const uint32_t tti) // TODO: Indicate received target power // phy_h->set_target_power_rar(iniReceivedTargetPower, (preambleTransmissionCounter-1)*powerRampingStep); - uint8_t grant[srslte::rar_subh::RAR_GRANT_LEN] = {}; + uint8_t grant[srsran::rar_subh::RAR_GRANT_LEN] = {}; rar_pdu_msg.get()->get_sched_grant(grant); - rntis->rar_rnti = SRSLTE_INVALID_RNTI; + rntis->rar_rnti = SRSRAN_INVALID_RNTI; phy_h->set_rar_grant(grant, rar_pdu_msg.get()->get_temp_crnti()); current_ta = rar_pdu_msg.get()->get_ta_cmd(); @@ -478,7 +478,7 @@ void ra_proc::complete() rrc->ra_completed(); - srslte::console("Random Access Complete. c-rnti=0x%x, ta=%d\n", rntis->crnti, current_ta); + srsran::console("Random Access Complete. c-rnti=0x%x, ta=%d\n", rntis->crnti, current_ta); rInfo("Random Access Complete. c-rnti=0x%x, ta=%d", rntis->crnti, current_ta); state = IDLE; diff --git a/srsue/src/stack/mac/proc_sr.cc b/srsue/src/stack/mac/proc_sr.cc index a6a7745c8..fe6e1b5ce 100644 --- a/srsue/src/stack/mac/proc_sr.cc +++ b/srsue/src/stack/mac/proc_sr.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -16,9 +16,9 @@ #define Debug(fmt, ...) logger.debug(fmt, ##__VA_ARGS__) #include "srsue/hdr/stack/mac/proc_sr.h" -#include "srslte/common/standard_streams.h" -#include "srslte/interfaces/ue_phy_interfaces.h" -#include "srslte/interfaces/ue_rrc_interfaces.h" +#include "srsran/common/standard_streams.h" +#include "srsran/interfaces/ue_phy_interfaces.h" +#include "srsran/interfaces/ue_rrc_interfaces.h" #include "srsue/hdr/stack/mac/proc_ra.h" namespace srsue { @@ -61,7 +61,7 @@ bool sr_proc::need_tx(uint32_t tti) return false; } -void sr_proc::set_config(srslte::sr_cfg_t& cfg) +void sr_proc::set_config(srsran::sr_cfg_t& cfg) { if (cfg.enabled && cfg.dsr_transmax == 0) { Error("Zero is an invalid value for dsr-TransMax (n4, n8, n16, n32, n64 are supported). Disabling SR."); @@ -89,7 +89,7 @@ void sr_proc::step(uint32_t tti) Info("SR: Releasing PUCCH/SRS resources, sr_counter=%d, dsr_transmax=%d", sr_counter, sr_cfg.dsr_transmax); - srslte::console("Scheduling request failed: releasing RRC connection...\n"); + srsran::console("Scheduling request failed: releasing RRC connection...\n"); rrc->release_pucch_srs(); ra->start_mac_order(); reset(); diff --git a/srsue/src/stack/mac/ul_harq.cc b/srsue/src/stack/mac/ul_harq.cc index 28805efed..9f192d6f2 100644 --- a/srsue/src/stack/mac/ul_harq.cc +++ b/srsue/src/stack/mac/ul_harq.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -16,14 +16,14 @@ #define Debug(fmt, ...) logger.debug(fmt, ##__VA_ARGS__) #include "srsue/hdr/stack/mac/ul_harq.h" -#include "srslte/common/interfaces_common.h" -#include "srslte/common/mac_pcap.h" -#include "srslte/common/timers.h" +#include "srsran/common/interfaces_common.h" +#include "srsran/common/mac_pcap.h" +#include "srsran/common/timers.h" namespace srsue { ul_harq_entity::ul_harq_entity(const uint8_t cc_idx_) : - proc(SRSLTE_MAX_HARQ_PROC), logger(srslog::fetch_basic_logger("MAC")), cc_idx(cc_idx_) + proc(SRSRAN_MAX_HARQ_PROC), logger(srslog::fetch_basic_logger("MAC")), cc_idx(cc_idx_) {} bool ul_harq_entity::init(mac_interface_rrc_common::ue_rnti_t* rntis_, ra_proc* ra_procedure_, mux* mux_unit_) @@ -32,7 +32,7 @@ bool ul_harq_entity::init(mac_interface_rrc_common::ue_rnti_t* rntis_, ra_proc* ra_procedure = ra_procedure_; rntis = rntis_; - for (uint32_t i = 0; i < SRSLTE_MAX_HARQ_PROC; i++) { + for (uint32_t i = 0; i < SRSRAN_MAX_HARQ_PROC; i++) { if (!proc[i].init(i, this)) { return false; } @@ -42,7 +42,7 @@ bool ul_harq_entity::init(mac_interface_rrc_common::ue_rnti_t* rntis_, ra_proc* void ul_harq_entity::reset() { - for (uint32_t i = 0; i < SRSLTE_MAX_HARQ_PROC; i++) { + for (uint32_t i = 0; i < SRSRAN_MAX_HARQ_PROC; i++) { proc[i].reset(); } ul_sps_assig.clear(); @@ -50,17 +50,17 @@ void ul_harq_entity::reset() void ul_harq_entity::reset_ndi() { - for (uint32_t i = 0; i < SRSLTE_MAX_HARQ_PROC; i++) { + for (uint32_t i = 0; i < SRSRAN_MAX_HARQ_PROC; i++) { proc[i].reset_ndi(); } } -void ul_harq_entity::set_config(srslte::ul_harq_cfg_t& harq_cfg_) +void ul_harq_entity::set_config(srsran::ul_harq_cfg_t& harq_cfg_) { harq_cfg = harq_cfg_; } -void ul_harq_entity::start_pcap(srslte::mac_pcap* pcap_) +void ul_harq_entity::start_pcap(srsran::mac_pcap* pcap_) { pcap = pcap_; } @@ -71,11 +71,11 @@ void ul_harq_entity::new_grant_ul(mac_interface_phy_lte::mac_grant_ul_t grant, { bzero(action, sizeof(mac_interface_phy_lte::tb_action_ul_t)); - if (grant.pid >= SRSLTE_MAX_HARQ_PROC) { + if (grant.pid >= SRSRAN_MAX_HARQ_PROC) { Error("Invalid PID: %d", grant.pid); return; } - if (grant.rnti == rntis->crnti || grant.rnti == rntis->temp_rnti || SRSLTE_RNTI_ISRAR(grant.rnti)) { + if (grant.rnti == rntis->crnti || grant.rnti == rntis->temp_rnti || SRSRAN_RNTI_ISRAR(grant.rnti)) { if (grant.rnti == rntis->crnti && proc[grant.pid].is_sps()) { grant.tb.ndi = true; } @@ -94,7 +94,7 @@ void ul_harq_entity::new_grant_ul(mac_interface_phy_lte::mac_grant_ul_t grant, int ul_harq_entity::get_current_tbs(uint32_t pid) { - if (pid >= SRSLTE_MAX_HARQ_PROC) { + if (pid >= SRSRAN_MAX_HARQ_PROC) { Error("Invalid PID: %d", pid); return 0; } @@ -125,13 +125,13 @@ ul_harq_entity::ul_harq_process::ul_harq_process() : logger(srslog::fetch_basic_ ul_harq_entity::ul_harq_process::~ul_harq_process() { if (is_initiated) { - srslte_softbuffer_tx_free(&softbuffer); + srsran_softbuffer_tx_free(&softbuffer); } } bool ul_harq_entity::ul_harq_process::init(uint32_t pid_, ul_harq_entity* parent) { - if (srslte_softbuffer_tx_init(&softbuffer, 110)) { + if (srsran_softbuffer_tx_init(&softbuffer, 110)) { ERROR("Error initiating soft buffer"); return false; } @@ -348,7 +348,7 @@ void ul_harq_entity::ul_harq_process::generate_new_tx(mac_interface_phy_lte::mac mac_interface_phy_lte::tb_action_ul_t* action) { // Compute average number of retransmissions per packet considering previous packet - harq_entity->average_retx = SRSLTE_VEC_CMA((float)current_tx_nb, harq_entity->average_retx, harq_entity->nof_pkts++); + harq_entity->average_retx = SRSRAN_VEC_CMA((float)current_tx_nb, harq_entity->average_retx, harq_entity->nof_pkts++); cur_grant = grant; harq_feedback = false; is_grant_configured = true; diff --git a/srsue/src/stack/mac_nr/CMakeLists.txt b/srsue/src/stack/mac_nr/CMakeLists.txt index 2003bb81b..d051c0d1a 100644 --- a/srsue/src/stack/mac_nr/CMakeLists.txt +++ b/srsue/src/stack/mac_nr/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -8,4 +8,4 @@ set(SOURCES mac_nr.cc proc_ra_nr.cc mux_nr.cc) add_library(srsue_mac_nr STATIC ${SOURCES}) -target_link_libraries(srsue_mac_nr srslte_mac) \ No newline at end of file +target_link_libraries(srsue_mac_nr srsran_mac) \ No newline at end of file diff --git a/srsue/src/stack/mac_nr/mac_nr.cc b/srsue/src/stack/mac_nr/mac_nr.cc index 8290ec158..78c28978d 100644 --- a/srsue/src/stack/mac_nr/mac_nr.cc +++ b/srsue/src/stack/mac_nr/mac_nr.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,20 +11,16 @@ */ #include "srsue/hdr/stack/mac_nr/mac_nr.h" -#include "srslte/mac/mac_rar_pdu_nr.h" +#include "srsran/mac/mac_rar_pdu_nr.h" #include "srsue/hdr/stack/mac_nr/proc_ra_nr.h" namespace srsue { -mac_nr::mac_nr(srslte::ext_task_sched_handle task_sched_) : - task_sched(task_sched_), - logger(srslog::fetch_basic_logger("MAC")), - proc_ra(logger), - mux(logger), - pcap(nullptr) +mac_nr::mac_nr(srsran::ext_task_sched_handle task_sched_) : + task_sched(task_sched_), logger(srslog::fetch_basic_logger("MAC")), proc_ra(logger), mux(logger), pcap(nullptr) { - tx_buffer = srslte::make_byte_buffer(); - rlc_buffer = srslte::make_byte_buffer(); + tx_buffer = srsran::make_byte_buffer(); + rlc_buffer = srsran::make_byte_buffer(); } mac_nr::~mac_nr() @@ -45,18 +41,18 @@ int mac_nr::init(const mac_nr_args_t& args_, phy_interface_mac_nr* phy_, rlc_int mux.init(); - if (srslte_softbuffer_tx_init_guru(&softbuffer_tx, SRSLTE_SCH_NR_MAX_NOF_CB_LDPC, SRSLTE_LDPC_MAX_LEN_ENCODED_CB) < - SRSLTE_SUCCESS) { + if (srsran_softbuffer_tx_init_guru(&softbuffer_tx, SRSRAN_SCH_NR_MAX_NOF_CB_LDPC, SRSRAN_LDPC_MAX_LEN_ENCODED_CB) < + SRSRAN_SUCCESS) { ERROR("Error init soft-buffer"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } started = true; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -void mac_nr::start_pcap(srslte::mac_pcap* pcap_) +void mac_nr::start_pcap(srsran::mac_pcap* pcap_) { pcap = pcap_; } @@ -67,7 +63,7 @@ void mac_nr::stop() started = false; } - srslte_softbuffer_tx_free(&softbuffer_tx); + srsran_softbuffer_tx_free(&softbuffer_tx); } // Implement Section 5.9 @@ -84,7 +80,7 @@ void mac_nr::run_tti(const uint32_t tti) mac_interface_phy_nr::sched_rnti_t mac_nr::get_ul_sched_rnti_nr(const uint32_t tti) { - return {c_rnti, srslte_rnti_type_c}; + return {c_rnti, srsran_rnti_type_c}; } bool mac_nr::is_si_opportunity() @@ -102,34 +98,34 @@ mac_interface_phy_nr::sched_rnti_t mac_nr::get_dl_sched_rnti_nr(const uint32_t t { // Priority: SI-RNTI, P-RNTI, RA-RNTI, Temp-RNTI, CRNTI if (is_si_opportunity()) { - return {SRSLTE_SIRNTI, srslte_rnti_type_si}; + return {SRSRAN_SIRNTI, srsran_rnti_type_si}; } if (is_paging_opportunity()) { - return {SRSLTE_PRNTI, srslte_rnti_type_si}; + return {SRSRAN_PRNTI, srsran_rnti_type_si}; } if (proc_ra.is_rar_opportunity(tti)) { - return {proc_ra.get_rar_rnti(), srslte_rnti_type_ra}; + return {proc_ra.get_rar_rnti(), srsran_rnti_type_ra}; } if (proc_ra.has_temp_rnti() && has_crnti() == false) { logger.debug("SCHED: Searching temp C-RNTI=0x%x (proc_ra)", proc_ra.get_temp_rnti()); - return {proc_ra.get_temp_rnti(), srslte_rnti_type_c}; + return {proc_ra.get_temp_rnti(), srsran_rnti_type_c}; } if (has_crnti()) { logger.debug("SCHED: Searching C-RNTI=0x%x", get_crnti()); - return {get_crnti(), srslte_rnti_type_c}; + return {get_crnti(), srsran_rnti_type_c}; } // turn off DCI search for this TTI - return {SRSLTE_INVALID_RNTI, srslte_rnti_type_c}; + return {SRSRAN_INVALID_RNTI, srsran_rnti_type_c}; } bool mac_nr::has_crnti() { - return c_rnti != SRSLTE_INVALID_RNTI; + return c_rnti != SRSRAN_INVALID_RNTI; } uint16_t mac_nr::get_crnti() @@ -137,7 +133,7 @@ uint16_t mac_nr::get_crnti() return c_rnti; } -void mac_nr::bch_decoded_ok(uint32_t tti, srslte::unique_byte_buffer_t payload) +void mac_nr::bch_decoded_ok(uint32_t tti, srsran::unique_byte_buffer_t payload) { // Send MIB to RLC rlc->write_pdu_bcch_bch(std::move(payload)); @@ -150,7 +146,7 @@ void mac_nr::bch_decoded_ok(uint32_t tti, srslte::unique_byte_buffer_t payload) int mac_nr::sf_indication(const uint32_t tti) { run_tti(tti); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } void mac_nr::prach_sent(const uint32_t tti, @@ -166,11 +162,11 @@ void mac_nr::prach_sent(const uint32_t tti, void mac_nr::write_pcap(const uint32_t cc_idx, mac_nr_grant_dl_t& grant) { if (pcap) { - for (uint32_t i = 0; i < SRSLTE_MAX_CODEWORDS; ++i) { + for (uint32_t i = 0; i < SRSRAN_MAX_CODEWORDS; ++i) { if (grant.tb[i] != nullptr) { if (proc_ra.has_rar_rnti() && grant.rnti == proc_ra.get_rar_rnti()) { pcap->write_dl_ra_rnti_nr(grant.tb[i]->msg, grant.tb[i]->N_bytes, grant.rnti, true, grant.tti); - } else if (grant.rnti == SRSLTE_PRNTI) { + } else if (grant.rnti == SRSRAN_PRNTI) { pcap->write_dl_pch_nr(grant.tb[i]->msg, grant.tb[i]->N_bytes, grant.rnti, true, grant.tti); } else { pcap->write_dl_crnti_nr(grant.tb[i]->msg, grant.tb[i]->N_bytes, grant.rnti, true, grant.tti); @@ -196,7 +192,7 @@ void mac_nr::tb_decoded(const uint32_t cc_idx, mac_nr_grant_dl_t& grant) proc_ra.handle_rar_pdu(grant); } else { // Push DL PDUs to queue for back-ground processing - for (uint32_t i = 0; i < SRSLTE_MAX_CODEWORDS; ++i) { + for (uint32_t i = 0; i < SRSRAN_MAX_CODEWORDS; ++i) { if (grant.tb[i] != nullptr) { pdu_queue.push(std::move(grant.tb[i])); } @@ -219,7 +215,7 @@ void mac_nr::new_grant_ul(const uint32_t cc_idx, const mac_nr_grant_ul_t& grant, action->tb.enabled = true; action->tb.rv = 0; action->tb.softbuffer = &softbuffer_tx; - srslte_softbuffer_tx_reset(&softbuffer_tx); + srsran_softbuffer_tx_reset(&softbuffer_tx); // Pack MAC PDU get_ul_data(grant, action->tb.payload); @@ -227,7 +223,7 @@ void mac_nr::new_grant_ul(const uint32_t cc_idx, const mac_nr_grant_ul_t& grant, metrics[cc_idx].tx_pkts++; } -void mac_nr::get_ul_data(const mac_nr_grant_ul_t& grant, srslte::byte_buffer_t* phy_tx_pdu) +void mac_nr::get_ul_data(const mac_nr_grant_ul_t& grant, srsran::byte_buffer_t* phy_tx_pdu) { // initialize MAC PDU phy_tx_pdu->clear(); @@ -237,7 +233,7 @@ void mac_nr::get_ul_data(const mac_nr_grant_ul_t& grant, srslte::byte_buffer_t* // If message 3 is pending pack message 3 for uplink transmission // Use the CRNTI which is provided in the RRC reconfiguration (only for DC mode maybe other) tx_pdu.add_crnti_ce(c_rnti); - srslte::mac_sch_subpdu_nr::lcg_bsr_t sbsr = {}; + srsran::mac_sch_subpdu_nr::lcg_bsr_t sbsr = {}; sbsr.lcg_id = 0; sbsr.buffer_size = 1; tx_pdu.add_sbsr_ce(sbsr); @@ -258,7 +254,7 @@ void mac_nr::get_ul_data(const mac_nr_grant_ul_t& grant, srslte::byte_buffer_t* logger.info(rlc_buffer->msg, rlc_buffer->N_bytes, "Read %d B from RLC", rlc_buffer->N_bytes); // add to MAC PDU and pack - if (tx_pdu.add_sdu(4, rlc_buffer->msg, rlc_buffer->N_bytes) != SRSLTE_SUCCESS) { + if (tx_pdu.add_sdu(4, rlc_buffer->msg, rlc_buffer->N_bytes) != SRSRAN_SUCCESS) { logger.error("Error packing MAC PDU"); } } else { @@ -282,7 +278,7 @@ void mac_nr::timer_expired(uint32_t timer_id) // not implemented } -void mac_nr::setup_lcid(const srslte::logical_channel_config_t& config) +void mac_nr::setup_lcid(const srsran::logical_channel_config_t& config) { logger.info("Logical Channel Setup: LCID=%d, LCG=%d, priority=%d, PBR=%d, BSD=%dms, bucket_size=%d", config.lcid, @@ -295,19 +291,20 @@ void mac_nr::setup_lcid(const srslte::logical_channel_config_t& config) // bsr_procedure.setup_lcid(config.lcid, config.lcg, config.priority); } -void mac_nr::set_config(const srslte::bsr_cfg_t& bsr_cfg) +void mac_nr::set_config(const srsran::bsr_cfg_t& bsr_cfg) { logger.info("BSR config periodic timer %d retx timer %d", bsr_cfg.periodic_timer, bsr_cfg.retx_timer); logger.warning("Not handling BSR config yet"); } -void mac_nr::set_config(const srslte::sr_cfg_t& sr_cfg) +void mac_nr::set_config(const srsran::sr_cfg_t& sr_cfg) { logger.info("Scheduling Request Config DSR tansmax %d", sr_cfg.dsr_transmax); logger.warning("Not Scheduling Request Config yet"); } -void mac_nr::set_config(const srslte::rach_nr_cfg_t& rach_cfg){ +void mac_nr::set_config(const srsran::rach_nr_cfg_t& rach_cfg) +{ proc_ra.set_config(rach_cfg); } @@ -339,7 +336,7 @@ bool mac_nr::is_valid_crnti(const uint16_t crnti) return (crnti >= 0x0001 && crnti <= 0xFFEF); } -void mac_nr::get_metrics(mac_metrics_t m[SRSLTE_MAX_CARRIERS]) {} +void mac_nr::get_metrics(mac_metrics_t m[SRSRAN_MAX_CARRIERS]) {} /** * Called from the main stack thread to process received PDUs @@ -347,13 +344,13 @@ void mac_nr::get_metrics(mac_metrics_t m[SRSLTE_MAX_CARRIERS]) {} void mac_nr::process_pdus() { while (started and not pdu_queue.empty()) { - srslte::unique_byte_buffer_t pdu = pdu_queue.wait_pop(); + srsran::unique_byte_buffer_t pdu = pdu_queue.wait_pop(); // TODO: delegate to demux class handle_pdu(std::move(pdu)); } } -void mac_nr::handle_pdu(srslte::unique_byte_buffer_t pdu) +void mac_nr::handle_pdu(srsran::unique_byte_buffer_t pdu) { logger.info(pdu->msg, pdu->N_bytes, "Handling MAC PDU (%d B)", pdu->N_bytes); @@ -361,7 +358,7 @@ void mac_nr::handle_pdu(srslte::unique_byte_buffer_t pdu) rx_pdu.unpack(pdu->msg, pdu->N_bytes); for (uint32_t i = 0; i < rx_pdu.get_num_subpdus(); ++i) { - srslte::mac_sch_subpdu_nr subpdu = rx_pdu.get_subpdu(i); + srsran::mac_sch_subpdu_nr subpdu = rx_pdu.get_subpdu(i); logger.info("Handling subPDU %d/%d: rnti=0x%x lcid=%d, sdu_len=%d", i + 1, rx_pdu.get_num_subpdus(), @@ -395,7 +392,7 @@ bool mac_nr::is_in_window(uint32_t tti, int* start, int* len) uint32_t st = (uint32_t)*start; uint32_t l = (uint32_t)*len; - if (srslte_tti_interval(tti, st) < l + 5) { + if (srsran_tti_interval(tti, st) < l + 5) { if (tti > st) { if (tti <= st + l) { return true; diff --git a/srsue/src/stack/mac_nr/mux_nr.cc b/srsue/src/stack/mac_nr/mux_nr.cc index 084ee457c..5cb082091 100644 --- a/srsue/src/stack/mac_nr/mux_nr.cc +++ b/srsue/src/stack/mac_nr/mux_nr.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,13 +11,13 @@ */ #include "srsue/hdr/stack/mac_nr/mux_nr.h" -#include "srslte/common/buffer_pool.h" +#include "srsran/common/buffer_pool.h" namespace srsue { mux_nr::mux_nr(srslog::basic_logger& logger_) : logger(logger_) { - msg3_buff = srslte::make_byte_buffer(); + msg3_buff = srsran::make_byte_buffer(); }; void mux_nr::init() {} diff --git a/srsue/src/stack/mac_nr/proc_ra_nr.cc b/srsue/src/stack/mac_nr/proc_ra_nr.cc index 3525c4ec4..024d1787f 100644 --- a/srsue/src/stack/mac_nr/proc_ra_nr.cc +++ b/srsue/src/stack/mac_nr/proc_ra_nr.cc @@ -11,8 +11,8 @@ */ #include "srsue/hdr/stack/mac_nr/proc_ra_nr.h" -#include "srslte/common/standard_streams.h" -#include "srslte/mac/mac_rar_pdu_nr.h" +#include "srsran/common/standard_streams.h" +#include "srsran/mac/mac_rar_pdu_nr.h" #include "srsue/hdr/stack/mac_nr/mac_nr.h" namespace srsue { @@ -34,7 +34,7 @@ proc_ra_nr::proc_ra_nr(srslog::basic_logger& logger_) : logger(logger_) {} void proc_ra_nr::init(phy_interface_mac_nr* phy_, mac_interface_proc_ra_nr* mac_, - srslte::ext_task_sched_handle* task_sched_) + srsran::ext_task_sched_handle* task_sched_) { phy = phy_; mac = mac_; @@ -46,12 +46,12 @@ void proc_ra_nr::init(phy_interface_mac_nr* phy_, } /* Sets a new configuration. The configuration is applied by initialization() function */ -void proc_ra_nr::set_config(const srslte::rach_nr_cfg_t& rach_cfg_) +void proc_ra_nr::set_config(const srsran::rach_nr_cfg_t& rach_cfg_) { if (state != IDLE) { logger.warning("Wrong state for ra reponse reception %s (expected state %s)", - srslte::enum_to_text(state_str_nr, (uint32_t)ra_state_t::MAX_RA_STATES, state), - srslte::enum_to_text(state_str_nr, (uint32_t)ra_state_t::MAX_RA_STATES, IDLE)); + srsran::enum_to_text(state_str_nr, (uint32_t)ra_state_t::MAX_RA_STATES, state), + srsran::enum_to_text(state_str_nr, (uint32_t)ra_state_t::MAX_RA_STATES, IDLE)); return; } rach_cfg = rach_cfg_; @@ -66,7 +66,7 @@ void proc_ra_nr::start_by_rrc() { if (state != IDLE || configured == false) { logger.warning("Trying to start PRACH by RRC order in invalid state (%s)", - srslte::enum_to_text(state_str_nr, (uint32_t)ra_state_t::MAX_RA_STATES, state)); + srsran::enum_to_text(state_str_nr, (uint32_t)ra_state_t::MAX_RA_STATES, state)); return; } started_by = initiators_t::RRC; @@ -87,16 +87,16 @@ bool proc_ra_nr::is_rar_opportunity(uint32_t tti) uint16_t proc_ra_nr::get_rar_rnti() { - if (rar_rnti == SRSLTE_INVALID_RNTI || state != WAITING_FOR_RESPONSE_RECEPTION) { + if (rar_rnti == SRSRAN_INVALID_RNTI || state != WAITING_FOR_RESPONSE_RECEPTION) { logger.error("Requested ra rnti is invalid. Anyway we return an invalid ra rnti"); - return SRSLTE_INVALID_RNTI; + return SRSRAN_INVALID_RNTI; } return rar_rnti; } bool proc_ra_nr::has_rar_rnti() { - if (rar_rnti != SRSLTE_INVALID_RNTI) { + if (rar_rnti != SRSRAN_INVALID_RNTI) { return true; } return false; @@ -104,7 +104,7 @@ bool proc_ra_nr::has_rar_rnti() bool proc_ra_nr::has_temp_rnti() { - return temp_rnti != SRSLTE_INVALID_RNTI; + return temp_rnti != SRSRAN_INVALID_RNTI; } uint16_t proc_ra_nr::get_temp_rnti() @@ -168,16 +168,16 @@ void proc_ra_nr::ra_response_reception(const mac_interface_phy_nr::mac_nr_grant_ if (state != WAITING_FOR_RESPONSE_RECEPTION) { logger.warning( "Wrong state for ra reponse reception %s (expected state %s)", - srslte::enum_to_text(state_str_nr, (uint32_t)ra_state_t::MAX_RA_STATES, state), - srslte::enum_to_text(state_str_nr, (uint32_t)ra_state_t::MAX_RA_STATES, WAITING_FOR_RESPONSE_RECEPTION)); + srsran::enum_to_text(state_str_nr, (uint32_t)ra_state_t::MAX_RA_STATES, state), + srsran::enum_to_text(state_str_nr, (uint32_t)ra_state_t::MAX_RA_STATES, WAITING_FOR_RESPONSE_RECEPTION)); return; } // Stop rar timer rar_timeout_timer.stop(); - for (uint32_t i = 0; i < SRSLTE_MAX_CODEWORDS; ++i) { + for (uint32_t i = 0; i < SRSRAN_MAX_CODEWORDS; ++i) { if (grant.tb[i] != nullptr) { - srslte::mac_rar_pdu_nr pdu; + srsran::mac_rar_pdu_nr pdu; if (!pdu.unpack(grant.tb[i]->msg, grant.tb[i]->N_bytes)) { logger.warning("Error unpacking RAR PDU (%d)", i); return; @@ -190,10 +190,10 @@ void proc_ra_nr::ra_response_reception(const mac_interface_phy_nr::mac_nr_grant_ temp_rnti = subpdu.get_temp_crnti(); // Set Temporary-C-RNTI if provided, otherwise C-RNTI is ok - phy->set_ul_grant(subpdu.get_ul_grant(), temp_rnti, srslte_rnti_type_c); + phy->set_ul_grant(subpdu.get_ul_grant(), temp_rnti, srsran_rnti_type_c); // reset all parameters that are used before rar - rar_rnti = SRSLTE_INVALID_RNTI; + rar_rnti = SRSRAN_INVALID_RNTI; mac->msg3_prepare(); current_ta = subpdu.get_ta(); } @@ -213,8 +213,8 @@ void proc_ra_nr::ra_contention_resolution() if (state != WAITING_FOR_CONTENTION_RESOLUTION) { logger.warning( "Wrong state for ra contention resolution by phy %s (expected state %s)", - srslte::enum_to_text(state_str_nr, (uint32_t)ra_state_t::MAX_RA_STATES, state), - srslte::enum_to_text(state_str_nr, (uint32_t)ra_state_t::MAX_RA_STATES, WAITING_FOR_CONTENTION_RESOLUTION)); + srsran::enum_to_text(state_str_nr, (uint32_t)ra_state_t::MAX_RA_STATES, state), + srsran::enum_to_text(state_str_nr, (uint32_t)ra_state_t::MAX_RA_STATES, WAITING_FOR_CONTENTION_RESOLUTION)); return; } if (started_by == initiators_t::RRC || started_by == initiators_t::MAC) { @@ -233,8 +233,8 @@ void proc_ra_nr::ra_contention_resolution(uint64_t rx_contention_id) if (state != WAITING_FOR_CONTENTION_RESOLUTION) { logger.warning( "Wrong state for ra contention resolution by phy %s (expected state %s)", - srslte::enum_to_text(state_str_nr, (uint32_t)ra_state_t::MAX_RA_STATES, state), - srslte::enum_to_text(state_str_nr, (uint32_t)ra_state_t::MAX_RA_STATES, WAITING_FOR_CONTENTION_RESOLUTION)); + srsran::enum_to_text(state_str_nr, (uint32_t)ra_state_t::MAX_RA_STATES, state), + srsran::enum_to_text(state_str_nr, (uint32_t)ra_state_t::MAX_RA_STATES, WAITING_FOR_CONTENTION_RESOLUTION)); return; } // TODO @@ -244,13 +244,13 @@ void proc_ra_nr::ra_completion() { if (state != WAITING_FOR_COMPLETION) { logger.warning("Wrong state for ra completion by phy %s (expected state %s)", - srslte::enum_to_text(state_str_nr, (uint32_t)ra_state_t::MAX_RA_STATES, state), - srslte::enum_to_text(state_str_nr, (uint32_t)ra_state_t::MAX_RA_STATES, WAITING_FOR_COMPLETION)); + srsran::enum_to_text(state_str_nr, (uint32_t)ra_state_t::MAX_RA_STATES, state), + srsran::enum_to_text(state_str_nr, (uint32_t)ra_state_t::MAX_RA_STATES, WAITING_FOR_COMPLETION)); return; } - srslte::console("Random Access Complete. c-rnti=0x%x, ta=%d\n", mac->get_c_rnti(), current_ta); + srsran::console("Random Access Complete. c-rnti=0x%x, ta=%d\n", mac->get_c_rnti(), current_ta); logger.info("Random Access Complete. c-rnti=0x%x, ta=%d", mac->get_c_rnti(), current_ta); - temp_rnti = SRSLTE_INVALID_RNTI; + temp_rnti = SRSRAN_INVALID_RNTI; reset(); } @@ -265,8 +265,8 @@ void proc_ra_nr::prach_sent(uint32_t tti, uint32_t s_id, uint32_t t_id, uint32_t task_queue.push([this, tti, s_id, t_id, f_id, ul_carrier_id]() { if (state != WAITING_FOR_PRACH_SENT) { logger.warning("Wrong state for prach sent notification by phy %s (expected state %s)", - srslte::enum_to_text(state_str_nr, (uint32_t)ra_state_t::MAX_RA_STATES, state), - srslte::enum_to_text(state_str_nr, (uint32_t)ra_state_t::MAX_RA_STATES, WAITING_FOR_PRACH_SENT)); + srsran::enum_to_text(state_str_nr, (uint32_t)ra_state_t::MAX_RA_STATES, state), + srsran::enum_to_text(state_str_nr, (uint32_t)ra_state_t::MAX_RA_STATES, WAITING_FOR_PRACH_SENT)); return; } prach_send_timer.stop(); @@ -281,7 +281,7 @@ void proc_ra_nr::prach_sent(uint32_t tti, uint32_t s_id, uint32_t t_id, uint32_t t_id, f_id, ul_carrier_id); - srslte::console("Random Access Transmission: prach_occasion=%d, preamble_index=%d, ra-rnti=0x%x, tti=%d\n", + srsran::console("Random Access Transmission: prach_occasion=%d, preamble_index=%d, ra-rnti=0x%x, tti=%d\n", prach_occasion, preamble_index, rar_rnti, diff --git a/srsue/src/stack/rrc/CMakeLists.txt b/srsue/src/stack/rrc/CMakeLists.txt index d51065957..434c9e077 100644 --- a/srsue/src/stack/rrc/CMakeLists.txt +++ b/srsue/src/stack/rrc/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of diff --git a/srsue/src/stack/rrc/phy_controller.cc b/srsue/src/stack/rrc/phy_controller.cc index c0d6e48d8..8b9dfa999 100644 --- a/srsue/src/stack/rrc/phy_controller.cc +++ b/srsue/src/stack/rrc/phy_controller.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -22,7 +22,7 @@ std::string to_string(const phy_cell_t& cell) } phy_controller::phy_controller(srsue::phy_interface_rrc_lte* phy_, - srslte::task_sched_handle task_sched_, + srsran::task_sched_handle task_sched_, std::function on_cell_selection) : base_t(srslog::fetch_basic_logger("RRC")), phy(phy_), @@ -35,7 +35,7 @@ void phy_controller::in_sync() trigger(in_sync_ev{}); } -bool phy_controller::set_cell_config(const srslte::phy_cfg_t& config, uint32_t cc_idx) +bool phy_controller::set_cell_config(const srsran::phy_cfg_t& config, uint32_t cc_idx) { logger.info("Setting PHY config for cc_idx=%d", cc_idx); return set_cell_config(config, cc_idx, true); @@ -45,9 +45,9 @@ void phy_controller::set_phy_to_default() { logger.info("Setting default PHY config (common and dedicated)"); - srslte::phy_cfg_t& default_cfg = current_cells_cfg[0]; + srsran::phy_cfg_t& default_cfg = current_cells_cfg[0]; default_cfg.set_defaults(); - for (uint32_t i = 0; i < SRSLTE_MAX_CARRIERS; ++i) { + for (uint32_t i = 0; i < SRSRAN_MAX_CARRIERS; ++i) { set_cell_config(default_cfg, i, false); } } @@ -57,9 +57,9 @@ void phy_controller::set_phy_to_default_dedicated() { logger.info("Setting default dedicated PHY config"); - srslte::phy_cfg_t& default_cfg = current_cells_cfg[0]; + srsran::phy_cfg_t& default_cfg = current_cells_cfg[0]; default_cfg.set_defaults_dedicated(); - for (uint32_t i = 0; i < SRSLTE_MAX_CARRIERS; ++i) { + for (uint32_t i = 0; i < SRSRAN_MAX_CARRIERS; ++i) { set_cell_config(default_cfg, i, false); } } @@ -68,14 +68,14 @@ void phy_controller::set_phy_to_default_pucch_srs() { logger.info("Setting default PHY config dedicated"); - srslte::phy_cfg_t& default_cfg_ded = current_cells_cfg[0]; + srsran::phy_cfg_t& default_cfg_ded = current_cells_cfg[0]; default_cfg_ded.set_defaults_pucch_sr(); - for (uint32_t i = 0; i < SRSLTE_MAX_CARRIERS; ++i) { + for (uint32_t i = 0; i < SRSRAN_MAX_CARRIERS; ++i) { set_cell_config(default_cfg_ded, i, false); } } -bool phy_controller::set_cell_config(const srslte::phy_cfg_t& cfg, uint32_t cc_idx, bool is_set) +bool phy_controller::set_cell_config(const srsran::phy_cfg_t& cfg, uint32_t cc_idx, bool is_set) { if ((is_set or cc_idx == 0 or configured_scell_mask[cc_idx]) and phy->set_config(cfg, cc_idx)) { current_cells_cfg[cc_idx] = cfg; @@ -101,7 +101,7 @@ void phy_controller::set_config_complete() * PHY Cell Select Procedure *************************************/ -bool phy_controller::start_cell_select(const phy_cell_t& phy_cell, srslte::event_observer observer) +bool phy_controller::start_cell_select(const phy_cell_t& phy_cell, srsran::event_observer observer) { if (is_in_state()) { logger.warning("Failed to launch cell selection as it is already running"); @@ -133,7 +133,7 @@ void phy_controller::selecting_cell::enter(phy_controller* f, const cell_sel_cmd fsmInfo("Starting for pci=%d, earfcn=%d", target_cell.pci, target_cell.earfcn); if (not f->phy->cell_select(target_cell)) { - trigger(srslte::failure_ev{}); + trigger(srsran::failure_ev{}); } } @@ -166,7 +166,7 @@ void phy_controller::selecting_cell::wait_in_sync::enter(selecting_cell* f) *************************************/ //! Searches for a cell in the current frequency and retrieves SIB1 if not retrieved yet -bool phy_controller::start_cell_search(srslte::event_observer observer) +bool phy_controller::start_cell_search(srsran::event_observer observer) { if (is_in_state()) { fsmInfo("Cell search already launched."); diff --git a/srsue/src/stack/rrc/rrc.cc b/srsue/src/stack/rrc/rrc.cc index 787a0088b..e8d481ba2 100644 --- a/srsue/src/stack/rrc/rrc.cc +++ b/srsue/src/stack/rrc/rrc.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,15 +11,15 @@ */ #include "srsue/hdr/stack/rrc/rrc.h" -#include "srslte/asn1/rrc.h" -#include "srslte/common/bcd_helpers.h" -#include "srslte/common/security.h" -#include "srslte/common/standard_streams.h" -#include "srslte/interfaces/ue_gw_interfaces.h" -#include "srslte/interfaces/ue_nas_interfaces.h" -#include "srslte/interfaces/ue_pdcp_interfaces.h" -#include "srslte/interfaces/ue_rlc_interfaces.h" -#include "srslte/interfaces/ue_usim_interfaces.h" +#include "srsran/asn1/rrc.h" +#include "srsran/common/bcd_helpers.h" +#include "srsran/common/security.h" +#include "srsran/common/standard_streams.h" +#include "srsran/interfaces/ue_gw_interfaces.h" +#include "srsran/interfaces/ue_nas_interfaces.h" +#include "srsran/interfaces/ue_pdcp_interfaces.h" +#include "srsran/interfaces/ue_rlc_interfaces.h" +#include "srsran/interfaces/ue_usim_interfaces.h" #include "srsue/hdr/stack/rrc/phy_controller.h" #include "srsue/hdr/stack/rrc/rrc_meas.h" #include "srsue/hdr/stack/rrc/rrc_procedures.h" @@ -34,7 +34,7 @@ bool simulate_rlf = false; -using namespace srslte; +using namespace srsran; using namespace asn1::rrc; namespace srsue { @@ -46,7 +46,7 @@ const static uint32_t required_sibs[NOF_REQUIRED_SIBS] = {0, 1, 2, 12}; // SIB1, Base functions *******************************************************************************/ -rrc::rrc(stack_interface_rrc* stack_, srslte::task_sched_handle task_sched_) : +rrc::rrc(stack_interface_rrc* stack_, srsran::task_sched_handle task_sched_) : stack(stack_), task_sched(task_sched_), state(RRC_STATE_IDLE), @@ -306,7 +306,7 @@ bool rrc::plmn_search() /* This is the NAS interface. When NAS requests to select a PLMN we have to * connect to either register or because there is pending higher layer traffic. */ -void rrc::plmn_select(srslte::plmn_id_t plmn_id) +void rrc::plmn_select(srsran::plmn_id_t plmn_id) { plmn_is_selected = true; selected_plmn_id = plmn_id; @@ -322,7 +322,7 @@ void rrc::plmn_select(srslte::plmn_id_t plmn_id) * it. Sends connectionRequest message and returns if message transmitted successfully. * It does not wait until completition of Connection Establishment procedure */ -bool rrc::connection_request(srslte::establishment_cause_t cause, srslte::unique_byte_buffer_t dedicated_info_nas_) +bool rrc::connection_request(srsran::establishment_cause_t cause, srsran::unique_byte_buffer_t dedicated_info_nas_) { if (not conn_req_proc.launch(cause, std::move(dedicated_info_nas_))) { logger.error("Failed to initiate connection request procedure"); @@ -332,7 +332,7 @@ bool rrc::connection_request(srslte::establishment_cause_t cause, srslte::unique return true; } -void rrc::set_ue_identity(srslte::s_tmsi_t s_tmsi) +void rrc::set_ue_identity(srsran::s_tmsi_t s_tmsi) { ue_identity_configured = true; ue_identity = s_tmsi; @@ -563,10 +563,10 @@ int rrc::start_cell_select() { if (not cell_selector.launch()) { logger.error("Failed to initiate a Cell Selection procedure..."); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } callback_list.add_proc(cell_selector); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } bool rrc::has_neighbour_cell(uint32_t earfcn, uint32_t pci) const @@ -634,7 +634,7 @@ bool rrc::mbms_service_start(uint32_t serv, uint32_t port) for (uint32_t j = 0; j < pmch->mbms_session_info_list_r9.size(); j++) { mbms_session_info_r9_s* sess = &pmch->mbms_session_info_list_r9[j]; if (serv == sess->tmgi_r9.service_id_r9.to_number()) { - srslte::console("MBMS service started. Service id=%d, port=%d, lcid=%d\n", serv, port, sess->lc_ch_id_r9); + srsran::console("MBMS service started. Service id=%d, port=%d, lcid=%d\n", serv, port, sess->lc_ch_id_r9); ret = true; add_mrb(sess->lc_ch_id_r9, port); } @@ -674,7 +674,7 @@ void rrc::radio_link_failure_push_cmd() void rrc::radio_link_failure_process() { // TODO: Generate and store failure report - srslte::console("Warning: Detected Radio-Link Failure\n"); + srsran::console("Warning: Detected Radio-Link Failure\n"); if (state == RRC_STATE_CONNECTED) { if (security_is_activated) { @@ -721,7 +721,7 @@ void rrc::timer_expired(uint32_t timeout_id) logger.info("Timer T310 expired: Radio Link Failure"); radio_link_failure_push_cmd(); } else if (timeout_id == t311.id()) { - srslte::console("Timer T311 expired: Going to RRC IDLE\n"); + srsran::console("Timer T311 expired: Going to RRC IDLE\n"); if (connection_reest.is_idle()) { logger.info("Timer T311 expired: Going to RRC IDLE"); start_go_idle(); @@ -738,11 +738,11 @@ void rrc::timer_expired(uint32_t timeout_id) } } else if (timeout_id == t302.id()) { logger.info("Timer T302 expired. Informing NAS about barrier alleviation"); - nas->set_barring(srslte::barring_t::none); + nas->set_barring(srsran::barring_t::none); } else if (timeout_id == t300.id()) { // Do nothing, handled in connection_request() } else if (timeout_id == t304.id()) { - srslte::console("Timer t304 expired: Handover failed\n"); + srsran::console("Timer t304 expired: Handover failed\n"); logger.info("Timer t304 expired: Handover failed"); ho_failed(); } else { @@ -814,7 +814,7 @@ bool rrc::nr_reconfiguration_proc(const rrc_conn_recfg_r8_ies_s& rx_recfg) * *******************************************************************************/ -void rrc::send_con_request(srslte::establishment_cause_t cause) +void rrc::send_con_request(srsran::establishment_cause_t cause) { logger.debug("Preparing RRC Connection Request"); @@ -825,7 +825,7 @@ void rrc::send_con_request(srslte::establishment_cause_t cause) if (ue_identity_configured) { rrc_conn_req->ue_id.set_s_tmsi(); - srslte::to_asn1(&rrc_conn_req->ue_id.s_tmsi(), ue_identity); + srsran::to_asn1(&rrc_conn_req->ue_id.s_tmsi(), ue_identity); } else { rrc_conn_req->ue_id.set_random_value(); // TODO use proper RNG @@ -913,7 +913,7 @@ void rrc::send_con_restablish_request(reest_cause_e cause, uint16_t crnti, uint1 rrc_conn_reest_req->ue_id.short_mac_i.from_number(mac_key[2] << 8 | mac_key[3]); rrc_conn_reest_req->reest_cause = cause; - srslte::console("RRC Connection Reestablishment to PCI=%d, EARFCN=%d (Cause: \"%s\")\n", + srsran::console("RRC Connection Reestablishment to PCI=%d, EARFCN=%d (Cause: \"%s\")\n", meas_cells.serving_cell().phy_cell.pci, meas_cells.serving_cell().phy_cell.earfcn, cause.to_string().c_str()); @@ -927,7 +927,7 @@ void rrc::send_con_restablish_request(reest_cause_e cause, uint16_t crnti, uint1 void rrc::send_con_restablish_complete() { logger.debug("Preparing RRC Connection Reestablishment Complete"); - srslte::console("RRC Connected\n"); + srsran::console("RRC Connected\n"); // Prepare ConnectionSetupComplete packet ul_dcch_msg_s ul_dcch_msg; @@ -939,7 +939,7 @@ void rrc::send_con_restablish_complete() reestablishment_successful = true; } -void rrc::send_con_setup_complete(srslte::unique_byte_buffer_t nas_msg) +void rrc::send_con_setup_complete(srsran::unique_byte_buffer_t nas_msg) { logger.debug("Preparing RRC Connection Setup Complete"); @@ -1086,14 +1086,14 @@ void rrc::handle_rrc_con_reconfig(uint32_t lcid, const rrc_conn_recfg_s& reconfi void rrc::rrc_connection_release(const std::string& cause) { // Save idleModeMobilityControlInfo, etc. - srslte::console("Received RRC Connection Release (releaseCause: %s)\n", cause.c_str()); + srsran::console("Received RRC Connection Release (releaseCause: %s)\n", cause.c_str()); start_go_idle(); } /// TS 36.331, 5.3.12 - UE actions upon leaving RRC_CONNECTED void rrc::leave_connected() { - srslte::console("RRC IDLE\n"); + srsran::console("RRC IDLE\n"); logger.info("Leaving RRC_CONNECTED state"); state = RRC_STATE_IDLE; drb_up = false; @@ -1327,7 +1327,7 @@ void rrc::handle_sib1() // Set TDD Config if (sib1->tdd_cfg_present) { - srslte_tdd_config_t tdd_config = {}; + srsran_tdd_config_t tdd_config = {}; tdd_config.sf_config = sib1->tdd_cfg.sf_assign.to_number(); tdd_config.ss_config = sib1->tdd_cfg.special_sf_patterns.to_number(); phy->set_config_tdd(tdd_config); @@ -1347,15 +1347,15 @@ void rrc::handle_sib2() // Set MBSFN configs if (sib2->mbsfn_sf_cfg_list_present) { - srslte::mbsfn_sf_cfg_t list[ASN1_RRC_MAX_MBSFN_ALLOCS]; + srsran::mbsfn_sf_cfg_t list[ASN1_RRC_MAX_MBSFN_ALLOCS]; for (uint32_t i = 0; i < sib2->mbsfn_sf_cfg_list.size(); ++i) { - list[i] = srslte::make_mbsfn_sf_cfg(sib2->mbsfn_sf_cfg_list[i]); + list[i] = srsran::make_mbsfn_sf_cfg(sib2->mbsfn_sf_cfg_list[i]); } phy->set_config_mbsfn_sib2(&list[0], sib2->mbsfn_sf_cfg_list.size()); } // Apply PHY RR Config Common - srslte::phy_cfg_t& current_pcell = phy_ctrl->current_cell_config()[0]; + srsran::phy_cfg_t& current_pcell = phy_ctrl->current_cell_config()[0]; set_phy_cfg_t_common_pdsch(¤t_pcell, sib2->rr_cfg_common.pdsch_cfg_common); set_phy_cfg_t_common_pusch(¤t_pcell, sib2->rr_cfg_common.pusch_cfg_common); set_phy_cfg_t_common_pucch(¤t_pcell, sib2->rr_cfg_common.pucch_cfg_common); @@ -1430,7 +1430,7 @@ void rrc::handle_sib13() const sib_type13_r9_s* sib13 = meas_cells.serving_cell().sib13ptr(); - phy->set_config_mbsfn_sib13(srslte::make_sib13(*sib13)); + phy->set_config_mbsfn_sib13(srsran::make_sib13(*sib13)); add_mrb(0, 0); // Add MRB0 } @@ -1458,7 +1458,7 @@ void rrc::paging_completed(bool outcome) void rrc::process_pcch(unique_byte_buffer_t pdu) { - if (pdu->N_bytes <= 0 or pdu->N_bytes >= SRSLTE_MAX_BUFFER_SIZE_BITS) { + if (pdu->N_bytes <= 0 or pdu->N_bytes >= SRSRAN_MAX_BUFFER_SIZE_BITS) { logger.error(pdu->msg, pdu->N_bytes, "Dropping PCCH message with %d B", pdu->N_bytes); return; } @@ -1491,9 +1491,9 @@ void rrc::process_pcch(unique_byte_buffer_t pdu) callback_list.add_proc(pcch_processor); } -void rrc::write_pdu_mch(uint32_t lcid, srslte::unique_byte_buffer_t pdu) +void rrc::write_pdu_mch(uint32_t lcid, srsran::unique_byte_buffer_t pdu) { - if (pdu->N_bytes <= 0 or pdu->N_bytes >= SRSLTE_MAX_BUFFER_SIZE_BITS) { + if (pdu->N_bytes <= 0 or pdu->N_bytes >= SRSRAN_MAX_BUFFER_SIZE_BITS) { return; } // TODO: handle MCCH notifications and update MCCH @@ -1503,7 +1503,7 @@ void rrc::write_pdu_mch(uint32_t lcid, srslte::unique_byte_buffer_t pdu) parse_pdu_mch(lcid, std::move(pdu)); } -void rrc::parse_pdu_mch(uint32_t lcid, srslte::unique_byte_buffer_t pdu) +void rrc::parse_pdu_mch(uint32_t lcid, srsran::unique_byte_buffer_t pdu) { asn1::cbit_ref bref(pdu->msg, pdu->N_bytes); if (meas_cells.serving_cell().mcch.unpack(bref) != asn1::SRSASN_SUCCESS or @@ -1512,7 +1512,7 @@ void rrc::parse_pdu_mch(uint32_t lcid, srslte::unique_byte_buffer_t pdu) return; } meas_cells.serving_cell().has_mcch = true; - phy->set_config_mbsfn_mcch(srslte::make_mcch_msg(meas_cells.serving_cell().mcch)); + phy->set_config_mbsfn_mcch(srsran::make_mcch_msg(meas_cells.serving_cell().mcch)); log_rrc_message( "MCH", Rx, pdu.get(), meas_cells.serving_cell().mcch, meas_cells.serving_cell().mcch.msg.c1().type().to_string()); if (args.mbms_service_id >= 0) { @@ -1532,7 +1532,7 @@ void rrc::parse_pdu_mch(uint32_t lcid, srslte::unique_byte_buffer_t pdu) void rrc::send_ul_ccch_msg(const ul_ccch_msg_s& msg) { // Reset and reuse sdu buffer if provided - unique_byte_buffer_t pdcp_buf = srslte::make_byte_buffer(); + unique_byte_buffer_t pdcp_buf = srsran::make_byte_buffer(); if (not pdcp_buf.get()) { logger.error("Fatal Error: Couldn't allocate PDU in byte_align_and_pack()."); return; @@ -1564,7 +1564,7 @@ void rrc::send_ul_ccch_msg(const ul_ccch_msg_s& msg) void rrc::send_ul_dcch_msg(uint32_t lcid, const ul_dcch_msg_s& msg) { // Reset and reuse sdu buffer if provided - unique_byte_buffer_t pdcp_buf = srslte::make_byte_buffer(); + unique_byte_buffer_t pdcp_buf = srsran::make_byte_buffer(); if (not pdcp_buf.get()) { logger.error("Fatal Error: Couldn't allocate PDU in byte_align_and_pack()."); return; @@ -1581,7 +1581,7 @@ void rrc::send_ul_dcch_msg(uint32_t lcid, const ul_dcch_msg_s& msg) pdcp->write_sdu(lcid, std::move(pdcp_buf)); } -void rrc::write_sdu(srslte::unique_byte_buffer_t sdu) +void rrc::write_sdu(srsran::unique_byte_buffer_t sdu) { if (state == RRC_STATE_IDLE) { logger.warning("Received ULInformationTransfer SDU when in IDLE"); @@ -1595,7 +1595,7 @@ void rrc::write_pdu(uint32_t lcid, unique_byte_buffer_t pdu) process_pdu(lcid, std::move(pdu)); } -void rrc::process_pdu(uint32_t lcid, srslte::unique_byte_buffer_t pdu) +void rrc::process_pdu(uint32_t lcid, srsran::unique_byte_buffer_t pdu) { logger.debug("RX PDU, LCID: %d", lcid); switch (lcid) { @@ -1629,17 +1629,17 @@ void rrc::parse_dl_ccch(unique_byte_buffer_t pdu) // 5.3.3.8 rrc_conn_reject_r8_ies_s* reject_r8 = &c1->rrc_conn_reject().crit_exts.c1().rrc_conn_reject_r8(); logger.info("Received ConnectionReject. Wait time: %d", reject_r8->wait_time); - srslte::console("Received ConnectionReject. Wait time: %d\n", reject_r8->wait_time); + srsran::console("Received ConnectionReject. Wait time: %d\n", reject_r8->wait_time); t300.stop(); if (reject_r8->wait_time) { - nas->set_barring(srslte::barring_t::all); + nas->set_barring(srsran::barring_t::all); t302.set(reject_r8->wait_time * 1000, [this](uint32_t tid) { timer_expired(tid); }); t302.run(); } else { // Perform the actions upon expiry of T302 if wait time is zero - nas->set_barring(srslte::barring_t::none); + nas->set_barring(srsran::barring_t::none); start_go_idle(); } } break; @@ -1650,7 +1650,7 @@ void rrc::parse_dl_ccch(unique_byte_buffer_t pdu) break; } case dl_ccch_msg_type_c::c1_c_::types::rrc_conn_reest: { - srslte::console("Reestablishment OK\n"); + srsran::console("Reestablishment OK\n"); transaction_id = c1->rrc_conn_reest().rrc_transaction_id; rrc_conn_reest_s conn_reest_copy = c1->rrc_conn_reest(); task_sched.defer_task([this, conn_reest_copy]() { handle_con_reest(conn_reest_copy); }); @@ -1680,7 +1680,7 @@ void rrc::parse_dl_dcch(uint32_t lcid, unique_byte_buffer_t pdu) dl_dcch_msg_type_c::c1_c_* c1 = &dl_dcch_msg.msg.c1(); switch (dl_dcch_msg.msg.c1().type().value) { case dl_dcch_msg_type_c::c1_c_::types::dl_info_transfer: - pdu = srslte::make_byte_buffer(); + pdu = srsran::make_byte_buffer(); if (!pdu.get()) { logger.error("Fatal error: out of buffers in pool"); return; @@ -1783,30 +1783,30 @@ void rrc::handle_ue_capability_enquiry(const ue_cap_enquiry_s& enquiry) info->ue_cap_rat_container_list[0].rat_type = rat_type_e::eutra; // Check UE config arguments bounds - if (args.release < SRSLTE_RELEASE_MIN || args.release > SRSLTE_RELEASE_MAX) { - uint32_t new_release = SRSLTE_MIN(SRSLTE_RELEASE_MAX, SRSLTE_MAX(SRSLTE_RELEASE_MIN, args.release)); + if (args.release < SRSRAN_RELEASE_MIN || args.release > SRSRAN_RELEASE_MAX) { + uint32_t new_release = SRSRAN_MIN(SRSRAN_RELEASE_MAX, SRSRAN_MAX(SRSRAN_RELEASE_MIN, args.release)); logger.error("Release is %d. It is out of bounds (%d ... %d), setting it to %d", args.release, - SRSLTE_RELEASE_MIN, - SRSLTE_RELEASE_MAX, + SRSRAN_RELEASE_MIN, + SRSRAN_RELEASE_MAX, new_release); args.release = new_release; } args.ue_category = (uint32_t)strtol(args.ue_category_str.c_str(), nullptr, 10); - if (args.ue_category < SRSLTE_UE_CATEGORY_MIN || args.ue_category > SRSLTE_UE_CATEGORY_MAX) { + if (args.ue_category < SRSRAN_UE_CATEGORY_MIN || args.ue_category > SRSRAN_UE_CATEGORY_MAX) { uint32_t new_category = - SRSLTE_MIN(SRSLTE_UE_CATEGORY_MAX, SRSLTE_MAX(SRSLTE_UE_CATEGORY_MIN, args.ue_category)); + SRSRAN_MIN(SRSRAN_UE_CATEGORY_MAX, SRSRAN_MAX(SRSRAN_UE_CATEGORY_MIN, args.ue_category)); logger.error("UE Category is %d. It is out of bounds (%d ... %d), setting it to %d", args.ue_category, - SRSLTE_UE_CATEGORY_MIN, - SRSLTE_UE_CATEGORY_MAX, + SRSRAN_UE_CATEGORY_MIN, + SRSRAN_UE_CATEGORY_MAX, new_category); args.ue_category = new_category; } ue_eutra_cap_s cap; - cap.access_stratum_release = (access_stratum_release_e::options)(args.release - SRSLTE_RELEASE_MIN); + cap.access_stratum_release = (access_stratum_release_e::options)(args.release - SRSRAN_RELEASE_MIN); cap.ue_category = (uint8_t)((args.ue_category < 1 || args.ue_category > 5) ? 4 : args.ue_category); cap.pdcp_params.max_num_rohc_context_sessions_present = false; cap.pdcp_params.supported_rohc_profiles.profile0x0001_r15 = false; @@ -2118,7 +2118,7 @@ void rrc::log_rr_config_common() current_mac_cfg.rach_cfg.responseWindowSize, current_mac_cfg.rach_cfg.contentionResolutionTimer); - const srslte::phy_cfg_t& current_pcell = phy_ctrl->current_cell_config()[0]; + const srsran::phy_cfg_t& current_pcell = phy_ctrl->current_cell_config()[0]; logger.info("Set PUSCH ConfigCommon: P0_pusch=%f, DMRS cs=%d, delta_ss=%d, N_sb=%d", current_pcell.ul_cfg.power_ctrl.p0_ue_pusch, current_pcell.ul_cfg.dmrs.cyclic_shift, @@ -2154,7 +2154,7 @@ void rrc::apply_rr_config_common(rr_cfg_common_s* config, bool send_lower_layers set_mac_cfg_t_rach_cfg_common(¤t_mac_cfg, config->rach_cfg_common); } - srslte::phy_cfg_t& current_pcell = phy_ctrl->current_cell_config()[0]; + srsran::phy_cfg_t& current_pcell = phy_ctrl->current_cell_config()[0]; if (config->prach_cfg.prach_cfg_info_present) { set_phy_cfg_t_common_prach(¤t_pcell, &config->prach_cfg.prach_cfg_info, config->prach_cfg.root_seq_idx); } else { @@ -2193,7 +2193,7 @@ void rrc::apply_rr_config_common(rr_cfg_common_s* config, bool send_lower_layers void rrc::log_phy_config_dedicated() { - srslte::phy_cfg_t& current_pcell = phy_ctrl->current_cell_config()[0]; + srsran::phy_cfg_t& current_pcell = phy_ctrl->current_cell_config()[0]; if (current_pcell.dl_cfg.cqi_report.periodic_configured) { logger.info("Set cqi-PUCCH-ResourceIndex=%d, cqi-pmi-ConfigIndex=%d, cqi-FormatIndicatorPeriodic=%d", current_pcell.ul_cfg.pucch.n_pucch_2, @@ -2235,7 +2235,7 @@ void rrc::apply_phy_config_dedicated(const phys_cfg_ded_s& phy_cnfg, bool is_han { logger.info("Applying PHY config dedicated"); - srslte::phy_cfg_t& current_pcell = phy_ctrl->current_cell_config()[0]; + srsran::phy_cfg_t& current_pcell = phy_ctrl->current_cell_config()[0]; set_phy_cfg_t_dedicated_cfg(¤t_pcell, phy_cnfg); if (is_handover) { current_pcell.ul_cfg.pucch.sr_configured = false; @@ -2250,7 +2250,7 @@ void rrc::apply_phy_config_dedicated(const phys_cfg_ded_s& phy_cnfg, bool is_han void rrc::apply_phy_scell_config(const scell_to_add_mod_r10_s& scell_config, bool enable_cqi) { - srslte_cell_t scell = {}; + srsran_cell_t scell = {}; uint32_t earfcn = 0; if (phy == nullptr) { @@ -2273,33 +2273,33 @@ void rrc::apply_phy_scell_config(const scell_to_add_mod_r10_s& scell_config, boo if (scell_config.rr_cfg_common_scell_r10_present) { const rr_cfg_common_scell_r10_s* rr_cfg = &scell_config.rr_cfg_common_scell_r10; auto non_ul_cfg = &rr_cfg->non_ul_cfg_r10; - scell.frame_type = (rr_cfg->tdd_cfg_v1130.is_present()) ? SRSLTE_TDD : SRSLTE_FDD; + scell.frame_type = (rr_cfg->tdd_cfg_v1130.is_present()) ? SRSRAN_TDD : SRSRAN_FDD; scell.nof_prb = non_ul_cfg->dl_bw_r10.to_number(); scell.nof_ports = non_ul_cfg->ant_info_common_r10.ant_ports_count.to_number(); scell.phich_length = (non_ul_cfg->phich_cfg_r10.phich_dur.value == phich_cfg_s::phich_dur_opts::normal) - ? SRSLTE_PHICH_NORM - : SRSLTE_PHICH_EXT; + ? SRSRAN_PHICH_NORM + : SRSRAN_PHICH_EXT; // Avoid direct conversion between different phich resource enum switch (non_ul_cfg->phich_cfg_r10.phich_res.value) { case phich_cfg_s::phich_res_opts::one_sixth: - scell.phich_resources = SRSLTE_PHICH_R_1_6; + scell.phich_resources = SRSRAN_PHICH_R_1_6; break; case phich_cfg_s::phich_res_opts::half: - scell.phich_resources = SRSLTE_PHICH_R_1_2; + scell.phich_resources = SRSRAN_PHICH_R_1_2; break; case phich_cfg_s::phich_res_opts::one: - scell.phich_resources = SRSLTE_PHICH_R_1; + scell.phich_resources = SRSRAN_PHICH_R_1; break; case phich_cfg_s::phich_res_opts::two: case phich_cfg_s::phich_res_opts::nulltype: - scell.phich_resources = SRSLTE_PHICH_R_2; + scell.phich_resources = SRSRAN_PHICH_R_2; break; } } // Initialize scell config with pcell cfg - srslte::phy_cfg_t scell_cfg = phy_ctrl->current_cell_config()[0]; + srsran::phy_cfg_t scell_cfg = phy_ctrl->current_cell_config()[0]; set_phy_cfg_t_scell_config(&scell_cfg, scell_config); if (not enable_cqi) { @@ -2511,12 +2511,12 @@ void rrc::handle_con_setup(const rrc_conn_setup_s& setup) state = RRC_STATE_CONNECTED; t300.stop(); t302.stop(); - srslte::console("RRC Connected\n"); + srsran::console("RRC Connected\n"); // Apply the Radio Resource configuration apply_rr_config_dedicated(&setup.crit_exts.c1().rrc_conn_setup_r8().rr_cfg_ded); - nas->set_barring(srslte::barring_t::none); + nas->set_barring(srsran::barring_t::none); if (dedicated_info_nas.get()) { send_con_setup_complete(std::move(dedicated_info_nas)); @@ -2724,7 +2724,7 @@ const std::string rrc::rb_id_str[] = asn1::rrc::ue_cap_rat_container_s rrc::get_eutra_nr_capabilities() { - srslte::byte_buffer_t caps_buf; + srsran::byte_buffer_t caps_buf; asn1::rrc::ue_cap_rat_container_s cap; rrc_nr->get_eutra_nr_capabilities(&caps_buf); cap.rat_type = asn1::rrc::rat_type_e::eutra_nr; @@ -2735,7 +2735,7 @@ asn1::rrc::ue_cap_rat_container_s rrc::get_eutra_nr_capabilities() asn1::rrc::ue_cap_rat_container_s rrc::get_nr_capabilities() { - srslte::byte_buffer_t caps_buf; + srsran::byte_buffer_t caps_buf; asn1::rrc::ue_cap_rat_container_s cap; rrc_nr->get_nr_capabilities(&caps_buf); cap.rat_type = asn1::rrc::rat_type_e::nr; diff --git a/srsue/src/stack/rrc/rrc_cell.cc b/srsue/src/stack/rrc/rrc_cell.cc index b525e3759..ef6363eea 100644 --- a/srsue/src/stack/rrc/rrc_cell.cc +++ b/srsue/src/stack/rrc/rrc_cell.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -14,20 +14,20 @@ namespace srsue { -meas_cell::meas_cell(srslte::unique_timer timer_) : timer(std::move(timer_)) +meas_cell::meas_cell(srsran::unique_timer timer_) : timer(std::move(timer_)) { timer.set(neighbour_timeout_ms); timer.run(); } -meas_cell::meas_cell(const phy_cell_t& phy_cell_, srslte::unique_timer timer) : meas_cell(std::move(timer)) +meas_cell::meas_cell(const phy_cell_t& phy_cell_, srsran::unique_timer timer) : meas_cell(std::move(timer)) { phy_cell = phy_cell_; } -srslte::plmn_id_t meas_cell_eutra::get_plmn(uint32_t idx) const +srsran::plmn_id_t meas_cell_eutra::get_plmn(uint32_t idx) const { if (idx < sib1.cell_access_related_info.plmn_id_list.size() && has_valid_sib1) { - return srslte::make_plmn_id_t(sib1.cell_access_related_info.plmn_id_list[idx].plmn_id); + return srsran::make_plmn_id_t(sib1.cell_access_related_info.plmn_id_list[idx].plmn_id); } else { return {}; } @@ -67,7 +67,7 @@ bool meas_cell::is_sib_scheduled(uint32_t sib_index) const return sib_info_map.find(sib_index) != sib_info_map.end(); } -bool meas_cell::has_sibs(srslte::span indexes) const +bool meas_cell::has_sibs(srsran::span indexes) const { for (uint32_t idx : indexes) { if (not has_sib(idx)) { @@ -139,7 +139,7 @@ uint16_t meas_cell_eutra::get_mcc() const uint16_t mcc; if (has_valid_sib1) { if (sib1.cell_access_related_info.plmn_id_list.size() > 0) { - if (srslte::bytes_to_mcc(&sib1.cell_access_related_info.plmn_id_list[0].plmn_id.mcc[0], &mcc)) { + if (srsran::bytes_to_mcc(&sib1.cell_access_related_info.plmn_id_list[0].plmn_id.mcc[0], &mcc)) { return mcc; } } @@ -152,7 +152,7 @@ uint16_t meas_cell_eutra::get_mnc() const uint16_t mnc; if (has_valid_sib1) { if (sib1.cell_access_related_info.plmn_id_list.size() > 0) { - if (srslte::bytes_to_mnc(&sib1.cell_access_related_info.plmn_id_list[0].plmn_id.mnc[0], + if (srsran::bytes_to_mnc(&sib1.cell_access_related_info.plmn_id_list[0].plmn_id.mnc[0], &mnc, sib1.cell_access_related_info.plmn_id_list[0].plmn_id.mnc.size())) { return mnc; @@ -166,7 +166,7 @@ uint16_t meas_cell_eutra::get_mnc() const * Neighbour Cell List ********************************************/ template -meas_cell_list::meas_cell_list(srslte::task_sched_handle task_sched_) : +meas_cell_list::meas_cell_list(srsran::task_sched_handle task_sched_) : serv_cell(new T(task_sched_.get_unique_timer())), task_sched(task_sched_) {} @@ -360,14 +360,14 @@ int meas_cell_list::set_serving_cell(phy_cell_t phy_cell, bool discard_servin { // don't update neighbor cell list unless serving cell changes if (phy_cell.pci == serving_cell().get_pci() && phy_cell.earfcn == serving_cell().get_earfcn()) { - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Remove future serving cell from neighbours to make space for current serving cell unique_meas_cell new_serving_cell = remove_neighbour_cell(phy_cell.earfcn, phy_cell.pci); if (new_serving_cell == nullptr) { logger.error("Setting serving cell: Unknown cell with earfcn=%d, PCI=%d", phy_cell.earfcn, phy_cell.pci); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Set new serving cell @@ -381,7 +381,7 @@ int meas_cell_list::set_serving_cell(phy_cell_t phy_cell, bool discard_servin logger.info("Serving cell not added to list of neighbours. Worse than current neighbours"); } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } template diff --git a/srsue/src/stack/rrc/rrc_meas.cc b/srsue/src/stack/rrc/rrc_meas.cc index 39eb07b11..ce06d2299 100644 --- a/srsue/src/stack/rrc/rrc_meas.cc +++ b/srsue/src/stack/rrc/rrc_meas.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,9 +11,9 @@ */ #include "srsue/hdr/stack/rrc/rrc_meas.h" -#include "srslte/asn1/rrc/dl_dcch_msg.h" -#include "srslte/interfaces/ue_phy_interfaces.h" -#include "srslte/rrc/rrc_cfg_utils.h" +#include "srsran/asn1/rrc/dl_dcch_msg.h" +#include "srsran/interfaces/ue_phy_interfaces.h" +#include "srsran/rrc/rrc_cfg_utils.h" #include "srsue/hdr/stack/rrc/rrc.h" /************************************************************************ @@ -23,7 +23,7 @@ * * ************************************************************************/ -using namespace srslte; +using namespace srsran; using namespace asn1::rrc; namespace srsue { @@ -31,7 +31,7 @@ namespace srsue { meas_obj_to_add_mod_s* find_meas_obj_map(std::map& l, uint32_t earfcn) { auto same_earfcn = [earfcn](const std::pair& c) { - return (int)earfcn == srslte::get_carrier_freq(c.second); + return (int)earfcn == srsran::get_carrier_freq(c.second); }; auto it = std::find_if(l.begin(), l.end(), same_earfcn); if (it == l.end()) { @@ -59,14 +59,14 @@ void rrc::rrc_meas::reset() float rrc::rrc_meas::rsrp_filter(const float new_value, const float avg_value) { phy_quant_t f = meas_cfg.get_filter_a(); - return std::isnormal(avg_value) ? SRSLTE_VEC_EMA(new_value, avg_value, f.rsrp) : new_value; + return std::isnormal(avg_value) ? SRSRAN_VEC_EMA(new_value, avg_value, f.rsrp) : new_value; } // Perform Layer 3 filtering 5.5.3.2 float rrc::rrc_meas::rsrq_filter(const float new_value, const float avg_value) { phy_quant_t f = meas_cfg.get_filter_a(); - return std::isnormal(avg_value) ? SRSLTE_VEC_EMA(new_value, avg_value, f.rsrq) : new_value; + return std::isnormal(avg_value) ? SRSRAN_VEC_EMA(new_value, avg_value, f.rsrq) : new_value; } /* Instruct PHY to start measurement on every configured frequency */ diff --git a/srsue/src/stack/rrc/rrc_nr.cc b/srsue/src/stack/rrc/rrc_nr.cc index c7166494c..f54508d43 100644 --- a/srsue/src/stack/rrc/rrc_nr.cc +++ b/srsue/src/stack/rrc/rrc_nr.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,10 +11,10 @@ */ #include "srsue/hdr/stack/rrc/rrc_nr.h" -#include "srslte/common/security.h" -#include "srslte/common/standard_streams.h" -#include "srslte/interfaces/ue_pdcp_interfaces.h" -#include "srslte/interfaces/ue_rlc_interfaces.h" +#include "srsran/common/security.h" +#include "srsran/common/standard_streams.h" +#include "srsran/interfaces/ue_pdcp_interfaces.h" +#include "srsran/interfaces/ue_rlc_interfaces.h" #include "srsue/hdr/stack/upper/usim.h" #define Error(fmt, ...) rrc_ptr->logger.error("Proc \"%s\" - " fmt, name(), ##__VA_ARGS__) @@ -24,12 +24,12 @@ using namespace asn1::rrc_nr; using namespace asn1; -using namespace srslte; +using namespace srsran; namespace srsue { const char* rrc_nr::rrc_nr_state_text[] = {"IDLE", "CONNECTED", "CONNECTED-INACTIVE"}; -rrc_nr::rrc_nr(srslte::task_sched_handle task_sched_) : +rrc_nr::rrc_nr(srsran::task_sched_handle task_sched_) : logger(srslog::fetch_basic_logger("RRC")), task_sched(task_sched_), conn_recfg_proc(this) {} @@ -42,7 +42,7 @@ void rrc_nr::init(phy_interface_rrc_nr* phy_, gw_interface_rrc* gw_, rrc_eutra_interface_rrc_nr* rrc_eutra_, usim_interface_rrc_nr* usim_, - srslte::timer_handler* timers_, + srsran::timer_handler* timers_, stack_interface_rrc* stack_, const rrc_nr_args_t& args_) { @@ -69,16 +69,16 @@ void rrc_nr::stop() void rrc_nr::init_core_less() { logger.info("Creating dummy DRB on LCID=%d", args.coreless.drb_lcid); - srslte::rlc_config_t rlc_cnfg = srslte::rlc_config_t::default_rlc_um_nr_config(6); + srsran::rlc_config_t rlc_cnfg = srsran::rlc_config_t::default_rlc_um_nr_config(6); rlc->add_bearer(args.coreless.drb_lcid, rlc_cnfg); - srslte::pdcp_config_t pdcp_cnfg{args.coreless.drb_lcid, - srslte::PDCP_RB_IS_DRB, - srslte::SECURITY_DIRECTION_DOWNLINK, - srslte::SECURITY_DIRECTION_UPLINK, - srslte::PDCP_SN_LEN_18, - srslte::pdcp_t_reordering_t::ms500, - srslte::pdcp_discard_timer_t::ms100, + srsran::pdcp_config_t pdcp_cnfg{args.coreless.drb_lcid, + srsran::PDCP_RB_IS_DRB, + srsran::SECURITY_DIRECTION_DOWNLINK, + srsran::SECURITY_DIRECTION_UPLINK, + srsran::PDCP_SN_LEN_18, + srsran::pdcp_t_reordering_t::ms500, + srsran::pdcp_discard_timer_t::ms100, false}; pdcp->add_bearer(args.coreless.drb_lcid, pdcp_cnfg); @@ -109,12 +109,12 @@ void rrc_nr::timer_expired(uint32_t timeout_id) } } -void rrc_nr::srslte_rrc_log(const char* str) {} +void rrc_nr::srsran_rrc_log(const char* str) {} template void rrc_nr::log_rrc_message(const std::string& source, direction_t dir, - const srslte::byte_buffer_t* pdu, + const srsran::byte_buffer_t* pdu, const T& msg, const std::string& msg_type) { @@ -189,13 +189,13 @@ void rrc_nr::out_of_sync() {} void rrc_nr::run_tti(uint32_t tti) {} // PDCP interface -void rrc_nr::write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t pdu) {} -void rrc_nr::write_pdu_bcch_bch(srslte::unique_byte_buffer_t pdu) {} -void rrc_nr::write_pdu_bcch_dlsch(srslte::unique_byte_buffer_t pdu) {} -void rrc_nr::write_pdu_pcch(srslte::unique_byte_buffer_t pdu) {} -void rrc_nr::write_pdu_mch(uint32_t lcid, srslte::unique_byte_buffer_t pdu) {} +void rrc_nr::write_pdu(uint32_t lcid, srsran::unique_byte_buffer_t pdu) {} +void rrc_nr::write_pdu_bcch_bch(srsran::unique_byte_buffer_t pdu) {} +void rrc_nr::write_pdu_bcch_dlsch(srsran::unique_byte_buffer_t pdu) {} +void rrc_nr::write_pdu_pcch(srsran::unique_byte_buffer_t pdu) {} +void rrc_nr::write_pdu_mch(uint32_t lcid, srsran::unique_byte_buffer_t pdu) {} -void rrc_nr::get_eutra_nr_capabilities(srslte::byte_buffer_t* eutra_nr_caps_pdu) +void rrc_nr::get_eutra_nr_capabilities(srsran::byte_buffer_t* eutra_nr_caps_pdu) { struct ue_mrdc_cap_s mrdc_cap; @@ -396,7 +396,7 @@ bool rrc_nr::rrc_reconfiguration(bool endc_release_and_add_r15, return true; } -void rrc_nr::get_nr_capabilities(srslte::byte_buffer_t* nr_caps_pdu) +void rrc_nr::get_nr_capabilities(srsran::byte_buffer_t* nr_caps_pdu) { struct ue_nr_cap_s nr_cap; @@ -491,7 +491,7 @@ bool rrc_nr::apply_rlc_add_mod(const rlc_bearer_cfg_s& rlc_bearer_cfg) } if (rlc_bearer_cfg.rlc_cfg_present == true) { - rlc_cfg = srslte::make_rlc_config_t(rlc_bearer_cfg.rlc_cfg); + rlc_cfg = srsran::make_rlc_config_t(rlc_bearer_cfg.rlc_cfg); if (rlc_bearer_cfg.rlc_cfg.type() == asn1::rrc_nr::rlc_cfg_c::types::um_bi_dir) { if (rlc_bearer_cfg.rlc_cfg.um_bi_dir().dl_um_rlc.sn_field_len_present && rlc_bearer_cfg.rlc_cfg.um_bi_dir().ul_um_rlc.sn_field_len_present && @@ -512,7 +512,7 @@ bool rrc_nr::apply_rlc_add_mod(const rlc_bearer_cfg_s& rlc_bearer_cfg) if (rlc_bearer_cfg.mac_lc_ch_cfg_present == true && rlc_bearer_cfg.mac_lc_ch_cfg.ul_specific_params_present) { logical_channel_config_t logical_channel_cfg; - logical_channel_cfg = srslte::make_mac_logical_channel_cfg_t(lc_ch_id, rlc_bearer_cfg.mac_lc_ch_cfg); + logical_channel_cfg = srsran::make_mac_logical_channel_cfg_t(lc_ch_id, rlc_bearer_cfg.mac_lc_ch_cfg); mac->setup_lcid(logical_channel_cfg); } return true; @@ -537,7 +537,7 @@ bool rrc_nr::apply_mac_cell_group(const mac_cell_group_cfg_s& mac_cell_group_cfg if (mac_cell_group_cfg.bsr_cfg_present) { logger.debug("Handling MAC BSR config"); - srslte::bsr_cfg_t bsr_cfg; + srsran::bsr_cfg_t bsr_cfg; bsr_cfg.periodic_timer = mac_cell_group_cfg.bsr_cfg.periodic_bsr_timer.to_number(); bsr_cfg.retx_timer = mac_cell_group_cfg.bsr_cfg.retx_bsr_timer.to_number(); mac->set_config(bsr_cfg); @@ -631,7 +631,7 @@ bool rrc_nr::apply_drb_add_mod(const drb_to_add_mod_s& drb_cfg) drb_cfg.pdcp_cfg.drb.pdcp_sn_size_dl.to_number()); } - srslte::pdcp_config_t pdcp_cfg = make_drb_pdcp_config_t(drb_cfg.drb_id, true, drb_cfg.pdcp_cfg); + srsran::pdcp_config_t pdcp_cfg = make_drb_pdcp_config_t(drb_cfg.drb_id, true, drb_cfg.pdcp_cfg); pdcp->add_bearer(lcid, pdcp_cfg); gw->update_lcid(eps_bearer_id, lcid); return true; @@ -756,11 +756,11 @@ proc_outcome_t rrc_nr::connection_reconf_no_ho_proc::react(const bool& config_co return proc_outcome_t::success; } -void rrc_nr::connection_reconf_no_ho_proc::then(const srslte::proc_state_t& result) +void rrc_nr::connection_reconf_no_ho_proc::then(const srsran::proc_state_t& result) { if (result.is_success()) { Info("Finished %s successfully", name()); - srslte::console("RRC NR reconfiguration successful.\n"); + srsran::console("RRC NR reconfiguration successful.\n"); return; } diff --git a/srsue/src/stack/rrc/rrc_procedures.cc b/srsue/src/stack/rrc/rrc_procedures.cc index 2030ec600..6bb796f15 100644 --- a/srsue/src/stack/rrc/rrc_procedures.cc +++ b/srsue/src/stack/rrc/rrc_procedures.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,12 +11,12 @@ */ #include "srsue/hdr/stack/rrc/rrc_procedures.h" -#include "srslte/common/security.h" -#include "srslte/common/standard_streams.h" -#include "srslte/common/tti_point.h" -#include "srslte/interfaces/ue_pdcp_interfaces.h" -#include "srslte/interfaces/ue_rlc_interfaces.h" -#include "srslte/interfaces/ue_usim_interfaces.h" +#include "srsran/common/security.h" +#include "srsran/common/standard_streams.h" +#include "srsran/common/tti_point.h" +#include "srsran/interfaces/ue_pdcp_interfaces.h" +#include "srsran/interfaces/ue_rlc_interfaces.h" +#include "srsran/interfaces/ue_usim_interfaces.h" #include "srsue/hdr/stack/rrc/rrc_meas.h" #include // for printing uint64_t @@ -27,8 +27,8 @@ namespace srsue { -using srslte::proc_outcome_t; -using srslte::tti_point; +using srsran::proc_outcome_t; +using srsran::tti_point; /************************************** * Cell Search Procedure @@ -285,7 +285,7 @@ proc_outcome_t rrc::si_acquire_proc::init(uint32_t sib_index_) return proc_outcome_t::yield; } -void rrc::si_acquire_proc::then(const srslte::proc_state_t& result) +void rrc::si_acquire_proc::then(const srsran::proc_state_t& result) { // make sure timers are stopped si_acq_retry_timer.stop(); @@ -389,7 +389,7 @@ proc_outcome_t rrc::serving_cell_config_proc::init(const std::vector& return launch_sib_acquire(); } -srslte::proc_outcome_t rrc::serving_cell_config_proc::launch_sib_acquire() +srsran::proc_outcome_t rrc::serving_cell_config_proc::launch_sib_acquire() { // Obtain the SIBs if not available or apply the configuration if available for (; req_idx < required_sibs.size(); req_idx++) { @@ -600,7 +600,7 @@ proc_outcome_t rrc::cell_selection_proc::react(const bool& cell_selection_result return start_next_cell_selection(); } -srslte::proc_outcome_t rrc::cell_selection_proc::start_phy_cell_selection(const meas_cell_eutra& cell) +srsran::proc_outcome_t rrc::cell_selection_proc::start_phy_cell_selection(const meas_cell_eutra& cell) { if (not is_same_cell(cell, meas_cells->serving_cell())) { rrc_ptr->set_serving_cell(cell.phy_cell, discard_serving); @@ -624,7 +624,7 @@ srslte::proc_outcome_t rrc::cell_selection_proc::start_phy_cell_selection(const return proc_outcome_t::yield; } -srslte::proc_outcome_t rrc::cell_selection_proc::start_sib_acquisition() +srsran::proc_outcome_t rrc::cell_selection_proc::start_sib_acquisition() { Info("PHY is camping on serving cell, but SIBs need to be acquired"); state = search_state_t::cell_config; @@ -677,7 +677,7 @@ proc_outcome_t rrc::cell_selection_proc::step() return proc_outcome_t::error; } -void rrc::cell_selection_proc::then(const srslte::proc_result_t& proc_result) const +void rrc::cell_selection_proc::then(const srsran::proc_result_t& proc_result) const { Info("Completed with %s.", proc_result.is_success() ? "success" : "failure"); // Inform Connection Request Procedure @@ -757,7 +757,7 @@ proc_outcome_t rrc::plmn_search_proc::step() return step(); } -void rrc::plmn_search_proc::then(const srslte::proc_state_t& result) const +void rrc::plmn_search_proc::then(const srsran::proc_state_t& result) const { // on cleanup, call plmn_search_completed if (result.is_success()) { @@ -777,8 +777,8 @@ rrc::connection_request_proc::connection_request_proc(rrc* parent_) : rrc_ptr(parent_), logger(srslog::fetch_basic_logger("RRC")) {} -proc_outcome_t rrc::connection_request_proc::init(srslte::establishment_cause_t cause_, - srslte::unique_byte_buffer_t dedicated_info_nas_) +proc_outcome_t rrc::connection_request_proc::init(srsran::establishment_cause_t cause_, + srsran::unique_byte_buffer_t dedicated_info_nas_) { cause = cause_; dedicated_info_nas = std::move(dedicated_info_nas_); @@ -795,7 +795,7 @@ proc_outcome_t rrc::connection_request_proc::init(srslte::establishment_cause_t if (rrc_ptr->t302.is_running()) { Info("Requested RRC connection establishment while T302 is running"); - rrc_ptr->nas->set_barring(srslte::barring_t::mo_data); + rrc_ptr->nas->set_barring(srsran::barring_t::mo_data); return proc_outcome_t::error; } @@ -879,7 +879,7 @@ proc_outcome_t rrc::connection_request_proc::step() return proc_outcome_t::error; } -void rrc::connection_request_proc::then(const srslte::proc_state_t& result) +void rrc::connection_request_proc::then(const srsran::proc_state_t& result) { if (result.is_error()) { logger.warning("Could not establish connection. Deallocating dedicatedInfoNAS PDU"); @@ -891,7 +891,7 @@ void rrc::connection_request_proc::then(const srslte::proc_state_t& result) rrc_ptr->nas->connection_request_completed(result.is_success()); } -srslte::proc_outcome_t rrc::connection_request_proc::react(const cell_selection_proc::cell_selection_complete_ev& e) +srsran::proc_outcome_t rrc::connection_request_proc::react(const cell_selection_proc::cell_selection_complete_ev& e) { if (state != state_t::cell_selection) { // ignore if we are not expecting an cell selection result @@ -939,14 +939,14 @@ srslte::proc_outcome_t rrc::connection_request_proc::react(const cell_selection_ // Handle RRC Reconfiguration without MobilityInformation Section 5.3.5.3 rrc::connection_reconf_no_ho_proc::connection_reconf_no_ho_proc(srsue::rrc* parent_) : rrc_ptr(parent_) {} -srslte::proc_outcome_t rrc::connection_reconf_no_ho_proc::init(const asn1::rrc::rrc_conn_recfg_s& recfg_) +srsran::proc_outcome_t rrc::connection_reconf_no_ho_proc::init(const asn1::rrc::rrc_conn_recfg_s& recfg_) { Info("Starting..."); rx_recfg = recfg_.crit_exts.c1().rrc_conn_recfg_r8(); // If first message after reestablishment, resume SRB2 and all DRB if (rrc_ptr->reestablishment_successful) { - for (int i = 2; i < SRSLTE_N_RADIO_BEARERS; i++) { + for (int i = 2; i < SRSRAN_N_RADIO_BEARERS; i++) { if (rrc_ptr->rlc->has_bearer(i)) { rrc_ptr->rlc->resume_bearer(i); } @@ -957,7 +957,7 @@ srslte::proc_outcome_t rrc::connection_reconf_no_ho_proc::init(const asn1::rrc:: if (rrc_ptr->reestablishment_successful) { // Reestablish PDCP and RLC for SRB2 and all DRB // TODO: Which is the maximum LCID? - for (int i = 2; i < SRSLTE_N_RADIO_BEARERS; i++) { + for (int i = 2; i < SRSRAN_N_RADIO_BEARERS; i++) { if (rrc_ptr->rlc->has_bearer(i)) { rrc_ptr->rlc->reestablish(i); rrc_ptr->pdcp->reestablish(i); @@ -975,7 +975,7 @@ srslte::proc_outcome_t rrc::connection_reconf_no_ho_proc::init(const asn1::rrc:: if (rrc_ptr->reestablishment_successful) { // Send status report if necessary. rrc_ptr->reestablishment_successful = false; - for (int i = 2; i < SRSLTE_N_RADIO_BEARERS; i++) { + for (int i = 2; i < SRSRAN_N_RADIO_BEARERS; i++) { if (rrc_ptr->rlc->has_bearer(i)) { rrc_ptr->pdcp->send_status_report(i); } @@ -1007,7 +1007,7 @@ srslte::proc_outcome_t rrc::connection_reconf_no_ho_proc::init(const asn1::rrc:: return proc_outcome_t::yield; } -srslte::proc_outcome_t rrc::connection_reconf_no_ho_proc::react(const bool& config_complete) +srsran::proc_outcome_t rrc::connection_reconf_no_ho_proc::react(const bool& config_complete) { if (not config_complete) { rrc_ptr->logger.error("Failed to config PHY"); @@ -1030,9 +1030,9 @@ srslte::proc_outcome_t rrc::connection_reconf_no_ho_proc::react(const bool& conf rrc_ptr->send_rrc_con_reconfig_complete(); } - srslte::unique_byte_buffer_t nas_pdu; + srsran::unique_byte_buffer_t nas_pdu; for (auto& pdu : rx_recfg.ded_info_nas_list) { - nas_pdu = srslte::make_byte_buffer(); + nas_pdu = srsran::make_byte_buffer(); if (nas_pdu.get()) { memcpy(nas_pdu->msg, pdu.data(), pdu.size()); nas_pdu->N_bytes = pdu.size(); @@ -1046,7 +1046,7 @@ srslte::proc_outcome_t rrc::connection_reconf_no_ho_proc::react(const bool& conf return proc_outcome_t::success; } -void rrc::connection_reconf_no_ho_proc::then(const srslte::proc_state_t& result) +void rrc::connection_reconf_no_ho_proc::then(const srsran::proc_state_t& result) { // Reset 5G NR reconfig variable has_5g_nr_reconfig = false; @@ -1083,7 +1083,7 @@ proc_outcome_t rrc::process_pcch_proc::step() { if (state == state_t::next_record) { for (; paging_idx < paging.paging_record_list.size(); ++paging_idx) { - srslte::s_tmsi_t s_tmsi_paged = srslte::make_s_tmsi_t(paging.paging_record_list[paging_idx].ue_id.s_tmsi()); + srsran::s_tmsi_t s_tmsi_paged = srsran::make_s_tmsi_t(paging.paging_record_list[paging_idx].ue_id.s_tmsi()); Info("Received paging (%d/%d) for UE %" PRIu64 ":%" PRIu64 "", paging_idx + 1, paging.paging_record_list.size(), @@ -1092,7 +1092,7 @@ proc_outcome_t rrc::process_pcch_proc::step() if (rrc_ptr->ue_identity == s_tmsi_paged) { if (RRC_STATE_IDLE == rrc_ptr->state) { Info("S-TMSI match in paging message"); - srslte::console("S-TMSI match in paging message\n"); + srsran::console("S-TMSI match in paging message\n"); if (not rrc_ptr->nas->paging(&s_tmsi_paged)) { Error("Unable to start NAS paging proc"); return proc_outcome_t::error; @@ -1174,7 +1174,7 @@ proc_outcome_t rrc::go_idle_proc::init() return proc_outcome_t::yield; } -srslte::proc_outcome_t rrc::go_idle_proc::react(bool timeout) +srsran::proc_outcome_t rrc::go_idle_proc::react(bool timeout) { rrc_ptr->leave_connected(); Info("Left connected state"); @@ -1200,7 +1200,7 @@ proc_outcome_t rrc::go_idle_proc::step() return proc_outcome_t::yield; } -void rrc::go_idle_proc::then(const srslte::proc_state_t& result) +void rrc::go_idle_proc::then(const srsran::proc_state_t& result) { if (rrc_ptr->nas->is_registered() and not rrc_ptr->cell_reselector.launch()) { rrc_ptr->logger.error("Failed to initiate a Cell Reselection procedure..."); @@ -1240,11 +1240,11 @@ proc_outcome_t rrc::cell_reselection_proc::init() proc_outcome_t rrc::cell_reselection_proc::step() { if (rrc_ptr->cell_selector.run()) { - return srslte::proc_outcome_t::yield; + return srsran::proc_outcome_t::yield; } if (cell_selection_fut.is_error()) { Error("Error while selecting a cell"); - return srslte::proc_outcome_t::error; + return srsran::proc_outcome_t::error; } cell_sel_result = *cell_selection_fut.value(); @@ -1266,10 +1266,10 @@ proc_outcome_t rrc::cell_reselection_proc::step() break; } Info("Finished successfully"); - return srslte::proc_outcome_t::success; + return srsran::proc_outcome_t::success; } -void rrc::cell_reselection_proc::then(const srslte::proc_state_t& result) +void rrc::cell_reselection_proc::then(const srsran::proc_state_t& result) { // Schedule cell reselection periodically, while rrc is idle if (not rrc_ptr->is_connected() and rrc_ptr->nas->is_registered()) { @@ -1313,7 +1313,7 @@ proc_outcome_t rrc::connection_reest_proc::init(asn1::rrc::reest_cause_e cause) // 5.3.7.1 - Conditions for Reestablishment procedure if (not rrc_ptr->security_is_activated or rrc_ptr->state != RRC_STATE_CONNECTED or - uernti.crnti == SRSLTE_INVALID_RNTI) { + uernti.crnti == SRSRAN_INVALID_RNTI) { Warning("Conditions are NOT met to start procedure."); return proc_outcome_t::error; } @@ -1348,7 +1348,7 @@ proc_outcome_t rrc::connection_reest_proc::init(asn1::rrc::reest_cause_e cause) rrc_ptr->t311.run(); // 1> Suspend all RB except SRB0; - for (int i = 1; i < SRSLTE_N_RADIO_BEARERS; i++) { + for (int i = 1; i < SRSRAN_N_RADIO_BEARERS; i++) { if (rrc_ptr->rlc->has_bearer(i)) { rrc_ptr->rlc->suspend_bearer(i); } @@ -1383,7 +1383,7 @@ bool rrc::connection_reest_proc::passes_cell_criteria() const } // 5.3.7.3 - Actions following cell selection while T311 is running -srslte::proc_outcome_t rrc::connection_reest_proc::cell_criteria() +srsran::proc_outcome_t rrc::connection_reest_proc::cell_criteria() { if (not passes_cell_criteria()) { Info("Selected Serving cell does not pass criteria. Re-launching re-selection procedure"); @@ -1415,7 +1415,7 @@ srslte::proc_outcome_t rrc::connection_reest_proc::cell_criteria() return proc_outcome_t::yield; } -srslte::proc_outcome_t rrc::connection_reest_proc::start_cell_selection() +srsran::proc_outcome_t rrc::connection_reest_proc::start_cell_selection() { // Launch cell reselection state = state_t::wait_cell_selection; @@ -1428,7 +1428,7 @@ srslte::proc_outcome_t rrc::connection_reest_proc::start_cell_selection() return proc_outcome_t::yield; } -srslte::proc_outcome_t +srsran::proc_outcome_t rrc::connection_reest_proc::react(const cell_selection_proc::cell_selection_complete_ev& cell_selected_ev) { if (state != state_t::wait_cell_selection) { @@ -1459,7 +1459,7 @@ rrc::connection_reest_proc::react(const cell_selection_proc::cell_selection_comp } // 5.3.7.5 - Reception of the RRCConnectionReestablishment by the UE -srslte::proc_outcome_t rrc::connection_reest_proc::react(const asn1::rrc::rrc_conn_reest_s& reest_msg) +srsran::proc_outcome_t rrc::connection_reest_proc::react(const asn1::rrc::rrc_conn_reest_s& reest_msg) { // 1> stop timer T301; rrc_ptr->t301.stop(); @@ -1510,19 +1510,19 @@ srslte::proc_outcome_t rrc::connection_reest_proc::react(const asn1::rrc::rrc_co } // 5.3.7.7 - T301 expiry or selected cell no longer suitable -srslte::proc_outcome_t rrc::connection_reest_proc::react(const t301_expiry& ev) +srsran::proc_outcome_t rrc::connection_reest_proc::react(const t301_expiry& ev) { Info("Timer T301 expired: Going to RRC IDLE"); - srslte::console("Timer T301 expired: Going to RRC IDLE\n"); + srsran::console("Timer T301 expired: Going to RRC IDLE\n"); rrc_ptr->start_go_idle(); return proc_outcome_t::error; } -srslte::proc_outcome_t rrc::connection_reest_proc::step() +srsran::proc_outcome_t rrc::connection_reest_proc::step() { if (rrc_ptr->t301.is_running() and not passes_cell_criteria()) { Info("Selected cell no longer suitable: Going to RRC IDLE"); - srslte::console("Selected cell no longer suitable: Going to RRC IDLE\n"); + srsran::console("Selected cell no longer suitable: Going to RRC IDLE\n"); rrc_ptr->start_go_idle(); return proc_outcome_t::error; } @@ -1530,9 +1530,9 @@ srslte::proc_outcome_t rrc::connection_reest_proc::step() } // 5.3.7.8 - Reception of RRCConnectionReestablishmentReject by the UE -srslte::proc_outcome_t rrc::connection_reest_proc::react(const asn1::rrc::rrc_conn_reest_reject_s& reject_msg) +srsran::proc_outcome_t rrc::connection_reest_proc::react(const asn1::rrc::rrc_conn_reest_reject_s& reject_msg) { - srslte::console("Reestablishment Reject. Going to RRC IDLE\n"); + srsran::console("Reestablishment Reject. Going to RRC IDLE\n"); Info("Reestablishment Reject. Going to RRC IDLE"); rrc_ptr->t301.stop(); rrc_ptr->start_go_idle(); @@ -1540,7 +1540,7 @@ srslte::proc_outcome_t rrc::connection_reest_proc::react(const asn1::rrc::rrc_co } // 5.3.7.6 - T311 expiry -srslte::proc_outcome_t rrc::connection_reest_proc::react(const t311_expiry& ev) +srsran::proc_outcome_t rrc::connection_reest_proc::react(const t311_expiry& ev) { // Abort procedure if T311 expires Info("T311 expired during cell configuration. Going to RRC IDLE"); @@ -1567,7 +1567,7 @@ rrc::ho_proc::ho_proc(srsue::rrc* rrc_) : rrc_ptr(rrc_) {} * will not run other functions between the steps, like SR, PRACH, etc. * */ -srslte::proc_outcome_t rrc::ho_proc::init(const asn1::rrc::rrc_conn_recfg_s& rrc_reconf) +srsran::proc_outcome_t rrc::ho_proc::init(const asn1::rrc::rrc_conn_recfg_s& rrc_reconf) { Info("Starting..."); recfg_r8 = rrc_reconf.crit_exts.c1().rrc_conn_recfg_r8(); @@ -1575,7 +1575,7 @@ srslte::proc_outcome_t rrc::ho_proc::init(const asn1::rrc::rrc_conn_recfg_s& rrc size_t nof_scells_active = rrc_ptr->phy_ctrl->current_config_scells().count(); Info("Received HO command to target PCell=%d", mob_ctrl_info->target_pci); - srslte::console("Received HO command to target PCell=%d, NCC=%d\n", + srsran::console("Received HO command to target PCell=%d, NCC=%d\n", mob_ctrl_info->target_pci, recfg_r8.security_cfg_ho.handov_type.intra_lte().next_hop_chaining_count); @@ -1587,7 +1587,7 @@ srslte::proc_outcome_t rrc::ho_proc::init(const asn1::rrc::rrc_conn_recfg_s& rrc if (cell_to_ho != nullptr) { target_cell = cell_to_ho->phy_cell; } else { - srslte::console("Received HO command to unknown PCI=%d\n", mob_ctrl_info->target_pci); + srsran::console("Received HO command to unknown PCI=%d\n", mob_ctrl_info->target_pci); Error("Could not find target cell earfcn=%d, pci=%d", rrc_ptr->meas_cells.serving_cell().get_earfcn(), mob_ctrl_info->target_pci); @@ -1666,12 +1666,12 @@ srslte::proc_outcome_t rrc::ho_proc::init(const asn1::rrc::rrc_conn_recfg_s& rrc } if (sec_intralte.security_algorithm_cfg_present) { rrc_ptr->sec_cfg.cipher_algo = - (srslte::CIPHERING_ALGORITHM_ID_ENUM)sec_intralte.security_algorithm_cfg.ciphering_algorithm.to_number(); + (srsran::CIPHERING_ALGORITHM_ID_ENUM)sec_intralte.security_algorithm_cfg.ciphering_algorithm.to_number(); rrc_ptr->sec_cfg.integ_algo = - (srslte::INTEGRITY_ALGORITHM_ID_ENUM)sec_intralte.security_algorithm_cfg.integrity_prot_algorithm.to_number(); + (srsran::INTEGRITY_ALGORITHM_ID_ENUM)sec_intralte.security_algorithm_cfg.integrity_prot_algorithm.to_number(); Info("Changed Ciphering to %s and Integrity to %s", - srslte::ciphering_algorithm_id_text[rrc_ptr->sec_cfg.cipher_algo], - srslte::integrity_algorithm_id_text[rrc_ptr->sec_cfg.integ_algo]); + srsran::ciphering_algorithm_id_text[rrc_ptr->sec_cfg.cipher_algo], + srsran::integrity_algorithm_id_text[rrc_ptr->sec_cfg.integ_algo]); } } @@ -1702,7 +1702,7 @@ srslte::proc_outcome_t rrc::ho_proc::init(const asn1::rrc::rrc_conn_recfg_s& rrc return proc_outcome_t::yield; } -srslte::proc_outcome_t rrc::ho_proc::react(t304_expiry ev) +srsran::proc_outcome_t rrc::ho_proc::react(t304_expiry ev) { Info("HO preparation timed out. Reverting RRC security config from source cell."); @@ -1714,7 +1714,7 @@ srslte::proc_outcome_t rrc::ho_proc::react(t304_expiry ev) return proc_outcome_t::error; } -srslte::proc_outcome_t rrc::ho_proc::react(ra_completed_ev ev) +srsran::proc_outcome_t rrc::ho_proc::react(ra_completed_ev ev) { if (ev.success) { Info("Random Access completed. Applying final configuration and finishing procedure"); @@ -1730,10 +1730,10 @@ srslte::proc_outcome_t rrc::ho_proc::react(ra_completed_ev ev) return proc_outcome_t::yield; } -void rrc::ho_proc::then(const srslte::proc_state_t& result) +void rrc::ho_proc::then(const srsran::proc_state_t& result) { Info("HO to PCI=%d, EARFCN=%d %ssuccessful", target_cell.pci, target_cell.earfcn, result.is_success() ? "" : "un"); - srslte::console("HO %ssuccessful\n", result.is_success() ? "" : "un"); + srsran::console("HO %ssuccessful\n", result.is_success() ? "" : "un"); rrc_ptr->t304.stop(); } diff --git a/srsue/src/stack/ue_stack_lte.cc b/srsue/src/stack/ue_stack_lte.cc index f452deffb..af4627e05 100644 --- a/srsue/src/stack/ue_stack_lte.cc +++ b/srsue/src/stack/ue_stack_lte.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,16 +11,16 @@ */ #include "srsue/hdr/stack/ue_stack_lte.h" -#include "srslte/common/standard_streams.h" -#include "srslte/interfaces/ue_phy_interfaces.h" -#include "srslte/srslog/event_trace.h" +#include "srsran/common/standard_streams.h" +#include "srsran/interfaces/ue_phy_interfaces.h" +#include "srsran/srslog/event_trace.h" #include #include #include #include -using namespace srslte; +using namespace srsran; namespace srsue { @@ -73,9 +73,9 @@ int ue_stack_lte::init(const stack_args_t& args_, { phy_nr = phy_nr_; if (init(args_, phy_, gw_)) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int ue_stack_lte::init(const stack_args_t& args_, phy_interface_stack_lte* phy_, gw_interface_stack* gw_) @@ -84,10 +84,10 @@ int ue_stack_lte::init(const stack_args_t& args_, phy_interface_stack_lte* phy_, gw = gw_; if (init(args_)) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int ue_stack_lte::init(const stack_args_t& args_) @@ -116,7 +116,7 @@ int ue_stack_lte::init(const stack_args_t& args_) // Set up pcap // parse pcap trace list std::vector pcap_list; - srslte::string_parse_list(args.pkt_trace.enable, ',', pcap_list); + srsran::string_parse_list(args.pkt_trace.enable, ',', pcap_list); if (pcap_list.empty()) { stack_logger.error("PCAP enable list empty defaulting to disable all PCAPs"); args.pkt_trace.mac_pcap.enable = false; @@ -147,7 +147,7 @@ int ue_stack_lte::init(const stack_args_t& args_) if (args.pkt_trace.mac_pcap.enable && args.pkt_trace.mac_nr_pcap.enable && args.pkt_trace.mac_pcap.filename == args.pkt_trace.mac_nr_pcap.filename) { stack_logger.info("Using same MAC PCAP file %s for LTE and NR", args.pkt_trace.mac_pcap.filename.c_str()); - if (mac_pcap.open(args.pkt_trace.mac_pcap.filename.c_str()) == SRSLTE_SUCCESS) { + if (mac_pcap.open(args.pkt_trace.mac_pcap.filename.c_str()) == SRSRAN_SUCCESS) { mac.start_pcap(&mac_pcap); mac_nr.start_pcap(&mac_pcap); stack_logger.info("Open mac pcap file %s", args.pkt_trace.mac_pcap.filename.c_str()); @@ -156,7 +156,7 @@ int ue_stack_lte::init(const stack_args_t& args_) } } else { if (args.pkt_trace.mac_pcap.enable) { - if (mac_pcap.open(args.pkt_trace.mac_pcap.filename.c_str()) == SRSLTE_SUCCESS) { + if (mac_pcap.open(args.pkt_trace.mac_pcap.filename.c_str()) == SRSRAN_SUCCESS) { mac.start_pcap(&mac_pcap); stack_logger.info("Open mac pcap file %s", args.pkt_trace.mac_pcap.filename.c_str()); } else { @@ -165,7 +165,7 @@ int ue_stack_lte::init(const stack_args_t& args_) } if (args.pkt_trace.mac_nr_pcap.enable) { - if (mac_nr_pcap.open(args.pkt_trace.mac_nr_pcap.filename.c_str()) == SRSLTE_SUCCESS) { + if (mac_nr_pcap.open(args.pkt_trace.mac_nr_pcap.filename.c_str()) == SRSRAN_SUCCESS) { mac_nr.start_pcap(&mac_nr_pcap); stack_logger.info("Open mac nr pcap file %s", args.pkt_trace.mac_nr_pcap.filename.c_str()); } else { @@ -175,7 +175,7 @@ int ue_stack_lte::init(const stack_args_t& args_) } if (args.pkt_trace.nas_pcap.enable) { - if (nas_pcap.open(args.pkt_trace.nas_pcap.filename.c_str()) == SRSLTE_SUCCESS) { + if (nas_pcap.open(args.pkt_trace.nas_pcap.filename.c_str()) == SRSRAN_SUCCESS) { nas.start_pcap(&nas_pcap); stack_logger.info("Open nas pcap file %s", args.pkt_trace.nas_pcap.filename.c_str()); } else { @@ -186,8 +186,8 @@ int ue_stack_lte::init(const stack_args_t& args_) // Init USIM first to allow early exit in case reader couldn't be found usim = usim_base::get_instance(&args.usim, usim_logger); if (usim->init(&args.usim)) { - srslte::console("Failed to initialize USIM.\n"); - return SRSLTE_ERROR; + srsran::console("Failed to initialize USIM.\n"); + return SRSRAN_ERROR; } // add sync queue @@ -206,7 +206,7 @@ int ue_stack_lte::init(const stack_args_t& args_) running = true; start(STACK_MAIN_THREAD_PRIO); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } void ue_stack_lte::stop() @@ -273,21 +273,21 @@ bool ue_stack_lte::switch_off() bool ue_stack_lte::enable_data() { // perform attach request - srslte::console("Turning off airplane mode.\n"); + srsran::console("Turning off airplane mode.\n"); return nas.enable_data(); } bool ue_stack_lte::disable_data() { // generate detach request - srslte::console("Turning on airplane mode.\n"); + srsran::console("Turning on airplane mode.\n"); return nas.disable_data(); } bool ue_stack_lte::start_service_request() { if (running) { - ue_task_queue.try_push([this]() { nas.start_service_request(srslte::establishment_cause_t::mo_data); }); + ue_task_queue.try_push([this]() { nas.start_service_request(srsran::establishment_cause_t::mo_data); }); } return true; } @@ -330,9 +330,9 @@ void ue_stack_lte::run_thread() * @param sdu * @param blocking */ -void ue_stack_lte::write_sdu(uint32_t lcid, srslte::unique_byte_buffer_t sdu) +void ue_stack_lte::write_sdu(uint32_t lcid, srsran::unique_byte_buffer_t sdu) { - auto task = [this, lcid](srslte::unique_byte_buffer_t& sdu) { pdcp.write_sdu(lcid, std::move(sdu)); }; + auto task = [this, lcid](srsran::unique_byte_buffer_t& sdu) { pdcp.write_sdu(lcid, std::move(sdu)); }; bool ret = gw_queue_id.try_push(std::bind(task, std::move(sdu))).first; if (not ret) { pdcp_logger.info("GW SDU with lcid=%d was discarded.", lcid); diff --git a/srsue/src/stack/ue_stack_nr.cc b/srsue/src/stack/ue_stack_nr.cc index 0f9f31002..611f45a58 100644 --- a/srsue/src/stack/ue_stack_nr.cc +++ b/srsue/src/stack/ue_stack_nr.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,9 +11,9 @@ */ #include "srsue/hdr/stack/ue_stack_nr.h" -#include "srslte/srslte.h" +#include "srsran/srsran.h" -using namespace srslte; +using namespace srsran; namespace srsue { @@ -26,8 +26,8 @@ ue_stack_nr::ue_stack_nr() : { get_background_workers().set_nof_workers(2); mac.reset(new mac_nr(&task_sched)); - pdcp.reset(new srslte::pdcp(&task_sched, "PDCP")); - rlc.reset(new srslte::rlc("RLC")); + pdcp.reset(new srsran::pdcp(&task_sched, "PDCP")); + rlc.reset(new srsran::rlc("RLC")); rrc.reset(new rrc_nr(&task_sched)); // setup logging for pool, RLC and PDCP @@ -83,7 +83,7 @@ int ue_stack_nr::init(const stack_args_t& args_) running = true; start(STACK_MAIN_THREAD_PRIO); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } void ue_stack_nr::stop() @@ -151,11 +151,11 @@ void ue_stack_nr::run_thread() * @param sdu * @param blocking */ -void ue_stack_nr::write_sdu(uint32_t lcid, srslte::unique_byte_buffer_t sdu) +void ue_stack_nr::write_sdu(uint32_t lcid, srsran::unique_byte_buffer_t sdu) { if (pdcp != nullptr) { std::pair ret = gw_task_queue.try_push(std::bind( - [this, lcid](srslte::unique_byte_buffer_t& sdu) { pdcp->write_sdu(lcid, std::move(sdu)); }, std::move(sdu))); + [this, lcid](srsran::unique_byte_buffer_t& sdu) { pdcp->write_sdu(lcid, std::move(sdu)); }, std::move(sdu))); if (not ret.first) { pdcp_logger.warning("GW SDU with lcid=%d was discarded.", lcid); } diff --git a/srsue/src/stack/upper/CMakeLists.txt b/srsue/src/stack/upper/CMakeLists.txt index 4cd8aa214..d027ba02c 100644 --- a/srsue/src/stack/upper/CMakeLists.txt +++ b/srsue/src/stack/upper/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of diff --git a/srsue/src/stack/upper/gw.cc b/srsue/src/stack/upper/gw.cc index 5aefebf0b..3cd957e08 100644 --- a/srsue/src/stack/upper/gw.cc +++ b/srsue/src/stack/upper/gw.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,9 +11,9 @@ */ #include "srsue/hdr/stack/upper/gw.h" -#include "srslte/common/standard_streams.h" -#include "srslte/interfaces/ue_pdcp_interfaces.h" -#include "srslte/upper/ipv6.h" +#include "srsran/common/standard_streams.h" +#include "srsran/interfaces/ue_pdcp_interfaces.h" +#include "srsran/upper/ipv6.h" #include #include @@ -46,17 +46,17 @@ int gw::init(const gw_args_t& args_, stack_interface_gw* stack_) mbsfn_sock_fd = socket(AF_INET, SOCK_DGRAM, 0); if (mbsfn_sock_fd < 0) { logger.error("Failed to create MBSFN sink socket"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (fcntl(mbsfn_sock_fd, F_SETFL, O_NONBLOCK)) { logger.error("Failed to set non-blocking MBSFN sink socket"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } mbsfn_sock_addr.sin_family = AF_INET; mbsfn_sock_addr.sin_addr.s_addr = inet_addr("127.0.0.1"); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } void gw::stop() @@ -112,7 +112,7 @@ void gw::get_metrics(gw_metrics_t& m, const uint32_t nof_tti) /******************************************************************************* PDCP interface *******************************************************************************/ -void gw::write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t pdu) +void gw::write_pdu(uint32_t lcid, srsran::unique_byte_buffer_t pdu) { logger.info(pdu->msg, pdu->N_bytes, "RX PDU. Stack latency: %ld us", pdu->get_latency_us().count()); dl_tput_bytes += pdu->N_bytes; @@ -135,7 +135,7 @@ void gw::write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t pdu) } } -void gw::write_pdu_mch(uint32_t lcid, srslte::unique_byte_buffer_t pdu) +void gw::write_pdu_mch(uint32_t lcid, srsran::unique_byte_buffer_t pdu) { if (pdu->N_bytes > 2) { logger.info(pdu->msg, @@ -175,13 +175,13 @@ int gw::setup_if_addr(uint32_t eps_bearer_id, int err; if (pdn_type == LIBLTE_MME_PDN_TYPE_IPV4 || pdn_type == LIBLTE_MME_PDN_TYPE_IPV4V6) { err = setup_if_addr4(ip_addr, err_str); - if (err != SRSLTE_SUCCESS) { + if (err != SRSRAN_SUCCESS) { return err; } } if (pdn_type == LIBLTE_MME_PDN_TYPE_IPV6 || pdn_type == LIBLTE_MME_PDN_TYPE_IPV4V6) { err = setup_if_addr6(ipv6_if_addr, err_str); - if (err != SRSLTE_SUCCESS) { + if (err != SRSRAN_SUCCESS) { return err; } } @@ -192,7 +192,7 @@ int gw::setup_if_addr(uint32_t eps_bearer_id, // Setup a thread to receive packets from the TUN device start(GW_THREAD_PRIO); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int gw::update_lcid(uint32_t eps_bearer_id, uint32_t new_lcid) @@ -210,9 +210,9 @@ int gw::update_lcid(uint32_t eps_bearer_id, uint32_t new_lcid) // TODO: update need filters if not the default lcid } else { logger.error("Did not found EPS bearer %d for updating LCID.", eps_bearer_id); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int gw::apply_traffic_flow_template(const uint8_t& erab_id, @@ -232,7 +232,7 @@ void gw::set_test_loop_mode(const test_loop_mode_state_t mode, const uint32_t ip *******************************************************************************/ void gw::add_mch_port(uint32_t lcid, uint32_t port) { - if (lcid > 0 && lcid < SRSLTE_N_MCH_LCIDS) { + if (lcid > 0 && lcid < SRSRAN_N_MCH_LCIDS) { mbsfn_ports[lcid] = port; } } @@ -245,7 +245,7 @@ void gw::run_thread() uint32 idx = 0; int32 N_bytes = 0; - srslte::unique_byte_buffer_t pdu = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t pdu = srsran::make_byte_buffer(); if (!pdu) { logger.error("Fatal Error: Couldn't allocate PDU in run_thread()."); return; @@ -259,18 +259,18 @@ void gw::run_thread() running = true; while (run_enable) { // Read packet from TUN - if (SRSLTE_MAX_BUFFER_SIZE_BYTES - SRSLTE_BUFFER_HEADER_OFFSET > idx) { - N_bytes = read(tun_fd, &pdu->msg[idx], SRSLTE_MAX_BUFFER_SIZE_BYTES - SRSLTE_BUFFER_HEADER_OFFSET - idx); + if (SRSRAN_MAX_BUFFER_SIZE_BYTES - SRSRAN_BUFFER_HEADER_OFFSET > idx) { + N_bytes = read(tun_fd, &pdu->msg[idx], SRSRAN_MAX_BUFFER_SIZE_BYTES - SRSRAN_BUFFER_HEADER_OFFSET - idx); } else { logger.error("GW pdu buffer full - gw receive thread exiting."); - srslte::console("GW pdu buffer full - gw receive thread exiting.\n"); + srsran::console("GW pdu buffer full - gw receive thread exiting.\n"); break; } logger.debug("Read %d bytes from TUN fd=%d, idx=%d", N_bytes, tun_fd, idx); if (N_bytes <= 0) { logger.error("Failed to read from TUN interface - gw receive thread exiting."); - srslte::console("Failed to read from TUN interface - gw receive thread exiting.\n"); + srsran::console("Failed to read from TUN interface - gw receive thread exiting.\n"); break; } @@ -332,7 +332,7 @@ void gw::run_thread() ul_tput_bytes += pdu->N_bytes; stack->write_sdu(lcid, std::move(pdu)); do { - pdu = srslte::make_byte_buffer(); + pdu = srsran::make_byte_buffer(); if (!pdu) { logger.error("Fatal Error: Couldn't allocate PDU in run_thread()."); usleep(100000); @@ -355,7 +355,7 @@ void gw::run_thread() int gw::init_if(char* err_str) { if (if_up) { - return SRSLTE_ERROR_ALREADY_STARTED; + return SRSRAN_ERROR_ALREADY_STARTED; } // change into netns @@ -366,12 +366,12 @@ int gw::init_if(char* err_str) if (netns_fd == -1) { err_str = strerror(errno); logger.error("Failed to find netns %s (%s): %s", args.netns.c_str(), netns.c_str(), err_str); - return SRSLTE_ERROR_CANT_START; + return SRSRAN_ERROR_CANT_START; } if (setns(netns_fd, CLONE_NEWNET) == -1) { err_str = strerror(errno); logger.error("Failed to change netns: %s", err_str); - return SRSLTE_ERROR_CANT_START; + return SRSRAN_ERROR_CANT_START; } } @@ -381,7 +381,7 @@ int gw::init_if(char* err_str) if (0 > tun_fd) { err_str = strerror(errno); logger.error("Failed to open TUN device: %s", err_str); - return SRSLTE_ERROR_CANT_START; + return SRSRAN_ERROR_CANT_START; } memset(&ifr, 0, sizeof(ifr)); @@ -393,7 +393,7 @@ int gw::init_if(char* err_str) err_str = strerror(errno); logger.error("Failed to set TUN device name: %s", err_str); close(tun_fd); - return SRSLTE_ERROR_CANT_START; + return SRSRAN_ERROR_CANT_START; } // Bring up the interface @@ -402,14 +402,14 @@ int gw::init_if(char* err_str) err_str = strerror(errno); logger.error("Failed to bring up socket: %s", err_str); close(tun_fd); - return SRSLTE_ERROR_CANT_START; + return SRSRAN_ERROR_CANT_START; } ifr.ifr_flags |= IFF_UP | IFF_RUNNING; if (0 > ioctl(sock, SIOCSIFFLAGS, &ifr)) { err_str = strerror(errno); logger.error("Failed to set socket flags: %s", err_str); close(tun_fd); - return SRSLTE_ERROR_CANT_START; + return SRSRAN_ERROR_CANT_START; } // Delete link-local IPv6 address. @@ -423,7 +423,7 @@ int gw::init_if(char* err_str) } if_up = true; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int gw::setup_if_addr4(uint32_t ip_addr, char* err_str) @@ -432,7 +432,7 @@ int gw::setup_if_addr4(uint32_t ip_addr, char* err_str) if (!if_up) { if (init_if(err_str)) { logger.error("init_if failed"); - return SRSLTE_ERROR_CANT_START; + return SRSRAN_ERROR_CANT_START; } } @@ -444,7 +444,7 @@ int gw::setup_if_addr4(uint32_t ip_addr, char* err_str) err_str = strerror(errno); logger.debug("Failed to set socket address: %s", err_str); close(tun_fd); - return SRSLTE_ERROR_CANT_START; + return SRSRAN_ERROR_CANT_START; } ifr.ifr_netmask.sa_family = AF_INET; ((struct sockaddr_in*)&ifr.ifr_netmask)->sin_addr.s_addr = inet_addr(args.tun_dev_netmask.c_str()); @@ -452,11 +452,11 @@ int gw::setup_if_addr4(uint32_t ip_addr, char* err_str) err_str = strerror(errno); logger.debug("Failed to set socket netmask: %s", err_str); close(tun_fd); - return SRSLTE_ERROR_CANT_START; + return SRSRAN_ERROR_CANT_START; } current_ip_addr = ip_addr; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int gw::setup_if_addr6(uint8_t* ipv6_if_id, char* err_str) @@ -476,7 +476,7 @@ int gw::setup_if_addr6(uint8_t* ipv6_if_id, char* err_str) if (!if_up) { if (init_if(err_str)) { logger.error("init_if failed"); - return SRSLTE_ERROR_CANT_START; + return SRSRAN_ERROR_CANT_START; } } @@ -486,13 +486,13 @@ int gw::setup_if_addr6(uint8_t* ipv6_if_id, char* err_str) if (inet_pton(AF_INET6, "fe80::", (void*)&sai.sin6_addr) <= 0) { logger.error("Bad address"); - return SRSLTE_ERROR_CANT_START; + return SRSRAN_ERROR_CANT_START; } memcpy(&sai.sin6_addr.s6_addr[8], ipv6_if_id, 8); if (ioctl(sock, SIOGIFINDEX, &ifr) < 0) { perror("SIOGIFINDEX"); - return SRSLTE_ERROR_CANT_START; + return SRSRAN_ERROR_CANT_START; } ifr6.ifr6_ifindex = ifr.ifr_ifindex; ifr6.ifr6_prefixlen = 64; @@ -501,7 +501,7 @@ int gw::setup_if_addr6(uint8_t* ipv6_if_id, char* err_str) if (ioctl(sock, SIOCSIFADDR, &ifr6) < 0) { err_str = strerror(errno); logger.error("Could not set IPv6 Link local address. Error %s", err_str); - return SRSLTE_ERROR_CANT_START; + return SRSRAN_ERROR_CANT_START; } for (int i = 0; i < 8; i++) { @@ -509,7 +509,7 @@ int gw::setup_if_addr6(uint8_t* ipv6_if_id, char* err_str) } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } bool gw::find_ipv6_addr(struct in6_addr* in6_out) diff --git a/srsue/src/stack/upper/nas.cc b/srsue/src/stack/upper/nas.cc index ac9e36254..4daf95f69 100644 --- a/srsue/src/stack/upper/nas.cc +++ b/srsue/src/stack/upper/nas.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,23 +10,23 @@ * */ -#include "srslte/common/bcd_helpers.h" -#include "srslte/common/security.h" -#include "srslte/common/string_helpers.h" +#include "srsran/common/bcd_helpers.h" +#include "srsran/common/security.h" +#include "srsran/common/string_helpers.h" #include #include #include #include -#include "srslte/asn1/liblte_mme.h" -#include "srslte/common/standard_streams.h" -#include "srslte/interfaces/ue_gw_interfaces.h" -#include "srslte/interfaces/ue_rrc_interfaces.h" -#include "srslte/interfaces/ue_usim_interfaces.h" +#include "srsran/asn1/liblte_mme.h" +#include "srsran/common/standard_streams.h" +#include "srsran/interfaces/ue_gw_interfaces.h" +#include "srsran/interfaces/ue_rrc_interfaces.h" +#include "srsran/interfaces/ue_usim_interfaces.h" #include "srsue/hdr/stack/upper/nas.h" #include "srsue/hdr/stack/upper/nas_idle_procedures.h" -using namespace srslte; +using namespace srsran; namespace srsue { @@ -34,7 +34,7 @@ namespace srsue { * NAS ********************************************************************/ -nas::nas(srslte::task_sched_handle task_sched_) : +nas::nas(srsran::task_sched_handle task_sched_) : plmn_searcher(this), task_sched(task_sched_), t3402(task_sched_.get_unique_timer()), @@ -59,7 +59,7 @@ void nas::init(usim_interface_nas* usim_, rrc_interface_nas* rrc_, gw_interface_ // parse and sanity check EIA list std::vector cap_list; - srslte::string_parse_list(cfg_.eia, ',', cap_list); + srsran::string_parse_list(cfg_.eia, ',', cap_list); if (cap_list.empty()) { logger.error("Empty EIA list. Select at least one EIA algorithm."); } @@ -72,7 +72,7 @@ void nas::init(usim_interface_nas* usim_, rrc_interface_nas* rrc_, gw_interface_ } // parse and sanity check EEA list - srslte::string_parse_list(cfg_.eea, ',', cap_list); + srsran::string_parse_list(cfg_.eea, ',', cap_list); if (cap_list.empty()) { logger.error("Empty EEA list. Select at least one EEA algorithm."); } @@ -143,7 +143,7 @@ void nas::run_tti() break; case emm_state_t::deregistered_substate_t::normal_service: case emm_state_t::deregistered_substate_t::attach_needed: - start_attach_request(srslte::establishment_cause_t::mo_data); + start_attach_request(srsran::establishment_cause_t::mo_data); break; case emm_state_t::deregistered_substate_t::attempting_to_attach: logger.debug("Attempting to attach"); @@ -202,7 +202,7 @@ void nas::timer_expired(uint32_t timeout_id) // Section 5.5.1.2.6 case c) attach_attempt_counter++; - srslte::console("Attach failed (attempt %d/%d)\n", attach_attempt_counter, max_attach_attempts); + srsran::console("Attach failed (attempt %d/%d)\n", attach_attempt_counter, max_attach_attempts); if (attach_attempt_counter < max_attach_attempts) { logger.warning("Timer T3410 expired after attach attempt %d/%d: starting T3411", attach_attempt_counter, @@ -222,7 +222,7 @@ void nas::timer_expired(uint32_t timeout_id) enter_emm_deregistered(emm_state_t::deregistered_substate_t::plmn_search); } else if (timeout_id == reattach_timer.id()) { logger.warning("Reattach timer expired: trying to attach again"); - start_attach_request(srslte::establishment_cause_t::mo_sig); + start_attach_request(srsran::establishment_cause_t::mo_sig); } else if (timeout_id == airplane_mode_sim_timer.id()) { if (airplane_mode_state == DISABLED) { // Enabling air-plane mode @@ -235,7 +235,7 @@ void nas::timer_expired(uint32_t timeout_id) } } else if (airplane_mode_state == ENABLED) { // Disabling airplane mode again - start_attach_request(srslte::establishment_cause_t::mo_sig); + start_attach_request(srsran::establishment_cause_t::mo_sig); airplane_mode_state = DISABLED; if (cfg.sim.airplane_t_off_ms > 0) { @@ -290,7 +290,7 @@ bool nas::disable_data() * The function returns true if the UE could attach correctly or false in case of error or timeout during attachment. * */ -void nas::start_attach_request(srslte::establishment_cause_t cause_) +void nas::start_attach_request(srsran::establishment_cause_t cause_) { logger.info("Attach Request with cause %s.", to_string(cause_).c_str()); @@ -315,7 +315,7 @@ void nas::start_attach_request(srslte::establishment_cause_t cause_) } // Start attach request - unique_byte_buffer_t msg = srslte::make_byte_buffer(); + unique_byte_buffer_t msg = srsran::make_byte_buffer(); if (msg == nullptr) { logger.warning("Couldn't allocate buffer for Attach request.\n"); return; @@ -340,10 +340,10 @@ void nas::start_attach_request(srslte::establishment_cause_t cause_) * The function returns true if the UE could attach correctly or false in case of error or timeout during attachment. * */ -void nas::start_service_request(srslte::establishment_cause_t cause_) +void nas::start_service_request(srsran::establishment_cause_t cause_) { logger.info("Service Request with cause %s.", to_string(cause_).c_str()); - srslte::console("Service Request with cause %s.\n", to_string(cause_).c_str()); + srsran::console("Service Request with cause %s.\n", to_string(cause_).c_str()); if (state.get_state() != emm_state_t::state_t::registered) { logger.info("NAS in invalid state for Service Request"); logger.info("Service request ignored. State = %s", state.get_full_state_text().c_str()); @@ -358,7 +358,7 @@ void nas::start_service_request(srslte::establishment_cause_t cause_) logger.info("NAS is already registered but RRC disconnected. Connecting now..."); // Start service request - unique_byte_buffer_t msg = srslte::make_byte_buffer(); + unique_byte_buffer_t msg = srsran::make_byte_buffer(); gen_service_request(msg); if (not rrc->connection_request(cause_, std::move(msg))) { logger.error("Error starting RRC connection"); @@ -404,7 +404,7 @@ bool nas::connection_request_completed(bool outcome) if (outcome == true) { logger.debug("RRC connection request completed. NAS State %s.", state.get_full_state_text().c_str()); if (state.get_state() == emm_state_t::state_t::service_request_initiated) { - srslte::console("Service Request successful.\n"); + srsran::console("Service Request successful.\n"); logger.info("Service Request successful."); rrc->paging_completed(true); state.set_registered(emm_state_t::registered_substate_t::normal_service); @@ -412,7 +412,7 @@ bool nas::connection_request_completed(bool outcome) } else { logger.debug("RRC connection request failed. NAS State %s.", state.get_full_state_text().c_str()); if (state.get_state() == emm_state_t::state_t::service_request_initiated) { - srslte::console("RRC connection for Service Request failed.\n"); + srsran::console("RRC connection for Service Request failed.\n"); logger.info("RRC connection for Service Request failed."); rrc->paging_completed(false); state.set_registered(emm_state_t::registered_substate_t::normal_service); @@ -435,7 +435,7 @@ bool nas::paging(s_tmsi_t* ue_identity) { if (state.get_state() == emm_state_t::state_t::registered) { logger.info("Received paging: requesting RRC connection establishment"); - start_service_request(srslte::establishment_cause_t::mt_access); + start_service_request(srsran::establishment_cause_t::mt_access); } else { logger.warning("Received paging while in state %s", state.get_full_state_text().c_str()); return false; @@ -652,7 +652,7 @@ void nas::select_plmn() } // First find if Home PLMN is available - for (const srslte::plmn_id_t& known_plmn : known_plmns) { + for (const srsran::plmn_id_t& known_plmn : known_plmns) { if (known_plmn == home_plmn) { logger.info("Selecting Home PLMN Id=%s", known_plmn.to_string().c_str()); current_plmn = known_plmn; @@ -666,7 +666,7 @@ void nas::select_plmn() std::string debug_str = "Could not find Home PLMN Id=" + home_plmn.to_string() + ", trying to connect to PLMN Id=" + known_plmns[0].to_string(); logger.info("%s", debug_str.c_str()); - srslte::console("%s\n", debug_str.c_str()); + srsran::console("%s\n", debug_str.c_str()); current_plmn = known_plmns[0]; state.set_deregistered(emm_state_t::deregistered_substate_t::normal_service); } @@ -886,7 +886,7 @@ bool nas::check_cap_replay(LIBLTE_MME_UE_SECURITY_CAPABILITIES_STRUCT* caps) * @param sec_hdr_type Security header type of the message * @return True if successful, false otherwise */ -int nas::apply_security_config(srslte::unique_byte_buffer_t& pdu, uint8_t sec_hdr_type) +int nas::apply_security_config(srsran::unique_byte_buffer_t& pdu, uint8_t sec_hdr_type) { if (have_ctxt) { if (pdu->N_bytes > 5) { @@ -900,12 +900,12 @@ int nas::apply_security_config(srslte::unique_byte_buffer_t& pdu, uint8_t sec_hd } } else { logger.error("Invalid PDU size %d", pdu->N_bytes); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } else { logger.debug("Not applying security for PDU. No context configured."); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } /** @@ -1020,7 +1020,7 @@ void nas::parse_attach_accept(uint32_t lcid, unique_byte_buffer_t pdu) act_def_eps_bearer_context_req.pdn_addr.addr[2], act_def_eps_bearer_context_req.pdn_addr.addr[3]); - srslte::console("Network attach successful. IP: %u.%u.%u.%u\n", + srsran::console("Network attach successful. IP: %u.%u.%u.%u\n", act_def_eps_bearer_context_req.pdn_addr.addr[0], act_def_eps_bearer_context_req.pdn_addr.addr[1], act_def_eps_bearer_context_req.pdn_addr.addr[2], @@ -1035,7 +1035,7 @@ void nas::parse_attach_accept(uint32_t lcid, unique_byte_buffer_t pdu) nullptr, err_str)) { logger.error("%s - %s", gw_setup_failure_str.c_str(), err_str ? err_str : ""); - srslte::console("%s\n", gw_setup_failure_str.c_str()); + srsran::console("%s\n", gw_setup_failure_str.c_str()); } } else if (LIBLTE_MME_PDN_TYPE_IPV6 == act_def_eps_bearer_context_req.pdn_addr.pdn_type) { memcpy(ipv6_if_id, act_def_eps_bearer_context_req.pdn_addr.addr, 8); @@ -1050,7 +1050,7 @@ void nas::parse_attach_accept(uint32_t lcid, unique_byte_buffer_t pdu) act_def_eps_bearer_context_req.pdn_addr.addr[6], act_def_eps_bearer_context_req.pdn_addr.addr[7]); - srslte::console("Network attach successful. IPv6 interface Id: %02x%02x:%02x%02x:%02x%02x:%02x%02x\n", + srsran::console("Network attach successful. IPv6 interface Id: %02x%02x:%02x%02x:%02x%02x:%02x%02x\n", act_def_eps_bearer_context_req.pdn_addr.addr[0], act_def_eps_bearer_context_req.pdn_addr.addr[1], act_def_eps_bearer_context_req.pdn_addr.addr[2], @@ -1068,7 +1068,7 @@ void nas::parse_attach_accept(uint32_t lcid, unique_byte_buffer_t pdu) ipv6_if_id, err_str)) { logger.error("%s - %s", gw_setup_failure_str.c_str(), err_str); - srslte::console("%s\n", gw_setup_failure_str.c_str()); + srsran::console("%s\n", gw_setup_failure_str.c_str()); } } else if (LIBLTE_MME_PDN_TYPE_IPV4V6 == act_def_eps_bearer_context_req.pdn_addr.pdn_type) { memcpy(ipv6_if_id, act_def_eps_bearer_context_req.pdn_addr.addr, 8); @@ -1083,7 +1083,7 @@ void nas::parse_attach_accept(uint32_t lcid, unique_byte_buffer_t pdu) act_def_eps_bearer_context_req.pdn_addr.addr[5], act_def_eps_bearer_context_req.pdn_addr.addr[6], act_def_eps_bearer_context_req.pdn_addr.addr[7]); - srslte::console("Network attach successful. IPv6 interface Id: %02x%02x:%02x%02x:%02x%02x:%02x%02x\n", + srsran::console("Network attach successful. IPv6 interface Id: %02x%02x:%02x%02x:%02x%02x:%02x%02x\n", act_def_eps_bearer_context_req.pdn_addr.addr[0], act_def_eps_bearer_context_req.pdn_addr.addr[1], act_def_eps_bearer_context_req.pdn_addr.addr[2], @@ -1105,7 +1105,7 @@ void nas::parse_attach_accept(uint32_t lcid, unique_byte_buffer_t pdu) act_def_eps_bearer_context_req.pdn_addr.addr[10], act_def_eps_bearer_context_req.pdn_addr.addr[11]); - srslte::console("Network attach successful. IP: %u.%u.%u.%u\n", + srsran::console("Network attach successful. IP: %u.%u.%u.%u\n", act_def_eps_bearer_context_req.pdn_addr.addr[8], act_def_eps_bearer_context_req.pdn_addr.addr[9], act_def_eps_bearer_context_req.pdn_addr.addr[10], @@ -1119,7 +1119,7 @@ void nas::parse_attach_accept(uint32_t lcid, unique_byte_buffer_t pdu) ipv6_if_id, err_str)) { logger.error("%s - %s", gw_setup_failure_str.c_str(), err_str); - srslte::console("%s\n", gw_setup_failure_str.c_str()); + srsran::console("%s\n", gw_setup_failure_str.c_str()); } } else { logger.error("PDN type not IPv4, IPv6 nor IPv4v6"); @@ -1195,7 +1195,7 @@ void nas::parse_attach_reject(uint32_t lcid, unique_byte_buffer_t pdu) liblte_mme_unpack_attach_reject_msg((LIBLTE_BYTE_MSG_STRUCT*)pdu.get(), &attach_rej); logger.warning("Received Attach Reject. Cause= %02X", attach_rej.emm_cause); - srslte::console("Received Attach Reject. Cause= %02X\n", attach_rej.emm_cause); + srsran::console("Received Attach Reject. Cause= %02X\n", attach_rej.emm_cause); // stop T3410 if (t3410.is_running()) { @@ -1259,7 +1259,7 @@ void nas::parse_authentication_request(uint32_t lcid, unique_byte_buffer_t pdu, ctxt.ksi = auth_req.nas_ksi.nas_ksi; } else { logger.error("NAS mapped security context not currently supported"); - srslte::console("Warning: NAS mapped security context not currently supported\n"); + srsran::console("Warning: NAS mapped security context not currently supported\n"); } if (auth_result == AUTH_OK) { @@ -1276,7 +1276,7 @@ void nas::parse_authentication_request(uint32_t lcid, unique_byte_buffer_t pdu, send_authentication_failure(LIBLTE_MME_EMM_CAUSE_SYNCH_FAILURE, res); } else { logger.warning("Network authentication failure"); - srslte::console("Warning: Network authentication failure\n"); + srsran::console("Warning: Network authentication failure\n"); send_authentication_failure(LIBLTE_MME_EMM_CAUSE_MAC_FAILURE, nullptr); } } @@ -1428,7 +1428,7 @@ void nas::parse_service_reject(uint32_t lcid, unique_byte_buffer_t pdu) return; } - srslte::console("Received service reject with EMM cause=0x%x.\n", service_reject.emm_cause); + srsran::console("Received service reject with EMM cause=0x%x.\n", service_reject.emm_cause); if (service_reject.t3446_present) { logger.info( "Received service reject with EMM cause=0x%x and t3446=%d", service_reject.emm_cause, service_reject.t3446); @@ -1465,7 +1465,7 @@ void nas::parse_emm_information(uint32_t lcid, unique_byte_buffer_t pdu) liblte_mme_unpack_emm_information_msg((LIBLTE_BYTE_MSG_STRUCT*)pdu.get(), &emm_info); std::string str = emm_info_str(&emm_info); logger.info("Received EMM Information: %s", str.c_str()); - srslte::console("%s\n", str.c_str()); + srsran::console("%s\n", str.c_str()); ctxt.rx_count++; } @@ -1583,7 +1583,7 @@ void nas::parse_deactivate_eps_bearer_context_request(unique_byte_buffer_t pdu) send_deactivate_eps_bearer_context_accept(request.proc_transaction_id, request.eps_bearer_id); } -void nas::parse_modify_eps_bearer_context_request(srslte::unique_byte_buffer_t pdu) +void nas::parse_modify_eps_bearer_context_request(srsran::unique_byte_buffer_t pdu) { LIBLTE_MME_MODIFY_EPS_BEARER_CONTEXT_REQUEST_MSG_STRUCT request; @@ -1669,7 +1669,7 @@ void nas::parse_emm_status(uint32_t lcid, unique_byte_buffer_t pdu) * Senders ******************************************************************************/ -void nas::gen_attach_request(srslte::unique_byte_buffer_t& msg) +void nas::gen_attach_request(srsran::unique_byte_buffer_t& msg) { if (msg == nullptr) { logger.error("Fatal Error: Couldn't allocate PDU in gen_attach_request()."); @@ -1778,7 +1778,7 @@ void nas::gen_attach_request(srslte::unique_byte_buffer_t& msg) t3410.run(); } -void nas::gen_service_request(srslte::unique_byte_buffer_t& msg) +void nas::gen_service_request(srsran::unique_byte_buffer_t& msg) { if (msg == nullptr) { logger.error("Fatal Error: Couldn't allocate PDU in gen_service_request()."); @@ -1833,7 +1833,7 @@ void nas::gen_pdn_connectivity_request(LIBLTE_BYTE_MSG_STRUCT* msg) pdn_con_req.pdn_type = LIBLTE_MME_PDN_TYPE_IPV4V6; } else { logger.warning("Unsupported PDN prtocol. Defaulting to IPv4"); - srslte::console("Unsupported PDN prtocol: %s. Defaulting to IPv4\n", cfg.apn_protocol.c_str()); + srsran::console("Unsupported PDN prtocol: %s. Defaulting to IPv4\n", cfg.apn_protocol.c_str()); pdn_con_req.pdn_type = LIBLTE_MME_PDN_TYPE_IPV4; } @@ -1855,7 +1855,7 @@ void nas::gen_pdn_connectivity_request(LIBLTE_BYTE_MSG_STRUCT* msg) void nas::send_security_mode_reject(uint8_t cause) { - unique_byte_buffer_t msg = srslte::make_byte_buffer(); + unique_byte_buffer_t msg = srsran::make_byte_buffer(); if (!msg) { logger.error("Fatal Error: Couldn't allocate PDU in send_security_mode_reject()."); return; @@ -1876,7 +1876,7 @@ void nas::send_security_mode_reject(uint8_t cause) */ void nas::send_attach_request() { - unique_byte_buffer_t pdu = srslte::make_byte_buffer(); + unique_byte_buffer_t pdu = srsran::make_byte_buffer(); if (!pdu) { logger.error("Fatal Error: Couldn't allocate PDU in %s().", __FUNCTION__); return; @@ -1887,7 +1887,7 @@ void nas::send_attach_request() void nas::send_detach_request(bool switch_off) { - unique_byte_buffer_t pdu = srslte::make_byte_buffer(); + unique_byte_buffer_t pdu = srsran::make_byte_buffer(); if (!pdu) { logger.error("Fatal Error: Couldn't allocate PDU in %s().", __FUNCTION__); return; @@ -1948,7 +1948,7 @@ void nas::send_detach_request(bool switch_off) if (rrc->is_connected()) { rrc->write_sdu(std::move(pdu)); } else { - if (not rrc->connection_request(srslte::establishment_cause_t::mo_sig, std::move(pdu))) { + if (not rrc->connection_request(srsran::establishment_cause_t::mo_sig, std::move(pdu))) { logger.error("Error starting RRC connection"); } } @@ -1968,7 +1968,7 @@ void nas::send_attach_complete(const uint8_t& transaction_id_, const uint8_t& ep &attach_complete.esm_msg); // Pack entire message - unique_byte_buffer_t pdu = srslte::make_byte_buffer(); + unique_byte_buffer_t pdu = srsran::make_byte_buffer(); liblte_mme_pack_attach_complete_msg( &attach_complete, current_sec_hdr, ctxt.tx_count, (LIBLTE_BYTE_MSG_STRUCT*)pdu.get()); // Write NAS pcap @@ -1991,7 +1991,7 @@ void nas::send_attach_complete(const uint8_t& transaction_id_, const uint8_t& ep void nas::send_detach_accept() { - unique_byte_buffer_t pdu = srslte::make_byte_buffer(); + unique_byte_buffer_t pdu = srsran::make_byte_buffer(); if (!pdu) { logger.error("Fatal Error: Couldn't allocate PDU in %s().", __FUNCTION__); return; @@ -2016,7 +2016,7 @@ void nas::send_detach_accept() void nas::send_authentication_response(const uint8_t* res, const size_t res_len) { - unique_byte_buffer_t pdu = srslte::make_byte_buffer(); + unique_byte_buffer_t pdu = srsran::make_byte_buffer(); if (!pdu) { logger.error("Fatal Error: Couldn't allocate PDU in send_authentication_response()."); return; @@ -2047,7 +2047,7 @@ void nas::send_authentication_response(const uint8_t* res, const size_t res_len) void nas::send_authentication_failure(const uint8_t cause, const uint8_t* auth_fail_param) { - unique_byte_buffer_t msg = srslte::make_byte_buffer(); + unique_byte_buffer_t msg = srsran::make_byte_buffer(); if (!msg) { logger.error("Fatal Error: Couldn't allocate PDU in send_authentication_failure()."); return; @@ -2095,7 +2095,7 @@ void nas::send_identity_response(const uint8 id_type) return; } - unique_byte_buffer_t pdu = srslte::make_byte_buffer(); + unique_byte_buffer_t pdu = srsran::make_byte_buffer(); if (!pdu) { logger.error("Fatal Error: Couldn't allocate PDU in send_identity_response()."); return; @@ -2119,7 +2119,7 @@ void nas::send_identity_response(const uint8 id_type) void nas::send_service_request() { - unique_byte_buffer_t msg = srslte::make_byte_buffer(); + unique_byte_buffer_t msg = srsran::make_byte_buffer(); if (!msg) { logger.error("Fatal Error: Couldn't allocate PDU in send_service_request()."); return; @@ -2239,7 +2239,7 @@ void nas::send_esm_information_response(const uint8 proc_transaction_id) esm_info_resp.protocol_cnfg_opts_present = false; } - unique_byte_buffer_t pdu = srslte::make_byte_buffer(); + unique_byte_buffer_t pdu = srsran::make_byte_buffer(); if (!pdu) { logger.error("Fatal Error: Couldn't allocate PDU in %s.", __FUNCTION__); return; @@ -2270,7 +2270,7 @@ void nas::send_esm_information_response(const uint8 proc_transaction_id) void nas::send_activate_dedicated_eps_bearer_context_accept(const uint8_t& proc_transaction_id, const uint8_t& eps_bearer_id) { - unique_byte_buffer_t pdu = srslte::make_byte_buffer(); + unique_byte_buffer_t pdu = srsran::make_byte_buffer(); LIBLTE_MME_ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_ACCEPT_MSG_STRUCT accept = {}; @@ -2304,7 +2304,7 @@ void nas::send_activate_dedicated_eps_bearer_context_accept(const uint8_t& proc_ void nas::send_deactivate_eps_bearer_context_accept(const uint8_t& proc_transaction_id, const uint8_t& eps_bearer_id) { - unique_byte_buffer_t pdu = srslte::make_byte_buffer(); + unique_byte_buffer_t pdu = srsran::make_byte_buffer(); LIBLTE_MME_DEACTIVATE_EPS_BEARER_CONTEXT_ACCEPT_MSG_STRUCT accept = {}; @@ -2338,7 +2338,7 @@ void nas::send_deactivate_eps_bearer_context_accept(const uint8_t& proc_transact void nas::send_modify_eps_bearer_context_accept(const uint8_t& proc_transaction_id, const uint8_t& eps_bearer_id) { - unique_byte_buffer_t pdu = srslte::make_byte_buffer(); + unique_byte_buffer_t pdu = srsran::make_byte_buffer(); LIBLTE_MME_MODIFY_EPS_BEARER_CONTEXT_ACCEPT_MSG_STRUCT accept = {}; @@ -2372,7 +2372,7 @@ void nas::send_modify_eps_bearer_context_accept(const uint8_t& proc_transaction_ void nas::send_activate_test_mode_complete() { - unique_byte_buffer_t pdu = srslte::make_byte_buffer(); + unique_byte_buffer_t pdu = srsran::make_byte_buffer(); if (liblte_mme_pack_activate_test_mode_complete_msg( (LIBLTE_BYTE_MSG_STRUCT*)pdu.get(), current_sec_hdr, ctxt.tx_count)) { @@ -2397,7 +2397,7 @@ void nas::send_activate_test_mode_complete() void nas::send_close_ue_test_loop_complete() { - unique_byte_buffer_t pdu = srslte::make_byte_buffer(); + unique_byte_buffer_t pdu = srsran::make_byte_buffer(); if (liblte_mme_pack_close_ue_test_loop_complete_msg( (LIBLTE_BYTE_MSG_STRUCT*)pdu.get(), current_sec_hdr, ctxt.tx_count)) { diff --git a/srsue/src/stack/upper/nas_emm_state.cc b/srsue/src/stack/upper/nas_emm_state.cc index 67e4862c9..11aa9f320 100644 --- a/srsue/src/stack/upper/nas_emm_state.cc +++ b/srsue/src/stack/upper/nas_emm_state.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/srsue/src/stack/upper/nas_idle_procedures.cc b/srsue/src/stack/upper/nas_idle_procedures.cc index 796fe46e3..a2396af37 100644 --- a/srsue/src/stack/upper/nas_idle_procedures.cc +++ b/srsue/src/stack/upper/nas_idle_procedures.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,10 +11,10 @@ */ #include "srsue/hdr/stack/upper/nas_idle_procedures.h" -#include "srslte/common/standard_streams.h" -#include "srslte/interfaces/ue_rrc_interfaces.h" +#include "srsran/common/standard_streams.h" +#include "srsran/interfaces/ue_rrc_interfaces.h" -using namespace srslte; +using namespace srsran; #define ProcError(fmt, ...) nas_ptr->logger.error("Proc \"%s\" - " fmt, name(), ##__VA_ARGS__) #define ProcWarning(fmt, ...) nas_ptr->logger.warning("Proc \"%s\" - " fmt, name(), ##__VA_ARGS__) @@ -22,7 +22,7 @@ using namespace srslte; namespace srsue { -using srslte::proc_outcome_t; +using srsran::proc_outcome_t; /* * PLMN Selection Procedures @@ -45,7 +45,7 @@ proc_outcome_t nas::plmn_search_proc::step() return proc_outcome_t::yield; } -void nas::plmn_search_proc::then(const srslte::proc_state_t& result) +void nas::plmn_search_proc::then(const srsran::proc_state_t& result) { ProcInfo("Completed with %s", result.is_success() ? "success" : "failure"); @@ -77,7 +77,7 @@ proc_outcome_t nas::plmn_search_proc::react(const plmn_search_complete_t& t) for (int i = 0; i < t.nof_plmns; i++) { nas_ptr->known_plmns.push_back(t.found_plmns[i].plmn_id); ProcInfo("Found PLMN: Id=%s, TAC=%d", t.found_plmns[i].plmn_id.to_string().c_str(), t.found_plmns[i].tac); - srslte::console("Found PLMN: Id=%s, TAC=%d\n", t.found_plmns[i].plmn_id.to_string().c_str(), t.found_plmns[i].tac); + srsran::console("Found PLMN: Id=%s, TAC=%d\n", t.found_plmns[i].plmn_id.to_string().c_str(), t.found_plmns[i].tac); } nas_ptr->select_plmn(); diff --git a/srsue/src/stack/upper/pcsc_usim.cc b/srsue/src/stack/upper/pcsc_usim.cc index 8e70cbd89..111730207 100644 --- a/srsue/src/stack/upper/pcsc_usim.cc +++ b/srsue/src/stack/upper/pcsc_usim.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -12,14 +12,14 @@ #include -#include "srslte/common/bcd_helpers.h" -#include "srslte/common/standard_streams.h" +#include "srsran/common/bcd_helpers.h" +#include "srsran/common/standard_streams.h" #include "srsue/hdr/stack/upper/pcsc_usim.h" #include "string.h" #define CHECK_SIM_PIN 0 -using namespace srslte; +using namespace srsran; namespace srsue { @@ -40,9 +40,9 @@ pcsc_usim::~pcsc_usim() int pcsc_usim::init(usim_args_t* args) { - int ret = SRSLTE_ERROR; + int ret = SRSRAN_ERROR; - if (sc.init(args) != SRSLTE_SUCCESS) { + if (sc.init(args) != SRSRAN_SUCCESS) { return ret; } @@ -65,7 +65,7 @@ int pcsc_usim::init(usim_args_t* args) } } else { logger.error("Invalid length for IMSI: %zu should be %d", imsi_str.length(), 15); - srslte::console("Invalid length for IMSI: %zu should be %d\n", imsi_str.length(), 15); + srsran::console("Invalid length for IMSI: %zu should be %d\n", imsi_str.length(), 15); return ret; } @@ -79,12 +79,12 @@ int pcsc_usim::init(usim_args_t* args) } } else { logger.error("Invalid length for IMEI: %zu should be %d", args->imei.length(), 15); - srslte::console("Invalid length for IMEI: %zu should be %d\n", args->imei.length(), 15); + srsran::console("Invalid length for IMEI: %zu should be %d\n", args->imei.length(), 15); return ret; } initiated = true; - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; return ret; } @@ -171,7 +171,7 @@ std::string pcsc_usim::get_mnc_str(const uint8_t* imsi_vec, std::string mcc_str) // return 0 if initialization was successfull, -1 otherwies int pcsc_usim::scard::init(usim_args_t* args) { - int ret_value = SRSLTE_ERROR; + int ret_value = SRSRAN_ERROR; uint pos = 0; // SC reader bool reader_found = false; // int transaction = 1; @@ -384,7 +384,7 @@ int pcsc_usim::scard::init(usim_args_t* args) goto clean_exit; } - ret_value = SRSLTE_SUCCESS; + ret_value = SRSRAN_SUCCESS; clean_exit: if (readers) { diff --git a/srsue/src/stack/upper/tft_packet_filter.cc b/srsue/src/stack/upper/tft_packet_filter.cc index 3a85df9cb..a0de74636 100644 --- a/srsue/src/stack/upper/tft_packet_filter.cc +++ b/srsue/src/stack/upper/tft_packet_filter.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,10 +11,10 @@ */ #include "srsue/hdr/stack/upper/tft_packet_filter.h" -#include "srslte/upper/ipv6.h" +#include "srsran/upper/ipv6.h" extern "C" { -#include "srslte/config.h" +#include "srsran/config.h" } #include @@ -184,7 +184,7 @@ bool inline tft_packet_filter_t::filter_contains(uint16_t filtertype) * * Note: 'active_filters' is a bitmask; bits set to '1' represent active filter components. */ -bool tft_packet_filter_t::match(const srslte::unique_byte_buffer_t& pdu) +bool tft_packet_filter_t::match(const srsran::unique_byte_buffer_t& pdu) { uint16_t ip_flags = IPV4_REMOTE_ADDR_FLAG | IPV4_LOCAL_ADDR_FLAG | IPV6_REMOTE_ADDR_FLAG | IPV6_REMOTE_ADDR_LENGTH_FLAG | IPV6_LOCAL_ADDR_LENGTH_FLAG; @@ -219,7 +219,7 @@ bool tft_packet_filter_t::match(const srslte::unique_byte_buffer_t& pdu) return true; } -bool tft_packet_filter_t::match_ip(const srslte::unique_byte_buffer_t& pdu) +bool tft_packet_filter_t::match_ip(const srsran::unique_byte_buffer_t& pdu) { struct iphdr* ip_pkt = (struct iphdr*)pdu->msg; struct ipv6hdr* ip6_pkt = (struct ipv6hdr*)pdu->msg; @@ -256,7 +256,7 @@ bool tft_packet_filter_t::match_ip(const srslte::unique_byte_buffer_t& pdu) return true; } -bool tft_packet_filter_t::match_protocol(const srslte::unique_byte_buffer_t& pdu) +bool tft_packet_filter_t::match_protocol(const srsran::unique_byte_buffer_t& pdu) { struct iphdr* ip_pkt = (struct iphdr*)pdu->msg; struct ipv6hdr* ip6_pkt = (struct ipv6hdr*)pdu->msg; @@ -278,7 +278,7 @@ bool tft_packet_filter_t::match_protocol(const srslte::unique_byte_buffer_t& pdu return true; } -bool tft_packet_filter_t::match_type_of_service(const srslte::unique_byte_buffer_t& pdu) +bool tft_packet_filter_t::match_type_of_service(const srsran::unique_byte_buffer_t& pdu) { struct iphdr* ip_pkt = (struct iphdr*)pdu->msg; @@ -294,7 +294,7 @@ bool tft_packet_filter_t::match_type_of_service(const srslte::unique_byte_buffer return true; } -bool tft_packet_filter_t::match_flow_label(const srslte::unique_byte_buffer_t& pdu) +bool tft_packet_filter_t::match_flow_label(const srsran::unique_byte_buffer_t& pdu) { struct ipv6hdr* ip6_pkt = (struct ipv6hdr*)pdu->msg; @@ -307,7 +307,7 @@ bool tft_packet_filter_t::match_flow_label(const srslte::unique_byte_buffer_t& p return true; } -bool tft_packet_filter_t::match_port(const srslte::unique_byte_buffer_t& pdu) +bool tft_packet_filter_t::match_port(const srsran::unique_byte_buffer_t& pdu) { struct iphdr* ip_pkt = (struct iphdr*)pdu->msg; struct ipv6hdr* ip6_pkt = (struct ipv6hdr*)pdu->msg; @@ -380,7 +380,7 @@ bool tft_packet_filter_t::match_port(const srslte::unique_byte_buffer_t& pdu) return true; } -uint8_t tft_pdu_matcher::check_tft_filter_match(const srslte::unique_byte_buffer_t& pdu) +uint8_t tft_pdu_matcher::check_tft_filter_match(const srsran::unique_byte_buffer_t& pdu) { std::lock_guard lock(tft_mutex); uint8_t lcid = default_lcid; @@ -408,15 +408,15 @@ int tft_pdu_matcher::apply_traffic_flow_template(const uint8_t& auto it = tft_filter_map.insert(std::make_pair(filter.eval_precedence, filter)); if (it.second == false) { logger.error("Error inserting TFT Packet Filter"); - return SRSLTE_ERROR_CANT_START; + return SRSRAN_ERROR_CANT_START; } } break; default: logger.error("Unhandled TFT OP code"); - return SRSLTE_ERROR_CANT_START; + return SRSRAN_ERROR_CANT_START; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } void tft_pdu_matcher::set_default_lcid(const uint8_t lcid) diff --git a/srsue/src/stack/upper/usim.cc b/srsue/src/stack/upper/usim.cc index 5a6d9c06b..ea8686d6a 100644 --- a/srsue/src/stack/upper/usim.cc +++ b/srsue/src/stack/upper/usim.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,11 +11,11 @@ */ #include "srsue/hdr/stack/upper/usim.h" -#include "srslte/common/bcd_helpers.h" -#include "srslte/common/standard_streams.h" +#include "srsran/common/bcd_helpers.h" +#include "srsran/common/standard_streams.h" #include -using namespace srslte; +using namespace srsran; namespace srsue { @@ -38,7 +38,7 @@ int usim::init(usim_args_t* args) str_to_hex(args->k, k); } else { logger.error("Invalid length for K: %zu should be %d", args->k.length(), 32); - srslte::console("Invalid length for K: %zu should be %d\n", args->k.length(), 32); + srsran::console("Invalid length for K: %zu should be %d\n", args->k.length(), 32); } if (auth_algo == auth_algo_milenage) { @@ -48,14 +48,14 @@ int usim::init(usim_args_t* args) compute_opc(k, op, opc); } else { logger.error("Invalid length for OP: %zu should be %d", args->op.length(), 32); - srslte::console("Invalid length for OP: %zu should be %d\n", args->op.length(), 32); + srsran::console("Invalid length for OP: %zu should be %d\n", args->op.length(), 32); } } else { if (32 == args->opc.length()) { str_to_hex(args->opc, opc); } else { logger.error("Invalid length for OPc: %zu should be %d", args->opc.length(), 32); - srslte::console("Invalid length for OPc: %zu should be %d\n", args->opc.length(), 32); + srsran::console("Invalid length for OPc: %zu should be %d\n", args->opc.length(), 32); } } } @@ -68,7 +68,7 @@ int usim::init(usim_args_t* args) } } else { logger.error("Invalid length for IMSI: %zu should be %d", args->imsi.length(), 15); - srslte::console("Invalid length for IMSI: %zu should be %d\n", args->imsi.length(), 15); + srsran::console("Invalid length for IMSI: %zu should be %d\n", args->imsi.length(), 15); } if (15 == args->imei.length()) { @@ -79,12 +79,12 @@ int usim::init(usim_args_t* args) } } else { logger.error("Invalid length for IMEI: %zu should be %d", args->imei.length(), 15); - srslte::console("Invalid length for IMEI: %zu should be %d\n", args->imei.length(), 15); + srsran::console("Invalid length for IMEI: %zu should be %d\n", args->imei.length(), 15); } initiated = true; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } void usim::stop() {} diff --git a/srsue/src/stack/upper/usim_base.cc b/srsue/src/stack/upper/usim_base.cc index 051845daf..eef44aee6 100644 --- a/srsue/src/stack/upper/usim_base.cc +++ b/srsue/src/stack/upper/usim_base.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -97,7 +97,7 @@ std::string usim_base::get_mcc_str(const uint8_t* imsi_vec) return mcc_oss.str(); } -bool usim_base::get_home_plmn_id(srslte::plmn_id_t* home_plmn_id) +bool usim_base::get_home_plmn_id(srsran::plmn_id_t* home_plmn_id) { if (!initiated) { logger.error("USIM not initiated!"); @@ -124,8 +124,8 @@ bool usim_base::get_home_plmn_id(srslte::plmn_id_t* home_plmn_id) void usim_base::generate_nas_keys(uint8_t* k_asme, uint8_t* k_nas_enc, uint8_t* k_nas_int, - srslte::CIPHERING_ALGORITHM_ID_ENUM cipher_algo, - srslte::INTEGRITY_ALGORITHM_ID_ENUM integ_algo) + srsran::CIPHERING_ALGORITHM_ID_ENUM cipher_algo, + srsran::INTEGRITY_ALGORITHM_ID_ENUM integ_algo) { if (!initiated) { logger.error("USIM not initiated!"); @@ -139,7 +139,7 @@ void usim_base::generate_nas_keys(uint8_t* k_asme, /* * RRC Interface */ -void usim_base::generate_as_keys(uint8_t* k_asme_, uint32_t count_ul, srslte::as_security_config_t* sec_cfg) +void usim_base::generate_as_keys(uint8_t* k_asme_, uint32_t count_ul, srsran::as_security_config_t* sec_cfg) { if (!initiated) { logger.error("USIM not initiated!"); @@ -150,7 +150,7 @@ void usim_base::generate_as_keys(uint8_t* k_asme_, uint32_t count_ul, srslte::as logger.debug(k_asme_, 32, "K_asme"); // Generate K_enb - srslte::security_generate_k_enb(k_asme_, count_ul, k_enb_ctx.k_enb.data()); + srsran::security_generate_k_enb(k_asme_, count_ul, k_enb_ctx.k_enb.data()); memcpy(k_asme, k_asme_, 32); @@ -181,7 +181,7 @@ void usim_base::generate_as_keys(uint8_t* k_asme_, uint32_t count_ul, srslte::as logger.debug(sec_cfg->k_up_enc.data(), sec_cfg->k_up_enc.size(), "K_UP_enc"); } -void usim_base::generate_as_keys_ho(uint32_t pci, uint32_t earfcn, int ncc, srslte::as_security_config_t* sec_cfg) +void usim_base::generate_as_keys_ho(uint32_t pci, uint32_t earfcn, int ncc, srsran::as_security_config_t* sec_cfg) { if (!initiated) { logger.error("USIM not initiated!"); @@ -210,7 +210,7 @@ void usim_base::generate_as_keys_ho(uint32_t pci, uint32_t earfcn, int ncc, srsl logger.debug(k_enb_ctx.nh.data(), 32, "NH:"); // Generate NH - srslte::security_generate_nh(k_asme, sync, k_enb_ctx.nh.data()); + srsran::security_generate_nh(k_asme, sync, k_enb_ctx.nh.data()); k_enb_ctx.ncc++; if (k_enb_ctx.ncc == 8) { @@ -220,7 +220,7 @@ void usim_base::generate_as_keys_ho(uint32_t pci, uint32_t earfcn, int ncc, srsl } // Generate K_enb - srslte::security_generate_k_enb_star(enb_star_key, pci, earfcn, k_enb_star); + srsran::security_generate_k_enb_star(enb_star_key, pci, earfcn, k_enb_star); // K_enb becomes K_enb* memcpy(k_enb_ctx.k_enb.data(), k_enb_star, 32); @@ -244,7 +244,7 @@ void usim_base::generate_as_keys_ho(uint32_t pci, uint32_t earfcn, int ncc, srsl logger.info(sec_cfg->k_rrc_int.data(), sec_cfg->k_rrc_int.size(), "HO K_RRC_int"); } -void usim_base::store_keys_before_ho(const srslte::as_security_config_t& as_ctx) +void usim_base::store_keys_before_ho(const srsran::as_security_config_t& as_ctx) { logger.info("Storing AS Keys pre-handover. NCC=%d", k_enb_ctx.ncc); logger.info(k_enb_ctx.k_enb.data(), 32, "Old K_eNB"); @@ -257,7 +257,7 @@ void usim_base::store_keys_before_ho(const srslte::as_security_config_t& as_ctx) return; } -void usim_base::restore_keys_from_failed_ho(srslte::as_security_config_t* as_ctx) +void usim_base::restore_keys_from_failed_ho(srsran::as_security_config_t* as_ctx) { logger.info("Restoring Keys from failed handover. NCC=%d", old_k_enb_ctx.ncc); *as_ctx = old_as_ctx; @@ -269,7 +269,7 @@ void usim_base::restore_keys_from_failed_ho(srslte::as_security_config_t* as_ctx * NR RRC Interface */ -void usim_base::generate_nr_context(uint16_t sk_counter, srslte::as_security_config_t* sec_cfg) +void usim_base::generate_nr_context(uint16_t sk_counter, srsran::as_security_config_t* sec_cfg) { if (!initiated) { logger.error("USIM not initiated!"); @@ -277,12 +277,12 @@ void usim_base::generate_nr_context(uint16_t sk_counter, srslte::as_security_con } logger.info("Generating Keys. SCG Counter %d", sk_counter); - srslte::security_generate_sk_gnb(k_enb_ctx.k_enb.data(), k_gnb_ctx.sk_gnb.data(), sk_counter); + srsran::security_generate_sk_gnb(k_enb_ctx.k_enb.data(), k_gnb_ctx.sk_gnb.data(), sk_counter); logger.info(k_gnb_ctx.sk_gnb.data(), 32, "k_sk_gnb"); update_nr_context(sec_cfg); } -void usim_base::update_nr_context(srslte::as_security_config_t* sec_cfg) +void usim_base::update_nr_context(srsran::as_security_config_t* sec_cfg) { if (!initiated) { logger.error("USIM not initiated!"); diff --git a/srsue/src/ue.cc b/srsue/src/ue.cc index 653747612..94a4e344f 100644 --- a/srsue/src/ue.cc +++ b/srsue/src/ue.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -11,12 +11,12 @@ */ #include "srsue/hdr/ue.h" -#include "srslte/build_info.h" -#include "srslte/common/band_helper.h" -#include "srslte/common/string_helpers.h" -#include "srslte/radio/radio.h" -#include "srslte/radio/radio_null.h" -#include "srslte/srslte.h" +#include "srsran/build_info.h" +#include "srsran/common/band_helper.h" +#include "srsran/common/string_helpers.h" +#include "srsran/radio/radio.h" +#include "srsran/radio/radio_null.h" +#include "srsran/srsran.h" #include "srsue/hdr/phy/phy.h" #include "srsue/hdr/phy/vnf_phy_nr.h" #include "srsue/hdr/stack/ue_stack_lte.h" @@ -25,7 +25,7 @@ #include #include -using namespace srslte; +using namespace srsran; namespace srsue { @@ -42,7 +42,7 @@ ue::~ue() int ue::init(const all_args_t& args_) { - int ret = SRSLTE_SUCCESS; + int ret = SRSRAN_SUCCESS; // Init UE log logger.set_level(srslog::basic_levels::info); @@ -50,46 +50,46 @@ int ue::init(const all_args_t& args_) // Validate arguments if (parse_args(args_)) { - srslte::console("Error processing arguments. Please check %s for more details.\n", args_.log.filename.c_str()); - return SRSLTE_ERROR; + srsran::console("Error processing arguments. Please check %s for more details.\n", args_.log.filename.c_str()); + return SRSRAN_ERROR; } // Instantiate layers and stack together our UE if (args.stack.type == "lte") { std::unique_ptr lte_stack(new ue_stack_lte); if (!lte_stack) { - srslte::console("Error creating LTE stack instance.\n"); - return SRSLTE_ERROR; + srsran::console("Error creating LTE stack instance.\n"); + return SRSRAN_ERROR; } std::unique_ptr gw_ptr(new gw()); if (!gw_ptr) { - srslte::console("Error creating a GW instance.\n"); - return SRSLTE_ERROR; + srsran::console("Error creating a GW instance.\n"); + return SRSRAN_ERROR; } std::unique_ptr lte_phy = std::unique_ptr(new srsue::phy); if (!lte_phy) { - srslte::console("Error creating LTE PHY instance.\n"); - return SRSLTE_ERROR; + srsran::console("Error creating LTE PHY instance.\n"); + return SRSRAN_ERROR; } - std::unique_ptr lte_radio = std::unique_ptr(new srslte::radio); + std::unique_ptr lte_radio = std::unique_ptr(new srsran::radio); if (!lte_radio) { - srslte::console("Error creating radio multi instance.\n"); - return SRSLTE_ERROR; + srsran::console("Error creating radio multi instance.\n"); + return SRSRAN_ERROR; } // init layers if (lte_radio->init(args.rf, lte_phy.get())) { - srslte::console("Error initializing radio.\n"); - return SRSLTE_ERROR; + srsran::console("Error initializing radio.\n"); + return SRSRAN_ERROR; } // from here onwards do not exit immediately if something goes wrong as sub-layers may already use interfaces if (lte_phy->init(args.phy, lte_stack.get(), lte_radio.get())) { - srslte::console("Error initializing PHY.\n"); - ret = SRSLTE_ERROR; + srsran::console("Error initializing PHY.\n"); + ret = SRSRAN_ERROR; } srsue::phy_args_nr_t phy_args_nr = {}; @@ -99,18 +99,18 @@ int ue::init(const all_args_t& args_) phy_args_nr.worker_cpu_mask = args.phy.worker_cpu_mask; phy_args_nr.log = args.phy.log; if (lte_phy->init(phy_args_nr, lte_stack.get(), lte_radio.get())) { - srslte::console("Error initializing NR PHY.\n"); - ret = SRSLTE_ERROR; + srsran::console("Error initializing NR PHY.\n"); + ret = SRSRAN_ERROR; } if (lte_stack->init(args.stack, lte_phy.get(), lte_phy.get(), gw_ptr.get())) { - srslte::console("Error initializing stack.\n"); - ret = SRSLTE_ERROR; + srsran::console("Error initializing stack.\n"); + ret = SRSRAN_ERROR; } if (gw_ptr->init(args.gw, lte_stack.get())) { - srslte::console("Error initializing GW.\n"); - ret = SRSLTE_ERROR; + srsran::console("Error initializing GW.\n"); + ret = SRSRAN_ERROR; } // move ownership @@ -121,29 +121,29 @@ int ue::init(const all_args_t& args_) } else if (args.stack.type == "nr") { logger.info("Initializing NR stack"); std::unique_ptr nr_stack(new srsue::ue_stack_nr()); - std::unique_ptr nr_radio(new srslte::radio_null); + std::unique_ptr nr_radio(new srsran::radio_null); std::unique_ptr nr_phy(new srsue::vnf_phy_nr); std::unique_ptr gw_ptr(new gw()); // Init layers if (nr_radio->init(args.rf, nullptr)) { - srslte::console("Error initializing radio.\n"); - return SRSLTE_ERROR; + srsran::console("Error initializing radio.\n"); + return SRSRAN_ERROR; } if (nr_phy->init(args.phy, nr_stack.get())) { - srslte::console("Error initializing PHY.\n"); - return SRSLTE_ERROR; + srsran::console("Error initializing PHY.\n"); + return SRSRAN_ERROR; } if (nr_stack->init(args.stack, nr_phy.get(), gw_ptr.get())) { - srslte::console("Error initializing stack.\n"); - return SRSLTE_ERROR; + srsran::console("Error initializing stack.\n"); + return SRSRAN_ERROR; } if (gw_ptr->init(args.gw, nr_stack.get())) { - srslte::console("Error initializing GW.\n"); - return SRSLTE_ERROR; + srsran::console("Error initializing GW.\n"); + return SRSRAN_ERROR; } // move ownership @@ -152,14 +152,14 @@ int ue::init(const all_args_t& args_) phy = std::move(nr_phy); radio = std::move(nr_radio); } else { - srslte::console("Invalid stack type %s. Supported values are [lte].\n", args.stack.type.c_str()); - ret = SRSLTE_ERROR; + srsran::console("Invalid stack type %s. Supported values are [lte].\n", args.stack.type.c_str()); + ret = SRSRAN_ERROR; } if (phy) { - srslte::console("Waiting PHY to initialize ... "); + srsran::console("Waiting PHY to initialize ... "); phy->wait_initialize(); - srslte::console("done!\n"); + srsran::console("done!\n"); } return ret; @@ -176,29 +176,29 @@ int ue::parse_args(const all_args_t& args_) logger.error("interpolate_subframe_enabled = %d, While using MBMS, " "please set interpolate_subframe_enabled to true", args.phy.interpolate_subframe_enabled); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if (args.phy.nof_phy_threads > 2) { logger.error("nof_phy_threads = %d, While using MBMS, please set " "number of phy threads to 1 or 2", args.phy.nof_phy_threads); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } if ((0 == args.phy.snr_estim_alg.find("refs"))) { logger.error("snr_estim_alg = refs, While using MBMS, please set " "algorithm to pss or empty"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } } - if (args.rf.nof_antennas > SRSLTE_MAX_PORTS) { - fprintf(stderr, "Maximum number of antennas exceeded (%d > %d)\n", args.rf.nof_antennas, SRSLTE_MAX_PORTS); - return SRSLTE_ERROR; + if (args.rf.nof_antennas > SRSRAN_MAX_PORTS) { + fprintf(stderr, "Maximum number of antennas exceeded (%d > %d)\n", args.rf.nof_antennas, SRSRAN_MAX_PORTS); + return SRSRAN_ERROR; } - if (args.rf.nof_carriers > SRSLTE_MAX_CARRIERS) { - fprintf(stderr, "Maximum number of carriers exceeded (%d > %d)\n", args.rf.nof_carriers, SRSLTE_MAX_CARRIERS); - return SRSLTE_ERROR; + if (args.rf.nof_carriers > SRSRAN_MAX_CARRIERS) { + fprintf(stderr, "Maximum number of carriers exceeded (%d > %d)\n", args.rf.nof_carriers, SRSRAN_MAX_CARRIERS); + return SRSRAN_ERROR; } if (args.rf.nof_carriers <= args.phy.nof_nr_carriers) { @@ -206,7 +206,7 @@ int ue::parse_args(const all_args_t& args_) "Maximum number of carriers enough for NR and LTE (%d <= %d)\n", args.rf.nof_carriers, args.phy.nof_nr_carriers); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // replicate some RF parameter to make them available to PHY @@ -217,12 +217,12 @@ int ue::parse_args(const all_args_t& args_) // populate DL EARFCN list if (not args.phy.dl_earfcn.empty()) { // Parse DL-EARFCN list - srslte::string_parse_list(args.phy.dl_earfcn, ',', args.phy.dl_earfcn_list); + srsran::string_parse_list(args.phy.dl_earfcn, ',', args.phy.dl_earfcn_list); // Populates supported bands args.stack.rrc.nof_supported_bands = 0; for (uint32_t& earfcn : args.phy.dl_earfcn_list) { - uint8_t band = srslte_band_get_band(earfcn); + uint8_t band = srsran_band_get_band(earfcn); // Try to find band, if not appends it if (std::find(args.stack.rrc.supported_bands.begin(), args.stack.rrc.supported_bands.end(), band) == args.stack.rrc.supported_bands.end()) { @@ -231,29 +231,29 @@ int ue::parse_args(const all_args_t& args_) } } else { logger.error("Error: dl_earfcn list is empty"); - srslte::console("Error: dl_earfcn list is empty\n"); - return SRSLTE_ERROR; + srsran::console("Error: dl_earfcn list is empty\n"); + return SRSRAN_ERROR; } // populate UL EARFCN list if (not args.phy.ul_earfcn.empty()) { std::vector ul_earfcn_list; - srslte::string_parse_list(args.phy.ul_earfcn, ',', ul_earfcn_list); + srsran::string_parse_list(args.phy.ul_earfcn, ',', ul_earfcn_list); // For each parsed UL-EARFCN links it to the corresponding DL-EARFCN args.phy.ul_earfcn_map.clear(); - for (size_t i = 0; i < SRSLTE_MIN(ul_earfcn_list.size(), args.phy.dl_earfcn_list.size()); i++) { + for (size_t i = 0; i < SRSRAN_MIN(ul_earfcn_list.size(), args.phy.dl_earfcn_list.size()); i++) { args.phy.ul_earfcn_map[args.phy.dl_earfcn_list[i]] = ul_earfcn_list[i]; } } - srslte_band_helper bands_helper; + srsran_band_helper bands_helper; // populate NR DL ARFCNs if (args.phy.nof_nr_carriers > 0) { if (not args.phy.dl_nr_arfcn.empty()) { // Parse list - srslte::string_parse_list(args.phy.dl_nr_arfcn, ',', args.phy.dl_nr_arfcn_list); + srsran::string_parse_list(args.phy.dl_nr_arfcn, ',', args.phy.dl_nr_arfcn_list); // Populates supported bands for (uint32_t& arfcn : args.phy.dl_nr_arfcn_list) { @@ -268,8 +268,8 @@ int ue::parse_args(const all_args_t& args_) } } else { logger.error("Error: dl_nr_arfcn list is empty"); - srslte::console("Error: dl_nr_arfcn list is empty\n"); - return SRSLTE_ERROR; + srsran::console("Error: dl_nr_arfcn list is empty\n"); + return SRSRAN_ERROR; } } @@ -279,7 +279,7 @@ int ue::parse_args(const all_args_t& args_) // Consider Carrier Aggregation support if more than one args.stack.rrc.support_ca = (args.phy.nof_lte_carriers > 1); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } void ue::stop() @@ -333,15 +333,15 @@ bool ue::get_metrics(ue_metrics_t* m) std::string ue::get_build_mode() { - return std::string(srslte_get_build_mode()); + return std::string(srsran_get_build_mode()); } std::string ue::get_build_info() { - if (std::string(srslte_get_build_info()).find(" ") != std::string::npos) { - return std::string(srslte_get_version()); + if (std::string(srsran_get_build_info()).find(" ") != std::string::npos) { + return std::string(srsran_get_version()); } - return std::string(srslte_get_build_info()); + return std::string(srsran_get_build_info()); } std::string ue::get_build_string() diff --git a/srsue/test/CMakeLists.txt b/srsue/test/CMakeLists.txt index 307b1b74f..4f86437d1 100644 --- a/srsue/test/CMakeLists.txt +++ b/srsue/test/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -15,9 +15,9 @@ if (ENABLE_TTCN3) endif (ENABLE_TTCN3) add_executable(metrics_test metrics_test.cc ../src/metrics_stdout.cc ../src/metrics_csv.cc) -target_link_libraries(metrics_test srslte_phy srslte_common) +target_link_libraries(metrics_test srsran_phy srsran_common) add_test(metrics_test metrics_test -o ${CMAKE_CURRENT_BINARY_DIR}/ue_metrics.csv) add_executable(mac_test mac_test.cc) -target_link_libraries(mac_test srsue_mac srsue_phy srslte_common srslte_mac srslte_phy srslte_radio srslte_asn1 rrc_asn1 ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES}) +target_link_libraries(mac_test srsue_mac srsue_phy srsran_common srsran_mac srsran_phy srsran_radio srsran_asn1 rrc_asn1 ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES}) add_test(mac_test mac_test) \ No newline at end of file diff --git a/srsue/test/mac_nr/CMakeLists.txt b/srsue/test/mac_nr/CMakeLists.txt index cd87e0084..a1a2c6e53 100644 --- a/srsue/test/mac_nr/CMakeLists.txt +++ b/srsue/test/mac_nr/CMakeLists.txt @@ -7,5 +7,5 @@ # add_executable(proc_ra_nr_test proc_ra_nr_test.cc) -target_link_libraries(proc_ra_nr_test srsue_mac_nr srslte_common) +target_link_libraries(proc_ra_nr_test srsue_mac_nr srsran_common) add_test(proc_ra_nr_test proc_ra_nr_test) \ No newline at end of file diff --git a/srsue/test/mac_nr/proc_ra_nr_test.cc b/srsue/test/mac_nr/proc_ra_nr_test.cc index 7374c85bf..1f663afaf 100644 --- a/srsue/test/mac_nr/proc_ra_nr_test.cc +++ b/srsue/test/mac_nr/proc_ra_nr_test.cc @@ -2,16 +2,16 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of * the distribution. * */ -#include "srslte/common/buffer_pool.h" -#include "srslte/common/common.h" -#include "srslte/common/test_common.h" +#include "srsran/common/buffer_pool.h" +#include "srsran/common/common.h" +#include "srsran/common/test_common.h" #include "srsue/hdr/stack/mac_nr/proc_ra_nr.h" using namespace srsue; @@ -30,7 +30,7 @@ public: preamble_received_target_power = preamble_received_target_power_; } int tx_request(const tx_request_t& request) override { return 0; } - int set_ul_grant(std::array, uint16_t rnti, srslte_rnti_type_t rnti_type) override + int set_ul_grant(std::array, uint16_t rnti, srsran_rnti_type_t rnti_type) override { return 0; } @@ -64,7 +64,7 @@ public: void msga_flush(){}; private: - uint16_t crnti = SRSLTE_INVALID_RNTI; + uint16_t crnti = SRSRAN_INVALID_RNTI; }; int main() @@ -76,14 +76,14 @@ int main() dummy_phy dummy_phy; dummy_mac dummy_mac; - srslte::task_scheduler task_sched{5, 2}; - srslte::ext_task_sched_handle ext_task_sched_h(&task_sched); + srsran::task_scheduler task_sched{5, 2}; + srsran::ext_task_sched_handle ext_task_sched_h(&task_sched); proc_ra_nr proc_ra_nr(mac_logger); proc_ra_nr.init(&dummy_phy, &dummy_mac, &ext_task_sched_h); TESTASSERT(proc_ra_nr.is_rar_opportunity(1) == false); - srslte::rach_nr_cfg_t rach_cfg; + srsran::rach_nr_cfg_t rach_cfg; rach_cfg.powerRampingStep = 4; rach_cfg.prach_ConfigurationIndex = 16; rach_cfg.PreambleReceivedTargetPower = -110; @@ -122,7 +122,7 @@ int main() grant.tti = rach_cfg.ra_responseWindow + tti_start + 3; grant.pid = 0x0123; uint8_t mac_dl_rar_pdu[] = {0x40, 0x06, 0x68, 0x03, 0x21, 0x46, 0x46, 0x02, 0x00, 0x00, 0x00}; - grant.tb[0] = srslte::make_byte_buffer(); + grant.tb[0] = srsran::make_byte_buffer(); grant.tb[0].get()->append_bytes(mac_dl_rar_pdu, sizeof(mac_dl_rar_pdu)); proc_ra_nr.handle_rar_pdu(grant); @@ -133,5 +133,5 @@ int main() task_sched.tic(); task_sched.run_pending_tasks(); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } diff --git a/srsue/test/mac_test.cc b/srsue/test/mac_test.cc index 85dca15db..2d8ff2b2d 100644 --- a/srsue/test/mac_test.cc +++ b/srsue/test/mac_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,24 +10,24 @@ * */ -#include "srslte/asn1/rrc/rr_common.h" -#include "srslte/asn1/rrc_utils.h" -#include "srslte/common/mac_pcap.h" -#include "srslte/common/test_common.h" -#include "srslte/test/ue_test_interfaces.h" +#include "srsran/asn1/rrc/rr_common.h" +#include "srsran/asn1/rrc_utils.h" +#include "srsran/common/mac_pcap.h" +#include "srsran/common/test_common.h" +#include "srsran/test/ue_test_interfaces.h" #include "srsue/hdr/stack/mac/mac.h" #include "srsue/hdr/stack/mac/mux.h" #include #include using namespace srsue; -using namespace srslte; +using namespace srsran; #define HAVE_PCAP 0 -static std::unique_ptr pcap_handle = nullptr; +static std::unique_ptr pcap_handle = nullptr; -namespace srslte { +namespace srsran { // fake classes class rlc_dummy : public srsue::rlc_dummy_interface @@ -46,7 +46,7 @@ public: nof_bytes = read_len; } - uint32_t len = SRSLTE_MIN(ul_queues[lcid], nof_bytes); + uint32_t len = SRSRAN_MIN(ul_queues[lcid], nof_bytes); // set payload bytes to LCID so we can check later if the scheduling was correct memset(payload, lcid > 0 ? lcid : 0xf, len); @@ -147,9 +147,9 @@ public: void set_timeadv_rar(uint32_t tti, uint32_t ta_cmd) override { rar_time_adv = ta_cmd; } void set_timeadv(uint32_t tti, uint32_t ta_cmd) override{}; void set_activation_deactivation_scell(uint32_t cmd, uint32_t tti) override { scell_cmd = cmd; }; - void set_rar_grant(uint8_t grant_payload[SRSLTE_RAR_GRANT_LEN], uint16_t rnti) override + void set_rar_grant(uint8_t grant_payload[SRSRAN_RAR_GRANT_LEN], uint16_t rnti) override { - memcpy(rar_payload, grant_payload, SRSLTE_RAR_GRANT_LEN); + memcpy(rar_payload, grant_payload, SRSRAN_RAR_GRANT_LEN); rar_temp_rnti = rnti; nof_rar_grants++; } @@ -164,7 +164,7 @@ public: // Testing methods int dl_grant(mac* mac_h, bool ack, uint16_t rnti, uint32_t len, const uint8_t* payload) { - bool ack_v[SRSLTE_MAX_CODEWORDS] = {ack, 0}; + bool ack_v[SRSRAN_MAX_CODEWORDS] = {ack, 0}; mac_interface_phy_lte::tb_action_dl_t dl_action = {}; mac_interface_phy_lte::mac_grant_dl_t dl_mac_grant = {}; @@ -176,7 +176,7 @@ public: dl_mac_grant.tb[0].tbs = len; mac_h->new_grant_dl(0, dl_mac_grant, &dl_action); - if (ack && !SRSLTE_RNTI_ISRAR(rnti)) { + if (ack && !SRSRAN_RNTI_ISRAR(rnti)) { dl_ndi = !dl_ndi; } @@ -201,11 +201,11 @@ public: int rar_and_check(mac* mac_h, bool preamble_matches, uint32_t temp_rnti) { // Generate RAR to MAC - uint8_t grant[SRSLTE_RAR_GRANT_LEN] = {1}; + uint8_t grant[SRSRAN_RAR_GRANT_LEN] = {1}; uint32_t rar_timeadv = 16; - srslte::rar_pdu rar_pdu_msg; + srsran::rar_pdu rar_pdu_msg; byte_buffer.clear(); rar_pdu_msg.init_tx(&byte_buffer, 7); if (rar_pdu_msg.new_subh()) { @@ -221,7 +221,7 @@ public: // Check MAC passes RAR grant and TA cmd to PHY if (preamble_matches) { - TESTASSERT(!memcmp(rar_payload, grant, SRSLTE_RAR_GRANT_LEN)); + TESTASSERT(!memcmp(rar_payload, grant, SRSRAN_RAR_GRANT_LEN)); TESTASSERT(rar_temp_rnti == temp_rnti); TESTASSERT(rar_time_adv == rar_timeadv); } @@ -307,7 +307,7 @@ private: uint32_t nof_rar_grants = 0; uint32_t rar_time_adv = 0; uint16_t rar_temp_rnti = 0; - uint8_t rar_payload[SRSLTE_RAR_GRANT_LEN]; + uint8_t rar_payload[SRSRAN_RAR_GRANT_LEN]; }; class rrc_dummy : public rrc_interface_mac @@ -341,7 +341,7 @@ private: mac* mac_h = nullptr; }; -} // namespace srslte +} // namespace srsran int mac_unpack_test() { @@ -387,7 +387,7 @@ int mac_unpack_test() mac.new_grant_dl(cc_idx, mac_grant, &dl_action); // Copy PDU into provided buffer - bool dl_ack[SRSLTE_MAX_CODEWORDS] = {true, false}; + bool dl_ack[SRSRAN_MAX_CODEWORDS] = {true, false}; memcpy(dl_action.tb[0].payload, dl_sch_pdu, sizeof(dl_sch_pdu)); dl_action.tb[0].enabled = true; mac.tb_decoded(cc_idx, mac_grant, dl_ack); @@ -402,7 +402,7 @@ int mac_unpack_test() // check received SCell activation command TESTASSERT(phy.get_scell_cmd() == 2); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Basic test with a single padding byte and a 10B SCH SDU @@ -454,7 +454,7 @@ int mac_ul_sch_pdu_test1() stack.run_tti(0); mac.stop(); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Basic logical channel prioritization test with 3 SCH SDUs @@ -548,7 +548,7 @@ int mac_ul_logical_channel_prioritization_test1() stack.run_tti(0); mac.stop(); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Similar test like above but with a much larger UL grant, we expect that each LCID is fully served @@ -651,7 +651,7 @@ int mac_ul_logical_channel_prioritization_test2() stack.run_tti(0); mac.stop(); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Basic logical channel prioritization test with 2 SCH SDUs @@ -737,7 +737,7 @@ int mac_ul_logical_channel_prioritization_test3() stack.run_tti(0); mac.stop(); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Manual excecution of TC 7.1.4.6 of 36.523-1 @@ -887,7 +887,7 @@ int mac_ul_logical_channel_prioritization_test4() stack.run_tti(0); mac.stop(); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // PDU with single SDU and short BSR (entire RLC buffers are transmitted in MAC PDU) @@ -944,7 +944,7 @@ int mac_ul_sch_pdu_with_short_bsr_test() stack.run_tti(tti); mac.stop(); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // PDU with single SDU and short BSR reporting zero data to transmit @@ -1001,7 +1001,7 @@ int mac_ul_sch_pdu_with_short_bsr_zero_test() stack.run_tti(tti); mac.stop(); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // PDU with only padding BSR (long BSR) and the rest padding @@ -1051,7 +1051,7 @@ int mac_ul_sch_pdu_with_padding_long_bsr_test() stack.run_tti(0); mac.stop(); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // PDU SDU and Long BSR as padding (indicating that more data is ready to be sent) @@ -1123,7 +1123,7 @@ int mac_ul_sch_pdu_with_padding_long_bsr_test2() stack.run_tti(0); mac.stop(); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // PDU with truncated BSR as two LCGs have data to transmit @@ -1205,7 +1205,7 @@ int mac_ul_sch_pdu_with_padding_trunc_bsr_test() stack.run_tti(0); mac.stop(); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Test correct operation of retx BSR timer @@ -1347,7 +1347,7 @@ int mac_ul_sch_regular_bsr_retx_test() stack.run_tti(tti); mac.stop(); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } /** @@ -1624,7 +1624,7 @@ int mac_ul_sch_periodic_bsr_test() stack.run_tti(tti); mac.stop(); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } /** @@ -1790,7 +1790,7 @@ int mac_ul_sch_trunc_bsr_test2() stack.run_tti(tti); mac.stop(); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Single byte MAC PDU @@ -1842,7 +1842,7 @@ int mac_ul_sch_pdu_one_byte_test() stack.run_tti(0); mac.stop(); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Two byte MAC PDU @@ -1894,7 +1894,7 @@ int mac_ul_sch_pdu_two_byte_test() stack.run_tti(0); mac.stop(); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Three byte MAC PDU (Single byte padding, SDU header, 1 B SDU) @@ -1946,7 +1946,7 @@ int mac_ul_sch_pdu_three_byte_test() stack.run_tti(0); mac.stop(); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } struct ra_test { @@ -1968,7 +1968,7 @@ struct ra_test { struct ra_test test; -int run_mac_ra_test(struct ra_test test, mac* mac, phy_dummy* phy, uint32_t* tti_state, srslte::stack_dummy* stack) +int run_mac_ra_test(struct ra_test test, mac* mac, phy_dummy* phy, uint32_t* tti_state, srsran::stack_dummy* stack) { uint32_t tti = *tti_state; @@ -2007,7 +2007,7 @@ int run_mac_ra_test(struct ra_test test, mac* mac, phy_dummy* phy, uint32_t* tti // Check MAC does not schedule RA-RNTI before window starts for (uint32_t i = 0; i < phy->prach_delay + 3 - 1 + test.rar_offset; i++) { stack->run_tti(tti); - TESTASSERT(!SRSLTE_RNTI_ISRAR(mac->get_dl_sched_rnti(tti))); + TESTASSERT(!SRSRAN_RNTI_ISRAR(mac->get_dl_sched_rnti(tti))); tti++; } @@ -2146,7 +2146,7 @@ int mac_random_access_test() mac mac("MAC", &stack.task_sched); stack.init(&mac, &phy); mac.init(&phy, &rlc, &rrc); - srslte::mac_cfg_t mac_cfg; + srsran::mac_cfg_t mac_cfg; set_mac_cfg_t_rach_cfg_common(&mac_cfg, rach_cfg); mac.set_config(mac_cfg); @@ -2335,13 +2335,13 @@ int mac_random_access_test() mac.stop(); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int main(int argc, char** argv) { #if HAVE_PCAP - pcap_handle = std::unique_ptr(new srslte::mac_pcap()); + pcap_handle = std::unique_ptr(new srsran::mac_pcap()); pcap_handle->open("mac_test.pcap"); #endif @@ -2356,25 +2356,25 @@ int main(int argc, char** argv) phy_logger.set_hex_dump_max_size(100000); srslog::init(); - TESTASSERT(mac_unpack_test() == SRSLTE_SUCCESS); - TESTASSERT(mac_ul_sch_pdu_test1() == SRSLTE_SUCCESS); - TESTASSERT(mac_ul_logical_channel_prioritization_test1() == SRSLTE_SUCCESS); - TESTASSERT(mac_ul_logical_channel_prioritization_test2() == SRSLTE_SUCCESS); - TESTASSERT(mac_ul_logical_channel_prioritization_test3() == SRSLTE_SUCCESS); - TESTASSERT(mac_ul_logical_channel_prioritization_test4() == SRSLTE_SUCCESS); - TESTASSERT(mac_ul_sch_pdu_with_short_bsr_test() == SRSLTE_SUCCESS); - TESTASSERT(mac_ul_sch_pdu_with_padding_long_bsr_test() == SRSLTE_SUCCESS); - TESTASSERT(mac_ul_sch_pdu_with_padding_long_bsr_test2() == SRSLTE_SUCCESS); - TESTASSERT(mac_ul_sch_pdu_with_padding_trunc_bsr_test() == SRSLTE_SUCCESS); - TESTASSERT(mac_ul_sch_regular_bsr_retx_test() == SRSLTE_SUCCESS); - TESTASSERT(mac_ul_sch_periodic_bsr_test() == SRSLTE_SUCCESS); - TESTASSERT(mac_ul_sch_trunc_bsr_test2() == SRSLTE_SUCCESS); - TESTASSERT(mac_ul_sch_pdu_one_byte_test() == SRSLTE_SUCCESS); - TESTASSERT(mac_ul_sch_pdu_two_byte_test() == SRSLTE_SUCCESS); - TESTASSERT(mac_ul_sch_pdu_three_byte_test() == SRSLTE_SUCCESS); + TESTASSERT(mac_unpack_test() == SRSRAN_SUCCESS); + TESTASSERT(mac_ul_sch_pdu_test1() == SRSRAN_SUCCESS); + TESTASSERT(mac_ul_logical_channel_prioritization_test1() == SRSRAN_SUCCESS); + TESTASSERT(mac_ul_logical_channel_prioritization_test2() == SRSRAN_SUCCESS); + TESTASSERT(mac_ul_logical_channel_prioritization_test3() == SRSRAN_SUCCESS); + TESTASSERT(mac_ul_logical_channel_prioritization_test4() == SRSRAN_SUCCESS); + TESTASSERT(mac_ul_sch_pdu_with_short_bsr_test() == SRSRAN_SUCCESS); + TESTASSERT(mac_ul_sch_pdu_with_padding_long_bsr_test() == SRSRAN_SUCCESS); + TESTASSERT(mac_ul_sch_pdu_with_padding_long_bsr_test2() == SRSRAN_SUCCESS); + TESTASSERT(mac_ul_sch_pdu_with_padding_trunc_bsr_test() == SRSRAN_SUCCESS); + TESTASSERT(mac_ul_sch_regular_bsr_retx_test() == SRSRAN_SUCCESS); + TESTASSERT(mac_ul_sch_periodic_bsr_test() == SRSRAN_SUCCESS); + TESTASSERT(mac_ul_sch_trunc_bsr_test2() == SRSRAN_SUCCESS); + TESTASSERT(mac_ul_sch_pdu_one_byte_test() == SRSRAN_SUCCESS); + TESTASSERT(mac_ul_sch_pdu_two_byte_test() == SRSRAN_SUCCESS); + TESTASSERT(mac_ul_sch_pdu_three_byte_test() == SRSRAN_SUCCESS); phy_logger.set_level(srslog::basic_levels::debug); - TESTASSERT(mac_random_access_test() == SRSLTE_SUCCESS); + TESTASSERT(mac_random_access_test() == SRSRAN_SUCCESS); phy_logger.set_level(srslog::basic_levels::none); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } diff --git a/srsue/test/metrics_test.cc b/srsue/test/metrics_test.cc index 4a951ad3d..fad64c1a2 100644 --- a/srsue/test/metrics_test.cc +++ b/srsue/test/metrics_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,8 +10,8 @@ * */ -#include "srslte/common/metrics_hub.h" -#include "srslte/srslte.h" +#include "srsran/common/metrics_hub.h" +#include "srsran/srsran.h" #include "srsue/hdr/metrics_csv.h" #include "srsue/hdr/metrics_stdout.h" #include "srsue/hdr/ue_metrics_interface.h" @@ -114,7 +114,7 @@ int main(int argc, char** argv) metrics_file.set_ue_handle(&ue); // create metrics hub and register metrics for stdout - srslte::metrics_hub metricshub; + srsran::metrics_hub metricshub; metricshub.init(&ue, period); metricshub.add_listener(&metrics_screen); metricshub.add_listener(&metrics_file); diff --git a/srsue/test/phy/CMakeLists.txt b/srsue/test/phy/CMakeLists.txt index e53a43ab3..8656910d6 100644 --- a/srsue/test/phy/CMakeLists.txt +++ b/srsue/test/phy/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -22,9 +22,9 @@ link_directories( add_executable(ue_phy_test ue_phy_test.cc) target_link_libraries(ue_phy_test srsue_phy - srslte_common - srslte_phy - srslte_radio + srsran_common + srsran_phy + srsran_radio ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES}) # Test disabled, it is not 100 deterministic. @@ -33,9 +33,9 @@ target_link_libraries(ue_phy_test add_executable(scell_search_test scell_search_test.cc) target_link_libraries(scell_search_test srsue_phy - srslte_common - srslte_phy - srslte_radio + srsran_common + srsran_phy + srsran_radio ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES}) add_lte_test(scell_search_test scell_search_test --duration=5 --cell.nof_prb=6 --active_cell_list=2,3,4,5,6 --simulation_cell_list=1,2,3,4,5,6 --channel_period_s=30 --channel.hst.fd=750 --channel.delay_max=10000) diff --git a/srsue/test/phy/scell_search_test.cc b/srsue/test/phy/scell_search_test.cc index f70ee8a24..e8528c12a 100644 --- a/srsue/test/phy/scell_search_test.cc +++ b/srsue/test/phy/scell_search_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,27 +10,27 @@ * */ -#include "srslte/interfaces/phy_interface_types.h" -#include "srslte/srslog/srslog.h" +#include "srsran/interfaces/phy_interface_types.h" +#include "srsran/srslog/srslog.h" #include "srsue/hdr/phy/scell/intra_measure.h" #include #include #include #include #include -#include -#include +#include +#include #include // Common execution parameters static uint32_t duration_execution_s; -static srslte_cell_t cell_base = {.nof_prb = 6, +static srsran_cell_t cell_base = {.nof_prb = 6, .nof_ports = 1, .id = 0, - .cp = SRSLTE_CP_NORM, - .phich_length = SRSLTE_PHICH_NORM, - .phich_resources = SRSLTE_PHICH_R_1_6, - .frame_type = SRSLTE_FDD}; + .cp = SRSRAN_CP_NORM, + .phich_length = SRSRAN_PHICH_NORM, + .phich_resources = SRSRAN_PHICH_R_1_6, + .frame_type = SRSRAN_FDD}; static std::string intra_meas_log_level; static std::string active_cell_list; static std::string simulation_cell_list; @@ -56,7 +56,7 @@ static std::string channel_log_level; // Simulation Serving cell PDSCH parameters static bool serving_cell_pdsch_enable; static uint16_t serving_cell_pdsch_rnti; -static srslte_tm_t serving_cell_pdsch_tm; +static srsran_tm_t serving_cell_pdsch_tm; static uint16_t serving_cell_pdsch_mcs; // Parsed PCI lists @@ -79,7 +79,7 @@ unsigned int reverse(unsigned int x) uint32_t prbset_to_bitmask() { uint32_t mask = 0; - auto nb = (uint32_t)ceilf((float)cell_base.nof_prb / srslte_ra_type0_P(cell_base.nof_prb)); + auto nb = (uint32_t)ceilf((float)cell_base.nof_prb / srsran_ra_type0_P(cell_base.nof_prb)); for (uint32_t i = 0; i < nb; i++) { if (i >= prbset_orig && i < prbset_orig + prbset_num) { mask = mask | ((uint32_t)0x1 << i); @@ -92,109 +92,109 @@ uint32_t prbset_to_bitmask() class test_enb { private: - srslte_enb_dl_t enb_dl; - srslte::channel_ptr channel; - cf_t* signal_buffer[SRSLTE_MAX_PORTS] = {}; + srsran_enb_dl_t enb_dl; + srsran::channel_ptr channel; + cf_t* signal_buffer[SRSRAN_MAX_PORTS] = {}; srslog::basic_logger& logger; public: - test_enb(const srslte_cell_t& cell, const srslte::channel::args_t& channel_args) : + test_enb(const srsran_cell_t& cell, const srsran::channel::args_t& channel_args) : enb_dl(), logger(srslog::fetch_basic_logger("Channel pci=" + std::to_string(cell.id))) { logger.set_level(srslog::str_to_basic_level(channel_log_level)); - channel = srslte::channel_ptr(new srslte::channel(channel_args, cell_base.nof_ports, logger)); - channel->set_srate(srslte_sampling_freq_hz(cell.nof_prb)); + channel = srsran::channel_ptr(new srsran::channel(channel_args, cell_base.nof_ports, logger)); + channel->set_srate(srsran_sampling_freq_hz(cell.nof_prb)); // Allocate buffer for eNb for (uint32_t i = 0; i < cell_base.nof_ports; i++) { - signal_buffer[i] = srslte_vec_cf_malloc(SRSLTE_SF_LEN_PRB(cell_base.nof_prb)); + signal_buffer[i] = srsran_vec_cf_malloc(SRSRAN_SF_LEN_PRB(cell_base.nof_prb)); if (!signal_buffer[i]) { ERROR("Error allocating buffer"); } } - if (srslte_enb_dl_init(&enb_dl, signal_buffer, cell.nof_prb)) { + if (srsran_enb_dl_init(&enb_dl, signal_buffer, cell.nof_prb)) { ERROR("Error initiating eNb downlink"); } - if (srslte_enb_dl_set_cell(&enb_dl, cell)) { + if (srsran_enb_dl_set_cell(&enb_dl, cell)) { ERROR("Error setting eNb DL cell"); } } - int work(srslte_dl_sf_cfg_t* dl_sf, - srslte_dci_cfg_t* dci_cfg, - srslte_dci_dl_t* dci, - srslte_softbuffer_tx_t** softbuffer_tx, + int work(srsran_dl_sf_cfg_t* dl_sf, + srsran_dci_cfg_t* dci_cfg, + srsran_dci_dl_t* dci, + srsran_softbuffer_tx_t** softbuffer_tx, uint8_t** data_tx, cf_t* baseband_buffer, - const srslte::rf_timestamp_t& ts) + const srsran::rf_timestamp_t& ts) { - int ret = SRSLTE_SUCCESS; - uint32_t sf_len = SRSLTE_SF_LEN_PRB(enb_dl.cell.nof_prb); + int ret = SRSRAN_SUCCESS; + uint32_t sf_len = SRSRAN_SF_LEN_PRB(enb_dl.cell.nof_prb); - srslte_enb_dl_put_base(&enb_dl, dl_sf); + srsran_enb_dl_put_base(&enb_dl, dl_sf); // Put PDSCH only if it is required if (dci && dci_cfg && softbuffer_tx && data_tx) { - if (srslte_enb_dl_put_pdcch_dl(&enb_dl, dci_cfg, dci)) { + if (srsran_enb_dl_put_pdcch_dl(&enb_dl, dci_cfg, dci)) { ERROR("Error putting PDCCH sf_idx=%d", dl_sf->tti); - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } // Create pdsch config - srslte_pdsch_cfg_t pdsch_cfg; - if (srslte_ra_dl_dci_to_grant(&enb_dl.cell, dl_sf, serving_cell_pdsch_tm, false, dci, &pdsch_cfg.grant)) { + srsran_pdsch_cfg_t pdsch_cfg; + if (srsran_ra_dl_dci_to_grant(&enb_dl.cell, dl_sf, serving_cell_pdsch_tm, false, dci, &pdsch_cfg.grant)) { ERROR("Computing DL grant sf_idx=%d", dl_sf->tti); - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } char str[512]; - srslte_dci_dl_info(dci, str, 512); + srsran_dci_dl_info(dci, str, 512); INFO("eNb PDCCH: rnti=0x%x, %s", serving_cell_pdsch_rnti, str); - for (uint32_t i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { + for (uint32_t i = 0; i < SRSRAN_MAX_CODEWORDS; i++) { pdsch_cfg.softbuffers.tx[i] = softbuffer_tx[i]; } // Enable power allocation pdsch_cfg.power_scale = true; pdsch_cfg.p_a = 0.0f; // 0 dB - pdsch_cfg.p_b = (serving_cell_pdsch_tm > SRSLTE_TM1) ? 1 : 0; // 0 dB + pdsch_cfg.p_b = (serving_cell_pdsch_tm > SRSRAN_TM1) ? 1 : 0; // 0 dB pdsch_cfg.rnti = serving_cell_pdsch_rnti; pdsch_cfg.meas_time_en = false; - if (srslte_enb_dl_put_pdsch(&enb_dl, &pdsch_cfg, data_tx) < 0) { + if (srsran_enb_dl_put_pdsch(&enb_dl, &pdsch_cfg, data_tx) < 0) { ERROR("Error putting PDSCH sf_idx=%d", dl_sf->tti); - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } - srslte_pdsch_tx_info(&pdsch_cfg, str, 512); + srsran_pdsch_tx_info(&pdsch_cfg, str, 512); INFO("eNb PDSCH: rnti=0x%x, %s", serving_cell_pdsch_rnti, str); } - srslte_enb_dl_gen_signal(&enb_dl); + srsran_enb_dl_gen_signal(&enb_dl); // Apply channel channel->run(signal_buffer, signal_buffer, sf_len, ts.get(0)); // Combine Tx ports for (uint32_t i = 1; i < enb_dl.cell.nof_ports; i++) { - srslte_vec_sum_ccc(signal_buffer[0], signal_buffer[i], signal_buffer[0], sf_len); + srsran_vec_sum_ccc(signal_buffer[0], signal_buffer[i], signal_buffer[0], sf_len); } - // Undo srslte_enb_dl_gen_signal scaling + // Undo srsran_enb_dl_gen_signal scaling float scale = sqrtf(cell_base.nof_prb) / 0.05f / enb_dl.ifft->cfg.symbol_sz; // Apply Neighbour cell attenuation if (enb_dl.cell.id != *pcis_to_simulate.begin()) { - scale *= srslte_convert_dB_to_amplitude(-ncell_attenuation_dB); + scale *= srsran_convert_dB_to_amplitude(-ncell_attenuation_dB); } // Scale signal - srslte_vec_sc_prod_cfc(signal_buffer[0], scale, signal_buffer[0], sf_len); + srsran_vec_sc_prod_cfc(signal_buffer[0], scale, signal_buffer[0], sf_len); // Add signal to baseband buffer - srslte_vec_sum_ccc(signal_buffer[0], baseband_buffer, baseband_buffer, sf_len); + srsran_vec_sum_ccc(signal_buffer[0], baseband_buffer, baseband_buffer, sf_len); return ret; } @@ -208,7 +208,7 @@ public: } } - srslte_enb_dl_free(&enb_dl); + srsran_enb_dl_free(&enb_dl); } }; @@ -241,12 +241,12 @@ public: cells[pci].rsrq_avg = m.rsrq; cells[pci].count = 1; } else { - cells[pci].rsrp_min = SRSLTE_MIN(cells[pci].rsrp_min, m.rsrp); - cells[pci].rsrp_max = SRSLTE_MAX(cells[pci].rsrp_max, m.rsrp); + cells[pci].rsrp_min = SRSRAN_MIN(cells[pci].rsrp_min, m.rsrp); + cells[pci].rsrp_max = SRSRAN_MAX(cells[pci].rsrp_max, m.rsrp); cells[pci].rsrp_avg = (m.rsrp + cells[pci].rsrp_avg * cells[pci].count) / (cells[pci].count + 1); - cells[pci].rsrq_min = SRSLTE_MIN(cells[pci].rsrq_min, m.rsrq); - cells[pci].rsrq_max = SRSLTE_MAX(cells[pci].rsrq_max, m.rsrq); + cells[pci].rsrq_min = SRSRAN_MIN(cells[pci].rsrq_min, m.rsrq); + cells[pci].rsrq_max = SRSRAN_MAX(cells[pci].rsrq_max, m.rsrq); cells[pci].rsrq_avg = (m.rsrq + cells[pci].rsrq_avg * cells[pci].count) / (cells[pci].count + 1); cells[pci].count++; } @@ -298,7 +298,7 @@ namespace bpo = boost::program_options; int parse_args(int argc, char** argv) { - int ret = SRSLTE_SUCCESS; + int ret = SRSRAN_SUCCESS; bpo::options_description options; bpo::options_description common("Common execution options"); @@ -313,7 +313,7 @@ int parse_args(int argc, char** argv) ("intra_meas_log_level", bpo::value(&intra_meas_log_level)->default_value("none"), "Intra measurement log level (none, warning, info, debug)") ("intra_freq_meas_len_ms", bpo::value(&phy_args.intra_freq_meas_len_ms)->default_value(20), "Intra measurement measurement length") ("intra_freq_meas_period_ms", bpo::value(&phy_args.intra_freq_meas_period_ms)->default_value(200), "Intra measurement measurement period") - ("phy_lib_log_level", bpo::value(&phy_lib_log_level)->default_value(SRSLTE_VERBOSE_NONE), "Phy lib log level (0: none, 1: info, 2: debug)") + ("phy_lib_log_level", bpo::value(&phy_lib_log_level)->default_value(SRSRAN_VERBOSE_NONE), "Phy lib log level (0: none, 1: info, 2: debug)") ("active_cell_list", bpo::value(&active_cell_list)->default_value("10,17,24,31,38,45,52"), "Comma separated neighbour PCI cell list") ; @@ -337,7 +337,7 @@ int parse_args(int argc, char** argv) ("channel.log_level", bpo::value(&channel_log_level)->default_value("info"), "Channel simulator logging level") ("serving_cell_pdsch_enable", bpo::value(&serving_cell_pdsch_enable)->default_value(true), "Enable simulated PDSCH in serving cell") ("serving_cell_pdsch_rnti", bpo::value(&serving_cell_pdsch_rnti)->default_value(0x1234), "Simulated PDSCH RNTI") - ("serving_cell_pdsch_tm", bpo::value((int*) &serving_cell_pdsch_tm)->default_value(SRSLTE_TM1), "Simulated Transmission mode 0: TM1, 1: TM2, 2: TM3, 3: TM4") + ("serving_cell_pdsch_tm", bpo::value((int*) &serving_cell_pdsch_tm)->default_value(SRSRAN_TM1), "Simulated Transmission mode 0: TM1, 1: TM2, 2: TM3, 3: TM4") ("serving_cell_pdsch_mcs", bpo::value(&serving_cell_pdsch_mcs)->default_value(20), "Simulated PDSCH MCS") ; @@ -352,14 +352,14 @@ int parse_args(int argc, char** argv) bpo::notify(vm); } catch (bpo::error& e) { std::cerr << e.what() << std::endl; - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } // help option was given or error - print usage and exit if (vm.count("help") || ret) { std::cout << "Usage: " << argv[0] << " [OPTIONS] config_file" << std::endl << std::endl; std::cout << options << std::endl << std::endl; - ret = SRSLTE_ERROR; + ret = SRSRAN_ERROR; } return ret; @@ -376,10 +376,10 @@ static void pci_list_parse_helper(std::string& list_str, std::set& lis // Do nothing } else if (not list_str.empty()) { // Remove spaces from neightbour cell list - list_str = srslte::string_remove_char(list_str, ' '); + list_str = srsran::string_remove_char(list_str, ' '); // Add cell to known cells - srslte::string_parse_list(list_str, ',', list); + srsran::string_parse_list(list_str, ',', list); } } @@ -389,26 +389,26 @@ int main(int argc, char** argv) // Parse args if (parse_args(argc, argv)) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Common for simulation and over-the-air srslog::basic_logger& logger = srslog::fetch_basic_logger("intra_measure"); srslog::init(); - cf_t* baseband_buffer = srslte_vec_cf_malloc(SRSLTE_SF_LEN_MAX); - srslte::rf_timestamp_t ts = {}; + cf_t* baseband_buffer = srsran_vec_cf_malloc(SRSRAN_SF_LEN_MAX); + srsran::rf_timestamp_t ts = {}; srsue::scell::intra_measure intra_measure(logger); meas_itf_listener rrc; srsue::phy_common common(logger); // Simulation only std::vector > test_enb_v; - uint8_t* data_tx[SRSLTE_MAX_TB] = {}; - srslte_softbuffer_tx_t* softbuffer_tx[SRSLTE_MAX_TB] = {}; + uint8_t* data_tx[SRSRAN_MAX_TB] = {}; + srsran_softbuffer_tx_t* softbuffer_tx[SRSRAN_MAX_TB] = {}; // Over-the-air only - std::unique_ptr radio = nullptr; + std::unique_ptr radio = nullptr; // Set Receiver args common.args = &phy_args; @@ -432,32 +432,32 @@ int main(int argc, char** argv) phy_args.rx_gain_offset = rx_gain + 62.0f; // Set phy-lib logging level - srslte_verbose = phy_lib_log_level; + srsran_verbose = phy_lib_log_level; // Allocate PDSCH data and tx-soft-buffers only if pdsch is enabled and radio is not available - for (int i = 0; i < SRSLTE_MAX_TB && serving_cell_pdsch_enable && radio == nullptr; i++) { - srslte_random_t random_gen = srslte_random_init(serving_cell_pdsch_rnti); + for (int i = 0; i < SRSRAN_MAX_TB && serving_cell_pdsch_enable && radio == nullptr; i++) { + srsran_random_t random_gen = srsran_random_init(serving_cell_pdsch_rnti); const size_t nof_bytes = (6144 * 16 * 3 / 8); - softbuffer_tx[i] = (srslte_softbuffer_tx_t*)calloc(sizeof(srslte_softbuffer_tx_t), 1); + softbuffer_tx[i] = (srsran_softbuffer_tx_t*)calloc(sizeof(srsran_softbuffer_tx_t), 1); if (!softbuffer_tx[i]) { ERROR("Error allocating softbuffer_tx"); } - if (srslte_softbuffer_tx_init(softbuffer_tx[i], cell_base.nof_prb)) { + if (srsran_softbuffer_tx_init(softbuffer_tx[i], cell_base.nof_prb)) { ERROR("Error initiating softbuffer_tx"); } - data_tx[i] = srslte_vec_u8_malloc(nof_bytes); + data_tx[i] = srsran_vec_u8_malloc(nof_bytes); if (!data_tx[i]) { ERROR("Error allocating data tx"); } else { for (uint32_t j = 0; j < nof_bytes; j++) { - data_tx[i][j] = (uint8_t)srslte_random_uniform_int_dist(random_gen, 0, 255); + data_tx[i][j] = (uint8_t)srsran_random_uniform_int_dist(random_gen, 0, 255); } } - srslte_random_free(random_gen); + srsran_random_free(random_gen); } pci_list_parse_helper(active_cell_list, pcis_to_meas); @@ -470,7 +470,7 @@ int main(int argc, char** argv) logger.set_level(srslog::str_to_basic_level(intra_meas_log_level)); intra_measure.init(0, &common, &rrc); - intra_measure.set_primary_cell(SRSLTE_MAX(earfcn_dl, 0), cell_base); + intra_measure.set_primary_cell(SRSRAN_MAX(earfcn_dl, 0), cell_base); if (earfcn_dl >= 0) { // Create radio log @@ -478,10 +478,10 @@ int main(int argc, char** argv) radio_logger.set_level(srslog::str_to_basic_level(radio_log_level)); // Create radio - radio = std::unique_ptr(new srslte::radio); + radio = std::unique_ptr(new srsran::radio); // Init radio - srslte::rf_args_t radio_args = {}; + srsran::rf_args_t radio_args = {}; radio_args.device_args = radio_device_args; radio_args.device_name = radio_device_name; radio_args.nof_carriers = 1; @@ -489,10 +489,10 @@ int main(int argc, char** argv) radio->init(radio_args, nullptr); // Set sampling rate - radio->set_rx_srate(srslte_sampling_freq_hz(cell_base.nof_prb)); + radio->set_rx_srate(srsran_sampling_freq_hz(cell_base.nof_prb)); // Set frequency - radio->set_rx_freq(0, srslte_band_fd(earfcn_dl) * 1e6); + radio->set_rx_freq(0, srsran_band_fd(earfcn_dl) * 1e6); } else { // Create test eNb's if radio is not available @@ -500,11 +500,11 @@ int main(int argc, char** argv) float channel_delay_us = 0; for (const auto& pci : pcis_to_simulate) { // Initialise cell - srslte_cell_t cell = cell_base; + srsran_cell_t cell = cell_base; cell.id = pci; // Initialise channel and push back - srslte::channel::args_t channel_args; + srsran::channel::args_t channel_args; channel_args.enable = (channel_period_s != 0); channel_args.hst_enable = std::isnormal(channel_hst_fd_hz); channel_args.hst_init_time_s = channel_init_time_s; @@ -516,7 +516,7 @@ int main(int argc, char** argv) channel_args.delay_period_s = (uint32_t)channel_period_s; channel_args.delay_init_time_s = channel_init_time_s; channel_args.awgn_enable = std::isnormal(channel_snr_db) and (pci == *pcis_to_simulate.begin()); - channel_args.awgn_signal_power_dBfs = srslte_enb_dl_get_maximum_signal_power_dBfs(cell.nof_prb); + channel_args.awgn_signal_power_dBfs = srsran_enb_dl_get_maximum_signal_power_dBfs(cell.nof_prb); channel_args.awgn_snr_dB = channel_snr_db; test_enb_v.push_back(std::unique_ptr(new test_enb(cell, channel_args))); @@ -537,17 +537,17 @@ int main(int argc, char** argv) // Run loop for (uint32_t sf_idx = 0; sf_idx < duration_execution_s * 1000; sf_idx++) { - srslte_dl_sf_cfg_t sf_cfg_dl = {}; + srsran_dl_sf_cfg_t sf_cfg_dl = {}; sf_cfg_dl.tti = sf_idx % 10240; sf_cfg_dl.cfi = cfi; - sf_cfg_dl.sf_type = SRSLTE_SF_NORM; + sf_cfg_dl.sf_type = SRSRAN_SF_NORM; // Clean buffer - srslte_vec_cf_zero(baseband_buffer, SRSLTE_SF_LEN_MAX); + srsran_vec_cf_zero(baseband_buffer, SRSRAN_SF_LEN_MAX); if (radio) { // Receive radio - srslte::rf_buffer_t radio_buffer(baseband_buffer, SRSLTE_SF_LEN_PRB(cell_base.nof_prb)); + srsran::rf_buffer_t radio_buffer(baseband_buffer, SRSRAN_SF_LEN_PRB(cell_base.nof_prb)); radio->rx_now(radio_buffer, ts); } else { // Run eNb simulator @@ -559,8 +559,8 @@ int main(int argc, char** argv) put_pdsch = false; // DCI Configuration - srslte_dci_dl_t dci; - srslte_dci_cfg_t dci_cfg; + srsran_dci_dl_t dci; + srsran_dci_cfg_t dci_cfg; dci_cfg.srs_request_enabled = false; dci_cfg.ra_format_enabled = false; dci_cfg.multiple_csi_request_enabled = false; @@ -585,34 +585,34 @@ int main(int argc, char** argv) dci_cfg.cif_enabled = false; // Set PRB Allocation type - dci.alloc_type = SRSLTE_RA_ALLOC_TYPE0; - prbset_num = (int)ceilf((float)cell_base.nof_prb / srslte_ra_type0_P(cell_base.nof_prb)); + dci.alloc_type = SRSRAN_RA_ALLOC_TYPE0; + prbset_num = (int)ceilf((float)cell_base.nof_prb / srsran_ra_type0_P(cell_base.nof_prb)); last_prbset_num = prbset_num; dci.type0_alloc.rbg_bitmask = prbset_to_bitmask(); dci.location.L = 0; dci.location.ncce = 0; // Set TB - if (serving_cell_pdsch_tm < SRSLTE_TM3) { - dci.format = SRSLTE_DCI_FORMAT1; + if (serving_cell_pdsch_tm < SRSRAN_TM3) { + dci.format = SRSRAN_DCI_FORMAT1; dci.tb[0].mcs_idx = serving_cell_pdsch_mcs; dci.tb[0].rv = 0; dci.tb[0].ndi = false; dci.tb[0].cw_idx = 0; dci.tb[1].mcs_idx = 0; dci.tb[1].rv = 1; - } else if (serving_cell_pdsch_tm == SRSLTE_TM3) { - dci.format = SRSLTE_DCI_FORMAT2A; - for (uint32_t i = 0; i < SRSLTE_MAX_TB; i++) { + } else if (serving_cell_pdsch_tm == SRSRAN_TM3) { + dci.format = SRSRAN_DCI_FORMAT2A; + for (uint32_t i = 0; i < SRSRAN_MAX_TB; i++) { dci.tb[i].mcs_idx = serving_cell_pdsch_mcs; dci.tb[i].rv = 0; dci.tb[i].ndi = false; dci.tb[i].cw_idx = i; } - } else if (serving_cell_pdsch_tm == SRSLTE_TM4) { - dci.format = SRSLTE_DCI_FORMAT2; + } else if (serving_cell_pdsch_tm == SRSRAN_TM4) { + dci.format = SRSRAN_DCI_FORMAT2; dci.pinfo = 0; - for (uint32_t i = 0; i < SRSLTE_MAX_TB; i++) { + for (uint32_t i = 0; i < SRSRAN_MAX_TB; i++) { dci.tb[i].mcs_idx = serving_cell_pdsch_mcs; dci.tb[i].rv = 0; dci.tb[i].ndi = false; @@ -634,7 +634,7 @@ int main(int argc, char** argv) ts.add(0.001); // Give data to intra measure component - intra_measure.write(sf_idx % 10240, baseband_buffer, SRSLTE_SF_LEN_PRB(cell_base.nof_prb)); + intra_measure.write(sf_idx % 10240, baseband_buffer, SRSRAN_SF_LEN_PRB(cell_base.nof_prb)); if (sf_idx % 1000 == 0) { printf("Done %.1f%%\n", (double)sf_idx * 100.0 / ((double)duration_execution_s * 1000.0)); } @@ -648,7 +648,7 @@ int main(int argc, char** argv) // Stop, it will block until the asynchronous thread quits intra_measure.stop(); - ret = rrc.print_stats() ? SRSLTE_SUCCESS : SRSLTE_ERROR; + ret = rrc.print_stats() ? SRSRAN_SUCCESS : SRSRAN_ERROR; if (radio) { radio->stop(); @@ -665,7 +665,7 @@ int main(int argc, char** argv) } for (auto& sb : softbuffer_tx) { if (sb) { - srslte_softbuffer_tx_free(sb); + srsran_softbuffer_tx_free(sb); free(sb); } } diff --git a/srsue/test/phy/ue_phy_test.cc b/srsue/test/phy/ue_phy_test.cc index e843c3ed4..83f3e98f3 100644 --- a/srsue/test/phy/ue_phy_test.cc +++ b/srsue/test/phy/ue_phy_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,12 +10,12 @@ * */ -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include #define CALLBACK(NAME, ...) \ @@ -52,7 +52,7 @@ private: received_##NAME = true; \ } -class phy_test_bench : public srslte::thread +class phy_test_bench : public srsran::thread { private: // Dummy classes @@ -103,7 +103,7 @@ private: void tb_decoded(uint32_t cc_idx, mac_grant_dl_t grant, bool* ack) override {} void bch_decoded_ok(uint32_t cc_idx, uint8_t* payload, uint32_t len) override {} void mch_decoded(uint32_t len, bool crc) override {} - void new_mch_dl(const srslte_pdsch_grant_t& phy_grant, tb_action_dl_t* action) override {} + void new_mch_dl(const srsran_pdsch_grant_t& phy_grant, tb_action_dl_t* action) override {} void set_mbsfn_config(uint32_t nof_mbsfn_services) override {} void run_tti(const uint32_t tti, const uint32_t tti_jump) override { @@ -138,11 +138,11 @@ private: bool last_cell_select = false, last_config = false, last_scell = false; }; - class dummy_radio : public srslte::radio_interface_phy + class dummy_radio : public srsran::radio_interface_phy { private: srslog::basic_logger& logger; - std::vector ring_buffers; + std::vector ring_buffers; float base_srate = 0.0f; float tx_srate = 0.0f; float rx_srate = 0.0f; @@ -153,8 +153,8 @@ private: uint64_t rx_timestamp = 0; std::mutex mutex; std::condition_variable cvar; - srslte_rf_info_t rf_info = {}; - srslte::rf_timestamp_t tx_last_tx = {}; + srsran_rf_info_t rf_info = {}; + srsran::rf_timestamp_t tx_last_tx = {}; uint32_t count_late = 0; CALLBACK(rx_now) @@ -167,13 +167,13 @@ private: { // Create Ring buffers for (auto& rb : ring_buffers) { - if (srslte_ringbuffer_init(&rb, (uint32_t)sizeof(cf_t) * SRSLTE_SF_LEN_MAX * SRSLTE_NOF_SF_X_FRAME)) { + if (srsran_ringbuffer_init(&rb, (uint32_t)sizeof(cf_t) * SRSRAN_SF_LEN_MAX * SRSRAN_NOF_SF_X_FRAME)) { perror("init softbuffer"); } } // Create temporal buffer - temp_buffer = srslte_vec_cf_malloc(SRSLTE_SF_LEN_MAX * SRSLTE_NOF_SF_X_FRAME); + temp_buffer = srsran_vec_cf_malloc(SRSRAN_SF_LEN_MAX * SRSRAN_NOF_SF_X_FRAME); if (!temp_buffer) { perror("malloc"); } @@ -188,7 +188,7 @@ private: ~dummy_radio() { for (auto& rb : ring_buffers) { - srslte_ringbuffer_free(&rb); + srsran_ringbuffer_free(&rb); } if (temp_buffer) { free(temp_buffer); @@ -200,19 +200,19 @@ private: void write_ring_buffers(cf_t** buffer, uint32_t nsamples) { for (uint32_t i = 0; i < ring_buffers.size(); i++) { - int ret = SRSLTE_SUCCESS; + int ret = SRSRAN_SUCCESS; do { - if (ret != SRSLTE_SUCCESS) { + if (ret != SRSRAN_SUCCESS) { logger.error("Ring buffer write failed (full). Trying again."); } - ret = srslte_ringbuffer_write_timed(&ring_buffers[i], buffer[i], (uint32_t)sizeof(cf_t) * nsamples, 1000); - } while (ret == SRSLTE_ERROR_TIMEOUT); + ret = srsran_ringbuffer_write_timed(&ring_buffers[i], buffer[i], (uint32_t)sizeof(cf_t) * nsamples, 1000); + } while (ret == SRSRAN_ERROR_TIMEOUT); } } uint32_t get_count_late() { return count_late; } - bool tx(srslte::rf_buffer_interface& buffer, const srslte::rf_timestamp_interface& tx_time) override + bool tx(srsran::rf_buffer_interface& buffer, const srsran::rf_timestamp_interface& tx_time) override { bool ret = true; notify_tx(); @@ -221,7 +221,7 @@ private: if (!std::isnormal(tx_srate)) { count_late++; } - if (srslte_timestamp_compare(&tx_time.get(0), tx_last_tx.get_ptr(0)) < 0) { + if (srsran_timestamp_compare(&tx_time.get(0), tx_last_tx.get_ptr(0)) < 0) { ret = false; } @@ -234,7 +234,7 @@ private: } void release_freq(const uint32_t& carrier_idx) override{}; void tx_end() override {} - bool rx_now(srslte::rf_buffer_interface& buffer, srslte::rf_timestamp_interface& rxd_time) override + bool rx_now(srsran::rf_buffer_interface& buffer, srsran::rf_timestamp_interface& rxd_time) override { notify_rx_now(); @@ -245,7 +245,7 @@ private: cf_t* buf_ptr = ((buffer.get(i) != nullptr) && (base_srate == rx_srate)) ? buffer.get(i) : temp_buffer; // Read base srate samples - int ret = srslte_ringbuffer_read(&ring_buffers[i], buf_ptr, (uint32_t)sizeof(cf_t) * base_nsamples); + int ret = srsran_ringbuffer_read(&ring_buffers[i], buf_ptr, (uint32_t)sizeof(cf_t) * base_nsamples); if (ret < 0) { logger.error("Reading ring buffer"); } else { @@ -277,7 +277,7 @@ private: } // Set Rx timestamp - srslte_timestamp_init_uint64(rxd_time.get_ptr(0), rx_timestamp, (double)base_srate); + srsran_timestamp_init_uint64(rxd_time.get_ptr(0), rx_timestamp, (double)base_srate); // Update timestamp rx_timestamp += base_nsamples; @@ -299,19 +299,19 @@ private: void set_rx_gain_th(const float& gain) override { std::unique_lock lock(mutex); - rx_gain = srslte_convert_dB_to_amplitude(gain); + rx_gain = srsran_convert_dB_to_amplitude(gain); logger.info("Set Rx gain-th to %+.1f dB (%.6f).", gain, rx_gain); } void set_tx_gain(const float& gain) override { std::unique_lock lock(mutex); - rx_gain = srslte_convert_dB_to_amplitude(gain); + rx_gain = srsran_convert_dB_to_amplitude(gain); logger.info("Set Tx gain to %+.1f dB (%.6f).", gain, rx_gain); } void set_rx_gain(const float& gain) override { std::unique_lock lock(mutex); - rx_gain = srslte_convert_dB_to_amplitude(gain); + rx_gain = srsran_convert_dB_to_amplitude(gain); logger.info("Set Rx gain to %+.1f dB (%.6f).", gain, rx_gain); } void set_tx_srate(const double& srate) override @@ -330,14 +330,14 @@ private: float get_rx_gain() override { std::unique_lock lock(mutex); - return srslte_convert_amplitude_to_dB(rx_gain); + return srsran_convert_amplitude_to_dB(rx_gain); } double get_freq_offset() override { return 0; } bool is_continuous_tx() override { return false; } bool get_is_start_of_burst() override { return false; } bool is_init() override { return false; } void reset() override {} - srslte_rf_info_t* get_info() override { return &rf_info; } + srsran_rf_info_t* get_info() override { return &rf_info; } }; // Common instances @@ -351,9 +351,9 @@ private: std::unique_ptr phy; // eNb - srslte_enb_dl_t enb_dl = {}; - cf_t* enb_dl_buffer[SRSLTE_MAX_PORTS] = {}; - srslte_dl_sf_cfg_t dl_sf_cfg = {}; + srsran_enb_dl_t enb_dl = {}; + cf_t* enb_dl_buffer[SRSRAN_MAX_PORTS] = {}; + srsran_dl_sf_cfg_t dl_sf_cfg = {}; uint64_t sfn = 0; // System Frame Number uint32_t sf_len = 0; @@ -363,13 +363,13 @@ private: std::condition_variable cvar; public: - phy_test_bench(const srsue::phy_args_t& phy_args, const srslte_cell_t& cell) : - radio(cell.nof_ports, srslte_sampling_freq_hz(cell.nof_prb)), + phy_test_bench(const srsue::phy_args_t& phy_args, const srsran_cell_t& cell) : + radio(cell.nof_ports, srsran_sampling_freq_hz(cell.nof_prb)), thread("phy_test_bench"), logger(srslog::fetch_basic_logger("test bench", false)) { // Deduce physical attributes - sf_len = SRSLTE_SF_LEN_PRB(cell.nof_prb); + sf_len = SRSRAN_SF_LEN_PRB(cell.nof_prb); // Initialise UE phy = std::unique_ptr(new srsue::phy); @@ -377,15 +377,15 @@ public: // Initialise DL baseband buffers for (uint32_t i = 0; i < cell.nof_ports; i++) { - enb_dl_buffer[i] = srslte_vec_cf_malloc(sf_len); + enb_dl_buffer[i] = srsran_vec_cf_malloc(sf_len); if (!enb_dl_buffer[i]) { perror("malloc"); } } // Initialise eNb DL - srslte_enb_dl_init(&enb_dl, enb_dl_buffer, SRSLTE_MAX_PRB); - srslte_enb_dl_set_cell(&enb_dl, cell); + srsran_enb_dl_init(&enb_dl, enb_dl_buffer, SRSRAN_MAX_PRB); + srsran_enb_dl_set_cell(&enb_dl, cell); // Wait PHY init to end phy->wait_initialize(); @@ -394,7 +394,7 @@ public: ~phy_test_bench() { // Free eNb DL object - srslte_enb_dl_free(&enb_dl); + srsran_enb_dl_free(&enb_dl); // Free buffers for (auto& buf : enb_dl_buffer) { @@ -410,7 +410,7 @@ public: srsue::phy_interface_rrc_lte* get_phy_interface_rrc() { return phy.get(); } srsue::phy_interface_mac_lte* get_phy_interface_mac() { return phy.get(); } - void configure_dedicated(uint16_t rnti, srslte::phy_cfg_t& phy_cfg) + void configure_dedicated(uint16_t rnti, srsran::phy_cfg_t& phy_cfg) { // Set PHY configuration phy->set_config(phy_cfg, 0); @@ -425,10 +425,10 @@ public: logger.debug("-- generating DL baseband SFN=%" PRId64 " TTI=%d;", sfn, dl_sf_cfg.tti); // Create empty resource grid with basic signals - srslte_enb_dl_put_base(&enb_dl, &dl_sf_cfg); + srsran_enb_dl_put_base(&enb_dl, &dl_sf_cfg); // Generate signal and transmit - srslte_enb_dl_gen_signal(&enb_dl); + srsran_enb_dl_gen_signal(&enb_dl); // Write baseband to radio radio.write_ring_buffers(enb_dl_buffer, sf_len); @@ -480,17 +480,17 @@ public: int main(int argc, char** argv) { - int ret = SRSLTE_SUCCESS; + int ret = SRSRAN_SUCCESS; const uint32_t default_timeout = 60000; // 1 minute // Define Cell - srslte_cell_t cell = {.nof_prb = 6, + srsran_cell_t cell = {.nof_prb = 6, .nof_ports = 4, .id = 1, - .cp = SRSLTE_CP_NORM, - .phich_length = SRSLTE_PHICH_NORM, - .phich_resources = SRSLTE_PHICH_R_1, - .frame_type = SRSLTE_FDD}; + .cp = SRSRAN_CP_NORM, + .phich_length = SRSRAN_PHICH_NORM, + .phich_resources = SRSRAN_PHICH_R_1, + .frame_type = SRSRAN_FDD}; // Define PHY arguments srsue::phy_args_t phy_args = {}; @@ -521,7 +521,7 @@ int main(int argc, char** argv) TESTASSERT(phy_test->get_stack()->wait_new_phy_meas(default_timeout)); // 3. Transmit PRACH - srslte::phy_cfg_t phy_cfg = {}; + srsran::phy_cfg_t phy_cfg = {}; phy_cfg.set_defaults(); phy_test->get_phy_interface_rrc()->set_config(phy_cfg, 0); TESTASSERT(phy_test->get_stack()->wait_config(default_timeout)); @@ -533,7 +533,7 @@ int main(int argc, char** argv) uint16_t rnti = 0x3c; phy_cfg = {}; phy_cfg.set_defaults(); - phy_cfg.dl_cfg.cqi_report.periodic_mode = SRSLTE_CQI_MODE_12; + phy_cfg.dl_cfg.cqi_report.periodic_mode = SRSRAN_CQI_MODE_12; phy_cfg.dl_cfg.cqi_report.periodic_configured = true; phy_cfg.dl_cfg.cqi_report.pmi_idx = 0; phy_cfg.ul_cfg.pucch.n_pucch_2 = 0; diff --git a/srsue/test/ttcn3/CMakeLists.txt b/srsue/test/ttcn3/CMakeLists.txt index a417f159d..47513bfae 100644 --- a/srsue/test/ttcn3/CMakeLists.txt +++ b/srsue/test/ttcn3/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of diff --git a/srsue/test/ttcn3/README.md b/srsue/test/ttcn3/README.md index 4364d7222..62e48341c 100644 --- a/srsue/test/ttcn3/README.md +++ b/srsue/test/ttcn3/README.md @@ -6,7 +6,7 @@ the upper-layer protocol stack against the UE conformance tests specified by 3GPP/ETSI in TS 36.523 [1]. The tester itself is built with Eclipse Titan [2] using the 3GPP EUTRA (LTE/EPC) UE Test Suites [3]. It is, however, -not part of the srsLTE repository. +not part of the srsRAN repository. The extensions present in this folder add a basic system simulator (SS) that talks over an ideal PHY to the fully unmodified UE upper-layer stack. It SS itself interfaces over multiple TCP/IP sockets to the TTCN3 tester, i.e., diff --git a/srsue/test/ttcn3/hdr/dut_utils.h b/srsue/test/ttcn3/hdr/dut_utils.h index 905d2fc03..ff90b321e 100644 --- a/srsue/test/ttcn3/hdr/dut_utils.h +++ b/srsue/test/ttcn3/hdr/dut_utils.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/srsue/test/ttcn3/hdr/lte_ttcn3_phy.h b/srsue/test/ttcn3/hdr/lte_ttcn3_phy.h index 0d0170c8b..3c6af7020 100644 --- a/srsue/test/ttcn3/hdr/lte_ttcn3_phy.h +++ b/srsue/test/ttcn3/hdr/lte_ttcn3_phy.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,15 +13,15 @@ #ifndef SRSUE_TTCN3_LTE_PHY_H #define SRSUE_TTCN3_LTE_PHY_H -#include "srslte/interfaces/ue_interfaces.h" -#include "srslte/interfaces/ue_phy_interfaces.h" +#include "srsran/interfaces/ue_interfaces.h" +#include "srsran/interfaces/ue_phy_interfaces.h" #include "srsue/hdr/phy/ue_lte_phy_base.h" #include "srsue/hdr/ue.h" #include "ttcn3_interfaces.h" -#include +#include using namespace srsue; -using namespace srslte; +using namespace srsran; namespace srsue { @@ -30,7 +30,7 @@ class lte_ttcn3_phy : public ue_lte_phy_base public: void set_cells_to_meas(uint32_t earfcn, const std::set& pci) override; typedef struct { - srslte_cell_t info; + srsran_cell_t info; float power; uint32_t earfcn; } cell_t; @@ -41,7 +41,7 @@ public: int init(const phy_args_t& args_, stack_interface_phy_lte* stack_, syssim_interface_phy* syssim_); - int init(const phy_args_t& args_, stack_interface_phy_lte* stack_, srslte::radio_interface_phy* radio_) override; + int init(const phy_args_t& args_, stack_interface_phy_lte* stack_, srsran::radio_interface_phy* radio_) override; // ue_phy_base interface int init(const phy_args_t& args_) override; @@ -58,12 +58,12 @@ public: void enable_pregen_signals(bool enable) override; void deactivate_scells() override; void set_activation_deactivation_scell(uint32_t cmd, uint32_t tti) override; - bool set_config(srslte::phy_cfg_t config, uint32_t cc_idx = 0) override; - bool set_scell(srslte_cell_t cell_info, uint32_t cc_idx, uint32_t earfcn) override; - void set_config_tdd(srslte_tdd_config_t& tdd_config) override; - void set_config_mbsfn_sib2(srslte::mbsfn_sf_cfg_t* cfg_list, uint32_t nof_cfgs) override{}; - void set_config_mbsfn_sib13(const srslte::sib13_t& sib13) override{}; - void set_config_mbsfn_mcch(const srslte::mcch_msg_t& mcch) override{}; + bool set_config(srsran::phy_cfg_t config, uint32_t cc_idx = 0) override; + bool set_scell(srsran_cell_t cell_info, uint32_t cc_idx, uint32_t earfcn) override; + void set_config_tdd(srsran_tdd_config_t& tdd_config) override; + void set_config_mbsfn_sib2(srsran::mbsfn_sf_cfg_t* cfg_list, uint32_t nof_cfgs) override{}; + void set_config_mbsfn_sib13(const srsran::sib13_t& sib13) override{}; + void set_config_mbsfn_mcch(const srsran::mcch_msg_t& mcch) override{}; // Measurements interface void meas_stop() override; @@ -85,7 +85,7 @@ public: // phy_interface_mac_common void set_timeadv_rar(uint32_t tti, uint32_t ta_cmd) override; void set_timeadv(uint32_t tti, uint32_t ta_cmd) override; - void set_rar_grant(uint8_t grant_payload[SRSLTE_RAR_GRANT_LEN], uint16_t rnti) override; + void set_rar_grant(uint8_t grant_payload[SRSRAN_RAR_GRANT_LEN], uint16_t rnti) override; uint32_t get_current_tti() override; float get_phr() override; float get_pathloss_db() override; @@ -113,7 +113,7 @@ private: cell_t pcell = {}; bool pcell_set = false; - srslte::phy_cfg_t phy_cfg = {}; + srsran::phy_cfg_t phy_cfg = {}; uint32_t current_tti = 0; uint32_t cc_idx = 0; @@ -125,7 +125,7 @@ private: std::mutex mutex; - srslte::task_scheduler task_sched; + srsran::task_scheduler task_sched; uint32_t ra_trans_cnt = 0; diff --git a/srsue/test/ttcn3/hdr/swappable_sink.h b/srsue/test/ttcn3/hdr/swappable_sink.h index 512164454..882c024aa 100644 --- a/srsue/test/ttcn3/hdr/swappable_sink.h +++ b/srsue/test/ttcn3/hdr/swappable_sink.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,7 +13,7 @@ #ifndef SRSUE_TTCN3_SWAPPABLE_SINK_H #define SRSUE_TTCN3_SWAPPABLE_SINK_H -#include "srslte/srslog/sink.h" +#include "srsran/srslog/sink.h" /// A custom sink implementation that allows hot swapping file sinks so that loggers can write to different files /// dynamically or other stream-like sinks like stdout. diff --git a/srsue/test/ttcn3/hdr/ttcn3_common.h b/srsue/test/ttcn3/hdr/ttcn3_common.h index a2b126a6f..24f699039 100644 --- a/srsue/test/ttcn3/hdr/ttcn3_common.h +++ b/srsue/test/ttcn3/hdr/ttcn3_common.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/srsue/test/ttcn3/hdr/ttcn3_drb_interface.h b/srsue/test/ttcn3/hdr/ttcn3_drb_interface.h index c95259b18..b0624fee4 100644 --- a/srsue/test/ttcn3/hdr/ttcn3_drb_interface.h +++ b/srsue/test/ttcn3/hdr/ttcn3_drb_interface.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,15 +13,15 @@ #ifndef SRSUE_TTCN3_DRB_INTERFACE_H #define SRSUE_TTCN3_DRB_INTERFACE_H -#include "srslte/common/buffer_pool.h" -#include "srslte/common/common.h" -#include "srslte/mac/pdu.h" +#include "srsran/common/buffer_pool.h" +#include "srsran/common/common.h" +#include "srsran/mac/pdu.h" #include "ttcn3_interfaces.h" #include "ttcn3_port_handler.h" -#include -#include +#include +#include -using namespace srslte; +using namespace srsran; // The DRB interface class ttcn3_drb_interface : public ttcn3_port_handler @@ -67,7 +67,7 @@ private: Document document; if (document.Parse((char*)&rx_buf->at(2)).HasParseError() || document.IsObject() == false) { logger.error((uint8_t*)&rx_buf->at(2), json_len, "Error parsing incoming data."); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Pretty-print @@ -111,7 +111,7 @@ private: } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } void handle_sdu(Document& document, const uint16_t lcid, const uint8_t* payload, const uint16_t len, bool follow_on) @@ -119,7 +119,7 @@ private: logger.info(payload, len, "Received DRB PDU (lcid=%d)", lcid); // pack into byte buffer - unique_byte_buffer_t pdu = srslte::make_byte_buffer(); + unique_byte_buffer_t pdu = srsran::make_byte_buffer(); pdu->N_bytes = len; memcpy(pdu->msg, payload, pdu->N_bytes); diff --git a/srsue/test/ttcn3/hdr/ttcn3_helpers.h b/srsue/test/ttcn3/hdr/ttcn3_helpers.h index ab9d4c2b0..b0ffbfe91 100644 --- a/srsue/test/ttcn3/hdr/ttcn3_helpers.h +++ b/srsue/test/ttcn3/hdr/ttcn3_helpers.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -20,8 +20,8 @@ #include "rapidjson/document.h" // rapidjson's DOM-style API #include "rapidjson/prettywriter.h" // for stringify JSON -#include "srslte/asn1/asn1_utils.h" -#include "srslte/common/byte_buffer.h" +#include "srsran/asn1/asn1_utils.h" +#include "srsran/common/byte_buffer.h" #include #include #include @@ -31,7 +31,7 @@ using namespace std; using namespace rapidjson; -using namespace srslte; +using namespace srsran; class ttcn3_helpers { @@ -408,7 +408,7 @@ public: } static std::string - get_rrc_pdu_ind_for_pdu(uint32_t tti, uint32_t lcid, const std::string cell_, srslte::unique_byte_buffer_t pdubuf) + get_rrc_pdu_ind_for_pdu(uint32_t tti, uint32_t lcid, const std::string cell_, srsran::unique_byte_buffer_t pdubuf) { Document resp; resp.SetObject(); @@ -479,7 +479,7 @@ public: } static std::string - get_drb_common_ind_for_pdu(uint32_t tti, uint32_t lcid, const std::string cell_, srslte::unique_byte_buffer_t drbpdu) + get_drb_common_ind_for_pdu(uint32_t tti, uint32_t lcid, const std::string cell_, srsran::unique_byte_buffer_t drbpdu) { Document resp; resp.SetObject(); diff --git a/srsue/test/ttcn3/hdr/ttcn3_interfaces.h b/srsue/test/ttcn3/hdr/ttcn3_interfaces.h index ba46b04bb..f0a1f448c 100644 --- a/srsue/test/ttcn3/hdr/ttcn3_interfaces.h +++ b/srsue/test/ttcn3/hdr/ttcn3_interfaces.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,9 +13,9 @@ #ifndef SRSUE_TTCN3_INTERFACES_H #define SRSUE_TTCN3_INTERFACES_H -#include "srslte/common/common.h" -#include "srslte/interfaces/ue_interfaces.h" -#include "srslte/interfaces/ue_pdcp_interfaces.h" +#include "srsran/common/common.h" +#include "srsran/interfaces/ue_interfaces.h" +#include "srsran/interfaces/ue_pdcp_interfaces.h" #include "ttcn3_helpers.h" // Interfaces used by system interface to communicate with main component @@ -34,8 +34,8 @@ public: class ss_sys_interface { public: - virtual void add_bcch_dlsch_pdu(const std::string cell_name, srslte::unique_byte_buffer_t pdu) = 0; - virtual void add_pch_pdu(srslte::unique_byte_buffer_t pdu) = 0; + virtual void add_bcch_dlsch_pdu(const std::string cell_name, srsran::unique_byte_buffer_t pdu) = 0; + virtual void add_pch_pdu(srsran::unique_byte_buffer_t pdu) = 0; virtual void set_cell_attenuation(const ttcn3_helpers::timing_info_t timing, const std::string cell_name, @@ -47,7 +47,7 @@ public: public: std::string name; uint32_t earfcn = 0; - srslte_cell_t phy_cell = {}; + srsran_cell_t phy_cell = {}; float initial_power = -90.0; float attenuation = 0.0; uint16_t temp_crnti = 0; @@ -58,12 +58,12 @@ public: virtual void add_srb(const ttcn3_helpers::timing_info_t timing, const std::string cell_name, const uint32_t lcid, - const srslte::pdcp_config_t pdcp_config) = 0; + const srsran::pdcp_config_t pdcp_config) = 0; virtual void del_srb(const ttcn3_helpers::timing_info_t timing, const std::string cell_name, const uint32_t lcid) = 0; virtual void add_drb(const ttcn3_helpers::timing_info_t timing, const std::string cell_name, const uint32_t lcid, - const srslte::pdcp_config_t pdcp_config) = 0; + const srsran::pdcp_config_t pdcp_config) = 0; virtual void del_drb(const ttcn3_helpers::timing_info_t timing, const std::string cell_name, const uint32_t lcid) = 0; virtual void set_as_security(const ttcn3_helpers::timing_info_t timing, @@ -71,8 +71,8 @@ public: const std::array k_rrc_enc, const std::array k_rrc_int, const std::array k_up_enc, - const srslte::CIPHERING_ALGORITHM_ID_ENUM cipher_algo, - const srslte::INTEGRITY_ALGORITHM_ID_ENUM integ_algo, + const srsran::CIPHERING_ALGORITHM_ID_ENUM cipher_algo, + const srsran::INTEGRITY_ALGORITHM_ID_ENUM integ_algo, const ttcn3_helpers::pdcp_count_map_t bearers) = 0; virtual void release_as_security(const ttcn3_helpers::timing_info_t timing, const std::string cell_name) = 0; @@ -86,12 +86,12 @@ class ss_srb_interface public: virtual void add_ccch_pdu(const ttcn3_helpers::timing_info_t timing, const std::string cell_name, - srslte::unique_byte_buffer_t pdu) = 0; + srsran::unique_byte_buffer_t pdu) = 0; virtual void add_dcch_pdu(const ttcn3_helpers::timing_info_t timing, const std::string cell_name, const uint32_t lcid, - srslte::unique_byte_buffer_t pdu, + srsran::unique_byte_buffer_t pdu, bool follow_on_flag) = 0; virtual void reestablish_bearer(const std::string cell_name, const uint32_t lcid) = 0; @@ -103,7 +103,7 @@ public: virtual void prach_indication(uint32_t preamble_index, const uint32_t& cell_id) = 0; virtual void sr_req(uint32_t tti_tx) = 0; virtual void tx_pdu(const uint8_t* payload, const int len, const uint32_t tx_tti) = 0; - virtual void select_cell(srslte_cell_t cell) = 0; + virtual void select_cell(srsran_cell_t cell) = 0; }; class phy_interface_syssim diff --git a/srsue/test/ttcn3/hdr/ttcn3_ip_ctrl_interface.h b/srsue/test/ttcn3/hdr/ttcn3_ip_ctrl_interface.h index 0db5cdc78..56651443a 100644 --- a/srsue/test/ttcn3/hdr/ttcn3_ip_ctrl_interface.h +++ b/srsue/test/ttcn3/hdr/ttcn3_ip_ctrl_interface.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -15,7 +15,7 @@ #include "rapidjson/document.h" #include "rapidjson/prettywriter.h" -#include "srslte/phy/io/netsource.h" +#include "srsran/phy/io/netsource.h" #include "ttcn3_helpers.h" #include "ttcn3_port_handler.h" @@ -46,7 +46,7 @@ private: Document document; if (document.Parse((char*)rx_buf->begin()).HasParseError() || document.IsObject() == false) { logger.error(rx_buf->begin(), n, "Error parsing incoming data."); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Pretty-print @@ -63,7 +63,7 @@ private: logger.error("Received unknown request."); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } void handle_routing_info(Document& document) diff --git a/srsue/test/ttcn3/hdr/ttcn3_ip_sock_interface.h b/srsue/test/ttcn3/hdr/ttcn3_ip_sock_interface.h index 81cd729f0..48c27dddb 100644 --- a/srsue/test/ttcn3/hdr/ttcn3_ip_sock_interface.h +++ b/srsue/test/ttcn3/hdr/ttcn3_ip_sock_interface.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -40,7 +40,7 @@ private: Document document; if (document.Parse((char*)rx_buf->begin()).HasParseError() || document.IsObject() == false) { logger.error(rx_buf->begin(), n, "Error parsing incoming data."); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Pretty-print @@ -57,7 +57,7 @@ private: logger.error("Received unknown request."); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } void handle_ctrl(Document& document) diff --git a/srsue/test/ttcn3/hdr/ttcn3_port_handler.h b/srsue/test/ttcn3/hdr/ttcn3_port_handler.h index e31e7d0b9..fab9ea656 100644 --- a/srsue/test/ttcn3/hdr/ttcn3_port_handler.h +++ b/srsue/test/ttcn3/hdr/ttcn3_port_handler.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -18,9 +18,9 @@ #ifndef SRSUE_TTCN3_PORT_HANDLER_H #define SRSUE_TTCN3_PORT_HANDLER_H -#include "srslte/common/epoll_helper.h" -#include "srslte/common/standard_streams.h" -#include "srslte/srslog/srslog.h" +#include "srsran/common/epoll_helper.h" +#include "srsran/common/standard_streams.h" +#include "srsran/srslog/srslog.h" #include "ttcn3_common.h" #include #include @@ -59,7 +59,7 @@ public: } } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int handle_notification(const uint8_t* payload, const uint32_t len) @@ -68,14 +68,14 @@ public: uint32_t notif_header_size = sizeof(((union sctp_notification*)NULL)->sn_header); if (notif_header_size > len) { printf("Error: Notification msg size is smaller than notification header size!\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } switch (notif->sn_header.sn_type) { case SCTP_ASSOC_CHANGE: { if (sizeof(struct sctp_assoc_change) > len) { printf("Error notification msg size is smaller than struct sctp_assoc_change size\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } const char* state = NULL; @@ -112,7 +112,7 @@ public: case SCTP_SHUTDOWN_EVENT: { if (sizeof(struct sctp_shutdown_event) > len) { printf("Error notification msg size is smaller than struct sctp_assoc_change size\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } struct sctp_shutdown_event* n = ¬if->sn_shutdown_event; logger.debug("SCTP_SHUTDOWN_EVENT notif: assoc id: %d", n->sse_assoc_id); @@ -124,7 +124,7 @@ public: break; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } ///< Send buffer to tester @@ -141,27 +141,27 @@ public: int flags = fcntl(fd, F_GETFL, 0); if (flags == -1) { perror("fcntl"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } flags |= O_NONBLOCK; int s = fcntl(fd, F_SETFL, flags); if (s == -1) { perror("fcntl"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } ///< Create, bind and listen on SCTP socket int port_listen() { - int ret = SRSLTE_ERROR; + int ret = SRSRAN_ERROR; sock_fd = socket(AF_INET, SOCK_SEQPACKET, IPPROTO_SCTP); if (sock_fd == -1) { - srslte::console("Could not create SCTP socket\n"); + srsran::console("Could not create SCTP socket\n"); return ret; } @@ -173,8 +173,8 @@ public: events.sctp_association_event = 1; if (setsockopt(sock_fd, IPPROTO_SCTP, SCTP_EVENTS, &events, sizeof(events))) { close(sock_fd); - srslte::console("Subscribing to sctp_data_io_events failed\n"); - return SRSLTE_ERROR; + srsran::console("Subscribing to sctp_data_io_events failed\n"); + return SRSRAN_ERROR; } // Port bind @@ -189,17 +189,17 @@ public: if (ret != 0) { close(sock_fd); logger.error("Error binding SCTP socket"); - srslte::console("Error binding SCTP socket\n"); - return SRSLTE_ERROR; + srsran::console("Error binding SCTP socket\n"); + return SRSRAN_ERROR; } // Listen for connections ret = listen(sock_fd, SOMAXCONN); - if (ret != SRSLTE_SUCCESS) { + if (ret != SRSRAN_SUCCESS) { close(sock_fd); logger.error("Error in SCTP socket listen"); - srslte::console("Error in SCTP socket listen\n"); - return SRSLTE_ERROR; + srsran::console("Error in SCTP socket listen\n"); + return SRSRAN_ERROR; } set_non_blocking(sock_fd); diff --git a/srsue/test/ttcn3/hdr/ttcn3_srb_interface.h b/srsue/test/ttcn3/hdr/ttcn3_srb_interface.h index 490db840e..16c70c8ab 100644 --- a/srsue/test/ttcn3/hdr/ttcn3_srb_interface.h +++ b/srsue/test/ttcn3/hdr/ttcn3_srb_interface.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,14 +13,14 @@ #ifndef SRSUE_TTCN3_SRB_INTERFACE_H #define SRSUE_TTCN3_SRB_INTERFACE_H -#include "srslte/common/buffer_pool.h" -#include "srslte/common/common.h" -#include "srslte/mac/pdu.h" +#include "srsran/common/buffer_pool.h" +#include "srsran/common/common.h" +#include "srsran/mac/pdu.h" #include "ttcn3_interfaces.h" #include "ttcn3_port_handler.h" -#include +#include -using namespace srslte; +using namespace srsran; // The SRB interface class ttcn3_srb_interface : public ttcn3_port_handler @@ -68,7 +68,7 @@ private: Document document; if (document.Parse((char*)&rx_buf->at(2)).HasParseError() || document.IsObject() == false) { logger.error((uint8_t*)&rx_buf->at(2), json_len, "Error parsing incoming data."); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Pretty-print @@ -99,7 +99,7 @@ private: logger.error("Received unknown request."); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Todo: move to SYSSIM @@ -108,7 +108,7 @@ private: logger.info(payload, len, "Received CCCH RRC PDU"); // pack into byte buffer - unique_byte_buffer_t pdu = srslte::make_byte_buffer(); + unique_byte_buffer_t pdu = srsran::make_byte_buffer(); pdu->N_bytes = len; memcpy(pdu->msg, payload, pdu->N_bytes); @@ -128,7 +128,7 @@ private: logger.info(payload, len, "Received DCCH RRC PDU (lcid=%d)", lcid); // pack into byte buffer - unique_byte_buffer_t pdu = srslte::make_byte_buffer(); + unique_byte_buffer_t pdu = srsran::make_byte_buffer(); pdu->N_bytes = len; memcpy(pdu->msg, payload, pdu->N_bytes); diff --git a/srsue/test/ttcn3/hdr/ttcn3_sys_interface.h b/srsue/test/ttcn3/hdr/ttcn3_sys_interface.h index 0eb7b54e1..f7ea84bfc 100644 --- a/srsue/test/ttcn3/hdr/ttcn3_sys_interface.h +++ b/srsue/test/ttcn3/hdr/ttcn3_sys_interface.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,12 +13,12 @@ #ifndef SRSUE_TTCN3_SYS_INTERFACE_H #define SRSUE_TTCN3_SYS_INTERFACE_H -#include "srslte/asn1/rrc_utils.h" -#include "srslte/common/buffer_pool.h" +#include "srsran/asn1/rrc_utils.h" +#include "srsran/common/buffer_pool.h" #include "ttcn3_helpers.h" #include "ttcn3_interfaces.h" -using namespace srslte; +using namespace srsran; // The EUTRA.SYS interface class ttcn3_sys_interface : public ttcn3_port_handler @@ -60,7 +60,7 @@ private: Document document; if (document.Parse(json).HasParseError() || document.IsObject() == false) { logger.error((uint8_t*)json, json_len, "Error parsing incoming data."); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Pretty-print @@ -110,7 +110,7 @@ private: logger.error("Received unknown request."); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } void handle_request_cell_basic(Document& document, const uint8_t* payload, const uint16_t len) @@ -139,7 +139,7 @@ private: cell.phy_cell.id = common_config["PhysicalCellId"].GetInt(); cell.phy_cell.cp = - (strcmp(dl_config["CyclicPrefix"].GetString(), "normal") == 0) ? SRSLTE_CP_NORM : SRSLTE_CP_EXT; + (strcmp(dl_config["CyclicPrefix"].GetString(), "normal") == 0) ? SRSRAN_CP_NORM : SRSRAN_CP_EXT; cell.phy_cell.nof_ports = (strcmp(phy_dl_config["AntennaGroup"]["AntennaInfoCommon"]["R8"]["antennaPortsCount"].GetString(), "an1") == 0) @@ -148,12 +148,12 @@ private: cell.phy_cell.nof_prb = (strcmp(dl_config["Bandwidth"].GetString(), "n25") == 0) ? 25 : 0; cell.phy_cell.phich_length = (strcmp(phy_dl_config["Phich"]["PhichConfig"]["R8"]["phich_Duration"].GetString(), "normal") == 0) - ? SRSLTE_PHICH_NORM - : SRSLTE_PHICH_EXT; + ? SRSRAN_PHICH_NORM + : SRSRAN_PHICH_EXT; cell.phy_cell.phich_resources = (strcmp(phy_dl_config["Phich"]["PhichConfig"]["R8"]["phich_Resource"].GetString(), "one") == 0) - ? SRSLTE_PHICH_R_1 - : SRSLTE_PHICH_R_1_6; + ? SRSRAN_PHICH_R_1 + : SRSRAN_PHICH_R_1_6; logger.info("DL EARFCN is %d with n_prb=%d", cell.earfcn, cell.phy_cell.nof_prb); const Value& ref_power = @@ -193,7 +193,7 @@ private: uint16_t tb_len = ((uint16_t)payload_ptr[0] << 8) | payload_ptr[1]; payload_ptr += 2; - unique_byte_buffer_t sib = srslte::make_byte_buffer(); + unique_byte_buffer_t sib = srsran::make_byte_buffer(); memcpy(sib->msg, payload_ptr, tb_len); payload_ptr += tb_len; sib->N_bytes = tb_len; @@ -536,14 +536,14 @@ private: const Value& as_sec = req["AS_Security"]; if (as_sec.HasMember("StartRestart")) { // get integrity algo - srslte::INTEGRITY_ALGORITHM_ID_ENUM integ_algo = {}; + srsran::INTEGRITY_ALGORITHM_ID_ENUM integ_algo = {}; std::string int_algo_string = as_sec["StartRestart"]["Integrity"]["Algorithm"].GetString(); if (int_algo_string == "eia0") { - integ_algo = srslte::INTEGRITY_ALGORITHM_ID_EIA0; + integ_algo = srsran::INTEGRITY_ALGORITHM_ID_EIA0; } else if (int_algo_string == "eia1") { - integ_algo = srslte::INTEGRITY_ALGORITHM_ID_128_EIA1; + integ_algo = srsran::INTEGRITY_ALGORITHM_ID_128_EIA1; } else if (int_algo_string == "eia2") { - integ_algo = srslte::INTEGRITY_ALGORITHM_ID_128_EIA2; + integ_algo = srsran::INTEGRITY_ALGORITHM_ID_128_EIA2; } else { logger.error("Unsupported integrity algorithm %s", int_algo_string.c_str()); } @@ -554,14 +554,14 @@ private: logger.debug(k_rrc_int.data(), k_rrc_int.size(), "K_rrc_int"); // get enc algo - srslte::CIPHERING_ALGORITHM_ID_ENUM cipher_algo = {}; + srsran::CIPHERING_ALGORITHM_ID_ENUM cipher_algo = {}; std::string cipher_algo_string = as_sec["StartRestart"]["Ciphering"]["Algorithm"].GetString(); if (cipher_algo_string == "eea0") { - cipher_algo = srslte::CIPHERING_ALGORITHM_ID_EEA0; + cipher_algo = srsran::CIPHERING_ALGORITHM_ID_EEA0; } else if (cipher_algo_string == "eea1") { - cipher_algo = srslte::CIPHERING_ALGORITHM_ID_128_EEA1; + cipher_algo = srsran::CIPHERING_ALGORITHM_ID_128_EEA1; } else if (cipher_algo_string == "eea2") { - cipher_algo = srslte::CIPHERING_ALGORITHM_ID_128_EEA2; + cipher_algo = srsran::CIPHERING_ALGORITHM_ID_128_EEA2; } else { logger.error("Unsupported ciphering algorithm %s", cipher_algo_string.c_str()); } @@ -694,7 +694,7 @@ private: uint16_t tb_len = ((uint16_t)payload_ptr[0] << 8) | payload_ptr[1]; payload_ptr += 2; - unique_byte_buffer_t pch = srslte::make_byte_buffer(); + unique_byte_buffer_t pch = srsran::make_byte_buffer(); memcpy(pch->msg, payload_ptr, tb_len); payload_ptr += tb_len; pch->N_bytes = tb_len; diff --git a/srsue/test/ttcn3/hdr/ttcn3_syssim.h b/srsue/test/ttcn3/hdr/ttcn3_syssim.h index d7abb3a2b..dcda4d15e 100644 --- a/srsue/test/ttcn3/hdr/ttcn3_syssim.h +++ b/srsue/test/ttcn3/hdr/ttcn3_syssim.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -13,10 +13,10 @@ #ifndef SRSUE_TTCN3_SYSSIM_H #define SRSUE_TTCN3_SYSSIM_H -#include "srslte/mac/pdu_queue.h" -#include "srslte/test/ue_test_interfaces.h" -#include "srslte/upper/pdcp.h" -#include "srslte/upper/rlc.h" +#include "srsran/mac/pdu_queue.h" +#include "srsran/test/ue_test_interfaces.h" +#include "srsran/upper/pdcp.h" +#include "srsran/upper/rlc.h" #include "ttcn3_common.h" #include "ttcn3_drb_interface.h" #include "ttcn3_ip_ctrl_interface.h" @@ -35,7 +35,7 @@ class ttcn3_syssim : public syssim_interface_phy, public rlc_interface_pdcp, public rrc_interface_pdcp, public gw_interface_pdcp, - public srslte::pdu_queue::process_callback + public srsran::pdu_queue::process_callback { public: explicit ttcn3_syssim(ttcn3_ue* ue_); @@ -91,7 +91,7 @@ public: void send_sr_ul_grant(); // internal function called from tx_pdu (called from main thread) - bool process_ce(srslte::sch_subh* subh); + bool process_ce(srsran::sch_subh* subh); uint32_t get_pid(const uint32_t tti_); @@ -172,23 +172,23 @@ public: std::array k_rrc_enc_, std::array k_rrc_int_, std::array k_up_enc_, - const srslte::CIPHERING_ALGORITHM_ID_ENUM cipher_algo_, - const srslte::INTEGRITY_ALGORITHM_ID_ENUM integ_algo_, + const srsran::CIPHERING_ALGORITHM_ID_ENUM cipher_algo_, + const srsran::INTEGRITY_ALGORITHM_ID_ENUM integ_algo_, const ttcn3_helpers::pdcp_count_map_t bearers_); void set_as_security_impl(const std::string cell_name, std::array k_rrc_enc_, std::array k_rrc_int_, std::array k_up_enc_, - const srslte::CIPHERING_ALGORITHM_ID_ENUM cipher_algo_, - const srslte::INTEGRITY_ALGORITHM_ID_ENUM integ_algo_, + const srsran::CIPHERING_ALGORITHM_ID_ENUM cipher_algo_, + const srsran::INTEGRITY_ALGORITHM_ID_ENUM integ_algo_, const ttcn3_helpers::pdcp_count_map_t bearers); void release_as_security(const ttcn3_helpers::timing_info_t timing, const std::string cell_name); void release_as_security_impl(const std::string cell_name); - void select_cell(srslte_cell_t phy_cell); + void select_cell(srsran_cell_t phy_cell); ttcn3_helpers::pdcp_count_map_t get_pdcp_count(const std::string cell_name); @@ -240,15 +240,15 @@ private: uint16_t dl_rnti = 0; int force_lcid = -1; srsue::stack_test_dummy stack; - bool last_dl_ndi[SRSLTE_FDD_NOF_HARQ] = {}; - bool last_ul_ndi[SRSLTE_FDD_NOF_HARQ] = {}; + bool last_dl_ndi[SRSRAN_FDD_NOF_HARQ] = {}; + bool last_ul_ndi[SRSRAN_FDD_NOF_HARQ] = {}; // For events/actions that need to be carried out in a specific TTI typedef std::queue task_queue_t; typedef std::map tti_action_map_t; tti_action_map_t tti_actions; - // Map between the cellId (name) used by 3GPP test suite and srsLTE cell struct + // Map between the cellId (name) used by 3GPP test suite and srsRAN cell struct class syssim_cell_t { public: @@ -261,13 +261,13 @@ private: int sib_idx = 0; ///< Index of SIB scheduled for next transmission // Simulator objects - srslte::rlc rlc; - srslte::pdcp pdcp; + srsran::rlc rlc; + srsran::pdcp pdcp; std::map bearer_follow_on_map; ///< Indicates if for a given LCID the follow_on_flag is set or not // security config ttcn3_helpers::pdcp_count_map_t pending_bearer_config; ///< List of bearers with pending security configuration - srslte::as_security_config_t sec_cfg; + srsran::as_security_config_t sec_cfg; }; typedef std::unique_ptr unique_syssim_cell_t; std::vector cells; @@ -279,12 +279,12 @@ private: syssim_cell_t* get_cell(const std::string cell_name); bool have_valid_pcell(); - srslte::pdu_queue pdus; - srslte::sch_pdu mac_msg_dl, mac_msg_ul; + srsran::pdu_queue pdus; + srsran::sch_pdu mac_msg_dl, mac_msg_ul; // buffer for DL transmissions - srslte::byte_buffer_t rar_buffer; - srslte::byte_buffer_t tx_payload_buffer; // Used to buffer final MAC PDU + srsran::byte_buffer_t rar_buffer; + srsran::byte_buffer_t tx_payload_buffer; // Used to buffer final MAC PDU uint64_t conres_id = 0; diff --git a/srsue/test/ttcn3/hdr/ttcn3_ue.h b/srsue/test/ttcn3/hdr/ttcn3_ue.h index a0219a7ee..28cffb339 100644 --- a/srsue/test/ttcn3/hdr/ttcn3_ue.h +++ b/srsue/test/ttcn3/hdr/ttcn3_ue.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -14,7 +14,7 @@ #define SRSUE_TTCN3_UE_H #include "lte_ttcn3_phy.h" -#include "srslte/common/standard_streams.h" +#include "srsran/common/standard_streams.h" #include "srsue/hdr/stack/ue_stack_lte.h" #include @@ -50,8 +50,8 @@ public: // GW interface void add_mch_port(uint32_t lcid, uint32_t port); - void write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t pdu); - void write_pdu_mch(uint32_t lcid, srslte::unique_byte_buffer_t pdu); + void write_pdu(uint32_t lcid, srsran::unique_byte_buffer_t pdu); + void write_pdu_mch(uint32_t lcid, srsran::unique_byte_buffer_t pdu); int setup_if_addr(uint32_t eps_bearer_id, uint32_t lcid, uint8_t pdn_type, @@ -70,7 +70,7 @@ public: void send_queued_data(); - void loop_back_pdu_with_tft(uint32_t input_lcid, srslte::unique_byte_buffer_t pdu); + void loop_back_pdu_with_tft(uint32_t input_lcid, srsran::unique_byte_buffer_t pdu); private: std::unique_ptr phy; @@ -80,8 +80,8 @@ private: srslog::basic_logger& logger; test_loop_mode_state_t test_loop_mode = TEST_LOOP_INACTIVE; - srslte::timer_handler::unique_timer pdu_delay_timer; - std::map > pdu_queue; // A PDU queue for each DRB + srsran::timer_handler::unique_timer pdu_delay_timer; + std::map > pdu_queue; // A PDU queue for each DRB tft_pdu_matcher tft_matcher; all_args_t args = {}; diff --git a/srsue/test/ttcn3/hdr/ttcn3_ut_interface.h b/srsue/test/ttcn3/hdr/ttcn3_ut_interface.h index 97fa104cd..2e6ea690b 100644 --- a/srsue/test/ttcn3/hdr/ttcn3_ut_interface.h +++ b/srsue/test/ttcn3/hdr/ttcn3_ut_interface.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -15,7 +15,7 @@ #include "rapidjson/document.h" #include "rapidjson/prettywriter.h" -#include "srslte/common/netsource_handler.h" +#include "srsran/common/netsource_handler.h" #include "ttcn3_interfaces.h" using namespace rapidjson; @@ -44,7 +44,7 @@ private: Document document; if (document.Parse((char*)rx_buf->begin()).HasParseError() || document.IsObject() == false) { logger.error(rx_buf->begin(), n, "Error parsing incoming data."); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Pretty-print @@ -101,7 +101,7 @@ private: logger.error("Unknown command type."); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } void handle_power_off(Document& document) diff --git a/srsue/test/ttcn3/src/CMakeLists.txt b/srsue/test/ttcn3/src/CMakeLists.txt index 99d87cb6d..e4a14469d 100644 --- a/srsue/test/ttcn3/src/CMakeLists.txt +++ b/srsue/test/ttcn3/src/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -12,13 +12,13 @@ add_executable(ttcn3_dut ttcn3_dut.cc lte_ttcn3_phy.cc ${SOURCES}) set(LINK_LIBRARIES srsue_stack srsue_upper srsue_rrc - srslte_upper - srslte_common - srslte_mac - srslte_mac - srslte_phy - srslte_radio - srslte_upper + srsran_upper + srsran_common + srsran_mac + srsran_mac + srsran_phy + srsran_radio + srsran_upper srsue_phy srsue_mac srsue_mac_nr diff --git a/srsue/test/ttcn3/src/lte_ttcn3_phy.cc b/srsue/test/ttcn3/src/lte_ttcn3_phy.cc index 4012b3bcb..063e60415 100644 --- a/srsue/test/ttcn3/src/lte_ttcn3_phy.cc +++ b/srsue/test/ttcn3/src/lte_ttcn3_phy.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -30,7 +30,7 @@ int lte_ttcn3_phy::init(const phy_args_t& args_, stack_interface_phy_lte* stack_ return init(args_); } -int lte_ttcn3_phy::init(const phy_args_t& args_, stack_interface_phy_lte* stack_, srslte::radio_interface_phy* radio_) +int lte_ttcn3_phy::init(const phy_args_t& args_, stack_interface_phy_lte* stack_, srsran::radio_interface_phy* radio_) { return init(args_); } @@ -41,7 +41,7 @@ int lte_ttcn3_phy::init(const phy_args_t& args_) logger.set_level(srslog::str_to_basic_level(args_.log.phy_level)); logger.set_hex_dump_max_size(-1); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } void lte_ttcn3_phy::stop(){}; @@ -59,7 +59,7 @@ void lte_ttcn3_phy::set_cell_map(const cell_list_t& cells_) cells = cells_; } -void lte_ttcn3_phy::set_config_tdd(srslte_tdd_config_t& tdd_config) {} +void lte_ttcn3_phy::set_config_tdd(srsran_tdd_config_t& tdd_config) {} void lte_ttcn3_phy::enable_pregen_signals(bool enable) { @@ -76,14 +76,14 @@ void lte_ttcn3_phy::set_activation_deactivation_scell(uint32_t cmd, uint32_t tti logger.debug("%s not implemented.", __FUNCTION__); } -bool lte_ttcn3_phy::set_config(srslte::phy_cfg_t config, uint32_t cc_idx_) +bool lte_ttcn3_phy::set_config(srsran::phy_cfg_t config, uint32_t cc_idx_) { logger.debug("%s not implemented.", __FUNCTION__); task_sched.defer_task([this]() { stack->set_config_complete(true); }); return true; } -bool lte_ttcn3_phy::set_scell(srslte_cell_t cell_info, uint32_t cc_idx, uint32_t earfcn) +bool lte_ttcn3_phy::set_scell(srsran_cell_t cell_info, uint32_t cc_idx, uint32_t earfcn) { logger.debug("%s not implemented.", __FUNCTION__); task_sched.defer_task([this]() { stack->set_scell_complete(true); }); @@ -227,7 +227,7 @@ void lte_ttcn3_phy::set_timeadv(uint32_t tti, uint32_t ta_cmd) } // Sets RAR grant payload -void lte_ttcn3_phy::set_rar_grant(uint8_t grant_payload[SRSLTE_RAR_GRANT_LEN], uint16_t rnti) +void lte_ttcn3_phy::set_rar_grant(uint8_t grant_payload[SRSRAN_RAR_GRANT_LEN], uint16_t rnti) { // Empty, SYSSIM knows when to provide UL grant for Msg3 logger.debug("%s not implemented.", __FUNCTION__); @@ -292,7 +292,7 @@ void lte_ttcn3_phy::new_tb(const srsue::mac_interface_phy_lte::mac_grant_dl_t dl stack->new_grant_dl(cc_idx, dl_grant, &dl_action); - bool dl_ack[SRSLTE_MAX_CODEWORDS] = {}; + bool dl_ack[SRSRAN_MAX_CODEWORDS] = {}; if (dl_action.tb[0].enabled && dl_action.tb[0].payload != nullptr) { logger.info(data, diff --git a/srsue/test/ttcn3/src/ttcn3_dut.cc b/srsue/test/ttcn3/src/ttcn3_dut.cc index 05d4eb55f..29006774f 100644 --- a/srsue/test/ttcn3/src/ttcn3_dut.cc +++ b/srsue/test/ttcn3/src/ttcn3_dut.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,8 +10,8 @@ * */ -#include "srslte/build_info.h" -#include "srslte/srslog/srslog.h" +#include "srsran/build_info.h" +#include "srsran/srslog/srslog.h" #include "srsue/hdr/ue.h" #include "swappable_sink.h" #include "ttcn3_syssim.h" @@ -19,7 +19,7 @@ #include #include -using namespace srslte; +using namespace srsran; using namespace srsue; ; using namespace std; @@ -106,7 +106,7 @@ all_args_t parse_args(ttcn3_dut_args_t* args, int argc, char* argv[]) int main(int argc, char** argv) { - std::cout << "Built in " << srslte_get_build_mode() << " mode using " << srslte_get_build_info() << "." << std::endl; + std::cout << "Built in " << srsran_get_build_mode() << " mode using " << srsran_get_build_info() << "." << std::endl; // we handle OS signals through epoll block_signals(); @@ -118,11 +118,11 @@ int main(int argc, char** argv) if (!srslog::install_custom_sink(swappable_sink::name(), std::unique_ptr(new swappable_sink( dut_args.log_filename, srslog::get_default_log_formatter())))) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } auto* default_sink = srslog::find_sink(swappable_sink::name()); if (!default_sink) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } srslog::set_default_sink(*default_sink); @@ -134,9 +134,9 @@ int main(int argc, char** argv) // create and init SYSSIM ttcn3_syssim syssim(ue.get()); - if (syssim.init(ue_args) != SRSLTE_SUCCESS) { + if (syssim.init(ue_args) != SRSRAN_SUCCESS) { fprintf(stderr, "Error: Couldn't initialize system simulator\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } return syssim.run(); diff --git a/srsue/test/ttcn3/src/ttcn3_syssim.cc b/srsue/test/ttcn3/src/ttcn3_syssim.cc index 0d9da2b45..b9f072736 100644 --- a/srsue/test/ttcn3/src/ttcn3_syssim.cc +++ b/srsue/test/ttcn3/src/ttcn3_syssim.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -12,11 +12,11 @@ #include "srsue/test/ttcn3/hdr/ttcn3_syssim.h" #include "dut_utils.h" -#include "srslte/mac/pdu_queue.h" -#include "srslte/srslog/srslog.h" -#include "srslte/test/ue_test_interfaces.h" -#include "srslte/upper/pdcp.h" -#include "srslte/upper/rlc.h" +#include "srsran/mac/pdu_queue.h" +#include "srsran/srslog/srslog.h" +#include "srsran/test/ue_test_interfaces.h" +#include "srsran/upper/pdcp.h" +#include "srsran/upper/rlc.h" #include "swappable_sink.h" #include "ttcn3_common.h" #include "ttcn3_drb_interface.h" @@ -52,7 +52,7 @@ ttcn3_syssim::ttcn3_syssim(ttcn3_ue* ue_) : signal_handler(&running), timer_handler(create_tti_timer(), [&](uint64_t res) { new_tti_indication(res); }) { - if (ue->init(all_args_t{}, this, "INIT_TEST") != SRSLTE_SUCCESS) { + if (ue->init(all_args_t{}, this, "INIT_TEST") != SRSRAN_SUCCESS) { ue->stop(); fprintf(stderr, "Couldn't initialize UE.\n"); } @@ -69,8 +69,8 @@ int ttcn3_syssim::init(const all_args_t& args_) auto* swp_sink = srslog::find_sink(swappable_sink::name()); if (!swp_sink) { logger.error("Unable to find the swappable sink"); - srslte::console("Unable to find the swappable sink\n"); - return SRSLTE_ERROR; + srsran::console("Unable to find the swappable sink\n"); + return SRSRAN_ERROR; } static_cast(swp_sink)->swap_to_stdout(); } @@ -103,27 +103,27 @@ int ttcn3_syssim::init(const all_args_t& args_) epoll_fd = epoll_create1(0); if (epoll_fd == -1) { logger.error("Error creating epoll"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // add signalfd signal_fd = add_signalfd(); - if (add_epoll(signal_fd, epoll_fd) != SRSLTE_SUCCESS) { + if (add_epoll(signal_fd, epoll_fd) != SRSRAN_SUCCESS) { logger.error("Error while adding signalfd to epoll"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } event_handler.insert({signal_fd, &signal_handler}); // init system interfaces to tester - if (add_port_handler() != SRSLTE_SUCCESS) { + if (add_port_handler() != SRSRAN_SUCCESS) { logger.error("Error creating port handlers"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Init common SS layers pdus.init(this); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } void ttcn3_syssim::set_forced_lcid(int lcid) @@ -135,59 +135,59 @@ int ttcn3_syssim::add_port_handler() { // UT port int ut_fd = ut.init(this, listen_address, UT_PORT); - if (add_epoll(ut_fd, epoll_fd) != SRSLTE_SUCCESS) { + if (add_epoll(ut_fd, epoll_fd) != SRSRAN_SUCCESS) { logger.error("Error while adding UT port to epoll"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } event_handler.insert({ut_fd, &ut}); - srslte::console("UT handler listening on SCTP port %d\n", UT_PORT); + srsran::console("UT handler listening on SCTP port %d\n", UT_PORT); // SYS port int sys_fd = sys.init(this, listen_address, SYS_PORT); - if (add_epoll(sys_fd, epoll_fd) != SRSLTE_SUCCESS) { + if (add_epoll(sys_fd, epoll_fd) != SRSRAN_SUCCESS) { logger.error("Error while adding SYS port to epoll"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } event_handler.insert({sys_fd, &sys}); - srslte::console("SYS handler listening on SCTP port %d\n", SYS_PORT); + srsran::console("SYS handler listening on SCTP port %d\n", SYS_PORT); // IPsock port int ip_sock_fd = ip_sock.init(listen_address, IPSOCK_PORT); - if (add_epoll(ip_sock_fd, epoll_fd) != SRSLTE_SUCCESS) { + if (add_epoll(ip_sock_fd, epoll_fd) != SRSRAN_SUCCESS) { logger.error("Error while adding IP sock port to epoll"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } event_handler.insert({ip_sock_fd, &ip_sock}); - srslte::console("IPSOCK handler listening on SCTP port %d\n", IPSOCK_PORT); + srsran::console("IPSOCK handler listening on SCTP port %d\n", IPSOCK_PORT); // IPctrl port int ip_ctrl_fd = ip_ctrl.init(listen_address, IPCTRL_PORT); - if (add_epoll(ip_ctrl_fd, epoll_fd) != SRSLTE_SUCCESS) { + if (add_epoll(ip_ctrl_fd, epoll_fd) != SRSRAN_SUCCESS) { logger.error("Error while adding IP ctrl port to epoll"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } event_handler.insert({ip_ctrl_fd, &ip_ctrl}); - srslte::console("IPCTRL handler listening on SCTP port %d\n", IPCTRL_PORT); + srsran::console("IPCTRL handler listening on SCTP port %d\n", IPCTRL_PORT); // add SRB fd int srb_fd = srb.init(this, listen_address, SRB_PORT); - if (add_epoll(srb_fd, epoll_fd) != SRSLTE_SUCCESS) { + if (add_epoll(srb_fd, epoll_fd) != SRSRAN_SUCCESS) { logger.error("Error while adding SRB port to epoll"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } event_handler.insert({srb_fd, &srb}); - srslte::console("SRB handler listening on SCTP port %d\n", SRB_PORT); + srsran::console("SRB handler listening on SCTP port %d\n", SRB_PORT); // add DRB fd int drb_fd = drb.init(this, listen_address, DRB_PORT); - if (add_epoll(drb_fd, epoll_fd) != SRSLTE_SUCCESS) { + if (add_epoll(drb_fd, epoll_fd) != SRSRAN_SUCCESS) { logger.error("Error while adding DRB port to epoll"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } event_handler.insert({drb_fd, &drb}); - srslte::console("DRB handler listening on SCTP port %d\n", DRB_PORT); + srsran::console("DRB handler listening on SCTP port %d\n", DRB_PORT); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } ///< Function called by epoll timer handler when TTI timer expires @@ -219,19 +219,19 @@ void ttcn3_syssim::new_tti_indication(uint64_t res) ss_events_t ev = event_queue.wait_pop(); switch (ev) { case UE_SWITCH_ON: - srslte::console("Switching on UE ID=%d\n", run_id); + srsran::console("Switching on UE ID=%d\n", run_id); ue->switch_on(); break; case UE_SWITCH_OFF: - srslte::console("Switching off UE ID=%d\n", run_id); + srsran::console("Switching off UE ID=%d\n", run_id); ue->switch_off(); break; case ENABLE_DATA: - srslte::console("Enabling data for UE ID=%d\n", run_id); + srsran::console("Enabling data for UE ID=%d\n", run_id); ue->enable_data(); break; case DISABLE_DATA: - srslte::console("Disabling data for UE ID=%d\n", run_id); + srsran::console("Disabling data for UE ID=%d\n", run_id); ue->disable_data(); break; } @@ -244,7 +244,7 @@ void ttcn3_syssim::new_tti_indication(uint64_t res) // DL/UL processing if UE has selected cell dl_rnti = ue->get_dl_sched_rnti(tti); - if (SRSLTE_RNTI_ISSI(dl_rnti)) { + if (SRSRAN_RNTI_ISSI(dl_rnti)) { // deliver SIBs one after another mac_interface_phy_lte::mac_grant_dl_t dl_grant = {}; dl_grant.tti = tti; @@ -255,17 +255,17 @@ void ttcn3_syssim::new_tti_indication(uint64_t res) ue->new_tb(dl_grant, cells[pcell_idx]->sibs[cells[pcell_idx]->sib_idx]->msg); logger.info("Delivered SIB%d for pcell_idx=%d", cells[pcell_idx]->sib_idx, pcell_idx); cells[pcell_idx]->sib_idx = (cells[pcell_idx]->sib_idx + 1) % cells[pcell_idx]->sibs.size(); - } else if (SRSLTE_RNTI_ISRAR(dl_rnti)) { + } else if (SRSRAN_RNTI_ISRAR(dl_rnti)) { if (prach_tti != -1) { rar_tti = (prach_tti + 3) % 10240; if (tti == rar_tti) { send_rar(prach_preamble_index); } } - } else if (SRSLTE_RNTI_ISPA(dl_rnti)) { + } else if (SRSRAN_RNTI_ISPA(dl_rnti)) { logger.debug("Searching for paging RNTI"); // PCH will be triggered from SYSSIM after receiving Paging - } else if (SRSLTE_RNTI_ISUSER(dl_rnti)) { + } else if (SRSRAN_RNTI_ISUSER(dl_rnti)) { // check if this is for contention resolution after PRACH/RAR if (dl_rnti == cells[pcell_idx]->config.crnti) { logger.debug("Searching for C-RNTI=0x%x", dl_rnti); @@ -284,11 +284,11 @@ void ttcn3_syssim::new_tti_indication(uint64_t res) send_sr_ul_grant(); } - if (dl_rnti != SRSLTE_INVALID_RNTI) { + if (dl_rnti != SRSRAN_INVALID_RNTI) { logger.debug("Searching for RNTI=0x%x", dl_rnti); // look for DL data to be send in each bearer and provide grant accordingly - for (int lcid = 0; lcid < SRSLTE_N_RADIO_BEARERS; lcid++) { + for (int lcid = 0; lcid < SRSRAN_N_RADIO_BEARERS; lcid++) { uint32_t buf_state = cells[pcell_idx]->rlc.get_buffer_state(lcid); // Schedule DL transmission if there is data in RLC buffer or we need to send Msg4 if ((buf_state > 0 && cells[pcell_idx]->bearer_follow_on_map[lcid] == false) || @@ -401,7 +401,7 @@ void ttcn3_syssim::tc_start(const char* name) auto* swp_sink = srslog::find_sink(swappable_sink::name()); if (!swp_sink) { logger.error("Unable to find the swappable sink"); - srslte::console("Unable to find the swappable sink\n"); + srsran::console("Unable to find the swappable sink\n"); return; } @@ -414,7 +414,7 @@ void ttcn3_syssim::tc_start(const char* name) } logger.info("Initializing UE ID=%d for TC=%s", run_id, tc_name.c_str()); - srslte::console("Initializing UE ID=%d for TC=%s\n", run_id, tc_name.c_str()); + srsran::console("Initializing UE ID=%d for TC=%s\n", run_id, tc_name.c_str()); // Patch UE config local_args.stack.pkt_trace.mac_pcap.filename = @@ -427,12 +427,12 @@ void ttcn3_syssim::tc_start(const char* name) ue->stop(); std::string err("Couldn't initialize UE."); logger.error("%s", err.c_str()); - srslte::console("%s\n", err.c_str()); + srsran::console("%s\n", err.c_str()); return; } // create and add TTI timer to epoll - if (add_epoll(timer_handler.get_timer_fd(), epoll_fd) != SRSLTE_SUCCESS) { + if (add_epoll(timer_handler.get_timer_fd(), epoll_fd) != SRSRAN_SUCCESS) { logger.error("Error while adding TTI timer to epoll"); } event_handler.insert({timer_handler.get_timer_fd(), &timer_handler}); @@ -442,7 +442,7 @@ void ttcn3_syssim::tc_start(const char* name) void ttcn3_syssim::tc_end() { logger.info("Deinitializing UE ID=%d", run_id); - srslte::console("Deinitializing UE ID=%d\n", run_id); + srsran::console("Deinitializing UE ID=%d\n", run_id); ue->stop(); // stop TTI timer @@ -535,7 +535,7 @@ void ttcn3_syssim::tx_pdu(const uint8_t* payload, const int len, const uint32_t // Save contention resolution if lcid == 0 if (mac_msg_ul.get()->get_sdu_lcid() == 0) { - int nbytes = srslte::sch_subh::MAC_CE_CONTRES_LEN; + int nbytes = srsran::sch_subh::MAC_CE_CONTRES_LEN; if (mac_msg_ul.get()->get_payload_size() >= (uint32_t)nbytes) { uint8_t* ue_cri_ptr = (uint8_t*)&conres_id; uint8_t* pkt_ptr = mac_msg_ul.get()->get_sdu_ptr(); // Warning here: we want to include the @@ -570,12 +570,12 @@ void ttcn3_syssim::send_rar(uint32_t preamble_index) // Prepare RAR grant uint8_t grant_buffer[64] = {}; - srslte_dci_rar_grant_t rar_grant = {}; + srsran_dci_rar_grant_t rar_grant = {}; rar_grant.tpc_pusch = 3; - srslte_dci_rar_pack(&rar_grant, grant_buffer); + srsran_dci_rar_pack(&rar_grant, grant_buffer); // Create MAC PDU and add RAR subheader - srslte::rar_pdu rar_pdu; + srsran::rar_pdu rar_pdu; rar_buffer.clear(); const int rar_pdu_len = 64; @@ -640,7 +640,7 @@ void ttcn3_syssim::send_sr_ul_grant() } // internal function called from tx_pdu (called from main thread) -bool ttcn3_syssim::process_ce(srslte::sch_subh* subh) +bool ttcn3_syssim::process_ce(srsran::sch_subh* subh) { uint16_t rnti = dl_rnti; @@ -651,29 +651,29 @@ bool ttcn3_syssim::process_ce(srslte::sch_subh* subh) uint16_t old_rnti = 0; bool is_bsr = false; switch (subh->ul_sch_ce_type()) { - case srslte::ul_sch_lcid::PHR_REPORT: + case srsran::ul_sch_lcid::PHR_REPORT: phr = subh->get_phr(); ss_mac_logger.info("CE: Received PHR from rnti=0x%x, value=%.0f", rnti, phr); break; - case srslte::ul_sch_lcid::CRNTI: + case srsran::ul_sch_lcid::CRNTI: old_rnti = subh->get_c_rnti(); ss_mac_logger.info("CE: Received C-RNTI from temp_rnti=0x%x, rnti=0x%x", rnti, old_rnti); break; - case srslte::ul_sch_lcid::TRUNC_BSR: - case srslte::ul_sch_lcid::SHORT_BSR: + case srsran::ul_sch_lcid::TRUNC_BSR: + case srsran::ul_sch_lcid::SHORT_BSR: idx = subh->get_bsr(buff_size_idx, buff_size_bytes); if (idx == -1) { ss_mac_logger.error("Invalid Index Passed to lc groups"); break; } ss_mac_logger.info("CE: Received %s BSR rnti=0x%x, lcg=%d, value=%d", - subh->ul_sch_ce_type() == srslte::ul_sch_lcid::SHORT_BSR ? "Short" : "Trunc", + subh->ul_sch_ce_type() == srsran::ul_sch_lcid::SHORT_BSR ? "Short" : "Trunc", rnti, idx, buff_size_idx[idx]); is_bsr = true; break; - case srslte::ul_sch_lcid::LONG_BSR: + case srsran::ul_sch_lcid::LONG_BSR: subh->get_bsr(buff_size_idx, buff_size_bytes); is_bsr = true; ss_mac_logger.info("CE: Received Long BSR rnti=0x%x, value=%d,%d,%d,%d", @@ -683,7 +683,7 @@ bool ttcn3_syssim::process_ce(srslte::sch_subh* subh) buff_size_idx[2], buff_size_idx[3]); break; - case srslte::ul_sch_lcid::PADDING: + case srsran::ul_sch_lcid::PADDING: ss_mac_logger.debug("CE: Received padding for rnti=0x%x", rnti); break; default: @@ -695,7 +695,7 @@ bool ttcn3_syssim::process_ce(srslte::sch_subh* subh) uint32_t ttcn3_syssim::get_pid(const uint32_t tti_) { - return tti_ % SRSLTE_FDD_NOF_HARQ; + return tti_ % SRSRAN_FDD_NOF_HARQ; } bool ttcn3_syssim::get_ndi_for_new_ul_tx(const uint32_t tti_) @@ -751,7 +751,7 @@ int ttcn3_syssim::run() } } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } uint32_t ttcn3_syssim::get_tti() @@ -894,7 +894,7 @@ void ttcn3_syssim::add_ccch_pdu(const ttcn3_helpers::timing_info_t timing, add_ccch_pdu_impl(cell_name, std::move(pdu)); } else { logger.debug("Scheduling CCCH PDU for TTI=%d", timing.tti); - auto task = [this, cell_name](srslte::unique_byte_buffer_t& pdu) { add_ccch_pdu_impl(cell_name, std::move(pdu)); }; + auto task = [this, cell_name](srsran::unique_byte_buffer_t& pdu) { add_ccch_pdu_impl(cell_name, std::move(pdu)); }; tti_actions[timing.tti].push(std::bind(task, std::move(pdu))); } } @@ -921,7 +921,7 @@ void ttcn3_syssim::add_dcch_pdu(const ttcn3_helpers::timing_info_t timing, add_dcch_pdu_impl(cell_name, lcid, std::move(pdu), follow_on_flag); } else { logger.debug("Scheduling DCCH PDU for TTI=%d", timing.tti); - auto task = [this, cell_name](uint32_t lcid, srslte::unique_byte_buffer_t& pdu, bool follow_on_flag) { + auto task = [this, cell_name](uint32_t lcid, srsran::unique_byte_buffer_t& pdu, bool follow_on_flag) { add_dcch_pdu_impl(cell_name, lcid, std::move(pdu), follow_on_flag); }; tti_actions[timing.tti].push(std::bind(task, lcid, std::move(pdu), follow_on_flag)); @@ -954,7 +954,7 @@ void ttcn3_syssim::add_pch_pdu(unique_byte_buffer_t pdu) mac_interface_phy_lte::mac_grant_dl_t dl_grant = {}; dl_grant.tti = tti; dl_grant.pid = get_pid(tti); - dl_grant.rnti = SRSLTE_PRNTI; + dl_grant.rnti = SRSRAN_PRNTI; dl_grant.tb[0].tbs = pdu->N_bytes; dl_grant.tb[0].ndi_present = true; dl_grant.tb[0].ndi = get_ndi_for_new_dl_tx(tti); @@ -991,7 +991,7 @@ void ttcn3_syssim::add_srb_impl(const std::string cell_name, const uint32_t lcid logger.info("Adding SRB%d", lcid); cell->pdcp.add_bearer(lcid, pdcp_config); - cell->rlc.add_bearer(lcid, srslte::rlc_config_t::srb_config(lcid)); + cell->rlc.add_bearer(lcid, srsran::rlc_config_t::srb_config(lcid)); } void ttcn3_syssim::reestablish_bearer(const std::string cell_name, const uint32_t lcid) @@ -1038,7 +1038,7 @@ void ttcn3_syssim::del_srb_impl(const std::string cell_name, const uint32_t lcid void ttcn3_syssim::add_drb(const ttcn3_helpers::timing_info_t timing, const std::string cell_name, const uint32_t lcid, - const srslte::pdcp_config_t pdcp_config) + const srsran::pdcp_config_t pdcp_config) { if (timing.now) { add_drb_impl(cell_name, lcid, pdcp_config); @@ -1061,7 +1061,7 @@ void ttcn3_syssim::add_drb_impl(const std::string cell_name, const uint32_t lcid if (lcid > 2) { logger.info("Adding DRB%d", lcid - 2); cell->pdcp.add_bearer(lcid, pdcp_config); - cell->rlc.add_bearer(lcid, srslte::rlc_config_t::default_rlc_am_config()); + cell->rlc.add_bearer(lcid, srsran::rlc_config_t::default_rlc_am_config()); } } @@ -1180,8 +1180,8 @@ void ttcn3_syssim::set_as_security(const ttcn3_helpers::timing_info_t tim std::array k_rrc_enc_, std::array k_rrc_int_, std::array k_up_enc_, - const srslte::CIPHERING_ALGORITHM_ID_ENUM cipher_algo_, - const srslte::INTEGRITY_ALGORITHM_ID_ENUM integ_algo_, + const srsran::CIPHERING_ALGORITHM_ID_ENUM cipher_algo_, + const srsran::INTEGRITY_ALGORITHM_ID_ENUM integ_algo_, const ttcn3_helpers::pdcp_count_map_t bearers_) { if (timing.now) { @@ -1199,8 +1199,8 @@ void ttcn3_syssim::set_as_security_impl(const std::string std::array k_rrc_enc_, std::array k_rrc_int_, std::array k_up_enc_, - const srslte::CIPHERING_ALGORITHM_ID_ENUM cipher_algo_, - const srslte::INTEGRITY_ALGORITHM_ID_ENUM integ_algo_, + const srsran::CIPHERING_ALGORITHM_ID_ENUM cipher_algo_, + const srsran::INTEGRITY_ALGORITHM_ID_ENUM integ_algo_, const ttcn3_helpers::pdcp_count_map_t bearers) { if (not syssim_has_cell(cell_name)) { @@ -1252,7 +1252,7 @@ void ttcn3_syssim::release_as_security_impl(const std::string cell_name) cell->pending_bearer_config.clear(); } -void ttcn3_syssim::select_cell(srslte_cell_t phy_cell) +void ttcn3_syssim::select_cell(srsran_cell_t phy_cell) { // find matching cell in SS cell list for (uint32_t i = 0; i < cells.size(); ++i) { @@ -1280,7 +1280,7 @@ ttcn3_helpers::pdcp_count_map_t ttcn3_syssim::get_pdcp_count(const std::string c if (cell->pdcp.is_lcid_enabled(i)) { ttcn3_helpers::pdcp_count_t bearer; uint16_t tmp; // not handling HFN - srslte::pdcp_lte_state_t pdcp_state; + srsran::pdcp_lte_state_t pdcp_state; cell->pdcp.get_bearer_state(i, &pdcp_state); bearer.rb_is_srb = i <= 2; bearer.rb_id = i; diff --git a/srsue/test/ttcn3/src/ttcn3_ue.cc b/srsue/test/ttcn3/src/ttcn3_ue.cc index db25651b4..9ede249e7 100644 --- a/srsue/test/ttcn3/src/ttcn3_ue.cc +++ b/srsue/test/ttcn3/src/ttcn3_ue.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -16,8 +16,8 @@ #include extern "C" { -SRSLTE_API char* srslte_get_build_info(); -SRSLTE_API char* srslte_get_build_mode(); +SRSRAN_API char* srsran_get_build_info(); +SRSRAN_API char* srsran_get_build_mode(); } ttcn3_ue::ttcn3_ue() : logger(srslog::fetch_basic_logger("UE", false)), tft_matcher(logger) {} @@ -27,7 +27,7 @@ int ttcn3_ue::init(all_args_t args, syssim_interface_phy* syssim_, const std::st // Init UE log logger.set_level(srslog::basic_levels::info); logger.set_hex_dump_max_size(128); - logger.info("Built in %s mode using %s.", srslte_get_build_mode(), srslte_get_build_info()); + logger.info("Built in %s mode using %s.", srsran_get_build_mode(), srsran_get_build_info()); // Patch args args.stack.nas.force_imsi_attach = true; @@ -41,7 +41,7 @@ int ttcn3_ue::init(all_args_t args, syssim_interface_phy* syssim_, const std::st args.stack.usim.k = "000102030405060708090A0B0C0D0E0F"; // fixed as per TS 34.108 Sec. 8.2 args.stack.rrc.feature_group = 0xe6041000; - args.stack.rrc.ue_category_str = SRSLTE_UE_CATEGORY_DEFAULT; + args.stack.rrc.ue_category_str = SRSRAN_UE_CATEGORY_DEFAULT; args.stack.rrc.ue_category = strtol(args.stack.rrc.ue_category_str.c_str(), nullptr, 10); args.stack.rrc.nof_supported_bands = 1; args.stack.rrc.supported_bands[0] = 7; @@ -57,32 +57,32 @@ int ttcn3_ue::init(all_args_t args, syssim_interface_phy* syssim_, const std::st if (args.stack.type == "lte") { stack = std::unique_ptr(new ue_stack_lte); if (!stack) { - srslte::console("Error creating LTE stack instance.\n"); - return SRSLTE_ERROR; + srsran::console("Error creating LTE stack instance.\n"); + return SRSRAN_ERROR; } phy = std::unique_ptr(new srsue::lte_ttcn3_phy); if (!phy) { - srslte::console("Error creating LTE PHY instance.\n"); - return SRSLTE_ERROR; + srsran::console("Error creating LTE PHY instance.\n"); + return SRSRAN_ERROR; } } else { - srslte::console("Invalid stack type %s. Supported values are [lte].\n", args.stack.type.c_str()); - return SRSLTE_ERROR; + srsran::console("Invalid stack type %s. Supported values are [lte].\n", args.stack.type.c_str()); + return SRSRAN_ERROR; } // init layers if (phy->init(args.phy, stack.get(), syssim_)) { - srslte::console("Error initializing PHY.\n"); - return SRSLTE_ERROR; + srsran::console("Error initializing PHY.\n"); + return SRSRAN_ERROR; } if (stack->init(args.stack, phy.get(), this)) { - srslte::console("Error initializing stack.\n"); - return SRSLTE_ERROR; + srsran::console("Error initializing stack.\n"); + return SRSRAN_ERROR; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } ttcn3_ue::~ttcn3_ue() @@ -150,7 +150,7 @@ uint16_t ttcn3_ue::get_dl_sched_rnti(uint32_t tti) // GW interface void ttcn3_ue::add_mch_port(uint32_t lcid, uint32_t port) {} -void ttcn3_ue::write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t pdu) +void ttcn3_ue::write_pdu(uint32_t lcid, srsran::unique_byte_buffer_t pdu) { logger.debug(pdu->msg, pdu->N_bytes, "Rx PDU (%d B) on lcid=%d", pdu->N_bytes, lcid); switch (test_loop_mode) { @@ -178,7 +178,7 @@ void ttcn3_ue::write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t pdu) break; } } -void ttcn3_ue::write_pdu_mch(uint32_t lcid, srslte::unique_byte_buffer_t pdu) {} +void ttcn3_ue::write_pdu_mch(uint32_t lcid, srsran::unique_byte_buffer_t pdu) {} int ttcn3_ue::setup_if_addr(uint32_t eps_bearer_id, uint32_t lcid, uint8_t pdn_type, @@ -190,7 +190,7 @@ int ttcn3_ue::setup_if_addr(uint32_t eps_bearer_id, } int ttcn3_ue::update_lcid(uint32_t eps_bearer_id, uint32_t new_lcid) { - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int ttcn3_ue::apply_traffic_flow_template(const uint8_t& eps_bearer_id, @@ -246,14 +246,14 @@ void ttcn3_ue::send_queued_data() for (auto& bearer_pdu_queue : pdu_queue) { logger.info("Delivering %zd buffered PDUs for LCID=%d", bearer_pdu_queue.second.size(), bearer_pdu_queue.first); while (not bearer_pdu_queue.second.empty()) { - srslte::unique_byte_buffer_t pdu; + srsran::unique_byte_buffer_t pdu; bearer_pdu_queue.second.try_pop(&pdu); loop_back_pdu_with_tft(bearer_pdu_queue.first, std::move(pdu)); } } } -void ttcn3_ue::loop_back_pdu_with_tft(uint32_t input_lcid, srslte::unique_byte_buffer_t pdu) +void ttcn3_ue::loop_back_pdu_with_tft(uint32_t input_lcid, srsran::unique_byte_buffer_t pdu) { logger.info(pdu->msg, pdu->N_bytes, "Rx PDU (%d B) on lcid=%d, looping back", pdu->N_bytes, input_lcid); stack->write_sdu(input_lcid, std::move(pdu)); diff --git a/srsue/test/ttcn3/test/CMakeLists.txt b/srsue/test/ttcn3/test/CMakeLists.txt index f4dea0dc2..2e46bd4f1 100644 --- a/srsue/test/ttcn3/test/CMakeLists.txt +++ b/srsue/test/ttcn3/test/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -9,9 +9,9 @@ include_directories(${PROJECT_SOURCE_DIR}/srsue/test/ttcn3/hdr) add_executable(rapidjson_test rapidjson_test.cc) -target_link_libraries(rapidjson_test srslte_common) +target_link_libraries(rapidjson_test srsran_common) add_test(rapidjson_test rapidjson_test) add_executable(ttcn3_if_handler_test ttcn3_if_handler_test.cc) -target_link_libraries(ttcn3_if_handler_test sctp srslte_phy srslte_common rrc_asn1) +target_link_libraries(ttcn3_if_handler_test sctp srsran_phy srsran_common rrc_asn1) add_test(ttcn3_if_handler_test ttcn3_if_handler_test) \ No newline at end of file diff --git a/srsue/test/ttcn3/test/rapidjson_test.cc b/srsue/test/ttcn3/test/rapidjson_test.cc index f3ed4bbcd..e7c56060f 100644 --- a/srsue/test/ttcn3/test/rapidjson_test.cc +++ b/srsue/test/ttcn3/test/rapidjson_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,7 +10,7 @@ * */ -#include "srslte/common/test_common.h" +#include "srsran/common/test_common.h" #include "ttcn3_helpers.h" #include #include @@ -78,7 +78,7 @@ int pretty_print(std::string json) PrettyWriter writer(buffer); document.Accept(writer); printf("%s\n", (char*)buffer.GetString()); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // UDP v4 test diff --git a/srsue/test/ttcn3/test/ttcn3_if_handler_test.cc b/srsue/test/ttcn3/test/ttcn3_if_handler_test.cc index 4e4efcf35..4d6e6d307 100644 --- a/srsue/test/ttcn3/test/ttcn3_if_handler_test.cc +++ b/srsue/test/ttcn3/test/ttcn3_if_handler_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -25,7 +25,7 @@ int if_handler_test() ttcn3_ip_ctrl_interface ip_ctrl(logger); ttcn3_srb_interface srb(logger); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int main(int argc, char** argv) @@ -34,5 +34,5 @@ int main(int argc, char** argv) if_handler_test(); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } diff --git a/srsue/test/upper/CMakeLists.txt b/srsue/test/upper/CMakeLists.txt index 630ae27ba..06832a052 100644 --- a/srsue/test/upper/CMakeLists.txt +++ b/srsue/test/upper/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -7,44 +7,44 @@ # add_executable(usim_test usim_test.cc) -target_link_libraries(usim_test srsue_upper srslte_upper srslte_phy rrc_asn1) +target_link_libraries(usim_test srsue_upper srsran_upper srsran_phy rrc_asn1) add_test(usim_test usim_test) if(HAVE_PCSC) add_executable(pcsc_usim_test pcsc_usim_test.cc) - target_link_libraries(pcsc_usim_test srsue_upper srslte_upper srslte_phy) + target_link_libraries(pcsc_usim_test srsue_upper srsran_upper srsran_phy) endif(HAVE_PCSC) add_executable(rrc_reconfig_test rrc_reconfig_test.cc) -target_link_libraries(rrc_reconfig_test srsue_upper srslte_upper srslte_phy rrc_asn1) +target_link_libraries(rrc_reconfig_test srsue_upper srsran_upper srsran_phy rrc_asn1) add_test(rrc_reconfig_test rrc_reconfig_test) add_executable(rrc_meas_test rrc_meas_test.cc) -target_link_libraries(rrc_meas_test srsue_rrc srsue_upper srslte_upper srslte_phy rrc_asn1 rrc_nr_asn1) +target_link_libraries(rrc_meas_test srsue_rrc srsue_upper srsran_upper srsran_phy rrc_asn1 rrc_nr_asn1) add_test(rrc_meas_test rrc_meas_test) add_executable(nas_test nas_test.cc) -target_link_libraries(nas_test srsue_upper srslte_upper srslte_phy rrc_asn1) +target_link_libraries(nas_test srsue_upper srsran_upper srsran_phy rrc_asn1) add_test(nas_test nas_test) add_executable(gw_test gw_test.cc) -target_link_libraries(gw_test srsue_upper srslte_upper srslte_phy) +target_link_libraries(gw_test srsue_upper srsran_upper srsran_phy) add_test(gw_test gw_test) add_executable(tft_test tft_test.cc) -target_link_libraries(tft_test srsue_upper srslte_upper srslte_phy) +target_link_libraries(tft_test srsue_upper srsran_upper srsran_phy) add_test(tft_test tft_test) add_executable(rrc_phy_ctrl_test rrc_phy_ctrl_test.cc) -target_link_libraries(rrc_phy_ctrl_test srslte_common srsue_rrc) +target_link_libraries(rrc_phy_ctrl_test srsran_common srsue_rrc) add_test(rrc_phy_ctrl_test rrc_phy_ctrl_test) add_executable(rrc_cell_test rrc_cell_test.cc) -target_link_libraries(rrc_cell_test srsue_rrc srsue_upper srslte_upper srslte_phy rrc_asn1 rrc_nr_asn1) +target_link_libraries(rrc_cell_test srsue_rrc srsue_upper srsran_upper srsran_phy rrc_asn1 rrc_nr_asn1) add_test(rrc_cell_test rrc_cell_test) add_executable(ue_rrc_nr_test ue_rrc_nr_test.cc) -target_link_libraries(ue_rrc_nr_test srsue_rrc srsue_upper srslte_upper srslte_phy rrc_asn1 rrc_nr_asn1) +target_link_libraries(ue_rrc_nr_test srsue_rrc srsue_upper srsran_upper srsran_phy rrc_asn1 rrc_nr_asn1) ######################################################################## # Option to run command after build (useful for remote builds) diff --git a/srsue/test/upper/gw_test.cc b/srsue/test/upper/gw_test.cc index bb68ab019..3fa169784 100644 --- a/srsue/test/upper/gw_test.cc +++ b/srsue/test/upper/gw_test.cc @@ -10,9 +10,9 @@ * */ -#include "srslte/common/test_common.h" -#include "srslte/interfaces/ue_pdcp_interfaces.h" -#include "srslte/srslog/srslog.h" +#include "srsran/common/test_common.h" +#include "srsran/interfaces/ue_pdcp_interfaces.h" +#include "srsran/srslog/srslog.h" #include "srsue/hdr/stack/upper/gw.h" #include @@ -22,7 +22,7 @@ class test_stack_dummy : public srsue::stack_interface_gw public: bool is_registered() { return true; } bool start_service_request() { return true; }; - void write_sdu(uint32_t lcid, srslte::unique_byte_buffer_t sdu) { return; } + void write_sdu(uint32_t lcid, srsran::unique_byte_buffer_t sdu) { return; } bool is_lcid_enabled(uint32_t lcid) { return true; } }; @@ -46,24 +46,24 @@ int gw_change_lcid_test() rtn = gw.setup_if_addr( eps_bearer_id, old_lcid, LIBLTE_MME_PDN_TYPE_IPV4, htonl(inet_addr("192.168.56.32")), nullptr, err_str); - if (rtn != SRSLTE_SUCCESS) { + if (rtn != SRSRAN_SUCCESS) { srslog::fetch_basic_logger("TEST", false) .error("Failed to setup GW interface. Not possible to test function. Try to execute with sudo rights."); gw.stop(); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } - TESTASSERT(gw.update_lcid(eps_bearer_id, new_lcid) == SRSLTE_SUCCESS); - TESTASSERT(gw.update_lcid(non_existing_eps_bearer_id, new_lcid) == SRSLTE_ERROR); + TESTASSERT(gw.update_lcid(eps_bearer_id, new_lcid) == SRSRAN_SUCCESS); + TESTASSERT(gw.update_lcid(non_existing_eps_bearer_id, new_lcid) == SRSRAN_ERROR); gw.stop(); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int main(int argc, char** argv) { srslog::init(); - TESTASSERT(gw_change_lcid_test() == SRSLTE_SUCCESS); + TESTASSERT(gw_change_lcid_test() == SRSRAN_SUCCESS); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } diff --git a/srsue/test/upper/nas_test.cc b/srsue/test/upper/nas_test.cc index 5a7d410db..c4b6634e1 100644 --- a/srsue/test/upper/nas_test.cc +++ b/srsue/test/upper/nas_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,11 +10,11 @@ * */ -#include "srslte/common/bcd_helpers.h" -#include "srslte/common/test_common.h" -#include "srslte/interfaces/ue_pdcp_interfaces.h" -#include "srslte/srslog/srslog.h" -#include "srslte/test/ue_test_interfaces.h" +#include "srsran/common/bcd_helpers.h" +#include "srsran/common/test_common.h" +#include "srsran/interfaces/ue_pdcp_interfaces.h" +#include "srsran/srslog/srslog.h" +#include "srsran/test/ue_test_interfaces.h" #include "srsue/hdr/stack/upper/gw.h" #include "srsue/hdr/stack/upper/nas.h" #include "srsue/hdr/stack/upper/usim.h" @@ -57,9 +57,9 @@ uint8_t deactivate_eps_bearer_pdu[] = {0x27, 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, uint16 mcc = 61441; uint16 mnc = 65281; -using namespace srslte; +using namespace srsran; -namespace srslte { +namespace srsran { // fake classes class pdcp_dummy : public rrc_interface_pdcp, public pdcp_interface_gw @@ -69,9 +69,9 @@ public: void write_pdu_bcch_bch(unique_byte_buffer_t pdu) {} void write_pdu_bcch_dlsch(unique_byte_buffer_t pdu) {} void write_pdu_pcch(unique_byte_buffer_t pdu) {} - void write_pdu_mch(uint32_t lcid, srslte::unique_byte_buffer_t sdu) {} + void write_pdu_mch(uint32_t lcid, srsran::unique_byte_buffer_t sdu) {} std::string get_rb_name(uint32_t lcid) { return std::string("lcid"); } - void write_sdu(uint32_t lcid, srslte::unique_byte_buffer_t sdu) {} + void write_sdu(uint32_t lcid, srsran::unique_byte_buffer_t sdu) {} bool is_lcid_enabled(uint32_t lcid) { return false; } }; @@ -88,7 +88,7 @@ public: { last_sdu_len = sdu->N_bytes; // printf("NAS generated SDU (len=%d):\n", sdu->N_bytes); - // srslte_vec_fprint_byte(stdout, sdu->msg, sdu->N_bytes); + // srsran_vec_fprint_byte(stdout, sdu->msg, sdu->N_bytes); } std::string get_rb_name(uint32_t lcid) { return std::string("lcid"); } uint32_t get_last_sdu_len() { return last_sdu_len; } @@ -99,13 +99,13 @@ public: nas_ptr->plmn_search_completed(plmns, 1); return true; } - void plmn_select(srslte::plmn_id_t plmn_id){}; - void set_ue_identity(srslte::s_tmsi_t s_tmsi) {} - bool connection_request(srslte::establishment_cause_t cause, srslte::unique_byte_buffer_t sdu) + void plmn_select(srsran::plmn_id_t plmn_id){}; + void set_ue_identity(srsran::s_tmsi_t s_tmsi) {} + bool connection_request(srsran::establishment_cause_t cause, srsran::unique_byte_buffer_t sdu) { printf("NAS generated SDU (len=%d):\n", sdu->N_bytes); last_sdu_len = sdu->N_bytes; - srslte_vec_fprint_byte(stdout, sdu->msg, sdu->N_bytes); + srsran_vec_fprint_byte(stdout, sdu->msg, sdu->N_bytes); is_connected_flag = true; nas_ptr->connection_request_completed(true); return true; @@ -136,7 +136,7 @@ public: start(-1); } bool switch_on() { return true; } - void write_sdu(uint32_t lcid, srslte::unique_byte_buffer_t sdu) { pdcp->write_sdu(lcid, std::move(sdu)); } + void write_sdu(uint32_t lcid, srsran::unique_byte_buffer_t sdu) { pdcp->write_sdu(lcid, std::move(sdu)); } bool is_lcid_enabled(uint32_t lcid) { return pdcp->is_lcid_enabled(lcid); } bool is_registered() { return true; } @@ -180,24 +180,24 @@ class gw_dummy : public gw_interface_nas, public gw_interface_pdcp uint8_t* ipv6_if_id, char* err_str) { - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int apply_traffic_flow_template(const uint8_t& eps_bearer_id, const uint8_t& lcid, const LIBLTE_MME_TRAFFIC_FLOW_TEMPLATE_STRUCT* tft) { - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } void write_pdu(uint32_t lcid, unique_byte_buffer_t pdu) {} - void write_pdu_mch(uint32_t lcid, srslte::unique_byte_buffer_t sdu) {} + void write_pdu_mch(uint32_t lcid, srsran::unique_byte_buffer_t sdu) {} void set_test_loop_mode(const test_loop_mode_state_t mode, const uint32_t ip_pdu_delay_ms = 0) {} }; -} // namespace srslte +} // namespace srsran int security_command_test() { - int ret = SRSLTE_ERROR; + int ret = SRSRAN_ERROR; stack_test_dummy stack; rrc_dummy rrc_dummy; @@ -225,7 +225,7 @@ int security_command_test() // push auth request PDU to NAS to generate security context byte_buffer_pool* pool = byte_buffer_pool::get_instance(); - unique_byte_buffer_t tmp = srslte::make_byte_buffer(); + unique_byte_buffer_t tmp = srsran::make_byte_buffer(); memcpy(tmp->msg, auth_request_pdu, sizeof(auth_request_pdu)); tmp->N_bytes = sizeof(auth_request_pdu); nas.write_pdu(LCID, std::move(tmp)); @@ -234,14 +234,14 @@ int security_command_test() rrc_dummy.reset(); // reuse buffer for security mode command - tmp = srslte::make_byte_buffer(); + tmp = srsran::make_byte_buffer(); memcpy(tmp->msg, sec_mode_command_pdu, sizeof(sec_mode_command_pdu)); tmp->N_bytes = sizeof(sec_mode_command_pdu); nas.write_pdu(LCID, std::move(tmp)); // check length of generated NAS SDU if (rrc_dummy.get_last_sdu_len() > 3) { - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } } @@ -250,7 +250,7 @@ int security_command_test() int mme_attach_request_test() { - int ret = SRSLTE_ERROR; + int ret = SRSRAN_ERROR; rrc_dummy rrc_dummy; pdcp_dummy pdcp_dummy; @@ -295,7 +295,7 @@ int mme_attach_request_test() // finally push attach accept byte_buffer_pool* pool = byte_buffer_pool::get_instance(); - unique_byte_buffer_t tmp = srslte::make_byte_buffer(); + unique_byte_buffer_t tmp = srsran::make_byte_buffer(); memcpy(tmp->msg, attach_accept_pdu, sizeof(attach_accept_pdu)); tmp->N_bytes = sizeof(attach_accept_pdu); nas.write_pdu(LCID, std::move(tmp)); @@ -305,7 +305,7 @@ int mme_attach_request_test() // check length of generated NAS SDU (attach complete) if (rrc_dummy.get_last_sdu_len() > 3) { - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } // ensure buffers are deleted before pool cleanup gw.stop(); @@ -316,7 +316,7 @@ int mme_attach_request_test() int esm_info_request_test() { - int ret = SRSLTE_ERROR; + int ret = SRSRAN_ERROR; srsue::stack_test_dummy stack{}; @@ -337,21 +337,21 @@ int esm_info_request_test() { srsue::nas nas(&stack.task_sched); nas_args_t cfg; - cfg.apn_name = "srslte"; + cfg.apn_name = "srsran"; cfg.apn_user = "srsuser"; cfg.apn_pass = "srspass"; cfg.force_imsi_attach = true; nas.init(&usim, &rrc_dummy, &gw, cfg); // push ESM info request PDU to NAS to generate response - unique_byte_buffer_t tmp = srslte::make_byte_buffer(); + unique_byte_buffer_t tmp = srsran::make_byte_buffer(); memcpy(tmp->msg, esm_info_req_pdu, sizeof(esm_info_req_pdu)); tmp->N_bytes = sizeof(esm_info_req_pdu); nas.write_pdu(LCID, std::move(tmp)); // check length of generated NAS SDU if (rrc_dummy.get_last_sdu_len() > 3) { - ret = SRSLTE_SUCCESS; + ret = SRSRAN_SUCCESS; } } @@ -382,7 +382,7 @@ int dedicated_eps_bearer_test() nas.init(&usim, &rrc_dummy, &gw, cfg); // push dedicated EPS bearer PDU to NAS - unique_byte_buffer_t tmp = srslte::make_byte_buffer(); + unique_byte_buffer_t tmp = srsran::make_byte_buffer(); memcpy(tmp->msg, activate_dedicated_eps_bearer_pdu, sizeof(activate_dedicated_eps_bearer_pdu)); tmp->N_bytes = sizeof(activate_dedicated_eps_bearer_pdu); nas.write_pdu(LCID, std::move(tmp)); @@ -393,7 +393,7 @@ int dedicated_eps_bearer_test() TESTASSERT(metrics.nof_active_eps_bearer == 0); // add default EPS beaerer - unique_byte_buffer_t attach_with_default_bearer = srslte::make_byte_buffer(); + unique_byte_buffer_t attach_with_default_bearer = srsran::make_byte_buffer(); memcpy(attach_with_default_bearer->msg, attach_accept_pdu, sizeof(attach_accept_pdu)); attach_with_default_bearer->N_bytes = sizeof(attach_accept_pdu); nas.write_pdu(LCID, std::move(attach_with_default_bearer)); @@ -403,7 +403,7 @@ int dedicated_eps_bearer_test() TESTASSERT(metrics.nof_active_eps_bearer == 1); // push dedicated bearer activation and check that it was added - tmp = srslte::make_byte_buffer(); + tmp = srsran::make_byte_buffer(); memcpy(tmp->msg, activate_dedicated_eps_bearer_pdu, sizeof(activate_dedicated_eps_bearer_pdu)); tmp->N_bytes = sizeof(activate_dedicated_eps_bearer_pdu); nas.write_pdu(LCID, std::move(tmp)); @@ -411,7 +411,7 @@ int dedicated_eps_bearer_test() TESTASSERT(metrics.nof_active_eps_bearer == 2); // tear-down dedicated bearer - tmp = srslte::make_byte_buffer(); + tmp = srsran::make_byte_buffer(); memcpy(tmp->msg, deactivate_eps_bearer_pdu, sizeof(deactivate_eps_bearer_pdu)); tmp->N_bytes = sizeof(deactivate_eps_bearer_pdu); nas.write_pdu(LCID, std::move(tmp)); @@ -419,14 +419,14 @@ int dedicated_eps_bearer_test() TESTASSERT(metrics.nof_active_eps_bearer == 1); // try to tear-down dedicated bearer again - tmp = srslte::make_byte_buffer(); + tmp = srsran::make_byte_buffer(); memcpy(tmp->msg, deactivate_eps_bearer_pdu, sizeof(deactivate_eps_bearer_pdu)); tmp->N_bytes = sizeof(deactivate_eps_bearer_pdu); nas.write_pdu(LCID, std::move(tmp)); nas.get_metrics(&metrics); TESTASSERT(metrics.nof_active_eps_bearer == 1); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int main(int argc, char** argv) diff --git a/srsue/test/upper/pcsc_usim_test.cc b/srsue/test/upper/pcsc_usim_test.cc index 807a9abe1..b5c58af29 100644 --- a/srsue/test/upper/pcsc_usim_test.cc +++ b/srsue/test/upper/pcsc_usim_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -39,21 +39,21 @@ int main(int argc, char** argv) srsue::pcsc_usim usim(logger); if (usim.init(&args)) { printf("Error initializing PC/SC USIM.\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; }; std::string imsi = usim.get_imsi_str(); cout << "IMSI: " << imsi << endl; - srslte::plmn_id_t home_plmn_id = {}; + srsran::plmn_id_t home_plmn_id = {}; if (usim.get_home_plmn_id(&home_plmn_id) == false) { printf("Error reading home PLMN\n"); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } cout << "Home PLMN: " << home_plmn_id.to_string() << endl; auth_result_t result = usim.generate_authentication_response(rand_enb, autn_enb, mcc, mnc, res, &res_len, k_asme); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } diff --git a/srsue/test/upper/rrc_cell_test.cc b/srsue/test/upper/rrc_cell_test.cc index 55de8181b..7eab5421c 100644 --- a/srsue/test/upper/rrc_cell_test.cc +++ b/srsue/test/upper/rrc_cell_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,14 +10,14 @@ * */ -#include "srslte/common/test_common.h" +#include "srsran/common/test_common.h" #include "srsue/hdr/stack/rrc/rrc_cell.h" using namespace srsue; int test_meas_cell() { - srslte::task_scheduler task_sched; + srsran::task_scheduler task_sched; meas_cell_eutra invalid_cell{task_sched.get_unique_timer()}, cell{phy_cell_t{1, 3400}, task_sched.get_unique_timer()}; TESTASSERT(not invalid_cell.is_valid()); @@ -45,12 +45,12 @@ int test_meas_cell() } TESTASSERT(cell.timer.is_expired()); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int test_add_neighbours() { - srslte::task_scheduler task_sched; + srsran::task_scheduler task_sched; meas_cell_list list{&task_sched}; TESTASSERT(list.nof_neighbours() == 0); TESTASSERT(not list.serving_cell().is_valid()); @@ -73,7 +73,7 @@ int test_add_neighbours() pmeas2.pci = 2; list.add_meas_cell(pmeas2); TESTASSERT(list.nof_neighbours() == 2); - TESTASSERT(list.set_serving_cell(phy_cell_t{2, 3400}, false) == SRSLTE_SUCCESS); + TESTASSERT(list.set_serving_cell(phy_cell_t{2, 3400}, false) == SRSRAN_SUCCESS); TESTASSERT(list.nof_neighbours() == 1); TESTASSERT(list.serving_cell().equals(3400, 2)); TESTASSERT(list.serving_cell().is_valid()); @@ -99,14 +99,14 @@ int test_add_neighbours() list.clean_neighbours(); TESTASSERT(list.nof_neighbours() == 0); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int main() { - TESTASSERT(test_meas_cell() == SRSLTE_SUCCESS); - TESTASSERT(test_add_neighbours() == SRSLTE_SUCCESS); + TESTASSERT(test_meas_cell() == SRSRAN_SUCCESS); + TESTASSERT(test_add_neighbours() == SRSRAN_SUCCESS); printf("Success\n"); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } diff --git a/srsue/test/upper/rrc_meas_test.cc b/srsue/test/upper/rrc_meas_test.cc index 1b502dcb9..3c150fdf2 100644 --- a/srsue/test/upper/rrc_meas_test.cc +++ b/srsue/test/upper/rrc_meas_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,11 +10,11 @@ * */ -#include "srslte/asn1/rrc/meascfg.h" -#include "srslte/common/buffer_pool.h" -#include "srslte/common/test_common.h" -#include "srslte/test/ue_test_interfaces.h" -#include "srslte/upper/pdcp.h" +#include "srsran/asn1/rrc/meascfg.h" +#include "srsran/common/buffer_pool.h" +#include "srsran/common/test_common.h" +#include "srsran/test/ue_test_interfaces.h" +#include "srsran/upper/pdcp.h" #include "srsue/hdr/stack/rrc/rrc.h" #include "srsue/hdr/stack/rrc/rrc_meas.h" #include "srsue/hdr/stack/rrc/rrc_nr.h" @@ -34,12 +34,12 @@ public: } // Not implemented methods - bool set_config(srslte::phy_cfg_t config, uint32_t cc_idx) override { return true; } - bool set_scell(srslte_cell_t cell_info, uint32_t cc_idx, uint32_t earfcn) override { return true; } - void set_config_tdd(srslte_tdd_config_t& tdd_config) override {} - void set_config_mbsfn_sib2(srslte::mbsfn_sf_cfg_t* cfg_list, uint32_t nof_cfgs) override {} - void set_config_mbsfn_sib13(const srslte::sib13_t& sib13) override {} - void set_config_mbsfn_mcch(const srslte::mcch_msg_t& mcch) override {} + bool set_config(srsran::phy_cfg_t config, uint32_t cc_idx) override { return true; } + bool set_scell(srsran_cell_t cell_info, uint32_t cc_idx, uint32_t earfcn) override { return true; } + void set_config_tdd(srsran_tdd_config_t& tdd_config) override {} + void set_config_mbsfn_sib2(srsran::mbsfn_sf_cfg_t* cfg_list, uint32_t nof_cfgs) override {} + void set_config_mbsfn_sib13(const srsran::sib13_t& sib13) override {} + void set_config_mbsfn_mcch(const srsran::mcch_msg_t& mcch) override {} bool cell_search() override { return true; } bool cell_is_camping() override { return true; } void deactivate_scells() override {} @@ -101,10 +101,10 @@ private: class mac_test : public srsue::mac_interface_rrc { public: - srslte::task_sched_handle task_sched; + srsran::task_sched_handle task_sched; rrc* rrc_ptr; - mac_test(rrc* rrc_, srslte::task_sched_handle task_sched_) : rrc_ptr(rrc_), task_sched(task_sched_) {} + mac_test(rrc* rrc_, srsran::task_sched_handle task_sched_) : rrc_ptr(rrc_), task_sched(task_sched_) {} int get_dlsch_with_sib1(bcch_dl_sch_msg_s& dlsch_msg) { @@ -125,7 +125,7 @@ public: void bcch_start_rx(int si_window_start, int si_window_length) override { task_sched.defer_task([this]() { - srslte::unique_byte_buffer_t pdu; + srsran::unique_byte_buffer_t pdu; for (uint32_t i = 0; i < 2; ++i) { bcch_dl_sch_msg_s dlsch_msg; if (i == 0) { @@ -134,7 +134,7 @@ public: get_dlsch_with_sys_info(dlsch_msg); } - pdu = srslte::make_byte_buffer(); + pdu = srsran::make_byte_buffer(); asn1::bit_ref bref(pdu->msg, pdu->get_tailroom()); dlsch_msg.pack(bref); pdu->N_bytes = bref.distance_bytes(); @@ -149,8 +149,8 @@ public: void mch_start_rx(uint32_t lcid) override {} - void set_config(srslte::mac_cfg_t& mac_cfg) override {} - void set_config(srslte::sr_cfg_t& sr_cfg) override {} + void set_config(srsran::mac_cfg_t& mac_cfg) override {} + void set_config(srsran::sr_cfg_t& sr_cfg) override {} void set_rach_ded_cfg(uint32_t preamble_index, uint32_t prach_mask) override {} void get_rntis(ue_rnti_t* rntis) override {} @@ -165,8 +165,8 @@ class rrc_nr_test final : public srsue::rrc_nr_interface_rrc { public: ~rrc_nr_test() = default; - void get_eutra_nr_capabilities(srslte::byte_buffer_t* eutra_nr_caps) override{}; - void get_nr_capabilities(srslte::byte_buffer_t* nr_cap) override{}; + void get_eutra_nr_capabilities(srsran::byte_buffer_t* eutra_nr_caps) override{}; + void get_nr_capabilities(srsran::byte_buffer_t* nr_cap) override{}; void phy_set_cells_to_meas(uint32_t carrier_freq_r15) override{}; void phy_meas_stop() override{}; bool rrc_reconfiguration(bool endc_release_and_add_r15, @@ -185,15 +185,15 @@ public: class nas_test : public srsue::nas { public: - nas_test(srslte::task_sched_handle t) : srsue::nas(t) {} + nas_test(srsran::task_sched_handle t) : srsue::nas(t) {} bool is_registered() override { return false; } }; -class pdcp_test : public srslte::pdcp +class pdcp_test : public srsran::pdcp { public: - pdcp_test(const char* logname, srslte::task_sched_handle t) : srslte::pdcp(t, logname) {} - void write_sdu(uint32_t lcid, srslte::unique_byte_buffer_t sdu, int sn = -1) override + pdcp_test(const char* logname, srsran::task_sched_handle t) : srsran::pdcp(t, logname) {} + void write_sdu(uint32_t lcid, srsran::unique_byte_buffer_t sdu, int sn = -1) override { ul_dcch_msg_s ul_dcch_msg; asn1::cbit_ref bref(sdu->msg, sdu->N_bytes); @@ -298,7 +298,7 @@ public: void send_ccch_msg(dl_ccch_msg_s& dl_ccch_msg) { - srslte::unique_byte_buffer_t pdu = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t pdu = srsran::make_byte_buffer(); asn1::bit_ref bref(pdu->msg, pdu->get_tailroom()); dl_ccch_msg.pack(bref); @@ -310,7 +310,7 @@ public: void send_dcch_msg(dl_dcch_msg_s& dl_dcch_msg) { - srslte::unique_byte_buffer_t pdu = srslte::make_byte_buffer(); + srsran::unique_byte_buffer_t pdu = srsran::make_byte_buffer(); ; asn1::bit_ref bref(pdu->msg, pdu->get_tailroom()); dl_dcch_msg.pack(bref); @@ -397,7 +397,7 @@ int cell_select_test() TESTASSERT(!rrctest.has_neighbour_cell(2, 2)); // Start cell selection procedure. The RRC will start with strongest cell - TESTASSERT(rrctest.start_cell_select() == SRSLTE_SUCCESS); + TESTASSERT(rrctest.start_cell_select() == SRSRAN_SUCCESS); stack.run_pending_tasks(); TESTASSERT(rrctest.phytest.last_selected_cell.earfcn == 2); TESTASSERT(rrctest.phytest.last_selected_cell.pci == 2); @@ -424,7 +424,7 @@ int cell_select_test() TESTASSERT(rrctest.has_neighbour_cell(2, 3)); // Start cell selection procedure. The RRC will start with strongest cell - TESTASSERT(rrctest.start_cell_select() == SRSLTE_SUCCESS); + TESTASSERT(rrctest.start_cell_select() == SRSRAN_SUCCESS); TESTASSERT(rrctest.phytest.last_selected_cell.earfcn == 1); TESTASSERT(rrctest.phytest.last_selected_cell.pci == 1); stack.run_pending_tasks(); @@ -449,7 +449,7 @@ int cell_select_test() cell_search_cell.pci = 5; cell_search_cell.earfcn = 5; cell_search_ret.found = srsue::rrc_interface_phy_lte::cell_search_ret_t::CELL_FOUND; - TESTASSERT(rrctest.start_cell_select() == SRSLTE_SUCCESS); + TESTASSERT(rrctest.start_cell_select() == SRSRAN_SUCCESS); rrctest.cell_select_complete(false); // it will fail to select pci=2 stack.run_pending_tasks(); rrctest.cell_select_complete(false); // it will fail to select pci=3 @@ -465,7 +465,7 @@ int cell_select_test() TESTASSERT(rrctest.is_serving_cell(5, 5)); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Tests the measObject configuration and the successful activation of PHY cells to search for @@ -1131,7 +1131,7 @@ int a3event_report_test(uint32_t a3_offset, uint32_t hyst, bool report_on_leave) TESTASSERT(meas_res.meas_result_neigh_cells.meas_result_list_eutra()[0].meas_result.rsrp_result == 81 + (hyst + a3_offset) / 2); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // Minimal testcase for testing inter rat reporting with nr @@ -1226,7 +1226,7 @@ int meas_obj_inter_rat_nr_test() rrctest.add_neighbour_cell_nr(500, 631680, -60.0); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int main(int argc, char** argv) @@ -1240,21 +1240,21 @@ int main(int argc, char** argv) srslog::init(); - TESTASSERT(cell_select_test() == SRSLTE_SUCCESS); - TESTASSERT(meas_obj_test() == SRSLTE_SUCCESS); - TESTASSERT(meas_obj_inter_rat_nr_test() == SRSLTE_SUCCESS); + TESTASSERT(cell_select_test() == SRSRAN_SUCCESS); + TESTASSERT(meas_obj_test() == SRSRAN_SUCCESS); + TESTASSERT(meas_obj_inter_rat_nr_test() == SRSRAN_SUCCESS); TESTASSERT( a1event_report_test( 30, time_to_trigger_opts::ms40, 3, report_cfg_eutra_s::report_amount_opts::r1, report_interv_opts::ms120) == - SRSLTE_SUCCESS); + SRSRAN_SUCCESS); TESTASSERT( a1event_report_test( 30, time_to_trigger_opts::ms0, 3, report_cfg_eutra_s::report_amount_opts::r1, report_interv_opts::ms120) == - SRSLTE_SUCCESS); + SRSRAN_SUCCESS); TESTASSERT( a1event_report_test( 30, time_to_trigger_opts::ms40, 3, report_cfg_eutra_s::report_amount_opts::r8, report_interv_opts::ms120) == - SRSLTE_SUCCESS); - TESTASSERT(a3event_report_test(6, 3, true) == SRSLTE_SUCCESS); - return SRSLTE_SUCCESS; + SRSRAN_SUCCESS); + TESTASSERT(a3event_report_test(6, 3, true) == SRSRAN_SUCCESS); + return SRSRAN_SUCCESS; } diff --git a/srsue/test/upper/rrc_phy_ctrl_test.cc b/srsue/test/upper/rrc_phy_ctrl_test.cc index 406ed65a3..3943a8f36 100644 --- a/srsue/test/upper/rrc_phy_ctrl_test.cc +++ b/srsue/test/upper/rrc_phy_ctrl_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,8 +10,8 @@ * */ -#include "srslte/common/test_common.h" -#include "srslte/test/ue_test_interfaces.h" +#include "srsran/common/test_common.h" +#include "srsran/test/ue_test_interfaces.h" #include "srsue/hdr/stack/rrc/phy_controller.h" namespace srsue { @@ -63,7 +63,7 @@ struct cell_select_result_test { int test_phy_ctrl_fsm() { - srslte::task_scheduler task_sched; + srsran::task_scheduler task_sched; phy_dummy_interface phy; phy_controller phy_ctrl{&phy, &task_sched}; cell_search_result_test csearch_tester{&phy_ctrl}; @@ -159,7 +159,7 @@ int test_phy_ctrl_fsm() phy_ctrl.start_cell_select(found_cell, csel_tester); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } class phy_test_dummy : public phy_dummy_interface @@ -173,7 +173,7 @@ public: /// TEST: Check if controller handles the case when PHY fails to init cell selection int test_phy_cell_select_init_error_handling() { - srslte::task_scheduler task_sched; + srsran::task_scheduler task_sched; phy_test_dummy phy; phy_controller phy_ctrl{&phy, &task_sched}; phy_cell_t found_cell{}; @@ -199,7 +199,7 @@ int main() RRC_logger.set_hex_dump_max_size(-1); srslog::init(); - TESTASSERT(srsue::test_phy_ctrl_fsm() == SRSLTE_SUCCESS); - TESTASSERT(srsue::test_phy_cell_select_init_error_handling() == SRSLTE_SUCCESS); + TESTASSERT(srsue::test_phy_ctrl_fsm() == SRSRAN_SUCCESS); + TESTASSERT(srsue::test_phy_cell_select_init_error_handling() == SRSRAN_SUCCESS); test_logger.info("Finished RRC PHY controller test successfully"); } diff --git a/srsue/test/upper/rrc_reconfig_test.cc b/srsue/test/upper/rrc_reconfig_test.cc index a4343ecd1..54100c2cc 100644 --- a/srsue/test/upper/rrc_reconfig_test.cc +++ b/srsue/test/upper/rrc_reconfig_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,11 +10,11 @@ * */ -#include "srslte/asn1/liblte_mme.h" -#include "srslte/asn1/rrc/dl_dcch_msg.h" -#include "srslte/srslog/srslog.h" +#include "srsran/asn1/liblte_mme.h" +#include "srsran/asn1/rrc/dl_dcch_msg.h" +#include "srsran/srslog/srslog.h" #include -#include +#include #define TESTASSERT(cond) \ { \ diff --git a/srsue/test/upper/tft_test.cc b/srsue/test/upper/tft_test.cc index 6f07a931e..1bcc7b28b 100644 --- a/srsue/test/upper/tft_test.cc +++ b/srsue/test/upper/tft_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,10 +10,10 @@ * */ -#include "srslte/asn1/liblte_mme.h" -#include "srslte/common/buffer_pool.h" -#include "srslte/common/int_helpers.h" -#include "srslte/srslte.h" +#include "srsran/asn1/liblte_mme.h" +#include "srsran/common/buffer_pool.h" +#include "srsran/common/int_helpers.h" +#include "srsran/srsran.h" #include "srsue/hdr/stack/upper/tft_packet_filter.h" #include @@ -25,7 +25,7 @@ } \ } using namespace srsue; -using namespace srslte; +using namespace srsran; // IP test message 1 // Source IP 127.0.0.1, Destination IP 127.0.0.2 @@ -104,7 +104,7 @@ uint8_t ipv6_unmatched_packet_lport[] = { int tft_filter_test_ipv6_combined() { srslog::basic_logger& logger = srslog::fetch_basic_logger("TFT"); - srslte::unique_byte_buffer_t ip_msg1, ip_msg2, ip_msg3, ip_msg4, ip_msg5; + srsran::unique_byte_buffer_t ip_msg1, ip_msg2, ip_msg3, ip_msg4, ip_msg5; ip_msg1 = make_byte_buffer(); ip_msg2 = make_byte_buffer(); ip_msg3 = make_byte_buffer(); @@ -162,7 +162,7 @@ int tft_filter_test_single_local_port() { srslog::basic_logger& logger = srslog::fetch_basic_logger("TFT"); - srslte::unique_byte_buffer_t ip_msg1, ip_msg2; + srsran::unique_byte_buffer_t ip_msg1, ip_msg2; ip_msg1 = make_byte_buffer(); ip_msg2 = make_byte_buffer(); @@ -171,7 +171,7 @@ int tft_filter_test_single_local_port() // Local port: 2222 uint8_t filter_message[3]; filter_message[0] = SINGLE_LOCAL_PORT_TYPE; - srslte::uint16_to_uint8(2222, &filter_message[1]); + srsran::uint16_to_uint8(2222, &filter_message[1]); // Set IP test message ip_msg1->N_bytes = ip_message_len1; @@ -206,7 +206,7 @@ int tft_filter_test_single_remote_port() { srslog::basic_logger& logger = srslog::fetch_basic_logger("TFT"); - srslte::unique_byte_buffer_t ip_msg1, ip_msg2; + srsran::unique_byte_buffer_t ip_msg1, ip_msg2; ip_msg1 = make_byte_buffer(); ip_msg2 = make_byte_buffer(); @@ -215,7 +215,7 @@ int tft_filter_test_single_remote_port() // Remote port: 2001 uint8_t filter_message[3]; filter_message[0] = SINGLE_REMOTE_PORT_TYPE; - srslte::uint16_to_uint8(2001, &filter_message[1]); + srsran::uint16_to_uint8(2001, &filter_message[1]); // Set IP test message ip_msg1->N_bytes = ip_message_len1; @@ -250,7 +250,7 @@ int tft_filter_test_ipv4_local_addr() { srslog::basic_logger& logger = srslog::fetch_basic_logger("TFT"); - srslte::unique_byte_buffer_t ip_msg1, ip_msg2; + srsran::unique_byte_buffer_t ip_msg1, ip_msg2; ip_msg1 = make_byte_buffer(); ip_msg2 = make_byte_buffer(); @@ -297,7 +297,7 @@ int tft_filter_test_ipv4_remote_addr() { srslog::basic_logger& logger = srslog::fetch_basic_logger("TFT"); - srslte::unique_byte_buffer_t ip_msg1, ip_msg2; + srsran::unique_byte_buffer_t ip_msg1, ip_msg2; ip_msg1 = make_byte_buffer(); ip_msg2 = make_byte_buffer(); @@ -343,7 +343,7 @@ int tft_filter_test_ipv4_tos() { srslog::basic_logger& logger = srslog::fetch_basic_logger("TFT"); - srslte::unique_byte_buffer_t ip_msg1, ip_msg2; + srsran::unique_byte_buffer_t ip_msg1, ip_msg2; ip_msg1 = make_byte_buffer(); ip_msg2 = make_byte_buffer(); @@ -393,7 +393,7 @@ int main(int argc, char** argv) logger.set_hex_dump_max_size(128); srslog::init(); - srslte::byte_buffer_pool::get_instance(); + srsran::byte_buffer_pool::get_instance(); if (tft_filter_test_single_local_port()) { return -1; } diff --git a/srsue/test/upper/ue_rrc_nr_test.cc b/srsue/test/upper/ue_rrc_nr_test.cc index 524d22a19..7539d4369 100644 --- a/srsue/test/upper/ue_rrc_nr_test.cc +++ b/srsue/test/upper/ue_rrc_nr_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,7 +10,7 @@ * */ -#include "srslte/common/test_common.h" +#include "srsran/common/test_common.h" #include "srsue/hdr/stack/rrc/rrc_nr.h" using namespace srsue; @@ -20,17 +20,17 @@ int rrc_nr_cap_request_test() srslog::basic_logger& logger = srslog::fetch_basic_logger("RRC"); logger.set_level(srslog::basic_levels::debug); logger.set_hex_dump_max_size(-1); - srslte::task_scheduler task_sched{512, 100}; - srslte::task_sched_handle task_sched_handle(&task_sched); + srsran::task_scheduler task_sched{512, 100}; + srsran::task_sched_handle task_sched_handle(&task_sched); rrc_nr rrc_nr(task_sched_handle); - srslte::byte_buffer_t caps; + srsran::byte_buffer_t caps; rrc_nr.get_eutra_nr_capabilities(&caps); rrc_nr.get_nr_capabilities(&caps); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int main(int argc, char** argv) { - TESTASSERT(rrc_nr_cap_request_test() == SRSLTE_SUCCESS); - return SRSLTE_SUCCESS; + TESTASSERT(rrc_nr_cap_request_test() == SRSRAN_SUCCESS); + return SRSRAN_SUCCESS; } diff --git a/srsue/test/upper/usim_test.cc b/srsue/test/upper/usim_test.cc index 23e3d5180..7ca21ef8d 100644 --- a/srsue/test/upper/usim_test.cc +++ b/srsue/test/upper/usim_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,7 +10,7 @@ * */ -#include "srslte/common/test_common.h" +#include "srsran/common/test_common.h" #include "srsue/hdr/stack/upper/usim.h" using namespace srsue; diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index f3cbc86a2..3d08986bd 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of diff --git a/test/README.md b/test/README.md index cbf74cab6..c8577e1e3 100644 --- a/test/README.md +++ b/test/README.md @@ -21,12 +21,12 @@ are analyzed. Single Execution ---------------- -The script can be executed manually. It expects the srsLTE build directory as +The script can be executed manually. It expects the srsRAN build directory as the first argument, the cell bandwidth as the second, and, optionally the number of component carrier as the third. ``` -$ sudo ./run_lte.sh ~/src/srsLTE/build 50 1 +$ sudo ./run_lte.sh ~/src/srsRAN/build 50 1 ``` Testing all Bandwidths diff --git a/test/run_lte.sh b/test/run_lte.sh index 2b5c1e94c..e9f2b210d 100755 --- a/test/run_lte.sh +++ b/test/run_lte.sh @@ -1,7 +1,7 @@ #!/bin/bash # -# Copyright 2013-2020 Software Radio Systems Limited +# Copyright 2013-2021 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -13,7 +13,7 @@ enb_pid=0 ue_pid=0 print_use(){ - echo "Please call script with srsLTE build path as first argument and number of PRBs as second (number of component carrier is optional)" + echo "Please call script with srsRAN build path as first argument and number of PRBs as second (number of component carrier is optional)" echo "E.g. ./run_lte.sh [build_path] [nof_prb] [num_cc]" exit -1 } @@ -45,9 +45,9 @@ kill_lte(){ kill -9 $epc_pid fi - if [ -f ./srsLTE.backtrace.crash ]; then + if [ -f ./srsRAN.backtrace.crash ]; then echo "Rename backtrace" - mv ./srsLTE.backtrace.crash srsLTE.backtrace.log + mv ./srsRAN.backtrace.crash srsRAN.backtrace.log fi # Delete netns From 98d0637deddc177b60b935115ee52b5de76f1503 Mon Sep 17 00:00:00 2001 From: Francisco Date: Fri, 19 Mar 2021 12:40:04 +0000 Subject: [PATCH 02/48] adt addition - implemented reusable circular map --- lib/include/srslte/adt/circular_map.h | 169 ++++++++++++++++++++++++++ lib/test/adt/CMakeLists.txt | 4 + lib/test/adt/circular_map_test.cc | 70 +++++++++++ 3 files changed, 243 insertions(+) create mode 100644 lib/include/srslte/adt/circular_map.h create mode 100644 lib/test/adt/circular_map_test.cc diff --git a/lib/include/srslte/adt/circular_map.h b/lib/include/srslte/adt/circular_map.h new file mode 100644 index 000000000..67d27a572 --- /dev/null +++ b/lib/include/srslte/adt/circular_map.h @@ -0,0 +1,169 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2020 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +#ifndef SRSLTE_ID_MAP_H +#define SRSLTE_ID_MAP_H + +#include "expected.h" +#include +#include + +template +class static_circular_map +{ + static_assert(std::is_integral::value, "Map key must be an integer"); + + using obj_t = std::pair; + using obj_storage_t = typename std::aligned_storage::type; + +public: + bool has_key(K id) + { + size_t idx = id % N; + return present[idx] and get_obj_(idx).first == id; + } + + bool insert(K id, const T& obj) + { + size_t idx = id % N; + if (present[idx]) { + return false; + } + new (&buffer[idx]) obj_t(id, obj); + present[idx] = true; + count++; + return true; + } + srslte::error_type insert(K id, T&& obj) + { + size_t idx = id % N; + if (present[idx]) { + return srslte::error_type(std::move(obj)); + } + new (&buffer[idx]) obj_t(id, std::move(obj)); + present[idx] = true; + count++; + return {}; + } + + bool erase(K id) + { + if (not has_key(id)) { + return false; + } + size_t idx = id % N; + get_obj_(idx).~obj_t(); + present[idx] = false; + --count; + return true; + } + + T& operator[](K id) + { + assert(has_key(id)); + return get_obj_(id % N).second; + } + const T& operator[](K id) const + { + assert(has_key(id)); + return get_obj_(id % N).second; + } + + size_t size() const { return count; } + bool empty() const { return count == 0; } + bool full() const { return count == N; } + size_t capacity() const { return N; } + + class iterator + { + public: + iterator() = default; + iterator(static_circular_map* map, size_t idx_) : ptr(map), idx(idx_) + { + if (idx < ptr->capacity() and not ptr->present[idx]) { + ++(*this); + } + } + + iterator& operator++() + { + while (++idx < ptr->capacity() and not ptr->present[idx]) { + } + return *this; + } + + obj_t& operator*() { return ptr->get_obj_(idx); } + obj_t* operator->() { return &ptr->get_obj_(idx); } + const obj_t* operator*() const { return ptr->buffer[idx]; } + const obj_t* operator->() const { return ptr->buffer[idx]; } + + bool operator==(const iterator& other) const { return ptr == other.ptr and idx == other.idx; } + bool operator!=(const iterator& other) const { return not(*this == other); } + + private: + static_circular_map* ptr = nullptr; + size_t idx = 0; + }; + class const_iterator + { + public: + const_iterator() = default; + const_iterator(static_circular_map* map, size_t idx_) : ptr(map), idx(idx_) {} + + const_iterator& operator++() + { + while (++idx < ptr->capacity() and not ptr->present[idx]) { + } + return *this; + } + + const obj_t* operator*() const { return ptr->buffer[idx]; } + const obj_t* operator->() const { return ptr->buffer[idx]; } + + bool operator==(const const_iterator& other) const { return ptr == other.ptr and idx == other.idx; } + bool operator!=(const const_iterator& other) const { return not(*this == other); } + + private: + const static_circular_map* ptr = nullptr; + size_t idx = 0; + }; + + iterator begin() { return iterator(this, 0); } + iterator end() { return iterator(this, N); } + const_iterator begin() const { return iterator(this, 0); } + const_iterator end() const { return iterator(this, N); } + + iterator find(K id) + { + if (has_key(id)) { + return iterator(this, id % N); + } + return end(); + } + const_iterator find(K id) const + { + if (has_key(id)) { + return iterator(this, id % N); + } + return end(); + } + +private: + obj_t& get_obj_(size_t idx) { return reinterpret_cast(buffer[idx]); } + const obj_t& get_obj_(size_t idx) const { return reinterpret_cast(buffer[idx]); } + + std::array buffer; + std::array present = {false}; + size_t count = 0; +}; + +#endif // SRSLTE_ID_MAP_H diff --git a/lib/test/adt/CMakeLists.txt b/lib/test/adt/CMakeLists.txt index fb2276200..1051c8c4b 100644 --- a/lib/test/adt/CMakeLists.txt +++ b/lib/test/adt/CMakeLists.txt @@ -45,3 +45,7 @@ add_test(mem_pool_test mem_pool_test) add_executable(circular_buffer_test circular_buffer_test.cc) target_link_libraries(circular_buffer_test srsran_common) add_test(circular_buffer_test circular_buffer_test) + +add_executable(circular_map_test circular_map_test.cc) +target_link_libraries(circular_map_test srslte_common) +add_test(circular_map_test circular_map_test) diff --git a/lib/test/adt/circular_map_test.cc b/lib/test/adt/circular_map_test.cc new file mode 100644 index 000000000..1a2d31c79 --- /dev/null +++ b/lib/test/adt/circular_map_test.cc @@ -0,0 +1,70 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2020 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +#include "srslte/adt/circular_map.h" +#include "srslte/common/test_common.h" + +namespace srslte { + +int test_id_map() +{ + static_circular_map myobj; + TESTASSERT(myobj.size() == 0 and myobj.empty() and not myobj.full()); + TESTASSERT(myobj.begin() == myobj.end()); + + TESTASSERT(not myobj.has_key(0)); + TESTASSERT(myobj.insert(0, "obj0")); + TESTASSERT(myobj.has_key(0) and myobj[0] == "obj0"); + TESTASSERT(myobj.size() == 1 and not myobj.empty() and not myobj.full()); + TESTASSERT(myobj.begin() != myobj.end()); + + TESTASSERT(not myobj.insert(0, "obj0")); + TESTASSERT(myobj.insert(1, "obj1")); + TESTASSERT(myobj.has_key(0) and myobj.has_key(1) and myobj[1] == "obj1"); + TESTASSERT(myobj.size() == 2 and not myobj.empty() and not myobj.full()); + + TESTASSERT(myobj.find(1) != myobj.end()); + TESTASSERT(myobj.find(1)->first == 1); + TESTASSERT(myobj.find(1)->second == "obj1"); + + // TEST: iteration + uint32_t count = 0; + for (std::pair& obj : myobj) { + TESTASSERT(obj.second == "obj" + std::to_string(count++)); + } + + // TEST: const iteration + count = 0; + for (const std::pair& obj : myobj) { + TESTASSERT(obj.second == "obj" + std::to_string(count++)); + } + + TESTASSERT(myobj.erase(0)); + TESTASSERT(myobj.erase(1)); + TESTASSERT(myobj.size() == 0 and myobj.empty()); + + return SRSLTE_SUCCESS; +} + +} // namespace srslte + +int main() +{ + auto& test_log = srslog::fetch_basic_logger("TEST"); + test_log.set_level(srslog::basic_levels::info); + + // Start the log backend. + srslog::init(); + + TESTASSERT(srslte::test_id_map() == SRSLTE_SUCCESS); + return SRSLTE_SUCCESS; +} \ No newline at end of file From 4869b14de36fae143caf33722834b6cfe2863b3f Mon Sep 17 00:00:00 2001 From: Francisco Date: Fri, 19 Mar 2021 13:24:54 +0000 Subject: [PATCH 03/48] application of new circular map to mac::ue_db --- .../{srslte => srsran}/adt/circular_map.h | 148 ++++++++++-------- lib/test/adt/circular_map_test.cc | 26 +-- srsenb/hdr/stack/mac/mac.h | 6 +- srsenb/src/stack/mac/mac.cc | 63 ++++---- 4 files changed, 140 insertions(+), 103 deletions(-) rename lib/include/{srslte => srsran}/adt/circular_map.h (83%) diff --git a/lib/include/srslte/adt/circular_map.h b/lib/include/srsran/adt/circular_map.h similarity index 83% rename from lib/include/srslte/adt/circular_map.h rename to lib/include/srsran/adt/circular_map.h index 67d27a572..441dd913d 100644 --- a/lib/include/srslte/adt/circular_map.h +++ b/lib/include/srsran/adt/circular_map.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -10,13 +10,15 @@ * */ -#ifndef SRSLTE_ID_MAP_H -#define SRSLTE_ID_MAP_H +#ifndef SRSRAN_ID_MAP_H +#define SRSRAN_ID_MAP_H #include "expected.h" #include #include +namespace srsran { + template class static_circular_map { @@ -26,63 +28,6 @@ class static_circular_map using obj_storage_t = typename std::aligned_storage::type; public: - bool has_key(K id) - { - size_t idx = id % N; - return present[idx] and get_obj_(idx).first == id; - } - - bool insert(K id, const T& obj) - { - size_t idx = id % N; - if (present[idx]) { - return false; - } - new (&buffer[idx]) obj_t(id, obj); - present[idx] = true; - count++; - return true; - } - srslte::error_type insert(K id, T&& obj) - { - size_t idx = id % N; - if (present[idx]) { - return srslte::error_type(std::move(obj)); - } - new (&buffer[idx]) obj_t(id, std::move(obj)); - present[idx] = true; - count++; - return {}; - } - - bool erase(K id) - { - if (not has_key(id)) { - return false; - } - size_t idx = id % N; - get_obj_(idx).~obj_t(); - present[idx] = false; - --count; - return true; - } - - T& operator[](K id) - { - assert(has_key(id)); - return get_obj_(id % N).second; - } - const T& operator[](K id) const - { - assert(has_key(id)); - return get_obj_(id % N).second; - } - - size_t size() const { return count; } - bool empty() const { return count == 0; } - bool full() const { return count == N; } - size_t capacity() const { return N; } - class iterator { public: @@ -137,6 +82,81 @@ public: size_t idx = 0; }; + bool contains(K id) + { + size_t idx = id % N; + return present[idx] and get_obj_(idx).first == id; + } + + bool insert(K id, const T& obj) + { + size_t idx = id % N; + if (present[idx]) { + return false; + } + new (&buffer[idx]) obj_t(id, obj); + present[idx] = true; + count++; + return true; + } + srsran::expected insert(K id, T&& obj) + { + size_t idx = id % N; + if (present[idx]) { + return srsran::expected(std::move(obj)); + } + new (&buffer[idx]) obj_t(id, std::move(obj)); + present[idx] = true; + count++; + return iterator(this, idx); + } + + bool erase(K id) + { + if (not contains(id)) { + return false; + } + size_t idx = id % N; + get_obj_(idx).~obj_t(); + present[idx] = false; + --count; + return true; + } + + iterator erase(iterator it) + { + assert(it->first < N); + iterator next = it; + ++next; + it->~obj_t(); + present[it->first] = false; + --count; + return next; + } + + void clear() + { + for (auto it = begin(); it != end();) { + it = erase(it); + } + } + + T& operator[](K id) + { + assert(contains(id)); + return get_obj_(id % N).second; + } + const T& operator[](K id) const + { + assert(contains(id)); + return get_obj_(id % N).second; + } + + size_t size() const { return count; } + bool empty() const { return count == 0; } + bool full() const { return count == N; } + size_t capacity() const { return N; } + iterator begin() { return iterator(this, 0); } iterator end() { return iterator(this, N); } const_iterator begin() const { return iterator(this, 0); } @@ -144,14 +164,14 @@ public: iterator find(K id) { - if (has_key(id)) { + if (contains(id)) { return iterator(this, id % N); } return end(); } const_iterator find(K id) const { - if (has_key(id)) { + if (contains(id)) { return iterator(this, id % N); } return end(); @@ -166,4 +186,6 @@ private: size_t count = 0; }; -#endif // SRSLTE_ID_MAP_H +} // namespace srsran + +#endif // SRSRAN_ID_MAP_H diff --git a/lib/test/adt/circular_map_test.cc b/lib/test/adt/circular_map_test.cc index 1a2d31c79..1db52a581 100644 --- a/lib/test/adt/circular_map_test.cc +++ b/lib/test/adt/circular_map_test.cc @@ -10,10 +10,10 @@ * */ -#include "srslte/adt/circular_map.h" -#include "srslte/common/test_common.h" +#include "srsran/common/test_common.h" +#include "srsran/adt/circular_map.h" -namespace srslte { +namespace srsran { int test_id_map() { @@ -21,15 +21,15 @@ int test_id_map() TESTASSERT(myobj.size() == 0 and myobj.empty() and not myobj.full()); TESTASSERT(myobj.begin() == myobj.end()); - TESTASSERT(not myobj.has_key(0)); + TESTASSERT(not myobj.contains(0)); TESTASSERT(myobj.insert(0, "obj0")); - TESTASSERT(myobj.has_key(0) and myobj[0] == "obj0"); + TESTASSERT(myobj.contains(0) and myobj[0] == "obj0"); TESTASSERT(myobj.size() == 1 and not myobj.empty() and not myobj.full()); TESTASSERT(myobj.begin() != myobj.end()); TESTASSERT(not myobj.insert(0, "obj0")); TESTASSERT(myobj.insert(1, "obj1")); - TESTASSERT(myobj.has_key(0) and myobj.has_key(1) and myobj[1] == "obj1"); + TESTASSERT(myobj.contains(0) and myobj.contains(1) and myobj[1] == "obj1"); TESTASSERT(myobj.size() == 2 and not myobj.empty() and not myobj.full()); TESTASSERT(myobj.find(1) != myobj.end()); @@ -52,10 +52,16 @@ int test_id_map() TESTASSERT(myobj.erase(1)); TESTASSERT(myobj.size() == 0 and myobj.empty()); - return SRSLTE_SUCCESS; + TESTASSERT(myobj.insert(0, "obj0")); + TESTASSERT(myobj.insert(1, "obj1")); + TESTASSERT(myobj.size() == 2 and not myobj.empty() and not myobj.full()); + myobj.clear(); + TESTASSERT(myobj.size() == 0 and myobj.empty()); + + return SRSRAN_SUCCESS; } -} // namespace srslte +} // namespace srsran int main() { @@ -65,6 +71,6 @@ int main() // Start the log backend. srslog::init(); - TESTASSERT(srslte::test_id_map() == SRSLTE_SUCCESS); - return SRSLTE_SUCCESS; + TESTASSERT(srsran::test_id_map() == SRSRAN_SUCCESS); + return SRSRAN_SUCCESS; } \ No newline at end of file diff --git a/srsenb/hdr/stack/mac/mac.h b/srsenb/hdr/stack/mac/mac.h index cb0061341..1ede59222 100644 --- a/srsenb/hdr/stack/mac/mac.h +++ b/srsenb/hdr/stack/mac/mac.h @@ -15,6 +15,7 @@ #include "sched.h" #include "srsenb/hdr/stack/mac/schedulers/sched_time_rr.h" +#include "srsran/adt/circular_map.h" #include "srsran/common/mac_pcap.h" #include "srsran/common/mac_pcap_net.h" #include "srsran/common/task_scheduler.h" @@ -134,8 +135,9 @@ private: sched_interface::dl_pdu_mch_t mch = {}; /* Map of active UEs */ - std::map > ue_db, ues_to_rem; - uint16_t last_rnti = 70; + srsran::static_circular_map, 64> ue_db; + std::map > ues_to_rem; + uint16_t last_rnti = 70; srsran::static_blocking_queue, 32> ue_pool; ///< Pool of pre-allocated UE objects void prealloc_ue(uint32_t nof_ue); diff --git a/srsenb/src/stack/mac/mac.cc b/srsenb/src/stack/mac/mac.cc index 7e48a6fdd..eeef5e7ba 100644 --- a/srsenb/src/stack/mac/mac.cc +++ b/srsenb/src/stack/mac/mac.cc @@ -139,7 +139,7 @@ int mac::rlc_buffer_state(uint16_t rnti, uint32_t lc_id, uint32_t tx_queue, uint { srsran::rwlock_read_guard lock(rwlock); int ret = -1; - if (ue_db.count(rnti)) { + if (ue_db.contains(rnti)) { if (rnti != SRSRAN_MRNTI) { ret = scheduler.dl_rlc_buffer_state(rnti, lc_id, tx_queue, retx_queue); } else { @@ -160,7 +160,7 @@ int mac::bearer_ue_cfg(uint16_t rnti, uint32_t lc_id, sched_interface::ue_bearer { int ret = -1; srsran::rwlock_read_guard lock(rwlock); - if (ue_db.count(rnti)) { + if (ue_db.contains(rnti)) { ret = scheduler.bearer_ue_cfg(rnti, lc_id, *cfg); } else { logger.error("User rnti=0x%x not found", rnti); @@ -172,7 +172,7 @@ int mac::bearer_ue_rem(uint16_t rnti, uint32_t lc_id) { srsran::rwlock_read_guard lock(rwlock); int ret = -1; - if (ue_db.count(rnti)) { + if (ue_db.contains(rnti)) { ret = scheduler.bearer_ue_rem(rnti, lc_id); } else { logger.error("User rnti=0x%x not found", rnti); @@ -215,7 +215,7 @@ int mac::ue_rem(uint16_t rnti) // Remove UE from the perspective of L2/L3 { srsran::rwlock_write_guard lock(rwlock); - if (ue_db.count(rnti)) { + if (ue_db.contains(rnti)) { ues_to_rem[rnti] = std::move(ue_db[rnti]); ue_db.erase(rnti); } else { @@ -440,38 +440,45 @@ uint16_t mac::allocate_rnti() uint16_t mac::allocate_ue() { - { - srsran::rwlock_read_guard lock(rwlock); - if (ue_db.size() >= args.max_nof_ues) { - logger.warning("Maximum number of connected UEs %d reached. Ignoring PRACH", args.max_nof_ues); + ue* inserted_ue = nullptr; + do { + // Get pre-allocated UE object + if (ue_pool.empty()) { + logger.error("Ignoring RACH attempt. UE pool empty."); return SRSRAN_INVALID_RNTI; } - } + std::unique_ptr ue_ptr = ue_pool.pop_blocking(); - // Get pre-allocated UE object - if (ue_pool.empty()) { - logger.error("Ignoring RACH attempt. UE pool empty."); - return SRSRAN_INVALID_RNTI; - } - std::unique_ptr ue_ptr = ue_pool.pop_blocking(); - uint16_t rnti = ue_ptr->get_rnti(); + // Add UE to map + { + srsran::rwlock_write_guard lock(rwlock); + if (ue_db.size() >= args.max_nof_ues) { + logger.warning("Maximum number of connected UEs %d reached. Ignoring PRACH", args.max_nof_ues); + return SRSRAN_INVALID_RNTI; + } + auto ret = ue_db.insert(ue_ptr->get_rnti(), std::move(ue_ptr)); + if (ret) { + inserted_ue = ret.value()->second.get(); + } + } + + // Allocate one new UE object in advance + srsran::get_background_workers().push_task([this]() { prealloc_ue(1); }); + + } while (inserted_ue == nullptr); + + // RNTI allocation was successful + uint16_t rnti = inserted_ue->get_rnti(); // Set PCAP if available if (pcap != nullptr) { - ue_ptr->start_pcap(pcap); + inserted_ue->start_pcap(pcap); } if (pcap_net != nullptr) { - ue_ptr->start_pcap_net(pcap_net); - } - - { - srsran::rwlock_write_guard lock(rwlock); - ue_db[rnti] = std::move(ue_ptr); + inserted_ue->start_pcap_net(pcap_net); } - // Allocate one new UE object in advance - srsran::get_background_workers().push_task([this]() { prealloc_ue(1); }); return rnti; } @@ -590,7 +597,7 @@ int mac::get_dl_sched(uint32_t tti_tx_dl, dl_sched_list_t& dl_sched_res_list) // Get UE uint16_t rnti = sched_result.data[i].dci.rnti; - if (ue_db.count(rnti)) { + if (ue_db.contains(rnti)) { // Copy dci info dl_sched_res->pdsch[n].dci = sched_result.data[i].dci; @@ -905,7 +912,7 @@ int mac::get_ul_sched(uint32_t tti_tx_ul, ul_sched_list_t& ul_sched_res_list) // Get UE uint16_t rnti = sched_result.pusch[i].dci.rnti; - if (ue_db.count(rnti)) { + if (ue_db.contains(rnti)) { // Copy grant info phy_ul_sched_res->pusch[n].current_tx_nb = sched_result.pusch[i].current_tx_nb; phy_ul_sched_res->pusch[n].pid = TTI_RX(tti_tx_ul) % SRSRAN_FDD_NOF_HARQ; @@ -989,7 +996,7 @@ void mac::write_mcch(const srsran::sib2_mbms_t* sib2_, bool mac::check_ue_exists(uint16_t rnti) { - if (not ue_db.count(rnti)) { + if (not ue_db.contains(rnti)) { if (not ues_to_rem.count(rnti)) { logger.error("User rnti=0x%x not found", rnti); } From 5d676199ab7641b4379d10ec154fb4fc3888c404 Mon Sep 17 00:00:00 2001 From: Francisco Date: Fri, 19 Mar 2021 13:40:48 +0000 Subject: [PATCH 04/48] adt bugfix - fix copy/move ctor of circular map --- lib/include/srsran/adt/circular_map.h | 50 +++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/lib/include/srsran/adt/circular_map.h b/lib/include/srsran/adt/circular_map.h index 441dd913d..04a3b0cc3 100644 --- a/lib/include/srsran/adt/circular_map.h +++ b/lib/include/srsran/adt/circular_map.h @@ -82,6 +82,52 @@ public: size_t idx = 0; }; + static_circular_map() { std::fill(present.begin(), present.end(), false); } + static_circular_map(const static_circular_map& other) : present(other.present), count(other.count) + { + for (size_t idx = 0; idx < other.size(); ++idx) { + if (present[idx]) { + new (&buffer[idx]) obj_t(other.get_obj_(idx)); + } + } + } + static_circular_map(static_circular_map&& other) noexcept : present(other.present), count(other.count) + { + for (size_t idx = 0; idx < other.size(); ++idx) { + if (present[idx]) { + new (&buffer[idx]) obj_t(std::move(other.get_obj_(idx))); + } + } + other.clear(); + } + ~static_circular_map() { clear(); } + static_circular_map& operator=(const static_circular_map& other) + { + if (this == &other) { + return *this; + } + clear(); + count = other.count; + present = other.present; + for (size_t idx = 0; idx < other.size(); ++idx) { + if (present[idx]) { + new (&buffer[idx]) obj_t(other.get_obj_(idx)); + } + } + } + static_circular_map& operator=(static_circular_map&& other) noexcept + { + clear(); + count = other.count; + present = other.present; + for (size_t idx = 0; idx < other.size(); ++idx) { + if (present[idx]) { + new (&buffer[idx]) obj_t(std::move(other.get_obj_(idx))); + } + } + clear(); + } + bool contains(K id) { size_t idx = id % N; @@ -182,8 +228,8 @@ private: const obj_t& get_obj_(size_t idx) const { return reinterpret_cast(buffer[idx]); } std::array buffer; - std::array present = {false}; - size_t count = 0; + std::array present; + size_t count = 0; }; } // namespace srsran From 88f5add1fb36726fde2b6d37a584f628723f8cf2 Mon Sep 17 00:00:00 2001 From: Francisco Date: Sun, 21 Mar 2021 13:01:54 +0000 Subject: [PATCH 05/48] adt - fix circular map erase function and added extra asserts --- lib/include/srsran/adt/circular_map.h | 28 ++++++++++++++++++++++----- lib/test/adt/circular_map_test.cc | 27 +++++++++++++++++++++++++- 2 files changed, 49 insertions(+), 6 deletions(-) diff --git a/lib/include/srsran/adt/circular_map.h b/lib/include/srsran/adt/circular_map.h index 04a3b0cc3..7d78b8970 100644 --- a/lib/include/srsran/adt/circular_map.h +++ b/lib/include/srsran/adt/circular_map.h @@ -46,15 +46,32 @@ public: return *this; } - obj_t& operator*() { return ptr->get_obj_(idx); } - obj_t* operator->() { return &ptr->get_obj_(idx); } - const obj_t* operator*() const { return ptr->buffer[idx]; } - const obj_t* operator->() const { return ptr->buffer[idx]; } + obj_t& operator*() + { + assert(idx < ptr->buffer.size() && "Index out-of-bounds"); + return ptr->get_obj_(idx); + } + obj_t* operator->() + { + assert(idx < ptr->buffer.size() && "Index out-of-bounds"); + return &ptr->get_obj_(idx); + } + const obj_t* operator*() const + { + assert(idx < ptr->buffer.size() && "Index out-of-bounds"); + return ptr->buffer[idx]; + } + const obj_t* operator->() const + { + assert(idx < ptr->buffer.size() && "Index out-of-bounds"); + return ptr->buffer[idx]; + } bool operator==(const iterator& other) const { return ptr == other.ptr and idx == other.idx; } bool operator!=(const iterator& other) const { return not(*this == other); } private: + friend class static_circular_map; static_circular_map* ptr = nullptr; size_t idx = 0; }; @@ -78,6 +95,7 @@ public: bool operator!=(const const_iterator& other) const { return not(*this == other); } private: + friend class static_circular_map; const static_circular_map* ptr = nullptr; size_t idx = 0; }; @@ -171,7 +189,7 @@ public: iterator erase(iterator it) { - assert(it->first < N); + assert(it.idx < N); iterator next = it; ++next; it->~obj_t(); diff --git a/lib/test/adt/circular_map_test.cc b/lib/test/adt/circular_map_test.cc index 1db52a581..662f65329 100644 --- a/lib/test/adt/circular_map_test.cc +++ b/lib/test/adt/circular_map_test.cc @@ -61,6 +61,30 @@ int test_id_map() return SRSRAN_SUCCESS; } +int test_id_map_wraparound() +{ + static_circular_map mymap; + + // Fill map + TESTASSERT(mymap.insert(0, "0")); + TESTASSERT(mymap.insert(1, "1")); + TESTASSERT(mymap.insert(2, "2")); + TESTASSERT(mymap.insert(3, "3")); + TESTASSERT(mymap.full()); + + // TEST: Ensure that insertion fails when map is full + TESTASSERT(not mymap.insert(4, "4")); + TESTASSERT(not mymap.erase(4)); + + // TEST: Ensure that insertion works once the element with matching map index is removed + TESTASSERT(mymap.erase(0)); + TESTASSERT(not mymap.full()); + TESTASSERT(mymap.insert(4, "4")); + TESTASSERT(mymap.full()); + + return SRSRAN_SUCCESS; +} + } // namespace srsran int main() @@ -72,5 +96,6 @@ int main() srslog::init(); TESTASSERT(srsran::test_id_map() == SRSRAN_SUCCESS); + TESTASSERT(srsran::test_id_map_wraparound() == SRSRAN_SUCCESS); return SRSRAN_SUCCESS; -} \ No newline at end of file +} From 7595dbaa02d0cdfea5c23705f058fd1bc69843aa Mon Sep 17 00:00:00 2001 From: Francisco Date: Sun, 21 Mar 2021 20:39:45 +0000 Subject: [PATCH 06/48] avoid blocking call for pop from UE pool in mac ue. change log lines --- srsenb/src/stack/mac/mac.cc | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/srsenb/src/stack/mac/mac.cc b/srsenb/src/stack/mac/mac.cc index eeef5e7ba..2accbce19 100644 --- a/srsenb/src/stack/mac/mac.cc +++ b/srsenb/src/stack/mac/mac.cc @@ -443,22 +443,26 @@ uint16_t mac::allocate_ue() ue* inserted_ue = nullptr; do { // Get pre-allocated UE object - if (ue_pool.empty()) { - logger.error("Ignoring RACH attempt. UE pool empty."); + std::unique_ptr ue_ptr; + if (not ue_pool.try_pop(ue_ptr)) { + logger.error("UE pool empty. Ignoring RACH attempt."); return SRSRAN_INVALID_RNTI; } - std::unique_ptr ue_ptr = ue_pool.pop_blocking(); + uint16_t rnti = ue_ptr->get_rnti(); + size_t max_ues = std::min((size_t)args.max_nof_ues, ue_db.capacity()); // Add UE to map { srsran::rwlock_write_guard lock(rwlock); if (ue_db.size() >= args.max_nof_ues) { - logger.warning("Maximum number of connected UEs %d reached. Ignoring PRACH", args.max_nof_ues); + logger.warning("Maximum number of connected UEs %zd connected to the eNB. Ignoring PRACH", max_ues); return SRSRAN_INVALID_RNTI; } - auto ret = ue_db.insert(ue_ptr->get_rnti(), std::move(ue_ptr)); + auto ret = ue_db.insert(rnti, std::move(ue_ptr)); if (ret) { inserted_ue = ret.value()->second.get(); + } else { + logger.info("Failed to allocate rnti=0x%x. Attempting a different rnti.", rnti); } } From 0d5038dd34786d1faec74d804332a864c2e96590 Mon Sep 17 00:00:00 2001 From: Francisco Date: Mon, 22 Mar 2021 10:59:34 +0000 Subject: [PATCH 07/48] fix wrong lib linking in cmaker --- lib/test/adt/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/test/adt/CMakeLists.txt b/lib/test/adt/CMakeLists.txt index 1051c8c4b..983a7959f 100644 --- a/lib/test/adt/CMakeLists.txt +++ b/lib/test/adt/CMakeLists.txt @@ -47,5 +47,5 @@ target_link_libraries(circular_buffer_test srsran_common) add_test(circular_buffer_test circular_buffer_test) add_executable(circular_map_test circular_map_test.cc) -target_link_libraries(circular_map_test srslte_common) +target_link_libraries(circular_map_test srsran_common) add_test(circular_map_test circular_map_test) From d91119baf68fa91bf2cd4ebac33d7ee455e3e8a5 Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Mon, 22 Mar 2021 16:51:32 +0000 Subject: [PATCH 08/48] RLC discard (#2515) * Added ability to discard to dyn_block_queue * Change way of keeping track of SDUs * Check nullptr in poping callback. Starting to check for nullptr in RLC read_pdu. * Adding RLC discard tests * Clearing PDCP info when RLC discard happens * Read SDUs until they are no longer nullptr * Changed discard_if to use template argument --- lib/include/srsran/adt/circular_buffer.h | 32 ++++++++ lib/include/srsran/upper/byte_buffer_queue.h | 37 +++++++-- lib/src/upper/rlc_am_lte.cc | 62 ++++++++++----- lib/test/upper/rlc_am_test.cc | 84 ++++++++++++++++++++ 4 files changed, 189 insertions(+), 26 deletions(-) diff --git a/lib/include/srsran/adt/circular_buffer.h b/lib/include/srsran/adt/circular_buffer.h index 3b8da7a44..28fdf7a81 100644 --- a/lib/include/srsran/adt/circular_buffer.h +++ b/lib/include/srsran/adt/circular_buffer.h @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -156,6 +157,19 @@ public: buffer.resize(size); } + template + T discard_if(const F& func) + { + for (auto it = buffer.begin(); it != buffer.end(); it++) { + if (*it != nullptr && func(*it)) { + T tmp = std::move(*it); + *it = nullptr; + return tmp; + } + } + return nullptr; + } + private: Container buffer; size_t rpos = 0; @@ -264,6 +278,18 @@ public: return false; } + template + bool discard_if(const F& func) + { + std::lock_guard lock(mutex); + T tmp = circ_buffer.discard_if(func); + if (tmp == nullptr) { + return false; + } + pop_func(tmp); + return true; + } + protected: bool active = true; uint8_t nof_waiting = 0; @@ -443,6 +469,12 @@ public: base_t(push_callback, pop_callback, size) {} void set_size(size_t size) { base_t::circ_buffer.set_size(size); } + + template + bool discard_if(const F& func) + { + return base_t::discard_if(func); + } }; } // namespace srsran diff --git a/lib/include/srsran/upper/byte_buffer_queue.h b/lib/include/srsran/upper/byte_buffer_queue.h index 5451ea68d..aa2ef33dc 100644 --- a/lib/include/srsran/upper/byte_buffer_queue.h +++ b/lib/include/srsran/upper/byte_buffer_queue.h @@ -23,7 +23,9 @@ #include "srsran/adt/circular_buffer.h" #include "srsran/common/block_queue.h" +#include "srsran/common/byte_buffer.h" #include "srsran/common/common.h" +#include #include namespace srsran { @@ -31,7 +33,9 @@ namespace srsran { class byte_buffer_queue { public: - byte_buffer_queue(int capacity = 128) : queue(capacity, push_callback(unread_bytes), pop_callback(unread_bytes)) {} + byte_buffer_queue(int capacity = 128) : + queue(capacity, push_callback(unread_bytes, n_sdus), pop_callback(unread_bytes, n_sdus)) + {} void write(unique_byte_buffer_t msg) { queue.push_blocking(std::move(msg)); } @@ -46,6 +50,7 @@ public: void resize(uint32_t capacity) { queue.set_size(capacity); } uint32_t size() { return (uint32_t)queue.size(); } + uint32_t get_n_sdus() { return n_sdus; } uint32_t size_bytes() { return unread_bytes; } @@ -67,20 +72,42 @@ public: bool is_full() { return queue.full(); } + template + bool discard_if(const F& func) + { + return queue.discard_if(func); + } + private: struct push_callback { - explicit push_callback(uint32_t& unread_bytes_) : unread_bytes(&unread_bytes_) {} - void operator()(const unique_byte_buffer_t& msg) { *unread_bytes += msg->N_bytes; } + explicit push_callback(uint32_t& unread_bytes_, uint32_t& n_sdus_) : unread_bytes(&unread_bytes_), n_sdus(&n_sdus_) + {} + void operator()(const unique_byte_buffer_t& msg) + { + *unread_bytes += msg->N_bytes; + (*n_sdus)++; + } uint32_t* unread_bytes; + uint32_t* n_sdus; }; struct pop_callback { - explicit pop_callback(uint32_t& unread_bytes_) : unread_bytes(&unread_bytes_) {} - void operator()(const unique_byte_buffer_t& msg) { *unread_bytes -= std::min(msg->N_bytes, *unread_bytes); } + explicit pop_callback(uint32_t& unread_bytes_, uint32_t& n_sdus_) : unread_bytes(&unread_bytes_), n_sdus(&n_sdus_) + {} + void operator()(const unique_byte_buffer_t& msg) + { + if (msg == nullptr) { + return; + } + *unread_bytes -= std::min(msg->N_bytes, *unread_bytes); + *n_sdus = std::max(0, (int32_t)(*n_sdus) - 1); + } uint32_t* unread_bytes; + uint32_t* n_sdus; }; dyn_blocking_queue queue; uint32_t unread_bytes = 0; + uint32_t n_sdus = 0; }; } // namespace srsran diff --git a/lib/src/upper/rlc_am_lte.cc b/lib/src/upper/rlc_am_lte.cc index 06476b0c2..bd6a8a83c 100644 --- a/lib/src/upper/rlc_am_lte.cc +++ b/lib/src/upper/rlc_am_lte.cc @@ -209,12 +209,9 @@ rlc_am_lte::rlc_am_lte_tx::rlc_am_lte_tx(rlc_am_lte* parent_) : pool(byte_buffer_pool::get_instance()), poll_retx_timer(parent_->timers->get_unique_timer()), status_prohibit_timer(parent_->timers->get_unique_timer()) -{ -} +{} -rlc_am_lte::rlc_am_lte_tx::~rlc_am_lte_tx() -{ -} +rlc_am_lte::rlc_am_lte_tx::~rlc_am_lte_tx() {} void rlc_am_lte::rlc_am_lte_tx::set_bsr_callback(bsr_callback_t callback) { @@ -320,7 +317,7 @@ bool rlc_am_lte::rlc_am_lte_tx::has_data() return (((do_status() && not status_prohibit_timer.is_running())) || // if we have a status PDU to transmit (not retx_queue.empty()) || // if we have a retransmission (tx_sdu != NULL) || // if we are currently transmitting a SDU - (not tx_sdu_queue.is_empty())); // or if there is a SDU queued up for transmission + (tx_sdu_queue.get_n_sdus() != 0)); // or if there is a SDU queued up for transmission } /** @@ -345,8 +342,8 @@ void rlc_am_lte::rlc_am_lte_tx::check_sn_reached_max_retx(uint32_t sn) uint32_t rlc_am_lte::rlc_am_lte_tx::get_buffer_state() { std::lock_guard lock(mutex); - uint32_t n_bytes = 0; - uint32_t n_sdus = 0; + uint32_t n_bytes = 0; + uint32_t n_sdus = 0; logger.debug("%s Buffer state - do_status=%s, status_prohibit_running=%s (%d/%d)", RB_NAME, @@ -384,7 +381,7 @@ uint32_t rlc_am_lte::rlc_am_lte_tx::get_buffer_state() // Bytes needed for tx SDUs if (tx_window.size() < 1024) { - n_sdus = tx_sdu_queue.size(); + n_sdus = tx_sdu_queue.get_n_sdus(); n_bytes += tx_sdu_queue.size_bytes(); if (tx_sdu != NULL) { n_sdus++; @@ -456,7 +453,21 @@ void rlc_am_lte::rlc_am_lte_tx::discard_sdu(uint32_t discard_sn) if (!tx_enabled) { return; } - logger.warning("Discard SDU not implemented yet"); + + bool discarded = + tx_sdu_queue.discard_if([&discard_sn](const unique_byte_buffer_t& sdu) { return sdu->md.pdcp_sn == discard_sn; }); + + if (discarded) { + // remove also from undelivered SDUs queue + logger.info("Discarding SDU with PDCP_SN=%d", discard_sn); + if (not undelivered_sdu_info_queue.has_pdcp_sn(discard_sn)) { + logger.info("PDCP SDU info does not exists for discarded SDU. PDCP_SN=%d", discard_sn); + } else { + undelivered_sdu_info_queue.clear_pdcp_sdu(discard_sn); + } + } else { + logger.info("Could not find SDU to discard. PDCP_SN=%d", discard_sn); + } } bool rlc_am_lte::rlc_am_lte_tx::sdu_queue_is_full() @@ -966,7 +977,7 @@ int rlc_am_lte::rlc_am_lte_tx::build_data_pdu(uint8_t* payload, uint32_t nof_byt } // Pull SDUs from queue - while (pdu_space > head_len && tx_sdu_queue.size() > 0 && header.N_li < RLC_AM_WINDOW_SIZE) { + while (pdu_space > head_len && tx_sdu_queue.get_n_sdus() > 0 && header.N_li < RLC_AM_WINDOW_SIZE) { if (last_li > 0) { header.li[header.N_li] = last_li; header.N_li++; @@ -978,7 +989,18 @@ int rlc_am_lte::rlc_am_lte_tx::build_data_pdu(uint8_t* payload, uint32_t nof_byt } break; } - tx_sdu = tx_sdu_queue.read(); + + do { + tx_sdu = tx_sdu_queue.read(); + } while (tx_sdu == nullptr && tx_sdu_queue.size() != 0); + + if (tx_sdu == nullptr) { + if (header.N_li > 0) { + header.N_li--; + } + break; + } + to_move = ((pdu_space - head_len) >= tx_sdu->N_bytes) ? tx_sdu->N_bytes : pdu_space - head_len; memcpy(pdu_ptr, tx_sdu->msg, to_move); last_li = to_move; @@ -1045,7 +1067,7 @@ int rlc_am_lte::rlc_am_lte_tx::build_data_pdu(uint8_t* payload, uint32_t nof_byt } // Update Tx window - vt_s = (vt_s + 1) % MOD; + vt_s = (vt_s + 1) % MOD; // Write final header and TX tx_pdu.buf = std::move(pdu); @@ -1318,9 +1340,7 @@ rlc_am_lte::rlc_am_lte_rx::rlc_am_lte_rx(rlc_am_lte* parent_) : reordering_timer(parent_->timers->get_unique_timer()) {} -rlc_am_lte::rlc_am_lte_rx::~rlc_am_lte_rx() -{ -} +rlc_am_lte::rlc_am_lte_rx::~rlc_am_lte_rx() {} bool rlc_am_lte::rlc_am_lte_rx::configure(rlc_am_config_t cfg_) { @@ -1752,8 +1772,8 @@ void rlc_am_lte::rlc_am_lte_rx::write_pdu(uint8_t* payload, const uint32_t nof_b parent->tx.handle_control_pdu(payload, nof_bytes); } else { std::lock_guard lock(mutex); - rlc_amd_pdu_header_t header = {}; - uint32_t payload_len = nof_bytes; + rlc_amd_pdu_header_t header = {}; + uint32_t payload_len = nof_bytes; rlc_am_read_data_pdu_header(&payload, &payload_len, &header); if (payload_len > nof_bytes) { logger.info("Dropping corrupted PDU (%d B). Remaining length after header %d B.", nof_bytes, payload_len); @@ -1858,9 +1878,9 @@ int rlc_am_lte::rlc_am_lte_rx::get_status_pdu(rlc_status_pdu_t* status, const ui int rlc_am_lte::rlc_am_lte_rx::get_status_pdu_length() { std::lock_guard lock(mutex); - rlc_status_pdu_t status = {}; - status.ack_sn = vr_ms; - uint32_t i = vr_r; + rlc_status_pdu_t status = {}; + status.ack_sn = vr_ms; + uint32_t i = vr_r; while (RX_MOD_BASE(i) < RX_MOD_BASE(vr_ms) && status.N_nack < RLC_AM_WINDOW_SIZE) { if (not rx_window.has_sn(i)) { status.N_nack++; diff --git a/lib/test/upper/rlc_am_test.cc b/lib/test/upper/rlc_am_test.cc index 649cde13e..47e3a50fe 100644 --- a/lib/test/upper/rlc_am_test.cc +++ b/lib/test/upper/rlc_am_test.cc @@ -3413,6 +3413,85 @@ bool reestablish_test() return SRSRAN_SUCCESS; } +// This test checks the correct functioning of RLC discard functionality +bool discard_test() +{ + const rlc_config_t config = rlc_config_t::default_rlc_am_config(); +#if HAVE_PCAP + rlc_pcap pcap; + pcap.open("rlc_am_reestablish_test.pcap", config); + rlc_am_tester tester(&pcap); +#else + rlc_am_tester tester(NULL); +#endif + + srsran::timer_handler timers(8); + + rlc_am_lte rlc1(srslog::fetch_basic_logger("RLC_AM_1"), 1, &tester, &tester, &timers); + rlc_am_lte rlc2(srslog::fetch_basic_logger("RLC_AM_2"), 1, &tester, &tester, &timers); + + srslog::fetch_basic_logger("RLC_AM_1").set_hex_dump_max_size(100); + srslog::fetch_basic_logger("RLC_AM_2").set_hex_dump_max_size(100); + srslog::fetch_basic_logger("RLC").set_hex_dump_max_size(100); + + if (not rlc1.configure(config)) { + return -1; + } + + if (not rlc2.configure(config)) { + return -1; + } + + // Check has_data() after a SDU discard + { + uint32_t num_tx_pdus = 1; + for (uint32_t i = 0; i < num_tx_pdus; ++i) { + // Write SDU + unique_byte_buffer_t sdu = srsran::make_byte_buffer(); + TESTASSERT(sdu != nullptr); + sdu->N_bytes = 5; + for (uint32_t k = 0; k < sdu->N_bytes; ++k) { + sdu->msg[k] = i; // Write the index into the buffer + } + sdu->md.pdcp_sn = i; + rlc1.write_sdu(std::move(sdu)); + } + } + rlc1.discard_sdu(0); // Try to discard PDCP_SN=1 + TESTASSERT(rlc1.has_data() == false); + + // Discard an SDU in the midle of the queue and read PDUs after + { + uint32_t num_tx_pdus = 10; + for (uint32_t i = 0; i < num_tx_pdus; ++i) { + // Write SDU + unique_byte_buffer_t sdu = srsran::make_byte_buffer(); + TESTASSERT(sdu != nullptr); + sdu->N_bytes = 1; + for (uint32_t k = 0; k < sdu->N_bytes; ++k) { + sdu->msg[k] = i; // Write the index into the buffer + } + sdu->md.pdcp_sn = i; + rlc1.write_sdu(std::move(sdu)); + } + } + rlc1.discard_sdu(3); // Try to discard PDCP_SN=1 + TESTASSERT(rlc1.has_data() == true); + TESTASSERT(rlc1.get_buffer_state() == 23); // 2 bytes fixed header, 12 , 9 bytes of data, + + unique_byte_buffer_t pdu = srsran::make_byte_buffer(); + uint32_t len = rlc1.read_pdu(pdu->msg, 50); // enough for all PDUs + pdu->N_bytes = len; + TESTASSERT(23 == len); + + srslog::fetch_basic_logger("TEST").info("Received %zd SDUs", tester.sdus.size()); + +#if HAVE_PCAP + pcap.close(); +#endif + + return SRSRAN_SUCCESS; +} int main(int argc, char** argv) { // Setup the log message spy to intercept error and warning log entries from RLC @@ -3603,5 +3682,10 @@ int main(int argc, char** argv) exit(-1); }; + if (discard_test()) { + printf("discard_test failed\n"); + exit(-1); + }; + return SRSRAN_SUCCESS; } From 26e79646944f43cf15f6918fee15ca5ede9ff59a Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Mon, 22 Mar 2021 19:01:58 +0100 Subject: [PATCH 09/48] mac_pcap_base: increase PDU queue size to 512 --- lib/include/srsran/common/mac_pcap_base.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/include/srsran/common/mac_pcap_base.h b/lib/include/srsran/common/mac_pcap_base.h index fe1d41b43..c56f18346 100644 --- a/lib/include/srsran/common/mac_pcap_base.h +++ b/lib/include/srsran/common/mac_pcap_base.h @@ -96,7 +96,7 @@ protected: std::mutex mutex; srslog::basic_logger& logger; bool running = false; - static_blocking_queue queue; + static_blocking_queue queue; uint16_t ue_id = 0; private: From 9d8d897d3ea6e6a136a55a71b085ab42982b9f6d Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Mon, 22 Mar 2021 19:04:22 +0100 Subject: [PATCH 10/48] mac_pcap_base: log warning when PDUs can't be added to write queue --- lib/src/common/mac_pcap_base.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/src/common/mac_pcap_base.cc b/lib/src/common/mac_pcap_base.cc index 03426e0e1..b992efee3 100644 --- a/lib/src/common/mac_pcap_base.cc +++ b/lib/src/common/mac_pcap_base.cc @@ -85,10 +85,10 @@ void mac_pcap_base::pack_and_queue(uint8_t* payload, memcpy(pdu.pdu->msg, payload, payload_len); pdu.pdu->N_bytes = payload_len; if (not queue.try_push(std::move(pdu))) { - logger.error("Failed to push message to pcap writer queue"); + logger.warning("Dropping PDU (%d B) in PCAP. Write queue full.", payload_len); } } else { - logger.info("Dropping PDU in PCAP. No buffer available or not enough space (pdu_len=%d).", payload_len); + logger.warning("Dropping PDU in PCAP. No buffer available or not enough space (pdu_len=%d).", payload_len); } } } @@ -122,10 +122,10 @@ void mac_pcap_base::pack_and_queue_nr(uint8_t* payload, memcpy(pdu.pdu->msg, payload, payload_len); pdu.pdu->N_bytes = payload_len; if (not queue.try_push(std::move(pdu))) { - logger.error("Failed to push message to pcap writer queue"); + logger.warning("Dropping PDU (%d B) in NR PCAP. Write queue full.", payload_len); } } else { - logger.info("Dropping PDU in NR PCAP. No buffer available or not enough space (pdu_len=%d).", payload_len); + logger.warning("Dropping PDU in NR PCAP. No buffer available or not enough space (pdu_len=%d).", payload_len); } } } From b5692037a286ad098d3ffb5b4711d5a191ac13e4 Mon Sep 17 00:00:00 2001 From: Francisco Date: Mon, 22 Mar 2021 17:37:08 +0000 Subject: [PATCH 11/48] created macros for assertions and warnings. The assert macro prints the whole callstack on crash. The warning macro can just log a warning or call an assertion fail depending on the cmake flag STOP_ON_WARNING --- CMakeLists.txt | 10 ++++ lib/include/srsran/adt/circular_map.h | 18 +++---- lib/include/srsran/common/srsran_assert.h | 60 ++++++++++++++++++++++ lib/include/srsran/common/test_common.h | 33 ++++++------ lib/test/adt/circular_map_test.cc | 7 ++- srsenb/test/mac/sched_common_test_suite.cc | 22 ++++---- 6 files changed, 108 insertions(+), 42 deletions(-) create mode 100644 lib/include/srsran/common/srsran_assert.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 2f7ff1327..9671e961e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -81,6 +81,8 @@ option(ENABLE_TIMEPROF "Enable time profiling" ON) option(FORCE_32BIT "Add flags to force 32 bit compilation" OFF) option(ENABLE_SRSLOG_TRACING "Enable event tracing using srslog" OFF) +option(ASSERTS_ENABLED "Enable srsRAN asserts" ON) +option(STOP_ON_WARNING "Interrupt application on warning" OFF) # Users that want to try this feature need to make sure the lto plugin is # loaded by bintools (ar, nm, ...). Older versions of bintools will not do @@ -107,6 +109,14 @@ if (ENABLE_SRSLOG_TRACING) add_definitions(-DENABLE_SRSLOG_EVENT_TRACE) endif (ENABLE_SRSLOG_TRACING) +if (ASSERTS_ENABLED) + add_definitions(-DASSERTS_ENABLED) +endif() + +if (STOP_ON_WARNING) + add_definitions(-DSTOP_ON_WARNING) +endif() + ######################################################################## # Find dependencies ######################################################################## diff --git a/lib/include/srsran/adt/circular_map.h b/lib/include/srsran/adt/circular_map.h index 7d78b8970..50ca4b318 100644 --- a/lib/include/srsran/adt/circular_map.h +++ b/lib/include/srsran/adt/circular_map.h @@ -14,15 +14,15 @@ #define SRSRAN_ID_MAP_H #include "expected.h" +#include "srsran/common/srsran_assert.h" #include -#include namespace srsran { template class static_circular_map { - static_assert(std::is_integral::value, "Map key must be an integer"); + static_assert(std::is_integral::value and std::is_unsigned::value, "Map key must be an unsigned integer"); using obj_t = std::pair; using obj_storage_t = typename std::aligned_storage::type; @@ -48,22 +48,22 @@ public: obj_t& operator*() { - assert(idx < ptr->buffer.size() && "Index out-of-bounds"); + srsran_assert(idx < ptr->buffer.size(), "Iterator out-of-bounds (%zd >= %zd)", idx, ptr->buffer.size()); return ptr->get_obj_(idx); } obj_t* operator->() { - assert(idx < ptr->buffer.size() && "Index out-of-bounds"); + srsran_assert(idx < ptr->buffer.size(), "Iterator out-of-bounds (%zd >= %zd)", idx, ptr->buffer.size()); return &ptr->get_obj_(idx); } const obj_t* operator*() const { - assert(idx < ptr->buffer.size() && "Index out-of-bounds"); + srsran_assert(idx < ptr->buffer.size(), "Iterator out-of-bounds (%zd >= %zd)", idx, ptr->buffer.size()); return ptr->buffer[idx]; } const obj_t* operator->() const { - assert(idx < ptr->buffer.size() && "Index out-of-bounds"); + srsran_assert(idx < ptr->buffer.size(), "Iterator out-of-bounds (%zd >= %zd)", idx, ptr->buffer.size()); return ptr->buffer[idx]; } @@ -189,7 +189,7 @@ public: iterator erase(iterator it) { - assert(it.idx < N); + srsran_assert(it.idx < N, "Iterator out-of-bounds (%zd >= %zd)", it.idx, N); iterator next = it; ++next; it->~obj_t(); @@ -207,12 +207,12 @@ public: T& operator[](K id) { - assert(contains(id)); + srsran_assert(contains(id), "Accessing non-existent ID=%zd", (size_t)id); return get_obj_(id % N).second; } const T& operator[](K id) const { - assert(contains(id)); + srsran_assert(contains(id), "Accessing non-existent ID=%zd", (size_t)id); return get_obj_(id % N).second; } diff --git a/lib/include/srsran/common/srsran_assert.h b/lib/include/srsran/common/srsran_assert.h new file mode 100644 index 000000000..f9f3e8646 --- /dev/null +++ b/lib/include/srsran/common/srsran_assert.h @@ -0,0 +1,60 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +#ifndef SRSRAN_ASSERT_H +#define SRSRAN_ASSERT_H + +#include "srsran/common/standard_streams.h" +#include "srsran/srslog/srslog.h" + +#ifdef ASSERTS_ENABLED + +#define srsran_unlikely(expr) __builtin_expect(!!(expr), 0) + +#define srsran_assert(condition, fmt, ...) \ + do { \ + if (srsran_unlikely(not(condition))) { \ + srslog::fetch_basic_logger("ALL").error("%s:%d: " fmt, __FILE__, __LINE__, ##__VA_ARGS__); \ + srsran::console_stderr("%s:%d: " fmt "\n", __FILE__, __LINE__, ##__VA_ARGS__); \ + srslog::flush(); \ + std::abort(); \ + } \ + } while (0) + +#ifdef STOP_ON_WARNING + +#define srsran_warning(condition, fmt, ...) srsran_assert(condition, fmt, ##__VA_ARGS__) + +#else // STOP_ON_WARNING + +#define srsran_warning(condition, fmt, ...) \ + do { \ + if (srsran_unlikely(not(condition))) { \ + srslog::fetch_basic_logger("ALL").warning("%s:%d: " fmt, __FILE__, __LINE__, ##__VA_ARGS__); \ + } \ + } while (0) + +#endif // STOP_ON_WARNING + +#else // ASSERTS_ENABLED + +#define srslte_assert(condition, fmt, ...) \ + do { \ + } while (0) + +#define srsran_warning(condition, fmt, ...) \ + do { \ + } while (0) + +#endif + +#endif // SRSRAN_ASSERT_H diff --git a/lib/include/srsran/common/test_common.h b/lib/include/srsran/common/test_common.h index e85632386..8e3785c85 100644 --- a/lib/include/srsran/common/test_common.h +++ b/lib/include/srsran/common/test_common.h @@ -17,6 +17,8 @@ #ifdef __cplusplus +#include "srsran/common/crash_handler.h" +#include "srsran/common/srsran_assert.h" #include "srsran/common/standard_streams.h" #include "srsran/srslog/srslog.h" #include @@ -128,27 +130,24 @@ private: std::vector entries; }; -} // namespace srsran +inline void test_init(int argc, char** argv) +{ + // Setup a backtrace pretty printer + srsran_debug_handle_crash(argc, argv); -#define TESTERROR(fmt, ...) \ - do { \ - srslog::fetch_basic_logger("TEST").error(fmt, ##__VA_ARGS__); \ - return SRSRAN_ERROR; \ - } while (0) + srslog::fetch_basic_logger("ALL").set_level(srslog::basic_levels::info); -#define TESTWARN(fmt, ...) \ - do { \ - srslog::fetch_basic_logger("TEST").warning(fmt, ##__VA_ARGS__); \ - } while (0) + // Start the log backend. + srslog::init(); +} -#define CONDERROR(cond, fmt, ...) \ - do { \ - if (cond) { \ - TESTERROR(fmt, ##__VA_ARGS__); \ - } \ - } while (0) +} // namespace srsran + +#define CONDERROR(cond, fmt, ...) srsran_assert(not(cond), fmt, ##__VA_ARGS__) + +#define TESTERROR(fmt, ...) CONDERROR(true, fmt, ##__VA_ARGS__) -#define TESTASSERT(cond) CONDERROR((not(cond)), "[%s][Line %d] Fail at \"%s\"", __FUNCTION__, __LINE__, (#cond)) +#define TESTASSERT(cond) srsran_assert((cond), "Fail at \"%s\"", (#cond)) #else // if C diff --git a/lib/test/adt/circular_map_test.cc b/lib/test/adt/circular_map_test.cc index 662f65329..a8a79ab0a 100644 --- a/lib/test/adt/circular_map_test.cc +++ b/lib/test/adt/circular_map_test.cc @@ -10,8 +10,8 @@ * */ -#include "srsran/common/test_common.h" #include "srsran/adt/circular_map.h" +#include "srsran/common/test_common.h" namespace srsran { @@ -87,13 +87,12 @@ int test_id_map_wraparound() } // namespace srsran -int main() +int main(int argc, char** argv) { auto& test_log = srslog::fetch_basic_logger("TEST"); test_log.set_level(srslog::basic_levels::info); - // Start the log backend. - srslog::init(); + srsran::test_init(argc, argv); TESTASSERT(srsran::test_id_map() == SRSRAN_SUCCESS); TESTASSERT(srsran::test_id_map_wraparound() == SRSRAN_SUCCESS); diff --git a/srsenb/test/mac/sched_common_test_suite.cc b/srsenb/test/mac/sched_common_test_suite.cc index 3926c5ba2..2d2554f87 100644 --- a/srsenb/test/mac/sched_common_test_suite.cc +++ b/srsenb/test/mac/sched_common_test_suite.cc @@ -28,12 +28,11 @@ int test_pusch_collisions(const sf_output_res_t& sf_out, uint32_t enb_cc_idx, co auto try_ul_fill = [&](prb_interval alloc, const char* ch_str, bool strict = true) { CONDERROR(alloc.stop() > nof_prb, "Allocated RBs %s out-of-bounds", fmt::format("{}", alloc).c_str()); CONDERROR(alloc.empty(), "Allocations must have at least one PRB"); - if (strict and ul_allocs.any(alloc.start(), alloc.stop())) { - TESTERROR("Collision Detected of %s alloc=%s and cumulative_mask=0x%s", - ch_str, - fmt::format("{}", alloc).c_str(), - fmt::format("{:x}", ul_allocs).c_str()); - } + CONDERROR(strict and ul_allocs.any(alloc.start(), alloc.stop()), + "Collision Detected of %s alloc=%s and cumulative_mask=0x%s", + ch_str, + fmt::format("{}", alloc).c_str(), + fmt::format("{:x}", ul_allocs).c_str()); ul_allocs.fill(alloc.start(), alloc.stop(), true); return SRSRAN_SUCCESS; }; @@ -102,12 +101,11 @@ int test_pdsch_collisions(const sf_output_res_t& sf_out, uint32_t enb_cc_idx, co return SRSRAN_ERROR; } CONDERROR(alloc_mask.none(), "DL allocation must occupy at least one RBG."); - if ((dl_allocs & alloc_mask).any()) { - TESTERROR("Detected collision in the DL %s allocation (%s intersects %s)", - channel, - fmt::format("{}", dl_allocs).c_str(), - fmt::format("{}", alloc_mask).c_str()); - } + CONDERROR((dl_allocs & alloc_mask).any(), + "Detected collision in the DL %s allocation (%s intersects %s)", + channel, + fmt::format("{}", dl_allocs).c_str(), + fmt::format("{}", alloc_mask).c_str()); dl_allocs |= alloc_mask; return SRSRAN_SUCCESS; }; From dd336c53eacde0c2a256aa5081214e6038c0a42d Mon Sep 17 00:00:00 2001 From: Francisco Date: Mon, 22 Mar 2021 20:34:18 +0000 Subject: [PATCH 12/48] changed srsran_warning to srsran_expect. Applied new macro to rlc am --- lib/include/srsran/common/srsran_assert.h | 6 +++--- lib/include/srsran/common/tti_point.h | 10 ++++------ lib/include/srsran/upper/rlc_am_lte.h | 7 ++++--- lib/src/upper/rlc_am_lte.cc | 4 ++-- srsenb/src/main.cc | 2 +- srsue/src/main.cc | 1 + 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/include/srsran/common/srsran_assert.h b/lib/include/srsran/common/srsran_assert.h index f9f3e8646..e2b5a462b 100644 --- a/lib/include/srsran/common/srsran_assert.h +++ b/lib/include/srsran/common/srsran_assert.h @@ -32,11 +32,11 @@ #ifdef STOP_ON_WARNING -#define srsran_warning(condition, fmt, ...) srsran_assert(condition, fmt, ##__VA_ARGS__) +#define srsran_expect(condition, fmt, ...) srsran_assert(condition, fmt, ##__VA_ARGS__) #else // STOP_ON_WARNING -#define srsran_warning(condition, fmt, ...) \ +#define srsran_expect(condition, fmt, ...) \ do { \ if (srsran_unlikely(not(condition))) { \ srslog::fetch_basic_logger("ALL").warning("%s:%d: " fmt, __FILE__, __LINE__, ##__VA_ARGS__); \ @@ -51,7 +51,7 @@ do { \ } while (0) -#define srsran_warning(condition, fmt, ...) \ +#define srsran_expect(condition, fmt, ...) \ do { \ } while (0) diff --git a/lib/include/srsran/common/tti_point.h b/lib/include/srsran/common/tti_point.h index a94adf779..08151f1a2 100644 --- a/lib/include/srsran/common/tti_point.h +++ b/lib/include/srsran/common/tti_point.h @@ -15,6 +15,7 @@ #include "srsran/adt/interval.h" #include "srsran/common/common.h" +#include "srsran/common/srsran_assert.h" #include "srsran/srslog/srslog.h" #include #include @@ -23,16 +24,13 @@ namespace srsran { struct tti_point { constexpr tti_point() = default; - explicit tti_point(uint32_t tti_val_) : tti_val(tti_val_ % 10240u) + explicit tti_point(uint32_t tti_val_) : tti_val(tti_val_ % 10240U) { if (tti_val_ > std::numeric_limits::max() / 2) { // there was a overflow at tti initialization uint32_t diff = std::numeric_limits::max() - tti_val_; - if (diff < 10240) { - tti_val = 10240 - diff - 1; - } else { - srslog::fetch_basic_logger("COMMON").error("Invalid TTI point assigned"); - } + srsran_expect(diff < 10240, "Invalid TTI point assigned"); + tti_val = 10240 - diff - 1; } } void reset() { tti_val = std::numeric_limits::max(); } diff --git a/lib/include/srsran/upper/rlc_am_lte.h b/lib/include/srsran/upper/rlc_am_lte.h index 202240138..5f273c64a 100644 --- a/lib/include/srsran/upper/rlc_am_lte.h +++ b/lib/include/srsran/upper/rlc_am_lte.h @@ -17,6 +17,7 @@ #include "srsran/adt/circular_array.h" #include "srsran/common/buffer_pool.h" #include "srsran/common/common.h" +#include "srsran/common/srsran_assert.h" #include "srsran/common/task_scheduler.h" #include "srsran/common/timeout.h" #include "srsran/interfaces/pdcp_interface_types.h" @@ -75,7 +76,7 @@ struct rlc_ringbuffer_t { rlc_ringbuffer_t() { clear(); } T& add_pdu(size_t sn) { - assert(not has_sn(sn)); + srsran_expect(not has_sn(sn), "The same SN=%d should not be added twice", sn); window[sn].rlc_sn = sn; active_flag[sn] = true; count++; @@ -83,14 +84,14 @@ struct rlc_ringbuffer_t { } void remove_pdu(size_t sn) { - assert(active_flag[sn]); + srsran_expect(has_sn(sn), "The removed SN=%d is not in the window", sn); window[sn] = {}; active_flag[sn] = false; count--; } T& operator[](size_t sn) { - assert(has_sn(sn)); + srsran_expect(has_sn(sn), "The accessed SN=%d is not in the window", sn); return window[sn]; } size_t size() const { return count; } diff --git a/lib/src/upper/rlc_am_lte.cc b/lib/src/upper/rlc_am_lte.cc index bd6a8a83c..5258806d4 100644 --- a/lib/src/upper/rlc_am_lte.cc +++ b/lib/src/upper/rlc_am_lte.cc @@ -820,7 +820,7 @@ int rlc_am_lte::rlc_am_lte_tx::build_segment(uint8_t* payload, uint32_t nof_byte } // Santity check we don't pack beyond the provided buffer - assert(head_len + (retx.so_end - retx.so_start) <= nof_bytes); + srsran_expect(head_len + (retx.so_end - retx.so_start) <= nof_bytes, "The provided buffer was overflown."); // Update retx_queue if (tx_window[retx.sn].buf->N_bytes == retx.so_end) { @@ -1129,7 +1129,7 @@ void rlc_am_lte::rlc_am_lte_tx::handle_control_pdu(uint8_t* payload, uint32_t no auto& pdu = tx_window[i]; if (!retx_queue.has_sn(i)) { rlc_amd_retx_t& retx = retx_queue.push(); - assert(tx_window[i].rlc_sn == i); + srsran_expect(tx_window[i].rlc_sn == i, "Incorrect RLC SN=%d!=%d being accessed", tx_window[i].rlc_sn, i); retx.sn = i; retx.is_segment = false; retx.so_start = 0; diff --git a/srsenb/src/main.cc b/srsenb/src/main.cc index 4f699cbb2..145603f9b 100644 --- a/srsenb/src/main.cc +++ b/srsenb/src/main.cc @@ -512,7 +512,7 @@ int main(int argc, char* argv[]) // Start the log backend. srslog::init(); - srslog::fetch_basic_logger("COMMON").set_level(srslog::basic_levels::info); + srslog::fetch_basic_logger("ALL").set_level(srslog::basic_levels::warning); srsran::log_args(argc, argv, "ENB"); srsran::check_scaling_governor(args.rf.device_name); diff --git a/srsue/src/main.cc b/srsue/src/main.cc index 66a44a02b..a8fa32a91 100644 --- a/srsue/src/main.cc +++ b/srsue/src/main.cc @@ -663,6 +663,7 @@ int main(int argc, char* argv[]) // Start the log backend. srslog::init(); + srslog::fetch_basic_logger("ALL").set_level(srslog::basic_levels::warning); srsran::log_args(argc, argv, "UE"); srsran::check_scaling_governor(args.rf.device_name); From 46d46e70ffb8ad2abec8d7d3cd7c95516cca7721 Mon Sep 17 00:00:00 2001 From: Francisco Date: Tue, 23 Mar 2021 09:46:28 +0000 Subject: [PATCH 13/48] add documentation for srsran_assert and srsran_expect macros --- lib/include/srsran/common/srsran_assert.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/include/srsran/common/srsran_assert.h b/lib/include/srsran/common/srsran_assert.h index e2b5a462b..48b1f4244 100644 --- a/lib/include/srsran/common/srsran_assert.h +++ b/lib/include/srsran/common/srsran_assert.h @@ -20,6 +20,10 @@ #define srsran_unlikely(expr) __builtin_expect(!!(expr), 0) +/** + * Macro that asserts condition is true. If false, it logs the remaining parameters, prints the backtrace and closes + * the application + */ #define srsran_assert(condition, fmt, ...) \ do { \ if (srsran_unlikely(not(condition))) { \ @@ -32,6 +36,10 @@ #ifdef STOP_ON_WARNING +/** + * Macro that verifies if condition is true. If false, and STOP_ON_WARNING is true, it behaves like srsran_assert. + * If STOP_ON_WARNING is false, it logs a warning. + */ #define srsran_expect(condition, fmt, ...) srsran_assert(condition, fmt, ##__VA_ARGS__) #else // STOP_ON_WARNING From 1a0891df5134bd14fb25bb9fafcc75b6098d9d3e Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Mon, 22 Mar 2021 17:24:52 +0100 Subject: [PATCH 14/48] all: check return value of make_byte_buffer() and handle them safely --- lib/include/srsran/common/basic_pnf.h | 3 ++ lib/src/common/basic_vnf.cc | 5 ++- lib/src/upper/pdcp_entity_lte.cc | 8 +++- lib/test/asn1/srsran_asn1_nas_test.cc | 2 + lib/test/common/byte_buffer_queue_test.cc | 3 ++ lib/test/common/choice_type_test.cc | 2 + lib/test/upper/pdcp_lte_test_discard_sdu.cc | 4 ++ srsenb/hdr/stack/rrc/rrc.h | 14 +++--- srsenb/hdr/stack/rrc/rrc_nr.h | 16 +++---- srsenb/src/stack/enb_stack_lte.cc | 5 ++- srsenb/src/stack/mac/mac_nr.cc | 27 +++++++---- srsenb/src/stack/rrc/rrc.cc | 34 +++++++++----- srsenb/src/stack/rrc/rrc_mobility.cc | 15 ++++++- srsenb/src/stack/rrc/rrc_nr.cc | 36 ++++++++++----- srsenb/src/stack/rrc/rrc_ue.cc | 8 ++++ srsenb/test/rrc/rrc_nr_test.cc | 6 +-- srsepc/src/mbms-gw/mbms-gw.cc | 4 ++ srsepc/src/mme/mme.cc | 4 ++ srsue/hdr/stack/mac_nr/mux_nr.h | 2 +- srsue/src/phy/nr/cc_worker.cc | 4 ++ srsue/src/stack/mac_nr/mac_nr.cc | 16 +++++-- srsue/src/stack/mac_nr/mux_nr.cc | 11 +++-- srsue/src/stack/rrc/rrc.cc | 12 ++--- srsue/src/stack/rrc/rrc_procedures.cc | 4 +- srsue/src/stack/upper/gw.cc | 2 +- srsue/src/stack/upper/nas.cc | 50 ++++++++++++++++----- srsue/test/mac_nr/proc_ra_nr_test.cc | 1 + srsue/test/ttcn3/hdr/ttcn3_drb_interface.h | 4 ++ srsue/test/ttcn3/hdr/ttcn3_srb_interface.h | 11 +++-- srsue/test/ttcn3/hdr/ttcn3_sys_interface.h | 8 ++++ srsue/test/upper/nas_test.cc | 9 ++++ srsue/test/upper/rrc_meas_test.cc | 10 ++++- srsue/test/upper/tft_test.cc | 15 +++++++ 33 files changed, 272 insertions(+), 83 deletions(-) diff --git a/lib/include/srsran/common/basic_pnf.h b/lib/include/srsran/common/basic_pnf.h index 1aef9ee62..8b7003f7b 100644 --- a/lib/include/srsran/common/basic_pnf.h +++ b/lib/include/srsran/common/basic_pnf.h @@ -363,6 +363,9 @@ private: uint32_t len = sizeof(*msg) - sizeof(msg->pdus->data) + msg->pdus->length; srsran::unique_byte_buffer_t tx = srsran::make_byte_buffer(); + if (tx == nullptr) { + return -1; + } memcpy(tx->msg, msg, len); rf_out_queue->push(std::move(tx)); } diff --git a/lib/src/common/basic_vnf.cc b/lib/src/common/basic_vnf.cc index d3ad5819b..69a020e47 100644 --- a/lib/src/common/basic_vnf.cc +++ b/lib/src/common/basic_vnf.cc @@ -183,14 +183,15 @@ int srsran_basic_vnf::handle_dl_ind(basic_vnf_api::dl_ind_msg_t* msg) for (uint32_t i = 0; i < msg->nof_pdus; ++i) { dl_grant.tb[i] = srsran::make_byte_buffer(); - if (dl_grant.tb[i]->get_tailroom() >= msg->pdus[i].length) { + if (dl_grant.tb[i] && dl_grant.tb[i]->get_tailroom() >= msg->pdus[i].length) { memcpy(dl_grant.tb[i]->msg, msg->pdus[i].data, msg->pdus[i].length); dl_grant.tb[i]->N_bytes = msg->pdus[i].length; if (msg->pdus[i].type == basic_vnf_api::PDSCH) { m_ue_stack->tb_decoded(cc_idx, dl_grant); } } else { - logger.error("TB too big to fit into buffer (%d > %d)", msg->pdus[i].length, dl_grant.tb[i]->get_tailroom()); + logger.error("TB too big to fit into buffer (%d)", msg->pdus[i].length); + return SRSRAN_ERROR; } } diff --git a/lib/src/upper/pdcp_entity_lte.cc b/lib/src/upper/pdcp_entity_lte.cc index 132d3bc9e..b75bf763c 100644 --- a/lib/src/upper/pdcp_entity_lte.cc +++ b/lib/src/upper/pdcp_entity_lte.cc @@ -958,8 +958,12 @@ std::map undelivered_sdus_queue::get_buf if (sdu.sdu != nullptr) { // TODO: Find ways to avoid deep copy srsran::unique_byte_buffer_t fwd_sdu = make_byte_buffer(); - *fwd_sdu = *sdu.sdu; - fwd_sdus.emplace(sdu.sdu->md.pdcp_sn, std::move(fwd_sdu)); + if (fwd_sdu != nullptr) { + *fwd_sdu = *sdu.sdu; + fwd_sdus.emplace(sdu.sdu->md.pdcp_sn, std::move(fwd_sdu)); + } else { + srslog::fetch_basic_logger("PDCP").warning("Can't allocate buffer to forward buffered SDUs."); + } } } return fwd_sdus; diff --git a/lib/test/asn1/srsran_asn1_nas_test.cc b/lib/test/asn1/srsran_asn1_nas_test.cc index a975aa885..e9c2f4b27 100644 --- a/lib/test/asn1/srsran_asn1_nas_test.cc +++ b/lib/test/asn1/srsran_asn1_nas_test.cc @@ -32,7 +32,9 @@ int nas_dedicated_eps_bearer_context_setup_request_test() srsran::unique_byte_buffer_t tst_msg, out_msg; tst_msg = srsran::make_byte_buffer(); + TESTASSERT(tst_msg != nullptr); out_msg = srsran::make_byte_buffer(); + TESTASSERT(out_msg != nullptr); LIBLTE_MME_ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_MSG_STRUCT ded_bearer_req; diff --git a/lib/test/common/byte_buffer_queue_test.cc b/lib/test/common/byte_buffer_queue_test.cc index 0371860a9..dbd4db650 100644 --- a/lib/test/common/byte_buffer_queue_test.cc +++ b/lib/test/common/byte_buffer_queue_test.cc @@ -27,6 +27,9 @@ void* write_thread(void* a) args_t* args = (args_t*)a; for (uint32_t i = 0; i < NMSGS; i++) { unique_byte_buffer_t b = srsran::make_byte_buffer(); + if (b == nullptr) { + return nullptr; + } memcpy(b->msg, &i, 4); b->N_bytes = 4; args->q->write(std::move(b)); diff --git a/lib/test/common/choice_type_test.cc b/lib/test/common/choice_type_test.cc index 5b46e24cc..df8c59e5f 100644 --- a/lib/test/common/choice_type_test.cc +++ b/lib/test/common/choice_type_test.cc @@ -200,6 +200,7 @@ int test_visit() // TEST: visitor hits type E and steals pdu E e; e.pdu = srsran::make_byte_buffer(); + TESTASSERT(e.pdu != nullptr); c = std::move(e); TESTASSERT(c.is() and srsran::get(c).pdu != nullptr); srsran::visit(v, c); @@ -209,6 +210,7 @@ int test_visit() // TEST: visitor hits type E and steals pdu. Second type called there is no pdu to steal. v.pdu = nullptr; e.pdu = srsran::make_byte_buffer(); + TESTASSERT(e.pdu != nullptr); c = std::move(e); srsran::visit(v, c); TESTASSERT(v.pdu != nullptr); diff --git a/lib/test/upper/pdcp_lte_test_discard_sdu.cc b/lib/test/upper/pdcp_lte_test_discard_sdu.cc index 50ba809eb..0d230dd62 100644 --- a/lib/test/upper/pdcp_lte_test_discard_sdu.cc +++ b/lib/test/upper/pdcp_lte_test_discard_sdu.cc @@ -37,10 +37,12 @@ int test_tx_sdu_notify(const srsran::pdcp_lte_state_t& init_state, // Write test SDU srsran::unique_byte_buffer_t sdu = srsran::make_byte_buffer(); + TESTASSERT(sdu != nullptr); sdu->append_bytes(sdu1, sizeof(sdu1)); pdcp->write_sdu(std::move(sdu)); srsran::unique_byte_buffer_t out_pdu = srsran::make_byte_buffer(); + TESTASSERT(out_pdu != nullptr); rlc->get_last_sdu(out_pdu); TESTASSERT(out_pdu->N_bytes == 4); @@ -84,10 +86,12 @@ int test_tx_sdu_discard(const srsran::pdcp_lte_state_t& init_state, // Write test SDU srsran::unique_byte_buffer_t sdu = srsran::make_byte_buffer(); + TESTASSERT(sdu != nullptr); sdu->append_bytes(sdu1, sizeof(sdu1)); pdcp->write_sdu(std::move(sdu)); srsran::unique_byte_buffer_t out_pdu = srsran::make_byte_buffer(); + TESTASSERT(out_pdu != nullptr); rlc->get_last_sdu(out_pdu); TESTASSERT(out_pdu->N_bytes == 4); diff --git a/srsenb/hdr/stack/rrc/rrc.h b/srsenb/hdr/stack/rrc/rrc.h index 184ec5a10..dfea04db4 100644 --- a/srsenb/hdr/stack/rrc/rrc.h +++ b/srsenb/hdr/stack/rrc/rrc.h @@ -52,13 +52,13 @@ public: explicit rrc(srsran::task_sched_handle task_sched_); ~rrc(); - void init(const rrc_cfg_t& cfg_, - phy_interface_rrc_lte* phy, - mac_interface_rrc* mac, - rlc_interface_rrc* rlc, - pdcp_interface_rrc* pdcp, - s1ap_interface_rrc* s1ap, - gtpu_interface_rrc* gtpu); + int32_t init(const rrc_cfg_t& cfg_, + phy_interface_rrc_lte* phy, + mac_interface_rrc* mac, + rlc_interface_rrc* rlc, + pdcp_interface_rrc* pdcp, + s1ap_interface_rrc* s1ap, + gtpu_interface_rrc* gtpu); void stop(); void get_metrics(rrc_metrics_t& m); diff --git a/srsenb/hdr/stack/rrc/rrc_nr.h b/srsenb/hdr/stack/rrc/rrc_nr.h index d21933406..278a83066 100644 --- a/srsenb/hdr/stack/rrc/rrc_nr.h +++ b/srsenb/hdr/stack/rrc/rrc_nr.h @@ -63,13 +63,13 @@ class rrc_nr final : public rrc_interface_pdcp_nr, public: explicit rrc_nr(srsran::timer_handler* timers_); - void init(const rrc_nr_cfg_t& cfg, - phy_interface_stack_nr* phy, - mac_interface_rrc_nr* mac, - rlc_interface_rrc_nr* rlc, - pdcp_interface_rrc_nr* pdcp, - ngap_interface_rrc_nr* ngap_, - gtpu_interface_rrc_nr* gtpu); + int32_t init(const rrc_nr_cfg_t& cfg, + phy_interface_stack_nr* phy, + mac_interface_rrc_nr* mac, + rlc_interface_rrc_nr* rlc, + pdcp_interface_rrc_nr* pdcp, + ngap_interface_rrc_nr* ngap_, + gtpu_interface_rrc_nr* gtpu); void stop(); @@ -78,7 +78,7 @@ public: rrc_nr_cfg_t update_default_cfg(const rrc_nr_cfg_t& rrc_cfg); void add_user(uint16_t rnti); void config_mac(); - uint32_t generate_sibs(); + int32_t generate_sibs(); int read_pdu_bcch_bch(const uint32_t tti, srsran::unique_byte_buffer_t& buffer) final; int read_pdu_bcch_dlsch(uint32_t sib_index, srsran::unique_byte_buffer_t& buffer) final; diff --git a/srsenb/src/stack/enb_stack_lte.cc b/srsenb/src/stack/enb_stack_lte.cc index 83321b375..ecca7314b 100644 --- a/srsenb/src/stack/enb_stack_lte.cc +++ b/srsenb/src/stack/enb_stack_lte.cc @@ -122,7 +122,10 @@ int enb_stack_lte::init(const stack_args_t& args_, const rrc_cfg_t& rrc_cfg_) } rlc.init(&pdcp, &rrc, &mac, task_sched.get_timer_handler()); pdcp.init(&rlc, &rrc, >pu); - rrc.init(rrc_cfg, phy, &mac, &rlc, &pdcp, &s1ap, >pu); + if (rrc.init(rrc_cfg, phy, &mac, &rlc, &pdcp, &s1ap, >pu) != SRSRAN_SUCCESS) { + stack_logger.error("Couldn't initialize RRC"); + return SRSRAN_ERROR; + } if (s1ap.init(args.s1ap, &rrc, this) != SRSRAN_SUCCESS) { stack_logger.error("Couldn't initialize S1AP"); return SRSRAN_ERROR; diff --git a/srsenb/src/stack/mac/mac_nr.cc b/srsenb/src/stack/mac/mac_nr.cc index c55ed530a..5795549aa 100644 --- a/srsenb/src/stack/mac/mac_nr.cc +++ b/srsenb/src/stack/mac/mac_nr.cc @@ -22,14 +22,6 @@ namespace srsenb { mac_nr::mac_nr() : logger(srslog::fetch_basic_logger("MAC")) { - bcch_bch_payload = srsran::make_byte_buffer(); - - // allocate 8 tx buffers for UE (TODO: as we don't handle softbuffers why do we need so many buffers) - for (int i = 0; i < SRSRAN_FDD_NOF_HARQ; i++) { - ue_tx_buffer.emplace_back(srsran::make_byte_buffer()); - } - - ue_rlc_buffer = srsran::make_byte_buffer(); } mac_nr::~mac_nr() @@ -58,6 +50,25 @@ int mac_nr::init(const mac_nr_args_t& args_, pcap->open(args.pcap.filename); } + bcch_bch_payload = srsran::make_byte_buffer(); + if (bcch_bch_payload == nullptr) { + return SRSRAN_ERROR; + } + + // allocate 8 tx buffers for UE (TODO: as we don't handle softbuffers why do we need so many buffers) + for (int i = 0; i < SRSRAN_FDD_NOF_HARQ; i++) { + srsran::unique_byte_buffer_t buffer = srsran::make_byte_buffer(); + if (buffer == nullptr) { + return SRSRAN_ERROR; + } + ue_tx_buffer.emplace_back(std::move(buffer)); + } + + ue_rlc_buffer = srsran::make_byte_buffer(); + if (ue_rlc_buffer == nullptr) { + return SRSRAN_ERROR; + } + logger.info("Started"); started = true; diff --git a/srsenb/src/stack/rrc/rrc.cc b/srsenb/src/stack/rrc/rrc.cc index e969f8b64..18bb26956 100644 --- a/srsenb/src/stack/rrc/rrc.cc +++ b/srsenb/src/stack/rrc/rrc.cc @@ -40,13 +40,13 @@ rrc::rrc(srsran::task_sched_handle task_sched_) : rrc::~rrc() {} -void rrc::init(const rrc_cfg_t& cfg_, - phy_interface_rrc_lte* phy_, - mac_interface_rrc* mac_, - rlc_interface_rrc* rlc_, - pdcp_interface_rrc* pdcp_, - s1ap_interface_rrc* s1ap_, - gtpu_interface_rrc* gtpu_) +int32_t rrc::init(const rrc_cfg_t& cfg_, + phy_interface_rrc_lte* phy_, + mac_interface_rrc* mac_, + rlc_interface_rrc* rlc_, + pdcp_interface_rrc* pdcp_, + s1ap_interface_rrc* s1ap_, + gtpu_interface_rrc* gtpu_) { phy = phy_; mac = mac_; @@ -67,7 +67,10 @@ void rrc::init(const rrc_cfg_t& cfg_, // Loads the PRACH root sequence cfg.sibs[1].sib2().rr_cfg_common.prach_cfg.root_seq_idx = cfg.cell_list[0].root_seq_idx; - nof_si_messages = generate_sibs(); + if (generate_sibs() != SRSRAN_SUCCESS) { + logger.error("Couldn't generate SIBs."); + return false; + } config_mac(); // Check valid inactivity timeout config @@ -84,6 +87,8 @@ void rrc::init(const rrc_cfg_t& cfg_, logger.info("Inactivity timeout: %d ms", cfg.inactivity_timeout_ms); running = true; + + return SRSRAN_SUCCESS; } void rrc::stop() @@ -764,7 +769,9 @@ void rrc::config_mac() * Before packing the message, it patches the cell specific params of * the SIB, including the cellId and the PRACH config index. * - * @return The number of SIBs messages per CC + * The number of generates SIB messages is stored in the class member nof_si_messages + * + * @return SRSRAN_SUCCESS on success, SRSRAN_ERROR on failure */ uint32_t rrc::generate_sibs() { @@ -809,9 +816,14 @@ uint32_t rrc::generate_sibs() // Pack payload for all messages for (uint32_t msg_index = 0; msg_index < nof_messages; msg_index++) { srsran::unique_byte_buffer_t sib_buffer = srsran::make_byte_buffer(); + if (sib_buffer == nullptr) { + logger.error("Couldn't allocate PDU in %s().", __FUNCTION__); + return SRSRAN_ERROR; + } asn1::bit_ref bref(sib_buffer->msg, sib_buffer->get_tailroom()); if (msg[msg_index].pack(bref) == asn1::SRSASN_ERROR_ENCODE_FAIL) { logger.error("Failed to pack SIB message %d", msg_index); + return SRSRAN_ERROR; } sib_buffer->N_bytes = bref.distance_bytes(); cell_ctxt->sib_buffer.push_back(std::move(sib_buffer)); @@ -827,7 +839,9 @@ uint32_t rrc::generate_sibs() } } - return nof_messages; + nof_si_messages = nof_messages; + + return SRSRAN_SUCCESS; } void rrc::configure_mbsfn_sibs() diff --git a/srsenb/src/stack/rrc/rrc_mobility.cc b/srsenb/src/stack/rrc/rrc_mobility.cc index f96704c64..16a5433a0 100644 --- a/srsenb/src/stack/rrc/rrc_mobility.cc +++ b/srsenb/src/stack/rrc/rrc_mobility.cc @@ -329,6 +329,10 @@ bool rrc::ue::rrc_mobility::start_ho_preparation(uint32_t target_eci, hoprep_r8.ue_radio_access_cap_info[0].rat_type = asn1::rrc::rat_type_e::eutra; srsran::unique_byte_buffer_t buffer = srsran::make_byte_buffer(); + if (buffer == nullptr) { + logger.error("Couldn't allocate PDU in %s().", __FUNCTION__); + return false; + } asn1::bit_ref bref(buffer->msg, buffer->get_tailroom()); if (rrc_ue->eutra_capabilities.pack(bref) == asn1::SRSASN_ERROR_ENCODE_FAIL) { logger.error("Failed to pack UE EUTRA Capability"); @@ -368,6 +372,10 @@ bool rrc::ue::rrc_mobility::start_ho_preparation(uint32_t target_eci, /*** pack HO Preparation Info into an RRC container buffer ***/ srsran::unique_byte_buffer_t buffer = srsran::make_byte_buffer(); + if (buffer == nullptr) { + logger.error("Couldn't allocate PDU in %s().", __FUNCTION__); + return false; + } asn1::bit_ref bref(buffer->msg, buffer->get_tailroom()); if (hoprep.pack(bref) == asn1::SRSASN_ERROR_ENCODE_FAIL) { Error("Failed to pack HO preparation msg"); @@ -711,7 +719,12 @@ void rrc::ue::rrc_mobility::handle_ho_requested(idle_st& s, const ho_req_rx_ev& /* Prepare Handover Command to be sent via S1AP */ srsran::unique_byte_buffer_t ho_cmd_pdu = srsran::make_byte_buffer(); - asn1::bit_ref bref2{ho_cmd_pdu->msg, ho_cmd_pdu->get_tailroom()}; + if (ho_cmd_pdu == nullptr) { + logger.error("Couldn't allocate PDU in %s().", __FUNCTION__); + trigger(srsran::failure_ev{}); + return; + } + asn1::bit_ref bref2{ho_cmd_pdu->msg, ho_cmd_pdu->get_tailroom()}; if (dl_dcch_msg.pack(bref2) != asn1::SRSASN_SUCCESS) { logger.error("Failed to pack HandoverCommand"); trigger(srsran::failure_ev{}); diff --git a/srsenb/src/stack/rrc/rrc_nr.cc b/srsenb/src/stack/rrc/rrc_nr.cc index 996144d7f..d71df9ef3 100644 --- a/srsenb/src/stack/rrc/rrc_nr.cc +++ b/srsenb/src/stack/rrc/rrc_nr.cc @@ -21,13 +21,13 @@ namespace srsenb { rrc_nr::rrc_nr(srsran::timer_handler* timers_) : logger(srslog::fetch_basic_logger("RRC")), timers(timers_) {} -void rrc_nr::init(const rrc_nr_cfg_t& cfg_, - phy_interface_stack_nr* phy_, - mac_interface_rrc_nr* mac_, - rlc_interface_rrc_nr* rlc_, - pdcp_interface_rrc_nr* pdcp_, - ngap_interface_rrc_nr* ngap_, - gtpu_interface_rrc_nr* gtpu_) +int rrc_nr::init(const rrc_nr_cfg_t& cfg_, + phy_interface_stack_nr* phy_, + mac_interface_rrc_nr* mac_, + rlc_interface_rrc_nr* rlc_, + pdcp_interface_rrc_nr* pdcp_, + ngap_interface_rrc_nr* ngap_, + gtpu_interface_rrc_nr* gtpu_) { phy = phy_; mac = mac_; @@ -46,7 +46,11 @@ void rrc_nr::init(const rrc_nr_cfg_t& cfg_, // derived slot_dur_ms = 1; - nof_si_messages = generate_sibs(); + if (generate_sibs() != SRSRAN_SUCCESS) { + logger.error("Couldn't generate SIB messages."); + return SRSRAN_ERROR; + } + config_mac(); // add dummy user @@ -67,6 +71,8 @@ void rrc_nr::init(const rrc_nr_cfg_t& cfg_, logger.info("Started"); running = true; + + return SRSRAN_SUCCESS; } void rrc_nr::stop() @@ -198,7 +204,7 @@ void rrc_nr::config_mac() mac->cell_cfg(&sched_cfg); } -uint32_t rrc_nr::generate_sibs() +int32_t rrc_nr::generate_sibs() { // MIB packing bcch_bch_msg_s mib_msg; @@ -206,6 +212,10 @@ uint32_t rrc_nr::generate_sibs() mib = cfg.mib; { srsran::unique_byte_buffer_t mib_buf = srsran::make_byte_buffer(); + if (mib_buf == nullptr) { + logger.error("Couldn't allocate PDU in %s().", __FUNCTION__); + return SRSRAN_ERROR; + } asn1::bit_ref bref(mib_buf->msg, mib_buf->get_tailroom()); mib_msg.pack(bref); mib_buf->N_bytes = bref.distance_bytes(); @@ -240,6 +250,10 @@ uint32_t rrc_nr::generate_sibs() // Pack payload for all messages for (uint32_t msg_index = 0; msg_index < nof_messages + 1; msg_index++) { srsran::unique_byte_buffer_t sib = srsran::make_byte_buffer(); + if (sib == nullptr) { + logger.error("Couldn't allocate PDU in %s().", __FUNCTION__); + return SRSRAN_ERROR; + } asn1::bit_ref bref(sib->msg, sib->get_tailroom()); msg[msg_index].pack(bref); sib->N_bytes = bref.distance_bytes(); @@ -249,7 +263,9 @@ uint32_t rrc_nr::generate_sibs() log_rrc_message("SIB payload", Tx, sib_buffer.back().get(), msg[msg_index]); } - return sib_buffer.size() - 1; + nof_si_messages = sib_buffer.size() - 1; + + return SRSRAN_SUCCESS; } /******************************************************************************* diff --git a/srsenb/src/stack/rrc/rrc_ue.cc b/srsenb/src/stack/rrc/rrc_ue.cc index 63aa5d618..3007f5f8b 100644 --- a/srsenb/src/stack/rrc/rrc_ue.cc +++ b/srsenb/src/stack/rrc/rrc_ue.cc @@ -201,6 +201,10 @@ void rrc::ue::parse_ul_dcch(uint32_t lcid, srsran::unique_byte_buffer_t pdu) srsran::unique_byte_buffer_t original_pdu = std::move(pdu); pdu = srsran::make_byte_buffer(); + if (pdu == nullptr) { + parent->logger.error("Couldn't allocate PDU in %s().", __FUNCTION__); + return; + } transaction_id = 0; @@ -748,6 +752,10 @@ bool rrc::ue::handle_ue_cap_info(ue_cap_info_s* msg) if (eutra_capabilities_unpacked) { srsran::unique_byte_buffer_t pdu = srsran::make_byte_buffer(); + if (pdu == nullptr) { + parent->logger.error("Couldn't allocate PDU in %s().", __FUNCTION__); + return false; + } asn1::bit_ref bref2{pdu->msg, pdu->get_tailroom()}; msg->pack(bref2); asn1::rrc::ue_radio_access_cap_info_s ue_rat_caps; diff --git a/srsenb/test/rrc/rrc_nr_test.cc b/srsenb/test/rrc/rrc_nr_test.cc index 77e00d6c6..466b9b65f 100644 --- a/srsenb/test/rrc/rrc_nr_test.cc +++ b/srsenb/test/rrc/rrc_nr_test.cc @@ -47,7 +47,7 @@ int test_sib_generation() rrc_nr_cfg_t rrc_cfg = rrc_obj.update_default_cfg(default_cfg); auto& sched_elem = rrc_cfg.sib1.si_sched_info.sched_info_list[0]; - rrc_obj.init(rrc_cfg, nullptr, &mac_obj, &rlc_obj, &pdcp_obj, nullptr, nullptr); + TESTASSERT(rrc_obj.init(rrc_cfg, nullptr, &mac_obj, &rlc_obj, &pdcp_obj, nullptr, nullptr) == SRSRAN_SUCCESS); TESTASSERT(test_cell_cfg(mac_obj.cellcfgobj) == SRSRAN_SUCCESS); // TEMP tests @@ -73,7 +73,7 @@ int test_rrc_setup() // set cfg rrc_nr_cfg_t default_cfg = {}; rrc_nr_cfg_t rrc_cfg = rrc_obj.update_default_cfg(default_cfg); - rrc_obj.init(rrc_cfg, nullptr, &mac_obj, &rlc_obj, &pdcp_obj, nullptr, nullptr); + TESTASSERT(rrc_obj.init(rrc_cfg, nullptr, &mac_obj, &rlc_obj, &pdcp_obj, nullptr, nullptr) == SRSRAN_SUCCESS); for (uint32_t n = 0; n < 2; ++n) { uint32_t timeout = 5500; @@ -92,5 +92,5 @@ int main() TESTASSERT(srsenb::test_sib_generation() == SRSRAN_SUCCESS); TESTASSERT(srsenb::test_rrc_setup() == SRSRAN_SUCCESS); - return 0; + return SRSRAN_SUCCESS; } diff --git a/srsepc/src/mbms-gw/mbms-gw.cc b/srsepc/src/mbms-gw/mbms-gw.cc index ee618f2e1..9cbe182b0 100644 --- a/srsepc/src/mbms-gw/mbms-gw.cc +++ b/srsepc/src/mbms-gw/mbms-gw.cc @@ -229,6 +229,10 @@ void mbms_gw::run_thread() // Mark the thread as running m_running = true; srsran::unique_byte_buffer_t msg = srsran::make_byte_buffer(); + if (msg == nullptr) { + m_logger.error("Couldn't allocate PDU in %s().", __FUNCTION__); + return; + } uint8_t seq = 0; while (m_running) { diff --git a/srsepc/src/mme/mme.cc b/srsepc/src/mme/mme.cc index 752a26536..f6245f4f4 100644 --- a/srsepc/src/mme/mme.cc +++ b/srsepc/src/mme/mme.cc @@ -89,6 +89,10 @@ void mme::stop() void mme::run_thread() { srsran::unique_byte_buffer_t pdu = srsran::make_byte_buffer("mme::run_thread"); + if (pdu == nullptr) { + m_s1ap_logger.error("Couldn't allocate PDU in %s().", __FUNCTION__); + return; + } uint32_t sz = SRSRAN_MAX_BUFFER_SIZE_BYTES - SRSRAN_BUFFER_HEADER_OFFSET; struct sockaddr_in enb_addr; diff --git a/srsue/hdr/stack/mac_nr/mux_nr.h b/srsue/hdr/stack/mac_nr/mux_nr.h index 1579a25c6..3c80add9c 100644 --- a/srsue/hdr/stack/mac_nr/mux_nr.h +++ b/srsue/hdr/stack/mac_nr/mux_nr.h @@ -25,7 +25,7 @@ public: explicit mux_nr(srslog::basic_logger& logger); ~mux_nr(){}; void reset(); - void init(); + int32_t init(); void step(); diff --git a/srsue/src/phy/nr/cc_worker.cc b/srsue/src/phy/nr/cc_worker.cc index bd7f03222..685cf7055 100644 --- a/srsue/src/phy/nr/cc_worker.cc +++ b/srsue/src/phy/nr/cc_worker.cc @@ -217,6 +217,10 @@ bool cc_worker::work_dl() if (phy->get_dl_pending_grant(dl_slot_cfg.idx, pdsch_cfg, ack_resource, pid)) { // Get data buffer srsran::unique_byte_buffer_t data = srsran::make_byte_buffer(); + if (data == nullptr) { + logger.error("Couldn't allocate PDU in %s().", __FUNCTION__); + return false; + } data->N_bytes = pdsch_cfg.grant.tb[0].tbs / 8U; // Get soft-buffer from MAC diff --git a/srsue/src/stack/mac_nr/mac_nr.cc b/srsue/src/stack/mac_nr/mac_nr.cc index 78c28978d..e28ea60ab 100644 --- a/srsue/src/stack/mac_nr/mac_nr.cc +++ b/srsue/src/stack/mac_nr/mac_nr.cc @@ -19,8 +19,6 @@ namespace srsue { mac_nr::mac_nr(srsran::ext_task_sched_handle task_sched_) : task_sched(task_sched_), logger(srslog::fetch_basic_logger("MAC")), proc_ra(logger), mux(logger), pcap(nullptr) { - tx_buffer = srsran::make_byte_buffer(); - rlc_buffer = srsran::make_byte_buffer(); } mac_nr::~mac_nr() @@ -39,7 +37,10 @@ int mac_nr::init(const mac_nr_args_t& args_, phy_interface_mac_nr* phy_, rlc_int proc_ra.init(phy, this, &task_sched); - mux.init(); + if (mux.init() != SRSRAN_SUCCESS) { + logger.error("Couldn't initialize mux unit."); + return SRSRAN_ERROR; + } if (srsran_softbuffer_tx_init_guru(&softbuffer_tx, SRSRAN_SCH_NR_MAX_NOF_CB_LDPC, SRSRAN_LDPC_MAX_LEN_ENCODED_CB) < SRSRAN_SUCCESS) { @@ -47,6 +48,15 @@ int mac_nr::init(const mac_nr_args_t& args_, phy_interface_mac_nr* phy_, rlc_int return SRSRAN_ERROR; } + tx_buffer = srsran::make_byte_buffer(); + if (tx_buffer == nullptr) { + return SRSRAN_ERROR; + } + rlc_buffer = srsran::make_byte_buffer(); + if (rlc_buffer == nullptr) { + return SRSRAN_ERROR; + } + started = true; return SRSRAN_SUCCESS; diff --git a/srsue/src/stack/mac_nr/mux_nr.cc b/srsue/src/stack/mac_nr/mux_nr.cc index 5cb082091..f9225f394 100644 --- a/srsue/src/stack/mac_nr/mux_nr.cc +++ b/srsue/src/stack/mac_nr/mux_nr.cc @@ -15,12 +15,17 @@ namespace srsue { -mux_nr::mux_nr(srslog::basic_logger& logger_) : logger(logger_) +mux_nr::mux_nr(srslog::basic_logger& logger_) : logger(logger_){}; + +int32_t mux_nr::init() { msg3_buff = srsran::make_byte_buffer(); -}; + if (msg3_buff == nullptr) { + return SRSRAN_ERROR; + } -void mux_nr::init() {} + return SRSRAN_SUCCESS; +} void mux_nr::msg3_flush() { diff --git a/srsue/src/stack/rrc/rrc.cc b/srsue/src/stack/rrc/rrc.cc index e8d481ba2..a802ffd27 100644 --- a/srsue/src/stack/rrc/rrc.cc +++ b/srsue/src/stack/rrc/rrc.cc @@ -1533,8 +1533,8 @@ void rrc::send_ul_ccch_msg(const ul_ccch_msg_s& msg) { // Reset and reuse sdu buffer if provided unique_byte_buffer_t pdcp_buf = srsran::make_byte_buffer(); - if (not pdcp_buf.get()) { - logger.error("Fatal Error: Couldn't allocate PDU in byte_align_and_pack()."); + if (pdcp_buf == nullptr) { + logger.error("Couldn't allocate PDU in %s().", __FUNCTION__); return; } @@ -1565,8 +1565,8 @@ void rrc::send_ul_dcch_msg(uint32_t lcid, const ul_dcch_msg_s& msg) { // Reset and reuse sdu buffer if provided unique_byte_buffer_t pdcp_buf = srsran::make_byte_buffer(); - if (not pdcp_buf.get()) { - logger.error("Fatal Error: Couldn't allocate PDU in byte_align_and_pack()."); + if (pdcp_buf == nullptr) { + logger.error("Couldn't allocate PDU in %s().", __FUNCTION__); return; } @@ -1681,8 +1681,8 @@ void rrc::parse_dl_dcch(uint32_t lcid, unique_byte_buffer_t pdu) switch (dl_dcch_msg.msg.c1().type().value) { case dl_dcch_msg_type_c::c1_c_::types::dl_info_transfer: pdu = srsran::make_byte_buffer(); - if (!pdu.get()) { - logger.error("Fatal error: out of buffers in pool"); + if (pdu == nullptr) { + logger.error("Couldn't allocate PDU in %s().", __FUNCTION__); return; } pdu->N_bytes = c1->dl_info_transfer().crit_exts.c1().dl_info_transfer_r8().ded_info_type.ded_info_nas().size(); diff --git a/srsue/src/stack/rrc/rrc_procedures.cc b/srsue/src/stack/rrc/rrc_procedures.cc index 6bb796f15..cf9af1557 100644 --- a/srsue/src/stack/rrc/rrc_procedures.cc +++ b/srsue/src/stack/rrc/rrc_procedures.cc @@ -1033,12 +1033,12 @@ srsran::proc_outcome_t rrc::connection_reconf_no_ho_proc::react(const bool& conf srsran::unique_byte_buffer_t nas_pdu; for (auto& pdu : rx_recfg.ded_info_nas_list) { nas_pdu = srsran::make_byte_buffer(); - if (nas_pdu.get()) { + if (nas_pdu != nullptr) { memcpy(nas_pdu->msg, pdu.data(), pdu.size()); nas_pdu->N_bytes = pdu.size(); rrc_ptr->nas->write_pdu(RB_ID_SRB1, std::move(nas_pdu)); } else { - rrc_ptr->logger.error("Fatal Error: Couldn't allocate PDU in %s.", __FUNCTION__); + rrc_ptr->logger.error("Couldn't allocate PDU in %s.", __FUNCTION__); return proc_outcome_t::error; } } diff --git a/srsue/src/stack/upper/gw.cc b/srsue/src/stack/upper/gw.cc index 3cd957e08..05b453cac 100644 --- a/srsue/src/stack/upper/gw.cc +++ b/srsue/src/stack/upper/gw.cc @@ -247,7 +247,7 @@ void gw::run_thread() srsran::unique_byte_buffer_t pdu = srsran::make_byte_buffer(); if (!pdu) { - logger.error("Fatal Error: Couldn't allocate PDU in run_thread()."); + logger.error("Couldn't allocate PDU in %s().", __FUNCTION__); return; } diff --git a/srsue/src/stack/upper/nas.cc b/srsue/src/stack/upper/nas.cc index 4daf95f69..153aa6398 100644 --- a/srsue/src/stack/upper/nas.cc +++ b/srsue/src/stack/upper/nas.cc @@ -317,7 +317,7 @@ void nas::start_attach_request(srsran::establishment_cause_t cause_) // Start attach request unique_byte_buffer_t msg = srsran::make_byte_buffer(); if (msg == nullptr) { - logger.warning("Couldn't allocate buffer for Attach request.\n"); + logger.error("Couldn't allocate PDU in %s().", __FUNCTION__); return; } @@ -359,6 +359,10 @@ void nas::start_service_request(srsran::establishment_cause_t cause_) // Start service request unique_byte_buffer_t msg = srsran::make_byte_buffer(); + if (msg == nullptr) { + logger.error("Couldn't allocate PDU in %s().", __FUNCTION__); + return; + } gen_service_request(msg); if (not rrc->connection_request(cause_, std::move(msg))) { logger.error("Error starting RRC connection"); @@ -1857,7 +1861,7 @@ void nas::send_security_mode_reject(uint8_t cause) { unique_byte_buffer_t msg = srsran::make_byte_buffer(); if (!msg) { - logger.error("Fatal Error: Couldn't allocate PDU in send_security_mode_reject()."); + logger.error("Couldn't allocate PDU in %s().", __FUNCTION__); return; } @@ -1878,7 +1882,7 @@ void nas::send_attach_request() { unique_byte_buffer_t pdu = srsran::make_byte_buffer(); if (!pdu) { - logger.error("Fatal Error: Couldn't allocate PDU in %s().", __FUNCTION__); + logger.error("Couldn't allocate PDU in %s().", __FUNCTION__); return; } gen_attach_request(pdu); @@ -1889,7 +1893,7 @@ void nas::send_detach_request(bool switch_off) { unique_byte_buffer_t pdu = srsran::make_byte_buffer(); if (!pdu) { - logger.error("Fatal Error: Couldn't allocate PDU in %s().", __FUNCTION__); + logger.error("Couldn't allocate PDU in %s().", __FUNCTION__); return; } @@ -1969,6 +1973,10 @@ void nas::send_attach_complete(const uint8_t& transaction_id_, const uint8_t& ep // Pack entire message unique_byte_buffer_t pdu = srsran::make_byte_buffer(); + if (pdu == nullptr) { + logger.error("Couldn't allocate PDU in %s().", __FUNCTION__); + return; + } liblte_mme_pack_attach_complete_msg( &attach_complete, current_sec_hdr, ctxt.tx_count, (LIBLTE_BYTE_MSG_STRUCT*)pdu.get()); // Write NAS pcap @@ -1993,7 +2001,7 @@ void nas::send_detach_accept() { unique_byte_buffer_t pdu = srsran::make_byte_buffer(); if (!pdu) { - logger.error("Fatal Error: Couldn't allocate PDU in %s().", __FUNCTION__); + logger.error("Couldn't allocate PDU in %s().", __FUNCTION__); return; } @@ -2018,7 +2026,7 @@ void nas::send_authentication_response(const uint8_t* res, const size_t res_len) { unique_byte_buffer_t pdu = srsran::make_byte_buffer(); if (!pdu) { - logger.error("Fatal Error: Couldn't allocate PDU in send_authentication_response()."); + logger.error("Couldn't allocate PDU in %s().", __FUNCTION__); return; } @@ -2049,7 +2057,7 @@ void nas::send_authentication_failure(const uint8_t cause, const uint8_t* auth_f { unique_byte_buffer_t msg = srsran::make_byte_buffer(); if (!msg) { - logger.error("Fatal Error: Couldn't allocate PDU in send_authentication_failure()."); + logger.error("Couldn't allocate PDU in %s().", __FUNCTION__); return; } @@ -2097,7 +2105,7 @@ void nas::send_identity_response(const uint8 id_type) unique_byte_buffer_t pdu = srsran::make_byte_buffer(); if (!pdu) { - logger.error("Fatal Error: Couldn't allocate PDU in send_identity_response()."); + logger.error("Couldn't allocate PDU in %s().", __FUNCTION__); return; } @@ -2121,7 +2129,7 @@ void nas::send_service_request() { unique_byte_buffer_t msg = srsran::make_byte_buffer(); if (!msg) { - logger.error("Fatal Error: Couldn't allocate PDU in send_service_request()."); + logger.error("Couldn't allocate PDU in %s().", __FUNCTION__); return; } @@ -2240,8 +2248,8 @@ void nas::send_esm_information_response(const uint8 proc_transaction_id) } unique_byte_buffer_t pdu = srsran::make_byte_buffer(); - if (!pdu) { - logger.error("Fatal Error: Couldn't allocate PDU in %s.", __FUNCTION__); + if (pdu == nullptr) { + logger.error("Couldn't allocate PDU in %s().", __FUNCTION__); return; } @@ -2271,6 +2279,10 @@ void nas::send_activate_dedicated_eps_bearer_context_accept(const uint8_t& proc_ const uint8_t& eps_bearer_id) { unique_byte_buffer_t pdu = srsran::make_byte_buffer(); + if (pdu == nullptr) { + logger.error("Couldn't allocate PDU in %s().", __FUNCTION__); + return; + } LIBLTE_MME_ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_ACCEPT_MSG_STRUCT accept = {}; @@ -2305,6 +2317,10 @@ void nas::send_activate_dedicated_eps_bearer_context_accept(const uint8_t& proc_ void nas::send_deactivate_eps_bearer_context_accept(const uint8_t& proc_transaction_id, const uint8_t& eps_bearer_id) { unique_byte_buffer_t pdu = srsran::make_byte_buffer(); + if (pdu == nullptr) { + logger.error("Couldn't allocate PDU in %s().", __FUNCTION__); + return; + } LIBLTE_MME_DEACTIVATE_EPS_BEARER_CONTEXT_ACCEPT_MSG_STRUCT accept = {}; @@ -2339,6 +2355,10 @@ void nas::send_deactivate_eps_bearer_context_accept(const uint8_t& proc_transact void nas::send_modify_eps_bearer_context_accept(const uint8_t& proc_transaction_id, const uint8_t& eps_bearer_id) { unique_byte_buffer_t pdu = srsran::make_byte_buffer(); + if (pdu == nullptr) { + logger.error("Couldn't allocate PDU in %s().", __FUNCTION__); + return; + } LIBLTE_MME_MODIFY_EPS_BEARER_CONTEXT_ACCEPT_MSG_STRUCT accept = {}; @@ -2373,6 +2393,10 @@ void nas::send_modify_eps_bearer_context_accept(const uint8_t& proc_transaction_ void nas::send_activate_test_mode_complete() { unique_byte_buffer_t pdu = srsran::make_byte_buffer(); + if (pdu == nullptr) { + logger.error("Couldn't allocate PDU in %s().", __FUNCTION__); + return; + } if (liblte_mme_pack_activate_test_mode_complete_msg( (LIBLTE_BYTE_MSG_STRUCT*)pdu.get(), current_sec_hdr, ctxt.tx_count)) { @@ -2398,6 +2422,10 @@ void nas::send_activate_test_mode_complete() void nas::send_close_ue_test_loop_complete() { unique_byte_buffer_t pdu = srsran::make_byte_buffer(); + if (pdu == nullptr) { + logger.error("Couldn't allocate PDU in %s().", __FUNCTION__); + return; + } if (liblte_mme_pack_close_ue_test_loop_complete_msg( (LIBLTE_BYTE_MSG_STRUCT*)pdu.get(), current_sec_hdr, ctxt.tx_count)) { diff --git a/srsue/test/mac_nr/proc_ra_nr_test.cc b/srsue/test/mac_nr/proc_ra_nr_test.cc index 1f663afaf..4f734b8eb 100644 --- a/srsue/test/mac_nr/proc_ra_nr_test.cc +++ b/srsue/test/mac_nr/proc_ra_nr_test.cc @@ -123,6 +123,7 @@ int main() grant.pid = 0x0123; uint8_t mac_dl_rar_pdu[] = {0x40, 0x06, 0x68, 0x03, 0x21, 0x46, 0x46, 0x02, 0x00, 0x00, 0x00}; grant.tb[0] = srsran::make_byte_buffer(); + TESTASSERT(grant.tb[0] != nullptr); grant.tb[0].get()->append_bytes(mac_dl_rar_pdu, sizeof(mac_dl_rar_pdu)); proc_ra_nr.handle_rar_pdu(grant); diff --git a/srsue/test/ttcn3/hdr/ttcn3_drb_interface.h b/srsue/test/ttcn3/hdr/ttcn3_drb_interface.h index b0624fee4..569bbe97f 100644 --- a/srsue/test/ttcn3/hdr/ttcn3_drb_interface.h +++ b/srsue/test/ttcn3/hdr/ttcn3_drb_interface.h @@ -120,6 +120,10 @@ private: // pack into byte buffer unique_byte_buffer_t pdu = srsran::make_byte_buffer(); + if (pdu == nullptr) { + logger.error("Couldn't allocate buffer in %s().", __FUNCTION__); + return; + } pdu->N_bytes = len; memcpy(pdu->msg, payload, pdu->N_bytes); diff --git a/srsue/test/ttcn3/hdr/ttcn3_srb_interface.h b/srsue/test/ttcn3/hdr/ttcn3_srb_interface.h index 16c70c8ab..6c4d92248 100644 --- a/srsue/test/ttcn3/hdr/ttcn3_srb_interface.h +++ b/srsue/test/ttcn3/hdr/ttcn3_srb_interface.h @@ -109,6 +109,10 @@ private: // pack into byte buffer unique_byte_buffer_t pdu = srsran::make_byte_buffer(); + if (pdu == nullptr) { + logger.error("Couldn't allocate buffer in %s().", __FUNCTION__); + return; + } pdu->N_bytes = len; memcpy(pdu->msg, payload, pdu->N_bytes); @@ -129,6 +133,10 @@ private: // pack into byte buffer unique_byte_buffer_t pdu = srsran::make_byte_buffer(); + if (pdu == nullptr) { + logger.error("Couldn't allocate buffer in %s().", __FUNCTION__); + return; + } pdu->N_bytes = len; memcpy(pdu->msg, payload, pdu->N_bytes); @@ -154,9 +162,6 @@ private: ss_srb_interface* syssim = nullptr; byte_buffer_pool* pool = nullptr; - - // struct sctp_sndrcvinfo sri = {}; - // struct sockaddr_in client_addr; }; #endif // SRSUE_TTCN3_SRB_INTERFACE_H diff --git a/srsue/test/ttcn3/hdr/ttcn3_sys_interface.h b/srsue/test/ttcn3/hdr/ttcn3_sys_interface.h index f7ea84bfc..d442d8666 100644 --- a/srsue/test/ttcn3/hdr/ttcn3_sys_interface.h +++ b/srsue/test/ttcn3/hdr/ttcn3_sys_interface.h @@ -194,6 +194,10 @@ private: payload_ptr += 2; unique_byte_buffer_t sib = srsran::make_byte_buffer(); + if (sib == nullptr) { + logger.error("Couldn't allocate buffer in %s().", __FUNCTION__); + return; + } memcpy(sib->msg, payload_ptr, tb_len); payload_ptr += tb_len; sib->N_bytes = tb_len; @@ -695,6 +699,10 @@ private: payload_ptr += 2; unique_byte_buffer_t pch = srsran::make_byte_buffer(); + if (pch == nullptr) { + logger.error("Couldn't allocate buffer in %s().", __FUNCTION__); + return; + } memcpy(pch->msg, payload_ptr, tb_len); payload_ptr += tb_len; pch->N_bytes = tb_len; diff --git a/srsue/test/upper/nas_test.cc b/srsue/test/upper/nas_test.cc index c4b6634e1..9256e2113 100644 --- a/srsue/test/upper/nas_test.cc +++ b/srsue/test/upper/nas_test.cc @@ -226,6 +226,7 @@ int security_command_test() // push auth request PDU to NAS to generate security context byte_buffer_pool* pool = byte_buffer_pool::get_instance(); unique_byte_buffer_t tmp = srsran::make_byte_buffer(); + TESTASSERT(tmp != nullptr); memcpy(tmp->msg, auth_request_pdu, sizeof(auth_request_pdu)); tmp->N_bytes = sizeof(auth_request_pdu); nas.write_pdu(LCID, std::move(tmp)); @@ -235,6 +236,7 @@ int security_command_test() // reuse buffer for security mode command tmp = srsran::make_byte_buffer(); + TESTASSERT(tmp != nullptr); memcpy(tmp->msg, sec_mode_command_pdu, sizeof(sec_mode_command_pdu)); tmp->N_bytes = sizeof(sec_mode_command_pdu); nas.write_pdu(LCID, std::move(tmp)); @@ -296,6 +298,7 @@ int mme_attach_request_test() // finally push attach accept byte_buffer_pool* pool = byte_buffer_pool::get_instance(); unique_byte_buffer_t tmp = srsran::make_byte_buffer(); + TESTASSERT(tmp != nullptr); memcpy(tmp->msg, attach_accept_pdu, sizeof(attach_accept_pdu)); tmp->N_bytes = sizeof(attach_accept_pdu); nas.write_pdu(LCID, std::move(tmp)); @@ -345,6 +348,7 @@ int esm_info_request_test() // push ESM info request PDU to NAS to generate response unique_byte_buffer_t tmp = srsran::make_byte_buffer(); + TESTASSERT(tmp != nullptr); memcpy(tmp->msg, esm_info_req_pdu, sizeof(esm_info_req_pdu)); tmp->N_bytes = sizeof(esm_info_req_pdu); nas.write_pdu(LCID, std::move(tmp)); @@ -383,6 +387,7 @@ int dedicated_eps_bearer_test() // push dedicated EPS bearer PDU to NAS unique_byte_buffer_t tmp = srsran::make_byte_buffer(); + TESTASSERT(tmp != nullptr); memcpy(tmp->msg, activate_dedicated_eps_bearer_pdu, sizeof(activate_dedicated_eps_bearer_pdu)); tmp->N_bytes = sizeof(activate_dedicated_eps_bearer_pdu); nas.write_pdu(LCID, std::move(tmp)); @@ -394,6 +399,7 @@ int dedicated_eps_bearer_test() // add default EPS beaerer unique_byte_buffer_t attach_with_default_bearer = srsran::make_byte_buffer(); + TESTASSERT(attach_with_default_bearer != nullptr); memcpy(attach_with_default_bearer->msg, attach_accept_pdu, sizeof(attach_accept_pdu)); attach_with_default_bearer->N_bytes = sizeof(attach_accept_pdu); nas.write_pdu(LCID, std::move(attach_with_default_bearer)); @@ -404,6 +410,7 @@ int dedicated_eps_bearer_test() // push dedicated bearer activation and check that it was added tmp = srsran::make_byte_buffer(); + TESTASSERT(tmp != nullptr); memcpy(tmp->msg, activate_dedicated_eps_bearer_pdu, sizeof(activate_dedicated_eps_bearer_pdu)); tmp->N_bytes = sizeof(activate_dedicated_eps_bearer_pdu); nas.write_pdu(LCID, std::move(tmp)); @@ -412,6 +419,7 @@ int dedicated_eps_bearer_test() // tear-down dedicated bearer tmp = srsran::make_byte_buffer(); + TESTASSERT(tmp != nullptr); memcpy(tmp->msg, deactivate_eps_bearer_pdu, sizeof(deactivate_eps_bearer_pdu)); tmp->N_bytes = sizeof(deactivate_eps_bearer_pdu); nas.write_pdu(LCID, std::move(tmp)); @@ -420,6 +428,7 @@ int dedicated_eps_bearer_test() // try to tear-down dedicated bearer again tmp = srsran::make_byte_buffer(); + TESTASSERT(tmp != nullptr); memcpy(tmp->msg, deactivate_eps_bearer_pdu, sizeof(deactivate_eps_bearer_pdu)); tmp->N_bytes = sizeof(deactivate_eps_bearer_pdu); nas.write_pdu(LCID, std::move(tmp)); diff --git a/srsue/test/upper/rrc_meas_test.cc b/srsue/test/upper/rrc_meas_test.cc index 3c150fdf2..3bc02e360 100644 --- a/srsue/test/upper/rrc_meas_test.cc +++ b/srsue/test/upper/rrc_meas_test.cc @@ -135,6 +135,9 @@ public: } pdu = srsran::make_byte_buffer(); + if (pdu == nullptr) { + return; + } asn1::bit_ref bref(pdu->msg, pdu->get_tailroom()); dlsch_msg.pack(bref); pdu->N_bytes = bref.distance_bytes(); @@ -299,6 +302,9 @@ public: void send_ccch_msg(dl_ccch_msg_s& dl_ccch_msg) { srsran::unique_byte_buffer_t pdu = srsran::make_byte_buffer(); + if (pdu == nullptr) { + return; + } asn1::bit_ref bref(pdu->msg, pdu->get_tailroom()); dl_ccch_msg.pack(bref); @@ -311,7 +317,9 @@ public: void send_dcch_msg(dl_dcch_msg_s& dl_dcch_msg) { srsran::unique_byte_buffer_t pdu = srsran::make_byte_buffer(); - ; + if (pdu == nullptr) { + return; + } asn1::bit_ref bref(pdu->msg, pdu->get_tailroom()); dl_dcch_msg.pack(bref); bref.align_bytes_zero(); diff --git a/srsue/test/upper/tft_test.cc b/srsue/test/upper/tft_test.cc index 1bcc7b28b..9b1ae415a 100644 --- a/srsue/test/upper/tft_test.cc +++ b/srsue/test/upper/tft_test.cc @@ -106,10 +106,15 @@ int tft_filter_test_ipv6_combined() srslog::basic_logger& logger = srslog::fetch_basic_logger("TFT"); srsran::unique_byte_buffer_t ip_msg1, ip_msg2, ip_msg3, ip_msg4, ip_msg5; ip_msg1 = make_byte_buffer(); + TESTASSERT(ip_msg1 != nullptr); ip_msg2 = make_byte_buffer(); + TESTASSERT(ip_msg2 != nullptr); ip_msg3 = make_byte_buffer(); + TESTASSERT(ip_msg3 != nullptr); ip_msg4 = make_byte_buffer(); + TESTASSERT(ip_msg4 != nullptr); ip_msg5 = make_byte_buffer(); + TESTASSERT(ip_msg5 != nullptr); // Set IP test message ip_msg1->N_bytes = sizeof(ipv6_matched_packet); @@ -164,7 +169,9 @@ int tft_filter_test_single_local_port() srsran::unique_byte_buffer_t ip_msg1, ip_msg2; ip_msg1 = make_byte_buffer(); + TESTASSERT(ip_msg1 != nullptr); ip_msg2 = make_byte_buffer(); + TESTASSERT(ip_msg2 != nullptr); // Filter length: 3 bytes // Filter type: Single local port @@ -208,7 +215,9 @@ int tft_filter_test_single_remote_port() srsran::unique_byte_buffer_t ip_msg1, ip_msg2; ip_msg1 = make_byte_buffer(); + TESTASSERT(ip_msg1 != nullptr); ip_msg2 = make_byte_buffer(); + TESTASSERT(ip_msg2 != nullptr); // Filter length: 3 bytes // Filter type: Single remote port @@ -252,7 +261,9 @@ int tft_filter_test_ipv4_local_addr() srsran::unique_byte_buffer_t ip_msg1, ip_msg2; ip_msg1 = make_byte_buffer(); + TESTASSERT(ip_msg1 != nullptr); ip_msg2 = make_byte_buffer(); + TESTASSERT(ip_msg2 != nullptr); // Filter length: 9 bytes // Filter type: IPv4 local address @@ -299,7 +310,9 @@ int tft_filter_test_ipv4_remote_addr() srsran::unique_byte_buffer_t ip_msg1, ip_msg2; ip_msg1 = make_byte_buffer(); + TESTASSERT(ip_msg1 != nullptr); ip_msg2 = make_byte_buffer(); + TESTASSERT(ip_msg2 != nullptr); // Filter length: 5 bytes // Filter type: IPv4 local address @@ -345,7 +358,9 @@ int tft_filter_test_ipv4_tos() srsran::unique_byte_buffer_t ip_msg1, ip_msg2; ip_msg1 = make_byte_buffer(); + TESTASSERT(ip_msg1 != nullptr); ip_msg2 = make_byte_buffer(); + TESTASSERT(ip_msg2 != nullptr); // Filter length: 3 bytes // Filter type: Type of service From e8395c74741bd2fd5fe448381f5687d92ffc3b05 Mon Sep 17 00:00:00 2001 From: faluco Date: Mon, 22 Mar 2021 10:46:32 +0100 Subject: [PATCH 15/48] - Implement a pool to store dyn arg store objects in srslog to avoid allocations when passing arguments to the backend. - Use string views inside the log formatters to avoid allocations. - Avoid a std::string when using fmt::vsprintf, instead favour fmt::vprintf. --- .../srsran/srslog/detail/log_backend.h | 5 + .../srsran/srslog/detail/log_entry_metadata.h | 16 +- .../srslog/detail/support/backend_capacity.h | 21 ++ .../detail/support/dyn_arg_store_pool.h | 78 +++++++ .../srsran/srslog/detail/support/work_queue.h | 9 +- lib/include/srsran/srslog/formatter.h | 88 +++----- lib/include/srsran/srslog/log_channel.h | 191 +++++++++--------- lib/src/srslog/backend_worker.cpp | 6 + lib/src/srslog/backend_worker.h | 25 ++- lib/src/srslog/formatters/json_formatter.cpp | 82 ++++---- lib/src/srslog/formatters/json_formatter.h | 49 ++--- lib/src/srslog/formatters/text_formatter.cpp | 99 +++++---- lib/src/srslog/formatters/text_formatter.h | 56 +++-- lib/src/srslog/log_backend_impl.h | 17 +- lib/src/srslog/srslog.cpp | 1 + lib/test/srslog/event_trace_test.cpp | 21 +- lib/test/srslog/json_formatter_test.cpp | 89 ++++---- lib/test/srslog/log_backend_test.cpp | 62 +++--- lib/test/srslog/log_channel_test.cpp | 96 ++++----- lib/test/srslog/test_dummies.h | 55 ++--- lib/test/srslog/text_formatter_test.cpp | 153 ++++++-------- 21 files changed, 593 insertions(+), 626 deletions(-) create mode 100644 lib/include/srsran/srslog/detail/support/backend_capacity.h create mode 100644 lib/include/srsran/srslog/detail/support/dyn_arg_store_pool.h diff --git a/lib/include/srsran/srslog/detail/log_backend.h b/lib/include/srsran/srslog/detail/log_backend.h index b4332d49f..d1765b498 100644 --- a/lib/include/srsran/srslog/detail/log_backend.h +++ b/lib/include/srsran/srslog/detail/log_backend.h @@ -13,6 +13,8 @@ #ifndef SRSLOG_DETAIL_LOG_BACKEND_H #define SRSLOG_DETAIL_LOG_BACKEND_H +#include "srsran/srslog/bundled/fmt/printf.h" + namespace srslog { namespace detail { @@ -31,6 +33,9 @@ public: /// NOTE: Calling this function more than once has no side effects. virtual void start() = 0; + /// Allocates a dyn_arg_store and returns a pointer to it on success, otherwise returns nullptr. + virtual fmt::dynamic_format_arg_store* alloc_arg_store() = 0; + /// Pushes a log entry into the backend. Returns true on success, otherwise /// false. virtual bool push(log_entry&& entry) = 0; diff --git a/lib/include/srsran/srslog/detail/log_entry_metadata.h b/lib/include/srsran/srslog/detail/log_entry_metadata.h index a2d50df3a..b33db0424 100644 --- a/lib/include/srsran/srslog/detail/log_entry_metadata.h +++ b/lib/include/srsran/srslog/detail/log_entry_metadata.h @@ -34,14 +34,14 @@ struct log_context { /// Metadata fields carried for each log entry. struct log_entry_metadata { - std::chrono::high_resolution_clock::time_point tp; - log_context context; - const char* fmtstring; - fmt::dynamic_format_arg_store store; - std::string log_name; - char log_tag; - small_str_buffer small_str; - std::vector hex_dump; + std::chrono::high_resolution_clock::time_point tp; + log_context context; + const char* fmtstring; + fmt::dynamic_format_arg_store* store; + std::string log_name; + char log_tag; + small_str_buffer small_str; + std::vector hex_dump; }; } // namespace detail diff --git a/lib/include/srsran/srslog/detail/support/backend_capacity.h b/lib/include/srsran/srslog/detail/support/backend_capacity.h new file mode 100644 index 000000000..21340d3a5 --- /dev/null +++ b/lib/include/srsran/srslog/detail/support/backend_capacity.h @@ -0,0 +1,21 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +#ifndef SRSLOG_DETAIL_SUPPORT_BACKEND_CAPACITY_H +#define SRSLOG_DETAIL_SUPPORT_BACKEND_CAPACITY_H + +/// Take this default value if users did not specify any custom size. +#ifndef SRSLOG_QUEUE_CAPACITY +#define SRSLOG_QUEUE_CAPACITY 8192 +#endif + +#endif // SRSLOG_DETAIL_SUPPORT_BACKEND_CAPACITY_H diff --git a/lib/include/srsran/srslog/detail/support/dyn_arg_store_pool.h b/lib/include/srsran/srslog/detail/support/dyn_arg_store_pool.h new file mode 100644 index 000000000..595181988 --- /dev/null +++ b/lib/include/srsran/srslog/detail/support/dyn_arg_store_pool.h @@ -0,0 +1,78 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +#ifndef SRSLOG_DETAIL_SUPPORT_DYN_ARG_STORE_POOL_H +#define SRSLOG_DETAIL_SUPPORT_DYN_ARG_STORE_POOL_H + +#include "srsran/srslog/bundled/fmt/printf.h" +#include "srsran/srslog/detail/support/backend_capacity.h" + +namespace srslog { + +namespace detail { + +/// Keeps a pool of dynamic_format_arg_store objects. The main reason for this class is that the arg store objects are +/// implemented with std::vectors, so we want to avoid allocating memory each time we create a new object. Instead, +/// reserve memory for each vector during initialization and recycle the objects. +class dyn_arg_store_pool +{ +public: + dyn_arg_store_pool() + { + pool.resize(SRSLOG_QUEUE_CAPACITY); + for (auto& elem : pool) { + // Reserve for 10 normal and 2 named arguments. + elem.reserve(10, 2); + } + free_list.reserve(SRSLOG_QUEUE_CAPACITY); + for (auto& elem : pool) { + free_list.push_back(&elem); + } + } + + /// Returns a pointer to a free dyn arg store object, otherwise returns nullptr. + fmt::dynamic_format_arg_store* alloc() + { + scoped_lock lock(m); + if (free_list.empty()) { + return nullptr; + } + + auto* p = free_list.back(); + free_list.pop_back(); + + return p; + } + + /// Deallocate the given dyn arg store object returning it to the pool. + void dealloc(fmt::dynamic_format_arg_store* p) + { + if (!p) { + return; + } + + scoped_lock lock(m); + p->clear(); + free_list.push_back(p); + } + +private: + std::vector > pool; + std::vector*> free_list; + mutable mutex m; +}; + +} // namespace detail + +} // namespace srslog + +#endif // SRSLOG_DETAIL_SUPPORT_DYN_ARG_STORE_POOL_H diff --git a/lib/include/srsran/srslog/detail/support/work_queue.h b/lib/include/srsran/srslog/detail/support/work_queue.h index b20a360bd..d1589f877 100644 --- a/lib/include/srsran/srslog/detail/support/work_queue.h +++ b/lib/include/srsran/srslog/detail/support/work_queue.h @@ -13,13 +13,10 @@ #ifndef SRSLOG_DETAIL_SUPPORT_WORK_QUEUE_H #define SRSLOG_DETAIL_SUPPORT_WORK_QUEUE_H +#include "srsran/srslog/detail/support/backend_capacity.h" #include "srsran/srslog/detail/support/thread_utils.h" #include -#ifndef SRSLOG_QUEUE_CAPACITY -#define SRSLOG_QUEUE_CAPACITY 8192 -#endif - namespace srslog { namespace detail { @@ -30,9 +27,9 @@ namespace detail { template class work_queue { - std::queue queue; + std::queue queue; mutable condition_variable cond_var; - static constexpr size_t threshold = capacity * 0.98; + static constexpr size_t threshold = capacity * 0.98; public: work_queue() = default; diff --git a/lib/include/srsran/srslog/formatter.h b/lib/include/srsran/srslog/formatter.h index be69c1730..3dcd85897 100644 --- a/lib/include/srsran/srslog/formatter.h +++ b/lib/include/srsran/srslog/formatter.h @@ -34,7 +34,7 @@ struct metric_value_formatter { /// Default metric value formatter. Users that want to override this behaviour /// should add an specialization of the metric they want to customize. template -struct metric_value_formatter> { +struct metric_value_formatter > { template void format(const T& v, fmt::memory_buffer& buffer) { @@ -59,54 +59,38 @@ public: virtual std::unique_ptr clone() const = 0; /// Formats the log entry into the input buffer. - virtual void format(detail::log_entry_metadata&& metadata, - fmt::memory_buffer& buffer) = 0; + virtual void format(detail::log_entry_metadata&& metadata, fmt::memory_buffer& buffer) = 0; /// Formats the context and log entry into the input buffer. template - void format_ctx(const srslog::context& ctx, - detail::log_entry_metadata&& metadata, - fmt::memory_buffer& buffer) + void format_ctx(const srslog::context& ctx, detail::log_entry_metadata&& metadata, fmt::memory_buffer& buffer) { format_context_begin(metadata, ctx.name(), sizeof...(Ts), buffer); - iterate_tuple(ctx.contents(), - 1, - buffer, - detail::make_index_sequence{}); + iterate_tuple(ctx.contents(), 1, buffer, detail::make_index_sequence{}); format_context_end(metadata, ctx.name(), buffer); } private: /// Processes all elements in a tuple. template - void iterate_tuple(const std::tuple& t, - unsigned level, - fmt::memory_buffer& buffer, - detail::index_sequence) + void + iterate_tuple(const std::tuple& t, unsigned level, fmt::memory_buffer& buffer, detail::index_sequence) { - (void)std::initializer_list{ - (process_element(std::get(t), level, buffer), 0)...}; + (void)std::initializer_list{(process_element(std::get(t), level, buffer), 0)...}; } /// Processes the input metric set. template - void process_element(const metric_set& ms, - unsigned level, - fmt::memory_buffer& buffer) + void process_element(const metric_set& ms, unsigned level, fmt::memory_buffer& buffer) { format_metric_set_begin(ms.name(), sizeof...(Ts), level, buffer); - iterate_tuple(ms.contents(), - level + 1, - buffer, - detail::make_index_sequence{}); + iterate_tuple(ms.contents(), level + 1, buffer, detail::make_index_sequence{}); format_metric_set_end(ms.name(), level, buffer); } /// Processes the input metric list. template - void process_element(const metric_list& list, - unsigned level, - fmt::memory_buffer& buffer) + void process_element(const metric_list& list, unsigned level, fmt::memory_buffer& buffer) { format_list_begin(list.name(), list.size(), level, buffer); for (const auto& elem : list) { @@ -117,16 +101,13 @@ private: /// Processes the input metric. template - void process_element(const metric& t, - unsigned level, - fmt::memory_buffer& buffer) + void process_element(const metric& t, unsigned level, fmt::memory_buffer& buffer) { fmt::memory_buffer value; - metric_value_formatter::type>{}.format( - t.value, value); + metric_value_formatter::type>{}.format(t.value, value); + value.push_back('\0'); - format_metric( - t.name(), fmt::to_string(value), t.units(), t.kind(), level, buffer); + format_metric(t.name(), value.data(), t.units(), t.kind(), level, buffer); } private: @@ -137,46 +118,37 @@ private: /// This callback gets called at the beginning of the context formatting /// algorithm. virtual void format_context_begin(const detail::log_entry_metadata& md, - const std::string& ctx_name, - unsigned size, - fmt::memory_buffer& buffer) = 0; + fmt::string_view ctx_name, + unsigned size, + fmt::memory_buffer& buffer) = 0; /// This callback gets called at the end of the context formatting algorithm. - virtual void format_context_end(const detail::log_entry_metadata& md, - const std::string& ctx_name, - fmt::memory_buffer& buffer) = 0; + virtual void + format_context_end(const detail::log_entry_metadata& md, fmt::string_view ctx_name, fmt::memory_buffer& buffer) = 0; /// This callback gets called at the beginning of a metric set formatting /// procedure. - virtual void format_metric_set_begin(const std::string& set_name, - unsigned size, - unsigned level, - fmt::memory_buffer& buffer) = 0; + virtual void + format_metric_set_begin(fmt::string_view set_name, unsigned size, unsigned level, fmt::memory_buffer& buffer) = 0; /// This callback gets called at the beginning of a metric set formatting end. - virtual void format_metric_set_end(const std::string& set_name, - unsigned level, - fmt::memory_buffer& buffer) = 0; + virtual void format_metric_set_end(fmt::string_view set_name, unsigned level, fmt::memory_buffer& buffer) = 0; /// This callback gets called at the beginning of a metric list formatting /// procedure. - virtual void format_list_begin(const std::string& list_name, - unsigned size, - unsigned level, - fmt::memory_buffer& buffer) = 0; + virtual void + format_list_begin(fmt::string_view list_name, unsigned size, unsigned level, fmt::memory_buffer& buffer) = 0; /// This callback gets called at the end of a metric list formatting /// procedure. - virtual void format_list_end(const std::string& list_name, - unsigned level, - fmt::memory_buffer& buffer) = 0; + virtual void format_list_end(fmt::string_view list_name, unsigned level, fmt::memory_buffer& buffer) = 0; /// This callback gets called for each metric. - virtual void format_metric(const std::string& metric_name, - const std::string& metric_value, - const std::string& metric_units, - metric_kind kind, - unsigned level, + virtual void format_metric(fmt::string_view metric_name, + fmt::string_view metric_value, + fmt::string_view metric_units, + metric_kind kind, + unsigned level, fmt::memory_buffer& buffer) = 0; }; diff --git a/lib/include/srsran/srslog/log_channel.h b/lib/include/srsran/srslog/log_channel.h index 8fa0387d9..273debf67 100644 --- a/lib/include/srsran/srslog/log_channel.h +++ b/lib/include/srsran/srslog/log_channel.h @@ -47,14 +47,9 @@ struct log_channel_config { class log_channel { public: - log_channel(std::string id, sink& s, detail::log_backend& backend) : - log_channel(std::move(id), s, backend, {}) - {} + log_channel(std::string id, sink& s, detail::log_backend& backend) : log_channel(std::move(id), s, backend, {}) {} - log_channel(std::string id, - sink& s, - detail::log_backend& backend, - log_channel_config config) : + log_channel(std::string id, sink& s, detail::log_backend& backend, log_channel_config config) : log_id(std::move(id)), log_sink(s), backend(backend), @@ -96,91 +91,87 @@ public: } // Populate the store with all incoming arguments. - fmt::dynamic_format_arg_store store; - (void)std::initializer_list{ - (store.push_back(std::forward(args)), 0)...}; + auto* store = backend.alloc_arg_store(); + if (!store) { + return; + } + (void)std::initializer_list{(store->push_back(std::forward(args)), 0)...}; // Send the log entry to the backend. - log_formatter& formatter = log_sink.get_formatter(); - detail::log_entry entry = { - &log_sink, - [&formatter](detail::log_entry_metadata&& metadata, - fmt::memory_buffer& buffer) { - formatter.format(std::move(metadata), buffer); - }, - {std::chrono::high_resolution_clock::now(), - {ctx_value, should_print_context}, - fmtstr, - std::move(store), - log_name, - log_tag, - small_str_buffer()}}; + log_formatter& formatter = log_sink.get_formatter(); + detail::log_entry entry = {&log_sink, + [&formatter](detail::log_entry_metadata&& metadata, fmt::memory_buffer& buffer) { + formatter.format(std::move(metadata), buffer); + }, + {std::chrono::high_resolution_clock::now(), + {ctx_value, should_print_context}, + fmtstr, + store, + log_name, + log_tag, + small_str_buffer()}}; backend.push(std::move(entry)); } /// Builds the provided log entry and passes it to the backend. When the /// channel is disabled the log entry will be discarded. - void operator()(small_str_buffer &&str) + void operator()(small_str_buffer&& str) { if (!enabled()) { return; } // Send the log entry to the backend. - log_formatter& formatter = log_sink.get_formatter(); - detail::log_entry entry = { - &log_sink, - [&formatter](detail::log_entry_metadata&& metadata, - fmt::memory_buffer& buffer) { - formatter.format(std::move(metadata), buffer); - }, - {std::chrono::high_resolution_clock::now(), - {ctx_value, should_print_context}, - nullptr, - {}, - log_name, - log_tag, - std::move(str)}}; + log_formatter& formatter = log_sink.get_formatter(); + detail::log_entry entry = {&log_sink, + [&formatter](detail::log_entry_metadata&& metadata, fmt::memory_buffer& buffer) { + formatter.format(std::move(metadata), buffer); + }, + {std::chrono::high_resolution_clock::now(), + {ctx_value, should_print_context}, + nullptr, + nullptr, + log_name, + log_tag, + std::move(str)}}; backend.push(std::move(entry)); } /// Builds the provided log entry and passes it to the backend. When the /// channel is disabled the log entry will be discarded. template - void operator()(const uint8_t* buffer, - size_t len, - const char* fmtstr, - Args&&... args) + void operator()(const uint8_t* buffer, size_t len, const char* fmtstr, Args&&... args) { if (!enabled()) { return; } // Populate the store with all incoming arguments. - fmt::dynamic_format_arg_store store; - (void)std::initializer_list{ - (store.push_back(std::forward(args)), 0)...}; + auto* store = backend.alloc_arg_store(); + if (!store) { + return; + } + (void)std::initializer_list{(store->push_back(std::forward(args)), 0)...}; // Calculate the length to capture in the buffer. - if (hex_max_size >= 0) + if (hex_max_size >= 0) { len = std::min(len, hex_max_size); + } // Send the log entry to the backend. - log_formatter& formatter = log_sink.get_formatter(); - detail::log_entry entry = { - &log_sink, - [&formatter](detail::log_entry_metadata&& metadata, - fmt::memory_buffer& buffer) { - formatter.format(std::move(metadata), buffer); - }, - {std::chrono::high_resolution_clock::now(), - {ctx_value, should_print_context}, - fmtstr, - std::move(store), - log_name, - log_tag, - small_str_buffer(), - std::vector(buffer, buffer + len)}}; + log_formatter& formatter = log_sink.get_formatter(); + detail::log_entry entry = {&log_sink, + [&formatter](detail::log_entry_metadata&& metadata, fmt::memory_buffer& buffer) { + formatter.format(std::move(metadata), buffer); + }, + {std::chrono::high_resolution_clock::now(), + {ctx_value, should_print_context}, + fmtstr, + store, + log_name, + log_tag, + small_str_buffer(), + std::vector(buffer, buffer + len)}}; backend.push(std::move(entry)); } @@ -194,20 +185,18 @@ public: } // Send the log entry to the backend. - log_formatter& formatter = log_sink.get_formatter(); - detail::log_entry entry = { - &log_sink, - [&formatter, ctx](detail::log_entry_metadata&& metadata, - fmt::memory_buffer& buffer) { - formatter.format_ctx(ctx, std::move(metadata), buffer); - }, - {std::chrono::high_resolution_clock::now(), - {ctx_value, should_print_context}, - nullptr, - {}, - log_name, - log_tag, - small_str_buffer()}}; + log_formatter& formatter = log_sink.get_formatter(); + detail::log_entry entry = {&log_sink, + [&formatter, ctx](detail::log_entry_metadata&& metadata, fmt::memory_buffer& buffer) { + formatter.format_ctx(ctx, std::move(metadata), buffer); + }, + {std::chrono::high_resolution_clock::now(), + {ctx_value, should_print_context}, + nullptr, + nullptr, + log_name, + log_tag, + small_str_buffer()}}; backend.push(std::move(entry)); } @@ -221,38 +210,38 @@ public: } // Populate the store with all incoming arguments. - fmt::dynamic_format_arg_store store; - (void)std::initializer_list{ - (store.push_back(std::forward(args)), 0)...}; + auto* store = backend.alloc_arg_store(); + if (!store) { + return; + } + (void)std::initializer_list{(store->push_back(std::forward(args)), 0)...}; // Send the log entry to the backend. - log_formatter& formatter = log_sink.get_formatter(); - detail::log_entry entry = { - &log_sink, - [&formatter, ctx](detail::log_entry_metadata&& metadata, - fmt::memory_buffer& buffer) { - formatter.format_ctx(ctx, std::move(metadata), buffer); - }, - {std::chrono::high_resolution_clock::now(), - {ctx_value, should_print_context}, - fmtstr, - std::move(store), - log_name, - log_tag, - small_str_buffer()}}; + log_formatter& formatter = log_sink.get_formatter(); + detail::log_entry entry = {&log_sink, + [&formatter, ctx](detail::log_entry_metadata&& metadata, fmt::memory_buffer& buffer) { + formatter.format_ctx(ctx, std::move(metadata), buffer); + }, + {std::chrono::high_resolution_clock::now(), + {ctx_value, should_print_context}, + fmtstr, + store, + log_name, + log_tag, + small_str_buffer()}}; backend.push(std::move(entry)); } private: - const std::string log_id; - sink& log_sink; - detail::log_backend& backend; - const std::string log_name; - const char log_tag; - const bool should_print_context; + const std::string log_id; + sink& log_sink; + detail::log_backend& backend; + const std::string log_name; + const char log_tag; + const bool should_print_context; detail::shared_variable ctx_value; - detail::shared_variable hex_max_size; - detail::shared_variable is_enabled; + detail::shared_variable hex_max_size; + detail::shared_variable is_enabled; }; } // namespace srslog diff --git a/lib/src/srslog/backend_worker.cpp b/lib/src/srslog/backend_worker.cpp index 50692fdd0..a564b69fe 100644 --- a/lib/src/srslog/backend_worker.cpp +++ b/lib/src/srslog/backend_worker.cpp @@ -95,8 +95,14 @@ void backend_worker::process_log_entry(detail::log_entry&& entry) if (entry.metadata.small_str.size()) { entry.metadata.fmtstring = entry.metadata.small_str.data(); } + + // Save the pointer before moving the entry. + auto* arg_store = entry.metadata.store; + entry.format_func(std::move(entry.metadata), fmt_buffer); + arg_pool.dealloc(arg_store); + if (auto err_str = entry.s->write({fmt_buffer.data(), fmt_buffer.size()})) { err_handler(err_str.get_error()); } diff --git a/lib/src/srslog/backend_worker.h b/lib/src/srslog/backend_worker.h index 92612b77b..641c024c2 100644 --- a/lib/src/srslog/backend_worker.h +++ b/lib/src/srslog/backend_worker.h @@ -14,6 +14,7 @@ #define SRSLOG_BACKEND_WORKER_H #include "srsran/srslog/detail/log_entry.h" +#include "srsran/srslog/detail/support/dyn_arg_store_pool.h" #include "srsran/srslog/detail/support/work_queue.h" #include "srsran/srslog/shared_types.h" #include @@ -31,8 +32,8 @@ class backend_worker static constexpr unsigned sleep_period_ms = 500; public: - explicit backend_worker(detail::work_queue& queue) : - queue(queue), running_flag(false) + explicit backend_worker(detail::work_queue& queue, detail::dyn_arg_store_pool& arg_pool) : + queue(queue), arg_pool(arg_pool), running_flag(false) {} backend_worker(const backend_worker&) = delete; @@ -94,23 +95,21 @@ private: void report_queue_on_full_once() { if (queue.is_almost_full()) { - err_handler( - fmt::format("The backend queue size is about to reach its maximum " - "capacity of {} elements, new log entries will get " - "discarded.\nConsider increasing the queue capacity.", - queue.get_capacity())); + err_handler(fmt::format("The backend queue size is about to reach its maximum " + "capacity of {} elements, new log entries will get " + "discarded.\nConsider increasing the queue capacity.", + queue.get_capacity())); err_handler = [](const std::string&) {}; } } private: detail::work_queue& queue; - detail::shared_variable running_flag; - error_handler err_handler = [](const std::string& error) { - fmt::print(stderr, "srsLog error - {}\n", error); - }; - std::once_flag start_once_flag; - std::thread worker_thread; + detail::dyn_arg_store_pool& arg_pool; + detail::shared_variable running_flag; + error_handler err_handler = [](const std::string& error) { fmt::print(stderr, "srsLog error - {}\n", error); }; + std::once_flag start_once_flag; + std::thread worker_thread; fmt::memory_buffer fmt_buffer; }; diff --git a/lib/src/srslog/formatters/json_formatter.cpp b/lib/src/srslog/formatters/json_formatter.cpp index 499703a1d..c7953501e 100644 --- a/lib/src/srslog/formatters/json_formatter.cpp +++ b/lib/src/srslog/formatters/json_formatter.cpp @@ -20,28 +20,33 @@ std::unique_ptr json_formatter::clone() const return std::unique_ptr(new json_formatter); } -void json_formatter::format(detail::log_entry_metadata&& metadata, - fmt::memory_buffer& buffer) +void json_formatter::format(detail::log_entry_metadata&& metadata, fmt::memory_buffer& buffer) { fmt::format_to(buffer, "{{\n" - " \"log_entry\": \"{}\"", - fmt::vsprintf(metadata.fmtstring, std::move(metadata.store))); + " \"log_entry\": \""); + if (metadata.fmtstring) { + if (metadata.store) { + fmt::basic_format_args > args(*metadata.store); + fmt::vprintf(buffer, fmt::to_string_view(metadata.fmtstring), args); + fmt::format_to(buffer, fmt::to_string_view("\"")); + } else { + fmt::format_to(buffer, "{}\"", metadata.fmtstring); + } + } if (!metadata.hex_dump.empty()) { fmt::format_to( - buffer, - ",\n \"hex_dump\": \"{:02x}\"", - fmt::join(metadata.hex_dump.cbegin(), metadata.hex_dump.cend(), " ")); + buffer, ",\n \"hex_dump\": \"{:02x}\"", fmt::join(metadata.hex_dump.cbegin(), metadata.hex_dump.cend(), " ")); } fmt::format_to(buffer, "\n}}\n"); } void json_formatter::format_context_begin(const detail::log_entry_metadata& md, - const std::string& ctx_name, - unsigned size, - fmt::memory_buffer& buffer) + fmt::string_view ctx_name, + unsigned size, + fmt::memory_buffer& buffer) { assert(scope_stack.empty() && "Stack should be empty"); assert(nest_level == 0 && "Nesting level should be 0"); @@ -50,15 +55,20 @@ void json_formatter::format_context_begin(const detail::log_entry_metadata& md, push_scope(size); if (md.fmtstring) { - fmt::format_to(buffer, - " \"log_entry\": \"{}\",\n", - fmt::vsprintf(md.fmtstring, std::move(md.store))); + if (md.store) { + fmt::format_to(buffer, " \"log_entry\": \""); + fmt::basic_format_args > args(*md.store); + fmt::vprintf(buffer, fmt::to_string_view(md.fmtstring), args); + fmt::format_to(buffer, "\",\n"); + } else { + fmt::format_to(buffer, " \"log_entry\": \"{}\",\n", md.fmtstring); + } } } void json_formatter::format_context_end(const detail::log_entry_metadata& md, - const std::string& ctx_name, - fmt::memory_buffer& buffer) + fmt::string_view ctx_name, + fmt::memory_buffer& buffer) { pop_scope(); fmt::format_to(buffer, "}}\n"); @@ -67,9 +77,9 @@ void json_formatter::format_context_end(const detail::log_entry_metadata& md, assert(nest_level == 0 && "Nesting level should be 0"); } -void json_formatter::format_metric_set_begin(const std::string& set_name, - unsigned size, - unsigned level, +void json_formatter::format_metric_set_begin(fmt::string_view set_name, + unsigned size, + unsigned level, fmt::memory_buffer& buffer) { // Arrays in JSON require an additional nesting level before inserting the @@ -90,29 +100,22 @@ void json_formatter::format_metric_set_begin(const std::string& set_name, push_scope(size); } -void json_formatter::format_metric_set_end(const std::string& set_name, - unsigned level, - fmt::memory_buffer& buffer) +void json_formatter::format_metric_set_end(fmt::string_view set_name, unsigned level, fmt::memory_buffer& buffer) { pop_scope(); - fmt::format_to(buffer, - "{: <{}}}}{}\n", - ' ', - indents(level), - needs_comma() && !in_list_scope() ? "," : ""); + fmt::format_to(buffer, "{: <{}}}}{}\n", ' ', indents(level), needs_comma() && !in_list_scope() ? "," : ""); if (in_list_scope()) { decrement_nest_level(); - fmt::format_to( - buffer, "{: <{}}}}{}\n", ' ', indents(level), needs_comma() ? "," : ""); + fmt::format_to(buffer, "{: <{}}}}{}\n", ' ', indents(level), needs_comma() ? "," : ""); } } -void json_formatter::format_metric(const std::string& metric_name, - const std::string& metric_value, - const std::string& metric_units, - metric_kind kind, - unsigned level, +void json_formatter::format_metric(fmt::string_view metric_name, + fmt::string_view metric_value, + fmt::string_view metric_units, + metric_kind kind, + unsigned level, fmt::memory_buffer& buffer) { consume_element(); @@ -128,9 +131,9 @@ void json_formatter::format_metric(const std::string& metric_name, needs_comma() ? "," : ""); } -void json_formatter::format_list_begin(const std::string& list_name, - unsigned size, - unsigned level, +void json_formatter::format_list_begin(fmt::string_view list_name, + unsigned size, + unsigned level, fmt::memory_buffer& buffer) { consume_element(); @@ -139,11 +142,8 @@ void json_formatter::format_list_begin(const std::string& list_name, push_list_scope(size); } -void json_formatter::format_list_end(const std::string& list_name, - unsigned level, - fmt::memory_buffer& buffer) +void json_formatter::format_list_end(fmt::string_view list_name, unsigned level, fmt::memory_buffer& buffer) { pop_scope(); - fmt::format_to( - buffer, "{: <{}}]{}\n", ' ', indents(level), needs_comma() ? "," : ""); + fmt::format_to(buffer, "{: <{}}]{}\n", ' ', indents(level), needs_comma() ? "," : ""); } diff --git a/lib/src/srslog/formatters/json_formatter.h b/lib/src/srslog/formatters/json_formatter.h index 4c7391835..751db1c84 100644 --- a/lib/src/srslog/formatters/json_formatter.h +++ b/lib/src/srslog/formatters/json_formatter.h @@ -29,42 +29,35 @@ public: std::unique_ptr clone() const override; - void format(detail::log_entry_metadata&& metadata, - fmt::memory_buffer& buffer) override; + void format(detail::log_entry_metadata&& metadata, fmt::memory_buffer& buffer) override; private: void format_context_begin(const detail::log_entry_metadata& md, - const std::string& ctx_name, - unsigned size, - fmt::memory_buffer& buffer) override; + fmt::string_view ctx_name, + unsigned size, + fmt::memory_buffer& buffer) override; void format_context_end(const detail::log_entry_metadata& md, - const std::string& ctx_name, - fmt::memory_buffer& buffer) override; + fmt::string_view ctx_name, + fmt::memory_buffer& buffer) override; - void format_metric_set_begin(const std::string& set_name, - unsigned size, - unsigned level, + void format_metric_set_begin(fmt::string_view set_name, + unsigned size, + unsigned level, fmt::memory_buffer& buffer) override; - void format_metric_set_end(const std::string& set_name, - unsigned level, - fmt::memory_buffer& buffer) override; + void format_metric_set_end(fmt::string_view set_name, unsigned level, fmt::memory_buffer& buffer) override; - void format_list_begin(const std::string& list_name, - unsigned size, - unsigned level, - fmt::memory_buffer& buffer) override; + void + format_list_begin(fmt::string_view list_name, unsigned size, unsigned level, fmt::memory_buffer& buffer) override; - void format_list_end(const std::string& list_name, - unsigned level, - fmt::memory_buffer& buffer) override; + void format_list_end(fmt::string_view list_name, unsigned level, fmt::memory_buffer& buffer) override; - void format_metric(const std::string& metric_name, - const std::string& metric_value, - const std::string& metric_units, - metric_kind kind, - unsigned level, + void format_metric(fmt::string_view metric_name, + fmt::string_view metric_value, + fmt::string_view metric_units, + metric_kind kind, + unsigned level, fmt::memory_buffer& buffer) override; /// Pushes a new entry in the scope stack. @@ -118,9 +111,7 @@ private: private: /// Keeps track of some information about a JSON scope. struct scope { - scope(unsigned size, bool inside_list) : - size(size), inside_list(inside_list) - {} + scope(unsigned size, bool inside_list) : size(size), inside_list(inside_list) {} /// Number of elements this scope holds. unsigned size; /// If true, indicates this scope belongs to a list. @@ -128,7 +119,7 @@ private: }; private: - unsigned nest_level = 0; + unsigned nest_level = 0; std::vector scope_stack; }; diff --git a/lib/src/srslog/formatters/text_formatter.cpp b/lib/src/srslog/formatters/text_formatter.cpp index 7e620f2a7..c47f5e884 100644 --- a/lib/src/srslog/formatters/text_formatter.cpp +++ b/lib/src/srslog/formatters/text_formatter.cpp @@ -23,39 +23,26 @@ std::unique_ptr text_formatter::clone() const /// Formats into a hex dump a range of elements, storing the result in the input /// buffer. -static void format_hex_dump(const std::vector& v, - fmt::memory_buffer& buffer) +static void format_hex_dump(const std::vector& v, fmt::memory_buffer& buffer) { - if (v.empty()) { - return; - } - const size_t elements_per_line = 16; for (auto i = v.cbegin(), e = v.cend(); i != e;) { - auto num_elements = - std::min(elements_per_line, std::distance(i, e)); + auto num_elements = std::min(elements_per_line, std::distance(i, e)); - fmt::format_to(buffer, - " {:04x}: {:02x}\n", - std::distance(v.cbegin(), i), - fmt::join(i, i + num_elements, " ")); + fmt::format_to(buffer, " {:04x}: {:02x}\n", std::distance(v.cbegin(), i), fmt::join(i, i + num_elements, " ")); std::advance(i, num_elements); } } /// Format the log metadata into the input buffer. -static void format_metadata(const detail::log_entry_metadata& metadata, - fmt::memory_buffer& buffer) +static void format_metadata(const detail::log_entry_metadata& metadata, fmt::memory_buffer& buffer) { // Time stamp data preparation. - std::tm current_time = - fmt::gmtime(std::chrono::high_resolution_clock::to_time_t(metadata.tp)); - auto us_fraction = std::chrono::duration_cast( - metadata.tp.time_since_epoch()) - .count() % - 1000000u; + std::tm current_time = fmt::gmtime(std::chrono::high_resolution_clock::to_time_t(metadata.tp)); + auto us_fraction = + std::chrono::duration_cast(metadata.tp.time_since_epoch()).count() % 1000000u; fmt::format_to(buffer, "{:%H:%M:%S}.{:06} ", current_time, us_fraction); // Format optional fields if present. @@ -70,25 +57,30 @@ static void format_metadata(const detail::log_entry_metadata& metadata, } } -void text_formatter::format(detail::log_entry_metadata&& metadata, - fmt::memory_buffer& buffer) +void text_formatter::format(detail::log_entry_metadata&& metadata, fmt::memory_buffer& buffer) { // Prefix first. format_metadata(metadata, buffer); // Message formatting. - fmt::format_to(buffer, - "{}\n", - fmt::vsprintf(metadata.fmtstring, std::move(metadata.store))); + if (metadata.fmtstring) { + if (metadata.store) { + fmt::basic_format_args > args(*metadata.store); + fmt::vprintf(buffer, fmt::to_string_view(metadata.fmtstring), args); + fmt::format_to(buffer, "\n"); + } else { + fmt::format_to(buffer, "{}\n", metadata.fmtstring); + } + } // Optional hex dump formatting. format_hex_dump(metadata.hex_dump, buffer); } void text_formatter::format_context_begin(const detail::log_entry_metadata& md, - const std::string& ctx_name, - unsigned size, - fmt::memory_buffer& buffer) + fmt::string_view ctx_name, + unsigned size, + fmt::memory_buffer& buffer) { // Entries without a log message are printed using a richer format. do_one_line_ctx_format = md.fmtstring; @@ -104,35 +96,39 @@ void text_formatter::format_context_begin(const detail::log_entry_metadata& md, } void text_formatter::format_context_end(const detail::log_entry_metadata& md, - const std::string& ctx_name, - fmt::memory_buffer& buffer) + fmt::string_view ctx_name, + fmt::memory_buffer& buffer) { if (!do_one_line_ctx_format) { return; } - fmt::format_to(buffer, "]: {}\n", fmt::vsprintf(md.fmtstring, md.store)); + if (md.store) { + fmt::format_to(buffer, "]: "); + fmt::basic_format_args > args(*md.store); + fmt::vprintf(buffer, fmt::to_string_view(md.fmtstring), args); + fmt::format_to(buffer, "\n"); + } else { + fmt::format_to(buffer, "]: {}\n", md.fmtstring); + } assert(scope_stack.empty() && "Stack should be empty"); } -void text_formatter::format_metric_set_begin(const std::string& set_name, - unsigned size, - unsigned level, +void text_formatter::format_metric_set_begin(fmt::string_view set_name, + unsigned size, + unsigned level, fmt::memory_buffer& buffer) { if (do_one_line_ctx_format) { - scope_stack.emplace_back(size, set_name); + scope_stack.emplace_back(size, set_name.data()); fmt::format_to(buffer, "["); return; } - fmt::format_to( - buffer, "{: <{}}> Set: {}\n", ' ', get_indents(level), set_name); + fmt::format_to(buffer, "{: <{}}> Set: {}\n", ' ', get_indents(level), set_name); } -void text_formatter::format_metric_set_end(const std::string& set_name, - unsigned level, - fmt::memory_buffer& buffer) +void text_formatter::format_metric_set_end(fmt::string_view set_name, unsigned level, fmt::memory_buffer& buffer) { if (!do_one_line_ctx_format) { return; @@ -142,11 +138,11 @@ void text_formatter::format_metric_set_end(const std::string& set_name, fmt::format_to(buffer, "]"); } -void text_formatter::format_metric(const std::string& metric_name, - const std::string& metric_value, - const std::string& metric_units, - metric_kind kind, - unsigned level, +void text_formatter::format_metric(fmt::string_view metric_name, + fmt::string_view metric_value, + fmt::string_view metric_units, + metric_kind kind, + unsigned level, fmt::memory_buffer& buffer) { if (do_one_line_ctx_format) { @@ -156,7 +152,7 @@ void text_formatter::format_metric(const std::string& metric_name, get_current_set_name(), metric_name, metric_value, - metric_units.empty() ? "" : " ", + metric_units.size() == 0 ? "" : " ", metric_units, needs_comma() ? ", " : ""); return; @@ -168,18 +164,17 @@ void text_formatter::format_metric(const std::string& metric_name, get_indents(level), metric_name, metric_value, - metric_units.empty() ? "" : " ", + metric_units.size() == 0 ? "" : " ", metric_units); } -void text_formatter::format_list_begin(const std::string& list_name, - unsigned size, - unsigned level, +void text_formatter::format_list_begin(fmt::string_view list_name, + unsigned size, + unsigned level, fmt::memory_buffer& buffer) { if (do_one_line_ctx_format) { return; } - fmt::format_to( - buffer, "{: <{}}> List: {}\n", ' ', get_indents(level), list_name); + fmt::format_to(buffer, "{: <{}}> List: {}\n", ' ', get_indents(level), list_name); } diff --git a/lib/src/srslog/formatters/text_formatter.h b/lib/src/srslog/formatters/text_formatter.h index 4dc1d8407..b7b5d6016 100644 --- a/lib/src/srslog/formatters/text_formatter.h +++ b/lib/src/srslog/formatters/text_formatter.h @@ -25,43 +25,35 @@ public: std::unique_ptr clone() const override; - void format(detail::log_entry_metadata&& metadata, - fmt::memory_buffer& buffer) override; + void format(detail::log_entry_metadata&& metadata, fmt::memory_buffer& buffer) override; private: void format_context_begin(const detail::log_entry_metadata& md, - const std::string& ctx_name, - unsigned size, - fmt::memory_buffer& buffer) override; + fmt::string_view ctx_name, + unsigned size, + fmt::memory_buffer& buffer) override; void format_context_end(const detail::log_entry_metadata& md, - const std::string& ctx_name, - fmt::memory_buffer& buffer) override; + fmt::string_view ctx_name, + fmt::memory_buffer& buffer) override; - void format_metric_set_begin(const std::string& set_name, - unsigned size, - unsigned level, + void format_metric_set_begin(fmt::string_view set_name, + unsigned size, + unsigned level, fmt::memory_buffer& buffer) override; - void format_metric_set_end(const std::string& set_name, - unsigned level, - fmt::memory_buffer& buffer) override; - - void format_list_begin(const std::string& list_name, - unsigned size, - unsigned level, - fmt::memory_buffer& buffer) override; - - void format_list_end(const std::string& list_name, - unsigned level, - fmt::memory_buffer& buffer) override - {} - - void format_metric(const std::string& metric_name, - const std::string& metric_value, - const std::string& metric_units, - metric_kind kind, - unsigned level, + void format_metric_set_end(fmt::string_view set_name, unsigned level, fmt::memory_buffer& buffer) override; + + void + format_list_begin(fmt::string_view list_name, unsigned size, unsigned level, fmt::memory_buffer& buffer) override; + + void format_list_end(fmt::string_view list_name, unsigned level, fmt::memory_buffer& buffer) override {} + + void format_metric(fmt::string_view metric_name, + fmt::string_view metric_value, + fmt::string_view metric_units, + metric_kind kind, + unsigned level, fmt::memory_buffer& buffer) override; /// Returns the set name of current scope. @@ -92,9 +84,7 @@ private: private: /// Keeps track of some state required for formatting. struct scope { - scope(unsigned size, std::string set_name) : - size(size), set_name(std::move(set_name)) - {} + scope(unsigned size, std::string set_name) : size(size), set_name(std::move(set_name)) {} /// Number of elements this scope holds. unsigned size; /// Set name in this scope. @@ -103,7 +93,7 @@ private: private: /// Flags that the formatting should take place into a single line. - bool do_one_line_ctx_format = false; + bool do_one_line_ctx_format = false; std::vector scope_stack; }; diff --git a/lib/src/srslog/log_backend_impl.h b/lib/src/srslog/log_backend_impl.h index 02b9548ad..23ca4b215 100644 --- a/lib/src/srslog/log_backend_impl.h +++ b/lib/src/srslog/log_backend_impl.h @@ -33,23 +33,28 @@ public: bool push(detail::log_entry&& entry) override { - return queue.push(std::move(entry)); + auto* arg_store = entry.metadata.store; + if (!queue.push(std::move(entry))) { + arg_pool.dealloc(arg_store); + return false; + } + return true; } + fmt::dynamic_format_arg_store* alloc_arg_store() override { return arg_pool.alloc(); } + bool is_running() const override { return worker.is_running(); } /// Installs the specified error handler into the backend worker. - void set_error_handler(error_handler err_handler) - { - worker.set_error_handler(std::move(err_handler)); - } + void set_error_handler(error_handler err_handler) { worker.set_error_handler(std::move(err_handler)); } /// Stops the backend worker thread. void stop() { worker.stop(); } private: detail::work_queue queue; - backend_worker worker{queue}; + detail::dyn_arg_store_pool arg_pool; + backend_worker worker{queue, arg_pool}; }; } // namespace srslog diff --git a/lib/src/srslog/srslog.cpp b/lib/src/srslog/srslog.cpp index 9026a63f8..c349c0318 100644 --- a/lib/src/srslog/srslog.cpp +++ b/lib/src/srslog/srslog.cpp @@ -198,6 +198,7 @@ void srslog::flush() } detail::log_entry cmd; + cmd.metadata.store = nullptr; cmd.flush_cmd = std::unique_ptr( new detail::flush_backend_cmd{completion_flag, std::move(sinks)}); diff --git a/lib/test/srslog/event_trace_test.cpp b/lib/test/srslog/event_trace_test.cpp index 94d8b063b..173089960 100644 --- a/lib/test/srslog/event_trace_test.cpp +++ b/lib/test/srslog/event_trace_test.cpp @@ -32,6 +32,8 @@ public: return true; } + fmt::dynamic_format_arg_store* alloc_arg_store() override { return &store; } + bool is_running() const override { return true; } void reset() { count = 0; } @@ -39,13 +41,13 @@ public: unsigned push_invocation_count() const { return count; } private: - unsigned count = 0; + unsigned count = 0; + fmt::dynamic_format_arg_store store; }; } // namespace -static bool -when_tracing_with_duration_event_then_two_events_are_generated(backend_spy& spy) +static bool when_tracing_with_duration_event_then_two_events_are_generated(backend_spy& spy) { trace_duration_begin("a", "b"); ASSERT_EQ(spy.push_invocation_count(), 1); @@ -56,8 +58,7 @@ when_tracing_with_duration_event_then_two_events_are_generated(backend_spy& spy) return true; } -static bool -when_tracing_with_complete_event_then_one_event_is_generated(backend_spy& spy) +static bool when_tracing_with_complete_event_then_one_event_is_generated(backend_spy& spy) { { trace_complete_event("a", "b"); @@ -70,17 +71,15 @@ when_tracing_with_complete_event_then_one_event_is_generated(backend_spy& spy) int main() { test_dummies::sink_dummy s; - backend_spy backend; - log_channel c("test", s, backend); + backend_spy backend; + log_channel c("test", s, backend); // Inject our spy into the framework. event_trace_init(c); - TEST_FUNCTION(when_tracing_with_duration_event_then_two_events_are_generated, - backend); + TEST_FUNCTION(when_tracing_with_duration_event_then_two_events_are_generated, backend); backend.reset(); - TEST_FUNCTION(when_tracing_with_complete_event_then_one_event_is_generated, - backend); + TEST_FUNCTION(when_tracing_with_complete_event_then_one_event_is_generated, backend); return 0; } diff --git a/lib/test/srslog/json_formatter_test.cpp b/lib/test/srslog/json_formatter_test.cpp index a1f8b1e3a..76d9fc0c5 100644 --- a/lib/test/srslog/json_formatter_test.cpp +++ b/lib/test/srslog/json_formatter_test.cpp @@ -18,23 +18,25 @@ using namespace srslog; /// Helper to build a log entry. -static detail::log_entry_metadata build_log_entry_metadata() +static detail::log_entry_metadata build_log_entry_metadata(fmt::dynamic_format_arg_store* store) { // Create a time point 50000us from epoch. using tp_ty = std::chrono::time_point; tp_ty tp(std::chrono::microseconds(50000)); - fmt::dynamic_format_arg_store store; - store.push_back(88); + if (store) { + store->push_back(88); + } - return {tp, {10, true}, "Text %d", std::move(store), "ABC", 'Z', small_str_buffer()}; + return {tp, {10, true}, "Text %d", store, "ABC", 'Z', small_str_buffer()}; } static bool when_fully_filled_log_entry_then_everything_is_formatted() { - fmt::memory_buffer buffer; - json_formatter{}.format(build_log_entry_metadata(), buffer); - std::string result = fmt::to_string(buffer); + fmt::dynamic_format_arg_store store; + fmt::memory_buffer buffer; + json_formatter{}.format(build_log_entry_metadata(&store), buffer); + std::string result = fmt::to_string(buffer); std::string expected = "{\n" " \"log_entry\": \"Text 88\"\n" "}\n"; @@ -44,21 +46,20 @@ static bool when_fully_filled_log_entry_then_everything_is_formatted() return true; } -static bool -when_fully_filled_log_entry_with_hex_dump_then_everything_is_formatted() +static bool when_fully_filled_log_entry_with_hex_dump_then_everything_is_formatted() { - auto entry = build_log_entry_metadata(); + fmt::dynamic_format_arg_store store; + auto entry = build_log_entry_metadata(&store); entry.hex_dump.resize(12); std::iota(entry.hex_dump.begin(), entry.hex_dump.end(), 0); fmt::memory_buffer buffer; json_formatter{}.format(std::move(entry), buffer); - std::string result = fmt::to_string(buffer); - std::string expected = - "{\n" - " \"log_entry\": \"Text 88\",\n" - " \"hex_dump\": \"00 01 02 03 04 05 06 07 08 09 0a 0b\"\n" - "}\n"; + std::string result = fmt::to_string(buffer); + std::string expected = "{\n" + " \"log_entry\": \"Text 88\",\n" + " \"hex_dump\": \"00 01 02 03 04 05 06 07 08 09 0a 0b\"\n" + "}\n"; ASSERT_EQ(result, expected); @@ -78,10 +79,9 @@ DECLARE_METRIC_SET("Network", myset2, thr_t, ip_addr_t); using basic_ctx_t = srslog::build_context_type; } // namespace -static bool -when_log_entry_with_only_basic_context_is_passed_then_context_is_formatted() +static bool when_log_entry_with_only_basic_context_is_passed_then_context_is_formatted() { - auto entry = build_log_entry_metadata(); + auto entry = build_log_entry_metadata(nullptr); entry.fmtstring = nullptr; basic_ctx_t ctx("UL Context"); @@ -93,7 +93,7 @@ when_log_entry_with_only_basic_context_is_passed_then_context_is_formatted() fmt::memory_buffer buffer; json_formatter{}.format_ctx(ctx, std::move(entry), buffer); - std::string result = fmt::to_string(buffer); + std::string result = fmt::to_string(buffer); std::string expected = "{\n" " \"RF\": {\n" " \"SNR\": -55.1,\n" @@ -111,11 +111,11 @@ when_log_entry_with_only_basic_context_is_passed_then_context_is_formatted() return true; } -static bool -when_log_entry_with_message_and_basic_context_is_passed_then_context_is_formatted() +static bool when_log_entry_with_message_and_basic_context_is_passed_then_context_is_formatted() { - auto entry = build_log_entry_metadata(); - basic_ctx_t ctx("UL Context"); + fmt::dynamic_format_arg_store store; + auto entry = build_log_entry_metadata(&store); + basic_ctx_t ctx("UL Context"); ctx.get().write(-55.1); ctx.get().write(-10); @@ -125,7 +125,7 @@ when_log_entry_with_message_and_basic_context_is_passed_then_context_is_formatte fmt::memory_buffer buffer; json_formatter{}.format_ctx(ctx, std::move(entry), buffer); - std::string result = fmt::to_string(buffer); + std::string result = fmt::to_string(buffer); std::string expected = "{\n" " \"log_entry\": \"Text 88\",\n" " \"RF\": {\n" @@ -157,23 +157,18 @@ DECLARE_METRIC_SET("ue_container", ue_set, ue_rnti_t, dl_cqi_t, bearer_list_t); DECLARE_METRIC("type", entry_type_t, std::string, ""); DECLARE_METRIC("sector_id", sector_id_t, unsigned, ""); DECLARE_METRIC_LIST("ue_list", ue_list_t, std::vector); -DECLARE_METRIC_SET("sector_metrics", - sector_set, - entry_type_t, - sector_id_t, - ue_list_t); +DECLARE_METRIC_SET("sector_metrics", sector_set, entry_type_t, sector_id_t, ue_list_t); DECLARE_METRIC_LIST("sector_list", sector_list_t, std::vector); using complex_ctx_t = srslog::build_context_type; } // namespace -static bool -when_log_entry_with_only_complex_context_is_passed_then_context_is_formatted() +static bool when_log_entry_with_only_complex_context_is_passed_then_context_is_formatted() { complex_ctx_t ctx("UL Context"); - auto entry = build_log_entry_metadata(); - entry.fmtstring = nullptr; + auto entry = build_log_entry_metadata(nullptr); + entry.fmtstring = nullptr; ctx.get().emplace_back(); ctx.at(0).get().emplace_back(); @@ -187,7 +182,7 @@ when_log_entry_with_only_complex_context_is_passed_then_context_is_formatted() fmt::memory_buffer buffer; json_formatter{}.format_ctx(ctx, std::move(entry), buffer); - std::string result = fmt::to_string(buffer); + std::string result = fmt::to_string(buffer); std::string expected = "{\n" " \"sector_list\": [\n" " {\n" @@ -252,19 +247,18 @@ DECLARE_METRIC_SET("metric_list_set", metric_list_set, list_metric2); DECLARE_METRIC_LIST("metrics_list", metrics_list, std::vector); DECLARE_METRIC("list_metric3", list_metric3, unsigned, ""); DECLARE_METRIC("list_metric4", list_metric4, unsigned, ""); -using list_ctx_t = - srslog::build_context_type; +using list_ctx_t = srslog::build_context_type; }; // namespace static bool when_context_with_empty_list_is_passed_then_list_object_is_empty() { list_ctx_t ctx("UL Context"); - auto entry = build_log_entry_metadata(); - entry.fmtstring = nullptr; + auto entry = build_log_entry_metadata(nullptr); + entry.fmtstring = nullptr; fmt::memory_buffer buffer; json_formatter{}.format_ctx(ctx, std::move(entry), buffer); - std::string result = fmt::to_string(buffer); + std::string result = fmt::to_string(buffer); std::string expected = "{\n" " \"list_metric3\": 0,\n" " \"list_metric4\": 0,\n" @@ -280,16 +274,11 @@ static bool when_context_with_empty_list_is_passed_then_list_object_is_empty() int main() { TEST_FUNCTION(when_fully_filled_log_entry_then_everything_is_formatted); - TEST_FUNCTION( - when_fully_filled_log_entry_with_hex_dump_then_everything_is_formatted); - TEST_FUNCTION( - when_log_entry_with_only_basic_context_is_passed_then_context_is_formatted); - TEST_FUNCTION( - when_log_entry_with_message_and_basic_context_is_passed_then_context_is_formatted); - TEST_FUNCTION( - when_log_entry_with_only_complex_context_is_passed_then_context_is_formatted); - TEST_FUNCTION( - when_context_with_empty_list_is_passed_then_list_object_is_empty); + TEST_FUNCTION(when_fully_filled_log_entry_with_hex_dump_then_everything_is_formatted); + TEST_FUNCTION(when_log_entry_with_only_basic_context_is_passed_then_context_is_formatted); + TEST_FUNCTION(when_log_entry_with_message_and_basic_context_is_passed_then_context_is_formatted); + TEST_FUNCTION(when_log_entry_with_only_complex_context_is_passed_then_context_is_formatted); + TEST_FUNCTION(when_context_with_empty_list_is_passed_then_list_object_is_empty); return 0; } diff --git a/lib/test/srslog/log_backend_test.cpp b/lib/test/srslog/log_backend_test.cpp index 1ef1b56ca..39a395a0c 100644 --- a/lib/test/srslog/log_backend_test.cpp +++ b/lib/test/srslog/log_backend_test.cpp @@ -46,9 +46,7 @@ namespace { class sink_spy : public sink { public: - sink_spy() : - sink(std::unique_ptr(new test_dummies::log_formatter_dummy)) - {} + sink_spy() : sink(std::unique_ptr(new test_dummies::log_formatter_dummy)) {} detail::error_string write(detail::memory_buffer buffer) override { @@ -64,33 +62,33 @@ public: const std::string& received_buffer() const { return str; } private: - unsigned count = 0; + unsigned count = 0; std::string str; }; } // namespace /// Builds a basic log entry. -static detail::log_entry build_log_entry(sink* s) +static detail::log_entry build_log_entry(sink* s, fmt::dynamic_format_arg_store* store) { using tp_ty = std::chrono::time_point; tp_ty tp; - fmt::dynamic_format_arg_store store; - store.push_back(88); + if (store) { + store->push_back(88); + } - return { - s, - [](detail::log_entry_metadata&& metadata, fmt::memory_buffer& buffer) {}, - {tp, {0, false}, "Text %d", std::move(store), "", '\0', small_str_buffer()}}; + return {s, + [](detail::log_entry_metadata&& metadata, fmt::memory_buffer& buffer) {}, + {tp, {0, false}, "Text %d", store, "", '\0', small_str_buffer()}}; } static bool when_backend_is_not_started_then_pushed_log_entries_are_ignored() { - sink_spy spy; + sink_spy spy; log_backend_impl backend; - backend.push(build_log_entry(&spy)); + backend.push(build_log_entry(&spy, backend.alloc_arg_store())); ASSERT_EQ(spy.write_invocation_count(), 0); @@ -104,7 +102,7 @@ static bool when_backend_is_started_then_pushed_log_entries_are_sent_to_sink() log_backend_impl backend; backend.start(); - backend.push(build_log_entry(&spy)); + backend.push(build_log_entry(&spy, backend.alloc_arg_store())); // Stop the backend to ensure the entry has been processed. backend.stop(); @@ -121,10 +119,9 @@ static bool when_backend_is_started_then_backend_invokes_format_func() log_backend_impl backend; backend.start(); - auto entry = build_log_entry(&s); - unsigned counter = 0; - entry.format_func = [&counter](detail::log_entry_metadata&& metadata, - fmt::memory_buffer& buffer) { ++counter; }; + auto entry = build_log_entry(&s, backend.alloc_arg_store()); + unsigned counter = 0; + entry.format_func = [&counter](detail::log_entry_metadata&& metadata, fmt::memory_buffer& buffer) { ++counter; }; backend.push(std::move(entry)); // Stop the backend to ensure the entry has been processed. @@ -144,14 +141,10 @@ class sink_error_stub : public sink { public: explicit sink_error_stub(std::string err) : - sink(std::unique_ptr(new test_dummies::log_formatter_dummy)), - err(std::move(err)) + sink(std::unique_ptr(new test_dummies::log_formatter_dummy)), err(std::move(err)) {} - detail::error_string write(detail::memory_buffer buffer) override - { - return err; - } + detail::error_string write(detail::memory_buffer buffer) override { return err; } detail::error_string flush() override { return err; } @@ -163,11 +156,11 @@ private: static bool when_sink_write_fails_then_error_handler_is_invoked() { - std::string error_str("error"); + std::string error_str("error"); sink_error_stub s(error_str); - bool valid_err = false; - unsigned count = 0; + bool valid_err = false; + unsigned count = 0; // valid_err checks that the input error matches the expected string. // The count variable counts the number of calls. auto handler = [&count, &valid_err, error_str](const std::string& error) { @@ -179,7 +172,7 @@ static bool when_sink_write_fails_then_error_handler_is_invoked() backend.set_error_handler(handler); backend.start(); - backend.push(build_log_entry(&s)); + backend.push(build_log_entry(&s, backend.alloc_arg_store())); // Stop the backend to ensure the entry has been processed. backend.stop(); @@ -204,7 +197,7 @@ static bool when_handler_is_set_after_start_then_handler_is_not_used() backend.start(); backend.set_error_handler(handler); - backend.push(build_log_entry(&s)); + backend.push(build_log_entry(&s, backend.alloc_arg_store())); // Stop the backend to ensure the entry has been processed. backend.stop(); @@ -223,7 +216,7 @@ static bool when_empty_handler_is_used_then_backend_does_not_crash() backend.set_error_handler({}); backend.start(); - backend.push(build_log_entry(&s)); + backend.push(build_log_entry(&s, backend.alloc_arg_store())); // Stop the backend to ensure the entry has been processed. backend.stop(); @@ -234,12 +227,9 @@ static bool when_empty_handler_is_used_then_backend_does_not_crash() int main() { TEST_FUNCTION(when_backend_is_started_then_is_started_returns_true); - TEST_FUNCTION( - when_backend_is_started_and_stopped_then_is_started_returns_false); - TEST_FUNCTION( - when_backend_is_not_started_then_pushed_log_entries_are_ignored); - TEST_FUNCTION( - when_backend_is_started_then_pushed_log_entries_are_sent_to_sink); + TEST_FUNCTION(when_backend_is_started_and_stopped_then_is_started_returns_false); + TEST_FUNCTION(when_backend_is_not_started_then_pushed_log_entries_are_ignored); + TEST_FUNCTION(when_backend_is_started_then_pushed_log_entries_are_sent_to_sink); TEST_FUNCTION(when_backend_is_started_then_backend_invokes_format_func); TEST_FUNCTION(when_sink_write_fails_then_error_handler_is_invoked); TEST_FUNCTION(when_handler_is_set_after_start_then_handler_is_not_used); diff --git a/lib/test/srslog/log_channel_test.cpp b/lib/test/srslog/log_channel_test.cpp index eb425bdc9..af231903b 100644 --- a/lib/test/srslog/log_channel_test.cpp +++ b/lib/test/srslog/log_channel_test.cpp @@ -19,8 +19,8 @@ using namespace srslog; static bool when_log_channel_is_created_then_id_matches_expected_value() { test_dummies::backend_dummy backend; - test_dummies::sink_dummy s; - log_channel log("id", s, backend); + test_dummies::sink_dummy s; + log_channel log("id", s, backend); ASSERT_EQ(log.id(), "id"); @@ -30,8 +30,8 @@ static bool when_log_channel_is_created_then_id_matches_expected_value() static bool when_log_channel_is_disabled_then_enabled_returns_false() { test_dummies::backend_dummy backend; - test_dummies::sink_dummy s; - log_channel log("id", s, backend); + test_dummies::sink_dummy s; + log_channel log("id", s, backend); log.set_enabled(false); @@ -43,8 +43,8 @@ static bool when_log_channel_is_disabled_then_enabled_returns_false() static bool when_log_channel_is_enabled_then_enabled_returns_true() { test_dummies::backend_dummy backend; - test_dummies::sink_dummy s; - log_channel log("id", s, backend); + test_dummies::sink_dummy s; + log_channel log("id", s, backend); log.set_enabled(true); @@ -71,23 +71,25 @@ public: bool is_running() const override { return true; } + fmt::dynamic_format_arg_store* alloc_arg_store() override { return &store; } + unsigned push_invocation_count() const { return count; } const detail::log_entry& last_entry() const { return e; } private: - unsigned count = 0; - detail::log_entry e; + unsigned count = 0; + detail::log_entry e; + fmt::dynamic_format_arg_store store; }; } // namespace -static bool -when_logging_in_log_channel_then_log_entry_is_pushed_into_the_backend() +static bool when_logging_in_log_channel_then_log_entry_is_pushed_into_the_backend() { - backend_spy backend; + backend_spy backend; test_dummies::sink_dummy s; - log_channel log("id", s, backend); + log_channel log("id", s, backend); log("test", 42, "Hello"); @@ -98,9 +100,9 @@ when_logging_in_log_channel_then_log_entry_is_pushed_into_the_backend() static bool when_logging_in_disabled_log_channel_then_log_entry_is_ignored() { - backend_spy backend; + backend_spy backend; test_dummies::sink_dummy s; - log_channel log("id", s, backend); + log_channel log("id", s, backend); log.set_enabled(false); log("test", 42, "Hello"); @@ -112,11 +114,11 @@ static bool when_logging_in_disabled_log_channel_then_log_entry_is_ignored() static bool when_logging_then_filled_in_log_entry_is_pushed_into_the_backend() { - backend_spy backend; + backend_spy backend; test_dummies::sink_dummy s; std::string name = "name"; - char tag = 'A'; + char tag = 'A'; log_channel log("id", s, backend, {name, tag, true}); @@ -141,14 +143,13 @@ static bool when_logging_then_filled_in_log_entry_is_pushed_into_the_backend() return true; } -static bool -when_logging_with_hex_dump_then_filled_in_log_entry_is_pushed_into_the_backend() +static bool when_logging_with_hex_dump_then_filled_in_log_entry_is_pushed_into_the_backend() { - backend_spy backend; + backend_spy backend; test_dummies::sink_dummy s; std::string name = "name"; - char tag = 'A'; + char tag = 'A'; log_channel log("id", s, backend, {name, tag, true}); @@ -171,18 +172,14 @@ when_logging_with_hex_dump_then_filled_in_log_entry_is_pushed_into_the_backend() ASSERT_EQ(entry.metadata.log_name, name); ASSERT_EQ(entry.metadata.log_tag, tag); ASSERT_EQ(entry.metadata.hex_dump.size(), 4); - ASSERT_EQ(std::equal(entry.metadata.hex_dump.begin(), - entry.metadata.hex_dump.end(), - std::begin(hex)), - true); + ASSERT_EQ(std::equal(entry.metadata.hex_dump.begin(), entry.metadata.hex_dump.end(), std::begin(hex)), true); return true; } -static bool -when_hex_array_length_is_less_than_hex_log_max_size_then_array_length_is_used() +static bool when_hex_array_length_is_less_than_hex_log_max_size_then_array_length_is_used() { - backend_spy backend; + backend_spy backend; test_dummies::sink_dummy s; std::string name = "name"; @@ -197,10 +194,7 @@ when_hex_array_length_is_less_than_hex_log_max_size_then_array_length_is_used() const detail::log_entry& entry = backend.last_entry(); ASSERT_EQ(entry.metadata.hex_dump.size(), 3); - ASSERT_EQ(std::equal(entry.metadata.hex_dump.begin(), - entry.metadata.hex_dump.end(), - std::begin(hex)), - true); + ASSERT_EQ(std::equal(entry.metadata.hex_dump.begin(), entry.metadata.hex_dump.end(), std::begin(hex)), true); return true; } @@ -213,14 +207,13 @@ using my_ctx = srslog::build_context_type; } // namespace -static bool -when_logging_with_context_then_filled_in_log_entry_is_pushed_into_the_backend() +static bool when_logging_with_context_then_filled_in_log_entry_is_pushed_into_the_backend() { - backend_spy backend; + backend_spy backend; test_dummies::sink_dummy s; std::string name = "name"; - char tag = 'A'; + char tag = 'A'; log_channel log("id", s, backend, {name, tag, true}); @@ -245,14 +238,13 @@ when_logging_with_context_then_filled_in_log_entry_is_pushed_into_the_backend() return true; } -static bool -when_logging_with_context_and_message_then_filled_in_log_entry_is_pushed_into_the_backend() +static bool when_logging_with_context_and_message_then_filled_in_log_entry_is_pushed_into_the_backend() { - backend_spy backend; + backend_spy backend; test_dummies::sink_dummy s; std::string name = "name"; - char tag = 'A'; + char tag = 'A'; log_channel log("id", s, backend, {name, tag, true}); @@ -278,10 +270,9 @@ when_logging_with_context_and_message_then_filled_in_log_entry_is_pushed_into_th return true; } -static bool -when_logging_with_small_string_then_filled_in_log_entry_is_pushed_into_the_backend() +static bool when_logging_with_small_string_then_filled_in_log_entry_is_pushed_into_the_backend() { - backend_spy backend; + backend_spy backend; test_dummies::sink_dummy s; log_channel log("id", s, backend); @@ -308,21 +299,14 @@ int main() TEST_FUNCTION(when_log_channel_is_created_then_id_matches_expected_value); TEST_FUNCTION(when_log_channel_is_disabled_then_enabled_returns_false); TEST_FUNCTION(when_log_channel_is_enabled_then_enabled_returns_true); - TEST_FUNCTION( - when_logging_in_log_channel_then_log_entry_is_pushed_into_the_backend); + TEST_FUNCTION(when_logging_in_log_channel_then_log_entry_is_pushed_into_the_backend); TEST_FUNCTION(when_logging_in_disabled_log_channel_then_log_entry_is_ignored); - TEST_FUNCTION( - when_logging_then_filled_in_log_entry_is_pushed_into_the_backend); - TEST_FUNCTION( - when_logging_with_hex_dump_then_filled_in_log_entry_is_pushed_into_the_backend); - TEST_FUNCTION( - when_hex_array_length_is_less_than_hex_log_max_size_then_array_length_is_used); - TEST_FUNCTION( - when_logging_with_context_then_filled_in_log_entry_is_pushed_into_the_backend); - TEST_FUNCTION( - when_logging_with_context_and_message_then_filled_in_log_entry_is_pushed_into_the_backend); - TEST_FUNCTION( - when_logging_with_small_string_then_filled_in_log_entry_is_pushed_into_the_backend); + TEST_FUNCTION(when_logging_then_filled_in_log_entry_is_pushed_into_the_backend); + TEST_FUNCTION(when_logging_with_hex_dump_then_filled_in_log_entry_is_pushed_into_the_backend); + TEST_FUNCTION(when_hex_array_length_is_less_than_hex_log_max_size_then_array_length_is_used); + TEST_FUNCTION(when_logging_with_context_then_filled_in_log_entry_is_pushed_into_the_backend); + TEST_FUNCTION(when_logging_with_context_and_message_then_filled_in_log_entry_is_pushed_into_the_backend); + TEST_FUNCTION(when_logging_with_small_string_then_filled_in_log_entry_is_pushed_into_the_backend); return 0; } diff --git a/lib/test/srslog/test_dummies.h b/lib/test/srslog/test_dummies.h index 8d78ef5d1..412f1e42b 100644 --- a/lib/test/srslog/test_dummies.h +++ b/lib/test/srslog/test_dummies.h @@ -22,45 +22,32 @@ namespace test_dummies { class log_formatter_dummy : public srslog::log_formatter { public: - void format(srslog::detail::log_entry_metadata&& metadata, - fmt::memory_buffer& buffer) override - {} + void format(srslog::detail::log_entry_metadata&& metadata, fmt::memory_buffer& buffer) override {} std::unique_ptr clone() const override { return nullptr; } private: void format_context_begin(const srslog::detail::log_entry_metadata& md, - const std::string& ctx_name, - unsigned size, - fmt::memory_buffer& buffer) override + fmt::string_view ctx_name, + unsigned size, + fmt::memory_buffer& buffer) override {} void format_context_end(const srslog::detail::log_entry_metadata& md, - const std::string& ctx_name, - fmt::memory_buffer& buffer) override - {} - void format_metric_set_begin(const std::string& set_name, - unsigned size, - unsigned level, - fmt::memory_buffer& buffer) override - {} - void format_metric_set_end(const std::string& set_name, - unsigned level, - fmt::memory_buffer& buffer) override + fmt::string_view ctx_name, + fmt::memory_buffer& buffer) override {} - void format_list_begin(const std::string& list_name, - unsigned size, - unsigned level, - fmt::memory_buffer& buffer) override + void + format_metric_set_begin(fmt::string_view set_name, unsigned size, unsigned level, fmt::memory_buffer& buffer) override {} - void format_list_end(const std::string& list_name, - unsigned level, - fmt::memory_buffer& buffer) override + void format_metric_set_end(fmt::string_view set_name, unsigned level, fmt::memory_buffer& buffer) override {} + void format_list_begin(fmt::string_view list_name, unsigned size, unsigned level, fmt::memory_buffer& buffer) override {} - void format_metric(const std::string& metric_name, - const std::string& metric_value, - const std::string& metric_units, + void format_list_end(fmt::string_view list_name, unsigned level, fmt::memory_buffer& buffer) override {} + void format_metric(fmt::string_view metric_name, + fmt::string_view metric_value, + fmt::string_view metric_units, srslog::metric_kind kind, - unsigned level, + unsigned level, fmt::memory_buffer& buffer) override {} }; @@ -69,15 +56,9 @@ private: class sink_dummy : public srslog::sink { public: - sink_dummy() : - sink(std::unique_ptr(new log_formatter_dummy)) - {} + sink_dummy() : sink(std::unique_ptr(new log_formatter_dummy)) {} - srslog::detail::error_string - write(srslog::detail::memory_buffer buffer) override - { - return {}; - } + srslog::detail::error_string write(srslog::detail::memory_buffer buffer) override { return {}; } srslog::detail::error_string flush() override { return {}; } }; @@ -91,6 +72,8 @@ public: bool push(srslog::detail::log_entry&& entry) override { return true; } bool is_running() const override { return true; } + + fmt::dynamic_format_arg_store* alloc_arg_store() override { return nullptr; } }; } // namespace test_dummies diff --git a/lib/test/srslog/text_formatter_test.cpp b/lib/test/srslog/text_formatter_test.cpp index 429f06ed1..d98a07cfe 100644 --- a/lib/test/srslog/text_formatter_test.cpp +++ b/lib/test/srslog/text_formatter_test.cpp @@ -18,23 +18,25 @@ using namespace srslog; /// Helper to build a log entry. -static detail::log_entry_metadata build_log_entry_metadata() +static detail::log_entry_metadata build_log_entry_metadata(fmt::dynamic_format_arg_store* store) { // Create a time point 50000us from epoch. using tp_ty = std::chrono::time_point; tp_ty tp(std::chrono::microseconds(50000)); - fmt::dynamic_format_arg_store store; - store.push_back(88); + if (store) { + store->push_back(88); + } - return {tp, {10, true}, "Text %d", std::move(store), "ABC", 'Z', small_str_buffer()}; + return {tp, {10, true}, "Text %d", store, "ABC", 'Z', small_str_buffer()}; } static bool when_fully_filled_log_entry_then_everything_is_formatted() { - fmt::memory_buffer buffer; - text_formatter{}.format(build_log_entry_metadata(), buffer); - std::string result = fmt::to_string(buffer); + fmt::memory_buffer buffer; + fmt::dynamic_format_arg_store store; + text_formatter{}.format(build_log_entry_metadata(&store), buffer); + std::string result = fmt::to_string(buffer); std::string expected = "00:00:00.050000 [ABC ] [Z] [ 10] Text 88\n"; ASSERT_EQ(result, expected); @@ -44,12 +46,13 @@ static bool when_fully_filled_log_entry_then_everything_is_formatted() static bool when_log_entry_without_name_is_passed_then_name_is_not_formatted() { - auto entry = build_log_entry_metadata(); - entry.log_name = ""; + fmt::dynamic_format_arg_store store; + auto entry = build_log_entry_metadata(&store); + entry.log_name = ""; fmt::memory_buffer buffer; text_formatter{}.format(std::move(entry), buffer); - std::string result = fmt::to_string(buffer); + std::string result = fmt::to_string(buffer); std::string expected = "00:00:00.050000 [Z] [ 10] Text 88\n"; ASSERT_EQ(result, expected); @@ -59,12 +62,13 @@ static bool when_log_entry_without_name_is_passed_then_name_is_not_formatted() static bool when_log_entry_without_tag_is_passed_then_tag_is_not_formatted() { - auto entry = build_log_entry_metadata(); - entry.log_tag = '\0'; + fmt::dynamic_format_arg_store store; + auto entry = build_log_entry_metadata(&store); + entry.log_tag = '\0'; fmt::memory_buffer buffer; text_formatter{}.format(std::move(entry), buffer); - std::string result = fmt::to_string(buffer); + std::string result = fmt::to_string(buffer); std::string expected = "00:00:00.050000 [ABC ] [ 10] Text 88\n"; ASSERT_EQ(result, expected); @@ -72,15 +76,15 @@ static bool when_log_entry_without_tag_is_passed_then_tag_is_not_formatted() return true; } -static bool -when_log_entry_without_context_is_passed_then_context_is_not_formatted() +static bool when_log_entry_without_context_is_passed_then_context_is_not_formatted() { - auto entry = build_log_entry_metadata(); - entry.context.enabled = false; + fmt::dynamic_format_arg_store store; + auto entry = build_log_entry_metadata(&store); + entry.context.enabled = false; fmt::memory_buffer buffer; text_formatter{}.format(std::move(entry), buffer); - std::string result = fmt::to_string(buffer); + std::string result = fmt::to_string(buffer); std::string expected = "00:00:00.050000 [ABC ] [Z] Text 88\n"; ASSERT_EQ(result, expected); @@ -90,17 +94,17 @@ when_log_entry_without_context_is_passed_then_context_is_not_formatted() static bool when_log_entry_with_hex_dump_is_passed_then_hex_dump_is_formatted() { - auto entry = build_log_entry_metadata(); + fmt::dynamic_format_arg_store store; + auto entry = build_log_entry_metadata(&store); entry.hex_dump.resize(20); std::iota(entry.hex_dump.begin(), entry.hex_dump.end(), 0); fmt::memory_buffer buffer; text_formatter{}.format(std::move(entry), buffer); - std::string result = fmt::to_string(buffer); - std::string expected = - "00:00:00.050000 [ABC ] [Z] [ 10] Text 88\n" - " 0000: 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f\n" - " 0010: 10 11 12 13\n"; + std::string result = fmt::to_string(buffer); + std::string expected = "00:00:00.050000 [ABC ] [Z] [ 10] Text 88\n" + " 0000: 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f\n" + " 0010: 10 11 12 13\n"; ASSERT_EQ(result, expected); @@ -120,11 +124,7 @@ DECLARE_METRIC_SET("ue_container", ue_set, thr_t, ip_addr_t, antenna_list_t); DECLARE_METRIC("type", entry_type_t, std::string, ""); DECLARE_METRIC("sector_id", sector_id_t, unsigned, ""); DECLARE_METRIC_LIST("ue_list", ue_list_t, std::vector); -DECLARE_METRIC_SET("sector_metrics", - sector_set, - entry_type_t, - sector_id_t, - ue_list_t); +DECLARE_METRIC_SET("sector_metrics", sector_set, entry_type_t, sector_id_t, ue_list_t); DECLARE_METRIC_LIST("sector_list", sector_list_t, std::vector); @@ -149,54 +149,33 @@ static complex_ctx_t build_complex_context() ctx.at(0).at(1).write(10.2); ctx.at(0).at(1).write("10.20.30.41"); - ctx.at(0) - .at(0) - .get() - .emplace_back(); - ctx.at(0).at(0).at(0).write( - 5.1); - ctx.at(0).at(0).at(0).write( - -11.5); - - ctx.at(0) - .at(0) - .get() - .emplace_back(); - ctx.at(0).at(0).at(1).write( - 10.1); - ctx.at(0).at(0).at(1).write( - -20.5); - - ctx.at(0) - .at(1) - .get() - .emplace_back(); - ctx.at(0).at(1).at(0).write( - 20.1); - ctx.at(0).at(1).at(0).write( - -30.5); - ctx.at(0) - .at(1) - .get() - .emplace_back(); - ctx.at(0).at(1).at(1).write( - 30.1); - ctx.at(0).at(1).at(1).write( - -40.5); + ctx.at(0).at(0).get().emplace_back(); + ctx.at(0).at(0).at(0).write(5.1); + ctx.at(0).at(0).at(0).write(-11.5); + + ctx.at(0).at(0).get().emplace_back(); + ctx.at(0).at(0).at(1).write(10.1); + ctx.at(0).at(0).at(1).write(-20.5); + + ctx.at(0).at(1).get().emplace_back(); + ctx.at(0).at(1).at(0).write(20.1); + ctx.at(0).at(1).at(0).write(-30.5); + ctx.at(0).at(1).get().emplace_back(); + ctx.at(0).at(1).at(1).write(30.1); + ctx.at(0).at(1).at(1).write(-40.5); return ctx; } -static bool -when_log_entry_with_only_context_is_passed_then_context_is_formatted() +static bool when_log_entry_with_only_context_is_passed_then_context_is_formatted() { - auto ctx = build_complex_context(); - auto entry = build_log_entry_metadata(); + auto ctx = build_complex_context(); + auto entry = build_log_entry_metadata(nullptr); entry.fmtstring = nullptr; fmt::memory_buffer buffer; text_formatter{}.format_ctx(ctx, std::move(entry), buffer); - std::string result = fmt::to_string(buffer); + std::string result = fmt::to_string(buffer); std::string expected = "00:00:00.050000 [ABC ] [Z] [ 10] Context dump for " "\"Complex Context\"\n" " > List: sector_list\n" @@ -230,22 +209,21 @@ when_log_entry_with_only_context_is_passed_then_context_is_formatted() return true; } -static bool -when_log_entry_with_context_and_message_is_passed_then_context_is_formatted() +static bool when_log_entry_with_context_and_message_is_passed_then_context_is_formatted() { - auto entry = build_log_entry_metadata(); - auto ctx = build_complex_context(); + fmt::dynamic_format_arg_store store; + auto entry = build_log_entry_metadata(&store); + auto ctx = build_complex_context(); fmt::memory_buffer buffer; text_formatter{}.format_ctx(ctx, std::move(entry), buffer); - std::string result = fmt::to_string(buffer); - std::string expected = - "00:00:00.050000 [ABC ] [Z] [ 10] [[sector_metrics_type: event, " - "sector_metrics_sector_id: 1, [ue_container_Throughput: 1.2 MB/s, " - "ue_container_Address: 10.20.30.40, [RF_SNR: 5.1 dB, RF_PWR: -11 " - "dBm][RF_SNR: 10.1 dB, RF_PWR: -20 dBm]][ue_container_Throughput: 10.2 " - "MB/s, ue_container_Address: 10.20.30.41, [RF_SNR: 20.1 dB, RF_PWR: -30 " - "dBm][RF_SNR: 30.1 dB, RF_PWR: -40 dBm]]]]: Text 88\n"; + std::string result = fmt::to_string(buffer); + std::string expected = "00:00:00.050000 [ABC ] [Z] [ 10] [[sector_metrics_type: event, " + "sector_metrics_sector_id: 1, [ue_container_Throughput: 1.2 MB/s, " + "ue_container_Address: 10.20.30.40, [RF_SNR: 5.1 dB, RF_PWR: -11 " + "dBm][RF_SNR: 10.1 dB, RF_PWR: -20 dBm]][ue_container_Throughput: 10.2 " + "MB/s, ue_container_Address: 10.20.30.41, [RF_SNR: 20.1 dB, RF_PWR: -30 " + "dBm][RF_SNR: 30.1 dB, RF_PWR: -40 dBm]]]]: Text 88\n"; ASSERT_EQ(result, expected); @@ -255,17 +233,12 @@ when_log_entry_with_context_and_message_is_passed_then_context_is_formatted() int main() { TEST_FUNCTION(when_fully_filled_log_entry_then_everything_is_formatted); - TEST_FUNCTION( - when_log_entry_without_name_is_passed_then_name_is_not_formatted); + TEST_FUNCTION(when_log_entry_without_name_is_passed_then_name_is_not_formatted); TEST_FUNCTION(when_log_entry_without_tag_is_passed_then_tag_is_not_formatted); - TEST_FUNCTION( - when_log_entry_without_context_is_passed_then_context_is_not_formatted); - TEST_FUNCTION( - when_log_entry_with_hex_dump_is_passed_then_hex_dump_is_formatted); - TEST_FUNCTION( - when_log_entry_with_only_context_is_passed_then_context_is_formatted); - TEST_FUNCTION( - when_log_entry_with_context_and_message_is_passed_then_context_is_formatted); + TEST_FUNCTION(when_log_entry_without_context_is_passed_then_context_is_not_formatted); + TEST_FUNCTION(when_log_entry_with_hex_dump_is_passed_then_hex_dump_is_formatted); + TEST_FUNCTION(when_log_entry_with_only_context_is_passed_then_context_is_formatted); + TEST_FUNCTION(when_log_entry_with_context_and_message_is_passed_then_context_is_formatted); return 0; } From c5bb522f11fc7133f582003ed2a2c0e6e549b566 Mon Sep 17 00:00:00 2001 From: Xavier Arteaga Date: Fri, 19 Feb 2021 19:40:19 +0100 Subject: [PATCH 16/48] SRSENB: Add PHY UE DB return codes --- srsenb/hdr/phy/phy_ue_db.h | 42 +++++++++------- srsenb/src/phy/lte/cc_worker.cc | 34 ++++++++++--- srsenb/src/phy/lte/sf_worker.cc | 4 +- srsenb/src/phy/phy.cc | 4 +- srsenb/src/phy/phy_ue_db.cc | 85 ++++++++++++++++++++++----------- 5 files changed, 116 insertions(+), 53 deletions(-) diff --git a/srsenb/hdr/phy/phy_ue_db.h b/srsenb/hdr/phy/phy_ue_db.h index d1a477f29..87aefbf4c 100644 --- a/srsenb/hdr/phy/phy_ue_db.h +++ b/srsenb/hdr/phy/phy_ue_db.h @@ -74,7 +74,7 @@ private: /** * Cell information for the UE database */ - typedef struct { + struct cell_info_t { cell_state_t state = cell_state_none; ///< Configuration state uint32_t enb_cc_idx = 0; ///< Corresponding eNb cell/carrier index uint8_t last_ri = 0; ///< Last reported rank indicator @@ -123,8 +123,9 @@ private: * Internal RNTI addition, it is not thread safe protected * * @param rnti identifier of the UE + * @return SRSLTE_SUCCESS if the RNTI is not duplicated and is added successfully, SRSLTE_ERROR code if it exists */ - inline void _add_rnti(uint16_t rnti); + inline int _add_rnti(uint16_t rnti); /** * Internal pending ACK clear for a given RNTI and TTI, it is not thread safe protected @@ -221,7 +222,8 @@ private: * * @param rnti provides UE identifier * @param enb_cc_idx eNb cell index - * @return The PHY configuration of the indicated UE for the indicated eNb carrier/call index. + * @param[out] phy_cfg The PHY configuration of the indicated UE for the indicated eNb carrier/call index. + * @return SRSLTE_SUCCESS if provided context is correct, SRSLTE_ERROR code otherwise */ inline srsran::phy_cfg_t _get_rnti_config(uint16_t rnti, uint32_t enb_cc_idx) const; @@ -255,16 +257,18 @@ public: * Removes a whole UE entry from the UE database * * @param rnti identifier of the UE + * @return SRSLTE_SUCCESS if provided RNTI exists, SRSLTE_ERROR code otherwise */ - void rem_rnti(uint16_t rnti); + int rem_rnti(uint16_t rnti); /** * Stack callback for indicating the completion of the configuration process and apply the stashed configuration in * the primary cell. * * @param rnti identifier of the user + * @return SRSLTE_SUCCESS if provided RNTI exists, SRSLTE_ERROR code otherwise */ - void complete_config(uint16_t rnti); + int complete_config(uint16_t rnti); /** * Activates or deactivates configured secondary cells for a given RNTI and SCell index (UE SCell index), index 0 is @@ -272,30 +276,25 @@ public: * @param rnti identifier of the UE * @param scell_idx * @param activate + * @return SRSLTE_SUCCESS if provided RNTI exists in the given cell, SRSLTE_ERROR code otherwise */ - void activate_deactivate_scell(uint16_t rnti, uint32_t ue_cc_idx, bool activate); + int activate_deactivate_scell(uint16_t rnti, uint32_t ue_cc_idx, bool activate); /** * Asserts a given eNb cell is PCell of the given RNTI * @param rnti identifier of the UE * @param enb_cc_idx eNb cell/carrier index - * @return It returns true if it is the primmary cell, othwerwise it returns false + * @return It returns true if it is the primary cell, otherwise it returns false */ bool is_pcell(uint16_t rnti, uint32_t enb_cc_idx) const; - /** - * Asserts a given eNb cell is part of the given RNTI - * @param rnti identifier of the UE - * @param enb_cc_idx eNb cell/carrier index - * @return It returns true if the cell is part of the UE, othwerwise it returns false - */ - bool ue_has_cell(uint16_t rnti, uint32_t enb_cc_idx) const; - /** * Get the current down-link physical layer configuration for an RNTI and an eNb cell/carrier * * @param rnti identifier of the UE * @param cc_idx the eNb cell/carrier identifier + * @param[out] dl_cfg Current DL PHY configuration + * @return SRSLTE_SUCCESS if provided RNTI exists in the given cell, SRSLTE_ERROR code otherwise */ srsran_dl_cfg_t get_dl_config(uint16_t rnti, uint32_t enb_cc_idx) const; @@ -304,6 +303,8 @@ public: * * @param rnti identifier of the UE * @param cc_idx the eNb cell/carrier identifier + * @param[out] dci_cfg Current DL-DCI configuration + * @return SRSLTE_SUCCESS if provided RNTI exists in the given cell, SRSLTE_ERROR code otherwise */ srsran_dci_cfg_t get_dci_dl_config(uint16_t rnti, uint32_t enb_cc_idx) const; @@ -312,6 +313,8 @@ public: * * @param rnti identifier of the UE * @param cc_idx the eNb cell/carrier identifier + * @param[out] ul_cfg Current UL PHY configuration + * @return SRSLTE_SUCCESS if provided RNTI exists in the given cell, SRSLTE_ERROR code otherwise */ srsran_ul_cfg_t get_ul_config(uint16_t rnti, uint32_t enb_cc_idx) const; @@ -320,6 +323,8 @@ public: * * @param rnti identifier of the UE * @param cc_idx the eNb cell/carrier identifier + * @param[out] dci_cfg Current UL-DCI configuration + * @return SRSLTE_SUCCESS if provided RNTI exists in the given cell, SRSLTE_ERROR code otherwise */ srsran_dci_cfg_t get_dci_ul_config(uint16_t rnti, uint32_t enb_cc_idx) const; @@ -362,6 +367,7 @@ public: * @param rnti is the UE identifier * @param uci_cfg is the UCI configuration * @param uci_value is the UCI received value + * @return SRSLTE_SUCCESS if provided RNTI exists in the given cell, SRSLTE_ERROR code otherwise */ void send_uci_data(uint32_t tti, uint16_t rnti, @@ -377,6 +383,7 @@ public: * @param enb_cc_idx the cell/carrier origin of the transmission * @param pid HARQ process identifier * @param tb the Resource Allocation for the PUSCH transport block + * @return SRSLTE_SUCCESS if provided RNTI exists in the given cell, SRSLTE_ERROR code otherwise */ void set_last_ul_tb(uint16_t rnti, uint32_t enb_cc_idx, uint32_t pid, srsran_ra_tb_t tb); @@ -388,7 +395,8 @@ public: * @param rnti the UE temporal ID * @param cc_idx the cell/carrier origin of the transmission * @param pid HARQ process identifier - * @return the Resource Allocation for the PUSCH transport block + * @param[out] ra_tb the Resource Allocation for the PUSCH transport block + * @return SRSLTE_SUCCESS if the provided context is valid */ srsran_ra_tb_t get_last_ul_tb(uint16_t rnti, uint32_t enb_cc_idx, uint32_t pid) const; @@ -398,7 +406,7 @@ public: * @param rnti * @param enb_cc_idx */ - void set_ul_grant_available(uint32_t tti, const stack_interface_phy_lte::ul_sched_list_t& ul_sched_list); + int set_ul_grant_available(uint32_t tti, const stack_interface_phy_lte::ul_sched_list_t& ul_sched_list); }; } // namespace srsenb diff --git a/srsenb/src/phy/lte/cc_worker.cc b/srsenb/src/phy/lte/cc_worker.cc index 9341eb34f..c4acee6ca 100644 --- a/srsenb/src/phy/lte/cc_worker.cc +++ b/srsenb/src/phy/lte/cc_worker.cc @@ -262,7 +262,7 @@ void cc_worker::decode_pusch_rnti(stack_interface_phy_lte::ul_sched_grant_t& ul_ uint16_t rnti = ul_grant.dci.rnti; // Invalid RNTI - if (rnti == 0) { + if (rnti == SRSLTE_INVALID_RNTI) { return; } @@ -272,7 +272,10 @@ void cc_worker::decode_pusch_rnti(stack_interface_phy_lte::ul_sched_grant_t& ul_ } // Get UE configuration - ul_cfg = phy->ue_db.get_ul_config(rnti, cc_idx); + if (phy->ue_db.get_ul_config(rnti, cc_idx, ul_cfg) < SRSLTE_SUCCESS) { + Error("Error retrieving UL configuration for RNTI %x and CC %d", rnti, cc_idx); + return; + } // Fill UCI configuration bool uci_required = @@ -288,8 +291,11 @@ void cc_worker::decode_pusch_rnti(stack_interface_phy_lte::ul_sched_grant_t& ul_ // Handle Format0 adaptive retx // Use last TBS for this TB in case of mcs>28 if (ul_grant.dci.tb.mcs_idx > 28) { - int rv_idx = grant.tb.rv; - grant.tb = phy->ue_db.get_last_ul_tb(rnti, cc_idx, ul_grant.pid); + int rv_idx = grant.tb.rv; + if (phy->ue_db.get_last_ul_tb(rnti, cc_idx, ul_grant.pid, grant.tb) < SRSLTE_SUCCESS) { + Error("Error retrieving last UL TB for RNTI %x, CC %d, PID %d", rnti, cc_idx, ul_grant.pid); + return; + } grant.tb.rv = rv_idx; Info("Adaptive retx: rnti=0x%x, pid=%d, rv_idx=%d, mcs=%d, old_tbs=%d", rnti, @@ -298,7 +304,10 @@ void cc_worker::decode_pusch_rnti(stack_interface_phy_lte::ul_sched_grant_t& ul_ ul_grant.dci.tb.mcs_idx, grant.tb.tbs / 8); } - phy->ue_db.set_last_ul_tb(rnti, cc_idx, ul_grant.pid, grant.tb); + + if (phy->ue_db.set_last_ul_tb(rnti, cc_idx, ul_grant.pid, grant.tb) < SRSLTE_SUCCESS) { + Error("Error setting last UL TB for RNTI %x, CC %d, PID %d", rnti, cc_idx, ul_grant.pid); + } // Run PUSCH decoder ul_cfg.pusch.softbuffers.rx = ul_grant.softbuffer_rx; @@ -380,7 +389,14 @@ int cc_worker::decode_pucch() srsran_ul_cfg_t ul_cfg = phy->ue_db.get_ul_config(rnti, cc_idx); // Check if user needs to receive PUCCH - if (phy->ue_db.fill_uci_cfg(tti_rx, cc_idx, rnti, false, false, ul_cfg.pucch.uci_cfg)) { + int ret = phy->ue_db.fill_uci_cfg(tti_rx, cc_idx, rnti, false, false, ul_cfg.pucch.uci_cfg); + if (ret < SRSLTE_SUCCESS) { + Error("Error retrieving UCI configuration for RNTI %x, CC %d", rnti, cc_idx); + continue; + } + + // If ret is more than success, UCI is present + if (ret > SRSLTE_SUCCESS) { // Decode PUCCH if (srsran_enb_ul_get_pucch(&enb_ul, &ul_sf, &ul_cfg.pucch, &pucch_res)) { ERROR("Error getting PUCCH"); @@ -388,7 +404,10 @@ int cc_worker::decode_pucch() } // Send UCI data to MAC - phy->ue_db.send_uci_data(tti_rx, rnti, cc_idx, ul_cfg.pucch.uci_cfg, pucch_res.uci_data); + if (phy->ue_db.send_uci_data(tti_rx, rnti, cc_idx, ul_cfg.pucch.uci_cfg, pucch_res.uci_data) < SRSLTE_SUCCESS) { + Error("Error sending UCI data for RNTI %x, CC %d", rnti, cc_idx); + continue; + } if (pucch_res.detected and pucch_res.ta_valid) { phy->stack->ta_info(tti_rx, rnti, pucch_res.ta_us); @@ -531,6 +550,7 @@ int cc_worker::encode_pdsch(stack_interface_phy_lte::dl_sched_grant_t* grants, u if (srsran_ra_dl_dci_to_grant( &enb_dl.cell, &dl_sf, dl_cfg.tm, dl_cfg.pdsch.use_tbs_index_alt, &grants[i].dci, &dl_cfg.pdsch.grant)) { Error("Computing DL grant"); + continue; } // Set soft buffer diff --git a/srsenb/src/phy/lte/sf_worker.cc b/srsenb/src/phy/lte/sf_worker.cc index aae91b8a7..19a4a0981 100644 --- a/srsenb/src/phy/lte/sf_worker.cc +++ b/srsenb/src/phy/lte/sf_worker.cc @@ -184,7 +184,9 @@ void sf_worker::work_imp() ul_sf.tti = tti_rx; // Set UL grant availability prior to any UL processing - phy->ue_db.set_ul_grant_available(tti_rx, ul_grants); + if (phy->ue_db.set_ul_grant_available(tti_rx, ul_grants)) { + Error("Error setting UL grants. Some grant's RNTI does not exist."); + } // Process UL for (uint32_t cc = 0; cc < cc_workers.size(); cc++) { diff --git a/srsenb/src/phy/phy.cc b/srsenb/src/phy/phy.cc index 1a2487475..13790aeba 100644 --- a/srsenb/src/phy/phy.cc +++ b/srsenb/src/phy/phy.cc @@ -248,7 +248,9 @@ void phy::set_config(uint16_t rnti, const phy_rrc_cfg_list_t& phy_cfg_list) void phy::complete_config(uint16_t rnti) { // Forwards call to the UE Database - workers_common.ue_db.complete_config(rnti); + if (workers_common.ue_db.complete_config(rnti) < SRSLTE_SUCCESS) { + Error("Error completing configuration for RNTI %x. It does not exist.", rnti); + } } void phy::configure_mbsfn(srsran::sib2_mbms_t* sib2, srsran::sib13_t* sib13, const srsran::mcch_msg_t& mcch) diff --git a/srsenb/src/phy/phy_ue_db.cc b/srsenb/src/phy/phy_ue_db.cc index 82f243c30..0f614c4bf 100644 --- a/srsenb/src/phy/phy_ue_db.cc +++ b/srsenb/src/phy/phy_ue_db.cc @@ -23,13 +23,13 @@ void phy_ue_db::init(stack_interface_phy_lte* stack_ptr, cell_cfg_list = &cell_cfg_list_; } -inline void phy_ue_db::_add_rnti(uint16_t rnti) +inline int phy_ue_db::_add_rnti(uint16_t rnti) { // Private function not mutexed // Assert RNTI does NOT exist if (ue_db.count(rnti)) { - return; + return SRSLTE_ERROR; } // Create new UE by accesing it @@ -51,6 +51,8 @@ inline void phy_ue_db::_add_rnti(uint16_t rnti) for (uint32_t tti = 0; tti < TTIMOD_SZ; tti++) { _clear_tti_pending_rnti(tti, rnti); } + + return SRSLTE_SUCCESS; } inline void phy_ue_db::_clear_tti_pending_rnti(uint32_t tti, uint16_t rnti) @@ -234,13 +236,13 @@ inline srsran::phy_cfg_t phy_ue_db::_get_rnti_config(uint16_t rnti, uint32_t enb // Make sure the C-RNTI exists and the cell/carrier is configured if (_assert_enb_cc(rnti, enb_cc_idx) != SRSRAN_SUCCESS) { ERROR("Trying to access cell/carrier %d in RNTI 0x%X. It is not active.", enb_cc_idx, rnti); - return default_cfg; + return SRSLTE_ERROR; } + // Write the current configuration uint32_t ue_cc_idx = _get_ue_cc_idx(rnti, enb_cc_idx); - - // Otherwise return current configuration - return ue_db.at(rnti).cell_info.at(ue_cc_idx).phy_cfg; + phy_cfg = ue_db.at(rnti).cell_info.at(ue_cc_idx).phy_cfg; + return SRSLTE_SUCCESS; } void phy_ue_db::clear_tti_pending_ack(uint32_t tti) @@ -329,13 +331,17 @@ void phy_ue_db::addmod_rnti(uint16_t rnti, const phy_interface_rrc_lte::phy_rrc_ } } -void phy_ue_db::rem_rnti(uint16_t rnti) +int phy_ue_db::rem_rnti(uint16_t rnti) { std::lock_guard lock(mutex); - if (ue_db.count(rnti) != 0) { - ue_db.erase(rnti); + if (ue_db.count(rnti) == 0) { + return SRSLTE_ERROR; } + + ue_db.erase(rnti); + + return SRSLTE_SUCCESS; } uint32_t phy_ue_db::_count_nof_configured_scell(uint16_t rnti) @@ -350,7 +356,7 @@ uint32_t phy_ue_db::_count_nof_configured_scell(uint16_t rnti) return nof_configured_scell; } -void phy_ue_db::complete_config(uint16_t rnti) +int phy_ue_db::complete_config(uint16_t rnti) { std::lock_guard lock(mutex); @@ -368,9 +374,11 @@ void phy_ue_db::complete_config(uint16_t rnti) ue_db[rnti].cell_info[ue_cc_idx].stash_use_tbs_index_alt = ue_db[rnti].cell_info[ue_cc_idx].phy_cfg.dl_cfg.pdsch.use_tbs_index_alt; } + + return SRSLTE_SUCCESS; } -void phy_ue_db::activate_deactivate_scell(uint16_t rnti, uint32_t ue_cc_idx, bool activate) +int phy_ue_db::activate_deactivate_scell(uint16_t rnti, uint32_t ue_cc_idx, bool activate) { std::lock_guard lock(mutex); @@ -383,12 +391,11 @@ void phy_ue_db::activate_deactivate_scell(uint16_t rnti, uint32_t ue_cc_idx, boo // If scell is default only complain if (activate and cell_info.state == cell_state_none) { - ERROR("RNTI 0x%X SCell %d has received an activation MAC command but it was not configured", rnti, ue_cc_idx); - return; + return SRSLTE_ERROR; } + // Set scell state cell_info.state = (activate) ? cell_state_secondary_active : cell_state_secondary_inactive; -} bool phy_ue_db::ue_has_cell(uint16_t rnti, uint32_t enb_cc_idx) const { @@ -411,10 +418,10 @@ srsran_dl_cfg_t phy_ue_db::get_dl_config(uint16_t rnti, uint32_t enb_cc_idx) con if (ue_db.count(rnti) && SRSRAN_RNTI_ISUSER(rnti)) { uint32_t ue_cc_idx = _get_ue_cc_idx(rnti, enb_cc_idx); if (ue_cc_idx == 0) { - ret.pdsch.use_tbs_index_alt = ue_db.at(rnti).cell_info[ue_cc_idx].stash_use_tbs_index_alt; + dl_cfg.pdsch.use_tbs_index_alt = ue_db.at(rnti).cell_info[ue_cc_idx].stash_use_tbs_index_alt; } } - return ret; + return SRSLTE_SUCCESS; } srsran_dci_cfg_t phy_ue_db::get_dci_dl_config(uint16_t rnti, uint32_t enb_cc_idx) const @@ -427,22 +434,36 @@ srsran_dci_cfg_t phy_ue_db::get_dci_dl_config(uint16_t rnti, uint32_t enb_cc_idx if (ue_db.count(rnti) && SRSRAN_RNTI_ISUSER(rnti)) { uint32_t ue_cc_idx = _get_ue_cc_idx(rnti, enb_cc_idx); if (ue_cc_idx == 0) { - ret.multiple_csi_request_enabled = ue_db.at(rnti).stashed_multiple_csi_request_enabled; + dci_cfg.multiple_csi_request_enabled = ue_db.at(rnti).stashed_multiple_csi_request_enabled; } } - return ret; + return SRSLTE_SUCCESS; } srsran_ul_cfg_t phy_ue_db::get_ul_config(uint16_t rnti, uint32_t enb_cc_idx) const { std::lock_guard lock(mutex); - return _get_rnti_config(rnti, enb_cc_idx).ul_cfg; + srslte::phy_cfg_t phy_cfg = {}; + + if (_get_rnti_config(rnti, enb_cc_idx, phy_cfg) < SRSLTE_SUCCESS) { + return SRSLTE_ERROR; + } + ul_cfg = phy_cfg.ul_cfg; + + return SRSLTE_SUCCESS; } srsran_dci_cfg_t phy_ue_db::get_dci_ul_config(uint16_t rnti, uint32_t enb_cc_idx) const { std::lock_guard lock(mutex); - return _get_rnti_config(rnti, enb_cc_idx).dl_cfg.dci; + srslte::phy_cfg_t phy_cfg = {}; + + if (_get_rnti_config(rnti, enb_cc_idx, phy_cfg) < SRSLTE_SUCCESS) { + return SRSLTE_ERROR; + } + dci_cfg = phy_cfg.dl_cfg.dci; + + return SRSLTE_SUCCESS; } bool phy_ue_db::set_ack_pending(uint32_t tti, uint32_t enb_cc_idx, const srsran_dci_dl_t& dci) @@ -509,17 +530,17 @@ int phy_ue_db::fill_uci_cfg(uint32_t tti, // There is a PUSCH grant available for the provided RNTI in at least one serving cell and this call is for PUCCH if (pusch_grant_available and not is_pusch_available) { - return 0; + return SRSLTE_SUCCESS; } // There is a PUSCH grant and enb_cc_idx with lowest ue_cc_idx with a grant if (pusch_grant_available and uci_enb_cc_id != enb_cc_idx) { - return 0; + return SRSLTE_SUCCESS; } // No PUSCH grant for this TTI and cell and no enb_cc_idx is not the PCell if (not pusch_grant_available and _get_ue_cc_idx(rnti, enb_cc_idx) != 0) { - return 0; + return SRSLTE_SUCCESS; } common_ue& ue = ue_db.at(rnti); @@ -570,7 +591,7 @@ int phy_ue_db::fill_uci_cfg(uint32_t tti, uci_required |= (srsran_uci_cfg_total_ack(&uci_cfg) > 0); // Return whether UCI needs to be decoded - return uci_required ? 1 : 0; + return uci_required ? 1 : SRSLTE_SUCCESS; } void phy_ue_db::send_uci_data(uint32_t tti, @@ -671,6 +692,8 @@ void phy_ue_db::send_uci_data(uint32_t tti, stack->ri_info(tti, rnti, cqi_cc_idx, uci_value.ri); cqi_scell_info.last_ri = uci_value.ri; } + + return SRSLTE_SUCCESS; } void phy_ue_db::set_last_ul_tb(uint16_t rnti, uint32_t enb_cc_idx, uint32_t pid, srsran_ra_tb_t tb) @@ -684,6 +707,8 @@ void phy_ue_db::set_last_ul_tb(uint16_t rnti, uint32_t enb_cc_idx, uint32_t pid, // Save resource allocation ue_db.at(rnti).cell_info[_get_ue_cc_idx(rnti, enb_cc_idx)].last_tb[pid] = tb; + + return SRSLTE_SUCCESS; } srsran_ra_tb_t phy_ue_db::get_last_ul_tb(uint16_t rnti, uint32_t enb_cc_idx, uint32_t pid) const @@ -695,11 +720,13 @@ srsran_ra_tb_t phy_ue_db::get_last_ul_tb(uint16_t rnti, uint32_t enb_cc_idx, uin return {}; } - // Returns the latest stored UL transmission grant - return ue_db.at(rnti).cell_info[_get_ue_cc_idx(rnti, enb_cc_idx)].last_tb[pid]; + // writes the latest stored UL transmission grant + ra_tb = ue_db.at(rnti).cell_info[_get_ue_cc_idx(rnti, enb_cc_idx)].last_tb[pid]; + + return SRSLTE_SUCCESS; } -void phy_ue_db::set_ul_grant_available(uint32_t tti, const stack_interface_phy_lte::ul_sched_list_t& ul_sched_list) +int phy_ue_db::set_ul_grant_available(uint32_t tti, const stack_interface_phy_lte::ul_sched_list_t& ul_sched_list) { std::lock_guard lock(mutex); @@ -721,6 +748,10 @@ void phy_ue_db::set_ul_grant_available(uint32_t tti, const stack_interface_phy_l // Rise Grant available flag ue_db[rnti].cell_info[_get_ue_cc_idx(rnti, enb_cc_idx)].is_grant_available[tti] = true; } + // Rise Grant available flag + ue_db[rnti].cell_info[_get_ue_cc_idx(rnti, enb_cc_idx)].is_grant_available[tti] = true; } } + + return SRSLTE_SUCCESS; } From 7704c09ce2c40e62aedc0f82cbe63e945396cb45 Mon Sep 17 00:00:00 2001 From: Xavier Arteaga Date: Fri, 19 Feb 2021 19:40:44 +0100 Subject: [PATCH 17/48] Fix typos --- lib/src/phy/phch/dci_nr.c | 6 +++--- srsue/hdr/phy/scell/intra_measure.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/src/phy/phch/dci_nr.c b/lib/src/phy/phch/dci_nr.c index a6c9b205d..6ba0e51ed 100644 --- a/lib/src/phy/phch/dci_nr.c +++ b/lib/src/phy/phch/dci_nr.c @@ -156,7 +156,7 @@ int srsran_dci_nr_format_0_0_pack(const srsran_carrier_nr_t* carrier, *(y++) = 0; } - // UL/SUL indicator – 1 bit for UEs configured with supplementaryUplink in ServingCellConfig, othwerwise 0 + // UL/SUL indicator – 1 bit for UEs configured with supplementaryUplink in ServingCellConfig, otherwise 0 if (supplementary_uplink) { *(y++) = 0; } @@ -250,7 +250,7 @@ int srsran_dci_nr_format_0_0_unpack(const srsran_carrier_nr_t* carrier, y++; } - // UL/SUL indicator – 1 bit for UEs configured with supplementaryUplink in ServingCellConfig, othwerwise 0 + // UL/SUL indicator – 1 bit for UEs configured with supplementaryUplink in ServingCellConfig, otherwise 0 if (supplementary_uplink) { y++; } @@ -306,7 +306,7 @@ int srsran_dci_nr_format_0_0_sizeof(const srsran_carrier_nr_t* carrier, // Padding goes here count += padding; - // UL/SUL indicator – 1 bit for UEs configured with supplementaryUplink in ServingCellConfig, othwerwise 0 + // UL/SUL indicator – 1 bit for UEs configured with supplementaryUplink in ServingCellConfig, otherwise 0 if (supplementary_uplink) { count++; } diff --git a/srsue/hdr/phy/scell/intra_measure.h b/srsue/hdr/phy/scell/intra_measure.h index cda0204fa..cff540036 100644 --- a/srsue/hdr/phy/scell/intra_measure.h +++ b/srsue/hdr/phy/scell/intra_measure.h @@ -77,7 +77,7 @@ public: void stop(); /** - * Sets the primmary cell, configures the cell bandwidth and sampling rate + * Sets the primary cell, configures the cell bandwidth and sampling rate * @param earfcn Frequency the component is receiving base-band from. Used only for reporting the EARFCN to the RRC * @param cell Actual cell configuration */ From cade7c810482effa6d87bec60c297fbc83abba42 Mon Sep 17 00:00:00 2001 From: Xavier Arteaga Date: Fri, 19 Feb 2021 19:44:16 +0100 Subject: [PATCH 18/48] Removed redundant error traces --- srsenb/hdr/phy/phy_ue_db.h | 52 ++++++------- srsenb/src/phy/lte/cc_worker.cc | 50 +++++++++---- srsenb/src/phy/phy.cc | 2 +- srsenb/src/phy/phy_ue_db.cc | 128 +++++++++++++++++--------------- 4 files changed, 129 insertions(+), 103 deletions(-) diff --git a/srsenb/hdr/phy/phy_ue_db.h b/srsenb/hdr/phy/phy_ue_db.h index 87aefbf4c..01fedcf29 100644 --- a/srsenb/hdr/phy/phy_ue_db.h +++ b/srsenb/hdr/phy/phy_ue_db.h @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2021 Software Radio Systems Limited + * Copyright 2013-2020 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -83,7 +83,7 @@ private: bool stash_use_tbs_index_alt = false; srsran::phy_cfg_t phy_cfg; ///< Configuration, it has a default constructor srsran::circular_array is_grant_available; ///< Indicates whether there is an available grant - } cell_info_t; + }; /** * UE object stored in the PHY common database @@ -123,7 +123,7 @@ private: * Internal RNTI addition, it is not thread safe protected * * @param rnti identifier of the UE - * @return SRSLTE_SUCCESS if the RNTI is not duplicated and is added successfully, SRSLTE_ERROR code if it exists + * @return SRSRAN_SUCCESS if the RNTI is not duplicated and is added successfully, SRSRAN_ERROR code if it exists */ inline int _add_rnti(uint16_t rnti); @@ -223,9 +223,9 @@ private: * @param rnti provides UE identifier * @param enb_cc_idx eNb cell index * @param[out] phy_cfg The PHY configuration of the indicated UE for the indicated eNb carrier/call index. - * @return SRSLTE_SUCCESS if provided context is correct, SRSLTE_ERROR code otherwise + * @return SRSRAN_SUCCESS if provided context is correct, SRSRAN_ERROR code otherwise */ - inline srsran::phy_cfg_t _get_rnti_config(uint16_t rnti, uint32_t enb_cc_idx) const; + inline int _get_rnti_config(uint16_t rnti, uint32_t enb_cc_idx, srsran::phy_cfg_t& phy_cfg) const; /** * Count number of configured secondary serving cells @@ -257,7 +257,7 @@ public: * Removes a whole UE entry from the UE database * * @param rnti identifier of the UE - * @return SRSLTE_SUCCESS if provided RNTI exists, SRSLTE_ERROR code otherwise + * @return SRSRAN_SUCCESS if provided RNTI exists, SRSRAN_ERROR code otherwise */ int rem_rnti(uint16_t rnti); @@ -266,7 +266,7 @@ public: * the primary cell. * * @param rnti identifier of the user - * @return SRSLTE_SUCCESS if provided RNTI exists, SRSLTE_ERROR code otherwise + * @return SRSRAN_SUCCESS if provided RNTI exists, SRSRAN_ERROR code otherwise */ int complete_config(uint16_t rnti); @@ -276,7 +276,7 @@ public: * @param rnti identifier of the UE * @param scell_idx * @param activate - * @return SRSLTE_SUCCESS if provided RNTI exists in the given cell, SRSLTE_ERROR code otherwise + * @return SRSRAN_SUCCESS if provided RNTI exists in the given cell, SRSRAN_ERROR code otherwise */ int activate_deactivate_scell(uint16_t rnti, uint32_t ue_cc_idx, bool activate); @@ -294,9 +294,9 @@ public: * @param rnti identifier of the UE * @param cc_idx the eNb cell/carrier identifier * @param[out] dl_cfg Current DL PHY configuration - * @return SRSLTE_SUCCESS if provided RNTI exists in the given cell, SRSLTE_ERROR code otherwise + * @return SRSRAN_SUCCESS if provided RNTI exists in the given cell, SRSRAN_ERROR code otherwise */ - srsran_dl_cfg_t get_dl_config(uint16_t rnti, uint32_t enb_cc_idx) const; + int get_dl_config(uint16_t rnti, uint32_t enb_cc_idx, srsran_dl_cfg_t& dl_cfg) const; /** * Get the current DCI configuration for PDSCH physical layer configuration for an RNTI and an eNb cell/carrier @@ -304,9 +304,9 @@ public: * @param rnti identifier of the UE * @param cc_idx the eNb cell/carrier identifier * @param[out] dci_cfg Current DL-DCI configuration - * @return SRSLTE_SUCCESS if provided RNTI exists in the given cell, SRSLTE_ERROR code otherwise + * @return SRSRAN_SUCCESS if provided RNTI exists in the given cell, SRSRAN_ERROR code otherwise */ - srsran_dci_cfg_t get_dci_dl_config(uint16_t rnti, uint32_t enb_cc_idx) const; + int get_dci_dl_config(uint16_t rnti, uint32_t enb_cc_idx, srsran_dci_cfg_t& dci_cfg) const; /** * Get the current PUCCH physical layer configuration for an RNTI and an eNb cell/carrier. @@ -314,9 +314,9 @@ public: * @param rnti identifier of the UE * @param cc_idx the eNb cell/carrier identifier * @param[out] ul_cfg Current UL PHY configuration - * @return SRSLTE_SUCCESS if provided RNTI exists in the given cell, SRSLTE_ERROR code otherwise + * @return SRSRAN_SUCCESS if provided RNTI exists in the given cell, SRSRAN_ERROR code otherwise */ - srsran_ul_cfg_t get_ul_config(uint16_t rnti, uint32_t enb_cc_idx) const; + int get_ul_config(uint16_t rnti, uint32_t enb_cc_idx, srsran_ul_cfg_t& ul_cfg) const; /** * Get the current DCI configuration for PUSCH physical layer configuration for an RNTI and an eNb cell/carrier @@ -324,9 +324,9 @@ public: * @param rnti identifier of the UE * @param cc_idx the eNb cell/carrier identifier * @param[out] dci_cfg Current UL-DCI configuration - * @return SRSLTE_SUCCESS if provided RNTI exists in the given cell, SRSLTE_ERROR code otherwise + * @return SRSRAN_SUCCESS if provided RNTI exists in the given cell, SRSRAN_ERROR code otherwise */ - srsran_dci_cfg_t get_dci_ul_config(uint16_t rnti, uint32_t enb_cc_idx) const; + int get_dci_ul_config(uint16_t rnti, uint32_t enb_cc_idx, srsran_dci_cfg_t& dci_cfg) const; /** * Removes all the pending ACKs of all the RNTIs for a given TTI @@ -367,13 +367,13 @@ public: * @param rnti is the UE identifier * @param uci_cfg is the UCI configuration * @param uci_value is the UCI received value - * @return SRSLTE_SUCCESS if provided RNTI exists in the given cell, SRSLTE_ERROR code otherwise + * @return SRSRAN_SUCCESS if provided RNTI exists in the given cell, SRSRAN_ERROR code otherwise */ - void send_uci_data(uint32_t tti, - uint16_t rnti, - uint32_t enb_cc_idx, - const srsran_uci_cfg_t& uci_cfg, - const srsran_uci_value_t& uci_value); + int send_uci_data(uint32_t tti, + uint16_t rnti, + uint32_t enb_cc_idx, + const srsran_uci_cfg_t& uci_cfg, + const srsran_uci_value_t& uci_value); /** * Set the latest UL Transport Block resource allocation for a given RNTI, eNb cell/carrier and UL HARQ process @@ -383,9 +383,9 @@ public: * @param enb_cc_idx the cell/carrier origin of the transmission * @param pid HARQ process identifier * @param tb the Resource Allocation for the PUSCH transport block - * @return SRSLTE_SUCCESS if provided RNTI exists in the given cell, SRSLTE_ERROR code otherwise + * @return SRSRAN_SUCCESS if provided RNTI exists in the given cell, SRSRAN_ERROR code otherwise */ - void set_last_ul_tb(uint16_t rnti, uint32_t enb_cc_idx, uint32_t pid, srsran_ra_tb_t tb); + int set_last_ul_tb(uint16_t rnti, uint32_t enb_cc_idx, uint32_t pid, srsran_ra_tb_t tb); /** * Get the latest UL Transport Block resource allocation for a given RNTI, eNb cell/carrier and UL HARQ process @@ -396,9 +396,9 @@ public: * @param cc_idx the cell/carrier origin of the transmission * @param pid HARQ process identifier * @param[out] ra_tb the Resource Allocation for the PUSCH transport block - * @return SRSLTE_SUCCESS if the provided context is valid + * @return SRSRAN_SUCCESS if the provided context is valid */ - srsran_ra_tb_t get_last_ul_tb(uint16_t rnti, uint32_t enb_cc_idx, uint32_t pid) const; + int get_last_ul_tb(uint16_t rnti, uint32_t enb_cc_idx, uint32_t pid, srsran_ra_tb_t& ra_tb) const; /** * Flags to true the UL grant available for a given TTI, RNTI and eNb cell/carrier index diff --git a/srsenb/src/phy/lte/cc_worker.cc b/srsenb/src/phy/lte/cc_worker.cc index c4acee6ca..2b5227f97 100644 --- a/srsenb/src/phy/lte/cc_worker.cc +++ b/srsenb/src/phy/lte/cc_worker.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2021 Software Radio Systems Limited + * Copyright 2013-2020 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -262,7 +262,7 @@ void cc_worker::decode_pusch_rnti(stack_interface_phy_lte::ul_sched_grant_t& ul_ uint16_t rnti = ul_grant.dci.rnti; // Invalid RNTI - if (rnti == SRSLTE_INVALID_RNTI) { + if (rnti == SRSRAN_INVALID_RNTI) { return; } @@ -272,7 +272,7 @@ void cc_worker::decode_pusch_rnti(stack_interface_phy_lte::ul_sched_grant_t& ul_ } // Get UE configuration - if (phy->ue_db.get_ul_config(rnti, cc_idx, ul_cfg) < SRSLTE_SUCCESS) { + if (phy->ue_db.get_ul_config(rnti, cc_idx, ul_cfg) < SRSRAN_SUCCESS) { Error("Error retrieving UL configuration for RNTI %x and CC %d", rnti, cc_idx); return; } @@ -292,7 +292,7 @@ void cc_worker::decode_pusch_rnti(stack_interface_phy_lte::ul_sched_grant_t& ul_ // Use last TBS for this TB in case of mcs>28 if (ul_grant.dci.tb.mcs_idx > 28) { int rv_idx = grant.tb.rv; - if (phy->ue_db.get_last_ul_tb(rnti, cc_idx, ul_grant.pid, grant.tb) < SRSLTE_SUCCESS) { + if (phy->ue_db.get_last_ul_tb(rnti, cc_idx, ul_grant.pid, grant.tb) < SRSRAN_SUCCESS) { Error("Error retrieving last UL TB for RNTI %x, CC %d, PID %d", rnti, cc_idx, ul_grant.pid); return; } @@ -305,7 +305,7 @@ void cc_worker::decode_pusch_rnti(stack_interface_phy_lte::ul_sched_grant_t& ul_ grant.tb.tbs / 8); } - if (phy->ue_db.set_last_ul_tb(rnti, cc_idx, ul_grant.pid, grant.tb) < SRSLTE_SUCCESS) { + if (phy->ue_db.set_last_ul_tb(rnti, cc_idx, ul_grant.pid, grant.tb) < SRSRAN_SUCCESS) { Error("Error setting last UL TB for RNTI %x, CC %d, PID %d", rnti, cc_idx, ul_grant.pid); } @@ -386,25 +386,30 @@ int cc_worker::decode_pucch() // If it's a User RNTI and doesn't have PUSCH grant in this TTI if (SRSRAN_RNTI_ISUSER(rnti) and phy->ue_db.is_pcell(rnti, cc_idx)) { - srsran_ul_cfg_t ul_cfg = phy->ue_db.get_ul_config(rnti, cc_idx); + srsran_ul_cfg_t ul_cfg = {}; + + if (phy->ue_db.get_ul_config(rnti, cc_idx, ul_cfg) < SRSRAN_SUCCESS) { + Error("Error retrieving last UL configuration for RNTI %x, CC %d", rnti, cc_idx); + continue; + } // Check if user needs to receive PUCCH int ret = phy->ue_db.fill_uci_cfg(tti_rx, cc_idx, rnti, false, false, ul_cfg.pucch.uci_cfg); - if (ret < SRSLTE_SUCCESS) { + if (ret < SRSRAN_SUCCESS) { Error("Error retrieving UCI configuration for RNTI %x, CC %d", rnti, cc_idx); continue; } // If ret is more than success, UCI is present - if (ret > SRSLTE_SUCCESS) { + if (ret > SRSRAN_SUCCESS) { // Decode PUCCH if (srsran_enb_ul_get_pucch(&enb_ul, &ul_sf, &ul_cfg.pucch, &pucch_res)) { - ERROR("Error getting PUCCH"); - return SRSRAN_ERROR; + Error("Error getting PUCCH"); + continue; } // Send UCI data to MAC - if (phy->ue_db.send_uci_data(tti_rx, rnti, cc_idx, ul_cfg.pucch.uci_cfg, pucch_res.uci_data) < SRSLTE_SUCCESS) { + if (phy->ue_db.send_uci_data(tti_rx, rnti, cc_idx, ul_cfg.pucch.uci_cfg, pucch_res.uci_data) < SRSRAN_SUCCESS) { Error("Error sending UCI data for RNTI %x, CC %d", rnti, cc_idx); continue; } @@ -450,7 +455,12 @@ int cc_worker::encode_pdcch_ul(stack_interface_phy_lte::ul_sched_grant_t* grants { for (uint32_t i = 0; i < nof_grants; i++) { if (grants[i].needs_pdcch) { - srsran_dci_cfg_t dci_cfg = phy->ue_db.get_dci_ul_config(grants[i].dci.rnti, cc_idx); + srsran_dci_cfg_t dci_cfg = {}; + + if (phy->ue_db.get_dci_ul_config(grants[i].dci.rnti, cc_idx, dci_cfg) < SRSRAN_SUCCESS) { + Error("Error retrieving DCI UL configuration for RNTI %x, CC %d", grants[i].dci.rnti, cc_idx); + continue; + } if (SRSRAN_RNTI_ISUSER(grants[i].dci.rnti)) { if (srsran_enb_dl_location_is_common_ncce(&enb_dl, grants[i].dci.location.ncce) && @@ -461,7 +471,7 @@ int cc_worker::encode_pdcch_ul(stack_interface_phy_lte::ul_sched_grant_t* grants } if (srsran_enb_dl_put_pdcch_ul(&enb_dl, &dci_cfg, &grants[i].dci)) { - ERROR("Error putting PUSCH %d", i); + Error("Error putting PUSCH %d", i); return SRSRAN_ERROR; } @@ -481,7 +491,12 @@ int cc_worker::encode_pdcch_dl(stack_interface_phy_lte::dl_sched_grant_t* grants for (uint32_t i = 0; i < nof_grants; i++) { uint16_t rnti = grants[i].dci.rnti; if (rnti) { - srsran_dci_cfg_t dci_cfg = phy->ue_db.get_dci_dl_config(grants[i].dci.rnti, cc_idx); + srsran_dci_cfg_t dci_cfg = {}; + + if (phy->ue_db.get_dci_dl_config(grants[i].dci.rnti, cc_idx, dci_cfg) < SRSRAN_SUCCESS) { + Error("Error retrieving DCI DL configuration for RNTI %x, CC %d", grants[i].dci.rnti, cc_idx); + continue; + } if (SRSRAN_RNTI_ISUSER(grants[i].dci.rnti) && grants[i].dci.format == SRSRAN_DCI_FORMAT1A) { if (srsran_enb_dl_location_is_common_ncce(&enb_dl, grants[i].dci.location.ncce) && @@ -544,7 +559,12 @@ int cc_worker::encode_pdsch(stack_interface_phy_lte::dl_sched_grant_t* grants, u uint16_t rnti = grants[i].dci.rnti; if (rnti && ue_db.count(rnti)) { - srsran_dl_cfg_t dl_cfg = phy->ue_db.get_dl_config(rnti, cc_idx); + srsran_dl_cfg_t dl_cfg = {}; + + if (phy->ue_db.get_dl_config(rnti, cc_idx, dl_cfg) < SRSRAN_SUCCESS) { + Error("Error retrieving DCI DL configuration for RNTI %x, CC %d", grants[i].dci.rnti, cc_idx); + continue; + } // Compute DL grant if (srsran_ra_dl_dci_to_grant( diff --git a/srsenb/src/phy/phy.cc b/srsenb/src/phy/phy.cc index 13790aeba..442f7fa5a 100644 --- a/srsenb/src/phy/phy.cc +++ b/srsenb/src/phy/phy.cc @@ -248,7 +248,7 @@ void phy::set_config(uint16_t rnti, const phy_rrc_cfg_list_t& phy_cfg_list) void phy::complete_config(uint16_t rnti) { // Forwards call to the UE Database - if (workers_common.ue_db.complete_config(rnti) < SRSLTE_SUCCESS) { + if (workers_common.ue_db.complete_config(rnti) < SRSRAN_SUCCESS) { Error("Error completing configuration for RNTI %x. It does not exist.", rnti); } } diff --git a/srsenb/src/phy/phy_ue_db.cc b/srsenb/src/phy/phy_ue_db.cc index 0f614c4bf..76b0b3e3a 100644 --- a/srsenb/src/phy/phy_ue_db.cc +++ b/srsenb/src/phy/phy_ue_db.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2021 Software Radio Systems Limited + * Copyright 2013-2020 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -29,7 +29,7 @@ inline int phy_ue_db::_add_rnti(uint16_t rnti) // Assert RNTI does NOT exist if (ue_db.count(rnti)) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Create new UE by accesing it @@ -52,7 +52,7 @@ inline int phy_ue_db::_add_rnti(uint16_t rnti) _clear_tti_pending_rnti(tti, rnti); } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } inline void phy_ue_db::_clear_tti_pending_rnti(uint32_t tti, uint16_t rnti) @@ -131,7 +131,6 @@ uint32_t phy_ue_db::_get_uci_enb_cc_idx(uint32_t tti, uint16_t rnti) const inline int phy_ue_db::_assert_rnti(uint16_t rnti) const { if (not ue_db.count(rnti)) { - ERROR("Trying to access RNTI 0x%X, it does not exist.", rnti); return SRSRAN_ERROR; } @@ -220,7 +219,7 @@ inline int phy_ue_db::_assert_cell_list_cfg() const return SRSRAN_SUCCESS; } -inline srsran::phy_cfg_t phy_ue_db::_get_rnti_config(uint16_t rnti, uint32_t enb_cc_idx) const +inline int phy_ue_db::_get_rnti_config(uint16_t rnti, uint32_t enb_cc_idx, srsran::phy_cfg_t& phy_cfg) const { srsran::phy_cfg_t default_cfg = {}; default_cfg.set_defaults(); @@ -230,19 +229,19 @@ inline srsran::phy_cfg_t phy_ue_db::_get_rnti_config(uint16_t rnti, uint32_t enb // Use default configuration for non-user C-RNTI if (not SRSRAN_RNTI_ISUSER(rnti)) { - return default_cfg; + phy_cfg = default_cfg; + return SRSRAN_SUCCESS; } // Make sure the C-RNTI exists and the cell/carrier is configured if (_assert_enb_cc(rnti, enb_cc_idx) != SRSRAN_SUCCESS) { - ERROR("Trying to access cell/carrier %d in RNTI 0x%X. It is not active.", enb_cc_idx, rnti); - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Write the current configuration uint32_t ue_cc_idx = _get_ue_cc_idx(rnti, enb_cc_idx); phy_cfg = ue_db.at(rnti).cell_info.at(ue_cc_idx).phy_cfg; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } void phy_ue_db::clear_tti_pending_ack(uint32_t tti) @@ -336,12 +335,12 @@ int phy_ue_db::rem_rnti(uint16_t rnti) std::lock_guard lock(mutex); if (ue_db.count(rnti) == 0) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } ue_db.erase(rnti); - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } uint32_t phy_ue_db::_count_nof_configured_scell(uint16_t rnti) @@ -362,7 +361,7 @@ int phy_ue_db::complete_config(uint16_t rnti) // Makes sure the RNTI exists if (_assert_rnti(rnti) != SRSRAN_SUCCESS) { - return; + return SRSRAN_ERROR; } // Once the reconfiguration is complete, the temporary parameters become the new ones @@ -375,7 +374,7 @@ int phy_ue_db::complete_config(uint16_t rnti) ue_db[rnti].cell_info[ue_cc_idx].phy_cfg.dl_cfg.pdsch.use_tbs_index_alt; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int phy_ue_db::activate_deactivate_scell(uint16_t rnti, uint32_t ue_cc_idx, bool activate) @@ -384,22 +383,20 @@ int phy_ue_db::activate_deactivate_scell(uint16_t rnti, uint32_t ue_cc_idx, bool // Assert RNTI and SCell are valid if (_assert_ue_cc(rnti, ue_cc_idx) != SRSRAN_SUCCESS) { - return; + return SRSRAN_SUCCESS; } cell_info_t& cell_info = ue_db[rnti].cell_info[ue_cc_idx]; // If scell is default only complain if (activate and cell_info.state == cell_state_none) { - return SRSLTE_ERROR; + return SRSRAN_ERROR; } // Set scell state cell_info.state = (activate) ? cell_state_secondary_active : cell_state_secondary_inactive; -bool phy_ue_db::ue_has_cell(uint16_t rnti, uint32_t enb_cc_idx) const -{ - return _assert_enb_cc(rnti, enb_cc_idx) == SRSRAN_SUCCESS; + return SRSRAN_SUCCESS; } bool phy_ue_db::is_pcell(uint16_t rnti, uint32_t enb_cc_idx) const @@ -408,10 +405,15 @@ bool phy_ue_db::is_pcell(uint16_t rnti, uint32_t enb_cc_idx) const return _assert_enb_pcell(rnti, enb_cc_idx) == SRSRAN_SUCCESS; } -srsran_dl_cfg_t phy_ue_db::get_dl_config(uint16_t rnti, uint32_t enb_cc_idx) const +int phy_ue_db::get_dl_config(uint16_t rnti, uint32_t enb_cc_idx, srsran_dl_cfg_t& dl_cfg) const { std::lock_guard lock(mutex); - srsran_dl_cfg_t ret = _get_rnti_config(rnti, enb_cc_idx).dl_cfg; + srsran::phy_cfg_t phy_cfg = {}; + + if (_get_rnti_config(rnti, enb_cc_idx, phy_cfg) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; + } + dl_cfg = phy_cfg.dl_cfg; // The DL configuration must overwrite the use_tbs_index_alt value (for 256QAM) with the temporary value // in case we are in the middle of a reconfiguration @@ -421,49 +423,54 @@ srsran_dl_cfg_t phy_ue_db::get_dl_config(uint16_t rnti, uint32_t enb_cc_idx) con dl_cfg.pdsch.use_tbs_index_alt = ue_db.at(rnti).cell_info[ue_cc_idx].stash_use_tbs_index_alt; } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -srsran_dci_cfg_t phy_ue_db::get_dci_dl_config(uint16_t rnti, uint32_t enb_cc_idx) const +int phy_ue_db::get_dci_dl_config(uint16_t rnti, uint32_t enb_cc_idx, srsran_dci_cfg_t& dci_cfg) const { std::lock_guard lock(mutex); - srsran_dci_cfg_t ret = _get_rnti_config(rnti, enb_cc_idx).dl_cfg.dci; + srsran::phy_cfg_t phy_cfg = {}; - // The DCI configuration used for DL grants must overwrite the multiple_csi_request_enabled value with the temporary - // value in case we are in the middle of a reconfiguration + if (_get_rnti_config(rnti, enb_cc_idx, phy_cfg) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; + } + dci_cfg = phy_cfg.dl_cfg.dci; + + // The DCI configuration used for DL grants must overwrite the multiple_csi_request_enabled value with the + // temporary value in case we are in the middle of a reconfiguration if (ue_db.count(rnti) && SRSRAN_RNTI_ISUSER(rnti)) { uint32_t ue_cc_idx = _get_ue_cc_idx(rnti, enb_cc_idx); if (ue_cc_idx == 0) { dci_cfg.multiple_csi_request_enabled = ue_db.at(rnti).stashed_multiple_csi_request_enabled; } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -srsran_ul_cfg_t phy_ue_db::get_ul_config(uint16_t rnti, uint32_t enb_cc_idx) const +int phy_ue_db::get_ul_config(uint16_t rnti, uint32_t enb_cc_idx, srsran_ul_cfg_t& ul_cfg) const { std::lock_guard lock(mutex); - srslte::phy_cfg_t phy_cfg = {}; + srsran::phy_cfg_t phy_cfg = {}; - if (_get_rnti_config(rnti, enb_cc_idx, phy_cfg) < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (_get_rnti_config(rnti, enb_cc_idx, phy_cfg) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } ul_cfg = phy_cfg.ul_cfg; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -srsran_dci_cfg_t phy_ue_db::get_dci_ul_config(uint16_t rnti, uint32_t enb_cc_idx) const +int phy_ue_db::get_dci_ul_config(uint16_t rnti, uint32_t enb_cc_idx, srsran_dci_cfg_t& dci_cfg) const { std::lock_guard lock(mutex); - srslte::phy_cfg_t phy_cfg = {}; + srsran::phy_cfg_t phy_cfg = {}; - if (_get_rnti_config(rnti, enb_cc_idx, phy_cfg) < SRSLTE_SUCCESS) { - return SRSLTE_ERROR; + if (_get_rnti_config(rnti, enb_cc_idx, phy_cfg) < SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } dci_cfg = phy_cfg.dl_cfg.dci; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } bool phy_ue_db::set_ack_pending(uint32_t tti, uint32_t enb_cc_idx, const srsran_dci_dl_t& dci) @@ -516,12 +523,12 @@ int phy_ue_db::fill_uci_cfg(uint32_t tti, // Assert Cell List configuration if (_assert_cell_list_cfg() != SRSRAN_SUCCESS) { - return -1; + return SRSRAN_ERROR; } // Assert eNb Cell/Carrier for the given RNTI if (_assert_active_enb_cc(rnti, enb_cc_idx) != SRSRAN_SUCCESS) { - return -1; + return SRSRAN_ERROR; } // Get the eNb cell/carrier index with lowest serving cell index (ue_cc_idx) that has an available grant. @@ -530,17 +537,17 @@ int phy_ue_db::fill_uci_cfg(uint32_t tti, // There is a PUSCH grant available for the provided RNTI in at least one serving cell and this call is for PUCCH if (pusch_grant_available and not is_pusch_available) { - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // There is a PUSCH grant and enb_cc_idx with lowest ue_cc_idx with a grant if (pusch_grant_available and uci_enb_cc_id != enb_cc_idx) { - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } // No PUSCH grant for this TTI and cell and no enb_cc_idx is not the PCell if (not pusch_grant_available and _get_ue_cc_idx(rnti, enb_cc_idx) != 0) { - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } common_ue& ue = ue_db.at(rnti); @@ -591,25 +598,25 @@ int phy_ue_db::fill_uci_cfg(uint32_t tti, uci_required |= (srsran_uci_cfg_total_ack(&uci_cfg) > 0); // Return whether UCI needs to be decoded - return uci_required ? 1 : SRSLTE_SUCCESS; + return uci_required ? 1 : SRSRAN_SUCCESS; } -void phy_ue_db::send_uci_data(uint32_t tti, - uint16_t rnti, - uint32_t enb_cc_idx, - const srsran_uci_cfg_t& uci_cfg, - const srsran_uci_value_t& uci_value) +int phy_ue_db::send_uci_data(uint32_t tti, + uint16_t rnti, + uint32_t enb_cc_idx, + const srsran_uci_cfg_t& uci_cfg, + const srsran_uci_value_t& uci_value) { std::lock_guard lock(mutex); // Assert UE RNTI database entry and eNb cell/carrier must be active if (_assert_active_enb_cc(rnti, enb_cc_idx) != SRSRAN_SUCCESS) { - return; + return SRSRAN_ERROR; } // Assert Stack if (_assert_stack() != SRSRAN_SUCCESS) { - return; + return SRSRAN_ERROR; } // Notify SR @@ -640,7 +647,7 @@ void phy_ue_db::send_uci_data(uint32_t tti, // Assert the SCell exists and it is active if (_assert_ue_cc(rnti, uci_cfg.cqi.scell_index) != SRSRAN_SUCCESS) { - return; + return SRSRAN_ERROR; } // Get CQI carrier index @@ -693,37 +700,37 @@ void phy_ue_db::send_uci_data(uint32_t tti, cqi_scell_info.last_ri = uci_value.ri; } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -void phy_ue_db::set_last_ul_tb(uint16_t rnti, uint32_t enb_cc_idx, uint32_t pid, srsran_ra_tb_t tb) +int phy_ue_db::set_last_ul_tb(uint16_t rnti, uint32_t enb_cc_idx, uint32_t pid, srsran_ra_tb_t tb) { std::lock_guard lock(mutex); // Assert UE DB entry if (_assert_active_enb_cc(rnti, enb_cc_idx) != SRSRAN_SUCCESS) { - return; + return SRSRAN_ERROR; } // Save resource allocation ue_db.at(rnti).cell_info[_get_ue_cc_idx(rnti, enb_cc_idx)].last_tb[pid] = tb; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } -srsran_ra_tb_t phy_ue_db::get_last_ul_tb(uint16_t rnti, uint32_t enb_cc_idx, uint32_t pid) const +int phy_ue_db::get_last_ul_tb(uint16_t rnti, uint32_t enb_cc_idx, uint32_t pid, srsran_ra_tb_t& ra_tb) const { std::lock_guard lock(mutex); // Assert UE DB entry if (_assert_active_enb_cc(rnti, enb_cc_idx) != SRSRAN_SUCCESS) { - return {}; + return SRSRAN_ERROR; } // writes the latest stored UL transmission grant ra_tb = ue_db.at(rnti).cell_info[_get_ue_cc_idx(rnti, enb_cc_idx)].last_tb[pid]; - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } int phy_ue_db::set_ul_grant_available(uint32_t tti, const stack_interface_phy_lte::ul_sched_list_t& ul_sched_list) @@ -744,14 +751,13 @@ int phy_ue_db::set_ul_grant_available(uint32_t tti, const stack_interface_phy_lt const stack_interface_phy_lte::ul_sched_grant_t& ul_sched_grant = ul_sched.pusch[i]; uint16_t rnti = ul_sched_grant.dci.rnti; // Check that eNb Cell/Carrier is active for the given RNTI - if (_assert_active_enb_cc(rnti, enb_cc_idx) == SRSRAN_SUCCESS) { - // Rise Grant available flag - ue_db[rnti].cell_info[_get_ue_cc_idx(rnti, enb_cc_idx)].is_grant_available[tti] = true; + if (_assert_active_enb_cc(rnti, enb_cc_idx) != SRSRAN_SUCCESS) { + return SRSRAN_ERROR; } // Rise Grant available flag ue_db[rnti].cell_info[_get_ue_cc_idx(rnti, enb_cc_idx)].is_grant_available[tti] = true; } } - return SRSLTE_SUCCESS; + return SRSRAN_SUCCESS; } From ea3c3b1d4fb4d93ae2459a3bb1627004a7dd57a8 Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Thu, 18 Mar 2021 17:56:08 +0000 Subject: [PATCH 19/48] Added some checks for the byte buffer allocation in the GTP-U --- srsenb/src/stack/upper/gtpu.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/srsenb/src/stack/upper/gtpu.cc b/srsenb/src/stack/upper/gtpu.cc index 3eb9494ea..4a9d0f74d 100644 --- a/srsenb/src/stack/upper/gtpu.cc +++ b/srsenb/src/stack/upper/gtpu.cc @@ -458,6 +458,10 @@ void gtpu::error_indication(in_addr_t addr, in_port_t port, uint32_t err_teid) gtpu_header_t header = {}; unique_byte_buffer_t pdu = make_byte_buffer(); + if (pdu == nullptr) { + logger.error("Could not allocate byte buffer for error indication"); + return; + } // header header.flags = GTPU_FLAGS_VERSION_V1 | GTPU_FLAGS_GTP_PROTOCOL | GTPU_FLAGS_SEQUENCE; @@ -488,6 +492,10 @@ void gtpu::echo_response(in_addr_t addr, in_port_t port, uint16_t seq) gtpu_header_t header = {}; unique_byte_buffer_t pdu = make_byte_buffer(); + if (pdu == nullptr) { + logger.error("Could not allocate byte buffer for echo response"); + return; + } // header header.flags = GTPU_FLAGS_VERSION_V1 | GTPU_FLAGS_GTP_PROTOCOL | GTPU_FLAGS_SEQUENCE; From ef5329bec0e238e886324cf826a7a196e3f18d4f Mon Sep 17 00:00:00 2001 From: Francisco Date: Tue, 23 Mar 2021 12:36:56 +0000 Subject: [PATCH 20/48] adt - extend circular map unit test to test the container with move-only types --- lib/include/srsran/adt/circular_map.h | 63 ++++++++-------- lib/include/srsran/adt/detail/type_storage.h | 76 ++++++++++++++++++++ lib/test/adt/circular_map_test.cc | 63 ++++++++++++++-- 3 files changed, 161 insertions(+), 41 deletions(-) create mode 100644 lib/include/srsran/adt/detail/type_storage.h diff --git a/lib/include/srsran/adt/circular_map.h b/lib/include/srsran/adt/circular_map.h index 50ca4b318..6c3823204 100644 --- a/lib/include/srsran/adt/circular_map.h +++ b/lib/include/srsran/adt/circular_map.h @@ -13,6 +13,7 @@ #ifndef SRSRAN_ID_MAP_H #define SRSRAN_ID_MAP_H +#include "detail/type_storage.h" #include "expected.h" #include "srsran/common/srsran_assert.h" #include @@ -24,8 +25,7 @@ class static_circular_map { static_assert(std::is_integral::value and std::is_unsigned::value, "Map key must be an unsigned integer"); - using obj_t = std::pair; - using obj_storage_t = typename std::aligned_storage::type; + using obj_t = std::pair; public: class iterator @@ -48,23 +48,23 @@ public: obj_t& operator*() { - srsran_assert(idx < ptr->buffer.size(), "Iterator out-of-bounds (%zd >= %zd)", idx, ptr->buffer.size()); + srsran_assert(idx < ptr->capacity(), "Iterator out-of-bounds (%zd >= %zd)", idx, ptr->capacity()); return ptr->get_obj_(idx); } obj_t* operator->() { - srsran_assert(idx < ptr->buffer.size(), "Iterator out-of-bounds (%zd >= %zd)", idx, ptr->buffer.size()); + srsran_assert(idx < ptr->capacity(), "Iterator out-of-bounds (%zd >= %zd)", idx, ptr->capacity()); return &ptr->get_obj_(idx); } const obj_t* operator*() const { - srsran_assert(idx < ptr->buffer.size(), "Iterator out-of-bounds (%zd >= %zd)", idx, ptr->buffer.size()); - return ptr->buffer[idx]; + srsran_assert(idx < ptr->capacity(), "Iterator out-of-bounds (%zd >= %zd)", idx, ptr->capacity()); + return &ptr->get_obj_(idx); } const obj_t* operator->() const { - srsran_assert(idx < ptr->buffer.size(), "Iterator out-of-bounds (%zd >= %zd)", idx, ptr->buffer.size()); - return ptr->buffer[idx]; + srsran_assert(idx < ptr->capacity(), "Iterator out-of-bounds (%zd >= %zd)", idx, ptr->capacity()); + return &ptr->get_obj_(idx); } bool operator==(const iterator& other) const { return ptr == other.ptr and idx == other.idx; } @@ -88,8 +88,8 @@ public: return *this; } - const obj_t* operator*() const { return ptr->buffer[idx]; } - const obj_t* operator->() const { return ptr->buffer[idx]; } + const obj_t* operator*() const { return &ptr->buffer[idx].get(); } + const obj_t* operator->() const { return &ptr->buffer[idx].get(); } bool operator==(const const_iterator& other) const { return ptr == other.ptr and idx == other.idx; } bool operator!=(const const_iterator& other) const { return not(*this == other); } @@ -103,17 +103,17 @@ public: static_circular_map() { std::fill(present.begin(), present.end(), false); } static_circular_map(const static_circular_map& other) : present(other.present), count(other.count) { - for (size_t idx = 0; idx < other.size(); ++idx) { + for (size_t idx = 0; idx < other.capacity(); ++idx) { if (present[idx]) { - new (&buffer[idx]) obj_t(other.get_obj_(idx)); + buffer[idx].template construct(other.get_obj_(idx)); } } } static_circular_map(static_circular_map&& other) noexcept : present(other.present), count(other.count) { - for (size_t idx = 0; idx < other.size(); ++idx) { + for (size_t idx = 0; idx < other.capacity(); ++idx) { if (present[idx]) { - new (&buffer[idx]) obj_t(std::move(other.get_obj_(idx))); + buffer[idx].template construct(std::move(other.get_obj_(idx))); } } other.clear(); @@ -124,26 +124,21 @@ public: if (this == &other) { return *this; } - clear(); + for (size_t idx = 0; idx < other.capacity(); ++idx) { + copy_if_present_helper(buffer[idx], other.buffer[idx], present[idx], other.present[idx]); + } count = other.count; present = other.present; - for (size_t idx = 0; idx < other.size(); ++idx) { - if (present[idx]) { - new (&buffer[idx]) obj_t(other.get_obj_(idx)); - } - } } static_circular_map& operator=(static_circular_map&& other) noexcept { - clear(); + for (size_t idx = 0; idx < other.capacity(); ++idx) { + move_if_present_helper(buffer[idx], other.buffer[idx], present[idx], other.present[idx]); + } count = other.count; present = other.present; - for (size_t idx = 0; idx < other.size(); ++idx) { - if (present[idx]) { - new (&buffer[idx]) obj_t(std::move(other.get_obj_(idx))); - } - } - clear(); + other.clear(); + return *this; } bool contains(K id) @@ -158,7 +153,7 @@ public: if (present[idx]) { return false; } - new (&buffer[idx]) obj_t(id, obj); + buffer[idx].template construct(id, obj); present[idx] = true; count++; return true; @@ -169,7 +164,7 @@ public: if (present[idx]) { return srsran::expected(std::move(obj)); } - new (&buffer[idx]) obj_t(id, std::move(obj)); + buffer[idx].template construct(id, std::move(obj)); present[idx] = true; count++; return iterator(this, idx); @@ -242,12 +237,12 @@ public: } private: - obj_t& get_obj_(size_t idx) { return reinterpret_cast(buffer[idx]); } - const obj_t& get_obj_(size_t idx) const { return reinterpret_cast(buffer[idx]); } + obj_t& get_obj_(size_t idx) { return buffer[idx].get(); } + const obj_t& get_obj_(size_t idx) const { return buffer[idx].get(); } - std::array buffer; - std::array present; - size_t count = 0; + std::array, N> buffer; + std::array present; + size_t count = 0; }; } // namespace srsran diff --git a/lib/include/srsran/adt/detail/type_storage.h b/lib/include/srsran/adt/detail/type_storage.h new file mode 100644 index 000000000..2645eaef1 --- /dev/null +++ b/lib/include/srsran/adt/detail/type_storage.h @@ -0,0 +1,76 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +#ifndef SRSRAN_TYPE_STORAGE_H +#define SRSRAN_TYPE_STORAGE_H + +#include +#include + +namespace srsran { + +template +struct type_storage { + template + void construct(Args&&... args) + { + new (&buffer) T(std::forward(args)...); + } + void destroy() { get().~T(); } + void copy_ctor(const type_storage& other) { buffer.get() = other.get(); } + void move_ctor(type_storage&& other) { buffer.get() = std::move(other.get()); } + void copy_assign(const type_storage& other) + { + if (this == &other) { + return; + } + get() = other.get(); + } + void move_assign(type_storage&& other) { get() = std::move(other.get()); } + + T& get() { return reinterpret_cast(buffer); } + const T& get() const { return reinterpret_cast(buffer); } + + typename std::aligned_storage::type buffer; +}; + +template +void copy_if_present_helper(type_storage& lhs, const type_storage& rhs, bool lhs_present, bool rhs_present) +{ + if (lhs_present and rhs_present) { + lhs.get() = rhs.get(); + } + if (lhs_present) { + lhs.destroy(); + } + if (rhs_present) { + lhs.template construct(rhs.get()); + } +} + +template +void move_if_present_helper(type_storage& lhs, type_storage& rhs, bool lhs_present, bool rhs_present) +{ + if (lhs_present and rhs_present) { + lhs.move_assign(std::move(rhs)); + } + if (lhs_present) { + lhs.destroy(); + } + if (rhs_present) { + lhs.template construct(std::move(rhs.get())); + } +} + +} // namespace srsran + +#endif // SRSRAN_TYPE_STORAGE_H diff --git a/lib/test/adt/circular_map_test.cc b/lib/test/adt/circular_map_test.cc index a8a79ab0a..aed0dd88a 100644 --- a/lib/test/adt/circular_map_test.cc +++ b/lib/test/adt/circular_map_test.cc @@ -15,7 +15,7 @@ namespace srsran { -int test_id_map() +void test_id_map() { static_circular_map myobj; TESTASSERT(myobj.size() == 0 and myobj.empty() and not myobj.full()); @@ -57,11 +57,9 @@ int test_id_map() TESTASSERT(myobj.size() == 2 and not myobj.empty() and not myobj.full()); myobj.clear(); TESTASSERT(myobj.size() == 0 and myobj.empty()); - - return SRSRAN_SUCCESS; } -int test_id_map_wraparound() +void test_id_map_wraparound() { static_circular_map mymap; @@ -81,8 +79,56 @@ int test_id_map_wraparound() TESTASSERT(not mymap.full()); TESTASSERT(mymap.insert(4, "4")); TESTASSERT(mymap.full()); +} - return SRSRAN_SUCCESS; +struct C { + C() { count++; } + ~C() { count--; } + C(C&&) { count++; } + C(const C&) = delete; + C& operator=(C&&) = default; + + static size_t count; +}; +size_t C::count = 0; + +void test_correct_destruction() +{ + TESTASSERT(C::count == 0); + { + static_circular_map circ_buffer; + TESTASSERT(C::count == 0); + TESTASSERT(circ_buffer.insert(0, C{})); + TESTASSERT(C::count == 1); + TESTASSERT(circ_buffer.insert(1, C{})); + TESTASSERT(circ_buffer.insert(2, C{})); + TESTASSERT(circ_buffer.insert(3, C{})); + TESTASSERT(C::count == 4); + TESTASSERT(not circ_buffer.insert(4, C{})); + TESTASSERT(C::count == 4); + TESTASSERT(circ_buffer.erase(1)); + TESTASSERT(C::count == 3); + TESTASSERT(not circ_buffer.contains(1)); + + std::array content{0, 2, 3}; + size_t i = 0; + for (auto& e : circ_buffer) { + TESTASSERT(content[i] == e.first); + i++; + } + + TESTASSERT(C::count == 3); + static_circular_map circ_buffer2; + circ_buffer2 = std::move(circ_buffer); + TESTASSERT(C::count == 3); + + static_circular_map circ_buffer3; + TESTASSERT(circ_buffer3.insert(1, C{})); + TESTASSERT(C::count == 4); + circ_buffer2 = std::move(circ_buffer3); + TESTASSERT(C::count == 1); + } + TESTASSERT(C::count == 0); } } // namespace srsran @@ -94,7 +140,10 @@ int main(int argc, char** argv) srsran::test_init(argc, argv); - TESTASSERT(srsran::test_id_map() == SRSRAN_SUCCESS); - TESTASSERT(srsran::test_id_map_wraparound() == SRSRAN_SUCCESS); + srsran::test_id_map(); + srsran::test_id_map_wraparound(); + srsran::test_correct_destruction(); + + printf("Success\n"); return SRSRAN_SUCCESS; } From 6d9709fe5427c5b2aea95394a3d48852da4c2c08 Mon Sep 17 00:00:00 2001 From: Francisco Date: Tue, 23 Mar 2021 15:47:26 +0000 Subject: [PATCH 21/48] adt - make circular buffer work with types without default ctor --- lib/include/srsran/adt/circular_buffer.h | 243 ++++++++++++++----- lib/include/srsran/adt/circular_map.h | 14 +- lib/include/srsran/adt/detail/type_storage.h | 24 +- lib/include/srsran/common/srsran_assert.h | 2 +- lib/test/adt/circular_buffer_test.cc | 225 ++++++++++++++--- 5 files changed, 391 insertions(+), 117 deletions(-) diff --git a/lib/include/srsran/adt/circular_buffer.h b/lib/include/srsran/adt/circular_buffer.h index 28fdf7a81..600273326 100644 --- a/lib/include/srsran/adt/circular_buffer.h +++ b/lib/include/srsran/adt/circular_buffer.h @@ -13,7 +13,9 @@ #ifndef SRSRAN_CIRCULAR_BUFFER_H #define SRSRAN_CIRCULAR_BUFFER_H +#include "srsran/adt/detail/type_storage.h" #include "srsran/adt/expected.h" +#include "srsran/common/srsran_assert.h" #include #include @@ -51,51 +53,97 @@ size_t get_max_size(const std::vector& a) template class base_circular_buffer { - using T = typename Container::value_type; + using storage_t = typename Container::value_type; + using T = typename storage_t::value_type; -public: - using value_type = T; - using difference_type = typename Container::difference_type; + template + class iterator_impl + { + using parent_type = typename std::conditional::value, + base_circular_buffer, + const base_circular_buffer >::type; + + public: + using value_type = DataType; + using reference = DataType&; + using pointer = DataType*; + using difference_type = std::ptrdiff_t; + using iterator_category = std::forward_iterator_tag; - struct iterator { - iterator(base_circular_buffer& parent_, size_t i) : parent(&parent_), idx(i) {} - iterator& operator++() + iterator_impl(parent_type& parent_, size_t i) : parent(&parent_), idx(i) {} + + iterator_impl& operator++() { idx = (idx + 1) % parent->max_size(); return *this; } - iterator operator++(int) + iterator_impl operator++(int) { - iterator tmp(*this); + iterator_impl tmp(*this); ++(*this); return tmp; } - iterator operator+(difference_type n) + iterator_impl operator+(difference_type n) { - iterator tmp(*this); + iterator_impl tmp(*this); tmp += n; return tmp; } - iterator& operator+=(difference_type n) + iterator_impl& operator+=(difference_type n) { idx = (idx + n) % parent->max_size(); return *this; } - value_type* operator->() { return &parent->buffer[idx]; } - const value_type* operator->() const { return &parent->buffer[idx]; } - value_type& operator*() { return parent->buffer[idx]; } - const value_type& operator*() const { return parent->buffer[idx]; } - bool operator==(const iterator& it) const { return it.parent == parent and it.idx == idx; } - bool operator!=(const iterator& it) const { return not(*this == it); } + value_type* operator->() { return &get(); } + const value_type* operator->() const { return &get(); } + value_type& operator*() { return get(); } + const value_type& operator*() const { return get(); } + + bool operator==(const iterator_impl& it) const { return it.parent == parent and it.idx == idx; } + bool operator!=(const iterator_impl& it) const { return not(*this == it); } private: - base_circular_buffer* parent; - size_t idx; + void assert_idx_within_bounds() + { + srsran_assert(idx + (idx >= parent->rpos ? 0 : parent->max_size()) < parent->rpos + parent->count, + "index=%zd is out-of-bounds [%zd, %zd)", + idx, + parent->rpos, + parent->count); + } + value_type& get() + { + assert_idx_within_bounds(); + return parent->buffer[idx].get(); + } + const value_type& get() const + { + assert_idx_within_bounds(); + return parent->buffer[idx].get(); + } + parent_type* parent; + size_t idx; }; - template - explicit base_circular_buffer(Args&&... args) : buffer(std::forward(args)...) - {} +public: + using value_type = T; + using difference_type = typename Container::difference_type; + using size_type = std::size_t; + + using iterator = iterator_impl; + using const_iterator = iterator_impl; + + base_circular_buffer() = default; + ~base_circular_buffer() { clear(); } + + template + typename std::enable_if::value>::type push(U&& t) + { + srsran_assert(not full(), "Circular buffer is full."); + size_t wpos = (rpos + count) % max_size(); + buffer[wpos].emplace(std::forward(t)); + count++; + } bool try_push(T&& t) { @@ -104,13 +152,7 @@ public: } push(std::move(t)); } - void push(T&& t) - { - assert(not full()); - size_t wpos = (rpos + count) % max_size(); - buffer[wpos] = std::move(t); - count++; - } + bool try_push(const T& t) { if (full()) { @@ -118,49 +160,56 @@ public: } push(t); } - void push(const T& t) - { - assert(not full()); - size_t wpos = (rpos + count) % max_size(); - buffer[wpos] = t; - count++; - } void pop() { - assert(not empty()); + srsran_assert(not empty(), "Cannot call pop() in empty circular buffer"); + buffer[rpos].destroy(); rpos = (rpos + 1) % max_size(); count--; } T& top() { - assert(not empty()); - return buffer[rpos]; + srsran_assert(not empty(), "Cannot call top() in empty circular buffer"); + return buffer[rpos].get(); } const T& top() const { - assert(not empty()); - return buffer[rpos]; + srsran_assert(not empty(), "Cannot call top() in empty circular buffer"); + return buffer[rpos].get(); + } + void clear() + { + for (size_t i = 0; i < count; ++i) { + buffer[rpos + i].destroy(); + } + count = 0; } - void clear() { count = 0; } bool full() const { return count == max_size(); } bool empty() const { return count == 0; } size_t size() const { return count; } size_t max_size() const { return detail::get_max_size(buffer); } - iterator begin() { return iterator(*this, rpos); } - iterator end() { return iterator(*this, (rpos + count) % max_size()); } - - template >::value> > - void set_size(size_t size) + T& operator[](size_t i) { - buffer.resize(size); + srsran_assert(i < count, "Out-of-bounds access to circular buffer (%zd >= %zd)", i, count); + return buffer[(rpos + i) % max_size()].get(); } + const T& operator[](size_t i) const + { + srsran_assert(i < count, "Out-of-bounds access to circular buffer (%zd >= %zd)", i, count); + return buffer[(rpos + i) % max_size()].get(); + } + + iterator begin() { return iterator(*this, rpos); } + const_iterator begin() const { return const_iterator(*this, rpos); } + iterator end() { return iterator(*this, (rpos + count) % max_size()); } + const_iterator end() const { return const_iterator(*this, (rpos + count) % max_size()); } template T discard_if(const F& func) { - for (auto it = buffer.begin(); it != buffer.end(); it++) { + for (auto it = begin(); it != end(); it++) { if (*it != nullptr && func(*it)) { T tmp = std::move(*it); *it = nullptr; @@ -170,7 +219,13 @@ public: return nullptr; } -private: +protected: + base_circular_buffer(size_t rpos_, size_t count_) : rpos(rpos_), count(count_) {} + template + base_circular_buffer(size_t rpos_, size_t count_, BufferArgs&&... args) : + rpos(rpos_), count(count_), buffer(std::forward(args)...) + {} + Container buffer; size_t rpos = 0; size_t count = 0; @@ -394,8 +449,53 @@ protected: * @tparam N size of the queue */ template -class static_circular_buffer : public detail::base_circular_buffer > -{}; +class static_circular_buffer : public detail::base_circular_buffer, N> > +{ + using base_t = detail::base_circular_buffer, N> >; + +public: + static_circular_buffer() = default; + static_circular_buffer(const static_circular_buffer& other) : base_t(other.rpos, other.count) + { + static_assert(std::is_copy_constructible::value, "T must be copy-constructible"); + std::uninitialized_copy(other.begin(), other.end(), base_t::begin()); + } + static_circular_buffer(static_circular_buffer&& other) noexcept : base_t(other.rpos, other.count) + { + static_assert(std::is_move_constructible::value, "T must be move-constructible"); + for (size_t i = 0; i < other.count; ++i) { + size_t idx = (other.rpos + i) % other.max_size(); + base_t::buffer[idx].move_ctor(std::move(other.buffer[idx])); + } + other.clear(); + } + static_circular_buffer& operator=(const static_circular_buffer& other) + { + if (this == &other) { + return *this; + } + base_t::clear(); + base_t::rpos = other.rpos; + base_t::count = other.count; + for (size_t i = 0; i < other.count; ++i) { + size_t idx = (other.rpos + i) % other.max_size(); + base_t::buffer[idx].copy_ctor(other.buffer[idx]); + } + return *this; + } + static_circular_buffer& operator=(static_circular_buffer&& other) noexcept + { + base_t::clear(); + base_t::rpos = other.rpos; + base_t::count = other.count; + for (size_t i = 0; i < other.count; ++i) { + size_t idx = (other.rpos + i) % other.max_size(); + base_t::buffer[idx].move_ctor(std::move(other.buffer[idx])); + } + other.clear(); + return *this; + } +}; /** * Circular buffer with buffer storage via a std::vector. @@ -404,19 +504,44 @@ class static_circular_buffer : public detail::base_circular_buffer -class dyn_circular_buffer : public detail::base_circular_buffer > +class dyn_circular_buffer : public detail::base_circular_buffer > > { - using base_t = detail::base_circular_buffer >; + using base_t = detail::base_circular_buffer > >; public: dyn_circular_buffer() = default; - explicit dyn_circular_buffer(size_t size) : base_t(size) {} + explicit dyn_circular_buffer(size_t max_size) : base_t(0, 0, max_size) {} + dyn_circular_buffer(dyn_circular_buffer&& other) noexcept : base_t(other.rpos, other.count, std::move(other.buffer)) + { + other.count = 0; + other.rpos = 0; + } + dyn_circular_buffer(const dyn_circular_buffer& other) : base_t(other.rpos, other.count, other.max_size()) + { + static_assert(std::is_copy_constructible::value, "T must be copy-constructible"); + for (size_t i = 0; i < other.count; ++i) { + size_t idx = (other.rpos + i) % other.max_size(); + base_t::buffer[idx].copy_ctor(other.buffer[idx]); + } + } + dyn_circular_buffer& operator=(dyn_circular_buffer other) noexcept + { + swap(other); + other.clear(); + return *this; + } + + void swap(dyn_circular_buffer& other) noexcept + { + std::swap(base_t::rpos, other.rpos); + std::swap(base_t::count, other.count); + std::swap(base_t::buffer, other.buffer); + } void set_size(size_t size) { - // Note: dynamic resizes not supported. - assert(base_t::empty()); - base_t::set_size(size); + srsran_assert(base_t::empty(), "Dynamic resizes not supported when circular buffer is not empty"); + base_t::buffer.resize(size); } }; diff --git a/lib/include/srsran/adt/circular_map.h b/lib/include/srsran/adt/circular_map.h index 6c3823204..23fc4c252 100644 --- a/lib/include/srsran/adt/circular_map.h +++ b/lib/include/srsran/adt/circular_map.h @@ -105,7 +105,7 @@ public: { for (size_t idx = 0; idx < other.capacity(); ++idx) { if (present[idx]) { - buffer[idx].template construct(other.get_obj_(idx)); + buffer[idx].template emplace(other.get_obj_(idx)); } } } @@ -113,7 +113,7 @@ public: { for (size_t idx = 0; idx < other.capacity(); ++idx) { if (present[idx]) { - buffer[idx].template construct(std::move(other.get_obj_(idx))); + buffer[idx].template emplace(std::move(other.get_obj_(idx))); } } other.clear(); @@ -153,7 +153,7 @@ public: if (present[idx]) { return false; } - buffer[idx].template construct(id, obj); + buffer[idx].template emplace(id, obj); present[idx] = true; count++; return true; @@ -164,7 +164,7 @@ public: if (present[idx]) { return srsran::expected(std::move(obj)); } - buffer[idx].template construct(id, std::move(obj)); + buffer[idx].template emplace(id, std::move(obj)); present[idx] = true; count++; return iterator(this, idx); @@ -240,9 +240,9 @@ private: obj_t& get_obj_(size_t idx) { return buffer[idx].get(); } const obj_t& get_obj_(size_t idx) const { return buffer[idx].get(); } - std::array, N> buffer; - std::array present; - size_t count = 0; + std::array, N> buffer; + std::array present; + size_t count = 0; }; } // namespace srsran diff --git a/lib/include/srsran/adt/detail/type_storage.h b/lib/include/srsran/adt/detail/type_storage.h index 2645eaef1..b97cc522e 100644 --- a/lib/include/srsran/adt/detail/type_storage.h +++ b/lib/include/srsran/adt/detail/type_storage.h @@ -18,23 +18,21 @@ namespace srsran { +namespace detail { + template struct type_storage { + using value_type = T; + template - void construct(Args&&... args) + void emplace(Args&&... args) { new (&buffer) T(std::forward(args)...); } void destroy() { get().~T(); } - void copy_ctor(const type_storage& other) { buffer.get() = other.get(); } - void move_ctor(type_storage&& other) { buffer.get() = std::move(other.get()); } - void copy_assign(const type_storage& other) - { - if (this == &other) { - return; - } - get() = other.get(); - } + void copy_ctor(const type_storage& other) { emplace(other.get()); } + void move_ctor(type_storage&& other) { emplace(std::move(other.get())); } + void copy_assign(const type_storage& other) { get() = other.get(); } void move_assign(type_storage&& other) { get() = std::move(other.get()); } T& get() { return reinterpret_cast(buffer); } @@ -53,7 +51,7 @@ void copy_if_present_helper(type_storage& lhs, const type_storage& rhs, bo lhs.destroy(); } if (rhs_present) { - lhs.template construct(rhs.get()); + lhs.copy_ctor(rhs); } } @@ -67,10 +65,12 @@ void move_if_present_helper(type_storage& lhs, type_storage& rhs, bool lhs lhs.destroy(); } if (rhs_present) { - lhs.template construct(std::move(rhs.get())); + lhs.move_ctor(std::move(rhs)); } } +} // namespace detail + } // namespace srsran #endif // SRSRAN_TYPE_STORAGE_H diff --git a/lib/include/srsran/common/srsran_assert.h b/lib/include/srsran/common/srsran_assert.h index 48b1f4244..cef540f00 100644 --- a/lib/include/srsran/common/srsran_assert.h +++ b/lib/include/srsran/common/srsran_assert.h @@ -28,8 +28,8 @@ do { \ if (srsran_unlikely(not(condition))) { \ srslog::fetch_basic_logger("ALL").error("%s:%d: " fmt, __FILE__, __LINE__, ##__VA_ARGS__); \ - srsran::console_stderr("%s:%d: " fmt "\n", __FILE__, __LINE__, ##__VA_ARGS__); \ srslog::flush(); \ + srsran::console_stderr("%s:%d: " fmt "\n", __FILE__, __LINE__, ##__VA_ARGS__); \ std::abort(); \ } \ } while (0) diff --git a/lib/test/adt/circular_buffer_test.cc b/lib/test/adt/circular_buffer_test.cc index 97db4b267..a1f78a8b1 100644 --- a/lib/test/adt/circular_buffer_test.cc +++ b/lib/test/adt/circular_buffer_test.cc @@ -15,53 +15,196 @@ namespace srsran { +struct C { + C() : val_ptr(new int(5)) { count++; } + ~C() { count--; } + C(C&& other) : val_ptr(move(other.val_ptr)) { count++; } + C& operator=(C&&) = default; + + std::unique_ptr val_ptr; + + static size_t count; +}; +size_t C::count = 0; + +struct D { + D() { count++; } + ~D() { count--; } + D(const D&) { count++; } + D(D&&) = delete; + D& operator=(D&&) = delete; + D& operator=(const D&) = default; + + static size_t count; +}; +size_t D::count = 0; + int test_static_circular_buffer() { - static_circular_buffer circ_buffer; - TESTASSERT(circ_buffer.max_size() == 10); - TESTASSERT(circ_buffer.empty() and not circ_buffer.full() and circ_buffer.size() == 0); - - // push until full - for (size_t i = 0; i < circ_buffer.max_size(); ++i) { - TESTASSERT(circ_buffer.size() == i and not circ_buffer.full()); - circ_buffer.push(i); - TESTASSERT(not circ_buffer.empty()); - } - TESTASSERT(circ_buffer.size() == 10 and circ_buffer.full()); + { + static_circular_buffer circ_buffer; + TESTASSERT(circ_buffer.max_size() == 10); + TESTASSERT(circ_buffer.empty() and not circ_buffer.full() and circ_buffer.size() == 0); - // test iterator - int count = 0; - for (int& it : circ_buffer) { - TESTASSERT(it == count); - count++; - } - TESTASSERT(*circ_buffer.begin() == circ_buffer.top()); + // push until full + for (size_t i = 0; i < circ_buffer.max_size(); ++i) { + TESTASSERT(circ_buffer.size() == i and not circ_buffer.full()); + circ_buffer.push(i); + TESTASSERT(not circ_buffer.empty()); + } + TESTASSERT(circ_buffer.size() == 10 and circ_buffer.full()); + + // test iterator + int count = 0; + for (int it : circ_buffer) { + TESTASSERT(it == count); + count++; + } + TESTASSERT(*circ_buffer.begin() == circ_buffer.top()); - // pop until empty - for (size_t i = 0; i < circ_buffer.max_size(); ++i) { - TESTASSERT(circ_buffer.size() == circ_buffer.max_size() - i and not circ_buffer.empty()); - TESTASSERT(circ_buffer.top() == (int)i); - circ_buffer.pop(); + // pop until empty + for (size_t i = 0; i < circ_buffer.max_size(); ++i) { + TESTASSERT(circ_buffer.size() == circ_buffer.max_size() - i and not circ_buffer.empty()); + TESTASSERT(circ_buffer.top() == (int)i); + circ_buffer.pop(); + } + TESTASSERT(circ_buffer.empty() and circ_buffer.size() == 0); + + // test iteration with wrap-around in memory + for (size_t i = 0; i < circ_buffer.max_size(); ++i) { + circ_buffer.push(i); + } + for (size_t i = 0; i < circ_buffer.max_size() / 2; ++i) { + circ_buffer.pop(); + } + circ_buffer.push(circ_buffer.max_size()); + circ_buffer.push(circ_buffer.max_size() + 1); + TESTASSERT(circ_buffer.size() == circ_buffer.max_size() / 2 + 2); + count = circ_buffer.max_size() / 2; + for (int& it : circ_buffer) { + TESTASSERT(it == count); + count++; + } } - TESTASSERT(circ_buffer.empty() and circ_buffer.size() == 0); - // test iteration with wrap-around in memory - for (size_t i = 0; i < circ_buffer.max_size(); ++i) { - circ_buffer.push(i); + // TEST: move-only types + { + static_circular_buffer circbuffer; + circbuffer.push(C{}); + circbuffer.push(C{}); + circbuffer.push(C{}); + circbuffer.push(C{}); + circbuffer.push(C{}); + TESTASSERT(circbuffer.full() and C::count == 5); + C c = std::move(circbuffer.top()); + TESTASSERT(circbuffer.full() and C::count == 6); + circbuffer.pop(); + TESTASSERT(not circbuffer.full() and C::count == 5); + + static_circular_buffer circbuffer2(std::move(circbuffer)); + TESTASSERT(circbuffer.empty() and circbuffer2.size() == 4); + TESTASSERT(C::count == 5); + circbuffer.push(C{}); + TESTASSERT(C::count == 6); + circbuffer = std::move(circbuffer2); + TESTASSERT(C::count == 5); } - for (size_t i = 0; i < circ_buffer.max_size() / 2; ++i) { - circ_buffer.pop(); + + TESTASSERT(C::count == 0); + return SRSRAN_SUCCESS; +} + +void test_dyn_circular_buffer() +{ + { + dyn_circular_buffer circ_buffer(10); + TESTASSERT(circ_buffer.max_size() == 10); + TESTASSERT(circ_buffer.empty() and not circ_buffer.full() and circ_buffer.size() == 0); + + // push until full + for (size_t i = 0; i < circ_buffer.max_size(); ++i) { + TESTASSERT(circ_buffer.size() == i and not circ_buffer.full()); + circ_buffer.push(i); + TESTASSERT(not circ_buffer.empty()); + } + TESTASSERT(circ_buffer.size() == 10 and circ_buffer.full()); + + // test iterator + int count = 0; + for (int it : circ_buffer) { + TESTASSERT(it == count); + count++; + } + TESTASSERT(*circ_buffer.begin() == circ_buffer.top()); + + // pop until empty + for (size_t i = 0; i < circ_buffer.max_size(); ++i) { + TESTASSERT(circ_buffer.size() == circ_buffer.max_size() - i and not circ_buffer.empty()); + TESTASSERT(circ_buffer.top() == (int)i); + circ_buffer.pop(); + } + TESTASSERT(circ_buffer.empty() and circ_buffer.size() == 0); + + // test iteration with wrap-around in memory + for (size_t i = 0; i < circ_buffer.max_size(); ++i) { + circ_buffer.push(i); + } + for (size_t i = 0; i < circ_buffer.max_size() / 2; ++i) { + circ_buffer.pop(); + } + circ_buffer.push(circ_buffer.max_size()); + circ_buffer.push(circ_buffer.max_size() + 1); + TESTASSERT(circ_buffer.size() == circ_buffer.max_size() / 2 + 2); + count = circ_buffer.max_size() / 2; + for (int& it : circ_buffer) { + TESTASSERT(it == count); + count++; + } } - circ_buffer.push(circ_buffer.max_size()); - circ_buffer.push(circ_buffer.max_size() + 1); - TESTASSERT(circ_buffer.size() == circ_buffer.max_size() / 2 + 2); - count = circ_buffer.max_size() / 2; - for (int& it : circ_buffer) { - TESTASSERT(it == count); - count++; + + // TEST: move-only types + { + dyn_circular_buffer circbuffer(5); + circbuffer.push(C{}); + circbuffer.push(C{}); + circbuffer.push(C{}); + circbuffer.push(C{}); + circbuffer.push(C{}); + TESTASSERT(circbuffer.full() and C::count == 5); + C c = std::move(circbuffer.top()); + TESTASSERT(circbuffer.full() and C::count == 6); + circbuffer.pop(); + TESTASSERT(not circbuffer.full() and C::count == 5); + + dyn_circular_buffer circbuffer2(std::move(circbuffer)); + TESTASSERT(circbuffer.empty() and circbuffer2.size() == 4); + TESTASSERT(C::count == 5); + circbuffer.set_size(5); + circbuffer.push(C{}); + TESTASSERT(C::count == 6); + circbuffer = std::move(circbuffer2); + TESTASSERT(C::count == 5); } - return SRSRAN_SUCCESS; + // TEST: copy-only types + { + dyn_circular_buffer circbuffer(3); + D d{}; + circbuffer.push(d); + circbuffer.push(d); + circbuffer.push(d); + TESTASSERT(circbuffer.full() and D::count == 4); + + dyn_circular_buffer circbuffer2(circbuffer); + TESTASSERT(circbuffer2.full() and circbuffer.full()); + TESTASSERT(D::count == 7); + circbuffer.pop(); + circbuffer.pop(); + TESTASSERT(D::count == 5); + circbuffer = circbuffer2; + TESTASSERT(D::count == 7); + } + TESTASSERT(C::count == 0); } int test_queue_block_api() @@ -115,9 +258,15 @@ int test_queue_block_api_2() } // namespace srsran -int main() +int main(int argc, char** argv) { + auto& test_log = srslog::fetch_basic_logger("TEST"); + test_log.set_level(srslog::basic_levels::info); + + srsran::test_init(argc, argv); + TESTASSERT(srsran::test_static_circular_buffer() == SRSRAN_SUCCESS); + srsran::test_dyn_circular_buffer(); TESTASSERT(srsran::test_queue_block_api() == SRSRAN_SUCCESS); TESTASSERT(srsran::test_queue_block_api_2() == SRSRAN_SUCCESS); srsran::console("Success\n"); From 1b1cfa40c92c82785ff7baf3c303d0f32ab5f531 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Mon, 22 Mar 2021 21:34:51 +0100 Subject: [PATCH 22/48] rlc_am_lte: add some more sanity checks around retx of PDUs this patch doesn't change any functionality but adds a bit of further error checking around the handling of status PDUs and the retx of PDUs --- lib/src/upper/rlc_am_lte.cc | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/lib/src/upper/rlc_am_lte.cc b/lib/src/upper/rlc_am_lte.cc index 5258806d4..a0dc3d561 100644 --- a/lib/src/upper/rlc_am_lte.cc +++ b/lib/src/upper/rlc_am_lte.cc @@ -535,16 +535,24 @@ void rlc_am_lte::rlc_am_lte_tx::timer_expired(uint32_t timeout_id) void rlc_am_lte::rlc_am_lte_tx::retransmit_pdu() { - if (not tx_window.empty()) { - // select first PDU in tx window for retransmission - rlc_amd_tx_pdu_t& pdu = tx_window[vt_a]; - logger.info("%s Schedule SN=%d for reTx.", RB_NAME, pdu.rlc_sn); - rlc_amd_retx_t& retx = retx_queue.push(); - retx.is_segment = false; - retx.so_start = 0; - retx.so_end = pdu.buf->N_bytes; - retx.sn = pdu.rlc_sn; + if (tx_window.empty()) { + logger.warning("%s No PDU to retransmit.", RB_NAME); + return; + } + + if (not tx_window.has_sn(vt_a)) { + logger.warning("%s Can't retransmit unexisting SN=%d.", RB_NAME, vt_a); + return; } + + // select first PDU in tx window for retransmission + rlc_amd_tx_pdu_t& pdu = tx_window[vt_a]; + logger.info("%s Schedule SN=%d for reTx.", RB_NAME, pdu.rlc_sn); + rlc_amd_retx_t& retx = retx_queue.push(); + retx.is_segment = false; + retx.so_start = 0; + retx.so_end = pdu.buf->N_bytes; + retx.sn = pdu.rlc_sn; } /**************************************************************************** @@ -1186,6 +1194,11 @@ void rlc_am_lte::rlc_am_lte_tx::handle_control_pdu(uint8_t* payload, uint32_t no i = (i + 1) % MOD; } + // Make sure vt_a points to valid SN + if (not tx_window.empty() && not tx_window.has_sn(vt_a)) { + logger.error("%s vt_a=%d points to invalid position in Tx window", RB_NAME, vt_a); + } + if (not notify_info_vec.empty()) { // Remove all SDUs that were fully acked for (uint32_t acked_pdcp_sn : notify_info_vec) { From 5bc55ec48c394ea3a7cc96fb7d460d32980ab307 Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Tue, 23 Mar 2021 13:01:48 +0000 Subject: [PATCH 23/48] Changed discard_if to appyly_if in circular_buffer.h. This was done so it would work when circular buffer holds other things that are not unique_pointers. Queue and pop_func had to be made public to be able to call the pop_func when an SDU is discarded. --- lib/include/srsran/adt/circular_buffer.h | 28 ++++++++------------ lib/include/srsran/upper/byte_buffer_queue.h | 10 ++++--- lib/src/upper/rlc_am_lte.cc | 9 +++++-- 3 files changed, 24 insertions(+), 23 deletions(-) diff --git a/lib/include/srsran/adt/circular_buffer.h b/lib/include/srsran/adt/circular_buffer.h index 600273326..e23dca196 100644 --- a/lib/include/srsran/adt/circular_buffer.h +++ b/lib/include/srsran/adt/circular_buffer.h @@ -207,16 +207,14 @@ public: const_iterator end() const { return const_iterator(*this, (rpos + count) % max_size()); } template - T discard_if(const F& func) + bool apply_first(const F& func) { for (auto it = begin(); it != end(); it++) { - if (*it != nullptr && func(*it)) { - T tmp = std::move(*it); - *it = nullptr; - return tmp; + if (func(*it)) { + return true; } } - return nullptr; + return false; } protected: @@ -334,24 +332,20 @@ public: } template - bool discard_if(const F& func) + bool apply_first(const F& func) { std::lock_guard lock(mutex); - T tmp = circ_buffer.discard_if(func); - if (tmp == nullptr) { - return false; - } - pop_func(tmp); - return true; + return circ_buffer.apply_first(func); } + PushingFunc push_func; + PoppingFunc pop_func; + protected: bool active = true; uint8_t nof_waiting = 0; mutable std::mutex mutex; std::condition_variable cvar_empty, cvar_full; - PushingFunc push_func; - PoppingFunc pop_func; CircBuffer circ_buffer; ~base_blocking_queue() { stop(); } @@ -596,9 +590,9 @@ public: void set_size(size_t size) { base_t::circ_buffer.set_size(size); } template - bool discard_if(const F& func) + bool apply_first(const F& func) { - return base_t::discard_if(func); + return base_t::apply_first(func); } }; diff --git a/lib/include/srsran/upper/byte_buffer_queue.h b/lib/include/srsran/upper/byte_buffer_queue.h index aa2ef33dc..4c8a0aa14 100644 --- a/lib/include/srsran/upper/byte_buffer_queue.h +++ b/lib/include/srsran/upper/byte_buffer_queue.h @@ -73,9 +73,9 @@ public: bool is_full() { return queue.full(); } template - bool discard_if(const F& func) + bool apply_first(const F& func) { - return queue.discard_if(func); + return queue.apply_first(func); } private: @@ -105,9 +105,11 @@ private: uint32_t* n_sdus; }; + uint32_t unread_bytes = 0; + uint32_t n_sdus = 0; + +public: dyn_blocking_queue queue; - uint32_t unread_bytes = 0; - uint32_t n_sdus = 0; }; } // namespace srsran diff --git a/lib/src/upper/rlc_am_lte.cc b/lib/src/upper/rlc_am_lte.cc index a0dc3d561..7e51c24e3 100644 --- a/lib/src/upper/rlc_am_lte.cc +++ b/lib/src/upper/rlc_am_lte.cc @@ -454,8 +454,13 @@ void rlc_am_lte::rlc_am_lte_tx::discard_sdu(uint32_t discard_sn) return; } - bool discarded = - tx_sdu_queue.discard_if([&discard_sn](const unique_byte_buffer_t& sdu) { return sdu->md.pdcp_sn == discard_sn; }); + bool discarded = tx_sdu_queue.apply_first([&discard_sn, this](unique_byte_buffer_t& sdu) { + if (sdu != nullptr && sdu->md.pdcp_sn == discard_sn) { + tx_sdu_queue.queue.pop_func(sdu); + sdu = nullptr; + } + return false; + }); if (discarded) { // remove also from undelivered SDUs queue From 5bdf2c93b3b0af1e0741c8c193bb1fc66e241f64 Mon Sep 17 00:00:00 2001 From: Xavier Arteaga Date: Tue, 23 Mar 2021 12:59:50 +0100 Subject: [PATCH 24/48] Initial NR PDSCH CSI-RS RE skip and other changes --- .../interfaces/rrc_nr_interface_types.h | 281 +++++++++++++++ lib/include/srsran/phy/ch_estimation/csi_rs.h | 113 +++---- .../srsran/phy/ch_estimation/csi_rs_cfg.h | 129 +++++++ .../srsran/phy/ch_estimation/dmrs_sch.h | 21 +- lib/include/srsran/phy/phch/csi_cfg.h | 1 + lib/include/srsran/phy/phch/pdsch_nr.h | 2 + lib/include/srsran/phy/phch/phch_cfg_nr.h | 24 +- lib/include/srsran/phy/phch/ra_nr.h | 2 + lib/include/srsran/phy/utils/re_pattern.h | 123 +++++++ lib/include/srsran/phy/utils/vector.h | 1 + lib/src/phy/ch_estimation/csi_rs.c | 222 ++++++++++-- lib/src/phy/ch_estimation/dmrs_pdcch.c | 7 +- lib/src/phy/ch_estimation/dmrs_sch.c | 106 ++++-- lib/src/phy/ch_estimation/test/CMakeLists.txt | 16 +- .../ch_estimation/test/csi_rs_pattern_test.c | 229 +++++++++++++ lib/src/phy/ch_estimation/test/csi_rs_test.c | 8 +- .../phy/ch_estimation/test/dmrs_pdsch_test.c | 65 ++-- lib/src/phy/phch/pdsch_nr.c | 252 ++++---------- lib/src/phy/phch/ra_nr.c | 204 +++++++++-- lib/src/phy/phch/ra_ul_nr.c | 18 - lib/src/phy/phch/test/pdsch_nr_test.c | 62 ++-- lib/src/phy/utils/re_pattern.c | 320 ++++++++++++++++++ lib/src/phy/utils/test/CMakeLists.txt | 9 + lib/src/phy/utils/test/re_pattern_test.c | 60 ++++ lib/src/phy/utils/test/vector_test.c | 46 +++ lib/src/phy/utils/vector.c | 8 + lib/test/adt/circular_map_test.cc | 2 +- lib/test/phy/CMakeLists.txt | 7 +- lib/test/phy/phy_dl_nr_test.c | 117 ++++--- srsenb/src/phy/nr/cc_worker.cc | 5 +- srsue/hdr/phy/nr/state.h | 6 +- srsue/src/phy/nr/cc_worker.cc | 2 +- 32 files changed, 1963 insertions(+), 505 deletions(-) create mode 100644 lib/include/srsran/phy/ch_estimation/csi_rs_cfg.h create mode 100644 lib/include/srsran/phy/utils/re_pattern.h create mode 100644 lib/src/phy/ch_estimation/test/csi_rs_pattern_test.c create mode 100644 lib/src/phy/utils/re_pattern.c create mode 100644 lib/src/phy/utils/test/re_pattern_test.c diff --git a/lib/include/srsran/interfaces/rrc_nr_interface_types.h b/lib/include/srsran/interfaces/rrc_nr_interface_types.h index b1964f65e..c0751687f 100644 --- a/lib/include/srsran/interfaces/rrc_nr_interface_types.h +++ b/lib/include/srsran/interfaces/rrc_nr_interface_types.h @@ -161,6 +161,63 @@ struct phy_cfg_nr_t { pdcch.search_space[2].nof_candidates[4] = 0; pdcch.search_space[2].type = srsran_search_space_type_ue; pdcch.search_space_present[2] = true; + // pdsch-Config: setup (1) + // setup + // dmrs-DownlinkForPDSCH-MappingTypeA: setup (1) + // setup + // dmrs-AdditionalPosition: pos1 (1) + // tci-StatesToAddModList: 1 item + // Item 0 + // TCI-State + // tci-StateId: 0 + // qcl-Type1 + // referenceSignal: ssb (1) + // ssb: 0 + // qcl-Type: typeD (3) + // resourceAllocation: resourceAllocationType1 (1) + // rbg-Size: config1 (0) + // prb-BundlingType: staticBundling (0) + // staticBundling + // bundleSize: wideband (1) + // zp-CSI-RS-ResourceToAddModList: 1 item + // Item 0 + // ZP-CSI-RS-Resource + // zp-CSI-RS-ResourceId: 0 + // resourceMapping + // frequencyDomainAllocation: row4 (2) + // row4: 80 [bit length 3, 5 LSB pad bits, 100. .... + // decimal value 4] + // nrofPorts: p4 (2) + // firstOFDMSymbolInTimeDomain: 8 + // cdm-Type: fd-CDM2 (1) + // density: one (1) + // one: NULL + // freqBand + // startingRB: 0 + // nrofRBs: 52 + // periodicityAndOffset: slots80 (9) + // slots80: 1 + // p-ZP-CSI-RS-ResourceSet: setup (1) + // setup + // zp-CSI-RS-ResourceSetId: 0 + // zp-CSI-RS-ResourceIdList: 1 item + // Item 0 + // ZP-CSI-RS-ResourceId: 0 + srsran_csi_rs_zp_resource_t zp_csi_rs_resource0 = {}; + zp_csi_rs_resource0.resource_mapping.row = srsran_csi_rs_resource_mapping_row_4; + zp_csi_rs_resource0.resource_mapping.frequency_domain_alloc[0] = true; + zp_csi_rs_resource0.resource_mapping.frequency_domain_alloc[1] = false; + zp_csi_rs_resource0.resource_mapping.frequency_domain_alloc[2] = false; + zp_csi_rs_resource0.resource_mapping.nof_ports = 4; + zp_csi_rs_resource0.resource_mapping.first_symbol_idx = 8; + zp_csi_rs_resource0.resource_mapping.cdm = srsran_csi_rs_cdm_fd_cdm2; + zp_csi_rs_resource0.resource_mapping.density = srsran_csi_rs_resource_mapping_density_one; + zp_csi_rs_resource0.resource_mapping.freq_band.start_rb = 0; + zp_csi_rs_resource0.resource_mapping.freq_band.nof_rb = 52; + zp_csi_rs_resource0.periodicity.period = 80; + zp_csi_rs_resource0.periodicity.offset = 1; + pdsch.p_zp_csi_rs_set.data[0] = zp_csi_rs_resource0; + pdsch.p_zp_csi_rs_set.count = 1; // pdsch-ConfigCommon: setup (1) // setup @@ -648,6 +705,230 @@ struct phy_cfg_nr_t { harq_ack.dl_data_to_ul_ack[6] = 11; harq_ack.nof_dl_data_to_ul_ack = 7; + // nzp-CSI-RS-ResourceToAddModList: 5 items + // Item 0 + // NZP-CSI-RS-Resource + // nzp-CSI-RS-ResourceId: 0 + // resourceMapping + // frequencyDomainAllocation: row2 (1) + // row2: 8000 [bit length 12, 4 LSB pad bits, 1000 0000 0000 .... decimal value 2048] + // nrofPorts: p1 (0) + // firstOFDMSymbolInTimeDomain: 4 + // cdm-Type: noCDM (0) + // density: one (1) + // one: NULL + // freqBand + // startingRB: 0 + // nrofRBs: 52 + // powerControlOffset: 0dB + // powerControlOffsetSS: db0 (1) + // scramblingID: 0 + // periodicityAndOffset: slots80 (9) + // slots80: 1 + // qcl-InfoPeriodicCSI-RS: 0 + srsran_csi_rs_nzp_resource_t nzp_resource_0 = {}; + nzp_resource_0.resource_mapping.row = srsran_csi_rs_resource_mapping_row_2; + nzp_resource_0.resource_mapping.frequency_domain_alloc[0] = true; + nzp_resource_0.resource_mapping.frequency_domain_alloc[1] = false; + nzp_resource_0.resource_mapping.frequency_domain_alloc[2] = false; + nzp_resource_0.resource_mapping.frequency_domain_alloc[3] = false; + nzp_resource_0.resource_mapping.frequency_domain_alloc[4] = false; + nzp_resource_0.resource_mapping.frequency_domain_alloc[5] = false; + nzp_resource_0.resource_mapping.frequency_domain_alloc[6] = false; + nzp_resource_0.resource_mapping.frequency_domain_alloc[7] = false; + nzp_resource_0.resource_mapping.frequency_domain_alloc[8] = false; + nzp_resource_0.resource_mapping.frequency_domain_alloc[9] = false; + nzp_resource_0.resource_mapping.frequency_domain_alloc[10] = false; + nzp_resource_0.resource_mapping.frequency_domain_alloc[11] = false; + nzp_resource_0.resource_mapping.nof_ports = 1; + nzp_resource_0.resource_mapping.first_symbol_idx = 4; + nzp_resource_0.resource_mapping.cdm = srsran_csi_rs_cdm_nocdm; + nzp_resource_0.resource_mapping.density = srsran_csi_rs_resource_mapping_density_one; + nzp_resource_0.resource_mapping.freq_band.start_rb = 0; + nzp_resource_0.resource_mapping.freq_band.nof_rb = 52; + nzp_resource_0.power_control_offset = 0; + nzp_resource_0.power_control_offset_ss = 0; + nzp_resource_0.scrambling_id = 0; + nzp_resource_0.periodicity.period = 80; + nzp_resource_0.periodicity.offset = 1; + + // Item 1 + // NZP-CSI-RS-Resource + // nzp-CSI-RS-ResourceId: 1 + // resourceMapping + // frequencyDomainAllocation: row1 (0) + // row1: 10 [bit length 4, 4 LSB pad bits, 0001 .... decimal value 1] + // nrofPorts: p1 (0) + // firstOFDMSymbolInTimeDomain: 4 + // cdm-Type: noCDM (0) + // density: three (2) + // three: NULL + // freqBand + // startingRB: 0 + // nrofRBs: 52 + // powerControlOffset: 0dB + // powerControlOffsetSS: db0 (1) + // scramblingID: 0 + // periodicityAndOffset: slots40 (7) + // slots40: 11 + // qcl-InfoPeriodicCSI-RS: 0 + srsran_csi_rs_nzp_resource_t nzp_resource_1 = {}; + nzp_resource_1.resource_mapping.row = srsran_csi_rs_resource_mapping_row_1; + nzp_resource_1.resource_mapping.frequency_domain_alloc[0] = false; + nzp_resource_1.resource_mapping.frequency_domain_alloc[1] = false; + nzp_resource_1.resource_mapping.frequency_domain_alloc[2] = false; + nzp_resource_1.resource_mapping.frequency_domain_alloc[3] = true; + nzp_resource_1.resource_mapping.nof_ports = 1; + nzp_resource_1.resource_mapping.first_symbol_idx = 4; + nzp_resource_1.resource_mapping.cdm = srsran_csi_rs_cdm_nocdm; + nzp_resource_1.resource_mapping.density = srsran_csi_rs_resource_mapping_density_three; + nzp_resource_1.resource_mapping.freq_band.start_rb = 0; + nzp_resource_1.resource_mapping.freq_band.nof_rb = 52; + nzp_resource_1.power_control_offset = 0; + nzp_resource_1.power_control_offset_ss = 0; + nzp_resource_1.scrambling_id = 0; + nzp_resource_1.periodicity.period = 40; + nzp_resource_1.periodicity.offset = 11; + // Item 2 + // NZP-CSI-RS-Resource + // nzp-CSI-RS-ResourceId: 2 + // resourceMapping + // frequencyDomainAllocation: row1 (0) + // row1: 10 [bit length 4, 4 LSB pad bits, 0001 .... decimal value 1] + // nrofPorts: p1 (0) + // firstOFDMSymbolInTimeDomain: 8 + // cdm-Type: noCDM (0) + // density: three (2) + // three: NULL + // freqBand + // startingRB: 0 + // nrofRBs: 52 + // powerControlOffset: 0dB + // powerControlOffsetSS: db0 (1) + // scramblingID: 0 + // periodicityAndOffset: slots40 (7) + // slots40: 11 + // qcl-InfoPeriodicCSI-RS: 0 + srsran_csi_rs_nzp_resource_t nzp_resource_2 = {}; + nzp_resource_2.resource_mapping.row = srsran_csi_rs_resource_mapping_row_1; + nzp_resource_2.resource_mapping.frequency_domain_alloc[0] = false; + nzp_resource_2.resource_mapping.frequency_domain_alloc[1] = false; + nzp_resource_2.resource_mapping.frequency_domain_alloc[2] = false; + nzp_resource_2.resource_mapping.frequency_domain_alloc[3] = true; + nzp_resource_2.resource_mapping.nof_ports = 1; + nzp_resource_2.resource_mapping.first_symbol_idx = 8; + nzp_resource_2.resource_mapping.cdm = srsran_csi_rs_cdm_nocdm; + nzp_resource_2.resource_mapping.density = srsran_csi_rs_resource_mapping_density_three; + nzp_resource_2.resource_mapping.freq_band.start_rb = 0; + nzp_resource_2.resource_mapping.freq_band.nof_rb = 52; + nzp_resource_2.power_control_offset = 0; + nzp_resource_2.power_control_offset_ss = 0; + nzp_resource_2.scrambling_id = 0; + nzp_resource_2.periodicity.period = 40; + nzp_resource_2.periodicity.offset = 11; + // Item 3 + // NZP-CSI-RS-Resource + // nzp-CSI-RS-ResourceId: 3 + // resourceMapping + // frequencyDomainAllocation: row1 (0) + // row1: 10 [bit length 4, 4 LSB pad bits, 0001 .... decimal value 1] + // nrofPorts: p1 (0) + // firstOFDMSymbolInTimeDomain: 4 + // cdm-Type: noCDM (0) + // density: three (2) + // three: NULL + // freqBand + // startingRB: 0 + // nrofRBs: 52 + // powerControlOffset: 0dB + // powerControlOffsetSS: db0 (1) + // scramblingID: 0 + // periodicityAndOffset: slots40 (7) + // slots40: 12 + // qcl-InfoPeriodicCSI-RS: 0 + srsran_csi_rs_nzp_resource_t nzp_resource_3 = {}; + nzp_resource_3.resource_mapping.row = srsran_csi_rs_resource_mapping_row_1; + nzp_resource_3.resource_mapping.frequency_domain_alloc[0] = false; + nzp_resource_3.resource_mapping.frequency_domain_alloc[1] = false; + nzp_resource_3.resource_mapping.frequency_domain_alloc[2] = false; + nzp_resource_3.resource_mapping.frequency_domain_alloc[3] = true; + nzp_resource_3.resource_mapping.nof_ports = 1; + nzp_resource_3.resource_mapping.first_symbol_idx = 4; + nzp_resource_3.resource_mapping.cdm = srsran_csi_rs_cdm_nocdm; + nzp_resource_3.resource_mapping.density = srsran_csi_rs_resource_mapping_density_three; + nzp_resource_3.resource_mapping.freq_band.start_rb = 0; + nzp_resource_3.resource_mapping.freq_band.nof_rb = 52; + nzp_resource_3.power_control_offset = 0; + nzp_resource_3.power_control_offset_ss = 0; + nzp_resource_3.scrambling_id = 0; + nzp_resource_3.periodicity.period = 40; + nzp_resource_3.periodicity.offset = 12; + // Item 4 + // NZP-CSI-RS-Resource + // nzp-CSI-RS-ResourceId: 4 + // resourceMapping + // frequencyDomainAllocation: row1 (0) + // row1: 10 [bit length 4, 4 LSB pad bits, 0001 .... decimal value 1] + // nrofPorts: p1 (0) + // firstOFDMSymbolInTimeDomain: 8 + // cdm-Type: noCDM (0) + // density: three (2) + // three: NULL + // freqBand + // startingRB: 0 + // nrofRBs: 52 + // powerControlOffset: 0dB + // powerControlOffsetSS: db0 (1) + // scramblingID: 0 + // periodicityAndOffset: slots40 (7) + // slots40: 12 + // qcl-InfoPeriodicCSI-RS: 0 + srsran_csi_rs_nzp_resource_t nzp_resource_4 = {}; + nzp_resource_4.resource_mapping.row = srsran_csi_rs_resource_mapping_row_1; + nzp_resource_4.resource_mapping.frequency_domain_alloc[0] = false; + nzp_resource_4.resource_mapping.frequency_domain_alloc[1] = false; + nzp_resource_4.resource_mapping.frequency_domain_alloc[2] = false; + nzp_resource_4.resource_mapping.frequency_domain_alloc[3] = true; + nzp_resource_4.resource_mapping.nof_ports = 1; + nzp_resource_4.resource_mapping.first_symbol_idx = 8; + nzp_resource_4.resource_mapping.cdm = srsran_csi_rs_cdm_nocdm; + nzp_resource_4.resource_mapping.density = srsran_csi_rs_resource_mapping_density_three; + nzp_resource_4.resource_mapping.freq_band.start_rb = 0; + nzp_resource_4.resource_mapping.freq_band.nof_rb = 52; + nzp_resource_4.power_control_offset = 0; + nzp_resource_4.power_control_offset_ss = 0; + nzp_resource_4.scrambling_id = 0; + nzp_resource_4.periodicity.period = 40; + nzp_resource_4.periodicity.offset = 12; + // zp-CSI-RS-ResourceSetToAddModList: 2 items + // Item 0 + // NZP-CSI-RS-ResourceSet + // nzp-CSI-ResourceSetId: 0 + // nzp-CSI-RS-Resources: 1 item + // Item 0 + // NZP-CSI-RS-ResourceId: 0 + pdsch.nzp_csi_rs_sets[0].data[0] = nzp_resource_0; + pdsch.nzp_csi_rs_sets[0].count = 1; + pdsch.nzp_csi_rs_sets[0].trs_info = false; + // Item 1 + // NZP-CSI-RS-ResourceSet + // nzp-CSI-ResourceSetId: 1 + // nzp-CSI-RS-Resources: 4 items + // Item 0 + // NZP-CSI-RS-ResourceId: 1 + // Item 1 + // NZP-CSI-RS-ResourceId: 2 + // Item 2 + // NZP-CSI-RS-ResourceId: 3 + // Item 3 + // NZP-CSI-RS-ResourceId: 4 + // trs-Info: true (0) + pdsch.nzp_csi_rs_sets[1].data[0] = nzp_resource_1; + pdsch.nzp_csi_rs_sets[1].data[1] = nzp_resource_2; + pdsch.nzp_csi_rs_sets[1].data[2] = nzp_resource_3; + pdsch.nzp_csi_rs_sets[1].data[3] = nzp_resource_4; + pdsch.nzp_csi_rs_sets[1].count = 4; + pdsch.nzp_csi_rs_sets[1].trs_info = true; // csi-ReportConfigToAddModList: 1 item // Item 0 // CSI-ReportConfig diff --git a/lib/include/srsran/phy/ch_estimation/csi_rs.h b/lib/include/srsran/phy/ch_estimation/csi_rs.h index ab7219dd3..7f7e659c9 100644 --- a/lib/include/srsran/phy/ch_estimation/csi_rs.h +++ b/lib/include/srsran/phy/ch_estimation/csi_rs.h @@ -13,95 +13,35 @@ #ifndef SRSRAN_CSI_RS_H_ #define SRSRAN_CSI_RS_H_ -#include "srsran/config.h" -#include "srsran/phy/common/phy_common_nr.h" +#include "csi_rs_cfg.h" +#include "srsran/phy/phch/phch_cfg_nr.h" #include #include #include +/** + * @brief Number of frequency domain elements for Row 1 + */ #define SRSRAN_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_ROW1 4 -#define SRSRAN_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_ROW2 12 -#define SRSRAN_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_ROW4 3 -#define SRSRAN_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_OTHER 6 -#define SRSRAN_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_MAX 12 - -typedef enum SRSRAN_API { - srsran_csi_rs_resource_mapping_row_1 = 0, - srsran_csi_rs_resource_mapping_row_2, - srsran_csi_rs_resource_mapping_row_4, - srsran_csi_rs_resource_mapping_row_other, -} srsran_csi_rs_resource_mapping_row_t; - -typedef enum SRSRAN_API { - srsran_csi_rs_resource_mapping_density_three = 0, - srsran_csi_rs_resource_mapping_density_dot5_even, - srsran_csi_rs_resource_mapping_density_dot5_odd, - srsran_csi_rs_resource_mapping_density_one, - srsran_csi_rs_resource_mapping_density_spare -} srsran_csi_rs_density_t; - -typedef enum SRSRAN_API { - srsran_csi_rs_cdm_nocdm = 0, - srsran_csi_rs_cdm_fd_cdm2, - srsran_csi_rs_cdm_cdm4_fd2_td2, - srsran_csi_rs_cdm_cdm8_fd2_td4 -} srsran_csi_rs_cdm_t; /** - * @brief Contains CSI-FrequencyOccupation flattened configuration + * @brief Number of frequency domain elements for Row 2 */ -typedef struct SRSRAN_API { - uint32_t start_rb; ///< PRB where this CSI resource starts in relation to common resource block #0 (CRB#0) on the - ///< common resource block grid. Only multiples of 4 are allowed (0, 4, ..., 274) - - uint32_t nof_rb; ///< Number of PRBs across which this CSI resource spans. Only multiples of 4 are allowed. The - ///< smallest configurable number is the minimum of 24 and the width of the associated BWP. If the - ///< configured value is larger than the width of the corresponding BWP, the UE shall assume that the - ///< actual CSI-RS bandwidth is equal to the width of the BWP. -} srsran_csi_rs_freq_occupation_t; +#define SRSRAN_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_ROW2 12 /** - * @brief Contains CSI-ResourcePeriodicityAndOffset flattened configuration + * @brief Number of frequency domain elements for Row 4 */ -typedef struct SRSRAN_API { - uint32_t period; // 4,5,8,10,16,20,32,40,64,80,160,320,640 - uint32_t offset; // 0..period-1 -} srsran_csi_rs_period_and_offset_t; +#define SRSRAN_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_ROW4 3 /** - * @brief Contains CSI-RS-ResourceMapping flattened configuration + * @brief Number of frequency domain elements for other rows */ -typedef struct SRSRAN_API { - srsran_csi_rs_resource_mapping_row_t row; - bool frequency_domain_alloc[SRSRAN_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_MAX]; - uint32_t ports; // 1, 2, 4, 8, 12, 16, 24, 32 - uint32_t first_symbol_idx; // 0..13 - uint32_t first_symbol_idx2; // 2..12 (set to 0 for disabled) - srsran_csi_rs_cdm_t cdm; - srsran_csi_rs_density_t density; - srsran_csi_rs_freq_occupation_t freq_band; -} srsran_csi_rs_resource_mapping_t; +#define SRSRAN_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_OTHER 6 /** - * @brief Contains NZP-CSI-RS-Resource flattened configuration + * @brief Measurement structure */ -typedef struct SRSRAN_API { - srsran_csi_rs_resource_mapping_t resource_mapping; - - float power_control_offset; // -8..15 dB - float power_control_offset_ss; // -3, 0, 3, 6 dB - - uint32_t scrambling_id; // 0..1023 - - srsran_csi_rs_period_and_offset_t periodicity; - -} srsran_csi_rs_nzp_resource_t; - -SRSRAN_API int srsran_csi_rs_nzp_put(const srsran_carrier_nr_t* carrier, - const srsran_slot_cfg_t* slot_cfg, - const srsran_csi_rs_nzp_resource_t* resource, - cf_t* grid); - typedef struct SRSRAN_API { float rsrp; float rsrp_dB; @@ -113,6 +53,35 @@ typedef struct SRSRAN_API { uint32_t nof_re; } srsran_csi_rs_measure_t; +/** + * @brief Calculates if the given periodicity implies a CSI-RS transmission in the given slot + * @remark Described in TS 36.211 section 7.4.1.5.3 Mapping to physical resources + * @param periodicity Periodicity configuration + * @param slot_cfg Slot configuration + * @return True if the periodicity configuration matches with the slot, false otherwise + */ +SRSRAN_API bool srsran_csi_rs_send(const srsran_csi_rs_period_and_offset_t* periodicity, + const srsran_slot_cfg_t* slot_cfg); + +/** + * @brief Adds to a RE pattern list the RE used in a CSI-RS resource for all CDM grops. This is intended for generating + * reserved RE pattern for PDSCH transmission. + * @param carrier Provides carrier configuration + * @param resource Provides a CSI-RS resource + * @param nof_resources Provides the number of ZP-CSI-RS resources + * @param l Symbol index in the slot + * @param[out] rvd_mask Provides the reserved mask + * @return SRSRAN_SUCCESS if the provided data is valid, and SRSRAN_ERROR code otherwise + */ +SRSRAN_API int srsran_csi_rs_append_resource_to_pattern(const srsran_carrier_nr_t* carrier, + const srsran_csi_rs_resource_mapping_t* resource, + srsran_re_pattern_list_t* re_pattern_list); + +SRSRAN_API int srsran_csi_rs_nzp_put(const srsran_carrier_nr_t* carrier, + const srsran_slot_cfg_t* slot_cfg, + const srsran_csi_rs_nzp_resource_t* resource, + cf_t* grid); + SRSRAN_API int srsran_csi_rs_nzp_measure(const srsran_carrier_nr_t* carrier, const srsran_slot_cfg_t* slot_cfg, const srsran_csi_rs_nzp_resource_t* resource, diff --git a/lib/include/srsran/phy/ch_estimation/csi_rs_cfg.h b/lib/include/srsran/phy/ch_estimation/csi_rs_cfg.h new file mode 100644 index 000000000..de52f62bc --- /dev/null +++ b/lib/include/srsran/phy/ch_estimation/csi_rs_cfg.h @@ -0,0 +1,129 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +#ifndef SRSRAN_CSI_RS_CFG_H +#define SRSRAN_CSI_RS_CFG_H + +#include "srsran/config.h" +#include "srsran/phy/common/phy_common_nr.h" + +/** + * @brief Maximum number of ZP CSI-RS resources per set defined in + * - TS 38.214 clause 5.1.4.2 PDSCH resource mapping with RE level granularity + * - TS 38.331 constant maxNrofZP-CSI-RS-ResourcesPerSet + */ +#define SRSRAN_PHCH_CFG_MAX_NOF_CSI_RS_PER_SET 16 + +/** + * @brief Maximum number of ZP CSI-RS Sets defined in TS 38.331 constant maxNrofZP-CSI-RS-ResourceSets + */ +#define SRSRAN_PHCH_CFG_MAX_NOF_CSI_RS_SETS 16 + +/** + * @brief Maximum number of CSI-RS frequency domain allocation bits + */ +#define SRSRAN_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_MAX 12 + +typedef enum SRSRAN_API { + srsran_csi_rs_resource_mapping_row_1 = 0, + srsran_csi_rs_resource_mapping_row_2, + srsran_csi_rs_resource_mapping_row_4, + srsran_csi_rs_resource_mapping_row_other, +} srsran_csi_rs_resource_mapping_row_t; + +typedef enum SRSRAN_API { + srsran_csi_rs_resource_mapping_density_three = 0, + srsran_csi_rs_resource_mapping_density_dot5_even, + srsran_csi_rs_resource_mapping_density_dot5_odd, + srsran_csi_rs_resource_mapping_density_one, + srsran_csi_rs_resource_mapping_density_spare +} srsran_csi_rs_density_t; + +typedef enum SRSRAN_API { + srsran_csi_rs_cdm_nocdm = 0, + srsran_csi_rs_cdm_fd_cdm2, + srsran_csi_rs_cdm_cdm4_fd2_td2, + srsran_csi_rs_cdm_cdm8_fd2_td4 +} srsran_csi_rs_cdm_t; + +/** + * @brief Contains CSI-FrequencyOccupation flattened configuration + */ +typedef struct SRSRAN_API { + uint32_t start_rb; ///< PRB where this CSI resource starts in relation to common resource block #0 (CRB#0) on the + ///< common resource block grid. Only multiples of 4 are allowed (0, 4, ..., 274) + + uint32_t nof_rb; ///< Number of PRBs across which this CSI resource spans. Only multiples of 4 are allowed. The + ///< smallest configurable number is the minimum of 24 and the width of the associated BWP. If the + ///< configured value is larger than the width of the corresponding BWP, the UE shall assume that the + ///< actual CSI-RS bandwidth is equal to the width of the BWP. +} srsran_csi_rs_freq_occupation_t; + +/** + * @brief Contains CSI-ResourcePeriodicityAndOffset flattened configuration + */ +typedef struct SRSRAN_API { + uint32_t period; // 4,5,8,10,16,20,32,40,64,80,160,320,640 + uint32_t offset; // 0..period-1 +} srsran_csi_rs_period_and_offset_t; + +/** + * @brief Contains CSI-RS-ResourceMapping flattened configuration + */ +typedef struct SRSRAN_API { + srsran_csi_rs_resource_mapping_row_t row; + bool frequency_domain_alloc[SRSRAN_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_MAX]; + uint32_t nof_ports; // 1, 2, 4, 8, 12, 16, 24, 32 + uint32_t first_symbol_idx; // 0..13 + uint32_t first_symbol_idx2; // 2..12 (set to 0 for disabled) + srsran_csi_rs_cdm_t cdm; + srsran_csi_rs_density_t density; + srsran_csi_rs_freq_occupation_t freq_band; +} srsran_csi_rs_resource_mapping_t; + +/** + * @brief Contains TS 38.331 NZP-CSI-RS-Resource flattened configuration + */ +typedef struct SRSRAN_API { + srsran_csi_rs_resource_mapping_t resource_mapping; ///< CSI-RS time/frequency mapping + float power_control_offset; ///< -8..15 dB + float power_control_offset_ss; ///< -3, 0, 3, 6 dB + uint32_t scrambling_id; ///< 0..1023 + srsran_csi_rs_period_and_offset_t periodicity; ///< Periodicity +} srsran_csi_rs_nzp_resource_t; + +/** + * @brief Non-Zero-Power CSI resource set + */ +typedef struct SRSRAN_API { + srsran_csi_rs_nzp_resource_t data[SRSRAN_PHCH_CFG_MAX_NOF_CSI_RS_PER_SET]; ///< Resources + uint32_t count; ///< Set to zero for not present + bool trs_info; ///< Indicates that the antenna port for all NZP-CSI-RS resources in the CSI-RS resource set is same. +} srsran_csi_rs_nzp_set_t; + +/** + * @brief Contains TS 38.331 ZP-CSI-RS-Resource flattened configuration + */ +typedef struct { + srsran_csi_rs_resource_mapping_t resource_mapping; ///< CSI-RS time/frequency mapping + srsran_csi_rs_period_and_offset_t periodicity; +} srsran_csi_rs_zp_resource_t; + +/** + * @brief Zero-Power CSI resource set + */ +typedef struct SRSRAN_API { + srsran_csi_rs_zp_resource_t data[SRSRAN_PHCH_CFG_MAX_NOF_CSI_RS_PER_SET]; ///< Resources + uint32_t count; ///< Number of resources in the set +} srsran_csi_rs_zp_set_t; + +#endif // SRSRAN_CSI_RS_CFG_H diff --git a/lib/include/srsran/phy/ch_estimation/dmrs_sch.h b/lib/include/srsran/phy/ch_estimation/dmrs_sch.h index a5aed07fe..93a031cf6 100644 --- a/lib/include/srsran/phy/ch_estimation/dmrs_sch.h +++ b/lib/include/srsran/phy/ch_estimation/dmrs_sch.h @@ -63,15 +63,14 @@ SRSRAN_API int srsran_dmrs_sch_get_symbols_idx(const srsran_dmrs_sch_cfg_t* dmrs uint32_t symbols_idx[SRSRAN_DMRS_SCH_MAX_SYMBOLS]); /** - * @brief Computes the sub-carrier indexes carrying DMRS - * + * @brief Computes the resource element pattern of resource elements reserved for DMRS * @param cfg PDSCH DMRS configuration provided by upper layers - * @param max_count is the number of sub-carriers to generate - * @param sc_idx is the destination pointer where the sub-carrier indexes are stored - * - * @return It returns the number of sub-carriers if inputs are valid, otherwise, it returns SRSRAN_ERROR code. + * @param[out] pattern Provides the RE pattern to fill + * @return SRSRAN_SUCCESS if computation is successful, SRSRAN_ERROR code otherwise */ -SRSRAN_API int srsran_dmrs_sch_get_sc_idx(const srsran_dmrs_sch_cfg_t* cfg, uint32_t max_count, uint32_t* sc_idx); +SRSRAN_API int srsran_dmrs_sch_rvd_re_pattern(const srsran_dmrs_sch_cfg_t* cfg, + const srsran_sch_grant_nr_t* grant, + srsran_re_pattern_t* pattern); /** * @brief Calculates the number of resource elements taken by a PDSCH-DMRS for a given PDSCH transmission @@ -143,8 +142,8 @@ SRSRAN_API int srsran_dmrs_sch_put_sf(srsran_dmrs_sch_t* q, * @attention Current implementation supports only type1 PDSCH DMRS (1 pilot every 2 RE) * * @param q DMRS-PDSCH object - * @param slot_cfg Slot configuration - * @param pdsch_cfg PDSCH configuration provided by upper layers + * @param slot Slot configuration + * @param cfg PDSCH configuration provided by upper layers * @param grant PDSCH information provided by a DCI * @param sf_symbols Received resource grid * @param[out] ce Channel estimates @@ -152,8 +151,8 @@ SRSRAN_API int srsran_dmrs_sch_put_sf(srsran_dmrs_sch_t* q, * @return it returns SRSRAN_ERROR code if an error occurs, otherwise it returns SRSRAN_SUCCESS */ SRSRAN_API int srsran_dmrs_sch_estimate(srsran_dmrs_sch_t* q, - const srsran_slot_cfg_t* slot_cfg, - const srsran_sch_cfg_nr_t* pdsch_cfg, + const srsran_slot_cfg_t* slot, + const srsran_sch_cfg_nr_t* cfg, const srsran_sch_grant_nr_t* grant, const cf_t* sf_symbols, srsran_chest_dl_res_t* chest_res); diff --git a/lib/include/srsran/phy/phch/csi_cfg.h b/lib/include/srsran/phy/phch/csi_cfg.h index 81cf88f88..40787c6be 100644 --- a/lib/include/srsran/phy/phch/csi_cfg.h +++ b/lib/include/srsran/phy/phch/csi_cfg.h @@ -26,6 +26,7 @@ * @brief Maximum number of CSI-RS resources defined in TS 38.331 maxNrofCSI-ResourceConfigurations */ #define SRSRAN_CSI_MAX_NOF_RESOURCES 112 + /** * @brief CSI report types defined in TS 38.331 CSI-ReportConfig */ diff --git a/lib/include/srsran/phy/phch/pdsch_nr.h b/lib/include/srsran/phy/phch/pdsch_nr.h index 0cd163afc..63190ee03 100644 --- a/lib/include/srsran/phy/phch/pdsch_nr.h +++ b/lib/include/srsran/phy/phch/pdsch_nr.h @@ -55,6 +55,8 @@ typedef struct SRSRAN_API { srsran_evm_buffer_t* evm_buffer; bool meas_time_en; uint32_t meas_time_us; + srsran_re_pattern_t dmrs_re_pattern; + uint32_t nof_rvd_re; } srsran_pdsch_nr_t; /** diff --git a/lib/include/srsran/phy/phch/phch_cfg_nr.h b/lib/include/srsran/phy/phch/phch_cfg_nr.h index b464907d9..95b49d934 100644 --- a/lib/include/srsran/phy/phch/phch_cfg_nr.h +++ b/lib/include/srsran/phy/phch/phch_cfg_nr.h @@ -21,9 +21,17 @@ #ifndef SRSRAN_PHCH_CFG_NR_H #define SRSRAN_PHCH_CFG_NR_H +#include "srsran/phy/ch_estimation/csi_rs_cfg.h" #include "srsran/phy/common/phy_common_nr.h" #include "srsran/phy/phch/sch_cfg_nr.h" #include "srsran/phy/phch/uci_cfg_nr.h" +#include "srsran/phy/utils/re_pattern.h" + +/** + * @brief Specifies the maximum number of ZP-CSI-RS resources configured per slot. It is not implicitly specified in the + * TS. + */ +#define SRSRAN_PHCH_CFG_MAX_NOF_ZP_CSI_RS_RES_PER_SLOT 16 /** * @brief PDSCH DMRS type @@ -203,6 +211,12 @@ typedef struct SRSRAN_API { srsran_sch_cfg_t sch_cfg; ///< Common shared channel parameters + /// PDSCH Periodic ZP-CSI-RS set + srsran_csi_rs_zp_set_t p_zp_csi_rs_set; + + /// PDSCH Periodic NZP-CSI-RS set, indexed by nzp-CSI-ResourceSetId + srsran_csi_rs_nzp_set_t nzp_csi_rs_sets[SRSRAN_PHCH_CFG_MAX_NOF_CSI_RS_SETS]; + /// PUSCH only srsran_beta_offsets_t beta_offsets; /// Semi-static only. float scaling; /// Indicates a scaling factor to limit the number of resource elements assigned to UCI on PUSCH. @@ -213,12 +227,12 @@ typedef struct SRSRAN_API { */ typedef struct SRSRAN_API { bool scrambling_id_present; - uint32_t scambling_id; // Identifier used to initialize data scrambling (0-1023) + uint32_t scambling_id; ///< Identifier used to initialize data scrambling (0-1023) - srsran_dmrs_sch_cfg_t dmrs; - srsran_sch_grant_nr_t grant; - - srsran_sch_cfg_t sch_cfg; ///< Common shared channel parameters + srsran_dmrs_sch_cfg_t dmrs; ///< DMRS configuration for this transmission + srsran_sch_grant_nr_t grant; ///< Actual SCH grant + srsran_sch_cfg_t sch_cfg; ///< Common shared channel parameters + srsran_re_pattern_list_t rvd_re; ///< Reserved resource elements, as pattern /// PUSCH only parameters srsran_uci_cfg_nr_t uci; ///< Uplink Control Information configuration diff --git a/lib/include/srsran/phy/phch/ra_nr.h b/lib/include/srsran/phy/phch/ra_nr.h index 546d20eca..344ef060d 100644 --- a/lib/include/srsran/phy/phch/ra_nr.h +++ b/lib/include/srsran/phy/phch/ra_nr.h @@ -90,12 +90,14 @@ SRSRAN_API int srsran_ra_nr_fill_tb(const srsran_sch_cfg_nr_t* pdsch_cfg, * Note: Only TypeA PDSCH mapping type is supported * * @param carrier Carrier information struct + * @param slot Slot configuration * @param pdsch_cfg PDSCH configuration indicated by higher layers * @param dci_dl DCI downlink (format 1_0 or 1_1) * @param pdsch_grant Generated PDSCH grant * @return 0 on success, -1 on error */ SRSRAN_API int srsran_ra_dl_dci_to_grant_nr(const srsran_carrier_nr_t* carrier, + const srsran_slot_cfg_t* slot, const srsran_sch_hl_cfg_nr_t* pdsch_cfg, const srsran_dci_dl_nr_t* dci_dl, srsran_sch_cfg_nr_t* cfg, diff --git a/lib/include/srsran/phy/utils/re_pattern.h b/lib/include/srsran/phy/utils/re_pattern.h new file mode 100644 index 000000000..00ab2a865 --- /dev/null +++ b/lib/include/srsran/phy/utils/re_pattern.h @@ -0,0 +1,123 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +#ifndef SRSRAN_RE_PATTERN_H +#define SRSRAN_RE_PATTERN_H + +#include "../common/phy_common_nr.h" + +/** + * @brief Maximum number of elements in a pattern list + */ +#define SRSRAN_RE_PATTERN_LIST_SIZE 4 + +/** + * @brief Characterizes a pattern in frequency-time domain in an NR slot resource grid + */ +typedef struct SRSRAN_API { + uint32_t rb_begin; ///< RB where the pattern begins in frequency domain + uint32_t rb_end; ///< RB where the pattern ends in frequency domain (excluded) + uint32_t rb_stride; ///< RB index jump + bool sc[SRSRAN_NRE]; ///< Frequency-domain pattern + bool symbol[SRSRAN_NSYMB_PER_SLOT_NR]; ///< Indicates OFDM symbols where the pattern is present +} srsran_re_pattern_t; + +/** + * @brief List of RE patterns + */ +typedef struct SRSRAN_API { + srsran_re_pattern_t data[SRSRAN_RE_PATTERN_LIST_SIZE]; ///< Actual patterns + uint32_t count; ///< Number of RE patterns +} srsran_re_pattern_list_t; + +/** + * @brief Calculates if a pattern matches a RE given a symbol l and a subcarrier k + * @param list Provides a list of patterns + * @param l OFDM symbol index + * @param k Subcarrier index + * @return True if pattern is valid and there is a match, false otherwise + */ +SRSRAN_API bool srsran_re_pattern_to_mask(const srsran_re_pattern_list_t* list, uint32_t l, uint32_t k); + +/** + * @brief Calculates the pattern mask for an entire symbol from a RE pattern list + * @param list Provides a list of patterns + * @param l OFDM symbol index + * @param[out] mask Mask vector + * @return SRSRAN_SUCCESS if the mask is computed successfully, SRSRAN_ERROR code otherwise + */ +SRSRAN_API int srsran_re_pattern_to_symbol_mask(const srsran_re_pattern_t* pattern, uint32_t l, bool* mask); + +/** + * @brief Calculates the pattern mask for an entire symbol from a RE pattern + * @param list Provides a list of patterns + * @param l OFDM symbol index + * @param[out] mask Mask vector + * @return SRSRAN_SUCCESS if the mask is computed successfully, SRSRAN_ERROR code otherwise + */ +SRSRAN_API int srsran_re_pattern_list_to_symbol_mask(const srsran_re_pattern_list_t* list, uint32_t l, bool* mask); + +/** + * @brief Merges a pattern into the pattern list, it either merges subcarrier or symbol mask or simply appends a new + * pattern + * @param patterns Provides a list of patterns + * @param p Provides pattern to merge + * @return SRSRAN_SUCCESS if merging is successful, SRSRAN_ERROR code otherwise + */ +SRSRAN_API int srsran_re_pattern_merge(srsran_re_pattern_list_t* list, const srsran_re_pattern_t* p); + +/** + * @brief Checks collision between a RE pattern list and a RE pattern + * @param list Provides pattern list + * @param p Provides a pattern + * @return SRSLTE_SUCCESS if no collision is detected, SRSLTE_ERROR code otherwise + */ +SRSRAN_API int srsran_re_pattern_check_collision(const srsran_re_pattern_list_t* list, const srsran_re_pattern_t* p); + +/** + * @brief Initialises a given pattern list + * @param patterns Provides a list of patterns + */ +SRSRAN_API void srsran_re_pattern_reset(srsran_re_pattern_list_t* list); + +/** + * @brief Writes a RE pattern information into a string + * @param pattern Provides the pattern + * @param str Provides string pointer + * @param str_len Maximum string length + * @return The number of characters writen into the string + */ +SRSRAN_API uint32_t srsran_re_pattern_info(const srsran_re_pattern_t* pattern, char* str, uint32_t str_len); + +/** + * @brief Writes a RE pattern list information into a string + * @param pattern Provides the pattern list + * @param str Provides string pointer + * @param str_len Maximum string length + * @return The number of characters writen into the string + */ +SRSRAN_API uint32_t srsran_re_pattern_list_info(const srsran_re_pattern_list_t* pattern, char* str, uint32_t str_len); + +/** + * @brief Counts the number of RE in a transmission characterised by initial and final symbol indexes and a PRB mask. + * @param list RE pattern list + * @param symbol_begin First transmission symbol + * @param symbol_end Last (excluded) transmission symbol + * @param prb_mask Frequency domain resource block mask + * @return The number of RE occupied by the pattern list in the transmission + */ +SRSRAN_API uint32_t srsran_re_pattern_list_count(const srsran_re_pattern_list_t* list, + uint32_t symbol_begin, + uint32_t symbol_end, + const bool prb_mask[SRSRAN_MAX_PRB_NR]); + +#endif // SRSRAN_RE_PATTERN_H diff --git a/lib/include/srsran/phy/utils/vector.h b/lib/include/srsran/phy/utils/vector.h index 5ea401301..c0022c6a8 100644 --- a/lib/include/srsran/phy/utils/vector.h +++ b/lib/include/srsran/phy/utils/vector.h @@ -181,6 +181,7 @@ SRSRAN_API void srsran_vec_prod_sss(const int16_t* x, const int16_t* y, int16_t* // Negate sign (scrambling) SRSRAN_API void srsran_vec_neg_sss(const int16_t* x, const int16_t* y, int16_t* z, const uint32_t len); SRSRAN_API void srsran_vec_neg_bbb(const int8_t* x, const int8_t* y, int8_t* z, const uint32_t len); +SRSRAN_API void srsran_vec_neg_bb(const int8_t* x, int8_t* z, const uint32_t len); /* Dot-product */ SRSRAN_API cf_t srsran_vec_dot_prod_cfc(const cf_t* x, const float* y, const uint32_t len); diff --git a/lib/src/phy/ch_estimation/csi_rs.c b/lib/src/phy/ch_estimation/csi_rs.c index c035ebec3..6a8f1c9e4 100644 --- a/lib/src/phy/ch_estimation/csi_rs.c +++ b/lib/src/phy/ch_estimation/csi_rs.c @@ -12,23 +12,27 @@ #include "srsran/phy/ch_estimation/csi_rs.h" #include "srsran/phy/common/sequence.h" +#include "srsran/phy/utils/debug.h" #include "srsran/phy/utils/vector.h" #include #include #include -#define SRSRAN_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_ROW1 4 -#define SRSRAN_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_ROW2 12 -#define SRSRAN_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_ROW4 3 -#define SRSRAN_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_OTHER 6 -#define SRSRAN_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_MAX 12 +/** + * @brief Maximum number of subcarriers occupied by a CSI-RS resource as defined in TS 38.211 Table 7.4.1.5.3-1 + */ +#define CSI_RS_MAX_SUBC_PRB 4 -#define CSI_RS_MAX_CDM_GROUP 16 +/** + * @brief Maximum number of symbols occupied by a CSI-RS resource as defined in TS 38.211 Table 7.4.1.5.3-1 + */ +#define CSI_RS_MAX_SYMBOLS_SLOT 4 static int csi_rs_location_f(const srsran_csi_rs_resource_mapping_t* resource, uint32_t i) { uint32_t count = 0; uint32_t nof_freq_domain = 0; + uint32_t mul = 1; switch (resource->row) { case srsran_csi_rs_resource_mapping_row_1: nof_freq_domain = SRSRAN_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_ROW1; @@ -38,28 +42,32 @@ static int csi_rs_location_f(const srsran_csi_rs_resource_mapping_t* resource, u break; case srsran_csi_rs_resource_mapping_row_4: nof_freq_domain = SRSRAN_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_ROW4; + mul = 4; break; case srsran_csi_rs_resource_mapping_row_other: nof_freq_domain = SRSRAN_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_OTHER; + mul = 2; break; } for (uint32_t j = 0; j < nof_freq_domain; j++) { - if (resource->frequency_domain_alloc[j]) { + if (resource->frequency_domain_alloc[nof_freq_domain - 1 - j]) { count++; } if (count == i) { - return i; + return j * mul; } } + ERROR("Unhandled configuration"); return SRSRAN_ERROR; } // Table 7.4.1.5.3-1: CSI-RS locations within a slot static int csi_rs_location_get_k_list(const srsran_csi_rs_resource_mapping_t* resource, - uint32_t k_list[CSI_RS_MAX_CDM_GROUP]) + uint32_t j, + uint32_t k_list[CSI_RS_MAX_SUBC_PRB]) { int k0 = csi_rs_location_f(resource, 1); // int k1 = csi_rs_location_f(resource, 2); @@ -71,20 +79,49 @@ static int csi_rs_location_get_k_list(const srsran_csi_rs_resource_mapping_t* re } // Row 1 - if (resource->row == srsran_csi_rs_resource_mapping_row_1 && resource->ports == 1 && - resource->density == srsran_csi_rs_resource_mapping_density_three && resource->cdm == srsran_csi_rs_cdm_nocdm) { + if (resource->row == srsran_csi_rs_resource_mapping_row_1 && resource->nof_ports == 1 && + resource->density == srsran_csi_rs_resource_mapping_density_three && resource->cdm == srsran_csi_rs_cdm_nocdm && + j == 0) { k_list[0] = k0; k_list[1] = k0 + 4; k_list[2] = k0 + 8; return 3; } + // Row 2 + if (resource->row == srsran_csi_rs_resource_mapping_row_2 && resource->nof_ports == 1 && + resource->cdm == srsran_csi_rs_cdm_nocdm) { + if (resource->density == srsran_csi_rs_resource_mapping_density_one || + resource->density == srsran_csi_rs_resource_mapping_density_dot5_even || + resource->density == srsran_csi_rs_resource_mapping_density_dot5_odd) { + k_list[0] = k0; + return 1; + } + } + + // Row 4 + if (resource->row == srsran_csi_rs_resource_mapping_row_4 && resource->nof_ports == 4 && + resource->density == srsran_csi_rs_resource_mapping_density_one && resource->cdm == srsran_csi_rs_cdm_fd_cdm2) { + if (j == 0) { + k_list[0] = k0; + k_list[1] = k0 + 1; + return 2; + } + if (j == 1) { + k_list[0] = k0 + 2; + k_list[1] = k0 + 2 + 1; + return 2; + } + } + + ERROR("Unhandled configuration"); return SRSRAN_ERROR; } // Table 7.4.1.5.3-1: CSI-RS locations within a slot static int csi_rs_location_get_l_list(const srsran_csi_rs_resource_mapping_t* resource, - uint32_t l_list[CSI_RS_MAX_CDM_GROUP]) + uint32_t j, + uint32_t l_list[CSI_RS_MAX_SYMBOLS_SLOT]) { uint32_t l0 = resource->first_symbol_idx; @@ -98,19 +135,44 @@ static int csi_rs_location_get_l_list(const srsran_csi_rs_resource_mapping_t* re // } // Row 1 - if (resource->row == srsran_csi_rs_resource_mapping_row_1 && resource->ports == 1 && + if (resource->row == srsran_csi_rs_resource_mapping_row_1 && resource->nof_ports == 1 && resource->density == srsran_csi_rs_resource_mapping_density_three && resource->cdm == srsran_csi_rs_cdm_nocdm) { l_list[0] = l0; return 1; } + // Row 2 + if (resource->row == srsran_csi_rs_resource_mapping_row_2 && resource->nof_ports == 1 && + resource->cdm == srsran_csi_rs_cdm_nocdm) { + if (resource->density == srsran_csi_rs_resource_mapping_density_one || + resource->density == srsran_csi_rs_resource_mapping_density_dot5_even || + resource->density == srsran_csi_rs_resource_mapping_density_dot5_odd) { + l_list[0] = l0; + return 1; + } + } + + // Row 4 + if (resource->row == srsran_csi_rs_resource_mapping_row_4 && resource->nof_ports == 4 && + resource->density == srsran_csi_rs_resource_mapping_density_one && resource->cdm == srsran_csi_rs_cdm_fd_cdm2) { + if (j == 0) { + l_list[0] = l0; + return 1; + } + if (j == 1) { + l_list[0] = l0; + return 1; + } + } + + ERROR("Unhandled configuration"); return SRSRAN_ERROR; } -uint32_t csi_rs_cinit(const srsran_carrier_nr_t* carrier, - const srsran_slot_cfg_t* slot_cfg, - const srsran_csi_rs_nzp_resource_t* resource, - uint32_t l) +static uint32_t csi_rs_cinit(const srsran_carrier_nr_t* carrier, + const srsran_slot_cfg_t* slot_cfg, + const srsran_csi_rs_nzp_resource_t* resource, + uint32_t l) { uint32_t n = SRSRAN_SLOT_NR_MOD(carrier->numerology, slot_cfg->idx); uint32_t n_id = resource->scrambling_id; @@ -118,7 +180,7 @@ uint32_t csi_rs_cinit(const srsran_carrier_nr_t* carrier, return ((SRSRAN_NSYMB_PER_SLOT_NR * n + l + 1UL) * (2UL * n_id) << 10UL) + n_id; } -bool srsran_csi_send(const srsran_csi_rs_period_and_offset_t* periodicity, const srsran_slot_cfg_t* slot_cfg) +bool srsran_csi_rs_send(const srsran_csi_rs_period_and_offset_t* periodicity, const srsran_slot_cfg_t* slot_cfg) { if (periodicity == NULL || slot_cfg == NULL) { return false; @@ -133,6 +195,43 @@ bool srsran_csi_send(const srsran_csi_rs_period_and_offset_t* periodicity, const return n == 0; } +static int csi_rs_nof_cdm_groups(const srsran_csi_rs_resource_mapping_t* resource) +{ + if (resource->row == srsran_csi_rs_resource_mapping_row_1 && resource->nof_ports == 1 && + resource->density == srsran_csi_rs_resource_mapping_density_three && resource->cdm == srsran_csi_rs_cdm_nocdm) { + return 1; + } + + // Row 1 + if (resource->row == srsran_csi_rs_resource_mapping_row_2 && resource->nof_ports == 1 && + resource->cdm == srsran_csi_rs_cdm_nocdm) { + if (resource->density == srsran_csi_rs_resource_mapping_density_one || + resource->density == srsran_csi_rs_resource_mapping_density_dot5_even || + resource->density == srsran_csi_rs_resource_mapping_density_dot5_odd) { + return 1; + } + } + + // Row 2 + if (resource->row == srsran_csi_rs_resource_mapping_row_2 && resource->nof_ports == 1 && + resource->cdm == srsran_csi_rs_cdm_nocdm) { + if (resource->density == srsran_csi_rs_resource_mapping_density_one || + resource->density == srsran_csi_rs_resource_mapping_density_dot5_even || + resource->density == srsran_csi_rs_resource_mapping_density_dot5_odd) { + return 1; + } + } + + // Row 3 + if (resource->row == srsran_csi_rs_resource_mapping_row_4 && resource->nof_ports == 4 && + resource->density == srsran_csi_rs_resource_mapping_density_one && resource->cdm == srsran_csi_rs_cdm_fd_cdm2) { + return 2; + } + + ERROR("Unhandled configuration"); + return SRSRAN_ERROR; +} + uint32_t csi_rs_count(srsran_csi_rs_density_t density, uint32_t nprb) { switch (density) { @@ -150,7 +249,7 @@ uint32_t csi_rs_count(srsran_csi_rs_density_t density, uint32_t nprb) return 0; } -uint32_t csi_rs_rb_begin(const srsran_carrier_nr_t* carrier, const srsran_csi_rs_resource_mapping_t* m) +static uint32_t csi_rs_rb_begin(const srsran_carrier_nr_t* carrier, const srsran_csi_rs_resource_mapping_t* m) { uint32_t ret = SRSRAN_MAX(carrier->start, m->freq_band.start_rb); @@ -162,12 +261,12 @@ uint32_t csi_rs_rb_begin(const srsran_carrier_nr_t* carrier, const srsran_csi_rs return ret; } -uint32_t csi_rs_rb_end(const srsran_carrier_nr_t* carrier, const srsran_csi_rs_resource_mapping_t* m) +static uint32_t csi_rs_rb_end(const srsran_carrier_nr_t* carrier, const srsran_csi_rs_resource_mapping_t* m) { return SRSRAN_MIN(carrier->start + carrier->nof_prb, m->freq_band.start_rb + m->freq_band.nof_rb); } -uint32_t csi_rs_rb_stride(const srsran_csi_rs_resource_mapping_t* m) +static uint32_t csi_rs_rb_stride(const srsran_csi_rs_resource_mapping_t* m) { uint32_t ret = 1; @@ -181,6 +280,65 @@ uint32_t csi_rs_rb_stride(const srsran_csi_rs_resource_mapping_t* m) return ret; } +int srsran_csi_rs_append_resource_to_pattern(const srsran_carrier_nr_t* carrier, + const srsran_csi_rs_resource_mapping_t* resource, + srsran_re_pattern_list_t* re_pattern_list) +{ + // Check inputs + if (resource == NULL || re_pattern_list == NULL) { + return SRSRAN_ERROR_INVALID_INPUTS; + } + + // Create temporal pattern + srsran_re_pattern_t pattern = {}; + pattern.rb_begin = csi_rs_rb_begin(carrier, resource); + pattern.rb_end = csi_rs_rb_end(carrier, resource); + pattern.rb_stride = csi_rs_rb_stride(resource); + + // Calculate number of CDM groups + int nof_cdm_groups = csi_rs_nof_cdm_groups(resource); + if (nof_cdm_groups < SRSRAN_SUCCESS) { + ERROR("Error getting number of CDM groups"); + return SRSRAN_ERROR; + } + + // Iterate over all CDM groups + for (int j = 0; j < nof_cdm_groups; j++) { + // Get SC indexes + uint32_t k_list[CSI_RS_MAX_SUBC_PRB] = {}; + int nof_k = csi_rs_location_get_k_list(resource, j, k_list); + if (nof_k < SRSRAN_SUCCESS) { + ERROR("Error getting indexes for CSI-RS"); + return SRSRAN_ERROR; + } + + // Fill subcarrier mask + for (int k = 0; k < nof_k; k++) { + pattern.sc[k_list[k]] = true; + } + + // Get OFDM symbol indexes + uint32_t l_list[CSI_RS_MAX_SUBC_PRB] = {}; + int nof_l = csi_rs_location_get_l_list(resource, j, l_list); + if (nof_l < SRSRAN_SUCCESS) { + ERROR("Error getting indexes for CSI-RS"); + return SRSRAN_ERROR; + } + + // Fill OFDM symbol mask + for (int l = 0; l < nof_l; l++) { + pattern.symbol[l_list[l]] = true; + } + + if (srsran_re_pattern_merge(re_pattern_list, &pattern) < SRSRAN_SUCCESS) { + ERROR("Error merging pattern"); + return SRSRAN_ERROR; + } + } + + return SRSRAN_SUCCESS; +} + int srsran_csi_rs_nzp_put(const srsran_carrier_nr_t* carrier, const srsran_slot_cfg_t* slot_cfg, const srsran_csi_rs_nzp_resource_t* resource, @@ -190,14 +348,17 @@ int srsran_csi_rs_nzp_put(const srsran_carrier_nr_t* carrier, return SRSRAN_ERROR; } - uint32_t k_list[CSI_RS_MAX_CDM_GROUP]; - int nof_k = csi_rs_location_get_k_list(&resource->resource_mapping, k_list); + // Force CDM group to 0 + uint32_t j = 0; + + uint32_t k_list[CSI_RS_MAX_SUBC_PRB]; + int nof_k = csi_rs_location_get_k_list(&resource->resource_mapping, j, k_list); if (nof_k <= 0) { return SRSRAN_ERROR; } - uint32_t l_list[CSI_RS_MAX_CDM_GROUP]; - int nof_l = csi_rs_location_get_l_list(&resource->resource_mapping, l_list); + uint32_t l_list[CSI_RS_MAX_SYMBOLS_SLOT]; + int nof_l = csi_rs_location_get_l_list(&resource->resource_mapping, j, l_list); if (nof_l <= 0) { return SRSRAN_ERROR; } @@ -261,14 +422,17 @@ int srsran_csi_rs_nzp_measure(const srsran_carrier_nr_t* carrier, return SRSRAN_ERROR; } - uint32_t k_list[CSI_RS_MAX_CDM_GROUP]; - int nof_k = csi_rs_location_get_k_list(&resource->resource_mapping, k_list); + // Force CDM group to 0 + uint32_t j = 0; + + uint32_t k_list[CSI_RS_MAX_SUBC_PRB]; + int nof_k = csi_rs_location_get_k_list(&resource->resource_mapping, j, k_list); if (nof_k <= 0) { return SRSRAN_ERROR; } - uint32_t l_list[CSI_RS_MAX_CDM_GROUP]; - int nof_l = csi_rs_location_get_l_list(&resource->resource_mapping, l_list); + uint32_t l_list[CSI_RS_MAX_SYMBOLS_SLOT]; + int nof_l = csi_rs_location_get_l_list(&resource->resource_mapping, j, l_list); if (nof_l <= 0) { return SRSRAN_ERROR; } diff --git a/lib/src/phy/ch_estimation/dmrs_pdcch.c b/lib/src/phy/ch_estimation/dmrs_pdcch.c index 161da0e86..800160a15 100644 --- a/lib/src/phy/ch_estimation/dmrs_pdcch.c +++ b/lib/src/phy/ch_estimation/dmrs_pdcch.c @@ -25,6 +25,7 @@ #define DMRS_PDCCH_INFO_TX(...) INFO("PDCCH DMRS Tx: " __VA_ARGS__) #define DMRS_PDCCH_INFO_RX(...) INFO("PDCCH DMRS Rx: " __VA_ARGS__) +#define DMRS_PDCCH_DEBUG_RX(...) DEBUG("PDCCH DMRS Rx: " __VA_ARGS__) /// @brief Enables interpolation at CCE frequency bandwidth to avoid interference with adjacent PDCCH DMRS #define DMRS_PDCCH_INTERPOLATE_GROUP 1 @@ -347,8 +348,6 @@ int srsran_dmrs_pdcch_estimate(srsran_dmrs_pdcch_estimator_t* q, // Calculate PRN sequence initial state uint32_t cinit = dmrs_pdcch_get_cinit(slot_idx, l, n_id); - DMRS_PDCCH_INFO_RX("n=%d; l=%d; cinit=%08x", slot_idx, l, cinit); - // Extract pilots least square estimates srsran_dmrs_pdcch_extract(q, cinit, &sf_symbols[l * q->carrier.nof_prb * SRSRAN_NRE], q->lse[l]); } @@ -410,8 +409,8 @@ int srsran_dmrs_pdcch_get_measure(const srsran_dmrs_pdcch_estimator_t* q, float sync_err = 0.0f; cf_t corr[SRSRAN_CORESET_DURATION_MAX] = {}; for (uint32_t l = 0; l < q->coreset.duration; l++) { - if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_INFO && !handler_registered) { - DMRS_PDCCH_INFO_RX("Measuring PDCCH l=%d; lse=", l); + if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_DEBUG && !handler_registered) { + DMRS_PDCCH_DEBUG_RX("Measuring PDCCH l=%d; lse=", l); srsran_vec_fprint_c(stdout, &q->lse[l][pilot_idx], nof_pilots); } diff --git a/lib/src/phy/ch_estimation/dmrs_sch.c b/lib/src/phy/ch_estimation/dmrs_sch.c index 5114b14c3..3724b126a 100644 --- a/lib/src/phy/ch_estimation/dmrs_sch.c +++ b/lib/src/phy/ch_estimation/dmrs_sch.c @@ -11,6 +11,7 @@ */ #include "srsran/phy/ch_estimation/dmrs_sch.h" +#include "srsran/phy/ch_estimation/csi_rs.h" #include "srsran/phy/common/sequence.h" #include #include @@ -399,26 +400,56 @@ int srsran_dmrs_sch_get_symbols_idx(const srsran_dmrs_sch_cfg_t* dmrs_cfg, return SRSRAN_ERROR; } -int srsran_dmrs_sch_get_sc_idx(const srsran_dmrs_sch_cfg_t* cfg, uint32_t max_count, uint32_t* sc_idx) +int srsran_dmrs_sch_rvd_re_pattern(const srsran_dmrs_sch_cfg_t* cfg, + const srsran_sch_grant_nr_t* grant, + srsran_re_pattern_t* pattern) { - int count = 0; - uint32_t delta = 0; + if (cfg == NULL || pattern == NULL) { + return SRSRAN_ERROR_INVALID_INPUTS; + } + // Initialise pattern with zeros + SRSRAN_MEM_ZERO(pattern, srsran_re_pattern_t, 1); + + // Fill RB bounds + pattern->rb_begin = 0; + pattern->rb_end = SRSRAN_MAX_PRB_NR; + pattern->rb_stride = 1; + + // Fill subcarrier mask if (cfg->type == srsran_dmrs_sch_type_1) { - for (uint32_t n = 0; count < max_count; n += 4) { - for (uint32_t k_prime = 0; k_prime < 2 && count < max_count; k_prime++) { - sc_idx[count++] = n + 2 * k_prime + delta; + for (uint32_t n = 0; n < 3; n++) { + for (uint32_t k_prime = 0; k_prime < 2; k_prime++) { + for (uint32_t delta = 0; delta < grant->nof_dmrs_cdm_groups_without_data; delta++) { + pattern->sc[(4 * n + 2 * k_prime + delta) % SRSRAN_NRE] = true; + } } } } else { - for (uint32_t n = 0; count < max_count; n += 6) { - for (uint32_t k_prime = 0; k_prime < 2 && count < max_count; k_prime++) { - sc_idx[count++] = n + k_prime + delta; + for (uint32_t n = 0; n < 2; n++) { + for (uint32_t k_prime = 0; k_prime < 2; k_prime++) { + for (uint32_t delta = 0; delta < grant->nof_dmrs_cdm_groups_without_data; delta++) { + pattern->sc[(6 * n + k_prime + 2 * delta) % SRSRAN_NRE] = true; + } } } } - return count; + // Calculate OFDM symbols + uint32_t symbols[SRSRAN_DMRS_SCH_MAX_SYMBOLS]; + int nof_l = srsran_dmrs_sch_get_symbols_idx(cfg, grant, symbols); + if (nof_l < SRSRAN_SUCCESS) { + ERROR("Error calculating OFDM symbols"); + return SRSRAN_ERROR; + } + + // Set OFDM symbol mask + for (int i = 0; i < nof_l; i++) { + uint32_t l = symbols[i]; + pattern->symbol[l % SRSRAN_NSYMB_PER_SLOT_NR] = true; + } + + return SRSRAN_SUCCESS; } int srsran_dmrs_sch_get_N_prb(const srsran_dmrs_sch_cfg_t* dmrs_cfg, const srsran_sch_grant_nr_t* grant) @@ -666,26 +697,26 @@ static int srsran_dmrs_sch_get_symbol(srsran_dmrs_sch_t* q, } int srsran_dmrs_sch_estimate(srsran_dmrs_sch_t* q, - const srsran_slot_cfg_t* slot_cfg, - const srsran_sch_cfg_nr_t* pdsch_cfg, + const srsran_slot_cfg_t* slot, + const srsran_sch_cfg_nr_t* cfg, const srsran_sch_grant_nr_t* grant, const cf_t* sf_symbols, srsran_chest_dl_res_t* chest_res) { const uint32_t delta = 0; - if (q == NULL || slot_cfg == NULL || sf_symbols == NULL || chest_res == NULL) { + if (q == NULL || slot == NULL || sf_symbols == NULL || chest_res == NULL) { return SRSRAN_ERROR_INVALID_INPUTS; } - const srsran_dmrs_sch_cfg_t* dmrs_cfg = &pdsch_cfg->dmrs; + const srsran_dmrs_sch_cfg_t* dmrs_cfg = &cfg->dmrs; cf_t* ce = q->temp; uint32_t symbol_sz = q->carrier.nof_prb * SRSRAN_NRE; // Symbol size in resource elements // Get symbols indexes uint32_t symbols[SRSRAN_DMRS_SCH_MAX_SYMBOLS] = {}; - int nof_symbols = srsran_dmrs_sch_get_symbols_idx(&pdsch_cfg->dmrs, grant, symbols); + int nof_symbols = srsran_dmrs_sch_get_symbols_idx(&cfg->dmrs, grant, symbols); if (nof_symbols <= SRSRAN_SUCCESS) { ERROR("Error getting symbol indexes"); return SRSRAN_ERROR; @@ -697,11 +728,11 @@ int srsran_dmrs_sch_estimate(srsran_dmrs_sch_t* q, for (uint32_t i = 0; i < nof_symbols; i++) { uint32_t l = symbols[i]; // Symbol index inside the slot - uint32_t cinit = srsran_dmrs_sch_seed( - &q->carrier, pdsch_cfg, grant, SRSRAN_SLOT_NR_MOD(q->carrier.numerology, slot_cfg->idx), l); + uint32_t cinit = + srsran_dmrs_sch_seed(&q->carrier, cfg, grant, SRSRAN_SLOT_NR_MOD(q->carrier.numerology, slot->idx), l); nof_pilots_x_symbol = srsran_dmrs_sch_get_symbol( - q, pdsch_cfg, grant, cinit, delta, &sf_symbols[symbol_sz * l], &q->pilot_estimates[nof_pilots_x_symbol * i]); + q, cfg, grant, cinit, delta, &sf_symbols[symbol_sz * l], &q->pilot_estimates[nof_pilots_x_symbol * i]); if (nof_pilots_x_symbol == 0) { ERROR("Error, no pilots extracted (i=%d, l=%d)", i, l); @@ -784,6 +815,26 @@ int srsran_dmrs_sch_estimate(srsran_dmrs_sch_t* q, symbol_idx++; } + // Initialise reserved mask + bool rvd_mask_wb[SRSRAN_NRE * SRSRAN_MAX_PRB_NR] = {}; + + // Compute reserved RE + if (srsran_re_pattern_list_to_symbol_mask(&cfg->rvd_re, l, rvd_mask_wb) < SRSRAN_SUCCESS) { + ERROR("Error generating reserved RE mask"); + return SRSRAN_ERROR; + } + + // Narrow reserved subcarriers to the ones used in the transmission + bool rvd_mask[SRSRAN_NRE * SRSRAN_MAX_PRB_NR] = {}; + for (uint32_t i = 0, k = 0; i < q->carrier.nof_prb; i++) { + if (grant->prb_idx[i]) { + for (uint32_t j = 0; j < SRSRAN_NRE; j++) { + rvd_mask[k++] = rvd_mask_wb[i * SRSRAN_NRE + j]; + } + } + } + + // Check if it s DMRS symbol if (symbols[symbol_idx] == l) { switch (dmrs_cfg->type) { case srsran_dmrs_sch_type_1: @@ -792,8 +843,9 @@ int srsran_dmrs_sch_estimate(srsran_dmrs_sch_t* q, continue; } for (uint32_t i = 1; i < nof_re_x_symbol; i += 2) { - chest_res->ce[0][0][count] = ce[i]; - count++; + if (!rvd_mask[i]) { + chest_res->ce[0][0][count++] = ce[i]; + } } break; case srsran_dmrs_sch_type_2: @@ -803,14 +855,20 @@ int srsran_dmrs_sch_estimate(srsran_dmrs_sch_t* q, } for (uint32_t i = grant->nof_dmrs_cdm_groups_without_data * 2; i < nof_re_x_symbol; i += 6) { uint32_t nof_re = (3 - grant->nof_dmrs_cdm_groups_without_data) * 2; - srsran_vec_cf_copy(&chest_res->ce[0][0][count], &ce[i], nof_re); - count += nof_re; + for (uint32_t j = 0; j < nof_re; j++) { + if (!rvd_mask[i + j]) { + chest_res->ce[0][0][count++] = ce[i + j]; + } + } } break; } } else { - srsran_vec_cf_copy(&chest_res->ce[0][0][count], ce, nof_re_x_symbol); - count += nof_re_x_symbol; + for (uint32_t i = 0; i < nof_re_x_symbol; i++) { + if (!rvd_mask[i]) { + chest_res->ce[0][0][count++] = ce[i]; + } + } } } // Set other values in the estimation result diff --git a/lib/src/phy/ch_estimation/test/CMakeLists.txt b/lib/src/phy/ch_estimation/test/CMakeLists.txt index 8e2fcca68..a272e84b5 100644 --- a/lib/src/phy/ch_estimation/test/CMakeLists.txt +++ b/lib/src/phy/ch_estimation/test/CMakeLists.txt @@ -77,7 +77,7 @@ add_lte_test(chest_test_sl_psbch chest_test_sl) add_executable(dmrs_pdsch_test dmrs_pdsch_test.c) target_link_libraries(dmrs_pdsch_test srsran_phy) -add_lte_test(dmrs_pdsch_test dmrs_pdsch_test) +add_nr_test(dmrs_pdsch_test dmrs_pdsch_test) ######################################################################## @@ -87,7 +87,7 @@ add_lte_test(dmrs_pdsch_test dmrs_pdsch_test) add_executable(dmrs_pdcch_test dmrs_pdcch_test.c) target_link_libraries(dmrs_pdcch_test srsran_phy) -add_lte_test(dmrs_pdcch_test dmrs_pdcch_test) +add_nr_test(dmrs_pdcch_test dmrs_pdcch_test) ######################################################################## @@ -97,5 +97,15 @@ add_lte_test(dmrs_pdcch_test dmrs_pdcch_test) add_executable(csi_rs_test csi_rs_test.c) target_link_libraries(csi_rs_test srsran_phy) -add_lte_test(csi_rs_test csi_rs_test -o 3 -S 0 -L 150 -f 3 -p 15) +add_nr_test(csi_rs_test csi_rs_test -o 3 -S 0 -L 150 -f 3 -p 15) + + +######################################################################## +# NR CSI RS Pattern test +######################################################################## + +add_executable(csi_rs_pattern_test csi_rs_pattern_test.c) +target_link_libraries(csi_rs_pattern_test srsran_phy) + +add_nr_test(csi_rs_pattern_test csi_rs_pattern_test) diff --git a/lib/src/phy/ch_estimation/test/csi_rs_pattern_test.c b/lib/src/phy/ch_estimation/test/csi_rs_pattern_test.c new file mode 100644 index 000000000..2bd11ff82 --- /dev/null +++ b/lib/src/phy/ch_estimation/test/csi_rs_pattern_test.c @@ -0,0 +1,229 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +#include "srsran/common/test_common.h" +#include "srsran/phy/ch_estimation/csi_rs.h" + +static srsran_carrier_nr_t carrier = {}; + +static int test_row1() +{ + for (uint32_t k = 0; k < SRSRAN_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_ROW1; k++) { + // Create CSI-RS mapping + srsran_csi_rs_resource_mapping_t m; // Dont initialise for detecting not initialised memory + m.row = srsran_csi_rs_resource_mapping_row_1; + for (uint32_t j = 0; j < SRSRAN_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_ROW1; j++) { + m.frequency_domain_alloc[j] = (k == j); + } + m.nof_ports = 1; + m.first_symbol_idx = 0; + m.cdm = srsran_csi_rs_cdm_nocdm; + m.density = srsran_csi_rs_resource_mapping_density_three; + m.freq_band.start_rb = carrier.start; + m.freq_band.nof_rb = carrier.nof_prb; + + // Create Pattern list and initialise + srsran_re_pattern_list_t patterns; + srsran_re_pattern_reset(&patterns); + + // Generate pattern list from CSI-RS mapping + TESTASSERT(srsran_csi_rs_append_resource_to_pattern(&carrier, &m, &patterns) == SRSRAN_SUCCESS); + + // Assert generated pattern + TESTASSERT(patterns.count == 1); + TESTASSERT(patterns.data[0].rb_begin == m.freq_band.start_rb); + TESTASSERT(patterns.data[0].rb_end == m.freq_band.start_rb + m.freq_band.nof_rb); + TESTASSERT(patterns.data[0].rb_stride == 1); + for (uint32_t j = 0; j < SRSRAN_NRE; j++) { + TESTASSERT(patterns.data[0].sc[j] == + (j % SRSRAN_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_ROW1 == (SRSRAN_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_ROW1 - 1 - k))); + } + for (uint32_t j = 0; j < SRSRAN_NSYMB_PER_SLOT_NR; j++) { + TESTASSERT(patterns.data[0].symbol[j] == (j == m.first_symbol_idx)); + } + } + + return SRSRAN_SUCCESS; +} + +static int test_row2() +{ + for (srsran_csi_rs_density_t density = srsran_csi_rs_resource_mapping_density_dot5_even; + density <= srsran_csi_rs_resource_mapping_density_one; + density++) { + for (uint32_t k = 0; k < SRSRAN_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_ROW2; k++) { + // Create CSI-RS mapping + srsran_csi_rs_resource_mapping_t m; // Dont initialise for detecting not initialised memory + m.row = srsran_csi_rs_resource_mapping_row_2; + for (uint32_t j = 0; j < SRSRAN_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_ROW2; j++) { + m.frequency_domain_alloc[j] = (k == j); + } + m.nof_ports = 1; + m.first_symbol_idx = 0; + m.cdm = srsran_csi_rs_cdm_nocdm; + m.density = density; + m.freq_band.start_rb = carrier.start; + m.freq_band.nof_rb = carrier.nof_prb; + + // Create Pattern list and initialise + srsran_re_pattern_list_t patterns; + srsran_re_pattern_reset(&patterns); + + // Generate pattern list from CSI-RS mapping + TESTASSERT(srsran_csi_rs_append_resource_to_pattern(&carrier, &m, &patterns) == SRSRAN_SUCCESS); + + // Assert generated pattern + uint32_t rb_stride = (density == srsran_csi_rs_resource_mapping_density_one) ? 1 : 2; + uint32_t rb_start = carrier.start; + if ((rb_start % 2 == 0 && density == srsran_csi_rs_resource_mapping_density_dot5_odd) || + (rb_start % 2 == 1 && density == srsran_csi_rs_resource_mapping_density_dot5_even)) { + rb_start++; + } + TESTASSERT(patterns.count == 1); + TESTASSERT(patterns.data[0].rb_begin == rb_start); + TESTASSERT(patterns.data[0].rb_end == m.freq_band.start_rb + m.freq_band.nof_rb); + TESTASSERT(patterns.data[0].rb_stride == rb_stride); + for (uint32_t j = 0; j < SRSRAN_NRE; j++) { + TESTASSERT(patterns.data[0].sc[j] == (j == (SRSRAN_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_ROW2 - 1 - k))); + } + for (uint32_t j = 0; j < SRSRAN_NSYMB_PER_SLOT_NR; j++) { + TESTASSERT(patterns.data[0].symbol[j] == (j == m.first_symbol_idx)); + } + } + } + + return SRSRAN_SUCCESS; +} + +static int test_row4() +{ + for (uint32_t k = 0; k < SRSRAN_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_ROW4; k++) { + // Create CSI-RS mapping + srsran_csi_rs_resource_mapping_t m; // Dont initialise for detecting not initialised memory + m.row = srsran_csi_rs_resource_mapping_row_4; + for (uint32_t j = 0; j < SRSRAN_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_ROW4; j++) { + m.frequency_domain_alloc[j] = (k == j); + } + m.nof_ports = 4; + m.first_symbol_idx = 0; + m.cdm = srsran_csi_rs_cdm_fd_cdm2; + m.density = srsran_csi_rs_resource_mapping_density_one; + m.freq_band.start_rb = carrier.start; + m.freq_band.nof_rb = carrier.nof_prb; + + // Create Pattern list and initialise + srsran_re_pattern_list_t patterns; + srsran_re_pattern_reset(&patterns); + + // Generate pattern list from CSI-RS mapping + TESTASSERT(srsran_csi_rs_append_resource_to_pattern(&carrier, &m, &patterns) == SRSRAN_SUCCESS); + + // Assert generated pattern + TESTASSERT(patterns.count == 1); + TESTASSERT(patterns.data[0].rb_begin == m.freq_band.start_rb); + TESTASSERT(patterns.data[0].rb_end == m.freq_band.start_rb + m.freq_band.nof_rb); + TESTASSERT(patterns.data[0].rb_stride == 1); + for (uint32_t j = 0; j < SRSRAN_NRE; j++) { + uint32_t k_begin = (SRSRAN_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_ROW4 - 1 - k) * 4; + uint32_t k_end = k_begin + 4; + TESTASSERT(patterns.data[0].sc[j] == (j >= k_begin && j < k_end)); + } + for (uint32_t j = 0; j < SRSRAN_NSYMB_PER_SLOT_NR; j++) { + TESTASSERT(patterns.data[0].symbol[j] == (j == m.first_symbol_idx)); + } + } + + return SRSRAN_SUCCESS; +} + +static int test_mix() +{ + srsran_csi_rs_resource_mapping_t resource0 = {}; + resource0.row = srsran_csi_rs_resource_mapping_row_4; + resource0.frequency_domain_alloc[0] = true; + resource0.frequency_domain_alloc[1] = false; + resource0.frequency_domain_alloc[2] = false; + resource0.nof_ports = 4; + resource0.first_symbol_idx = 8; + resource0.cdm = srsran_csi_rs_cdm_fd_cdm2; + resource0.density = srsran_csi_rs_resource_mapping_density_one; + resource0.freq_band.start_rb = 0; + resource0.freq_band.nof_rb = 52; + + srsran_csi_rs_resource_mapping_t resource1 = {}; + resource1.row = srsran_csi_rs_resource_mapping_row_2; + resource1.frequency_domain_alloc[0] = true; + resource1.frequency_domain_alloc[1] = false; + resource1.frequency_domain_alloc[2] = false; + resource1.frequency_domain_alloc[3] = false; + resource1.frequency_domain_alloc[4] = false; + resource1.frequency_domain_alloc[5] = false; + resource1.frequency_domain_alloc[6] = false; + resource1.frequency_domain_alloc[7] = false; + resource1.frequency_domain_alloc[8] = false; + resource1.frequency_domain_alloc[9] = false; + resource1.frequency_domain_alloc[10] = false; + resource1.frequency_domain_alloc[11] = false; + resource1.nof_ports = 1; + resource1.first_symbol_idx = 4; + resource1.cdm = srsran_csi_rs_cdm_nocdm; + resource1.density = srsran_csi_rs_resource_mapping_density_one; + resource1.freq_band.start_rb = 0; + resource1.freq_band.nof_rb = 52; + + // Initialise pattern list + srsran_re_pattern_list_t patterns; + srsran_re_pattern_reset(&patterns); + + // Generate pattern list from CSI-RS mapping + TESTASSERT(srsran_csi_rs_append_resource_to_pattern(&carrier, &resource0, &patterns) == SRSRAN_SUCCESS); + TESTASSERT(srsran_csi_rs_append_resource_to_pattern(&carrier, &resource1, &patterns) == SRSRAN_SUCCESS); + + // Assert generated pattern + TESTASSERT(patterns.count == 2); + + for (uint32_t l = 0; l < SRSRAN_NSYMB_PER_SLOT_NR; l++) { + bool mask[SRSRAN_NRE * SRSRAN_MAX_PRB_NR] = {}; + + TESTASSERT(srsran_re_pattern_list_to_symbol_mask(&patterns, l, mask) == SRSRAN_SUCCESS); + + if (l == resource0.first_symbol_idx) { + for (uint32_t k = 0; k < SRSRAN_NRE * SRSRAN_MAX_PRB_NR; k++) { + TESTASSERT(mask[k] == ((k < 52 * SRSRAN_NRE) && (k % SRSRAN_NRE >= 8))); + } + } else if (l == resource1.first_symbol_idx) { + for (uint32_t k = 0; k < SRSRAN_NRE * SRSRAN_MAX_PRB_NR; k++) { + TESTASSERT(mask[k] == ((k < 52 * SRSRAN_NRE) && (k % SRSRAN_NRE == 11))); + } + } else { + for (uint32_t k = 0; k < SRSRAN_NRE * SRSRAN_MAX_PRB_NR; k++) { + TESTASSERT(mask[k] == false); + } + } + } + + return SRSRAN_SUCCESS; +} + +int main(int argc, char** argv) +{ + // Initialise carrier + carrier.start = 0; + carrier.nof_prb = 52; + + TESTASSERT(test_row1() == SRSRAN_SUCCESS); + TESTASSERT(test_row2() == SRSRAN_SUCCESS); + TESTASSERT(test_row4() == SRSRAN_SUCCESS); + TESTASSERT(test_mix() == SRSRAN_SUCCESS); + + return SRSRAN_SUCCESS; +} diff --git a/lib/src/phy/ch_estimation/test/csi_rs_test.c b/lib/src/phy/ch_estimation/test/csi_rs_test.c index c3cacb175..2a8b7da05 100644 --- a/lib/src/phy/ch_estimation/test/csi_rs_test.c +++ b/lib/src/phy/ch_estimation/test/csi_rs_test.c @@ -136,10 +136,10 @@ int main(int argc, char** argv) } // Fixed parameters, other params are not implemented - resource.resource_mapping.cdm = srsran_csi_rs_cdm_nocdm; - resource.resource_mapping.density = srsran_csi_rs_resource_mapping_density_three; - resource.resource_mapping.row = srsran_csi_rs_resource_mapping_row_1; - resource.resource_mapping.ports = 1; + resource.resource_mapping.cdm = srsran_csi_rs_cdm_nocdm; + resource.resource_mapping.density = srsran_csi_rs_resource_mapping_density_three; + resource.resource_mapping.row = srsran_csi_rs_resource_mapping_row_1; + resource.resource_mapping.nof_ports = 1; // Row 1 supported only! uint32_t nof_freq_dom_alloc = SRSRAN_CSI_RS_NOF_FREQ_DOMAIN_ALLOC_ROW1; diff --git a/lib/src/phy/ch_estimation/test/dmrs_pdsch_test.c b/lib/src/phy/ch_estimation/test/dmrs_pdsch_test.c index 1da99b177..d3137d8a9 100644 --- a/lib/src/phy/ch_estimation/test/dmrs_pdsch_test.c +++ b/lib/src/phy/ch_estimation/test/dmrs_pdsch_test.c @@ -164,41 +164,44 @@ static int assert_cfg(const srsran_sch_cfg_nr_t* pdsch_cfg, const srsran_sch_gra continue; } - if (grant->mapping != gold[i].mapping_type) { + // Skip golden sample if one of the parameters does not match + if (grant->mapping != gold[i].mapping_type || pdsch_cfg->dmrs.typeA_pos != gold[i].typeA_pos || + pdsch_cfg->dmrs.additional_pos != gold[i].additional_pos || pdsch_cfg->dmrs.length != gold[i].max_length || + pdsch_cfg->dmrs.type != gold[i].type) { continue; } - if (pdsch_cfg->dmrs.typeA_pos != gold[i].typeA_pos) { - continue; - } - - if (pdsch_cfg->dmrs.additional_pos != gold[i].additional_pos) { - continue; - } - - if (pdsch_cfg->dmrs.length != gold[i].max_length) { - continue; - } - - if (pdsch_cfg->dmrs.type != gold[i].type) { - continue; + // Generate subcarrier mask from golden sample + bool sc_mask[SRSRAN_NRE] = {}; + if (grant->nof_dmrs_cdm_groups_without_data == 1) { + for (uint32_t j = 0; j < gold[i].nof_sc; j++) { + sc_mask[gold[i].sc_idx[j] % SRSRAN_NRE] = true; + } + } else if (pdsch_cfg->dmrs.type == srsran_dmrs_sch_type_1) { + for (uint32_t k = 0; k < SRSRAN_NRE; k++) { + sc_mask[k] = true; + } + } else if (pdsch_cfg->dmrs.type == srsran_dmrs_sch_type_2) { + for (uint32_t k = 0; k < SRSRAN_NRE; k++) { + sc_mask[k] = ((k % 6) < grant->nof_dmrs_cdm_groups_without_data * 2); + } } - uint32_t symbols[SRSRAN_DMRS_SCH_MAX_SYMBOLS] = {}; - int nof_symbols = srsran_dmrs_sch_get_symbols_idx(&pdsch_cfg->dmrs, grant, symbols); - - TESTASSERT(nof_symbols == gold[i].nof_symbols); - + // Generate symbol mask from golden sample + bool symbol_mask[SRSRAN_NSYMB_PER_SLOT_NR] = {}; for (uint32_t j = 0; j < gold[i].nof_symbols; j++) { - TESTASSERT(symbols[j] == gold[i].symbol_idx[j]); + symbol_mask[gold[i].symbol_idx[j] % SRSRAN_NSYMB_PER_SLOT_NR] = true; } - uint32_t sc[SRSRAN_NRE] = {}; - srsran_dmrs_sch_get_sc_idx(&pdsch_cfg->dmrs, SRSRAN_NRE, sc); + // Generate DMRS pattern + srsran_re_pattern_t pattern = {}; + TESTASSERT(srsran_dmrs_sch_rvd_re_pattern(&pdsch_cfg->dmrs, grant, &pattern) == SRSRAN_SUCCESS); - for (uint32_t j = 0; j < gold[i].nof_sc; j++) { - TESTASSERT(sc[j] == gold[i].sc_idx[j]); - } + // Assert subcarrier mask + TESTASSERT(memcmp(pattern.sc, sc_mask, sizeof(bool) * SRSRAN_NRE) == 0); + + // Assert symbol mask + TESTASSERT(memcmp(pattern.symbol, symbol_mask, sizeof(bool) * SRSRAN_NSYMB_PER_SLOT_NR) == 0); return SRSRAN_SUCCESS; } @@ -307,7 +310,15 @@ int main(int argc, char** argv) for (grant.nof_dmrs_cdm_groups_without_data = 1; grant.nof_dmrs_cdm_groups_without_data <= 3; grant.nof_dmrs_cdm_groups_without_data++) { // Load default type A grant - srsran_ra_dl_nr_time_default_A(0, pdsch_cfg.dmrs.typeA_pos, &grant); + if (srsran_ra_dl_nr_time_default_A(m, pdsch_cfg.dmrs.typeA_pos, &grant) < SRSRAN_SUCCESS) { + ERROR("Error loading time resource"); + continue; + } + + // Mapping type B is not supported + if (grant.mapping == srsran_sch_mapping_type_B) { + continue; + } int n = run_test(&dmrs_pdsch, &pdsch_cfg, &grant, sf_symbols, &chest_dl_res); diff --git a/lib/src/phy/phch/pdsch_nr.c b/lib/src/phy/phch/pdsch_nr.c index c60e86c13..30fff7475 100644 --- a/lib/src/phy/phch/pdsch_nr.c +++ b/lib/src/phy/phch/pdsch_nr.c @@ -11,6 +11,7 @@ */ #include "srsran/phy/phch/pdsch_nr.h" +#include "srsran/phy/ch_estimation/csi_rs.h" #include "srsran/phy/common/phy_common_nr.h" #include "srsran/phy/mimo/layermap.h" #include "srsran/phy/mimo/precoding.h" @@ -174,171 +175,25 @@ void srsran_pdsch_nr_free(srsran_pdsch_nr_t* q) } } -/** - * @brief copies a number of countiguous Resource Elements - * @param sf_symbols slot symbols in frequency domain - * @param symbols resource elements - * @param count number of resource elements to copy - * @param put Direction, symbols are copied into sf_symbols if put is true, otherwise sf_symbols are copied into symbols - */ -static void srsran_pdsch_re_cp(cf_t* sf_symbols, cf_t* symbols, uint32_t count, bool put) -{ - if (put) { - srsran_vec_cf_copy(sf_symbols, symbols, count); - } else { - srsran_vec_cf_copy(symbols, sf_symbols, count); - } -} - -/* - * As a RB is 12 RE wide, positions marked as 1 will be used for the 1st CDM group, and the same with group 2: - * - * +---+---+---+---+---+---+---+---+---+---+---+---+ - * | 1 | 2 | 1 | 2 | 1 | 2 | 1 | 2 | 1 | 2 | 1 | 2 | - * +---+---+---+---+---+---+---+---+---+---+---+---+ - * -- k --> - * - * If the number of DMRS CDM groups without data is set to: - * - 1, data is mapped in RE marked as 2 - * - Otherwise, no data is mapped in this symbol - */ -static uint32_t srsran_pdsch_nr_cp_dmrs_type1(const srsran_pdsch_nr_t* q, - const srsran_sch_grant_nr_t* grant, - cf_t* symbols, - cf_t* sf_symbols, - bool put) +static inline uint32_t pdsch_nr_put_rb(cf_t* dst, cf_t* src, bool* rvd_mask) { uint32_t count = 0; - uint32_t delta = 0; - - if (grant->nof_dmrs_cdm_groups_without_data != 1) { - return count; - } - - for (uint32_t i = 0; i < q->carrier.nof_prb; i++) { - if (grant->prb_idx[i]) { - for (uint32_t j = 0; j < SRSRAN_NRE; j += 2) { - if (put) { - sf_symbols[i * SRSRAN_NRE + delta + j + 1] = symbols[count++]; - } else { - symbols[count++] = sf_symbols[i * SRSRAN_NRE + delta + j + 1]; - } - } + for (uint32_t i = 0; i < SRSRAN_NRE; i++) { + if (!rvd_mask[i]) { + dst[i] = src[count++]; } } - return count; } -/* - * As a RB is 12 RE wide, positions marked as 1 will be used for the 1st CDM group, and the same with groups 2 and 3: - * - * +---+---+---+---+---+---+---+---+---+---+---+---+ - * | 1 | 1 | 2 | 2 | 3 | 3 | 1 | 1 | 2 | 2 | 3 | 3 | - * +---+---+---+---+---+---+---+---+---+---+---+---+ - * -- k --> - * - * If the number of DMRS CDM groups without data is set to: - * - 1, data is mapped in RE marked as 2 and 3 - * - 2, data is mapped in RE marked as 3 - * - otherwise, no data is mapped in this symbol - */ -static uint32_t srsran_pdsch_nr_cp_dmrs_type2(const srsran_pdsch_nr_t* q, - const srsran_sch_grant_nr_t* grant, - cf_t* symbols, - cf_t* sf_symbols, - bool put) +static inline uint32_t pdsch_nr_get_rb(cf_t* dst, cf_t* src, bool* rvd_mask) { uint32_t count = 0; - - if (grant->nof_dmrs_cdm_groups_without_data != 1 && grant->nof_dmrs_cdm_groups_without_data != 2) { - return count; - } - - uint32_t re_offset = (grant->nof_dmrs_cdm_groups_without_data == 1) ? 2 : 4; - uint32_t re_count = (grant->nof_dmrs_cdm_groups_without_data == 1) ? 4 : 2; - - for (uint32_t i = 0; i < q->carrier.nof_prb; i++) { - if (grant->prb_idx[i]) { - // Copy RE between pilot pairs - srsran_pdsch_re_cp(&sf_symbols[i * SRSRAN_NRE + re_offset], &symbols[count], re_count, put); - count += re_count; - - // Copy RE after second pilot - srsran_pdsch_re_cp(&sf_symbols[(i + 1) * SRSRAN_NRE - re_count], &symbols[count], re_count, put); - count += re_count; + for (uint32_t i = 0; i < SRSRAN_NRE; i++) { + if (!rvd_mask[i]) { + dst[count++] = src[i]; } } - - return count; -} - -static uint32_t srsran_pdsch_nr_cp_dmrs(const srsran_pdsch_nr_t* q, - const srsran_sch_cfg_nr_t* cfg, - const srsran_sch_grant_nr_t* grant, - cf_t* symbols, - cf_t* sf_symbols, - bool put) -{ - uint32_t count = 0; - - const srsran_dmrs_sch_cfg_t* dmrs_cfg = &cfg->dmrs; - - switch (dmrs_cfg->type) { - case srsran_dmrs_sch_type_1: - count = srsran_pdsch_nr_cp_dmrs_type1(q, grant, symbols, sf_symbols, put); - break; - case srsran_dmrs_sch_type_2: - count = srsran_pdsch_nr_cp_dmrs_type2(q, grant, symbols, sf_symbols, put); - break; - } - - return count; -} - -static uint32_t srsran_pdsch_nr_cp_clean(const srsran_pdsch_nr_t* q, - const srsran_sch_grant_nr_t* grant, - cf_t* symbols, - cf_t* sf_symbols, - bool put) -{ - uint32_t count = 0; - uint32_t start = 0; // Index of the start of continuous data - uint32_t length = 0; // End of continuous RE - - for (uint32_t i = 0; i < q->carrier.nof_prb; i++) { - if (grant->prb_idx[i]) { - // If fist continuous block, save start - if (length == 0) { - start = i * SRSRAN_NRE; - } - length += SRSRAN_NRE; - } else { - // Consecutive block is finished - if (put) { - srsran_vec_cf_copy(&sf_symbols[start], &symbols[count], length); - } else { - srsran_vec_cf_copy(&symbols[count], &sf_symbols[start], length); - } - - // Increase RE count - count += length; - - // Reset consecutive block - length = 0; - } - } - - // Copy last contiguous block - if (length > 0) { - if (put) { - srsran_vec_cf_copy(&sf_symbols[start], &symbols[count], length); - } else { - srsran_vec_cf_copy(&symbols[count], &sf_symbols[start], length); - } - count += length; - } - return count; } @@ -349,35 +204,40 @@ static int srsran_pdsch_nr_cp(const srsran_pdsch_nr_t* q, cf_t* sf_symbols, bool put) { - uint32_t count = 0; - uint32_t dmrs_l_idx[SRSRAN_DMRS_SCH_MAX_SYMBOLS] = {}; - uint32_t dmrs_l_count = 0; + uint32_t count = 0; - // Get symbol indexes carrying DMRS - int32_t nof_dmrs_symbols = srsran_dmrs_sch_get_symbols_idx(&cfg->dmrs, grant, dmrs_l_idx); - if (nof_dmrs_symbols < SRSRAN_SUCCESS) { - return SRSRAN_ERROR; - } + for (uint32_t l = grant->S; l < grant->S + grant->L; l++) { + // Initialise reserved RE mask to all false + bool rvd_mask[SRSRAN_NRE * SRSRAN_MAX_PRB_NR] = {}; - if (SRSRAN_DEBUG_ENABLED && srsran_verbose >= SRSRAN_VERBOSE_DEBUG && !handler_registered) { - DEBUG("dmrs_l_idx="); - srsran_vec_fprint_i(stdout, (int32_t*)dmrs_l_idx, nof_dmrs_symbols); - } + // Reserve DMRS + if (srsran_re_pattern_to_symbol_mask(&q->dmrs_re_pattern, l, rvd_mask) < SRSRAN_SUCCESS) { + ERROR("Error generating DMRS reserved RE mask"); + return SRSRAN_ERROR; + } - for (uint32_t l = grant->S; l < grant->S + grant->L; l++) { - // Advance DMRS symbol counter until: - // - the current DMRS symbol index is greater or equal than current symbol l - // - no more DMRS symbols - while (dmrs_l_idx[dmrs_l_count] < l && dmrs_l_count < nof_dmrs_symbols) { - dmrs_l_count++; + // Reserve RE from configuration + if (srsran_re_pattern_list_to_symbol_mask(&cfg->rvd_re, l, rvd_mask) < SRSRAN_SUCCESS) { + ERROR("Error generating reserved RE mask"); + return SRSRAN_ERROR; } - if (l == dmrs_l_idx[dmrs_l_count]) { - count += srsran_pdsch_nr_cp_dmrs( - q, cfg, grant, &symbols[count], &sf_symbols[l * q->carrier.nof_prb * SRSRAN_NRE], put); - } else { - count += - srsran_pdsch_nr_cp_clean(q, grant, &symbols[count], &sf_symbols[l * q->carrier.nof_prb * SRSRAN_NRE], put); + // Actual copy + for (uint32_t rb = 0; rb < q->carrier.nof_prb; rb++) { + // Skip PRB if not available in grant + if (!grant->prb_idx[rb]) { + continue; + } + + // Calculate RE index at the begin of the symbol + uint32_t re_idx = (q->carrier.nof_prb * l + rb) * SRSRAN_NRE; + + // Put or get + if (put) { + count += pdsch_nr_put_rb(&sf_symbols[re_idx], &symbols[count], &rvd_mask[rb * SRSRAN_NRE]); + } else { + count += pdsch_nr_get_rb(&symbols[count], &sf_symbols[re_idx], &rvd_mask[rb * SRSRAN_NRE]); + } } } @@ -487,6 +347,12 @@ int srsran_pdsch_nr_encode(srsran_pdsch_nr_t* q, return SRSRAN_ERROR; } + // Compute DMRS pattern + if (srsran_dmrs_sch_rvd_re_pattern(&cfg->dmrs, grant, &q->dmrs_re_pattern) < SRSRAN_SUCCESS) { + ERROR("Error computing DMRS pattern"); + return SRSRAN_ERROR; + } + // 7.3.1.1 and 7.3.1.2 uint32_t nof_cw = 0; for (uint32_t tb = 0; tb < SRSRAN_MAX_TB; tb++) { @@ -571,10 +437,8 @@ static inline int pdsch_nr_decode_codeword(srsran_pdsch_nr_t* q, res->evm = srsran_evm_run_b(q->evm_buffer, &q->modem_tables[tb->mod], q->d[tb->cw_idx], llr, tb->nof_bits); } - // Change LLR sign - for (uint32_t i = 0; i < tb->nof_bits; i++) { - llr[i] = -llr[i]; - } + // Change LLR sign and set to zero the LLR that are not used + srsran_vec_neg_bb(llr, llr, tb->nof_bits); // Descrambling srsran_sequence_apply_c(llr, llr, tb->nof_bits, pdsch_nr_cinit(&q->carrier, cfg, rnti, tb->cw_idx)); @@ -610,12 +474,18 @@ int srsran_pdsch_nr_decode(srsran_pdsch_nr_t* q, gettimeofday(&t[1], NULL); } + // Compute DMRS pattern + if (srsran_dmrs_sch_rvd_re_pattern(&cfg->dmrs, grant, &q->dmrs_re_pattern) < SRSRAN_SUCCESS) { + ERROR("Error computing DMRS pattern"); + return SRSRAN_ERROR; + } + uint32_t nof_cw = 0; for (uint32_t tb = 0; tb < SRSRAN_MAX_TB; tb++) { nof_cw += grant->tb[tb].enabled ? 1 : 0; } - uint32_t nof_re = srsran_ra_dl_nr_slot_nof_re(cfg, grant); + uint32_t nof_re = grant->tb[0].nof_re; if (channel->nof_re != nof_re) { ERROR("Inconsistent number of RE (%d!=%d)", channel->nof_re, nof_re); @@ -723,6 +593,12 @@ uint32_t srsran_pdsch_nr_rx_info(const srsran_pdsch_nr_t* q, len += srsran_pdsch_nr_grant_info(cfg, grant, &str[len], str_len - len); + if (cfg->rvd_re.count != 0) { + len = srsran_print_check(str, str_len, len, ", Reserved={"); + len += srsran_re_pattern_list_info(&cfg->rvd_re, &str[len], str_len - len); + len = srsran_print_check(str, str_len, len, "}"); + } + if (q->evm_buffer != NULL) { len = srsran_print_check(str, str_len, len, ",evm={", 0); for (uint32_t i = 0; i < SRSRAN_MAX_CODEWORDS; i++) { @@ -766,13 +642,5 @@ uint32_t srsran_pdsch_nr_tx_info(const srsran_pdsch_nr_t* q, char* str, uint32_t str_len) { - uint32_t len = 0; - - len += srsran_pdsch_nr_grant_info(cfg, grant, &str[len], str_len - len); - - if (q->meas_time_en) { - len = srsran_print_check(str, str_len, len, ", t=%d us", q->meas_time_us); - } - - return len; + return srsran_pdsch_nr_rx_info(q, cfg, grant, NULL, str, str_len); } diff --git a/lib/src/phy/phch/ra_nr.c b/lib/src/phy/phch/ra_nr.c index a4ab97397..53caf96c3 100644 --- a/lib/src/phy/phch/ra_nr.c +++ b/lib/src/phy/phch/ra_nr.c @@ -11,6 +11,7 @@ */ #include "srsran/phy/phch/ra_nr.h" +#include "srsran/phy/ch_estimation/csi_rs.h" #include "srsran/phy/phch/csi.h" #include "srsran/phy/phch/pdsch_nr.h" #include "srsran/phy/phch/ra_dl_nr.h" @@ -245,6 +246,27 @@ static ra_nr_table_t ra_nr_select_table(srsran_mcs_table_t mcs_table, return ra_nr_select_table_pdsch(mcs_table, dci_format, search_space_type, rnti_type); } +static int ra_nr_dmrs_power_offset(srsran_sch_grant_nr_t* grant) +{ + if (grant == NULL) { + return SRSRAN_ERROR_INVALID_INPUTS; + } + + // Defined by TS 38.214 V15.10.0: + // - Table 4.1-1: The ratio of PDSCH EPRE to DM-RS EPRE + // - Table 6.2.2-1: The ratio of PUSCH EPRE to DM-RS EPRE + float ratio_dB[3] = {0, -3, -4.77}; + + if (grant->nof_dmrs_cdm_groups_without_data < 1 || grant->nof_dmrs_cdm_groups_without_data > 3) { + ERROR("Invalid number of DMRS CDM groups without data (%d)", grant->nof_dmrs_cdm_groups_without_data); + return SRSRAN_ERROR; + } + + grant->beta_dmrs = srsran_convert_dB_to_amplitude(-ratio_dB[grant->nof_dmrs_cdm_groups_without_data - 1]); + + return SRSRAN_SUCCESS; +} + double srsran_ra_nr_R_from_mcs(srsran_mcs_table_t mcs_table, srsran_dci_format_nr_t dci_format, srsran_search_space_type_t search_space_type, @@ -405,6 +427,34 @@ uint32_t srsran_ra_nr_tbs(uint32_t N_re, double S, double R, uint32_t Qm, uint32 return ra_nr_tbs_from_n_info4(n_info, R); } +static int ra_nr_assert_csi_rs_dmrs_collision(const srsran_sch_cfg_nr_t* pdsch_cfg) +{ + // Generate DMRS pattern + srsran_re_pattern_t dmrs_re_pattern = {}; + if (srsran_dmrs_sch_rvd_re_pattern(&pdsch_cfg->dmrs, &pdsch_cfg->grant, &dmrs_re_pattern) < SRSRAN_SUCCESS) { + ERROR("Error computing DMRS pattern"); + return SRSRAN_ERROR; + } + + // Check for collision + if (srsran_re_pattern_check_collision(&pdsch_cfg->rvd_re, &dmrs_re_pattern) < SRSRAN_SUCCESS) { + // Create reserved info string + char str_rvd[512] = {}; + srsran_re_pattern_list_info(&pdsch_cfg->rvd_re, str_rvd, (uint32_t)sizeof(str_rvd)); + + // Create DMRS info string + char str_dmrs[512] = {}; + srsran_re_pattern_info(&dmrs_re_pattern, str_dmrs, (uint32_t)sizeof(str_dmrs)); + + ERROR("Error. The UE is not expected to receive CSI-RS (%s) and DM-RS (%s) on the same resource elements.", + str_rvd, + str_dmrs); + return SRSRAN_ERROR; + } + + return SRSRAN_SUCCESS; +} + int srsran_ra_nr_fill_tb(const srsran_sch_cfg_nr_t* pdsch_cfg, const srsran_sch_grant_nr_t* grant, uint32_t mcs_idx, @@ -451,7 +501,7 @@ int srsran_ra_nr_fill_tb(const srsran_sch_cfg_nr_t* pdsch_cfg, // 1) The UE shall first determine the number of REs (N RE ) within the slot. int N_re = srsran_ra_dl_nr_slot_nof_re(pdsch_cfg, grant); if (N_re <= SRSRAN_SUCCESS) { - ERROR("Invalid number of RE"); + ERROR("Invalid number of RE (%d)", N_re); return SRSRAN_ERROR; } @@ -461,55 +511,141 @@ int srsran_ra_nr_fill_tb(const srsran_sch_cfg_nr_t* pdsch_cfg, uint32_t nof_layers_cw2 = grant->nof_layers - nof_layers_cw1; tb->N_L = (cw_idx == 0) ? nof_layers_cw1 : nof_layers_cw2; + // Check DMRS and CSI-RS collision according to TS 38.211 7.4.1.5.3 Mapping to physical resources + // If there was a collision, the number of RE in the grant would be wrong + if (ra_nr_assert_csi_rs_dmrs_collision(pdsch_cfg) < SRSRAN_SUCCESS) { + ERROR("Error: CSI-RS and DMRS collision detected"); + return SRSRAN_ERROR; + } + + // Calculate reserved RE + uint32_t N_re_rvd = srsran_re_pattern_list_count(&pdsch_cfg->rvd_re, grant->S, grant->S + grant->L, grant->prb_idx); + // Steps 2,3,4 tb->tbs = (int)srsran_ra_nr_tbs(N_re, S, R, Qm, tb->N_L); tb->R = R; tb->mod = m; - tb->nof_re = N_re * grant->nof_layers; + tb->nof_re = (N_re - N_re_rvd) * grant->nof_layers; tb->nof_bits = tb->nof_re * Qm; tb->enabled = true; return SRSRAN_SUCCESS; } -static int ra_dl_dmrs(const srsran_sch_hl_cfg_nr_t* pdsch_hl_cfg, - srsran_sch_grant_nr_t* pdsch_grant, - srsran_dmrs_sch_cfg_t* dmrs_cfg) +static int ra_dl_dmrs(const srsran_sch_hl_cfg_nr_t* hl_cfg, srsran_sch_grant_nr_t* grant, srsran_sch_cfg_nr_t* cfg) { - const bool dedicated_dmrs_present = (pdsch_grant->mapping == srsran_sch_mapping_type_A) - ? pdsch_hl_cfg->dmrs_typeA.present - : pdsch_hl_cfg->dmrs_typeB.present; + const bool dedicated_dmrs_present = + (grant->mapping == srsran_sch_mapping_type_A) ? hl_cfg->dmrs_typeA.present : hl_cfg->dmrs_typeB.present; - if (pdsch_grant->dci_format == srsran_dci_format_nr_1_0 || !dedicated_dmrs_present) { - if (pdsch_grant->mapping == srsran_sch_mapping_type_A) { + if (grant->dci_format == srsran_dci_format_nr_1_0 || !dedicated_dmrs_present) { + if (grant->mapping == srsran_sch_mapping_type_A) { // Absent default values are defined is TS 38.331 - DMRS-DownlinkConfig - dmrs_cfg->additional_pos = srsran_dmrs_sch_add_pos_2; - dmrs_cfg->type = srsran_dmrs_sch_type_1; - dmrs_cfg->length = srsran_dmrs_sch_len_1; - dmrs_cfg->scrambling_id0_present = false; - dmrs_cfg->scrambling_id1_present = false; - - if (pdsch_grant->dci_format == srsran_dci_format_nr_1_0) { - if (srsran_ra_dl_nr_nof_dmrs_cdm_groups_without_data_format_1_0(dmrs_cfg, pdsch_grant) < SRSRAN_SUCCESS) { - ERROR("Error loading number of DMRS CDM groups"); - return SRSRAN_ERROR; - } - } else { - ERROR("Invalid case"); - return SRSRAN_ERROR; - } + cfg->dmrs.additional_pos = srsran_dmrs_sch_add_pos_2; + cfg->dmrs.type = srsran_dmrs_sch_type_1; + cfg->dmrs.length = srsran_dmrs_sch_len_1; + cfg->dmrs.scrambling_id0_present = false; + cfg->dmrs.scrambling_id1_present = false; + } else { + ERROR("Unsupported configuration"); + return SRSRAN_ERROR; + } + } else { + if (grant->mapping == srsran_sch_mapping_type_A) { + cfg->dmrs.additional_pos = hl_cfg->dmrs_typeA.additional_pos; + cfg->dmrs.type = hl_cfg->dmrs_typeA.type; + cfg->dmrs.length = hl_cfg->dmrs_typeA.length; + cfg->dmrs.scrambling_id0_present = false; + cfg->dmrs.scrambling_id1_present = false; + } else { + cfg->dmrs.additional_pos = hl_cfg->dmrs_typeB.additional_pos; + cfg->dmrs.type = hl_cfg->dmrs_typeB.type; + cfg->dmrs.length = hl_cfg->dmrs_typeB.length; + cfg->dmrs.scrambling_id0_present = false; + cfg->dmrs.scrambling_id1_present = false; + } + } - return SRSRAN_SUCCESS; + // Set number of DMRS CDM groups without data + if (grant->dci_format == srsran_dci_format_nr_1_0) { + if (srsran_ra_dl_nr_nof_dmrs_cdm_groups_without_data_format_1_0(&cfg->dmrs, grant) < SRSRAN_SUCCESS) { + ERROR("Error loading number of DMRS CDM groups"); + return SRSRAN_ERROR; } + } else { + ERROR("Invalid case"); + return SRSRAN_ERROR; + } - ERROR("Unsupported configuration"); + // Set DMRS power offset Table 6.2.2-1: The ratio of PUSCH EPRE to DM-RS EPRE + if (ra_nr_dmrs_power_offset(grant) < SRSRAN_SUCCESS) { + ERROR("Error setting DMRS power offset"); return SRSRAN_ERROR; } - return SRSRAN_ERROR; + return SRSRAN_SUCCESS; +} + +static int ra_dl_resource_mapping(const srsran_carrier_nr_t* carrier, + const srsran_slot_cfg_t* slot, + const srsran_sch_hl_cfg_nr_t* pdsch_hl_cfg, + srsran_sch_cfg_nr_t* pdsch_cfg) +{ + // SS/PBCH block transmission resources not available for PDSCH + // ... Not implemented + + // 5.1.4.1 PDSCH resource mapping with RB symbol level granularity + // rateMatchPatternToAddModList ... Not implemented + + // 5.1.4.2 PDSCH resource mapping with RE level granularity + // RateMatchingPatternLTE-CRS ... Not implemented + + // Append periodic ZP-CSI-RS + for (uint32_t i = 0; i < pdsch_hl_cfg->p_zp_csi_rs_set.count; i++) { + // Select resource + const srsran_csi_rs_zp_resource_t* resource = &pdsch_hl_cfg->p_zp_csi_rs_set.data[i]; + + // Check if the periodic ZP-CSI is transmitted + if (srsran_csi_rs_send(&resource->periodicity, slot)) { + INFO("Tx/Rx ZP-CSI-RS @slot=%d\n", slot->idx); + if (srsran_csi_rs_append_resource_to_pattern(carrier, &resource->resource_mapping, &pdsch_cfg->rvd_re)) { + ERROR("Error appending ZP-CSI-RS as RE pattern"); + return SRSRAN_ERROR; + } + } + } + + // Append semi-persistent ZP-CSI-RS here + // ... not implemented + + // Append aperiodic ZP-CSI-RS here + // ... not implemented + + // Append periodic NZP-CSI-RS according to TS 38.211 clause 7.3.1.5 Mapping to virtual resource blocks + // Only aplicable if CRC is scrambled by C-RNTI, MCS-C-RNTI, CS-RNTI, or PDSCH with SPS + bool nzp_rvd_valid = pdsch_cfg->grant.rnti_type == srsran_rnti_type_c || + pdsch_cfg->grant.rnti_type == srsran_rnti_type_mcs_c || + pdsch_cfg->grant.rnti_type == srsran_rnti_type_cs; + for (uint32_t set_id = 0; set_id < SRSRAN_PHCH_CFG_MAX_NOF_CSI_RS_SETS && nzp_rvd_valid; set_id++) { + for (uint32_t res_id = 0; res_id < pdsch_hl_cfg->nzp_csi_rs_sets[set_id].count; res_id++) { + // Select resource + const srsran_csi_rs_nzp_resource_t* resource = &pdsch_hl_cfg->nzp_csi_rs_sets[set_id].data[res_id]; + + // Check if the periodic ZP-CSI is transmitted + if (srsran_csi_rs_send(&resource->periodicity, slot)) { + INFO("Tx/Rx NZP-CSI-RS set_id=%d; res=%d; @slot=%d\n", set_id, res_id, slot->idx); + if (srsran_csi_rs_append_resource_to_pattern(carrier, &resource->resource_mapping, &pdsch_cfg->rvd_re)) { + ERROR("Error appending ZP-CSI-RS as RE pattern"); + return SRSRAN_ERROR; + } + } + } + } + + return SRSRAN_SUCCESS; } int srsran_ra_dl_dci_to_grant_nr(const srsran_carrier_nr_t* carrier, + const srsran_slot_cfg_t* slot, const srsran_sch_hl_cfg_nr_t* pdsch_hl_cfg, const srsran_dci_dl_nr_t* dci_dl, srsran_sch_cfg_nr_t* pdsch_cfg, @@ -541,8 +677,14 @@ int srsran_ra_dl_dci_to_grant_nr(const srsran_carrier_nr_t* carrier, pdsch_grant->rnti_type = dci_dl->rnti_type; pdsch_grant->tb[0].rv = dci_dl->rv; + // 5.1.4 PDSCH resource mapping + if (ra_dl_resource_mapping(carrier, slot, pdsch_hl_cfg, pdsch_cfg) < SRSRAN_SUCCESS) { + ERROR("Error in resource mapping"); + return SRSRAN_ERROR; + } + // 5.1.6.2 DM-RS reception procedure - if (ra_dl_dmrs(pdsch_hl_cfg, pdsch_grant, &pdsch_cfg->dmrs) < SRSRAN_SUCCESS) { + if (ra_dl_dmrs(pdsch_hl_cfg, pdsch_grant, pdsch_cfg) < SRSRAN_SUCCESS) { ERROR("Error selecting DMRS configuration"); return SRSRAN_ERROR; } @@ -603,7 +745,7 @@ ra_ul_dmrs(const srsran_sch_hl_cfg_nr_t* pusch_hl_cfg, srsran_sch_grant_nr_t* pu } // Set DMRS power offset Table 6.2.2-1: The ratio of PUSCH EPRE to DM-RS EPRE - if (srsran_ra_ul_nr_dmrs_power_offset(pusch_grant) < SRSRAN_SUCCESS) { + if (ra_nr_dmrs_power_offset(pusch_grant) < SRSRAN_SUCCESS) { ERROR("Error setting DMRS power offset"); return SRSRAN_ERROR; } @@ -746,4 +888,4 @@ int srsran_ra_ul_set_grant_uci_nr(const srsran_sch_hl_cfg_nr_t* pusch_hl_cfg, pusch_cfg->uci = *uci_cfg; return SRSRAN_SUCCESS; -} \ No newline at end of file +} diff --git a/lib/src/phy/phch/ra_ul_nr.c b/lib/src/phy/phch/ra_ul_nr.c index 41fe9ed30..8960f2903 100644 --- a/lib/src/phy/phch/ra_ul_nr.c +++ b/lib/src/phy/phch/ra_ul_nr.c @@ -222,24 +222,6 @@ int srsran_ra_ul_nr_nof_dmrs_cdm_groups_without_data_format_0_0(const srsran_sch return SRSRAN_SUCCESS; } -int srsran_ra_ul_nr_dmrs_power_offset(srsran_sch_grant_nr_t* grant) -{ - if (grant == NULL) { - return SRSRAN_ERROR_INVALID_INPUTS; - } - - float ratio_dB[3] = {0, -3, -4.77}; - - if (grant->nof_dmrs_cdm_groups_without_data < 1 || grant->nof_dmrs_cdm_groups_without_data > 3) { - ERROR("Invalid number of DMRS CDM groups without data (%d)", grant->nof_dmrs_cdm_groups_without_data); - return SRSRAN_ERROR; - } - - grant->beta_dmrs = srsran_convert_dB_to_amplitude(-ratio_dB[grant->nof_dmrs_cdm_groups_without_data - 1]); - - return SRSRAN_SUCCESS; -} - #define RA_UL_PUCCH_CODE_RATE_N 8 #define RA_UL_PUCCH_CODE_RATE_RESERVED NAN diff --git a/lib/src/phy/phch/test/pdsch_nr_test.c b/lib/src/phy/phch/test/pdsch_nr_test.c index ca34bb90f..42a58b169 100644 --- a/lib/src/phy/phch/test/pdsch_nr_test.c +++ b/lib/src/phy/phch/test/pdsch_nr_test.c @@ -28,11 +28,10 @@ static srsran_carrier_nr_t carrier = { 1 // max_mimo_layers }; -static uint32_t n_prb = 0; // Set to 0 for steering -static uint32_t mcs = 30; // Set to 30 for steering -static srsran_sch_cfg_nr_t pdsch_cfg = {}; -static srsran_sch_grant_nr_t pdsch_grant = {}; -static uint16_t rnti = 0x1234; +static uint32_t n_prb = 0; // Set to 0 for steering +static uint32_t mcs = 30; // Set to 30 for steering +static srsran_sch_cfg_nr_t pdsch_cfg = {}; +static uint16_t rnti = 0x1234; void usage(char* prog) { @@ -153,20 +152,20 @@ int main(int argc, char** argv) } // Use grant default A time resources with m=0 - if (srsran_ra_dl_nr_time_default_A(0, pdsch_cfg.dmrs.typeA_pos, &pdsch_grant) < SRSRAN_SUCCESS) { + if (srsran_ra_dl_nr_time_default_A(0, pdsch_cfg.dmrs.typeA_pos, &pdsch_cfg.grant) < SRSRAN_SUCCESS) { ERROR("Error loading default grant"); goto clean_exit; } // Load number of DMRS CDM groups without data - if (srsran_ra_dl_nr_nof_dmrs_cdm_groups_without_data_format_1_0(&pdsch_cfg.dmrs, &pdsch_grant) < SRSRAN_SUCCESS) { + if (srsran_ra_dl_nr_nof_dmrs_cdm_groups_without_data_format_1_0(&pdsch_cfg.dmrs, &pdsch_cfg.grant) < SRSRAN_SUCCESS) { ERROR("Error loading number of DMRS CDM groups without data"); goto clean_exit; } - pdsch_grant.nof_layers = carrier.max_mimo_layers; - pdsch_grant.dci_format = srsran_dci_format_nr_1_0; - pdsch_grant.rnti = rnti; + pdsch_cfg.grant.nof_layers = carrier.max_mimo_layers; + pdsch_cfg.grant.dci_format = srsran_dci_format_nr_1_0; + pdsch_cfg.grant.rnti = rnti; uint32_t n_prb_start = 1; uint32_t n_prb_end = carrier.nof_prb + 1; @@ -190,10 +189,10 @@ int main(int argc, char** argv) for (n_prb = n_prb_start; n_prb < n_prb_end; n_prb++) { for (mcs = mcs_start; mcs < mcs_end; mcs++) { for (uint32_t n = 0; n < SRSRAN_MAX_PRB_NR; n++) { - pdsch_grant.prb_idx[n] = (n < n_prb); + pdsch_cfg.grant.prb_idx[n] = (n < n_prb); } - if (srsran_ra_nr_fill_tb(&pdsch_cfg, &pdsch_grant, mcs, &pdsch_grant.tb[0]) < SRSRAN_SUCCESS) { + if (srsran_ra_nr_fill_tb(&pdsch_cfg, &pdsch_cfg.grant, mcs, &pdsch_cfg.grant.tb[0]) < SRSRAN_SUCCESS) { ERROR("Error filing tb"); goto clean_exit; } @@ -204,28 +203,29 @@ int main(int argc, char** argv) continue; } - for (uint32_t i = 0; i < pdsch_grant.tb[tb].tbs; i++) { + for (uint32_t i = 0; i < pdsch_cfg.grant.tb[tb].tbs; i++) { data_tx[tb][i] = (uint8_t)srsran_random_uniform_int_dist(rand_gen, 0, UINT8_MAX); } - pdsch_grant.tb[tb].softbuffer.tx = &softbuffer_tx; + pdsch_cfg.grant.tb[tb].softbuffer.tx = &softbuffer_tx; } - if (srsran_pdsch_nr_encode(&pdsch_tx, &pdsch_cfg, &pdsch_grant, data_tx, sf_symbols) < SRSRAN_SUCCESS) { + if (srsran_pdsch_nr_encode(&pdsch_tx, &pdsch_cfg, &pdsch_cfg.grant, data_tx, sf_symbols) < SRSRAN_SUCCESS) { ERROR("Error encoding"); goto clean_exit; } for (uint32_t tb = 0; tb < SRSRAN_MAX_TB; tb++) { - pdsch_grant.tb[tb].softbuffer.rx = &softbuffer_rx; - srsran_softbuffer_rx_reset(pdsch_grant.tb[tb].softbuffer.rx); + pdsch_cfg.grant.tb[tb].softbuffer.rx = &softbuffer_rx; + srsran_softbuffer_rx_reset(pdsch_cfg.grant.tb[tb].softbuffer.rx); } - for (uint32_t i = 0; i < pdsch_grant.tb->nof_re; i++) { + for (uint32_t i = 0; i < pdsch_cfg.grant.tb->nof_re; i++) { chest.ce[0][0][i] = 1.0f; } - chest.nof_re = pdsch_grant.tb->nof_re; + chest.nof_re = pdsch_cfg.grant.tb->nof_re; - if (srsran_pdsch_nr_decode(&pdsch_rx, &pdsch_cfg, &pdsch_grant, &chest, sf_symbols, pdsch_res) < SRSRAN_SUCCESS) { + if (srsran_pdsch_nr_decode(&pdsch_rx, &pdsch_cfg, &pdsch_cfg.grant, &chest, sf_symbols, pdsch_res) < + SRSRAN_SUCCESS) { ERROR("Error encoding"); goto clean_exit; } @@ -236,18 +236,18 @@ int main(int argc, char** argv) } float mse = 0.0f; - uint32_t nof_re = srsran_ra_dl_nr_slot_nof_re(&pdsch_cfg, &pdsch_grant); - for (uint32_t i = 0; i < pdsch_grant.nof_layers; i++) { + uint32_t nof_re = srsran_ra_dl_nr_slot_nof_re(&pdsch_cfg, &pdsch_cfg.grant); + for (uint32_t i = 0; i < pdsch_cfg.grant.nof_layers; i++) { for (uint32_t j = 0; j < nof_re; j++) { mse += cabsf(pdsch_tx.d[i][j] - pdsch_rx.d[i][j]); } } - if (nof_re * pdsch_grant.nof_layers > 0) { - mse = mse / (nof_re * pdsch_grant.nof_layers); + if (nof_re * pdsch_cfg.grant.nof_layers > 0) { + mse = mse / (nof_re * pdsch_cfg.grant.nof_layers); } if (mse > 0.001) { ERROR("MSE error (%f) is too high", mse); - for (uint32_t i = 0; i < pdsch_grant.nof_layers; i++) { + for (uint32_t i = 0; i < pdsch_cfg.grant.nof_layers; i++) { printf("d_tx[%d]=", i); srsran_vec_fprint_c(stdout, pdsch_tx.d[i], nof_re); printf("d_rx[%d]=", i); @@ -257,20 +257,20 @@ int main(int argc, char** argv) } if (!pdsch_res[0].crc) { - ERROR("Failed to match CRC; n_prb=%d; mcs=%d; TBS=%d;", n_prb, mcs, pdsch_grant.tb[0].tbs); + ERROR("Failed to match CRC; n_prb=%d; mcs=%d; TBS=%d;", n_prb, mcs, pdsch_cfg.grant.tb[0].tbs); goto clean_exit; } - if (memcmp(data_tx[0], data_rx[0], pdsch_grant.tb[0].tbs / 8) != 0) { - ERROR("Failed to match Tx/Rx data; n_prb=%d; mcs=%d; TBS=%d;", n_prb, mcs, pdsch_grant.tb[0].tbs); + if (memcmp(data_tx[0], data_rx[0], pdsch_cfg.grant.tb[0].tbs / 8) != 0) { + ERROR("Failed to match Tx/Rx data; n_prb=%d; mcs=%d; TBS=%d;", n_prb, mcs, pdsch_cfg.grant.tb[0].tbs); printf("Tx data: "); - srsran_vec_fprint_byte(stdout, data_tx[0], pdsch_grant.tb[0].tbs / 8); + srsran_vec_fprint_byte(stdout, data_tx[0], pdsch_cfg.grant.tb[0].tbs / 8); printf("Rx data: "); - srsran_vec_fprint_byte(stdout, data_rx[0], pdsch_grant.tb[0].tbs / 8); + srsran_vec_fprint_byte(stdout, data_rx[0], pdsch_cfg.grant.tb[0].tbs / 8); goto clean_exit; } - printf("n_prb=%d; mcs=%d; TBS=%d; EVM=%f; PASSED!\n", n_prb, mcs, pdsch_grant.tb[0].tbs, pdsch_res[0].evm); + INFO("n_prb=%d; mcs=%d; TBS=%d; EVM=%f; PASSED!\n", n_prb, mcs, pdsch_cfg.grant.tb[0].tbs, pdsch_res[0].evm); } } diff --git a/lib/src/phy/utils/re_pattern.c b/lib/src/phy/utils/re_pattern.c new file mode 100644 index 000000000..d390ae2ad --- /dev/null +++ b/lib/src/phy/utils/re_pattern.c @@ -0,0 +1,320 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +#include "srsran/phy/utils/re_pattern.h" +#include "srsran/phy/utils/debug.h" +#include "srsran/phy/utils/vector.h" + +bool srsran_re_pattern_to_mask(const srsran_re_pattern_list_t* list, uint32_t l, uint32_t k) +{ + uint32_t rb_idx = k % SRSRAN_NRE; + uint32_t sc_idx = k / SRSRAN_NRE; + + // Check pattern list is valid + if (list == NULL) { + return false; + } + + // Iterate all given patterns + for (uint32_t i = 0; i < list->count; i++) { + const srsran_re_pattern_t* pattern = &list->data[i]; + + // Skip pattern if it is not active in this OFDM symbol + if (!pattern->symbol[l]) { + continue; + } + + // Skip pattern if RB index is put of the pattern bounds + if (rb_idx < pattern->rb_begin || rb_idx >= pattern->rb_end) { + continue; + } + + // Matched SC, early return + if (pattern->sc[sc_idx]) { + return true; + } + } + + // If reached here, no pattern was matched + return false; +} + +int srsran_re_pattern_to_symbol_mask(const srsran_re_pattern_t* pattern, uint32_t l, bool* mask) +{ + // Check inputs + if (pattern == NULL || mask == NULL) { + return SRSRAN_ERROR_INVALID_INPUTS; + } + + // Check symbol index is in range + if (l >= SRSRAN_NSYMB_PER_SLOT_NR) { + ERROR("Symbol index is out of range"); + return SRSRAN_ERROR; + } + + // Skip pattern if it is not active in this OFDM symbol + if (!pattern->symbol[l]) { + return SRSRAN_SUCCESS; + } + + // Make sure RB end is bounded + if (pattern->rb_end > SRSRAN_MAX_PRB_NR) { + return SRSRAN_ERROR; + } + + // Add mask for pattern + for (uint32_t rb_idx = pattern->rb_begin; rb_idx < pattern->rb_end; rb_idx += pattern->rb_stride) { + for (uint32_t sc_idx = 0; sc_idx < SRSRAN_NRE; sc_idx++) { + mask[rb_idx * SRSRAN_NRE + sc_idx] |= pattern->sc[sc_idx]; + } + } + + return SRSRAN_SUCCESS; +} + +int srsran_re_pattern_list_to_symbol_mask(const srsran_re_pattern_list_t* list, uint32_t l, bool* mask) +{ + // Check inputs + if (list == NULL || mask == NULL) { + return SRSRAN_ERROR_INVALID_INPUTS; + } + + // Iterate all given patterns + for (uint32_t i = 0; i < list->count; i++) { + if (srsran_re_pattern_to_symbol_mask(&list->data[i], l, mask) < SRSRAN_SUCCESS) { + ERROR("Error calculating mask"); + return SRSRAN_ERROR; + } + } + + return SRSRAN_SUCCESS; +} + +int srsran_re_pattern_merge(srsran_re_pattern_list_t* list, const srsran_re_pattern_t* p) +{ + // Check inputs are valid + if (list == NULL || p == NULL) { + return SRSRAN_ERROR_INVALID_INPUTS; + } + + // Count number of subcarrier mask + uint32_t kcount = 0; + for (uint32_t k = 0; k < SRSRAN_NRE; k++) { + kcount += p->sc[k] ? 1 : 0; + } + + // Count number of symbol mask + uint32_t lcount = 0; + for (uint32_t l = 0; l < SRSRAN_NRE; l++) { + lcount += p->symbol[l] ? 1 : 0; + } + + // If any mask is empty, ignore + if (kcount == 0 || lcount == 0) { + return SRSRAN_SUCCESS; + } + + // Iterate all given patterns + for (uint32_t i = 0; i < list->count; i++) { + srsran_re_pattern_t* pattern = &list->data[i]; + + // Skip if RB parameters dont match + if (pattern->rb_begin != p->rb_begin || pattern->rb_end != p->rb_end || pattern->rb_stride != p->rb_stride) { + continue; + } + + // Check if symbol mask matches + bool lmatch = (memcmp(pattern->symbol, p->symbol, SRSRAN_NSYMB_PER_SLOT_NR) == 0); + + // Check if sc mask matches + bool kmatch = (memcmp(pattern->sc, p->sc, SRSRAN_NRE) == 0); + + // If OFDM symbols and subcarriers mask match, it means that the patterns are completely overlapped and no merging + // is required + if (kmatch && lmatch) { + return SRSRAN_SUCCESS; + } + + // If OFDM symbols mask matches, merge subcarrier mask + if (lmatch) { + for (uint32_t k = 0; k < SRSRAN_NRE; k++) { + pattern->sc[k] |= p->sc[k]; + } + return SRSRAN_SUCCESS; + } + + // If subcarriers mask matches, merge OFDM symbols mask + if (kmatch) { + for (uint32_t l = 0; l < SRSRAN_NSYMB_PER_SLOT_NR; l++) { + pattern->symbol[l] |= p->symbol[l]; + } + return SRSRAN_SUCCESS; + } + } + + // If reached here, no pattern was matched. Try appending + if (list->count >= SRSRAN_RE_PATTERN_LIST_SIZE) { + ERROR("Insufficient number of available RE patterns in list"); + return SRSRAN_ERROR; + } + + // Append + list->data[list->count] = *p; + list->count++; + + return SRSRAN_SUCCESS; +} + +int srsran_re_pattern_check_collision(const srsran_re_pattern_list_t* list, const srsran_re_pattern_t* p) +{ + // Check inputs are valid + if (list == NULL || p == NULL) { + return SRSRAN_ERROR_INVALID_INPUTS; + } + + // Count number of subcarrier mask + uint32_t kcount = 0; + for (uint32_t k = 0; k < SRSRAN_NRE; k++) { + kcount += p->sc[k] ? 1 : 0; + } + + // Count number of symbol mask + uint32_t lcount = 0; + for (uint32_t l = 0; l < SRSRAN_NRE; l++) { + lcount += p->symbol[l] ? 1 : 0; + } + + // If any mask is empty, no collision + if (kcount == 0 || lcount == 0) { + return SRSRAN_SUCCESS; + } + + // Iterate all given patterns + for (uint32_t i = 0; i < list->count; i++) { + const srsran_re_pattern_t* pattern = &list->data[i]; + + // Skip if RB do not overlap + if (pattern->rb_begin > p->rb_end || p->rb_begin > pattern->rb_end) { + continue; + } + + // Check if symbol are matched + bool lmatch = false; + for (uint32_t l = 0; l < SRSRAN_NSYMB_PER_SLOT_NR && !lmatch; l++) { + // Consider match if both patterns have a positive symbol in common + lmatch = (p->symbol[l] && pattern->symbol[l]); + } + + // If the symbols are not matched, skip pattern + if (!lmatch) { + continue; + } + + // Check if any subcarrier mask matches + for (uint32_t k = 0; k < SRSRAN_NRE; k++) { + // Consider a collision if both subcarrier mask are true + if (p->sc[k] && pattern->sc[k]) { + return SRSRAN_ERROR; + } + } + } + + // If reached here, means no collision + return SRSRAN_SUCCESS; +} + +void srsran_re_pattern_reset(srsran_re_pattern_list_t* list) +{ + if (list == NULL) { + return; + } + SRSRAN_MEM_ZERO(list, srsran_re_pattern_list_t, 1); +} + +uint32_t srsran_re_pattern_info(const srsran_re_pattern_t* pattern, char* str, uint32_t str_len) +{ + if (pattern == NULL || str == NULL || str_len == 0) { + return 0; + } + + char subc[SRSRAN_NRE + 1] = {}; + srsran_vec_sprint_bin(subc, SRSRAN_NRE + 1, (uint8_t*)pattern->sc, SRSRAN_NRE); + + char symb[SRSRAN_NSYMB_PER_SLOT_NR + 1] = {}; + srsran_vec_sprint_bin(symb, SRSRAN_NSYMB_PER_SLOT_NR + 1, (uint8_t*)pattern->symbol, SRSRAN_NSYMB_PER_SLOT_NR); + + return srsran_print_check(str, + str_len, + 0, + "begin=%d end=%d stride=%d sc=%s symb=%s ", + pattern->rb_begin, + pattern->rb_end, + pattern->rb_stride, + subc, + symb); +} + +uint32_t srsran_re_pattern_list_info(const srsran_re_pattern_list_t* list, char* str, uint32_t str_len) +{ + uint32_t len = 0; + if (list == NULL || str == NULL || str_len == 0) { + return 0; + } + + for (uint32_t i = 0; i < list->count; i++) { + len = srsran_print_check(str, str_len, len, "RE%d: ", i); + len += srsran_re_pattern_info(&list->data[i], &str[len], str_len - len); + } + + return len; +} + +uint32_t srsran_re_pattern_list_count(const srsran_re_pattern_list_t* list, + uint32_t symbol_begin, + uint32_t symbol_end, + const bool prb_mask[SRSRAN_MAX_PRB_NR]) +{ + uint32_t count = 0; + if (list == NULL || prb_mask == NULL) { + return 0; + } + + // Iterate over all symbols and create a symbol mask + for (uint32_t l = symbol_begin; l < symbol_end; l++) { + // Entire symbol mask to prevent overlapped RE to count twice + bool symbol_mask[SRSRAN_NRE * SRSRAN_MAX_PRB_NR] = {}; + + // For each pattern, compute symbol mask + for (uint32_t i = 0; i < list->count; i++) { + if (srsran_re_pattern_to_symbol_mask(&list->data[i], l, symbol_mask) < SRSRAN_SUCCESS) { + ERROR("Error calculating symbol mask"); + return SRSRAN_ERROR; + } + } + + // Count number of masked elements + for (uint32_t rb = 0; rb < SRSRAN_MAX_PRB_NR; rb++) { + // Skip PRB if disabled + if (!prb_mask[rb]) { + continue; + } + + // Iterate all subcarriers in the PRB + for (uint32_t k = rb * SRSRAN_NRE; k < (rb + 1) * SRSRAN_NRE; k++) { + // Count only the true masked RE + count += (uint32_t)symbol_mask[k]; + } + } + } + + return count; +} \ No newline at end of file diff --git a/lib/src/phy/utils/test/CMakeLists.txt b/lib/src/phy/utils/test/CMakeLists.txt index 4a5f062f4..095945c7b 100644 --- a/lib/src/phy/utils/test/CMakeLists.txt +++ b/lib/src/phy/utils/test/CMakeLists.txt @@ -36,10 +36,19 @@ target_link_libraries(vector_test srsran_phy) add_test(vector_test vector_test) +######################################################################## +# Ring-Buffer TEST ######################################################################## add_executable(ringbuffer_test ring_buffer_test.c) target_link_libraries(ringbuffer_test srsran_phy) add_test(ringbuffer_tester ringbuffer_test) + ######################################################################## +# RE-Pattern TEST +######################################################################## +add_executable(re_pattern_test re_pattern_test.c) +target_link_libraries(re_pattern_test srsran_phy) + +add_test(re_pattern_test re_pattern_test) \ No newline at end of file diff --git a/lib/src/phy/utils/test/re_pattern_test.c b/lib/src/phy/utils/test/re_pattern_test.c new file mode 100644 index 000000000..ffed8bfb7 --- /dev/null +++ b/lib/src/phy/utils/test/re_pattern_test.c @@ -0,0 +1,60 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +#include "srsran/common/test_common.h" +#include "srsran/phy/utils/re_pattern.h" + +int main(int argc, char** argv) +{ + srsran_re_pattern_list_t pattern_list; + + // Reset list + srsran_re_pattern_reset(&pattern_list); + + // Create first pattern and merge + srsran_re_pattern_t pattern_1 = {}; + pattern_1.rb_begin = 1; + pattern_1.rb_end = 50; + pattern_1.rb_stride = 1; + for (uint32_t k = 0; k < SRSRAN_NRE; k++) { + pattern_1.sc[k] = (k % 2 == 0); // Only even subcarriers + } + for (uint32_t l = 0; l < SRSRAN_NSYMB_PER_SLOT_NR; l++) { + pattern_1.symbol[l] = (l % 2 == 0); // Only even symbols + } + TESTASSERT(srsran_re_pattern_merge(&pattern_list, &pattern_1) == SRSRAN_SUCCESS); + TESTASSERT(pattern_list.count == 1); + + // Create second pattern and merge + srsran_re_pattern_t pattern_2 = pattern_1; + for (uint32_t l = 0; l < SRSRAN_NSYMB_PER_SLOT_NR; l++) { + pattern_2.symbol[l] = (l % 2 == 1); // Only odd symbols + } + TESTASSERT(srsran_re_pattern_merge(&pattern_list, &pattern_2) == SRSRAN_SUCCESS); + TESTASSERT(pattern_list.count == 1); + + // Assert generated mask + for (uint32_t l = 0; l < SRSRAN_NSYMB_PER_SLOT_NR; l++) { + bool mask[SRSRAN_NRE * SRSRAN_MAX_PRB_NR] = {}; + TESTASSERT(srsran_re_pattern_list_to_symbol_mask(&pattern_list, l, mask) == SRSRAN_SUCCESS); + for (uint32_t k = 0; k < SRSRAN_NRE * SRSRAN_MAX_PRB_NR; k++) { + if (k >= pattern_1.rb_begin * SRSRAN_NRE && k < pattern_1.rb_end * SRSRAN_NRE && + (k / SRSRAN_NRE - pattern_1.rb_begin) % pattern_1.rb_stride == 0) { + TESTASSERT(mask[k] == (k % 2 == 0)); + } else { + TESTASSERT(mask[k] == false); + } + } + } + + return SRSRAN_SUCCESS; +} \ No newline at end of file diff --git a/lib/src/phy/utils/test/vector_test.c b/lib/src/phy/utils/test/vector_test.c index 0d184e1b3..45eca840d 100644 --- a/lib/src/phy/utils/test/vector_test.c +++ b/lib/src/phy/utils/test/vector_test.c @@ -211,6 +211,44 @@ TEST( free(y); free(z);) +TEST( + srsran_vec_neg_bbb, MALLOC(int8_t, x); MALLOC(int8_t, y); MALLOC(int8_t, z); + + int16_t gold = 0.0f; + for (int i = 0; i < block_size; i++) { + x[i] = RANDOM_B(); + do { + y[i] = RANDOM_B(); + } while (!y[i]); + } + + TEST_CALL(srsran_vec_neg_bbb(x, y, z, block_size)) + + for (int i = 0; i < block_size; i++) { + gold = y[i] < 0 ? -x[i] : x[i]; + mse += abs(gold - z[i]); + } + + free(x); + free(y); + free(z);) + +TEST( + srsran_vec_neg_bb, MALLOC(int8_t, x); MALLOC(int8_t, z); + + int16_t gold = 0.0f; + for (int i = 0; i < block_size; i++) { x[i] = RANDOM_B(); } + + TEST_CALL(srsran_vec_neg_bb(x, z, block_size)) + + for (int i = 0; i < block_size; i++) { + gold = -x[i]; + mse += abs(gold - z[i]); + } + + free(x); + free(z);) + TEST( srsran_vec_acc_cc, MALLOC(cf_t, x); cf_t z = 0.0f; @@ -836,6 +874,14 @@ int main(int argc, char** argv) test_srsran_vec_neg_sss(func_names[func_count], &timmings[func_count][size_count], block_size); func_count++; + passed[func_count][size_count] = + test_srsran_vec_neg_bbb(func_names[func_count], &timmings[func_count][size_count], block_size); + func_count++; + + passed[func_count][size_count] = + test_srsran_vec_neg_bb(func_names[func_count], &timmings[func_count][size_count], block_size); + func_count++; + passed[func_count][size_count] = test_srsran_vec_acc_cc(func_names[func_count], &timmings[func_count][size_count], block_size); func_count++; diff --git a/lib/src/phy/utils/vector.c b/lib/src/phy/utils/vector.c index 8128ed537..8db09fd02 100644 --- a/lib/src/phy/utils/vector.c +++ b/lib/src/phy/utils/vector.c @@ -465,11 +465,19 @@ void srsran_vec_neg_sss(const int16_t* x, const int16_t* y, int16_t* z, const ui { srsran_vec_neg_sss_simd(x, y, z, len); } + void srsran_vec_neg_bbb(const int8_t* x, const int8_t* y, int8_t* z, const uint32_t len) { srsran_vec_neg_bbb_simd(x, y, z, len); } +void srsran_vec_neg_bb(const int8_t* x, int8_t* z, const uint32_t len) +{ + for (uint32_t i = 0; i < len; i++) { + z[i] = -x[i]; + } +} + // CFO and OFDM processing void srsran_vec_prod_ccc(const cf_t* x, const cf_t* y, cf_t* z, const uint32_t len) { diff --git a/lib/test/adt/circular_map_test.cc b/lib/test/adt/circular_map_test.cc index aed0dd88a..9bbb25dae 100644 --- a/lib/test/adt/circular_map_test.cc +++ b/lib/test/adt/circular_map_test.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of diff --git a/lib/test/phy/CMakeLists.txt b/lib/test/phy/CMakeLists.txt index e280225cb..2a99abea6 100644 --- a/lib/test/phy/CMakeLists.txt +++ b/lib/test/phy/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2013-2021 Software Radio Systems Limited +# Copyright 2013-2020 Software Radio Systems Limited # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of @@ -52,4 +52,7 @@ add_lte_test(pucch_ca_test pucch_ca_test) add_executable(phy_dl_nr_test phy_dl_nr_test.c) target_link_libraries(phy_dl_nr_test srsran_phy srsran_common srsran_phy ${SEC_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) -add_nr_test(phy_dl_nr_test phy_dl_nr_test -p 100 -m 28) \ No newline at end of file +add_nr_test(phy_dl_nr_test phy_dl_nr_test -p 100 -m 28) +add_nr_test(phy_dl_nr_test_rvd phy_dl_nr_test -P 52 -p 52 -m 0 + -R 0 52 1 010010010010 00000000010000 + -R 0 52 1 100100100100 00000010000000) \ No newline at end of file diff --git a/lib/test/phy/phy_dl_nr_test.c b/lib/test/phy/phy_dl_nr_test.c index 10898dc08..4f8f958e7 100644 --- a/lib/test/phy/phy_dl_nr_test.c +++ b/lib/test/phy/phy_dl_nr_test.c @@ -20,20 +20,18 @@ #include static srsran_carrier_nr_t carrier = { - 0, // cell_id + 501, // cell_id 0, // numerology - 100, // nof_prb + 52, // nof_prb 0, // start 1 // max_mimo_layers }; -static uint32_t n_prb = 0; // Set to 0 for steering -static uint32_t mcs = 30; // Set to 30 for steering -static srsran_sch_cfg_nr_t pdsch_cfg = {}; -static srsran_sch_grant_nr_t pdsch_grant = {}; -static uint16_t rnti = 0x1234; -static uint32_t nof_slots = 10; +static uint32_t n_prb = 0; // Set to 0 for steering +static uint32_t mcs = 30; // Set to 30 for steering +static srsran_sch_cfg_nr_t pdsch_cfg = {}; +static uint32_t nof_slots = 10; static void usage(char* prog) { @@ -44,6 +42,7 @@ static void usage(char* prog) printf("\t-m MCS PRB, set to >28 for steering [Default %d]\n", mcs); printf("\t-T Provide MCS table (64qam, 256qam, 64qamLowSE) [Default %s]\n", srsran_mcs_table_to_str(pdsch_cfg.sch_cfg.mcs_table)); + printf("\t-R Reserve RE: [rb_begin] [rb_end] [rb_stride] [sc_mask] [symbol_mask]\n"); printf("\t-L Provide number of layers [Default %d]\n", carrier.max_mimo_layers); printf("\t-v [set srsran_verbose to debug, default none]\n"); } @@ -51,7 +50,7 @@ static void usage(char* prog) static int parse_args(int argc, char** argv) { int opt; - while ((opt = getopt(argc, argv, "PpmnTLv")) != -1) { + while ((opt = getopt(argc, argv, "RPpmnTLv")) != -1) { switch (opt) { case 'P': carrier.nof_prb = (uint32_t)strtol(argv[optind], NULL, 10); @@ -68,6 +67,24 @@ static int parse_args(int argc, char** argv) case 'T': pdsch_cfg.sch_cfg.mcs_table = srsran_mcs_table_from_str(argv[optind]); break; + case 'R': { + srsran_re_pattern_t pattern = {}; + pattern.rb_begin = (uint32_t)strtol(argv[optind++], NULL, 10); + pattern.rb_end = (uint32_t)strtol(argv[optind++], NULL, 10); + pattern.rb_stride = (uint32_t)strtol(argv[optind++], NULL, 10); + uint32_t sc_mask = (uint32_t)strtol(argv[optind++], NULL, 2); + for (uint32_t i = 0; i < SRSRAN_NRE; i++) { + pattern.sc[i] = ((sc_mask >> (SRSRAN_NRE - 1U - i)) & 0x1) == 0x1; + } + uint32_t symbol_mask = (uint32_t)strtol(argv[optind], NULL, 2); + for (uint32_t i = 0; i < SRSRAN_NSYMB_PER_SLOT_NR; i++) { + pattern.symbol[i] = ((symbol_mask >> (SRSRAN_NSYMB_PER_SLOT_NR - 1U - i)) & 0x1) == 0x1; + } + if (srsran_re_pattern_merge(&pdsch_cfg.rvd_re, &pattern) < SRSRAN_ERROR) { + ERROR("Error adding pattern"); + return SRSRAN_ERROR; + } + } break; case 'L': carrier.max_mimo_layers = (uint32_t)strtol(argv[optind], NULL, 10); break; @@ -86,7 +103,6 @@ static int parse_args(int argc, char** argv) static int work_gnb_dl(srsran_enb_dl_nr_t* enb_dl, srsran_slot_cfg_t* slot, srsran_search_space_t* search_space, - srsran_dci_dl_nr_t* dci_dl, srsran_dci_location_t* dci_location, uint8_t** data_tx) { @@ -96,20 +112,26 @@ static int work_gnb_dl(srsran_enb_dl_nr_t* enb_dl, } // Hard-coded values - dci_dl->format = srsran_dci_format_nr_1_0; - dci_dl->rnti_type = srsran_rnti_type_c; - dci_dl->location = *dci_location; - dci_dl->search_space = search_space->type; - dci_dl->rnti = rnti; + srsran_dci_dl_nr_t dci_dl = {}; + dci_dl.rnti = pdsch_cfg.grant.rnti; + dci_dl.rnti_type = pdsch_cfg.grant.rnti_type; + dci_dl.format = srsran_dci_format_nr_1_0; + dci_dl.location = *dci_location; + dci_dl.search_space = search_space->type; + dci_dl.coreset_id = 1; + dci_dl.freq_domain_assigment = 0; + dci_dl.time_domain_assigment = 0; + dci_dl.vrb_to_prb_mapping = 0; + dci_dl.mcs = mcs; + dci_dl.rv = 0; // Put actual DCI - if (srsran_enb_dl_nr_pdcch_put(enb_dl, slot, dci_dl) < SRSRAN_SUCCESS) { + if (srsran_enb_dl_nr_pdcch_put(enb_dl, slot, &dci_dl) < SRSRAN_SUCCESS) { ERROR("Error putting PDCCH"); return SRSRAN_ERROR; } // Put PDSCH transmission - pdsch_cfg.grant = pdsch_grant; if (srsran_enb_dl_nr_pdsch_put(enb_dl, slot, &pdsch_cfg, data_tx) < SRSRAN_SUCCESS) { ERROR("Error putting PDSCH"); return SRSRAN_ERROR; @@ -124,8 +146,9 @@ static int work_ue_dl(srsran_ue_dl_nr_t* ue_dl, srsran_slot_cfg_t* slot, srsran_ { srsran_ue_dl_nr_estimate_fft(ue_dl, slot); - srsran_dci_dl_nr_t dci_dl_rx = {}; - int nof_found_dci = srsran_ue_dl_nr_find_dl_dci(ue_dl, slot, rnti, srsran_rnti_type_c, &dci_dl_rx, 1); + srsran_dci_dl_nr_t dci_dl_rx = {}; + int nof_found_dci = + srsran_ue_dl_nr_find_dl_dci(ue_dl, slot, pdsch_cfg.grant.rnti, pdsch_cfg.grant.rnti_type, &dci_dl_rx, 1); if (nof_found_dci < SRSRAN_SUCCESS) { ERROR("Error decoding"); return SRSRAN_ERROR; @@ -136,7 +159,6 @@ static int work_ue_dl(srsran_ue_dl_nr_t* ue_dl, srsran_slot_cfg_t* slot, srsran_ return SRSRAN_ERROR; } - pdsch_cfg.grant = pdsch_grant; if (srsran_ue_dl_nr_decode_pdsch(ue_dl, slot, &pdsch_cfg, pdsch_res) < SRSRAN_SUCCESS) { ERROR("Error decoding"); return SRSRAN_ERROR; @@ -192,8 +214,8 @@ int main(int argc, char** argv) srsran_ue_dl_nr_pdcch_cfg_t pdcch_cfg = {}; // Configure CORESET - srsran_coreset_t* coreset = &pdcch_cfg.coreset[0]; - pdcch_cfg.coreset_present[0] = true; + srsran_coreset_t* coreset = &pdcch_cfg.coreset[1]; + pdcch_cfg.coreset_present[1] = true; coreset->duration = 2; for (uint32_t i = 0; i < SRSRAN_CORESET_FREQ_DOMAIN_RES_SIZE; i++) { coreset->freq_resources[i] = i < carrier.nof_prb / 6; @@ -202,7 +224,9 @@ int main(int argc, char** argv) // Configure Search Space srsran_search_space_t* search_space = &pdcch_cfg.search_space[0]; pdcch_cfg.search_space_present[0] = true; - search_space->type = srsran_search_space_type_ue; + search_space->id = 0; + search_space->coreset_id = 1; + search_space->type = srsran_search_space_type_common_3; for (uint32_t L = 0; L < SRSRAN_SEARCH_SPACE_NOF_AGGREGATION_LEVELS_NR; L++) { search_space->nof_candidates[L] = srsran_pdcch_nr_max_candidates_coreset(coreset, L); } @@ -264,13 +288,16 @@ int main(int argc, char** argv) } // Use grant default A time resources with m=0 - if (srsran_ra_dl_nr_time_default_A(0, pdsch_cfg.dmrs.typeA_pos, &pdsch_grant) < SRSRAN_SUCCESS) { + pdsch_cfg.dmrs.typeA_pos = srsran_dmrs_sch_typeA_pos_2; + if (srsran_ra_dl_nr_time_default_A(0, pdsch_cfg.dmrs.typeA_pos, &pdsch_cfg.grant) < SRSRAN_SUCCESS) { ERROR("Error loading default grant"); goto clean_exit; } - pdsch_grant.nof_layers = carrier.max_mimo_layers; - pdsch_grant.dci_format = srsran_dci_format_nr_1_0; - pdsch_grant.nof_dmrs_cdm_groups_without_data = 1; + pdsch_cfg.grant.nof_layers = carrier.max_mimo_layers; + pdsch_cfg.grant.dci_format = srsran_dci_format_nr_1_0; + pdsch_cfg.grant.nof_dmrs_cdm_groups_without_data = 1; + pdsch_cfg.grant.rnti_type = srsran_rnti_type_c; + pdsch_cfg.grant.rnti = 0x4601; uint32_t n_prb_start = 1; uint32_t n_prb_end = carrier.nof_prb + 1; @@ -291,10 +318,11 @@ int main(int argc, char** argv) for (n_prb = n_prb_start; n_prb < n_prb_end; n_prb++) { for (mcs = mcs_start; mcs < mcs_end; mcs++, slot_count++) { for (uint32_t n = 0; n < SRSRAN_MAX_PRB_NR; n++) { - pdsch_grant.prb_idx[n] = (n < n_prb); + pdsch_cfg.grant.prb_idx[n] = (n < n_prb); } + pdsch_cfg.grant.nof_prb = n_prb; - if (srsran_ra_nr_fill_tb(&pdsch_cfg, &pdsch_grant, mcs, &pdsch_grant.tb[0]) < SRSRAN_SUCCESS) { + if (srsran_ra_nr_fill_tb(&pdsch_cfg, &pdsch_cfg.grant, mcs, &pdsch_cfg.grant.tb[0]) < SRSRAN_SUCCESS) { ERROR("Error filing tb"); goto clean_exit; } @@ -305,17 +333,17 @@ int main(int argc, char** argv) continue; } - for (uint32_t i = 0; i < pdsch_grant.tb[tb].tbs; i++) { + for (uint32_t i = 0; i < pdsch_cfg.grant.tb[tb].tbs; i++) { data_tx[tb][i] = (uint8_t)srsran_random_uniform_int_dist(rand_gen, 0, UINT8_MAX); } - pdsch_grant.tb[tb].softbuffer.tx = &softbuffer_tx; + pdsch_cfg.grant.tb[tb].softbuffer.tx = &softbuffer_tx; } // Compute PDCCH candidate locations uint32_t L = 0; uint32_t ncce_candidates[SRSRAN_SEARCH_SPACE_MAX_NOF_CANDIDATES_NR] = {}; - int nof_candidates = - srsran_pdcch_nr_locations_coreset(coreset, search_space, rnti, L, slot.idx, ncce_candidates); + int nof_candidates = srsran_pdcch_nr_locations_coreset( + coreset, search_space, pdsch_cfg.grant.rnti, L, slot.idx, ncce_candidates); if (nof_candidates < SRSRAN_SUCCESS) { ERROR("Error getting PDCCH candidates"); goto clean_exit; @@ -326,11 +354,8 @@ int main(int argc, char** argv) dci_location.ncce = ncce_candidates[0]; dci_location.L = L; - // Setup DCI - srsran_dci_dl_nr_t dci_dl = {}; - gettimeofday(&t[1], NULL); - if (work_gnb_dl(&enb_dl, &slot, search_space, &dci_dl, &dci_location, data_tx) < SRSRAN_ERROR) { + if (work_gnb_dl(&enb_dl, &slot, search_space, &dci_location, data_tx) < SRSRAN_ERROR) { ERROR("Error running eNb DL"); goto clean_exit; } @@ -339,8 +364,8 @@ int main(int argc, char** argv) pdsch_encode_us += (size_t)(t[0].tv_sec * 1e6 + t[0].tv_usec); for (uint32_t tb = 0; tb < SRSRAN_MAX_TB; tb++) { - pdsch_grant.tb[tb].softbuffer.rx = &softbuffer_rx; - srsran_softbuffer_rx_reset(pdsch_grant.tb[tb].softbuffer.rx); + pdsch_cfg.grant.tb[tb].softbuffer.rx = &softbuffer_rx; + srsran_softbuffer_rx_reset(pdsch_cfg.grant.tb[tb].softbuffer.rx); } gettimeofday(&t[1], NULL); @@ -358,23 +383,23 @@ int main(int argc, char** argv) } if (!pdsch_res[0].crc) { - ERROR("Failed to match CRC; n_prb=%d; mcs=%d; TBS=%d;", n_prb, mcs, pdsch_grant.tb[0].tbs); + ERROR("Failed to match CRC; n_prb=%d; mcs=%d; TBS=%d;", n_prb, mcs, pdsch_cfg.grant.tb[0].tbs); goto clean_exit; } - if (memcmp(data_tx[0], data_rx[0], pdsch_grant.tb[0].tbs / 8) != 0) { - ERROR("Failed to match Tx/Rx data; n_prb=%d; mcs=%d; TBS=%d;", n_prb, mcs, pdsch_grant.tb[0].tbs); + if (memcmp(data_tx[0], data_rx[0], pdsch_cfg.grant.tb[0].tbs / 8) != 0) { + ERROR("Failed to match Tx/Rx data; n_prb=%d; mcs=%d; TBS=%d;", n_prb, mcs, pdsch_cfg.grant.tb[0].tbs); printf("Tx data: "); - srsran_vec_fprint_byte(stdout, data_tx[0], pdsch_grant.tb[0].tbs / 8); + srsran_vec_fprint_byte(stdout, data_tx[0], pdsch_cfg.grant.tb[0].tbs / 8); printf("Rx data: "); - srsran_vec_fprint_byte(stdout, data_rx[0], pdsch_grant.tb[0].tbs / 8); + srsran_vec_fprint_byte(stdout, data_rx[0], pdsch_cfg.grant.tb[0].tbs / 8); goto clean_exit; } - INFO("n_prb=%d; mcs=%d; TBS=%d; EVM=%f; PASSED!", n_prb, mcs, pdsch_grant.tb[0].tbs, pdsch_res[0].evm); + INFO("n_prb=%d; mcs=%d; TBS=%d; EVM=%f; PASSED!", n_prb, mcs, pdsch_cfg.grant.tb[0].tbs, pdsch_res[0].evm); // Count the Tx/Rx'd number of bits - nof_bits += pdsch_grant.tb[0].tbs; + nof_bits += pdsch_cfg.grant.tb[0].tbs; } } } diff --git a/srsenb/src/phy/nr/cc_worker.cc b/srsenb/src/phy/nr/cc_worker.cc index aaaa2b52b..85f3827ea 100644 --- a/srsenb/src/phy/nr/cc_worker.cc +++ b/srsenb/src/phy/nr/cc_worker.cc @@ -125,8 +125,11 @@ int cc_worker::encode_pdsch(stack_interface_phy_nr::dl_sched_grant_t* grants, ui srsran_sch_cfg_nr_t pdsch_cfg = {}; // Compute DL grant - if (srsran_ra_dl_dci_to_grant_nr(&enb_dl.carrier, &pdsch_hl_cfg, &grants[i].dci, &pdsch_cfg, &pdsch_cfg.grant)) { + if (srsran_ra_dl_dci_to_grant_nr( + &enb_dl.carrier, &dl_slot_cfg, &pdsch_hl_cfg, &grants[i].dci, &pdsch_cfg, &pdsch_cfg.grant) < + SRSRAN_SUCCESS) { ERROR("Computing DL grant"); + return false; } // Set soft buffer diff --git a/srsue/hdr/phy/nr/state.h b/srsue/hdr/phy/nr/state.h index 2b0996ad5..90a70fd42 100644 --- a/srsue/hdr/phy/nr/state.h +++ b/srsue/hdr/phy/nr/state.h @@ -142,11 +142,11 @@ public: * @param tti_rx The TTI in which the grant was received * @param dci_dl The DL DCI message to store */ - void set_dl_pending_grant(uint32_t tti_rx, const srsran_dci_dl_nr_t& dci_dl) + void set_dl_pending_grant(const srsran_slot_cfg_t& slot, const srsran_dci_dl_nr_t& dci_dl) { // Convert DL DCI to grant srsran_sch_cfg_nr_t pdsch_cfg = {}; - if (srsran_ra_dl_dci_to_grant_nr(&carrier, &cfg.pdsch, &dci_dl, &pdsch_cfg, &pdsch_cfg.grant)) { + if (srsran_ra_dl_dci_to_grant_nr(&carrier, &slot, &cfg.pdsch, &dci_dl, &pdsch_cfg, &pdsch_cfg.grant)) { ERROR("Computing UL grant"); return; } @@ -159,7 +159,7 @@ public: } // Calculate Receive TTI - tti_rx = TTI_ADD(tti_rx, pdsch_cfg.grant.k); + uint32_t tti_rx = TTI_ADD(slot.idx, pdsch_cfg.grant.k); // Scope mutex to protect read/write the list std::lock_guard lock(pending_dl_grant_mutex); diff --git a/srsue/src/phy/nr/cc_worker.cc b/srsue/src/phy/nr/cc_worker.cc index 685cf7055..e12f8e230 100644 --- a/srsue/src/phy/nr/cc_worker.cc +++ b/srsue/src/phy/nr/cc_worker.cc @@ -143,7 +143,7 @@ void cc_worker::decode_pdcch_dl() } // Enqueue UL grants - phy->set_dl_pending_grant(dl_slot_cfg.idx, dci_rx[i]); + phy->set_dl_pending_grant(dl_slot_cfg, dci_rx[i]); } if (logger.debug.enabled()) { From 14bfd55fb98f7f7a35c7a714805f3983bee1c5eb Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Tue, 23 Mar 2021 21:45:07 +0100 Subject: [PATCH 25/48] Restore removed function from ue_db --- srsenb/hdr/phy/phy_ue_db.h | 8 ++++++++ srsenb/src/phy/phy_ue_db.cc | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/srsenb/hdr/phy/phy_ue_db.h b/srsenb/hdr/phy/phy_ue_db.h index 01fedcf29..765b08cc7 100644 --- a/srsenb/hdr/phy/phy_ue_db.h +++ b/srsenb/hdr/phy/phy_ue_db.h @@ -288,6 +288,14 @@ public: */ bool is_pcell(uint16_t rnti, uint32_t enb_cc_idx) const; + /** + * Asserts a given eNb cell is part of the given RNTI + * @param rnti identifier of the UE + * @param enb_cc_idx eNb cell/carrier index + * @return It returns true if the cell is part of the UE, othwerwise it returns false + */ + bool ue_has_cell(uint16_t rnti, uint32_t enb_cc_idx) const; + /** * Get the current down-link physical layer configuration for an RNTI and an eNb cell/carrier * diff --git a/srsenb/src/phy/phy_ue_db.cc b/srsenb/src/phy/phy_ue_db.cc index 76b0b3e3a..5988f164e 100644 --- a/srsenb/src/phy/phy_ue_db.cc +++ b/srsenb/src/phy/phy_ue_db.cc @@ -152,6 +152,11 @@ inline int phy_ue_db::_assert_enb_cc(uint16_t rnti, uint32_t enb_cc_idx) const return SRSRAN_SUCCESS; } +bool phy_ue_db::ue_has_cell(uint16_t rnti, uint32_t enb_cc_idx) const +{ + return _assert_enb_cc(rnti, enb_cc_idx) == SRSRAN_SUCCESS; +} + inline int phy_ue_db::_assert_enb_pcell(uint16_t rnti, uint32_t enb_cc_idx) const { if (_assert_enb_cc(rnti, enb_cc_idx) != SRSRAN_SUCCESS) { From 6cd9bba641072a748bc150d9216e7bfe98500b76 Mon Sep 17 00:00:00 2001 From: AlaiaL Date: Tue, 23 Mar 2021 10:13:37 +0100 Subject: [PATCH 26/48] Added the cpu metrics to the system metrics. --- lib/include/srsran/system/sys_metrics.h | 9 +- .../srsran/system/sys_metrics_processor.h | 24 +++- lib/src/system/sys_metrics_processor.cc | 117 ++++++++++++++---- srsenb/src/metrics_csv.cc | 18 ++- srsue/src/metrics_csv.cc | 18 ++- 5 files changed, 152 insertions(+), 34 deletions(-) diff --git a/lib/include/srsran/system/sys_metrics.h b/lib/include/srsran/system/sys_metrics.h index 150e9f36f..890e9c9d7 100644 --- a/lib/include/srsran/system/sys_metrics.h +++ b/lib/include/srsran/system/sys_metrics.h @@ -21,11 +21,12 @@ namespace srsran { struct sys_metrics_t { uint32_t process_realmem_kB = 0; uint32_t process_virtualmem_kB = 0; - float process_realmem = -1.f; - float process_virtualmem = -1.f; + float process_realmem = 0.f; uint32_t thread_count = 0; - float process_cpu_usage = -1.f; - float system_mem = -1.f; + float process_cpu_usage = 0.f; + float system_mem = 0.f; + uint32_t cpu_count = 0; + float cpu_load[128]; }; } // namespace srsran diff --git a/lib/include/srsran/system/sys_metrics_processor.h b/lib/include/srsran/system/sys_metrics_processor.h index 4c1d6309b..7da5c9af5 100644 --- a/lib/include/srsran/system/sys_metrics_processor.h +++ b/lib/include/srsran/system/sys_metrics_processor.h @@ -42,6 +42,18 @@ class sys_metrics_processor std::string comm; }; + /// Helper class to read the cpu metrics. + struct cpu_metrics_t { + std::string name = ""; + int32_t user = 0; + int32_t nice = 0; + int32_t system = 0; + int32_t idle = 0; + int32_t iowait = 0; + int32_t irq = 0; + int32_t softirq = 0; + }; + public: /// Measures and returns the system metrics. sys_metrics_t get_metrics(); @@ -56,9 +68,17 @@ private: /// NOTE: on error, metrics memory parameters are set to 0. void calculate_mem_usage(sys_metrics_t& metrics) const; + /// Calculate the cpu metrics and stores them in the given metrics. delta_time_in_seconds is the number of seconds + /// elapsed since the last cpu metrics measurement. + void calculate_cpu_metrics(sys_metrics_t& metrics, float delta_time_in_seconds); + + /// Returns the cpu metrics from the given line. + cpu_metrics_t read_cpu_idle_from_line(const std::string& line) const; + private: - proc_stats_info last_query = {}; - std::chrono::time_point last_query_time = std::chrono::steady_clock::now(); + proc_stats_info last_query = {}; + cpu_metrics_t last_cpu_thread[128] = {}; + std::chrono::time_point last_query_time = std::chrono::steady_clock::now(); }; } // namespace srsran diff --git a/lib/src/system/sys_metrics_processor.cc b/lib/src/system/sys_metrics_processor.cc index 89e52835d..4dbf3f39f 100644 --- a/lib/src/system/sys_metrics_processor.cc +++ b/lib/src/system/sys_metrics_processor.cc @@ -18,6 +18,9 @@ using namespace srsran; +static const uint32_t cpu_count = ::sysconf(_SC_NPROCESSORS_CONF); +static const float ticks_per_second = ::sysconf(_SC_CLK_TCK); + sys_metrics_processor::proc_stats_info::proc_stats_info() { std::string line; @@ -55,6 +58,9 @@ sys_metrics_t sys_metrics_processor::get_metrics() // Get the memory metrics. calculate_mem_usage(metrics); + // Calculate cpu metrics. + calculate_cpu_metrics(metrics, measure_interval_ms / 1000.f); + // Get the stats from the proc. proc_stats_info current_query; metrics.thread_count = current_query.num_threads; @@ -80,23 +86,54 @@ float sys_metrics_processor::calculate_cpu_usage(const proc_stats_info& current_ return 0.f; } - static const uint32_t cpu_count = ::sysconf(_SC_NPROCESSORS_CONF); - static const float ticks_per_second = ::sysconf(_SC_CLK_TCK); - return ((current_query.stime + current_query.utime) - (last_query.stime + last_query.utime)) * 100.f / (cpu_count * ticks_per_second * delta_time_in_seconds); } -/// Extracts and returns the memory size from the given line. -static uint32_t read_memory_value_from_line(const std::string& line) +sys_metrics_processor::cpu_metrics_t sys_metrics_processor::read_cpu_idle_from_line(const std::string& line) const { std::istringstream reader(line); - std::string label, unit; - uint32_t value; + cpu_metrics_t m; - reader >> label >> value >> unit; + reader >> m.name >> m.user >> m.nice >> m.system >> m.idle >> m.iowait >> m.irq >> m.softirq; - return value; + return m; +} + +void sys_metrics_processor::calculate_cpu_metrics(sys_metrics_t& metrics, float delta_time_in_seconds) +{ + metrics.cpu_count = cpu_count; + + std::ifstream file("/proc/stat"); + std::string line; + + if (!file) { + return; + } + + int count = -1; + while (std::getline(file, line)) { + // First line is the CPU field that contains all the cores and thread. For now, we skip this one. + if (count < 0) { + ++count; + continue; + } + + // Parse all the cpus. + if (line.find("cpu") != std::string::npos) { + auto tmp = read_cpu_idle_from_line(line); + auto index = count++; + if (tmp.idle < last_cpu_thread[index].idle) { + metrics.cpu_load[index] = 0.f; + continue; + } + + metrics.cpu_load[index] = std::max( + (1.f - (tmp.idle - last_cpu_thread[index].idle) / (ticks_per_second * delta_time_in_seconds)) * 100.f, 0.f); + + last_cpu_thread[index] = std::move(tmp); + } + } } /// Sets the memory parameters of the given metrics to zero. @@ -104,11 +141,22 @@ static void set_mem_to_zero(sys_metrics_t& metrics) { metrics.process_realmem_kB = 0; metrics.process_virtualmem_kB = 0; - metrics.process_virtualmem = 0; metrics.process_realmem = 0; metrics.system_mem = 0; } +/// Extracts and returns the memory size from the given line. +static int32_t read_memory_value_from_line(const std::string& line) +{ + std::istringstream reader(line); + std::string label, unit; + int32_t value; + + reader >> label >> value >> unit; + + return value; +} + static void calculate_percentage_memory(sys_metrics_t& metrics) { std::ifstream file("/proc/meminfo"); @@ -119,19 +167,42 @@ static void calculate_percentage_memory(sys_metrics_t& metrics) return; } - // Total system's memory is in the first line. - std::getline(file, line); - uint32_t total_mem_kB = read_memory_value_from_line(line); + struct meminfo_t { + uint32_t total_kB = 0; + uint32_t free_kB = 0; + uint32_t buffers_kB = 0; + uint32_t cached_kB = 0; + uint32_t slab_kB = 0; + }; - // System's available memory is in the third line. - std::getline(file, line); - std::getline(file, line); - uint32_t available_mem_kB = read_memory_value_from_line(line); + // Retrieve the data + meminfo_t m_info; + while (std::getline(file, line)) { + // Looks for Virtual memory. + if (line.find("MemTotal:") != std::string::npos) { + m_info.total_kB = std::max(read_memory_value_from_line(line), 0); + } + if (line.find("MemFree:") != std::string::npos) { + m_info.free_kB = std::max(read_memory_value_from_line(line), 0); + } + if (line.find("Buffers:") != std::string::npos) { + m_info.buffers_kB = std::max(read_memory_value_from_line(line), 0); + } + if (line.find("Cached:") != std::string::npos) { + m_info.cached_kB = std::max(read_memory_value_from_line(line), 0); + } + if (line.find("Slab:") != std::string::npos) { + m_info.slab_kB = std::max(read_memory_value_from_line(line), 0); + } + } // Calculate the metrics. - metrics.process_realmem = 100.f * (float(metrics.process_realmem_kB) / total_mem_kB); - metrics.process_virtualmem = 100.f * (float(metrics.process_virtualmem_kB) / total_mem_kB); - metrics.system_mem = (1.f - float(available_mem_kB) / float(total_mem_kB)) * 100.f; + metrics.process_realmem = (metrics.process_realmem_kB <= m_info.total_kB) + ? 100.f * (float(metrics.process_realmem_kB) / m_info.total_kB) + : 0; + metrics.system_mem = + (1.f - float(m_info.buffers_kB + m_info.cached_kB + m_info.free_kB + m_info.slab_kB) / float(m_info.total_kB)) * + 100.f; } void sys_metrics_processor::calculate_mem_usage(sys_metrics_t& metrics) const @@ -147,12 +218,14 @@ void sys_metrics_processor::calculate_mem_usage(sys_metrics_t& metrics) const while (std::getline(file, line)) { // Looks for Virtual memory. if (line.find("VmSize:") != std::string::npos) { - metrics.process_virtualmem_kB = read_memory_value_from_line(line); + // NOTE: std::max will clamp negative values to 0. + metrics.process_virtualmem_kB = std::max(read_memory_value_from_line(line), 0); continue; } // Looks for physical memory. if (line.find("VmRSS:") != std::string::npos) { - metrics.process_realmem_kB = read_memory_value_from_line(line); + // NOTE: std::max will clamp negative values to 0. + metrics.process_realmem_kB = std::max(read_memory_value_from_line(line), 0); continue; } } diff --git a/srsenb/src/metrics_csv.cc b/srsenb/src/metrics_csv.cc index f2a0b7ca1..34ffd0ac7 100644 --- a/srsenb/src/metrics_csv.cc +++ b/srsenb/src/metrics_csv.cc @@ -56,7 +56,15 @@ void metrics_csv::set_metrics(const enb_metrics_t& metrics, const uint32_t perio if (file.is_open() && enb != NULL) { if (n_reports == 0) { file << "time;nof_ue;dl_brate;ul_brate;" - "proc_rmem;proc_rmem_kB;proc_vmem;proc_vmem_kB;sys_mem;proc_cpu;thread_count\n"; + "proc_rmem;proc_rmem_kB;proc_vmem_kB;sys_mem;system_load;thread_count"; + + // Add the cores. + for (uint32_t i = 0, e = ::sysconf(_SC_NPROCESSORS_CONF); i != e; ++i) { + file << ";cpu_" << std::to_string(i); + } + + // Add the new line. + file << "\n"; } // Time @@ -90,11 +98,15 @@ void metrics_csv::set_metrics(const enb_metrics_t& metrics, const uint32_t perio const srsran::sys_metrics_t& m = metrics.sys; file << float_to_string(m.process_realmem, 2); file << std::to_string(m.process_realmem_kB) << ";"; - file << float_to_string(m.process_virtualmem, 2); file << std::to_string(m.process_virtualmem_kB) << ";"; file << float_to_string(m.system_mem, 2); file << float_to_string(m.process_cpu_usage, 2); - file << std::to_string(m.thread_count); + file << std::to_string(m.thread_count) << ";"; + + // Write the cpu metrics. + for (uint32_t i = 0, e = m.cpu_count, last_cpu_index = e - 1; i != e; ++i) { + file << float_to_string(m.cpu_load[i], 2, (i != last_cpu_index)); + } file << "\n"; diff --git a/srsue/src/metrics_csv.cc b/srsue/src/metrics_csv.cc index e0b19caf4..666fd4981 100644 --- a/srsue/src/metrics_csv.cc +++ b/srsue/src/metrics_csv.cc @@ -78,7 +78,15 @@ void metrics_csv::set_metrics(const ue_metrics_t& metrics, const uint32_t period "bler;" "rf_o;rf_" "u;rf_l;is_attached;" - "proc_rmem;proc_rmem_kB;proc_vmem;proc_vmem_kB;sys_mem;proc_cpu;thread_count\n"; + "proc_rmem;proc_rmem_kB;proc_vmem_kB;sys_mem;sys_load;thread_count"; + + // Add the cores. + for (uint32_t i = 0, e = ::sysconf(_SC_NPROCESSORS_CONF); i != e; ++i) { + file << ";cpu_" << std::to_string(i); + } + + // Add the new line. + file << "\n"; } for (uint32_t r = 0; r < metrics.phy.nof_active_cc; r++) { @@ -159,11 +167,15 @@ void metrics_csv::set_metrics(const ue_metrics_t& metrics, const uint32_t period const srsran::sys_metrics_t& m = metrics.sys; file << float_to_string(m.process_realmem, 2); file << std::to_string(m.process_realmem_kB) << ";"; - file << float_to_string(m.process_virtualmem, 2); file << std::to_string(m.process_virtualmem_kB) << ";"; file << float_to_string(m.system_mem, 2); file << float_to_string(m.process_cpu_usage, 2); - file << std::to_string(m.thread_count); + file << std::to_string(m.thread_count) << ";"; + + // Write the cpu metrics. + for (uint32_t i = 0, e = m.cpu_count, last_cpu_index = e - 1; i != e; ++i) { + file << float_to_string(m.cpu_load[i], 2, (i != last_cpu_index)); + } file << "\n"; } From c9d1c77e8c45591d67963e7214e46535f8e7789d Mon Sep 17 00:00:00 2001 From: AlaiaL Date: Tue, 23 Mar 2021 15:43:23 +0100 Subject: [PATCH 27/48] - Deleted the magic number of maximum supported cores, now it is a constexpr. - When the system has more cores that the maximum supported, the cpu metrics will not be registered. --- lib/include/srsran/system/sys_metrics.h | 4 +++- lib/include/srsran/system/sys_metrics_processor.h | 6 +++--- lib/src/system/sys_metrics_processor.cc | 5 +++++ srsenb/src/metrics_csv.cc | 4 ++-- srsue/src/metrics_csv.cc | 2 +- 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/include/srsran/system/sys_metrics.h b/lib/include/srsran/system/sys_metrics.h index 890e9c9d7..92cc33a4a 100644 --- a/lib/include/srsran/system/sys_metrics.h +++ b/lib/include/srsran/system/sys_metrics.h @@ -17,6 +17,8 @@ namespace srsran { +constexpr uint32_t metrics_max_supported_cpu = 32; + /// Metrics of cpu usage, memory consumption and number of thread used by the process. struct sys_metrics_t { uint32_t process_realmem_kB = 0; @@ -26,7 +28,7 @@ struct sys_metrics_t { float process_cpu_usage = 0.f; float system_mem = 0.f; uint32_t cpu_count = 0; - float cpu_load[128]; + float cpu_load[metrics_max_supported_cpu]; }; } // namespace srsran diff --git a/lib/include/srsran/system/sys_metrics_processor.h b/lib/include/srsran/system/sys_metrics_processor.h index 7da5c9af5..18a5890d8 100644 --- a/lib/include/srsran/system/sys_metrics_processor.h +++ b/lib/include/srsran/system/sys_metrics_processor.h @@ -76,9 +76,9 @@ private: cpu_metrics_t read_cpu_idle_from_line(const std::string& line) const; private: - proc_stats_info last_query = {}; - cpu_metrics_t last_cpu_thread[128] = {}; - std::chrono::time_point last_query_time = std::chrono::steady_clock::now(); + proc_stats_info last_query = {}; + cpu_metrics_t last_cpu_thread[metrics_max_supported_cpu] = {}; + std::chrono::time_point last_query_time = std::chrono::steady_clock::now(); }; } // namespace srsran diff --git a/lib/src/system/sys_metrics_processor.cc b/lib/src/system/sys_metrics_processor.cc index 4dbf3f39f..052daa9a4 100644 --- a/lib/src/system/sys_metrics_processor.cc +++ b/lib/src/system/sys_metrics_processor.cc @@ -102,6 +102,11 @@ sys_metrics_processor::cpu_metrics_t sys_metrics_processor::read_cpu_idle_from_l void sys_metrics_processor::calculate_cpu_metrics(sys_metrics_t& metrics, float delta_time_in_seconds) { + // When the number of cpu is higher than system_metrics_t supports, skip the cpu metrics. + if (cpu_count > metrics_max_supported_cpu) { + return; + } + metrics.cpu_count = cpu_count; std::ifstream file("/proc/stat"); diff --git a/srsenb/src/metrics_csv.cc b/srsenb/src/metrics_csv.cc index 34ffd0ac7..779eb8d22 100644 --- a/srsenb/src/metrics_csv.cc +++ b/srsenb/src/metrics_csv.cc @@ -58,8 +58,8 @@ void metrics_csv::set_metrics(const enb_metrics_t& metrics, const uint32_t perio file << "time;nof_ue;dl_brate;ul_brate;" "proc_rmem;proc_rmem_kB;proc_vmem_kB;sys_mem;system_load;thread_count"; - // Add the cores. - for (uint32_t i = 0, e = ::sysconf(_SC_NPROCESSORS_CONF); i != e; ++i) { + // Add the cpus + for (uint32_t i = 0, e = metrics.sys.cpu_count; i != e; ++i) { file << ";cpu_" << std::to_string(i); } diff --git a/srsue/src/metrics_csv.cc b/srsue/src/metrics_csv.cc index 666fd4981..7474355ab 100644 --- a/srsue/src/metrics_csv.cc +++ b/srsue/src/metrics_csv.cc @@ -81,7 +81,7 @@ void metrics_csv::set_metrics(const ue_metrics_t& metrics, const uint32_t period "proc_rmem;proc_rmem_kB;proc_vmem_kB;sys_mem;sys_load;thread_count"; // Add the cores. - for (uint32_t i = 0, e = ::sysconf(_SC_NPROCESSORS_CONF); i != e; ++i) { + for (uint32_t i = 0, e = metrics.sys.cpu_count; i != e; ++i) { file << ";cpu_" << std::to_string(i); } From bbaebd1274026b6f11a83280772698e735dfd599 Mon Sep 17 00:00:00 2001 From: AlaiaL Date: Wed, 24 Mar 2021 09:59:02 +0100 Subject: [PATCH 28/48] Added a warning in the log when the cpu metrics are not registered due to the number cpu cores is greater than supported. --- lib/include/srsran/system/sys_metrics.h | 2 +- lib/include/srsran/system/sys_metrics_processor.h | 3 +++ lib/src/system/sys_metrics_processor.cc | 7 +++++++ srsenb/src/enb.cc | 2 +- srsue/src/ue.cc | 2 +- 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/include/srsran/system/sys_metrics.h b/lib/include/srsran/system/sys_metrics.h index 92cc33a4a..fb05aa2c3 100644 --- a/lib/include/srsran/system/sys_metrics.h +++ b/lib/include/srsran/system/sys_metrics.h @@ -17,7 +17,7 @@ namespace srsran { -constexpr uint32_t metrics_max_supported_cpu = 32; +constexpr uint32_t metrics_max_supported_cpu = 32u; /// Metrics of cpu usage, memory consumption and number of thread used by the process. struct sys_metrics_t { diff --git a/lib/include/srsran/system/sys_metrics_processor.h b/lib/include/srsran/system/sys_metrics_processor.h index 18a5890d8..1a819d222 100644 --- a/lib/include/srsran/system/sys_metrics_processor.h +++ b/lib/include/srsran/system/sys_metrics_processor.h @@ -13,6 +13,7 @@ #ifndef SRSRAN_SYS_METRICS_PROCESSOR_H #define SRSRAN_SYS_METRICS_PROCESSOR_H +#include "srsran/srslog/logger.h" #include "srsran/system/sys_metrics.h" #include #include @@ -55,6 +56,7 @@ class sys_metrics_processor }; public: + explicit sys_metrics_processor(srslog::basic_logger& log); /// Measures and returns the system metrics. sys_metrics_t get_metrics(); @@ -76,6 +78,7 @@ private: cpu_metrics_t read_cpu_idle_from_line(const std::string& line) const; private: + srslog::basic_logger& log; proc_stats_info last_query = {}; cpu_metrics_t last_cpu_thread[metrics_max_supported_cpu] = {}; std::chrono::time_point last_query_time = std::chrono::steady_clock::now(); diff --git a/lib/src/system/sys_metrics_processor.cc b/lib/src/system/sys_metrics_processor.cc index 052daa9a4..0660f270e 100644 --- a/lib/src/system/sys_metrics_processor.cc +++ b/lib/src/system/sys_metrics_processor.cc @@ -21,6 +21,13 @@ using namespace srsran; static const uint32_t cpu_count = ::sysconf(_SC_NPROCESSORS_CONF); static const float ticks_per_second = ::sysconf(_SC_CLK_TCK); +sys_metrics_processor::sys_metrics_processor(srslog::basic_logger& log) : log(log) +{ + if (cpu_count > metrics_max_supported_cpu) { + log.warning("Number of cpu is greater than supported. CPU metrics will be disabled."); + } +} + sys_metrics_processor::proc_stats_info::proc_stats_info() { std::string line; diff --git a/srsenb/src/enb.cc b/srsenb/src/enb.cc index b16cac867..4c903babd 100644 --- a/srsenb/src/enb.cc +++ b/srsenb/src/enb.cc @@ -23,7 +23,7 @@ namespace srsenb { enb::enb(srslog::sink& log_sink) : - started(false), log_sink(log_sink), enb_log(srslog::fetch_basic_logger("ENB", log_sink, false)) + started(false), log_sink(log_sink), enb_log(srslog::fetch_basic_logger("ENB", log_sink, false)), sys_proc(enb_log) { // print build info std::cout << std::endl << get_build_string() << std::endl << std::endl; diff --git a/srsue/src/ue.cc b/srsue/src/ue.cc index 94a4e344f..526a8ebda 100644 --- a/srsue/src/ue.cc +++ b/srsue/src/ue.cc @@ -29,7 +29,7 @@ using namespace srsran; namespace srsue { -ue::ue() : logger(srslog::fetch_basic_logger("UE", false)) +ue::ue() : logger(srslog::fetch_basic_logger("UE", false)), sys_proc(logger) { // print build info std::cout << std::endl << get_build_string() << std::endl << std::endl; From fd3c2b855ec587844c89e1ec2bead3a2612055a4 Mon Sep 17 00:00:00 2001 From: AlaiaL Date: Wed, 24 Mar 2021 10:54:22 +0100 Subject: [PATCH 29/48] - Renamed log to logger. - Added a log entry in the metrics when skipping a measurement due to time constrains --- lib/include/srsran/system/sys_metrics_processor.h | 4 ++-- lib/src/system/sys_metrics_processor.cc | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/include/srsran/system/sys_metrics_processor.h b/lib/include/srsran/system/sys_metrics_processor.h index 1a819d222..b3471e5ad 100644 --- a/lib/include/srsran/system/sys_metrics_processor.h +++ b/lib/include/srsran/system/sys_metrics_processor.h @@ -56,7 +56,7 @@ class sys_metrics_processor }; public: - explicit sys_metrics_processor(srslog::basic_logger& log); + explicit sys_metrics_processor(srslog::basic_logger& logger); /// Measures and returns the system metrics. sys_metrics_t get_metrics(); @@ -78,7 +78,7 @@ private: cpu_metrics_t read_cpu_idle_from_line(const std::string& line) const; private: - srslog::basic_logger& log; + srslog::basic_logger& logger; proc_stats_info last_query = {}; cpu_metrics_t last_cpu_thread[metrics_max_supported_cpu] = {}; std::chrono::time_point last_query_time = std::chrono::steady_clock::now(); diff --git a/lib/src/system/sys_metrics_processor.cc b/lib/src/system/sys_metrics_processor.cc index 0660f270e..61e36385f 100644 --- a/lib/src/system/sys_metrics_processor.cc +++ b/lib/src/system/sys_metrics_processor.cc @@ -21,10 +21,10 @@ using namespace srsran; static const uint32_t cpu_count = ::sysconf(_SC_NPROCESSORS_CONF); static const float ticks_per_second = ::sysconf(_SC_CLK_TCK); -sys_metrics_processor::sys_metrics_processor(srslog::basic_logger& log) : log(log) +sys_metrics_processor::sys_metrics_processor(srslog::basic_logger& logger) : logger(logger) { if (cpu_count > metrics_max_supported_cpu) { - log.warning("Number of cpu is greater than supported. CPU metrics will be disabled."); + logger.warning("Number of cpu is greater than supported. CPU metrics will be disabled."); } } @@ -57,6 +57,7 @@ sys_metrics_t sys_metrics_processor::get_metrics() // The time elapsed between 2 measures must be greater that 100 milliseconds. if (measure_interval_ms < 100u) { + logger.warning("Interval less that 100ms, skipping measurement."); return {}; } From 1cc2cc4e7f380334cd52b3ac6e948b66c23da43e Mon Sep 17 00:00:00 2001 From: AlaiaL Date: Wed, 24 Mar 2021 10:59:17 +0100 Subject: [PATCH 30/48] Fixed typo --- lib/src/system/sys_metrics_processor.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/system/sys_metrics_processor.cc b/lib/src/system/sys_metrics_processor.cc index 61e36385f..408027c6b 100644 --- a/lib/src/system/sys_metrics_processor.cc +++ b/lib/src/system/sys_metrics_processor.cc @@ -57,7 +57,7 @@ sys_metrics_t sys_metrics_processor::get_metrics() // The time elapsed between 2 measures must be greater that 100 milliseconds. if (measure_interval_ms < 100u) { - logger.warning("Interval less that 100ms, skipping measurement."); + logger.warning("Interval less than 100ms, skipping measurement."); return {}; } From 609366afce5075518d2b56fa57f8e7d2674acf5e Mon Sep 17 00:00:00 2001 From: Francisco Date: Tue, 23 Mar 2021 10:50:38 +0000 Subject: [PATCH 31/48] change sched buffer state update log level to info for SRBs --- srsenb/src/stack/mac/sched_ue_ctrl/sched_lch.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/srsenb/src/stack/mac/sched_ue_ctrl/sched_lch.cc b/srsenb/src/stack/mac/sched_ue_ctrl/sched_lch.cc index 88b7452d4..10869e80b 100644 --- a/srsenb/src/stack/mac/sched_ue_ctrl/sched_lch.cc +++ b/srsenb/src/stack/mac/sched_ue_ctrl/sched_lch.cc @@ -139,9 +139,13 @@ void lch_ue_manager::dl_buffer_state(uint8_t lcid, uint32_t tx_queue, uint32_t r logger.warning("The provided lcid=%d is not valid", lcid); return; } + if (lcid < 3 and (lch[lcid].buf_tx != (int)tx_queue or lch[lcid].buf_retx != (int)retx_queue)) { + logger.info("SCHED: DL lcid=%d buffer_state=%d,%d", lcid, tx_queue, retx_queue); + } else { + logger.debug("SCHED: DL lcid=%d buffer_state=%d,%d", lcid, tx_queue, retx_queue); + } lch[lcid].buf_retx = retx_queue; lch[lcid].buf_tx = tx_queue; - logger.debug("SCHED: DL lcid=%d buffer_state=%d,%d", lcid, tx_queue, retx_queue); } int lch_ue_manager::get_max_prio_lcid() const From f992350d2df7de1c971e47ec8a6a9a85baa7b50c Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Wed, 24 Mar 2021 22:40:55 +0100 Subject: [PATCH 32/48] rlc_um_nr_pdu_test: add testcases for 12bit SN length packing/unpacking --- lib/test/upper/rlc_um_nr_pdu_test.cc | 124 +++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) diff --git a/lib/test/upper/rlc_um_nr_pdu_test.cc b/lib/test/upper/rlc_um_nr_pdu_test.cc index 96a491a68..e84c774a7 100644 --- a/lib/test/upper/rlc_um_nr_pdu_test.cc +++ b/lib/test/upper/rlc_um_nr_pdu_test.cc @@ -219,6 +219,115 @@ int rlc_um_nr_pdu_unpack_test6() return SRSRAN_SUCCESS; } +// Unpack RLC UM 12bit SN middle segment PDU SI=11 SN=5 SO=360 +int rlc_um_nr_pdu_unpack_test7() +{ + std::array tv = { + 0xc0, 0x05, 0x01, 0x68, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, + 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, + 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, + 0x7e, 0x7f, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, + 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1, 0xa2, 0xa3, + 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, + 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, + 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, + 0xdd, 0xde, 0xdf, 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, + 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb}; + const uint32_t header_len = 4; + srsran::byte_buffer_t pdu = make_pdu_and_log(tv); + + // unpack PDU + rlc_um_nr_pdu_header_t header = {}; + TESTASSERT(rlc_um_nr_read_data_pdu_header(&pdu, srsran::rlc_um_nr_sn_size_t::size12bits, &header) != 0); + + TESTASSERT(header.si == rlc_nr_si_field_t::neither_first_nor_last_segment); + TESTASSERT(header.so == 360); + TESTASSERT(header.sn == 5); + + TESTASSERT(rlc_um_nr_packed_length(header) == header_len); + + // clear header + corrupt_pdu_header(pdu, header_len, tv.size() - header_len); + + // pack again + TESTASSERT(rlc_um_nr_write_data_pdu_header(header, &pdu) == header_len); + TESTASSERT(pdu.N_bytes == tv.size()); + TESTASSERT(memcmp(pdu.msg, tv.data(), pdu.N_bytes) == 0); + + return SRSRAN_SUCCESS; +} + +// Unpack RLC UM 12bit SN first segment PDU SI=01 SN=5 +int rlc_um_nr_pdu_unpack_test8() +{ + std::array tv = { + 0x40, 0x05, 0x80, 0x00, 0x05, 0x45, 0x00, 0x04, 0x04, 0xf1, 0xaf, 0x40, 0x00, 0x40, 0x01, 0xbd, 0xf5, 0xc0, 0xa8, + 0x03, 0x01, 0xc0, 0xa8, 0x03, 0x02, 0x08, 0x00, 0xbc, 0xea, 0x0b, 0x0d, 0x00, 0x07, 0x81, 0x10, 0x5b, 0x60, 0x00, + 0x00, 0x00, 0x00, 0xed, 0x4c, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, + 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, + 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, + 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0x61, 0x62, 0x63, + 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, + 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, + 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95}; + const uint32_t header_len = 2; + srsran::byte_buffer_t pdu = make_pdu_and_log(tv); + + // unpack PDU + rlc_um_nr_pdu_header_t header = {}; + TESTASSERT(rlc_um_nr_read_data_pdu_header(&pdu, srsran::rlc_um_nr_sn_size_t::size12bits, &header) != 0); + + TESTASSERT(header.si == rlc_nr_si_field_t::first_segment); + TESTASSERT(header.so == 0); + TESTASSERT(header.sn == 5); + + TESTASSERT(rlc_um_nr_packed_length(header) == header_len); + + // clear header + corrupt_pdu_header(pdu, header_len, tv.size() - header_len); + + // pack again + TESTASSERT(rlc_um_nr_write_data_pdu_header(header, &pdu) == header_len); + TESTASSERT(pdu.N_bytes == tv.size()); + TESTASSERT(memcmp(pdu.msg, tv.data(), pdu.N_bytes) == 0); + + return SRSRAN_SUCCESS; +} + +// Unpack/pack RLC UM 12bit SN last segment PDU SI=10 SN=1542 SO=972 +int rlc_um_nr_pdu_unpack_test9() +{ + std::array tv = {0x86, 0x06, 0x03, 0xcc, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, + 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 0xc0, 0xc1, 0xc2, + 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, + 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, + 0xdd, 0xde, 0xdf, 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7}; + const uint32_t header_len = 4; + + srsran::byte_buffer_t pdu = make_pdu_and_log(tv); + + // unpack PDU + rlc_um_nr_pdu_header_t header = {}; + TESTASSERT(rlc_um_nr_read_data_pdu_header(&pdu, srsran::rlc_um_nr_sn_size_t::size12bits, &header) != 0); + + TESTASSERT(header.si == rlc_nr_si_field_t::last_segment); + TESTASSERT(header.so == 972); + TESTASSERT(header.sn == 1542); + + TESTASSERT(rlc_um_nr_packed_length(header) == header_len); + + // clear header + corrupt_pdu_header(pdu, header_len, tv.size() - header_len); + + // pack again + TESTASSERT(rlc_um_nr_write_data_pdu_header(header, &pdu) == header_len); + TESTASSERT(pdu.N_bytes == tv.size()); + TESTASSERT(memcmp(pdu.msg, tv.data(), pdu.N_bytes) == 0); + + return SRSRAN_SUCCESS; +} + int main(int argc, char** argv) { #if PCAP @@ -258,6 +367,21 @@ int main(int argc, char** argv) return SRSRAN_ERROR; } + if (rlc_um_nr_pdu_unpack_test7()) { + fprintf(stderr, "rlc_um_nr_pdu_unpack_test7() failed.\n"); + return SRSRAN_ERROR; + } + + if (rlc_um_nr_pdu_unpack_test8()) { + fprintf(stderr, "rlc_um_nr_pdu_unpack_test8() failed.\n"); + return SRSRAN_ERROR; + } + + if (rlc_um_nr_pdu_unpack_test9()) { + fprintf(stderr, "rlc_um_nr_pdu_unpack_test9() failed.\n"); + return SRSRAN_ERROR; + } + #if PCAP pcap_handle->close(); #endif From 48c106ae640546040caf6352ef6b0f3660577f34 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Wed, 24 Mar 2021 23:19:05 +0100 Subject: [PATCH 33/48] rlc_um_nr: fix packing/unpacking of PDUs with 12bit SN * fix SN extraction/writing * fix packed header size calculation * fix segmentation logic and take variable header lenght into account --- lib/include/srsran/upper/rlc_um_nr.h | 3 + lib/src/upper/rlc_um_nr.cc | 132 +++++++++++++++------------ 2 files changed, 76 insertions(+), 59 deletions(-) diff --git a/lib/include/srsran/upper/rlc_um_nr.h b/lib/include/srsran/upper/rlc_um_nr.h index 2421f90e7..5d01b40d4 100644 --- a/lib/include/srsran/upper/rlc_um_nr.h +++ b/lib/include/srsran/upper/rlc_um_nr.h @@ -62,6 +62,9 @@ private: uint32_t next_so = 0; // The segment offset for the next generated PDU + static constexpr uint32_t head_len_full = 1; // full SDU header size is always + uint32_t head_len_first = 0, head_len_segment = 0; // are computed during configure based on SN length + void debug_state(); }; diff --git a/lib/src/upper/rlc_um_nr.cc b/lib/src/upper/rlc_um_nr.cc index cd653efc0..03f7bf4da 100644 --- a/lib/src/upper/rlc_um_nr.cc +++ b/lib/src/upper/rlc_um_nr.cc @@ -99,6 +99,15 @@ bool rlc_um_nr::rlc_um_nr_tx::configure(const rlc_config_t& cnfg_, std::string r return false; } + // calculate header sizes for configured SN length + rlc_um_nr_pdu_header_t header = {}; + header.si = rlc_nr_si_field_t::first_segment; + header.so = 0; + head_len_first = rlc_um_nr_packed_length(header); + + header.so = 1; + head_len_segment = rlc_um_nr_packed_length(header); + tx_sdu_queue.resize(cnfg_.tx_queue_length); rb_name = rb_name_; @@ -108,18 +117,44 @@ bool rlc_um_nr::rlc_um_nr_tx::configure(const rlc_config_t& cnfg_, std::string r int rlc_um_nr::rlc_um_nr_tx::build_data_pdu(unique_byte_buffer_t pdu, uint8_t* payload, uint32_t nof_bytes) { + // Sanity check (we need at least 2B for a SDU) + if (nof_bytes < 2) { + logger.warning("%s Cannot build a PDU with %d byte.", rb_name.c_str(), nof_bytes); + return 0; + } + std::lock_guard lock(mutex); rlc_um_nr_pdu_header_t header = {}; header.si = rlc_nr_si_field_t::full_sdu; header.sn = TX_Next; header.sn_size = cfg.um_nr.sn_field_length; - uint32_t to_move = 0; - uint8_t* pdu_ptr = pdu->msg; + uint32_t pdu_space = SRSRAN_MIN(nof_bytes, pdu->get_tailroom()); - int head_len = rlc_um_nr_packed_length(header); - int pdu_space = SRSRAN_MIN(nof_bytes, pdu->get_tailroom()); + // Select segmentation information and header size + if (tx_sdu == nullptr) { + // Read a new SDU + tx_sdu = tx_sdu_queue.read(); + next_so = 0; + + // Check for full SDU case + if (tx_sdu->N_bytes <= pdu_space - head_len_full) { + header.si = rlc_nr_si_field_t::full_sdu; + } else { + header.si = rlc_nr_si_field_t::first_segment; + } + } else { + // The SDU is not new; check for last segment + if (tx_sdu->N_bytes <= pdu_space - head_len_segment) { + header.si = rlc_nr_si_field_t::last_segment; + } else { + header.si = rlc_nr_si_field_t::neither_first_nor_last_segment; + } + } + header.so = next_so; + // Calculate actual header length + uint32_t head_len = rlc_um_nr_packed_length(header); if (pdu_space <= head_len + 1) { logger.warning("%s Cannot build a PDU - %d bytes available, %d bytes required for header", rb_name.c_str(), @@ -128,50 +163,24 @@ int rlc_um_nr::rlc_um_nr_tx::build_data_pdu(unique_byte_buffer_t pdu, uint8_t* p return 0; } - // Check for SDU segment - if (tx_sdu) { - uint32_t space = pdu_space - head_len; - to_move = space >= tx_sdu->N_bytes ? tx_sdu->N_bytes : space; - logger.debug( - "%s adding remainder of SDU segment - %d bytes of %d remaining", rb_name.c_str(), to_move, tx_sdu->N_bytes); - memcpy(pdu_ptr, tx_sdu->msg, to_move); - pdu_ptr += to_move; - pdu->N_bytes += to_move; - tx_sdu->N_bytes -= to_move; - tx_sdu->msg += to_move; - if (tx_sdu->N_bytes == 0) { - logger.debug( - "%s Complete SDU scheduled for tx. Stack latency: %ld us", rb_name.c_str(), tx_sdu->get_latency_us().count()); - tx_sdu.reset(); - header.si = rlc_nr_si_field_t::last_segment; - } else { - header.si = rlc_nr_si_field_t::neither_first_nor_last_segment; - } - pdu_space -= SRSRAN_MIN(to_move, pdu->get_tailroom()); - header.so = next_so; - } else { - // Pull SDU from queue - logger.debug("pdu_space=%d, head_len=%d", pdu_space, head_len); - - head_len = rlc_um_nr_packed_length(header); - tx_sdu = tx_sdu_queue.read(); - uint32_t space = pdu_space - head_len; - to_move = space >= tx_sdu->N_bytes ? tx_sdu->N_bytes : space; - logger.debug("%s adding new SDU - %d bytes of %d remaining", rb_name.c_str(), to_move, tx_sdu->N_bytes); - memcpy(pdu_ptr, tx_sdu->msg, to_move); - pdu_ptr += to_move; - pdu->N_bytes += to_move; - tx_sdu->N_bytes -= to_move; - tx_sdu->msg += to_move; - if (tx_sdu->N_bytes == 0) { - logger.debug( - "%s Complete SDU scheduled for tx. Stack latency: %ld us", rb_name.c_str(), tx_sdu->get_latency_us().count()); - tx_sdu.reset(); - header.si = rlc_nr_si_field_t::full_sdu; - } else { - header.si = rlc_nr_si_field_t::first_segment; - } - pdu_space -= to_move; + // Calculate the amount of data to move + uint32_t space = pdu_space - head_len; + uint32_t to_move = space >= tx_sdu->N_bytes ? tx_sdu->N_bytes : space; + + // Log + logger.debug("%s adding %s - (%d/%d)", rb_name.c_str(), to_string(header.si).c_str(), to_move, tx_sdu->N_bytes); + + // Move data from SDU to PDU + uint8_t* pdu_ptr = pdu->msg; + memcpy(pdu_ptr, tx_sdu->msg, to_move); + pdu_ptr += to_move; + pdu->N_bytes += to_move; + tx_sdu->N_bytes -= to_move; + tx_sdu->msg += to_move; + + // Release SDU if emptied + if (tx_sdu->N_bytes == 0) { + tx_sdu.reset(); } // advance SO offset @@ -188,6 +197,10 @@ int rlc_um_nr::rlc_um_nr_tx::build_data_pdu(unique_byte_buffer_t pdu, uint8_t* p memcpy(payload, pdu->msg, pdu->N_bytes); uint32_t ret = pdu->N_bytes; + // Assert number of bytes + srsran_expect( + ret <= nof_bytes, "Error while packing MAC PDU (more bytes written (%d) than expected (%d)!", ret, nof_bytes); + logger.info(payload, ret, "%s Tx PDU SN=%d (%d B)", rb_name.c_str(), header.sn, pdu->N_bytes); debug_state(); @@ -586,8 +599,7 @@ uint32_t rlc_um_nr_read_data_pdu_header(const uint8_t* payload, ptr++; } else if (sn_size == rlc_um_nr_sn_size_t::size12bits) { header->si = (rlc_nr_si_field_t)((*ptr >> 6) & 0x03); // 2 bits SI - header->sn = (*ptr & 0x0F) << 4; // 4 bits SN - + header->sn = (*ptr & 0x0F) << 8; // 4 bits SN if (header->si == rlc_nr_si_field_t::full_sdu and header->sn != 0) { fprintf(stderr, "Malformed PDU, reserved bits are set.\n"); return 0; @@ -632,17 +644,19 @@ uint32_t rlc_um_nr_packed_length(const rlc_um_nr_pdu_header_t& header) { uint32_t len = 0; if (header.si == rlc_nr_si_field_t::full_sdu) { - len = 1; - } else if (header.si == rlc_nr_si_field_t::first_segment) { - len = 1; - if (header.sn_size == rlc_um_nr_sn_size_t::size12bits) { - len++; - } + // that's all .. + len++; } else { if (header.sn_size == rlc_um_nr_sn_size_t::size6bits) { - len = 3; + // Only 1B for SN + len++; } else { - len = 4; + // 2 B for 12bit SN + len += 2; + } + if (header.so) { + // Two bytes always for segment information + len += 2; } } return len; @@ -668,7 +682,7 @@ uint32_t rlc_um_nr_write_data_pdu_header(const rlc_um_nr_pdu_header_t& header, b ptr++; } else { // 12bit SN - *ptr |= (header.sn & 0xf); // 4 bit SN + *ptr |= (header.sn >> 8) & 0xf; // high part of SN (4 bit) ptr++; *ptr = (header.sn & 0xFF); // remaining 8 bit SN ptr++; From 6eedd7027523783eedcc45fea7e83d97db1e70a8 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Wed, 24 Mar 2021 23:20:50 +0100 Subject: [PATCH 34/48] rlc_stress_test: add RLC UM NR 12bit stresstest --- lib/test/upper/CMakeLists.txt | 3 ++- lib/test/upper/rlc_stress_test.cc | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/test/upper/CMakeLists.txt b/lib/test/upper/CMakeLists.txt index c4ca7780a..e17961e96 100644 --- a/lib/test/upper/CMakeLists.txt +++ b/lib/test/upper/CMakeLists.txt @@ -30,7 +30,8 @@ add_lte_test(rlc_am_stress_test rlc_stress_test --mode=AM --loglevel 1 --sdu_gen add_lte_test(rlc_um_stress_test rlc_stress_test --mode=UM --loglevel 1) add_lte_test(rlc_tm_stress_test rlc_stress_test --mode=TM --loglevel 1 --random_opp=false) -add_nr_test(rlc_um_nr_stress_test rlc_stress_test --rat NR --mode=UM --loglevel 1) +add_nr_test(rlc_um6_nr_stress_test rlc_stress_test --rat NR --mode=UM6 --loglevel 1) +add_nr_test(rlc_um12_nr_stress_test rlc_stress_test --rat NR --mode=UM12 --loglevel 1) add_executable(rlc_um_data_test rlc_um_data_test.cc) target_link_libraries(rlc_um_data_test srsran_upper srsran_phy srsran_common) diff --git a/lib/test/upper/rlc_stress_test.cc b/lib/test/upper/rlc_stress_test.cc index 21512a8cd..327043fa2 100644 --- a/lib/test/upper/rlc_stress_test.cc +++ b/lib/test/upper/rlc_stress_test.cc @@ -93,7 +93,7 @@ void parse_args(stress_test_args_t* args, int argc, char* argv[]) bpo::options_description common("Configuration options"); common.add_options() ("rat", bpo::value(&args->rat)->default_value("LTE"), "The RLC version to use (LTE/NR)") - ("mode", bpo::value(&args->mode)->default_value("AM"), "Whether to test RLC acknowledged or unacknowledged mode (AM/UM)") + ("mode", bpo::value(&args->mode)->default_value("AM"), "Whether to test RLC acknowledged or unacknowledged mode (AM/UM for LTE) (UM6/UM12 for NR)") ("duration", bpo::value(&args->test_duration_sec)->default_value(5), "Duration (sec)") ("sdu_size", bpo::value(&args->sdu_size)->default_value(-1), "Size of SDUs (-1 means random)") ("random_opp", bpo::value(&args->random_opp)->default_value(true), "Whether to generate random MAC opportunities") @@ -477,8 +477,10 @@ void stress_test(stress_test_args_t args) pcap.open("rlc_stress_test.pcap", cnfg_); } } else if (args.rat == "NR") { - if (args.mode == "UM") { + if (args.mode == "UM6") { cnfg_ = rlc_config_t::default_rlc_um_nr_config(6); + } else if (args.mode == "UM12") { + cnfg_ = rlc_config_t::default_rlc_um_nr_config(12); } else { cout << "Unsupported RLC mode " << args.mode << ", exiting." << endl; exit(-1); From 7a3a5f4cf4636a6ef25c59950b675641dc55c6f6 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Wed, 24 Mar 2021 21:13:55 +0100 Subject: [PATCH 35/48] rrc_nr: announce short SN in PDCP capabilities this allows selecting 12bit SNs for the NR PDCP entity --- srsue/src/stack/rrc/rrc_nr.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/srsue/src/stack/rrc/rrc_nr.cc b/srsue/src/stack/rrc/rrc_nr.cc index f54508d43..171f1582d 100644 --- a/srsue/src/stack/rrc/rrc_nr.cc +++ b/srsue/src/stack/rrc/rrc_nr.cc @@ -415,6 +415,7 @@ void rrc_nr::get_nr_capabilities(srsran::byte_buffer_t* nr_caps_pdu) nr_cap.rlc_params_present = true; nr_cap.rlc_params.um_with_short_sn_present = true; nr_cap.rlc_params.um_with_long_sn_present = true; + nr_cap.pdcp_params.short_sn_present = true; // Pack nr_caps asn1::bit_ref bref(nr_caps_pdu->msg, nr_caps_pdu->get_tailroom()); From 8c86d2084dbd70757953d3671cf50a2386813567 Mon Sep 17 00:00:00 2001 From: David Rupprecht Date: Wed, 17 Mar 2021 17:08:46 +0100 Subject: [PATCH 36/48] Adding NR phy config RRC parsing Added error handling Reworked flattening error handling --- lib/include/srsran/asn1/rrc_nr_utils.h | 44 +- .../srsran/interfaces/ue_usim_interfaces.h | 4 +- lib/src/asn1/rrc_nr_utils.cc | 519 +++++++++++++++- lib/test/asn1/rrc_nr_utils_test.cc | 492 ++++++++++++++++ srsue/hdr/stack/rrc/rrc_nr.h | 18 +- srsue/hdr/stack/upper/usim_base.h | 4 +- srsue/src/stack/rrc/rrc_nr.cc | 556 +++++++++++++++++- srsue/src/stack/upper/usim_base.cc | 14 +- 8 files changed, 1615 insertions(+), 36 deletions(-) diff --git a/lib/include/srsran/asn1/rrc_nr_utils.h b/lib/include/srsran/asn1/rrc_nr_utils.h index df4263a48..28cc6eb82 100644 --- a/lib/include/srsran/asn1/rrc_nr_utils.h +++ b/lib/include/srsran/asn1/rrc_nr_utils.h @@ -32,6 +32,22 @@ struct pdcp_cfg_s; struct lc_ch_cfg_s; struct rach_cfg_common_s; +// Phy +struct tdd_ul_dl_cfg_common_s; +struct phys_cell_group_cfg_s; +struct search_space_s; +struct search_space_s; +struct csi_report_cfg_s; +struct ctrl_res_set_s; +struct pdsch_time_domain_res_alloc_s; +struct pusch_time_domain_res_alloc_s; +struct pucch_format_cfg_s; +struct pucch_res_s; +struct sched_request_res_cfg_s; +struct dmrs_ul_cfg_s; +struct beta_offsets_s; +struct uci_on_pusch_s; + } // namespace rrc_nr } // namespace asn1 @@ -42,7 +58,33 @@ namespace srsran { plmn_id_t make_plmn_id_t(const asn1::rrc_nr::plmn_id_s& asn1_type); void to_asn1(asn1::rrc_nr::plmn_id_s* asn1_type, const plmn_id_t& cfg); - +/*************************** + * PHY Config + **************************/ +bool make_phy_tdd_cfg(const asn1::rrc_nr::tdd_ul_dl_cfg_common_s& tdd_ul_dl_cfg_common, + srsran_tdd_config_nr_t* srsran_tdd_config_nr); +bool make_phy_harq_ack_cfg(const asn1::rrc_nr::phys_cell_group_cfg_s& phys_cell_group_cfg, + srsran_ue_dl_nr_harq_ack_cfg_t* srsran_ue_dl_nr_harq_ack_cfg); +bool make_phy_coreset_cfg(const asn1::rrc_nr::ctrl_res_set_s& ctrl_res_set, srsran_coreset_t* srsran_coreset); +bool make_phy_search_space_cfg(const asn1::rrc_nr::search_space_s& search_space, + srsran_search_space_t* srsran_search_space); +bool make_phy_csi_report(const asn1::rrc_nr::csi_report_cfg_s& csi_report_cfg, + srsran_csi_hl_report_cfg_t* srsran_csi_hl_report_cfg); +bool make_phy_common_time_ra(const asn1::rrc_nr::pdsch_time_domain_res_alloc_s& pdsch_time_domain_res_alloc, + srsran_sch_time_ra_t* srsran_sch_time_ra); +bool make_phy_common_time_ra(const asn1::rrc_nr::pusch_time_domain_res_alloc_s& pusch_time_domain_res_allo, + srsran_sch_time_ra_t* srsran_sch_time_ra); +bool make_phy_max_code_rate(const asn1::rrc_nr::pucch_format_cfg_s& pucch_format_cfg, uint32_t* max_code_rate); +bool make_phy_res_config(const asn1::rrc_nr::pucch_res_s& pucch_res, + uint32_t format_2_max_code_rate, + srsran_pucch_nr_resource_t* srsran_pucch_nr_resource); +bool make_phy_sr_resource(const asn1::rrc_nr::sched_request_res_cfg_s& sched_request_res_cfg, + srsran_pucch_nr_sr_resource_t* srsran_pucch_nr_sr_resource); +bool make_phy_dmrs_additional_pos(const asn1::rrc_nr::dmrs_ul_cfg_s& dmrs_ul_cfg, + srsran_dmrs_sch_add_pos_t* srsran_dmrs_sch_add_pos); +bool make_phy_beta_offsets(const asn1::rrc_nr::beta_offsets_s& beta_offsets, + srsran_beta_offsets_t* srsran_beta_offsets); +bool make_phy_pusch_scaling(const asn1::rrc_nr::uci_on_pusch_s& uci_on_pusch, float* scaling); /*************************** * MAC Config **************************/ diff --git a/lib/include/srsran/interfaces/ue_usim_interfaces.h b/lib/include/srsran/interfaces/ue_usim_interfaces.h index 8ad50cf9f..ae1112b44 100644 --- a/lib/include/srsran/interfaces/ue_usim_interfaces.h +++ b/lib/include/srsran/interfaces/ue_usim_interfaces.h @@ -56,8 +56,8 @@ public: class usim_interface_rrc_nr { public: - virtual void generate_nr_context(uint16_t sk_counter, srsran::as_security_config_t* sec_cfg) = 0; - virtual void update_nr_context(srsran::as_security_config_t* sec_cfg) = 0; + virtual bool generate_nr_context(uint16_t sk_counter, srsran::as_security_config_t* sec_cfg) = 0; + virtual bool update_nr_context(srsran::as_security_config_t* sec_cfg) = 0; }; } // namespace srsue diff --git a/lib/src/asn1/rrc_nr_utils.cc b/lib/src/asn1/rrc_nr_utils.cc index 0ba2c5eac..5b1b67da7 100644 --- a/lib/src/asn1/rrc_nr_utils.cc +++ b/lib/src/asn1/rrc_nr_utils.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2021 Software Radio Systems Limited + * Copyright 2013-2020 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -194,6 +194,521 @@ srsran::pdcp_config_t make_drb_pdcp_config_t(const uint8_t bearer_id, bool is_ue return cfg; } +bool make_phy_tdd_cfg(const tdd_ul_dl_cfg_common_s& tdd_ul_dl_cfg_common, + srsran_tdd_config_nr_t* in_srsran_tdd_config_nr) +{ + srsran_tdd_config_nr_t srsran_tdd_config_nr = {}; + switch (tdd_ul_dl_cfg_common.pattern1.dl_ul_tx_periodicity) { + case tdd_ul_dl_pattern_s::dl_ul_tx_periodicity_opts::ms1: + srsran_tdd_config_nr.pattern1.period_ms = 1; + break; + case tdd_ul_dl_pattern_s::dl_ul_tx_periodicity_opts::ms2: + srsran_tdd_config_nr.pattern1.period_ms = 2; + break; + case tdd_ul_dl_pattern_s::dl_ul_tx_periodicity_opts::ms5: + srsran_tdd_config_nr.pattern1.period_ms = 5; + break; + case tdd_ul_dl_pattern_s::dl_ul_tx_periodicity_opts::ms10: + srsran_tdd_config_nr.pattern1.period_ms = 10; + break; + + case tdd_ul_dl_pattern_s::dl_ul_tx_periodicity_opts::ms1p25: + case tdd_ul_dl_pattern_s::dl_ul_tx_periodicity_opts::ms0p5: + case tdd_ul_dl_pattern_s::dl_ul_tx_periodicity_opts::ms0p625: + case tdd_ul_dl_pattern_s::dl_ul_tx_periodicity_opts::ms2p5: + default: + asn1::log_warning("Invalid option for dl_ul_tx_periodicity_opts %s", + tdd_ul_dl_cfg_common.pattern1.dl_ul_tx_periodicity.to_string()); + return false; + } + srsran_tdd_config_nr.pattern1.nof_dl_slots = tdd_ul_dl_cfg_common.pattern1.nrof_dl_slots; + srsran_tdd_config_nr.pattern1.nof_dl_symbols = tdd_ul_dl_cfg_common.pattern1.nrof_dl_symbols; + srsran_tdd_config_nr.pattern1.nof_ul_slots = tdd_ul_dl_cfg_common.pattern1.nrof_ul_slots; + srsran_tdd_config_nr.pattern1.nof_ul_symbols = tdd_ul_dl_cfg_common.pattern1.nrof_ul_symbols; + // Copy and return struct + *in_srsran_tdd_config_nr = srsran_tdd_config_nr; + return true; +} + +bool make_phy_harq_ack_cfg(const phys_cell_group_cfg_s& phys_cell_group_cfg, + srsran_ue_dl_nr_harq_ack_cfg_t* in_srsran_ue_dl_nr_harq_ack_cfg) +{ + srsran_ue_dl_nr_harq_ack_cfg_t srsran_ue_dl_nr_harq_ack_cfg; + switch (phys_cell_group_cfg.pdsch_harq_ack_codebook) { + case phys_cell_group_cfg_s::pdsch_harq_ack_codebook_opts::dynamic_value: + srsran_ue_dl_nr_harq_ack_cfg.pdsch_harq_ack_codebook = srsran_pdsch_harq_ack_codebook_dynamic; + break; + case phys_cell_group_cfg_s::pdsch_harq_ack_codebook_opts::semi_static: + srsran_ue_dl_nr_harq_ack_cfg.pdsch_harq_ack_codebook = srsran_pdsch_harq_ack_codebook_semi_static; + break; + case phys_cell_group_cfg_s::pdsch_harq_ack_codebook_opts::nulltype: + srsran_ue_dl_nr_harq_ack_cfg.pdsch_harq_ack_codebook = srsran_pdsch_harq_ack_codebook_none; + break; + default: + asn1::log_warning("Invalid option for pdsch_harq_ack_codebook %s", + phys_cell_group_cfg.pdsch_harq_ack_codebook.to_string()); + return false; + } + *in_srsran_ue_dl_nr_harq_ack_cfg = srsran_ue_dl_nr_harq_ack_cfg; + return true; +} + +bool make_phy_search_space_cfg(const search_space_s& search_space, srsran_search_space_t* in_srsran_search_space) +{ + srsran_search_space_t srsran_search_space = {}; + srsran_search_space.id = search_space.search_space_id; + if (not search_space.ctrl_res_set_id_present) { + asn1::log_warning("ctrl_res_set_id option not present"); + return false; + } + srsran_search_space.coreset_id = search_space.ctrl_res_set_id; + + if (not search_space.nrof_candidates_present) { + asn1::log_warning("nrof_candidates_present option not present"); + return false; + } + srsran_search_space.nof_candidates[0] = search_space.nrof_candidates.aggregation_level1.value; + srsran_search_space.nof_candidates[1] = search_space.nrof_candidates.aggregation_level2.value; + srsran_search_space.nof_candidates[2] = search_space.nrof_candidates.aggregation_level4.value; + srsran_search_space.nof_candidates[3] = search_space.nrof_candidates.aggregation_level8.value; + srsran_search_space.nof_candidates[4] = search_space.nrof_candidates.aggregation_level16.value; + + if (not search_space.search_space_type_present) { + asn1::log_warning("nrof_candidates option not present"); + return false; + } + switch (search_space.search_space_type.type()) { + case search_space_s::search_space_type_c_::types_opts::options::common: + srsran_search_space.type = srsran_search_space_type_common_3; + break; + case search_space_s::search_space_type_c_::types_opts::options::ue_specific: + srsran_search_space.type = srsran_search_space_type_ue; + break; + default: + asn1::log_warning("Invalid option for search_space_type %s", search_space.search_space_type.type().to_string()); + return false; + } + // Copy struct and return value + *in_srsran_search_space = srsran_search_space; + return true; +} + +bool make_phy_csi_report(const csi_report_cfg_s& csi_report_cfg, + srsran_csi_hl_report_cfg_t* in_srsran_csi_hl_report_cfg) +{ + srsran_csi_hl_report_cfg_t srsran_csi_hl_report_cfg = {}; + switch (csi_report_cfg.report_cfg_type.type()) { + case csi_report_cfg_s::report_cfg_type_c_::types_opts::options::nulltype: + srsran_csi_hl_report_cfg.type = SRSRAN_CSI_REPORT_TYPE_NONE; + break; + case csi_report_cfg_s::report_cfg_type_c_::types_opts::options::periodic: + srsran_csi_hl_report_cfg.type = SRSRAN_CSI_REPORT_TYPE_PERIODIC; + break; + case csi_report_cfg_s::report_cfg_type_c_::types_opts::options::aperiodic: + srsran_csi_hl_report_cfg.type = SRSRAN_CSI_REPORT_TYPE_APERIODIC; + break; + case csi_report_cfg_s::report_cfg_type_c_::types_opts::options::semi_persistent_on_pucch: + srsran_csi_hl_report_cfg.type = SRSRAN_CSI_REPORT_TYPE_SEMI_PERSISTENT_ON_PUCCH; + break; + case csi_report_cfg_s::report_cfg_type_c_::types_opts::options::semi_persistent_on_pusch: + srsran_csi_hl_report_cfg.type = SRSRAN_CSI_REPORT_TYPE_SEMI_PERSISTENT_ON_PUSCH; + break; + default: + asn1::log_warning("Invalid option for report_cfg_type %s", csi_report_cfg.report_cfg_type.type().to_string()); + return false; + } + + if (srsran_csi_hl_report_cfg.type = SRSRAN_CSI_REPORT_TYPE_PERIODIC) { + srsran_csi_hl_report_cfg.periodic.period = + csi_report_cfg.report_cfg_type.periodic().report_slot_cfg.type().to_number(); + switch (csi_report_cfg.report_cfg_type.periodic().report_slot_cfg.type()) { + case csi_report_periodicity_and_offset_c::types_opts::slots4: + srsran_csi_hl_report_cfg.periodic.offset = csi_report_cfg.report_cfg_type.periodic().report_slot_cfg.slots4(); + break; + case csi_report_periodicity_and_offset_c::types_opts::slots5: + srsran_csi_hl_report_cfg.periodic.offset = csi_report_cfg.report_cfg_type.periodic().report_slot_cfg.slots5(); + break; + case csi_report_periodicity_and_offset_c::types_opts::slots8: + srsran_csi_hl_report_cfg.periodic.offset = csi_report_cfg.report_cfg_type.periodic().report_slot_cfg.slots8(); + break; + case csi_report_periodicity_and_offset_c::types_opts::slots10: + srsran_csi_hl_report_cfg.periodic.offset = csi_report_cfg.report_cfg_type.periodic().report_slot_cfg.slots10(); + break; + case csi_report_periodicity_and_offset_c::types_opts::slots16: + srsran_csi_hl_report_cfg.periodic.offset = csi_report_cfg.report_cfg_type.periodic().report_slot_cfg.slots16(); + break; + case csi_report_periodicity_and_offset_c::types_opts::slots20: + srsran_csi_hl_report_cfg.periodic.offset = csi_report_cfg.report_cfg_type.periodic().report_slot_cfg.slots20(); + break; + case csi_report_periodicity_and_offset_c::types_opts::slots40: + srsran_csi_hl_report_cfg.periodic.offset = csi_report_cfg.report_cfg_type.periodic().report_slot_cfg.slots40(); + break; + case csi_report_periodicity_and_offset_c::types_opts::slots80: + srsran_csi_hl_report_cfg.periodic.offset = csi_report_cfg.report_cfg_type.periodic().report_slot_cfg.slots80(); + break; + case csi_report_periodicity_and_offset_c::types_opts::slots160: + srsran_csi_hl_report_cfg.periodic.offset = csi_report_cfg.report_cfg_type.periodic().report_slot_cfg.slots160(); + break; + case csi_report_periodicity_and_offset_c::types_opts::slots320: + srsran_csi_hl_report_cfg.periodic.offset = csi_report_cfg.report_cfg_type.periodic().report_slot_cfg.slots320(); + break; + default: + asn1::log_warning("Invalid option for report_slot_cfg %s", + csi_report_cfg.report_cfg_type.periodic().report_slot_cfg.type().to_string()); + return false; + } + } + + srsran_csi_hl_report_cfg.channel_meas_id = csi_report_cfg.res_for_ch_meas; + + srsran_csi_hl_report_cfg.interf_meas_present = csi_report_cfg.csi_im_res_for_interference_present; + srsran_csi_hl_report_cfg.interf_meas_id = csi_report_cfg.csi_im_res_for_interference; + + switch (csi_report_cfg.report_quant.type()) { + case csi_report_cfg_s::report_quant_c_::types_opts::none: + srsran_csi_hl_report_cfg.quantity = SRSRAN_CSI_REPORT_QUANTITY_NONE; + break; + case csi_report_cfg_s::report_quant_c_::types_opts::cri_ri_pmi_cqi: + srsran_csi_hl_report_cfg.quantity = SRSRAN_CSI_REPORT_QUANTITY_CRI_RI_PMI_CQI; + break; + case csi_report_cfg_s::report_quant_c_::types_opts::cri_ri_i1: + srsran_csi_hl_report_cfg.quantity = SRSRAN_CSI_REPORT_QUANTITY_CRI_RI_I1; + break; + case csi_report_cfg_s::report_quant_c_::types_opts::cri_ri_i1_cqi: + srsran_csi_hl_report_cfg.quantity = SRSRAN_CSI_REPORT_QUANTITY_CRI_RI_I1_CQI; + break; + case csi_report_cfg_s::report_quant_c_::types_opts::cri_ri_cqi: + srsran_csi_hl_report_cfg.quantity = SRSRAN_CSI_REPORT_QUANTITY_CRI_RI_CQI; + break; + case csi_report_cfg_s::report_quant_c_::types_opts::cri_rsrp: + srsran_csi_hl_report_cfg.quantity = SRSRAN_CSI_REPORT_QUANTITY_CRI_RSRP; + break; + case csi_report_cfg_s::report_quant_c_::types_opts::ssb_idx_rsrp: + srsran_csi_hl_report_cfg.quantity = SRSRAN_CSI_REPORT_QUANTITY_SSB_INDEX_RSRP; + break; + case csi_report_cfg_s::report_quant_c_::types_opts::cri_ri_li_pmi_cqi: + srsran_csi_hl_report_cfg.quantity = SRSRAN_CSI_REPORT_QUANTITY_CRI_RI_LI_PMI_CQI; + break; + default: + asn1::log_warning("Invalid option for report_quant %s", csi_report_cfg.report_quant.type().to_string()); + return false; + } + + if (not csi_report_cfg.report_freq_cfg_present) { + asn1::log_warning("report_freq_cfg_present option not present"); + return false; + } + + if (not csi_report_cfg.report_freq_cfg.cqi_format_ind_present) { + asn1::log_warning("cqi_format_ind option not present"); + return false; + } + + switch (csi_report_cfg.report_freq_cfg.cqi_format_ind) { + case csi_report_cfg_s::report_freq_cfg_s_::cqi_format_ind_opts::wideband_cqi: + srsran_csi_hl_report_cfg.freq_cfg = SRSRAN_CSI_REPORT_FREQ_WIDEBAND; + break; + case csi_report_cfg_s::report_freq_cfg_s_::cqi_format_ind_opts::subband_cqi: + srsran_csi_hl_report_cfg.freq_cfg = SRSRAN_CSI_REPORT_FREQ_SUBBAND; + break; + default: + asn1::log_warning("Invalid option for cqi_format_ind %s", + csi_report_cfg.report_freq_cfg.cqi_format_ind.to_string()); + return false; + + break; + } + + if (not csi_report_cfg.cqi_table_present) { + asn1::log_warning("cqi_table_present not present"); + return false; + } + + switch (csi_report_cfg.cqi_table) { + case csi_report_cfg_s::cqi_table_opts::table1: + srsran_csi_hl_report_cfg.cqi_table = SRSRAN_CSI_CQI_TABLE_1; + break; + case csi_report_cfg_s::cqi_table_opts::table2: + srsran_csi_hl_report_cfg.cqi_table = SRSRAN_CSI_CQI_TABLE_2; + break; + case csi_report_cfg_s::cqi_table_opts::table3: + srsran_csi_hl_report_cfg.cqi_table = SRSRAN_CSI_CQI_TABLE_3; + break; + default: + asn1::log_warning("Invalid option for cqi_table %s", csi_report_cfg.cqi_table.to_string()); + return false; + } + *in_srsran_csi_hl_report_cfg = srsran_csi_hl_report_cfg; + return true; +} + +bool make_phy_coreset_cfg(const ctrl_res_set_s& ctrl_res_set, srsran_coreset_t* in_srsran_coreset) +{ + srsran_coreset_t srsran_coreset = {}; + srsran_coreset.coreset_id = ctrl_res_set.ctrl_res_set_id; + + switch (ctrl_res_set.precoder_granularity) { + case ctrl_res_set_s::precoder_granularity_opts::same_as_reg_bundle: + srsran_coreset.precoder_granularity = srsran_coreset_precoder_granularity_reg_bundle; + break; + case ctrl_res_set_s::precoder_granularity_opts::all_contiguous_rbs: + srsran_coreset.precoder_granularity = srsran_coreset_precoder_granularity_contiguous; + default: + asn1::log_warning("Invalid option for precoder_granularity %s", ctrl_res_set.precoder_granularity.to_string()); + return false; + }; + srsran_coreset.duration = ctrl_res_set.dur; + for (uint32_t i = 0; i < SRSRAN_CORESET_FREQ_DOMAIN_RES_SIZE; i++) { + srsran_coreset.freq_resources[i] = ctrl_res_set.freq_domain_res.get(SRSRAN_CORESET_FREQ_DOMAIN_RES_SIZE - 1 - i); + } + *in_srsran_coreset = srsran_coreset; + return true; +} + +bool make_phy_common_time_ra(const pdsch_time_domain_res_alloc_s& pdsch_time_domain_res_alloc, + srsran_sch_time_ra_t* in_srsran_sch_time_ra) +{ + srsran_sch_time_ra_t srsran_sch_time_ra = {}; + srsran_sch_time_ra.sliv = pdsch_time_domain_res_alloc.start_symbol_and_len; + switch (pdsch_time_domain_res_alloc.map_type) { + case pdsch_time_domain_res_alloc_s::map_type_opts::type_a: + srsran_sch_time_ra.mapping_type = srsran_sch_mapping_type_A; + break; + case pdsch_time_domain_res_alloc_s::map_type_opts::type_b: + srsran_sch_time_ra.mapping_type = srsran_sch_mapping_type_B; + break; + default: + asn1::log_warning("Invalid option for map_type: %s", pdsch_time_domain_res_alloc.map_type.to_string()); + return false; + } + + if (pdsch_time_domain_res_alloc.k0_present) { + srsran_sch_time_ra.k = pdsch_time_domain_res_alloc.k0; + } else { + srsran_sch_time_ra.k = 0; + } + *in_srsran_sch_time_ra = srsran_sch_time_ra; + return true; +} + +bool make_phy_common_time_ra(const pusch_time_domain_res_alloc_s& pusch_time_domain_res_alloc, + srsran_sch_time_ra_t* in_srsran_sch_time_ra) +{ + srsran_sch_time_ra_t srsran_sch_time_ra = {}; + srsran_sch_time_ra.sliv = pusch_time_domain_res_alloc.start_symbol_and_len; + switch (pusch_time_domain_res_alloc.map_type) { + case pusch_time_domain_res_alloc_s::map_type_opts::type_a: + srsran_sch_time_ra.mapping_type = srsran_sch_mapping_type_A; + break; + case pusch_time_domain_res_alloc_s::map_type_opts::type_b: + srsran_sch_time_ra.mapping_type = srsran_sch_mapping_type_B; + break; + default: + asn1::log_warning("Invalid option for map_type: %s", pusch_time_domain_res_alloc.map_type.to_string()); + return false; + } + + if (pusch_time_domain_res_alloc.k2_present) { + srsran_sch_time_ra.k = pusch_time_domain_res_alloc.k2; + } else { + srsran_sch_time_ra.k = 0; + } + *in_srsran_sch_time_ra = srsran_sch_time_ra; + return true; +} + +bool make_phy_max_code_rate(const pucch_format_cfg_s& pucch_format_cfg, uint32_t* in_max_code_rate) +{ + if (not pucch_format_cfg.max_code_rate_present) { + asn1::log_warning("max_code_rate option not present"); + return false; + } + *in_max_code_rate = pucch_format_cfg.max_code_rate.value; + return true; +} + +bool make_phy_res_config(const pucch_res_s& pucch_res, + uint32_t format_2_max_code_rate, + srsran_pucch_nr_resource_t* in_srsran_pucch_nr_resource) +{ + srsran_pucch_nr_resource_t srsran_pucch_nr_resource = {}; + srsran_pucch_nr_resource.starting_prb = pucch_res.start_prb; + switch (pucch_res.format.type()) { + case pucch_res_s::format_c_::types_opts::format0: + srsran_pucch_nr_resource.format = SRSRAN_PUCCH_NR_FORMAT_0; + break; + case pucch_res_s::format_c_::types_opts::format1: + srsran_pucch_nr_resource.format = SRSRAN_PUCCH_NR_FORMAT_1; + srsran_pucch_nr_resource.initial_cyclic_shift = pucch_res.format.format1().init_cyclic_shift; + srsran_pucch_nr_resource.nof_symbols = pucch_res.format.format1().nrof_symbols; + srsran_pucch_nr_resource.start_symbol_idx = pucch_res.format.format1().start_symbol_idx; + srsran_pucch_nr_resource.time_domain_occ = pucch_res.format.format1().time_domain_occ; + break; + case pucch_res_s::format_c_::types_opts::format2: + srsran_pucch_nr_resource.format = SRSRAN_PUCCH_NR_FORMAT_2; + srsran_pucch_nr_resource.nof_symbols = pucch_res.format.format2().nrof_symbols; + srsran_pucch_nr_resource.start_symbol_idx = pucch_res.format.format2().start_symbol_idx; + srsran_pucch_nr_resource.nof_prb = pucch_res.format.format2().nrof_prbs; + break; + case pucch_res_s::format_c_::types_opts::format3: + srsran_pucch_nr_resource.format = SRSRAN_PUCCH_NR_FORMAT_3; + asn1::log_warning("SRSRAN_PUCCH_NR_FORMAT_3 conversion not supported"); + return false; + case pucch_res_s::format_c_::types_opts::format4: + srsran_pucch_nr_resource.format = SRSRAN_PUCCH_NR_FORMAT_4; + asn1::log_warning("SRSRAN_PUCCH_NR_FORMAT_4 conversion not supported"); + return false; + default: + srsran_pucch_nr_resource.format = SRSRAN_PUCCH_NR_FORMAT_ERROR; + return false; + } + srsran_pucch_nr_resource.max_code_rate = format_2_max_code_rate; + *in_srsran_pucch_nr_resource = srsran_pucch_nr_resource; + return true; +} + +bool make_phy_sr_resource(const sched_request_res_cfg_s& sched_request_res_cfg, + srsran_pucch_nr_sr_resource_t* in_srsran_pucch_nr_sr_resource) +{ + srsran_pucch_nr_sr_resource_t srsran_pucch_nr_sr_resource = {}; + srsran_pucch_nr_sr_resource.sr_id = sched_request_res_cfg.sched_request_id; + if (sched_request_res_cfg.periodicity_and_offset_present && sched_request_res_cfg.res_present) { + srsran_pucch_nr_sr_resource.configured = true; + switch (sched_request_res_cfg.periodicity_and_offset.type()) { + case sched_request_res_cfg_s::periodicity_and_offset_c_::types_opts::sl2: + srsran_pucch_nr_sr_resource.period = 2; + srsran_pucch_nr_sr_resource.offset = sched_request_res_cfg.periodicity_and_offset.sl2(); + break; + case sched_request_res_cfg_s::periodicity_and_offset_c_::types_opts::sl4: + srsran_pucch_nr_sr_resource.period = 4; + srsran_pucch_nr_sr_resource.offset = sched_request_res_cfg.periodicity_and_offset.sl4(); + break; + case sched_request_res_cfg_s::periodicity_and_offset_c_::types_opts::sl5: + srsran_pucch_nr_sr_resource.period = 5; + srsran_pucch_nr_sr_resource.offset = sched_request_res_cfg.periodicity_and_offset.sl5(); + break; + case sched_request_res_cfg_s::periodicity_and_offset_c_::types_opts::sl8: + srsran_pucch_nr_sr_resource.period = 8; + srsran_pucch_nr_sr_resource.offset = sched_request_res_cfg.periodicity_and_offset.sl8(); + break; + case sched_request_res_cfg_s::periodicity_and_offset_c_::types_opts::sl10: + srsran_pucch_nr_sr_resource.period = 10; + srsran_pucch_nr_sr_resource.offset = sched_request_res_cfg.periodicity_and_offset.sl10(); + break; + case sched_request_res_cfg_s::periodicity_and_offset_c_::types_opts::sl16: + srsran_pucch_nr_sr_resource.period = 16; + srsran_pucch_nr_sr_resource.offset = sched_request_res_cfg.periodicity_and_offset.sl16(); + break; + case sched_request_res_cfg_s::periodicity_and_offset_c_::types_opts::sl20: + srsran_pucch_nr_sr_resource.period = 20; + srsran_pucch_nr_sr_resource.offset = sched_request_res_cfg.periodicity_and_offset.sl20(); + break; + case sched_request_res_cfg_s::periodicity_and_offset_c_::types_opts::sl40: + srsran_pucch_nr_sr_resource.period = 40; + srsran_pucch_nr_sr_resource.offset = sched_request_res_cfg.periodicity_and_offset.sl40(); + break; + case sched_request_res_cfg_s::periodicity_and_offset_c_::types_opts::sl80: + srsran_pucch_nr_sr_resource.period = 80; + srsran_pucch_nr_sr_resource.offset = sched_request_res_cfg.periodicity_and_offset.sl80(); + break; + case sched_request_res_cfg_s::periodicity_and_offset_c_::types_opts::sl160: + srsran_pucch_nr_sr_resource.period = 160; + srsran_pucch_nr_sr_resource.offset = sched_request_res_cfg.periodicity_and_offset.sl160(); + break; + case sched_request_res_cfg_s::periodicity_and_offset_c_::types_opts::sl320: + srsran_pucch_nr_sr_resource.period = 320; + srsran_pucch_nr_sr_resource.offset = sched_request_res_cfg.periodicity_and_offset.sl320(); + break; + case sched_request_res_cfg_s::periodicity_and_offset_c_::types_opts::sl640: + srsran_pucch_nr_sr_resource.period = 640; + srsran_pucch_nr_sr_resource.offset = sched_request_res_cfg.periodicity_and_offset.sl640(); + break; + case sched_request_res_cfg_s::periodicity_and_offset_c_::types_opts::sym2: + case sched_request_res_cfg_s::periodicity_and_offset_c_::types_opts::sym6or7: + case sched_request_res_cfg_s::periodicity_and_offset_c_::types_opts::sl1: + default: + srsran_pucch_nr_sr_resource.configured = false; + asn1::log_warning("Invalid option for periodicity_and_offset %s", + sched_request_res_cfg.periodicity_and_offset.type().to_string()); + return false; + } + + } else { + srsran_pucch_nr_sr_resource.configured = false; + } + *in_srsran_pucch_nr_sr_resource = srsran_pucch_nr_sr_resource; + return true; +} + +bool make_phy_dmrs_additional_pos(const dmrs_ul_cfg_s& dmrs_ul_cfg, + srsran_dmrs_sch_add_pos_t* in_srsran_dmrs_sch_add_pos) +{ + srsran_dmrs_sch_add_pos_t srsran_dmrs_sch_add_pos = {}; + if (not dmrs_ul_cfg.dmrs_add_position_present) { + asn1::log_warning("dmrs_add_position option not present"); + } + + switch (dmrs_ul_cfg.dmrs_add_position) { + case dmrs_ul_cfg_s::dmrs_add_position_opts::pos0: + srsran_dmrs_sch_add_pos = srsran_dmrs_sch_add_pos_0; + break; + case dmrs_ul_cfg_s::dmrs_add_position_opts::pos1: + srsran_dmrs_sch_add_pos = srsran_dmrs_sch_add_pos_1; + break; + case dmrs_ul_cfg_s::dmrs_add_position_opts::pos3: + srsran_dmrs_sch_add_pos = srsran_dmrs_sch_add_pos_3; + break; + default: + asn1::log_warning("Invalid option for dmrs_add_position %s", dmrs_ul_cfg.dmrs_add_position.to_string()); + return false; + } + *in_srsran_dmrs_sch_add_pos = srsran_dmrs_sch_add_pos; + return true; +} + +bool make_phy_beta_offsets(const beta_offsets_s& beta_offsets, srsran_beta_offsets_t* in_srsran_beta_offsets) +{ + srsran_beta_offsets_t srsran_beta_offsets = {}; + + srsran_beta_offsets.ack_index1 = beta_offsets.beta_offset_ack_idx1_present ? beta_offsets.beta_offset_ack_idx1 : 11; + srsran_beta_offsets.ack_index2 = beta_offsets.beta_offset_ack_idx2_present ? beta_offsets.beta_offset_ack_idx2 : 11; + srsran_beta_offsets.ack_index3 = beta_offsets.beta_offset_ack_idx3_present ? beta_offsets.beta_offset_ack_idx3 : 11; + srsran_beta_offsets.csi1_index1 = + beta_offsets.beta_offset_csi_part1_idx1_present ? beta_offsets.beta_offset_csi_part1_idx1 : 13; + srsran_beta_offsets.csi1_index2 = + beta_offsets.beta_offset_csi_part1_idx2_present ? beta_offsets.beta_offset_csi_part1_idx2 : 13; + srsran_beta_offsets.csi2_index1 = + beta_offsets.beta_offset_csi_part2_idx1_present ? beta_offsets.beta_offset_csi_part2_idx1 : 13; + srsran_beta_offsets.csi2_index2 = + beta_offsets.beta_offset_csi_part2_idx2_present ? beta_offsets.beta_offset_csi_part2_idx2 : 13; + *in_srsran_beta_offsets = srsran_beta_offsets; + return true; +} + +bool make_phy_pusch_scaling(const uci_on_pusch_s& uci_on_pusch, float* in_scaling) +{ + float pusch_scaling = 0; + switch (uci_on_pusch.scaling) { + case uci_on_pusch_s::scaling_opts::f0p5: + pusch_scaling = 0.5; + break; + case uci_on_pusch_s::scaling_opts::f0p65: + pusch_scaling = 0.65; + break; + case uci_on_pusch_s::scaling_opts::f0p8: + pusch_scaling = 0.8; + break; + case uci_on_pusch_s::scaling_opts::f1: + pusch_scaling = 1.0; + break; + default: + asn1::log_warning("Invalid option for scaling %s", uci_on_pusch.scaling.to_string()); + return false; + } + *in_scaling = pusch_scaling; + return true; +} + } // namespace srsran namespace srsenb { @@ -213,7 +728,7 @@ int set_sched_cell_cfg_sib1(srsenb::sched_interface::cell_cfg_t* sched_cfg, cons // setup PRACH if (not sib1.si_sched_info.si_request_cfg.rach_occasions_si_present) { - asn1::log_error("Expected RA Resp Win present\n"); + asn1::log_warning("rach_occasions_si option not present"); return SRSRAN_ERROR; } sched_cfg->prach_rar_window = sib1.si_sched_info.si_request_cfg.rach_occasions_si.rach_cfg_si.ra_resp_win.to_number(); diff --git a/lib/test/asn1/rrc_nr_utils_test.cc b/lib/test/asn1/rrc_nr_utils_test.cc index 59e41ce24..ea71a2f14 100644 --- a/lib/test/asn1/rrc_nr_utils_test.cc +++ b/lib/test/asn1/rrc_nr_utils_test.cc @@ -19,6 +19,7 @@ #include "srsran/common/test_common.h" using namespace srsran; +using namespace asn1::rrc_nr; int test_rlc_config() { @@ -66,6 +67,485 @@ int test_mac_rach_common_config() return SRSRAN_SUCCESS; } +// Phy tests + +int make_phy_tdd_cfg_test() +{ + // tdd-UL-DL-ConfigurationCommon + // referenceSubcarrierSpacing: kHz15 (0) + // pattern1 + // dl-UL-TransmissionPeriodicity: ms10 (7) + // nrofDownlinkSlots: 7 + // nrofDownlinkSymbols: 6 + // nrofUplinkSlots: 2 + // nrofUplinkSymbols: 4 + tdd_ul_dl_cfg_common_s tdd_ul_dl_cfg_common = {}; + + tdd_ul_dl_cfg_common.ref_subcarrier_spacing = subcarrier_spacing_opts::khz15; + tdd_ul_dl_cfg_common.pattern1.dl_ul_tx_periodicity = tdd_ul_dl_pattern_s::dl_ul_tx_periodicity_opts::ms10; + tdd_ul_dl_cfg_common.pattern1.nrof_dl_slots = 7; + tdd_ul_dl_cfg_common.pattern1.nrof_dl_symbols = 6; + tdd_ul_dl_cfg_common.pattern1.nrof_ul_slots = 2; + tdd_ul_dl_cfg_common.pattern1.nrof_ul_symbols = 4; + + srsran_tdd_config_nr_t srsran_tdd_config_nr; + TESTASSERT(make_phy_tdd_cfg(tdd_ul_dl_cfg_common, &srsran_tdd_config_nr) == true); + + TESTASSERT(srsran_tdd_config_nr.pattern1.period_ms == 10); + TESTASSERT(srsran_tdd_config_nr.pattern1.nof_dl_slots == 7); + TESTASSERT(srsran_tdd_config_nr.pattern1.nof_dl_symbols == 6); + TESTASSERT(srsran_tdd_config_nr.pattern1.nof_ul_slots == 2); + TESTASSERT(srsran_tdd_config_nr.pattern1.nof_ul_symbols == 4); + TESTASSERT(srsran_tdd_config_nr.pattern2.period_ms == 0); + return SRSRAN_SUCCESS; +} + +int make_phy_harq_ack_cfg_test() +{ + // physicalCellGroupConfig + // pdsch-HARQ-ACK-Codebook: dynamic (1) + phys_cell_group_cfg_s phys_cell_group_cfg = {}; + phys_cell_group_cfg.pdsch_harq_ack_codebook = phys_cell_group_cfg_s::pdsch_harq_ack_codebook_opts::dynamic_value; + + srsran_ue_dl_nr_harq_ack_cfg_t srsran_ue_dl_nr_harq_ack_cfg; + TESTASSERT(make_phy_harq_ack_cfg(phys_cell_group_cfg, &srsran_ue_dl_nr_harq_ack_cfg) == true); + + TESTASSERT(srsran_ue_dl_nr_harq_ack_cfg.pdsch_harq_ack_codebook == srsran_pdsch_harq_ack_codebook_dynamic); + return SRSRAN_SUCCESS; +} + +int make_phy_coreset_cfg_test() +{ + ctrl_res_set_s ctrl_res_set = {}; + ctrl_res_set.ctrl_res_set_id = 1; + ctrl_res_set.precoder_granularity = ctrl_res_set_s::precoder_granularity_opts::same_as_reg_bundle; + ctrl_res_set.dur = 1; + ctrl_res_set.cce_reg_map_type.set_non_interleaved(); + ctrl_res_set.freq_domain_res.from_string("111111110000000000000000000000000000000000000"); + + srsran_coreset_t srsran_coreset; + TESTASSERT(make_phy_coreset_cfg(ctrl_res_set, &srsran_coreset) == true); + + TESTASSERT(srsran_coreset.coreset_id == 1); + TESTASSERT(srsran_coreset.precoder_granularity == srsran_coreset_precoder_granularity_reg_bundle); + TESTASSERT(srsran_coreset.duration == 1); + TESTASSERT(srsran_coreset.mapping_type == srsran_coreset_mapping_type_non_interleaved); + + for (uint32_t i = 0; i < SRSRAN_CORESET_FREQ_DOMAIN_RES_SIZE; i++) { + TESTASSERT(srsran_coreset.freq_resources[i] == (i < 8)); + } + + return SRSRAN_SUCCESS; +} + +int make_phy_search_space_cfg_test() +{ + // SearchSpace + // searchSpaceId: 1 + // controlResourceSetId: 1 + // monitoringSlotPeriodicityAndOffset: sl1 (0) + // sl1: NULL + // monitoringSymbolsWithinSlot: 8000 [bit length 14, 2 LSB pad bits, 1000 0000 0000 00.. decimal value 8192] + // nrofCandidates + // aggregationLevel1: n0 (0) + // aggregationLevel2: n0 (0) + // aggregationLevel4: n1 (1) + // aggregationLevel8: n0 (0) + // aggregationLevel16: n0 (0) + // searchSpaceType: common (0) + // common + // dci-Format0-0-AndFormat1-0 + search_space_s search_space = {}; + search_space.search_space_id = 1; + search_space.ctrl_res_set_id_present = true; + search_space.ctrl_res_set_id = 1; + search_space.monitoring_slot_periodicity_and_offset_present = true; + search_space.monitoring_slot_periodicity_and_offset.set_sl1(); + search_space.monitoring_symbols_within_slot_present = true; + search_space.monitoring_symbols_within_slot.from_string("10000000000000"); + search_space.nrof_candidates_present = true; + search_space.nrof_candidates.aggregation_level1 = + search_space_s::nrof_candidates_s_::aggregation_level1_opts::options::n0; + search_space.nrof_candidates.aggregation_level2 = + search_space_s::nrof_candidates_s_::aggregation_level2_opts::options::n0; + search_space.nrof_candidates.aggregation_level4 = + search_space_s::nrof_candidates_s_::aggregation_level4_opts::options::n1; + search_space.nrof_candidates.aggregation_level8 = + search_space_s::nrof_candidates_s_::aggregation_level8_opts::options::n0; + search_space.nrof_candidates.aggregation_level16 = + search_space_s::nrof_candidates_s_::aggregation_level16_opts::options::n0; + search_space.search_space_type_present = true; + search_space.search_space_type.set_common(); + search_space.search_space_type.common().dci_format0_minus0_and_format1_minus0_present = true; + + srsran_search_space_t srsran_search_space; + TESTASSERT(make_phy_search_space_cfg(search_space, &srsran_search_space) == true); + + TESTASSERT(srsran_search_space.id == 1); + TESTASSERT(srsran_search_space.coreset_id == 1); + TESTASSERT(srsran_search_space.nof_candidates[0] == 0); + TESTASSERT(srsran_search_space.nof_candidates[1] == 0); + TESTASSERT(srsran_search_space.nof_candidates[2] == 1); + TESTASSERT(srsran_search_space.nof_candidates[3] == 0); + TESTASSERT(srsran_search_space.nof_candidates[4] == 0); + TESTASSERT(srsran_search_space.type == srsran_search_space_type_common_3); + + // searchSpacesToAddModList: 1 item + // Item 0 + // SearchSpace + // searchSpaceId: 2 + // controlResourceSetId: 2 + // monitoringSlotPeriodicityAndOffset: sl1 (0) + // sl1: NULL + // monitoringSymbolsWithinSlot: 8000 [bit length 14, 2 LSB pad bits, 1000 0000 0000 + // 00.. decimal value 8192] nrofCandidates + // aggregationLevel1: n0 (0) + // aggregationLevel2: n2 (2) + // aggregationLevel4: n1 (1) + // aggregationLevel8: n0 (0) + // aggregationLevel16: n0 (0) + // searchSpaceType: ue-Specific (1) + // ue-Specific + // dci-Formats: formats0-0-And-1-0 (0) + + search_space_s search_space_2 = {}; + search_space_2.search_space_id = 2; + search_space_2.ctrl_res_set_id_present = true; + search_space_2.ctrl_res_set_id = 2; + search_space_2.monitoring_slot_periodicity_and_offset_present = true; + search_space_2.monitoring_slot_periodicity_and_offset.set_sl1(); + search_space_2.monitoring_symbols_within_slot_present = true; + search_space_2.monitoring_symbols_within_slot.from_string("10000000000000"); + search_space_2.nrof_candidates_present = true; + search_space_2.nrof_candidates.aggregation_level1 = + search_space_s::nrof_candidates_s_::aggregation_level1_opts::options::n0; + search_space_2.nrof_candidates.aggregation_level2 = + search_space_s::nrof_candidates_s_::aggregation_level2_opts::options::n2; + search_space_2.nrof_candidates.aggregation_level4 = + search_space_s::nrof_candidates_s_::aggregation_level4_opts::options::n1; + search_space_2.nrof_candidates.aggregation_level8 = + search_space_s::nrof_candidates_s_::aggregation_level8_opts::options::n0; + search_space_2.nrof_candidates.aggregation_level16 = + search_space_s::nrof_candidates_s_::aggregation_level16_opts::options::n0; + search_space_2.search_space_type_present = true; + search_space_2.search_space_type.set_ue_specific(); + search_space_2.search_space_type.ue_specific().dci_formats = + search_space_s::search_space_type_c_::ue_specific_s_::dci_formats_opts::formats0_minus0_and_minus1_minus0; + + srsran_search_space_t srsran_search_space_2; + TESTASSERT(make_phy_search_space_cfg(search_space_2, &srsran_search_space_2) == true); + + TESTASSERT(srsran_search_space_2.id == 2); + TESTASSERT(srsran_search_space_2.coreset_id == 2); + TESTASSERT(srsran_search_space_2.nof_candidates[0] == 0); + TESTASSERT(srsran_search_space_2.nof_candidates[1] == 2); + TESTASSERT(srsran_search_space_2.nof_candidates[2] == 1); + TESTASSERT(srsran_search_space_2.nof_candidates[3] == 0); + TESTASSERT(srsran_search_space_2.nof_candidates[4] == 0); + TESTASSERT(srsran_search_space_2.type == srsran_search_space_type_ue); + + return SRSRAN_SUCCESS; +} + +int make_phy_csi_report_test() +{ + // csi-ReportConfigToAddModList: 1 item + // Item 0 + // CSI-ReportConfig + // reportConfigId: 0 + // resourcesForChannelMeasurement: 0 + // csi-IM-ResourcesForInterference: 1 + // reportConfigType: periodic (0) + // periodic + // reportSlotConfig: slots80 (7) + // slots80: 9 + // pucch-CSI-ResourceList: 1 item + // Item 0 + // PUCCH-CSI-Resource + // uplinkBandwidthPartId: 0 + // pucch-Resource: 17 + // reportQuantity: cri-RI-PMI-CQI (1) + // cri-RI-PMI-CQI: NULL + // reportFreqConfiguration + // cqi-FormatIndicator: widebandCQI (0) + // timeRestrictionForChannelMeasurements: notConfigured (1) + // timeRestrictionForInterferenceMeasurements: notConfigured (1) + // groupBasedBeamReporting: disabled (1) + // disabled + // cqi-Table: table2 (1) + // subbandSize: value1 (0) + csi_report_cfg_s csi_report_cfg = {}; + csi_report_cfg.report_cfg_id = 0; + csi_report_cfg.res_for_ch_meas = 0; + csi_report_cfg.csi_im_res_for_interference_present = true; + csi_report_cfg.csi_im_res_for_interference = 1; + csi_report_cfg.report_cfg_type.set_periodic(); + csi_report_cfg.report_cfg_type.periodic().report_slot_cfg.set_slots80(); + csi_report_cfg.report_cfg_type.periodic().report_slot_cfg.slots80() = 9; + pucch_csi_res_s pucch_csi_res; + pucch_csi_res.pucch_res = 17; + pucch_csi_res.ul_bw_part_id = 0; + csi_report_cfg.report_cfg_type.periodic().pucch_csi_res_list.push_back(pucch_csi_res); + csi_report_cfg.report_quant.set_cri_ri_pmi_cqi(); + csi_report_cfg.report_freq_cfg_present = true; + csi_report_cfg.report_freq_cfg.cqi_format_ind_present = true; + csi_report_cfg.report_freq_cfg.cqi_format_ind = + csi_report_cfg_s::report_freq_cfg_s_::cqi_format_ind_opts::wideband_cqi; + csi_report_cfg.cqi_table_present = true; + csi_report_cfg.cqi_table = csi_report_cfg_s::cqi_table_opts::table2; + csi_report_cfg.subband_size = csi_report_cfg_s::subband_size_opts::value1; + + srsran_csi_hl_report_cfg_t srsran_csi_hl_report_cfg; + TESTASSERT(make_phy_csi_report(csi_report_cfg, &srsran_csi_hl_report_cfg) == true); + + TESTASSERT(srsran_csi_hl_report_cfg.type == SRSRAN_CSI_REPORT_TYPE_PERIODIC); + TESTASSERT(srsran_csi_hl_report_cfg.channel_meas_id == 0); + TESTASSERT(srsran_csi_hl_report_cfg.interf_meas_present == true); + TESTASSERT(srsran_csi_hl_report_cfg.interf_meas_id == 1); + TESTASSERT(srsran_csi_hl_report_cfg.periodic.period == 80); + TESTASSERT(srsran_csi_hl_report_cfg.periodic.offset == 9); + TESTASSERT(srsran_csi_hl_report_cfg.quantity == SRSRAN_CSI_REPORT_QUANTITY_CRI_RI_PMI_CQI); + TESTASSERT(srsran_csi_hl_report_cfg.freq_cfg == SRSRAN_CSI_REPORT_FREQ_WIDEBAND); + TESTASSERT(srsran_csi_hl_report_cfg.cqi_table == SRSRAN_CSI_CQI_TABLE_2); + return SRSRAN_SUCCESS; +} + +int make_phy_common_time_ra_test() +{ + // Test 1 & 2 + // pdsch-ConfigCommon: setup (1) + // setup + // pdsch-TimeDomainAllocationList: 2 items + // Item 0 + // PDSCH-TimeDomainResourceAllocation + // mappingType: typeA (0) + // startSymbolAndLength: 40 + // Item 1 + // PDSCH-TimeDomainResourceAllocation + // mappingType: typeA (0) + // startSymbolAndLength: 57 + srsran_sch_time_ra_t srsran_sch_time_ra = {}; + + pdsch_time_domain_res_alloc_s pdsch_time_domain_res_alloc = {}; + pdsch_time_domain_res_alloc.start_symbol_and_len = 40; + pdsch_time_domain_res_alloc.map_type = pdsch_time_domain_res_alloc_s::map_type_opts::type_a; + + TESTASSERT(make_phy_common_time_ra(pdsch_time_domain_res_alloc, &srsran_sch_time_ra) == true); + + TESTASSERT(srsran_sch_time_ra.mapping_type == srsran_sch_mapping_type_A); + TESTASSERT(srsran_sch_time_ra.sliv == 40); + TESTASSERT(srsran_sch_time_ra.k == 0); + + pdsch_time_domain_res_alloc.start_symbol_and_len = 57; + pdsch_time_domain_res_alloc.map_type = pdsch_time_domain_res_alloc_s::map_type_opts::type_a; + + TESTASSERT(make_phy_common_time_ra(pdsch_time_domain_res_alloc, &srsran_sch_time_ra) == true); + TESTASSERT(srsran_sch_time_ra.mapping_type == srsran_sch_mapping_type_A); + TESTASSERT(srsran_sch_time_ra.sliv == 57); + TESTASSERT(srsran_sch_time_ra.k == 0); + + // Test 3 & 4 + + // pusch-ConfigCommon: setup (1) + // setup + // pusch-TimeDomainAllocationList: 2 items + // Item 0 + // PUSCH-TimeDomainResourceAllocation + // k2: 4 + // mappingType: typeA (0) + // startSymbolAndLength: 27 + // Item 1 + // PUSCH-TimeDomainResourceAllocation + // k2: 5 + // mappingType: typeA (0) + // startSymbolAndLength: 27 + // p0-NominalWithGrant: -90dBm + + srsran_sch_time_ra = {}; + pusch_time_domain_res_alloc_s pusch_time_domain_res_alloc = {}; + pusch_time_domain_res_alloc.k2_present = true; + pusch_time_domain_res_alloc.k2 = 4; + pusch_time_domain_res_alloc.start_symbol_and_len = 27; + pusch_time_domain_res_alloc.map_type = pusch_time_domain_res_alloc_s::map_type_opts::type_a; + + TESTASSERT(make_phy_common_time_ra(pusch_time_domain_res_alloc, &srsran_sch_time_ra) == true); + + TESTASSERT(srsran_sch_time_ra.mapping_type == srsran_sch_mapping_type_A); + TESTASSERT(srsran_sch_time_ra.sliv == 27); + TESTASSERT(srsran_sch_time_ra.k == 4); + + pusch_time_domain_res_alloc = {}; + pusch_time_domain_res_alloc.k2_present = true; + pusch_time_domain_res_alloc.k2 = 5; + pusch_time_domain_res_alloc.start_symbol_and_len = 27; + pusch_time_domain_res_alloc.map_type = pusch_time_domain_res_alloc_s::map_type_opts::type_a; + + TESTASSERT(make_phy_common_time_ra(pusch_time_domain_res_alloc, &srsran_sch_time_ra) == true); + + TESTASSERT(srsran_sch_time_ra.mapping_type == srsran_sch_mapping_type_A); + TESTASSERT(srsran_sch_time_ra.sliv == 27); + TESTASSERT(srsran_sch_time_ra.k == 5); + + return SRSRAN_SUCCESS; +} + +int make_phy_max_code_rate_test() +{ + // format1: setup (1) + // setup + // format2: setup (1) + // setup + // maxCodeRate: zeroDot25 (2) + pucch_format_cfg_s pucch_format_cfg = {}; + pucch_format_cfg.max_code_rate_present = true; + pucch_format_cfg.max_code_rate = pucch_max_code_rate_opts::options::zero_dot25; + uint32_t max_code_rate; + TESTASSERT(make_phy_max_code_rate(pucch_format_cfg, &max_code_rate) == true); + TESTASSERT(max_code_rate == 2); + return SRSRAN_SUCCESS; +} + +int make_phy_res_config_test() +{ + uint32_t format_2_max_code_rate = 2; + pucch_res_s pucch_res = {}; + + // Item 0 + // PUCCH-Resource + // pucch-ResourceId: 0 + // startingPRB: 0 + // format: format1 (1) + // format1 + // initialCyclicShift: 0 + // nrofSymbols: 14 + // startingSymbolIndex: 0 + // timeDomainOCC: 0 + + pucch_res.pucch_res_id = 0; + pucch_res.start_prb = 0; + pucch_res.format.set_format1(); + pucch_res.format.format1().init_cyclic_shift = 0; + pucch_res.format.format1().nrof_symbols = 14; + pucch_res.format.format1().start_symbol_idx = 0; + pucch_res.format.format1().time_domain_occ = 0; + + srsran_pucch_nr_resource_t srsran_pucch_nr_resource; + + TESTASSERT(make_phy_res_config(pucch_res, format_2_max_code_rate, &srsran_pucch_nr_resource) == true); + + TESTASSERT(srsran_pucch_nr_resource.format == SRSRAN_PUCCH_NR_FORMAT_1); + TESTASSERT(srsran_pucch_nr_resource.starting_prb == 0); + TESTASSERT(srsran_pucch_nr_resource.initial_cyclic_shift == 0); + TESTASSERT(srsran_pucch_nr_resource.nof_symbols == 14); + TESTASSERT(srsran_pucch_nr_resource.start_symbol_idx == 0); + TESTASSERT(srsran_pucch_nr_resource.time_domain_occ == 0); + TESTASSERT(srsran_pucch_nr_resource.max_code_rate == 2); + + return SRSRAN_SUCCESS; +} + +int make_phy_sr_resource_test() +{ + // schedulingRequestResourceToAddModList: 1 item + // Item 0 + // SchedulingRequestResourceConfig + // schedulingRequestResourceId: 1 + // schedulingRequestID: 0 + // periodicityAndOffset: sl40 (10) + // sl40: 8 + // resource: 16 + sched_request_res_cfg_s sched_request_res_cfg; + sched_request_res_cfg.sched_request_res_id = 1; + sched_request_res_cfg.sched_request_id = 0; + sched_request_res_cfg.periodicity_and_offset_present = true; + sched_request_res_cfg.periodicity_and_offset.set_sl40(); + sched_request_res_cfg.periodicity_and_offset.sl40() = 8; + sched_request_res_cfg.res_present = true; + sched_request_res_cfg.res = 16; + + srsran_pucch_nr_sr_resource_t srsran_pucch_nr_sr_resource; + TESTASSERT(make_phy_sr_resource(sched_request_res_cfg, &srsran_pucch_nr_sr_resource) == true); + + TESTASSERT(srsran_pucch_nr_sr_resource.sr_id == 0); + TESTASSERT(srsran_pucch_nr_sr_resource.period == 40); + TESTASSERT(srsran_pucch_nr_sr_resource.offset == 8); + TESTASSERT(srsran_pucch_nr_sr_resource.configured == true); + + return SRSRAN_SUCCESS; +} + +int make_phy_dmrs_additional_pos_test() +{ + // pusch-Config: setup (1) + // setup + // dmrs-UplinkForPUSCH-MappingTypeA: setup (1) + // setup + // dmrs-AdditionalPosition: pos1 (1) + // transformPrecodingDisabled + dmrs_ul_cfg_s dmrs_ul_cfg; + dmrs_ul_cfg.dmrs_add_position_present = true; + dmrs_ul_cfg.dmrs_add_position = dmrs_ul_cfg_s::dmrs_add_position_opts::pos1; + srsran_dmrs_sch_add_pos_t srsran_dmrs_sch_add_pos; + TESTASSERT(make_phy_dmrs_additional_pos(dmrs_ul_cfg, &srsran_dmrs_sch_add_pos) == true); + + TESTASSERT(srsran_dmrs_sch_add_pos == srsran_dmrs_sch_add_pos_1); + + return SRSRAN_SUCCESS; +} + +int make_phy_beta_offsets_test() +{ + // uci-OnPUSCH: setup (1) + // setup + // betaOffsets: semiStatic (1) + // semiStatic + // betaOffsetACK-Index1: 9 + // betaOffsetACK-Index2: 9 + // betaOffsetACK-Index3: 9 + // betaOffsetCSI-Part1-Index1: 6 + // betaOffsetCSI-Part1-Index2: 6 + // betaOffsetCSI-Part2-Index1: 6 + // betaOffsetCSI-Part2-Index2: 6 + + beta_offsets_s beta_offsets; + beta_offsets.beta_offset_ack_idx1_present = true; + beta_offsets.beta_offset_ack_idx1 = 9; + beta_offsets.beta_offset_ack_idx2_present = true; + beta_offsets.beta_offset_ack_idx2 = 9; + beta_offsets.beta_offset_ack_idx3_present = true; + beta_offsets.beta_offset_ack_idx3 = 9; + beta_offsets.beta_offset_csi_part1_idx1_present = true; + beta_offsets.beta_offset_csi_part1_idx1 = 6; + beta_offsets.beta_offset_csi_part1_idx2_present = true; + beta_offsets.beta_offset_csi_part1_idx2 = 6; + beta_offsets.beta_offset_csi_part2_idx1_present = true; + beta_offsets.beta_offset_csi_part2_idx1 = 6; + beta_offsets.beta_offset_csi_part2_idx2_present = true; + beta_offsets.beta_offset_csi_part2_idx2 = 6; + + srsran_beta_offsets_t srsran_beta_offsets; + TESTASSERT(make_phy_beta_offsets(beta_offsets, &srsran_beta_offsets) == true); + + TESTASSERT(srsran_beta_offsets.ack_index1 == 9); + TESTASSERT(srsran_beta_offsets.ack_index2 == 9); + TESTASSERT(srsran_beta_offsets.ack_index3 == 9); + TESTASSERT(srsran_beta_offsets.csi1_index1 == 6); + TESTASSERT(srsran_beta_offsets.csi1_index2 == 6); + TESTASSERT(srsran_beta_offsets.csi2_index1 == 6); + TESTASSERT(srsran_beta_offsets.csi2_index2 == 6); + return SRSRAN_SUCCESS; +} + +int make_phy_pusch_scaling_test() +{ + uci_on_pusch_s uci_on_pusch; + uci_on_pusch.scaling = uci_on_pusch_s::scaling_opts::f1; + float scaling; + TESTASSERT(make_phy_pusch_scaling(uci_on_pusch, &scaling) == true); + TESTASSERT(scaling = 1.0); + return SRSRAN_SUCCESS; +} + int main() { auto& asn1_logger = srslog::fetch_basic_logger("ASN1", false); @@ -80,6 +560,18 @@ int main() TESTASSERT(test_rlc_config() == SRSRAN_SUCCESS); TESTASSERT(test_mac_rach_common_config() == SRSRAN_SUCCESS); + TESTASSERT(make_phy_tdd_cfg_test() == SRSRAN_SUCCESS); + TESTASSERT(make_phy_harq_ack_cfg_test() == SRSRAN_SUCCESS); + TESTASSERT(make_phy_search_space_cfg_test() == SRSRAN_SUCCESS); + TESTASSERT(make_phy_csi_report_test() == SRSRAN_SUCCESS); + TESTASSERT(make_phy_coreset_cfg_test() == SRSRAN_SUCCESS); + TESTASSERT(make_phy_common_time_ra_test() == SRSRAN_SUCCESS); + TESTASSERT(make_phy_max_code_rate_test() == SRSRAN_SUCCESS); + TESTASSERT(make_phy_res_config_test() == SRSRAN_SUCCESS); + TESTASSERT(make_phy_sr_resource_test() == SRSRAN_SUCCESS); + TESTASSERT(make_phy_dmrs_additional_pos_test() == SRSRAN_SUCCESS); + TESTASSERT(make_phy_beta_offsets_test() == SRSRAN_SUCCESS); + TESTASSERT(make_phy_pusch_scaling_test() == SRSRAN_SUCCESS); srslog::flush(); diff --git a/srsue/hdr/stack/rrc/rrc_nr.h b/srsue/hdr/stack/rrc/rrc_nr.h index 4f99ce10a..2e04a88b3 100644 --- a/srsue/hdr/stack/rrc/rrc_nr.h +++ b/srsue/hdr/stack/rrc/rrc_nr.h @@ -119,7 +119,7 @@ public: uint32_t sk_counter_r15, bool nr_radio_bearer_cfg1_r15_present, asn1::dyn_octstring nr_radio_bearer_cfg1_r15); - void configure_sk_counter(uint16_t sk_counter); + bool configure_sk_counter(uint16_t sk_counter); bool is_config_pending(); // STACK interface void cell_search_completed(const rrc_interface_phy_lte::cell_search_ret_t& cs_ret, const phy_cell_t& found_cell); @@ -136,6 +136,9 @@ private: bool running = false; srsran::block_queue cmd_q; + // PHY config + srsran::phy_cfg_nr_t phy_cfg = {}; + phy_interface_rrc_nr* phy = nullptr; mac_interface_rrc_nr* mac = nullptr; rlc_interface_rrc* rlc = nullptr; @@ -179,11 +182,24 @@ private: std::map drb_eps_bearer_id; // Map of drb id to eps_bearer_id + // temporary maps for building the pucch nr resources + std::map res_list; + std::map res_list_present; + bool apply_cell_group_cfg(const asn1::rrc_nr::cell_group_cfg_s& cell_group_cfg); bool apply_radio_bearer_cfg(const asn1::rrc_nr::radio_bearer_cfg_s& radio_bearer_cfg); bool apply_rlc_add_mod(const asn1::rrc_nr::rlc_bearer_cfg_s& rlc_bearer_cfg); bool apply_mac_cell_group(const asn1::rrc_nr::mac_cell_group_cfg_s& mac_cell_group_cfg); bool apply_sp_cell_cfg(const asn1::rrc_nr::sp_cell_cfg_s& sp_cell_cfg); + bool apply_phy_cell_group_cfg(const asn1::rrc_nr::phys_cell_group_cfg_s& phys_cell_group_cfg); + bool apply_dl_common_cfg(const asn1::rrc_nr::dl_cfg_common_s& dl_cfg_common); + bool apply_ul_common_cfg(const asn1::rrc_nr::ul_cfg_common_s& ul_cfg_common); + bool apply_sp_cell_init_dl_pdcch(const asn1::rrc_nr::pdcch_cfg_s& pdcch_cfg); + bool apply_sp_cell_init_dl_pdsch(const asn1::rrc_nr::pdsch_cfg_s& pdsch_cfg); + bool apply_sp_cell_ded_ul_pucch(const asn1::rrc_nr::pucch_cfg_s& pucch_cfg); + bool apply_sp_cell_ded_ul_pusch(const asn1::rrc_nr::pusch_cfg_s& pusch_cfg); + bool apply_csi_meas_cfg(const asn1::rrc_nr::csi_meas_cfg_s& csi_meas_cfg); + bool apply_res_csi_report_cfg(const asn1::rrc_nr::csi_report_cfg_s& csi_report_cfg); bool apply_drb_add_mod(const asn1::rrc_nr::drb_to_add_mod_s& drb_cfg); bool apply_security_cfg(const asn1::rrc_nr::security_cfg_s& security_cfg); diff --git a/srsue/hdr/stack/upper/usim_base.h b/srsue/hdr/stack/upper/usim_base.h index bb26040b7..cdb3019aa 100644 --- a/srsue/hdr/stack/upper/usim_base.h +++ b/srsue/hdr/stack/upper/usim_base.h @@ -93,8 +93,8 @@ public: void restore_keys_from_failed_ho(srsran::as_security_config_t* as_ctx) final; // NR RRC interface - void generate_nr_context(uint16_t sk_counter, srsran::as_security_config_t* sec_cfg) final; - void update_nr_context(srsran::as_security_config_t* sec_cfg) final; + bool generate_nr_context(uint16_t sk_counter, srsran::as_security_config_t* sec_cfg) final; + bool update_nr_context(srsran::as_security_config_t* sec_cfg) final; // Helpers std::string get_mcc_str(const uint8_t* imsi_vec); diff --git a/srsue/src/stack/rrc/rrc_nr.cc b/srsue/src/stack/rrc/rrc_nr.cc index 171f1582d..836805994 100644 --- a/srsue/src/stack/rrc/rrc_nr.cc +++ b/srsue/src/stack/rrc/rrc_nr.cc @@ -128,7 +128,7 @@ void rrc_nr::log_rrc_message(const std::string& source, (dir == Rx) ? "Rx" : "Tx", msg_type.c_str(), pdu->N_bytes); - logger.debug("Content:\n%s", json_writer.to_string().c_str()); + logger.debug("Content:%s", json_writer.to_string().c_str()); } else if (logger.info.enabled()) { logger.info("%s - %s %s (%d B)", source.c_str(), (dir == Rx) ? "Rx" : "Tx", msg_type.c_str(), pdu->N_bytes); } @@ -151,7 +151,7 @@ void rrc_nr::log_rrc_message(const std::string& source, (dir == Rx) ? "Rx" : "Tx", msg_type.c_str(), oct.size()); - logger.debug("Content:\n%s", json_writer.to_string().c_str()); + logger.debug("Content:%s", json_writer.to_string().c_str()); } else if (logger.info.enabled()) { logger.info("%s - %s %s (%d B)", source.c_str(), (dir == Rx) ? "Rx" : "Tx", msg_type.c_str(), oct.size()); } @@ -457,11 +457,15 @@ void rrc_nr::phy_set_cells_to_meas(uint32_t carrier_freq_r15) fake_measurement_timer.run(); } -void rrc_nr::configure_sk_counter(uint16_t sk_counter) +bool rrc_nr::configure_sk_counter(uint16_t sk_counter) { logger.info("[NR] Configure new SK counter %d. Update Key for secondary gnb", sk_counter); - usim->generate_nr_context(sk_counter, &sec_cfg); + if (usim->generate_nr_context(sk_counter, &sec_cfg) == false) { + return false; + } + return true; } + bool rrc_nr::is_config_pending() { if (conn_recfg_proc.is_busy()) { @@ -499,9 +503,11 @@ bool rrc_nr::apply_rlc_add_mod(const rlc_bearer_cfg_s& rlc_bearer_cfg) rlc_bearer_cfg.rlc_cfg.um_bi_dir().dl_um_rlc.sn_field_len != rlc_bearer_cfg.rlc_cfg.um_bi_dir().ul_um_rlc.sn_field_len) { logger.warning("NR RLC sequence number length is not the same in uplink and downlink"); + return false; } } else { logger.warning("NR RLC type is not unacknowledged mode bidirectional"); + return false; } } else { logger.warning("In RLC bearer cfg does not contain rlc cfg"); @@ -525,6 +531,8 @@ bool rrc_nr::apply_mac_cell_group(const mac_cell_group_cfg_s& mac_cell_group_cfg if (mac_cell_group_cfg.sched_request_cfg.sched_request_to_add_mod_list_present) { if (mac_cell_group_cfg.sched_request_cfg.sched_request_to_add_mod_list.size() > 1) { logger.warning("Only handling 1 scheduling request index to add"); + return false; + } else { sr_cfg.dsr_transmax = mac_cell_group_cfg.sched_request_cfg.sched_request_to_add_mod_list[1].sr_trans_max; mac->set_config(sr_cfg); } @@ -532,6 +540,7 @@ bool rrc_nr::apply_mac_cell_group(const mac_cell_group_cfg_s& mac_cell_group_cfg if (mac_cell_group_cfg.sched_request_cfg.sched_request_to_release_list_present) { logger.warning("Not handling sched request to release list"); + return false; } } if (mac_cell_group_cfg.sched_request_cfg_present) @@ -558,24 +567,507 @@ bool rrc_nr::apply_mac_cell_group(const mac_cell_group_cfg_s& mac_cell_group_cfg return true; } +bool rrc_nr::apply_sp_cell_init_dl_pdcch(const asn1::rrc_nr::pdcch_cfg_s& pdcch_cfg) +{ + if (pdcch_cfg.search_spaces_to_add_mod_list_present) { + for (uint32_t i = 0; i < pdcch_cfg.search_spaces_to_add_mod_list.size(); i++) { + srsran_search_space_t search_space; + if (make_phy_search_space_cfg(pdcch_cfg.search_spaces_to_add_mod_list[i], &search_space) == true) { + phy_cfg.pdcch.search_space[search_space.id] = search_space; + phy_cfg.pdcch.search_space_present[search_space.id] = true; + } else { + logger.warning("Warning while building search_space structure"); + return false; + } + } + } else { + logger.warning("Option search_spaces_to_add_mod_list not present"); + return false; + } + return true; +} + +bool rrc_nr::apply_sp_cell_init_dl_pdsch(const asn1::rrc_nr::pdsch_cfg_s& pdsch_cfg) +{ + return true; +} + +bool rrc_nr::apply_res_csi_report_cfg(const asn1::rrc_nr::csi_report_cfg_s& csi_report_cfg) +{ + uint32_t report_cfg_id = csi_report_cfg.report_cfg_id; + srsran_csi_hl_report_cfg_t srsran_csi_hl_report_cfg; + if (make_phy_csi_report(csi_report_cfg, &srsran_csi_hl_report_cfg) == true) { + phy_cfg.csi.reports[report_cfg_id] = srsran_csi_hl_report_cfg; + } else { + logger.warning("Warning while building report structure"); + return false; + } + if (csi_report_cfg.report_cfg_type.type() == csi_report_cfg_s::report_cfg_type_c_::types_opts::options::periodic) { + if (csi_report_cfg.report_cfg_type.periodic().pucch_csi_res_list.size() > 0) { + uint32_t res_id = csi_report_cfg.report_cfg_type.periodic() + .pucch_csi_res_list[0] + .pucch_res; // TODO: support and check more items + if (res_list_present[res_id] == true) { + phy_cfg.csi.reports[report_cfg_id].periodic.resource = res_list[res_id]; + } else { + logger.error("Resources set not present for assigning pucch sets (res_id %d)", res_id); + return false; + } + } else { + logger.warning("List size to small: pucch_csi_res_list.size() < 0"); + return false; + } + } + return true; +} + +bool rrc_nr::apply_csi_meas_cfg(const asn1::rrc_nr::csi_meas_cfg_s& csi_meas_cfg) +{ + if (csi_meas_cfg.csi_report_cfg_to_add_mod_list_present) { + for (uint32_t i = 0; i < csi_meas_cfg.csi_report_cfg_to_add_mod_list.size(); i++) { + if (apply_res_csi_report_cfg(csi_meas_cfg.csi_report_cfg_to_add_mod_list[i]) == false) { + return false; + } + } + } else { + logger.warning("Option csi_report_cfg_to_add_mod_list not present"); + return false; + } + return true; +} + +bool rrc_nr::apply_dl_common_cfg(const asn1::rrc_nr::dl_cfg_common_s& dl_cfg_common) +{ + if (dl_cfg_common.init_dl_bwp_present) { + if (dl_cfg_common.init_dl_bwp.pdsch_cfg_common_present) { + if (dl_cfg_common.init_dl_bwp.pdsch_cfg_common.type() == + asn1::rrc_nr::setup_release_c::types_opts::setup) { + const pdcch_cfg_common_s& pdcch_cfg_common = dl_cfg_common.init_dl_bwp.pdcch_cfg_common.setup(); + if (pdcch_cfg_common.common_ctrl_res_set_present) { + srsran_coreset_t coreset; + if (make_phy_coreset_cfg(pdcch_cfg_common.common_ctrl_res_set, &coreset) == true) { + phy_cfg.pdcch.coreset[coreset.coreset_id] = coreset; + phy_cfg.pdcch.coreset_present[coreset.coreset_id] = true; + } else { + logger.warning("Warning while building coreset structure"); + return false; + } + } else { + logger.warning("Option common_ctrl_res_set not present"); + return false; + } + if (pdcch_cfg_common.common_search_space_list_present) { + for (uint32_t i = 0; i < pdcch_cfg_common.common_search_space_list.size(); i++) { + srsran_search_space_t search_space; + if (make_phy_search_space_cfg(pdcch_cfg_common.common_search_space_list[i], &search_space) == true) { + phy_cfg.pdcch.search_space[search_space.id] = search_space; + phy_cfg.pdcch.search_space_present[search_space.id] = true; + } else { + logger.warning("Warning while building search_space structure"); + return false; + } + } + } else { + logger.warning("Option common_search_space_list not present"); + return false; + } + if (pdcch_cfg_common.ra_search_space_present) { + if (phy_cfg.pdcch.search_space_present[pdcch_cfg_common.ra_search_space] == true) { + // phy_cfg.pdcch.ra_rnti = 0x16; //< Supposed to be deduced from PRACH configuration + phy_cfg.pdcch.ra_search_space = phy_cfg.pdcch.search_space[pdcch_cfg_common.ra_search_space]; + phy_cfg.pdcch.ra_search_space_present = true; + phy_cfg.pdcch.ra_search_space.type = srsran_search_space_type_common_3; + } else { + logger.warning("Search space %d not presenet for random access search space", + pdcch_cfg_common.ra_search_space); + } + } else { + logger.warning("Option ra_search_space not present"); + return false; + } + } else { + logger.warning("Option pdsch_cfg_common not of type setup"); + return false; + } + } else { + logger.warning("Option pdsch_cfg_common not present"); + return false; + } + if (dl_cfg_common.init_dl_bwp.pdsch_cfg_common_present) { + if (dl_cfg_common.init_dl_bwp.pdsch_cfg_common.type() == setup_release_c::types::setup) { + pdsch_cfg_common_s pdsch_cfg_common = dl_cfg_common.init_dl_bwp.pdsch_cfg_common.setup(); + if (pdsch_cfg_common.pdsch_time_domain_alloc_list_present) { + for (uint32_t i = 0; i < pdsch_cfg_common.pdsch_time_domain_alloc_list.size(); i++) { + srsran_sch_time_ra_t common_time_ra; + if (make_phy_common_time_ra(pdsch_cfg_common.pdsch_time_domain_alloc_list[i], &common_time_ra) == true) { + phy_cfg.pdsch.common_time_ra[i] = common_time_ra; + phy_cfg.pdsch.nof_common_time_ra = i; + } else { + logger.warning("Warning while building common_time_ra structure"); + return false; + } + } + } else { + logger.warning("Option pdsch_time_domain_alloc_list not present"); + return false; + } + } else { + logger.warning("Option pdsch_cfg_common not of type setup"); + return false; + } + } else { + logger.warning("Option pdsch_cfg_common not present"); + return false; + } + } else { + logger.warning("Option init_dl_bwp not present"); + return false; + } + return true; +} + +bool rrc_nr::apply_ul_common_cfg(const asn1::rrc_nr::ul_cfg_common_s& ul_cfg_common) +{ + if (ul_cfg_common.init_ul_bwp_present) { + if (ul_cfg_common.init_ul_bwp.rach_cfg_common_present) { + if (ul_cfg_common.init_ul_bwp.rach_cfg_common.type() == setup_release_c::types_opts::setup) { + rach_nr_cfg_t rach_nr_cfg = make_mac_rach_cfg(ul_cfg_common.init_ul_bwp.rach_cfg_common.setup()); + phy_cfg.pdcch.ra_rnti = ul_cfg_common.init_ul_bwp.rach_cfg_common.setup().rach_cfg_generic.prach_cfg_idx; + mac->set_config(rach_nr_cfg); + } else { + logger.warning("Option rach_cfg_common not of type setup"); + return false; + } + } else { + logger.warning("Option rach_cfg_common not present"); + return false; + } + if (ul_cfg_common.init_ul_bwp.pusch_cfg_common_present) { + if (ul_cfg_common.init_ul_bwp.pusch_cfg_common.type() == setup_release_c::types_opts::setup) { + if (ul_cfg_common.init_ul_bwp.pusch_cfg_common.setup().pusch_time_domain_alloc_list_present) { + for (uint32_t i = 0; + i < ul_cfg_common.init_ul_bwp.pusch_cfg_common.setup().pusch_time_domain_alloc_list.size(); + i++) { + srsran_sch_time_ra_t common_time_ra; + if (make_phy_common_time_ra( + ul_cfg_common.init_ul_bwp.pusch_cfg_common.setup().pusch_time_domain_alloc_list[i], + &common_time_ra) == true) { + phy_cfg.pusch.common_time_ra[i] = common_time_ra; + phy_cfg.pusch.nof_common_time_ra = i + 1; + } else { + logger.warning("Warning while building common_time_ra structure"); + } + } + } else { + logger.warning("Option pusch_time_domain_alloc_list not present"); + return false; + } + } else { + logger.warning("Option pusch_cfg_common not of type setup"); + return false; + } + } else { + logger.warning("Option pusch_cfg_common not present"); + return false; + } + if (ul_cfg_common.init_ul_bwp.pucch_cfg_common_present) { + if (ul_cfg_common.init_ul_bwp.pucch_cfg_common.type() == setup_release_c::types_opts::setup) { + } else { + logger.warning("Option pucch_cfg_common not of type setup"); + return false; + } + } else { + logger.warning("Option pucch_cfg_common not present"); + return false; + } + } else { + logger.warning("Option init_ul_bwp not present"); + return false; + } + return true; +} + +bool rrc_nr::apply_sp_cell_ded_ul_pucch(const asn1::rrc_nr::pucch_cfg_s& pucch_cfg) +{ + // determine format 2 max code rate + uint32_t format_2_max_code_rate = 0; + if (pucch_cfg.format2_present && pucch_cfg.format2.type() == setup_release_c::types::setup) { + if (pucch_cfg.format2.setup().max_code_rate_present) { + if (make_phy_max_code_rate(pucch_cfg.format2.setup(), &format_2_max_code_rate) == false) { + logger.warning("Warning while building format_2_max_code_rate"); + } + } + } else { + logger.warning("Option format2 not present or not of type setup"); + return false; + } + + // now look up resource and assign into internal struct + if (pucch_cfg.res_to_add_mod_list_present) { + for (uint32_t i = 0; i < pucch_cfg.res_to_add_mod_list.size(); i++) { + uint32_t res_id = pucch_cfg.res_to_add_mod_list[i].pucch_res_id; + if (make_phy_res_config(pucch_cfg.res_to_add_mod_list[i], format_2_max_code_rate, &res_list[res_id]) == true) { + res_list_present[res_id] = true; + } else { + logger.warning("Warning while building pucch_nr_resource structure"); + return false; + } + } + } else { + logger.warning("Option res_to_add_mod_list not present"); + return false; + } + + // Check first all resource lists and + phy_cfg.pucch.enabled = true; + if (pucch_cfg.res_set_to_add_mod_list_present) { + for (uint32_t i = 0; i < pucch_cfg.res_set_to_add_mod_list.size(); i++) { + uint32_t set_id = pucch_cfg.res_set_to_add_mod_list[i].pucch_res_set_id; + phy_cfg.pucch.sets[set_id].nof_resources = pucch_cfg.res_set_to_add_mod_list[i].res_list.size(); + for (uint32_t j = 0; j < pucch_cfg.res_set_to_add_mod_list[i].res_list.size(); j++) { + uint32_t res_id = pucch_cfg.res_set_to_add_mod_list[i].res_list[j]; + if (res_list_present[res_id] == true) { + phy_cfg.pucch.sets[set_id].resources[j] = res_list[res_id]; + } else { + logger.error( + "Resources set not present for assign pucch sets (res_id %d, setid %d, j %d)", res_id, set_id, j); + } + } + } + } + + if (pucch_cfg.sched_request_res_to_add_mod_list_present) { + for (uint32_t i = 0; i < pucch_cfg.sched_request_res_to_add_mod_list.size(); i++) { + uint32_t res_id = pucch_cfg.sched_request_res_to_add_mod_list[i].sched_request_res_id; + srsran_pucch_nr_sr_resource_t srsran_pucch_nr_sr_resource; + if (make_phy_sr_resource(pucch_cfg.sched_request_res_to_add_mod_list[i], &srsran_pucch_nr_sr_resource) == + true) { // TODO: fix that if indexing is solved + phy_cfg.pucch.sr_resources[res_id] = srsran_pucch_nr_sr_resource; + } else { + logger.warning("Warning while building srsran_pucch_nr_sr_resource structure"); + return false; + } + } + } else { + logger.warning("Option sched_request_res_to_add_mod_list not present"); + return false; + } + + if (pucch_cfg.dl_data_to_ul_ack_present) { + for (uint32_t i = 0; i < pucch_cfg.dl_data_to_ul_ack.size(); i++) { + phy_cfg.harq_ack.dl_data_to_ul_ack[i] = pucch_cfg.dl_data_to_ul_ack[i]; + } + phy_cfg.harq_ack.nof_dl_data_to_ul_ack = pucch_cfg.dl_data_to_ul_ack.size(); + } else { + logger.warning("Option dl_data_to_ul_ack not present"); + return false; + } + + return true; +}; + +bool rrc_nr::apply_sp_cell_ded_ul_pusch(const asn1::rrc_nr::pusch_cfg_s& pusch_cfg) +{ + if (pusch_cfg.dmrs_ul_for_pusch_map_type_a_present) { + if (pusch_cfg.dmrs_ul_for_pusch_map_type_a.type() == setup_release_c::types_opts::setup) { + srsran_dmrs_sch_add_pos_t srsran_dmrs_sch_add_pos; + if (make_phy_dmrs_additional_pos(pusch_cfg.dmrs_ul_for_pusch_map_type_a.setup(), &srsran_dmrs_sch_add_pos) == + true) { + phy_cfg.pusch.dmrs_typeA.additional_pos = srsran_dmrs_sch_add_pos; + phy_cfg.pusch.dmrs_typeA.present = true; + } else { + logger.warning("Warning while build srsran_dmrs_sch_add_pos structure"); + return false; + } + } else { + logger.warning("Option dmrs_ul_for_pusch_map_type_a not of type setup"); + return false; + return false; + } + } else { + logger.warning("Option dmrs_ul_for_pusch_map_type_a not present"); + return false; + } + if (pusch_cfg.uci_on_pusch_present) { + if (pusch_cfg.uci_on_pusch.type() == setup_release_c::types_opts::setup) { + if (pusch_cfg.uci_on_pusch.setup().beta_offsets_present) { + if (pusch_cfg.uci_on_pusch.setup().beta_offsets.type() == + uci_on_pusch_s::beta_offsets_c_::types_opts::semi_static) { + srsran_beta_offsets_t beta_offsets; + if (make_phy_beta_offsets(pusch_cfg.uci_on_pusch.setup().beta_offsets.semi_static(), &beta_offsets) == true) { + phy_cfg.pusch.beta_offsets = beta_offsets; + } else { + logger.warning("Warning while building beta_offsets structure"); + return false; + } + } else { + logger.warning("Option beta_offsets not of type semi_static"); + return false; + } + if (make_phy_pusch_scaling(pusch_cfg.uci_on_pusch.setup(), &phy_cfg.pusch.scaling) == false) { + logger.warning("Warning while building scaling structure"); + return false; + } + } else { + logger.warning("Option beta_offsets not present"); + return false; + } + } else { + logger.warning("Option uci_on_pusch of type setup"); + return false; + } + } else { + logger.warning("Option uci_on_pusch not present"); + return false; + } + return true; +}; + bool rrc_nr::apply_sp_cell_cfg(const sp_cell_cfg_s& sp_cell_cfg) { if (sp_cell_cfg.recfg_with_sync_present) { const recfg_with_sync_s& recfg_with_sync = sp_cell_cfg.recfg_with_sync; mac->set_crnti(recfg_with_sync.new_ue_id); + // Common config if (recfg_with_sync.sp_cell_cfg_common_present) { if (recfg_with_sync.sp_cell_cfg_common.ul_cfg_common_present) { - const bwp_ul_common_s* bwp_ul_common = &recfg_with_sync.sp_cell_cfg_common.ul_cfg_common.init_ul_bwp; - if (bwp_ul_common->rach_cfg_common_present) { - if (bwp_ul_common->rach_cfg_common.type() == setup_release_c::types_opts::setup) { - const rach_cfg_common_s& rach_cfg_common = bwp_ul_common->rach_cfg_common.setup(); - rach_nr_cfg_t rach_nr_cfg = make_mac_rach_cfg(rach_cfg_common); - mac->set_config(rach_nr_cfg); + if (apply_ul_common_cfg(recfg_with_sync.sp_cell_cfg_common.ul_cfg_common) == false) { + return false; + } + } else { + logger.warning("Secondary primary cell ul cfg common not present"); + return false; + } + if (recfg_with_sync.sp_cell_cfg_common.dl_cfg_common_present) { + if (apply_dl_common_cfg(recfg_with_sync.sp_cell_cfg_common.dl_cfg_common) == false) { + return false; + } + } else { + logger.warning("DL cfg common not present"); + return false; + } + if (recfg_with_sync.sp_cell_cfg_common.tdd_ul_dl_cfg_common_present) { + srsran_tdd_config_nr_t tdd; + if (make_phy_tdd_cfg(recfg_with_sync.sp_cell_cfg_common.tdd_ul_dl_cfg_common, &tdd) == true) { + phy_cfg.tdd = tdd; + } else { + logger.warning("Warning while building tdd structure"); + return false; + } + } else { + logger.warning("TDD UL DL config not present"); + return false; + } + } + } else { + logger.warning("Reconfig with with sync not present"); + return false; + } + + // Dedicated config + if (sp_cell_cfg.sp_cell_cfg_ded_present) { + // Dedicated Downlink + if (sp_cell_cfg.sp_cell_cfg_ded.init_dl_bwp_present) { + if (sp_cell_cfg.sp_cell_cfg_ded.init_dl_bwp.pdcch_cfg_present) { + if (sp_cell_cfg.sp_cell_cfg_ded.init_dl_bwp.pdcch_cfg.type() == + setup_release_c::types_opts::setup) { + if (apply_sp_cell_init_dl_pdcch(sp_cell_cfg.sp_cell_cfg_ded.init_dl_bwp.pdcch_cfg.setup()) == false) { + return false; } + } else { + logger.warning("Option pdcch_cfg not of type setup"); + return false; + } + } else { + logger.warning("Option pdcch_cfg not present"); + return false; + } + if (sp_cell_cfg.sp_cell_cfg_ded.init_dl_bwp.pdsch_cfg_present) { + if (sp_cell_cfg.sp_cell_cfg_ded.init_dl_bwp.pdsch_cfg.type() == + setup_release_c::types_opts::setup) { + apply_sp_cell_init_dl_pdsch(sp_cell_cfg.sp_cell_cfg_ded.init_dl_bwp.pdsch_cfg.setup()); + } else { + logger.warning("Option pdsch_cfg_cfg not of type setup"); + return false; } + } else { + logger.warning("Option pdsch_cfg not present"); + return false; } + } else { + logger.warning("Option init_dl_bwp not present"); + return false; } - mac->start_ra_procedure(); + // Dedicated Uplink + if (sp_cell_cfg.sp_cell_cfg_ded.ul_cfg_present) { + if (sp_cell_cfg.sp_cell_cfg_ded.ul_cfg.init_ul_bwp_present) { + if (sp_cell_cfg.sp_cell_cfg_ded.ul_cfg.init_ul_bwp.pucch_cfg_present) { + if (sp_cell_cfg.sp_cell_cfg_ded.ul_cfg.init_ul_bwp.pucch_cfg.type() == + setup_release_c::types_opts::setup) { + if (apply_sp_cell_ded_ul_pucch(sp_cell_cfg.sp_cell_cfg_ded.ul_cfg.init_ul_bwp.pucch_cfg.setup()) == false) { + return false; + } + } else { + logger.warning("Option pucch_cfg not of type setup"); + return false; + } + } else { + logger.warning("Option pucch_cfg not present"); + return false; + } + if (sp_cell_cfg.sp_cell_cfg_ded.ul_cfg.init_ul_bwp.pusch_cfg_present) { + if (sp_cell_cfg.sp_cell_cfg_ded.ul_cfg.init_ul_bwp.pusch_cfg.type() == + setup_release_c::types_opts::setup) { + if (apply_sp_cell_ded_ul_pusch(sp_cell_cfg.sp_cell_cfg_ded.ul_cfg.init_ul_bwp.pusch_cfg.setup()) == false) { + return false; + } + } else { + logger.warning("Option pusch_cfg not of type setup"); + return false; + } + } else { + logger.warning("Option pusch_cfg not present"); + return false; + } + } else { + logger.warning("Option init_ul_bwp not present"); + return false; + } + } else { + logger.warning("Option ul_cfg not present"); + return false; + } + if (sp_cell_cfg.sp_cell_cfg_ded.csi_meas_cfg_present) { + if (sp_cell_cfg.sp_cell_cfg_ded.csi_meas_cfg.type() == setup_release_c::types_opts::setup) { + if (apply_csi_meas_cfg(sp_cell_cfg.sp_cell_cfg_ded.csi_meas_cfg.setup()) == false) { + return false; + } + } else { + logger.warning("Option csi_meas_cfg not of type setup"); + return false; + } + } else { + logger.warning("Option csi_meas_cfg not present"); + return false; + } + + } else { + logger.warning("Option sp_cell_cfg_ded not present"); + return false; + } + phy->set_config(phy_cfg); + mac->start_ra_procedure(); + return true; +} + +bool rrc_nr::apply_phy_cell_group_cfg(const phys_cell_group_cfg_s& phys_cell_group_cfg) +{ + srsran_ue_dl_nr_harq_ack_cfg_t harq_ack; + if (make_phy_harq_ack_cfg(phys_cell_group_cfg, &harq_ack) == true) { + phy_cfg.harq_ack = harq_ack; + } else { + logger.warning("Warning while building harq_ack structure"); + return false; } return true; } @@ -584,17 +1076,25 @@ bool rrc_nr::apply_cell_group_cfg(const cell_group_cfg_s& cell_group_cfg) { if (cell_group_cfg.rlc_bearer_to_add_mod_list_present) { for (uint32_t i = 0; i < cell_group_cfg.rlc_bearer_to_add_mod_list.size(); i++) { - apply_rlc_add_mod(cell_group_cfg.rlc_bearer_to_add_mod_list[i]); + if (apply_rlc_add_mod(cell_group_cfg.rlc_bearer_to_add_mod_list[i]) == false) { + return false; + } } } if (cell_group_cfg.mac_cell_group_cfg_present) { - apply_mac_cell_group(cell_group_cfg.mac_cell_group_cfg); + if (apply_mac_cell_group(cell_group_cfg.mac_cell_group_cfg) == false) { + return false; + } } if (cell_group_cfg.phys_cell_group_cfg_present) { - logger.warning("Not handling physical cell group config"); + if (apply_phy_cell_group_cfg(cell_group_cfg.phys_cell_group_cfg) == false) { + return false; + } } if (cell_group_cfg.sp_cell_cfg_present) { - apply_sp_cell_cfg(cell_group_cfg.sp_cell_cfg); + if (apply_sp_cell_cfg(cell_group_cfg.sp_cell_cfg) == false) { + return false; + } } return true; } @@ -644,6 +1144,7 @@ bool rrc_nr::apply_security_cfg(const security_cfg_s& security_cfg) if (security_cfg.key_to_use_present) { if (security_cfg.key_to_use.value != security_cfg_s::key_to_use_opts::options::secondary) { logger.warning("Only secondary key supported yet"); + return false; } } @@ -662,8 +1163,8 @@ bool rrc_nr::apply_security_cfg(const security_cfg_s& security_cfg) sec_cfg.cipher_algo = CIPHERING_ALGORITHM_ID_128_EEA3; break; default: - logger.warning("Unsupported algorithm"); - break; + logger.warning("Unsupported algorithm %s", security_cfg.security_algorithm_cfg.ciphering_algorithm.to_string()); + return false; } if (security_cfg.security_algorithm_cfg.integrity_prot_algorithm_present) { @@ -681,11 +1182,14 @@ bool rrc_nr::apply_security_cfg(const security_cfg_s& security_cfg) sec_cfg.integ_algo = INTEGRITY_ALGORITHM_ID_128_EIA3; break; default: - logger.warning("Unsupported algorithm"); - break; + logger.warning("Unsupported algorithm %s", + security_cfg.security_algorithm_cfg.integrity_prot_algorithm.to_string()); + return false; } } - usim->update_nr_context(&sec_cfg); + if (usim->update_nr_context(&sec_cfg) == false) { + return false; + } } // Apply security config for all known NR lcids @@ -700,11 +1204,15 @@ bool rrc_nr::apply_radio_bearer_cfg(const radio_bearer_cfg_s& radio_bearer_cfg) { if (radio_bearer_cfg.drb_to_add_mod_list_present) { for (uint32_t i = 0; i < radio_bearer_cfg.drb_to_add_mod_list.size(); i++) { - apply_drb_add_mod(radio_bearer_cfg.drb_to_add_mod_list[i]); + if (apply_drb_add_mod(radio_bearer_cfg.drb_to_add_mod_list[i]) == false) { + return false; + } } } if (radio_bearer_cfg.security_cfg_present) { - apply_security_cfg(radio_bearer_cfg.security_cfg); + if (apply_security_cfg(radio_bearer_cfg.security_cfg) == false) { + return false; + } } return true; } @@ -734,7 +1242,9 @@ proc_outcome_t rrc_nr::connection_reconf_no_ho_proc::init(const bool if (sk_counter_r15_present) { Info("Applying Cell Group Cfg"); - rrc_ptr->configure_sk_counter((uint16_t)sk_counter_r15); + if (!rrc_ptr->configure_sk_counter((uint16_t)sk_counter_r15)) { + return proc_outcome_t::error; + } } Info("Applying Radio Bearer Cfg"); diff --git a/srsue/src/stack/upper/usim_base.cc b/srsue/src/stack/upper/usim_base.cc index eef44aee6..9d9c7dd92 100644 --- a/srsue/src/stack/upper/usim_base.cc +++ b/srsue/src/stack/upper/usim_base.cc @@ -269,24 +269,27 @@ void usim_base::restore_keys_from_failed_ho(srsran::as_security_config_t* as_ctx * NR RRC Interface */ -void usim_base::generate_nr_context(uint16_t sk_counter, srsran::as_security_config_t* sec_cfg) +bool usim_base::generate_nr_context(uint16_t sk_counter, srsran::as_security_config_t* sec_cfg) { if (!initiated) { logger.error("USIM not initiated!"); - return; + return false; } logger.info("Generating Keys. SCG Counter %d", sk_counter); srsran::security_generate_sk_gnb(k_enb_ctx.k_enb.data(), k_gnb_ctx.sk_gnb.data(), sk_counter); logger.info(k_gnb_ctx.sk_gnb.data(), 32, "k_sk_gnb"); - update_nr_context(sec_cfg); + if (update_nr_context(sec_cfg) == false) { + return false; + } + return true; } -void usim_base::update_nr_context(srsran::as_security_config_t* sec_cfg) +bool usim_base::update_nr_context(srsran::as_security_config_t* sec_cfg) { if (!initiated) { logger.error("USIM not initiated!"); - return; + return false; } logger.info(k_gnb_ctx.sk_gnb.data(), 32, "k_sk_gnb"); // Generate K_rrc_enc and K_rrc_int @@ -307,6 +310,7 @@ void usim_base::update_nr_context(srsran::as_security_config_t* sec_cfg) logger.debug(sec_cfg->k_rrc_enc.data(), sec_cfg->k_rrc_enc.size(), "NR K_RRC_enc"); logger.debug(sec_cfg->k_up_int.data(), sec_cfg->k_up_int.size(), "NR K_UP_int"); logger.debug(sec_cfg->k_up_enc.data(), sec_cfg->k_up_enc.size(), "NR K_UP_enc"); + return true; } } // namespace srsue From b06ef3f3907d0edae720f95b5bd4d0b83045634b Mon Sep 17 00:00:00 2001 From: faluco Date: Wed, 24 Mar 2021 12:26:28 +0100 Subject: [PATCH 37/48] Switch the queue of the log backend to use a circular buffer. --- lib/include/srsran/common/srsran_assert.h | 3 --- .../srsran/srslog/detail/support/work_queue.h | 16 ++++++++-------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/lib/include/srsran/common/srsran_assert.h b/lib/include/srsran/common/srsran_assert.h index cef540f00..fc30241fc 100644 --- a/lib/include/srsran/common/srsran_assert.h +++ b/lib/include/srsran/common/srsran_assert.h @@ -27,9 +27,6 @@ #define srsran_assert(condition, fmt, ...) \ do { \ if (srsran_unlikely(not(condition))) { \ - srslog::fetch_basic_logger("ALL").error("%s:%d: " fmt, __FILE__, __LINE__, ##__VA_ARGS__); \ - srslog::flush(); \ - srsran::console_stderr("%s:%d: " fmt "\n", __FILE__, __LINE__, ##__VA_ARGS__); \ std::abort(); \ } \ } while (0) diff --git a/lib/include/srsran/srslog/detail/support/work_queue.h b/lib/include/srsran/srslog/detail/support/work_queue.h index d1589f877..ef7b9d8de 100644 --- a/lib/include/srsran/srslog/detail/support/work_queue.h +++ b/lib/include/srsran/srslog/detail/support/work_queue.h @@ -13,9 +13,9 @@ #ifndef SRSLOG_DETAIL_SUPPORT_WORK_QUEUE_H #define SRSLOG_DETAIL_SUPPORT_WORK_QUEUE_H +#include "srsran/adt/circular_buffer.h" #include "srsran/srslog/detail/support/backend_capacity.h" #include "srsran/srslog/detail/support/thread_utils.h" -#include namespace srslog { @@ -27,9 +27,9 @@ namespace detail { template class work_queue { - std::queue queue; - mutable condition_variable cond_var; - static constexpr size_t threshold = capacity * 0.98; + srsran::static_circular_buffer queue; + mutable condition_variable cond_var; + static constexpr size_t threshold = capacity * 0.98; public: work_queue() = default; @@ -43,7 +43,7 @@ public: { cond_var.lock(); // Discard the new element if we reach the maximum capacity. - if (queue.size() > capacity) { + if (queue.full()) { cond_var.unlock(); return false; } @@ -60,7 +60,7 @@ public: { cond_var.lock(); // Discard the new element if we reach the maximum capacity. - if (queue.size() > capacity) { + if (queue.full()) { cond_var.unlock(); return false; } @@ -81,7 +81,7 @@ public: cond_var.wait(); } - T elem = std::move(queue.front()); + T elem = std::move(queue.top()); queue.pop(); cond_var.unlock(); @@ -112,7 +112,7 @@ public: } // Here we have been woken up normally. - T Item = std::move(queue.front()); + T Item = std::move(queue.top()); queue.pop(); cond_var.unlock(); From 4b5e15cd708616f0d7322fabbc1a34e30138ac91 Mon Sep 17 00:00:00 2001 From: faluco Date: Thu, 25 Mar 2021 10:11:43 +0100 Subject: [PATCH 38/48] - Fixed missing return statements in base_circular_buffer::try_push. - Fixed array index calculation in base_circular_buffer::clear. - Removed redundant explicit in srslog::backend_worker. --- lib/include/srsran/adt/circular_buffer.h | 4 +++- lib/src/srslog/backend_worker.h | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/include/srsran/adt/circular_buffer.h b/lib/include/srsran/adt/circular_buffer.h index e23dca196..851366898 100644 --- a/lib/include/srsran/adt/circular_buffer.h +++ b/lib/include/srsran/adt/circular_buffer.h @@ -151,6 +151,7 @@ public: return false; } push(std::move(t)); + return true; } bool try_push(const T& t) @@ -159,6 +160,7 @@ public: return false; } push(t); + return true; } void pop() { @@ -180,7 +182,7 @@ public: void clear() { for (size_t i = 0; i < count; ++i) { - buffer[rpos + i].destroy(); + buffer[(rpos + i) % max_size()].destroy(); } count = 0; } diff --git a/lib/src/srslog/backend_worker.h b/lib/src/srslog/backend_worker.h index 641c024c2..e45786dab 100644 --- a/lib/src/srslog/backend_worker.h +++ b/lib/src/srslog/backend_worker.h @@ -32,7 +32,7 @@ class backend_worker static constexpr unsigned sleep_period_ms = 500; public: - explicit backend_worker(detail::work_queue& queue, detail::dyn_arg_store_pool& arg_pool) : + backend_worker(detail::work_queue& queue, detail::dyn_arg_store_pool& arg_pool) : queue(queue), arg_pool(arg_pool), running_flag(false) {} From 3c1a97f45007211acc0913ec5410158dc1414a98 Mon Sep 17 00:00:00 2001 From: faluco Date: Thu, 25 Mar 2021 10:38:00 +0100 Subject: [PATCH 39/48] - Use fprintf in the srsran_assert context incase the assert is being triggered by srslog producing a circular loop. - Switch to use a dynamic circular buffer for the log backend queue. --- lib/include/srsran/common/srsran_assert.h | 3 ++- lib/include/srsran/srslog/detail/support/work_queue.h | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/include/srsran/common/srsran_assert.h b/lib/include/srsran/common/srsran_assert.h index fc30241fc..77094ac0f 100644 --- a/lib/include/srsran/common/srsran_assert.h +++ b/lib/include/srsran/common/srsran_assert.h @@ -13,8 +13,8 @@ #ifndef SRSRAN_ASSERT_H #define SRSRAN_ASSERT_H -#include "srsran/common/standard_streams.h" #include "srsran/srslog/srslog.h" +#include #ifdef ASSERTS_ENABLED @@ -27,6 +27,7 @@ #define srsran_assert(condition, fmt, ...) \ do { \ if (srsran_unlikely(not(condition))) { \ + std::fprintf(stderr, "%s:%d: " fmt "\n", __FILE__, __LINE__, ##__VA_ARGS__); \ std::abort(); \ } \ } while (0) diff --git a/lib/include/srsran/srslog/detail/support/work_queue.h b/lib/include/srsran/srslog/detail/support/work_queue.h index ef7b9d8de..2a7f17b20 100644 --- a/lib/include/srsran/srslog/detail/support/work_queue.h +++ b/lib/include/srsran/srslog/detail/support/work_queue.h @@ -27,12 +27,12 @@ namespace detail { template class work_queue { - srsran::static_circular_buffer queue; - mutable condition_variable cond_var; - static constexpr size_t threshold = capacity * 0.98; + srsran::dyn_circular_buffer queue; + mutable condition_variable cond_var; + static constexpr size_t threshold = capacity * 0.98; public: - work_queue() = default; + work_queue() : queue(capacity) {} work_queue(const work_queue&) = delete; work_queue& operator=(const work_queue&) = delete; From 1b47bee4c09fbf391fef6c9d1293a52695341c52 Mon Sep 17 00:00:00 2001 From: Francisco Date: Thu, 25 Mar 2021 21:27:44 +0000 Subject: [PATCH 40/48] handover - avoid halting ho preparation just due to the presence of a handover restriction list or handover request extension field --- srsenb/src/stack/upper/s1ap.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/srsenb/src/stack/upper/s1ap.cc b/srsenb/src/stack/upper/s1ap.cc index a13de8400..953361f35 100644 --- a/srsenb/src/stack/upper/s1ap.cc +++ b/srsenb/src/stack/upper/s1ap.cc @@ -881,9 +881,12 @@ bool s1ap::handle_handover_request(const asn1::s1ap::ho_request_s& msg) } }); - if (msg.ext or msg.protocol_ies.ho_restrict_list_present or - msg.protocol_ies.handov_type.value.value != handov_type_opts::intralte) { - logger.error("Not handling S1AP non-intra LTE handovers and extensions"); + if (msg.ext or msg.protocol_ies.ho_restrict_list_present) { + logger.warning("Not handling S1AP Handover Request extensions or Handover Restriction List"); + } + + if (msg.protocol_ies.handov_type.value.value != handov_type_opts::intralte) { + logger.error("Not handling S1AP non-intra LTE handovers"); return false; } From 6219500148bc1a628b64363d95983c31726a067c Mon Sep 17 00:00:00 2001 From: Xavier Arteaga Date: Thu, 25 Mar 2021 12:42:17 +0100 Subject: [PATCH 41/48] Added NR-RRC RACH parsing --- lib/include/srsran/asn1/rrc_nr_utils.h | 2 ++ .../interfaces/rrc_nr_interface_types.h | 9 ----- lib/src/asn1/rrc_nr_utils.cc | 34 ++++++++++++++++++- srsue/src/phy/nr/sf_worker.cc | 3 +- srsue/src/phy/nr/worker_pool.cc | 19 ++++++----- srsue/src/stack/rrc/rrc_nr.cc | 8 ++++- 6 files changed, 54 insertions(+), 21 deletions(-) diff --git a/lib/include/srsran/asn1/rrc_nr_utils.h b/lib/include/srsran/asn1/rrc_nr_utils.h index 28cc6eb82..a739a287c 100644 --- a/lib/include/srsran/asn1/rrc_nr_utils.h +++ b/lib/include/srsran/asn1/rrc_nr_utils.h @@ -61,6 +61,8 @@ void to_asn1(asn1::rrc_nr::plmn_id_s* asn1_type, const plmn_id_t& cfg); /*************************** * PHY Config **************************/ +bool make_phy_rach_cfg(const asn1::rrc_nr::rach_cfg_common_s& asn1_type, srsran_prach_cfg_t* prach_cfg); + bool make_phy_tdd_cfg(const asn1::rrc_nr::tdd_ul_dl_cfg_common_s& tdd_ul_dl_cfg_common, srsran_tdd_config_nr_t* srsran_tdd_config_nr); bool make_phy_harq_ack_cfg(const asn1::rrc_nr::phys_cell_group_cfg_s& phys_cell_group_cfg, diff --git a/lib/include/srsran/interfaces/rrc_nr_interface_types.h b/lib/include/srsran/interfaces/rrc_nr_interface_types.h index c0751687f..cc0a8efc8 100644 --- a/lib/include/srsran/interfaces/rrc_nr_interface_types.h +++ b/lib/include/srsran/interfaces/rrc_nr_interface_types.h @@ -35,15 +35,6 @@ struct phy_cfg_nr_t { phy_cfg_nr_t() { - // Default PRACH configuration - prach.is_nr = true; - prach.config_idx = 16; - prach.root_seq_idx = 1; - prach.freq_offset = 0; - prach.zero_corr_zone = 0; - prach.num_ra_preambles = 64; - prach.hs_flag = false; - // tdd-UL-DL-ConfigurationCommon // referenceSubcarrierSpacing: kHz15 (0) // pattern1 diff --git a/lib/src/asn1/rrc_nr_utils.cc b/lib/src/asn1/rrc_nr_utils.cc index 5b1b67da7..ee78d9596 100644 --- a/lib/src/asn1/rrc_nr_utils.cc +++ b/lib/src/asn1/rrc_nr_utils.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -194,6 +194,38 @@ srsran::pdcp_config_t make_drb_pdcp_config_t(const uint8_t bearer_id, bool is_ue return cfg; } +bool make_phy_rach_cfg(const rach_cfg_common_s& asn1_type, srsran_prach_cfg_t* prach_cfg) +{ + prach_cfg->is_nr = true; + prach_cfg->config_idx = asn1_type.rach_cfg_generic.prach_cfg_idx; + prach_cfg->zero_corr_zone = (uint32_t)asn1_type.rach_cfg_generic.zero_correlation_zone_cfg; + prach_cfg->num_ra_preambles = 64; // Hard-coded + prach_cfg->hs_flag = false; // Hard-coded + prach_cfg->tdd_config = {}; // Hard-coded + + // As the current PRACH is based on LTE, the freq-offset shall be subtracted 1 for aligning with NR bandwidth + // For example. A 52 PRB cell with an freq_offset of 1 will match a LTE 50 PRB cell with freq_offset of 0 + prach_cfg->freq_offset = (uint32_t)asn1_type.rach_cfg_generic.msg1_freq_start; + if (prach_cfg->freq_offset == 0) { + asn1::log_error("PRACH freq offset must be at least one"); + return false; + } + prach_cfg->freq_offset--; + + switch (prach_cfg->root_seq_idx = asn1_type.prach_root_seq_idx.type()) { + case rach_cfg_common_s::prach_root_seq_idx_c_::types_opts::l839: + prach_cfg->root_seq_idx = (uint32_t)asn1_type.prach_root_seq_idx.l839(); + break; + case rach_cfg_common_s::prach_root_seq_idx_c_::types_opts::l139: + default: + asn1::log_error("Not-implemented option for prach_root_seq_idx type %s", + asn1_type.prach_root_seq_idx.type().to_string()); + return false; + } + + return true; +}; + bool make_phy_tdd_cfg(const tdd_ul_dl_cfg_common_s& tdd_ul_dl_cfg_common, srsran_tdd_config_nr_t* in_srsran_tdd_config_nr) { diff --git a/srsue/src/phy/nr/sf_worker.cc b/srsue/src/phy/nr/sf_worker.cc index d0560096c..50dca8362 100644 --- a/srsue/src/phy/nr/sf_worker.cc +++ b/srsue/src/phy/nr/sf_worker.cc @@ -84,7 +84,8 @@ void sf_worker::work_imp() tx_buffer.set(0, prach_ptr); // Notify MAC about PRACH transmission - phy_state->stack->prach_sent(TTI_TX(tti_rx), 7, 1, 0, 0); + phy_state->stack->prach_sent( + TTI_TX(tti_rx), 0, SRSRAN_SLOT_NR_MOD(phy_state->carrier.numerology, TTI_TX(tti_rx)), 0, 0); // Transmit NR PRACH phy->worker_end(this, false, tx_buffer, dummy_ts, true); diff --git a/srsue/src/phy/nr/worker_pool.cc b/srsue/src/phy/nr/worker_pool.cc index a821299cf..7bf9c7c3e 100644 --- a/srsue/src/phy/nr/worker_pool.cc +++ b/srsue/src/phy/nr/worker_pool.cc @@ -55,15 +55,6 @@ bool worker_pool::init(const phy_args_nr_t& args, phy_common* common, stack_inte prach_buffer = std::unique_ptr(new prach(prach_log)); prach_buffer->init(phy_state.args.dl.nof_max_prb); - // Set PRACH hard-coded cell - srsran_cell_t cell = {}; - cell.nof_prb = 50; - cell.id = phy_state.carrier.id; - if (not prach_buffer->set_cell(cell, phy_state.cfg.prach)) { - prach_log.error("Setting PRACH cell"); - return false; - } - return true; } @@ -130,6 +121,16 @@ int worker_pool::set_ul_grant(std::array pac bool worker_pool::set_config(const srsran::phy_cfg_nr_t& cfg) { phy_state.cfg = cfg; + + // Set PRACH hard-coded cell + srsran_cell_t cell = {}; + cell.nof_prb = 50; + cell.id = phy_state.carrier.id; + if (not prach_buffer->set_cell(cell, phy_state.cfg.prach)) { + logger.error("Error setting PRACH cell"); + return false; + } + return true; } diff --git a/srsue/src/stack/rrc/rrc_nr.cc b/srsue/src/stack/rrc/rrc_nr.cc index 836805994..dadc003fd 100644 --- a/srsue/src/stack/rrc/rrc_nr.cc +++ b/srsue/src/stack/rrc/rrc_nr.cc @@ -734,6 +734,13 @@ bool rrc_nr::apply_ul_common_cfg(const asn1::rrc_nr::ul_cfg_common_s& ul_cfg_com rach_nr_cfg_t rach_nr_cfg = make_mac_rach_cfg(ul_cfg_common.init_ul_bwp.rach_cfg_common.setup()); phy_cfg.pdcch.ra_rnti = ul_cfg_common.init_ul_bwp.rach_cfg_common.setup().rach_cfg_generic.prach_cfg_idx; mac->set_config(rach_nr_cfg); + + // Make the RACH configuration for PHY + if (not make_phy_rach_cfg(ul_cfg_common.init_ul_bwp.rach_cfg_common.setup(), &phy_cfg.prach)) { + logger.warning("Error parsing rach_cfg_common"); + return false; + } + } else { logger.warning("Option rach_cfg_common not of type setup"); return false; @@ -882,7 +889,6 @@ bool rrc_nr::apply_sp_cell_ded_ul_pusch(const asn1::rrc_nr::pusch_cfg_s& pusch_c } else { logger.warning("Option dmrs_ul_for_pusch_map_type_a not of type setup"); return false; - return false; } } else { logger.warning("Option dmrs_ul_for_pusch_map_type_a not present"); From bde7b49ca3a67b10c2cddd5dd5cb3b5feb43da0d Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Thu, 25 Mar 2021 14:20:52 +0100 Subject: [PATCH 42/48] ue,mac_nr: add basic SR procedure the current implementation support only one SR config and doesn't support the prohibit timer --- .../srsran/interfaces/mac_interface_types.h | 14 ++ .../srsran/interfaces/ue_nr_interfaces.h | 9 +- srsue/hdr/stack/mac_nr/mac_nr.h | 16 ++- srsue/hdr/stack/mac_nr/proc_ra_nr.h | 1 + srsue/hdr/stack/mac_nr/proc_sr_nr.h | 57 ++++++++ srsue/src/stack/mac_nr/CMakeLists.txt | 2 +- srsue/src/stack/mac_nr/mac_nr.cc | 15 ++- srsue/src/stack/mac_nr/proc_ra_nr.cc | 12 ++ srsue/src/stack/mac_nr/proc_sr_nr.cc | 125 ++++++++++++++++++ srsue/src/stack/rrc/rrc_nr.cc | 20 ++- 10 files changed, 248 insertions(+), 23 deletions(-) create mode 100644 srsue/hdr/stack/mac_nr/proc_sr_nr.h create mode 100644 srsue/src/stack/mac_nr/proc_sr_nr.cc diff --git a/lib/include/srsran/interfaces/mac_interface_types.h b/lib/include/srsran/interfaces/mac_interface_types.h index 2cf7940a2..836330366 100644 --- a/lib/include/srsran/interfaces/mac_interface_types.h +++ b/lib/include/srsran/interfaces/mac_interface_types.h @@ -136,6 +136,20 @@ struct rach_nr_cfg_t { } }; +// 38.321 Section 5.4.4 (only one config supported right now) +struct sr_cfg_item_nr_t { + uint8_t sched_request_id; + uint8_t prohibit_timer; + uint8_t trans_max; +}; + +#define SRSRAN_MAX_MAX_NR_OF_SR_CFG_PER_CELL_GROUP (8) +struct sr_cfg_nr_t { + bool enabled; + uint8_t num_items; + sr_cfg_item_nr_t item[SRSRAN_MAX_MAX_NR_OF_SR_CFG_PER_CELL_GROUP]; +}; + struct mac_cfg_t { // Default constructor with default values as in 36.331 9.2.2 mac_cfg_t() { set_defaults(); } diff --git a/lib/include/srsran/interfaces/ue_nr_interfaces.h b/lib/include/srsran/interfaces/ue_nr_interfaces.h index 34db1f4ad..bada51663 100644 --- a/lib/include/srsran/interfaces/ue_nr_interfaces.h +++ b/lib/include/srsran/interfaces/ue_nr_interfaces.h @@ -98,10 +98,11 @@ public: class mac_interface_rrc_nr { public: - virtual void setup_lcid(const srsran::logical_channel_config_t& config) = 0; - virtual void set_config(const srsran::bsr_cfg_t& bsr_cfg) = 0; - virtual void set_config(const srsran::sr_cfg_t& sr_cfg) = 0; - virtual void set_config(const srsran::rach_nr_cfg_t& rach_cfg) = 0; + // Config calls that return SRSRAN_SUCCESS or SRSRAN_ERROR + virtual void setup_lcid(const srsran::logical_channel_config_t& config) = 0; + virtual void set_config(const srsran::bsr_cfg_t& bsr_cfg) = 0; + virtual int32_t set_config(const srsran::sr_cfg_nr_t& sr_cfg) = 0; + virtual void set_config(const srsran::rach_nr_cfg_t& rach_cfg) = 0; // RRC triggers MAC ra procedure virtual void start_ra_procedure() = 0; diff --git a/srsue/hdr/stack/mac_nr/mac_nr.h b/srsue/hdr/stack/mac_nr/mac_nr.h index 465b923db..40f2e00ac 100644 --- a/srsue/hdr/stack/mac_nr/mac_nr.h +++ b/srsue/hdr/stack/mac_nr/mac_nr.h @@ -15,6 +15,7 @@ #include "mac_nr_interfaces.h" #include "proc_ra_nr.h" +#include "proc_sr_nr.h" #include "srsran/common/block_queue.h" #include "srsran/common/mac_pcap.h" #include "srsran/interfaces/mac_interface_types.h" @@ -66,13 +67,13 @@ public: void get_metrics(mac_metrics_t* metrics); /// Interface for RRC (RRC -> MAC) - void setup_lcid(const srsran::logical_channel_config_t& config); - void set_config(const srsran::bsr_cfg_t& bsr_cfg); - void set_config(const srsran::sr_cfg_t& sr_cfg); - void set_config(const srsran::rach_nr_cfg_t& rach_cfg); - void set_contention_id(const uint64_t ue_identity); - bool set_crnti(const uint16_t crnti); - void start_ra_procedure(); + void setup_lcid(const srsran::logical_channel_config_t& config); + void set_config(const srsran::bsr_cfg_t& bsr_cfg); + int32_t set_config(const srsran::sr_cfg_nr_t& sr_cfg); + void set_config(const srsran::rach_nr_cfg_t& rach_cfg); + void set_contention_id(const uint64_t ue_identity); + bool set_crnti(const uint16_t crnti); + void start_ra_procedure(); /// procedure ra nr interface uint64_t get_contention_id(); @@ -144,6 +145,7 @@ private: // MAC Uplink-related procedures proc_ra_nr proc_ra; + proc_sr_nr proc_sr; mux_nr mux; }; diff --git a/srsue/hdr/stack/mac_nr/proc_ra_nr.h b/srsue/hdr/stack/mac_nr/proc_ra_nr.h index 726313514..88feb0f57 100644 --- a/srsue/hdr/stack/mac_nr/proc_ra_nr.h +++ b/srsue/hdr/stack/mac_nr/proc_ra_nr.h @@ -47,6 +47,7 @@ public: void pdcch_to_crnti(); void start_by_rrc(); + void start_by_mac(); void reset(); private: diff --git a/srsue/hdr/stack/mac_nr/proc_sr_nr.h b/srsue/hdr/stack/mac_nr/proc_sr_nr.h new file mode 100644 index 000000000..12dee8275 --- /dev/null +++ b/srsue/hdr/stack/mac_nr/proc_sr_nr.h @@ -0,0 +1,57 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +#ifndef SRSUE_PROC_SR_NR_H +#define SRSUE_PROC_SR_NR_H + +#include "srsran/interfaces/ue_mac_interfaces.h" +#include "srsran/srslog/srslog.h" +#include + +/// Scheduling Request procedure as defined in 5.4.4 of 38.321 +/// Note: currently only a single SR config for all logical channels is supported + +namespace srsue { + +class proc_ra_nr; +class phy_interface_mac_nr; +class rrc_interface_mac; + +class proc_sr_nr +{ +public: + explicit proc_sr_nr(srslog::basic_logger& logger); + int32_t init(proc_ra_nr* ra_, phy_interface_mac_nr* phy_, rrc_interface_mac* rrc_); + void step(uint32_t tti); + int32_t set_config(const srsran::sr_cfg_nr_t& cfg); + void reset(); + void start(); + +private: + bool need_tx(uint32_t tti); + + int sr_counter = 0; + bool is_pending_sr = 0; + + srsran::sr_cfg_nr_t cfg = {}; + + proc_ra_nr* ra = nullptr; + rrc_interface_mac* rrc = nullptr; + phy_interface_mac_nr* phy = nullptr; + srslog::basic_logger& logger; + + bool initiated = false; +}; + +} // namespace srsue + +#endif // SRSUE_PROC_SR_H diff --git a/srsue/src/stack/mac_nr/CMakeLists.txt b/srsue/src/stack/mac_nr/CMakeLists.txt index d051c0d1a..90ccea98c 100644 --- a/srsue/src/stack/mac_nr/CMakeLists.txt +++ b/srsue/src/stack/mac_nr/CMakeLists.txt @@ -6,6 +6,6 @@ # the distribution. # -set(SOURCES mac_nr.cc proc_ra_nr.cc mux_nr.cc) +set(SOURCES mac_nr.cc proc_ra_nr.cc proc_sr_nr.cc mux_nr.cc) add_library(srsue_mac_nr STATIC ${SOURCES}) target_link_libraries(srsue_mac_nr srsran_mac) \ No newline at end of file diff --git a/srsue/src/stack/mac_nr/mac_nr.cc b/srsue/src/stack/mac_nr/mac_nr.cc index e28ea60ab..f84f69b4a 100644 --- a/srsue/src/stack/mac_nr/mac_nr.cc +++ b/srsue/src/stack/mac_nr/mac_nr.cc @@ -17,9 +17,13 @@ namespace srsue { mac_nr::mac_nr(srsran::ext_task_sched_handle task_sched_) : - task_sched(task_sched_), logger(srslog::fetch_basic_logger("MAC")), proc_ra(logger), mux(logger), pcap(nullptr) -{ -} + task_sched(task_sched_), + logger(srslog::fetch_basic_logger("MAC")), + proc_ra(logger), + proc_sr(logger), + mux(logger), + pcap(nullptr) +{} mac_nr::~mac_nr() { @@ -307,10 +311,9 @@ void mac_nr::set_config(const srsran::bsr_cfg_t& bsr_cfg) logger.warning("Not handling BSR config yet"); } -void mac_nr::set_config(const srsran::sr_cfg_t& sr_cfg) +int32_t mac_nr::set_config(const srsran::sr_cfg_nr_t& sr_cfg) { - logger.info("Scheduling Request Config DSR tansmax %d", sr_cfg.dsr_transmax); - logger.warning("Not Scheduling Request Config yet"); + return proc_sr.set_config(sr_cfg); } void mac_nr::set_config(const srsran::rach_nr_cfg_t& rach_cfg) diff --git a/srsue/src/stack/mac_nr/proc_ra_nr.cc b/srsue/src/stack/mac_nr/proc_ra_nr.cc index 024d1787f..b67c80e92 100644 --- a/srsue/src/stack/mac_nr/proc_ra_nr.cc +++ b/srsue/src/stack/mac_nr/proc_ra_nr.cc @@ -74,6 +74,18 @@ void proc_ra_nr::start_by_rrc() ra_procedure_initialization(); } +void proc_ra_nr::start_by_mac() +{ + if (state != IDLE || configured == false) { + logger.warning("Trying to start PRACH by MAC order in invalid state (%s)", + srsran::enum_to_text(state_str_nr, (uint32_t)ra_state_t::MAX_RA_STATES, state)); + return; + } + started_by = initiators_t::MAC; + logger.info("Starting PRACH by MAC order"); + ra_procedure_initialization(); +} + bool proc_ra_nr::is_rar_opportunity(uint32_t tti) { // TODO replace second "&&"" by rar_timeout_timer.running if timer thread safe and delayed starting (tti+3) diff --git a/srsue/src/stack/mac_nr/proc_sr_nr.cc b/srsue/src/stack/mac_nr/proc_sr_nr.cc new file mode 100644 index 000000000..e40e1a8ac --- /dev/null +++ b/srsue/src/stack/mac_nr/proc_sr_nr.cc @@ -0,0 +1,125 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +#include "srsue/hdr/stack/mac_nr/proc_sr_nr.h" +#include "srsran/common/standard_streams.h" +#include "srsran/interfaces/ue_phy_interfaces.h" +#include "srsran/interfaces/ue_rrc_interfaces.h" +#include "srsue/hdr/stack/mac_nr/proc_ra_nr.h" + +namespace srsue { + +proc_sr_nr::proc_sr_nr(srslog::basic_logger& logger) : logger(logger) {} + +int32_t proc_sr_nr::init(proc_ra_nr* ra_, phy_interface_mac_nr* phy_, rrc_interface_mac* rrc_) +{ + rrc = rrc_; + ra = ra_; + phy = phy_; + initiated = true; + sr_counter = 0; + return SRSRAN_SUCCESS; +} + +void proc_sr_nr::reset() +{ + is_pending_sr = false; +} + +bool proc_sr_nr::need_tx(uint32_t tti) +{ + int last_tx_tti = 0; // FIXME: phy->sr_last_tx_tti(); + logger.debug("SR: need_tx(): last_tx_tti=%d, tti=%d", last_tx_tti, tti); + if (last_tx_tti >= 0) { + // TODO: implement prohibit timer + if (TTI_SUB(last_tx_tti, tti) >= 8) { + return true; + } + } + return false; +} + +int32_t proc_sr_nr::set_config(const srsran::sr_cfg_nr_t& cfg_) +{ + // disable by default + cfg.enabled = false; + + if (cfg_.num_items != 1) { + logger.error("Only one SR config supported. Disabling SR."); + return SRSRAN_ERROR; + } + + if (cfg_.enabled && cfg_.item[0].trans_max == 0) { + logger.error("Zero is an invalid value for sr-TransMax (n4, n8, n16, n32, n64 are supported). Disabling SR."); + return SRSRAN_ERROR; + } + + if (cfg_.enabled && cfg_.item[0].prohibit_timer > 0) { + logger.error("sr-ProhibitTimer isn't supported. Disabling SR."); + return SRSRAN_ERROR; + } + + if (cfg_.enabled) { + logger.info("SR: Set sr-TransMax=%d", cfg_.item[0].trans_max); + } + + // store config + cfg = cfg_; + + return SRSRAN_SUCCESS; +} + +void proc_sr_nr::step(uint32_t tti) +{ + if (initiated) { + if (is_pending_sr) { + if (cfg.enabled) { + if (sr_counter < cfg.item[0].trans_max) { + if (sr_counter == 0 || need_tx(tti)) { + sr_counter++; + logger.info("SR: Signalling PHY sr_counter=%d", sr_counter); + phy->sr_send(0); // @xavierarteaga what is the ID you expect here? + } + } else { + if (need_tx(tti)) { + logger.info("SR: Releasing PUCCH/SRS resources, sr_counter=%d, sr-TransMax=%d", + sr_counter, + cfg.item[0].trans_max); + srsran::console("Scheduling request failed: releasing RRC connection...\n"); + rrc->release_pucch_srs(); + // TODO: + // - clear any configured downlink assignments and uplink grants; + // - clear any PUSCH resources for semi-persistent CSI reporting; + ra->start_by_mac(); + reset(); + } + } + } else { + logger.info("SR: PUCCH not configured. Starting RA procedure"); + ra->start_by_mac(); + reset(); + } + } + } +} + +void proc_sr_nr::start() +{ + if (initiated) { + if (!is_pending_sr) { + sr_counter = 0; + is_pending_sr = true; + } + } +} + +} // namespace srsue diff --git a/srsue/src/stack/rrc/rrc_nr.cc b/srsue/src/stack/rrc/rrc_nr.cc index dadc003fd..240a4e80c 100644 --- a/srsue/src/stack/rrc/rrc_nr.cc +++ b/srsue/src/stack/rrc/rrc_nr.cc @@ -527,14 +527,24 @@ bool rrc_nr::apply_rlc_add_mod(const rlc_bearer_cfg_s& rlc_bearer_cfg) bool rrc_nr::apply_mac_cell_group(const mac_cell_group_cfg_s& mac_cell_group_cfg) { if (mac_cell_group_cfg.sched_request_cfg_present) { - sr_cfg_t sr_cfg; if (mac_cell_group_cfg.sched_request_cfg.sched_request_to_add_mod_list_present) { - if (mac_cell_group_cfg.sched_request_cfg.sched_request_to_add_mod_list.size() > 1) { + if (mac_cell_group_cfg.sched_request_cfg.sched_request_to_add_mod_list.size() == 1) { + const sched_request_to_add_mod_s& asn1_cfg = + mac_cell_group_cfg.sched_request_cfg.sched_request_to_add_mod_list[0]; + sr_cfg_nr_t sr_cfg = {}; + sr_cfg.num_items = 1; + sr_cfg.item[0].sched_request_id = asn1_cfg.sched_request_id; + sr_cfg.item[0].trans_max = asn1_cfg.sr_trans_max.to_number(); + if (asn1_cfg.sr_prohibit_timer_present) { + sr_cfg.item[0].prohibit_timer = asn1_cfg.sr_trans_max; + } + if (mac->set_config(sr_cfg) != SRSRAN_SUCCESS) { + logger.error("Couldn't configure SR procedure."); + return false; + } + } else { logger.warning("Only handling 1 scheduling request index to add"); return false; - } else { - sr_cfg.dsr_transmax = mac_cell_group_cfg.sched_request_cfg.sched_request_to_add_mod_list[1].sr_trans_max; - mac->set_config(sr_cfg); } } From e2c7809abb6ddb121b38a94d4bee3353a83a9c0b Mon Sep 17 00:00:00 2001 From: faluco Date: Thu, 25 Mar 2021 12:19:33 +0100 Subject: [PATCH 43/48] - Introduce a new tracer scoped object that only records if the event duration exceeds the programmed threshold. --- lib/include/srsran/srslog/event_trace.h | 27 ++++++++++++++++--------- lib/src/srslog/event_trace.cpp | 12 +++++++---- lib/test/srslog/event_trace_test.cpp | 26 ++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 14 deletions(-) diff --git a/lib/include/srsran/srslog/event_trace.h b/lib/include/srsran/srslog/event_trace.h index f08fe86c7..8fcfd9e49 100644 --- a/lib/include/srsran/srslog/event_trace.h +++ b/lib/include/srsran/srslog/event_trace.h @@ -40,8 +40,7 @@ void event_trace_init(log_channel& c); /// The event trace data will be written into the specified filename after /// capacity bytes of data have been generated or at program exit. /// Returns true on success, otherwise false. -bool event_trace_init(const std::string& filename, - std::size_t capacity = 1024 * 1024); +bool event_trace_init(const std::string& filename, std::size_t capacity = 1024 * 1024); #ifdef ENABLE_SRSLOG_EVENT_TRACE @@ -51,12 +50,16 @@ void trace_duration_begin(const std::string& category, const std::string& name); /// Generates the end phase of a duration event. void trace_duration_end(const std::string& category, const std::string& name); -/// Generates a complete event. #define SRSLOG_TRACE_COMBINE1(X, Y) X##Y #define SRSLOG_TRACE_COMBINE(X, Y) SRSLOG_TRACE_COMBINE1(X, Y) -#define trace_complete_event(C, N) \ - auto SRSLOG_TRACE_COMBINE(scoped_complete_event, __LINE__) = \ - srslog::detail::scoped_complete_event(C, N) + +/// Generates a complete event. +#define trace_complete_event(C, N) \ + auto SRSLOG_TRACE_COMBINE(scoped_complete_event, __LINE__) = srslog::detail::scoped_complete_event(C, N) + +/// Generates a complete event but only is recorded if the event duration exceeds a certain threshold in microseconds. +#define trace_threshold_complete_event(C, N, T) \ + auto SRSLOG_TRACE_COMBINE(scoped_complete_event, __LINE__) = srslog::detail::scoped_complete_event(C, N, T) #else @@ -64,6 +67,7 @@ void trace_duration_end(const std::string& category, const std::string& name); #define trace_duration_begin(C, N) #define trace_duration_end(C, N) #define trace_complete_event(C, N) +#define trace_threshold_complete_event(C, N, T) #endif @@ -73,16 +77,19 @@ namespace detail { class scoped_complete_event { public: - scoped_complete_event(const char* cat, const char* n) : - category(cat), name(n), start(std::chrono::steady_clock::now()) + scoped_complete_event(const char* cat, + const char* n, + std::chrono::microseconds threshold = std::chrono::microseconds::zero()) : + category(cat), name(n), start(std::chrono::steady_clock::now()), threshold(threshold) {} ~scoped_complete_event(); private: - const char* const category; - const char* const name; + const char* const category; + const char* const name; std::chrono::time_point start; + std::chrono::microseconds threshold; }; } // namespace detail diff --git a/lib/src/srslog/event_trace.cpp b/lib/src/srslog/event_trace.cpp index 7d84f018c..cb5cdae48 100644 --- a/lib/src/srslog/event_trace.cpp +++ b/lib/src/srslog/event_trace.cpp @@ -118,12 +118,16 @@ srslog::detail::scoped_complete_event::~scoped_complete_event() return; } - auto end = std::chrono::steady_clock::now(); - unsigned long long diff = std::chrono::duration_cast(end - start).count(); + auto end = std::chrono::steady_clock::now(); + auto diff = std::chrono::duration_cast(end - start); + + if (diff < threshold) { + return; + } small_str_buffer str; - // Limit to the category and name strings to a predefined length so everything fits in a small string. - fmt::format_to(str, "{:.32} {:.16}, {}", category, name, diff); + // Limit the category and name strings to a predefined length so everything fits in a small string. + fmt::format_to(str, "{:.32} {:.16}, {}", category, name, diff.count()); str.push_back('\0'); (*tracer)(std::move(str)); } diff --git a/lib/test/srslog/event_trace_test.cpp b/lib/test/srslog/event_trace_test.cpp index 173089960..d55648e08 100644 --- a/lib/test/srslog/event_trace_test.cpp +++ b/lib/test/srslog/event_trace_test.cpp @@ -14,6 +14,7 @@ #include "srsran/srslog/log_channel.h" #include "test_dummies.h" #include "testing_helpers.h" +#include using namespace srslog; @@ -68,6 +69,27 @@ static bool when_tracing_with_complete_event_then_one_event_is_generated(backend return true; } +static bool when_tracing_with_under_threshold_complete_event_then_no_event_is_generated(backend_spy& spy) +{ + { + trace_threshold_complete_event("a", "b", std::chrono::microseconds(100000)); + } + ASSERT_EQ(spy.push_invocation_count(), 0); + + return true; +} + +static bool when_tracing_with_above_threshold_complete_event_then_one_event_is_generated(backend_spy& spy) +{ + { + trace_threshold_complete_event("a", "b", std::chrono::microseconds(10)); + std::this_thread::sleep_for(std::chrono::microseconds(1000)); + } + ASSERT_EQ(spy.push_invocation_count(), 1); + + return true; +} + int main() { test_dummies::sink_dummy s; @@ -80,6 +102,10 @@ int main() TEST_FUNCTION(when_tracing_with_duration_event_then_two_events_are_generated, backend); backend.reset(); TEST_FUNCTION(when_tracing_with_complete_event_then_one_event_is_generated, backend); + backend.reset(); + TEST_FUNCTION(when_tracing_with_under_threshold_complete_event_then_no_event_is_generated, backend); + backend.reset(); + TEST_FUNCTION(when_tracing_with_above_threshold_complete_event_then_one_event_is_generated, backend); return 0; } From 8e48467a3000797b6eaed71bf94e576c43cbceda Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Thu, 25 Mar 2021 13:05:43 +0000 Subject: [PATCH 44/48] Make sure that meas_report_desc is present if ho_active == true in rr.conf --- srsenb/src/enb_cfg_parser.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/srsenb/src/enb_cfg_parser.cc b/srsenb/src/enb_cfg_parser.cc index a704c3a93..cc55e202d 100644 --- a/srsenb/src/enb_cfg_parser.cc +++ b/srsenb/src/enb_cfg_parser.cc @@ -747,6 +747,10 @@ static int parse_cell_list(all_args_t* args, rrc_cfg_t* rrc_cfg, Setting& root) if (cellroot.exists("ho_active") and cellroot["ho_active"]) { HANDLEPARSERCODE(parse_meas_cell_list(&cell_cfg.meas_cfg, cellroot["meas_cell_list"])); + if (not cellroot.exists("meas_report_desc")) { + ERROR("PARSER ERROR: \"ho_active\" is set to true, but field \"meas_report_desc\" doesn't exist.\n"); + return -1; + } HANDLEPARSERCODE(parse_meas_report_desc(&cell_cfg.meas_cfg, cellroot["meas_report_desc"])); } From 838d5ac0f40b36150709fe142f579885f468acb3 Mon Sep 17 00:00:00 2001 From: David Rupprecht Date: Fri, 26 Mar 2021 10:47:58 +0100 Subject: [PATCH 45/48] Added description for using the same filename for mac and mac_nr pcap --- srsue/ue.conf.example | 2 ++ 1 file changed, 2 insertions(+) diff --git a/srsue/ue.conf.example b/srsue/ue.conf.example index 9b329182d..b9ac0e85c 100644 --- a/srsue/ue.conf.example +++ b/srsue/ue.conf.example @@ -63,6 +63,8 @@ tx_gain = 80 # Protocol=udp. Further, enable the heuristic dissection in UDP under: # Analyze > Enabled Protocols > MAC-LTE > mac_lte_udp and MAC-NR > mac_nr_udp # For more information see: https://wiki.wireshark.org/MAC-LTE +# Using the same filename for mac_filename and mac_nr_filename writes both +# MAC-LTE and MAC-NR to the same file allowing a better analysis. # NAS-layer packets are dissected with DLT=148, and Protocol = nas-eps. # # enable: Enable packet captures of layers (mac/mac_nr/nas/none) multiple option list From b944528a4fc3e36c2470027c08eed9c7f262529e Mon Sep 17 00:00:00 2001 From: David Rupprecht Date: Thu, 25 Mar 2021 13:41:00 +0100 Subject: [PATCH 46/48] Install srslog to system folder --- lib/src/srslog/CMakeLists.txt | 18 +++++++++++++++--- lib/src/srslog/bundled/fmt/CMakeLists.txt | 14 -------------- lib/src/srslog/formatters/CMakeLists.txt | 13 ------------- 3 files changed, 15 insertions(+), 30 deletions(-) delete mode 100644 lib/src/srslog/bundled/fmt/CMakeLists.txt delete mode 100644 lib/src/srslog/formatters/CMakeLists.txt diff --git a/lib/src/srslog/CMakeLists.txt b/lib/src/srslog/CMakeLists.txt index 7800e8c3a..794285555 100644 --- a/lib/src/srslog/CMakeLists.txt +++ b/lib/src/srslog/CMakeLists.txt @@ -12,10 +12,22 @@ set(SOURCES srslog_c.cpp event_trace.cpp) -add_subdirectory(bundled/fmt) -add_subdirectory(formatters) +include_directories(${PROJECT_SOURCE_DIR}/lib/include/srsran/srslog/bundled/) +include_directories(${PROJECT_SOURCE_DIR}/lib/include/srsran/srslog/formatters) + +set(SOURCES + ${SOURCES} + ${CMAKE_CURRENT_SOURCE_DIR}/bundled/fmt/format.cc + ${CMAKE_CURRENT_SOURCE_DIR}/bundled/fmt/os.cc) + +set(SOURCES + ${SOURCES} + ${CMAKE_CURRENT_SOURCE_DIR}/formatters/json_formatter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/formatters/text_formatter.cpp) + find_package(Threads REQUIRED) add_library(srslog STATIC ${SOURCES}) -target_link_libraries(srslog formatters fmt "${CMAKE_THREAD_LIBS_INIT}") +target_link_libraries(srslog ${CMAKE_THREAD_LIBS_INIT}) +INSTALL(TARGETS srslog DESTINATION ${LIBRARY_DIR}) diff --git a/lib/src/srslog/bundled/fmt/CMakeLists.txt b/lib/src/srslog/bundled/fmt/CMakeLists.txt deleted file mode 100644 index e1a92ee3a..000000000 --- a/lib/src/srslog/bundled/fmt/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -# -# Copyright 2013-2021 Software Radio Systems Limited -# -# By using this file, you agree to the terms and conditions set -# forth in the LICENSE file which can be found at the top level of -# the distribution. -# - -set(SOURCES - format.cc - os.cc) - -add_library(fmt STATIC ${SOURCES}) -target_include_directories(fmt PUBLIC ../../../../include/srsran/srslog/bundled) diff --git a/lib/src/srslog/formatters/CMakeLists.txt b/lib/src/srslog/formatters/CMakeLists.txt deleted file mode 100644 index 7d35370d2..000000000 --- a/lib/src/srslog/formatters/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -# -# Copyright 2013-2021 Software Radio Systems Limited -# -# By using this file, you agree to the terms and conditions set -# forth in the LICENSE file which can be found at the top level of -# the distribution. -# - -set(SOURCES - json_formatter.cpp - text_formatter.cpp) - -add_library(formatters STATIC ${SOURCES}) From ca7a38a2ba5cb357ed0dd12a9311e3cbc30f29d3 Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Thu, 25 Mar 2021 10:46:31 +0000 Subject: [PATCH 47/48] Remove old context in eNB's RRC if new connection request arrives with the same TMSI --- srsenb/src/stack/rrc/rrc.cc | 2 +- srsenb/src/stack/rrc/rrc_ue.cc | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/srsenb/src/stack/rrc/rrc.cc b/srsenb/src/stack/rrc/rrc.cc index 18bb26956..253aafb46 100644 --- a/srsenb/src/stack/rrc/rrc.cc +++ b/srsenb/src/stack/rrc/rrc.cc @@ -820,7 +820,7 @@ uint32_t rrc::generate_sibs() logger.error("Couldn't allocate PDU in %s().", __FUNCTION__); return SRSRAN_ERROR; } - asn1::bit_ref bref(sib_buffer->msg, sib_buffer->get_tailroom()); + asn1::bit_ref bref(sib_buffer->msg, sib_buffer->get_tailroom()); if (msg[msg_index].pack(bref) == asn1::SRSASN_ERROR_ENCODE_FAIL) { logger.error("Failed to pack SIB message %d", msg_index); return SRSRAN_ERROR; diff --git a/srsenb/src/stack/rrc/rrc_ue.cc b/srsenb/src/stack/rrc/rrc_ue.cc index 3007f5f8b..5ff2a0f79 100644 --- a/srsenb/src/stack/rrc/rrc_ue.cc +++ b/srsenb/src/stack/rrc/rrc_ue.cc @@ -299,7 +299,18 @@ void rrc::ue::handle_rrc_con_req(rrc_conn_request_s* msg) mmec = (uint8_t)msg_r8->ue_id.s_tmsi().mmec.to_number(); m_tmsi = (uint32_t)msg_r8->ue_id.s_tmsi().m_tmsi.to_number(); has_tmsi = true; + + // Make sure that the context does not already exist + for (auto ue_it = parent->users.begin(); ue_it != parent->users.end(); ue_it++) { + if (ue_it->first != rnti && ue_it->second->has_tmsi && ue_it->second->mmec == mmec && + ue_it->second->m_tmsi == m_tmsi) { + parent->logger.info("RRC connection request: UE context already exists. M-TMSI=%d", m_tmsi); + parent->rem_user_thread(ue_it->first); // Simply remove the old context. No need to notify the MME, it will + // update the eNB/MME-UE S1AP Id pair. + } + } } + establishment_cause = msg_r8->establishment_cause; send_connection_setup(); state = RRC_STATE_WAIT_FOR_CON_SETUP_COMPLETE; @@ -756,7 +767,7 @@ bool rrc::ue::handle_ue_cap_info(ue_cap_info_s* msg) parent->logger.error("Couldn't allocate PDU in %s().", __FUNCTION__); return false; } - asn1::bit_ref bref2{pdu->msg, pdu->get_tailroom()}; + asn1::bit_ref bref2{pdu->msg, pdu->get_tailroom()}; msg->pack(bref2); asn1::rrc::ue_radio_access_cap_info_s ue_rat_caps; auto& dest = ue_rat_caps.crit_exts.set_c1().set_ue_radio_access_cap_info_r8().ue_radio_access_cap_info; From a5229a02d1a3ba0c43b4043d4a5c52c9881720cc Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Thu, 25 Mar 2021 19:26:42 +0000 Subject: [PATCH 48/48] Make sure RRC identity is set when NAS reads UE context from file. --- srsenb/src/stack/rrc/rrc_ue.cc | 1 + srsue/src/stack/rrc/rrc.cc | 2 -- srsue/src/stack/rrc/rrc_procedures.cc | 4 +++- srsue/src/stack/upper/nas.cc | 6 ++++++ 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/srsenb/src/stack/rrc/rrc_ue.cc b/srsenb/src/stack/rrc/rrc_ue.cc index 5ff2a0f79..20fd22a55 100644 --- a/srsenb/src/stack/rrc/rrc_ue.cc +++ b/srsenb/src/stack/rrc/rrc_ue.cc @@ -307,6 +307,7 @@ void rrc::ue::handle_rrc_con_req(rrc_conn_request_s* msg) parent->logger.info("RRC connection request: UE context already exists. M-TMSI=%d", m_tmsi); parent->rem_user_thread(ue_it->first); // Simply remove the old context. No need to notify the MME, it will // update the eNB/MME-UE S1AP Id pair. + break; } } } diff --git a/srsue/src/stack/rrc/rrc.cc b/srsue/src/stack/rrc/rrc.cc index a802ffd27..27dc2cf52 100644 --- a/srsue/src/stack/rrc/rrc.cc +++ b/srsue/src/stack/rrc/rrc.cc @@ -137,8 +137,6 @@ void rrc::init(phy_interface_rrc_lte* phy_, t311 = task_sched.get_unique_timer(); t304 = task_sched.get_unique_timer(); - ue_identity_configured = false; - transaction_id = 0; cell_clean_cnt = 0; diff --git a/srsue/src/stack/rrc/rrc_procedures.cc b/srsue/src/stack/rrc/rrc_procedures.cc index cf9af1557..5290256f4 100644 --- a/srsue/src/stack/rrc/rrc_procedures.cc +++ b/srsue/src/stack/rrc/rrc_procedures.cc @@ -822,7 +822,9 @@ proc_outcome_t rrc::connection_request_proc::step() if (state == state_t::cell_selection) { // NOTE: cell selection will signal back with an event trigger return proc_outcome_t::yield; - } else if (state == state_t::config_serving_cell) { + } + + if (state == state_t::config_serving_cell) { if (rrc_ptr->serv_cell_cfg.run()) { return proc_outcome_t::yield; } diff --git a/srsue/src/stack/upper/nas.cc b/srsue/src/stack/upper/nas.cc index 153aa6398..d231f7af6 100644 --- a/srsue/src/stack/upper/nas.cc +++ b/srsue/src/stack/upper/nas.cc @@ -1885,6 +1885,7 @@ void nas::send_attach_request() logger.error("Couldn't allocate PDU in %s().", __FUNCTION__); return; } + gen_attach_request(pdu); rrc->write_sdu(std::move(pdu)); } @@ -2522,6 +2523,11 @@ bool nas::read_ctxt_file(nas_sec_ctxt* ctxt_) have_ctxt = true; current_sec_hdr = LIBLTE_MME_SECURITY_HDR_TYPE_INTEGRITY_AND_CIPHERED; + // Set UE identity in RRC + s_tmsi_t s_tmsi; + s_tmsi.mmec = ctxt.guti.mme_code; + s_tmsi.m_tmsi = ctxt.guti.m_tmsi; + rrc->set_ue_identity(s_tmsi); return true; } return false;